aboutsummaryrefslogtreecommitdiff
path: root/aoc-2022-dotnet/Day02
diff options
context:
space:
mode:
authorTomasz Chojnacki <tomaszchojnacki2001@gmail.com>2022-12-09 19:31:24 +0100
committerTomasz Chojnacki <tomaszchojnacki2001@gmail.com>2022-12-09 19:31:24 +0100
commit967e964f453fc031816270b90d6eab38410769a3 (patch)
tree99ca5504c1be629eb35cda6514df401965d232fd /aoc-2022-dotnet/Day02
parentfd04f2ebd1a4ade35a3e218b7737311ac631fce8 (diff)
downloadgleam_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.fsproj4
-rw-r--r--aoc-2022-dotnet/Day02/Program.fs8
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