private static void Main()
foreach(var testcase in _testCases)
private static bool[] Solution(int[] kidsCandies, int extraCandies)
bool[] ans = new bool[kidsCandies.Length];
for(int i = 0; i < kidsCandies.Length; i++)
if (kidsCandies[i] > max)
for(int i = 0; i < kidsCandies.Length; i++)
ans[i] = (kidsCandies[i] + extraCandies) >= max;
private static readonly TestCase[] _testCases = {
KidsCandies = new[] { 3, 1, 2, 5, 7 },
Solution = new[] { true, false, false, true, true }
KidsCandies = new[] { 1, 3, 1 },
Solution = new[] { false, true, false }
KidsCandies = new[] { 9, 11, 11, 6, 5, 6, 7, 1 },
Solution= new[] { true, true, true, false, false, false, false, false }
KidsCandies = new[] { 9, 5, 11, 8, 6 },
Solution= new[] { true, false, true, true, false }
KidsCandies = new[] { 9, 4, 6, 10, 7 },
Solution= new[] { true, true, true, true, true }
KidsCandies = new[] { 0, 8, 5, 5, 5, 1, 11, 11, 9, 5, 8, 0, 3, 5 },
Solution = new[] { false, true, true, true, true, false, true, true, true, true, true, false, true, true }
private static void CheckSolution(TestCase testCase)
var output = Solution(testCase.KidsCandies, testCase.ExtraCandies);
var outputCorrect = output.SequenceEqual(testCase.Solution);
var outputText = outputCorrect ? "PASS" : "FAIL";
static string ArrayToString<T>(T[] array) => "[" + string.Join(", ", array) + "]";
Console.WriteLine($"KidsCandies: {ArrayToString(testCase.KidsCandies)}");
Console.WriteLine($"ExtraCandies: {testCase.ExtraCandies}");
Console.WriteLine($"Solution: {ArrayToString(testCase.Solution)}");
Console.WriteLine($"Actual Output: {ArrayToString(output)}");
Console.WriteLine($"==== {outputText} ====");
public int[] KidsCandies { get; init; }
public int ExtraCandies { get; init; }
public bool[] Solution { get; init; }