Piyush & Magical Park

The code is failing 1 test case. What’s the flaw in the code?

Hello @namanmanchanda09,

Consider the testcase:
4 4 5 10
. * * *
* # . .
* * . .
* # * *
Expected Output:
Yes
31
Your Output:
Yes
17

Considerations
2.1. Initially, the strength is S
2.2. if Piyush encounters *, strength increases by 5
2.3. If he encounters ‘.’, strength decreases by 2
2.4. Piyush requires strength of 1 for every step
2.5. Piyush can shift immediately from last of one row to the start of next one without loss of any strength(i.e. when he would change the row from the last element of the row)
2.6. If he changes the row after encountering the ‘#’, then he loses 1 strength for changing the row.
2.7. he needs at least a K amount of strength to reach home.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

The test case isn’t clear due to some indentation and different kind of symbols. Can you send the test case again?

46%20PM
This is what that’s visible.

Sure @namanmanchanda09,

I have modified it, you can check.
If you need any help in correcting the code, let me know.

I am not able to understand how come this test case
4 4 5 10
. * * *

  • . .

    • . .
  • * *

results to 31.

Can you tell the value of S at every index? That might help.

I have understood it. Thank you.

@namanmanchanda09 Should i help?

1 Like

No I have got it. Thanks again.

Great @namanmanchanda09,

Please, mark this doubt as resolved.

Have already marked it resolved.