From c5c13916792f02e22881c728144ce1956ee798c5 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Sun, 23 Feb 2020 14:39:12 +0100 Subject: [PATCH] Use CartesianIndices instead of tuples --- src/optim.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/optim.jl b/src/optim.jl index 03cbbeb..0f65f89 100644 --- a/src/optim.jl +++ b/src/optim.jl @@ -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 = [