initial add to repository
This commit is contained in:
25
2017_01.sln
25
2017_01.sln
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 15
|
|
||||||
VisualStudioVersion = 15.0.28010.2048
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2017_01", "2017_01\2017_01.csproj", "{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {03AD54F0-CF5D-409C-801B-45464BFF9001}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,6 +11,76 @@ namespace _2017_01
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
var Indata = File.ReadAllText(@"I:\Adventofcode_171201\data171201.txt");
|
||||||
|
//var Indata = "1212";
|
||||||
|
|
||||||
|
|
||||||
|
MethodOne(Indata);
|
||||||
|
MethodTwo(Indata);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void MethodOne(string Indata)
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
char lastFig = ' ';
|
||||||
|
char firstFig = ' ';
|
||||||
|
foreach (var figure in Indata.ToCharArray())
|
||||||
|
{
|
||||||
|
if (lastFig == ' ')
|
||||||
|
{
|
||||||
|
firstFig = figure;
|
||||||
|
}
|
||||||
|
if (figure == lastFig)
|
||||||
|
{
|
||||||
|
value += int.Parse(figure.ToString());
|
||||||
|
}
|
||||||
|
lastFig = figure;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstFig == lastFig)
|
||||||
|
{
|
||||||
|
value += int.Parse(lastFig.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Console.WriteLine("--Method 1--");
|
||||||
|
System.Console.WriteLine($"---{value}---");
|
||||||
|
System.Console.WriteLine("----------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MethodTwo(string Indata)
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
// char lastFig = ' ';
|
||||||
|
// char firstFig = ' ';
|
||||||
|
int locPos = 0;
|
||||||
|
char[] characters = Indata.ToCharArray();
|
||||||
|
foreach (var figure in characters)
|
||||||
|
{
|
||||||
|
if (figure == jmfChar(characters,locPos))
|
||||||
|
{
|
||||||
|
value += int.Parse(figure.ToString());
|
||||||
|
}
|
||||||
|
locPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Console.WriteLine("--Method 2--");
|
||||||
|
System.Console.WriteLine($"---{value}---");
|
||||||
|
System.Console.WriteLine("----------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static char jmfChar(char[] ind, int pos)
|
||||||
|
{
|
||||||
|
char returnChr = ' ';
|
||||||
|
int chars = ind.Length / 2;
|
||||||
|
if (pos + chars > ind.Length - 1)
|
||||||
|
{
|
||||||
|
returnChr = ind[pos + chars - ind.Length];
|
||||||
|
}
|
||||||
|
else returnChr = ind[pos + chars ];
|
||||||
|
|
||||||
|
return returnChr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
2018_01/2018_01.csproj
Normal file
53
2018_01/2018_01.csproj
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{A3A5185C-C171-42EF-A5AF-B4F9A9772231}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>_2018_01</RootNamespace>
|
||||||
|
<AssemblyName>2018_01</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
6
2018_01/App.config
Normal file
6
2018_01/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
60
2018_01/Program.cs
Normal file
60
2018_01/Program.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using static System.Console;
|
||||||
|
|
||||||
|
namespace _2018_01
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
long longVar = 0;
|
||||||
|
int varv = 0;
|
||||||
|
bool stopped = false;
|
||||||
|
Dictionary<string, int> resCheck = new Dictionary<string, int>();
|
||||||
|
string indata = File.ReadAllText(@"I:\Adventofcode_181201\data181201.txt");
|
||||||
|
//string indata = "+1\r\n-2\r\n+3\r\n+1\r\n+1\r\n-2\r\n";
|
||||||
|
string[] resTab = indata.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
while (!stopped)
|
||||||
|
{
|
||||||
|
varv++;
|
||||||
|
foreach (var str in resTab)
|
||||||
|
{
|
||||||
|
longVar += long.Parse(str);
|
||||||
|
WriteLine($"freq: {longVar} nr :{str.ToString()}");
|
||||||
|
if (checkAdd(resCheck, longVar) > 1)
|
||||||
|
{
|
||||||
|
stopped = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WriteLine($"The answer is {longVar} at varv {varv}");
|
||||||
|
//foreach (var keyStr in resCheck.Keys)
|
||||||
|
//{
|
||||||
|
// WriteLine($"freq: {keyStr} nr :{resCheck[keyStr].ToString()}");
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int checkAdd(Dictionary<string, int> work, long newVal)
|
||||||
|
{
|
||||||
|
int times = 0;
|
||||||
|
int res;
|
||||||
|
if (work.TryGetValue(newVal.ToString(), out res))
|
||||||
|
{
|
||||||
|
work[newVal.ToString()] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
work.Add(newVal.ToString(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
times = work[newVal.ToString()];
|
||||||
|
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
2018_01/Properties/AssemblyInfo.cs
Normal file
36
2018_01/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("2018_01")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("2018_01")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("a3a5185c-c171-42ef-a5af-b4f9a9772231")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
53
2018_02/2018_02.csproj
Normal file
53
2018_02/2018_02.csproj
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{03B8F28E-27B5-44BC-8051-58E2CB771E6B}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>_2018_02</RootNamespace>
|
||||||
|
<AssemblyName>2018_02</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
6
2018_02/App.config
Normal file
6
2018_02/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
136
2018_02/Program.cs
Normal file
136
2018_02/Program.cs
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace _2018_02
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
int twos = 0, threes = 0;
|
||||||
|
|
||||||
|
Dictionary<string, int> resCheck = new Dictionary<string, int>();
|
||||||
|
string indata = File.ReadAllText(@"I:\Adventofcode_181201\data181202.txt");
|
||||||
|
//string indata = "abcdef\r\nbababc\r\nabbcde\r\nabcccd\r\naabcdd\r\nabcdee\r\nababab\r\n";
|
||||||
|
|
||||||
|
string[] resTab = indata.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
foreach (var boxId in resTab)
|
||||||
|
{
|
||||||
|
char[] characters = boxId.ToArray();
|
||||||
|
Array.Sort(characters);
|
||||||
|
analyseString(characters, ref twos, ref threes);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Console.WriteLine($"twos: {twos} threes: {threes} checksum: {twos * threes} ");
|
||||||
|
|
||||||
|
SecondAnalyse(resTab);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void analyseString(char[] characters, ref int twos, ref int threes)
|
||||||
|
{
|
||||||
|
int locTwos = 0, locthrees = 0;
|
||||||
|
char lastChar = ' ';
|
||||||
|
byte cnt = 0;
|
||||||
|
foreach (var tkn in characters)
|
||||||
|
{
|
||||||
|
if (tkn == lastChar)
|
||||||
|
{
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cnt == 2)
|
||||||
|
{
|
||||||
|
if (locTwos == 0)
|
||||||
|
locTwos++;
|
||||||
|
}
|
||||||
|
if (cnt == 3)
|
||||||
|
{
|
||||||
|
if (locthrees == 0)
|
||||||
|
{
|
||||||
|
locthrees++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastChar = tkn;
|
||||||
|
cnt = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cnt == 2)
|
||||||
|
{
|
||||||
|
if (locTwos == 0)
|
||||||
|
locTwos++;
|
||||||
|
}
|
||||||
|
if (cnt == 3)
|
||||||
|
{
|
||||||
|
if (locthrees == 0)
|
||||||
|
{
|
||||||
|
locthrees++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
twos += locTwos;
|
||||||
|
threes += locthrees;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SecondAnalyse(string[] restab)
|
||||||
|
{
|
||||||
|
bool ready = false;
|
||||||
|
var xlen = restab[0].Length;
|
||||||
|
|
||||||
|
foreach (var str in restab)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < xlen; i++)
|
||||||
|
{
|
||||||
|
foreach (var str2 in restab)
|
||||||
|
{
|
||||||
|
if (str2 == str) { }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string stx = "", sty = "";
|
||||||
|
var st0 = stringUtanPos(str, i, out stx);
|
||||||
|
var st1 = stringUtanPos(str2, i, out sty);
|
||||||
|
if (st0 == st1)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine($"box 1: {str},\r\nbox 2: {str2} diff chars {stx} , {sty}\r\n{st0}\r\n{st1}");
|
||||||
|
ready = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (ready) break;
|
||||||
|
}
|
||||||
|
if (ready) break;
|
||||||
|
}
|
||||||
|
if (ready) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string stringUtanPos(string str, int i, out string stx)
|
||||||
|
{
|
||||||
|
string tmp = str;
|
||||||
|
stx = str.Substring(i, 1);
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
tmp = str.Substring(0, i) + str.Substring(i + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp = str.Substring(i+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
2018_02/Properties/AssemblyInfo.cs
Normal file
36
2018_02/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("2018_02")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("2018_02")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("03b8f28e-27b5-44bc-8051-58e2cb771e6b")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
53
2018_03/2018_03.csproj
Normal file
53
2018_03/2018_03.csproj
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{32017090-A2BF-40D9-9652-6F820D58E415}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>_2018_03</RootNamespace>
|
||||||
|
<AssemblyName>2018_03</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
6
2018_03/App.config
Normal file
6
2018_03/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
136
2018_03/Program.cs
Normal file
136
2018_03/Program.cs
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using static System.Console;
|
||||||
|
|
||||||
|
namespace _2018_03
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
int xDim = 0;
|
||||||
|
int yDim = 0;
|
||||||
|
//string indata = File.ReadAllText(@"I:\Adventofcode_181201\data181203.txt");
|
||||||
|
string indata = File.ReadAllText(@"D:\AdventOfCode\data\2018_03_data.txt");
|
||||||
|
//string indata = "#1 @ 1,3: 4x4\r\n#2 @ 3,1: 4x4\r\n#3 @ 5,5: 2x2\r\n";
|
||||||
|
|
||||||
|
string[] resTab = indata.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
int[,] fabricArea = null;
|
||||||
|
|
||||||
|
List<ElveSpace> areas = new List<ElveSpace>();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var str in resTab)
|
||||||
|
{
|
||||||
|
areas.Add(new ElveSpace(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ElveSpace es in areas)
|
||||||
|
{
|
||||||
|
// WriteLine($"Nr {es.SpaceNr} , xpos: {es.xPos} , ypos: {es.yPos} , width: {es.width} , higth: {es.highth} ");
|
||||||
|
|
||||||
|
if (es.bigWidth > xDim)
|
||||||
|
{
|
||||||
|
xDim = es.bigWidth;
|
||||||
|
}
|
||||||
|
if (es.bigHeight > yDim)
|
||||||
|
{
|
||||||
|
yDim = es.bigHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteLine($"the big picture : {xDim} X {yDim}");
|
||||||
|
fabricArea = new int[xDim, yDim];
|
||||||
|
foreach (ElveSpace es in areas)
|
||||||
|
{
|
||||||
|
es.AllocateArea(fabricArea);
|
||||||
|
}
|
||||||
|
int concurredArea = 0;
|
||||||
|
for (int x = 0; x < xDim; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < yDim; y++)
|
||||||
|
{
|
||||||
|
if (fabricArea[x, y] > 1)
|
||||||
|
{
|
||||||
|
concurredArea += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteLine($"dubbeltecknat : {concurredArea} square-inches av {xDim * yDim} square-inches");
|
||||||
|
|
||||||
|
foreach (ElveSpace es in areas)
|
||||||
|
{
|
||||||
|
if (es.CheckNotOverLap(fabricArea))
|
||||||
|
{
|
||||||
|
WriteLine($"Area nr: {es.SpaceNr} is free from concurrers !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ElveSpace
|
||||||
|
{
|
||||||
|
public int SpaceNr { get; set; }
|
||||||
|
|
||||||
|
public int xPos { get; set; }
|
||||||
|
public int yPos { get; set; }
|
||||||
|
public int width { get; set; }
|
||||||
|
public int highth { get; set; }
|
||||||
|
public int bigWidth { get; set; }
|
||||||
|
public int bigHeight { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public ElveSpace(string spcData)
|
||||||
|
{
|
||||||
|
string[] fields = spcData.Split(new char[] { '#', '@', ',', ':', 'x' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
SpaceNr = int.Parse(fields[0]);
|
||||||
|
xPos = int.Parse(fields[1]);
|
||||||
|
yPos = int.Parse(fields[2]);
|
||||||
|
width = int.Parse(fields[3]);
|
||||||
|
highth = int.Parse(fields[4]);
|
||||||
|
|
||||||
|
bigWidth = xPos + width;
|
||||||
|
bigHeight = yPos + highth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AllocateArea(int[,] fabricArea)
|
||||||
|
{
|
||||||
|
for (int i = xPos; i < xPos + width; i++)
|
||||||
|
{
|
||||||
|
for (int j = yPos; j < yPos + highth; j++)
|
||||||
|
{
|
||||||
|
fabricArea[i, j] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckNotOverLap(int[,] fabricArea)
|
||||||
|
{
|
||||||
|
bool answer = true;
|
||||||
|
for (int i = xPos; i < xPos + width; i++)
|
||||||
|
{
|
||||||
|
for (int j = yPos; j < yPos + highth; j++)
|
||||||
|
{
|
||||||
|
if (fabricArea[i, j] > 1)
|
||||||
|
{
|
||||||
|
answer = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (answer == false)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
36
2018_03/Properties/AssemblyInfo.cs
Normal file
36
2018_03/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("2018_03")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("2018_03")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("32017090-a2bf-40d9-9652-6f820d58e415")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
98
2018_04/2018_04.csproj
Normal file
98
2018_04/2018_04.csproj
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{59680EAD-6530-4913-A7D5-C7E1F445D05F}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<RootNamespace>_2018_04</RootNamespace>
|
||||||
|
<AssemblyName>2018_04</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xaml">
|
||||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Page Include="MainWindow.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
6
2018_04/App.config
Normal file
6
2018_04/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
9
2018_04/App.xaml
Normal file
9
2018_04/App.xaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="_2018_04.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:_2018_04"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
17
2018_04/App.xaml.cs
Normal file
17
2018_04/App.xaml.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace _2018_04
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
12
2018_04/MainWindow.xaml
Normal file
12
2018_04/MainWindow.xaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<Window x:Class="_2018_04.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:_2018_04"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
28
2018_04/MainWindow.xaml.cs
Normal file
28
2018_04/MainWindow.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace _2018_04
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
2018_04/Properties/AssemblyInfo.cs
Normal file
55
2018_04/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Resources;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("2018_04")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("2018_04")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
//In order to begin building localizable applications, set
|
||||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||||
|
//the line below to match the UICulture setting in the project file.
|
||||||
|
|
||||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||||
|
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
|
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
71
2018_04/Properties/Resources.Designer.cs
generated
Normal file
71
2018_04/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <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>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace _2018_04.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources
|
||||||
|
{
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ((resourceMan == null))
|
||||||
|
{
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("_2018_04.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
117
2018_04/Properties/Resources.resx
Normal file
117
2018_04/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
30
2018_04/Properties/Settings.Designer.cs
generated
Normal file
30
2018_04/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <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>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace _2018_04.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
2018_04/Properties/Settings.settings
Normal file
7
2018_04/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
||||||
49
AdventOfCode.sln
Normal file
49
AdventOfCode.sln
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.28407.52
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2017_01", "2017_01\2017_01.csproj", "{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2018_01", "2018_01\2018_01.csproj", "{A3A5185C-C171-42EF-A5AF-B4F9A9772231}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2018_02", "2018_02\2018_02.csproj", "{03B8F28E-27B5-44BC-8051-58E2CB771E6B}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2018_03", "2018_03\2018_03.csproj", "{32017090-A2BF-40D9-9652-6F820D58E415}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2018_04", "ConsoleApp1\2018_04.csproj", "{7E85B89B-15D2-4248-AE0D-DD96C84A2E5A}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{06CE1756-7EB8-4E0C-910C-9EC316D4E04E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A3A5185C-C171-42EF-A5AF-B4F9A9772231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A3A5185C-C171-42EF-A5AF-B4F9A9772231}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A3A5185C-C171-42EF-A5AF-B4F9A9772231}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A3A5185C-C171-42EF-A5AF-B4F9A9772231}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{03B8F28E-27B5-44BC-8051-58E2CB771E6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{03B8F28E-27B5-44BC-8051-58E2CB771E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{03B8F28E-27B5-44BC-8051-58E2CB771E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{03B8F28E-27B5-44BC-8051-58E2CB771E6B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{32017090-A2BF-40D9-9652-6F820D58E415}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{32017090-A2BF-40D9-9652-6F820D58E415}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{32017090-A2BF-40D9-9652-6F820D58E415}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{32017090-A2BF-40D9-9652-6F820D58E415}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7E85B89B-15D2-4248-AE0D-DD96C84A2E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7E85B89B-15D2-4248-AE0D-DD96C84A2E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7E85B89B-15D2-4248-AE0D-DD96C84A2E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7E85B89B-15D2-4248-AE0D-DD96C84A2E5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {03AD54F0-CF5D-409C-801B-45464BFF9001}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
53
ConsoleApp1/2018_04.csproj
Normal file
53
ConsoleApp1/2018_04.csproj
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{7E85B89B-15D2-4248-AE0D-DD96C84A2E5A}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>ConsoleApp1</RootNamespace>
|
||||||
|
<AssemblyName>ConsoleApp1</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
6
ConsoleApp1/App.config
Normal file
6
ConsoleApp1/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
153
ConsoleApp1/Program.cs
Normal file
153
ConsoleApp1/Program.cs
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using static System.Console;
|
||||||
|
|
||||||
|
namespace _2018_04
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string[] splitter = new string[] { "[", "]" };
|
||||||
|
|
||||||
|
string[] resTab = File.ReadAllLines(@"D:\AdventOfCode\data\2018_04_data.txt");
|
||||||
|
|
||||||
|
Array.Sort(resTab);
|
||||||
|
Dictionary<int, GardDay> gdList = new Dictionary<int, GardDay>();
|
||||||
|
GardDay gd = null;
|
||||||
|
|
||||||
|
//[1518-11-01 00:00] Guard #10 begins shift
|
||||||
|
//[1518-11-01 00:05] falls asleep
|
||||||
|
//[1518-11-01 00:25] wakes up
|
||||||
|
//[1518-11-01 00:30] falls asleep
|
||||||
|
//[1518-11-01 00:55] wakes up
|
||||||
|
|
||||||
|
foreach (var str in resTab)
|
||||||
|
{
|
||||||
|
if (str.Contains("#"))
|
||||||
|
{
|
||||||
|
if (gd != null)
|
||||||
|
{
|
||||||
|
WriteLine(gd.ToString());
|
||||||
|
if (gdList.ContainsKey(gd.GardNr))
|
||||||
|
{
|
||||||
|
for (int vekt = 0; vekt < gdList[gd.GardNr].MinTabell.Length; vekt++)
|
||||||
|
{
|
||||||
|
gdList[gd.GardNr].MinTabell[vekt] += gd.MinTabell[vekt];
|
||||||
|
}
|
||||||
|
gdList[gd.GardNr].SleepMinutes += gd.SleepMinutes;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gd.fillMinTable();
|
||||||
|
gdList.Add(gd.GardNr, gd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gd = new GardDay(str);
|
||||||
|
// WriteLine($"Gard day = {gd.ToString()}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gd.fillNext(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach( int key in gdList.Keys)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//gdList.Add(gd.GardNr, gd);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class GardDay
|
||||||
|
{
|
||||||
|
string[] splitter = new string[] { "[", "]" };
|
||||||
|
public int GardNr { get; set; }
|
||||||
|
public Dictionary<DateTime, string> TimeStamp { get; set; }
|
||||||
|
public int[] MinTabell { get; set; }
|
||||||
|
public int SleepMinutes { get; set; }
|
||||||
|
public void fillMinTable()
|
||||||
|
{
|
||||||
|
int saveMin = -1;
|
||||||
|
foreach (KeyValuePair<DateTime, string> pair in TimeStamp)
|
||||||
|
{
|
||||||
|
if (pair.Value == "sleep")
|
||||||
|
{
|
||||||
|
saveMin = pair.Key.Minute;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (saveMin > -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = saveMin; i < pair.Key.Minute; i++)
|
||||||
|
{
|
||||||
|
MinTabell[i]++;
|
||||||
|
SleepMinutes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public GardDay(string inRow)
|
||||||
|
{
|
||||||
|
MinTabell = new int[60];
|
||||||
|
SleepMinutes = 0;
|
||||||
|
string outStr = "";
|
||||||
|
fillNext(inRow, out outStr);
|
||||||
|
var xwords = outStr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (var ystr in xwords)
|
||||||
|
{
|
||||||
|
if (ystr.Contains("#"))
|
||||||
|
{
|
||||||
|
GardNr = int.Parse(ystr.Substring(ystr.IndexOf("#") + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillNext(string inRow)
|
||||||
|
{
|
||||||
|
string tmpOut = null;
|
||||||
|
fillNext(inRow, out tmpOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillNext(string inRow, out string outStr)
|
||||||
|
{
|
||||||
|
string[] xrow = inRow.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
outStr = xrow[1];
|
||||||
|
DateTime ts = DateTime.Parse(xrow[0]);
|
||||||
|
if (TimeStamp == null)
|
||||||
|
{
|
||||||
|
TimeStamp = new Dictionary<DateTime, string>();
|
||||||
|
}
|
||||||
|
string tmpStep = "sleep";
|
||||||
|
if (outStr.Contains("Guard") || outStr.Contains("wakes"))
|
||||||
|
{
|
||||||
|
tmpStep = "awake";
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeStamp.Add(ts, tmpStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder outTxt = new StringBuilder();
|
||||||
|
outTxt.Append($"gardnr {GardNr}");
|
||||||
|
foreach (var key in TimeStamp.Keys)
|
||||||
|
{
|
||||||
|
outTxt.Append($" Time : {key}, {TimeStamp[key]}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return outTxt.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
36
ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("ConsoleApp1")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ConsoleApp1")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("7e85b89b-15d2-4248-ae0d-dd96c84a2e5a")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
Reference in New Issue
Block a user