id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jotto


Jotto is a word game that resembles the colored-peg game 'Mastermind.' In Jotto, player one secretly chooses a five-letter target word with five different letters (no proper nouns allowed; no duplicate letters allowed), and player two makes a series of guesses until s/he has figured out all the letters in the target. For example, player one picks "lucky" as the target, and player two guesses "close". To this, player one replies "2", because there are two letters in common, "c" and "l" (it doesn't matter if the letters are in the correct position within the word). Then player two guesses "could" and gets the reply "3". The game continues until player one replies with "5" (even if player two guessed a word which is not exactly the target but is an anagram of the target). Your task is to define the function jotto(turns) which takes a list of turns, where each turn is a [guess, reply] pair (guess is a five-letter word and reply is an integer, 0-5), and returns the (alphabetized) list of all words in the dictionary that are the remaining possible targets (because they are consistent with all the guess/reply pairs). Use the following dictionary (derived from the most common 5000 words, eliminating proper nouns): dictionary = """about above abuse acres actor admin adobe adult after agent album alert alive alone along among angel angle anime april armed asked audio audit avoid baker bands banks based basic beach bears beast began begin being below birds birth black blank blind block blogs blues board boats bonds bonus bound boxes brain brand bread break brief bring broad brown build built busty buyer bytes cable candy cards cause chain chair chart cheap chest chief child chips claim clean clear clips close clubs coast codes coins comes could count court cover craft crash crazy cream crime crown daily dance dates deals death delay delta depth diary dicke dirty doing doubt draft drawn dream drink drive drugs dutch early earth ebony eight email empty enjoy entry equal exact exist extra faces facts faith false fiber field fight filed files films final finds firms first fixed flags flash focus folks force forms forth forum found frame fraud fresh front fruit funds games ghost giant gifts girls given gives globe goals grace grade grand grant graph great group grove grown guard guest guide hairy hands heads heard heart heavy helps holds homes horse hotel hours house human humor icons ideal ideas image index items joint jokes judge kinds kings knows labor lakes lands large laser later latin layer leads learn least light lines links lived lives loans lodge logic login loved lower lucky lunch magic major maker makes march marks match maybe mayor means meant media metal metro micro might miles minor mixed model modes money month moral mount mouse mouth moved moves movie multi music naked named names newly night noise north noted notes novel nurse ocean often older opens opera other owned owner pages paint panel pants parks parts party patch pearl phase phone piano picks pilot place plain plane plans plant plate plays point poker ports pound power price pride prime prize proud prove pulse query quest quick quiet quite quote radio raise range rapid rated rates ratio reach ready reply rhode ridge right rings roads roman round route royal rules saint saved scale scope score setup shape share sharp shift shirt shock short shown sight since slide smart smile smith smoke solar solid solve sound south space speak spend spent split sport spray stage stand stick stock stone store storm story strip study style sugar suite super table taken takes talks taxes teach teams terms thank their thick thing think third those throw tiger times today tones topic touch tough tours tower towns track trade trail train trans trend trial tried trips truck truly turns twice types ultra under units until urban usage using valid value video views vinyl virus vista vital voice votes wales wants waste watch water while white whole whose width wings woman women words works world worse worst worth would wrong wrote yards years yield young yours youth""".split()


jotto([['close', 2], ['could', 3]]) → ['child', 'count', 'court', 'lucky', 'lunch', 'sound', 'touch', 'world']
jotto([['learn', 0], ['latin', 0]]) → ['focus', 'shock']
jotto([['codes', 1], ['empty', 1], ['ratio', 0]]) → ['lucky']

...Save, Compile, Run (ctrl-enter)

def jotto(turns):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 492 Post-solution available

Copyright Nick Parlante 2017 - privacy