let shuffle result =
  let result = Array.copy result in
  for i = Array.length result - 1 downto 0 do
    let other = Random.int (i + 1) and tmp = result.(i) in
    result.(i) <- result.(other); result.(other) <- tmp
  done; result