bastien.monsarrat 6 years ago
parent
commit
6cc70147b9

+ 12 - 0
Adv2015.sln

@@ -37,6 +37,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D08.2", "D08.2\D08.2.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D09", "D09.1\D09.csproj", "{8680B3A9-FBC7-4432-857A-9FE81ED4590B}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D10.1", "D10.1\D10.1.csproj", "{D720AFF3-4AE8-4083-8AC9-FE620A260D2A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D10.2", "D10.2\D10.2.csproj", "{F7E0673F-04A5-414D-9DD6-7E442DEAAE24}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -111,6 +115,14 @@ Global
 		{8680B3A9-FBC7-4432-857A-9FE81ED4590B}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{8680B3A9-FBC7-4432-857A-9FE81ED4590B}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{8680B3A9-FBC7-4432-857A-9FE81ED4590B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D720AFF3-4AE8-4083-8AC9-FE620A260D2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D720AFF3-4AE8-4083-8AC9-FE620A260D2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D720AFF3-4AE8-4083-8AC9-FE620A260D2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D720AFF3-4AE8-4083-8AC9-FE620A260D2A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F7E0673F-04A5-414D-9DD6-7E442DEAAE24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F7E0673F-04A5-414D-9DD6-7E442DEAAE24}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F7E0673F-04A5-414D-9DD6-7E442DEAAE24}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F7E0673F-04A5-414D-9DD6-7E442DEAAE24}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

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

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

+ 45 - 0
D10.1/Program.cs

@@ -0,0 +1,45 @@
+using System;
+using System.Text;
+
+namespace D10._1
+{
+    public class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+            string input = args[0];
+
+            int tries = 40;
+            Apply(ref input, ref tries);
+
+            Console.WriteLine($"The answer is : {input.Length}");
+        }
+
+        public static void Apply(ref string input, ref int tries)
+        {
+            while (tries > 0)
+            {
+                var ninput = new StringBuilder("");
+
+                int i = 0;
+                while (i < input.Length)
+                {
+                    char current = input[i];
+                    int count = 0;
+                    while (i < input.Length && input[i] == current)
+                    {
+                        count++;
+                        i++;
+                    }
+
+                    ninput.Append(count);
+                    ninput.Append(current);
+                }
+
+                input = ninput.ToString();
+                tries--;
+            }
+        }
+    }
+}

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

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D10.1": {
+      "commandName": "Project",
+      "commandLineArgs": "1113122113"
+    }
+  }
+}

+ 13 - 0
D10.2/D10.2.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D10._2</RootNamespace>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\D10.1\D10.1.csproj" />
+  </ItemGroup>
+
+</Project>

+ 18 - 0
D10.2/Program.cs

@@ -0,0 +1,18 @@
+using System;
+
+namespace D10._2
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+            string input = args[0];
+
+            int tries = 50;
+            _1.Program.Apply(ref input, ref tries);
+
+            Console.WriteLine($"The answer is : {input.Length}");
+        }
+    }
+}

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

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D10.2": {
+      "commandName": "Project",
+      "commandLineArgs": "1113122113"
+    }
+  }
+}