kyu_4.next_bigger_number_with_the_same_digits package
Submodules
kyu_4.next_bigger_number_with_the_same_digits.next_bigger module
Solution for -> Next bigger number with the same digits.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_4.next_bigger_number_with_the_same_digits.next_bigger.digit_that_breaks_ordering_index(digits: list) int[source]
Find a digit that breaks ordering index.
Starting from last digit of given number, find the first digit which breaks the sorted ordering. Let the index of this found digit be ‘i’ and the digit be number[i].
- Parameters:
digits – list of digits
- Returns:
the index of the first digit which breaks the sorted ordering
- kyu_4.next_bigger_number_with_the_same_digits.next_bigger.next_bigger(n: int) int[source]
Next bigger function.
A function that takes a positive integer number and returns the next bigger number formed by the same digits.
If no bigger number can be composed using those digits, return -1. :param n: :return:
- kyu_4.next_bigger_number_with_the_same_digits.next_bigger.next_greater_digit_index(digits: list, i: int) int[source]
Find next greater digit index.
Find the next greater digit in the right portion of number[i] - that is from digit at index i+1 to last digit. Let that digit be number[j] at index ‘j’.
- Parameters:
digits – list of digits
i – index of number[i]
- Returns:
next greater digit in the right portion of number[i]
kyu_4.next_bigger_number_with_the_same_digits.test_next_bigger module
Test for -> Next bigger number with the same digits.
Created by Egor Kostan. GitHub: https://github.com/ikostan
Module contents
Next bigger number with the same digits package.