Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- def string_splosion1(str):
- newString = ''
- for i in range(len(str)):
- x = len(str) - i
- negNum = x * -1
- newString = newString + str[:negNum]
- newString += str
- return newString
- def string_splosion2(str):
- result = ""
- for i in range(len(str)):
- result = result + str[:i+1]
- return result
- n = 10000
- t0 = time.time()
- for i in range(n): string_splosion1('Code')
- t1 = time.time()
- t2 = time.time()
- for x in range(n): string_splosion2('Code')
- t3 = time.time()
- total_n = t1-t0
- total_z = t3-t2
- print(total_n)
- print(total_z)
Advertisement
Add Comment
Please, Sign In to add comment