In [ ]:
import obscure_by_height
from timeit import timeit

In [ ]:
def bruteforce(x, y, n): #, printout
    """full iteration of above problem"""
    from itertools import permutations
    rabbits = list(range(1, n+1))
    success_count = 0 
    for perm in permutations(rabbits):
        height_max = 0 
        x_count = 0
        for rabbit in perm:
            if rabbit > height_max:
                height_max = rabbit
                x_count += 1
            
        height_max = 0 
        y_count = 0 
        for rabbit in reversed(perm):
            if rabbit > height_max:
                height_max = rabbit
                y_count += 1
        
        if x_count == x and y_count == y:
            success_count += 1
            for rabbit in perm:
                pass
                #print("x"*rabbit)
            #print()
            
    return str(success_count)

In [ ]:
args = (1, 2, 40)
print(answer(*args))
print(bruteforce(*args))

In [ ]:
for n in range(3, 12):
    for x in range(1, n+1):
        for y in range(1, n+1):
            bf = bruteforce(x, y, n)
            a = answer(x, y, n)
            if a != bf:
                print x, y, n 
                print "failed test!"
            else:
                print x, y, n, "passed!"

In [ ]:
from timeit import timeit

%timeit -n 1 answer(*args)

In [ ]:
import fractions
print(fractions.Fraction(274.0/120))

print(factfract(8,5))

In [ ]:
import math
print(type(math.factorial(40)))

def factorial_fraction(num, den):
    """returns reduced factorial of num/den without performing full multiplication"""
    product = 1
    for n in range(den, num):
        product *= n+1
    return product

def factorial_fraction2(num, den):
    """same thing using mathlib"""
    return math.factorial(num) // math.factorial(den)

args = (50, 30)

%timeit factorial_fraction(*args)
%timeit factorial_fraction2(*args)

%timeit factorial_fraction(50, 1)
%timeit math.factorial(50)

In [ ]:
if answer(2, 2, 3) == "2":
    print("test 1 passed")
else:
    print("test 1 failed")
    
if answer(1, 2, 6) == "24":
    print("test 1 passed")
else:
    print("test 1 failed")

In [ ]:
#if nx < x:
         #   print "zero"
        # #   return 0

                #    print x, nx, "one"
        #    if nx < 1:
        #        return 0
        #    else: