lotto_interpreter.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import random
  2. import contextlib
  3. chars="`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>? \t\n"
  4. addCMD = chars[random.randint(0, len(chars)-1)]
  5. subCMD = chars[random.randint(0, len(chars)-1)]
  6. appCMD = chars[random.randint(0, len(chars)-1)]
  7. exrCMD = chars[random.randint(0, len(chars)-1)]
  8. outCMD = chars[random.randint(0, len(chars)-1)]
  9. # 0.000000011645049%
  10. # addCMD = '+'
  11. # subCMD = '-'
  12. # appCMD = '>'
  13. # exrCMD = '<'
  14. # outCMD = '!'
  15. with open("./lotto/main.lotto") as raw:
  16. con = raw.read()
  17. with contextlib.suppress(Exception):
  18. curstring = ""
  19. curcell = 0
  20. lines = con.split("\n")
  21. for line in lines:
  22. for chariter in range(len(line)):
  23. curchar = line[chariter]
  24. if curchar == appCMD:
  25. curstring += chr(curcell)
  26. curcell = 0
  27. elif curchar == outCMD:
  28. print(curstring)
  29. curstring = ""
  30. with contextlib.suppress(Exception):
  31. nextchar = line[chariter+1]
  32. editor = 1
  33. if nextchar == exrCMD:
  34. editor = 10
  35. if curchar == addCMD:
  36. curcell += editor
  37. elif curchar == subCMD:
  38. curcell -= editor