JavaScript (ES6), 104 bytes

a=>[c=a.reduce(c=>c*++i,Math.max(...a),i=0),a.reduce(g=(x,k)=>x%m-k?g(x+n,k):(n*=m,m+=c,x),0,n=1,m=c+1)]

Returns [c, b] as an array. The solution it returns isn't minimal in c but I think it is minimal in b for the given c. For 120 bytes this returns solutions minimal in c and in b for the given c:

f=(a,c=1,b=a.reduce(g=(x,k)=>x%m-k?d--?g(x+n,k):0/0:n%m?g(x,k,n+=o):(o=n,d=m+=c,x),0,o=n=1,d=m=c+1))=>1/b?[b,c]:f(a,c+1)

Ungolfed minimal solution solver:

function godel(a) {
    for (c = 0;; c++) {
        var b = 0, n = 1, i = 0;
        for (;;) {
            var m = c * i + c + 1;
            // Increase b until β(b,c,i) = a[i]
            // Adding n won't change output for smaller i
            for (j = 0; j < m; j++) if (b % m != a[i]) b += n;
            if (j == m) break; // couldn't find a remainder, c too low
            i++;
            if (i == a.length) return [b, c]; // Result!
            // Next time we want adding n to b not to change β(b,c,i)
            for (j = 1; n * j % m != 0; j++);
            n *= j;
        }
    }
}


Find all the numbers have this property, its double and its triple contain each digit from 1 to 9 exactly once

APL (20)

192 219 273 327∘.×⍳3

Just prints the numbers multiplied by 1, 2, and 3.

Without hardcoding (25)

{∧/1↓⎕D∊⍕k←⍵×⍳3:⎕←k}¨⍳400


Haskell, 57 55 bytes

import Data.List
s a=all((==100).sum)<$>[transpose a,a]

Input of type (Eq a, Num a) => [[a]]. Outputs boolean list [left-stochastic, right-stochastic]

Thanks to @proudhaskeller for saving 2 bytes


Matlab, 412 327 bytes
Golfed (Thanks to @AndrasDeak for golfing s!):
s=dec2bin('iecbmgdoh'.'-97)-48;s=[s;-s];T=1e4;D=Inf(1,T);P=D;I=NaN(T,4);for i=1:T;I(i,:)=sprintf('%04d',i-1)-'0';end;G=input('');D(G+1)=0;for k=0:12;for n=find(D==k);for i=1:18;m=1+mod(I(n,:)+s(i,:),10)*10.^(3:-1:0)';if D(m)==Inf;D(m)=k+1;P(m)=n-1;end;end;end;end;n=0;X='0000';while n-G;n=P(n+1);X=[I(n+1,:)+48;X];end;disp(X)

This codes uses some dynamic programming for finding the shortest 'path' from the given number to 0000 using only the possible steps. The challenge is basically a shortest path prioblem (alternatively you could perhaps consider the steps as a commutatuve group.) but the difficulty was coming up with an efficient implementation. The basic structures are two 10000-element arrays, one for storing the number of steps to get to that index, the other one to store a pointer to the previous 'node' in our graph. It simultaneously calculates the 'paths' to all other possible numbers.
Examples:
9871
0981
0091
0001
0000

1210
0100
0000

Examples by @noisyass:

7478
8578
9678
0788
0899
0900
0000

3737
2627
1517
0407
0307
0207
0107
0007
0008
0009
0000

Own Example (longest sequence, shared with 6284)

4826
3826
2826
1826
0826
0926
0026
0015
0004
0003
0002
0001
0000

Full Code (inlcuding some comments):
%steps
s=[eye(4);1,1,0,0;0,1,1,0;0,0,1,1;1,1,1,0;0,1,1,1];
s=[s;-s];

D=NaN(1,10000);%D(n+1) = number of steps to get to n
P=NaN(1,10000);%P(n+1) was last one before n

I=NaN(10000,4);%integer representation as array
for i=0:9999;
    I(i+1,:)=sprintf('%04d',i)-'0';
end

G=9871; % define the current number (for the golfed version replaced with input('');
D(G+1)=0;
B=10.^(3:-1:0); %base for each digit

for k=0:100; %upper bound on number of steps;
    L=find(D==k)-1;
    for n=L; %iterate all new steps
        for i=1:18; %search all new steps
            m=sum(mod(I(n+1,:)+s(i,:),10) .* [1000,100,10,1]);
            if isnan(D(m+1))
                D(m+1) = k+1;
                P(m+1)=n;
            end
        end
    end
end
n=0;%we start here
X=[];
while n~=G
    X=[I(n+1,:)+'0';X];
    n=P(n+1);
end
disp([I(G+1,:)+'0';X,''])


CJam, 32 31 28 bytes

0q~)f/f-_,(_,\0a*1+fm<~]W%z

Try it online

This takes the input in ascending order, using the CJam list format. Sample input:

[-4.0 -7.0 13.0]

Explanation:

0     Push a 0 for later sign inversion.
q~    Get and interpret input.
)     Pop off last value.
f/    Divide all other values by it.
f-    Invert sign of values.
_,    Get count of values, which corresponds to n.
(     Decrement by 1.
_,    Create list of offsets [0 1 ... n-1] for later.
\     Swap n-1 back to top.
0a*   Create list of n-1 zeros.
1+    Append a 1. This is the second-but-last column [0 0 ... 0 1].
fm<   Apply rotation with all offsets [0 1 ... n-1] to column.
~     Unwrap the list of 0/1 columns.
]     Wrap all columns
W%    Invert their order from last-to-first to first-to last.
z     Transpose to get final matrix.
`     Convert to string for output.


How many steps does it take from n to 1 by subtracting the greatest divisor?

Jelly, 9 bytes
ÆṪÐĿÆFL€S

Try it online! or verify all test cases.
Background
The definition of sequence A064097 implies that

By Euler's product formula

where φ denotes Euler's totient function and p varies only over prime numbers.
Combining both, we deduce the property

where ω denotes the number of distinct prime factors of n.
Applying the resulting formula k + 1 times, where k is large enough so that φk+1(n) = 1, we get

From this property, we obtain the formula

where the last equality holds because ω(1) = 0.
How it works
ÆṪÐĿÆFL€S  Main link. Argument: n

  ÐĿ       Repeatedly apply the link to the left until the results are no longer
           unique, and return the list of unique results.
ÆṪ           Apply Euler's totient function.
           Since φ(1) = 1, This computes φ-towers until 1 is reached.
    ÆF     Break each resulting integer into [prime, exponent] pairs.
      L€   Compute the length of each list.
           This counts the number of distinct prime factors.
        S  Add the results.


Is there an unmatched parenthesis in this String?

Python 2, 47 bytes

lambda s:map(s.count,'([{')!=map(s.count,')]}')

Try it online! Test cases from musicman523.

Checks if list of counts for each type of open paren matches that for the corresponding close parens.

The program is one byte longer

q=input().count
print map(q,'([{')!=map(q,')]}')


CJam (15 14 bytes)

qN/ee{:=i2%)}%

Online demo

Thanks to Adnan for a one-byte saving.

Dissection

qN/    e# Split input on newlines
ee{    e# Label each line with its index and map:
  :=i  e#   Get the character at the same index (i.e. diagonalise)
  2%)  e#   Compute (ASCII value mod 2) + 1
       e#   Maps 0 1 2 3 4 5 6 7 8 9
       e#     to 1 2 1 2 1 2 1 2 1 2
}%


Python 2, 93 88 86 bytes

-4 bytes thanks to @LeakyNun
-2 bytes thanks to @Mr.Xcoder

def g(i):l=-~len(i)/3;print f(i[:l])==f(i[l:-l])==f(i[-l:])
f=lambda a:sum(map(int,a))

Try it online!


Ruby

This works only on Windows.

if aTerribleErrorOccurredAndWeNeedToKillTheScriptNow
    c = ($$ % 94 + 33).chr
    puts "#{c * 50}\n#{c + "KILLING SCRIPT".center(48) + c}\n#{c * 50}"
    `taskkill /PID #{$$} /F`
end

The process ID, $$, is unpredictable. However, this will always kill the currently running script, while printing an error message bordered by an unpredictable character like this:

##################################################
#                 KILLING SCRIPT                 #
##################################################

Of course, exit or quit do the same thing, but this one kills Ruby forcefully with the OS! And it also bypasses at_exit handlers.


One Ring to rule them all. One String to contain them all


CJam, 78 bytes
r_A,s-" e . .e"S/\a#[SSS"'./~'e/~i1$,-'e\]s"0]=~~_i:Q\Q=Qg&/
s,:L{;QAL(:L#9L*(*)9/-_1<}g(L)md_)p\AL#+_ps=

The program is 104 bytes long and qualifies for the bonus.
The newline is purely cosmetic. The first line parses the input, the second generates the output.
Try it online!
Idea
For any positive integer k, there are 9×10k-1 positive integers of exactly k digits (not counting leading zeroes). Thus, if we concatenate all of them, we obtain an integer of 9×n×10k-1.
Now, concatenating all integers of n or less digits yields an integer of

digits.
For a given input q, we try determine the highest n such that the above expression is smaller than q. We set n := ⌈log10q⌉-1, then n := ⌈log10q⌉-2, etc. until the desired expression becomes smaller than q, subtract the resulting expression from q (yielding r) and save the last value of n in l.
r now specifies the index in the concatenation of all positive integers of l+1 digits, which means that the desired output is the r%(l+1)th digit of the r/(l+1)th integer of l+1 digits.
Code (input parsing)
r_          e# Read from STDIN and duplicate.
A,s-        e# Remove all digits.
" e . .e"S/ e# Push ["" "e" "." ".e"].
\a#         e# Compute the index of the non-digit part in this array.

[SSS"'./~'e/~i1$,-'e\]s"0]

            e# Each element corresponds to a form of input parsing:
            e#   0 (only digits): noop
            e#   1 (digits and one 'e'): noop
            e#   2 (digits and one '.'): noop
            e#   3 (digits, one '.' then one 'e'):
            e#     './~    Split at dots and dump the chunks on the stack.
            e#     'e/~    Split the and chunks at e's and dump.
            e#     i       Cast the last chunk (exponent) to integer.
            e#     1$      Copy the chunk between '.' and 'e' (fractional part).
            e#     ,-      Subtract its length from the exponent.
            e#     'e\     Place an 'e' between fractional part and exponent.
            e#     ]s      Collect everything in a string.
            e#   -1 (none of the above): push 0

~           e# For s string, this evaluates. For 0, it pushes -1.
~           e# For s string, this evaluates. For -1, it pushes 0.
            e# Causes a runtime exception for some sorts of invalid input.
_i:Q        e# Push a copy, cast to Long and save in Q.
\Q=         e# Check if Q is numerically equal to the original.
Qg          e# Compute the sign of Q.
&           e# Logical AND. Pushes 1 for valid input, 0 otherwise.
/           e# Divide by Q the resulting Boolean.
            e# Causes an arithmetic exception for invalid input.

Code (output generation)
s,:L     e# Compute the number of digits of Q and save in L.
{        e# Do:
  ;      e#   Discard the integer on the stack.
  Q      e#   Push Q.
  AL(:L# e#   Push 10^(L=-1).
  9L*(   e#   Push 9L-1.
  *)     e#   Multiply and increment.
  9/     e#   Divide by 9.
  -      e#   Subtract from Q.
  _1<    e#   Check if the difference is non-positive.
}g       e# If so, repeat the loop.
(        e# Subtract 1 to account for 1-based indexing.
L)md     e# Push quotient and residue of the division by L+1.
_)p      e# Copy, increment (for 1-based indexing) and print.
\AL#+    e# Add 10^L to the quotient.
_p       e# Print a copy.
s        e# Convert to string.
2$=      e# Retrieve the character that corresponds to the residue.


Display a chain of little mountains with an odd number on the top of it!

05AB1E, 19 15 14 12 bytes

05AB1E uses CP-1252 encoding.
Saved 4 bytes thanks to Adnan.
Saved 2 bytes thanks to carusocomputing

ÅÉðìDg…/ \×»

Try it online!

Explanation

ÅÉ               # list of uneven number up to input
  ðì             # prepend a space to each
    Dg           # get length of list
      …/ \       # push the string "/ \"
          ×      # repeat the string length-list times
           »     # join rows by spaces and columns by newlines


Perl 6, 20 snippets

{$_ eq m/[[<-[()*?|\\]>|\\<[()*?|\\]>|'(' <~~>* ')']<[*?]>?|\|]+/}

Try it online!

The snippets are taken from:

{$_ eq, m/[, <-[, ()*?, |\\, ]>, |\\, <[, ()*?, |\\, ]>, |, '(' <~~>* ')', <[, *?, ]>, ?|, \|, ]+/, }.

This is mostly the greedy approach (made obvious by all the one or two character snippets). I used SymbolHound to search for the individual characters, and the only real optimisation was the '(' <~~>* ')' snippet, which is taken from my own answer on recursive Perl 6 regexes.

Explanation:

This basically checks if the input is equal to a greedy match of a valid regex. The reason we can't just use the regex itself and add ^$ to mark the ends is because we are using a recursive regex, which wouldn't work if there were ^$ markers. The regex itself is:

m/[                             ]+/   # Match one or more times
   [              ]  # Any of
    <-[()*?|\\]> |     # Not a metacharacter
    \\<[()*?|\\]>      # A metacharacter preceded by a \
    '(' <~~>* ')'      # Brackets surrounding a valid regex
                   <[*?]>?  # Optionally followed by a ? or *
                           | \|    # Or just the | metacharacter


Approximate definite integrals using Riemann sums

R, 69 65 63 57 bytes

function(a,b,n,k,f,w=(b-a)/n)sum(sapply(a+w*(1:n-k),f))*w

Try it online!

Takes k=FALSE for right-hand sums, although the TIO link now includes aliases for "left" and "right" for ease of use.

a+w*(1:n-k) generates appropriate left- or right-hand points.

Then sapply applies f to each element of the result, which we then sum up and multiply by the interval width (b-a)/n to yield the result. This last also neatly takes care of any sign issues we might have.


Rearrange pixels in image so it can't be recognized and then get it back

Python 2.7 (with PIL) - No Pseudorandomness

I break the image into 2 by 2 blocks (ignoring the remainder) and rotate each block by 180 degrees, then I do the same with 3 by 3 blocks, then 4, etc. up to some parameter BLKSZ. Then I do the same for BLKSZ-1, then BLKSZ-2, all the way back down to 3, then 2. This method reverses itself exactly; the unscramble function is the scramble function.

The code:

from PIL import Image
import math

im = Image.open("ST1.png", "r")
arr = im.load() #pixel data stored in this 2D array

def rot(A, n, x1, y1): #this is the function which rotates a given block
    temple = []
    for i in range(n):
        temple.append([])
        for j in range(n):
            temple[i].append(arr[x1+i, y1+j])
    for i in range(n):
        for j in range(n):
            arr[x1+i,y1+j] = temple[n-1-i][n-1-j]

xres = 800
yres = 480
BLKSZ = 50 #blocksize
for i in range(2, BLKSZ+1):
    for j in range(int(math.floor(float(xres)/float(i)))):
        for k in range(int(math.floor(float(yres)/float(i)))):
            rot(arr, i, j*i, k*i)
for i in range(3, BLKSZ+1):
    for j in range(int(math.floor(float(xres)/float(BLKSZ+2-i)))):
        for k in range(int(math.floor(float(yres)/float(BLKSZ+2-i)))):
            rot(arr, BLKSZ+2-i, j*(BLKSZ+2-i), k*(BLKSZ+2-i))

im.save("ST1OUT "+str(BLKSZ)+".png")

print("Done!")

Depending on the blocksize, you can make the computation eradicate all resemblance to the original image: (BLKSZ = 50)

Or make the computation efficient: (BLKSZ = 10)


GolfScript (175 chars)

I assume input and output in MSB-first upper-case hex.

For want of good test cases, I don't guarantee that this implementation is correct. I've worked to a test case which I derived from Rivest's simple test for implementations of DES: given his test input of 9474B8E8C73BCA7D I think that the expected output is

BE23F4265E76
63FD57CA5952
6DEDC3C5E33C
73E5BBF11EC8
FD8593D8923F
778A9F177EAC
3FB0963839F1
3E0CFEA3E837
41FFD1A34BCB
55FDE796B313
F3E5C3F70764
79C7A758ABCA
F1919F74F41D
3582F76B34EA
B758B6ACF92B
44FF4B3F4D29

To that caveat I must add another, which is that I use a lot of base conversion including some of strings with non-printable characters. As usual, I'll give the program in a couple of ASCII-safe formats. xxd output:

0000000: 312f 7b31 302c 2727 2a37 312c 3635 3e2b  1/{10,''*71,65>+
0000010: 3a5e 5c3f 3136 2b32 7b62 6173 657d 3a42  :^\?16+2{base}:B
0000020: 7e28 3b7e 7d25 607b 3d7d 2b5b 3536 5b5b  ~(;~}%`{=}+[56[[
0000030: 2d38 5d32 342a 372f 2e2b 2739 3939 1b37  -8]24*7/.+'999.7
0000040: 3717 275d 7a69 705b 5d2a 5b5d 2a7b 3124  7.']zip[]*[]*{1$
0000050: 2b7d 2f5d 2534 3932 3831 2032 427b 2129  +}/]%49281 2B{!)
0000060: 7b32 382f 7b28 2b7d 257e 2b7d 2a27 1d3c  {28/{(+}%~+}*'.<
0000070: f9df 2a9b 7079 2030 dea2 83df 3bca a82f  ..*.py 0....;../
0000080: 50ec 11f8 e55c 74d2 f104 b2ae 130e ac5c  P....\t........\
0000090: d627 27ff 3827 7b42 7d2f 7b31 243d 7d25  .''.8'{B}/{1$=}%
00000a0: 342f 7b32 425e 3d7d 256e 2b5c 7d2f 3b    4/{2B^=}%n+\}/;

Base-64 encoded:

MS97MTAsJycqNzEsNjU+KzpeXD8xNisye2Jhc2V9OkJ+KDt+fSVgez19K1s1NltbLThdMjQqNy8u
Kyc5OTkbNzcXJ116aXBbXSpbXSp7MSQrfS9dJTQ5MjgxIDJCeyEpezI4L3soK30lfit9KicdPPnf
KptweSAw3qKD3zvKqC9Q7BH45Vx00vEEsq4TDqxc1icn/zgne0J9L3sxJD19JTQvezJCXj19JW4r
XH0vOw==

And with the magic strings substituted with a printable (but longer) version using escape characters and some unnecessary line-breaks:

1/{10,''*71,65>+:^\?16+2{base}:B~(;~}%`{=}+
[56[[-8]24*7/.+'999\e77\027']zip[]*[]*{1$+}/]
%49281 2B{!){28/{(+}%~+}*
'\035<\371\337*\233py 0\336\242\203\337;\312\250/P\354\021\370\345\\t\322\361\004\262\256\023\016\254\\\326'
'\3778'{B}/{1$=}%4/{2B^=}%n+\}/;

This is a pretty literal translation. The vaguely interesting bits are:

Permutation PC1 turns out to have a lot of structure. If you take first differences, all but 6 of them are -8. The second line of the reformatted version reconstructs it from these differences in 39 characters. For comparison, representing it by base conversion would require 44 characters for the string literal; and representing a generic permutation of numbers 1 to 63 requires 36 base-256 digits (i.e. a 38-character string literal plus code to convert it).
49281 2B{!) ... } encodes the shift lengths. This is the most obvious place to attempt further optimisation.
Permutation PC2 doesn't seem to have any usable structure, so that's a straight double base conversion. (Not to be confused with a double bass conversion).


Generate all halting Smallfuck programs of length n

Java (OpenJDK 8), Score: ???

This clocks in at 980 bytes, since I had so much to work with I decided to make it a little more readable.  Basically I'm generating all the possible programs for length n and iterating them n^x times for some x.  x is currently 3 but it can be modified arbitrarily to any size, limited only by the limitation of the JVM's precission.  This will work for arbitrarily large input values if x is increased, but I have it set to 3 for tio.

import java.util.*;
public class Main{
    public static void main(String[] args){
        int i = new Scanner(System.in).nextInt();
        int x = 3;
        l:for(int j=0;j<Math.pow(5, i);j++){
            try {
                String s="";
                for(int k=j;s.length()<i;k/=5)
                    s="+<>][".charAt(k%5)+s;
                Stack<Integer>y=new Stack<Integer>();
                Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>();
                for(int m=0; m<s.length();m++){
                    char c=s.charAt(m);
                    if(c=='[')y.push(m);
                    if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);}
                }
                if(y.size()>0)
                    continue;
                boolean[] t= new boolean[s.length()];
                int l=0,n=0;
                for(long m=0;l<s.length()&m<Math.pow(i,x);l++,m++){
                    switch(s.charAt(l)){
                    case'+':t[n]=!t[n];break;
                    case'>':n++;break;
                    case'<':n--; if(n < 0)continue l;break;
                    case'[':if(!t[n])l=f.get(l);break;
                    case']':l=b.get(l)-1;break;
                    }
                }
                if(l>=s.length()){
                    System.out.println(s);
                }
            } catch(Exception e){continue;}
        }
    }
}

Try it online!


Golf the Inverse of Exponential Generating Function

Julia, 91 81 77 bytes

!v=(b=[1;0v[r=2:end]];for i=r,j=0:i-2 b[i]-=binomial(i-1,j)v[i-j]b[j+1]end;b)

Usage: ![1 0 -1 0 1 0 -1 0]

Saved 4 bytes thanks to Dennis!

This is a fairly straightforward implementation - it uses the fact that the "exponential" part causes a binomial to appear in the solution. Otherwise, it's just solving for the relevant coefficients.


Regex (ECMAScript), 1085 855 597 536 511 508 504 bytes
Matching abundant numbers in ECMAScript regex is an entirely different beast than doing so in practically any other regex flavor. The lack of forward/nested backreferences or recursion means that it is impossible to directly count or keep a running total of anything. The lack of lookbehind makes it often a challenge even to have enough space to work in.
Many problems must be approached from an entirely different perspective, and you'll be wondering if they're solvable at all. It forces you to cast a much wider net in finding which mathematical properties of the numbers you're working with might be able to be used to make a particular problem solvable.
Back in March-April 2014 I constructed a solution to this problem in ECMAScript regex. At first I had every reason to suspect the problem was completely impossible, but then the mathematician teukon sketched an idea that made an encouraging case for making it look solvable after all – but he made it clear he had no intention of constructing the regex (he had competed/cooperated with my on constructing/golfing previous regexes, but reached his limit by this point and was content to restrict his further contributions to theorizing).
Solving unary mathematical problems in ECMAScript regex has been a fascinating journey for me, so in the past I put spoiler warnings in this post and others like it – in case others, especially those with an interest in number theory, wanted to take a crack at independently solving things like generalized multiplication. I am now removing the spoiler warnings though; they did not prove to be constructive.
Before posting my ECMAScript regex, I thought it would be interesting to analyze Martin Ender's .NET pure regex solution, ^(?!(1(?<=(?=(?(\3+$)((?>\2?)\3)))^(1+)))*1$). It turns out to be very straightforward to understand that regex, and it is elegant in its simplicity. To demonstrate the contrast between our solutions, here is a commented and pretty-printed (but unmodified) version of his regex:
# For the purpose of these comments, the input number will be referred to as N.

^(?!                  # Attempt to add up all the divisors. Since this is a regex and we
                      # can only work within the available space of the input, that means
                      # if the sum of the divisors is greater than N, the attempt to add
                      # all the divisors will fail at some point, causing this negative
                      # lookahead to succeed, showing that N is an abundant number.

  (1                  # Cycle through all values of tail that are less than N, testing
                      # each one to see if it is a divisor of N.

    (?<=              # Temporarily go back to the start so we can directly operate both
                      # on N and the potential divisor. This requires variable-length
                      # lookbehind, a .NET feature – even though this special case of
                      # going back to the start, if done left-to-right, would actually be
                      # very easy to implement even in a regex flavour that has no
                      # lookbehind to begin with. But .NET evaluates lookbehinds right
                      # to left, so please read these comments in the order indicated,
                      # from [Step 1] to [Step 7]. The comment applying to entering the
                      # lookahead group, [Step 2], is shown on its closing parenthesis.
      (?=             # [Step 3] Since we're now in a lookahead, evaluation is left to
                      #          right.
        (?(\3+$)      # [Step 4] If \3 is a divisor of N, then...
          (           # [Step 5] Add it to \2, the running total sum of divisors:
                      #          \2 = \2 + \3
            (?>\2?)   # [Step 6] Since \2 is a nested backref, it will fail to match on
                      #          the first iteration. The "?" accounts for this, making
                      #          it add zero to itself on the first iteration. This must
                      #          be done before adding \3, to ensure there is enough room
                      #          for the "?" not to cause the match to become zero-length
                      #          even if \2 has a value.
            \3        # [Step 7] Iff we run out of space here, i.e. iff the sum would
                      #          exceed N at this point, the match will fail, making the
                      #          negative lookahead succeed, showing that we have an
                      #          abundant number.
          )

        )
      )               # [Step 2] Enter a lookahead that is anchored to the start due to
                      #          having a "^" immediately to its right. The regex would
                      #          still work if the "^" were moved to the left of the
                      #          lookahead, but would be slightly slower, because the
                      #          engine would do some spurious matching before hitting
                      #          the "^" and backtracking.
      ^(1+)           # [Step 1] \3 = number to test for being a potential divisor – its
                      #               right-side-end is at the point where the lookbehind
                      #               started, and thus \3 cycles through all values from
                      #               1 to N-1.
    )
  )*1$                # Exclude N itself from being considered as a potential divisor,
                      # because if we included it, the test for proper abundance would be
                      # the sum of divisors exceeding 2*N. We don't have enough space for
                      # that, so instead what would happen if we did not exclude N as a
                      # divisor would be testing for "half-abundance", i.e. the sum of
                      # all divisors other than N exceeding N/2. By excluding N as a
                      # divisor we can let our threshold for abundance be the sum of
                      # divisors exceeding N.
)

