first commit

This commit is contained in:
2019-12-03 18:33:35 -05:00
commit 06176e2ec2
30 changed files with 503 additions and 0 deletions

Binary file not shown.

Binary file not shown.

31
AdventOfCode2019.sln Normal file
View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29009.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProblemOne", "ProblemOne\ProblemOne.csproj", "{58FECE0A-7AC6-47CC-A93A-6D843FC040A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProblemTwo", "ProblemTwo\ProblemTwo.csproj", "{B2FF7525-4241-41D1-B325-F814DEB7672F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{58FECE0A-7AC6-47CC-A93A-6D843FC040A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{58FECE0A-7AC6-47CC-A93A-6D843FC040A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58FECE0A-7AC6-47CC-A93A-6D843FC040A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58FECE0A-7AC6-47CC-A93A-6D843FC040A0}.Release|Any CPU.Build.0 = Release|Any CPU
{B2FF7525-4241-41D1-B325-F814DEB7672F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2FF7525-4241-41D1-B325-F814DEB7672F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2FF7525-4241-41D1-B325-F814DEB7672F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2FF7525-4241-41D1-B325-F814DEB7672F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EBF8B716-389F-47B8-B749-02492D04E273}
EndGlobalSection
EndGlobal

6
ProblemOne/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View 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>{58FECE0A-7AC6-47CC-A93A-6D843FC040A0}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ProblemOne</RootNamespace>
<AssemblyName>ProblemOne</AssemblyName>
<TargetFrameworkVersion>v4.7.2</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>

153
ProblemOne/Program.cs Normal file
View File

@@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProblemOne
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetTotalFuelRequiredPartOne());
Console.WriteLine(GetTotalFuelRequiredPartTwo());
Console.ReadLine();
}
static int GetTotalFuelRequiredPartTwo()
{
var totalFuelRequired = 0;
foreach (var massInput in MassInputs)
{
var fuelRequired = massInput;
do
{
fuelRequired = GetFuelRequiredPartOne(fuelRequired);
totalFuelRequired += fuelRequired;
}
while (GetFuelRequiredPartOne(fuelRequired) > 0);
}
return totalFuelRequired;
}
static int GetTotalFuelRequiredPartOne()
{
var totalFuelRequired = 0;
foreach (var massInput in MassInputs)
totalFuelRequired += GetFuelRequiredPartOne(massInput);
return totalFuelRequired;
}
static int GetFuelRequiredPartOne(int massInput)
{
return (int)(Math.Floor(massInput / 3.0M) - 2.0M);
}
static List<int> MassInputs = new List<int>()
{
92349,
57040,
64079,
121555,
143735,
64642,
104858,
144446,
88871,
62338,
113424,
59960,
53999,
86867,
67224,
124130,
108921,
130492,
120361,
74426,
70397,
88106,
125442,
74237,
137818,
66633,
71756,
143276,
143456,
135698,
121124,
67739,
112861,
78572,
73565,
111899,
57543,
130314,
121605,
121426,
117143,
129957,
98042,
104760,
144846,
131238,
101076,
53328,
83592,
104077,
101952,
54137,
115363,
60556,
133086,
113361,
117829,
75003,
93729,
140022,
126219,
59907,
140589,
91812,
50485,
56232,
92858,
106820,
123423,
98553,
135315,
95583,
72278,
98702,
55709,
146773,
89719,
134752,
79562,
70455,
88468,
139824,
138646,
117516,
123267,
113754,
120353,
139145,
53219,
63053,
131434,
91705,
53650,
145234,
78461,
119587,
108976,
113613,
121790,
120366
};
}
}

View 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("ProblemOne")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProblemOne")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[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("58fece0a-7ac6-47cc-a93a-6d843fc040a0")]
// 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")]

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

View File

@@ -0,0 +1 @@
32b0cee30476cf404bcb931ca8435e90f1b2fd77

View File

@@ -0,0 +1,7 @@
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\bin\Debug\ProblemOne.exe.config
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\bin\Debug\ProblemOne.exe
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\bin\Debug\ProblemOne.pdb
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\obj\Debug\ProblemOne.csprojAssemblyReference.cache
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\obj\Debug\ProblemOne.csproj.CoreCompileInputs.cache
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\obj\Debug\ProblemOne.exe
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemOne\ProblemOne\obj\Debug\ProblemOne.pdb

