aoc2023/day15.quox

28 lines
672 B
Text
Raw Normal View History

load "bool.quox"
load "nat.quox"
load "string.quox"
load "list.quox"
load "io.quox"
def hash : ω.String → =
letω hash1 : ω. → ω.Char → =
λ n c ⇒ case char.ws? c return of {
'true ⇒ n;
'false ⇒ nat.mod (nat.times 17 (nat.plus (char.to- c) n)) 256
} in
string.foldlω 0 hash1
def split : ω.String → List String =
letω comma = char.from- 0x2C in
string.split (char.eq comma)
#[main]
def part1 =
io.bindω String True
(io.read-fileω "in/day15")
(λ s ⇒ io.dump (list.sum (list.mapω String hash (split s))))
def0 ShittyHashMap = Vec 8 (Vec 8 (Vec 8 (List (String × ))))