Letter Boxed validator The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows:

You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appears twice. The aim of the game is to find words made of those 12 letters (and those letters only) such that:

Each word is at least 3 letters long;
Consecutive letters cannot be from the same side;
The last letter of a word becomes the first letter of the next word;
All letters are used at least once (letters can be reused).

In this challenge, you are given the letters and a list of words. The goal is to check whether the list of words is a valid Letter Boxed solution.
Input
Input consists of (1) 4 groups of 3 letters and (2) a list of words. It can be in any suitable format.
Output
A truthy value if the list of words is a valid solution to the Letter Boxed challenge for those 4×3 letters, and a falsey value otherwise.
Test cases
Groups of letters={{I,C,O},  {M,R,E}, {G,N,S}, {A,P,L}}.
Truthy values

PILGRIMAGE, ENCLOSE
CROPS, SAIL, LEAN, NOPE, ENIGMA

Falsey values

PILGRIMAGE, ECONOMIES (can't have CO since they are on the same side)
CROPS, SAIL, LEAN, NOPE (G and M have not been used)
PILGRIMAGE, ENCLOSURE (U is not one of the 12 letters)
ENCLOSE, PILGRIMAGE (last letter of 1st word is not first letter of 2nd word)
SCAMS, SO, ORGANISE, ELOPE (all words must be at least 3 letters long).

Note that in this challenge, we do not care whether the words are valid (part of a dictionary).
Scoring:
This code-golf, lowest score in bytes wins!

05AB1E, 37 35 33 32 31 29 28 bytes
εk3÷üÊ}DO2@¹ü«εüQO}²{¹˜êQ)˜P

-2 bytes by taking inspiration of the ê approach @Emigna used in his 05AB1E answer.
-3 bytes thanks to @Grimy.
Takes a list of list of characters for the words as first input, and the flattened list of twelve letters as second input.
Try it online or verify all test cases.
Explanation:

ε         # Map over the character-lists `y` of the (implicit) input-list of words:
 k        #  Get the index of each character in the (implicit) input-list of letters
  3÷      #  Integer-divide each index by 3
    üÊ    #  Check for each overlapping pair of integers that they are NOT equal
}D        # After the map: duplicate the resulting list
  O       #  Get the sum of each inner list of truthy/falsey values
   2@     #  And check that each is larger than 2 (so all words had at least 3 letters)
¹ü        # Get all overlapping pairs of character-lists from the input-list of words:
  «       #  And merge them together to a flattened list of characters
   ε   }  # Map over those merged character lists:
    üQ    #  Check for each overlapping pair of characters in the list that they are equal
      O   #  And take the sum of this (where we'd expect 1/truthy if the last character of
          #  the first word and the first character of the second word are equal)
          #  (NOTE: This could fail for inputs with identical adjacent characters,
          #   but the earlier check of `εk3÷üÊ}` already covers for this)
²{        # Push the input-list of letters, and sort them
  ¹˜      # Push the input-list of list of word-letters, flattened,
    ê     # and then uniquified and sorted as well
     Q    # And check if both lists of characters are the same
)˜        # Then wrap everything on the stack into a list, and deep flatten it
  P       # And check if everything is truthy by taking the product
          # (which is output implicitly as result)


Write a brainfuck translator In any programming or scripting language x, write a program that takes a valid brainfuck sourcecode from stdin and output, to stdout, the sourcecode of a program, written in language x, that would output the exact same thing as the brainfuck program would do.

Your program must work for any valid brainfuck program, including the empty file.

Your score would be equal to the byte count of your sourcecode, plus the byte count of your output given the following input:

+++++ [-]
+++++ +++++ [
    > +++++ ++
    > ++ +++ ++++ +
    > +++
    <<< -
]
> ++ . H
> + . e
++ +++ ++. l
. l
+++ . o
> ++ . space
< +++++ +++ . w
----- --- . o
+++ . r
---- - - . l
----- --- . d
> + . exclamation mark
------lol; useless code :-)--------------------------[.............................................][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]<-<<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

For example, for an input of [-], the output of *p=0; is much more favourable than while(*p) *p--;

If you happen to use non-ASCII characters, the byte count must be calculated using the UTF-8 encoding.

Lowest score wins. However, creative solutions that attempt to minimise the output shall be encouraged by upvotes.

Brainfuck, 5 + 540 = 545 bytes

5 bytes of code, 540 from output of given test file (assuming  got the count right from my paste of that code).

,[.,]

Assuming EOF is 0.


