Skip to content

Commit c27fea7

Browse files
committed
Add tailcall-notes to Day 6
1 parent a002ff4 commit c27fea7

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

Cargo.lock

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ edition = "2021"
88
[dependencies]
99
clap = { version = "4.4", features = ["derive"] }
1010
itertools = "0.14.0"
11-
rayon = "1.8"
11+
rayon = "1.8"
12+
tailcall = "1.0.1"

src/day06.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// - the 'functional' setup allows of trivial parallelization
77

88
use itertools::Itertools;
9+
use tailcall::tailcall;
910
use rayon::prelude::*;
1011
use std::collections::BTreeMap;
1112
use std::collections::HashMap;
@@ -391,6 +392,10 @@ impl Lines {
391392
}
392393
}
393394

395+
// see https://stackoverflow.com/q/59257543 etc
396+
// also check out what happens if the recursive call is replaced with
397+
// would_loop(...) == true
398+
#[tailcall]
394399
// Would this setup result in a loop?
395400
fn would_loop(
396401
guard: Guard,

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
3 => day03::day03(input),
2525
4 => day04::day04(input),
2626
5 => day05::day05(input),
27-
6 => day06::day06(input),
28-
_ => day07::day07(input),
27+
7 => day07::day07(input),
28+
_ => day06::day06(input),
2929
}
3030
}

0 commit comments

Comments
 (0)