Day 1: Dusty Shed

Megathread guidelines

  • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
  • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

FAQ

  • CameronDev@programming.devOPM
    link
    fedilink
    arrow-up
    5
    ·
    2 days ago

    Rust

            let input = include_str!("../../input/2026/day_1.txt");
            let mut recipes = HashMap::new();
            input
                .split('\n')
                .map(|line| line.parse::<u32>().unwrap())
                .for_each(|value| {
                    *recipes.get_or_set_with_mut(value, || 0) += 1;
                });
    
            let mut recipes = recipes.into_iter().collect::<Vec<(u32, i32)>>();
            recipes.sort_by_key(|a| -a.1);
    
            let result = recipes[0].0 * recipes[1].0 * recipes[2].0;
            println!("{result}");
    

    Probably non-optimal, but still 1ms, so good enough for me.

    Kinda bizarrely easy second task, only had to change one character.

    • CameronDev@programming.devOPM
      link
      fedilink
      arrow-up
      2
      arrow-down
      2
      ·
      1 day ago

      For shits and giggles I tried it on my local LLM agent, it took a small amount of prompting, but solved it in about 5 mins.

      The best part is this:

      It so confidently multiplied 3 numbers together and got the answer wrong… first set was correct somehow, second was completely hallucinated.