using System.Collections.Generic;
public static void Main()
Program p = new Program();
Console.WriteLine("Skriv in rummets dimensioner (bredd och djup). Två heltal som ska sepereras med mellanslag.\n");
string breddDjup = Console.ReadLine();
string[] breddDjupArr = breddDjup.Split(' ');
countWords(breddDjupArr);
checkIfNumber(breddDjupArr[0]);
checkIfNumber(breddDjupArr[1]);
Int32.TryParse(breddDjupArr[0], out x);
Int32.TryParse(breddDjupArr[1], out y);
Console.WriteLine("Ange startposition \n");
string startPos = Console.ReadLine();
string[] startPosArr = startPos.Split(' ');
checkIfNumber(startPosArr[0]);
checkIfNumber(startPosArr[1]);
string[] serieRader = new string[4];
for(var i = 0; i < serieRader.Length; i++){
Console.WriteLine("Ange Rörelse (tex 0,0)");
string temp = Console.ReadLine();
string[] tempArr = temp.Split(',');
Int32.TryParse(tempArr[0], out xRad);
Int32.TryParse(tempArr[1], out yRad);
if(xRad <= x && yRad <= y){
serieRader[i] = xRad + "," + yRad;
public void runMachine(int bredd, int djup, string[] startPos, string[] movement){
string[,] room = new string[bredd,djup];
HashSet<string> coveredAreas = new HashSet<string>();
for(var i = 0; i < movement.Length; i++){
coveredAreas.Add(movement[i]);
Int32.TryParse(startPos[0], out x);
Int32.TryParse(startPos[1], out y);
countSteps(x, y, coveredAreas);
public void countSteps(int curX, int curY, HashSet<string> area){
foreach (string i in area){
string tempXstring = i.Substring(0,1);
string tempYstring = i.Substring(1,2);
Int32.TryParse(tempXstring, out tempX);
Int32.TryParse(tempYstring, out tempY);
Console.WriteLine("Totalt:" + count.ToString() + "\n");
public void checkIfNumber(string word){
bool isNumeric = int.TryParse(word, out n);
Console.WriteLine("Skriv endast nummer!");
throw new Exception("Only numbers!");
public void countWords(string [] words){
Console.WriteLine("words är:" + words.Length);
Console.WriteLine("Skriv rätt format!");
throw new Exception("Wrong format!");