Test if an integer is odd or even, but do it as inefficiently or kooky as you can
Bonus points for skirting the execution time limit without waits or unnecessary loops
def oddEven(n):
return not str(n)[-1] in "02468"
import codewars_test as test
import random, string
import solution # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("Negative Evens")
def neg():
for i in range(1,10):
## Test for negative evens
test.assert_equals(oddEven(random.randrange(i*-1000, -1, 2)), 0)
@test.it("Negative Odds")
def neg_odd():
for i in range(1,10):
## Test for negative odds
test.assert_equals(oddEven(random.randrange(i*-1000, -1, 2))+1, 1)
@test.it("Zero")
def zero():
## Test zeros
test.assert_equals(oddEven(0),0)
@test.it("Positive Evens")
def pos():
for i in range(1,10):
## Test for positive evens
test.assert_equals(oddEven(random.randrange(2, i*1000, 2)), 0)
@test.it("Positive Odds")
def pos_odd():
for i in range(1,10):
## Test for positive odds
test.assert_equals(oddEven(random.randrange(2, i*1000, 2))+1, 1)