aboutsummaryrefslogtreecommitdiff
path: root/aoc-2022-dotnet/Day03
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/Day03
parentfd04f2ebd1a4ade35a3e218b7737311ac631fce8 (diff)
downloadgleam_aoc2020-967e964f453fc031816270b90d6eab38410769a3.tar.gz
gleam_aoc2020-967e964f453fc031816270b90d6eab38410769a3.zip
Extract common functions to util module
Diffstat (limited to 'aoc-2022-dotnet/Day03')
-rw-r--r--aoc-2022-dotnet/Day03/Day03.fsproj4
-rw-r--r--aoc-2022-dotnet/Day03/Program.fs7
2 files changed, 6 insertions, 5 deletions
diff --git a/aoc-2022-dotnet/Day03/Day03.fsproj b/aoc-2022-dotnet/Day03/Day03.fsproj
index e337a41..b9a3919 100644
--- a/aoc-2022-dotnet/Day03/Day03.fsproj
+++ b/aoc-2022-dotnet/Day03/Day03.fsproj
@@ -15,4 +15,8 @@
<Compile Include="Program.fs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Common\Common.fsproj" />
+ </ItemGroup>
+
</Project>
diff --git a/aoc-2022-dotnet/Day03/Program.fs b/aoc-2022-dotnet/Day03/Program.fs
index 153e639..512ef40 100644
--- a/aoc-2022-dotnet/Day03/Program.fs
+++ b/aoc-2022-dotnet/Day03/Program.fs
@@ -1,6 +1,7 @@
module Day03
open System.IO
+open Common
let priority item =
if 'a' <= item && item <= 'z' then
@@ -10,13 +11,9 @@ let priority item =
else
failwithf "Invalid item: %c" item
-let cutInHalf xs =
- let half = Seq.length xs / 2
- [ Seq.take half xs; Seq.skip half xs ]
-
let solution1 =
Seq.sumBy (
- cutInHalf
+ Util.cutInHalf
>> Seq.map Set
>> Set.intersectMany
>> Seq.exactlyOne