File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 9393| [ Day 4: The Ideal Stocking Stuffer] ( src/solutions/year2015/day04.rs ) | ⭐⭐ | 66.769 | 1931.428 |
9494| [ Day 5: Doesn't He Have Intern-Elves For This?] ( src/solutions/year2015/day05.rs ) | ⭐⭐ | 0.261 | 0.987 |
9595| [ Day 6: Probably a Fire Hazard] ( src/solutions/year2015/day06.rs ) | ⭐⭐ | 871.538 | 817.533 |
96- | [ Day 7: Some Assembly Required] ( src/solutions/year2015/day07.rs ) | ⭐ | 0.308 | - |
96+ | [ Day 7: Some Assembly Required] ( src/solutions/year2015/day07.rs ) | ⭐⭐ | 0.308 | 0.293 |
9797
9898# TODO
9999
Original file line number Diff line number Diff line change @@ -11,18 +11,30 @@ impl Solution for Day07 {
1111 self . signal ( input, "a" )
1212 }
1313
14- fn part_two ( & self , _input : & str ) -> String {
15- String :: from ( "0" )
14+ fn part_two ( & self , input : & str ) -> String {
15+ let a_value = self . signal ( input, "a" ) ;
16+
17+ let mut instructions = self . parse ( input) ;
18+ instructions
19+ . entry ( "b" . to_string ( ) )
20+ . and_modify ( |v| * v = Instruction :: Value ( Value :: Numeric ( a_value. parse ( ) . unwrap ( ) ) ) ) ;
21+
22+ self . signal_for_instructions ( & instructions, "a" )
1623 }
1724}
1825
1926impl Day07 {
2027 fn signal ( & self , input : & str , wire : & str ) -> String {
2128 let instructions = self . parse ( input) ;
22- let main = instructions. get ( wire) . unwrap ( ) ;
29+
30+ self . signal_for_instructions ( & instructions, wire)
31+ }
32+
33+ fn signal_for_instructions ( & self , instructions : & Wires , wire : & str ) -> String {
2334 let mut cache = HashMap :: new ( ) ;
35+ let main = instructions. get ( wire) . unwrap ( ) ;
2436
25- main. calculate ( & instructions, & mut cache) . to_string ( )
37+ main. calculate ( instructions, & mut cache) . to_string ( )
2638 }
2739
2840 fn parse ( & self , input : & str ) -> Wires {
You can’t perform that action at this time.
0 commit comments