Created
November 8, 2017 20:44
-
-
Save jakab922/0b765dfe04d8be0e1e20c2181b60e8e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from sol2 import solve | |
def brute_solve(n, step=2): | |
curr = range(n) | |
what = 0 | |
while len(curr) > 1: | |
nwhat = (what - len(curr) % step) % step | |
# nwhat = 1 - what if len(curr) % 2 == 1 else what | |
curr = [val for i, val in enumerate(curr) if i % step != what] | |
what = nwhat | |
return curr[0] | |
@pytest.mark.parametrize("n", range(1, 201)) | |
def test_it_works(n): | |
assert solve(n) == brute_solve(n) | |
print "solve(n): %s" % (solve(n),) | |
def test_speed(): | |
solve(12345678912) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment