File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 9797| [ Day 8: Matchsticks] ( src/solutions/year2015/day08.rs ) | ⭐⭐ | 0.052 | 0.129 |
9898| [ Day 9: All in a Single Night] ( src/solutions/year2015/day09.rs ) | ⭐⭐ | 34.320 | 34.850 |
9999| [ Day 10: Elves Look, Elves Say] ( src/solutions/year2015/day10.rs ) | ⭐⭐ | 2.099 | 32.258 |
100- | [ Day 11: Corporate Policy] ( src/solutions/year2015/day11.rs ) | ⭐⭐ | 0.543 | 19.202 |
100+ | [ Day 11: Corporate Policy] ( src/solutions/year2015/day11.rs ) | ⭐⭐ | 0.543 | 14.384 |
101101
102102# TODO
103103
Original file line number Diff line number Diff line change @@ -72,8 +72,11 @@ impl<const N: usize> Password<N> {
7272 i -= 1 ;
7373 continue ;
7474 } else {
75- //fixme: if current letter is ambiguous we can skip to the next (optimization)
76- chars[ i] += 1 ;
75+ if Self :: is_letter_ambiguous ( chars[ i] + 1 ) {
76+ chars[ i] += 2 ;
77+ } else {
78+ chars[ i] += 1 ;
79+ }
7780 break ;
7881 }
7982 }
@@ -94,14 +97,18 @@ impl<const N: usize> Password<N> {
9497
9598 fn not_contains_ambiguous_letters ( & self ) -> bool {
9699 for i in 0 ..N {
97- if self . chars [ i] == b'i' || self . chars [ i ] == b'o' || self . chars [ i ] == b'l' {
100+ if Self :: is_letter_ambiguous ( self . chars [ i] ) {
98101 return false ;
99102 }
100103 }
101104
102105 true
103106 }
104107
108+ fn is_letter_ambiguous ( char : u8 ) -> bool {
109+ char == b'i' || char == b'o' || char == b'l'
110+ }
111+
105112 fn contains_nonoverlapping_two_pairs ( & self ) -> bool {
106113 let mut i = 0 ;
107114 let mut pairs = 0 ;
You can’t perform that action at this time.
0 commit comments