1
0
www.mikescher.com/www/statics/aoc/2022/06_solution-2.nim

25 lines
605 B
Nim
Raw Permalink Normal View History

2022-12-06 08:27:04 +01:00
import std/strutils
import std/sequtils
proc run06_2(): string =
const input = staticRead"../input/day06.txt"
let chars = input.toSeq()
let idarr = (0 .. len(chars) - 14 - 1)
.toSeq()
.filter(proc(it: int):bool = chars[it .. it+ 3].deduplicate().len() == 4 )
.filter(proc(it: int):bool = chars[it .. it+13].deduplicate().len() == 14 )
#echo ""
#echo idarr
#echo ""
return intToStr(idarr[0] + 14)
when not defined(js):
echo run06_2()
else:
proc js_run06_2(): cstring {.exportc.} =
return cstring(run06_2())