Golfed sort by debian version number I wrote some perl to sort by debian package version number (specification here). Whilst readable, it was disappointingly long (114 lines, 2042 characters) - shocking. So this challenge is to produce the shortest program (in perl or otherwise) which takes debian package version numbers on STDIN separated by \n, sorts them, and puts the output on STDOUT separated by \n.

You can produce an dataset of debian versions numbers on a debian/ubuntu box by:

apt-cache madison . | perl -n -e 'print "$1\n" if /^\S+\s+\|\s+(\S+)\s+/;'

For those not on Debian / Ubuntu I've put a random selection of 1000 here. The sorted version of this sample is here. The md5sum of the unsorted and sorted versions (check they each end with a \n) are:

5ffd12d3f59b06619a712e92791c0dfd  input.sample
e6b2d03ddfd9491c5bdf2594a5aa82e5  output.sample

(note as Ventero points out in the comments, there are certain equivalent version numbers, e.g. lines 135-138 out of the output, where 08 and 8 are equivalent and thus the sort order is arbitrary)

For the purposes of verifying your input, you can install Debian::Dpkg::Version from CPAN and use the following to test:

#!/usr/bin/perl

use strict;
use warnings;
use Debian::Dpkg::Version;

my @input;

while (<>)
{
    chomp;
    push @input, $_;
}

my @output = sort version_compare (@input);
print join("\n", @output)."\n";

The following test data is thus sorted in the correct order, and (I believe) only contains lines complying with the Debian spec above, with each version being distinct:

0~~-~~
0~~-~
0~-~~
0~-~
0~-0
0-0
0-1
0-02
3-0
04-0
04a-0
5-0
04:3-0
5:3-0
06:3-0
06:3a-0
06:3a-01
06:3a-3~
06:3a-3
6:3a-04
06:3a-05
06:3.-0
06:3:a
06:3:a-01
06:3:a-05

The rules are:

Package name sorting must be exactly per the Debian spec
No inclusion of external modules written to perform Debian packages sorting, as that would make it rather easy. Therefore golfing the above test program will not produce a legal answer, as it includes Debian::Dpkg::Version. You may of course look to the source of that module for inspiration if you lack imagination, but I believe there are shorter ways to do this.
You may assume that any input line whose format is invalid (i.e. does not constitute a version number conforming to the debian spec) must be retained, but may be sorted arbitrarily.
Equivalent version numbers may be sorted arbitrarily, e.g. 0.08-1 is equivalent to 0.8-1 as the numeric components 08 and 8 are compared as integers.
Save in respect of the arbitrary sort order of any lines not constituting version numbers conforming to the debian spec, and equivalent version numbers, your output should be identical to the test program above.

Ruby 2.0, 145 179 characters

puts$<.sort_by{|a|(1..3).map{|i|"#{a[/^(\d+:)?(.+?)(-[^-]+)?
/,i]}".scan(/(\D*)(\d*)/).map{|w,n|w.bytes.map{|c|c<126?c>58?c:c+99:-1}+[0,n.hex]}}}

Correctly sorts both the linked reference input (though it generates a slightly different output order due to different sorting of equivalent version numbers, e.g. 1.06-2 vs 1.6-2) and the included test data.


Is my kids' alphabet mat properly grouped by colors? My kids have an alphabet mat to play with, something like this:

After months with the tiles of the mat randomly placed, I got tired and placed all the tiles of the mat grouped by sections according to their background colors. So, if the letters represent the background color, I got a mat like this:

AABBCDDDE
ABBCCCDEE
ABCCCCDDE
AACCCDDEE
AAAACCCCE
AAAAAACCC

So, for colors A, B, C, D and E there is always a way to connect all the tiles with the same background color either horizontally or vertically in the mat. That's what I call a mat properly grouped by colors. You can see the groups for the previous example in the following tables:

AA
A
A
AA
AAAA
AAAAAA

  BB
 BB
 B

    C
   CCC
  CCCC
  CCC
    CCCC
      CCC

     DDD
      D
      DD
     DD

        E
       EE
        E
       EE
        E

Also, there is only one group for every color, so this would not be valid:

ABA
ABA

Because color A tiles are not grouped in only one group. This also would not be valid because the tiles do not connect either horizontally or vertically:

AB
BA

The challenge

Given a 2-dimensional array of characters in the printable ASCII range (does not need to be a square one as long as the size of both dimensions are equal to or greater than 1), check if the array represents a mat properly grouped by colors (each different character in the array represents a different color). Input may be in any reasonable format as long as it represents a 2-dimensional array of characters (2D char array, array of strings of the same length, and so on), and output must be a pair of truthy and falsey values (0/1, 't'/'f', true/false, whatever as long as something is returned and the return values are consistent across inputs).

This is code-golf, so may the shortest program/function/method/lambda for each language win!

Examples

A    truthy

AB
AB   truthy

AB
BA   falsey

ABCDE    truthy

ABCDC    falsey

**::dd22
***:d222
*:::::22    truthy

$$$%%%&&
$$%%&&&&
&&$$$%&&    falsey

AABBCDDDE
ABBCCCDEE
ABCCCCDDE
AACCCDDEE
AAAACCCCE
AAAAAACCC   truthy

AABB
ABBA
AAAA    truthy

AAAB
AAAA
AAAA    truthy

My mat properly grouped by colors

(I still have to fix those borders...)

MATL, 16 15 bytes

1e"G@=4&1ZI1>vzg

Input is a 2D char array (with rows separated by ;). Output is 0 if input qualifies, or 1 otherwise.

Try it online! Or verify all test cases.

Explanation

The code essentialy checks if each char in the input has only one connected component, considering 4-connectivity (that is, no diagonals).

Repeated chars are processed repeatedly (which is golfier than deduplicating).

1e       % Implicit input. Reshape into a row vector of chars
"        % For each char
  G      %   Push input again
  @      %   Push current char
  =      %   Equal (element-wise)? Gives a matrix of zeros and ones, where one
         %   represents the presence of the current char
  4      %   Push 4. This will indicate 4-connectivity
  &1ZI   %   Matrix with labels of connected componnents. Inputs are a number (4)
         %   to indicate connectivity, and a binary matrix. The output is a matrix
         %   the same size as the input where each connected componnent of ones
         %   in the input is replaced by a different integer starting at 1
  1>     %   Greater than 1 (element-wise)? The result is a matrix. If the result
         %   is true for some entry the input doesn't qualify
  v      %   Concatenate vertically with results from previous iterations
  z      %   Number of nonzero/true values
  g      %   Logical. Converts nonzero to true
         % Implicit end. Implicit display. False / true are displayed as 0 / 1


What colour is this? Given three number values - being the Red, Green, and Blue elements of a colour (eight bits per channel, 0 to 255) - your program must output the name of the given colour.

For example;

Input:  255, 0, 0
Output: Red

or;

Input:  80, 0, 0
Output: Dark Red

This is a popularity contest, so whichever answer has the most votes by the first of July wins.

Ispired by: Show the input RGB color

Python

This is a Python script that uses the results from xkcd's Color Survey, in which Randall Munroe asked thousands of people the exact same question. He arrived at the following chart:

The survey only has data on fully-saturated colors (I guess non-saturated colors would all be described as 'grayish'). This means we have to do some color-related tricks to force our input to become fully saturated.

What I've done here is just convert the input color to HSV, crank up the saturation, and call it a day. This is probably not very correct from a color perception point of view, but it works well enough here - and it's simple enough that you only need the standard library. Batteries included indeed.

The script expects satfaces.txt, from here (mirror), to be in the current directory.

import sys, colorsys

n = (int(sys.argv[1], 16))
r = ((n & 0xff0000) >> 16) / 255.0
g = ((n & 0x00ff00) >> 8) / 255.0
b = ((n & 0x0000ff)) / 255.0

(h, s, v) = colorsys.rgb_to_hsv(r, g, b)
(r, g, b) = colorsys.hsv_to_rgb(h, 1, v)

match = "[{}, {}, {}]".format(int(r*255), int(g*255), int(b*255))

for line in open("satfaces.txt"):
    if line.startswith(match):
        print("You were thinking of: " + line.split("] ")[1].strip())
        break

Some example runs:

$ python color.py CEB301
You were thinking of: yellow
$ python color.py CC9900
You were thinking of: orange
$ python color.py CC0000
You were thinking of: red
$ python color.py 0077FF
You were thinking of: blue

And here are the colors:

I'd say that's pretty close.


Give me the first day of next month Simple question!

Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format.

Example inputs:

2018-05-06

2019-12-20

Their respective outputs:

2018-06-01

2020-01-01

The rules:

Imports are free and don't count towards your score.
The date will be stored in a string called s.
The solution with the least characters, wins


The redundant boolean Introduction

Classically, booleans are one bit; true or false, 1 or 0. Leading zeros would just be redundant. For example, 001 means the same as 00001 or just 1.

The 32-bit boolean

Given a truthy/falsey value, output the equivalent 32-bit boolean as a string.
 (Or as a number if for some reason your language supports leading zeros.)

Your program doesn't have to work for every truthy/falsy type, only what your programming language work best for.

Example i/o

Input >> Output

truthy >> 00000000000000000000000000000001
falsey >> 00000000000000000000000000000000

This is code-golf, so lowest bytes wins!

Python 3, 33 25 18 15 bytes

Thanks @jurjen-bos for the __mod__ tip.

'%.32d'.__mod__

Try it online!


Arbitrary-Length Ternary Squarefree Words A string is squarefree if it contains no substring twice in a row.

It is possible to have an arbitrarily long squarefree word using a 3-letter alphabet.

Write a program which accepts a positive integer n from stdin and prints any squarefree word of length n, using characters A, B and C.

Shortest code wins.

Python, 94

n=input()
x=[0]
exec"x+=[1-y for y in x];"*n
print''.join('ABC'[x[i+1]-x[i]]for i in range(n))

It uses the Thue–Morse sequence method from wikipedia.

Efficient version (100 chars):

n=input()
x=[0]
while x==x[:n]:x+=[1-y for y in x]
print''.join('ABC'[x[i+1]-x[i]]for i in range(n))


Simulate move left for 2048 I have a fixed length vector of 4 elements. The inputs of which are always 0 or 2^n for n = 1 to 15 (so n = 0 excluded i.e.  2^0 = 1 will not appear)

x = [32, 4, 4, 8]

the result should be

x = [32, 8, 8, 0]

The way it works is that values that are the same will get combined, but one it's combined it can not be combined with another value for another turn.

and we want to simulate the shortest code to make simulate 2048 move left on this one row.

The shortest code wins! It's fixed-size 4 vector. So it's not the same as the other problem. Also, you need to put zeros here.

Test cases:

[0,0,0,0] -> [0,0,0,0]
[0,0,0,2] -> [2,0,0,0]
[2,0,0,4] -> [2,4,0,0]
[8,0,0,8] -> [16,0,0,0]
[16,16,32,64] -> [32,32,64,0]
[16,16,8,8] -> [32,16,0,0]
[2,2,2,0] -> [4,2,0,0]

APL (Dyalog Unicode), 36 bytesSBCS

Anonymous tacit prefix function.

⎕UCS{4↑⍺⍺t⎕R(1⌽∪¨t←2/¨⍺⍺2*⍳16)⍺⍺⍵~0}

Try it online!

⎕UCS{…} derived function where ⍵ is the argument and ⍺⍺ converts to/from code points:

 ⍵~0 the argument without zeros

 ⍺⍺ convert to code points

 t⎕R(…) Replace the texts t (defined below) with the corresponding texts from:

  ⍳16 the indices from 1 to 16

  2* two raised to the power of those

  ⍺⍺ convert them to characters

  2/¨ make two of each

  t← assign to t

  ∪¨ get the unique element from each (i.e. deduplicate them)

  1⌽ cyclically rotate the first string to the end

 ⍺⍺ convert to code points

 4↑ take the first four elements, padding with zeros


Solve Any Motion Physics Problem (Equations Supplied) Physics Challenge

This program should be able to solve for ANY two of the following variables the user wants to solve.

s (displacement)
v (velocity)
u (initial velocity)
a (acceleration)
t (time)

At start the user must choose two variables they want to solve for and what variables they can supply. You are limited to using the following equations.

Equations Permitted

(http://en.wikipedia.org/wiki/Equations_of_motion)

The entrant with the least amount of code and posts the quickest will win.

Rules

This is code-golf. The shortest code wins.
Your program must terminate in reasonable time for all reasonable inputs.
You are allowed to transform the equations algebraically if need be
The program must be able to interpret a variable of which the user cannot supply (See Example 2)

Input Example

The program will start and ask which variable the user will like to calculate:
(s, v, u, a, t) - the user selects this via a char type or string.
It then supplies all values for the other unknowns and the program will solve for the variables.

Example 1:

*What would you like to calculate? (s, v, u, a, t)*
Input: a, u     // This could also be s,v s,u, s,a v,u (ANY COMBINATION)

*Enter value for s:*
Input: 7        // The input will always be random

*Enter value for v:*
Input: 5

// Repeat for others

//program calculates

Var a = answer
Var u = answer

Example 2:

*What would you like to calculate? (s, v, u, a, t)*
Input: a, t

*Enter value for u:*
Input: 5

*Enter value for s:*
Input: UNKNOWN

*Enter value for v:*
Input: 7

*The answers for a and t are 464 and 742*

Edit

I think everyone here is overcomplicating the question. It simply asks to solve any 2 variables from the list of (s, v, u, a, t) and solve them using the equations. As the programmer you must be able to allow values to be taken for the variables that are not being solved. I will clarify that the program must be able to solve for any variable supplied by the user on startup. I also removed the somewhat correct equation s=v/t because people are becoming confused by it.

Maple, 41 chars

s:=i->solve({v=u+a*t,s=(u+v)*t/2,op(i)}):

(Formulas used: #1 and #3.  These are sufficient to let Maple derive the rest.)

This defines a function s that takes in a set of initial conditions and solves the equations of motion for those initial values.  For example, the command:

> s({ u = 1, v = 2, t = 3 });

outputs:

                          {a = 1/3, s = 9/2, t = 3, u = 1, v = 2}

Notes:

You generally need to specify three initial values for a unique solution; if you don't provide enough, Maple will try to give you a partial solution:

> s({ u = 1, v = 2 });

                                        3 t
                          {a = 1/t, s = ---, t = t, u = 1, v = 2}
                                         2

(Yes, that's an ASCII art fraction there.  Even in text mode, Maple tries to typeset your math nicely.)

No solution is return for overspecified or otherwise unsolvable inputs; for example, s({ u = 1, v = 2, t = 0 }); outputs nothing.

If multiple solutions exist, Maple will generally try to return all of them:

> s({ u = 1, s = 0, a = -1 });

                          {a = -1, s = 0, t = 2, u = 1, v = -1},
                          {a = -1, s = 0, t = 0, u = 1, v = 1}

Sometimes, the output may contain RootOf() expressions, as in:

> s({ u = 10, s = 1, a = -1 });
                                                         2
                {a = -1, s = 1, t = RootOf(2 - 20 _Z + _Z , label = _L3), u = 10,
                                               2
                 v = 10 - RootOf(2 - 20 _Z + _Z , label = _L3)}

As far as Maple's concerned, this is a perfectly good solution, but if you want to turn it into something readable for us mere humans, use allvalues():

> allvalues(s({ u = 10, s = 1, a = -1 }));
                                            1/2                 1/2
                {a = -1, s = 1, t = 10 - 7 2   , u = 10, v = 7 2   },
                                            1/2                  1/2
                {a = -1, s = 1, t = 10 + 7 2   , u = 10, v = -7 2   }

Alternatively, you can specify the initial conditions as floating-point values, e.g. u = 10.0, which will cause Maple to return purely numerical solutions instead:

> s({ u = 10.0, s = 1, a = -1 });

                {a = -1., s = 1., t = 0.1005050634, u = 10., v = 9.899494937},
                {a = -1., s = 1., t = 19.89949494, u = 10., v = -9.899494937}

Finally, note that, since Maple is a computer algebra system, it allows you to specify arbitrary equations in the input.  For example, if we didn't care about the specific initial velocity, but only about the change in velocity, we could just specify e.g. v = u + 1 and get the partial solution:

> s({ v = u + 1 });

                {a = 1/t, s = t v - 1/2 t, t = t, u = v - 1, v = v}

We can even extend the physics model if we want, as in:

> s({ f = m * a, u = 0, f = 1, m = 10, t = 5 });

                {a = 1/10, f = 1, m = 10, s = 5/4, t = 5, u = 0, v = 1/2}


12 hour to 24 hour time converter Amazingly, this simple task doesn't seem to exist already, so...

Your task is to write a program that takes as input a 12 hour time,  and converts it into "military time", or 24-hour time format.

Input will be in the form:

HH:MM am/pm

Although slight variations are allowed:

The space separating the am/pm from the rest of the time is optional.
The last part can either be "am"/"pm",  or "a"/"p".
Any capitalization is fine.

Output will be the inputted time, transformed into 24-hour format. It can be a number, or a string.

For both the input and output:

0s in the first place are optional. 0s in the last 3 places are mandatory.
the delimiter separating hours and minutes can be a ":", " " (a space), or nothing.

Other notes:

Midnight can be expressed either as 0000, or 2400.
Midnight will be considered "am", while noon will be considered "pm".

Your program can be a function, or a full program, and should either return the result, or output it to the stdout. Trailing whitespace is ok.

Examples (you aren't required to support every format):

12:00am -> 0000
1200 pm -> 1200
1234Am  -> 00:34
134a    -> 134
01:34PM -> 13 34
1234pm  -> 1234

This is code golf, so the smallest number of bytes wins. Since this is so trivial to solve using a built-in, it would be nice to see some code that manually solves this (but use of built-ins are fine).

Just to clarify, you aren't required to support every possible format. Supporting only a single input and a single output format (of your choice) is fine. I would however like to limit the format as outlined above (which is already quite free). {1134,'pm'}, for example, would be unacceptable.

MATL, 4 bytes
15XO

Try it online!
Explanation
Built-in function: date string conversion with automatic detection of input format and with output format 15, which corresponds to 'HH:MM'. This is equivalent to @StewieGriffin's Octave answer.


A nicely-spaced ASCII spiral Consider this spiral

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

Starting in the centre:

The first line (upwards) has 3 characters.
The second line has the same number of characters (3)
Next, we add two chars (5) for the next two sides.
This pattern continues, two sides the same length then increase the length by 2.

I want to generate this spiral for N lines.

Write in any language.
The input/argument, etc. is the number of lines in your spiral.
Each line starts with the ending character of the previous line in the direction 90 degrees clockwise of the previous line.
I don't care how much whitespace is before or after each line, as long as the elements of the spiral line up.
Output text to draw the spiral with any non-whitespace character you choose.
Attempt to do this in the smallest number of bytes.

Test cases (using a hash as output):

N = 1

#
#
#

N = 2

###
#
#

N = 3

###
# #
# #
  #
  #

N = 10

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

05AB1E, 13 11 bytes

Code:

Thanks to Emigna for saving two bytes!

LDÈ-Ì'#3Ý·Λ

Uses the 05AB1E encoding. Try it online!

Explanation

The lengths of each individual edge on the spiral starts with length 3 and gradually increases every two steps by two:

$$
3, 3, 5, 5, 7, 7, 9,\dots
$$

For a spiral with \$n\$ edges, we just need to trim this list to size \$n\$. This is done with the following piece of code:

L                # Create a list from [1 .. input]
 DÈ              # Duplicate and check for each number if even
   -             # Subtract that from the first list
    Ì            # Add 2

This basically gives us the desired list of lengths.

     '#          # Push the '#' character
       0246S     # Push the array [0, 2, 4, 6]
            Λ    # Write to canvas

The canvas works as a function that pops three parameters (where the rightmost parameter is popped first): <length(s)>, <char(s)>, <direction(s)>. The directions parameter is in this case a list of numbers. The numbers that correspond to the directions are:

$$
\left[\begin{array}{r}
7 & 0 & 1 \\
6 & \circ & 2 \\
5 & 4 & 3
\end{array}\right]
$$

In this case, [0, 2, 4, 6] corresponds to the directions list [↑, →, ↓, ←]. The canvas iterates over each length retrieved from the list of lengths, uses the '#' character and cyclically iterates over the directions list.


The ASCII character countdown! Since this is a answer-chaining challenge, you might want to sort answers by oldest.

Your task is simple: Choose any printable ASCII character that's not chosen in the previous answers. And then, you need to print your chosen character in your program to standard output. (You can ONLY print your chosen character, without printing other garbage to STDOUT)
The catch
Let's say you picked x as your chosen character, and your answer is the answer numbered y. You have to insert y x's into the previous source code, at any position you like. For the first answer, the previous answer is the empty program.
An example
Answers have to start with the number 1. So for example, I chose the character #, and I posted a 1 byte answer in /// that prints the # mark.
#

And then, the second answer (numbered 2) has to insert 2 of their picked x character into the previous source code, such that the modified code will print their x character. So assume this is written in Keg:
x#x

And then, the third answer has to do the same, and so on, until 95 is reached.
Answer format
I'd love to see an explanation of your code as well, preferably with an online interpreter link!
# [{Language name}]({link-to-language}), {code-length} bytes

\$y= {The number of your answer}\$. Used so far: <code>{Characters used in answers so far}</code>

    {your code}

The winning criterion & other rules

The first user whose answer stays without a succeeding answer for a month wins the challenge. If that's not satisfied, the first person who reaches the number 95 wins the challenge.
You are not allowed to put any other character in your code other than printable ASCII characters.
You need to wait 2 answers before you post a new answer after your submission.
Please make sure your answer is valid. If yours is not valid, chaining answers aren't allowed to be posted.
You can answer in a language that is used in previous answers.
You could only insert y x's into the source code.
Your are not allowed to take input.
Your program can output to STDERR, as long as the output to STDOUT is as intended.

2sable, 36 bytes
//9#999999//,#,#,221'/,#q',#q,qq2///

\$y=8\$. Used so far: 1'2q#,9/
Try it online.
Maybe this opens up some other languages that use // to comment. :)
Explanation:

2sable is an old version of 05AB1E (legacy) (which of itself is an old version of 05AB1E).
The legacy version outputs a leading newline however: try it online.
And the latest 05AB1E version outputs three leading newline: try it online.
//                                    # Divide twice, no-ops with an empty stack
  9                                   # Push 9
   #                                  # Pop and split it by spaces
                                      # (since it contains no spaces, it only pops)
    999999                            # Push 999999
          /                           # Divide the empty stack by this, popping the integer
           /                          # No-op divide again with an empty stack
            ,                         # No-op print (which would output a newline in the
                                      # newer versions)
             #,#,                     # Some more no-ops
                 221                  # Push 221
                    '/               '# Push "/"
                      ,               # Pop and print this "/" to STDOUT
                       #              # Split the 221 on spaces, so it just pops
                        q             # Exit the program
                         ',#q,qq2/// '# No-ops


I'm Jelly of Python (Robbers) What does "jelly" mean in the title?. Cop's thread
Robbers, you are to choose an uncracked Cop answer, and attempt to find a Jelly program which is:

shorter than the Cop's answer
solves the linked challenge, according to the rules of the challenge

So long as these two bullet points are met, your answer cracks the Cop's.
The user with the most cracks wins.
Example submission
# 8 bytes, cracks [ChartZ Belatedly's answer](<link to answer>)

    “3ḅaė;œ»

[Try it online!][TIO-kmrxlphk]

[TIO-kmrxlphk]: https://tio.run/##y0rNyan8//9RwxzjhztaE49Mtz46@dDu//8B "Jelly – Try It Online"

Jelly, 21 bytes, cracks Jonathan Allan's answer
“¡ẉḟUHġ[4A»ŒVw⁾SuNXṛ⁸

Try it online!
Takes the return value of time.ctime(), finds Su in it, and negates the value. On a Sunday, this passes -1 to X (random number function), causing an error. Otherwise it passes 0 to X, not erroring. then final return value is forced to be the empty string ⁸, so it will print nothing.


Simulate a sock drawer Background

I have a collection of "weekday socks", which are seven pairs of socks labeled by the days of the week.
When I wash my socks, they end up in a pile, and I must arrange them into the correct pairs before putting them into the closet.
My strategy is to pull one random sock from the pile at a time and put it on a drawer.
Whenever there's a matching pair of socks on the drawer, I tie them together and put them in the closet.
Your task is to simulate this random process and return the number of draws required to find the first matching pair.

Input

Your input is an integer N ≥ 1.
It represents the "number of days in a week": there are N pairs of socks in the pile, and each pair has a distinct label.
If necessary, you may also take a PRNG seed as input.

Output

Your output is the number of socks I have to draw before the first matching pair is found.
For example, if the first two socks already form a matching pair, the output is 2.

Of course, the output is random, and depends on the drawing order.
We assume that all drawing orders are equally likely, so that each time a sock is drawn, the choice is uniform and independent from all other choices.

Example

Let N = 3, so that we have 6 socks in total, labeled A A B B C C.
One possible run of the "sock-drawing protocol" is as follows:

       | Pile   | Drawer | Pairs
Begin  | AABBCC | -      | -
Draw B | AABCC  | B      | -
Draw C | AABC   | BC     | -
Draw B | AAC    | C      | BB
Draw A | AC     | AC     | BB
Draw A | C      | C      | AA BB
Draw C | -      | -      | AA BB CC

The first matching pair was found after drawing the second B, which was the third sock to be drawn, 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.
Input and output can be in any reasonable format, including unary (string of 1s).

You may assume that your language's built-in RNG is perfect.
You don't have to actually simulate the sock-drawing protocol, as long as your outputs have the correct probability distribution.

"Test cases"

Here are the approximate probabilities of all outputs for the input N = 7:

Output       2     3     4     5     6     7     8
Probability  0.077 0.154 0.210 0.224 0.186 0.112 0.037

To test your solution, you can run it for, say, 40 000 times and see whether the output distribution is reasonably close to this.

Jelly, 8 bytes

ḤX€Ṛ<RTḢ

Try it online! or verify the distribution for N = 7.

Background

Let n be the number of pairs; there are 2n individual socks.

For the first draw, there are 2n socks and 0 of them would result in a matching pair. Therefore, the probability of success is 0 / 2n = 0.

Since the first draw wasn't successful, there are 2n - 1 socks on the pile and 1 of them would result in a matching pair. Therefore, the probability of success is 1 / (2n - 1).

If the second draw wasn't successful, there are 2n - 2 socks on the pile and 2 of them would result in a matching pair. Therefore, the probability of success is 2 / (2n - 2).

In general, if the first k draws were unsuccessful, there are 2n - k socks on the pile and 2 of them would result in a matching pair. Therefore, the probability of success is k / (2n - k).

Finally, if none of the first n draws was successful, there are 2n - k socks on the pile and all of them would result in a matching pair. Therefore, the probability of success is n / (2n - n) = 1.

How it works

ḤX€Ṛ<RTḢ  Main link. Argument: n

Ḥ         Unhalve; yield 2n.
 X€       Map `random draw' over [1, ..., 2n], pseudo-randomly choosing an integer
          from [1, ..., k] for each k in [1, ..., 2n].
   Ṛ      Reverse the resulting array.
     R    Range; yield [1, ..., n].
    <     Perform vectorized comparison.
          Comparing k with the integer chosen from [1, ..., 2n - (k - 1)] yields 1
          with probability (k - 1) / (2n - (k - 1)), as desired.
          The latter half of elements of the left argument do not have a counter-
          part in the right argument, so they are left untouched and thus truthy.
      T   Truth; yield all indices of non-zero integers.
       Ḣ  Head; extract the first one.


Help My Brother Work on his Tan(gent)! This challenge is entirely fictional. There is no time limit for this challenge.
My little brother is terrible with computers! He saved up all of his money to buy a new one, and within half an hour the hard drive was wiped and the only software left is a lousy BF interpreter. The worst part of it is, he has a huge Geometry test tomorrow and needs help!
The Challenge
There's no way I'm going to let him touch my machine, so I'm going to need a fast way to write BF programs that solve his problem. He's learning about finding the area of regular polygons, and writing a new BF program for every calculation is a massive task. I need a fast way to generate BF programs! That's where you come in...
The Input
Your program or function will receive an integer 2 < N <= 100 which shall represent the number of sides of a regular polygon. You may receive input from function arguments, command line arguments, STDIN, or your language's closest alternative. If necessary, you may additionally require trailing or leading whitespace.
The Output
Your program should generate a separate BF program that takes input of a single positive integer 0 < a <= 10^10 that shall represent the length of the apothem of a regular polygon. When run, the BF program should output the area of a polygon with N sides and an apothem of a. More specifically:

Assume that the BF interpreter is set up such that , takes a number as input and . outputs a value as a number, not a character. An input of 12 does not translate to the characters '1' '2' in memory, rather the literal number 12. Similarly, when a value of 48 is output, it outputs '48', not the character '0'.
Assume also that each value on the tape of the BF program may contain an infinitely large integer -- the value will never wrap to 0.
Assume that the tape of the BF spans infinitely to the right, but has no negative indices. The pointer starts at 0.
My brother is as careless with numbers as he is with computers. As such, the BF code should output the area rounded to the nearest integer.

The Rules
In a separate and unrelated incident, my brother downloaded so much garbage onto my primary programming machine that I have virtually no hard drive space left. As such, your original program may not exceed 512 bytes.
Your score in this challenge is the length of all BF programs generated by your program for values of N from 3 to 100 inclusive.
Standard loopholes are disallowed.

Python, 23938 score

from math import*
def apothem(n):
 c=int(n*tan(pi/n)/2*10)

 s=',>' + '+'*c
 m=">[-]>[-]<<[>>+<<-]>>[<<<[>+>+<<-]>>[<<+>>-]>-]<<"*2
 p=">>[-]<[-]<+++++<[-]++++++++++"
 d=">[>+<-]>[<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<[>+<<-[>>[-]>+<<<-]>>>[<<<+>>>-]<[<-[<<->>[-]]+>-]<-]<<+>]"
 o="<."
 print s+m+p+d+o

the area of a regular polygon is nsa/2 width n given in Python and a later in BF. s is the sidelength of the polygon, which can be computed from a and n
c is a constant, such that the area is (aac+5)/10, so only this formula must be coded into BF. c is between 15 and 25.
s is the starting point for the BF code: read the apothem and write c
m does c=ca twice, so in the cell formaly holding c there is aac
p prepares for the final operation, clearing temporary cells, adding 5 to aac and setting the first cell to 10
d division
o output

This is my first writing in BF, so all algorithms are from this page.


Tips for code-golfing in C# What general tips do you have for golfing in C#? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C# (e.g. "remove comments" is not an answer). Please post one tip per answer.

-- borrowed from marcog's idea ;)

Instead of using .ToString() use +"" for numerics and other types that can be natively cast to a string safely.

.ToString() <-- 11 chars
+""         <--  3 chars


Escape from the tarpit (Robbers) This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete.
This is the robbers' thread. The cops' thread is here.
Robbers
The cops will post definitions of Turing-complete languages. Your task is to crack them by proving that they are indeed Turing complete. See the cops' challenge for more details and formal specifications.

ais523's answer - Blindfolded Arithmetic

(I hope my proof is understandable. I can't check my own proof e.g. with a Try it online! link so I'm not sure)

All code in this post will be Python pseudocode, with rep n: repeat n times. All conditionals must be either 0 or 1.

It's provable that the value of i is always >0 in the program execution, so i/i always give 1.

Define some building blocks:

if c: a = a + b is equivalent to d = b * c; a = a + d; assuming d is unused.
So, let (statement) be if c: statement where c can be some condition.

b = b * 2**N (where N is a compile-time constant) is equivalent to

rep N: b = b + b

b = a / 2**N is equivalent to

b = i / i
b = b * 2**N
b = a / b

b = a % 2**N is equivalent to

b = a / 2**N
b = b * 2**N
b = a - b

Any 2-symbol Turing machine with N states can be written like this:

while True:
    if state == 0:
        # process state 0
    if state == 1:
        # process state 1
    .
    .
    .
    if state == HALTING_STATE:
        0 / 0
    .
    .
    .
    if state == N-1:
        # process state N-1
    state = newstate

where each # process state block looks like this

# optional (not all states need this)
tape.move_left()

# optional
tape.move_right()

# optional
tape.flip()

new_state = a if tape.value() else b

This needs to be translated to BFA compatible code.

Two variables i and a will be used to represent the tape and state (and tape as well)

The content of i at each wraparound:

N least significant bits are equal to 2**state (i.e., the state'th significant bit is on, all other bits are off)
The rest of bits form the right half of the tape.

The content of a at each wraparound:

The left half of the tape.

The tape pointer is on the least significant bit of a.

At the beginning of each loop, N bits are inserted between the tape part and the state part in i:

d = i / 2**N
d = d * 2**N
i = i - d
d = d * 2**N
i = i + d

At each # process state i block, the structure of i is:

M-N least significant bits: the remaining part of the old value of state (state >> i). (where M = 2*N - i)
N next LSB: (partial) value of new_state (or 0 if it's not defined yet in that loop)
Rest: Tape.

Of course M is a compile time constant.

(as an exception, the "process halting state" block can be implemented as

if i%2: b = b - b; b = b / b;

or equivalently (assume c isn't used)

c = i % 2; b = i / i; if c: b = b - b; b = b / b;

)

More rewriting:

(tape.move_left()) (the outer () stands for conditional, as always)

# allocate a free bit on (i)
b = i / 2**M
(i = i + b)
# copy that bit from (a) to (i)
b = a % 2
b = b * 2**M
(i = i + b)
# remove a byte from (a)
b = i/i
(b = b + b)
a = a / b

(tape.move_right())

# allocate (M+1) bits at the end of (a)
(a = a * 2**(M+1))

# copy that from (i) to (a)
b = i % 2**(M+1)
(a = a + b)

# remove the (M) bits from (a) that is over-copied from (i)
b = i/i # now b==1
rep M: (b = b + b)
a = a / b # if the conditional fails a = a / 1 is a no-op.

# clear that bit on (i)
b = a % 2
b = b * 2**M
(i = i - b)

# remove the bit from (i)
b = i / 2**(M+1)
b = b * 2**M
(i = i - b)

(tape.flip())

b = a % 2
b = b * 2
(a = a - b)
b = i/i
(a = a + b)

(new_state = a if tape.value() else b)

  TODO

There are 2 remaining issues:

Only the bits to the left of the pointer is outputted, and
if not tape_value(): tape.move_left() (and the equivalent move_right) is not directly supported.

To solve those problems,

A TM with only a half of the tape is still TC.

  You can interlace the positive-index cells with the negative-index ones, and replace every movement with a double-movement (doubling the number of states). You'll also need to mark two cells at the left with special symbols so you know to shift by one and turn around (1 extra symbol; 1 extra state), and you'll need to have a reversed copy of every state for when you're in negative-land and every movement is backwards (again doubling the number of states).

(source)

So, it's possible to:

Make the tape from 2 interleaving infinite tapes.
One of them only have one 1 denoting the right end of the tape. The other is used to store data.
At program halt, instead of immediately exiting, move right until hit the end of the tape.

So the whole tape are stored in the right half (i.e., i) and readable at program termination.

  Am I still missing something?


The Farfallino Alphabet The Task
Your task is to create a program or a function that, given a sentence, outputs it translated to the Farfallino language. 'Y' is treated as a consonant.
The usual rules for farfallino alphabet are based on the substitution of each vowel with a 3 letter sequence where the vowel itself is repeated with an interceding f.
house → hofoufusefe
lake → lafakefe
star → stafar
king → kifing
search → sefeafarch

More examples:
Hello World

Hefellofo Woforld

Code golfs are nice, yuppy!

Cofodefe gofolfs afarefe nificefe, yufuppy!

When you come across a double vowel syllable (the vowels must match, like door, boots, reed, etc.) you must omit the 2nd vowel.
This rule is mandatory
Cool game

WRONG: Cofoofol gafamefe
RIGHT: Cofofol gafamefe

More examples, again:
Aardvark → Afafardvafark
Artisan → Afartifisafan
ASCII → AfaSCIfifi
NASA → NAfaSAfa
Oobleck → Ofofobleck
I'M DEAD! → Ifi'M DEfeAfaD!
Abc → Afabc

Input
Your input must be an ASCII string.
>2 consecutive vowels are not special. You have to handle 2 consecutive vowels:
AAAH → AfafaAfaH
AAAAH → AfafaAfafaH

How to win
The shortest source code in bytes for each language wins.
1, 2, 3... go!

Japt, v2.0a0, 7 bytes
r\v_²íf

Try it

Explanation
r           :Replace
 \v         :/[AEIOU]/gi
   _        :Pass each match through a function
    ²       :  Duplicate
     íf     :  Interleave "f"

Note: This solution was posted before the "bonus" of handling double vowels was made a requirement and before the (apparent) requirement that when repeating an uppercase vowel the second occurrence should be lowercased. I don't much feel like wasting time on a challenge whose spec is constantly changing and invalidating the solutions that have already been posted, nor do I feel I should be expected to sacrifice 90 rep by deleting a solution that was valid at the time of posting.


Tetrahedron Surface Area The challenge
This challenge is very straightforward. Given four 3-dimensional points, calculate the surface area of the tetrahedron that they form. This is code-golf, so shortest code wins. Standard loopholes apply, with the added stipulation that any built-in function to do this task given four points is prohibited.
You can assume all four points will be distinct, and will be given via STDIN, 1 point per line. Each point will consist of three 16-bit unsigned integers. The exact format of each point can be modified if it makes things easier, such as three space separated integers. Having each point on a separate line is mandatory however. Output should be through STDOUT, to at least 2 decimal places.
For those of you who do not know, a tetrahedron is a 3-d solid, formed by 4 triangular faces.
Example
# input (format is up to you, see clarification above)
[23822, 47484, 57901]
[3305, 23847, 42159]
[19804, 11366, 14013]
[52278, 28626, 52757]

# output
2932496435.95

Please leave a note if you notice my math is wrong.

Python, 198 178 161 chars

V=eval('input(),'*4)
A=0
for i in range(4):F=V[:i]+V[i+1:];a,b,c=map(lambda e:sum((a-b)**2for a,b in zip(*e)),zip(F,F[1:]+F));A+=(4*a*b-(a+b-c)**2)**.5
print A/4

The input format is as given in the question.

It calculates the length of the edges adjacent to each of the faces and then uses Heron's formula.


Output an upside-down tent Given an integer, output an upside-down tent.

The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).

If input = -1:
____
\/_/

If input = -2:
________
\  /   /
 \/___/

If input = -3:
____________
\    /     /
 \  /     /
  \/_____/

If input = 1:
____
\_\/

If input = 2:
________
\   \  /
 \___\/

If input = 3:
____________
\     \    /
 \     \  /
  \_____\/

et cetera

Note that the top of the tent (i.e. the last line) has 2 * abs(input) - 1 underscores.

There can be no leading spaces, such that the first line directly starts with an underscore.

Assume that the input will never be 0.

Your code should be as short as possible.

This challenge is based on a chat mini challenge by Helka Homba, which is allowed to be used in real challenges under the conditions of Calvin's Hobbies Public License.

MATL, 55 53 52 51 bytes
|95cy4*Y"DXytPEt0*yvG0>?P_]!'\/ 'w)95JG|G0<yEq:++&(

Try it online!
Explanation
Let N denote the input. The code proceeds in three steps.
First, the first line of  4*N underscores is built as a string and is displayed (which removes it from the stack).
Second, the "frame" of the tent is built using the two types of slashes. To do this, a numerical 2D array is created which contains 1 and 2 corresponding to the two types of slashes, and 0 for space.
This is done concatenating four matrices:

An identity matrix of size abs (N);
A matrix of the same size containing 2 in the antidiagonal;
A null matrix of the same size;
A copy of matrix 2.

Concatenating these four matrices vertically gives, using N=3 as an example, the following 4*N × N matrix:
1 0 0
0 1 0
0 0 1
0 0 2
0 2 0
2 0 0
0 0 0
0 0 0
0 0 0
0 0 2
0 2 0
2 0 0

(which, transposed, begins to look like the tent).
We now take care of the sign of the input. If it is positive we simply transpose the above matrix and index into the string '\/ '. Indexing is 1-based and modular, so 1 becomes '\', 2 becomes '/' and 0 becomes ' ', producing the 2D char array
\    /     /
 \  /     /
  \/     /

On the other hand, if the input is negative we vertically flip and arithmetically negate the 4*N × N matrix, producing
-2  0  0
 0 -2  0
 0  0 -2
 0  0  0
 0  0  0
 0  0  0
-2  0  0
 0 -2  0
 0  0 -2
 0  0 -1
 0 -1  0
-1  0  0

Index -1 now refers to '/' and -2 to '\'. That is, the two types of slashes have been interchanged, as required. Again transposing and indexing into the string '\/ ' thus gives the reversed tent:
\     \    /
 \     \  /
  \     \/

Third, underscores need to be filled into part of the last row of the 2D char array. The horizontal position of this line depends on the sign of the input, and its lenght is abs(N).
Once the corresponding spaces have been replaced by underscores, the result is implicitly displayed, below the initial line of underscores that was already displayed in the first step.


Print element from the periodic table Your task is simple: given a number as an input, you have to print the English name of the chemical element with that atomic number, up to and including ununoctium. For example, for an input of 77, your program has to print Iridium, and nothing else.

You can use any language, but no library (or other, in-built feature) which includes the names of the elements is allowed, your program has to store or generate the names on its own. Use names in wikipedia for the spelling of the names of the elements.

Shortest code wins, not sooner than 1 days after first valid answer.

Python, 69 + 536 = 605 (lazy solution)

I took the liberty of not capitalizing the names of the elements. That allows me to shave off extra 41 bytes. zlib is most likely not the best compressor for plaintext, it takes 1292 bytes down to 536.

python file:

import zlib
print (eval(zlib.decompress(open('a').read())))[input()]

data file a (b64 encoded for web):

eJxNVNGS5CAI/Jd5vj+62gdUJlpDMIU6t9mvPzSQ2YetZVCbpmny9/H488hnkrohzxCpjF0DKj1f
UUA5ybKhSp3XIkhYAZfuT+v3eQVPGlUK4zzGdavVdL3fYWNsVww09sJX3AqVuK4euTb9k9FmetBz
yKyXySFBtuti7dAMKgJFA4rAVquXDgb/BgbLxix1dzK8gdKZqMX6qgGor77iC2lljgMnhZ/CUf9t
4FpsKLsXAGmoTyYBJLRkmJUW55ecR18FZIRiTJoqx/2Kz97lin6KqBBXzKUGo1rpDAn5agxjZrSX
Mnr2gpJd50NZeseq7Xt1ECFZ5+Wj0SQFSmOvfC5somFUiqIt+t/INnWfXQC7Q/o2w8UroiUPgYY1
nVaNf8WHaoLurAa74+CQepiukCq5MTqKSZDOpo+tfq5kgPd5z4NuMe8sje5KZXg6qJKe7pvh4K31
ZVu5dazNdRIf1kGgWl38KqU5EpQ4ZGmWb08QwjwLpe06l+VS8mlC6xNjCira4toUATbjio8LYr+b
1z24Zeu/Doa48RgPbcE5jn4XU3rFoKMPVDf55futK1OeVew6FlYVHP6pzjbfISc19NuK1XB/HuCf
4M19elAUzVpII/heI+gnY/OPRxYfhW/ujqWz+yaB7CpScmtX5L75UHQRUelaycGDfWWehFLfn/yB
vlZU1Pm7izjPmur1+VXj+vH1H5EjvoY=


Explosions on a chessboard Atomic chess is a (very fun)
variant of chess in which every capture causes an "explosion," destroying the
captured piece, the piece doing the capturing, and all non-pawns in a 1-square
radius. The goal of this challenge is not to play an entire game of atomic
chess, but simply to simulate what happens when a certain move is made.

Disclaimer: Explosion sound effects not included.

Input

Board position will be given in Forsyth-Edwards
Notation
(commonly known as FEN), but with only the first field. For example, an input
of:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

represents the starting position:

This must be taken as a string or your language's equivalent. It is guaranteed
to be valid; for example, you don't have to care if there are ten kings, or if
there is no king at all.

You will also be given the move that you are to simulate, which is represented
as two square names: the square on which the piece to be moved is, and the
square it is moving to. For example, moving the king's pawn two spaces forwards
on the above picture would be represented as:

e2e4

This must also be taken as a string. The move will always be valid, and you do
not need to support castling. You do
need to support en passant, which
will be explained in further detail in the next section.

Output

The output of your program should be in the same partial-FEN notation as the
input, with the specified move made (and any pieces exploded if necessary).

The exact rules for explosions are—when a piece is captured:

Remove the piece being captured (this will always be the piece on the second
square named in the input, except for when the capture is an en passant).
Remove the piece that is doing the capturing (this will always be the piece
on the first square named in the input).
Remove every piece that is:

located on one of the 8 squares surrounding the one where the capture took
place (for en passant, this is the square that the capturing pawn would
be on, if it didn't explode).
not a pawn.

Quick overview of en passant rules, for those who are unfamiliar: if a pawn
moves two spaces forwards from its starting rank, and there is a pawn that
could have captured it if it only moved one square forward, it may capture it
anyway, but only on the subsequent move. This capture is said to be done "in
passing" (or in French: "en passant").

Test cases

In the pictures, the green arrows represet the move about to be made, and the
green circles represents pieces that are exploded.

Input: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR, g1f3
Output: rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R

Input: 3kBb1r/pp5p/3p4/4pn2/P7/1P2P1pP/2rP1P2/R1B3RK, f2g3
Output: 3kBb1r/pp5p/3p4/4pn2/P7/1P2P2P/2rP4/R1B3RK

(stolen from http://en.lichess.org/ocoSfS5I/white#36)

Input: rnbqk1nr/1pp5/p2pp1pp/5p2/1bN5/2P1PQ1N/PP1P1PPP/R1B1KB1R, f3b7
Output: 3qk1nr/2p5/p2pp1pp/5p2/1bN5/2P1P2N/PP1P1PPP/R1B1KB1R

(stolen from http://en.lichess.org/NCUnA6LV/white#14)

Input: rnbqk2r/pp2p2p/2p3pb/3pP3/5P2/2N5/PPPP2P1/R1BQKB1R, e5d6
Output: rnbqk2r/pp2p2p/2p3pb/8/5P2/2N5/PPPP2P1/R1BQKB1R

(stolen from http://en.lichess.org/AvgU4Skq/white#16; this wasn't the actual
move, but I couldn't be bothered to find an atomic game that actually had en
passant :P)

Input: 5r2/2k5/p1B5/1pP1p3/1P4P1/3P4/P7/1K3R1q, c6h1
Output: 5r2/2k5/p7/1pP1p3/1P4P1/3P4/P7/1K3R2

(stolen from http://en.lichess.org/l77efXEb/white#58)

Scoring

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

JavaScript (ES6) 305 310 321

As a function with 2 real parameters (and a lot more with default values, used as a quick and dirty way to define locals)

Test running the snippet below (being EcmaScript 6, Firefox only)

F=(g,m,b=[...g.replace(/\d/g,c=>'0'.repeat(c))],P=p=>p=='p'|p=='P',n=parseInt(m,32),
  s=n>>5&31,u=n>>15,x=b[y=u+62-(n>>10&31)*9])=>(
  b[b[y]=0,z=s+62-(n&31)*9]<1&!(s!=u&P(x))?b[z]=x:
  [-1,1,8,9,10,-8,-9,-10].map(i=>b[i+=z]>'/'&&!P(b[i])?b[i]=0:0,b[b[z]<1?z>y?z-9:z+9:z]=0),
  b.join('').replace(/0+/g,x=>x.length)
)

//TEST
out=x=>O.innerHTML+=x+'\n'

test=[
 ['rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR', 'g1f3'
  ,'rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R']
,['3kBb1r/pp5p/3p4/4pn2/P7/1P2P1pP/2rP1P2/R1B3RK', 'f2g3'
  ,'3kBb1r/pp5p/3p4/4pn2/P7/1P2P2P/2rP4/R1B3RK']
,['rnbqk1nr/1pp5/p2pp1pp/5p2/1bN5/2P1PQ1N/PP1P1PPP/R1B1KB1R', 'f3b7'
  ,'3qk1nr/2p5/p2pp1pp/5p2/1bN5/2P1P2N/PP1P1PPP/R1B1KB1R']
,['rnbqk2r/pp2p2p/2p3pb/3pP3/5P2/2N5/PPPP2P1/R1BQKB1R', 'e5d6'
  ,'rnbqk2r/pp2p2p/2p3pb/8/5P2/2N5/PPPP2P1/R1BQKB1R']
,['5r2/2k5/p1B5/1pP1p3/1P4P1/3P4/P7/1K3R1q', 'c6h1'
  ,'5r2/2k5/p7/1pP1p3/1P4P1/3P4/P7/1K3R2']
]

test.forEach(t=>(
  r=F(t[0],t[1]),
  out('Test '+(r==t[2]?'Ok':'Fail!')+'  '+t[0]+' move '+t[1]
     +'\nResult   '+r+'\nExpected '+t[2]+'\n')))

Ungolfed

B=(b,m)=>{
  P=p=>p=='p'|p=='P'
  m=parseInt(m,32)
  r=m&31 // arrival row
  s=(m/32&31)-10 // arrival column
  z=s+(8-r)*9 // arrival position
  t=m/32/32&31 // start row
  u=(m/32/32/32&31)-10 // start column
  y=u+(8-t)*9 // start position
  b=[...b.replace(/\d/g,c=>'0'.repeat(c))] // board to array, empty squares as 0
  x=b[y] // moving piece
  b[y]=0
  C=s!=u&P(x) // pawn capture
  if (b[z]<1 && !C)
  {  // no capture
    b[z]=x
  }
  else
  {
    // capture and boom!
    if (b[z]<1) // arrival empty: en passant
      b[z>y?z-9:z+9]=0;
    else
      b[z]=0;
    // zero to nearest 8 squares
    [-1,1,8,9,10,-8,-9,-10].forEach(i=>b[i+=z]>'/'&&!P(b[i])?b[i]=0:0)
  }
  return b.join('').replace(/0+/g,x=>x.length)
}


GET your dubs together On 4chan, a popular game is get. Every post on the site gets a sequential post ID. Since you can't influence or determine them, people try to guess (at least a part of) their own post number, usually the first few digits. Another version of the game is called dubs, and it's goal is to get repeating digits at the end of the number (i.e 1234555).
Your task, if you wish to accept it, is to write a program that takes a post id as input (standard integer, you can assume below 2^32), and returns how many repeating digits are on the end.
Rules

Standard loopholes are disallowed.
The program can be a function, full program, REPL command, whatever works, really, as long as no external uncounted code/arguments are needed to run it.
Input can come from STDIN, function arguments, command line argument, file, whatever suits you.

Test Cases
Input: 14892093
Output: 1

Input: 12344444
Output: 5

Input: 112311
Output: 2

Input: 888888
Output: 6

Input: 135866667 //Post number I got on /pol/ few days ago, rip
Output: 1

Mathematica, 29 bytes

How about an arithmetic solution?

IntegerExponent[9#+#~Mod~10]&

I'm very pleased to see that this beats the straight-forward Mathematica approach.

Explanation

The code itself computes 9*n + n%10 and then finds the largest power of 10 that divides the input, or in other words, counts the trailing zeros. We need to show if n ends in k repeated digits, that 9*n + n%10 has k trailing zeros.

Rep-digits are most easily expressed mathematically by dividing a number like 99999 (which is 105-1) by 9 and then multiplying by the repeated digit. So we can write n = m*10k + d*(10k-1)/9, where m ≢ d (mod 10), to ensure that n doesn't end in more than k repeated digits. Note that d = n%10.

Let's plug that into our formula 9*n + n%10. We get 9*m*10k + d*(10k-1) + d. The d at the end is cancelled, so we're left with: 9*m*10k + d*10k = (9*m + d)*10k. But 9 ≡ -1 (mod 10), so 9*m + d ≡ d - m (mod 10). But we've asserted that m ≢ d (mod 10) and hence d - m ≢ 0 (mod 10).

In other words, we've shown that 9*m + d is not divisible by 10 and therefore, the largest power of 10 that divides 9*n + n%10 = (9*m + d)*10k is k, the number of trailing repeated digits.

As a bonus, this solution prints the correct result, ∞, for input 0.


Is it a uniform polyhedron? Objective
Given a vertex figure consisting of regular convex polygons, determine whether it represents a convex uniform polyhedron.
What is a uniform polyhedron?
A uniform polyhedron is a polyhedron whose faces are regular polygons, while having the same vertex figure for each vertices. Generally a uniform polyhedron can be nonconvex, but only convex polyhedra will be considered in this challenge. (More precisely, the polyhedron is required to be vertex-transitive, but that's just another detail.)
What is a vertex figure?
In the context of a convex uniform polyhedron, a vertex figure is a list of the number of edges of polygons (in order) around a vertex. For example, a cube has vertex figure of (4.4.4).
Truthy inputs

(3.3.3) – Tetrahedron
(4.4.4) – Cube
(3.3.3.3) – Octahedron
(5.5.5) – Dodecahedron
(3.3.3.3.3) – Icosahedron
(4.4.N) for every N≥3 – N-gonal prism (It is a cube for N=4)
(3.3.3.N) for every N≥4 – N-gonal antiprism (It is an octahedron for N=3)
(3.6.6) – Truncated tetrahedron
(3.4.3.4) – Cuboctahedron
(3.8.8) – Truncated cube
(4.6.6) – Truncated octahedron
(3.4.4.4) – Rhombicuboctahedron
(4.6.8) – Truncated cuboctahedron
(3.3.3.3.4) – Snub cube
(3.5.3.5) – Icosidodecahedron
(3.10.10) – Truncated dodecahedron
(5.6.6) – Truncated icosahedron
(3.4.5.4) – Rhombicosidodecahedron
(4.6.10) – Truncated icosidodecahedron
(3.3.3.3.5) – Snub dodecahedron

Rotations and reversions (generally, all dihedral permutations) of these lists are also truthy. For example, (4.6.8), (4.8.6), (6.4.8), (6.8.4), (8.4.6), (8.6.4) are all truthy.
Falsy examples

(3.3.3.3.3.3) – Triangular tiling; not a polyhedron.
(5.5.5.5) – Order-4 pentagonal (hyperbolic) tiling; not a polyhedron.
(3.3.4.4) – Cannot be uniform. Note that this is different from (3.4.3.4).

Don't care situations
An input is expected to have at least 3 entries, and to consist of integers that are at least 3. Otherwise, the challenge falls in don't care situation.

(5/2.5/2.5/2) – Great stellated dodecahedron; not convex.
(3.3) – Triangular dihedron; not Euclidean.
(2.2.2) – Triangular hosohedron; not Euclidean.
(3/2.3/2.3/2) – Retrograde tetrahedron.
(1)
(-3)
()

Python 3, 190 bytes

def f(F):s="".join(hex(k)[2]for k in F);F[1:]in[[4,4],[3]*3]or{s,s[::-1]}&{*"555 333 366 388 3aa 466 566 468 46a 3434 3444 3454 3535 33333 33334 33335".split()}and max(F)<16or f(F[1:]+F[:1])

Try it online!
Takes input as a list of integers representing the vertex figure. The function errors (RecursionError) if the vertex figure is not a uniform polyhedron, otherwise there is no error.
I tried several schemes of organizing the finite classes into a smart way that takes advantage of patterns, but hardcoding all possibilities reigned superior since it is a relatively small set.
Explanation
def f(F):
    # F is a rotation of the input vertex figure; initially is the input vertex figure
    # Convert to string for easier comparison later in the code
    s="".join(hex(k)[2]for k in F)
    # Test true if the permutation is N.4.4.4 or N.3.3.3
    (F[1:]in[[4,4],[3]*3]or
    # Test truthy if permutation (or its reverse) is in
    #   3.3.3, 3.6.6, 3.8.8, 3.10.10, 4.6.6, 5.6.6, 4.6.8, 4.6.10,
    #   3.3.3.N, 3.4.3.4, 3.4.4.4, 3.4.5.4, 3.5.3.5
    #   3.3.3.3.3, 3.3.3.3.4, 3.3.3.3.5
    {s,s[::-1]}&{*"555 333 366 388 3aa 466 566 468 46a 3434 3444 3454 3535 33333 33334 33335".split()}
    # Numbers greater than 15 would convert into the most-significant hexit when converted to a string,
    # causing 0x43 to match the same as 0x4,
    # so we need to check that none of this happened if we want a bugfree string search
    and max(F)<16
    # If we tested truthy, then terminate
    # Otherwise, recurse with the vertex figure cyclically rotated left one
    or f(F[1:]+F[:1]))


Print out a shape in printable ASCII art based on a specific number of sides provided by the user The Challenge:
Just as the title says, your challenge is to use the printable ASCII characters to create a program that prints out a random polygon in the terminal based on the number of sides, n provided by the user, where n is an integer in the range 3 -> 10 including 3 and 10, in as few bytes as possible.
For example:
If n = 4 it should print out a 4 sided shape. For instance, it may print out a square, like so:
 ______
|      |
|      |
|______|

However, if the program is called again with the same attribute of n=4, it should print out a different polygon based on the same number of sides. For instance, maybe a plain, old parallelogram this time, like so:
    ______________
   /             /
  /             /
 /_____________/

As another example, consider n=6. At least once, it should print out a 6-sided polygon, such as the convex hexagon shown below:
    ________
   /        \
  /          \
 /            \
 \            /
  \          /
   \________/

But another time, it should print out a visually different polygon with 6 sides, for instance, maybe a concave hexagon like the following:
________
\      /
 \    /
  \  /
  /  \
 /    \
/______\

Finally, as a last example, if n=3, it may print out an isosceles triangle:
    / \
   /   \
  /_____\

However, another call with the same attribute should print out another kind of triangle, maybe like the following right triangle:
    /|
   / |
  /__|

EDIT: To fulfill @CatsAreFluffy's request, here is an example of an ASCII nine-sided polygon:
    ___
   /   \
  /     \
 /       \
 \       /
  \     /
   \   /
   /   \
  /     \
 /       \
 \       /
  \     /
   \   /
    \ /
     v

NOTE: These are all just examples. Your polygons can be drawn in any style, as long as they meet the guidelines shown below.
Guidelines:

Each number of sides, from 3-10, should have at least 2 different shapes associated with it.

The program should print out a random shape from the shapes associated with each number of sides each time the program is executed with a specific number of visually distinguishable sides in the range 3 -> 10 given as an argument.

The sides of the each polygon can be any length, such that every shape able to be drawn by the entire program has at least one side with the same length as all the others. For instance, a triangle should have at least one side with the same length as one of the sides of a parallelogram. So should the square, pentagons, rectangles, etc. with the parallelogram, and also with each other. As a reference, in the examples given in the challenge sections, each shape has at least one side with a length of 3 slashes.

Standard loopholes apply.

Java, 1887 1866 bytes
Try in on Ideone
Saved 21 bytes due to unneeded "public" headers (Thanks to @Bálint!)
Not exactly a golfing challenge, but hey, why not?
I feel Java might actually be the best language for this challenge because no esolang could handle this, and many others don't have as good list manipulation (although Java's takes way more bytes).
Golfed:
import java.util.*;public class A{public static void main(String[]args){System.out.print((new P()).b(Integer.parseInt((new Scanner(System.in)).next())).s());}}class P{S p;public S b(int w){p=new S(w);int j=-1,k=-1,f=(w%2)*2,t,y,x;for(x=0;x<w/2-2+w%2;x++){t=r();y=r();if(j==t|k==y|t==y){x--;continue;}g(t,true,2);g(y,false,2-f);f=0;j=t;k=y;}while(1>0){t=r();y=r();if(w<4&t<1&y<1)continue;if(j==t|k==y|t==y|j==y){x--;continue;}g(t,true,3);g(y,false,3+(w<4?0:(w%2)*2));break;}return p;}void g(int w,boolean b,int h){if(w<1)p.u(h,b);else if(w<2)p.r(h,b);else p.l(h,b);}int r(){return (int)(Math.random()*3);}}class S{List<List<Character>>q,a;int h,s,u,o,e,r,b,t,g,n,m,x,y;public S(int d){s=d;h=s+s%2-1;u=h;o=h;b=s>3?(int)(Math.random()*3*s)+1:0;q=new ArrayList<List<Character>>();a=new ArrayList<List<Character>>();for(x=0;x<h;x++){q.add(new ArrayList<Character>());a.add(new ArrayList<Character>());}i(0,q);i(0,a);e=1;r=1;t=0;g=0;n=0;m=0;}public String s(){String p="";for(x=0;x<e+b+r;x++)p+=x>t+(s<4?1:0)&x<e+b+g?'_':' ';p+="\n";for(y=0;y<h;y++){for(x=0;x<e;x++)p+=y>h-2&x>n?'_':q.get(y).get(x);for(x=0;x<b;x++)p+=y>h-2?'_':' ';for(x=0;x<r;x++)p+=y>h-2&x<m-1?'_':a.get(y).get(x);p+="\n";}return p;}void i(int i,List<List<Character>>z){for(List<Character>l:z)l.add(i,' ');if(z==q){e++;if(i<=t)t++;if(i<=n)n++;}else{r++;if(i<=g)g++;if(i<=m)m++;}}void u(int v,boolean i){if(i){u-=v;for(y=0;y<v;)q.get(u+y++).set(t,'|');}else{o-=v;for(y=0;y<v;)a.get(o+y++).set(g,'|');}}void l(int v, boolean i){if(i){x=v-t;while(x-->0)i(0,q);t=x>0?0:t-v;u-=v;for(y=0;y<v;)q.get(y+u).set(t+y++,'\\');}else{x=v-g;while(x-->0)i(0,a);g=x>0?0:g-v;o-=v;for(y=0;y<v;)a.get(y+o).set(g+y++,'\\');}}void r(int v,boolean i){if(i){t+=v;y=t;while(e<=y)i(e,q);t=y-1;u-=v;for(y=0;y<v;)q.get(u+y).set(t-y++,'/');}else{g+=v;y=g;while(r<=y)i(r,a);g=v<1?g:y-1;o-=v;for(y=0;y<v;)a.get(o+y).set(g-y++,'/');}}}

Must be in file called A.java (for obvious reasons). To run:

In the terminal, type javac A.java
Then, if it gives you no errors, type java A
Finally, type the number of sides. This program actually supports side lengths up to 65536

As you can see in the example output below, the corners tend to be more open, and the sides not as smooth, as compared to the polygons in the examples. Also, it cannot produce a square, but still follows the official guidelines. If there are any problems I can change the answer to fix them.
Sample output:
3

  / |
 /  |
/___|

4
   ____
  /    \
 /      \
/________\

5
   _________
  /         |
 /          |
/           |
\           |
 \ _________|

6
  ____________
 |            \
 |             \
 |              \
 /               |
/_______________ |

7
 _____________________
\                     /
 \                   /
  \                 /
   |               /
   |              /
   \              \
    \ _____________\

8
 _______________
\               /
 \             /
  \           /
   |          \
   |           \
   /            |
  /____________ |

9
 __________
\          /
 \        /
  \      /
   |    /
   |   /
   /   \
  /     \
  |      |
  |_____ |

10
   ____
  /    \
 /      \
/        \
|         /
|        /
\        |
 \       |
  /      \
 /________\

EDIT: Finally! the ungolfed code is here! It's a bit long, but you probably already guessed that...
I will get to the explanation soon.
import java.util.*;
public class ASCII_Polygon_Driver
{
   public static void main(String[] args)
   {
      System.out.print(P.b(Integer.parseInt((new Scanner(System.in)).next())));
   }
}
class P
{
   static S p;
   public static S b(int w)
   {
      p = new S(w);
      int l1=-1,l2=-1,f=(w%2)*2,r1,r2,x;
      for(x=0;x<w/2-2+w%2;x++)
      {
         r1=r();
         r2=r();
         if(l1==r1){x--;continue;}
         if(l2==r2){x--;continue;}
         if(r1==r2){x--;continue;}
         g(r1,true,2);
         g(r2,false,2-f);
         f=0;
         l1=r1;
         l2=r2;
      }
      while(true)
      {
         r1=r();
         r2=r();
         if(w<4&r1<1&r2<1)continue;
         if(l1==r1|l2==r2|r1==r2|l1==r2){x--;continue;}
         g(r1,true,3);
         g(r2,false,3+(w<4?0:(w%2)*2));
         break;
      }
      return p;
   }
   static void g(int w,boolean b,int h)
   {
      if(w<1)p.goUp(h,b);
      else if(w<2)p.goRight(h,b);
      else p.goLeft(h,b);
   }
   static int r()
   {
      return (int)(Math.random()*3);
   }
}
class S
{
   public List<List<Character>> area1;
   public List<List<Character>> area2;
   private int wid1;
   private int wid2;
   private int spcb;
   public int hght;
   private int top1;
   private int top2;
   private int bot1;
   private int bot2;
   private int mid1;
   private int mid2;
   public int sides;
   private int x;
   private int y;
   public int y1;
   public int y2;
   public S(int numSides)
   {
      sides = numSides;
      hght = sides+sides%2-1;
      y1=hght;
      y2=hght;
      spcb = sides>3?(int)(Math.random()*3*sides)+1:0;
      area1 = new ArrayList<List<Character>>();
      area2 = new ArrayList<List<Character>>();
      for(x=0;x<hght;x++)
      {
         area1.add(new ArrayList<Character>());
         area2.add(new ArrayList<Character>());
      }
      insertCollum1(0);
      insertCollum2(0);
      wid1 = 1;
      wid2 = 1;
      top1 = 0;
      top2 = 0;
      bot1 = 0;
      bot2 = 0;
   }
   public String toString()
   {
      String out ="";

      for(x=0; x<wid1+spcb+wid2; x++)
      {
         out+=x>top1+1&x<wid1+spcb+top2?'_':' ';
      }
      out+="\n";
      for(y=0; y<hght; y++)
      {
         for(x=0; x<wid1; x++)out+=y>hght-2&x>bot1?'_':area1.get(y).get(x);
         for(x=0; x<spcb; x++)out+=y>hght-2?'_':' ';
         for(x=0; x<wid2; x++)out+=y>hght-2&x<bot2-1?'_':area2.get(y).get(x);
         out+="\n";
      }
      return out;
   }
   private void insertCollum1(int index)
   {
      for(List<Character> line : area1)
      {
         line.add(index,' ');
      }
      wid1++;
      if(index<=top1)top1++;
      if(index<=bot1)bot1++;
   }
   private void insertCollum2(int index)
   {
      for(List<Character> line : area2)
      {
         line.add(index,' ');
      }
      wid2++;
      if(index<=top2)top2++;
      if(index<=bot2)bot2++;
   }
   /*private void setChar1(int x, int y, char character, List<List<Character>> which)
   {
      which.get(y).set(x,character);
   }*/
   public void goUp(int howMany, boolean is1)
   {
      if(is1)
      {
         y1-=howMany;
         for(y=0;y<howMany;)
         {
            area1.get(y1+y++).set(top1,'|');
         }
      }
      else
      {
         y2-=howMany;
         for(y=0;y<howMany;)
         {
            area2.get(y2+y++).set(top2,'|');
         }
      }
   }
   public void goLeft(int howMany, boolean is1)
   {
      if(is1)
      {
         x = howMany-top1;
         while(x-->0)insertCollum1(0);
         top1 = Math.max(0,top1-howMany);
         y1-=howMany;
         for(y=0;y<howMany;)
         {
            area1.get(y+y1).set(top1+y++,'\\');
         }
      }
      else
      {
         x = howMany-top2;
         while(x-->0)insertCollum2(0);
         top2 = Math.max(0,top2-howMany);
         y2-=howMany;
         for(y=0;y<howMany;)
         {
            area2.get(y+y2).set(top2+y++,'\\');
         }
      }
   }
   public void goRight(int howMany,boolean is1)
   {
      if(is1)
      {
         top1+=howMany;
         y=top1;
         while(wid1<=y)insertCollum1(wid1);
         top1=y-1;
         y1-=howMany;
         for(y=0;y<howMany;)
         {
            area1.get(y1+y).set(top1-y++,'/');
         }
      }
      else
      {
         top2+=howMany;
         y=top2;
         while(wid2<=y)insertCollum2(wid2);
         top2=howMany<1?top2:y-1;
         y2-=howMany;
         for(y=0;y<howMany;)
         {
            area2.get(y2+y).set(top2-y++,'/');
         }
      }
   }
}


Animations with all colours Last year, there was a very popular challenge to create an image containing every 24-bit RGB colour.

My challenge is to create a smooth animation (24 frames/s say), where the colour of every pixel of every frame is unique.  I will also allow duplication of colours as long as every colour appears the same number of times (greater than 0), since otherwise the animation will have to be short, or the frames small.

I have produced some examples here, based on the winning solution to the 2d version.  Unfortunately, it seems you can't embed videos, so links will have to do.

Mathematica
This is a straightforward implementation with each rgb colour occupying an intersection in a 256 by 256 by 256 unit grid.
The jerkiness seems to be an artefact of the video, not an error in the data, which should be exact.
red values increase downwards, green values increase rightwards, and blue values increase by frame.
Perhaps I'll jumble things up later.
f@b_ := Image@Table[{r, g, b}/255, {r, 0, 255}, {g, 0, 255}]
Export["c.mov", Table[f@b, {b, 0, 255}]]

QuickTime clip


What is the standard scratch? In golf, the standard scratch of a course is calculated using this formula:

(3*num_of_3_par_holes + 4*num_of_4_par_holes + 5*num_of_5_par_holes) - difficulty_rating

Your task is to calculate the standard scratch of a golf course, given these 4 inputs.

You should take input in any standard form in the format

[num_of_3_pars, num_of_4_pars, num_of_5_pars], difficulty rating

but if it saves bytes, you many take input in a different way.

You should output the final result by any accepted method on meta, such as returning from a function.

Shortest code wins because this is code-golf!

Scratch, 145 bytes

-2 thanks to boboquack
-??? because writing it in Oto is shorter than English

(Because Scratch is the standard scratch.)

Here's a sample run:

.


Sort odd numbers first Rearrange a given list such that all the odd numbers appear before all the even numbers. Besides for this requirement, the output list may be in any order.
The input will only contain integers, but they may be negative and there may be duplicates, and they may appear in any order.
Shortest solution wins.
Test cases
[1,2] → [1,2]
[2,1] → [1,2]
[1,0,0] → [1,0,0]
[0,0,-1] → [-1,0,0]
[3,4,3] → [3,3,4]
[-4,3,3] → [3,3,-4]
[2,2,2,3] → [3,2,2,2]
[3,2,2,2,1,2] → [1,3,2,2,2,2] or [3,1,2,2,2,2]
[-2,-2,-2,-1,-2,-3] → [-1,-3,-2,-2,-2,-2,] or [-3,-1,-2,-2,-2,-2,]
[] → []


Good Old Suffix Vector Inspired by an old manual...

The challenge

I define the ath suffix vector of b as the boolean list of length a with b trailing truthy values.

Write a program or function that, given a and b by any means, returns the ath suffix vector of b by any means.

Now this may seem trivial, but here is the catch: Your score is the byte count plus the earliest year your solution would have worked.

Rules

All standard rules apply, except that languages and language versions that were released after this challenge, may also be used.

Output using whatever representation of boolean values that your language uses, e.g. 1/0, True/False, TRUE/FALSE, "True"/"False", etc.

Output using whatever representation of lists that your language uses, e.g. 0 0 1, [False,False,True], (FALSE;FALSE;TRUE), {"False","False","True"}, etc.

You may assume that a ≥ b is always true and that they are of an appropriate data type.

Test cases

Given a = 7 and b = 3, return 0 0 0 0 1 1 1

Given a = 4 and b = 4, return [True,True,True,True]

Given a = 2 and b = 0, return (FALSE;FALSE)

Given a = 0 and b = 0, return {}

Example solution and scoring

I might want to submit the solution {⌽⍺↑⍵⍴1} using Dyalog APL. That would be a bytecount of 8. This is a dynamic function, which works from version 8.1 of Dyalog APL, released in 1998, so my total score is 2006. My submitted answer should look something like:

# Dyalog APL 8.1, 1998 + 8 = 2006
    {⌽⍺↑⍵⍴1}

Optional explanation...
Recommended: Link to documentation showing when the features you used were released.

Lowest score wins!


Is this a rectangle? The challenge:

Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.

Rules:

For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted as rectangles
Coordinates for rectangles can be given in any order, for example this:

A----B
|    |
D----C

and this:

A---B
|   |
|   |
|   |
C---D

are both rectangles.

Rectangles can be rotated, so they won't always be parallel to x and y axis.
You may take input in any form you like as long as the order for each coordinate is not mixed: [x,x,x,x,y,y,y,y] is not acceptable, where as [x,y,x,y,x,y,x,y] or [(x,y),(x,y),(x,y),(x,y)] is fine.
Complex numbers are a valid form of input
This is codegolf, so lowest byte count wins.

Test cases:

[0,2, 3,2, 3,0, 0,0]      Truthy
[3,5, 2,0, 0,2, 5,3]      Truthy
[6,3, 3,5, 0,2, 3,0]      Falsy
[1,4, 5,2, 4,0, 0,2]      Truthy
[0,0, 0,0, 3,2, 4,0]      Falsy
[1,1, 1,1, 1,1, 1,1]      Truthy
[1,4, 100,1, 100,1, 1,4]  Truthy

Python 3, 88 \$\cdots\$ 54 43 bytes

lambda l:len({abs(sum(l)/4-z)for z in l})<2

Try it online!

How

Calculates the distances from the quadrilateral's centre of mass to all of its vertices and tests if they're equal.

Input The four vertices as a sequence of complex numbers in any order.
Output True/False


Discrete Convolution or Polynomial Multiplication Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, the convolution of the two lists represents the coefficients of the product of the two polynomials.
Definition
Given the lists A=[a(0),a(1),a(2),...,a(n)] and B=[b(0),b(1),b(2),...,b(m)] (setting a(k)=0 for k<0 and k>n and b(k)=0 for k<0 and k>m) then the convolution of the two is defined as A*B=[c(0),c(1),...,c(m+n)] where c(k) = sum [ a(x)*b(y) for all integers x y such that x+y=k]
Rules

Any convenient input and output formatting for your language is allowed.
Built-ins for convolution, creating convolution matrices, correlation and polynomial multiplication are not allowed.

Examples
[1,1]*[1] = [1,1]
[1,1]*[1,1] = [1,2,1]
[1,1]*[1,2,1] = [1,3,3,1]
[1,1]*[1,3,3,1] = [1,4,6,4,1]
[1,1]*[1,4,6,4,1] = [1,5,10,10,5,1]

[1,-1]*[1,1,1,1,1] = [1,0,0,0,0,-1]
[80085,1337]*[-24319,406] = [-1947587115,7,542822]

J, 10 8 bytes

[:+//.*/

Usage:

ppc =: [:+//.*/    NB. polynomial product coefficients
80085 1337 ppc _24319 406
_1947587115 7 542822

Description: The program takes takes two lists, makes a multiplication table, then adds the numbers on the positive diagonals.


Roguelike pathfinding Roguelike pathfinding

Your task will be, given a two-dimensional array of the elements described below, which represents a dungeon, to output or return a single number representing the amount of gold pieces the rogue can collect without waking up any monsters.

The elements of the array are as follows:

Empty spaces are represented by either . or a space, your call;
Rogue's starting position is represented by, of course, @;
A gold piece is represented by $;
Walls are represented by #;
Monsters are represented by characters from the following regexp: [a-zA-Z*&].

The array shall not contain any characters not listed above, so you can assume that anything that is not a wall, an empty space, the rogue or a gold piece is a monster.

The rules for pathfinding are:

The rogue can only walk through empty cells or cells containing gold;
It takes a turn to move to a adjacent or diagonally adjacent cell;
Picking up the gold is instant;
The rogue can't stay adjacent or diagonally adjacent to a monster for more than one turn without waking it up, which is forbidden;
The rogue can enter the awareness area of a monster any number of times, the monster will only wake up if the rogue spends two consecutive turns near it.

Input and output rules

You can get the input in any reasonable format, including a two-dimensional array, a flat array, a string or whatever else. If it makes your life easier, you may also take the dimensions of the array as well.

It's guaranteed that the rogue will not be near a monster at the beginning.

A full program or a function is fine.

Scoring

This is code-golf, the score is the bytes count of your submission with fewer being better.

Test cases

I use dots for empty spaces here for readability purposes, if you so desire you may use spaces (see above). Also note that this is a pure coincidence that the rogue is always in the upper-left corner, your code should handle any other valid position as well.

1)
@..
.$.
...  -> 1

Just a sanity test.

2)
@....
...g$
.....  -> 0

Again, a sanity test.

3)
@....
...$g
.....  -> 1

The rogue can grab the gold by moving in from the left.

4)
@....g..
.......$
........
.....h..  -> 1

The rogue can zig-zag between the monsters, never staying for more than one turn near each.

5)
@....z..
.......$
.....b..  -> 0

The tactics from the previous test case don't work here - the monster sensitivity areas overlap.

6)
@$#.
###$
....  -> 1

Sanity test.

7)
@..#..
$.$g.$
...#..  -> 2

Ditto.

8)
@#.d#$
$...##
e.....
..$...
##..$b
.#..g$  -> 3

Of all the gold here, only three can be reached safely: the gold near the starting position can be got by moving down one and then back to the starting position. To escape from the top left corner the rogue has to move diagonally down-right twice. The gold in the middle poses no challenge. The outer gold guarded by g and b can be got by moving in diagonally from the place to the right of the middle gold and then back. The rest cannot be got: top-right gold is blocked by walls, and the bottom-right gold requires two turns in monster sensitivity areas.

The following test cases were generously donated by mbomb007.

9)
  12345678
a @....g.D
b .......$
c ......#.
d .....h..  -> 1

This one is tricky. A path is b4-b5-c6-b7-c8-b8(grab).

10)
  12345678
a @....g.D
b .......$
c .......#
d .....h..  -> 1

A path is [bc]4-c5-b6-c7-b8(grab).

11)
  12345678
a @....g.D
b ......#$
c .......#
d .....h..  -> 1

The extra wall doesn't actually change anything, [bc]4-c5-b6-c7-b8(grab) is still a solution.

previous solutions (part of them) can be found in the footer container in the tio link (those are probably more readable)

JavaScript (Node.js),883 436 411 360,345 311 bytes

g=>g.map((r,y)=>[...r].map((c,x)=>A+=c=="$"&&P(g,x,y)),A=0)|A
P=(g,x,y,m={},p={},I=i=9,M={})=>{if(/[.$]/.test(c=(g[y]||0)[x])){for(;i--;)if(/^[^.@$#]$/.test(C=(g[y+~-(i/3)]||0)[x+i%3-1])){if(m[C])return
M[C]=1}for(;I--;)if(!p[(X=x+~-(I/3))+","+(Y=y+I%3-1)]&&P(g,X,Y,M,{...p,[x+","+y]:1}))return 1}return c=="@"}

Try it online!

Explantion -

instead of going from the player to the cash i went from the case to the @. i think i should be faster because i know when to stop looking (reach the @) , and when you look for cash you need to always keep moving until you covered all of the spots (and the ways to get to them). so the algo is pretty simple that way - the main function
g.map((r,y)=>[...r].map((c,x)=>A+=c=="$"&&P(g,x,y)),A=0)|A:
find cash -> if you found it -> start looking for the player -> if you found him -> increment A
now lets got to the path finder aka P
if(/[.$]/.test(c=(g[y]||[])[x])) just check if the current cell is "special" -> if so we want to return if its a player. special cases : @#(monster)

for(;i--;)
if(/^[a-zA-Z*&]$/.test(C=(g[y+~-(i/3)]||0)[x+i%3-1])) -> if my neighbor is a monster
{if(m[C])return false -> and it already was in the previous turn - this path is not value
M[C]=1} -> if not just add it to the neighbors monsters
for(;I--;)
if(!p[(X=x+~-(I / 3))+","+(Y=y+I%3-1)]&&P(g,X,Y,M,{...p,[x+","+y]:1}))return true iterate neighbors again - if i wasn't already there (p is the path taken)
continue path (call P)


Decompose words into other words (e.g., “afterglow” = “aft” + “erg” + “low”) Here's one for all you wordsmiths out there! Write a program or function which takes a list of words and produces a list of all possible concatenative decompositions for each word. For example:

(Note: This is only a small sampling for illustrative purposes. Actual output is far more voluminous.)

afterglow = after + glow
afterglow = aft + erg + low
alienation = a + lie + nation
alienation = a + lien + at + i + on
alienation = a + lien + at + ion
alienation = alien + at + i + on
alienation = alien + at + ion
archer = arc + her
assassinate = ass + as + sin + ate
assassinate = ass + ass + in + ate
assassinate = assassin + ate
backpedalled = back + pedal + led
backpedalled = back + pedalled
backpedalled = backpedal + led
goatskin = go + at + skin
goatskin = goat + skin
goatskin = goats + kin
hospitable = ho + spit + able
temporally = tempo + rally
windowed = win + do + wed
windowed = wind + owed
weatherproof = we + at + her + pro + of
yeasty = ye + a + sty

Ok, you get the idea. :-)

Rules

Use any programming language of your choosing. Shortest code by character count for each language wins. This means there is one winner for each language used. The overall winner will be simply the shortest code of all submitted.
The input list can be a text file, standard input, or any list structure your language provides (list, array, dictionary, set, etc.). The words can be English or any other natural language. (If the list is English words, you'll want to ignore or pre-filter-out single-letter items except for "a" and "i". Similarly, for other languages, you'll want to ignore nonsensical items if they appear in the file.)
The output list can be a text file, standard output, or any list structure your language uses.
You can use any input dictionary you like, but you'll probably want to use one that provides sensible words rather than one that provides too many obscure, arcane, or obnubilated words. This the file I used: The Corncob list of more than 58000 English words

Questions

This challenge is primarily about writing the code to accomplish the task, but it's also fun to comb through the results...

What subwords occur most commonly?
What word can be decomposed into the greatest number of subwords?
What word can be decomposed the most different ways?
What words are composed of the largest subwords?
What decompositions did you find that were the most amusing?

Python 186
a=open(raw_input()).read().split()
def W(r):
 if r:
    for i in range(1,len(r)+1):
     if r[:i]in a:
        for w in W(r[i:]):yield[r[:i]]+w
 else:yield[]
while 1:
 for f in W(raw_input()):print f

Not particularly efficient but actually not terrible slow. It just naively (I suppose it's possible, though I think unlikely that python does some clever optimizations) checks that sub-words are in the corncob dictionary and recursively finds as many words as it can. Of course this dictionary is pretty extensive and you could try one which doesn't include various abbreviations and acronyms (leading to things like bedridden: be dr id den). Also the linked dictionary did not seem to have 'A' or 'I' listed as words so I manually added them in.
Edit:
Now the first input is the filename of the dictionary to use, and every additional one is a word.


Say Hello to the Pioneers of Computer Science Choose your favorite famous computer scientist or computer science pioneer who was born in 1942 or earlier (as 1943 marks the start of the creation of the 'first' computer). They should have a Wikipedia page or other site that lists their birth year and tells how their accomplishments relate to computer science. You may choose the same as someone else but choosing someone new is encouraged.

Take a name they are commonly known by. This will most likely be their first and last name but it might include abbreviations or middle names if that is more common. For example, for Tony Hoare both Tony Hoare and C. A. R. Hoare would be acceptable.

All the characters in the name must be printable ASCII. If the name contains characters that aren't printable ASCII it's fine if you choose something approximate. e.g. Kurt Godel instead of Kurt Gödel.

Take the set of unique characters in the name (e.g. C. ARHoare) and shift them up the printable ASCII scale by the birth year of your scientist, looping around from ~ to space. (Basically add the birth year modulo 95.) This will give you a (most likely) new set of printable ASCII characters.

For example, C. A. R. Hoare was born in 1934, so shifting every character in C. ARHoare by 1934 (34 mod 95) characters gives ePBctj2$5(.

This Stack Snippet will do all the shifting for you:

function go() {var name = document.getElementById("name").value;var year = parseInt(document.getElementById("year").value);var unique = {};for (var i = 0; i < name.length; i++) { unique[name.charAt(i)] = true; } var result = ''; for (var char in unique) { result += String.fromCharCode((char.charCodeAt(0) - 32 + year) % 95 + 32); } document.getElementById("result").value = result; }
Name: <input type="text" id="name" value="C. A. R. Hoare">

Birth Year: <input type="text" id="year" value="1934">

<button type="button" onclick="go()">Ok</button>

Result: <input type="text" id="result" readonly>

Challenge

Using this set and only this set (no tabs, no newlines) of shifted printable ASCII characters, write a program that prints Hello, [name]! to stdout or closest alternative, where [name] is the same exact name you chose above and shifted to get your program characters. You may use multiple characters from the set or not use some at all. For example, the theoretical program PetBee($25 prints Hello, C. A. R. Hoare!.

Scoring

Your score is your code size in bytes times the number of unique characters in the name you choose. The lowest sore wins.

CJam, 230 117 115 114 113 110 107 106 bytes * 13 = 1378

23)3*c11(2#)c111(((c3*))))22 2*c32c23 3*c3))$(113))c1$)))2$)2$(32c3)))$(3)$))1($)1($)3))$)1($)1$(12$(((33c

Test it here.

I chose Edsger Dijkstra, born 1930, which gives me c#2&$1>b()* 3 (whom I really just chose because he was the first one I found whose name yielded useful characters for CJam; I've checked a dozen names since and none looked as promising).

The code basically just builds the ASCII codes using 1, 2, 3, *, # (exponentiation) and (, ) (decrement, increment) and converts them to a character with c. To save some characters I can sometimes copy an earlier character with $ (0$ copies the top stack element, 1$ copies the second-to-top stack element and so on).

Here is the breakdown of the code into characters (this is also runnable):

23)3*c    "(23+1)*3 -> 72 -> H";
11(2#)c   "(11-1)^2+1 -> 101 -> e";
111(((c   "111-3 -> 108 -> l";
3*)       "Turn l into string lll and split off the third l.";
)))       "l+3 -> o";
22 2*c    "22*2 -> 44 -> ,";
32c       "32 -> Space";
23 3*c    "23*3 -> 69 -> E";
3))$(     "e-1 -> d";
113))c    "113+2 -> 115 -> s";
1$)))     "d+3 -> g";
2$)       "d+1 -> e";
2$(       "s+1 -> r";
32c       "32 -> Space";
3)))$(    "E-1 -> D";
3)$))     "g+2 -> i";
1($)      "i+1 -> j";
1($)      "j+1 -> k";
3))$)     "r+1 -> s";
1($)      "s+1 -> t";
1$(       "s-1 -> r";
12$(((    "d-3 -> a";
33c       "33 -> !";


Count rotary dial pulses in a phone number (including letters) In your grandparents' day, dialing a phone number was done with a rotary dial like this:

To dial each digit, put your finger in the corresponding hole, pull it over to the finger stop, and release it.  A mechanism will cause the dial to spin back to its resting position, and the phone will disconnect and reconnect a circuit a specified number of times, making audible clicks.

Dialing the digit N requires N such “pulses”, except for N=0 which is ten pulses.

Rotary phones have the property that large digits (8, 9, 0) take longer to dial than small digits (1, 2, 3).  This was an important consideration in drawing up early area code maps, and why New York City with its heavy population (and phone line) density got 212 (only 5 pulses), while while 907 (26 pulses) went to sparsely-inhabited Alaska.  Of course, this all became irrelevant when touch-tone dialing became popular.

The challenge

Write, in as few bytes as possible, a program or function that takes as input a string (or sequence of characters) containing a telephone number, and outputs its number of rotary dial pulses.  These are to be counted as follows:

Digits

Digits 1-9 count as that number of pulses.
Digit 0 counts as 10 pulses.

Letters

Note that digits 2-9 on the dial have letters of the Latin alphabet associated with them.  These were originally intended for named exchanges, but were latter re-appropriated for phonewords, and for text message input systems.

You must support having letters in your phone numbers, using the E.161 assignment of letters to digits:

A, B, C = 2
D, E, F = 3
G, H, I = 4
J, K, L = 5
M, N, O = 6
P, Q, R, S = 7
T, U, V = 8
W, X, Y, Z = 9

You may assume that the input has already been case-folded, to either upper or lower case.

Other characters

You must allow arbitrary use of the characters ()+-./ and space as formatting separators.  You may chose to allow any non-alphanumeric character for this purpose, if it's easier to implement.

These characters do not contribute to the pulse count.

Example code

A non-golfed lookup table and function in Python:

PULSES = {
    '1': 1,
    '2': 2, 'A': 2, 'B': 2, 'C': 2,
    '3': 3, 'D': 3, 'E': 3, 'F': 3,
    '4': 4, 'G': 4, 'H': 4, 'I': 4,
    '5': 5, 'J': 5, 'K': 5, 'L': 5,
    '6': 6, 'M': 6, 'N': 6, 'O': 6,
    '7': 7, 'P': 7, 'Q': 7, 'R': 7, 'S': 7,
    '8': 8, 'T': 8, 'U': 8, 'V': 8,
    '9': 9, 'W': 9, 'X': 9, 'Y': 9, 'Z': 9,
    '0': 10
}

def pulse_count(phone_num):
    return sum(PULSES.get(digit, 0) for digit in phone_num)

Example input and output

911 → 11
867-5309 → 48
713 555 0123 → 42
+1 (212) PE6-5000 → 57
1-800-FLOWERS → 69
PUZZLES → 48

05AB1E, 19 18 17 15 bytes

AÁ0ªā6+žq÷9š‡þO

Try it online!

This is the first answer to use π. Why use π, you might ask? Well, the letters are associated with 22233344455566677778889999, in order. Notice how most digits repeat 3 times, but 7 repeats 4 times. You could say that each digit repeats (3+1/7) times, on average. I wonder if there’s any number that’s approximately 3+1/7 and takes fewer bytes than 22/7…

This only gives 4 7s, not 4 9s, so we still need to handle Z as a special case.

A               # alphabet (abcdefghijklmnopqrstuvwxyz)
 Á              # rotate right (zabcdefghijklmnopqrstuvwxy)
  0ª            # append 0 (zabcdefghijklmnopqrstuvwxy0)

ā6+             # range [7..33]
   žq÷          # divide by π (22233344455566677778889991010)
      9š        # prepend 9 (922233344455566677778889991010)

‡               # transliterate the implicit input with the two lists above
                # this replaces z → 9, a → 2, … y → 9, 0 → 10
 þ              # remove all non-digits
  O             # sum


Is it a lobster number? Introduction
A "lobster number", by my own designation, is a number that contains within itself all of its prime factors.  The "lobster" description was inspired by the recent question "Speed of Lobsters".  The basic idea is that each prime factor can be made by lobsters munching away digits of the number until you are left with just the factor.
Example: 51375 is a lobster number, since its prime factors are [3,5,137], which can be made by lobsters thusly: [***3*, 5**** / ****5, *137*].   Another lobster number is 62379, as the factors [3,29,239] can be formed as [**3**,*2**9,*23*9].
Challenge
Given a number as input, return whether it is a lobster number or not.  Preferentially this is a boolean output, such as 1 or 0, or True or False.
Astute readers may realize that prime numbers are a trivial solution to this requirement, but since they don't allow the lobsters to eat any digits, they are out. Your program must not identify prime numbers as lobster numbers.
This is similar to OEIS A035140, but has the additional requirement that each digit of the factor must appear at least the same number of times in the number, and in the correct order. In other words, 132 is not a lobster number, since its factors are [2,3,11], and the 11 cannot be made by munching away at just 132.  312 is also not a lobster number, because its factors are [2,3,13], and 13 is out of order.
I believe the "mathematical" definition would be: "Determine if the number n is a composite number such that all prime factors of n are a subsequence of n".
Test Cases
59177  -> True
62379  -> True
7      -> False
121    -> True
187    -> False
312    -> False

As always, Standard Loopholes are forbidden.
Note:
It has come to my attention that the original reasoning I gave for not needing to handle 0 or 1 as input is faulty.  However, requiring the proper output at this point would invalidate a number of answers.  Therefore, let it hereby be known that neither 0 nor 1 are lobster numbers, but you also do not need to handle them as input (they are not valid test cases). If your code does handle them correctly, you may give yourself the Lobster Advocate Badge™.

Python 3, 155, 126, 124, 123, 120 116, 113 bytes

Yes! First python answer!
Saved 21 bytes due to a suggestion by Dominic van Essen to remove the for loop!
Saved 8 bytes because I realized I could use t*=True/False instead of t+=[True/False].
Saved another 2 bytes right after I finished editing because I realized t could simply be set to the same value as i and l!
Saved 1 byte based off Danis's python 2 comment.
Saved another 3 bytes based off Tipping Octopus's comment.
Saved another 4 bytes due to Tipping Octopus again!
Saved another 3 bytes thanks to Dominic's suggestion to remove the t variable.
New Answer
x=input()
n=int(x)
i=l=2
while~-n:
 if n%i:i+=1
 else:n//=i;l+=1;j=iter(x);l*=2*all(c in j for c in str(i))
print(l>4)

How it works
The while loop computes the prime factors of the input. If a prime factor is found, it checks if it is a subsequence of the input. l is multiplied by whether or not this is True. This takes advantage of the fact that python's True and False values act like 1s and 0s when you multiply by them. This means that instead of appending True/False to t and checking whether all(t) is True like in my old answer, I can just multiply l by 2*True/False and check its value in the print statement. The print statement prints True if l>4.
Try it online!
Old Answer
x=n=int(input())
l=[]
i=2
while i<=n:
 if n%i:i+=1
 else:n/=i;l+=[i]
t=[]
for p in l:i=iter(str(x));t+=[all(c in i for c in str(p))]
print(all(t)*len(l)>1)

Try it online!