diff options
author | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2022-12-09 19:31:24 +0100 |
---|---|---|
committer | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2022-12-09 19:31:24 +0100 |
commit | 967e964f453fc031816270b90d6eab38410769a3 (patch) | |
tree | 99ca5504c1be629eb35cda6514df401965d232fd /aoc-2022-dotnet/Day02 | |
parent | fd04f2ebd1a4ade35a3e218b7737311ac631fce8 (diff) | |
download | gleam_aoc2020-967e964f453fc031816270b90d6eab38410769a3.tar.gz gleam_aoc2020-967e964f453fc031816270b90d6eab38410769a3.zip |
Extract common functions to util module
Diffstat (limited to 'aoc-2022-dotnet/Day02')
-rw-r--r-- | aoc-2022-dotnet/Day02/Day02.fsproj | 4 | ||||
-rw-r--r-- | aoc-2022-dotnet/Day02/Program.fs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/aoc-2022-dotnet/Day02/Day02.fsproj b/aoc-2022-dotnet/Day02/Day02.fsproj index 0e98abc..795d59c 100644 --- a/aoc-2022-dotnet/Day02/Day02.fsproj +++ b/aoc-2022-dotnet/Day02/Day02.fsproj @@ -19,4 +19,8 @@ <PackageReference Include="FSharpPlus" Version="1.3.2" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Common\Common.fsproj" /> + </ItemGroup> + </Project> diff --git a/aoc-2022-dotnet/Day02/Program.fs b/aoc-2022-dotnet/Day02/Program.fs index 0546195..8568f9a 100644 --- a/aoc-2022-dotnet/Day02/Program.fs +++ b/aoc-2022-dotnet/Day02/Program.fs @@ -2,6 +2,7 @@ open System.IO open FSharpPlus +open Common type Move = | Rock @@ -36,11 +37,6 @@ type Strategy = | "Z" -> Z | s -> failwithf "Invalid strategy: %s" s -let splitToTuple sep str = - match Seq.toList <| String.split [ sep ] str with - | [ x; y ] -> x, y - | _ -> failwith "Invalid string format!" - let scoreRound (enemy, player) = let selectionScore = match player with @@ -70,7 +66,7 @@ let guide2 (enemy: Move) = let parseRound guide roundStr = let (enemy, strategy) = roundStr - |> splitToTuple " " + |> Util.splitStringToTuple " " |> mapItem1 Move.parse |> mapItem2 Strategy.parse |