Comments on Create a range grid
Parent
Create a range grid
This challenge is based on the i.
verb from J.
A range grid is basically a range of m × n
numbers fit into a rectangular grid with m
rows and n
columns.
A 2×3
range grid would be:
0 1 2
3 4 5
Challenge
Generate a range grid, given m
and n
. You can display it, or return an array.
This is code-golf
. Shortest answer in each language wins.
Ruby, 33 bytes ``` ->n,m{[(0 …
2y ago
BQN (CBQN), 10 bytes Anonymou …
2y ago
C (gcc), 59 bytes ``` C i; …
2y ago
[Python 2], 46 bytes …
2y ago
[Python 3], 49 bytes …
2y ago
Japt `-m`, 4 bytes VÆT° …
2y ago
MATL, 8 bytes ``` tp:qwPe! …
2y ago
Lua 5.4, 76 bytes ``` lua …
2y ago
Post
C (gcc), 59 bytes
i;f(m,n){while(i<m*n){putchar(i%n?32:13);putchar(48+i++);}}
-
m
is the number of rows. -
n
is the number of columns.
1 comment thread