Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cProfile
- # def lights(): return["".join(["-" if (len(set(x for x in range(1,buttonNo + 1) if lightNo%x == 0))%2 == 0) else "*" for lightNo in range(1,51)]) for buttonNo in range(1,51)]
- # def xlights(): return["".join(["-" if (len(set(x for x in xrange(1,buttonNo + 1) if lightNo%x == 0))%2 == 0) else "*" for lightNo in xrange(1,51)]) for buttonNo in xrange(1,51)]
- # print cProfile.run('lights()')
- # print cProfile.run('xlights()')
- def iain():
- output = "-" * 50
- for x in range(1,51):
- output = "".join([output[i-1] if (i%x!=0) else "-" if output[i-1] == "*" else "*" for i in xrange(1,51)])
- print output
- def dan():
- output = list("-" * 50)
- for x in xrange(1,51):
- for i in xrange(1,51):
- if i % x == 0:
- output[i-1] = "*" if output[i-1] == "-" else "-"
- print "".join(output)
- def last():
- return["".join(["*" if (50 >= x and float(x**.5).is_integer()) else "-" for x in xrange(1,51)])]
- def testIain():
- for i in xrange(100):
- iain()
- def testDan():
- for i in xrange(100):
- dan()
- def testLast():
- for i in xrange(100):
- last()
- cProfile.run('testDan()')
- cProfile.run('testIain()')
- # cProfile.run('testLast()')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement