This commit is contained in:
Rupus Reinefjord 2022-12-06 19:17:14 +01:00
parent dd98983ab3
commit 93c1db7b57

12
2022/day06.nim Normal file
View file

@ -0,0 +1,12 @@
proc decode(data: string, unique: int): int =
for i in 0..data.high:
block inner:
let chars = data[i..i + unique - 1]
for j in 0..unique - 2:
if chars[j] in chars[j+1..^1]:
break inner
return i + unique
let data = stdin.readAll()
echo decode(data, 4)
echo decode(data, 14)