implement following the text
Verifying solution... Test 1 passed! Test 2 passed! Test 3 passed! [Hidden] Test 4 passed! [Hidden] Test 5 failed [Hidden] Test 6 failed [Hidden] Test 7 passed! [Hidden] Test 8 passed! [Hidden] Test 9 failed [Hidden] Test 10 passed! [Hidden]
This commit is contained in:
parent
09fbc7784c
commit
e47a5cd2e4
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