P
P
Petesso2015-05-23 15:18:02
JavaScript
Petesso, 2015-05-23 15:18:02

How to find the bounds of a 2D array?

There is a half-two-dimensional array with a curved structure, you need to find its x and y boundaries in the form of ranges. That is, as a result, the json array below should look like " x : from -83 to 194, and y : from 0 to 214"

{"0":["2","2","2","2"],
"1":["2","0"],
"28":["0","0","0","0"],
"29":["0","2"],
"30":{"3":"2","0":"2","14":"2","6":"1"},
"-2":{"8":"2","2":"1","3":"1"},
"36":{"27":"2","15":"1","16":"1"},
"-83":{"67":"2"},
"194":{"214":"2"},
"178":{"192":"2"},
"127":{"145":"2"},
"55":{"147":"2"},
"47":{"21":"1"},
"40":{"19":"1"},
"37":{"19":"1"},
"65":{"17":"1"}}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-05-23
@Petesso

jsfiddle.net/v8tjmwz9/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question