public void Start() { // ENSWN //{ East, North, South, West, North }; var combinations = new Dictionary <string, List <Move> >(); var group1 = Permuts(Directions) .Select(p => p.Select(d => new Move(d)).ToList()) .ToList(); foreach (var moves1 in group1) { foreach (var moves2 in group1) { var moves = moves1.ToList(); moves.AddRange(moves2); foreach (var move in moves) { Board.Do(move); if (!Board.Holes.Any(h => h.IsEmpty)) { var solutions = Board.Moves.ToList(); var key = string.Join("", solutions.Select(m => m.Direction)); if (solutions.Count > 0 && (!combinations.ContainsKey(key) || combinations[key].Count > solutions.Count)) { combinations[key] = solutions; } break; } } Board = new SquireBoard(CopyInputData(TestCaseInput)); } } Board.Moves.Clear(); if (combinations.Count > 0) { Board.Moves.AddRange(combinations.Values.OrderBy(v => v.Count).First()); } }
public MarbleGame(int caseNumber, TestCaseInputDataModel testCaseInput) { CaseNumber = caseNumber; TestCaseInput = testCaseInput; Board = new SquireBoard(CopyInputData(TestCaseInput)); }