Tootfinder

Opt-in global Mastodon full text search. Join the index!

@beeb@hachyderm.io
2023-12-07 09:14:12
Content warning:

Potential Advent of Code Day 7 spoiler in picture
That feeling when you implement all the traits...
#AdventOfCode #AdventOfCode2023 #AoC2023

    fn part_1(input: &Self
@beeb@hachyderm.io
2023-12-06 11:51:58
Content warning:

Advent of Code Day 6 spoiler in picture.
"Yeah Mr. White! Yeah! Science!"
#AdventOfCode #AoC2023 #AdventOfCode2023

fn winning_interval(race: &Race) -> RangeInclusive<u64> {
    // formula for winning the race: (t - x) * x > r, where t is the race total time and r is the previous record
    // this gives a lower bound of 0.5 * (t - sqrt(t^2 - 4*r)) and a higher bound of 0.5*(t + sqrt(t^2 - 4*r))
    let t = race.total_time as f64;
    let r = race.record_distance as f64;
    let sqrt = (t * t - 4. * r).sqrt();
    let mut low = 0.5 * (t - sqrt);
    let mut high = 0.5 * (t + sqrt);
    // since we have to go…
@rayres@social.linux.pizza
2023-12-02 14:45:38