open Core.Std

let times_to_repeat = 40

let () =
  let require_line = (function
      | None -> failwith "input required"
      | Some line -> line) in
  In_channel.input_line stdin
  |> require_line
  |> MathSequence.iterate ~f:LookAndSay.next ~count:times_to_repeat
  |> String.length |> Int.to_string
  |> print_string

open Core.Std

(* let times_to_repeat = 40 *)
let times_to_repeat = 50

let () =
  let require_line = (function
      | None -> failwith "input required"
      | Some line -> line) in
  In_channel.input_line stdin
  |> require_line
  |> MathSequence.iterate ~f:LookAndSay.next ~count:times_to_repeat
  |> String.length |> Int.to_string
  |> print_string

Complete day 10 part 2
Complete day 10 part 2

This takes 43 seconds to calculate on my machine with the given input, “3113322113”. I guess it’s good that I used a fast language like OCaml – otherwise I would have had to optimize the equivalent of `LookAndSay.next` further.
