finish extra/queue-to-do #15
16
extra/queue-to-do/solution.py
Normal file
16
extra/queue-to-do/solution.py
Normal file
@ -0,0 +1,16 @@
|
||||
def solution(start, length):
|
||||
checksum = 0
|
||||
for i in range(length):
|
||||
base = start + length * i
|
||||
for j in range(length - i):
|
||||
checksum ^= base + j
|
||||
return checksum
|
||||
|
||||
tests = [
|
||||
([0, 3], 2),
|
||||
([17, 4], 14)
|
||||
]
|
||||
|
||||
for i, o in tests:
|
||||
result = solution(*i)
|
||||
print (i, result == o, result, o)
|
||||
Loading…
x
Reference in New Issue
Block a user