Closed tinoism closed 5 years ago
Just realized that it wouldn't compile... Although the intuition about having the negative index is correct, in rust we annotate the negative indices by adding the length of the array. For instance, "negative indexes like -1 and -2 get added to the length of the slice to become real indices, like len - 1
and len - 2
" as indicated in this issue.
The function in
live_neighbor_count
of Game of life should iteratedelta_*
from[-1, 0, 1]
instead of from[self.height - 1, 0, 1]
and[self.width - 1, 0, 1]
.