Add latest solutions
This commit is contained in:
parent
696dbfc739
commit
3850dba4ec
1
2015/01/input
Normal file
1
2015/01/input
Normal file
File diff suppressed because one or more lines are too long
12
2015/01/part01.py
Normal file
12
2015/01/part01.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = f.read()
|
||||||
|
|
||||||
|
solution = 0
|
||||||
|
|
||||||
|
for char in puzzle_input:
|
||||||
|
if char == "(":
|
||||||
|
solution += 1
|
||||||
|
else:
|
||||||
|
solution -= 1
|
||||||
|
|
||||||
|
print(solution)
|
18
2015/01/part02.py
Normal file
18
2015/01/part02.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = f.read()
|
||||||
|
|
||||||
|
floor = 0
|
||||||
|
position = 1
|
||||||
|
|
||||||
|
for char in puzzle_input:
|
||||||
|
if char == "(":
|
||||||
|
floor += 1
|
||||||
|
else:
|
||||||
|
floor -= 1
|
||||||
|
|
||||||
|
if floor == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
position += 1
|
||||||
|
|
||||||
|
print(position)
|
1000
2015/02/input
Normal file
1000
2015/02/input
Normal file
File diff suppressed because it is too large
Load Diff
15
2015/02/part01.py
Normal file
15
2015/02/part01.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
paper = 0
|
||||||
|
|
||||||
|
for present_dim in puzzle_input:
|
||||||
|
parsed_dim = [int(x) for x in present_dim.split("x")]
|
||||||
|
parsed_dim.sort()
|
||||||
|
print(parsed_dim)
|
||||||
|
|
||||||
|
[l, w, h] = parsed_dim
|
||||||
|
|
||||||
|
paper += 3 * l * w + 2 * w * h + 2 * h * l
|
||||||
|
|
||||||
|
print(paper)
|
14
2015/02/part02.py
Normal file
14
2015/02/part02.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
ribbon = 0
|
||||||
|
|
||||||
|
for present_dim in puzzle_input:
|
||||||
|
parsed_dim = [int(x) for x in present_dim.split("x")]
|
||||||
|
parsed_dim.sort()
|
||||||
|
|
||||||
|
[l, w, h] = parsed_dim
|
||||||
|
|
||||||
|
ribbon += 2 * l + 2 * w + l * w * h
|
||||||
|
|
||||||
|
print(ribbon)
|
1
2015/03/input
Normal file
1
2015/03/input
Normal file
File diff suppressed because one or more lines are too long
19
2015/03/part01.py
Normal file
19
2015/03/part01.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = f.read()
|
||||||
|
|
||||||
|
# puzzle_input = "^v^v^v^v^v"
|
||||||
|
|
||||||
|
coords = (0, 0)
|
||||||
|
delivered_houses = set()
|
||||||
|
delivered_houses.add(coords)
|
||||||
|
|
||||||
|
MOVEMENTS = {">": (1, 0), "^": (0, 1), "<": (-1, 0), "v": (0, -1)}
|
||||||
|
|
||||||
|
for char in puzzle_input:
|
||||||
|
[d_x, d_y] = MOVEMENTS[char]
|
||||||
|
coords = (coords[0] + d_x, coords[1] + d_y)
|
||||||
|
|
||||||
|
delivered_houses.add(coords)
|
||||||
|
|
||||||
|
print(delivered_houses)
|
||||||
|
print(len(delivered_houses))
|
27
2015/03/part02.py
Normal file
27
2015/03/part02.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = f.read()
|
||||||
|
|
||||||
|
# puzzle_input = "^v^v^v^v^v"
|
||||||
|
|
||||||
|
coords = (0, 0)
|
||||||
|
delivered_houses = set()
|
||||||
|
delivered_houses.add(coords)
|
||||||
|
|
||||||
|
MOVEMENTS = {">": (1, 0), "^": (0, 1), "<": (-1, 0), "v": (0, -1)}
|
||||||
|
|
||||||
|
SANTA_MOVES = puzzle_input[::2]
|
||||||
|
ROBO_MOVES = puzzle_input[1::2]
|
||||||
|
|
||||||
|
for char in SANTA_MOVES:
|
||||||
|
[d_x, d_y] = MOVEMENTS[char]
|
||||||
|
coords = (coords[0] + d_x, coords[1] + d_y)
|
||||||
|
delivered_houses.add(coords)
|
||||||
|
|
||||||
|
coords = (0, 0)
|
||||||
|
|
||||||
|
for char in ROBO_MOVES:
|
||||||
|
[d_x, d_y] = MOVEMENTS[char]
|
||||||
|
coords = (coords[0] + d_x, coords[1] + d_y)
|
||||||
|
delivered_houses.add(coords)
|
||||||
|
|
||||||
|
print(len(delivered_houses))
|
1
2015/04/input
Normal file
1
2015/04/input
Normal file
@ -0,0 +1 @@
|
|||||||
|
ckczppom
|
20
2015/04/part01.py
Normal file
20
2015/04/part01.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from hashlib import md5
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = f.read().strip()
|
||||||
|
|
||||||
|
# puzzle_input = "abcdef"
|
||||||
|
# puzzle_input = "pqrstuv"
|
||||||
|
|
||||||
|
solution = 0
|
||||||
|
|
||||||
|
cur_hash = ""
|
||||||
|
|
||||||
|
while cur_hash[:5] != "00000":
|
||||||
|
solution += 1
|
||||||
|
md5_input = puzzle_input + str(solution)
|
||||||
|
cur_hash = md5(md5_input.encode("utf-8")).hexdigest()
|
||||||
|
|
||||||
|
print(cur_hash)
|
||||||
|
print(puzzle_input)
|
||||||
|
print(solution)
|
20
2015/04/part02.py
Normal file
20
2015/04/part02.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from hashlib import md5
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = f.read().strip()
|
||||||
|
|
||||||
|
# puzzle_input = "abcdef"
|
||||||
|
# puzzle_input = "pqrstuv"
|
||||||
|
|
||||||
|
solution = 0
|
||||||
|
|
||||||
|
cur_hash = ""
|
||||||
|
|
||||||
|
while cur_hash[:6] != "000000":
|
||||||
|
solution += 1
|
||||||
|
md5_input = puzzle_input + str(solution)
|
||||||
|
cur_hash = md5(md5_input.encode("utf-8")).hexdigest()
|
||||||
|
|
||||||
|
print(cur_hash)
|
||||||
|
print(puzzle_input)
|
||||||
|
print(solution)
|
1000
2015/05/input
Normal file
1000
2015/05/input
Normal file
File diff suppressed because it is too large
Load Diff
46
2015/05/part01.py
Normal file
46
2015/05/part01.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
nice_words = 0
|
||||||
|
|
||||||
|
|
||||||
|
def has_three_or_more_vowels(word):
|
||||||
|
vowels = 0
|
||||||
|
for char in word:
|
||||||
|
if char in "aeiou":
|
||||||
|
vowels += 1
|
||||||
|
if vowels >= 3:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def has_letter_twice_in_a_row(word):
|
||||||
|
last = word[0]
|
||||||
|
for char in word[1:]:
|
||||||
|
if last == char:
|
||||||
|
return True
|
||||||
|
last = char
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def contains_bad_string(word):
|
||||||
|
BAD_STRINGS = ["ab", "cd", "pq", "xy"]
|
||||||
|
for bad_string in BAD_STRINGS:
|
||||||
|
if bad_string in word:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def is_nice_word(word):
|
||||||
|
return (
|
||||||
|
has_three_or_more_vowels(word)
|
||||||
|
and has_letter_twice_in_a_row(word)
|
||||||
|
and not contains_bad_string(word)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
for word in puzzle_input:
|
||||||
|
if is_nice_word(word):
|
||||||
|
nice_words += 1
|
||||||
|
|
||||||
|
print(nice_words)
|
36
2015/05/part02.py
Normal file
36
2015/05/part02.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
# puzzle_input = ["qjhvhtzxzqqjkmpb", "xxyxx", "uurcxstgmygtbstg", "ieodomkazucvgmuy"]
|
||||||
|
|
||||||
|
nice_words = 0
|
||||||
|
|
||||||
|
|
||||||
|
def has_duplicate_pair(word):
|
||||||
|
for idx_a in range(len(word) - 3):
|
||||||
|
for idx_b in range(idx_a + 2, len(word) - 1):
|
||||||
|
pair_1 = word[idx_a] + word[idx_a + 1]
|
||||||
|
pair_2 = word[idx_b] + word[idx_b + 1]
|
||||||
|
|
||||||
|
if pair_1 == pair_2:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def has_repeated_letter_with_one_between(word):
|
||||||
|
for idx, a in enumerate(word[:-2]):
|
||||||
|
b = word[idx + 2]
|
||||||
|
if a == b:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def is_nice_word(word):
|
||||||
|
return has_duplicate_pair(word) and has_repeated_letter_with_one_between(word)
|
||||||
|
|
||||||
|
|
||||||
|
for word in puzzle_input:
|
||||||
|
if is_nice_word(word):
|
||||||
|
nice_words += 1
|
||||||
|
|
||||||
|
print(nice_words)
|
300
2015/06/input
Normal file
300
2015/06/input
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
turn off 660,55 through 986,197
|
||||||
|
turn off 341,304 through 638,850
|
||||||
|
turn off 199,133 through 461,193
|
||||||
|
toggle 322,558 through 977,958
|
||||||
|
toggle 537,781 through 687,941
|
||||||
|
turn on 226,196 through 599,390
|
||||||
|
turn on 240,129 through 703,297
|
||||||
|
turn on 317,329 through 451,798
|
||||||
|
turn on 957,736 through 977,890
|
||||||
|
turn on 263,530 through 559,664
|
||||||
|
turn on 158,270 through 243,802
|
||||||
|
toggle 223,39 through 454,511
|
||||||
|
toggle 544,218 through 979,872
|
||||||
|
turn on 313,306 through 363,621
|
||||||
|
toggle 173,401 through 496,407
|
||||||
|
toggle 333,60 through 748,159
|
||||||
|
turn off 87,577 through 484,608
|
||||||
|
turn on 809,648 through 826,999
|
||||||
|
toggle 352,432 through 628,550
|
||||||
|
turn off 197,408 through 579,569
|
||||||
|
turn off 1,629 through 802,633
|
||||||
|
turn off 61,44 through 567,111
|
||||||
|
toggle 880,25 through 903,973
|
||||||
|
turn on 347,123 through 864,746
|
||||||
|
toggle 728,877 through 996,975
|
||||||
|
turn on 121,895 through 349,906
|
||||||
|
turn on 888,547 through 931,628
|
||||||
|
toggle 398,782 through 834,882
|
||||||
|
turn on 966,850 through 989,953
|
||||||
|
turn off 891,543 through 914,991
|
||||||
|
toggle 908,77 through 916,117
|
||||||
|
turn on 576,900 through 943,934
|
||||||
|
turn off 580,170 through 963,206
|
||||||
|
turn on 184,638 through 192,944
|
||||||
|
toggle 940,147 through 978,730
|
||||||
|
turn off 854,56 through 965,591
|
||||||
|
toggle 717,172 through 947,995
|
||||||
|
toggle 426,987 through 705,998
|
||||||
|
turn on 987,157 through 992,278
|
||||||
|
toggle 995,774 through 997,784
|
||||||
|
turn off 796,96 through 845,182
|
||||||
|
turn off 451,87 through 711,655
|
||||||
|
turn off 380,93 through 968,676
|
||||||
|
turn on 263,468 through 343,534
|
||||||
|
turn on 917,936 through 928,959
|
||||||
|
toggle 478,7 through 573,148
|
||||||
|
turn off 428,339 through 603,624
|
||||||
|
turn off 400,880 through 914,953
|
||||||
|
toggle 679,428 through 752,779
|
||||||
|
turn off 697,981 through 709,986
|
||||||
|
toggle 482,566 through 505,725
|
||||||
|
turn off 956,368 through 993,516
|
||||||
|
toggle 735,823 through 783,883
|
||||||
|
turn off 48,487 through 892,496
|
||||||
|
turn off 116,680 through 564,819
|
||||||
|
turn on 633,865 through 729,930
|
||||||
|
turn off 314,618 through 571,922
|
||||||
|
toggle 138,166 through 936,266
|
||||||
|
turn on 444,732 through 664,960
|
||||||
|
turn off 109,337 through 972,497
|
||||||
|
turn off 51,432 through 77,996
|
||||||
|
turn off 259,297 through 366,744
|
||||||
|
toggle 801,130 through 917,544
|
||||||
|
toggle 767,982 through 847,996
|
||||||
|
turn on 216,507 through 863,885
|
||||||
|
turn off 61,441 through 465,731
|
||||||
|
turn on 849,970 through 944,987
|
||||||
|
toggle 845,76 through 852,951
|
||||||
|
toggle 732,615 through 851,936
|
||||||
|
toggle 251,128 through 454,778
|
||||||
|
turn on 324,429 through 352,539
|
||||||
|
toggle 52,450 through 932,863
|
||||||
|
turn off 449,379 through 789,490
|
||||||
|
turn on 317,319 through 936,449
|
||||||
|
toggle 887,670 through 957,838
|
||||||
|
toggle 671,613 through 856,664
|
||||||
|
turn off 186,648 through 985,991
|
||||||
|
turn off 471,689 through 731,717
|
||||||
|
toggle 91,331 through 750,758
|
||||||
|
toggle 201,73 through 956,524
|
||||||
|
toggle 82,614 through 520,686
|
||||||
|
toggle 84,287 through 467,734
|
||||||
|
turn off 132,367 through 208,838
|
||||||
|
toggle 558,684 through 663,920
|
||||||
|
turn on 237,952 through 265,997
|
||||||
|
turn on 694,713 through 714,754
|
||||||
|
turn on 632,523 through 862,827
|
||||||
|
turn on 918,780 through 948,916
|
||||||
|
turn on 349,586 through 663,976
|
||||||
|
toggle 231,29 through 257,589
|
||||||
|
toggle 886,428 through 902,993
|
||||||
|
turn on 106,353 through 236,374
|
||||||
|
turn on 734,577 through 759,684
|
||||||
|
turn off 347,843 through 696,912
|
||||||
|
turn on 286,699 through 964,883
|
||||||
|
turn on 605,875 through 960,987
|
||||||
|
turn off 328,286 through 869,461
|
||||||
|
turn off 472,569 through 980,848
|
||||||
|
toggle 673,573 through 702,884
|
||||||
|
turn off 398,284 through 738,332
|
||||||
|
turn on 158,50 through 284,411
|
||||||
|
turn off 390,284 through 585,663
|
||||||
|
turn on 156,579 through 646,581
|
||||||
|
turn on 875,493 through 989,980
|
||||||
|
toggle 486,391 through 924,539
|
||||||
|
turn on 236,722 through 272,964
|
||||||
|
toggle 228,282 through 470,581
|
||||||
|
toggle 584,389 through 750,761
|
||||||
|
turn off 899,516 through 900,925
|
||||||
|
turn on 105,229 through 822,846
|
||||||
|
turn off 253,77 through 371,877
|
||||||
|
turn on 826,987 through 906,992
|
||||||
|
turn off 13,152 through 615,931
|
||||||
|
turn on 835,320 through 942,399
|
||||||
|
turn on 463,504 through 536,720
|
||||||
|
toggle 746,942 through 786,998
|
||||||
|
turn off 867,333 through 965,403
|
||||||
|
turn on 591,477 through 743,692
|
||||||
|
turn off 403,437 through 508,908
|
||||||
|
turn on 26,723 through 368,814
|
||||||
|
turn on 409,485 through 799,809
|
||||||
|
turn on 115,630 through 704,705
|
||||||
|
turn off 228,183 through 317,220
|
||||||
|
toggle 300,649 through 382,842
|
||||||
|
turn off 495,365 through 745,562
|
||||||
|
turn on 698,346 through 744,873
|
||||||
|
turn on 822,932 through 951,934
|
||||||
|
toggle 805,30 through 925,421
|
||||||
|
toggle 441,152 through 653,274
|
||||||
|
toggle 160,81 through 257,587
|
||||||
|
turn off 350,781 through 532,917
|
||||||
|
toggle 40,583 through 348,636
|
||||||
|
turn on 280,306 through 483,395
|
||||||
|
toggle 392,936 through 880,955
|
||||||
|
toggle 496,591 through 851,934
|
||||||
|
turn off 780,887 through 946,994
|
||||||
|
turn off 205,735 through 281,863
|
||||||
|
toggle 100,876 through 937,915
|
||||||
|
turn on 392,393 through 702,878
|
||||||
|
turn on 956,374 through 976,636
|
||||||
|
toggle 478,262 through 894,775
|
||||||
|
turn off 279,65 through 451,677
|
||||||
|
turn on 397,541 through 809,847
|
||||||
|
turn on 444,291 through 451,586
|
||||||
|
toggle 721,408 through 861,598
|
||||||
|
turn on 275,365 through 609,382
|
||||||
|
turn on 736,24 through 839,72
|
||||||
|
turn off 86,492 through 582,712
|
||||||
|
turn on 676,676 through 709,703
|
||||||
|
turn off 105,710 through 374,817
|
||||||
|
toggle 328,748 through 845,757
|
||||||
|
toggle 335,79 through 394,326
|
||||||
|
toggle 193,157 through 633,885
|
||||||
|
turn on 227,48 through 769,743
|
||||||
|
toggle 148,333 through 614,568
|
||||||
|
toggle 22,30 through 436,263
|
||||||
|
toggle 547,447 through 688,969
|
||||||
|
toggle 576,621 through 987,740
|
||||||
|
turn on 711,334 through 799,515
|
||||||
|
turn on 541,448 through 654,951
|
||||||
|
toggle 792,199 through 798,990
|
||||||
|
turn on 89,956 through 609,960
|
||||||
|
toggle 724,433 through 929,630
|
||||||
|
toggle 144,895 through 201,916
|
||||||
|
toggle 226,730 through 632,871
|
||||||
|
turn off 760,819 through 828,974
|
||||||
|
toggle 887,180 through 940,310
|
||||||
|
toggle 222,327 through 805,590
|
||||||
|
turn off 630,824 through 885,963
|
||||||
|
turn on 940,740 through 954,946
|
||||||
|
turn on 193,373 through 779,515
|
||||||
|
toggle 304,955 through 469,975
|
||||||
|
turn off 405,480 through 546,960
|
||||||
|
turn on 662,123 through 690,669
|
||||||
|
turn off 615,238 through 750,714
|
||||||
|
turn on 423,220 through 930,353
|
||||||
|
turn on 329,769 through 358,970
|
||||||
|
toggle 590,151 through 704,722
|
||||||
|
turn off 884,539 through 894,671
|
||||||
|
toggle 449,241 through 984,549
|
||||||
|
toggle 449,260 through 496,464
|
||||||
|
turn off 306,448 through 602,924
|
||||||
|
turn on 286,805 through 555,901
|
||||||
|
toggle 722,177 through 922,298
|
||||||
|
toggle 491,554 through 723,753
|
||||||
|
turn on 80,849 through 174,996
|
||||||
|
turn off 296,561 through 530,856
|
||||||
|
toggle 653,10 through 972,284
|
||||||
|
toggle 529,236 through 672,614
|
||||||
|
toggle 791,598 through 989,695
|
||||||
|
turn on 19,45 through 575,757
|
||||||
|
toggle 111,55 through 880,871
|
||||||
|
turn off 197,897 through 943,982
|
||||||
|
turn on 912,336 through 977,605
|
||||||
|
toggle 101,221 through 537,450
|
||||||
|
turn on 101,104 through 969,447
|
||||||
|
toggle 71,527 through 587,717
|
||||||
|
toggle 336,445 through 593,889
|
||||||
|
toggle 214,179 through 575,699
|
||||||
|
turn on 86,313 through 96,674
|
||||||
|
toggle 566,427 through 906,888
|
||||||
|
turn off 641,597 through 850,845
|
||||||
|
turn on 606,524 through 883,704
|
||||||
|
turn on 835,775 through 867,887
|
||||||
|
toggle 547,301 through 897,515
|
||||||
|
toggle 289,930 through 413,979
|
||||||
|
turn on 361,122 through 457,226
|
||||||
|
turn on 162,187 through 374,746
|
||||||
|
turn on 348,461 through 454,675
|
||||||
|
turn off 966,532 through 985,537
|
||||||
|
turn on 172,354 through 630,606
|
||||||
|
turn off 501,880 through 680,993
|
||||||
|
turn off 8,70 through 566,592
|
||||||
|
toggle 433,73 through 690,651
|
||||||
|
toggle 840,798 through 902,971
|
||||||
|
toggle 822,204 through 893,760
|
||||||
|
turn off 453,496 through 649,795
|
||||||
|
turn off 969,549 through 990,942
|
||||||
|
turn off 789,28 through 930,267
|
||||||
|
toggle 880,98 through 932,434
|
||||||
|
toggle 568,674 through 669,753
|
||||||
|
turn on 686,228 through 903,271
|
||||||
|
turn on 263,995 through 478,999
|
||||||
|
toggle 534,675 through 687,955
|
||||||
|
turn off 342,434 through 592,986
|
||||||
|
toggle 404,768 through 677,867
|
||||||
|
toggle 126,723 through 978,987
|
||||||
|
toggle 749,675 through 978,959
|
||||||
|
turn off 445,330 through 446,885
|
||||||
|
turn off 463,205 through 924,815
|
||||||
|
turn off 417,430 through 915,472
|
||||||
|
turn on 544,990 through 912,999
|
||||||
|
turn off 201,255 through 834,789
|
||||||
|
turn off 261,142 through 537,862
|
||||||
|
turn off 562,934 through 832,984
|
||||||
|
turn off 459,978 through 691,980
|
||||||
|
turn off 73,911 through 971,972
|
||||||
|
turn on 560,448 through 723,810
|
||||||
|
turn on 204,630 through 217,854
|
||||||
|
turn off 91,259 through 611,607
|
||||||
|
turn on 877,32 through 978,815
|
||||||
|
turn off 950,438 through 974,746
|
||||||
|
toggle 426,30 through 609,917
|
||||||
|
toggle 696,37 through 859,201
|
||||||
|
toggle 242,417 through 682,572
|
||||||
|
turn off 388,401 through 979,528
|
||||||
|
turn off 79,345 through 848,685
|
||||||
|
turn off 98,91 through 800,434
|
||||||
|
toggle 650,700 through 972,843
|
||||||
|
turn off 530,450 through 538,926
|
||||||
|
turn on 428,559 through 962,909
|
||||||
|
turn on 78,138 through 92,940
|
||||||
|
toggle 194,117 through 867,157
|
||||||
|
toggle 785,355 through 860,617
|
||||||
|
turn off 379,441 through 935,708
|
||||||
|
turn off 605,133 through 644,911
|
||||||
|
toggle 10,963 through 484,975
|
||||||
|
turn off 359,988 through 525,991
|
||||||
|
turn off 509,138 through 787,411
|
||||||
|
toggle 556,467 through 562,773
|
||||||
|
turn on 119,486 through 246,900
|
||||||
|
turn on 445,561 through 794,673
|
||||||
|
turn off 598,681 through 978,921
|
||||||
|
turn off 974,230 through 995,641
|
||||||
|
turn off 760,75 through 800,275
|
||||||
|
toggle 441,215 through 528,680
|
||||||
|
turn off 701,636 through 928,877
|
||||||
|
turn on 165,753 through 202,780
|
||||||
|
toggle 501,412 through 998,516
|
||||||
|
toggle 161,105 through 657,395
|
||||||
|
turn on 113,340 through 472,972
|
||||||
|
toggle 384,994 through 663,999
|
||||||
|
turn on 969,994 through 983,997
|
||||||
|
turn on 519,600 through 750,615
|
||||||
|
turn off 363,899 through 948,935
|
||||||
|
turn on 271,845 through 454,882
|
||||||
|
turn off 376,528 through 779,640
|
||||||
|
toggle 767,98 through 854,853
|
||||||
|
toggle 107,322 through 378,688
|
||||||
|
turn off 235,899 through 818,932
|
||||||
|
turn on 445,611 through 532,705
|
||||||
|
toggle 629,387 through 814,577
|
||||||
|
toggle 112,414 through 387,421
|
||||||
|
toggle 319,184 through 382,203
|
||||||
|
turn on 627,796 through 973,940
|
||||||
|
toggle 602,45 through 763,151
|
||||||
|
turn off 441,375 through 974,545
|
||||||
|
toggle 871,952 through 989,998
|
||||||
|
turn on 717,272 through 850,817
|
||||||
|
toggle 475,711 through 921,882
|
||||||
|
toggle 66,191 through 757,481
|
||||||
|
turn off 50,197 through 733,656
|
||||||
|
toggle 83,575 through 915,728
|
||||||
|
turn on 777,812 through 837,912
|
||||||
|
turn on 20,984 through 571,994
|
||||||
|
turn off 446,432 through 458,648
|
||||||
|
turn on 715,871 through 722,890
|
||||||
|
toggle 424,675 through 740,862
|
||||||
|
toggle 580,592 through 671,900
|
||||||
|
toggle 296,687 through 906,775
|
37
2015/06/part01.py
Normal file
37
2015/06/part01.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
lights = [[False for _ in range(1000)] for _ in range(1000)]
|
||||||
|
|
||||||
|
for instruction in puzzle_input:
|
||||||
|
from_coords = instruction.split(" ")[-1::-1][2]
|
||||||
|
to_coords = instruction.split(" ")[-1::-1][0]
|
||||||
|
from_coords = [int(x) for x in from_coords.split(",")]
|
||||||
|
to_coords = [int(x) for x in to_coords.split(",")]
|
||||||
|
|
||||||
|
[x_1, y_1] = from_coords
|
||||||
|
[x_2, y_2] = to_coords
|
||||||
|
|
||||||
|
toggle_mode = instruction.startswith("toggle")
|
||||||
|
set_to = instruction.startswith("turn on")
|
||||||
|
|
||||||
|
for x in range(x_1, x_2 + 1):
|
||||||
|
for y in range(y_1, y_2 + 1):
|
||||||
|
if toggle_mode:
|
||||||
|
lights[x][y] = not lights[x][y]
|
||||||
|
else:
|
||||||
|
lights[x][y] = set_to
|
||||||
|
|
||||||
|
print(instruction, from_coords, to_coords)
|
||||||
|
|
||||||
|
lights_on = 0
|
||||||
|
|
||||||
|
for row in lights:
|
||||||
|
for light in row:
|
||||||
|
if light:
|
||||||
|
lights_on += 1
|
||||||
|
|
||||||
|
print(lights_on)
|
40
2015/06/part02.py
Normal file
40
2015/06/part02.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
puzzle_input = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
lights = [[0 for _ in range(1000)] for _ in range(1000)]
|
||||||
|
|
||||||
|
for instruction in puzzle_input:
|
||||||
|
from_coords = instruction.split(" ")[-1::-1][2]
|
||||||
|
to_coords = instruction.split(" ")[-1::-1][0]
|
||||||
|
from_coords = [int(x) for x in from_coords.split(",")]
|
||||||
|
to_coords = [int(x) for x in to_coords.split(",")]
|
||||||
|
|
||||||
|
[x_1, y_1] = from_coords
|
||||||
|
[x_2, y_2] = to_coords
|
||||||
|
|
||||||
|
diff = 0
|
||||||
|
if instruction.startswith("turn on"):
|
||||||
|
diff = 1
|
||||||
|
elif instruction.startswith("turn off"):
|
||||||
|
diff = -1
|
||||||
|
else:
|
||||||
|
diff = 2
|
||||||
|
|
||||||
|
for x in range(x_1, x_2 + 1):
|
||||||
|
for y in range(y_1, y_2 + 1):
|
||||||
|
lights[x][y] = lights[x][y] + diff
|
||||||
|
if lights[x][y] < 0:
|
||||||
|
lights[x][y] = 0
|
||||||
|
|
||||||
|
print(instruction, from_coords, to_coords)
|
||||||
|
|
||||||
|
brightness = 0
|
||||||
|
|
||||||
|
for row in lights:
|
||||||
|
for light in row:
|
||||||
|
brightness += light
|
||||||
|
|
||||||
|
print(brightness)
|
8
2015/07/example
Normal file
8
2015/07/example
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
123 -> x
|
||||||
|
456 -> y
|
||||||
|
x AND y -> d
|
||||||
|
x OR y -> e
|
||||||
|
x LSHIFT 2 -> f
|
||||||
|
y RSHIFT 2 -> g
|
||||||
|
NOT x -> h
|
||||||
|
NOT y -> i
|
339
2015/07/input
Normal file
339
2015/07/input
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
bn RSHIFT 2 -> bo
|
||||||
|
lf RSHIFT 1 -> ly
|
||||||
|
fo RSHIFT 3 -> fq
|
||||||
|
cj OR cp -> cq
|
||||||
|
fo OR fz -> ga
|
||||||
|
t OR s -> u
|
||||||
|
lx -> a
|
||||||
|
NOT ax -> ay
|
||||||
|
he RSHIFT 2 -> hf
|
||||||
|
lf OR lq -> lr
|
||||||
|
lr AND lt -> lu
|
||||||
|
dy OR ej -> ek
|
||||||
|
1 AND cx -> cy
|
||||||
|
hb LSHIFT 1 -> hv
|
||||||
|
1 AND bh -> bi
|
||||||
|
ih AND ij -> ik
|
||||||
|
c LSHIFT 1 -> t
|
||||||
|
ea AND eb -> ed
|
||||||
|
km OR kn -> ko
|
||||||
|
NOT bw -> bx
|
||||||
|
ci OR ct -> cu
|
||||||
|
NOT p -> q
|
||||||
|
lw OR lv -> lx
|
||||||
|
NOT lo -> lp
|
||||||
|
fp OR fv -> fw
|
||||||
|
o AND q -> r
|
||||||
|
dh AND dj -> dk
|
||||||
|
ap LSHIFT 1 -> bj
|
||||||
|
bk LSHIFT 1 -> ce
|
||||||
|
NOT ii -> ij
|
||||||
|
gh OR gi -> gj
|
||||||
|
kk RSHIFT 1 -> ld
|
||||||
|
lc LSHIFT 1 -> lw
|
||||||
|
lb OR la -> lc
|
||||||
|
1 AND am -> an
|
||||||
|
gn AND gp -> gq
|
||||||
|
lf RSHIFT 3 -> lh
|
||||||
|
e OR f -> g
|
||||||
|
lg AND lm -> lo
|
||||||
|
ci RSHIFT 1 -> db
|
||||||
|
cf LSHIFT 1 -> cz
|
||||||
|
bn RSHIFT 1 -> cg
|
||||||
|
et AND fe -> fg
|
||||||
|
is OR it -> iu
|
||||||
|
kw AND ky -> kz
|
||||||
|
ck AND cl -> cn
|
||||||
|
bj OR bi -> bk
|
||||||
|
gj RSHIFT 1 -> hc
|
||||||
|
iu AND jf -> jh
|
||||||
|
NOT bs -> bt
|
||||||
|
kk OR kv -> kw
|
||||||
|
ks AND ku -> kv
|
||||||
|
hz OR ik -> il
|
||||||
|
b RSHIFT 1 -> v
|
||||||
|
iu RSHIFT 1 -> jn
|
||||||
|
fo RSHIFT 5 -> fr
|
||||||
|
be AND bg -> bh
|
||||||
|
ga AND gc -> gd
|
||||||
|
hf OR hl -> hm
|
||||||
|
ld OR le -> lf
|
||||||
|
as RSHIFT 5 -> av
|
||||||
|
fm OR fn -> fo
|
||||||
|
hm AND ho -> hp
|
||||||
|
lg OR lm -> ln
|
||||||
|
NOT kx -> ky
|
||||||
|
kk RSHIFT 3 -> km
|
||||||
|
ek AND em -> en
|
||||||
|
NOT ft -> fu
|
||||||
|
NOT jh -> ji
|
||||||
|
jn OR jo -> jp
|
||||||
|
gj AND gu -> gw
|
||||||
|
d AND j -> l
|
||||||
|
et RSHIFT 1 -> fm
|
||||||
|
jq OR jw -> jx
|
||||||
|
ep OR eo -> eq
|
||||||
|
lv LSHIFT 15 -> lz
|
||||||
|
NOT ey -> ez
|
||||||
|
jp RSHIFT 2 -> jq
|
||||||
|
eg AND ei -> ej
|
||||||
|
NOT dm -> dn
|
||||||
|
jp AND ka -> kc
|
||||||
|
as AND bd -> bf
|
||||||
|
fk OR fj -> fl
|
||||||
|
dw OR dx -> dy
|
||||||
|
lj AND ll -> lm
|
||||||
|
ec AND ee -> ef
|
||||||
|
fq AND fr -> ft
|
||||||
|
NOT kp -> kq
|
||||||
|
ki OR kj -> kk
|
||||||
|
cz OR cy -> da
|
||||||
|
as RSHIFT 3 -> au
|
||||||
|
an LSHIFT 15 -> ar
|
||||||
|
fj LSHIFT 15 -> fn
|
||||||
|
1 AND fi -> fj
|
||||||
|
he RSHIFT 1 -> hx
|
||||||
|
lf RSHIFT 2 -> lg
|
||||||
|
kf LSHIFT 15 -> kj
|
||||||
|
dz AND ef -> eh
|
||||||
|
ib OR ic -> id
|
||||||
|
lf RSHIFT 5 -> li
|
||||||
|
bp OR bq -> br
|
||||||
|
NOT gs -> gt
|
||||||
|
fo RSHIFT 1 -> gh
|
||||||
|
bz AND cb -> cc
|
||||||
|
ea OR eb -> ec
|
||||||
|
lf AND lq -> ls
|
||||||
|
NOT l -> m
|
||||||
|
hz RSHIFT 3 -> ib
|
||||||
|
NOT di -> dj
|
||||||
|
NOT lk -> ll
|
||||||
|
jp RSHIFT 3 -> jr
|
||||||
|
jp RSHIFT 5 -> js
|
||||||
|
NOT bf -> bg
|
||||||
|
s LSHIFT 15 -> w
|
||||||
|
eq LSHIFT 1 -> fk
|
||||||
|
jl OR jk -> jm
|
||||||
|
hz AND ik -> im
|
||||||
|
dz OR ef -> eg
|
||||||
|
1 AND gy -> gz
|
||||||
|
la LSHIFT 15 -> le
|
||||||
|
br AND bt -> bu
|
||||||
|
NOT cn -> co
|
||||||
|
v OR w -> x
|
||||||
|
d OR j -> k
|
||||||
|
1 AND gd -> ge
|
||||||
|
ia OR ig -> ih
|
||||||
|
NOT go -> gp
|
||||||
|
NOT ed -> ee
|
||||||
|
jq AND jw -> jy
|
||||||
|
et OR fe -> ff
|
||||||
|
aw AND ay -> az
|
||||||
|
ff AND fh -> fi
|
||||||
|
ir LSHIFT 1 -> jl
|
||||||
|
gg LSHIFT 1 -> ha
|
||||||
|
x RSHIFT 2 -> y
|
||||||
|
db OR dc -> dd
|
||||||
|
bl OR bm -> bn
|
||||||
|
ib AND ic -> ie
|
||||||
|
x RSHIFT 3 -> z
|
||||||
|
lh AND li -> lk
|
||||||
|
ce OR cd -> cf
|
||||||
|
NOT bb -> bc
|
||||||
|
hi AND hk -> hl
|
||||||
|
NOT gb -> gc
|
||||||
|
1 AND r -> s
|
||||||
|
fw AND fy -> fz
|
||||||
|
fb AND fd -> fe
|
||||||
|
1 AND en -> eo
|
||||||
|
z OR aa -> ab
|
||||||
|
bi LSHIFT 15 -> bm
|
||||||
|
hg OR hh -> hi
|
||||||
|
kh LSHIFT 1 -> lb
|
||||||
|
cg OR ch -> ci
|
||||||
|
1 AND kz -> la
|
||||||
|
gf OR ge -> gg
|
||||||
|
gj RSHIFT 2 -> gk
|
||||||
|
dd RSHIFT 2 -> de
|
||||||
|
NOT ls -> lt
|
||||||
|
lh OR li -> lj
|
||||||
|
jr OR js -> jt
|
||||||
|
au AND av -> ax
|
||||||
|
0 -> c
|
||||||
|
he AND hp -> hr
|
||||||
|
id AND if -> ig
|
||||||
|
et RSHIFT 5 -> ew
|
||||||
|
bp AND bq -> bs
|
||||||
|
e AND f -> h
|
||||||
|
ly OR lz -> ma
|
||||||
|
1 AND lu -> lv
|
||||||
|
NOT jd -> je
|
||||||
|
ha OR gz -> hb
|
||||||
|
dy RSHIFT 1 -> er
|
||||||
|
iu RSHIFT 2 -> iv
|
||||||
|
NOT hr -> hs
|
||||||
|
as RSHIFT 1 -> bl
|
||||||
|
kk RSHIFT 2 -> kl
|
||||||
|
b AND n -> p
|
||||||
|
ln AND lp -> lq
|
||||||
|
cj AND cp -> cr
|
||||||
|
dl AND dn -> do
|
||||||
|
ci RSHIFT 2 -> cj
|
||||||
|
as OR bd -> be
|
||||||
|
ge LSHIFT 15 -> gi
|
||||||
|
hz RSHIFT 5 -> ic
|
||||||
|
dv LSHIFT 1 -> ep
|
||||||
|
kl OR kr -> ks
|
||||||
|
gj OR gu -> gv
|
||||||
|
he RSHIFT 5 -> hh
|
||||||
|
NOT fg -> fh
|
||||||
|
hg AND hh -> hj
|
||||||
|
b OR n -> o
|
||||||
|
jk LSHIFT 15 -> jo
|
||||||
|
gz LSHIFT 15 -> hd
|
||||||
|
cy LSHIFT 15 -> dc
|
||||||
|
kk RSHIFT 5 -> kn
|
||||||
|
ci RSHIFT 3 -> ck
|
||||||
|
at OR az -> ba
|
||||||
|
iu RSHIFT 3 -> iw
|
||||||
|
ko AND kq -> kr
|
||||||
|
NOT eh -> ei
|
||||||
|
aq OR ar -> as
|
||||||
|
iy AND ja -> jb
|
||||||
|
dd RSHIFT 3 -> df
|
||||||
|
bn RSHIFT 3 -> bp
|
||||||
|
1 AND cc -> cd
|
||||||
|
at AND az -> bb
|
||||||
|
x OR ai -> aj
|
||||||
|
kk AND kv -> kx
|
||||||
|
ao OR an -> ap
|
||||||
|
dy RSHIFT 3 -> ea
|
||||||
|
x RSHIFT 1 -> aq
|
||||||
|
eu AND fa -> fc
|
||||||
|
kl AND kr -> kt
|
||||||
|
ia AND ig -> ii
|
||||||
|
df AND dg -> di
|
||||||
|
NOT fx -> fy
|
||||||
|
k AND m -> n
|
||||||
|
bn RSHIFT 5 -> bq
|
||||||
|
km AND kn -> kp
|
||||||
|
dt LSHIFT 15 -> dx
|
||||||
|
hz RSHIFT 2 -> ia
|
||||||
|
aj AND al -> am
|
||||||
|
cd LSHIFT 15 -> ch
|
||||||
|
hc OR hd -> he
|
||||||
|
he RSHIFT 3 -> hg
|
||||||
|
bn OR by -> bz
|
||||||
|
NOT kt -> ku
|
||||||
|
z AND aa -> ac
|
||||||
|
NOT ak -> al
|
||||||
|
cu AND cw -> cx
|
||||||
|
NOT ie -> if
|
||||||
|
dy RSHIFT 2 -> dz
|
||||||
|
ip LSHIFT 15 -> it
|
||||||
|
de OR dk -> dl
|
||||||
|
au OR av -> aw
|
||||||
|
jg AND ji -> jj
|
||||||
|
ci AND ct -> cv
|
||||||
|
dy RSHIFT 5 -> eb
|
||||||
|
hx OR hy -> hz
|
||||||
|
eu OR fa -> fb
|
||||||
|
gj RSHIFT 3 -> gl
|
||||||
|
fo AND fz -> gb
|
||||||
|
1 AND jj -> jk
|
||||||
|
jp OR ka -> kb
|
||||||
|
de AND dk -> dm
|
||||||
|
ex AND ez -> fa
|
||||||
|
df OR dg -> dh
|
||||||
|
iv OR jb -> jc
|
||||||
|
x RSHIFT 5 -> aa
|
||||||
|
NOT hj -> hk
|
||||||
|
NOT im -> in
|
||||||
|
fl LSHIFT 1 -> gf
|
||||||
|
hu LSHIFT 15 -> hy
|
||||||
|
iq OR ip -> ir
|
||||||
|
iu RSHIFT 5 -> ix
|
||||||
|
NOT fc -> fd
|
||||||
|
NOT el -> em
|
||||||
|
ck OR cl -> cm
|
||||||
|
et RSHIFT 3 -> ev
|
||||||
|
hw LSHIFT 1 -> iq
|
||||||
|
ci RSHIFT 5 -> cl
|
||||||
|
iv AND jb -> jd
|
||||||
|
dd RSHIFT 5 -> dg
|
||||||
|
as RSHIFT 2 -> at
|
||||||
|
NOT jy -> jz
|
||||||
|
af AND ah -> ai
|
||||||
|
1 AND ds -> dt
|
||||||
|
jx AND jz -> ka
|
||||||
|
da LSHIFT 1 -> du
|
||||||
|
fs AND fu -> fv
|
||||||
|
jp RSHIFT 1 -> ki
|
||||||
|
iw AND ix -> iz
|
||||||
|
iw OR ix -> iy
|
||||||
|
eo LSHIFT 15 -> es
|
||||||
|
ev AND ew -> ey
|
||||||
|
ba AND bc -> bd
|
||||||
|
fp AND fv -> fx
|
||||||
|
jc AND je -> jf
|
||||||
|
et RSHIFT 2 -> eu
|
||||||
|
kg OR kf -> kh
|
||||||
|
iu OR jf -> jg
|
||||||
|
er OR es -> et
|
||||||
|
fo RSHIFT 2 -> fp
|
||||||
|
NOT ca -> cb
|
||||||
|
bv AND bx -> by
|
||||||
|
u LSHIFT 1 -> ao
|
||||||
|
cm AND co -> cp
|
||||||
|
y OR ae -> af
|
||||||
|
bn AND by -> ca
|
||||||
|
1 AND ke -> kf
|
||||||
|
jt AND jv -> jw
|
||||||
|
fq OR fr -> fs
|
||||||
|
dy AND ej -> el
|
||||||
|
NOT kc -> kd
|
||||||
|
ev OR ew -> ex
|
||||||
|
dd OR do -> dp
|
||||||
|
NOT cv -> cw
|
||||||
|
gr AND gt -> gu
|
||||||
|
dd RSHIFT 1 -> dw
|
||||||
|
NOT gw -> gx
|
||||||
|
NOT iz -> ja
|
||||||
|
1 AND io -> ip
|
||||||
|
NOT ag -> ah
|
||||||
|
b RSHIFT 5 -> f
|
||||||
|
NOT cr -> cs
|
||||||
|
kb AND kd -> ke
|
||||||
|
jr AND js -> ju
|
||||||
|
cq AND cs -> ct
|
||||||
|
il AND in -> io
|
||||||
|
NOT ju -> jv
|
||||||
|
du OR dt -> dv
|
||||||
|
dd AND do -> dq
|
||||||
|
b RSHIFT 2 -> d
|
||||||
|
jm LSHIFT 1 -> kg
|
||||||
|
NOT dq -> dr
|
||||||
|
bo OR bu -> bv
|
||||||
|
gk OR gq -> gr
|
||||||
|
he OR hp -> hq
|
||||||
|
NOT h -> i
|
||||||
|
hf AND hl -> hn
|
||||||
|
gv AND gx -> gy
|
||||||
|
x AND ai -> ak
|
||||||
|
bo AND bu -> bw
|
||||||
|
hq AND hs -> ht
|
||||||
|
hz RSHIFT 1 -> is
|
||||||
|
gj RSHIFT 5 -> gm
|
||||||
|
g AND i -> j
|
||||||
|
gk AND gq -> gs
|
||||||
|
dp AND dr -> ds
|
||||||
|
b RSHIFT 3 -> e
|
||||||
|
gl AND gm -> go
|
||||||
|
gl OR gm -> gn
|
||||||
|
y AND ae -> ag
|
||||||
|
hv OR hu -> hw
|
||||||
|
1674 -> b
|
||||||
|
ab AND ad -> ae
|
||||||
|
NOT ac -> ad
|
||||||
|
1 AND ht -> hu
|
||||||
|
NOT hn -> ho
|
55
2015/07/part1.py
Normal file
55
2015/07/part1.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
instructions = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
SOURCES = dict()
|
||||||
|
|
||||||
|
for instruction in instructions:
|
||||||
|
print(instruction)
|
||||||
|
[operation, wire] = instruction.split(" -> ")
|
||||||
|
SOURCES[wire] = operation
|
||||||
|
|
||||||
|
print(SOURCES)
|
||||||
|
|
||||||
|
|
||||||
|
def evaluate_wire(wire):
|
||||||
|
try:
|
||||||
|
return int(wire)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
operation = SOURCES[wire]
|
||||||
|
print("evaluating wire", wire, "; operation:", operation)
|
||||||
|
|
||||||
|
parameters = operation.split(" ")
|
||||||
|
|
||||||
|
result = None
|
||||||
|
|
||||||
|
if "NOT" in operation:
|
||||||
|
[_, a] = parameters
|
||||||
|
result = evaluate_wire(a) ^ 0b1111111111111111
|
||||||
|
elif "OR" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) | evaluate_wire(b)
|
||||||
|
elif "AND" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) & evaluate_wire(b)
|
||||||
|
elif "LSHIFT" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) << evaluate_wire(b)
|
||||||
|
elif "RSHIFT" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) >> evaluate_wire(b)
|
||||||
|
else:
|
||||||
|
result = evaluate_wire(operation)
|
||||||
|
|
||||||
|
SOURCES[wire] = str(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
print(evaluate_wire("a"))
|
||||||
|
# for wire in ["d", "e", "f", "g", "h", "i"]:
|
||||||
|
# print("==", wire, "==")
|
||||||
|
# print(evaluate_wire(wire))
|
||||||
|
# print(SOURCES)
|
||||||
|
|
||||||
|
print("finish")
|
56
2015/07/part2.py
Normal file
56
2015/07/part2.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
instructions = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
solution_part_1 = 46065
|
||||||
|
|
||||||
|
SOURCES = dict()
|
||||||
|
|
||||||
|
for instruction in instructions:
|
||||||
|
print(instruction)
|
||||||
|
[operation, wire] = instruction.split(" -> ")
|
||||||
|
SOURCES[wire] = operation
|
||||||
|
|
||||||
|
SOURCES["b"] = solution_part_1
|
||||||
|
|
||||||
|
|
||||||
|
def evaluate_wire(wire):
|
||||||
|
try:
|
||||||
|
return int(wire)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
operation = SOURCES[wire]
|
||||||
|
print("evaluating wire", wire, "; operation:", operation)
|
||||||
|
|
||||||
|
if type(operation) == int:
|
||||||
|
return operation
|
||||||
|
|
||||||
|
parameters = operation.split(" ")
|
||||||
|
|
||||||
|
result = None
|
||||||
|
|
||||||
|
if "NOT" in operation:
|
||||||
|
[_, a] = parameters
|
||||||
|
result = evaluate_wire(a) ^ 0b1111111111111111
|
||||||
|
elif "OR" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) | evaluate_wire(b)
|
||||||
|
elif "AND" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) & evaluate_wire(b)
|
||||||
|
elif "LSHIFT" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) << evaluate_wire(b)
|
||||||
|
elif "RSHIFT" in operation:
|
||||||
|
[a, _, b] = parameters
|
||||||
|
result = evaluate_wire(a) >> evaluate_wire(b)
|
||||||
|
else:
|
||||||
|
result = evaluate_wire(operation)
|
||||||
|
|
||||||
|
SOURCES[wire] = str(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
print(evaluate_wire("a"))
|
||||||
|
|
||||||
|
print("finish")
|
300
2015/08/input
Normal file
300
2015/08/input
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
"sjdivfriyaaqa\xd2v\"k\"mpcu\"yyu\"en"
|
||||||
|
"vcqc"
|
||||||
|
"zbcwgmbpijcxu\"yins\"sfxn"
|
||||||
|
"yumngprx"
|
||||||
|
"bbdj"
|
||||||
|
"czbggabkzo\"wsnw\"voklp\"s"
|
||||||
|
"acwt"
|
||||||
|
"aqttwnsohbzian\"evtllfxwkog\"cunzw"
|
||||||
|
"ugvsgfv"
|
||||||
|
"xlnillibxg"
|
||||||
|
"kexh\"pmi"
|
||||||
|
"syvugow"
|
||||||
|
"m\"ktqnw"
|
||||||
|
"yrbajyndte\\rm"
|
||||||
|
"f\"kak\x70sn\xc4kjri"
|
||||||
|
"yxthr"
|
||||||
|
"alvumfsjni\"kohg"
|
||||||
|
"trajs\x5brom\xf1yoijaumkem\"\"tahlzs"
|
||||||
|
"\"oedr\"pwdbnnrc"
|
||||||
|
"qsmzhnx\""
|
||||||
|
"\"msoytqimx\\tbklqz"
|
||||||
|
"mjdfcgwdshrehgs"
|
||||||
|
"\"rivyxahf\""
|
||||||
|
"ciagc\x04bp"
|
||||||
|
"xkfc"
|
||||||
|
"xrgcripdu\x4c\xc4gszjhrvumvz\"mngbirb"
|
||||||
|
"gvmae\"yiiujoqvr\"mkxmgbbut\"u"
|
||||||
|
"ih"
|
||||||
|
"ncrqlejehs"
|
||||||
|
"mkno\x43pcfdukmemycp"
|
||||||
|
"uanzoqxkpsksbvdnkji\"feamp"
|
||||||
|
"axoufpnbx\\ao\x61pfj\"b"
|
||||||
|
"dz\\ztawzdjy"
|
||||||
|
"ihne\"enumvswypgf"
|
||||||
|
"\"dgazthrphbshdo\\vuqoiy\""
|
||||||
|
"dlnmptzt\\zahwpylc\\b\"gmslrqysk"
|
||||||
|
"mhxznyzcp"
|
||||||
|
"rebr\"amvxw\x5fmbnfpkkeghlntavj"
|
||||||
|
"lades\x47ncgdof\"\"jmbbk"
|
||||||
|
"dwxuis\xa5wdkx\\z\"admgnoddpgkt\\zs"
|
||||||
|
"g\\k\x27qsl\x34hwfglcdxqbeclt\xca\\"
|
||||||
|
"lhyjky\\m\"pvnm\\xmynpxnlhndmahjl"
|
||||||
|
"c\"uxabbgorrpprw\"xas\\vefkxioqpt"
|
||||||
|
"rfrvjxpevcmma\x71gtfipo"
|
||||||
|
"fgh\"kcwoqwfnjgdlzfclprg\"q"
|
||||||
|
"onxnwykrba"
|
||||||
|
"hkkg\x60f\"tjzsanpvarzgkfipl"
|
||||||
|
"\"aintes\"ofq\"juiaqlqxmvpe\\a"
|
||||||
|
"wiyczzs\"ciwk"
|
||||||
|
"mfqeu"
|
||||||
|
"v\xe1z\x7ftzalmvdmncfivrax\\rjwq"
|
||||||
|
"k\"vtg"
|
||||||
|
"exhrtdugeml\xf0"
|
||||||
|
"behnchkpld"
|
||||||
|
"mhgxy\"mfcrg\xc5gnp\"\"osqhj"
|
||||||
|
"rlvjy"
|
||||||
|
"awe"
|
||||||
|
"ctwy"
|
||||||
|
"vt"
|
||||||
|
"\x54t"
|
||||||
|
"zugfmmfomz"
|
||||||
|
"cv\"cvcvfaada\x04fsuqjinbfh\xa9cq\xd2c\"d"
|
||||||
|
"oj"
|
||||||
|
"xazanf\"wbmcrn"
|
||||||
|
"\\\\zkisyjpbzandqikqjqvee"
|
||||||
|
"dpsnbzdwnxk\\v"
|
||||||
|
"sj\"tuupr\\oyoh"
|
||||||
|
"myvkgnw\x81q\xaaokt\\emgejbsyvxcl\\\xee"
|
||||||
|
"ejeuqvunjcirdkkpt\"nlns"
|
||||||
|
"twmlvwxyvfyqqzu"
|
||||||
|
"\"xwtzdp\x98qkcis\"dm\\\"ep\"xyykq"
|
||||||
|
"vvcq\\expok"
|
||||||
|
"wgukjfanjgpdjb"
|
||||||
|
"\"mjcjajnxy\\dcpc"
|
||||||
|
"wdvgnecw\\ab\x44klceduzgsvu"
|
||||||
|
"dqtqkukr\"iacngufbqkdpxlwjjt"
|
||||||
|
"\"xj\"\x66qofsqzkoah"
|
||||||
|
"nptiwwsqdep"
|
||||||
|
"gsnlxql\x30mjl"
|
||||||
|
"yeezwokjwrhelny\""
|
||||||
|
"bjauamn\\izpmzqqasid"
|
||||||
|
"tvjdbkn\"tiziw\x82r"
|
||||||
|
"w"
|
||||||
|
"xwoakbbnjnypnaa\xa9wft\"slrmoqkl"
|
||||||
|
"vwxtnlvaaasyruykgygrvpiopzygf\"vq"
|
||||||
|
"qdancvnvmhlmpj\\isdxs"
|
||||||
|
"xzc\\elw"
|
||||||
|
"b\"wxeqvy\"qf\"g\xcaoklsucwicyw\"dovr"
|
||||||
|
"yomlvvjdbngz\"rly\"afr"
|
||||||
|
"bfb\"x\"aweuwbwmoa\x13\"t\"zhr"
|
||||||
|
"\"dmfoxb\"qvpjzzhykt\xd2\"\"ryhxi"
|
||||||
|
"psqef\"yu\\qiflie\"\x79w"
|
||||||
|
"arzewkej\"lqmh\\sayyusxxo\\"
|
||||||
|
"vuvvp"
|
||||||
|
"hc\"lg\x6bcpupsewzklai\"l"
|
||||||
|
"cjdfygc\"auorqybnuqghsh\x10"
|
||||||
|
"j"
|
||||||
|
"wqjexk\"eyq\\lbroqhk\\dqzsqk"
|
||||||
|
"dws\"ru\"dvxfiwapif\"oqwzmle"
|
||||||
|
"agcykg\\jt\\vzklqjvknoe"
|
||||||
|
"kksd\"jmslja\\z\"y\\b\xaagpyojct"
|
||||||
|
"nnpipxufvbfpoz\"jno"
|
||||||
|
"dtw"
|
||||||
|
"xlolvtahvgqkx\\dgnhj\\spsclpcxv\\"
|
||||||
|
"mxea\\mbjpi"
|
||||||
|
"lgbotkk\"zmxh\\\\qji\"jszulnjsxkqf"
|
||||||
|
"lwckmhwhx\"gmftlb\x91am"
|
||||||
|
"xxdxqyxth"
|
||||||
|
"\"lmqhwkjxmvayxy"
|
||||||
|
"tf"
|
||||||
|
"qy"
|
||||||
|
"wdqmwxdztax\"m\"\x09\x11xdxmfwxmtqgwvf"
|
||||||
|
"\xcbnazlf\"ghziknszmsrahaf"
|
||||||
|
"e\x6aupmzhxlvwympgjjpdvo\"kylfa"
|
||||||
|
"\x81vhtlillb\xactgoatva"
|
||||||
|
"dvnlgr"
|
||||||
|
"f"
|
||||||
|
"xg\xfacwizsadgeclm"
|
||||||
|
"vnnrzbtw\"\\prod\\djbyppngwayy\""
|
||||||
|
"lrt\xf4jahwvfz"
|
||||||
|
"aqpnjtom\"ymkak\\dadfybqrso\\fwv"
|
||||||
|
"gz\"aac\"mrbk\"ktommrojraqh"
|
||||||
|
"wycamwoecsftepfnlcdkm"
|
||||||
|
"nrhddblbuzlqsl\x9cben"
|
||||||
|
"vckxhyqkmqmdseazcykrbysm"
|
||||||
|
"sil\xbbtevmt\"gvrvybui\"faw\"j"
|
||||||
|
"cjex\\tp\x45pzf"
|
||||||
|
"asjobvtxszfodgf\"ibftg"
|
||||||
|
"gkyjyjdrxdcllnh\"sjcibenrdnxv"
|
||||||
|
"oswsdpjyxpbwnqbcpl\"yrdvs\\zq"
|
||||||
|
"\"\"tyowzc\\fycbp\"jbwrbvgui"
|
||||||
|
"cbpcabqkdgzmpgcwjtrchxp"
|
||||||
|
"iyrzfh\x45gw\"fdlfpiaap\x31xqq"
|
||||||
|
"evgksznidz"
|
||||||
|
"b\\w\\"
|
||||||
|
"loufizbiy\x57aim\"bgk"
|
||||||
|
"qjfyk"
|
||||||
|
"g\"anmloghvgr\x07zwqougqhdz"
|
||||||
|
"usbbmwcxd\\bdgg"
|
||||||
|
"htitqcpczml"
|
||||||
|
"eke\\cqvpexqqk\"to\"tqmljrpn\xe6lji\""
|
||||||
|
"g\xd2ifdsej"
|
||||||
|
"h\"sk\"haajajpagtcqnzrfqn\xe6btzo"
|
||||||
|
"wfkuffdxlvm\\cvlyzlbyunclhmpp"
|
||||||
|
"myaavh\"spue"
|
||||||
|
"hqvez\x68d\"eo\"eaioh"
|
||||||
|
"s\"qd\"oyxxcglcdnuhk"
|
||||||
|
"ilqvar"
|
||||||
|
"srh"
|
||||||
|
"puuifxrfmpc\"bvalwi\x2blu\\"
|
||||||
|
"yywlbutufzysbncw\\nqsfbhpz\"mngjq"
|
||||||
|
"zbl\\jfcuop"
|
||||||
|
"hjdouiragzvxsqkreup\\"
|
||||||
|
"qi"
|
||||||
|
"ckx\\funlj\xa7ahi"
|
||||||
|
"k"
|
||||||
|
"ufrcnh\"ajteit"
|
||||||
|
"cqv\"bgjozjj\x60x\xa8yhvmdvutchjotyuz"
|
||||||
|
"hkuiet\"oku\x8cfhumfpasl"
|
||||||
|
"\"\\sbe\x4d"
|
||||||
|
"vhknazqt"
|
||||||
|
"eyyizvzcahgflvmoowvs\\jhvygci"
|
||||||
|
"kki\x3ewcefkgtjap\"xtpxh\"lzepoqj"
|
||||||
|
"wvtk"
|
||||||
|
"\"ynet"
|
||||||
|
"zh\\obk\"otagx\x59txfzf"
|
||||||
|
"ocowhxlx\xe6zqg\x63wx\\tclkhq\\vmaze"
|
||||||
|
"w\"cf"
|
||||||
|
"qpniprnrzrnvykghqnalr"
|
||||||
|
"jctcqra\"\x05dhlydpqamorqjsijt\\xjdgt"
|
||||||
|
"sig"
|
||||||
|
"qhlbidbflwxe\"xljbwls\x20vht"
|
||||||
|
"irmrebfla\xefsg\"j"
|
||||||
|
"nep"
|
||||||
|
"hjuvsqlizeqobepf"
|
||||||
|
"guzbcdp\"obyh"
|
||||||
|
"\"mjagins\xf9tqykaxy\""
|
||||||
|
"knvsdnmtr\"zervsb"
|
||||||
|
"hzuy"
|
||||||
|
"zza\"k\"buapb\\elm\xfeya"
|
||||||
|
"lrqar\"dfqwkaaqifig\"uixjsz"
|
||||||
|
"\"azuo\x40rmnlhhluwsbbdb\x32pk\\yu\"pbcf"
|
||||||
|
"dplkdyty"
|
||||||
|
"rfoyciebwlwphcycmguc"
|
||||||
|
"ivnmmiemhgytmlprq\\eh"
|
||||||
|
"lhkyzaaothfdhmbpsqd\\yyw"
|
||||||
|
"tnlzifupcjcaj"
|
||||||
|
"\\qiyirsdrfpmu\\\x15xusifaag"
|
||||||
|
"\\lcomf\\s"
|
||||||
|
"uramjivcirjhqcqcg"
|
||||||
|
"kkbaklbxfxikffnuhtu\xc6t\"d"
|
||||||
|
"n\xefai"
|
||||||
|
"\"toy\"bnbpevuzoc\"muywq\"gz\"grbm"
|
||||||
|
"\"muu\\wt"
|
||||||
|
"\\srby\"ee"
|
||||||
|
"erf\"gvw\"swfppf"
|
||||||
|
"pbqcgtn\"iuianhcdazfvmidn\\nslhxdf"
|
||||||
|
"uxbp"
|
||||||
|
"up\\mgrcyaegiwmjufn"
|
||||||
|
"nulscgcewj\\dvoyvhetdegzhs\""
|
||||||
|
"masv\"k\\rzrb"
|
||||||
|
"qtx\x79d\"xdxmbxrvhj"
|
||||||
|
"fid\\otpkgjlh\"qgsvexrckqtn\xf4"
|
||||||
|
"tagzu"
|
||||||
|
"bvl\\\"noseec"
|
||||||
|
"\\xgicuuh"
|
||||||
|
"w\"a\"npemf"
|
||||||
|
"sxp"
|
||||||
|
"nsmpktic\x8awxftscdcvijjobnq\"gjd"
|
||||||
|
"uks\"\"jxvyvfezz\"aynxoev\"cuoav"
|
||||||
|
"m"
|
||||||
|
"lkvokj"
|
||||||
|
"vkfam\"yllr\"q\x92o\x4ebecnvhshhqe\\"
|
||||||
|
"efdxcjkjverw"
|
||||||
|
"lmqzadwhfdgmep\x02tzfcbgrbfekhat"
|
||||||
|
"cpbk\x9azqegbpluczssouop\x36ztpuoxsw"
|
||||||
|
"cqwoczxdd\"erdjka"
|
||||||
|
"cwvqnjgbw\\fxdlby"
|
||||||
|
"mvtm"
|
||||||
|
"lt\"bbqzpumplkg"
|
||||||
|
"ntd\xeeuwweucnuuslqfzfq"
|
||||||
|
"y\xabl\"dbebxjrlbmuoo\\\x1au"
|
||||||
|
"qjoqx\\a"
|
||||||
|
"pu\"ekdnfpmly\xbago\""
|
||||||
|
"fjhhdy"
|
||||||
|
"arl"
|
||||||
|
"xcywisim\"bwuwf\"\"raepeawwjub"
|
||||||
|
"pbe"
|
||||||
|
"dbnqfpzyaumxtqnd\xc5dcqrkwyop"
|
||||||
|
"ojv\x40vtkwgkqepm\x8bzft\\vedrry"
|
||||||
|
"wggqkfbwqumsgajqwphjec\"mstxpwz"
|
||||||
|
"zjkbem"
|
||||||
|
"icpfqxbelxazlls"
|
||||||
|
"pvpqs\\abcmtyielugfgcv\"tjxapxqxnx"
|
||||||
|
"oqddwlvmtv\"\x39lyybylfb\"jmngnpjrdw"
|
||||||
|
"gisgbve"
|
||||||
|
"\"aglg"
|
||||||
|
"y\"\"ss\xafvhxlrjv"
|
||||||
|
"qbgqjsra"
|
||||||
|
"ihshbjgqpdcljpmdwdprwloy"
|
||||||
|
"djja\\wcdn\"svkrgpqn\"uz\"hc\x43hj"
|
||||||
|
"cbjm"
|
||||||
|
"pnn"
|
||||||
|
"pqvh\"noh"
|
||||||
|
"\"\\fdktlp"
|
||||||
|
"ncea"
|
||||||
|
"pqgzphiyy"
|
||||||
|
"\xbedovhxuipaohlcvkwtxwmpz\"ckaif\"r"
|
||||||
|
"arjuzbjowqciunfwgxtph\"vlhy\"n"
|
||||||
|
"c"
|
||||||
|
"nrpdxunulgudqzlhtae"
|
||||||
|
"iefheu\"uru\""
|
||||||
|
"aqijysxuijud\"np\\opbichhudil\xbesum"
|
||||||
|
"pfpevmtstl\"lde\"bzr\"vspdxs"
|
||||||
|
"vparfbdjwvzsocpnzhp"
|
||||||
|
"g\x4ffxaarafrsjthq\\\xc1rw"
|
||||||
|
"ng\\rqx\\gwpzucbh\xafl"
|
||||||
|
"rw\"nf\\dna"
|
||||||
|
"jkkeahxurxla\\g\xb3czrlsyimmwcwthr"
|
||||||
|
"twaailoypu\"oas\"kpuuyedlaw\\\xb0vzt"
|
||||||
|
"hznex\\gdiqvtugi"
|
||||||
|
"imdibsunjeswhk"
|
||||||
|
"ta\\icileuzpxro\"cfmv\"mzp"
|
||||||
|
"coykr\x57luiysucfaflmilhlehmvzeiepo"
|
||||||
|
"u\x3dfh\xd4yt"
|
||||||
|
"piw\x1bz\"eowy\"vfk\"wqiekw"
|
||||||
|
"gan\"y"
|
||||||
|
"p\"bevidoazcznr\"hddxuuq\""
|
||||||
|
"bwzucczznutbxe"
|
||||||
|
"z\"viqgyqjisior\\iecosmjbknol"
|
||||||
|
"dmlpcglcfkfsctxydjvayhymv\x3c\\gp"
|
||||||
|
"bfvkqrintbbvgfv"
|
||||||
|
"xlzntrgdck\"cprc\xadczyarbznqmuhxyuh"
|
||||||
|
"uqdxnuwioc\"kdytxq\\ig"
|
||||||
|
"xrafmucpmfi"
|
||||||
|
"vr\"hltmfrge"
|
||||||
|
"eonf\"nt\\wtcnsocs"
|
||||||
|
"j\xb7xoslyjeyjksplkqixncgkylkw"
|
||||||
|
"njw\"pefgfbez\x9axshdmplxzquqe"
|
||||||
|
"di\x58bvptfsafirpc"
|
||||||
|
"l\x1fkco"
|
||||||
|
"x"
|
||||||
|
"mprndo\"n"
|
||||||
|
"psegit"
|
||||||
|
"svbdnkkuuqs\"sqxu\"oqcyz\"aizashk"
|
||||||
|
"cwkljukxer\\\"\\nff\"esjwiyaoy"
|
||||||
|
"ilxrkgbjjxpvhdtq\"cpiuoofdnkpp"
|
||||||
|
"hlngi\"ulxep\\qohtmqnqjb\"rkgerho"
|
||||||
|
"gxws\"bcgm\"p"
|
||||||
|
"bv\"mds\\zhfusiepgrz\\b\x32fscdzz"
|
||||||
|
"l\xfampwtme\x69qvxnx\"\"\xc4jruuymjxrpsv"
|
||||||
|
"qqmxhrn"
|
||||||
|
"xziq\\\x18ybyv\x9am\"neacoqjzytertisysza"
|
||||||
|
"aqcbvlvcrzceeyx\\j\"\"x"
|
||||||
|
"yjuhhb"
|
||||||
|
"\x5em\"squulpy"
|
||||||
|
"dpbntplgmwb"
|
||||||
|
"utsgfkm\\vbftjknlktpthoeo"
|
||||||
|
"ccxjgiocmuhf\"ycnh"
|
||||||
|
"lltj\"kbbxi"
|
25
2015/08/part1.py
Normal file
25
2015/08/part1.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
lines = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
solution = 0
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
char_count = 0
|
||||||
|
i = 1
|
||||||
|
while i < len(line) - 1:
|
||||||
|
char = line[i]
|
||||||
|
if char == "\\":
|
||||||
|
next_char = line[i + 1]
|
||||||
|
if next_char in ["\\", '"']:
|
||||||
|
i += 1
|
||||||
|
elif next_char in ["x"]:
|
||||||
|
i += 3
|
||||||
|
char_count += 1
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
literal_count = len(line)
|
||||||
|
|
||||||
|
print(f"{line}: {literal_count=}, {char_count=}")
|
||||||
|
solution += literal_count - char_count
|
||||||
|
|
||||||
|
print(solution)
|
21
2015/08/part2.py
Normal file
21
2015/08/part2.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
lines = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
solution = 0
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
literal_count = len(line)
|
||||||
|
|
||||||
|
char_count = 2 # surrounding double quotes: '"'
|
||||||
|
i = 0
|
||||||
|
while i < len(line):
|
||||||
|
char = line[i]
|
||||||
|
if char in ['"', "\\", ""]:
|
||||||
|
char_count += 1
|
||||||
|
char_count += 1
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
print(f"{line}: {literal_count=}, {char_count=}")
|
||||||
|
solution += char_count - literal_count
|
||||||
|
|
||||||
|
print(solution)
|
28
2015/09/input
Normal file
28
2015/09/input
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Faerun to Tristram = 65
|
||||||
|
Faerun to Tambi = 129
|
||||||
|
Faerun to Norrath = 144
|
||||||
|
Faerun to Snowdin = 71
|
||||||
|
Faerun to Straylight = 137
|
||||||
|
Faerun to AlphaCentauri = 3
|
||||||
|
Faerun to Arbre = 149
|
||||||
|
Tristram to Tambi = 63
|
||||||
|
Tristram to Norrath = 4
|
||||||
|
Tristram to Snowdin = 105
|
||||||
|
Tristram to Straylight = 125
|
||||||
|
Tristram to AlphaCentauri = 55
|
||||||
|
Tristram to Arbre = 14
|
||||||
|
Tambi to Norrath = 68
|
||||||
|
Tambi to Snowdin = 52
|
||||||
|
Tambi to Straylight = 65
|
||||||
|
Tambi to AlphaCentauri = 22
|
||||||
|
Tambi to Arbre = 143
|
||||||
|
Norrath to Snowdin = 8
|
||||||
|
Norrath to Straylight = 23
|
||||||
|
Norrath to AlphaCentauri = 136
|
||||||
|
Norrath to Arbre = 115
|
||||||
|
Snowdin to Straylight = 101
|
||||||
|
Snowdin to AlphaCentauri = 84
|
||||||
|
Snowdin to Arbre = 96
|
||||||
|
Straylight to AlphaCentauri = 107
|
||||||
|
Straylight to Arbre = 14
|
||||||
|
AlphaCentauri to Arbre = 46
|
43
2015/09/part1.py
Normal file
43
2015/09/part1.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import itertools
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
connections = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
GRAPH = dict()
|
||||||
|
LOCATIONS = set()
|
||||||
|
|
||||||
|
for connection in connections:
|
||||||
|
[location_a, _, location_b, _, distance] = connection.split(" ")
|
||||||
|
distance = int(distance)
|
||||||
|
|
||||||
|
LOCATIONS.add(location_a)
|
||||||
|
LOCATIONS.add(location_b)
|
||||||
|
GRAPH[(location_a, location_b)] = distance
|
||||||
|
GRAPH[(location_b, location_a)] = distance
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_distance(route):
|
||||||
|
dist = 0
|
||||||
|
for i in range(len(route) - 1):
|
||||||
|
location_a = route[i]
|
||||||
|
location_b = route[i + 1]
|
||||||
|
if (location_a, location_b) not in GRAPH:
|
||||||
|
return None
|
||||||
|
dist += GRAPH[(location_a, location_b)]
|
||||||
|
return dist
|
||||||
|
|
||||||
|
|
||||||
|
SHORTEST_ROUTE = None
|
||||||
|
SHORTEST_DISTANCE = None
|
||||||
|
|
||||||
|
for route in itertools.permutations(LOCATIONS, len(LOCATIONS)):
|
||||||
|
dist = calculate_distance(route)
|
||||||
|
if dist is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if SHORTEST_DISTANCE is None or dist < SHORTEST_DISTANCE:
|
||||||
|
SHORTEST_DISTANCE = dist
|
||||||
|
SHORTEST_ROUTE = route
|
||||||
|
|
||||||
|
print(SHORTEST_ROUTE)
|
||||||
|
print(SHORTEST_DISTANCE)
|
43
2015/09/part2.py
Normal file
43
2015/09/part2.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import itertools
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
connections = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
GRAPH = dict()
|
||||||
|
LOCATIONS = set()
|
||||||
|
|
||||||
|
for connection in connections:
|
||||||
|
[location_a, _, location_b, _, distance] = connection.split(" ")
|
||||||
|
distance = int(distance)
|
||||||
|
|
||||||
|
LOCATIONS.add(location_a)
|
||||||
|
LOCATIONS.add(location_b)
|
||||||
|
GRAPH[(location_a, location_b)] = distance
|
||||||
|
GRAPH[(location_b, location_a)] = distance
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_distance(route):
|
||||||
|
dist = 0
|
||||||
|
for i in range(len(route) - 1):
|
||||||
|
location_a = route[i]
|
||||||
|
location_b = route[i + 1]
|
||||||
|
if (location_a, location_b) not in GRAPH:
|
||||||
|
return None
|
||||||
|
dist += GRAPH[(location_a, location_b)]
|
||||||
|
return dist
|
||||||
|
|
||||||
|
|
||||||
|
LONGEST_ROUTE = None
|
||||||
|
LONGEST_DISTANCE = None
|
||||||
|
|
||||||
|
for route in itertools.permutations(LOCATIONS, len(LOCATIONS)):
|
||||||
|
dist = calculate_distance(route)
|
||||||
|
if dist is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if LONGEST_DISTANCE is None or dist > LONGEST_DISTANCE:
|
||||||
|
LONGEST_DISTANCE = dist
|
||||||
|
LONGEST_ROUTE = route
|
||||||
|
|
||||||
|
print(LONGEST_ROUTE)
|
||||||
|
print(LONGEST_DISTANCE)
|
94
2015/10/atoms
Normal file
94
2015/10/atoms
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
94 Pu 31221132221222112112322211 Np
|
||||||
|
93 Np 1311222113321132211221121332211 Hf Pa H Ca Pu
|
||||||
|
92 U 3 Pa
|
||||||
|
91 Pa 13 Th
|
||||||
|
90 Th 1113 Ac
|
||||||
|
89 Ac 3113 Ra
|
||||||
|
88 Ra 132113 Fr
|
||||||
|
87 Fr 1113122113 Rn
|
||||||
|
86 Rn 311311222113 Ho At
|
||||||
|
85 At 1322113 Po
|
||||||
|
84 Po 1113222113 Bi
|
||||||
|
83 Bi 3113322113 Pm Pb
|
||||||
|
82 Pb 123222113 Tl
|
||||||
|
81 Tl 111213322113 Hg
|
||||||
|
80 Hg 31121123222113 Au
|
||||||
|
79 Au 132112211213322113 Pt
|
||||||
|
78 Pt 111312212221121123222113 Ir
|
||||||
|
77 Ir 3113112211322112211213322113 Os
|
||||||
|
76 Os 1321132122211322212221121123222113 Re
|
||||||
|
75 Re 111312211312113221133211322112211213322113 Ge Ca W
|
||||||
|
74 W 312211322212221121123222113 Ta
|
||||||
|
73 Ta 13112221133211322112211213322113 Hf Pa H Ca W
|
||||||
|
72 Hf 11132 Lu
|
||||||
|
71 Lu 311312 Yb
|
||||||
|
70 Yb 1321131112 Tm
|
||||||
|
69 Tm 11131221133112 Er Ca Co
|
||||||
|
68 Er 311311222 Ho Pm
|
||||||
|
67 Ho 1321132 Dy
|
||||||
|
66 Dy 111312211312 Tb
|
||||||
|
65 Tb 3113112221131112 Ho Gd
|
||||||
|
64 Gd 13221133112 Eu Ca Co
|
||||||
|
63 Eu 1113222 Sm
|
||||||
|
62 Sm 311332 Pm Ca Zn
|
||||||
|
61 Pm 132 Nd
|
||||||
|
60 Nd 111312 Pr
|
||||||
|
59 Pr 31131112 Ce
|
||||||
|
58 Ce 1321133112 La H Ca Co
|
||||||
|
57 La 11131 Ba
|
||||||
|
56 Ba 311311 Cs
|
||||||
|
55 Cs 13211321 Xe
|
||||||
|
54 Xe 11131221131211 I
|
||||||
|
53 I 311311222113111221 Ho Te
|
||||||
|
52 Te 1322113312211 Eu Ca Sb
|
||||||
|
51 Sb 3112221 Pm Sn
|
||||||
|
50 Sn 13211 In
|
||||||
|
49 In 11131221 Cd
|
||||||
|
48 Cd 3113112211 Ag
|
||||||
|
47 Ag 132113212221 Pd
|
||||||
|
46 Pd 111312211312113211 Rh
|
||||||
|
45 Rh 311311222113111221131221 Ho Ru
|
||||||
|
44 Ru 132211331222113112211 Eu Ca Tc
|
||||||
|
43 Tc 311322113212221 Mo
|
||||||
|
42 Mo 13211322211312113211 Nb
|
||||||
|
41 Nb 1113122113322113111221131221 Er Zr
|
||||||
|
40 Zr 12322211331222113112211 Y H Ca Tc
|
||||||
|
39 Y 1112133 Sr U
|
||||||
|
38 Sr 3112112 Rb
|
||||||
|
37 Rb 1321122112 Kr
|
||||||
|
36 Kr 11131221222112 Br
|
||||||
|
35 Br 3113112211322112 Se
|
||||||
|
34 Se 13211321222113222112 As
|
||||||
|
33 As 11131221131211322113322112 Ge Na
|
||||||
|
32 Ge 31131122211311122113222 Ho Ga
|
||||||
|
31 Ga 13221133122211332 Eu Ca Ac H Ca Zn
|
||||||
|
30 Zn 312 Cu
|
||||||
|
29 Cu 131112 Ni
|
||||||
|
28 Ni 11133112 Zn Co
|
||||||
|
27 Co 32112 Fe
|
||||||
|
26 Fe 13122112 Mn
|
||||||
|
25 Mn 111311222112 Cr Si
|
||||||
|
24 Cr 31132 V
|
||||||
|
23 V 13211312 Ti
|
||||||
|
22 Ti 11131221131112 Sc
|
||||||
|
21 Sc 3113112221133112 Ho Pa H Ca Co
|
||||||
|
20 Ca 12 K
|
||||||
|
19 K 1112 Ar
|
||||||
|
18 Ar 3112 Cl
|
||||||
|
17 Cl 132112 S
|
||||||
|
16 S 1113122112 P
|
||||||
|
15 P 311311222112 Ho Si
|
||||||
|
14 Si 1322112 Al
|
||||||
|
13 Al 1113222112 Mg
|
||||||
|
12 Mg 3113322112 Pm Na
|
||||||
|
11 Na 123222112 Ne
|
||||||
|
10 Ne 111213322112 F
|
||||||
|
9 F 31121123222112 O
|
||||||
|
8 O 132112211213322112 N
|
||||||
|
7 N 111312212221121123222112 C
|
||||||
|
6 C 3113112211322112211213322112 B
|
||||||
|
5 B 1321132122211322212221121123222112 Be
|
||||||
|
4 Be 111312211312113221133211322112211213322112 Ge Ca Li
|
||||||
|
3 Li 312211322212221121123222112 He
|
||||||
|
2 He 13112221133211322112211213322112 Hf Pa H Ca Li
|
||||||
|
1 H 22 H
|
1
2015/10/input
Normal file
1
2015/10/input
Normal file
@ -0,0 +1 @@
|
|||||||
|
1321131112
|
42
2015/10/part1.py
Normal file
42
2015/10/part1.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
start_number = f.readline().strip()
|
||||||
|
|
||||||
|
# start_number = "211"
|
||||||
|
|
||||||
|
print("Start:", start_number)
|
||||||
|
|
||||||
|
|
||||||
|
def generate_next_number(number):
|
||||||
|
next_number = ""
|
||||||
|
last_char = ""
|
||||||
|
char_count = 0
|
||||||
|
|
||||||
|
for char in number:
|
||||||
|
# initialize
|
||||||
|
if not last_char:
|
||||||
|
last_char = char
|
||||||
|
char_count = 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# same as last char: increase count
|
||||||
|
if char == last_char:
|
||||||
|
char_count += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# different than last char: append to next_number and initialize
|
||||||
|
next_number = next_number + str(char_count) + last_char
|
||||||
|
char_count = 1
|
||||||
|
last_char = char
|
||||||
|
|
||||||
|
next_number = next_number + str(char_count) + last_char
|
||||||
|
return next_number
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(40):
|
||||||
|
print("Iteration:", i + 1)
|
||||||
|
prev_number = start_number
|
||||||
|
start_number = generate_next_number(start_number)
|
||||||
|
# print(f"{prev_number} -> {start_number}")
|
||||||
|
|
||||||
|
print("Solution:")
|
||||||
|
print(len(start_number))
|
41
2015/10/part2.py
Normal file
41
2015/10/part2.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
start_number = f.readline().strip()
|
||||||
|
|
||||||
|
print("Start:", start_number, "length:", len(start_number))
|
||||||
|
|
||||||
|
ATOM_TO_NUMBER = dict()
|
||||||
|
NUMBER_TO_ATOM = dict()
|
||||||
|
DECAY = dict()
|
||||||
|
|
||||||
|
# From https://web.archive.org/web/20061224154744/http://www.uam.es/personal_pdi/ciencias/omartin/Biochem.PDF
|
||||||
|
with open("atoms") as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
columns = line.strip().split(" ")
|
||||||
|
[_, atom, number] = columns[:3]
|
||||||
|
NUMBER_TO_ATOM[number] = atom
|
||||||
|
ATOM_TO_NUMBER[atom] = number
|
||||||
|
DECAY[atom] = columns[3:]
|
||||||
|
|
||||||
|
start_atom = NUMBER_TO_ATOM[start_number]
|
||||||
|
|
||||||
|
print("Starting with atom:", start_atom)
|
||||||
|
|
||||||
|
ATOM_COUNT = defaultdict(int)
|
||||||
|
ATOM_COUNT[start_atom] = 1
|
||||||
|
|
||||||
|
for i in range(50):
|
||||||
|
NEXT_ATOM_COUNT = defaultdict(int)
|
||||||
|
for atom, count in ATOM_COUNT.items():
|
||||||
|
for new_atom in DECAY[atom]:
|
||||||
|
NEXT_ATOM_COUNT[new_atom] += count
|
||||||
|
ATOM_COUNT = NEXT_ATOM_COUNT
|
||||||
|
|
||||||
|
length = 0
|
||||||
|
for atom, count in ATOM_COUNT.items():
|
||||||
|
length += len(ATOM_TO_NUMBER[atom]) * count
|
||||||
|
|
||||||
|
print("Round", i + 1, "len:", length)
|
||||||
|
|
||||||
|
print(length)
|
1
2015/11/input
Normal file
1
2015/11/input
Normal file
@ -0,0 +1 @@
|
|||||||
|
vzbxkghb
|
85
2015/11/part1.py
Normal file
85
2015/11/part1.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
start_password = "vzbxkghb"
|
||||||
|
# start_password = "abcdefgh"
|
||||||
|
print("Start password:", start_password)
|
||||||
|
|
||||||
|
|
||||||
|
def b26_to_int(input_string):
|
||||||
|
result = 0
|
||||||
|
exp = 1
|
||||||
|
for char in input_string[::-1]:
|
||||||
|
char_value = ord(char) - 97 # from 0 to 25
|
||||||
|
result += char_value * exp
|
||||||
|
exp *= 26
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def int_to_b26(input_number):
|
||||||
|
result = ""
|
||||||
|
while input_number:
|
||||||
|
quot, remainder = divmod(input_number, 26)
|
||||||
|
result += chr(remainder + 97)
|
||||||
|
input_number = quot
|
||||||
|
return result[::-1]
|
||||||
|
|
||||||
|
|
||||||
|
def increment_password(password):
|
||||||
|
return int_to_b26(b26_to_int(password) + 1).rjust(8, "a")
|
||||||
|
|
||||||
|
|
||||||
|
STRAIGHTS = [chr(x + 97) + chr(x + 98) + chr(x + 99) for x in range(24)]
|
||||||
|
|
||||||
|
|
||||||
|
def has_increasing_straight(password):
|
||||||
|
for straight in STRAIGHTS:
|
||||||
|
if straight in password:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def has_forbidden_letter(password):
|
||||||
|
for char in ["i", "o", "l"]:
|
||||||
|
if char in password:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
PAIRS = [chr(x + 97) + chr(x + 97) for x in range(26)]
|
||||||
|
|
||||||
|
|
||||||
|
def contains_two_pairs(password):
|
||||||
|
count_pairs = 0
|
||||||
|
for pair in PAIRS:
|
||||||
|
if pair in password:
|
||||||
|
count_pairs += 1
|
||||||
|
if count_pairs >= 2:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def validate_password(password):
|
||||||
|
return (
|
||||||
|
has_increasing_straight(password)
|
||||||
|
and not has_forbidden_letter(password)
|
||||||
|
and contains_two_pairs(password)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# to_int = b26_to_int(start_password)
|
||||||
|
# print(start_password, to_int, int_to_b26(to_int))
|
||||||
|
# print(start_password, increment_password(start_password))
|
||||||
|
|
||||||
|
# for pwd in ["hijklmmn", "abbceffg", "abbcegjk", "abcdffaa", "ghjaabcc"]:
|
||||||
|
# print(pwd)
|
||||||
|
# print(validate_password(pwd))
|
||||||
|
# print()
|
||||||
|
|
||||||
|
# print(STRAIGHTS)
|
||||||
|
# print(PAIRS)
|
||||||
|
|
||||||
|
|
||||||
|
while not validate_password(start_password):
|
||||||
|
start_password = increment_password(start_password)
|
||||||
|
|
||||||
|
print(start_password)
|
||||||
|
|
||||||
|
# false guess: vzcaabcc
|
90
2015/11/part2.py
Normal file
90
2015/11/part2.py
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
start_password = "vzbxkghb"
|
||||||
|
# start_password = "abcdefgh"
|
||||||
|
print("Start password:", start_password)
|
||||||
|
|
||||||
|
|
||||||
|
def b26_to_int(input_string):
|
||||||
|
result = 0
|
||||||
|
exp = 1
|
||||||
|
for char in input_string[::-1]:
|
||||||
|
char_value = ord(char) - 97 # from 0 to 25
|
||||||
|
result += char_value * exp
|
||||||
|
exp *= 26
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def int_to_b26(input_number):
|
||||||
|
result = ""
|
||||||
|
while input_number:
|
||||||
|
quot, remainder = divmod(input_number, 26)
|
||||||
|
result += chr(remainder + 97)
|
||||||
|
input_number = quot
|
||||||
|
return result[::-1]
|
||||||
|
|
||||||
|
|
||||||
|
def increment_password(password):
|
||||||
|
return int_to_b26(b26_to_int(password) + 1).rjust(8, "a")
|
||||||
|
|
||||||
|
|
||||||
|
STRAIGHTS = [chr(x + 97) + chr(x + 98) + chr(x + 99) for x in range(24)]
|
||||||
|
|
||||||
|
|
||||||
|
def has_increasing_straight(password):
|
||||||
|
for straight in STRAIGHTS:
|
||||||
|
if straight in password:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def has_forbidden_letter(password):
|
||||||
|
for char in ["i", "o", "l"]:
|
||||||
|
if char in password:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
PAIRS = [chr(x + 97) + chr(x + 97) for x in range(26)]
|
||||||
|
|
||||||
|
|
||||||
|
def contains_two_pairs(password):
|
||||||
|
count_pairs = 0
|
||||||
|
for pair in PAIRS:
|
||||||
|
if pair in password:
|
||||||
|
count_pairs += 1
|
||||||
|
if count_pairs >= 2:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def validate_password(password):
|
||||||
|
return (
|
||||||
|
has_increasing_straight(password)
|
||||||
|
and not has_forbidden_letter(password)
|
||||||
|
and contains_two_pairs(password)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# to_int = b26_to_int(start_password)
|
||||||
|
# print(start_password, to_int, int_to_b26(to_int))
|
||||||
|
# print(start_password, increment_password(start_password))
|
||||||
|
|
||||||
|
# for pwd in ["hijklmmn", "abbceffg", "abbcegjk", "abcdffaa", "ghjaabcc"]:
|
||||||
|
# print(pwd)
|
||||||
|
# print(validate_password(pwd))
|
||||||
|
# print()
|
||||||
|
|
||||||
|
# print(STRAIGHTS)
|
||||||
|
# print(PAIRS)
|
||||||
|
|
||||||
|
|
||||||
|
while not validate_password(start_password):
|
||||||
|
start_password = increment_password(start_password)
|
||||||
|
|
||||||
|
start_password = increment_password(start_password)
|
||||||
|
|
||||||
|
while not validate_password(start_password):
|
||||||
|
start_password = increment_password(start_password)
|
||||||
|
|
||||||
|
print(start_password)
|
||||||
|
|
||||||
|
# false guess: vzcaabcc
|
1
2015/12/input
Normal file
1
2015/12/input
Normal file
File diff suppressed because one or more lines are too long
6
2015/12/part1.py
Normal file
6
2015/12/part1.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
document = f.readline().strip()
|
||||||
|
|
||||||
|
print(sum([int(x) for x in re.findall(r"[0-9-]+", document)]))
|
31
2015/12/part2.py
Normal file
31
2015/12/part2.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
document = f.readline().strip()
|
||||||
|
|
||||||
|
document = json.loads(document)
|
||||||
|
|
||||||
|
|
||||||
|
def iterate_object(json_object):
|
||||||
|
object_sum = 0
|
||||||
|
object_type = type(json_object)
|
||||||
|
|
||||||
|
if object_type == list:
|
||||||
|
for item in json_object:
|
||||||
|
object_sum += iterate_object(item)
|
||||||
|
elif object_type == int:
|
||||||
|
return json_object
|
||||||
|
elif object_type == str:
|
||||||
|
pass
|
||||||
|
elif object_type == dict:
|
||||||
|
for item in json_object.values():
|
||||||
|
if item == "red":
|
||||||
|
return 0
|
||||||
|
object_sum += iterate_object(item)
|
||||||
|
else:
|
||||||
|
raise TypeError(f"No case for type {object_type}!")
|
||||||
|
|
||||||
|
return object_sum
|
||||||
|
|
||||||
|
|
||||||
|
print(iterate_object(document))
|
56
2015/13/input
Normal file
56
2015/13/input
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
Alice would gain 54 happiness units by sitting next to Bob.
|
||||||
|
Alice would lose 81 happiness units by sitting next to Carol.
|
||||||
|
Alice would lose 42 happiness units by sitting next to David.
|
||||||
|
Alice would gain 89 happiness units by sitting next to Eric.
|
||||||
|
Alice would lose 89 happiness units by sitting next to Frank.
|
||||||
|
Alice would gain 97 happiness units by sitting next to George.
|
||||||
|
Alice would lose 94 happiness units by sitting next to Mallory.
|
||||||
|
Bob would gain 3 happiness units by sitting next to Alice.
|
||||||
|
Bob would lose 70 happiness units by sitting next to Carol.
|
||||||
|
Bob would lose 31 happiness units by sitting next to David.
|
||||||
|
Bob would gain 72 happiness units by sitting next to Eric.
|
||||||
|
Bob would lose 25 happiness units by sitting next to Frank.
|
||||||
|
Bob would lose 95 happiness units by sitting next to George.
|
||||||
|
Bob would gain 11 happiness units by sitting next to Mallory.
|
||||||
|
Carol would lose 83 happiness units by sitting next to Alice.
|
||||||
|
Carol would gain 8 happiness units by sitting next to Bob.
|
||||||
|
Carol would gain 35 happiness units by sitting next to David.
|
||||||
|
Carol would gain 10 happiness units by sitting next to Eric.
|
||||||
|
Carol would gain 61 happiness units by sitting next to Frank.
|
||||||
|
Carol would gain 10 happiness units by sitting next to George.
|
||||||
|
Carol would gain 29 happiness units by sitting next to Mallory.
|
||||||
|
David would gain 67 happiness units by sitting next to Alice.
|
||||||
|
David would gain 25 happiness units by sitting next to Bob.
|
||||||
|
David would gain 48 happiness units by sitting next to Carol.
|
||||||
|
David would lose 65 happiness units by sitting next to Eric.
|
||||||
|
David would gain 8 happiness units by sitting next to Frank.
|
||||||
|
David would gain 84 happiness units by sitting next to George.
|
||||||
|
David would gain 9 happiness units by sitting next to Mallory.
|
||||||
|
Eric would lose 51 happiness units by sitting next to Alice.
|
||||||
|
Eric would lose 39 happiness units by sitting next to Bob.
|
||||||
|
Eric would gain 84 happiness units by sitting next to Carol.
|
||||||
|
Eric would lose 98 happiness units by sitting next to David.
|
||||||
|
Eric would lose 20 happiness units by sitting next to Frank.
|
||||||
|
Eric would lose 6 happiness units by sitting next to George.
|
||||||
|
Eric would gain 60 happiness units by sitting next to Mallory.
|
||||||
|
Frank would gain 51 happiness units by sitting next to Alice.
|
||||||
|
Frank would gain 79 happiness units by sitting next to Bob.
|
||||||
|
Frank would gain 88 happiness units by sitting next to Carol.
|
||||||
|
Frank would gain 33 happiness units by sitting next to David.
|
||||||
|
Frank would gain 43 happiness units by sitting next to Eric.
|
||||||
|
Frank would gain 77 happiness units by sitting next to George.
|
||||||
|
Frank would lose 3 happiness units by sitting next to Mallory.
|
||||||
|
George would lose 14 happiness units by sitting next to Alice.
|
||||||
|
George would lose 12 happiness units by sitting next to Bob.
|
||||||
|
George would lose 52 happiness units by sitting next to Carol.
|
||||||
|
George would gain 14 happiness units by sitting next to David.
|
||||||
|
George would lose 62 happiness units by sitting next to Eric.
|
||||||
|
George would lose 18 happiness units by sitting next to Frank.
|
||||||
|
George would lose 17 happiness units by sitting next to Mallory.
|
||||||
|
Mallory would lose 36 happiness units by sitting next to Alice.
|
||||||
|
Mallory would gain 76 happiness units by sitting next to Bob.
|
||||||
|
Mallory would lose 34 happiness units by sitting next to Carol.
|
||||||
|
Mallory would gain 37 happiness units by sitting next to David.
|
||||||
|
Mallory would gain 40 happiness units by sitting next to Eric.
|
||||||
|
Mallory would gain 18 happiness units by sitting next to Frank.
|
||||||
|
Mallory would gain 7 happiness units by sitting next to George.
|
40
2015/13/part1.py
Normal file
40
2015/13/part1.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
from itertools import permutations
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
instructions = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
POINTS = defaultdict(int)
|
||||||
|
PERSONS = set()
|
||||||
|
|
||||||
|
for instruction in instructions:
|
||||||
|
person_a, _, sign, points, _, _, _, _, _, _, person_b = instruction.split(" ")
|
||||||
|
person_b = person_b.strip(".")
|
||||||
|
multiplicator = 1 if sign == "gain" else -1
|
||||||
|
points = int(points) * multiplicator
|
||||||
|
|
||||||
|
person_a, person_b = sorted([person_a, person_b])
|
||||||
|
POINTS[(person_a, person_b)] += points
|
||||||
|
PERSONS.add(person_a)
|
||||||
|
PERSONS.add(person_b)
|
||||||
|
|
||||||
|
print("POINTS", POINTS)
|
||||||
|
print("PERSONS", PERSONS)
|
||||||
|
|
||||||
|
HIGHEST_POINTS = None
|
||||||
|
SEATING_ORDER = None
|
||||||
|
|
||||||
|
for seating_plan in permutations(PERSONS, len(PERSONS)):
|
||||||
|
points = 0
|
||||||
|
seating_plan = list(seating_plan)
|
||||||
|
|
||||||
|
for person_a, person_b in zip(seating_plan, seating_plan[1:] + seating_plan[:1]):
|
||||||
|
person_a, person_b = sorted([person_a, person_b])
|
||||||
|
points += POINTS[(person_a, person_b)]
|
||||||
|
|
||||||
|
if HIGHEST_POINTS is None or HIGHEST_POINTS < points:
|
||||||
|
HIGHEST_POINTS = points
|
||||||
|
SEATING_ORDER = seating_plan
|
||||||
|
|
||||||
|
print("Best order:", SEATING_ORDER)
|
||||||
|
print(HIGHEST_POINTS)
|
42
2015/13/part2.py
Normal file
42
2015/13/part2.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
from itertools import permutations
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
instructions = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
POINTS = defaultdict(int)
|
||||||
|
PERSONS = set()
|
||||||
|
PERSONS.add("Me!")
|
||||||
|
|
||||||
|
for instruction in instructions:
|
||||||
|
person_a, _, sign, points, _, _, _, _, _, _, person_b = instruction.split(" ")
|
||||||
|
person_b = person_b.strip(".")
|
||||||
|
multiplicator = 1 if sign == "gain" else -1
|
||||||
|
points = int(points) * multiplicator
|
||||||
|
|
||||||
|
person_a, person_b = sorted([person_a, person_b])
|
||||||
|
POINTS[(person_a, person_b)] += points
|
||||||
|
PERSONS.add(person_a)
|
||||||
|
PERSONS.add(person_b)
|
||||||
|
|
||||||
|
print("POINTS", POINTS)
|
||||||
|
print("PERSONS", PERSONS)
|
||||||
|
print()
|
||||||
|
|
||||||
|
HIGHEST_POINTS = None
|
||||||
|
SEATING_ORDER = None
|
||||||
|
|
||||||
|
for seating_plan in permutations(PERSONS, len(PERSONS)):
|
||||||
|
points = 0
|
||||||
|
seating_plan = list(seating_plan)
|
||||||
|
|
||||||
|
for person_a, person_b in zip(seating_plan, seating_plan[1:] + seating_plan[:1]):
|
||||||
|
person_a, person_b = sorted([person_a, person_b])
|
||||||
|
points += POINTS[(person_a, person_b)]
|
||||||
|
|
||||||
|
if HIGHEST_POINTS is None or HIGHEST_POINTS < points:
|
||||||
|
HIGHEST_POINTS = points
|
||||||
|
SEATING_ORDER = seating_plan
|
||||||
|
|
||||||
|
print("Best order:", SEATING_ORDER)
|
||||||
|
print(HIGHEST_POINTS)
|
9
2015/14/input
Normal file
9
2015/14/input
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Vixen can fly 19 km/s for 7 seconds, but then must rest for 124 seconds.
|
||||||
|
Rudolph can fly 3 km/s for 15 seconds, but then must rest for 28 seconds.
|
||||||
|
Donner can fly 19 km/s for 9 seconds, but then must rest for 164 seconds.
|
||||||
|
Blitzen can fly 19 km/s for 9 seconds, but then must rest for 158 seconds.
|
||||||
|
Comet can fly 13 km/s for 7 seconds, but then must rest for 82 seconds.
|
||||||
|
Cupid can fly 25 km/s for 6 seconds, but then must rest for 145 seconds.
|
||||||
|
Dasher can fly 14 km/s for 3 seconds, but then must rest for 38 seconds.
|
||||||
|
Dancer can fly 3 km/s for 16 seconds, but then must rest for 37 seconds.
|
||||||
|
Prancer can fly 25 km/s for 6 seconds, but then must rest for 143 seconds.
|
28
2015/14/part1.py
Normal file
28
2015/14/part1.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
reindeers = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
TIME_ELAPSED = 2503
|
||||||
|
|
||||||
|
max_distance = 0
|
||||||
|
|
||||||
|
for reindeer in reindeers:
|
||||||
|
name = reindeer.split(" ")[0]
|
||||||
|
[speed, fly_time, rest_time] = [int(x) for x in re.findall("[0-9]+", reindeer)]
|
||||||
|
|
||||||
|
cycle = fly_time + rest_time
|
||||||
|
count_cycles, rest = divmod(TIME_ELAPSED, cycle)
|
||||||
|
rest = min(rest, fly_time)
|
||||||
|
|
||||||
|
distance = count_cycles * fly_time * speed + rest * speed
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"{name.ljust(8)}: {speed}km/s for {fly_time}s, rest {rest_time}s -> {distance}km"
|
||||||
|
)
|
||||||
|
|
||||||
|
if distance > max_distance:
|
||||||
|
max_distance = distance
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(max_distance)
|
54
2015/14/part2.py
Normal file
54
2015/14/part2.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import re
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
lines = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
MAX_TIME = 2503
|
||||||
|
# MAX_TIME = 1000
|
||||||
|
|
||||||
|
|
||||||
|
def get_distance(speed, fly_time, rest_time, time_elapsed):
|
||||||
|
cycle = fly_time + rest_time
|
||||||
|
count_cycles, rest = divmod(time_elapsed, cycle)
|
||||||
|
rest = min(rest, fly_time)
|
||||||
|
distance = count_cycles * fly_time * speed + rest * speed
|
||||||
|
return distance
|
||||||
|
|
||||||
|
|
||||||
|
reindeers = list()
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
name = line.split(" ")[0]
|
||||||
|
[speed, fly_time, rest_time] = [int(x) for x in re.findall("[0-9]+", line)]
|
||||||
|
reindeers.append((name, speed, fly_time, rest_time))
|
||||||
|
|
||||||
|
# example:
|
||||||
|
# reindeers = [("Comet", 14, 10, 127), ("Dancer", 16, 11, 162)]
|
||||||
|
|
||||||
|
POINTS = defaultdict(int)
|
||||||
|
|
||||||
|
for second in range(1, MAX_TIME + 1):
|
||||||
|
max_distance = None
|
||||||
|
leaders = []
|
||||||
|
for reindeer in reindeers:
|
||||||
|
name, speed, fly_time, rest_time = reindeer
|
||||||
|
distance = get_distance(speed, fly_time, rest_time, second)
|
||||||
|
if max_distance is None or distance > max_distance:
|
||||||
|
max_distance = distance
|
||||||
|
leaders = [name]
|
||||||
|
elif distance == max_distance:
|
||||||
|
leaders.append(name)
|
||||||
|
|
||||||
|
for leader in leaders:
|
||||||
|
POINTS[leader] += 1
|
||||||
|
|
||||||
|
print("Standings:")
|
||||||
|
for name, points in POINTS.items():
|
||||||
|
print(f" {name.ljust(8)}: {points}")
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("Winner points:")
|
||||||
|
print(max(POINTS.values()))
|
||||||
|
|
||||||
|
# 472: too low
|
2
2015/15/example
Normal file
2
2015/15/example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8
|
||||||
|
Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3
|
4
2015/15/input
Normal file
4
2015/15/input
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Sprinkles: capacity 5, durability -1, flavor 0, texture 0, calories 5
|
||||||
|
PeanutButter: capacity -1, durability 3, flavor 0, texture 0, calories 1
|
||||||
|
Frosting: capacity 0, durability -1, flavor 4, texture 0, calories 6
|
||||||
|
Sugar: capacity -1, durability 0, flavor 0, texture 2, calories 8
|
68
2015/15/part1.py
Normal file
68
2015/15/part1.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import re
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
# list of ingredients
|
||||||
|
# each line is an ingredient
|
||||||
|
# each col is the property
|
||||||
|
INGREDIENTS = []
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
lines = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
values = re.findall("-?[0-9]+", line)
|
||||||
|
values = [int(x) for x in values]
|
||||||
|
INGREDIENTS.append(values)
|
||||||
|
|
||||||
|
NUM_INGREDIENTS = len(INGREDIENTS)
|
||||||
|
NUM_PROPERTIES = len(INGREDIENTS[0])
|
||||||
|
|
||||||
|
# list of properties
|
||||||
|
# each line is a property
|
||||||
|
# ech col is theingredient
|
||||||
|
PROPERTIES = np.zeros((NUM_PROPERTIES, NUM_INGREDIENTS))
|
||||||
|
for idx_a, values in enumerate(INGREDIENTS):
|
||||||
|
for idx_b, value in enumerate(values):
|
||||||
|
PROPERTIES[idx_b][idx_a] = value
|
||||||
|
|
||||||
|
|
||||||
|
print(INGREDIENTS)
|
||||||
|
print(PROPERTIES)
|
||||||
|
|
||||||
|
max_score = 0
|
||||||
|
amounts = None
|
||||||
|
|
||||||
|
for a in range(0, 101):
|
||||||
|
print(a)
|
||||||
|
for b in range(0, 101 - a):
|
||||||
|
for c in range(0, 101 - (a + b)):
|
||||||
|
for d in range(0, 101 - (a + b + c)):
|
||||||
|
score = 1
|
||||||
|
multipliers = [a, b, c, d]
|
||||||
|
for prop in PROPERTIES[:-1]:
|
||||||
|
prop_sum = sum([a * b for a, b in zip(prop, multipliers)])
|
||||||
|
if prop_sum < 0:
|
||||||
|
prop_sum = 0
|
||||||
|
score *= prop_sum
|
||||||
|
|
||||||
|
if score > max_score:
|
||||||
|
max_score = score
|
||||||
|
amounts = [a, b, c, d]
|
||||||
|
# print("New leader:", score, amounts)
|
||||||
|
|
||||||
|
print("finish")
|
||||||
|
print(int(max_score))
|
||||||
|
print(amounts)
|
||||||
|
|
||||||
|
multipliers = amounts
|
||||||
|
score = 1
|
||||||
|
for prop in PROPERTIES:
|
||||||
|
prop_sum = sum([a * b for a, b in zip(prop, multipliers)])
|
||||||
|
if prop_sum < 0:
|
||||||
|
prop_sum = 0
|
||||||
|
score *= prop_sum
|
||||||
|
print("score", prop_sum)
|
||||||
|
|
||||||
|
|
||||||
|
# 35087450112 too high [0, 0, ?, ?]
|
||||||
|
# 6211814400 too high [28, 32, 18, 22]
|
71
2015/15/part2.py
Normal file
71
2015/15/part2.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import re
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
# list of ingredients
|
||||||
|
# each line is an ingredient
|
||||||
|
# each col is the property
|
||||||
|
INGREDIENTS = []
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
lines = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
values = re.findall("-?[0-9]+", line)
|
||||||
|
values = [int(x) for x in values]
|
||||||
|
INGREDIENTS.append(values)
|
||||||
|
|
||||||
|
NUM_INGREDIENTS = len(INGREDIENTS)
|
||||||
|
NUM_PROPERTIES = len(INGREDIENTS[0])
|
||||||
|
|
||||||
|
# list of properties
|
||||||
|
# each line is a property
|
||||||
|
# ech col is theingredient
|
||||||
|
PROPERTIES = np.zeros((NUM_PROPERTIES, NUM_INGREDIENTS))
|
||||||
|
for idx_a, values in enumerate(INGREDIENTS):
|
||||||
|
for idx_b, value in enumerate(values):
|
||||||
|
PROPERTIES[idx_b][idx_a] = value
|
||||||
|
|
||||||
|
|
||||||
|
print(INGREDIENTS)
|
||||||
|
print(PROPERTIES)
|
||||||
|
|
||||||
|
max_score = 0
|
||||||
|
amounts = None
|
||||||
|
|
||||||
|
for a in range(0, 101):
|
||||||
|
print(a)
|
||||||
|
for b in range(0, 101 - a):
|
||||||
|
for c in range(0, 101 - (a + b)):
|
||||||
|
for d in range(0, 101 - (a + b + c)):
|
||||||
|
score = 1
|
||||||
|
multipliers = [a, b, c, d]
|
||||||
|
calorie_sum = sum([a * b for a, b in zip(PROPERTIES[-1], multipliers)])
|
||||||
|
if calorie_sum != 500:
|
||||||
|
continue
|
||||||
|
for prop in PROPERTIES[:-1]:
|
||||||
|
prop_sum = sum([a * b for a, b in zip(prop, multipliers)])
|
||||||
|
if prop_sum < 0:
|
||||||
|
prop_sum = 0
|
||||||
|
score *= prop_sum
|
||||||
|
|
||||||
|
if score > max_score:
|
||||||
|
max_score = score
|
||||||
|
amounts = [a, b, c, d]
|
||||||
|
# print("New leader:", score, amounts)
|
||||||
|
|
||||||
|
print("finish")
|
||||||
|
print(int(max_score))
|
||||||
|
print(amounts)
|
||||||
|
|
||||||
|
multipliers = amounts
|
||||||
|
score = 1
|
||||||
|
for prop in PROPERTIES:
|
||||||
|
prop_sum = sum([a * b for a, b in zip(prop, multipliers)])
|
||||||
|
if prop_sum < 0:
|
||||||
|
prop_sum = 0
|
||||||
|
score *= prop_sum
|
||||||
|
print("score", prop_sum)
|
||||||
|
|
||||||
|
|
||||||
|
# 35087450112 too high [0, 0, ?, ?]
|
||||||
|
# 6211814400 too high [28, 32, 18, 22]
|
10
2015/16/components
Normal file
10
2015/16/components
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
children: 3
|
||||||
|
cats: 7
|
||||||
|
samoyeds: 2
|
||||||
|
pomeranians: 3
|
||||||
|
akitas: 0
|
||||||
|
vizslas: 0
|
||||||
|
goldfish: 5
|
||||||
|
trees: 3
|
||||||
|
cars: 2
|
||||||
|
perfumes: 1
|
500
2015/16/input
Normal file
500
2015/16/input
Normal file
@ -0,0 +1,500 @@
|
|||||||
|
Sue 1: goldfish: 6, trees: 9, akitas: 0
|
||||||
|
Sue 2: goldfish: 7, trees: 1, akitas: 0
|
||||||
|
Sue 3: cars: 10, akitas: 6, perfumes: 7
|
||||||
|
Sue 4: perfumes: 2, vizslas: 0, cars: 6
|
||||||
|
Sue 5: goldfish: 1, trees: 3, perfumes: 10
|
||||||
|
Sue 6: children: 9, vizslas: 7, cars: 9
|
||||||
|
Sue 7: cars: 6, vizslas: 5, cats: 3
|
||||||
|
Sue 8: akitas: 10, vizslas: 9, children: 3
|
||||||
|
Sue 9: vizslas: 8, cats: 2, trees: 1
|
||||||
|
Sue 10: perfumes: 10, trees: 6, cars: 4
|
||||||
|
Sue 11: cars: 9, children: 1, cats: 1
|
||||||
|
Sue 12: pomeranians: 4, akitas: 6, goldfish: 8
|
||||||
|
Sue 13: cats: 10, children: 5, trees: 9
|
||||||
|
Sue 14: perfumes: 8, vizslas: 3, samoyeds: 1
|
||||||
|
Sue 15: vizslas: 2, perfumes: 8, trees: 3
|
||||||
|
Sue 16: pomeranians: 10, trees: 9, samoyeds: 4
|
||||||
|
Sue 17: akitas: 7, vizslas: 0, goldfish: 6
|
||||||
|
Sue 18: trees: 5, vizslas: 9, cars: 0
|
||||||
|
Sue 19: akitas: 3, goldfish: 9, trees: 10
|
||||||
|
Sue 20: perfumes: 7, samoyeds: 3, vizslas: 10
|
||||||
|
Sue 21: perfumes: 7, pomeranians: 10, akitas: 8
|
||||||
|
Sue 22: vizslas: 6, trees: 8, akitas: 10
|
||||||
|
Sue 23: goldfish: 0, trees: 4, children: 9
|
||||||
|
Sue 24: goldfish: 7, pomeranians: 9, akitas: 4
|
||||||
|
Sue 25: cars: 7, trees: 4, pomeranians: 4
|
||||||
|
Sue 26: trees: 9, akitas: 9, pomeranians: 7
|
||||||
|
Sue 27: samoyeds: 0, perfumes: 9, goldfish: 10
|
||||||
|
Sue 28: cars: 5, trees: 7, vizslas: 1
|
||||||
|
Sue 29: perfumes: 9, trees: 1, children: 6
|
||||||
|
Sue 30: goldfish: 10, trees: 0, cars: 4
|
||||||
|
Sue 31: akitas: 2, perfumes: 5, goldfish: 5
|
||||||
|
Sue 32: goldfish: 0, akitas: 5, trees: 0
|
||||||
|
Sue 33: vizslas: 2, akitas: 2, samoyeds: 3
|
||||||
|
Sue 34: goldfish: 8, perfumes: 5, cars: 3
|
||||||
|
Sue 35: akitas: 1, cats: 4, trees: 9
|
||||||
|
Sue 36: cars: 4, vizslas: 4, goldfish: 7
|
||||||
|
Sue 37: akitas: 5, perfumes: 7, trees: 3
|
||||||
|
Sue 38: goldfish: 10, trees: 2, vizslas: 9
|
||||||
|
Sue 39: goldfish: 4, pomeranians: 5, vizslas: 5
|
||||||
|
Sue 40: perfumes: 5, samoyeds: 4, akitas: 6
|
||||||
|
Sue 41: goldfish: 9, cars: 4, perfumes: 5
|
||||||
|
Sue 42: trees: 6, pomeranians: 9, goldfish: 8
|
||||||
|
Sue 43: perfumes: 7, pomeranians: 1, akitas: 2
|
||||||
|
Sue 44: vizslas: 9, cars: 5, cats: 0
|
||||||
|
Sue 45: akitas: 1, goldfish: 6, trees: 0
|
||||||
|
Sue 46: akitas: 5, vizslas: 8, trees: 2
|
||||||
|
Sue 47: trees: 9, akitas: 2, vizslas: 9
|
||||||
|
Sue 48: goldfish: 10, trees: 5, akitas: 2
|
||||||
|
Sue 49: cars: 7, vizslas: 2, perfumes: 6
|
||||||
|
Sue 50: akitas: 5, goldfish: 6, perfumes: 0
|
||||||
|
Sue 51: cars: 9, cats: 7, trees: 5
|
||||||
|
Sue 52: akitas: 7, goldfish: 10, cars: 0
|
||||||
|
Sue 53: cars: 10, cats: 4, perfumes: 2
|
||||||
|
Sue 54: goldfish: 2, pomeranians: 5, perfumes: 10
|
||||||
|
Sue 55: vizslas: 5, akitas: 4, cars: 8
|
||||||
|
Sue 56: goldfish: 9, vizslas: 4, akitas: 5
|
||||||
|
Sue 57: perfumes: 8, samoyeds: 7, cars: 9
|
||||||
|
Sue 58: cars: 5, akitas: 7, perfumes: 8
|
||||||
|
Sue 59: samoyeds: 8, cars: 10, vizslas: 10
|
||||||
|
Sue 60: akitas: 6, samoyeds: 0, goldfish: 3
|
||||||
|
Sue 61: trees: 8, pomeranians: 0, akitas: 2
|
||||||
|
Sue 62: trees: 1, perfumes: 3, vizslas: 4
|
||||||
|
Sue 63: vizslas: 6, samoyeds: 9, goldfish: 8
|
||||||
|
Sue 64: goldfish: 7, trees: 6, vizslas: 3
|
||||||
|
Sue 65: cars: 1, vizslas: 0, akitas: 6
|
||||||
|
Sue 66: cats: 6, pomeranians: 4, cars: 9
|
||||||
|
Sue 67: trees: 10, pomeranians: 7, samoyeds: 3
|
||||||
|
Sue 68: pomeranians: 5, goldfish: 9, akitas: 1
|
||||||
|
Sue 69: akitas: 1, vizslas: 0, trees: 9
|
||||||
|
Sue 70: cats: 4, goldfish: 4, vizslas: 10
|
||||||
|
Sue 71: vizslas: 7, perfumes: 7, trees: 8
|
||||||
|
Sue 72: children: 2, vizslas: 9, cats: 3
|
||||||
|
Sue 73: cars: 8, pomeranians: 0, perfumes: 6
|
||||||
|
Sue 74: akitas: 1, pomeranians: 8, vizslas: 10
|
||||||
|
Sue 75: vizslas: 5, perfumes: 5, cars: 7
|
||||||
|
Sue 76: cars: 3, vizslas: 3, goldfish: 0
|
||||||
|
Sue 77: akitas: 9, samoyeds: 1, pomeranians: 3
|
||||||
|
Sue 78: trees: 0, vizslas: 0, akitas: 6
|
||||||
|
Sue 79: pomeranians: 9, cars: 1, perfumes: 0
|
||||||
|
Sue 80: perfumes: 10, trees: 1, cats: 0
|
||||||
|
Sue 81: goldfish: 5, akitas: 9, trees: 0
|
||||||
|
Sue 82: vizslas: 1, akitas: 6, children: 4
|
||||||
|
Sue 83: samoyeds: 7, perfumes: 8, pomeranians: 4
|
||||||
|
Sue 84: perfumes: 3, children: 3, cats: 7
|
||||||
|
Sue 85: goldfish: 9, trees: 3, cars: 9
|
||||||
|
Sue 86: cars: 0, perfumes: 9, vizslas: 0
|
||||||
|
Sue 87: children: 3, trees: 4, akitas: 3
|
||||||
|
Sue 88: trees: 1, samoyeds: 1, goldfish: 0
|
||||||
|
Sue 89: akitas: 8, cars: 3, vizslas: 9
|
||||||
|
Sue 90: pomeranians: 9, trees: 9, goldfish: 8
|
||||||
|
Sue 91: goldfish: 7, trees: 10, children: 0
|
||||||
|
Sue 92: cats: 9, cars: 7, perfumes: 7
|
||||||
|
Sue 93: vizslas: 2, goldfish: 7, cats: 9
|
||||||
|
Sue 94: akitas: 5, cars: 8, vizslas: 4
|
||||||
|
Sue 95: goldfish: 7, vizslas: 1, perfumes: 2
|
||||||
|
Sue 96: goldfish: 5, trees: 6, perfumes: 10
|
||||||
|
Sue 97: trees: 0, perfumes: 7, cars: 0
|
||||||
|
Sue 98: cars: 2, perfumes: 6, trees: 8
|
||||||
|
Sue 99: trees: 10, children: 7, cats: 9
|
||||||
|
Sue 100: samoyeds: 5, goldfish: 6, vizslas: 6
|
||||||
|
Sue 101: cars: 10, perfumes: 9, vizslas: 3
|
||||||
|
Sue 102: pomeranians: 6, trees: 1, samoyeds: 4
|
||||||
|
Sue 103: cars: 2, perfumes: 1, goldfish: 5
|
||||||
|
Sue 104: goldfish: 2, cars: 8, pomeranians: 2
|
||||||
|
Sue 105: goldfish: 6, vizslas: 0, trees: 10
|
||||||
|
Sue 106: trees: 10, akitas: 10, pomeranians: 0
|
||||||
|
Sue 107: vizslas: 2, pomeranians: 10, trees: 3
|
||||||
|
Sue 108: children: 3, vizslas: 8, akitas: 7
|
||||||
|
Sue 109: perfumes: 2, akitas: 2, samoyeds: 3
|
||||||
|
Sue 110: goldfish: 7, trees: 1, perfumes: 1
|
||||||
|
Sue 111: akitas: 2, cars: 9, perfumes: 2
|
||||||
|
Sue 112: children: 10, cars: 0, akitas: 3
|
||||||
|
Sue 113: akitas: 9, vizslas: 4, children: 3
|
||||||
|
Sue 114: pomeranians: 3, trees: 2, goldfish: 5
|
||||||
|
Sue 115: perfumes: 8, cars: 6, trees: 0
|
||||||
|
Sue 116: samoyeds: 6, children: 3, pomeranians: 1
|
||||||
|
Sue 117: goldfish: 1, trees: 2, akitas: 1
|
||||||
|
Sue 118: goldfish: 10, akitas: 10, samoyeds: 0
|
||||||
|
Sue 119: vizslas: 10, perfumes: 6, cars: 0
|
||||||
|
Sue 120: cars: 2, perfumes: 9, goldfish: 5
|
||||||
|
Sue 121: vizslas: 2, trees: 2, cars: 6
|
||||||
|
Sue 122: vizslas: 3, trees: 0, akitas: 2
|
||||||
|
Sue 123: akitas: 5, samoyeds: 7, goldfish: 1
|
||||||
|
Sue 124: goldfish: 8, samoyeds: 7, trees: 8
|
||||||
|
Sue 125: trees: 3, goldfish: 8, perfumes: 5
|
||||||
|
Sue 126: cats: 3, vizslas: 9, goldfish: 0
|
||||||
|
Sue 127: pomeranians: 9, goldfish: 3, perfumes: 6
|
||||||
|
Sue 128: vizslas: 4, cars: 8, goldfish: 5
|
||||||
|
Sue 129: vizslas: 8, children: 5, perfumes: 8
|
||||||
|
Sue 130: cars: 7, children: 7, cats: 3
|
||||||
|
Sue 131: perfumes: 1, akitas: 8, vizslas: 9
|
||||||
|
Sue 132: perfumes: 7, samoyeds: 10, pomeranians: 6
|
||||||
|
Sue 133: cars: 5, perfumes: 3, goldfish: 7
|
||||||
|
Sue 134: perfumes: 9, akitas: 2, cats: 3
|
||||||
|
Sue 135: perfumes: 1, trees: 9, vizslas: 9
|
||||||
|
Sue 136: akitas: 7, cars: 3, perfumes: 7
|
||||||
|
Sue 137: vizslas: 9, goldfish: 8, cars: 5
|
||||||
|
Sue 138: trees: 0, samoyeds: 1, cars: 3
|
||||||
|
Sue 139: cars: 0, perfumes: 6, trees: 0
|
||||||
|
Sue 140: pomeranians: 4, cars: 1, perfumes: 7
|
||||||
|
Sue 141: vizslas: 10, akitas: 8, cats: 3
|
||||||
|
Sue 142: trees: 1, cats: 6, vizslas: 5
|
||||||
|
Sue 143: pomeranians: 9, cars: 7, perfumes: 9
|
||||||
|
Sue 144: cars: 0, perfumes: 2, pomeranians: 1
|
||||||
|
Sue 145: trees: 1, goldfish: 9, perfumes: 8
|
||||||
|
Sue 146: cars: 8, children: 5, vizslas: 2
|
||||||
|
Sue 147: perfumes: 2, goldfish: 5, cars: 0
|
||||||
|
Sue 148: akitas: 2, perfumes: 7, pomeranians: 6
|
||||||
|
Sue 149: goldfish: 8, cars: 0, trees: 1
|
||||||
|
Sue 150: akitas: 6, perfumes: 5, trees: 0
|
||||||
|
Sue 151: vizslas: 6, samoyeds: 8, akitas: 10
|
||||||
|
Sue 152: trees: 7, akitas: 7, perfumes: 6
|
||||||
|
Sue 153: goldfish: 9, cats: 9, cars: 3
|
||||||
|
Sue 154: vizslas: 10, trees: 0, cars: 9
|
||||||
|
Sue 155: perfumes: 3, children: 2, goldfish: 1
|
||||||
|
Sue 156: goldfish: 7, perfumes: 5, akitas: 6
|
||||||
|
Sue 157: cats: 10, trees: 1, goldfish: 0
|
||||||
|
Sue 158: cats: 7, children: 7, vizslas: 6
|
||||||
|
Sue 159: perfumes: 9, akitas: 0, cars: 0
|
||||||
|
Sue 160: akitas: 3, goldfish: 10, pomeranians: 2
|
||||||
|
Sue 161: goldfish: 10, cars: 6, perfumes: 3
|
||||||
|
Sue 162: trees: 0, cars: 9, goldfish: 1
|
||||||
|
Sue 163: cars: 8, perfumes: 9, vizslas: 5
|
||||||
|
Sue 164: goldfish: 1, trees: 10, children: 6
|
||||||
|
Sue 165: goldfish: 0, vizslas: 6, cars: 0
|
||||||
|
Sue 166: akitas: 5, vizslas: 1, cars: 5
|
||||||
|
Sue 167: vizslas: 1, samoyeds: 1, children: 4
|
||||||
|
Sue 168: samoyeds: 7, vizslas: 7, akitas: 3
|
||||||
|
Sue 169: goldfish: 3, cats: 9, trees: 2
|
||||||
|
Sue 170: cars: 5, perfumes: 9, vizslas: 5
|
||||||
|
Sue 171: goldfish: 7, cars: 6, perfumes: 10
|
||||||
|
Sue 172: cats: 6, akitas: 1, children: 6
|
||||||
|
Sue 173: cats: 4, goldfish: 1, children: 3
|
||||||
|
Sue 174: cars: 2, pomeranians: 2, vizslas: 7
|
||||||
|
Sue 175: trees: 0, children: 4, goldfish: 7
|
||||||
|
Sue 176: children: 8, cars: 5, cats: 9
|
||||||
|
Sue 177: pomeranians: 4, vizslas: 7, trees: 3
|
||||||
|
Sue 178: vizslas: 6, perfumes: 10, akitas: 6
|
||||||
|
Sue 179: cars: 4, akitas: 4, trees: 4
|
||||||
|
Sue 180: akitas: 8, goldfish: 6, trees: 9
|
||||||
|
Sue 181: perfumes: 3, vizslas: 10, cars: 3
|
||||||
|
Sue 182: vizslas: 3, samoyeds: 3, goldfish: 7
|
||||||
|
Sue 183: goldfish: 10, perfumes: 2, cats: 1
|
||||||
|
Sue 184: goldfish: 5, trees: 1, perfumes: 1
|
||||||
|
Sue 185: vizslas: 10, trees: 9, perfumes: 2
|
||||||
|
Sue 186: goldfish: 6, perfumes: 9, trees: 1
|
||||||
|
Sue 187: cars: 0, trees: 9, goldfish: 6
|
||||||
|
Sue 188: cars: 0, trees: 1, vizslas: 9
|
||||||
|
Sue 189: akitas: 7, vizslas: 2, trees: 0
|
||||||
|
Sue 190: pomeranians: 5, perfumes: 8, akitas: 10
|
||||||
|
Sue 191: vizslas: 5, akitas: 3, cats: 0
|
||||||
|
Sue 192: children: 1, trees: 1, cars: 2
|
||||||
|
Sue 193: cars: 3, goldfish: 9, trees: 2
|
||||||
|
Sue 194: samoyeds: 3, akitas: 4, perfumes: 8
|
||||||
|
Sue 195: trees: 1, vizslas: 8, akitas: 10
|
||||||
|
Sue 196: akitas: 6, cars: 5, pomeranians: 0
|
||||||
|
Sue 197: akitas: 5, vizslas: 5, cats: 1
|
||||||
|
Sue 198: trees: 4, cars: 6, goldfish: 6
|
||||||
|
Sue 199: cats: 7, cars: 5, goldfish: 6
|
||||||
|
Sue 200: vizslas: 4, cats: 0, akitas: 9
|
||||||
|
Sue 201: pomeranians: 1, perfumes: 4, children: 2
|
||||||
|
Sue 202: cats: 1, perfumes: 4, vizslas: 3
|
||||||
|
Sue 203: vizslas: 1, akitas: 9, children: 5
|
||||||
|
Sue 204: perfumes: 8, cars: 7, trees: 4
|
||||||
|
Sue 205: perfumes: 7, pomeranians: 5, cats: 9
|
||||||
|
Sue 206: vizslas: 8, trees: 2, akitas: 2
|
||||||
|
Sue 207: akitas: 6, vizslas: 2, perfumes: 10
|
||||||
|
Sue 208: vizslas: 1, children: 7, akitas: 4
|
||||||
|
Sue 209: perfumes: 4, trees: 2, children: 1
|
||||||
|
Sue 210: goldfish: 0, vizslas: 2, samoyeds: 10
|
||||||
|
Sue 211: cars: 8, perfumes: 3, trees: 1
|
||||||
|
Sue 212: cars: 8, samoyeds: 5, pomeranians: 8
|
||||||
|
Sue 213: akitas: 2, goldfish: 8, pomeranians: 2
|
||||||
|
Sue 214: akitas: 6, pomeranians: 2, cars: 0
|
||||||
|
Sue 215: trees: 10, pomeranians: 4, vizslas: 0
|
||||||
|
Sue 216: perfumes: 0, cars: 8, trees: 0
|
||||||
|
Sue 217: samoyeds: 8, akitas: 7, children: 10
|
||||||
|
Sue 218: perfumes: 1, vizslas: 6, children: 0
|
||||||
|
Sue 219: children: 1, goldfish: 4, trees: 1
|
||||||
|
Sue 220: akitas: 10, goldfish: 10, trees: 5
|
||||||
|
Sue 221: cars: 7, pomeranians: 6, perfumes: 3
|
||||||
|
Sue 222: vizslas: 6, children: 0, akitas: 5
|
||||||
|
Sue 223: perfumes: 9, cars: 1, trees: 6
|
||||||
|
Sue 224: pomeranians: 1, trees: 0, vizslas: 0
|
||||||
|
Sue 225: goldfish: 8, akitas: 4, perfumes: 10
|
||||||
|
Sue 226: pomeranians: 7, cats: 7, children: 4
|
||||||
|
Sue 227: trees: 0, akitas: 2, perfumes: 1
|
||||||
|
Sue 228: vizslas: 6, cars: 10, perfumes: 9
|
||||||
|
Sue 229: cars: 0, perfumes: 6, trees: 4
|
||||||
|
Sue 230: pomeranians: 7, perfumes: 5, trees: 2
|
||||||
|
Sue 231: goldfish: 9, cars: 6, trees: 7
|
||||||
|
Sue 232: akitas: 1, vizslas: 5, cars: 3
|
||||||
|
Sue 233: akitas: 7, samoyeds: 2, vizslas: 5
|
||||||
|
Sue 234: akitas: 6, cats: 8, pomeranians: 0
|
||||||
|
Sue 235: pomeranians: 5, akitas: 5, vizslas: 3
|
||||||
|
Sue 236: goldfish: 5, trees: 6, akitas: 5
|
||||||
|
Sue 237: goldfish: 9, perfumes: 5, cats: 5
|
||||||
|
Sue 238: cats: 8, goldfish: 4, perfumes: 0
|
||||||
|
Sue 239: samoyeds: 8, children: 6, pomeranians: 6
|
||||||
|
Sue 240: akitas: 4, samoyeds: 10, trees: 8
|
||||||
|
Sue 241: trees: 2, goldfish: 8, cars: 1
|
||||||
|
Sue 242: perfumes: 2, cars: 0, akitas: 10
|
||||||
|
Sue 243: pomeranians: 1, cars: 7, trees: 2
|
||||||
|
Sue 244: trees: 9, vizslas: 2, akitas: 10
|
||||||
|
Sue 245: cars: 9, pomeranians: 4, trees: 0
|
||||||
|
Sue 246: cars: 9, pomeranians: 7, perfumes: 1
|
||||||
|
Sue 247: trees: 0, goldfish: 1, akitas: 8
|
||||||
|
Sue 248: vizslas: 1, cats: 4, akitas: 4
|
||||||
|
Sue 249: cats: 6, children: 4, goldfish: 9
|
||||||
|
Sue 250: vizslas: 1, cars: 10, samoyeds: 5
|
||||||
|
Sue 251: cars: 0, goldfish: 1, vizslas: 7
|
||||||
|
Sue 252: cars: 7, akitas: 9, vizslas: 10
|
||||||
|
Sue 253: akitas: 7, vizslas: 2, perfumes: 5
|
||||||
|
Sue 254: vizslas: 10, akitas: 5, samoyeds: 0
|
||||||
|
Sue 255: pomeranians: 8, goldfish: 0, cats: 6
|
||||||
|
Sue 256: cars: 10, goldfish: 8, vizslas: 9
|
||||||
|
Sue 257: goldfish: 3, perfumes: 9, cats: 3
|
||||||
|
Sue 258: trees: 6, goldfish: 6, cars: 6
|
||||||
|
Sue 259: trees: 0, goldfish: 2, perfumes: 8
|
||||||
|
Sue 260: trees: 5, akitas: 0, cars: 0
|
||||||
|
Sue 261: pomeranians: 9, goldfish: 7, perfumes: 8
|
||||||
|
Sue 262: perfumes: 8, vizslas: 6, goldfish: 2
|
||||||
|
Sue 263: vizslas: 6, trees: 5, goldfish: 9
|
||||||
|
Sue 264: vizslas: 4, perfumes: 7, cars: 9
|
||||||
|
Sue 265: goldfish: 10, trees: 3, perfumes: 1
|
||||||
|
Sue 266: trees: 10, akitas: 8, goldfish: 8
|
||||||
|
Sue 267: goldfish: 4, trees: 0, samoyeds: 9
|
||||||
|
Sue 268: vizslas: 1, trees: 0, goldfish: 8
|
||||||
|
Sue 269: cars: 2, perfumes: 10, goldfish: 5
|
||||||
|
Sue 270: perfumes: 7, cars: 2, vizslas: 1
|
||||||
|
Sue 271: cars: 6, perfumes: 10, goldfish: 6
|
||||||
|
Sue 272: samoyeds: 4, goldfish: 2, vizslas: 9
|
||||||
|
Sue 273: perfumes: 4, goldfish: 4, vizslas: 1
|
||||||
|
Sue 274: children: 4, cars: 4, perfumes: 3
|
||||||
|
Sue 275: children: 8, vizslas: 3, trees: 2
|
||||||
|
Sue 276: vizslas: 5, children: 7, perfumes: 3
|
||||||
|
Sue 277: perfumes: 3, cats: 4, vizslas: 5
|
||||||
|
Sue 278: cars: 1, samoyeds: 10, akitas: 2
|
||||||
|
Sue 279: trees: 9, perfumes: 9, cars: 10
|
||||||
|
Sue 280: vizslas: 5, trees: 0, perfumes: 6
|
||||||
|
Sue 281: vizslas: 3, akitas: 10, pomeranians: 7
|
||||||
|
Sue 282: trees: 1, children: 2, akitas: 8
|
||||||
|
Sue 283: akitas: 9, goldfish: 6, cats: 5
|
||||||
|
Sue 284: cars: 9, children: 10, pomeranians: 2
|
||||||
|
Sue 285: pomeranians: 0, perfumes: 4, cars: 7
|
||||||
|
Sue 286: perfumes: 0, vizslas: 10, akitas: 10
|
||||||
|
Sue 287: cats: 2, perfumes: 3, trees: 5
|
||||||
|
Sue 288: akitas: 9, vizslas: 8, samoyeds: 9
|
||||||
|
Sue 289: perfumes: 6, children: 2, cars: 7
|
||||||
|
Sue 290: akitas: 0, children: 5, cars: 5
|
||||||
|
Sue 291: cars: 4, perfumes: 0, trees: 1
|
||||||
|
Sue 292: cats: 0, cars: 8, perfumes: 6
|
||||||
|
Sue 293: akitas: 9, cats: 5, children: 5
|
||||||
|
Sue 294: akitas: 4, cars: 9, goldfish: 3
|
||||||
|
Sue 295: cars: 2, akitas: 3, perfumes: 7
|
||||||
|
Sue 296: perfumes: 4, cars: 7, goldfish: 10
|
||||||
|
Sue 297: trees: 5, akitas: 8, vizslas: 1
|
||||||
|
Sue 298: perfumes: 0, goldfish: 6, trees: 9
|
||||||
|
Sue 299: perfumes: 6, samoyeds: 8, cars: 1
|
||||||
|
Sue 300: goldfish: 10, perfumes: 4, akitas: 2
|
||||||
|
Sue 301: cars: 3, trees: 0, goldfish: 8
|
||||||
|
Sue 302: perfumes: 7, samoyeds: 2, vizslas: 7
|
||||||
|
Sue 303: children: 10, goldfish: 7, perfumes: 2
|
||||||
|
Sue 304: samoyeds: 8, vizslas: 2, cars: 1
|
||||||
|
Sue 305: trees: 1, cats: 0, goldfish: 10
|
||||||
|
Sue 306: trees: 4, perfumes: 2, cars: 7
|
||||||
|
Sue 307: cars: 6, vizslas: 2, children: 6
|
||||||
|
Sue 308: vizslas: 2, cars: 0, akitas: 7
|
||||||
|
Sue 309: cars: 3, vizslas: 8, perfumes: 6
|
||||||
|
Sue 310: goldfish: 7, perfumes: 7, vizslas: 3
|
||||||
|
Sue 311: pomeranians: 10, trees: 2, cars: 0
|
||||||
|
Sue 312: samoyeds: 2, vizslas: 9, akitas: 1
|
||||||
|
Sue 313: cars: 4, pomeranians: 7, goldfish: 7
|
||||||
|
Sue 314: akitas: 2, pomeranians: 9, samoyeds: 10
|
||||||
|
Sue 315: akitas: 3, vizslas: 2, trees: 0
|
||||||
|
Sue 316: cars: 0, perfumes: 4, pomeranians: 6
|
||||||
|
Sue 317: akitas: 10, goldfish: 3, pomeranians: 7
|
||||||
|
Sue 318: cars: 9, trees: 0, pomeranians: 9
|
||||||
|
Sue 319: akitas: 3, vizslas: 7, children: 10
|
||||||
|
Sue 320: vizslas: 0, akitas: 8, pomeranians: 4
|
||||||
|
Sue 321: cars: 10, akitas: 9, vizslas: 3
|
||||||
|
Sue 322: perfumes: 0, akitas: 8, vizslas: 6
|
||||||
|
Sue 323: vizslas: 10, perfumes: 5, cars: 3
|
||||||
|
Sue 324: akitas: 0, goldfish: 6, vizslas: 7
|
||||||
|
Sue 325: perfumes: 9, vizslas: 5, pomeranians: 2
|
||||||
|
Sue 326: vizslas: 6, goldfish: 10, pomeranians: 8
|
||||||
|
Sue 327: vizslas: 10, cars: 1, akitas: 7
|
||||||
|
Sue 328: trees: 1, perfumes: 10, cars: 10
|
||||||
|
Sue 329: pomeranians: 5, samoyeds: 3, cars: 10
|
||||||
|
Sue 330: akitas: 6, cars: 1, pomeranians: 4
|
||||||
|
Sue 331: cars: 5, children: 2, trees: 0
|
||||||
|
Sue 332: vizslas: 6, pomeranians: 1, perfumes: 0
|
||||||
|
Sue 333: akitas: 7, trees: 1, cats: 9
|
||||||
|
Sue 334: vizslas: 6, goldfish: 9, akitas: 7
|
||||||
|
Sue 335: akitas: 3, samoyeds: 3, cars: 3
|
||||||
|
Sue 336: samoyeds: 10, perfumes: 9, trees: 6
|
||||||
|
Sue 337: vizslas: 2, cars: 9, akitas: 0
|
||||||
|
Sue 338: akitas: 6, perfumes: 9, vizslas: 3
|
||||||
|
Sue 339: cars: 3, samoyeds: 8, trees: 2
|
||||||
|
Sue 340: cats: 7, perfumes: 8, cars: 9
|
||||||
|
Sue 341: goldfish: 9, perfumes: 5, cars: 10
|
||||||
|
Sue 342: trees: 0, akitas: 3, perfumes: 5
|
||||||
|
Sue 343: perfumes: 2, children: 0, cars: 6
|
||||||
|
Sue 344: goldfish: 8, trees: 8, perfumes: 0
|
||||||
|
Sue 345: perfumes: 6, cars: 6, goldfish: 5
|
||||||
|
Sue 346: vizslas: 8, trees: 1, cars: 6
|
||||||
|
Sue 347: cars: 0, cats: 3, perfumes: 7
|
||||||
|
Sue 348: children: 7, perfumes: 10, cars: 7
|
||||||
|
Sue 349: pomeranians: 8, akitas: 5, children: 2
|
||||||
|
Sue 350: perfumes: 9, pomeranians: 4, goldfish: 3
|
||||||
|
Sue 351: perfumes: 8, pomeranians: 7, trees: 4
|
||||||
|
Sue 352: samoyeds: 1, goldfish: 9, akitas: 8
|
||||||
|
Sue 353: akitas: 6, goldfish: 10, vizslas: 8
|
||||||
|
Sue 354: akitas: 7, cars: 2, goldfish: 6
|
||||||
|
Sue 355: cars: 3, goldfish: 6, akitas: 5
|
||||||
|
Sue 356: akitas: 2, goldfish: 9, pomeranians: 1
|
||||||
|
Sue 357: goldfish: 10, cars: 6, pomeranians: 9
|
||||||
|
Sue 358: trees: 0, children: 2, goldfish: 6
|
||||||
|
Sue 359: samoyeds: 3, cars: 2, akitas: 4
|
||||||
|
Sue 360: trees: 1, goldfish: 8, cars: 5
|
||||||
|
Sue 361: akitas: 5, vizslas: 7, perfumes: 1
|
||||||
|
Sue 362: cats: 5, vizslas: 9, children: 4
|
||||||
|
Sue 363: goldfish: 9, perfumes: 3, vizslas: 9
|
||||||
|
Sue 364: children: 7, samoyeds: 2, pomeranians: 10
|
||||||
|
Sue 365: perfumes: 9, akitas: 10, pomeranians: 4
|
||||||
|
Sue 366: cars: 10, trees: 3, cats: 4
|
||||||
|
Sue 367: vizslas: 6, akitas: 10, perfumes: 5
|
||||||
|
Sue 368: akitas: 9, vizslas: 9, children: 4
|
||||||
|
Sue 369: goldfish: 8, trees: 2, perfumes: 5
|
||||||
|
Sue 370: trees: 0, children: 4, cars: 8
|
||||||
|
Sue 371: cats: 6, perfumes: 0, vizslas: 2
|
||||||
|
Sue 372: akitas: 7, cars: 5, perfumes: 3
|
||||||
|
Sue 373: cars: 0, perfumes: 4, pomeranians: 10
|
||||||
|
Sue 374: akitas: 5, perfumes: 5, vizslas: 2
|
||||||
|
Sue 375: goldfish: 7, trees: 10, pomeranians: 7
|
||||||
|
Sue 376: cars: 8, trees: 1, pomeranians: 8
|
||||||
|
Sue 377: cars: 0, akitas: 9, vizslas: 1
|
||||||
|
Sue 378: akitas: 5, perfumes: 3, vizslas: 7
|
||||||
|
Sue 379: trees: 2, goldfish: 8, pomeranians: 8
|
||||||
|
Sue 380: akitas: 5, cars: 9, perfumes: 9
|
||||||
|
Sue 381: cars: 2, perfumes: 6, trees: 3
|
||||||
|
Sue 382: perfumes: 6, vizslas: 2, goldfish: 9
|
||||||
|
Sue 383: akitas: 8, vizslas: 7, cats: 1
|
||||||
|
Sue 384: akitas: 9, trees: 10, vizslas: 7
|
||||||
|
Sue 385: cars: 0, perfumes: 7, vizslas: 2
|
||||||
|
Sue 386: vizslas: 10, akitas: 4, perfumes: 9
|
||||||
|
Sue 387: perfumes: 6, pomeranians: 5, samoyeds: 8
|
||||||
|
Sue 388: vizslas: 10, trees: 9, goldfish: 9
|
||||||
|
Sue 389: goldfish: 8, akitas: 4, perfumes: 10
|
||||||
|
Sue 390: goldfish: 6, trees: 8, akitas: 1
|
||||||
|
Sue 391: vizslas: 4, akitas: 10, goldfish: 7
|
||||||
|
Sue 392: akitas: 1, vizslas: 6, samoyeds: 5
|
||||||
|
Sue 393: trees: 6, cars: 3, akitas: 5
|
||||||
|
Sue 394: goldfish: 9, trees: 3, cars: 5
|
||||||
|
Sue 395: akitas: 6, samoyeds: 4, goldfish: 4
|
||||||
|
Sue 396: akitas: 2, trees: 1, cats: 5
|
||||||
|
Sue 397: cars: 0, children: 9, trees: 10
|
||||||
|
Sue 398: pomeranians: 3, samoyeds: 9, goldfish: 10
|
||||||
|
Sue 399: cars: 7, akitas: 4, goldfish: 8
|
||||||
|
Sue 400: cars: 4, akitas: 5, vizslas: 4
|
||||||
|
Sue 401: pomeranians: 5, akitas: 8, vizslas: 5
|
||||||
|
Sue 402: cats: 7, cars: 6, goldfish: 6
|
||||||
|
Sue 403: samoyeds: 8, perfumes: 4, cars: 5
|
||||||
|
Sue 404: akitas: 10, goldfish: 4, trees: 2
|
||||||
|
Sue 405: trees: 8, perfumes: 1, cars: 2
|
||||||
|
Sue 406: trees: 0, perfumes: 9, pomeranians: 10
|
||||||
|
Sue 407: perfumes: 4, trees: 7, goldfish: 3
|
||||||
|
Sue 408: akitas: 1, perfumes: 3, cars: 5
|
||||||
|
Sue 409: trees: 6, samoyeds: 3, cars: 9
|
||||||
|
Sue 410: vizslas: 3, goldfish: 5, akitas: 7
|
||||||
|
Sue 411: goldfish: 10, trees: 1, vizslas: 9
|
||||||
|
Sue 412: cars: 0, akitas: 6, trees: 6
|
||||||
|
Sue 413: goldfish: 7, trees: 0, cars: 3
|
||||||
|
Sue 414: pomeranians: 10, samoyeds: 3, cars: 10
|
||||||
|
Sue 415: perfumes: 6, trees: 9, cars: 4
|
||||||
|
Sue 416: trees: 2, cars: 4, goldfish: 8
|
||||||
|
Sue 417: goldfish: 2, cars: 9, cats: 5
|
||||||
|
Sue 418: vizslas: 1, cars: 9, akitas: 0
|
||||||
|
Sue 419: perfumes: 6, cats: 3, children: 9
|
||||||
|
Sue 420: cats: 5, goldfish: 7, akitas: 9
|
||||||
|
Sue 421: trees: 1, samoyeds: 6, pomeranians: 1
|
||||||
|
Sue 422: trees: 10, goldfish: 6, children: 7
|
||||||
|
Sue 423: cars: 8, goldfish: 7, vizslas: 3
|
||||||
|
Sue 424: samoyeds: 9, akitas: 7, trees: 5
|
||||||
|
Sue 425: akitas: 5, children: 4, perfumes: 9
|
||||||
|
Sue 426: goldfish: 1, children: 9, cats: 2
|
||||||
|
Sue 427: vizslas: 9, akitas: 7, goldfish: 9
|
||||||
|
Sue 428: pomeranians: 7, akitas: 5, vizslas: 1
|
||||||
|
Sue 429: vizslas: 7, goldfish: 7, cars: 9
|
||||||
|
Sue 430: trees: 7, perfumes: 0, pomeranians: 5
|
||||||
|
Sue 431: children: 9, perfumes: 5, vizslas: 7
|
||||||
|
Sue 432: trees: 6, samoyeds: 7, cats: 1
|
||||||
|
Sue 433: goldfish: 5, trees: 5, children: 6
|
||||||
|
Sue 434: goldfish: 9, akitas: 7, cars: 3
|
||||||
|
Sue 435: samoyeds: 10, perfumes: 2, cars: 0
|
||||||
|
Sue 436: akitas: 5, pomeranians: 4, perfumes: 7
|
||||||
|
Sue 437: vizslas: 5, cats: 6, perfumes: 5
|
||||||
|
Sue 438: trees: 2, goldfish: 6, vizslas: 7
|
||||||
|
Sue 439: samoyeds: 8, pomeranians: 10, goldfish: 1
|
||||||
|
Sue 440: akitas: 6, children: 9, perfumes: 4
|
||||||
|
Sue 441: cars: 2, goldfish: 9, children: 0
|
||||||
|
Sue 442: goldfish: 7, cars: 2, vizslas: 8
|
||||||
|
Sue 443: goldfish: 6, samoyeds: 3, perfumes: 2
|
||||||
|
Sue 444: trees: 2, goldfish: 7, cars: 8
|
||||||
|
Sue 445: trees: 2, pomeranians: 0, children: 0
|
||||||
|
Sue 446: perfumes: 4, akitas: 4, goldfish: 6
|
||||||
|
Sue 447: vizslas: 7, akitas: 9, cars: 3
|
||||||
|
Sue 448: goldfish: 6, trees: 9, cars: 0
|
||||||
|
Sue 449: samoyeds: 7, perfumes: 4, vizslas: 10
|
||||||
|
Sue 450: akitas: 7, cars: 10, goldfish: 7
|
||||||
|
Sue 451: goldfish: 4, children: 7, pomeranians: 4
|
||||||
|
Sue 452: cats: 4, vizslas: 6, trees: 7
|
||||||
|
Sue 453: cars: 1, trees: 10, goldfish: 9
|
||||||
|
Sue 454: trees: 2, goldfish: 3, vizslas: 10
|
||||||
|
Sue 455: pomeranians: 9, vizslas: 3, akitas: 2
|
||||||
|
Sue 456: vizslas: 10, akitas: 2, goldfish: 1
|
||||||
|
Sue 457: trees: 5, cats: 5, children: 8
|
||||||
|
Sue 458: cars: 6, goldfish: 3, akitas: 9
|
||||||
|
Sue 459: goldfish: 7, akitas: 2, cats: 7
|
||||||
|
Sue 460: akitas: 1, cars: 5, children: 8
|
||||||
|
Sue 461: cars: 8, perfumes: 0, goldfish: 6
|
||||||
|
Sue 462: pomeranians: 6, cats: 2, perfumes: 6
|
||||||
|
Sue 463: vizslas: 7, perfumes: 3, goldfish: 3
|
||||||
|
Sue 464: akitas: 10, goldfish: 10, trees: 1
|
||||||
|
Sue 465: vizslas: 0, akitas: 2, trees: 2
|
||||||
|
Sue 466: perfumes: 6, akitas: 8, cars: 2
|
||||||
|
Sue 467: goldfish: 1, cars: 10, perfumes: 3
|
||||||
|
Sue 468: goldfish: 4, trees: 2, cars: 9
|
||||||
|
Sue 469: perfumes: 6, pomeranians: 0, vizslas: 10
|
||||||
|
Sue 470: samoyeds: 8, children: 0, akitas: 7
|
||||||
|
Sue 471: children: 3, goldfish: 9, cats: 9
|
||||||
|
Sue 472: samoyeds: 0, goldfish: 0, trees: 0
|
||||||
|
Sue 473: trees: 3, goldfish: 4, vizslas: 1
|
||||||
|
Sue 474: perfumes: 10, cars: 3, trees: 7
|
||||||
|
Sue 475: akitas: 5, vizslas: 4, goldfish: 5
|
||||||
|
Sue 476: children: 2, akitas: 7, vizslas: 3
|
||||||
|
Sue 477: vizslas: 6, pomeranians: 9, trees: 6
|
||||||
|
Sue 478: vizslas: 7, pomeranians: 6, akitas: 7
|
||||||
|
Sue 479: trees: 2, perfumes: 2, children: 2
|
||||||
|
Sue 480: cars: 8, cats: 5, vizslas: 0
|
||||||
|
Sue 481: trees: 5, goldfish: 0, akitas: 3
|
||||||
|
Sue 482: cars: 8, perfumes: 6, goldfish: 10
|
||||||
|
Sue 483: goldfish: 0, cars: 3, perfumes: 10
|
||||||
|
Sue 484: pomeranians: 1, samoyeds: 1, perfumes: 3
|
||||||
|
Sue 485: trees: 0, akitas: 2, vizslas: 4
|
||||||
|
Sue 486: cars: 3, vizslas: 8, goldfish: 1
|
||||||
|
Sue 487: pomeranians: 9, vizslas: 2, children: 10
|
||||||
|
Sue 488: akitas: 6, vizslas: 10, perfumes: 9
|
||||||
|
Sue 489: goldfish: 6, vizslas: 4, cars: 2
|
||||||
|
Sue 490: vizslas: 10, cats: 8, samoyeds: 1
|
||||||
|
Sue 491: cats: 9, cars: 1, perfumes: 10
|
||||||
|
Sue 492: goldfish: 6, cars: 9, pomeranians: 9
|
||||||
|
Sue 493: children: 10, goldfish: 10, vizslas: 0
|
||||||
|
Sue 494: pomeranians: 5, cars: 0, vizslas: 0
|
||||||
|
Sue 495: vizslas: 7, perfumes: 6, samoyeds: 3
|
||||||
|
Sue 496: trees: 1, cats: 4, cars: 10
|
||||||
|
Sue 497: cats: 1, perfumes: 0, cars: 7
|
||||||
|
Sue 498: perfumes: 7, vizslas: 6, cats: 9
|
||||||
|
Sue 499: vizslas: 8, perfumes: 1, akitas: 3
|
||||||
|
Sue 500: perfumes: 4, cars: 9, trees: 4
|
39
2015/16/part1.py
Normal file
39
2015/16/part1.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
sues_raw = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
with open("components") as f:
|
||||||
|
components_raw = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
COMPONENTS = dict()
|
||||||
|
for component in components_raw:
|
||||||
|
key, amount = component.split(":")
|
||||||
|
amount = int(amount)
|
||||||
|
COMPONENTS[key] = amount
|
||||||
|
|
||||||
|
|
||||||
|
print(COMPONENTS)
|
||||||
|
SUES = dict()
|
||||||
|
|
||||||
|
for sue in sues_raw:
|
||||||
|
name, component_list = sue.split(":", 1)
|
||||||
|
component_list = [x.strip() for x in component_list.split(",")]
|
||||||
|
components = dict()
|
||||||
|
for component in component_list:
|
||||||
|
key, amount = component.split(":")
|
||||||
|
amount = int(amount)
|
||||||
|
components[key] = amount
|
||||||
|
SUES[name] = components
|
||||||
|
|
||||||
|
|
||||||
|
def is_match(components):
|
||||||
|
for key, val in components.items():
|
||||||
|
if COMPONENTS[key] != val:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
print(SUES)
|
||||||
|
for name, components in SUES.items():
|
||||||
|
if is_match(components):
|
||||||
|
print("Found:", name)
|
47
2015/16/part2.py
Normal file
47
2015/16/part2.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
sues_raw = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
with open("components") as f:
|
||||||
|
components_raw = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
COMPONENTS = dict()
|
||||||
|
for component in components_raw:
|
||||||
|
key, amount = component.split(":")
|
||||||
|
amount = int(amount)
|
||||||
|
COMPONENTS[key] = amount
|
||||||
|
|
||||||
|
|
||||||
|
print(COMPONENTS)
|
||||||
|
SUES = dict()
|
||||||
|
|
||||||
|
for sue in sues_raw:
|
||||||
|
name, component_list = sue.split(":", 1)
|
||||||
|
component_list = [x.strip() for x in component_list.split(",")]
|
||||||
|
components = dict()
|
||||||
|
for component in component_list:
|
||||||
|
key, amount = component.split(":")
|
||||||
|
amount = int(amount)
|
||||||
|
components[key] = amount
|
||||||
|
SUES[name] = components
|
||||||
|
|
||||||
|
|
||||||
|
def is_match(components):
|
||||||
|
for key, remembered_val in components.items():
|
||||||
|
measured_val = COMPONENTS[key]
|
||||||
|
if key in ["cats", "trees"]:
|
||||||
|
if not remembered_val > measured_val:
|
||||||
|
return False
|
||||||
|
elif key in ["pomeranians", "goldfish"]:
|
||||||
|
if not remembered_val < measured_val:
|
||||||
|
return False
|
||||||
|
elif remembered_val != measured_val:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
for name, components in SUES.items():
|
||||||
|
if is_match(components):
|
||||||
|
print("Found:", name)
|
||||||
|
|
||||||
|
print("Finish")
|
20
2015/17/input
Normal file
20
2015/17/input
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
11
|
||||||
|
30
|
||||||
|
47
|
||||||
|
31
|
||||||
|
32
|
||||||
|
36
|
||||||
|
3
|
||||||
|
1
|
||||||
|
5
|
||||||
|
3
|
||||||
|
32
|
||||||
|
36
|
||||||
|
15
|
||||||
|
11
|
||||||
|
46
|
||||||
|
26
|
||||||
|
28
|
||||||
|
1
|
||||||
|
19
|
||||||
|
3
|
25
2015/17/part1.py
Normal file
25
2015/17/part1.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
jars = [int(n) for n in f.readlines()]
|
||||||
|
|
||||||
|
jars.sort(reverse=True)
|
||||||
|
|
||||||
|
|
||||||
|
def count_remaining_combinations(remaining_eggnog, remaining_jars):
|
||||||
|
if remaining_eggnog == 0:
|
||||||
|
return 1
|
||||||
|
if remaining_eggnog < 0:
|
||||||
|
return 0
|
||||||
|
if len(remaining_jars) == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
for idx, jar in enumerate(remaining_jars):
|
||||||
|
count += count_remaining_combinations(
|
||||||
|
remaining_eggnog - jar, remaining_jars[idx + 1 :]
|
||||||
|
)
|
||||||
|
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
print(count_remaining_combinations(150, jars))
|
39
2015/17/part2.py
Normal file
39
2015/17/part2.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
with open("input") as f:
|
||||||
|
jars = [int(n) for n in f.readlines()]
|
||||||
|
|
||||||
|
jars.sort(reverse=True)
|
||||||
|
|
||||||
|
combinations = []
|
||||||
|
|
||||||
|
|
||||||
|
def count_remaining_combinations(remaining_eggnog, remaining_jars, used_jars):
|
||||||
|
if remaining_eggnog == 0:
|
||||||
|
combinations.append(used_jars)
|
||||||
|
return 1
|
||||||
|
if remaining_eggnog < 0:
|
||||||
|
return 0
|
||||||
|
if len(remaining_jars) == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
for idx, jar in enumerate(remaining_jars):
|
||||||
|
count += count_remaining_combinations(
|
||||||
|
remaining_eggnog - jar, remaining_jars[idx + 1 :], used_jars + [jar]
|
||||||
|
)
|
||||||
|
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
count_remaining_combinations(150, jars, [])
|
||||||
|
|
||||||
|
minimum_number_of_jars = min([len(x) for x in combinations])
|
||||||
|
|
||||||
|
print("Minimum number of jars:", minimum_number_of_jars)
|
||||||
|
|
||||||
|
minimal_comninations = [x for x in combinations if len(x) == minimum_number_of_jars]
|
||||||
|
|
||||||
|
print(minimal_comninations)
|
||||||
|
|
||||||
|
print("Count:")
|
||||||
|
print(len(minimal_comninations))
|
6
2015/18/example
Normal file
6
2015/18/example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.#.#.#
|
||||||
|
...##.
|
||||||
|
#....#
|
||||||
|
..#...
|
||||||
|
#.#..#
|
||||||
|
####..
|
100
2015/18/input
Normal file
100
2015/18/input
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#...##......#......##.##..#...##......##.#.#.###.#.#..#..#......####..#......###.#.#....#..##..###..
|
||||||
|
####..#.#...#....#.#####.##.##.#..#.......#....#.##...###.###..#.#.#........#..#.#.##...##..#.####.#
|
||||||
|
...#..##...#.#.###.#.###..#.##.####.###...#...........#.###..##.#.##.#.###...#.#..###....#.###.#..#.
|
||||||
|
.#...##...####.#..#.....#..#...#.#.##...#...##..#.#.###....#..###.....##..#.###..###.....##..###...#
|
||||||
|
..##.#####....##..#.#..##.##..######...#..###.######.....#..##...#.#..##..##..#..#..#..##.#.#.#.#...
|
||||||
|
.###.###.###...##...##..###..##.###.#.....##..##.#.#########...##..##.#..##.#..##..####..#.#.#.#####
|
||||||
|
#.#####..###.###.##.##.#...#.#.#.#..#.###...#..##.###.#...####.#..#.#.....###..#..####..#.#.#...##..
|
||||||
|
....#...##.....#....####.##.#.###..#.#.##..#.#...##.###.###..#.##..#.#.##..##..#.##.###..#.#.###.###
|
||||||
|
##.##...#.##...#.#..#.#..#...###...###.#..#..#.#####..###.#......#.....###.#####.#.#..#.#.#.##..#.#.
|
||||||
|
#.#..#.....#.....##.#..##...###..##...##...###.#.###.#..#.#.###...##..##..#.###...#.#######.#...#.#.
|
||||||
|
#.#.....####.#..#.##...#.##....#####.###.#.....#####....###..#........##..####...#...#.###....#..###
|
||||||
|
##.#.##..#.#.##.#.....##.#.....###.####.#..######.....####.#.#..##.#.##...#..#.#.....#.####.#.......
|
||||||
|
#..#..#.#..#.######.##..##.####.....##.#.##.#.######..#.#....#.#...#.#..#..#.#.###.#..#.#.#..#...###
|
||||||
|
####..####.#.#.###.....#.#.#.##..#.##.##.##.#..##..##.#.##.....#.#..#.####.....###.#..#.####.#.#..##
|
||||||
|
###.##..##.#.##..#..##...#.#####.##.#....##.####.#.##....#..###.#.#.##...#.....#.#.#.#.#..##.#.#..#.
|
||||||
|
......#..####...##.##...#.##.##...##..#..##.###..#...#..##...#.#....###.####...#.##.###.#.##.####.##
|
||||||
|
..#...#####.#.#..#.##....#..#...#..####.....###...##.###....#..#.###...#........#.#.##..#..#.#.....#
|
||||||
|
#######.#.#.###.###..######.##..#####.##.###.###....####.#..##.##...###.#..############.#.##....##.#
|
||||||
|
#.#...##.###.#.###..#.#.#.#.#.#..##..####.#..##.....#.##..#.##...##.#..##..#.#.#....##....##.#..#.#.
|
||||||
|
..#.#.####.....###..#######.#.#.#.#...##.#####.....##...##...##.###..######.###..#...####.#..###.###
|
||||||
|
.#.##....#.#.##..##.#.##.##..######...#.....#..#.#.#.#.....#.#..##.#.#.......#######....#.......#...
|
||||||
|
..###.##.##..##....#.###...#.....##..##......###...##..###.##...##.###.#.#.#.###.###.#.#...###..#...
|
||||||
|
.##.#.#...#...##.#.#...#..#..#.#...##.#.##...##..#....#.#..##.#..#.#..#.#.....#..#.#...#######.#.##.
|
||||||
|
...####....#.###.#..###..##...##..#.#.#.###...#..##.##.##..##.#...#..#.##.....#.#........#..#.#.####
|
||||||
|
.....##..###...#....#.#.#.#...###.###...#.#...#.#.####....#..####...###..#..######..##.##..###.#####
|
||||||
|
#####.##..#....###.###....##.....#.#..#....#.#####.##.#.####.#.##...#..###...###..##...#.###.#####..
|
||||||
|
###.##..........########.######....####.###.#..##...#.##.####.#.....##..#####..###...#####.....#.#.#
|
||||||
|
##..#####.##.#.#####.#.##.##..#.##....########.#####.#...#.###.##...#.###.#.#..#....##.#..#...#.#.#.
|
||||||
|
.##.#....#..#...#..#####..#..##.#......#..#....########...#..#...#.....####.#...##...#.###.#.#..##.#
|
||||||
|
.##.##.#.##.#.##...#.#.#..##.##.###.#..##..#...###.##.###.#####.#.###..#..###.#...#.###.#...#..#.#.#
|
||||||
|
.#..#..#.#..#..###..#....###.####.##.#.###.#.##.###.#.##.###.###...###...###.#...####...#.##.##.#.#.
|
||||||
|
###..##...###...#..##.#..#.#...##....###.##.##..#####....###..#..#....#..###.###.#...#.##...#.#.#..#
|
||||||
|
#....#.......##.....#.##...#..#.###.#.##..##..#.##..#.###..##.##...#####.#..#####..#####..#####....#
|
||||||
|
.####.####....###..###.#.##.####.##.#...####.#.###.#.....#...####..#####.###..#.#.###.##.##...##..#.
|
||||||
|
####..##...##.########...##..###..#..###.##.#.#.#........#.#####.#...#.###.####.#..####..#.#.#....##
|
||||||
|
###.#..#...###.#..#..#.###...##..###.##.#.#...#..#...####..##....#.#..#..##.#.#...#####.###.#..#.#.#
|
||||||
|
...##....#.###.#.#..##...##.###.#..#..#......#...#.#..####.#.##..######.####.#...#..#..#..##.#.#.##.
|
||||||
|
##.####.#...#..#.#.##..##.#.#.###..##...####......#..######.#......#.##.#....##...###.#.#..#......##
|
||||||
|
#.....#...#######.##.#..#.#...###.#..#.####....#.#.##.#.##...###..#...#.###.##..#.###..#.##...#####.
|
||||||
|
#####.##...#..#.#.#.......#.##..#####..#####...###..##.#.#..###.#.#####.####..#.#..##...#.##...#.###
|
||||||
|
.##.#..#######.###.#.####.....##...#.##.#.#..#...##....####......######.#..######.....##########.##.
|
||||||
|
##...#.#..#.##.###.#.#.#.##.###.##..##.##.##...#.#..###.#######..#.....#####..#....######.#..##..###
|
||||||
|
.#.#.###.....#..##..#.#..##..#.###...###.#..##...#...#.#####.#.#####..###.#..#...##..#.#..#..####...
|
||||||
|
.#......##..#.....####.###....##.###.....###.##........#.###.##..#..#.#######.#.######..##..###.....
|
||||||
|
..##.#.#..#.##...#.###.###...######..#..#.#..#....###.#.#....#..........#...##.##.##.#..##..#.#####.
|
||||||
|
###.###.#..#.##..##.#..#..##.....##.....#..#######.#..#.#.#.####.###..###.#.#..#.##.##.####.###.####
|
||||||
|
#.#.#..#....########.#..#..#...##..#.##..#.#..##..####...##.....#.##.#.#...########..#.###.#..#.#.##
|
||||||
|
.##.....#...#.#...##.##....###...##..#.####...#..#.#..#..#.##..#.###.##.####.##..####.....##.#.....#
|
||||||
|
....####.#.##.#.##.#..##.#.######.##.####..#...####.#..###.#.#..#..##.#.#.....##.#####.#.####...#.#.
|
||||||
|
#..#####.#####.....##....######..##....#..#.#.###.#####.....##.##.####.#...##...#.##.#.#####.##.#...
|
||||||
|
##.####..###.#....#...#.#.#.#.###.#####.#.####..####...####......##..#..#..#.#.##...########....#...
|
||||||
|
.###.#.#.#.#..####.##.#..######..#.#.###.....#.#......#.#.#.#..####.##...##.#####.#.##..##..#..#.#..
|
||||||
|
.....###...#...#.####.###.#.#.#.#.....#....#.####.###.##.##.##.#######......#.####......#....##.....
|
||||||
|
##..#..#.#.##..#...#..##.##.##..###.#....##.##....####.#.##.###....#.##.#.#.##...##.###...#..#..####
|
||||||
|
...#.#..##..##.#...##.##...#.#......#.#.##..###....####.##...#.#.###.#..#..#.####..##..##..#####.###
|
||||||
|
.##.##..##########.##...#.##.####.#.#######.##.#.##.##..#...##....########.###..##.##.##.#..##.#.#.#
|
||||||
|
#####.#....#.##..#.....#......##.##..#.##.###..##.......###..##.#.###.##.###....####.#..#.###..#.#.#
|
||||||
|
.#...#..#.##....##....#...####....#...#..#...####...########.###.#..##.#.#.##..###..#.#.###.....##.#
|
||||||
|
##..##.....###......#..###.##.####.##.####.#.#....#..#...#..#.#..#.###.#...#...#..##.##...#..#######
|
||||||
|
.....##..###..##...#####.#.#.....###.#.#..####...#.#.#..#..####..##.#..###.####.#....##..###....#..#
|
||||||
|
#.#.##.#....#.#####.#....##...#...##...##....#.#.......#....#..#...###.###.#.####..####....#.##.#.#.
|
||||||
|
..##...##..###.#.#.##.#..#....#.#.....##.###.#.###.###.....#...#.#..#######.#####..#.###...##......#
|
||||||
|
#......###..#....#.#..#.###.##.#...##..###.####.#.#....#.##..#.###..##.#..#####..##.###.....#..###..
|
||||||
|
##.#.##..##.###.#..##.....#.##.....###....##.####.######.#...#..###....#.#...#.##.....###....#..#.#.
|
||||||
|
.##.#.#.#.##..#.#.#..##..#.###.####....#..###.######..####.#.....###.##..#...###.#..######.##.#.##..
|
||||||
|
...##.####.#..##.#####.##.#...##..#..#...#.#.#.#####...#....#..###...#..#....#.#.##.#.######.#..####
|
||||||
|
..#.#.#.#...#.######.#.....#..#.#..###....#.#.########...#....#.#.##..#...##...#.#..#.#.###....##...
|
||||||
|
#####..#..##..#..##..#..#.#.##.#....#####.####.##.#.###..##..##....#.....#.#####.#...#.#####.##.#.#.
|
||||||
|
#.#..#####...####.###.###.....####.###.....##...##...#..#..#######.#.##....##..####.....##...#..#..#
|
||||||
|
#.#.###.#.#..##..#....#.#...#.#.##.##..#.##.....##...#.#..##.......##.#.###..#####.#.##....#.##.....
|
||||||
|
...#.......#....#.#.####.#.###.###..#....#..##.#..####........#.##..#...#.#...###.#..#.#.#...#...#..
|
||||||
|
...##.#####.##.#.###.##.##.#.##..##.#.#.#.#.#.##.#..##...##.#.#..#..##.##.#####.#.###...#####..#..#.
|
||||||
|
#######.#..#..#....##.#.#..####.#..#..###...#..#.......###.#.#.####....#.###...#.#.###.#.#.#.#..###.
|
||||||
|
..##.##.#.##.###....###.##.#.###.#...#....#.####..###..###.#.#..#...##.#.#.#..##.###..###.#.##...###
|
||||||
|
######..######..##..##.#.#.##.##.#..##..#.#.#.##..#.#...#...#.#.#..######.#..#.#.######..#......##.#
|
||||||
|
#.#####.....#.......#########..###.##...#...##.#.#..#...#####...#...#..#.###.#..#.#...###.#.#.#...#.
|
||||||
|
#....##....###...##.##.#...##.........##.#.#..#.#.##.#.######.#####..#..###.###.#...#.#.##.######...
|
||||||
|
#.#...###.#.###.##.#.######.#######.###.##..#.#.#...######.##.####.##..#.#.#.#......##..##.........#
|
||||||
|
..###..##....#.....##...#.#.###.#.#.....##.#...###.####.#...#...##..##.#.#.####..###...######....#.#
|
||||||
|
..###.#.##.####.#..#.##....##..#####....#..##.##.#..#######...#.####...##.#.#.##.........#....#....#
|
||||||
|
.##.#...#.####..#.#...#.##..######.##..##.#.###.##..###.###....##..#.##.##..##.#...###.##.##.###....
|
||||||
|
#...###.###.#..#....#.......#..#.....###..#.###.##.##....#.####.#.####.##..##..#..#.....#....##.#.#.
|
||||||
|
.##.#..#..#.##.......#.####.#######.....#.##.##.#.....#.#..#....######.#..###.##.##.....#.####..##.#
|
||||||
|
###..#.###.#..####.....##....#..####....#.##.##..#...######.#########...#.#....##...###.#..#.##...#.
|
||||||
|
#..###..##..#.#.##.###.#.#.##...###.#...##.##..#.###....###..#.#...#.###..######.#..#.###..#..#..#.#
|
||||||
|
.#........##.#.###..###.#.#.##.....##.##.#.#...##..#.##....###..#.#.#.#.##....#.##..#.#...###...#...
|
||||||
|
####.####..#....#.#.#..#..##.......##.####...###.##..#.#.##.#..##..######.......##.#.##..#...#.....#
|
||||||
|
..#..#..###..##.##..######.#..###..###.#.##..##.#..#####.#.#.#.##..#.##..##.##......####.#..........
|
||||||
|
...##.##..###.#...###....#.#.#.#.....#.##.....##...#...#......####...##.##....##.#..#.####.#..###.#.
|
||||||
|
..#.....####.#.###.#####..#..###..#..#.#...#####...###.###....#.###..#...#..#..#.#..#.##..##.#.#....
|
||||||
|
..##.#####...###.###.........#....##.####.##..#.#..#.#...#...##.##.##..#.#.##.########......#####...
|
||||||
|
...###.#.#..#...#.###.###.......##.###.#..#.##########...#..#.#.#.##.#.###...######..#.#...###.##...
|
||||||
|
.#.#.#######.#..##.##..##...#...####...#..#####.#..##...###.#.#...#.##...#......#..##.####..#.....##
|
||||||
|
.##.##.#.#......#######..###.....##.#.##..###......#....####...#.###.#.##.#........#..#....##.....##
|
||||||
|
#...#.###.#.##...##.####....#...#.###..#.#.....#.#....#.#.#.##...#.#..#####.#.#..#..#..#....#...####
|
||||||
|
.....##...###......#####..##.##.##...##.#.#####..##...#.#.#.#.###...###.##.####..#.#..#.#..#.####.##
|
||||||
|
#..#..##.#.##.#.##.#.#.#..###....###.##.#.##.#...#.#..#...#....###.#..#.#.######.#...####..#..##.#.#
|
||||||
|
#..#.#..#...###.#..##.#...#...##.#......#...#..#..####..##.....#.###...#.#..#.#....#.#####.##.###...
|
||||||
|
###....#.#..#.#..###..#.##......#...#..#..##.#..###..##..#..#.####..#...########..##.#.##.#.#.#...#.
|
||||||
|
.#.#.##.##.###..#...#.#....#..#.##..#.#.#.#.##.##.#####...#........####..###..####.#####..#.##.#.##.
|
80
2015/18/part1.py
Normal file
80
2015/18/part1.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
from time import sleep
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
lights = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
STEPS = 100
|
||||||
|
# STEPS = 4
|
||||||
|
|
||||||
|
X_MAX = len(lights)
|
||||||
|
Y_MAX = len(lights[0])
|
||||||
|
|
||||||
|
|
||||||
|
def print_lights():
|
||||||
|
for row in lights:
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
|
||||||
|
def neighbors_that_are_on(center_x, center_y):
|
||||||
|
count = 0
|
||||||
|
for d_x in range(-1, 2):
|
||||||
|
for d_y in range(-1, 2):
|
||||||
|
x = center_x + d_x
|
||||||
|
y = center_y + d_y
|
||||||
|
if d_x == 0 and d_y == 0:
|
||||||
|
continue
|
||||||
|
if x < 0 or x >= X_MAX:
|
||||||
|
continue
|
||||||
|
if y < 0 or y >= Y_MAX:
|
||||||
|
continue
|
||||||
|
neighbor = lights[x][y]
|
||||||
|
if neighbor == "#":
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
def get_next_state(prev_state, neighbors_count):
|
||||||
|
if prev_state == "#":
|
||||||
|
if neighbors_count in [2, 3]:
|
||||||
|
return "#"
|
||||||
|
else:
|
||||||
|
return "."
|
||||||
|
else: # light == '.'
|
||||||
|
if neighbors_count == 3:
|
||||||
|
return "#"
|
||||||
|
else:
|
||||||
|
return "."
|
||||||
|
|
||||||
|
|
||||||
|
print("Initial state")
|
||||||
|
print_lights()
|
||||||
|
print()
|
||||||
|
|
||||||
|
for step in range(STEPS):
|
||||||
|
new_lights = []
|
||||||
|
|
||||||
|
for x in range(X_MAX):
|
||||||
|
line = ""
|
||||||
|
for y in range(Y_MAX):
|
||||||
|
light = lights[x][y]
|
||||||
|
neighbors_count = neighbors_that_are_on(x, y)
|
||||||
|
next_state = get_next_state(light, neighbors_count)
|
||||||
|
line += next_state
|
||||||
|
new_lights.append(line)
|
||||||
|
|
||||||
|
lights = new_lights
|
||||||
|
print("Step", step + 1)
|
||||||
|
print_lights()
|
||||||
|
print()
|
||||||
|
sleep(0.03)
|
||||||
|
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for line in lights:
|
||||||
|
for light in line:
|
||||||
|
if light == "#":
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
print(count)
|
||||||
|
|
||||||
|
# 353: too low
|
87
2015/18/part2.py
Normal file
87
2015/18/part2.py
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
from time import sleep
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
lights = [n.strip() for n in f.readlines()]
|
||||||
|
|
||||||
|
STEPS = 100
|
||||||
|
# STEPS = 5
|
||||||
|
|
||||||
|
X_MAX = len(lights)
|
||||||
|
Y_MAX = len(lights[0])
|
||||||
|
|
||||||
|
|
||||||
|
def print_lights():
|
||||||
|
for row in lights:
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
|
||||||
|
def neighbors_that_are_on(center_x, center_y):
|
||||||
|
count = 0
|
||||||
|
for d_x in range(-1, 2):
|
||||||
|
for d_y in range(-1, 2):
|
||||||
|
x = center_x + d_x
|
||||||
|
y = center_y + d_y
|
||||||
|
if d_x == 0 and d_y == 0:
|
||||||
|
continue
|
||||||
|
if x < 0 or x >= X_MAX:
|
||||||
|
continue
|
||||||
|
if y < 0 or y >= Y_MAX:
|
||||||
|
continue
|
||||||
|
neighbor = lights[x][y]
|
||||||
|
if neighbor == "#":
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
def get_next_state(prev_state, neighbors_count):
|
||||||
|
if prev_state == "#":
|
||||||
|
if neighbors_count in [2, 3]:
|
||||||
|
return "#"
|
||||||
|
else:
|
||||||
|
return "."
|
||||||
|
else: # light == '.'
|
||||||
|
if neighbors_count == 3:
|
||||||
|
return "#"
|
||||||
|
else:
|
||||||
|
return "."
|
||||||
|
|
||||||
|
|
||||||
|
def turn_corners_on():
|
||||||
|
lights[0] = "#" + lights[0][1:-1] + "#"
|
||||||
|
lights[-1] = "#" + lights[-1][1:-1] + "#"
|
||||||
|
|
||||||
|
|
||||||
|
print("Initial state")
|
||||||
|
turn_corners_on()
|
||||||
|
print_lights()
|
||||||
|
print()
|
||||||
|
|
||||||
|
for step in range(STEPS):
|
||||||
|
new_lights = []
|
||||||
|
|
||||||
|
for x in range(X_MAX):
|
||||||
|
line = ""
|
||||||
|
for y in range(Y_MAX):
|
||||||
|
light = lights[x][y]
|
||||||
|
neighbors_count = neighbors_that_are_on(x, y)
|
||||||
|
next_state = get_next_state(light, neighbors_count)
|
||||||
|
line += next_state
|
||||||
|
new_lights.append(line)
|
||||||
|
|
||||||
|
lights = new_lights
|
||||||
|
turn_corners_on()
|
||||||
|
print("Step", step + 1)
|
||||||
|
print_lights()
|
||||||
|
print()
|
||||||
|
sleep(0.03)
|
||||||
|
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for line in lights:
|
||||||
|
for light in line:
|
||||||
|
if light == "#":
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
print(count)
|
||||||
|
|
||||||
|
# 353: too low
|
7
2015/19/example
Normal file
7
2015/19/example
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
e => H
|
||||||
|
e => O
|
||||||
|
H => HO
|
||||||
|
H => OH
|
||||||
|
O => HH
|
||||||
|
|
||||||
|
HOH
|
45
2015/19/input
Normal file
45
2015/19/input
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
Al => ThF
|
||||||
|
Al => ThRnFAr
|
||||||
|
B => BCa
|
||||||
|
B => TiB
|
||||||
|
B => TiRnFAr
|
||||||
|
Ca => CaCa
|
||||||
|
Ca => PB
|
||||||
|
Ca => PRnFAr
|
||||||
|
Ca => SiRnFYFAr
|
||||||
|
Ca => SiRnMgAr
|
||||||
|
Ca => SiTh
|
||||||
|
F => CaF
|
||||||
|
F => PMg
|
||||||
|
F => SiAl
|
||||||
|
H => CRnAlAr
|
||||||
|
H => CRnFYFYFAr
|
||||||
|
H => CRnFYMgAr
|
||||||
|
H => CRnMgYFAr
|
||||||
|
H => HCa
|
||||||
|
H => NRnFYFAr
|
||||||
|
H => NRnMgAr
|
||||||
|
H => NTh
|
||||||
|
H => OB
|
||||||
|
H => ORnFAr
|
||||||
|
Mg => BF
|
||||||
|
Mg => TiMg
|
||||||
|
N => CRnFAr
|
||||||
|
N => HSi
|
||||||
|
O => CRnFYFAr
|
||||||
|
O => CRnMgAr
|
||||||
|
O => HP
|
||||||
|
O => NRnFAr
|
||||||
|
O => OTi
|
||||||
|
P => CaP
|
||||||
|
P => PTi
|
||||||
|
P => SiRnFAr
|
||||||
|
Si => CaSi
|
||||||
|
Th => ThCa
|
||||||
|
Ti => BP
|
||||||
|
Ti => TiTi
|
||||||
|
e => HF
|
||||||
|
e => NAl
|
||||||
|
e => OMg
|
||||||
|
|
||||||
|
CRnCaCaCaSiRnBPTiMgArSiRnSiRnMgArSiRnCaFArTiTiBSiThFYCaFArCaCaSiThCaPBSiThSiThCaCaPTiRnPBSiThRnFArArCaCaSiThCaSiThSiRnMgArCaPTiBPRnFArSiThCaSiRnFArBCaSiRnCaPRnFArPMgYCaFArCaPTiTiTiBPBSiThCaPTiBPBSiRnFArBPBSiRnCaFArBPRnSiRnFArRnSiRnBFArCaFArCaCaCaSiThSiThCaCaPBPTiTiRnFArCaPTiBSiAlArPBCaCaCaCaCaSiRnMgArCaSiThFArThCaSiThCaSiRnCaFYCaSiRnFYFArFArCaSiRnFYFArCaSiRnBPMgArSiThPRnFArCaSiRnFArTiRnSiRnFYFArCaSiRnBFArCaSiRnTiMgArSiThCaSiThCaFArPRnFArSiRnFArTiTiTiTiBCaCaSiRnCaCaFYFArSiThCaPTiBPTiBCaSiThSiRnMgArCaF
|
35
2015/19/part1.py
Normal file
35
2015/19/part1.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import re
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
|
def parse_atoms(molecule):
|
||||||
|
return re.findall(r"[A-Z][a-z]*", molecule)
|
||||||
|
|
||||||
|
|
||||||
|
decay = defaultdict(list)
|
||||||
|
|
||||||
|
with open("input") as f:
|
||||||
|
line = f.readline()
|
||||||
|
while line != "\n":
|
||||||
|
atom, decays_to = line.strip().split(" => ")
|
||||||
|
decay[atom].append(decays_to)
|
||||||
|
line = f.readline()
|
||||||
|
|
||||||
|
molecule = f.readline()
|
||||||
|
|
||||||
|
print(decay)
|
||||||
|
print()
|
||||||
|
print(molecule)
|
||||||
|
|
||||||
|
atoms = parse_atoms(molecule)
|
||||||
|
|
||||||
|
next_molecules = set()
|
||||||
|
|
||||||
|
for idx, atom in enumerate(atoms):
|
||||||
|
prefix = "".join(atoms[:idx])
|
||||||
|
suffix = "".join(atoms[idx + 1 :])
|
||||||
|
for decay_molecule in decay[atom]:
|
||||||
|
descendant = prefix + decay_molecule + suffix
|
||||||
|
next_molecules.add(descendant)
|
||||||
|
|
||||||
|
print(len(next_molecules))
|
63
2015/19/part2.py
Normal file
63
2015/19/part2.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import re
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
INPUT_FILENAME = "example"
|
||||||
|
|
||||||
|
|
||||||
|
def parse_atoms(molecule):
|
||||||
|
"""Return a list of all Atoms in the molecule string"""
|
||||||
|
return re.findall(r"[A-Z][a-z]*", molecule)
|
||||||
|
|
||||||
|
|
||||||
|
ATOMS = set()
|
||||||
|
REPLACEMENTS = list()
|
||||||
|
|
||||||
|
with open(INPUT_FILENAME) as f:
|
||||||
|
line = f.readline()
|
||||||
|
while line != "\n":
|
||||||
|
atom, decays_to = line.strip().split(" => ")
|
||||||
|
REPLACEMENTS.append([atom, decays_to])
|
||||||
|
ATOMS.update(parse_atoms(decays_to))
|
||||||
|
ATOMS.add(atom)
|
||||||
|
line = f.readline()
|
||||||
|
|
||||||
|
MOLECULE = f.readline().strip()
|
||||||
|
|
||||||
|
ATOMS.update(parse_atoms(MOLECULE))
|
||||||
|
|
||||||
|
|
||||||
|
print("ATOMS", ATOMS)
|
||||||
|
print()
|
||||||
|
print("REPLACEMENTS", REPLACEMENTS)
|
||||||
|
print()
|
||||||
|
print("MOLECULE", MOLECULE)
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def shrink(molecule, from_molecule, to_atom, idx):
|
||||||
|
prefix = molecule[:idx]
|
||||||
|
suffix = molecule[idx + len(from_molecule) :]
|
||||||
|
return prefix + to_atom + suffix
|
||||||
|
|
||||||
|
|
||||||
|
def step(molecule):
|
||||||
|
next_molecules = []
|
||||||
|
for (atom, decays_to) in REPLACEMENTS:
|
||||||
|
possible = [m.start() for m in re.finditer(decays_to, molecule)]
|
||||||
|
if not possible:
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(decays_to, atom)
|
||||||
|
|
||||||
|
if atom == "e" and len(decays_to) != len(molecule):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for idx in possible:
|
||||||
|
next_molecule = shrink(molecule, decays_to, atom, idx)
|
||||||
|
next_molecules.append(next_molecules)
|
||||||
|
print(" ", idx, next_molecule)
|
||||||
|
|
||||||
|
return next_molecules
|
||||||
|
|
||||||
|
|
||||||
|
step(MOLECULE)
|
1
2015/20/input
Normal file
1
2015/20/input
Normal file
@ -0,0 +1 @@
|
|||||||
|
33100000
|
79
2015/20/part1.py
Normal file
79
2015/20/part1.py
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
INPUT = 33100000
|
||||||
|
|
||||||
|
|
||||||
|
def get_divisors(num):
|
||||||
|
divisors = set()
|
||||||
|
divisors.add(1)
|
||||||
|
divisors.add(num)
|
||||||
|
|
||||||
|
upper_limit = num
|
||||||
|
lower_limit = 2
|
||||||
|
|
||||||
|
while lower_limit < upper_limit:
|
||||||
|
quotient, rest = divmod(num, lower_limit)
|
||||||
|
if rest == 0:
|
||||||
|
divisors.add(lower_limit)
|
||||||
|
divisors.add(quotient)
|
||||||
|
lower_limit += 1
|
||||||
|
|
||||||
|
return divisors
|
||||||
|
|
||||||
|
|
||||||
|
def present_count(house_number):
|
||||||
|
divisors = get_divisors(house_number)
|
||||||
|
presents = 0
|
||||||
|
for divisor in divisors:
|
||||||
|
presents += divisor * 10
|
||||||
|
return presents
|
||||||
|
|
||||||
|
|
||||||
|
X = []
|
||||||
|
Y = []
|
||||||
|
|
||||||
|
for x in range(1, 100):
|
||||||
|
if x % 100 == 0:
|
||||||
|
print(x)
|
||||||
|
y = present_count(x)
|
||||||
|
plt.plot(x, y, "bo")
|
||||||
|
plt.annotate(f"{x}", (x, y), xytext=(2, 0), textcoords="offset points")
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
print("Estimation...")
|
||||||
|
prev_house_number = None
|
||||||
|
house_number = 1
|
||||||
|
presents = 10
|
||||||
|
while True:
|
||||||
|
prev_house_number = house_number
|
||||||
|
house_number = house_number * 2
|
||||||
|
presents += house_number * 10
|
||||||
|
print(house_number, presents)
|
||||||
|
|
||||||
|
if presents > INPUT:
|
||||||
|
break
|
||||||
|
|
||||||
|
lower_bound = prev_house_number
|
||||||
|
upper_bound = house_number
|
||||||
|
|
||||||
|
print("Estimation lower bound:", lower_bound)
|
||||||
|
print("Estimation upper bound:", upper_bound)
|
||||||
|
print()
|
||||||
|
|
||||||
|
current = int(lower_bound + (upper_bound - lower_bound) / 2)
|
||||||
|
|
||||||
|
loop_count = 0
|
||||||
|
while True:
|
||||||
|
presents = present_count(current)
|
||||||
|
print("loop", current, lower_bound, upper_bound, presents)
|
||||||
|
if presents < INPUT:
|
||||||
|
lower_bound = current
|
||||||
|
else:
|
||||||
|
upper_bound = current
|
||||||
|
|
||||||
|
current = int(lower_bound + (upper_bound - lower_bound) / 2)
|
||||||
|
|
||||||
|
print("finished")
|
||||||
|
# 2097152 too high
|
||||||
|
# 1540098 too high
|
BIN
2015/20/test.png
Normal file
BIN
2015/20/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
3
2015/21/input
Normal file
3
2015/21/input
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Hit Points: 103
|
||||||
|
Damage: 9
|
||||||
|
Armor: 2
|
20
2020/24/example
Normal file
20
2020/24/example
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
sesenwnenenewseeswwswswwnenewsewsw
|
||||||
|
neeenesenwnwwswnenewnwwsewnenwseswesw
|
||||||
|
seswneswswsenwwnwse
|
||||||
|
nwnwneseeswswnenewneswwnewseswneseene
|
||||||
|
swweswneswnenwsewnwneneseenw
|
||||||
|
eesenwseswswnenwswnwnwsewwnwsene
|
||||||
|
sewnenenenesenwsewnenwwwse
|
||||||
|
wenwwweseeeweswwwnwwe
|
||||||
|
wsweesenenewnwwnwsenewsenwwsesesenwne
|
||||||
|
neeswseenwwswnwswswnw
|
||||||
|
nenwswwsewswnenenewsenwsenwnesesenew
|
||||||
|
enewnwewneswsewnwswenweswnenwsenwsw
|
||||||
|
sweneswneswneneenwnewenewwneswswnese
|
||||||
|
swwesenesewenwneswnwwneseswwne
|
||||||
|
enesenwswwswneneswsenwnewswseenwsese
|
||||||
|
wnwnesenesenenwwnenwsewesewsesesew
|
||||||
|
nenewswnwewswnenesenwnesewesw
|
||||||
|
eneswnwswnwsenenwnwnwwseeswneewsenese
|
||||||
|
neswnwewnwnwseenwseesewsenwsweewe
|
||||||
|
wseweeenwnesenwwwswnew
|
471
2020/24/input
Normal file
471
2020/24/input
Normal file
@ -0,0 +1,471 @@
|
|||||||
|
swswswswneswswwwswnewswswweswnwsww
|
||||||
|
nwwewenenwnenwnwnwnwneswnwswnwnwswswnw
|
||||||
|
seneswwwswwnenwnenwswswswswsewseeww
|
||||||
|
esenesenesesesewseseswnesesweesesesese
|
||||||
|
seseseeseenesewseenwsesewswwsesenwse
|
||||||
|
eswenewnenenewneneneneenenenenwnene
|
||||||
|
nwseeseseeseseseseewseesenwseeesese
|
||||||
|
nwnwswswswweneseswwswwneswswswswswsw
|
||||||
|
senenenwnenewneneneseswneeeenenenew
|
||||||
|
eswnwnesenwnwnenwnwnwnwwnwsenwwswswenw
|
||||||
|
wswneswswseesewswseswswswnenesenenwswswne
|
||||||
|
seswseswneswswswwnwswwswseneswswswswsee
|
||||||
|
neseseswnwesesesesewswsesenesenesesesw
|
||||||
|
wwswwwsweswwwww
|
||||||
|
seswwnwneenwswneenwewneneneseenee
|
||||||
|
eswseenweswewseneeeeseeswnwnwse
|
||||||
|
swsweswswswnweswswneswwswnwswwwswswswsw
|
||||||
|
nwwnwnwnwnwnwnwnwwswwnweneswwenwnw
|
||||||
|
sewswwwwwwwweswwwwneswwnwswnw
|
||||||
|
nwneeneeneneseneseneneneneneneswnenwnene
|
||||||
|
swnenenweeneeeseswweneenenenenene
|
||||||
|
nwnwnwsenwewsesenwenwwwswwnwnesenw
|
||||||
|
swnwswswswswswsewseswnewneseswswswneesw
|
||||||
|
wwweswwswwsewswswwwwnwwesewwne
|
||||||
|
swswsweneswswswenwswnewnwswwneswseswswe
|
||||||
|
nwnesewwnwwnwwwsew
|
||||||
|
enwwwnenwnewwwwswwseeswewe
|
||||||
|
neswseswswsenwseswnwseswse
|
||||||
|
senwseneneneneneeseneswnenenenenwnenwnw
|
||||||
|
swseneswwseenwsenwneneswnewnenewene
|
||||||
|
ewwwwwwwewwwnwswwwwwwwne
|
||||||
|
eswswenwsenwnwsenenw
|
||||||
|
nwneseewseswwsewswnwnwnwwwwnewww
|
||||||
|
nwwwwwwwwewnwwswnew
|
||||||
|
neeeseeesewseeeeeeeewe
|
||||||
|
wweswnenwwnewnwnwwwewsewnwwsew
|
||||||
|
swwswwwswwewwswswnwsweswnwwwww
|
||||||
|
eseswneenwneenweseenweeseeeenw
|
||||||
|
neneswneneneneneneneneneswnenwnwnw
|
||||||
|
nwnwwnwewwswwnwwwnwsewnwwenwnw
|
||||||
|
seswswswnwswwwwswwswneswwseswnw
|
||||||
|
nwseswenwwneneneseswneenwnenenwnenwnenw
|
||||||
|
nwnenenenesewwnenwnwnesenwnwnwnwnenwnwnw
|
||||||
|
wseeeneseeeseseesesenwseseswsesese
|
||||||
|
sweseswnwseseseswseswseseseswswswse
|
||||||
|
ewwwswswsenwewnewwwenwwwnwww
|
||||||
|
nwwsewnwnwnwneswwnwesewnwwnwnwnwnwne
|
||||||
|
nenwnwnwnenenwnenwnwswswnwneenenwnwnwne
|
||||||
|
esenwneswsesesweeeeweseseeseseswnw
|
||||||
|
swswswswwsesweseswswswsw
|
||||||
|
swsweneswwseswswswwswsenewswwswseswnene
|
||||||
|
nenenewnwnenenwenwnesenwneseswnwnwnwne
|
||||||
|
nenenenewneeseneneswneneneswsenenenwne
|
||||||
|
nenenwnenwswwnweesenwsenwnwnwseswnwnwnw
|
||||||
|
seseeenwsenwswsesenwseeseeseeseswese
|
||||||
|
swneeseseneswswnwswnwwwwswswnee
|
||||||
|
seeseseseneseseswsewseenenwwneseswse
|
||||||
|
wswseseenwwswnewenwswswwwnewwsw
|
||||||
|
nenewswnwnenwnwneeneswseeneswnenwnenesene
|
||||||
|
nwswsenweweseeneseesesesesesesesee
|
||||||
|
seneswswwesenenwswseswnwseseseseseswne
|
||||||
|
wwnwwweswnwnwwweneseewnwsesenw
|
||||||
|
swswneneneneenewnesenewweenweswne
|
||||||
|
eseneseneseenenewwswseweenweenenene
|
||||||
|
nwwnwwnwsenwnwnwnwwnwwnww
|
||||||
|
swweswsewewwwwwwwwwwnewne
|
||||||
|
swswnewseseseesenewseesesesesesenwese
|
||||||
|
swswnenwnenwnwnwnwnenenenwnwwnenwseene
|
||||||
|
wnwwwwnwnwwnwwnwnwwwnwnwsenwe
|
||||||
|
nwseswwwnenwwwwesewwwwwwwnenwnw
|
||||||
|
nwswswnwswwswwnenenwnwnwnwnewnenw
|
||||||
|
seswswswnwswswswswswswswswswswswsw
|
||||||
|
neneseeneswnwnenwnwsenwnenenewne
|
||||||
|
wwwwwnenwnwnweswwnwsewwwesese
|
||||||
|
swwswswwwwseswswenwnewswwswweswnw
|
||||||
|
swwswseswswseeswswswewswswnwswswese
|
||||||
|
nwnwewsenenwnesewwwwswnwnenwswsee
|
||||||
|
seseseenwwswseneneseswswnwnewswnwsenwse
|
||||||
|
wwswwnwwwwsewwwenewnwswnwwwe
|
||||||
|
swwwwswwswwswneseswswswwnewswwse
|
||||||
|
nenenwneeswnenesweneneneeneneswsewesw
|
||||||
|
seswswswseswswswswsweenwswswwseswwsw
|
||||||
|
swswswsewneseesenwseseswseswswswnwsesw
|
||||||
|
nwwnewnwnwswnwnwswnwsenwwnwenwnenww
|
||||||
|
wswwnwwwswwwwswe
|
||||||
|
eewneeeeneeswsee
|
||||||
|
wseneseeseewseseseswsewse
|
||||||
|
wwswnwnwwnewnwsewenenwswwewswwne
|
||||||
|
seneesesesesewswswwnwseswswseseswseswsw
|
||||||
|
ewnweeeseneseeseseeneseswwwee
|
||||||
|
wwwwswwsewwwwewwwwwswnwwne
|
||||||
|
swsewswswswseswseseeswsenwseswswswsenw
|
||||||
|
nenenenenesenenenenenenewenewneswsene
|
||||||
|
newnewewwnwnwnwsewwswnwwwwesww
|
||||||
|
neseeeneneeewnee
|
||||||
|
wsenwwnwenwnwwnwnwnwwnwnwwnw
|
||||||
|
nweswenwseseswwseeenwseenwswsesewsw
|
||||||
|
wwwswwwwsewwwwwwwwne
|
||||||
|
nenwnwnwnenwnwnwnenwwnwnwnwnwnwe
|
||||||
|
eeeeeweneeseeeesweeeeew
|
||||||
|
seneseeeeewewnweseeseseseeseese
|
||||||
|
swenenenenwesweewneeeneneeeeeee
|
||||||
|
wnenwseswnwwwsenwnwwnwnwwnwwnwnwnwnw
|
||||||
|
sewwwswnwwnwwwswwnewwewwwsw
|
||||||
|
swwwwswswwswswwwswnew
|
||||||
|
esweeneeswenwnweesweneeeeswee
|
||||||
|
eenweeseneeeeeeeeeseeenenwsw
|
||||||
|
nwneswweeneseswnwswnweeesesesenwe
|
||||||
|
neneneeswnwnwnwnenenwnenene
|
||||||
|
wseewseeseseneswsenwsenewsesweseswswse
|
||||||
|
eseswneneseneenenewswwnwnenenesenenenw
|
||||||
|
seswsesesweseswseswseswwsw
|
||||||
|
nwnenenenenwnenenwsenenwwsenewnenenene
|
||||||
|
eneneneneswnenenenenenenenwneneneswnwnw
|
||||||
|
neneeneneenwnenenesweneneewsweneene
|
||||||
|
swnwnwneswnwnwseenwnwnenwenewnwnwnwwnw
|
||||||
|
swswwnwwswnwwseswewswneseneswewneswe
|
||||||
|
neswswnewwswswwwswwsewww
|
||||||
|
nwneeenwswnwsenwnwnwnwnenwswnwnwsenwnw
|
||||||
|
neeswnwnwwnwseswesweneswnw
|
||||||
|
swnenwenwnwnwnwsesenwswnwnwnwnwnwnwnwnw
|
||||||
|
swseswswnenwwwwseswwwwsw
|
||||||
|
seswneseswseswswswsewesenwsenesewsesw
|
||||||
|
eseeneswseenwewseewneeeene
|
||||||
|
swnenenenenenenewwneneswnenenesenesenw
|
||||||
|
swnenwnenwnwenenenwnenenwnwnene
|
||||||
|
eswneenwwnwwwneewneneneswneseswee
|
||||||
|
neseneseneewneeeweewnwneeseee
|
||||||
|
nesenenenenwnwnenwswnwnenwnenenwnw
|
||||||
|
seswsesesenwseeeeseseeesesewseenw
|
||||||
|
eneswsewneeswnenweswneeswnewwswseene
|
||||||
|
eeseseseswneswseseeeeeeeeewne
|
||||||
|
wwwseswnenwwnwnwenenwnw
|
||||||
|
sesenesweeeeeweeeweeenwwe
|
||||||
|
wsewnwwsewwewwnew
|
||||||
|
esesenwnwwwneswwswsenwnwnwseswneswwew
|
||||||
|
nenwwnwnwnwswwenwwwenwwwnwnwwnw
|
||||||
|
seeeneeneeseeswnenenwsweweewee
|
||||||
|
swswswwswswswswwswswwswneswswsw
|
||||||
|
nweseneweseeswwnwwswswnw
|
||||||
|
wnwsweswseswswswswseswne
|
||||||
|
swnenenwneenenenenenenenenenenenene
|
||||||
|
swswswswswseswswwswswswwnwwenwnwseswesw
|
||||||
|
wswwswswwswswsweswewswwswnwnesw
|
||||||
|
neneeewneneeswnewneneeseseswewnw
|
||||||
|
seseswseeesenwsesweseneseeseeesese
|
||||||
|
nenenenwnesewneswneneseneenewnene
|
||||||
|
neneneneneneswwneneneneneesenenenenene
|
||||||
|
swswswnwswnwswsweeswswseswswswswswswnw
|
||||||
|
sweeseseneeeseeswnewnwnwwewsee
|
||||||
|
neswsenwnewwnwwwwwwswweseenenww
|
||||||
|
nwwwwnwwwsewnwwswnewwwnewww
|
||||||
|
nwswsweswswneswseswswswswwneseswwnesww
|
||||||
|
wsewwnwwwwswnewwwwsewswwwsw
|
||||||
|
nwwwwwsenewneewwseenewwsesw
|
||||||
|
nwnenwwnwwnwwnenenwnenwenesenwenwne
|
||||||
|
nwnenwnwsewnenwsenwnenenwnwnenenenwnene
|
||||||
|
wswswwwenwswenesewwnenwe
|
||||||
|
wseswneeswneseenwnwsenwswewwweswesw
|
||||||
|
swnwseseeeeewseswnwseneseswsenwsesene
|
||||||
|
sweneswnwnwswsweneswnwswneswneswsweswsw
|
||||||
|
eeeswnwswneeneenewswnewneneeee
|
||||||
|
senwwnenwenwnwwsenwnwnwnenw
|
||||||
|
esesenweseeeeseseeesesese
|
||||||
|
seeeeseneseseeeswseeeeseewsene
|
||||||
|
wneswwwwswswwwewwnesesenwwwse
|
||||||
|
wnwnwwwsenwnwswnwnwnenewnwnwwnwwnw
|
||||||
|
senewsesesesesesesesesesesese
|
||||||
|
eenweswneeenee
|
||||||
|
nwnenwwnwnwnwnwwwseenwnwnwwnwnwnwswnw
|
||||||
|
esweneseeneeneeneneneneneswnenewnee
|
||||||
|
nwwwwswwewnwnwww
|
||||||
|
neneeneewneeneneneswnwnesenenenenwnesene
|
||||||
|
wneswsesenewswwwwwwwnwswwwseww
|
||||||
|
wesenesewswsenwswneswswseswneesesese
|
||||||
|
sesesenwswsewnwsenwswseswesenenwseeseew
|
||||||
|
wwnwswwneswwweswwwwwwwswww
|
||||||
|
nenenwnesewwswswewsenwswnewwswew
|
||||||
|
wwwnwwwnenwwwwwnwswnwnw
|
||||||
|
nenwswneneneenenenenwnenwnwnwnenwnw
|
||||||
|
swenwswewswswswewnwwswnewswseswne
|
||||||
|
swsenweeseswenwseseswsenwsesewseswswse
|
||||||
|
eeeweswnwnenenweeswneeeseneeee
|
||||||
|
swwswneseswnwseneswnewswweseswnwww
|
||||||
|
swswswswnenwswswseswseswswswneswwseswsw
|
||||||
|
enwsewsweeseseseneweeseswesenwese
|
||||||
|
nesenweneneneneneswnwnwnenwnenwnenwnene
|
||||||
|
seswseeenwsesenweseseseseseneseeseeswse
|
||||||
|
senenwsewnwnwnenwewnwswwneswnwnwsweenw
|
||||||
|
neeewnenweseseseeswnesweneneewwse
|
||||||
|
eeenwswswseneweseneenweneneneew
|
||||||
|
swswneneswnenenenwnenwnenenenwnwnwwnwe
|
||||||
|
swsweswwswswswwnwwwweswswswwswnw
|
||||||
|
wewwewwwwnwswswwwwswwswsww
|
||||||
|
swwnwwswnweseswnwswseweenewwww
|
||||||
|
neswswswseswswseswswswseswwswswswsesenw
|
||||||
|
eneeneneneewneneneeneneenesew
|
||||||
|
nwnwnwnwnwnwnwsenwenenenwnwnwnwwnwnwswne
|
||||||
|
weneswnwsenewseseswseeseene
|
||||||
|
eseseweneenwnweseeseseneneweswswe
|
||||||
|
swswswswseswswsenwnwseswseeswswsweswnw
|
||||||
|
sweswwsweswswwswswsweswswwnwswnwenw
|
||||||
|
eeeseseeenwsewswesesewsenwsenesw
|
||||||
|
seneswseseseseneseseseweesesesw
|
||||||
|
ewnwnwwnenwwnwwnenwwnwsewwnwswww
|
||||||
|
senweeswseswneweesesesesewnwnwsee
|
||||||
|
wseseseseseseeneseese
|
||||||
|
neswneswewnwswwwwwwwswwwseewnwse
|
||||||
|
sewwsesesewnwswswswseeneeesesewse
|
||||||
|
sweswwneseneswswswswnwswnesene
|
||||||
|
eesweeenenweeneeeswenwneeeene
|
||||||
|
eseseeneweeseeeeneenwneeenwne
|
||||||
|
neneneneneswneenenwnewneneneneswnenenenee
|
||||||
|
nwnesewwswswseswnwwneswswwswwsesesw
|
||||||
|
eeneeswesenwewenwneneeeseenwesw
|
||||||
|
nenwneneneneswnenenenwnwnenw
|
||||||
|
wwseewnewwneenwwnwswsewseenwse
|
||||||
|
wsenwwnwwswwwwwswnweewnenwsee
|
||||||
|
nweseswseseseeeseeseeseeesenwsese
|
||||||
|
neneswseesewesenenenwneswwswnewswswsenw
|
||||||
|
wwneseenwwsenwnwnwneswswewnwswwnwne
|
||||||
|
eneneeneneeneesw
|
||||||
|
nwnenenwenwnwseeenwwswnwnenwnenewnw
|
||||||
|
swsweswswsewewswswnwnwwsewwe
|
||||||
|
swseneswswswswswswsesewswswseseswswnesw
|
||||||
|
eseseesenwsenwseseeeweesesweeene
|
||||||
|
neswnwsewsweseswseseswsesesenwnwneseseswse
|
||||||
|
eeneeeseeseenwneeneeeeeewne
|
||||||
|
nenwswewnwsweneswwenwswneseseneenew
|
||||||
|
weeswwwwnenwswnwsenewnwswwnwnwenw
|
||||||
|
wwnewswswswwnwseswwwswswwwnwsew
|
||||||
|
newsenwwneswwnwwnwswseeswseswsenwww
|
||||||
|
swswwsweneswwwnwnee
|
||||||
|
nwswswswswswswswswnwnwswenwseswswseeswsw
|
||||||
|
nwnwnwnewswwswnwnwnenwsenweenwnwnwnese
|
||||||
|
nwenwseseseswswswswswswenwseswnwewswswse
|
||||||
|
swneswwewsenwnwnweeenenweeseese
|
||||||
|
nwwwwwswnwesenwwnee
|
||||||
|
nwnwwwwnwwnwnwsenw
|
||||||
|
nwseseseswswneseswswnwseseswsweswsweswsw
|
||||||
|
enweswnweswnweneeeneneneeeswee
|
||||||
|
sesenwseswnwswswnenesesesesweseseesesw
|
||||||
|
swseswsewnwnwwneswswswseswswneseswwsw
|
||||||
|
nenwnenwnwnwnwnesenwnwnwnwswnene
|
||||||
|
swwenweesenesweesenweseeeeee
|
||||||
|
swnewsesenwswesweeneneesewnw
|
||||||
|
swneweswsenwnenesese
|
||||||
|
nwnweseeseseseswseewseseenenwsee
|
||||||
|
neswswneseeeeenenwwneeenenwneseneene
|
||||||
|
swswswsesesesenwsesesenwseswsesese
|
||||||
|
nwswnwenwnwnwnwnwnwnwnwnwnwsenwnw
|
||||||
|
eeneesweeeeeeseswnweeneneewe
|
||||||
|
eeenweseseeeswnwwnwnenwswnewsenenw
|
||||||
|
neswswswswseseesweswsenwsesenwnwswswsesew
|
||||||
|
eseeeseenweseeeeseese
|
||||||
|
swwwswwswwswwsewwswswnwsww
|
||||||
|
swswwsenwswwswswswswwwswew
|
||||||
|
eeeseeeseswewneeswneee
|
||||||
|
sweseswswenwnwwswswnwnenwwseewwwsee
|
||||||
|
wwnwwwwnwnwwwwewwenewnwswww
|
||||||
|
sewneswnwseeneswwwnewnwenewseswwnw
|
||||||
|
seswswswswwswswswnwsweswswswswseswswe
|
||||||
|
seswswswswswnwneswnwswswsesesenese
|
||||||
|
eenweseeeseeeeneneeeweseesw
|
||||||
|
swnwseswswnweneswenwnewenenwnwswnenese
|
||||||
|
wweenewnwsewnwwnwnenwswseweesw
|
||||||
|
wwseneeneneneneseenwwswsewwesee
|
||||||
|
wwsenewwswswwwswwwwswsw
|
||||||
|
nwwswwwnwwwnenwnwwnwnenwwswwnesw
|
||||||
|
eneseeweseesesesweewnwenwwswe
|
||||||
|
eneneeeweneeseeeenesenenenwne
|
||||||
|
neeneeeeesweseweeeeeewee
|
||||||
|
swsewnesenweenwenwnwneseseswnwnenene
|
||||||
|
sewseswseseswseseseswswesenwneswsesese
|
||||||
|
nwwwnewsewswswwnwseewwwsenewne
|
||||||
|
enwneseeeeswswneeenwnweeewwsw
|
||||||
|
wnwswswswswswsweswsw
|
||||||
|
nenenenwnesenwnenwnwswwswnene
|
||||||
|
swseseseseenwesenwsesewseesewnwseenw
|
||||||
|
eswenwsweeeenwneswseeeenwwnee
|
||||||
|
sweeswswwswswnwwnwswseseeswsesw
|
||||||
|
nweenwswsesenwneswnweeeeseseswswsenw
|
||||||
|
wnewseenwnwswneseeeeswnenwneene
|
||||||
|
nwsewnwnwnenwnwnwswenwnwnwnwwnwnwnwse
|
||||||
|
swswswswswswswnwswswswswseeswnwseswswsw
|
||||||
|
senwseswseeseneseewnwnweeseesesesesese
|
||||||
|
eeseeeenweeeneeeeneeeew
|
||||||
|
seswsenwswseesesenwswsesweswneseswsesese
|
||||||
|
nwwnenwnwwwnwwwsenwwnwnwsewnwnewsew
|
||||||
|
swneswswswswnwwswswswseswswsweswseenw
|
||||||
|
swwnenwnwneneenenenwnenwnenenenwnwne
|
||||||
|
ewneswsenwnwenenenwswseeesewnwsww
|
||||||
|
wswswenwwnenwnwseeswwnweswswnweeswse
|
||||||
|
nwnwnwsewnwnwnwenwswwsewnwenwnwwnw
|
||||||
|
neneswneneneneneneeneenenwnenewnwneenesw
|
||||||
|
eeeseseeweeeeenee
|
||||||
|
nwnwnwswsenenwenwnwnwnwswnwnwsenwnwsweene
|
||||||
|
wwsewwwwswwnewwnewwswwswwsw
|
||||||
|
nesesewwneseneseweeenwsweenwswwse
|
||||||
|
eeenweesweeewweeeeneeeee
|
||||||
|
eseswnwwsenwswneswsesweseneeneneswwwsw
|
||||||
|
wnwnwnwnwewnwnwseenwwnww
|
||||||
|
enwsenwseseeneseeseseseeswnwseesesee
|
||||||
|
neneseseseeswswwseswnesesewswnwnwwee
|
||||||
|
neenwnwnwnenwsenwnwnwsenwnenenwnwneneswnwnw
|
||||||
|
senewnwnenweeewnenwnenenwswnwnenwswnwne
|
||||||
|
seseswseswsesesesesenesewseesesesesew
|
||||||
|
nenenenwwnwneeneenwswnwnenwnwnenewnee
|
||||||
|
wwwwwseswneewnewneswnwewswsenw
|
||||||
|
nwnenwnwnwnwenwnwnenenwnwsenwnwwwnwne
|
||||||
|
wswwsenewnenenesewneneseseseewnewsw
|
||||||
|
nwnwsenwnwnwnenwnwnwnwnwnwnwnw
|
||||||
|
nwswswnwnenenwenenewneeeneswswnenwwnene
|
||||||
|
sesenwnwenwnwwnwnwnwnwnwnwnwsenwneswsenw
|
||||||
|
nwneneneswnenwnwnwnenenwnenwsenwnene
|
||||||
|
seneswneewswnenwwneeeeneeneneewe
|
||||||
|
seswswswswswneswswswswwweswwswnwswwne
|
||||||
|
swnenwnwwnenwnwnwsenenwweesenenenew
|
||||||
|
swsewwnenwnwwwwsenwwwewnwwsenew
|
||||||
|
eeeeeneeneeweneeeneenwnewswene
|
||||||
|
nwnwnwnwwnwwwwnwwwwnewnwwswneswe
|
||||||
|
swwnwsweneseswwswnewswswnwswseswnwseswe
|
||||||
|
swswswswswswswswswswseswswswswneewnwww
|
||||||
|
senwnenwsenenewnwnwwsenenwnwnwnwenenw
|
||||||
|
wswnwenwenewnwwwwwnwnwwswwwsw
|
||||||
|
swseseswswseswseneswwseneseswwseswsesese
|
||||||
|
eeeswsenewenweseeeeseeeenesw
|
||||||
|
enwnenwneswwewnwsewnwnenenwnwse
|
||||||
|
nwnenwnenwenwnwnenwnwnwswnwnwnwneneswnw
|
||||||
|
sweswseswswnwswswswswswswseenwswsewsw
|
||||||
|
wnwnwewnweenwnwewnwwsenwweswnw
|
||||||
|
senenwnwwnwnwnwwnwwwnwnwnwnwnwnwnwsesw
|
||||||
|
nwnwnwneswnwnwenwnwnewnwneenwnwnwswne
|
||||||
|
seesenewnwneswnenenenenenenenesewnene
|
||||||
|
seswwswnenwnwseseswseswswswseseweneesw
|
||||||
|
swwswenwwnwnwwewwwnwwnwnwwe
|
||||||
|
nwnwnenenwnwsenenwnwsenwnwswnwnwnwnwnw
|
||||||
|
wewsesenwswnewnwnwwnw
|
||||||
|
nesenenewneesenenweneweneeneeneeswne
|
||||||
|
senwwsenwswswnwneesewwnwneenwwnwswe
|
||||||
|
nwnwenwnwnwswnwnwnwnwnwswnwnwwenwnwnwnw
|
||||||
|
nwnwnwswnwnwneewnesenwnwnwnewnenwnenwnwe
|
||||||
|
wseseenwswseneseseneeeseeeeesenw
|
||||||
|
nenewwsewwenenwwsewswwnwwswww
|
||||||
|
nwwwnwwnesewewwwwswwewwseww
|
||||||
|
eeswseneswwsenwesesweswwsenwnwnwnese
|
||||||
|
wnwwswwewwwwwwwsenwnwwnwwsenw
|
||||||
|
nwnwnwnwnwneseneenwnenwwneenenwnwwnw
|
||||||
|
nwnwsewswnesenenwenweneseeneswwnenwwne
|
||||||
|
nwseeneneneneeneneneneneswwwwewswse
|
||||||
|
nwnenwnenenenwwswneneswnwneneneeenenwne
|
||||||
|
swswswsweswnwwswswswsweswneswswswswsw
|
||||||
|
seswseseswseswseswswnwseswswswseneswew
|
||||||
|
senwwwweswnwneswenwwswnwnwnenwwse
|
||||||
|
swswswswsewseswsewsesesesweneswsesesw
|
||||||
|
enenewneneneeeewneneseeneeneseene
|
||||||
|
nwnwnwnwnwwsenwnwsenwnwsenwnwwnwnenwnwnesw
|
||||||
|
nenenenwswnwneneneneneneneenwsenenenenw
|
||||||
|
nwnenwnwnwnwnwenwnwnwswneswnwnwnwnwnwsenw
|
||||||
|
neenenwseswnwseswswnwwnenwnwnenenenwswsew
|
||||||
|
sewnenwnenwenesenwwnwsenenwwne
|
||||||
|
wswnwwswwnwnwnwnenewnwnw
|
||||||
|
senwswneeswswswswwwswswswwsweswwsw
|
||||||
|
esewswneeeeneeewneneneneseenenwnene
|
||||||
|
nenwnwwneswnwswnwnenwswnwnwsenenwnenwnwnw
|
||||||
|
wswswnwswswwswnwswwsweweswswswsw
|
||||||
|
swswenewweswwwsweewwseswwnwnw
|
||||||
|
swwwseswswwsenesweesweenwnewsese
|
||||||
|
eseeseneseewsweneeeeseeeeee
|
||||||
|
wwnwwnwnwnwwswsewnwnwnwnwewwwnw
|
||||||
|
nwneswnwswnenwenwnwnenwnwwsenwnwnwnwne
|
||||||
|
eeeeeeneneneeweeeese
|
||||||
|
seseswseswneneseseswsenwseseseswseswsesee
|
||||||
|
wswwseswswswswswewwswnwnewsww
|
||||||
|
esenwwwseswwwnewwewnewwwww
|
||||||
|
seeeeeneeseeesenweseesewnwesese
|
||||||
|
eswwewwwwnwwwwwsewwwewnwsw
|
||||||
|
seeseeseesenwnwseeswsweswseseseesesenw
|
||||||
|
eeseeweeeseeeeeeeee
|
||||||
|
seeeseewswsenwseenwseeseneneswese
|
||||||
|
nwnwnwwneneneneewnwenenenenwsenwswnw
|
||||||
|
wsesweswnewswneswsenesewswnwseswnesene
|
||||||
|
seswseseseswseseseseswnwswswseswsesenwe
|
||||||
|
newnenesewneneneeneneseneeneneneesw
|
||||||
|
swswswswwsweswswwwwswsenweswnwwne
|
||||||
|
enwwwnwswswswwsew
|
||||||
|
nwnwnwneswnenwnwnwnenenwe
|
||||||
|
nenwneneseswnenwnenwneswneswwswneseee
|
||||||
|
eneneneeneswswneneenwswenwwneseenenw
|
||||||
|
seseswnwsenwsewswnewnwwneewneswswnew
|
||||||
|
eneneenenenenenenenenewnenenenesw
|
||||||
|
neswneswwneneewseneneeewnwnenenwne
|
||||||
|
swnwnewneeseswnweneswnwsenwnwwsewe
|
||||||
|
swwenenwswwnwsweseswswsw
|
||||||
|
senenwnenenenewnwnewnwenwnwneeneswnee
|
||||||
|
wnewneswswswwneseswww
|
||||||
|
sewwweswsewseswswswswnewseeneesw
|
||||||
|
wnwnwwsewwnwneseewwwnwsenwwww
|
||||||
|
swswswwswwswewwswswswseeswswnwswsw
|
||||||
|
seswneswsewswswswseseeswsw
|
||||||
|
nwwwnwsenwwseseneewwnwnwwwwnw
|
||||||
|
swswswswnwswwswsewne
|
||||||
|
sewneswswwweseneneeswnwnwswewswswe
|
||||||
|
nenwenwenwnwwnwnenwnenenenwnwneswnenw
|
||||||
|
eeneseseseseenwseswnewsesenwwew
|
||||||
|
nenwnesenenwwnenenenwnenenwneene
|
||||||
|
swseeseseseswsenewseseeswswnwswwswnwnwne
|
||||||
|
nwnenwnenwwnewswswseenwnwnwnw
|
||||||
|
seseswseswwsweswswswsenwswsenenwswswseswsw
|
||||||
|
nwwwsewwwwwnenwnwwwwwnwsenwsew
|
||||||
|
nenwnenwnenenenwnenwnenenesewneswnenenw
|
||||||
|
neenwnenesenwnenwnwneenwseswnwwwnwne
|
||||||
|
nenwnwnesenwnwenwnwsenwnwnwnwnwnwnwnww
|
||||||
|
swwwwwswwneswwwwsewwswwswenw
|
||||||
|
nwswswwswnwseseenww
|
||||||
|
nenwsesewneeswnwnenesenesenenewnwneee
|
||||||
|
swnewweneswseswswswswswswswswneswswswnwsw
|
||||||
|
eneseneeswwnwwnwnwsesewswenwnwsewnw
|
||||||
|
nweswnenenesenwneneneneswenenenenenenwnw
|
||||||
|
swnwnweneseenwewnweeswsenwswswnwese
|
||||||
|
esenwsweenwseeseeeeeesesweeese
|
||||||
|
wwwwwwwwwwwnesewww
|
||||||
|
swseswsesesenwseswswse
|
||||||
|
seseseswseesewseswseseseswswsese
|
||||||
|
wseeswswneseseswnwnwswswswnewwwwsw
|
||||||
|
wnwenwnwswnwnwswnwewewwnwnewnwnwse
|
||||||
|
enenwnwwwnwwwsenenwswnwseneseswnenw
|
||||||
|
eeeeswseseeeeseeeenwswnweeese
|
||||||
|
nwneswswswseswswwswswseeswswswwseswswsw
|
||||||
|
swseswnwswseswneswswswswswswsweswswsww
|
||||||
|
swswswswnwswswswsenweseseswseneseswswne
|
||||||
|
eswwnweseesesewnwsesesenwseseneesesese
|
||||||
|
enwseewnesweeenenwneseeswneeswenwe
|
||||||
|
wswwswswwseewswwnwwwseswnwswenw
|
||||||
|
nwnwnwwnwnwnwswnwnwnwe
|
||||||
|
swsenwnenwnwnwnwwe
|
||||||
|
nwseeseneeeeseeeeeeeswneseswe
|
||||||
|
neeeeewnenewnesesw
|
||||||
|
nwsewesenwnwnenenwnwsewwseneenwswnwnw
|
||||||
|
nwsewwnenenenesenwnwsenwsewnesenenwse
|
||||||
|
swsenenenwseseseswswsenwweeswsenwwsesw
|
||||||
|
wewswswwswwwwnenweswwsw
|
||||||
|
sewwwwneswnewwswwwwwwwnewwww
|
||||||
|
nenwnesenwenenwnenesenenwswswenewwnenene
|
||||||
|
eneeneeseeewneeneee
|
||||||
|
seswnwwwnenwewewnwenwwnwnwsesew
|
||||||
|
swseenewnesenwwsenwwseswnese
|
||||||
|
senwwwwewsenwwnwnwnwnwswnwnenwwswnwne
|
||||||
|
nwseseseneswsenenesesenewnesesenwswwseswe
|
||||||
|
sesewnwnwnweeswnwnwwnwnwwnwnenwnwnese
|
||||||
|
nwneneneenenwneswnwnwneneneneswnenenene
|
||||||
|
wweseseswswneswsesweseswseseswsewswe
|
||||||
|
esweseeeseswnwsenwseenwsenweesew
|
||||||
|
neswseeweeesweseeseesesenwseee
|
||||||
|
nwwnwnwswesewneenwsesewwwnwnwnww
|
||||||
|
nesewneseneeneneeeeenenewnenenenenenw
|
||||||
|
eswswswwswswwwwswnwswswwwswswsene
|
||||||
|
eeneneeneenenenwnenenewneeeeewsw
|
||||||
|
swseswneswswseseswswneseneswsesesese
|
||||||
|
weweseneneesweswswnenwenwnwwseswse
|
||||||
|
nenewnweesenenwneneneneeseneeneenenese
|
||||||
|
enenwwnwnwnwnwnewnwnwwswwwnwnwwnwse
|
||||||
|
seeseswseseeenwsesenesenwseseeeese
|
||||||
|
neenwwnesenwneneneswsenenenwnwsenwnwwne
|
||||||
|
swwwswswswnwwewswnewwnewwwswswsw
|
||||||
|
seswsesesesesewsesesenewneneseesesese
|
||||||
|
neswswnwswswswseswwnesewswnwse
|
||||||
|
wseseswnwsenwswswswseseeeswnewseeswsw
|
||||||
|
seseewenwseseseesesew
|
||||||
|
seneswseswnweneseswnwwnwsenenwsenwsesww
|
||||||
|
wwseneswswwswwneseswswswswwseswswwne
|
83
2020/24/solution.py
Normal file
83
2020/24/solution.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
"""Solution for 2020/24"""
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
instructions = []
|
||||||
|
with open('input', 'r') as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
i = 0
|
||||||
|
instruction = []
|
||||||
|
while i < len(line):
|
||||||
|
if line[i] in ['w', 'e']:
|
||||||
|
instruction.append(line[i])
|
||||||
|
else:
|
||||||
|
instruction.append(line[i:i+2])
|
||||||
|
i += 1
|
||||||
|
i += 1
|
||||||
|
instructions.append(instruction)
|
||||||
|
|
||||||
|
|
||||||
|
print(instructions)
|
||||||
|
|
||||||
|
MOVEMENTS = {
|
||||||
|
'e': (1, 0),
|
||||||
|
'w': (-1, 0),
|
||||||
|
'ne': (0, 1),
|
||||||
|
'sw': (0, -1),
|
||||||
|
'nw': (-1, 1),
|
||||||
|
'se': (1, -1),
|
||||||
|
}
|
||||||
|
|
||||||
|
MOVES = 100
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
flipped_tiles = defaultdict(int)
|
||||||
|
|
||||||
|
for instruction in instructions:
|
||||||
|
coord = parse_instruction(instruction)
|
||||||
|
flipped_tiles[coord] += 1
|
||||||
|
|
||||||
|
print(''.join(instruction), coord)
|
||||||
|
blacks = set([x[0] for x in flipped_tiles.items() if x[1] % 2 == 1])
|
||||||
|
|
||||||
|
for day in range(MOVES):
|
||||||
|
new_blacks = set()
|
||||||
|
bbox = get_bbox(blacks)
|
||||||
|
for x in range(bbox[0] - 1, bbox[2] + 2):
|
||||||
|
for y in range(bbox[1] - 1, bbox[3] + 2):
|
||||||
|
coord = (x, y)
|
||||||
|
neighbors = get_neighbors(coord)
|
||||||
|
adj_blacks = len([x for x in neighbors if x in blacks])
|
||||||
|
is_black = coord in blacks
|
||||||
|
if is_black and adj_blacks in [1, 2]:
|
||||||
|
new_blacks.add(coord)
|
||||||
|
elif not is_black and adj_blacks == 2:
|
||||||
|
new_blacks.add(coord)
|
||||||
|
blacks = new_blacks
|
||||||
|
print(f'Day {day+1:>3}: {len(blacks)}')
|
||||||
|
|
||||||
|
|
||||||
|
def parse_instruction(instruction):
|
||||||
|
coord = (0, 0)
|
||||||
|
for move in instruction:
|
||||||
|
dx, dy = MOVEMENTS[move]
|
||||||
|
coord = (coord[0] + dx, coord[1] + dy)
|
||||||
|
return coord
|
||||||
|
|
||||||
|
|
||||||
|
def get_bbox(coords):
|
||||||
|
x_coords = list(map(lambda coord: coord[0], coords))
|
||||||
|
y_coords = list(map(lambda coord: coord[1], coords))
|
||||||
|
return min(x_coords), min(y_coords), max(x_coords), max(y_coords)
|
||||||
|
|
||||||
|
|
||||||
|
def get_neighbors(coord):
|
||||||
|
neigh = []
|
||||||
|
for dx, dy in MOVEMENTS.values():
|
||||||
|
neigh.append((coord[0] + dx, coord[1] + dy))
|
||||||
|
return neigh
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
53
2020/24/solution1.py
Normal file
53
2020/24/solution1.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
"""Solution for 2020/24"""
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
instructions = []
|
||||||
|
with open('input', 'r') as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
i = 0
|
||||||
|
instruction = []
|
||||||
|
while i < len(line):
|
||||||
|
if line[i] in ['w', 'e']:
|
||||||
|
instruction.append(line[i])
|
||||||
|
else:
|
||||||
|
instruction.append(line[i:i+2])
|
||||||
|
i += 1
|
||||||
|
i += 1
|
||||||
|
instructions.append(instruction)
|
||||||
|
|
||||||
|
|
||||||
|
print(instructions)
|
||||||
|
|
||||||
|
MOVEMENTS = {
|
||||||
|
'e': (1, 0),
|
||||||
|
'w': (-1, 0),
|
||||||
|
'ne': (0, 1),
|
||||||
|
'sw': (0, -1),
|
||||||
|
'nw': (-1, 1),
|
||||||
|
'se': (1, -1),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def parse_instruction(instruction):
|
||||||
|
coord = (0, 0)
|
||||||
|
for move in instruction:
|
||||||
|
dx, dy = MOVEMENTS[move]
|
||||||
|
coord = (coord[0] + dx, coord[1] + dy)
|
||||||
|
return coord
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
flipped_tiles = defaultdict(int)
|
||||||
|
|
||||||
|
for instruction in instructions:
|
||||||
|
coord = parse_instruction(instruction)
|
||||||
|
flipped_tiles[coord] += 1
|
||||||
|
|
||||||
|
print(''.join(instruction), coord)
|
||||||
|
blacks = [x[0] for x in flipped_tiles.items() if x[1] % 2 == 1]
|
||||||
|
print('flipped', blacks)
|
||||||
|
print(len(blacks))
|
||||||
|
|
||||||
|
main()
|
2
2020/25/example
Normal file
2
2020/25/example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
5764801
|
||||||
|
17807724
|
2
2020/25/input
Normal file
2
2020/25/input
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
11349501
|
||||||
|
5107328
|
35
2020/25/solution.py
Normal file
35
2020/25/solution.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
with open('input', 'r') as f:
|
||||||
|
p_key_a = int(f.readline())
|
||||||
|
p_key_b = int(f.readline())
|
||||||
|
|
||||||
|
|
||||||
|
print(p_key_a, p_key_b)
|
||||||
|
|
||||||
|
PRIME = 20201227
|
||||||
|
SUBJECT_NUMBER = 7
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
enc_key = 1
|
||||||
|
|
||||||
|
loop_size_a = 0
|
||||||
|
print('Brute forcing loop size of a...')
|
||||||
|
while enc_key != p_key_b:
|
||||||
|
enc_key = loop(enc_key, SUBJECT_NUMBER)
|
||||||
|
loop_size_a += 1
|
||||||
|
|
||||||
|
enc_key = 1
|
||||||
|
print(loop_size_a)
|
||||||
|
for _ in range(loop_size_a):
|
||||||
|
enc_key = loop(enc_key, p_key_a)
|
||||||
|
|
||||||
|
print(enc_key)
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def loop(num, subj_num):
|
||||||
|
return (num * subj_num) % PRIME
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
16
lib/aoc.sh
Executable file
16
lib/aoc.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PARENT_DIR=$(dirname $PWD)
|
||||||
|
YEAR=${PARENT_DIR##*/}
|
||||||
|
DAY_RAW=${PWD##*/}
|
||||||
|
DAY=$((10#$DAY_RAW))
|
||||||
|
|
||||||
|
SESSION_KEY=$(cat ~/.aocrc)
|
||||||
|
|
||||||
|
echo "Fetching ${YEAR} ${DAY}"
|
||||||
|
echo $SESSION_KEY
|
||||||
|
|
||||||
|
curl -b session=$SESSION_KEY https://adventofcode.com/${YEAR}/day/${DAY}/input > input
|
||||||
|
|
||||||
|
echo "Visit: https://adventofcode.com/${YEAR}/day/${DAY}"
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user