The Random Walker Printer Draw a program or function that will write to STDOUT n times (each for one step) a string that contains a dot . at the location of the walker. The program also needs to write a line every s seconds (or wait s seconds after each line).

A random walk is a mathematical formalization of a path that consists of a succession of random steps (wiki), such that every new step will be the last step plus a new value, so any tstep value is just the sum of all the random values before ir plus the initial value.

The program should take 2 inputs and will use only spaces " " and dots "." on the output. The start value of the walker will be 20 such that the output should be a dot after 19 spaces.

                  . #19 spaces then a dot

Every new step the value will be the last value of the walker plus one of these[-2-1,0,1,2](20% chance each). After the new position is printed the program should wait s seconds and the go to the next step. If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same. The number of spaces will always be a number from 0 to 39.

Example

#input
Mywalk(s = 0.1, n = 30)

#output
                     .
                    .
                      .
                        .
                          .
                           .
                            .
                          .
                         .
                          .
                           .
                            .
                           .
                          .
                           .
                           .
                         .
                         .
                          .
                            .
                           .
                          .
                           .
                           .
                           .
                         .
                          .
                         .
                          .
                          .

Considerations

You may take the input as any reasonable format
The shortest code wins
It's okay if your program only accept the seconds as integers

Matlab, 112
The core idea is generating a list of possible next positions and then uniformly drawing one of them. If we are e.g. at position $l=1$ the possible steps would be [-1,0,1,2,3] Of course if we would chose -1 that would be invalid and we would have to stay at the same position. Thats why we replace the invalid positions with the current position, [1,0,1,2,3], and then randomly chose an element from this updated list.
The OP asked us tho draw the program, so here we go:

The transcription:
function c(n,s);
l=19;                             %initialize position
for k=1:n;
    disp([ones(1,l)*32,'.']);     %print the line
    z=(-2:2)+l;                   %get vector of possible next steps (for l=1 we get [-1,0,1,2,3])
    z(z<0)=l;                     %prune invalids: here we just replace the the invalid positions with the current position
    z(z>39)=l;                    %   this ensures the same behaivour as staying in the same spot when going outside of the range
    l=z(randi(5));                %draw random sample of those
    pause(s);
end


Contiguous Block Count Count the number of contiguous blocks within a given 3D input.

Input

The input will consist of one or more rectangles of characters separated by blank lines. Each rectangle represents a cross section of the 3D space. The characters used will be 0, representing empty space, and 1 representing a solid block.

Example

00000
01110
01110
01110

00000
01110
01110
01110

00000
01110
01110
01110

In the above example we have a 3x3 cube - the bottom layer first, then the middle and then the top.

Output

The output should be a single integer giving the number of contiguous blocks within the input.

What's considered contiguous?

If any two 1s are adjacent to each other to the front, back, left, right, top or bottom, they are considered to be part of the same contiguous block. If they are not adjacent or they are only adjacent diagonally, they are not considered to be part of the same block.

Examples

00
11

Contiguous.

10
10

Contiguous.

10
01

Not contiguous.

01
00

01
00

Contiguous.

01
00

00
01

Not contiguous.

01
00

00
10

Not contiguous.

01
00

10
00

Not contiguous.

Test inputs

11101110111
10000011100

00111000000
00000000000

Result: 1

111
111
111

000
010
000

111
111
111

Result: 1

111
111
111

100
000
000

101
011
111

Result: 2

11011011011
00100100100

11011011011
00100100100

00100100100
11011011011

00100100100
11011011011

Result: 14

11011011011
01100100110

11011011011
00100100100

00100100100
11011011011

00100100100
11011011011

Result: 12

11011011011
00100100100

11011011011
01100100110

00100100100
11011011011

00100100100
11011011011

Result: 10

11111
10001
10001
10001
11111

Result: 1

11111
10001
10101
10001
11111

Result: 2

11111
11111
11111
11111
11111

11111
10001
10001
10001
11111

11111
10001
10001
10001
11111

11111
10001
10001
10001
11111

11111
11111
11111
11111
11111

Result: 1

11111
11111
11111
11111
11111

11111
10001
10001
10001
11111

11111
10001
10101
10001
11111

11111
10001
10001
10001
11111

11111
11111
11111
11111
11111

Result: 2

11111
11111
11111
11111
11111

11111
10001
10001
10001
11111

11111
10001
10101
10001
11111

11111
10001
10101
10001
11111

11111
11111
11111
11111
11111

Result: 1

Input format

I'm happy to be slightly flexible on the input format, so if you want to take a list of strings as input instead of one continuous string that's okay, and if you want to take a list of lists of characters (or integers if that helps) that's okay too.

Your answer can be a full program reading input or a function taking the input as a parameter. If your anonymous function needs a name in order for me to call it, then the characters for assigning the function to a name need to be counted too.

This is code golf so shortest code in bytes will win the big green tick, but any answer that meets the spec, passes the tests and has obviously been golfed will get my upvote.

APL, 83 bytes

{0=⍴o←(,G)/Z←,⍳⍴G←⍵:0⋄1+∇G⊣{G[⊂⍵]←0⋄0=⍴A←G[A]/A←(A∊Z)/A←⍵∘+¨(+,-)↓∘.=⍨⍳3:⍬⋄∇¨A}⊃o}

Unlike some other languages, APL does not have a built-in for this (that I know of).

This function takes a 3-dimensional array of bits. It uses a 3-dimensional flood fill to remove blocks one by one, and counts how many blocks it can remove before the input is empty.

Non-golfed version with comments here.


Pong in the shortest code The challenge is simple. Give the shortest code possible to reproduce the classic 2-player game of pong http://en.wikipedia.org/wiki/Pong .  The level of graphics and functionality should be as close as possible to this javascript demonstration http://codeincomplete.com/posts/2011/5/14/javascript_pong/demo.html (but without the extra options you can click on on the left or the frame, fps etc. information in the bottom right).

As always the code must be written in a free language (in both senses) and should be runnable on linux. Any libraries used must also be free, easily available and not be written for the purposes of this competition (and also not already contain a working version of Pong!).

sed, 35

Raising the bar a bit with a postage-stamp sed meditation.

s/> / >/
s/ </< /
s/0</0>/
s/>1/<1/

The meditation is enjoyed on stdin/stdout on two computers, not necessarily connected by a network.  The meditation begins in the state

0         <       1

with guru zero on the left and one on the right.  The angle bracket moves left and right, and if a guru maneuvers their number to contact the cursor as it comes to their side, their score is increased by one, and they become elated with joy.

The meditation is initiated by typing the above state into sed -f medi.sed, and the computer responds with the next state.  The dutiful guru types that state into the meditation, reading aloud the next key they will press, with both gurus pressing the holy key to enter the future at the same time.  The dutiful computer replies with the next state.  This, in turn, is read aloud while typed in unison as with the last.  Continue advancing into the future until infinite bliss is achieved.

Gurus desiring a challenge may play 'turbo' mode, wherein the gurus attempt to collaboratively predict the computer's next state, and typing it into the prompt instead of the current state.  Gurus will have the wisdom to verify agreement between their predictions before entering the future.


Golf the xᵗʰ root of x While bored in high-school (when I was half my current age...), I found that \$f(x) = x^{x^{-1}}\$ had some interesting properties, including e.g. that the maximum \$f\$ for \$0 ≤ x\$ is \$f(e)\$, and that the binding energy per nucleon of an isotope can be approximated as \$6 × f(x ÷ 21)\$...
Anyway, write the shortest function or program that calculates the xth root of x for any number in your language's domain.
Examples cases
For all languages
     -1   >       -1
   ¯0.2   >    -3125
   ¯0.5   >        4
    0.5   >     0.25
      1   >        1
      2   >    1.414
      e   >    1.444
      3   >    1.442
    100   >    1.047
  10000   >    1.001

For languages that handle complex numbers
   -2   >        -0.7071i
    i   >            4.81
   2i   >    2.063-0.745i
 1+2i   >   1.820-0.1834i
 2+2i   >   1.575-0.1003i

For languages that handle infinities
-1/∞   >   0    (or ∞ or ̃∞)
   0   >   0    (or 1 or ∞)
 1/∞   >   0
   ∞   >   1
  -∞   >   1

For languages that handle both infinities and complex numbers
 -∞-2i   >   1      (or ̃∞)

 ̃∞ denotes directed infinity.

TI-BASIC, 3 bytes

Ans×√Ans

TI-BASIC uses tokens, so Ans and ×√ are both one byte.

Explanation

Ans is the easiest way to give input; it is the result of the last expression. ×√ is a function for the x'th root of x, so for example 5×√32 is 2.


Align the text to a block Task

Your task is to write whole program, which will align given input to a block of given size.

Input:

40
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Output:

Lorem  ipsum dolor sit amet, consectetur
adipiscing  elit,  sed do eiusmod tempor
incididunt  ut  labore  et  dolore magna
aliqua.  Ut  enim  ad minim veniam, quis
nostrud   exercitation  ullamco  laboris
nisi ut aliquip ex ea commodo consequat.
Duis  aute  irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu
fugiat  nulla  pariatur.  Excepteur sint
occaecat cupidatat non proident, sunt in
culpa  qui  officia deserunt mollit anim
id est laborum.
                <-- note the linebreak

Input Details

You have to write whole executable/interpretable program.
You may suppose, that the input contains only printable ASCII characters and does not contain tab \t.
The input can contain line breaks. If it does so, they are given as \n, \r, or \r\n depending on what you expect. They are however united throughout whole input.
The input can be given in STDIN, or as command line arguments. You can use both of them if it suits your needs (for example, read block size from command args and input as stdin). You may not, however, hardcode any part of the input to your program.
You may suppose that the block size is given as valid positive (> 0) number.
Line break in the input is treated the same way as a space (thus being word separator)
If the input contains multiple concurrent spaces they are treated as one.

Output details

The output has to be formatted into a block of given size. The formatting is done by adding spaces between words.
The number of spaces between words on a line has to be equal for that line. If it is not possible, additional spaces must be added one by one after words starting from the left.
If the word is longer that given block size, it will stand alone on a single line (and will exceed the block size).
If the output should contain only one word, it will be aligned to the left.
The last line of the output has to be aligned to the left, with only one space between words. The last line of the output has to end with trailing line break.

The answer, with shortest number of bytes after some time, wins.
If you need additional information, leave a comment.

Test cases

Input:
10
Lorem ipsum dolor sit amet,
consectetur adipiscing elit, sed do eiusmod tempor

Output:
Lorem
ipsum
dolor  sit
amet,
consectetur
adipiscing
elit,  sed
do eiusmod
tempor

Input:
20
Lorem     ipsum

dolor  sit amet,

Output:
Lorem   ipsum  dolor
sit amet,

Input:
1
Lorem ipsum dolor sit amet

Output:
Lorem
ipsum
dolor
sit
amet

Pyth, 60 57 54 51 50 52 bytes
2015-10-22: fixing a bug took 2 bytes.
=HfTcjd.zdWHAcH]f|qTlH>jd<HhTQ1s.iGcJ|tlG1*d?H-QlsGJ

Try it online.


12 Days of Christmas Lyrics I thought this would be a fun challenge for everyone and I'm curious to see the solutions people come up with.

Print the "12 Days Of Christmas" lyrics

On the first day of Christmas,
my true love gave to me,
A partridge in a pear tree.

On the second day of Christmas,
my true love gave to me,
Two turtle doves,
And a partridge in a pear tree.

...

On the twelfth day of Christmas,
My true love gave to me,
Twelve drummers drumming,
Eleven pipers piping,
Ten lords-a-leaping,
Nine ladies dancing,
Eight maids-a-milking,
Seven swans-a-swimming,
Six geese-a-laying,
Five golden rings,
Four calling birds,
Three french hens,
Two turtle doves,
And a partridge in a pear tree.

Rules

You don't have to worry about capitalization; the entire text can be case insensitive
You can sensibly ignore any punctuation: hyphens can be spaces, and commas and periods can be ignored
There should be a blank line between each verse
You must ordinalize your numbers: "first day of Christmas", "Four calling birds", etc


Write a program that says how many times it was ran Write a program that after running will show how many times it was ran before. You are only allowed to modify the executable itself (the code itself, or compiled version of your code), you cannot modify anything else or create new files.

Example:

$ ./yourprogram
0
$ ./yourprogram
1
$ ./yourprogram
2

Somewhat less trivial example than y'old bash, in C:

#include <stdio.h>

int main(int argc,char **argv){
    const char *data="Da best marker in da world 0\0\0\0\0\0\0";
    FILE *f;
    int i;
    char c;
    long int pos;
    printf("%s\n",data+27);
    f=fopen(argv[0],"r+b");
    i=0;
    c=fgetc(f);
    while(!feof(f)){
        if(data[i]==c){
            i++;
            if(i==27)break;
        } else i=0;
        c=fgetc(f);
    }
    if(i!=27)return 1;
    i=0;
    pos=ftell(f);
    c=fgetc(f);
    while(c!='\0'){
        i=10*i+c-'0';
        c=fgetc(f);
    }
    i++; //The increment!
    fseek(f,pos,SEEK_SET);
    fprintf(f,"%d",i);
    fflush(f);
    fclose(f);
    return 0;
}


Counting Queen's paths on a rectangular chessboard Task

Given two positive integers \$m,n\$, imagine a chessboard of size \$m \times n\$. A chess queen is on the upper-left corner. In how many ways can it reach the lower-right corner, by moving only right, down, or diagonally right-down (possibly moving many steps at once, because it's a queen)?

The resulting 2D sequence is A132439.

Standard code-golf rules apply. The shortest code in bytes wins.

Test cases

m n result
1 1      1
1 2      1
1 3      2
1 4      4
1 5      8
2 2      3
2 3      7
2 4     17
2 5     40
3 3     22
3 4     60
3 5    158
4 4    188
4 5    543
5 5   1712

Haskell, 94 91 64 54 bytes

1!1=1;m!n=sum[m!(n-x)+(m-x)!n+(m-x)!(n-x)|x<-[1..m+n]]

Try it online!

Initially a boring port of the comment on OEIS

-27 from some tricks off dingledooper's answer

-10 from Christian Sievers


-ENDED- Do something that looks like something else Write a snippet, a function, a programm, ... that is obfuscated in a way that it looks clear at the first sight that it does something else.

For example: write a bit of code that adds two number, but when you ask someone "what does it do?", he will tell you it prints "Hello, World!".

Rules

The code must be readable for someone who roughly knows the language you use (avoid intrinsic obfuscated language like APL, in your own interest).
The code must do something unexpected that the reader initially couldn't predict.
When you ask different readers, they must have the same (wrong) opinion about what the code does.

Rating

Please read other contestants' codes during maximum 10-20 seconds, just to have a good idea of what happens there.
Add a comment to the answer saying what you think the code does. If the answer you want to give is already there, simply +1 the comment. (if you miss that answer and add another comment, don't worry, it won't be counted as another answer).
The points will be awared this way: (maxFalseOpinion - goodGuess) / totalOpinion (see example below).
Rate other contestants with fairplay and don't comment your own code.
Only add useful comments. Avoid "I don't know" and "good one!", they are not taken into account for the rating, but it's the code and not the ratings that must be obfuscated.

Rating example

The snippet adds two numbers. The comments say:

(3) It displays "Hello, World!"
(1) It substracts 2 numbers.
(2) It adds 2 numbers.

The total amount of points is the maximum number of opinions (3) - the number of good guesses (2) divided by the total amount of guesses (3 + 1 + 2 = 6). Result: (3 - 2) / 6 = 1/6 = 16.67%.

MORE ABOUT POINTS

People seem to have some trouble figuring out the points.

Here is a perfect score:

printf('Hello World');

comments:
It displays the number of time you have clicked a button. (17 comments).
TOTAL: 17 comments

Score: (17 - 0)/17 = 1 = 100%

Here is a lame score:

printf('Hello World');

comments:
It prints "Hello World". (13 comments).
TOTAL: 13 comments

Score: (0 - 13) / 13 = -1 = -100%

Here is a not so bad score:

printf('Hello World');

comments:
It prints the user name. (2 comments).
It displays the current time (15 comments).
It returns what you entered without modification. (3 comment).
It prints "Hello World" (1 comment).
TOTAL: 21 comments

Score: (15 - 1) / 21 = 0.6667 = 66.67%
Explaining :
15 is the main guess, what people said the most.
1 is the correct number of guesses.
21 is the sum of all comments.

Javascript

var а;
a = 1;
а++;
alert( a );

Answer: It outputs 1. The comments below explain it pretty well - there are two different variables here, a - 'LATIN SMALL LETTER A' and а - 'CYRILLIC SMALL LETTER A'.

There was 1 correct answer, 50 people thought it outputs 2, and with a total of 52 answers, the score is (50 - 1) / 52 = 49 / 52 = 94,23%


Calculate the inverse modulus The task:
Output a value for x, where a mod x = b for two given values a,b.
Assumption

a and b will always be positive integers
There won't always be a solution for x
If multiple solutions exist, output at least one of them.
If there aren't any solutions, output nothing or some indication that no solutions exist.
Built-ins are allowed (not as fun as other mathematical approaches)
Outputs are always integers

Examples
A, B >> POSSIBLE OUTPUTS

5, 2 >> 3
9, 4 >> 5
8, 2 >> 3, 6
6, 6 >> 7, (ANY NUMBER > 6)
8, 7 >> NO SOLUTION
2, 4 >> NO SOLUTION
8, 5 >> NO SOLUTION
10,1 >> 3, 9

This is code-golf, so lowest bytes wins.

JavaScript, 28 27 26 24 23 bytes

a=>b=>(a-=b)?a>b&&a:b+1

Try it online!

false indicates no solution.

-1 thanks @Arnauld


Pascal's Column Sums Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first 5 rows (borrowed from Generate Pascal's triangle):

    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1

We're going to take Pascal's Triangle and perform some sums on it (hah-ha). For a given input n, output the columnar sum of the first n rows of Pascal's Triangle. For example, for input 5, the output would be formed by

            1
          1   1
        1   2   1
      1   3   3   1
[+] 1   4   6   4   1
----------------------
    1 1 5 4 9 4 5 1 1

So the output would be [1, 1, 5, 4, 9, 4, 5, 1, 1].

Note that you don't necessarily need to generate Pascal's Triangle to calculate the summation - that's up to your implementation if it's shorter to do so or not.

Input

A single positive integer n with n >= 1 in any convenient format.

Output

The resulting array/list of the column-wise summation of the first n rows of Pascal's triangle, as outlined above. Again, in any suitable format.

Rules

Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

[input]
[output]

1
[1]

2
[1, 1, 1]

3
[1, 1, 3, 1, 1]

5
[1, 1, 5, 4, 9, 4, 5, 1, 1]

11
[1, 1, 11, 10, 54, 44, 155, 111, 286, 175, 351, 175, 286, 111, 155, 44, 54, 10, 11, 1, 1]

MATL, 16 bytes
tZv=Gq:"t5BZ+]vs

Try it online!
Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0

Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0

Repeating the operation gives
0 0 1 0 2 0 1 0 0

then
0 1 0 3 0 3 0 1 0

etc. Concatenating these arrays vertically and computing the sum of each column gives the result.
t       % Input n implictly. Duplicate
Zv      % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
=       % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq:     % Push [1 2 ... n-1]
"       % For each. This executes the following code n-1 times
  t     %   Duplicate
  5B    %   Push 5 in binary, that is, [1 0 1]
  Z+    %   Convolution keeping size
]       % End
v       % Concatenate all results vertically
s       % Sum. Display implicitly.


(RGS 4/5) Inverting matrices modulo m Task

Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified.

Matrix inverse

If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the inverse of M will exist if and only of the determinant of M is invertible modulo m, which happens when the determinant is coprime with m.

The inverse of M is a square matrix inv(M) such that M*inv(M) = inv(M)*M = I, where

$$I = \begin{bmatrix}
1 & 0 & 0 & \cdots & 0 \\
0 & 1 & 0 & \cdots & 0 \\
\vdots & \ddots & \ddots & \ddots & \vdots \\
0 & 0 & \cdots & 0 & 1
\end{bmatrix}$$

has the same shape of M and is called the identity matrix. As an example, consider the first test case, where [[22, 43], [29, 37]] is the inverse of [[26, 16], [38, 41]] mod 45:

$$\begin{bmatrix}
26&16\\38&41
\end{bmatrix} \cdot \begin{bmatrix}
22&43\\29&37
\end{bmatrix} = \begin{bmatrix}
1036&1710\\2025&3151
\end{bmatrix} \equiv \begin{bmatrix}
1 & 0 \\ 0&1
\end{bmatrix} \mod 45$$

Input

A square matrix M with integer values between 0 and m-1, inclusive, and a positive integer m > 1. The matrix may be given in any sensible format, including

a list of lists, where the inner lists encode the rows, like M = [[1, 2], [3, 4]], or a flattened version, like M = [1, 2, 3, 4]
a list of lists, where the inner lists encode the columns, like M = [[1, 3], [2, 4]], or a flattened version, like M = [1, 3, 2, 4]

where these encode the matrix

\$\$\begin{bmatrix}
1 & 2 \\ 3 & 4
\end{bmatrix}\$\$

The integer m giving the modulus.

You may also accept the size of the matrix as input.

The inputs can be given in any order.

Output

A matrix representing the inverse of M modulo m. You may assume such an inverse exists. Preferable format is for each matrix entry \$a_{i,j}\$ to satisfy \$0 \leq a_{i,j} < m\$ but this is just to make it easier to compare with the test cases.

Test cases

45, [[26, 16], [38, 41]] -> [[22, 43], [29, 37]]

39, [[29, 50], [29, 1]] -> [[16, 19], [4, 35]]

35, [[24, 14], [48, 45]] -> [[5, 7], [4, 33]]

53, [[43, 20], [15, 8]] -> [[5, 14], [37, 7]]

49, [[15, 11, 30], [20, 12, 40], [33, 25, 2]] -> [[33, 28, 23], [25, 18, 0], [25, 48, 13]]

37, [[8, 9, 22, 17], [24, 30, 30, 19], [39, 8, 45, 23], [5, 30, 22, 33]] -> [[18, 17, 26, 20], [29, 36, 23, 1], [19, 0, 9, 3], [30, 23, 14, 21]]

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

This is the fourth challenge of the RGS Golfing Showdown. If you want to participate in the competition, you have 96 hours to submit your eligible answers. Remember there is still 300 reputation in prizes! (See 6 of the rules)

Also, as per section 4 of the rules in the linked meta post, the "restricted languages" for this third challenge are only Jelly, V (vim) and 05AB1E so submissions in these languages are not eligible for the final prize. But they can still be posted!!

Otherwise, this is still a regular code-golf challenge, so enjoy!

R, 68 bytes

function(M,m,n,A=M){while(any(A%*%M%%m!=diag(n)))A[]=rpois(n^2,9)
A}

Try it online!

Strikingly slow. Will most likely time out for all test cases on TIO, but is guaranteed to give an answer eventually.

Works by rejection sampling: generates random matrices A, with each value taken from a \$Poisson(9)\$ distribution, until a solution is found.

Note that to get A of the correct dimensions, it is 6 bytes shorter to initialize it as A=M and then replace all the values with A[]=rpois(n^2,9) than to create it directly with A=matrix(rpois(n^2,9),n).


Draw a sudoku board using line drawing characters This is code golf. For this challenge, I will accept a method (you don't need a full program), but the method signature does count towards the byte count and I want to see the full signature (not a lamdba). The input for the method is an integer array with 81 elements. The output/return value from the method is a string that represents the array as an ascii sudoku board.
If you're using an esoteric language or something that absolutely doesn't have methods, you can adapt, but if the language supports this at all I want to see something might actually be plugged into a "real" ungolfed program, even if the method body itself is a pain to work with. The requirement is not meant to block languages like Jelly or 05AB1E, but to make it easier for languages like Java to build something that makes sense for that platform.
For the input, integer values 1-9 should have obvious meanings. A 0 should always be interpreted as a blank cell. You may also interpret anything else outside the 1-9 range as a blank cell, but this is not required. Positioning from the array to the puzzle starts at the top left and fills each row from left to right before moving to the next row.
For the boxes, I want double lines around the outside and between each 3x3 region, and single lines between other cells. These should be drawn with line drawing characters (if your I/O format represents strings as a sequence of bytes rather than a sequence of characters, you should represent them in a well-known encoding such as UTF-8 or codepage 347).
For this challenge, I am NOT asking you to generate the sudoku puzzle. That is the input for the function. I am NOT asking you to solve the puzzle. I'm just asking you to produce a string to "draw" what you're given (in as few bytes as possible).
Example Input:
Values for the array:
{ 8, 5, 0, 0, 0, 2, 4, 0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 9, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7, 0, 0, 2, 3, 0, 5, 0, 0, 0, 9, 0, 0 ,0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 7, 0, 0, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 0, 4, 0}

The values can use whatever mechanism is natural for your language: int[], ArrayList, sequence, tuple, string of digits, whatever, as long as you have a value in the input for every cell (no maps for only populated cells to positions). Remember that the input is supplied... it is not part of your byte count. But the input might represent any sudoku puzzle, and the puzzle might not even have a valid solution. You do get to assume that puzzle is printable. You won't get something with 82 elements, for example.
You also get to assume a reasonable fixed-width font.
Corresponding Output:

╔═══╤═══╤═══╦═══╤═══╤═══╦═══╤═══╤═══╗
║ 8 │ 5 │   ║   │   │ 2 ║ 4 │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 7 │ 2 │   ║   │   │   ║   │   │ 9 ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │   │ 4 ║   │   │   ║   │   │   ║
╠═══╪═══╪═══╬═══╪═══╪═══╬═══╪═══╪═══╣
║   │   │   ║ 1 │   │ 7 ║   │   │ 2 ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 3 │   │ 5 ║   │   │   ║ 9 │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │ 4 │   ║   │   │   ║   │   │   ║
╠═══╪═══╪═══╬═══╪═══╪═══╬═══╪═══╪═══╣
║   │   │   ║   │ 8 │   ║   │ 7 │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │ 1 │ 7 ║   │   │   ║   │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │   │   ║   │ 3 │ 6 ║   │ 4 │   ║
╚═══╧═══╧═══╩═══╧═══╧═══╩═══╧═══╧═══╝

Python 3, 232 bytes

Thanks to those who helped to golf this down.

Encryption within encryption...

q=lambda x,y:x+y+x+y+x
r=lambda a,b,c,d,e:a+q(q(b*3,c),d)+e+"\n"
print(((r(*"╔═╤╦╗")+q(q("║ %d │ %d │ %d "*3+"║\n",r(*"╟─┼╫╢")),r(*"╠═╪╬╣"))+r(*"╚═╧╩╝"))%eval(input())).replace(*"0 "))

Try it online!

To be golfed.


Fix my notation for lists of matrices, part 1 Sometimes, I have lists of constant matrices in my code:
[ [[1, 0],
   [0, 1]],

  [[1, 0],
   [0,-1]],

  [[0, 1],
   [1, 0]],

  [[0,-1],
   [1, 0]] ]

That's a terrible use of screen real estate. I'd much rather write them next to each other:
[   [[1, 0],    [[1, 0],    [[0, 1],    [[0,-1],
     [0, 1]],    [0,-1]],    [1, 0]],    [1, 0]]   ]

You'll find that this is still a syntactically valid nested list, it's just no longer rectangular and it has a very different structure (in particular, it gets deeper every time I add a matrix larger than 1x1). However, it's still possible to reconstruct the initial list of matrices from this new list.
So that I can use this syntax in the future, I need you to write some code which converts arrays that were written in a horizontal arrangement to the list of matrices they represent.
To make sure that answers don't perform 2D pattern matching on the layout in the source code, the input will be given either as just the array object, or if you take a string representation, then it will not contain any whitespace indicating how the literal was written in the code. So you'd get some input like this:
[[[1, 0], [[1, 0], [[0, 1], [[0,-1], [0, 1]], [0,-1]], [1, 0]], [1, 0]]]

And the output should be the following array or its string representation (again, no further layout is needed):
[[[1, 0], [0, 1]], [[1, 0], [0,-1]], [[0, 1], [1, 0]], [[0,-1], [1, 0]]]

This is the first and easier part of a two-part challenge. In this one, you may assume that all matrices are square and have the same dimensions and that they are properly aligned next to each other. In the second part we'll relax these assumptions.
Rules
The input will be a nested list or its canonical string representation (in your language of choice), and you should output the result in the same format. The result will always contain at least one matrix, and the matrices can be as small as 1x1. The matrices will only contain (signed) integers with absolute value less than 128.
You may write a program or a function and use any of the standard methods of receiving input and providing output.
You may use any programming language, but note that these loopholes are forbidden by default.
This is code-golf, so the shortest valid answer – measured in bytes – wins.
Test Cases
Each test case has a) the list matrices laid out nicely next to each other as they would be in the code (this is not your input), b) the unformatted list without the extraneous whitespace (this is your input), c) the expected output.
Pretty: [ [[0]] ]
Input:  [[[0]]]
Output: [[[0]]]

Pretty: [  [[-1]],  [[0]],  [[1]]  ]
Input:  [[[-1]],[[0]],[[1]]]
Output: [[[-1]],[[0]],[[1]]]

Pretty: [  [[1, 0],   [[1, 0],   [[0, 1],   [[0,-1],
            [0, 1]],   [0,-1]],   [1, 0]],   [1, 0]]  ]
Input:  [[[1,0],[[1,0],[[0,1],[[0,-1],[0,1]],[0,-1]],[1,0]],[1,0]]]
Output: [[[1,0],[0,1]],[[1,0],[0,-1]],[[0,1],[1,0]],[[0,-1],[1,0]]]

Pretty: [  [[1, 0, 0],   [[ 127,  63,   31],   [[1, 0, 0],   [[0, 0, 0],
            [0, 1, 0],    [  15,   0,  -15],    [0, 0, 1],    [0, 0, 0],
            [0, 0, 1]],   [ -31, -63, -127]],   [0, 1, 0]],   [0, 0, 0]]  ]
Input:  [[[1,0,0],[[127,63,31],[[1,0,0],[[0,0,0],[0,1,0],[15,0,-15],[0,0,1],[0,0,0],[0,0,1]],[-31,-63,-127]],[0,1,0]],[0,0,0]]]
Output: [[[1,0,0],[0,1,0],[0,0,1]],[[127,63,31],[15,0,-15],[-31,-63,-127]],[[1,0,0],[0,0,1],[0,1,0]],[[0,0,0],[0,0,0],[0,0,0]]]

Jelly, 20 15 13 11 bytes

Fðs⁹œsZµḢḢL

Try it online!

Background

Like most things, this challenge is rather simple once you've figured out what you have to do. And I eventually did, after three deletions and one rollback...

First, we must figure out the dimensions of the matrices. That's easier done than said: the first element of the first element is the first row of the first output matrix, so its length is equal to the number of columns of the square output matrices.

For example, if the input is

[  [[1, 0, 0],   [[ 127,  63,   31],   [[1, 0, 0],   [[0, 0, 0],
    [0, 1, 0],    [  15,   0,  -15],    [0, 0, 1],    [0, 0, 0],
    [0, 0, 1]],   [ -31, -63, -127]],   [0, 1, 0]],   [0, 0, 0]]  ]

the first element of the first element is [1, 0, 0], whose length is ℓ = 3.

If we flatten the input and split it into chunks of that length, we get all rows of the output matrices, albeit in the wrong order. For our example input, this gives

[  [1, 0, 0], [127,  63,   31], [1, 0, 0], [0, 0, 0],
   [0, 1, 0], [ 15,  0,   -15], [0, 0, 1], [0, 0, 0],
   [0, 0, 1], [-31, -63, -127], [0, 1, 0], [0, 0, 0]  ]

To obtain the final output, we must first split the row array into ℓ chunks of equal length. For our example input, this gives

[ [[1, 0, 0], [127,  63,   31], [1, 0, 0], [0, 0, 0]],
  [[0, 1, 0], [ 15,  0,   -15], [0, 0, 1], [0, 0, 0]],
  [[0, 0, 1], [-31, -63, -127], [0, 1, 0], [0, 0, 0]] ]

Each column is now one of the output matrices, so transposing the resulting matrix of arrays is all that's left to do. For our example input, that gives

[
 [[1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]],

 [[127,  63,   31],
  [ 15,   0,  -15],
  [-31, -63, -127]],

 [[1, 0, 0],
  [0, 0, 1],
  [0, 1, 0]],

 [[0, 0, 0],
  [0, 0, 0],
  [0, 0, 0]]
]

as desired.

How it works

Fðs⁹œsZµḢḢL  Monadic link. Argument: A (ragged array)

F            Monadic chain. Argument: A

F            Flatten A. This yields the vector V.

       µḢḢL  Monadic chain. Argument: A

        Ḣ    Head; retrieve the first element of A.
         Ḣ   Head; retrieve the first element of the first element of A.
          L  Compute ℓ, the length of the resulting array.

 ðs⁹œsZ      Dyadic chain. Left argument: V. Right argument: ℓ

  s⁹         Split V into chunks of length ℓ.
    œs       Split the result into ℓ chunks of equal length.
      Z      Zip/transpose the result.


Would this string work as string? Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and overline. You can use ~ in place of overline if you need since overline is not convenient ASCII.)

For example, one possible input is:

__/‾‾\/\_/‾

Your program needs to output a truthy or falsy value depending on whether the left edge of the string is "connected", so to speak, to the right edge of the string via the lines of the characters. So, if the kerning was a bit less, there would be a solid black (albeit kinky) line all the way from the left edge to the right, like an unbroken piece of string or twine.

The output for the above example would be true because the edges are connected:

To be clear on the connections:

/ connects on its bottom left and top right
\ connects on its top left and bottom right
_ connects on its bottom left and bottom right
‾ (or ~) connects on its top left and top right

Also:

It doesn't matter whether the edges of the string started on the top or the bottom, it only matters that they connect horizontally through the whole length of the string.
You can assume the input string is non-empty, and of course just one line.

Here are some more examples followed by 1 (truthy) if they are connected or 0 (falsy) if not:

__/‾‾\/\_/‾
1

_
1

\
1

/
1

‾
1

___
1

\/
1

/\/
1

/\/\
1

‾‾‾
1

\\
0

‾‾
1

_‾
0

‾_
0

\_____/
1

\/\\/\\___
0

\/\__/‾‾\
1

______/\_____
1

‾‾‾‾‾‾\\_____
0

‾‾‾‾‾‾\______
1

_____/‾‾‾‾‾
1

\___/‾‾‾\___/‾‾‾
1

\_/_\_
0

\_/\_
1

/\/\/\/\/\/\/\/\/\/\/\/
1

____________________
1

‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
1

‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾/
0

‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾\
1

/\‾/\‾___/\_\/__\/\‾‾
0

The shortest code is the winner.

Jelly, 9 bytes
-1 byte thanks to @EriktheOutgolfer
Expect ~ instead of ‾. Returns \$0\$ or \$1\$.
O*Ɲ:⁽8ƇḂẠ

Try it online!, Truthy test suite, Falsy test suite
Using this formula (but otherwise similar to the 11-byte version below):
$$n=\left\lfloor\frac{x^y}{15145}\right\rfloor$$
The transition is valid if \$n\$ is odd, or invalid if \$n\$ is even.
Commented
O*Ɲ:⁽8ƇḂẠ     - main link, taking a string          e.g. "\_/"
O             - get ASCII codes                     -->  [92, 95, 47]
 *Ɲ           - exponentiation on all pairs         -->  [92**95, 95**47]
   :⁽8Ƈ       - integer division by 15145           -->  [23964828…8421, 59257069…0485]
       Ḃ      - least significant bit (i.e. parity) -->  [1, 1]
        Ạ     - all values equal to 1?              -->  1

Jelly,  14 12  11 bytes
Supports (and expects) the ‾ character in the input string. Returns \$0\$ or \$1\$.
O*Ɲ%276%7ỊẠ

Try it online!, Truthy test suite, Falsy test suite
How?
Given two consecutive characters of ASCII codes \$x\$ and \$y\$, we want a function that checks whether they form a valid transition.
We need a non-commutative operation, because the result may change when the characters are reversed. For instance, _/ is valid but /_ is not.
Using exponentiation, a possible formula1 is:
$$n=(x^y \bmod 276)\bmod 7$$
The transition is valid if \$n\le1\$, or invalid if \$n>1\$.
 chars |    x |    y | (x**y)%276 | %7 | valid
-------+------+------+------------+----+-------
   __  |   95 |   95 |      71    |  1 |  yes
   _/  |   95 |   47 |     119    |  0 |  yes
   _‾  |   95 | 8254 |     265    |  6 |   no
   _\  |   95 |   92 |     265    |  6 |   no
   /_  |   47 |   95 |      47    |  5 |   no
   //  |   47 |   47 |      47    |  5 |   no
   /‾  |   47 | 8254 |       1    |  1 |  yes
   /\  |   47 |   92 |       1    |  1 |  yes
   ‾_  | 8254 |   95 |     136    |  3 |   no
   ‾/  | 8254 |   47 |      88    |  4 |   no
   ‾‾  | 8254 | 8254 |     196    |  0 |  yes
   ‾\  | 8254 |   92 |     196    |  0 |  yes
   \_  |   92 |   95 |      92    |  1 |  yes
   \/  |   92 |   47 |      92    |  1 |  yes
   \‾  |   92 | 8254 |     184    |  2 |   no
   \\  |   92 |   92 |     184    |  2 |   no

1. Found with a brute-force search in Node.js (using BigInts)
Commented
O*Ɲ%276%7ỊẠ   - main link, taking a string          e.g. "\_/"
O             - get ASCII codes                     -->  [92, 95, 47]
 *Ɲ           - exponentiation on all pairs         -->  [92**95, 95**47]
   %276       - modulo 276                          -->  [92, 119]
       %7     - modulo 7                            -->  [1, 0]
         Ị    - ≤1?                                 -->  [1, 1]
          Ạ   - all values equal to 1?              -->  1


Sums of 24-hour time Given an integer between 0 and 141 (inclusive), list all 24-hour times whose hour, minute, and second units add to that integer.

Rules of addition

Numbers are added by their time units, not by single digits.

For example, take 17:43:59

17+43+59=119

Remember, that is an example of digits being added. In reality, you would enter 119, and 17:43:59 would be one of the results. Output should be given as HH:MM:SS or H:MM:SS.

Also keep in mind the highest number possible is 141, being 23:59:59. This is code golf, so the lowest amount wins. Trial and error is permitted, but there may be a better way to go about this.

Edit: Please specify where in your code the input value is.

Jelly, 16 30 29 20 bytes

Now with the correct output format! Many thanks to Dennis for his help in debugging this answer. Golfing suggestions welcome. Try it online!

Edit: +14 bytes from using the correct output format. -1 byte from removing an extra space. -3 from changing from 24,60,60 to “ð<<‘. -6 bytes from changing +100DḊ€€ to d⁵.

“ð<<‘Œp’S=¥Ðfd⁵j€”:Y

Explanation

“ð<<‘Œp’S=¥Ðfd⁵j€”:Y  Main link. Argument: n

“ð<<‘                 Jelly ord() the string `ð<<` to get [24, 60, 60]. Call this list z.
     Œp               Cartesian product of z's items.
                        Since each item of z is a literal,
                        Jelly takes the range [1 ... item] for each item.
       ’              Decrements every number in the Cartesian product
                        to get lowered ranges [0 ... item-1].
        S=¥           Create a dyadic link of `sum is equal to (implicit n)`.
           Ðf         Filter the Cartesian product for items with sum equal to n.
             d⁵       By taking divmod 10 of every number in each item,
                        we get zero padding for single-digit numbers
                        and every double-digit number just turns into a list of its digits.
               j€”:   Join every number with a ':'.
                   Y  Join all of the times with linefeeds for easier reading.


Let's draw some Atari ST bombs! Introduction
The Atari ST was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a row of bombs on the screen, as shown in the following picture:

Source: https://commons.wikimedia.org/wiki/File:Row_of_bombs.png
NB: Depending on the OS version, the bomb graphics may vary slightly. But let's take this one as reference.
The number of bombs depends on the exception vector, the most common ones being:

($008) Bus Error : 2 bombs
($00c) Address Error : 3 bombs
($010) Illegal Instruction : 4 bombs

Goal
Your goal is to write a program or function that prints or outputs an ASCII art of such Atari ST bombs.
Input
An integer representing the number of bombs to display. Your code must support the most common values: 2, 3 and 4. Supporting less and/or more bombs is fine, but it is neither required nor subject to a bonus.
Output
The original bomb consists of a 16x16 pixel tile, represented here in both ASCII and binary:
....##..........    0000110000000000
.#.#..#.........    0101001000000000
.......#........    0000000100000000
#..#....#.......    1001000010000000
..#...#####.....    0010001111100000
......#####.....    0000001111100000
....#########...    0000111111111000
...###########..    0001111111111100
...###########..    0001111111111100
..#############.    0011111111111110
..########.####.    0011111111011110
...#######.###..    0001111111011100
...######.####..    0001111110111100
....#########...    0000111111111000
.....#######....    0000011111110000
.......###......    0000000111000000

In this challenge, each ASCII bomb must be stretched to twice its original width for a better rendering. Therefore, it will consist of 16 rows of 32 characters, using ## for 'ON' pixels and two spaces for 'OFF' pixels. All bomb tiles must be put side by side. Leading spaces are forbidden. Trailing spaces are also forbidden, except the ones that are actually part of the bomb tile (i.e. the 31st and 32nd columns) which must be present. You may include no more than one leading line-break and no more than one trailing line-break.
Example
Below is the reference output for two bombs, where mandatory line-breaks are marked as \n and tolerated extra line-breaks are marked as (\n):
(\n)
        ####                            ####                    \n
  ##  ##    ##                    ##  ##    ##                  \n
              ##                              ##                \n
##    ##        ##              ##    ##        ##              \n
    ##      ##########              ##      ##########          \n
            ##########                      ##########          \n
        ##################              ##################      \n
      ######################          ######################    \n
      ######################          ######################    \n
    ##########################      ##########################  \n
    ################  ########      ################  ########  \n
      ##############  ######          ##############  ######    \n
      ############  ########          ############  ########    \n
        ##################              ##################      \n
          ##############                  ##############        \n
              ######                          ######            (\n)

(Of course, other line-break formats such as \r or \r\n may be used just as well.)
Rules
This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

Jelly, 43 44 bytes

+1 byte - forgot to double the characters (not that anyone noticed!)

“¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P"¦ḊƥṾ’b⁴‘ĖŒṙị⁾ #Ḥs⁴ẋ€³Y

TryItOnline

How?

Preparation was to compress the data as a run-length encoding of the original image:

Count the length of each run of 1s (space) or 0s (hash) in the image, ignoring new lines - yields a list: [4,2,11,1,1,...];
Subtract one from each number - this gives a range of [0,15];
Treat this as a base-16 number (enumerate the values, v, with index i in reverse and sum up 16**i*v = 19468823747267181273462257760938030726282593096816512166437);
Convert this to base-250: [5,119,249,42,...];
Map into Jelly's code page as indexes: ¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P

Now the code evaluates this number, maps the 1s and 0s to space and hash characters*, doubles each, splits into lines and repeats each the appropriate number of times.
* actually the implementation is performed modulo 2 to save bytes, so spaces are odd and hashes are even:

“¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P"¦ḊƥṾ’b⁴‘ĖŒṙị⁾ #Ḥs⁴ẋ€³Y - Main link: n
“¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P"¦ḊƥṾ’                  - base 250 number, as above
                           b⁴                - convert to base 16 (the run length - 1 list)
                             ‘               - increment (vectorises) (the run length list)
                              Ė              - enumerate (pairs each with 1,2,3...)
                               Œṙ            - run length decode
                                              ([1,1,1,1,2,2,3,3,3,3,3,3,3,3,3,3,3,4,5,...])
                                  ⁾ #        - string " #"
                                 ị           - index into (1 based and modular)
                                              (makes a bomb without line feeds)
                                     Ḥ       - double (each char becomes a list of 2 chars)
                                      s⁴     - split into slices of length 16
                                        ẋ€³  - repeat each input, n, times
                                           Y - join with line feeds


Cat a mouse: ASCII art pointers The Xerox Alto, originally released in 1973, was the first computer to feature the now-familiar angled mouse pointer. The Alto's bitmapped pointer looked like this (redrawn from Fig. 2 here):

Your task in this code-golf challenge is to write a program/function that generates an ASCII art representation of the mouse pointer pictured above. Rules:

Input is a positive integer \$n\$, which is a scaling factor for the output.
Represent each black pixel as an \$n\times{}n\$ block of any single printable character. (The test cases use @, which vaguely resembles a mouse viewed from above.)
Similarly, represent each empty pixel to the bottom/left of the pointer as an \$n\times{}n\$ block of a second printable character. (Spaces are used in the test cases.)
Optionally, your output may also include the empty pixels to the top/right of the pointer, represented by the same character chosen under Rule 3.
Any sensible output format (e.g. multi-line string, array of strings, matrix of characters) is acceptable.
A single trailing newline at the end of the output is permitted.

Test cases
\$n = 1\$
@
@@
@@@
@@@@
@@@@@
@@@@@@
@@@@@@@
@@@@
@@ @@
@  @@
    @@
    @@
     @@
     @@
      @@
      @@

\$n = 2\$
@@
@@
@@@@
@@@@
@@@@@@
@@@@@@
@@@@@@@@
@@@@@@@@
@@@@@@@@@@
@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@@@@@
@@@@@@@@
@@@@  @@@@
@@@@  @@@@
@@    @@@@
@@    @@@@
        @@@@
        @@@@
        @@@@
        @@@@
          @@@@
          @@@@
          @@@@
          @@@@
            @@@@
            @@@@
            @@@@
            @@@@

\$n = 3\$
@@@
@@@
@@@
@@@@@@
@@@@@@
@@@@@@
@@@@@@@@@
@@@@@@@@@
@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@   @@@@@@
@@@@@@   @@@@@@
@@@@@@   @@@@@@
@@@      @@@@@@
@@@      @@@@@@
@@@      @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@


Decompose a number into triangles Given an integer n, decompose it into a sum of maximal triangular numbers (where Tm represents the mth triangular number, or the sum of the integers from 1 to m) as follows:

while n > 0,

find the largest possible triangular number Tm such that Tm ≤ n.
append m to the triangular-decomposition representation of n.
subtract Tm from n.

For example, an input of 44 would yield an output of 8311, because:

1+2+3+4+5+6+7+8 = 36 < 44, but 1+2+3+4+5+6+7+8+9 = 45 > 44.

the first digit is 8; subtract 36 from 44 to get 8 left over.

1+2+3 = 6 < 8, but 1+2+3+4 = 10 > 8.

the second digit is 3; subtract 6 from 8 to get 2 left over.

1 < 2, but 1+2 = 3 > 2.

the third and fourth digits must be 1 and 1.

Use the digits 1 through 9 to represent the first 9 triangular numbers, then use the letters a through z (can be capitalized or lowercase) to represent the 10th through 35th triangular number. You will never be given an input that will necessitate the use of a larger "digit".

The bounds on the input are 1 ≤ n < 666, and it will always be an integer.

All possible inputs and outputs, and some selected test cases (listed as input, then output):

1 1
2 11
3 2
4 21
5 211
6 3
100 d32
230 k5211
435 t
665 z731

An output of ∞ for an input of -1/12 is not required. :)

JavaScript (ES6), 52 bytes

f=(n,t=0)=>t<n?f(n-++t,t):t.toString(36)+(n?f(n):'')

How?

Rather than explicitly computing Ti = 1 + 2 + 3 + … + i, we start with t = 0 and iteratively subtract t + 1 from n while t < n, incrementing t at each iteration. When the condition is not fulfilled anymore, a total of Tt has been subtracted from n and the output is updated accordingly. We repeat the process until n = 0.

Below is a summary of all operations for n = 100.

 n  |  t | t < n | output
----+----+-------+--------
100 |  0 | yes   | ""
 99 |  1 | yes   | ""
 97 |  2 | yes   | ""
 94 |  3 | yes   | ""
 90 |  4 | yes   | ""
 85 |  5 | yes   | ""
 79 |  6 | yes   | ""
 72 |  7 | yes   | ""
 64 |  8 | yes   | ""
 55 |  9 | yes   | ""
 45 | 10 | yes   | ""
 34 | 11 | yes   | ""
 22 | 12 | yes   | ""
  9 | 13 | no    | "d"
----+----+-------+--------
  9 |  0 | yes   | "d"
  8 |  1 | yes   | "d"
  6 |  2 | yes   | "d"
  3 |  3 | no    | "d3"
----+----+-------+--------
  3 |  0 | yes   | "d3"
  2 |  1 | yes   | "d3"
  0 |  2 | no    | "d32"

Test cases

f=(n,t=0)=>t<n?f(n-++t,t):t.toString(36)+(n?f(n):'')

console.log(f(1))   // 1
console.log(f(2))   // 11
console.log(f(3))   // 2
console.log(f(4))   // 21
console.log(f(5))   // 211
console.log(f(6))   // 3
console.log(f(100)) // d32
console.log(f(230)) // k5211
console.log(f(435)) // t
console.log(f(665)) // z731


Apply Kirchhoff's law Kirchhoff's law says that when you sum up all the currents (positive for the currents going to a junction, and negative for current leaving a junction), you will always get as result 0.

Look at the following diagram:

Using Kirchhoff's law, you can see that i1 + i4 - i2 - i3 = 0, so i1 + i4 = i2 + i3.

Given two lists, one with all the currents entering the junction and one with all the currents leaving the junction except one, output the last one.

Testcases:

[1, 2, 3], [1, 2] = 3
[4, 5, 6], [7, 8] = 0
[5, 7, 3, 4, 5, 2], [8, 4, 5, 2, 1] = 6

The second list always has one item less than the first list. The output cannot be negative. Smallest program wins.

Jelly, 2 bytes

_S

Try it here!

Takes the entering currents in the first argument, and the leaving currents in the second argument. _ subtracts them pairwise, leaving the single element from the longer list as-is, and S sums the result.


Fibonacci domino tiling There's classic combinatorial result that the number of ways to tile a 2*n strip by 1*2 dominoes is the nth Fibonacci number. You goal is to print all the tilings for a given n, drawn with dashes and vertical lines like these 8 tilings for n=5:

|————
|————

——|——
——|——

|||——
|||——

————|
————|

||——|
||——|

|——||
|——||

——|||
——|||

|||||
|||||

You are to provide a program or named function that take n as input and prints the required output. Fewest bytes wins.

Input

A number n between 1 and 10 inclusive via STDIN or function input.

Output

Print every possible domino tilings of the 2*n strip, drawn horizontally. The tilings may be in any order, but each should appear exactly once. They must be separated by a blank line.

A vertical domino is made of two vertical bars (|) and a horizontal domino is made of two em dashes (—). You may use hyphens (-) in place of em dashes to stay in ASCII.

You can do anything with whitespace as long as the printed output looks the same.

C, 106
Golfed version
f(n){
  for(int i,h=n*2<<n;h--;(i/3|i/3*2)-i||(putchar(i>>h%n&1?45:124),h%n||puts(h%(n*2)?"":"\n")))
    i=h/2/n;
}

Original version
i,j,n;
main(){
  scanf("%d",&n);
  for(i=1<<n;i--;)if((i/3|i/3*2)==i){
    for(j=1<<n;j/=2;)printf("%c",i&j?'-':'|');puts("");
    for(j=1<<n;j/=2;)printf("%c",i&j?'-':'|');puts("\n");
  }
}

How it works
The variable i runs from 1<<n-1 down to 0, producing all possible binary numbers with n digits. 0 encodes for | and 1 encodes for -. We are interested in numbers that contain 1's in pairs. Obviously such numbers are divisible by 3.
When a number is divided by 3, the original number can be recovered by multiplying the result by 2 and adding it to itself (effectively mutliplying by 3.) Most numbers will require a carry, but when the process is carried out on the numbers of interest, no carry is required, so in these cases only, OR can be used instead of addition. This is used to test for the numbers of interest, as they are the only ones where the expression i/3|i/3*2 returns the original value of i. See example below.
1111=15 ---> 0101=5 ---> 1111=15 (valid, 0101|1010==0101+1010)
1001=9  ---> 0011=3 ---> 0111=7 (invalid, 0011|0110 != 0011+0110)
The test value is always equal or less than the original value. As numbers that are not multiples of 3 also return a number less than the original when divided by 3 then multipled by 3, the test gives the desired FALSE on these numbers too.
In the original version a couple of loops in j are used to scan through the bits of i and produce the output. In the golfed version a single for loop is used, in which h runs through all numbers from (n*2)*(1<<n)-1 down to 0. Values of i are generated by h/2/n. The variable j is no longer used, as the equivalent quantity is obtained from h%n. The use of n*2 enables both lines to be printed from the same loop, with some nifty multiplexing in the puts statement to print either one or two newlines at the end of the row.
Note that the meat of this is in the increment position of the for() bracket and therefore gets executed after the i=h/2/h.
Sample output n=6:
$ ./a
6
------
------

----||
----||

--|--|
--|--|

--||--
--||--

--||||
--||||

|----|
|----|

|--|--
|--|--

|--|||
|--|||

||----
||----

||--||
||--||

|||--|
|||--|

||||--
||||--

||||||
||||||


given prime factors of a number, what is the fastest way to calculate it's proper divisors? Given prime factors of a number, what is the fastest way to calculate divisors?

clc; clear;
sms=0;
count = 1;
x=0;
for i=11:28123
    fac = factor(i);
    sm = 1;
    for j = 1:length(fac)-1
        sm = sm + sum(prod(unique(combntns(fac,j), 'rows'),2));
    end
    if sm>i
        x(count) = i;
        count = count + 1;
    end
end
sum1=0;
count = 1;
for i=1:length(x)
    for j=i:length(x)
        smss = x(i) + x(j);
        if smss <= 28123
            sum1(count) = smss;
            count = count + 1;
        end
    end
end
sum1 = unique(sum1);
disp(28123*28124/2-sum(sum1));

currently I'm using this prod(unique(combntns(fac,j), 'rows'),2) code which is awfully slow and I'm using Matlab.

Mathematica
Union[Prepend[Times @@@ Rest@Subsets@l, 1]]

Usage
I'm assuming that repeated factors would be repeated in the list of factors, as below:
l = {2, 2, 3, 5, 5, 11, 11, 11, 31, 37, 617};
Union[Prepend[Times @@@ Rest@Subsets@l, 1]]//AbsoluteTiming

This routine is much slower than the built in function Divisors, which has to first factor the Integer.  I am fairly certain that Divisors is compiled.
Divisors[282584210700]; // AbsoluteTiming

{0.000262, Null}


Regex for Finding Radioactive Elements Find the shortest regex that matches all radioactive elements and nothing else in the Periodic Table of Elements.

Radioactive Elements

'Technetium','Promethium','Polonium','Astatine','Radon','Francium','Radium','Actinium','Thorium','Protactinium','Uranium','Neptunium','Plutonium','Americium','Curium','Berkelium','Californium','Einsteinium','Fermium','Mendelevium','Nobelium','Lawrencium','Rutherfordium','Dubnium','Seaborgium','Bohrium','Hassium','Meitnerium','Darmstadtium','Roentgenium','Copernicium','Ununtrium','Flerovium','Ununpentium','Livermorium','Ununseptium','Ununoctium'

Non-radioactive Elements

'Hydrogen','Helium','Lithium','Beryllium','Boron','Carbon','Nitrogen','Oxygen','Fluorine','Neon','Sodium','Magnesium','Aluminium','Silicon','Phosphorus','Sulphur','Chlorine','Argon','Potassium','Calcium','Scandium','Titanium','Vanadium','Chromium','Manganese','Iron','Cobalt','Nickel','Copper','Zinc','Gallium','Germanium','Arsenic','Selenium','Bromine','Krypton','Rubidium','Strontium','Yttrium','Zirconium','Niobium','Molybdenum','Ruthenium','Rhodium','Palladium','Silver','Cadmium','Indium','Tin','Antimony','Tellurium','Iodine','Xenon','Caesium','Barium','Lanthanum','Cerium','Praseodymium','Neodymium','Samarium','Europium','Gadolinium','Terbium','Dysprosium','Holmium','Erbium','Thulium','Ytterbium','Lutetium','Hafnium','Tantalum','Tungsten','Rhenium','Osmium','Iridium','Platinum','Gold','Mercury','Thallium','Lead','Bismuth'

Scored by character count in the regex.
Use standard Perl regex (just no specialized functions).
Assume all lower case.
You only need to count the characters of the regex itself.

Note if you used a program to get you started and maybe post how well it did. I'll post my best attempt as an answer to get started/show an example.

Char Count 61

lon|ct|oh|^ra|...t.+i|^c?u|or.+u|r.+c.|e..+e|f.?e|^h?as|be*.i

One 3 characters better than accepted answer!

63-character solution found with Peter Norvig's Regex golf solver. 61-character improvement found by a personal rewrite of that program in Go.


Transposed, primes, oh my! The task is simple: your program reads an integer as an input, and prints whether it is a prime or not. You can print "yes/no", "true/false" or anything what unambiguously identifies the result.
The challenge is, the code has to work with its rows and columns transposed.
To exclude the obvious solution (shortest "simple" solution repeated vertically char-by-char with the use of comments), the metric is a little bit different from the usual code-golf:
Because formatting is very important in this challenge, the code size is measured in the area of the smallest rectangle the code fits in. In other words, whitespace does count, and the lines should be filled to be of equal length (you don't have to actually do it when you post the solution, for simplicity's sake). For example
int main()
{
    return 0;
}

would have a size of 4*13 = 52, (and obviously it does not fit either of the two criteria: prime detection and transposable.)
Smallest size wins.
You can use any language, and any library function except if the sole purpose of that function is to find, generate, or detect primes.
Edit:
While the winner would probably be the Golfscript solution, I'll award a 50 point bounty for the best C or C++ solution!

C, 2*70 2*60

Prints y for primes, nothing otherwise.
EDIT: Changed code to save 10 chars. Must be run without paramters (so m=1).

main(m,n){for(scanf("%d",&n);n%++m&&n>1;);n-m||puts("y");}/*
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

The method for handling the transposition is quite generic, and can be applied to any program.
It's based on converting this:

abcd/*
\\\\*/

To this:

a\
b\
c\
d\
/*
*/

And both mean simply abcd.


Go generate some Java Your boss wants you to write code like this:

public static boolean isPowerOfTen(long input) {
  return
    input == 1L
  || input == 10L
  || input == 100L
  || input == 1000L
  || input == 10000L
  || input == 100000L
  || input == 1000000L
  || input == 10000000L
  || input == 100000000L
  || input == 1000000000L
  || input == 10000000000L
  || input == 100000000000L
  || input == 1000000000000L
  || input == 10000000000000L
  || input == 100000000000000L
  || input == 1000000000000000L
  || input == 10000000000000000L
  || input == 100000000000000000L
  || input == 1000000000000000000L;
}

(Martin Smith, at https://codereview.stackexchange.com/a/117294/61929)

which is efficient and so, but not that fun to type. Since you want to minimize the number of keypresses you have to do, you write a shorter program or function (or method) that outputs this function for you (or returns a string to output). And since you have your very own custom full-range unicode keyboard with all 120,737 keys required for all of unicode 8.0, we count unicode characters, instead of keypresses. Or bytes, if your language doesn't use unicode source code.

Any input your program or function takes counts towards your score, since you obviously have to type that in as well.

Clarifications and edits:

Removed 3 trailing spaces after the last }
Removed a single trailing space after return
Returning a string of output from a function/method is ok

PostgreSQL, 158 characters

select'public static boolean isPowerOfTen(long input) {
  return
   '||string_agg(' input == 1'||repeat('0',x)||'L','
  ||')||';
}'from generate_series(0,18)x


Tiling a staircase with staircases Background
A staircase polyomino is a polyomino made of unit squares whose shape resembles a staircase. More formally, a staircase polyomino of size \$n\$ is defined as follows:

A staircase polyomino of size 1 is a single unit square.
A staircase polyomino of size \$n\$ is the same as that of size \$n-1\$ with a horizontal bar of length \$n\$ attached to the bottom, left-aligned.

Let's call them just staircases for brevity.
For example, here are the staircases of size 1 to 4:
#

#
##

#
##
###

#
##
###
####

Challenge
Given a positive integer \$n\$, calculate the number of ways the staircase of size \$n\$ can be tiled with one or more staircases.
Multiple staircases of same size can be used in a tiling, and the staircases can be rotated. So the following are valid tilings for \$n=4\$:
A
BC
DEF
GHIJ

A
AA
AAA
AAAA

A
AA
BBC
BDCC

Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
Generated using this Python 3 reference solution.
1 -> 1
2 -> 2
3 -> 8
4 -> 57
5 -> 806
6 -> 20840
7 -> 1038266

JavaScript (ES10),  250 ... 228  227 bytes
n=>(e=g=(a,[x]=a)=>+e?e=0:(x&=-x)?a.map((_,s)=>[b=1<<s,...s?[1,b+=~-b,b]:[]].map((m,d)=>d|x>>s&&g(a.flatMap(S=(v,y)=>(S|=y>s?v:(e|=(v^=M=x*m>>!d*s)&M,m^=1<<[s+~y,y+1,s-y,y][d],v))?v:[])))):n++)([...Array(n)].map(_=>2**n---1))|n

Try it online!
How?
The size-\$n\$ staircase is described with an array \$a[\:]\$ of \$n\$ bit masks, going from the longest to the shortest row.
For \$n=4\$, this gives:
# # # #  0b1111 = 15
. # # #  0b0111 = 7
. . # #  0b0011 = 3
. . . #  0b0001 = 1  --> a = [ 15, 7, 3, 1 ]

At each iteration, we remove all the leading empty rows in \$a[\:]\$ and look for the least significant non-zero bit \$x\$ in the first non-empty row. Note that \$x\$ is not set to the index of this bit, but to the corresponding power of \$2\$.
For each \$s\in[0\:..\:n-1]\$ we try to cover the main staircase with another staircase of size \$s+1\$ anchored to the non-zero bit, and whose rows are described with the bit mask \$m\$. If \$s=0\$, we only try the orientation \$d=0\$. Otherwise, we try \$d=0\$ to \$d=3\$.
The table below describes for each value of \$d\$:

the initial value of \$m\$
the index of the bit that must be inverted in \$m\$ to generate the next row
the shift applied to \$m\$

The non-zero bit to which the staircase is anchored is marked with an A. In all cases, \$m\$ is first multiplied by \$x\$ before being shifted. All examples are given with \$x=16\$ and \$s=2\$.
             x           d = 0
       . . . . . . . .
y = 0        A           init.  : 2 ** s
y = 1        # #         bit    : s + ~y  (i.e. s - y - 1)
y = 2        # # #       shift  : >> s

             x           d = 1
       . . . . . . . .
y = 0        A           init.  : 1
y = 1      # #           bit    : y + 1
y = 2    # # #           shift  : none

             x           d = 2
       . . . . . . . .
y = 0    # # A           init.  : 2 * (2 ** s) - 1
y = 1      # #           bit    : s - y
y = 2        #           shift  : none

             x           d = 3
       . . . . . . . .
y = 0    # # A           init.  : 2 * (2 ** s) - 1
y = 1    # #             bit    : y
y = 2    #               shift  : none

Note: Given that the bits to the right of the non-zero bit are all cleared by definition and given that we go from top to bottom, the anchor point of the covering staircase is unambiguously defined for each orientation.


Minimum Scalar Product Minimum Scalar Product

The inspiration for this code golf problem is from Google's code jam competition. The premise behind the problem is, given the input of two vectors of varying lengths, find the minimum possible scalar. A scalar can be found using the following formula:

x1 * y1 + x2 * y2 + ... + xn * yn

The problem, however, is that multiple values for the scalar can be found depending on the order of the numerals in the input case (seen below). Your goal is to determine the minimum possible scalar integer solution by plugging in the input case numbers into the equation and solving for it. You may use every number in the input only once, and must use all of the numbers.

Allow me to provide an example with the following vectors.

Input

3
1 3 -5
-2 4 1

Output

-25

The first integer on the line represents the number of numbers, n, in each vector. In this case, we have three numbers in each vector.

The number n may vary with each test case, but there will always be two vectors.

In the example input, the minimum scalar product would be -25.

(-5 * 4) + (1 * 1) + (3 * -2) = 25

Rules

You may only use each integer in both vectors once.
You must use all integers in the vectors.
Your output must only include the final product
I'll select the solution with the least amount of code, which follows all of the specifications listed above, in any language!

   Hint: You don't need to brute force this problem, unless it makes your code shorter. There is a specific method involved in finding the minimum spanning scalar :).

Jelly, 6 bytes

ṢṚ×Ṣ}S

Try it online!

Using brute force is equally short:

Œ!×S€Ṃ

How it works

ṢṚ×Ṣ}S  Main link. Arguments: u (vector), v (vector)

Ṣ       Sort the components of u.
 Ṛ      Reverse.
   Ṣ}   Sort the components of v.
  ×     Multiply the results, element by element.
     S  Compute the sum of the products.


Open source optical lattice clock A recent question showed how Mathematica could be used to make a beautiful optical lattice clock image.  The image looks like this.

This challenge is to reproduce this image as closely as possible using as short code as possible using only easily available open source tools (and without just downloading the image or parts of it).

Rules As it is not reasonable to ask for a pixel by pixel reproduction this is a popularity contest. However, please up-vote code that is a short (in the style of code-golf) and which produces an accurate and beautiful reproduction of the image.

POV-Ray, 512 characters
Here's my try. I didn't manage to replicate the lighting, so I've decided to keep the variation of highlight positions rather than to put the lights further away to keep the background brighter.
The area shadow is rather low-quality. I might as well turn it off completely (and save precious characters), but if someone is willing to donate some computing power and crank up the shadow quality and/or the dither quality, I'll gladly accept.
#include"functions.inc"
camera{location<-3,5,-6>right x look_at 0 focal_point 0 aperture 1 blur_samples 9}
#macro s(p)sphere{pi*p+y/3 1 pigment{rgb<2,8,2>/9}finish{phong .5 phong_size 5 specular 1 roughness .001}}#end
#macro l(p,c)light_source{p c/8 area_light 9*x,9*z,3,3}#end l(<6,6,0>,<8,4,8>)l(<0,6,0>,<4,8,8>)
isosurface{function{y/3+pow(cos(x)*cos(z),2)/2}contained_by{box{-9,100}}pigment{tiling 1 color_map{[.9 rgb 1][1 rgb 0]}scale .5/pi}}
s(0)s(<0,0,-1>)s(<-1,0,0>)s(<0,0,2>)s(<2,0,1>)s(<2,0,3>)

Result:

ungolfed:
#version 3.7;
#include "functions.inc"
global_settings{assumed_gamma 1}
camera{
  location <-3,5,-6>
  right x //set the aspect ratio
  look_at 0
  focal_point 0 aperture 1 blur_samples 9
}

#macro l(p,c) // position, color
  light_source{
    p c/8
    area_light 9*x,9*z,3,3
  }
#end
l(<6,6,0>,<8,4,8>)
l(<0,6,0>,<4,8,8>)

isosurface{
  function{y/3+pow(cos(x)*cos(z),2)/2}
  contained_by{box{-9,100}}
  pigment{
    tiling 1
    color_map{[.9 rgb 1][1 rgb 0]}
    scale .5/pi
  }
}
#macro s(p) //position
  sphere{
    pi*p+y/3 1
    pigment{rgb<2,8,2>/9}
    //phong for the wide highlights, specular for the small ones.
    finish{phong .5 phong_size 5 specular 1 roughness .001}
  }
#end
s(0)
s(<0,0,-1>)
s(<-1,0,0>)
s(<0,0,2>)
s(<2,0,1>)
s(<2,0,3>)

P.S.: I've only counted the five line-breaks to round the character count to a perfectly round number.


Remove letters while keeping strings unique Inspired by this wonderful (based on the number of views and votes) challenge, which, in my humble opinion, has way too few answers.

Given (by any means) a list of strings, return (by any means) a set of letters that, when removed from the given strings, leaves the total length of (what remains of) the strings as small as possible, while keeping each string unique and at least one character long.

Examples:

Given "Day" and "day"; return "ay", because the given strings will be "D" and "d" when the characters "ay" are removed.

Given "Hello World!", "Hello world.", and "Hello world"; return "Helo Wrd" gives  because the strings will be "!", "w.", and "w" when the characters "Helo Wrd" (with a space) are removed.

Given "century", "decade", "year", "month", "week", "day", "hour", "minute", and "second"; return "centurdowi" because the given words will be "y", "a", "ya", "mh", "k", "ay", "h", "m", "s" when the characters "centurdowi" are removed.

The order and format of the returned set is not important.

Haskell, 138 130 bytes

import Data.List
c=concat
f i=snd$minimum[(length$c q,s)|s<-subsequences$nub$c i,q<-[map(filter(`notElem`s))i],nub q==q,all(>"")q]

Usage example: f ["century", "decade", "year", "month", "week", "day", "hour", "minute", "second"] -> "centurdoki".

This is a brute force approach.

     s<-subsequences$nub$c i  -- concatenate input i to a single string, remove
                              -- duplicates and make a list of all subsequences
       q<-[map(filter(...))i] -- remove chars appearing in subsequence s from all
                              -- input words, call result q
          nub q==q            -- keep those s where q has no duplicates (i.e. each
                              -- resulting string is unique) and
            all(>"")q         -- contains no empty strings
  (length$c q,s)              -- make pairs from all kept s, where the first element
                              -- is the combines length of all strings in q,
                              -- second element is s itself
snd$minimum                   -- find minimum of those pairs and discard length

Edit: @Seeq helped me saving 8 bytes. Thanks!


Select the word around the given index in a given string In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected.
(This feature has more complicated properties, but they will not be required to be implemented for this challenge.)
For example, let | be your cursor in abc de|f ghi.
Then, when you double click, the substring def will be selected.
Input/Output
You will be given two inputs: a string and an integer.
Your task is to return the word-substring of the string around the index specified by the integer.
Your cursor can be right before or right after the character in the string at the index specified.
If you use right before, please specify in your answer.
Specifications (Specs)
The index is guaranteed to be inside a word, so no edge cases like abc |def ghi or abc def| ghi.
The string will only contain printable ASCII characters (from U+0020 to U+007E).
The word "word" is defined by the regex (?<!\w)\w+(?!\w), where \w is defined by [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], or "alphanumeric characters in ASCII including underscore".
The index can be 1-indexed or 0-indexed.
If you use 0-indexed, please specify it in your answer.
Testcases
The testcases are 1-indexed, and the cursor is right after the index specified.
The cursor position is for demonstration purpose only, which will not be required to be outputted.
string    index     output    cursor position
abc def   2         abc       ab|c def
abc def   5         def       abc d|ef
abc abc   2         abc       ab|c abc
ab cd ef  4         cd        ab c|d ef
ab   cd   6         cd        ab   c|d
ab!cd     1         ab        a|b!cd

V, 10, 9 7 bytes
À|diwVp

Try it online!
This answer uses 1-based indexing.
This could be shorter if we do exactly what the title says: "Select the word around the given index in a string". We could do
À|viw

Which literally selects the word, but unfortunately doesn't change the output at all. So we need a little workaround to make it work by cutting it into a register, deleting the rest of the text, then pasting the register back in.
Explanation:
À|          " Jump the position of argument 1
  diw       " (d)elete (i)nside this (w)ord.
     V      " Select this line
      p     " And replace it with the word we just deleted


Sum of combinations with repetition Write the shortest code you can solving the following problem:

Input:

An integer X with  2 <= X and X <= 100

Output:

Total combinations of 2, 3, and 5 (repetition is allowed, order matters) whose sum is equal to X.

Examples:

Input: 8

Output: 6, because the valid combinations are:

3+5
5+3
2+2+2+2
2+3+3
3+2+3
3+3+2

Input: 11

Output: 16, because the valid combinations are

5+3+3
5+2+2+2
3+5+3
3+3+5
3+3+3+2
3+3+2+3
3+2+3+3
3+2+2+2+2
2+5+2+2
2+3+3+3
2+3+2+2+2
2+2+5+2
2+2+3+2+2
2+2+2+5
2+2+2+3+2
2+2+2+2+3

Input: 100

Output: 1127972743581281, because the valid combinations are ... many

Input and output can be of any reasonable form.
The lowest byte count in each language wins.
Standard code-golf rules apply.

Python 2, 46 45 bytes

thanks to xnor for -1 byte

f=lambda n:n>0and f(n-2)+f(n-3)+f(n-5)or n==0

Try it online!


I text the correct combo of ones and zeros I recently listed to the song I'm a Textpert about texting while driving and one particular line in the song inspired this challenge.

  I never stoop so low as to text photos / Instead I text the correct combo of ones and zeros

Now obviously, this would be an almost impossible thing to do in ones head and so you should help textperts world wide by coding a program to do the same thing.

Your job is to take the name of an image file with the dimensions 500x500 pixels and output the file as binary. You may also take an image as input, if you language supports it.

You may use image files with the extensions

.jpg
.png
.gif
.bmp
.svg

Allow me to demonstrate how to convert an image into binary, for those who don't understand what I mean.

Step 1

Take the first pixel in the file and retrieve its RGB value as 3 decimal numbers: R, G and B. Let's assume, for example, that the first pixel is 255,0,0 (red).

Step 2

Convert each number into its 8-bit binary representation and concatenate into a single 24-bit number. For the example, this yields 111111110000000000000000

Step 3

Add this 24-bit number to the final output. Therefore, the final output should be 6000000 digits long and should consist of entirely 1 and 0

This is a code-golf so shortest code wins!

Pyth, 14 13 bytes

-1 byte thanks to Erik the Outgolfer (z can be removed for implicit input).

sm.[\08.Bd.n'

Explanations

sm.[\08.Bd.n'

            '    # Open the path/URL given as implicit input. Return list of color triples for color images: [(255, 125, 23), ...]
          .n     # Flatten the list
 m     .Bd       # For each element of the list, convert to binary
  .[\08          # Pad with zeros on the left up to 8 characters
s                # Concatenate the list of bytes

Unfortunately, because of safety reasons, that cannot be tested with the online interpreter; you will have to clone Pyth to test it on your own computer.


Make a list continuous! Take an input list L containing positive integers, and insert the least amount of integers into the sequence, so that you make it a continuous one.

Example:

L = 4 2 6 1
Out: 4 3 2 3 4 5 6 5 4 3 2 1

The input and output formats are optional.

Test cases:

L = 1
Out: 1

L = 10 4
Out: 10 9 8 7 6 5 4

L = 13 13
Out: 13 13

L = 3 6
Out: 3 4 5 6

L = 4 4 1 1 4 4
Out: 4 4 3 2 1 1 2 3 4 4

This is code-golf... You know the rules.

Builtin
Husk:
…

Try it online!
I bet this builtin exists in more than one language, so I made this a community wiki, just add in more languages where this is a builtin if you know them!


Lisp Extraction Mission In Lisp style languages, a list is usually defined like this:

(list 1 2 3)

For the purposes of this challenge, all lists will only contain positive integers or other lists. We will also leave out the list keyword at the start, so the list will now look like this:

(1 2 3)

We can get the first element of a list by using car. For example:

(car (1 2 3))
==> 1

And we can get the original list with the first element removed with cdr:

(cdr (1 2 3))
==> (2 3)

Important: cdr will always return a list, even if that list would have a single element:

(cdr (1 2))
==> (2)
(car (cdr (1 2)))
==> 2

Lists can also be inside other lists:

(cdr (1 2 3 (4 5 6)))
==> (2 3 (4 5 6))

Write a program that returns code that uses car and cdr to return a certain integer in a list. In the code that your program returns, you can assume that the list is stored in l, the target integer is in l somewhere, and that all the integers are unique.

Examples:

Input: (6 1 3) 3

Output: (car (cdr (cdr l)))

Input: (4 5 (1 2 (7) 9 (10 8 14))) 8

Output: (car (cdr (car (cdr (cdr (cdr (cdr (car (cdr (cdr l))))))))))

Input: (1 12 1992) 1

Output: (car l)

Common Lisp, 99

The following 99 bytes solution is a CL version of the nice Scheme answer.

(defun g(l n &optional(o'l))(if(eql n l)o(and(consp l)(or(g(car l)n`(car,o))(g(cdr l)n`(cdr,o))))))

I originally tried to make use of position and position-if, but it turned out to be not as compact as I would have liked (209 bytes):

(lambda(L x &aux(p'l))(labels((f(S &aux e)(cons(or(position x S)(position-if(lambda(y)(if(consp y)(setf e(f y))))S)(return-from f()))e)))(dolist(o(print(f L))p)(dotimes(i o)(setf p`(cdr,p)))(setf p`(car,p)))))

Expanded

(lambda
  (l x &aux (p 'l))
  (labels ((f (s &aux e)
             (cons
              (or (position x s)
                  (position-if
                   (lambda (y)
                     (if (consp y)
                         (setf e (f y))))
                   s)
                  (return-from f nil))
              e)))
    (dolist (o (print (f l)) p)
      (dotimes (i o) (setf p `(cdr ,p)))
      (setf p `(car ,p)))))

Example

(funcall *fun* '(4 5 (1 2 (7) 9 (10 8 14))) 14)

The list is quoted, but if you really want, I can use a macro.
The returned value is[1]:

(CAR (CDR (CDR (CAR (CDR (CDR (CDR (CDR (CAR (CDR (CDR L)))))))))))

For tests, I used to generate a lambda form where l was a variable:

(LAMBDA (#:G854) (CAR (CDR (CDR (CAR (CDR (CDR (CDR (CDR (CAR (CDR (CDR #:G854))))))))))))

Calling this with the original list returns 14.

[1] (caddar (cddddr (caddr l))) would be nice too


3 and 5 Litre Jug Puzzle You may have seen this one in Die Hard: With a Vengeance... This question is based on the famous 3 and 5 Litre Jug Puzzle, but with a slightly different slant.

Golf up some code that when given an integer between 1 and 100 will provide you with the quickest instructions to measure out into a tank, the corresponding number of litres of water from a fountain, using a 3 litre jug and a 5 litre jug.

There are no gradations on either of the jugs; the fountain is abundant in supply of water, and the tank is assumed to be emptied out upon the start of each execution of the code.

You cannot access water from the tank once it goes into the tank.

The format of execution is as follows:

Input:

4 for example.

Output

Output each numbered step, as shown, followed by a tally of the volumes of the 5L jug, the 3L jug and the tank. Tally format also shown below. The number of steps must also be outputted at the end of the steps.

1) Fill 5L jug

5L: 5, 3L: 0, T: 0

2) Pour from 5L jug into 3L jug

5L: 2, 3L: 3, T: 0

3) Empty 3L jug

5L: 2, 3L: 0, T: 0

4) Pour from 5L jug into 3L jug

5L: 0, 3L: 2, T: 0

5) Fill 5L jug

5L: 5, 3L: 2, T: 0

6) Pour from 5L jug into 3L jug

5L: 4, 3L: 3, T: 0

7) Pour from 5L jug into tank

5L: 0, 3L: 3, T: 4

Volume measured out in 7 turns

Example 2

Input: 8

Output:

1) Fill 5L jug

5L: 5, 3L: 0, T: 0

2) Pour from 5L jug into tank

5L: 0, 3L: 0, T: 5

3) Fill 3L jug

5L: 0, 3L: 3, T: 5

4) Pour from 3L jug into tank

5L: 0, 3L: 0, T: 8

Volume measured out in 4 turns

Conventions

Fill xL jug - fills the associated jug to the top from the fountain
Empty xL jug - empties the contents of the associated jug into the fountain
Pour from xL jug into yL jug - Pours the contents of the xL jug into the yL jug
Pour from xL jug into tank - Pours the contents of the xL jug into the tank

Shortest code wins.

Ruby, 407 376 365 331 324 323

This is getting kind of hard to read...

x=y=n=d=0
g=gets.to_i
"#{[43435,102,t=45,t,12,t,12,t,t][g+~d]||12}".chars{|c|n+=1
puts [eval(["x-=t=[3-y,x].min;y+=t"+t=";'Pour from 5L jug into 3L jug'","x=5;'Fill 5L jug'","d+=x;x=0"+t.sub(/3.+/,"tank'")][c.ord%3].tr t='35xy',c<?3?t:'53yx'),"5L: #{x}, 3L: #{y}, T: #{d}"]}while g>d
$><<"Volume measured out in #{n} turns"

Takes input on STDIN.  Example run for N=10:

Fill 5L jug
5L: 5, 3L: 0, T: 0
Pour from 5L jug into tank
5L: 0, 3L: 0, T: 5
Fill 5L jug
5L: 5, 3L: 0, T: 5
Pour from 5L jug into tank
5L: 0, 3L: 0, T: 10
Volume measured out in 4 turns


Sort by what the digit pairs describe Given a positive integer, we can form a new number that's described by its digits taken pairwise (with a leading 0 added for numbers with odd number of digits).

For eg.:

1234 can be read as one 2, three 4s - so, the output for 1234 is 2444.
643 has an odd number of digits, so a leading zero is added to make it even. Then, 0643 can be read as: zero 6s, four 3s, hence the output would be 3333.

(This is OEIS A056967).

Task: Given an array of positive integers, sort them by their digit-pair-described value, in ascending order. Order does not matter between input numbers that lead to the same value.

Input: an array/list/set of positive integers. Leading zeros in the input are not allowed, and input as strings/lists of digits/etc. are not allowed - the inputs should be as close to an integer/numeric type as your language is capable of using.

Output: the array sorted in the above-mentioned way, returned in any of the usual ways (function return value/STDOUT/shouting into the void/etc.) You can print them individually, return them as numbers, strings, or lists of digits.

Test cases

Input
Output

[19, 91, 2345, 2023]
[19, 2023, 2345, 91]

[25257, 725, 91, 5219, 146125, 14620512]
[725, 5219, 14620512, 91, 146125, 25257]

[123130415 3335 91 111111111 528 88]
[528, 111111111, 123130415, 3335, 88, 91]

[1 21 33 4 5]
[1 4 5 21 33]

[3725, 10, 2537, 1, 1225, 2512]
[10, 1, 1225, 2512, 2537, 3725]

[125, 26, 1115, 1024]
[1115, 1024, 125, 26]

(In the 4th test case, 1, 4, and 5 all evaluate to 0, and so can be sorted among themselves in any order. Similarly in the fifth test case, 10 and 1 both evaluate to 0s, and so can be sorted in either order.)

(Related: Say what you see, One 1, Two 1's, One 2 One 1

Thanks to Kevin Cruijssen for help clarifying the question in the Sandbox.

APL (Dyalog), 26 bytes

Thanks ngn for saving 1 byte :)

{⍵[⍋⌽↑,⍨⌿⍴⌿0 10⊤⍵⊤⍨⍴⍨100]}

Try it online!

Inspiration take from dzaima & ngn


Exact generalised harmonic numbers The generalised harmonic number of order \$m\$ of \$n\$ is
$$H_{n,m} = \sum_{k=1}^n \frac 1 {k^m}$$
For example, the harmonic numbers are \$H_{n,1}\$, and \$H_{\infty,2} = \frac {\pi^2} 6\$. These are related to the Riemann zeta function as
$$\zeta(m) = \lim_{n \to \infty} H_{n,m}$$
Given two positive integers \$n > 0\$, \$m > 0\$, output the exact rational number \$H_{n,m}\$. The fraction should be reduced to its simplest term (i.e. if it is \$\frac a b\$, \$\gcd(a, b) = 1\$). You may output as a numerator/denominator pair, a rational number or any clear value that distinguishes itself as a rational number. You may not output as a floating point number.
This is code-golf, so the shortest code in bytes wins
Test cases
n, m -> Hₙ,ₘ
3, 7 -> 282251/279936
6, 4 -> 14011361/12960000
5, 5 -> 806108207/777600000
4, 8 -> 431733409/429981696
3, 1 -> 11/6
8, 3 -> 78708473/65856000
7, 2 -> 266681/176400
6, 7 -> 940908897061/933120000000
2, 8 -> 257/256
5, 7 -> 2822716691183/2799360000000

M, 4 bytes
Rİ*S

Try it online!
Obligatory trivial answer ;-;
Rİ*S  Main Link; takes n on the left and m on the right
R     Range: [1, 2, 3, ..., n]
 İ    Inverse/Reciprocal: [1, 1/2, 1/3, ..., 1/n]
  *   Exponent: [1, 1/2^m, 1/3^m, ..., 1/n^m]
   S  Sum


Reverse the consonants The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples follow.

Input: a test case.
The consonants here are t,s,t,c,s. They should come in reversed order, i.e. s,c,t,s,t and inserted back into the string to the same positions where the pre-reversed characters were located: a sect sate.
Input: well-done. Output: nedl-lowe.
Input: reverse the consonants. Output: setenne sne cohtosarvr.

This is the code golf, the shortest solution wins.

Y should be considered vowel regardless of what it is and not reversed.

Anything, as well as numbers, punctuation, quotes, and other symbols (@#$%^&*(){}[]\|/<>~-_+=`), could potentially appear in the input.

Retina, 22 21 20 17

O#^`[b-z-[eiouy]]

Try it online!

1 byte thanks to Leaky Nun!

4 bytes thanks to Martin!

O means sort, and # means to sort by numeric value. Since none of the matched characters will ever have a numeric value, all letters have the same weight: 0. ^ means to reverse the order of the sorted values, which thanks to stable sorting means the values are reversed.

The -[...] means to do the setwise difference between the outer character class and this inner class. This is part of .NET and you can read more at the MSDN.


MarGolf Meets Langton's Anthill This is Markov.
Markov's golf ball rolls around randomly.
Markov's ball will hole however he strikes it.
Markov is smart.
Be like Markov.

And this:

is an anthill in Langton's backyard.
The anthill is big enough to hold Markov's golfball, MarGolf. However, the anthill moves and changes direction depending on the surrounding terrain.

The Task

Take an input of a 10x20 field:

* MarGolf
O Lanton's Anthill
, Anthill turns 90 degrees clockwise
. Anthill turns 90 degrees counterclockwise
0 MarGolf in Langton's Anthill

A field looks like this:

,...,.,,..,...,.,,..
..,.,,,..,...,..,.,.
.,,*.,....,.,,,.,,,.
,.,,.,...,,.,.,,,,,.
.,..,....,,.....,,.,
,.,.,...,..,.,,,,..,
....,,,,,,,,,.......
........,,.,...,...,
,,,,,,,,,,,,....,O.,
,.,.,.,.....,,.,,,,,

Game rules:
The configuration of the input field is called tick 0. Your program needs to evaluate and print out the configuration of the next tick, in which both MarGolf and Langton's Anthill will move to another cell. The the item in the current cell will become the item currently in the target cell. If both MarGolf and the anthill move to the same cell in the next tick, the game ends.

Movement rules:

MarGolf moves randomly. All nine cells in the 3x3 area around MarGolf has equal chance of being selected. This becomes a choice among 6 cells at an edge of the field, and 4 cells at a corner.
Langton's Anthill needs to remember its movement direction of either up, down, left, or right (NSEW or whatever equivalent). It moves one cell in its direction each tick, and the original content of the cell changes its direction clockwise or anti-clockwise, as specified above. Initial direction at tick 0 is random, each direction has an equal chance of being the initial.

Notes

The program needs to print the configuration of each tick, until the game ends.
The tick number precedes the field configuration of each tick.
You may assume the input is always valid.
The shortest program is bytes wins.

Update: forgot to mention anthill reverses direction before moving if it would otherwise go off the field. Credit to user81655 for reminding.

Java 10, 611 609 607 593 591 bytes

m->{int x=0,y=0,X=0,Y=0,r=10,c,d=4,e;for(d*=Math.random();r-->0;)for(c=20;c-->0;){if(m[r][c]<43){x=r;y=c;}if(m[r][c]>48){X=r;Y=c;}}for(;;d=m[r][c]<45?d<2?d+2:d<3?1:0:d>1?d-2:d>0?2:3){p(m);for(e=4;e==4;e*=Math.random())e=9;m[r=x][c=y]=m[x+=e/3<1?x>0?-1:1:e/3>1?x<9?1:-1:0][y+=e%3<1?y>0?-1:1:e%3>1?y<19?1:-1:0];if(m[x][y]>48){m[x][y]=48;m[r][c]=0;p(m);e/=0;}m[x][y]=42;m[r=X][c=Y]=m[X+=d<1?X<9?1:-1:d==1?X>0?-1:1:0][Y+=d==2?Y<19?1:-1:d>2?Y>0?-1:1:0];if(m[X][Y]<43){m[r][c]=48;m[X][Y]=0;p(m);e/=0;}m[X][Y]=79;}}void p(char[][]m){var p="";for(var a:m)p+=p.valueOf(a)+"\n";System.out.println(p);}

-4 bytes thanks to @ceilingcat.
Assumes the final swap of * and O will empty the cell where * is coming from.
Explanation:
Try it online.
m->{                        // Method with character-matrix parameter and no return-type
  int x=0,y=0,              //  [x,y] coordinates of MarGolf
      X=0,Y=0,              //  [X,Y] coordinates of Langton's Anthill
      r=10,c,               //  Temp [x,y] coordinates
      d=4,                  //  Direction Langton's Anthill
      e;                    //  Direction MarGolf
  for(d*=Math.random();     //  Set the direction Langton's Anthill randomly [0,3]
      r-->0;)               //  Loop over the rows:
    for(c=20;c-->0;){       //   Inner loop over the columns:
      if(m[r][c]<43){       //    If '*' is found:
        x=r;y=c;}           //     Set MarGolf's [x,y] coordinates
      if(m[r][c]>48){       //    If 'O' is found:
        X=r;Y=c;}}          //     Set Langton's Anthill's [X,Y] coordinates
  for(;                     //  Loop indefinitely:
       ;                    //    After every iteration:
        d=                  //     Change the direction of Langton's Anthill:
          m[r][c]<45?       //      If the swapped cell contained a comma:
           d<2?d+2:d<3?1:0  //       Change the direction clockwise
          :                 //      Else (the swapped cell contained a dot):
           d>1?d-2:d>0?2:3){//       Change the direction counterclockwise
  p(m);                     //  Pretty-print the matrix
  for(e=4;e==4;e*=Math.random())e=9;
                            //  Change direction MarGolf randomly [0-9] (excluding 4)
  m[r=x][c=y]               //  Save the current MarGolf coordinates
   =m[x+=e/3<1?x>0?-1:1:e/3>1?x<9?1:-1:0]
     [y+=e%3<1?y>0?-1:1:e%3>1?y<19?1:-1:0];
                            //  And change that cell to the content in direction `e`
                            //  0 to 9 (excl. 4) is NW,N,NE,W,n/a,E,SW,S,SE respectively
                            //  If `e` would go out of bounds, it moves opposite instead
  if(m[x][y]>48){           //  If MarGolf reached Langton's Anthill:
    m[x][y]=48;             //   Set that cell to '0'
    m[r][c]=0;              //   And empty the swapped cell
    p(m);                   //   Print the final status of the matrix
    e/=0;}                  //   And stop the loop with an error to exit the program
  m[x][y]=42;               //  Change the cell in the new coordinate to '*'
  m[r=X][c=Y]               //  Save the current Langton's Anthill coordinates
   =m[X+=d<1?X<9?1:-1:d==1?X>0?-1:1:0]
      [Y+=d==2?Y<19?1:-1:d>2?Y>0?-1:1:0];
                            //  And change that cell to the content in direction `d`
                            //  0 to 3 is E,W,S,N respectively
                            //  If `d` would be out of bounds, it moves opposite instead
  if(m[X][Y]<43){           //  If MarGolf reached Langton's Anthill:
    m[r][c]=48;             //   Set that cell to '0'
    m[X][Y]=0;              //   And empty the swapped cell
    p(m);                   //   Print the final status of the matrix
    e/=0;}                  //   And stop the loop with an error to exit the method
  m[X][Y]=79;}}             //  Change the cell in the new coordinate to 'O'

void p(char[][]m){          // Separated method to print the given matrix
  var p="";                 //  String to print, starting empty
  for(var a:m){             //  Loop over the rows:
    p+=p.valueOf(a)         //   Convert the character-array to a String line and append,
                     +"\n"; //   including a trailing newline
  System.out.println(p);}   //  Print the String with trailing newline as separator


Cover a set with multiples Lets take a set of integers greater than 1 and call it X.  We will define S(i) to be the set of all members of X divisible by i where i > 1.   Would like to choose from these subsets a group of sets such that

Their union is the set X
No element of X is in two of the sets.

For example we can regroup {3..11} as

      {3,4,5,6,7,8,9,10,11}
S(3): {3,    6,    9,     }
S(4): {  4,      8,       }
S(5): {    5,        10,  }
S(7): {        7,         }
S(11):{                 11}

Some sets cannot be expressed in this way.  For example if we take {3..12}, 12 is a multiple of both 3 and 4 preventing our sets from being mutually exclusive.

Some sets can be expressed in multiple ways, for example {4..8} can be represented as

      {4,5,6,7,8}
S(4): {4,      8}
S(5): {  5,     }
S(6): {    6,   }
S(7): {      7, }

but it can also be represented as

      {4,5,6,7,8}
S(2): {4,  6,  8}
S(5): {  5,     }
S(7): {      7, }

Task

Our goal is to write a program that will take a set as input and output the smallest number of subsets that cover it in this fashion.  If there are none you should output some value other than a positive integer (for example 0).

This is a code-golf question so answers will be scored in bytes, with less  bytes being better.

Tests

{3..11}       -> 5
{4..8}        -> 3
{22,24,26,30} -> 1
{5}           -> 1

Python 2, 167 bytes

lambda a:([q for q in range(a[-1])if a in[sorted(sum(j,[]))for j in combinations([[p for p in a if p%i<1]for i in range(2,1+a[-1])],q)]]+[0])[0]
from itertools import*

Try it online!

-9 bytes thanks to Zacharý
-4 bytes thanks to Mr. Xcoder
-2 bytes by using lists instead of sets
-5 bytes by using a in [...] rather than any([a == ...]).
-2 bytes thanks to Mr. Xcoder
-8 bytes by merging statements
-5 bytes thanks to Mr. Xcoder
-7 bytes thanks to Mr. Xcoder / Zacharý
+7 bytes to fix bug
-1 byte thanks to ovs

note

This is extremely slow for larger maximum numbers because it is in no way optimized; it did not within 2 minutes on Mr. Xcoder's device for [22, 24, 26, 30].