kyu_4.next_smaller_number_with_the_same_digits package

Submodules

kyu_4.next_smaller_number_with_the_same_digits.next_smaller module

Solution for -> Next smaller number with the same digits.

Created by Egor Kostan. GitHub: https://github.com/ikostan

kyu_4.next_smaller_number_with_the_same_digits.next_smaller.find_x(n: int) int[source]

Find x.

Parameters:

n – int

Returns:

int

kyu_4.next_smaller_number_with_the_same_digits.next_smaller.find_y(n: int, x_i: int) int[source]

Find y.

Parameters:
  • n – int

  • x_i – int

Returns:

int

kyu_4.next_smaller_number_with_the_same_digits.next_smaller.next_smaller(n: int) int[source]

next_smaller function.

A function that takes a positive integer and returns the next smaller positive integer containing the same digits. If no smaller number can be composed using those digits, return -1 :param n: int :return: int

kyu_4.next_smaller_number_with_the_same_digits.test_next_smaller module

Test for -> Next smaller number with the same digits.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_4.next_smaller_number_with_the_same_digits.test_next_smaller.NextSmallerTestCase(methodName='runTest')[source]

Bases: TestCase

Testing next_smaller function.

_classSetupFailed = False
_class_cleanups = []
test_next_smaller()[source]

Testing next_smaller function.

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

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

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

Module contents

Next smaller number with the same digits package.