Created
December 12, 2017 22:07
-
-
Save pta2002/1445d5b75dea019071ffb1225f8fe1bf 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
import Data.Vector as V | |
-- parsing | |
parse :: String -> V.Vector Int | |
parse = fromList . fmap read . lines | |
run :: V.Vector Int -> Int | |
run v = go v 0 | |
where go v n | |
| n < 0 || n >= V.length v = 0 | |
| otherwise = let x = v ! n | |
nv = v V.\\ [(n, succ x)] | |
in 1 + go nv (n + x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment