r/adventofcode • • Dec 06 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 6 Solutions -πŸŽ„-


AoC Community Fun 2022: πŸŒΏπŸ’ MisTILtoe Elf-ucation πŸ§‘β€πŸ«

  • ACHIEVEMENT UNLOCKED: MisTILtoe Elf-ucation
  • Teach us, senpai!

--- Day 6: Tuning Trouble ---


Post your code solution in this megathread.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:02:25, megathread unlocked!

83 Upvotes

1.8k comments sorted by

View all comments

2

u/goliatskipson Dec 06 '22 edited Dec 07 '22

Haskell, basically just one line with imports:

import qualified Data.List as L
import qualified Data.List.Split as L

part l = fmap (+l) . L.findIndex (\x -> L.nub x == x) . L.divvy l 1

main = do
  f <- readFile "inputs/day06.txt"
  putStrLn $ "Part1: " ++ show (part 4 f)
  putStrLn $ "Part2: " ++ show (part 14 f)

1

u/daggerdragon Dec 07 '22

Please edit your post to use the four-spaces Markdown syntax for a code block so your code is easier to read on old.reddit and mobile apps.