public static int GetNextValidNumber(int digit) { int minimum = 0; int[] numbers = IntegerHelper.IntToIntArray(digit); for (int index = 0; index < numbers.Length; index++) { if (minimum <= numbers[index]) { minimum = numbers[index]; } else { UpdateArray(index, numbers, minimum); } } int newDigit = IntegerHelper.IntArrayToInt(numbers); if (!ContainsDuplicates(numbers)) { newDigit++; return(GetNextValidNumber(newDigit)); } return(newDigit);
public void IntegerHelper_IntArrayToInt() { var testData = new List <(int[] array, int expected)> { (new[] { 2, 6, 4, 7, 9, 3 }, 264793), (new[] { 0, 2 }, 2), }; foreach (var data in testData) { int result = IntegerHelper.IntArrayToInt(data.array); Assert.Equal(data.expected, result); } }