Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4906

Teaching and learning resources • Re: Advent of Code 2024

$
0
0

Code:

(* Advent of Code - 2024; day1 - part2 on BPI-F3 RISC-V *)(* OCaml code *)#load "utils.cmo"open Utilslet rec unleave = function    [] -> [],[]  | [a; b] :: t -> match unleave t with      l, r -> (int_of_string a :: l, int_of_string b :: r)let day_1b file =  let ll,rl = file |> read_lol_words |> unleave in  let sll = List.sort compare ll in  let srl = List.sort compare rl in  List.(fold_left (+) 0          (map (fun l -> l * length (filter ((=) l) srl)) sll))
utop[5]> time (fun () -> day_1b "input.txt");;
Execution time: 0.148755s
- : int = 26593248

Statistics: Posted by hrvoje064 — Sun Dec 01, 2024 1:15 pm



Viewing all articles
Browse latest Browse all 4906

Trending Articles