How to convert HEX2 to RGBA? The world of art is full of colour, but the world of the network is even fuller than the world of art of diferent colours and it's renderings. That's why we need to know how to convert one type of colour format to another.
The challenge is self-evident:
Write a program / function than converts an given HEX code (#00ff0080, for instance) to RGBA (like rgba(0, 255, 0, 0.5)).
Rules:

External libraries/ built-ins for converting HEX to RGBA are disallowed. However, jQuery and syntax replacers like that are acceptable.
Standard Input/Output rules apply.
Format of the alpha can be between (1 == 100%) or the other (100 == 100%) that's not really important.
The output is flexible, as long as it returns the 4 converted values (as a String, Array, List, your choice).
You may choose to take the input without the # in the beginning. Hence, you can take input as either #RRGGBBAA or RRGGBBAA. You can assume that the hex code (excluding the #) will always be 8 characters long.
You should divide all the values by 255, including the alpha. The minimum decimal precision (for the alpha will be 2 decimal places).

Test Cases
Input:  00ff0080
Output: 0, 255, 0, 0.5

Scoring
code-golf, the code with the least amount of bytes wins.

JavaScript (ES6), 73 54 50 bytes
(Saved some bytes thanks to @LeakyNun, the edited challenge, and @CraigAyre.)
s=>s.match(/../g).map((c,i)=>('0x'+c)/(i-3?1:255))

let f=

s=>s.match(/../g).map((c,i)=>('0x'+c)/(i-3?1:255))

console.log(f('00ff0080'));


Ambiguous Locations on a Grid You have a little robot with four distance sensors. It knows the layout of a room, but it has no sense of orientation other than being able to lock onto the grid orientation. You want to be able to find out where the robot is based on the readings, but it can be ambiguous because of the limited sensors.

Challenge Explanation

You will be given a room layout and four clockwise distance readings giving the number of cells between you and a wall. There can be walls in the middle of the room and the edges of the grid are also walls. The robot cannot be placed on top of a wall.

Your objective is to list all of the locations within the room that the robot could be in that would give the given readings. Keep in mind that the robot has no sense of orientation (other than being locked to 90 degree angles on the grid- i.e. the robot will never be oriented diagonally or some other skew angle), so a reading of [1, 2, 3, 4], for example, is the same as reading [3, 4, 1, 2].

Examples

For these examples, cell coordinates will be given as 0-indexed (x, y) pairs from the top-left cell. Readings will be given in clockwise order in a square bracketed list. Layouts will use pound signs for walls and other characters (usually dots) to represent empty cells.

Case 1

. . . .
. . . .
. . # .
. . . .

[1, 0, 2, 3] ==> (1, 0), (3, 1)
[0, 0, 3, 3] ==> (0, 0), (3, 0), (0, 3), (3, 3)
[2, 1, 1, 0] ==> (0, 2), (2, 1)
[1, 1, 2, 2] ==> (1, 1)

Case 2

# a . # a .
a # . . # a
. . # . . #
# . . # . .
a # . . # a
. a # . a #

[0, 0, 1, 1] ==> every position on the grid that is a dot
[1, 0, 0, 0] ==> all of the a's on the grid

Case 3

.

[0, 0, 0, 0] ==> (0, 0)

Case 4

. # #
. . .

[1, 2, 0, 0] ==> (0, 1)
[0, 1, 2, 0] ==> (0, 1)
[0, 0, 1, 0] ==> (0, 0)
[1, 0, 1, 0] ==> (1, 1)
[0, 1, 0, 1] ==> (1, 1)

Case 5

. # . .
. . . .
. . # .
. . . .

[2, 1, 1, 0] ==> (0, 2), (2, 1)
[0, 2, 2, 1] ==> (1, 1)
[1, 0, 2, 2] ==> (1, 1)
[0, 3, 0, 0] ==> (0, 0)
[1, 0, 1, 1] ==> (1, 2)

Other Rules

Input may be in any convenient format. Input is a grid of walls and spaces and a list of four distances in clockwise order.
Output may either be a list of all cells that satisfy the reading or a modified version of the grid showing which cells satisfy the reading. The exact format of the output doesn't matter as long as it is reasonable and consistent. Valid output formats include, but are not limited to:

Printing a line for each cell coordinate as an ordered pair
Printing the grid with ., #, and ! for space, walls, and possible locations, respectively.
Returning a list of ordered pairs
Returning a list of indexes
Returning a list of lists using different values for spaces, walls, and possible locations
Return/print a matrix of 0s and 1s, using 1s to represent cells where the reading would occur. (It is not necessary to include walls)
Once again, this list is not exhaustive, so other representations are valid as long as they are consistent and show every possible valid location in a grid or list. If you are unsure, leave a comment and I will be happy to clarify.

You may assume that a reading corresponds to at least one location on the grid.
You may assume that the input grid is at least 1x1 in size and has at least one empty space.
You may assume that the input grid is no larger than 256 cells in each dimension.
You may assume that the input grid is always a perfect rectangle and not jagged.
There is no penalty or bonus if your program happens to give sane outputs for invalid inputs.
This is code golf, so shortest code wins.

JavaScript (ES6),  130 128 126  125 bytes
Takes input as \$(m)(l)\$ where \$m\$ is a binary matrix describing the room layout (\$0\$ = wall, \$1\$ = empty) and \$l\$ is the list of distances.
Returns another binary matrix where each valid position is marked with \$1\$.

m=>l=>m.map((r,y)=>r.map((v,x)=>v&!!([...'3210321'].map(d=>(g=X=>(m[Y+=~-d%2]||0)[X+=(d-2)%2]?1+g(X):0)(x,Y=y))+g).match(l)))

Try it online! (with post-processed output for readability)
Commented
m => l =>                         // m[] = layout matrix; l[] = list of distances
  m.map((r, y) =>                 // for each row r[] at position y in m[]:
    r.map((v, x) =>               //   for each cell v at position x in r[];
      v &&                        //     yield 0 if v = 0
      !!(                         //     otherwise, test whether we can find l[] within a
        [...'3210321']            //     list containing twice the results of the sensors
        .map(d =>                 //       for each direction d:
          (g = X => (             //         g = recursive function taking X
              m[Y += ~-d % 2]     //         add dy[d] to Y
              || 0                //         use a dummy object if we're out of the board
            )[X += (d - 2) % 2] ? //         add dx[d] to X; if (m[Y] || 0)[X] is equal to 1:
              1 +                 //           add 1 to the final result
              g(X)                //           and do a recursive call
            :                     //         else:
              0                   //           yield 0 and stop recursion
          )(x, Y = y)             //         initial call to g with X = x and Y = y
        )                         //       end of map() over directions
        + g                       //       coerce the result to a comma-separated string,
                                  //       followed by harmless garbage
      ).match(l)                  //     test whether l[] can be found in this string
                                  //     (l[] is implicitly coerced to a string as well)
    )                             //   end of map() over r[]
  )                               // end of map() over m[]


Finite tilings in one dimension The purpose of this challenge is to determine if a collection of one-dimensonal pieces can be tiled to form a finite continuous chunk.

A piece is a non-empty, finite sequence of zeros and ones that starts and ends with a one. Some possible pieces are 1, 101, 1111, 1100101.

Tiling means arranging the pieces so that a single contiguous block of ones is formed. A one from one piece can occupy the place of a zero, but not of a one, from another piece.

Equivalently, if we view a one as being "solid material" and a zero as a "hole", the pieces should fit so as to form a single stretch, without leaving any holes.

To form a tiling, pieces can only be shifted along their one-dimensional space. (They cannot be split, or reflected). Each piece is used exactly once.

Examples

The three pieces 101, 11, 101 can be tiled as shown in the following, where each piece is represented with the required shift:

  101
11
   101

so the obtained tiling is

111111

As a second example, the pieces 11011 and 1001101 cannot be tiled. In particular, the shift

 11011
1001101

is not valid because there are two ones that collide; and

11011
  1001101

is not valid because the result would contain a zero.

Additional rules

The input is a collection of one or more pieces. Any reasonable format is allowed; for example:

A list of strings, where each string can contain two different, consistent characters;
Several arrays, where each array contains the positions of ones for a piece;
A list of (odd) integers such the binary representation of each number defines a piece.

The output should be a truthy value if a tiling is possible, and a falsy value otherwise. Output values need not be consistent; that is, they can be different for different inputs.

Programs or functions are allowed, in any programming language. Standard loopholes are forbidden.

Shortest code in bytes wins.

Test cases

Each input is on a different line

Truthy

1
111
1, 1
11, 111, 1111
101, 11, 1
101, 11, 101
10001, 11001, 10001
100001, 1001, 1011
10010001, 1001, 1001, 101
10110101, 11001, 100001, 1
110111, 100001, 11, 101
1001101, 110111, 1, 11, 1

Falsy

101
101, 11
1, 1001
1011, 1011
11011, 1001101
1001, 11011, 1000001
1001, 11011, 1000001, 10101

JavaScript (ES6), 74 73 70 bytes

Takes input as an array of 32-bit integers. Returns a boolean.

f=([n,...a],x)=>n?[...f+''].some(_=>n&&!(x&n)&f(a,x|n,n<<=1)):!(x&-~x)

Or 66 bytes with inverted truthy/falsy values:

f=([n,...a],x)=>n?[...Array(32)].every(_=>x&n|f(a,x|n,n*=2)):x&-~x

Test cases

f=([n,...a],x)=>n?[...f+''].some(_=>n&&!(x&n)&f(a,x|n,n<<=1)):!(x&-~x)

console.log('[Truthy]')
console.log(f([0b1]))
console.log(f([0b111]))
console.log(f([0b1,0b1]))
console.log(f([0b11,0b111,0b1111]))
console.log(f([0b101,0b11,0b1]))
console.log(f([0b101,0b11,0b101]))
console.log(f([0b10001,0b11001,0b10001]))
console.log(f([0b100001,0b1001,0b1011]))
console.log(f([0b10010001,0b1001,0b1001,0b101]))
console.log(f([0b10110101,0b11001,0b100001,0b1]))
console.log(f([0b110111,0b100001,0b11,0b101]))
console.log(f([0b1001101,0b110111,0b1,0b11,0b1]))

console.log('[Falsy]')
console.log(f([0b101]))
console.log(f([0b101,0b11]))
console.log(f([0b1,0b1001]))
console.log(f([0b1011,0b1011]))
console.log(f([0b11011,0b1001101]))
console.log(f([0b1001,0b11011,0b1000001]))
console.log(f([0b1001,0b11011,0b1000001,0b10101]))

How?

f = (                       // f = recursive function taking:
  [n, ...a],                //   n = next integer, a = array of remaining integers
  x                         //   x = solution bitmask, initially undefined
) =>                        //
  n ?                       // if n is defined:
    [... f + ''].some(_ =>  //   iterate 32+ times:
      n &&                  //     if n is not zero:
        !(x & n)            //       if x and n have some bits in common,
        &                   //       force invalidation of the following result
        f(                  //       do a recursive call with:
          a,                //         the remaining integers
          x | n,            //         the updated bitmask
          n <<= 1           //         and update n for the next iteration
        )                   //       end of recursive call
    )                       //   end of some()
  :                         // else (all integers have been processed):
    !(x & -~x)              //   check that x is a continuous chunk of 1's


Get a word's individuality! I love /usr/share/dict/words; it's so handy! I use it for all my programs, whenever I can! You're going to take advantage of this ever so useful file to use, by testing a word's individuality.

Input

A word; defined in this challenge as any string of characters
/usr/share/dict/words in some format; you may hard code it, read from disk, assume it as a second argument, whatever makes the most sense in your challenge

Output

A words individuality (see below)

A word's individuality is derived from the following equation:

<the number of words for which it is a substring> / <length of the word>

Let's take a look at an example:
hello. There are 12 words which have the substring hello in them, divided by 5 (hello's length), and hello's individuality is 12/5 or 2.4

P.S. This is codegolf, so the lower the individuality score, the more individual

Because individuality is a long word, your program must be as short as possible

Good Luck!

Test Cases

You can use this convenient Node.js script, which fits the challenge requirements to fit your code. It is also how I generated the test cases:

var fs = require("fs");
var word = process.argv[2];

process.stdout.write("Reading file...")
fs.readFile("/usr/share/dict/words", function(err, contents) {
  console.log("Done")
  if (err) throw err;

  words = contents.toString().split("\n");

  var substrings = words.filter(w => w.indexOf(word) > -1).length;
  var length     = word.length;

  console.log(`${word} => ${substrings} / ${length} = ${substrings / length}`)
})

Test Cases:

hello => 12 / 5 = 2.4
individuality => 1 / 13 = 0.07692307692307693
redic => 52 / 5 = 10.4
ulous => 200 / 5 = 40
challen => 15 / 7 = 2.142857142857143
ges => 293 / 3 = 97.66666666666667
hidden => 9 / 6 = 1.5
words => 12 / 5 = 2.4
aside => 8 / 5 = 1.6

Bash, 41, 39, 34, 33, 26 bytes
EDIT:

Converted from function to a script
One byte off by removing the ignore case flag
Replaced wc -l with grep -c, saving 5 bytes. Thanks @Riley !

A rather trivial solution in bash + coreutils
Golfed
bc -l<<<`grep -c $1`/${#1}

Test
>cat /usr/share/dict/words| ./test ulous
7.60000000000000000000

>grep -i ulous /usr/share/dict/words | wc -l
38


Paint a still life (or a moving one) - draw an image in the Game of Life You are given as input a greyscale image. Your task is to find a static or looping pattern in Conway's Game of Life that resembles the input image as closely as possible.

Your output can be either a still image or a looping animation in some format that can be converted to gif. The output image dimensions should be the same as the input, and it must contain only black and white pixels.

If the output is an animation, each frame must be generated from the previous one according to the Game of Life rules, with one cell per pixel. The animation must loop, with the first frame being generated from the last frame by the same rules.

If the output is a still image, applying the game-of-life rules to it must produce the same image. This means that no 'alive' cell may have more than three or less than two 'alive' neighbours, and no 'dead' cell may have exactly three 'alive' neighbours. (Note that this is basically the same as an animation as described above, but with only one frame.)

Extra rules and clarifications:

You (or your program) may choose whether 'alive' cells are represented as white and 'dead' as black, or vice versa. That is, you can either hard-code this or your program can choose it based on the input image. (But it must be the same for every frame of the animation.)
The boundary conditions should be periodic, meaning that cells on the rightmost column have neighbours on the leftmost column, etc.
For animations, the frame rate is up to you (or your program); I imagine fast frame rates will work well for approximating grey pixels.
Please post at least two results embedded in your answer. If you can post results from all of the input images below, it's preferable.
It is acceptable to scale down the test images if this is necessary in order to achieve gifs with small enough file sizes. If you want to link to larger files as well, that's fine. If you want to show off, feel free to find some higher-resolution source files.
Please try to avoid having too many controllable parameters in your code - it's best if your program's only input is the image. The exception is if you want to have a parameter for controlling the number of animation frames, since that will affect the file size.
You may use external programs to change the format of the input and output files, and/or compile output frames into an animation if you want. (This is not a file-format-handling challenge.)
This is popularity-contest, so the answer with the most votes wins.

Here is a selection of test images, mostly taken from other questions on this site. (It's possible that I will add additional "bonus" input images later.)

Just to get things started, here's a very dumb reference attempt in Python 2, which takes advantage of the fact that a block of four squares is a stable structure in the Game of Life. It just rescales the input image by a factor of 4, then draws a block if the corresponding pixel is darker than 0.5.

from skimage import io
from skimage import transform
import sys

img = io.imread(sys.argv[1],as_grey=True)

source = transform.resize(img, [i/4 for i in img.shape])

img[:]=1
for x in xrange(source.shape[0]):
    for y in xrange(source.shape[1]):
        if source[x,y]<0.5:
            img[x*4, y*4] = 0
            img[x*4+1, y*4] = 0
            img[x*4, y*4+1] = 0
            img[x*4+1, y*4+1] = 0

io.imsave(sys.argv[2], img)

Here are some outputs from the example code. I'm sure that much better results are possible.


List the first 20 friendly number pairs I just started reading about friendly numbers and I think they sound great.

  In number theory, friendly numbers are two or more natural numbers with a common abundancy, the ratio between the sum of divisors of a number and the number itself. Two numbers with the same abundancy form a friendly pair; n numbers with the same abundancy form a friendly n-tuple.

So, how small  a program can you write to output a list of the first 20 friendly numbers.

Assuming I've understood everything I've read correctly the output of your program should be:

6,28
30,140
80,200
40,224
12,234
84,270
66,308
78,364
102,476
6,496
28,496
114,532
240,600
138,644
120,672
150,700
174,812
135,819
186,868
864,936
222,1036
246,1148

I'd also like to add that the program must calculate the answers and not use any external resources or hard coded answers (thanks Peter).


Write an interpreter generator There are quite a few accumulator-based programming languages featured in challenges across the site, but it's a little tiring to have to write almost identical code for each one. So in this challenge you will write a program which can generate interpreters from an input.
How does this work? Let us take this example:
[a ** 3, b * 2, c + 15, d = 0, e / 8]

This is not the only input format allowed. You are allowed to take input as an array of directives, an array of strings or even an entire string composed of these directives. Each directive looks similar to this:
[a, *, 3]

In this case, the a command multiplies (+ means add, - means subtract, * means multiply, / means divide, ** means exponentiate and = means assignment) the accumulator by 3 (the third element). So with the aforementioned input, we end up with this schema:
the command `a` cubes the accumulator
the command `b` doubles the accumulator
the command `c` adds 15 to the accumulator
the command `d` assigns the accumulator to 0
the command `e` divides the accumulator by 8

This means that typing the command cabdcbbe will output 7.5, because: (these rules apply to all generated "languages")

the accumulator is automatically initialized to 0 at the beginning of a program
the accumulator is implicitly outputted at the end of a command
(0 + 15)**3*2 is disregarded because d reassigns the accumulator to zero
(0 + 15)*2*2/8 = 7.5
When given an array of directives, your program should output a complete program in your favorite language (might be the one you write your answer in, but not necessarily) which takes a valid program in the newly generated language and outputs the accumulator at the end of it. If I were using JavaScript and were passed the array we discussed, my program might output

const program = prompt();
let acc = 0;
for (const command of program) {
  if (command === 'a') {
    acc = acc ** 3;
  } else if (command === 'b') {
    acc = acc * 2;
  } else if (command === 'c') {
    acc = acc + 15;
  } else if (command === 'd') {
    acc = 0;
  } else if (command === 'e') {
    acc = acc / 8;
  }
}
alert(acc);

now, for some more rules:

the input will always be valid. No destructive operators will be entered (such as a / 0 which divides the accumulator by zero.
each command will perform only one operation on the accumulator, so there will be no command which multiplies the accumulator by 3, squares it and adds 5 to it all in one go.
each command is one letter long.
the shortest answer in bytes wins. [code-golf rules]
the interpreter should read the program from STDIN or from a file.
on TIO, you may pre-define the input array in the header section, but your program should obviously be able to handle any valid input.
you only need to support the six operators mentioned previously.
commands can involve floating point numbers and not only integers
you may replace the operators but you must then state which ones you changed
you may output a float even if all operators yield integers. You may not truncate outputs however

J, 61 56 53 52 bytes
1 :0
('0'".@,~,@,.&' ')[u".@;@}:@,@,."1;:@'=: & &'
)

Try it online!
Note: -3 bytes off TIO for f=:
Operator changes used to match J's built-ins:

** -> ^
/ -> %
= -> ]

Additional notes:

This is adverb that modifies the program to interpret, which is given as a list of 3-element directives.  The resulting verb then takes the input as an argument, and returns the result.
Assumes the program string to execute will be read from right-to-left -- again, this is in keeping with J's normal convention.


Decoding the Kaadi system You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been encoded indirectly into the text. You figure out that the text uses a 'Kaadi' system, a restricted subset of the more common 'Katapayadi' system.

(The Katapayadi system is an ancient Indian system to encode numerals as letters, often used as mnemonics to remember long numbers.)

Your task here is to decode text encoded in the Kaadi system and print out the numerical value.

Details

Input characters

The Kaadi system is based on the Katapayadi system's rules, but uses only the first row of consonants. Your text here has been transliterated to Latin alphabet, and is known to contain only:

vowels 'a','e','i','o','u'
consonants 'g','k','c','j', and their capital forms (to represent the aspirated form of those consonants), and 'ṅ' and 'ñ'.

(You may choose to receive and handle 'ṅ' as 'ng' and 'ñ' as 'ny' if that's more convenient in your language.)

Value assignment

In this system,

each consonant when followed by a vowel has a digit associated with it. These are:

'k'=>1, 'K'=>2,
'g'=>3, 'G'=>4,
'ṅ'=>5,
'c'=>6, 'C'=>7,
'j'=>8, 'J'=>9,
'ñ'=>0

Note however, that these values apply only when these consonants are followed by a vowel. kacCi has the same value as kaCi (ka,Ci=(1,7)) since the middle c is unaccompanied by a vowel.

Additionally, an initial vowel or sequence of two vowels represents a 0. aikaCi would be: ai,ka,Ci = (0,1,7)
Extra vowels anywhere else in the middle of the text have no value: kauCia is the same as kaCi, the extra vowels can be ignored.

Final numeric value

Once the digit values of the letters have been figured out, the final numerical value is obtained as the reverse order of those digits i.e. the first digit from the text is the least significant digit in the final value.

Eg.
GucCi has Gu and Ci, so (4, 7), so the final value is 74.
kakakaGo is (1,1,1,4), so the the answer is 4111.
guṅKo is (3,2), so encodes 23. (gungKo if using ASCII-equivalent.)

Input

A string containing a Kaadi-encoded text

will contain only vowels and the above consonants
the vowels are always in lowercase and occur in groups of no more than 2
you may choose to accept the letters for 5 and 0 either as their Unicode characters 'ṅ' and 'ñ' or as their ASCII equivalents 'ng' and 'ny' (they're in lowercase in either form)
you may assume there are no spaces or punctuations

Output

The numerical value of the text, as given by the above rules

for empty input, an empty output or any false-y output in your language of choice is acceptable, in addition to 0
for invalid input (input with anything other than vowels and the above consonants), the output is undefined - anything goes

Test cases

"GucCi"
=> 74
"kakakaGo"
=> 4111
"aiKaCiigukoJe"
=> 913720
""
=> 0 //OR empty/falsey output
"a"
=> 0
"ukkiKagijeCaGaacoJiiKka"
=> 1964783210
"kegJugjugKeg"
=> 2891
"guṅKo"
=> 23
"Guñaaka"
=> 104
"juñiKoṅe"
=>5208

(the last ones can be:

"gungKo"
=> 23
"Gunyaaka"
=> 104
"junyiKonge"
=>5208

if you prefer that.)

Standard rules for I/O and loopholes apply. May the best golfer win!

JavaScript (ES6), 83 bytes
s=>s.replace(s=/(^|[ṅcCjJñkKgG])[aeiou]/g,(_,c)=>o=(s+s).search(c)%10+o,o='')&&o

Try it online!
How?
We use the following regular expression to match either the beginning of the string or one of the Kaadi consonants, followed by a vowel:
/(^|[ṅcCjJñkKgG])[aeiou]/g

For each match in the input string, we invoke the following callback function that takes the content c of the capturing group as parameter:
(_, c) => o = (s + s).search(c) % 10 + o

We find the value of the consonant by looking for its position in the regular expression (coerced to a string by adding it to itself).
The consonants are ordered in such a way that their value is equal to their position modulo 10:
string   : /  (  ^  |  [  ṅ  c  C  j  J  ñ  k  K  g  G  ]  )  [  a  e  i  o  u  ]  /  g
position : 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 ...
modulo 10: -  -  -  -  -  5  6  7  8  9  0  1  2  3  4  -  ...

When we match the beginning of the string instead of a consonant, c is an empty string whose position in the regular expression is 0 -- which, conveniently, is the expected result in that case.
Finally, we insert this digit at the beginning of the output string o.


Suggest me a challenge! I am too bored and want a challenge to solve. But I do not see any interesting challenges, and I am too lazy to search for one. Can you (Well, technically your code) suggest me one?

I/O

Input: None.

Output: A link to a random open(i.e. non-closed) challenge("Challenge" excludes tips!) on PPCG. You may not link to an answer in a challenge, Just a challenge. (I didn't ask for an interesting answer!)

Examples

Valid:

http://codegolf.stackexchange.com/questions/93288/make-me-a-mooncake
http://codegolf.stackexchange.com/questions/113796/raise-a-single-number
http://codegolf.stackexchange.com/questions/113898

Invalid:

http://codegolf.stackexchange.com/questions/78152/tips-for-golfing-in-matl (tips question)
http://codegolf.stackexchange.com/questions/113896/josephus-problem (closed)
http://codegolf.stackexchange.com/questions/84260/add-two-numbers/84365#84365 (linked to answer)

JavaScript (ES6), 209 bytes
Does work, but will most likely hit the StackExchange API limit very quickly. It will probably take a while to output the link, as it's checking randomly for a valid question.
_=>fetch(`//api.stackexchange.com/2.2/questions/${new Date%2e4}?site=codegolf`).then(_=>_.json()).then((a,b=a.items)=>{if(!b.length||b[0].tags.includes`tips`||b[0].closed_date)f();else console.log(b[0].link)})

f=_=>fetch(`//api.stackexchange.com/2.2/questions/${new Date%2e4}?site=codegolf`).then(_=>_.json()).then((a,b=a.items)=>{if(!b.length||b[0].tags.includes`tips`||b[0].closed_date)f();else console.log(b[0].link)})

f();


Find the Best Set of Adapters I'm trying to plug this really old phone into my computer but the phone seems to use a very obscure plug. Luckily I have some adapters. Unfortunately, I can't figure out which of them to use to connect my phone to my computer. Can you find the smallest number of adapters that can link my phone and computer?
Input
A pair of strings representing the phone and the computer's port type and a list of pairs of strings where the pair A, B transforms an input of type A to type B. Example:
("A", "D")
[
  ("A", "B"),
  ("C", "D"),
  ("B", "C"),
]

The first pair ("A", "D") is the desired connection. The rest are adapters.
Challenge
Output the number of adapters required to connect the phone to the computer. In the above example, the answer would be 3 as all 3 adapters would be required.
Test Cases
Phone, Computer
TypeA -> TypeB
TypeC -> TypeD
Output

A, D
A -> B
B -> C
C -> D
3

A, Z
A -> B
B -> C
C -> D
D -> Z
X -> Y
Y -> Z
4

A, B
A -> B
X -> Y
Y -> Z
1

A, C
A -> B
B -> C
C -> A
2

A, C
A -> A
B -> B
C -> C
A -> B
B -> C
2

Rules

Standard loopholes disallowed
This is code-golf, shortest code wins
You can assume it is possible to make the connection
The port on the phone and computer will not be of the same type
There may be adapters of type A -> A
It is not guaranteed that all of the adapters will be possible to use
You may take input in any form that is convenient

Jelly, 13 bytes
ṗJ$Ẏy@ƒ⁼⁵ɗƇẈṂ

Try it online!
Full program taking a list of pairs L (e.g. ['AB', 'BC', 'CD', 'DZ', 'XY', 'YZ']) as the first argument, the source as the second and the target as the third.
How it works
Brute-force approach.
ṗJ$Ẏy@ƒ⁼⁵ɗƇẈṂ - Main link. Takes L on the left and S on the right
  $           - Group the previous 2 links into a monad f(L):
 J            -   Yield the indices of L; [1, 2, 3, ..., len(L)]
ṗ             -   Get the n'th Cartesian power of L for each n in this range
   Ẏ          - Flatten into a list of lists
         ɗƇ   - Keep those for which the following is true:
      ƒ       -   Reduce the list by the following, starting with S:
    y@        -     Translate, according to the pair mapping
       ⁼⁵     - Does the final result equal T?
           ẈṂ - Get the length of the shortest element


Evaluating Logic Gates Logic gates are functions which perform basic logic operations. In this problem, we will account for the following 6 logic gates: AND, OR, XOR, NAND, NOR, and XNOR. Each of these takes two boolean inputs \$ a \$ and \$ b \$, and outputs a boolean. Below are the truth tables which show the output of each gate given two inputs.

Task

Given two boolean inputs \$ a \$ and \$ b \$, return/output a list of the names of all gates which would return a Truthy value. The order doesn't matter, but the names must be in the exact format as given in the 2nd sentence of the above paragraph (not the ones in the diagram). You are also allowed to output them exclusively in lowercase, if desired.

Clarifications

You may also output a delimiter-separated string
I will allow leading/trailing spaces

Test Cases

Input

0 0
0 1
1 0
1 1

Output

[NOR, NAND, XNOR]
[OR, NAND, XOR]
[OR, NAND, XOR]
[OR, AND, XNOR]

This is code-golf, so the shortest code in bytes wins!

Python 3, 53 50 49 bytes

Thanks @JonathanAllan for saving 1 byte!

lambda a,b:"NOR N"[a|b:5-a*b]+"AND X"+"NOR"[a^b:]

Try it online!


Pad a jagged array to be square Given a 2-dimensional jagged array and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that length is the same as the number of rows).
The fill values should always be added to the "edges", which may be the start or the end, but not in the middle.
For example, with the fill value 8, this array:
[[1, 5, 3],
 [4, 5],
 [1, 2, 2, 5]]

could become:
[[1, 5, 3, 8],
 [4, 5, 8, 8],
 [1, 2, 2, 5],
 [8, 8, 8, 8]]

Here is another valid output:
[[8, 8, 8, 8],
 [8, 1, 5, 3],
 [8, 4, 5, 8],
 [1, 2, 2, 5]]

However, the padding should be minimal: the size of the output square should be equal to the maximum of the length of the rows and the number of rows. For example, this is not a valid output for the input above:
[[1, 5, 3, 8, 8],
 [4, 5, 8, 8, 8],
 [1, 2, 2, 5, 8],
 [8, 8, 8, 8, 8],
 [8, 8, 8, 8, 8]]

More test cases
All using fill value 0 for simplicity.
Input:
[]
Output:
[]

Input:
[[],
 []]
Output:
[[0, 0],
 [0, 0]]

Input:
[[5]]
Output:
[[5]]

Input:
[[0, 0],
 [0],
 [0, 0, 0]]
Output:
[[0, 0, 0],
 [0, 0, 0],
 [0, 0, 0]]

Input:
[[1, 2, 3, 4]]

Output:
[[1, 2, 3, 4],
 [0, 0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0, 0]]

Input:
[[1],
 [2],
 [3],
 [4, 5]]
Output:
[[1, 0, 0, 0],
 [2, 0, 0, 0],
 [3, 0, 0, 0],
 [4, 5, 0, 0]]

Rules

The array's elements and the fill value can be of whatever type or set of values you like, as long as there are at least two distinct possibilities. For example, you could use characters, where the array is a multi-line string (where each line is a row), or you could restrict the values to single digits...
Standard loopholes are forbidden
Standard I/O rules apply
This is code-golf, so the shortest code in bytes wins

Haskell, 67 bytes

m%v|let l?x=take(maximum$length<$>(1<$m):m)$l++repeat x=(?v)<$>m?[]

Try it online!


Construct a polynomial with given roots The challenge is to write the shortest function/program to find a polynomial given the roots. The function or program should take valid input; that is, a list of integers representing the roots of the polynomial, and return valid output.

Output should return a sequence of numbers representing the polynomial.
For example:

2, 3 represents 2x^1 - 3x^0 = 0

1, 6, 1, 8, 0, 3, 3 represents 1x^6 + 6x^5 + 1x^4 + 8x^3 + 0x^2 + 3x^1 + 3x^0 = 0

-1 0 5, -3 represents -1x^3 + 0x^2 + 5x^1 + -3x^0 = 0

I hope you get the idea.

Example Usage

For an input of 1, 2, the output should be 1, -3, 2, which represents the equation 1x^2 + -3x^1 + 2x^0 = 0, or x^2 - 3x + 2 = 0.

For an input of 1, -1, 0, the output should be 1, 0, -1, 0.

For the input, duplicate values should be removed and order does not matter. For example, the result with input 3, 3, 6 should be the same as the result with input 6, 3.

Float arguments are optional.

As this is code golf, the shortest entry in characters wins. Good luck!

J, 8 bytes
A series of verbs:
|.p.1;~.

Call it like this:
   |.p.1;~. 1 2
1 _3 2

J has a built-in verb p. (Roots). It converts between polynomials like 2 _3 1 (reverse order from the problem) and a multiplier/root pair like (1; 1 2).
From right-to-left, ~. takes the unique elements, 1; pairs the list with 1, meaning we want the smallest integer polynomial, p. does the actual work, and |. reverses the resulting list.


Un-hash the Java Hash Hash Un-hashing

The basic goal of this challenge is to exploit the high probability of collision in the Java Hash function to create a list of plausible inputs that created an outputted hash. The program that can print the most results in one hour wins.

For example, hashing golf produces the number 3178594. Other 'words' you could hash to get the same number would be: hQNG, hQMf, hPlf

Details

The basic Java hash function is defined as:

function hash(text){
    h = 0;
    for(i : text) {
        h = 31*h + toCharCode(i);
    }
    return h;
}

You can use an altered or more efficient variant of the hash function (such as using bitwise to replace multiplication) if it produces the same results.

If your language of choice does not use signed ints or have integer overflow, you must implement a wrap function in the hash to emulate integer overflow so that 2147483648 would overflow to -2147483648.

You can choose not to worry about inputs that wrap around multiple times, such as those with 6-7 characters or more. If you choose to include those, you have a better chance of winning.

Additional Requirements

Your code should have at least one input: the hash itself. An optional second input is the maximum number of letters to guess. For example, guessHash(53134) might produce a list of all input combinations up to the absolute maximum amount (see the next requirement), and guessHash(53134, 4) will display all input combinations that contain 1-4 letters.
As there are an infinite amount of results, the most letters that can be in a single result will be set at 256. If your program can manage to output all 256 letter results in a reasonable amount of time (see next requirement), you automatically win.
Your program should not run for more than an hour on any non-specialized computer you use. Non-specialized means it can't run on a server system using 256 different cores or on a super-computer, it must be something that any regular consumer would/could buy. The shorter time period is for practicality, so that you don't have to use all your processing power for too long.
All the results in your final list of inputs must produce the same hash as the inputted hash.
You are to implement your own search, brute-force, or any algorithm to produce the final list.
Using a native search method or search method from another library is not allowed (example: binary search library). Using String.search(char) or Array.find(value) is okay if it is not a primary feature of your search algorithm (such as to spot duplicate results or find if a letter exists in given string).
The final list of input values should use all readable ASCII characters (32 to 126).

Example

I went ahead and created a very inefficient version of this challenge to produce an example list! Each result I gave is separated by spaces, although you can print each result on a new line or any other readable method of organization.

i30( i3/G i2NG hQNG hQMf hPlf golf

You do not have to print results to a file, just record how many results you get.

Judging

The number to un-hash is: 69066349

I will pick the best answer based on which-ever code produces the most results.  If you remember above where I said wrapping was optional, it'd be a good idea to include multiple wrappings if you want the most results in your final list.

If you have any questions or additional comments, feel free to ask.

Good Luck!

C#, 1.052 × 1010

The idea is to do the hash function in reverse to get all possible un-hashed strings from the given number. Integer overflow of the 32-bit hash value is also emulated in reverse by incrementing the given hash value by 2^32 on each iteration.

UPDATE: I've made several micro-optimisations that significantly improved the performance of my program. The new version produced 10.52 billion results in 15 minutes (compared to 9.05 billion in 1 hour for the previous version).

Futher improvement may be difficult since the output file was 117GB in size and that's about how much free space I have on my SSD. Writing results to the screen doesn't seem to be a viable option since it's almost a thousand times slower than writing to a file.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace Unhash
{
    class Program
    {
        const int minChar = 32;

        const int maxChar = 126;

        // limit maxStrLength to make sure that max hash value does not exceed long.MaxValue (2^63 - 1)
        const int maxStrLength = 12;

        static long[] minHashValues;

        static long[] maxHashValues;

        static Program()
        {
            minHashValues = new long[maxStrLength + 1];
            for (int strLength = 0; strLength <= maxStrLength; strLength++)
                minHashValues[strLength] = Pow(31, strLength) / (31 - 1) * minChar;

            maxHashValues = new long[maxStrLength + 1];
            for (int strLength = 0; strLength <= maxStrLength; strLength++)
                maxHashValues[strLength] = Pow(31, strLength) / (31 - 1) * maxChar;
        }

        static void GuessHash(int hash, int maxLength = 256)
        {
            Stopwatch sw = Stopwatch.StartNew();
            var timeLimit = new TimeSpan(0, 15, 0);

            if (maxLength > maxStrLength)
                maxLength = maxStrLength;

            long currentHash = (uint)hash;
            long step = 1L << 32;

            const int bufferSize = 32 * 1024;
            using (var writer = new StreamWriter("output.txt", false, new UTF8Encoding(false), bufferSize))
            {
                for (int strLength = 0; strLength <= maxLength; strLength++)
                {
                    long maxHash = maxHashValues[strLength];
                    if (currentHash > maxHash)
                        continue;

                    long minHash = minHashValues[strLength];
                    while (currentHash < minHash)
                        currentHash += step;

                    while ((currentHash <= maxHash) && (sw.Elapsed < timeLimit))
                    {
                        GuessLongHash(writer, currentHash, new char[strLength], strLength - 1);
                        currentHash += step;
                    }
                }
            }
        }

        static void GuessLongHash(StreamWriter writer, long hash, char[] chars, int charPos)
        {
            if (hash <= maxChar)
            {
                char ch = (char)hash;
                if (ch >= minChar)
                {
                    chars[charPos] = ch;
                    writer.WriteLine(new string(chars));
                }
                return;
            }

            char c = (char)(hash % 31);
            while (c < minChar)
                c += (char)31;

            while (c <= maxChar)
            {
                chars[charPos] = c;
                GuessLongHash(writer, (hash - c) / 31, chars, charPos - 1);

                c += (char)31;
            }
        }

        static long Pow(int value, int exponent)
        {
            long result = 1;
            for (int i = 0; i < exponent; i++)
                result *= value;
            return result;
        }

        static void Main(string[] args)
        {
            const int hash = 69066349;
            GuessHash(hash);
        }
    }
}


Rank a list of integers You're given a non-empty list of positive integers, e.g.
[6 2 9 7 2 6 5 3 3 4]

You should rank these numbers by their value, but as is usual in leaderboards, if there is a tie then all the tied numbers get the same rank, and an appropriate number of ranks is skipped. The expected output for the above list would therefore be
[3 9 1 2 9 3 5 7 7 6]

For example, the highest value in the input was 9, so this becomes a 1 (first rank). The third highest value is 6, so both 6s become 3, and the rank 4 is skipped entirely.
Rules
You can use any convenient, unambiguous, flat list format for input and output. The first/smallest rank in the output should always be 1.
You may write a program or a function and use any of the our 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
[8] -> [1]
[1 15] -> [2 1]
[18 14 11] -> [1 2 3]
[11 16 14 8] -> [3 1 2 4]
[15 15 15 15 15] -> [1 1 1 1 1]
[10 2 5 4 15 5] -> [2 6 3 5 1 3]
[5 5 10 10 5 11 18] -> [5 5 3 3 5 2 1]
[2 4 9 4 17 9 17 16] -> [8 6 4 6 1 4 1 3]
[11 17 19 17 10 10 15 3 18] -> [6 3 1 3 7 7 5 9 2]
[2 11 4 8 3 3 12 20 4 18] -> [10 4 6 5 8 8 3 1 6 2]
[12 6 10 2 19 19 6 19 8 6 18] -> [5 8 6 11 1 1 8 1 7 8 4]
[5 6 14 19 13 5 19 9 19 9 9 19] -> [11 10 5 1 6 11 1 7 1 7 7 1]
[9 2 12 3 7 11 15 11 6 8 11 17 11] -> [8 13 3 12 10 4 2 4 11 9 4 1 4]
[3 5 15 7 18 5 3 9 11 2 18 1 10 19] -> [11 9 4 8 2 9 11 7 5 13 2 14 6 1]
[6 11 4 19 14 7 13 16 10 12 7 9 7 10 10] -> [14 6 15 1 3 11 4 2 7 5 11 10 11 7 7]
[11 20 11 1 20 16 11 11 4 8 9 7 11 14 10 14] -> [6 1 6 16 1 3 6 6 15 13 12 14 6 4 11 4]
[4 7 15 2 3 2 3 1 14 2 10 4 7 6 11 2 18] -> [9 6 2 13 11 13 11 17 3 13 5 9 6 8 4 13 1]
[5 1 17 7 1 9 3 6 9 7 6 3 2 18 14 4 18 16] -> [12 17 3 8 17 6 14 10 6 8 10 14 16 1 5 13 1 4]
[5 6 8 10 18 13 20 10 7 1 8 19 20 10 10 18 7 2 1] -> [16 15 11 7 4 6 1 7 13 18 11 3 1 7 7 4 13 17 18]
[12 17 8 2 9 7 15 6 19 5 13 16 14 20 10 11 18 4 3 1] -> [9 4 13 19 12 14 6 15 2 16 8 5 7 1 11 10 3 17 18 20]

Workaround in Excel for silly Rules Regarding Mouse Inputs on Code Golf Stack Exchange: (WESRRMICGSE) 28 bytes

rank(RC[1],r1c1:r1024:c1024)

Input list as csv (10,23,34,2,) into the compiler after entering the source. no quotes, no brackets, trailing comma.

WESRRMICGSE is exactly like programming in excel, except you can omit the initial '=' sign to save a byte. The difference in functionality comes from the fact that WESRRMICGSE will either drag the formula down to copy the code automatically and provide different outputs provided with a single integer input. provided a list as input, that list goes into the B column (input column), and the formula is drug down automatically to match the number of inputs. (eg: the input 34,21,45, would 'drag' the formula down 2 cells, for a total of 3 cells with the formula).

Edit: I never expected this answer to be popular. Wow!


"Defragmenting" a list A fragmented file is a file which is seperated into several parts on a harddrive, because it can't fit into a certain space.

On all harddrives, there are files called unmovable files, which are unmovable. To simulate real data on a harddrive, the input will also have unmovable files.

You are given several sequences of consecutive numbers, all scrambled into one list. The goal is to order each of these sequences so that they are placed in as little space as possible. The list can be as big as you need it to be. If there is no space for a sequence, then put a - instead.

To mark the unmovable files, another list, with the same length as the data, will be given after you recieve the data. It will contain either a 0 or a 1. Every 1 within that list means that the corresponding item in the data is unmovable.

Shortest code wins.

Test Cases

The output does not have to be exactly like this, but the length needs to be the same, and all of the sequences need to be ordered.

[ 0,  0,  1,  1,  1,  1,  0,  0,  0,  0,  0]
[25, 30, 11, 12, 13, 14, 68, 69, 31, 26, 32]
Output: [25, 26, 11, 12, 13, 14, 68, 69, 30, 31, 32]
(output length: 11)

[0, 0, 0,  0, 0,  1,  1,  1, 0, 0,  0,  0,  0,  0,  0, 0]
[2, 3, 5, 14, 8, 10, 11, 12, 4, 6, 28, 30, 29, 15, 16, 7]
Output: [14, 15, 16, -, -, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 28, 29, 30]
(output length: 18)

APL (132 126 123 147 145 143)

This was a bit harder than I thought it'd be :)

Edit: the hard drive is infinite :S. All sequences that could not fit in the original space, are now appended onto the end of the output.

F←⍬⋄{×⍴⍵:∇1↓⍵⊣{∨/P←S⍷⍨1⍴⍨⍴⍵:S[R]∘←0⊣D[R←1-⍨(⍳⍴⍵)+⌊/P/⍳⍴P]∘←⍵⋄F∘←F,⍵}⊃⍵⋄D[S/⍳⍴S]∘←'-'}G[⍒⊃∘⍴¨G←K⊂⍨1≠|-⌿K,[÷2]¯1⌽K←K[⍋K←(S←~⎕)/D←⎕]]⋄F,⍨D/⍨~⌽∧\⌽S

This is what it does to your 1st and 2nd example (the 2nd example is different, but in your example the output length is not the same as the input length and you said in a comment it was wrong, so...)

⎕:    25 30 11 12 13 14 68 69 31 26 32
⎕:    0  0  1  1  1  1  0  0  0  0  0
25 26 11 12 13 14 30 31 32 68 69

⎕:    2 3 5 14 8 10 11 12 4 6 28 30 29 15 16 7
⎕:    0 0 0 0  0 1  1  1  0 0 0  0  0  0  0  0
14 15 16 - - 10 11 12 2 3 4 5 6 7 8 28 29 30

Explanation:

F←⍬: set F to the empty list. This will hold the overflow.
K←K[⍋K←(S←~⎕)/D←⎕]: read two lists. The first list (numbers) is stored in D. The second list (whether the data is unmovable) is inverted and then stored in S. Get all movable numbers, and sort them. Store this in K.
G←K⊂⍨1≠|-⌿K,[÷2]¯1⌽K: Subtract each element of K from the next element of K. Wherever this is not 1, we found the beginning of a new sequence. Store the list of sequences in G.
G[⍒⊃∘⍴¨G...]: sort the list of sequences by descending length. This way, we place the longest sequences first.
{×⍴⍵:...}G: as long as this list of sequences is not empty...
∇1↓⍵⊣: handle the tail of the list, after...
{...}⊃⍵: doing the following with the head:
∨/P←S⍷⍨1⍴⍨⍴⍵: find, in S, a list of ones that is as long as the current sequence (⍵).
S[R]∘←0⊣D[R←1-⍨(⍳⍴⍵)+⌊/P/⍳⍴P]∘←⍵: if there is one, store ⍵ in D at the first position that it fits, and mark these positions as unmovable in S.
⋄F∘←F,⍵: if there is no room, add it to the overflow.
⋄D[S/⍳⍴S]∘←'-': when we're at the end of the list of sequences, all positions where S is still one are places where we couldn't put anything. Mark these with -.
⋄F,⍨D/⍨~⌽∧\⌽S: then, at the end, display D, with the trailing -s removed, followed by the overflow (F) per the new rules.


Identify the direction of lines in an ASCII-figure Challenge:

Take a rectangular figure consisting of the two characters # and  (whitespace, ASCII-32), and identify which direction the lines are. The options are: 'Vertical', 'Horizontal', 'Left Diagonal' and 'Right Diagonal'.

Input:

The input will be a figure of size n-by-m where 5 <= m,n <= 20. There will be two spaces between horizontal lines, two spaces between lines in the horizontal/vertical direction. Note that the lines doesn't have to start or end in a corner. The input will look like this:

Horizontal:

##########

##########

##########

Vertical (note that there can be leading spaces):

 #  #  #
 #  #  #
 #  #  #
 #  #  #
 #  #  #

Left diagonal:

#  #  #
 #  #
  #  #
#  #  #
 #  #

Right diagonal:

#  #  #  #  #
  #  #  #  #
 #  #  #  #  #
#  #  #  #  #
  #  #  #  #

The input format is optional. You may substitute the visual newlines by \n, or create the grid by concatenating the rows with ASCII-10 (relevant for MATLAB/Octave).
You may not take the input as numbers (1/0) instead of # and 0.

Output:

The output shall be 4 distinct values/outputs for each of the four different cases. It can for instance be 1,2,3,4, or V,H,L,R.

Test cases:

There will be an asterisk over the top left corner of the figure, and an asterisk below the bottom left corner of the figures. This is to indicate where the figure starts and ends.

Horizontal:
*
#####

#####

    *
*

###########

          *
*

##########################

##########################

##########################
                         *

Vertical:
*
#  #  #  #
#  #  #  #
#  #  #  #
#  #  #  #
#  #  #  #
         *
*
 #  #  #  #  #  #
 #  #  #  #  #  #
 #  #  #  #  #  #
 #  #  #  #  #  #
 #  #  #  #  #  #
                  *

Left diagonal
*
#  #  #
 #  #
  #  #
#  #  #
 #  #
      *
*
#  #  #  #  #
 #  #  #  #
  #  #  #  #
#  #  #  #  #
 #  #  #  #
  #  #  #  #
            *
*
  #  #  #
#  #  #  #
 #  #  #
  #  #  #
#  #  #  #
         *

Right diagonal
*
#  #  #  #  #
  #  #  #  #
 #  #  #  #  #
#  #  #  #  #
  #  #  #  #
             *
*
 #  #  #  #  #  #  #
#  #  #  #  #  #  #
  #  #  #  #  #  #
 #  #  #  #  #  #  #
#  #  #  #  #  #  #
                   *

This is code-golf so the shortest code in each language wins.

Slip, 6 + 2 = 8 bytes

+2 bytes for the f flag.

^*`#`#

Try it here!

Prints one of the following:

##

#
#

#
 #

 #
#

Explanation

The ^* sets the IP's direction to any one of the eight octilinear directions. Then `#`# simply matches two hash symbols in that direction. The f flag limits Slip to looking only for the first match, and by default the bounding box of that match is printed to STDOUT.

The pattern itself would be two bytes shorter in Snails (z\#2), but I don't think Snails can print the match itself, it only has numeric output (and adapting the pattern to printing 4 different numbers based on the direction would most likely take a lot more bytes).


Tips for golfing in Prolog What general tips do you have for golfing in Prolog? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Prolog (e.g. one letter variables is not specific to Prolog to reduce the size of programs).

Please indicate in your tips if it is specific to an implementation of Prolog (e.g. SWI-Prolog specific built-ins)

Please post only one tip per answer, or a list of tips that are all closely related to the same main idea.

Use Operators for Predicate Names
It is possible to give predicates operators as names so long as the operator is one of the predefined operators (listed here) and is not already defined as a predicate. This saves a few bytes both when defining and calling the predicate since operator predicates do not need to be written in the normal name(arg1,arg2,etc..) form and can be called as one might expect with operators.
For one and two argument predicates, they can be give the names of unary and binary operators, respectively. For higher arity predicates, we can still avoid parentheses using pattern matching. For example if we have a predicate A+B+C:-..., Prolog will use its operator precedence and associativity rules to transform it into (A+B)+C:-... which is a operator predicate where the first argument is pattern matched to A+B. Or A-B+C*D:-... which becomes (A-B)+(C*D) so its first argument is pattern matched to A-B and its second is pattern matched to C*D.
Examples
_+_+_.
A-B+C*D:-between(A,B,C),C+D.
\X:-X>1,X<10.
X+Y:-length(Y,X),member(X,Y).

5+[10,5,3,2,5],a+b+c,0-20+X*[2,4,6,5,40],\9.

The output will be X = 5.
Try it Online!
Corollary
Since DCGs are syntactic sugar for predicates they too can be given operators for names. This works as expected when calling them as DCGs either from a DCG or using the phrase predicates or others that are designed to work with DCGs. When calling them as predicates parentheses are required (eg A+B-->... must be called like +(A,B,...)) since DCG predicates take an additional two arguments for their difference lists. For operator named DCGs with more than two arguments using operator pattern matching then it is important to make sure when calling it as a predicate that the pattern matched operators are distributed correctly.
Giving operator names to DCGs that take no additional arguments can be useful if you need to call them within your program since then you can do so without using parentheses. Caution is required because it can be the case that what you save in parentheses you can lose to added spacing required to parse adjacent operators.
Examples
/ -->a+b+X,X+d+e.
A+B+C-->[A],[B],[C].

X/[],member(c,X),phrase(f+o+o,Y),+(b+a,r,Z,[]).

Output will be
X = [a, b, c, c, d, e],
Y = [f, o, o],
Z = [b, a, r].

Try it online!
Caveats
With the unary operators + and -, Prolog will interpret +20 or -20 as numbers instead of a call to a +/1 or -/1 predicate. Predicates given unary + or - as names can still be called on number by using parentheses (+(20), -(20)). If avoiding the extra bytes from parentheses is desirable other unary operators such as \, $, etc can be used as names instead.
The combination of pattern matching and operator named predicates is not entirely without flaws. If you have two predicates that have the same operator as their name and with pattern matching one is strictly more general than the other then the more general one may get called first or if the less general one fails (depending on their ordering in the source). For instance in the example above if A-B+C*D fails to match its input then Prolog will try calling X+Y. This will result in an error because length/2 require Y to be an integer which it will not be since it will be in the form C*D. This can be avoided simply by making sure no two predicates have the same operator as their name or if that fails then using cuts and careful ordering of the source.


What are the five most powerful characters in your language? Choose any five characters your language supports. There are 5! = 5×4×3×2×1 = 120 ways these can be arranged into a 5-character string that contains each character once; 120 permutations.
Choose your characters such that, when each of the 120 strings is run in your language, the 120 outputs produced will be as many unique integers from 1 to 120 (inclusive) as possible.
That is, for each of the 120 permutations of your 5 characters that produce runnable code that outputs a single number, you want the set of all those numbers to match as close as possible to the set of integers from 1 through 120.
So, ideally, your first permutation would output 1, the next 2, the next 3, all the way up to 120. But that ideal is likely impossible for most languages and characters.
The 5-character strings may be run as:

a program with no input
a function with no arguments
a REPL command

Different strings can be run in different ways if desired
For the output to count, it must be a single integer output in a normal way, such as:

being printed to stdout
returned by  the function
the result of the REPL expression

The code should terminate normally (which may involve erroring out as long as the number has been output first). Code that does not run at all is fine, just the (nonexistent) output doesn't count. The numbers output should be in decimal unless a different base is the norm for your language.
The submission that generates the most distinct numbers from 1 through 120 wins. The earlier submission wins in case of a tie.
Notes

Your 5 characters do not all need to be different, but of course having duplicate characters reduces the effective number of permutations.
Float outputs such as 32.0 count as well as plain 32. (But 32.01 would not.)
Leading zeroes such as 032 count as well as plain 32.
Valid outputs should be deterministic and time invariant.
We are dealing with characters, not bytes.

Example
The characters 123+* are a reasonable first choice for Python's (or many language's) REPL. The resulting 120 permutations and outputs are:
123+* n/a
123*+ n/a
12+3* n/a
12+*3 n/a
12*3+ n/a
12*+3 36
132+* n/a
132*+ n/a
13+2* n/a
13+*2 n/a
13*2+ n/a
13*+2 26
1+23* n/a
1+2*3 7
1+32* n/a
1+3*2 7
1+*23 n/a
1+*32 n/a
1*23+ n/a
1*2+3 5
1*32+ n/a
1*3+2 5
1*+23 23
1*+32 32
213+* n/a
213*+ n/a
21+3* n/a
21+*3 n/a
21*3+ n/a
21*+3 63
231+* n/a
231*+ n/a
23+1* n/a
23+*1 n/a
23*1+ n/a
23*+1 23
2+13* n/a
2+1*3 5
2+31* n/a
2+3*1 5
2+*13 n/a
2+*31 n/a
2*13+ n/a
2*1+3 5
2*31+ n/a
2*3+1 7
2*+13 26
2*+31 62
312+* n/a
312*+ n/a
31+2* n/a
31+*2 n/a
31*2+ n/a
31*+2 62
321+* n/a
321*+ n/a
32+1* n/a
32+*1 n/a
32*1+ n/a
32*+1 32
3+12* n/a
3+1*2 5
3+21* n/a
3+2*1 5
3+*12 n/a
3+*21 n/a
3*12+ n/a
3*1+2 5
3*21+ n/a
3*2+1 7
3*+12 36
3*+21 63
+123* n/a
+12*3 36
+132* n/a
+13*2 26
+1*23 23
+1*32 32
+213* n/a
+21*3 63
+231* n/a
+23*1 23
+2*13 26
+2*31 62
+312* n/a
+31*2 62
+321* n/a
+32*1 32
+3*12 36
+3*21 63
+*123 n/a
+*132 n/a
+*213 n/a
+*231 n/a
+*312 n/a
+*321 n/a
*123+ n/a
*12+3 n/a
*132+ n/a
*13+2 n/a
*1+23 n/a
*1+32 n/a
*213+ n/a
*21+3 n/a
*231+ n/a
*23+1 n/a
*2+13 n/a
*2+31 n/a
*312+ n/a
*31+2 n/a
*321+ n/a
*32+1 n/a
*3+12 n/a
*3+21 n/a
*+123 n/a
*+132 n/a
*+213 n/a
*+231 n/a
*+312 n/a
*+321 n/a

There are 36 numbers generated, all luckily within 1 to 120:
36, 26, 7, 7, 5, 5, 23, 32, 63, 23, 5, 5, 5, 7, 26, 62, 62, 32, 5, 5, 5, 7, 36, 63, 36, 26, 23, 32, 63, 23, 26, 62, 62, 32, 36, 63

However, only 8 of them are unique:
36, 26, 7, 5, 23, 32, 63, 62

So such a submission would only score 8 out of a maximal 120.


Choose Scenes for a Movie Introduction
Finally the movie company is financing your film. They have given you a maximum budget and they also set the running time of your movie.
Now you can start with the pre-production. You have a bunch of scenes already planned, but not all of them will fit into the budget and the film would get way too long as well. You know however the importance of each scene. You goal is to choose scenes, that the movie is not going to be too expensive, too long and mediocre.
Input
You get the running time and the budget the studio has approved:
[25, 10]

You have the list of scenes including running time, costs and the importance for each of them:
[ [5, 2, 4], [7, 1, 3] ]

If arrays aren't working for you, choose another input format that suits your best. Times are in minutes. Budget and costs are in millions of random currency. The importance is a range from [1–9]. All numbers are integers.
Output
Output the list of scenes to be included into the movie in the matter that:

The sum of importance is maximized.
The costs do not exceed the budget.
The length is within a ±5 minutes range of the approved running time.

The order of scenes is unimportant and doesn't need to be preserved.
You can output a list of numbers or an array. Your output can have a zero- or a one-based index:
[0,2,5] – 0, 2, 5 – 0 2 5
[1,3,6] – 1, 3, 6 – 1 3 6

It may be possible, that multiple solutions apply to any given input. You only need to find one.
Constraints

Scenes can't be shortened nor can they get cheaper.
Each scene can only be included once.

Requirements

Your program must finish in the time of the movie's actual length.
Input is accepted from STDIN, command line arguments, as function parameters or from the closest equivalent.
You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.
This is code-golf so shortest answer in bytes wins.
Standard loopholes are disallowed.

Movies
Your first movie is a documentary about a small town in Germany called Knapsack1. This city was resettled due to environmental constraints in the 70s:
Movie: [25, 10]

Scenes: [
    [5,  2, 4],
    [5,  5, 7],
    [7,  1, 3],
    [8,  5, 3],
    [12, 3, 9],
]

Possible solution with running time 22, budget 10 and an importance of 20:
0, 1, 4

Your next project is an episode of Fargo:
Movie: [45, 25]

Scenes: [
    [2,  1, 1],
    [8,  5, 9],
    [10, 6, 8],
    [10, 3, 6],
    [10, 9, 7],
    [11, 4, 3],
    [19, 5, 6],
]

Possible solution with running time 40, budget 24 and an importance of 31:
0, 1, 2, 3, 4

Finally here are the scenes for a movie where "M. McConaughey travels to a distant galaxy only to find out that Matt Damon got there first.":
Movie: [169, 165]

Scenes: [
    [5,  8,  2],
    [5,  20, 6],
    [6,  5,  8],
    [6,  10, 3],
    [7,  6,  5],
    [7,  9,  4],
    [7,  8,  9],
    [7,  9,  5],
    [8,  6,  8],
    [8,  8,  8],
    [8,  5,  6],
    [9,  5,  6],
    [9,  8,  5],
    [9,  4,  6],
    [9,  6,  9],
    [9,  8,  6],
    [9,  7,  8],
    [10, 22, 4],
    [10, 12, 9],
    [11, 7,  9],
    [11, 9,  8],
    [12, 11, 5],
    [15, 21, 7],
]

Possible solution with running time 169, budget 165 and an importance of 133:
1, 2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22

1 Any resemblance between the challenge's problem and actual locales is entirely coincidental.

MATLAB, 100 bytes

function X=o(m,s)
X=find(bintprog(-1*s(:,3),[s(:,2)';s(:,1)';-1*s(:,1)'],[m(2);m(1)+5;5-m(1)])==1);

The Binary Optimization problem is solved through the bintprog function, available in Matlab2013b; this function was replaced by intlinprog in newer Matlab versions.

Inputs are a vector (m), for movie constraints, and a matrix (s), for the scenes. In particular m is a two-element row vector [running_time budget], while s is a Nx3 matrix, where N is the number of the scenes and each row is made up of [running_time costs importance].


Generate a random program in your favorite language We all heard of testing compilers using randomly generated inputs. Your task is to write a program to generate a valid program (including no undefined behavior) in your favorite language. The generating program language doesn't have to be the same as the generated program language.

Your program will receive an integer as the argument which you can use as seed for your random number generator. The generated programs should be structurally different (given different seeds) not just different variable names or constants.

Examples:

$ ./generate 1
int main() { return 0; }

$ ./generate 2
#include <math.h>
int main() { return (int) pow(4, 3); }

Please include a couple of outputs in your answers.

The shortest solution wins. I will give a small bonus based on the number of votes, so please vote the most creative solutions.

Python → Brainf*ck (185 223 233 255 285 287 303 characters)

Code

import random as r,sys
r.seed(int(sys.argv[1]))
c=list('<>.,+-')+['']
n=9/r.random()
def b():
 global n
 s=''
 while n>0:n-=1;o=r.choice(c);s+=o if o else'[%s]'%b()
 return s
print b()

303 → 287 Characters: Removed math.ceil (it's not really necessary).
287 → 285 Characters: Switched to an empty string to denote the branch operator.
285 → 255 Characters: Condensed the if statement in the while loop.
255 → 233 Characters: Implemented JBernardo's suggestions from the comments.
233 → 223 Characters: Implemented tjko's suggestion from the comments.
223 → 185 Characters: Implemented some whitespace reduction suggestions from the comments.

Examples

$ python generate.py 1
-->,,+-<<-,-<,->[[<<,[.>.<>,,>>>,.<-,+>[[<.-+[.-+.+[-,+<>-.>,++.,,-,.,<<+[+]]]]]]]]
$ python generate.py 2
[<<--+.+++>]
$ python generate.py 3
,.++<<->>[,-,+>+[,-+<-+.<[,-[+[.-,[[<<>[,+.]]]]]]]]

Actually figuring out what the resulting BF programs do is left as an exercise to the reader.


Regex in reverse - decompose regular expressions The Problem

I have a bunch of regular expressions that I need to use in some code, but I'm using a programming language that doesn't support regex! Luckily, I know that the test string will have a maximum length and will be composed of printable ASCII only.

The Challenge

You must input a regex and a number n, and output every string composed of printable ASCII (ASCII codes 32 to 126 inclusive,  to ~, no tabs or newlines) of length less than or equal to n that matches that regex. You may not use built-in regular expressions or regex matching functions in your code at all. Regular expressions will be limited to the following:

Literal characters (and escapes, which force a character to be literal, so \. is a literal ., \n is a literal n (equivalent to just n), and \w is equivalent to w. You do not need to support escape sequences.)
. - wildcard (any character)
Character classes, [abc] means "a or b or c" and [d-f] means anything from d to f (so, d or e or f). The only characters that have special meaning in a character class are [ and ] (which will always be escaped, so don't worry about those), \ (the escape character, of course), ^ at the beginning of the character class (which is a negation), and - (which is a range).
| - the OR operator, alternation. foo|bar means either foo or bar, and (ab|cd)e matches either abe or cde.
* - match the previous token repeated zero or more times, greedy (it tries to repeat as many times as possible)
+ - repeated one or more times, greedy
? - zero or one times
Grouping with parentheses, to group tokens for |, *. +, or ?

The input regex will always be valid (i.e., you do not have to handle input like ?abc or (foo or any invalid input). You may output the strings in any order you would like, but each string must appear only once (don't output any duplicates).

The Test Cases

Input: .*, 1
Output: (empty string), , !, ", ..., }, ~

Input: w\w+, 3
Output: ww, www

Input: [abx-z][^ -}][\\], 3
Output: a~\, b~\, x~\, y~\, z~\

Input: ab*a|c[de]*, 3
Output: c, cd, ce, aa, cde, ced, cdd, cee, aba

Input: (foo)+(bar)?!?, 6
Output: foo, foo!, foofoo, foobar

Input: (a+|b*c)d, 4
Output: ad, cd, aad, bcd, aaad, bbcd

Input: p+cg, 4
Output: pcg, ppcg

Input: a{3}, 4
Output: a{3}

The Winner

This is code-golf, so the shortest code in bytes will win!

Python v2.7 1069 1036 950 925 897 884 871 833 822

This answer seems rather long for a code golf, but there are a lot operators that need to be handled and I know what purpose each byte in this answer does. Since there is no existing answer I submit this as a target for other users to beat. See if you can make a shorter answer :).

The two main functions are f which parses the regex starting at the ith character, and d which generates the matching strings, using r the sub-regexes we can recursed into, 'a' the array representing the part of the current sub-regex not yet processed, and a string suffix s which represents the part of the string generated so far.

Also check out the sample output and a test harness.

import sys;V=sys.argv;n=int(V[2]);r=V[1];S=len;R=range;C=R(32,127)
Z=[];z=-1;D='d(r,p,';F='for j in '
def f(i,a):
 if i>=S(r):return a,i
 c=r[i];x=0;I="|)]".find(c)
 if c in"([|":x,i=f(i+1,Z)
 if I+1:return([c,a,x],[a],[c,a])[I],i
 if'\\'==c:i+=1;x=c+r[i]
 return f(i+1,a+[x or c])
def d(r,a,s):
 if S(s)>n:return
 while a==Z:
        if r==Z:print s;return
        a=r[z];r=r[:z]
 e=a[z];p=a[0:z]
 if'|'==a[0]:d(r,a[1],s);d(r,a[2],s)
 elif']'==a[0]:
        g=a[1];N=g[0]=='^';g=(g,g[1:])[N];B=[0]*127;O=[ord(c[z])for c in g]
        for i in R(0,S(g)):
         if'-'==g[i]:exec F+'R(O[i-1],O[i+1]):B[j]=1'
         else:B[O[i]]=1
        for c in C:N^B[c]<1or d(r,Z,chr(c)+s)
 elif' '>e:d(r+[p],e,s)
 else:c=p[:z];exec{'.':F+'C:'+D+'chr(j)+s)','?':D+'s);d(r,p[:z],s)','*':F+'R(0,n+1):d(r,c,s);c+=[p[z]]','+':"d(r,p+['*',p[z]],s)"}.get(e,D+'e[z]+s)')
d(Z,f(0,Z)[0],"")

Note that tabs in the original solution have been expanded. To count the number of characters in the original use unexpand < regex.py | wc.


Expand roots into a polynomial Challenge
Given the roots of a polynomial separated by spaces as input, output the expanded form of the polynomial.
For example, the input
1 2

represents this equation:
(x-1)(x-2)

And should output:
x^2-3x+2

The exact format of output is not important, it can be:
1x^2+-3x^1+2x^0

or:
0 0 0
1x^3+0x^2+0x^1+0

or:
3 14 15 92
1x^4+-124x^3+3241x^2+-27954x^1+57960

Scoring/Rules

eval and likes are disallowed.
You may use any version of Python or any other language.

MATL, 29 bytes
ljU"1@_hX+]tn:Pqv'+%gx^%g'wYD

Input is an array with the roots.
EDITS:

(May 20, 2016): the X+ function has been removed, as Y+ includes its functionality. So in the above code replace X+ by Y+.
(September 29, 2017): due to changes in the YD function, w in the above code should be removed.

The following link includes those changes.
Try it online!
Explanation
This applies repeated convolution with terms of the form [1, -r] where r is a root.
l          % push number 1
jU         % take input string. Convert to number array
"          % for each root r
  1        %   push number 1
  @_       %   push -r
  h        %   concatenate horizontally
  X+       %   convolve. This gradually builds array of coefficients
]          % end for each
tn:Pq      % produce array [n-1,n-2,...,0], where n is the number of roots
v          % concatenate vertically with array of coefficients
'+%gx^%g'  % format string, sprintf-style
w          % swap
YD         % sprintf. Implicitly display


Play the elimination game Introduction

In this challenge, your task is to simulate a certain type of elimination game.
In the game, the participants stand in a circle, and everyone is holding an integer.
On each round of the game, every participant points at the person n steps away, if n is the number they are holding. If n is positive, they count to their right, if n is negative, they count to their left, and if n is zero, they point at themselves.
Every participant who has someone pointing at them is eliminated, and leaves the circle; this ends the round.
The rounds continue until there are no participants left.

Input

Your input is a non-empty list of integers, in any reasonable format.
It represents the numbers that the participants of the game are holding.

Output

Your output is the number of rounds it takes until the game ends.

Example

Consider the input list [3,1,-2,0,8].
On the first round, the following happens:

The person holding 3 points right at the person holding 0.
The person holding 1 points right at the person holding -2.
The person holding -2 points left at the person holding 3.
The person holding 0 points at themself.
The person holding 8 points right at the person holding -2 (the list represents a circle, so it wraps around at the ends).

This means that 0, -2 and 3 are eliminated, so the second round is done with the list [1,8].
Here, 1 points at 8, and 8 points at themself, so 8 is eliminated.
The third round is done with the list [1], where 1 simply points at themself and is eliminated.
It took three rounds to eliminate all participants, so the correct output is 3.

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

Test cases

[3] -> 1
[0,0,0] -> 1
[-2,-1,0,1,2,3,4,5,6,7] -> 2
[5,5,5,6,6,6] -> 2
[3,-7,-13,18,-10,8] -> 2
[-7,5,1,-5,-13,-10,9] -> 2
[4,20,19,16,8,-9,-14,-2,17,7,2,-2,10,0,18,-5,-5,20] -> 3
[11,2,7,-6,-15,-8,15,-12,-2,-8,-17,6,-6,-5,0,-20,-2,11,1] -> 4
[2,-12,-11,7,-16,9,15,-10,7,3,-17,18,6,6,13,0,18,10,-7,-1] -> 3
[18,-18,-16,-2,-19,1,-9,-18,2,1,6,-15,12,3,-10,8,-3,7,-4,-11,5,-15,17,17,-20,11,-13,9,15] -> 6

Matlab, 91 77 bytes
function k=f(a);k=0;while a*0+1;l=numel(a);a(mod((1:l)+a-1,l)+1)=[];k=k+1;end

Old version:
function k=f(a);for k=1:numel(a);a(mod((1:l)+a-1,l)+1)=[];l=numel(a);if l==0;break;end;end

This is a challenge where matlab shines, the heart of this code is the deletion of the array entries: a(mod((1:l)+a-1,l)+1)=[] which is quite elegant I think.


Count the Matchsticks Most people here are familiar with seven segment displays, which are also used in matchstick puzzles. Below are the digits 0 through 9 and letters a through z, except k,m,t,v,w, written in this format.

 _        _   _         _    _    _    _    _
| |   |   _|  _|  |_|  |_   |_     |  |_|  |_|
|_|   |  |_   _|    |   _|  |_|    |  |_|   _|

 _       _      _  _  _                        _   _      _               _
|_| |_  |   _| |_ |_ |   |_  |   | |   _   _  |_| |_|  _ |_      |_| |_|  _|
| | |_| |_ |_| |_ |  |_| | | | |_| |_ | | |_| |     | |   _| |_| | |   | |_

The challenge here is simple. Given an input string, output the number of matchsticks required to represent that string. If the string contains a character outside of the above representation, ignore it (count it as 0).

For example, for input 53, a total of 10 matchsticks are required, 5 for the 5 and 5 for the 3, so the output is 10.

For input hello a total of 19 matchsticks are required, h (4), e (5), l (3), l (3), o (4), so the output is 19.

For clarity, here are the matchsticks required to build each character:

0 -> 6
1 -> 2
2 -> 5
3 -> 5
4 -> 4
5 -> 5
6 -> 6
7 -> 3
8 -> 7
9 -> 6
a -> 6
b -> 5
c -> 4
d -> 5
e -> 5
f -> 4
g -> 5
h -> 4
i -> 2
j -> 4
l -> 3
n -> 3
o -> 4
p -> 5
q -> 5
r -> 2
s -> 5
u -> 3
x -> 5
y -> 4
z -> 5

Now for the twist, and there are two of them.

The first is that the input is considered case-insensitive. That is, A and a should both count for 6 matchsticks, even though the visual representation looks like an uppercase A.
Your score is your source code run through this algorithm, plus the length of your source code in bytes, lower is better. For example, if your source code was abc123, your score would be 6+5+4+2+5+5 = 27 + 6 = 33. If your source code was #&@()*, your score would be 0 + 6 = 6.

Input/Output Examples

0    -> 6
53   -> 10
111  -> 6
112  -> 9
8888 -> 28
hello -> 19
PPCG  -> 19
Programming Puzzles & Code Golf -> 99
#&()mt!!~ -> 0
*DḌƤÆE%Ḅċ0 -> 16

Rules

If applicable, you can assume that the input/output will fit in your language's native Integer type.
The input and output can be given by any convenient method.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.

Python 2, 97 bytes + 237 matches = 334

lambda w:sum(map(('1ir'*2+'7lnu'*3+'4cfhjoy'*4+'235bdegpqsxz'*5+'069a'*6+'8'*7).count,w.lower()))

Try it online!

This works by generating a string where each buildable character appears the same amount of matchsticks required to build that character


Match coordinates with their values Given 3 input items, a list of coordinate pairs, a 2D string, and a single-character string, output whether the character at each coordinate of the 2D string is equal to the single character.  You can take the input in any order and the coordinates may be 1-indexed.

You may take the 2D string as a 2D list, a list of lines, or a 2D string.

Example: (0,0), "#_\n__", "#" -> True

The string is

#_
__

The char at the coordinate (0,0) (from the top left) is #.  This is equal to the third input item, #, so you output True (or any truthy value)

Example: [(0,0), (1,1)], "#_\n_#", "#" -> True

The string is

#_
_#

The characters at the coordinates of (0,0) and (1,1) are both #, so the output is true.

The output is only true iff every coordinate matches a hash.  Not every hash has to have a matching coordinate though.  If there are no occurrences of the single char (# in some of the test cases) in the 2D string, the output is still just falsy.

You can assume the coordinates will always be within the bounds of the 2D string.

More test cases: (I put the single char second for ease of readability)

[(0,0), (2,1), (3,0)], #

#_##
#_##

True

[(0,0), (1,1), (3,0)], #

#_##
#_##

False (1,1 is not a hash)

[(1,1)], a

#a##
#a##

True

[(4, 0), (3, 0), (2, 0), (1, 0), (0, 0), (0, 1), (0, 2), (0, 3), (1, 3), (2, 3), (2, 2), (3, 2), (4, 2), (4, 3)], ' '

 ####
 #
   #

True

Note the last test case uses spaces as the single char string, and hashes around the spaces.

Related. (inverse of this challenge)

Python, 39 bytes

Takes the inputs:

a list of (x, y) integer coordinates
b list of strings
c single character string

lambda a,b,c:{b[y][x]for x,y in a}=={c}


Special String reformatting This challenge is to take an alphabetical string as input and to apply the following conversion:

The first of each type of character of the string must stay, and must be immediately followed by an integer representing how many of these characters were in the original string. Any repeating characters must be omitted.

All inputs will be entirely lower-case letters (no spaces). Outputs must be ordered in the same way as the inputs (input hi must give output of h1i1, not i1h1)

Examples

Input: potato Output: p1o2t2a1

Input: pqwertyuiop Output: p2q1w1e1r1t1y1u1i1o1

Input: thisisanexample Output: t1h1i2s2a2n1e2x1m1p1l1

Input: oreganoesque Output: o2r1e3g1a1n1s1q1u1

Input: aaaaaaabaaaaaa Output: a13b1

Scoring

This is code-golf. Shortest answer wins!

APL (Dyalog Unicode), 7 bytes (SBCS)

Anonymous tacit prefix function.

,,∘⍕∘≢⌸

Try it online!

⌸ apply the following function between each unique character and the indices where it occurs:

 , concatenate the character

  ∘ to

   ⍕ the stringification

    ∘ of

     ≢ the indices' count

, flatten


Swap bits with their neighbours Task description

Given an integer, swap its (2k–1)-th and 2k-th least significant bits for all integers k > 0. This is sequence A057300 in the OEIS.

(The number is assumed to have “infinitely many” leading zeroes. In practice, this simply means prepending a single 0 bit to odd-length numbers.)

This is code-golf, so the shortest code (in bytes) wins.

Test cases

0 -> 0
1 -> 2
9 -> 6
85 -> 170
220 -> 236
1827 -> 2835
47525 -> 30298

Python 2, 26 bytes
lambda n:2*n-3*(4**n/3&n/2)

Bit tricks!
Say n has form ...ghfedcba in binary. Then, we can split it into every other bit as
n   = o + 2*e
n   = ...hgfedcba
o   = ...0g0e0c0a
2*e = ...h0f0d0b0

Then, the bit-switched result s can be expressed as s=2*o+e.
s   = 2*o + e
s   = ...ghefcdab
2*o = ...g0e0c0a0
e   = ...0h0f0d0b

We'd rather compute only one of e and o, so we express o=n-2*e and substitute
s=2*(n-2*e)+e = 2*n-3*e

So, now it remains to express e in terms of n. The number M=4**n/3 has form ...10101010101 in binary, which serves as a mask for the odd digits. The exponent n ensures that M is long enough. Taking the bitwise and of n/2 and this value gives e as desired.
n/2     = ...hgfedcb
M       = ...1010101
n/2 & M = ...h0f0d0b = e

We can instead express e in terms of o e=(n-o)/2, which gives s=(n+o*3)/2, which saves a byte thanks to an optimization from xsot.
lambda n:n+(n&4**n/3)*3>>1


Count how many numbers are divisible by perfect numbers in a given range Given two arbitrary integers \$a\$ and \$b\$, count how many numbers are divisible by perfect numbers in that given range (\$a\$ and \$b\$ both are inclusive).

In mathematics, a perfect number is a positive integer that is the sum
of its proper positive divisors, that is, the sum of the positive
divisors excluding the number itself.Equivalently, a perfect number is
a number that is half the sum of all of its positive divisors
(including itself), or \$σ(n) = 2n\$.

Input:
1 100

Output:
18

Use stdin and stdout for Input/Output
Your code must handle big integers, so it is not good enough to hard-code a list of perfect numbers.
Shortest code wins

Mathematica - 117

Naive approach, linear for the range size

With[{p=#(#+1)/2&/@Select[2^Range@@Floor@Log2@Sqrt@#-1,PrimeQ]},Length@Select[Range@@#,Or@@Divisible[#,p]&]]&@Input[]

The correct way would be constructing numbers from the perfect numbers that are in the given range of course.


Create a programming language that only appears to be unusable (Robbers' thread) See the cop thread for more information. Each answer to this question should crack an answer there. That is to say, it should be code to find the third-largest integer in the input when run in the interpreter given in that answer.
If you post a crack that turns out to be invalid, you should delete it and are ineligible to post another attempt against the same answer.
Scoring
The winner of this question is the robber who makes the highest number of successful cracks.

Shuffle, by Liam Noronha

cinpush

main:
    gte Hans 1s Leopold
    jnz Leopold done

    mov 1s Hans

    gte Gertrude Hans Leopold
    jnz Leopold done

    mov Gertrude ShabbySam
    mov Hans Gertrude
    mov ShabbySam Hans

    gte Alberto Gertrude Leopold
    jnz Leopold done

    mov Alberto ShabbySam
    mov Gertrude Alberto
    mov ShabbySam Gertrude

    done:

    mov 10 ShabbySam

    gte 1s ShabbySam Leopold
    jz Leopold undo_u

    mov 30 ShabbySam
    gte 1s ShabbySam Leopold
    jz Leopold undo_d

    undo_r:

        POP!! 1

        "shuffle" f
        "shuffle" f
        "shuffle" b
        "shuffle" b
        "shuffle" l
        "shuffle" f
        "shuffle" f
        "shuffle" b
        "shuffle" b

        jmp end

    undo_u:

        POP!! 1

        "shuffle" f
        "shuffle" f
        "shuffle" f
        "shuffle" b
        "shuffle" b
        "shuffle" b
        "shuffle" l
        "shuffle" l
        "shuffle" l
        "shuffle" f
        "shuffle" b

        jmp end

    undo_d:

        POP!! 1

        "shuffle" f
        "shuffle" b
        "shuffle" l
        "shuffle" f
        "shuffle" f
        "shuffle" f
        "shuffle" b
        "shuffle" b
        "shuffle" b

    end:
    jnz 1s main

print Hans
done!

This was really great fun, thank you Liam! :)

Thanks to Sp3000 for a slight but necessary nudge in the right direction.

How?

Two words: Pocket Cube.

It turns out that the stacks correspond to the faces of a 2x2x2 Rubik's cube as follows:

           ____ ____
          |    |    |
          | 19 | 17 |
          |____U____|
          |    |    |
          | 20 | 18 |
 _________|____|____|____ ____ ____ ____
|    |    |    |    |    |    |    |    |
| 13 | 14 |  1 |  2 |  9 | 10 |  6 |  5 |
|____L____|____F____|____R____|____B____|
|    |    |    |    |    |    |    |    |
| 15 | 16 |  3 |  4 | 11 | 12 |  8 |  7 |
|____|____|____|____|____|____|____|____|
          |    |    |
          | 22 | 24 |
          |____D____|
          |    |    |
          | 21 | 23 |
          |____|____|

Where ULFRBD indicate which face corresponds to up, left, front, right, back, down when the cube is folded properly.

The permutations correspond to rotating any one side by 90 degrees (where the names thankfully match up). It turns out that f, r and d are clockwise rotations (when viewing the face) and r, l and u are counter-clockwise rotations (when viewing the face).

Now the cinpush command operates such that it applies one of the rotations u, d or r (depending on the given value) and then pushes the input value onto the stack in position 1. (And then it repeats doing this for every element in the input.) That means we can reverse this process (to ensure we end up with the correct order of stacks without having to solve an arbitrary Rubik's cube) by repeatedly looking at the stack in position 1, undoing the corresponding permutation and popping the value of that stack (so that next time we see the stack, we get the value underneath).

How do we undo the rotations? Thankfully, we have both f and b at our disposal. If we apply both of them, we rotate the entire cube by 90 degrees. This means we can move the affected side (U, R or D) to L, undo the rotation using one or three ls (depending on the relative direction of l and the rotation performed during the input), and then rotate the cube back to its previous orientation using f and b again.

In particular, each of the rotations performed during input can be undone as follows:

u --> fffbbblllfb
r --> ffbblffbb
d --> fblfffbbb

I'll see if I can come up with some animations to show that this works.

Now this gives us a way to iterate through the entire input once. But with 5 registers, that's all we need:

Alberto is the maximum value encountered so far.
Gertrude is the 2nd largest value encountered so far.
Hans is the 3rd largest value encountered so far.

When we encounter a new value, we bubble it up those three as far as necessary, where we can use ShabbySam as a temporary register for the swaps. That still leaves Leopold which we can use to hold a conditional when making the necessary comparisons.

At the end of the process, we simply print the contents of Hans, which will already hold the 3rd largest value.


Output a Latin Square An \$n\times n\$ Latin Square is a grid containing exactly \$n\$ distinct values where the values in each row and column are distinct. For example,
$$\begin{matrix}
A & B & C \\
C & A & B \\
B & C & A \\
\end{matrix}$$
is a Latin square as no row or column contains a repeated value.
You are to take a positive integer \$n\$ as input and output an \$n\times n\$ Latin Square. The values can be any \$n\$ distinct values, and do not have to be consistent for different \$n\$. Your program should be consistent and deterministic, so running it with the same input should always produce the same output.
You may output in any reasonable manner, including a flat array consisting of \$n^2\$ values, or as a list of \$n\$ lists, each containing \$n\$ values. You may input and output in any convenient method
This is code-golf, so the shortest code in bytes wins.
Test cases
These are just some possible outputs, your program may differ so long as the output is correct
1 [[1]]
2 [[1, 2], [2, 1]]
3 [[1, 2, 3], [2, 3, 1], [3, 1, 2]]
4 [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]
5 [[1, 2, 3, 4, 5], [2, 3, 5, 1, 4], [3, 5, 4, 2, 1], [4, 1, 2, 5, 3], [5, 4, 1, 3, 2]]

Python 2, 37 bytes
Outputs a flattened \$ n \times n \$ latin square.

lambda n:((range(n)*-~n)[1:]*n)[::~n]

Try it online!


Create a Muriel-like language and implementation Muriel is a language where the only way to loop is to create a quine and execute it. Your job is to create your own language with this property and an implementation of it in a pre-existing language.

We will define a Muriel-like language like as follows:

It has a built-in command for executing code in its own language, similar to Muriel's @ command or python's exec.
It is Turing complete.
If you remove the built-in execution command it is no longer Turing complete.

Muriel is Muriel-like with @ as its built-in execution command. Smurf is also Muriel-like (its built-in execution command is x). Python is not Muriel-like, since it is still Turing complete if you remove exec.

Your job is to create a Muriel-like programming language, and then to provide an implementation of it in a language of your choice. Your score is the length of the implementation, which you are trying to minimize.

Notes:

Your built-in execution does not need to function exactly like Muriel. It is up to you how it handles termination of the child program, errors, scoping, etc...
The language you write the implementation can not itself be Muriel-like. (This is so that @ is not a valid entry.) It also must have existed before this post.

Python 3 and "The minimum TC subset of Underload but with the characters changed to 2019, reversed, and with a 0 on top", 156 129 bytes

c,n,*s=input(),0,[]
while c:
 i,*c=c;q="6">i
 if n:n+=q*int(i)-q;s[n and-1]+=i,
 elif q:n="1"<i;s+=s[-1]*(1-n),
 else:c=s.pop()+c

Try it online!
Explanations in the header, ungolfed code in the footer.


\$n\$-perfect numbers A positive integer \$x\$ is an \$n\$-perfect number if \$\sigma(x) = nx\$, where \$\sigma(x)\$ is the divisor sum function. For example, \$120\$ is a \$3\$-perfect number because its divisors sum to \$360\$:
$$360 = 3\times120 = 1+2+3+4+5+6+8+10+12+15+20+24+30+40+60+120$$
and
$$926073336514623897600 = 6\times154345556085770649600 = 1+2+3+4+5+6+7+8+9+10+11+12+\dots+51448518695256883200+77172778042885324800+154345556085770649600$$
so \$154345556085770649600\$ is a \$6\$-perfect number.
You are to take an integer \$x\$ as input and output a value \$n\$, such that \$x\$ is an \$n\$-perfect number. If no such \$n\$ exists, you may output any consistent value that isn't a positive integer. You will never receive an input outside the bounds of your language, but your algorithm must work for arbitrarily large \$x\$.
This is code-golf so the shortest code in bytes wins.
Mini challenge: Beat 5 bytes in Jelly
Test cases
    x -> n
    1 -> 1
    2 -> 0
    3 -> 0
    4 -> 0
    5 -> 0
    6 -> 2
   28 -> 2
  120 -> 3
  496 -> 2
  500 -> 0
  672 -> 3
30240 -> 4
154345556085770649600 -> 6

Jelly, 5 bytes
R×iÆs

Try it online!
Explanation:
      - Explanation (sample for input 6)
R     - Range ([1, 2, 3, 4, 5, 6])
 ×    - Multiply by input ([6, 12, 18, 24, 30, 36])
   Æs - Divisor sum (12)
  i   - Index of divisor sum in list, else 0 (2)


Compute the size of intersections of sets Input
A positive integer N representing the size of the problem and four positive integers v, x, y, z.
Output
This is what your code should compute. Consider a set of N distinct integers and consider all ways of choosing 3 subsets (which can overlap) from the set.   There are \$2^{3N}\$ different possible ways of choosing the three subsets. Call the three subsets A, B and C.
Your code must count the number of possible choices of subsets A, B, C such that |A∩B∩C| = v, |A∩B| = x, |B∩C| = y, |C∩A| = z for non-negative integers v, x,y, z.
Scoring
I will generate a set of 5 valid inputs for each N and the time for your code will be the longest running time for a given problem size for any of the 5 inputs. Each answer will be tested on the same set of inputs, and your score is the highest N your code reaches on my PC in 60 seconds (spec details below). This means you need to give me simple and complete instructions on how to compile and run your code in Linux.
Examples
Answers for different values of N, v, x, y, z.

2, 0, 1, 1, 1 gives 0
2, 1, 1, 1, 1 gives 8
2, 2, 1, 1, 1 gives 0
8, 0, 2, 3, 3 gives 560
8, 1, 2, 3, 3 gives 80640
8, 2, 2, 3, 3 gives 215040
8, 3, 2, 3, 3 gives 0

My PC
I have an AMD Ryzen 5 3400G running Ubuntu 20.04.
Notes
This challenge is run per language so the fastest in Python is not competing with the fastest in C directly. I will maintain a league table per language once the first answer is given.

Python 3.8 (pre-release)

from math import comb
C=lambda n,k:comb(n,k) if n>=0 and k>=0 else 0
f=lambda n,v,x,y,z:C(n,v)*C(n-v,x-v)*C(n-x,y-v)*C(n-x-y+v,z-v)*4**(n-x-y-z+2*v)

Try it online!

We fill the Venn diagram's compartments one by one, and we multiply the numbers of options we have at each step:
C(v,n) - to fill the common intersection A∩B∩C, we need to choose v elements out of a total of n. After making that choice, we are left with n-v elements.
C(n-v,x-v) - we fill the x-v compartment from those n-v, and we're left with n-v-(x-v) = n-x elements
C(n-x,y-v) - we fill y-v, with n-x-y+v left
C(n-x-y+v,z-v) - we fill z-v
For each of the remaining n-x-y-z+2*v elements, there are four possibilities - either belong to exactly one of A, B, or C, or to none of them. Those choices are independent, so we multiply by 4**(n-x-y-z+2*v).


Let's do some “enciph5r47g” This is the inverse of Let's do some "deciph4r4ng"

In this challenge, your task is to encipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each typical writing character (ASCII range 32-126) must be replaced by a number N (0-9) to indicate that it is the same as the character N+1 positions before it. The exception is when the character does not appear within the previous 10 positions in the original string. In that case, you should simply print the character again.
Effectively, you should be able to reverse the operation from the original challenge.
Example
The input string "Programming" would be encoded this way:

Hence, the expected output is "Prog2am0in6".
Clarifications and rules

The input string will contain ASCII characters in the range 32 - 126 exclusively. You can assume that it will never be empty.
The original string is guaranteed not to contain any digit.
Once a character has been encoded, it may in turn be referenced by a subsequent digit. For instance, "alpaca" should be encoded as "alp2c1".
References will never wrap around the string: only previous characters can be referenced.
You can write either a full program or a function, which either prints or outputs the result.
This is code golf, so the shortest answer in bytes wins.
Standard loopholes are forbidden.

Test cases
Input : abcd
Output: abcd

Input : aaaa
Output: a000

Input : banana
Output: ban111

Input : Hello World!
Output: Hel0o W2r5d!

Input : this is a test
Output: this 222a19e52

Input : golfing is good for you
Output: golfin5 3s24o0d4f3r3y3u

Input : Programming Puzzles & Code Golf
Output: Prog2am0in6 Puz0les7&1Cod74G4lf

Input : Replicants are like any other machine. They're either a benefit or a hazard.
Output: Replicants 4re3lik448ny3oth8r5mac6in8.8T64y'r371it9376a1b5n1fit7or2a1h2z17d.

Retina, 24 23 bytes

(.)(?<=\1(.{0,9}).)
$.2

Try it online!

A fairly simple regex substitution. We match each character and try to find a copy of it 0-9 characters before it. If we find it, we replace the character with the number of characters we had to match to get to the copy.

The results don't quite match the test cases, because this one uses the largest possible digit instead of the smallest possible one.