Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defp largest_global_power(matrix) do
- max = {{nil, nil, nil}, nil}
- Enum.reduce(1..@grid_size, max, fn x, max ->
- Enum.reduce(1..@grid_size, max, fn y, max ->
- max_size = Enum.min([@grid_size - x, @grid_size - y])
- Enum.reduce(0..max_size, max, fn s, max ->
- square = Matrex.submatrix(matrix, x..(x + s), y..(y + s))
- tp = Matrex.sum(square)
- {_, max_tp} = max
- if is_nil(max_tp) or tp > max_tp do
- {{x, y, s}, tp}
- else
- max
- end
- end)
- end)
- end)
- end
Add Comment
Please, Sign In to add comment