bastien.monsarrat 7 anni fa
parent
commit
2c4e8b6e0b
4 ha cambiato i file con 79 aggiunte e 0 eliminazioni
  1. 6 0
      Adv2018.sln
  2. 9 0
      D11.2/D11.2.csproj
  3. 56 0
      D11.2/Program.cs
  4. 8 0
      D11.2/Properties/launchSettings.json

+ 6 - 0
Adv2018.sln

@@ -47,6 +47,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D10.2", "D10.2\D10.2.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D11.1", "D11.1\D11.1.csproj", "{3413167A-CC8C-457E-B82E-4C5240AED0D1}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D11.2", "D11.2\D11.2.csproj", "{9CAA4935-5795-4D99-8557-53A8B1250477}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -141,6 +143,10 @@ Global
 		{3413167A-CC8C-457E-B82E-4C5240AED0D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{3413167A-CC8C-457E-B82E-4C5240AED0D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{3413167A-CC8C-457E-B82E-4C5240AED0D1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{9CAA4935-5795-4D99-8557-53A8B1250477}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9CAA4935-5795-4D99-8557-53A8B1250477}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9CAA4935-5795-4D99-8557-53A8B1250477}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9CAA4935-5795-4D99-8557-53A8B1250477}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 9 - 0
D11.2/D11.2.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D11._2</RootNamespace>
+  </PropertyGroup>
+
+</Project>

+ 56 - 0
D11.2/Program.cs

@@ -0,0 +1,56 @@
+using System;
+
+namespace D11._2
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length == 0) return;
+            int serial = int.Parse(args[0]);
+
+            const int length = 300;
+            var grid = new int[length, length];
+
+            for (int x = 1; x <= length; ++x)
+            {
+                for (int y = 1; y <= length; ++y)
+                {
+                    int id = (x + 10);
+
+                    int n = (id * y + serial) * id;
+                    int c = (n / 100) % 10;
+
+
+                    grid[x - 1, y - 1] = c - 5;
+                }
+            }
+
+            int maxTotal = 0;
+            (int x, int y, int g)? maxCoordinates = null;
+
+            for (var g = 0; g < length; ++g)
+            {
+                for (int x = 1; x <= length -g + 1; ++x)
+                    for (int y = 1; y <= length -g + 1; ++y)
+                    {
+                        
+                        int total = 0;
+                        for (int j = 0; j < g; ++j)
+                            for (int i = 0; i < g; ++i)
+                            {
+                                total += grid[x - 1 + i, y - 1 + j];
+                            }
+
+                        if (total > maxTotal)
+                        {
+                            maxTotal = total;
+                            maxCoordinates = (x, y, g);
+                        }
+                    }
+            }
+
+            Console.WriteLine($"The answer is : ({maxCoordinates.Value.x},{maxCoordinates.Value.y},{maxCoordinates.Value.g})");
+        }
+    }
+}

+ 8 - 0
D11.2/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D11.2": {
+      "commandName": "Project",
+      "commandLineArgs": "\"9798\""
+    }
+  }
+}