diff options
| -rw-r--r-- | solutions/py/d04.py | 6 | ||||
| -rw-r--r-- | solutions/py/d10.py | 9 | ||||
| -rw-r--r-- | solutions/py/d15.py | 2 | ||||
| -rw-r--r-- | solutions/py/d16.py | 24 | ||||
| -rw-r--r-- | solutions/py/main.py | 2 |
5 files changed, 14 insertions, 29 deletions
diff --git a/solutions/py/d04.py b/solutions/py/d04.py index 778b05e..c9bcbf3 100644 --- a/solutions/py/d04.py +++ b/solutions/py/d04.py @@ -25,7 +25,8 @@ def pt1(input): amount = 0 n = 357253 while n < 892942 + 1: - if (inc := isIncreasing(n))[0] == True: + inc = isIncreasing(n) + if inc[0] == True: if containsDouble(n): amount += 1 n += 1 @@ -46,7 +47,8 @@ def pt2(input): amount = 0 n = 357253 while n < 892942 + 1: - if (inc := isIncreasing(n))[0] == True: + inc = isIncreasing(n) + if inc[0] == True: if containsDouble(n): amount += 1 n += 1 diff --git a/solutions/py/d10.py b/solutions/py/d10.py index 008dbc3..0d918d9 100644 --- a/solutions/py/d10.py +++ b/solutions/py/d10.py @@ -63,7 +63,8 @@ def pt1(input): best = [0, 0, 0] for coord in res: - if (amount := len(res[coord])) > best[0]: + amount = len(res[coord]) + if amount > best[0]: best = [amount, coord, res[coord]] return (best[1], best[0]) @@ -106,7 +107,8 @@ def pt2(input): best = [0, 0, 0] for coord in res: - if (amount := len(res[coord])) > best[0]: + amount = len(res[coord]) + if amount > best[0]: best = [amount, coord, res[coord]] asteroids.remove(best[1]) x0 = best[1][0] @@ -207,7 +209,8 @@ def visualize(input): best = [0, 0, 0] for coord in res: - if (amount := len(res[coord])) > best[0]: + amount = len(res[coord]) + if amount > best[0]: best = [amount, coord, res[coord]] asteroids.remove(best[1]) x0 = best[1][0] diff --git a/solutions/py/d15.py b/solutions/py/d15.py index 9ee3f65..e1de236 100644 --- a/solutions/py/d15.py +++ b/solutions/py/d15.py @@ -250,7 +250,7 @@ def visualize(input): oxygen = (cur_x, cur_y) else: break - time.sleep(0.0075) + time.sleep(0.005) print(draw(board, droid=(cur_x, cur_y))) c.output = None c.SIG_OUTPUT = False diff --git a/solutions/py/d16.py b/solutions/py/d16.py index d08c856..93b52d2 100644 --- a/solutions/py/d16.py +++ b/solutions/py/d16.py @@ -4,7 +4,7 @@ def do(input, phases=100, repeats=1): nums += [int(x) for x in input[0].strip()] for phase in range(phases): - print(phase) + #print(phase) new_list = [] for i in range(len(nums)): # position of number to calculate new_num = 0 @@ -28,7 +28,7 @@ def pt2(input, phases=100, repeats=10000): nums += [int(x) for x in input[0].strip()] nums = nums[offset:] for phase in range(phases): - print(phase) + #print(phase) nums = nums[::-1] new_nums = [] n = sum(nums) @@ -38,29 +38,9 @@ def pt2(input, phases=100, repeats=10000): nums = new_nums return "".join([str(n) for n in nums[:8]]) -def square(size): - s = "" - for y in range(size): - for x in range(size): - mod = (x+1) % (4*(y+1)) - if mod < y+1: - s += "0" - elif mod < 2*y + 2: - s += "+" - elif mod < 3*y + 3: - s += "0" - else: - s += "-" - s += " " - s += "\n" - return s - if __name__ == "__main__": input = open("../input/16", "r").readlines() ans1 = pt1(input) ans2 = pt2(input) print(ans1) print(ans2) - #print(square(8)) - #print(square(20)) - #print(square(62)) diff --git a/solutions/py/main.py b/solutions/py/main.py index e454eb5..cc0f04c 100644 --- a/solutions/py/main.py +++ b/solutions/py/main.py @@ -21,7 +21,7 @@ import d17 mods = [d01, d02, d03, d04, d05, d06, d07, d08, d09, d10, \ d11, d12, d13, d14, d15, d16, d17] -skip = [16] +skip = [12, 16] timings = [[0 for _ in range(2)] for _ in range(len(mods))] clock_type = time.CLOCK_MONOTONIC |
