If we multiply the integer      `717 (n)` by `7 (k)`, the result will be equal to `5019`.
Consider all the possible ways that this last number may be split as a string and calculate their corresponding sum obtained by adding the substrings as integers. When we add all of them up,... surprise, we got the original number `717`:
```
Partitions as string                Total Sums
['5', '019']                        5 + 19 = 24
['50', '19']                       50 + 19 = 69
['501', '9']                      501 + 9 = 510
['5', '0', '19']                5 + 0 + 19 = 24
['5', '01', '9']                 5 + 1 + 9 = 15
['50', '1', '9']                50 + 1 + 9 = 60
['5', '0', '1', '9']         5 + 0 + 1 + 9 = 15
                            ____________________
                              Big Total:    717
                            ____________________
```
In fact, `717` is one of the few integers that has such property with a factor `k = 7`.
Changing the factor `k`, for example to `k = 3`, we may see that the integer `40104` fulfills this property.
Given an integer `start_value` and an integer `k`, output the smallest integer `n`, but higher than `start_value`, that fulfills the above explained properties.
If by chance, `start_value`, fulfills the property, do not return `start_value` as a result, only the next integer. Perhaps you may find this assertion redundant if you understood well the requirement of the kata: "output the smallest integer `n`, but higher than `start_value`"
The values for `k` in the input may be one of these: `3, 4, 5, 7`
### Features of the random tests
If you want to understand the style and features of the random tests, see the *Notes* at the end of these instructions.
The random tests are classified in three parts.
- Random tests each with one of the possible values of `k` and a random `start_value` in the interval `[100, 1300]`
- Random tests each with a `start_value` in a larger interval for each value of `k`, as follows:
 - for `k = 3`, a random `start value` in the range `[30000, 40000]`
 - for `k = 4`, a random `start value` in the range `[2000, 10000]`
 - for `k = 5`, a random `start value` in the range `[10000, 20000]`
 - for `k = 7`, a random `start value` in the range `[100000, 130000]`
- More challenging tests, each with a random `start_value` in the interval `[100000, 110000]`.
See the examples tests.
Enjoy it.
# Notes:
- As these sequences are finite, in other words, they have a maximum term for each value of k, the tests are prepared in such way that the `start_value`  will always be less than this maximum term. So you may be confident that your code will always find an integer.
- The values of `k` that generate sequences of integers, for the constrains of this kata are: 2, 3, 4, 5, and 7. The case `k = 2` was not included because it generates only two integers.
- The sequences have like "mountains" of abundance of integers but also have very wide ranges like "valleys" of scarceness. Potential solutions, even the fastest ones, may time out searching the next integer due to an input in one of these valleys. So it was intended to avoid these ranges.
Javascript and Ruby versions will be released soon.
from itertools import combinations, chain, count
from functools import lru_cache

def segmentations(a):
    def split_at(js):
        i = 0
        for j in js:
            yield a[i:j]
            i = j
        yield a[i:]

    r = range(1, len(a))
    for k in r:
        for sep in combinations(r, k):
            yield split_at(sep)

@lru_cache(maxsize=None)
def value(x, k):
    return sum(int(''.join(L)) for L in chain.from_iterable(segmentations(str(x * k))))

def next_higher(start_value, k):
    return next(x for x in count(start_value+1) if x == value(x, k))
from itertools import combinations, chain, count
from functools import lru_cache

def segmentations(a):
    def split_at(js):
        i = 0
        for j in js:
            yield a[i:j]
            i = j
        yield a[i:]

    r = range(1, len(a))
    for k in r:
        for sep in combinations(r, k):
            yield split_at(sep)

@lru_cache(maxsize=None)
def value(x, k):
    return sum(int(''.join(L)) for L in chain.from_iterable(segmentations(str(x * k))))

def next_higher(start_value, k):
    return next(x for x in count(start_value+1) if x == value(x, k))