Skip to main content
1 of 5
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 79 bytes

lambda h,w,i:[(i+j)%w+(i/w*w+k)%(h*w)for k in[-w,0,w]for j in[-1,0,1]if j or k]

Try it online!

Chas Brown
  • 9.8k
  • 1
  • 13
  • 39