Problem 3¶
Find two summands s1
and s2
for a given non-negative number n
.
The following properties should hold:
* s1 ≥ s2
* s1 + s2 == n
* The digit 7 does not appear neither in s1
nor in s2
.
Though the original problem did not state it, we enforce s1 > 0
and s2 > 0
.
Functions:
Disassemble the integer |
|
|
Assemble the integer from the given |
Find the two summands |
- number_to_digits(n: int) List[int] [source]¶
Disassemble the integer
n
into individual digits.- Requires
n > 0
- Ensures
digits_to_number(result) == n
all(0 <= digit <= 9 for digit in result)
result[0] != 0
"".join(str(digit) for digit in result) == str(n)
- digits_to_number(digits: Reversible[int]) int [source]¶
Assemble the integer from the given
digits
.- Requires
all(0 <= digit <= 9 for digit in digits)
len(digits) > 0
- find_summands(n: int) Tuple[int, int] [source]¶
Find the two summands
(s1, s2)
which satisfy the conditions.s1 ≥ s2
s1 + s2 == n
The digit 7 does not appear neither in
s1
nor ins2
.
- Requires
n > 2
- Ensures
"7" not in str(result[1])
"7" not in str(result[0])
result[0] >= result[1]
result[1] > 0
result[0] > 0