| Bytes | Lang | Time | Link |
|---|---|---|---|
| 066 | Pure Bash no external utilities | 230722T185540Z | Digital |
| 077 | Ruby | 230722T193338Z | Level Ri |
| 267 | SQL | 230724T173936Z | 0V32F10W |
| 112 | Java | 230724T140457Z | Kevin Cr |
| nan | Vyxal | 230721T131209Z | lyxal |
| 016 | Jelly | 230724T132637Z | Lynn |
| 022 | 05AB1E | 230724T101445Z | Kevin Cr |
| 128 | BQN CBQN | 230723T171349Z | LeopardS |
| 097 | Kotlin | 230723T154353Z | Sally lo |
| 076 | Python 3 | 230723T153143Z | Sally lo |
| 099 | C clang | 230723T045354Z | Moderate |
| 122 | Excel ms365 | 230721T122751Z | JvdV |
| 069 | Python 3 | 230721T213906Z | xnor |
| 097 | Python | 230721T210152Z | SuperSto |
| 076 | Perl 5 | 230721T203248Z | Xcali |
| 019 | Jelly | 230721T201918Z | Jonathan |
| 060 | R | 230721T150121Z | Giuseppe |
| 067 | Retina | 230721T150609Z | Neil |
| 138 | Bash | 230721T120734Z | Thor |
| 025 | Charcoal | 230721T144540Z | Neil |
| 074 | JavaScript ES6 | 230721T112042Z | Arnauld |
| 021 | Thunno 2 N | 230721T112251Z | The Thon |
Pure Bash - no external utilities, 66
Thanks to @Nahuel Fouilleul for saving 10 bytes!
printf "`echo %3s{,,}{,,,}`\n" '' {0..10} $[{1..5}*{1,{0..50..5}}]
Ruby, 77 bytes
Improvements thanks to Dingus
q=*r=1..10;s=" "
1.upto(6){|i|puts" #{s} "+("%4d"*10)%q
q=r.map{|j|j*5*s=i}}
Ruby, 82 bytes
q=r=[*1..10];s=" "
1.upto(6){|i|puts (" #{s} "+"%4d"*10)%q
s=i;q=r.map{|j|j*i*5}}
SQL, Will never win 267
with C AS(SELECT 10 C UNION ALL SELECT C-1FROM C WHERE C-1>=0),M AS(SELECT 5 M UNION ALL SELECT M-1FROM M WHERE M-1>0),PS as(select C,M,C*M*5 PS from C cross join M)SELECT*FROM(SELECT*FROM PS)tbl PIVOT(max(PS)FOR C IN ([0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]))P
Try it here db<>fiddle
Explained...
--List Crystals 0-10
with Crystal AS (
SELECT 10 Crystal
UNION ALL
SELECT Crystal-1
FROM Crystal
WHERE Crystal-1>=0
)
--List Members 1-5
,Member AS (
SELECT 5 Member
UNION ALL
SELECT Member-1
FROM Member
WHERE Member-1>0
)
--Join Crystal and Member, Calc People Seconds
,PS as
(
select Crystal,Member,Crystal*Member*5 PS
from Crystal
cross join Member
)
--Pivot Maze
SELECT * FROM
(
SELECT *
FROM PS
) tbl
PIVOT(
max(PS)
FOR Crystal IN ([0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10])
) pvt
Java, 112 bytes
v->{var r="";for(int i=-1,j;i++<5;r+="\n")for(j=-2;j++<10;)r+=r.format("%4s",i<1?j<0?r:j:j<0?i:i*j*5);return r;}
Explanation:
v->{ // Method with empty unused parameter and String return-type
var r=""; // Result-String, starting empty
for(int i=-1,j;i++<5 // Loop `i` in the range (-1,5]:
; // After every iteration:
r+="\n") // Append a newline to the result-String
for(j=-2;j++<10;) // Inner loop `j` in the range (-2,10]:
r+=r.format("%4s", // Append the following with up to 4 leading spaces to the
// result-String:
i<1?i<j? // If it's the first row and column:
r // Append the result-String itself, which is still "" at
// this point
: // Else-if it's the first row, but NOT the first column:
j // Append `j`
:j<0? // Else-if it's the first column, but NOT the first row:
i // Append `i`
: // Else (it's neither the first row nor column):
i*j*5); // Append `i` multiplied by `j` multiplied by 5
return r;} // After the nested loops, return the result-String
Vyxal, 115 bitsv1, 14.375 bytes
5ƛ₀ʀ*5*J;₀ʀðppÞĠ
Explained
5ƛ₀ʀ*5*J;₀ʀðppÞĠ
5ƛ ; # To each number in the range [1, 5]:
₀ʀ* # Multiply it by the range [0, 10]
5* # Multiply that by 5
J # And prepend the number to the start of the list
₀ʀðp # The list [0, 10] with " " prepended
p # Put that list at the start of the list of lists from before
ÞĠ # Gridify, right-aligning and joining columns on spaces.
💎
Created with the help of Luminespire.
Jelly, 16 bytes
⁵Żð⁶;W;Gµ5×1;×þ5
ð⁶;W;Gµ [[" "] + a] + f(a), as a grid
where
⁵Ż a = [0…10]
5×1;×þ5 f(r) = table of [1]+(5×r) times [1…5]
05AB1E, 22 bytes
5LTÝδ*5*TÝšεNš}§3j»ð2ǝ
Should have been 21 bytes without the §, but unfortunately there is a bug in 05AB1E.
Explanation:
5LTÝδ* # Push a 0..10 by 1..5 multiplication table:
5L # Push a list in the range [1,5]
TÝ # Push a list in the range [0,10]
δ # Pop both lists, and apply double-vectorized:
* # Multiply the values together
5* # Multiply each value by 5
TÝš # Prepend list [0,10] to this matrix
ε } # Map over each row:
Nš # Prepend the 0-based map-index to the list
§ # (workaround: cast every integer to a string)
3j # Prepend leading spaces where necessary so each string is of length 3
» # Join each inner list of strings with space delimiter,
# and then each string with newline delimiter
ǝ # Replace the character
2 # at (0-based) index 2 (which is the first '0')
ð # with a space
# (after which the result is output implicitly)
BQN (CBQN), 128 bytes
This is definitely sub-optimal. I don't really know what I'm doing with this language.
•Out ¯1↓⥊(1↓˘∾˘⍉(/⟜" "∘(4-≠)∾⊢)¨•Fmt¨[↕6]∾⍉[↕11]∾5××´¨1↓↕6‿11)∾˘6‿1⥊@+10
Kotlin, 118 bytes 97 bytes
fun main() = println((0..5).joinToString("\n") { j -> (0..10).joinToString(" ") { i -> "${i * j * 5}".padStart(3) } })
I've removed about 21 bytes thanks to The Thonnu because I forgot to remove spaces, also I've used "%3d".format() to pad the numbers to a width of 3 characters.
fun main()=println((0..5).joinToString("\n"){j->(0..10).joinToString(" "){"%3d".format(it*j*5)}})
Python 3, 76 bytes
print(*(' '.join(f'{i*j*5:3}'for i in range(11))for j in range(6)),sep='\n')
C (clang), 99 bytes
p(r,i){r?printf("\n%d",r):0;for(i=-1;i++<10;printf("\t%d",r>0?i*5*r:i));}f(i){for(i=0;i<6;p(i++));}
Excel (ms365), 145, 122 bytes
- -23 bytes thanks to @JosWoolley
Formula in A1:
=LET(x,ROW(1:6)-1,y,COLUMN(A:K)-1,TEXTJOIN(HSTACK(IF(y+1," "),CHAR(10)),,RIGHT(" "&HSTACK(IF(x,x," "),IF(x,y*5*x,y)),3)))
This can be 117 bytes if we would swap CHAR(10) out for a literal Alt+Enter:
=LET(x,ROW(1:6)-1,y,COLUMN(A:K)-1,TEXTJOIN(HSTACK(IF(y+1," "),"
"),,RIGHT(" "&HSTACK(IF(x,x," "),IF(x,y*5*x,y)),3)))
Python 3, 69 bytes
for k in b"\n":print(('%4s'*12%(k//5or'',*range(0,11*k,k)))[1:])
Thanks to dingledooper for -3 bytes from the bytestring hardcode. If trailing spaces are allowed:
64 bytes
for k in b"\n":print('%3s '*12%(k//5or'',*range(0,11*k,k)))
Python, 97 bytes
[print(("%4s"*12%x)[1:])for x in[(" ",*range(11))]+[(c,*range(0,c*50+1,5*c))for c in range(1,6)]]
Perl 5, 76 bytes
printf$"x3 .($b="%4d"x11),0..10;//,printf"
$_$b",map$_*=5*$',0..10for 1..5
Jelly, 19 bytes
-r⁵×þ`ḣ7ẸƇ»×¥5AG⁶3¦
How?
-r⁵×þ`ḣ7ẸƇ»×¥5AG⁶3¦ - Main Link: no arguments
-r⁵ - -1 inclusive range 10 -> [-1,0,1,2,3,4,5,6,7,8,9,10]
` - use as both arguments of:
þ - table with:
× - multiplication
ḣ7 - head to index seven
Ƈ - keep those for which:
Ẹ - any?
¥5 - last two links as a dyad - f(M=that, 5):
× - {M} multiply {5}
» - {M} maximum {that}
(multiplies M's positive values by 5)
A - absolute values
G - format as a grid
¦ - sparse application...
3 - ...to indices: [3]
⁶ - ...action: a space character
(replaces the top left 5 (from -1×-1×5) with a space)
Retina, 67 bytes
11*#5*$(¶_11*@
_
$>:&
#
$:&
%`@(?<=(.).*)
$.($1*$:&*5*
P^`\d+
Try it online! Explanation:
11*#5*$(¶_11*@
Insert a template for the output: 11 column headers, and 5 rows, each with a header.
_
$>:&
Populate the row headers. $>:& translates as 1-indexed match index.
#
$:&
Populate the column headers. $:& is the 0-indexed match index.
%`@(?<=(.).*)
$.($1*$:&*5*
Populate the table body. Each row is processed independently, and each @'s match index is multiplied by the row number and by 5.
P^`\d+
Left-pad all of the numbers to the same width.
Bash, 138 bytes
(echo;seq 0 10;paste -d' ' <(seq 5) <(printf %s\\n {1..5}\*{0..10}\*5|bc|xargs -n11)|tr \ \\n)|sed 's/^/printf %3s\\\\n /e'|pr -ats\ -12
With comments
This solution works by generating all the desired numbers, one per line, and then formatting the table with printf(1) and pr(1):
(
# Generate the top line
echo
seq 0 10
# Intersperse 1 through 5 in-between the calculated rows using paste(1).
# The calculation is done with a cross-product of {1..5}*{0..10}*5 piped
# to bc(1).
paste -d' ' \
<(seq 5) \
<(\
printf '%s\n' {1..5}\*{0..10}\*5 |
bc |
xargs -n11 \
) |
tr ' ' '\n' \
) |
# All columns should be 3 characters wide.
sed 's/^/printf "%3s\\n" /e' |
# Use pr(1) to output data across (-a), no header (-t) and with a space
# separator (-s ' ') between the 12 columns (-12).
pr -ats' ' -12
Charcoal, 26 25 bytes
E⁶⪫E¹²◧⎇λI×⊖λ∨×⁵ι¹⎇ιIιω³
Try it online! Link is to verbose version of code. Explanation:
⁶ Literal integer `6`
E Map over implicit range
¹² Literal integer `12`
E Map over implicit range
⎇λ If not the first column
λ Current column
⊖ Decremented
× Multiplied by
ι Current row
× Multiplied by
⁵ Literal integer `5`
∨ Logical Or
¹ Literal integer `1`
I Cast to string
⎇ι If not the first row
Iι Current row as a string
ω Else empty string
◧ ³ Left-pad to length 3
⪫ Join with spaces
Implicitly print
23 22 bytes using the newer version of Charcoal on ATO:
E⁶⪫E¹²◧⎇λ×⊖λ∨×⁵ι¹∨ιω³
Attempt This Online! Link is to verbose version of code. Explanation: PadLeft stringifies its argument, allowing the removal of two instances of Cast and the subsequent simplification of Ternary to Or.
JavaScript (ES6), 74 bytes
+4 bytes for a quick and dirty fix to comply with the updated output
f=(y=5,x=11)=>x--?f(y,x)+` ${x*y*5||x}`.slice(-4):y?f(y-1)+`
`+y:' '
Commented
f = ( // f is a recursive function taking:
y = 5, // y = team members
x = 11 // x = crystals
) => //
x-- ? // if x is not 0 (decrement it afterwards):
f(y, x) + // do a recursive call with (x, y)
` ${x * y * 5 || x}` // and append x * y * 5 or x if this is 0
.slice(-4) // right-justified to 4 characters
// with leading spaces
: // else:
y ? // if y is not 0:
f(y - 1) + // do a recursive call with just y-1 (which
// means that x is implicitly reset to 11)
`\n ` + // followed by a line feed a 2 spaces
y // followed by y
: // else:
' ' // insert the 3 top-left spaces and stop
Thunno 2 N, 21 bytes
5ıTĖ×5×nƤð4ṙ;TĖðƤð4ṙƤ
Explanation
5ı # Map over [1..5]:
TĖ× # Multiply by [0..10]
5× # And multiply by 5
nƤ # Prepend the current number
ð4ṙ # Right-justify to length 4
; # End map
TĖ # Push [0..10]
ðƤ # Prepend a space
ð4ṙ # Right-justify to length 4
Ƥ # Prepend this list
# Implicit output, joined on newlines
