move to 2022/

This commit is contained in:
Rupus Reinefjord 2022-12-01 19:41:19 +01:00
parent fa059dde06
commit 79066fb583

18
2022/day-01/solve.nim Normal file
View file

@ -0,0 +1,18 @@
import std/[algorithm, math, os, strutils, sugar]
let lst = stdin.readAll().strip()
let elves = lst.split("\n\n")
var totals = collect:
for elf in elves:
let elfInts = collect:
for cal in elf.split("\n"):
parseInt(cal)
sum(elfInts)
totals.sort(order = Descending)
if paramStr(1) == "1":
echo totals[0]
elif paramStr(1) == "2":
echo sum(totals[0..2])