Lecture07-CodeBreaker-part2-3pp

E the same as in the code 0 1 2 3 code a b f b check

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: • Most people got Step 1 and checking for valid guess lengths in Step 2 • Checking for a valid guess was harder • Some review comments… 4 CMPUT174  ­ ­ Design & Problem Solving Iterate and refine • Giving feedback • First: Count how many posiMons have the right le<er (i.e., the same as in the code) 0 1 2 3 code = A B F B check guess guess= F A A B 0 1 2 3 give feedback Keep Going? Ask new guess ✔ check guess 5 CMPUT174  ­ ­ Design & Problem Solving Iterate and refine • Second: Go over the unmatched posiMons, and check if they match any posiMon in the code • QuesBon: how do we “remember” that posiMon 3 has been counted already?   We have to ignore it when finding out of place le<ers! 0 1 2 3 code = A B F B ✔ guess= F A A B 0 1 2 3 CMPUT174  ­ ­ Design & Problem Solving 6 2 13 ­10 ­02 Iterate and refine • How do we “remember” that posiMon 3 has been counted already? • One simple soluMon: Mark the posiBons as we use them 0 1 2 3 code = A B F B 0 1 2 3 code = A B F # ✔ ✔ guess= F A A B 0 1 2 3 guess= F A A # 0 1 2 3 7 CMPUT174  ­ ­ Design & Problem Solving Iterate and refine • One simple soluMon: Mark the posiBons as you check them 0 1 2 3 copy = A B F # ✔ guess= F A A # 0 1 2 3 • OK, s...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online