New answers tagged

0

Charcoal, 75 bytes ≔⁻²⪪024420¹ε≔⁻²⪪343101¹δNθFNFθ«J×κ§ε⊖ι×κ§δ⊖ιF⊕κ«GHV→^←².M§ε⊕ι§δ⊕ι»»≔LKAζ⎚Iζ Try it online! Link is to verbose version of code. Takes input as size and sections. Explanation: Far too long because it doesn't try to use a formula, but guarantees 100% correct answers. ≔⁻²⪪024420¹ε≔⁻²⪪343101¹δ Create displacement vectors for each of the six ...


0

JavaScript (Node.js), 38 36 bytes n=>k=>n*n*k+(k<6&&n*4+2-k-(n>1&k>4)) -2 bytes thanks to Shaggy Try it online!


4

Python 2, 38 bytes lambda n,k:k*n*n+(4*n-k+2-k/5%n)*(k<6) Try it online! Not sure about its correctness. But it at least passed all testcases. -2 bytes by dingledooper -5 bytes by xnor


0

Excel, 63 bytes =LET(r,2*A1-1,x,ABS(A1-SEQUENCE(r)),REPT(" ",x)&REPT("* ",r-x)) Link to Spreadsheet The above spills the results to multiple cells. The 75 byte formula for a single cells answer is below. =LET(r,2*A1-1,x,ABS(A1-SEQUENCE(r)),CONCAT(REPT(" ",x)&REPT("* ",r-x)&" "))


0

C (gcc), 164 125 124 bytes i,h;main(z,b)int**b;{z=atoi(b[1])-1;for(i=z-~z;i--;puts(""))for(h=z<i?z-i+z:i,printf("%*s",z-h,""),h-=~z;h--;)printf("* ");} Try it online!


0

JavaScript (Node.js), 121 99 bytes i=>[...t=[...Array(i)].map((_,z)=>''.padEnd(i-z)+'* '.repeat(z+i)),...t.reverse().slice(1)].join` ` Try it online!


1

Vyxal C, 8 bytes ʁ+×*vṄøm Try it Online! ʁ # Range(n) (0...n-1) + # Plus n (n...2n-1) ×* # That many asterisks vṄ # Join each by spaces øm # Palindromise # (C flag) Center and join by newlines


Top 50 recent answers are included