Skip to content
Permalink
e915468b34
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
165 lines (150 sloc) 14 KB
# importing any additional library resources #
import textwrap
import time
# if we want the user to adjust the time that they have? #
time_input = input("Enter the time it takes you to read the story in seconds: ")
seconds_for_countdown = time_input
# the story text is stored in the variable 'story_text', then we use the textwrap library to print it to the terminal with line breaks automatically #
story_text = "As the sun started to set down and the sky turned jet black. Tony, who is a former CIA operative, and his daughter Sarah were snatched from their homes in the middle of the night and locked in a 20 by 20-foot cube shaped cell with a dimmed light bulb, stained mattresses and an old computer which only uses binary. The only way for him to be able to escape and spare himself and his daughter is to figure out a list of binary numbers which he will need to convert to English text. Time was the biggest enemy as he only had 30 minutes to complete and sprint for the exit door of the cell."
story_text += "\n\nOn the other hand, Sarah was put in a cell next to Tony’s cell. The only thing separating them was a wall made of thick, black tinted glass. Where she sees him get tortured, without him knowing she was there. Her legs were tied to a chair, her hands cuffed together, her arms wrapped behind the chair and her mouth was sealed. \n\nTo further make sure she could not communicate with anyone, they locked her in an empty cell. So silent, she could hear her own heartbeat beat like a drum. She looked around trying to find a way to talk to her father. Luckily, she still had her wedding ring on her and the chair she sat on was made of metal. She figured away to get in touch with Tony.\n\nSince childhood whenever Sarah got upset, she did not talk to anyone. She used to lock herself in her room and refuse to eat or come out of it. Tony would go to her, knock on the door, and try to get her out of there. One day she knocked back. Tony sat in front of her room as they knocked back and forth. This would go on until one day they made their own coded language.\n\n"
# print("\n".join(textwrap.wrap(story_text, 60)))
print(story_text)
# numbers represent how many knocks. E.g. 1 knock pause then 2 knocks means latter G.
Knocks = { 1:'A',2:'B',3:'C',4:'D',5:'E','1 PAUSE 1':'F','1 PAUSE 2':'G','1 PAUSE 3':'H','1 PAUSE 4':'I','1 PAUSE 5':'J','2 PAUSE 1':'K','2 PAUSE 2':'L','2 PAUSE 3':'M','2 PAUSE 4':'N','2 PAUSE 5':'O','3 PAUSE 1':'P','3 PAUSE 2':'Q','3 PAUSE 3':'R','3 PAUSE 4':'S/Z','3 PAUSE 5':'T','4 PAUSE 1':'U','4 PAUSE 2':'V','4 PAUSE 3':'W','4 PAUSE 4':'X','4 PAUSE 5':'Y','5 PAUSE 1':0,'5 PAUSE 2':1,'5 PAUSE 3':2,'5 PAUSE 4':3,'5 PAUSE 5':4,'6 PAUSE 1':5,'6 PAUSE 2':6,'6 PAUSE 3':7,'6 PAUSE 4':8,'6 PAUSE 5':9,6:'New letter'}
# the audience can choice to view the coded knocks or not.
def codedLetters(ans):
ans = str(ans.upper())
if ans == 'YES':
print(Knocks)
else:
print('Let us carry on.')
codedLetters(input('Do you want to see the key to the coded language? '))
story_text2 = "\nThe signal language Sarah made with her father inspired her to learn more about coding and pursue Computer science as a career. She finished her bachelor’s and master’s degrees. On her PhD research she was working on AI, that is when she made an AI that could learn to program in all languages and apply the programming to any machine. Her project was a success and the government got intrigued by it. \n\nSarah got a contract offer from the department of intelligence, with an enormous amount of funding for her project. Plus, she got to work closely with the CIA in other word her father Tony. She was overjoyed, but little did she know where this path would lead her to. \n\nTony heard tapping. He noticed it was not random. There was a pattern. It kept repeating. Tap-Tap Tap Tap-Tap Tap. There was someone trying to reach out to him from the darkness. A ray of hope struck. trying to communicate with him. He was not sure who though. \n\n4 TAPS 6 TAPs 1 TAP 6 TAPS 4 TAPS. \n\nD new letter A new letter D. \n\nTony: Is that you Sarah? He shouted. \n\nSarah: 4,5 (6) 5 (6) 3,4 . yes. she tapped. \n\nTony: I am so glad you are still alive. He said as he sniffled between words. \n\nSarah: Do not worry I am going to help you solve the riddle. We are getting out of here alive. She tapped. \n\nTony tries to lift his lifeless body upright due to the unimaginable torture which ensued beforehand. He grasps the keyboard and sets his sights on this life-or-death situation. His fingers start to shiver with fear as he struggles mightily to type properly. Tony's gazes at endless lines of binary numbers that he needs to conquer with under 15 minutes to go. Tony’s plan was to work out the binary code in groups instead of a single line. Even though his hopes were on the verge of being crushed, he was super determined to get the job done and rescue the one person that he truly cares about in his life. \n\nHowever, that was not the only puzzle he had to solve. He must go through and survive the traps that were laid on his path to Sarah. One of the traps was the ROOM. There was a massive door in front of Tony and next to it was a board with instructions. Behind this door, there are 4 numbered doors from 1 to 4 , each has a unique number burned on it. There is also a number painted on the wall of every room. Only 1 of them lead to the exit. The rest lead to trapped rooms with certain death. The number on the correct door is ‘the square of an odd number’ , ‘the cube of an even number’ or ‘ it has a factor of 2 primary’ numbers. Each room has only one door with the correct answer. Every room follows this rule except the last one. The door number is the sum of the numbers that were painted on the walls of the previous rooms.\n\nTony planned his scape and came up with the following solution: \n\nIs it a prime number? \nYes -> Go to the next door and check the number on it. \nNo -> Go to the next question.\n\nDoes it have a factor of 2 prime numbers?\nYes -> Enter the room. Pick a door and check the number on it.\nNo -> Go to the next question. \n\nIs it a square number? \nYes -> Go to the next question. \nNo -> Go to the next question.\n\nIs it the square of an odd number ? \nYes -> Enter the room. Pick a door and check the number on it.\nNo -> Go to the next door.\n\nDoes it have a factor of 2 prime numbers?\nYes -> Enter the room. Pick a door and check the number on it.\nNo -> Go to the next question.\n\nIs it the square of an odd number ? \nYes -> enter.\n\nIs it a cube number?\nYes -> go to the next question.\nNo -> go to the next question.\n\nIs it the cube of an even number ?\nYes -> enter.\nNo -> Go to the next door and check the number on it.\n\nHave you checked all the doors?\nYes -> This is the final room. \nNo -> Go to the next door and check the number on it.\n\nHe proceeded with his plan and opened the door. \n\n 1st room.\no Note the number on the wall (it was 45).\no Check the number on door 1.\no 51. it has a factor of 2 prime numbers (3 * 17).\no Enter .\n\n 2nd room.\no Note the number on the wall (it was 2).\no Add that number to the previous one.\no Check the number on door 1.\no 24. it is not square number, is not cube number but is a multiple of 2 prime numbers.\no Check the number on door 2.\no 64. is a square number, but not the square of an odd number. It is cube number of an even number (43).\no Enter.\n\n 3rd room.\no Note the number on the wall (it was 6).\no Add that number to the previous one.\no Check the number on door 1.\no 27. it is not multiple of prime number. is not square number. It is a cube number, but it is not the cube of an even number.\no Check the number on door 2.\no 23. it is prime number.\no Check the number on door 3.\no 49 does not have factor of 2 primes. It is a square number of an odd number.\no Enter.\n\n 4th room.\no Note the number on the wall (it was 61).\no Add that number to the previous one.\no None of the door numbers are square nor cube nor has a factor of 2 prime number.\no The door number should be 61 + 6 + 45 +2 = 114\no Look for door number 114.\no Enter.\nTony survived and got a step closer to his daughter.\n"
print(story_text2)
# instantiate the variables for the timer used #
time_start = time.time()
seconds = 0
minutes = 0
# function for a countdown (this is posted in the terminal, and reduced by 1 second every 1 second) #
def countdown(time_input):
while time_input:
# instantiates the fact that the time_input is divided by 60 to achieve one minute of time #
mins, secs = divmod(time_input, 60)
# formatting used for minutes and seconds #
timer = '{:02d}:{:02d}'.format(mins, secs)
# prints the timer, and pushes the users cursor to the next line #
print(timer, end="\r")
# forces the timer to sleep for 1 second #
time.sleep(1)
# removes 1 second from the time input variable, thereby reducing the timer by 1 second #
time_input -= 1
print("End of countdown, your given time to read the story is finished. Now it's your turn to solve the puzzle and complete the game.\n\n")
#instantiates the task1 function to start the game.
task1(input('Is it a prime number? '))
# we can change the countdown here, if we decide 30 minutes is too much/ too little time for the average user #
# seconds_for_countdown = 1800
# Eliminates all primary numbers
def task1( question1):
question1 = str(question1.upper())
if question1 == 'YES':
print('Go to the next door and check the number on it')
task1(input('Is it a prime number? ' ))
elif question1 == 'NO':
print('Go to the next question.')
task2(input('Does it have a factor of 2 prime numbers? ' ))
else:
print('Please enter a valid answer')
task1(input('Is it a prime number? ' ))
def task2(question2):
question2 = str(question2.upper())
if question2 == 'YES':
print('Enter the room. Pick a door and check the number on it')
task1(input('Is it a prime number? ' ))
elif question2 == 'NO':
print('Go to the next question.')
task3A(input('Is it a cube number? '))
else:
print('Please enter a valid answer')
task2(input('Does it have a factor of 2 prime numbers? ' ))
def task3A( question3A):
question3A = str(question3A.upper())
if question3A == 'YES':
print('Go to the next question.')
task3B(input('Is it the cube of an even number? ' ))
elif question3A == 'NO':
print('Go to the next question.')
task4A(input('Is it a square number? '))
else:
print('Please enter a valid answer.')
task3A(input('Is it a cube number? '))
# Eliminates cube numbers that are odd number cubed.
def task3B(question3B):
question3B = str(question3B.upper())
if question3B == 'YES':
print('Enter the room. Pick a door and check the number on it')
task1(input('Is it a prime number? ' ))
elif question3B == 'NO':
print('Go to the next question.')
task4A(input('Is it a square number? '))
else:
print('Please enter a valid answer')
task3B(input('Is it the cube of an even number? '))
def task4A(question4A):
question4A = str(question4A.upper())
if question4A == 'YES':
print('Go to the next question.')
task4B(input('Is it the square of an odd number? ' ))
elif question4A == 'NO':
task5(input('Have you chacked all doors? '))
else:
print('Please enter a valid answer')
task4A(input('Is it a square number? '))
# Eliminates square numbers that are even number squared.
def task4B(question4B):
question4B = str(question4B.upper())
if question4B == 'YES':
print('Enter the room. Pick a door and check the number on it')
task1(input('Is it a prime number? ' ))
elif question4B == 'NO':
print('Go to the next door and check the number on it.')
task1(input('Is it a prime number? ' ))
else:
print('Please enter a valid answer')
task4B(input('Is it the square of an odd number? '))
def task5(question5):
question5 = str(question5.upper())
if question5 == 'YES':
print('This is the final room.')
elif question5 == 'NO':
print('Go to the next door and check the number on it.')
task1(input('Is it a prime number? ' ))
else:
print('Please enter a valid answer')
task5(input('Have you chacked all doors? '))
# instantiates the countdown function, and casts the argument to an int (input of the user)
countdown(int(seconds_for_countdown))
para_two_three = ("on the other hand, Sarah wa put in a cell next to Tony's cell. The only thing separating them was a wall made of thick, black tinted glass. Where she sees him get tortured, without him knowing she was there. Her legs were tied to a chair, her hands cuffed together, her arms wrapped behind the cair and her mouth was sealed. To further make sure she could not communicate with anyone, they locked her in an empty cell. So silent, she could hear her own heart beat like a drum. She looked around trying to find a way to talk to her father. Luckily, she still had her wedding ring on her and the chair she sat on was made of metal. She figured a way to get in touch with Tony.")
print(para_two_three)
option1 = ("1,Get Sarah to communicate with Tony")
option2 = ("2,Not have Sarah communicate")
option3 = ("3,Try and get Sarah to escape")
print(option1)
print(option2)
print(option3)
choice = input("What option will you pick!:")
def story(choice):
option1 = ("Get Sarah to communicate with Tony")
option2 = ("Not have Sarah communicate")
option3 = ("Try and get Sarah to escape")
if choice == "1" or choice == "option1" or choice == "option 1" or choice == "Option 1":
print("You have chosen to " + option1+ ".")
print("Result: Sarah knocks on the door to communicate with Tony")
if choice == "2" or choice == "option2" or choice == "option 2" or choice == "Option 2":
print("You have chosen to " + option2 + ".")
print("Result: Saarah satres at the floor")
if choice == "3" or choice == "option3" or choice == "option 3" or choice == "Option 3":
print("You have chosen to " + option3 + ".")
print("Result; Oh that wasn't wise, the guards see Sarah trying to escape. She is killed. GAME OVER")
else:
print("Oops, that's no good")
story(choice)