Advertisement
999ms

Untitled

Oct 2nd, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import msvcrt
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import time
  5.  
  6. def nuc(u, n):
  7.     if u >= n:
  8.         u -= n
  9.         n *= 3
  10.     else:
  11.         n += u * 3
  12.         u = 0
  13.     return u, n
  14.  
  15. u = int(input())
  16. n = 0
  17. timer = 1
  18.  
  19. unranium_data = [u]
  20. neutrons_data = [n]
  21.  
  22. while u > 0:
  23.     ch = 'not_x'
  24.     if msvcrt.kbhit():
  25.         ch = msvcrt.getch()
  26.     kek = 0
  27.     if ch == b'x':
  28.         n += 1
  29.     u, n = nuc(u, n)
  30.     unranium_data.append(u)
  31.     neutrons_data.append(n)
  32.     timer += 1
  33.     time.sleep(0.3)
  34. plt.plot([i for i in range(timer)], unranium_data)
  35. plt.plot([i for i in range(timer)], neutrons_data)
  36.        
  37. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement