USING: grouping hash-sets io.backend io.encodings.utf8 io.files kernel math sequences sets unicode ; IN: advent-of-code.day-03 : get-input-one ( -- seq ) "vocab:advent-of-code/day-03/_input/one.txt" normalize-path utf8 file-lines ; : find-duplicate ( string -- duplicate ) dup length 2/ group [ >hash-set ] map first2 intersect members first ; : >priority ( fixnum -- fixnum ) dup letter? [ 96 - ] [ 38 - ] if ; : solve-part-one ( -- solution ) get-input-one [ find-duplicate >priority ] map sum ; : find-bagde-item ( seq -- badge ) [ >hash-set ] map first3 intersect intersect members first ; : solve-part-two ( -- solution ) get-input-one 3 group [ find-bagde-item >priority ] map sum ;