Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Some structured programming design techniques: [ A ] Your S 1 ( for Game 1 ) may be defined as follows: # Nice to show
Some structured programming design techniques:
A Your Sfor Game may be defined as follows:
# Nice to show row index to and column index to for readability of your code
S # Game
# column index:
# Python row Users row
#
#
#
#
#
#
#
#
# Python column
# Users column
B Your main program may have the following code to drive your game
n # line number for each separation line for readability
print
printn;nn;
printYour game is as follows:
showGameS # to print x game board
print
printn;nn;
printYour game : # show the check result
checkGameS # to check rowscolumnssquares Total checkings.
print
printn;nn;
You may have similar code to drive your game to
C Your checkGame function must call the following functions:
RowOKS row to check row: through meaning Row through from users view
ColumnOKS column to check column: through meaning Column through from users view
SquareOKS square to check square: through meaning Square through from users view
D Your checkGame function may look as follows:
def checkGameS: # check game board S for rows, columns, squares
countBad # count how many problems being detected
for r in range: # rows check with r to
if not RowOKS r: # r to from computers view
printRow r has a problem." # Row to from users view
countBad # increment countBad by
for c in range: # columns check: to actually they mean column to for user.
# more your coding here ################### if not ColumnOKS c:
for q in range: # squares check: to actually they mean square to for user.
# more your coding here ################### if not SquareOKS q:
if countBad : # perfect game since nothing is bad
printCongratulations You won the game."
E Your RowOK function may look as follows:
def RowOKS r: # check Row r in S board is OK or not
goodlist # a perfect list of thru sorted order
slist Sr # get row r which can be or
clist # We must make a real copy of the original source list to avoid changing it here.
for element in slist:
clist.appendelement # make a real copy to avoid side effect to the original x array
clist.sort # sort the list before comparing with goodlist
return clist goodlist # true means OK for row r in S since they are equal
# end of RowOK
Your ColumnOKS c and SquareOKS q functions are similar to RowOKS r function.
F How to define Slist to be Square
SlistSSSSSSSS
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started