didn't know you could just use = to check equality of 2 nested lists..
This commit is contained in:
parent
81aade09dd
commit
4b612ac95d
1 changed files with 1 additions and 10 deletions
11
day11.ml
11
day11.ml
|
|
@ -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…
Add table
Add a link
Reference in a new issue