diff options
Diffstat (limited to 'challenge-251/lubos-kolouch/python/ch-1.py')
| -rw-r--r-- | challenge-251/lubos-kolouch/python/ch-1.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-251/lubos-kolouch/python/ch-1.py b/challenge-251/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..62a2fcd678 --- /dev/null +++ b/challenge-251/lubos-kolouch/python/ch-1.py @@ -0,0 +1,23 @@ +from typing import List + + +def concatenation_value(ints: list[int]) -> int: + concat_value = 0 + while len(ints) > 0: + if len(ints) == 1: + concat_value += ints[0] + del ints[0] + else: + first = str(ints[0]) + last = str(ints[-1]) + concat = int(first + last) + concat_value += concat + del ints[0] + del ints[-1] + return concat_value + + +# Tests +assert concatenation_value([6, 12, 25, 1]) == 1286 +assert concatenation_value([10, 7, 31, 5, 2, 2]) == 489 +assert concatenation_value([1, 2, 10]) == 112 |
