/upe-coding-challenge

upe coding challenge spring 2018

Primary LanguagePython

UPE Coding Challenge Spring 2018
--------------------------------

NOTE 1: i'm running Python 2.7.10 (sorry python 3 users)
NOTE 2: i've included a screenshot titled "proof.png" to show that in fact, i did get a win rate of 28% for 100 games!!!
NOTE 3: there's a bug associated with unicode encoding/decoding (that hardly ever occurs), which causes the program to crash. in this case, it's best to just restart the program. you can do this manually, or by executing the included script "script.sh" to continuously run my program, regardless of any failures. (however, script.sh can only be exited by manually restarting Terminal)

TO RUN:
python coding_challenge.py

TO RESET:
python reset.py

GENERAL STRATEGY:
- Always guess 'a' and 'e' first.
- Then, we try to make an educated guess:
	- For each word in the "state" string, look through the dictionary (newDict.txt) for matching entries. If we find a matching
	entry, we append it to a list called "possibleWords".
	- If we don't find any possible words, then we just guess the next most common character (that hasn't been guessed before) in
	the string "etaoinsrhldcumfpgwybvkxjqz".
	- If we do find possible words, we create a frequency dictionary called "freqList". Then, we go through each possible word and 
	for each character that hasn't been guessed before, we update the frequency dictionary. In essence, this creates a frequency
	table. Then, we just guess the character with the highest frequency.
- If we lose or win a game, we look at the returned "lyrics" string and find words that weren't in our dictionary before,
and we append these to our (growing) dictionary.