Initial commit.
This commit is contained in:
commit
83508ce6a5
|
@ -0,0 +1,32 @@
|
||||||
|
*.swp
|
||||||
|
*.*~
|
||||||
|
project.lock.json
|
||||||
|
.DS_Store
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
build/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
msbuild.log
|
||||||
|
msbuild.err
|
||||||
|
msbuild.wrn
|
||||||
|
|
||||||
|
# Visual Studio 2015
|
||||||
|
.vs/
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.26430.14
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AoC2018", "AoC2018\AoC2018.csproj", "{ECD52B05-8FB6-4B9C-80AD-1AB5C2807EAA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AoC2018Test", "AoC2018Test\AoC2018Test.csproj", "{DC118C5C-268B-4ABD-A5E6-048B8DE5AC27}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{ECD52B05-8FB6-4B9C-80AD-1AB5C2807EAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ECD52B05-8FB6-4B9C-80AD-1AB5C2807EAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ECD52B05-8FB6-4B9C-80AD-1AB5C2807EAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ECD52B05-8FB6-4B9C-80AD-1AB5C2807EAA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DC118C5C-268B-4ABD-A5E6-048B8DE5AC27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DC118C5C-268B-4ABD-A5E6-048B8DE5AC27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DC118C5C-268B-4ABD-A5E6-048B8DE5AC27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DC118C5C-268B-4ABD-A5E6-048B8DE5AC27}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,14 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Input\Day1Input.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using AoC2018.Solutions;
|
||||||
|
|
||||||
|
namespace AoC2018
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Find all classes inheriting from Solution, create an instance, and execute Run method.
|
||||||
|
foreach (Type t in Assembly.GetEntryAssembly().ExportedTypes)
|
||||||
|
{
|
||||||
|
if (t.GetTypeInfo().IsSubclassOf(typeof(Solution)))
|
||||||
|
{
|
||||||
|
Solution solution = Activator.CreateInstance(t) as Solution;
|
||||||
|
|
||||||
|
Console.WriteLine("-----------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Day {solution.Day} - {solution.Title}");
|
||||||
|
Console.WriteLine("-----------------------------------------------------------");
|
||||||
|
|
||||||
|
solution.Run();
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AoC2018.Solutions
|
||||||
|
{
|
||||||
|
public class Day1Solution : Solution
|
||||||
|
{
|
||||||
|
public override string Title => "Chronal Calibration";
|
||||||
|
|
||||||
|
public override int Day => 1;
|
||||||
|
|
||||||
|
public override void Run()
|
||||||
|
{
|
||||||
|
string[] input = File.ReadAllLines(Path.Combine("Input", "Day1Input.txt"));
|
||||||
|
Dictionary<int, int> frequencyOccurrences = new Dictionary<int, int>();
|
||||||
|
int part1Result = 0, part2Result = 0;
|
||||||
|
bool part2Flag = false;
|
||||||
|
|
||||||
|
for (var i = 0; i < input.Length; i++)
|
||||||
|
{
|
||||||
|
part1Result += int.Parse(input[i]);
|
||||||
|
}
|
||||||
|
Console.WriteLine($"Part 1 Result: {part1Result}");
|
||||||
|
|
||||||
|
part1Result = 0;
|
||||||
|
while (!part2Flag)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < input.Length; i++)
|
||||||
|
{
|
||||||
|
part1Result += int.Parse(input[i]);
|
||||||
|
|
||||||
|
if (!frequencyOccurrences.ContainsKey(part1Result))
|
||||||
|
frequencyOccurrences.Add(part1Result, 0);
|
||||||
|
|
||||||
|
frequencyOccurrences[part1Result]++;
|
||||||
|
|
||||||
|
if (frequencyOccurrences[part1Result] > 1)
|
||||||
|
{
|
||||||
|
part2Flag = true;
|
||||||
|
part2Result = part1Result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Part 2 Result: {part2Result}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace AoC2018.Solutions
|
||||||
|
{
|
||||||
|
public abstract class Solution
|
||||||
|
{
|
||||||
|
public abstract string Title { get; }
|
||||||
|
public abstract int Day { get; }
|
||||||
|
|
||||||
|
public abstract void Run();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AoC2018\AoC2018.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace AoC2018Test
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class UnitTest1
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void TestMethod1()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue