remove unused index stuff
This commit is contained in:
parent
58db497e5d
commit
36361b9a7a
1 changed files with 9 additions and 9 deletions
18
day5.ml
18
day5.ml
|
@ -9,34 +9,34 @@ let rec find' ?(lo=0) ~hi = function
|
||||||
| L::hs -> find' ~lo ~hi:(avg lo hi) hs
|
| L::hs -> find' ~lo ~hi:(avg lo hi) hs
|
||||||
| H::hs -> find' ~lo:(avg (lo+1) hi) ~hi hs
|
| H::hs -> find' ~lo:(avg (lo+1) hi) ~hi hs
|
||||||
|
|
||||||
exception Inexact of bounds * int option [@warn_on_literal_pattern]
|
exception Inexact of bounds [@warn_on_literal_pattern]
|
||||||
|
|
||||||
let find ?index ?lo ~hi halves =
|
let find ?lo ~hi halves =
|
||||||
match find' ?lo ~hi halves with
|
match find' ?lo ~hi halves with
|
||||||
| Exact x -> x
|
| Exact x -> x
|
||||||
| Between p -> raise (Inexact (p, index))
|
| Between p -> raise (Inexact p)
|
||||||
|
|
||||||
|
|
||||||
type path = {rows: half list; cols: half list}
|
type path = {rows: half list; cols: half list}
|
||||||
|
|
||||||
exception Unknown_char of char * int option
|
exception Unknown_char of char [@warn_on_literal_pattern]
|
||||||
|
|
||||||
let path_of_string ?index str =
|
let path_of_string str =
|
||||||
let revs {rows; cols} = List.{rows = rev rows; cols = rev cols} in
|
let revs {rows; cols} = List.{rows = rev rows; cols = rev cols} in
|
||||||
let put acc = function
|
let put acc = function
|
||||||
| 'F' -> {acc with rows = L :: acc.rows}
|
| 'F' -> {acc with rows = L :: acc.rows}
|
||||||
| 'B' -> {acc with rows = H :: acc.rows}
|
| 'B' -> {acc with rows = H :: acc.rows}
|
||||||
| 'L' -> {acc with cols = L :: acc.cols}
|
| 'L' -> {acc with cols = L :: acc.cols}
|
||||||
| 'R' -> {acc with cols = H :: acc.cols}
|
| 'R' -> {acc with cols = H :: acc.cols}
|
||||||
| c -> raise (Unknown_char (c, index)) in
|
| c -> raise (Unknown_char c) in
|
||||||
String.to_seq str |> Seq.fold_left put {rows = []; cols = []} |> revs
|
String.to_seq str |> Seq.fold_left put {rows = []; cols = []} |> revs
|
||||||
|
|
||||||
|
|
||||||
type seat = {row: int; col: int}
|
type seat = {row: int; col: int}
|
||||||
|
|
||||||
let seat_of_path ?index {rows; cols} =
|
let seat_of_path {rows; cols} =
|
||||||
{row = find ?index ~hi:127 rows;
|
{row = find ~hi:127 rows;
|
||||||
col = find ?index ~hi:7 cols}
|
col = find ~hi:7 cols}
|
||||||
|
|
||||||
let seat_id {row; col} = (row * 8) + col
|
let seat_id {row; col} = (row * 8) + col
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue