using System.Collections.Generic;
public int[,] moveformat;
public static int VariantCount = 0;
public static void Main()
var myChessPiece = new Chesspiece();
myChessPiece.movedistance = 3;
myChessPiece.name = "Knight";
myChessPiece.moveformat = new int[2, 1];
List<string> listofNumbers = new List<string>();
int[,] dialPad = new int[4, 3] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 11, 0, 12 } };
for (int yaxis = 0; yaxis < 3; yaxis++)
for (int xaxis = 0; xaxis < 3; xaxis++)
if (yaxis == 0 && xaxis == 0)
for (int phoneNumberCounter = 0; phoneNumberCounter < 6; phoneNumberCounter++)
if (phoneNumberCounter > 0)
Try8KnightMoves(ref firstPos, ref secondPos);
Console.WriteLine("Number of viable numbers for {0} is {1}", myChessPiece.name, VariantCount);
public static void Try8KnightMoves(ref int firstPos, ref int secondPos)
int[] moveX = {2, -2, -2, 2};
int[] moveY = { 1, 1, -1, -1 };
for (int j = 0; j < moveX.Length; j++)
if (KnightMovementOpt(ref firstPos, ref secondPos, moveX[j], moveY[j])) { VariantCount += 1; }
public static bool KnightMovementOpt(ref int firstPos, ref int secondPos, int move1, int move2)
int possibleFirstPos = -1;
int possibleSecondPos = -1;
if (firstPos + move1 < 4 && firstPos + move1 >= 0)
if (secondPos + move2 <= 2 && secondPos + move2 >= 0)
possibleSecondPos = secondPos + 1;
if ( possibleFirstPos != -1 && (possibleFirstPos != 1 || possibleFirstPos != 2) && possibleSecondPos != 3)
firstPos = possibleFirstPos;
secondPos = possibleSecondPos;