APL (Dyalog Extended), 31 bytes

(⎕D,⎕A)⊃⍨⊃⎕⌽¯1⌽,⍉⎕(⊣⊤⍳⍤*~*-2⍨)⎕

Try it online!
A full program that takes numbers from stdin in the order of k, b, n. n being 1-based cost me 3 bytes ¯1⌽.
How it works
The main mathematical trick is well explained in Neil's answer. The gist is that the repeating part of the base-b representation consists of length-k base-b digits of 0..b^k-1, except b^k-2.
This answer implements it very literally: list all repeating base-b digits, cyclically fetch nth digit from it, and convert it to 0-9A-Z. Cyclic indexing uses ngn's trick.
⎕(...)⎕     ⍝ Take k (the right) and b (the left) from stdin
  ⍳⍤*~*-2⍨  ⍝ Create a list of 0..b^k-1, and remove the number b^k-2
  ⊣⊤        ⍝ Convert these numbers into base-b digits into columns
,⍉          ⍝ Transpose and flatten to get the repeating base-b digits
⊃⎕⌽¯1⌽      ⍝ Take n from stdin and get the nth digit cyclically
(⎕D,⎕A)⊃⍨   ⍝ Convert the number to the corresponding char in 0-9A-Z


V, 4 bytes

Î4É

Try it online!

(Note the trailing space)

V is encoded in Latin1, where this is encoded like so:

00000000: ce34 c920                                .4.

Explanation

Î            " On every line
 4É<space>   " Prepend 4 spaces

Here's a solution that is also 4 bytes in UTF-8!

VG4>

VG          " Select everything
   >        " Indent
  4         " 4 times (with spaces)


Python 2, 115 bytes

This assumes that a \$\star\$ exists iff \$N\$ is an integer power of 2, including 1. I don't have a proof for it, but it is evident from the first few cases (and @att noted it in comments).
N=input()
f=lambda p,q:f(f(p,q-1),(p+1)%N)if p*q else q
print([i for i in range(1,N)if N%i+f(1,i)<1]+[N])[:N&N-1<1]

Try it online
188 bytes without assuming the power-of-2 condition.
N=input()
f=lambda p,q:f(f(p,q-1),(p+1)%N)if p*q else q
print([i for i in range(1,N)if N%i+f(1,i)<1]+[N])[:all(f(i%N,f(i/N%N,i/N/N%N))==f(f(i%N,i/N%N),f(i%N,i/N/N%N))for i in range(N**3))]

Try it online! (N from 1 to 10, simulates STDIN)
The short, recursive approach is slow since it repeats computation of many entries, so I've made an iterative, memoized approach which is much faster (quadratic in N) and can compute up to N=4096 within 60 seconds on TIO. This reveals a bit of a pattern (two 2s, two 4s, four 8s, four (?) 16s, etc.), but this needs confirmation before working into an answer.
How it Works
The algorithm assumes that \$\star\$ is unique, if it exists (proof below). It uses recursion, setting
\$p\star q=\begin{cases}
q, &p=0 \\
p+1 \mod n, &q=1 \\
(p \star (q-1 \mod n))\star (p+1 \mod n), &\text{otherwise}
\end{cases}\$
The first case (\$p=0\$) is Lemma 1 in the uniqueness proof: \$0\star q=q\$.
The second case (\$q=1\$) is given.
The third case has a simple proof despite its complex self (assuming addition and subtraction are mod \$N\$:
\begin{align*}
&p \star q\\
=&p \star ((q-1)+1) \\
=&p \star ((q-1)\star 1) \\
=&(p \star (q-1))\star(p\star 1) \\
=&(p \star (q-1))\star(p+1)
\end{align*}
This is enough to determine the unique \$\star\$ (Rationalization to myself that the proof was necessary: It shows that the third case will not recurse indefinitely).
The period is the minimum \$i\$ such that \$1\star (i+1) = 1\star 1 = 2\$. If this \$i\$ doesn't divide \$N\$, then it is not a period.
Ungolfed code:
# f(p,q,N) = p⋆q
def f(p,q,N):
    if p==0:
        return q
    if q==1:
        return (p+1)%N
    return f(f(p,(q-1)%N,N),(p+1)%N, N)

def period(N):
    if any(f(p,f(q,r,N),N) != f(f(p,q,N),f(p,r,N),N) for p in range(N) for q in range(N) for r in range(N)):
        # The f does not exist
        return []
    for i in range(1, N):
        # period is i if f(1,i+1)=f(1,1)=2
        if f(1,i+1,N) == 2:
            # might not be divisible, in which case it is not the period
            if N%i:
                return [N]
            return [i]

This could be sped up immensely by memoization utilizing \$ a \star 2 = a \star (1 \star 1) = (a\star 1)\star (a\star 1) = (a+1)\star(a+1) \$ and \$1 \star a = (1\star (a-1))\star 2\$.
Proof of Uniqueness of \$\star\$
For this section, we assume all addition/subtraction is mod \$N\$.
Lemma 1: For all \$a\$, \$0 \star a = a\$
Proof: Induction
Base case: \$a=1\$. Given since \$0\star 1=1\$.
Step: Assume this lemma holds for \$a=k\$. Then \begin{align*}
&0 \star (k + 1)\\
=&  0\star (k\star 1) \\
=& (0\star k)\star (0\star 1) \\
=& k \star 1 \\
=& k+1,
\end{align*}
so this holds for \$a=k+1\$. Since this addition is mod \$N\$, this will "wrap around" back to \$0\$, so it applies for \$a=0\$ too, not just \$a\geq 1\$
Theorem: If an operation \$\star\$ is valid for a given \$N\$, then it the unique \$\star\$ that is valid for that \$N\$.
Proof: We use strong induction to show that, for all \$0\leq a,b\leq N-1\$, \$a\star b\$ is uniquely determined by \$N\$. In addition, for each \$a\$ and \$b\$ in the same set, either (1) \$a\star b=0\$ or (2) \$a<a\star b<N\$

Base case: \$a\star b\$ is uniquely determined and equal to \$0\$ for \$a=N-1\$ and for all \$b\$.
We prove this base case with induction too.

Base case: \$b=1\$. We are given \$a\star 1=a+1\$, so \$(N-1)\star 1=0\$, uniquely determined.
Step: Given \$(N-1)\star b=0\$ for \$b=k\$, then
\begin{align*}
      &(N-1)\star (b+1)\\
      =&(N-1)\star (b\star 1)\\
      =&((N-1)\star b)\star((N-1)\star 1)\\
      =&0\star0 \\
      =&0,
    \end{align*}
where we use Lemma 1 to show \$0\star 0=0\$,
so \$(N-1)\star b\$ is uniquely determiend to be \$0\$.

Assume \$a\star b\$ is uniquely determined and either (1) or (2) hold for all \$k<a\leq N-1\$ and for all \$b\$. Then for \$a=k\$, we will show \$a\star b\$ is uniquely determined and either (1) or (2) hold for all \$b\$, again with induction.

Base case: \$k\star b\$ is uniquely determined and either (1) or (2) hold for \$b=1\$. This is trivial since \$k\star 1=k+1>k\$, so \$k\star 1\$ is unique and (2) holds

Step: Assume \$k\star b\$ is uniquely determined and either (1) or (2) hold for \$b=j\$. Then:
\begin{align*}
      &k\star (b+1)\\
      =&k\star (b\star 1)\\
      =&(k\star b)\star(k\star 1)\\
      =&(k\star b)\star(k+1)
    \end{align*}
If (1) holds, then \$k\star b=0\$, so \$k\star(b+1)=k+1>k\$ by Lemma 1. Thus \$k\star(b+1)\$ is uniquely determined and satisfies (2).
If (2) holds, then \$k<k\star b\leq N-1\$,so by the outer inductive assumption, \$k\star(b+1)=(k\star b)\star (k+1)\$ is uniquely determined and either (1) or (2) holds for it.
In either case, \$k\star(b+1)\$ is uniquely determined and either (1) or (2) hold for it, completing the inductive step.


APL (Dyalog Unicode), 56 bytes

(,⊖⍣(?2)↑a(3+⍳3)(10-⌽a←3?3)){⍺ ⍺⌷9 9⍴∊⌽⍵∘.⌽⍵⊖¨⊂3 3⍴⍳9}⍳3

Try it online!

A full program that randomly gives a 9-by-9 matrix of digits.

By OP mentioning "it must be possible to obtain at least 9 structurally different boards", I believe it was to prevent using just trivial transformations like reflection and rotation. But there are more possible transformations than that. I use two kinds of transformations:

Permute R19C19, R28C28 and R37C37 (6 cases)

Example: Swap R19C19 and R28C28

a b c - - - A B C     e d f - - - D F E
d e f - - - D E F     b a c - - - A C B
g h j - - - G H J     h g j - - - G J H
- - - - - - - - -     - - - - - - - - -
- - - - - - - - - ==> - - - - - - - - -
- - - - - - - - -     - - - - - - - - -
k l m - - - K L M     l k m - - - K M L
n p q - - - N P Q     s r t - - - R T S
r s t - - - R S T     p n q - - - N Q P

Reverse the order of boxes in both dimensions (2 cases: reverse both or keep intact)

a b c - - - A B C     K L M - - - k l m
d e f - - - D E F     N P Q - - - n p q
g h j - - - G H J     R S T - - - r s t
- - - - - - - - -     - - - - - - - - -
- - - - - - - - - ==> - - - - - - - - -
- - - - - - - - -     - - - - - - - - -
k l m - - - K L M     A B C - - - a b c
n p q - - - N P Q     D E F - - - d e f
r s t - - - R S T     G H J - - - g h j

resulting in 12 structurally different boards. Note that, in both cases, the thing that changes on the diagonals is the order of the digits. Also, the center box is always intact, so no two boards are equivalent under transliteration.

Part 1: Construct a valid diagonal sudoku board

⍝ A 3x3 box of 1..9
⊂3 3⍴⍳9
┌─────┐
│1 2 3│
│4 5 6│
│7 8 9│
└─────┘

⍝ The box rotated upwards 1, 2, 3 times
(⍳3)⊖¨⊂3 3⍴⍳9
┌─────┬─────┬─────┐
│4 5 6│7 8 9│1 2 3│
│7 8 9│1 2 3│4 5 6│
│1 2 3│4 5 6│7 8 9│
└─────┴─────┴─────┘

⍝ The boxes rotated left 1, 2, 3 times
(⍳3)∘.⌽(⍳3)⊖¨⊂3 3⍴⍳9
┌─────┬─────┬─────┐
│5 6 4│8 9 7│2 3 1│
│8 9 7│2 3 1│5 6 4│
│2 3 1│5 6 4│8 9 7│
├─────┼─────┼─────┤
│6 4 5│9 7 8│3 1 2│
│9 7 8│3 1 2│6 4 5│
│3 1 2│6 4 5│9 7 8│
├─────┼─────┼─────┤
│4 5 6│7 8 9│1 2 3│
│7 8 9│1 2 3│4 5 6│
│1 2 3│4 5 6│7 8 9│
└─────┴─────┴─────┘

⍝ Horizontally reverse the boxes, keeping the contents inside the boxes
⌽(⍳3)∘.⌽(⍳3)⊖¨⊂3 3⍴⍳9
┌─────┬─────┬─────┐
│2 3 1│8 9 7│5 6 4│
│5 6 4│2 3 1│8 9 7│
│8 9 7│5 6 4│2 3 1│
├─────┼─────┼─────┤
│3 1 2│9 7 8│6 4 5│
│6 4 5│3 1 2│9 7 8│
│9 7 8│6 4 5│3 1 2│
├─────┼─────┼─────┤
│1 2 3│7 8 9│4 5 6│
│4 5 6│1 2 3│7 8 9│
│7 8 9│4 5 6│1 2 3│
└─────┴─────┴─────┘

⍝ Enlist the digits and reshape into 9x9 matrix
⍝ (Each box goes to each row)
9 9⍴∊⌽(⍳3)∘.⌽(⍳3)⊖¨⊂3 3⍴⍳9
2 3 1 5 6 4 8 9 7
8 9 7 2 3 1 5 6 4
5 6 4 8 9 7 2 3 1
3 1 2 6 4 5 9 7 8
9 7 8 3 1 2 6 4 5
6 4 5 9 7 8 3 1 2
1 2 3 4 5 6 7 8 9
7 8 9 1 2 3 4 5 6
4 5 6 7 8 9 1 2 3

Part 2: Generate permutation vector

,⊖⍣(?2)↑a(3+⍳3)(10-⌽a←3?3)
                    a←3?3   ⍝ Generate a permutation of 1 2 3
                            ⍝ ex) 2 3 1
        a(3+⍳3)(10-⌽a    )  ⍝ Permutation vector in chunks of 3
                            ⍝ ex) (2 3 1)(4 5 6)(9 7 8)
       ↑                    ⍝ Promote to matrix
 ⊖⍣(?2)                     ⍝ Reverse vertically 1 or 2 times
                            ⍝ ex) [9 7 8][4 5 6][2 3 1]
,                           ⍝ Flatten ex) 9 7 8 4 5 6 2 3 1

Part 3: Permute the rows and columns

⍝ Permute both rows and columns of the matrix through indexing function
perm perm⌷mat
⍝ Using the example permutation above, the sudoku board is:
3 1 2 7 8 9 5 6 4
9 7 8 4 5 6 2 3 1
6 4 5 1 2 3 8 9 7
8 9 7 6 4 5 1 2 3
5 6 4 3 1 2 7 8 9
2 3 1 9 7 8 4 5 6
4 5 6 2 3 1 9 7 8
1 2 3 8 9 7 6 4 5
7 8 9 5 6 4 3 1 2


05AB1E, Cracked by mbomb007
Hopefully fun to crack and not too obvious.
Regex (PCRE):
^\w*[+\-*\/%]*\w*.{0,2}$

Output n=4:
[[1, 2, 3, 4], [8, 7, 6, 5], [9, 10, 11, 12], [16, 15, 14, 13]]

Original solution
UXFXLNX*+NFR}ˆ


Jelly, 26 bytes

feels too long

DŒṖṖEÐƤḄ$ÐṀLÐṂṪµḢ*@0¦LµṪ⁼Ḍ

A monadic link taking an integer and returning 1 if the input is satisfying and 0 if not.

Try it online! or see a test-suite

How?

DŒṖṖEÐƤḄ$ÐṀLÐṂṪµḢ*@0¦LµṪ⁼Ḍ - Link: integer, n    e.g. 8300
D                          - to decimal list          [8,3,0,0]
 ŒṖ                        - all partitions           [[[8],[3],[0],[0]],[[8],[3],[0,0]],[[8],[3,0],[0]],[[8],[3,0,0]],[[8,3],[0],[0]],[[8,3],[0,0]],[[8,3,0],[0]],[[8,3,0,0]]]
   Ṗ                       - pop (the "no tail" one)  [[[8],[3],[0],[0]],[[8],[3],[0,0]],[[8],[3,0],[0]],[[8],[3,0,0]],[[8,3],[0],[0]],[[8,3],[0,0]],[[8,3,0],[0]]]
         ÐṀ                - keep maximal under the operation: e.g. for [[8,3],[0],[0]]
        $                  -   last two links as a monad:
     ÐƤ                    -     for suffixes:   i.e. [[[8,3],[0],[0]],[[0],[0]],[[0]]]
    E                      -       all equal?         [0              ,1        ,1]
       Ḅ                   -     convert from binary  3
                           -          ...which yields [[[8],[3],[0],[0]],[[8,3],[0],[0]]]
            ÐṂ             - keep minimal under the operation:
           L               -   length
                           -          ...which yields [[[8,3],[0],[0]]]
              Ṫ            - tail (rightmost)         [[8,3],[0],[0]]
               µ           - monadic chain separation
                Ḣ          - yield head and modify    [8,3]   ...leaving [[0],[0]]
                     L     - length (of modified)     2
                    ¦      - sparse application       (to the [8,3])
                   0       -   ...to index: 0         (to the rightmost digit, the 3)
                 *@        -   power (sw@p args)      [8,8]  ([8, 3*@2] = [8, 2*3] = [8,8])
                      µ    - monadic chain separation
                       Ṫ   - yield tail and modify    8   ...leaving [8]
                         Ḍ - from decimal (modified)  8
                        ⁼  - equal?                   1


Help the poor Cryptographers - DLP Edition

Cado-nfs is the right tool to use.

It provides abstract enough way of handling any case, but relies on input specific optimizations that cannot be done by the program anyway.

There is no general (applicable to anything with same efficiency) solution (even theoretical one) for NFS that can be implemented in program at the moment.

Judging by the work done in CADO-nfs, simply coming up with a good enough algorithm for just 100 digit number would take several months of research before any programming can be done.

You should ask around on CADO-nfs forums, there were at least couple of tests mentioning 103-104-digit algorithms, that might be more useful.

If nfs is not a strict requirement, you could mention it in question.
Sadly, I cannot comment yet; and no, I am far from specialist in any of the areas.


JavaScript (ES6),  178 169  168 bytes
Returns the \$n\$ first terms as an array.

n=>(X=[1],Y=[L=1],d=5,j=x=y=0,g=a=>--n?g([...a,(X[x+=~-'210012'[d%=6]]=-~X[x])+(Y[y+=~-'1221'[j?d:d++]]=-~Y[y])+(Z[x+y]=-~Z[x+y])-2],++j%L?0:(j%=L*6)?d++:L++):a)(Z=[1])

Try it online!
How?
This is a rather naive approach that actually computes the spiral with cube coordinates \$(x,y,x+y)\$ and keeps track of the number of cells on each row \$Z[x+y]\$, each diagonal \$Y[y]\$ and each anti-diagonal \$X[x]\$.
Commented
n => (                            // n = input
  X = [1], Y = [L = 1],           // X[] = anti-diagonals, Y[] = diagonals, L = layer
  d = 5,                          // d = direction in [0..5]
  j =                             // j = cell index in the current layer
  x = y = 0,                      // (x, y) = coordinates
  g = a =>                        // g = main recursive function taking the output a[]
    --n ?                         // decrement n; if we haven't computed enough terms:
      g(                          //   recursive call:
        [ ...a,                   //     append the previous terms
          ( X[x +=                //     update x and increment X[x]
              ~-'210012'[d %= 6]  //       pick dx according to d
            ] = -~X[x]            //
          ) +                     //
          ( Y[y +=                //     update y and increment Y[y]
              ~-'1221'[j ? d      //       pick dy according to d
                         : d++]   //       increment d afterwards if j = 0
            ] = -~Y[y]            //       (i.e. this is the 1st cell of the layer)
          ) +                     //
          (Z[x + y] = -~Z[x + y]) //     increment Z[x + y]
          - 2                     //     subtract 2 from X[x] + Y[y] + Z[z] because
        ],                        //     the current cell is counted three times
        ++j                       //     increment j
        % L ?                     //     if it's not the last cell of this side:
          0                       //       do nothing
        :                         //     else:
          (j %= L * 6) ?          //       if it's not the last cell of the layer:
            d++                   //         increment d
          :                       //       else:
            L++                   //         increment L
      )                           //   end of recursive call
    :                             // else:
      a                           //   we're done: return a[]
)(Z = [1])                        // initial call to g with a[] = Z[] = [1]


Match strings whose length is isolated prime

Perl, 54
/^(?!(..+)\1+$)(?=..(?:|(..+)\2+)$)(?=(..(.*))\4\3*$)/

I think this is not possible without the Perl look-ahead expression... Firstly, there is no positive regex to match the prime number. You can only match a non-prime by simulating multiplication: (..+)\1+. To negate it, I use negative look-ahead: /^(?!(..+)\1+$)/ matches prime numbers (neglecting the 0, 1 case).
The beauty of the look-ahead is that it is zero-width, i.e. eats no characters. This means you can actually AND those conditions! My regex is composed of 3 look-aheads, corresponding to AND-ing 3 conditions:

(?!(..+)\1+$) - N (length of the string) is the prime number
(?=..(?:|(..+)\2+)$) - N-2 is a non-prime - this is a trival modification of the basic non-prime expression - (..+)\1+) - just add two characters. The (?:|...) is included to also match an empty string (case N=2 should match too).
(?=(..(.*))\4\3*$) - N+2 is a non-prime - again, trivial modification of the basic non-prime expression - cut two characters out of one repetition.

Test:
$ perl -E'($"x$_)=~/^(?!(..+)\1+$)(?=..(?:|(..+)\2+)$)(?=(..(.*))\4\3*$)/&&say for(2..200)'
2
23
37
47
53
67
79
83
89
97
113
127
131
157
163
167
173


Python 2, 135 130 129 bytes

-1 byte thanks to Lynn

lambda s:cmp(*s)%2*s[::cmp(*s)|1]in'OIH TIE XI7 RF O8 OGC LI0 O3 O96 VA O6 KI PI WI L1 WMI O0 RIB NI1 FE SOC VID ZIFB1 PF LE1 RP'

Try it online!

Python 3, 143 bytes

lambda*i:any({*i}&{a,c}=={*i}for a,b in zip('CFGILMPSVW013689','GO BEPR O 017BDEFHKLMNOPRTVWXZ E W R O A M O BEL O 9O O 6O'.split())for c in b)

Try it online!


Compute the difference between two days.

Perl 5.14, score = -162
-163 -181 -196 -214 -167 -213 -234

code.length = 211: 208 source characters + 3 for running perl with the -p option
bonus = 5.5: default, order, year 0, never-valid month/day, invalid date, wholly-invalid input

