Connecting Values
Description:
Given a two-dimensional array of non negative integers arr
, a value val
, and a coordinate coord
in the form (row, column)
, return an iterable (depending on the language) of all of the coordinates that contain the given value and are connected to the original coordinate by the given value. Connections may be made horizontally, vertically, and diagonally. If the value of arr
at coord
is not equal to val
, return an empty iterable. The coordinates must include the original coordinate and may be in any order.
Examples:
With the following array:
[1,0,2,0,2,1]
[1,0,2,1,5,7]
[4,1,1,0,1,9]
With val 1
and coord (0, 0)
, the output should contain (the order doesn't matter and the actual data structure depends on the language):
[(2, 4), (2, 1), (0, 0), (2, 2), (1, 0), (1, 3)]
With value 2
and coord (0, 2)
:
[(0, 2), (1, 2)]
With value 0
and coord (0, 0)
, the output should be empty.
Similar Kata:
Stats:
Created | May 25, 2015 |
Published | May 25, 2015 |
Warriors Trained | 1146 |
Total Skips | 54 |
Total Code Submissions | 1389 |
Total Times Completed | 243 |
JavaScript Completions | 148 |
Python Completions | 81 |
Rust Completions | 17 |
Go Completions | 15 |
Total Stars | 25 |
% of votes with a positive feedback rating | 93% of 81 |
Total "Very Satisfied" Votes | 71 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 8 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |