Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Crypto.Random.random import randint
- from secret import flag
- class Challenge:
- def __init__(self):
- self.rounds = 50
- def checking(self, list_num, magic_num):
- for i in list_num:
- if i == magic_num:
- return True
- return False
- def quest(self):
- turns = 10
- magic_num = randint(0, 1023)
- for i in range(turns):
- req = int(input(">>> "))
- try:
- list_num = list(map(int, req.split()))
- except:
- print("Nice try, kiddo!")
- return False
- if self.checking(list_num, magic_num):
- print("YES")
- else:
- print("NO")
- try:
- print("Your final answer is : ")
- answer = int(input())
- if answer == magic_num:
- print("Correct!")
- return True
- else:
- print("Wrong!")
- return False
- except:
- print("Your answer is not valid!!!")
- return False
- def main(self):
- print("Welcome to my challenge!!!")
- print("In this challenge, you have to past 50 rounds, each round have 1 magic numbers.")
- print("Your task is to guess that number.")
- print("You can ask me at most 10 questions.")
- print("Let\'s assume you want to know if magic number is in (1, 2, 3, 4, 5) list, then you have to send like \"1 2 3 4 5\", each seperate by a space.")
- print("After that, you will receive two kind of answers.")
- print("YES if the magic number is in the list you send me.")
- print("NO if the magic number is not in the list you send me.")
- print("After 10 turns, you will give me the final asnwer, if it is correct, you pass, if wrong, you lose.")
- print("Good luck, hackers!!!")
- for i in range(self.rounds):
- print(("Challenge " + str(i) + " :"))
- if self.quest():
- print(("You passed the challenge " + str(i) + "th"))
- else:
- print("You failed!")
- return
- print("Here is your flag : " + flag)
- Chall = Challenge()
- Chall.main()
Advertisement
Add Comment
Please, Sign In to add comment