A ragged matrix, is a matrix that has a different number of elements in each row. Your challenge is to write a program in any favorable language to find the indices of all occurrences of target in the ragged matrix.
Input:
A list of ragged lists (can be empty) of positive integers and a target range e.g. 26-56
. The target range, given 2 positive integers. For languages that do not support this type of list, you can input it as a string representation
You may assume that a<=b
Output:
If a number in the ragged list is within the range or equal to a
or equal to b
, output the index of the ragged list then the index of the number in that ragged list e.g. 0 4
- The 0
is the first ragged list in the input and the 4
is the index of the number in the first ragged list
Test cases:
[[[1,3,2,32,19],[19,2,48,19],[],[9,35,4],[3,19]],19-53]
->
[[0,3],[0,4],[1,0],[1,2],[1,3],[3,1],[4,1]]
[[[1,2,3,2],[],[7,9,2,1,4]],2-2]
->
[[0,1],[0,3],[2,2]]
You can choose to follow the output format above or output it in the following as well:
[[[1,3,2,32,19],[19,2,48,19],[],[9,35,4],[3,19]],19-53]
->
0 3 0 4 1 0 1 2 1 3 3 1 4 1
0-based and 1-based indexing is allowed
You can output your answers in any way as long as it is distinguishable what the indexes of the number and matrix are
You may assume the integers in the list are always positive and non-zero
This is code-golf, so shortest code wins!
a<=b
. Then why example is56-26
? \$\endgroup\$range
object in python? (e.g.range(26,57)
for26-56
) \$\endgroup\$ŒṪ
seems to be made for this challenge \$\endgroup\$