-
-
Save jcmorrow/e33ca5d59c5a4e376992d298d0752d8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input =: 15 5 1 4 7 0 | |
nth =: dyad define | |
last =. _1{y | |
allP =. _1}.y | |
prev =. allP i: last | |
if. prev = # allP do. | |
new =. allP,last,0 | |
else. | |
new =. allP,last,((# allP) - prev) | |
end. | |
if. (#new) = x do. | |
new return. | |
else. | |
x nth new | |
end. | |
) | |
{. |. 2020 nth input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment