Sunteți pe pagina 1din 3

This was my first attempt at writing a program.

Don't h8 or aggit8 me or ill kil


l your best m8.
#
#
#
#
#
#
#
#
#
#
#
#
#
#

ProgramName: PuzzleProgram
FilenName: PuzzleProgram.py
Author: Josh Willis
Date: 16/01/14
Program to allow user to solve a coded word puzzle. Will allow the user to
enter and delete letter pairings and substitutions. Program will load
words.txt file which contains the words. Program will loads clues.txt which
contains clues to solve the puzzle. Program will display the list of 10 words
with the substitions input by the user. Program will allow the user to keep
trying until the code is broken. Program will check the users list of words
against the external file solved.txt and displays the appropriate success or
fail message.

# For this first part i will be developing the part of the program that opens th
e
# Words.txt file for the user to use.

print("Here Is The Contents Of The Words.Txt File...")


f = open("words.txt","r")
print(f.read())
f.close()
subsdict = {}
CodedWords = ["#+/084&\n\
#3*#%#+\n\
8%203:\n\
,1$&\n\
!-*%\n\
.#7&33&\n\
#*#71%\n\
&-&641'2\n\
#))85\n\
9&330*"]
menu =
1.
2.
3.
4.
5.
6.
9.

"Welcome to AQA Code Puzzle:\n\


Enter a pairing\n\
Delete a pairing\n\
Check answers\n\
Clues?\n\
Show current pairings\n\
Help\n\
Quit\n"

x = 1
x = int(input(menu))
while x != 9:
if x == 1:
#Starts if statement when user chooses option 1
f = open
#Sets F variable to open

print("Enter a pairing")
#Prints Enter a pairing to user
print(CodedWords)
#Prints Codedwords
Symbol = input("Enter a symbol: ")
#Asks user to enter a symbol
Letter = input("Enter a letter: ")
#Asks user to enter a letter
for key, value in subsdict.items():
#
if Letter == key:
#Starts IF statement so if letter = key then it...
print("Error")
#Print error to the user
if Symbol == value:
print("Error")
subsdict[Letter] = Symbol
for key, value in enumerate(CodedWords):
CodedWords[key] = value.replace(Symbol,Letter)
print(CodedWords [key])
x = int(input(menu))
#Enter a pairing
elif x == 2:
print ("Delete a pairing")
print(CodedWords)
Letter = input("Enter a letter: ")
Symbol = input("Enter a symbol: ")
for value, key in enumerate(Codedwords):
Codedwords[value]= key.replace(letter, symbol)
print(Codedwords)
x = int(input(menu))
#Delete a pairing
elif x == "3":
f = open
print ("Check answers")
x = int(input(menu))
#Check answers
elif x == "4":
f = open ("clues.txt", "r")
print(f.read())
f.close()
x = int(input(menu))
#Hints
elif x == "5":
print ("Show current pairings")
x = int(input(menu))
#Shows current pairings
elif x == "6":
f = open
print("Frequency of latter")
if x== 6:
frequency = []
frequency = (input("Please enter the letter that you want to check."
))
pointer = 0
for word in CodedWords:

for character in word:


if frequency == character:
pointer = pointer +1
print ("The symbol", frequncy, "appears", pointer, "times in the puzzle"
)
x = int(input(menu))
#Displays instructions
elif x == "7":
f = open
print("Quit")
x = int(input(menu))
#Quit
print("Goodbye")
f.close()

S-ar putea să vă placă și