Code
$_=eval(join'-',map{($y,$m,$d)=/(....)(..)(..)/;die"E\n"if!($m*$d)||$m>12||$d>30+($m&1^$m>7)-($m==2)*(2-!($y=~s/00$//r%4));$y-=($m<3)-400;$d+int(($m+9)%12*30.6+.4)+int(365.2425*$y)}/^(\d{8})[ ,-](\d{8})$/)//E

Calculates a modified Julian day number for each date (ignoring the epoch-related adjustments to save code length) and subtracts the two. (ref. "Julian Day" at Wikipedia).

requires perl 5.14+ for the /r option on the substitutions
month-length calculation to get the invalid date bonus: the 30+($m&1^$m>7) part gives the length of any month but February; the rest adjusts for February in an ordinary or leap year

Assumptions

"use Gregorian calendar" means the proleptic Gregorian calendar for dates before whichever Julian to Gregorian transition we're using.  That is, don't subtract 11 days for intervals that cross, for example, the 3 Sep 1752 - 14 Sep 1752 British transition.
"handle year 0" means, for example, 00000101-00010101 should give 366, as 0 is an integral multiple of 400, and so year 0 is a leap year.


MATL, 14 bytes
Thanks to Emigna for pointing out a mistake, now corrected
`yVdd~?yD]wy+T

Infinite loop that outputs the numbers as they are found.
Try it online! Note that in the online interpreter the results are displayed after the 1-minute time-out.
Explanation
Let F(n) and F(n+1) denote two generic consecutive terms of the Fibonacci sequence. Each iteration of the loop starts with the stack containing F(n), F(n+1) for some n.
`         % Do...while
  y       %   Duplicate from below. Takes the two inputs F(0), F(1) (implicitly)
          %   in the first iteration
          %   STACK: F(n), F(n+1), F(n)
  V       %   Convert to string. Let the digits of F(n) be '3579' for example
          %   STACK: F(n), F(n+1), '3579'
  d       %   Consecutive differences (of ASCII codes)
          %   STACK: F(n), F(n+1), [2 2 2]
  d       %   Consecutive differences
          %   STACK: F(n), F(n+1),  [0 0]
  ~       %   Logical negate, element-wise
          %   STACK: F(n), F(n+1), [1 1]
  ?       %   If top of the stack is non-empty and only contains non-zero entries
          %   (this is the case for digits '3579', but not for '3578' or '33')
          %   STACK: F(n), F(n+1)
    y     %     Duplicate from below
          %     STACK: F(n), F(n+1), F(n)
    D     %     Display immediately. This prints the copy of F(n)
          %     STACK: F(n), F(n+1)
  ]       %   End
  w       %   Swap
          %   STACK: F(n+1), F(n)
  y       %   Duplicate from below
          %   STACK: F(n+1), F(n), F(n+1)
  +       %   Add. Note that F(n)+F(n+1) is F(n+2)
          %   STACK: F(n+1), F(n+2)
  T       %   Push true. This will be used as loop condition
          %   STACK: F(n+1), F(n+2), true
          % End (implicit). The top of the stack is consumed as loop condition.
          % Since it is true, a new iteration will begin, with the stack
          % containing F(n+1), F(n+2)


Bash (+coreutils), 81, 87, 82, 78 bytes
Uses the man page for X, as the source of words.
Golfed
man xyst\  x|&grep -Po '\b[a-z]{4,} '|sed 's/\(.\)/\u\1 is for &/'|sort -uk1,1

EDITS

Used a non-existing 'xyst' man page + |& to save 5 bytes;
Saved 4 more bytes, by swapping sed and sort.

Test
%man xyst\  x|&grep -Po '\b[a-z]{4,} '|sed 's/\(.\)/\u\1 is for &/'|sort -uk1,1

A is for also
B is for build
C is for computing
D is for distribution
E is for entry
F is for following
G is for graphics
H is for hierarchical
I is for implementations
J is for just
K is for keyboard
L is for listing
M is for manual
N is for network
O is for output
P is for programs
Q is for quite
R is for runs
S is for system
T is for transparent
U is for used
V is for various
W is for window
X is for xyst
Y is for your
Z is for zeros


Distinct subsets that sum to a given number

Pyth, 6

@yE./Q

Try it online

We get all of the subsets of the given list with yE, and then ./Q gets all of the integer partitions (lists of integers that add up to it) of the other input. @ Finds the intersection of the two sets.


Use a=b=c=0 instead of a,b,c=0,0,0.

Use a,b,c='123' instead of a,b,c='1','2','3'.


Merging text files based on a prefix key

perl

I'm sure this can be done a few percent faster in some other language, but perl makes this super quick to implement at the optimal big-O level, and likely performs well enough. This code preserves order.

#!/usr/bin/perl -w

use strict;
use warnings;

my $key_size = $ARGV[0] =~ /--key-size=(\d+)/ ?
               (shift @ARGV, $1) : 4;

sub slurp {
  my $fn = shift;
  open my $fh, "<", $fn || die "can't open $fn for reading: $!";
  my (%keys, @order);
  while(<$fh>) {
    chomp;
    my $key = substr $_, 0, $key_size;
    push @order, $key;
    $keys{$key} = substr $_, $key_size;
  }
  close $fh || die "can't close $fn: $!";
  return [ \@order, \%keys ];
}

$_ = slurp shift @ARGV;
my @order = @{ $_->[0] };
my %keys  = %{ $_->[1] };
while(@ARGV) {
  my ($order2, $keys2) = @{slurp shift @ARGV};
  $keys{$_} = delete $keys2->{$_}  for (grep { exists $keys2->{$_} } @order);
  for (grep { exists $keys2->{$_} } @{$order2}) {
    $keys{$_} = $keys2->{$_};
    push @order, $_;
  }
}

print "$_$keys{$_}\n"  for  @order;

Test output:

ski@anito$ perl merger.pl --key-size=4 file1 file2  file3
0010THIS_IS_LINE_1_FROM_FILE2
0011EMPTY_LINE
00A0THIS_IS_LINE_3_FROM_FILE1
0100EMPTY_LINE

And here's a slightly faster version that doesn't preserve order:

#!/usr/bin/perl -w

use strict;
use warnings;

my $key_size = $ARGV[0] =~ /--key-size=(\d+)/ ?
               (shift @ARGV, $1) : 4;

my %keys;
while(@ARGV) {
  my $fn = shift;
  open my $fh, "<", $fn || die "can't open $fn for reading: $!";
  while(<$fh>) {
    chomp;
    $keys{substr $_, 0, $key_size} = substr $_, $key_size;
  }
  close $fh || die "can't close $fn: $!";
}

print "$_$keys{$_}\n"  for  keys %keys;


Perl, 188 180 + 2 = 182 bytes

Wuhuu, got to use goto.

@q=/.(?!$)/g,next if$w=$e=!@q;for(@F){a:$w+=$_;$_=$q[$w];/</?($_=-1,goto a):/X/?$e++:/#/?$w=0:!$_&&last;$e++}$r+=$"lt$r?-$w:$w;$t+=$"lt$t?-$e:$e-1}{say$w>@q?$t<0?B:A:!$r?0:$r<0?B:A

Requires -a and -E|-M5.010:

$ echo $'>-<-<#<-<-<-<-$\n5 4 2\n1 1 1' | perl -M5.010 boardgame.pl
B

Somewhat ungolfed version:

#!/usr/bin/perl -a

# Read all but last char from the board into an array
@board = /.(?!$)/g,next if $pos = $turns = !@board;
for (@F) {
    a:
    $pos+=$_;
    $_=$board[$pos];
    /</?($_=-1,goto a):
    /X/?$turns++:
    /#/?$pos=0:
    # End of Game (Victory!)
    !$_&&last;

    $turns++
}
# Make sure '$pos_diff' and '$turns_diff' are not zero by checking against [:space:]
# ' ' is less than 0 on the ascii table
$pos_diff += $"lt$pos_diff ? -$pos : $pos;
$turns_diff += $"lt$turns_diff ? -$turns : $turns-1;
}{
    say $pos>@board?
            $turns_diff<0?B
            :A
        :
        !$pos_diff?0:
        $pos_diff<0?B:
        A


MATL, 6 bytes
0:10YB

Try it at MATL Online
Explanation
0:10    % Create the array [0...10]
YB      % Convert this array to a binary string where each number is
        % placed on a new row
        % Implicitly display the result


Pyke, Pyth, Python 2, Foo, Brain****, GolfScript, Actually, <><, Gol<><, Seriously, Befunge, Fission, Haystack, 13 languages, 546 bytes
When I saw the other 10 11 12 language answer, I had to add an extra one two 3. I'm also seriously considering dropping Pyth if only to save on bytes. (at the moment 162 of them)
#\ s[\g\r\a\v\y)w.q)\r\o\l\l\ssp00/;oooooooo'stuffing;oooooo~'`turkey'
print'corn'#))))))))))))))))))))))))]+[--------->++<]>+w.q++[->+++<]>++w.q+++++++++++w.q-----------w.q----------------;))!+f'!n'!i'!s'!s'!e'!r'!d'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))L
'bread'#)))\é'i'n'o'r'a+++++))))))))))))))))))))))))))))))))))))))))))))))))\♀1X'c'a'm++++'e's'e'e'h'c'd'n'a++++++++)+.&\�0\ó))))))))))))))))))
#\25*8*0+c25*6*9+c25*6*7+c25*6*5+c25*7*8+c25*8*0+c25*7*3+c25*6*9+c|000000
# ,,,,,,,,@0>00000000\#"biscuits"aetteews"

Pyke: Try it here! rolls
Relevent line of code:
#s[\g\r\a  \v\y)w.q)\r\o\l\l\ssp00/;oooooooo'stuffing;oooooo~'`turkey'

#s[\g\r\a  \v\y)w.q) - effectively a comment because # doesn't do anything with an empty stack
\r\o\l\l\ss - sum("r", "o", "l", "l", "s")
p - print(^)
00/ - raise a ZeroDivisionError to stop running code

Pyth: Try it here! gravy
Relevent line of code:
#s[\g\r\a  \v\y)w.q)\r\o\l\l\ssp00/;oooooooo'stuffing;oooooo~'`turkey'

#...) - while True:
s[\g\r\a  \v\y) - sum(["g", "r", "a", "v", "y"])
w - input()
.q - quit

All the )'s are for Pyth to make it compile without erroring on no input.

Python 2: corn
Line 1 is a whole comment
Line 2 prints "corn" and then has a comment
Line 3 has a string literal and then a comment
Line 4 onwards are comments

Foo: Try It Online! biscuits
Foo prints out anything enclosed in double quotes ("). In this case I was careful to only include languages that could cope with other forms of string input (Special case for Befunge). If there was any text after the final ", that would be printed too.

Brain****: Try It Online! salad
I copied the output of constant string generator. I had to escape all . characters with .q so it would play with Pyth and w. so it would play with Pyke. I added some extra - characters so the cells would get to the right points before printing at another . character in the 3rd line

GolfScript: Try It Online! cornbread
In GolfScript, # is a comment until end of line.
What GolfScript interpreter sees:
#comment
print'corn'#comment
'bread'#comment

In GolfScript, for whatever reason, print takes a string and prints it without a newline. Just having bread is enough to print it as well.

Actually: Try It Online! macandcheese
Relevant line:
'bread'#)))\é'i'n'o'r'a+++++))))))))))))))))))))))))))))))))))))))))))))))))\♀1X'c'a'm++++'e's'e'e'h'c'd'n'a++++++++)+.&\�0\ó))))))))))))))))))

é - clears the stack of whatever junk was on it before.
'i'n'o'r'a+++++ - create string "aroni"
) - rotate entire stack (effectively comments as stack is only 1 long)
♀1X - pop stack (now empty)
'c'a'm++++ - constructs the string "mac"
'e's'e'e'h'c'd'n'a++++++++ - constructs the string "andcheese"
) - rotate stack (reverse)
+ - "mac" + "andcheese"
� - quit

<><: Copy+Paste only turkey

Gol<><: Try It Online! stuffing
As <>< except ` skips the first ' and only outputs enough characters to print stuffing

Seriously: Try It Online! macaroniandcheese
Relevant line:
'bread'#)))\é'i'n'o'r'a+++++))))))))))))))))))))))))))))))))))))))))))))))))\♀1X'c'a'm++++'e's'e'e'h'c'd'n'a++++++++)+.&\�0\ó))))))))))))))))))
é - clears the stack of whatever junk was on it before.
'i'n'o'r'a+++++ - create string "aroni"
) - rotate entire stack (effectively comments as stack is only 1 long)
♀1X - no-op
'c'a'm++++ - constructs the string "mac" + "aroni"
'e's'e'e'h'c'd'n'a++++++++ - constructs the string "andcheese"
) - rotate stack (reverse)
+ - "macaroni" + "andcheese"
. - print stack
0\ó - exit

Befunge: Try It Online! sweettea
Code that is looked at
#s[\g\r\a  \v - |
            ) - | - Directing the stack pointer to the correct place
            é - |
# ,,,,,,,,@0>00000000\#"biscuits"aetteews"

            >                              - change direction of travel
             00000000\#"biscuits           - a load of no-ops `#` skips the opening `"`
                                "aetteews" - add the chars to the stack in reverse order
  ,,,,,,,,@                                - output 8 chars from the stack and exit.

Fission: Try It Online! dressing
Code looked at:
;))!+f'!n'!i'!s'!s'!e'!r'!d'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))L

Of which are used:
;!+f'!n'!i'!s'!s'!e'!r'!d'L
                          L - start an atom going left
                      !d'   - create the character `d` and print it
                              ...
;                           - exit

Haystack (2015): PECANPIE (with EXTRA newlines!)
#\
 r
 b
 \25*8*0+c25*6*9+c25*6*7+c25*6*5+c25*7*8+c25*8*0+c25*7*3+c25*6*9+c

Of which do something functional:
  25*8*0+c25*6*9+c25*6*7+c25*6*5+c25*7*8+c25*8*0+c25*7*3+c25*6*9+c

I construct each upper case ascii codepoint for the letters in PECANPIE  in uppercase because they're all below 100. I then print them all out as characters.


Python 2, 129 126 119 104 bytes

def f(n,k,p=0):z=p<1or n>0;q=-~ord('}/lx2Z^o~z'[n%10])*z;return(z and f(n/10,k,q))+k*bin(p^q).count('1')

Try it online!

Thx for a big 15 bytes from ovs.

As specified, takes a non-negative number and a positive sign length, and returns total changes.


Ruby, 43

def s a,*b,&f
a.map{|x|b[f[x]]=x}
b-[p]
end

Calling looks like

p s(["a","ccc","bb","eeeee"],&:length)
  -> ["a", "bb", "ccc", "eeeee"]

Tricks: *b in the arg list creates an empty output array (so long as you don't, y'know, pass any args). &f creates a lambda reference to the passed-in block that can be called via f[] (normal Ruby convention is to use yield). a.map iterates over the input array without modifying it and is one character shorter than a.each. b-[p] strips out the nil values, equivalent to b.compact.


Vyxal, 1 byte
Ǒ

Try it Online!
laughs in stolen jelly built-ins


Python 2 using numpy, 71 62 bytes

import numpy
def g(M,n):R=(M+M**0)**n>0;print(R&R.T).argmax(0)

Takes input as a numpy matrix representing adjacency and the number of nodes. Produces output as a numpy row matrix that labels each vertex by the lowest vertex number in its component.
For an adjacency matrix M, the matrix power M**n counts the number of n-step paths from each start vertex to each end vertex. Adding the identity to M via M+M**0 modifies the adjacency matrix to add a self-loop to every edge. So, (M+M**0)**n counts paths of length at most n (with redundancy).
Since any path has length at most n, the number of nodes, any (i,j) where vertex j can be reached from i corresponds to a positive entry of (M+M**0)**n. The reachability matrix is thenR=(M+M**0)**n>0, where the >0 works entrywise.
Computing the entrywise and as R&R.T, where R.T is the transpose, then gives a matrix indicating the pairs of mutually reachable vertices. It's ith row is an indicator vector for vertices in the same strongly connected component as it. Taking its argmax of each row gives the index of the first True in it, which is the index of the smallest vertex in its component.


x86_64 machine language (Linux), 16 bytes
0:       f2 48 0f 2a c7          cvtsi2sd %rdi,  %xmm0
5:       66 48 0f 7e c0          movq     %xmm0, %rax
a:       f3 48 0f b8 c0          popcnt   %rax,  %rax
f:       c3                      retq

Accepts a single 64-bit integer parameter in RDI, converts it to a floating-point value in XMM0, stores those bits back in RAX, and then computes the hamming weight of RAX, leaving the result in RAX so it can be returned to the caller.
Requires a processor that supports the POPCNT instruction, which would be Intel Nehalem, AMD Barcelona, and later microarchitectures.
To Try it online!, compile and run the following C program:
#include<stdio.h>
const char g[]="\xF2\x48\x0F\x2A\xC7\x66\x48\x0F\x7E\xC0\xF3\x48\x0F\xB8\xC0\xC3";
#define f(x) ((int(*)(long))g)(x)

int main(int a){
  printf("%d\n",f(22));
  printf("%d\n",f(714));
  printf("%d\n",f(0));
  printf("%d\n",f(1));
  printf("%d\n",f(4503599627370496L));
  printf("%d\n",f(4503599627370495L));
  printf("%d\n",f(1024));
  printf("%d\n",f(-1024));
  printf("%d\n",f(-4096));
  printf("%d\n",f(1000000000));
  printf("%d\n",f(-12345678));
}

Edit: Fixed segfault in TIO link.


MATL, 56 53 bytes
:"'!!((!((!!#*```).?p0```!!!]'8eP!P]'p(.' '.a-'XE&hqc

Try it online!
Explanation
Awake goat
The awake goat can be packed into the string
  '' ''  ")___(->o/___   \

and unpacked as will be explained shortly. However, the single-quote symbols would need to be duplicated in order to escape them, so the string literal would have to be defined as (note the enclosing single-quote symbols and the duplication of the original ones):
'  '''' ''''  ")___(->o/___   \'

To save bytes, we define the string using characters one code point above that, thus avoiding duplication. The string literal becomes
'!!((!((!!#*```).?p0```!!!]'

At the end of the code we will subtract 1 and convert to char. (We could do it now, right after the string literal; but leaving it for the end will save another single-quote duplication, as we will see).
To explain how the string is unpacked, we will work with the original characters (that are produced at the end of the code by subtacting 1), so the explanation is easier to follow. We first reshape the string
  '' ''  ")___(->o/___   \

into an 8-row 2D char array, in column-major order (down, then across). This automatically pads the last column with char 0 (at the end of the code, subtracting 1 will transform it into number −1, which converted to char gives again char 0). Char 0 is displayed as a space. So effectively we are padding with spaces. The result of reshaping is
  >
 "o\
')/
'__
 __
'__
'(
 -

We now flip vertically:
 -
'(
'__
 __
'__
')/
 "o\
  >

and then transpose and flip vertically again to produce the awake goat:
      \
  ___/o>
-(___)"
 '' ''

The two flip operations are needed because the original packed string is "in reverse". This is to exploit the fact that the actual 2D char array representing the goat has 6 initial spaces in its first row, which get automatically filled by padding when the string is reshaped into an 8-row 2D array. But the padding is done at the end (not beginning) of the last column (not row), hence the flips and transpose.
Sleeping goat
A sleeping goat is generated from an awake goat by transliterating chars o, ', - into -, `, , respectively. Actually, because of the one-code-point-above transformation, we transliterate chars p, (, ' into ., a, -, which again saves us from having to duplicate the single-quote symbol. This is why the subtract-one operation was left for the end of the program.
Code structure

Generate an awake goat N times, working with code points increased by 1.
Transform the last goat into a sleeping goat.
Concatenate all goats horizontally. Subtract 1 to code points and cast to char.

Commented code
:                              % (Step 1) Implicitly input N. Push range [1 2 ... N]
"                              % For each (i.e. repeat N times)
  '!!((!((!!#*```).?p0```!!!]' %   Push this string. Quotes are escaped by duplicating
  8e                           %   Reshape into an 8-row 2D array of char, in
                               %   column-major order, padding last column with
                               %   char 0
  P                            %   Flip vertically
  !P                           %   Transpose and flip vertically
]                              % End
'p(.'                          % (Step 2) Push this string: source for transliteration
'.a-'                          % Push this string: target for transliteration
XE                             % Transliterate. Transforms last goat into sleeping
&h                             % (Step 3) Horizontally concat all 2D char arrays
qc                             % Subtract 1 and convert to char. 0 becomes −1, which
                               % is converted to char 0, which is displayed as a space
                               % Implicitly display


Ruby, 407 376 365 331 324 323

This is getting kind of hard to read...

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

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

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


Word VBA, 199 147 126 116 102 100 87 85  Bytes

Why emulate when you can do?!
Declared function in the ThisDocument module that takes input n in the form of Array(true,true,false,true) and outputs to the Word font size selector :P
Golfed:
Sub a(n):Set f=Content.Font:For Each i In n
If i Then f.Grow Else f.Shrink
Next:End Sub

Ungolfed:
Sub a(n)
    Set f=ThisDocument.Content.Font
    For Each i In n
        If i Then
            f.Grow
        Else
            f.Shrink
        End if
    Next
    ''  Implicitly output font size to MS Word Font Size Selector
End Sub

.GIF of usage

Thanks
-21 thanks to @Adám (removed Selection.WholeStory: call)
-10 thanks to @Adám (assume clean environment; remove f.size=11: call)
-14 thanks to @Adám (cheeky output word font size selector)
-2 thanks to @Adám (bool ParamArray)
-13 for changing ParamArray n() to n and expecting input as Boolean Array
-2 for moving from a code module to the ThisDocument module
Old Version 114 Bytes
Takes input n as a ParamArray, in the form of true,true,false,true and outputs word vbe immediates window
Sub a(ParamArray n()):Set f=Selection.Font:For Each i In n
If i Then f.Grow Else f.Shrink
Next:Debug.?f.Size:End Sub

Older version, 199 Bytes
Takes input in the form of 170,-4,6,-1 (accepts numbers larger than 1 in magnitude)
Sub a(ParamArray n()):Selection.WholeStory:Set f=Selection.Font:f.Size=12:For Each i In n
If i>1 Then
For j=i To 0 Step -1:f.Grow:Next
Else
For j=i To 0:f.Shrink:Next:End If:Next:Debug.?f.Size:End Sub


section .text

global _start

_start:
  xor r8, r8
  xor r9, r9
  xor r10, r10

_do_while:

_getchar:
  cmp r9, r10

  jne _getchar_done

_getchar_read_buffer:
  xor r9, r9

  xor eax, eax
  xor edi, edi
  mov rsi, in_buf
  mov rdx, inbuf_maxlen

  syscall

  mov r10, rax

_getchar_done:
  mov al, [in_buf + r9]
  inc r9

_do_while_cont:
  cmp al, [req + r8]

  jne _reset

_increment:
  inc r8

  cmp r8, 5

  jne _do_while

  mov rax, 1
  mov rdi, 1
  mov rsi, ans
  mov rdx, 5

  syscall

_end:
  mov rax, 60
  xor rdi, rdi

  syscall

_reset:
  xor r8, r8

  cmp al, 'd'

  jne _do_while

  inc r8

  jmp _do_while

section .rodata
  inbuf_maxlen equ 1000000

  req db "draw!"

ALIGN 8
  ans db "bang!"

section .bss
  in_buf resb inbuf_maxlen

A little hand-written assembly. Compile with:
nasm -felf64 foobar.s && ld foobar.o -o foobar

Edit: move in_bi into a register and use xor.
Edit: used the wrong jump, my code was wrong...
Edit: the previous code had a bug where it would read garbage if the read syscall did not return a full buffer. This version is more efficient (and correct)...
Edit: make sure to process ddraw! correctly. Thanks to Anders Kaseorg for the test case.
Edit: re-structure to move getchar out of a function and to jump less.
Edit: don't xor the high bits of the registers at the suggestion of Cody Gray
Edit: align (thanks to Joshua) and move into .rodata


Retina, 70 68 62 bytes

.+
10**
.
$.>`
~(`.+
6*$+*
)`.(.+)
L`.{$.1}
%,-6`.

,2,9`.
*
_

Try it online!

Explanation

Let's call the input n, and we'll use 3 as an example.

.+
10**

The 10** is short for 10*$&*_ which replaces the input with a string of 10n underscores.

.
$.>`

Now we replace each underscore with the length of the string up to and including that underscore. So this just results in the number from 1 to 10n all concatenated together (10n is always enough to fill up two lines of the required length).

~(`.+
6*$+*

Eval! This and the next stage will generate the source code of another program, which is then run against that string of concatenated integers.

To generate that program, this stage first replaces the integers with a string of 6n underscores ($+ refers to the program's original input).

)`.(.+)
L`.{$.1}

Then replace those underscores with L`.{…}, where … is 6n-1 (the length of the lines we're looking at). So we've generated a regex, whose quantifier depends on the original input.

When this program gets eval'ed it matches chunks of length 6n-1, of which there will be at least two. For our example input 3, we end up with:

12345678910111213
14151617181920212
22324252627282930

Now we just need to extract the relevant digits.

%,-6`.

First, on each line (%) we remove all but the last five digits (,-6). That gives us

11213
20212
82930

Finally:

,2,9`.
*

We expand every other digit (2) in the first ten (9, this is 0-based) in unary. Those happen to be those in the Olympic Rings positions.

_

And we count the number of resulting underscores, to sum them and convert the result to decimal.


Charcoal, 17 bytes

Code:

ＮβＧ←β_↙↙¹→↘⁺β¹‖Ｍ→

Explanation:

Ｎβ                      # Place the input into β
   Ｇ←β_                 # Draw a line of length β with _ as the filling character
        ↙                # Move the cursor one down and one left
         ↙¹              # Draw a line from the cursor position to one position ↙
           →             # Move the cursor 1 to the right
             ⁺β¹         # Add one to the input and..
            ↘            # Create a line pointing ↘, with the size calculated above
                ‖Ｍ→     # Mirror to the right

A very neat command is ‖Ｍ, which also automatically mirrors / into \.

Uses the Charcoal encoding.

Try it online!


Make a Valentine wish with your favourite language

C/Python Polyglot/Polygamist

Monogamy isn't for everyone.
Based on my answer to Execute Prints Backwards.

#define def main(){0?
#define print printf(
#define return 0)));}

def main():
    print "Python",
    print ", I love you much more than ",
    print "C",
    return

main();

Output, when run as C:

C, I love you much more than Python

Output, when run as Python:

Python , I love you much more than  C


Jelly, 6 bytes

Œ!=ÐṂR

A monadic Link accepting a positive integer which yields a list of lists of integers.

Try it online!

How?

Œ!=ÐṂR - Link: integer, n
Œ!     - all permutations of (implicit range of [1..n])
     R - range of [1..n]
   ÐṂ  - filter keep those which are minimal by:
  =    -   equals? (vectorises)
       -   ... i.e. keep only those permutations that evaluate as [0,0,0,...,0]


Haskell, 49 characters

f[]=[[]]
f(2:r)=f(0:r)++f(1:r)
f(x:r)=map(x:)$f r

Interestingly this is exactly what I'd write even if this wasn't golf - except for removing spaces and calling the list's tail r rather than xs.


JavaScript (375)

Probably a terrible attempt, but anyway, here goes...

alert(function N(s,z){return O="zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,,fif,,,eigh,,,,twen,,for".split(","),(z?O[s]||O[s-10]||O[s-20]:s<13?N(s,1):s<20?N(s,1)+"teen":s<100?N(a=20+(s/10|0),1)+"ty"+(s%10?" "+N(s%10):""):s<1e3?N(s/100|0)+" hundred"+(s%100?" "+N(s%100):""):s<1e5?N(s/1e3|0)+" thousand"+(s%1e3?" "+N(s%1e3):""):0)||NaN}(prompt()))

Pretty-printed (as a function):

function N(s,z) {
  return O = "zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,,fif,,,eigh,,,,twen,,for".split(","),
      (z? O[s] || O[s-10] || O[s-20]
       : s < 13?  N(s,1)
       : s < 20?  N(s,1) + "teen"
       : s < 100? N(a=20+(s/10|0),1) + "ty" + (s%10?" "+N(s%10):"")
       : s < 1e3?  N(s/100|0) +  " hundred" + (s%100?" "+N(s%100):"")
       : s < 1e5?  N(s/1e3|0) + " thousand" + (s%1e3?" "+N(s%1e3):"") : 0) || NaN
}

Sample conversion (note that it even outputs NaN when out of bounds, i.e. invalid input):

540: five hundred forty
4711: four thousand seven hundred eleven
7382: seven thousand three hundred eighty two
1992: one thousand nine hundred ninety two
hutenosa: NaN
1000000000: NaN
-3: NaN


Generate numerical permutations with conditions and template metaprogramming

Success!!!! It only took me 3 hours or so. (Note: Requires C++11 support)

4,410 characters (including output functions)

Compiled on GCC 4.7.2 (Ideone)

#include<iostream>
#include<type_traits>

int constexpr powOf10(size_t power)
{
    return power == 0 ? 1 : 10 * powOf10(power - 1);
}

template<int... digits>
struct buildNumber;

template<int first, int... digits>
struct buildNumber<first, digits...> : std::integral_constant<int, first * powOf10(sizeof...(digits)) + buildNumber<digits...>::value>
{
};

template<>
struct buildNumber<> : std::integral_constant<int, 0>
{
};

template<int... digits>
struct areAllDigits;

template<int first, int... digits>
struct areAllDigits<first, digits...>
{
    static bool constexpr value = first > 0 && first < 10 && areAllDigits<digits...>::value;
};

template<int first>
struct areAllDigits<first>
{
    static bool constexpr value = first>0 && first < 10;
};

template<class T>
struct buildNumberT;

template<int... digits>
struct digitContainer
{

};

template<int... digits>
struct buildNumberT<digitContainer<digits...>> : buildNumber<digits...> {};

template<class T1, class T2>
struct concatCtr;

template<int... digits1, int... digits2>
struct concatCtr<digitContainer<digits1...>, digitContainer<digits2...>>
{
    typedef  digitContainer<digits1..., digits2...> type;
};

template<int number, size_t digit>
struct breakIntoDigits
{
    typedef typename concatCtr<digitContainer<number / powOf10(digit)>, typename breakIntoDigits<number % powOf10(digit), digit - 1>::ctr>::type ctr;
};

template<int number>
struct breakIntoDigits<number, 0>
{
    typedef digitContainer<number> ctr;
};

template<int needle, int... haystack>
struct contains;

template<int needle, int first, int... haystack>
struct contains<needle, first, haystack...>
{
    static bool constexpr value = needle == first || contains<needle, haystack...>::value;
};

template<int needle>
struct contains<needle>
{
    static constexpr bool value = false;
};

template<int... values>
struct max;

template<int first, int... rest>
struct max<first, rest...>
{
    static constexpr int value = first > max<rest...>::value ? first : max<rest...>::value;
};

template<>
struct max<>
{
    static int constexpr value = 0;
};

template<class container, int... digits>
struct ruleChecker;

template<int current, int... allPrevious, int... rest>
struct ruleChecker<digitContainer<allPrevious...>, current, rest...>
{
    static bool constexpr value = (current == 0 || sizeof...(allPrevious) == 0 || contains<current, allPrevious...>::value || current > max<allPrevious...>::value) && ruleChecker<digitContainer<allPrevious..., current>, rest...>::value;
};

template<class container>
struct ruleChecker<container>
{
    static bool constexpr value = true;
};

template<class ctr1, class ctr2>
struct ruleCheckerT;

template<class ctr1, int... set2>
struct ruleCheckerT<ctr1, digitContainer<set2...>> : ruleChecker<ctr1, set2...>{};

template<int number, int length>
struct isValidNumber : ruleCheckerT<digitContainer<>, typename breakIntoDigits<number, length>::ctr>
{
};

template<int number, int length>
struct generateList
{
    typedef typename std::conditional<number % powOf10(length) == 0,
        digitContainer<>,
        typename concatCtr<
            typename generateList<number + 1, length>::container,
            typename std::conditional<isValidNumber<number, length>::value,
                    digitContainer<number>,
                    digitContainer<>
                >::type
            >::type
        >::type container;
};

template<int number>
struct generateList<number, 1>
{
    typedef typename concatCtr<
        typename generateList<number + 1, 1>::container,
        typename std::conditional<isValidNumber<number, 1>::value,
                digitContainer<number>,
                digitContainer<>
            >::type
        >::type container;
};

#define DEFINE_ENDPOINT_FOR_LENGTH(length) template<> struct generateList<powOf10(length), (length)>{typedef digitContainer<> container;}

template<int length>
struct insanity
{
    static_assert(length > 0, "Length must be greater than 0.");
    typedef typename concatCtr<typename generateList<1, length>::container, digitContainer<0>>::type numberList;
};

template<int first, int... rest>
void outputContainer(digitContainer<first, rest...> values)
{
    std::cout<<first<<'\n';
    outputContainer(digitContainer<rest...>{});
}

void outputContainer(digitContainer<> empty)
{
    std::flush(std::cout);
}

Explanation

insanity is the entry point, as used in the OP.  buildNumber builds a number from a list of digits; breakIntoDigits does the opposite; it takes a number and breaks it into length digits.  areAllDigits is just a helper I used earlier.  It isn't used in the final code.  It's value property is true if all the numbers passed to it are base-10 digits.  It generates a list of valid numbers (validated by isValidNumber) and puts them in a digitContainer (originally I was only going to use this for digits, but I decided to use it for both things).

Limitations

It can only calculate up to the point the compiler errors out from template recursion depth.
You need to define an ending point for each length because otherwise it keeps instantiating templates up to the limit because of std::conditional. You define an ending point for each length by typing DEFINE_ENDPOINT_FOR_LENGTH(i) where i is the length.


Perl 5 - 4212 3956 3930

use IO::Uncompress::Gunzip qw(gunzip);
gunzip 'g'=>\$_;
while(/(\x00*)(.)(.)(.)(.)/gs){$c[$i+=ord($2)+255*length$1]=sprintf"#%02x%02x%02x\n",map{ord}$3,$4,$5}
@a[32,33,39,47,97..123]=(3,1812,3,17,82,4,1013,119,3,909,8,10,10,1827,1219,4,718,265,228,418,2347,10,3,31,3,1786,921,380,1223,1915,4);
$_=<>;
for$i(0..(($h=y///c-1)<=12?$h-1:12)){$h+=$a[(($i/2|0)==1)+ord((/./g)[$i])]if($i!=7&&$i!=10)}
print$c[$h];

407 bytes for the code and 3523 for the data file. Binary data is read from the file 'g', a hexdump of which can be found here.

This uses a perfect hash function generated using GNU gperf, which assigns each color name to a unique integer in the range 0 to 6304 that can be used to index a table. The gzipped data contains the color values in the format of 1 byte indicating the offset in the table from the previous color, then 3 bytes for the color itself (with two hex digits per byte). (A 0 byte for the offset means it's actually the next value + 255, since not every offset fit in one byte).

The code parses the data to create the table containing the color rgb string, then applies the hash function (translated to perl) to the input to select the matching output from the table.

Usage:

echo 'pale red' | perl get-color.pl
#d9544d

Edit: Further reduced the size by gzipping the data file


APL (Dyalog Unicode), 55 48 bytes

≢⍸↑2≠/¨⊢∘g\3⍴⊂2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←⍉⍤2⍉∘⌽)⍣6~⎕

Try it online!
-7 bytes thanks to @ngn.
Improvements:

2 3 1⍉ → ⍉⍤2⍉: Replace "cycle the axes once" with "swap 1st and 3rd axes, then 2nd and 3rd"
{⍵(g⍵)(g g⍵)} → ⊢∘g\3⍴⊂: A scan that ignores the left arg and applies g to the right arg, so it works like this:

3⍴⊂x gives (x x x)
⊢∘g\3⍴⊂x gives (x)(x ⊢∘g x)(x ⊢∘g x ⊢∘g x)
which is the same as (x)(g x)(g g x) because:
  x ⊢∘g x
→ x ⊢ g x
→ x ⊢ (g x)
→ g x

APL (Dyalog Unicode), 55 bytes

{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

Try it online!
A full program that takes a 3D array. Uses the flood fill already used here. Another key idea is g←2 3 1⍉⌽, which effectively cycles through all six sides when applied with ⍣6 (repeat six times).
How it works
{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

~⎕                ⍝ Logical negation of the input
(1,g←2 3 1⍉⌽)⍣6   ⍝ Pad with a layer of ones on all six sides
2(g⊣(⌈∧⊢)/,)⍣6⍣≡  ⍝ Flood fill from the outside, changing 1s to 2s:
2(        ,)      ⍝   Prepend 2 on the last axis
   ⊣(⌈∧⊢)/        ⍝   Pairwise lcm(max(x,y),y) over the last axis
                  ⍝   Effectively, propagate 2 to an adjacent 1 on the right
  g               ⍝   Cycle the orientation once
            ⍣6⍣≡  ⍝   Repeat 6 times until the flood fill is complete
2=                ⍝ Map 2s to 1s, and anything else to 0s
{⍵(g⍵)(g g⍵)}     ⍝ Construct 3 arrays so that each axis becomes the last axis
2≠/¨              ⍝ Extract faces (where 0 and 1 are adjacent) for each array
≢⍸↑               ⍝ Count ones in all arrays


Retina, 17 bytes

\B\w+(\.[a-z])
$1

Try it online!

Explanation

\B         # Start from a position that isn't a word boundary. This ensures that
           # the first letter of the package name is skipped.
\w+        # Match one or more word characters. This is the remainder of the
           # package name which we want to remove.
(          # Capture the next part in group 1, because we want to keep it...
  \.[a-z]  #   Match a period and a lower-case letter. This ensures that we
           #   don't match the package that precedes the class, or the package or
           #   class at the end of the input.
)

This is replaced with $1, which is the period and lower case letter which shouldn't be removed.


Haskell, 99 97 82 81 bytes

-16 bytes thanks to Delfad0r (taking inputs as a list, using abusing that we don't need to deduplicate -> n can always be in [0,4] & using a clever combination of input-format and ap)!

filter((==1e4).sum).mapM([read.(take n<>(c:).drop n)|c<-['0'..'9'],n<-[0..4]]<*>)

Try it online!


Shortest implementation of a linked list, stack and queue

Haskell, 81 69 characters

data L a=N|a:~L a
N~:z=z:~N
(a:~b)~:z=a:~(b~:z)
r N=N
r(a:~z)=r z~:a

This code makes use of no preexisting functions at all. The push operation is :~, the enqueue operation is ~:. Both pop and dequeue are via pattern match against :~. The extra operation r is reverse.

Stacks:

ex1 =
    let stack0 = N                      -- empty stack
        stack1 = 'a' :~ stack0          -- push 'a'
        stack2 = 'b' :~ stack1          -- push 'b'
        first :~ stack3 = stack2        -- pop
        second :~ stack4 = stack3       -- pop
    in mapM_ print [first, second]

—

λ: ex1
'b'
'a'

Queues:

ex2 =
    let queue0 = N                      -- empty queue
        queue1 = queue0 ~: 'x'          -- enq 'x'
        queue2 = queue1 ~: 'y'          -- enq 'y'
        queue3 = queue2 ~: 'z'          -- enq 'z'
        next0 :~ queue4 = queue3        -- deq
        next1 :~ queue5 = queue4        -- deq
        next2 :~ queue6 = queue5        -- deq
    in mapM_ print [next0, next1, next2]

—

λ: ex2
'x'
'y'
'z'

List reverse operation:

ex3 =
    let list = "alpha" :~ ("beta" :~ ("gamma" :~ N)) -- a list
        tsil = r list                   -- reverse the list
        native N = []                   -- convert to native list
        native (a:~z) = a : native z    -- for easy printing
    in mapM_ (print . native) [list, tsil]

—

λ: ex3
["alpha","beta","gamma"]
["gamma","beta","alpha"]


QuadR, 19 bytes

_(.)
[A-Z]
\u1
_\l&

Try it online!


Haskell 206 Chars

import Data.List
import Control.Applicative
import Data.Function
main= readLn >>= print .(flip take (map read $ fix (("1":). map (concat .(map ((++)<$>(show . length)<*>((:[]). head))). group))::[Integer]))

It works by using the group function to group them into groups of equal things. Then it uses applicatives with functions to build a function that simultaneously reads the length, and appends it to with one the elements. It uses a fix and a map to create a recursive definition (point-free.) And there ya go.


Define a function f such that f(f(n)) = -n for all non-zero integers n

Python: 61 34 30 29 27 points

f: Q -> Q

in math:

       | 0.5-x   if x is in Q \ Z
f(x) = |
       | x+0.5   if x is in Z

in Python:

f=lambda x:.5+[x,-x][x%1>0]

tested with

filter(lambda n: n[0] != -n[1], map(lambda n:(n,f(f(n))),range(0,50)))

logic behind this:

When you take an integer n and put it into f you will get x+0.5. This is not an integer any more, so the next application will be 0.5-(x+0.5) which is -x.

Credits

Thanks to

Bakuriu for striping it down from 61 characters to 34 characters.
Volatility for further reducing code size to 30 characters.
copy for reducing code size to 29 characters (and fixing a potential floating point problem).
aditsu for mentioning an inconsistency that came with the changes above.

Notes

First I thought this would be ok

f = lambda n: 1j*n

but its f:N->C and that is not allowed :-/


Matlab

why

example of outputs:

>> why
The programmer suggested it.
>> why
To please a very terrified and smart and tall engineer.
>> why
The tall system manager obeyed some engineer.
>> why
He wanted it that way.

[This is one of Matlab's easter eggs]

EDIT: you can see the code of this function here: why.m


Ways to put extra 0s on the stack

A lot of times, you will be faced with the following 4-character piece of code:

0 2@

Element's stack-item-movement operator @ is very general-purpose, sometimes too much so for golfing, since it always takes two arguments, which may need to be separated by a space.  So, it can take several characters to perform a single movement.

Usually, there is a better way to do this.

You can often produce empty values from the hash.  The code  2:0 2@ can almost always be shortened to 3:~2@ to save one character because chances are that nothing is stored in the hash for that particular key.

If the top thing on the stack is the input, you can sacrifice the newline at the end of it like so:

_0 2@
_)2@

In a limited number of cases, usually with 0 1@, you don't need the @ at all.  This works with input or when putting a constant on the stack.

_0 1@
'_"

text 0 1@
'text"


Jelly, 12 bytes

;2U+¥Ð¡-,1ZḢ

Try it online!

Background

We can extend F and L to -1 by defining F(-1) = 1 and L(-1) = -1. This is consistent with the recursive function.

Our program starts with

-1  1
 0  2

In each step, to form the next pair, we reverse the last pair and add it to the penultimate pair. For example:

[0, 2] U+¥ [-1, 1] -> [2, 0] + [-1, 1] -> [1, 1]

If we continue this process for a few more steps, we get

-1  1
 0  2
 1  1
 1  3
 4  2
 3  7
11  5

The Lucas-nacci sequence is simply the left column.

How it works

;2U+¥Ð¡-,1ZḢ  Niladic link. No implicit input.
              Since the link doesn't start with a nilad, the argument 0 is used.

;2            Concatenate the argument with 2, yielding [0, 2].
       -,1    Yield [-1, 1]. This is [L(-1), F(-1)].
    ¥         Create a dyadic chain of the two atoms to the left:
  U             Reverse the left argument.
   +            Add the reversed left argument and the right one, element-wise.
     Ð¡       For reasons‡, read a number n from STDIN.
              Repeatedly call the dyadic link U+¥, updating the right argument with
              the value of the left one, and the left one with the return value.
              Collect all intermediate results.
          Z   Zip the list of results, grouping the first and seconds coordinates.
           Ḣ  Head; select the list of first coordinates.

‡ Ð¡ peeks at the two links to the left: 2 and U+¥. Since the leftmost one is a nilad, it cannot be the body of the loop. Therefore, U+¥ is used as body and a number is read from input. Since there are no command-line arguments, that number is read from STDIN.


Implement Smokey's !!/coffee command. (Part 2)

Jelly, 60 bytes
“¦ƘÇ=X⁸ẓÇsŻY»⁶“¢p ɼƁỴŒ?Ọi^gċ{çØLƲ`ẆĿJ$ȮȷẈv&ẋȧ>ċ8½c»ḲX⁶“Ƙa»⁶³

