Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i have to create a code for my assignment . The first parameter represents a puzzle, the second represents a direction ( the value of
i have to create a code for my assignment The first parameter represents a puzzle, the second represents a direction the value of one of the constants UP DOWN, FORWARD and BACKWARD the third represents the guessed word, the fourth represents the row or column number, and the fifth represents the number of words left to be found before this guess. If this guessed word is found in this puzzle at this location row or column and in this direction, return the number of points earned for this guess. Otherwise, return Hint: you will need to call on several helper functions from above and from the starter code here are all the function codes that i have made and you need to use them def getcolumnpuzzle: str colnum: int str:
Return column colnum of puzzle.
Preconditions:
colnum number of columns in puzzle
puzzle is in the proper 'Where's that word? puzzle format
getcolumnabcd
efgh
ijkl
bfj
getcolumnabcd
efgh
ijkl
'aei'
puzzlelist puzzle.stripsplit
column
for row in puzzlelist:
column column rowcolnum
return column
def getrowlengthpuzzle: str int:
Return the length of a row in puzzle.
Preconditions:
puzzle is in the proper 'Where's that word? puzzle format
getrowlengthabcd
efgh
ijkl
getrowlengthab
cd
ef
return lenpuzzlesplit
def stringcontainstext: str text: str bool:
Return True if and only if text appears anywhere in text
stringcontainsabcbc
True
stringcontainsabccb
False
return text in text
# Implement the required functions below.
#
# We have provided the complete docstring but not the body! for the first
# function you are to write. Write a function body for the function
# getcurrentplayer and then follow the Function Design Recipe to produce
# complete functions for getwinner, getfactor, reverse, getrow, getpoints
# and checkguess. When you have completed all of these functions, run the
# file puzzleprogram.py to play the game!
def getcurrentplayerplayeroneturn: bool str:
Return 'player one' if and only if playeroneturn is True; otherwise,
return 'player two'.
getcurrentplayerTrue
'player one'
getcurrentplayerFalse
'player two'
if playeroneturn True:
return P
else:
return P
#YOU MIGHT BE ABLE TO SIMPLIFY THE BODY DESCRIPTION MORE AND THE RETURN
#STATEMENT
def getwinnerscoreofplayerone: int, scoreofplayertwo: int str:
Return PWINS if scoreofplayerone is greater than scoreofplayertwo, PWINS if scoreofplayertwo scoreofplayerone; otherwise, return TIE
getwinner
PWINS
getwinner
PWINS
getwinner
TIE
if scoreofplayerone scoreofplayertwo:
return PWINS
elif scoreofplayertwo scoreofplayerone:
return PWINS
else:
return TIE
def getfactordirection: str int:
getfactorFORWARD
getfactorBACKWORD
getfactorUP
getfactorDOWN
if direction 'FORWARD':
return FORWARDFACTOR #
elif direction 'BACKWORD':
return BACKWARDFACTOR #
elif direction UP:
return UPFACTOR #
else:
return DOWNFACTOR #
def reverseinputstring:str str:
Return a reversed copy of the inputstring
reverseanya
'ayna'
reversekaveh
'hevak'
reversejacqueline
'einleuqcaj'
if not inputstring:
return
return inputstring reverseinputstring:
def getrowpuzzle:str rownum:int str:
Return the letters in the corresponding rownum. The letters must be
in the same order as they appear in the puzzle. The first row is rownum
getrowabcd
efgh
ijkl
'efgh'
getrowabcd
efgh
ijkl
'ijkl'
#call on starter function getrowlength
rowlength getrowlengthpuzzle
startindex rownum rowlength
endindex startindex rowlength
return puzzlestartindex:endindex
def getpointsdirection:str wordsremaining:int int:
Return the number of points earned when the word is found in the
correct direction based on the wordsremaining.
getpointsFORWARD
getpointsBACKWARD
getpointsUP
getpointsDOWN
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started