Skip to content

Instantly share code, notes, and snippets.

@clisamurai
Last active January 12, 2016 21:24
Show Gist options
  • Save clisamurai/d74e30f07794be9d8604 to your computer and use it in GitHub Desktop.
Save clisamurai/d74e30f07794be9d8604 to your computer and use it in GitHub Desktop.
Bullseye is a computerized creator of the puzzles variously known as word polygons, word targets and plenty of other names. Bullseye is a Python program which uses relies on Python 2.7 and was created by Mitchell Palmer as a learning project.
import random
import pprint
import textwrap
pp = pprint.PrettyPrinter(indent=4)
print "Welcome to the Bullseye Puzzle!"
print textwrap.wrap("Bullseye is a computerized creator of the puzzles variously known as word polygons, word targets and plenty of other names. Bullseye is a Python program which uses relies on Python 2.7 and was created by Mitchell Palmer as a learning project")
def shuffle_word(word):
word = list(word)
random.shuffle(word)
return ''.join(word)
result = None
while result is None:
try:
lines = (line.rstrip('\n') for line in open('words.txt'))
nine_letters = []
other_usable_words = []
final_words = []
for word in lines:
if (len(word)==9) and (word.lower()==word):
nine_letters.append(word)
elif ( 3 <= len(word) < 9) and (word.lower()==word):
other_usable_words.append(word)
nine_letter_word = random.choice(nine_letters)
central_letter = random.choice(nine_letter_word)
for word in other_usable_words:
letters_used = []
word_passes_so_far = False
if central_letter in word:
for letter in word:
if letter in nine_letter_word and letter not in letters_used:
word_passes_so_far = True
letters_used.append(letter)
else:
word_passes_so_far = False
break
if word_passes_so_far:
final_words.append(word)
nine_letters_shuffled = list(shuffle_word(nine_letter_word).replace(central_letter, ""))
result = "|---|---|---|\n" + "| " + nine_letters_shuffled[0] + " | " + nine_letters_shuffled[1] + " | " + nine_letters_shuffled[2] + " |\n" + "|---|---|---|\n" + "| " + nine_letters_shuffled[3] + " | " + central_letter + " | " + nine_letters_shuffled[4] + " |\n" +"|---|---|---|\n" + "| " + nine_letters_shuffled[5] +" | " + nine_letters_shuffled[6] + " | " + nine_letters_shuffled[7] + " |\n" + "|---|---|---|\n";
aggregateScore = 0
for word in final_words:
aggregateScore += len(word) - 5
print result
if aggregateScore > 151:
print "Easy"
elif 101 < aggregateScore < 150:
print "Resonably Easy"
elif 51 < aggregateScore < 100:
print "Resonable"
elif 1 < aggregateScore < 50:
print "Hard"
elif 0 > aggregateScore:
print "Fiendishly Difficult"
# print "Scores: "
# print "Good: " +
fake = raw_input('Hit enter on the keyboard to view answers.')
print "Nine-letter word: " + nine_letter_word
print "Final words: "
pp.pprint(final_words)
except:
pass
@clisamurai
Copy link
Author

I am working on including a more accurate difficulty rating in 2.0 as well as including an algorithm to determine how many words would be considered a good, great or excellent score. I am also thinking about including a levels system based on the centre letter.

@clisamurai
Copy link
Author

Please note you need a newline seperated list of words call words.txt to be in the same directory for this to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment