kyu_4.next_bigger_number_with_the_same_digits package

Submodules

kyu_4.next_bigger_number_with_the_same_digits.next_bigger module

kyu_4.next_bigger_number_with_the_same_digits.next_bigger.digit_that_breaks_ordering_index(digits: list) → int[source]

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]

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

kyu_4.next_bigger_number_with_the_same_digits.next_bigger.next_greater_digit_index(digits: list, i: int) → int[source]

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

class kyu_4.next_bigger_number_with_the_same_digits.test_next_bigger.NextBiggerTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_next_bigger()[source]

Testing next_bigger function

You have to test a function that takes a positive integer number and returns the next bigger number formed by the same digits:

12 ==> 21 513 ==> 531 2017 ==> 2071

If no bigger number can be composed using those digits, return -1

Module contents