blob: 258ef4da0dc56304d073285bc4ace78ba3478fd5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env python3
import sys
def main(ints):
solution = 0
half = len(ints) // 2
# If we have an odd number of integers, use the middle value
if len(ints) % 2 == 1:
solution += ints[half]
# Combine the concatenation of the remaining integers, starting with first
# and last, then second and second last, and so on.
for i in range(half):
solution += int(str(ints[i]) + str(ints[-1-i]))
print(solution)
if __name__ == '__main__':
# Convert input into integers
array = [int(n) for n in sys.argv[1:]]
main(array)
|