Skip to content

Instantly share code, notes, and snippets.

@jcmorrow
Created December 9, 2020 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcmorrow/d95113066f69ffb1a69de4b63f03e900 to your computer and use it in GitHub Desktop.
Save jcmorrow/d95113066f69ffb1a69de4b63f03e900 to your computer and use it in GitHub Desktop.
nums =: ".S:0 (LF cut fread '~/code/advent_of_code/day_9.txt')
valid =: monad : '(_1 {. (y { nums)) e. ~.,((_1 }. (y { nums)) +/ (_1 }. (y { nums)))'
iter =: dyad : '(i.(#x)-(y-1)) +/ (i.y)'
goal =: (((,valid &> <"1(_25 }. ,.nums iter 26)) i. 0) + 25) { nums
get =: monad : 'y { nums'
index =: (+/ "1 get &> <"1 (_1}. nums iter 17)) i. goal
(<./ (index { nums iter 17) { nums) + (>./ (index { nums iter 17) { nums)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment