Skip to content

Commit 71700c3

Browse files
committed
refactor(17/2024): simplify
1 parent 091021d commit 71700c3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
| [Day 14: Restroom Redoubt](src/solutions/year2024/day14.rs) | ⭐⭐ | 0.172 | 102.252 |
2828
| [Day 15: Warehouse Woes](src/solutions/year2024/day15.rs) | ⭐⭐ | 7.226 | 9.084 |
2929
| [Day 16: Reindeer Maze](src/solutions/year2024/day16.rs) | ⭐⭐ | 6.478 | 24.347 |
30-
| [Day 17: Chronospatial Computer](src/solutions/year2024/day17.rs) || 0.096 | - |
30+
| [Day 17: Chronospatial Computer](src/solutions/year2024/day17.rs) || 0.038 | - |
3131
| [Day 18: RAM Run](src/solutions/year2024/day18.rs) | ⭐⭐ | 2.487 | 204.885 |
3232
| [Day 19: Linen Layout](src/solutions/year2024/day19.rs) | ⭐⭐ | 2.923 | 22.751 |
3333
| [Day 20: Race Condition](src/solutions/year2024/day20.rs) | ⭐⭐ | 7.355 | 280.627 |

src/solutions/year2024/day17.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ impl Program {
6969
let mut instruction_pointer = 0;
7070
let mut output = Vec::new();
7171

72-
while let Some(opcode) = self.program.get(instruction_pointer) {
72+
while let Some([opcode, operand]) = self
73+
.program
74+
.get(instruction_pointer..=instruction_pointer + 1)
75+
{
7376
let operation = InstructionType::from(*opcode);
74-
let operand = self.program.get(instruction_pointer + 1).unwrap();
7577
let mut do_jump = true;
7678

7779
match operation {

0 commit comments

Comments
 (0)