Skip to content

Commit edc6a5f

Browse files
committed
try ilog
1 parent 1163c68 commit edc6a5f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/bin/11.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type Stone = u64;
77
type Step = u8;
88

99
#[memoize]
10+
// have a memoize cache buster to fix timing multiple runs
1011
fn blink_rec(_cache_buster: u64, stone: Stone, times: Step) -> u64 {
1112
if times == 0 {
1213
return 1;
@@ -22,7 +23,8 @@ fn blink_rec(_cache_buster: u64, stone: Stone, times: Step) -> u64 {
2223
digit_count += 1;
2324
temp /= 10;
2425
}
25-
26+
// makes p1 2x slower but p2 0.2x faster
27+
// let digit_count = stone.checked_ilog10().unwrap_or(0);
2628
if digit_count % 2 == 0 {
2729
let divisor: u64 = 10_u64.pow(digit_count / 2);
2830
let (upper, lower) = stone.div_rem_euclid(&divisor);

0 commit comments

Comments
 (0)