Retired
Mr. Bernard's lost cookie (retired)
Description:
Mr. Bernard's Lost Cookie
Background:
In a 2D grid representing Mr. Bernard's pantry shelves, a special cookie is hidden. It is marked with a '1' in a sea of '0's indicating empty shelves.
Challenge:
Your mission is to write a function locate_x
that finds the cookie's coordinates in the 2D list.
Instructions:
- The function
locate_x(array)
will receive a 2D list as its parameter. - Return the coordinates
[row, column]
of the '1' in the list. - If the list is empty or no '1' is present, return
False
.
Examples:
locate_x([
[0, 0, 0],
[1, 0, 0],
[0, 0, 0]
]) # Should return [1, 0]
locate_x([
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 0]
]) # Should return [2, 2]
locate_x([]) # Should return None
Similar Kata:
Stats:
Created | Nov 8, 2023 |
Warriors Trained | 7 |
Total Skips | 0 |
Total Code Submissions | 16 |
Total Times Completed | 7 |
Python Completions | 7 |
Total Stars | 1 |
% of votes with a positive feedback rating | 25% of 6 |
Total "Very Satisfied" Votes | 1 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 5 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |