metya 3 éve
commit
60bdbf42f6
100 módosított fájl, 18174 hozzáadás és 0 törlés
  1. 2 0
      README.md
  2. 1 0
      aoc2020/.gitignore
  3. 98 0
      aoc2020/10th/input
  4. 77 0
      aoc2020/10th/main.jl
  5. 90 0
      aoc2020/11th/input
  6. 136 0
      aoc2020/11th/main.jl
  7. 780 0
      aoc2020/12th/input
  8. 53 0
      aoc2020/12th/main.jl
  9. 200 0
      aoc2020/1st/input
  10. 82 0
      aoc2020/1st/main.jl
  11. 1000 0
      aoc2020/2nd/input
  12. 30 0
      aoc2020/2nd/main.jl
  13. 323 0
      aoc2020/3rd/input
  14. 24 0
      aoc2020/3rd/main.jl
  15. 1169 0
      aoc2020/4th/input
  16. 108 0
      aoc2020/4th/main.jl
  17. 23 0
      aoc2020/4th/stolen.jl
  18. 789 0
      aoc2020/5th/input
  19. 14 0
      aoc2020/5th/main.jl
  20. 2050 0
      aoc2020/6th/input
  21. 53 0
      aoc2020/6th/main.jl
  22. 594 0
      aoc2020/7th/input
  23. 45 0
      aoc2020/7th/main.jl
  24. 631 0
      aoc2020/8th/input
  25. 58 0
      aoc2020/8th/main.jl
  26. 1000 0
      aoc2020/9th/input
  27. 82 0
      aoc2020/9th/main.jl
  28. 1 0
      aoc2020/README.md
  29. 32 0
      aoc2021/.gitignore
  30. 8 0
      aoc2021/day10_syntax_scoring/Cargo.toml
  31. 138 0
      aoc2021/day10_syntax_scoring/README.md
  32. 10 0
      aoc2021/day10_syntax_scoring/example.txt
  33. 110 0
      aoc2021/day10_syntax_scoring/input.txt
  34. 47 0
      aoc2021/day10_syntax_scoring/main.py
  35. 3 0
      aoc2021/day10_syntax_scoring/src/main.rs
  36. 8 0
      aoc2021/day11_dumbo_octopus/Cargo.toml
  37. 381 0
      aoc2021/day11_dumbo_octopus/README.md
  38. 10 0
      aoc2021/day11_dumbo_octopus/example.txt
  39. 10 0
      aoc2021/day11_dumbo_octopus/input.txt
  40. 54 0
      aoc2021/day11_dumbo_octopus/main.py
  41. 3 0
      aoc2021/day11_dumbo_octopus/src/main.rs
  42. 8 0
      aoc2021/day12_passage_pathing/Cargo.toml
  43. 194 0
      aoc2021/day12_passage_pathing/README.md
  44. 7 0
      aoc2021/day12_passage_pathing/example.txt
  45. 23 0
      aoc2021/day12_passage_pathing/input.txt
  46. 76 0
      aoc2021/day12_passage_pathing/main.py
  47. 3 0
      aoc2021/day12_passage_pathing/src/main.rs
  48. 8 0
      aoc2021/day13_transparent_origami/Cargo.toml
  49. 163 0
      aoc2021/day13_transparent_origami/README.md
  50. 921 0
      aoc2021/day13_transparent_origami/day13.txt
  51. 21 0
      aoc2021/day13_transparent_origami/example.txt
  52. 812 0
      aoc2021/day13_transparent_origami/input.txt
  53. 55 0
      aoc2021/day13_transparent_origami/main.py
  54. 3 0
      aoc2021/day13_transparent_origami/src/main.rs
  55. 86 0
      aoc2021/day14_extended_polymerization/README.md
  56. 102 0
      aoc2021/day14_extended_polymerization/day14.txt
  57. 18 0
      aoc2021/day14_extended_polymerization/example.txt
  58. 102 0
      aoc2021/day14_extended_polymerization/input.txt
  59. 54 0
      aoc2021/day14_extended_polymerization/main.py
  60. 195 0
      aoc2021/day15_chiton/README.md
  61. 100 0
      aoc2021/day15_chiton/day15.txt
  62. 10 0
      aoc2021/day15_chiton/example.txt
  63. 100 0
      aoc2021/day15_chiton/input.txt
  64. 96 0
      aoc2021/day15_chiton/main.py
  65. 171 0
      aoc2021/day16_packet_decoder/README.md
  66. 15 0
      aoc2021/day16_packet_decoder/example.txt
  67. 1 0
      aoc2021/day16_packet_decoder/input.txt
  68. 100 0
      aoc2021/day16_packet_decoder/main.py
  69. 17 0
      aoc2021/day17_trick_shot/Cargo.toml
  70. 177 0
      aoc2021/day17_trick_shot/README.md
  71. 10 0
      aoc2021/day17_trick_shot/benches/my_bench.rs
  72. 1 0
      aoc2021/day17_trick_shot/example.txt
  73. 1 0
      aoc2021/day17_trick_shot/input.txt
  74. 55 0
      aoc2021/day17_trick_shot/main.py
  75. 52 0
      aoc2021/day17_trick_shot/src/lib.rs
  76. 53 0
      aoc2021/day17_trick_shot/src/main.rs
  77. 264 0
      aoc2021/day18_snailfish/README.md
  78. 10 0
      aoc2021/day18_snailfish/example.txt
  79. 100 0
      aoc2021/day18_snailfish/input.txt
  80. 91 0
      aoc2021/day18_snailfish/main.py
  81. 8 0
      aoc2021/day1_sonar_sweep/Cargo.toml
  82. 89 0
      aoc2021/day1_sonar_sweep/README.md
  83. 10 0
      aoc2021/day1_sonar_sweep/example.txt
  84. 2000 0
      aoc2021/day1_sonar_sweep/input.txt
  85. 46 0
      aoc2021/day1_sonar_sweep/main.py
  86. 43 0
      aoc2021/day1_sonar_sweep/src/main.rs
  87. 159 0
      aoc2021/day20_trench_map/README.md
  88. 13 0
      aoc2021/day20_trench_map/example.txt
  89. 102 0
      aoc2021/day20_trench_map/input.txt
  90. 107 0
      aoc2021/day20_trench_map/main.py
  91. 77 0
      aoc2021/day21_dirac_dice/README.md
  92. 2 0
      aoc2021/day21_dirac_dice/example.txt
  93. 2 0
      aoc2021/day21_dirac_dice/input.txt
  94. 67 0
      aoc2021/day21_dirac_dice/main.py
  95. 100 0
      aoc2021/day24_arithmetic_logic_unit/README.md
  96. 11 0
      aoc2021/day24_arithmetic_logic_unit/example.txt
  97. 252 0
      aoc2021/day24_arithmetic_logic_unit/input.txt
  98. 109 0
      aoc2021/day24_arithmetic_logic_unit/main.py
  99. 366 0
      aoc2021/day25_sea_cucumber/README.md
  100. 9 0
      aoc2021/day25_sea_cucumber/example.txt

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+# AoC
+ My Advents of Code in the different years

+ 1 - 0
aoc2020/.gitignore

@@ -0,0 +1 @@
+.vscode

+ 98 - 0
aoc2020/10th/input

@@ -0,0 +1,98 @@
+118
+14
+98
+154
+71
+127
+38
+50
+36
+132
+66
+121
+65
+26
+119
+46
+2
+140
+95
+133
+15
+40
+32
+137
+45
+155
+156
+97
+145
+44
+153
+96
+104
+58
+149
+75
+72
+57
+76
+56
+143
+11
+138
+37
+9
+82
+62
+17
+88
+33
+5
+10
+134
+114
+23
+111
+81
+21
+103
+126
+18
+8
+43
+108
+120
+16
+146
+110
+144
+124
+67
+79
+59
+89
+87
+131
+80
+139
+31
+115
+107
+53
+68
+130
+101
+22
+125
+83
+92
+30
+39
+102
+47
+109
+152
+1
+29
+86

+ 77 - 0
aoc2020/10th/main.jl

@@ -0,0 +1,77 @@
+using BenchmarkTools
+using DataStructures
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data = parse.(Int, readlines(selfdir))
+inputs=sort(vcat(data, 0, maximum(data)+3))
+
+mini_test = parse.(Int, split("16\n10\n15\n5\n1\n11\n7\n19\n6\n12\n4\n"))
+test_adapters = "28\n33\n18\n42\n31\n14\n46\n20\n48\n47\n24\n23\n49\n45\n19\n38\n39\n11\n1\n32\n25\n35\n8\n17\n7\n9\n4\n2\n34\n10\n3\n"
+test_adapters = parse.(Int, split(test_adapters))
+
+
+#---------part1
+
+function diffs(adapters)
+    diffs = diff(adapters)
+    count_diff = counter(diffs)
+    return count_diff, count_diff[1] * count_diff[3]
+end
+
+#--------part2
+
+
+function count_combinations(data)
+    diffs = diff(data)
+    cntr = 0
+    groups = []
+    for i in diffs
+        if i == 1
+            cntr += 1
+        else
+            if cntr < 2
+                cntr = 0
+                continue
+            end
+            push!(groups, cntr)
+            cntr = 0
+        end
+    end
+    cntr = 1
+    for k in groups
+        cntr *= binomial(k, 2) + 1
+    end
+    return cntr
+end
+
+
+function dynamic_tribonacci(data)
+    ad = Dict()
+    ad[0] = 1
+    for i in data
+        ad[i] = get(ad, i-1, 0) + get(ad, i-2, 0) + get(ad, i-3, 0)
+    end 
+    return ad
+end
+
+memo = Dict()
+function recursion_way(n)
+    n ∉ inputs       ? 0 :
+    n == inputs[begin] ? 1 :
+    get!(() -> sum(recursion_way, n-3:n-1), memo, n)
+end
+
+#--------evaluation
+
+part1 = @time diffs(inputs)
+println(part1)
+part2 = @time count_combinations(inputs)
+println(part2)
+part2_another = @time dynamic_tribonacci(inputs[2:end])[inputs[end]]
+println(part2_another)
+@time recursion_way(last(inputs))
+
+
+
+

+ 90 - 0
aoc2020/11th/input

@@ -0,0 +1,90 @@
+LLLLL.LLLLLL.LLLLLLLLL.LLL.LL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLL.LLLLLLLLLL.LLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLLL.LLLLLLLL.LLLLL.LLL.LLLLLL.LLLL.LLLLL.LLLLLLLLLLL.LLLLLLLL.LLLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLL.LLLL.L.LLLLLLLLLLLLLLLLLLLLLLLLL.LLL.LLLL
+LLLLL.L.LLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLL.LLLL.L.LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+L.LL.L.L.LL.....L.L..L.LL.L.L.L.....L..LLL.L.....L.L...LL..L.....L...L..L.LLLL..L.LL......L.L.L.
+LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.L.LLLLLLLLL.LLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLL.
+LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+......LL..LLLL.L...LL.....L.L.......L..L.LL....L.LLL........L.L.L.LL.....L.........L....L......L
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLL.LL.LLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL..LLLLLLL..LLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLL.LLLL.LLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.L.LLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.L.LLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLL..LLLLL.LLL.LLLLLL.LLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLL.L.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+.L...L...L.....L...L....L.LL.LLL.LL...LL.L..L...L......L..LL..L..LL..L.L......L.L.LLL......L.L..
+LLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLL.LLLLLLLLLLLLLLLLL.L.LLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLL.L.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLL.LLL.LLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLL.LL.LL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+...........LLL.....LLL.....LL.L..........L..L.L.L...L.L.....L........L......L..L..L...LL....L.L.
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLL.LLLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLL.LLLL.L.LLLL.LLLLLL.LLLLLL.LLLL.LLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLL.LLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLL.LLLL.LLLLLLL.L.LLLLLLLL
+LLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL.L.LLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLLLLLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+.LLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLLL.LLLL.LLLL.LLLLLLLLLLLLL
+L.......LL...LL...L..L.....L..LL..L.L.LLL.L.L..L.LL.L.........L....LLLL..LL..L.L..L..LLLL..LL.L.
+LLLLL.LLLLLL.LLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLL.LLLLLL..LLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLL.LLLL.LLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+....LLL.LL....L.L.........L.L............L..L...L.LLLL......L...L.L..L....L.......L..L..........
+LLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL..LLLLLLLL.LLLLLL.LL.L.LLLLL.LLLLLL.LLLLLL.LLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LL.L.LLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLLLL.L..LLL..LLLLLLLLL.LLLLLL.LLLL.L.LLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLL..LLLLL.LLLLLLLLL.LLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+.L..LLLL..L.L.LLL.......LL.LL.LL......L.L....L.LLL.......L...L.L.LL...LL.....L.L....L.L...L.L...
+LLLLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLLLLLL.LLLL
+LLLLL.LL.LLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLL.LLLL..LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL..LLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLL.LL
+LLL.LLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLL
+LLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLL.LLLLLLLLLL.LLLLLLLLLLLLLLLLLLL
+.L..L..LLL....LL......LL.L.L..LL..LL....L...L..L.L.L...L..L..L.LLLL.L....L.....L..L...L...LLL...
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLLLL.L.LLLLLL.LLLL.LLL.LLLLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLL.LLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LL.LLL.LLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLLLLLLLLL.LLLLLLLL.LLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLL..LLLLLLLLLLLLLL.LLLLLL.LL.LLLLLLLLLLL.L.LLLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+..LL.LL.L.LL.L...L..L..L..L...LL........L......LL.LLLL.......L..LLL.L.L....L.....L..LL..L.LL.LL.
+LLLLL.LLLL.L.LLLLL.LLL.LLLLLL.LLLLLLL.LL.LLLLLL.LLLLLL.LLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL..LLLLL.LLLLLLL.LLLL.LLLLLLLLLLL.LLLL..LLLL.LLLLLLLLLLL.LLLLLLLLLLLLL.LLLL
+LLLLL.LLLLLLLLLLLLLLL.L.LLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLL..LLLLLLLLLLLLLLL.L.LLLLLLLLLLL.LLLLLLLLLLLL.LLLL.LLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LL.LL.LLL.LL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL..LLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLL..LLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+.LL..LL.L.LL......L.L.LL...L..LL..LL...L..L.L..LL...L.L..L.....L.LLL..L..LL.L..L.......L..LLL...
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLL..LLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLL..LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLL.LLLLLLLLL.LLLL.LLL.L.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
+LLLLL.LLL.LL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLL.LL.LLL.LLLL.LLLLL.LLLLLL.LL.L.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.L.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+.L.L....LLL.L.L........L..L....L..L...LL..L..LLL..L.L....L..L.LL....LL.L.L.....L........L..L.L..
+LLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLLLLLLL.LLLLLLLLLLL.LLLLLLLLLLLLLL.LL.LLLLLLLLLLLLL.LLLL.LLLLL.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLL.LLLLLLLLLLL.LLLLLLLLLLLLLL.LLL
+LLLLL.LLLLLL.LLLLLLLLLLLLLL.L.LLLLLLL.LLLLLLLL.LLLLLLL.LLLL.LLLLL.LLLLLL.LLLL.LLLLL.LL..LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.L.LLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLL.LLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+LLLLLLLLLLLL.LLLLLLLLLLLLL.LL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLL.LLLL.LLLLLLLLLLLLLLLLLL
+LLLL..L.LLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLL.LLLLLLLLLLL.LLLLLLLLL.LLLLLLLL
+LLLLL..LLLLL.LLLLLLLLL.LLLLLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLLLLLL.LLLLLL..LLLLLLLLL.LLLLLLLL
+LLLLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLL.LLLLLLLLLLLLLLLLLLL.L.LL..LLLLLLLLLLL.LLLL.LLLLLLLLL.LLLLLLLL

+ 136 - 0
aoc2020/11th/main.jl

@@ -0,0 +1,136 @@
+using BenchmarkTools
+using DataStructures
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data = readlines(selfdir)
+
+test_data = split(
+"""
+L.LL.LL.LL
+LLLLLLL.LL
+L.L.L..L..
+LLLL.LL.LL
+L.LL.LL.LL
+L.LLLLL.LL
+..L.L.....
+LLLLLLLLLL
+L.LLLLLL.L
+L.LLLLL.LL
+""")
+
+#--------part1
+
+function conv2d(input, filter, padding="valid")
+    input_r, input_c = size(input)
+    filter_r, filter_c = size(filter)
+
+    if padding == "same"
+        pad_r = (filter_r - 1) ÷ 2 # Integer division.
+        pad_c = (filter_c - 1) ÷ 2 # Needed because of Type-stability feature of Julia
+
+        input_padded = zeros(input_r+(2*pad_r), input_c+(2*pad_c))
+        for i in 1:input_r, j in 1:input_c
+            input_padded[i+pad_r, j+pad_c] = input[i, j]
+        end
+        input = input_padded
+        input_r, input_c = size(input)
+    elseif padding == "valid"
+        # We don't need to do anything here
+    else 
+        throw(DomainError(padding, "Invalid padding value"))
+    end
+
+    result = zeros(input_r-filter_r+1, input_c-filter_c+1)
+    result_r, result_c = size(result)
+
+    for i in 1:result_r
+        for j in 1:result_c
+            for k in 1:filter_r 
+                for l in 1:filter_c 
+                    result[i,j] += input[i+k-1,j+l-1]*filter[k,l]
+                end
+            end
+        end
+    end
+    return result
+end
+
+function step(orig_seats)
+    seats = deepcopy(orig_seats)
+    conv_arr = replace(seats, 'L'=>0, '#'=>1, '.'=>0) |> 
+                x-> conv2d(x, [[1,1,1] [1,0,1] [1,1,1]], "same")
+    for i in 1:size(seats)[1], j in 1:size(seats)[2]
+        if (conv_arr[i,j] > 3) & (seats[i,j] == '#')
+            seats[i,j] = 'L'
+        elseif (conv_arr[i,j] == 0) & (seats[i,j] == 'L')
+            seats[i,j]='#'
+        end
+    end
+    seats
+end
+
+
+#--------part2
+
+function step2(orig_state)
+    b = deepcopy(orig_state)
+    bd = deepcopy(orig_state)
+    for i in 1:size(bd, 1), j in 1:size(bd, 2)
+        cntr = count_dir(bd, i, j)
+        # cntr = count_seats_part2(b,i,j,'#')
+        if bd[i,j] == '#' && cntr >= 5
+            b[i,j] = 'L'
+        elseif bd[i,j] == 'L' && cntr == 0
+            b[i,j] = '#'
+        end
+    end
+    b
+end
+
+function count_dir(seats, i, j)
+    cntr = 0
+    for Δx in (-1, 0, 1), Δy in (-1, 0, 1)
+        (Δx == 0 && Δy == 0) && continue
+        x, y = i, j
+        while true
+            x += Δx
+            y += Δy
+            !(x >= 1 && x <= size(seats, 1)) && break
+            !(y >= 1 && y <= size(seats, 2)) && break
+            if seats[x, y] == '#'
+                cntr += 1
+                break
+            elseif seats[x, y] == '.'
+                continue
+            else
+                break
+            end
+        end
+    end
+    return cntr
+end
+
+#--------evaluation
+
+function modeling(data, step)
+    data = replace(data, 'L'=>'#')
+    state = reduce(vcat, permutedims.(collect.(data)))
+    num_steps = 0
+    new_state = step(state)
+    while state != new_state
+        state = new_state
+        new_state = step(new_state)
+        num_steps += 1
+    end
+    counter(new_state), num_steps
+end
+
+
+part1 = @btime modeling(data, step)
+part2 = @btime modeling(data, step2)
+
+
+
+
+

+ 780 - 0
aoc2020/12th/input

@@ -0,0 +1,780 @@
+R90
+F56
+R90
+F56
+R90
+R180
+W5
+L90
+E2
+L90
+S5
+E1
+F11
+L90
+F46
+S2
+E2
+S1
+E2
+E3
+N4
+W1
+N4
+L90
+W4
+L90
+N1
+E1
+S4
+F45
+S4
+W4
+S1
+E3
+E3
+E1
+F76
+S5
+E1
+N3
+W2
+F55
+E3
+F34
+S2
+S2
+E3
+S5
+L90
+L90
+W5
+F23
+R90
+F14
+F21
+L90
+N3
+L180
+N3
+F98
+R180
+S5
+F94
+R90
+N5
+L90
+S3
+F85
+R90
+F77
+S1
+R90
+E3
+S2
+E5
+R180
+W3
+F46
+R90
+F44
+S3
+W3
+L180
+N4
+L90
+N1
+E2
+L90
+S4
+R90
+E1
+N4
+F100
+L90
+S4
+F94
+L180
+W2
+S1
+R90
+E5
+L90
+S4
+L90
+W3
+E1
+R270
+S4
+E2
+N5
+F3
+R180
+F21
+L90
+F57
+W1
+F77
+F24
+N4
+E5
+S3
+L90
+F64
+N5
+L90
+N1
+F42
+S5
+W1
+F50
+S1
+W3
+N5
+E5
+F19
+R180
+W4
+S4
+F20
+L90
+W1
+F88
+R90
+F57
+L90
+N4
+W5
+R90
+S3
+E2
+S1
+E2
+N1
+E4
+S1
+F3
+R90
+W1
+N4
+R90
+F38
+E5
+E1
+N2
+R90
+N5
+S4
+E3
+F8
+W5
+R90
+E4
+F19
+N1
+F50
+E1
+F54
+W5
+L90
+F10
+S2
+E3
+R90
+S5
+L90
+F59
+N3
+R90
+W5
+F33
+N4
+R270
+F46
+S2
+L270
+F97
+E4
+N2
+E5
+R90
+F31
+R180
+N1
+W1
+R90
+F40
+R90
+S5
+F15
+L90
+E2
+L90
+L90
+F53
+N4
+F28
+E5
+F58
+L90
+W1
+L90
+E1
+L90
+N1
+F42
+S2
+S3
+F62
+E5
+F73
+W1
+R270
+F10
+R90
+E5
+N3
+E4
+S1
+E2
+N4
+E4
+F47
+E3
+E5
+S5
+F24
+L90
+N2
+L180
+S2
+F82
+W3
+S2
+W1
+R90
+N5
+E3
+N4
+L90
+N1
+F53
+S3
+L90
+S5
+F88
+F40
+S1
+E4
+N4
+F66
+W3
+L90
+E1
+R180
+F73
+R90
+W4
+N4
+F85
+E4
+F66
+S1
+W4
+F16
+R180
+N5
+L90
+S3
+E4
+N4
+W2
+L90
+R90
+W3
+N5
+R90
+F45
+E2
+S5
+R90
+F6
+W4
+S2
+E4
+F74
+W4
+L90
+F75
+W2
+L90
+F97
+R90
+N4
+F27
+L180
+F45
+S1
+L90
+W2
+F10
+W3
+S4
+F42
+W1
+F30
+R90
+E2
+F94
+E5
+R90
+F41
+E1
+N3
+W1
+N2
+R90
+S5
+F93
+N1
+R90
+F38
+S3
+F50
+L270
+W1
+S4
+F64
+W1
+N1
+F61
+R90
+W2
+R90
+N1
+F31
+S2
+F7
+N2
+R90
+S5
+E3
+S1
+E1
+R90
+E2
+R90
+E4
+F76
+R90
+W4
+F15
+S3
+F2
+R90
+N4
+F66
+L180
+W3
+N2
+F1
+S4
+L90
+N1
+F19
+F20
+E1
+R90
+N3
+F54
+N4
+F62
+W2
+S1
+F49
+W3
+S4
+W3
+N2
+E4
+N1
+R90
+E1
+N2
+L90
+F46
+S4
+E2
+L90
+S3
+L90
+N4
+R180
+F56
+L90
+E2
+F51
+W1
+N5
+E2
+L90
+E3
+S5
+W3
+F73
+E5
+F100
+L90
+N2
+W2
+L180
+F89
+L90
+N3
+W4
+S2
+W1
+L270
+E5
+N2
+R90
+F65
+W1
+F41
+E2
+N4
+E1
+F73
+L180
+S4
+L90
+N4
+W3
+N4
+E1
+R180
+F67
+E5
+L90
+N5
+F75
+N3
+E4
+R90
+F28
+R90
+S3
+F77
+L180
+N2
+N1
+R90
+F77
+S3
+W3
+N4
+F60
+W4
+F40
+L90
+W3
+W3
+E1
+S2
+W2
+N1
+F86
+R180
+E1
+L180
+F17
+R90
+F11
+E1
+S2
+F48
+S2
+W2
+F1
+N5
+F53
+N2
+W1
+L180
+L90
+N5
+W1
+L180
+E1
+F67
+W4
+N3
+E5
+N1
+F88
+R90
+F93
+E1
+F33
+L90
+F1
+W2
+N4
+W3
+F85
+S1
+E2
+F69
+R90
+S4
+W2
+L90
+W3
+S5
+F14
+W1
+S5
+W2
+F95
+F30
+E1
+F4
+W3
+R90
+F93
+N5
+E1
+F9
+L90
+W5
+L270
+E1
+L90
+S2
+F97
+S1
+F18
+E3
+R90
+N1
+R90
+N5
+F72
+S4
+L90
+W3
+S3
+F13
+W5
+N2
+F31
+F17
+S4
+E2
+L90
+N5
+R90
+F42
+W2
+N1
+S3
+F60
+W5
+N4
+R90
+E5
+S3
+F88
+E4
+N5
+W3
+L180
+N3
+F66
+E5
+R270
+E3
+L180
+W4
+W3
+S2
+W1
+F69
+E5
+L90
+F23
+W5
+L90
+F49
+S3
+R180
+W2
+L90
+N1
+R90
+S4
+F71
+N5
+F36
+R180
+F62
+L180
+F39
+N5
+F36
+R180
+N4
+W4
+E5
+F94
+F39
+L90
+N1
+F70
+R90
+W2
+R180
+F16
+E3
+S1
+R180
+E1
+S3
+E5
+L90
+N5
+F76
+N4
+R90
+E3
+L180
+N3
+F20
+S3
+R90
+N3
+L270
+E4
+N5
+F49
+S3
+F79
+W3
+R270
+E1
+L180
+R90
+F34
+W3
+S5
+E5
+F76
+N3
+N5
+F66
+L90
+F48
+E1
+L270
+E3
+S2
+L180
+N3
+F1
+W5
+L90
+F9
+S5
+F64
+L180
+W1
+N1
+E2
+F4
+R90
+F81
+W5
+S4
+E1
+N4
+E1
+F61
+R180
+S2
+R180
+F24
+N3
+W5
+N1
+F67
+L180
+F50
+W5
+R90
+N2
+L180
+F80
+W5
+L90
+N1
+F31
+E5
+R90
+N5
+R90
+F93
+E2
+E3
+L90
+E2
+L90
+E1
+N4
+W4
+F80
+R180
+F84
+E5
+N1
+F37
+S3
+W5
+S4
+F9
+R90
+E2
+R90
+F39
+R90
+F77
+N3
+R90
+E5
+N2
+F49
+S2
+W3
+F42
+N1
+F19
+E2
+N3
+R90
+F48
+N1
+W3
+S2
+E3
+L90
+E1
+R90
+F100
+E2
+L90
+F90
+W1
+F66
+N4
+R180
+W2
+F33

+ 53 - 0
aoc2020/12th/main.jl

@@ -0,0 +1,53 @@
+using BenchmarkTools
+using DataStructures
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data = readlines(selfdir)
+
+test_instr = split(
+"""
+F10
+N3
+F7
+R90
+F11
+""")
+
+a = collect(zip(first.(test_instr), parse.(Int, [i[2:end] for i in test_instr])))
+instr = collect(zip(first.(data), parse.(Int, [i[2:end] for i in data])))
+
+#--------part1
+
+function get_man(instr)
+    sides = ['E', 'S', 'W', 'N']
+    s = 1
+    direc = DefaultDict(0)
+    for (dir, dis) in instr
+        if dir == 'F' 
+            direc[sides[s]] += dis
+        elseif dir == 'R'
+            s += Int(dis/90)
+            s = s > 4 ? s % 4 : s
+        elseif dir == 'L'
+            s -= Int(dis/90)
+            s = s < 1 ? 4 + s : s
+        else 
+            direc[dir] += dis
+        end
+    end
+    abs(direc['E']-direc['W']) + abs(direc['N']-direc['S'])
+end
+
+#--------part2
+
+sides = ['E', 'S', 'W', 'N']
+s = 1
+waypoint = DefaultDict(0)
+ship = DefaultDict(0)
+waypoint['E'] = 10
+waypoint['N'] = 1
+
+
+
+get_man(instr)

+ 200 - 0
aoc2020/1st/input

@@ -0,0 +1,200 @@
+2010
+1856
+1905
+1786
+1557
+1995
+1830
+1971
+1909
+1500
+1806
+1846
+2003
+1839
+1943
+1977
+1537
+689
+1861
+1886
+1815
+1763
+1834
+1881
+1952
+1853
+1775
+1835
+1874
+1948
+1978
+347
+1672
+885
+1709
+1826
+1911
+1644
+1064
+1561
+1966
+1352
+1347
+1928
+1756
+615
+1513
+1932
+1968
+1762
+1842
+1475
+1921
+1716
+1533
+1975
+1924
+1850
+1456
+1783
+1587
+1913
+1908
+1502
+1993
+1635
+1691
+1706
+1871
+1857
+1915
+1604
+1618
+1902
+1860
+1648
+1933
+1999
+1960
+1389
+1858
+1793
+1609
+1484
+1735
+1535
+1891
+1879
+1517
+1766
+1926
+1668
+1495
+1585
+1831
+1308
+1767
+1479
+1638
+1600
+710
+1685
+1818
+1859
+1822
+1844
+1550
+1872
+1719
+1863
+1987
+199
+1840
+1817
+1752
+1612
+1983
+1838
+1504
+1997
+716
+1862
+1931
+1356
+1645
+1962
+1574
+1914
+1869
+1919
+1487
+1961
+1728
+1867
+1177
+1757
+1316
+1875
+1991
+1646
+700
+1972
+2004
+1577
+118
+1954
+1483
+1516
+2007
+1506
+1588
+1698
+1725
+2006
+179
+1849
+1894
+1695
+1399
+1726
+1658
+1920
+1825
+1837
+1878
+1591
+1611
+1409
+1553
+1705
+1845
+1718
+1732
+1639
+1885
+1929
+1887
+1787
+1541
+1946
+1391
+1884
+1938
+1496
+1720
+1669
+1965
+1967
+1890
+1743
+1889
+1970
+1866
+1912
+1785
+1998
+1708
+1810
+1939
+2005

+ 82 - 0
aoc2020/1st/main.jl

@@ -0,0 +1,82 @@
+using Combinatorics
+using DelimitedFiles
+using BenchmarkTools
+
+#--------part1
+
+function twosum(array)
+    sort_a = sort(array[:, 1])
+    for i in sort_a
+        for j in sort_a
+            if i + j == 2020
+                return i * j
+            end
+        end
+    end
+end
+
+function ocamlAnton(array)
+    sort_a = sort(array[:, 1])
+    i = 1
+    j = length(sort_a) - 1
+    while i < j
+        _sum = sort_a[i] + sort_a[j]
+        if _sum > 2020
+            j = j - 1
+        elseif _sum < 2020
+            i = i + 1
+        else
+            return sort_a[i] * sort_a[j]
+        end
+    end
+end
+
+function twosumcomb(array)
+    for pair in combinations(array, 2)
+        if sum(pair) == 2020
+            return prod(pair)
+        end
+    end
+end
+
+#--------part2
+
+function threesum(array)
+    sort_a = sort(array[:, 1])
+    for i in sort_a
+        for j in sort_a
+            for a in sort_a
+                if i + j + a == 2020
+                    return i * j * a
+                end
+            end
+        end
+    end
+end
+
+function threesumcomb(array)
+    for cort in combinations(array, 3)
+        if sum(cort) == 2020
+            return prod(cort)
+        end
+    end
+end
+
+#--------evaluation
+
+selfdir = joinpath(@__DIR__, "input")
+array = readdlm(selfdir, Int)
+
+ocaml_result = @btime ocamlAnton(array)
+println("ocaml_result = $ocaml_result")
+
+twosum_result = @btime twosum(array)
+println("twosum_result = $twosum_result")
+twosumcomb_result = @btime twosumcomb(array)
+println("twosumcomb_result = $twosumcomb_result")
+
+threesum_result = @btime threesum(array)
+println("threesum_result = $threesum_result")
+threesumcomb_result = @btime threesumcomb(array)
+println("threesumcomb_result = $threesumcomb_result")
+

+ 1000 - 0
aoc2020/2nd/input

@@ -0,0 +1,1000 @@
+8-9 x: xxxxxxxrk
+5-8 f: fxffmfff
+2-5 c: ccspwpc
+1-4 g: gggg
+9-10 l: lllllllllk
+1-3 j: djjfz
+3-4 n: nnnmn
+8-9 l: llllllllc
+4-5 v: vvvvm
+3-4 t: ttnt
+4-5 w: wrwws
+12-14 x: xxxxxxxxxxxcxxxx
+9-10 q: qqqqqqqqtq
+4-5 q: qsktqncqqqdn
+2-7 h: ngkhcthb
+9-11 r: rrqrrrrpcvs
+3-6 c: rccbcc
+7-8 k: xpkmjlxkt
+1-5 l: zcwdhpkvz
+4-11 r: rhmzhrxrdrrtddj
+11-15 g: lggndgggsggggtdggg
+6-12 m: mmmmmmgmmmmmwm
+4-9 z: zzzgzzzzz
+4-9 k: kkkkkkkknk
+9-14 l: fldlllllldqllwj
+1-10 k: sbnxkmtbgdf
+2-3 v: tjzvnfv
+3-4 d: dddd
+1-2 l: ltfwjqjlqpnbqmnj
+2-5 r: rrrrr
+9-10 v: vvvvvvvvvdv
+16-17 j: jjjjnjjrjjjjhjjzqjj
+10-19 q: qqqqpqqqktqqqqqtfhq
+17-18 c: ccccccccccccccccmc
+3-7 f: kcpnxfffpv
+4-7 m: mrzmmtsmmmb
+8-10 l: lmlllllllnlb
+1-3 d: bzndm
+2-13 s: szsssjsssssssss
+3-8 b: bbbwbshbbbb
+15-18 h: hhhhhhhhghhhhhzhhh
+6-10 b: zbbbtbswrn
+12-14 t: nttttttttttstzgt
+7-12 f: vffcmffwfjpk
+3-18 r: frvkrwrlrrdbdrrrrxnr
+12-13 k: kkkpkkkkrkkxkkk
+6-11 b: bbbbblbbbbbw
+4-5 f: tfdjf
+7-8 m: cqmmmzmmmmgm
+2-4 j: jjfx
+3-5 v: xvvvsq
+9-10 s: sssmsssshgsd
+1-6 t: tptbjsttt
+4-15 z: zzzgzzzzzzzzzzz
+4-5 p: mxpnp
+2-3 n: knwfnnj
+10-11 s: sfswsbssgssvp
+12-13 d: dwndddddddlnddrdds
+14-15 k: bcvpdjkkndkmkrg
+10-13 x: xxxxxxxxxnxxz
+5-10 f: fffkffgspffffzcf
+11-12 t: ttttqtttxhtzzttt
+15-16 k: kkkkkkkkkkkkkktk
+6-8 b: bfbbbbtkbb
+2-7 h: hlhhhhgh
+3-11 q: ldbtqbsfkqqcrl
+10-15 q: qqrqqmqqqqfwqfzqqxqq
+3-5 r: ldtrrxrnqrhqnhkrv
+9-10 n: qnkvnnfnznnnnjn
+1-8 w: wwwrwwpxmwsswwzwzww
+1-4 f: zfwtzx
+1-8 w: wwwnnwfv
+9-11 r: jrrfgrrrzdr
+15-18 b: bbbbbbzbbbbbbbsgbb
+16-19 t: sfgfffhscvpdrqtvsmh
+7-8 k: kkkkkkrk
+9-11 z: fszzzzzzszzzcz
+1-14 k: lhkrkkkklkkkpkfkk
+5-6 s: sssscs
+11-13 j: jjjpnjjjjjkjjj
+1-6 x: mxhjgxbt
+9-11 t: xtltttttktg
+4-12 z: zzkdzwzzzzzfzz
+13-16 j: jjjqjjjcjjsjdjjjjj
+13-14 h: bhhhhhhhhhvhhhhhh
+6-7 k: vwllpkb
+1-5 c: sbnmbhcjlczjrc
+2-11 c: skrtgbzdklcxqrwr
+16-17 r: rvnnjknhswckcbrmr
+5-6 b: btbbbnbb
+3-5 c: ccpcm
+3-7 h: hhvhvbhfth
+2-11 d: ddbddlddvdfdwxwxd
+6-8 m: mwmmmmmmmmc
+1-5 l: lgwrlpmnfnzlczkpflt
+4-6 x: cgbncxtwsvjwtbjqxzz
+6-13 h: tnhshhkhhhjsdhrbh
+1-2 s: gpzrf
+12-14 p: pxpzpppfpppppxpp
+2-8 j: jddjjjjtjjqpj
+3-13 v: vkvvvvvvvvvvdvvvvvv
+4-16 b: bbbbbbbbbbbbbzbdb
+5-6 b: bbbbbbb
+2-4 v: vvvhv
+13-14 w: wwwcwwwwwwwwtww
+1-7 g: gdbgpncbdgk
+13-18 g: ggggskgggcgggghgsvr
+15-18 c: cckcccccccccccgccccr
+4-6 l: klflll
+17-18 g: gggzgggggggggggggg
+1-3 m: kmmmmmm
+5-10 s: qxstrsbxkssksc
+16-18 r: rrrrrrrrjrrjrrrrrvrr
+6-9 c: rgcscfjccvzgcccqc
+2-5 m: mmvmp
+1-11 z: zbsdnzstzsbzzlj
+6-7 v: vvvvtvqvpv
+11-12 x: xxxxxxqxxxfnx
+4-15 h: hnthvnjhzhqhwvwhh
+4-12 g: dggggrvvgmcldfgqbggj
+11-12 l: lllllwllllvn
+1-3 l: lpplz
+5-6 v: vzndfwd
+6-8 j: vxjjddjjjmjpjw
+6-7 k: kkkkklkk
+2-9 g: zgqmwlgfrsz
+1-2 k: kkqk
+2-13 h: clhmnhhwhpdhh
+3-14 z: zzxzzzzzzzzzzg
+9-10 v: vvvvvvvvpf
+17-18 z: zzzzzzzzzzzzzzczgz
+15-18 j: jjjjjjjjdjjjjjjjjx
+2-7 w: zqfxwwwwww
+4-11 r: qrcrrzrqnrhrn
+9-10 q: jqctxwmccqqpcqqbllq
+4-5 b: tbbbk
+1-2 r: rsvmjrbprjjvdkcfk
+9-11 v: vvvvvvvvvvv
+1-4 c: ccbjccccc
+7-8 l: llllllql
+5-8 c: cncccccwc
+3-4 d: kdzdkjdqkvhdz
+6-7 j: cjjjpqj
+11-16 t: ttttttttbttttttttt
+5-17 v: vvgvqvxvsvvvbvvvvvvv
+12-18 k: kkkgkkkkkskkkkkdkwk
+1-7 p: ppqqpjp
+1-13 v: fsvbwvvvmvtvv
+8-10 q: qqmqqqqbqmvvq
+14-16 m: mmmmmmmmmmmmmmmgm
+2-5 r: prrrmr
+6-12 j: jhjjjzjpjmjjvj
+5-6 x: xxxxdx
+4-5 n: nnnsnn
+2-6 j: jjjjztj
+3-8 j: tzjzbjbqqjlww
+13-15 z: btzzwrzbzmdcdzz
+1-2 j: ddjkbx
+4-8 b: jbbkbqsblcbhprzqtb
+3-5 b: bbkbb
+6-8 f: fffffffff
+2-4 l: lsprl
+17-18 t: ttttttttttttttttth
+1-4 p: pppf
+13-18 m: mmmmmmmmmmhmsmmmmmmm
+7-8 s: sssssssss
+18-19 t: ttjtttttttttttttttjt
+2-5 j: jjddt
+6-12 r: trrnrcrnrrrr
+6-7 h: rhhkhhthdsh
+6-7 s: vpxmpdstfdv
+9-10 p: ppppppppwpppp
+2-4 h: hhhh
+1-3 h: hhthhhhfhhhhh
+4-5 k: dkbknt
+7-10 d: kbdddddddsdd
+11-16 s: ssswksjsssgsssssspt
+5-8 b: vxlbbbzmbkktwrtlbt
+2-8 h: hhmhvszx
+6-8 g: ggzggggxgg
+3-4 q: qqqp
+4-9 v: vvfvqzbvvh
+10-13 g: xggmgglfgxpsgggggg
+1-8 b: bgsblbskxgkt
+7-10 b: dbbqhftgblbbb
+1-2 j: wjjgrdznbn
+12-13 z: mzzjzzzzzzzgzzsz
+4-9 m: psmmmmmbzmvmmm
+8-9 n: nnnmnnnnpnnn
+2-3 p: qpjhhgkp
+6-7 h: phhhwhhmfh
+2-4 b: bkrljb
+11-12 c: crccbcccccccc
+3-14 r: rrrrbrrhrrrrrzhr
+5-6 c: ccrcdcwcc
+1-17 k: kkkkkkkkkkkkkkkklkkk
+4-7 k: kkkkkkvkk
+3-4 w: rqwc
+6-12 k: kkxkklkkkkkk
+2-3 w: dpww
+15-16 h: hhhhhhhhhhshhhwhh
+2-6 x: gxxmthnbj
+3-5 s: sbhsc
+10-12 q: qfqqprqqrmqqq
+9-11 f: hkpmjfgfrcfnfz
+2-16 f: ffffffffffffnffq
+4-5 f: fffcf
+2-7 d: tdzqcdd
+1-4 h: hnxz
+16-17 g: gggggggtgggggggqx
+2-4 n: nngcd
+4-6 r: rrrkmf
+5-6 g: ggghgggg
+7-9 p: qkmpfzpptdjsbppcthpp
+9-13 t: ttttttbtttttt
+5-7 l: cldkllzgxldwlcdll
+5-8 f: ffpqrftfsjd
+6-13 t: tbtltkltttsjttkr
+6-17 w: wtbwwpwwwhwcwtwzzww
+2-8 x: nxsqbdmkqtx
+2-5 s: fsrsvss
+9-12 x: nxxxxxxxmxxxnx
+1-16 j: jjlmjrgpnkgjjwhjhxt
+6-10 k: kkxkkkkkpfkkl
+3-9 l: lhzgllglllrtt
+18-19 p: pppppsppppppppppppp
+1-8 b: bbbbdbbwbbjkbbj
+16-18 p: pppppppppspppptppgpt
+1-5 w: wnmwff
+3-4 v: vvvvm
+1-16 j: jbhjjbjhwjjgjxjw
+8-17 j: jjjjhjjjjjjjcjjjs
+3-4 n: nnnn
+17-18 t: tttttttttttttxttwtt
+3-4 k: kbpkk
+2-3 n: ndnn
+9-13 m: mmmmmmzmwmmmm
+1-10 d: djdddddldddddddd
+9-13 v: vjvvvvvvfvjvv
+13-14 m: mmmmmmmmmmmmmm
+4-10 x: xnxczxxxxxx
+17-18 h: hhhhhhhhhhhthhhhmhh
+3-13 z: zzmzzzzzzzzzzz
+3-6 w: wwtwwww
+11-14 v: ghvvvvvvvvvlvkvvvsvd
+2-9 r: qrdqvchhjgrpgj
+9-10 w: wwwwrwwwww
+3-5 c: xcgccc
+6-7 z: zzzzzfz
+16-18 b: bbbbbdbbbbbbbbbpbp
+3-5 s: ssssw
+3-4 z: zztzzzzzzz
+7-8 j: jjjjjjpj
+11-12 b: mbsjljhbbnpczlnbm
+1-4 k: tkhk
+9-10 j: jjjnjjjjjz
+3-8 v: nvrbvvmrvhcs
+1-5 z: szdcdjphttvnrd
+2-7 m: zmmmmmhvqhpmmmmsmmv
+7-8 t: tbtttttghcdptljtk
+2-9 s: slssssssss
+2-4 g: jgnn
+3-8 s: ssksssss
+6-10 t: bthxljrxhth
+4-10 d: dddddddddqddddddddd
+8-13 c: ccrjcccccqjcc
+6-8 z: tlgdknkzxrghz
+8-11 t: jttttmtbttdt
+1-2 x: xhxx
+3-4 c: cccj
+9-10 v: vvsvvvvvvv
+4-8 q: qqclqqqqtqqpzqj
+7-9 w: wwwwrwnwj
+1-3 w: cbwmzwwr
+6-7 l: llllllz
+1-8 h: rhzhhphhmhfnh
+1-5 t: ktrtv
+6-11 c: kfccccdcccvxwc
+4-7 q: qrqqzcx
+4-7 z: wcxzjrlhfbnczdj
+7-14 k: mckkdnkrkpkknkdkckfz
+1-6 v: vvvvvbv
+2-6 p: gmpszppxppp
+3-16 k: ggxkknwkkjkqskzktgk
+15-17 z: zzxqmnclzxzfvznzb
+3-6 x: xxxxxpxxx
+17-19 q: stvktzjwzbrbfmbqjsq
+4-6 b: bbbsbbb
+9-10 p: spttdpplsppdprxrvpgm
+4-5 w: wwwwn
+10-16 r: grnjxrwrrrzdrpmjtrrr
+14-15 q: qqkqqqqgqqtqqqrqhq
+4-8 q: qqqqzkzsqq
+10-16 m: mmmmmmmmmwnmmmmmmmmm
+5-10 h: hhhhzhhhhhhh
+5-11 p: mkpphppzhwqpgpsqcshz
+2-4 l: nnllsl
+2-8 q: bqjtjmfqsqgcjvgf
+2-3 w: wwsw
+12-16 s: lmsjpgzfldmrhrmf
+4-6 n: gnnnnv
+9-12 s: xmwssfsssssnssxwds
+2-4 h: vzfh
+1-2 n: ngdp
+4-7 q: sqqnhqqsvqqq
+5-6 k: zvkdkldkg
+11-12 w: wwwwwwxwwwkw
+7-11 p: hgbsfjpmbkz
+1-4 v: rwqvv
+4-6 s: pssssss
+7-10 m: mlmmmmmmmrmmx
+1-2 n: hnmqzsn
+11-12 n: nnnrnnnnnnnbn
+1-2 k: qbxhwswsxzkdsxcbtwrw
+13-15 n: nnnsnnnnnnnntnc
+17-20 n: nnnnnxtnnnnnvnndjnnn
+2-17 n: npnnnnnnnnnnnnnnnnn
+6-13 t: ttkrxzdkttltszskt
+10-15 k: mkfllgkdnvjptdh
+6-9 m: mmmmmjmmm
+14-15 w: wwxwwnwwwwzwwkgqkwww
+2-10 k: zmgrvrzlmkgcddcrxk
+12-14 c: cccczccccccjcjcccc
+11-15 m: mmmmdmmmmmmmmmqm
+18-19 r: rrrrrrrrrbrrrrrrrxbr
+6-10 b: hnbnbblvpd
+10-12 x: pwpxxqnxxxxxxvzcxx
+3-4 n: nnnpj
+4-6 n: nnnwnnjn
+3-4 k: kkmk
+12-14 j: jmjjjjjcjjjlwjjdj
+3-4 q: gqqxq
+7-10 z: zzcztxzzzzzx
+2-14 q: cqnqbvqsglczhb
+3-6 r: mrrhrn
+14-15 z: gzdzdszdkrfzzgpp
+4-10 j: jjjjjjjjjbj
+3-7 w: vrwwwwhwwkw
+6-8 s: shswpbjss
+2-4 h: ghvnhh
+3-8 m: mmmmxmmvm
+5-6 g: ggxgxg
+1-2 v: vzvv
+2-7 r: qgmgrxrgrgv
+5-15 z: zzzzbzzzzzzzzzz
+3-10 t: tttttdtttwtl
+1-4 w: kwws
+1-3 h: crxhhkhc
+5-6 f: nfffnttvfcm
+9-15 d: ddddpdqddmdjddz
+7-8 c: mjfqkmclzphkcnjrg
+4-7 l: lcblmnlpltgbnsjll
+5-8 v: rvcvvvvbvv
+3-4 b: kbblb
+12-17 v: vvzvvvdrvvvvvctspvnz
+4-9 d: dddsdddddddddsd
+6-7 s: shvgwsspmsnr
+5-10 k: dghtgjbkkk
+1-5 m: mmmcsxm
+1-3 q: bvqqk
+7-9 c: wccsccxcfkvvkctzc
+5-6 k: jdkkcqkkg
+5-8 g: tgggqpzfgfg
+19-20 t: ttttttttttttttttttth
+1-9 n: dhmnnqnnnpnnr
+4-7 w: fwmwwrz
+1-3 p: qcnppb
+1-14 f: jtrcqftxkxfmxffffhf
+10-11 z: zzpzzzzzzkzzz
+13-15 h: phhhfhhhhlhhbhhhh
+10-12 t: tttttttttmtt
+6-9 s: psssxsscssss
+3-4 p: ppbgp
+11-15 b: lpjbbbpbbbrhbbbb
+9-10 c: cchccccccl
+3-9 t: wtltcrnvtmgtf
+10-13 g: rkgggkfvcgktrhx
+16-18 k: kkkkkkkzkkkkkkkfkk
+3-8 q: txxqqjbqqd
+7-16 j: gjgxwjjwjwvhjkqvr
+4-12 t: xttzrmdtjvttcn
+3-5 c: lcvcczsjd
+14-16 n: nnnnnnnrmnnnnnnpn
+4-9 c: cccfrpclcc
+13-14 l: klllllllllllll
+2-5 l: rlxvflqllllvsm
+9-10 h: rhbhhhhhrhh
+3-4 p: pftpp
+1-3 z: zwbjlzpwldx
+12-16 s: sbqwfmsstlsqbsws
+8-9 g: gtqggjqgn
+4-14 w: twwtwwwwgvwwwwswpwr
+14-15 x: xxxxxqxxvxxxpxhxxx
+11-12 c: ccdccccxccclmcccc
+8-10 w: wwwwwwwrwwwwwww
+1-4 f: fffqfpffff
+3-4 p: pppq
+3-8 l: dglblkmlllklxqsl
+2-4 k: wkskqwkccrtv
+10-11 l: lllllllllsl
+6-11 b: qkgjbcqqhbqxw
+1-3 q: qvqpp
+10-14 d: xzhdlcwkqqzzbdtf
+14-15 f: ffffffffffffftq
+7-8 q: qqqqfqqdrqqh
+4-9 h: ljfhrhhmbr
+11-13 r: rrrrwrrrrkrhh
+7-10 z: zzzzzznkzb
+3-5 n: kvtnn
+1-3 g: ggng
+5-8 g: gggggggg
+2-9 c: csnczjctbcmcccc
+11-12 n: jnnnnxfknnndnnfnr
+1-5 d: vdmddddd
+7-8 z: zzzrztzmz
+6-8 z: zbzzsmzzjm
+1-2 r: trrrcn
+5-7 m: msmmxcm
+12-13 h: hnvhztwhhpwhqkf
+10-11 t: wprthmcttqtt
+4-6 r: tttrssfrrbxjrzgr
+3-5 r: zrsnr
+8-12 z: zjqzzzxdzzzb
+16-17 x: gxxtswfpzxxpxbvxq
+4-5 h: hhhhg
+19-20 f: ffffffffffffffffffrf
+3-4 l: llbsq
+7-15 k: knkkkkfkkkkskkklkkkk
+3-6 q: qqpqqb
+7-9 t: ctztttttpjvt
+1-2 x: xmpx
+10-12 c: cctccdcchzcppctq
+6-7 s: lssnssxns
+4-13 m: wmngjsmtmmcjmdmm
+2-9 h: jhmdxgchltdgj
+12-13 c: hcjcrrlsgcccn
+7-10 t: tsbtzttzqj
+18-19 c: sccccccccccccccccczc
+3-4 g: ggghw
+7-12 p: vdlpjjpvmrmpskp
+8-10 v: hqwvvtvvtvvvvjv
+2-4 k: nkgv
+1-3 h: hhxmhn
+11-13 d: ddddddddddcddd
+7-19 g: ggggmgggggggggggbsmm
+5-13 k: kbkkkkmkwblkdf
+1-2 j: jjjzjjjjwjjjj
+6-10 g: gfsggjgggnl
+2-3 s: cskcs
+3-11 m: mjvqhbhjgqmq
+1-11 q: qdwqqqbqjmzmdhxl
+2-12 k: kkkkkkjwkkkckkzr
+9-12 v: vvvvvvvvsvvv
+3-4 r: rjmxr
+2-7 k: kkpvkkr
+3-4 h: hnzhhhsvfbswzxkslt
+3-4 n: qbnmhhnhdchbnnvk
+1-8 v: vvvvvvvv
+3-4 j: jjmjj
+9-18 f: ffffffffzffffffffff
+4-6 f: qgfjffbfj
+1-3 m: mmmmmtmmzm
+2-5 d: qdddf
+4-5 w: wwswbkwjcw
+5-9 g: jvhgwlllgvxrfg
+1-2 p: fhvmh
+15-20 m: mmkmmmmmcmmmmmmnncmc
+13-16 l: llncvllllllllllglz
+16-17 l: llblllllkllllllndlgl
+5-8 s: ssstwvsts
+1-2 d: rddddldxdsrtddd
+6-7 d: dddkdpdddd
+4-5 w: wcwgw
+9-11 r: lrfsrhrxqrrnrjggr
+1-9 w: pxpfwbmxwdgvbhzlt
+11-14 q: lhnlmdssgvqqskr
+8-13 x: vtcxxmxswxmxd
+5-13 r: sbpdrpgbvdrrrx
+1-5 m: bmmmm
+1-2 m: fmmsrft
+2-6 v: pvvrvb
+6-7 s: sssssksf
+3-4 c: zclc
+11-17 q: qqqqqqtqgqqqqqqqmq
+1-6 j: jjgcrlm
+3-4 n: sfnn
+12-13 p: bppppppppppmkp
+6-7 q: dtgqtqqlqqqqsq
+5-6 v: vvvvqvv
+7-8 d: ddwddbjdd
+11-16 m: mmmmmtmmmmmmmmmfm
+18-19 v: vvvvvvvfvvvvvvvvvvr
+1-2 j: jljjj
+3-9 r: rrrzrnrsdrrr
+7-10 w: twslbwxwbwwwwww
+9-11 v: rpvvzvxvvvzvvv
+3-5 d: zzvtdt
+7-11 p: prldqxjtpnppx
+1-10 z: lzzzbcfgzz
+11-14 h: hhhhhshhhhhhmph
+6-12 v: sfbvvwvvjvkvvvd
+8-10 f: fffhfffffnc
+7-8 g: gqjgfwfggghggh
+8-9 x: zgxxxxmhxxxx
+12-13 z: zzzzzmnbzzzzgzzzr
+2-3 c: cvcsccfg
+3-4 s: ssws
+5-8 c: cccwcccp
+4-6 c: ccccdlxcc
+5-8 l: prlzlxcccl
+1-4 g: qlng
+8-12 c: ccccccckcccccccccc
+2-8 d: ddpddqjhbbr
+13-15 j: jjjjjjvjjjwjjjqjj
+5-8 x: xxwxcxcnxxxxfx
+4-6 t: dtfbctcgtzrtntw
+5-12 r: rrkdrrrdrrrx
+6-7 h: rhbghkhchjmbkhhm
+7-9 z: zzdzzgzpz
+4-5 v: lvnmq
+1-6 w: wwwwwwjw
+14-16 n: hpnnnnnnvnxnnnnlnn
+18-20 r: ftrrzrsrrrgsrzhwrbrr
+12-13 s: ssfbssssssssws
+2-9 g: gfvcgzgjb
+2-4 n: nntqtn
+4-5 h: vqzhzhrxhh
+4-5 g: ggqkg
+1-2 x: xzkx
+7-11 j: jjdjjmddlrjgjjjqzls
+1-3 v: vvvctbv
+4-7 s: fwmsssdss
+10-11 p: pppppppppbppp
+13-14 q: qqqqqqcqqnzqzqqqqqt
+7-14 z: rhzzwqmzzzzxzzzzcgz
+8-9 b: bgbsbbbbwbsbblbcr
+7-8 h: hhhhhhghkh
+1-2 g: ngct
+13-15 f: fffffffffffvmfg
+4-7 h: mdghhfs
+12-14 z: xzjzzzzvzzzgzz
+3-4 p: ppsp
+18-19 q: wqkqxtkfhlmrxndwsqcc
+5-14 p: ppppbppprnprwpwpp
+3-4 j: jjjcjj
+2-3 b: blbn
+4-6 g: grggvcgg
+2-4 h: hghhh
+4-6 f: fffffm
+2-4 n: qsdnxt
+2-5 q: qqqqqq
+9-12 w: whlqgwcrqxwwrvw
+6-7 z: zzzzztqzz
+7-10 l: slnzmdlslsrc
+4-8 q: jqqqjqqltd
+5-6 h: xjzbdbsfjfrxhxqlbbrt
+6-12 w: wwwlbvwwwwwwww
+2-5 c: zcpcf
+4-5 h: hhhmh
+16-17 h: hhhhhjhhhhhhhhhgh
+12-13 f: fffffffffffmk
+4-5 d: dddgd
+4-10 p: xppvfpsgpphcpppml
+3-5 w: wwtwwj
+7-10 w: twwwwgtwjwjwww
+5-10 z: zzzzzzzzzgzzz
+13-14 t: sjxsttgttttbqtthtbd
+6-8 c: ccccmdrcct
+2-4 v: vcxm
+3-7 k: dkkzfwzkn
+4-7 v: cjrvvxtsvvvv
+11-15 s: ssssssssssrssss
+1-8 j: jskfjjjj
+2-3 p: pgnpn
+4-5 p: psplppc
+1-3 n: nnnn
+11-12 x: xxxxmxxxxxzxxdrqx
+1-4 k: kpln
+6-10 p: pphppppppkp
+2-4 v: cgxvvxkzvs
+6-7 m: mmmvbmmjsrmtzkddzmxm
+5-9 s: xcshstsdslsxms
+1-17 m: vmjmmmmmgmmmmmbmst
+2-3 g: ghgg
+5-6 k: kkkkmkh
+5-6 c: lccfcccsgc
+4-6 n: nncnbnmznngnj
+8-11 j: ljffjmrjmjm
+4-9 j: rqxjwfsrfzbxjjmnflj
+3-6 s: zscszpss
+3-4 d: qldtdht
+15-17 x: xmxxxxxxxxxxxxdxx
+1-4 m: mmmmmmm
+2-9 v: vvvvnvzsvv
+3-4 n: nndn
+9-13 s: crxnbslshlbgsh
+1-10 c: cczkccchfc
+3-5 d: dddddwv
+7-9 n: hqrhnxnzfnkqnvnnnng
+3-4 c: cwcvfdc
+6-8 l: llllllltl
+4-6 q: qqqqqm
+1-5 x: xhmxxxtwxdxkk
+5-17 f: gffrffffmffcbmfffff
+15-16 x: xxxxxxxxxxxxxxcl
+3-7 z: nmjzzdzz
+9-12 v: vzvxvxvwpvvvvvcvxpmv
+4-6 w: wtwwwm
+3-12 d: dddddzdddgdw
+2-4 p: pqpk
+2-4 g: pqqgbwqzsjtcrmg
+3-5 d: xdhsdpndjhd
+9-11 t: ttbtttttqtt
+2-11 d: kddwtcwxgkclxcnfgm
+1-4 v: hgvvfvjvz
+4-5 s: ssssm
+2-11 g: gmggvgggggn
+3-6 c: ccrccvr
+1-4 n: nznfnn
+1-4 f: sfxffff
+17-18 q: qqqqqqqqqqqqqqqxhq
+2-5 l: zllhn
+7-10 v: cvcvvvvvvqxbv
+9-13 l: lllgllllllllql
+3-11 g: mlgwrbcsdflzm
+4-5 t: gtbtcfqrxfxtjptgpqr
+5-8 d: gfdzjkvd
+4-5 f: ftfff
+15-17 p: pppppppppppkjpppft
+1-3 d: tcdd
+3-12 n: tnxnnbshnndnnhbn
+5-8 q: pqlkptqqqcqbqrr
+8-9 l: lllllkllb
+10-13 j: rsfjlxjtfjrkxn
+8-9 w: wmzvwwwwdwzwwt
+12-14 w: wwwwwwwwwwwwwm
+6-7 g: qwggfqgnvrggg
+15-16 x: xxmxxqrlgnfxxsxr
+4-8 n: gnnlnnlncnrnnqnwncd
+8-11 k: kkkkpknzdkkck
+4-5 m: mmmsm
+3-4 n: nnxn
+7-11 c: cckcdzcjldcwfcr
+12-14 j: wxvjvpjjjpjkjj
+1-13 h: fhhcfzhhhhhhhh
+11-12 p: pppppwfpppspp
+3-4 t: tktptt
+1-6 n: nnnnnfnn
+6-15 l: lllllmwlllllllll
+5-6 q: qqqqqdqlqqq
+4-8 j: bjjxhjjd
+2-9 w: tdwpwdkcw
+6-8 l: llllltbr
+13-14 f: fffffffffffffj
+4-11 z: wxzkzzzzzzzt
+7-11 w: wwkvcfwfsrcw
+4-9 b: bzbjgbbbb
+17-18 k: kkkkkbmkdkmckkvbkk
+5-6 j: ngffrjspcz
+16-18 q: qqvqqqqqqqqqqqqhqqqb
+12-15 s: sszszstsgsssssdssssq
+5-6 d: dddddg
+4-8 s: ssssvnss
+16-19 g: lgzswgbfwghgggnglqg
+8-9 t: tttttttltttt
+14-20 b: bvbbjjbbbwttbbblbbbp
+4-7 c: cxcdhmm
+1-11 g: gkvjfgjlggpjb
+1-2 w: whmwwcwqgw
+6-16 p: lgwrlppdfpxbltmqlp
+4-7 r: rwrrhhrqgrr
+12-15 j: jjjjjjjjjtjnjjh
+3-5 k: kkkkkkkk
+7-9 p: wpxpphfpp
+2-3 z: zfzz
+2-3 k: nbsdwkqktssd
+7-12 g: gggggpnpdssgwggx
+6-8 r: frrrrjrr
+1-7 l: llllllll
+11-16 x: bxxsqxxxxxxktxxz
+3-5 n: nwbknpnnvnr
+8-9 t: qtttfvttqnttttmtttdv
+3-4 d: dfgk
+5-7 f: ffwffff
+9-10 c: cccccccpgr
+3-4 q: qqpq
+1-2 k: kmwvdkzwxlkk
+1-8 s: sssljrsmsx
+12-13 r: rsrrrbrnrhrrhrprrrrn
+4-16 w: kfqncxdmjlwkfjmwhw
+9-13 l: llllllllpllllll
+2-4 m: mlmmdbbqqmgkcffxw
+2-12 j: jjjjpjjjjjjrj
+9-11 x: qxxdxxxxxxqx
+2-6 v: svcsfvrfpbxpmvtscqjg
+2-12 c: dctwqfthcdbcsklb
+1-2 c: zcfrlczcpxcm
+2-8 s: nspkfsvbfsw
+5-10 m: dxvwmqmngmzd
+2-3 w: twsxwvwzw
+5-10 c: cccccccpcxrc
+8-16 j: jjjjjjjmjjjjjjjjjj
+8-16 p: ppppsppdpphppdxp
+16-18 t: tttttttttttttttttcs
+11-13 j: jjjjhjjjjbjgjjj
+14-15 d: ddddddddddddddwdd
+1-15 s: psgssjszssbssdsgds
+14-16 z: zzzzzzzzzzzzzrzqz
+8-10 v: vvvpvvvvvg
+4-5 z: zzkzf
+3-9 g: ggggggggfg
+1-4 n: ckwcnhz
+7-9 w: ckwwwwjwq
+5-12 q: qbqwcqbvvxbq
+4-10 x: xvxxxghnrk
+2-3 d: pdpmdkvsmccpnp
+3-11 f: lffffjfmzqplsfzfl
+9-10 h: hhhhhhhhhk
+1-4 x: bxxxxxmxx
+10-13 t: rnnglkrgbrrwtqjmlbn
+5-17 v: zfmxkbtjpvvvqdxcvvnv
+9-10 j: kjkzjlnjjjjjjjj
+13-15 g: gggggggggggwxsg
+2-7 l: llhrxjl
+5-6 s: hfszgwczxtsp
+1-10 v: dqqvhttqqv
+10-13 z: zctbpzzzzzpzdznzz
+6-10 p: mpplqpppfhhqptphp
+2-5 w: wwgbw
+1-4 b: sbbbbb
+6-15 z: hpzlzzzzzpzzzgdzzlzn
+2-4 r: rhfrdqrxsb
+6-16 s: crrtqsjqfssssgsssc
+17-18 h: hhhhhhhhhhhhhhhnrh
+6-8 f: xpgdffbblxxl
+2-4 h: wzfmhhl
+5-6 k: jkkkhk
+8-9 c: ccccccccc
+16-17 t: tttwttdtttttttvkttt
+9-10 f: fffffffffh
+6-10 l: zxclbtlsjlbls
+2-6 m: mmjmms
+8-11 r: rrrrrrxtrrrsqr
+1-11 v: gcvxfvdkvvs
+9-12 c: xgcjrmscgjmjfsdxcp
+10-11 g: gggggjggggdg
+5-7 s: ssssprssm
+2-3 c: nzccfjcdxc
+9-13 k: mdhkkgkkkkxkkvrkkk
+6-7 s: sssssbsssk
+12-19 n: xtlfpnxflxwblnjsnxnq
+3-4 t: tdtltttlp
+2-4 g: gggg
+11-12 k: kkkkkklkkmmk
+2-6 r: rsrrrrrl
+3-4 r: rrzq
+12-14 l: lllllplllklmlrd
+2-3 d: dkdd
+1-2 t: vttt
+7-14 l: lmdkltvllhsnllnl
+6-7 s: scssxssrsqfsjrcgdsb
+5-6 d: tndddgrv
+1-3 t: jhvtckvptnp
+14-15 g: ggggbggzqggggdvgg
+2-5 t: tvttt
+4-9 f: hfsmksgnfh
+6-14 k: kkkkkkkkkkkkkskk
+6-7 w: wwwwwwxwcc
+5-9 n: bnsvnnnqtpncn
+5-7 v: vvjvfvvv
+7-8 d: ddddddxd
+13-14 b: bbbbbbbbbbbblf
+1-4 l: lllml
+9-12 p: ppppgppgpppwpdp
+4-11 p: rpjpprbztgkxx
+4-7 g: ggggzgtg
+2-3 j: ncjjk
+14-15 v: vvvvvvvvvvvvvvfv
+9-10 l: llxllllhlzlsb
+13-14 p: ppnppppppppppz
+5-11 j: jjjvhjkjjjjzj
+14-20 b: dbbbbbbbbzbbbbbbbbgc
+5-6 m: mmdzzjmm
+3-4 t: ttft
+5-6 m: mmmmrmpmmmm
+15-17 v: qhjrfvvbvplvvvvvq
+1-15 t: gctmcdxttttvvtt
+4-5 v: pfvcvcvrvv
+13-14 n: nnnnnnnnnbnnknn
+7-9 h: hhhhhhhhh
+1-2 f: fhffgj
+1-12 b: bbbbbbbbdbbk
+6-7 n: nnnnnng
+13-18 f: fffffffffffffffffs
+11-14 b: bbbbbbbbbbbvbfb
+10-12 h: hhhhhhhhhwhq
+7-8 w: wwcwqcwwwpwbww
+1-5 m: fmmmjmm
+14-15 v: vvvhvvvvvvvvvvf
+12-17 b: bbvbbbsblwbbbbbxf
+1-5 w: stwwj
+6-10 j: jjjjjgjjjj
+1-4 l: zvcjqgqrvvfndlj
+5-7 s: tswsgws
+1-13 v: zfwvvvvpvvvvmvvvvvjv
+1-3 j: rjjvpkknmmjmxpqrmx
+5-8 s: mxgsrsssbstb
+5-14 q: qqqqqqmtjqqqqqqc
+1-7 s: sswdxsnbkj
+5-9 d: ldnbdmrtv
+7-8 w: wwwwwwww
+7-8 g: gxggggpg
+8-12 r: rrrrrrrrrrrkrr
+2-5 n: nnbnsmpml
+2-3 g: gsggggggg
+9-11 s: kssssssssxns
+15-16 m: bhsxvbrjhfzmmflm
+4-7 h: wmhhhhzh
+2-13 g: khdgzvpxgrcvgc
+5-13 n: wnnnnslnnnnnjt
+3-7 t: ttsptkgttt
+1-7 m: ffqtfmm
+8-12 p: pplppppspjpppq
+17-18 r: rrrprrrrgrrrrxrrrzrr
+3-4 f: ffzff
+10-11 x: xxxxxxxxxxw
+10-11 b: bbhbbbbwbbbbbd
+7-16 b: htbbxcbsbtjgxdvjcbc
+9-12 g: gggxggggsgvgqg
+13-15 l: dgllcqgtslfvkwlb
+10-11 f: fffvfffffffff
+2-6 d: ddqtnb
+3-11 m: mmmmsvqmmmcxkmm
+15-16 f: fffgffffffffkffqff
+3-4 s: hvgssssb
+4-5 s: jslss
+10-19 v: vvvvvvvvnvvvvvvvvvg
+1-3 c: cmcqkckzzsczn
+2-3 j: jjhm
+10-11 j: jjjjmvjjjxkjj
+2-3 r: rqrrtztrbpk
+6-7 d: dddddrd
+6-16 n: dzqnnsnmssnjznnnnnv
+7-11 f: ffqrffhfffftfffff
+2-8 z: zzzzkzddzzb
+2-7 j: nhjjjjjhjs
+7-10 l: xlltwhllrd
+10-12 w: nwrsqlwhqkcl
+15-16 w: wwwwwwwwwwwwwwwl
+11-12 h: hhhhhhhhphmh
+1-6 v: czvvwkgbvmjxvvgv
+3-14 p: pppppppppqpppxpppprp
+2-6 d: ddqrdnddddddddnddd
+8-18 j: gjghwxsjfpcfqmjxqjc
+5-11 g: ftggkgggbvsggb
+1-4 q: bqqqqqqqqqqz
+1-12 x: bgxxxxxmxxxx
+3-5 l: lllll
+3-7 c: zwccrrnfw
+3-4 q: sqdqsr
+3-4 g: gggv
+9-10 h: wnpkttckhh
+3-4 t: ttgp
+3-6 g: glcgtgg
+5-6 w: wwxxnwmpgkppwnwwj
+3-4 f: ffzf
+5-7 z: zdzzfvv
+4-6 p: ppmprgpmcdkcp
+11-12 m: mmmmmmmmmmcm
+2-7 z: zzzzwzz
+7-8 m: mmmmmmms
+4-15 z: zcsnzzfczzmczdzjdzz
+6-7 k: rkrlklk
+7-8 v: dtklkrqhv
+4-5 x: wprlxxhxbjsfx
+4-7 j: cvrjjbxxjfwjjjd
+1-2 g: ggsb
+5-7 k: kkrfgvkqxk
+3-5 q: qqpqq
+7-12 c: cccccxmncnvzbcc
+2-6 h: mhlhgl
+7-8 l: lllllzllbfl
+1-6 f: xnfssk
+12-13 d: dddddddddddgd
+3-7 p: ppkppppg
+8-11 j: mjfwjzfpjgjtnnqh
+9-10 c: qtjcccccjcfclscc
+10-12 b: bbbbbbpbbbbbcb
+1-3 p: rfppppc
+2-5 j: wjjbkbm
+14-15 k: zkkkkkkkkkkkkvk
+4-10 v: jkjslhtdvvtprslsr
+4-10 s: sklrpnszsswls
+8-11 k: dktkkkkkkkzkktq
+10-16 v: rndbqtdxwtkvhvgvhkg
+1-3 w: swwm
+7-8 z: zzpzbzjzz
+2-17 f: hfxrbqffmfdrzfzgsvmq
+1-4 c: cqclc
+5-10 x: xzxxxxxxkx
+1-3 x: xdspcrljk
+13-14 g: kwwbqcmwfwhrgzlg
+7-10 z: xpsxjczspcflhbjk
+6-12 m: sxgpgmbdmvksfpmqcjx
+9-11 c: ccncctcfcvpccxc
+9-11 t: ttxttttwttb
+2-13 x: xxdvxmxxxnxxzx
+17-18 n: nncnnnnnnnnnnnrnvn
+5-12 j: jpjzjpjjjsphjtj
+9-14 n: znnnnnnnnnnvsnnn
+3-4 v: vfdvxwlv
+2-18 w: mwfpnzwlvwmxgsprvhp
+11-13 b: bblbbbbbbbcbbrlc
+1-12 l: llllllrlhspdl
+4-6 p: pphhpp
+5-7 r: rffrwrrqzrzcv
+7-10 z: hfzzzzzzzz
+17-18 q: qqqqqqqqlqqqqqbqqqq
+9-14 s: ssstsjssbsgsss
+12-16 w: wwwwwwwwwwwwwwwgw
+1-4 h: bhhh
+1-2 g: ggggqggrn
+10-12 p: dzpzvvwppphfpl
+3-4 w: wnwp
+2-17 k: pdkknkhkskhndkvkkgwk
+10-13 w: wwwwwwwwzwwwnzw
+5-6 t: crrgctktdmtttldhdlmt
+9-11 h: hhhhhhhhthchhhhh
+2-4 k: jktxzmhhmxjmtkkbphpk
+6-9 g: ggggghggqg
+1-5 j: xjjcj
+1-5 p: xpwnp
+1-11 q: qqqqjqhqqjf
+8-16 p: pppppppnppkpppch
+1-3 k: kkkk
+4-11 s: sssbsslswss
+6-10 s: sfkssshksrsq
+2-4 v: mnvv
+5-6 l: llllllllllll
+3-5 n: nznnn
+4-5 l: nllzwml
+3-5 w: rwwqv
+4-6 x: xxbxvwxdxgbxgx
+10-16 w: wwwwswwwwwwwwwlwqw
+10-12 d: dddddddddddfd
+7-9 q: qwlqzqqsvqq
+5-7 p: fpzpkplppp
+4-11 n: xfnxfjhxvxnnzc
+3-4 x: qfxx
+18-19 g: gggqggdggggggggggmgg
+13-15 c: cccccccccccczcc
+11-12 v: qvvnvvvzcvhtvctvtb
+3-15 d: dpdgmdnfsdbgdddbdmcd
+9-13 j: jjjjcjjprjjjjj
+3-9 t: qtvttxtxtngnhdt
+12-13 d: ddddddddzdddcv
+4-8 h: hhhhhhhbhh
+2-3 x: xrxc
+2-10 l: lmlllllllll
+7-8 d: dddddddrdd
+11-13 c: ccccccccccccd
+1-3 p: pzppmvp
+4-8 b: bjbbvbbzbbbbbqbxxf
+4-5 p: hcprp
+5-9 m: mmmmvmgmmmmj
+2-8 z: zzfzxjfz
+16-17 z: kzzrdzzzwzzzzzzznzzz
+3-4 d: gddsd
+1-9 m: mmkmxmmmjh
+14-15 f: fffffffffffsfqff
+10-11 w: wwwwwwwwwhw
+5-6 q: nqcqqspqq
+2-4 b: bbbj
+8-9 l: llvnqlllwsll
+6-7 t: wttttttt
+9-10 n: nnhnnnnnjnn
+1-2 g: gdgg
+7-8 v: vmvvvvvxv
+8-13 v: vvvvvvvwgvvvvx
+6-7 m: smmfjfmscmpmmp
+3-5 m: mmhbmm
+3-4 t: tttft
+5-12 l: xslklnmkpmbl
+19-20 h: hhhhhhhhhhhhhhhhhhht
+4-8 f: ffffffhlf
+1-3 k: khkg
+15-16 s: sssssssssssssssb
+7-10 j: jzjjjjjjjw
+5-7 w: bszqxhws
+7-8 l: tknllgzl
+10-12 g: gggggggggmggg
+2-4 s: sgns
+11-17 h: bqrhkhhhjhswbhzhkhh
+8-15 d: gdddhdddddgjddddwdd
+8-12 s: gssbjtdsssjtsw
+1-3 p: pfppp
+2-4 t: tttw
+5-10 w: zzcwwwwwwkwwwqws
+1-7 c: ccrmhdchwbr
+7-11 g: xzgnggggrggrg

+ 30 - 0
aoc2020/2nd/main.jl

@@ -0,0 +1,30 @@
+using DelimitedFiles
+selfdir = joinpath(@__DIR__, "input")
+input = readdlm(selfdir)
+
+amount =
+    [map(x -> parse(Int, x), (x, y)) for (x, y) in [split(x, "-") for x in input[:, 1]]]
+
+function valid_passwords()
+    valid = 0
+    for (amount, key, password) in zip(amount, first.(input[:, 2]), input[:, 3])
+        count = sum([1 for x in password if x == key])
+        if amount[1] <= count <= amount[2]
+            valid += 1
+        end
+    end
+    return valid
+end
+
+function valid_passwords2()
+    valid = 0
+    for (amount, key, password) in zip(amount, first.(input[:, 2]), input[:, 3])
+        if (password[amount[1]] == key) ⊻ (password[amount[2]] == key)
+            valid += 1
+        end
+    end
+    return valid
+end
+
+valid = valid_passwords()
+valid2 = valid_passwords2()

+ 323 - 0
aoc2020/3rd/input

@@ -0,0 +1,323 @@
+.............#...#....#.....##.
+.#...##.........#.#.........#.#
+.....##......#.......#.........
+.......#...........#.#.........
+#...........#...#..#.#......#..
+.........##....#.#...#.........
+.....#.........#.#...........#.
+....#...............##....##...
+#.#.............#..#.......#.#.
+...#...........................
+......#..#....#.............#..
+........#......#.......#.......
+....#.....#..#.#...#.........#.
+..#.#.......#.##...#....#.....#
+...........#.........#..#......
+#...........#.#..#...#.#.#....#
+........#......................
+....#.#.....#....#.......#..#..
+.............................#.
+....##..........#.....##......#
+......#.....................#..
+..#.....##.......#.............
+....#.#..............#.#.......
+..#.#........#.....#..##.......
+.....#...##.........##....#.#..
+.#....#..#..#...........#......
+.............#.....##........#.
+..#....#............#.........#
+###..........#........#.......#
+#...#..#.#.#.........#..#......
+..#....#......#.............#..
+#...#........#..#...#.....#....
+.#..........#.#........#.......
+#.....#.........#..#......#....
+....#....##........#......#....
+.......#....#.....#..#..#.....#
+.........#...#.#...#.##........
+.##.##...........#..##..#......
+.#.##....#........#...#........
+.......##.........##.####.....#
+....#..##....#.................
+.#........#..........#.........
+##....##..........##........#..
+#......#...........#....#..#...
+.......#..#....##..##.....#....
+.........#.#.#...#.....#.......
+......#...#...#....#......#....
+##....#..........#....##....##.
+###.........#...#...#..........
+#.....##.#........#.......#....
+#...............#...##.#......#
+..#.....####.###......#......#.
+....#.......#..........#.......
+....##..............#.#.#......
+.......##..#.......#...........
+..#.......##....#.......###...#
+........#...#.......#.#...#....
+.........##....#..#....#.......
+............#.#.......#.#......
+.....#.....#...#....#.##.......
+.......#.........#.......#.....
+.#..#...#.....#............#.##
+.......#.#......##.............
+##.#......#.....#.#............
+.#....#.....#............#...#.
+.........#.......#.#...........
+#............#.##...#..#...#.#.
+......#....#.......#....#......
+..........#........#..#.#......
+#..##.......#.........#..#.....
+.........#.....##........#.#..#
+..#................#...........
+....#..#........##.........#..#
+###...#....##.#......##.......#
+.......#......##..#.......#....
+.......###...#...#..........##.
+................#.......#......
+.#......##.##........#.........
+....##.#.....##.......#........
+...........#...........#.....#.
+..#........#..#.#...#.#........
+#...............#...#.##.##.#.#
+................#.......#......
+.#..#......#........#.#........
+...##..#.......#.......#..#....
+.#.....#.#....##..#........#...
+........##......#..........#...
+.#.......#.......#...#..#......
+.#..##.....#....#............#.
+...#..........#....#........#..
+..#.#..#.......#.#.##..........
+#........###.....#.#.......#.##
+.....#....##.............#.#..#
+..##............#...##.........
+...#.........#...........#.....
+...#......#.#...#..###.........
+.............#...##............
+.....##..##.####.#..#......#.#.
+.#...#.....#.....#.#.....#.....
+.........#.......###.....#..##.
+.##.#..#..........#.##.#.#.....
+.#...#...#.#.##......#..#......
+.............#......#......#...
+#.....................#......#.
+...#.....#.....#....#........#.
+................##..#....#..#..
+#.###...#.....................#
+...#..#....#.......#.........#.
+...........#..#..#...........#.
+.......#..#......#....#.#......
+..........#......#..#....#.....
+.#.#.....#...#.#...#...#.#....#
+.....#.......#............#...#
+#.#....#......#......#........#
+.#.#..#.........##...#.........
+#..###..#......................
+..#.#..#.......................
+.##.....#...#......#..#........
+...#...........#...#.......##..
+..#...........#........#.......
+........#....#.....#.#.........
+..........#...........#.....#..
+......#...#...##.#.............
+.#...#...##....................
+............###.........#......
+.#.#...................#..#....
+....#.#...#.#........#.#.......
+....#...#...........#.......#.#
+...........#............#...##.
+.....####....#.#......#.#......
+.##.............#............#.
+......#.........#............##
+#.#....#...##....#.......#....#
+.....#.#....#..#..#...#..#.#..#
+.........................#.....
+......#.#....###.......#....#..
+.....................##.#...#.#
+..#.....#.#.#...#...#..........
+........#..##........#...#...#.
+..........#.#.##....#....##....
+.............#..#..............
+..#.##..#.......#...#..#..##..#
+..#..#....#.#..........#..#....
+..........#....#...#......#....
+.##...#.......................#
+.#.....#....#..........#.......
+...........#..#......##.....#..
+......###.#..##....#...#.##....
+.......#..#.#....#.............
+...#..#......##.........###.#..
+...........#............##...#.
+...#...#...........##.....#....
+..................#............
+.#.#.#...#..............#..##..
+#.#....#........#.........#.##.
+#.#.#.......#.....#..........#.
+...##.....##.#.....#...........
+.#....#..............##...##..#
+........##.....................
+#..#..#.....###.............#..
+.......#...........#...........
+.........#.....................
+.......#...#...#.....##........
+......#.........#........#.....
+...#....##..#.####.#.......#.#.
+.....#..#......#........#.##..#
+.##....#......##......#...###..
+..###.#........##.#...#.......#
+............#......##....#.#...
+.....#....##..##............##.
+......##....#.#...#....#.#..#.#
+.......#.........#.#.....#.#...
+.......#.#....#................
+.##...###..#.....#............#
+#.#......#.#..#..#.#...#..#..#.
+..#.#.#.....#............#...##
+.##....###.........#..#........
+.#..#.#..#.#....#.........##.#.
+....#..#...##.##........#......
+........#.#....##....#....#....
+.......#..#..#.#..............#
+#....#....#.....#....#.........
+.#.###...#....#.......#........
+.........#.#....##....#...#....
+....#.............#.....##.##..
+.....#.....#...##..#.#.##...##.
+.........#..#................##
+...##..##......#.....#........#
+.#....#.....#.#......#..###....
+#.....#..#.....................
+....#.#...#.#.................#
+.....##..................#.....
+#....##...#.##..###...#........
+##.#.........#.......#....#....
+.#.#.............##..#.##......
+...#.#..............#......#...
+.............#.........#.....#.
+#.......#........#......#.....#
+.....#..............#.##.#.....
+#......##...................#..
+##.#.....#..........#........#.
+#...........##...........#.....
+.#...#.....#..#..##....#.......
+.....#.........#....##.#.......
+#........#......#.............#
+.#..................####.#.....
+#...#......#....##...#.#..#..#.
+............#.#............#...
+............#........#.#..###..
+.#..#..#..#.#.#.....#.#........
+#.....#..#.#...#..#..#........#
+#................#....#..#.....
+....#..#..#.#......#.#..#.....#
+.#..#.......#...##.#.#.....#..#
+#.....................#.......#
+.............#.......#...#.....
+....#......#.........###.##....
+....#..#.......#.#........#....
+....#...#....#.#....#..........
+...#..#......#.............#...
+.......###.#.........#....#.#..
+..#.....##.....................
+.#.#...........#..##....#......
+..........##.#....#.#..........
+...........#.#..#.#..#.#.......
+..........#..#...#.....##......
+.....#.........#...#.#..#......
+#.#................#..........#
+...#.....##.#..#...#.##.......#
+.....##...........#............
+.....#...#...#...#.#.....#.....
+...........##..................
+.........#................#....
+......#.....#.#...#.......#....
+...#...#........#...#...#.#.#..
+...............##..#....##...#.
+...#.#...........##.......##..#
+...........#............#......
+.#....#.#.......##.#.#.#.......
+.....#.#..#.#.#................
+.#............#...#.#..........
+.....#.......#.#.......#.....#.
+#....#...........#...#....##...
+..#...#..##.....#....#..#......
+#.#.........#..#.#..#.#......#.
+................#......##......
+#........#..............#....#.
+........#..#.#........#..#..#..
+#..........#......#............
+..##.......#..#.......#....#...
+.#........#..#..#.#.......##...
+................#..............
+#.................#...........#
+##..#...................#....##
+#..#....#.....#.#..#.#.#......#
+#................#.#.#...#.....
+.............#..#...#..##...#.#
+#..................#...........
+..............#..#.....##.....#
+..#...............#.#..........
+.....#......#....#..#...#......
+.#......#...##.....###.....#...
+...##...##.##....#.#.#..#......
+....#.#.......#..##....#.##....
+...#.........#.#.....#...#...##
+.##.#.........##..#.##..#......
+.#...#......#......#.........#.
+.............#.................
+..........#..............#.....
+##...........#...#...###....#..
+....#...............#..........
+.......####.....#......#.......
+........#..........#..#........
+..#.......#..#.................
+......#.#..##...##....#........
+.##...#........#...#....#...#..
+.......................#.......
+.........##..#..#...#....##...#
+..#..#...#.....#.........#..#..
+.......#....#.........#...#..#.
+.............#.................
+.....##..#.....###....##.#.....
+....#.#..#..#.#.....##....#..#.
+......#..#..............#.##..#
+..#..#......#.#.........#..#...
+..........#.#..#....#.....#....
+.....................#.........
+...#.....#.......##..#.#.......
+.....#...#..........###....#.#.
+......#.....##............#...#
+.......#..........#.#..#...#..#
+#...#..#...........#..##..#....
+.#......#.......##.....#..#....
+...#..#....#.......##......#...
+........#.......##...#.......#.
+.....#........#................
+......#........#....#..........
+...#....#....###.........#.#...
+##..............#......#..#.#..
+.........##....#........#..#.#.
+.......#.##.#........#........#
+.....###..#..#...........#....#
+.......#....##.......#.#...#...
+#..............#.#....#..#...#.
+#..#....#..#.#............#..#.
+.#...##.#..................#...
+...#...............##.........#
+###..............#.#..#.#.#....
+.#......#.#.....##.......#.....
+...#.................#.#.......
+.#...#....#...#..#......#...#..
+...##....#........#.#.#..#.....
+..#.....#........#....#.#......
+...........#.#...#.............
+......#.....#.....#.........#..
+.#.##.###...#.##.......#.......
+.............#....#.......#....
+..............#...........#....
+.............#..#.#.....#....#.
+.......#........##...##..##....
+..##...#............#..#......#
+.............#...##.....#......
+.#...##..##.#.........#.##...#.

+ 24 - 0
aoc2020/3rd/main.jl

@@ -0,0 +1,24 @@
+forest_slope_array = open(joinpath(@__DIR__, "input")) |> readlines
+
+function encounter_trees_array(down, step)
+    trees = 0
+    position = 1
+    len = length(forest_slope_array[1])
+    for line in forest_slope_array[1:down:end]
+        trees += line[position] == '#' ? 1 : 0
+        position += step
+        position = position > len ? position % len : position
+    end
+    trees
+end
+
+println(encounter_trees_array(1, 3))
+
+product_trees =
+    encounter_trees_array(1, 1) *
+    encounter_trees_array(1, 3) *
+    encounter_trees_array(1, 5) *
+    encounter_trees_array(1, 7) *
+    encounter_trees_array(2, 1)
+
+println(product_trees)

+ 1169 - 0
aoc2020/4th/input

@@ -0,0 +1,1169 @@
+byr:2024 iyr:2016
+eyr:2034 ecl:zzz pid:985592671 hcl:033b48
+hgt:181 cid:166
+
+hgt:66cm
+pid:152cm
+hcl:cfb18a eyr:1947
+byr:2020 ecl:zzz iyr:2029
+
+ecl:gry hcl:#888785 eyr:2023 cid:63
+iyr:2019 hgt:177cm
+pid:656793259
+
+pid:#5e832a
+ecl:dne hcl:#7d3b0c byr:2018 eyr:1928 hgt:61cm iyr:1936 cid:241
+
+hcl:#888785 ecl:oth eyr:2025
+pid:597580472
+iyr:2017 hgt:187cm byr:1957 cid:247
+
+eyr:2029 cid:145 iyr:2026 pid:178cm hgt:162in ecl:gry
+hcl:#a5d09f byr:2002
+
+eyr:2024
+ecl:amb
+pid:349191561 iyr:2018 hgt:156cm byr:1972
+hcl:#341e13
+
+byr:1998 pid:408617933
+hcl:#fffffd hgt:193cm eyr:2021 ecl:brn iyr:2013
+
+eyr:1964 byr:2026
+hcl:#cfa07d hgt:154cm pid:175cm cid:85 iyr:2018 ecl:gmt
+
+hgt:161cm
+pid:021086946
+iyr:2020 ecl:blu eyr:2024
+byr:1921
+
+pid:173cm cid:235 eyr:1935 iyr:1952 ecl:utc byr:2015 hgt:187
+hcl:6239ed
+
+iyr:2015 hcl:#18171d pid:2691566700 ecl:gmt hgt:68cm eyr:2032 byr:2016
+cid:341
+
+hcl:#c0946f
+iyr:2010 pid:941290886 eyr:2023 ecl:brn
+hgt:190cm
+byr:1927
+
+pid:423210256 eyr:2026 iyr:2011 byr:1926 hcl:#efcc98
+ecl:grn
+hgt:185cm cid:135
+
+ecl:blu eyr:2030
+byr:1996 hgt:154cm iyr:2019 pid:809421142
+hcl:#b6652a
+cid:250
+
+hcl:39615c iyr:1934 byr:2009 pid:7752456272 hgt:191cm
+eyr:2024 ecl:#5b7a58
+
+iyr:1938 hgt:160in hcl:#623a2f eyr:2031
+ecl:grn pid:169cm byr:1964
+
+ecl:grt byr:2004 hcl:026249 hgt:176in iyr:1933 eyr:2023
+pid:176cm
+
+hgt:167cm
+pid:023312072 ecl:oth iyr:2018 hcl:#866857 eyr:2024 byr:1994
+
+hcl:#c0946f
+ecl:blu iyr:2016
+eyr:2023 hgt:193cm
+pid:190756361 byr:1943
+cid:306
+
+iyr:2013 hgt:179cm ecl:oth
+cid:290 eyr:2020 pid:953948851
+hcl:#6b5442
+byr:1973
+
+pid:795414848
+cid:51
+ecl:oth iyr:2020 hcl:#ceb3a1 eyr:2026 byr:1995 hgt:186cm
+
+iyr:2020
+byr:1993 hgt:159cm pid:905121332
+ecl:brn eyr:2023
+hcl:#341e13
+
+ecl:hzl iyr:2017 eyr:2020 hcl:z byr:2003 hgt:163
+
+eyr:2038
+cid:342 hgt:116 iyr:2019 hcl:73db63 byr:1973 ecl:gry pid:468207739
+
+pid:022772899 eyr:2040 hgt:181cm
+ecl:dne
+hcl:#866857
+byr:1931 iyr:2012
+
+pid:36127238 eyr:2038 cid:227 iyr:1985 hgt:103 byr:2004
+hcl:z ecl:#45a680
+
+hgt:183cm
+iyr:2013 byr:1933 cid:112
+eyr:2024 pid:795616425
+hcl:#7d3b0c
+ecl:gry
+
+cid:236 byr:1985 hgt:160cm
+hcl:#6b5442 eyr:2028
+ecl:gmt pid:277781460 iyr:2018
+
+ecl:amb
+byr:1948 pid:750948701 eyr:2025 iyr:2013 hgt:62in hcl:#7d3b0c
+
+eyr:2029 iyr:2020 pid:385941629 byr:1998 hgt:153cm cid:321
+hcl:#623a2f
+
+byr:1966 hgt:69in iyr:2012
+pid:423254216
+eyr:2020 hcl:#602927 ecl:blu
+
+byr:2004 pid:14257358 cid:338 iyr:2010
+ecl:gry
+hcl:#602927
+hgt:152cm
+
+ecl:gry eyr:2027 hcl:#341e13
+iyr:2018 pid:298762877 hgt:162cm byr:1968
+
+hcl:#ceb3a1
+iyr:2019 ecl:brn eyr:2020 pid:575413143 byr:2030 hgt:185cm
+cid:159
+
+eyr:2025 pid:628251539 ecl:blu byr:1953 hgt:63in hcl:#18171d iyr:2016
+
+pid:973247326 byr:1925 hcl:#341e13 ecl:grn eyr:2028 hgt:156cm
+iyr:2014
+
+byr:1957 hgt:154cm
+hcl:#7d3b0c
+pid:062760305 eyr:2023 ecl:brn
+iyr:2012
+
+ecl:brn eyr:2029
+cid:250
+pid:477431667 hgt:177cm
+byr:1993 iyr:2020 hcl:#ceb3a1
+
+pid:155471269 iyr:2010 byr:1985 hgt:169cm eyr:2026 hcl:#694b7d cid:337 ecl:gry
+
+ecl:grt hgt:152in byr:2012
+pid:#b9d022 iyr:2030
+eyr:2037 hcl:z cid:201
+
+hcl:9270b3 eyr:2028
+hgt:71cm iyr:2017 pid:#6c7af7 ecl:grn byr:1971
+
+pid:#0ab7e1 hgt:166cm byr:1929
+cid:289
+hcl:#623a2f iyr:2005
+ecl:amb
+
+pid:967754435
+hgt:175cm hcl:#341e13 ecl:utc iyr:2023 eyr:1949 byr:1988
+
+byr:1942 ecl:brn eyr:2023 pid:898126666 hgt:182cm cid:138
+hcl:#866857
+iyr:2010
+
+eyr:2027 iyr:2019 byr:1953 pid:760664328 hcl:#b6652a
+ecl:grn hgt:155cm
+
+iyr:2018
+ecl:brn hcl:#18171d pid:953129359 hgt:167cm eyr:2030 byr:1974
+
+cid:77
+pid:975070417 hcl:#b6652a ecl:amb iyr:2013 byr:1995
+eyr:2025 hgt:184cm
+
+hgt:168cm
+eyr:2026 byr:1938 ecl:gry pid:037135813 hcl:#6b5442
+iyr:2010
+
+iyr:2017 hcl:4cc74b byr:1980 hgt:176in
+pid:460622356 ecl:xry eyr:2030
+
+hcl:z
+ecl:oth pid:872514537 hgt:175in eyr:1984 iyr:2011 cid:145 byr:2024
+
+iyr:2014 ecl:blu
+pid:332729196 hgt:63in
+eyr:2020
+hcl:#602927
+
+hcl:#7d3b0c pid:369981570 byr:1996 ecl:gry
+eyr:2024 iyr:2017
+
+pid:446117373 hgt:158cm
+iyr:2010 ecl:gry eyr:2024 hcl:#e54715
+
+cid:341 pid:842156559
+hgt:167cm hcl:#602927 byr:1939 ecl:amb iyr:2016
+
+byr:2017
+cid:176
+ecl:#9e42ae iyr:2029 pid:8965345 eyr:2038 hcl:z
+hgt:116
+
+eyr:2027 iyr:2014 hcl:#ceb3a1
+cid:280 pid:871521406 ecl:oth byr:1957 hgt:166cm
+
+cid:303 iyr:2019
+eyr:2021 pid:579593282 ecl:gry hcl:011a46 byr:1981
+hgt:184cm
+
+iyr:2015 byr:1936 cid:61 ecl:brn pid:307248029 hgt:172cm hcl:#18171d eyr:2029
+
+pid:708687506 ecl:brn hcl:#602927
+iyr:2014 byr:1987
+hgt:193cm
+eyr:2021
+
+ecl:gry
+iyr:2015 hcl:#efcc98 byr:1950
+cid:150 eyr:2023 pid:569864726
+hgt:161cm
+
+byr:1920 hcl:#602927 iyr:2018
+ecl:gry eyr:2020
+hgt:192cm pid:020336420
+
+hcl:#539335 byr:1949
+hgt:152cm
+cid:95 pid:002018679
+eyr:2030 iyr:2015 ecl:brn
+
+hcl:#b6652a eyr:2023
+pid:515291463 iyr:2013 byr:1990
+ecl:blu hgt:160cm
+
+eyr:2030 iyr:2012
+ecl:grn pid:416049447 hgt:188cm
+hcl:#a97842 byr:1976
+
+iyr:2017 hgt:61in ecl:oth byr:2001 eyr:2028
+hcl:#733820
+pid:078720467
+
+eyr:2021 hgt:151cm iyr:2020
+hcl:#efcc98 ecl:oth
+byr:1985
+pid:876231883
+
+iyr:2019 hcl:#ceb3a1 hgt:156in
+eyr:2004 pid:093465895 ecl:amb byr:2026
+
+pid:103964845 hgt:178cm cid:320 ecl:oth
+hcl:#fffffd byr:2002 eyr:2021 iyr:2019
+
+ecl:brn byr:1920 pid:499363957
+cid:217 hcl:#341e13 hgt:164cm
+iyr:2017 eyr:2028
+
+ecl:brn pid:5837609946 iyr:2011
+byr:1971 eyr:2030 hgt:189cm
+hcl:#866857
+
+byr:1974 iyr:2015 hcl:#cfa07d
+hgt:190cm ecl:grn pid:330115418 eyr:2020 cid:173
+
+iyr:2010
+eyr:2024 byr:1943 pid:227557868
+cid:102 hgt:72in
+hcl:#6b5442
+
+hgt:151cm byr:1994
+pid:050723476
+cid:104 iyr:2010 hcl:#b6652a
+ecl:brn eyr:2030
+
+ecl:gry byr:1942
+hcl:#c5e354 hgt:192cm iyr:2019
+eyr:2027 pid:192177566
+
+ecl:hzl hcl:#c0946f byr:1997 pid:853199076 hgt:166cm
+iyr:2019
+eyr:2020
+cid:329
+
+eyr:2027 iyr:2029 hcl:#602927
+pid:#1b8593 byr:2028 hgt:172in ecl:grn
+
+eyr:2036 iyr:2030 ecl:utc
+pid:22330365 hcl:z byr:2016 hgt:65cm
+
+pid:936740771
+ecl:grn byr:1976
+hcl:#602927
+iyr:2017 hgt:192cm
+cid:257 eyr:2027
+
+eyr:2021 pid:415535681
+hcl:#b6652a hgt:191cm
+ecl:hzl
+iyr:2013 byr:1985
+
+hgt:193cm
+pid:499609129
+iyr:2014 ecl:oth
+eyr:2029 hcl:#cfa07d byr:1973
+
+ecl:gry byr:1996 cid:85 hgt:174cm iyr:2013 pid:444611265 hcl:#6b5442 eyr:2028
+
+pid:170343402
+iyr:2029
+hgt:167cm
+byr:2016 eyr:2034 ecl:hzl hcl:z cid:254
+
+hcl:4893d5 ecl:blu byr:1960
+eyr:2027 pid:573029479 iyr:1952 hgt:74in
+
+eyr:2021 hgt:192cm pid:729836929 iyr:2020 byr:1973
+cid:155 ecl:grn hcl:#602927
+
+hcl:#a97842 byr:1946
+iyr:2018 cid:172 hgt:162cm eyr:2030 ecl:amb pid:028768413
+
+iyr:2020 hcl:#c0946f ecl:grn pid:601040247 cid:237 hgt:177cm eyr:2024
+byr:1941
+
+iyr:2014 byr:1959
+eyr:2028
+hcl:#fffffd
+ecl:#7df42b cid:165 hgt:68cm
+
+byr:1944 hcl:#18171d
+pid:009636175 hgt:155cm ecl:amb eyr:2032 iyr:2015
+
+byr:1987 hgt:150cm
+hcl:#b6652a eyr:2021
+ecl:blu
+pid:723709387 iyr:2017
+
+byr:1937 ecl:oth eyr:2022 hcl:#733820 pid:143694811 cid:175 hgt:150cm
+
+pid:562911401
+cid:80 hgt:61in byr:1922 eyr:2027 ecl:amb iyr:2014
+hcl:#602927
+
+iyr:2013 ecl:amb pid:826291674 hcl:#ceb3a1 eyr:2021 byr:1968 hgt:75in
+
+hcl:#5e0e07
+hgt:164cm pid:572114080 eyr:2028 iyr:2016
+byr:1922 ecl:oth
+
+ecl:blu eyr:2029 hgt:155cm
+byr:1950 hcl:#866857 cid:271 iyr:2015
+pid:216813084
+
+iyr:2018 byr:2009 cid:212 ecl:#71a98c pid:3467231102 hcl:z hgt:173cm
+eyr:2026
+
+eyr:1945 cid:302 iyr:2030
+hcl:z pid:0411732179
+byr:2004 hgt:165in
+ecl:grt
+
+iyr:2010 hgt:169cm
+hcl:#ceb3a1
+eyr:2022 pid:659709686 ecl:hzl
+byr:1931
+
+hcl:z pid:5077677466
+eyr:2021 hgt:184cm
+iyr:1973
+byr:2009 ecl:#35575e
+
+hgt:190cm cid:103 iyr:2018
+byr:1970 ecl:gry
+eyr:2028
+pid:549406360 hcl:#18171d
+
+byr:1964 eyr:2023 iyr:2015 hgt:174cm pid:305268492
+hcl:#b98e00 ecl:blu
+
+hgt:162cm
+ecl:brn iyr:2019 byr:1951
+cid:169 pid:755632568 eyr:2030 hcl:#ceb3a1
+
+iyr:2010 ecl:oth hgt:192cm eyr:2025
+hcl:#efcc98 pid:003868873 byr:1925
+
+hcl:z
+ecl:gmt hgt:62 eyr:1991
+byr:2012
+iyr:2025 pid:1835041269
+
+hgt:162
+iyr:2026 byr:2024
+pid:6463124513 hcl:#602927 ecl:oth eyr:2028
+
+hcl:bfb027 iyr:1945 byr:1989 eyr:1944 pid:826897563 ecl:dne cid:117 hgt:177
+
+hcl:#b6652a iyr:2013
+ecl:blu byr:1952 eyr:2020 pid:737726601 cid:308
+hgt:167cm
+
+eyr:2028 iyr:2012 hcl:#6b5442
+byr:1986 ecl:blu
+pid:365821409 hgt:180cm
+
+hgt:101 eyr:2037 pid:2457985649
+ecl:gmt
+hcl:4c0784 iyr:2029
+
+hcl:#341e13 iyr:1954 ecl:dne byr:2007
+eyr:2028 pid:552497791 hgt:189cm cid:263
+
+ecl:blu
+hgt:71in pid:360012597 eyr:2029 hcl:#18171d byr:1949
+iyr:2014
+
+hgt:164cm cid:237 iyr:2016 byr:1966
+hcl:#623a2f ecl:oth
+pid:129809894 eyr:2027
+
+hcl:a2243b eyr:2031
+ecl:#de9183
+byr:1982 hgt:109 iyr:1968 pid:848311277
+
+eyr:1950
+hcl:45470a byr:1983
+pid:82580746 cid:321
+hgt:191cm ecl:dne iyr:2013
+
+iyr:2018 ecl:blu eyr:2021
+byr:1983 pid:045613120
+
+hgt:164cm byr:1926
+hcl:#cfa07d
+eyr:2030
+iyr:2010
+pid:360787918 cid:61 ecl:amb
+
+pid:#d6dddd iyr:1967 ecl:gmt hcl:z byr:1947 eyr:1943 cid:93 hgt:97
+
+ecl:oth hgt:172cm
+hcl:#efcc98 byr:1957
+pid:729531506 iyr:2017
+eyr:2030
+
+ecl:#5a51b9 byr:2023 eyr:2021 iyr:2027
+pid:174cm hgt:80 hcl:6b4f6e
+
+hgt:157cm
+ecl:amb
+eyr:2020 pid:994733990 iyr:2020 cid:174 byr:1966
+hcl:#7d3b0c
+
+eyr:1986
+byr:2020 hcl:#c0946f
+pid:499981246
+iyr:1926 cid:214 ecl:amb hgt:161cm
+
+hcl:#18171d byr:1971
+pid:#ef8a06
+eyr:2019 ecl:blu
+hgt:158cm iyr:2011
+
+byr:1959 cid:298 pid:876132993
+ecl:blu iyr:2011 hgt:176cm
+hcl:#6b5442 eyr:2030
+
+eyr:2030
+byr:1926 hcl:#733820 iyr:2017
+hgt:150cm pid:165cm ecl:blu
+
+byr:1991 eyr:2027
+hgt:183cm
+pid:178cm
+ecl:grn hcl:8a6142 iyr:2017
+cid:265
+
+hgt:183cm
+eyr:2027 hcl:#602927 pid:530884763 byr:1959 ecl:brn iyr:2013
+
+hcl:#b6652a eyr:2030 hgt:171cm cid:97 byr:2002 pid:166795809
+ecl:hzl
+iyr:2016
+
+pid:479944517 hgt:166cm byr:1976 eyr:2022 hcl:#a97842
+ecl:grn iyr:2018
+
+byr:1949
+eyr:2013
+hcl:z ecl:hzl
+pid:152cm hgt:139 iyr:1962
+
+pid:278193062 hcl:#c0946f iyr:2013 byr:1950 eyr:2020 hgt:167cm
+ecl:oth
+
+eyr:1955
+iyr:2018 pid:#ffd4de byr:1922 hgt:178cm hcl:z
+ecl:lzr
+cid:154
+
+ecl:grn hcl:#a189d5 byr:1977 pid:120286096
+eyr:1966
+hgt:178cm
+iyr:2011
+
+eyr:2028
+hcl:#fffffd iyr:2013 byr:1956 pid:565425333 cid:207 ecl:gry hgt:67in
+
+hgt:188cm eyr:2028 cid:90
+iyr:2019 pid:574624890 hcl:#b6652a byr:1937 ecl:oth
+
+hcl:#efcc98 hgt:152cm ecl:hzl iyr:2010 cid:217 byr:1936 eyr:2027 pid:857984889
+
+hgt:124 iyr:2015 byr:1989 ecl:oth eyr:2023 hcl:#ceb3a1 pid:917440765
+
+ecl:#61e880 cid:82
+pid:165cm byr:2019 eyr:1930 hgt:152in hcl:z iyr:2030
+
+byr:1974
+hgt:60in ecl:gry
+hcl:#c0946f
+pid:215085889
+iyr:2017 eyr:2020
+
+ecl:grn hcl:#ceb3a1
+pid:602147794 hgt:180cm eyr:2028 byr:1927 iyr:2018
+
+hcl:#ceb3a1 byr:1958 ecl:gry
+pid:210246609 iyr:2018 hgt:169cm
+eyr:2023
+cid:255
+
+eyr:2025
+byr:1950 hgt:177cm
+ecl:gry pid:547034188
+iyr:2018
+cid:218 hcl:#341e13
+
+pid:380369950
+eyr:2022 hgt:65in iyr:2019 ecl:brn
+byr:1996
+
+hgt:167cm
+iyr:2014
+eyr:2029 cid:199 pid:144048588 byr:1963 ecl:oth hcl:#733820
+
+byr:1962 ecl:brn hgt:161cm eyr:2022 hcl:#cfa07d
+pid:247699670 iyr:2016
+
+hgt:192cm ecl:#8bdb3e pid:#b152a9 hcl:#18171d iyr:2012 byr:2011 cid:335 eyr:2040
+
+hcl:11f8f4 ecl:#86f885 iyr:2022
+hgt:75in
+pid:920078124 byr:1952 eyr:1994
+
+pid:718378772 cid:282
+hcl:#fffffd hgt:166cm eyr:2023 iyr:2019 byr:1944
+ecl:grn
+
+eyr:1963 pid:562051556
+ecl:#793853
+hcl:z byr:2030 iyr:2026
+
+byr:1980
+cid:143 hgt:161cm eyr:2022
+pid:778422225
+hcl:#7d3b0c iyr:2011 ecl:blu
+
+byr:1940 eyr:2021 hgt:74in cid:161 hcl:#a97842 ecl:blu
+pid:864682628 iyr:2014
+
+byr:1991 pid:163871357 ecl:oth
+hgt:189cm cid:229 eyr:2024
+hcl:#efcc98
+iyr:2012
+
+iyr:2013 hcl:#ceb3a1 ecl:hzl byr:1985 pid:801995950 hgt:73in
+eyr:2029
+
+byr:1931 hcl:#ceb3a1 iyr:2013
+cid:289 eyr:2027 ecl:blu
+hgt:150cm pid:969679765
+
+iyr:2015 hgt:176cm eyr:2025 ecl:blu
+byr:1935 pid:388582890 hcl:#efcc98
+
+iyr:1956 eyr:2034 pid:049440894 ecl:xry byr:1950 cid:228
+hgt:186cm
+
+iyr:2014 hcl:#fffffd byr:1985
+eyr:2022
+hgt:176cm pid:556889061 ecl:amb
+
+pid:994755123 hgt:165cm
+ecl:brn
+eyr:2022 byr:1937 iyr:2011
+
+byr:2012
+hcl:z cid:217 iyr:1958
+ecl:brn hgt:160cm
+pid:871866608
+eyr:2027
+
+hcl:#a97842
+ecl:hzl byr:1929
+iyr:2016
+eyr:2029 pid:220410871 hgt:192cm
+
+pid:332596122 byr:1986
+hcl:#cfa07d
+eyr:2022 hgt:189cm ecl:grn iyr:2016
+
+hgt:167cm
+hcl:#6b5442 eyr:2026
+iyr:2020 ecl:grn cid:231 pid:521486150
+
+cid:299
+hgt:178cm byr:1945 ecl:brn iyr:2012
+hcl:#fffffd eyr:2022
+pid:264693268
+
+ecl:lzr pid:157cm hcl:f0a766
+iyr:2029 hgt:175in byr:2004
+
+hcl:#888785
+hgt:159cm eyr:2025
+iyr:2012 ecl:oth
+byr:1995 pid:135442622
+
+eyr:2024 hcl:#a97842
+iyr:2013 pid:186863004 ecl:brn byr:1929 hgt:162cm
+
+pid:518619727 ecl:grn
+hcl:#866857 byr:1954
+iyr:2016
+hgt:69in
+
+eyr:2022 iyr:2018
+byr:1926
+ecl:oth pid:073817633
+hgt:167cm hcl:#b6652a
+
+hgt:190cm iyr:2019
+ecl:dne byr:2010 eyr:2023 pid:979671212
+
+hgt:190
+ecl:#5ddbda byr:2025 iyr:1973 pid:#a082dc eyr:1998 cid:177 hcl:z
+
+iyr:1976 eyr:2026 pid:4862485 hgt:71in
+byr:1975 ecl:#41855f hcl:#ceb3a1
+
+ecl:brn
+byr:1927 iyr:2012 hgt:67in
+pid:479646443 eyr:2039 hcl:z
+
+pid:779458123
+cid:263 hcl:#efcc98
+byr:1951
+hgt:153cm iyr:2011
+ecl:amb eyr:2030
+
+hgt:187cm
+eyr:2028
+byr:1957
+hcl:#b6652a iyr:2015 pid:616963706 ecl:brn
+
+hgt:154cm byr:1947
+pid:51196404
+eyr:2020 iyr:2001
+ecl:hzl
+
+hgt:157cm iyr:2013 eyr:2021
+ecl:blu hcl:d9e6e0
+byr:2023
+
+iyr:2010
+hcl:#866857
+ecl:brn eyr:2022
+cid:163 byr:1962 pid:458396337 hgt:160cm
+
+ecl:amb eyr:2027
+byr:1987
+hgt:184cm
+pid:125222897 cid:214
+iyr:2020
+
+ecl:grt eyr:1942
+iyr:2023
+hcl:901862 hgt:159in
+byr:2009
+
+eyr:2028
+byr:1973 hgt:151cm iyr:2013 ecl:hzl pid:229165831
+
+eyr:2024 hgt:190cm ecl:grn byr:1962 iyr:1921 pid:531272718 hcl:#ceb3a1
+
+hgt:169in pid:1747598652 ecl:dne
+iyr:1974 eyr:2031 hcl:#602927 byr:2030
+
+hgt:177cm iyr:1963 eyr:2006
+cid:276 hcl:#7d3b0c
+pid:192cm
+ecl:grn byr:2022
+
+pid:893346945 hcl:#733820 ecl:oth iyr:2013 byr:1973 hgt:186cm eyr:2025
+
+hgt:177cm
+eyr:2025
+byr:1997 hcl:#733820
+cid:295 iyr:2016 pid:019887743 ecl:grn
+
+iyr:2019
+byr:1982 eyr:2030 ecl:brn pid:041140029 hcl:#a97842 hgt:189cm
+
+pid:165cm iyr:1962 hcl:e5c590 ecl:#e394a4
+eyr:2040
+hgt:70cm byr:2006
+
+byr:1940 eyr:2025 iyr:2020 hcl:#a97842 ecl:brn pid:502841851 cid:121
+hgt:160cm
+
+eyr:2015 ecl:zzz hgt:174 pid:154cm iyr:2021
+hcl:z
+cid:113
+byr:2003
+
+iyr:2020
+eyr:2023 pid:402183362 hcl:#120eb2
+ecl:amb
+hgt:150in
+byr:1921
+
+pid:059311672 cid:290 hcl:#7d3b0c byr:1996
+iyr:2021 hgt:155cm ecl:hzl eyr:2030
+
+pid:790768270 hgt:167cm ecl:gry
+byr:1973
+hcl:#b6652a eyr:2028 iyr:2017
+
+hcl:#18171d eyr:2024 pid:062349624
+byr:2002 iyr:2019 cid:230 ecl:oth
+
+iyr:2015
+hgt:170cm
+cid:193
+eyr:2025 ecl:hzl byr:1947
+pid:484823445
+hcl:#623a2f
+
+pid:5792950369 cid:343
+hcl:1d16b7 eyr:2024
+hgt:185in iyr:1965
+ecl:gmt byr:1948
+
+pid:#a1a101
+ecl:grn
+byr:1945
+iyr:2013 hcl:#ceb3a1 hgt:156cm cid:279 eyr:2026
+
+pid:936593230 eyr:2026 hgt:179cm
+hcl:#7d3b0c
+iyr:2015 byr:1976
+ecl:gry
+
+eyr:2021 pid:210678956 hgt:153cm cid:72 iyr:2018 ecl:grn
+
+pid:995512119
+byr:1937 eyr:2021 hcl:#4d8fe2 ecl:brn
+iyr:2019
+hgt:187cm
+
+hcl:#341e13 pid:282336259 eyr:2022
+cid:95 byr:1977 hgt:101 ecl:#955529
+iyr:2029
+
+pid:934992980 hcl:#fffffd iyr:2028 eyr:1945 ecl:gry byr:1926
+
+iyr:2018 ecl:gry
+hgt:179cm hcl:#866857 pid:573616710
+byr:1987
+
+byr:2010 eyr:2021 hcl:z pid:018180068 hgt:74
+cid:183 iyr:2027 ecl:dne
+
+iyr:2020 hgt:160cm
+pid:760124779 hcl:#b6652a ecl:grn eyr:2030 byr:1951
+
+pid:354858055 ecl:hzl hgt:192cm
+hcl:#ceb3a1 byr:1983 cid:314
+iyr:2016 eyr:2027
+
+eyr:2028 iyr:2013 hgt:171cm hcl:54be83 ecl:xry byr:2021
+pid:89895052
+
+byr:1963 iyr:2019
+pid:298992037 eyr:2024
+hgt:63in hcl:#341e13
+
+hgt:64cm
+pid:7645482607 ecl:#c94773 cid:231 hcl:621e9d eyr:2000 byr:2013
+
+hcl:#ceb3a1 ecl:gry iyr:2015 hgt:178cm byr:1945
+pid:416960939
+
+hgt:178cm
+cid:121
+byr:1961 iyr:2019 hcl:#6b5442
+eyr:2028 pid:098226989
+
+iyr:2015 eyr:2028
+ecl:amb
+hgt:154cm
+pid:364426658 byr:1960
+hcl:#623a2f
+
+byr:1998
+pid:#e5ab03 hcl:z ecl:grn
+iyr:2006 hgt:61cm eyr:2038
+
+hcl:#866857 eyr:2020
+hgt:187in
+pid:#8239dc iyr:2010 ecl:#6259e7 byr:1939
+
+pid:#6082fa eyr:2028 ecl:gry hcl:937410 iyr:2010
+hgt:173cm
+
+eyr:1922 ecl:grt pid:228396726 hgt:65cm
+hcl:#6b5442 byr:2024 iyr:2010
+
+hcl:#c0946f iyr:2016 byr:1978
+pid:774430678 eyr:2026
+ecl:oth hgt:61in
+
+cid:208 pid:714195768 iyr:2019 eyr:2022 byr:1937 ecl:gry hcl:#ceb3a1 hgt:159cm
+
+eyr:2028 ecl:gry iyr:2010 byr:2001 hgt:163cm pid:409136005 hcl:#623a2f cid:200
+
+pid:471094613 eyr:2028 hgt:165cm iyr:2010 ecl:amb byr:1995 hcl:#a97842
+
+ecl:oth iyr:2011 pid:907249487 eyr:2020
+byr:1924 cid:68 hcl:#a97842
+hgt:155cm
+
+byr:1983
+hgt:69cm
+eyr:2027 iyr:2010 hcl:#866857
+pid:671371092
+ecl:amb
+
+hgt:97 pid:168cm cid:67
+eyr:1957 hcl:#623a2f byr:2027 ecl:gry iyr:2019
+
+ecl:blu iyr:2012 pid:287999130 hgt:178cm eyr:2020
+byr:1940
+hcl:#888785
+
+hcl:z hgt:63cm ecl:grt
+iyr:2024 eyr:2031 pid:167cm
+byr:2013
+
+hgt:65in hcl:z cid:300 ecl:amb pid:58257193
+byr:1969 iyr:2011 eyr:1985
+
+hcl:#341e13 eyr:2036 hgt:189in
+pid:58541401
+ecl:#d793f2 iyr:2010 byr:2006
+
+cid:259 ecl:grn
+hcl:#a97842
+hgt:167cm
+pid:641690548 eyr:2021
+byr:1930
+iyr:2010
+
+eyr:2027
+hgt:75in
+cid:335 hcl:#602927 iyr:2012 ecl:blu pid:724014178
+byr:1928
+
+eyr:2027
+hcl:#8345d8 ecl:grn byr:1965 pid:728151722
+hgt:182cm iyr:2016
+
+iyr:2020 pid:794922933
+hcl:#341e13
+ecl:oth
+byr:1985
+hgt:71in
+eyr:2022
+
+ecl:#025c94
+hcl:#fffffd
+iyr:2027
+byr:1987 hgt:186cm cid:135 pid:005852205
+eyr:2021
+
+byr:2020
+ecl:grn
+pid:91200233
+iyr:2014 eyr:2020 hgt:179cm hcl:be0c95
+
+ecl:gmt iyr:2010 pid:171cm byr:2010 eyr:2036 hgt:159in hcl:424df0
+
+ecl:gry iyr:2013 hcl:#7d3b0c hgt:175cm pid:337611432 byr:1953 eyr:2021
+
+byr:1926 pid:678688040
+hcl:#cfa07d
+cid:311 eyr:2027 hgt:183cm iyr:2018
+ecl:blu
+
+byr:2021
+pid:156cm
+ecl:dne
+hgt:156cm
+hcl:#6b5442
+iyr:2027
+
+pid:380639402 eyr:2025
+cid:196
+hgt:163cm
+hcl:#602927 ecl:hzl
+iyr:2015
+
+eyr:2039 hcl:5aa018 byr:2007 ecl:dne
+hgt:77 pid:#d30c1c iyr:2025
+
+ecl:blu
+iyr:1986 pid:3544865154 eyr:2027 byr:2007 hgt:74cm hcl:ca33b3
+
+pid:#b05294 byr:1951 hcl:#ceb3a1 cid:221
+iyr:2000 hgt:110 eyr:2021
+
+byr:1954 hcl:#efcc98 iyr:2018 ecl:#f4ea81
+pid:414210788 hgt:174cm eyr:2037
+
+pid:#abbdd9
+hgt:164in
+iyr:2003 cid:319 eyr:2035
+byr:2015
+ecl:#9b38c7
+
+ecl:amb
+iyr:2018 byr:1922
+hgt:157cm pid:801421993 eyr:2029
+hcl:#efcc98
+
+eyr:2022
+hcl:#b6652a
+ecl:amb byr:1942
+hgt:153cm iyr:2018
+pid:805225382
+
+byr:1925
+hcl:#efcc98 ecl:amb pid:539625393 cid:269
+hgt:161cm iyr:2013 eyr:2025
+
+cid:305 hgt:154cm
+hcl:#18171d byr:1998
+eyr:2029 iyr:2011 pid:634235387 ecl:gry
+
+hcl:#6b5442 pid:504467634 iyr:2018 cid:96 byr:1970
+ecl:gry eyr:2023 hgt:167cm
+
+iyr:2020 hgt:163cm hcl:#fffffd pid:762271916 byr:2029 eyr:2022
+ecl:#12027c
+
+byr:1978
+cid:134 hcl:#6b5442
+iyr:2010 pid:627335191 ecl:blu eyr:2023 hgt:171cm
+
+pid:260340768 hcl:#a97842 byr:1947 ecl:#2150e3 iyr:2019
+cid:153
+hgt:65in eyr:2025
+
+byr:1973 eyr:2022
+cid:229 pid:515108192 ecl:amb hcl:z
+iyr:2013 hgt:178cm
+
+ecl:hzl
+hgt:158cm hcl:#a97842
+pid:657117959 byr:1977 eyr:2023 iyr:2018
+
+ecl:gry eyr:2024
+hgt:163cm byr:1976 iyr:2017
+pid:653769092 hcl:#18171d
+
+ecl:amb pid:161694953
+hcl:#602927 hgt:188cm eyr:2021 byr:1946
+iyr:2016
+
+eyr:2021
+hgt:178cm ecl:grn
+byr:1961 pid:472866063 iyr:2011 hcl:#cfa07d cid:160
+
+eyr:2037 iyr:2011
+hgt:187cm byr:1973 pid:163cm hcl:#b6652a
+ecl:brn cid:283
+
+iyr:2017 hcl:#18171d eyr:2020 pid:059926864 hgt:160cm ecl:brn
+
+byr:2010
+hcl:8217d4 hgt:153in iyr:1989 eyr:2037 pid:#74e0a4 ecl:#ba5782
+
+ecl:#28f922
+byr:1951 hgt:65cm
+iyr:2025 pid:151cm hcl:z eyr:2028
+
+pid:302959013
+hgt:167cm eyr:2022 ecl:hzl iyr:2014
+cid:168
+hcl:#888785 byr:1969
+
+pid:013861920 hcl:#623a2f
+ecl:gry
+byr:1928
+iyr:2017 hgt:174cm eyr:2028 cid:250
+
+byr:1997 hgt:74cm hcl:#efcc98 eyr:2039 ecl:#d3dc6a
+cid:243
+iyr:2030 pid:189cm
+
+hgt:67cm byr:2011 eyr:2040 pid:192cm ecl:#b7a5a8 hcl:281b25
+
+iyr:2014 ecl:brn byr:1954 hcl:#fffffd pid:285922660 hgt:76in eyr:2028
+
+iyr:2021 byr:2028
+eyr:2023
+hgt:69in hcl:e832ef pid:714568559 ecl:#f10004 cid:208
+
+ecl:brn hgt:166cm hcl:#cfa07d
+cid:59 pid:4884483993
+iyr:2012
+eyr:1932
+
+iyr:2029 byr:2025
+cid:238 ecl:utc
+eyr:2022
+pid:887425834 hgt:177in
+
+pid:014383055 cid:342 hgt:183cm eyr:2025
+iyr:2014 ecl:blu byr:1969 hcl:#7d3b0c
+
+eyr:2033
+hcl:#341e13
+iyr:2014
+hgt:71cm ecl:#750eec
+byr:1980 pid:#e2d3ac
+
+hgt:154cm iyr:2019 hcl:#341e13 ecl:hzl byr:1942 pid:393181243 eyr:2025
+cid:316
+
+ecl:amb
+hgt:158cm
+eyr:2025 byr:1986 hcl:#fffffd pid:379180765 iyr:2014
+
+pid:8191674491 eyr:2028 hcl:#efcc98 byr:2015 iyr:2012
+ecl:amb cid:140
+
+byr:2015 hcl:8e3e81 eyr:2024 hgt:180cm iyr:1984 pid:#56cd0e
+ecl:zzz
+
+pid:247138863 eyr:2022 hgt:176cm iyr:2014 byr:1929
+ecl:gry cid:87 hcl:#b6652a
+
+hcl:z pid:#c4cdee ecl:#ca97a6 byr:1971 eyr:2032
+iyr:1997 hgt:156in
+
+ecl:gry
+hgt:167cm eyr:2030 byr:1984 hcl:#cfa07d iyr:2016
+
+hcl:#a97842 hgt:163cm
+pid:373461578 iyr:2017
+byr:1926 ecl:amb
+eyr:2021
+
+cid:161 hcl:#b6652a byr:1930 ecl:brn eyr:2028 hgt:166cm iyr:2016
+
+ecl:amb cid:126
+eyr:2024
+hcl:#18171d iyr:2019
+byr:1991 hgt:183cm
+
+ecl:lzr iyr:2026 byr:1996
+hgt:69in pid:#ccef7e eyr:2028
+hcl:#fffffd
+
+hgt:68cm iyr:1945
+ecl:brn byr:2009 pid:#56e987 hcl:fdd212 eyr:2023
+
+pid:72039060 eyr:2036 hgt:172cm
+hcl:#fffffd iyr:2011
+byr:1944 ecl:xry cid:202
+
+ecl:hzl
+eyr:2025
+byr:1922 hcl:#efcc98
+pid:795790549
+iyr:2020 hgt:150cm
+
+hgt:155cm
+hcl:#373de2 pid:#707dc6 iyr:2017 byr:2002 eyr:2038
+ecl:oth
+
+hcl:#888785 iyr:2011
+hgt:159cm
+byr:1962 eyr:2026 ecl:amb pid:672792762
+
+cid:217 eyr:2025 hgt:164cm byr:1999 pid:975218035 ecl:grn hcl:#18171d iyr:2011
+
+pid:655501194 eyr:2029 byr:1999 iyr:2013
+hgt:183cm hcl:#a97842 ecl:hzl
+
+byr:1986 hcl:#efcc98 pid:160cm ecl:oth eyr:2022 iyr:2022 hgt:150cm
+cid:63
+
+hgt:69in byr:2002 pid:0528229881 ecl:blu hcl:z iyr:2022
+eyr:2033
+
+iyr:2020 pid:007754028 hcl:z cid:232 ecl:dne hgt:73in
+
+ecl:hzl
+iyr:2016 hcl:#7d3b0c byr:1948
+eyr:2021
+cid:269 hgt:173cm pid:176430746
+
+cid:310
+ecl:xry
+eyr:2032 hgt:64cm
+pid:190cm hcl:z byr:2019
+
+hgt:150cm pid:660176034 hcl:#c0946f
+ecl:hzl byr:1986 eyr:2021 iyr:2019
+
+pid:7876582
+eyr:2021 iyr:2020
+hgt:185cm hcl:#18171d cid:319 ecl:amb byr:1943
+
+ecl:hzl hcl:#623a2f iyr:1950 byr:2012 cid:334 eyr:2028
+
+eyr:2028
+byr:1992 hcl:#b6652a ecl:hzl cid:222
+hgt:189cm iyr:2016
+pid:092856842
+
+hcl:a3c52a
+iyr:2025 byr:2023
+hgt:182cm ecl:#be1503 pid:9311657615 eyr:2005
+
+eyr:2035
+byr:1988 hgt:193cm
+iyr:2028 cid:128 hcl:#18171d ecl:utc pid:9743739773
+
+ecl:zzz hcl:z
+hgt:64cm pid:160cm byr:2026 eyr:1943 iyr:2028 cid:74
+
+ecl:oth
+pid:874577361
+iyr:2010 eyr:2021
+hgt:160cm hcl:#c0946f
+byr:1959

+ 108 - 0
aoc2020/4th/main.jl

@@ -0,0 +1,108 @@
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
+optional_fields = ["cid"]
+
+#--------part1
+
+function valid_documents()
+    valid = 0
+    Document = Dict()
+    for (idx, line) in enumerate(eachline(selfdir))
+        if (line == "")
+            valid += required_fields ⊆ keys(Document)
+            Document = Dict()
+        else
+            line != ""
+            [foreach(x -> (Document[x[1]] = x[2]), [split(i, ':')]) for i in split(line)]
+        end
+    end
+    if ~isempty(Document)
+        valid += required_fields ⊆ keys(Document)
+    end
+    return valid
+end
+
+function valid_documents_pipe()
+    selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+    required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
+    optional_fields = ["cid"]
+    a =
+        read(selfdir, String) |>
+        x -> split(x, "\n\n") .|> 
+        x -> split(x) .|> 
+        x -> split(x, ':')
+
+    b = 
+        a .|> 
+        Dict |> 
+        x -> mapreduce(y -> required_fields ⊆ keys(y), +, x)
+
+    return b
+end
+
+#---------part2
+
+function check_fields(Document)
+    checks = 0
+    if required_fields ⊆ keys(Document)
+        checks += 1920 <= parse(Int, Document["byr"]) <= 2002
+        checks += 2010 <= parse(Int, Document["iyr"]) <= 2020
+        checks += 2020 <= parse(Int, Document["eyr"]) <= 2030
+        checks += if endswith(Document["hgt"], "cm")
+            150 <= parse(Int, Document["hgt"][1:(end - 2)]) <= 193
+        elseif endswith(Document["hgt"], "in")
+            59 <= parse(Int, Document["hgt"][1:(end - 2)]) <= 76
+        else
+            false
+        end
+        checks += ~isnothing(match(r"#[0-9a-f]{6}"i, Document["hcl"]))
+        checks += Document["ecl"] ∈ ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"]
+        checks += ~isnothing((match(r"^[0-9]{9}$", Document["pid"])))
+    end
+    return checks == 7
+end
+
+function valid_documents2()
+
+    valid = 0
+    Document = Dict()
+    for (idx, line) in enumerate(eachline(selfdir))
+        if (line != "")
+            [foreach(x -> (Document[x[1]] = x[2]), [split(i, ':')]) for i in split(line)]
+        else
+            valid += check_fields(Document)
+            Document = Dict()
+        end
+    end
+    if ~isempty(Document)
+        valid += check_fields(Document)
+    end
+    return valid
+end
+
+
+function valid_documents_pipe2()
+    selfdir = selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+    required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
+    optional_fields = ["cid"]
+    a =
+        read(selfdir, String) |>
+        x -> split(x, "\n\n") .|> 
+        x -> split(x) .|> 
+        x -> split(x, ':')
+
+    b = 
+        a .|> 
+        Dict |> 
+        x -> mapreduce(y -> check_fields(y), +, x)
+
+    return b
+end
+
+#--------evaluation
+
+valid2 = @btime valid_documents()
+valid1 = @btime valid_documents_pipe()
+
+valid3 = @btime valid_documents2()
+valid4 = @btime valid_documents_pipe2()

+ 23 - 0
aoc2020/4th/stolen.jl

@@ -0,0 +1,23 @@
+function part2(data)
+    fields = Dict(
+        "byr" => x-> (n = tryparse(Int, x); !isnothing(n) && 1920<=n<=2002),
+        "iyr" => x-> (n = tryparse(Int, x); !isnothing(n) && 2010<=n<=2020),
+        "eyr" => x-> (n = tryparse(Int, x); !isnothing(n) && 2020<=n<=2030),
+        "hgt" => x->
+        if endswith(x, "cm")
+            height = parse(Int, replace(x, "cm"=>""))
+            150 <= height <= 193
+        elseif endswith(x, "in")
+            height = parse(Int, replace(x, "in"=>""))
+            59 <= height <= 76
+        else
+            false
+        end,
+        "hcl" => x->!isnothing(match(r"^#[0-9a-f]{6}$"i, x)),
+        "ecl" => x->x ∈ ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"],
+        "pid" => x->!isnothing(match(r"^\d{9}$", x)),
+    )
+    (data .|> x->all([cond(get(x, key, "")) for (key, cond) in fields])) |> sum
+end
+
+part2(b)

+ 789 - 0
aoc2020/5th/input

@@ -0,0 +1,789 @@
+BFFFBBFRLR
+FBFFFBBLRL
+BFFFFFBRRR
+FBBBFFFLRR
+FFBFBFBRLL
+FBBFFBBLRR
+FBBFFFFRLL
+BFFFBBFRLL
+BBFBFBFRLL
+BFFFFFBRLL
+FFBFFFBRRR
+BBFFBFFRLR
+BBFFBBFLLL
+FBFBFBFLLL
+BBFFFFFLLR
+FFBBBFFRLL
+FFBFFBFRRR
+BFFFBBFLRL
+BFBBBBFLRR
+BFBFFBFLLL
+FFBFFBBLRL
+FFBFBFFRLR
+FFBFBBBLLR
+FFFBBFBLLR
+FFFBBBFLRL
+FBFBBBFLLL
+FBBFFFBLLR
+BFFFBBBRLL
+FFBBFBBRRL
+FBFFBBBLLR
+FBFBBFFRRL
+FBBBBFFLLL
+FFBFBFFLLR
+BFFFFBFLLR
+FBBBFBFLRR
+FBFFFFFRRR
+FFBFBBFRRL
+BFFFBBBLLR
+FBBFFBFRLL
+BFFFFBBRLL
+FBBBFFFRRL
+BBFBFFFLLR
+FBBFBBFRLR
+FFFBFFBRRR
+BFBBFBBLRL
+FBBBFFBLRR
+BBFFBBFLRR
+FFBBFBBLLL
+BFFBBBBRRL
+FBBFBFBRLL
+BFFFFFFRRL
+BBFBFBFLLL
+FBFFBFFLLR
+FBFBFBFRLR
+BFBFBBBRLR
+BBFFBBFLLR
+BFFBFBFRRR
+BFBBFBFLLL
+FBFBBFBRLR
+FBBFBFBLRL
+FBFFBFFLRR
+BFFFFFFRRR
+BFFFFBFRLL
+FBFBFFFLLR
+BFFFFBFLRL
+BBFFFFFRLL
+FBFBFFFLRR
+BFFBFBBLRL
+BFBFBBFLLR
+BFBFBBBLRL
+BFFBFFFRRL
+BFFFFFFLLL
+FFBBBBBLLR
+FBBBFFFLLL
+BFFFBBFRRL
+FFFBFBBRLL
+FFFBFFBRRL
+BFBFBFBRRR
+BBFFFBFLLR
+BFFFBFFLLL
+FBFBBFBLRR
+FFBBBBFLRR
+BFFBBBFLRR
+BBFFBBBLLR
+FFFBFBBRRL
+BBFFFBBLRR
+FFBFFFBRRL
+FFBFFFBRLR
+BFBFBFFRLL
+FBFFFBFLRL
+BBFFFFFRLR
+BFBBFFBRLR
+FBFBFBBRRR
+BFBFFFFLLR
+FFBFBFBLRR
+FFFBBBBRRL
+FBFFBBFRRR
+BFFBBBBLRR
+BFFBFFFLLR
+BFBFFBFLLR
+FBBBBBBRLR
+BFBFFFFLRL
+BBFFBFFLLL
+FBBBBBBLLR
+FFBBBBBRRL
+BFBFFFFLLL
+FBFBBBFRLL
+BFFBBBFLRL
+FBBFBBBLLL
+FBFBBFBRRR
+FFBBFFFRLL
+BBFFBBBLRL
+FBBFFFBRLL
+BBFBFFBRLR
+FBBBFFBLLR
+BFBFFFBRRL
+FBFFBBBRLL
+FBFBBBBRLL
+BFFFBFFRLR
+FFBBFBFRLR
+BFBFBFFLRR
+FFFBBFFLRR
+BFBFBBBLLL
+BFBFBFBRLR
+BFFFFBFLRR
+FFBBBFBRRR
+BFFFFBBLLR
+BBFFBFBLRR
+BFBFFFBRRR
+BFFFFBBRLR
+FBBBBBFRRR
+FBBFBBFLLR
+FFBBFBBRLL
+BFBBFFBLRR
+FBBBFFFLLR
+BFFFBFFLRL
+FBBBBFBLLR
+BFBBFBFLRR
+BFBBBFFLLL
+BFFBFBFRLL
+BFBBFBFRRL
+BFFBFFBLRR
+FFBFFFBLLL
+FFFBFBFLRL
+FBBBFBBLRR
+BFFFBBBLRR
+FBFFFFFRLR
+BBFFBBBLRR
+BFBFFBBLRR
+FBFFBBBRRR
+FBFFBFFLLL
+BFBBBBFRLL
+FBBBBBBRRL
+BFFBBBBLRL
+FFBFBBFLRR
+FFBBBFBLLL
+FBBFFFFRLR
+BBFBFBFRRR
+FBFBFFBLRL
+FFBBFBBLRL
+FBFBBFFLLL
+BFFFBFBLRR
+FBFBFFBLLR
+FBBBBBFLRL
+FFBFBFFRLL
+BBFFBBFRRR
+FFFBBFFLLR
+BFBBBFBLRR
+FFBBFFBLRL
+BFFBBBFRRL
+BFBBBBFRRL
+BBFFBFFRRL
+FFBFFBBRRR
+BFFBFBFLRR
+FBFBFFBRRR
+FBBFBBFLRL
+FBFFFFBLRL
+FBFFFBBLLL
+FFBFFBFRLR
+FBFFFBBRRL
+BFBBBFBLLL
+BFBFBFFLRL
+BFBFFBFRRR
+BBFFBBBRLL
+BBFFFBFLRL
+BBFFBFFRLL
+FBBFFBFLLL
+FBBBBFFLLR
+FFBFFFFLLR
+FFBBBBFLLR
+BFBBBBBRRR
+FFBBFBFRRR
+FFBFFBFLRL
+FBFBBFFRRR
+BFBBBFFRRR
+FBBFBBFRLL
+FBBFBBBRLR
+BFFFFFBRLR
+BFFBFBBRLL
+FBFFFBBLRR
+FFBFFFFRLL
+FBBBBFBRRL
+FBBBBFBRLR
+BFBBBBFLLL
+FBBBBBFRLL
+FBFBFBFLRL
+FFBFBBFLLL
+FBBBBFFRRL
+BFFBFBFLLL
+FFFBBBFLLL
+FBFBBBBLLL
+BFBBBBFRLR
+BBFBFFFRRR
+FBBBBBBLRL
+BFFFBFBLRL
+FFBBFBFLLR
+BFBBBFBLRL
+FBBBBBBRLL
+FFBBFFFRRR
+BFFFFBBRRR
+FBFFBBBLLL
+BBFBFFFLRL
+FFBFFFBLRR
+FFBBBFBLLR
+BFFBBFFRRR
+FBBFBFFLRL
+FFBBBBBLRR
+FBBBFBBLLL
+BBFBFBFRLR
+FBFBFBBLRR
+FBBBFBBRLR
+FBFBFBBLLR
+FFFBBFBRRR
+FBBBFFBRLL
+FFBBBBFLRL
+BBFFBFFRRR
+FBFBFBFLLR
+FBBBFBFRLR
+BFFBBBFRRR
+FFFBFBBLLR
+BBFBFBBLRR
+FBFFBBFRLR
+FFBBBFFLLR
+FFBBFBFLRL
+BFFBFFFLLL
+BFBFFBFRRL
+FBFBBBBRRL
+BFBBBBFLLR
+FBBFFBBRLL
+BFFBBFBRLR
+BFBFFFBLRR
+FFBBFFBLRR
+FBBFFFFRRL
+BFBBFBBLLR
+FBFFFBFRLR
+BFBBBBFLRL
+BFBBBBBRLL
+FFBBBBFRLR
+BBFBFFBLLR
+FBBFFFBLRR
+FBFFFFFLLL
+FBBFFBFRLR
+FBFFBBBRRL
+FFBFBFBRRL
+FFBBBBFLLL
+FFBFBBBRLR
+FBBFBFBRLR
+BBFFFBBLLR
+FBBFFBBLLL
+FFBBFFFLLL
+FBBBBBFLRR
+FFBBFFFLRR
+BFFBFFBLLR
+FBFFBFBRRR
+FFFBFFBRLR
+FBFFFFFLRR
+BFFFBFBRLL
+FBFBBFBRRL
+FFBFBBBLRL
+BFFFBBFLLR
+FBBFFBBRRR
+BFBBFBFRLL
+FBFFFFBRLL
+BBFFFFBLRR
+BFFBFBFLLR
+FFBFBBBRRL
+FBBFFFBRLR
+FFBBBBFRRR
+BFBBFFBLLR
+BFBFFFBLLL
+BFFFBBBRRR
+FBFBBBFRRR
+BFBFFBBRRL
+FBFBBFBLLR
+BFFFBBBRLR
+BFFFFBFLLL
+BFFBFFBRLR
+FBBFBFBRRR
+FFBBFBBRRR
+FBFFFBBLLR
+BFBBFBBRLR
+FFBBBBBRLR
+FBFFBBFRRL
+BFFBBBFLLR
+FBBBFFBLLL
+BFBFBFFRRR
+BFBFBBFRRR
+FBBFFBBLLR
+BFFFFFFLLR
+FBBBBFFRLR
+FBBBBBBLLL
+BFBBBBFRRR
+BFBBBFFRLR
+FFBFFBBRLL
+FFBBFBFLLL
+BFBFFFBLRL
+FFFBBBFLRR
+FBBFBFFRRL
+FFFBFBFLLL
+BFFBBFBLLL
+BBFFFFBLLL
+BFBBBBBRRL
+FBBFBFBLRR
+FBFFBFBRLL
+BBFBFBBLLL
+FFBBBFBLRR
+FBBBFFFRRR
+BFFBBBBLLL
+FBFBFBFRRR
+BFFFFFBLLL
+BFBFBFBLLR
+BBFFFFBRRL
+FBBBFBFLLL
+FFBFFFFLLL
+FBFBFFBLLL
+FBBBBBBRRR
+BFBFFBFLRR
+FFBFBFBLLL
+FFBFFBFRRL
+BFBFBBFRRL
+FFBBFBBLLR
+FBBBBBFLLR
+BFFBFFFRLL
+BBFFFBBLLL
+FBFFFFFLLR
+FFBBBFFRRR
+FBFFFBFRRR
+FFFBBBBLRL
+FBFBFBBRRL
+FBBFBFBLLL
+BFBFFFFLRR
+BBFFBFBLRL
+FFFBFBFRLR
+BFFBBFFLRL
+FFFBBFFRRL
+BFBFBFBRRL
+FFBBBFFLLL
+BBFFFBFLRR
+FFFBBBBLLR
+FFBBBFFRLR
+FFBFBBFLRL
+FFBBBFBLRL
+BFBFFFFRRL
+FBFBBFFLRR
+FBBBBBBLRR
+FBFBBBBRRR
+FFBFBFFLRR
+FBBFBFFRLR
+BFFBBBBRRR
+BFFFBFBLLL
+BFFBBFFLLL
+BFFFFBBLRL
+FFBBBBBLLL
+FBBBBFFRRR
+FFBBFFBRRL
+BBFBBFFLLL
+FFFBBFBRRL
+BFBFFFFRLR
+FBFFBFBLLL
+FFFBBFFLRL
+BBFFBFFLLR
+FBBFBFFLRR
+FBFFBBBRLR
+FBFFFFFRRL
+FFFBBFBRLL
+BFFBFFFLRL
+BFFBBFBLRR
+FFBFBFBLRL
+FBBFBFBLLR
+BBFFFFBLLR
+BFBFBFBLRL
+FFBBBFBRRL
+BBFFBFBLLR
+BBFFFFBRRR
+FFBFBFBRLR
+BBFBFFFRLR
+FBBBFBFRLL
+FFBBFBFRRL
+BBFBFBBLLR
+FFBBFFFLRL
+FFBFFBBLLL
+FBFBBFFLLR
+FFBFFFFLRR
+BFBBFFBRLL
+BFBBFBBLLL
+BBFBFFFRRL
+FBBBFBBRRL
+BBFBFBBRLR
+BBFBFFBRRL
+FBFBBBFLRL
+BFBFBFFRRL
+FFBBBBFRRL
+BFFFBBFRRR
+FFFBBBBRLL
+FBBBFFBRLR
+FBBFBBBRLL
+BFBFFBBLRL
+FFFBBBFLLR
+BFBBFBBRRR
+FFFBFBBLLL
+FFFBBBBRLR
+FBFFBFBLLR
+FBFBFBBRLR
+FFBBFFBRLR
+BBFFFFFLLL
+FFFBFFBRLL
+FFBBBBBRLL
+FBBFBFFLLR
+BBFFFBBLRL
+FBBBFBBLLR
+BFFFFFFLRL
+FFFBFBFRRR
+BFFFFFBLRL
+BFBBFBFLRL
+BFBBFFBRRL
+FBFBBFFRLL
+FFBFBFFRRL
+BFFFBBFLLL
+BBFFBFBRLR
+BFFBFBBLLR
+FBFBBBBLRL
+FBFFBFFRRR
+FBFFFBBRRR
+FBBFFBBLRL
+FBFBBBBRLR
+BFBBFFFRRR
+BFFBBFBRRL
+FBBFBFFRLL
+FFBBFFFRLR
+FFFBFBFLRR
+FFBBBBFRLL
+FBBFBBBLRL
+BBFFBBFRLR
+BBFFFBFLLL
+BFFFFBFRRL
+BFFBBFBLLR
+FFBFFFBLLR
+FFFBFBBLRR
+BFBFFBFLRL
+BFFBBFBRLL
+FBFFBBFRLL
+FFBBFBFLRR
+BBFFBFBRLL
+FBBBFFBRRL
+FBFBBBFLLR
+FFBBFFFLLR
+FBFFBBFLRR
+BFBFBFBLLL
+BBFBFFBLLL
+BFFFBBFLRR
+BFBBBFBRLL
+BFBFBBFRLL
+BBFBFFFLLL
+FBFFFFBLRR
+BFFFBFBLLR
+FFBBFFBLLL
+FBBBFFFLRL
+BFFBFFBRRL
+FBBFBFBRRL
+FBBBBBFRLR
+FBBBBFFLRL
+FBBBFBFRRL
+BFFFBBBRRL
+FBBFBFFRRR
+BFFFFBFRLR
+BBFBFFBLRR
+BFBBBBBRLR
+FBFFFBBRLR
+FBFFBBFLRL
+FBFFFFBLLR
+BFFBFBFRRL
+FFBFBBBLLL
+FBBFFBFLRR
+BFBFBFBLRR
+FFFBFBFRRL
+FFBBBBBLRL
+BFFBFFFRRR
+FFBFBFBLLR
+FFBFFBBRRL
+BFFBFFBRLL
+BBFFBFBLLL
+BFBBFBBRRL
+FFBFFBBRLR
+BFFFBFFRRR
+BFBBFFBLLL
+FBFFFBFLLR
+BFBFFFBLLR
+FFBBBFFLRL
+FFBFBBFRRR
+BFBBFFFRLR
+BFFFBFFLLR
+FBBFBBFRRL
+FBBFFBFLRL
+BFBBFBFLLR
+FFBBBFBRLR
+FBFBBFFLRL
+FBFBFBFRRL
+FBBBFBFLRL
+FBFBBFFRLR
+FFBFFBFLRR
+BFFBFBBRRL
+BFFBBBBRLL
+BFBFBBBRRL
+BFFFFBBRRL
+BFFFFBBLLL
+FBFFFBFLRR
+BFFFBBBLRL
+BBFFBBFLRL
+FFBBFBFRLL
+FBBBFFFRLR
+FBFFBFBRRL
+BFBBBBBLLL
+BBFFBFBRRR
+FBBBFFBLRL
+BFBBFFFLLL
+BBFFFFFRRR
+FFFBFFBLRR
+FBBBFBFLLR
+BBFFFBBRRR
+FBFFFBFLLL
+BBFFFBFRLR
+BFFBFBFRLR
+BFBBBFFRRL
+BFBFBBBRLL
+BFFBBFBLRL
+FFBFBBFLLR
+FBBFFFBLLL
+BBFBFBFLRL
+FFFBFBBRRR
+BBFFFFBRLL
+BFFBFFBLLL
+BFFFBBBLLL
+FFFBBFBLRR
+FBBFBBBLRR
+FBFFFBBRLL
+FFBFFFBLRL
+BBFFFBFRLL
+BFBFBFFRLR
+FBFBFBBRLL
+FBBBFFBRRR
+FBFBFFFRLR
+BFBBBFBLLR
+FBFFFBFRRL
+BFBBFFFLRL
+BFFBBFBRRR
+BBFBFFFRLL
+BFBBBFFLLR
+FBFFBBBLRR
+BFFBBBFRLL
+BFBBFFFRRL
+FFFBBBBLRR
+BBFFBBBRLR
+FBFBBBBLLR
+BFFFBFBRRR
+FBFBFFFLLL
+FFFBBBFRRR
+FFBFFBFLLL
+BBFFBBBRRR
+FFBFBBBRLL
+FBBBBFFLRR
+FBBFFFBRRL
+FBBBFBBRRR
+FBFBBFBLRL
+BBFFFBBRLL
+FBFBFFBLRR
+FFBFFFFRRL
+FBBBBFBLLL
+FFFBBFFRRR
+BFBFBBFLRL
+BFBFBBBRRR
+FBFFBBFLLR
+FBFBFBBLLL
+BFBFBBFRLR
+FFBBBFBRLL
+BBFBFBFLLR
+BFFFBFFRRL
+FFFBBBFRLL
+FBFFBFFLRL
+BFFFFFBLLR
+FFFBBFBRLR
+BBFBFFBLRL
+BFFBBFFRLL
+BFBBFFFLRR
+BFBBBBBLLR
+BFFBBFFLLR
+FFBFBFBRRR
+FFBBFFBLLR
+FBBBFBBRLL
+BFBBFFBLRL
+FBBFBBBRRL
+FBBBBFBLRL
+BFBBBFFLRL
+BFFFFFBLRR
+FBFBFFFRLL
+FBFBFFBRRL
+FBFFBFFRLL
+BFBFBFBRLL
+BFFBFBFLRL
+BFBBFFBRRR
+BBFFFFFLRL
+FBBBFBBLRL
+BFBFFBBRLL
+BBFFFBBRLR
+BFBFFBFRLL
+FFBFFFBRLL
+BFFBBBBLLR
+FBFFFFFLRL
+BFBBBFFRLL
+BFFBFBBLLL
+BBFFBBBLLL
+BFFBBFFLRR
+BFFBFFFRLR
+FBFBFFFRRL
+FBBFFBFRRL
+FBBFBBBRRR
+BFFFFFBRRL
+BFBBFBFRRR
+BBFFBFFLRL
+FBFBBFBRLL
+FBFBFBFLRR
+BBFFBBFRLL
+FFBBBFFRRL
+BFFBBFFRRL
+BFFBFBBRRR
+BBFFFFFRRL
+FFBBFBBRLR
+BBFBFBBRRR
+BFBFFFFRLL
+BFFBBFFRLR
+FFFBBFBLRL
+BBFFFFFLRR
+BFBFBBFLLL
+BFBBBBBLRR
+FFFBFBFLLR
+FBFFFFBLLL
+BFFBBBFLLL
+BFFBBBBRLR
+BFFFFFFLRR
+FFFBFBBLRL
+BFFFFBFRRR
+FBFFBBFLLL
+FBFFFBFRLL
+BBFBFFBRLL
+BBFFFFBLRL
+BBFFBFFLRR
+FBBBBFBRRR
+FBBFFFFLLL
+FFBBBBBRRR
+BFBFFBBLLR
+FBFFFFFRLL
+FFBFBFFRRR
+FFBFFBFLLR
+BFBFBBFLRR
+FBFBBBBLRR
+FBBFFFFLRR
+FFBFBBBLRR
+FBFFFFBRLR
+FBFBBBFLRR
+BFBFFFFRRR
+FBBFFFFLLR
+BBFBFBBLRL
+FFBBFFBRRR
+FFBFFBBLLR
+BFBFBFFLLR
+FBBFBBFLRR
+FBBFFFBLRL
+BFFBFBBLRR
+FFBBFFFRRL
+FBFFBFBRLR
+FBFFBFBLRL
+FFBFBBFRLR
+FFBFFFFLRL
+BBFFFFBRLR
+FBFFBFBLRR
+BFFBFFBLRL
+BFBFFBBRRR
+FBFFFFBRRL
+FBFBFBBLRL
+FFFBBBBRRR
+BBFFBBFRRL
+FBBFFBBRLR
+BFFFFFFRLR
+FBBFBBFRRR
+FBFBBBFRLR
+BFBFFFBRLR
+FBBFFBFRRR
+FFBBFBBLRR
+FFFBBFFRLR
+FFFBFBBRLR
+FBBFFFFLRL
+FBFBFFBRLL
+BFBBFFFLLR
+FBBFBBBLLR
+BFFFFFFRLL
+BBFFBBBRRL
+FBFBBFBLLL
+BBFBFBFLRR
+FFBFBFFLRL
+FFBFBBFRLL
+FBBBFFFRLL
+BBFFBFBRRL
+FBBBFBFRRR
+FFBFBFFLLL
+FBFFFFBRRR
+BFBFFBBLLL
+FFFBFBFRLL
+FBBFBBFLLL
+BBFFFBFRRL
+FFFBBFBLLL
+BBFBFBBRLL
+BFBBBFBRRR
+BFFFFBBLRR
+BFBFFFBRLL
+BFFFBFFLRR
+BFFBBBFRLR
+FBBFFFFRRR
+FBFFBBBLRL
+FFBBBFFLRR
+FFBFBBBRRR
+BFBBFFFRLL
+BFBFBBBLLR
+FFFBBFFRLL
+FBFBFBFRLL
+FBBBBFFRLL
+FFFBBBFRLR
+BFBFBBBLRR
+FBFFBFFRRL
+FFBFFBFRLL
+FBBFFFBRRR
+FBBFFBBRRL
+BBFFFBFRRR
+FFFBBBFRRL
+FFFBBFFLLL
+BFBBFBFRLR
+FBBBBBFLLL
+BFBFBFFLLL
+FBFBFFFRRR
+FBFFBFFRLR
+BFBBFBBLRR
+FFBBFFBRLL
+BFBBFBBRLL
+FBBBBBFRRL
+BFFFBFBRLR
+BFBBBBBLRL
+BFFBFFBRRR
+BBFBFBFRRL
+BFBFFBFRLR
+BFFBFFFLRR
+FBBBBFBRLL
+BBFBFFBRRR
+BFFFBFBRRL
+BFFBFBBRLR
+FBBBBFBLRR
+BFBFFBBRLR
+BFBBBFBRLR
+BBFFFBBRRL
+FBBFBFFLLL
+FFBFFFFRLR
+FBFBFFBRLR
+BFFFBFFRLL
+FBFBBBFRRL
+FBFBFFFLRL
+BBFBFFFLRR
+FFBFFFFRRR
+BFBBBFBRRL
+FFFBBBBLLL
+BBFBFBBRRL
+FFBFFBBLRR
+FBBFFBFLLR

+ 14 - 0
aoc2020/5th/main.jl

@@ -0,0 +1,14 @@
+input = readlines(joinpath(splitdir(@__FILE__)[1], "input"))
+
+ids = input .|> x -> foldl(replace, ["F"=>"0", "B"=>"1", "L"=>"0", "R"=>"1"], init=x) |> x-> parse(Int, x, base=2)
+
+function max_id()
+    maximum(ids)
+end
+
+function what_seat()
+    setdiff(minimum(ids):maximum(ids), ids)[1]
+end
+
+println("max id: $(@btime max_id())")
+println("what seat: $(@btime what_seat())")

+ 2050 - 0
aoc2020/6th/input

@@ -0,0 +1,2050 @@
+jmqnkzlsfedaptx
+usjfkadqwmeyilph
+
+lodbmhvcaset
+wcognbeaxhmvdt
+
+f
+f
+f
+f
+
+dwxfircztpyshol
+dogfryaxtlhzscw
+gwchdzyftolsxra
+thrdwcxfosqzyl
+rholzdwctxfsy
+
+dbifho
+zmdh
+hobd
+
+iqjdvpxyfremnbzuohglc
+dpohfyzjqicbnegrmuxvl
+uromlgbqyjznecvpxhidf
+cyebghlzpoiqmrjfxnudv
+vjgzlpbfondxrceyhqimu
+
+mpxsao
+oxasmp
+rzxqokamp
+
+bigjutwl
+
+rdcwfenzhlos
+gzorslxh
+marjhzqbipoukvls
+
+fdclagjkvrmwxqyszupnoethbi
+zdiyfcuahnkxewltsgqrpbj
+derbpujchxlqfngtaskzwyi
+
+gyx
+yg
+gx
+fgver
+
+nb
+bo
+
+efruscbgipldnvhkmj
+nurivmpbcjhdlgeks
+dejbncphmrugwilosvk
+rdshekcjvpulmnigbx
+ceylvdjbrtmipukhqsnagz
+
+brel
+sre
+
+mrswukndjx
+bpdmzfueco
+
+pdlmyaghtbokvncwfej
+awetylgcdvojhfbknpmz
+hdcelimjygvtfbonkpa
+
+phqa
+nprhzw
+ecilsgmtyxhupbofd
+
+czilhqfowdmx
+ozlhficawmx
+lnhfzsxcwoim
+hzlfoxawcim
+
+efrhjzslqoptycnda
+teszplncraojhqydf
+fqshytjplrcnodaz
+fpanjlzrocstmqydh
+qvclarztynpdfjsguoh
+
+tsazpikyfb
+vprgizekaucq
+kdlowxhnzamj
+
+lnyr
+pnyl
+lny
+znly
+
+tlsp
+tdpl
+ktpl
+ltps
+wvqtzlep
+
+zvpyqm
+xn
+se
+sbt
+
+itwldrhevjpsxfmyugkaoc
+olaxpdtfgrewkjcsyuhimqv
+sdeokjvhucplgyxtimwafr
+tjmliweuykfvcrspaxghod
+ufcesrkohxtipmjaylvwdg
+
+g
+g
+
+eopcfqntlsxbrmwjku
+xcybqjknurefsptwl
+entfcwuxqbkzljrps
+ufkxaincsdjbelrwhtqp
+fwsnekcrtxupjlqb
+
+gpwuyvtmefadj
+ujaiwdetfyvgmp
+mvdajpgwfeuty
+fptkgamuveyjdw
+
+pqelcgwyksmhx
+wxlpghsqmnykec
+hlkcbfyemwqpgdx
+
+hflgy
+hgfl
+vfhlgp
+hlgf
+
+qfecvy
+yefcvq
+yqvfec
+
+vgioynksz
+kgzsivyo
+vosigzyk
+
+r
+r
+t
+pz
+r
+
+smcejxgypzldar
+pfjevtgrowiqmxbnc
+
+wsk
+iwks
+wks
+ksiw
+ksuaw
+
+bnxp
+penx
+jnxqpgl
+pxcn
+
+itdaowjkclxvuzgyprb
+vbagupycikozjrtdwxl
+
+jtokzdhpiy
+pyhzjdikt
+ihzmdjyktp
+tjdihkzpy
+yztkdpjhi
+
+zpamwnubtx
+ymznbwtu
+
+zcxrublkn
+nlrxubkz
+
+hqtc
+vedjnxuosriz
+mp
+lk
+
+w
+w
+w
+y
+w
+
+lsiphdnogwcjvx
+ayxwtvqcogldn
+
+rcxas
+xcswy
+
+ekxyfmurzcqhsojg
+xshfumlkqrcytejo
+uosqjyfihcxkrme
+imorjfsxqcugekhy
+uxrysjmqhkcofe
+
+uhn
+hu
+uhyd
+hun
+mhru
+
+rowzbpfcxvtaudlmnsygike
+wnqbtsaplrxkyedzvfui
+ntrkabpixsuqfvzlhewyd
+
+ixzyehksfb
+exifbzyksh
+bjyzfieskxh
+wxyhikrsnezvfb
+hzkbfsexyi
+
+rdtenu
+xudh
+hud
+udx
+ud
+
+tqinldjgzhyosm
+glnipmzoyqhts
+hitsylzgqmon
+
+fgmxvubwisltn
+emxtwfnqdbvisl
+lsmftnbvxwi
+vlnwbstzxrimf
+
+hxopuygnmsjfzketdliwr
+lerzsoghdiuwfxpjtbymnk
+ysmkdrgwpxujztnohlife
+
+ubwsf
+tpzwehnikrgyjl
+
+uongl
+nolug
+luvnog
+glonu
+onugl
+
+c
+c
+
+qhflxwpb
+cfx
+fuzxng
+tfxah
+
+ctfzbwdmv
+mvtaowgk
+motwvx
+wtimv
+wotmv
+
+bkxz
+awytslxgcj
+
+ohyx
+oxh
+xho
+xho
+
+wrziyfnpqm
+tjysexk
+
+xvqnadomefi
+miqovedxnaf
+adxvofimqne
+doxqnvafmie
+xnioaevmfqd
+
+mjleo
+aeldc
+tihrlk
+ml
+
+hxdoicvbzm
+omvnxidwzhc
+mzkilcfhudtex
+qrhcdyxvwmzi
+
+i
+i
+i
+
+mrspfekayvo
+fmrysvpkoa
+kdozcmgasfrjypv
+kvfmyrspoa
+bwpsvfamokyr
+
+vrotxenkg
+rokmet
+rekto
+etykrpo
+aetrpmko
+
+ahkbpnglj
+nalbqgpjh
+
+ardusw
+duwars
+rduasw
+auwsdr
+
+v
+b
+d
+b
+d
+
+alycurnjmw
+msjdtwurqkypev
+iurcfhmjywx
+
+vkgiz
+lnvzcdkj
+bmqarwto
+
+sdye
+sdye
+esyd
+
+vwljec
+zydxaenitwj
+jerwohg
+jregbwh
+
+idzerxjavywb
+fxawvzjriebo
+lsbwgqaicuepxzrjmvt
+jrbzdwivxea
+
+paegsh
+oagshetpj
+eapghs
+
+nsa
+snma
+san
+nsa
+ans
+
+klctpn
+kzp
+pce
+mpgbfqory
+ecnp
+
+pjhztrfdnax
+zlhstupnbfajxdri
+rkztopwdqnmxyaejfc
+jxfrtapzdgns
+vnjxzratlpdf
+
+jeoqafrcsybmln
+fiqjnmasrxky
+snvqjryfamt
+fanymhjrsq
+
+xfshvyz
+nluwirzdfehxpmtqv
+
+yxzl
+zpxl
+
+it
+eit
+si
+
+kotcavg
+fgkbot
+krojszy
+tokewgiv
+
+nz
+n
+n
+
+xtehngmdwavqfocisl
+htgwexliqsafvmnc
+
+krjs
+rkjseu
+rjkwbgs
+srjk
+
+mksdca
+whetbmv
+
+bnckvzhdrwi
+azbtvlqjymn
+bhzcnkv
+
+jgcwltupqdmyiobnkxfeh
+digkmftlyxoqjcwhepunb
+iyejcnutgbohwdmfkpxql
+
+fnudjpocvl
+ylupojvxk
+
+etadjxh
+ealvymb
+ecmuybva
+mlaneqr
+
+iuetgj
+egj
+
+ovwaedbjungzi
+goczdweuv
+edjzsorywu
+odfmzteqxuphwk
+iuldwevoznj
+
+kuafxo
+kfubnx
+xkuy
+
+szbrnetfcmygqahop
+bhmqfzctorelpagy
+afemogythkrszcqpb
+
+oazfxmulgki
+lmagfukdzqx
+iudmgelxcqkfaz
+ujkzgfnarmxsl
+lxptkgwmfazuy
+
+ge
+ibjufwpt
+
+er
+rte
+re
+
+lmiugtfa
+isqokgfmybja
+imvefghaw
+mngcaifz
+
+pkdgzocuen
+aqyjrongpiszdwk
+
+rhsjtnv
+nftzhudvm
+clhtvxrn
+otchwyvn
+
+obr
+tbnha
+bek
+tbve
+bvh
+
+fzy
+yvi
+ys
+
+linyheauvwqczfgxbm
+mfvglhieqwxrubny
+xuqemsiyldobgvfnw
+
+wtlp
+kyr
+
+sxqecjzagtn
+ntvpjxsciqzkga
+jltghzxydqsmwca
+
+tayqzsou
+mhfbjkpngexvt
+
+tulkjgfcb
+bfmgucijtysl
+jlocdagt
+jlcpenqrhzvtg
+cyxfjmgltwu
+
+ifxsclutj
+vxscjuidfl
+icxfusjl
+ijculsfx
+
+nswkzpixhaojlruyq
+akxjqrysohpiwl
+xarqyepwlsgikthoj
+lpqoxmkjaityhrsw
+sxhjrwalqiypeko
+
+maisrcxbwdtezfokqyunh
+agsqmexkuyrodhb
+ehoxduarylskmqb
+oesydbkaumhrxql
+msyuvhokbexpqard
+
+yxnqvzglspecmathrb
+gbnarexvolhmyspq
+xblvqgpsfahmner
+
+ewnudklzmvxqcs
+xcspjzvmbhrtulk
+
+vfzgpomk
+zqgkrfopmhv
+evzomkgxslip
+vzhkopmyg
+
+djoebyfurmnsczlapwhxtigvq
+ahzdbvqljmpfcwskytuiogr
+
+wyubqtslnxrkhjgfvi
+ivlsqkfbtrjgyw
+
+zj
+u
+k
+bemnplisa
+u
+
+kqr
+h
+p
+czh
+
+nlwyij
+njawiy
+
+dmjtlipsqafwoezuxbrhkc
+lzbwfusqdcrexaitmjkph
+clpawkxbeifzdqmvhjsrut
+gtxahqnzkbrpecuyfldswimj
+sbzehxlcdtruafwkimpjq
+
+vjlpwzocebkinmdaxtfsh
+xtvnfekwdlhoj
+jdovxkheunfltw
+eylqghtonxjdfwvk
+
+yvflxdbuaswtkj
+ubatvydkwjfx
+dtfkwvxaybuj
+dwbftxakyjvgu
+
+fitncsg
+tfgnisc
+gnscfti
+cfsmtngi
+tscfing
+
+pqiynka
+xjcuolmgtzwedrs
+
+pjtfwa
+v
+
+ftaexgsbwmryph
+ubfilnqyxamd
+mjfayxlidbcou
+
+phftai
+aptighf
+taphfi
+
+zhvdutaxgyjcfp
+cvzjtygfhpdu
+dtzvphgcyjfu
+
+ey
+y
+y
+
+mhguzvyxtbnorf
+bynmexr
+bynxmer
+
+teagprlboyfcjw
+rptxbeyjfakwlg
+yarpftwkljegb
+fpkeltybjragw
+
+akmbegwrtiszpqjclvy
+hkqbmvnyir
+irhvmqyokb
+bvqkyimrf
+mbkoyxrivqdn
+
+yigkdnrmowxsje
+jsigwnorxdmeyk
+wjxengdiorskmy
+
+wfqlmzv
+tbposdrkhaygx
+
+xdpu
+a
+cbq
+p
+
+kwveirgajyxcb
+urkyvzwcibpexq
+kwxvbcyeri
+ciwxryekblv
+
+cezbkty
+bytezckq
+iekgzxytbc
+ecykztqb
+
+ojpru
+apouxrj
+ofzrjpu
+pjiruxo
+
+lepmrvdqajo
+peqnvaousjhmflb
+
+apkzlh
+clrp
+jpfvyiune
+
+kzonxufgedqjcvp
+ljtypdihbrscmxguv
+
+hztgrdkfbuilowmsepvncyj
+yjzciltueoshvbkfmdgnwr
+jbswehmkiyvgdnzurotlfc
+xgqrhwsozelnyvudmftbkacji
+
+i
+cyeti
+i
+
+gahjt
+thbljy
+yjht
+
+jvzdynegqkf
+onyvlzfse
+fvyezncw
+nmezwuvyf
+
+dz
+zs
+z
+
+inrhgtdplvmqbykjfew
+niuwhdabevcflpqmt
+
+rndbqw
+wnrcdqb
+
+lqugyhvmpsbdicj
+hnvqsilpbcgju
+pvbscrqalhigjux
+spcqlabijhguv
+spagvcqbuhilj
+
+drmfvibstegqjku
+mveurqfjsdgtik
+rmqdifjkvsegtu
+ymdifkvtsquejgr
+
+ocknfiw
+pqtukinymcaow
+owkcnsi
+
+wfydm
+mhflywcd
+
+zoxdfl
+rjbmwai
+
+orikvxpg
+kiubgrmxvpo
+vokgcxirp
+povkrigx
+
+yjdir
+zyudejri
+jyrdi
+jdyri
+
+iqg
+igq
+iqg
+gqei
+
+gxyapsbkotzmjuwfnrqd
+rbjuwaifmgykxdevpq
+prdbgwmkhfanjyxqlzuc
+
+cz
+zc
+
+xgdrpnmzq
+xsqhflioukzevba
+gdzycqxmwt
+
+ksthb
+hutjfk
+htbzkj
+ipdghalotk
+
+z
+f
+f
+f
+
+h
+ius
+
+y
+yjd
+y
+y
+
+amv
+mefva
+avm
+vma
+avm
+
+dsgce
+gvcdsweplb
+mhdgcfjaury
+
+klg
+lgkx
+kgl
+
+afxcimest
+mfcaxstie
+acmseitfxkh
+xmifsacet
+sxicetafm
+
+hvenw
+envhw
+bevhn
+ndhysev
+
+d
+dvj
+cf
+q
+
+pcymvj
+pmvcj
+vpctmrja
+cvmpj
+
+slywjaeqovbduzg
+fvprxbztdnisolcme
+
+njlwgdhtpmqv
+hlmcbgpfditvqwyza
+
+drichegunkzsxaob
+ashvyqigbzekjoxrmcdu
+iabkzdgsrxechoul
+
+gswcar
+rwasgc
+hcwrsga
+srwacg
+
+lmroa
+ml
+rlna
+lbkvxy
+
+cm
+cm
+
+iuljnorfsapxceztmbwhd
+tyemwsnpjcbolqzifhrxau
+ujpsfzamicorxenlbwghdt
+
+aqibdv
+qvceadli
+qvaid
+daviq
+
+weyaps
+eswyka
+
+othfcp
+qrplshxf
+hfp
+
+noegrjpfakyuxlbi
+xfunzlrhgykijdpae
+npjgilaykufrhex
+nqfkxlryaoejgpiu
+nspyigjltxwvmcuakerf
+
+pdqk
+pkqd
+qpdok
+
+onqriyzefvwat
+pbgjslwd
+
+ojhuntyxkvisg
+touknjhyigrsvx
+
+upbozynctgja
+gjouyzenc
+
+dhefoiyrxwbajt
+fairhbtjywlxdops
+adxfhtiybojw
+tbyhixjwanfdo
+ibyomdtkwjfhxa
+
+sevowj
+safehvyoxw
+svoewt
+jvsewio
+woevs
+
+ibqj
+qjfb
+bq
+cbnwlqx
+
+abhzxvqlrcjkmswgoynifpdet
+upqvrzwfglaknioymtsbdhexj
+rzeswobatkxqnlmyidjghvfp
+rxmglhojqdtzbaeisnvkfpyw
+zehtiqfslvpxkodgwarmjynb
+
+ajrfuhtq
+nsf
+pifoycz
+cgvefo
+
+ufpzi
+axu
+wu
+qtdul
+gfu
+
+qlfyskwebuzindcxmjohp
+ydpznsqokiahbmcfeujwx
+bogpjmfnyclizxkwsuhdeq
+jezbdocqskpxynwhmuif
+
+bdvrmazgpno
+gmbantdurp
+
+vawrthce
+xpfcobhrzlatv
+avethrc
+vhtqrac
+
+lsue
+euils
+esul
+luse
+
+rtcangphwi
+hvlacwoftepnx
+
+vkdmr
+dlvtfrkmozshg
+bmdvrk
+uadbmkrjv
+dmvexrkjp
+
+jinbek
+jknieb
+jnkeib
+kpiebnqj
+jekibn
+
+kfecmdalsjuo
+ntjicfxguey
+
+zviloscfjeywmuqgnh
+lgizmhjqcounvy
+ojhizcmvlnyguq
+vchmnoyiuzqjlg
+
+oqrwpzi
+oipzuq
+
+vpf
+pfvx
+paf
+
+wrl
+cfmrubxoap
+
+nqufrlhkgzavmjwx
+rvhmcpjlatfugwzqkn
+umqznjfbglkvwarh
+
+uaqvoxngrhkwpejtczsid
+tujpcvwhkdsxzqoinelag
+
+lypwa
+wa
+
+eyiukqb
+fibueqyko
+
+zxoatgsyfjv
+stzgvxyafo
+ystzfogvxa
+yotxzafvsg
+xtygovfsaz
+
+ojz
+joz
+opqzdcjsyre
+
+x
+x
+x
+x
+x
+
+rc
+fcr
+
+i
+i
+ronsi
+i
+i
+
+e
+g
+dqzls
+rm
+
+fxkvlgbtmnryusaidheo
+nrylbusaoivfkxdmehgt
+advjqoynebcirkwtmhlxzufg
+
+zdqlbwhaio
+dclkpzihborwxqa
+adowihbzlq
+
+fzgmpsnjvqudy
+pvsyznmfdjqugw
+amfsjduvygnqpz
+ympsvndqzgjuwf
+qfmxvspzdjgcyoun
+
+akjpwio
+hcbm
+
+zrcxphil
+cihbsgxlzypa
+txlhsumizc
+qikzldwxvhcnf
+
+otnqmblawiuyzpekch
+ztceiqnakymuwblpho
+biaehczpwoklumxynqt
+tekznibhmcqypluaow
+zlmteknopqwcuibyah
+
+lbmdvpyquzehwo
+yjrhivaxkopsbzgft
+
+ijbqampfcnyhluxg
+cbqdijhumyxpagnfl
+gfncxwjulpqmyba
+
+vqfjaklcpsxn
+sknqbcepz
+
+dvejbmfk
+pkmfjevb
+jmfbkves
+emkbfjv
+ejvmbsfk
+
+q
+j
+p
+j
+
+fzahk
+khfa
+fhak
+hafk
+ahkf
+
+mrtvwxd
+vrxpw
+
+sz
+zb
+z
+z
+zd
+
+umynwrjvdbxfgtoiazhskec
+azocfmxwbsiyutnhkdvergj
+bimekgvzhafnutodyrxscjw
+rzscbaxwdvteoniumykfgjh
+
+wixlhoqnkfecr
+ntlyfkrwgziceh
+isfluhxknrcbew
+
+egnrfpwuvcys
+vruygnfkeosw
+yuqsfmkgnepvr
+zdvutrsljxeygnf
+gqfpiersynuv
+
+rpenvsx
+rvyepxsn
+nxpersv
+srpvxne
+spezcjxrkdnv
+
+kyjgzoub
+ygzkiusoba
+ybzjougk
+
+yenijuv
+nehjoyiuv
+
+cx
+ctx
+xc
+xc
+fxkyc
+
+yuf
+yetf
+yf
+
+lcerywpto
+uryte
+eytr
+veytr
+rtye
+
+skrfb
+rmscwgk
+fkrnjs
+krvs
+fsrken
+
+lnapgo
+nop
+opn
+
+cmwslaozbxtidn
+xctbiadnmozlws
+zdilnxobsactmwq
+bwxcnszldiotam
+zspaxcrityodmlbnw
+
+qknijt
+jipqknt
+njtqkir
+ktnjiq
+iknqjt
+
+awekvcdlzxufpbt
+ucvjprwldkzbafxme
+lmkxwefudvpjarbz
+axsfpnbwkvlzyoegud
+
+vpykichglsernwudt
+cvtkuypidlwhersgn
+
+qowbdgthv
+hwdtgovbrq
+hdbqtwokczv
+
+vgmnarhkiqxybpj
+abgjkqmrxypnvih
+rhpaqvjxidtkmbngy
+xpybkgqijrnhamv
+
+u
+u
+u
+u
+u
+
+bczhrlgvy
+bxdswtfzmka
+ozbge
+
+wy
+xte
+bunkexi
+magp
+
+wchuym
+youcw
+cuyto
+cuywqro
+xnygieuc
+
+htlxjfmbi
+mtxiqjfhbyl
+
+chsuf
+d
+vymtlxr
+xto
+kvm
+
+iegprozq
+zoqpegir
+gzepiroq
+
+pqjbvedxiscft
+cztpxsfkjv
+jtpzxfyacnsv
+fkhtulcpxsvj
+nxypcvtflsj
+
+mbaeyinswvcjdqpflro
+wyfivehtpalrjqdbmusnco
+fdoipmenabsyqjrcwvl
+
+sxumcri
+xeupbrfimg
+
+rvytkuzxhwj
+kywbxrzjuvth
+jkryxuvnwzht
+ktjnrhpuvxwzy
+
+pfuozncwalsv
+iloasnzmuc
+
+eamjzlcgrpytkwvdf
+mgyrezadjpkwfltcvn
+djplwrmyzgetfacvnk
+ryzfmpagjwcltedvk
+kezfgywvmltjarcpbd
+
+unwsrlpbfqgikjx
+kuewiqrfsgvbnjxpl
+smgnakxrfjpliwuqb
+
+rpjdloambtxiueskf
+ultjriaoxbdgwspkm
+amtlkpsjuibdrox
+bjcikursxmaolepdt
+
+dcrhitjplqmbsz
+vjwrdktpclszhb
+
+aknpdwxzyob
+cbmepxzanwghlod
+dftnzywxvobap
+tpzaxwondb
+
+skvfhqjwc
+jvhfkwacq
+
+rxhlqpsv
+uoksgfhqmxwpct
+qhvjpibsdnzxl
+qxypisahb
+
+ucxhazo
+hoazcux
+xhczoau
+azuoxch
+ucohzax
+
+jroudctikylaz
+uikajctloyrzdh
+ztudariclkojy
+yuakrlocjdzti
+
+ibjgyheqtsfaokl
+jnkxcrpfdwuvg
+
+bgdcwmliqapr
+zmnjtrfciskue
+
+wrftzpxjbedniahscvguy
+ztcvwbdiphryfsajegxnu
+wjtnafcrsvyzpgdxubqhie
+fjxazirvdgynetwhbcusp
+rpwhyadfvecsxgijnlutzb
+
+ixsafmqz
+gckxfzuq
+hbqxfz
+
+btrkgnadzs
+qdkwgstpfzv
+hdieoxugzsj
+
+gf
+fg
+fg
+gfe
+
+ieqgstfyzmvc
+sbfvgjt
+atsgvf
+gfsvt
+
+unktjiwsgfxvqh
+wvbsikqmxjhtufng
+iqhvkwxslutjfneg
+ivqcujwngkxhfst
+fixvhqtkusjnwg
+
+jyeizdhnr
+lfzdwes
+
+sfnwxrhomibjk
+jknewldztvcrsfmohi
+
+bsnkyeljzihrvoq
+jslzbqowfvekym
+
+nhysveaf
+mpfcoa
+foam
+
+adcj
+jyc
+jvad
+mkj
+
+ynoflmsi
+mlzrfspi
+
+djmqatpxs
+stdmjxqa
+
+jwdx
+myplugwjs
+hwjbd
+wajxb
+
+zpstmcdyijohqwexl
+wqxoecpdihmszyjlt
+eqxmpywisjchztodl
+
+wcntrjpyubmdoeazh
+cepthmbdzoynajrws
+dnorwhbpqycetmjza
+zncmybxroipjatweh
+
+teobkvdywzmrq
+yedjkgrofnvwtxb
+oyewkrxftbdv
+
+gdxqht
+thd
+thd
+
+ornwqcgvfm
+rgnvwqofmc
+
+lgmkvjudyiobrfcehazs
+idgzlokpbfhaujrymcsve
+vhikocutjbsedrlamgyz
+
+upafbl
+bfaukpl
+
+jzytn
+nft
+mnftz
+qetna
+hlcwpxigotd
+
+ugiyjvlpeasw
+qznlpu
+umctqnplrd
+fxkqphblu
+
+urjsc
+ecjurxsi
+rcsljeu
+jsurc
+nsvzbcjur
+
+shgtowmxzue
+voedwskmhuajq
+sompeirfyc
+
+lofiwgavbxpdmrj
+gjxbowprfaldmvi
+rlwiafvjxdgompb
+xvprgwoafmjdlbi
+moildgafjrwvxpb
+
+orqmykigx
+gximohqyr
+mqygxori
+qymriogx
+
+bw
+wutak
+oxsdf
+rupqm
+ehm
+
+zvjibpa
+ptgyzvild
+itpzvxwnh
+rkuiosqcpfze
+
+viq
+tviq
+qiv
+viq
+qvi
+
+dxpvnchftlqiokejyb
+njayvfqcipxltdhbk
+cdntplibhyvjqkfx
+
+e
+em
+e
+yve
+
+pbkhjxsqwryfgiecavodunmzt
+qxcnposglmrjbvyuzwedftik
+
+yvwtescpiqmbxzkr
+pmcbvytqkzwixes
+wciktumeqzyxbvsp
+wvfpkzysitbcxqem
+
+ctxjqfkyehlpdnimaru
+umayxlticfrnhzweqdj
+
+zandguibwkxcmthy
+vytkfexwczbnumagi
+
+omfjbgiew
+xjufhnoglwicp
+jivdgwokf
+
+uhiforcjt
+tfrsehcbzou
+crfogtuh
+rtguhocf
+ctioufryh
+
+omgzpckleuwhvdixqns
+dkhpognscemaivjwtzlbxu
+mdivfpeczsnguolwxkh
+zfvdhimgplseunwkoxcq
+lmnpkvszheiwodcgqux
+
+zyqmgvetxihro
+odbkpwzxclnsu
+
+vlbcuafq
+ublqzv
+
+bmfvqrhn
+qbhjfnrvm
+hjqbnvmfr
+qmvhnrbtf
+mrqnfvhb
+
+amrvbuxwq
+qxv
+tszixqcfj
+ryxaq
+
+pbaoqmuhtzlnjfvki
+poyaqztfbclkhus
+
+osrkdltnbpcwe
+jfypxqrkdvtoc
+
+iwcng
+hknmzjeribx
+icndgo
+cnid
+gin
+
+qdcglm
+qgdmcl
+cdmlqfg
+qmgcdl
+qdgwlmc
+
+wmksilftz
+ltsmkzfiewq
+slmfwktiz
+wfmzsiklnbt
+itkmsewzlf
+
+lqfeanvdbmxurghpjkz
+bxiqwspehgckamdnyfl
+bnmetlfxhgqdakp
+jqzonfralpxbgedtkhm
+
+ohjlba
+njvolrh
+nhloj
+njlohzg
+qfcyjholk
+
+idntcbergvzw
+benuwdqkvisrgz
+bywroevdgzni
+
+bsmypejhaqwtoc
+bqraoipmnxsyvwhc
+gsmohzqplfiwabyuc
+crpqxsbzdhyamwo
+
+hjiwcpsaem
+acsjihpewm
+pjchaewsim
+mepjcshaiw
+
+phxymeqsgd
+emdgujsoqx
+
+ahjw
+lakw
+wah
+awh
+wam
+
+uqnem
+unqem
+uqmen
+qeunm
+
+mvixeokutywnspjd
+pvondstjybxkuewmf
+mxpevuokjgytnwsd
+
+ljfqzmdtnubo
+edmjungbzfqop
+bmwndujzyqfo
+
+ezpmodywqxgbakl
+txljuwgbedqmzaoknpy
+mwkzxgloyqpedab
+
+jdanqfmbxtzgcireh
+nhfqzrjicdmxabgte
+izeafnmxqtjcrgdhb
+xqtfadmbnzirjhcge
+nmcfeihjxdalbgrqtz
+
+tkcpyamfnqx
+ckhmwnfprqsybt
+
+yzjhtglxoimsnrapevfbwkdcqu
+kjbtvgzlhrmdcsyfeiauoqwpxn
+
+aoinshmy
+fh
+hf
+
+bd
+bk
+b
+b
+bd
+
+zbhvoa
+revhzgbsof
+qzcbvo
+
+k
+c
+
+gsxmitkp
+rqsxkp
+skxp
+skpx
+
+tyfujzvsowxhqblapnk
+atvoflqbpxkhnzsjwuy
+hjasyxbztufwnpqkvlo
+
+rphmgva
+gmjp
+bqnwofsdtzckeiluyx
+
+wikmayl
+hixnymja
+anyim
+ymrntaixu
+ivmogaqybep
+
+cafwzdvb
+bnvmezfjpuqostyr
+lavfcwbgzik
+
+vuekszlxbnoid
+codnzveliyxuk
+
+mesvilyqtkrp
+tiqjyvepsukl
+
+ruicvofq
+uvcfhoqr
+frocuavq
+forvcqui
+
+q
+q
+q
+wq
+
+njbcfkdwsx
+cbyfskwge
+bdowxcsefk
+wprzkiuvmlabfcs
+
+qzbxragvojiysmc
+xfhelp
+
+nemwakchpqvbgzro
+zqvbwrkhcmagoenp
+nchqbaeozrgmvkpw
+eqmbovwcakngzhpr
+rhwzokanpvqbegmc
+
+w
+i
+kuen
+vp
+p
+
+rxjvfqgtam
+xvfasqrdtng
+atbfvqgcrx
+
+egrj
+ergnd
+mvqxrpatke
+hre
+
+o
+r
+ej
+
+eqotfizr
+fioezr
+eznorfmi
+
+einyftdglp
+tlegyfnbip
+
+vnaftgzqyxldpkuhcjm
+jhycgqwxvuznfdpbmlkaet
+pgvkarltjnmzxchfuydq
+hxzsqaltnyfcjmgvkpdu
+zpnhuxagcjdqtfmvlky
+
+juvirnzwohl
+ecps
+bckqpdy
+
+jbgztcyhvidkpmrnfuawe
+jhntweaufcpmizrydbkgv
+dpievumwzfbcarngkjthy
+vrkuhgtwpimncoafdzyjbe
+
+dsqgnwtyf
+fjdvstgwq
+tdgnvwsfq
+gqshfwdt
+qtfolgdrsw
+
+sa
+as
+as
+as
+soa
+
+iyhbzw
+bjwizhy
+qywzbtinh
+izyhcjbwd
+
+kujogydsxtraliqmezbhwf
+ydgrlabhfqizswoxktjme
+fyjorqamgixhkbdlszetw
+hroibgxfmjkweztqaysld
+qrebaikxwzlfjogtdyhsm
+
+zefvicmnptwjsrdaoguk
+xjnrwosmvcbyeklfptzaui
+wsmuajtnrkheopizcvf
+
+tphinkmgfqlwxrdyevcbuzaso
+qelonzuybdxvshtcfpkiagwrm
+
+wjniasqzmecyupvo
+qjewvapfmcxnlyuitzo
+dvzqjruhkyeginmwpaoc
+wozympvnijceqaubx
+lpzwiumecayovjqn
+
+yh
+xc
+xzl
+g
+qz
+
+j
+jg
+jn
+
+gtnerjuha
+hagjvertnu
+rgeahjutn
+jngtherau
+
+pzmvogy
+tdjnxmc
+bsruhakifwelq
+
+qyswkhevrjxplmza
+fkdequwnioby
+
+avgqyxszctedpifhnbowjm
+wotmkxnzavqpicbyjfh
+rlybfxonczvhqmiptwaj
+
+prs
+sp
+csp
+ps
+
+rq
+naowd
+
+zpmfkyuqo
+uzqpymko
+kmqznopuy
+
+ozgdkubisx
+zfbaidhwkgxstycq
+dbmgxnipszk
+gbvxznilsjdk
+
+ow
+o
+o
+qo
+
+wqj
+wtlqxj
+wqjtf
+qjucowa
+qdjletw
+
+ysaglonmkduqerzvixb
+amribxuvnkyodslqgze
+
+vx
+a
+x
+x
+
+cq
+qc
+cqj
+qc
+
+gmkto
+hjiavenz
+mo
+fp
+rkcduty
+
+gprmentzywxdlbqsuj
+yunepgtrqsjlwzmxbd
+ujylsbqgvxnmpdtwzer
+ntmpqedrgysjbuzlxw
+crdujwtymosxgnpzqelb
+
+rzd
+o
+ow
+o
+w
+
+cnbsiowkrlpez
+sjnlbwckprei
+
+ibm
+mbi
+ziu
+
+qiameynpoj
+bijsyczhodtapelqf
+opejqriyan
+oaqygiejwp
+onapeqjiy
+
+lqjhiuyob
+ybhuftil
+
+u
+j
+u
+u
+u
+
+cxhtlekagrpsz
+aoyrtgqepm
+jefwtirguaphd
+puivrgacebnjt
+
+iezamrsjwtgcdh
+ymolpqdzscegtijanwxv
+cmdgijsawetz
+tbdcjiaszuegwm
+agdmwkecijzfts
+
+qbrhj
+vrej
+rjhpa
+jpr
+mylfzudkrtjw
+
+qlxhycegwtadvfjumrnk
+mlscrjtvhufkxdyegawqn
+
+mxuiehsocznyvtd
+nsoevihduzcmxty
+sntheuocxzvydmi
+zcnuxhmoivdetys
+vdhzcslyminexout
+
+nltphyz
+tzyhnlp
+
+chboyxelwdm
+jafztipqr
+kv
+taj
+nspuq
+
+yaog
+jvy
+jkye
+
+ofwcpsnbzejgu
+srboczftpuewnkg
+bgunhokierzpxsfcw
+edwzsihpuxgnobfc
+szxmuyabofvdecnpgw
+
+gtpus
+sptu
+tuvsndqp
+
+ti
+it
+
+jdlnmscgpaebruqh
+pmglrnhcqebajdus
+jbecumrqshlagdpn
+qgpceanuhdlsojmbr
+plcmsbhujrgedqan
+
+uaekpzbgn
+knvxhefcimy
+
+ltvho
+thlvo
+tvohl
+
+egaicytnwvkrsohljxbu
+rvwbxjyasehnickgltuoz
+
+nysofuzrbhcetakmdgp
+trnvygcxzmsubaekd
+
+dhva
+shdav
+vadh
+avdh
+
+piftmjyvorhdk
+zovxaghiuq
+ozvlibhugqew
+cwhlivxo
+iqhgosbv
+
+icaxyjb
+rklpxgq
+tzrmx
+xfmvn
+zvexd
+
+uezd
+dfbze
+yedzv
+deyzf
+szajqxpdk
+
+jpetks
+jpktie
+xykjdcebzgtoh
+nlkjaeit
+ektjqfnl
+
+itsgqnl
+endictjfgoslu
+ishtlpgxrn
+stlngvi
+twqslnrgi
+
+agodjfkmblxvi
+fixgmajlvokb
+joafvxgkimlb
+
+gfpqsxctouhrkaijzbmevw
+gmfoikabwhzpsuqynetvlrxj
+suejaigxtpodrmfzqhvkwb
+
+pnvtgafmj
+tnapfvjmg
+njatvgpmf
+
+lft
+ltf
+lsgyvmbfct
+jdflt
+tfdl
+
+ihlxnvsktqyjgrpuow
+whokcilnutvsxgy
+lukshywxgntovi
+vhtgyxwuknsloi
+hxwgiukyotlvzsn
+
+gtlhswu
+ksutghwli
+ltgushwp
+ltjauwvecsxqhg
+
+it
+it
+ti
+it
+
+n
+o
+j
+stym
+
+t
+t
+kt
+t
+tu
+
+rnkmbuljxf
+mabjnkychf
+ktqbnmoflej
+fknzmbrje
+
+zsfewbyvxta
+fywztbsa
+tbsynqwzaof
+toawfzbys
+
+a
+y
+c
+
+hl
+hl
+hl
+lh
+
+vqipoaygbnesrwhdm
+dhrcapsuexbwioytnqgmk
+gypzoneqdvfmbsrahiw
+
+kypcwmun
+emcnukhgw
+ucgwmkn
+
+doejsplwvmybiq
+lbcjhmwsoqtdpgy
+
+mylqbcezj
+elmryzsq
+ymqbdzeln
+
+j
+j
+jt
+j
+j
+
+nr
+dn
+
+oqzlbvtpgca
+bqoeg
+qugbreo
+
+i
+fd
+mxy
+ebgy
+
+bktxgjlfnc
+knfjtgxlcb
+fbnltjgxmkc
+xtnbjlfkcyg
+
+rthfbiajsy
+txsoayjh
+
+xfjykonhtzwbric
+wsvmtlgepc
+
+iavozrmcxwf
+jbpguq
+
+qagdznlfwtpscre
+fepczhiasgwdqlntr
+fnwplacgutzeqsdr
+acdqeplwgnsfztr
+
+stxqayumzelihb
+oumqlxbsatiyhze
+bqsxemzyhtuila
+
+g
+sft
+b
+g
+
+aozwhycb
+azwy
+
+f
+kif
+
+t
+s
+s
+s
+s
+
+godyxji
+igydjob
+yjodig
+yjdiog
+ozjcdgyi
+
+e
+o
+o
+d
+
+fqzpyghcv
+cqvyhzfpg
+chfqpzyvg
+
+afvxbzskqu
+puavxhzks
+
+jtbg
+gj
+ijg
+gij
+
+k
+vbcn
+k
+t
+
+tzbkywxemd
+tbkzxwmde
+dbmekxwzt
+tbzmkwedx
+
+hagcokltv
+lvgocykat
+hyvipgcltako
+amecltgnxvfjqdzkb
+
+adgbvno
+n
+
+hgzkdpnimvaqtroycwf
+yfjvrohmkapcwezdntsig
+rkhnwzivptyomacfdgb
+
+yoqdxf
+uorhyx
+cevlywoxzp
+ogrumyxd
+
+opmbnzxk
+znobkmpx
+
+pirlwzuqa
+plunfoarqivz
+rlqagzusip
+
+r
+q
+j
+r
+c
+
+qpokva
+ikvaoq
+
+bl
+nxqv
+sqb
+rtikywjpdh
+oaqg
+
+zjoksy
+zyosjk
+
+otsuclvnbi
+rusfwedazpjkygqm
+
+qfdsrzk
+suwrkqdh
+eaisxcjdm
+
+cdlnwvkoeizhmujfgtspxybrq
+rdykiuwbhtzxmvcspnfeojqg
+
+v
+v
+hv

+ 53 - 0
aoc2020/6th/main.jl

@@ -0,0 +1,53 @@
+using DataStructures
+using BenchmarkTools
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data =
+read(selfdir, String) |>
+x -> split(x, "\n\n") .|> 
+x -> split(x) 
+
+#--------part1
+
+function anyone_yes()
+    sum(map(x->length(x), map(unique, (map(x-> reduce(*, x), data)))))
+end
+
+function anyone_yes_sets()
+    sum(data .|> x -> union(x...) |> length)
+end
+
+#--------part2
+
+function all_yes()
+
+    data .|> 
+    (
+        x -> (reduce(*, x), length(x)) |> 
+        x -> (counter(x[1]), x[2]) |> 
+        x -> (values(x[1]), x[2]) |> 
+        x -> count(==(x[2]), x[1])
+        ) |> 
+        sum
+        
+    end
+    
+function all_yes_sets()
+    sum(data .|> x -> intersect(x...) |> length)
+end
+
+#--------evaluation
+
+println("first impl")
+anyone_yes_count = @btime anyone_yes()
+all_yes_count = @btime all_yes()
+
+println("check sets union")
+@btime anyone_yes_sets()
+
+println("check sets intersect")
+@btime all_yes_sets()
+
+println(anyone_yes_count)
+println(all_yes_count)

+ 594 - 0
aoc2020/7th/input

@@ -0,0 +1,594 @@
+posh crimson bags contain 2 mirrored tan bags, 1 faded red bag, 1 striped gray bag.
+bright gray bags contain 1 striped white bag, 4 vibrant cyan bags, 4 clear white bags, 4 muted gold bags.
+pale plum bags contain 1 dark silver bag.
+light tomato bags contain 5 plaid brown bags, 5 bright maroon bags, 5 shiny beige bags.
+wavy brown bags contain 2 faded lavender bags, 2 wavy coral bags, 5 clear gold bags.
+dark chartreuse bags contain 4 striped lavender bags, 2 shiny silver bags, 5 wavy plum bags.
+dotted chartreuse bags contain 3 shiny teal bags, 4 posh maroon bags.
+muted purple bags contain 2 pale lavender bags, 5 drab red bags, 3 wavy fuchsia bags.
+shiny gray bags contain 5 pale red bags, 1 light chartreuse bag, 5 bright blue bags, 3 light gold bags.
+dull cyan bags contain 2 light green bags, 2 vibrant fuchsia bags.
+dotted gray bags contain 4 light bronze bags, 5 dim blue bags.
+muted plum bags contain 3 shiny brown bags, 4 shiny teal bags.
+bright magenta bags contain 1 plaid yellow bag, 1 dull white bag.
+dotted lime bags contain 4 shiny gray bags, 2 bright teal bags, 5 dim fuchsia bags, 1 vibrant chartreuse bag.
+mirrored beige bags contain 2 plaid crimson bags, 3 wavy tomato bags.
+pale purple bags contain 2 faded chartreuse bags, 2 dark lime bags, 4 drab white bags, 4 shiny olive bags.
+dull bronze bags contain 3 bright lavender bags.
+striped bronze bags contain 1 dark olive bag, 5 dotted orange bags.
+vibrant orange bags contain 1 plaid plum bag, 1 faded lime bag, 1 clear lavender bag, 1 muted brown bag.
+dull blue bags contain 5 dotted tan bags, 2 light crimson bags.
+mirrored red bags contain 1 shiny crimson bag.
+vibrant coral bags contain 1 vibrant gray bag.
+plaid tan bags contain 4 clear magenta bags, 5 posh brown bags, 5 drab lime bags.
+dark yellow bags contain 2 striped bronze bags, 3 shiny tomato bags.
+mirrored lime bags contain 3 bright orange bags.
+mirrored salmon bags contain 3 dark white bags, 5 clear salmon bags.
+light crimson bags contain 1 plaid cyan bag, 2 pale silver bags, 5 pale violet bags, 1 shiny crimson bag.
+clear white bags contain 2 muted blue bags, 5 dotted olive bags.
+muted magenta bags contain 4 dark purple bags.
+clear red bags contain 4 dark gray bags, 3 striped beige bags.
+plaid gray bags contain 3 faded olive bags.
+posh teal bags contain 3 pale gray bags, 3 dim beige bags, 2 dark gray bags, 1 shiny coral bag.
+pale violet bags contain 5 pale silver bags, 2 shiny crimson bags, 5 dull olive bags, 2 drab magenta bags.
+shiny purple bags contain 5 shiny indigo bags, 3 dotted green bags, 2 wavy blue bags, 3 light salmon bags.
+mirrored gold bags contain 2 muted coral bags, 4 shiny lavender bags.
+drab brown bags contain 1 posh lime bag.
+dull salmon bags contain 5 dotted lavender bags, 3 plaid gray bags, 5 dim coral bags.
+striped coral bags contain 5 muted brown bags, 3 muted plum bags, 2 dim aqua bags.
+dark violet bags contain 5 drab chartreuse bags.
+dark lavender bags contain 3 posh lime bags.
+plaid fuchsia bags contain no other bags.
+faded yellow bags contain 3 posh lime bags, 4 wavy blue bags, 3 faded crimson bags, 2 shiny lavender bags.
+faded crimson bags contain 2 dim yellow bags, 5 drab chartreuse bags.
+dull red bags contain 3 dark silver bags, 5 faded plum bags.
+dull lime bags contain 1 dim black bag.
+vibrant tomato bags contain 3 dull gray bags.
+light tan bags contain 3 dim brown bags, 5 striped lavender bags, 2 dull indigo bags.
+pale turquoise bags contain 4 posh plum bags, 5 striped chartreuse bags, 5 dim magenta bags.
+dim gray bags contain 2 mirrored indigo bags, 3 dim white bags.
+bright salmon bags contain 5 bright lavender bags.
+faded coral bags contain 5 striped blue bags, 3 dark plum bags, 3 mirrored blue bags.
+mirrored bronze bags contain 3 dark gold bags, 1 faded teal bag.
+bright aqua bags contain 2 vibrant olive bags.
+wavy purple bags contain 3 wavy teal bags, 5 dim olive bags, 3 muted blue bags.
+bright crimson bags contain 5 drab blue bags.
+bright white bags contain 2 light cyan bags, 1 posh silver bag.
+striped turquoise bags contain 5 mirrored gray bags.
+drab magenta bags contain 4 vibrant green bags, 3 mirrored black bags, 4 muted white bags.
+clear teal bags contain 1 wavy bronze bag, 5 dark turquoise bags, 2 drab teal bags.
+dull aqua bags contain 4 dim fuchsia bags, 3 drab green bags, 3 muted tomato bags.
+posh coral bags contain 4 wavy bronze bags, 4 mirrored blue bags, 2 pale white bags, 3 shiny brown bags.
+faded olive bags contain 1 muted brown bag.
+muted white bags contain 1 vibrant green bag.
+plaid violet bags contain 5 drab magenta bags.
+clear cyan bags contain 1 clear gray bag, 1 mirrored gold bag, 4 mirrored white bags, 5 clear brown bags.
+dull coral bags contain 3 bright blue bags, 1 light plum bag, 4 dotted violet bags, 1 dim teal bag.
+plaid blue bags contain 3 dark plum bags, 1 wavy aqua bag, 1 plaid turquoise bag.
+posh indigo bags contain 4 dim black bags, 5 posh orange bags.
+drab plum bags contain 1 bright tan bag, 3 faded bronze bags, 5 plaid bronze bags.
+mirrored aqua bags contain 2 striped coral bags.
+posh salmon bags contain 1 mirrored tomato bag, 2 shiny red bags.
+pale yellow bags contain 5 striped fuchsia bags, 3 muted gray bags, 3 plaid green bags.
+faded purple bags contain 5 mirrored tan bags, 2 faded lime bags.
+faded blue bags contain 4 bright green bags, 5 dark crimson bags.
+dark beige bags contain 3 pale magenta bags, 4 vibrant lavender bags, 4 posh aqua bags, 3 striped fuchsia bags.
+bright cyan bags contain 3 pale violet bags, 5 pale coral bags, 4 shiny black bags, 1 dark blue bag.
+wavy green bags contain 1 dotted purple bag, 4 muted gold bags.
+pale orange bags contain 1 drab tomato bag, 3 muted purple bags, 3 muted coral bags.
+vibrant violet bags contain 1 wavy olive bag, 2 plaid chartreuse bags, 5 light cyan bags.
+vibrant plum bags contain 5 light olive bags.
+shiny silver bags contain 1 faded coral bag, 2 dotted olive bags, 4 mirrored red bags, 3 clear fuchsia bags.
+bright blue bags contain 3 striped gray bags, 2 dotted indigo bags, 5 clear magenta bags, 3 dotted green bags.
+dotted red bags contain 3 mirrored white bags.
+light lime bags contain 5 bright purple bags.
+bright purple bags contain 2 bright lavender bags, 1 clear turquoise bag, 3 pale magenta bags.
+faded tomato bags contain 2 shiny turquoise bags, 5 dim crimson bags.
+light brown bags contain 3 pale violet bags, 2 striped blue bags, 1 wavy lavender bag.
+posh silver bags contain 2 bright silver bags, 5 dim olive bags.
+shiny chartreuse bags contain 4 striped black bags.
+dull violet bags contain 1 striped white bag.
+posh chartreuse bags contain 5 wavy crimson bags, 1 vibrant orange bag, 2 mirrored tan bags, 5 shiny brown bags.
+plaid green bags contain 2 light aqua bags, 5 dull fuchsia bags.
+pale bronze bags contain 5 dull white bags.
+muted violet bags contain 3 pale red bags, 5 dull red bags, 5 light cyan bags.
+wavy aqua bags contain no other bags.
+posh plum bags contain 3 faded green bags.
+wavy lavender bags contain 1 light gold bag, 2 faded teal bags, 1 shiny tomato bag, 1 pale white bag.
+dull silver bags contain 5 mirrored indigo bags, 1 dim red bag, 2 shiny coral bags, 2 drab tan bags.
+light teal bags contain 4 bright lavender bags, 4 bright yellow bags, 5 wavy crimson bags.
+shiny maroon bags contain 2 clear magenta bags, 3 striped blue bags.
+mirrored turquoise bags contain 2 dark violet bags, 5 dark aqua bags.
+light orange bags contain 2 plaid lime bags.
+dotted lavender bags contain 1 striped olive bag.
+posh magenta bags contain 1 plaid teal bag, 1 muted salmon bag.
+drab tan bags contain 4 dull tan bags, 5 faded teal bags.
+wavy olive bags contain 5 plaid aqua bags, 3 dull turquoise bags, 5 faded aqua bags, 2 plaid maroon bags.
+muted beige bags contain 2 mirrored tomato bags, 4 dotted salmon bags.
+muted chartreuse bags contain 1 plaid white bag, 1 dull beige bag, 5 vibrant maroon bags, 3 drab gray bags.
+striped teal bags contain 4 wavy yellow bags, 1 dull lime bag, 1 pale green bag, 4 drab chartreuse bags.
+pale green bags contain 1 dim violet bag, 1 mirrored beige bag.
+dim lime bags contain 4 dotted aqua bags, 2 pale red bags.
+clear purple bags contain 5 clear lavender bags.
+plaid beige bags contain 1 bright olive bag, 1 light brown bag, 1 muted blue bag, 4 dotted green bags.
+dark blue bags contain 1 dim red bag, 2 wavy cyan bags.
+shiny lime bags contain 3 dull tomato bags, 2 bright gray bags, 1 pale fuchsia bag.
+muted lavender bags contain 2 mirrored tan bags, 1 vibrant orange bag, 2 light gold bags.
+drab violet bags contain 1 dotted beige bag, 5 faded purple bags, 1 pale green bag.
+striped lime bags contain 3 plaid orange bags.
+posh gold bags contain 3 dark bronze bags, 3 posh chartreuse bags, 1 clear lime bag, 5 shiny coral bags.
+mirrored white bags contain 4 dull red bags, 1 pale crimson bag, 2 posh blue bags.
+dotted brown bags contain 1 vibrant lavender bag, 3 dark lavender bags, 5 bright salmon bags.
+faded salmon bags contain 2 mirrored violet bags, 5 dark chartreuse bags, 5 dull silver bags, 1 mirrored teal bag.
+dull purple bags contain 2 light brown bags, 2 mirrored tan bags.
+muted black bags contain 4 vibrant indigo bags, 2 wavy crimson bags, 4 light cyan bags, 5 dim salmon bags.
+muted cyan bags contain 2 posh olive bags, 5 dark gray bags, 2 plaid green bags, 2 clear brown bags.
+shiny violet bags contain 1 vibrant gray bag, 4 posh teal bags.
+dim lavender bags contain 1 dim coral bag, 4 light silver bags, 3 dull teal bags, 3 wavy coral bags.
+dotted tan bags contain 5 plaid tan bags, 2 plaid plum bags, 3 vibrant crimson bags.
+faded aqua bags contain 3 light purple bags, 1 pale white bag, 5 muted turquoise bags.
+drab coral bags contain 4 vibrant turquoise bags, 1 dull yellow bag, 4 clear turquoise bags, 5 dull beige bags.
+mirrored olive bags contain 5 plaid magenta bags, 5 light indigo bags.
+light salmon bags contain 2 dull plum bags, 1 striped blue bag.
+vibrant magenta bags contain 5 muted lime bags, 3 dull tomato bags, 2 clear tomato bags, 3 dim brown bags.
+dark brown bags contain 4 dull gray bags.
+striped plum bags contain 2 plaid turquoise bags.
+drab tomato bags contain 1 mirrored black bag, 1 dull beige bag.
+dotted black bags contain 4 light cyan bags.
+shiny plum bags contain 5 drab magenta bags.
+plaid purple bags contain 1 dark black bag.
+muted bronze bags contain 4 muted white bags, 1 dotted bronze bag, 3 bright crimson bags.
+striped aqua bags contain 5 mirrored silver bags, 2 dim blue bags, 2 drab purple bags.
+light indigo bags contain 1 muted olive bag, 5 shiny plum bags.
+drab lavender bags contain 4 dotted aqua bags, 1 dull chartreuse bag, 5 drab teal bags, 3 light brown bags.
+wavy fuchsia bags contain 4 posh maroon bags.
+dim blue bags contain 2 mirrored purple bags, 2 dim gold bags, 3 vibrant chartreuse bags, 1 dull red bag.
+muted olive bags contain 2 pale crimson bags, 4 mirrored green bags, 1 dim white bag.
+striped tomato bags contain 4 posh tan bags, 2 pale crimson bags, 2 shiny fuchsia bags, 5 striped gray bags.
+faded white bags contain 3 vibrant tan bags.
+dotted gold bags contain 5 plaid gray bags, 5 mirrored cyan bags, 2 vibrant purple bags, 5 light orange bags.
+vibrant crimson bags contain 2 mirrored violet bags, 3 faded chartreuse bags, 3 wavy lavender bags.
+light lavender bags contain 2 light gold bags.
+muted fuchsia bags contain 4 drab blue bags.
+clear tomato bags contain 3 plaid aqua bags.
+shiny fuchsia bags contain 1 wavy lavender bag, 5 striped blue bags.
+shiny cyan bags contain 5 dim red bags, 3 dim brown bags.
+wavy crimson bags contain 3 bright lavender bags, 2 faded plum bags.
+light cyan bags contain 1 striped fuchsia bag.
+mirrored crimson bags contain 3 wavy lavender bags, 4 vibrant tan bags, 5 faded plum bags.
+dark tomato bags contain 5 mirrored gray bags, 5 muted fuchsia bags, 2 plaid lavender bags, 4 light purple bags.
+plaid magenta bags contain 1 muted silver bag, 5 light lavender bags, 4 muted brown bags, 3 drab turquoise bags.
+vibrant olive bags contain 1 plaid cyan bag, 5 drab white bags, 1 bright indigo bag, 5 plaid yellow bags.
+dull crimson bags contain 5 pale silver bags, 3 posh blue bags, 5 dull olive bags.
+mirrored gray bags contain 4 dull olive bags, 1 shiny fuchsia bag, 5 mirrored black bags, 2 clear magenta bags.
+dim aqua bags contain 3 mirrored indigo bags, 5 muted maroon bags, 4 dark orange bags.
+bright tan bags contain 2 bright teal bags, 5 vibrant indigo bags, 1 dull black bag.
+dark white bags contain 3 dark violet bags.
+dull black bags contain 5 posh cyan bags, 5 shiny tomato bags, 1 light yellow bag.
+mirrored orange bags contain 3 posh coral bags, 1 bright silver bag, 3 faded plum bags, 2 dotted coral bags.
+mirrored tan bags contain 2 pale violet bags, 1 dim gold bag, 2 faded green bags, 2 posh blue bags.
+shiny turquoise bags contain 1 vibrant silver bag.
+plaid chartreuse bags contain 4 striped white bags, 5 vibrant bronze bags, 1 pale brown bag.
+mirrored plum bags contain 1 shiny fuchsia bag, 4 bright indigo bags, 4 muted maroon bags, 2 drab red bags.
+faded lavender bags contain 3 faded chartreuse bags, 5 muted plum bags, 3 light brown bags.
+dim green bags contain 5 pale plum bags, 2 clear magenta bags.
+bright green bags contain 5 posh lime bags.
+dim yellow bags contain 1 plaid fuchsia bag, 1 dotted olive bag.
+pale silver bags contain 1 muted brown bag, 3 clear lavender bags.
+dark turquoise bags contain 2 wavy lavender bags, 4 posh gray bags, 3 plaid tan bags.
+muted gray bags contain 4 drab teal bags.
+striped maroon bags contain 1 striped fuchsia bag, 1 vibrant green bag.
+clear crimson bags contain 1 light black bag, 4 dim aqua bags, 2 dull red bags.
+dotted bronze bags contain 3 muted purple bags, 5 muted lime bags, 5 pale plum bags.
+wavy coral bags contain 1 dull white bag.
+dotted purple bags contain 2 dim blue bags.
+pale cyan bags contain 1 dark beige bag, 1 drab crimson bag, 2 plaid black bags, 3 dim tomato bags.
+clear green bags contain 4 muted lime bags, 1 mirrored white bag, 4 pale lavender bags, 2 muted gold bags.
+plaid yellow bags contain 3 muted silver bags.
+pale tan bags contain 4 shiny cyan bags.
+clear brown bags contain 2 dull maroon bags, 4 posh orange bags, 3 mirrored blue bags.
+striped cyan bags contain 1 muted tomato bag, 2 dim magenta bags.
+clear lavender bags contain 3 plaid fuchsia bags.
+dull gold bags contain 5 dim salmon bags.
+dark cyan bags contain 4 pale gold bags, 2 muted tan bags.
+plaid olive bags contain 5 posh tan bags.
+vibrant aqua bags contain 3 striped violet bags, 3 muted turquoise bags.
+dim white bags contain 2 plaid fuchsia bags, 1 dull olive bag, 4 faded teal bags.
+mirrored silver bags contain 2 mirrored gray bags, 4 muted blue bags, 4 dull gray bags.
+wavy violet bags contain 5 bright green bags, 3 pale silver bags, 5 dark aqua bags, 4 shiny tomato bags.
+bright coral bags contain 2 striped chartreuse bags, 4 clear aqua bags, 5 vibrant olive bags, 3 wavy tomato bags.
+plaid coral bags contain 3 clear turquoise bags, 2 muted olive bags, 2 faded crimson bags, 5 dull yellow bags.
+posh purple bags contain 4 dull cyan bags.
+muted maroon bags contain 5 striped white bags, 2 pale blue bags, 3 dull crimson bags, 1 pale lavender bag.
+mirrored black bags contain 5 plaid fuchsia bags, 3 vibrant green bags, 1 faded chartreuse bag.
+vibrant turquoise bags contain 4 plaid black bags, 1 shiny brown bag, 5 wavy purple bags, 2 dim red bags.
+muted gold bags contain 3 clear lavender bags, 2 dotted chartreuse bags, 3 dim green bags, 2 mirrored black bags.
+dark lime bags contain 5 dark aqua bags, 2 plaid plum bags.
+posh brown bags contain 3 drab fuchsia bags, 1 dim gold bag, 4 drab magenta bags, 3 wavy aqua bags.
+clear yellow bags contain 3 wavy indigo bags.
+muted blue bags contain 1 wavy crimson bag, 5 mirrored red bags, 5 shiny crimson bags, 4 plaid fuchsia bags.
+drab white bags contain 5 dull olive bags, 2 posh maroon bags, 2 pale silver bags, 5 muted brown bags.
+dim gold bags contain no other bags.
+faded plum bags contain 4 plaid turquoise bags, 5 drab chartreuse bags, 2 dotted olive bags, 3 plaid fuchsia bags.
+light blue bags contain 4 plaid coral bags, 5 dotted violet bags.
+vibrant gold bags contain 2 dim fuchsia bags, 3 faded white bags.
+plaid crimson bags contain 1 plaid plum bag.
+dim fuchsia bags contain 3 faded teal bags.
+mirrored chartreuse bags contain 3 wavy black bags.
+mirrored fuchsia bags contain 1 faded teal bag, 5 light coral bags.
+muted coral bags contain 3 light magenta bags, 5 faded green bags, 1 dull olive bag, 2 muted silver bags.
+dim teal bags contain 4 pale teal bags, 1 plaid maroon bag, 2 plaid yellow bags, 1 plaid orange bag.
+faded green bags contain 4 striped gray bags.
+vibrant beige bags contain 2 muted blue bags, 3 vibrant gray bags.
+muted silver bags contain 3 dotted violet bags.
+dotted cyan bags contain 2 mirrored gray bags, 5 muted purple bags, 2 faded bronze bags.
+bright turquoise bags contain 1 pale tan bag, 1 pale salmon bag.
+wavy gold bags contain 2 pale olive bags.
+faded turquoise bags contain 2 vibrant fuchsia bags, 2 drab fuchsia bags, 4 striped black bags.
+faded lime bags contain 4 dim gold bags, 5 vibrant yellow bags.
+faded black bags contain 2 dark coral bags, 2 shiny crimson bags, 4 clear gray bags.
+vibrant silver bags contain 1 shiny teal bag, 5 dotted chartreuse bags, 1 pale magenta bag, 3 clear coral bags.
+dim brown bags contain 1 posh gray bag.
+dim cyan bags contain 2 drab tan bags, 4 posh white bags.
+bright fuchsia bags contain 1 dark crimson bag, 3 posh coral bags.
+clear tan bags contain 1 light tomato bag, 5 bright olive bags, 1 dull violet bag, 2 bright green bags.
+pale red bags contain 5 mirrored tomato bags, 4 dull red bags, 3 shiny teal bags.
+drab chartreuse bags contain 1 vibrant green bag, 3 shiny crimson bags, 3 dotted olive bags.
+dark gray bags contain 4 dotted coral bags, 2 shiny teal bags, 1 muted blue bag, 4 bright silver bags.
+dim purple bags contain 5 dotted gold bags.
+shiny crimson bags contain no other bags.
+posh maroon bags contain 4 light magenta bags, 4 muted tan bags.
+mirrored purple bags contain no other bags.
+wavy silver bags contain 5 faded lavender bags, 4 clear lime bags.
+dark indigo bags contain 3 light plum bags, 5 dotted crimson bags, 1 wavy plum bag, 4 light gold bags.
+wavy gray bags contain 3 clear gold bags.
+pale gray bags contain 2 bright gold bags.
+muted turquoise bags contain 1 wavy bronze bag, 1 muted blue bag.
+dull yellow bags contain 3 posh olive bags, 5 faded red bags.
+mirrored tomato bags contain 3 striped olive bags, 4 light chartreuse bags, 5 pale silver bags.
+dotted crimson bags contain 3 muted brown bags, 4 dim blue bags, 4 dark silver bags, 3 pale lavender bags.
+pale magenta bags contain 3 clear bronze bags, 1 plaid brown bag, 1 dim gold bag.
+faded brown bags contain 3 plaid fuchsia bags, 1 faded chartreuse bag.
+clear salmon bags contain 1 plaid fuchsia bag, 4 wavy coral bags, 5 shiny coral bags, 3 clear turquoise bags.
+clear coral bags contain 5 faded chartreuse bags, 1 drab chartreuse bag, 2 dim gold bags.
+dull magenta bags contain 2 dark coral bags, 4 drab indigo bags, 3 posh maroon bags.
+posh black bags contain 4 dim white bags, 2 dark lime bags, 5 faded green bags, 2 plaid green bags.
+dim beige bags contain 2 striped lavender bags, 5 posh lavender bags.
+clear turquoise bags contain 2 muted brown bags.
+faded red bags contain 2 vibrant salmon bags, 3 dark orange bags.
+shiny aqua bags contain 1 shiny salmon bag, 2 light olive bags, 4 dotted magenta bags.
+dotted yellow bags contain 3 striped green bags, 5 posh tan bags.
+dark silver bags contain 4 posh maroon bags, 4 clear lavender bags.
+dull gray bags contain 3 plaid violet bags, 3 dark silver bags, 3 mirrored black bags, 1 drab indigo bag.
+drab indigo bags contain 2 faded plum bags, 4 clear turquoise bags, 2 pale white bags, 3 drab magenta bags.
+dotted indigo bags contain 1 dim olive bag.
+drab crimson bags contain 3 plaid turquoise bags, 2 pale purple bags.
+pale coral bags contain 3 posh blue bags.
+shiny tomato bags contain 5 muted salmon bags, 4 faded plum bags, 1 drab chartreuse bag, 5 muted brown bags.
+wavy yellow bags contain 4 striped black bags, 1 dull turquoise bag.
+faded indigo bags contain 4 wavy crimson bags, 1 dark orange bag, 5 dotted coral bags.
+light white bags contain 2 bright blue bags, 3 pale lavender bags, 3 dull lime bags, 2 pale coral bags.
+dark black bags contain 4 light orange bags, 5 shiny coral bags.
+dull white bags contain 3 striped fuchsia bags.
+bright tomato bags contain 5 shiny cyan bags, 4 plaid bronze bags, 1 muted salmon bag.
+vibrant lime bags contain 1 dotted gray bag, 3 drab crimson bags, 3 faded crimson bags.
+dotted orange bags contain 2 dark purple bags, 4 faded lavender bags.
+dim black bags contain 3 dark turquoise bags, 5 posh gray bags, 4 dull tan bags.
+light bronze bags contain 1 striped blue bag.
+dotted salmon bags contain 3 muted crimson bags, 1 faded gold bag, 1 wavy violet bag, 3 striped gray bags.
+shiny coral bags contain 1 shiny fuchsia bag.
+clear beige bags contain 1 dim yellow bag, 3 mirrored tomato bags.
+mirrored blue bags contain 1 plaid fuchsia bag.
+bright yellow bags contain 3 dotted violet bags, 5 dull teal bags.
+drab bronze bags contain 1 dim black bag, 5 faded indigo bags.
+posh red bags contain 1 pale silver bag.
+dark bronze bags contain 4 dotted fuchsia bags, 5 light salmon bags, 1 muted brown bag, 1 posh blue bag.
+pale indigo bags contain 4 vibrant bronze bags.
+light violet bags contain 2 shiny tomato bags, 1 wavy maroon bag.
+muted crimson bags contain 4 clear gold bags, 4 dark coral bags.
+faded chartreuse bags contain no other bags.
+muted tan bags contain no other bags.
+clear lime bags contain 1 bright lavender bag, 4 dim olive bags, 4 pale plum bags.
+plaid lime bags contain 1 drab lime bag.
+mirrored green bags contain 4 dim tomato bags, 3 clear coral bags, 2 shiny lavender bags.
+bright orange bags contain 5 bright salmon bags, 4 plaid maroon bags.
+dim plum bags contain 1 striped chartreuse bag, 3 dotted violet bags, 1 faded teal bag, 1 dim green bag.
+faded tan bags contain 4 mirrored black bags.
+wavy salmon bags contain 1 faded tomato bag.
+dim coral bags contain 3 dull indigo bags, 3 wavy tomato bags.
+dim turquoise bags contain 2 wavy yellow bags, 4 dull silver bags.
+dull chartreuse bags contain 5 mirrored purple bags, 4 pale coral bags, 2 shiny purple bags.
+drab fuchsia bags contain 4 dotted olive bags, 2 dim gold bags, 4 shiny crimson bags.
+dull tomato bags contain 2 striped indigo bags.
+striped lavender bags contain 5 plaid cyan bags, 5 faded green bags, 1 posh gray bag.
+clear gold bags contain 5 clear turquoise bags, 2 dull tan bags.
+dark orange bags contain 5 dotted olive bags, 3 pale magenta bags, 2 posh blue bags, 1 vibrant green bag.
+clear plum bags contain 4 posh olive bags.
+dark olive bags contain 5 faded silver bags, 1 vibrant tan bag, 3 bright crimson bags.
+striped magenta bags contain 3 shiny lavender bags, 5 faded green bags, 4 striped lavender bags, 2 mirrored black bags.
+dim chartreuse bags contain 4 striped turquoise bags, 5 mirrored tomato bags.
+faded teal bags contain 3 dull olive bags, 1 dull tan bag, 5 posh maroon bags.
+wavy cyan bags contain 1 shiny magenta bag.
+dim tomato bags contain 1 plaid plum bag, 2 plaid fuchsia bags, 5 mirrored blue bags.
+drab maroon bags contain 4 faded coral bags, 2 dotted black bags, 3 posh orange bags, 2 faded indigo bags.
+posh white bags contain 2 clear coral bags, 3 plaid turquoise bags, 2 mirrored black bags.
+shiny orange bags contain 4 light coral bags.
+bright teal bags contain 3 clear gray bags, 2 clear turquoise bags, 3 faded crimson bags.
+clear aqua bags contain 3 muted silver bags, 5 dim white bags, 5 drab lime bags, 4 clear gold bags.
+vibrant black bags contain 1 dim violet bag, 5 pale indigo bags, 4 wavy indigo bags, 5 muted green bags.
+clear chartreuse bags contain 1 dull black bag, 3 dotted olive bags, 3 dull indigo bags.
+posh lavender bags contain 5 vibrant orange bags, 2 dim white bags, 1 dull beige bag.
+dark crimson bags contain 5 faded tomato bags, 1 striped fuchsia bag.
+light black bags contain 3 muted tomato bags, 5 clear bronze bags, 4 drab chartreuse bags.
+wavy plum bags contain 3 dotted coral bags, 5 vibrant olive bags.
+plaid salmon bags contain 4 dull salmon bags.
+wavy chartreuse bags contain 1 mirrored turquoise bag.
+vibrant fuchsia bags contain 2 mirrored gold bags, 5 dull bronze bags.
+dim violet bags contain 1 faded fuchsia bag, 1 mirrored red bag, 2 posh fuchsia bags, 4 mirrored turquoise bags.
+vibrant tan bags contain 2 clear salmon bags, 5 drab red bags, 3 dotted gray bags.
+dim bronze bags contain 1 drab green bag.
+shiny lavender bags contain 3 muted salmon bags.
+striped fuchsia bags contain 4 dim gold bags, 2 dotted crimson bags.
+dim tan bags contain 2 plaid red bags, 2 bright chartreuse bags, 2 dim salmon bags.
+dotted violet bags contain no other bags.
+dull maroon bags contain 4 faded chartreuse bags.
+clear violet bags contain 1 drab lime bag, 5 muted coral bags, 1 clear lavender bag.
+plaid maroon bags contain 1 drab red bag, 3 muted gold bags.
+vibrant gray bags contain 1 plaid fuchsia bag.
+light yellow bags contain 4 mirrored blue bags, 2 plaid fuchsia bags, 1 wavy tomato bag.
+dotted teal bags contain 3 light tan bags.
+vibrant chartreuse bags contain 1 shiny crimson bag, 2 plaid fuchsia bags.
+dull lavender bags contain 1 light crimson bag.
+dark gold bags contain 3 muted olive bags, 1 posh tan bag, 5 vibrant purple bags.
+light aqua bags contain 1 wavy bronze bag.
+dim crimson bags contain 3 plaid beige bags, 1 plaid yellow bag.
+plaid brown bags contain 5 dotted olive bags, 4 muted salmon bags, 3 dim gold bags.
+dotted magenta bags contain 1 wavy coral bag, 2 drab turquoise bags, 5 mirrored tomato bags.
+muted tomato bags contain 4 wavy fuchsia bags, 4 pale magenta bags.
+posh tomato bags contain 1 striped beige bag, 1 faded brown bag.
+faded gray bags contain 4 plaid maroon bags, 5 muted silver bags, 5 muted maroon bags, 4 vibrant fuchsia bags.
+plaid lavender bags contain 3 dim blue bags, 4 vibrant gray bags, 2 light silver bags, 1 dull green bag.
+muted indigo bags contain 2 dark coral bags, 1 vibrant indigo bag, 3 dim yellow bags, 4 muted aqua bags.
+posh turquoise bags contain 4 drab red bags, 2 faded teal bags, 4 dull maroon bags.
+bright red bags contain 5 wavy lime bags, 4 bright black bags, 1 muted white bag.
+pale tomato bags contain 1 posh olive bag.
+dim maroon bags contain 5 vibrant red bags, 3 vibrant orange bags, 1 dark chartreuse bag.
+shiny teal bags contain 2 plaid fuchsia bags, 4 dotted olive bags, 2 vibrant chartreuse bags, 4 muted brown bags.
+plaid gold bags contain 3 clear olive bags, 1 faded chartreuse bag.
+shiny beige bags contain 5 wavy lavender bags, 3 muted salmon bags.
+drab green bags contain 1 clear bronze bag, 2 posh teal bags, 1 dotted green bag, 5 pale white bags.
+light beige bags contain 5 vibrant red bags.
+clear indigo bags contain 4 plaid violet bags.
+clear black bags contain 5 striped olive bags, 5 posh red bags, 4 posh brown bags, 4 shiny olive bags.
+wavy red bags contain 1 dull red bag, 2 shiny magenta bags, 4 shiny black bags.
+striped indigo bags contain 1 striped black bag, 2 plaid cyan bags.
+clear bronze bags contain no other bags.
+shiny salmon bags contain 1 muted tan bag, 5 striped white bags, 5 striped fuchsia bags.
+mirrored teal bags contain 5 light lime bags.
+dotted blue bags contain 4 dark aqua bags, 3 clear bronze bags, 4 dull olive bags.
+shiny blue bags contain 3 bright green bags, 5 pale lavender bags.
+faded cyan bags contain 3 dark red bags, 4 drab cyan bags, 5 faded beige bags.
+light purple bags contain 3 posh silver bags.
+vibrant teal bags contain 4 dotted gold bags, 1 plaid yellow bag, 1 mirrored cyan bag, 5 dull indigo bags.
+wavy bronze bags contain 2 muted silver bags.
+dim red bags contain 3 clear bronze bags, 5 faded plum bags.
+muted yellow bags contain 2 muted blue bags, 5 striped beige bags, 2 drab indigo bags, 5 drab red bags.
+mirrored lavender bags contain 3 dull maroon bags.
+pale white bags contain 3 vibrant chartreuse bags, 5 posh maroon bags, 4 muted brown bags, 3 plaid turquoise bags.
+vibrant maroon bags contain 2 shiny purple bags, 2 dim yellow bags.
+dull teal bags contain 2 mirrored black bags, 5 drab white bags.
+bright olive bags contain 5 clear bronze bags, 2 drab red bags.
+shiny white bags contain 2 clear brown bags, 4 muted white bags.
+muted aqua bags contain 4 dim green bags, 3 shiny tomato bags, 2 posh chartreuse bags, 4 muted lavender bags.
+dull fuchsia bags contain 5 mirrored red bags, 4 dark lime bags.
+pale brown bags contain 4 striped indigo bags, 4 dotted coral bags, 4 shiny maroon bags, 5 striped white bags.
+plaid tomato bags contain 4 drab turquoise bags, 1 posh plum bag, 5 dotted indigo bags.
+pale teal bags contain 5 dull plum bags, 5 dim crimson bags, 5 shiny purple bags.
+mirrored yellow bags contain 1 posh olive bag.
+dim silver bags contain 4 clear magenta bags, 3 plaid silver bags, 1 striped maroon bag.
+posh cyan bags contain 5 pale coral bags, 2 faded magenta bags, 4 dim cyan bags.
+clear silver bags contain 1 muted red bag, 1 faded turquoise bag.
+shiny black bags contain 1 dim blue bag.
+bright silver bags contain 4 shiny teal bags, 1 dull red bag, 4 bright olive bags, 2 shiny brown bags.
+drab aqua bags contain 3 vibrant indigo bags, 5 wavy cyan bags, 3 shiny violet bags, 2 dull bronze bags.
+vibrant lavender bags contain 1 muted turquoise bag, 5 light crimson bags, 3 wavy crimson bags.
+pale lavender bags contain 2 posh blue bags, 5 dim red bags.
+plaid black bags contain 2 faded green bags, 1 bright black bag.
+dotted white bags contain 5 shiny gold bags, 2 dotted magenta bags.
+wavy maroon bags contain 3 striped white bags, 3 mirrored black bags, 3 plaid turquoise bags.
+dotted plum bags contain 1 faded coral bag.
+striped salmon bags contain 4 plaid indigo bags, 1 light brown bag, 4 posh tomato bags, 1 bright chartreuse bag.
+faded violet bags contain 5 shiny coral bags.
+dotted fuchsia bags contain 3 dim red bags, 1 muted purple bag, 3 striped indigo bags, 3 drab magenta bags.
+dark coral bags contain 4 pale lavender bags, 2 posh coral bags, 5 striped olive bags, 1 clear bronze bag.
+posh tan bags contain 2 dark silver bags.
+dotted green bags contain 3 drab white bags, 4 drab red bags, 4 pale magenta bags.
+clear blue bags contain 2 plaid fuchsia bags, 2 dotted purple bags, 2 faded violet bags, 1 dim blue bag.
+dotted olive bags contain 3 plaid fuchsia bags, 2 dim gold bags, 1 shiny crimson bag, 2 muted tan bags.
+plaid red bags contain 3 dull violet bags, 1 dotted crimson bag, 1 dull plum bag.
+plaid teal bags contain 4 muted tomato bags, 5 posh tan bags.
+striped green bags contain 5 dotted gray bags, 1 faded green bag, 1 muted brown bag.
+pale gold bags contain 4 shiny purple bags, 2 dim cyan bags.
+dim salmon bags contain 3 bright green bags, 2 dim magenta bags, 1 dim black bag.
+drab beige bags contain 3 light lime bags, 2 faded teal bags, 3 light fuchsia bags.
+shiny green bags contain 5 wavy gray bags, 1 mirrored tan bag.
+dark red bags contain 4 mirrored silver bags, 5 pale plum bags, 1 wavy violet bag.
+wavy black bags contain 1 drab white bag, 4 shiny chartreuse bags, 2 striped white bags.
+vibrant white bags contain 5 shiny lavender bags, 4 dark black bags, 1 dull bronze bag.
+faded silver bags contain 3 vibrant purple bags, 5 mirrored blue bags, 5 dull chartreuse bags, 1 faded bronze bag.
+mirrored brown bags contain 5 dull plum bags, 3 mirrored orange bags, 1 light gold bag, 5 light cyan bags.
+striped brown bags contain 4 muted indigo bags, 3 dim coral bags, 3 drab turquoise bags.
+faded beige bags contain 1 drab chartreuse bag, 5 faded fuchsia bags, 1 clear salmon bag, 2 dim cyan bags.
+pale salmon bags contain 1 dotted tomato bag, 5 faded silver bags, 2 dim beige bags.
+striped chartreuse bags contain 1 light magenta bag.
+pale chartreuse bags contain 3 dark white bags, 5 shiny aqua bags.
+wavy teal bags contain 2 light orange bags, 3 dull cyan bags.
+dull tan bags contain 3 mirrored purple bags, 5 plaid turquoise bags, 5 posh blue bags, 5 shiny crimson bags.
+wavy white bags contain 5 wavy olive bags.
+clear magenta bags contain 1 pale lavender bag.
+light gold bags contain 1 posh maroon bag, 1 dull olive bag, 3 striped chartreuse bags.
+striped olive bags contain 4 clear magenta bags, 3 clear gold bags, 3 shiny black bags.
+plaid aqua bags contain 5 posh tan bags, 4 mirrored indigo bags, 3 drab white bags, 1 drab red bag.
+dark maroon bags contain 4 dim purple bags, 5 dark turquoise bags.
+mirrored magenta bags contain 3 striped lime bags, 4 posh lime bags, 2 shiny olive bags.
+bright brown bags contain 5 dim yellow bags.
+bright black bags contain 4 posh brown bags, 3 shiny beige bags, 2 wavy lavender bags.
+light olive bags contain 1 dark purple bag, 2 clear fuchsia bags, 2 striped blue bags, 4 pale brown bags.
+dull beige bags contain 5 shiny fuchsia bags, 4 muted brown bags, 5 posh gray bags, 4 posh maroon bags.
+bright indigo bags contain 5 dotted coral bags, 2 dull red bags, 5 dotted olive bags.
+drab cyan bags contain 1 mirrored brown bag, 4 dim aqua bags, 4 mirrored plum bags.
+faded magenta bags contain 2 dull silver bags, 3 clear gold bags.
+pale aqua bags contain 1 bright indigo bag, 2 posh maroon bags, 1 pale lavender bag.
+light red bags contain 3 muted magenta bags, 4 pale olive bags.
+vibrant salmon bags contain 3 dim tomato bags, 1 vibrant lavender bag, 4 muted plum bags.
+striped blue bags contain 1 dull tan bag, 3 muted silver bags, 2 dotted green bags.
+shiny olive bags contain 1 plaid cyan bag, 5 dark violet bags, 3 clear bronze bags.
+drab black bags contain 1 faded black bag.
+posh bronze bags contain 5 plaid brown bags, 1 striped white bag.
+posh blue bags contain 3 plaid fuchsia bags, 1 muted silver bag, 1 drab chartreuse bag.
+posh fuchsia bags contain 5 plaid red bags, 5 vibrant silver bags, 4 faded coral bags.
+clear olive bags contain 1 plaid orange bag, 5 dim cyan bags.
+striped red bags contain 3 clear crimson bags, 5 clear lime bags, 4 faded bronze bags, 2 posh teal bags.
+dotted coral bags contain 2 pale silver bags.
+drab teal bags contain 2 pale violet bags, 1 mirrored red bag.
+pale black bags contain 5 dull olive bags.
+vibrant brown bags contain 1 mirrored indigo bag, 3 clear white bags.
+pale olive bags contain 1 pale white bag, 1 dark plum bag, 1 dim tomato bag, 1 vibrant beige bag.
+faded orange bags contain 1 striped coral bag, 3 dull plum bags, 3 drab silver bags, 3 clear fuchsia bags.
+plaid silver bags contain 3 drab chartreuse bags.
+pale beige bags contain 5 clear yellow bags, 2 vibrant purple bags, 1 faded salmon bag.
+dark magenta bags contain 2 wavy lavender bags, 4 shiny tomato bags, 2 faded plum bags.
+dark purple bags contain 2 clear brown bags, 1 vibrant chartreuse bag, 1 vibrant fuchsia bag, 5 pale blue bags.
+vibrant yellow bags contain 5 drab chartreuse bags.
+light silver bags contain 5 shiny crimson bags.
+clear maroon bags contain 2 plaid teal bags, 4 muted tomato bags, 3 faded tan bags.
+drab turquoise bags contain 1 plaid yellow bag, 4 wavy bronze bags, 3 vibrant olive bags.
+drab salmon bags contain 1 dark white bag, 3 light plum bags, 3 posh silver bags, 3 clear salmon bags.
+shiny magenta bags contain 1 striped chartreuse bag.
+dull indigo bags contain 2 striped green bags.
+posh green bags contain 4 muted gold bags, 2 light chartreuse bags.
+striped crimson bags contain 5 striped turquoise bags.
+posh aqua bags contain 5 light magenta bags.
+vibrant bronze bags contain 4 pale magenta bags, 4 light silver bags, 2 vibrant yellow bags, 2 wavy yellow bags.
+bright bronze bags contain 3 dark violet bags, 1 dim black bag, 2 dark silver bags.
+plaid orange bags contain 3 dim tomato bags, 3 drab turquoise bags.
+drab lime bags contain 1 drab white bag, 5 muted white bags.
+bright lime bags contain 5 shiny teal bags, 3 muted purple bags.
+wavy lime bags contain 5 dull maroon bags.
+dim indigo bags contain 4 pale cyan bags, 2 dotted turquoise bags, 2 striped blue bags, 2 posh brown bags.
+wavy blue bags contain 2 pale plum bags.
+muted brown bags contain 1 muted silver bag, 1 dotted olive bag, 1 drab fuchsia bag.
+shiny bronze bags contain 2 dotted gray bags, 2 shiny magenta bags, 4 posh black bags.
+light fuchsia bags contain 3 mirrored brown bags, 1 faded purple bag, 2 wavy violet bags, 1 posh salmon bag.
+light maroon bags contain 4 dull chartreuse bags, 4 dotted cyan bags, 2 muted tan bags.
+muted teal bags contain 2 muted coral bags, 1 dotted aqua bag, 2 vibrant gray bags, 5 dim crimson bags.
+shiny yellow bags contain 4 bright olive bags.
+bright maroon bags contain 2 clear maroon bags, 2 striped cyan bags.
+pale crimson bags contain 1 posh blue bag, 4 posh maroon bags, 2 clear lavender bags.
+dim orange bags contain 5 striped fuchsia bags, 3 posh tan bags, 1 striped beige bag.
+vibrant green bags contain 3 dotted violet bags, 2 shiny crimson bags, 1 clear lavender bag.
+striped orange bags contain 3 bright white bags, 2 dotted maroon bags, 5 drab indigo bags.
+dull plum bags contain 1 striped fuchsia bag, 3 faded crimson bags, 3 dim green bags, 2 posh lavender bags.
+drab olive bags contain 2 posh white bags, 3 bright salmon bags.
+dull green bags contain 5 wavy turquoise bags, 4 mirrored gray bags, 3 light maroon bags.
+mirrored cyan bags contain 1 plaid beige bag.
+plaid cyan bags contain 5 faded chartreuse bags, 5 shiny crimson bags, 3 drab fuchsia bags, 4 wavy aqua bags.
+posh yellow bags contain 5 dark chartreuse bags.
+clear orange bags contain 3 bright green bags, 4 shiny gold bags.
+dim magenta bags contain 5 faded crimson bags, 3 plaid tan bags, 5 mirrored orange bags, 1 pale lavender bag.
+bright beige bags contain 4 bright gold bags, 5 pale chartreuse bags.
+dark plum bags contain 2 pale silver bags.
+bright violet bags contain 1 dotted green bag.
+vibrant cyan bags contain 1 dark turquoise bag.
+posh gray bags contain 3 pale crimson bags, 3 muted white bags, 4 shiny brown bags, 3 clear magenta bags.
+striped beige bags contain 5 dull bronze bags, 4 dim blue bags, 1 dotted olive bag.
+shiny gold bags contain 5 vibrant green bags, 4 pale violet bags, 4 dull olive bags, 3 pale white bags.
+dark salmon bags contain 3 muted bronze bags, 4 muted silver bags, 2 pale purple bags.
+wavy tan bags contain 3 light turquoise bags, 5 dark bronze bags.
+light plum bags contain 5 wavy bronze bags, 4 dull crimson bags, 5 dim aqua bags.
+drab silver bags contain 2 dim fuchsia bags, 3 wavy bronze bags.
+plaid indigo bags contain 3 plaid tomato bags, 5 clear beige bags.
+pale lime bags contain 2 striped cyan bags, 2 mirrored lavender bags.
+faded gold bags contain 4 faded tomato bags, 2 light cyan bags, 2 pale orange bags, 1 wavy bronze bag.
+striped tan bags contain 1 bright silver bag, 2 faded green bags, 5 dim blue bags, 1 shiny maroon bag.
+drab purple bags contain 3 dull red bags, 3 light olive bags, 3 shiny red bags.
+muted orange bags contain 1 mirrored brown bag, 2 muted green bags.
+dull brown bags contain 3 dim silver bags, 4 posh lavender bags, 5 dark white bags.
+wavy tomato bags contain 1 drab lime bag, 1 shiny teal bag, 5 dotted violet bags, 4 light crimson bags.
+dark green bags contain 2 posh orange bags, 4 mirrored tan bags, 5 mirrored violet bags.
+wavy turquoise bags contain 4 light salmon bags, 2 shiny maroon bags, 1 muted salmon bag.
+posh orange bags contain 5 dull red bags, 1 drab lime bag, 2 shiny gold bags.
+vibrant indigo bags contain 5 dark violet bags.
+faded fuchsia bags contain 5 clear lavender bags, 1 dull silver bag, 5 drab lime bags, 3 bright white bags.
+wavy beige bags contain 3 vibrant green bags, 3 faded teal bags, 4 muted indigo bags.
+pale fuchsia bags contain 1 drab lime bag.
+muted salmon bags contain 1 dotted violet bag, 4 vibrant chartreuse bags, 3 muted silver bags.
+shiny red bags contain 2 dull gray bags, 3 pale white bags, 1 faded brown bag.
+clear gray bags contain 1 posh maroon bag, 1 shiny beige bag.
+muted green bags contain 1 drab magenta bag, 3 pale fuchsia bags, 5 dark fuchsia bags, 1 dull gray bag.
+vibrant purple bags contain 1 vibrant yellow bag, 4 muted aqua bags.
+dark fuchsia bags contain 5 mirrored lavender bags, 2 dim red bags, 5 shiny teal bags, 5 vibrant beige bags.
+striped purple bags contain 2 dim aqua bags, 1 posh teal bag, 5 pale brown bags.
+posh lime bags contain 2 wavy aqua bags.
+striped violet bags contain 2 dotted chartreuse bags.
+muted lime bags contain 1 shiny brown bag, 2 bright purple bags, 2 drab chartreuse bags, 4 clear lavender bags.
+light gray bags contain 5 dull maroon bags, 4 dull crimson bags, 5 mirrored cyan bags.
+mirrored maroon bags contain 1 mirrored chartreuse bag, 1 muted cyan bag.
+light turquoise bags contain 2 bright yellow bags.
+vibrant blue bags contain 4 muted tomato bags, 2 dull salmon bags.
+mirrored indigo bags contain 3 light chartreuse bags, 5 dark turquoise bags.
+faded bronze bags contain 5 dotted chartreuse bags.
+dotted beige bags contain 4 bright purple bags, 2 striped green bags, 3 posh brown bags.
+drab red bags contain 2 vibrant chartreuse bags, 1 dim red bag, 4 dark silver bags, 4 pale magenta bags.
+wavy orange bags contain 3 striped bronze bags, 4 dotted tan bags.
+striped black bags contain 1 shiny tomato bag.
+drab gold bags contain 1 plaid lime bag, 2 wavy lavender bags.
+shiny brown bags contain 5 dull tan bags.
+posh beige bags contain 1 drab gold bag, 3 dull beige bags, 1 posh blue bag, 2 drab red bags.
+light green bags contain 3 mirrored tan bags.
+mirrored coral bags contain 5 mirrored lavender bags, 5 dark white bags, 5 pale silver bags.
+plaid bronze bags contain 3 pale lavender bags, 1 muted silver bag, 2 faded teal bags, 1 dull teal bag.
+light chartreuse bags contain 1 muted blue bag, 4 posh chartreuse bags, 2 wavy aqua bags, 4 vibrant orange bags.
+drab yellow bags contain 2 shiny aqua bags.
+plaid turquoise bags contain no other bags.
+drab orange bags contain 1 posh salmon bag, 5 dark violet bags.
+dark teal bags contain 4 bright indigo bags, 3 plaid coral bags, 1 dark violet bag, 5 shiny tomato bags.
+drab gray bags contain 4 dotted maroon bags.
+dotted maroon bags contain 4 plaid turquoise bags, 5 pale bronze bags.
+muted red bags contain 5 posh brown bags.
+dim olive bags contain 3 posh brown bags, 2 faded plum bags, 4 wavy tomato bags.
+pale maroon bags contain 5 dark gold bags, 3 dotted silver bags, 3 shiny tomato bags.
+dotted turquoise bags contain 1 plaid blue bag, 5 dim green bags, 5 dull plum bags.
+dotted tomato bags contain 2 dotted indigo bags, 2 clear fuchsia bags.
+dark aqua bags contain 5 posh olive bags.
+dark tan bags contain 5 dotted chartreuse bags, 5 posh red bags, 3 plaid cyan bags, 5 pale plum bags.
+bright chartreuse bags contain 4 posh white bags, 4 shiny maroon bags, 1 shiny tomato bag.
+striped gray bags contain 4 shiny gold bags, 3 drab white bags, 3 plaid cyan bags.
+dull olive bags contain 4 plaid brown bags, 2 plaid turquoise bags, 2 plaid cyan bags, 1 vibrant green bag.
+shiny indigo bags contain 3 shiny black bags, 1 dark orange bag, 1 posh white bag.
+bright lavender bags contain 1 muted salmon bag, 5 posh maroon bags.
+plaid white bags contain 5 wavy silver bags.
+light coral bags contain 3 pale silver bags.
+plaid plum bags contain 4 shiny brown bags, 1 dark silver bag, 4 pale lavender bags.
+light magenta bags contain 5 drab chartreuse bags.
+shiny tan bags contain 4 vibrant chartreuse bags, 5 dim brown bags.
+wavy magenta bags contain 1 vibrant turquoise bag, 4 dull violet bags, 5 clear indigo bags.
+pale blue bags contain 2 posh lime bags, 1 shiny brown bag.
+dull orange bags contain 5 dull lime bags, 1 pale crimson bag.
+striped white bags contain 1 posh aqua bag, 3 pale magenta bags, 2 posh gray bags.
+dotted aqua bags contain 2 plaid teal bags.
+wavy indigo bags contain 4 dark blue bags, 3 dotted black bags, 2 pale violet bags, 4 pale silver bags.
+bright plum bags contain 3 muted green bags.
+bright gold bags contain 3 dull beige bags, 3 faded plum bags, 1 mirrored gray bag, 5 muted lime bags.
+clear fuchsia bags contain 3 clear orange bags, 5 dull crimson bags, 3 drab red bags, 5 vibrant silver bags.
+posh olive bags contain 2 vibrant green bags.
+faded maroon bags contain 2 vibrant chartreuse bags, 5 drab tomato bags, 3 dim tomato bags.
+posh violet bags contain 1 dim gold bag, 2 light chartreuse bags, 4 faded indigo bags, 2 plaid violet bags.
+drab blue bags contain 4 muted purple bags, 5 bright olive bags.
+dull turquoise bags contain 5 pale lavender bags, 3 light aqua bags, 3 drab teal bags.
+striped silver bags contain 4 wavy black bags, 5 plaid magenta bags.
+striped gold bags contain 3 shiny tomato bags, 2 light fuchsia bags, 1 bright salmon bag.
+mirrored violet bags contain 4 mirrored blue bags.
+vibrant red bags contain 4 striped lavender bags, 1 clear fuchsia bag.
+striped yellow bags contain 3 vibrant red bags.
+dotted silver bags contain 1 muted blue bag, 3 shiny teal bags, 2 plaid coral bags, 1 dim aqua bag.

+ 45 - 0
aoc2020/7th/main.jl

@@ -0,0 +1,45 @@
+using BenchmarkTools
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data = readlines(selfdir)
+
+function parse_line(line)
+    main_bag, contains = split(line, " bags contain ")
+    if contains == "no other bags."
+        return (main_bag, ())
+    else
+        con = collect(match(r"^(\d+) ([a-z ]+) bags?\.?$", bag).captures for bag in split(contains, ", ")) .|>
+                x -> (parse(Int, x[1]), x[2])
+        return main_bag, con
+    end 
+end
+
+#--------part1
+
+function shiny_gold(bag, rules)
+    if bag == "shiny gold"
+        return true
+    else
+        return any(shiny_gold(name, rules) for (_, name) in rules[bag])
+    end
+end
+
+function inside_shiny_gold(bag, rules)
+    return 1 + reduce(+, (num * inside_shiny_gold(name, rules) for (num, name) in rules[bag]), init=0)
+end
+
+#---------part2
+
+function contains_shiny_gold()
+    data .|> parse_line |> Dict |> x -> [shiny_gold(name , x) for name in keys(x) if name != "shiny gold"] |> sum
+end
+
+function how_much_inside_shiny_gold()
+    (data .|> parse_line |> Dict |> x -> inside_shiny_gold("shiny gold" , x)) - 1
+end
+
+#---------evaluation
+
+part1 = @btime contains_shiny_gold()
+part1 = @btime how_much_inside_shiny_gold()

+ 631 - 0
aoc2020/8th/input

@@ -0,0 +1,631 @@
+nop +283
+acc +26
+acc +37
+acc +6
+jmp +109
+acc +10
+jmp +18
+acc +5
+jmp +327
+acc -4
+jmp +269
+acc -7
+acc +27
+nop +7
+acc +0
+jmp +81
+acc +42
+nop +338
+acc -5
+jmp +391
+nop +276
+jmp +354
+acc +22
+jmp +528
+acc +0
+acc +20
+acc +15
+acc -17
+jmp +537
+acc -15
+acc +12
+acc -17
+acc +17
+jmp +34
+acc -19
+jmp +88
+acc +19
+acc +35
+acc +17
+acc +7
+jmp +443
+acc +22
+jmp +584
+jmp -2
+jmp +408
+acc +46
+acc +43
+acc +4
+jmp +532
+acc -19
+acc -19
+acc +38
+acc -10
+jmp +476
+acc +1
+acc +3
+acc +19
+acc +28
+jmp +480
+jmp +1
+acc +32
+acc -2
+jmp +518
+acc +5
+acc -19
+acc +19
+jmp +344
+jmp +99
+acc +0
+acc +30
+acc -13
+acc -19
+jmp +385
+acc -18
+jmp +157
+acc +15
+acc +4
+jmp +503
+acc -6
+acc +42
+jmp +461
+acc -6
+jmp +328
+acc -9
+nop +199
+acc +15
+jmp +206
+jmp +182
+acc +35
+nop +275
+acc +3
+jmp +1
+jmp -25
+nop -20
+nop -6
+jmp -7
+nop +145
+acc +4
+acc +28
+jmp +315
+nop -76
+nop +12
+nop +170
+jmp +291
+acc -16
+acc +5
+nop -10
+jmp +235
+acc +6
+acc -1
+nop +492
+acc +44
+jmp +119
+jmp +128
+jmp +1
+jmp +328
+acc -7
+jmp +126
+nop +351
+acc +9
+acc +4
+acc -1
+jmp +276
+acc +0
+nop +133
+acc +36
+acc +32
+jmp +173
+acc +41
+nop -95
+jmp +153
+acc +7
+acc +13
+acc -10
+jmp +223
+jmp +186
+acc +4
+jmp +90
+acc -7
+acc +15
+jmp +366
+acc +9
+acc +27
+acc +1
+jmp +417
+acc -19
+jmp +268
+acc +38
+acc +1
+acc +27
+jmp +1
+jmp +420
+acc +13
+acc +9
+acc +1
+jmp +370
+acc +25
+acc +3
+acc -1
+jmp +324
+nop +352
+acc +39
+jmp +121
+acc +15
+jmp +348
+jmp +11
+acc -12
+acc +23
+jmp +407
+jmp -6
+acc +43
+jmp -8
+acc +48
+nop +316
+acc +5
+jmp +323
+acc +3
+jmp +1
+acc +34
+jmp +191
+jmp -160
+acc -18
+acc +33
+jmp -79
+acc +9
+acc +50
+acc -15
+acc -1
+jmp -100
+acc -18
+acc +49
+nop -184
+acc +20
+jmp +404
+nop +280
+jmp +294
+acc -12
+jmp +1
+acc +8
+jmp +320
+nop +387
+acc +15
+nop +359
+acc -7
+jmp +182
+nop +1
+nop -40
+acc +3
+jmp -38
+acc +44
+acc -11
+nop +297
+jmp +174
+jmp -140
+acc +32
+acc +28
+acc +8
+acc +9
+jmp -194
+acc -9
+acc +32
+jmp +291
+acc +43
+nop +220
+acc +9
+acc +15
+jmp -167
+jmp -8
+acc -3
+acc +12
+jmp +195
+acc +48
+acc +16
+nop +137
+acc +29
+jmp +48
+acc +11
+acc +46
+acc +22
+acc -2
+jmp -167
+jmp +123
+jmp +128
+acc +24
+acc +50
+acc -10
+jmp -202
+acc -17
+acc -13
+jmp +1
+jmp +89
+acc -4
+acc +41
+jmp +111
+acc +50
+acc +41
+jmp +83
+acc -2
+nop +194
+jmp +239
+acc +33
+acc +25
+jmp +347
+nop +6
+acc +0
+acc -16
+jmp +73
+acc -12
+jmp -5
+jmp +188
+jmp +1
+jmp -264
+acc +44
+acc +6
+acc +35
+jmp +312
+acc +28
+acc +8
+jmp -15
+acc +48
+jmp +215
+acc -1
+jmp -55
+acc +22
+acc -18
+acc +47
+jmp -266
+jmp +1
+acc +18
+acc +0
+acc -11
+jmp +221
+acc -10
+nop -189
+jmp -216
+jmp -3
+acc -8
+acc +22
+jmp +253
+jmp -168
+acc -7
+acc +14
+nop +315
+acc +11
+jmp -47
+nop -36
+acc +40
+jmp +95
+jmp +13
+acc -14
+acc -5
+acc +48
+jmp -85
+acc -17
+acc +20
+acc -5
+acc +6
+jmp +221
+acc +32
+acc +7
+jmp +12
+nop +266
+acc -11
+acc -8
+nop +182
+jmp -184
+nop -137
+acc +48
+jmp +155
+jmp -124
+acc +44
+jmp +24
+acc +12
+jmp -292
+jmp +195
+jmp -301
+acc +45
+acc -14
+jmp -66
+jmp +86
+acc +33
+jmp -136
+jmp -146
+acc -3
+acc -13
+acc +16
+jmp -183
+acc +4
+acc -8
+acc +14
+jmp -169
+acc +35
+acc +18
+nop -24
+jmp -127
+jmp -219
+jmp +190
+acc -4
+acc +1
+jmp +62
+nop +220
+acc +18
+acc +36
+jmp +58
+acc +25
+jmp +21
+nop -24
+acc +2
+acc +49
+jmp -325
+acc +24
+acc +23
+acc +13
+jmp +143
+jmp -45
+nop +212
+jmp -29
+acc -12
+acc -12
+jmp -107
+nop +126
+acc +32
+jmp -113
+jmp +1
+acc -6
+jmp -102
+nop +57
+acc -16
+acc +25
+jmp -213
+acc +19
+acc +29
+acc +0
+jmp -320
+acc +42
+jmp +94
+acc +6
+jmp -363
+acc -18
+jmp -365
+acc +39
+jmp +13
+acc +47
+acc +24
+acc +9
+acc +25
+jmp +151
+acc +17
+jmp +1
+jmp -77
+jmp +24
+acc -13
+acc -13
+jmp -141
+acc +22
+acc +9
+nop +92
+jmp -334
+acc +30
+acc +11
+jmp -304
+acc +8
+jmp -275
+acc +35
+jmp -95
+jmp +1
+acc -18
+nop -407
+nop -18
+jmp +146
+acc +37
+acc -4
+acc +19
+jmp -409
+acc +28
+acc -10
+nop +151
+acc +17
+jmp -418
+nop +56
+acc +40
+acc -13
+jmp -301
+acc +28
+acc -7
+acc -6
+jmp +62
+acc +0
+acc +6
+acc +25
+acc +26
+jmp +18
+acc -14
+jmp +93
+acc +43
+acc +19
+jmp -109
+acc +24
+acc +0
+jmp -328
+acc +42
+jmp -165
+acc -3
+acc +18
+jmp +153
+jmp +1
+acc -10
+acc -7
+jmp -199
+acc +30
+nop -403
+acc -12
+jmp -209
+jmp -242
+acc +38
+nop +33
+acc -10
+acc +22
+jmp -419
+acc -18
+acc +27
+acc +22
+jmp -57
+nop -313
+acc +20
+acc -7
+acc -10
+jmp -371
+jmp -159
+jmp -478
+acc +9
+acc +7
+acc +15
+nop +72
+jmp -358
+jmp -138
+acc -17
+jmp +9
+acc +47
+acc -2
+jmp -221
+nop -331
+nop -297
+acc +12
+acc -13
+jmp +3
+jmp -198
+jmp -150
+acc +17
+jmp -313
+nop -314
+jmp +69
+acc +0
+nop -397
+jmp -104
+jmp -223
+acc -14
+jmp +44
+jmp -61
+acc -7
+acc -18
+jmp -270
+acc -14
+acc +32
+jmp -177
+jmp +84
+acc +6
+nop +14
+jmp +47
+acc +37
+acc -19
+acc -9
+jmp -200
+acc +11
+acc -5
+acc +2
+acc +37
+jmp -488
+nop +19
+jmp -490
+jmp -491
+acc +24
+acc +30
+acc +14
+jmp -19
+jmp -37
+acc +19
+jmp -540
+acc +48
+acc +22
+jmp -434
+jmp -196
+acc +12
+acc -9
+acc +48
+acc -5
+jmp -433
+acc +23
+jmp -245
+acc +43
+jmp -228
+acc +44
+jmp -168
+nop -221
+jmp -102
+jmp +1
+acc +39
+nop -153
+jmp -455
+acc +48
+jmp -75
+jmp +31
+nop -383
+acc -12
+jmp -245
+acc -2
+acc +3
+jmp -421
+acc +38
+jmp -158
+acc +39
+acc -4
+acc -1
+acc +0
+jmp -186
+acc +28
+jmp -247
+jmp +1
+acc -19
+acc +31
+acc +34
+jmp -148
+acc +5
+nop -417
+nop -230
+acc +11
+jmp -162
+jmp +1
+acc +32
+jmp -303
+nop -214
+jmp -332
+acc -10
+acc +33
+jmp -142
+acc +19
+acc +41
+acc +12
+jmp -495
+acc +42
+nop -318
+acc +36
+jmp -524
+jmp +1
+acc +46
+acc -6
+jmp -582
+acc +28
+acc +38
+acc -17
+acc +2
+jmp -432
+acc +35
+nop -550
+acc -6
+jmp -394
+acc +38
+acc +49
+nop -99
+acc +50
+jmp +1

+ 58 - 0
aoc2020/8th/main.jl

@@ -0,0 +1,58 @@
+using BenchmarkTools
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data = (readlines(selfdir) .|> x -> split(x, " ") |> x -> [x[1], parse(Int, x[2])]) |> enumerate |> collect
+
+#--------part1
+
+function check_boot(data=data)
+    ind = 1
+    spent_ind = []
+    accumulator = 0
+    while !(ind in spent_ind) & (ind <= length(data))
+        ind, (instruction, number) = data[ind]
+        push!(spent_ind, ind)
+        if instruction == "acc"
+            accumulator += number
+            ind += 1
+        elseif instruction == "jmp"
+            ind += number
+        else
+            ind += 1
+        end
+    end
+    if ind == length(data) + 1
+        return accumulator, true
+    else
+        return accumulator, false
+    end
+end
+
+#--------part2
+
+function fix(data=data)
+    c_data = deepcopy(data)
+    ind = 1
+    while ind <= length(c_data)
+        ind, (instr, number) = c_data[ind]
+        if instr == "acc"
+            ind += 1
+            continue
+        end
+        c_data[ind][2][1] = instr == "jmp" ? "nop" : "jmp"
+        accumulator, check = check_boot(c_data)
+        if check
+            return accumulator, ind
+        else
+            c_data[ind][2][1] = instr
+            ind += 1
+        end
+    end
+end
+
+#---------evaluation
+
+part1 = @btime check_boot()
+
+part2 = @btime fix()

+ 1000 - 0
aoc2020/9th/input

@@ -0,0 +1,1000 @@
+33
+42
+23
+38
+45
+20
+48
+21
+30
+49
+5
+25
+35
+39
+27
+31
+8
+16
+36
+2
+41
+1
+9
+4
+34
+3
+7
+6
+33
+10
+11
+12
+13
+14
+15
+17
+20
+24
+5
+49
+43
+44
+8
+16
+48
+58
+18
+56
+19
+31
+25
+63
+29
+39
+27
+38
+32
+21
+13
+22
+23
+59
+41
+24
+42
+26
+37
+33
+34
+35
+93
+36
+40
+43
+44
+76
+45
+49
+62
+100
+53
+64
+97
+113
+68
+47
+85
+50
+57
+206
+71
+67
+89
+69
+75
+79
+80
+87
+110
+91
+92
+263
+102
+103
+140
+137
+104
+107
+164
+97
+114
+117
+181
+124
+146
+136
+169
+144
+199
+154
+399
+355
+301
+195
+183
+189
+201
+200
+204
+251
+224
+296
+214
+241
+211
+261
+253
+260
+307
+280
+327
+298
+372
+349
+496
+383
+384
+481
+387
+411
+531
+401
+502
+662
+462
+452
+425
+455
+464
+471
+744
+513
+558
+587
+578
+676
+839
+721
+845
+964
+767
+863
+858
+812
+924
+1386
+826
+907
+926
+1445
+916
+1042
+919
+1426
+1607
+1071
+1091
+1165
+1254
+1299
+1397
+1488
+1961
+1835
+1579
+1838
+1934
+1638
+1719
+1949
+1733
+1742
+1823
+1842
+1958
+2370
+1990
+2010
+2162
+2419
+2236
+2464
+2553
+3800
+3997
+2885
+4111
+3589
+3217
+3565
+3357
+3371
+4161
+3452
+3691
+3475
+4655
+3665
+6576
+5649
+5347
+11231
+9238
+4626
+4700
+4789
+5349
+5438
+6102
+7062
+6242
+6574
+6588
+6782
+6728
+6809
+6823
+6927
+7117
+7140
+8101
+9907
+11363
+14677
+9326
+9415
+14764
+12012
+18740
+12166
+10138
+12555
+11540
+12830
+12816
+13655
+13302
+13370
+13899
+24721
+13632
+13963
+16342
+16466
+30121
+23378
+18741
+20689
+19464
+19553
+24567
+30305
+26462
+23770
+21678
+23508
+24095
+24356
+26793
+36748
+32043
+48662
+27002
+29974
+32373
+27595
+30429
+32808
+60095
+38294
+39430
+38205
+39017
+62525
+63997
+87767
+76499
+45186
+45448
+45773
+56903
+48451
+75455
+57222
+81470
+54597
+57431
+56976
+57569
+144743
+95774
+63237
+96999
+77222
+77311
+78447
+83391
+84465
+103048
+90634
+90959
+102617
+102879
+91221
+94224
+105354
+186824
+133044
+167856
+157645
+148203
+114407
+172996
+134791
+140459
+228818
+160702
+172671
+181593
+162912
+161838
+174025
+175099
+181855
+185445
+353301
+360849
+282263
+196575
+199578
+253557
+360280
+454934
+310982
+272052
+249198
+338011
+302297
+410411
+358413
+510560
+606986
+334509
+359470
+335863
+689164
+349124
+356954
+367300
+453135
+659251
+445773
+450132
+532438
+448776
+502755
+521250
+616498
+880720
+551495
+851879
+1062271
+788998
+1108027
+670372
+1055762
+683633
+684987
+692817
+1066630
+1133765
+706078
+724254
+1137748
+894549
+898908
+952887
+1119148
+951531
+1394626
+1236482
+1655015
+1221867
+1340493
+1623162
+1354005
+1636520
+1355359
+1376450
+1790884
+1368620
+2478241
+3031465
+2204378
+4133256
+1430332
+1600627
+1793457
+1850439
+1846080
+2321507
+2346157
+3204444
+2173398
+2458349
+2954632
+3840898
+2963655
+2955986
+3558383
+2709364
+5235843
+3276412
+2745070
+2798952
+3214700
+5160364
+3946784
+3997835
+3030959
+3223789
+3394084
+8114996
+4559803
+4019478
+4494905
+8400701
+7340868
+5740323
+5203419
+6773083
+6240067
+9182627
+5454434
+11673379
+8163798
+8253386
+5544022
+5776029
+6818430
+6245659
+6254748
+13569430
+6425043
+6617873
+11194757
+10734972
+8514383
+8579281
+9222897
+14936881
+10657853
+12362452
+17434824
+10747441
+14058405
+11230463
+23859867
+11798770
+17440416
+31493229
+11320051
+17352845
+12021688
+12679791
+12863532
+34793261
+13042916
+17093664
+15197154
+21902688
+21194174
+17737280
+26316561
+25594734
+21405294
+22550514
+23341739
+21977904
+34572202
+23029233
+43307982
+23118821
+35892765
+56474890
+56350898
+23999842
+67307824
+24701479
+38315975
+25906448
+30136580
+34945604
+36602448
+59721269
+38931454
+52687094
+41079019
+46106773
+61487499
+49025269
+44528418
+77880184
+45007137
+46148054
+47029075
+82840090
+47820300
+48701321
+49906290
+58945446
+104249687
+70808252
+50607927
+64837902
+77956880
+65082184
+71548052
+57195069
+98428227
+80010473
+106494636
+85607437
+90635191
+91155191
+93229739
+89535555
+92036212
+92827437
+93177129
+94849375
+127830773
+96521621
+126658201
+156874114
+140143482
+122277253
+107802996
+181571767
+122032971
+128743121
+220779333
+137205542
+142802506
+215104690
+182765294
+212668162
+175142992
+182362992
+180690746
+182712684
+184384930
+184863649
+218554592
+189698750
+191370996
+218798874
+204324617
+248691172
+334701133
+229835967
+259482795
+236546117
+250776092
+259238513
+265948663
+280008048
+357505984
+431054164
+357855676
+355833738
+540218668
+433554821
+363053738
+369248579
+367097614
+374083680
+374562399
+624925817
+381069746
+567378355
+423123491
+434160584
+635841786
+480612059
+487322209
+615072251
+592379855
+510014605
+525187176
+545956711
+637514032
+731939356
+738925422
+724953290
+755632145
+730151352
+732302317
+1010404185
+861884608
+741181294
+748646079
+797685890
+948310667
+1324682172
+914772643
+1670404788
+1340025541
+1079702064
+1147528637
+1161028962
+1035201781
+1055971316
+1834696777
+2109339629
+1270910001
+1362467322
+1463878712
+1457255607
+1644923995
+1471332646
+2400556140
+1603065902
+1797152610
+1489827373
+2004281983
+4045480135
+1853657206
+1863083310
+1949974424
+1970743959
+2091173097
+2395996857
+2326881317
+3298575489
+2196230743
+2306111782
+2418438638
+4901641391
+6365520103
+2633377323
+2819722929
+2921134319
+2928588253
+3134751368
+3747127034
+4003622042
+3092893275
+3286979983
+3343484579
+3833827269
+3716740516
+3803631630
+3813057734
+4297625276
+4061917056
+4287403840
+7228522708
+8014365792
+5124818996
+9709004682
+5125834711
+5553190006
+7218759595
+5561965576
+8958646265
+5740857248
+5849722572
+6021481528
+6926720544
+11214124384
+12051539540
+6379873258
+7100037717
+7060225095
+7520372146
+8100461574
+7616689364
+7874974790
+8349320896
+10028261088
+9412222836
+12479910550
+14480334832
+17901262112
+10975557283
+14620409863
+13662427150
+11302822824
+11411688148
+11590579820
+12120730506
+20860208090
+12401354786
+16408134346
+16224295686
+18500603764
+13440098353
+14160262812
+14580597241
+15137061510
+27021764649
+19028377512
+17287197626
+21618840908
+22714510972
+20387780119
+25892022980
+29912291912
+55804314892
+22278380107
+49300144756
+23813042934
+33030529056
+23002267968
+25030678173
+24522085292
+25841453139
+26561617598
+45280648075
+29717658751
+28740860053
+52863217788
+29297324322
+31867794867
+32424259136
+36315575138
+37674977745
+38906038534
+42006621027
+42666160226
+46229233258
+46091423041
+46800465399
+50374660532
+61585453618
+48843721107
+97175125931
+47524353260
+48032946141
+49552763465
+50363538431
+52403070737
+55302477651
+58458518804
+58038184375
+84348521279
+61165119189
+94774093942
+70773833401
+96876667248
+73990552883
+102766609168
+107705548388
+101955834202
+147240205679
+92320656299
+92891888440
+105982872064
+146429430713
+95557299401
+97077116725
+97585709606
+143081652661
+98396484572
+99916301896
+105666016082
+158069086819
+155939213131
+116496703179
+252906221761
+131938952590
+135155672072
+144764386284
+163094489700
+171067669608
+166311209182
+203262847789
+185212544739
+305309292498
+222162719261
+187877955700
+188449187841
+192634416126
+194662826331
+198312786468
+202743132807
+195982194178
+268760505782
+332642341984
+300328842413
+237604968672
+267094624662
+279591192879
+312478897357
+315832055892
+387297242457
+279920058356
+307858875984
+537933811085
+439828175390
+388475392528
+373090500439
+373661732580
+390621088507
+459729040788
+376327143541
+381083603967
+390645020509
+392975612799
+440348101479
+433587162850
+463076818840
+504699593334
+545463844656
+517196161551
+517525027028
+546685817541
+559511251235
+587778934340
+595752114248
+653010558795
+763735520948
+840812644755
+749988876121
+746752233019
+749417643980
+754174104406
+754745336547
+757410747508
+769302756340
+774059216766
+783620633308
+824232183359
+980601845868
+1237136035606
+1183531048588
+1281260547976
+1349926218654
+1034721188579
+1063881979092
+1064210844569
+1310421338489
+1379372747556
+2032383306351
+1345169758228
+1399762791814
+1504734212668
+1496169876999
+1533609509429
+1500926337425
+1524048092887
+1508919440953
+2079724094829
+2568330698008
+2854089199181
+4350259076180
+1804834029227
+2315981736555
+2707579141475
+2811347675914
+2098603167671
+2573130285522
+2098932033148
+2379890946807
+2128092823661
+2597820353998
+2655591096717
+2724542505784
+3009845778378
+3204596821041
+2895932668813
+3000904089667
+3034535846854
+3024974430312
+3032967533840
+5620475174597
+3313753470180
+3903437196898
+4120815765782
+7161606752094
+3903766062375
+3932926852888
+4754523129865
+6100529489854
+4197535200819
+4226695991332
+5162628670515
+6237564354881
+6828859521701
+5137938602039
+6824516345330
+5380133602501
+5725446595451
+5896836758480
+5928900202653
+5920907099125
+6033871623507
+11196500294022
+10154687389289
+11962454947369
+7217190667078
+7217519532555
+9066394732890
+10017652524262
+11825976085305
+13317720156932
+12158471454006
+9360163871334
+8424231192151
+11026394722520
+9389324661847
+10300567272554
+10518072204540
+10863385197490
+11034775360519
+11105580197952
+16075594488414
+11759318218958
+11817743857605
+17859847708812
+11954778722632
+13251062290585
+18455719394737
+14434710199633
+15641421859229
+15641750724706
+16577683403889
+28532462126521
+17784395063485
+17813555853998
+23193246814525
+28160414981366
+29631299711603
+18724798464705
+19689891934401
+19907396866387
+29739173786117
+21552847565059
+26676197219748
+22140355558471
+36509193528190
+34124602134034
+23714096941590
+23772522580237
+25205841013217
+26389488922265
+35987557764692
+39413944439466
+30076132058862
+40865154023176
+32219434128595
+34362078467374
+35597950917483
+60223290469780
+36538354318703
+42883138748926
+38414690399106
+62898682450455
+43693203123530
+39597288800788
+41460244431446
+92637856236572
+61554299997937
+45854452500061
+124452982448392
+47486619521827
+66344036262629
+48919937954807
+53848654639099

+ 82 - 0
aoc2020/9th/main.jl

@@ -0,0 +1,82 @@
+using BenchmarkTools
+
+selfdir = joinpath(splitdir(@__FILE__)[1], "input")
+
+data = parse.(Int, readlines(selfdir))
+
+#--------part1
+
+function check(preambula, number)
+    for i in 1:25
+        for j in (i+1):25
+            if preambula[i] + preambula[j] == number
+                return true
+            end
+        end
+    end
+    return false
+end
+
+function get_number()
+    preambula = []
+    is_valid = true
+    for (ind, number) in enumerate(data)
+        if (length(preambula) < 25)
+            push!(preambula, number)
+        else
+            if !check(preambula, number)
+                return ind, number
+            else
+                popfirst!(preambula)
+                push!(preambula, number)
+            end
+        end
+    end
+end
+
+#--------part2
+
+function get_weakness_number(ind)
+    for i in 1:ind
+        vv = data[i]
+        for j in (1+i):ind
+            vv += data[j]
+            if vv == data[ind]
+                min, max = minimum(data[i:j]), maximum(data[i:j])
+                return i, j, min, max, min+max
+            elseif vv > data[ind]
+                break
+            else
+                continue
+            end
+        end
+    end
+end
+
+
+continious_set = []
+for number in data[1:549]
+    _sum = reduce(+, continious_set, init=0)
+    if _sum == data[549]
+        return continious_set, min(continious_set) + max(continious_set)
+    elseif _sum < data[549] 
+        push!(continious_set, number)
+        # println("$_sum fewer $(data[549])")
+    else
+        while _sum >= data[549]
+            # println("$_sum bigger $(data[549])")
+            popfirst!(continious_set)
+            _sum = reduce(+, continious_set, init=0)
+            if _sum == data[549]
+                return continious_set, min(continious_set) + max(continious_set)
+            end
+        end
+    end
+    return "pidor"
+end
+
+
+#--------evaluation
+
+part1 = @btime get_number()
+part2 = @btime get_weakness_number(part1[1])

+ 1 - 0
aoc2020/README.md

@@ -0,0 +1 @@
+adventcode2020

+ 32 - 0
aoc2021/.gitignore

@@ -0,0 +1,32 @@
+# Generated by Cargo
+# will have compiled files and executables
+/target/
+target
+
+# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
+# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
+Cargo.lock
+
+# These are backup files generated by rustfmt
+**/*.rs.bk
+
+# python
+.mypy_cache
+__pycache__
+
+#vscode
+.vscode
+
+
+
+# Added by cargo
+/target
+
+# MacOs
+.DS_Store
+
+# Added by cargo
+#
+# already existing elements were commented out
+
+#/target

+ 8 - 0
aoc2021/day10_syntax_scoring/Cargo.toml

@@ -0,0 +1,8 @@
+[package]
+name = "day10_syntax_scoring"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 138 - 0
aoc2021/day10_syntax_scoring/README.md

@@ -0,0 +1,138 @@
+--- Day 10: Syntax Scoring ---
+------------------------------
+
+You ask the submarine to determine the best route out of the deep-sea cave, but it only replies:
+
+
+
+```
+Syntax error in navigation subsystem on line: all of them
+```
+
+*All of them?!* The damage is worse than you thought. You bring up a copy of the navigation subsystem (your puzzle input).
+
+
+The navigation subsystem syntax is made of several lines containing *chunks*. There are one or more chunks on each line, and chunks contain zero or more other chunks. Adjacent chunks are not separated by any delimiter; if one chunk stops, the next chunk (if any) can immediately start. Every chunk must *open* and *close* with one of four legal pairs of matching characters:
+
+
+* If a chunk opens with `(`, it must close with `)`.
+* If a chunk opens with `[`, it must close with `]`.
+* If a chunk opens with `{`, it must close with `}`.
+* If a chunk opens with `<`, it must close with `>`.
+
+
+So, `()` is a legal chunk that contains no other chunks, as is `[]`. More complex but valid chunks include `([])`, `{()()()}`, `<([{}])>`, `[<>({}){}[([])<>]]`, and even `(((((((((())))))))))`.
+
+
+Some lines are *incomplete*, but others are *corrupted*. Find and discard the corrupted lines first.
+
+
+A corrupted line is one where a chunk *closes with the wrong character* - that is, where the characters it opens and closes with do not form one of the four legal pairs listed above.
+
+
+Examples of corrupted chunks include `(]`, `{()()()>`, `(((()))}`, and `<([]){()}[{}])`. Such a chunk can appear anywhere within a line, and its presence causes the whole line to be considered corrupted.
+
+
+For example, consider the following navigation subsystem:
+
+
+
+```
+[({(<(())[]>[[{[]{<()<>>
+[(()[<>])]({[<{<<[]>>(
+{([(<{}[<>[]}>{[]{[(<()>
+(((({<>}<{<{<>}{[]{[]{}
+[[<[([]))<([[{}[[()]]]
+[{[{({}]{}}([{[{{{}}([]
+{<[[]]>}<{[{[{[]{()[[[]
+[<(<(<(<{}))><([]([]()
+<{([([[(<>()){}]>(<<{{
+<{([{{}}[<[[[<>{}]]]>[]]
+
+```
+
+Some of the lines aren't corrupted, just incomplete; you can ignore these lines for now. The remaining five lines are corrupted:
+
+
+* `{([(<{}[<>[]}>{[]{[(<()>` - Expected `]`, but found `}` instead.
+* `[[<[([]))<([[{}[[()]]]` - Expected `]`, but found `)` instead.
+* `[{[{({}]{}}([{[{{{}}([]` - Expected `)`, but found `]` instead.
+* `[<(<(<(<{}))><([]([]()` - Expected `>`, but found `)` instead.
+* `<{([([[(<>()){}]>(<<{{` - Expected `]`, but found `>` instead.
+
+
+Stop at the first incorrect closing character on each corrupted line.
+
+
+Did you know that syntax checkers actually have contests to see who can get the high score for syntax errors in a file? It's true! To calculate the syntax error score for a line, take the *first illegal character* on the line and look it up in the following table:
+
+
+* `)`: `3` points.
+* `]`: `57` points.
+* `}`: `1197` points.
+* `>`: `25137` points.
+
+
+In the above example, an illegal `)` was found twice (`2*3 = *6*` points), an illegal `]` was found once (`*57*` points), an illegal `}` was found once (`*1197*` points), and an illegal `>` was found once (`*25137*` points). So, the total syntax error score for this file is `6+57+1197+25137 = *26397*` points!
+
+
+Find the first illegal character in each corrupted line of the navigation subsystem. *What is the total syntax error score for those errors?*
+
+
+--- Part Two ---
+----------------
+
+Now, discard the corrupted lines. The remaining lines are *incomplete*.
+
+
+Incomplete lines don't have any incorrect characters - instead, they're missing some closing characters at the end of the line. To repair the navigation subsystem, you just need to figure out *the sequence of closing characters* that complete all open chunks in the line.
+
+
+You can only use closing characters (`)`, `]`, `}`, or `>`), and you must add them in the correct order so that only legal pairs are formed and all chunks end up closed.
+
+
+In the example above, there are five incomplete lines:
+
+
+* `[({(<(())[]>[[{[]{<()<>>` - Complete by adding `}}]])})]`.
+* `[(()[<>])]({[<{<<[]>>(` - Complete by adding `)}>]})`.
+* `(((({<>}<{<{<>}{[]{[]{}` - Complete by adding `}}>}>))))`.
+* `{<[[]]>}<{[{[{[]{()[[[]` - Complete by adding `]]}}]}]}>`.
+* `<{([{{}}[<[[[<>{}]]]>[]]` - Complete by adding `])}>`.
+
+
+Did you know that autocomplete tools *also* have contests? It's true! The score is determined by considering the completion string character-by-character. Start with a total score of `0`. Then, for each character, multiply the total score by 5 and then increase the total score by the point value given for the character in the following table:
+
+
+* `)`: `1` point.
+* `]`: `2` points.
+* `}`: `3` points.
+* `>`: `4` points.
+
+
+So, the last completion string above - `])}>` - would be scored as follows:
+
+
+* Start with a total score of `0`.
+* Multiply the total score by 5 to get `0`, then add the value of `]` (2) to get a new total score of `2`.
+* Multiply the total score by 5 to get `10`, then add the value of `)` (1) to get a new total score of `11`.
+* Multiply the total score by 5 to get `55`, then add the value of `}` (3) to get a new total score of `58`.
+* Multiply the total score by 5 to get `290`, then add the value of `>` (4) to get a new total score of `294`.
+
+
+The five lines' completion strings have total scores as follows:
+
+
+* `}}]])})]` - `288957` total points.
+* `)}>]})` - `5566` total points.
+* `}}>}>))))` - `1480781` total points.
+* `]]}}]}]}>` - `995444` total points.
+* `])}>` - `294` total points.
+
+
+Autocomplete tools are an odd bunch: the winner is found by *sorting* all of the scores and then taking the *middle* score. (There will always be an odd number of scores to consider.) In this example, the middle score is `*288957*` because there are the same number of scores smaller and larger than it.
+
+
+Find the completion string for each incomplete line, score the completion strings, and sort the scores. *What is the middle score?*
+
+

+ 10 - 0
aoc2021/day10_syntax_scoring/example.txt

@@ -0,0 +1,10 @@
+[({(<(())[]>[[{[]{<()<>>
+[(()[<>])]({[<{<<[]>>(
+{([(<{}[<>[]}>{[]{[(<()>
+(((({<>}<{<{<>}{[]{[]{}
+[[<[([]))<([[{}[[()]]]
+[{[{({}]{}}([{[{{{}}([]
+{<[[]]>}<{[{[{[]{()[[[]
+[<(<(<(<{}))><([]([]()
+<{([([[(<>()){}]>(<<{{
+<{([{{}}[<[[[<>{}]]]>[]]

+ 110 - 0
aoc2021/day10_syntax_scoring/input.txt

@@ -0,0 +1,110 @@
+{<<<[<(<{[[[[<<><>>({}())]<<[]{}>{<><>}>]]<({<[]{}>}<[[]{}]{[]<>}>){({{}<>}[<>[]))<({}())<{}<>>>}>]([{[<{}<>
+{{{<(<<{<([[<{[][]}<<><>>>{{(){}}}]<{[{}{}][<><>]}[[[]()][()[]]]>])(<{([[]][<>{}])[([]<>){[][]}]}(([[]()]
+(([{<{<<{((({[()[]]([][])}[{()}(<>)])[<(()<>)>(([])[{}[]])]){{([()()){[]()})}})}({<<[(()<>){()}
+{[[{[[[{[[<(({{}}{{}()}){{()<>}{<>()}})>({<{(){}}>{(<>{})(())}}((({}()))({[]()}<()()>)))]<(
+<<[({({(((<<[[<>{}]{<>()}]{[<>{}][[]()]}>([[<>]]{{<><>}[<>[]]})>)){[<[[<<>()>{<>{}}][(()<>){[]{}}]]>}<[[<
+({<([{({{<{{<{(){}}<()[]>><{()<>}(()())>}[([{}[]]<<>{}>){<[][]>({})}]}<{({{}[]}<[][]>)((<>{})(()<>))}<{<{}(
+{([{{[({[<<(([[]()])<(<>())[<>[]]>]{([[]{}]([]()))}>([{{[][]}({}{})}(([]{})[[]<>])])>[<<[{<><>}[
+<[<([<(<<{{<(<[]<>>)><(<{}[]>[[][]]){{{}()}[[]()])>}}><[<(({<><>}{(){}})([<>[]]))>]>>{[<<[{([]{})[<>{}]}[
+{{{{({((((<{[([]{})<<>{}>]({<>})}<(<()<>><[]{}>)<(()())({}<>)>>>)<{[{{<>{}}}]}([[{()()}{[]()}
+[<(({((<{{<({(()())((){})}[[()<>]{{}[]}])<<[()<>]><{<>{}}{<>{}}>>>}{(((<<>{}>{()[]})([[][]][(){}]))[(<
+<<[({{<{{<({<{<><>}(<>[])>{[[]{}][()]}}){<<([]())(()<>)>[{()[]}]><[[<>{}]({}())](<[]<>>{<>()})>}>{[
+{{(({<[[<<{{{<[]{}>({}())}}{{[{}()]<()()>}((<>{}})}}<{<[()()]{[][]}>(((){}){{}[]})}>>[{<[[<>[]](())]
+[((({{{({[<(<({}<>)<{}[]>>)[[[[][]](()[])]({{}{}}{()[]})]>[(<[<>()][<>()]>[[[]()]((){})])]
+{<<<{[<{<{<[{[<>]<[]()>}{<<>[]><()<>>}]>{[[<(){}>({}())][{()[]}{{}<>}]](<[[]<>]{()<>}>[{[]{}}[
+{<[<[{({[<{{{{<><>}{{}()}}{<<><>>(<>{})}}{[{{}{}}<()<>>]{[<>{}]}}}({[[{}()]<{}[]>][<{}<>><[]{}>]}{<<<>
+(<[<([<[{(<(({[][]}(()[]})[<{}()><{}()>]){[[{}[]]{{}<>}]}>{[{<{}()>{{}()}}<<<>{}>{[]<>}>]})(<{{(<><>
+[[{{[[({[[[<{(<><>)<{}()>}({<>{}}(()<>))>]<<[{()()}[<>]]<{[]()}[<><>]>>>][<{(({}<>)){<{}{}}[[]{}]}
+(((<[({[([({[([]{})[<>()]]<{(){}}(()())>}[{(()<>]<{}{}>}[{{}<>}<{}()>]]){<<[<>()]<[]>><[[]()](<>(
+[(({{<[([{<<[{[]{}}<[]{}>]({()[]}[()])>>}])<{{{[({<>[]}(<>[]))([{}()]({}[]))]<{[{}()]{{}<>}}{<{
+<[(<[<[{<<{(<[<>{}]<[]()>>{((){}){()<>}})}<<<[{}{}][<><>]>>(([()()][<>]){<{}()><<><>>})>>[{({<{}
+{(<{<{[<{<({<{[]<>}[<>()]]<[[][]][()()]>}({({}<>){<><>}}[<<>()>{[][]}])){[[{<>()}({}[])](({}[])<{}>)]([
+{([<{<(([<{[[<<>><[]()>]{(<>{})[{}{}]}}[((()()){<>[]})[(<>[]){()<>}]]}>])([{([<(<>())[{}<>]>][[(()<>)<{}[]>
+[(((<[<{{<[<{{{}[]}}><<<()[]>({}<>)>{{{}[]}[<>()]}}]{{{({})[{}()]}({(){}}<{}[]>)}({({}[])(())}{(<><>)[<>{}]}
+{{[(<{(<[<[<<{{}}[()()]>><[({}{})][<{}()><{}>]>]{[{[{}][<><>]}[[()()]([]{})]]{{({}()){(){}}}<{[]{}}<
+[{{<{<([(<[<[{()[]}]{<(){}>}>[([()<>][<>()])[{()<>}[<>[]]]]]>)])>}{([[<{<{{[()<>]{()()}}<[<><>]<<>[]>>)[{[()(
+<(({<[[[[(({({<>[]}[{}])<<{}()>{(){}}>}{({{}[]}{()[]}){{<><>}[<>{}]}})<[{{()()}[()()]}]({{<><>}<()()>}[<(
+({{{([{<{[[[[<[]()>{(){}}]{([]{})[{}[]]}][[{[]()}]<[()[]](<>[])>]]((<[<><>]{(){}}><<{}{}>>))]}(
+([<[({[[([{<(<<>()><{}[]>){[()[]][(){}]}>}({((<>()){()()})}{({{}()}<<>()>){[{}]<[]()>}})])([<(
+{<<[[<(([({[<[[]]((){})><{[]()}{()<>}>]}<<(<<><>>(()())){{<>{}}}>>)]])<(<<<<[{{}()}[[]()]]((()))>(
+[[{{{[[[[(<{[(()[])[[]]][(()[])((){})]}[{{<><>}{{}()}}([[]()])]><([<<>()>{{}()}])>)({([[[]]>{<()<>>[{}<>]}
+{{({[{<<<[(({[<>[]>{<>()}}){<{[]<>}>({{}<>}<()>)})(<{(()())<()()>}({[][]}[(){}])>(<[()[]][<>[]]>[{()<>}
+({[[[<[<[{[({<<>()><<><>>}{{<>()}<()<>>})]<<[[<><>]<[]()>][[()][{}{}]]>{[{[]{}}([]<>)]<({}{})(<>{})>}>}]>[[{[
+<<<(({{{[{([(({}{})([]<>))<[<><>]{<>{}}>]<(<<>[]>(<>[]))[([]<>)[()[]]]>)(<[[()()]{[]{}}][{()[]}{(){}}]>[<({
+{[[((([[<{{{(<(){}>{<>()})}}}[((<([]<>)[[][]]>{<{}[]>[<>]})[{[(){}]}{<(){}><<>()>}])<{([[]<>])[((){}
+{[[(({{{<<<<[<[]<>>]><[{<>{}}]([{}<>]<()()>)>>>{[[<<[]{}>>[{<>()}]]{[{[][]}{[]()}][{(){}}[()]]
+<[([([[[[(([((<><>)[<>]){([][]){[][]}}]({[()[]>{()[]}}{{<>{}}(()[])}))){<<{<{}[]>{{}()}}><[[<>[]]<<><>>]
+{(([{([(<[((<<[][]>((){})>)<((<>{}){[][]})(<<>[]>)})]><[((((()){<>()})[{[]()}{<>{}}]))]>)[[<<<{[<
+{([([(({[{{<([<>[]][<>{}])>([<{}()>(<>)]{[()[]]<[]<>>})}<[[[[]()][{}{}]]([()()])][(<()()>[()[]
+{<(<({({<(<[{<{}()>[<><>]}[{()[]}{{}<>}]]{[{[]()}<<>{}>]([[]<>](<>()))}>(([[[][]](<>())})[({<><>}[()<>])]))>}
+<((<(<<<{{{<[<[][]>([]{})]><(<(){}>[()<>])>}<[{<[][]>{<><>}}](({{}<>}))>}[<{{(<><>)<<><>>}(<[]{}>[[]()])}>
+[<<{{(<[{<([[[(){}]<{}{}>]<[{}()]>][[{{}()}[()<>]](<<><>>[{}<>])])([<({}{})[{}<>]>{{()()}}]{[{[
+[[[<[<<{{{[[[[[]{}](()())]]{{{<><>}((){})}[({}<>)([][])]}]({[[<><>]([][])][{<>{}}(()())]}{[[<>[]]
+{(<[[[<{<<[[{{{}[]}[{}{}]}<<<>()>[{}{}]>]({{[]{}}{[]<>}}<<(){}>[()]})]<[{({}[])[()()]}<[<><
+[<[<([{({[{<(<<><>>[()<>])[[{}<>][<>[]]]><[<()<>>]<([][])>>}<({{<>{}}{{}{}}}([()()][(){}]))[<({}<>)([]())>({[
+[{[[<[{{{{[{(({}[])(()()))([(){}]{[]{}})}][{<(<>())<{}()>><({}[])[()<>]]}<<[[]{}][[]()]>{{
+{<{<[<<{[{<[[[(){}]][({}{}){()<>}]]({[<><>](<>{})})>[{{[{}[]]<<>{}>}[[(){}]([][])]}{(({}[]){[]
+[<((<<{((([<{<()()>[{}[]]}[<[][]}<()()>]>]<[<[<><>]{()<>}><{(){}}<(){}>>]>){{[([{}<>][(){}]){{[
+<[{(<<<<<{[<[<()<>><(){}>]>{[{()()}[()[]]]}}}{[<{[{}{}]([][])}(([]{})[(){}])>]{<[{(){}}[()<>]][({}[]){()()}]>
+{<{{[({{<{[<{(<>()]{<>{}}}<<<><>>{()<>}>>[{([]{})}<{[]()}{<>[]}>]][([<()[]>{<>{}}]([{}{}]{(){}})
+<({([({[(<[(({[]()}{{}()}){[(){}]})][{<<<>[]>{()()}>}(<{{}<>}{[][]}>{[<><>](<>())})]>[[[{({}{})<(){}>}
+[(<[[[<[{(([{{<>{}}([]{})}[{<>()}{<><>}]]<{(()())<{}[]>}{(<>)[<>[]]}>){{({<><>}(()))}({<[]{}>{<>[]}})})
+<[{([([[([<[([()()]((){})){([]())(()[])}]<<{()[]}<{}[]>>{{[]()}<<>[]>}>>(<[<[]{}>[{}]]>)][(
+(([<<(<[<<[<[[()()]{[]()}}{<{}{}>{{}<>}}>[<<<>()>[[]{}]>[({})[<>()]]]](<{{<>[]}[{}{}]}[(()())]>[[{{
+[{<[<((((([{(<[]()>([]{}))<[<><>]>}[(([]{})[{}{}])<({}())<[]<>>>]])))))([<<({<<[{}{}]><{()<>}{[]()
+<<[<<[[[<{<[{{<>()}(<>{})}([[][]])]{[(<><>)(<><>)]((()<>)[()[]])}>[<[<()[]>[(){}]]((<>())[()<>])>]}>]]
+<<{<[([[((<[[{<>{}}]<[()<>]([]{})>]{<({}<>){()()}><<()()>>}>[<<<<>()>{[]()}><<()()><<>()}>>])
+{(<[{{([{<(<{[{}{}]<<><>>}([<>{}][[]()])>(([<>[]])[{{}[]}{{}{}}]))[(({<>()}<()()>){([]{}){[]
+{<[<<[<[<<{[(<{}{}>)<[<>[]](<><>)>]{(({}<>)[<>[]]){<{}<>>([]{})}}}>[[<[[{}()]{[]()}]>]{[{{{}()
+(<<<<<<<([{(<[<>{}]([][])>{{[]<>}])}{<<<()<>><()()>>[{{}()}[{}{}]]>[[[{}()][[]<>]]{<{}[]>[(){}]}]}])
+([<[<[[{[(<<{([][]){<>()}}[<()<>>(()[])]>{{(())(()())}{({}[]){[]()}}}><[([(){}])({{}{}})]>)(({[[[][]
+<(<[[<([{<([<[[][]]({}())>>){{(([])[<><>])<{<>[]}[{}()]>}{[<()>[{}{}]]((()[]){<>})}}>}[<<{[[()
+({<<{[{[(({{<{()()}>[(<>[])]}[([{}<>]{[]{}}){{{}()}<{}<>>}]}{<({[]}[{}()]){{(){}}[<>{}]}><{[<><>
+({<[([[(<{<{{[[]<>](()[])}{<[]<>>(<>[])]}>{[[{{}{}}][{<>[]}(<>)]]<<<()()>({}<>)><<{}()>{{}()}>>}}>[(<[(<{}<>>
+[[((<{<<[{{<<<[][]><[]{}>>>{[<()()>]<<[]<>>((){})>}}}{<(<((){}){{}<>}>[([]<>)<{}[]>])<[[{}{}](<><>)]{([
+<{{({([([{{((({}<>)(()()))[(<>{})<[][]>])(<{<><>}([]<>)>{(()[])[[]{}]})}{<{{{}()}({}())}[([]{
+{<[(<{[<{[[(<<{}<>>[[]<>]>}{[<[]<>>[{}()]]{[{}](<>)}}]]}{{({(<{}{}>[()[]])[[{}{}][{}]]}<<<<>{}>>[([][
+({<{<<[([<[[<<{}[]>(()[])>][[([][]>[<><>]]{{()}}]](<((<>[])<<><>>)[({}()){{}[]}]><([[]<>]{<>[]})
+<{({[{{{<[<[{<()()><{}[]]}{[[]{}]([]<>)}]{{([]()){<>()}}{{{}<>}({}<>)}}>[<<<[]()>[{}[]]><(()())[<>[]]>>(
+{(([((<[<({{{<()()>[()<>]}<[{}{}]<<>[]>>}(<{[]()}{()[]}>([{}[]]({}())))}({{<{}{}>[<>{}]){{[]()}{[]<>}
+(([({{[[(<[<(<<><>>[[]()]){([]())({}<>)}>[((()()){()()})[({}())<[]()>]]]>[{{<[{}{}][{}()]>}{([<><>]<
+[[{<{([<[{(((<()()>{{}[]}}<<{}{}>[{}[]]>){(((){})[{}<>])<<(){}>(<>{})>})}(([<(<><>)<[]<>>>([<>()])]<[({}{
+<[{(<[(<<{<{<({}{})<(){}>>([[]{}]{()<>})}[{{[][]}[[]]}([()](<>()))]>[{(({}[])(()())>([{}])}{(<[]()>{
+<{({{<{{{{{{<[()()]([]{})>{([]{})[()()]}}}}}}({(<[{([]{})({}{})}{(<>())<{}<>>}]({{<><>}}[{()<>}[[
+{{[({(<{[([[<<()()>{()[]}><{()<>}{{}{}}>]]<{[{()<>}(()<>)][<{}{}>([][])]}<{<[][]>[()()]}<{()<>}[[][]]>>>)]
+(<({{({{{([({{{}()}{(){}}}<{(){}}<<>[]>>)(<[[]<>][<>{}]><[<>{}]>)]{[{(()[])}{[[]<>]{{}}}]((((){}){<>
+<(([(((((((({([]<>)}<(()<>)<<>[]>>)[{[[]{}][()<>]}<{()<>}>])<<<{(){}}[<>()]>{(()()){[]<>}}>
+<<<<{{{[[([<{{<>()}[{}<>]}<<(){}><[]{}>>>([[[]()]<{}()>})]({[[{}()]{<>()}][{[]<>}[(){}]]}))((
+{[(<<<<({(<[[{{}}]<(()<>)<{}<>>>]<([[][]]({}<>)){[()[]]<(){}>}}>)}[[[([[[]<>]<()()>][{[]{}}])[[
+(<((<((<<([((<<>()>(<>()))<{<>()}([][])>)[[({})<{}<>>]]])>(<{(({()[]}(<><>)){{()[]}{()()}])}<({<()<>>({}
+[(<<<(<<{{({<[<>[]]([]()]><<<>()><<><>>>}[<[<>{}]((){})>(([]{}){(){}})])<<[{<>()}<{}()>]({
+([[{<[[<[{(<<(<><>)>({<><>}{<>[]})>[{[[]{}]({}{}))])}{(<((<><>)(()[]))><([<><>]{()[]})[{<>
+<<[[<{<<<[{[<(<>[])>{{{}<>}(()[])}][({[]{}}(<>()))<(<><>){{}()}>]}{{{(()<>)<<>{}>}<<[][]>>}[([[][]]{()()}))}]
+(([({{{<<{{{<[(){}]{[]()}>({{}()}({}{}))}}{([{()<>}<()>](([][])<<>[]>)){{<<><>>{()}}{<{}<>><[]<>>}}}}{[<[[[][
+[([{<{{[([<((({}{})[<><>])<{{}{}}<()()>>)>{(<[()[]][<>{}]>(<()[]>[()<>]))([(<>[])<{}{}>]{<{}()>[<>[]]})}
+[<<<[(<((<(<{(<>[]){<>{}}}{{<>{}}}><[(()[])(()())][<[]{}><<>{}>]>)>[({<[()<>]({})>})])(<[[({<><>}{(){
+{{(<({<<{([{[<<>()}<{}[]>][{<>{}}[{}{}]]}{{[[]<>]{{}()}}}][({([]{})<()()>}){{({}[]){()}}{{()}
+{({((({[([<(({()<>}[{}<>])[<<><>><()()>])<[(()[])<{}()>]{[[]()]({}<>)}>>[({<()<>)})]]<{<<{{
+<<({[([{[{<<<[()<>]{()<>}>{([][])[<>[]]}>{({<><>})[{[][]}<{}{}>}}><<({{}()}<{}()>)><[(()[]){()()}][<()<>>{[](
+[([<({<{[<[<<<(){}><{}[]>>([{}[]])><{<[]<>>[{}()]}[<{}<>>{(){}}]>][(({{}()}[{}<>]))(<{[]()}(())>{
+<<([(<(({{{[{(<>()>[{}()]}[<[]{}>({}())]]}<{({{}()}[<>{}])}{<(<>[])({}<>)>{<[]()><[]<>>}}>}{{[{[
+{<([<{{<(<({<({}<>){()<>}>(<(){}>([]{}))})>({{[([]())([]())]}<[[{}{}>[<><>]]{([]())<{}()>}>
+[[{({[<{<({[{{<>[]}[(){}]}<[<><>]{[][]}>][{{(){}}<<>[]>}[{(){}}[()[]]}]}{{(<<>{}>[{}[]])<{()[]}[<>{}]>}
+{(({{[[{{[([({<>[]}[[]<>])[{()()}<()[]>]]){(<{[]{}}{[]{}}>(<(){}>{[]<>}))((<{}<>>{(){}})<[<>()
+<{[<([[<{<[{{{()<>}<[]()>}{[()]([]())}}<<[(){}]([][])>{{[]{}}<[][]>}>]<([{{}()}[<>{}]])<[<[]<>><()
+({[<<[<{([{[({(){}}{()[]})<<[]()>>]<[{()[]>{()<>}][<{}>{[]()}]>}[([<(){}>(())])({[()()]<<>{}>}<{{}{}}
+[[<{[{{[{[[{({{}[]})}]](<<<(()<>)><({}{})<{}{}>>>([<{}<>>(()[])][<<>()>])>)}<(<<([()[]][()[]])<{()
+[{([(({<{<([(({}<>)[{}()])])><{[[{[]<>}<<><>>]<<[]<>><(){}>>]}{{<<(){}>{<>()}>[<{}{}>{<>[]}]}[<[()()]
+<[[[<({[[<{{<(<>())(<><>)>{[(){}][{}<>]}}({({}<>){{}[]}])}[[(<{}{}>[()[]])]{(([][])<()>)[({}())<{}()>
+{[[(<(<{<([[(([]{})[<>()])<<[]>[()[]]>](<{()[]}[[]<>]>{[()<>]([]())})][([<{}<>>[{}[]]]{<[]>(<>)
+<[<[[<<(({[(<[[]]{<>[]}>{(<>())(()())})<({(){}}{[][]})>]([{<()()><[]()>}[{[]()}[[][]>]]{{(())}(({}{})<<>[
+(({<{{[{(<[[[<<>()>][{<>()}[[]<>]]]]{{{{<><>}({}{})}{{[][]}({}[])}}{[{{}<>}{[]()}]}}>{<([[
+<([<{([([[{{[{{}{}}<{}()>]<{{}{}}>}({{(){}}{<>()}}[<(){}>[()()]])}[<{{<>[]}[()()]}{{{}[]}{[]<>}}>]]{[{<
+<{({{[<{<(({[({}<>)[[]<>]]<<[]{}>(()<>)>}))[<{((<>[])[<><>])<((){}][()()]>}{<([]{})(<><>)>}>{(
+{<<<<([{[<[{<<(){}>({}{})>}<<{[][]}{<>()}>({{}()}([]{})))]((({<><>}<{}[]>)({[]()}{<>()}))[[<{}{}>][{[]()
+[(<(<[(<{({[<(<>{})[()()]>[([]{}){[]<>}]]{{<{}{}>(<><>)}<{{}()}((){})>}}<<{{()[]}((){}}}{{
+{<<<[(<([{<<([()()][()])<{[]<>}[<>()]>>[<(()())<<>{}>>({[]{}}([]<>))]>}])>)([([{{{[[[]()](()
+<<({<{<([([[<[(){}]<<><>>><{()[]}[(){}]>]<(<{}[]>){[[]<>](()[])}>][<[<(){}>[{}[]]]({[][]}((){}))>
+{([{{[(<({{<(<[][]>{()()}){[{}()]}><(<<>())<[]{}>){<{}{}>((){})}>}}((<(<<>[]><()()>)><{[[][]]}<[<>
+[(<{{[{[{<([[[{}[]]<<>>]][[(()[])[(){}]]])({([<>[]]({}<>)){([]{})({}[])}}({(())({}[])}<{<>[]}(()[])>))
+({[([(<{<(<<(([][])(()()))({[]()}(<>[]))><({{}()}[[]()])>>)>[<[([{()<>}<[]<>>]([{}<>]{()()}})<[<{}

+ 47 - 0
aoc2021/day10_syntax_scoring/main.py

@@ -0,0 +1,47 @@
+import os, sys
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, check_example, generate_readme
+
+
+def solve(input: list[str]) -> tuple[int, int]:
+
+    braces = {")": "(", "}": "{", "]": "[", ">": "<"}
+    reverse_braces = {"(": ")", "{": "}", "[": "]", "<": ">"}
+    illegal_points = {")": 3, "}": 1197, "]": 57, ">": 25137}
+    completion_points = {")": 1, "}": 3, "]": 2, ">": 4}
+
+    scores = []
+    sum = 0
+
+    for line in input:
+        score = 0
+        stack = []
+        not_corrapted = True
+        for char in line.strip():
+            if char in braces.values():
+                stack.append(char)
+            else:
+                if braces[char] == stack[-1]:
+                    stack.pop()
+                else:
+                    sum += illegal_points[char]
+                    not_corrapted = False
+                    break
+        if not_corrapted:
+            while stack:
+                score = score * 5 + completion_points[reverse_braces[stack.pop()]]
+            scores.append(score)
+    print("The anwer of part1 is:", sum)
+    print("The anser of part2 is:", sorted(scores)[int(len(scores) / 2)])
+    return sum, sorted(scores)[int(len(scores) / 2)]
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 10)
+
+    check_example(example, solve)
+    solve(input)
+
+    generate_readme(task_dir, 10)

+ 3 - 0
aoc2021/day10_syntax_scoring/src/main.rs

@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}

+ 8 - 0
aoc2021/day11_dumbo_octopus/Cargo.toml

@@ -0,0 +1,8 @@
+[package]
+name = "day11_dumbo_octopus"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 381 - 0
aoc2021/day11_dumbo_octopus/README.md

@@ -0,0 +1,381 @@
+--- Day 11: Dumbo Octopus ---
+-----------------------------
+
+You enter a large cavern full of rare bioluminescent [dumbo octopuses](https://www.youtube.com/watch?v=eih-VSaS2g0)! They seem to not like the Christmas lights on your submarine, so you turn them off for now.
+
+
+There are 100 octopuses arranged neatly in a 10 by 10 grid. Each octopus slowly gains *energy* over time and *flashes* brightly for a moment when its energy is full. Although your lights are off, maybe you could navigate through the cave without disturbing the octopuses if you could predict when the flashes of light will happen.
+
+
+Each octopus has an *energy level* - your submarine can remotely measure the energy level of each octopus (your puzzle input). For example:
+
+
+
+```
+5483143223
+2745854711
+5264556173
+6141336146
+6357385478
+4167524645
+2176841721
+6882881134
+4846848554
+5283751526
+
+```
+
+The energy level of each octopus is a value between `0` and `9`. Here, the top-left octopus has an energy level of `5`, the bottom-right one has an energy level of `6`, and so on.
+
+
+You can model the energy levels and flashes of light in *steps*. During a single step, the following occurs:
+
+
+* First, the energy level of each octopus increases by `1`.
+* Then, any octopus with an energy level greater than `9` *flashes*. This increases the energy level of all adjacent octopuses by `1`, including octopuses that are diagonally adjacent. If this causes an octopus to have an energy level greater than `9`, it *also flashes*. This process continues as long as new octopuses keep having their energy level increased beyond `9`. (An octopus can only flash *at most once per step*.)
+* Finally, any octopus that flashed during this step has its energy level set to `0`, as it used all of its energy to flash.
+
+
+Adjacent flashes can cause an octopus to flash on a step even if it begins that step with very little energy. Consider the middle octopus with `1` energy in this situation:
+
+
+
+```
+Before any steps:
+11111
+19991
+19191
+19991
+11111
+
+After step 1:
+34543
+4*000*4
+5*000*5
+4*000*4
+34543
+
+After step 2:
+45654
+51115
+61116
+51115
+45654
+
+```
+
+An octopus is *highlighted* when it flashed during the given step.
+
+
+Here is how the larger example above progresses:
+
+
+
+```
+Before any steps:
+5483143223
+2745854711
+5264556173
+6141336146
+6357385478
+4167524645
+2176841721
+6882881134
+4846848554
+5283751526
+
+After step 1:
+6594254334
+3856965822
+6375667284
+7252447257
+7468496589
+5278635756
+3287952832
+7993992245
+5957959665
+6394862637
+
+After step 2:
+88*0*7476555
+5*0*89*0*87*0*54
+85978896*0*8
+84857696*00*
+87*00*9*0*88*00*
+66*000*88989
+68*0000*5943
+*000000*7456
+9*000000*876
+87*0000*6848
+
+After step 3:
+*00*5*0*9*00*866
+85*00*8*00*575
+99*000000*39
+97*000000*41
+9935*0*8*00*63
+77123*00000*
+791125*000*9
+221113*0000*
+*0*421125*000*
+*00*21119*000*
+
+After step 4:
+2263*0*31977
+*0*923*0*31697
+*00*3222115*0*
+*00*41111163
+*00*76191174
+*00*53411122
+*00*4236112*0*
+5532241122
+1532247211
+113223*0*211
+
+After step 5:
+4484144*000*
+2*0*44144*000*
+2253333493
+1152333274
+11873*0*3285
+1164633233
+1153472231
+6643352233
+2643358322
+2243341322
+
+After step 6:
+5595255111
+3155255222
+33644446*0*5
+2263444496
+2298414396
+2275744344
+2264583342
+7754463344
+3754469433
+3354452433
+
+After step 7:
+67*0*7366222
+4377366333
+4475555827
+34966557*0*9
+35*00*6256*0*9
+35*0*9955566
+3486694453
+8865585555
+486558*0*644
+4465574644
+
+After step 8:
+7818477333
+5488477444
+5697666949
+46*0*876683*0*
+473494673*0*
+474*00*97688
+69*0000*7564
+*000000*9666
+8*00000*4755
+68*0000*7755
+
+After step 9:
+9*0*6*0000*644
+78*00000*976
+69*000000*8*0*
+584*00000*82
+5858*0000*93
+69624*00000*
+8*0*2125*000*9
+222113*000*9
+9111128*0*97
+7911119976
+
+After step 10:
+*0*481112976
+*00*31112*00*9
+*00*411125*0*4
+*00*811114*0*6
+*00*991113*0*6
+*00*93511233
+*0*44236113*0*
+553225235*0*
+*0*53225*0*6*00*
+*00*3224*0000*
+
+```
+
+After step 10, there have been a total of `204` flashes. Fast forwarding, here is the same configuration every 10 steps:
+
+
+
+```
+After step 20:
+3936556452
+56865568*0*6
+449655569*0*
+444865558*0*
+445686557*0*
+568*00*86577
+7*00000*9896
+*0000000*344
+6*000000*364
+46*0000*9543
+
+After step 30:
+*0*643334118
+4253334611
+3374333458
+2225333337
+2229333338
+2276733333
+2754574565
+5544458511
+9444447111
+7944446119
+
+After step 40:
+6211111981
+*0*421111119
+*00*42111115
+*000*3111115
+*000*3111116
+*00*65611111
+*0*532351111
+3322234597
+2222222976
+2222222762
+
+After step 50:
+9655556447
+48655568*0*5
+448655569*0*
+445865558*0*
+457486557*0*
+57*000*86566
+6*00000*9887
+8*000000*533
+68*00000*633
+568*0000*538
+
+After step 60:
+25333342*00*
+274333464*0*
+2264333458
+2225333337
+2225333338
+2287833333
+3854573455
+1854458611
+1175447111
+1115446111
+
+After step 70:
+8211111164
+*0*421111166
+*00*42111114
+*000*4211115
+*0000*211116
+*00*65611111
+*0*532351111
+7322235117
+5722223475
+4572222754
+
+After step 80:
+1755555697
+59655556*0*9
+448655568*0*
+445865558*0*
+457*0*86557*0*
+57*000*86566
+7*00000*8666
+*0000000*99*0*
+*0000000*8*00*
+*0000000000*
+
+After step 90:
+7433333522
+2643333522
+2264333458
+2226433337
+2222433338
+2287833333
+2854573333
+4854458333
+3387779333
+3333333333
+
+After step 100:
+*0*397666866
+*0*749766918
+*00*53976933
+*000*4297822
+*000*4229892
+*00*53222877
+*0*532222966
+9322228966
+7922286866
+6789998766
+
+```
+
+After 100 steps, there have been a total of `*1656*` flashes.
+
+
+Given the starting energy levels of the dumbo octopuses in your cavern, simulate 100 steps. *How many total flashes are there after 100 steps?*
+
+
+--- Part Two ---
+----------------
+
+It seems like the individual flashes aren't bright enough to navigate. However, you might have a better option: the flashes seem to be *synchronizing*!
+
+
+In the example above, the first time all octopuses flash simultaneously is step `*195*`:
+
+
+
+```
+After step 193:
+5877777777
+8877777777
+7777777777
+7777777777
+7777777777
+7777777777
+7777777777
+7777777777
+7777777777
+7777777777
+
+After step 194:
+6988888888
+9988888888
+8888888888
+8888888888
+8888888888
+8888888888
+8888888888
+8888888888
+8888888888
+8888888888
+
+After step 195:
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+*0000000000*
+
+```
+
+If you can calculate the exact moments when the octopuses will all flash simultaneously, you should be able to navigate through the cavern. *What is the first step during which all octopuses flash?*
+
+

+ 10 - 0
aoc2021/day11_dumbo_octopus/example.txt

@@ -0,0 +1,10 @@
+5483143223
+2745854711
+5264556173
+6141336146
+6357385478
+4167524645
+2176841721
+6882881134
+4846848554
+5283751526

+ 10 - 0
aoc2021/day11_dumbo_octopus/input.txt

@@ -0,0 +1,10 @@
+3113284886
+2851876144
+2774664484
+6715112578
+7146272153
+6256656367
+3148666245
+3857446528
+7322422833
+8152175168

+ 54 - 0
aoc2021/day11_dumbo_octopus/main.py

@@ -0,0 +1,54 @@
+import os, sys
+import numpy as np
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, generate_readme, check_example
+
+
+def update_step_count(step: np.ndarray) -> tuple[int, np.ndarray, bool]:
+    acc = 0
+    while len(np.where((step > 9) & (step < 1000))[0]) != 0:
+        x, y = np.where((step > 9) & (step < 1000))
+        for idx in range(len(x)):
+            step[max(0, x[idx] - 1) : x[idx] + 2, max(0, y[idx] - 1) : y[idx] + 2] += 1
+            step[x[idx], y[idx]] = 1000 + acc
+            acc += 1
+    return (
+        len(step[step > 9]),
+        np.where(step > 9, 0, step),
+        len(step[step > 9]) == step.size,
+    )
+
+
+def part1(input: list[str]):
+    octopuses = np.array([list(line.strip()) for line in input], dtype=int)
+    sum_flashes = 0
+    for _ in range(1, 101):
+        octopuses += 1
+        flashes, octopuses, _ = update_step_count(octopuses)
+        sum_flashes += flashes
+    print("The asnwer of part1 is:", sum_flashes)
+
+
+def part2(input: list[str]):
+    octopuses = np.array([list(line.strip()) for line in input], dtype=int)
+    step = 0
+    all_flash = False
+    while not all_flash:
+        octopuses += 1
+        _, _, all_flash = update_step_count(octopuses)
+        step += 1
+    print("The answer if part2 is:", step)
+
+
+if __name__ == "__main__":
+
+    input, example = get_input(task_dir, 11)
+
+    check_example(example, part1)
+    check_example(example, part2)
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 11)

+ 3 - 0
aoc2021/day11_dumbo_octopus/src/main.rs

@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}

+ 8 - 0
aoc2021/day12_passage_pathing/Cargo.toml

@@ -0,0 +1,8 @@
+[package]
+name = "day12_passage_pathing"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 194 - 0
aoc2021/day12_passage_pathing/README.md

@@ -0,0 +1,194 @@
+--- Day 12: Passage Pathing ---
+-------------------------------
+
+With your submarine's subterranean subsystems subsisting suboptimally, the only way you're getting out of this cave anytime soon is by finding a path yourself. Not just *a* path - the only way to know if you've found the *best* path is to find *all* of them.
+
+
+Fortunately, the sensors are still mostly working, and so you build a rough map of the remaining caves (your puzzle input). For example:
+
+
+
+```
+start-A
+start-b
+A-c
+A-b
+b-d
+A-end
+b-end
+
+```
+
+This is a list of how all of the caves are connected. You start in the cave named `start`, and your destination is the cave named `end`. An entry like `b-d` means that cave `b` is connected to cave `d` - that is, you can move between them.
+
+
+So, the above cave system looks roughly like this:
+
+
+
+```
+    start
+    /   \
+c--A-----b--d
+    \   /
+     end
+
+```
+
+Your goal is to find the number of distinct *paths* that start at `start`, end at `end`, and don't visit small caves more than once. There are two types of caves: *big* caves (written in uppercase, like `A`) and *small* caves (written in lowercase, like `b`). It would be a waste of time to visit any small cave more than once, but big caves are large enough that it might be worth visiting them multiple times. So, all paths you find should *visit small caves at most once*, and can *visit big caves any number of times*.
+
+
+Given these rules, there are `*10*` paths through this example cave system:
+
+
+
+```
+start,A,b,A,c,A,end
+start,A,b,A,end
+start,A,b,end
+start,A,c,A,b,A,end
+start,A,c,A,b,end
+start,A,c,A,end
+start,A,end
+start,b,A,c,A,end
+start,b,A,end
+start,b,end
+
+```
+
+(Each line in the above list corresponds to a single path; the caves visited by that path are listed in the order they are visited and separated by commas.)
+
+
+Note that in this cave system, cave `d` is never visited by any path: to do so, cave `b` would need to be visited twice (once on the way to cave `d` and a second time when returning from cave `d`), and since cave `b` is small, this is not allowed.
+
+
+Here is a slightly larger example:
+
+
+
+```
+dc-end
+HN-start
+start-kj
+dc-start
+dc-HN
+LN-dc
+HN-end
+kj-sa
+kj-HN
+kj-dc
+
+```
+
+The `19` paths through it are as follows:
+
+
+
+```
+start,HN,dc,HN,end
+start,HN,dc,HN,kj,HN,end
+start,HN,dc,end
+start,HN,dc,kj,HN,end
+start,HN,end
+start,HN,kj,HN,dc,HN,end
+start,HN,kj,HN,dc,end
+start,HN,kj,HN,end
+start,HN,kj,dc,HN,end
+start,HN,kj,dc,end
+start,dc,HN,end
+start,dc,HN,kj,HN,end
+start,dc,end
+start,dc,kj,HN,end
+start,kj,HN,dc,HN,end
+start,kj,HN,dc,end
+start,kj,HN,end
+start,kj,dc,HN,end
+start,kj,dc,end
+
+```
+
+Finally, this even larger example has `226` paths through it:
+
+
+
+```
+fs-end
+he-DX
+fs-he
+start-DX
+pj-DX
+end-zg
+zg-sl
+zg-pj
+pj-he
+RW-he
+fs-DX
+pj-RW
+zg-RW
+start-pj
+he-WI
+zg-he
+pj-fs
+start-RW
+
+```
+
+*How many paths through this cave system are there that visit small caves at most once?*
+
+
+--- Part Two ---
+----------------
+
+After reviewing the available paths, you realize you might have time to visit a single small cave *twice*. Specifically, big caves can be visited any number of times, a single small cave can be visited at most twice, and the remaining small caves can be visited at most once. However, the caves named `start` and `end` can only be visited *exactly once each*: once you leave the `start` cave, you may not return to it, and once you reach the `end` cave, the path must end immediately.
+
+
+Now, the `36` possible paths through the first example above are:
+
+
+
+```
+start,A,b,A,b,A,c,A,end
+start,A,b,A,b,A,end
+start,A,b,A,b,end
+start,A,b,A,c,A,b,A,end
+start,A,b,A,c,A,b,end
+start,A,b,A,c,A,c,A,end
+start,A,b,A,c,A,end
+start,A,b,A,end
+start,A,b,d,b,A,c,A,end
+start,A,b,d,b,A,end
+start,A,b,d,b,end
+start,A,b,end
+start,A,c,A,b,A,b,A,end
+start,A,c,A,b,A,b,end
+start,A,c,A,b,A,c,A,end
+start,A,c,A,b,A,end
+start,A,c,A,b,d,b,A,end
+start,A,c,A,b,d,b,end
+start,A,c,A,b,end
+start,A,c,A,c,A,b,A,end
+start,A,c,A,c,A,b,end
+start,A,c,A,c,A,end
+start,A,c,A,end
+start,A,end
+start,b,A,b,A,c,A,end
+start,b,A,b,A,end
+start,b,A,b,end
+start,b,A,c,A,b,A,end
+start,b,A,c,A,b,end
+start,b,A,c,A,c,A,end
+start,b,A,c,A,end
+start,b,A,end
+start,b,d,b,A,c,A,end
+start,b,d,b,A,end
+start,b,d,b,end
+start,b,end
+
+```
+
+The slightly larger example above now has `103` paths through it, and the even larger example now has `3509` paths through it.
+
+
+Given these new rules, *how many paths through this cave system are there?*
+
+

+ 7 - 0
aoc2021/day12_passage_pathing/example.txt

@@ -0,0 +1,7 @@
+start-A
+start-b
+A-c
+A-b
+b-d
+A-end
+b-end

+ 23 - 0
aoc2021/day12_passage_pathing/input.txt

@@ -0,0 +1,23 @@
+he-JK
+wy-KY
+pc-XC
+vt-wy
+LJ-vt
+wy-end
+wy-JK
+end-LJ
+start-he
+JK-end
+pc-wy
+LJ-pc
+at-pc
+xf-XC
+XC-he
+pc-JK
+vt-XC
+at-he
+pc-he
+start-at
+start-XC
+at-LJ
+vt-JK

+ 76 - 0
aoc2021/day12_passage_pathing/main.py

@@ -0,0 +1,76 @@
+from doctest import Example
+import os, sys
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, check_example, generate_readme
+from collections import deque, defaultdict
+
+
+def parse(input: list[str]) -> dict:
+    in_map_cave = defaultdict(list)
+    for line in input:
+        a, b = line.split("-")
+        in_map_cave[a].append(b)
+        if a != "start" and b != "end":
+            in_map_cave[b].append(a)
+    return dict(in_map_cave)
+
+
+def findpaths(map_cave: dict, twice=False) -> tuple[int, list]:
+    paths = []
+    path = ["start"]
+    q = deque([path])
+    state_q = deque([False])
+    while q:
+        path = q.popleft()
+        double_visited = state_q.popleft()
+        if path[-1] == "end":
+            paths.append(path)
+            continue
+        for cave in map_cave[path[-1]]:
+            if not (cave.islower() and (cave in path)):
+                q.append(path + [cave])
+                state_q.append(double_visited)
+            elif not double_visited and twice:
+                state_q.append(True)
+                q.append(path + [cave])
+    return len(paths), paths
+
+
+def findpaths_first_version(map_cave: dict) -> tuple[int, list]:
+    paths = []
+    path = ["start"]
+    q = deque([path])
+    while q:
+        path = q.popleft()
+        if path[-1] == "end":
+            paths.append(path)
+            continue
+        for cave in map_cave[path[-1]]:
+            if not (cave.islower() and (cave in path)):
+                newpath = path.copy()
+                newpath.append(cave)
+                q.append(newpath)
+    return len(paths), paths
+
+
+def part1(input: list[str]):
+    l, _ = findpaths(parse(input))
+    print("The answer of part1 is:", l)
+
+
+def part2(input: list[str]):
+    l, _ = findpaths(parse(input), twice=True)
+    print("The answer of part2 is:", l)
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 12)
+
+    check_example(example, part1)
+    check_example(example, part2)
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 12)

+ 3 - 0
aoc2021/day12_passage_pathing/src/main.rs

@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}

+ 8 - 0
aoc2021/day13_transparent_origami/Cargo.toml

@@ -0,0 +1,8 @@
+[package]
+name = "day13_transparent_origami"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 163 - 0
aoc2021/day13_transparent_origami/README.md

@@ -0,0 +1,163 @@
+--- Day 13: Transparent Origami ---
+-----------------------------------
+
+You reach another volcanically active part of the cave. It would be nice if you could do some kind of thermal imaging so you could tell ahead of time which caves are too hot to safely enter.
+
+
+Fortunately, the submarine seems to be equipped with a thermal camera! When you activate it, you are greeted with:
+
+
+
+```
+Congratulations on your purchase! To activate this infrared thermal imaging
+camera system, please enter the code found on page 1 of the manual.
+
+```
+
+Apparently, the Elves have never used this feature. To your surprise, you manage to find the manual; as you go to open it, page 1 falls out. It's a large sheet of [transparent paper](https://en.wikipedia.org/wiki/Transparency_(projection))! The transparent paper is marked with random dots and includes instructions on how to fold it up (your puzzle input). For example:
+
+
+
+```
+6,10
+0,14
+9,10
+0,3
+10,4
+4,11
+6,0
+6,12
+4,1
+0,13
+10,12
+3,4
+3,0
+8,4
+1,10
+2,14
+8,10
+9,0
+
+fold along y=7
+fold along x=5
+
+```
+
+The first section is a list of dots on the transparent paper. `0,0` represents the top-left coordinate. The first value, `x`, increases to the right. The second value, `y`, increases downward. So, the coordinate `3,0` is to the right of `0,0`, and the coordinate `0,7` is below `0,0`. The coordinates in this example form the following pattern, where `#` is a dot on the paper and `.` is an empty, unmarked position:
+
+
+
+```
+...#..#..#.
+....#......
+...........
+#..........
+...#....#.#
+...........
+...........
+...........
+...........
+...........
+.#....#.##.
+....#......
+......#...#
+#..........
+#.#........
+
+```
+
+Then, there is a list of *fold instructions*. Each instruction indicates a line on the transparent paper and wants you to fold the paper *up* (for horizontal `y=...` lines) or *left* (for vertical `x=...` lines). In this example, the first fold instruction is `fold along y=7`, which designates the line formed by all of the positions where `y` is `7` (marked here with `-`):
+
+
+
+```
+...#..#..#.
+....#......
+...........
+#..........
+...#....#.#
+...........
+...........
+-----------
+...........
+...........
+.#....#.##.
+....#......
+......#...#
+#..........
+#.#........
+
+```
+
+Because this is a horizontal line, fold the bottom half *up*. Some of the dots might end up overlapping after the fold is complete, but dots will never appear exactly on a fold line. The result of doing this fold looks like this:
+
+
+
+```
+#.##..#..#.
+#...#......
+......#...#
+#...#......
+.#.#..#.###
+...........
+...........
+
+```
+
+Now, only `17` dots are visible.
+
+
+Notice, for example, the two dots in the bottom left corner before the transparent paper is folded; after the fold is complete, those dots appear in the top left corner (at `0,0` and `0,1`). Because the paper is transparent, the dot just below them in the result (at `0,3`) remains visible, as it can be seen through the transparent paper.
+
+
+Also notice that some dots can end up *overlapping*; in this case, the dots merge together and become a single dot.
+
+
+The second fold instruction is `fold along x=5`, which indicates this line:
+
+
+
+```
+#.##.|#..#.
+#...#|.....
+.....|#...#
+#...#|.....
+.#.#.|#.###
+.....|.....
+.....|.....
+
+```
+
+Because this is a vertical line, fold *left*:
+
+
+
+```
+#####
+#...#
+#...#
+#...#
+#####
+.....
+.....
+
+```
+
+The instructions made a square!
+
+
+The transparent paper is pretty big, so for now, focus on just completing the first fold. After the first fold in the example above, `*17*` dots are visible - dots that end up overlapping after the fold is completed count as a single dot.
+
+
+*How many dots are visible after completing just the first fold instruction on your transparent paper?*
+
+
+--- Part Two ---
+----------------
+
+Finish folding the transparent paper according to the instructions. The manual says the code is always *eight capital letters*.
+
+
+*What code do you use to activate the infrared thermal imaging camera system?*
+
+

+ 921 - 0
aoc2021/day13_transparent_origami/day13.txt

@@ -0,0 +1,921 @@
+994,18
+1014,343
+84,406
+219,849
+570,488
+575,395
+387,213
+904,382
+676,479
+1028,437
+500,123
+202,735
+716,315
+1153,822
+197,397
+678,154
+1104,285
+1041,799
+262,159
+925,543
+1193,299
+918,159
+1170,826
+1181,889
+938,9
+843,481
+5,480
+95,416
+944,831
+853,285
+276,108
+435,717
+616,383
+766,893
+863,611
+442,521
+5,446
+272,26
+1146,876
+244,845
+117,747
+457,397
+336,235
+249,169
+612,443
+251,693
+67,333
+376,840
+16,719
+1190,617
+95,857
+955,511
+984,180
+134,613
+413,145
+1141,416
+681,830
+162,308
+411,70
+1041,239
+184,382
+460,791
+798,79
+1161,429
+238,450
+649,296
+445,53
+616,495
+244,519
+669,781
+15,105
+157,296
+411,824
+713,450
+922,311
+373,173
+5,190
+1156,347
+1262,392
+441,656
+984,744
+810,123
+216,1
+395,185
+930,893
+669,864
+934,600
+160,121
+1170,628
+713,562
+512,290
+1058,618
+1294,719
+910,683
+338,661
+910,298
+172,547
+694,495
+1041,95
+875,717
+269,95
+902,385
+599,737
+825,693
+1232,848
+1138,235
+887,640
+1066,845
+13,47
+1272,511
+622,289
+1190,277
+1148,586
+776,3
+780,271
+713,239
+649,25
+107,513
+35,799
+825,84
+363,565
+609,621
+1250,708
+1121,605
+401,668
+306,810
+880,635
+628,98
+885,504
+952,694
+1116,254
+80,98
+947,351
+1067,152
+406,270
+1059,693
+1102,238
+785,30
+232,311
+1232,64
+994,876
+1133,429
+1260,330
+524,386
+167,324
+28,393
+132,516
+1305,296
+72,698
+385,254
+475,477
+587,287
+1049,168
+142,64
+172,235
+1002,679
+430,515
+741,593
+528,289
+768,266
+716,260
+910,235
+1305,704
+870,399
+1146,18
+1077,751
+281,53
+830,164
+306,35
+142,127
+610,880
+480,705
+1113,397
+257,51
+734,46
+649,598
+300,322
+1058,52
+913,843
+638,175
+1200,893
+1158,276
+1131,346
+1066,729
+669,47
+55,269
+1141,362
+774,208
+387,661
+842,555
+1181,617
+84,488
+85,301
+356,277
+196,297
+152,637
+274,221
+423,640
+1267,283
+1116,444
+412,854
+256,690
+656,240
+1278,737
+90,65
+522,516
+639,789
+527,351
+445,343
+576,848
+408,660
+1124,339
+641,113
+890,354
+239,611
+141,768
+1131,122
+413,749
+276,142
+937,534
+1133,1
+1148,296
+1086,483
+5,704
+706,142
+311,339
+915,185
+80,576
+103,294
+840,767
+928,607
+45,595
+710,714
+902,770
+236,325
+947,187
+1180,386
+1156,464
+251,201
+452,436
+1056,7
+214,292
+162,596
+415,425
+1297,864
+858,21
+922,235
+448,436
+632,292
+1156,99
+1158,637
+425,106
+785,478
+595,9
+1275,203
+971,28
+1255,269
+813,598
+1034,752
+974,222
+773,501
+1186,873
+788,378
+246,621
+1036,221
+50,330
+1118,225
+944,887
+843,654
+892,688
+10,170
+624,327
+59,325
+796,404
+560,583
+634,158
+430,820
+361,771
+1004,84
+848,732
+1020,577
+570,630
+951,255
+231,702
+186,555
+239,835
+177,270
+626,617
+597,2
+1068,488
+70,879
+939,507
+997,781
+202,383
+1174,124
+142,290
+1086,820
+763,269
+1246,383
+276,451
+308,215
+1232,512
+594,442
+1068,157
+1240,15
+22,451
+1017,729
+788,516
+35,95
+897,609
+189,605
+267,824
+701,299
+0,395
+447,163
+900,434
+691,691
+1062,270
+758,288
+1148,308
+902,124
+880,596
+796,490
+492,596
+470,319
+874,343
+535,275
+110,449
+894,2
+798,736
+1278,157
+932,786
+1226,712
+216,893
+186,714
+457,53
+1265,299
+1251,549
+959,688
+974,235
+631,861
+1161,653
+895,835
+59,9
+686,648
+1200,449
+956,602
+149,494
+234,92
+328,296
+872,757
+910,659
+353,136
+206,609
+43,171
+470,799
+246,385
+610,14
+669,113
+527,95
+1074,617
+1110,737
+726,879
+1069,749
+701,621
+773,119
+835,865
+1049,280
+567,374
+447,843
+1287,879
+1233,501
+743,822
+1124,180
+621,165
+1047,49
+681,136
+171,276
+753,240
+1064,621
+108,294
+688,157
+557,218
+149,429
+1230,268
+576,325
+616,368
+996,784
+534,3
+1092,175
+850,444
+731,28
+1081,838
+1022,78
+392,63
+383,849
+728,401
+669,847
+441,238
+415,835
+937,165
+154,99
+618,868
+764,294
+1012,893
+853,53
+569,581
+1146,856
+261,589
+1071,59
+994,170
+619,169
+20,747
+291,259
+864,238
+505,848
+177,449
+311,789
+97,228
+1091,717
+691,203
+65,502
+242,488
+1043,233
+1156,547
+1266,213
+525,49
+54,42
+974,683
+887,752
+1280,556
+1260,623
+775,619
+984,296
+256,204
+296,255
+1230,57
+397,101
+186,443
+1066,273
+246,273
+1064,837
+316,101
+569,761
+341,702
+570,264
+780,67
+341,192
+759,121
+536,208
+582,151
+1086,411
+512,736
+430,635
+78,288
+80,823
+1230,161
+1071,649
+1044,659
+1243,633
+90,887
+773,53
+1104,443
+443,609
+753,228
+1168,255
+218,175
+579,649
+564,719
+393,838
+304,292
+954,277
+1004,35
+200,157
+1034,108
+622,597
+246,572
+1299,527
+1094,893
+874,712
+108,495
+552,288
+1168,527
+1173,512
+634,606
+1056,289
+910,605
+713,892
+1092,742
+629,830
+678,227
+514,404
+1207,600
+1287,127
+186,180
+559,702
+213,600
+818,596
+33,640
+542,266
+13,296
+1290,411
+736,268
+339,82
+1011,511
+363,777
+1036,1
+129,617
+11,866
+436,103
+1146,756
+1052,448
+587,561
+194,254
+1302,211
+1076,92
+1250,583
+22,555
+955,383
+728,679
+393,56
+574,268
+171,724
+1138,224
+1056,887
+982,843
+470,751
+219,717
+649,89
+567,163
+957,382
+184,738
+574,71
+1047,497
+1153,192
+863,843
+318,211
+669,270
+348,35
+366,7
+949,837
+875,177
+269,640
+452,10
+338,618
+735,395
+713,655
+55,848
+1220,569
+693,476
+880,515
+609,273
+306,84
+199,298
+440,602
+137,605
+1267,723
+38,383
+208,238
+457,192
+140,107
+810,99
+371,507
+995,759
+157,192
+300,154
+607,621
+721,502
+1238,698
+1290,288
+50,527
+59,549
+335,618
+154,795
+261,676
+1170,787
+452,603
+291,351
+164,876
+1049,589
+366,455
+964,343
+1052,446
+567,420
+944,63
+90,271
+818,242
+1290,362
+110,1
+624,567
+243,152
+137,289
+528,605
+925,450
+544,585
+0,499
+1113,702
+430,298
+691,169
+740,45
+55,401
+107,625
+336,211
+530,827
+676,736
+400,298
+1064,273
+140,266
+199,596
+276,752
+843,240
+1288,443
+1168,830
+537,327
+1091,625
+172,323
+77,841
+738,823
+728,493
+1233,841
+1074,773
+569,593
+78,64
+1161,150
+474,831
+475,865
+904,737
+416,2
+688,289
+547,401
+80,621
+785,497
+746,7
+1069,637
+1297,296
+932,183
+783,635
+977,805
+241,749
+162,296
+594,260
+678,718
+979,324
+261,305
+782,93
+1092,623
+1049,726
+1216,311
+1020,317
+574,318
+1113,192
+194,327
+791,698
+773,327
+880,35
+259,261
+743,693
+1299,28
+1011,383
+525,254
+1305,414
+120,891
+962,604
+1280,567
+514,490
+11,28
+266,191
+1299,418
+892,211
+1173,323
+599,158
+1074,586
+678,740
+1180,829
+1092,719
+557,228
+214,714
+423,254
+1153,744
+692,868
+569,285
+726,463
+537,53
+1302,670
+1250,442
+723,561
+184,512
+520,613
+808,637
+72,316
+599,718
+796,68
+54,266
+952,639
+1278,297
+853,217
+1161,465
+567,245
+546,600
+932,527
+129,169
+574,519
+400,45
+743,474
+683,63
+219,625
+654,240
+402,394
+202,159
+1285,512
+885,390
+1019,19
+157,744
+927,176
+500,464
+177,429
+686,327
+830,730
+257,101
+997,593
+1056,148
+853,609
+828,771
+1078,311
+517,323
+567,72
+1074,596
+70,239
+372,661
+753,676
+1225,761
+8,352
+1133,744
+785,49
+1118,221
+1184,829
+23,575
+254,849
+632,624
+254,887
+641,623
+269,444
+351,688
+293,729
+254,148
+734,569
+574,621
+621,254
+410,210
+631,879
+72,663
+184,95
+8,318
+923,661
+1203,269
+482,99
+938,681
+1285,288
+600,714
+868,521
+691,317
+1272,495
+1043,824
+741,285
+820,74
+1233,53
+728,148
+984,598
+987,772
+326,296
+734,288
+1089,136
+587,261
+1240,879
+734,325
+90,623
+467,15
+1183,707
+80,733
+124,67
+514,826
+1235,245
+400,235
+1310,395
+1148,596
+1181,497
+971,866
+392,159
+713,444
+1299,866
+254,743
+32,597
+644,276
+1074,271
+885,106
+629,382
+87,245
+616,526
+363,187
+795,464
+740,264
+252,52
+191,420
+328,322
+520,501
+326,843
+869,238
+1215,857
+887,254
+274,1
+528,93
+927,830
+1202,399
+452,291
+865,343
+1041,640
+120,667
+132,416
+750,535
+845,289
+406,737
+1058,276
+557,464
+52,893
+604,142
+1081,676
+887,37
+272,868
+805,17
+1126,319
+564,623
+482,771
+956,322
+731,649
+1034,443
+811,394
+569,313
+412,830
+962,479
+904,624
+656,372
+710,490
+1255,401
+679,861
+551,121
+632,227
+1178,192
+977,744
+992,211
+1086,158
+378,527
+1297,47
+410,729
+438,85
+298,445
+582,764
+1251,773
+1000,719
+507,794
+909,668
+969,478
+843,413
+1308,101
+1230,716
+129,254
+458,745
+346,551
+313,593
+761,127
+1053,101
+304,602
+900,281
+1104,3
+736,57
+336,672
+134,137
+43,283
+746,439
+609,299
+1232,606
+689,254
+124,21
+1280,191
+715,9
+25,288
+869,656
+848,757
+870,752
+224,483
+915,136
+132,444
+1153,254
+552,606
+617,628
+177,445
+341,478
+348,290
+547,269
+682,98
+661,805
+743,374
+984,843
+236,569
+452,425
+646,542
+388,659
+1006,292
+339,28
+
+fold along x=655
+fold along y=447
+fold along x=327
+fold along y=223
+fold along x=163
+fold along y=111
+fold along x=81
+fold along y=55
+fold along x=40
+fold along y=27
+fold along y=13
+fold along y=6

+ 21 - 0
aoc2021/day13_transparent_origami/example.txt

@@ -0,0 +1,21 @@
+6,10
+0,14
+9,10
+0,3
+10,4
+4,11
+6,0
+6,12
+4,1
+0,13
+10,12
+3,4
+3,0
+8,4
+1,10
+2,14
+8,10
+9,0
+
+fold along y=7
+fold along x=5

+ 812 - 0
aoc2021/day13_transparent_origami/input.txt

@@ -0,0 +1,812 @@
+726,774
+246,695
+579,249
+691,724
+246,820
+738,887
+1088,75
+264,887
+704,775
+907,625
+676,117
+507,658
+1009,24
+547,735
+157,126
+599,113
+445,226
+363,691
+918,794
+927,113
+999,400
+443,305
+654,729
+408,767
+1066,863
+1148,473
+321,35
+1093,803
+1044,718
+202,889
+262,164
+378,541
+619,662
+1034,849
+432,595
+1145,656
+1295,668
+1125,705
+1161,529
+759,619
+1170,147
+688,742
+328,729
+718,439
+935,701
+246,647
+594,110
+845,495
+160,189
+1225,315
+580,486
+469,481
+440,401
+584,774
+897,719
+1007,516
+547,159
+112,117
+982,645
+62,439
+192,441
+631,211
+654,16
+113,698
+378,865
+373,19
+441,777
+390,7
+1263,312
+1121,610
+509,582
+893,352
+44,131
+1092,19
+592,719
+918,100
+326,820
+62,719
+520,889
+718,103
+571,579
+1165,267
+1208,334
+525,415
+268,588
+769,464
+596,716
+734,436
+1283,747
+35,457
+982,94
+1235,849
+932,752
+1265,243
+262,752
+99,704
+547,732
+1096,829
+791,329
+1222,320
+199,568
+671,494
+1079,93
+569,315
+129,415
+868,878
+788,803
+1175,889
+965,676
+904,660
+552,560
+619,484
+507,236
+566,768
+1215,30
+45,410
+885,441
+478,336
+945,397
+596,306
+1145,686
+189,495
+1153,126
+79,444
+719,403
+903,91
+27,105
+441,329
+768,565
+671,400
+507,205
+224,390
+867,753
+425,441
+1123,67
+833,14
+793,278
+1237,724
+238,808
+1099,32
+411,243
+1,574
+726,120
+862,441
+212,94
+80,199
+1047,312
+164,389
+440,773
+185,189
+412,114
+537,792
+403,697
+1208,768
+408,527
+1135,831
+746,826
+1064,110
+15,226
+102,574
+1001,442
+769,16
+1236,408
+440,121
+1309,131
+771,473
+1064,527
+189,284
+427,704
+276,865
+986,593
+1009,870
+745,276
+965,291
+1190,5
+1084,768
+313,750
+976,544
+1222,658
+223,619
+718,791
+976,574
+705,822
+785,863
+388,390
+1235,716
+579,645
+90,378
+497,849
+1308,145
+658,301
+648,94
+1150,189
+231,129
+408,639
+390,119
+132,556
+639,220
+885,453
+413,651
+639,68
+177,544
+552,782
+239,130
+867,645
+187,67
+1163,494
+1227,19
+249,658
+132,270
+740,82
+73,206
+1166,525
+262,506
+1092,875
+923,509
+967,400
+813,849
+734,364
+604,541
+566,758
+90,852
+190,831
+1047,65
+313,144
+542,157
+720,304
+129,863
+1280,149
+448,441
+947,484
+1048,506
+408,863
+657,803
+480,834
+201,369
+489,208
+1275,36
+1064,784
+781,845
+1071,152
+1251,61
+455,500
+564,68
+758,798
+922,390
+443,421
+505,792
+60,784
+1059,645
+741,315
+89,164
+142,637
+348,705
+763,735
+165,686
+711,781
+1220,852
+455,120
+1205,859
+1208,413
+1098,240
+33,505
+821,208
+35,289
+1251,833
+1131,226
+745,730
+75,625
+905,75
+738,7
+1223,316
+923,395
+7,884
+1153,299
+552,96
+1047,134
+642,266
+537,698
+1211,190
+959,235
+1235,625
+711,614
+510,798
+73,306
+47,582
+657,875
+468,75
+638,346
+144,525
+612,665
+917,57
+1235,402
+211,249
+831,63
+1197,250
+493,686
+887,801
+85,315
+263,65
+924,306
+140,595
+997,141
+657,173
+579,850
+489,686
+448,5
+572,7
+1248,103
+445,674
+711,113
+1232,884
+1121,278
+845,732
+786,630
+114,712
+691,662
+140,147
+1088,299
+408,191
+897,691
+92,662
+904,754
+1309,621
+102,768
+7,10
+33,429
+903,803
+2,749
+1083,704
+157,819
+325,91
+830,386
+763,284
+175,63
+902,199
+887,129
+1285,297
+1287,683
+590,304
+714,716
+6,686
+1136,834
+452,889
+653,315
+135,145
+683,329
+251,473
+1110,455
+959,516
+1091,838
+407,220
+654,800
+549,239
+765,355
+113,250
+771,93
+194,270
+864,803
+517,417
+345,291
+253,724
+365,145
+522,624
+692,495
+830,834
+1021,301
+825,595
+145,890
+1125,481
+48,119
+82,7
+965,666
+540,630
+542,121
+731,290
+85,763
+957,297
+1277,617
+1089,239
+619,612
+62,175
+427,190
+401,724
+1133,798
+475,882
+1062,140
+246,784
+1001,515
+244,31
+759,171
+1246,282
+249,236
+919,816
+907,25
+755,403
+557,725
+15,332
+840,861
+1031,760
+965,218
+813,45
+440,829
+885,457
+45,243
+351,435
+191,565
+984,820
+715,275
+689,641
+289,845
+575,892
+605,822
+1136,508
+137,278
+870,513
+59,621
+79,539
+89,276
+1,621
+753,725
+1119,301
+1,763
+1159,539
+1059,25
+267,843
+1072,236
+1203,607
+425,453
+62,551
+788,624
+576,884
+326,430
+345,452
+539,473
+1195,337
+981,432
+23,683
+455,394
+1098,654
+1118,441
+1277,429
+567,625
+773,698
+23,459
+441,464
+870,488
+567,269
+517,399
+935,302
+436,875
+309,442
+900,191
+1277,277
+1310,165
+383,781
+149,792
+492,578
+88,658
+736,500
+103,275
+731,44
+720,794
+1278,600
+981,462
+1020,623
+329,462
+333,483
+977,880
+1181,863
+509,890
+846,831
+246,527
+570,754
+841,481
+78,884
+1231,355
+618,47
+413,719
+850,786
+174,386
+364,175
+1193,196
+162,421
+221,239
+373,875
+718,7
+1231,539
+1218,662
+333,868
+885,9
+30,149
+1299,511
+227,190
+1197,698
+1150,705
+657,238
+783,717
+1159,383
+212,688
+241,719
+618,495
+1232,458
+985,432
+27,75
+918,506
+328,800
+145,582
+387,395
+90,516
+1019,773
+334,574
+1285,149
+716,558
+413,236
+353,477
+607,193
+845,844
+874,875
+1099,648
+264,63
+99,491
+263,312
+303,67
+463,565
+433,239
+902,527
+132,355
+1300,550
+606,119
+291,849
+25,86
+301,865
+1046,831
+805,102
+408,598
+1101,693
+1215,864
+947,691
+64,730
+1237,170
+970,628
+1136,60
+947,730
+334,544
+1149,686
+1009,198
+691,282
+691,457
+378,142
+599,614
+648,320
+507,400
+1178,803
+478,558
+267,51
+279,701
+965,452
+691,232
+401,170
+219,838
+1292,413
+296,373
+246,127
+446,91
+894,86
+115,480
+1287,155
+433,655
+263,134
+87,630
+965,403
+107,623
+189,610
+330,749
+1121,271
+965,603
+135,749
+1059,473
+328,165
+27,147
+443,134
+1210,320
+1211,470
+415,824
+835,882
+405,819
+957,870
+493,721
+1246,164
+935,591
+895,824
+264,455
+99,470
+408,296
+803,400
+1084,126
+1135,63
+835,46
+830,60
+653,721
+1104,453
+525,863
+102,334
+1235,45
+870,121
+375,591
+60,336
+348,880
+895,600
+517,477
+427,526
+100,551
+37,301
+477,880
+0,94
+383,390
+266,718
+212,240
+634,329
+291,493
+976,320
+751,30
+1119,593
+443,753
+1099,645
+79,450
+189,278
+358,745
+870,355
+1064,820
+353,597
+770,630
+157,75
+22,371
+214,493
+465,726
+1205,655
+740,469
+125,49
+1019,849
+735,556
+1148,421
+832,336
+803,338
+848,441
+946,175
+301,149
+115,305
+528,215
+6,208
+6,320
+691,410
+238,658
+16,346
+735,892
+689,725
+661,320
+1136,386
+1153,810
+363,730
+326,464
+321,819
+885,885
+1048,388
+425,9
+127,809
+656,16
+599,280
+74,408
+387,509
+73,724
+293,877
+557,687
+656,878
+1304,320
+1034,865
+704,119
+126,663
+141,656
+914,859
+1230,647
+340,266
+33,501
+1262,352
+505,344
+1283,105
+1198,289
+855,500
+574,871
+540,598
+465,844
+1210,343
+825,96
+290,623
+174,508
+132,539
+867,93
+1101,201
+392,142
+472,126
+552,320
+631,739
+867,473
+763,758
+467,67
+251,269
+1273,301
+619,282
+1148,130
+801,4
+566,136
+1098,94
+1274,47
+333,411
+401,82
+48,352
+1230,522
+907,269
+870,829
+631,683
+406,660
+440,488
+800,798
+244,765
+657,768
+662,94
+33,465
+785,415
+83,450
+1159,355
+653,686
+392,730
+417,352
+691,829
+902,598
+947,282
+242,469
+135,301
+174,834
+816,189
+914,894
+671,562
+460,786
+1079,765
+125,525
+213,430
+480,60
+1086,390
+1111,809
+375,302
+1227,390
+1072,684
+343,494
+443,473
+904,234
+485,45
+1285,86
+977,299
+758,782
+242,425
+460,718
+37,593
+730,486
+559,877
+505,102
+401,812
+231,254
+403,269
+493,238
+1181,479
+189,29
+545,355
+264,439
+547,60
+900,695
+689,393
+1079,254
+408,199
+846,383
+1223,630
+1121,284
+345,666
+441,117
+237,800
+191,525
+1066,255
+552,768
+639,494
+798,705
+1004,189
+1169,861
+686,745
+1121,29
+554,126
+1277,465
+977,432
+711,399
+12,628
+
+fold along x=655
+fold along y=447
+fold along x=327
+fold along y=223
+fold along x=163
+fold along y=111
+fold along x=81
+fold along y=55
+fold along x=40
+fold along y=27
+fold along y=13
+fold along y=6

+ 55 - 0
aoc2021/day13_transparent_origami/main.py

@@ -0,0 +1,55 @@
+import os, sys
+import numpy as np
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, check_example, generate_readme
+
+
+def folding(input: list[str]) -> tuple[int, np.ndarray]:
+    coords = np.array(
+        [
+            (line.split(",")[1], line.split(",")[0])
+            for line in input
+            if len(line) > 1 and len(line) < 12
+        ],
+        dtype=int,
+    )
+    instructions = [line[11:].split("=") for line in input if line.startswith("f")]
+    x, y = 0, 0
+    for inst in instructions:
+        match inst:
+            case ["y", c]: x = int(c) * 2 + 1
+            case ["x", c]: y = int(c) * 2 + 1
+        if x != 0 and y != 0: paper = np.zeros((x, y), dtype=np.int8); break
+    paper[coords[:, 0], coords[:, 1]] = 1
+    for step, inst in enumerate(instructions):
+        match inst:
+            case ["y", c]: paper = paper[: int(c)] + np.flipud(paper[int(c) + 1 :])
+            case ["x", c]: paper = paper[:, : int(c)] + np.fliplr(paper[:, int(c) + 1 :])
+        if step == 0:
+            part1 = np.where(paper > 0, 1, 0).sum()
+    part2 = np.where(paper > 0, "#", ".")
+    return part1, part2
+
+
+def part1(input: list[str]):
+    part1, _ = folding(input)
+    print("The anwer of part1 is:", part1)
+
+
+def part2(input: list[str]):
+    _, part2 = folding(input)
+    print("The answer of part2 is:\n")
+    for line in part2:
+        print("".join(line))
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 13)
+
+    check_example(example, part1)
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 13)

+ 3 - 0
aoc2021/day13_transparent_origami/src/main.rs

@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}

+ 86 - 0
aoc2021/day14_extended_polymerization/README.md

@@ -0,0 +1,86 @@
+--- Day 14: Extended Polymerization ---
+---------------------------------------
+
+The incredible pressures at this depth are starting to put a strain on your submarine. The submarine has [polymerization](https://en.wikipedia.org/wiki/Polymerization) equipment that would produce suitable materials to reinforce the submarine, and the nearby volcanically-active caves should even have the necessary input elements in sufficient quantities.
+
+
+The submarine manual contains instructions for finding the optimal polymer formula; specifically, it offers a *polymer template* and a list of *pair insertion* rules (your puzzle input). You just need to work out what polymer would result after repeating the pair insertion process a few times.
+
+
+For example:
+
+
+
+```
+NNCB
+
+CH -> B
+HH -> N
+CB -> H
+NH -> C
+HB -> C
+HC -> B
+HN -> C
+NN -> C
+BH -> H
+NC -> B
+NB -> B
+BN -> B
+BB -> N
+BC -> B
+CC -> N
+CN -> C
+
+```
+
+The first line is the *polymer template* - this is the starting point of the process.
+
+
+The following section defines the *pair insertion* rules. A rule like `AB -> C` means that when elements `A` and `B` are immediately adjacent, element `C` should be inserted between them. These insertions all happen simultaneously.
+
+
+So, starting with the polymer template `NNCB`, the first step simultaneously considers all three pairs:
+
+
+* The first pair (`NN`) matches the rule `NN -> C`, so element `*C*` is inserted between the first `N` and the second `N`.
+* The second pair (`NC`) matches the rule `NC -> B`, so element `*B*` is inserted between the `N` and the `C`.
+* The third pair (`CB`) matches the rule `CB -> H`, so element `*H*` is inserted between the `C` and the `B`.
+
+
+Note that these pairs overlap: the second element of one pair is the first element of the next pair. Also, because all pairs are considered simultaneously, inserted elements are not considered to be part of a pair until the next step.
+
+
+After the first step of this process, the polymer becomes `N*C*N*B*C*H*B`.
+
+
+Here are the results of a few steps using the above rules:
+
+
+
+```
+Template:     NNCB
+After step 1: NCNBCHB
+After step 2: NBCCNBBBCBHCB
+After step 3: NBBBCNCCNBBNBNBBCHBHHBCHB
+After step 4: NBBNBNBBCCNBCNCCNBBNBBNBBBNBBNBBCBHCBHHNHCBBCBHCB
+
+```
+
+This polymer grows quickly. After step 5, it has length 97; After step 10, it has length 3073. After step 10, `B` occurs 1749 times, `C` occurs 298 times, `H` occurs 161 times, and `N` occurs 865 times; taking the quantity of the most common element (`B`, 1749) and subtracting the quantity of the least common element (`H`, 161) produces `1749 - 161 = *1588*`.
+
+
+Apply 10 steps of pair insertion to the polymer template and find the most and least common elements in the result. *What do you get if you take the quantity of the most common element and subtract the quantity of the least common element?*
+
+
+--- Part Two ---
+----------------
+
+The resulting polymer isn't nearly strong enough to reinforce the submarine. You'll need to run more steps of the pair insertion process; a total of *40 steps* should do it.
+
+
+In the above example, the most common element is `B` (occurring `2192039569602` times) and the least common element is `H` (occurring `3849876073` times); subtracting these produces `*2188189693529*`.
+
+
+Apply *40* steps of pair insertion to the polymer template and find the most and least common elements in the result. *What do you get if you take the quantity of the most common element and subtract the quantity of the least common element?*
+
+

+ 102 - 0
aoc2021/day14_extended_polymerization/day14.txt

@@ -0,0 +1,102 @@
+HBCHSNFFVOBNOFHFOBNO
+
+HF -> O
+KF -> F
+NK -> F
+BN -> O
+OH -> H
+VC -> F
+PK -> B
+SO -> B
+PP -> H
+KO -> F
+VN -> S
+OS -> B
+NP -> C
+OV -> C
+CS -> P
+BH -> P
+SS -> P
+BB -> H
+PH -> V
+HN -> F
+KV -> H
+HC -> B
+BC -> P
+CK -> P
+PS -> O
+SH -> N
+FH -> N
+NN -> P
+HS -> O
+CB -> F
+HH -> F
+SB -> P
+NB -> F
+BO -> V
+PN -> H
+VP -> B
+SC -> C
+HB -> H
+FP -> O
+FC -> H
+KP -> B
+FB -> B
+VK -> F
+CV -> P
+VF -> V
+SP -> K
+CC -> K
+HV -> P
+NC -> N
+VH -> K
+PF -> P
+PB -> S
+BF -> K
+FF -> C
+FV -> V
+KS -> H
+VB -> F
+SV -> F
+HO -> B
+FN -> C
+SN -> F
+OB -> N
+KN -> P
+BV -> H
+ON -> N
+NF -> S
+OF -> P
+NV -> S
+VS -> C
+OO -> C
+BP -> H
+BK -> N
+CP -> N
+PC -> K
+CN -> H
+KB -> B
+BS -> P
+KK -> P
+SF -> V
+CO -> V
+CH -> P
+FO -> B
+FS -> F
+VO -> H
+NS -> F
+KC -> H
+VV -> K
+NO -> P
+OK -> F
+PO -> V
+FK -> H
+OP -> H
+PV -> N
+CF -> P
+NH -> K
+SK -> O
+KH -> P
+HP -> V
+OC -> V
+HK -> F

+ 18 - 0
aoc2021/day14_extended_polymerization/example.txt

@@ -0,0 +1,18 @@
+NNCB
+
+CH -> B
+HH -> N
+CB -> H
+NH -> C
+HB -> C
+HC -> B
+HN -> C
+NN -> C
+BH -> H
+NC -> B
+NB -> B
+BN -> B
+BB -> N
+BC -> B
+CC -> N
+CN -> C

+ 102 - 0
aoc2021/day14_extended_polymerization/input.txt

@@ -0,0 +1,102 @@
+PKHOVVOSCNVHHCVVCBOH
+
+NO -> B
+PV -> P
+OC -> K
+SC -> K
+FK -> P
+PO -> P
+FC -> V
+KN -> V
+CN -> O
+CB -> K
+NF -> K
+CO -> F
+SK -> F
+VO -> B
+SF -> F
+PB -> F
+FF -> C
+HC -> P
+PF -> B
+OP -> B
+OO -> V
+OK -> N
+KB -> H
+PN -> V
+PP -> N
+FV -> S
+BO -> O
+HN -> C
+FP -> F
+BP -> B
+HB -> N
+VC -> F
+PC -> V
+FO -> O
+OH -> S
+FH -> B
+HK -> B
+BC -> F
+ON -> K
+FN -> N
+NN -> O
+PH -> P
+KS -> H
+HV -> F
+BK -> O
+NP -> S
+CC -> H
+KV -> V
+NB -> C
+NS -> S
+KO -> V
+NK -> H
+HO -> C
+KC -> P
+VH -> C
+VK -> O
+CP -> K
+BS -> N
+BB -> F
+VV -> K
+SH -> O
+SO -> N
+VF -> K
+NV -> K
+SV -> O
+NH -> C
+VS -> N
+OF -> N
+SP -> C
+HP -> O
+NC -> V
+KP -> B
+KH -> O
+SN -> S
+CS -> N
+FB -> P
+OB -> H
+VP -> B
+CH -> O
+BF -> B
+PK -> S
+CF -> V
+CV -> S
+VB -> P
+CK -> H
+PS -> N
+SS -> C
+OS -> P
+OV -> F
+VN -> V
+BV -> V
+HF -> B
+FS -> O
+BN -> K
+SB -> N
+HH -> S
+BH -> S
+KK -> H
+HS -> K
+KF -> V

+ 54 - 0
aoc2021/day14_extended_polymerization/main.py

@@ -0,0 +1,54 @@
+from doctest import Example
+import os, sys
+from tabnanny import check
+
+from numpy import poly
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, check_example, generate_readme
+from collections import Counter, defaultdict
+
+
+def parse(input: list[str]) -> tuple[str, dict]:
+    template = input[0]
+    instructions = {}
+    for line in input[2:]:
+        key, value = line.split(" -> ")
+        instructions[(key[0], key[1])] = value
+    return template, instructions
+
+
+def polymerize(steps: int, template: str, instructions: dict) -> int:
+    counter = Counter(template)
+    combinations: defaultdict[tuple, int] = defaultdict(int)
+    for i in range(len(template) - 1):
+        combinations[(template[i], template[i + 1])] += 1
+    for _ in range(steps):
+        temp_combinations = combinations.copy()
+        for comb in temp_combinations:
+            counter[instructions[comb]] += temp_combinations[comb]
+            combinations[comb] -= temp_combinations[comb]
+            combinations[(comb[0], instructions[comb])] += temp_combinations[comb]
+            combinations[(instructions[comb], comb[1])] += temp_combinations[comb]
+    return max(counter.values()) - min(counter.values())
+
+
+def part1(input: list[str]):
+    print("The answer of part1 is:", polymerize(10, *parse(input)))
+
+
+def part2(input: list[str]):
+    print("The answer if part2 is:", polymerize(40, *parse(input)))
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 14)
+
+    check_example(example, part1)
+    check_example(example, part2)
+
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 14)

+ 195 - 0
aoc2021/day15_chiton/README.md

@@ -0,0 +1,195 @@
+--- Day 15: Chiton ---
+----------------------
+
+You've almost reached the exit of the cave, but the walls are getting closer together. Your submarine can barely still fit, though; the main problem is that the walls of the cave are covered in [chitons](https://en.wikipedia.org/wiki/Chiton), and it would be best not to bump any of them.
+
+
+The cavern is large, but has a very low ceiling, restricting your motion to two dimensions. The shape of the cavern resembles a square; a quick scan of chiton density produces a map of *risk level* throughout the cave (your puzzle input). For example:
+
+
+
+```
+1163751742
+1381373672
+2136511328
+3694931569
+7463417111
+1319128137
+1359912421
+3125421639
+1293138521
+2311944581
+
+```
+
+You start in the top left position, your destination is the bottom right position, and you cannot move diagonally. The number at each position is its *risk level*; to determine the total risk of an entire path, add up the risk levels of each position you *enter* (that is, don't count the risk level of your starting position unless you enter it; leaving it adds no risk to your total).
+
+
+Your goal is to find a path with the *lowest total risk*. In this example, a path with the lowest total risk is highlighted here:
+
+
+
+```
+*1*163751742
+*1*381373672
+*2136511*328
+369493*15*69
+7463417*1*11
+1319128*13*7
+13599124*2*1
+31254216*3*9
+12931385*21*
+231194458*1*
+
+```
+
+The total risk of this path is `*40*` (the starting position is never entered, so its risk is not counted).
+
+
+*What is the lowest total risk of any path from the top left to the bottom right?*
+
+
+--- Part Two ---
+----------------
+
+Now that you know how to find low-risk paths in the cave, you can try to find your way out.
+
+
+The entire cave is actually *five times larger in both dimensions* than you thought; the area you originally scanned is just one tile in a 5x5 tile area that forms the full map. Your original map tile repeats to the right and downward; each time the tile repeats to the right or downward, all of its risk levels *are 1 higher* than the tile immediately up or left of it. However, risk levels above `9` wrap back around to `1`. So, if your original map had some position with a risk level of `8`, then that same position on each of the 25 total tiles would be as follows:
+
+
+
+```
+8 9 1 2 3
+9 1 2 3 4
+1 2 3 4 5
+2 3 4 5 6
+3 4 5 6 7
+
+```
+
+Each single digit above corresponds to the example position with a value of `8` on the top-left tile. Because the full map is actually five times larger in both dimensions, that position appears a total of 25 times, once in each duplicated tile, with the values shown above.
+
+
+Here is the full five-times-as-large version of the first example above, with the original map in the top left corner highlighted:
+
+
+
+```
+*1163751742*2274862853338597396444961841755517295286
+*1381373672*2492484783351359589446246169155735727126
+*2136511328*3247622439435873354154698446526571955763
+*3694931569*4715142671582625378269373648937148475914
+*7463417111*8574528222968563933317967414442817852555
+*1319128137*2421239248353234135946434524615754563572
+*1359912421*2461123532357223464346833457545794456865
+*3125421639*4236532741534764385264587549637569865174
+*1293138521*2314249632342535174345364628545647573965
+*2311944581*3422155692453326671356443778246755488935
+22748628533385973964449618417555172952866628316397
+24924847833513595894462461691557357271266846838237
+32476224394358733541546984465265719557637682166874
+47151426715826253782693736489371484759148259586125
+85745282229685639333179674144428178525553928963666
+24212392483532341359464345246157545635726865674683
+24611235323572234643468334575457944568656815567976
+42365327415347643852645875496375698651748671976285
+23142496323425351743453646285456475739656758684176
+34221556924533266713564437782467554889357866599146
+33859739644496184175551729528666283163977739427418
+35135958944624616915573572712668468382377957949348
+43587335415469844652657195576376821668748793277985
+58262537826937364893714847591482595861259361697236
+96856393331796741444281785255539289636664139174777
+35323413594643452461575456357268656746837976785794
+35722346434683345754579445686568155679767926678187
+53476438526458754963756986517486719762859782187396
+34253517434536462854564757396567586841767869795287
+45332667135644377824675548893578665991468977611257
+44961841755517295286662831639777394274188841538529
+46246169155735727126684683823779579493488168151459
+54698446526571955763768216687487932779859814388196
+69373648937148475914825958612593616972361472718347
+17967414442817852555392896366641391747775241285888
+46434524615754563572686567468379767857948187896815
+46833457545794456865681556797679266781878137789298
+64587549637569865174867197628597821873961893298417
+45364628545647573965675868417678697952878971816398
+56443778246755488935786659914689776112579188722368
+55172952866628316397773942741888415385299952649631
+57357271266846838237795794934881681514599279262561
+65719557637682166874879327798598143881961925499217
+71484759148259586125936169723614727183472583829458
+28178525553928963666413917477752412858886352396999
+57545635726865674683797678579481878968159298917926
+57944568656815567976792667818781377892989248891319
+75698651748671976285978218739618932984172914319528
+56475739656758684176786979528789718163989182927419
+67554889357866599146897761125791887223681299833479
+
+```
+
+Equipped with the full map, you can now find a path from the top left corner to the bottom right corner with the lowest total risk:
+
+
+
+```
+*1*1637517422274862853338597396444961841755517295286
+*1*3813736722492484783351359589446246169155735727126
+*2*1365113283247622439435873354154698446526571955763
+*3*6949315694715142671582625378269373648937148475914
+*7*4634171118574528222968563933317967414442817852555
+*1*3191281372421239248353234135946434524615754563572
+*1*3599124212461123532357223464346833457545794456865
+*3*1254216394236532741534764385264587549637569865174
+*1*2931385212314249632342535174345364628545647573965
+*2*3119445813422155692453326671356443778246755488935
+*2*2748628533385973964449618417555172952866628316397
+*2*4924847833513595894462461691557357271266846838237
+*324*76224394358733541546984465265719557637682166874
+47*15*1426715826253782693736489371484759148259586125
+857*4*5282229685639333179674144428178525553928963666
+242*1*2392483532341359464345246157545635726865674683
+246*1123532*3572234643468334575457944568656815567976
+423653274*1*5347643852645875496375698651748671976285
+231424963*2342*5351743453646285456475739656758684176
+342215569245*332*66713564437782467554889357866599146
+33859739644496*1*84175551729528666283163977739427418
+35135958944624*61*6915573572712668468382377957949348
+435873354154698*44*652657195576376821668748793277985
+5826253782693736*4*893714847591482595861259361697236
+9685639333179674*1*444281785255539289636664139174777
+3532341359464345*2461*575456357268656746837976785794
+3572234643468334575*4*579445686568155679767926678187
+5347643852645875496*3*756986517486719762859782187396
+3425351743453646285*4564*757396567586841767869795287
+4533266713564437782467*554*8893578665991468977611257
+449618417555172952866628*3163*9777394274188841538529
+462461691557357271266846838*2*3779579493488168151459
+546984465265719557637682166*8*7487932779859814388196
+693736489371484759148259586*125*93616972361472718347
+17967414442817852555392896366*6413*91747775241285888
+46434524615754563572686567468379*7*67857948187896815
+46833457545794456865681556797679*26*6781878137789298
+645875496375698651748671976285978*21*873961893298417
+4536462854564757396567586841767869*7*952878971816398
+5644377824675548893578665991468977*6112*579188722368
+5517295286662831639777394274188841538*5*299952649631
+5735727126684683823779579493488168151*4*599279262561
+6571955763768216687487932779859814388*1*961925499217
+7148475914825958612593616972361472718*34725*83829458
+28178525553928963666413917477752412858886*3*52396999
+57545635726865674683797678579481878968159*2*98917926
+57944568656815567976792667818781377892989*24*8891319
+756986517486719762859782187396189329841729*1431*9528
+564757396567586841767869795287897181639891829*2*7419
+675548893578665991468977611257918872236812998*33479*
+
+```
+
+The total risk of this path is `*315*` (the starting position is still never entered, so its risk is not counted).
+
+
+Using the full map, *what is the lowest total risk of any path from the top left to the bottom right?*
+
+

+ 100 - 0
aoc2021/day15_chiton/day15.txt

@@ -0,0 +1,100 @@
+1968464916112191391611281151919845361299153415891198154268959132641114694817612267218838462583491879
+1525711216133142195619415736511844811196712782556111378172222212112846932272411896119155816624819212
+2143631162361912221922237361391393339328231912118313179363187197511971887961771617331732194239586227
+2521625314121441899413948951224935654611261168644252173433111379118144918591261352845133931111363211
+3419116395171316754263144619316121119141789791156176133491119172413835731812143128339462157211714832
+4524964153247428319314129912911299537321149133376523131712395239297611385551521232187248866732262314
+3711569922572112311111231381621569819613115824152623211149153892114351938526483513994131899221246184
+9372218211227923291116514163647131281542651458928544319272115333829653212283218213572346151271148314
+7252439612436928721197324142761165133345614518725427643227211291261848311822364911669219447123922134
+3124222285338327514911622121557639192231775721619241455811912419714186296111754892144116269518316174
+5113431512416811186162119586184219513154115654732512834832944622331272212673422211413215473168541114
+8918761263115111432573131417344914456815121312151143626751572997964931367144931111322221919431184539
+2315112868211215119123391436214851892132438117198411361732935213389219321913111286356991581617112311
+8213439278426518916841321158915338871751157511511512411526362572186581353252493251161642321331319238
+3814648212312217732224215365116422292413315931251182667691212141251192261129314133611341111121183625
+1632153282115827199494219478516848819429439421146162464381572116271251127191323111921221781821561229
+2964993982275411123511321114194422113815922449458312261195939424115899991846139318433141623175699422
+3185911132222225882128911425231711193121162114993245158813396433493132142156112353212191881311222243
+2597419176117872623372257547963288114359198274123111217111515117134582471213835379443482187231716921
+1156128452723117148178522621611191136116514111135527613613518738572952213915169837111312119876125721
+8232332331311591318439824111216968834143211892318778976161332121429244151178389953221281123441111113
+2321966882423191161139314598311457179989165191214751117411811412971757518116913242314292957532412983
+5176118365231113228253112189957159351158513473428824359199457932137469329915812169531133176131715211
+7651131457228491985123334121791142316224345141412388137921745363819214421812123122111415171218423211
+3462391917297997812111394356232391771437391419149441431342312821371511368751471167152824426236119229
+4673185152112592819181865591613249119154112282337391342192979211292112114221121795165339253212146534
+4234957215119118622851122121288184214119123159675381781924921392139651738861641324135449311387528341
+5219623922594391372919236718332186133284187961852865774318269243651818144191524996159111313242918421
+7163473192149725221212261161211451212213312989111233514933331991243913291411726828442295192918336141
+9122121522342158355114591229418954411929582133466671811425725985313519796543513459188229991411919219
+1792321481168175515583211914355119425236113438217255811327548818533439118112225647992411894311221942
+6235961521362362331146957118417134195221372115174333562114577921453125915976317129248126331176514522
+1315322174651119927411853861313118318521851637512417779171141549468491216918151477196121583981631755
+3941512442333131733964938141131332181187172121911135919752637339812991513231411212596255623611113539
+4221411783221181622948692351164312639511911592521128119211739941244427471111892925571131192573439919
+1179196115212251261629513312991614794161983441112259261137256511915723118319332739142153922123143117
+4231711395216212819875423823212711161196111827533224932197941859731111442899614524483228527617386378
+3918246317283515329158129197374311321211714111832117967254272122116518731213341117948182114211224847
+2923818147359817264926711219234482591493138155147251119914129565392391271176111137476683621547214217
+1961381361734232123843911261247113619353513993323262598118181179514371422883549929231394584165211832
+8514111722951326162613191813346231172214441618781818362213597235884114841316169219182995612563233821
+1365732542831964731216313272619283721242171451815356121331113311623984432353118721938919562191451111
+2822939361319198155191312193217341726142263417942332122271866654334531117199731412186215315146877927
+1111454359813524123761969515729922437711147235265451492183352723992156214643584182711682754226151263
+2977234336552255461792636551916673213921564434121847731352815474153152211858923499436981622823142348
+1292116131548485823181118519834219267112994518194931139252194529133187389422531711195274926683516371
+4911191361188766113552115172265138293791321889212169645451869671991412161748416412312612856411243186
+1317171178186646329441152426228813263661198721323128341111326617211726491932473921125915111382162198
+1185112194772921899819164227599216312811921688121293758432648221118311682142211822211438864221158113
+4542913914281291351283313249391816267798761311622914884369113218553165256697957132933611942925155261
+4494431146129213351534929615418612524813688423431931398914972311152141513154988119419614671251497111
+9623781247216311684114814216291279421121111133322113443333261553655145212128395757147123414315523289
+5321158321169288211432611617339989115915699522248123124468123741112916981113251279212342226718119572
+3474561211372227212241133695812932236239356434494845611611717313598811351571451453513995711211431833
+8112861219127115311321991221176277548738413781747479942776125183321215594862116111775124614156181132
+4962761786242336114125151132266391316125134395336121111216174625111123821122755643641261588223833941
+4198791539415131939214719356144111462292386514121424212196639132151862123635134187812272994532554718
+4598231121311615611917161815226991221461112165262118216421252531152312223292442184491316842394264422
+6239922321177627293489322115395696297817393991218913471197221121271165841514312479855362119521884969
+1129114429442542251149132165119424383113411921471754121121214319237527583191735143212464219732392112
+1651231731856554191881141112413451251172218323241241662928111731271512822142161717213123118613613958
+4298112947145118999241658624222911212348432972424642451312255991211325333571286324481199944628374392
+2761216221111199295216838121731331169992911428481193317316457213225122995618911861614181331811151242
+4129378113472816127482433662823529814712133421698191248182391953151395229111932982436827873314521119
+1591561822112619623231519742542149141689376414216738233473231111332139316451913219341561438221397874
+3927251379311586676539123444146199319136274351291218146428138112816811112992452159548481616112158814
+9412114216661113751181221282182423133313612415161191211331589216172472359989471911138112692441934134
+2223225313925912191371119962371229122143953359523119746452516412252465926211817191299112619176196217
+1346158412389516131916991159321171727892967134931688661131511835391329289921283696234673819265582175
+1522461841192567446612342131217417151616649916394676931424334131645279316115831134257161411114339316
+2918271212143975123191492589111415816122658247911522114911751889713836923119752121583492316934222783
+2335822567917124981467893564192215151353297122123129212261122319967914112586924611514581622672125171
+5262413541889891181929911314153212728724291811815629411322228137335534214312958167399318199354579921
+9149219511885776119163152492427744911141613211121114715212251229291241137566488625114213223212151148
+1181157118724317911213711358719188263574762499564922141213462748611178379228521173951691928154154412
+3213211513627293819429164224237122932214895451454614242621317522471165136382297232654725159128311114
+4484732912114211553149811921421351313119141219414157143619532522811639911376191311111137331991152913
+1262277731165542116111282477417427466617265711322672119177456936322531711241935314283119112931271932
+8214487123411419964129118129254247918442832196374131848261379849412854112626271519928536312355117313
+1832123949338931145313411211931537496181431511219182279284211859131676523211671295264677294311151228
+1113331952811742119875195316449591311261618916825111517632719398311919141292213725149811219913814311
+2183432231291181121671961945221637251379192299935371391132618747113147599983122713361339112821364318
+1241549642129923318162112113915337861432341899721968116332321232337371311172285444693912311175852346
+6943425149126562165738742539622666221429574222528297996511562211917121698495184521192211121392891925
+3953911963215814161264113995511685544211797184319295131476823118129122192826662468114521116322441136
+6116346345651121664941991121121311413328951552314256113457889116194327118619533491348898152231235194
+1953441191249162186952321591361417162859225311123722633854535156121327211121914511731241246272342113
+7116541293114612191134544214846918511122329126131849271259313569415571115134141815215312113894888172
+2129212414488722182372398711847475194188444222531918316111338511967921142317492122141511831529112878
+7299971148111133521137477211291393539983146478512354451435418118599937354197118811351825126562471838
+3221753129222942924161143512659426819184812455272916714683133423132121128513161681618521251882367126
+7514395613933634141312211145243355553271117322417232972862411211881312311684714718127539314131613781
+3755164181884737344157241191441917282435985872268369128914871211246781489161614827272731214553141912
+1213151346851191527143987929944819185122171119431928512718341126514385311264471629211116125461472177
+7945119111919535234662132621944641673221471944118212216712891297182783944744711859271919395411258142
+2833123313293199844711314521199719361191931438661222212228993111111497111395122621712972371139939619
+4321293489656698521653282414295113191986252764513991554331562212629412621454111114271569299317726181
+3131241189731335231214319872311119789921512392816123597387128412667119915386414217195129492221913482
+7136132513132281639712311618231211268291831313425125189328161681993353119711511196639111622963441181
+4516311181565123296194779671456321611329615324411382743419111219951224135411334613154142168712942561

+ 10 - 0
aoc2021/day15_chiton/example.txt

@@ -0,0 +1,10 @@
+1163751742
+1381373672
+2136511328
+3694931569
+7463417111
+1319128137
+1359912421
+3125421639
+1293138521
+2311944581

+ 100 - 0
aoc2021/day15_chiton/input.txt

@@ -0,0 +1,100 @@
+3729872819193991183741381921327255521912952378488598118157113984111185733831264519216187279992419418
+5839825522941613758499639687561111615124625155472171543113322145452129392716221276818211881511729352
+4134729959612251917116193522113292497262149491996954282652192113892225279647399619715952115938324548
+8387823489361238911321196479271121241798431843675221612894614723199459142261892562892477475897214512
+2718311642158195471366126437626684361191984281192441149813281131372523114141737811963891392161137188
+1633716976828186977272984618799494164582512419123433193444192745176719174622119174162711842752234165
+8536196119751362771594822831112563792161411228119529921951212333211112374111122385191395119499226196
+4424317748893842284116292918291167918211295529958217188311851137241537379742135219141663113153715852
+3118475188124822611422973296416158186529284923987111664121452139411642146719148931134139633722641847
+6851934149531611188541342575162991912832471661544139732761133218933646738718723992129187399613818363
+8153996929154182715146321353713617999211911991712941292333288249481822115792643477119536793973947672
+7219715818738959216685957518194222695783428395164128457323484552944171592198421251883239713548617221
+1262715395664469179893169118711838439794991291113611518666789621183671761419168175156219311493971496
+5241795258244271119913665291444149925518231579149351154234692197423721632373259921734111194199878154
+4238919311942942962853734193142392439162389918892922614616712112651496157996572162932176861513321689
+9397215672529142519895713347129712324116226286229997859151411981342537141915625372164711292712271421
+3395998782141141719726913999455621113392579612663513951212835919421421242919833637317529711498219116
+2193481471711852229569989879692416197122721216812227229992815761918531423489811393438911922965159619
+4842769293869661728152444171799231294143174132199496274679281251135395246427174194254112411652171336
+7992213251961243149212217916322343145475259214827893275457252191114725328937222915223442914328557723
+2257187265321614694969351332168129755211199211175225132312414285271189179368149151732736998989183162
+8216159952412315973921944882311215542361211713196411468113138592199962919177359812769281129128192484
+7491712861972818586611375111891433737952336953282859622126886116519113818731197552121618979191289214
+9519299558167367473182241275151831439451481131239621792576394619881973176817252322399699919212924199
+2315922512218947577619523732973112884923978163221913621269686911182181363219113486556931341519945112
+6114115165916192895839149184894622929498814157381736592893293169135524712244127981174929812544513413
+5186913211322157317731247169519515226295142118961713817836883118248313123316421981183166894416113212
+4117695592141811484382169917655234176199986738357695382819216661977178922912172994913241815492391665
+1571136364983453162181411823855156449192935349821291922512428561912864382151915377191817265141217962
+1511291521659137275227657389911232174472896149815797911894194717839991395338952281616815662228492261
+5828649125911123147137111832461381136612461674311161311833567156151233413382644122117615261229934173
+6151177376158711154321611441522594214112311812241881211943918197935521371919719146218811223421423894
+8769116935173916741343771261675921553829389184959278736924912651794116911316749155111581161921181169
+1711211239127111911176889918113329893131982442519774356963635189623532958831392412373131996442229141
+8633897991511824191382413558492722818991942928281925122119259339589111712291922129859161986267128135
+9592118213811241524721679636318994375941713868297714991252937192511552165416131951668421172623281224
+3224967269576379116111249675581273884425919773572225149511812863246891912168591295183221461718421422
+1554432656234281738838111221231519664799394131692122691811183425679412111316991512929619825198183867
+8248994927649116365583392331561911911837163132517663179873111735733184412973866711251251838923138449
+5259211459891128167134999531169162279172418131658691816665194211521987621113113198831211278839577946
+2785766599294435194392639953157165111218825739651111991224243551822321261168277364891346786626349118
+2714176168296153336844183231182651535252463889562247241432572343373223788151338686163198268922373524
+1355199994479811117234865127578891964939314321321131179231184988525399914955371213194451337347174271
+2116691425521958741819654741947979988533162911541518281862591639174833194413595438171721318151996214
+7199413117511419274877394179775819313934612491919181143337191211418784118822152826611134757325297537
+9525471113816242245487658916222149127519318152786998981513273463154343973912519194569122512192576721
+8168293345397118811396943189777839452129229161163228361721767527622711159864283942348157872324991142
+1191859221977482194691487167621999239712994872537873851817413832133757531978721219176129127569918815
+2114592297313315112911251614298395213117958733251192212175912913123511396311931271738262121284792536
+2869919932971461318762683112553939622994172781357518899238953989332763946514119128918136121797522992
+1349359123923859364619598285283386628323357861442156348911212121163812726264112246252161153121465435
+3221714127113384432737491292891511495246829324132792729299648883264213925176172541324123571149461999
+2123452292359227318591393119291173478879314981248346349367731941746977191783914861198178388492721198
+6211151669423929481934553652811251118648971383154888223416145752294918295652137651391623141933251291
+1968199132837222725229115976261297331767978518644196281478978288879576342326944551848174958343125397
+9331187439143975289119938671749215743238865389127911933921288941828132496128811145715171716399781599
+8258695688469693682244411353746194449428433941532714551256339647221249128225651966262619631137432182
+1119815925889242989958161716735179151476111719411733228249429593464279127861485547371295945237111819
+1918941314483889391331161963259121114221361714162111171971755198331181987585351939382129399318456711
+2262369845812951662915911785311143553431911972946357841843955617392141453143811149171162189138215235
+9781738821684639758119216888999826613624827494919951411173121215253215182387663649198281989862882821
+5223471599176435949148791138949213439183587697771591962269762454282212636422227573816229614333991413
+1811857347615983396146881211143218878911161157132571218225549931871192247141659276739241119657253519
+9391116719296421398791622137739193128374551475718131458235726213387973681553419632215736219214115921
+2577296995887712122121271337118125955881125383969163187854885533588966136231227268367642651291119112
+8285247192128184472392664649591512698197881133414392149947313121191253442792749846313714931567561541
+5914998569937141423125519223543734716223412411297159869613731926111162615427219296342112996881399614
+9731617327324492677486876137627244986422232423294135291891755252141477994628216979396311119149141391
+6317494852428673391351138315428114518732111171227125466441941312854564642431811268458791719112129369
+5641722963924711738382184153391487755941992731689138293622141914971722786511194329483914836177721721
+2191711541319495518458932467456256154389594979661481111229819291398162784169185516522936311913342435
+4661927857362831214943291511527118581986618335355199294413511719841391915159192145187217776222362274
+1313423119181436167418611172917428394185995441185543711811411839751923935879331959894382314286712886
+2862378195197428119549152195162131821795674762115185761752932583827579739227163815129181532289251591
+3148183931321398349281623744934235751418141164229128288998984592191421546943449113926281979912992143
+6115611238311871526265173386221167312321173417322118912121514233272921373414511252314326187317315994
+5811391547139123152186991645788816694273223339633121964738848994167111299136891815992738119115287251
+9725141913213349381912262371128529445291223261493393657279646629881882917237532642243639121216841143
+3148319878619529254721119699214126285353918292829935411789925221122521243761861198451134393197484183
+2435892433518185918762215822812512297918145719969442131992693291494353423274863566659211899632347393
+3148114389167985389933767531929983537978116198826159249714966381987574965861944917253114237219219761
+2231321238248499915232934551158911163849872299989188311411373921315888123377868546876123317221893431
+7912151221119349216814212491382123658643142191841111739865439144111199119989819652867621232625986243
+9859438127152434312655293318611182747593379469173271121766249593771491955721156621892496492641213444
+4929938238912922229422954293129124132372163439223878142913281213986317472199131824363419139431219311
+1968711715383961221294128819426217422912365715915298613143986568719211322631198568127732915271881651
+1239331149933523962637128912698656291169897151994262819396381113789171724783976127346481695985869225
+5289966393551655752114812379691166211454531182299813127121156612915235229222218314795665421111633258
+3127918537891332228227411221581128459148111972112426655116663413129719191831523473352344966511991919
+8512892492529735512912187137642211534129682216299596715181914732116586298727395149931114125495922665
+2113381417361993148552393738241411426473221311118675228881719381122349492151915996115916113761769471
+1193331211133269118281192734513221196629614542378821919122127511913582111219462941913911592896921567
+1928839511249353121114797115153112412181184939817233951399211343292439385522184128815982824112251117
+2827119576811541383193518515431343378695916957871431921151853841937126894841832535928653198383218118
+1323643111222957224134137112939211788117112179862952393114148713251912769398353381195595723195928165
+8579198914969811424799274417548281918819941211372431422234999171533811523538112681312838314493612252
+9375681881414251511777522314895223498189769112441916199178382117741713498857163298814216928591589821
+3232841129939327192792126115197721144739941873884315514136993422182184312983669392631413116981372991
+9391291341187851374493262858523912451129322182139437634233926139214699174658694128513176871491776159
+1962692319292956392768329433119198234612213218634341969199512619382115112923378297838795174731871477

+ 96 - 0
aoc2021/day15_chiton/main.py

@@ -0,0 +1,96 @@
+import os, sys
+import numpy as np
+from queue import PriorityQueue
+from collections import defaultdict, deque
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, check_example, generate_readme
+
+
+def get_dirs(center, i_size, j_size):
+    i, j = center
+    up = max(0, i - 1), j
+    left = i, max(0, j - 1)
+    down = min(i + 1, i_size), j
+    right = i, min(j_size, j + 1)
+    return up, left, down, right
+
+
+def dijkstra(G, start=(0, 0), end=False, pq=True, star=False):
+    i_s, j_s = G.shape[0] - 1, G.shape[1] - 1
+    end = (i_s, j_s) if not end else end
+    parents = {}
+    q = PriorityQueue() if pq else deque()
+    nodeCosts = defaultdict(lambda: float("inf"))
+    nodeCosts[start] = 0
+    if pq:
+        q.put((0, start))
+    else:
+        q.append((0, start))
+
+    def get_path(node):
+        path = []
+        while node != start:
+            path.append(node)
+            node = parents[node]
+        path.append(start)
+        return path[::-1]
+
+    def estimate(end, node):
+        return abs(end[0] - node[0]) + abs(end[1] - node[1])
+
+    acc = 0
+    while (q.qsize() if pq else len(q)) != 0:
+        acc += 1
+        _, node = q.get() if pq else q.popleft()
+        if pq and node == end:
+            print("With early stop!", acc)
+            return get_path(node), nodeCosts[node]
+        for adjNode in get_dirs(node, i_s, j_s):
+            newCost = nodeCosts[node] + G[adjNode]
+            if nodeCosts[adjNode] > newCost:
+                parents[adjNode] = node
+                nodeCosts[adjNode] = newCost
+                if star:
+                    newCost += estimate(end, adjNode)
+                if pq:
+                    q.put((newCost, adjNode))
+                else:
+                    q.append((newCost, adjNode))
+    return get_path(end), nodeCosts[end]
+
+
+def part1(input: list[str], verbose=True):
+    ceiling = np.array([list(line) for line in input], dtype=int)
+    _, cost = dijkstra(ceiling)
+    if verbose:
+        print("The answer of part1 is:", cost)
+
+
+def part2(input: list[str], pq=True, star=False, verbose=True):
+    ceiling = np.array([list(line) for line in input], dtype=int)
+    full_ceiling = ceiling.copy()
+    for step in range(1, 5):
+        left_ceiling = ceiling + step
+        left_ceiling[left_ceiling > 9] -= 9
+        full_ceiling = np.hstack([full_ceiling, left_ceiling])
+    line_ceiling = full_ceiling.copy()
+    for step in range(1, 5):
+        down_ceiling = line_ceiling + step
+        down_ceiling[down_ceiling > 9] -= 9
+        full_ceiling = np.vstack([full_ceiling, down_ceiling])
+    _, cost = dijkstra(full_ceiling, pq=pq, star=star)
+    if verbose:
+        print("The answer of part2 is:", cost)
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 15)
+
+    check_example(example, part1)
+    check_example(example, part2)
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 15)

+ 171 - 0
aoc2021/day16_packet_decoder/README.md

@@ -0,0 +1,171 @@
+--- Day 16: Packet Decoder ---
+------------------------------
+
+As you leave the cave and reach open waters, you receive a transmission from the Elves back on the ship.
+
+
+The transmission was sent using the Buoyancy Interchange Transmission System (BITS), a method of packing numeric expressions into a binary sequence. Your submarine's computer has saved the transmission in [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) (your puzzle input).
+
+
+The first step of decoding the message is to convert the hexadecimal representation into binary. Each character of hexadecimal corresponds to four bits of binary data:
+
+
+
+```
+0 = 0000
+1 = 0001
+2 = 0010
+3 = 0011
+4 = 0100
+5 = 0101
+6 = 0110
+7 = 0111
+8 = 1000
+9 = 1001
+A = 1010
+B = 1011
+C = 1100
+D = 1101
+E = 1110
+F = 1111
+
+```
+
+The BITS transmission contains a single *packet* at its outermost layer which itself contains many other packets. The hexadecimal representation of this packet might encode a few extra `0` bits at the end; these are not part of the transmission and should be ignored.
+
+
+Every packet begins with a standard header: the first three bits encode the packet *version*, and the next three bits encode the packet *type ID*. These two values are numbers; all numbers encoded in any packet are represented as binary with the most significant bit first. For example, a version encoded as the binary sequence `100` represents the number `4`.
+
+
+Packets with type ID `4` represent a *literal value*. Literal value packets encode a single binary number. To do this, the binary number is padded with leading zeroes until its length is a multiple of four bits, and then it is broken into groups of four bits. Each group is prefixed by a `1` bit except the last group, which is prefixed by a `0` bit. These groups of five bits immediately follow the packet header. For example, the hexadecimal string `D2FE28` becomes:
+
+
+
+```
+110100101111111000101000
+VVVTTTAAAAABBBBBCCCCC
+
+```
+
+Below each bit is a label indicating its purpose:
+
+
+* The three bits labeled `V` (`110`) are the packet version, `6`.
+* The three bits labeled `T` (`100`) are the packet type ID, `4`, which means the packet is a literal value.
+* The five bits labeled `A` (`10111`) start with a `1` (not the last group, keep reading) and contain the first four bits of the number, `0111`.
+* The five bits labeled `B` (`11110`) start with a `1` (not the last group, keep reading) and contain four more bits of the number, `1110`.
+* The five bits labeled `C` (`00101`) start with a `0` (last group, end of packet) and contain the last four bits of the number, `0101`.
+* The three unlabeled `0` bits at the end are extra due to the hexadecimal representation and should be ignored.
+
+
+So, this packet represents a literal value with binary representation `011111100101`, which is `2021` in decimal.
+
+
+Every other type of packet (any packet with a type ID other than `4`) represent an *operator* that performs some calculation on one or more sub-packets contained within. Right now, the specific operations aren't important; focus on parsing the hierarchy of sub-packets.
+
+
+An operator packet contains one or more packets. To indicate which subsequent binary data represents its sub-packets, an operator packet can use one of two modes indicated by the bit immediately after the packet header; this is called the *length type ID*:
+
+
+* If the length type ID is `0`, then the next *15* bits are a number that represents the *total length in bits* of the sub-packets contained by this packet.
+* If the length type ID is `1`, then the next *11* bits are a number that represents the *number of sub-packets immediately contained* by this packet.
+
+
+Finally, after the length type ID bit and the 15-bit or 11-bit field, the sub-packets appear.
+
+
+For example, here is an operator packet (hexadecimal string `38006F45291200`) with length type ID `0` that contains two sub-packets:
+
+
+
+```
+00111000000000000110111101000101001010010001001000000000
+VVVTTTILLLLLLLLLLLLLLLAAAAAAAAAAABBBBBBBBBBBBBBBB
+
+```
+
+* The three bits labeled `V` (`001`) are the packet version, `1`.
+* The three bits labeled `T` (`110`) are the packet type ID, `6`, which means the packet is an operator.
+* The bit labeled `I` (`0`) is the length type ID, which indicates that the length is a 15-bit number representing the number of bits in the sub-packets.
+* The 15 bits labeled `L` (`000000000011011`) contain the length of the sub-packets in bits, `27`.
+* The 11 bits labeled `A` contain the first sub-packet, a literal value representing the number `10`.
+* The 16 bits labeled `B` contain the second sub-packet, a literal value representing the number `20`.
+
+
+After reading 11 and 16 bits of sub-packet data, the total length indicated in `L` (27) is reached, and so parsing of this packet stops.
+
+
+As another example, here is an operator packet (hexadecimal string `EE00D40C823060`) with length type ID `1` that contains three sub-packets:
+
+
+
+```
+11101110000000001101010000001100100000100011000001100000
+VVVTTTILLLLLLLLLLLAAAAAAAAAAABBBBBBBBBBBCCCCCCCCCCC
+
+```
+
+* The three bits labeled `V` (`111`) are the packet version, `7`.
+* The three bits labeled `T` (`011`) are the packet type ID, `3`, which means the packet is an operator.
+* The bit labeled `I` (`1`) is the length type ID, which indicates that the length is a 11-bit number representing the number of sub-packets.
+* The 11 bits labeled `L` (`00000000011`) contain the number of sub-packets, `3`.
+* The 11 bits labeled `A` contain the first sub-packet, a literal value representing the number `1`.
+* The 11 bits labeled `B` contain the second sub-packet, a literal value representing the number `2`.
+* The 11 bits labeled `C` contain the third sub-packet, a literal value representing the number `3`.
+
+
+After reading 3 complete sub-packets, the number of sub-packets indicated in `L` (3) is reached, and so parsing of this packet stops.
+
+
+For now, parse the hierarchy of the packets throughout the transmission and *add up all of the version numbers*.
+
+
+Here are a few more examples of hexadecimal-encoded transmissions:
+
+
+* `8A004A801A8002F478` represents an operator packet (version 4) which contains an operator packet (version 1) which contains an operator packet (version 5) which contains a literal value (version 6); this packet has a version sum of `*16*`.
+* `620080001611562C8802118E34` represents an operator packet (version 3) which contains two sub-packets; each sub-packet is an operator packet that contains two literal values. This packet has a version sum of `*12*`.
+* `C0015000016115A2E0802F182340` has the same structure as the previous example, but the outermost packet uses a different length type ID. This packet has a version sum of `*23*`.
+* `A0016C880162017C3686B18A3D4780` is an operator packet that contains an operator packet that contains an operator packet that contains five literal values; it has a version sum of `*31*`.
+
+
+Decode the structure of your hexadecimal-encoded BITS transmission; *what do you get if you add up the version numbers in all packets?*
+
+
+--- Part Two ---
+----------------
+
+Now that you have the structure of your transmission decoded, you can calculate the value of the expression it represents.
+
+
+Literal values (type ID `4`) represent a single number as described above. The remaining type IDs are more interesting:
+
+
+* Packets with type ID `0` are *sum* packets - their value is the sum of the values of their sub-packets. If they only have a single sub-packet, their value is the value of the sub-packet.
+* Packets with type ID `1` are *product* packets - their value is the result of multiplying together the values of their sub-packets. If they only have a single sub-packet, their value is the value of the sub-packet.
+* Packets with type ID `2` are *minimum* packets - their value is the minimum of the values of their sub-packets.
+* Packets with type ID `3` are *maximum* packets - their value is the maximum of the values of their sub-packets.
+* Packets with type ID `5` are *greater than* packets - their value is *1* if the value of the first sub-packet is greater than the value of the second sub-packet; otherwise, their value is *0*. These packets always have exactly two sub-packets.
+* Packets with type ID `6` are *less than* packets - their value is *1* if the value of the first sub-packet is less than the value of the second sub-packet; otherwise, their value is *0*. These packets always have exactly two sub-packets.
+* Packets with type ID `7` are *equal to* packets - their value is *1* if the value of the first sub-packet is equal to the value of the second sub-packet; otherwise, their value is *0*. These packets always have exactly two sub-packets.
+
+
+Using these rules, you can now work out the value of the outermost packet in your BITS transmission.
+
+
+For example:
+
+
+* `C200B40A82` finds the sum of `1` and `2`, resulting in the value `*3*`.
+* `04005AC33890` finds the product of `6` and `9`, resulting in the value `*54*`.
+* `880086C3E88112` finds the minimum of `7`, `8`, and `9`, resulting in the value `*7*`.
+* `CE00C43D881120` finds the maximum of `7`, `8`, and `9`, resulting in the value `*9*`.
+* `D8005AC2A8F0` produces `1`, because `5` is less than `15`.
+* `F600BC2D8F` produces `0`, because `5` is not greater than `15`.
+* `9C005AC2F8F0` produces `0`, because `5` is not equal to `15`.
+* `9C0141080250320F1802104A08` produces `1`, because `1` + `3` = `2` * `2`.
+
+
+*What do you get if you evaluate the expression represented by your hexadecimal-encoded BITS transmission?*
+
+

+ 15 - 0
aoc2021/day16_packet_decoder/example.txt

@@ -0,0 +1,15 @@
+D2FE28
+38006F45291200
+EE00D40C823060
+8A004A801A8002F478
+620080001611562C8802118E34
+C0015000016115A2E0802F182340
+A0016C880162017C3686B18A3D4780
+C200B40A82
+04005AC33890
+880086C3E88112
+CE00C43D881120
+D8005AC2A8F0
+F600BC2D8F
+9C005AC2F8F0
+9C0141080250320F1802104A08

+ 1 - 0
aoc2021/day16_packet_decoder/input.txt

@@ -0,0 +1 @@
+420D610055D273AF1630010092019207300B278BE5932551E703E608400C335003900AF0402905009923003880856201E95C00B60198D400B50034400E20101DC00E10024C00F1003C400B000212697140249D049F0F8952A8C6009780272D5D074B5741F3F37730056C0149658965E9AED7CA8401A5CC45BB801F0999FFFEEE0D67050C010C0036278A62D4D737F359993398027800BECFD8467E3109945C1008210C9C442690A6F719C48A351006E9359C1C5003E739087E80F27EC29A0030322BD2553983D272C67508E5C0804639D4BD004C401B8B918E3600021D1061D47A30053801C89EF2C4CCFF39204C53C212DABED04C015983A9766200ACE7F95C80D802B2F3499E5A700267838803029FC56203A009CE134C773A2D3005A77F4EDC6B401600043A35C56840200F4668A71580043D92D5A02535BAF7F9A89CF97C9F59A4F02C400C249A8CF1A49331004CDA00ACA46517E8732E8D2DB90F3005E92362194EF5E630CA5E5EEAD1803E200CC228E70700010A89D0BE3A08033146164177005A5AEEB1DA463BDC667600189C9F53A6FF6D6677954B27745CA00BCAE53A6EEDC60074C920001B93CFB05140289E8FA4812E071EE447218CBE1AA149008DBA00A497F9486262325FE521898BC9669B382015365715953C5FC01AA8002111721D4221007E13C448BA600B4F77F694CE6C01393519CE474D46009D802C00085C578A71E4001098F518639CC301802B400E7CDDF4B525C8E9CA2188032600E44B8F1094C0198CB16A29180351EA1DC3091F47A5CA0054C4234BDBC2F338A77B84F201232C01700042A0DC7A8A0200CC578B10A65A000601048B24B25C56995A30056C013927D927C91AB43005D127FDC610EF55273F76C96641002A4F0F8C01CCC579A8D68E52587F982996F537D600

+ 100 - 0
aoc2021/day16_packet_decoder/main.py

@@ -0,0 +1,100 @@
+import os, sys
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from math import prod
+from get_tasks import get_input, generate_readme, check_example
+
+
+
+def read_litval():
+    global cur
+    blitval = ""
+    while b[cur : cur + 1] == "1":
+        cur += 1
+        blitval += b[cur : cur + 4]
+        cur += 4
+    cur += 1
+    blitval += b[cur : cur + 4]
+    cur += 4
+    litval = int(blitval, 2)
+    return litval
+
+
+def read_header():
+    global typeID, packver, cur
+    packver = int(b[cur : cur + 3], 2)
+    cur += 3
+    typeID = int(b[cur : cur + 3], 2)
+    cur += 3
+
+def read_op():
+    global cur
+    litsub = []
+    if b[cur] == "0":
+        cur += 1
+        nbits = int(b[cur : cur + 15], 2)
+        cur += 15
+        end_subpackets = cur + nbits
+        while cur != end_subpackets:
+            litsub += [parse_block()]
+        return litsub
+    else:
+        cur += 1
+        npacks = int(b[cur : cur + 11], 2)
+        cur += 11
+        n = 0
+        while n != npacks:
+            n += 1
+            litsub += [parse_block()]
+        return litsub
+
+def parse_block():
+    global typeID, cur, sumpackver, sumval
+    read_header()
+    sumpackver += packver
+    match typeID:
+        case 4: return read_litval()
+        case 0: return sum(read_op())
+        case 1: return prod(read_op())
+        case 2: return min(read_op())
+        case 3: return max(read_op())
+        case 5: subs = read_op(); return 1 if subs[0] > subs[1] else 0
+        case 6: subs = read_op(); return 1 if subs[0] < subs[1] else 0
+        case 7: subs = read_op(); return 1 if subs[0] == subs[1] else 0
+
+def part1(input, verbose=True):
+    global b, cur, sumpackver
+    cur = 0
+    sumpackver = 0
+    packet = input[0]
+    b = bin(int(packet, 16))[2:].zfill(len(packet)*4)
+    parse_block()
+    if verbose:
+        print("The answer of part1 is:", sumpackver)
+    
+def part2(input, verbose=True):
+    global b, cur, sumpackver
+    cur = 0
+    sumpackver = 0
+    packet = input[0]
+    b = bin(int(packet, 16))[2:].zfill(len(packet)*4)
+    val = parse_block()
+    if verbose:
+        print("The answer of part1 is:", val)
+
+if __name__ == "__main__":
+    
+    input, example = get_input(task_dir, 16)
+
+    print("PART1")
+    for packet in example[3:7]:
+        check_example([packet], part1)
+    print("PART2")
+    for packet in example[7:]:
+        check_example([packet], part2)
+    
+    part1(input)
+    part2(input)
+    
+    generate_readme(task_dir, 16)

+ 17 - 0
aoc2021/day17_trick_shot/Cargo.toml

@@ -0,0 +1,17 @@
+[package]
+name = "day17_trick_shot"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+regex = "1.5"
+
+
+[dev-dependencies]
+criterion = "0.3"
+
+[[bench]]
+name = "my_bench"
+harness = false

+ 177 - 0
aoc2021/day17_trick_shot/README.md

@@ -0,0 +1,177 @@
+--- Day 17: Trick Shot ---
+--------------------------
+
+You finally decode the Elves' message. `HI`, the message says. You continue searching for the sleigh keys.
+
+
+Ahead of you is what appears to be a large [ocean trench](https://en.wikipedia.org/wiki/Oceanic_trench). Could the keys have fallen into it? You'd better send a probe to investigate.
+
+
+The probe launcher on your submarine can fire the probe with any [integer](https://en.wikipedia.org/wiki/Integer) velocity in the `x` (forward) and `y` (upward, or downward if negative) directions. For example, an initial `x,y` velocity like `0,10` would fire the probe straight up, while an initial velocity like `10,-1` would fire the probe forward at a slight downward angle.
+
+
+The probe's `x,y` position starts at `0,0`. Then, it will follow some trajectory by moving in *steps*. On each step, these changes occur in the following order:
+
+
+* The probe's `x` position increases by its `x` velocity.
+* The probe's `y` position increases by its `y` velocity.
+* Due to drag, the probe's `x` velocity changes by `1` toward the value `0`; that is, it decreases by `1` if it is greater than `0`, increases by `1` if it is less than `0`, or does not change if it is already `0`.
+* Due to gravity, the probe's `y` velocity decreases by `1`.
+
+
+For the probe to successfully make it into the trench, the probe must be on some trajectory that causes it to be within a *target area* after any step. The submarine computer has already calculated this target area (your puzzle input). For example:
+
+
+
+```
+target area: x=20..30, y=-10..-5
+```
+
+This target area means that you need to find initial `x,y` velocity values such that after any step, the probe's `x` position is at least `20` and at most `30`, *and* the probe's `y` position is at least `-10` and at most `-5`.
+
+
+Given this target area, one initial velocity that causes the probe to be within the target area after any step is `7,2`:
+
+
+
+```
+.............#....#............
+.......#..............#........
+...............................
+S........................#.....
+...............................
+...............................
+...........................#...
+...............................
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................TTTTTTTT#TT
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+
+```
+
+In this diagram, `S` is the probe's initial position, `0,0`. The `x` coordinate increases to the right, and the `y` coordinate increases upward. In the bottom right, positions that are within the target area are shown as `T`. After each step (until the target area is reached), the position of the probe is marked with `#`. (The bottom-right `#` is both a position the probe reaches and a position in the target area.)
+
+
+Another initial velocity that causes the probe to be within the target area after any step is `6,3`:
+
+
+
+```
+...............#..#............
+...........#........#..........
+...............................
+......#..............#.........
+...............................
+...............................
+S....................#.........
+...............................
+...............................
+...............................
+.....................#.........
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................T#TTTTTTTTT
+....................TTTTTTTTTTT
+
+```
+
+Another one is `9,0`:
+
+
+
+```
+S........#.....................
+.................#.............
+...............................
+........................#......
+...............................
+....................TTTTTTTTTTT
+....................TTTTTTTTTT#
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+....................TTTTTTTTTTT
+
+```
+
+One initial velocity that *doesn't* cause the probe to be within the target area after any step is `17,-4`:
+
+
+
+```
+S..............................................................
+...............................................................
+...............................................................
+...............................................................
+.................#.............................................
+....................TTTTTTTTTTT................................
+....................TTTTTTTTTTT................................
+....................TTTTTTTTTTT................................
+....................TTTTTTTTTTT................................
+....................TTTTTTTTTTT..#.............................
+....................TTTTTTTTTTT................................
+...............................................................
+...............................................................
+...............................................................
+...............................................................
+................................................#..............
+...............................................................
+...............................................................
+...............................................................
+...............................................................
+...............................................................
+...............................................................
+..............................................................#
+
+```
+
+The probe appears to pass through the target area, but is never within it after any step. Instead, it continues down and to the right - only the first few steps are shown.
+
+
+If you're going to fire a highly scientific probe out of a super cool probe launcher, you might as well do it with *style*. How high can you make the probe go while still reaching the target area?
+
+
+In the above example, using an initial velocity of `6,9` is the best you can do, causing the probe to reach a maximum `y` position of `*45*`. (Any higher initial `y` velocity causes the probe to overshoot the target area entirely.)
+
+
+Find the initial velocity that causes the probe to reach the highest `y` position and still eventually be within the target area after any step. *What is the highest `y` position it reaches on this trajectory?*
+
+
+--- Part Two ---
+----------------
+
+Maybe a fancy trick shot isn't the best idea; after all, you only have one probe, so you had better not miss.
+
+
+To get the best idea of what your options are for launching the probe, you need to find *every initial velocity* that causes the probe to eventually be within the target area after any step.
+
+
+In the above example, there are `*112*` different initial velocity values that meet these criteria:
+
+
+
+```
+23,-10  25,-9   27,-5   29,-6   22,-6   21,-7   9,0     27,-7   24,-5
+25,-7   26,-6   25,-5   6,8     11,-2   20,-5   29,-10  6,3     28,-7
+8,0     30,-6   29,-8   20,-10  6,7     6,4     6,1     14,-4   21,-6
+26,-10  7,-1    7,7     8,-1    21,-9   6,2     20,-7   30,-10  14,-3
+20,-8   13,-2   7,3     28,-8   29,-9   15,-3   22,-5   26,-8   25,-8
+25,-6   15,-4   9,-2    15,-2   12,-2   28,-9   12,-3   24,-6   23,-7
+25,-10  7,8     11,-3   26,-7   7,1     23,-9   6,0     22,-10  27,-6
+8,1     22,-8   13,-4   7,6     28,-6   11,-4   12,-4   26,-9   7,4
+24,-10  23,-8   30,-8   7,0     9,-1    10,-1   26,-5   22,-9   6,5
+7,5     23,-6   28,-10  10,-2   11,-1   20,-9   14,-2   29,-7   13,-3
+23,-5   24,-8   27,-9   30,-7   28,-5   21,-10  7,9     6,6     21,-5
+27,-10  7,2     30,-9   21,-8   22,-7   24,-9   20,-6   6,9     29,-5
+8,-2    27,-8   30,-5   24,-7
+
+```
+
+*How many distinct initial velocity values cause the probe to be within the target area after any step?*
+
+

+ 10 - 0
aoc2021/day17_trick_shot/benches/my_bench.rs

@@ -0,0 +1,10 @@
+extern crate day17_trick_shot;
+use day17_trick_shot as day17;
+use criterion::{criterion_group, criterion_main, Criterion};
+
+fn ben(c: &mut Criterion) {
+    c.bench_function("day17", |b| b.iter(|| day17::main()));
+}
+
+criterion_group!(benches, ben);
+criterion_main!(benches);

+ 1 - 0
aoc2021/day17_trick_shot/example.txt

@@ -0,0 +1 @@
+target area: x=20..30, y=-10..-5

+ 1 - 0
aoc2021/day17_trick_shot/input.txt

@@ -0,0 +1 @@
+target area: x=169..206, y=-108..-68

+ 55 - 0
aoc2021/day17_trick_shot/main.py

@@ -0,0 +1,55 @@
+from doctest import Example
+import os, sys, re
+task_dir = os.path.dirname(__file__)
+sys.path.append(f'{task_dir}/..')
+from get_tasks import get_input, generate_readme, check_example
+
+def hit(position, target):
+    x, y = position
+    x1, x2, y1, y2 = target
+    return True if x <= x2 and x >= x1 and y >= y1 and y <= y2 else False
+
+def launch_prob(target):
+    succes = {}
+    succes_init_velocity = []
+    for i in range(1, target[1]+1):
+        for j in range(target[2], -target[2]):
+            init_velocity = i, j
+            hor, ver = i, j
+            hy = 0
+            x, y  = 0, 0
+            while not (apple := hit((x, y), target)):
+                py = y
+                x += hor; y += ver
+                if py > y and hy == 0: hy = py
+                if hor < 0: hor += 1
+                elif hor > 0: hor -= 1
+                else: pass
+                ver -= 1
+                if (x > target[1]) or (y < target[2]): break
+            if apple: 
+                succes[hy] = init_velocity
+                succes_init_velocity.append(init_velocity)
+    return succes, succes_init_velocity
+
+def part1(input: list[str]):
+    target = [int(c) for c in re.findall('-?\d+', input[0])]
+    hy, _ = launch_prob(target)
+    print("The answer of part1 is:", max(hy))
+    
+def part2(input: list[str]):
+    target = [int(c) for c in re.findall('-?\d+', input[0])]
+    _, v = launch_prob(target)
+    print("The answer of part1 is:", len(v))
+    
+    
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 17)
+    
+    check_example(example, part1)
+    check_example(example, part2)
+    
+    part1(input)
+    part2(input)
+    
+    generate_readme(task_dir, 17)

+ 52 - 0
aoc2021/day17_trick_shot/src/lib.rs

@@ -0,0 +1,52 @@
+#![allow(dead_code)]
+#![allow(unused_variables)]
+use regex::Regex;
+
+#[inline]
+pub fn main() {
+    let reg = Regex::new(r"-?\d+").unwrap();
+    let target: Vec<i32> = reg
+        .captures_iter(&include_str!("../input.txt"))
+        .map(|x| x.get(0).unwrap().as_str().parse().unwrap())
+        .collect();
+    let (a, b) = launch_prob(target);
+}
+
+fn launch_prob(target: Vec<i32>) -> (i32, Vec<i32>) {
+    let [x1, x2, y1, y2] = <[i32; 4]>::try_from(target).ok().unwrap();
+    let mut acc = 0;
+    let mut maxy = Vec::new();
+    for i in 1..x2 + 1 {
+        for j in y1..-y1 {
+            let mut hor = i;
+            let mut ver = j;
+            let mut hy = 0;
+            let mut x = 0;
+            let mut y = 0;
+            while !(x <= x2 && x >= x1 && y >= y1 && y <= y2) {
+                let py = y;
+                x += hor;
+                y += ver;
+                if py > y && hy == 0 {
+                    hy = py;
+                };
+                ver -= 1;
+                if hor < 0 {
+                    hor += 1;
+                } else if hor > 0 {
+                    hor -= 1;
+                } else {
+                    hor = 0;
+                }
+                if x >= x2 || y <= y1 {
+                    break;
+                }
+            }
+            if x <= x2 && x >= x1 && y >= y1 && y <= y2 {
+                acc += 1;
+                maxy.push(hy);
+            }
+        }
+    }
+    return (acc, maxy);
+}

+ 53 - 0
aoc2021/day17_trick_shot/src/main.rs

@@ -0,0 +1,53 @@
+#![allow(dead_code)]
+#![allow(unused_variables)]
+use regex::Regex;
+
+fn main() {
+    let reg = Regex::new(r"-?\d+").unwrap();
+    let target: Vec<i32> = reg
+        .captures_iter(&include_str!("../input.txt"))
+        .map(|x| x.get(0).unwrap().as_str().parse().unwrap())
+        .collect();
+    let (a, b) = launch_prob(target);
+    println!("Part1 {:?}, Part2 {:?}", a, b.iter().max().unwrap())
+}
+
+fn launch_prob(target: Vec<i32>) -> (i32, Vec<i32>) {
+    let [x1, x2, y1, y2] = <[i32; 4]>::try_from(target).ok().unwrap();
+    println!("Target {:?}", (x1,x2,y1,y2));
+    let mut acc = 0;
+    let mut maxy = Vec::new();
+    for i in 1..x2+1 {
+        for j in y1..-y1 {
+            let mut hor = i;
+            let mut ver = j;
+            let mut hy = 0;
+            let mut x = 0;
+            let mut y = 0;
+            while !(x <= x2 && x >= x1 && y >= y1 && y <= y2){
+                let py = y;
+                x += hor;
+                y += ver;
+                if py > y && hy == 0 {
+                    hy = py;
+                    };
+                ver -= 1;
+                if hor < 0 {
+                    hor += 1;
+                } else if hor > 0 {
+                    hor -= 1;
+                } else {
+                    hor = 0;
+                }               
+                if x >= x2 || y <= y1  {
+                    break;
+                }
+            }
+            if x <= x2 && x >= x1 && y >= y1 && y <= y2 {
+                acc += 1;
+                maxy.push(hy);
+            }
+        }
+    }
+    return (acc, maxy);
+}

+ 264 - 0
aoc2021/day18_snailfish/README.md

@@ -0,0 +1,264 @@
+--- Day 18: Snailfish ---
+-------------------------
+
+You descend into the ocean trench and encounter some [snailfish](https://en.wikipedia.org/wiki/Snailfish). They say they saw the sleigh keys! They'll even tell you which direction the keys went if you help one of the smaller snailfish with his *math homework*.
+
+
+Snailfish numbers aren't like regular numbers. Instead, every snailfish number is a *pair* - an ordered list of two elements. Each element of the pair can be either a regular number or another pair.
+
+
+Pairs are written as `[x,y]`, where `x` and `y` are the elements within the pair. Here are some example snailfish numbers, one snailfish number per line:
+
+
+
+```
+[1,2]
+[[1,2],3]
+[9,[8,7]]
+[[1,9],[8,5]]
+[[[[1,2],[3,4]],[[5,6],[7,8]]],9]
+[[[9,[3,8]],[[0,9],6]],[[[3,7],[4,9]],3]]
+[[[[1,3],[5,3]],[[1,3],[8,7]]],[[[4,9],[6,9]],[[8,2],[7,3]]]]
+
+```
+
+This snailfish homework is about *addition*. To add two snailfish numbers, form a pair from the left and right parameters of the addition operator. For example, `[1,2]` + `[[3,4],5]` becomes `[[1,2],[[3,4],5]]`.
+
+
+There's only one problem: *snailfish numbers must always be reduced*, and the process of adding two snailfish numbers can result in snailfish numbers that need to be reduced.
+
+
+To *reduce a snailfish number*, you must repeatedly do the first action in this list that applies to the snailfish number:
+
+
+* If any pair is *nested inside four pairs*, the leftmost such pair *explodes*.
+* If any regular number is *10 or greater*, the leftmost such regular number *splits*.
+
+
+Once no action in the above list applies, the snailfish number is reduced.
+
+
+During reduction, at most one action applies, after which the process returns to the top of the list of actions. For example, if *split* produces a pair that meets the *explode* criteria, that pair *explodes* before other *splits* occur.
+
+
+To *explode* a pair, the pair's left value is added to the first regular number to the left of the exploding pair (if any), and the pair's right value is added to the first regular number to the right of the exploding pair (if any). Exploding pairs will always consist of two regular numbers. Then, the entire exploding pair is replaced with the regular number `0`.
+
+
+Here are some examples of a single explode action:
+
+
+* `[[[[*[9,8]*,1],2],3],4]` becomes `[[[[*0*,*9*],2],3],4]` (the `9` has no regular number to its left, so it is not added to any regular number).
+* `[7,[6,[5,[4,*[3,2]*]]]]` becomes `[7,[6,[5,[*7*,*0*]]]]` (the `2` has no regular number to its right, and so it is not added to any regular number).
+* `[[6,[5,[4,*[3,2]*]]],1]` becomes `[[6,[5,[*7*,*0*]]],*3*]`.
+* `[[3,[2,[1,*[7,3]*]]],[6,[5,[4,[3,2]]]]]` becomes `[[3,[2,[*8*,*0*]]],[*9*,[5,[4,[3,2]]]]]` (the pair `[3,2]` is unaffected because the pair `[7,3]` is further to the left; `[3,2]` would explode on the next action).
+* `[[3,[2,[8,0]]],[9,[5,[4,*[3,2]*]]]]` becomes `[[3,[2,[8,0]]],[9,[5,[*7*,*0*]]]]`.
+
+
+To *split* a regular number, replace it with a pair; the left element of the pair should be the regular number divided by two and rounded *down*, while the right element of the pair should be the regular number divided by two and rounded *up*. For example, `10` becomes `[5,5]`, `11` becomes `[5,6]`, `12` becomes `[6,6]`, and so on.
+
+
+Here is the process of finding the reduced result of `[[[[4,3],4],4],[7,[[8,4],9]]]` + `[1,1]`:
+
+
+
+```
+after addition: [[[[*[4,3]*,4],4],[7,[[8,4],9]]],[1,1]]
+after explode:  [[[[0,7],4],[7,[*[8,4]*,9]]],[1,1]]
+after explode:  [[[[0,7],4],[*15*,[0,13]]],[1,1]]
+after split:    [[[[0,7],4],[[7,8],[0,*13*]]],[1,1]]
+after split:    [[[[0,7],4],[[7,8],[0,*[6,7]*]]],[1,1]]
+after explode:  [[[[0,7],4],[[7,8],[6,0]]],[8,1]]
+
+```
+
+Once no reduce actions apply, the snailfish number that remains is the actual result of the addition operation: `[[[[0,7],4],[[7,8],[6,0]]],[8,1]]`.
+
+
+The homework assignment involves adding up a *list of snailfish numbers* (your puzzle input). The snailfish numbers are each listed on a separate line. Add the first snailfish number and the second, then add that result and the third, then add that result and the fourth, and so on until all numbers in the list have been used once.
+
+
+For example, the final sum of this list is `[[[[1,1],[2,2]],[3,3]],[4,4]]`:
+
+
+
+```
+[1,1]
+[2,2]
+[3,3]
+[4,4]
+
+```
+
+The final sum of this list is `[[[[3,0],[5,3]],[4,4]],[5,5]]`:
+
+
+
+```
+[1,1]
+[2,2]
+[3,3]
+[4,4]
+[5,5]
+
+```
+
+The final sum of this list is `[[[[5,0],[7,4]],[5,5]],[6,6]]`:
+
+
+
+```
+[1,1]
+[2,2]
+[3,3]
+[4,4]
+[5,5]
+[6,6]
+
+```
+
+Here's a slightly larger example:
+
+
+
+```
+[[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]]
+[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]
+[[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]]
+[[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]]
+[7,[5,[[3,8],[1,4]]]]
+[[2,[2,2]],[8,[8,1]]]
+[2,9]
+[1,[[[9,3],9],[[9,0],[0,7]]]]
+[[[5,[7,4]],7],1]
+[[[[4,2],2],6],[8,7]]
+
+```
+
+The final sum `[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]` is found after adding up the above snailfish numbers:
+
+
+
+```
+  [[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]]
++ [7,[[[3,7],[4,3]],[[6,3],[8,8]]]]
+= [[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]]
+
+  [[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]]
++ [[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]]
+= [[[[6,7],[6,7]],[[7,7],[0,7]]],[[[8,7],[7,7]],[[8,8],[8,0]]]]
+
+  [[[[6,7],[6,7]],[[7,7],[0,7]]],[[[8,7],[7,7]],[[8,8],[8,0]]]]
++ [[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]]
+= [[[[7,0],[7,7]],[[7,7],[7,8]]],[[[7,7],[8,8]],[[7,7],[8,7]]]]
+
+  [[[[7,0],[7,7]],[[7,7],[7,8]]],[[[7,7],[8,8]],[[7,7],[8,7]]]]
++ [7,[5,[[3,8],[1,4]]]]
+= [[[[7,7],[7,8]],[[9,5],[8,7]]],[[[6,8],[0,8]],[[9,9],[9,0]]]]
+
+  [[[[7,7],[7,8]],[[9,5],[8,7]]],[[[6,8],[0,8]],[[9,9],[9,0]]]]
++ [[2,[2,2]],[8,[8,1]]]
+= [[[[6,6],[6,6]],[[6,0],[6,7]]],[[[7,7],[8,9]],[8,[8,1]]]]
+
+  [[[[6,6],[6,6]],[[6,0],[6,7]]],[[[7,7],[8,9]],[8,[8,1]]]]
++ [2,9]
+= [[[[6,6],[7,7]],[[0,7],[7,7]]],[[[5,5],[5,6]],9]]
+
+  [[[[6,6],[7,7]],[[0,7],[7,7]]],[[[5,5],[5,6]],9]]
++ [1,[[[9,3],9],[[9,0],[0,7]]]]
+= [[[[7,8],[6,7]],[[6,8],[0,8]]],[[[7,7],[5,0]],[[5,5],[5,6]]]]
+
+  [[[[7,8],[6,7]],[[6,8],[0,8]]],[[[7,7],[5,0]],[[5,5],[5,6]]]]
++ [[[5,[7,4]],7],1]
+= [[[[7,7],[7,7]],[[8,7],[8,7]]],[[[7,0],[7,7]],9]]
+
+  [[[[7,7],[7,7]],[[8,7],[8,7]]],[[[7,0],[7,7]],9]]
++ [[[[4,2],2],6],[8,7]]
+= [[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]
+
+```
+
+To check whether it's the right answer, the snailfish teacher only checks the *magnitude* of the final sum. The magnitude of a pair is 3 times the magnitude of its left element plus 2 times the magnitude of its right element. The magnitude of a regular number is just that number.
+
+
+For example, the magnitude of `[9,1]` is `3*9 + 2*1 = *29*`; the magnitude of `[1,9]` is `3*1 + 2*9 = *21*`. Magnitude calculations are recursive: the magnitude of `[[9,1],[1,9]]` is `3*29 + 2*21 = *129*`.
+
+
+Here are a few more magnitude examples:
+
+
+* `[[1,2],[[3,4],5]]` becomes `*143*`.
+* `[[[[0,7],4],[[7,8],[6,0]]],[8,1]]` becomes `*1384*`.
+* `[[[[1,1],[2,2]],[3,3]],[4,4]]` becomes `*445*`.
+* `[[[[3,0],[5,3]],[4,4]],[5,5]]` becomes `*791*`.
+* `[[[[5,0],[7,4]],[5,5]],[6,6]]` becomes `*1137*`.
+* `[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]` becomes `*3488*`.
+
+
+So, given this example homework assignment:
+
+
+
+```
+[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]
+[[[5,[2,8]],4],[5,[[9,9],0]]]
+[6,[[[6,2],[5,6]],[[7,6],[4,7]]]]
+[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]]
+[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]]
+[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]]
+[[[[5,4],[7,7]],8],[[8,3],8]]
+[[9,3],[[9,9],[6,[4,9]]]]
+[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]
+[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]]
+
+```
+
+The final sum is:
+
+
+
+```
+[[[[6,6],[7,6]],[[7,7],[7,0]]],[[[7,7],[7,7]],[[7,8],[9,9]]]]
+```
+
+The magnitude of this final sum is `*4140*`.
+
+
+Add up all of the snailfish numbers from the homework assignment in the order they appear. *What is the magnitude of the final sum?*
+
+
+--- Part Two ---
+----------------
+
+You notice a second question on the back of the homework assignment:
+
+
+What is the largest magnitude you can get from adding only two of the snailfish numbers?
+
+
+Note that snailfish addition is not [commutative](https://en.wikipedia.org/wiki/Commutative_property) - that is, `x + y` and `y + x` can produce different results.
+
+
+Again considering the last example homework assignment above:
+
+
+
+```
+[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]
+[[[5,[2,8]],4],[5,[[9,9],0]]]
+[6,[[[6,2],[5,6]],[[7,6],[4,7]]]]
+[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]]
+[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]]
+[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]]
+[[[[5,4],[7,7]],8],[[8,3],8]]
+[[9,3],[[9,9],[6,[4,9]]]]
+[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]
+[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]]
+
+```
+
+The largest magnitude of the sum of any two snailfish numbers in this list is `*3993*`. This is the magnitude of `[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]` + `[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]`, which reduces to `[[[[7,8],[6,6]],[[6,0],[7,7]]],[[[7,8],[8,8]],[[7,9],[0,6]]]]`.
+
+
+*What is the largest magnitude of any sum of two different snailfish numbers from the homework assignment?*
+
+

+ 10 - 0
aoc2021/day18_snailfish/example.txt

@@ -0,0 +1,10 @@
+[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]
+[[[5,[2,8]],4],[5,[[9,9],0]]]
+[6,[[[6,2],[5,6]],[[7,6],[4,7]]]]
+[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]]
+[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]]
+[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]]
+[[[[5,4],[7,7]],8],[[8,3],8]]
+[[9,3],[[9,9],[6,[4,9]]]]
+[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]
+[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]]

+ 100 - 0
aoc2021/day18_snailfish/input.txt

@@ -0,0 +1,100 @@
+[[0,6],[[[4,0],[6,6]],[[2,2],9]]]
+[[9,[[1,6],[6,0]]],[[1,[0,8]],[[0,8],[9,8]]]]
+[[[0,[2,1]],3],[[[2,4],[1,2]],[7,5]]]
+[[[[8,3],[8,5]],[[7,8],[5,5]]],[9,2]]
+[[8,[1,9]],[[[9,9],[9,2]],1]]
+[[[[3,7],[2,1]],[0,9]],4]
+[[[[3,8],[6,0]],[0,7]],[[[6,3],[2,0]],9]]
+[[[9,[7,0]],[8,[9,6]]],[[5,6],4]]
+[[[[3,6],[3,6]],[0,2]],[[[8,3],9],[[3,4],8]]]
+[[7,[8,4]],1]
+[6,[[3,[5,6]],[0,6]]]
+[[[7,[4,7]],[[4,5],[4,3]]],[[5,5],[0,[4,2]]]]
+[[[0,[2,9]],[[2,4],[4,8]]],[[8,[9,5]],[[9,6],0]]]
+[[[[2,0],[9,7]],[[3,2],0]],[7,7]]
+[[5,[2,1]],[[3,[5,1]],[[8,5],[1,8]]]]
+[[[[9,7],6],[[7,8],7]],[[[6,8],9],[[9,5],7]]]
+[[4,2],[[[0,1],[7,2]],[[0,2],[5,5]]]]
+[[1,8],[[5,[7,9]],[[3,1],[7,1]]]]
+[[[4,[4,6]],6],5]
+[[[5,[3,6]],6],[[[8,0],[8,6]],[[3,3],[0,1]]]]
+[[4,[[2,6],[0,9]]],[[0,6],[4,2]]]
+[[[[9,4],[6,5]],7],[[[1,5],[0,9]],[4,[4,2]]]]
+[[7,[[6,5],8]],[[[5,6],0],[6,[3,5]]]]
+[[[5,[6,4]],[8,[0,4]]],[[3,[9,3]],4]]
+[[[[4,0],6],[6,[6,5]]],[[9,[6,3]],[[9,6],7]]]
+[[[[2,2],4],[8,[7,2]]],[2,1]]
+[5,[9,[[5,9],4]]]
+[[[1,[7,7]],[[2,2],8]],[[[9,7],5],[4,3]]]
+[[[[6,8],1],1],[1,[[2,0],6]]]
+[[[[0,5],8],[[8,9],[9,3]]],[[[5,5],[4,2]],2]]
+[[[9,[2,5]],[6,[1,7]]],[5,[3,[2,2]]]]
+[[[7,6],8],[[[1,9],3],[5,2]]]
+[8,[[2,[0,7]],8]]
+[[[[8,1],[0,0]],5],1]
+[[1,[[4,8],0]],[[9,[7,8]],5]]
+[[[[1,3],1],[[9,8],[6,6]]],5]
+[[[3,2],[[0,5],[0,1]]],[[9,[9,3]],[4,9]]]
+[[[0,[2,4]],[[3,3],[6,5]]],[[1,[2,1]],[[3,4],9]]]
+[[2,[3,[7,6]]],[5,5]]
+[[[[8,2],0],[[9,6],[9,0]]],[[[6,2],[5,0]],9]]
+[7,[9,7]]
+[3,[[[5,5],1],[8,5]]]
+[[[5,5],[5,6]],[9,5]]
+[[[9,7],[1,2]],[8,[5,[7,0]]]]
+[[[1,[5,2]],[7,[8,9]]],[2,[[4,5],[2,3]]]]
+[[[4,[2,2]],[5,[4,7]]],[[[0,3],2],[5,[2,6]]]]
+[[0,[[6,5],5]],[[7,[7,2]],3]]
+[[[4,[9,4]],[1,9]],[7,[[7,1],[6,1]]]]
+[1,[0,2]]
+[[[[5,1],[2,1]],[[7,8],6]],[[3,[4,9]],2]]
+[[9,[[4,0],[8,8]]],[[[6,6],[2,8]],[1,[1,5]]]]
+[[[1,2],[7,0]],[7,[[3,0],5]]]
+[[[6,[0,8]],3],[[3,7],1]]
+[[[[6,1],[1,0]],9],[[4,8],[3,[0,8]]]]
+[[6,[3,[5,8]]],9]
+[[[[5,0],[7,7]],[[3,1],[4,8]]],5]
+[[[3,7],[9,0]],[[[0,2],7],0]]
+[8,9]
+[[8,[[0,8],4]],[1,[[4,6],2]]]
+[[[5,5],3],[[6,6],[0,[6,3]]]]
+[[[7,[3,7]],[[6,1],[9,4]]],[[[8,9],1],[[8,7],6]]]
+[[6,[[0,9],[2,3]]],[[1,[5,3]],[8,4]]]
+[[[3,5],8],[[[2,4],[7,5]],5]]
+[[0,[[7,0],[9,4]]],[[[0,0],[6,7]],[6,5]]]
+[[[[1,9],[6,4]],0],[6,[3,[4,8]]]]
+[[[[1,6],[0,4]],8],[[8,8],6]]
+[[[[7,4],[9,6]],7],[[1,6],[1,0]]]
+[1,[[[6,8],5],5]]
+[8,4]
+[9,[[9,[3,9]],0]]
+[5,[[[4,9],7],[[1,0],0]]]
+[[[6,1],[0,[2,3]]],[[[7,8],[5,9]],9]]
+[3,[[3,[3,4]],[6,[7,8]]]]
+[[[7,[7,1]],[4,[2,0]]],[6,[7,3]]]
+[[6,9],[[3,[4,7]],3]]
+[1,[[9,[5,1]],[7,[7,5]]]]
+[[3,2],[[9,[6,8]],[[1,0],2]]]
+[[[[3,2],8],[7,6]],9]
+[[3,[[9,5],6]],[5,9]]
+[[[3,[6,3]],[[7,0],[5,7]]],[[3,3],[[4,9],[4,8]]]]
+[[[0,[4,3]],2],[3,[0,[1,3]]]]
+[[[7,[3,4]],[7,[3,1]]],[[0,[4,7]],6]]
+[[[1,[7,4]],[[8,7],3]],4]
+[[[5,5],[[0,3],2]],[1,[[9,4],6]]]
+[[[[6,0],[8,8]],[6,[6,0]]],[5,6]]
+[[[1,[5,4]],[[5,9],[1,7]]],[[5,[4,7]],[4,[4,4]]]]
+[[0,[[2,6],0]],[[6,[4,3]],5]]
+[[[1,[5,3]],[9,[1,2]]],[[[4,8],[5,6]],0]]
+[[0,7],[1,[7,7]]]
+[4,[[7,[7,2]],[[9,1],7]]]
+[2,[[1,6],[6,9]]]
+[[[4,[4,5]],9],[[[1,7],6],[3,[7,3]]]]
+[[6,[[1,1],[7,8]]],[[[5,2],[8,1]],5]]
+[[[5,5],[[4,1],[1,2]]],[[3,8],[3,4]]]
+[[[[1,9],[0,3]],[4,[0,9]]],4]
+[[[4,9],0],[[9,0],[8,[7,5]]]]
+[[6,[5,3]],[[[6,6],4],[[6,8],4]]]
+[[[[1,1],2],1],[1,[[6,4],2]]]
+[[[[6,3],[1,5]],[6,[7,7]]],[6,6]]
+[[[[3,0],[5,6]],1],[[[9,3],[1,7]],[[3,4],[2,7]]]]

+ 91 - 0
aoc2021/day18_snailfish/main.py

@@ -0,0 +1,91 @@
+import os, sys, re
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, generate_readme, check_example, bench
+from math import floor, ceil
+
+
+def explodes(strl, v=False):
+    for pair in re.finditer(r"\[(\d+),(\d+)\]", strl):
+        sd, ed = pair.start(), pair.end()
+        if strl[:sd].count("[") - strl[:sd].count("]") >= 4:
+            p1, p2 = int(pair.group(1)), int(pair.group(2))
+            numreplace = list(re.finditer(r"\d+", strl[:sd]))[::-1]
+            if numreplace:
+                s, e, v = (
+                    numreplace[0].start(),
+                    numreplace[0].end(),
+                    int(numreplace[0][0]),
+                )
+                before = strl[:s] + str(p1 + v) + strl[e:sd]
+            else:
+                before = strl[:sd]
+            numreplace = list(re.finditer(r"\d+", strl[ed:]))
+            if numreplace:
+                s, e, v = (
+                    numreplace[0].start(),
+                    numreplace[0].end(),
+                    int(numreplace[0][0]),
+                )
+                after = strl[ed : ed + s] + str(p2 + v) + strl[ed + e :]
+            else:
+                after = strl[ed:]
+            return before + "0" + after, True
+    return strl, False
+
+
+def split(strl):
+    for num in re.finditer(r"\d{2}", strl):
+        s, e = num.start(), num.end()
+        d = int(num[0])
+        ls = floor(d / 2)
+        rs = ceil(d / 2)
+        return strl[:s] + f"[{ls},{rs}]" + strl[e:], True
+    return strl, False
+
+
+def addition(l):
+    e = True
+    while e:
+        l, e = explodes(l)
+        if not e:
+            l, e = split(l)
+    return l
+
+
+def magnitude(line):
+    while pairs := list(re.finditer(r"\[(\d+),(\d+)\]", line)):
+        for pair in pairs[::-1]:
+            sd, ed = pair.start(), pair.end()
+            p1, p2 = int(pair[1]), int(pair[2])
+            line = line[:sd] + str(p1 * 3 + p2 * 2) + line[ed:]
+    return int(line)
+
+@bench
+def part1(input):
+    res = []
+    for line in input:
+        res.append(line)
+        if len(res) > 1:
+            res.append(addition(f"[{res.pop(0)},{res.pop(0)}]"))
+    print(magnitude(res[0]))
+
+@bench
+def part2(input):
+    mag = []
+    for ind, line in enumerate(input):
+        for ind2, line2 in enumerate(input):
+            if ind == ind2:
+                continue
+            mag.append(magnitude(addition(f"[{line},{line2}]")))
+    print(max(mag))
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 18)
+
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 18)

+ 8 - 0
aoc2021/day1_sonar_sweep/Cargo.toml

@@ -0,0 +1,8 @@
+[package]
+name = "day_1_sonar_sweep"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 89 - 0
aoc2021/day1_sonar_sweep/README.md

@@ -0,0 +1,89 @@
+
+### --- Day 1: Sonar Sweep ---
+
+You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean!
+
+
+Your instincts tell you that in order to save Christmas, you'll need to get all fifty stars by December 25th.
+
+Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
+
+As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine.
+
+For example, suppose you had the following report:
+
+```
+199
+200
+208
+210
+200
+207
+240
+269
+260
+263
+```
+
+This report indicates that, scanning outward from the submarine, the sonar sweep found depths of 199, 200, 208, 210, and so on.
+
+The first order of business is to figure out how quickly the depth increases, just so you know what you're dealing with - you never know if the keys will get carried into deeper water by an ocean current or a fish or something.
+
+To do this, count the number of times a depth measurement increases from the previous measurement. (There is no measurement before the first measurement.) In the example above, the changes are as follows:
+
+```
+199 (N/A - no previous measurement)
+200 (increased)
+208 (increased)
+210 (increased)
+200 (decreased)
+207 (increased)
+240 (increased)
+269 (increased)
+260 (decreased)
+263 (increased)
+```
+In this example, there are 7 measurements that are larger than the previous measurement.
+
+How many measurements are larger than the previous measurement?
+
+
+### --- Part Two ---
+
+Considering every single measurement isn't as useful as you expected: there's just too much noise in the data.
+
+Instead, consider sums of a three-measurement sliding window. Again considering the above example:
+
+```
+199  A      
+200  A B    
+208  A B C  
+210    B C D
+200  E   C D
+207  E F   D
+240  E F G  
+269    F G H
+260      G H
+263        H
+```
+
+Start by comparing the first and second three-measurement windows. The measurements in the first window are marked A (199, 200, 208); their sum is 199 + 200 + 208 = 607. The second window is marked B (200, 208, 210); its sum is 618. The sum of measurements in the second window is larger than the sum of the first, so this first comparison increased.
+
+Your goal now is to count the number of times the sum of measurements in this sliding window increases from the previous sum. So, compare A with B, then compare B with C, then C with D, and so on. Stop when there aren't enough measurements left to create a new three-measurement sum.
+
+In the above example, the sum of each three-measurement window is as follows:
+
+```
+A: 607 (N/A - no previous sum)
+B: 618 (increased)
+C: 618 (no change)
+D: 617 (decreased)
+E: 647 (increased)
+F: 716 (increased)
+G: 769 (increased)
+H: 792 (increased)
+```
+
+In this example, there are 5 sums that are larger than the previous sum.
+
+Consider sums of a three-measurement sliding window. How many sums are larger than the previous sum?

+ 10 - 0
aoc2021/day1_sonar_sweep/example.txt

@@ -0,0 +1,10 @@
+199
+200
+208
+210
+200
+207
+240
+269
+260
+263

+ 2000 - 0
aoc2021/day1_sonar_sweep/input.txt

@@ -0,0 +1,2000 @@
+199
+203
+200
+201
+196
+195
+196
+214
+227
+225
+229
+260
+246
+253
+271
+281
+280
+295
+310
+293
+295
+297
+298
+297
+306
+299
+290
+292
+289
+287
+291
+296
+294
+287
+286
+287
+289
+290
+281
+283
+282
+275
+256
+265
+242
+231
+226
+216
+227
+226
+249
+238
+237
+247
+245
+250
+264
+267
+259
+258
+264
+261
+249
+246
+239
+240
+259
+258
+280
+279
+278
+281
+272
+256
+255
+271
+286
+290
+286
+288
+290
+294
+292
+294
+292
+293
+294
+291
+298
+303
+301
+330
+331
+336
+362
+371
+374
+368
+367
+368
+366
+364
+371
+377
+378
+384
+386
+388
+393
+409
+423
+422
+411
+412
+426
+430
+441
+460
+462
+464
+469
+461
+483
+452
+455
+457
+468
+506
+509
+514
+525
+512
+524
+523
+522
+531
+549
+548
+549
+548
+524
+525
+528
+526
+537
+544
+549
+546
+525
+532
+535
+543
+544
+545
+525
+536
+538
+541
+524
+534
+542
+538
+539
+544
+543
+539
+538
+527
+553
+552
+562
+560
+561
+573
+574
+570
+571
+568
+569
+571
+573
+566
+567
+584
+591
+607
+605
+604
+605
+617
+615
+617
+606
+608
+609
+613
+616
+635
+634
+637
+635
+634
+655
+639
+646
+637
+628
+622
+648
+645
+640
+652
+653
+659
+661
+658
+650
+667
+670
+668
+680
+682
+673
+668
+678
+677
+675
+676
+677
+675
+688
+681
+676
+684
+675
+664
+665
+654
+660
+664
+663
+667
+658
+661
+676
+675
+680
+681
+690
+693
+697
+721
+733
+739
+740
+739
+751
+765
+766
+752
+748
+763
+772
+771
+782
+784
+797
+799
+817
+812
+811
+795
+783
+785
+790
+785
+784
+782
+771
+756
+759
+783
+772
+774
+779
+783
+786
+780
+783
+779
+777
+778
+777
+762
+778
+777
+770
+773
+769
+770
+771
+764
+765
+761
+745
+754
+758
+759
+746
+738
+740
+742
+767
+765
+754
+755
+758
+762
+760
+761
+757
+761
+770
+773
+777
+776
+777
+769
+767
+793
+805
+798
+793
+803
+809
+808
+817
+804
+809
+805
+804
+806
+808
+812
+830
+831
+832
+831
+819
+820
+823
+822
+812
+814
+812
+842
+858
+855
+856
+862
+860
+855
+839
+840
+841
+840
+846
+850
+859
+861
+852
+846
+848
+845
+833
+843
+846
+849
+889
+890
+894
+904
+907
+904
+905
+906
+907
+910
+902
+906
+900
+907
+906
+899
+887
+867
+866
+873
+878
+885
+880
+890
+863
+860
+859
+885
+856
+853
+854
+852
+864
+855
+874
+875
+874
+875
+871
+872
+867
+870
+873
+874
+860
+862
+879
+878
+879
+880
+881
+882
+878
+882
+885
+890
+902
+903
+905
+906
+909
+917
+916
+934
+932
+935
+937
+935
+910
+911
+907
+902
+904
+910
+917
+918
+943
+945
+959
+973
+972
+969
+973
+972
+958
+957
+959
+963
+968
+961
+960
+973
+971
+970
+977
+1002
+1012
+1011
+1007
+1017
+1024
+1014
+1013
+1019
+1005
+984
+983
+980
+993
+999
+982
+988
+989
+990
+992
+988
+989
+988
+981
+958
+973
+966
+965
+942
+926
+933
+928
+932
+940
+927
+930
+920
+930
+897
+905
+907
+889
+882
+888
+889
+872
+873
+885
+884
+886
+887
+898
+901
+902
+895
+880
+894
+886
+882
+885
+890
+896
+880
+881
+866
+872
+875
+903
+901
+907
+899
+920
+921
+934
+935
+937
+928
+929
+927
+928
+935
+906
+908
+906
+882
+883
+887
+891
+892
+898
+903
+907
+909
+916
+917
+945
+935
+937
+928
+918
+927
+916
+929
+919
+931
+954
+953
+954
+956
+953
+947
+937
+941
+960
+968
+951
+955
+954
+938
+939
+946
+945
+947
+948
+951
+943
+949
+946
+954
+952
+949
+943
+936
+944
+941
+950
+952
+948
+947
+971
+970
+969
+974
+971
+1000
+1005
+1007
+1009
+1008
+1000
+998
+999
+1001
+1008
+1001
+1024
+1005
+998
+1016
+1018
+1019
+1020
+1021
+1057
+1056
+1052
+1044
+1045
+1057
+1058
+1074
+1075
+1069
+1056
+1055
+1056
+1052
+1059
+1070
+1043
+1039
+1035
+1025
+1015
+1018
+1029
+1033
+1042
+1038
+1031
+1033
+1023
+1016
+1019
+1018
+1016
+1018
+1020
+1009
+1008
+997
+973
+983
+990
+996
+1002
+1001
+1000
+1002
+1001
+1015
+1016
+1015
+1019
+1020
+1016
+1010
+1009
+1008
+1016
+1018
+1015
+1011
+1004
+999
+1000
+1027
+1035
+1050
+1051
+1068
+1058
+1072
+1086
+1089
+1060
+1043
+1028
+1026
+1028
+1052
+1050
+1042
+1040
+1036
+1055
+1050
+1051
+1049
+1053
+1054
+1059
+1058
+1066
+1059
+1061
+1070
+1071
+1068
+1059
+1060
+1065
+1066
+1068
+1060
+1059
+1070
+1069
+1068
+1067
+1068
+1070
+1069
+1066
+1073
+1065
+1066
+1050
+1052
+1050
+1056
+1055
+1063
+1062
+1057
+1054
+1048
+1047
+1051
+1049
+1043
+1017
+1016
+1002
+1005
+992
+994
+999
+1001
+1017
+1026
+1024
+1028
+1040
+1039
+1046
+1022
+1023
+992
+995
+1019
+1022
+1023
+1011
+1004
+1005
+993
+991
+992
+995
+996
+997
+1009
+1011
+1012
+1017
+1030
+1029
+1031
+1024
+1033
+1008
+1006
+1018
+1020
+1015
+1020
+1031
+1029
+1026
+1030
+1042
+1039
+1029
+1027
+1008
+1003
+1019
+1000
+1001
+995
+996
+994
+988
+989
+988
+987
+994
+997
+1000
+994
+997
+989
+991
+985
+975
+982
+981
+986
+980
+979
+973
+984
+985
+983
+981
+956
+925
+924
+919
+913
+915
+917
+914
+916
+895
+910
+924
+919
+914
+928
+935
+927
+930
+932
+936
+939
+944
+948
+947
+946
+945
+948
+944
+942
+944
+958
+956
+947
+955
+990
+995
+996
+1007
+1009
+1013
+1012
+1011
+1020
+1019
+1021
+1016
+1038
+1050
+1043
+1046
+1047
+1043
+1040
+1039
+1045
+1046
+1030
+1031
+1034
+1035
+1045
+1066
+1085
+1092
+1101
+1100
+1101
+1099
+1084
+1085
+1086
+1090
+1091
+1087
+1100
+1099
+1092
+1095
+1101
+1102
+1118
+1117
+1138
+1139
+1132
+1127
+1131
+1132
+1130
+1128
+1130
+1150
+1149
+1157
+1158
+1156
+1157
+1155
+1170
+1175
+1167
+1166
+1177
+1174
+1186
+1187
+1186
+1185
+1189
+1193
+1204
+1191
+1196
+1198
+1186
+1198
+1215
+1210
+1211
+1212
+1211
+1207
+1206
+1198
+1202
+1190
+1185
+1190
+1199
+1222
+1225
+1222
+1234
+1236
+1260
+1261
+1262
+1272
+1289
+1286
+1290
+1297
+1295
+1270
+1291
+1299
+1303
+1318
+1342
+1356
+1361
+1362
+1326
+1325
+1333
+1329
+1349
+1353
+1367
+1368
+1371
+1369
+1353
+1351
+1349
+1352
+1354
+1353
+1356
+1355
+1362
+1366
+1368
+1370
+1349
+1354
+1357
+1356
+1360
+1357
+1361
+1363
+1364
+1345
+1338
+1335
+1334
+1322
+1329
+1333
+1334
+1331
+1330
+1337
+1348
+1347
+1348
+1317
+1307
+1313
+1330
+1323
+1324
+1327
+1334
+1336
+1334
+1332
+1338
+1341
+1342
+1373
+1375
+1374
+1372
+1373
+1371
+1370
+1375
+1363
+1361
+1366
+1389
+1390
+1366
+1380
+1381
+1379
+1383
+1400
+1402
+1404
+1409
+1410
+1434
+1439
+1443
+1448
+1434
+1462
+1463
+1462
+1464
+1465
+1471
+1465
+1464
+1469
+1473
+1480
+1486
+1488
+1492
+1494
+1495
+1496
+1504
+1496
+1495
+1472
+1469
+1465
+1466
+1455
+1464
+1465
+1474
+1475
+1490
+1499
+1490
+1492
+1489
+1500
+1504
+1500
+1499
+1500
+1510
+1511
+1516
+1511
+1515
+1512
+1499
+1506
+1509
+1493
+1495
+1496
+1485
+1486
+1476
+1475
+1484
+1485
+1469
+1477
+1478
+1467
+1468
+1469
+1477
+1478
+1475
+1473
+1461
+1468
+1470
+1496
+1491
+1506
+1505
+1526
+1530
+1528
+1529
+1533
+1555
+1558
+1557
+1554
+1557
+1559
+1560
+1562
+1561
+1563
+1564
+1550
+1559
+1558
+1559
+1554
+1535
+1538
+1541
+1540
+1529
+1528
+1519
+1527
+1535
+1518
+1523
+1519
+1536
+1562
+1561
+1566
+1568
+1583
+1584
+1599
+1585
+1581
+1588
+1559
+1561
+1574
+1587
+1574
+1576
+1589
+1588
+1582
+1581
+1584
+1604
+1563
+1555
+1561
+1564
+1548
+1541
+1542
+1546
+1548
+1550
+1566
+1544
+1523
+1525
+1521
+1541
+1550
+1551
+1548
+1558
+1561
+1560
+1550
+1563
+1578
+1582
+1563
+1557
+1558
+1557
+1559
+1574
+1569
+1577
+1576
+1577
+1571
+1573
+1572
+1574
+1577
+1581
+1566
+1535
+1539
+1540
+1536
+1545
+1544
+1513
+1511
+1509
+1502
+1489
+1490
+1495
+1488
+1492
+1513
+1519
+1520
+1521
+1530
+1512
+1514
+1512
+1517
+1518
+1520
+1519
+1527
+1526
+1527
+1528
+1529
+1522
+1525
+1529
+1525
+1524
+1525
+1527
+1529
+1524
+1523
+1525
+1533
+1535
+1536
+1555
+1557
+1573
+1572
+1571
+1590
+1593
+1594
+1593
+1565
+1566
+1554
+1572
+1567
+1569
+1566
+1597
+1616
+1630
+1641
+1638
+1634
+1647
+1651
+1649
+1652
+1659
+1660
+1651
+1656
+1653
+1654
+1653
+1658
+1643
+1642
+1641
+1654
+1655
+1656
+1666
+1673
+1682
+1665
+1663
+1670
+1654
+1668
+1667
+1656
+1646
+1655
+1662
+1680
+1683
+1682
+1683
+1684
+1722
+1702
+1710
+1711
+1715
+1728
+1730
+1735
+1736
+1750
+1755
+1756
+1755
+1752
+1761
+1768
+1767
+1760
+1751
+1747
+1764
+1763
+1762
+1748
+1753
+1745
+1752
+1754
+1746
+1747
+1748
+1756
+1761
+1756
+1734
+1711
+1712
+1721
+1727
+1726
+1731
+1729
+1715
+1716
+1733
+1738
+1740
+1756
+1755
+1748
+1744
+1751
+1756
+1774
+1775
+1755
+1746
+1754
+1758
+1767
+1785
+1786
+1787
+1788
+1766
+1787
+1786
+1788
+1762
+1757
+1752
+1760
+1781
+1750
+1757
+1762
+1767
+1770
+1744
+1743
+1747
+1756
+1763
+1775
+1769
+1760
+1759
+1766
+1768
+1764
+1759
+1761
+1792
+1798
+1800
+1802
+1813
+1810
+1822
+1824
+1816
+1842
+1843
+1835
+1833
+1834
+1837
+1826
+1830
+1850
+1855
+1857
+1862
+1856
+1877
+1878
+1875
+1850
+1847
+1846
+1847
+1846
+1826
+1829
+1825
+1817
+1818
+1815
+1834
+1833
+1822
+1825
+1815
+1817
+1815
+1816
+1810
+1822
+1815
+1817
+1821
+1820
+1814
+1802
+1799
+1814
+1834
+1830
+1842
+1828
+1836
+1849
+1851
+1849
+1848
+1849
+1865
+1885
+1895
+1904
+1910
+1921
+1937
+1941
+1970
+1968
+1975
+1982
+2003
+2012
+2011
+2008
+2006
+1997
+1994
+1991
+1989
+1988
+1995
+1976
+2006
+2018
+2015
+2023
+2022
+2023
+2048
+2038
+2039
+2041
+2057
+2058
+2059
+2060
+2059
+2061
+2031
+2032
+2033
+2020
+2019
+2023
+2032
+2034
+2027
+2029
+2027
+2018
+2028
+2055
+2054
+2043
+2047
+2046
+2055
+2047
+2056
+2037
+2032
+2003
+2002
+1999
+2001
+1996
+2000
+2002
+2004
+1988
+1990
+1999
+1986
+1988
+1986
+1985
+1977
+1978
+1977
+1973
+1977
+1978
+1985
+1988
+1964
+1967
+1989
+1984
+1980
+1979
+1980
+1999
+2006
+2004
+2018
+2051
+2024
+2023
+2025
+2026
+2012
+2000
+2017
+2018
+2017
+2019
+2017
+2025
+2030
+2038
+2016
+2001
+2020
+2018
+2010
+2013
+2028
+2031
+2018
+2019
+2009
+2015
+2011
+2012
+2024
+2027
+2028
+2018
+2007
+2009
+2011
+2009
+2008
+2006
+2008
+2013
+2017
+2027
+2030
+2031
+2029
+2045
+2064
+2065
+2064
+2077
+2075
+2066
+2037
+2038
+2043
+2047
+2049
+2055
+2090
+2092
+2101
+2115
+2117
+2130
+2131
+2130
+2136
+2141
+2145
+2151
+2150
+2149
+2150
+2143
+2150
+2139
+2142
+2140
+2146
+2147
+2148
+2146
+2141
+2158
+2176
+2195
+2194
+2190
+2187
+2188
+2205
+2206
+2208
+2207
+2208
+2200
+2199
+2193
+2169
+2188
+2189
+2183
+2202
+2170
+2164
+2165
+2166
+2177
+2181
+2198
+2197
+2207
+2201
+2206
+2203
+2209
+2213
+2214
+2216
+2218
+2219
+2214
+2235
+2239
+2235
+2253
+2246
+2247
+2246
+2247
+2246
+2251
+2249
+2275
+2285
+2293
+2294
+2295
+2299
+2303
+2302
+2303
+2276
+2282
+2287
+2294
+2299
+2301
+2300
+2306
+2294
+2301
+2296
+2289
+2291
+2300
+2301
+2287
+2286
+2307
+2305
+2315
+2305
+2309
+2334
+2337
+2348
+2349
+2350
+2332
+2342
+2341
+2338
+2310
+2316
+2333
+2335
+2330
+2342
+2349
+2341
+2363
+2368
+2374
+2360
+2359
+2350
+2348
+2359
+2365
+2364
+2355
+2341
+2339
+2345
+2338
+2335
+2323
+2324
+2318
+2294
+2296
+2297
+2286
+2282
+2278
+2276
+2272
+2267
+2269
+2270
+2269
+2266
+2268
+2264
+2268
+2260
+2263
+2297
+2311
+2319
+2301
+2292
+2302
+2309
+2307
+2303
+2306
+2311
+2293
+2278
+2284
+2288
+2271
+2273
+2275
+2278
+2279
+2283
+2318
+2315
+2312
+2325
+2346
+2339
+2314
+2303
+2304
+2279
+2278
+2269
+2267
+2270
+2277
+2287
+2285
+2288
+2289
+2288
+2284
+2283
+2281
+2289
+2288
+2275
+2278
+2265
+2267
+2262
+2259
+2260
+2261
+2251
+2250
+2254
+2253
+2242
+2240
+2241
+2226
+2232
+2236
+2201
+2182
+2183
+2191
+2185
+2192
+2197
+2211
+2210
+2208
+2218
+2219
+2228
+2227
+2225
+2226
+2225
+2226
+2229
+2233
+2237
+2236
+2211
+2215
+2216
+2236
+2227
+2228
+2227
+2226
+2244
+2260
+2258
+2257
+2258
+2250
+2248
+2229
+2225
+2223
+2222
+2221
+2220
+2219
+2213
+2214
+2212
+2216
+2217
+2220
+2216
+2217
+2223
+2227
+2231
+2225
+2228
+2230
+2233
+2226
+2224
+2241
+2221
+2220
+2224
+2221
+2220
+2223
+2221
+2246
+2247
+2246
+2222
+2226
+2237
+2250
+2251
+2276
+2288
+2309
+2304
+2330
+2323
+2327
+2350
+2349
+2348
+2346
+2354
+2350
+2323
+2320
+2313
+2315
+2314
+2316
+2332
+2338
+2341

+ 46 - 0
aoc2021/day1_sonar_sweep/main.py

@@ -0,0 +1,46 @@
+import os, sys
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input
+
+measures, example = get_input(task_dir, 1)
+# print(example)
+
+
+def part1(input):
+    counter = 0
+    temp = max(int(m) for m in input)
+    for measure in input:
+        if int(measure) > temp:
+            counter += 1
+        temp = int(measure)
+
+    print("The answer of part1 is:", counter)
+
+
+def check_part1(example):
+    part1(example)
+
+
+def part2(input):
+    input = [int(m) for m in input]
+    counter = 0
+    temp = sum(input[0:3])
+    for ind in range(len(input) - 2):
+        if sum(input[ind : ind + 3]) > temp:
+            counter += 1
+        temp = sum(input[ind : ind + 3])
+
+    print("The answer of part2 is:", counter)
+
+
+def check_part2(example):
+    part2(example)
+
+
+if __name__ == "__main__":
+    check_part1(example)
+    part1(measures)
+    check_part2(example)
+    part2(measures)

+ 43 - 0
aoc2021/day1_sonar_sweep/src/main.rs

@@ -0,0 +1,43 @@
+fn main() {
+    let measures: Vec<i32> = include_str!("../input.txt")
+        .lines()
+        .map(|x| x.parse().unwrap())
+        .collect();
+    let example: Vec<i32> = include_str!("../example.txt")
+        .lines()
+        .map(|x| x.parse().unwrap())
+        .collect();
+
+    check_example(&example, &part1);
+    check_example(&example, &part2);
+    part1(&measures);
+    part2(&measures);
+}
+
+fn check_example(example: &Vec<i32>, part: &dyn Fn(&Vec<i32>)) {
+    part(&example)
+}
+
+fn part1(input: &Vec<i32>) {
+    let mut counter = 0;
+    let mut temp = input.iter().max().unwrap();
+    for measure in input {
+        if measure > temp {
+            counter += 1;
+        }
+        temp = measure
+    }
+    println!("The Answer of part1 is: {}", counter);
+}
+
+fn part2(input: &Vec<i32>) {
+    let mut counter = 0;
+    // let temp: i32 = input[0..3].iter().sum();
+    for ind in 0..(input.len() - 3) {
+        if input[ind] < input[ind + 3] {
+            // println!("{}, {}, {}", ind, input[ind], input[ind + 3]);
+            counter += 1
+        }
+    }
+    println!("The Answer of part2 is: {}", counter);
+}

+ 159 - 0
aoc2021/day20_trench_map/README.md

@@ -0,0 +1,159 @@
+--- Day 20: Trench Map ---
+--------------------------
+
+With the scanners fully deployed, you turn their attention to mapping the floor of the ocean trench.
+
+
+When you get back the image from the scanners, it seems to just be random noise. Perhaps you can combine an image enhancement algorithm and the input image (your puzzle input) to clean it up a little.
+
+
+For example:
+
+
+
+```
+..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..##
+#..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###
+.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#.
+.#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#.....
+.#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#..
+...####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.....
+..##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
+
+#..#.
+#....
+##..#
+..#..
+..###
+
+```
+
+The first section is the *image enhancement algorithm*. It is normally given on a single line, but it has been wrapped to multiple lines in this example for legibility. The second section is the *input image*, a two-dimensional grid of *light pixels* (`#`) and *dark pixels* (`.`).
+
+
+The image enhancement algorithm describes how to enhance an image by *simultaneously* converting all pixels in the input image into an output image. Each pixel of the output image is determined by looking at a 3x3 square of pixels centered on the corresponding input image pixel. So, to determine the value of the pixel at (5,10) in the output image, nine pixels from the input image need to be considered: (4,9), (4,10), (4,11), (5,9), (5,10), (5,11), (6,9), (6,10), and (6,11). These nine input pixels are combined into a single binary number that is used as an index in the *image enhancement algorithm* string.
+
+
+For example, to determine the output pixel that corresponds to the very middle pixel of the input image, the nine pixels marked by `[...]` would need to be considered:
+
+
+
+```
+# . . # .
+#[. . .].
+#[# . .]#
+.[. # .].
+. . # # #
+
+```
+
+Starting from the top-left and reading across each row, these pixels are `...`, then `#..`, then `.#.`; combining these forms `...#...#.`. By turning dark pixels (`.`) into `0` and light pixels (`#`) into `1`, the binary number `000100010` can be formed, which is `34` in decimal.
+
+
+The image enhancement algorithm string is exactly 512 characters long, enough to match every possible 9-bit binary number. The first few characters of the string (numbered starting from zero) are as follows:
+
+
+
+```
+0         10        20        30  *34*    40        50        60        70
+|         |         |         |   *|*     |         |         |         |
+..#.#..#####.#.#.#.###.##.....###.*#*#.#..###.####..#####..#....#..#..##..##
+
+```
+
+In the middle of this first group of characters, the character at index 34 can be found: `#`. So, the output pixel in the center of the output image should be `#`, a *light pixel*.
+
+
+This process can then be repeated to calculate every pixel of the output image.
+
+
+Through advances in imaging technology, the images being operated on here are *infinite* in size. *Every* pixel of the infinite output image needs to be calculated exactly based on the relevant pixels of the input image. The small input image you have is only a small region of the actual infinite input image; the rest of the input image consists of dark pixels (`.`). For the purposes of the example, to save on space, only a portion of the infinite-sized input and output images will be shown.
+
+
+The starting input image, therefore, looks something like this, with more dark pixels (`.`) extending forever in every direction not shown here:
+
+
+
+```
+...............
+...............
+...............
+...............
+...............
+.....#..#......
+.....#.........
+.....##..#.....
+.......#.......
+.......###.....
+...............
+...............
+...............
+...............
+...............
+
+```
+
+By applying the image enhancement algorithm to every pixel simultaneously, the following output image can be obtained:
+
+
+
+```
+...............
+...............
+...............
+...............
+.....##.##.....
+....#..#.#.....
+....##.#..#....
+....####..#....
+.....#..##.....
+......##..#....
+.......#.#.....
+...............
+...............
+...............
+...............
+
+```
+
+Through further advances in imaging technology, the above output image can also be used as an input image! This allows it to be enhanced *a second time*:
+
+
+
+```
+...............
+...............
+...............
+..........#....
+....#..#.#.....
+...#.#...###...
+...#...##.#....
+...#.....#.#...
+....#.#####....
+.....#.#####...
+......##.##....
+.......###.....
+...............
+...............
+...............
+
+```
+
+Truly incredible - now the small details are really starting to come through. After enhancing the original input image twice, `*35*` pixels are lit.
+
+
+Start with the original input image and apply the image enhancement algorithm twice, being careful to account for the infinite size of the images. *How many pixels are lit in the resulting image?*
+
+
+--- Part Two ---
+----------------
+
+You still can't quite make out the details in the image. Maybe you just didn't [enhance](https://en.wikipedia.org/wiki/Kernel_(image_processing)) it enough.
+
+
+If you enhance the starting input image in the above example a total of *50* times, `*3351*` pixels are lit in the final output image.
+
+
+Start again with the original input image and apply the image enhancement algorithm 50 times. *How many pixels are lit in the resulting image?*
+
+

+ 13 - 0
aoc2021/day20_trench_map/example.txt

@@ -0,0 +1,13 @@
+..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..##
+#..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###
+.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#.
+.#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#.....
+.#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#..
+...####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.....
+..##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
+
+#..#.
+#....
+##..#
+..#..
+..###

+ 102 - 0
aoc2021/day20_trench_map/input.txt

@@ -0,0 +1,102 @@
+##..#.####..#.#.##.#######.######.#####..#...##.###....#..#.##..#....#.#.##.#.#.#...###..###..#.#..#.#####.#.#.##..##.#.###.#..##.###.###...####.#####....#....#..#.#...#.#.#.#.#...#####...##..####.##.##...#.##.#####........#..#####..##.##..###########....#.##.#####.##..#####...#..#.#.##...#.#.#..#...####......#.#.####....##.#.##.####..##..##.#.......#...#.###########.....###.#######....##.#.#######..#.......###.##....#.#..#....##..#.###.#..#.###.###.##..##.#.#...#.#.....###.#.#....###..#.....##.#.#####.....
+
+#.#.#.###...#####.#.###...#.#..##.#.#..#.#.#####.##......##..#.....#.#..#.##.#..##.##.#.#.#.##...#..
+.#.##..#.##.#..#...##..##....##....###.##.#..##..............#####.#.###..#..####....##.##.#.#....#.
+.##.##.###.##.#...#.#..#.###.##.####..#....#.#.####..##.####.###....##..###.#.#.....#..##.##.##.#...
+..#.##.####.####..##..####.##.###..#.#..#..##.#..#..####.#.....####.#..#####...###.##...#.##...###..
+###..##.#.#######.##....#.#.###..###..#..#####..#....##.##.###....#..#####.#..##.#...######.##..#.#.
+....#.#.##..##.####..###..#####.#.#.##....#..#...##########..##.#...#..#.##.#####.#.###..#.#..######
+.#....#.........##...#####.##.......#.###.#.###..###.#..##.###...####...........#..######...##..####
+...#.#..###.###.#.#.##.#.###.#.######.#####.#...#.#...##..###.##.####.###..#..#.####.####..#.##.#.##
+.#.#..####..#.#.#.##.......##..#..##..#..#.#.#..##..#..##.#.#.##..###....###.###.###..#....#.#..#.##
+#......###.##.#..###.#.#.###.#...#..#.#.##.##...##..####..##.###..#...######...####..##.#####......#
+.#...###.#.##.##...##......##..#.....###.###.#.#.####.###...#...#...#.##..#.##.###.#.#..#.....#####.
+.##..#..#.#..#..#.##..#..###..##.##....#.#....#.####.##.###.#...###.#..###..###..#......##..#...##.#
+..##..#..#..#..##.##...###.#.##.....#..###..##...##......#.#.#..#..#..#.#...#...#.........#.##.#...#
+#.###.#..##..##...#.#...#......###.....##.######..#....#...##.###..#..####...##......#.##...##.##.#.
+####....#.#..##.#.#.....##.##.#....#.##...###.#.#.#..##...#####.##.#.......##.#..#.##.....###.#.#..#
+...#.#...#.......#.##.#...#####...##.##.#....###.......##...#.##.#.##...#.#.....#.#####.###.#####.#.
+.###..#..##..####.##.#.###.###.###..#...###.#######...#...#.###..###..#..###.....##..#.###......##..
+.#####.##.#..##....#.########..####.##...###..#.###..#..#.#####...#...##.#.##.#.....##.#..#####...##
+...###......##.#.#.##...#....#.##..#.##.##..##.#.#.#####....#..##....##..##.#.##.....#..#.#..####..#
+.#..###....#....##.#..#.##...#.#..#.#####.###.#.#..#.#..#.##.#....##.#.##...#####.#####...#...##.#..
+#.#.#...#....#.#..#.##.#....#.#.###..##.##..#.#.#.....######.....#.#..#.###.#..##.##.#.###..#.###...
+..#.#.#.#......###..##.#.##.##.###...###..#..####...#.#.##.###.#..#.#.#...##..##..##..#..####.##..##
+...#.#.#...#..######.##.##.##...#..#..#..#..##.###.#....#..##..##.##.#......###.#.#..#....#.#...#...
+...#.##...#.....###...#.##.###...####.#####....##.#....##.#...#.#..##..##.#..#####.......##.#...#.#.
+##.#.#######.###...#.####..#..###.#.#..#.#.#.###..##.#.##.....#####..##.#...##...#....###.#.#...##..
+##.#....##.##.#.###.......##..#.##..#.#......#..#.##.#..##.###..##...#...###...#..##.###...###....##
+...#..#..#...##...#.###.#######.#.#....#..#.#####.#...#####....###.######....#.#..#.....##.#..##.##.
+...#.##########..#.##..###....##.....####.##..###..#.#.####..###.###...###..##...#.#.###...#...#.#.#
+.#...#.#.....#.##.#.#.##...#....#.....#.#.....#...##..##.#.##..#....#.##.#######.##.##....#...#..###
+.#..#....#.#...##.##.##...#.#..##.##..#...#.###..#.##.###.#...###....####..#.##..####.#.#..#########
+#.###.#..#####.##...##.##...#.#####...#..###....#.#..#..#.##..##.#..######..##.######.#..#.###..####
+##..#.##.##..#.....#...#...#####.##...##.#.##.####..#.###.##.#.....##..#....#.#..###.#.##.#.#.###...
+#.##..#.#.....#..#.##.###..###...##..#.#........##.###.#.........###.....#..#.##.##...###...#..###.#
+#.....##.#.....#.#..###..#.#...#..#..###.#......###..#.######..#...##.#.#...#.#.#.#..##.##...##.##..
+###...#....#..####.#..###..#.#.#..##.###..##.####...##.#..###.#.####.#..#....##...#.#...###..###..#.
+..##..#..#...##.....##..#.##.##..#.#.####.##.###.#.#####......#.#..##.#...##.#.#.####..###....##...#
+..##.#....#.####.....#.#.##....###..##..##..##....#...##...#.#.#.########...####....#..#.#.###.#.#..
+###.#.##.###......####....##.##.#...###.#.....#....###.##.#######.##.####.##.#.###.####..#......#..#
+...#..#..#.#....#.####...##.#..##.#####.###.#..#.##....#.##.#..####.#.#...######..###.#.######.##.#.
+####.#....#....#...###....#.#.#.##.#..##.#.####..##..#...#......#######.#.#.#.##..#.....#..##.......
+..##.#.#...#.##...#..#..##.#.##.......#.##.####..#.#.....#..#.....###.##.#.#...###..#..#...#.#.##.##
+.#.########..####.#.###...##...#........#.####.####.#.#####.###..#####...##.##..#..#.#......#...###.
+.#...#.###.#.#...#.#.#..####.##.#.####..#..#.##.....#####..#######.##....##...###..####.#.#####.....
+###.#.######.#.#.#..#.#....##.....#...###.####.#.#..#.....##.##.###.#.####.....##.#....#...##..#.#..
+##...#.....##.####.###.#.#.#.##.#.#.##.####....#.######....#....##......#....#..#.#..####.#.#.##.##.
+..#.##.##...#.#.....#.##.##.######.####..#...#..###.##..##...#.####.##....##..#.###.#.####.###.#...#
+#.##.##.##...#.....##.#.##.#.#####.#.#.....#..##...#.####...######..#....#.#.##..###.############..#
+#.##.###...#..#.#.....####..#..#.#..#.#########...#..##.#.#...#...#.#.#...#...#.#..##.#.#..####.#..#
+.##.##.##......##.#..###.#.##.####..#..##...###...##....#.##..#####.#.#.#...#.#.#..###..###..###..#.
+.##.#####..#.#.#.####.#.#.##.##.....######.#..###..#####..##....#.#.#.##.##.#...#.#.#.#.####.##.##..
+...#....#.##...#####.#.###.####...##.#...##.#.#..#.#...####......#####.#.##.#..#####.#...#..#...#...
+#..#.##...#.#..#.###.#.#.#...#.##.##..#.##...###.######..#.##..###..#.#.###.##.#.###.....#..#.#..###
+.###.#........##..##......##.#######.#.#..###...#..#.##..####.#.####..###...#..##.###.##.###.#...#..
+###.###..##..##.#..#.##....#####.##.#....#..###..#..#.#...#.#.#......#.##..#####...###..##.#.....###
+##.#..###...#.#..###.....###.###.#.#..#...#.#...###..#.....########.##......#...##..#.#.#.#..#.#.##.
+#..##.#.#.##.####..##.###..#...#..#..###..##...#..#......#.#....##......####.#.###...##..###...#...#
+..#..##..####..###..#####.#.#.##.##.##....##.#.#.##...#......#...#..###....####..#.##..#.###....#.##
+###..#######...#...######.#######.##..##..###.....##..#...#..##..#######.....#..##..##..##..#.####..
+..#.###.#.##...#.#.##.#.#.###..##.....###.###.#..####.#...##..##...#..#.###.##.##.####....#...##....
+##.#.#...##.....#.#.#.##..##..####....#.#...#.#.#.#..#..###..###.#.#.###..#.###..#..###...##.......#
+###...##..#.#.####..#..#...##..#..#.#.#.#...###.##.###.###.#####.#.....####..#####.###.##..###..#...
+..###.#####.##...#.####....#.#...##...##....###......###...#.#.#.......###..#..#...#####.#..########
+#.####....#.#.#.#.#.#.#..#.##...#.#.###.#.##.##..#..#.###.##.##....##.###...#..##.#.....##.###.##.#.
+.#.#.##..#.#.##...##.####.#...#.#..##.#..##.#.##..##..#.####.##.#...##..###.###..###..#.#....###.##.
+####.#...#....####.###.####...##.....#######.....###....##.#........#.###.....#.#.#.###.####.##.#.##
+.#..#..#..####.#.##..##...###..###.###...######.###....##...#.##..#####.#.####.......#...#.##.#.....
+.#..#....#...#####..#..#...#..#...##.#.##.#.##.#...#.##..##.####..#.###.###.#..##.###.......###.#...
+.##.##.#..#...###.####.#.###.#...#..#.##.#..##.#.#.##..####.#####....##.###.###....#....#..##.###..#
+..#..#..##.###...#.###.#.###...###....##.##.#.#..#..#.##.#.#.....#####..#.##.###.#.....#..#.#.######
+#...##..###.###.#..#....#..#.##..##.###..#.#.#..##...#.##..#..#.#####.......#.##......##.#.#..#..#..
+.#....####.##.###.##....#...###.#..#####.#..#..##....####.#...####.#..###...#....#.#..####..##....##
+##..#####..#..#..#.#####.#.###..#....#..##.#...#.###..#..#####....##..##.#......##.###..#.#...#.###.
+##.......#..##.#.#.##.#...#.########.#.#.##..##.#..###.....#.#..###...##..#......##.##.##......#..##
+.##...##.#.#.....#.#.#.#....###..#..##...#.#.#.##.####.##.##.##.....##.#.....#.#.##..#.#.####.#..##.
+..#..#....###.....#.###...###.###...##....##.#.#.##....#..######...#.##.#.#...##.#....##########.###
+.....#.#.#.##.#.#.....#..#.#.#..####.##.#...#.#.....#####.###.#...#...#....###.#.......#.#..#...##..
+.##..###.#....#..#.##.#.#.#..#..#.##.....#####..##.....##.##....#...#..##..#..#.....###..#...##.#..#
+#.#.#..#.#...#.#.#.#...#..#.#.###.#.....#...#...#.###..######.#..###..####..####...##..#.....#.####.
+#..##........#.#.##.#.##.#.#####..#....#####.####...#....#.#..####.#..###.#.###..##..#....##.#...#.#
+..#....#....#....#.#.####......#.##...###..###.#.#..#.#.#.###..#.#.###.....#..###..##..#.##..#.#..##
+#...#..#.###.#....#.#.#.#..#.####..#####..###.....##..#.###..#.##.#####.#.#....###.###..#.##.###..#.
+#####.###.#.#.####..#.###.##..#.#.#..#........#########.##.#.#.#..##.#...#..#...#.##....#..##.##.#.#
+#.##.....#.##.#..##.....####.##..#..#...#.#..#.#######..#.##.#..#.##...###.###....###..#.##.##.####.
+.#....##########..#.#..###..#.#.#.#...#..#.#..###..##....######.###....#...##...#...#..###.#.#...###
+#.#.#..#.##.....##..####.###.#.###.#..#....#.#...#..##.#.#.##...#..#.......#...#.....##.##.##...#...
+#....#...#..##..............##.###.#.#####.##..#########..#.#..##.###..##.##..#.##.##..##..#...###.#
+##...#.####...##.....##.##....##.######.##.#.##.####..##..#####..#..#.#.###.....#..##..#.#...####...
+#..#.####.#....##..#.###.##.#.#.#.#...##.##.#.####......###.#.####.#####...##.#.#.##.#..######..#..#
+..##...##.#.##.##.#.#..#....#.##.##.#..###...######.####.#......#..#.#..#.#####.....#.#.#..#......#.
+#......#.###.#......###....##.##.#.#...#...##.#.#.######..#.##.####..#..#...#.##.###....#......####.
+.#.#.#####.###.##.##......#......##.#.....##..#.###..#.##....##.#.##.#####..##.##..#####.#..#...##.#
+##.#.#.#..#.###.##.#.#....##.#.##.....#.#.#.#..#...#.....#.#.#.#.#####....#######.#..#..##..##.###.#
+..#.##..####.#.......#....######...####.#.#.###.#...######.#....##.#.##.##.###.#..#...##...##..#....
+.#.##.###..###........##.##.####.####.#...#.##....#####.##..####...##.##..#.#.####.#####....##....#.
+#.##.#.#.##......#.#####.#.#..###....#...#...#..##..##.#.#.####..###.#.#..######.###.......#..#.####
+..##.#.#...##...#.....#......#..##.#.##.###.#.###..#..#.#.####.##.#.####.#.####.#.#..###.##.###..#.#
+#........#.#..#.....##..#...##..##..##..#.##..##.#.####..####.#.#.#####..###.#.....#.#....#..#..###.
+#..##..#.######.....##..#.##..#..###.####.#.#....#.#.........#####.####..##.####.##..#.#..#..#.###..
+##.##..##.####..#.#...#..#..#..##.....##..#...#.###..#.............##.#...###....##.####.#.###..#..#
+#..#.#.###..###....#####.#.#.#..#.##.#.##...##..###.##..###....#.###.##..#.#.#.#######.##.#.#.#..#..

+ 107 - 0
aoc2021/day20_trench_map/main.py

@@ -0,0 +1,107 @@
+import os, sys
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+import numpy as np
+from get_tasks import get_input, generate_readme, check_example, bench
+from itertools import takewhile
+from scipy.signal import convolve2d
+from numpy.lib.stride_tricks import sliding_window_view
+
+
+def parse(input, test=False):
+    if test:
+        code = (
+            "".join([line for line in takewhile(lambda l: len(l) > 0, input)])
+            .replace("#", "1")
+            .replace(".", "0")
+        )
+        code = np.array(list(code), dtype=int)
+        image = np.array([list(line) for line in input[8:]])
+    else:
+        code = np.array(list(input[0].replace("#", "1").replace(".", "0")), dtype=int)
+        image = np.array([list(line) for line in input[2:]])
+    image[image == "."] = 0
+    image[image == "#"] = 1
+    return image.astype(int), code
+
+
+def naive_virgin_enhance_image(image, code, steps):
+    for step in range(steps):
+        match code[0]:
+            case 0: pad = 0; val = 0
+            case _: pad = step % 2; val = 1 - pad
+        sp = 3 if step == 0 else 1
+        enhance_image = np.pad(image, sp, constant_values=pad)
+        enhanced_image = np.full_like(enhance_image, val, dtype=int)
+        for i in range(enhance_image.shape[0] - 2):
+            for j in range(enhance_image.shape[1] - 2):
+                win = enhance_image[i : i + 3, j : j + 3]
+                enhanced_image[i + 1, j + 1] = code[
+                    win.flatten()[0] * 256 + np.packbits(win.flatten()[1:])
+                ]
+        image = enhanced_image
+    return image
+
+
+def true_vectorized_chad_enhance_image(image, code, steps, outside=0, pad_size=2):
+    for _ in range(steps):
+        image = np.pad(image, pad_size, constant_values=outside)
+
+        windows = sliding_window_view(image, (3, 3))
+        windows = windows.reshape(*windows.shape[:2], 9)
+        codes = windows[:, :, 0] * 256 + np.packbits(windows[:, :, 1:]).reshape(
+            windows.shape[:2]
+        )
+        image = code[codes]
+        outside = code[outside * 511]
+    return image
+
+
+def literally_genious_conv_enhance_image(image, code, steps, outside=0):
+    kernel = np.array(
+    [
+        [ 1,  2,  4],
+        [ 8, 16, 32],
+        [64,128,256]
+    ]
+)   
+    for _ in range(steps):
+        image = code[convolve2d(image, kernel, fillvalue=outside)]
+        outside = code[outside*511]
+    return image
+
+@bench
+def part1(input, test=False, method='conv_kernel'):
+    image, code = parse(input, test)
+    if method == 'conv_kernel':
+        image = literally_genious_conv_enhance_image(image, code, steps=2)
+    elif method == 'vectorized':
+        image = true_vectorized_chad_enhance_image(image, code, steps=2)
+    else: 
+        image = naive_virgin_enhance_image(image, code, steps=2)
+    print("The answer of part1 is:", image.sum())
+
+
+@bench
+def part2(input, test=False, method='conv_kernel'):
+    image, code = parse(input, test)
+    if method == 'conv_kernel':
+        image = literally_genious_conv_enhance_image(image, code, steps=50)
+    elif method == 'vectorized':
+        image = true_vectorized_chad_enhance_image(image, code, steps=50)
+    else: 
+        image = naive_virgin_enhance_image(image, code, steps=50)
+    print("The answer of part2 is:", image.sum())
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 20)
+
+    part1(example, True)
+    part2(example, True)
+
+    part1(input, method='conv_kernel')
+    part2(input, method='conv_kernel')
+
+    generate_readme(task_dir, 20)

+ 77 - 0
aoc2021/day21_dirac_dice/README.md

@@ -0,0 +1,77 @@
+--- Day 21: Dirac Dice ---
+--------------------------
+
+There's not much to do as you slowly descend to the bottom of the ocean. The submarine computer challenges you to a nice game of *Dirac Dice*.
+
+
+This game consists of a single [die](https://en.wikipedia.org/wiki/Dice), two [pawns](https://en.wikipedia.org/wiki/Glossary_of_board_games#piece), and a game board with a circular track containing ten spaces marked `1` through `10` clockwise. Each player's *starting space* is chosen randomly (your puzzle input). Player 1 goes first.
+
+
+Players take turns moving. On each player's turn, the player rolls the die *three times* and adds up the results. Then, the player moves their pawn that many times *forward* around the track (that is, moving clockwise on spaces in order of increasing value, wrapping back around to `1` after `10`). So, if a player is on space `7` and they roll `2`, `2`, and `1`, they would move forward 5 times, to spaces `8`, `9`, `10`, `1`, and finally stopping on `2`.
+
+
+After each player moves, they increase their *score* by the value of the space their pawn stopped on. Players' scores start at `0`. So, if the first player starts on space `7` and rolls a total of `5`, they would stop on space `2` and add `2` to their score (for a total score of `2`). The game immediately ends as a win for any player whose score reaches *at least `1000`*.
+
+
+Since the first game is a practice game, the submarine opens a compartment labeled *deterministic dice* and a 100-sided die falls out. This die always rolls `1` first, then `2`, then `3`, and so on up to `100`, after which it starts over at `1` again. Play using this die.
+
+
+For example, given these starting positions:
+
+
+
+```
+Player 1 starting position: 4
+Player 2 starting position: 8
+
+```
+
+This is how the game would go:
+
+
+* Player 1 rolls `1`+`2`+`3` and moves to space `10` for a total score of `10`.
+* Player 2 rolls `4`+`5`+`6` and moves to space `3` for a total score of `3`.
+* Player 1 rolls `7`+`8`+`9` and moves to space `4` for a total score of `14`.
+* Player 2 rolls `10`+`11`+`12` and moves to space `6` for a total score of `9`.
+* Player 1 rolls `13`+`14`+`15` and moves to space `6` for a total score of `20`.
+* Player 2 rolls `16`+`17`+`18` and moves to space `7` for a total score of `16`.
+* Player 1 rolls `19`+`20`+`21` and moves to space `6` for a total score of `26`.
+* Player 2 rolls `22`+`23`+`24` and moves to space `6` for a total score of `22`.
+
+
+...after many turns...
+
+
+* Player 2 rolls `82`+`83`+`84` and moves to space `6` for a total score of `742`.
+* Player 1 rolls `85`+`86`+`87` and moves to space `4` for a total score of `990`.
+* Player 2 rolls `88`+`89`+`90` and moves to space `3` for a total score of `745`.
+* Player 1 rolls `91`+`92`+`93` and moves to space `10` for a final score, `1000`.
+
+
+Since player 1 has at least `1000` points, player 1 wins and the game ends. At this point, the losing player had `745` points and the die had been rolled a total of `993` times; `745 * 993 = *739785*`.
+
+
+Play a practice game using the deterministic 100-sided die. The moment either player wins, *what do you get if you multiply the score of the losing player by the number of times the die was rolled during the game?*
+
+
+--- Part Two ---
+----------------
+
+Now that you're warmed up, it's time to play the real game.
+
+
+A second compartment opens, this time labeled *Dirac dice*. Out of it falls a single three-sided die.
+
+
+As you experiment with the die, you feel a little strange. An informational brochure in the compartment explains that this is a *quantum die*: when you roll it, the universe *splits into multiple copies*, one copy for each possible outcome of the die. In this case, rolling the die always splits the universe into *three copies*: one where the outcome of the roll was `1`, one where it was `2`, and one where it was `3`.
+
+
+The game is played the same as before, although to prevent things from getting too far out of hand, the game now ends when either player's score reaches at least `*21*`.
+
+
+Using the same starting positions as in the example above, player 1 wins in `*444356092776315*` universes, while player 2 merely wins in `341960390180808` universes.
+
+
+Using your given starting positions, determine every possible outcome. *Find the player that wins in more universes; in how many universes does that player win?*
+
+

+ 2 - 0
aoc2021/day21_dirac_dice/example.txt

@@ -0,0 +1,2 @@
+Player 1 starting position: 4
+Player 2 starting position: 8

+ 2 - 0
aoc2021/day21_dirac_dice/input.txt

@@ -0,0 +1,2 @@
+Player 1 starting position: 3
+Player 2 starting position: 4

+ 67 - 0
aoc2021/day21_dirac_dice/main.py

@@ -0,0 +1,67 @@
+import os, sys
+
+task_dir = os.path.dirname(__file__)
+sys.path.append(f"{task_dir}/..")
+from get_tasks import get_input, generate_readme, check_example, bench
+from itertools import product
+from functools import cache
+from collections import Counter
+
+
+def virgin_warmup_game(player1=0, player2=0, pos1=4, pos2=8):
+    roll = 1
+    step = 0
+    while not (player1 >= 1000 or player2 >= 1000):
+        if step % 2 == 0:
+            pos1 = 10 if (s := (sum(range(roll, roll + 3)) + pos1) % 10) == 0 else s
+            player1 += pos1
+        else:
+            pos2 = 10 if (s := (sum(range(roll, roll + 3)) + pos2) % 10) == 0 else s
+            player2 += pos2
+        roll += 3
+        step += 3
+        roll = roll % 100 if roll > 100 else roll
+    return min(player1, player2) * step
+
+
+outcomes = Counter(map(sum, product([1, 2, 3], [1, 2, 3], [1, 2, 3])))
+
+@cache
+def chad_dirac_dice(player1=0, player2=0, pos1=4, pos2=8):
+    wins1, wins2 = 0, 0
+    if player1 >= 21:
+        return 1, 0
+    if player2 >= 21:
+        return 0, 1
+    for s, c in outcomes.items():
+        npos1 = 10 if (np := (s + pos1) % 10) == 0 else np
+        a, b = chad_dirac_dice(player2, player1 + npos1, pos2, npos1)
+        wins1 += b*c
+        wins2 += a*c
+    return wins1, wins2
+
+
+@bench
+def part1(input):
+    pos1 = int(input[0][-1])
+    pos2 = int(input[1][-1])
+    print("The answer of part1 is:", virgin_warmup_game(pos1=pos1, pos2=pos2))
+
+
+@bench
+def part2(input):
+    pos1 = int(input[0][-1])
+    pos2 = int(input[1][-1])
+    print("The answer of part2 is:", max(chad_dirac_dice(pos1=pos1, pos2=pos2)))
+
+
+if __name__ == "__main__":
+    input, example = get_input(task_dir, 21)
+
+    check_example(example, part1)
+    check_example(example, part2)
+
+    part1(input)
+    part2(input)
+
+    generate_readme(task_dir, 21)

+ 100 - 0
aoc2021/day24_arithmetic_logic_unit/README.md

@@ -0,0 +1,100 @@
+--- Day 24: Arithmetic Logic Unit ---
+-------------------------------------
+
+[Magic smoke](https://en.wikipedia.org/wiki/Magic_smoke) starts leaking from the submarine's [arithmetic logic unit](https://en.wikipedia.org/wiki/Arithmetic_logic_unit) (ALU). Without the ability to perform basic arithmetic and logic functions, the submarine can't produce cool patterns with its Christmas lights!
+
+
+It also can't navigate. Or run the oxygen system.
+
+
+Don't worry, though - you *probably* have enough oxygen left to give you enough time to build a new ALU.
+
+
+The ALU is a four-dimensional processing unit: it has integer variables `w`, `x`, `y`, and `z`. These variables all start with the value `0`. The ALU also supports *six instructions*:
+
+
+* `inp a` - Read an input value and write it to variable `a`.
+* `add a b` - Add the value of `a` to the value of `b`, then store the result in variable `a`.
+* `mul a b` - Multiply the value of `a` by the value of `b`, then store the result in variable `a`.
+* `div a b` - Divide the value of `a` by the value of `b`, truncate the result to an integer, then store the result in variable `a`. (Here, "truncate" means to round the value toward zero.)
+* `mod a b` - Divide the value of `a` by the value of `b`, then store the *remainder* in variable `a`. (This is also called the [modulo](https://en.wikipedia.org/wiki/Modulo_operation) operation.)
+* `eql a b` - If the value of `a` and `b` are equal, then store the value `1` in variable `a`. Otherwise, store the value `0` in variable `a`.
+
+
+In all of these instructions, `a` and `b` are placeholders; `a` will always be the variable where the result of the operation is stored (one of `w`, `x`, `y`, or `z`), while `b` can be either a variable or a number. Numbers can be positive or negative, but will always be integers.
+
+
+The ALU has no *jump* instructions; in an ALU program, every instruction is run exactly once in order from top to bottom. The program halts after the last instruction has finished executing.
+
+
+(Program authors should be especially cautious; attempting to execute `div` with `b=0` or attempting to execute `mod` with `a<0` or `b<=0` will cause the program to crash and might even damage the ALU. These operations are never intended in any serious ALU program.)
+
+
+For example, here is an ALU program which takes an input number, negates it, and stores it in `x`:
+
+
+
+```
+inp x
+mul x -1
+
+```
+
+Here is an ALU program which takes two input numbers, then sets `z` to `1` if the second input number is three times larger than the first input number, or sets `z` to `0` otherwise:
+
+
+
+```
+inp z
+inp x
+mul z 3
+eql z x
+
+```
+
+Here is an ALU program which takes a non-negative integer as input, converts it into binary, and stores the lowest (1's) bit in `z`, the second-lowest (2's) bit in `y`, the third-lowest (4's) bit in `x`, and the fourth-lowest (8's) bit in `w`:
+
+
+
+```
+inp w
+add z w
+mod z 2
+div w 2
+add y w
+mod y 2
+div w 2
+add x w
+mod x 2
+div w 2
+mod w 2
+
+```
+
+Once you have built a replacement ALU, you can install it in the submarine, which will immediately resume what it was doing when the ALU failed: validating the submarine's *model number*. To do this, the ALU will run the MOdel Number Automatic Detector program (MONAD, your puzzle input).
+
+
+Submarine model numbers are always *fourteen-digit numbers* consisting only of digits `1` through `9`. The digit `0` *cannot* appear in a model number.
+
+
+When MONAD checks a hypothetical fourteen-digit model number, it uses fourteen separate `inp` instructions, each expecting a *single digit* of the model number in order of most to least significant. (So, to check the model number `13579246899999`, you would give `1` to the first `inp` instruction, `3` to the second `inp` instruction, `5` to the third `inp` instruction, and so on.) This means that when operating MONAD, each input instruction should only ever be given an integer value of at least `1` and at most `9`.
+
+
+Then, after MONAD has finished running all of its instructions, it will indicate that the model number was *valid* by leaving a `0` in variable `z`. However, if the model number was *invalid*, it will leave some other non-zero value in `z`.
+
+
+MONAD imposes additional, mysterious restrictions on model numbers, and legend says the last copy of the MONAD documentation was eaten by a [tanuki](https://en.wikipedia.org/wiki/Japanese_raccoon_dog). You'll need to *figure out what MONAD does* some other way.
+
+
+To enable as many submarine features as possible, find the largest valid fourteen-digit model number that contains no `0` digits. *What is the largest model number accepted by MONAD?*
+
+
+--- Part Two ---
+----------------
+
+As the submarine starts booting up things like the [Retro Encabulator](https://www.youtube.com/watch?v=RXJKdh1KZ0w), you realize that maybe you don't need all these submarine features after all.
+
+
+*What is the smallest model number accepted by MONAD?*
+
+

+ 11 - 0
aoc2021/day24_arithmetic_logic_unit/example.txt

@@ -0,0 +1,11 @@
+inp w
+add z w
+mod z 2
+div w 2
+add y w
+mod y 2
+div w 2
+add x w
+mod x 2
+div w 2
+mod w 2

+ 252 - 0
aoc2021/day24_arithmetic_logic_unit/input.txt

@@ -0,0 +1,252 @@
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 12
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 4
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 11
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 10
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 14
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 12
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -6
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 14
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 15
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 6
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 12
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 16
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -9
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 1
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 14
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 7
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 1
+add x 14
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 8
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -5
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 11
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -9
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 8
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -5
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 3
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -2
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 1
+mul y x
+add z y
+inp w
+mul x 0
+add x z
+mod x 26
+div z 26
+add x -7
+eql x w
+eql x 0
+mul y 0
+add y 25
+mul y x
+add y 1
+mul z y
+mul y 0
+add y w
+add y 8
+mul y x
+add z y

+ 109 - 0
aoc2021/day24_arithmetic_logic_unit/main.py

@@ -0,0 +1,109 @@
+import os, sys, re
+task_dir = os.path.dirname(__file__)
+sys.path.append(f'{task_dir}/..')
+from get_tasks import get_input, generate_readme, check_example
+
+
+def ALU(program, number):
+    number = iter(map(int, str(number)))
+    ma = {'w':0, 'z':0, 'x':0, 'y':0}
+    for idx, line in enumerate(program):
+        if len(inp := line.split()) == 2: ma[inp[1]] = next(number)
+        else:
+            ins, a, b = line.split()
+            if ins == 'add': ma[a] = ma[a] + int(b) if b.isdigit() or b.startswith('-') else ma[a] + ma[b]
+            if ins == 'mul': ma[a] = ma[a] * int(b) if b.isdigit() or b.startswith('-') else ma[a] * ma[b]
+            if ins == 'mod': 
+                if ma[a] < 0 : raise ValueError(f'{a} < 0! or {b} <= 0: {ma[a]}. istruction number {idx}: {line}')
+                else: ma[a] = ma[a] % int(b) if b.isdigit() else ma[a] % ma[b]
+            if ins == 'div': 
+                if (b.isdigit() and int(b) < 0) or (not b.isdigit() and ma[b] < 0): 
+                    raise ValueError(f'{b} <= 0: {b if b.isdigit() else ma[b]}. istruction number {idx}: {line}')
+                else: ma[a] = int(ma[a] / int(b)) if b.isdigit() or b.startswith('-') else int((ma[a] / ma[b]))
+            if ins == 'eql': 
+                if b.isdigit() and ma[a] == int(b):
+                    ma[a] = 1 
+                elif not b.isdigit() and ma[b] == ma[a]:
+                    ma[a] = 1
+                else:
+                    ma[a] = 0
+    return ma['w'], ma['x'], ma['y'], ma['z']
+
+def get_equations_from_input(input):
+    placeholder = 'abcdefghijklmn'
+    number = iter(placeholder)
+    pstack = []
+    diffs = []
+    stack = []
+    equations = []
+    for idx, line in enumerate(input):
+        match idx % 18:
+            case 5 | 15: diffs.append(line)
+    for idx, line in enumerate(diffs):
+        _, a, b = line.split()
+        if a == 'x' and b.startswith("-"):
+            pstack.append(['pop', f'{b} = {next(number)}'])
+        elif a == 'x':
+            pstack.append(['push', f'{next(number)} + {diffs[idx+1].split()[2]}'])
+    for line in pstack:
+        if line[0] == 'push':
+            stack.append(line[1])
+        elif line[0] == 'pop':
+            pop = stack.pop().split('+')
+            val = line[1].split('=')
+            equations.append([f"{pop[0]} + {eval(pop[-1]+val[0])} = {val[-1]}"])
+    return equations
+
+def part1(equations):
+    placeholder = 'abcdefghijklmn'
+    for equation in equations:
+        if re.findall(r"\-", equation[0]):
+            equation = equation[0]
+            letter1 = equation[0]
+            letter2 = equation[-1]
+            placeholder = placeholder.replace(letter1, '9')
+            equation = equation.replace(letter1, '9')
+            placeholder = placeholder.replace(letter2, str(eval(equation.split('=')[0])))
+        else:
+            equation = equation[0][::-1]
+            letter1 = equation[0]
+            letter2 = equation[-1]
+            placeholder = placeholder.replace(letter1, '9')
+            equation = equation.replace(letter1, '9')
+            placeholder = placeholder.replace(letter2, str(9 - int(equation.split('=')[1].split('+')[0]))) 
+    print("The answer of part1 is:", placeholder)
+    return placeholder
+
+def part2(equations):
+    placeholder = 'abcdefghijklmn'
+    for equation in equations:
+        if re.findall(r"\-", equation[0]):
+           equation = equation[0][::-1]
+           letter1 = equation[0]
+           letter2 = equation[-1]
+           placeholder = placeholder.replace(letter1, '1')
+           equation = equation.replace(letter1, '1')
+           placeholder = placeholder.replace(letter2, str(1 + int(equation.split('=')[1].split('+')[0][1]))) 
+        else:
+            equation = equation[0]
+            letter1 = equation[0]
+            letter2 = equation[-1]
+            placeholder = placeholder.replace(letter1, '1')
+            equation = equation.replace(letter1, '1')
+            placeholder = placeholder.replace(letter2, str(eval(equation.split('=')[0])))
+    print("The answer of part2 is:", placeholder)
+    return placeholder
+            
+            
+if __name__ == '__main__':
+
+    input, example = get_input(task_dir, 24)
+    
+    equations = get_equations_from_input(input)
+    
+    part1(equations)
+    part2(equations)
+
+    generate_readme(task_dir, 24)
+
+    

+ 366 - 0
aoc2021/day25_sea_cucumber/README.md

@@ -0,0 +1,366 @@
+--- Day 25: Sea Cucumber ---
+----------------------------
+
+This is it: the bottom of the ocean trench, the last place the sleigh keys could be. Your submarine's experimental antenna *still isn't boosted enough* to detect the keys, but they *must* be here. All you need to do is *reach the seafloor* and find them.
+
+
+At least, you'd touch down on the seafloor if you could; unfortunately, it's completely covered by two large herds of [sea cucumbers](https://en.wikipedia.org/wiki/Sea_cucumber), and there isn't an open space large enough for your submarine.
+
+
+You suspect that the Elves must have done this before, because just then you discover the phone number of a deep-sea marine biologist on a handwritten note taped to the wall of the submarine's cockpit.
+
+
+"Sea cucumbers? Yeah, they're probably hunting for food. But don't worry, they're predictable critters: they move in perfectly straight lines, only moving forward when there's space to do so. They're actually quite polite!"
+
+
+You explain that you'd like to predict when you could land your submarine.
+
+
+"Oh that's easy, they'll eventually pile up and leave enough space for-- wait, did you say submarine? And the only place with that many sea cucumbers would be at the very bottom of the Mariana--" You hang up the phone.
+
+
+There are two herds of sea cucumbers sharing the same region; one always moves *east* (`>`), while the other always moves *south* (`v`). Each location can contain at most one sea cucumber; the remaining locations are *empty* (`.`). The submarine helpfully generates a map of the situation (your puzzle input). For example:
+
+
+
+```
+v...>>.vv>
+.vv>>.vv..
+>>.>v>...v
+>>v>>.>.v.
+v>v.vv.v..
+>.>>..v...
+.vv..>.>v.
+v.v..>>v.v
+....v..v.>
+
+```
+
+Every *step*, the sea cucumbers in the east-facing herd attempt to move forward one location, then the sea cucumbers in the south-facing herd attempt to move forward one location. When a herd moves forward, every sea cucumber in the herd first simultaneously considers whether there is a sea cucumber in the adjacent location it's facing (even another sea cucumber facing the same direction), and then every sea cucumber facing an empty location simultaneously moves into that location.
+
+
+So, in a situation like this:
+
+
+
+```
+...>>>>>...
+```
+
+After one step, only the rightmost sea cucumber would have moved:
+
+
+
+```
+...>>>>.>..
+```
+
+After the next step, two sea cucumbers move:
+
+
+
+```
+...>>>.>.>.
+```
+
+During a single step, the east-facing herd moves first, then the south-facing herd moves. So, given this situation:
+
+
+
+```
+..........
+.>v....v..
+.......>..
+..........
+
+```
+
+After a single step, of the sea cucumbers on the left, only the south-facing sea cucumber has moved (as it wasn't out of the way in time for the east-facing cucumber on the left to move), but both sea cucumbers on the right have moved (as the east-facing sea cucumber moved out of the way of the south-facing sea cucumber):
+
+
+
+```
+..........
+.>........
+..v....v>.
+..........
+
+```
+
+Due to *strong water currents* in the area, sea cucumbers that move off the right edge of the map appear on the left edge, and sea cucumbers that move off the bottom edge of the map appear on the top edge. Sea cucumbers always check whether their destination location is empty before moving, even if that destination is on the opposite side of the map:
+
+
+
+```
+Initial state:
+...>...
+.......
+......>
+v.....>
+......>
+.......
+..vvv..
+
+After 1 step:
+..vv>..
+.......
+>......
+v.....>
+>......
+.......
+....v..
+
+After 2 steps:
+....v>.
+..vv...
+.>.....
+......>
+v>.....
+.......
+.......
+
+After 3 steps:
+......>
+..v.v..
+..>v...
+>......
+..>....
+v......
+.......
+
+After 4 steps:
+>......
+..v....
+..>.v..
+.>.v...
+...>...
+.......
+v......
+
+```
+
+To find a safe place to land your submarine, the sea cucumbers need to stop moving. Again consider the first example:
+
+
+
+```
+Initial state:
+v...>>.vv>
+.vv>>.vv..
+>>.>v>...v
+>>v>>.>.v.
+v>v.vv.v..
+>.>>..v...
+.vv..>.>v.
+v.v..>>v.v
+....v..v.>
+
+After 1 step:
+....>.>v.>
+v.v>.>v.v.
+>v>>..>v..
+>>v>v>.>.v
+.>v.v...v.
+v>>.>vvv..
+..v...>>..
+vv...>>vv.
+>.v.v..v.v
+
+After 2 steps:
+>.v.v>>..v
+v.v.>>vv..
+>v>.>.>.v.
+>>v>v.>v>.
+.>..v....v
+.>v>>.v.v.
+v....v>v>.
+.vv..>>v..
+v>.....vv.
+
+After 3 steps:
+v>v.v>.>v.
+v...>>.v.v
+>vv>.>v>..
+>>v>v.>.v>
+..>....v..
+.>.>v>v..v
+..v..v>vv>
+v.v..>>v..
+.v>....v..
+
+After 4 steps:
+v>..v.>>..
+v.v.>.>.v.
+>vv.>>.v>v
+>>.>..v>.>
+..v>v...v.
+..>>.>vv..
+>.v.vv>v.v
+.....>>vv.
+vvv>...v..
+
+After 5 steps:
+vv>...>v>.
+v.v.v>.>v.
+>.v.>.>.>v
+>v>.>..v>>
+..v>v.v...
+..>.>>vvv.
+.>...v>v..
+..v.v>>v.v
+v.v.>...v.
+
+...
+
+After 10 steps:
+..>..>>vv.
+v.....>>.v
+..v.v>>>v>
+v>.>v.>>>.
+..v>v.vv.v
+.v.>>>.v..
+v.v..>v>..
+..v...>v.>
+.vv..v>vv.
+
+...
+
+After 20 steps:
+v>.....>>.
+>vv>.....v
+.>v>v.vv>>
+v>>>v.>v.>
+....vv>v..
+.v.>>>vvv.
+..v..>>vv.
+v.v...>>.v
+..v.....v>
+
+...
+
+After 30 steps:
+.vv.v..>>>
+v>...v...>
+>.v>.>vv.>
+>v>.>.>v.>
+.>..v.vv..
+..v>..>>v.
+....v>..>v
+v.v...>vv>
+v.v...>vvv
+
+...
+
+After 40 steps:
+>>v>v..v..
+..>>v..vv.
+..>>>v.>.v
+..>>>>vvv>
+v.....>...
+v.v...>v>>
+>vv.....v>
+.>v...v.>v
+vvv.v..v.>
+
+...
+
+After 50 steps:
+..>>v>vv.v
+..v.>>vv..
+v.>>v>>v..
+..>>>>>vv.
+vvv....>vv
+..v....>>>
+v>.......>
+.vv>....v>
+.>v.vv.v..
+
+...
+
+After 55 steps:
+..>>v>vv..
+..v.>>vv..
+..>>v>>vv.
+..>>>>>vv.
+v......>vv
+v>v....>>v
+vvv...>..>
+>vv.....>.
+.>v.vv.v..
+
+After 56 steps:
+..>>v>vv..
+..v.>>vv..
+..>>v>>vv.
+..>>>>>vv.
+v......>vv
+v>v....>>v
+vvv....>.>
+>vv......>
+.>v.vv.v..
+
+After 57 steps:
+..>>v>vv..
+..v.>>vv..
+..>>v>>vv.
+..>>>>>vv.
+v......>vv
+v>v....>>v
+vvv.....>>
+>vv......>
+.>v.vv.v..
+
+After 58 steps:
+..>>v>vv..
+..v.>>vv..
+..>>v>>vv.
+..>>>>>vv.
+v......>vv
+v>v....>>v
+vvv.....>>
+>vv......>
+.>v.vv.v..
+
+```
+
+In this example, the sea cucumbers stop moving after `*58*` steps.
+
+
+Find somewhere safe to land your submarine. *What is the first step on which no sea cucumbers move?*
+
+
+--- Part Two ---
+----------------
+
+Suddenly, the experimental antenna control console lights up:
+
+
+
+```
+*Sleigh keys detected!*
+```
+
+According to the console, the keys are *directly under the submarine*. You landed right on them! Using a robotic arm on the submarine, you move the sleigh keys into the airlock.
+
+
+Now, you just need to get them to Santa in time to save Christmas! You check your clock - it *is* Christmas. There's no way you can get them back to the surface in time.
+
+
+Just as you start to lose hope, you notice a button on the sleigh keys: *remote start*. You can start the sleigh from the bottom of the ocean! You just need some way to *boost the signal* from the keys so it actually reaches the sleigh. Good thing the submarine has that experimental antenna! You'll definitely need *50 stars* to boost it that far, though.
+
+
+The experimental antenna control console lights up again:
+
+
+
+```
+*Energy source detected.
+Integrating energy source from device "sleigh keys"...done.
+Installing device drivers...done.
+Recalibrating experimental antenna...done.
+Boost strength due to matching signal phase: *1 star**
+```
+
+Only *49 stars* to go.
+
+

+ 9 - 0
aoc2021/day25_sea_cucumber/example.txt

@@ -0,0 +1,9 @@
+v...>>.vv>
+.vv>>.vv..
+>>.>v>...v
+>>v>>.>.v.
+v>v.vv.v..
+>.>>..v...
+.vv..>.>v.
+v.v..>>v.v
+....v..v.>

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott