didn't know you could just use = to check equality of 2 nested lists..

master
Dustin Swan 3 years ago
parent 81aade09dd
commit 4b612ac95d

@ -74,19 +74,10 @@ let change_seats is_far l =
)
) l
let hash = Hashtbl.create 1000
let grid_equal g1 g2 = (* abusing hash but not a drug problem *)
match Hashtbl.find_opt hash g2 with
| Some _ -> true
| None ->
let _ = Hashtbl.add hash g2 0 in
false
let rec start is_far grid = (* keep changing seats until the grid stops changing *)
(* print_grid grid; *)
let grid' = change_seats is_far grid in
if grid_equal grid grid'
if grid = grid'
then grid'
else start is_far grid'

Loading…
Cancel
Save