1
0
bastien.monsarrat 6 жил өмнө
parent
commit
1b24d0924c

+ 6 - 0
Adv2018.sln

@@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D10.1", "D10.1\D10.1.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D10.2", "D10.2\D10.2.csproj", "{9A5878B7-51D8-432D-AD25-DF2DC5EEDDAF}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D11.1", "D11.1\D11.1.csproj", "{3413167A-CC8C-457E-B82E-4C5240AED0D1}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -135,6 +137,10 @@ Global
 		{9A5878B7-51D8-432D-AD25-DF2DC5EEDDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9A5878B7-51D8-432D-AD25-DF2DC5EEDDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{9A5878B7-51D8-432D-AD25-DF2DC5EEDDAF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3413167A-CC8C-457E-B82E-4C5240AED0D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{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
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

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

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

+ 52 - 0
D11.1/Program.cs

@@ -0,0 +1,52 @@
+using System;
+
+namespace D11._1
+{
+    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)? maxCoordinates = null;
+
+            for (int x = 1; x <= length - 2; ++x)
+            {
+                for (int y = 1; y <= length - 2; ++y)
+                {
+                    int total = 0;
+                    for (int j = 0; j < 3; ++j)
+                    for (int i = 0; i < 3; ++i)
+                        total += grid[x - 1 + i, y - 1 + j];
+
+                    if (total > maxTotal)
+                    {
+                        maxTotal = total;
+                        maxCoordinates = (x, y);
+                    }
+                }
+            }
+
+            Console.WriteLine($"The answer is : ({maxCoordinates.Value.x},{maxCoordinates.Value.y})");
+        }
+    }
+}

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

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