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:

  1. The function locate_x(array) will receive a 2D list as its parameter.
  2. Return the coordinates [row, column] of the '1' in the list.
  3. 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:

CreatedNov 8, 2023
Warriors Trained7
Total Skips0
Total Code Submissions16
Total Times Completed7
Python Completions7
Total Stars1
% of votes with a positive feedback rating25% of 6
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes4
Total Rank Assessments5
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • JakeRigney Avatar
Ad