public Pair[] toPair(string s) { Pair[] temp = new Pair[10]; Char[] tempd = s.ToCharArray(); for (int i = 0; i <= 9; i++) { temp[i].x = new Digit(i); temp[i].y = new Digit(tempd[i]); } return temp; }
public static Pair[] genFirstRoots(Digit d) { //create array of root arrays Pair[][] roots = new Pair[][] { new Pair[] { new Pair(1,1), new Pair(3,7), new Pair(9,9)}, //produce 1 in ones digit new Pair[] { new Pair(1,3), new Pair(7,9)}, //produce 3 in ones digit new Pair[] { new Pair(1,7) , new Pair(3,9)}, //produce 7 in ones digit new Pair[] { new Pair(1,9) , new Pair(3,3), new Pair(7,7)}}; // produce 9 in ones digit switch (d.Value) { case 1: //if ones digit is 1 return roots[0]; case 3: //if ones digit is 3 return roots[1]; case 7: //if ones digit is 7 return roots[2]; case 9: //if ones digit is 9 return roots[3]; default: //else return defualt return null; } }