Skip to content

Instantly share code, notes, and snippets.

@tryggvigy
Created December 1, 2017 21:00
Show Gist options
  • Save tryggvigy/e3b31bdbd32f774b00c1a7e20fe41bd7 to your computer and use it in GitHub Desktop.
Save tryggvigy/e3b31bdbd32f774b00c1a7e20fe41bd7 to your computer and use it in GitHub Desktop.
Advent Of Code - Day 1
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