I'm very new to programming and I'm trying to solve this problem in R.
A snail lives in the centre of an 11 x 11 matrix at co-ordinates [6,6] and he wants to travel N number of spaces away from his house. He can only move adjacent to the square he is currently in (left, right, up and down) and if he is at the border of the matrix then he stops where he currently is. Return a matrix featuring the number of times the snail was sighted in each square during his adventure using the runif()
function.
The function will look something like this as input: new_snail_house(N)
Any help on where to start would be useful, I know roughly the rule on how to move the snail:
Up = [i, j-1]
Down = [i, j+1]
Left = [i-1, j]
Right = [i+1, j]
I don't have a clue on how I would use this though and how I would use the runif()
function to get the number of sightings. Thanks in advance!