using System.Collections.Generic;
internal class TaskSolver
public static void Main(string[] args)
TestGenerateWordsFromWord();
TestGetPreviousMaxDigital();
TestSearchQueenOrHorse();
Console.WriteLine("All Test completed!");
public static List<string> GenerateWordsFromWord(string word, List<string> wordDictionary)
return new List<string>();
public static int MaxLengthTwoChar(string word)
public static long GetPreviousMaxDigital(long value)
public static List<int> SearchQueenOrHorse(char[][] gridMap)
return new List<int>{-1, -1};
public static long CalculateMaxCoins(int[][] mapData, int idStart, int idFinish)
private static void TestGenerateWordsFromWord()
var wordsList = new List<string>
"кот", "ток", "око", "мимо", "гром", "ром", "мама",
"рог", "морг", "огр", "мор", "порог", "бра", "раб", "зубр"
AssertSequenceEqual( GenerateWordsFromWord("арбуз", wordsList), new []{ "бра", "зубр", "раб"} );
AssertSequenceEqual( GenerateWordsFromWord("лист", wordsList), new List<string>() );
AssertSequenceEqual( GenerateWordsFromWord("маг", wordsList), new List<string>() );
AssertSequenceEqual( GenerateWordsFromWord("погром", wordsList), new List<string>{ "гром", "мор", "морг", "огр", "порог", "рог", "ром"} );
private static void TestMaxLengthTwoChar()
AssertEqual( MaxLengthTwoChar("beabeeab"), 5);
AssertEqual(MaxLengthTwoChar("а"), 0);
AssertEqual(MaxLengthTwoChar("ab"), 2);
private static void TestGetPreviousMaxDigital()
AssertEqual(GetPreviousMaxDigital(21), 12l);
AssertEqual(GetPreviousMaxDigital(531), 513l);
AssertEqual(GetPreviousMaxDigital(1027), -1l);
AssertEqual(GetPreviousMaxDigital(2071), 2017l);
AssertEqual(GetPreviousMaxDigital(135), -1l);
private static void TestSearchQueenOrHorse()
new[] {'s', '#', '#', '#', '#', '#'},
new[] {'#', 'x', 'x', 'x', 'x', '#'},
new[] {'#', '#', '#', '#', 'x', '#'},
new[] {'#', '#', '#', '#', 'x', '#'},
new[] {'#', '#', '#', '#', '#', 'e'},
AssertSequenceEqual(SearchQueenOrHorse(gridA), new []{3, 2});
new[] {'s', '#', '#', '#', '#', '#'},
new[] {'#', 'x', 'x', 'x', 'x', '#'},
new[] {'#', 'x', '#', '#', 'x', '#'},
new[] {'#', '#', '#', '#', 'x', '#'},
new[] {'x', '#', '#', '#', '#', 'e'},
AssertSequenceEqual(SearchQueenOrHorse(gridB), new []{-1, 3});
new[] {'s', '#', '#', '#', '#', 'x'},
new[] {'x', 'x', 'x', 'x', 'x', 'x'},
new[] {'#', '#', '#', '#', 'x', '#'},
new[] {'#', '#', '#', 'e', 'x', '#'},
new[] {'x', '#', '#', '#', '#', '#'},
AssertSequenceEqual(SearchQueenOrHorse(gridC), new []{2, -1});
private static void TestCalculateMaxCoins()
AssertEqual(CalculateMaxCoins(mapA, 0, 3), 11l);
AssertEqual(CalculateMaxCoins(mapB, 0, 5), -1l);
AssertEqual(CalculateMaxCoins(mapC, 0, 5), 19l);
private static void Assert(bool value)
throw new Exception("Assertion failed");
private static void AssertEqual(object value, object expectedValue)
if (value.Equals(expectedValue))
throw new Exception($"Assertion failed expected = {expectedValue} actual = {value}");
private static void AssertSequenceEqual<T>(IEnumerable<T> value, IEnumerable<T> expectedValue)
if (ReferenceEquals(value, expectedValue))
throw new ArgumentNullException(nameof(value));
if (expectedValue is null)
throw new ArgumentNullException(nameof(expectedValue));
var valueList = value.ToList();
var expectedValueList = expectedValue.ToList();
if (valueList.Count != expectedValueList.Count)
throw new Exception($"Assertion failed expected count = {expectedValueList.Count} actual count = {valueList.Count}");
for (var i = 0; i < valueList.Count; i++)
if (!valueList[i].Equals(expectedValueList[i]))
throw new Exception($"Assertion failed expected value at {i} = {expectedValueList[i]} actual = {valueList[i]}");