Add project files.
This commit is contained in:
13
.idea/.idea.AdventOfCode2024/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.AdventOfCode2024/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/contentModel.xml
|
||||
/.idea.AdventOfCode2024.iml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
4
.idea/.idea.AdventOfCode2024/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.AdventOfCode2024/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
.idea/.idea.AdventOfCode2024/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.AdventOfCode2024/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/.idea.AdventOfCode2024/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.AdventOfCode2024/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
25
AdventOfCode2024.sln
Normal file
25
AdventOfCode2024.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35312.102
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day1", "Day1\Day1.csproj", "{B9B134C5-93CB-4F54-90F6-FA911A04BDA5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B9B134C5-93CB-4F54-90F6-FA911A04BDA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B9B134C5-93CB-4F54-90F6-FA911A04BDA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B9B134C5-93CB-4F54-90F6-FA911A04BDA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B9B134C5-93CB-4F54-90F6-FA911A04BDA5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8A2CDA81-8B9A-4F96-AE18-A11BC68BF332}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
16
Day1/Day1.csproj
Normal file
16
Day1/Day1.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="input.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
14
Day1/Program.cs
Normal file
14
Day1/Program.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
var lines = File.ReadAllLines("input.txt");
|
||||
|
||||
var parts = lines.Select(line => (line.Split(" ")[0], line.Split(" ")[1])).ToList();
|
||||
var list1 = parts.Select(part => int.Parse(part.Item1)).Order().ToList();
|
||||
var list2 = parts.Select(part => int.Parse(part.Item2)).Order().ToList();
|
||||
int distance = 0, similarityScore = 0;
|
||||
|
||||
for (var i = 0; i < list1.Count; i++)
|
||||
{
|
||||
distance += Math.Abs(list1[i] - list2[i]);
|
||||
similarityScore += list1[i] * list2.Count(item => item == list1[i]);
|
||||
}
|
||||
|
||||
Console.WriteLine($"Part 1 : {distance}\nPart 2 : {similarityScore}");
|
||||
1000
Day1/input.txt
Normal file
1000
Day1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user