aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--aoc-2022-dotnet/Day06/Day06.fsproj15
-rw-r--r--aoc-2022-dotnet/Day06/Program.fs18
-rw-r--r--aoc-2022-dotnet/README.md4
-rw-r--r--aoc-2022-dotnet/aoc-2022-dotnet.sln8
5 files changed, 43 insertions, 4 deletions
diff --git a/README.md b/README.md
index 6df389c..8b9295c 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Repository storing my solutions to Advent of Code. See other people's solutions
### [2022](aoc-2022-dotnet)
![.NET](https://img.shields.io/badge/.NET-grey?logo=.NET)
-![Stars](https://img.shields.io/badge/🌟%20stars-10/50-orange)
+![Stars](https://img.shields.io/badge/🌟%20stars-12/50-orange)
[awesome]: https://github.com/Bogdanp/awesome-advent-of-code
[aoc]: https://adventofcode.com
diff --git a/aoc-2022-dotnet/Day06/Day06.fsproj b/aoc-2022-dotnet/Day06/Day06.fsproj
new file mode 100644
index 0000000..249287d
--- /dev/null
+++ b/aoc-2022-dotnet/Day06/Day06.fsproj
@@ -0,0 +1,15 @@
+ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net7.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Content Include="input.txt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Compile Include="Program.fs" />
+ </ItemGroup>
+
+</Project>
diff --git a/aoc-2022-dotnet/Day06/Program.fs b/aoc-2022-dotnet/Day06/Program.fs
new file mode 100644
index 0000000..75a5ffb
--- /dev/null
+++ b/aoc-2022-dotnet/Day06/Program.fs
@@ -0,0 +1,18 @@
+ο»Ώopen System.IO
+
+let solution n =
+ Seq.windowed n
+ >> Seq.findIndex (Set >> Set.count >> (=) n)
+ >> (+) n
+
+assert
+ [ ("mjqjpqmgbljsphdztnvjfqwrcgsmlb", 7, 19)
+ ("bvwbjplbgvbhsrlpgdmjqwftvncz", 5, 23)
+ ("nppdvjthqldpwncqszvftbrmjlhg", 6, 23)
+ ("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg", 10, 29)
+ ("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw", 11, 26) ]
+ |> List.forall (fun (test, s4, s14) -> solution 4 test = s4 && solution 14 test = s14)
+
+let input = File.ReadAllText "input.txt"
+printfn "%d" <| solution 4 input
+printfn "%d" <| solution 14 input
diff --git a/aoc-2022-dotnet/README.md b/aoc-2022-dotnet/README.md
index b74d6c1..ef93031 100644
--- a/aoc-2022-dotnet/README.md
+++ b/aoc-2022-dotnet/README.md
@@ -1,6 +1,6 @@
# Advent of Code 2022 in .NET
![.NET](https://img.shields.io/badge/.NET-grey?logo=.NET)
-![Stars](https://img.shields.io/badge/🌟%20stars-10/50-orange)
+![Stars](https://img.shields.io/badge/🌟%20stars-12/50-orange)
## Progress
| Day | Part 1 | Part 2 |
@@ -10,7 +10,7 @@
| Day 3: Rucksack Reorganization | 🌟 | 🌟 |
| Day 4: Camp Cleanup | 🌟 | 🌟 |
| Day 5: Supply Stacks | 🌟 | 🌟 |
-| Day 6: ??? | | |
+| Day 6: Tuning Trouble | 🌟 | 🌟 |
| Day 7: ??? | | |
| Day 8: ??? | | |
| Day 9: ??? | | |
diff --git a/aoc-2022-dotnet/aoc-2022-dotnet.sln b/aoc-2022-dotnet/aoc-2022-dotnet.sln
index 06c19f4..3cfbda2 100644
--- a/aoc-2022-dotnet/aoc-2022-dotnet.sln
+++ b/aoc-2022-dotnet/aoc-2022-dotnet.sln
@@ -18,7 +18,9 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Day03", "Day03\Day03.fsproj
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Day04", "Day04\Day04.fsproj", "{3E74A210-46A7-420E-93B4-12CCC4B51957}"
EndProject
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Day05", "Day05\Day05.fsproj", "{4D538535-1283-4EEF-80F7-72A9A1643615}"
+Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Day05", "Day05\Day05.fsproj", "{4D538535-1283-4EEF-80F7-72A9A1643615}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Day06", "Day06\Day06.fsproj", "{24E41736-93F0-4222-810F-47B9A740E599}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -46,6 +48,10 @@ Global
{4D538535-1283-4EEF-80F7-72A9A1643615}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D538535-1283-4EEF-80F7-72A9A1643615}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D538535-1283-4EEF-80F7-72A9A1643615}.Release|Any CPU.Build.0 = Release|Any CPU
+ {24E41736-93F0-4222-810F-47B9A740E599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {24E41736-93F0-4222-810F-47B9A740E599}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {24E41736-93F0-4222-810F-47B9A740E599}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {24E41736-93F0-4222-810F-47B9A740E599}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE