Use CartesianIndices instead of tuples

This commit is contained in:
Dimitri Lozeve 2020-02-23 14:39:12 +01:00
parent 3a2dc40ce5
commit c5c1391679

View file

@ -8,9 +8,7 @@ function neighbourindices(mask::Matrix, idx::Int)::Vector{Int}
end
m, n = size(mask)
j, i = divrem(idx - 1, m)
i += 1
j += 1
i, j = Tuple(CartesianIndices(mask)[idx])
indices = [(i, j-1), (i, j+1), (i-1, j), (i+1, j)]
# cells filled with 0 are not part of the garden
cartesianindices = [