Binary file not shown.

Binary file not shown.

6
ProblemTwo/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View 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>{B2FF7525-4241-41D1-B325-F814DEB7672F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ProblemTwo</RootNamespace>
<AssemblyName>ProblemTwo</AssemblyName>
<TargetFrameworkVersion>v4.7.2</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>

101
ProblemTwo/Program.cs Normal file
View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProblemTwo
{
class Program
{
static void Main(string[] args)
{
/* PART ONE */
var program = LoadProgramIntoMemory(ProgramStringPartOne);
program = SeedProgram(program, 12, 2);
program = ExecuteProgram(program);
Console.WriteLine(program[0]);
/* PART TWO */
for (int noun = 0; noun < 100; noun++)
{
for (int verb = 0; verb < 100; verb++)
{
program = LoadProgramIntoMemory(ProgramStringPartOne);
program = SeedProgram(program, noun, verb);
program = ExecuteProgram(program);
if (program[0] == 19690720)
Console.WriteLine(100 * noun + verb);
}
}
Console.ReadLine();
}
static int[] LoadProgramIntoMemory(string strProgram)
{
return strProgram.Split(',').Select(x => int.Parse(x)).ToArray();
}
static int[] SeedProgram(int[] program, int noun, int verb)
{
program[1] = noun;
program[2] = verb;
return program;
}
static int[] ExecuteProgram(int[] program)
{
int parameterCount = 0;
for (int i = 0; i < program.Length; i = i + parameterCount)
{
var operationCode = (Operations)program[i];
if (operationCode == Operations.Add)
{
var inputOne = program[i + 1];
var inputTwo = program[i + 2];
var result = program[i + 3];
program[result] = program[inputOne] + program[inputTwo];
parameterCount = OperationParameterCount.Add;
}
else if (operationCode == Operations.Multiply)
{
var inputOne = program[i + 1];
var inputTwo = program[i + 2];
var result = program[i + 3];
program[result] = program[inputOne] * program[inputTwo];
parameterCount = OperationParameterCount.Multiply;
}
else if (operationCode == Operations.Exit)
{
break;
}
else
throw new Exception("Unsupported Operation");
}
return program;
}
enum Operations
{
Add = 1,
Multiply = 2,
Exit = 99
}
static class OperationParameterCount
{
public static int Add => 4;
public static int Multiply => 4;
public static int Exit => 0;
}
static string ProgramStringPartOne = "1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,6,19,1,5,19,23,1,23,6,27,1,5,27,31,1,31,6,35,1,9,35,39,2,10,39,43,1,43,6,47,2,6,47,51,1,5,51,55,1,55,13,59,1,59,10,63,2,10,63,67,1,9,67,71,2,6,71,75,1,5,75,79,2,79,13,83,1,83,5,87,1,87,9,91,1,5,91,95,1,5,95,99,1,99,13,103,1,10,103,107,1,107,9,111,1,6,111,115,2,115,13,119,1,10,119,123,2,123,6,127,1,5,127,131,1,5,131,135,1,135,6,139,2,139,10,143,2,143,9,147,1,147,6,151,1,151,13,155,2,155,9,159,1,6,159,163,1,5,163,167,1,5,167,171,1,10,171,175,1,13,175,179,1,179,2,183,1,9,183,0,99,2,14,0,0";
}
}

View 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("ProblemTwo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProblemTwo")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[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("b2ff7525-4241-41d1-b325-f814deb7672f")]
// 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")]

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

View File

@@ -0,0 +1 @@
32b0cee30476cf404bcb931ca8435e90f1b2fd77

View File

@@ -0,0 +1,7 @@
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\bin\Debug\ProblemTwo.exe.config
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\bin\Debug\ProblemTwo.exe
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\bin\Debug\ProblemTwo.pdb
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\obj\Debug\ProblemTwo.csprojAssemblyReference.cache
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\obj\Debug\ProblemTwo.csproj.CoreCompileInputs.cache
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\obj\Debug\ProblemTwo.exe
C:\Users\grodriguez\source\repos\AdventOfCode\2019\ProblemTwo\obj\Debug\ProblemTwo.pdb

Binary file not shown.

Binary file not shown.