Skip to content

Instantly share code, notes, and snippets.

@pta2002
Created December 12, 2017 22:07
Show Gist options
  • Save pta2002/1445d5b75dea019071ffb1225f8fe1bf to your computer and use it in GitHub Desktop.
Save pta2002/1445d5b75dea019071ffb1225f8fe1bf to your computer and use it in GitHub Desktop.
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