diff --git a/README.md b/README.md index 0d6d178..394ad53 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Advastore Coding Dojo + # Advastore Coding Dojo Herzlich Willkommen in unserem Coding Dojo, hiermit möchten wie euch einige Übungsaufgaben an die Hand geben, damit ihr eure Fähigkeiten weiterhin erprobt, verbessert und vertieft. diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.config b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.xaml b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.xaml new file mode 100644 index 0000000..9d3c63e --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.xaml.cs b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.xaml.cs new file mode 100644 index 0000000..11d2820 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace LangtonAntProject +{ + /// + /// Interaktionslogik für "App.xaml" + /// + public partial class App : Application + { + } +} diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/LangtonAnt.cs b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/LangtonAnt.cs new file mode 100644 index 0000000..46847d7 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/LangtonAnt.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace LangtonAntProject +{ + public class LangtonAnt + { + private int gridSize; + private int[,] grid; + private Direction startDirection; + private int startPosition_X; + private int startPosition_Y; + private int iterationCount; + public LangtonAnt(int gridSize, Direction startDirection, int startPosition_X, int startPosition_Y, int iterationCount) + { + this.gridSize = gridSize; + this.startDirection = startDirection; + + grid = new int[this.gridSize, this.gridSize]; + + this.startPosition_X = startPosition_X; + this.startPosition_Y = startPosition_Y; + this.iterationCount = iterationCount; + + //grid initialize + for (int i=0; i < this.gridSize; i++) + { + for(int j=0; j < this.gridSize; j++) + { + grid[i, j] = Convert.ToInt32(Color.w); + } + } + } + //do all iterations and save result match fields to a file + public string Start() + { + if (!Directory.Exists(@"..\..\Output")) + { + Directory.CreateDirectory(@"..\..\Output"); + } + var path = @"..\..\Output\Result.txt"; + + int currentPosition_x = this.startPosition_X; + int currentPosition_y = this.startPosition_Y; + Direction currentDirection = this.startDirection; + + StringBuilder matchField = new StringBuilder(); + + for (var i = 0; i < iterationCount; i++) + { + + if (grid[currentPosition_x, currentPosition_y] == (int)Color.s) + { + grid[currentPosition_x, currentPosition_y] = (int)Color.w; + + TurnToLeft(ref currentDirection, ref currentPosition_x, ref currentPosition_y); + + } + else + { + grid[currentPosition_x, currentPosition_y] = (int)Color.s; + + TurnToRight(ref currentDirection, ref currentPosition_x, ref currentPosition_y); + + } + + + //save grid values + for (int x = 0; x < gridSize; x++) + { + for (int y = 0; y < gridSize; y++) + { + if (x == currentPosition_x && y == currentPosition_y) matchField.Append(currentDirection.ToString()); + var color = Enum.Parse(typeof(Color), grid[x, y].ToString()); + + matchField.Append(color.ToString()).Append(","); + + + } + } + matchField.AppendLine(); + } + + //write the current match field to file + using (StreamWriter stream = new StreamWriter(path,false)) + { + stream.Write(matchField.ToString()); + } + return path; + } + + private void TurnToRight(ref Direction direction, ref int currentPosition_x, ref int currentPosition_y) + { + switch (direction) + { + case Direction.n: + direction = Direction.o; + currentPosition_x++; + break; + case Direction.o: + direction = Direction.s; + currentPosition_y++; + break; + case Direction.s: + direction = Direction.w; + currentPosition_x = currentPosition_x + gridSize - 1; + break; + case Direction.w: + direction = Direction.n; + currentPosition_y = currentPosition_y + gridSize - 1; + break; + } + + currentPosition_x = currentPosition_x % gridSize; + currentPosition_y = currentPosition_y % gridSize; + } + private void TurnToLeft(ref Direction direction, ref int currentPosition_x, ref int currentPosition_y) + { + switch (direction) + { + case Direction.n: + direction = Direction.w; + currentPosition_x = currentPosition_x + gridSize - 1; + break; + case Direction.w: + direction = Direction.s; + currentPosition_y++; + break; + case Direction.s: + direction = Direction.o; + currentPosition_x++; + break; + case Direction.o: + direction = Direction.n; + currentPosition_y= currentPosition_y+gridSize-1; + break; + } + currentPosition_x = currentPosition_x % gridSize; + currentPosition_y = currentPosition_y % gridSize; + } + } + + public enum Direction + { + n, o, s, w + + } + public enum Color + { + s, w + } +} diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/LangtonAntProject.csproj b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/LangtonAntProject.csproj new file mode 100644 index 0000000..7f5edde --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/LangtonAntProject.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {74C817F8-B984-41E2-AD2C-9D7C849CE46E} + WinExe + LangtonAmeiseProject + LangtonAmeiseProject + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + \ No newline at end of file diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/MainWindow.xaml b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/MainWindow.xaml new file mode 100644 index 0000000..023439d --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/MainWindow.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + Kantenlänge: + 11 + + Startposition x: + 6 + + Startposition y: + 6 + + Blickrichtung: + w + + Anzahl der Züge + 10 + + Geschwindigkeit + 90 + + + + + + + + + + + + + + + + diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/MainWindow.xaml.cs b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/MainWindow.xaml.cs new file mode 100644 index 0000000..8732988 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/MainWindow.xaml.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Interop; +using System.Windows.Threading; +using System.Timers; +using System.Drawing; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; + +namespace LangtonAntProject +{ + /// + /// Interaktionslogik für MainWindow.xaml + /// + public partial class MainWindow : Window + { + private int gridSize; + private string path; + const int cellSize = 30; + public MainWindow() + { + InitializeComponent(); + } + + + private void InitGrid(object sender, RoutedEventArgs e) + { + var startPosition_x = 0; + var startPosition_y = 0; + var iterationCount = 0; + var direction = LangtonAntProject.Direction.n; + + int.TryParse(this.GridSize.Text, out gridSize); + int.TryParse(this.StartPosition_x.Text, out startPosition_x); + int.TryParse(this.StartPosition_y.Text, out startPosition_y); + int.TryParse(this.IterationCount.Text, out iterationCount); + + switch (this.Direction.Text.ToLower().Trim()) + { + case "n": + direction = LangtonAntProject.Direction.n; break; + case "s": + direction = LangtonAntProject.Direction.s; break; + case "o": + direction = LangtonAntProject.Direction.o; break; + case "w": + direction = LangtonAntProject.Direction.w; break; + } + + if (gridSize <= 0) + { + MessageBox.Show("Kantenlänge muss großer als 0 sein."); + return; + } + if ( startPosition_x >= gridSize || startPosition_y >= gridSize || startPosition_x < 0 || startPosition_y < 0) + { + MessageBox.Show($"Startposition x und Startposition y müssen zwischen 0 und {gridSize-1} sein."); + return; + } + + InitGridCells(); + InitAntPosition(this.Direction.Text.ToLower().Trim(), startPosition_x, startPosition_y); + + var langtonAnt = new LangtonAnt(gridSize, direction, startPosition_x, startPosition_y, iterationCount); + path = langtonAnt.Start(); + + MessageBox.Show("Spielfeld ist initialisiert"); + } + //initialize the grid with white cells + private void InitGridCells() + { + for (int i = 0; i < gridSize; i++) + { + for (int j = 0; j < gridSize; j++) + { + var rectangle = new System.Windows.Shapes.Rectangle + { + Width = cellSize, + Height = cellSize, + Fill = System.Windows.Media.Brushes.White, + Stroke = System.Windows.Media.Brushes.Black, + StrokeThickness = 1, + Name = $"Rect_{i}_{j}" + }; + Canvas.SetLeft(rectangle, i * cellSize); + Canvas.SetTop(rectangle, j * cellSize); + Canvas.Children.Add(rectangle); + } + } + } + private void InitAntPosition(string direction,int x,int y) + { + var directionText = ""; + if (direction == "n") directionText = "^"; + else if (direction == "o") directionText = "->"; + else if (direction == "s") directionText = char.ConvertFromUtf32(8595); + else if (direction == "w") directionText = "<-"; + else directionText = ""; + + var rect = new System.Windows.Shapes.Rectangle + { + Width = cellSize, + Height = cellSize, + Fill = System.Windows.Media.Brushes.White, + Stroke = System.Windows.Media.Brushes.Black, + StrokeThickness = 1, + Name = $"Rect_{x}{y}" + }; + Canvas.SetLeft(rect, x * cellSize); + Canvas.SetTop(rect, y * cellSize); + ; + //draw the new one + Canvas.Children.Add(rect); + + //draw the ant + if (!string.IsNullOrEmpty(directionText)) + DrawTextOnRectange(rect, directionText); + } + + private async void StartDrawing(object sender, RoutedEventArgs e) + { + if (string.IsNullOrEmpty(path) || !File.Exists(path)) + { + MessageBox.Show("Klicken Sie bitte auf dem initialisieren button."); + + return; + } + + int speed = 10; + int.TryParse(this.Speed.Text, out speed); + if(speed<0 || speed > 100) + { + MessageBox.Show("Geschwindigkeit muss zwischen 0 und 100 sein."); + return; + } + + using (StreamReader stream = new StreamReader(path)) + { + Dispatcher d = Application.Current.Dispatcher; + + while (true) + { + var line = stream.ReadLine(); + await Application.Current.Dispatcher.InvokeAsync(new Action(() => + { + DrawGrid(line); + + }), DispatcherPriority.Background); + + Thread.Sleep(1000-(speed*10)); + + if (string.IsNullOrEmpty(line)) break; + } + + MessageBox.Show("Fertig"); + + } + } + + //draw an iteration + private void DrawGrid(string line) + { + if (string.IsNullOrEmpty(line)) return; + + var matchField = line.Split(','); + var direction = ""; + var directionText = ""; + int x = 0; + int y = 0; + foreach (var field in matchField) + { + + direction = field.Length == 2 ? field[0].ToString() : ""; + + if (direction == "n") directionText = "^"; + else if (direction == "o") directionText = "->"; + else if (direction == "s") directionText = char.ConvertFromUtf32(8595); + else if (direction == "w") directionText = "<-"; + else directionText = ""; + + var rectName = $"Rect_{x}_{y}"; + + //find the rectange using its name + var currentRect = Canvas.Children.OfType().FirstOrDefault(r => r.Name == rectName) as System.Windows.Shapes.Rectangle; + + if (currentRect != null) + { + //copy the current rectangle info + var rect = new System.Windows.Shapes.Rectangle + { + Width = currentRect.Width, + Height = currentRect.Height, + Fill = currentRect.Fill, + Stroke = currentRect.Stroke, + StrokeThickness = currentRect.StrokeThickness, + Name = currentRect.Name + }; + Canvas.SetLeft(rect, x * cellSize); + Canvas.SetTop(rect, y * cellSize); + + //remove the old rectangle + Canvas.Children.Remove(currentRect); + //draw the new one + Canvas.Children.Add(rect); + //change color + switch (field.Length == 2 ? field[1].ToString() : field) + { + case "s": + rect.Fill = System.Windows.Media.Brushes.Black; + break; + case "w": + rect.Fill = System.Windows.Media.Brushes.White; + break; + } + //draw the ant + if (!string.IsNullOrEmpty(directionText)) + DrawTextOnRectange(rect, directionText); + + + } + + if (y < gridSize - 1) + { + y++; + } + else + { + y = 0; + x++; + } + } + + + } + //draw the ant + private void DrawTextOnRectange(System.Windows.Shapes.Rectangle rect, string directionText) + { + DrawingVisual drawingVisual = new DrawingVisual(); + using(DrawingContext drawingContext = drawingVisual.RenderOpen()) + { + FormattedText ft = new FormattedText( + directionText, + System.Globalization.CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, + new Typeface("Arial"), + 16, + System.Windows.Media.Brushes.Red); + double text_x = (rect.Width - ft.Width) / 2; + double text_y = (rect.Height - ft.Height) / 2; + drawingContext.DrawRectangle(rect.Fill,null,new Rect(0,0,rect.Width,rect.Height)); + drawingContext.DrawText(ft,new System.Windows.Point(text_x,text_y)); + } + DrawingBrush drawingBrush = new DrawingBrush(drawingVisual.Drawing); + rect.Fill = drawingBrush; + } + + private void NumberValidationTextBox(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9]+"); + e.Handled = regex.IsMatch(e.Text); + } + } +} diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Output/Result.txt b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Output/Result.txt new file mode 100644 index 0000000..1020658 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Output/Result.txt @@ -0,0 +1,10 @@ +w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,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w,w,w,s,s,ss,w,w,w,w,w,w,w,w,s,s,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w, +w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,s,s,w,w,w,w,w,w,w,w,s,s,w,w,w,w,w,w,w,w,w,s,s,ow,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w, diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/AssemblyInfo.cs b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0782932 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("LangtonAmeiseProject")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LangtonAmeiseProject")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie +//ImCodeVerwendeteKultur in der .csproj-Datei +//in einer fest. Wenn Sie in den Quelldateien beispielsweise Deutsch +//(Deutschland) verwenden, legen Sie auf \"de-DE\" fest. Heben Sie dann die Auskommentierung +//des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile, +//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher + //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird, + // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.) + ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs + //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird, + // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.) +)] + + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Resources.Designer.cs b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9616fb0 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion: 4.0.30319.42000 +// +// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace LangtonAntProject.Properties +{ + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse + // über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LangtonAmeiseProject.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Resources.resx b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Settings.Designer.cs b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8f3cf3e --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LangtonAntProject.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Settings.settings b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/katas/LangtonAnt/solutions/Areej_Abu_Jeash/LangtonAmeiseProject/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/katas/StrangeChessboard/solutions/Areej_Abu_Jeash/Program.cs b/katas/StrangeChessboard/solutions/Areej_Abu_Jeash/Program.cs new file mode 100644 index 0000000..1ef7d29 --- /dev/null +++ b/katas/StrangeChessboard/solutions/Areej_Abu_Jeash/Program.cs @@ -0,0 +1,39 @@ +// See https://aka.ms/new-console-template for more information + + +Console.WriteLine("Test case 1:"); +var rs = new int[] { 3, 1, 2, 7, 1 }; +var cs = new int[] { 1, 8, 4, 5, 2 }; + +var result=Calculate(rs, cs); + +Console.WriteLine("total_white_area: " + result.Item1); +Console.WriteLine("total_black_area: " + result.Item2); + +var testCase1 = ((result.Item1 + result.Item2) == (rs.Sum() * cs.Sum())) ? true : false; + +Console.WriteLine("Test case 1 passed: " + testCase1.ToString()); + +//Determine the total white area and the total black area of his board. +(int, int) Calculate(int[]rs, int[]cs) +{ + (int total_white_area, int total_black_area) result=(0,0); + + bool w = true; + foreach(int r in rs) + { + foreach(int c in cs) + { + if (w) + { + result.total_white_area += r * c; + } + else + { + result.total_black_area += r * c; + } + w = !w; + } + } + return result; +} \ No newline at end of file diff --git a/katas/StrangeChessboard/solutions/Areej_Abu_Jeash/StrangeChessboard.csproj b/katas/StrangeChessboard/solutions/Areej_Abu_Jeash/StrangeChessboard.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/katas/StrangeChessboard/solutions/Areej_Abu_Jeash/StrangeChessboard.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + +