Advertisement
mbratanov

Untitled

Sep 11th, 2024
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. import timeit
  2.  
  3. diyan_code = """
  4. numbers = "1 2 3 4 5".split(" ")
  5. [print(numbers.pop(), end=" ") for _ in range(len(numbers))]
  6. """
  7.  
  8. atanas_code = """
  9. numbers = "1 2 3 4 5".split(" ")
  10. my_stack = []
  11. while numbers:
  12.    my_stack.append(numbers.pop())
  13.  
  14. print(" ".join(my_stack))
  15. """
  16.  
  17. execution_time = timeit.timeit(diyan_code, number=1)
  18. print(f"Diyan - Execution time: {execution_time:.6f} seconds")
  19.  
  20. execution_time = timeit.timeit(atanas_code, number=1)
  21. print(f"Atanas - Execution time: {execution_time:.6f} seconds")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement