Draft
2D Player Movement
Description:
You're making a basic 2D game, and you're trying to write a simple alogrithm that determines if the user can move the player in any given direction.
Given a 2D Array of binary digits (arr)
, and the players current position (pos)
return True
if the player can move up, down, left, and right.
else return False
.
A 0
indicates the player can move to that position while a 1
indicates a player can NOT move to that position.
Example:
arr = [[0, 1, 0, 0, 1],
[1, 1, 0, 1, 1],
[0, 0, 1, 0, 0],
[0, 1, 0, 0, 1],
[1, 0, 0, 1, 0]]
pos = (3,3)
This example should return False, as the player can move up or left, but the player can NOT move down or right.
The player can't move through an edge. You'll need to handle potential listIndex errors for edge positions.
The value of the players current position is irrelivent.
Arrays
Lists
Algorithms
Fundamentals
Similar Kata:
Stats:
Created | Feb 24, 2019 |
Warriors Trained | 6 |
Total Skips | 0 |
Total Code Submissions | 6 |
Total Times Completed | 4 |
Python Completions | 4 |
Total Stars | 1 |
% of votes with a positive feedback rating | 50% of 2 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 2 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |