using System.Collections.Generic;
internal class TaskSolver
public static void Main(string[] args)
Console.WriteLine("All Test completed!");
public static List<int> GetWordSubWords(List<string> words, List<string> wordDictionary)
public static int FindPath(int[][] gridMap, int sX, int sY, int eX, int eY, int energyAmount)
public static string FormatPrettyCoins(long value, char separator)
if(value > (long)Math.Pow(10,5))
if(value > (long)Math.Pow(10,7))
tmp_value = (int)Math.Floor((double)value/Math.Pow(10,6));
Console.WriteLine(tmp_value);
public static int FindMaxRect(List<int> heights)
private static void TestGetWordSubWords()
var wordsList = new List<string>
"кот", "ток", "око", "мимо", "гром", "ром",
"рог", "морг", "огр", "мор", "порог"
AssertSequenceEqual( GetWordSubWords(new List<string>{"кот"}, wordsList), new []{2} );
AssertSequenceEqual( GetWordSubWords(new List<string>{"мама"}, wordsList), new []{0} );
AssertSequenceEqual( GetWordSubWords(new List<string>{"погром", "гром"}, wordsList), new []{7, 6} );
private static void TestFindPath()
new[] {1, 1, 1, 0, 1, 1},
new[] {1, 1, 1, 0, 1, 1},
new[] {1, 1, 1, 0, 0, 0},
new[] {1, 1, 1, 1, 1, 1},
new[] {1, 1, 1, 1, 1, 1},
new[] {1, 1, 1, 1, 1, 1},
AssertEqual(FindPath(gridA, 0,0,2, 2, 5), 4);
AssertEqual(FindPath(gridA, 0,0,5, 5, 30), -1);
AssertEqual(FindPath(gridA, 0,0,0, 5, 3), -1);
private static void TestFormatPrettyCoins()
AssertEqual(FormatPrettyCoins(10, ' '), "10");
AssertEqual(FormatPrettyCoins(1233, ' '), "1 233");
AssertEqual(FormatPrettyCoins(1717310, ' '), "1 717K");
AssertEqual(FormatPrettyCoins(7172343310, ' '), "7 172M");
private static void FindMaxRect()
AssertEqual(FindMaxRect(new List<int>{1, 2, 3, 4, 4, 4, 5, 4, 6}), 24);
AssertEqual(FindMaxRect(new List<int>{1, 2, 3, 5, 5, 4, 2, 4, 6}), 16);
AssertEqual(FindMaxRect(new List<int>{8, 9, 3, 5, 5, 2, 3, 4, 6, 1, 6}), 18);
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]}");