diff --git a/AdventOfCode/Day12.cs b/AdventOfCode/Day12.cs index 67df01f..c17eaac 100644 --- a/AdventOfCode/Day12.cs +++ b/AdventOfCode/Day12.cs @@ -89,22 +89,23 @@ private int GetPossibleArrangements(char[] spring, List groups, int index = if (spring[index] == '?') { - char[] option = spring.ToArray(); - option[index] = '#'; - (bool isValid, int newIndex) = IsValid(option, groups, index, curGroupIndex); + spring[index] = '#'; + (bool isValid, int newIndex) = IsValid(spring, groups, index, curGroupIndex); if (isValid) { - int a = GetPossibleArrangements(option, groups, index + 1, newIndex); + int a = GetPossibleArrangements(spring, groups, index + 1, newIndex); count += a; } - option[index] = '.'; - (isValid, newIndex) = IsValid(option, groups, index, curGroupIndex); + spring[index] = '.'; + (isValid, newIndex) = IsValid(spring, groups, index, curGroupIndex); if (isValid) { - int b = GetPossibleArrangements(option, groups, index + 1, newIndex); + int b = GetPossibleArrangements(spring, groups, index + 1, newIndex); count += b; } + + spring[index] = '?'; } else {