bastien.monsarrat 6 жил өмнө
parent
commit
3cee0dcec1

+ 24 - 0
Adv2015.sln

@@ -7,6 +7,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D01.1", "D01.1\D01.1.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D01.2", "D01.2\D01.2.csproj", "{60B353FD-B5F9-4DE0-8D76-5E3F8BAD463B}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D02.1", "D02.1\D02.1.csproj", "{63C94AB1-2D4C-4175-A5A8-8C198F400CD1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D02.2", "D02.2\D02.2.csproj", "{4B0A16C9-9318-41A0-B1A0-793EA4933B3B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D03.1", "D03.1\D03.1.csproj", "{410E977E-7901-4BBC-9C5B-1102D5681CC1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D03.2", "D03.2\D03.2.csproj", "{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -21,6 +29,22 @@ Global
 		{60B353FD-B5F9-4DE0-8D76-5E3F8BAD463B}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{60B353FD-B5F9-4DE0-8D76-5E3F8BAD463B}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{60B353FD-B5F9-4DE0-8D76-5E3F8BAD463B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{63C94AB1-2D4C-4175-A5A8-8C198F400CD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{63C94AB1-2D4C-4175-A5A8-8C198F400CD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{63C94AB1-2D4C-4175-A5A8-8C198F400CD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{63C94AB1-2D4C-4175-A5A8-8C198F400CD1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4B0A16C9-9318-41A0-B1A0-793EA4933B3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4B0A16C9-9318-41A0-B1A0-793EA4933B3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4B0A16C9-9318-41A0-B1A0-793EA4933B3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4B0A16C9-9318-41A0-B1A0-793EA4933B3B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{410E977E-7901-4BBC-9C5B-1102D5681CC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{410E977E-7901-4BBC-9C5B-1102D5681CC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{410E977E-7901-4BBC-9C5B-1102D5681CC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{410E977E-7901-4BBC-9C5B-1102D5681CC1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

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

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

+ 42 - 0
D03.1/Program.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace D03._1
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+            if (File.Exists(args[0]) == false) throw new FileNotFoundException();
+            
+            string text = "";
+            using (var file = File.OpenText(args[0]))
+            {
+                text = file.ReadToEnd();
+            }
+
+            (int x, int y) pos = (0, 0);
+            var visited = new HashSet<(int, int)>
+            {
+                pos
+            };
+
+            foreach (var c in text)
+            {
+                switch (c)
+                {
+                    case '>': pos.x++; break;
+                    case '<': pos.x--; break;
+                    case '^': pos.y--; break;
+                    case 'v': case 'V': pos.y++; break;
+                    default: continue;
+                }
+                visited.Add(pos);
+            }
+
+            Console.WriteLine($"Answer is : {visited.Count}");
+        }
+    }
+}

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

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D03.1": {
+      "commandName": "Project",
+      "commandLineArgs": "\"..\\..\\..\\..\\D03.1\\input.txt\""
+    }
+  }
+}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
D03.1/input.txt


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

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

+ 44 - 0
D03.2/Program.cs

@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace D03._2
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+            if (File.Exists(args[0]) == false) throw new FileNotFoundException();
+
+            string text = "";
+            using (var file = File.OpenText(args[0]))
+            {
+                text = file.ReadToEnd();
+            }
+
+            (int x, int y)[] pos = new[] { (0, 0), (0, 0) };
+            var visited = new HashSet<(int, int)>
+            {
+                (0, 0)
+            };
+
+            int santas = 2, santaId = 0;
+            foreach (var c in text)
+            {
+                santaId = (santaId + 1) % santas;
+                switch (c)
+                {
+                    case '>': pos[santaId].x++; break;
+                    case '<': pos[santaId].x--; break;
+                    case '^': pos[santaId].y--; break;
+                    case 'v': case 'V': pos[santaId].y++; break;
+                    default: continue;
+                }
+                visited.Add(pos[santaId]);
+            }
+
+            Console.WriteLine($"Answer is : {visited.Count}");
+        }
+    }
+}

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

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D03.2": {
+      "commandName": "Project",
+      "commandLineArgs": "\"..\\..\\..\\..\\D03.1\\input.txt\""
+    }
+  }
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно