diff --git a/AnimalClassification/AnimalClassification.csproj b/AnimalClassification/AnimalClassification.csproj
new file mode 100644
index 00000000..21dff5ca
--- /dev/null
+++ b/AnimalClassification/AnimalClassification.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.2
+
+
+
diff --git a/AnimalClassification/Program.cs b/AnimalClassification/Program.cs
new file mode 100644
index 00000000..54d0ce96
--- /dev/null
+++ b/AnimalClassification/Program.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace AnimalClassification
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+
+ }
+ }
+}
diff --git a/Mastermind/.vscode/launch.json b/Mastermind/.vscode/launch.json
new file mode 100644
index 00000000..60c9449e
--- /dev/null
+++ b/Mastermind/.vscode/launch.json
@@ -0,0 +1,28 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/Mastermind.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
+ "console": "internalConsole",
+ "stopAtEntry": false,
+ "internalConsoleOptions": "openOnSessionStart"
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ,]
+}
\ No newline at end of file
diff --git a/Mastermind/.vscode/tasks.json b/Mastermind/.vscode/tasks.json
new file mode 100644
index 00000000..ccfc68f7
--- /dev/null
+++ b/Mastermind/.vscode/tasks.json
@@ -0,0 +1,15 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/Mastermind.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Mastermind/Mastermind.csproj b/Mastermind/MasterMind/MasterMind.csproj
similarity index 100%
rename from Mastermind/Mastermind.csproj
rename to Mastermind/MasterMind/MasterMind.csproj
diff --git a/Mastermind/Mastermind.cs b/Mastermind/MasterMind/Mastermind.cs
similarity index 52%
rename from Mastermind/Mastermind.cs
rename to Mastermind/MasterMind/Mastermind.cs
index 365fb84c..ffd66690 100644
--- a/Mastermind/Mastermind.cs
+++ b/Mastermind/MasterMind/Mastermind.cs
@@ -1,59 +1,86 @@
using System;
+using System.Collections.Generic;
namespace Mastermind
{
+
class Program
{
// possible letters in code
public static char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
-
+
// size of code
public static int codeSize = 4;
-
+
// number of allowed attempts to crack the code
public static int allowedAttempts = 10;
-
+
// number of tried guesses
public static int numTry = 0;
-
+
// test solution
- public static char[] solution = new char[] {'a', 'b', 'c', 'd'};
-
+ public static char[] solution = GenerateRandomCode();
+
// game board
public static string[][] board = new string[allowedAttempts][];
-
-
+
+
public static void Main()
{
char[] guess = new char[4];
-
CreateBoard();
DrawBoard();
- Console.WriteLine("Enter Guess:");
- guess = Console.ReadLine().ToCharArray();
- // leave this command at the end so your program does not close automatically
- Console.ReadLine();
+ do
+ {
+ Console.WriteLine("Enter Guess:");
+ string input = Console.ReadLine();
+ guess = input.ToCharArray();
+ PlaceMark(guess);
+ DrawBoard();
+ numTry++;
+ } while (!CheckSolution(guess) && (numTry < allowedAttempts));
+ if (CheckSolution(guess))
+ {
+ System.Console.WriteLine("You win!");
+ }
+ else
+ {
+ System.Console.WriteLine("You lost!");
+ }
+
}
-
+
public static bool CheckSolution(char[] guess)
{
// Your code here
+ for (int i = 0; i < guess.Length; i++)
+ {
+ if (guess[i] == solution[i])
+ {
+ if (i == guess.Length - 1)
+ {
+ return true;
+ }
+ continue;
+
+ }
+ else
+ {
+ break;
+ }
+ }
+
return false;
}
-
+
public static string GenerateHint(char[] guess)
{
// Your code here
return " ";
}
-
- public static void InsertCode(char[] guess)
- {
- // Your code here
- }
-
+
public static void CreateBoard()
{
for (var i = 0; i < allowedAttempts; i++)
@@ -65,22 +92,34 @@ public static void CreateBoard()
}
}
}
-
public static void DrawBoard()
{
for (var i = 0; i < board.Length; i++)
{
Console.WriteLine("|" + String.Join("|", board[i]));
}
-
+
}
-
- public static void GenerateRandomCode() {
+
+ public static void PlaceMark(char[] guess)
+ {
+ // your code goes here
+ for (int i = 0; i < guess.Length; i++)
+ {
+ board[numTry][i] = guess[i].ToString();
+ }
+
+ }
+
+ public static char[] GenerateRandomCode()
+ {
+ char[] solution = new char[codeSize];
Random rnd = new Random();
- for(var i = 0; i < codeSize; i++)
+ for (var i = 0; i < codeSize; i++)
{
solution[i] = letters[rnd.Next(0, letters.Length)];
}
+ return solution;
}
}
}
diff --git a/Mastermind/MasterMind/ball.cs b/Mastermind/MasterMind/ball.cs
new file mode 100644
index 00000000..d906b877
--- /dev/null
+++ b/Mastermind/MasterMind/ball.cs
@@ -0,0 +1,15 @@
+using System;
+namespace Mastermind
+{
+
+ class Ball
+ {
+ public string letter { get; private set; }
+
+ public Ball(string letter)
+ {
+ this.letter = letter;
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/Mastermind/MasterMind/game.cs b/Mastermind/MasterMind/game.cs
new file mode 100644
index 00000000..5ece5369
--- /dev/null
+++ b/Mastermind/MasterMind/game.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+
+namespace Mastermind
+{
+
+ class Game
+ {
+ private List rows = new List();
+ private string[] answer = new string[4];
+
+ public Game(string[] answer)
+ {
+ this.answer = answer;
+ }
+
+ private string Score(Row row)
+ {
+ string[] answerClone = (string[])this.answer.Clone();
+ // red is correct letter and correct position
+ // white is correct letters minus red
+ // this.answer => ["a", "b", "c", "d"]
+ // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }]
+ int red = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ if (answerClone[i] == row.balls[i].letter)
+ {
+ red++;
+ }
+ }
+
+ int white = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ int foundIndex = Array.IndexOf(answerClone, row.balls[i].letter);
+ if (foundIndex > -1)
+ {
+ white++;
+ answerClone[foundIndex] = null;
+ }
+ }
+ return $" {red} - {white - red}";
+ }
+
+ public void AddRow(Row row)
+ {
+ this.rows.Add(row);
+ }
+
+ public string Rows
+ {
+ get
+ {
+ string temp = "";
+ foreach (var row in this.rows)
+ {
+ string score = this.Score(row);
+ temp = temp + row.Balls + score + "\n";
+ }
+ return temp;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Mastermind/MasterMind/row.cs b/Mastermind/MasterMind/row.cs
new file mode 100644
index 00000000..156fd252
--- /dev/null
+++ b/Mastermind/MasterMind/row.cs
@@ -0,0 +1,25 @@
+using System;
+namespace Mastermind
+{
+ class Row
+ {
+ public Ball[] balls = new Ball[4];
+
+ public Row(Ball[] balls)
+ {
+ this.balls = balls;
+ }
+ public string Balls
+ {
+ get
+ {
+ foreach (var ball in this.balls)
+ {
+ Console.Write(ball.letter);
+ }
+ return "";
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Mastermind/TowersOfHanoi/TowersOfHanoi.cs b/Mastermind/TowersOfHanoi/TowersOfHanoi.cs
new file mode 100644
index 00000000..a0b927d7
--- /dev/null
+++ b/Mastermind/TowersOfHanoi/TowersOfHanoi.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Tower
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Game game = new Game();
+
+ game.PrintBoard();
+ }
+ }
+ class Block
+ {
+ public int weight { get; private set; }
+
+ public Block(int weight)
+ {
+ this.weight = weight;
+ }
+ }
+ class Tower
+ {
+ public Stack blocks = new Stack();
+ }
+ class Game
+ {
+ Dictionary towers = new Dictionary();
+
+ public Game()
+ {
+ Tower towerA = new Tower();
+ Tower towerB = new Tower();
+ Tower towerC = new Tower();
+ towers["A"] = towerA;
+ towers["B"] = towerB;
+ towers["C"] = towerC;
+ towerA.blocks.Push(new Block(1));
+ towerA.blocks.Push(new Block(2));
+ towerA.blocks.Push(new Block(3));
+ towerA.blocks.Push(new Block(4));
+ }
+
+ public void PrintBoard()
+ {
+ foreach (KeyValuePair item in towers)
+ {
+ string blocks = "";
+ foreach (Block block in item.Value.blocks)
+ {
+ blocks += block.weight.ToString();
+ }
+ System.Console.WriteLine(item.Key + "| " + blocks);
+
+ }
+ }
+ public void MovePiece()
+ {
+
+ foreach (KeyValuePair item in towers)
+ {
+ towers.Values.Pop();
+ }
+ }
+ }
+}
diff --git a/Mastermind/TowersOfHanoi/TowersOfHanoi.csproj b/Mastermind/TowersOfHanoi/TowersOfHanoi.csproj
new file mode 100644
index 00000000..ce1697ae
--- /dev/null
+++ b/Mastermind/TowersOfHanoi/TowersOfHanoi.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.0
+
+
+