Question: can you help me with modify section function:modify _ section ( str , str , int, int ) - > str The first parameter represents
can you help me with modify section function:modifysection
str str int, int str
The first parameter represents the game state, the second parameter is the move to be applied to the string, the third parameter is the section number of the section to be modified, and the fourth parameter is the section length.
You may assume the move will be one of ROTATE or SWAP the str value representing each can be seen in the constants provided for you at the top of the starter code and that the third parameter is a valid section number.
This function will return a new string that reflects the updated game state after applying the given move to the specified section. For example, the function call modifysectionteerkocrlkaedef modifysectiongamestate: str move: str sectionnum: int, sectionlength
: int str:
Given a scrambled string, move, section number, and section length,
return a new string that reflects the updated game state after applying
the move to the specified section
modifysectionteerkocrlake 'SWAP',
'teerrocklkae'
modifysectionbtuterfly 'SWAP',
'butterfly'
modifysectionockrhillR
'rockhill'
start getsectionstartsectionnum, sectionlength
end start sectionlength
if move SWAP:
newgamestate gamestate:start gamestateend
gamestatestart:end gamestatestart: gamestateend:
elif move ROTATE:
newgamestate gamestate:start gamestateend : start:
gamestatestart gamestateend:
else :
newgamestate gamestate
return newgamestate
however neither swap or rotate seems to work pls help as asap with right code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
