15 lines
339 B
Python
Executable file
15 lines
339 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import sys
|
|
|
|
if __name__ == '__main__':
|
|
inp = [int(i) for i in sys.stdin.readline().split(',')]
|
|
|
|
def calc(f):
|
|
return min([
|
|
sum(f(abs(crab-i)) for crab in inp)
|
|
for i in range(min(inp), max(inp)+1)
|
|
])
|
|
|
|
print(calc(lambda n: n))
|
|
print(calc(lambda n: n * (n+1)//2))
|