File tree Expand file tree Collapse file tree 2 files changed +5
-14
lines changed
Expand file tree Collapse file tree 2 files changed +5
-14
lines changed Original file line number Diff line number Diff line change 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 |
9393| [ Day 4: The Ideal Stocking Stuffer] ( src/solutions/year2015/day04.rs ) | ⭐⭐ | 66.769 | 1931.428 |
94- | [ Day 5: Doesn't He Have Intern-Elves For This?] ( src/solutions/year2015/day05.rs ) | ⭐⭐ | 0.261 | 3.733 |
94+ | [ Day 5: Doesn't He Have Intern-Elves For This?] ( src/solutions/year2015/day05.rs ) | ⭐⭐ | 0.261 | 0.987 |
9595
9696# TODO
9797
Original file line number Diff line number Diff line change @@ -48,19 +48,10 @@ impl Day05 {
4848 }
4949
5050 fn pair_twice ( & self , word : & str ) -> bool {
51- let vec = word. chars ( ) . collect_vec ( ) ;
52-
53- for ( i, w) in vec. windows ( 2 ) . enumerate ( ) {
54- let pair = format ! ( "{}{}" , w[ 0 ] , w[ 1 ] ) ;
55-
56- for j in i + 2 ..vec. len ( ) - 1 {
57- if pair == format ! ( "{}{}" , vec[ j] , vec[ j + 1 ] ) {
58- return true ;
59- }
60- }
61- }
62-
63- false
51+ word. chars ( ) . tuple_windows ( ) . any ( |( c1, c2) | {
52+ let pair = format ! ( "{}{}" , c1, c2) ;
53+ word. matches ( & pair) . count ( ) >= 2
54+ } )
6455 }
6556
6657 fn repeated_with_letter_between ( & self , word : & str ) -> bool {
You can’t perform that action at this time.
0 commit comments