Pyth - 39 bytes
This is a monstrous combination of regexp and eval. I like the approach, but will try to improve the implementation.
It uses the Polynomial Remainder Theorem.
K_sPe:z"-|\+"3!v.ssXPtw,\^\x,"**""*K"\*

Doesn't work online because of eval use.


Pyth, 44 42

ItQpdd*\_*4/Q2)jbms<*dQhQ,c" /\ "2,\/"__\\

The first line:

ItQpdd*\_*4/Q2)
ItQ           )    If the input is not 1
   pdd             Print two spaces
      *\_*4/Q2     Then groups of 4 underscores, repeated input/2 times.

The other two lines are generated by noticing that the second line consists of " /" and "\ " alternating input + 1 times, and the third line consists of "/" and "__\" alternated in the same fashion.


The Fx Expression Language (ImageMagick), 8 4 bytes
EDITS

Simplified to u!=v, -4 bytes

As "Fx Expression Language" is apparently Turing complete, I've re-profiled my answer to it (was Unix Shell + Image Magick).
Golfed
u!=v

Fx does not support bitwise XOR nor bitwise NOT, so I've used != instead (which works just fine for the pure BW images).
u=> stands for "first image in list"
v=> "second image in list"

Input and output are implicit (controlled by the interpreter).
Usage
ImageMagick convert utility, serves as the "Fx Expression Language" interpreter, when invoked with -fx, as illustrated below:
convert $1 $2 -fx u!=v $3

The arguments are:

Input image A
Input image B
Output image O (A^B).

Sample output
convert a.png b.png -fx u!=v o.png


Ruby 1.9+, 73 characters

I see the no-regex rule as silly and arbitrary, so here's a spiteful regex based solution:

gets
($.+=1;puts$_.gsub!(/(.)(.)/){$2*$1.to_i})until~/^(22)*[12]?$/
p~-$.

Test run:

$ ruby 21.rb <<< 122122122121212212
211222111111222
11222111222
122111222
2111222
111222
1222
222
7

The last line is the number of steps.

Edit: Regex restriction has been removed by Vereos.


Python 2, 39 bytes

f=lambda n:n>9and 10*f(n/10)or 5>>5/-~n

Try it online!


Mathematica, 39 bytes
Count[Union@@FactorInteger@#,_?PrimeQ]&

Try it online!
thanks to Martin Ender (-11 bytes)


Python 2, 183 94 bytes

-4 bytes thanks to Artyer (use input() and print rather than def and return)
-1 byte thanks to FlipTack (use print-~p[0] rather than print p[0]+1)

p=range(input())
d=i=1
while p[1:]:m=p.pop(i)%2;i-=m+m-(d<0);d=-m|1;i+=d;i%=len(p)
print-~p[0]

repl.it

This just follows the instructions given, I've noticed some pattern, maybe it could be exploited?

The only changes are:

to use 0 based indexing (so even people are odd and vice-versa) - this is saves 5 bytes in the golfed logic and is corrected at the end with +1
to use 1 as left and -1 as right (to use a range - just like everyone is facing outwards instead)
to change the logic of the step where the next chosen individual is found to account for poping from the list making the "pointer" index already step one to the right in the list (or to the left in original terminology).

Ungolfed:

def circle(n):
    people = range(n) # p
    direction = 1 # d
    removeIndex = 1 # i
    while n > 1:
        removingMod2 = people.pop(removeIndex) % 2 # m
        removeIndex -= removingMod2 + removingMod2 - (direction == -1)
        direction = -removingMod2 or 1
        removeIndex += direction
        n -= 1
        removeIndex %= n
    return people[0] + 1


Triangular battleships (A computational geometry problem)

Python 3, 252 bytes

This is certainly the most variables I've ever used in code golf. :^P

from math import*;A=atan2
def h(a,b,c,d,e,f,g,h,i,j,R):
 r=R;_=0
 while r>0:Q=A(j-h,i-g);k,l=g+r*cos(Q),h+r*sin(Q);D=A(d-b,c-a);E=A(f-b,e-a);F=A(l-b,k-a);G=A(b-d,a-c);H=A(f-d,e-c);I=A(l-d,k-c);_=_ or(D<F<E or E<F<D)and(G<I<H or H<I<G);r-=.001
 return _

Slightly ungolfed, with comments:

from math import*
# Parameters:
#  (a,b) (c,d) (e,f) - vertices of the triangle
#  (g,h) - location of cannon
#  (i,j) - aim of cannon
#  R - range of cannon
# Variables within function:
#  _ - was this shot a hit?
#  r - distance 0 < r <= R that we're testing
#  Q - angle between cannon source and destination
#  (k,l) - point that we're testing
#  D,E,F - angles between point 1 and 2,3,test
#  G,H,I - angles between point 2 and 1,3,test
def h(a,b,c,d,e,f,g,h,i,j,R):
    r=R;_=0
    while r>0:
        Q=atan2(j-h,i-g)
        k,l=g+r*cos(Q),h+r*sin(Q)
        D=atan2(d-b,c-a)
        E=atan2(f-b,e-a)
        F=atan2(l-b,k-a)
        G=atan2(b-d,a-c)
        H=atan2(f-d,e-c)
        I=atan2(l-d,k-c)
        _=_ or(D<F<E or E<F<D)and(G<I<H or H<I<G)
        r-=.001
    return _

How it works:

Calculate the endpoint of the shot.
Test lots of points along the line from the endpoint to the cannon's location:

Calculate angles from vertex 1 to other two vertices and to test point;
Calculate angles from vertex 2 to other two vertices and to test point;
If the test point angle is between the other two angles, in both cases, then the test point is within the triangle and the ship has been hit.

Sample runs:

>>> h(0,0,0,1,1,0,1,1,0,0,2)
True
>>> h(0,0,1,2,3,0,-4,0,0,0,8)
False
>>> h(0,0,-1,3,4,-1,-3,-4,3,4,5)
False
>>> h(-2,-3,-3,6,7,-2,-6,2,1,-4,7)
True


Jelly, 33 bytes

<⁽¡ð,769FẠ
Ḋs2Zr/€p/;€Ḣµ€ẎµQL⁼LȧÇ

A monadic link taking a list of lists of the window-data and returning 0 if any windows exceed their monitor's space or overlap, or 1 otherwise.

Uses 1-indexed monitor IDs; 1,1 to 1024,768 inclusive are considered on-screen.

Try it online! (Too slow for the first two test cases! Typical golf :))

How?

The reason this is so slow is because it creates all the pixels for all the windows, each with its monitor ID and checks for overlap using de-duplication (which is implemented using lists not sets). It also checks each pixel is on-screen rather than checking just the input corners. All in all very inefficient...

Test-case 1 succeeded (1) locally in only eleven minutes! Test-case 2 succeeded (0) in less.

<⁽¡ð,769FẠ - Link 1 check pixels are on-screen: list of lists, each being [x,y,ID]
 ⁽¡ð       - literal base-250 integer = 1025
    ,769   - pair with literal 769
<          - less than (vectorises) -> [[x<1025, y<769, ID],...]
        F  - flatten into a single list
         Ạ - all truthy?

Ḋs2Zr/€p/;€Ḣµ€ẎµQL⁼LȧÇ - Main link: list of lists, each being [ID,Lx,By,Rx,Ty]
            µ€         - for €ach window:
Ḋ                      -   dequeue -> [Lx,By,Rx,Ty]
 s2                    -   split into twos -> [[Lx,By],[Rx,Ty]]
   Z                   -   transpose -> [[Lx,Rx],[By,Ty]]
     /€                -   reduce €ach with:
    r                  -     inclusive range -> [[Lx,...,Rx],[By,...,Ty]]
        /              -   reduce with:
       p               -     Cartesian product -> all pixels, [[Lx,By],[Lx,By+1],...[Lx,Ty],[Lx+1,By],... ...[Rx,Ty]]
           Ḣ           -   head -> ID
         ;€            -   concatenate each pixel with the monitor ID
              Ẏ        - tighten -> one list of all window's [x,y,ID] values
               µ       - monadic chain separation, call that w
                Q      - deduplicate (unique [x,y,ID] values)
                 L     - length
                   L   - length of w
                  ⁼    - equal?
                     Ç - call last link (1) as a monad (all on-screen?)
                    ȧ  - logical and


Shortest simple regex matching a binary word

JavaScript (ES6), 488 341 bytes

s=>[s.replace(/(.)\1+/g,'$1+'),...[...Array(60)].map((_,i)=>`(${(i+4).toString(2).slice(1)})+`),...[...Array(1536)].map((_,i)=>`${i>>10?(i>>8&1)+(i&2?'+':''):''}(${i&1}${i&4?i>>4&1:i&16?'+':''}${i&8?''+(i>>7&1)+(i&64?i>>5&1:i&32?'+':''):''})+${i&512?(i>>8&1)+(i&2?'+':''):''}`)].filter(r=>s.match(`^${r}$`)).sort((a,b)=>a.length-b.length)[0]

