| Bytes | Lang | Time | Link |
|---|---|---|---|
| 105 | AWK | 250318T181022Z | xrs |
| 066 | jq | 230819T163146Z | GammaFun |
| 006 | Jelly | 230818T141411Z | The Thon |
| 068 | Ruby | 230820T051035Z | Jonah |
| 020 | J | 230818T162634Z | Jonah |
| nan | K ngn/k | 230818T150707Z | doug |
| 072 | Python | 230818T123614Z | The Thon |
| 049 | Excel | 230819T053711Z | Jos Wool |
| 057 | Retina | 230818T183326Z | Neil |
| 055 | sclin | 230818T172551Z | Mama Fun |
| 082 | R | 230818T162342Z | pajonk |
| 008 | Japt R | 230818T161340Z | Shaggy |
| 079 | Ruby | 230818T155203Z | Jordan |
| 004 | Canvas | 230818T125316Z | Kevin Cr |
| 006 | 05AB1E | 230818T123201Z | Kevin Cr |
| 069 | JavaScript ES6 | 230818T120331Z | Arnauld |
| 007 | Charcoal | 230818T120132Z | Neil |
| 007 | Thunno 2 N | 230818T120000Z | The Thon |
| 005 | Vyxal | 230818T114047Z | lyxal |
AWK, 105 bytes
{for(;i++<$1;)k=split(i,b[i],X);for(k++;k-->1;print"")for(i=0;i++<$1;)printf(b[i][k]==""?" ":b[i][k])" "}
jq, 68 66 bytes
-2 bytes with a better use of range
[range(.)+1|@sh/""]|transpose|map(map(.//" ")|join(" "))|reverse[]
Attempt This Online!
Attempt This Online!
[
range(.) + 1 # `range` generates 0 to n - 1; add 1
| @sh / "" # Since numbers do not have spaces or special characters,
# `@sh` behaves the same as `@text`/`tostring`.
# `/ ""` splits into an array of characters
] # `[ ... ]` collects values into an array
| transpose # transpose, filling missing values with null.
| map(
map(.//" ") # replace null with space
| join(" ") # join on spaces
)
| reverse[] # most-significant digits last.
Jelly, 6 bytes
Ṿ€z⁶ṚG
-2 thanks to @UnrelatedString
Explanation
Ṿ€z⁶ṚG # Main link - argument n
€ # To each number in the range [1..n]:
Ṿ # Convert it to a string
z⁶ # Transpose using filler space
Ṛ # Reverse this list of lists
G # Format as a grid
# (join each on spaces, then newlines)
Ruby, 68 bytes
->n{(0...s=n.to_s.size).map{|i|(0..n).map{_1.digits[i-s]||" "}*" "}}
Inspired by Jordan's ruby answer, but different enough to merit a new post.
J, 25 23 20 bytes
1j1#"#.0|.@|:1":@+i.
-3 thanks to doug!
1 ... +i.1...n":@Each of them formatted as a string0|.@|:Transposed and reversed1j1#"#.Add the space padding
K (ngn/k), 40 30 20 bytes
{" "/'|+(#$x)$$1+!x}
-10 : more straightforward (less fun?)
-10 : Actual golfing courtesy of @coltim and @bstrat
Python, 72 bytes
n=input()
*map(print,*(f'{j+1:<{len(n)}}'[::-1]for j in range(int(n)))),
-1 thanks to @Arnauld (by switching to Python 3.8)
-5 thanks to @c-- (by using f-strings)
-12 thanks to @loopy walt (by using map rather than a for loop)
Excel, 49 bytes
=MID(SEQUENCE(,A1),1+LEN(A1)-SEQUENCE(LEN(A1)),1)
Input in cell A1.
Retina, 57 bytes
.+
*¶
¶
$^$.>`#¶#¶
P^`.+
N$`.
$.%`
¶
~L$`#+
L`.{$.&}
A`#
Try it online! Explanation: Based on my golf to @TwiNight's answer to Enklactify these strings to transpose the text.
.+
*¶
¶
$^$.>`#¶#¶
Create a range from 1 to the input, but with the digits reversed, and each line padded with a #, and the lines separated by a line with just a #.
P^`.+
Left pad everything with spaces so that it lines up.
N$`.
$.%`
Sort all characters by their column index.
¶
~L$`#+
L`.{$.&}
Complete the transposition by joining everything together and then splitting by the number of #s.
A`#
Remove the final line, which will always be the #s.
sclin, 55 bytes
;1+ I>a10X>b tpose _`"_`\" \"rep +` ; tk _` w>< n>o"map
Try it here! Takes input from the second line.
For testing purposes:
;1+ I>a10X>b tpose _`"_`\" \"rep +` ; tk _` w>< n>o"map
20
Explanation
Prettified code:
; 1+ I>a 10X>b tpose _` ( _` " "rep +` ; tk _` w>< n>o ) map
Assuming input n:
; 1+ I>arange[1, n]10X>bdigitize (literally "convert each to base-10 digits")tpose _`transpose, reverse resulting lines(...) mapmap over each line..._` " "rep +` ; tk _`left-pad with spaces to length n_`reverse" "rep +`concatenate to infinite list of spaces; tktake first n elements_`reverse again
w>< n>ojoin with space and output
The (current) lack of string manipulation commands present in sclin makes it a tad unwieldy for string challenges...
R, 82 bytes
\(n)write(t(Reduce(cbind,strsplit(format(paste(1:n),j="l"),""))[nchar(n):1,]),1,n)
Ruby, 79 bytes
->n{(1..n).map{d=_1.digits
[" "]*(n.to_s.size-d.size)+d}.transpose.map{_1*" "}}
Canvas, 4 bytes
R↶ *
Explanation:
R # Push a list in the range [1, (implicit) input-integer],
# and implicitly print each integer on a separated newline to the Canvas
↶ # Rotate the entire Canvas 90 degrees counterclockwise
* # Join each character on each line of the Canvas with a space delimiter
05AB1E, 6 bytes
L€SζR»
Explanation:
L # Push a list in the range [1, (implicit) input-integer]
€S # Map each integer to a list of digits
ζ # Zip/transpose; swapping rows/columsn,
# with a space character to fill unequal length rows
R # Reverse this list of lists
» # Join each inner list by spaces, and then each string by newlines
# (after which the result is output implicitly)
JavaScript (ES6), 69 bytes
Expects the input number as a string.
f=(n,d=0,i=n)=>i?f(n,d,i-1)+(`${i}`[d]||' ')+' ':n[++d]?f(n,d)+`
`:''
Charcoal, 7 bytes
↑IEN⟦⊕ι
Try it online! Link is to verbose version of code. Explanation:
N Input as a number
E Map over implicit range
ι Current value
⊕ Incremented
⟦ Make into sublist (causes the output to be double-spaced)
I Cast to string
↑ Print rotated 90°
Thunno 2 N, 7 bytes
RðƬrðȷj
Explanation
RðƬrðȷj # Implicit input
RðƬ # Transpose [1..input], filling with spaces
rðȷj # Reverse and join each on spaces
# Implicit output, joined on newlines
Vyxal, 40 bitsv2, 5 bytes
ɾ∩Ṙ⁋øɽ
I honestly don't know how people find these obscure string overloads that I can never seem to remember.
Explained
ɾ∩Ṙ⁋øɽ
ɾ∩ # Transpose the range [1, input], treating digits as columns.
Ṙ⁋ # Reverse that, and join each sublist on spaces. Then, join that on newlines.
øɽ # Right align that. I honestly don't know why this works. It just does.
💎
Created with the help of Luminespire.