Created
December 1, 2017 21:00
-
-
Save tryggvigy/e3b31bdbd32f774b00c1a7e20fe41bd7 to your computer and use it in GitHub Desktop.
Advent Of Code - Day 1
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
open Core.Std | |
let solveCaptcha digits = | |
let rec loop ls sum = match ls with | |
| hd::[] when (List.hd_exn digits) = hd -> sum + hd | |
| hd::sd::tl when hd = sd -> loop (sd::tl) (sum + hd) | |
| hd::tl -> loop tl sum | |
| _ -> sum | |
in | |
loop digits 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment