Skip to main content
added 121 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 79 6969 66 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)%h*w for q in range(9)if q-4]

Try it online!Try it online!

3 bytes gifted by Neil noting that (x*w)%(h*w)==((x)%h)*w==(x)%h*w.

0-indexed solution.

Python 2, 79 69 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q-4]

Try it online!

0-indexed solution.

Python 2, 79 69 66 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)%h*w for q in range(9)if q-4]

Try it online!

3 bytes gifted by Neil noting that (x*w)%(h*w)==((x)%h)*w==(x)%h*w.

0-indexed solution.

added 23 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 79 69 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q-4]

Try it online!

0-indexed solution.

Python 2, 79 69 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q-4]

Try it online!

Python 2, 79 69 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q-4]

Try it online!

0-indexed solution.

added 13 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 79 7069 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q!=4]-4]

Try it online!Try it online!

Python 2, 79 70 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q!=4]

Try it online!

Python 2, 79 69 bytes

lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)*w%(h*w)for q in range(9)if q-4]

Try it online!

added 13 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39
Loading
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39
Loading