File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 9090| [ Day 1: Not Quite Lisp] ( src/solutions/year2015/day01.rs ) | ⭐⭐ | 0.013 | 0.001 |
9191| [ Day 2: I Was Told There Would Be No Math] ( src/solutions/year2015/day02.rs ) | ⭐⭐ | 0.074 | 0.105 |
9292| [ Day 3: Perfectly Spherical Houses in a Vacuum] ( src/solutions/year2015/day03.rs ) | ⭐⭐ | 0.358 | 0.373 |
93- | [ Day 4: The Ideal Stocking Stuffer] ( src/solutions/year2015/day04.rs ) | ⭐ | 66.769 | - |
93+ | [ Day 4: The Ideal Stocking Stuffer] ( src/solutions/year2015/day04.rs ) | ⭐⭐ | 66.769 | 1931.428 |
9494
9595# TODO
9696
Original file line number Diff line number Diff line change @@ -5,22 +5,28 @@ pub struct Day04;
55
66impl Solution for Day04 {
77 fn part_one ( & self , input : & str ) -> String {
8+ self . answer ( input, "00000" )
9+ }
10+
11+ fn part_two ( & self , input : & str ) -> String {
12+ self . answer ( input, "000000" )
13+ }
14+ }
15+
16+ impl Day04 {
17+ fn answer ( & self , input : & str , starts_with : & str ) -> String {
818 ( 0u64 ..)
919 . find ( |answer| {
1020 let hash = format ! ( "{}{}" , input, answer) ;
1121 let digest = compute ( hash) ;
1222
1323 let x = format ! ( "{:x}" , digest) ;
1424
15- x. starts_with ( "00000" )
25+ x. starts_with ( starts_with )
1626 } )
1727 . unwrap ( )
1828 . to_string ( )
1929 }
20-
21- fn part_two ( & self , _input : & str ) -> String {
22- String :: from ( "0" )
23- }
2430}
2531
2632#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments