New Ruby, 135 bytes, >> Hψ(φ3(Ω+1))(9)

where H is the Hardy hierarchy, ψ is an extended version of Madore's OCF (will explain below) and φ is the Veblen function.

Try it online!

f=->a,n,b=a{c,d,e=a;a==c ?a-1:e ?a==a-[0]?[[c,d,f[e,n,b]],d-1,c]:c:[n<1||c==0?n:[f[c||b,n-1]],n,n]};h=[],k=9,k;h=f[h,p(k*=k)]while h!=0

Ungolfed: (using functions, not lambdas)

def f(a,n,b)
  c,d,e = a
  if a == c
    return a-1
  elsif e
    if a == a-[0]
      return [[c,d,f(e,n,b)],d-1,c]
    else
      return c
    end
  else
    x = c || b
    if n < 1 || c == 0
      return [n,n,n]
    else
      return [f(x,n-1,x),n,n]
    end
  end
end

k = 9
h = [[],k,k]
while (h != 0) do
  k *= k
  p k
  h = f(h,k,h)
end

Madore's extended OCF:

And (crudely) Veblen's phi function:

Explanation without ordinals:

f(a,n,b) reduces an array recursively. (if no third argument given, it takes the first argument twice.)
f(k,n,b) = k-1, k is a positive int.
f([c,d,0],n,b) = f([c,0,e],n,b) = c
f([c,d,e],n,b) = [[c,d,f(e,n,b)],d-1,c], d ≠ -1 and c ≠ 0

f([a],0,b) = [0,0,0]
f([0],n,b) = [n,n,n]
f([],n,b) = f([b],n,b)
f([a],n,b) = [f[a,n-1,a],n,n]

My program initiates k = 9, h = [[],9,9]. It then applies k = k*k and h = f(h,k) until h == 0 and outputs k.

Explanation with ordinals:

Ordinals follow the following representation: n, [], [a], [a,b,c], where n,d is a natural number and a,c are all ordinals.
x = Ord(y) if y is the syntactic version of x.
a[n,b] = Ord(f(a,n))
ω = Ord([0]) = Ord(f([a],-1,b))
n = Ord(n)
Ω = Ord([])
ψ'(a) = Ord([a])
ψ'(a)[n] = Ord(f([a],n))
φ(b,c) ≈ Ord([[0],b,c])
a(↓b)c = Ord([a,b,c]) (down-arrows/backwards associative hyper operators I designed just for ordinals)

We follow the following FS for our ordinals:
k[n,b] = k-1, k < ω
ω[n,b] = n(↓n)n
(a(↓b)0)[n,b] = (a(↓0)c)[n,b] = a
(a(↓b)c)[n,b] = (a(↓b)(c[n,b]))(↓b[n,b])a, b ≥ 0 and c > 0.
ψ'(a)[0,b] = 0(↓0)0
ψ'(a)[n,b] = (ψ'(a[n-1,a]))(↓n)ω, a > 0 and n ≥ 0. (also note that we've changed from [n,b] to [n,a].)
Ω[n,b] = ψ'(b)[n,b]

ψ'(ω∙α) ≈ ψ(α), the ordinal collapsing function described in the image above.

My program more or less initiates k = 9 and h = Ω(↑9)9, then applies k ← k² and h ← h[k,h] until h = 1 and returns k.

And so if I did this right, [[],9,9] is way bigger than the Bachmann-Howard ordinal ψ(ΩΩΩ...), which is way bigger than ϑ(Ωωω)+1.

ψ(Ω(↓9)9) > ψ(Ω(↓4)3) > ψ(ΩΩΩ)+1 > ψ(ΩΩωω)+1 > ϑ(Ωωω)+1

And if my analysis is correct, then we should have ψ'(ΩΩ∙x) ~= ψ*(ΩΩ∙x), where ψ* is the normal Madore's psi function. If this holds, then my ordinal is approximately ψ*(φ3(Ω+ω)).

Old Ruby, 309 bytes, Hψ'0(Ω9)(9) (see revision history, besides the new one is way better)


Pyth, 39 bytes
Lsm.:bdtUbKfT.zj\,mhf!}Yjb-Kk+yky++bkbK

Bruteforces all subsets of every string in increasing length and checks if that string occurs inside any other. If that doesn't work, it will do the same except for all subsets of \nstring\n.


Perl 5, 92 bytes

