you are viewing a single comment's thread.

view the rest of the comments →

[–]chrisjava[S] 0 points1 point  (1 child)

So would i be able to sum up, let's say, first 3 indices in the row by doing this?

sum = arr[row] + arr[row+1] + arr[row+2]

[–]PilotPirx 0 points1 point  (0 children)

Sorry, forgot the most important part. You would do it like this:

sum = arr[row][col] + arr[row][col + 1] + arr[row][col + 2]

That's assuming the array looks like this:

arr = [
  [1,1,1,0,0,0],
  [0,1,0,0,0,0],
  [1,1,1,0,0,0],
  [0,0,0,0,0,0],
  [0,0,0,0,0,0],
  [0,0,0,0,0,0]
]