commit 9796ca03afd251e335f75fbb120b1086a9aa9210 Author: Travis Rivera Date: Sun Mar 17 18:23:11 2024 -0400 Question15 solved (time exceeded 25 minutes) diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..bb49b81 --- /dev/null +++ b/Program.cs @@ -0,0 +1,6 @@ +// See https://aka.ms/new-console-template for more information +using projectEuler; + +Console.WriteLine("Hello, World!"); +var question = question15.Solve(21,21); +Console.WriteLine(question); \ No newline at end of file diff --git a/ProjectEuler.csproj b/ProjectEuler.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/ProjectEuler.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ProjectEuler.sln b/ProjectEuler.sln new file mode 100644 index 0000000..6a456d2 --- /dev/null +++ b/ProjectEuler.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectEuler", "ProjectEuler.csproj", "{FE2E32A1-5E96-45B8-AE16-71BEC7A0DDA7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FE2E32A1-5E96-45B8-AE16-71BEC7A0DDA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE2E32A1-5E96-45B8-AE16-71BEC7A0DDA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE2E32A1-5E96-45B8-AE16-71BEC7A0DDA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE2E32A1-5E96-45B8-AE16-71BEC7A0DDA7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FF2A347A-C997-4486-9BA2-2D8CC4DD0122} + EndGlobalSection +EndGlobal diff --git a/bin/Debug/net8.0/ProjectEuler.deps.json b/bin/Debug/net8.0/ProjectEuler.deps.json new file mode 100644 index 0000000..32d80ce --- /dev/null +++ b/bin/Debug/net8.0/ProjectEuler.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v8.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v8.0": { + "ProjectEuler/1.0.0": { + "runtime": { + "ProjectEuler.dll": {} + } + } + } + }, + "libraries": { + "ProjectEuler/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net8.0/ProjectEuler.dll b/bin/Debug/net8.0/ProjectEuler.dll new file mode 100644 index 0000000..4478529 Binary files /dev/null and b/bin/Debug/net8.0/ProjectEuler.dll differ diff --git a/bin/Debug/net8.0/ProjectEuler.exe b/bin/Debug/net8.0/ProjectEuler.exe new file mode 100644 index 0000000..60a2a20 Binary files /dev/null and b/bin/Debug/net8.0/ProjectEuler.exe differ diff --git a/bin/Debug/net8.0/ProjectEuler.pdb b/bin/Debug/net8.0/ProjectEuler.pdb new file mode 100644 index 0000000..69e5b05 Binary files /dev/null and b/bin/Debug/net8.0/ProjectEuler.pdb differ diff --git a/bin/Debug/net8.0/ProjectEuler.runtimeconfig.json b/bin/Debug/net8.0/ProjectEuler.runtimeconfig.json new file mode 100644 index 0000000..becfaea --- /dev/null +++ b/bin/Debug/net8.0/ProjectEuler.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net8.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "8.0.0" + }, + "configProperties": { + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false + } + } +} \ No newline at end of file diff --git a/devlog b/devlog new file mode 100644 index 0000000..94cb869 --- /dev/null +++ b/devlog @@ -0,0 +1,2 @@ +A lot of times I run into stack overflow issues. +Use BigInteger and you will not run into stack overflow issues. \ No newline at end of file diff --git a/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs b/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs new file mode 100644 index 0000000..2217181 --- /dev/null +++ b/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] diff --git a/obj/Debug/net8.0/ProjectEuler.AssemblyInfo.cs b/obj/Debug/net8.0/ProjectEuler.AssemblyInfo.cs new file mode 100644 index 0000000..58506e7 --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("ProjectEuler")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("ProjectEuler")] +[assembly: System.Reflection.AssemblyTitleAttribute("ProjectEuler")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net8.0/ProjectEuler.AssemblyInfoInputs.cache b/obj/Debug/net8.0/ProjectEuler.AssemblyInfoInputs.cache new file mode 100644 index 0000000..96ffc3e --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +ffcde6f75b6a2a29b7675ed917cd743ebe587f04c450947801882186d33ad68a diff --git a/obj/Debug/net8.0/ProjectEuler.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net8.0/ProjectEuler.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..59045b3 --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,13 @@ +is_global = true +build_property.TargetFramework = net8.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = ProjectEuler +build_property.ProjectDir = C:\Users\Travis\Desktop\projects\ProjectEuler\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/obj/Debug/net8.0/ProjectEuler.GlobalUsings.g.cs b/obj/Debug/net8.0/ProjectEuler.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/obj/Debug/net8.0/ProjectEuler.assets.cache b/obj/Debug/net8.0/ProjectEuler.assets.cache new file mode 100644 index 0000000..7b34f34 Binary files /dev/null and b/obj/Debug/net8.0/ProjectEuler.assets.cache differ diff --git a/obj/Debug/net8.0/ProjectEuler.csproj.CoreCompileInputs.cache b/obj/Debug/net8.0/ProjectEuler.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..953b336 --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +cf16980a0ba4091f5ea3e0558bd5272f285814d26eeff00d425e377e20bb1870 diff --git a/obj/Debug/net8.0/ProjectEuler.csproj.FileListAbsolute.txt b/obj/Debug/net8.0/ProjectEuler.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..e44d25a --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +C:\Users\Travis\Desktop\projects\ProjectEuler\bin\Debug\net8.0\ProjectEuler.exe +C:\Users\Travis\Desktop\projects\ProjectEuler\bin\Debug\net8.0\ProjectEuler.deps.json +C:\Users\Travis\Desktop\projects\ProjectEuler\bin\Debug\net8.0\ProjectEuler.runtimeconfig.json +C:\Users\Travis\Desktop\projects\ProjectEuler\bin\Debug\net8.0\ProjectEuler.dll +C:\Users\Travis\Desktop\projects\ProjectEuler\bin\Debug\net8.0\ProjectEuler.pdb +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.GeneratedMSBuildEditorConfig.editorconfig +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.AssemblyInfoInputs.cache +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.AssemblyInfo.cs +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.csproj.CoreCompileInputs.cache +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.dll +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\refint\ProjectEuler.dll +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.pdb +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ProjectEuler.genruntimeconfig.cache +C:\Users\Travis\Desktop\projects\ProjectEuler\obj\Debug\net8.0\ref\ProjectEuler.dll diff --git a/obj/Debug/net8.0/ProjectEuler.dll b/obj/Debug/net8.0/ProjectEuler.dll new file mode 100644 index 0000000..4478529 Binary files /dev/null and b/obj/Debug/net8.0/ProjectEuler.dll differ diff --git a/obj/Debug/net8.0/ProjectEuler.genruntimeconfig.cache b/obj/Debug/net8.0/ProjectEuler.genruntimeconfig.cache new file mode 100644 index 0000000..c6592d5 --- /dev/null +++ b/obj/Debug/net8.0/ProjectEuler.genruntimeconfig.cache @@ -0,0 +1 @@ +10b4be1bdd189e5f97095d6e9334221900ee43b067b33755c1ab85c5d26a5277 diff --git a/obj/Debug/net8.0/ProjectEuler.pdb b/obj/Debug/net8.0/ProjectEuler.pdb new file mode 100644 index 0000000..69e5b05 Binary files /dev/null and b/obj/Debug/net8.0/ProjectEuler.pdb differ diff --git a/obj/Debug/net8.0/apphost.exe b/obj/Debug/net8.0/apphost.exe new file mode 100644 index 0000000..60a2a20 Binary files /dev/null and b/obj/Debug/net8.0/apphost.exe differ diff --git a/obj/Debug/net8.0/ref/ProjectEuler.dll b/obj/Debug/net8.0/ref/ProjectEuler.dll new file mode 100644 index 0000000..e03c978 Binary files /dev/null and b/obj/Debug/net8.0/ref/ProjectEuler.dll differ diff --git a/obj/Debug/net8.0/refint/ProjectEuler.dll b/obj/Debug/net8.0/refint/ProjectEuler.dll new file mode 100644 index 0000000..e03c978 Binary files /dev/null and b/obj/Debug/net8.0/refint/ProjectEuler.dll differ diff --git a/obj/ProjectEuler.csproj.nuget.dgspec.json b/obj/ProjectEuler.csproj.nuget.dgspec.json new file mode 100644 index 0000000..944c8b8 --- /dev/null +++ b/obj/ProjectEuler.csproj.nuget.dgspec.json @@ -0,0 +1,72 @@ +{ + "format": 1, + "restore": { + "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj": {} + }, + "projects": { + "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj", + "projectName": "ProjectEuler", + "projectPath": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj", + "packagesPath": "C:\\Users\\Travis\\.nuget\\packages\\", + "outputPath": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\Travis\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net8.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + } + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.202/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/obj/ProjectEuler.csproj.nuget.g.props b/obj/ProjectEuler.csproj.nuget.g.props new file mode 100644 index 0000000..7d737fd --- /dev/null +++ b/obj/ProjectEuler.csproj.nuget.g.props @@ -0,0 +1,16 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\Travis\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages + PackageReference + 6.9.1 + + + + + + \ No newline at end of file diff --git a/obj/ProjectEuler.csproj.nuget.g.targets b/obj/ProjectEuler.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/obj/ProjectEuler.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/obj/project.assets.json b/obj/project.assets.json new file mode 100644 index 0000000..039f402 --- /dev/null +++ b/obj/project.assets.json @@ -0,0 +1,78 @@ +{ + "version": 3, + "targets": { + "net8.0": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + "net8.0": [] + }, + "packageFolders": { + "C:\\Users\\Travis\\.nuget\\packages\\": {}, + "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj", + "projectName": "ProjectEuler", + "projectPath": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj", + "packagesPath": "C:\\Users\\Travis\\.nuget\\packages\\", + "outputPath": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\Travis\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net8.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + } + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.202/PortableRuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache new file mode 100644 index 0000000..8d071e7 --- /dev/null +++ b/obj/project.nuget.cache @@ -0,0 +1,8 @@ +{ + "version": 2, + "dgSpecHash": "T2aVq83MosNF2xLxjuIWNKqV1uHTuuxtWh0Vh8q9MVfPQFacYZtfkYDCLotTw89XtMMGho9no9eVN189TrvxfQ==", + "success": true, + "projectFilePath": "C:\\Users\\Travis\\Desktop\\projects\\ProjectEuler\\ProjectEuler.csproj", + "expectedPackageFiles": [], + "logs": [] +} \ No newline at end of file diff --git a/question15.cs b/question15.cs new file mode 100644 index 0000000..4e45ada --- /dev/null +++ b/question15.cs @@ -0,0 +1,59 @@ +using System.CodeDom.Compiler; +using System.Numerics; +using System.Security.Cryptography.X509Certificates; + +namespace projectEuler { + // + class question15 { + question15(){ + + } + + public static BigInteger Solve(int x, int y){ + List> grid = new List>(); + //initialize grid + for(int width = 0; width < x; width++){ + grid.Add(new List()); + string row = ""; + for(int height = 0; height < y; height++){ + grid[width].Add(0); + row += " 0"; + } + Console.WriteLine(row); + } + + + grid[0][0] = 1; + for(int width = 0; width < x; width++) { + string row = ""; + for(int height = 0; height < x ; height++){ + if(grid[width][height] == 1){ + continue; + } + BigInteger top = 0; + BigInteger left = 0; + if(width - 1 >= 0) + { + left = grid[width-1][height]; + } + if(height - 1 >= 0){ + top = grid[width][height-1]; + } + if(top == 0 || left == 0) { + row += " 1"; + grid[width][height] = 1; + } else { + row += " " + (top + left).ToString(); + grid[width][height] = top + left; + } + + } + Console.WriteLine(row); + } + return grid[x-1][y-1]; + + + } + + } +} \ No newline at end of file