Try the .NET regex online
Now, back to my ECMAScript regex. First, here it is in raw, whitespace-and-comment-free format:
^(?=(((?=(xx+?)\3+$)(x+)\4*(?=\4$))+(?!\3+$)(?=(xx(x*?))\5*$)x)(x+))(?=\1(x(x*))(?=\8*$)\6\9+$)(?=(.*)((?=\8*$)\5\9+$))(?=(x*?)(?=(x\11)+$)(?=\12\10|(x))(x(x*))(?=\15*$)(?=\11+$)\11\16+$)(?=(x(x*))(?=\17*$)\7\18+$)((?=(x*?(?=\17+$)(?=\17+?(?=((xx(x*))(?=\18+$)\22*$))(x+).*(?=\17$)\24*(?=\24$)(?!(xx+)\25*(?!\22+$)\25$)\22+$)((?=(x\7)+$)\15{2}\14|)))(?=.*(?=\24)x(x(x*))(?=\28*$)\23\29*$)(?=.*(x((?=\28*$)\22\29+$)))(.*(?!\30)\20|(?=.*?(?!x\20)(?=\30*$)(x(x*))(?=\33*$)(?=\31+$)\31\34+$).*(?=\33\21$)))+$
(change \14 to \14? for compatibility with PCRE, .NET, and practically every other regex flavour that's not ECMAScript)
Try it online!
Try it online! (faster, 537 byte version of the regex)
And now a brief summary of the story behind it.
At first it was very non-obvious, to me at least, that it was even possible to match primes in the general case. And after solving that, the same applied to powers of 2. And then powers of composite numbers. And then perfect squares. And even after solving that, doing generalized multiplication seemed impossible at first.
In an ECMAScript loop, you can only keep track of one changing number; that number cannot exceed the input, and has to decrease at every step. My first working regex for matching correct multiplication statements A*B=C was 913 bytes, and worked by factoring A, B, and C into their prime powers – for each prime factor, repeatedly divide the pair of prime power factors of A and C by their prime base until the one corresponding to A reaches 1; the one corresponding to C is then compared to the prime power factor of B. These two powers of the same prime were "multiplexed" into a single number by adding them together; this would always be unambiguously separable on each subsequent iteration of the loop, for the same reason that positional numeral systems work.
We got multiplication down to 50 bytes using a completely different algorithm (which teukon and I were able to arrive at independently, though it took him only a few hours and he went straight to it, whereas it took me a couple days even after it was brought to my attention that a short method existed): for A≥B, A*B=C if and only if C is the smallest number which satisfies C≡0 mod A and C≡B mod A-1. (Conveniently, the exception of A=1 needs no special handling in regex, where 0%0=0 yields a match.) I just can't get over how neat it is that such an elegant way of doing multiplication exists in such a minimal regex flavour. (And the requirement of A≥B can be replaced with a requirement that A and B are prime powers of the same power. For the case of A≥B, this can be proven using the Chinese remainder theorem.) See this post for a more in-depth explanation.
If it had turned out that there was no simpler algorithm for multiplication, the abundant number regex would probably be on the order of ten thousand bytes or so (even taking into account that I golfed the 913 byte algorithm down to 651 bytes). It does lots of multiplication and division, and ECMAScript regex has no subroutines.
I started working on the abundant number problem tangentially in 23 March 2014, by constructing a solution for what seemed at the time to be a sub-problem of this: Identifying the prime factor of highest multiplicity, so that it could be divided out of N at the start, leaving room to do some necessary calculations. At the time this seemed to be a promising route to take. (My initial solution ended up being quite large at 326 bytes, later golfed down to 185 bytes.) But the rest of the method teukon sketched would have been extremely complicated, so as it turned out, I took a rather different route. It proved to be sufficient to divide out the largest prime power factor of N corresponding to the largest prime factor on N; doing this for the prime of highest multiplicity would have added needless complexity and length to the regex.
What remained was treating the sum of divisors as a product of sums instead of a straight sum. As explained by teukon on 14 March 2014:

We're given a number n = p0a0p1a1...pk-1ak-1.  We want to handle the sum of the factors of n, which is (1 + p0 + p02 + ... + p0a0)(1 + p1 + p12 + ... + p1a1)...(1 + pk-1 + pk-12 + ... + pk-1ak-1).

It blew my mind to see this. I had never thought of factoring the aliquot sum in that way, and it was this formula more than anything else that made the solvability of abundant number matching in ECMAScript regex look plausible.
In the end, instead of testing for a result of addition or multiplication exceeding N, or testing that such a result pre-divided by M exceeds N/M, I went with testing if a result of division is less than 1. I arrived at the first working version on 7 April 2014.
The full history of my golf optimizations of this regex is on github. At a certain point one optimization ended up making the regex much slower, so from that point on I maintained two versions. They are:
regex for matching abundant numbers.txt
regex for matching abundant numbers - shortest.txt
These regexes are fully compatible with both ECMAScript and PCRE, but a recent optimization involved using a potentially non-participating capture group \14, so by dropping PCRE compatibility and changing \14? to \14 they can both be reduced by 1 byte.
Here is the smallest version, with that optimization applied (making it ECMAScript-only), reformatted to fit in a StackExchange code block with (mostly) no horizontal scrolling needed:
# Match abundant numbers in the domain ^x*$ using only the ECMAScript subset of regex
# functionality. For the purposes of these comments, the input number = N.
^
# Capture the largest prime factor of N, and the largest power of that factor that is
# also a factor of N. Note that the algorithm used will fail if N itself is a prime
# power, but that's fine, because prime powers are never abundant.
(?=
  (                      # \1 = tool to make tail = Z-1
    (                    # Repeatedly divide current number by its smallest factor
      (?=(xx+?)\3+$)
      (x+)\4*(?=\4$)
    )+                   # A "+" is intentionally used instead of a "*", to fail if N
                         #  is prime. This saves the rest of the regex from having to
                         #  do needless work, because prime numbers are never abundant.
    (?!\3+$)             # Require that the last factor divided out is a different prime.
    (?=(xx(x*?))\5*$)    # \5 = the largest prime factor of N; \6 = \5-2
    x                    # An extra 1 so that the tool \1 can make tail = Z-1 instead of just Z
  )
  (x+)                   # Z = the largest power of \5 that is a factor of N; \7 = Z-1
)
# We want to capture Z + Z/\5 + Z/\5^2 + ... + \5^2 + \5 + 1 = (Z * \5 - 1) / (\5 - 1),
# but in case Z * \5 > N we need to calculate it as (Z - 1) / (\5 - 1) * \5 + 1.
# The following division will fail if Z == N, but that's fine, because no prime power is
# abundant.
(?=
  \1                     # tail = (Z - 1)
  (x(x*))                # \8   = (Z - 1) / (\5 - 1); \9 = \8-1
  # It is guaranteed that either \8 > \5-1 or \8 == 1, which allows the following
  # division-by-multiplication to work.
  (?=\8*$)
  \6\9+$
)
(?=
  (.*)                   # \10 = tool to compare against \11
  (                      # \11 = \8 * \5  =  (Z - 1) / (\5 - 1) * \5; later, \13 = \11+1
    (?=\8*$)
    \5\9+$
  )
)
# Calculate Q = \15{2} + Q_R = floor(2 * N / \13). Since we don't have space for 2*N, we
# need to calculate N / \13 first, including the fractional part (i.e. the remainder),
# and then multiply the result, including the fractional part, by 2.
(?=
  (x*?)(?=(x\11)+$)      # \12 = N % \13; \13 = \11 + 1
  (?=\12\10|(x))         # \14 = Q_R = floor(\12 * 2 / \13)
                         #     = +1 carry if \12 * 2 > \11, or NPCG otherwise
  (x(x*))                # \15 = N / \13; \16 = \15-1
  (?=\15*$)
  (?=\11+$)              # must match if \15 <  \13; otherwise doesn't matter
  \11\16+$               # must match if \15 >= \13; otherwise doesn't matter
)
# Calculate \17 = N / Z. The division by Z can be done quite simply, because the divisor
# is a prime power.
(?=
  (x(x*))                # \17 = N / Z; \18 = \17-1
  (?=\17*$)
  \7\18+$
)
# Seed a loop which will start with Q and divide it by (P^(K+1)-1)/(P-1) for every P^K
# that is a factor of \17. The state is encoded as \17 * P + R, where the initial value
# of R is Q, and P is the last prime factor of N to have been already processed.
#
# However, since the initial R would be larger than \17 (and for that matter there would
# be no room for any nonzero R since with the initial value of P, it is possible for
# \17 * P to equal N), treat it as a special case, and let the initial value of R be 0,
# signalling the first iteration to pretend R=Q. This way we can avoid having to divide Q
# and \17 again outside the loop.
#
# While we're at it, there's really no reason to do anything to seed this loop. To seed
# it with an initial value of P=\5, we'd have to do some multiplication. If we don't do
# anything to seed it, it will decode P=Z. That is wrong, but harmless, since the next
# lower prime that \17 is divisible by will still be the same, as \5 cannot be a factor
# of \17.

# Start the loop.
(
  (?=
    (                    # \20 = actual value of R
      x*?(?=\17+$)       # move forward by directly decoded value of R, which can be zero
      # The division by \17 can be done quite simply, because it is known that
      # the quotient is prime.
      (?=
        \17+?            # tail = \17 * (a prime which divides into \17)
        (?=
          (              # \21 = encoded value for next loop iteration
            (xx(x*))     # \22 = decoded value of next smaller P; \23 = (\22-1)-1
            (?=\18+$)    # iff \22 > \17, this can have a false positive, but never a false negative
            \22*$        # iff \22 < \17, this can have a false positive, but never a false negative
          )
        )
        # Find the largest power of \22 that is a factor of \17, while also asserting
        # that \22 is prime.
        (x+)             # \24 = the largest power of \22 that is a factor of \17
        .*(?=\17$)
        \24*(?=\24$)
        (?!
          (xx+)\25*
          (?!\22+$)
          \25$
        )
        \22+$
      )
      (
        (?=(x\7)+$)      # True iff this is the first iteration of the loop.
        \15{2}\14        # Potentially unset capture, and thus dependent on ECMAScript
                         # behavior. Change "\14" to "\14?" for compatibility with non-
                         # ECMAScript engines, so that it will act as an empty capture
                         # with engines in which unset backrefs always fail to match.
      |
      )
    )
  )
  # Calculate \30 = (\24 - 1) / (\22 - 1) * \22 + 1
  (?=
    .*(?=\24)x           # tail = \24 - 1
    (x(x*))              # \28 = (\24 - 1) / (\22 - 1); \29 = \28-1
    (?=\28*$)
    \23\29*$
  )
  (?=
    .*(x(                # \30 = 1 + \28 * \22 = (\28 - 1) / (\22 - 1) * \22 + 1; \31 = \30-1
      (?=\28*$)
      \22\29+$
    ))
  )
  # Calculate \33 = floor(\20 / \30)
  (
    .*(?!\30)\20         # if dividing \20 / \30 would result in a number less than 1,
                         # then N is abundant and we can exit the loop successfully
  |
    (?=
      .*?(?!x\20)(?=\30*$)
      (x(x*))            # \33 = \20 / \30; \34 = \33-1
      (?=\33*$)
      (?=\31+$)          # must match if \33 <  \30; otherwise doesn't matter
      \31\34+$           # must match if \33 >= \30; otherwise doesn't matter
    )
    # Encode the state for the next iteration of the loop, as \17 * \22 + \33
    .*(?=\33\21$)
  )
)+$


Python – 5

Python 3 built-in function pow have third parameter. So Python 3 already have built-in RSA encoder

r=pow


print("Hello World!")

Works in at least  Julia, Perl, PHP, Python2, Python3, Qbasic, R, Ruby ...


Output the largest number with the fewest digits

Pyth, 7 3 6 bytes

eS.ml`

Test Suite

Explanation:

e      Still grab the last element
 S      Still sort
  .ml`   But prefilter the list for those with the (m)inimum length.

7 byte solution:

eSh.gl`

Test Suite

Explanation:

   .g   Group items in (implicit) input by:
     l  The length of
      ` their representation
  h     Get those with the shortest length
 S      Sort the resulting list
e       and grab the last (i.e. largest) element


CodingAndAlgorithms
This answer actually uses coding and algorithms, unlike the others so far!reference: imgur(also beats all of the answers posted before this)
def play(A, B):
    if sum(A) == 1:
        return [A.index(1), B.index(max(B))]
    elif max(A) + max(B) > 1000:
        return [A.index(max(A)), B.index(max(B))]
    elif 0 in A:
        return 1
    elif 0 in B:
        return [A.index(min(A)), 1-B.index(0)]
    else:
        return [A.index(min(A)), B.index(min(B))]


Mathematica, 108 bytes

Print@@Join@@({Characters@"CHON",#}ᵀ/.a_/;Last@a<2:>Table@@a)&/@{12011,1008,15999,14007}~FrobeniusSolve~#&

Pure function expecting the input as an integer (1000 times the relative molecular mass); it prints all possible answers to STOUD (and returns an array of Nulls).

The heavy lifting is done by the builtin {12011,1008,15999,14007}~FrobeniusSolve~#, which finds all nonnegative integer combinations of the hardcoded weights that equal the input. {Characters@"CHON",#}ᵀ puts each such combination in a form like {{"C", 0}, {"H", 1}, {"O", 2}, {"N", 3}}. (ᵀ is actually the 3-byte private Mathematica character U+F3C7.)

The transformation rule /.a_/;Last@a<2:>Table@@a changes pairs of the form {x, 0} to {} and pairs of the form {x, 1} to {x} (and spits out errors as it tries to apply to the whole expression as well). Then Print@@Join@@ prints the result in the correct form, avoiding the need to cast the integers as strings and concatenate.


Python 3, 53 50 49 bytes

Thanks @JonathanAllan for saving 1 byte!

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

Try it online!


JavaScript (ES7), 128 126 bytes

(m,a,D,S,t=0)=>S.map((s,i)=>t+=(r=(f=d=>d>s/2?1+f((l=d<m?d:m,l*l+d*d-2*d*l*Math.cos(a*Math.PI/180))**.5,s):2)(D[i]))<8?r:8)&&t

Try it online!

Explanation

Because only the distance from the ball to the hole matters and not the coordinates of the ball, we can write an algorithm that calculates how close the ball gets to the hole with each shot, then run that repeatedly until the ball reaches the green. But how do we do this?

Re-using OP's helpful diagram explaining ball movement, with MS Paint modifications:

We have access to these numbers:

d, the current distance from ball to hole;
θ, the slice angle; and
l, the length of the shot (minimum of d and the max shot length).

And the goal is to find x, the distance from ball to hole after the shot is taken.

First we note that a and b are simply l cos θ and l sin θ, respectively. We can see that by the Pythagorean theorem, x can be represented as sqrt(b2 + (d-a)2). Expanding this out, we get

x = sqrt(b^2 + (d - a)^2)
  = sqrt((l*sin(θ))^2 + (d - l*cos(θ))^2)
  = sqrt((l^2 * sin^2(θ)) + (d^2 - 2*d*l*cos(θ) + l^2 * cos^2(θ))
  = sqrt(l^2 * sin^2(θ) + l^2 * cos^2(θ) + d^2 - 2dl*cos(θ))
  = sqrt(l^2 * (sin^2(θ) + cos^2(θ)) + d^2 - 2dl*cos(θ))
  = sqrt(l^2 * 1 + d^2 - 2dl*cos(θ))
  = sqrt(l^2 + d^2 - 2dl*cos(θ))

And so, the new distance from ball to hole will be sqrt(l2 + d2 - 2dl cos θ). Then we count the iterations it takes to get this distance within the radius of the green, add 2, and cap at 8 to get the final score for that hole.

(Thanks to @LegionMammal978 for pointing out that all of the calculations I made are a direct result of the law of cosines...)

Interestingly enough, when the ball is closer to the hole than its max shot, l = d and we can simplify the formula quite a bit further:

x = sqrt(l^2 + d^2 - 2dl*cos(θ))
  = sqrt(d^2 + d^2 - 2d^2*cos(θ))
  = sqrt(2d^2 - 2d^2*cos(θ))
  = sqrt(d^2(2 - 2cos(θ)))
  = d * sqrt(2 - 2cos(θ))

To find the # of remaining iterations, we could then simply find d / r (where r = the radius of the green) and divide that by sqrt(2 - 2cos(θ)), then take the ceiling of the result and add 2. Unfortunately, this doesn't seem to be as short as just finding the smaller of d and the max shot length.


APL (Dyalog Classic), 21 bytes

∊⊢,⊢∘⊂~¨(,\⊣⊂⍨1,2>/⍋)

Try it online!

This is a train equivalent to {∊⍵,(⊂⍵)~¨(,\⍺⊂⍨1,2>/⍺⍋⍵)}

⍋ gives the permutation of right argument ⍵ in left argument ⍺

1,2>/ compare consecutive pairs with > and prepend a 1

⍺⊂⍨ use the above boolean mask to split ⍺ into groups; 1s in the mask mark the start of a new group

,\ cumulative concatenations of the groups

(⊂⍵)~¨ complement of each with respect to ⍵

⍵, prepend ⍵

∊ flatten as a single string


Find all a, b, c, d, e, such that a + b + c + d + e = 1000 with no more than 3 loops

APL (Dyalog Unicode), 23 16 bytesSBCS

Full program. No loops. Prints a list of quintuplets with two spaces between them. Each quintuplet has the variables separated by single spaces. Requires 0-indexing (⎕IO←0) which is default on many systems.

⍸1E3=⊃∘.+/5⍴⊂⍳1001

Since the above code requires more memory than available on TIO, here's exactly the same, but with a + b + c + d + e between 0 and 10 and a sum of 10:

⍸1E1=⊃∘.+/5⍴⊂⍳11.0

Try it online!

⍳1001 the ɩntegers 0…1000

⊂ enclose to treat as a unit

5⍴ reshape that to length 5

∘.+/ reduction by outer-sum (like outer product, but with plus)
this creates a 5D array with all dimensions being 1000 elements long

⊃ disclose (the reduction had to enclose the result to reduce the rank from 1  to 0)

1E3 5D Boolean mask where equal to 1000

⍸ list of ɩndices where true


Floating points: Make Gaussian elimination go wrong

Taking this as a question about numerical inaccuracy in calculations rather than in conversion from numbers which can't be exactly represented in 64 bits to 64-bit representations, we're interested in nearly singular matrices.

Let's take the simplest possible case:

[a b] [x] = [p]
[c d] [y]   [q]

has solution

[x] = [(dp - bq) / (ad - bc)]
[y]   [(aq - cp) / (ad - bc)]

so that if ad - bc is very small we find that errors in dp - bq and aq - cp are magnified.

We also find that scaling p and q scales the absolute error linearly, which points out a massive flaw in the scoring system of this question.

How can we get a nearly singular matrix? In order of ill-conditionedness:

a=1+e, b=c=d=1 gives ad - bc = e. This allows us to get a determinant of 1 ulp (which for IEEE 64-bit is on the order of 10^-16).
a=1+e, d=1-e, b=c=1 gives ad - bc = -e^2. This allows us to get a determinant on the order of 10^-32.

2
1.000000000000001 1
1 0.999999999999999

1 1

gives output:

1.0 1.0 | 1.0
1.0 1.0 | 1.0

Result: -9.0    10.0

rather than x = 100000000000000, y = -100000000000000

Similarly,

2
1.000000000000001 1
1 0.999999999999999

1E307 1E307

gives

1.0 1.0 | 1e+307
1.0 1.0 | 1e+307

Result: -9.1120238836e+307  1.01120238836e+308

rather than x = 1E321, y = -1E321. This seems to roundly beat Johannes' solution (it gives a score on the order of 10^642 vs 10^588), and moreover it would continue to generate about the same score even if the input numbers were tweaked to be exactly representable in IEEE 64-bit, whereas his would then score 0.
a=d=e, bc=0 gives ad - bc = e^2 but this time we can choose e to be a very small number rather than 1 ULP. In principle this allows us to get a determinant on the order of 10^-600 (i.e. underflowing IEEE 64-bit). However, so far I haven't managed to get a decent score without an infinity in the answer, and I gather from your chat with Johannes that even though the question doesn't rule out infinite scores, in practice you do.


05AB1E, 1 byte

£

This is the substring(0,N) command.
Applied on a list this works repeatedly on the remainder on the string.

Try it online!


Remove Spaces, Maintaining Capitalization


Write the prettiest bytebeat composition

(Signed 16-bit little endian, 8000Hz mono (--format=S16_LE))

Music

Much better than before! (although it's quite long)

main(t){for(;;t++)putchar(((7&(((t>>17)+1)>>2)+((t>>10)&1+2*(t>>18&1))*(("23468643"[7&t>>12]-48)+(3&t>>11))+((3&t>>17)>0)*(3&t>>9)*!(1&t>>10)*(((2+t>>10&3)^(2+t>>11&3))))*t*"@06+"[3&t>>15]/32));}

(You can listen this at here)

I wrote this, but even I don't know how some part works, like >0 and (especially) the first 7&.

Change for loop to for(;!(t>>22);t++)... to listen it 'once'. I don't know whether it "loops" exactly the same way, however.

Melody (base of above music)

I love this melody I made (C-G-A-F ftw), but it's too 'plain'...

main(t){for(;;t++)putchar(((t>>10)&1)*(t*("23468643"[7&t>>12]-48)+t*(3&t>>11))*"@06+"[3&t>>15]/32);}

Simple music (which I made before)

main(t){for(;;t++)putchar(t*(3&t>>11)+(t&t>>11)*4*!((t>>11)%3));}


Python, 82 78
def f(b):G=b^b&b-1;return sum(b**(b/G-i-1)*(G*i+(G-1)*b/2)for i in range(b/G))

Huh?

The number of digit groups that the subdivison yields, G, is simply the greatest power of two that divides the number of digits (i.e. the base), b.
It's given by G = b ^ (b & (b - 1)), where ^ is bitwise-XOR.
If you're familiar with the fact that n is a power of two iff n & (n - 1) = 0 then it should be pretty easy to see why.
Otherwise, work out a few cases (in binary) and it'll become clear.

The number of digits per group, g, is simply b / G.

The first digit group, 012...(g-1), as a number in base b, is .

The next group, g(g+1)...(2g-1), as a number in base b, is the sum
.

More generally, the n-th group (zero-based), as a number in base b, an, is .

Recall that there are G groups, hence the sum of all groups is

which is what the program calculates.


Take It or Leave It: A Game Show for Computers

CJam, $87,143 $700,424 $720,327 $727,580 $770,272

{0:T:M;1e4:E,:)mr{RM>{RR(*MM)*-E0.032*220+R*<{ERM--:E;R:MT+:T;}{E(:E;}?}&}fRT}
[easi*]$easi2/=N

This program simulates the entire game multiple times and calculates the median.

How to run

I've scored my submission by doing 100,001 test runs:

$ time java -jar cjam-0.6.5.jar take-it-or-leave-it.cjam 100001
770272

real    5m7.721s
user    5m15.334s
sys     0m0.570s

Approach

For each envelope, we do the following:

Estimate the amount of money that will inevitably be lost by taking the envelope.

If R is the content and M is the maximum that has been taken, the amount can be estimated as R(R-1)/2 - M(M+1)/2, which gives the money all envelopes with contents X in the interval (M,R) contain.

If no envelopes had been passed yet, the estimation would be perfect.
Calculate the amount of money that will inevitably be lost by passing the envelope.

This is simply the money the envelope contains.
Check if the quotient of both is less than 110 + 0.016E, where E is the number of remaining envelopes (not counting envelopes that cannot be taken anymore).

If so, take. Otherwise, pass.


Print Leonardo DiCaprio without using any of the letters in his name


Pyth, 35 34 bytes
Input already converted to decimal.
L+O32+eSbhSbf<yTJ495Qf|gyTJ<yT347Q

Test suite.
Previous 35-byte version:
Input already converted to decimal.
L+O32+eSbhSbf<yT495Qf|gyT495<yT347Q

Test suite.
Verify that the third testcase is not the same for each run.
Sample input/output:
input:
[[217, 102, 255], [236, 179, 255], [172, 0, 230]]
output:
[[217, 102, 255], [236, 179, 255], [172, 0, 230]]
[[172, 0, 230]]

Explanation
(max/255 + min/255)/2 + random[-0.03 .. 0.03] >= 0.94
(max/255 + min/255) + random[-0.06 .. 0.06] >= 1.88
max + min + random[-15 .. 15] >= 479.4
max + min + random[0 .. 31] >= 494.4
max + min + random[0 .. 31] >= 495

(max/255 + min/255)/2 + random[-0.03 .. 0.03] <= 0.65
(max/255 + min/255) + random[-0.06 .. 0.06] <= 1.30
max + min + random[-15 .. 15] <= 331.5
max + min + random[0 .. 31] <= 346.4
max + min + random[0 .. 31] < 347

L+O32+eSbhSbf<yT495Qf|gyT495<yT347Q
                                     @memoized
L                                    def y(b):
 +O32                                    return random(range(32)) +
     +eSb                                b.sort[-1] +
         hSb                             b.sort[0]
            f      Q                 filter for elements in Q as T:
             <yT495                      y(T) < 495
                                     (implicitly printed)
                    f             Q  filter for elements in Q as T
                     |gyT495             y(T) >= 495 or
                            <yT347       y(T) < 347
                                     (implicitly printed)

Before you complain that it calls random three times, hence having inconsistent outputs from the function, note that the function is memoized.
Before you complain that different students with the same colour always produce the same outcome, note that the question never said that the random generator must be independent. It must only be uniform.


Python 3, 58 52 bytes

lambda n:[9-(9in n)-sum(x>d for x in{*n})for d in n]

Try it online!

Input: The number n, as a list of digits.
Output: A similar number, as a list of digits.

-6 bytes thanks to @xnor!

How:
Reverses the list of unique digits, then maps them to 9,8,7,... or 8,7,6,... depending on whether n contains the digit 9 or not.
For example:

               | n = 1827 | n = 7899
Reverse unique |   8721   |   987
Maps to        |   9876   |   876
Results        | m = 6978 | m = 6788

Old solution

Python 3, 80 bytes

f=lambda n,i=9:(i in n)^(i-1in n)and[[d,d^i^~-i][i-2<d<=i]for d in n]or f(n,i-1)

Try it online!

Input: The number n, as a list of digits.
Output: A similar number, as a list of digits.

-1 byte thanks to @KevinCruijssen!

How
The solution tries to find a pair of consecutive digits \$(i-1,i)\$ such that one digit appears in \$n\$, and the other doesn't. It then replaces all occurrences of one digit with the other.
The pair of digits are searched from \$(8,9)\$ downward, in order to discourage replacing 1 with 0.


GolfScript (90 chars)

n/.,1&[""]*+.{,}%$-1=.1&+{1$,-´' '*+}+%2/{zip 2/{~+0\{32=!1$++}/" ▗▝▐▖▄▞▟▘▚▀▜▌▙▛█"3/=}%n}%

A lot of this goes to handling ragged arrays. Nasty test case:

xx
xxx
xxx
xx
x

contains a 3 different 2x2 grids with only one of the 4 cells containing any character at all.

To make things worse, the zip transposition to chop the columns into pairs gives the same output for ["xx" "xxx"]zip and ["xxx" "xx"]zip. I therefore begin by padding out to ensure that all lines are the same even length, and that there are an even number of lines.

Note that this program assumes that the interpreter will treat " ▗▖▄▝▐▞▟▘▚▌▙▀▜▛█" as a string of length 48, even though as per instructions in the question I'm counting it as 16 chars plus delimiters.

I've tested this to the best of my ability, but I can't find a monospace font which actually renders those characters correctly.


Create a programming language interpreter

DogeScript

The 99 bottles of beer program:

many amaze 99 time

such scare bottles-of-beer
such scream on-the-wall
many despair 13 time

such fail take-one-down-pass-it-around

wow

so amaze
so scare
so scream
so despair!

so amaze
so scare
so despair!

much amaze

so fail
so despair!

so amaze
so scare
so scream

so despair!
so despair!

very amaze

wow

The PHP interpreter:

<?php
$input=fopen('php://stdin', 'r');

//pre-process input
$input=preg_replace("/ +/", " ", $input); //replace any multiple spaces by a single space

//split into instructions by newlines
$instructions=explode("\n", $input);

$loopstartpoint= -1;
$variables=array();
$activevariable="";
for($instrpointer=0; $instrpointer<count($instructions); $instrpointer++)
{
    $tokens=explode(" ", $instructions[$instrpointer]);
    switch($tokens[0])
    {
        case "wow":
            if($loopstartpoint<0)
            {
                $loopstartpoint=$instrpointer+1;
            }
            else
            {
                if($variables[ $activevariable ])
                {
                    $instrpointer=$loopstartpoint;
                }
                else
                {
                    $loopstartpoint= -1;
                }
            }
            break;
        case "so":
            if(substr($tokens[1], -1)=="!")
            {
                echo chr($variables[ substr($tokens[1], 0, -1) ]);
            }
            else
            {
                echo $variables[ $tokens[1] ];
                echo " ";
            }
            break;
        case "very":
            $activevariable=$tokens[1];
            break;
        case "much":
            if(!isset($variables[ $tokens[1] ]))
                $variables[ $tokens[1] ]=0;
            if(count($tokens)==2)
            {
                $variables[ $tokens[1] ]--;
            }
            else
            {
                for($loop=0;$loop<$tokens[2];$loop++)
                {
                    $variables[ $tokens[1] ]--;
                }
            }
            $activevariable=$tokens[1];
            break;
        case "many":
            if(!isset($variables[ $tokens[1] ]))
                $variables[ $tokens[1] ]=0;
            if(count($tokens)==2)
            {
                $variables[ $tokens[1] ]++;
            }
            else
            {
                for($loop=0;$loop<$tokens[2];$loop++)
                {
                    $variables[ $tokens[1] ]++;
                }
            }
            $activevariable=$tokens[1];
            break;
        case "such":
            $variables[ $tokens[1] ]=$tokens[2];
            $activevariable=$tokens[1];
            break;
    }
}
?>

The syntax as it currently stands:

wow - start and end loops, end of loop checks if active variable is 0 and loops if not
so without ! - print variable's value
so with ! - print variable's ASCII character
much - decrement this variable
many - increment this variable
such - set variable
very - make variable active
x time - does previous statement x times

Variables are initially 0.

Try it here.
Any suggestions for improvement are welcome.


convey, 66 bytes
1<<<<,<<
/>>>v$1^
,<"<##<^
:`#?@#^^
{1$v>"}%2
  ~,>/+?<
  3 0$,>*2

Try it online!
Explanation will follow after I tried some other orientations …


Python 3.8 (pre-release), 51 bytes

lambda s:((c:=s.count)('o')-c('/'),c('/o'),c('/-'))

Try it online!


JavaScript (ES6), 61 51 50 bytes

Takes 6 distinct parameters as input, in the order described in the challenge. Expects the last parameter to be 1 for read, 2 for write or 3 for execute. Returns 0 or 1.

(p,u,g,a,G,P)=>!a|p[u-a?6-3*G.includes(g)+P:P]>'Z'

Test cases

let f =

(p,u,g,a,G,P)=>!a|p[u-a?6-3*G.includes(g)+P:P]>'Z'

//            p             u   g   a   G          P
console.log(f('-rwx------', 13, 15, 13, [15, 24],  1)) // True  (user)
console.log(f('-rwxr-xr-x', 13, 24, 24, [15, 24],  2)) // False (group)
console.log(f('-rwxr-Sr-T', 13, 15, 24, [15, 35],  3)) // False (group)
console.log(f('-rwsr-xr-t', 13, 15, 24, [24, 35],  3)) // True  (others)
console.log(f('----------', 13, 15,  0, [0, 1, 2], 1)) // True  (superuser)
console.log(f('----------', 13, 15,  1, [0, 1, 2], 1)) // False (others)
console.log(f('----rwxrwx', 13, 15, 13, [15, 24],  1)) // False (user)


Write an program that terminates after 60 seconds - Cops' Thread

Perl 52 bytes (26 edits allowed) (Safe, technically speaking)

sub a{[gmtime+time]->[0]^$x}$x=a;0 until a;0 while a

Unfortunately, I don't think it's possible to write an uncrackable Perl program (it should become obvious why if and when this is cracked; being able to edit half the program is just too much), but this algorithm should be very hard to change to wait for any length of time other than 1 minute.
Marking this as safe, as nobody's officially submitted a crack for 14 days (although someone unofficially cracked it by just writing a separate program and commenting out the existing code). The basic idea of the program is as follows: we look at the seconds digit of the time, loop until it changes, then loop until it returns to its original value. This requires quite some changes to alter to a length of time other than 1 minute, 1 hour, or 1 day (although 26 edits is easily enough – you can do some modular arithmetic on the seconds value to determine a new target to wait until – but nobody found that solution).


Encode Images into Tweets (Extreme Image Compression Edition)

I've improved my method by adding actual compression. It now operates by iteratively doing the following:

Convert the image to YUV
Downsize the image preserving the aspect ratio (if the image is color, the chroma is sampled at 1/3 the width & height of the luminance)
Reduce the bit depth to 4 bits per sample
Apply median prediction to the image, making the sample distribution more uniform
Apply adaptive range compression to the image.
See if the size of the compressed image is <= 112

The largest image that fits in the 112 bytes is then used as the final image, with the remaining two bytes used to store the width & height of the compressed image, plus a flag indicating if the image is in color. For decoding, the process is reversed, and the image scaled up so the smaller dimension is 128.

There is some room for improvement, namely not all the available bytes are used typically, but I feel I'm at the point of significantly diminishing returns for downsampling + lossless compression.

Quick & dirty C++ source

Windows exe

Mona Lisa (13x20 luminance, 4x6 chroma)

&Jhmi8(,x6})Y"f!JC1jTzRh}$A7ca%/B~jZ?[_I17+91j;0q';|58yvX}YN426@"97W8qob?VB'_Ps`x%VR=H&3h8K=],4Bp=$K=#"v{thTV8^~lm vMVnTYT3rw N%I

Hindenburg (21x13 luminance)

GmL<B&ep^m40dPs%V[4&"~F[Yt-sNceB6L>Cs#/bv`\4{TB_P Rr7Pjdk7}<*<{2=gssBkR$>!['ROG6Xs{AEtnP=OWDP6&h{^l+LbLr4%R{15Zc<D?J6<'#E.(W*?"d9wdJ'

Mountains (19x14 luminance, 6x4 chroma)

Y\Twg]~KC((s_P>,*cePOTM_X7ZNMHhI,WeN(m>"dVT{+cXc?8n,&m$TUT&g9%fXjy"A-fvc 3Y#Yl-P![lk~;.uX?a,pcU(7j?=HW2%i6fo@Po DtT't'(a@b;sC7"/J

2D Shapes (21x15 luminance, 7x5 chroma)

n@|~c[#w<Fv8mD}2LL!g_(~CO&MG+u><-jT#{KXJy/``#S@m26CQ=[zejo,gFk0}A%i4kE]N ?R~^8!Ki*KM52u,M(his+BxqDCgU>ul*N9tNb\lfg}}n@HhX77S@TZf{k<CO69!


APL, 53 49 43 42 40 39 36

I managed to replicate J's ;. in APL, and used Gareth's approach, saving 13 chars.

{×5⌷⍵:5⌷⍵⋄+/⍵}¨3,⌿3,/×∘?∘9¨∘.∨⍨9⍴0 1

Sample run:

      {×5⌷⍵:5⌷⍵⋄+/⍵}¨3,⌿3,/×∘?∘9¨∘.∨⍨9⍴0 1
9  9 6  1 7  5 6
7 55 5 39 9 54 9
9  8 2  1 8  1 9
2 43 8 41 6 42 5
7  3 4  4 8  3 2
2 29 1 26 2 35 8
6  4 2  3 2  3 7

Explanation:

∘.∨⍨9⍴0 1 generates a bit mask.
×∘?∘9¨ multiplies each bit by a random value from 1 to 9 inclusive, generating a masked grid of random numbers.
3,⌿3,/ uses what can only be described as hackery to return all 3 by 3 overlapping boxes in the masked array. These are also flattened in the process.
{×5⌷⍵:5⌷⍵⋄+/⍵}¨ iterates over the array, assigning each element to ⍵. For each iteration, it takes the fifth (middle, remembering that APL indexing is 1-based), and returns its sign. In this case this is equivalent to testing if the number is greater than 0. If this returns 1 (for true), then return that element. Otherwise, return the sum of the elements in the flattened 3 by 3 box. It uses the :⋄ ternary operator, which is the equivalent of ?: in many languages.


Retina, 68 64 63 bytes

M!s`"(\\.|[^"])*"?|'.|\d+|\S
ms`^'(.)|^"(([^\\"]|\\.)*$)
"$1$2"

or

s`\s*((")(\\.|[^"])*(?<-2>")?|'.|\d+|.)\s*
$1$2¶
\ms`^'(.)
"$1"

I think this covers all the funky edge cases, even those not covered by the test cases in the challenge.

Try it online!


Python 3.8, 55 54 bytes

Output is a list of characters.

lambda s,d=33:[chr((ord(c)-(d:=d-1))%95+32)for c in s]

Try it online!


Python 2 3, 255 204 180 178 bytes

This is answer is inaccurate by a day or two in several places, including for some of the test cases, though I was told that some inaccuracy was acceptable. At any rate, the motion of the moon is never very exact and this function remains generally correct (or at least, it doesn't vary too far).

Edit: In the course of correcting my code and making it more accurate, I have golfed it down considerably.

Edit: This code is now a one-line Python 3 program. (Credit to TimmyD for the name "magic numbers")

p,q,r=(int(i)for i in input().split("-"));t=q<3;y=p-2000-t;i,j=divmod(((r+(153*(q+12*t-3)+2)//5+365*y+y//4-y//100+y//400+11010)*86400-74100)%2551443,637861);print((86400<=j)+2*i)

Ungolfed:

def jul(p,q,r):
    '''
    The Julian Day Number (JDN) of the input minus the JDN of January 7, 1970,
    the first new moon after January 1, 1970.
    '''
    t=q<3
    y=p-2000-t  # -2000 years to push day 0 to January 1, 2000
    return r+(153*(q+12*t-3)+2)//5+365*y+y//4-y//100+y//400+11010
    # +11010 days to push day 0 to January 7, 1970

def moon(s):
    '''
    Input format: yyyy-mm-dd

    An attempt at explaining the "magic numbers"
    - 29.53059 days is close to 2551443 seconds, so I used that
    - The offset of +12300 seconds because the new moon of 1970-01-07 was at 2035 UTC
      or 12300 seconds before midnight. For those of you saying that this pushes
      the beginning of my calendar to 2035, *6* January 1970, yes it does.
      But if I need to the calendar to recognize 1970-01-07 as the day of the new moon
      which means that midnight needed to be a positive number of seconds, 0 <= x < 86400.
      Basically, I hacked it together, and +12300 worked.
    '''
    d = 86400
    p,q,r = map(int, s.split("-"))
    z=(jul(p,q,r)*d+12300)%2551443  # 2551443 is about the number of seconds in a lunar month
    div, mod = divmod(z, 637861)    # 637861 seconds is about a quarter of a lunar month
                                    # div is what part of the lunar month this is (0 - 3)
                                    # mod is seconds since the start of the main phase
    return 2*div + (86400 <= mod)   # 2*div for the main phase, and
                                    # is mod >= the number seconds in a day?
                                    # (+0 if within a day of the main phase, +1 otherwise)


Jelly, 21 bytes

Takes input as a list of two strings. Returns 0 for dissonant or 1 for consonant.

OḢ6×%21_Lµ€IA“¬ɠṘ’æ»Ḃ

Try it online!

OḢ6×%21_Lµ€IA“¬ɠṘ’æ»Ḃ   - main link
         µ€             - for each note             e.g. ["A#", "C"]
O                       -   convert to ASCII codes  -->  [[65, 35], 67]
 Ḣ                      -   keep the first element  -->  [65, 67]
  6×                    -   multiply by 6           -->  [390, 402]
    %21                 -   modulo 21               -->  [12, 3]
       _L               -   subtract the length     -->  [12, 3] - [2, 1] = [10, 2]
           IA           - absolute difference       -->  8
             “¬ɠṘ’      - the integer 540205
                  æ»    - right-shift               -->  540205 >> 8 = 2110
                    Ḃ   - isolate the LSB           -->  2110 & 1 = 0

Making-of

We first should note that the function F that we're looking for is commutative: for any pair of notes (A, B), we have F(A, B) = F(B, A).

Since there are not too many possible inputs and only 2 possible outputs to deal with, it must be possible to find a rather simple hash function H, such that |H(A) - H(B)| produces a limited range of values and is collision-free for all possible pairs of notes (A, B) with respect to the expected output.

We're going to test the set of functions H(mul, mod), which are defined as:

H(mul, mod)(s) = ((ORD(s[0]) * mul) MOD mod) - LEN(s)

Where ORD(s[0]) is the ASCII code of the first character of the note and LEN(s) is the length of the note (2 if there's a '#' and 1 if not).

Below is a commented version of the JS code that was used to find a couple of valid pairs (mul, mod) and the resulting bitmasks. There are many possible solutions, but * 6 % 21 is the shortest one with this method.

// all 12 notes
note = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'];

// reference implementation that takes 2 notes
// and returns 0 for dissonant or 1 for consonant
F = (a, b) =>
  +!~[1, 2, 6, 10, 11].indexOf((note.indexOf(a) - note.indexOf(b) + 12) % 12)

for(mul = 1; mul < 100; mul++) {
  for(mod = 1; mod < 31; mod++) {
    // hash function
    H = s => s.charCodeAt() * mul % mod - s.length;

    table = {};

    // for all possible pairs of notes (a, b)
    if(note.every(a => note.every(b => {
      // compute the table index
      idx = Math.abs(H(a) - H(b));

      // and the expected result
      res = F(a, b);

      // if the slot is empty, store the correct value
      if(table[idx] === undefined) {
        table[idx] = res;
        return 1;
      }
      // else, make sure that the correct value is already there
      return table[idx] == res;
    }))) {
      // if all tests pass: translate the table into a binary mask
      for(n = 0, msk = 0; n < 31; n++) {
        msk |= (table[n] || 0) << n;
      }
      // and display the result
      console.log('mul ' + mul + ', mod ' + mod + ' --> ' + msk);
    }
  }
}


F̲o̲r̲m̲a̲t̲t̲e̲r̲ (*Unicode* **Markdown** __Formatter__)

Stax, 75 73 74 70 bytes

Ç╜ÿPÜV►♀b7╛i┴?τ\⌂:Té√╖■♠(µ`ómƒÜKx▬∙═τ½εxÅr∩!E#î⌡╕B┴zäÅéë┘S²↔óh₧≡6ÿ╖iô├

Run and debug it online

The basic approach is store the 4 types of formatting in a bit field, and then get the correct character offset from a lookup using the integer value.  Only 8 values are in the lookup.  The high bit denoting underline is handled separately.

Here's a commented ungolfed version.

m                       Map mode: for each line of input,
                            run the rest of the program, then output
"\*\*|__|."|F           Find all regex matches using pattern. This splits the string into
                            individual characters except for ** and __, which stay together.
                            These will be called "atoms" of the input.
{                       begin a block
  VAVa+                 Construct "ABC..XYZabc..xyz"
  "_*``_****__"_I       Get the index of the current atom in "_*`_****__"
  0|MY                  Take the maximum with zero, then store in register y.
                            This gives {*: 1, `: 2, **: 4, __: 8} and 0 for all else.
  x|^X                  Xor with the x register and write back. It stores bitflags for 4 modes.
  "&6mU*9*9 0E*9 !"!@   Index into codepoint lookup table using x.
  c52+|r                Build range of 52 consecutive values starting at codepoint.
  \$                    Build translation string by combination with the alphabetic string.
  |t                    Perform translation on the current atom.
  818+                  Add codepoint 818 to the current atom.
  x8<T                  Remove it again if x<8.  This is iff underline mode is off.
  y!*                   Multiply by the logical not of y.  If the atom is for formatting,
                        this eliminates output for this atom
m                       map over atoms using the enclosed block

Run this one


Oneliner to merge lines with same first field

Retina, 17 bytes

12 bytes saved thanks to @MartinEnder
1 byte saved thanks to @jimmy23013

Scored in ISO 8859-1 encoded bytes.
Uses ; instead of | as the input field separator.
(?<=(.+;).+)¶\1
%

Try it online.


Python 2, 23 bytes

lambda n:~n/2+n%2*(n|2)

Odd inputs give roughly n/2, even ones roughly -n/2. So, I started with -n/2+n%2*n and tweaked from there.

Try it online!


Python 3, 61 bytes

rant="partisn't"
print(("HHeelllloo,,  WWoorrlldd!!"""[::2]))

Try it online!

Abusing the fact that print is a function in Python 3 :)

The least partisan solution you'll find here on PPCG.

Becomes

rn=print
rn("Hello, World!"[:])


Haskell, Laikoni

((show.(*1).read.reverse.show.(^2)=<<[1..])!!)

Try it online!

The (*1) was necessary  for type checking.


Shell script: 64 51 characters
curl -sL http://stackoverflow.com/users/`cat`|grep -oPm2 'n">\K[0-9,]+|e">\K[^<]+'

Sample run:
bash-4.1$ curl -sL http://stackoverflow.com/users/`cat`|grep -oPm2 'n">\K[0-9,]+|e">\K[^<]+'
662504
manatwork
834

bash-4.1$ curl -sL http://stackoverflow.com/users/`cat`|grep -oPm2 'n">\K[0-9,]+|e">\K[^<]+'
764357
Lego Stormtroopr
3,087

(Note that you have to press ^D after typing in the input interactively. Or just pipe it to the command.)


Retina, 26 bytes (sets 4, 5)

[^u]es|ee|m.i|y|^...c|d.*a

Retina is @MartinBüttner's regex language. I haven't used anything specific to .NET regexes, so you can test the regex at Regex101 here. Alternatively you can use Retina's grep G mode like so:

G`[^u]es|ee|m.i|y|^...c|d.*a

and pipe in a file with one word per line for batch testing.

Retina outputs the number of matches by default, giving us our truthy/falsy value. The rule "the values don't all have to be the same truthy/falsy type" is pretty important though since marchioness matches twice, giving an output of 2.

(Using the mod-chaining method from the previous male/female question seems to be shorter in CJam, but I'll let someone else do that)


Calculate a pi-based sequence with a pi-based frequence

Mathematica, 253 bytes

f=(For[i=0;j=1,j<=#,j+=Mod[RealDigits[9801/Sqrt@8/Sum[(4j)!(1103+26390j)/(j!)^4/396^(4j),{j,0,125}],10,999][[1,j]]-1,10]+1;++i];"99iiiitS===oooo8862^^^^^^\uusRRRRRRqqqqqqqqMMMMmlllllllgggggggFFFeeeeeeeeDDDDDDaaaaa55555555<<{{\{{{{{{}}}}}}}}--@@@@@@";i)&

Ungolfed:

f = (
   For[i = 0; j = 1, j <= #,
    j += Mod[
       RealDigits[
          9801/Sqrt@8/
           Sum[(4 j)! (1103 + 26390 j)/(j!)^4/396^(4 j), {j, 0, 125}],
           10, 999][[1, j]] - 1, 10] + 1; ++i];
   "99iiiitS===oooo8862^^^^^^uusRRRRRRqqqqqqqqMMMMmlllllllgggggggFFFeeeeeeeeDDDDDDaaaaa55555555<<{{{{{{{{}}}}}}}}--@@@@@@";
   i
   ) &

Usage is f[999].

A whopping 122 bytes are used to pad the code with a useless string to get the right character frequencies. I'll try to improve that tomorrow.

The character frequencies should match the digits of pi in this order:

3#/&(,![)4+9j0it"S=;]ro862^usRqM1mlgFfeDda5<{}-@

I confirmed that there is some correct order with the following snippet:

Sort[Last /@
   Tally[Characters@
     "f=(For[i=0;j=1,j<=#,j+=Mod[RealDigits[9801/Sqrt@8/Sum[(4j)!(\
1103+26390j)/(j!)^4/396^(4j),{j,0,125}],10,999][[1,j]]-1,10]+1;++i];\"\
99iiiitS===oooo8862^^^^^^\
uusRRRRRRqqqqqqqqMMMMmlllllllgggggggFFFeeeeeeeeDDDDDDaaaaa55555555<<{{\
{{{{{{}}}}}}}}--@@@@@@\";i)&"]] ==
 Sort[RealDigits[Pi, 10, 48][[1]] /. 0 -> 10]

I'm computing pi with Ramanujan's series. It converges to 1000 digits in 125 terms. Due to golfing reasons, I recompute the 999 necessary digits for every single digit of the subsequence, but it still completes within a second for n = 999 on my machine.


Squaring Off (fit to smallest possible square)

MATL, 12 9 bytes

Saved three bytes thanks to Luis. he instead of UGwewe, but adding a t in the beginning.

tnX^Xkthe

Try it online!

This returns the results, but transposed compared to the result in OPs post (which is OK).

Explanation:

This works the same way for both numeric and string input, as MATL treats them the same way.

Assume the input is 'Dyalog APL'

                % Implicit: Take string or numeric array as input
                % Stack: 'Dyalog APL'
t               % Duplicate
                % Stack: 'Dyalog APL'
                %        'Dyalog APL'
 n              % Number of elements in last element.
                % Stack: 'Dyalog APL'
                %        10
  X^            % Take the square root of the number of elements
                % Stack: 'Dyalog APL'
                % Stack: 3.16...
    Xk          % Ceil last number
                % Stack: 'Dyalog APL'
                %        4
      t         % Duplicate element
                % Stack: 'Dyalog APL'
                %        4
                %        4
       h        % Concatenate the last to elements horizontally
                % Stack: 'Dyalog APL'
                %        4  4
        e       % reshape into 4 rows, and 4 columns. Pads the input with zeros or spaces
                % if necessary.
                % Stack: (Note that there's a trailing column not shown below)
                %        DoP
                %        ygL
                %        a
                %        lA

This outputs nothing for empty input, which happens to be way MATL outputs empty matrices / strings.


Excel, 163 143 bytes
=LET(a,BASE(SEQUENCE(3^A1)-1,3,A1),b,FILTER(a,ISERROR(FIND(12,a))*ISERROR(FIND(21,a))),SUBSTITUTE(b,2,0)&"
"&SUBSTITUTE(SUBSTITUTE(b,1,0),2,1))

Use 1 for walls and 0 for empty cells.
Original
=LET(a,BASE(SEQUENCE(3^A1)-1,3,A1),b,FILTER(a,ISERROR(FIND(12,a))*ISERROR(FIND(21,a))),SUBSTITUTE(SUBSTITUTE(b,1,"X"),2,0)&"
"&SUBSTITUTE(SUBSTITUTE(b,2,"X"),1,0))

Uses 0 for empty cells and X for walls.
Link to Spreadsheet


GolfScript, 59 characters
[{;;[]`}:it{|`}:ll{-`}:ve{;$n*}:st];~"#{ARGV*' '}"' '%(-2>~

Implemented the first idea which came into my mind. The database format is simply a GolfScript array representation. Install/remove also handle the case when a program is already installed.
Explanation
# Define four functions for later use ([...]; simply removes them from the stack):
[
  {;;[]`}:it         # init -> discard arguments, discard db, create empty db
  {|`}:ll            # install -> add arguments to db (if not already there)
  {-`}:ve            # remove -> remove all arguments from db
  {;$n*}:st          # list -> discard arguments, sort, join with newline
];

~                    # Parse db given on STDIN
"#{ARGV*' '}"' '%    # Parse command line arguments into array
(-2>                 # Take first argument (command) and the last two chars from it
~                    # Execute that command (i.e. "it" for "init", ...)


Haskell, 67 61 bytes

f n=minimum$n:[f$div n d|d<-read.pure<$>show n,d>1,mod n d<1]

Try it online!
Explanation:

read.pure<$>show n transforms the input integer n into a list of digits.
For each digit d from this list, we check d>1 and mod n d<1, that is whether d divides n.
If the checks are successful, we divide n by d and recursively apply f: f$div n d.
Altogether, this yields a list of the minimal integers from all sub-trees of n.
As the list might be empty, we append n to it and return the minimum of the list.


Haskell, 35 bytes

x?y|isNaN$x/y=tanh x*tanh y|0<1=x/y

Try it online!
The relevant function is (?), which takes two Doubles as input and returns a Double as output.
How?
The hyperbolic tangent is an amazing function (two bytes shorter than signum!).

x
tanh x

0.0
0.0

-0.0
-0.0

Infinity
1.0

-Infinity
-1.0

Haskell, 30 29 bytes
x?y|x/y<=1/0=x/y|0<1=tanh$x*y

Try it online!
Using MarcMush's amazing trick, which relies on the well-known formula1
$$
\tanh(x\cdot y)=\tanh(x)\cdot\tanh(y).
$$

1 I know, I know, maths.


05AB1E, 10 7 bytes

Code:

Â'š×Â‡Q

Explanation:

To check if a string is a palindrome, we just need to check the input with the input, with at swapped and cg swapped and then reverse it. So that is what we are going to do. We push the input and the input reversed using Â (bifurcate). Now comes a tricky part. 'š× is the compressed version for creating. If we reverse it, you can see why it's in the code:

CreATinG
|  ||  |
GniTAerC

This will be used to transliterate the reversed input. Transliteration is done with ‡. After that, we just check if the input and the transliterated input are eQual and print that value. So this is how the stack looks like for input actg :

Â          # ["actg", "gtca"]
 'š×       # ["actg", "gtca", "creating"]
    Â      # ["actg", "gtca", "creating", "gnitaerc"]
     ‡     # ["actg", "cagt"]
      Q    # [0]

Which can also be seen with the debug flag (Try it here).

Uses CP-1252 encoding. Try it online!.


Remove a weight so the rest can't be balanced

CJam, 19 17
q~:T{T:^^2bW%}$W=

Input format:
[1 2 3 4 5 6 7 8 9]

2 bytes thanks to Optimizer.


05AB1E, 3 bytes

¢ÏP

Try it online!

¢       # count occurences of each number
 Ï      # keep only those where the count is 1
  P     # product (1 if the list is empty)


APL (Dyalog), 26 bytes

Thanks ngn for saving 1 byte :)

{⍵[⍋⌽↑,⍨⌿⍴⌿0 10⊤⍵⊤⍨⍴⍨100]}

Try it online!

Inspiration take from dzaima & ngn


JavaScript (ES6), 32 30 bytes

Saved 2 bytes thanks to @Shaggy

(w,h,x)=>Q=n=>--h?n+Q(n-x):n*w

Takes input in a curried format: f(W,H,x,y)(n)

let f =
(w,h,x)=>Q=n=>--h?n+Q(n-x):n*w;

console.log(
  f(3, 4, 9, 9)(32)
);

How?

First we note that the sum of the T starting at n with height H can be broken down into two sums:

n
The sum of the T starting one row higher with height H - 1

By repeatedly adding n to the total, moving one row up, and subtracting 1 from H until it reaches 1, we end up summing the vertical stem of the T. Moving one row up is accomplished by subtracting x from n, since it can be observed that the difference between any cell and the one above is x.

When H reaches 1, we now have only the crossbar of width W left to sum. At this point n represents the center of the crossbar. We could sum the crossbar recursively as we did with the stem, but instead we take advantage of a fairly simple formula:

sum(n - a : n + a) = (n - a) + (n - (a-1)) + ... + n + ... + (n + (a-1)) + (n + a)
                   = (n - a) + (n + a) + (n - (a-1)) + (n + (a-1)) + ... + n
                   = 2n + 2n + ... + n
                   = n * (2a + 1)

In this case, our a is (W - 1) / 2, which makes

n * (2a + 1) = n * (((W - 1) / 2) * 2 + 1)
             = n * ((W - 1) + 1)
             = n * W

which is the sum of the crossbar.


What's the second non-repeating character?

MATL, 11 bytes
tk&=s1=)FT)

This exits with an error (allowed by default) if there is no second non-repeated character.
Try it online!
Explanation
t      % Implicitly take input string. Duplicate
k      % Convert to lowercase
&=     % 2D array of equality comparisons
s      % Sum of each column
1=     % True for entries that equal 1
)      % Apply logical index to the input string to keep non-repeated characters
TF)    % Apply logical index to take 2nd element if it exists. Implicitly display


Python 2, 56 bytes

f=lambda h,*t:t and"(.5?.5)*(%s+%%s)+"%f(*t)%-h+`h`or`h`

Try it online!

The ? stands for ±. Example usage:

f(-3,5,20) ->
(.5?.5)*((.5?.5)*(20+-5)+5+3)+-3

The idea is that we can take an expression E and adjoin a new value h to its set of values by doing (.5±.5)*(E+-h)+h.


Smallest number you can get by adding up numbers in sequence

Python - 104 99

My interpretation:

L=map(int,input().split())
k=1
while k in map(sum,[[i,j]for i in L for j in L if i<j]):k+=1
print k

I tested it with the input string 0 1 2 3 4 8 11 19 33 59 154 196 260 containing a 0 to avoid the trivial solution 0.

Result:

16


Code Golf: Forwards sdrawkcaB sdrawkcaB Forwards Forwards sdrawkcaB

TeaScript, 55 bytes 58 60 69 76 78 80 87 89

xO`a-z `?xl(#~-i&2?l:lv(),/ +/):Ld`SÀZn Û § «e Ò5s`

This is extremely short, I'm very happy with it.

The last ~20 characters may seem like gibberish but that's "Sentence must only use letters" encoded. All the characters have char codes below 256 so each are one byte

Explanation

xO`a-z `?  // If input contains only a-z and space...

   xl(#       // Loop through input
      ~-i&2?  // If (index - 1 "unary and"ed with 2) isn't 0...
          :l,     // Leave alone
          lv()    // Otherwise, reverse string
       / +/ // Loops on spaces
   )

:Ld`SÀZn Û § «e Ò5s` // Otherwise... decompress and print  the error string

Try it online
Pastebin


Hexagony, 271 bytes

I present to you, the first 3% of a Hexagony self-interpreter...

|./...\..._..>}{<$}=<;>'<..../;<_'\{*46\..8._~;/;{{;<..|M..'{.>{{=.<.).|.."~....._.>(=</.\=\'$/}{<}.\../>../..._>../_....@/{$|....>...</..~\.>,<$/'";{}({/>-'(<\=&\><${~-"~<$)<....'.>=&'*){=&')&}\'\'2"'23}}_}&<_3.>.'*)'-<>{=/{\*={(&)'){\$<....={\>}}}\&32'-<=._.)}=)+'_+'&<

Try it online! You can also run it on itself, but it will take about 5-10 seconds.

In principle this might fit into side-length 9 (for a score of 217 or less), because this uses only 201 commands, and the ungolfed version I wrote first (on side-length 30) needed only 178 commands. However, I'm pretty sure it would take forever to actually make everything fit, so I'm not sure whether I'll actually attempt it.

It should also be possible to golf this a bit in size 10 by avoiding the use of the last one or two rows, such that the trailing no-ops can be omitted, but that would require a substantial rewrite, as one of the first path joins makes use of the bottom left corner.

Explanation

Let's start by unfolding the code and annotating the control flow paths:

That's still quite messy, so here is the same diagram for the "ungolfed" code which I wrote first (in fact, this is side-length 20 and originally I wrote the code on side-length 30 but that was so sparse that it wouldn't improve the readability at all, so I compacted it just a little bit to make the size a bit more reasonable):

Click for larger version.

The colours are exactly the same apart from a few very minor details, the non-control-flow commands are also exactly the same. So I'll be explaining how this works based on the ungolfed version, and if you really want to know how the golfed one works, you can check which parts there correspond to which in the larger hexagon. (The only catch is that the golfed code starts with a mirror so that the actual code begins in the right corner going left.)

The basic algorithm is almost identical to my CJam answer. There are two differences:

Instead of solving the centred hexagonal number equation, I just compute consecutive centred hexagonal numbers until one is equal to or larger than the length of the input. This is because Hexagony does not have a simple way to compute a square root.
Instead of padding the input with no-ops right away, I check later if I've already exhausted the commands in the input and print a . instead if I have.

That means the basic idea boils down to:

Read and store input string while computing its length.
Find the smallest side-length N (and corresponding centred hexagonal number hex(N)) which can hold the entire input.
Compute the diameter 2N-1.
For each line, compute the indent and the number of cells (which sum to 2N-1). Print the indent, print the cells (using . if the input is already exhausted), print a linefeed.

Note that there are only no-ops so the actual code starts in the left corner (the $, which jumps over the >, so the we really start on the , in the dark grey path).

Here is the initial memory grid:

So the memory pointer starts out on edge labelled input, pointing North. , reads a byte from STDIN or a -1 if we've hit EOF into that edge. Hence, the < right after is a conditional for whether we've read all the input. Let's remain in the input loop for now. The next code we execute is

{&32'-

This writes a 32 into the edge labelled space, and then subtracts it from the input value in the edge labelled diff. Note that this can never be negative because we're guaranteed that the input contains only printable ASCII. It will be zero when the input was a space. (As Timwi points out, this would still work if the input could contain linefeeds or tabs, but it would also strip out all other unprintable characters with character codes less than 32.) In that case, the < deflects the instruction pointer (IP) left and the light grey path is taken. That path simply resets the position of the MP with {= and then reads the next character - thus, spaces are skipped. Otherwise, if the character was not a space, we execute

=}}})&'+'+)=}

This first moves around the hexagon through the length edge until its opposite the diff edge, with =}}}. Then it copies the value from opposite the length edge into the length edge, and increments it with )&'+'+). We'll see in a second why this makes sense. Finally, we move the a new edge with =}:

(The particular edge values are from the last test case given in the challenge.) At this point, the loop repeats, but with everything shifted one hexagon northeast. So after reading another character, we get this:

Now you can see that we're gradually writing the input (minus spaces) along the northeast diagonal, with the characters on every other edge, and the length up to that character being stored parallel to the edge labelled length.

When we're done with the input loop, memory will look like this (where I've already labelled a few new edges for the next part):

The % is the last character we read, the 29 is the number of non-space characters we read. Now we want to find the side-length of the hexagon. First, there is some linear initialisation code in the dark green/grey path:

=&''3{

Here, =& copies the length (29 in our example) into the edge labelled length. Then ''3 moves to the edge labelled 3 and sets its value to 3 (which we just need as a constant in the computation). Finally { moves to the edge labelled N(N-1).

Now we enter the blue loop. This loop increments N (stored in the cell labelled N) then computes its centered hexagonal number and subtracts it from the input length. The linear code which does that is:

{)')&({=*'*)'-

Here, {) moves to and increments N. ')&( moves to edge labelled N-1, copies N there and decrements it. {=* computes their product in N(N-1). '*) multiplies that by the constant 3 and increments the result in the edge labelled hex(N). As expected, this is the Nth centered hexagonal number. Finally '- computes the difference between that and the input length. If the result is positive, the side-length is not large enough yet, and the loop repeats (where }} move the MP back to the edge labelled N(N-1)).

Once the side-length is large enough, the difference will be zero or negative and we get this:

First off, there is now the really long linear green path which does some necessary initialisation for the output loop:

{=&}}}32'"2'=&'*){=&')&}}

The {=& starts by copying the result in the diff edge into the length edge, because we later need something non-positive there. }}}32 writes a 32 into the edge labelled space. '"2 writes a constant 2 into the unlabelled edge above diff. '=& copies N-1 into the second edge with the same label. '*) multiplies it by 2 and increments it so that we get the correct value in the edge labelled 2N-1 at the top. This is the diameter of the hexagon. {=&')& copies the diameter into the other edge labelled 2N-1. Finally }} moves back to the edge labelled 2N-1 at the top.

Let's relabel the edges:

The edge we're currently on (which still holds the diameter of the hexagon) will be used to iterate over the lines of the output. The edge labelled indent will compute how many spaces are needed on the current line. The edge labelled cells will be used to iterate over the number of cells in the current line.

We're now on the pink path which computes indent. ('- decrements the lines iterator and subtracts it from N-1 (into the indent edge). The short blue/grey branch in the code simply computes the modulus of the result (~ negates the value if it's negative or zero, and nothing happens if it's positive). The rest of the pink path is "-~{ which subtracts the indent from the diameter into the cells edge and then moves back to the indent edge.

The dirty yellow path now prints the indentation. The loop contents are really just

'";{}(

Where '" moves to the space edge, ; prints it, {} moves back to indent and ( decrements it.

