Created
October 7, 2010 12:40
-
-
Save wasabili/615041 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
(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