I really don't know what am I missing in my code and how to fix it. Please help me fix it! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I really don't know what am I missing in my code and how to fix it. Please help me fix it!

It's a problem in the community section named "2D Map". Here's my code:----------> https://code.sololearn.com/crOw323MPxvz/?ref=app

24th Jul 2023, 7:22 AM
Vaibhav Pandey
2 Answers
+ 5
Vaibhav Pandey, not so easy to understand how the logic of the code is working. so i did some tests with various inputs, and i found a constellation of the input, where the result is not correct. when using this input: 'XXXXX,XXXXX,XXXXX,XXXXP,XXXXP'. the result should be 1, because it is just one step downwards. your current code outputs 0. it looks like the result is not correct, if "P" has the same position / index in the substring. may be this can help you to find the bug.
24th Jul 2023, 4:37 PM
Lothar
Lothar - avatar
+ 1
Lothar Thank you bro I just added a new line in the first for loop and the bug is fixed.
25th Jul 2023, 4:46 AM
Vaibhav Pandey