on encountering end of a row, from where will he starts i mean from the left or the right of the next row
further meeting an blocked(#) from where he will start his next move
and at which point he is considered out of the puzzle and if the last one is * that is magical bean then do we need to add 5 in his strength or not
π‘ Piyush and Magical Park
- On encountering end of a row piyush will start from next row from 0th column.
- Further meeting an blocked(#) he will begin from 0th column of next row.
- He is considered out of the puzzle if in the last row he encounters # or he reaches the bottom right cell.
- If the last one is * that is magical bean then you have to add 5 to his strength.
If you got all your answers then mark the doubt as resolved.
when he encounter a"." then s-=2 after that do we need to subtract one from his strength as his each step costs him one unit strength so in total on encountering a β.β his strength will be reduced by 3 and same in case of * his strength is increased by 4 as one is reduced for this stepβ¦https://ide.codingblocks.com/s/172170 i m doing it this way but answer is not correct
2 test cases are failing with this code
Hi @Learning_bunny
Yes we need to subtract one from his strength as his each step costs him one unit strength only if he is not on the last column of a row. That is for j==m-1 we need not subtract 1. In your code there are few changes you need to consider :
- in the if condition it should be s<k at line 15 (EQUAL SIGN NOT REQUIRED)
- sβ; at line 12 is not needed.
- at line 20 it should be s-=2;
- add one if condition to decrement his strength when he is not in the last column.
if(j!=m-1){
sβ;
}
Here is your corrected code :
If you got all your answers then mark the doubt as resolved.