X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=Kata4L%C3%B6sungen%2FCSharp%2Findex.mdwn;fp=Kata4L%C3%B6sungen%2FCSharp%2Findex.mdwn;h=0000000000000000000000000000000000000000;hb=730888d3909be35cdad7d089b4b8b045adadd5e1;hp=21d90a4342cacd95ff10d245cc99550b9c4360b1;hpb=002c2ec44e7cad8ac26f85657700e703b4d923b4;p=debienna.git diff --git "a/Kata4L\303\266sungen/CSharp/index.mdwn" "b/Kata4L\303\266sungen/CSharp/index.mdwn" deleted file mode 100644 index 21d90a4..0000000 --- "a/Kata4L\303\266sungen/CSharp/index.mdwn" +++ /dev/null @@ -1,139 +0,0 @@ - - -# 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]]