We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 012efb2 commit b6fd8bfCopy full SHA for b6fd8bf
readme.md
@@ -92,7 +92,7 @@
92
| [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 | 1931.428 |
94
| [Day 5: Doesn't He Have Intern-Elves For This?](src/solutions/year2015/day05.rs) | ⭐⭐ | 0.261 | 0.987 |
95
-| [Day 6: Probably a Fire Hazard](src/solutions/year2015/day06.rs) | ⭐ | 1227.077 | - |
+| [Day 6: Probably a Fire Hazard](src/solutions/year2015/day06.rs) | ⭐⭐ | 1227.077 | 1580.565 |
96
97
# TODO
98
src/solutions/year2015/day06.rs
@@ -112,7 +112,7 @@ impl Instruction for TurnOff {
112
}
113
114
fn apply_part_two(&self, grid: &mut Grid<u64>) {
115
- grid.modify_many_with(self.surface_range.points(), |b| *b = u64::max(*b - 1, 0))
+ grid.modify_many_with(self.surface_range.points(), |b| *b = if *b == 0 { 0 } else { *b - 1})
116
117
118
@@ -155,5 +155,14 @@ mod tests {
155
fn part_two_example_test() {
156
assert_eq!("1", Day06.part_two("turn on 0,0 through 0,0"));
157
assert_eq!("2000000", Day06.part_two("toggle 0,0 through 999,999"));
158
+ assert_eq!("7", Day06.part_two(r#"toggle 0,0 through 0,3
159
+ turn off 0,0 through 0,0"#));
160
+ assert_eq!("6", Day06.part_two(r#"toggle 0,0 through 0,3
161
+ turn off 0,0 through 0,0
162
163
164
165
166
167
168
0 commit comments