Revision f3112fe4-ab5c-403e-ab85-b714be362dbc - Code Golf Stack Exchange

# [R], 125 bytes

<!-- language-all: lang-r -->

 function(x,i,m=array(seq(prod(x)),x),n=rbind(m,m,m),o=cbind(n,n,n),p=which(m==i,T)+x-1,r=o[p[1]:(p[1]+2),p[2]:(p[2]+2)])r[-5]

[Try it online!][TIO-jjr9c9ui]

[R]: https://www.r-project.org/
[TIO-jjr9c9ui]: https://tio.run/##PcoxDsIwDAXQnVN0tFV3SNoyIHwLtqhDCVTN0KQYEOH0IWkl9CXr/S9LmqpzU6Xp7e3LBQ@RHC08ioxfeN4fsEq4QUSkiORZrs7fYKEcpMB2q55ykFb@zM7OsDA7umAdG0XCwaxGDScot9b5y@it6dIGFNP0Q5rAQkcd0hEPf6vdfbHe3eaR2t2qWGH6AQ "R – Try It Online"
1-based.

Input is `[w, h], i` because R populates arrays column first.

Makes the array and then "triples" it row- and column-wise. Then locate `i` in the original array and find it's neighborhood. Output without `i`.

AltStyle によって変換されたページ (->オリジナル) /