0

Could any of you guys help me with this code?I still fail test case 4 in 2D map code challenge.

https://code.sololearn.com/cGkcPN4tcB5f/?ref=app You're given a representation of a 5x5 2D map, and if you can only move left, right, up, or down, determine how many moves you would have to make to get between two points on the map. Task: Determine the total number of moves that are needed between two points on a map. The points that you move between are marked with a P and the spaces in between are marked with X. Input Format: A string that represents the 2D space starting at the top left. Each level from top to bottom is separated by a comma. Output Format: An integer that represents the total number of moves that you had to make. Sample Input: XPXXX,XXXXX,XXXXX,XXXPX,XXXXX Sample Output: 5

14th Feb 2023, 8:52 AM
Killiam Chances
Killiam Chances - avatar
1 Odpowiedź
+ 4
Save code and share link.. That helps to debug easily.. Is it code coach task or lesson task..? Add specific lesson number pls.. edit: @Notify after any edit! Killiam Chances Description states you can move left, right, up, down but your code works for farward way only.. left moves not considering. ex: b = 0, a = 4 then b-a is -4 , so try applying absolute method.....
14th Feb 2023, 9:25 AM
Jayakrishna 🇮🇳