Lecture07-CodeBreaker-part2-3pp

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

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

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 &amp; Problem Solving Iterate and reﬁne • Giving feedback • First: Count how many posiMons have the right le&lt;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 &amp; Problem Solving Iterate and reﬁne • 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 ﬁnding out of place le&lt;ers! 0 1 2 3 code = A B F B ✔ guess= F A A B 0 1 2 3 CMPUT174  ­ ­ Design &amp; Problem Solving 6 2 13 ­10 ­02 Iterate and reﬁne • 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 &amp; Problem Solving Iterate and reﬁne • 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