Skip to content

Reflections 2026

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

2016 / 2018 / 2019 / 2020 / 2021 / 2022 / 2023 / 2024 / 2025 / 2026

Table of Contents

Day 1

Top / Prompt / Code / Standalone

Wow am I washed :) Some silly mistakes I made:

  1. Parsed as Double instead of Int even though Double never shows up in Advent of Code.
  2. Calculated the sum of the first three frequencies instead of the product
  3. Found the product of the three least common instead of the three most common.

All of these silly mistakes motivate me to get back in practice haha. The struggle is real.

Anyway in Haskell this is pretty simple, it reads the same in bash or any other text processing language probably. Parsing is lines, and you can find the freq list using Data.Map.fromListWith (+). And the difference between Part 1 and Part 2 is just the order that you sort the frequencies before you sum them.

import Data.Map qualified as M

-- | List of codes and their frequencies
freqList :: String -> [(String, Int)]
freqList = M.toList . M.fromListWith (+) . map (,1) . lines

part1 :: String -> Int
part1 = product . map (read . fst) . take 3 . sortOn (Down . snd) . freqList

part2 :: String -> Int
part2 = product . map (read . fst) . take 3 . sortOn snd . freqList

Day 1 Benchmarks

>> Day 01a
benchmarking...
time                 11.42 μs   (11.37 μs .. 11.51 μs)
                     1.000 R²   (0.999 R² .. 1.000 R²)
mean                 11.40 μs   (11.36 μs .. 11.48 μs)
std dev              175.0 ns   (81.19 ns .. 303.6 ns)
variance introduced by outliers: 12% (moderately inflated)

* parsing and formatting times excluded

>> Day 01b
benchmarking...
time                 10.45 μs   (10.27 μs .. 10.71 μs)
                     0.998 R²   (0.997 R² .. 1.000 R²)
mean                 10.31 μs   (10.25 μs .. 10.44 μs)
std dev              270.6 ns   (85.08 ns .. 453.2 ns)
variance introduced by outliers: 29% (moderately inflated)

* parsing and formatting times excluded

Clone this wiki locally