Created
December 1, 2022 05:51
-
-
Save leifmetcalf/35b0390c5d125ab1129ac3db8dbc67df to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
let () = | |
let f (elves, acc) line = | |
if String.is_empty line then | |
(acc :: elves, 0) | |
else | |
(elves, acc + int_of_string line) | |
in | |
let (elves, acc) = In_channel.fold_lines In_channel.stdin ~init:([], 0) ~f in | |
let elves = List.sort ~compare:Int.descending (acc :: elves) in | |
printf "%d\n" @@ List.fold (List.take elves 3) ~init:0 ~f:(+) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment