Advertisement
JollyMineCrafter

math competition cheat device (kinda inefficient)

May 15th, 2021 (edited)
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.39 KB | None | 0 0
  1. # Welcome to my cheat devices folder!
  2. # This program was written for a math competition.
  3.  
  4. # There's this game where I have to move a block
  5. # (value = 1) into some other blocks to add/multiply
  6. # it (values in 'listed'). sounds simple enough, but
  7. # well, it's not. That's why I'm writing this code
  8. # lmao. Don't underestimate these kinda games.
  9.  
  10. # If anyone wants to simplify this, please hmu :^)
  11.  
  12.  
  13.  
  14.  
  15. import random
  16.  
  17. result = 0
  18. while result != 49:
  19.     listed = ["+2","+3","+5","*2","*3","*5"]
  20.  
  21.     pathway = random.sample(listed, 6)
  22.     pathway = str(pathway)
  23.     pathway = pathway.replace("', '", "")
  24.  
  25.     path = "1"+str(pathway)[2:-2]
  26.  
  27.     value1 = str(path)[0:-10]
  28.     value2 = str(path)[3:-8]
  29.     value3 = str(path)[5:-6]
  30.     value4 = str(path)[7:-4]
  31.     value5 = str(path)[9:-2]
  32.     value6 = str(path)[11:0]
  33.  
  34.     test1 = value1
  35.     road1 = eval(test1)
  36.     test2 = str(road1) + value2
  37.     road2 = eval(test2)
  38.     test3 = str(road2) + value3
  39.     road3 = eval(test3)
  40.     test4 = str(road3) + value4
  41.     road4 = eval(test4)
  42.     test5 = str(road4) + value5
  43.  
  44.     result = eval(test5)
  45.  
  46.     print(path[0:-2], "=", result)
  47.  
  48.  
  49.  
  50.  
  51.  
  52. # Notes:
  53.  
  54. # As you can see, I didn't use value6 in the result
  55. # calculation. If I were to include it, there would
  56. # be another two lines:
  57. #     road5 = eval(test5)
  58. #     test6 = str(road5) + value6
  59. # and  the result would be eval(test6) instead.
  60. # However, as my math requires me to look for 49,
  61. # my answer is achieved through 5 values only.
  62.  
  63. # You can change the values in 'listed' into any
  64. # combination of operators and numbers you'd like!
  65. # I just chose those ones because that's what I was
  66. # supposed to work with.
  67.  
  68. # Also, the '6' in random.sample() represents the
  69. # amount of values inside 'listed'. If you'd like to
  70. # add less or more values into the list, adjust that
  71. # as well.
  72.  
  73. # The things in square brackets, like [0:-2], tell
  74. # Python where to start and where to end. For
  75. # example, [1:-1] tell it to start at value 1 and
  76. # end at '-1' counting from the last character. So
  77. # if an object value is 12345, it'll be reduced to
  78. # just 234. (Remember: the start and end values
  79. # are 0, so to get 12345 you would have to type
  80. # [0:0].
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. # New (still not working yet) version:
  118.  
  119.  
  120.  
  121. # Created on 14/05/2021-15/05/2021
  122. # Last modified on 16/05/2021
  123. # Last used on N/A
  124.  
  125. import random
  126.  
  127. result = 0
  128. x = 0
  129. listed = ["+2","+3","+5","*2"]
  130. cherish = "0"
  131.  
  132. def value(x):
  133.     x=x
  134.     value="value"+str(x)
  135.     return value
  136.  
  137. while x==0:
  138.     final = input("Please input a number.\n> ")
  139.     if final.isnumeric() == True:
  140.         break
  141.     else:
  142.         print("Please try again.\n")
  143.  
  144. cherish = str(value(x))
  145.  
  146. while result != final:
  147.  
  148.     pathway = random.sample(listed, len(listed))
  149.     pathway = str(pathway)
  150.     pathway = pathway.replace("', '", "")
  151.  
  152.     path = "1"+str(pathway)[2:-2]
  153.  
  154.     cherish = str(path)[x:(x+3)]
  155.  
  156.     while x != (len(listed)*2):
  157.        
  158.         step = str(eval(cherish))
  159.         lane = str(path)[x:x+3]
  160.         roadway = eval(step) + eval(lane)
  161.         sidewalk = eval(str(roadway))
  162.  
  163.         print ("path, cherish, step, lane, roadway, sidewalk:", path,",", cherish,",", step,",", lane,",", roadway,",", sidewalk)
  164.  
  165.         x = x + 2
  166.         cherish = str(step)
  167.  
  168.     if result == final:
  169.         break
  170.  
  171. print(path[0:-2], "=", result)
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement