main.ml 474 B

1234567891011121314
  1. open Base
  2. let main() =
  3. let source = Stdio.In_channel.read_all "input" in
  4. let map = Lib.parse_map (String.strip source) in
  5. let count = Lib.count_trees_in_slope map (3, 1) in
  6. let all_counts =
  7. List.map ~f:(Lib.count_trees_in_slope map) Lib.all_slopes in
  8. let product =
  9. List.fold ~init:1 ~f:(fun x y -> x * y) all_counts in
  10. Stdio.printf "part one: you would hit %d trees\n" count;
  11. Stdio.printf "part two: you would hit %d trees\n" product
  12. let () = main()