Skip to content

Instantly share code, notes, and snippets.

@mjgpy3
mjgpy3 / p1.hs
Created December 5, 2020 18:04
aoc-2020-day5
module Main where
import Data.List (foldl')
parseBinary = foldl' (\acc v -> acc*2 + (if v then 1 else 0)) 0
seatId = parseBinary . map (`elem` "BR")
main = do
raw <- readFile "./d5.txt"
@mjgpy3
mjgpy3 / p1.hs
Last active December 4, 2020 17:41
aoc-2020-day4
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.Text.IO as TIO
import qualified Data.Text as T
passportTexts = T.splitOn "\n\n"
required =
@mjgpy3
mjgpy3 / p1.hs
Created December 3, 2020 09:49
aoc-2020-day3.hs
module Main where
import qualified Data.Map.Strict as M
import Data.List (unfoldr)
import Control.Monad (guard)
input = [
"....#...............#.#..###.##",
-- etc...
]
@mjgpy3
mjgpy3 / aoc-2019-d4p2.hs
Created December 2, 2020 22:11
aoc-2019-d4p2.hs
module D4 where
import Control.Monad (guard)
import Data.List (group)
s = 147981
e = 691423
exTwoAdj = elem 2 . map length . group . show
@mjgpy3
mjgpy3 / p1.hs
Created December 2, 2020 11:11
aoc-2020-day2.hs
module Main where
input =
[
-- Use vim `s/...` to make input look like this
(9, 10, 'm', "mmmmnxmmmwm"),
-- ...
]
isValidPassword (min, max, needle, hay) =
@mjgpy3
mjgpy3 / alphabet.ml
Created October 10, 2020 03:01
alphabet.ml
open Base;;
let dependencies (sorted_words: string list): (char, char Hash_set.t) Hashtbl.t =
let
(* For now assume Latin chars from English alphabet.
This could certainly be more clever but isn't really the heart of the problem. *)
graph = Hashtbl.create ~growth_allowed:true ~size:26 (module Char)
in
let
same_first_char a b = String.equal (String.prefix a 1) (String.prefix b 1)
@mjgpy3
mjgpy3 / links.red
Created June 13, 2020 14:28
Red Links
@mjgpy3
mjgpy3 / keybase.md
Created March 20, 2020 14:51
keybase.md

Keybase proof

I hereby claim:

  • I am mjgpy3 on github.
  • I am mjgpy3 (https://keybase.io/mjgpy3) on keybase.
  • I have a public key ASB0SpzTI-dWtTIyPmCKHIwrv9fRhEqDbDbcqsZjlM85SAo

To claim this, I am signing this object:

@mjgpy3
mjgpy3 / reminder.sh
Created October 24, 2019 00:05
Reminder for bashrc
if [ $(date +%s) -ge $(date -d 2019-11-01 +%s) ];
then
notify-send "Check out this cool thing!"
fi