day06
This commit is contained in:
parent
dd98983ab3
commit
93c1db7b57
1 changed files with 12 additions and 0 deletions
12
2022/day06.nim
Normal file
12
2022/day06.nim
Normal 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)
|
Loading…
Add table
Reference in a new issue