Skip to content

Instantly share code, notes, and snippets.

@angus-g
Last active December 2, 2020 05:44
Show Gist options
  • Save angus-g/be9d9c9de8a80385cd127778cddb9c9e to your computer and use it in GitHub Desktop.
Save angus-g/be9d9c9de8a80385cd127778cddb9c9e to your computer and use it in GitHub Desktop.
input=: cutLF fread '~Projects/advent/2020-day2.in'
valid=: verb define
'con char word'=. ' ' splitstring y
'min max'=. ". each '-' splitstring con
(min&<: *. <:&max) +/ ({. char) = word
)
valid2=: verb define
'con char word'=. ' ' splitstring y
i=. > ". each '-' splitstring con
~:/ ({. char) = (i - 1) { word
)
NB. part 1
+/ > valid each input
NB. part 2
+/ > valid2 each input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment