import std/[strutils, algorithm, sequtils] import aoc proc parseInput(input: string): seq[seq[int]] = for line in input.splitLines(): result.add line.splitWhitespace().mapIt(parseInt(it)) proc checkPair(x, y: int): bool = if y < x: return false let dist = abs(y - x) if dist < 1 or dist > 3: return false return true proc checkWindow(x, y, z: int): bool = if not [x, y, z].isSorted: return false let dists = [abs(z-y), abs(y-x)] if dists.filterIt(it < 1 or it > 3).len != 0: return false return true proc isSafe(report: seq[int]): bool = var levels = report # make all lists ascending order if levels[0] > levels[1]: levels.reverse() for i in 0..