converted moin categories to tags
[debienna.git] / Kata4Lösungen / CSharp / index.mdwn
index c728ae1..21d90a4 100644 (file)
-= Part 1 =\r
-\r
-{{{\r
-using System;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
-\r
-namespace Kata4\r
-{\r
-        class Kata4\r
-        {\r
-                public static void Main(string[] argv)\r
-                {\r
-                        FileStream fs = new FileStream("K4Weather.txt", FileMode.Open, FileAccess.Read);\r
-                        StreamReader r = new StreamReader(fs);\r
-                        int min_spread = Int32.MaxValue;\r
-                        int spread_day = -1;\r
-                        while(r.Peek() > -1)\r
-                        {\r
-                                string s = r.ReadLine();\r
-                                Match fields = Regex.Match(s, "^ +([0-9]+) +([0-9]+)[^ ]* *([0-9]+).*");\r
-                                try {\r
-                                        int day = Convert.ToInt32(fields.Groups[1].ToString());\r
-                                        int min = Convert.ToInt32(fields.Groups[3].ToString());\r
-                                        int max = Convert.ToInt32(fields.Groups[2].ToString());\r
-                                        int spread = max - min;\r
-                                        if (spread <= min_spread)\r
-                                        {\r
-                                                spread_day = day;\r
-                                                min_spread = spread;\r
-                                        }\r
-                                } catch {\r
-                                }\r
-                        }\r
-                        Console.WriteLine(spread_day);\r
-                }\r
-        }\r
-}\r
-\r
-\r
-}}}\r
-\r
-\r
-= Part 2 =\r
-\r
-{{{\r
-using System;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
-\r
-namespace Kata4\r
-{\r
-        class Kata4_2\r
-        {\r
-                public static void Main(string[] argv)\r
-                {\r
-                        FileStream fs = new FileStream("K4Soccer.txt", FileMode.Open, FileAccess.Read);\r
-                        StreamReader r = new StreamReader(fs);\r
-                        int min_spread = Int32.MaxValue;\r
-                        string spread_day = "";\r
-                        while(r.Peek() > -1)\r
-                        {\r
-                                string s = r.ReadLine();\r
-                                Match fields = Regex.Match(s, "^ +[0-9]+\\. ([A-Za-z_]+) +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +([0-9]+) +- +([0-9]+).*");\r
-                                try {\r
-                                        string day = fields.Groups[1].ToString();\r
-                                        Console.Write("Testing");\r
-                                        Console.WriteLine(day);\r
-                                        int min = Convert.ToInt32(fields.Groups[2].ToString());\r
-                                        int max = Convert.ToInt32(fields.Groups[3].ToString());\r
-                                        int spread = Math.Abs( max - min );\r
-                                        if (spread <= min_spread)\r
-                                        {\r
-                                                spread_day = day;\r
-                                                min_spread = spread;\r
-                                        }\r
-                                } catch {\r
-                                }\r
-                        }\r
-                        Console.WriteLine(spread_day);\r
-                }\r
-        }\r
-}\r
-}}}\r
-\r
-= Part 3 =\r
-\r
-{{{\r
-using System;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
-\r
-namespace Kata4\r
-{\r
-        class Kata4_2\r
-        {\r
-                public static void Main(string[] args)\r
-                {\r
-                        Console.Write("part1: ");\r
-                        DM("K4Weather.txt", "^ +([0-9]+) +([0-9]+)[^ ]* *([0-9]+).*");\r
-                        Console.Write("part2: ");\r
-                        DM("K4Soccer.txt", "^ +[0-9]+\\. ([A-Za-z_]+) +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +([0-9]+) +- +([0-9]+).*");\r
-                }\r
-\r
-                public static void DM(string file, string pattern)\r
-                {\r
-                        FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read);\r
-                        StreamReader r = new StreamReader(fs);\r
-                        int min_spread = Int32.MaxValue;\r
-                        string spread_day = "";\r
-                        while(r.Peek() > -1)\r
-                        {\r
-                                string s = r.ReadLine();\r
-                                Match fields = Regex.Match(s, pattern);\r
-                                try {\r
-                                        string day = fields.Groups[1].ToString();\r
-                                        int min = Convert.ToInt32(fields.Groups[2].ToString());\r
-                                        int max = Convert.ToInt32(fields.Groups[3].ToString());\r
-                                        int spread = Math.Abs( max - min );\r
-                                        if (spread <= min_spread)\r
-                                        {\r
-                                                spread_day = day;\r
-                                                min_spread = spread;\r
-                                        }\r
-                                } catch {\r
-                                }\r
-                        }\r
-                        Console.WriteLine(spread_day);\r
-                }\r
-        }\r
-}\r
-}}}\r
-\r
-----\r
-CategoryCodeSnippets
\ No newline at end of file
+
+
+# Part 1
+
+
+[[!format txt """
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+
+namespace Kata4
+{
+        class Kata4
+        {
+                public static void Main(string[] argv)
+                {
+                        FileStream fs = new FileStream("K4Weather.txt", FileMode.Open, FileAccess.Read);
+                        StreamReader r = new StreamReader(fs);
+                        int min_spread = Int32.MaxValue;
+                        int spread_day = -1;
+                        while(r.Peek() > -1)
+                        {
+                                string s = r.ReadLine();
+                                Match fields = Regex.Match(s, "^ +([0-9]+) +([0-9]+)[^ ]* *([0-9]+).*");
+                                try {
+                                        int day = Convert.ToInt32(fields.Groups[1].ToString());
+                                        int min = Convert.ToInt32(fields.Groups[3].ToString());
+                                        int max = Convert.ToInt32(fields.Groups[2].ToString());
+                                        int spread = max - min;
+                                        if (spread <= min_spread)
+                                        {
+                                                spread_day = day;
+                                                min_spread = spread;
+                                        }
+                                } catch {
+                                }
+                        }
+                        Console.WriteLine(spread_day);
+                }
+        }
+}
+
+
+"""]]
+
+# Part 2
+
+
+[[!format txt """
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+
+namespace Kata4
+{
+        class Kata4_2
+        {
+                public static void Main(string[] argv)
+                {
+                        FileStream fs = new FileStream("K4Soccer.txt", FileMode.Open, FileAccess.Read);
+                        StreamReader r = new StreamReader(fs);
+                        int min_spread = Int32.MaxValue;
+                        string spread_day = "";
+                        while(r.Peek() > -1)
+                        {
+                                string s = r.ReadLine();
+                                Match fields = Regex.Match(s, "^ +[0-9]+\\. ([A-Za-z_]+) +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +([0-9]+) +- +([0-9]+).*");
+                                try {
+                                        string day = fields.Groups[1].ToString();
+                                        Console.Write("Testing");
+                                        Console.WriteLine(day);
+                                        int min = Convert.ToInt32(fields.Groups[2].ToString());
+                                        int max = Convert.ToInt32(fields.Groups[3].ToString());
+                                        int spread = Math.Abs( max - min );
+                                        if (spread <= min_spread)
+                                        {
+                                                spread_day = day;
+                                                min_spread = spread;
+                                        }
+                                } catch {
+                                }
+                        }
+                        Console.WriteLine(spread_day);
+                }
+        }
+}
+"""]]
+
+# Part 3
+
+
+[[!format txt """
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+
+namespace Kata4
+{
+        class Kata4_2
+        {
+                public static void Main(string[] args)
+                {
+                        Console.Write("part1: ");
+                        DM("K4Weather.txt", "^ +([0-9]+) +([0-9]+)[^ ]* *([0-9]+).*");
+                        Console.Write("part2: ");
+                        DM("K4Soccer.txt", "^ +[0-9]+\\. ([A-Za-z_]+) +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +([0-9]+) +- +([0-9]+).*");
+                }
+
+                public static void DM(string file, string pattern)
+                {
+                        FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read);
+                        StreamReader r = new StreamReader(fs);
+                        int min_spread = Int32.MaxValue;
+                        string spread_day = "";
+                        while(r.Peek() > -1)
+                        {
+                                string s = r.ReadLine();
+                                Match fields = Regex.Match(s, pattern);
+                                try {
+                                        string day = fields.Groups[1].ToString();
+                                        int min = Convert.ToInt32(fields.Groups[2].ToString());
+                                        int max = Convert.ToInt32(fields.Groups[3].ToString());
+                                        int spread = Math.Abs( max - min );
+                                        if (spread <= min_spread)
+                                        {
+                                                spread_day = day;
+                                                min_spread = spread;
+                                        }
+                                } catch {
+                                }
+                        }
+                        Console.WriteLine(spread_day);
+                }
+        }
+}
+"""]]
+
+
+ [[!tag CategoryCodeSnippets]]