When we're done with that the (second) dark grey path searches for next character to print. The =} moves in position (which means, onto the cells edge, pointing South). Then we have a very tight loop of {} which simply moves down two edges in the South-West direction, until we hit the end of the stored string:

Notice that I've relabelled one edge there EOF?. Once we've processed this character, we'll make that edge negative, so that the {} loop will terminate here instead of the next iteration:

In the code, we're at the end of the dark grey path, where ' moves back one step onto the input character. If the situation is one of the last two diagrams (i.e. there's still a character from the input we haven't printed yet), then we're taking the green path (the bottom one, for people who aren't good with green and blue). That one is fairly simple: ; prints the character itself. ' moves to the corresponding space edge which still holds a 32 from earlier and ; prints that space. Then {~ makes our EOF? negative for the next iteration, ' moves a back a step so that we can return to the North-West end of the string with another tight }{ loop. Which ends on the length cell (the non-positive one below hex(N). Finally } moves back to the cells edge.

If we've already exhausted the input though, then the loop which searches for EOF? will actually terminate here:

In that case ' moves onto the length cell, and we're taking the light blue (top) path instead, which prints a no-op. The code in this branch is linear:

{*46;{{;{{=

The {*46; writes a 46 into the edge labelled no-op and prints it (i.e. a period). Then {{; moves to the space edge and prints that. The {{= moves back to the cells edge for the next iteration.

At this point the paths join back together and ( decrements the cells edge. If the iterator is not zero yet, we will take the light grey path, which simply reverses the MP's direction with = and then goes looking for the next character to print.

Otherwise, we've reached the end of the current line, and the IP will take the purple path instead. This is what the memory grid looks like at that point:

The purple path contains this:

=M8;~'"=

The = reverses the direction of the MP again. M8 sets the sets its value to 778 (because the character code of M is 77 and digits will append themselves to the current value). This happens to be 10 (mod 256), so when we print it with ;, we get a linefeed. Then ~ makes the edge negative again, '" moves back to the lines edge and = reverses the MP once more.

Now if the lines edge is zero, we're done. The IP will take the (very short) red path, where @ terminates the program. Otherwise, we continue on the purple path which loops back into the pink one, to print another line.

Control flow diagrams created with Timwi's HexagonyColorer. Memory diagrams created with the visual debugger in his Esoteric IDE.


Shortest code to produce infinite non-periodic output

Python 2, 23 bytes

while 1:print id;id=id,

Try it online!

Prints

<built-in function id>
(<built-in function id>,)
((<built-in function id>,),)
(((<built-in function id>,),),)
((((<built-in function id>,),),),)

and so on. Starts with the built-in function id, the shortest pre-initialized variable name, and repeatedly turns it into a tuple of itself.

In Python 3, this solution is one byte longer because of print(), but the byte can be recovered from print outputting None:

while 1:id=print(id),id

or

while[print(id)]:id=id,


Python 3, O(h × w × d) 296 bytes, O(h × w × d')

def f(a):
 w=0;b=[len(a[0])*[0]];a=b+a+b;a=[[0]+x+[0]for x in a];b=sorted(set(sum(a,[])))
 for[i,j]in zip(b,b[1:]+[1+max(b)]):
  c=[[0,0]]
  while c:
   [x,y]=c.pop()
   if x<len(a)and x>=0and y<len(a[0])and y>=0and a[x][y]<=i:w+=i-a[x][y];a[x][y]=j;c+=[[x+1,y],[x,y+1],[x-1,y],[x,y-1]]
 return w

Try it online! Where d' represents the number of distinct values in the input. Edit: Saved 3 bytes thanks to @Mr.Xcoder.


Addition-Subtraction of Numbers Within String

Jelly, 17 15 12 bytes

fØDV€ḂT‘ịƲSḤ

Try it online!

Try test cases.

The program keeps only the digits that follow an odd digit then computes twice the sum.

fØDV€ḂT‘ịƲSḤ
f                   Remove anything that isn't...
 ØD                 a digit.
   V€               Cast each digit to an integer
         Ʋ          Monad:
     Ḃ              Parity of each digit.
      T             Indices of truthy elements (odd digits).
       ‘            Increment.
        ị           Index into list of digits.
                    Wraps to beginning and if there are no digits this returns 0.
          S         Sum.
           Ḥ        Double.


Python 2, 43 bytes

Takes as input the target integer \$a\$, and a lambda function \$g\$. Since the list is always either strictly increasing or decreasing, we only need to check if \$a\$ appears in the next \$ |a-g(0)|+1 \$ numbers.

lambda a,g:a in map(g,range(abs(a-g(0))+1))

Try it online!


Bash + grep + lynx, 38
Since we can open a web browser, then I will use lynx:
lynx -dump $1|grep -Po '(?<=d:)[^&]+'

(Thanks to @manatwork for grep usage instead of sed)
We pass in the whole URL in as a parameter:
$ ./gr.sh "www.google.com/search?q=stackexchange&ie=utf-8&oe=utf-8"
http://stackexchange.com/
https://en.wikipedia.org/wiki/Stack_Exchange
https://twitter.com/stackexchange
https://play.google.com/store/apps/details?id=com.stackexchange.marvin
https://github.com/StackExchange/StackExchange.Redis
https://github.com/StackExchange/StackExchange.Redis/blob/master/Docs/Basics.md
https://www.crunchbase.com/organization/stack-exchange
$

Which gives the same list as:


Print the amount of ones in a binary number without using bitwise operators

APL, 9 12 characters
+/2|⌊⎕÷2*⍳32

This assumes that the interpreter uses 32-bit integers, and that ⎕IO is set to 0 (meaning that monadic ⍳ begins with 0, rather than 1). I used the 32-bit version of Dyalog APL.
Explanation, from right to left:

⍳32 generates a vector of the first 32 integers (as explained before, because ⎕IO is 0, this vector begins with 0).
* is the power function. In this case, it generates 2 to the power of each element of the vector supplied as its right argument.
÷ is the divided-by function. It gives us ⎕ (evaluated user input) divided by each element of the vector to its right (each power of two).
⌊ floors each element of the argument to its right.
2| gives us the remainder of each element of to its right divided by 2.
/ reduces (folds) its right argument using the function to its left, +.

Not quite 9 characters anymore. :(
Old, rule-breaking version:

+/⎕⊤⍨32/2

Explanation, from right to left:

32/2: Replicate 2, 32 times.
⍨ commutes the dyadic function to its left, which in this case is ⊤ (i.e., X⊤⍨Y is equivalent to Y⊤X).
⊤ is the encode function. It encodes the integer to its right in the base given to its left. Note that, because of the commute operator, the right and left arguments are switched. The base is repeated for the number of digits required, hence 32/2.
⎕ is a niladic function that accepts user input and evaluates it.
+/ reduces (folds) its right argument using +. (We add up the 0's and 1's.)


Python 2, 445 400 bytes
I'm a fan of Settlers, so this challenge was fun.
T="^"
Z=26
A=T*52
for i in range(11):A+=(T*(i%2)*3).join(x for x in raw_input()).center(Z,T)
A+=T*52
def f(c,p=0,l=0,B=A):
 b=l;C=B[0:p]+T+B[p+1:];n=(Z,1)[p%2]
 for i in(p<1)*range(390):
    if(i/Z%2<1&i%2>0)|(i/Z%2>0&i%2<1):b=max(b,f(c,i))
 for i in(p-n,p+n)*(B[p]==c):
    for j in(i-Z,i-1,i+1,i+Z)*(B[i]in c+"_"):b=max(b,f(c,j,l+1,C))
 return b
i=l=0
for x in A:
 if x<T:i=f(x)
 if i>l:c=x;l=i
print c,l

Score reflects replacing each occurrence of 4 spaces with a tab.
Explanation
The lines before the function definition read the input, and build a normalized board into a single string variable.  The process inserts "^" characters into the short lines representing the vertical road segments.  It also pads the board with "^" characters.
^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^________RR_R_^^^^^^^
^^^^^^_^^^_^^^R^^^_^^^^^^^
^^^^__RR_R_RRR_____R_^^^^^
^^^^B^^^_^^^_^^^_^^^R^^^^^
^^_B_________B__OO_OOR_^^^
^^B^^^_^^^_^^^B^^^_^^^R^^^
^^BB_BBB_____B____RR_R_^^^
^^^^O^^^B^^^B^^^_^^^O^^^^^
^^^^OO__BB_BB__OOO_OO^^^^^
^^^^^^O^^^_^^^O^^^_^^^^^^^
^^^^^^_O_OOO_O_____^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^

When called with the default parameters, the function returns the length of a road of a given color.  The first loop is active only when the position (p) parameter was supplied.  It recursively finds the length of the road at each valid road position, and keeps track of the longest one.  When there is a road at the position parameter, the function recursively adds the length of adjacent roads of the same color.  The road is replaced with a "~" in the working copy of the board to ensure it doesn't recount segments that have already been counted.
The code following the function definition calls the function for each color in the board, and prints the highest scoring color and length.
Demo it here


Jelly, 9 bytes

Credits to Erik the Outgolfer.

Œċ*3S€ċ>1

Try it online!

This is too slow that it won't even work for 1729 online.

Much faster, 12 bytes

Credits to Dennis.

R*3fRŒċS€ċ>1

Try it online!


Mathematica, 8 bytes

Im[I^#]&

Explanation

Im[I^#]&
   I^#    (* Raise the imaginary unit to the input power *)
Im[   ]   (* Take the imaginary part *)


JavaScript (ES6) + HTML, 114 + 16 = 130 bytes

Saved 16 bytes thanks to @Shaggy

a=Array(96).fill` `;onkeypress=k=>(a[k.key.charCodeAt()-32]=k.key,O.innerText=a.join` `.match(/.{1,32}/g).join`
`)

It's so unbelievably satisfying to just mash the keyboard...


Shortest way to generate 12 repeated characters in JavaScript

Unfortunately, after what seems an eternity of searching documentation, I can't seem find any solution that will work with the 12-character constraint and generate for any given character given. However, there are a few neat tricks one can do to save some bytes for specific cases:

1eL-1+'' will give a string, filled with 9s, of L length.

''.padEnd(L) will give a string, filled with spaces, of L length. It's only useful when L > 10, otherwise it's too long. This one can be immediately chained with a function.

N/9+'' will give a string, starting with 0. then followed by a bunch of Ns. This does not work when N < 1 or N > 8, and the result obviously does not contain the same characters the whole way, but pretty close and pretty short.

Array(L)+'' will give a string, filled with commas, of length L - 1.