kyu_5.string_incrementer package
Submodules
kyu_5.string_incrementer.string_incrementer module
Solution for -> String incrementer.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.string_incrementer.string_incrementer.get_first_digit_index(string: str)[source]
Find index of first non digit char from right to left.
- Parameters:
string – input string
- Returns:
index of first non digit char or None
- kyu_5.string_incrementer.string_incrementer.increment_string(string: str) str[source]
increment_string function.
A function which increments a string, to create a new string:
1. If the string already ends with a number, the number should be incremented by 1.
2. If the string does not end with a number. the number 1 should be appended to the new string. :param string: input string :return: output string with incremented number
kyu_5.string_incrementer.test_increment_string module
Test for -> String incrementer.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- class kyu_5.string_incrementer.test_increment_string.StringIncrementerTestCase(methodName='runTest')[source]
Bases:
TestCaseTesting increment_string function.
- _classSetupFailed = False
- _class_cleanups = []
- test_increment_string = None
- test_increment_string_0_foo(**kw)
Testing a function named increment_string [with string=’foo’, expected=’foo1’].
- Returns:
- test_increment_string_1_foobar001(**kw)
Testing a function named increment_string [with string=’foobar001’, expected=’foobar002’].
- Returns:
- test_increment_string_2_foobar1(**kw)
Testing a function named increment_string [with string=’foobar1’, expected=’foobar2’].
- Returns:
- test_increment_string_3_foobar00(**kw)
Testing a function named increment_string [with string=’foobar00’, expected=’foobar01’].
- Returns:
- test_increment_string_4_foobar99(**kw)
Testing a function named increment_string [with string=’foobar99’, expected=’foobar100’].
- Returns:
- test_increment_string_5_foobar099(**kw)
Testing a function named increment_string [with string=’foobar099’, expected=’foobar100’].
- Returns:
- test_increment_string_6_(**kw)
Testing a function named increment_string [with string=’’, expected=’1’].
- Returns:
- test_increment_string_7_009(**kw)
Testing a function named increment_string [with string=’009’, expected=’010’].
- Returns:
- test_increment_string_8__0000007(**kw)
Testing a function named increment_string [with string=’^0000007’, expected=’^0000008’].
- Returns:
Module contents
String incrementer.