Home • Up • Sign my Guestbook! • RSS • Published: 2026-12-01 • Updated: 2026-12-01

Advent of Code 2026


Day #01🔗

import Data.List ( sortOn )
import Data.Map qualified as Map

main :: IO ()
main =
  interact
    ( show
        . product
        . map fst
        . take 3
        . reverse -- comment out for Part 2
        . sortOn snd
        . Map.toList
        . Map.fromListWith (+)
        . fmap ((,1) . (read @Integer))
        . lines
    )

Day #02🔗

Part #01🔗

import Data.Bifunctor (Bifunctor (first))
import Data.List (sortOn)
import Data.Map qualified as Map

-- Spent a few minutes on this being roygbiv
-- because I play too much Paranoia
path = "roygbv" ++ path

advance :: Bool -> Char -> String -> (Integer, String)
advance frst to (here : path) =
  if (not frst) && to == here
    then (0, here : path)
    else first (+ 1) $ advance False to path

runProgram [] _ = 0
runProgram
  (inst : prog)
  path =
    let (steps, newPath) = advance True inst path
     in steps + runProgram prog newPath

main :: IO ()
main =
  interact
    ( show
        . (flip runProgram $ path)
        . head
        . lines
    )

Part #02🔗

After counting the occurences, we should always jump to ourselves otherwise to the next instruction before us in sequence. So we just exhaust 6-jumps for every instruction before jumping back one (or more if instructions don’t exist) instructions and repeating.

[('g',228),('o',146),('r',284),('v',161),('y',254)]
(+
 (* 6 284) ;; R
 5
 (* 6 160) ;; V - 1
 4
 (* 6 227) ;; G - 1
 5
 (* 6 253) ;; Y - 1
 5
 (* 6 145) ;; O - 1
)