Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 106710

A competition to solve a particular problem through the usage and manipulation of arrays.

2 votes

Rolling a ball over a list

JavaScript (Node.js), 55 bytes f=(n,d=1,a=0,C=n[a])=>C<2?f((n[a]^=1,n),d=C?-d:d,a+d):n Try it online!
ophact's user avatar
  • 3,174
1 vote

Wiggle the tower

JavaScript (Node.js), 299 bytes f=(i,L=0,N=i.map((E,I)=>i.map(G=>I<G|0)).reverse(),Y=Q=>Q.map((e,j)=>Q.reduce((A,g,h)=>A+Q[h][j],0)),F=d=>i[N[L].indexOf(1)-d]&&i[N[L].lastIndexOf(1)-d]&&!(X=N.map((E, …
ophact's user avatar
  • 3,174
2 votes

Crate art stacking

Python 3.8 (pre-release), 128 bytes lambda n:(s:=sum(n))and'\n'.join('\n'.join((n[-1]-N)*s//2*' '+N*('*'+'* '[0<m<s-1]*(s-2)+'*'*(s>1))for m in range(s))for N in n) Try it online!
ophact's user avatar
  • 3,174
5 votes

Fill in the next numbers

Python 3.8 (pre-release), 43 bytes f=lambda n,i=2:n and[n[0]]+f(n[[i]>n:],i+1) Try it online! Thanks @dingledooper for -2 bytes.
ophact's user avatar
  • 3,174
2 votes

center a matrix

Python 3.8 (pre-release), 64 bytes lambda n,l:(c:=[[l]*(l+l+len(n))]*l)+[l*[l]+e+l*[l]for e in n]+c Try it online! It's been a while since I posted a working answer...so feel free to suggest golfs. …
ophact's user avatar
  • 3,174
1 vote

Alternating sums of multidimensional arrays

Python 3.8 (pre-release), 66 bytes lambda n:n*0==0and n or sum((1-i%2*2)*f(e)for i,e in enumerate(n)) Try it online!
ophact's user avatar
  • 3,174
11 votes

Implement an argwhere function

Python 3.8 (pre-release), 45 bytes lambda l,F:[i for i,e in enumerate(l)if F(e)] Try it online! Looks like it won't get much shorter than this. Explanation: keep all indexes (found by unpacking; the …
ophact's user avatar
  • 3,174
2 votes

Sort musical pitches

JavaScript (Node.js), 99 bytes n=>n.sort((a,b,l=e=>`b${D=e.slice(-1)}#`.search(e[1])+12*D+'C D EF G A B'.search(e[0]))=>l(a)-l(b)) Try it online!
ophact's user avatar
  • 3,174
2 votes

Sort numbers in a ragged list

Vyxal, 38 bytes 1N→_a`\d+`?λ←_a1+→_a`\d+`?Ẏ⌊s←_a iS;øṙ Try it Online! Thanks @lyxal for helping me a lot in chat. I've never posted any Vyxal answers before. This is a port of my JavaScript solution. …
ophact's user avatar
  • 3,174
4 votes

Sort numbers in a ragged list

JavaScript (Node.js), 62 bytes n=>n.replace(r=/\d+/g,_=>n.match(r).sort((a,b)=>a-b)[i++],i=0) Try it online! Probably defeats the purpose of the challenge, but it is valid. Takes in a stringified li …
ophact's user avatar
  • 3,174