Mercurial > hg > aoc
comparison 2017/day08/problem @ 34:049fb8e56025
Add problem statements and inputs
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 09 Jan 2018 21:51:44 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
33:bc652fa0a645 | 34:049fb8e56025 |
---|---|
1 --- Day 8: I Heard You Like Registers --- | |
2 | |
3 You receive a signal directly from the CPU. Because of your recent | |
4 assistance with jump instructions, it would like you to compute the | |
5 result of a series of unusual register instructions. | |
6 | |
7 Each instruction consists of several parts: the register to modify, | |
8 whether to increase or decrease that register's value, the amount by | |
9 which to increase or decrease it, and a condition. If the condition | |
10 fails, skip the instruction without modifying the register. The | |
11 registers all start at 0. The instructions look like this: | |
12 | |
13 b inc 5 if a > 1 | |
14 a inc 1 if b < 5 | |
15 c dec -10 if a >= 1 | |
16 c inc -20 if c == 10 | |
17 | |
18 These instructions would be processed as follows: | |
19 | |
20 Because a starts at 0, it is not greater than 1, and so b is not | |
21 modified. | |
22 | |
23 a is increased by 1 (to 1) because b is less than 5 (it is 0). | |
24 | |
25 c is decreased by -10 (to 10) because a is now greater than or | |
26 equal to 1 (it is 1). | |
27 | |
28 c is increased by -20 (to -10) because c is equal to 10. | |
29 | |
30 After this process, the largest value in any register is 1. | |
31 | |
32 You might also encounter <= (less than or equal to) or != (not equal | |
33 to). However, the CPU doesn't have the bandwidth to tell you what all | |
34 the registers are named, and leaves that to you to determine. | |
35 | |
36 What is the largest value in any register after completing the | |
37 instructions in your puzzle input? | |
38 | |
39 Your puzzle answer was 4902. | |
40 | |
41 --- Part Two --- | |
42 | |
43 To be safe, the CPU also needs to know the highest value held in any | |
44 register during this process so that it can decide how much memory to | |
45 allocate to these operations. For example, in the above instructions, | |
46 the highest value ever held was 10 (in register c after the third | |
47 instruction was evaluated). | |
48 | |
49 Your puzzle answer was 7037. | |
50 | |
51 Both parts of this puzzle are complete! They provide two gold stars: ** |