Try it online!
If you write a nilad while there's an argument Jelly just dumps it into STDOUT, which is really nice for this challenge because you don't need to worry about maintaining the list of output characters but rather just dump the outputs piece by piece.
Explanation
“¦ƘÇ=X⁸ẓÇsŻY»⁶“...»ḲX⁶“Ƙa»⁶³  Main Link
“¦ƘÇ=X⁸ẓÇsŻY»                 "brews a cup of coffee for"
             ⁶                " " (dumps previous string to output)
              “...»           compressed string with space-separated coffee types
                   Ḳ          split on spaces
                    X         choose a random value
                     ⁶        " " (dumps the coffee type to output)
                      “Ƙa»    "for" (dumps the space to output)
                          ⁶   " " (dumps "for" to output)
                           ³  get the command line argument (implicit output)

It's the same length to compress " for" as to place a space and then compress "for". Unfortunately Jelly compressed strings don't seem to support trailing spaces, which unlike most situations actually matters here.


Find the longest run of consecutive digits

Jelly, 18 bytes

I9,-;N¤yŒgỊS€ṀµÐṀḢ

Try it online!

Takes and returns as list of digits so as to preserve leading zeroes.


GFA BASIC on Atari ST, 27 bytes
This is a manually edited source code in .LST format. It contains unprintable characters: [SO] and [SI] stand for ASCII characters #14 and #15 respectively. Both lines ends with CR.
DEFTEXT,,,32
TEXT0,28,"[SO][SI]"

This will draw a 28x26 Atari logo, which is part of the Atari ST system font.


Pyth, 37 bytes

.-Jjb.zpef!.-TJ+,kb+Rb._"pyth is awesome!

The source code is 41 bytes long. Try it online.

How it works

  Jjb.z                                      Save all user input in J.
                      ._"pyth is awesome!    Compute all prefixes that string:
                                               ["p", "py", ... ]
                   +Rb                       Append a linefeed to each prefix.
               +,kb                          Concatenate ["", "\n"] with the result.
         f                                   Filter the resulting array; for each T:
           .-TJ                                Perform bagwise difference between T
                                               and J (respects multiplicities).
         !                                     Take the logical NOT.
                                             Keep T if ! returned True, i.e., if J
                                             contains all of T's characters.
        e                                    Retrieve the last, longest match.
       p                                     Print it.
.-J                                          Remove its characters from J.
                                             (implicit) Print the result.


This is the sort of challenge that bytes

Jelly, 8 programs

Ṣ                   Built-in sort.
¹Þ                  Sort-by the identity function.
Ụị                  Sort indices by values, then index into list.
Œ!Ṃ                 Smallest permutation.
7778Ọv              Eval Unicode 7778 (Ṣ).
ẊI>@-.S$$¿          Bogosort.
<;0œṡ0⁸ṁjµ/         Insertion sort.
AṀ‘¶+Ç©ṬT_©®³ċÐ€®x' A terrifying hack.

The last program is really annoying…

AṀ‘¶+Ç©               Add ® = abs(max(L)) + 1 to the entire list.
                      Now it’s offset to be entirely positive.
       Ṭ              Create a binary array with 1s at these indices.
        T             Find the indices of 1s in this array.
                      The result is sorted, but offset wrong, and lacks duplicates.
         _©®          Subtract the offset, saving this list to ®.
                      Now restore the duplicates:
            ³ċÐ€      Count occurences in the original list.
                ®x'   Repeat the elements of ® that many times.

If I can remove the œṡ from <;0œṡ0⁸ṁjµ/, there’s also this weird one: ²SNr²ZFœ&. Help is appreciated.


PHP, 99 bytes
As ISO 8859-1:
<?=base64_encode("i·yø!9%z)ª»-ºü1Ë:°z»rº*)jÇ_ä<\½¹æ§'àr¹Z¡ë¢vg²¨äÅ¹°¿<òÇî¶Êê¦æHâÞuÆÚ");

To reproduce reliably,
printf '<?=base64_encode("' >| 4times.php
printf abcdefghijklmnopqrstuvwxyzqwertyuiopasdfghjklzxcvbnmpyfgcrlaoeuidhtnsqjkxbmwvzzyxwvutsrqponmlkjihgfedcba | base64 -d >> 4times.php
printf '");' >> 4times.php


05AB1E, 16 bytes

∞.¡ÂÑgsÑg.S}¦ζsè

Try it online!

0-indexed [rich,poor]:

∞                # Push infinite list.
 .¡        }     # Split into three lists by...
   ÂÑgsÑg.S      # 1 if rich, 0 if nothing, -1 if poor.
            ¦ζ   # Remove list of nothings, and zip rich/poor together.
              sè # Grab nth element.

