0

Why don't my two codes pass all the test cases for the 2D Map code coach?

Here's the Cpp version (passes tests 1, 2 and 6): https://sololearn.com/compiler-playground/c7H2KAOM22BM/?ref=app And the Py code (just passes tests 1 and 2): https://sololearn.com/compiler-playground/cAJJ4KDyEbaL/?ref=app

5th Oct 2024, 12:34 PM
Calvin Jude
Calvin Jude - avatar
3 ответов
+ 2
Calvin Jude in the C++ code, its coordinate conversion is flawed. Hint: The comma makes 6 characters per row, not 5. In the Python code, you need to revise the if condition where it tests for the edge case when both Ps are in the same row. Both codes will pass after these minor corrections.
5th Oct 2024, 2:55 PM
Brian
Brian - avatar
0
2D MAP --------------- 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
5th Oct 2024, 12:36 PM
Calvin Jude
Calvin Jude - avatar
6th Oct 2024, 9:48 AM
Bob_Li
Bob_Li - avatar