Skip to content

Instantly share code, notes, and snippets.

@wasabili
Created October 7, 2010 12:40
Show Gist options
  • Save wasabili/615041 to your computer and use it in GitHub Desktop.
Save wasabili/615041 to your computer and use it in GitHub Desktop.
(use file.util)
(use srfi-1)
(letrec ((input (file->string-list "input.txt"))
(n-m (map string->number (string-split (car input) #\Space)))
(n (car n-m))
(m (cdr n-m))
(dat (map string->number (cdr input)))
(mass (take dat n))
(dise (drop dat n)))
(let loop((index 1) (count 1))
(let ((i (+ index (list-ref dise (- count 1)))))
(if (>= i n)
(display count)
(let ((i (+ i (list-ref mass (- i 1)))))
(if (>= i n)
(display count)
(loop i (+ count 1))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment