let width = 32
let height = 10

let add2 r = (r lsl 2) lor 0b10
let add3 r = (r lsl 3) lor 0b100

let rows = ref []

let rec fill w r =
  if w = width then rows := r :: !rows
  else if w < width then begin fill (w + 2) (add2 r); fill (w + 3) (add3 r) end

let () = fill 2 0; fill 3 0

let rec sum f = function
  | [] -> 0
  | x :: r -> f x + sum f r

let table = Hashtbl.create 5003

let rec w r h =
  if h = 1 then
    1
  else
    sum (fun r' -> if r land r' = 0 then memo_w r' (h-1) else 0) !rows

and memo_w r h =
  try  Hashtbl.find table (r,h)
  with Not_found -> let v = w r h in Hashtbl.add table (r,h) v; v

let sol = w 0 (height+1)
let () = Format.printf "%d@." sol


This document was generated using caml2html