Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

r - 我如何解决和解决R中的这个蜗牛冒险编程问题(How do I approach and solve this snail adventure programming problem in R)

I'm very new to programming and I'm trying to solve this problem in R.

(我是编程新手,正在尝试解决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.

(一只蜗牛生活在坐标为[6,6]的11 x 11矩阵的中心,他想离开家N个空间。)

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.

(使用runif()函数返回一个矩阵,该矩阵包含蜗牛在冒险期间在每个方块中被看见的次数。)

The function will look something like this as input: new_snail_house(N)

(该函数作为输入看起来像这样: 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.

(我对如何使用它以及如何使用runif()函数获取瞄准次数runif() 。)

Thanks in advance!

(提前致谢!)

  ask by flufenamic translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...