Paste: AoC 2022 Day 6

Author: nomennescio
Mode: factor
Date: Tue, 6 Dec 2022 08:43:58
Plain Text |
! 2022 nomennescio
USING: io.encodings.utf8 io.files kernel math prettyprint sequences sets ;
IN: aoc2022

: parse-file ( path encoding -- datastream ) file-lines first ;
: first-uniques ( seq n -- i ) [ 1 - cut [ suffix [ rest ] keep all-unique? ] find drop nip ] keep + ;
: part1 ( -- ) "input-6.txt" utf8 parse-file 4 first-uniques . ;
: part2 ( -- ) "input-6.txt" utf8 parse-file 14 first-uniques . ;
: day6 ( -- ) part1 part2 ;

MAIN: day6

New Annotation

Summary:
Author:
Mode:
Body: