Advertisement
raedr7n

AoC 2022 Day 02

Dec 2nd, 2022 (edited)
2,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.49 KB | None | 0 0
  1. module AoC_2022.Day02
  2.  
  3. open Util
  4.  
  5. let lines = System.IO.File.ReadAllLines("../../../Inputs/Day02.txt")
  6.  
  7. let score (game : string) =
  8.     let [|u; v|] = game.Split " " |> Array.map (int << char)
  9.     ((v - u - 22) mod 3) * 3 + (v - 87)
  10.  
  11. Array.map score lines |> Array.sum |> System.Console.WriteLine
  12.  
  13. let b (game : string) =
  14.     let [|u; v|] = game.Split " "
  15.     score $"{u} {char <| (int (char u) + int (char v) - 1) mod 3 + 88}"
  16.  
  17. Array.map b lines |> Array.sum |> System.Console.WriteLine
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement