Hot answers tagged

17 votes

Multiply numbers by their depth

Vyxal, 4 bytes ⁽L€* Try it Online! ...
user avatar
  • 8,816
10 votes

Multiply numbers by their depth

Wolfram Language (Mathematica), 12 bytes #0/@#-#&@-#& Try it online! ...
user avatar
  • 16.3k
7 votes

Multiply numbers by their depth

Python, 51 49 44 43 bytes f=lambda l,d=0:l*d*-1or[f(s,d-1)for s in l] Attempt This Online! This is a really fun abuse of the overloading of the ...
user avatar
  • 1,234
5 votes

Multiply numbers by their depth

Jelly, 5 bytes ŒJẈṁ× Try it online! ...
user avatar
5 votes

Tile stacking with ■ and □

Python 3, 237 bytes ...
user avatar
  • 30.6k
5 votes

Multiply numbers by their depth

K (ngn/k), 17 bytes {$[x~*x;0;x+o'x]} Try it online!
user avatar
  • 471
4 votes

Multiply numbers by their depth

BQN, 9 bytes {+⟜𝕊⍟=¨𝕩} Try it here! -5 bytes thanks to @att! Explanation {...¨𝕩} for each element n over input... ...
user avatar
4 votes

Multiply numbers by their depth

JavaScript, 32 bytes (g=k=>a=>a.map?.(g(-~k))??a*k)() ...
user avatar
  • 30.6k
3 votes

Tile stacking with ■ and □

Python3, 714 bytes: ...
user avatar
  • 3,276
3 votes

Multiply numbers by their depth

PARI/GP, 25 bytes f(a)=if(#a',a+apply(f,a)) Attempt This Online!
user avatar
  • 35.8k
3 votes

Multiply numbers by their depth

Retina 0.8.2, 51 bytes \d+ $* 1(?=((\[)|(?<-2>])|(])|[^][])+) $#3$* 1+ $.& Try it online! Link includes test cases. Explanation: ...
user avatar
  • 146k
3 votes

Swap every two elements in a list

Desmos, 42 38 bytes -4 bytes thanks to @aiden's suggestion and wackscope variables l=[1...L.length] f(L)=L[l-1+2mod(l,2)] Try It On Desmos!
user avatar
3 votes

Swap every two elements in a list

Nibbles, 3.5 3 bytes (6 nibbles) \+\`/~ ...
user avatar
3 votes

Swap every two elements in a list

APL, 15 bytes {,⌽⍵⍴⍨(2÷⍨≢⍵)2} The same idea as in the existing solution, but implemented as a separate function and two bytes less.
user avatar
3 votes

Multiply numbers by their depth

Racket, 88 63 bytes (define(m l[d 0])(if(list? l)(map(λ(n)(m n(+ 1 d)))l)(* l d))) Try it online! -25 from removing whitespace, ty @emanresu A!
user avatar
  • 31
2 votes

Get the best of two Arrays

Vyxal, 6 bytes ₌Þ∴=›* Try it Online! ...
user avatar
  • 31.5k
2 votes

Get the best of two Arrays

Vyxal, 8 7 bytes Zƛ≈[∑|G -1 byte thanks to @emanresu A Add the flag if you want to see the numbers in decimal format. Try it ...
user avatar
2 votes

Pairs at every distance

Knight, 91 bytes ;=l~1;W E++'=x'=l+1l'P'1;=aT;=wF;W<=w+1w l;=bF;=s~1;W<=s+1s-l w=b|b?E+'x'sE+'x'+s w=a&a bOa Enter each number in the input list on their ...
user avatar
  • 5,523
2 votes

Flood fill by distance

Vyxal, 32 bytes k₁w≬ƛ£?ÞT›'¥ε∑ṅ}ÞfU↔‹vÞǔ∑:fGε›*‹ Try it Online! Port of Jonathan Allan's Jelly answer, byte count can certainly be way less.
user avatar
  • 8,816
2 votes

Swap every two elements in a list

sed -n, 10 bytes 2~2{G;p};h Try it online! 2~2{G;p} For even numbered lines, append hold ...
user avatar
  • 28.2k
2 votes

Tile stacking with ■ and □

JavaScript (ES6), 198 bytes ...
user avatar
  • 169k
2 votes

Swap every two elements in a list

Brachylog, 5 bytes ġ₂↔ᵐc Try it online! Explanation ...
user avatar
  • 36.5k
2 votes

Multiply numbers by their depth

lin, 26 bytes "deps1> (.+ \@ ' + ) e&".' Try it here! Uses stack as nested list. For testing purposes (use -i ...
user avatar
2 votes

Multiply numbers by their depth

05AB1E, 23 16 15 bytes .γd}DžuSδ¢ÆηO*J Try it online! -2 thanks to @Kevin Cruijssen Takes the input list as a string, using ( ...
user avatar
2 votes

Multiply numbers by their depth

05AB1E, 16 bytes _"Ddië®δ.V>"©.V* Try it online or verify all test cases. Explanation: First step of this 05AB1E answer of mine. ...
user avatar
2 votes

Multiply numbers by their depth

Perl 5 -p, 33 bytes s/\d+/$&*($`=~y|[||-$`=~y|]||)/ge Try it online! For each number, depth is determined by counting the ...
user avatar
  • 12.7k
2 votes

Multiply numbers by their depth

Ruby, 38 bytes f=->a,d=0{a*0==0?a*d:a.map{f[_1,d+1]}} Attempt This Online!
user avatar
  • 25.2k
2 votes

Multiply numbers by their depth

Ruby, 38 bytes f=->a,i=1{a.map{f[_1,i+1]rescue _1*i}} Attempt This Online! An alternative to Razetime's answer for the same byte count.
user avatar
  • 11.8k
2 votes

Multiply numbers by their depth

Knight, 124 118 bytes ...
user avatar
  • 8,816
1 vote

Swap every two elements in a list

ECMAScript 2015 with Lodash (Array), 39 bytes l=>_.chunk(l,2).flatMap(s=>[s[1],s[0]]) Solution below works if array doesn't chunk evenly (...
user avatar
  • 310

Only top scored, non community-wiki answers of a minimum length are eligible