Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

1 vote

Infer pluses and minuses

T-SQL, 3378 bytes I saw this a few days ago, and was thinking of languages I could use to solve this problem. Ended up deciding to write the entire thing in a query on data.stackexchange.com because I ...
CrSb0001's user avatar
  • 391
0 votes

Infer pluses and minuses

05AB1E, 14 bytes ®X‚Ig<ãʒ1š¹*OQ Two separated inputs \$[a_0,...,a_{n-1}]\$ and \$a_n\$. Output as a list of all possible results, with ...
Kevin Cruijssen's user avatar
0 votes

Infer pluses and minuses

Haskell, 64 bytes f(x:w:y)=[q|q<-mapM(\_->[-1,1])y,sum(zipWith(*)q$w:y)==last y-x] Try it online!
matteo_c's user avatar
  • 6,400
3 votes

Infer pluses and minuses

R, 55 bytes Takes \$a_N\$ as a separate argument, returns a matrix of all solutions with 1/2 for -/+. ...
ovs's user avatar
  • 59.5k
1 vote

Infer pluses and minuses

Brachylog, 15 bytes {+.∧1w₄|-.∧w₄}ˡ Try it online! Outputs + as 1 and ...
Fatalize's user avatar
  • 38.7k
4 votes

Infer pluses and minuses

Python 3,  75   67  64 bytes -8 bytes thanks to Jitse (by placing the output in r - a very smart golf!). ...
Jonathan Allan's user avatar
0 votes

Infer pluses and minuses

Python, 132 bytes ...
corvus_192's user avatar
  • 5,322
1 vote

Infer pluses and minuses

Jelly, 7 bytes _,+ɗ/œẹ A dyadic Link that accepts a list of non-negative* integers*, the summands \$[a_1, a_2, \cdots, a_{N-1}]\$, on the left and a non-negative* ...
Jonathan Allan's user avatar
2 votes

Infer pluses and minuses

Python, 105 91 bytes - 14 bytes thanks to xnor def f(l,n,o=[]): if[n]==l:print(o) if l[1:]:c,d,*r=l;[f([c+a*d]+r,n,o+[a])for a in[1,-1]] I have very little ...
math scat's user avatar
  • 9,368

Top 50 recent answers are included