Skip to content

Instantly share code, notes, and snippets.

View joncol's full-sized avatar

Jonas Collberg joncol

View GitHub Profile
@joncol
joncol / Day11.hs
Created December 11, 2024 20:19
AoC 2024, day 11, part 2
type HashTable s k v = C.HashTable s k v
type Stone = Int
type Memo s = HashTable s (Stone, Int) Int
solvePart2 :: BS.ByteString -> Result
solvePart2 contents =
Result $ runST $ do
memo :: Memo s <- H.new
@joncol
joncol / day17.py
Created December 20, 2024 09:44
Day 17, part 2
import itertools
program = [2, 4, 1, 3, 7, 5, 0, 3, 1, 5, 4, 1, 5, 5, 3, 0]
rp = list(reversed(program))
def calc(ta):
b = (ta & 0b111) ^ 0b011 # Look at the 3 rightmost bits of "ta"
c = (
@joncol
joncol / Main.hs
Last active December 30, 2024 19:57
ImGui + SDL z-order
module Main (main) where
import Control.Exception (bracket, bracket_)
import Control.Monad (unless, when)
import Control.Monad.IO.Class ()
import Control.Monad.Managed
import DearImGui
import DearImGui.OpenGL3
import DearImGui.SDL
import DearImGui.SDL.Renderer
main :: IO ()
main = do
evalContT $ do
a <- ContT $ withFile "a.txt" ReadMode
b <- ContT $ withFile "b.txt" ReadMode
aContents <- liftIO $ hGetContents a
bContents <- liftIO $ hGetContents b
liftIO . putStrLn $ "contents of a: " <> show aContents
liftIO . putStrLn $ "contents of b: " <> show bContents