Solved Day 2 Part 1 :D

master
gnomerd 5 years ago
parent c9714949f6
commit 8f0b6f102c
  1. 36
      2019/Day2/Part1.cs
  2. 18
      2019/Day2/Program.cs
  3. BIN
      2019/Day2/bin/Debug/netcoreapp2.2/Day2.dll
  4. BIN
      2019/Day2/bin/Debug/netcoreapp2.2/Day2.pdb
  5. 5
      2019/Day2/bin/Debug/netcoreapp2.2/Day2.runtimeconfig.dev.json
  6. 2
      2019/Day2/obj/Day2.csproj.nuget.cache
  7. 10
      2019/Day2/obj/Day2.csproj.nuget.g.props
  8. 4
      2019/Day2/obj/Day2.csproj.nuget.g.targets
  9. BIN
      2019/Day2/obj/Debug/netcoreapp2.2/Day2.assets.cache
  10. 2
      2019/Day2/obj/Debug/netcoreapp2.2/Day2.csproj.CoreCompileInputs.cache
  11. 33
      2019/Day2/obj/Debug/netcoreapp2.2/Day2.csproj.FileListAbsolute.txt
  12. BIN
      2019/Day2/obj/Debug/netcoreapp2.2/Day2.csprojAssemblyReference.cache
  13. BIN
      2019/Day2/obj/Debug/netcoreapp2.2/Day2.dll
  14. BIN
      2019/Day2/obj/Debug/netcoreapp2.2/Day2.pdb
  15. 18
      2019/Day2/obj/project.assets.json

@ -10,30 +10,40 @@ namespace Part1 {
}
}
public class compile {
public int NEXT = 4; // steps per opcode
public const int NEXT = 4; // steps per opcode
public bool writedebug = true;
public vars.intcode getOpcode( int opcode ) {
return (vars.intcode)opcode; // return the opcode, if 1 then return "ADD" etc
}
public bool isOpcode( int i ) {
return false;
public void Debug( string txt ) {
if( writedebug == true ) {
Console.WriteLine( txt );
}
}
public int[] runopcode( int[] array, int i, vars.intcode opcode ) {
int writepos = array[array[i+3]]; // get the write pos
public dynamic runopcode( int[] array, int i, vars.intcode opcode ) {
int writepos;
if( opcode == vars.intcode.ADD ) {
int sum = array[array[i+1]] + array[array[i+2]]; // get the two values
Console.WriteLine( "ADD (" + i.ToString() + ") " + "Sum=" + sum.ToString() + " at i=" + array[i+3].ToString() );
writepos = array[i+3]; // get the write pos
Debug( "ADD (" + i.ToString() + "/" + array.Length.ToString() + ") " + "Sum=" + sum.ToString() + " at i=" + writepos.ToString() );
array[writepos] = sum; // write the value
} else if( opcode == vars.intcode.MULT ) {
int product = array[array[i+1]] * array[array[i+2]]; // get the two values
Console.WriteLine( "MULT (" + i.ToString() + ") " + "Product=" + product.ToString() + " at i=" + array[i+3].ToString() );
writepos = array[i+3];
Debug( "MULT (" + i.ToString() + "/" + array.Length.ToString() + ") " + "Product=" + product.ToString() + " at i=" + writepos.ToString() );
array[writepos] = product; // write the value
} else if ( opcode == vars.intcode.STOP ) {
} else if ( opcode == vars.intcode.STOP ) {
Debug( "STOP (" + i.ToString() + "/" + array.Length.ToString() + ")" );
}
return array;
@ -41,15 +51,13 @@ namespace Part1 {
public int[] intcode( int[] input ) {
int[] output = input; // make an instanse of the input where we can change stuff
//int opcode_count = 0;
for( int i = 0; i < output.Length; i+= NEXT ) {
Console.WriteLine(i);
Console.WriteLine( "\n----Running Intcode----" );
for( int i = 0; i < output.Length; i+= NEXT ) {
vars.intcode opcode = getOpcode(input[i]);
output = runopcode( output, i, opcode );
//Console.WriteLine( getOpcode(output[i]).ToString() + " | " + i.ToString() );
if( (int)output[i] == 99 ) { break; }
}
Console.WriteLine( "----Intcode finished----\n" );
return output;
}
}

@ -12,8 +12,24 @@ namespace Day2 {
int[] output = new int[intcodes.Length];
Part1.compile compile = new Part1.compile();
compile.intcode( intcodes );
//// Part 1 stuff ////
intcodes[1] = 12;
intcodes[2] = 2;
output = compile.intcode( intcodes ); // run the intcode program
Console.WriteLine("\n--Intcode result--");
for( int i = 0; i < output.Length; i++ ) {
if( i != output.Length - 1 ) {
Console.Write( output[i].ToString() + "," );
} else {
Console.Write( output[i].ToString() + "\n" );
}
}
Console.WriteLine( "--End of Intcode result--\n" );
Console.WriteLine( "Part 1 result: " + output[0].ToString() ); // get the pos 0
}
}
}

@ -1,9 +1,8 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\elias.almqvist\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\elias.almqvist\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
"/home/elal/.dotnet/store/|arch|/|tfm|",
"/home/elal/.nuget/packages"
]
}
}

