{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture07-CodeBreaker-part1-3pp

# Append0size print mc mc for i in range0size

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: i in range(0,size): mC.append([0]*size) print mC mc= for i in range(0,size): mc.append([0]*size) print mC • The problem deﬁni:on is o=en vague, with many parts that can be solved in many diﬀerent ways # Multiply C = A x B i=0 while i < size: j=0 while j < size: sum = 0 k=0 while k < size: sum = sum + mA[i][k] * mB[k][j] k =k+1 mC[i][j] = sum j=j+1 i=i+1 # Print C print "\nMatrix C = A x B is:" i=0 while i < size: j=0 while j < size: print mC[i][j], j=j+1 print "\n", i=i+1 print "\n", 2 CMPUT174  ­ ­ Design & Problem Solving Design by itera=ve reﬁnement design reﬁne informal outline iterate informal design implementa:on reﬁne iterate more formal design reﬁne iterate formal code • Some people make a clear dis:nc:on between design and implementa=on (turning the design into code), but we can think of both tasks as steps in the same itera:ve process CMPUT174  ­ ­ Design & Problem Solving 3 1 13 ­10 ­01 Example: Codebreaker game • Two ­player game: the codemaker and the codebreaker   The game goes for a number of rounds   The codemaker chooses a paPern of four colored pegs; duplicates are allowed   The codebreaker tries to guess the paPern both in order and color   The codemaker provides feedback a=er each round by saying the number of pegs tha...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online