7 kyu
'x' marks the spot.
1,917 of 2,274user4386369
Description:
Task:
Given a two dimensional array, return the co-ordinates of x
.
If x
is not inside the array, or if x
appears multiple times, return []
.
The co-ordinates should be zero indexed in row-major order.
You should assume you will always get an array as input. The array will only contain 'x'
s and 'o'
s.
Examples
Input: []
Return an empty array if input is an empty array => []
Input: [
['o', 'o'],
['o', 'o']
]
Return an empty array if no x found => []
Input: [
['x', 'o'],
['o', 'x']
]
Return an empty array if more than one x found => []
Input: [
['x', 'o'],
['o', 'o']
]
Return [0,0] when x at top left => [0, 0]
Input: [
['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'],
['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'],
['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'],
['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'],
['o', 'o', 'o', 'o', 'o', 'o', 'x', 'o'],
['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o']
]
Return [4,6] for the example above => [4, 6]
Fundamentals
Arrays
Matrix
Similar Kata:
Stats:
Created | Jul 2, 2016 |
Published | Jul 2, 2016 |
Warriors Trained | 3833 |
Total Skips | 41 |
Total Code Submissions | 6847 |
Total Times Completed | 2274 |
JavaScript Completions | 1917 |
C Completions | 155 |
Julia Completions | 13 |
CoffeeScript Completions | 8 |
Python Completions | 231 |
Total Stars | 45 |
% of votes with a positive feedback rating | 93% of 376 |
Total "Very Satisfied" Votes | 332 |
Total "Somewhat Satisfied" Votes | 39 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 7 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |