description.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. --- Day 11: Monkey in the Middle ---
  2. As you finally start making your way upriver, you realize your pack is much lighter than you remember. Just then, one of the items from your pack goes flying overhead. Monkeys are playing Keep Away with your missing things!
  3. To get your stuff back, you need to be able to predict where the monkeys will throw your items. After some careful observation, you realize the monkeys operate based on how worried you are about each item.
  4. You take some notes (your puzzle input) on the items each monkey currently has, how worried you are about those items, and how the monkey makes decisions based on your worry level. For example:
  5. Monkey 0:
  6. Starting items: 79, 98
  7. Operation: new = old * 19
  8. Test: divisible by 23
  9. If true: throw to monkey 2
  10. If false: throw to monkey 3
  11. Monkey 1:
  12. Starting items: 54, 65, 75, 74
  13. Operation: new = old + 6
  14. Test: divisible by 19
  15. If true: throw to monkey 2
  16. If false: throw to monkey 0
  17. Monkey 2:
  18. Starting items: 79, 60, 97
  19. Operation: new = old * old
  20. Test: divisible by 13
  21. If true: throw to monkey 1
  22. If false: throw to monkey 3
  23. Monkey 3:
  24. Starting items: 74
  25. Operation: new = old + 3
  26. Test: divisible by 17
  27. If true: throw to monkey 0
  28. If false: throw to monkey 1
  29. Each monkey has several attributes:
  30. Starting items lists your worry level for each item the monkey is currently holding in the order they will be inspected.
  31. Operation shows how your worry level changes as that monkey inspects an item. (An operation like new = old * 5 means that your worry level after the monkey inspected the item is five times whatever your worry level was before inspection.)
  32. Test shows how the monkey uses your worry level to decide where to throw an item next.
  33. If true shows what happens with an item if the Test was true.
  34. If false shows what happens with an item if the Test was false.
  35. After each monkey inspects an item but before it tests your worry level, your relief that the monkey's inspection didn't damage the item causes your worry level to be divided by three and rounded down to the nearest integer.
  36. The monkeys take turns inspecting and throwing items. On a single monkey's turn, it inspects and throws all of the items it is holding one at a time and in the order listed. Monkey 0 goes first, then monkey 1, and so on until each monkey has had one turn. The process of each monkey taking a single turn is called a round.
  37. When a monkey throws an item to another monkey, the item goes on the end of the recipient monkey's list. A monkey that starts a round with no items could end up inspecting and throwing many items by the time its turn comes around. If a monkey is holding no items at the start of its turn, its turn ends.
  38. In the above example, the first round proceeds as follows:
  39. Monkey 0:
  40. Monkey inspects an item with a worry level of 79.
  41. Worry level is multiplied by 19 to 1501.
  42. Monkey gets bored with item. Worry level is divided by 3 to 500.
  43. Current worry level is not divisible by 23.
  44. Item with worry level 500 is thrown to monkey 3.
  45. Monkey inspects an item with a worry level of 98.
  46. Worry level is multiplied by 19 to 1862.
  47. Monkey gets bored with item. Worry level is divided by 3 to 620.
  48. Current worry level is not divisible by 23.
  49. Item with worry level 620 is thrown to monkey 3.
  50. Monkey 1:
  51. Monkey inspects an item with a worry level of 54.
  52. Worry level increases by 6 to 60.
  53. Monkey gets bored with item. Worry level is divided by 3 to 20.
  54. Current worry level is not divisible by 19.
  55. Item with worry level 20 is thrown to monkey 0.
  56. Monkey inspects an item with a worry level of 65.
  57. Worry level increases by 6 to 71.
  58. Monkey gets bored with item. Worry level is divided by 3 to 23.
  59. Current worry level is not divisible by 19.
  60. Item with worry level 23 is thrown to monkey 0.
  61. Monkey inspects an item with a worry level of 75.
  62. Worry level increases by 6 to 81.
  63. Monkey gets bored with item. Worry level is divided by 3 to 27.
  64. Current worry level is not divisible by 19.
  65. Item with worry level 27 is thrown to monkey 0.
  66. Monkey inspects an item with a worry level of 74.
  67. Worry level increases by 6 to 80.
  68. Monkey gets bored with item. Worry level is divided by 3 to 26.
  69. Current worry level is not divisible by 19.
  70. Item with worry level 26 is thrown to monkey 0.
  71. Monkey 2:
  72. Monkey inspects an item with a worry level of 79.
  73. Worry level is multiplied by itself to 6241.
  74. Monkey gets bored with item. Worry level is divided by 3 to 2080.
  75. Current worry level is divisible by 13.
  76. Item with worry level 2080 is thrown to monkey 1.
  77. Monkey inspects an item with a worry level of 60.
  78. Worry level is multiplied by itself to 3600.
  79. Monkey gets bored with item. Worry level is divided by 3 to 1200.
  80. Current worry level is not divisible by 13.
  81. Item with worry level 1200 is thrown to monkey 3.
  82. Monkey inspects an item with a worry level of 97.
  83. Worry level is multiplied by itself to 9409.
  84. Monkey gets bored with item. Worry level is divided by 3 to 3136.
  85. Current worry level is not divisible by 13.
  86. Item with worry level 3136 is thrown to monkey 3.
  87. Monkey 3:
  88. Monkey inspects an item with a worry level of 74.
  89. Worry level increases by 3 to 77.
  90. Monkey gets bored with item. Worry level is divided by 3 to 25.
  91. Current worry level is not divisible by 17.
  92. Item with worry level 25 is thrown to monkey 1.
  93. Monkey inspects an item with a worry level of 500.
  94. Worry level increases by 3 to 503.
  95. Monkey gets bored with item. Worry level is divided by 3 to 167.
  96. Current worry level is not divisible by 17.
  97. Item with worry level 167 is thrown to monkey 1.
  98. Monkey inspects an item with a worry level of 620.
  99. Worry level increases by 3 to 623.
  100. Monkey gets bored with item. Worry level is divided by 3 to 207.
  101. Current worry level is not divisible by 17.
  102. Item with worry level 207 is thrown to monkey 1.
  103. Monkey inspects an item with a worry level of 1200.
  104. Worry level increases by 3 to 1203.
  105. Monkey gets bored with item. Worry level is divided by 3 to 401.
  106. Current worry level is not divisible by 17.
  107. Item with worry level 401 is thrown to monkey 1.
  108. Monkey inspects an item with a worry level of 3136.
  109. Worry level increases by 3 to 3139.
  110. Monkey gets bored with item. Worry level is divided by 3 to 1046.
  111. Current worry level is not divisible by 17.
  112. Item with worry level 1046 is thrown to monkey 1.
  113. After round 1, the monkeys are holding items with these worry levels:
  114. Monkey 0: 20, 23, 27, 26
  115. Monkey 1: 2080, 25, 167, 207, 401, 1046
  116. Monkey 2:
  117. Monkey 3:
  118. Monkeys 2 and 3 aren't holding any items at the end of the round; they both inspected items during the round and threw them all before the round ended.
  119. This process continues for a few more rounds:
  120. After round 2, the monkeys are holding items with these worry levels:
  121. Monkey 0: 695, 10, 71, 135, 350
  122. Monkey 1: 43, 49, 58, 55, 362
  123. Monkey 2:
  124. Monkey 3:
  125. After round 3, the monkeys are holding items with these worry levels:
  126. Monkey 0: 16, 18, 21, 20, 122
  127. Monkey 1: 1468, 22, 150, 286, 739
  128. Monkey 2:
  129. Monkey 3:
  130. After round 4, the monkeys are holding items with these worry levels:
  131. Monkey 0: 491, 9, 52, 97, 248, 34
  132. Monkey 1: 39, 45, 43, 258
  133. Monkey 2:
  134. Monkey 3:
  135. After round 5, the monkeys are holding items with these worry levels:
  136. Monkey 0: 15, 17, 16, 88, 1037
  137. Monkey 1: 20, 110, 205, 524, 72
  138. Monkey 2:
  139. Monkey 3:
  140. After round 6, the monkeys are holding items with these worry levels:
  141. Monkey 0: 8, 70, 176, 26, 34
  142. Monkey 1: 481, 32, 36, 186, 2190
  143. Monkey 2:
  144. Monkey 3:
  145. After round 7, the monkeys are holding items with these worry levels:
  146. Monkey 0: 162, 12, 14, 64, 732, 17
  147. Monkey 1: 148, 372, 55, 72
  148. Monkey 2:
  149. Monkey 3:
  150. After round 8, the monkeys are holding items with these worry levels:
  151. Monkey 0: 51, 126, 20, 26, 136
  152. Monkey 1: 343, 26, 30, 1546, 36
  153. Monkey 2:
  154. Monkey 3:
  155. After round 9, the monkeys are holding items with these worry levels:
  156. Monkey 0: 116, 10, 12, 517, 14
  157. Monkey 1: 108, 267, 43, 55, 288
  158. Monkey 2:
  159. Monkey 3:
  160. After round 10, the monkeys are holding items with these worry levels:
  161. Monkey 0: 91, 16, 20, 98
  162. Monkey 1: 481, 245, 22, 26, 1092, 30
  163. Monkey 2:
  164. Monkey 3:
  165. ...
  166. After round 15, the monkeys are holding items with these worry levels:
  167. Monkey 0: 83, 44, 8, 184, 9, 20, 26, 102
  168. Monkey 1: 110, 36
  169. Monkey 2:
  170. Monkey 3:
  171. ...
  172. After round 20, the monkeys are holding items with these worry levels:
  173. Monkey 0: 10, 12, 14, 26, 34
  174. Monkey 1: 245, 93, 53, 199, 115
  175. Monkey 2:
  176. Monkey 3:
  177. Chasing all of the monkeys at once is impossible; you're going to have to focus on the two most active monkeys if you want any hope of getting your stuff back. Count the total number of times each monkey inspects items over 20 rounds:
  178. Monkey 0 inspected items 101 times.
  179. Monkey 1 inspected items 95 times.
  180. Monkey 2 inspected items 7 times.
  181. Monkey 3 inspected items 105 times.
  182. In this example, the two most active monkeys inspected items 101 and 105 times. The level of monkey business in this situation can be found by multiplying these together: 10605.
  183. Figure out which monkeys to chase by counting how many items they inspect over 20 rounds. What is the level of monkey business after 20 rounds of stuff-slinging simian shenanigans?
  184. Your puzzle answer was 76728.
  185. --- Part Two ---
  186. You're worried you might not ever get your items back. So worried, in fact, that your relief that a monkey's inspection didn't damage an item no longer causes your worry level to be divided by three.
  187. Unfortunately, that relief was all that was keeping your worry levels from reaching ridiculous levels. You'll need to find another way to keep your worry levels manageable.
  188. At this rate, you might be putting up with these monkeys for a very long time - possibly 10000 rounds!
  189. With these new rules, you can still figure out the monkey business after 10000 rounds. Using the same example above:
  190. == After round 1 ==
  191. Monkey 0 inspected items 2 times.
  192. Monkey 1 inspected items 4 times.
  193. Monkey 2 inspected items 3 times.
  194. Monkey 3 inspected items 6 times.
  195. == After round 20 ==
  196. Monkey 0 inspected items 99 times.
  197. Monkey 1 inspected items 97 times.
  198. Monkey 2 inspected items 8 times.
  199. Monkey 3 inspected items 103 times.
  200. == After round 1000 ==
  201. Monkey 0 inspected items 5204 times.
  202. Monkey 1 inspected items 4792 times.
  203. Monkey 2 inspected items 199 times.
  204. Monkey 3 inspected items 5192 times.
  205. == After round 2000 ==
  206. Monkey 0 inspected items 10419 times.
  207. Monkey 1 inspected items 9577 times.
  208. Monkey 2 inspected items 392 times.
  209. Monkey 3 inspected items 10391 times.
  210. == After round 3000 ==
  211. Monkey 0 inspected items 15638 times.
  212. Monkey 1 inspected items 14358 times.
  213. Monkey 2 inspected items 587 times.
  214. Monkey 3 inspected items 15593 times.
  215. == After round 4000 ==
  216. Monkey 0 inspected items 20858 times.
  217. Monkey 1 inspected items 19138 times.
  218. Monkey 2 inspected items 780 times.
  219. Monkey 3 inspected items 20797 times.
  220. == After round 5000 ==
  221. Monkey 0 inspected items 26075 times.
  222. Monkey 1 inspected items 23921 times.
  223. Monkey 2 inspected items 974 times.
  224. Monkey 3 inspected items 26000 times.
  225. == After round 6000 ==
  226. Monkey 0 inspected items 31294 times.
  227. Monkey 1 inspected items 28702 times.
  228. Monkey 2 inspected items 1165 times.
  229. Monkey 3 inspected items 31204 times.
  230. == After round 7000 ==
  231. Monkey 0 inspected items 36508 times.
  232. Monkey 1 inspected items 33488 times.
  233. Monkey 2 inspected items 1360 times.
  234. Monkey 3 inspected items 36400 times.
  235. == After round 8000 ==
  236. Monkey 0 inspected items 41728 times.
  237. Monkey 1 inspected items 38268 times.
  238. Monkey 2 inspected items 1553 times.
  239. Monkey 3 inspected items 41606 times.
  240. == After round 9000 ==
  241. Monkey 0 inspected items 46945 times.
  242. Monkey 1 inspected items 43051 times.
  243. Monkey 2 inspected items 1746 times.
  244. Monkey 3 inspected items 46807 times.
  245. == After round 10000 ==
  246. Monkey 0 inspected items 52166 times.
  247. Monkey 1 inspected items 47830 times.
  248. Monkey 2 inspected items 1938 times.
  249. Monkey 3 inspected items 52013 times.
  250. After 10000 rounds, the two most active monkeys inspected items 52166 and 52013 times. Multiplying these together, the level of monkey business in this situation is now 2713310158.
  251. Worry levels are no longer divided by three after each item is inspected; you'll need to find another way to keep your worry levels manageable. Starting again from the initial state in your puzzle input, what is the level of monkey business after 10000 rounds?
  252. Your puzzle answer was 21553910156.