diff --git a/2022/day3.nim b/2022/day3.nim new file mode 100644 index 0000000..0a0b31c --- /dev/null +++ b/2022/day3.nim @@ -0,0 +1,35 @@ +{.hint[name]: off.} # snake_case > camelCase +import sequtils +import strutils +import std/sets +import sugar + +let elves = split_lines strip read_file "input/3" + +proc get_priority(c: char): int = + if c in 'a'..'z': + return ord(c) - ord('a') + 1 + return ord(c) - ord('A') + 27 + +# Part 1 +proc part_1_score(line: string): int = + let halflen = len(line) shr 1 + var knapsack_1 = collect initHashSet: # Couldn't work out how to collect to set[char] + for c in line[0..