File tree 8 files changed +85
-0
lines changed
8 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 267
267
| 22 | [ Grid Computing] ( https://adventofcode.com/2016/day/22 ) | [ Source] ( src/year2016/day22.rs ) | 31 |
268
268
| 23 | [ Safe Cracking] ( https://adventofcode.com/2016/day/23 ) | [ Source] ( src/year2016/day23.rs ) | 1 |
269
269
| 24 | [ Air Duct Spelunking] ( https://adventofcode.com/2016/day/24 ) | [ Source] ( src/year2016/day24.rs ) | 335 |
270
+ | 25 | [ Clock Signal] ( https://adventofcode.com/2016/day/25 ) | [ Source] ( src/year2016/day25.rs ) | 1 |
270
271
271
272
## 2015
272
273
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ mod year2016 {
88
88
benchmark ! ( year2016, day22) ;
89
89
benchmark ! ( year2016, day23) ;
90
90
benchmark ! ( year2016, day24) ;
91
+ benchmark ! ( year2016, day25) ;
91
92
}
92
93
93
94
mod year2019 {
Original file line number Diff line number Diff line change
1
+ cpy a d
2
+ cpy 4 c
3
+ cpy 633 b
4
+ inc d
5
+ dec b
6
+ jnz b -2
7
+ dec c
8
+ jnz c -5
9
+ cpy d a
10
+ jnz 0 0
11
+ cpy a b
12
+ cpy 0 a
13
+ cpy 2 c
14
+ jnz b 2
15
+ jnz 1 6
16
+ dec b
17
+ dec c
18
+ jnz c -4
19
+ inc a
20
+ jnz 1 -7
21
+ cpy 2 b
22
+ jnz c 2
23
+ jnz 1 4
24
+ dec b
25
+ dec c
26
+ jnz 1 -4
27
+ jnz 0 0
28
+ out b
29
+ jnz a -19
30
+ jnz 1 -21
Original file line number Diff line number Diff line change @@ -215,6 +215,7 @@ pub mod year2016 {
215
215
pub mod day22;
216
216
pub mod day23;
217
217
pub mod day24;
218
+ pub mod day25;
218
219
}
219
220
220
221
/// # Rescue Santa from deep space with a solar system adventure.
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ fn all_solutions() -> Vec<Solution> {
126
126
solution!( year2016, day22) ,
127
127
solution!( year2016, day23) ,
128
128
solution!( year2016, day24) ,
129
+ solution!( year2016, day25) ,
129
130
// 2019
130
131
solution!( year2019, day01) ,
131
132
solution!( year2019, day02) ,
Original file line number Diff line number Diff line change
1
+ //! # Clock Signal
2
+ //!
3
+ //! Like [`Day 12`] and [`Day 23`] this problem is all about *reading* code not writing code.
4
+ //!
5
+ //! Reverse engineering the code shows that it takes the initial value of `a` then adds
6
+ //! two constants multiplied by each other to create a seed.
7
+ //!
8
+ //! This seed is then repeatedly bit shifted right by dividing by 2 using an inefficient linear
9
+ //! time loop. The remainder (the bit that drops off) is the output. This means that output
10
+ //! sequence is simply the binary digits of `a + offset` in reverse repeated over and over.
11
+ //!
12
+ //! To obtain the desired pattern we need the next highest binary number that has the
13
+ //! pattern `101010..`.
14
+ //!
15
+ //! [`Day 12`]: crate::year2016::day12
16
+ //! [`Day 23`]: crate::year2016::day23
17
+ use crate :: util:: parse:: * ;
18
+
19
+ /// Extract the constant offset from the assembunny code.
20
+ pub fn parse ( input : & str ) -> u32 {
21
+ let lines: Vec < _ > = input. lines ( ) . collect ( ) ;
22
+ let first: u32 = lines[ 1 ] . unsigned ( ) ;
23
+ let second: u32 = lines[ 2 ] . unsigned ( ) ;
24
+ first * second
25
+ }
26
+
27
+ pub fn part1 ( input : & u32 ) -> u32 {
28
+ let offset = * input;
29
+ let mut result = 0 ;
30
+
31
+ // Find the next number with binary pattern `101010..` greater than the input.
32
+ while result < offset {
33
+ result = ( result << 2 ) | 2 ;
34
+ }
35
+
36
+ result - offset
37
+ }
38
+
39
+ pub fn part2 ( _input : & u32 ) -> & ' static str {
40
+ "n/a"
41
+ }
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ mod year2016 {
81
81
mod day22_test;
82
82
mod day23_test;
83
83
mod day24_test;
84
+ mod day25_test;
84
85
}
85
86
86
87
mod year2019 {
Original file line number Diff line number Diff line change
1
+ #[ test]
2
+ fn part1_test ( ) {
3
+ // No example data
4
+ }
5
+
6
+ #[ test]
7
+ fn part2_test ( ) {
8
+ // No example data
9
+ }
You can’t perform that action at this time.
0 commit comments