Skip to content

Commit ed6e976

Browse files
committed
Fix invalid diff list initialization
1 parent ea86110 commit ed6e976

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

day22/experiments/.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CompileFlags:
2+
Add: [-std=c++20]

day22/experiments/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ out:
88
mkdir -p $@
99

1010
out/day22: ./day22.cpp | out
11-
$(CXX) $< -ffast-math -fopenmp -O3 -std=c++11 -o $@
11+
$(CXX) $< -ffast-math -fopenmp -O3 -std=c++20 -o $@

day22/experiments/day22.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <cstdint>
33
#include <iostream>
44
#include <fstream>
5+
#include <optional>
56
#include <vector>
67

78
const int64_t LIMIT = 2000;
@@ -25,7 +26,7 @@ int64_t prng(int64_t secret, int64_t n) {
2526
}
2627

2728
int64_t monkey(int64_t secret, int64_t x1, int64_t x2, int64_t x3, int64_t x4) {
28-
int64_t d1 = -1, d2 = -1, d3 = -1, d4 = -1;
29+
std::optional<int64_t> d1, d2, d3, d4;
2930
for (int64_t i = 0; i < LIMIT; i++) {
3031
int64_t lastPrice = secret % 10;
3132
secret = next(secret);

day22/src/day22.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int prng(int secret, int n) {
2121
}
2222

2323
int monkey(int secret, int x1, int x2, int x3, int x4) {
24-
int d1 = -1, d2 = -1, d3 = -1, d4 = -1;
24+
int? d1 = null, d2 = null, d3 = null, d4 = null;
2525
for (var i = 0; i < LIMIT; i++) {
2626
int lastPrice = secret % 10;
2727
secret = next(secret);

0 commit comments

Comments
 (0)