It was nice to see some of the same faces (as it were) again from last year!
Also great to see more Haskell solutions, and props to those crazy enough to write in J and Uiua.
It was nice to see some of the same faces (as it were) again from last year!
Also great to see more Haskell solutions, and props to those crazy enough to write in J and Uiua.
A total inability to write code correctly today slowed me down a bit, but I got there in the end. Merry Christmas, everyone <3
import Data.Either
import Data.List
import Data.List.Split
readInput = partitionEithers . map readEntry . splitOn [""] . lines
where
readEntry ls =
(if head (head ls) == '#' then Left else Right)
. map (length . head . group)
$ transpose ls
main = do
(locks, keys) <- readInput <$> readFile "input25"
print . length $ filter (and . uncurry (zipWith (<=))) ((,) <$> locks <*> keys)
Most people would use “word”, “half-word”, “quarter-word” etc, but the Anglophiles insist on “tuppit”, “ternary piece”, “span” and “chunk” (that’s 5 bits, or 12 old bits).
TDD
const max12 = (x, y) => {
if (x === 1 && y === 2) {
return 2;
} else if (x === 7 && y === 4) {
return 7;
} else {
return x;
}
};
Um, actually… A signed 32-bit counter would loop back to December 1901, so the calendar is presumably 31-bit unsigned. (Sorry)
I agree with 15: I solved it pretty quickly and I like my solution, but what makes me really happy is that I’m pretty sure I couldn’t have solved it a few years ago.
Also day 11 (Plutonian pebbles): it’s such a simple problem, and part two is a perfect example of how and why to use dynamic programming. I’ve been encouraging everyone to try it.