sub f{min map{$o=$_;map{$s="@_";$c=!/$o/*$s=~s,$o,$_,g;$s=~/(.) (.) \1/&&$1-$2?9e9:$c}@_}@_}

Try it online!

sub f{                        #ungolfed:
  min                         #minimum of the yielded list of numbers (from core module List::Util)
  map{                        #map: outer loop of f()'s input args
    $o=$_;                    #keep $o (outer) loop element
    map{                      #map: inner loop of f()'s input args
      $s="@_";                #$s string are input args (input chars) concatenated with no separation
      $c=!/$o/*$s=~s,$o,$_,g; #$c becomes 0 if inner and outer loop elements are equal
                              #otherwise $c becomes the number of changes on the input
                              #$s string when swapping $o with $_ (outer and inner loop variable)
      $s=~/(.) (.) \1/&&$1-$2 #check if $s after the swapping is valid: no three consecutive chars
                              #...should exists in $s where 1st and 3rd are equal but 2nd is not
        ? 9e9                 #yield big number 9e9 if $s is invalid to make sure it wont be the minimum
        : $c                  #yield the number of swaps if $s is valid
    }
    @_                       #input arg's
  }
  @_                         #input arg's, outer loop
}


Mathematica (41)
s = "2+5-6/9*8+7";
ToExpression@StringReplace[s,"/"->"^-1 "]

2

Correct me if I'm wrong


Python 2, 495 bytes

This one is a real-time KMP, which is a lot shorter and only slightly slower than the BMG algorithm (which is usually sublinear). Call with K(pattern, text); output is identical to the BMG algorithm.

L,R,o=len,range,lambda x:ord(x)-97
def K(P,T):
 M,N=L(P),L(T);Z=[0]*M;Z[0]=M;r=l=0
 for k in R(1,l):
    if k>r:
     n=0
     while n+k<l<P[n]==P[n+k]:n+=1
     Z[k]=n
     if n>0:l,r=k,k+n-1
    else:
     p,_=k-l,r-k+1
     if Z[p]<_:Z[k]=Z[p]
     else:
        i=r+1
        while i<M<P[i]==P[i-k]:i+=1
        Z[k],l,r=i-k,k,i-1
 F=[[0]*26]*M
 for j in R(M-1,0,-1):z=Z[j];i,x=j+z-1,P[z+1];F[i][o(x)]=z
 s=m=0
 while s+m<N:
    c=T[s+m]
    if c==P[m]:
     m+=1
     if m==M:print s,;s+=1;m-=1
    else:
     if m==0:s+=1
     else:f=F[m][o(c)];s+=m-f;m=f


Python 2, 43 45 bytes

lambda s:reduce(lambda p,n:n*(7-p!=n!=p>0),s)

43 bytes (inspired heavily by @Zgarb)

lambda s:reduce(lambda p,n:n*(p>0<n^p<7),s)

This function combines my reduce statement with the bit-flicking logic from @Zgarb's answer, for a combination that is shorter than both.

Both answers output the following:

0 if the input is not a valid sequence
The last digit of the sequence if it is valid


Husk, 10 bytes
►ȯLU¡oΠd↔ŀ

Try it online!
Explanation
►ȯLU¡oΠd↔ŀ
        ↔ŀ reverse the range 0..n-1
►ȯ         max-by, returning the last maximal element for the following:
    ¡o      create an infinite list using:
      Πd     product of digits.
   U        longest unique prefix
  L         take its length


Python 2, 29

lambda x:len(x)/(x!='google')

Gives a ZeroDivisionError on "google", and the length otherwise. This takes advantage of Python's booleans equaling 0 and 1.


Python 2, 26 24 23 bytes
-2 bytes thanks to @Adnan (replace p*(p+1)/2 with p*-~p/2)
-1 byte thanks to @MartinEnder (replace -p*-~p/2 with +p*~p/2

lambda n,p:n-p*n+p*~p/2

Tests are on ideone


Haskell: ψ(ΩΩω) + 999672 points

main=print$f++shows f"$iterate(Z:@)Z";f="data N=Z|N:@N deriving Show;r=repeat;s Z=[];s(a:@Z)=r a;s(Z:@b)=($u b)<$>h b;s(a:@b)=do(f,c)<-h b`zip`s a;f<$>[c:@b,a]\nh=scanl(flip(.))id.t;t(Z:@Z)=r(:@Z);t(Z:@b)=((Z:@).)<$>t b;t(a:@b)=flip(:@).(:@b)<$>s a;u Z=Z;u(Z:@b)=u b;u(a:@_)=a;g f=mapM_$print.((f++shows f\"$s$\")++).show;main=g"

329 bytes of code with ordinal ψ(ΩΩω) + 1. Uses a tree-based representation of ordinals discovered by Jervell (2005). The tree with children α, β, …, γ is denoted α :@ (β :@ (… :@ (γ :@ Z)…)). This left-to-right order agrees with Jervell, although note that Madore flips it right-to-left.

Haskell: Γ0 + 999777 points

main=print$f++shows f"$iterate((:[]).T)[]";f="data T=T[T]deriving(Eq,Ord,Show);r=reverse;s[]=[];s(T b:c)=(++c)<$>scanl(++)[](b>>cycle[fst(span(>=T b)c)++[T$r d]|d<-s$r b]);g f=mapM_$print.((f++shows f\"$s$\")++).show;main=g"

224 bytes of code with ordinal Γ0 + 1. This is based on a generalization of Beklemishev’s Worm to ordinal-valued elements, which are themselves recursively represented by worms.

Haskell: ε0 + 999853 points

main=print$f++shows f"$map(:[])[0..]";f="s[]=[];s(0:a)=[a];s(a:b)=b:s(a:fst(span(>=a)b)++a-1:b);g f=mapM_$print.((f++shows f\"$s$\")++).show;main=g"

148 bytes of code with ordinal ε0 + 1. This is based on Beklemishev’s Worm. The list

map(+1)α ++ [0] ++ map(+1)β ++ [0] ++ ⋯ ++ [0] ++ map(+1)γ

represents the ordinal (ωγ + ⋯ + ωβ + ωα) − 1. So the second-level outputs [0], [1], [2], [3], … represent 1, ω, ωω, ωωω, …, the first-level output represents ε0, and the initial program represents ε0 + 1.

Haskell: ε0 + 999807 points

main=print$f++shows f"$iterate(:@Z)Z";f="data N=Z|N:@N deriving Show;s Z=[];s(Z:@b)=repeat b;s(a:@Z)=scanl(flip(:@))Z$s a;s(a:@b)=(a:@)<$>s b;g f=mapM_$print.((f++shows f\"$s$\")++).show;main=g"

194 bytes of code with ordinal ε0 + 1.

Z represents 0, and we can prove by transfinite induction on α, then on β, that α :@ β ≥ ωα + β. So there are second-level outputs at least as big as any tower ωω⋰ω, which means the first-level output is at least ε0 and the initial program is at least ε0 + 1.


Befunge, Score 0

I think I cracked it - no single character deletion will change the output.
Deleting any character from line 1 changes nothing - it still goes down at the same place.
Lines 2 and 3 are redundant. Normally line 2 is executed, but if you delete a character from it, the < is missed, and line 3 takes charge.
Deleting newlines doesn't break it either (it did break my previous version).
No test program, sorry.

EDIT: simplified a lot.

                              vv
@,,,,,,,,,,,,,"Hello, world!"<<
@,,,,,,,,,,,,,"Hello, world!"<<

A short explanation of the flow:

Befunge starts executing from top-left, moving right. Spaces do nothing.
v turns the execution flow downward, so it goes down one line.
< turns the execution flow left, so it reads line 2 in reversed order.
"Hello, world!" pushes the string to the stack. It's pushed in reversed order, because we're executing right to left.
, pops a character and prints it. The last character pushed is printed first, which reverses the string once more.
@ terminates the program.


Exciting Mario Kart Grand Prix - Minimize the point difference!

JavaScript (ES7), 19 bytes

n=>14/n**n+1^n%12<1

Try it online!
We compute:
$$\left\lfloor\frac{14}{n^n}+1\right\rfloor$$
which is \$\lfloor 14/1+1\rfloor=15\$ for \$n=1\$, \$\lfloor 14/4+1 \rfloor=4\$ for \$n=2\$, or \$1\$ for \$n>2\$.
We then XOR the result with \$1\$ if \$n \bmod 12=0\$.


Jelly, 7 bytes

Æf^<¥4P

Swaps 2s and 3s in the input's prime factorization. The probability of odds is 2/3.

Try it online!

How it works

Æf^<¥4P  Main link. Argument: n

Æf       Compute all prime factors of n, with duplicates.
    ¥4   Combine the two links to the left into a dyadic chain and call it with
         right argument 4.
   <       Compare each prime factor with 4. Yields 1 for 2 and 3, 0 otherwise.
  ^        Bitwise XOR the results with the corresponding prime factors.
         This maps 2 to 3, 3 to 2, and all other primes to themselves.
      P  Take the product of the resulting primes.


Haskell, 31 bytes

f(a:b:c:d:e)=a:c:f(b:d:e)
f x=x

Try it online!

Avoids having to special-case omitting the first character by having extracting it be part of the recursive definition.


Jelly, 13 bytes

,²DS€=/
1Ç³#Ṫ

Input is 1-indexed. Try it online!

How it works

1Ç³#Ṫ    Main link. Argument: n (index)

1        Set the return value to 1.
   #     Execute ... until ... matches have been found.
 Ç         the helper link
  ³        n
    Ṫ    Extract the last match.

,²DS€=/  Helper link. Argument: k (integer)

,²       Pair k with k².
  D      Convert each to decimal.
   S€    Compute the sum of each list of base 10 digits.
     =/  Reduce by equality.


05AB1E, 20 12 bytes

Saved 8 bytes thanks to Osable!

µNSDOsP‚¾>å½

Uses the CP-1252 encoding. Try it online!


Rolling three dice and show the probabilities


05AB1E, 13 11 bytes

Code:

Thanks to Emigna for saving two bytes!

LDÈ-Ì'#3Ý·Λ

Uses the 05AB1E encoding. Try it online!

Explanation

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

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

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

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

This basically gives us the desired list of lengths.

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

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

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

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


Vim (no external tools), 106 bytes

Newlines for clarity:

:h<_↵↵↵YZZPllabc♥
:s/./\u&&/g↵
qa6li↵♥q7@a3i ♥fY
i↵    →→↵  →↵→ð♥
ʌHA ♥9l
qbmaʌ99jY$P`ah@bq@b
y11G:g//m0↵P

Here ↵ is Return, → is Right, ♥ is Escape, ʌ is CTRL-V, and ð is Delete.


Python 2, 203 202 187 133 bytes

a,b=input()
s=0
while a:print'%3s%9s'%(a,'[ %%dd] '[a%2::2]%b);s+=[0,b][a%2];a/=2;b*=2
print'%10s==\n%11s'%(''.rjust(len(`s`),'='),s)

Try it online!
If I can use * for string multiplication ('='*R) and as a 'selector' (b*(a%2) instead of [0,b][a%2]), I get:
118 bytes

a,b=input()
s=0
while a:print'%3s%9s'%(a,'[ %%dd] '[a%2::2]%b);s+=a%2*b;a/=2;b*=2
print'%10s==\n%11s'%('='*len(`s`),s)

Try it online!

Explanation:
a,b=input()                   #Get input
L=len(`a`)                    #Get length of first number for adjusting text
l=[]                          #Output list
s=0                           #Sum
while a:
 B=['[%d]',' %d '][a%2]%b     #B is either '[b]' or ' b ' depending on if a is odd/even
 l+=[(`a`,B)]                 #Add a,B to output list
 s+=[0,b][a%2]                #Add b to sum if a is odd
 a/=2;                        #Halve a
 b*=2;                        #Double b
R=len(B)                      #Length of last B for adjusting output
l+=[('',''.rjust(R,'='))]     #Add double line ==== to output list
l+=[('','%d '%s)]             #Add sum to output list
for x,y in l:
 print x.rjust(L),y.rjust(R)  #Print adjusted numbers


Haskell, 45 bytes

n!a=not$any(n!)[x|x<-[n..a-1],mod a x<1]||n>a

Try it online!

I define a nice recursive function (!):

n!a checks if any factor of a, in the range [n,a-1], is an n-prime. Then it negates the result. It also makes sure that n>a


MATL, 52 bytes
xxx:"1GY.Xx2e3Z@25eHG>~47*cD]Xx12:~c!3G80yn-H/kZ"why

Inputs are, in this order: pause between updates, number of drops, message, number of repetitions. The monitor has size 80×25 characters (hard-coded).
GIF or it didn't happen! (Example with inputs 0.2, 100, 'THE END', 30)

Or try it at MATL Online.
Explanation
xxx      % Take first three inputs implicitly and delete them (but they get
         % copied into clipboard G)
:"       % Take fourth input implicitly. Repeat that many times
  1G     %   Push first input (pause time)
  Y.     %   Pause that many seconds
  Xx     %   Clear screen
  2e3    %   Push 2000 (number of chars in the monitor, 80*25)
  Z@     %   Push random permutation of the integers from 1 to 2000
  25e    %   Reshape as a 25×80 matrix, which contains the numbers from 1 to 2000
         %   in random positions
  HG     %   Push second input (number of drops)
  >~     %   Set numbers that are <= second input to 1, and the rest to 0
  47*c   %   Multiply by 47 (ASCII for '/') and convert to char. Char 0 will
         %   be displayed as a space
  D      %   Display
]        % End
Xx       % Clear screen
12:~     % Push row vector of twelve zeros
c!       % Convert to char and transpose. This will produce 12 lines containing
         % a space, to vertically center the message in the 25-row monitor
3G       % Push third input (message string)
80       % Push 80
yn       % Duplicate message string and push its length
-        % Subtract
H/k      % Divide by 2 and round down
Z"       % Push string of that many spaces, to horizontally center the message
         % in the 80-column monitor
w        % Swap
h        % Concatenate horizontally
y        % Duplicate the column vector of 12 spaces to fill the monitor
         % Implicitly display


53 parts - 11x11 grid
I just learned to play Manufactoria 2 days ago, so it is probably not very golf-optimized, but at least it solves the problem. It implements trial division of course, via repeated subtraction. All divisors from 2 to N-1 are checked. The time complexity should be O(N^3), I believe.

Solution Link
I was very disappointed to have to use a conveyor belt :)


Resource for generating shortest regex given a list of strings

The Machine Learning Lab at the University of Trieste, Italy, wrote a web app to solve this exact problem, available at: Automatic Generation of Regular Expressions from Examples based on "genetic programming" and published a paper about it. Based on the fact that it had to come from the Machine Learning Lab of a university in Italy, and was worth publishing a paper about, it is probably a pretty hard problem to solve. Doesn't sound like the type of question for Code Golf SE, but I'm new here, so I wouldn't be the expert on that.


Snails, 15 bytes
\Oo!{.,fee7.,\F

Try it online!
1 means survival while 0 means death.
Since it is impossible to outrun the fire, it is never useful to try to go around it. The best route is always a straight line. So there are only four possible choices of escape route. To determine if a direction is safe, we check for any F in the "fire cone" pointing in that direction.


Write a self replicating program that stops replicating after "printing" "Hello world!" with the filenames

Python 2, 194

import os,sys
h,A='H|e|l|l |o| |w|o |r|l  |d|!'.split('|'),sys.argv[0]
d,a,F=dict(zip(h,h[1:])),A.split('.')[0],file
if a in d:o=d[a]+'.py';F(o,'w').write(F(A).read());os.popen('python "'+o+'"')


Python 2, 191 bytes

from math import*
C=sorted(input());l,h=C[-1]/2,sum(C)
while h-l>1e-9:m=l+h;a=[asin(c/m)for c in C[:-1]];f=pi-sum(a);l,h=[l,m/2,h][m*sin(f)<C[-1]:][:2]
print sum(l*l*sin(2*t)for t in a+[f])/2

Uses a binary search to find the radius, then calculates the area of each segment by the angle/radius.

It finds the radius by first summing all but the largest chord angle, and checking the remaining angle to the remaining chord. Those angles are then also used to compute the area of each segment. A segment's area can be negative, if it's angle is bigger than 180 degrees.

Readable implementation:

import math

def segment_angles(line_segments, r):
    return [2*math.asin(c/(2*r)) for c in line_segments]

def cyclic_ngon_area(line_segments):
    line_segments = list(sorted(line_segments))
    lo, hi = max(line_segments) / 2, sum(line_segments)
    while hi - lo > 1e-9:
        mid = (lo + hi) / 2
        angles = segment_angles(line_segments[:-1], mid)
        angles.append(2*math.pi - sum(angles))
        if 2 * mid * math.sin(angles[-1]/2) < line_segments[-1]:
            lo = mid
        else:
            hi = mid
    return sum([lo*lo * math.sin(a) / 2 for a in angles])


Smallest number such that concatenation is a square

05AB1E, 7 bytes
∞<.Δ«Å²

Try it online or verify all test cases.
05AB1E (legacy), 8 bytes
[N«Å²#}N

Try it online or verify all test cases.
Alternative 8-byter which works in both 05AB1E versions (credit to @Grimmy):
[N«Å²iNq

Try it online (no test suite due to the program terminate q).
Explanation:

∞         # Push an infinite list in the range [1, ...]
 <        # Decrease each by 1 to make the range [0, ...]
  .Δ      # Find the first value which is truthy for:
    «     #  Concat the value to the (implicit) input-integer
     Å²   #  And check whether it is a square number
          # (after which this found first value is output implicitly as result)

[         # Start an infinite loop:
 N«       #  Concat the 0-based loop index to the (implicit) input-integer
   Å²     #  If it's a square number:
     #    #   Stop the infinite loop
}N        # After the infinite loop has stopped: push the last index
          # (after which this found index is output implicitly as result)

[         # Start an infinite loop:
 N«       #  Concat the 0-based loop index to the (implicit) input-integer
   Å²i    #  If it's a square number:
      N   #   Push the index again
       q  #   And terminate the program
          #   (after which this index is output implicitly as result)

The legacy version didn't had the ∞ builtin, and in the new version it isn't possible to push the last index N after a loop is terminated, which is why I decided to post both solutions.


JavaScript (ES6), 203  208 233 270 256 characters
Edit Revised using a loop instead of a sequence of calls.
Edit Added top and bottom row that were missing.
A function returning the output. Run the snippet in Firefox to test.

f=w=>[h='█'[R='repeat'](19),...[17,15,13,9,5,1,5,9,13,15,17].map((d,i)=>(t=i>5?-v:v,v-=i<5?d:1-d,e=' '[R](d/2),b='█'[R](10-d/2),b+('.'[R](t<d&&d-t)+e+' .'[i>4&w>i-6&t>=d|0]+e).slice(0,d)+b),v=w),h].join`
`

// Less golfed
F=
w=>[h='█'.repeat(19),
    ... [17, 15, 13, 9, 5, 1, 5, 9, 13, 15, 17].map(
     (d,i) => (
       t = i>5 ? -v : v,
       v -= i<5 ? d : 1-d,
       e = ' '.repeat(d / 2),
       b = '█'.repeat(10 - d / 2),
       b +
        ('.'.repeat(t < d && d - t)
         + e + ' .'[i > 4 & w > i-6 & t >= d | 0]
         + e).slice(0,d)
       + b
     ), v = w
    ),
    h].join('\n')

// TEST

O.innerHTML=f(+I.value)

function tick(d) {
  var i=+I.value+d
  I.value=i
  O.innerHTML=f(i)
}

var int=0;

function auto()
{
  function go()
  {
    var t = I.value;
    O.innerHTML=f(++t)
    if (t>70)t=0;
    I.value = t;
  }
  if (A.checked && !int)
  {
    int = setInterval(go, 200);
  }
  else if (!A.checked && int)
  {
    clearInterval(int);
    int = 0;
  }
}
input[type=text] { width: 3em }
<button onclick='tick(-1)'>-</button>
<input type=text id=I value=0 onchange='tick(0)' >
<button onclick='tick(1)'>+</button>
<input type=checkbox id=A onclick='auto()'>Fly time
<pre id=O><pre>


Dyalog APL, 23 21 19 bytes

Takes table of (R, G, B) triplets.
Inspired by miles' algorithm
Returns table of indices into {(255, 0, 0), (0, 255, 0), (0, 0, 255)}. Horribly wasteful.
(?∘≢⊃⊢)¨(⊂⍳3)/¨⍨1+⊢

(
 ?∘≢ random index
 ⊃ selects
 ⊢ from
)¨ each of
(
 ⊂ the entire
 ⍳3 first three indices
)/¨⍨ replicated by each of
1+⊢ the incremented triplets
TryAPL!

Old version
Returns table of 0-based indices into {(255, 0, 0), (0, 255, 0), (0, 0, 255)}
{+/(?0)≥+\(1+⍵)÷3++/⍵}¨

{...}¨ for each quixel in the table, find the:
 +/ the sum of (i.e. count of truths of)
 (?0)≥ a random 0 < number < 1 being greater than or equal to
 +\ the cumulative sum of
 (1+⍵)÷ the incremented RGB values divided by
 3+ three plus
 +/⍵ the sum of the quixel
Note: Dyalog APL lets you chose between the Lehmer linear congruential generator, the Mersenne Twister, and the Operating System's RNG¹ ².
For example, the image:
┌──────────┬──────────┬───────────┬───────────┬─────────┐
│52 241 198│148 111 45│197 165 180│9 137 120  │46 62 75 │
├──────────┼──────────┼───────────┼───────────┼─────────┤
│81 218 104│0 0 255   │0 255 0    │181 202 116│122 89 76│
├──────────┼──────────┼───────────┼───────────┼─────────┤
│181 61 34 │84 7 27   │233 220 249│39 184 160 │255 0 0  │
└──────────┴──────────┴───────────┴───────────┴─────────┘

can give
┌─┬─┬─┬─┬─┐
│1│0│2│2│1│
├─┼─┼─┼─┼─┤
│2│2│1│1│2│
├─┼─┼─┼─┼─┤
│0│2│1│2│0│
└─┴─┴─┴─┴─┘

Notice how the three "pure" quixels collapsed to their respective colors.
TryAPL online!


Sorting a List with a Another Sorted List

Ruby 81 bytes

m=Score.each_index.sort_by{|i|Score[i]}
p m.map{|i|Names[i]}
p m.map{|i|Email[i]}

A golfed implemention of the algorithm below, assuming Score, Names, and Email are all already defined, and that only output of the post-sorted Names and Email is required.

Sample usage:

Score = ['score1','score10','score6','score2','score22','score12']
Names = ['name1','name10','name6','name2','name22','name12']
Email = ['email1','email10','email6','email2','email22','email12']

m=Score.each_index.sort_by{|i|Score[i]}
p m.map{|i|Names[i]}
p m.map{|i|Email[i]}

Sample output:

["name1", "name10", "name12", "name2", "name22", "name6"]
["email1", "email10", "email12", "email2", "email22", "email6"]

Ruby (with natural sort) 123 bytes

m=Score.each_index.sort_by{|i|Score[i].scan(/\d+|\D+/).map{|i|i=~/\d/?i.to_i: i}}
p m.map{|i|Names[i]}
p m.map{|i|Email[i]}

Correctly sorts strings with any number of digital groupings, as one would sort them 'naturally'. The only caveat is that all strings in the Score array must start with a digit, or all must start with a non-digit.

Sample output:

["name1", "name2", "name6", "name10", "name12", "name22"]
["email1", "email2", "email6", "email10", "email12", "email22"]

Python

Not a code-golf answer.

Find the inverse permutation of the list which is to be sorted in lexicographical order (in the problem description, this Scores array). This can be achieved in O(n log n) time (as the problem is analog to sorting), although the implementation below is O(n²).
Apply this permutation to each list. The permute function is O(n) complexity.

Sample implementation:

def get_inv_perm(items):
  size = len(items)
  perm = [0]*size
  for i in range(size):
    for j in range(size): perm[j] += items[j] > items[i]
  return perm

def permute(arr, perm):
  size = len(arr)
  out = [0] * size
  for i in range(size):
    val = perm[i]
    out[i] = arr[val]
  return out

if __name__ == "__main__":
  Score = ['score1','score10','score6','score2','score22','score12']
  Names = ['name1','name10','name6','name2','name22','name12']
  Email = ['email1','email10','email6','email2','email22','email12']

  perm = get_inv_perm(Score)

  print permute(Score, perm)
  print permute(Names, perm)
  print permute(Email, perm)

Sample output:

['score1', 'score10', 'score12', 'score2', 'score22', 'score6']
['name1', 'name10', 'name12', 'name2', 'name22', 'name6']
['email1', 'email10', 'email12', 'email2', 'email22', 'email6']

Because the sort is lexicographical, score10 and score12 appear directly after score1. The get_inv_perm function assumes the items list is unique. The remaining lists need not be.


Mathematica, 63 55 bytes

f=If[#5<1,#+#4,f[#+#2,#3-1,#2,#5-1,#2-1-#4]]&;g=1~f~##&

This defines a function g which can be called like

g[5, 5, 1, 3]

I'm using a recursive approach. It uses up to 2(N+M) iterations, depending on how far down the spiral the result is found. It does handle all inputs (up to g[10^6,10^6,5^5-1,5^5], which requires the most iterations) within a few seconds, but for larger inputs, you'll need to increase the default iteration limit like

$IterationLimit = 10000000;

Basically, if k is the starting number of the spiral, I'm checking if the j index is 0 in which case I can just return k + i. Otherwise, I throw away the top row, rotate the spiral by 90 degrees (anti-clockwise), increment k accordingly, and look at the remaining spiral instead. We can move to the next spiral with the following mapping of parameters:

kn+1 = kn + mn
Mn+1 = Nn - 1
Nn+1 = Mn
in+1 = jn - 1
jn+1 = nm - in - 1

This assumes that M is the width and N is the height.


Jelly,  14  13 bytes

14 -> 13 assumes trailing spaces-only entry is allowed in the list format output; if not I shall revert to the 14 (asked)

+ƝƬK€z⁶Zṙ"JC$

A monadic link. Output is a list of lists using space characters as the spaces (includes a single trailing spaces-only entry).

Try it online! (includes a footer to show the list structure since running the monadic link as a full program will print smashed output implicitly.)


Divide and stay Happy. Who cares about the Conquer part?

Java

Trying to solve this problem in two phases:

Build two equally sized lists by adding the remaining biggest to the currently smaller list and the next to the other. Repeat.
Identify items from both lists that can be switched to reduce the difference in value

Input like

8
1 2 3 4 5 6 7 8

is already solved after phase 1 as e.g.

2 3 5 8
1 4 6 7
diff=0

and input like

6
1 4 5 6 7 8

will need both phases so that

1 5 8
4 6 7
diff=3

(after phase one) becomes the result of

1 6 8
4 5 7
diff=1

While I can guarantee this attempt will always provide a solution, I can not prove that a optimal solution is found in all cases. With the restriction of equally sized lists it however feels quite realistic that there are no corner cases left behind. Prove me wrong ;-)
Program on ideone.com
import java.util.*;

/**
 * Created to solve http://codegolf.stackexchange.com/q/23461/16293 .
 */
public class EqualSums {

    public static void main(String[] args) {
        final Scanner s = new Scanner(System.in);
        // Read number of elements to divide
        final int count = s.nextInt();
        if (count % 2 == 1) {
            throw new IllegalStateException(count + " can not be divided by 2. Consider adding a 0 value.");
        }
        // Read the elements to divide
        final SortedList valueStack = new SortedList(count);
        for (int i = 0; i < count; i++) {
            valueStack.add(s.nextLong());
        }

        final SortedList targetOne = new SortedList(count / 2);
        final SortedList targetTwo = new SortedList(count / 2);
        // Divide elements into two groups
        addInPairs(targetOne, targetTwo, valueStack);
        // Try to ensure groups have equal value
        retaliate(targetOne, targetTwo);

        // Output result
        System.out.println(targetOne);
        System.out.println(targetTwo);
        System.out.println("diff=" + Math.abs(targetOne.getSum() - targetTwo.getSum()));
    }

    private static void addInPairs(SortedList targetOne, SortedList targetTwo, SortedList valueStack) {
        SortedList smallerTarget = targetOne;
        SortedList biggerTarget = targetTwo;
        while (!valueStack.isEmpty()) {
            // Add biggest remaining value to small target
            smallerTarget.add(valueStack.removeLast());

            // Add second biggest remaining value to big target
            biggerTarget.add(valueStack.removeLast());

            // Flip targets if roles have changed
            if (smallerTarget.getSum() > biggerTarget.getSum()) {
                final SortedList temp = smallerTarget;
                smallerTarget = biggerTarget;
                biggerTarget = temp;
            }
        }

    }

    private static void retaliate(SortedList targetOne, SortedList targetTwo) {
        long difference;
        boolean changed;
        outer:
        do {
            difference = Math.abs(targetOne.getSum() - targetTwo.getSum());
            if (difference == 0) {
                return;
            }
            changed = false;
            // Try to find two values, that reduce the difference by changing them between targets
            for (Long valueOne : targetOne) {
                for (Long valueTwo : targetTwo) {
                    final Long tempOne = targetOne.getSum() + valueTwo - valueOne;
                    final Long tempTwo = targetTwo.getSum() - valueTwo + valueOne;
                    if (Math.abs(tempOne - tempTwo) < difference) {
                        targetOne.remove(valueOne);
                        targetTwo.add(valueOne);
                        targetTwo.remove(valueTwo);
                        targetOne.add(valueTwo);
                        changed = true;
                        continue outer;
                    }
                }
            }
        } while (changed);
    }

    public static class SortedList extends AbstractList<Long> {

        private final ArrayList<Long> list;
        private long sum = 0;

        public SortedList(int count) {
            list = new ArrayList<>(count);
        }

        // the next functions access list-field directly
        @Override
        public Long get(int index) {
            return list.get(index);
        }

        @Override
        public boolean add(final Long t) {
            final int i = Collections.binarySearch(list, t);
            if (i < 0) {
                // No equal element present
                list.add(-i - 1, t);
            } else {
                list.add(afterLastEqual(i, t), t);
            }
            sum += t;
            return true;
        }

        @Override
        public Long remove(int index) {
            final Long old = list.remove(index);
            sum -= old;
            return old;
        }

        @Override
        public int size() {
            return list.size();
        }

        // the next functions access list-field only through the functions above this point
        // to ensure the sum is well kept

        public long getSum() {
            return sum;
        }

        private int afterLastEqual(final int start, Object o) {
            int found = start;
            while (found < size() && o.equals(get(found))) {
                found++;
            }
            return found;
        }

        private int beforeFirstEqual(final int start, final Object o) {
            int found = start;
            while (found >= 0 && o.equals(get(found))) {
                found--;
            }
            return found;
        }

        @Override
        public int indexOf(Object o) {
            try {
                final int i = Collections.binarySearch(this, (Long) o);
                if (i >= 0) {
                    return beforeFirstEqual(i, o) + 1;
                }
            } catch (ClassCastException e) {
                // Object was not instance of Long
            }
            return -1;
        }

        @Override
        public int lastIndexOf(Object o) {
            try {
                final int i = Collections.binarySearch(this, (Long) o);
                if (i >= 0) {
                    return afterLastEqual(i, o) - 1;
                }
            } catch (ClassCastException e) {
                // Object was not instance of Long
            }
            return -1;
        }

        @Override
        public boolean remove(Object o) {
            if (o == null) {
                return false;
            }
            final int i = indexOf(o);
            if (i >= 0) {
                remove(i);
                return true;
            }
            return false;
        }

        public Long removeLast() {
            return remove(size() - 1);
        }

        public Long removeFirst() {
            return remove(0);
        }

        @Override
        public String toString() {
            Iterator<Long> it = iterator();
            if (!it.hasNext()) {
                return "";
            }

            StringBuilder sb = new StringBuilder();
            for (; ; ) {
                Long e = it.next();
                sb.append(e);
                if (!it.hasNext()) {
                    return sb.toString();
                }
                sb.append(' ');
            }
        }
    }
}


Find the optimal set of weights to add to a certain set of weights

Mathematica 80 75

Update: See at bottom an update on Doorknob's challenging last test, added on Nov.5

This passes all but the last test. However, it does not attempt to use a digit more than once.  And it only searches from solutions that are subsets of the larger data set.

The function generates all of the subsets of the input data set and then tests which subsets can be used to construct the complete set. After the viable subsets are found, it chooses the smallest sets.

s=Subsets
f@i_:=GatherBy[Select[s@i,Complement[i, Total /@ s@#]=={}&],Length]〚1〛

Tests

f[{1, 3, 4, 7, 8, 11}]

  {{1, 3, 7}}

f[{1, 5, 6, 9, 10, 14, 15}]

  {{1, 5, 9}}

f[{7, 14, 15, 21, 22, 29}]

  {{7, 14, 15}}

f[{4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 18}]

  {{4, 5, 6, 7}}

f[{2, 3, 5, 7}]

  {{2, 3, 5}, {2, 3, 7}}

Update

Below I'll provide an initial analysis that may help get started toward a solution.

The data:

data = {10, 16, 19, 23, 26, 27, 30, 37, 41, 43, 44, 46, 50, 53, 57, 60, 61, 64, 68, 71, 77, 80, 84, 87};

Differently from the earlier approach, we want to consider, in the solution set, numbers that do NOT appear in the data set.

The approach makes use of absolute differences between pairs of numbers in the data set.

g[d_] := DeleteCases[Reverse@SortBy[Tally[Union[Sort /@ Tuples[d, {2}]] /. {a_, b_} :> Abs[a - b]], Last], {0, _}]

Let's look at the number of times each difference appears; we'll only grab the first 8 cases, starting from the most common difference].

g[data][[1;;8]]

  {{7, 14}, {27, 13}, {34, 12}, {3, 11}, {20, 10}, {16, 10}, {4,
    10}, {11, 9}}

14 pairs differed by 7; 13 pairs differed by 27, and so on.

Now let's test subsets starting with {difference1},{difference1, difference2}, and so on, until we can hopefully account for all the original elements in the data set.

h reveals those numbers from the original set that cannot be constructed by composing sums from the subset.

h[t_] := Complement[data, Total /@ Subsets@t]

By the fifth try, there are still 10 elements that cannot be formed from {7, 27, 34, 3, 20}:

h[{7, 27, 34, 3, 20}]

  {16, 19, 26, 43, 46, 53, 60, 77, 80, 87}

But on the next try, all numbers of the data set are accounted for:

h[{7, 27, 34, 3, 20, 16}]

  {}

This is still not as economical as {3,7,16,27,34}, but it's close.

There are still some additional things to take into account.

If 1 is in the data set, it will be required in the solution set.
There may well be some "loners" in the original set that cannot be composed from the most common differences. These would need to be included apart from the difference tests.

These are more issues than I can handle at the moment. But I hope it sheds some light on this very interesting challenge.


Perl, 59 56 54 bytes

Includes +1 for -p

Run with the input on STDIN, e.g. perl -p shifty.pl <<< ">_> <_< >_< <_>"

shifty.pl:

s%^|<|(>)%y/iI/Ii/or$_=Ii;$1?s/i |i$/ i/:s/ i/i /%reg

Explanation

The control string alternates instructions for i and I and the rule is the same for both of them if you formulate them as:

< Move left if there is a space to the left
> Move right if there is a space or end of string to the right

So I'm going to swap i and I in the target string at each step so I only need to apply the rule to one letter ever. This is the y/iI/Ii/

I will walk the control string looking for < and > using a substitution which is usually the shortest way in perl to process something character by character. To avoid having to write $var =~ I want the control string in the perl default variable $_. And I also want an easy way to distinguish < from >. All this can be accomplished using

s%<|(>)%  code using $1 to distinguish < from > %eg

The target string I also want to manipulate using substitutions and for the same reason I want that in $_ too. $_ being two things at once seems impossible.

However I can have my cake and eat it too because the $_ inside the body of a substitution does not have to remain the same as the $_ being substituded. Once perl started substituting a string this string will not change even if you change the variable the string originally came from. So you can do something like:

s%<|(>)% change $_ here without disturbing the running substitution %eg

I want to replace the original $_ by the initial "Ii" only the very first time the substitution body gets executed (otherwise I keep resetting the target string). This replacement however also has to happen for an empty control string, so even for the empty control string the body needs to be executed at least once. To make sure the substition runs an extra time at the start of the control string (even for empty control strings) I change the substitution to:

s%^|<|(>)% change $_ here without disturbing the running substitution %eg

I will run the y/iI/Ii/ as the first thing inside the substitution code. While $_ is still the control string this won't yet contain any Ii, so if the transliteration indicates nothing was changed that is my trigger initialize $_:

y/iI/Ii/or$_=Ii

Now I can implement the actual moving of the letters. Since I start with a swap all moves should be done on i, not I. If $1 is set move i to the right:

s/i |i$/ i/

If $1 is not set move i to the left

s/ i/i /

Notice that at the start of the control string when I match ^ $1 will not be set, so it tries to move i to the left on the initial string Ii. This won't work because there is no space there, so the intial string remains undisturbed (this is why I put the () around > instead of <)

Only one problem remains: at the end of the outer substitution $_ is set to result of the outer substitution regardless of what you did to $_ inside the substitution body. So the target string with the proper placement of i and I gets lost. In older perls this would be a fatal flaw. More recent perls however have the r modifier which means "make a copy of the original string, do your substitution on that and return the resulting string (instead of number of matches)". When I use that here the result is that the modified command string gets discarded while the original $_ is not disturbed by perl and left after the substitution. However the disturbing I do on $_ is still done after perl left $_ alone. So at the end $_ will be the proper target string.

The -p option makes sure the original string is in $_ and also prints the final $_.


Python 2, 78 60 52 46 45 bytes

-6 bytes thanks to G B.
-1 byte thanks to Jakob.

n=input()
b=10**~-len(`n`)
print~-b+n/b+n%b*9

Try it online!

Finally reached a closed form, 1-indexed.

Python 2, 78 bytes

0-indexed.

d=10;k=1
exec'\nk+=9\nif k>d+7:k=d;d*=10\nif k>=d:k-=d/10*9-1'*input()
print k

Try it online!


Partition it into as few disjoint contiguous increasing subsequences as possible

Kotlin, 91 bytes

fold(mutableListOf<Int>()){r,i->r.indexOfFirst{it<i}.let{if(it<0)r+=i else r[it]=i
r}}.size

Beautified

fold(mutableListOf<Int>()) {r,i->
    r.indexOfFirst { it<i }.let {
        if (it<0) r+=i else r[it]=i
        r
    }
}.size

Test

fun MutableList<Int>.f() =
fold(mutableListOf<Int>()){r,i->r.indexOfFirst{it<i}.let{if(it<0)r+=i else r[it]=i
r}}.size

fun main(args: Array<String>) {
    val i = mutableListOf(1,2,3,4,3,5)
    println(i.f())
}

TIO

TryItOnline


Deorst, 1 byte

Try it online!

Commentator, 1 byte

Try it online!

Snails, 1 byte

Try it online!

So far, I have found three one-byte solutions, all of which print 1 with a space in the source code.

The first two languages were created by @cairdcoinheringaahing, and the last one by @feersum.


Some tips:

In R, it's recommended to use <- over =. For golfing, the
opposite holds since = is shorter...
If you call a function more than once, it is often beneficial to
define a short alias for it:

as.numeric(x)+as.numeric(y)

a=as.numeric;a(x)+a(y)

Partial matching can be your friend, especially when functions
    return lists which you only need one item of.  Compare
    rle(x)$lengths to rle(x)$l
Many challenges require you to read input. scan is often a good fit for this (the user ends the input by entring an empty line).

scan()    # reads numbers into a vector
scan(,'') # reads strings into a vector

Coercion can be useful.  t=1 is much shorter than t=TRUE.  Alternatively, switch can save you precious characters as well, but you'll want to use 1,2 rather than 0,1.

if(length(x)) {} # TRUE if length != 0
sum(x<3)         # Adds all the TRUE:s (count TRUE)

If a function computes something complicated and you need various other types of calculations based on the same core value, it is often beneficial to either: a) break it up into smaller functions, b) return all the results you need as a list, or c) have it return different types of values depending on an argument to the function.
As in any language, know it well - R has thousands of functions, there is probably some that can solve the problem in very few characters - the trick is to know which ones!

Some obscure but useful functions:

sequence
diff
rle
embed
gl # Like rep(seq(),each=...) but returns a factor

Some built-in data sets and symbols:

letters     # 'a','b','c'...
LETTERS     # 'A','B','C'...
month.abb   # 'Jan','Feb'...
month.name  # 'January','Feburary'...
T           # TRUE
F           # FALSE
pi          # 3.14...


Jelly, 3 bytes
Code:
ĖP€

Explanation:
Ė     # Enumerate.
 P€   # Product of each.
      # Implicit joining of everything.

Uses the Jelly encoding. Try it online!.


Paint a still life (or a moving one) - draw an image in the Game of Life


Illustrate football team formations on a pitch

Python 2, 401 377 bytes

def g(x,o):
 r=lambda r:["|"+"  x"*5+"  |","|        x        |","|     x     x     |","|    x   x   x    |","|  x   x   x   x  |"][r%5];d="+"+"-"*17+"+";h=[d,"|     |  x  |     |","|     +-----+     |"]+map(r,x);b=map(lambda r:r.replace("x","o"),[s for s in h[:3]]+map(r,o))[::-1];e="|"+" "*17+"|"
 if len(x)-4:h.insert(5,e)
 if len(o)-4:b.insert(1,e)
 print"\n".join(h+[d]+b)

Ungolfed version with test environment here!
Function that takes two lists of the format [defenders, midfielders, midfielders, attackers] while the one midfielder number is optional. Team X (top) comes first, team O (bottom) second.


Jelly, 20 bytes

ṣ€”/ZṖF”#eƊ¿œiÐḟ”+ZE

A monadic Link accepting a list of lists of characters, [topic, pattern], which returns 1 or 0 for match or no-match respectively.

Try it online! Or see a test-suite.

How?

ṣ€”/ZṖF”#eƊ¿œiÐḟ”+ZE - Link: list of lists of characters, [topic, pattern]
 €                   - for each:
ṣ                    -   split at occurrences of:
  ”/                 -     '/' character
    Z                - transpose (any excess of topic is kept)
           ¿         - while...
          Ɗ          - ...condition: last three links as a monad:
       ”#            -   '#' character
         e           -   exists in:
      F              -     flatten
     Ṗ               - ...do: pop the tail off
              Ðḟ     - filter discard those for which:
            œi       -   first multi-dimensional index of: ([] if not found, which is falsey)
                ”+   -     '+' character
                  Z  - transpose
                   E - all equal?


Find number of rectangles in a 2D byte array


Directories required for creating a folder tree

Python

In Python, you would just use os.makedirs(). See the docs at the bottom of this post
import sys

num_existing, num_required = map(int, next(sys.stdin).split())

sep = "/"
directory = {}

for i,path in enumerate(s.rstrip("\n") for s in sys.stdin):
    d = directory
    base = ""
    for p in path.split(sep)[1:]:
        base += sep+p
        if p not in d:
            if i >= num_existing:
                print base
            d[p]={}
        d = d[p]

Python docs for os.makedirs()
>>> import os
>>> help(os.makedirs)

Help on function makedirs in module os:

makedirs(name, mode=511)
    makedirs(path [, mode=0777])

    Super-mkdir; create a leaf directory and all intermediate ones.
    Works like mkdir, except that any intermediate path segment (not
    just the rightmost) will be created if it does not exist.  This is
    recursive.


CJam, 37 34 30 27 24 bytes

3 bytes saved by user23013.

q~,f>{_(a-W<}{e`:a:e~z}w

This takes the input as k first, n second. It uses 1 and 0 to indicate notes and rests, respectively.

Try it here. Alternatively, here is a test harness which runs all of the given test cases (swapping the input order) and also reformats the output to use x and . for easier comparison with the reference solutions. (The results appearing in the input of the test harness are discarded before running the code. They could be safely removed without affecting the program.)

Explanation

q~                       e# Read and eval the input, dumping k and n on the stack.
  ,                      e# Create a range [0 .. n-1]
   f>                    e# For each of them, check if it's less than k.
                         e# This gives k 1s and n-k 0s.
     {      }{        }w e# While the first block yields a truthy result, execute
                         e# the second block.
      _                  e# Duplicate the array.
       (a-               e# Remove all instances of core sequences.
          W<             e# Remove one remainder sequence if there is one. This
                         e# gives an empty array (falsy) whenever there are less
                         e# than two remainder sequences.
              e`         e# Run-length encode. I.e. this turns an array into a list
                         e# of pairs of run-length and element.
                :a:e~    e# Wrap each RLE pair in an array and RLD it. This
                         e# partitions the array into cores and remainders.
                     z   e# Zip the two parts, interleaving cores and remainders.

This process very deeply nested arrays, but the important part is that all cores (and all remainders) always have the same nested structure, so they are still  equal to each other. CJam automatically prints the stack contents at the end of the program and omits array delimiters entirely, hence this structure does not affect the output either.


Brachylog, 25 24 19 bytes

5 bytes thanks to Karl Napf.

lybb'(eM-yA,?:[M]z:%aodA)
l:2'(eM-yA,?:[M]z:%aodA)
l:2'(eMg:?rz:%adlM)

Try it online!

Verify all testcases!

l:2'(eMg:?rz:%adlM)
l:2                  Temp = [2:length(input)]
   '(             )  true if the following cannot be proven:
     eM                  M is an element of the interval
                         indicated by Temp, i.e. from 2
                         to the length of input inclusive,
       g:?rz:%adlM       every element of input modulo M
                         de-duplicated has length M.


05AB1E, 23 21 20 bytes

Prints a list of valid routes.
Saved 2 bytes thanks to Kevin Cruijssen.

æ€œ€`ʒü.LP}ʒ¬²Qsθ³Q*

Try it online!


JavaScript (ES6), score 77 74 66
The period of this PSG is 5.  Each iteration of the sequence removes one asterisk in the block comment until it reaches 2, then goes back to 6.
f=_=>/**/`f=${f}`.replace('**/','*/').replace('/*\/','/******/')

Let's look at some partial sums to see what the limit approaches.
m     1     2     3     4     5
score 64    66    66.33 66.25 66

Edit: thanks to @ETHproductions for pointing out that I should put the comment first.  Not only is the code much shorter, it appears neater!


JavaScript (ES6),  63 54 52  50 bytes
Saved 2 bytes by applying an optimization similar to the one suggested by @AZTECCO on my C answer
Expects (a)(b), where a and b are bytes. Returns 0 if the blocks can dovetail perfectly or 1 otherwise.
a=>g=b=>b?a<<8&b|(c=a<<8|b,c+=c&-c)&c-1&&g(b<<1):1

Try it online!
How?
The recursive function g attempts to shift b to the left, 1 position at a time, until the following conditions are both met:

(a << 8) & b is equal to 0, i.e. a << 8 and b have no set bits in common
c = (a << 8) | b is a sequence of consecutive 1's, possibly followed by trailing 0's

For the second test, we add to c the rightmost set bit in c and see if this results in a single 1, by carry propagation along the sequence of consecutive 1's.
We use the following bitwise tricks:
c & -c      // returns the rightmost set bit in c

c & (c - 1) // returns c without the rightmost set bit in c
            // (0 if c is an exact power of 2)

Example:
0111111000 + (0111111000 & -0111111000) = 0111111000 + 0000001000 = 1000000000
1000000000 & (1000000000 - 1) = 1000000000 & 0111111111 = 0

We stop the recursion when b = 0, which means that all bits have been thrown away. (This is why we do b << 1 instead of b * 2, so that b is forced to a 32-bit integer rather than an IEEE 754 floating-point number.)


Are there More Hard Objects or Soft Objects

MATL, 105 104 58 50 49 bytes

Thanks to @Neil for a suggestion that allowed me to remove 46 bytes!

2\TTYaEq4:HeqgEqZ+K/Zot0>+ss'Soft Hard Equal'Ybw)

Input is a 2D char array, with rows separated by ;. The example in the challenge is

['########          ';'#      #          ';'########          ';'                  ';'   ###        ####';'   ###        ####';'   ###            ']

Here's another example:

['###                ';'###                ';'###                ';'                   ';'###################';'#                 #';'#                 #';'#                 #';'###################']

This corresponds to

###
###
###

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

and thus should give 'Equal'.

As a third example, corresponding to 'Soft',

['   ######    ';'   #    #    ';'   ######    ';'          ###';'   ##  #  # #';'          ###';'             ';'             ';' ########    ';' #      #    ';' ########    ']

that is,

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

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

Try it online!

Explanation

This uses 2D convolution to detect shapes. The input is converted to a 2D array with 1 indicating # and -1 for space; and is padded with a frame of -1 values. This assures that shapes at the edge of the original field are also detected.

A soft object is detected by the mask

 1   1
 1  -1

which corresponds to the object's upper-left corner with one empty interior point. Note that the convolution inverts the mask, so it is defined as [-1 1; 1 1] in the code. The number S of positions in which the convolution equals 4 is the total number of soft objects.

An object (soft or hard) is detected by the mask

-1  -1
-1   1

which correponds to the object's upper-left corner together with some empty exterior points. This mask is the negated version of the previous one, so the previous convolution result can be reused. Specifically, the number T of positions in which that result equals -4 is the total number of objects.

The number H of hard objects is T−S. The output string is determined by the sign of S−H = 2*S−T.

2\                 % Input. Modulo 2: '#' gives 1, ' ' gives 0
TTYa               % Add a frame of zeros
Eq                 % Convert 0 to -1
4:HeqgEq           % Generate mask [-1 1; 1 1], for soft objects
Z+                 % 2D convolution, preserving size
K/Zo               % Divide by 4 and round towards 0. Gives 1 or -1 for 4 or -4
t0>                % Duplicate. 1 for positive entries (soft objects), 0 otherwise
+                  % Add. This corresponds to the factor 2 that multiplies number S
ss                 % Sum of 2D array. Gives 2*S-T
'Soft Hard Equal'  % Push this string
Yb                 % Split by spaces. Gives cell array
w)                 % Swap. Apply (modular) index to select one string


Day of Week - Natural language processing and date parsing

JavaScript (ES6), 254 bytes

s=>(F=e=>'0x'+'0A39135?2B?8602467'[parseInt(s.match(e+' ([A-Z]\\w+)')[1],33)%234%81%19],n=(F`s.{5}`-(g=m=>new Date(~F`(no|le).*`,m).getDay())(F`s`)+g(F`l`)+7)%7)-F` .{9}a`?`No, it will be a ${'Sun,Mon,Tues,Wednes,Thurs,Fri,Satur'.split`,`[n]}day.`:`Yes.`

Try it online!
How?
Given the leading part e of a regular expression, the helper function F looks for the capitalized word that immediately follows and turns it into either a 0-indexed day (from 0 = Sunday to 6 = Saturday) or a 0-indexed month (from 0 = January to 11 = December).
F = e =>                // e = regular expression part, as a string
  '0x' +                // parse as hexadecimal
  '0A39135?2B?8602467'[ // a digit between '0' and 'B'
    parseInt(           //   selected by 1) parsing
      s.match(          //     the sub-string in s that matches
        e +             //       the leading part of the regular expression
        ' ' +           //       followed by a space
        '([A-Z]\\w+)'   //       followed by a capturing group for
      )[1],             //       a capitalized word (which is what we keep)
      33                //     in base 33
    )                   //   end of parseInt()
    % 234 % 81 % 19     //   and 2) applying a modulo chain
  ]                     // end of digit lookup

Try the hash function online!
We invoke F with:

"s.{5}" to match "begins on a [day]"
"s" to match "is [month]"
"l" to match "will [month]" (the w may also be capitalized)
" .{9}a" to match either " start on a [day]" or " begin on a [day]"
"(no|le).*" to match either "not" or "leap", whichever comes first (this is a special case where the capitalized word is put in a 2nd capturing group and ignored)

The helper function g takes a month and returns a week day in [0..6]:
g = m => new Date(~F`(no|le).*`, m).getDay()

The expression ~F`(no|le).*` in there evaluates to -1 if "no" is matched (not leap) or to -4 if "le" is matched (leap). This works as expected because the year -4 is leap1 and the year -1 is not.
Using g and the data collected above, we create two dates in the same reference year and look for the difference between the corresponding week days, modulo 7. This allows us to answer the question.

1: At least that's what JS thinks. But this is apparently not true.


Pyth, 31 bytes
This is the direct conversion of the algorithm used in my CJam answer. Tips for golfing welcome!
Mu?G}H+GG+G>Hefq<HT>G-lGTUH^GHk

This code defines a function g which takes two arguments, the string of list of characters and the number.
Example usage:
Mu?G}H+GG+G>Hefq<HT>G-lGTUH^GHkg"ABC"3

Output:
AAABAACABBABCACBACCBBBCBCCC

Code expansion:
M                 # def g(G,H):
 u                #   return reduce(lambda G, H:
  ?G              #     (G if
    }H            #       (H in
      +GG         #          add(G,G)) else
    +G            #       add(G,
      >H          #         slice_end(H,
        e         #           last_element(
         f        #             Pfilter(lambda T:
          q       #               equal(
           <HT    #                 slice_start(H,T),
           >G     #                 slice_end(G,
             -lGT #                   minus(Plen(G),T))),
          UH      #               urange(H)))))),
  ^GH             #     cartesian_product(G,H),
  k               #     "")

Try it here


PHP>=7.1, 820 Bytes

<?preg_match_all("#(\d+(\s+\d+){3})#s",$_GET[0],$t);$r=($w="array_fill")(1,25,$w(1,80," "));function u($n,$y,$x){global$r;$u=[$z=[" ","│",$c="┤","┐","└",$d="┴",$e="┬",$b="├","─","┘","┌",$a="┼"],["│",$c,$b,$a],[$c,$a],["┐",$c,$e,$a],["└",$d,$b,$a],[$d,$a],[$e,$a],[$b,$a],["─",$d,$e,$a],["┘",$c,$d,$a],["┌",$e,$b,$a],[$a]];$o=$r[$y][$x];$s=array_intersect($u[($k="array_search")($n,$z)],$u[$k($o,$z)]);$r[$y][$x]=reset($s);}foreach($t[1]as$e){[$a,$b,$c,$d]=explode(" ",preg_replace("#\s+#"," ",$e));u("┌",$h=min($c,$d),$f=min($a,$b));u("┐",$h,$g=max($a,$b));u("└",$i=max($c,$d),$f);u("┘",$i,$g);foreach(($l="array_slice")(range($f,$g),1,-1)as$x){u("─",$h,$x);u("─",$i,$x);}foreach($l(range($h,$i),1,-1)as$y){u("│",$y,$f);u("│",$y,$g);}}foreach($r as$v)echo join($v)."\n";

-6 Bytes for use "array_fill","array_search", "array_slice" without "

+19 Bytes echo ltrim(rtrim(join($v))."\n","\n"); instead of echo join($v)."\n"; to print only the necessary Chars

Online Version

Expanded

preg_match_all("#(\d+(\s+\d+){3})#s",$_GET[0],$t); # find all rects
$r=($w="array_fill")(1,25,$w(1,80," ")); # fill a empty 2 D array with spaces
function u($n,$y,$x){ # Char , Y Coordinate, X Coordinate as parameter
global$r; # result array must be global to make changes
# The following array based on Set Theory
$u=[
$z=[" ","│",$c="┤","┐","└",$d="┴",$e="┬",$b="├","─","┘","┌",$a="┼"],
["│",$c,$b,$a],
[$c,$a],
["┐",$c,$e,$a],
["└",$d,$b,$a],
[$d,$a],
[$e,$a],
[$b,$a],
["─",$d,$e,$a],
["┘",$c,$d,$a],
["┌",$e,$b,$a]
,[$a]];
$o=$r[$y][$x]; # old value for YX
$s=array_intersect($u[($k="array_search")($n,$z)],$u[$k($o,$z)]); # make the Cut quantity
$r[$y][$x]=reset($s); # Take the first value Cut quantity and set it as new value
}
foreach($t[1]as$e){ # for each rect
[$a,$b,$c,$d]=explode(" ",preg_replace("#\s+#"," ",$e)); #split the four coordinates
# next 4 rows make edges and set minimum and maximum for X an Y values
u("┌",$h=min($c,$d),$f=min($a,$b));
u("┐",$h,$g=max($a,$b));
u("└",$i=max($c,$d),$f);
u("┘",$i,$g);
foreach(($l="array_slice")(range($f,$g),1,-1)as$x){u("─",$h,$x);u("─",$i,$x);} # make the X lines
foreach($l(range($h,$i),1,-1)as$y){u("│",$y,$f);u("│",$y,$g);} # make the  Y lines
}
foreach($r as$v)echo join($v)."\n"; # Output

Order of the array Set Theory

foreach($u as $k0=>$v0)
foreach($u as $k1=>$v1)
echo "\n\n'".$z[$k0]."' + '".$z[$k1]."' = '". join("','",array_intersect($v0,$v1))."'";

Examples Set Theory all possible values

The array without the use of variables to short it

$u=[
$z=[" ","│","┤","┐","└","┴","┬","├","─","┘","┌","┼"],
["│","┤","├","┼"],
["┤","┼",],
["┐","┤","┬","┼"],
["└","┴","├","┼"],
["┴","┼"],
["┬","┼"],
["├","┼"],
["─","┴","┬","┼"],
["┘","┤","┴","┼"],
["┌","┬","├","┼"]
,["┼"]];');


Don't forget about self modifying code

As Dennis showed in https://codegolf.stackexchange.com/a/142785/24812 a loop can be much shorter than a linear program and that there are clever ways to exit the loop.  The spec makes it clear that a 90 degree angle allows you to choose one of two different directions at runtime.  Dennis showed that you could modify the program at runtime - with amazing results.


Ruby: 56 characters
([v=%w(a e i o u y),[*?a..?z]-v]*5).map{|a|$><<a.sample}

Example outputs:

itopytojog
umapujojim
ipagodusas
yfoqinifyw
ebylipodiz


Shortest Hello World program with no semi colons

C# 85 chars
class H{static void Main(){if(System.Console.Out.WriteAsync("Hello, world!")is H){}}}


Wolfram Language (Mathematica), 23 bytes

#∈Circumsphere@{##2}&

Try it online!

Takes four inputs: the lists {x1,y1}, {x2,y2}, {x3,y3}, and {x4,y4}. Checks if the first point lies on the circumcircle of the other three. Also works for checking if \$n+1\$ points in \$\mathbb R^n\$ are concyclic, provided the last \$n\$ of them are affinely independent (because Circumsphere is sad if you give it a degenerate input).

Alternatively, here is a mathematical approach:

Wolfram Language (Mathematica), 29 28 25 24 bytes

Det@{#^2+#2^2,##,1^#}^0&

Try it online!

Takes two lists as input: {x1,x2,x3,x4} and {y1,y2,y3,y4}. Returns Indeterminate when the four points are on a common circle, and 1 otherwise.

From the four points \$(x_1, y_1), (x_2,y_2), (x_3, y_3), (x_4, y_4)\$, this solution constructs the matrix below:

\$\begin{bmatrix}x_1^2 + y_1^2 & x_2^2 + y_2^2 & x_3^2 + y_3^2 & x_4^2 + y_4^2 \\ x_1 & x_2 & x_3 & x_4 \\ y_1 & y_2 & y_3 & y_4 \\ 1 & 1 & 1 & 1 \end{bmatrix}\$

The determinant of this matrix is 0 if and only if the four rows are linearly dependent, and a linear dependency between the rows is the same thing as the equation of a circle that's satisfied at all four points.

The shortest way I could think of to check if the determinant is 0 is to raise it to the 0-th power: 0^0 is Indeterminate while anything else gives 1.


R, 62 52 40 34 bytes

sum(c(1,1,-1)%*%combn(scan(),3)>0)

Try it online!

Port of Luis Mendo's Octave solution

Since a<=b<=c, the triangle condition is equivalent to a+b-c>0. The a+b-c is succinctly captured by the matrix product [1,1,-1] * X, where X is the 3-combinations of the input array.

There were a lot of suggestions for improvements made by 3 different people in the comments:

Robert S. for suggesting scan.
Robin Ryder for suggesting improvements to the triangle inequality and this odd one which requires the input to be in descending order (which just goes to show how important a flexible input format is).
and finally Nick Kennedy for the following:

R, 40 bytes

y=combn(scan(),3);sum(y[3,]<y[1,]+y[2,])

Try it online!


Jelly, 18 bytes
V©_¥®N,$Ø<xµ¹e?ØD)

A full program. Assumes (like everyone else has) that no actual Brainfuck evaluation has to be made (no balancing of unbalanced brackets)
Try it online!
How?
V©_¥®N,$Ø<xµ¹e?ØD) - Main Link: list of characters, s
                 ) - for each character, c, in s:
               ØD  -   digits = "0123456789"
              ?    -   if...
             e     -   ...condition: (c) exists in? (digits)
           µ       -   ...then: monadic link:
    ®              -            recall from register (initially 0)
   ¥               -            last two links as a dyad i.e. f(c, ®):
V                  -              evaluate (c)
 ©                 -              (copy to the register)
  _                -              subtract (®)  i.e. x = value(c) - register
       $           -            last two links as a monad i.e. f(x):
     N             -              negate (x)
      ,            -              pair with (x)  -> [-x,x]
        Ø<         -            list of characters = "<>"
          x        -            repeat (vectorises) - negatives act like 0
            ¹      -   ...else: identity - i.e. f(c) -> c
                   - implicit (smashing) print


Brachylog, 9 8 bytes
ṗ∧4√;?+ṗ

Try it online!
Explanation
ṗ           Input is prime
 ∧          And
  4√        A number whose square is 4 (i.e. -2 or 2)
    ;?+     That number + the Input…
       ṗ    …is prime


Generate a Rectangle from a Specification

K, 123 110 bytes

I used a similar approach to cardboard_box's solution.

r:{y,x#,*|y};h:{t:(#x)|#y;r[t-#x;x],'r[t-#y]y};a:{(,x .|2#y),2_ y};*(){(a[{+h[+x;+y]}]x;a[h]x;(,,y),x)"-|"?y}/

This program is a series of helper definitions followed by a tacit function which takes a string as a right argument. Reformatting for readability and assigning the final function as f:

r: {y,x#,*|y};                           / repeat last row x times
h: {t:(#x)|#y;r[t-#x;x],'r[t-#y;y]};     / append horizontal
v: {+h[+x;+y]};                          / append vertical
a: {(,x[y@1;y@0]),2_ y};                 / pop two values, concat

f: *(){:[y="-";a[v;x]; y="|";a[h;x]; (,,y),x]}/;

Use example:

  f "ja-r|g-o|ni-|ze|d-|"
("jronze"
 "aroidd"
 "ggoidd")

Tested using Kona, but it will also work in oK if you replace the : in the definition of f with a $- k5 changed the syntax of "cond".

A key point is recognizing that doing a vertical append is the transpose of the horizontal append of the transpose of both matrices. (See definition v.) I think there's still room to squeeze out a few characters here and there. If anyone is interested in a more detailed explanation I can provide one.

edit:

Updated the program at the top of this entry. Ungolfed version:

r: {y,x#,*|y};                           / repeat row x times
h: {t:(#x)|#y;r[t-#x;x],'r[t-#y;y]};     / append horizontal
v: {+h[+x;+y]};                          / append vertical
a: {(,x .|2#y),2_ y};                    / apply a concat
f: *(){(a[v]x;a[h]x;(,,y),x)"-|"?y}/;

Notable length optimizations include the use of "dot apply" in a, replacing the "cond" with list indexing in f (less efficient, but shorter) and replacing terms of the form a[b;c] into a[b]c where permitted by grouping. Since I'm no longer using "cond" or any primitives which are different between k3 and k5 this version now works in oK without modification.


4004 machine code, 12 bytes

This is the best code I could come up with using the same I/O as the provided code:

D4      LDM 4
B0      XCH R0
D3      LDM 3
F4      CMA
B1      XCH R1
D0      LDM 0
40 09   JUN TEST
        :LOOP
80      ADD R0
        :TEST
71 08   ISZ R1, LOOP
E0      WRM

If you omit the first 3 instructions and the last instruction then the inputs become R0 and the accumulator and the accumulator becomes the output.

Note that this does not handle overflow very well at all; you can add in a CLC to ensure that it at least calculates it correctly modulo 16, or in case the caller has left the carry set.


JavaScript (ES6), 70 bytes

Input format: Curried function

A function that takes the divisor and returns a function that takes each digit or \$-1\$ for EOF. The second function returns either \$0\$ (false), \$1\$ (true) or itself (no answer).

p=>(q='',g=(d,t=k=z=!~d||(q=d+q,p))=>k--?g(d,t-=(k+q)%p<1):t?t-z&&g:1)

Try it online!

How?

Given a divisor \$p\$ and a dividend \$q\$ consisting of \$n\$ decimal digits, we compute the following expression for all \$0 \le k < p\$:

$$k\times 10^n+q \pmod p\tag{1}$$

For any \$x\ge p\$ there exists \$m\ge 1\$ and \$0 \le k < p\$ such that \$x=mp+k\$, leading to:

$$x\times 10^n+q \pmod p=\\
(mp+k)\times 10^n+q \pmod p=\\
(mp\times 10^n \pmod p)+ (k\times 10^n+q \pmod p)\pmod p=\\
0+(k\times 10^n+q \pmod p)\pmod p=\\
k\times 10^n+q \pmod p$$

Therefore, if \$(1)\$ is equal to \$0\$ for all \$0 \le k < p\$, it will also be equal to \$0\$ for any \$k \ge p\$ and the answer is true.

For the same reason, if \$(1)\$ is greater than \$0\$ for all \$0 \le k < p\$, the answer is false.

If the results of \$(1)\$ are mixed, we can't decide yet and need either more digits of \$q\$ or the EOF notification.

Commented

p => (                       // p = divisor
  q = '',                    // q = dividend stored as a string, initially empty
  g = (                      // g() = curried function taking:
    d,                       //   d = next digit
    t =                      //   t = number of iterations yielding a non-zero value
    k =                      //   k = total number of iterations to process
    z =                      //   z = copy of k
      !~d ||                 //   if d == -1 (meaning EOF), use only 1 iteration
                             //   so that we simply test the current value of q
      (q = d + q, p)         //   otherwise, prepend d to q and use p iterations
  ) =>                       //
    k-- ?                    //   decrement k; if it was not equal to zero:
      g(                     //     do a recursive call to g():
        d,                   //       pass the current value of d (will be ignored anyway)
        t -= (k + q) % p < 1 //       test (k + q) % p and update t accordingly
      )                      //     end of recursive call
    :                        //   else:
      t ?                    //     if t is greater than 0:
        t - z && g           //       return 0 if t == z, or g otherwise
      :                      //     else:
        1                    //       return 1
)                            //


Climbing binomial tree to find the option value


05AB1E, 3 bytes
žs¤

Explained
žs   # push pi to N digits
  ¤  # get last digit

Try it online
Uses 1-based indexing.
Supports up to 100k digits.


TI-Basic (83 series), 137 bytes

For(I,1,length(Ans
Ans+sub(sub(Ans,I,1)+"ABCDEFGHIJKLMNOPQRSTUVWXYZ",1+int(2rand)inString("abcdefghijklmnopqrstuvwxyz",sub(Ans,I,1)),1
End
sub(Ans,I,I-1

Takes input in Ans, as illustrated in the screenshot below:

(If the screenshot looks scrambled, as it sometimes does for me, try opening it in a new tab?)

TI-Basic (at least the TI-83 version... maybe I should branch out into TI-89 golfing) is a terrible language to try to golf this challenge in, since:

It provides absolutely no support for any arithmetic with characters, knowing the uppercase version of a lowercase character, or even knowing the alphabet.
Every single lowercase character takes 2 bytes to store. (In fact, I had to use an assembly script just to be able to type the lowercase letters.)

The result is that 78 bytes of this program (more than half) are just storing the alphabet, twice.

Anyway, the idea is that we loop through the string, with a chance of turning lowercase characters into uppercase ones as we go, and adding the result onto the end of the string so that both the input and the output are stored in Ans. When we leave the For( loop, I is one more than the length of the original string, so taking the I-1 characters starting at I gives the output.


Perl, 211 characters
y/W/B/for@8=@1=map$_.W,split//,RNBQKBNR;@b{$_.1..$_.9}=(@$_,/2/?PW:/7/?PB:"- ")x8for@r=reverse 1..8;$c=join"  ","",a..h;do{y/a-h\n/1-8/d;/ /;@b{$',$`}=@b{$`,19};say$c;say"$_ @b{$_.1..$_.8} $_"for@r;say$c}while<>

Nothing very unusual about this first attempt, except maybe the use of a do..while loop in golf.  Uses say, so you need to run this with perl -M5.01.  The input parsing is really klugy and fragile; in particular, excess whitespace will kill it.  On the other hand, you're not constrained to use 1-8 for rows and a-h for columns, either will do.  End the program with Ctrl-C or by ending the input (Ctrl-D in Unix).
I assumed I don't need to match the whitespace in the sample output exactly — I prefer a more compact board anyway.  (I did keep the board orientation, even though flipping it upside down would save me eight chars.)  A sample game session might look something like this:
  a  b  c  d  e  f  g  h
8 RB NB BB QB KB BB NB RB 8
7 PB PB PB PB PB PB PB PB 7
6 -  -  -  -  -  -  -  -  6
5 -  -  -  -  -  -  -  -  5
4 -  -  -  -  -  -  -  -  4
3 -  -  -  -  -  -  -  -  3
2 PW PW PW PW PW PW PW PW 2
1 RW NW BW QW KW BW NW RW 1
  a  b  c  d  e  f  g  h
2f 3f
  a  b  c  d  e  f  g  h
8 RB NB BB QB KB BB NB RB 8
7 PB PB PB PB PB PB PB PB 7
6 -  -  -  -  -  -  -  -  6
5 -  -  -  -  -  -  -  -  5
4 -  -  -  -  -  -  -  -  4
3 -  -  -  -  -  PW -  -  3
2 PW PW PW PW PW -  PW PW 2
1 RW NW BW QW KW BW NW RW 1
  a  b  c  d  e  f  g  h
7e 5e
  a  b  c  d  e  f  g  h
8 RB NB BB QB KB BB NB RB 8
7 PB PB PB PB -  PB PB PB 7
6 -  -  -  -  -  -  -  -  6
5 -  -  -  -  PB -  -  -  5
4 -  -  -  -  -  -  -  -  4
3 -  -  -  -  -  PW -  -  3
2 PW PW PW PW PW -  PW PW 2
1 RW NW BW QW KW BW NW RW 1
  a  b  c  d  e  f  g  h
2g 4g
  a  b  c  d  e  f  g  h
8 RB NB BB QB KB BB NB RB 8
7 PB PB PB PB -  PB PB PB 7
6 -  -  -  -  -  -  -  -  6
5 -  -  -  -  PB -  -  -  5
4 -  -  -  -  -  -  PW -  4
3 -  -  -  -  -  PW -  -  3
2 PW PW PW PW PW -  -  PW 2
1 RW NW BW QW KW BW NW RW 1
  a  b  c  d  e  f  g  h
8d 4h
  a  b  c  d  e  f  g  h
8 RB NB BB -  KB BB NB RB 8
7 PB PB PB PB -  PB PB PB 7
6 -  -  -  -  -  -  -  -  6
5 -  -  -  -  PB -  -  -  5
4 -  -  -  -  -  -  PW QB 4
3 -  -  -  -  -  PW -  -  3
2 PW PW PW PW PW -  -  PW 2
1 RW NW BW QW KW BW NW RW 1
  a  b  c  d  e  f  g  h
^C