completed day 1

This commit is contained in:
Rob Stoffelen 2022-12-01 15:32:20 +01:00
commit 9795f63915
40 changed files with 4850 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

25
AdventOfCode 2022.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day 01", "Day 01\Day 01.csproj", "{0547286C-CC14-44D9-8D7B-26BAA3377721}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0547286C-CC14-44D9-8D7B-26BAA3377721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0547286C-CC14-44D9-8D7B-26BAA3377721}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0547286C-CC14-44D9-8D7B-26BAA3377721}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0547286C-CC14-44D9-8D7B-26BAA3377721}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {716D4A39-3ED5-4047-8761-79BF9B24FB61}
EndGlobalSection
EndGlobal

17
Day 01/Day 01.csproj Normal file
View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Day_01</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Update="day-01-input.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

44
Day 01/Program.cs Normal file
View File

@ -0,0 +1,44 @@
string[] data = await File.ReadAllLinesAsync("day-01-input.txt");
Console.WriteLine($"Max value: {GetPart2(data)}");
Console.ReadKey(true);
int GetPart1(string[] data)
{
int maxValue = 0, buffer = 0;
foreach (string value in data)
{
if (string.IsNullOrEmpty(value))
{
if (buffer > maxValue) maxValue = buffer;
buffer = 0;
continue;
}
buffer += Convert.ToInt32(value);
}
return maxValue;
}
int GetPart2(string[] data)
{
List<int> values = new List<int>();
int buffer = 0;
foreach (string value in data)
{
if (string.IsNullOrEmpty(value))
{
values.Add(buffer);
buffer = 0;
continue;
}
buffer += Convert.ToInt32(value);
}
return values.OrderByDescending(v => v).Take(3).Sum();
}

View File

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"Day 01/1.0.0": {
"runtime": {
"Day 01.dll": {}
}
}
}
},
"libraries": {
"Day 01/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
}
}
}

File diff suppressed because it is too large Load Diff

2255
Day 01/day-01-input.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
{
"format": 1,
"restore": {
"D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj": {}
},
"projects": {
"D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj",
"projectName": "Day 01",
"projectPath": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj",
"packagesPath": "C:\\Users\\rst\\.nuget\\packages\\",
"outputPath": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\rst\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.my-lex.nl/nuget/": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.401\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\rst\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.3.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\rst\.nuget\packages\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Day 01")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Day 01")]
[assembly: System.Reflection.AssemblyTitleAttribute("Day 01")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -0,0 +1 @@
39f22354d9a8152bdfb38284cccedd7de741c614

View File

@ -0,0 +1,10 @@
is_global = true
build_property.TargetFramework = net6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Day_01
build_property.ProjectDir = D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\

View File

@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@ -0,0 +1 @@
bff4f099a388956ce7191b159052cbeded8be4c3

View File

@ -0,0 +1,16 @@
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\bin\Debug\net6.0\Day 01.exe
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\bin\Debug\net6.0\day-01-input.txt
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\bin\Debug\net6.0\Day 01.deps.json
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\bin\Debug\net6.0\Day 01.runtimeconfig.json
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\bin\Debug\net6.0\Day 01.dll
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\bin\Debug\net6.0\Day 01.pdb
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.csproj.AssemblyReference.cache
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.GeneratedMSBuildEditorConfig.editorconfig
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.AssemblyInfoInputs.cache
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.AssemblyInfo.cs
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.csproj.CoreCompileInputs.cache
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.dll
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\refint\Day 01.dll
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.pdb
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\Day 01.genruntimeconfig.cache
D:\Personal\AdventOfCode\AdventOfCode 2022\Day 01\obj\Debug\net6.0\ref\Day 01.dll

Binary file not shown.

View File

@ -0,0 +1 @@
48f9e8d564abb2b31c4df5d17701a4f3ca9f6ba5

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,69 @@
{
"version": 3,
"targets": {
"net6.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net6.0": []
},
"packageFolders": {
"C:\\Users\\rst\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj",
"projectName": "Day 01",
"projectPath": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj",
"packagesPath": "C:\\Users\\rst\\.nuget\\packages\\",
"outputPath": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\rst\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.my-lex.nl/nuget/": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.401\\RuntimeIdentifierGraph.json"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "65T8FGgqOEzsEEBXOOC0kHWXW8s18YZRSZS65WNTFhXZttVnuqoH/TaTk0yynyTo8NQ0V3/prJpHgg+8WVOWDw==",
"success": true,
"projectFilePath": "D:\\Personal\\AdventOfCode\\AdventOfCode 2022\\Day 01\\Day 01.csproj",
"expectedPackageFiles": [],
"logs": []
}