[DOC] Some more comments to explain why this works

This commit is contained in:
2023-12-11 23:19:32 +01:00
parent d1a50a8d18
commit 52b2a4f1af

View File

@@ -97,7 +97,7 @@ impl DaySolver for Day8 {
}
}
// println!("Start node {}, after {}: {:?}", start_node, i, end_times);
// println!("Start node {}, after {} with period {}: {:?}", start_node, i, end_times[1]-end_times[0], end_times);
periods_per_start_node.push(Period {
start: BigInt::from(end_times[0]),
repeat: BigInt::from(end_times[1] - end_times[0])
@@ -106,6 +106,7 @@ impl DaySolver for Day8 {
// Now we just need to find out when these periods fall at the same time
// This appears to be the LCM of all periods
// This only works because the period and start are the same for each sequence we got...
let mut solution_period: Period = periods_per_start_node.first().unwrap().to_owned();
for period in periods_per_start_node.iter().skip(1) {
solution_period = Period {
@@ -113,7 +114,6 @@ impl DaySolver for Day8 {
repeat: solution_period.repeat.lcm(&period.repeat)
};
}
// note: I don't understand why we can just ignore how long it takes to get to the end the first time...
// let mut i = 0usize;
//