bastien.monsarrat 6 years ago
parent
commit
9101606ce3

+ 6 - 0
Adv2015.sln

@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.329
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D01.1", "D01.1\D01.1.csproj", "{4F8C0427-49D7-41ED-A7FC-490C79560CBA}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D01.2", "D01.2\D01.2.csproj", "{60B353FD-B5F9-4DE0-8D76-5E3F8BAD463B}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
 		{4F8C0427-49D7-41ED-A7FC-490C79560CBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{4F8C0427-49D7-41ED-A7FC-490C79560CBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{4F8C0427-49D7-41ED-A7FC-490C79560CBA}.Release|Any CPU.Build.0 = Release|Any CPU
+		{60B353FD-B5F9-4DE0-8D76-5E3F8BAD463B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{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
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 19 - 1
D01.1/Program.cs

@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 
 namespace D01._1
 {
@@ -6,7 +7,24 @@ namespace D01._1
     {
         static void Main(string[] args)
         {
-            Console.WriteLine("Hello World!");
+            if (args.Length < 1) return;
+            if (File.Exists(args[0]) == false) throw new FileNotFoundException();
+
+            int floor = 0;
+
+            string text = "";
+            using (var file = File.OpenText(args[0]))
+            {
+                text = file.ReadToEnd();
+            }
+
+            foreach (var car in text)
+            {
+                if (car == '(') floor++;
+                if (car == ')') floor--;
+            }
+
+            Console.WriteLine($"Answer is : {floor}");
         }
     }
 }

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

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

File diff suppressed because it is too large
+ 0 - 0
D01.1/input.txt


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

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

+ 34 - 0
D01.2/Program.cs

@@ -0,0 +1,34 @@
+using System;
+using System.IO;
+
+namespace D01._2
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) return;
+            if (File.Exists(args[0]) == false) throw new FileNotFoundException();
+
+            int floor = 0;
+
+            string text = "";
+            using (var file = File.OpenText(args[0]))
+            {
+                text = file.ReadToEnd();
+            }
+
+            int c = 0;
+            foreach (var car in text)
+            {
+                c++;
+                if (car == '(') floor++;
+                if (car == ')') floor--;
+
+                if (floor == -1) break;
+            }
+
+            Console.WriteLine($"Answer is : {c}");
+        }
+    }
+}

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

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

File diff suppressed because it is too large
+ 0 - 0
input.txt


Some files were not shown because too many files changed in this diff