16 lines
339 B
Python
16 lines
339 B
Python
|
#!/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))
|