Explanation: Since six regexes can express all possible binary words, and the longest two are nine characters long, it suffices to check those and all shorter regexes. One candidate is obviously the string with "run length encoding" (i.e. all digit runs replaced with appropriate +s), but also strings with one set of ()s need to be checked. I generate 1596 such regexes (this includes duplicates and useless regexes but they'll just be eliminated) and test all 1597 to see which is the shortest match. The generated regexes fall into two types: \(\d{2,5}\)\+ (60 regexes) and (\d\+?)?\(\d[\d+]?(\d[\d+]?)?\)(\d\+?)? (1536 regexes as I avoid generating regexes with both leading and trailing digit).


Jelly,  26  24 bytes

d64d1¦27Fża¥“csi”Fḟ0ȯ⁾0i

A full program taking the number and printing the result.
It does seem too long to me...

Try it online! or see the test suite.

How?

updating...

d64d1¦27Fża¥“csi”Fḟ0ȯ⁾0i - Main link: number n
 64                      - literal 64
d                        - divmod (whole divisions and remainder)
      27                 - literal 27
    1¦                   - apply to index 1 (the whole division from above)
   d                     - divmod
        F                - flatten into a single list (of three items i.e. [(n/64)/27, (n/64)%27, n%64]
            “csi”        - literal ['c','s','i']
           ¥             - last two links as a dyad:
         ż               -   zip
          a              -   logical and (any 0s in the divmod result become [0,0], others become [integer, character]
                 F       - flatten (from list of three lists to one list)
                  ḟ0     - filter discard zeros
                     ⁾0i - literal ['0','i']
                    ȯ    - logical or (non-vectorising)
                         - implicit print (smashed together representation, so [578703,'c',19,'i'] prints as 578703c19i)


Python3, 861 821 819 714 678 674 670 662 661 658 596 591 561 555 551 536 bytes.
-8 bytes thanks to @DestructibleLemon (b=a+... and d=B...), -15 bytes thanks to @Felipe Nardi Batista (useless lambda and variable)
And thanks to everyone over in chat who helped golf this!
from random import*
C=choice
Z='000'
A='AAA'
B=A+'-0'+Z
a=A+' '+Z
b=A+'0'+Z
c=a[::-1]
d=B[1:]
print(C(''.join(C(['ABCDEFGHJKLMNPRSTUVWXYZ','0123456789',i]['A0'.find(i)])for i in([a]*5+[Z+'0',b,b,b]+[c]*6+['0'+A+Z,d,d+'0',A+' A00','AA 00'+Z,Z+'A,000AA,000AAA,'+A+Z,'0AA0'+Z,a+'0,0AA A00,'+a,Z+'-'+A,'00A-'+A,Z+' 0'+Z,'A00-'+A,Z+'-AAA,AAA-'+Z]+[B]*6+[a+'0',Z+A,B[:-1],Z+'-'+Z,a+','+c,'A00-00A','A00 0AA'])[[*zip('AIMMVAAGWAKKLNOCDCFIIMMMNNNNNNPTVWOOPRSTU','KASPTSZAARSYADRACTLLNDINVHJMYCAXAIHKRICNT')].index(tuple(input()))]).split(',')))

Try it online
Any golfing suggestions are welcome (and wanted). And, please, if you spot any errors, just tell me via the comments!


SED, 45 (43 + 2 for the -n flag)

s/./a/g
h
n
s/./b/g
G
:a
s/b\(.*\)a/\1/
ta

Expects input as two separate lines, outputs the difference in unary, using "a" or "b" to indicate the longer string. run with sed -n.


JavaScript (ES6), 55 bytes
Method #1: the cache overwrites the input
Takes input in currying syntax (cache_size)(list).

n=>a=>a.map(x=>a[a.indexOf(x,k>n&&k-n)<k||k++]=x,k=0)|k

Try it online!
How?
We overwrite the input array a[ ] with the cache, using a separate pointer k initialized to 0.
We use a.indexOf(x, k > n && k - n) < k to test whether x is in the cache.
The cache can't grow faster than the original array is walked through, so each value is guaranteed to be found, either within or beyond the cache window (i.e. indexOf() will never return -1).
A value is in the cache if it is found at an index between max(0, k - n) and k - 1 (both bounds included), in which case we do a[true] = x. This only affects a property of the underlying object behind a[ ] but does not alter the array a[ ]. Otherwise, we do a[k++] = x.
Example
Below are the different steps for the input [1, 1, 2, 3, 3, 2, 1, 4] with a cache size of 2:

bold borders: map() pointer
brackets: cache pointer k
orange: current cache window
yellow: expired cache values

JavaScript (ES6), 57 bytes
Method #2: the cache is appended at the end of the input
Takes input in currying syntax (cache_size)(list).
n=>a=>a.map(x=>n*~a.indexOf(~x,-n)||a.push(~x)&k++,k=0)|k

Try it online!
How?
Because the input array a[ ] is guaranteed to contain non-negative integers, we can safely append the cache at the end of a[ ] by using the one-complement ~x of each value x.
We use n * ~a.indexOf(~x, -n) to test whether ~x is found among the last n values. Whenever this test fails, we append ~x to a[ ] and increment the number of misses k.
Example
Below are the different steps for the same example as above, using this method. Because cache values are simply appended at the end of the array, there is no explicit cache pointer.


Calculate the middle number of a row of the pascal triangle

Ohm, 6 bytes

½⌠Ddac

Try it online!

If the number is even it is you calculate (n n/2) if it is odd (n+1 (n+1)/2)

         Inplicit input
½        Half
 ⌠       Ceil
  D      Duplicate on stack
   d     x2
    a    Swap on stack
     c   Binomial


Jelly,  18 17  16 bytes
I believe there is a lot of potential for this effort to be out-golfed
L‘HạŒỤṀ€IṠQṢ«FE$

A monadic link accepting a list of lists of numbers which returns a list of integers:
Concave ->  [0, 0]
Flat    ->  [-1, 0, 1]
Convex  ->  [-1, 0]
Mixed   ->  [-1, 0, 0]

Try it online! Or see the test-suite.
L‘H could be replaced with the less efficient but atomically shorter JÆm.
How?
L‘HạŒỤṀ€IṠQṢ«FE$ - Link: list of (equal length) lists of numbers
L                - length
 ‘               - increment
  H              - halve
                 -   = middle 1-based index (in both dimensions as the input is square)
    ŒỤ           - sort multi-dimensional indices by their corresponding values
                 -   = a list of pairs of 1-based indexes
   ạ             - absolute difference (vectorises)
                 -   = list of [verticalDistanceToMiddle, horizontalDistanceToMiddle] pairs
      Ṁ€         - maximum of €ach
                 -   each = N/2-k (i.e. 0 as middle ring and N/2 as outermost)
        I        - incremental deltas (e.g. [3,2,2,3,1]->[3-2,2-2,3-2,1-3]=[-1,0,1,-2])
         Ṡ       - sign (mapping -n:-1; 0:0; and +n:1)
          Q      - de-duplicate
           Ṣ     - sort
                 -   = concave:[0, 1]; convex:[-1, 0]; flatOrMixed:[-1, 0, 1]
               $ - last two links as a monad
             F   -   flatten
              E  -   all equal? (1 if flat otherwise 0)
            «    - minimum (vectorises)
                 -   = concave:[0, 0]; convex:[-1, 0]; mixed:[-1, 0, 0]; flat:[-1, 0, 1]


Cubify This! A lesson in grayscale... er... color... er... whatever

Imagemagick (108)

Version: ImageMagick 6.8.7-7 Q16 x86_64 2013-11-27

The following call:

$ convert -resize 75x75 -fx "q=p.intensity;q<1/6?#0051BA:q<2/6?#C41E3A:q<3/6?#009e60:q<4/6?#ff5800:q<5/6?#FFD500:#FFF" input output

where input and output have to be modified for the input and output filename.

I only counted the chars between -resize and #FFF", if you think this is invalid feel free to comment.

I used Lenna as image (she appeared in a Playboy, and anyone doing that should count as a Hollywood celebrity, right?)

Input:

Output:

$ convert -resize 75x75 -fx "q=p.intensity;q<1/6?#0051BA:q<2/6?#C41E3A:q<3/6?#009e60:q<4/6?#ff5800:q<5/6?#FFD500:#FFF" Lenna.png LennaRubik.png

Output enlarged:

Notes: according to the imagemagick docs you cannot have more than one conditional operator in a statement, but the call still seems to work fine, so probably this was fixed and the docs were just not updated.

Running identify on the result image (to show the colors are indeed fine):

$ identify -verbose LennaRubik.png
  (...)
  Colors: 6
  Histogram:
       338: (  0, 81,186) #0051BA srgb(0,81,186)
      1652: (  0,158, 96) #009E60 srgb(0,158,96)
      1187: (196, 30, 58) #C41E3A srgb(196,30,58)
      1674: (255, 88,  0) #FF5800 srgb(255,88,0)
       706: (255,213,  0) #FFD500 srgb(255,213,0)
        68: (255,255,255) #FFFFFF white
  (...)

If you think Lenna doesn't count as a proper celebrity, here is Bruce Willis:


Python, 60 bytes

lambda x,y:[n for n in range(1<<x+y)if bin(n).count('1')==y]

Test it on Ideone.

How it works

All positive numbers that can be represented in binary with x zeroes and y ones is clearly smaller than 2x + y, since the canonical binary representation of the latter has x + y + 1 digits.

The lambda simply iterates over the integers in [0, 2x + y) and keeps all integers n in that range that have y ones. Since n < 2x + y is can be represented with x (or less) zeroes.


Perl 6, 195 186 177 132 bytes

-41 bytes thanks to nwellnhof!

{->\b,\c{$!={!c*(b-$0.comb)/($0-1||1)+1};S:g{[(\S+)[\s|$]<?{b>=$0.ords&&.$!%%1}>]+|(\S**{b})}=$0.join(' 'x.$!).fmt("%{b*c||-b}s
")}}

Try it online!

Anonymous code block that takes input curried, e.g. f('text')(length, direction). Uses the values -1,0,1 as left, middle and right respectively.


Build the busiest beaver in x86 machine code in 32 bytes or less

2524224 instructions

My program:

_start:
        mov     bl, _end
        stc
iloop:  adc     [bx], al
        inc     bx
        jnz     iloop
        jnc     _start
        a32
        loop    _start
        hlt
_end:

(Technical note: this is written for nasm. The a32 is nasm's syntax for the alternate address-size prefix byte. For masm, you would replace the a32 with defb 0x67.)

For clarity, here's the listing output:

 1                  _start:
 2 0000 B310                mov     bl, _end
 3 0002 F9                  stc
 4 0003 1007        iloop:  adc     [bx], al
 5 0005 43                  inc     bx
 6 0006 75F9                jnz     iloop
 7 0008 73F4                jnc     _start
 8 000A 67                  a32
 9 000B E2F1                loop    _start
10 000D F4                  hlt
11                  _end:

The program assumes that the processor is in real mode, and that the program is located at the bottom of a 64k segment of memory which is otherwise initialized to all-bits-zero. Its design is simple: treat the memory as a single giant unsigned integer, and increment it through all possible values, until it rolls back around to all-zeroes. Repeat this 232 times. Then halt.

The innermost loop (lines 4‒6) is responsible for incrementing the huge integer. Each iteration adds zero or one to a single byte, depending on whether there was a carry out of the previous byte. Note that every byte in the huge integer is accessed, whether or not it has changed, so this loop always iterates 216 - 14 times.

By the way, in case you were wondering, this code illustrates the reason why the x86 inc/dec instructions don't affect the carry flag: just to simplify this sort of multi-byte carry pattern. (This pattern came up more often back in the days of 8-bit microprocessors, when the original 8080 instruction set was defined.)

Line 7 causes the incrementing process to repeat until a one is carried out of the last byte, indicating that the huge integer has been reset to all-bits-zero. This takes a long time.

Lines 8‒9 mark the outermost loop, and causes this process to repeat 232 times, until the ecx register rolls around to zero. This is effectively equivalent to adding another 32 bits to the giant integer.

It would be possible to add another outer loop and do this again using (say) the edx register, and then maybe using esi and edi for even more repetitions. However, it's not worth doing. The instructions to increment and loop require four bytes. Those four bytes are taken away from the giant integer. So we lose 32 bits on the RAM counter, just to add 32 bits via a register: it ends up being a wash. The only reason ecx is an exception is that it has a specialized loop instruction that fits into only three bytes. Thus the program trades 24 bits for 32, a tiny but still positive gain of 8 bits.

It's not too hard to directly calculate the number of instructions that the program executes before it halts. However, there's a much simpler way to estimate this number. The program modifies all of its memory, less the 14 bytes that contain the program, and the bx and ecx registers. This adds up to 216 - 14 + 2 + 4 = 65528 bytes, for a total of 524224 bits. The shortcut involves realizing that, in the process of running, every single possible pattern of 524224 bits appears exactly once. For the RAM and the ecx register this is easy to see, since the program increments through every single value. For bx this is a little less obvious, since it's being changed at the same time as the value in memory is being updated. However, one can show that, given the program's structure, if a complete bit pattern were to actually appear twice, then the program would have to be in an infinite loop. Since this is not the case, each bit pattern must ultimately be visited only once. (The complete proof is left as an exercise to the reader, naturally.)

Since every possible bit pattern appears in the course of the program, the program must execute at least 2524224 instructions, which is approximately equal to 1.4 × 10157807. (The acutal number is very slightly higher, because of the jump instructions, but the difference at this magnitude is negligible.)

Obviously, this could be significantly improved by using more than 64k of RAM. I'm holding off on the next version of the code until I figure out exactly how much RAM can be accessed.


Pyth + ///, 15 bytes - 10 = 5
pPt`S15", STOP!

This prints 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, STOP! in Pyth, by taking range(1,15+1) and stripping off the start and end brackets, and printing it immediately followed by ", STOP!".
The next fourteen programs are in ///, which directly outputs all programs that don't contain / or \. So the second program
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

gives 2 and the third program 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15. The penultimate program, 15, STOP!, prints 15, STOP!, so the last program is just STOP!.


C++ (gcc), 3.809 seconds

Compile with g++ -O3 -std=c++14.
As requested by the OP, the testcases were included in the source.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

constexpr int TESTCASES_NUM = 9;
constexpr char *TESTCASES[TESTCASES_NUM] = {"124351141512412435325", "Write a fast-growing assembly function", "And I'm now heading to the elevator", "I'm in the now infamous elevator", "1549827632458914598012734", "i was always mediocre at golfing", "tho, i like some code challenges", "I am once again in an elevator", "A person with mannerism of cat"};

int solve(char *s, int n) {
    int ans = 0;
    int i, j;
    char *p, *q, b;
    char s0[n];
    memcpy(s0, s, n);
    do {
        for(i = 0; i < n; ++i) {
            for(j = i + 1; j < n; ++j) {
                if(s[i] == s[j]) {
                    for(p = s + i + 1, q = s + j - 1; p < q; ++p, --q) {
                        b = *p;
                        *p = *q;
                        *q = b;
                    }
                    break;
                }
            }
        }
        ++ans;
    } while (memcmp(s0, s, n));
    return ans;
}

int main(int argc, char **argv) {
    for(int t = 0; t < TESTCASES_NUM; ++t) {
        char* s = TESTCASES[t];
        int  n = strlen(s);

        int count[300];
        memset(count, 0, sizeof(count));
        for(int i = 0; i < n; ++i) {
            ++count[s[i]];
        }
        char z[n];
        int m = 0;
        for(int i = 0; i < n; ++i) {
            if(count[s[i]] == 1) {
                if(i > 1 and count[s[i - 1]] == 1 and count[s[i - 2]] == 1) {
                    continue;
                }
            }
            if(i > 1 and s[i] == s[i - 2] and count[s[i - 1]] == 1) {
                --m;
                continue;
            }
            if(m == 0 and count[s[i]] == 0) {
                continue;
            }
            z[m++] = s[i];
        }
        while(m > 1 and count[z[m - 1]] == 1) {
            --m;
        }

        printf("%d\n", solve(z, m));
    }
}

Try it online!
The naive implementation, with a couple of preprocessing optimizations.
Say that a character is unique if it occurs exactly once in the input string.

If there are more than 2 consecutive unique characters, we can remove some of them until there are exactly 2 consecutive ones.
We can remove every prefix or suffix consisting entirely of unique characters.
We can make substitutions aba -> a whenever b is unique (thanks to kops for the suggestion!).


Python 2, 31

lambda l:l and l==zip(*zip(*l))

This requires the lists to be lists of tuples. zip Drops extra elements if the input was ragged, so double zipping is only a noop if the lists all have the same length.

Try it here


Where are the runs in this infinite string? (CCCCCC Found!)

CCCCCC found at 2.124*10^519.
Precise index is 2124002227156710537549582070283786072301315855169987260450819829164756027922998360364044010386660076550764749849261595395734745608255162468143483136030403857241667604197146133343367628903022619551535534430377929831860918493875279894519909944379122620704864579366098015086419629439009415947634870592393974557860358412680068086381231577773140182376767811142988329838752964017382641454691037714240414750501535213021638601291385412206075763857490254382670426605045419312312880204888045665938646319068208885093114686859061215
Found by r.e.s., using the (old version of) code below, after 3.5 hours of searching.
Around that index, the string is: ...BCCBCBCCCBCCCCCCBCCB...
To verify, change the indicated line in the code below to start at 2946, instead of 5. Verification takes 20 seconds.
Update: Improved program. Old program searched ~10x more locations than necessary.
New version finds the CCCCCC in only 33 minutes.
How the code works: Basically, I only look at the regions which correspond to the ends of incremental strings, and calculate the letters by looking recursively back to the original string. Note that it uses a memo table, which may fill up your memory. Put a cap on the length of the memo table if necessary.
import time
import sys
sys.setrecursionlimit(4000)
ULIMIT=4000
end_positions=[]
current_end=2
while len(end_positions)<ULIMIT+3:
    end_positions.append(current_end)
    next_end=((current_end+1)*3+1)//2-1
    current_end=next_end
memo={}
def find_letter(pos):
    if pos in memo:
        return memo[pos]
    if pos<3:
        return 'ABC'[pos]
    for end_num in range(len(end_positions)-1):
        if pos>end_positions[end_num] and pos<=end_positions[end_num+1]:
            delta=end_positions[end_num+1]-end_positions[end_num]
            if len(memo)>5*10**6:
                return find_letter(pos-delta)
            memo[pos]=find_letter(pos-delta)
            return memo[pos]
time.clock()
for end_num in range(5,ULIMIT+1): # This line.
    diff = 1 # Because end_num is guaranteed to be a C
    while True:
        last_letter=find_letter(end_positions[end_num]+diff)
        if not last_letter=='C':
            break
        diff+=1
    if end_num%100==0:
        pos_str=str(end_positions[end_num])
        print(end_num,'%s.%s*10^%i'%(pos_str[0],pos_str[1:5],len(pos_str)-1),
        len(memo),diff,time.clock())
    if diff>=6:
        print(end_num,end_positions[end_num],diff,time.clock())

Current max searched to: 4000 iterations
CCCCCC found at iteration(s):
2946


Javascript 370 - 74 = 296

http://jsfiddle.net/wBKQ6/7/

(This only works in Chrome because I'm abusing the fact that element IDs are added to the global scope).

(function loop(){
    M=Math;p=M.PI/2;z=M.pow;q=M.sqrt;d=new Date();h=(d.getHours()%12/3*p+p)%(p*4);m=(d.getMinutes()/15*p+p)%(p*4);s=(d.getSeconds()/15*p+p)%(p*4);e=49;o='';

    for(r=0;r<99;r++){
        for(c=0;c<99;c++){
            d=q(z(r-e,2)+z(c-e,2));
            a=(M.atan2(e-r,e-c)+p*4)%(p*4);
            E=(d<e*.8&&M.abs(m-a)*d<.5) || (d<e*.5&&M.abs(h-a)*d<.5) || (d<e*1&&M.abs(s-a)*d<.5);
            o+=d-e>0||d<1||E||(e-d<5&&a%p==0)?'●':'○';
            //■□●○
        }
        o+='\n';
    }
    O.innerText=o
    setTimeout(loop,1000);
})()

Golfed (370):

!function L(){p=M.PI/2;q=p*4;P=M.pow;d=new Date();s=(d.getSeconds(S=d.getMinutes(e=40))/15*p+p)%q;m=(S/15*p+p)%q;h=(d.getHours(A=M.abs)%12/3*p+S/180*p+p)%q;for(r=o='';r<81;r++,o+='\n')for(c=0;c<81;){d=M.sqrt(P(r-e,2)+P(c-e,2));a=(M.atan2(e-r,e-c++)+q)%q;o+='○●'[d-e>0|d<e*.8&A(m-a)*d<1|d<e/2&A(h-a)*d<1|d<e&A(s-a)*d<1|e-d<5&a%p==0]}O.innerText=o;setTimeout(L,9)}(M=Math)

Sample Output (much more condensed in demo):

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●○○○○○○●○○○○○○●●●●●●●●●●●●●●
●●●●●●●●●●●●○○○○○○○○●○○○○○○○○●●●●●●●●●●●●
●●●●●●●●●●○○○○○○○○○○●○○○○○○○○○○●●●●●●●●●●
●●●●●●●●○○○○○○○○○○○○●○○○○○○○○○○○○●●●●●●●●
●●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●●
●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●
●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●
●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●
●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●
●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●
●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●
●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●
●●○○○○○○○○○○○○○○○○○○○○○○○○○●○○○○○○○○○○○●●
●○○○○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○●○○○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○●○○○○○○○○○○○○○○○○○○●
●●●●●○○○○○○○○○○○○○○○●○○○○○○○○○○○○○○○●●●●●
●○○○○○○○○○○○○○○○○○○●○●○○○○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○●○○●○○○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○●○○○○●●○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○●○○○○○●●○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○●○○○○○○○●●○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○●●○○○○○○○○●●○○○○○○○○○○○○●
●●○○○○○○○○○○○○○○●○○○○○○○○○○○●○○○○○○○○○○●●
●●○○○○○○○○○○○○○●○○○○○○○○○○○○○●○○○○○○○○○●●
●●●○○○○○○○○○○○○●○○○○○○○○○○○○○○●○○○○○○○●●●
●●●○○○○○○○○○○○●○○○○○○○○○○○○○○○○●○○○○○○●●●
●●●●○○○○○○○○○○●○○○○○○○○○○○○○○○○○●○○○○●●●●
●●●●○○○○○○○○○●○○○○○○○○○○○○○○○○○○○●●○○●●●●
●●●●●○○○○○○○●●○○○○○○○○○○○○○○○○○○○○●●●●●●●
●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●
●●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●●
●●●●●●●●○○○○○○○○○○○○●○○○○○○○○○○○○●●●●●●●●
●●●●●●●●●●○○○○○○○○○○●○○○○○○○○○○●●●●●●●●●●
●●●●●●●●●●●●○○○○○○○○●○○○○○○○○●●●●●●●●●●●●
●●●●●●●●●●●●●●○○○○○○●○○○○○○●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●


Underhanded contest (?): Anti-Virus wars

bash (113)

sort -t, "$1"
#PK^C^D^@^@^@^@^@^@^@^@^@^@^@^@^@^@D^@^@^@D^@^@^@^@^@^@^@X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

The above uses caret notation. Notably, ^@ indicates a null byte.

How it works

sort -t, "$1" sorts the file specified as the first command-line argument ($1), using the comma character as field delimiter (-t,).
# at the beginning of the second line comments it out; it will get ignored by bash.
PK^C^D^@^@^@^@^@^@^@^@^@^@^@^@^@^@D^@^@^@D^@^@^@^@^@^@^@ is the shortest possible ZIP file local file header:

PK^C^D (0x04034B50) is the local file header signature.
^@^@^@^@^@^@^@^@^@^@^@^@^@^@ specifies the ZIP version, a bit flag, the compression method and the compressed file's mtime and checksum. All are set to zero.
The twice occurring D^@^@^@ (0x00000044 or 68) specifies the file's compressed and uncompressed length (68 bytes).
^@^@^@^@ specifies the filename and extra header length. Both are set to zero.

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* is the 68 byte long  EICAR test string, which serves as the data associated to the above header.

This takes advantage of the fact that ClamAV will act on all ZIP file local file headers, even if they're encountered outside of actual ZIP files.

Malware scan

VirusTotal gives 15 false positives out of its current 51 scanners. This includes ClamAV.


Perl, 63 60 59 57 bytes

Includes +2 for -pa

Give input parameters on STDIN

mnomial.pl <<< "3 5 6"

#!/usr/bin/perl -pa
$_=/-/^($_--,1x$F[2])=~/^(1{0,$_}){$F[1]}$(??{++$;})/+$

As a perl programmer I just know that every problem is really a regex in disguise...

Explanation:

m(3,5,6) can be seen as the number of ways you can get 6 by adding 5 integers in the range [0..2]. You can write a regex matching such a partition using:

1 x 6 = /^(1{0,2}){5}$/

However once a single solution is found the regex stops. We need to fail the found solution to get the regex to backtrack to the next solution and count the failures. In perl this can be done by extending the regex at runtime with something that is sure to fail, e.g. by demanding that something comes after the end of the string:

 1 x 6 = /^(1{0,2}){5}$(??{++$n})/

$n will count the number of failed attempts

My solution is basically this with two modifications:

Output the counter in such a way that you get 0 instead of the empty string if there is no valid partition and the counter never gets incremented
If the third argument is negative it would work if negative string lengths existed, but 1 x -5 is the empty string and 0 can be written exactly one way as sum of zeros, so that would output 1 instead of 0. I xor with the result of /-/to change the 1 back to 0

Without the need to handle a negative third argument this 49 byte solution would be good enough (give one parameter of m(x,y,z) on each line of STDIN in order y \n z \n x \n):

#!/usr/bin/perl -pa
$_=(1x<>)=~/^(1{0,@{[<>-1]}}){@F}$(??{++$;})/+$


CJam, 86 bytes

qN/_,{1$=cS-},W=0{_3$3$==_'X-}{"^v<>"#_"NSWE"=L\+:L;"\(\ \)\ ( )"S/=~}w];Le`{(+}%", "*

Try it online

Explanation:

qN/     Get input and split into rows.
_,      Calculate number of rows.
{       Loop over row indices.
  1$=     Get row at the index.
  c       Get first character.
  S-      Compare with space.
},      End of filter. The result is a list of row indices that do not start with space.
W=      Get last one. This is the row index of the start character.
0       Column number of start position. Ready to start tracing now.
{       Start of condition in main tracing loop.
  _3$3$   Copy map and current position.
  ==      Extract character at current position.
  _'X-    Check if it's the end character `X.
}       End of loop condition.
{       Start of loop body. Move to next character.
  "^v<>"  List of directions.
  #       Find character at current position in list of directions.
  _       Copy direction index.
  "NSWE"  Matching direction letters.
  =       Look up direction letter.
  L\+:L;  Append it to directions stored in variable L.
  "\(\ \)\ ( )"
          Space separated list of commands needed to move to next position for each of
          the 4 possible directions.
  S/      Split it at spaces.
  =       Extract the commands for the current direction.
  ~       Evaluate it.
}w      End of while loop for tracking.
];      Discard stack content. The path was stored in variable L.
Le`     Get list of directions in variable L, and RLE it.
{       Loop over the RLE entries.
  (+      Swap from [length character] to [character length].
}%      End of loop over RLE entries.
", "*   Join them with commas.


CJam (60 bytes + 120 = 180 score)

{_5/4*8e!961=7_)er<:A\,^e!{A\+}%{2ew::-:z1&!},{_$.-:z1b}$0=}

Online test suite with integrated scoring

Extension up to n=24

Dissection

{
  _5/4*        e# Work out how much of the hard-coded prefix to use
  8e!961=7_)er e# Prefix [0 2 4 1 3 5 8 6]
               e# I identified this by brute forcing up to n=10 and looking for patterns
               e# I then used the identified prefix [0 2 4 1] to brute-force further
  <:A          e# Take the desired prefix of the hard-coded array, and store a copy in A
  \,^e!        e# Generate all permutations of the values in [0 .. n-1] which aren't in A
  {A\+}%       e# Prepend A to each of them
  {            e# Filter...
    2ew::-     e#   Take each difference of two consecutive elements
    :z         e#   Find their absolute values
    1&         e#   Test whether 1 is among those absolute values
    !          e#   Reject if it is
  },
  {            e# Sort by...
    _$.-       e#   Take pairwise differences of permutation with the identity
    :z         e#   Absolute values
    1b         e#   Add them (by interpreting in base 1)
  }$
  0=           e# Take the first
}


CJam, 18 17 bytes

0{sN1$e`2af.b}ri*

Thanks to @MartinBüttner for golfing off one byte!

Try it online in the CJam interpreter.

How it works

0                 e# Push 0.
 {           }ri* e# Repeat int(input)) times:
  s               e#   Stringify the element on top of the stack.
                       EXAMPLE: [[[1 1] '1] [[1] '0]] -> "11110"
   N              e#   Push a linefeed.
    1$            e#   Copy the last stack.
      e`          e#   Perform run-length encoding.
                  e#   EXAMPLE: "100110" -> [[1 '1] [2 '0] [2 '1] [1 '0]]
        2a        e#   Push [2].
          f.b     e#   For each pair [x 'y], execute: [x 'y][2].b
                  e#   This pushes [x2b 'y], where b is base conversion.


Chemistry 101 - Introduction to the Periodic Table

CJam, 64 59 58 56 54 bytes

Thanks to Dennis for saving 2 bytes.

{_80-zG-z8<{80>"LA"=}{_"X8�"f>[-14_AAGH].*+:+Imd)}?}

Try it online!

Leaves either period and group or a single character on the stack.

Explanation

There are two main ideas here:

First, we deal with the Lanthanides and Actinides. We have the condition 56 < x < 72 for Lanthanides and 88 < x < 104 for Actinides. Both of these can be expressed as a single comparison by taking an absolute difference to the centre of the range: the inequalities become |x - 64| < 8 and |x - 96| < 8, respectively. But these are still very similar, and doing the two comparisons separately is expensive. So we apply the same idea of checking a symmetric range, by taking another absolute difference with the centre between the two ranges, 80, first: ||x-80| - 16| < 8. This condition indicates that the atom is either a Lanthanide or an Actinide, but distinguishing between these two cases is then as trivial as comparing against 80 (or some other value between the ranges).
Since the output is really an index in a table of width 18, an obvious approach is to try base-converting the value to base 18, so that the two digits give group and period. To do that, we need to shift some values around though. All the we really need to do is to add the gaps in periods 1, 2 and 3 and close the gaps in periods 6 and 7. It's easiest to do this from the end, so that the values of the other gaps aren't affected (and keep their values).

_            e# Make a copy of the input, to figure out whether the output
             e# should be L or A.
80-z         e# Absolute difference from 80.
G-z          e# Absolute difference from 16.
8<           e# Check whether the result is less than 8.
{            e# If so...
  80>        e#   Check whether the input is greater than 80.
  "LA"=      e#   Select 'L or 'A accordingly.
}{           e# ...otherwise...
  _          e#   Duplicate input again.
  "X8"    e#   Push a string with character codes [88 56 12 4 1].
             e#   These are the values just before the gaps.
  f>         e#   Compare the input to each of these.
  [-14_AAGH] e#   Push [-14 -14 10 10 16 17]. These are the changes we need to
             e#   make to remove or insert the gaps corresponding to the above
             e#   positions. Note that the 17 doesn't get paired with an offset.
             e#   It's a constant offset to itself, which is equivalent to
             e#   decrementing the input (to make it zero based) and adding 18
             e#   to make the increment the period and make it 1-based.
  .*         e#   Multiply each gap by whether it's before the input value.
  +:+        e#   Add all of the applicable gaps to the input value.
  Imd        e#   Divmod 18, gives 1-based period and 0-based group.
  )          e#   Increment the group to make it one-based.
}?


Wolfram Language (Mathematica), 34 bytes

0~Range~19~Binomial~i~Sum~{i,0,#}&

Try it online!

The tier \$n\$ metasequence is the sum of the first \$n+1\$ elements of each row of the Pascal triangle.


Python 2, 42 39 bytes

n,a,b=input()
while n:print n%a;n=n/a*b

Try it online!

Thanks to @xnor for finding the shorter form.

Obsolete version (42 bytes):

f=lambda n,a,b:n and[n%a]+f(n/a*b,a,b)or[]

Try it online!

Parameters: input, numerator (with sign) and denominator.

Returns an array, lowest digit first.

This just works because the division and modulo in Python follows the sign of the denominator, so we don't have to care about same signs explicitly.

Test case output:

f(7, 4, 3)       == [3, 3]
f(-42, -2, 1)    == [0, -1, -1, -1, -1, -1, -1]
f(-112, -7, 3)   == [0, -1, 0, -5, -6]
f(1234, 9, 2)    == [1, 4, 6, 3, 2]
f(60043, -37, 3) == [-8, -22, -14, -33]


Haskell 106

t=10;d=divMod;s z|z<w z=s$w z|t>0=z
w x|x<t=x|y>z=(q*t+y)*t+z|t>0=y+t*(w v)where{(v,y)=d x t;(q,z)=d v t}

example:

ghci> s 502010406072952146729521467295214672952146729
999997777766666555554444422222222221111100000

An answer that doesn't dodge the question.

An explanation was requested, here it is ungolfed. It's a very inefficient bubble sort.

-- t=10 - alias for 10. d=divMod - alias for divMod.
-- The alias for '10' turns out to be unnecessary; inlining it
-- and using '1>0' for True has the same character count. It's
-- a relic of earlier versions of the code.

-- 's': if no digits need swapped, return the number,
-- otherwise return 's' applied to the number with
-- that pair of digits swapped.
sort z=
  let temp=sort_pair z
  -- because we are sorting in descending order,
  -- sorting a pair of digits always increases the number.
  -- testing > costs one less char than ==.
  if z<temp then
    -- golfed version uses guards instead of if/else to save space.
    -- t>0 is '10 > 0', which is 'True', in fewer chars.
    sort temp
  else
    z
-- 'w': recursively swap one pair of out of order digits, or
-- return the original number if no pairs needed swapped.
sort_pair x=
  -- haskell does the assignments below lazily, they aren't
  -- calculated unless I use them. 'divMod' lets me do this
  -- with fewer chars.
  let y = x `mod` 10 -- last digit
      v = x `div` 10 -- all but last digit
      z = v `mod` 10 -- second last digit
      q = v `div` 10 -- all but last 2 digits
  in
  if x < 10 then
    x
  else if y > z then
    -- last 2 digits are out of order. swap them & return
    -- This is rearranged using Horner's method to save space
    -- http://en.wikipedia.org/wiki/Horner%27s_method
    -- ... although it turns out not to save anything, it's a relic.
    (q * 10 + y)*10 + z
  else
    -- last digit is ok, so try sort_pair on remaining digits
    let temp = sort_pair v in
    -- put last digit back on the end and return
    -- having the bracketed expression last here
    -- let me remove a space before 'where'
    y+(10*temp)

Shorter answers exist in Haskell, equivalent to some of the others posted, eg:

import Data.List;s=read.sort.show::Integer->Integer

... scores 52+20=72, or this, scoring 45+20=65:

import Data.List;main=interact(reverse.sort)

... but the spirit of the question - no arrays, strings, or characters - is more interesting.


Find the Longest Palindrome in a String by Removing Characters

Here is my solution in Java (not exactly short hah)...

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Palindrome {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(new File("src/pal.dat"));

        int q = sc.nextInt();
        sc.nextLine();

        for (int z = 0; z < q; z++) {
            String line = sc.nextLine();

            int max = 0;
            String maxP = "";

            for (int k = 0; k < line.length(); k++) {

                String p = calc(line.substring(k));

                if (p.length() > max) {
                    max = p.length();
                    maxP = p;
                }

            }

            System.out.println("Max Palindrome: " + maxP);

        }

    }

    public static String calc(String s) {
        if (s.length() == 0)
            return "";
        if (s.length() == 1 || (s.length() == 2 && s.charAt(0) != s.charAt(1)))
            return s.charAt(0) + "";
        if (s.length() == 2)
            return s;

        char[] arr = s.toCharArray();

        boolean match = false;
        int i = 0;
        for (i = arr.length - 1; i > 0; i--) {
            if (arr[i] == arr[0]) {
                match = true;
                break;
            }
        }

        int max = 0;
        String maxPalin = "";
        for (int k = 1; k < i; k++) {
            String p = calc(s.substring(k, i));
            if (p.length() > max) {
                max = p.length();
                maxPalin = p;
            }
        }

        if (match)
            return arr[0] + maxPalin + arr[0];
        return maxPalin;

    }

}


Python 3, 159 156 152 151 150 148 bytes

n=int(input())+1
for c,x in zip(b" C","Qupu Blinkorp Paas Karpasus Floopdoor Dumaflop Lindilo Fwup".split()):c>=n>0and print(*[n,x][-c:]);n-=c

The bytes object in the zip contains unprintable characters:

for c,x in zip(b"\x16\x11\x18\x11\x01\x1c C", ...): ...

(Thanks to @xnor for suggesting a for/zip loop for -3 bytes)


APL (Dyalog Unicode), 41 bytesSBCS

Saved 30 bytes (!) by consulting the wisdom of the APL Orchard, especially @ngn and @Sherlock9.

{0::⍵⋄∊∇¨⌽∘⊖¨@4,⌽@1⊢∘⍉\⌽↑∘⍵¨∘.,⍨2 ¯2÷⍨≢⍵}

Try it online!

Explanation as follows:

{0::⍵⋄∊∇¨⌽∘⊖¨@4,⌽@1⊢∘⍉\⌽↑∘⍵¨∘.,⍨2 ¯2÷⍨≢⍵} ⍝ Recursive function - takes input as an
                                          ⍝ n*n square matrix
 0::⍵                                     ⍝ Our base case - this is an error guard
                                          ⍝ If there's any error, catch it and
                                          ⍝ return the function's input
                                      ≢⍵  ⍝ Find the number of rows in the input
                                2 ¯2÷⍨    ⍝ Divide the above by 2 and negative 2,
                                          ⍝ resulting in a 2-element vector
                            ∘.,⍨          ⍝ Outer product - take the above vector and
                                          ⍝ apply concatenation (,) with each element
                                          ⍝ against all elements in the vector. Since
                                          ⍝ we have a 2-element vector, this results in
                                          ⍝ a 2-by-2 matrix, e.g.
                                          ⍝ [[(2,2),(2,¯2)],[(¯2,2),(¯2,¯2)]]
                        ↑∘⍵¨              ⍝ For each element in the matrix, we apply
                                          ⍝ "take" against our original input matrix.
                                          ⍝ Take, given a negative number, will take
                                          ⍝ elements from the end of a particular rank.
                                          ⍝ With our argument above, this means that we end
                                          ⍝ up with our original original input matrix
                                          ⍝ split by quadrant into a 2-by-2 matrix.
                                          ⍝ It is also worth noting that take expects
                                          ⍝ an integer argument, so for matrices whose
                                          ⍝ rowcount divided by two results in a decimal
                                          ⍝ (i.e., 1-by-1 matrices), we throw an error
                                          ⍝ which is caught by the guard above, returning
                                          ⍝ the original input.
                       ⌽                  ⍝ Flip the above matrix about the vertical axis.
                   ⊢∘⍉\                   ⍝ Apply a "monadic transpose scan". More details
                                          ⍝ on how this works below, but for our purposes
                                          ⍝ this applies transpose to each of the two
                                          ⍝ sub-matrices on the right half.
                ⌽@1                       ⍝ Swap the two upper sub-matrices. Given our
                                          ⍝ flip for the overall matrix above, this returns
                                          ⍝ the two upper quadrants to their original
                                          ⍝ positions.
               ,                          ⍝ Ravel: flatten the 2-by-2 matrix into a
                                          ⍝ 4-element vector
         ⌽∘⊖¨@4                           ⍝ Take the last element of the list (the lower
                                          ⍝ right quadrant originally) and flip it
                                          ⍝ along the vertical and horizontal axes. Given
                                          ⍝ the transposition above, this has the final
                                          ⍝ effect of transposition along the antidiagonal.
       ∇¨                                 ⍝ For each element in the above vector, recurse.
      ∊                                   ⍝ Recursively flatten the results into a single
                                          ⍝ vector.

More details on "monadic transpose scan".

Dyalog documentation on error guards.


Program that creates larger versions of itself (quine-variant)

H9+ : 1 char
9

That's right. One character. Outputs the lyrics to 99 bottles of beer, which is a valid program. All the extraneous data does not count, but there are plenty of 9s in there.
The output of the outputted program is the lyrics to 99 bottles of beer 59 times.
This function gives the number of times the lyrics are outputted if you run the program n times (if my calculation is correct):
f(n) = 59n-1


GolfScript, 138 characters
n%~[~]:N;1/:P.&:L;9..*?{(.[{.9%)\9/}81*;]:§;L{.`{\~@@=*}+[P§]zip%{+}*\L?N==}%§9/..zip+\3/{{3/}%zip{{+}*}%}%{+}*+{.&,9=}%+1-,!{§puts}*.}do;

This is a killer sudoku solver in GolfScript. It expects input on STDIN in two rows as given in the example above.
Please note: Since the puzzle description does not make any restrictions on execution time I preferred small code size over speed. The code tests all 9^81 grid configurations for a solution which may take some time on a slow computer ;-)


Convert numbers to binary... but you're allowed to use twos as well

GolfScript (25 bytes) / CJam (19 17 bytes)

GolfScript:

{:^.*,{3base}%{2base^=},}

This creates an anonymous function (see meta discussion about permissibility of anonymous functions).

Online demo

A straight translation into CJam is (with thanks to Martin Büttner for shaving a couple of characters)

{:X_*,3fb{2bX=},}

Dissection

{             # Function boilerplate
  :^          # Store parameter as variable ^
  .*          # Square parameter - see detailed explanation below
  ,{3base}%   # Produce an array of 0 to ^*^-1 in ternary
  {2base^=},  # Filter to those which evaluate to ^ in binary
}

The reason for the squaring operation is that we need to iterate up to the largest possible value whose ternary representation, interpreted in binary, is equal to ^. Since 2 = 10, the "normal" binary representation of ^ is the one which matters. If we convert that to ternary, we find that the "worst" cases are powers of 2. An optimal approach would be to take the argument to the power of ln 3/ln 2 ~= 1.585, but squaring is much shorter.


Logically, there should be an asterisk (*) every time i == j and i+j==w-1(for diagonals), i == 0 and j == 0 (for top line and left side) and j == w-1 and i==h-1  (for right side and bottom line).
class d {
    public static void main(String[] a) {
        for(int i=0,w=new Byte(a[0]),h=new Byte(a[1]);i<h;i++) {
            for(int j=0;j<w;j++) {
                System.out.print(i==0 || j==0 || i==h-1 || i+j==w-1 || j==w-1 || i==j ? "*":" ");
            }
            System.out.println();
        }
    }
}


Prolific Perfect Pangram Programs Pertaining to Printable ASCII

Perl, 70*18446744073709551615*10^987654320

say q{!"#%&'+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\]^_`bcdfghijklmnoprtuvwz|}x(1e987654320*~$[)

Output:

!"#%&'+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\]^_`bcdfghijklmnoprtuvwz|

repeated 18446744073709551615*10^987654320 times.

$[ is by default 0, so ~$[ is equivalent to 18446744073709551615.

As a side note, I ran out of memory trying to create the number 10^987654320.

Old Answer (7703703696):

say qw(!"#$%&'*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdefghijklmnoprtuvz{|}~10)x98765432

Output is:

!"#$%&'*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdefghijklmnoprtuvz{|}~10

repeated 98765432 times.

Note: Run all samples with perl -Mbignum -E


Jelly, 9 bytes

,‘œ?ŻḌI÷9

Try it online! (print the n'th element)

Try it online! (20 first elements)

Explanation:

      I÷9      Compute the difference divided by 9 between
 ‘             the (n+1)th
  œ?           permutation
,              and
               the (n)th
  œ?           permutation
    Ż          of [0,1,2,...n]
     Ḍ         converted to decimal.

(Jelly has the builtin œ? which computes the nth permutation of a list in approximately linear time. Quite useful.)


Jelly, 16 14  13 bytes

Ṅ⁶ỤṪ$¦µQL>3µ¿

TryItOnline!

Most to least favourite, as for anyone serious about their O.C.D., is alphabetical!

Takes input and outputs as text (i.e. the rows are delimited by new lines).

3 bytes saved by reversing the direction and using a different method: grade up rather than finding characters from the alphabet.

How?

Ṅ⁶ỤṪ$¦µQL>3µ¿ - Main link: Skittle text
      µ    µ  - monadic chain separation
            ¿ - while
       Q      - unique items
        L     - length
         >3   - greater than 3 (until only new lines, spaces and 'g's remain)
Ṅ             -     print z and a line feed, yield z
    $         -     treat last two links as a monad
  Ụ           -         grade up (get indices of: new lines; spaces; gs; os; ps; rs; ys)
   Ṫ          -         tail (the last of those, so last y if there is one, else last r, ...)
 ⁶            -     space character
     ¦        -     apply at index (replace that index with a space)


Shortest code to dump a file into workable memory

C#

var a = System.IO.File.ReadAllText("filename.txt");

a is a string that will contain the contents of filename.txt


424 425: Haskell, Python 2, Perl

As they should for a true Rosetta comparison, all three programs work the same way, taking input from the first command-line argument and building up the list with the same rules, and variable names, where possible.

Haskell, 171

import System.Environment
main=do i<-getArgs;putStr.show$[n|n<-[0..777777],all(`notElem`"5689").show$n,all(\d->n`div`d`mod`100`notElem`13:[30..39])[1,1000]]!!(read.head$i)

Python 2, 156

import sys
print[n for n in range(777778)if all([c not in"5689"for c in str(n)])and all([n/d%100not in[13]+range(30,40)for d in[1,1000]])][int(sys.argv[1])]

Perl, 97 98

$i=@ARGV[0];die if $i>30275;for(0..777777){push@n,$_ if!(/[5689]/ or/(13|3.)(|...)$/)}print@n[$i]


Tiling a 2^N by 2^N Grid with L-Shaped Trominoes

C, 399 bytes

char*T=" |-+ | +-| ",*B;w;f(N,x,y,m,n,F,h,k,i,j){w=B?F=0,w:1<<N|1;char b[N?w*w:6];for(k=w;k--;)b[k*w-1]=10;B=!B?F=1,m=0,n=0,x--,y--,b:B;if(N>1){h=1<<N-1;i=x>--h,j=y>h;while(++k<4)if(k%2-i||k/2-j)f(N-1,!(k%2)*h,!(k/2)*h,m+k%2*(h+1),n+k/2*(h+1));f(1,h&i,h&j,m+h,n+h);h++;f(N-1,x-h*i,y-h*j,m+h*i,n+h*j);}else while(++k<4)B[w*(n+k/2)+m+k%2]=T[5*x+2*y+k];if(F)B[y*w+x]=79,B[w*w-w-1]=0,puts(N?B:"O"),B=0;}

No one's come forward with anything yet, so I'll offer up a meager solution. Mark my words, this is not the end. This will get shorter.
We define a function f that takes 10 arguments, but you need only call it with f(N, X, Y). Output goes to stdout.
Here's a readable version:
char*T=" |-+ | +-| ",*B;
w;
f(N,x,y,m,n,F,h,k,i,j){
    w=B?F=0,w:1<<N|1;
    char b[N?w*w:6];
    for(k=w;k--;)
        b[k*w-1]=10;
    B=!B?F=1,m=0,n=0,x--,y--,b:B;
    if(N>1){
        h=1<<N-1;
        i=x>--h,j=y>h;
        while(++k<4)
            if(k%2-i||k/2-j)
                f(N-1,!(k%2)*h,!(k/2)*h,m+k%2*(h+1),n+k/2*(h+1));
        f(1,h&i,h&j,m+h,n+h);
        h++;
        f(N-1,x-h*i,y-h*j,m+h*i,n+h*j);
    }
    else
        while(++k<4)
            B[w*(n+k/2)+m+k%2]=T[5*x+2*y+k];
    if(F)B[y*w+x]=79,B[w*w-w-1]=0,puts(N?B:"O"),B=0;
}

A taste of output for f(3, 2, 7):
+--++--+
|+-||-+|
||+--+||
+-|-+|-+
+--+||-+
|-+|-+||
|O|||-+|
+--++--+

It's a fairly simple recursive algorithm to fill the grid. I may upload an animation of the algorithm drawing trominoes since I think it's pretty neat. As usual, feel free to ask questions and shout at me if my code breaks!
Try it online!


Python 3, 45 bytes

k=P=1
while k<1e6:P%k>0==print(k);P*=k*k;k+=1

Try it online!
By the time the loop reaches testing k, it has iteratively computed the squared-factorial P=(k-1)!^2. If k is prime, then it doesn't appear in the product 1 * 2 * ... * (k-1), so it's not a factor of P. But, if it's composite, all its prime factors are smaller and so in the product. The squaring is only actually needed to stop k=4 from falsely being called prime.
More strongly, it follows from Wilson's Theorem that when k is prime, P%k equals 1. Though we only need that it's nonzero here, it's useful in general that P%k is an indicator variable for whether k is prime.
Thanks to @Sisyphus for 1 byte with P%k>0==print(k) using chained operator short-circuiting in place of P%k and print(k).


R, 59 bytes

function(){T[o]<<-T[o<-sample(6,1,,max(T)-T+1)]+1
o}
T=!1:6

Try it online!

Keeps the counts in T, which is then transformed to be used as the weights argument to sample (which then most likely normalizes them to sum to 1).

The [<<- operator is used to assign a value to T in one of the parent environments (in this case, the only parent environment is .GlobalEnv).


Jelly, 3 bytes

+¡ạ

Takes x, y, and n (0-indexed) as separate command-line arguments, in that order.

Try it online!

How it works

+¡ạ  Main link. Left argument: x. Right argument: y. Third argument: n

  ạ  Yield abs(x - y) = y - x, the (-1)-th value of the Lucas sequence.
+¡   Add the quicklink's left and right argument (initially x and y-x), replacing
     the right argument with the left one and the left argument with the result.
     Do this n times and return the final value of the left argument.


05AB1E, 16 bytes
œvyŒ€J})˜Ùvy²Q}O

Explained
œv                # for each permutation of the list of elements
  yŒ              # get all sublist of elements
    €J            # join as strings to form the words possible to spell
      })˜Ù        # convert to list of unique spellable strings
          vy²Q}   # compare each word with input word
               O  # sum giving 1 if the word is found, else 0

Warning: Extremely slow. I recommend testing on a much smaller subset of elements in the online interpreter.
Takes list of elements as first argument.
Takes word to test as second argument.
Returns 1 for true and 0 for false.
Try it online on a small subset of elements


JavaScript (ES6), 55 bytes
Saved 6 bytes thanks to @Neil
Takes input in currying syntax (year)(month). Returns false for asymmetric, true for centrally symmetric and 0 for completely symmetric.
y=>m=>(n=(g=_=>new Date(y,m--,7).getDay())()+g())&&n==7

Try it online!
How?
We define the function g() which returns the weekday of yyyy/mm/01, as an integer between 0 = Monday and 6 = Sunday.
g = _ => new Date(y, m--, 7).getDay()

Because getDay() natively returns 0 = Sunday to 6 = Saturday, we shift the result to the expected range by querying for the 7th day instead.
Then we define:
n = g() + g()

Because the constructor of Date expects a 0-indexed month and because g() decrements m after passing it to Date, we actually first compute the weekday of the first day of the next month and then add that of the current one.
Completely symmetric months
Completely symmetric months start with a Monday and are followed by a month which also starts with a Monday. This is only possible for February of a non-leap year.
- Feb --------------    - Mar --------------
Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su
--------------------    --------------------
01 02 03 04 05 06 07    01 02 03 04 05 06 07
08 09 10 11 12 13 14    08 09 10 11 12 13 14
15 16 17 18 19 20 21    15 16 17 18 19 20 21
22 23 24 25 26 27 28    22 23 24 25 26 27 28
                        29 30 31

This leads to n = 0.
Centrally symmetric months
Centrally symmetric months are months for which the sum of the weekday of their first day and that of the next month is 7.
- M ----------------    - M+1 --------------
Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su
--------------------    --------------------
 0  1 [2] 3  4  5  6     0  1  2  3  4 [5] 6
--------------------    --------------------
      01 02 03 04 05                   01 02
06 07 08 09 10 11 12    03 04 05 06 07 07 09
13 14 15 16 17 18 19    ...
20 21 22 23 24 25 26
27 28 29 30 31

Hence the second test: n == 7.

No built-in, 93 bytes
Uses Zeller's congruence. Same I/O format as the other version.
y=>m=>(n=(g=_=>(Y=y,((m+(m++>2||Y--&&13))*2.6|0)+Y+(Y>>2)-6*~(Y/=100)+(Y>>2))%7)()+g())&&n==7

Try it online!


Matlab, 218 190 175 bytes
function f(a,b);q=a;l(b)=0;l(a)=1;while~l(b);x=q(1);q=q(2:end);l(end+1:x^2)=0;g=x+1:x^2;s=2:x-1;u=[g(~mod(g,x)),s(~mod(x,s)&s.^2>=x)];u=u(~l(u));q=[q,u];l(u)=l(x)+1;end;l(b)-1

Thanks @beaker for the shortcut in in the list lengthening step!
This is a relatively straightforward dijkstra implementation:
q=a;                  %queue
l(b)=0;       %list of path lengths
l(a)=1;
while~l(b);         %if there is no predecessor to b
    x=q(1);         %get first queue element
    q=q(2:end);
    %add edges
    l(end+1:x^2)=0;% lengthen predecessor list if too short
    g=x+1:x^2;      % g=greater neighbours
    s=2:x-1;        % s=smaller neighbours %keep only valid/unvisited neighbours
    u=[g(~mod(g,x)),s(~mod(x,s)&s.^2>=x)]; %-1byte
    u=u(~l(u));
    q=[q,u];      %add only hte valid nodes edges to queue
    l(u)=l(x)+1;       %mark x as predecessor
end;
l(b)-1 %output length to the end of the path

 no convolution today


National Scheduling Conflict Championships

SWI-Prolog, 537 524 516 502 447 436 bytes
z(A:B:C,[D:E:F|G]):-(A=D;B>=F;E>=C),(G=[];z(A:B:C,G)).
u([A|B],C):-z(A,C),(B=[];u(B,C)).
y([A,B,C|D])-->[A:B:C],(y(D);{_=_}).
d-->[A:_],{write(A),tab(1)},d;{_=_}.
l([H|T],R):-T=[],R=H;length(H,N),l(T,X),length(X,M),(N>M,R=H;R=X).
v([],_,R,R).
v([A|T],Z,B,R):-u(A,A),\+z(Z,A),v(T,Z,[A|B],R);v(T,Z,B,R).
s([E|T],[F|N]):-E=F,(N=[];s(T,N));s(T,[F|N]).
x(A):-y(A,D,[]),K="NSCC":_,select(K,D,E),setof(L,s(E,L),B),v(B,K,[],R),l(R,S),d(S,[]),!.

Brief explanation of what each predicate does:

z(A,B) checks that an event A doesn't conflict with any event of a list of events B
u(A,B) checks that every event of a list A does not conflict with any event of a list B (used to check that there are no conflicts in list A by calling u(A,A))
y(A,B,C) splits a List into a list of triplets (to transform inputs into a list of events)
d(A) prints the names of events in a list A
l(A,R) evaluates the longest list of events R contained in the list of lists A
v(A,NSCC,C,R) returns a list R containing every list of events in A that have no internal conflict and that conflict with the event NSCC
s(A,B) true if B is a subset of A
x(A) main predicate, A is the input.

Test cases: execute test. in the interpreter after loading the code above with the following added after it:
test:-
    x(["UnderwaterBasketWeavingConvention",50,800,"NSCC",500,550]),
    nl,
    x(["SconeEating",0,50,"RegexSubbing",45,110,"CodeGolfing",95,105,"NSCC",100,200]),
    nl,
    x(["VelociraptorHunting",0,300,"NerdSniping",200,500,"SEChatting",400,700,"DoorknobTurning",650,750,"NSCC",725,775]),
    nl,
    x(["NSCC",110,115,"A",100,120,"B",120,140,"C",105,135,"D",100,105,"E",135,500]),
    nl,
    x(["A",800,900,"NSCC",700,1000,"B",650,750,"C",950,1050,"D",655,660,"E",660,665,"F",1030,1040,"G",1040,1060]),
    nl,
    x(["A",10,11,"B",11,12,"C",12,13,"D",13,14,"NSCC",15,1090,"E",10,16]).

This took me way more time than I thought it would. This can probably be golfed significantly more. Also you could probably use the various constraint programming libraries that exist to get shorter solutions.
Edit: Thanks to @Oliphaunt for the idea of using A:B:C instead of [A,B,C] for triplets. Saves 14 bytes.
Edit2: Thanks again to @Oliphaunt for  pointing out that the predicate ``t/3`was useless. Saves 55 bytes
Edit3: Gained 11 bytes using definitive clause grammar on predicates y and d.


Output the spoken names of numbers used on planet Flapus

Retina, Colopee'pokri, 165 157 143 127 123 bytes

(.+)(.)
$2'$1
0
Kuzla
1
Ponara
2
Boqkel
3
Colopee
4
Vruenat
5
Foham
6
Stikty
7
Kricola
(?<='.*[iou])[a-z]+

T`L`l`'.+
zla'

The trailing linefeed is significant.

Try it online!

Explanation

(.+)(.)
$2'$1

We start by bringing the trailing digit to the front and inserting an apostrophe after it. Note that this leaves single-digit numbers unchanged, since the regex doesn't match - so those never get an apostrophe in the first place.

0
Kuzla
1
Ponara
2
Boqkel
3
Colopee
4
Vruenat
5
Foham
6
Stikty
7
Kricola

This replaces each digit with its full name, regardless of where it appears.

(?<='.*[iou])[a-z]+

This shortens all the digit names that appear after an apostrophe. Note that only the vowels iou appear first in a digit name, so we check a position that is right after one of those, and after an apostrophe and then match (and remove) all lower case letters that follow that position. Since we've inserted the digit names in title case, this will stop before the next digit.

T`L`l`'.+

This uses transliteration to turn all upper case characters, L, into their lower case counterpart, l, provided they are found in a match that starts with ' (in order to leave the leading capital untouched).

zla'

The only thing that's left is correctly handling multiples of (octal) 10. In that case, we'll have a result starting with Kuzla', which we want to start with Ku instead. So we simply remove all occurrences of zla'.


Maxima, 149

load(mnewton)$y(d):=?encode\-universal\-time(0,0,0,d[4],d[3],d[2])/31536000$mnewton(f[1][1]+sum(f[i][1]*(1+r)^(y(f[1])-y(f[i])),i,2,length(f)),r,.1);

This code has a bug where some payments might be off by 1/24 day (1 hour). This bug happens if your local time zone moves in or out of daylight-saving time. To fix this bug, add ,0 (2 characters) after d[2].

First set f to a list of lists in the form [[flow, year, month, day], ...]. Then paste this code at Maxima's prompt. The answer comes in the form [[r = float]]. If you want the float by itself, use part(%[1][1],2);

Example 1:

(%i150) f : [[-1, 2001, 1, 1], [.3, 2002, 1, 1], [.4, 2005, 1, 1],
             [.5, 2005, 1, 10]]$

(%i151) load(mnewton)$y(d):=?encode\-universal\-time(0,0,0,d[4],d[3],d[2])/31536000$mnewton(sum(f[i][1]*(1+r)^(y(f[1])-y(f[i])),i,1,length(f)),r,.1);
(%o153)                   [[r = .058394251994029284]]

Example 2:

(%i154) f : [[-1, 2011, 1, 1], [-.3, 2012, 2, 1], [.4, 2015, 3, 1],
             [.01, 2015, 3, 15], [.8, 2015, 4, 10]]$

(%i155) load(mnewton)$y(d):=?encode\-universal\-time(0,0,0,d[4],d[3],d[2])/31536000$mnewton(sum(f[i][1]*(1+r)^(y(f[1])-y(f[i])),i,1,length(f)),r,.1);
(%o157)                  [[r = - .017843072768412977]]

Example 3:

(%i158) f : [[-1, 2011, 1, 1], [3.3, 2012, 2, 1], [5.4, 2015, 3, 1],
             [6.01, 2015, 3, 15], [17.8, 2015, 4, 10]]$

(%i159) load(mnewton)$y(d):=?encode\-universal\-time(0,0,0,d[4],d[3],d[2])/31536000$mnewton(sum(f[i][1]*(1+r)^(y(f[1])-y(f[i])),i,1,length(f)),r,.1);
(%o161)                   [[r = 2.4823712861605407]]

My time zone is America/New_York. Because of the daylight-saving bug, other time zones might give slightly different answers.

Ungolfed

load(mnewton)$

/*
Returns the number of 365-day periods since the epoch, when called as
year([year, month, day]).
*/
year(date):=
?encode\-universal\-time(
  /* s, m, h, day, month, year, time zone */
  0, 0, 0, date[3], date[2], date[1], 0) /
31536000 /* seconds in 365 days */$

/*
Finds a numerical approximation for the internal rate of return for a
list of cash flows on a list of dates.  The dates must be a list of
lists in the form

    [[year, month, day], [year, month, day], ...]

The first date in the list is the present date for calculating the
present value of each cash flow.  Returns the rate for each 365-day
period.
*/
xirr(flows, dates):=
part(
  /* Solve for rate where net present value = 0. */
  mnewton(
    sum(
      /* present value of flows[i] on dates[i] */
      flows[i] * (1 + rate)^(year(dates[1]) - year(dates[i])),
      i, 1, length(flows)),
    rate  /* solve for rate */,
    .1    /* initial guess */)
  [1][1], /* extract 1st solution, 1st variable */
  2       /* value in variable = value */)$

Here xirr(flows, dates) is a function, but the golfed version only has an expression that looks at f.  The golfed version also removes the part call and adds the daylight-saving bug.


Python 2, 240 bytes

Straightforward binary encoding implementation.

R=range(26)
print"\n".join(" ".join(chr(65+r)+chr(65+c)if int("8hfxckgq1olihfa47x3rrdkojzkklec7qk1hp4ht6avmzxfg7c4uv14xe0pzvvg93x81ag2bf88v2w0p3p08g8nwtuktbwosj9dytset3qmhdl72v5u62nepapgabdqqu7x",36)&1<<c+r*26 else"  "for c in R)for r in R)

The script for generating the integer is quick and dirty:

codes="""AA    AC AD AE AF AG    AI       AL AM AN AO AP AQ AR AS AT AU    AW AX    AZ
BA BB    BD BE BF BG BH BI BJ    BL BM BN BO    BQ BR BS BT BU BV BW BX BY BZ
CA    CC CD    CF CG CH CI    CK CL CM CN CO CP    CR CS    CU CV CW CX CY CZ
            DE    DG       DJ DK    DM    DO                            DY DZ
EA    EC    EE EF EG EH             EM       EP    ER ES ET EU EV EW
                        FI FJ FK FL FM    FO       FR                FX
GA GB GC GD GE GF GG GH GI       GL GM GN    GP GQ GR GS GT GU    GW    GY
                              HK    HM HN          HR    HT HU
   IB IC ID IE                   IL IM IN IO    IQ IR IS IT IU IV IW IX IY IZ
JA          JE                      JM    JO JP
            KE    KG KH KI          KM KN    KP    KR             KW    KY KZ
LA LB LC       LF       LI    LK                   LR LS LT LU LV       LY
MA    MC MD ME MF MG MH       MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ
NA    NC    NE NF NG    NI       NL       NO NP    NR    NT NU             NZ
OA                                  OM
PA          PE PF PG PH PI    PK PL PM PN          PR PS PT       PW    PY
QA                                  QM QN QO QP QQ QR QS QT QU QV QW QX QY QZ
RA RB RC    RE       RH RI       RL RM RN RO RP       RS    RU    RW
SA SB SC SD SE SF SG SH SI SJ SK SL SM SN SO       SR SS ST SU SV    SX SY SZ
TA    TC TD    TF TG TH    TJ TK TL TM TN TO TP    TR    TT    TV TW       TZ
UA                UG          UK    UM                US                UY UZ
VA    VC    VE    VG    VI             VN                   VU
               WF                WL       WO          WS       WV
XA XB XC XD XE XF XG XH XI XJ XK XL XM XN XO XP XQ XR XS XT XU XV XW XX XY XZ
            YE                                           YT YU YV
ZA                                  ZM             ZR             ZW       ZZ
"""
n = sum(1 << (x/3) for x in range(0, len(codes), 3) if codes[x] != " ")
def baseN(num,b,numerals="0123456789abcdefghijklmnopqrstuvwxyz"):
    return ((num == 0) and numerals[0]) or (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b])
print baseN(n, 36)


Ruby, Into the Corner, Score: 3340

Here is a very simple strategy to kick this off. I do have an idea for a (near) perfect score, but I'm having trouble formalising it, so here is something simple to get things going.

def slide board, dir
    case dir
    when 'U'
        i0 = 0
        i_stride = 1
        i_dist = 4
    when 'D'
        i0 = 15
        i_stride = -1
        i_dist = -4
    when 'L'
        i0 = 0
        i_stride = 4
        i_dist = 1
    when 'R'
        i0 = 15
        i_stride = -4
        i_dist = -1
    end

    4.times do |x|
        column = []
        top_merged = false
        4.times do |y|
            tile = board[i0 + x*i_stride + y*i_dist]
            next if tile == 0
            if top_merged || tile != column.last
                column.push tile
                top_merged = false
            else
                column[-1] *= 2
                top_merged = true
            end
        end

        4.times do |y|
            board[i0 + x*i_stride + y*i_dist] = column[y] || 0
        end
    end

    board
end

def advance board
    if board.reduce(:*) > 0
        return board, board
    end

    16.times do |i|
        if board[15-i] == 0
            board[15-i] = 4
            break
        end
    end

    spawned = board.clone

    # Attention, dirty dirty hand-tweaked edge cases to avoid
    # the inevitable for a bit longer. NSFS!
    if board[11] == 8 && (board[12..15] == [32, 16, 4, 4] ||
                          board[12..15] == [16, 16, 4, 4] && board[8..10] == [256,64,32]) ||
       board[11] == 16 && (board[12..15] == [32, 8, 4, 4] ||
                           board[12..15] == [4, 32, 8, 8] ||
                           board[12..15] == [4, 32, 0, 4])

        dir = 'R'
    elsif board[11] == 16 && board[12..15] == [4, 4, 32, 4] ||
          board[11] == 8 && board[12..15] == [0, 4, 32, 8]
        dir = 'U'
    else
        dir = (board.reduce(:+)/4).even? ? 'U' : 'L'
    end

    board = slide(board, dir)

    if board == spawned
        dir = dir == 'U' ? 'L' : 'U'
        board = slide(board, dir)
    end
    return spawned, board
end

The advance function is the one your asking for. It takes a board as 1d array and returns the board after the tile has been spawned and after the move has been made.

You can test it with this snippet

board = [0]*16
loop do
    spawned, board = advance(board)
    board.each_slice(4) {|row| puts row*' '}
    puts
    break if board[15] > 0
end

puts "Score: #{board.reduce :+}"

The strategy is very simple, and is the one I actually used to skip to the 128 when I was playing 2048 myself: just alternate between up and left. To make this work for as long as possible, new 4s are spawned in the bottom right corner.

EDIT: I've added a hard coded switch to go right a few times at specific steps just before the end, which actually lets me reach 1024. This is getting somewhat out of hand though, so I'll stop with this for now and think about a generally better approach tomorrow. (Honestly, the fact that I can increase my score by a factor of 4 by adding hand-tweaked hacks only tells me that my strategy is crap.)

This is the board you end up with

1024 512 256 128
 512 256 128  16
 256 128  64   8
   8  32   8   4


Ordered sequence of ascending integer combinations

Haskell, 89 bytes

g takes an integer and returns a string.

g n=unlines$max"-".foldr(\(s,i)r->id=<<[show i++s:r|s:r>"+"])""<$>mapM(mapM(,)"+-")[1..n]

Try it online!

How it works

Loosely speaking, the algorithm constructs a list of all 2^n combinations 1+2+...n+, 1+2+...n- up to 1-2-...n-, strips away the final +-terminated numbers, and if the result is empty, replaces it with -.
mapM(,)"+-" is a shorter way (using the function monad) to write \i->[('+',i),('-',i)].
mapM(mapM(,)"+-")[1..n] generates (using the list monad for the outer mapM) a list with all combinations as lists of tuples e.g. [(1,'+'),(2,'-'),...,(n,'+')].
foldr ... <$> ... combines each of these lists of tuples into a string, using the lambda expression to build it from the right.

(s,i) is a tuple of a sign and a number, and r is the string constructed from the tuples to its right.
id=<<[show i++s:r|s:r>"+"] prepends i and s to the string r constructed so far, but not if the sign s is positive and r is empty.

This is tested by comparing s:r to "+". By luck this is the lexicographically smallest string that can result from concatenating them, so the comparison can use > rather than /=.

Also by luck, "-" is smaller than any nonempty string that can be constructed by the fold, so the empty string can be replaced with it by using max.
Finally unlines turns the strings into a single string of lines.


Python 2.7 571 542 509

import sys
o,l,v,k,w="MYPOCKET",[list(e)for e in sys.stdin],[],enumerate,len
def f(z,q,t):
 for r,c in(z,q+1),(z,q-1),(z+1,q),(z-1,q):
  if w(l)>r>=0 and 0<=c<w(l[r])and o[t]==l[r][c]:
    v.append((r,c))
    if f(r,c,(t+1)%w(o)):return 1
    else:v.pop()
 if z==1 and(0,q)in v or z==0 and(z,q+1)in v:return 1
for i,x in k(l[0]):
 v=[(0,i)]
 if x==o[0]and f(0,i,1):break
for i in range(1,w(l)-1):b=[y for x,y in sorted(v)if x==i];print"".join(["".join(e)if w(e)>0 else" "for e in[l[i][b[j-1]+1:y]for j,y in k(b)][1:]])

Works as a program(banking on a recursive function) and accepting input from stdin.
Demo here.Testing it (ex1.txt and ex2.txt are the examples from the question)-

$ python pockets.py < ex1.txt
F
BND
EUF
SNDUW
BOVUV
ENWF
$ python pockets.py < ex2.txt
  HA
NDSES
 HA

Ungolfed version with comments -

s="""
EKCYMOPD
KCOPHAYM
EKNDSEST
JETHACKE
KRMYPOBN
"""
li2=[list(e.strip()) for e in s.split("\n") if e.strip()!='']
buf=[]
def find_precious(row, col, c_ind):
    for r,c in[(row,col+1),(row,col-1),(row+1,col),(row-1,col)]:
        if len(li2)>r>=0 and 0<=c<len(li2[r]) and seq[c_ind]==li2[r][c]:
            if (r,c)in buf:return True
            buf.append((r,c))
            if find_precious(r,c,(c_ind+1)%len(seq)):return True
            else:buf.pop()
    if row==1 and (row-1,col) in buf or row==0 and (row,col+1) in buf:return True
    return False

for i,x in enumerate(li2[0]):
    if x==seq[0]:
        buf=[(0,i)]
        if find_precious(0,i,1):break
if len(buf)==1:
    exit("Failed")

#Calculate the middle men
for i in range(1,len(li2)-1):
    b=[y for x,y in sorted(buf)if x==i]
    print "".join(["".join(e)for e in [li2[i][b[j-1]+1:y]for j,y in enumerate(b)][1:]if len(e)>0])

Let me know, if I did something stupid or something can be done better.
I know it's looong, but it's the best I could do :P


APL (Dyalog Unicode), 7 bytes

⌽∘⍉⍣⎕⊢⎕

Try it online!

⎕ prompt for matrix expression from stdin

⊢ yield that

⎕ prompt for \$i\$ expression from stdin

⍣ do the following that many times

⍉ transpose

∘ and then

⌽ mirror


Find the sum of all possible base representations

Python 3, 72 71 69 bytes
Thanks to FryAmTheEggman for saving a byte!
Thanks to DSM for saving 2 bytes!
N=x=0
y=input()
while N<36:
 N+=1
 try:x+=int(y,N)
 except:0
print(x)


Python

import random

def sample(n, lower, upper):
    result = []
    pool = {}
    for _ in xrange(n):
        i = random.randint(lower, upper)
        x = pool.get(i, i)
        pool[i] = pool.get(lower, lower)
        lower += 1
        result.append(x)
    return result

I probably just re-invented some well-known algorithm, but the idea is to (conceptually) perform a partial Fisher-Yates shuffle of the range lower..upper to get the length n prefix of a uniformly shuffled range.

Of course, storing the whole range would be rather expensive, so I only store the locations where the elements have been swapped.

This way, the algorithm should perform well both in the case where you're sampling numbers from a tight range (e.g. 1000 numbers in the range 1..1000), as well as the case where you're sampling numbers from a large range.

I'm not sure about the quality of randomness from the built-in generator in Python, but it's relatively simple to swap in any generator that can generate integers uniformly from some range.


Python 3, 54 bytes

Thanks Python for having a built-in function for this task! :D

import os;print(os.path.commonprefix(input().split()))

Takes input as two words separated by a space such as glossary global.


Shortest example of code that is compiled and increasing the optimization level makes it take longer

C (gcc 6.2.0-5ubuntu12 x86_64), 58 bytes

typedef struct{long a,b}s;s f(long*c){return(s){*c,c[1]};}

Compiled with -O1, we get the following assembly code (minus boilerplate):

f:
    movq    8(%rdi), %rdx
    movq    (%rdi), %rax
    ret

With -O3, it looks like this:

f:
    movdqu  (%rdi), %xmm0
    movaps  %xmm0, -24(%rsp)
    movq    -24(%rsp), %rax
    movq    -16(%rsp), %rdx
    ret

This is obviously worse (the first version copies from memory to registers directly, the second version copies from memory into the wrong register, back into scratch space in memory, and then from there into the correct registers, which is just doing more work for no gain).

This is a pretty longstanding example of a silly gcc miscompilation. In older versions of gcc, the -O3 code was even worse (containing a full function setup/teardown sequence, stack protection checks, and the like); it seems to have improved somewhat in the more recent versions.

Incidentally, clang produces code almost identical to gcc's -O1 at any positive optimization level (the only difference is that sometimes the two assignments are done in the other order).


CJam, 81 70 bytes
'"qN/{__Sm0=#>}%N*"=
="/"=\"\"="*'"++~]$_W='=/,f{1$'=/,m4/\N/\f{S*\N}}

So we have to stack the Christmas presents? This code does it like an actual person would do*.
First, we stack all the presents against a wall to easily move them up and down using this code:
'"qN/{__Sm0=#>}%N*

then, we identify each present as a separate item using this code:
"=
="/"=\"\"="*'"++~]

then, we sort the presents based on their heights and widths using this code:
$

Till now, all the gifts have been stacked against a wall in order to have perfect alignment with each other. But as this is Christmas, we want to place the gifts aligned centered like a Christmas tree! This code does that:
_W=Af{1$Am4/\N/\f{S*\N}}

Here is a step by step output of the code for example in the question:
"Step 1 - Stack the presents against a wall";
========================
|                      |
========================
=============
|           |
|           |
|           |
|           |
|           |
|           |
=============
=======
|     |
|     |
|     |
=======
===================
|                 |
|                 |
|                 |
===================
=================
|               |
|               |
|               |
|               |
=================
=======
|     |
|     |
=======

"Step 2 - Identify the presents as a collection of presents";
["========================
|                      |
========================" "=============
|           |
|           |
|           |
|           |
|           |
|           |
=============" "=======
|     |
|     |
|     |
=======" "===================
|                 |
|                 |
|                 |
===================" "=================
|               |
|               |
|               |
|               |
=================" "=======
|     |
|     |
======="]

"Step 3 - Sort on height & width, with presents stacked against a wall to help sort them";
=======
|     |
|     |
=======
=======
|     |
|     |
|     |
=======
=============
|           |
|           |
|           |
|           |
|           |
|           |
=============
=================
|               |
|               |
|               |
|               |
=================
===================
|                 |
|                 |
|                 |
===================
========================
|                      |
========================

"Final step - stack them like a Christmas Tree";
        =======
        |     |
        |     |
        =======
        =======
        |     |
        |     |
        |     |
        =======
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
   =================
   |               |
   |               |
   |               |
   |               |
   =================
  ===================
  |                 |
  |                 |
  |                 |
  ===================
========================
|                      |
========================

Try it online here
* Might differ from person to person though :P


MATL, 6 bytes
2^:q^s

Try it online!
2^   % Take implicit input, say N, and square it: N^2
:q   % Generate array [0 1 ... N^2-1]
^    % Take implicit input, M, and compute [M^0 M^1 ... M^(N^2-1)]
s    % Sum of the array. Implicit display


Python, 292 chars

import sys
R=''
for x in sys.stdin:R+='%-97s\n'%x[:-1].replace(' ','@')
M={'/':'-98/d','\\':'98/d'}
for d in(-98,-1,1,98,99,97,-97,-99):
 if d>98:M={'|':'d^2','-':'-d^2'}
 p=R.find('C')
 while 1:
  p+=d
  if R[p]in' @':R=R[:p]+' '+R[p+1:]
  elif R[p]in M:d=eval(M[R[p]])
  else:break
print R,

Reads in the room, makes it rectangular, then walks out from the candle in all directions.  M contains the active mirror characters and their effect (/\ for the cardinal directions, |- for the others)

Can handle rooms up to 97 characters wide.


Jelly, 13 bytes

Q⁼g
*`Ṗ©bç"®S

Try it online!

Another O(nn) solution.

Explanation

Q⁼g  Helper link. Input: digits (LHS), integer (RHS)
Q    Unique (digits)
 ⁼   Match
  g  GCD between each digit and the integer

*`Ṗ©bç"®S  Main link. Input: integer n
*`         Compute n^n
  Ṗ        Pop, forms the range [1, n^n-1]
   ©       Store previous result in register
    b      Convert each integer to base n
     ç"    Call the helper link, vectorized, with
       ®   The register's value
        S  Sum


JavaScript (ES6),  111 ... 84  80 bytes
Returns true rather than \$1\$ for \$n=2\$.

f=(n,j)=>(g=(i,x,e=1)=>i?e>n?g(i-1,x):g(i-1,x+e)+g(i,x,e*x):x==n)(j,2)||f(n,-~j)

Try it online!
Commented
f = (                     // f is the main recursive function taking:
  n,                      //   n = input
  j                       //   j = maximum number of steps
) => (                    //
  g = (                   // g is another recursive function taking:
    i,                    //   i = number of remaining steps
    x,                    //   x = current sum
    e = 1                 //   e = current exponentiated part
  ) =>                    //
    i ?                   // if there's still at least one step to go:
      e > n ?             //   if e is greater than n:
                          //     add the result of a recursive call with:
        g(i - 1, x)       //       i - 1, x unchanged and e = 1
      :                   //   else:
                          //     add the sum of recursive calls with:
        g(i - 1, x + e) + //       i - 1, x + e and e = 1
        g(i, x, e * x)    //       i unchanged, x unchanged and e = e * x
    :                     // else:
      x == n              //   stop recursion; return 1 if x = n
)(j, 2)                   // initial call to g with i = j and x = 2
|| f(n, -~j)              // if it fails, try again with j + 1


CJam (100 98 91 89 83 bytes)

1a{_[XX]*\_{_0a*}:E~\{E\_{ff*W%{0@+.+}*}:C~.+2f/}:D~.+C.+3f/1\+}q~:I*DE1$D.-X\+.+I=

Takes input from stdin, outputs to stdout. Note that this exploits the licence to not handle input 0 to save two bytes by inlining the definitions of C and D. Online demo

NB this is very slow and memory-inefficient. By trimming arrays a much faster version is obtained (3 bytes more). Online demo.

Dissection

OEIS gives (modulo an indexing error) the generating function decomposition $$\begin{eqnarray}
A000598(x) &=& 1 + x Z(S_3; A000598(x)) \\
A000678(x) &=& x Z(S_4; A000598(x)) \\
A000599(x) &=& Z(S_2; A000598(x) - 1) \\
A000602(x) &=& A000678(x) - A000599(x) + A000598(x^2) \\
\end{eqnarray}$$ where \$Z(S_n; f(x))\$ denotes the cycle index of the symmetric group \$S_n\$ applied to the function \$f(x)\$.

I manipulated this into a slightly golfier decomposition, and then looked up the intermediate sequences and discovered that they're also in OEIS:

$$\begin{eqnarray}
A000642(x) &=& Z(S_2, A000598(x)) \\
A000631(x) &=& Z(S_2, A000642(x)) \\
A000602(x) &=& A000642(x) + x A000642(x^2) - x A000631(x)
\end{eqnarray}$$

Earlier versions reused block C (convolve two polynomials) from this answer. I've found a much shorter one, but I can't update that answer because it's from a chaining question.

1a            e# Starting from [1]...
{             e# Loop I times (see below) to build A000598 by f -> 1 + Z(S_3; f)
  _[XX]*      e#   Copy and double-inflate to f(x^3)
  \_          e#   Flip and copy: stack is f(x^3) f(x) f(x)
  {_0a*}:E~   e#   Assign copy-and-inflate to E and execute
              e#   Stack: f(x^3) f(x) f(x) f(x^2)
  \           e#   Flip
  {           e#   Define and execute block D, which applies f -> Z(S_2;f)
              e#     Stack: ... f
    E\_       e#     Stack: ... f(x^2) f(x) f(x)
    {         e#     Define and execute block C, which convolves two sequences
      ff*     e#       Multiply copies of the second sequence by each term of the first
      W%      e#       Reverse
      {       e#       Fold
        0@+.+ e#         Prepend a 0 to the first and pointwise sum
      }*
    }:C~      e#     Stack: ... f(x^2) f(x)^2
    .+2f/     e#     Pointwise average
  }:D~        e#   Stack: f(x^3) f(x) f(x^2) Z(S_2;f(x))
  .+C         e#   Stack: f(x^3) f(x)*(f(x^2) + Z(S_2;f(x)))
  .+3f/       e#   Add and divide by 3 to finish computing Z(S_3; f)
  1\+         e#   Prepend a 1
}
q~:I          e# Read input to I
*             e# Loop that many times
              e# Stack: I+1 terms of A000598 followed by junk
D             e# Stack: I+1 terms of A000642 followed by junk
E1$D          e# Stack: A000642 A000642(x^2) A000631
.-X\+.+       e# Stack: A000602
I=            e# Extract term I


Find nth root of variable without using math operators/functions

JavaScript

This answer doesn't satisfy all the rules, but I'm happy that at least it works. It's valid only for integers greater than one and there's no further precision.

Note that the + and > operators are used for string concatenation/comparison and the maths is behind the curtain. I hope that the ! operator doesn't count as "arithmetic" as it operates over booleans.

function f(x,n){for(a=(c=',')+Array(x),s=r=c;a>s;r+=c)for(i='',s=r;i!=Array(n);i+=c)s=s.split(c).join(r);return r.slice(1).length}

And some tests:

> f(125,3)
5
> f(16807,5)
7
> f(4782969,7)
9


Swap prime exponents with their neighbours

Jelly, 10 bytes

ÆE;0s2UFÆẸ

Try it online! or verify all test cases.

How it works

ÆE;0s2UFÆẸ  Main link. Argument: n

ÆE          Yield the exponents of n's prime factorization.
  ;0        Append a zero.
    s2      Split into pairs.
      U     Upend; reverse each pair.
       F    Flatten the resulting list of pairs.
        ÆẸ  Convert the prime exponents to integer.


Further golfing this C# code from Scramble words while preserving their outlines

As I am using linq in my program, I can change ToCharArray to ToArray to save 4 bytes.

I can also change the namespace around to be either System.Linq or System.Text.RegularExpressions to save a further 6 bytes by removing the using for it:

namespace System.Text.RegularExpressions

As @MartinEnder♦ points out in the comments I can save 10 bytes by re-ordering the groups in the regex and changing [A-Za-z] to \p{L}:

\p{L}(([gpqy])|(i|t)|(j)|([bdf-l])|([a-z]))*?[a-z]?\b


Perl, 257 bytes

Includes +4 for -0p

Give grammar on STDIN (without trailing spaces. Make sure to remove the extra space in the second example). Assumes non-terminal names only contain letters, digits and _. Uses # instead of $ to indicate end of input. Can handle literals containing spaces

perl -M5.010 follow.pl
E T e
e '+' T e
e
T F t
t '*' F t
t
F '(' E ')'
F 'id'
^D

Outputs the follow sets as a list of non-terminal literal in no particular order. For the example above it outputs:

F ')'
F #
t ')'
t #
T ')'
T #
F '+'
t '+'
T '+'
F '*'
e ')'
e #
E ')'
E #

follow.pl:

#!/usr/bin/perl -0n
s/'.*?'/~$&/eg;s% (?=(\w.*\n))%$_.=">$1"%reg;/\s/;$_.=">$` #\n";s%^((\w+)\K ?\S*).*%$s{$1}++||"\$a.=s/ $2\\b/$&/rg"%eemgr,s%^(\w+ ).*?(\w+)$%"\$a.=s/>$1/>$2 /rg"%eermg,$_.=$a,s%>.*\xd8\K .*%%g,s%.+\n%$&x!/\n$&/g%eg until$$_++;s/\xd8.*?\xd8/~$&/eg;say/>(\w+ \W\S*\n)/g

Works as shown, but replace \xd8 and \n by their literal versions to get the claimed score.

It should be possible to improve this since converting the first sets to the follow sets is currently very awkward.


Improving a Rubik's Cube scrambler's byte count

140 135 127 bytes

Still a big one, but here's for starters:

function(){for(a=s=y=r=[],x=Math.random;a<25;s[a++]=r+["'",2,''][0|x(y=r)*3])for(;r==y;r='RLUDFB'[0|x()*6]);return s.join(' ')}

Some of the few tips used:

Loose the var. There is no point in using var when your aim is to golf!
When a = [], a++ gives 0. We use this fact to remove a 0 and ,
Combine the a<25 and a++
You don't need to split a string. You can access its characters anyways via [i]
Get rid of {} in for loops

More to come.


C (40 -10% = 36) (38 -10% = 34.2)
Note that, in C, a log function can only be defined for a specific type. Therefore, this log "function" takes only int arguments.
#define log(x)printf("log("#x") %d",x)

A more general solution specifies how to print the argument, in addition to the argument itself:
#define lg2(f,x)printf("lg2("#x") "f,x)

which would be used as e.g. lg2("%s", "I'm a string"); or lg2("%f", 3.1415).


Python, 219 chars

I went for maximum golfage, with just enough interface to satisfy the question.

import time
P=input()
N=range(20)
while 1:
 for i in N:print''.join(' *'[i*20+j in P]for j in N)
 time.sleep(.1);Q=[(p+d)%400 for d in(-21,-20,-19,-1,1,19,20,21)for p in P];P=set(p for p in Q if 2-(p in P)<Q.count(p)<4)

You run it like this:

echo "[8,29,47,48,49]" | ./life.py

The numbers in the list represent the coordinates of the starting cells.  The first row is 0-19, the second row is 20-39, etc.

Run it in a terminal with 21 rows and it looks pretty snazzy.


J, 84 bytes

Starting from a 1 element list the function keeps all the possible intermediate numbers in the list by evaling the next expression and adding it's up and down rounded copies.

Will golf further and add explanation tomorrow.
Can't find obvious ways to golf it more.

f=.3 :'/:~~.<.>((,>.,<.)@".@(":@],''x'',;@[))&.>/|.(>@{.;_2<\}.);:y rplc''/'';''%'''

Passes all the tests.

Usage:

   f '1/3*2*2*2*2*2*2'
0 16 20 21 22 24 32 64
   f '1/3*9'
0 3 9

Try it here.


Use xkcd's formula to approximate the world population

Pyth, 21 20 bytes

-1 byte by Dennis

c/J-*3.d3C\ᙹ4T+33J

These have the same byte count but are ASCII-only:

c/J%*3.d3 523 4T+33J
c/-J%*3.d3*44T33 4TJ

I don't know Pyth, so still probably possibly golfable. Using the same algorithm:

TI-BASIC, 23 bytes

max(3getDate-5753
{.1int(Ans/4),Ans+33

getDate returns a list of three floats {YYYY,MM,DD} in some order depending on the date format setting (TI-84s don't have a true int datatype); the max( will be the year. Multiplying and subtracting inside the max( saves a close-paren.


Jelly, 10 bytes

ṗŒḂƤ€Ḋ€Ḅċ1

This is a brute-force search over all ns possible strings.

My results differ from the other answers', but the solutions my answer counts seem to be valid.

Try it online!


I suggest all of them!

More seriously, they all come in handy some of the time, and the more the better! Implicit input is never bad, just have a flag to turn it off. Variables are helpful so they don't need to be found on a stack or tape; same with registers. Stacks are helpful to store data, and so are tapes. I recommend trying to implement multiple, say a stack and registers, or a stack and variables, like GolfScript. If you can make each function one byte, then your language will probably be effective at golfing, as you can use the advantages of each.

An example:

Say I want to take two numbers as inputs, and add their string lengths
Variables might be better for this (a stack might not)
Example code in GolfScript (with implicit input):

~,\,+
~ # Eval input (e.g. "1 2" > 1, 2)
, # Take Length
\ # Reverse items on the stack
, # Take Length
+ # Add
  # Implicit output

However, with variables (I know it's longer, it just doesn't have to swap places on the stack):

~,:a;,:b;ab+
~ # Eval input
, # Get length
:a# Store in "a"
; # Discard value left on stack
, # Length
:b# Store in "b"
; # Discard
a # Recall a
b # Recall b
+ # Add
  # Implicit output

Overloads

Another thing that can be helpful is overloads. For example, if you have a variable storing function, maybe it could be used as a monad (one-input function; I'm not sure of the term out side of J/K/APL) to add to the stack or tape.

Example:

c12 # Stores "1" into register 2
c1] # Pushes "1" onto the stack ("]" is used to denote the end of the monad)


Given a list of Tetris moves, return the number of completed lines

C, 401 392 383 378 374 351 335 324 320 318 316 305 bytes

d[99]={'3Z3Z',983177049,513351321,1016270793,970073931,~0},*L=d+5,V,s;char c;main(x){B:for(c=0;c[++L]|V;V>>=4)c-=(L[c]=*L|(V&15)<<x)>1022;s-=c;if(scanf("%c%1d%d,",&c,&V,&x)>2)for(V=c^79?d[c/4%5]>>24-V*8:27,V=c^73?V/64%4<<8|V/8%8<<4|V%8:V&32?15:4369;;--L)for(c=4;c--;)if(L[c]>>x&V>>c*4&15)goto B;return s;}

Takes comma-separated input on stdin, returns the score in the exit status.

Requires char to be signed (which is the default for GCC) and requires '3Z3Z' to be interpreted as 861549402 (which is the case for GCC on little endian machines, at least).

Usage example:

echo "O00,T24,S02,T01,L00,Z03,O07,L06,I05,I19" | ./tetris; echo "$?";

High-level explanation:

All shapes except the line can fit in a 3x3 grid with one corner missing:

6 7 -
3 4 5
0 1 2

That means it's easy to store them in a byte each. For example:

- - -         0 0 -
- # -   -->   0 1 0   -->   0b00010111
# # #         1 1 1

(we align each piece to the bottom-left of the box to make dropping it easier)

Since we get at least 4 bytes to an int, this means we can store all 4 rotations of each piece in a single integer, with a special case for the line. We can also fit each row of the game grid into an int (only needs 10 bits), and the currently falling piece into a long (4 lines = 40 bits).

Breakdown:

d[99]={             // General memory
  '3Z3Z',           //  Shape of "S" piece (multi-char literal, value = 861549402)
  983177049,        //  Shape of "T" piece
  513351321,        //  Shape of "Z" piece
  1016270793,       //  Shape of "J" piece
  970073931,        //  Shape of "L" piece
  ~0                //  Bottom of game grid (solid row)
},                  //  Rest of array stores lines in the game
*L=d+5,             // Working line pointer (start >= base of grid)
V,                  // Current piece after expansion (also stores rotation)
s;                  // Current score (global to initialise as 0)
char c;             // Input shape identifier (also counts deleted lines)
main(x){            // "x" used to store x location
  B:                                // Loop label; jumps here when piece hits floor
  for(c=0;c[++L]|V;V>>=4)           // Paint latest piece & delete completed lines
    c-=(L[c]=*L|(V&15)<<x)>1022;
  s-=c;                             // Increment score
  if(scanf("%c%1d%d,",&c,&V,&x)>2)  // Load next command
    for(V=c^79?                     // Identify piece & rotation
          d[c/4%5]>>24-V*8          //  Not "O": load from data
        :27,                        //  Else "O": always 27
        V=c^73?                     // If not "I" (line):
          V/64%4<<8|V/8%8<<4|V%8    //  expand shape to 16-bits
        :                           // Else we are a line:
          V&32?                     //  "I" coincides with "J"; use this to check
               15:4369;             //  horizontal/vertical
        ;--L)                       // Loop from top-to-bottom of grid
      for(c=4;c--;)                 //  Loop through rows of piece
        if(L[c]>>x&V>>c*4&15)       //   If collides with existing piece:
          goto B;                   //    Exit loops
  return s;                         // Return score in exit status
}

-4, -1 thanks to @Titus, and -23, -11 with inspiration from their answer