Skip to content

Instantly share code, notes, and snippets.

@jakab922
Created November 8, 2017 20:44
Show Gist options
  • Save jakab922/0b765dfe04d8be0e1e20c2181b60e8e7 to your computer and use it in GitHub Desktop.
Save jakab922/0b765dfe04d8be0e1e20c2181b60e8e7 to your computer and use it in GitHub Desktop.
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