commit 7fe4f12015107df54ce03d187bf71956e2039e8c Author: Valeriano A.R Date: Fri Dec 7 23:46:42 2018 +0100 Day01 part 1, statement and failing tests diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0ea75b --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.suo +*.exe +*.dll +*.pdb +*.user +*/bin/* +*/obj/* +/.vs/* +packages/* diff --git a/AdventOfCode2017.Tests/AdventOfCode2017.Tests.csproj b/AdventOfCode2017.Tests/AdventOfCode2017.Tests.csproj new file mode 100644 index 0000000..c6c7be2 --- /dev/null +++ b/AdventOfCode2017.Tests/AdventOfCode2017.Tests.csproj @@ -0,0 +1,106 @@ + + + + + Debug + AnyCPU + {3537CE59-1C57-481B-85F7-3F2A1F0EDE1D} + Library + Properties + AdventOfCode2017.Tests + AdventOfCode2017.Tests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + + + + + + + {49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66} + AdventOfCode2017 + + + + + + + False + + + False + + + False + + + False + + + + + + + + + Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. + + + + + + + \ No newline at end of file diff --git a/AdventOfCode2017.Tests/Day01_Tests.cs b/AdventOfCode2017.Tests/Day01_Tests.cs new file mode 100644 index 0000000..6f11cb5 --- /dev/null +++ b/AdventOfCode2017.Tests/Day01_Tests.cs @@ -0,0 +1,54 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using AdventOfCode2017; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdventOfCode2017.Tests +{ + [TestClass()] + public class Day01_Tests + { + [TestMethod()] + public void ResolvePart1__Test1() + { + Day01 day01 = new Day01(); + + string result = day01.ResolvePart1(new string[] { "1122", }); + + Assert.AreEqual("3", result); + } + + [TestMethod()] + public void ResolvePart1__Test2() + { + Day01 day01 = new Day01(); + + string result = day01.ResolvePart1(new string[] { "1111", }); + + Assert.AreEqual("4", result); + } + + [TestMethod()] + public void ResolvePart1__Test3() + { + Day01 day01 = new Day01(); + + string result = day01.ResolvePart1(new string[] { "1234", }); + + Assert.AreEqual("0", result); + } + + [TestMethod()] + public void ResolvePart1__Test4() + { + Day01 day01 = new Day01(); + + string result = day01.ResolvePart1(new string[] { "91212129", }); + + Assert.AreEqual("9", result); + } + } +} \ No newline at end of file diff --git a/AdventOfCode2017.Tests/Properties/AssemblyInfo.cs b/AdventOfCode2017.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3f2563a --- /dev/null +++ b/AdventOfCode2017.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// La información general de un ensamblado se controla mediante el siguiente +// conjunto de atributos. Cambie estos valores de atributo para modificar la información +// asociada con un ensamblado. +[assembly: AssemblyTitle("AdventOfCode2017.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AdventOfCode2017.Tests")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles +// para los componentes COM. Si es necesario obtener acceso a un tipo en este ensamblado desde +// COM, establezca el atributo ComVisible en true en este tipo. +[assembly: ComVisible(false)] + +// El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM. +[assembly: Guid("3537ce59-1c57-481b-85f7-3f2a1f0ede1d")] + +// La información de versión de un ensamblado consta de los cuatro valores siguientes: +// +// Versión principal +// Versión secundaria +// Número de compilación +// Revisión +// +// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión +// mediante el carácter '*', como se muestra a continuación: +//[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AdventOfCode2017.Tests/packages.config b/AdventOfCode2017.Tests/packages.config new file mode 100644 index 0000000..102a45c --- /dev/null +++ b/AdventOfCode2017.Tests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/AdventOfCode2017.sln b/AdventOfCode2017.sln new file mode 100644 index 0000000..fc7649f --- /dev/null +++ b/AdventOfCode2017.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode2017", "AdventOfCode2017\AdventOfCode2017.csproj", "{49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode2017.Tests", "AdventOfCode2017.Tests\AdventOfCode2017.Tests.csproj", "{3537CE59-1C57-481B-85F7-3F2A1F0EDE1D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66}.Release|Any CPU.Build.0 = Release|Any CPU + {3537CE59-1C57-481B-85F7-3F2A1F0EDE1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3537CE59-1C57-481B-85F7-3F2A1F0EDE1D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3537CE59-1C57-481B-85F7-3F2A1F0EDE1D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3537CE59-1C57-481B-85F7-3F2A1F0EDE1D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1D80D845-47C9-4610-BA3D-DCAAAD773CA1} + EndGlobalSection +EndGlobal diff --git a/AdventOfCode2017/AdventOfCode2017.csproj b/AdventOfCode2017/AdventOfCode2017.csproj new file mode 100644 index 0000000..fa0de58 --- /dev/null +++ b/AdventOfCode2017/AdventOfCode2017.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {49C8A67C-D94C-4CFB-B7FB-C19A1A83CA66} + Exe + AdventOfCode2017 + AdventOfCode2017 + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/AdventOfCode2017/Day01.cs b/AdventOfCode2017/Day01.cs new file mode 100644 index 0000000..076ea49 --- /dev/null +++ b/AdventOfCode2017/Day01.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdventOfCode2017 +{ + /* + * + --- Day 1: Inverse Captcha --- + + The night before Christmas, one of Santa's Elves calls you in a panic. "The printer's broken! We can't print the Naughty or Nice List!" By the time you make it to sub-basement 17, there are only a few minutes until midnight. "We have a big problem," she says; "there must be almost fifty bugs in this system, but nothing else can print The List. Stand in this square, quick! There's no time to explain; if you can convince them to pay you in stars, you'll be able to--" She pulls a lever and the world goes blurry. + + When your eyes can focus again, everything seems a lot more pixelated than before. She must have sent you inside the computer! You check the system clock: 25 milliseconds until midnight. With that much time, you should be able to collect all fifty stars by December 25th. + + Collect stars by solving puzzles. Two puzzles will be made available on each day millisecond in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! + + You're standing in a room with "digitization quarantine" written in LEDs along one wall. The only door is locked, but it includes a small interface. "Restricted Area - Strictly No Digitized Users Allowed." + + It goes on to explain that you may only leave by solving a captcha to prove you're not a human. Apparently, you only get one millisecond to solve the captcha: too fast for a normal human, but it feels like hours to you. + + The captcha requires you to review a sequence of digits (your puzzle input) and find the sum of all digits that match the next digit in the list. The list is circular, so the digit after the last digit is the first digit in the list. + + For example: + + 1122 produces a sum of 3 (1 + 2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit. + 1111 produces 4 because each digit (all 1) matches the next. + 1234 produces 0 because no digit matches the next. + 91212129 produces 9 because the only digit that matches the next one is the last digit, 9. + + What is the solution to your captcha? + + */ + + public class Day01 : IDay + { + public string ResolvePart1(string[] inputs) + { + return null; + } + + public string ResolvePart2(string[] inputs) + { + return null; + } + } +} diff --git a/AdventOfCode2017/IDay.cs b/AdventOfCode2017/IDay.cs new file mode 100644 index 0000000..abd4c8c --- /dev/null +++ b/AdventOfCode2017/IDay.cs @@ -0,0 +1,8 @@ +namespace AdventOfCode2017 +{ + public interface IDay + { + string ResolvePart1(string[] inputs); + string ResolvePart2(string[] inputs); + } +} diff --git a/AdventOfCode2017/Program.cs b/AdventOfCode2017/Program.cs new file mode 100644 index 0000000..153b1e7 --- /dev/null +++ b/AdventOfCode2017/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.IO; + +namespace AdventOfCode2017 +{ + public class Program + { + private static void Main(string[] args) + { + int currentDayNumber = 1; + IDay currentDay = null; + + switch (currentDayNumber) + { + case 1: currentDay = new Day01(); break; + } + + string[] linesDay = File.ReadAllLines(string.Format("inputs/Day{0:00}.txt", currentDayNumber)); + string resultPart1 = currentDay.ResolvePart1(linesDay); + Console.WriteLine("Day{1:00} Result Part1: {0}", resultPart1, currentDayNumber); + string resultPart2 = currentDay.ResolvePart2(linesDay); + Console.WriteLine("Day{1:00} Result Part2: {0}", resultPart2, currentDayNumber); + + Console.Read(); + } + } +} diff --git a/AdventOfCode2017/Properties/AssemblyInfo.cs b/AdventOfCode2017/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7593549 --- /dev/null +++ b/AdventOfCode2017/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("AdventOfCode2017")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AdventOfCode2017")] +[assembly: AssemblyCopyright("Copyright © Valeriano A.R. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] +[assembly: Guid("49c8a67c-d94c-4cfb-b7fb-c19a1a83ca66")] +[assembly: AssemblyFileVersion("1.0.0")] diff --git a/AdventOfCode2017/inputs/Day01.txt b/AdventOfCode2017/inputs/Day01.txt new file mode 100644 index 0000000..4ee62ea --- /dev/null +++ b/AdventOfCode2017/inputs/Day01.txt @@ -0,0 +1 @@ +818275977931166178424892653779931342156567268946849597948944469863818248114327524824136924486891794739281668741616818614613222585132742386168687517939432911753846817997473555693821316918473474459788714917665794336753628836231159578734813485687247273288926216976992516314415836985611354682821892793983922755395577592859959966574329787693934242233159947846757279523939217844194346599494858459582798326799512571365294673978955928416955127211624234143497546729348687844317864243859238665326784414349618985832259224761857371389133635711819476969854584123589566163491796442167815899539788237118339218699137497532932492226948892362554937381497389469981346971998271644362944839883953967698665427314592438958181697639594631142991156327257413186621923369632466918836951277519421695264986942261781256412377711245825379412978876134267384793694756732246799739464721215446477972737883445615664755923441441781128933369585655925615257548499628878242122434979197969569971961379367756499884537433839217835728263798431874654317137955175565253555735968376115749641527957935691487965161211853476747758982854811367422656321836839326818976668191525884763294465366151349347633968321457954152621175837754723675485348339261288195865348545793575843874731785852718281311481217515834822185477982342271937155479432673815629144664144538221768992733498856934255518875381672342521819499939835919827166318715849161715775427981485233467222586764392783699273452228728667175488552924399518855743923659815483988899924199449721321589476864161778841352853573584489497263216627369841455165476954483715112127465311353411346132671561568444626828453687183385215975319858714144975174516356117245993696521941589168394574287785233685284294357548156487538175462176268162852746996633977948755296869616778577327951858348313582783675149343562362974553976147259225311183729415381527435926224781181987111454447371894645359797229493458443522549386769845742557644349554641538488252581267341635761715674381775778868374988451463624332123361576518411234438681171864923916896987836734129295354684962897616358722633724198278552339794629939574841672355699222747886785616814449297817352118452284785694551841431869545321438468118