--- /dev/null
+(module net.journcy.aoc2022.day03
+ {autoload {c net.journcy.aoc2022.common}})
+
+; a-z (97-122) -> 1-26
+; A-Z (65-90) -> 27-52
+(defn item->priority [item]
+ (let [ord (- (string.byte item) 64)]
+ (if (> ord 26)
+ (- ord 32)
+ (+ ord 26))))
+
+(defn errorcheck [rucksack]
+ (let [len (# rucksack)
+ half (/ len 2)
+ first (string.sub rucksack 1 half)
+ second (string.sub rucksack (- half))
+ same (c.head (c.intersect (c.split first "") (c.split second "")))]
+ (item->priority same)))
+
+(defn badgecheck [sacks]
+ (->> sacks
+ (c.map #(c.split $1 ""))
+ (c.reduce c.intersect)
+ c.head
+ item->priority))
+
+(comment
+ (c.intersect ["v" "J" "r" "w" "p" "W" "t" "w" "J" "g" "W" "r"]
+ ["h" "c" "s" "F" "M" "M" "f" "F" "F" "h" "F" "p"])
+ (c.map errorcheck
+ ["vJrwpWtwJgWrhcsFMMfFFhFp"
+ "jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL"
+ "PmmdzqPrVvPwwTWBwg"
+ "wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn"
+ "ttgJtRGJQctTZtZT"
+ "CrZsJsPPZsGzwwsLwLmpwMDw"])
+ (badgecheck ["vJrwpWtwJgWrhcsFMMfFFhFp"
+ "jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL"
+ "PmmdzqPrVvPwwTWBwg"])
+ (c.map badgecheck
+ (c.partition
+ ["vJrwpWtwJgWrhcsFMMfFFhFp"
+ "jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL"
+ "PmmdzqPrVvPwwTWBwg"
+ "wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn"
+ "ttgJtRGJQctTZtZT"
+ "CrZsJsPPZsGzwwsLwLmpwMDw"]
+ 3)))
+
+(defn part1 [lines]
+ (->> lines
+ (c.map errorcheck)
+ c.sum))
+
+(defn part2 [lines]
+ (let [parts (c.partition lines 3)]
+ (c.sum (c.map badgecheck parts))))
+
+(comment
+ (part1 (c.lines "input/day03.txt"))
+ (part2 (c.lines "input/day03.txt")))