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

Stats:

CreatedJul 2, 2016
PublishedJul 2, 2016
Warriors Trained3833
Total Skips41
Total Code Submissions6847
Total Times Completed2274
JavaScript Completions1917
C Completions155
Julia Completions13
CoffeeScript Completions8
Python Completions231
Total Stars45
% of votes with a positive feedback rating93% of 376
Total "Very Satisfied" Votes332
Total "Somewhat Satisfied" Votes39
Total "Not Satisfied" Votes5
Total Rank Assessments7
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • user4386369 Avatar
  • joh_pot Avatar
  • Chrono79 Avatar
  • Souzooka Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • TheMainCoder Avatar
  • akar-0 Avatar
  • farhanaditya Avatar
  • XoRMiAS Avatar
  • LosBlobbos Avatar
  • saudiGuy Avatar
Ad