Skip to main content
42 bytes
Source Link
Robin Ryder
  • 15.6k
  • 2
  • 24
  • 70

R, 4342 bytes

function(w,h,a=1)cbind(a<-1:(h*w-1))cbind(a,a+w^!a%%w)

Try it online!Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d=1 if i is a multiple of w, and d=0 otherwise.

R, 43 bytes

function(w,h,a=1:(h*w-1))cbind(a,a+w^!a%%w)

Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d=1 if i is a multiple of w, and d=0 otherwise.

R, 42 bytes

function(w,h)cbind(a<-1:(h*w-1),a+w^!a%%w)

Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d=1 if i is a multiple of w, and d=0 otherwise.

deleted 10 characters in body
Source Link
Robin Ryder
  • 15.6k
  • 2
  • 24
  • 70

R, 43 bytes

function(w,h,a=1:(h*w-1))cbind(a,a+w^!a%%w)

Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d is 1d=1 if i is a multiple of w, and d is 0d=0 otherwise.

R, 43 bytes

function(w,h,a=1:(h*w-1))cbind(a,a+w^!a%%w)

Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d is 1 if i is a multiple of w, and d is 0 otherwise.

R, 43 bytes

function(w,h,a=1:(h*w-1))cbind(a,a+w^!a%%w)

Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d=1 if i is a multiple of w, and d=0 otherwise.

Source Link
Robin Ryder
  • 15.6k
  • 2
  • 24
  • 70

R, 43 bytes

function(w,h,a=1:(h*w-1))cbind(a,a+w^!a%%w)

Try it online!

Creates the spanning graph

1-2-3
    |
4-5-6
    |
7-8-9

Node i is connected to node i+1 in general, or to node i+w if i is a multiple of w. This corresponds to a connecting node i to node i+w^d where d is 1 if i is a multiple of w, and d is 0 otherwise.