aboutsummaryrefslogtreecommitdiff
path: root/challenge-251/lubos-kolouch/python/ch-1.py
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2024-01-14 14:22:57 +0100
committerLubos Kolouch <lubos@kolouch.net>2024-01-14 14:22:57 +0100
commitae2d092f1d47bcf5a5c4e622ae2d7117e76dfc8a (patch)
tree5a724435600b6d05ef1c6b3da1a2965c8f8d7fee /challenge-251/lubos-kolouch/python/ch-1.py
parent9a485c9bac8e3887b165d67c9aa81d71cdd42f01 (diff)
downloadperlweeklychallenge-club-ae2d092f1d47bcf5a5c4e622ae2d7117e76dfc8a.tar.gz
perlweeklychallenge-club-ae2d092f1d47bcf5a5c4e622ae2d7117e76dfc8a.tar.bz2
perlweeklychallenge-club-ae2d092f1d47bcf5a5c4e622ae2d7117e76dfc8a.zip
feat(challenge-251/lubos-kolouch/perl,python,raku/): Challenge 251 LK Perl Python Raku
Diffstat (limited to 'challenge-251/lubos-kolouch/python/ch-1.py')
-rw-r--r--challenge-251/lubos-kolouch/python/ch-1.py23
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