First page Back Continue Last page Overview Graphics

Exercise

Write a function with a 2-dimensional field and a row and column positon as parameters. The field (board) is filled with 0's and 1's. The function shall return the number of neighbours of the position.

0

0

0

0

0

0

0

0

0

1

1

0

0

0

1

0

0

0

0

0

0

1

1

0

0

1

1

0

1

0

1

0

0

1

1

1

0

0

0

0

0

1

0

0

1

0

1

0

0

0

1

1

1

1

0

0

0

0

1

1

1

1

0

0

0

1

1

0

0

0

0

0

0

0

0

0

0

0

0

0

Number of neighbours of the green field: 4