@ -1,5 +1,5 @@
{
"version": 1,
"dgSpecHash": "k94jWAVAo0NJ8nobTwOKlsjof88fE7r24yVvZ8q7gCAnxQUY11s52T3YOZ43y8pYkXSUpnffhxCmrqevKrUTRg==",
"dgSpecHash": "WGPy0F+3AX2FrBKpPAYLKoPyKm8mT9nvSxwf1DU0kcg+H41fJVNHn+vTzdr7A/b3qqioCrpqhVX0rXrCRgYD0A==",
"success": true
}

@ -3,16 +3,16 @@
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\elias.almqvist\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/home/elal/Projects/adventofcode/2019/Day2/obj/project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/elal/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/elal/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.9.4</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.netcore.app/2.2.0/build/netcoreapp2.2/Microsoft.NETCore.App.props" Condition="Exists('$(NuGetPackageRoot)microsoft.netcore.app/2.2.0/build/netcoreapp2.2/Microsoft.NETCore.App.props')" />
</ImportGroup>
</Project>

@ -4,7 +4,7 @@
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.targets')" />
<Import Project="$(NuGetPackageRoot)netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.netcore.app/2.2.0/build/netcoreapp2.2/Microsoft.NETCore.App.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.netcore.app/2.2.0/build/netcoreapp2.2/Microsoft.NETCore.App.targets')" />
</ImportGroup>
</Project>

@ -1 +1 @@
f69870805a1a9a2284bc4856da9b8fe4d4374980
9fe783133b7f321bdac60ee865e123f6adce08e3

@ -1,11 +1,22 @@
C:\EliasPrograms\adventofcode\2019\Day2\obj\Debug\netcoreapp2.2\Day2.csprojAssemblyReference.cache
C:\EliasPrograms\adventofcode\2019\Day2\obj\Debug\netcoreapp2.2\Day2.csproj.CoreCompileInputs.cache
C:\EliasPrograms\adventofcode\2019\Day2\obj\Debug\netcoreapp2.2\Day2.AssemblyInfoInputs.cache
C:\EliasPrograms\adventofcode\2019\Day2\obj\Debug\netcoreapp2.2\Day2.AssemblyInfo.cs
C:\EliasPrograms\adventofcode\2019\Day2\bin\Debug\netcoreapp2.2\Day2.deps.json
C:\EliasPrograms\adventofcode\2019\Day2\bin\Debug\netcoreapp2.2\Day2.runtimeconfig.json
C:\EliasPrograms\adventofcode\2019\Day2\bin\Debug\netcoreapp2.2\Day2.runtimeconfig.dev.json
C:\EliasPrograms\adventofcode\2019\Day2\bin\Debug\netcoreapp2.2\Day2.dll
C:\EliasPrograms\adventofcode\2019\Day2\bin\Debug\netcoreapp2.2\Day2.pdb
C:\EliasPrograms\adventofcode\2019\Day2\obj\Debug\netcoreapp2.2\Day2.dll
C:\EliasPrograms\adventofcode\2019\Day2\obj\Debug\netcoreapp2.2\Day2.pdb
C:/EliasPrograms/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.csprojAssemblyReference.cache
C:/EliasPrograms/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.csproj.CoreCompileInputs.cache
C:/EliasPrograms/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.AssemblyInfoInputs.cache
C:/EliasPrograms/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.AssemblyInfo.cs
C:/EliasPrograms/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.deps.json
C:/EliasPrograms/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.runtimeconfig.json
C:/EliasPrograms/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.runtimeconfig.dev.json
C:/EliasPrograms/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.dll
C:/EliasPrograms/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.pdb
C:/EliasPrograms/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.dll
C:/EliasPrograms/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.pdb
/home/elal/Projects/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.deps.json
/home/elal/Projects/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.runtimeconfig.json
/home/elal/Projects/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.runtimeconfig.dev.json
/home/elal/Projects/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.dll
/home/elal/Projects/adventofcode/2019/Day2/bin/Debug/netcoreapp2.2/Day2.pdb
/home/elal/Projects/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.csprojAssemblyReference.cache
/home/elal/Projects/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.csproj.CoreCompileInputs.cache
/home/elal/Projects/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.AssemblyInfoInputs.cache
/home/elal/Projects/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.AssemblyInfo.cs
/home/elal/Projects/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.dll
/home/elal/Projects/adventofcode/2019/Day2/obj/Debug/netcoreapp2.2/Day2.pdb

@ -688,30 +688,24 @@
]
},
"packageFolders": {
"C:\\Users\\elias.almqvist\\.nuget\\packages\\": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
"/home/elal/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "c:\\EliasPrograms\\adventofcode\\2019\\Day2\\Day2.csproj",
"projectUniqueName": "/home/elal/Projects/adventofcode/2019/Day2/Day2.csproj",
"projectName": "Day2",
"projectPath": "c:\\EliasPrograms\\adventofcode\\2019\\Day2\\Day2.csproj",
"packagesPath": "C:\\Users\\elias.almqvist\\.nuget\\packages\\",
"outputPath": "c:\\EliasPrograms\\adventofcode\\2019\\Day2\\obj\\",
"projectPath": "/home/elal/Projects/adventofcode/2019/Day2/Day2.csproj",
"packagesPath": "/home/elal/.nuget/packages/",
"outputPath": "/home/elal/Projects/adventofcode/2019/Day2/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\elias.almqvist\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
"/home/elal/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp2.2"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {

Loading…
Cancel
Save