Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Welcome to my cheat devices folder!
- # This program was written for a math competition.
- # There's this game where I have to move a block
- # (value = 1) into some other blocks to add/multiply
- # it (values in 'listed'). sounds simple enough, but
- # well, it's not. That's why I'm writing this code
- # lmao. Don't underestimate these kinda games.
- # If anyone wants to simplify this, please hmu :^)
- import random
- result = 0
- while result != 49:
- listed = ["+2","+3","+5","*2","*3","*5"]
- pathway = random.sample(listed, 6)
- pathway = str(pathway)
- pathway = pathway.replace("', '", "")
- path = "1"+str(pathway)[2:-2]
- value1 = str(path)[0:-10]
- value2 = str(path)[3:-8]
- value3 = str(path)[5:-6]
- value4 = str(path)[7:-4]
- value5 = str(path)[9:-2]
- value6 = str(path)[11:0]
- test1 = value1
- road1 = eval(test1)
- test2 = str(road1) + value2
- road2 = eval(test2)
- test3 = str(road2) + value3
- road3 = eval(test3)
- test4 = str(road3) + value4
- road4 = eval(test4)
- test5 = str(road4) + value5
- result = eval(test5)
- print(path[0:-2], "=", result)
- # Notes:
- # As you can see, I didn't use value6 in the result
- # calculation. If I were to include it, there would
- # be another two lines:
- # road5 = eval(test5)
- # test6 = str(road5) + value6
- # and the result would be eval(test6) instead.
- # However, as my math requires me to look for 49,
- # my answer is achieved through 5 values only.
- # You can change the values in 'listed' into any
- # combination of operators and numbers you'd like!
- # I just chose those ones because that's what I was
- # supposed to work with.
- # Also, the '6' in random.sample() represents the
- # amount of values inside 'listed'. If you'd like to
- # add less or more values into the list, adjust that
- # as well.
- # The things in square brackets, like [0:-2], tell
- # Python where to start and where to end. For
- # example, [1:-1] tell it to start at value 1 and
- # end at '-1' counting from the last character. So
- # if an object value is 12345, it'll be reduced to
- # just 234. (Remember: the start and end values
- # are 0, so to get 12345 you would have to type
- # [0:0].
- # New (still not working yet) version:
- # Created on 14/05/2021-15/05/2021
- # Last modified on 16/05/2021
- # Last used on N/A
- import random
- result = 0
- x = 0
- listed = ["+2","+3","+5","*2"]
- cherish = "0"
- def value(x):
- x=x
- value="value"+str(x)
- return value
- while x==0:
- final = input("Please input a number.\n> ")
- if final.isnumeric() == True:
- break
- else:
- print("Please try again.\n")
- cherish = str(value(x))
- while result != final:
- pathway = random.sample(listed, len(listed))
- pathway = str(pathway)
- pathway = pathway.replace("', '", "")
- path = "1"+str(pathway)[2:-2]
- cherish = str(path)[x:(x+3)]
- while x != (len(listed)*2):
- step = str(eval(cherish))
- lane = str(path)[x:x+3]
- roadway = eval(step) + eval(lane)
- sidewalk = eval(str(roadway))
- print ("path, cherish, step, lane, roadway, sidewalk:", path,",", cherish,",", step,",", lane,",", roadway,",", sidewalk)
- x = x + 2
- cherish = str(step)
- if result == final:
- break
- print(path[0:-2], "=", result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement