text:
Size Does Matter (at least referring to bottles)
Introduction
I have an even number of bottles, all of different sizes. Unfortunately, I only know the size of the smallest bottle: 300ml.

I also know the following:

Half of the bottles are twice the size of the other half, meaning that the smallest small bottle and the smallest large bottle are in a ratio of 2:1.
The smaller bottles, from smallest to largest, increase in size by n%, where n is the number of bottles multiplied by 3.

Could you help find what sizes my bottles are?
Challenge
Your input is to be an even number of bottles.

The output should be the size of all of the small bottles (from smallest to largest), then all of the large bottles (from smallest to largest).
Example I/O
In: 2
Out: 300, 600
In: 4
Out: 300, 336, 600, 672
In: 10
Out: 300, 390, 507, 659.1, 856.83, 600, 780, 1014, 1318.2, 1713.66
(Note: commas are unnecessary; this answer can be formatted in any way you want as long as all of the "small" bottles come before the "large" bottles.)
Rules
Standard loophole rules apply.

This is code-golf, so shortest answer in bytes wins!
Winners
Esoteric Languages
15 bytes
05AB1E by Kevin Cruijssen
Standard Languages
36 bytes
Mathematica by attinat

In the third testcase, does it mean 856.83 is smaller one but 600 is larger one? It is confusing.

Yes - the size of "smaller" bottles can be larger than the "larger" bottles.

Essentially, the first half of your output should be the "smaller" bottles, and the second half should be the "larger" bottles.

Doesn't "(at least referring to bottles)" make the title even worse when you think about it?

Let's not go there.

05AB1E, 15 bytes
₆v;F.03*>NmyтP,

Port of @TFeld's Python 2 answer, so make sure to upvote him.
Try it online or verify all test cases.
Explanation:
₆                # Push builtin integer 36
 v               # Loop `y` over both digits:
  ;              #  Halve the (implicit) input-integer
   F             #  Inner loop `N` in the range [0, input/2):
    .03*         #   Multiply the (implicit) input by 0.03
                 #   (alternative 4-byter: `т/3*` # divide by 100, multiply by 3)
        >        #   Increase this by 1
         Nm      #   Take it to the power `N`
           yт    #   Push both `y` and 100
             P   #   And take the product of the entire stack
              ,  #   Then pop and print this number with trailing newline

Wait, 05AB1E has floating-point literals‽ I always assumed this wouldn't work, since . is used for extended commands.

Here's another 15, another 15, and yet another one.
There are lots of possible approaches, but I'm not finding anything shorter.

@Grimmy The new version of 05AB1E indeed had floating point literals :) In the legacy version this wasn't available yet, but it's something new Adnan added in the rewrite.

Python 2, 61 60 59 bytes
lambda n:[a*(1+.03*n)**i*75for a in 4,8for i in range(n/2)]

Try it online!
-1 byte, thanks to Joseph Sible

It confuses me that you've managed to get [300.0, 336.00000000000006, 600.0, 672.0000000000001]. Where did the extra 0's come from?

That's floating point precision for you..

@Corsaka That's caused by the same thing that makes many languages say 0.1 + 0.2 != 0.3 is true

-1 byte: use 75, 4, and 8 in place of 100, 3, and 6.

@JosephSible Thanks :)

Wolfram Language (Mathematica), 36 bytes
{#,2#}&[300(1+.03#)^Range[0,#/2-1]]&

Try it online!

Jelly, 16 bytes
×.03‘*HḶ$×300;Ḥ$

Try it online!
-2 bytes thanks to Nick Kennedy
Explanation
×.03‘*HḶ$×300;Ḥ$  Main Link
×.03              Multiply the number of bottles by 3%
    ‘             Increment (add 100%)
     *            (Vectorized) exponent to the power of:
      HḶ$         [0, 1, ..., n-1]
         ×300     Multiply each factor by 300
             ;Ḥ$  Double the list and append it

×.03 saves two bytes.

@NickKennedy Thanks!

Julia 1.0, 42 38 bytes
f(n,z=[75*(1+.03n).^(0:n÷2-1)])=4z,8z

-4 bytes using ideas from John and Joseph Sible.
Try it online!

Haskell, 47 bytes
f n=[75*a*(1+0.03*n)**i|a<-[4,8],i<-[0..n/2-1]]

Try it online!

Python 2, 55 bytes
n=input()/2
for c in 4,8:exec"print c*75;c*=1+.06*n;"*n

Try it online!
The *75 trick is taken from other answers.

JavaScript (Node.js), 63 bytes
f=(n,b=300,r=1+n*9/b,h=n/2)=>n?[b,...f(n-1,--h?b*r:600,r,h)]:[]

Try it online!

59 bytes

57 bytes

55 bytes, expanding on @Arnauld's improvements.

@Arnauld Maybe you could post as another answer. It is different enough as another answer, imo.

@Arnauld And use the idea from here, it is 54 bytes

Congrats on the gold [tag:code-golf] badge!

PHP, 70 62 bytes
for($s=300;$i++<$n=$argn;$s=$n/2-$i?$s+$s*$n*.03:600)echo$s,_;

Try it online!
Output numbers are seperated by _.
Alternative for $s+$s*$n*.03 can be $s*=1+$n*.03 too, but both are same length.

I'm getting errors with this one. Seems to be complaining that i was never defined

@Corsaka those are warnings or notices in stderr and are totally fine.

Icon, 60 58 bytes
procedure f(n)
write(!36*(1+.03*n)^(0to n/2-1)*100)&\z
end

Try it online!
Saved 2 bytes by replacing (3|6)(alternate 3 with 6) with !36. !generates the components of a data object. When applied to a number it generates its digits. In Unicon - the descendent of Icon - !n generates the numbers in the range 1..n.

What's the point of \z? TIO doesn't understand it.

@Corsaka 3|6 and 0to n/2-1 are generators and normally I would write every write((3|6)*...). Icon have a bactracking mechanism though and when an expression fails, it backtracks to fetch another value from the preceding generator(s). \z checks if the value z is non-null and since z is not present (declared), it backtracks until the 2 generators are exhausted.

@Corsaka TIO only complains that I use a variable that is not declared. Here I declared the variable n in the main procedure and it stopped compaining about n, only z remained.

Ruby, 57 53 bytes
->n{n.times.map{|a|300*(1+a*2/n)*(1+0.03*n)**a%=n/2}}

Try it online!

-1 byte: use 75, 4, and 8 in place of 100, 3, and 6.

Thanks, but I've found a better way.

PowerShell, 66 54 bytes
-12 bytes thanks to mazzy

param($n)300,600|%{$y=$_;1..($n/2)|%{$y;$y*=1+$n*.03}}

Try it online!

54 bytes

@mazzy breaks on the last test case. The last Small Bottle (856.83) is larger than the first Big Bottle (600)

oO! thanks. Very strange comment "the size of "smaller" bottles can be larger than the "larger" bottles". Ok. Another 54 bytes

K (oK), 32 bytes
{s,2*s:(-1+x%2)((1+.03*x)*)\300}

Try it online!

Charcoal, 23 bytes
ＮθＦ²Ｅ⊘θＩ××³⁰⁰⊕ιＸ⊕×θ·⁰³κ

Try it online! Link is to verbose version of code. Outputs each list element on a separate line. Explanation:
Ｎθ

Input n
Ｆ²

Loop i twice, once for the small sizes, once for the large sizes.
Ｅ⊘θ

Loop k over half of the number of bottles, and implicitly output each calculation on its own line.
Ｉ××³⁰⁰⊕ιＸ⊕×θ·⁰³κ

Calculate 300(i+1)(.03n+1)ᵏ and cast the result to string.

R, 46 bytes
x=scan();b=300*(1+0.03*x)^(0:(x/2-1));c(b,b*2)

Try it online

https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet tldr, make a function that accepts x.

@gggg bummer. Reversed back to the standard scan-based approach, then

Forth (gforth), 84 bytes
: x dup 2/ 0 do fdup f. fover f* loop ; : f dup s>f .03e f* 1e f+ 3e2 x 6e2 fnip x ;

Try it online!
Code Explanation
\ helper function to extract out common logic from the small and large numbers
: x               \ start a new word definition
  dup 2/          \ duplicate the input and divide by 2
  0 do            \ loop from 0 to n/2
    fdup f.       \ print the top of the floating point stack
    fover f*      \ multiple the top float stack value by the 2nd float stack value
  loop            \ end the loop
;

: f               \ start a new word definition
  dup s>f         \ duplicate n and place a copy on the float stack
  0.03e f*        \ multiple by 0.03 (multiply by 3 and divide by 100)
  1e f+           \ add 1 to get our increase multiplier
  3e2 x           \ print the smaller numbers by starting with 300
  6e2 fnip x      \ drop the remaining small number and print the large numbers from 600
;                 \ end word definition

Pyth, 23 bytes
Fk2Fb/Q2*300*hk^h*.03Qb

Try it online!
Port of @TFeld's answer, which I was able to make decently concise. Cant help but feel like there's a more clever answer with Pyth but I wasnt able to find it.
How it Works
Fk2Fb/Q2*300*hk^h*.03Qb
Fk2                     - For k in range(2)
   Fb/Q2                - For b in range(input/2)
        *300*hk         - 300 times k+1 times...
                h*.03Q  - 1 + 0.03 times input
               ^      b - The above to the exponent b
                          Implicitly prints the result

Wolfram Language (Mathematica), 40 bytes
Two independent 40-byte answers: the first is an unnamed function, the second is a named function g, both taking one argument.
Table[300i(1+.03#)^j,{i,2},{j,0,#/2-1}]&

g@n_:=300#(1+.03n)^(#2-1)&~Array~{2,n/2}

Java 8, 89 bytes
n->{for(int k=0,i;++k<3;)for(i=0;i<n/2;)System.out.println(Math.pow(.03*n+1,i++)*k*300);}

Port of @TFeld's Python 2 answer, so make sure to upvote him.
Try it online.
Explanation:
n->{                              // Method with integer parameter and no return-type
  for(int k=0,i;++k<3;)           //  Loop `k` in the range (0,3) (basically [1,2]):
    for(i=0;i<n/2;)               //   Inner loop `i` in the range [0, i/2):
      System.out.println(         //    Print with trailing newline:
        Math.pow(.03*n            //     `n` multiplied by 0.03
                 +1               //     incremented by 1
                   ,i++)          //     to the power `i`
                        *k*300);} //     multiplied by `k` and 300

C (gcc), 79 74 77 bytes
78 if the dash in compile arg is ignored.
Port of TField answer.
Increase in bytes is to comply with rules.
-5 bytes thanks to ceilingcat and bznein
b;c;f(a){for(b=0;++b<3;c=0)while(c<a/2)printf("%f ",pow(.03*a+1,c++)*b*300);}

Try it online!

You can also replace for(;c<a/2;) with while(c<a/2)

Is it required for the function to be able to be called multiple times?

Yes

Wren, 79 bytes
Fn.new{|n|
for(a in[300,600])for(i in 1..n/2){
System.print(a)
a=a+a*n*0.03
}
}

Try it online!
Wren, 81 bytes
TField answer turns out to be longer.
Fn.new{|n|
for(i in 0...n/2)for(a in[3,6])System.print(a*(1+0.03*n).pow(i)*100)
}

Try it online!

Japt, 27 23 bytes
_+3/L*Z*U}h[300]Uz
cUmÑ

Try it
_+3/L*Z*U} // function returning next element
h[300]Uz // runs the above func. U/2 times, starting from 300
cU®Ñ // concat the array obtained with the array multiplied * 2

Saved 4 thanks to @Shaggy

23 bytes

#Ĭ == 300 in terms of bytes! Lol

yup. But you save a byte by avoiding UTF encoding, where Ñ is 2 bytes.

Husk, 20 bytes
S+mDmo*300`^→*.03¹ŀ½

Try it online! A port of the standard answer.


text:
Area of diagonal-folded regular polygon
I have a piece of paper whose shape is a regular n-gon with side length 1. Then I fold it through some of its diagonals. What is the area of the shape formed by the (former) edges of the regular polygon?
Illustration
Suppose n = 8, i.e. an octagon-shaped paper. Let's name the vertices from A to H (left picture). Then I fold the paper along the two diagonals BE and FH (right picture). Mathematically, folding BE means to reflect the vertices C and D with respect to the line BE to obtain C' and D'. Your task is to calculate the area of the shaded octagon on the right picture.

Input
The number of sides n and a list representation of the folds l. Each element of l represents either a fold or an intact side of the polygon. If it is a fold, its value is the number of sides moved by the fold (e.g. 3 for the BE fold above, 2 for FH). Otherwise, the value is 1 (e.g. for the sides AB, EF, AH).
For the example above, the input will be 8, [1, 3, 1, 2, 1] if we count from the vertex A, counter-clockwise. If we count clockwise from E instead, the input will be 8, [3, 1, 1, 2, 1]; the expected answer is the same.
Note that sum(l) == n. Also, l == [1] * n (1 repeated n times) case is just the regular polygon untouched, which is a valid input.
The resulting polygon is guaranteed to be simple (it does not intersect or touch itself). For n=3 or n=4, this means that the only valid input is the polygon folded zero times. For n=6, l=[1, 2, 2, 1] or l=[1, 2, 1, 2] is invalid because the two folds will cause two folded vertices to meet at the center of the hexagon.
Output
The area of the n-sided polygon created by the given folds. The result must be within 1e-6 absolute/relative error from the expected result.
Scoring & winning criterion
Standard code-golf rules apply. Shortest code in bytes wins.
Test cases
n l => answer
---------------
4 [1, 1, 1, 1]    => 1.000000
5 [1, 1, 1, 1, 1] => 1.720477
5 [2, 1, 1, 1]    => 0.769421
6 [1, 2, 1, 1, 1] => 1.732051
7 [1, 2, 1, 2, 1] => 2.070249
8 [1, 3, 1, 2, 1] => 1.707107

The picture below shows the first five test cases.

A reference implementation in Python.

Wolfram Language (Mathematica), 37 36 bytes
Tr[Csc[i=Pi/#2]^2Sin[2i#]-Cot@i#]/4&

Try it online!
Takes input in the order l, n.
Uses the same approach as in the reference and many other implementations.
Mathematica's trigonometric and arithmetic functions will automatically vectorize, and Tr returns the sum of the elements of a one-dimensional list.
\$\csc\$ and \$\cot\$ are relatively uncommon; \$\csc x=\frac1{\sin x}\$, and \$\cot x=\frac1{\tan x}\$.

Nice solution.  Do you mind adding an explanation?

@Jonah it turned out to be the same as the reference implementation, but I'll add a little in.

Ruby, 79 .. 66 65 bytes
->n,f{(f*2+[w=-1]*n).sum{|z|(w**z*=b=2r/n).imag/(1-w**b).real}/4}

Try it online!
Loosely based on the reference implementation:

The area of the original polygon (ABCDEFGH) is a
If we cut instead of folding, we get a new convex polygon (ABEFH), we call the area of this polygon b
The difference between a and b is the area of the polygons we cut away (BCDE and FGH), let's call it c
The area of the folded polygon is b-c or a-2c (we have to remove BCDE and FGH twice from the original polygon). This equals to 2b-a
Both a and b can be represented as the sum of triangles (formed by 2 radiuses of the enclosing circle and one side of the polygon). Yes, we have a formula for calculating a, but if we define an intermediate function g it's easier to use it for both a and b
The area of a triangle is r*r*sin(2lπ/n) where l is the number of vertices in a fold and n is the total number of vertices, and r is the radius (which is 1/sin(π/n))
a is the sum of n triangles with l=1
since g(-x)=-g(x), we don't need to split the sum in 2 parts, we can sum over a larger array (that is twice f plus [-1] repeated n times), the intermediate function can become a block.
sin(x)^2 becomes (1-cos(2x))/2
sin(2π/x) and cos(2π/x) are imaginary and real part of the xth root of -1.

JavaScript (ES7),  87 83 82 79  72 bytes
Saved 2 bytes thanks to @Shaggy
Saved 7 bytes thanks to @GB's insight
Takes input as (n)(list). Derived from the reference implementation.
with(Math)f=n=>a=>a.map(v=>n+=sin(2*v*T)/sin(T)**2,n/=-tan(T=PI/n))&&n/4

Try it online!
Given the number of sides \$n\$ and the folding values \$F_1\$ to \$F_m\$, this computes:
$$A=\frac{1}{4}\left(-\frac{n}{\tan(\theta)}+\sum_{i=1}^{m}\frac{\sin(2\theta F_i)}{\sin(\theta)^2}\right)$$
with \$\theta=\dfrac{\pi}{n}\$

80 bytes

You can take the 2Fi/t out of the sum. t is a constant and the sum of Fi is n.

Java 8, 123 114 112 103 bytes
a->n->{double t=Math.PI/n,T=Math.sin(t);n/=-Math.tan(t);for(int v:a)n+=Math.sin(2*v*t)/T/T;return n/4;}

Port of the Python reference implementation.
-11 bytes by porting @Arnauld's JavaScript answer.
-9 bytes thanks to @G.B's insight.
Try it online.

APL (Dyalog Unicode), 41 35 bytes
{4÷⍨(+/(1○2×⍵×t)÷2*⍨1○t)-⍺÷3○t←○÷⍺}

Try it online!
Uses Arnauld's expression for calculating the area.
-6 bytes from ovs. (removing inner dfn)
Explanation
{4÷⍨(+/(1○2×⍵×t)÷2*⍨1○t)-⍺÷3○t←○÷⍺} ⍺ → n, ⍵ → l
                             t←○÷⍺  assign t to Π/n (○÷n = (○1)÷n)
    (                  )            apply the following to each element of l:
       (1○2×⍵×t)                       sin(2×element×t)
                ÷                      divided by
                 2*⍨1○t                sin(t)²
    (+/                             sum the results
                        -           minus:
                         ⍺          n
                          ÷         divided by
                           3○t      tan(t)
 4÷⍨                                divide that whole expression by 4

05AB1E, 36 31 30 25 23 bytes
·žqI/©*®šÅ½ćn/OI®Å¼/-4/

Folds-list as first input, sides-integer as second input.
Port of my Java answer.
-5 bytes by porting @Arnauld's JavaScript answer.
-1 byte thanks to @Grimy.
-5 bytes thanks to @G.B's insight.
Try it online or verify all test cases.
Explanation:
·               # Double each value in the (implicit) input-list
 žq             # Push PI
   I/           # Divide it by the input-integer
     ©          # Store this PI/input in variable `®` (without popping)
      *         # Multiply this to each doubled value in the list
       ®š       # Prepend `®` (PI/input) to this list
         Å½     # Take the sine of each value in the list
           ć    # Pop and push remainder-list and first item separated to the stack
            n   # Square this first item: sin(PI/input)²
             /  # Divide each value in the list by this
              O # And then sum all values together
  ®Å¼           # Get the tangent of `®`: tan(PI/input)
 I   /          # And divide the input-integer by this
      -         # Subtract it from the sum
       4/       # And divide it by 4
                # (after which the result is output implicitly)

-1 by sharing the ·

As noticed by GB, my formula was overcomplicated. You should be able to save a couple of bytes in your ports as well.

@Arnauld Thanks for letting me know. -9 in my Java port and -5 in 05AB1E :)

Python 3, 81 79 bytes
lambda n,f,a=-1:sum([(a**(2/n*r)).imag/(1-a**(2/n)).real for r in f*2+[a]*n])/4

Try it online!
A Python port of my Ruby solution.

R, 60 57 bytes
-2 and -1 thanks to Nick Kennedy and CriminallyVulgar!
function(n,l,t=pi/n)(sum(sin(2*t*l)/sin(t)^2)-n/tan(t))/4

Try it online!

Save 2 bytes: https://tio.run/##TcpLCoAwDATQvadwmWilWOtnoVcRRCgUahSN569Y/JTZzDxm9ybtC29OmtmuBCSc4GGzkhAKkjwRMObHucBhCVTGmUN5V8ZRIUrtDWgxQylCEBMD9b8jUdFuwiOW9hP1SBekesVf

Cheeky extra byte on top of @NickKennedy's Try it online!

Icon, 108 bytes
procedure g(s,f)
r:=.5/sin(t:=&pi/s)
p:=s*(c:=.25/tan(t))
p-:=(c*(i:=!f)-r*r*sin(2*i*t)/2)*2&\z
return p
end

Try it online!
An Icon port of the Python reference implementation.

Jelly, 23 bytes
×ḤÆS÷ÆS²¥_ÆTİ×ɗS
ØP÷ç÷4

Try it online!
A full program that takes the number of sides as its first argument and the list of folds as its right. Returns/prints the area of the folded polygon.
Loosely based on the formula in @Arnauld’s answer.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Format a Swedish phone number
In some parts of the world, phone numbers are fixed-length, apparently. That sounds boring, though.
For this challenge, your task is to take the digits of a what is presumed to be a valid phone number, and format it based on some simplified rules around what a phone number looks like.
Input format
Your input will consist of nothing except the digits 0 through 9, and the input will contain between five and ten of them (both inclusive). Every input will be a valid phone number, according to the following simplified rules:

A full phone number consists of eight to ten digits and can be divided into an optional area code of two to four digits (the first of which is 0), and a mandatory subscriber number of five to eight digits (the first of which is not 0)
When calling someone from a landline phone who has the same area code as you, you do not need to dial the area code. Thus, your program must be able to handle inputs consisting only of a subscriber number with no area code.
The subscriber number consists of 5 to 8 digits, and the first one isn't 0.
The area code, if present, begins with 0, and has 2 to 4 digits. For this challenge's purposes, the length depends on the second digit:

The second digit of the area code will never be 0.
If the second digit is 8, the entire area code will be 2 digits long (so the entire area code will be 08)
If the second digit is 1, 2, 3, 4, or 7, the area code will be 3 digits long.
If the second digit is 5, 6, or 9, the area code will be 4 digits long.

However, for some inputs, the above cutoff point would cause the subscriber number to be too short or begin with a 0. Since we know the input is a valid phone number (because I say so) we have to conclude that the length of the area code is different from the above. If the length listed above does not work, you should pick a length which works, preferring 3-digit codes over 4-digit codes, and preferring either of those to 2-digit codes. You will not need to handle inputs like 0801234, which are invalid for all those cutoff points.

Output format
Your output should be the area code, followed by a dash (only if an area code is present), followed by the subscriber number which should be grouped in one of the following manners (with the groups separated by a single space):
xxx xxx xx
xxx xx xx
xx xx xx
xxx xx

That means numbers with area codes specified will have one of the following formats:
0x-xxx xxx xx
0x-xxx xx xx
0x-xx xx xx
0xx-xxx xx xx
0xx-xx xx xx
0xx-xxx xx
0xxx-xx xx xx
0xxx-xxx xx

Test cases
All numbers were randomly generated, and some of them could potentially be in use, so while I don't expect any of them to belong to anyone in particular, please don't try to call them.
27983516    ->  279 835 16     # No area code, 8 digits
6278304     ->  627 83 04      # No area code, 7 digits
627830      ->  62 78 30       # No area code, 6 digits
11865       ->  118 65         # No area code, 5 digits
067934821   ->  0679-348 21    # Simple 4+5
0927586130  ->  0927-58 61 30  # Simple 4+6
0374821096  ->  037-482 10 96  # Simple 3+7
042807961   ->  042-80 79 61   # Simple 3+6
04629873    ->  046-298 73     # Simple 3+5
0897106384  ->  08-971 063 84  # Simple 2+8
081859302   ->  08-185 93 02   # Simple 2+7
08379451    ->  08-37 94 51    # Simple 2+6
0480936572  ->  0480-93 65 72  # Area code couldn't be 048 to prevent subscriber number starting with 0
0957024168  ->  095-702 41 68  # Area code couldn't be 0957 for the same reason
06057291    ->  060-572 91     # Area code couldn't be 0605 because of subscriber number's length
04809714    ->  04-80 97 14    # Area code could neither be 048 nor 0480 didn't help
080062517   ->  0800-625 17    # Area code could neither be 08 nor 080
09106574    ->  09-10 65 74    # Area code had to be shortened twice from 0910 because shortening it to 091 didn't work

This is code-golf, shortest code in each language wins.

Why 0574821096  ->  057-482 10 96? Why not -> 0574-82 10 96?

@mazzy Because at some point I changed the specification and forgot to update that particular test case - 0574-82 10 96 would be the correct output for that test case, thanks for pointing it out.

Why are there no test cases for 2+5, 3+8, 4+7, 4+8? Is there an unstated rule that the total length is always 8, 9 or 10?

@Grimmy Err, yes, apparently that rule got lost somewhere along the way. Thanks for pointing that out.

Retina, 78 73 bytes
(0(8|[569].?.?|..?0?)(?=[^0]....))?(...?)?(...?)(..)$
$1$#1*-$3$#3* $4 $5

Inspired by both @mazzy's PowerShell answer and @NahuelFouilleul's Perl 5 answer, so make sure to upvote them both as well!
-5 bytes thanks to @Neil.
Try it online.
Explanation:
Match the digit groups like this:
(                                )? # An optional group 1, which consists of:
 0                                  #  A leading 0
  ( |         |     )               #  followed by either (ignored inner group 2):
   8                                #   A single 8
    |[569]                          #   or one of 569,
          .?.?                      #      with one or two optional chars
              |.                    #   or any character,
                .?                  #      with one optional character,
                  0?                #      and an optional trailing 0
                     (?=        )   #  followed by an uncaptured inner group with:
                        [^0]        #   A character which is NOT a 0
                            ....    #   followed by any four characters
(    )?                             # An optional group 3, which consists of:
 ..                                 #  Two characters,
   .?                               #  followed by an optional character
(    )                              # A mandatory group 4,
 ...?                               #  which is similar as group 3
(  )                                # Followed by a mandatory group 5
    $                               # (at the end of the string), which consists of:
 ..                                 #  Any two characters

Then replace it with:
$1                                  # The content of group 1 (possibly empty)
  $#1*                              # If group 1 isn't empty:
      -                             #  A "-"
       $3                           # The content of group 3 (possibly empty)
         $#3*                       # If group 3 isn't empty:
             <sp>                   #  A " "
                 $4                 # The content of group 4
                   <sp>             # A " "
                       $5           # The content of group 5

nice .... instead .{4}

You can use $1$#1*-$3$#3* $4 $5 to save 5 bytes (it makes the second stage unnecessary).

@Neil Ah, that's how you do it! I figured it should be possible to do something like that. I had $1$.1*-$3$.3* $4 $5 with ([- ])+ -> $1 at first, and knew it should be somehow possible to do something like "if there is a match, have a -", but I must have skipped past it in the docs. Thanks!

Perl 5 (-p), 92, 84 bytes
s/(0(8|[569].?.?|..?0?)(?=.{5})(?!0))?(...?)?(...?)(..)$/$1-$3 $4 $5/;s/^\D*|-\K //g

Try it online!

thanks, fixed +2 bytes

they appered after shortening but fixed

nice -\K. █▬█ █ ▀█▀

PowerShell, 135 127 118 107 105 bytes
-1 byte thanks @Kevin Cruijssen
$args-replace'(0(8|[569].?.?|..?0?)(?=[^0].{4}))?(...?)?(...?)(..)$','$1-$3 $4 $5'-replace'^\D+|(?<=\D) '

Try it online!

You can remove the leading ^, only the trailing $ is necessary.

Python 3.8, 554 bytes
#it's the source patterns
s=r'''xxx xxx xx
xxx xx xx
xx xx xx
xxx xx
0x-xxx xxx xx
0x-xxx xx xx
0x-xx xx xx
0xx-xxx xx xx
0xx-xx xx xx
0xx-xxx xx
0xxx-xx xx xx
0xxx-xxx xx'''.split('\n')
import re
#now we make pattern matchers for each of them,
#assuming 0 does not start a short number (^) or the first group after '-'
m=[re.compile('^'+
              re.sub(r'(^)?(\-)?(x+)',
                         lambda m:
                         (lambda x:
                          [r'(\d{%d})'%x,r'([1-9]\d{%d})'%(x-1)]
                          [(m.group(2)!=None)or(m.group(1)!=None)])
                         (len(m.group(3))),i)
              .replace(' ','')
              +'$')
   for i in s]
f=lambda i:(lambda k,v:re.sub('x+','%s',k)%v)(*(
    #then we sort matching patterns by
    #first character in ['','8','12347','569'][len(first_group)]
    #and by len(first_group)
    #and take the last elem. It will be with key (True,n) or
    #(False,max(n)) if n is the first group's length
    sorted(
    [(k,v.groups()) for j,k in zip(m,s) if (v:=j.match(i))],
    key=lambda x:((g:=x[1][0])[0] in ['','8','12347','569'][len(g)],
                                len(g)) )[-1]))

Try it online!
I see it can be shortened by sum(len(j)-1 for i in s for j in re.findall('x+',i))==50 bytes by replacing 'x' repeating n times by n, but I just wanted to demonstrate the approach.

C# (Visual C# Interactive Compiler), 246 bytes
s=>{int a=s[1]-'0',b=0,c=s.Length,d,e;bool f=s[4]==48,g=s[2]==48;var h="";if(s[0]==48){b=a==8?2:a<5|a==7?3:f?3:4;b=s[3]==48?!g&c-b<6?2:f?3:4:g?3:b;h+=s.Substring(0,b)+"-";}for(d=b;d<c-1;d+=e)h+=$"{s.Substring(d,e=c-b==6?2:c-d<5?2:3)} ";return h;}

Try it online!
int a = s[1]-'0'   //int value of second char
    b = 0,         //area code length
    c = s.Length,  //length of the input
    d,             //for loop iterator
    e;             //length of the current number group

bool f = s[4]==48, //5th digit is 0
     g = s[2]==48; //3rd digit is 0

var h="";          //output string

if(s[0]==48)       //starts with 0 / is area code
{
    b=a==8?2:a<5|a==7?3:f?3:4;          //set area code length from subscriber number
    b=s[3]==48?g&c-b<6?2:f?3:4:!g?3:b;  //modify area code length according to special 0's
    h+=s.Substring(0,b)+"-";            //append area code to output
}

for(d=b;d<c-1;d+=e) //iterate the non area code numbers
{
    h+=$"{s.Substring(d,e=c-b==6?2:c-d<5?2:3)} "; //append number group of 'e' length
}

return h;

Suggest g|c-b>5?f?3:4:2 instead of !g&c-b<6?2:f?3:4

JavaScript (Node.js), 284 267 bytes
(n,B=I=>+n[I]&&n.length-I>4,A=a=>a.includes(n[1]),b=B(0),L=A('8')?2:A('569')?4:3)=>(b?'':n.slice(0,B(L)?L:L=L>3?B(3)?3:2:L>2?B(4)?4:2:B(4)?4:3))+(b?'':'-')+n.slice(b?0:L).replace(/./g,(e,i,T,U=e+' ')=>T[5]?T[6]?T[7]?i==2|i==5?U:e:i==2|i==4?U:e:i==1|i==3?U:e:i==2?U:e)

Try it online!
No regex except for the basic /./g, and that's the way I want it to be.

Python 3, 128 bytes
lambda x:re.sub(r'^\D+|(?<=\D) ','',re.sub(r'(0(8|[569].?.?|..?0?)(?=[^0].{4}))?(...?)?(...?)(..)$',r'\1-\3 \4 \5',x))
import re

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Counting syllables
Challenge
Write code that, given an English word, outputs the number of syllables it has. Scoring will be determined by a combination of code length and accuracy.
Rules

The accuracy of the solution should be measured against this CSV file (which countains syllable counts for all the 52,439 entries in the CMU Pronouncing Dictionary that are also words listed in the SOWPODS Scrabble Dictionary).
Entries should accept any word listed in the file and return a numeric value for it; behaviour on other inputs is left undefined. Note that the words listed are all lower-case and between 2 and 15 letters long.
The returned syllable count is correct if it corresponds to any of the listed counts for that word. Note that some words have multiple correct syllable counts, which are separated with a '|' in the CSV: eg

resume,2|3
resumed,2
resumes,2|3
resuming,3

Input/output can be given by any convenient method.
Standard loopholes are forbidden.

Scoring
This is a modified code-golf, with the total score being the sum of the code length in bytes and the square of percentage error (which is first rounded to the nearest percent). For example:

lambda s:2 has a score of 10 (bytes) + 61*61 (squared % error) = 3731
lambda s:sum(s.count(v)for v in "aeiouy") has a score of 41 + 45*45 = 2066.

Related / possible dupe (difference is the given word-list to test against and scoring formula). I don't have the time to build a test-suite (might do so tomorrow), but I wonder what percentage the regex of that accepted answer would match in the list of this challenge.

@KevinCruijssen That is quite similar, isn't it? :-( I've tested the top Ruby answer and it scores 86.52%, which gives an overall score of 53 + 13^2 = 222. I can personally do a bit better, but perhaps it's too similar to be of interest.

Should I just close it as duplicate?

175 (75 bytes, 10.44% incorrect words).


text:
A guess the word game
A guess the word game
The agreed dictionary.  All words are 6 letters long with all letters distinct
Rules:  This is a game of two players and the task will be to implement Player 2.
Player 1 chooses a word from the agreed dictionary
Player 2 repeatedly guesses a word from the agreed dictionary.
At each turn, Player 1 tells Player 2 how many letters the guess has in common with the secret word.  For example, youths and devout have three letters in common.
Goal
Player 2's goal is to guess the word in as few turns as possible.
Task
The task is to implement player 2 to minimize the maximum number of guesses they ever have to make. Your score is the maximum number of guesses made when considered over all the words in the agreed dictionary. A lower score is better.
You should test  your code by choosing each word from the agreed dictionary in turn and see how many guesses your implementation of Player 2 needs. You should then output the maximum.
Objective winning criteria
Answers will first be compared by the score they get using the rules above. Two answers with the same score will then be compared using code-golf rules. That is by the number of bytes in the code.

Why the downvote?

I feel like this challenge is just going to end up being a regular code-golf once someone figures out the best word path :P Not a necessarily bad thing, and I didn't downvote.

@HyperNeutrino Yes. I am happy with that outcome.

Using bytecount as a tiebreaker is a thing to avoid when writing challenges

@pppery Thanks. I added a comment to that answer giving some counter-arguments.

Should we somehow store the dict or it is allowed to load it from github?

@AlexeyBurdin Your code can load it from wherever is convenient.

How do Player 2 guess any of ['carets', 'caster', 'caters', 'crates', 'reacts', 'recast', 'traces']? One by one? Player 1 will reply 6 for each of them, how do Player 2 know he winned?

I suppose player 1 can tell you if you got the right word and stop the game. I have the same problem witn ["palest", "pastel", "petals", "plates", "pleats", "staple"]

@GB Yes, that's exactly right.

@ everyone: you can use ./.input.tio as file-path in TIO and it will use the content of the STDIN as file content. I did something similar in this challenge. It probably won't be able to fit the entire wordlist because it's too large, but a smaller test sample is possible to verify your code a bit. @GB Here your Ruby TIO like this.

Distant cousin of this challenge?

@640KB Yes, I think so.

Ah man, I've just done it thinking P2 tells P1 which characters the words had in common, not just the count. And the worst score was 64 (very straightforward implementation). No idea how the current answers are able to get it so efficient with those rules. Good challenge, much harder than I expected.

Ruby, 418 bytes, score 12 (on 'palest')
$dict = File.readlines('agreeddict.txt').map(&:chomp)

def search(wrd)
  words = 0
  fdic = $dict.clone
  guess = ''
  starters = ['earths','blowup','coding']

  chs = wrd.chars

  while guess!=wrd do
    guess = starters.pop || fdic.pop
    words += 1
    ghs = guess.chars
    chars = (chs|ghs).size
    fdic.select!{|w|(w.chars|ghs).size == chars}
  end

  words
end

upp = 0;

p $dict.map{|w|
  [search(w),w]
}.max

Try it online!
Runs in 15 seconds on my machine.
TIO link for reference only - does not work if the file is not in the current directory.
The trick
Instead of brute-force elimination, try a list of initializers first. A lot of words differ by only 1 character and it's easy to get stuck in a single-letter elimination loop.
The most difficult words to guess are those with 4-5 very common characters (a e r s t), 1-2 'outsiders' (c p x z...) and some anagrams in the dictionary.
For example, when we reach a word containing the letters "a e r s t" and the answer is 5: if we just filter all the entries containing these 5 characters, we are left with a dictionary of 40 similar words, and then we have to try almost all of them, removing only a few words at each step.
We need to remove these words first, and we filter on the least common character, so if we get to "earths", and Player 1 answers 5, we don't have a lot of words to check. The first 2 words we always check are "coding" and "blowup" (no pun intended).
Now we can try with  a word containing the 5 most common letters ("earths"). If the answer is 4 or 5 (which is likely), we don't have a lot of words to choose from, because we already filtered all the words containing only 1 or 2 uncommon letters (and we only used 3 guesses to get here).
Finding the right initializers was a little tricky, I started with a list of 5 "quasi orthogonal" words (with as few letters as possible in common, a good start was "sporty fuzing hawked climax jumble", missing only the letter z) and got to 13, then started a test on automatically generated smaller lists.
'palest' seems to be a worst case, having 6 anagrams and 4 very common letters, but it's not the only word requiring 12 guesses, so I don't think I could get a better score with this approach.
I don't want to golf this.

12 is a very good score. Well done!

What do you get for https://gist.githubusercontent.com/lesshaste/6b573a51e0d2ca3d4fcc159dbf20eb7e/raw/b3fded2e9ce42262fd85beff6e0341faf889dfa6/4%2520letters ?

Python 3.8, 730 bytes, score 13
p='https://gist.github.com/lesshaste/775f70d4da6778807ff9a8a42c293169/raw/c36b8d3b3d501106de781cb2c3b4c8f6e9d47b33/agreeddict.txt'
from urllib.request import urlopen as o
w=str(o(p).read(),encoding='utf-8').split('\n')
from collections import*
g=lambda x:lambda s:len(set(x)&set(s))
s=dict()
for x in w:
	f=g(x) #the answer function from Player 1. Nothing else knows x
	y=w[:] #init the word set
	c=0 #tries counter
	wd='muting'
	while len(set(frozenset(i) for i in y))>1: #till we have only one set of letters
		c+=1
		m=f(wd)
		y=[i for i in y if len(set(i)&set(wd))==m] #filter words
		#print('%2d'%c,wd,'answer:%d'%m,'variants left:%4d'%len(y))
		d=dict()
		for i in y:
			r=Counter(len(set(i)&set(j)) for j in y)
			d[i]=max(r.items(),key=lambda x:x[1])
			#-math.log(d[i]/len(y),2) is the info in worst case
		wd=min(d.items(),key=lambda x:x[1][1])[0]
	s[x]=(c,len(y))
	assert set(y[0])==set(x)
	print(x,c,len(y),flush=True)
print(max(sum(i) if i[1]!=1 else i[0] for i in s.values()))

Try it online! (doesn't seem to work, you can download it from there and run with python3 (likely 3-4 hours)) -- the result is here.
The working version with 5 first words+['palest','extras','orates'] for shorter amount of time (with words-list lzma-compressed).
At every step we choose such word from the list of words left, as even the worst answer form Player 1 gives us the most of information over all worst cases. We need ~11.77 bits of information.
Output is word, number of tries to get set of letters, number of words with such set.
The maximum:
 1 muting answer:1 variants left:1149
 2 charts answer:4 variants left: 133
 3 alerts answer:5 variants left:  32
 4 averts answer:5 variants left:  19
 5 prates answer:5 variants left:  16
 6 rawest answer:5 variants left:  13
 7 skater answer:5 variants left:  10
 8 stared answer:5 variants left:   7
 9 barest answer:5 variants left:   5
10 faster answer:5 variants left:   3
11 ersatz answer:5 variants left:   2
12 extras answer:5 variants left:   1
orates 12 1

(compared with "palest")
 1 muting answer:1 variants left:1149
 2 charts answer:3 variants left: 344
 3 dactyl answer:3 variants left: 102
 4 adepts answer:5 variants left:  18
 5 basted answer:4 variants left:  11
 6 palest answer:6 variants left:   6

The TIO doesn't seem to work.

I do with y=[i for i in y if len(set(i)&set(wd))==m]

Your output suggests 12 but I am not sure what orates 12 1 means

This means after 12th step Player 2 knows that the word is 'orates' (1 candidate) but he didn't hit 6 before, so need 1 more turn.

Haskell, haven't bothered to golf, 14
If I can get down to 13, I'll try to golf this, but I don't have time right now:
{-# LANGUAGE TemplateHaskell #-}
module Main where

import Control.Monad.State.Lazy
import Control.Lens
import Data.List (intersect)
import System.Environment
import Text.Printf

data World = World { _wDictionary :: [String]
                   , _wAnswer     :: String
                   , _wScore      :: Int
                   }
makeLenses ''World

main :: IO ()
main = do [answer]   <- getArgs
          dictionary <- fmap lines getContents
          let score   = evalState solve $ World dictionary answer 0
          putStrLn $ printf "Correctly guessed answer %s in %d attempts" answer score

solve :: State World Int
solve = do word   <- uses wDictionary head
           result <- guess word
           if result == 6
           then use wScore
           else do wDictionary %= filter ((== result) . length . intersect word)
                   solve

guess :: String -> State World Int
guess word = do wScore += 1
                uses wAnswer $ length . intersect word

Words scoring 14 are "streak", "skater", and "takers."
I can't add TIO because it doesn't have the lens package.


text:
Exploding Primes
At the time of writing this puzzle, there are soon to be 269 puzzles related to primes. To celebrate/mourn this event (269 is prime), this challenge will be about exploding primes. In preparation for this task, I've obtained a permit (legal, I assure you) for dynamite charges of military grade, along with enormous dynamite itself. Unfortunately, I also have a lot of junk in my warehouse, and I've packaged everything (and I mean everything) into ASCII text.
From sizes 1 to 6 (actual input sizes can be arbitrarily large), here are examples of my enormous dynamite:
                             +
                          ___L__
                     +   |      |
                   __L__ |      |
               +  |     ||      |
             __L_ |     ||      |
         +  |    ||     ||      |
        _L_ |    ||     ||      |
     + |   ||    ||     ||      |
    _L |   ||    ||     ||      |
 + |  ||   ||    ||     ||      |
 L |  ||   ||    ||     ||      |
| ||  ||   ||    ||     ||      |
|_||__||___||____||_____||______|
                                                                  __________________
                                               _______________   |                  |
                               ____________   |               |  |                  |
                  _________   |            |  |               |  |                  L-*
        ______   |         |  |            L-*|               L-*|                  |
 ___   |      L-*|         L-*|            |  |               |  |                  |
|___L-*|______|  |_________|  |____________|  |_______________|  |__________________|

The pattern for size n vertical dynamite is two 2n-high columns of | separated by n spaces in the middle/_s on the bottom and top. The bottom _s will be surrounded by |s, but the top _s will be surrounded by spaces. There will be an L under a + replacing the mid-point (biased right) of the top _s.
The pattern for size n horizontal dynamite is two n-wide rows of _ separated by n-1 space-filled rows in the middle. There will be n+1-high columns on the left and right, out of which the top character will be a space, and others will be |. There will be an L with a * on the right replacing the mid-point (biased upwards) of the right |s.
As my best and brightest assistant, you will need to help me determine how many primes each ASCII package (input grid) can destroy. Your task is to count all the valid dynamite within a package, taking into account the size. You will output a string like so: BOOM! # prime(s) primed for destruction, where # is the total computed dynamite size in the package.
Examples
Input:
 ______
|      L-*
|______|
Output:
BOOM! 2 prime(s) primed for destruction
Reasoning:
Single piece of dynamite of size 2

Input:
Output:
BOOM! 0 prime(s) primed for destruction
Reasoning:
Empty string contains no dynamite

Input:
   __+_
   \_|_\
   /_|_/
  ___L___
~~\_____/~~
Output:
BOOM! 0 prime(s) primed for destruction
Reasoning:
Despite being cute and non-empty, this ASCII ship from my warehouse has no dynamite in it

Input:
 ____________
|            |
|    ___     L-*
|   |___L-*  |
|____________|
Output:
BOOM! 1 prime(s) primed for destruction
Reasoning:
Dynamite is non-recursive - the outer dynamite doesn't count at all,
but the inner dynamite is valid and will blow up 1 prime.

Input:
 +
 L
| |
|_|
Output:
BOOM! 0 prime(s) primed for destruction
Reasoning:
A space character is missing to the right of the L - the box must be
fully complete, although the + for vertical and -* for horizontal dynamite
are not necessarily space-padded; all that is required for those elements
is that they be aligned with the L.

Input:
                     +
                   __L__
                + |     |
             __L_ |     |
         +  |    ||     | _____________________
        _L_ |    ||     ||                     |
     + |   ||    ||     ||                     |
    _L |   ||    ||     ||                     |
 + |  ||   ||    ||     ||                     L-*
 L |  ||   ||    ||     ||                     |
| ||  ||   ||    ||     ||                     |
|_||__||___||____||_____||_____________________|
Output:
BOOM! 18 prime(s) primed for destruction
Reasoning:
The size-4 dynamite is malformed, but all the other pieces of dynamite
are valid. Summing the dynamite sizes within this package yields
1 + 2 + 3 + 5 + 7 = 18 units of dynamite.

Input:
   A
  C+C
 M L M
E | | E
 M|_|M
  C C
   A
Output:
BOOM! 1 prime(s) primed for destruction
Reasoning:
The dynamite's box is properly surrounded by spaces, and the tip is not
required to be surrounded by spaces. Therefore, this is a valid piece of
dynamite that can explode 1 prime.

Input:
 +
 L ______
| |      L-*
|_|______|
Output:
BOOM! 3 prime(s) primed for destruction
Reasoning:
Although the 2 pieces of dynamite intersect, each on their own satisfies
the parameters for enormous dynamite. Therefore, the pieces can explode
1 + 2 = 3 primes together.

Rules
Input will be an ASCII grid/string of characters in any reasonable format. Output must be a correctly computed string consisting of BOOM! # prime(s) primed for destruction, where # is the total computed dynamite size in the input.
Your answer may be a function or full program (both will be scored according to the same metrics).
Exploiting standard loopholes is forbidden.
Scoring
This is code-golf - shortest code wins. Go out there and explode some primes :)

I'm (slowly) refurbishing on an old record player from 1959 whose capacitors look exactly like that and explode the same way. BOOM!

@Arnauld That's pretty interesting - sounds like you're inadvertently well prepared for a prime-hunting expedition

JavaScript (ES8),  298 ... 272  267 bytes
Takes input as an array of strings.
a=>`BOOM! ${a.map((s,y)=>s.replace(/ _*(L?)_*(?= )/g,(s,L,x)=>t+=(w=s.length,L?y&&s[d=w+1>>1]+a[y-1][k=w*2-1,x+d]=='L+'&&~-w:k=w/3|0)*(v=L?0:++k+1>>1,g=c=>!--k||(a[y+k]+g).indexOf('|'.padEnd(w,c)+(--v?'|':'L-*'),x)==x&g())`_`),t=0)|t} prime(s) primed for destruction`

Try it online!
How?
For each line, we look for the following pattern:
/ _*(L?)_*(?= )/g

The above regular expression matches a space followed by a sequence of _ with or without a single L within it, followed by a space. We use a lookahead for this last space, so that it can be combined with the first space of another pattern immediately following.
If a L is captured, the pattern is interpreted as the top of a vertical dynamite stick. In this case, we make sure that the L is located at the expected position and that there is a + above it.
If no L is captured, the pattern is interpreted as the top of a horizontal dynamite stick.
In both cases, we use the recursive helper function \$g\$ to test the body of the stick. There's a special case in this function to make sure that we have L-* at the end of the middle row of a horizontal stick. All other rows are expected to be a sequence of _ or spaces surrounded by two |.
Commented
Wrapper
a => `BOOM! ${...} prime(s) primed for destruction`

Main code
a.map((s, y) =>                  // for each string s at position y in the input a[]:
  s.replace(                     //   for each string s
    / _*(L?)_*(?= )/g,           //   matching / _*(L?)_*(?= )/
    (s, L, x) =>                 //   with L = captured 'L' and x = position:
      t += (                     //     update t:
        w = s.length,            //       w = length of matched string
        L ?                      //       if a 'L' was captured:
          y &&                   //         if y is not equal to 0
          s[d = w + 1 >> 1] +    //         and the character at floor((w+1)/2)
          a[y - 1]               //         followed by the character above it ...
          [k = w * 2 - 1, x + d] //         (set k to 2w-1)
          == 'L+' && ~-w         //         ... form the string 'L+', yield w-1
        :                        //       else:
          k = w / 3 | 0          //         yield k = floor(w/3)
      ) * (                      //       multiply this by the result of g():
        v = L ? 0                //         if a 'L' was captured, set v to 0
              : ++k + 1 >> 1,    //         else, increment k and set v to floor((k+1)/2)
        g = c =>                 //         g is a recursive function taking a character c:
          !--k ||                //           decrement k and stop if it's equal to 0
          (a[y + k]              //           otherwise, take the entry at y+k,
                    + g)         //           coerce it to a string in case it's undefined,
          .indexOf(              //           look for the position of this substring:
            '|'.padEnd(w, c) +   //             a '|' followed by c repeated w-1 times
            (--v ? '|' : 'L-*'), //             followed by either a '|' or 'L-*' if v = 0
            x                    //             starting from x
          ) == x                 //           and make sure it's equal to x
          & g()                  //           recursive call with c undefined
      )`_`                       //       initial call to g with c = '_'
  ),                             //   end of replace()
  t = 0                          //   start with t = 0
) | t                            // end of map(); return t

Perl 5 (-Minteger -00p), 323 bytes
Gives the correct output for tests, to be golfed more
for$s(2..y/
//){$t=$s-1>>1;$u=$s/2-1;$v=2*$s-1;s/^ (___){$s} .*
(\|(   ){$s}\|.*
){$t}\|(?3){$s}L-\*.*
(?2){$u}\|(?1){$s}\||^...{$u}\+.*
 __{$u}L_{$t} .*
(\| {$s}\|.*
){$v}\|_{$s}\|/$\+=$s;$&/gme}s/^ ___ .*
\|___L-\*|^.\+.*
 L .*
\| \|.*
\|_\|/$\++;$&/gme;s/^.//gm&&redo}{$\|=0;$\="BOOM! $\ prime(s) primed for destruction"

Try it online!

Nicely done! I look forward to further golfification :P


text:
Sort and Table a Sentence by Word Lengths
In as few bytes as possible, sort the input, a delimited string OR list/vector/array of words, words contain printable ASCII except space (ASCII values 33-126) into a numbered list, table, or something resembling a table, by length.
Table rules are as follows:

Order is mandatory, direction is optional, either labelled rows from shortest to longest or vice versa,
Formatting is not the challenge. So as long as the output is some form of numerically labelled rows of words, a numbered list, or a list of lists, or similar output, then it is a satisfactory answer.
including/excluding gaps (NA values, see below examples for both methods of output)
Word case is untouched. How the word appears in input should be shown in output.

Input 1:
Code Golf and Coding Challenges Meta

or
("Code","Golf","and","Coding","Challenges","Meta")

or similar
Output 1:
 1. NA
 2. NA
 3. and
 4. Code Golf Meta
 5. NA
 6. Coding
 7. NA
 8. NA
 9. NA
 10. Challenges

or
3. and
4. Code Golf Meta
6. Coding
10. Challenges

or
[[3, ['and']], [4, ['Code', 'Golf', 'Meta']], [6, ['Coding']], [10, ['Challenges']]]

Input 2:
My v3ry 3xc3113nt m0th3r ju5t 53rv3d u5 nin3 pizz@5 #JusticeForPluto

Output 2:
1. NA
2. My u5
3. NA
4. v3ry ju5t nin3
5. NA
6. m0th3r 53rv3d pizz@5
7. NA
8. NA
9. 3xc3113nt
10. NA
11. NA
12. NA
13. NA
14. NA
15. NA
16. #JusticeForPluto

or
2. My u5
4. v3ry ju5t nin3
6. m0th3r 53rv3d pizz@5
9. 3xc3113nt
16. #JusticeForPluto

or
[[2, ['My', 'u5']], [4, ['v3ry', 'ju5t', 'nin3']], [6, ['m0th3r', '53rv3d', 'pizz@5']], [9, ['3xc3113nt']], [16, ['#JusticeForPluto']]]

More examples can be provided if necessary but I think this should suffice for now.
Please ask questions if you have them, this is my second attempt at a challenge. (the first failed dramatically)

In your second example, it seems that @ is part of a word, but . is not, and # is. Could you please define what a "word" means? Thanks.

@HyperNeutrino Sorry, I meant to delete that period. I'll make some edits

Can the length be in unary?

@someone I'm unfamiliar with unary outputs. I'd have to see it to confirm, but I imagine it can be a valid answer.

R, 28 bytes
split(w<-scan(,""),nchar(w))

Try it online!
split does the trick; results in a list() where the element names are the lengths and  the elements are vectors containing the words.

I was wondering about the best R method. I didn't even know split existed, or how it worked. That's fantastic!

@Sumner18 yes, split is super nice; if you're doing something that requires split, a transformation on each group, and an unsplit, then ave is worth trying as well.

K (ngn/k), 12 14 bytes
{x@=#'x@:<#'x}

Try it online!
this returns a k dictionary. lengths are key, words are value. let me know if this output format is acceptable.
in q (wrapper around the k4 dialect), we can evaluate using the k interpreter and get q output formatting:
q)k){x@=#:'x@:<#:'x}("Code"; "Golf"; "and"; "Coding"; "Challenges"; "Meta")
3 | ,"and"
4 | ("Meta";"Golf";"Code")
6 | ,"Coding"
10| ,"Challenges"

note the extra colons, which aren't required for "eached" monads in the ngn implementation

Definitely an interesting output format. If this output is functional as a dictionary, and could be used, say, as input to some other program, then I would say it is acceptable.

@Sumner18 oh yeah, it's functionally a dictionary. see here, where we assign the dict to r, then use key juxtaposition to return the corresponding values

@scrawl did you mean {x@=#'x@:<#'x}?

@ngn, yes. i am constantly getting ahead of myself and not testing robustness

that being said, my initial submission was pretty wrong in 2 big ways. it wasn't just missing edge cases

Japt, 7 bytes
Input as an array of words, output as a 2D-array.
üÊËiDÎÊ

Try it
üÊËiDÎÊ     :Implicit input of array
ü           :Group and sort by
 Ê          :  Length
  Ë         :Map each sub-array D
   i        :  Prepend
    DÎÊ     :    Length of first element of D

Perl 6, 19 bytes
*.classify(*.chars)

Try it online!
Pretty much does exactly as asked.
*.classify(       )  # Classify the list
           *.chars   # By number of characters

I've heard of Perl's godlike ability to handle strings and regular expressions. I would expect nothing less of it.

@Sumner18 You're probably thinking of Perl 5 (though Perl 6 (now known as Raku) is pretty good at it too)

PowerShell, 18 bytes
$args|group Length

Try it online!

C (gcc), 147 129 bytes
Thanks to girobuz and ceilingcat for the suggestions.
This routine first finds the maximum string length of an input array of strings, then prints the words by length in reverse.
m,*t;f(int**s){for(t=s;*s;m=fmax(m,strlen(*s++)+1));for(;--m;)for(printf("\n%d",m),s=t;*s;)printf(" %s"+3*(strlen(*s++)!=m),*s);}

Try it online!

143 bytes

jq, 53 bytes
map({l:length,s:.})|group_by(.l)|.[]|[.[0].l,[.[].s]]

Try it online!

Welcome to Code Golf! Nice first post.

JavaScript, 50 bytes
Input as an array of words, output as an object where the keys are the word lengths and the values are arrays of words.
a=>a.map(w=>o[l=w.length]=[...o[l]||[],w],o={})&&o

Try it Online!

Retina 0.8.2, 37 bytes
S`
.+
$.& $&
O#`
r`(?<=\1.+)¶(.+ )

Try it online! Explanation:
S`

Split the input on spaces.
.+
$.& $&

Precede each word by its length.
O#`

Sort numerically.
r`(?<=\1.+)¶(.+ )

If two lines start with the same length, delete the newline and the length.

Python 2, 76 74 72 bytes
lambda a:sorted((l,[d for d in a if len(d)==l])for l in set(map(len,a)))

Try it online!

Can squeeze a couple more bytes with set unpacking in python 3 Try it online!

05AB1E, 9 7 bytes
€gêεùy‚

-2 bytes thanks to @Grimy.
Outputs a list of lists from lowest to highest, with the label at the right side instead of left. I.e. [[["and"],3],[["Code","Golf","Meta"],4],[["Coding"],6],[["Challenges"],10]].
Try it online or verify all test cases.
Explanation:
€g       # Get the length of each string in the (implicit) input-list
  ê      # Sort and uniquify this list of lengths
   ε     # Map each length `y` to:
    ù    #  Keep strings from the (implicit) input-list equal to this length
     y‚  #  And pair it with the current length `y`
         # (after which the result is output implicitly)

é.γg} => €gêù for -1. EDIT: actually here's 7.

@Grimmy Thanks. Now the grouped by .γ builtin looks even more useless than I already thought.. xD

Turns out there was actually a group-by built-in all this time: .¡ (incorrectly documented as sort-by). It doesn't
save any bytes here (ù is more appropriate anyway), but it dramatically
improved this old answer of
mine.

@Grimmy Oh, that's good to know. Never knew we had one. Did you discovered this in the source code? Maybe tag @Mr.Xcoder somewhere so he could change the wiki for it?

I discovered this because I wanted to use split-by for another challenge, but it didn’t behave like I thought it would, so I investigated it.

Brachylog, 9 bytes
lᵍ{hl}ᶻ¹o

Try it online!
Takes input as a list of words (the testing header converts from space-separated for convenience). Output is as a list of pairs [length,words], sorted in ascending order of length. Two alternative solutions of the same length, lᵒlᵍ{hl}ᶻ and lᵍ{hl}ᶻtᵒ, output pairs reversed.

Ruby, 22 28 bytes
->w{w.group_by(&:size).sort}

Try it online!

This output is not ordered shortest to longest words.

Sorry, now it is.

APL (Dyalog Unicode), 15 bytes
(⍋⊃¨⊂)≢¨{⊂⍺⍵}⌸⊢

Try it online!
APL is not particularly good at simply sorting.
How it works
(⍋⊃¨⊂)≢¨{⊂⍺⍵}⌸⊢
      ≢¨     ⌸⊢  Group the arg's elements by their lengths
        {⊂⍺⍵}    Wrap each list of items, paired with the length
(⍋⊃¨⊂)           Idiom for sorting:
 ⍋               Grade up; gives indexes that will make the array sorted
  ⊃¨⊂            Map the indexes to the items

You could save 1 with (⍋⊃¨⊂)≢¨(⊂,)⌸⊢ or go Extended: ∧≢¨⊂⍤,⌸⊢

Retina, 31 27 23 bytes
Takes input as a newline-separated list of words (I haven't noticed that's allowed at first).
.+
$.& $&
N`
D`\d+
¶

I'll add the explanation later (for now, the previous revision's explanation without the first line works perfectly).
Try it online!

Is this what you were referring to as unary output? It looks okay to me.

@Sumner18 This is definitely not unary output :) I was planning to use it in the Retina answer I was planning to create, but decimal turned out to be shorter (in unary, the lengths would be basically runs of # characters instead of numbers)

That's what I thought, I guess I was just confused. My reasoning is that if a unary output could be a useful input in some other program, or if one could reason why unary labelling is valid/useful, then I believe it would be a satisfactory response.

Haskell, 59 56 bytes
l=length
f s=[(n,[x|x<-s,l x==n])|n<-[1..maximum$l<$>s]]

Try it online!

-3 bytes by using a list comprehension instead of a lambda, thanks to 79037662

This seems to work for 56 bytes, list comprehension is usually shorter than mapping with a lambda: https://tio.run/##FY3NasMwEITveQqh5pCAY2qEb1YJFFooGHIXpohEjtWs1kY/QQl5d3d1mZlvYXYmHW4GYHXaIpPM6aX/ZbvFW4ysZuOeqQ1T/HO@GF7x7xlGMo0XUrpZvJYwaQCDVxMIehM1H6pS6h/Ed@GLiXwWTSMwUnbvcRKewl9qC7fC30X5mFoStCjIFvt8Hgu//aQQ7dl8zf4EKc58GFaQZS9Om5EFqXZYqfzK3SFUwLKUOOxf2B1UU9dOZ@uS20K3/QhUXP8B

@79037662 Thanks, applied.

SimpleTemplate, 136 bytes
Yeah, it's a long one... The order of the output is what made it longer :/
{@setM 0}{@eachargv.0}{@callstrlen intoR _}{@setL.[R]L.[R],_}{@ifM is lowerR}{@setM R}{@/}{@/}{@forfrom 1toM}{@echo_}.{@echojl" " L.[_]}

Incredibly, it is easier (and shorter) to output that to return.
You can try it on http://sandbox.onlinephpfunctions.com/code/ec4bf4b3efa93c63c6c5c9f1458330da0178b6cd
(Line 974 has the words, line 976 has the golfed/ungolfed version variable)

Ungolfed:
{@set results}
{@set max 0}
{@each argv.0 as word}
    {@call strlen into length word}
    {@set results.[length] results.[length], word}
    {@if max is lower than length}
        {@set max length}
    {@/}
{@/}
{@for i from 1 to length}
    {@echo i}.{@echo separator " " results.[i], "\n"}
{@/}

Most of it should be easy to understand.

Wolfram Language (Mathematica), 30 bytes
KeySort@*GroupBy[StringLength]

Try it online!

Jelly, 6 8 bytes
ẈẈḢ,Ɗƙ⁸Ṣ

Try it online!
A monadic link which takes a list of Jelly strings and returns a list of lists where the first member of each list is the length and the second is a list of Jelly strings of that length. Plus 2 bytes now it’s been clarified that ordering of the list is mandatory.

I suppose I should clarify. Ordering the list is mandatory, direction is optional.

Pyth, 9 bytes
m+lhdd.gl

Try it online!
Port of @Shaggy's answer, so I cant really take credit for this (lol)
Pyth, 14 bytes
m+dfqdlTQSleol

Try it online!
Saves a few bytes by mapping a filtered list to each number in a 1-indexed range. This only saves 2 bytes due to the fact that the last two bytes can be implicit (would be m+dfqdlTQSleolNQ otherwise)
How it works
m+dfqdlTQSleol
m              - Map
 +d            - The sum of the element and...
   fqdlTQ      - The filtered input where each element of the input is length d
         Sl    - To the range [1, length]
           eol - of the last element of the ordered list by key=length
               - Print implicitly

Pyth, 16 bytes
FkSleolNQkfqklTQ

Try it online!
16 bytes seems a bit high for a challenge like this but oh well. Would be 14 bytes but it looks like the last 2 bytes cant be implicit due to how filter works in pyth
How it works
FkSleolNQkfqklTQ
Fk                 - For k in...
  Sl               - The range [1, length]
    eolN           - Of the last element of the sorted list by key=length
        Q          - Of the input
         k         - Print k
          fqklT    - Filter by key k == length...
               Q   - The input (prints implicitly)

Sorry if this answer is too long, I can cut it a bit if needed

PowerShell, 63 53 bytes
$a=@{};$args|%{$a[$_.length]+=" $_"};$a|% *or|sort N*

Try it online!
(-10 bytes thanks to mazzy)
Takes arguments via splatting, which on TIO manifests as separate command-line arguments.
We first construct an empty hashtable $a, then loop through the input arguments. Each item is tacked onto $a in the appropriate $_.length slot. Then comes the lengthy .GetEnumerator() followed by a sort to get the hashtable to print out in order. That's left on the pipeline and output is implicit.

Perl 5 (-040n), 45, 40, 34 bytes
-5 bytes thanks to Xcali
$a[y///c].=" $_"}{say$b++,$_ for@a

Try it online!

40 bytes if 0 can be included as an entry.  Either way, using \n as a delimiter can save a byte or two.

or adding -040n option to set space as record delimiter

Japt, 7 bytes
üÊ®uZÎl

Try it
üÊ®uZÎl // input as array of words
üÊ // group by length
  ® // for each group
   uZÎl // append length of 1st word

PHP, 62 bytes
for(;$w=$argv[++$i];ksort($a))$a[strlen($w)][]=$w;print_r($a);

Try it online!

J, 22 bytes
-2 bytes thaks to FrownyFrog
If the output can be a table with some empty boxes:
[:/:~#@>(,~#&.>@{.)/.]

Try it online!
J, 24 bytes
/:~@(#@><@(#@>@{.;])/.])

Try it online!
Just made it work - no doubt it can be golfed further.

The output from J is beautiful. Does it always look like this?

@Sumner18 It is boxed - J works on homogeneous arrays (vectors, tables and so on). When it is necessary to store data of different type (as it is now - numbers and lists of strings) and length, the data should be boxed

@Sumner18 Here is some examples of boxed vs regular arrays in J. Please note the trailing spaces/zeros  of the regular arrays. The boxed versions contain no fill.

[:/:~#@>(,~#&.>@{.)/.] if these empty boxes are acceptable

@FrownyFrog Thank you! Maybe this format is acceptable.

Another approach with the same number of bytes: /:~@((>;~0{#&>)/.~#&>)

@Traws This is also nice, thanks!

Scala, 30 42 bytes
Correction thanks to Value Ink
(s:String)=>s.split(" ").groupBy(_.length)

Try it online!

Welcome to the site! Unfortunately, assuming the input is already in a variable (in this case s) is not one of our Standard IO Methods. In addition, I notice that this doesn't print the value (it seems to require a call to print), meaning that this is a snippet, which doesn't conform to our rules

Thank you. Would replacing s with args[0] do the trick then? As for requiring a call to print, the runner I included displays the result without the call but not in stdout.

Also more generally, what is the standard for JVM languages here? One also needs class definitions, a main method etc. to get a 'non-snippet' so not sure what is deemed too much to exclude

Unfortunately, being a Python guy myself, I'm not to familiar with the site rules for other languages. However, if you have a look at some of the highest votes questions on Meta, you should be able to find the defaults/rules for other languages

I believe the correct format based on this tutorial on lambdas is (s:String)=>s.split(" ").groupBy(_.length). (You don't need to include the assignment portion val f= by our rules.) Try it online!

I don't know Scala, but isn't _.split(" ").groupBy(_.length) an anonymous lambda too? In the same way as _.length?

RPL, 60+10 bytes
Let's explore more creative output formats:
DUP«SIZE»DOLIST SWAP 2«STR→ X ROT ^ *»DOLIST ΣLIST EXPANDMOD

turns the list {"Code" "Golf" "and" "Coding" "Challenges" "Meta"} into the polynomial
Challenges·X10+Coding·X6+(Code+Golf+Meta)·X4+and·X3 thanks to EXPANDMOD.
Sadly to allow exotic names like pizz@5 – just for you to know, @ introduces comments – STR→ must be replaced by #5B15h SYSEVAL adding 10 bytes to the source code, and obfuscating the call. That does however allow printable and even non printable chars, the latters only displayed as black squares but not lost. So the garbage resistant code is
DUP«SIZE»DOLIST SWAP 2«#5B15h SYSEVAL X ROT ^ *»DOLIST ΣLIST EXPANDMOD

(EXPANDMOD is present in HP50g at least. Tested with Emu48 in 50g mode.
The code page is documented here).

JULIA
Some 55 bytes:
H(l,L=length.(l))=sort([(v,l[L.==v]) for v in Set(L)])

Try it online

JavaScript (ES6), 53 bytes
Takes input as a list of words. Returns an object whose keys are the lengths and whose values are the lists of corresponding words.
a=>a.map(w=>(o[n=w.length]=o[n]||[]).push(w),o={})&&o

Try it online!

Red, 107 bytes
func[a][m: copy#()foreach w sort a[k: length? w
unless m/:k[put m k copy[]]append m/:k w]sort/skip to[]m 2]

Try it online!

C# (Visual C# Interactive Compiler), 48 bytes
a=>a.GroupBy(k=>k.Length,v=>v).OrderBy(g=>g.Key)

Try it online!
-1 byte thanks to @dzaima
-43 bytes if returning the raw grouping is allowed, thanks to @someone
-18 bytes by switching to the Visual C# Interactive Compiler

I think you can simply return the results of the OrderBy.

@someone, It's kind of unclear but I'll add that as a third option too

APL(NARS), chars 34, bytes 68
{a,⍨¨↑¨≢¨¨a←a⊂⍨≢¨a←a[⍋a←⍵⊂⍨' '≠⍵]}

test:
  f←{a,⍨¨↑¨≢¨¨a←a⊂⍨≢¨a←a[⍋a←⍵⊂⍨' '≠⍵]}
  ⎕fmt f 'Code Golf and coding challenges Meta'
┌4──────────────────────────────────────────────────────────────────────┐
│┌2───────┐ ┌4────────────────────────┐ ┌2──────────┐ ┌2───────────────┐│
││  ┌3───┐│ │  ┌4────┐ ┌4────┐ ┌4────┐│ │  ┌6──────┐│ │   ┌10─────────┐││
││3 │ and││ │4 │ Code│ │ Golf│ │ Meta││ │6 │ coding││ │10 │ challenges│││
││~ └────┘2 │~ └─────┘ └─────┘ └─────┘2 │~ └───────┘2 │~~ └───────────┘2│
│└∊───────┘ └∊────────────────────────┘ └∊──────────┘ └∊───────────────┘3
└∊──────────────────────────────────────────────────────────────────────┘
  ⎕fmt f 'My v3ry 3xc13nt m0th3r 53rv3d u5 pzz@5 #Ju'
┌6─────────────────────────────────────────────────────────────────────────────────────────┐
│┌3────────────┐ ┌2───────┐ ┌2────────┐ ┌2─────────┐ ┌3────────────────────┐ ┌2───────────┐│
││  ┌2──┐ ┌2──┐│ │  ┌3───┐│ │  ┌4────┐│ │  ┌5─────┐│ │  ┌6──────┐ ┌6──────┐│ │  ┌7───────┐││
││2 │ My│ │ u5││ │3 │ #Ju││ │4 │ v3ry││ │5 │ pzz@5││ │6 │ 53rv3d│ │ m0th3r││ │7 │ 3xc13nt│││
││~ └───┘ └───┘2 │~ └────┘2 │~ └─────┘2 │~ └──────┘2 │~ └───────┘ └───────┘2 │~ └────────┘2│
│└∊────────────┘ └∊───────┘ └∊────────┘ └∊─────────┘ └∊────────────────────┘ └∊───────────┘3
└∊─────────────────────────────────────────────────────────────────────────────────────────┘

Lua, 85 94 bytes
changed to to function format +9 bytes
r={}m=0 for j=1,#i do w=i[j]l=#w m=l>m and l or m c=r[l]r[l]=c and w..","..c or w end return r

Try it online!

Welcome to the site! The output format in this challenge is pretty loose so you could probably save some bytes if you move the print part to the footer in TIO.

Allright then, thanks for the hint. Im new to this so im learning :D

Python 3, 81 bytes
Outputs a dictionary instead of a list or tuple:
lambda s:dict(sorted((len(x),list(filter(lambda y:len(y)==len(x),s)))for x in s))

Try it online!

Röda, 53 bytes
{a=new map;a[#_]+=_1 if[a[#_1]?]else a[#_1]=[_1];[a]}

Try it online!
Explanation
{a=new map;a[#_]+=_1 if[a[#_1]?]else a[#_1]=[_1];[a]}
{                                                   } anonymous function
 a=new map;                                           let a be a hash map
                                                      for each _1:
                     if[       ]else            ;     if
                        a[#_1]?                         a[length(_1)] exists
           a[#_]+=_1                                  then append _1 to a[length(_1)]
                                     a[#_1]=[_1]      else a[length(_1)] = [_1]
                                                 [a]  return a

Husk, 8 bytes
mṠ,oL←kL

Try it online!
so close..

Arturo, 32 bytes
$=>[gather arrange&=>size=>size]

Try it

Python 3, 64 bytes
lambda x:{i:[*filter(lambda a:len(a)==i,x)]for i in range(1,11)}

Try it online!

Zsh, 52 bytes
for i;printf \ $i>>$#i;(for j (*)<<<$j`<$j`)|sort -n

Try it online!
For each argument/word i, append to a file called $#i (length of i).
For each resulting file j (*), print the filename <<<$j and contents <$j, and sort.


text:
Unique magic triplets
Description
Your input is a list of integers \$[a_1, \dots, a_n]\$.
A magic triplet is a triplet \$(a_i, a_j, a_k)\$ of values from this list, such that

the indices \$\{i, j, k\}\$ are all distinct,
the values are in ascending order (\$a_i \leq a_j \leq a_k\$), and
the sum of two of the values equals the third.

Your task is to output all unique magic triplets, in any order.
Rules

Each number in the input list is guaranteed to be in the range \$-2^{32} \leq a < 2^{32}\$.
The input list's length is guaranteed to be at most 1000.
The input list's length may be less than 3 (even 0). In this case, there are no magic triplets, and your program should produce an empty result.
The shortest answer in bytes wins.

Test cases
[1,2,3,2,4] -> [[1,2,3], [1,3,4], [2,2,4]]
[0,0,0,0] -> [[0,0,0]]
[1,0,-1] -> [[-1,0,1]]
[1,2] -> []
[1,2,4,8,99] -> []
[33,90,7,24,60,32,80,43,15,40,36,90,65,12,91,33,88,1,96,33,40] -> [[7,33,40], [32,33,65], [1,32,33], [1,90,91], [7,36,43], [24,36,60], [12,24,36], [36,60,96], [15,65,80], [40,40,80]]

Notes

In the second test case, [[0,0,0], [0,0,0]] is not a valid answer. No triplet may be listed twice in the output.
Remember that your program may order the triplets differently. For example, [[2,2,4], [1,2,3], [1,3,4]] is also a valid output for the first test case.
Nonetheless, [[4,2,2], …] is invalid: each triplet itself must be in ascending order.

Hey @chaugiang, I rewrote your question for clarity, and to be a bit more in the codegolf.SE “style”.  If you disagree with my rewrite, feel free to roll it back (or fix what you dislike about it).

@Lynn Thank you a lot for your contributions.

Ruby, 46 51 58 bytes
->l{l.permutation(3).select{|a,b,c|a+b==c}.map(&:sort)|[]}

Try it online!
Ok, not so straightforward, but now seems to work.

I'm afraid this works only for input array already sorted ascending, which is not guaranteed by the challenge. For example from test case E it finds only 5 sets while 10 are expected.

You are right. Fixed now.

Yepp, that was the easy fix. But handling negative numbers like in test case B [1, 0, -1] may be harder. ☹

Oops. Fixed again.

05AB1E, 11 10 9 10 bytes
{æ3ùêʒxsOå

+1 byte as bugfix for test cases like [1,0,-1] → [[-1,0,1]] (-1+1=0) and [-1,-2,-3] → [[-3,-2,-1]] (-1+-2=-3).
Try it online or verify all test cases.
Explanation:
{           # Sort the (implicit) input-list from lowest to highest value
 æ          # Take the powerset of this sorted list
  3ù        # Only keep inner lists of length 3
    ê       # (Sort and) uniquify this entire list of triplets
     ʒ      # Filter this list of (individually sorted) triplets by:
      x     #  Double each value in the triplet (without popping the triplet itself)
       s    #  Swap to get the original triplet
        O   #  Take the sum of this triplet
         å  #  And check whether this value is in the doubled list
            # (after which the filtered list is output implicitly as result)

The last four bytes could alternatively be œÆ0å (given by @Grimy): Try it online or verify all test cases.
      œ     #  Get all possible permutations of the triplet
       Æ    #  Reduce each by subtracting: [a,b,c] → a-b-c
        0å  #  And check if there are any 0s among the reduced permutations

xsOå can also be œÆP>. Same byte-count, but more stylish.

@Grimmy The Æ was also in my 9-byter. :) I've added it (with 0å instead of P>, since it's a bit more logical to me what's being checked). PS: It might be more stylish, but I think that permutations builtin would decrease the performance slightly, though. :)

Jelly, 10 bytes
Ṣœc3ḤiSƊƇQ

Try it online!
Ṣ             Sort the input,
 œc3          find all length-3 subsequences,
        Ƈ     filter to only the sets for which
      S       the sum of all three elements
     i        is an element of
    Ḥ  Ɗ      the set with all elements doubled,
         Q    and uniquify.

Brachylog, 11 bytes
{o⊇Ṫ.+/₂∈}ᵘ

Try it online!
Takes input through the input variable and outputs through the output variable.
{        }ᵘ    Output every unique output from:
    .          the output is
  ⊇            a subsequence
   Ṫ           of length 3
{              of the input
 o             sorted
     +         the sum of which
      /₂       divided by 2
        ∈      is an element of
         }     the output.

[2,2,4] shouldn't be a magic triplet. I think you can fix by replacing the sort by distinct.

The challenge spec only requires that the indices are distinct, and that the values within the triplet are non-decreasing (although it uses the word "increasing"). Note that the first test case contains two 2s and expects [2,2,4] to be output, and the fifth test case only contains one 2, so expects [2,2,4] to not be output.

by bad, I didn't read the question properly.

Japt, 13  11 bytes
á3 k_r-ÃmÍâ

Try it
á3 k_r-ÃmÍâ // input as arrays
á3            // all unique permutations
  k_          // save list that..
    r-Ã       // reduced by - from first element
         mÍ   // ==mn   => sort all
              â // remove duplicates

Thanks to @Shaggy and @Embodiment of Ignorance for saving 2

12 bytes: https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=4TMga19yLcNtbiDi&input=W1sxLCAyLCAzLCAyLCA0XSwKIFsxLCAwLCAtMV0sCiBbMSwgMl0sCiBbMSwgMiwgNCwgOCwgOTldLAogWzMzLCA5MCwgNywgMjQsIDYwLCAzMiwgODAsIDQzLCAxNSwgNDAsIDM2LCA5MCwgNjUsIDEyLCA5MSwgMzMsIDg4LCAxLCA5NiwgMzMsIDQwXSwKIFstMSwgLTIsIDksIDgsIDMsIDYsIDE3LCAyMCwgLTRdLAogWzAsIDAsIDAsIDAsIDFdCl0KLVEKLW0. Using r- is very clever!

11 bytes

@Embodiment of Ignorance thanks, it's been a while since I wanted to use it ! Forgot that sort can be just mn!

Very nicely done, by the way. I took a quick, uncaffeinated stab at this this morning and ended up around 15 bytes.

@Shaggy thanks for all the help given!

Perl 6, 65 64 bytes
*.combinations(3)>>.sort.grep({@$_.sum==2*.any}).unique(:as(~*))

Try it online!
*.combinations(3)               # All the combinations of length 3
                 >>.sort        # Sorted
                        .grep({               }) # Filtered by
                              {@$_.sum==         # The sum is equal to
                                        2*.any   # Double any element
                                                .unique(:as(~*))  # And take the unique lists

Flooring the halved sum adds (0 0 1) to the new last test case ([0,0,0,0,1]).

...actually it adds a bunch of stuff to several test cases. I thought this might work as a fixed version, but 1. I don't actually know Perl and 2. it's missing (40 40 80) from the [33, 90, 7, 24, 60, 32, 80, 43, 15, 40, 36, 90, 65, 12, 91, 33, 88, 1, 96, 33, 40] case.

@UnrelatedString Rolled back to a previous version. That test case was modified later (OP added the second 40), so I had the old version.

Ah, makes sense.

JavaScript (Node.js),  118 116  115 bytes
Returns a set.
a=>new Set(a.flatMap((x,i)=>a.flatMap((y,j)=>j-i&&~(k=a.indexOf(x+y))&&k-i&&k-j?[x,y,x+y].sort((a,b)=>a-b)+'':[])))

Try it online!
Commented
a =>                             // a[] = input array
  new Set(                       // create a set:
    a.flatMap((x, i) =>          //   for each value x at position i in a[]:
      a.flatMap((y, j) =>        //     for each value y at position j in a[]:
        j - i &&                 //       if j is not equal to i
        ~(                       //       and the position k
          k = a.indexOf(x + y)   //       of x + y in a[]
        ) &&                     //       is not equal to -1
        k - i &&                 //       and k is not equal to i
        k - j ?                  //       and k is not equal to j:
          [x, y, x + y]          //         build the triplet (x, y, x + y)
          .sort((a, b) => a - b) //         sort it in ascending order
          + ''                   //         and coerce it to a string
        :                        //       else:
          []                     //         yield an empty array
      )                          //     end of inner flatMap()
    )                            //   end of outer flatMap()
  )                              // end of Set()

Python 3, 94, 89, 88, 85 bytes
One byte saved thanks to frank.
lambda l:{p for p in combinations(sorted(l),3)if sum(p)/2in p}
from itertools import*

Try it online!

Haskell, 78 bytes
import Data.List
f x=nub[y|y@[a,b,c]<-subsequences$sort x,or[2*z==sum y|z<-y]]

Try it online!

K (oK), 38 bytes
{?{x@<x}'({z=x+y}.)#x@/:{x~?x}#+!3##x}

Try it online!

Charcoal, 66 bytes
ＦＬθＦＬθＦＬθＦ¬⌈⟦⁼ικ⁼ιλ⁼κλ›§θι§θκ›§θκ§θλ⟧«≔Ｅ⟦ικλ⟧§θνη¿∧№η⊘Ση¬№υη⊞υη»Ｉυ

Try it online! Link is to verbose version of code. Explanation:
ＦＬθＦＬθＦＬθＦ¬⌈⟦

Loop through all triples of indices...
⁼ικ⁼ιλ⁼κλ

... checking whether the indices are distinct...
›§θι§θκ›§θκ§θλ

... and that the triplet is in ascending order...
⟧«≔Ｅ⟦ικλ⟧§θνη

... if so then save the triplet in a variable...
¿∧№η⊘Ση¬№υη⊞υη

... and if it contains its halved sum and is unique then remember it in a list.
»Ｉυ

After checking all triplets output the unique magic triplets double-spaced with each triplet member on its own line.

JULIA
A solution w/o external package:
F(l)=(n=length(sort!(l));a=Set();
for i=1:n,j=1:n,k=1:n i<j<k&&(v=l[[i,j,k]];sum(v) in 2v)&&push!(a,v)end;
[a...])

Not a nice one 115 bytes of code (with 2 extra newlines for readability).
A solution using the non-core package Combinatorics:
using Combinatorics
H(l)=[Set(v for v in combinations(sort(l),3) if sum(v) in 2v)...]

Length 85 bytes (or 84 if you omit the space before the '''if''')
You can REPLIT online.

Welcome to CG&CC! I tried running your solution online, but the Combinatorics package doesn't seem to be installed on TIO. I don't think there's any problem with using non-standard libraries so long as you mention them in the language header, but it might be a good idea to also write a solution that can be more easily verified.

Java 10, 225 bytes
import java.util.*;L->{var r=new TreeSet();for(int j,k,a,b,t[],i=L.size();i-->0;)for(j=i;j-->0;)if((k=L.indexOf((a=L.get(i))+(b=L.get(j))))>=0&k!=i&k!=j){Arrays.sort(t=new int[]{a,b,a+b});r.add(Arrays.toString(t));}return r;}

Port of @Arnauld's JavaScript answer, just twice as long.. >.>
Try it online.
Explanation:
import java.util.*;       // Required import for the TreeSet and both Arrays
L->{                      // Method with integer-List as parameter & sorted Set as return
  var r=new TreeSet();    //  Result-set, starting uninitialized
                          //  A Set will automatically remove duplicates
                          //  (and a TreeSet will automatically sort, which is irrelevant,
                          //   but it's the same size as a regular HashSet anyway)
  for(int j,k,a,b,t[],    //  Temp integers
      i=L.sisze();i-->0;) //  Loop `i` in the range (input-length, 0]:
    for(j=i;j-->0;)       //   Inner loop `j` in the range (`i`, 0]:
      if((k=L.indexOf((a=L.get(i))
                          //    Set `a` to the `i`'th value in the list
          +(b=L.get(j))   //    Set `b` to the `j`'th value in the list
                          //    And add `a` and `b` together
         ))               //    Set `k` to the index of this sum
           >=0            //    If the index `k` is NOT -1
         &k!=i&k!=j){     //    And `k` is also NOT `i` nor `j`:
        Arrays.sort(t=new int[]{a,b,a+b});
                          //     Create an array `t` with items [a,b,a+b],
                          //     and sort the values of this triplet
        r.add(Arrays.toString(t));}
                          //     Then convert this array to a String,
                          //     and add it to the result-TreeSet
  return r;}              //  After the nested loop: return the result-TreeSet

Pyth, 13 bytes
{f}csT2T.cSQ3

Try it online!
Port of the solution thats been floating around.
How it works
{f}csT2T.cSQ3
        .c  3  - All combinations length 3 of...
          SQ   - The sorted input
 f             - Filtered such that...
   csT2        - Half the sum of each combination...
  }    T       - Is an element of the original combination
{              - Remove duplicates

Pyth, 15 bytes
{mSdfqsPTeT.PQ3

Try it online!
Less sophisticated solution. Posting it because I think it can be golfed more
How it works
{mSdfqsPTeT.PQ3
           .PQ3 - All 3 element permutations of the input
    f           - Filtered such that
      sPT       - The sum of the first 2 inputs...
     q   eT     - Is equal to the last input
 mSd            - Sort all elements
{               - Remove duplicates


text:
ASCII texturing
Write a function or a full program that applies an ASCII  texture  to a 2d shape.
Inputs: shape, texture, dimensions(optionally).

Both Shape and Texture can be given by any convenient method (2d matrix, array of strings or string with newlines)
Shape data have a rectangular shape and contains 2 possible values: [truthy/falsey] binary/integer values (0/1 or n1/n2) or 2 different characters, just specify which one represent the shape parts [truthy] and which one represent the blank parts [falsey] and be consistent .
The texture has a square shape only (width ≡ height) and contains printable ASCII characters.
Optionally you can also pass dimensions of the matrices if needed.

Output: the shape with each truthy value substituted with the corresponding texture value (coordinates/indices mod texture size), the blank parts must be substituted with spaces.

The ratio is always 1:1
The entire shape must be covered and only the shape.
No offset, texturing must start at top-left corner (0,0) of the shape data with the origin of the texture also at the top-left corner.

Examples (using various shape formats in JSON)
Shape
[[0,0,1,1,0,0],
 [0,1,1,1,1,0],
 [0,1,1,1,1,0],
 [0,0,1,1,0,0]]

Texture
["/\\",
 "\\/"]

Output
["  /\  ",
 " /\/\ ",
 " \/\/ ",
 "  \/  "]

Shape
["        xxxxxxxx     ",
 "  xxxxxxxxxxxxxxxx   ",
 "    xxxxxxxxxxxxxxxx ",
 "  xxxxxxxxxxxxxxxxxxx",
 "xxxxxxxxxxxxxxxxxxxxx",
 "xxxxxxxxxxxxxxxxxxxxx",
 "xxxxxxxxxxxxxxxxxxxxx",
 "xxxxxxxxxxxxxxxxxxxxx"]

Texture
["[__]",
 "_][_",
 "[__]",
 "_][_"]

Output
["        [__][__]     ",
 "  [__][__][__][__]   ",
 "    [__][__][__][__] ",
 "  [__][__][__][__][__",
 "[__][__][__][__][__][",
 "_][__][__][__][__][__",
 "[__][__][__][__][__][",
 "_][__][__][__][__][__"]

Shape
[0,0,0,1]

Texture
["ab",
 "ba"]

Output
["   b"]

Shape
["11100001011010",
 "01111010101101",
 "01011011111101"]

Texture
["   ./]| |  / /.",
 "_|_|[]|/|_/\\_|/",
 "_|_|[/|_|_\\/_|.",
 "./_./]|_|//\\/./",
 "_|_|[]|/|_/\\_|/",
 "_|_|[]/ | \\/_|.",
 " /_  /|_|//\\/3/",
 "_|_|[]|/|_/\\_|/",
 "_|_|/ |_|_\\/_|.",
 "./_$/]|_|//\\/./",
 " |_|  |/|_/\\_|/",
 "_|_|[/|_|_\\$_|/",
 "_/  /]|_/ /\\///",
 "_|_/[]|/|/ \\_|/",
 "_|/|[/|_|_ /_||",
 " /_./]|_|  \\/|/"]

Output
(a surprise for you!)
Rules

Input/output can be given by any convenient method.
You can print it to STDOUT or return it as a function result.
Either a full program or a function are acceptable.
Extraneous whitespace are forbidden.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Sandbox post

APL (Dyalog Unicode), 20 12 bytesSBCS
-6 bytes through dzaima
Full program. Prompts stdin for:

texture as a list of strings
number of rows in shape matrix
number of columns in shape matrix
indices of falsies (to be blanks) in the shape matrix

All the ⎕s are supposed to be rectangles (they're not tofu). They symbolise a computer console which here means prompt for array input via stdin.
' '@⎕↑⎕⍴¨⎕⍴⎕

Try it online!
⎕ prompt for texture as a list of strings; ["/\\","\\/"]
⎕⍴ prompt for number of rows in shape matrix (4) and use that to cyclically reshape the texture (this gives us enough texture lines); ["/\\","\\/","/\\","\\/"]
⎕⍴¨ prompt for number of columns in shape matrix (6) and use that to cyclically reshape each of the texture lines (this gives us enough characters in each texture line); ["/\\/\\/\\","\\//\\/\\","/\\/\\/\\","\\//\\/\\"]
↑ combine the list of lines into a character matrix;
  ["/\/\/\"
   "\//\/\"
   "/\/\/\"
   "\//\/\"]
' '@⎕ prompt for indices for blanks ([[0,0],[0,1],[0,4],[0,5],[1,0],[1,5],[2,0],[2,5],[3,0],[3,1],[3,4],[3,5]]) and then place blanks at those indices;
    /\
   //\
   //
    /

Canvas, 9 bytes
ｍ⤢ｍ⤢；ｎ← ╋

Try it here!
Abusing that the input will be ASCII and so won't contain ←, but the shape is made of spaces and ← for easy overlapping and replacement. Alternative 12 bytes taking shape as space and #.

Japt, 10 bytes
ËmÈ?VgEY:S

Try it
ËmÈ?VgEY:S       U = shape as 2d array, V = texture as list of lines
Ë                Map each row, define E as row number
 mÈ                Map each element in these rows, define Y as element number
   ?                 Is the value a 1?
    VgEY               Get the character at texture[E,Y]
        :S           Else return a space if the value is a 0

You don't need the space before the :

@Shaggy Somehow I missed that. Thanks!

J, 32 bytes
4 :'y}'' '',:x({.@]$($"1~{:))$y'

Try it online!
Some notes:

This was a rare case where I got a shorter solution with an explicit, rather than tacit, verb.
I wanted a solution that didn't prompt for input (ie, didn't want to just translate Adam's excellent APL solution into J).

05AB1E, 11 bytes
εNUεiXèNèëð

Port of @EmbodimentOfIgnorance's Japt answer, so make sure to upvote him!
Inputs as defined in the first format of the challenge. Output as a character-matrix.
Try it online or verify all test cases. (Footer will pretty-print the character-matrix, feel free to remove it to see the actual output.)
Explanation:
ε          # Map over the rows of the (implicit) integer-matrix:
 NU        #  Push the map-index, and then pop and store it in variable `X`
   ε       #  Inner map over the cells of the current row:
    i      #   If the value of the current cell is a 1:
     Xè    #    Use variable `X` to index into the (implicit) input-list of strings,
           #    with automatic wraparound
       Nè  #    And then use the inner map index to index into this string
    ë      #   Else:
     ð     #    Push a space instead

Haskell, 51 49 bytes

The texture and shape are provided in the format used by the first example.
This works even if the texture isn't square or contains unprintables.
Dimensions do not need to be passed.
-2 bytes by abbreviating zipWith to z.

f=z(z(%)).cycle.map cycle
z=zipWith
_%0=' '
x%_=x

Try it online!

J, 19 bytes
]]&' '"+]g"1~g=:$~#

Try it online!
Dyadic train. Left argument is texture, right argument is shape, 1 is blank, 0 is fill.
How it works
I extended the dyadic & trick to the "If" usage of ^:, i.e. boolean repetition amount. Also, an assignment =: can group the part of the train on its right, saving a pair of parens.
]]&' '"+]g"1~g=:$~#  Left argument: texture, Right argument: shape
                $~#  Repeat the texture's rows to fit the shape's rows
             g=:     Assign this sub-function to g
        ]g"1~        Use g to do the same on columns
]     "+             For each cell on the texture and shape,
 ]&' '                 Replace the texture's cell with ' ' if shape's cell is 1
                       Keep the texture if shape's cell is 0

Icon, 100 97 bytes
procedure f(t,s)
i:=0&r:=|!t\*s&i+:=1&j:=0&c:=|!r\*!s&s[i,j+:=1]:=[" ",c][s[i,j]]&\z
return s
end

Try it online!
Uses 1 for spaces and 2 for textured in shape data.
Explanation:
procedure f(t,s)                   ; t - texture, s - shape data
    i:=0 &                         ; i is the row index
    r:=|!t\*s &                    ; repeats the rows of the texture as many times as the rows of the shape data
    i+:=1 &                        ; next row
    j:=0 &                         ; j is the column index; reset to start
    c:=|!r\*!s &                   ; repeats the characters of each row of the texture as many times as the row of the shape
    s[i,j+:=1]:=[" ",c][s[i,j]] &  ; modify the shape data ot " " or to texture
    \z                             ; z is not declared and thus causes Icon to backtrack
    return s                       ; return the modified shape data
end

Julia 1.0, 68 bytes
f(s,t,n,Y,X)=[t[y,x] ? s[mod1(y,n),mod1(x,n)] : ' ' for y=1:Y,x=1:X]

Takes the shape as a 2d array of characters, the pattern as a array of Bools, and the dimensions (because length is long). Returns a character array via array comprehension.
Try it online!

Charcoal, 16 bytes
Ｆθ«ＦΣιＧ→¹η¿›0ι⸿→

Try it online! Link is to verbose version of code. Takes input as newline-delimited strings. Explanation:
Ｆθ«

Loop over the shape.
ＦΣι

If the value is a 1...
Ｇ→¹η

... then draw a 1x1 polygon filled using the template. Conveniently in Charcoal the fill is always relative to the origin of the canvas. Unfortunately Charcoal can't draw zero-sized polygons or Oblongs of sides less than 2, otherwise I could save a couple of bytes here.
¿›0ι

If this is a newline...
⸿

... then move to the start of the next line of the canvas...
→

... otherwise move forward on the current line.

Jelly, 13 bytes
JṁJ}ị⁸ṁ"⁹a@o⁶

Try it online!
A dyadic link taking a list of Jelly strings for the texture as its left argument and an integer matrix for the shape as its right argument. Returns a list of Jelly strings.

Ruby, 65 bytes
->s,p,w,h{s.zip(p*h).map{|a,b|a.zip(b*w).map{|x,y|x>0?y:' '}*''}}

Try it online!
Input: Matrix of 0 and 1, texture as 2d array of characters, size of the matrix (width and height).

Japt, 9 bytes
ËmÈù1VgEY

Try it

Python 2, 97 94 86 bytes
lambda S,P,w:[''.join([' ',P[j%w][i%w]][v]for i,v in E(s))for j,s in E(S)]
E=enumerate

Try it online!
3 bytes thx to frank
Takes the shape as S, a list list of 0/1;the texture P as a list of strings; and w as the width/height of P. Returns a list of strings.

Texture is guaranteed to be square so you can just do i%len(P)

@frank - ah thanks, I missed that!