Beispiel #1
0
        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);
Beispiel #2
0
        public void IntegerHelper_IntToIntArray()
        {
            var testData = new List <(int digit, int[] expected)>
            {
                (264793, new[] { 2, 6, 4, 7, 9, 3 }),
            };

            foreach (var data in testData)
            {
                int[] result = IntegerHelper.IntToIntArray(data.digit);

                Assert.Equal(data.expected, result);
            }
        }