Lecture07-CodeBreaker-part1-3pp

Append0size print mc mc for i in range0size

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: 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 defini:on is o=en vague, with many parts that can be solved in many different 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 refinement design refine informal outline iterate informal design implementa:on refine iterate more formal design refine 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

Ask a homework question - tutors are online