Maybe someone can explain why this version doesn't seem to terminate, but when I click "cancel execution" on TIO it finishes with the correct answer, or if you wait 60 seconds you get the correct answer. For a version that terminates "correctly" you could use: T+nL.¡ÂÑgsÑg.S}¦ζsè +3 bytes


Make the most useful program within 100 characters

C - 47 bytes

The following program outputs every document ever written in human history, along with every document that will ever be written and loads of interesting texts that no human will ever come up with (along with a "little bit" of garbage in between). Just give it some time. Moreover, every time you run it, it will output different texts first! If that's not useful! (And all of that within half the character limit!)

main(){srand(time(0));while(1)putchar(rand());}

If you don't care about it outputting something else each time, you only need 41 bytes!

main(){srand(0);while(1)putchar(rand());}

Not quite C99 conform, but it compiles smoothly with gcc.exe (GCC) 4.7.0 20111220.

The rules state

  Your program may be as slow as you want, and use as much resources as you want, as long you can prove it does what it meant to do.

No problem.

Some things, this program will output:

a solution to every Millennium Problem
tomorrow's newspaper articles
the complete works of Shakespeare's (of course)
your darkest secret
all the other answers to this question

   Not really, because (as ace correctly mentioned in the comment), rand() is only a pseudo-random generator, that will wrap around at some point - probably way too early to produce a lot of meaningful texts. But I doubt that getting data from a true (hardware) random number generator is remotely possible within 100 characters. I'll leave this here for the fun of it, though.

As Dennis notes, the randomness of the the algorithm, could be somewhat improved (within the character limit), by using rand()^rand()>>16 instead of rand().


Calculate probability of getting half as many heads as coin tosses.

Cops entry (posted by Conor O'Brien): https://codegolf.stackexchange.com/a/100521/8927

Original question: Calculate probability of getting half as many heads as coin tosses.

The posted solution had a couple of obfuscation techniques applied, followed by multiple layers of the same obfuscation technique. Once past the first few tricks, it became a simple (if tedious!) task to extract the actual function:

nCr(a,b) = a! / ((a-b)! * b!)
result = nCr(x, x/2) / 2^x

Took a while to realise what I was looking at (for a while I suspected something to do with entropy), but once it twigged, I managed to find the question easily by searching for "probability of coin toss".

Since Conor O'Brien challenged an in-depth explanation of his code, here's a rundown of the more interesting bits:

It starts by obfuscating some built-in function calls. This is achieved by base-32 encoding the function names, then assigning them to new global-namespace names of a single character. Only 'atob' is actually used; the other 2 are just red-herrings (eval takes the same shorthand as atob, only to be overridden, and btoa simply isn't used).

_=this;
[
    490837, // eval -> U="undefined"       -> u(x) = eval(x) (but overwritten below), y = eval
    358155, // atob -> U="function (M,..." -> u(x) = atob(x)
    390922  // btoa -> U="function (M,..." -> n(x) = btoa(x), U[10] = 'M'
].map(
    y=function(M,i){
        return _[(U=y+"")[i]] = _[M.toString(2<<2<<2)]
    }
);

Next there are a couple of trivial string mix-ups to hide the code. These are easily reversed:

u(["","GQ9ZygiYTwyPzE6YSpk","C0tYSki","SkoYSkvZChhLWIpL2QoYikg"].join("K"))
// becomes
'(d=g("a<2?1:a*d(--a)"))(a)/d(a-b)/d(b) '

u("KScpKWIsYShFLCliLGEoQyhEJyhnLGM9RSxiPUQsYT1D").split("").reverse().join("")
// becomes
"C=a,D=b,E=c,g('D(C(a,b),E(a,b))')"

The bulk of the obfuscation is the use of the g function, which simply defines new functions. This is applied recursively, with functions returning new functions, or requiring functions as parameters, but eventually simplifies right down. The most interesting function to come out of this is:

function e(a,b){ // a! / ((a-b)! * b!) = nCr
    d=function(a){return a<2?1:a*d(--a)} // Factorial
    return d(a)/d(a-b)/d(b)
}

There's also a final trick with this line:

U[10]+[![]+[]][+[]][++[+[]][+[]]]+[!+[]+[]][+[]][+[]]+17..toString(2<<2<<2)
// U = "function (M,i"..., so U[10] = 'M'. The rest just evaluates to "ath", so this just reads "Math"

Although since the next bit is ".pow(T,a)", it was always pretty likely that it would have to be "Math"!

The steps I took along the route of expanding functions were:

// Minimal substitutions:
function g(s){return Function("a","b","c","return "+s)};
function e(a,b,c){return (d=g("a<2?1:a*d(--a)"))(a)/d(a-b)/d(b)}
function h(a,b,c){return A=a,B=b,g('A(a,B(a))')}
function j(a,b,c){return a/b}
function L(a,b,c){return Z=a,Y=b,g('Z(a,Y)')}
k=L(j,T=2);
function F(a,b,c){return C=a,D=b,E=c,g('D(C(a,b),E(a,b))')}
RESULT=F(
    h(e,k),
    j,
    function(a,b,c){return _['Math'].pow(T,a)}
);

// First pass
function e(a,b){
    d=function(a){return a<2?1:a*d(--a)}
    return d(a)/d(a-b)/d(b)
}
function h(a,b){
    A=a
    B=b
    return function(a){
        return A(a,B(a))
    }
}
function j(a,b){ // ratio function
    return a/b
}
function L(a,b){ // binding function (binds param b)
    Z=a
    Y=b
    return function(a){
        return Z(a,Y)
    }
}
T=2; // Number of states the coin can take
k=L(j,T); // function to calculate number of heads required for fairness
function F(a,b,c){
    C=a
    D=b
    E=c
    return function(a,b,c){return D(C(a,b),E(a,b))}
}
RESULT=F(
    h(e,k),
    j,
    function(a){return Math.pow(T,a)}
);

// Second pass
function e(a,b){...}
function k(a){
    return a/2
}
function F(a,b,c){
    C=a
    D=b
    E=c
    return function(a,b,c){return D(C(a,b),E(a,b))}
}
RESULT=F(
    function(a){
        return e(a,k(a))
    },
    function(a,b){
        return a/b
    },
    function(a){return Math.pow(2,a)}
);

// Third pass
function e(a,b) {...}
C=function(a){ // nCr(x,x/2) function
    return e(a,a/2)
}
D=function(a,b){ // ratio function
    return a/b
}
E=function(a){return Math.pow(2,a)} // 2^x function
RESULT=function(a,b,c){
    return D(C(a,b),E(a,b))
}

The structure of the function nesting is based around utility; the outer-most "D" / "j" function calculates a ratio, then the inner "C" / "h" and "E" (inline) functions calculate the necessary coin flip counts. The "F" function, removed in the third pass, is responsible for connecting these together into a usable whole. Similarly the "k" function is responsible for choosing the number of heads which need to be observed; a task which it delegates to the ratio function "D"/"j" via the parameter binding function "L"; used here to fix parameter b to T (here always 2, being the number of states the coin can take).

In the end, we get:

function e(a,b){ // a! / ((a-b)! * b!)
    d=function(a){return a<2?1:a*d(--a)} // Factorial
    return d(a)/d(a-b)/d(b)
}
RESULT=function(a){
    return e(a, a/2) / Math.pow(2,a)
}


Python 3, 167 bytes, produces Python 3.0, 3.1, ..., 3.9, 3.10, \${167 \over 11^2}\approx1.38\$
thanks to SuperStormer for refreshing my memory, allowing to add 3.10.

lambda r:'try:exec("%s");o=%d\nexcept:0\n'*10%sum(zip("0;int.bit_length;callable;u'';import enum;b''%();f'';breakpoint;(a:=0);{}|{}".split(';'),r),())+'print(o)'

Try it online!
This works by trying to evaluate expressions code that rely on new language features and updating the output value if successful. By including more subversions, the score could probably be decreased by quite a bit.

Version
Code
New Language feature

3.1
int.bit_length
New builtin

3.2
callable
New builtin

3.3
u''
Old syntax for unicode strings re-added from Python 2

3.4
import enum
New module called enum

3.5
b''%()
String formatting with % for bytes objects

3.6
f''
f-strings

3.7
breakpoint
New builtin function

3.8
(a:=0)
Assignment expressions

3.9
{}|{}
Dictionary union with |

3.10
a:x=0
postponed evaluation of annotations is now enabled by default


Python - 65535

http://ideone.com/knKRhn

from math import exp, log

def divnr(p, q):
  """
    Integer division p/q using Newton-Raphson Division.
    Assumes p > q > 0.
  """

  sp = p.bit_length()-1
  sq = q.bit_length()-1
  sr = sp - sq + 1

  s = []
  t = sr
  while t > 15:
    s = [t] + s
    t = (t>>1) + 1
  # Base-case division
  r = (1 << (t<<1)) / (q >> sq-t)

  for u in s:
    r = (r << u-t+1) - (r*r * (q >> sq-u) >> (t<<1))
    t = u
  return (r * (p >> sq)) >> sr

def pibs(a, b):
  if a == b:
    if a == 0:
      return (1, 1, 1123)
    p = a*(a*(32*a-48)+22)-3
    q = a*a*a*24893568
    t = 21460*a+1123
    return (p, -q, p*t)
  m = (a+b) >> 1
  p1, q1, t1 = pibs(a, m)
  p2, q2, t2 = pibs(m+1, b)
  return (p1*p2, q1*q2, q2*t1 + p1*t2)

def ebs(a, b):
  if a == b:
    if a == 0:
      return (1, 1)
    return (1, a)
  m = (a+b) >> 1
  p1, q1 = ebs(a, m)
  p2, q2 = ebs(m+1, b)
  return (p1*q2+p2, q1*q2)

if __name__ == '__main__':
  n = input()

  pi_terms = int(n*0.16975227728583067)

  # 10^n == e^p
  p = n*2.3025850929940457

  # Lambert W_0(p/e) a la Newton
  k = log(p) - 1
  w = k - (k-1)/(k+1)
  while k > w:
    k = w
    w -= (k - p*exp(-k-1))/(k+1)

  # InverseGamma(e^p) approximation
  e_terms = int(p / w)

  pp, pq, pt = pibs(0, pi_terms)
  ep, eq = ebs(0, e_terms)

  z = 10**n
  p = 3528*z*ep*abs(pq)
  q = eq*abs(pt)

  pie = divnr(p, q)
  print pie,

Ideone doesn't seem to have gmpy2 installed, which is unfortunate for at least two reasons. One, because it would make the calcuation a lot faster, and two, because it makes any formula requiring an arbitrary precision square root impractical.

The formula I use for π was listed by Ramanujan as Formula (39):

which converges at the rate of ~5.89 digits per term. To my knowledge, this is the fastest converging series of its kind that doesn't require the evaluation of an arbitrary precision square root. Formula (44) in the same paper (convergence rate ~7.98 digits per term) is most often referred to as the Ramanujan Formula.

The formula I use for e is the sum of inverse factorials. The number of terms required is calculated as Γ-1(10n), using an approximation I found on mathoverflow. The Lambert W0 component is found using Newton's Method.

The calculation of each of these summations is done via the Fast E-function Evalution (more generally known as binary-splitting), originally devised by Karatsuba. The method reduces a summation to n terms to a single rational value p/q. These two values are then multiplied to produce the final result.

Update:
Profiling revealed that over half of the time needed for the calculation was spent in the final division. Only the upper most log2(10n) bits of q are needed to obtain full precision, so I trim a few off beforehand. The code now fills the Ideone output buffer in 3.33s.

Update 2:
Since this is an optimization challenge, I decided to write my own division routine to combat CPython's slowness. The implementation of divnr above uses Newton-Raphson Division. The general idea is to calculate d = 1/q · 2n using Newton's Method, where n is the number of bits the result requires, and compute the result as p · d >> n. Runtime is now 2.87s - and this is without even chopping off bits before the calculation; it's unnecessary for this method.


JavaScript (E6) 97.5 (39*5*0.5)

(O(n), linear search, the array can be scrambled again and again)
The function accepts (and ignores) a third parameter

F=(a,x)=>a.map((e,i)=>e-x?0:j=i,j=-1)|j

or

F=(a,x)=>a.some((e,i)=>(j=i,e==x))?j:-1

or

F=(a,x)=>a.every((e,i)=>(j=i,e-x))?-1:j

Test in FireFox/FireBug console

F([5, 2, 3, 4, -1, 6, 90, 80, 70, 100],-1, 2)

Output

4


Bash

watch -tn.1 date +%T\|figlet

Yeah, yeah, I know it's not golf (28 bytes!), but I do like the minimalism:

watch is a tool provided by the procps package that repeatedly runs a command every <specified interval of time> and outputs the updated results. (An example of where this is handy: watch -n.1 ls -lh ~/downloads/foo to view the progress of a download.)

The -t flag for watch represents --no-title, as otherwise it would look like this:

The -n 0.1 flag simply means "update every 0.1 seconds."

Then comes the command that we're watching over. First, date +%T prints the date in the desired format (date comes from coreutils):

       %T     time; same as %H:%M:%S

Then this is piped to figlet (unsurprisingly provided by the figlet package), which converts STDIN to ASCII art.

(|  |  _            _   _,            _|   _
 |  | / \_|  |     /   / |  /|/|     / |  / \_
  \/|/\_/  \/|_/   \__/\/|_/ | |_/   \/|_/\_/
   (|

             _/  _/                                      _/
    _/_/_/  _/  _/        _/_/_/    _/_/    _/  _/_/  _/_/_/_/    _/_/_/
 _/    _/  _/  _/      _/_/      _/    _/  _/_/        _/      _/_/
_/    _/  _/  _/          _/_/  _/    _/  _/          _/          _/_/
 _/_/_/  _/  _/      _/_/_/      _/_/    _/            _/_/  _/_/_/

        _|                   |    |   |    _)
  _ \  |    __ \   _ \  _` | __|  __| __ \  | __ \   _` |  __|
 (   | __|  |   |  __/ (   | |    |   | | | | |   | (   |\__ \
\___/ _|   _|  _|\___|\__,_|\__| \__|_| |_|_|_|  _|\__, |____/
                                                   |___/
                       _
    o_|_|_  _|_|_  _  |_o _ | __|_ ._ .__  _ .__.._ _
\/\/| |_| |  |_| |(/_ | |(_||(/_|_ |_)|(_)(_||(_|| | |o
                          _|       |       _|


Python 2, 68 bytes

One of the few cases where itertools is useful.

lambda b,a:s(b)in map(s,product(*a))
s=sorted
from itertools import*

Try it online!


MATL, 16 bytes

Zv3L)t?yn:)2$S}i

Try it online! Or verify all test cases.

Explanation

Consider inputs 5, 'programmingpuzzles'.

Zv     % Input, implicit: number n. Symmetric range
       % STACK: [1 2 3 4 5 4 3 2 1]
3L     % Push [1 -1+1j]. When used as an index, this means 1:end-1
       % STACK: [1 2 3 4 5 4 3 2 1], [1 -1+1j]
)      % Index. Removes last element
       % STACK: [1 2 3 4 5 4 3 2]
t      % Duplicate
       % STACK: [1 2 3 4 5 4 3 2], [1 2 3 4 5 4 3 2]
?      %   If non-empty and non-zero
       %   STACK: [1 2 3 4 5 4 3 2]
  y    %   Implict input: string s. Duplicate from below
       %   STACK: 'programmingpuzzles', [1 2 3 4 5 4 3 2], 'programmingpuzzles'
  n    %   Number of elements
       %   STACK: 'programmingpuzzles', [1 2 3 4 5 4 3 2], 18
  :    %   Range
       %   STACK: 'programmingpuzzles', [1 2 3 4 5 4 3 2], [1 2 3 ··· 17 18]
  )    %   Index modularly
       %   STACK: 'programmingpuzzles', [1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2]
  2$S  %   Two-input sort: stably sorts first input as given by the second
       %   STACK: 'piermnlsomgzgapzru'
}      % Else. This branch is entered when n=1. The stack contains an empty array
       %   STACK: []
  i    %   Take input
       %   STACK: [], [], 'programmingpuzzles'
       % End, implicit
       % Display stack, implicit. Empty arrays are not displayed


MATLAB - 114 129 bytes
function n=c(m)
n=rref(m);l=size(n,1);for i=1:l
e=1.5+.5*(-1)^i:2:l;N=n(e,:);n(e,:)=N+repmat(n(i,:),length(e),1).*max(N).^2;end

Try it online
For a given nxm matrix, there are three forms of the rref of the matrix.

The identity matrix (with optional all-zero columns) (m>=n)
Full rank matrix where columns that do not contain a row-leading 1 can have any value (m>n)
Identity matrix with zero rows on the bottom (m<n)

1 and 3 are easily made into a checkerboard by looping through each row and adding every odd/even row (which would have the 1s in the appropriate places)
for 2, however, it is impossible to make a checkerboard matrix unless the matrix is already a checkerboard. This is because the columns that have nonzero values can never be reduced because there is no column with a row-leading 1, and any ERO would add a value in another space that would ruin the checkerboard pattern. I'm certain there's a more rigorous explanation but linear algebra is not easy.


Super fast sampling from a tricky random distribution

GMPY2
Abuse of GMP. @OP the slowest part of the code is printing the numbers, if leaving them in memory is fine the code would be much much faster.
import math
import random
import gmpy2
from gmpy2 import mpz, mpfr

gmpy2.get_context().precision = 11 # 32 bits of accuracy

N = 100000000
random_state = gmpy2.random_state()
pi = math.pi
half_pi = pi / 2
size = 0
for i in range(N):
    u1 = gmpy2.mpfr_random(random_state)
    u2 = gmpy2.mpfr_random(random_state)
    w1 = gmpy2.mul(pi, gmpy2.sub(u1,1/2))
    w2 = -gmpy2.log(u2)
    a = gmpy2.mul(gmpy2.tan(w1), gmpy2.sub(half_pi, w1))
    b = gmpy2.div(gmpy2.log(gmpy2.mul(w2, gmpy2.cos(w1))), gmpy2.sub(half_pi, w1))
    x = gmpy2.add(a, b)


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.


J (73 68 58 41 39 38 35 34 characters)

After thinking about the problem for some time, I found an entirely different way to generate the Devil's Staircase pattern. The old answer including its explanation has been removed, you can look into the revisions of this answer to figure out how it was.

This answer returns an array of blanks and sharps, representing the devil's staircase.

' #'{~1(]|.@=@#~[:,3^q:)2}.@i.@^>:

Here is the answer split into its two parts in explicit notation:

f =: 3 : '|. = (, 3 ^ 1 q: y) # y'
g =: 3 : '(f }. i. 2 ^ >: y) { '' #'''

Explanation

The approach is a bit different, so observe and be amazed.

>: 3 – three incremented, that is,

4

2 ^ >: 3 – two to the power of three incremented, that is,

16

i. 2 ^ >: 3 – the first 2 ^ >: 3 integers, that is,

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

}. i. 2 ^ 4 – the first 2 ^ >: 3 integers, beheaded, that is,

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Let's call this sequence s; we enter f now.
1 q: s – the exponents of 2 in the prime decomposition of each item of s. In general, x q: y yields a table of the exponents for the first x primes in the prime decomposition of y. This yields:

0
1
0
2
0
1
0
3
0
1
0
2
0
1
0

3 ^ 1 q: s – three to the power of these exponents, that is,

 1
 3
 1
 9
 1
 3
 1
27
 1
 3
 1
 9
 1
 3
 1

, 3 ^ 1 q: s – the ravel (that is, the argument with it's structure collapsed into a vector) of the previous result. This is needed because q: introduces an unwanted trailing axis. This yields

 1 3 1 9 1 3 1 27 1 3 1 9 1 3 1

(, 3 ^ 1 q: s) # s – each item of s replicated as often as the corresponding item in the previous result, that is,

1 2 2 2 3 4 4 4 4 4 4 4 4 4 5 6 6 6 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 10 10 10 11 12 12 12 12 12 12 12 12 12 13 14 14 14 15

= (, 3 ^ 1 q: s) # s – the self classification of the previous result, this is, a matrix where each row represents one of the unique items of the argument, each column represents the corresponding item of the argument and each cell represents whether the items of row and column are equal, that is,

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

|. = (, 3 ^ 1 q: s) # s – the previous result flipped along the vertical axis.
(|. = (, 3 ^ 1 q: s) # s) { ' #' – the items of the previous result used as indices into the array ' #', so 0 is replaced by   and 1 is replaced by #, that is,

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

the result we want.


CJam, 11 keystrokes

The code is

"HELP*")9-

and the keylist is

Shift"HELP*") release shift 9-

and here is a demonstration of how it looks:

and here is how the code works:

"HELP*"              "This puts the string HELP* on stack";
       )             "This takes out the last character of the string and puts it
                      on the stack as a character";
        9-           "This simply reduces 9 from the ASCII code of * character
                      present on the stack which makes it an !";
                     "CJam automatically prints everything that is on stack";

Try the code here


OSX + Bash + smcFanControl, 91 bytes
This relies on the third-party smcFanControl suite to do the hard work and is therefore more of a proof-of-concept than a serious answer.  Real answers could pick apart the smcFanControl source code and do this without third-party help.
smcFanControl.app is assumed to be installed in /Applications.
p=/Ap*/smcFan*/C*/R*/smc\ -k # Path to CLI utility
f()($p'FS! ' -w000$1)        # function to set fan mode
f 3                          # Set fan speeds to "forced" mode
eval $p\ F{0,1}"Tg -w5DC0;"  # Set fan 1 and 2 to 6000 RPM target speed
read                         # wait for keyboard input
f 0                          # Return fans to "auto" mode

Comments added for explanation, but not included in score.


Pyth, 24 20 19 18 bytes
FN.z+*ZC9N~Z-1/N\)

Increments a counter for every line, counts total number of closing parentheses encountered so far, and subtracts it from the counter. Then we indent by counter tabs.


Python 2, 84 80 78 76 bytes

lambda a:[''.join(sorted(a,key=lambda s:'.'in s or s+s)[::i])for i in[-1,1]]

Try it online!

-2 bytes, thanks to Arnauld


Convert a string of binary characters to the ASCII equivalents

JavaScript (ES6) 49 55 56 64
s.replace(/\d+./g,x=>String.fromCharCode('0b'+x))

Edit Accepting @bebe suggestion - thanks
Edit2 Didn't know about binary numeric literal - thanks @kapep
Edit3 Wow 6 not 4 bytes saved thx @ETHproductions
Explanation as requested in comments
String.replace can take 2 arguments:

regular expression /\d+./g : one or more digits followed by one different character - the g flag specify to search the pattern more than once
a function, here specified in arrow format, where the argument (x) wil be the found string (the sequence of digits eventually followed by a space) and the value of the function is what is replaced (in this case, the single character from the code).

It's worth noting that the at the end of the string the regexp matches the sequence of digits without a trailing space, in this case the dot matches the last digit. Try '123'.match(/(\d+)./) to verify.
(Still) one of the more verbose pieces of javascript ever...
(Assignment to string s not counted)

var s='1001000 1100101 1101100 1101100 1101111 100000 1010111 1101111 1110010 1101100 1100100'
var x=
s.replace(/\d+./g,x=>String.fromCharCode('0b'+x))

console.log(x)


Compute the Digit Difference Sum of a Number

Python 2, 73
Luckily, I managed to avoid any string operations.
t=lambda n:n>9and abs(n%10-n/10%10)+10*t(n/10)
g=lambda n:n and n+g(t(n))

g is the function that computes the answer.


Golf some quine stripes in different languages