add pair_of_list helper function
This commit is contained in:
parent
883d16a3a3
commit
8a9648ff3e
2 changed files with 5 additions and 4 deletions
|
@ -41,10 +41,12 @@ let outcome me oponent =
|
|||
| 1 | -2 -> Win
|
||||
| _ -> Draw
|
||||
|
||||
open Utils
|
||||
|
||||
let solve f l = l
|
||||
|> List.map (fun line -> line
|
||||
|> String.split_on_char ' '
|
||||
|> (fun l -> (List.hd l, List.tl l |> List.hd))
|
||||
|> pair_of_list
|
||||
|> f
|
||||
|> (fun (oponent, me) -> ((outcome me oponent) |> int_of_outcome) + int_of_choice me))
|
||||
|> List.fold_left (+) 0
|
||||
|
@ -56,7 +58,5 @@ let d2_2 = solve (fun (oponent_s, outcome_s) ->
|
|||
(choice_of_string oponent_s, outcome_of_string outcome_s)
|
||||
|> (fun (oponent, outcome) -> (oponent, (choice_of_outcome oponent outcome))))
|
||||
|
||||
open Utils
|
||||
|
||||
let _ = "\n1: " ^ (string_of_int (read_file "bin/d2/input.txt" |> d2_1)) ^
|
||||
"\n2: " ^ (string_of_int (read_file "bin/d2/input.txt" |> d2_2)) |> print_endline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue