Files
rose-ash/plans
giles 5eed0dd5f5
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
ocaml: phase 5.1 coin_min.ml baseline (67 cents in US coins = 6)
Minimum-coin DP with -1 sentinel for unreachable values:

  let coin_min coins amount =
    let dp = Array.make (amount + 1) (-1) in
    dp.(0) <- 0;
    for i = 1 to amount do
      List.iter (fun c ->
        if c <= i && dp.(i - c) >= 0 then begin
          let cand = dp.(i - c) + 1 in
          if dp.(i) < 0 || cand < dp.(i) then dp.(i) <- cand
        end
      ) coins
    done;
    dp.(amount)

  coin_min [1; 5; 10; 25] 67 = 6   (* 25+25+10+5+1+1 *)

Tests `if c <= i && dp.(i-c) >= 0 then` short-circuit guard;
relies on iter-242 fix so dp.(i-c) is not evaluated when c > i.

158 baseline programs total.
2026-05-10 22:07:17 +00:00
..