def main(): print prob5v2(20) # time different approaches, using first 15 as doing 1st 20 takes too long setup = """ from project_euler.problem5.problem5 import prob5, prob5v2 """ runs = [("""prob5(15)""", setup, "Using all()"), ("""prob5v2(15)""", setup, "Inner pred function"), ] num_iterations = 100 print format_runs(timeruns(runs, num_iterations))
def main(): print prob4(3) print prob4v2(3) # time different approaches setup = """ from project_euler.problem4.problem4 import prob4, prob4v2 """ runs = [("""prob4(3)""", setup, "Nested For Loop"), ("""prob4v2(3)""", setup, "Dict comprehension"), ] num_iterations = 100 print format_runs(timeruns(runs, num_iterations))
def main(): print prob5v2(20) # time different approaches, using first 15 as doing 1st 20 takes too long setup = """ from project_euler.problem5.problem5 import prob5, prob5v2 """ runs = [ ("""prob5(15)""", setup, "Using all()"), ("""prob5v2(15)""", setup, "Inner pred function"), ] num_iterations = 100 print format_runs(timeruns(runs, num_iterations))
def main(): print prob4(3) print prob4v2(3) # time different approaches setup = """ from project_euler.problem4.problem4 import prob4, prob4v2 """ runs = [ ("""prob4(3)""", setup, "Nested For Loop"), ("""prob4v2(3)""", setup, "Dict comprehension"), ] num_iterations = 100 print format_runs(timeruns(runs, num_iterations))
def main(): ''' Run the solution to the problem timing each approach ''' # Print out the answer for the given input print "Answer: %d" % prob42(loadfile(), is_tnum_set) # time different approaches setup = """ from project_euler.problem42.prob42 import prob42, is_tnum_builtinsqrt, loadfile lines = loadfile() """ runs = [("""prob42(lines)""", setup, "Using Set Lookup"), ("""prob42(lines, is_tnum_builtinsqrt)""", setup, "Solving quadratic"), ] num_iterations = 100 print format_runs(timeruns(runs, num_iterations))
def main(): ''' Run the solution to the problem timing each approach ''' print prob6(100, sum_squares_formula, squares_sum_gauss) # time different approaches setup = """ from project_euler.problem6.prob6 import prob6, sum_squares_loop, \ squares_sum_gauss, squares_sum_loop, sum_squares_formula """ runs = [("""prob6(100, sum_squares_loop, squares_sum_gauss)""", setup, "Naive sumsquares, Gauss squaresum"), ("""prob6(100, sum_squares_loop, squares_sum_loop)""", setup, "Naive sumsquares, naive squaresum"), ("""prob6(100, sum_squares_formula, squares_sum_gauss)""", setup, "Smart sumsquares, Gauss squaresum"), ("""prob6(100, sum_squares_formula, squares_sum_loop)""", setup, "Smart sumsquares, naive squaresum"), ] num_iterations = 10000 print format_runs(timeruns(runs, num_iterations))
def main(): ''' Run the solution to the problem timing each approach ''' print prob6(100, sum_squares_formula, squares_sum_gauss) # time different approaches setup = """ from project_euler.problem6.prob6 import prob6, sum_squares_loop, \ squares_sum_gauss, squares_sum_loop, sum_squares_formula """ runs = [ ("""prob6(100, sum_squares_loop, squares_sum_gauss)""", setup, "Naive sumsquares, Gauss squaresum"), ("""prob6(100, sum_squares_loop, squares_sum_loop)""", setup, "Naive sumsquares, naive squaresum"), ("""prob6(100, sum_squares_formula, squares_sum_gauss)""", setup, "Smart sumsquares, Gauss squaresum"), ("""prob6(100, sum_squares_formula, squares_sum_loop)""", setup, "Smart sumsquares, naive squaresum"), ] num_iterations = 10000 print format_runs(timeruns(runs, num_iterations))