aoc2023/day15.quox

27 lines
672 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 × ))))