πŸ’‘ Piyush and Magical Park

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

Hi @Learning_bunny

  1. On encountering end of a row piyush will start from next row from 0th column.
  2. Further meeting an blocked(#) he will begin from 0th column of next row.
  3. He is considered out of the puzzle if in the last row he encounters # or he reaches the bottom right cell.
  4. 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 :

  1. in the if condition it should be s<k at line 15 (EQUAL SIGN NOT REQUIRED)
  2. s–; at line 12 is not needed.
  3. at line 20 it should be s-=2;
  4. 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.