generated from MartinZikmund/template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d91270
commit 4e8dfc5
Showing
6 changed files
with
275 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="input.txt" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="input.txt"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Tools\Tools.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Tools; | ||
|
||
var input = InputTools.ReadAllLines(); | ||
int[] cardCount = new int[input.Length]; | ||
for (int i = 0; i < cardCount.Length; i++) | ||
{ | ||
cardCount[i] = 1; | ||
} | ||
|
||
for (int cardId = 0; cardId < input.Length; cardId++) | ||
{ | ||
string? line = input[cardId]; | ||
var parts = line.Split(':'); | ||
var numbers = parts[1].Split('|'); | ||
var pickedNumbers = numbers[0] | ||
.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) | ||
.Select(int.Parse) | ||
.ToArray(); | ||
var ourNumbers = numbers[1] | ||
.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) | ||
.Select(int.Parse) | ||
.ToArray(); | ||
|
||
var matchCount = pickedNumbers.Intersect(ourNumbers).Count(); | ||
|
||
for (int i = 0; i < matchCount; i++) | ||
{ | ||
cardCount[cardId + 1 + i] += cardCount[cardId]; | ||
} | ||
} | ||
|
||
Console.WriteLine(cardCount.Sum()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"profiles": { | ||
"Run": { | ||
"commandName": "Project" | ||
} | ||
} | ||
} |
Oops, something went wrong.