{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Give feedback check guess give feedback false correct

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2 4 13 ­10 ­02 Iterate and refine • Now we need to count the le<ers which are out of place • We sMll need to mark the le<ers as we use them, so we don’t count them twice! 0 1 2 3 copy = A B F # 0 1 2 3 copy = A B F # ✔ guess= F A A # 0 1 2 3 guess= F A A # X 13 CMPUT174  ­ ­ Design & Problem Solving …Iterate and refine • And count the number of le<ers which are correct but out of place   Now using lists! #now count the letters that are out of place outOfPlace=0 for letter in guessLst: if letter!= “#” position=0 found=False while ((position <4) and (found is False)): if letter == codeLst[position] outOfPlace=outOfPlace+1 codeLst[position]=“#” found=True position=position+1 14 CMPUT174  ­ ­ Design & Problem Solving Code breaker game Start • InteracMve program while loop Ask first guess Start check guess Ask first guess TRUE FALSE Keep Going? give feedback check guess give feedback FALSE correct guess? TRUE refine print hurray! Ask new guess check guess TRUE print hurray! Ask new guess FALSE right guess? print sorry! Stop ch...
View Full Document

{[ snackBarMessage ]}