1275 words by simple greedy hill-climbing

Code is C#. Solution produced is

Score 1275 from ^[bcdfgmpstw][aehiloprtu][aeilnorstu][acdeklnrst][adehklrsty]$

I'm using that output format because it's really easy to test:

grep -iE "^[bcdfgmpstw][aehiloprtu][aeilnorstu][acdeklnrst][adehklrsty]$" linuxwords.txt | wc

namespace Sandbox {
    class Launcher {
        public static void Main(string[] args)
        {
            string[] lines = _Read5s();
            int[][] asMasks = lines.Select(line => line.ToCharArray().Select(ch => 1 << (ch - 'a')).ToArray()).ToArray();
            Console.WriteLine(string.Format("{0} words found", lines.Length));

            // Don't even bother starting with a good mapping.
            int[] combos = _AllCombinations().ToArray();
            int[] best = new int[]{0x3ff, 0x3ff, 0x3ff, 0x3ff, 0x3ff};
            int bestSc = 0;
            while (true)
            {
                Console.WriteLine(string.Format("Score {0} from {1}", bestSc, _DialsToString(best)));

                int[] prevBest = best;
                int prevBestSc = bestSc;

                // Greedy hill-climbing approach
                for (int off = 0; off < 5; off++)
                {
                    int[] dials = (int[])prevBest.Clone();

                    dials[off] = (1 << 26) - 1;
                    int[][] filtered = asMasks.Where(mask => _Permitted(dials, mask)).ToArray();
                    int sc;
                    dials[off] = _TopTen(filtered, off, out sc);
                    if (sc > bestSc)
                    {
                        best = (int[])dials.Clone();
                        bestSc = sc;
                    }
                }

                if (bestSc == prevBestSc) break;
            }

            Console.WriteLine("Done");
            Console.ReadKey();
        }

        private static int _TopTen(int[][] masks, int off, out int sc)
        {
            IDictionary<int, int> scores = new Dictionary<int, int>();
            for (int k = 0; k < 26; k++) scores[1 << k] = 0;

            foreach (int[] mask in masks) scores[mask[off]]++;

            int rv = 0;
            sc = 0;
            foreach (KeyValuePair<int, int> kvp in scores.OrderByDescending(kvp => kvp.Value).Take(10))
            {
                rv |= kvp.Key;
                sc += kvp.Value;
            }
            return rv;
        }

        private static string _DialsToString(int[] dials)
        {
            StringBuilder sb = new StringBuilder("^");
            foreach (int dial in dials)
            {
                sb.Append('[');
                for (int i = 0; i < 26; i++)
                {
                    if ((dial & (1 << i)) != 0) sb.Append((char)('a' + i));
                }
                sb.Append(']');
            }
            sb.Append('$');
            return sb.ToString();
        }

        private static IEnumerable<int> _AllCombinations()
        {
            // \binom{26}{10}
            int set = (1 << 10) - 1;
            int limit = (1 << 26);
            while (set < limit)
            {
                yield return set;

                // Gosper's hack:
                int c = set & -set;
                int r = set + c;
                set = (((r ^ set) >> 2) / c) | r;
            }
        }

        private static bool _Permitted(int[] dials, int[] mask)
        {
            for (int i = 0; i < dials.Length; i++)
            {
                if ((dials[i] & mask[i]) == 0) return false;
            }
            return true;
        }

        private static string[] _Read5s()
        {
            System.Text.RegularExpressions.Regex word5 = new System.Text.RegularExpressions.Regex("^[a-z][a-z][a-z][a-z][a-z]$", System.Text.RegularExpressions.RegexOptions.Compiled);
            return File.ReadAllLines(@"d:\tmp\linuxwords.txt").Select(line => line.ToLowerInvariant()).Where(line => word5.IsMatch(line)).ToArray();
        }
    }
}


Charcoal, 86 69 bytes
ＷＳ⊞υι≔⪫υ¶θ≔v>^<ηＰθ…θ⌈Ｅη⌕θιＷ№ηＫＫ«↶⊗⁺³⌕ηＫＫ≔ⅈι ≔§⪪\-//|\³⁻ⅈιη»≔⌈ＫＡθ⎚→‹θ!

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - if all the dominoes fall, nothing if some remain. Explanation:
ＷＳ⊞υι≔⪫υ¶θ

Input the table as an array of strings and join them together.
≔v>^<η

Make a string of rotations for the starting domino characters. The string starts with the character for a clockwise rotation, then the one for no rotation, then an anticlockwise rotation, then a u-turn.
Ｐθ…θ⌈Ｅη⌕θι

Print the table and then up until the (last) occurrence of one the starting domino characters.
Ｗ№ηＫＫ«

While the current character is present in the table of rotations...
↶⊗⁺³⌕ηＫＫ

... pivot according to the position of the character in the table of rotations (annoyingly I have to spend an extra byte adding 3 instead of subtracting 1 because Charcoal can't pivot by negative amounts)...
≔ⅈι ≔§⪪\-//|\³⁻ⅈιη

... and, temporarily saving the current X-coordinate, erase the current character, moving in the current direction, then choose the list of valid characters (again listed in the order rotate clockwise, don't rotate, rotate anticlockwise) depending on whether the current direction is vertical or horizontal (detected via the change in X-coordinate, since Charcoal has no builtin to read the current direction).
»≔⌈ＫＡθ⎚→‹θ!

Check that only spaces are left.


05AB1E, 23 21 bytes
This is my first 05AB1E program (In fact this is my first golfing using golfing language), so please, if you have any notes, tips or improvements - I would love to get some in the comments section.
Program:
`rs/î©\õ.gGs«N®%0Qi¶«}}

Explaination:
`rs/î©\õ.gGs«N®%0Qi¶«}}
`                             Push each element of the input to the stack
 r                            Reverse the stack
  s                           Swap the first two values in stack (which are the numbers)
   /                          Division between both numbers in order to get the number of words in each line
    î                         Round up
     ©                        Store that value in the register
      \                       Remove that number from the stack (remove head)
       õ                      Push empty string to pass over the first iteration
        .g                    Push the length of the stack (which is the number of words)
          G            }      Loop from 1 to The length of the stack
           s                  Swap the two words in the head of the stack
            «                 Concatenate
             N                Push counter_variable
              ®               Push the number we saved in the register (number of words per line)
               %              Modulo (To check if we need to concatenate a newline)
                0Q            Equals zero
                  i  }        If true
                   ¶          Push newline
                    «         Concatenate

Try it online!
Saving 2 bytes with the help of @KevinCruijssen:
`rs/îUõ.gGs«NX%_i¶«}}

Try it online!


APL  45  41
{⍺←1⋄2≤+/,⍺=(v∘.≤v)×∘.+⍨⍵*⍨v←⍳⌊⍺*.5:⍺⋄⍵∇⍨⍺+1}

Shorter but slower version of 41 chars:
{⍺←1⋄2≤+/,⍺=(v∘.≤v)×∘.+⍨⍵*⍨v←⍳⍺:⍺⋄⍵∇⍨⍺+1}

You can try it online, just paste the function and invoke it with a number:
      {⍺←1⋄2≤+/,⍺=(v∘.≤v)×∘.+⍨⍵*⍨v←⍳⌊⍺*.5:⍺⋄⍵∇⍨⍺+1} 2
50
      {⍺←1⋄2≤+/,⍺=(v∘.≤v)×∘.+⍨⍵*⍨v←⍳⌊⍺*.5:⍺⋄⍵∇⍨⍺+1} 3
1729

(The algorithm is quite dumb though, don't expect the online interpreter to compute n=4)
The answer for n=2 is 50 = 5² + 5² = 7² + 1² because its a number that "can be expressed as the sum of two squares of positive integers—doesn't say different—in two ways."
If you want to add the distinct clause, just change (v∘.≤v) into (v∘.<v), same number of chars, and n=2 becomes 65:
      {⍺←1⋄2≤+/,⍺=(v∘.<v)×∘.+⍨⍵*⍨v←⍳⌊⍺*.5:⍺⋄⍵∇⍨⍺+1} 2
65

I'm beating GolfScript? Can't be!!


CJam, 28 27 bytes

PP+mr_mc\ms]1.mrmqf*"(,)".\

This solution is not rejection-based. I'm generating the points in polar coordinates, but with a non-uniform distribution of the radii to achieve a uniform density of the points.

Test it here.

Explanation

PP+     e# Push 2π.
mr_     e# Get a random float between 0 and 2π, make a copy.
mc\     e# Take the cosine of one copy and swap with the other.
ms]     e# Take the sine of the other copy and wrap them in an array.
        e# This gives us a uniform point on the unit circle.
1.mr    e# Get a random float between 0 and 1.
mq      e# Take the square root. This is the random radius.
f*      e# Multiply x and y by this radius.
"(,)".\ e# Put the resulting numbers in the required format.

Why does it work? Consider a narrow annulus of radius r and (small) width dr. The area is approximately 2π*r*dr (if the annulus is narrow, the inner and outer circumference are almost identical, and the curvature can be ignored, such that the area can be treated as that of a rectangle with side lengths of the circumference and the width of the annulus). So the area increases linearly with the radius. This means that we also want a linear distribution of the random radii, in order to achieve a constant density (at twice the radius, there is twice as much area to fill, so we want twice as many points there).

How do we generate a linear random distribution from 0 to 1? Let's look at the discrete case first. Say, we have a desired distribution of 4 values, like {0.1, 0.4, 0.2, 0.3} (i.e. we want 1 to be 4 times as common as 0, and twice as common as 2; we want 3 three times as common as 0):

How can pick one of the four values with the desired distribution? We can stack them up, pick a uniformly random value between 0 and 1 on the y-axis and pick the segment at that point:

There's a different way to visualise this picking though. We could instead replace each value of the distribution with the accumulation of the values up to that point:

And now we treat the top line of this chart as a function f(x) = y and invert it to get a function g(y) = f-1(y) = x, which we can apply to a uniformly random value in y ∈ [0,1]:

Cool, so how can make use of this to generate a linear distribution of radii? This is the distribution we want:

The first step is to accumulate the values of the distribution. But the distribution is continuous, so instead of summing over all previous values, we take an integral from 0 to r. We can easily solve that analytically: ∫0r r dr = 1/2 r2. However, we want this to be normalised, i.e. to multiply it by a constant such that this gives 1 for the maximum value of r, so what we really want is r2:

And finally, we invert this to get a function we can apply to a uniform value in [0,1], which we can again do analytically: it's just r = √y, where y is the random value:

This is a fairly useful technique that can often be used to generate simple distributions exactly (it works for any distribution, but for complicated ones the last two steps may have to be solved numerically). However, I wouldn't use it in this particular case in production code, because the square root, sine and cosine are prohibitively expensive: using a rejection-based algorithm is on average much faster, because it only needs addition and multiplication.


Counting Queen's paths on a rectangular chessboard

Haskell, 94 91 64 54 bytes

1!1=1;m!n=sum[m!(n-x)+(m-x)!n+(m-x)!(n-x)|x<-[1..m+n]]

Try it online!

Initially a boring port of the comment on OEIS

-27 from some tricks off dingledooper's answer

-10 from Christian Sievers


You call it Centering, I call it Code Golf

HTML5 + JavaScript (ES5), 515 bytes

That count includes the HTML tags as they are part of the program. If you only count the image processing code, it is 376 bytes including the function wrapper.

<canvas id=o></canvas><script>f=function(p){o=new Image();o.crossOrigin='Anonymous';o.src=p;o.onload=function(){v=document.getElementById('o'),c=v.getContext('2d');v.width=l=w=o.width;v.height=t=h=o.height;c.drawImage(o,0,0);for(k=255,d=c[g='getImageData'](0,0,w,h).data,r=b=i=0;i<d.length;)if((d[i++]<k||d[i++]<k||d[i++]<k)&&d[i++]){x=i/4%w;y=~~(i/4/w);l=l<x?l:x;t=t<y?t:y;b=b>y?b:y;r=r>x?r:x}n=c[g](l,t,r-l+1,b-t+1);c.clearRect(0,0,w,h);c.putImageData(n,(w-r+l)/2,(h-b+t)/2)}}</script><input onblur=f(this.value)>

Input

A URL to an image.

Security restrictions

Because this program is running in a browser environment, only URLs to CORS-enabled images will work. Imgur is CORS enabled.

IE 10 does not support CORS. I haven't tested in IE 11 yet but it does work in Chrome and Firefox.

How to run

Type/paste in a URL into the input field.
De-focus (tab/click out of) from the input field.

Output

It outputs on the canvas on the page.

As this is a browser-based application, security restrictions prevent automatic download of a file but you can right click and save image in Chrome and Firefox. I haven't tested on IE 11 yet.

Demo

JavaScript code has been removed from the script element and put into the appropriate area to accommodate Stack Snippets:

f = function(p) {
  o = new Image();
  o.crossOrigin = 'Anonymous';
  o.src = p;
  o.onload = function() {
    v = document.getElementById('o'), c = v.getContext('2d');
    v.width = l = w = o.width;
    v.height = t = h = o.height;
    c.drawImage(o, 0, 0);
    for (k = 255, d = c[g = 'getImageData'](0, 0, w, h).data, r = b = i = 0; i < d.length;)
      if ((d[i++] < k || d[i++] < k || d[i++] < k) && d[i++]) {
        x = i / 4 % w;
        y = ~~(i / 4 / w);
        l = l < x ? l : x;
        t = t < y ? t : y;
        b = b > y ? b : y;
        r = r > x ? r : x
      }
    n = c[g](l, t, r - l + 1, b - t + 1);
    c.clearRect(0, 0, w, h);
    c.putImageData(n, (w - r + l) / 2, (h - b + t) / 2)
  }
}
<canvas id=o></canvas>
<input onblur=f(this.value)>


How far away is n to the next power of b?

Jelly,  4  3 bytes

ạæċ

A dyadic link taking n on the left and b on the right and returning the result.

Try it online!

How?

ạæċ - Link: number n, number b | n,b ∈ ℕ
 æċ - ceiling n to the next power of b
ạ   - absolute difference between n and that


Javascript,56 53 52 bytes
-3 bytes thanks to @ovs
-1 byte thanks to @Arnauld
p=parseInt,a=>(p(p(a,16)[s='toString'](8))/2)[s](16)

toString on an integer converts the integer to a string in that base.
Try it online!


C

#include <stdio.h>

int puts(const char *str) {
  fputs("Hello, world!\n", stdout);
}

int main() {
  printf("Goodbye!\n");
}

When compiled with GCC, the compiler replaces printf("Goodbye!\n") with puts("Goodbye!"), which is simpler and is supposed to be equivalent. I've sneakily provided my custom puts function, so that gets called instead.


Jolf, 35 bytes

Saves 1 byte thanks to @Cᴏɴᴏʀ O'Bʀɪᴇɴ. This is encoded in ISO 8859-7.

? hI'_ΜGI'_dpyH0pxRGIL0"(?=[A-Z])'_

Woohoo my first Jolf program!

Explanation

   // I = input
? hI'_                              // If input contains _
       GI'_                          // Split on _
      Μ    d                         // Loop, then join
            pyH0                     // Make the first character uppercase
                                    // ELSE...
                  RGIL0"(?=[A-Z])    // Split *after* all uppercase chars
                                 '_  // join with _
                px                   //Make lowercase

Try it online


Python 2, 41 bytes

lambda l:[sorted(l)[x==min(l)]for x in l]

Try it online!

For each element x we check whether x==min(l). If not, this is False, which is treated as 0 when used as a list index into sorted(l), giving the smallest element. Otherwise, it's True aka 1, giving the second-smallest element, since that element itself is smallest and should be ignored.


Duplicate the KOOS Jr. Scoring interval algorithm

05AB1E, 59 bytes

•G‚Œιã¶&‡Vc–QΩ`ååI~(Ìö{3.ùSÿ{Ćι¯TærÆcï`₃āÀ}ªHÕ¶η•4ô.¥R3°/Iè

Try it online!

Explanation

•G‚Œιã¶&‡Vc–QΩååI~(Ìö{3.ùSÿ{Ćι¯TærÆcï₃āÀ}ªHÕ¶η• is a compressed version of the input constructed by:

multiplying each element in the input by 1000
reversing the resulting list
calculating deltas
joining to a single base-10 number
compressing to base-255

The rest of the code is then:

4ô          # split in pieces of 4
  .¥        # undelta
    R       # reverse
     3°/    # divide each by 1000
        Iè  # index into list with input


PHP, score = 289 (17×(7+10))

PHP's built-in functions make it quite easy to do this badly. The following code just shuffles the string until a valid result is obtained:

function f($s){
while(preg_match(
'/(..).*?\1/',$s)
+preg_match('/(.'
.')\1\1/',$s))$s=
str_shuffle(
$s);return $s;}

Benchmarks

Average and maximum execution times calculated using the following code:

$s = 'Mississippi';
$t_total = 0;
$t_max = 0;
for ($i=0; $i<10; $i++) {
  $t0 = microtime(true);
  echo f($s);
  $t = microtime(true) - $t0;
  printf("  %10.7f\n",$t);
  $t_total += $t;
  if ($t > $t_max) $t_max = $t;
}
printf("Avg: %10.7f secs; Max: %10.7f secs\n",$t_total/$i, $t_max);

Results:

Mississippi: Avg:  0.0002460 secs; Max:  0.0005491 secs
Anticonstitutionnellement: Avg:  0.0001470 secs; Max:  0.0002971 secs
Pneumonoultramicroscopicsilicovolcanoconiosis: Avg:  0.0587177 secs; Max:  0.1668079 secs
Donaudampfschiffahrtselektrizitatenhauptbetriebswerkbauunterbeamtengesellschaft*: Avg:  9.5642390 secs; Max: 34.9904099 secs
baaacadaeafbbcbdbebfccdcecfdde†: Avg:  5.0858626 secs; Max:  9.8927171 secs

* I changed ä to a to avoid multi-byte issues
† This was the hardest 30-character string I could come up with. It's actually the first 30 characters of the De Bruijn sequence for k='abcdef' and n=2, with the first 'b' moved to avoid an instant match.


JavaScript (ES6),  52 51  50 bytes
Saved 1 byte thanks to @tsh
Takes input as a string. Returns a Boolean value.

f=n=>n>[n%10]?f(-(-n[0]-n)%10+n.slice(1,-1)):!n[1]

Try it online!
Commented
f = n =>                 // f = recursive function taking n (a string)
  n > [n % 10]           // The last digit is isolated with n % 10 and turned into a
                         // singleton array, which is eventually coerced to a string
                         // when the comparison occurs.
                         // So we do a lexicographical comparison between n and its
                         // last digit (e.g. '231'>'1' and '202'>'2', but '213'<'3').
  ?                      // If the above result is true:
    f(                   //   do a recursive call:
      -(-n[0] - n) % 10  //     We compute (int(first_digit) + int(n)) mod 10. There's no
                         //     need to isolate the last digit since we do a mod 10 anyway.
      + n.slice(1, -1)   //     We add the middle part, as a string. It may be empty.
    )                    //   end of recursive call
  :                      // else:
    !n[1]                //   return true if n has only 1 digit, or false otherwise


Stax, 601 584 574 564 553 539 bytes

«=¬█j▼sw│╥═7♫çÿñ╦*‼e"!‼╤Å╟D·εWÜå╖L♂@#î╚å♫▐ô;(┤┼»Kî→δäû║h◘│¶zurΘ█┐£ë}∞è┼$÷gôwg¬≤╒Ñ╧]∙ì▄╦╕ís│\☺'┴♫Φ^┐╤å{1█♠₧ï∩∙↑▀⌂d▲╡⌡3J‼¡qâ╧3¥Çƒwe▀≡╔MjZΣΩyüO╬ªÉΩö^Y╡►8K₧óN·ÿjg≈Cö9^◘■~Ä_ßx▐Å┌ Q>/♫╤QΩzN╤V½▓▀◙ß╗╗◄►(╔☺╡┘Ah╙¢√ß▼GΩ→ù◄:─◘#♫úq•ø≤>↨)Å│╤[ïmgBX┤╛v\ⁿ╛å╘╕7d╪TµbW#2¶ø╙╜~êê[↨>K►♪0∞#XJ°ñntG∞⌐V♥Z<ÿº'║☺;┤é⌡♠gáσßÑ+♂z♥‼S9 l≈╫ºÜT»↕▀τ♣¡gWe¥_çà(┬f╜n[╗╤fσ╞R₧▲V▌═◙úKÆÜ▄☺╥s1▼╩ûû╗▌▌Ω■g∞Y╡9╦tè┴y♂w∟⌂┌'╣W▀M╓·uBôúPm◘ ☻ⁿFh<╘sú▲Ö╘¶¿_2♦Θb{╪δC\lô+▀9¶ß§╡╓)ú}○8∟⌡nÑôI )╓îFbH[î║╞e&"¶↓~A#ç╔▄─áσ∙:═Æ▬ª▄ÄêQSNM◙∞Z╜≈±╘▬LIÿ|#.¿Φµ║▌Lväv▓♣;└Æ▲▄♣↕{╪½)╚φ╡♦:oÉ▀j╠ΔP<ç↔|±╦=╣▓Φ▒─4D▄■ìà>↓┐

Run and debug it

It does at least attempt to use different strategies for different pieces.
I've still got some hope for a few sections, but here's an explanation of the approaches so far.

                                    The general approach is to push a bunch of stuff on the stack.
                                    Then join it all together and split it in thirds.
'                                   just a space
`jaH1"jS3!`X                        compressed literal for "Hello, World!" assigned to the x register
`38dZl;i#D]|@Y@*`                   compressed literal for "It's showtime talk to the hand"
^                                   convert to upper case; it compresses better in lower case
n'"|SY                              Wrap the x register in quotes and save it in the y register
`=j("sx6c1 ob`^                     compressed literal for "you have been terminated" in upper
."9                                 literal for '"9'
yrD                                 register y (quoted hello world), reversed, first character dropped
"ck,@ "                             literal
"^h{ai{W>bJ,^T+NLDK(G$s@+"!         crammed array [725, 101597559, 354, 45325875, 1115935, -65, -85335]
$"5a9+"|t                           concat as strings, then map '5' to 'a' and '9' to '+'
`='9%[mh++PxF!`                     compressed literal for " Take Circle Line to "
`~J@[E<`n                           compressed literal for "Paddington"; copy the one about the circle
`jj_kmZ5`                           compressed literal for "Wood Lane"
n7T                                 copy " Take Circle Line to " and truncate last 7 characters
"alert'"x''                         some literals and x register
`~lLKPq'III^) .tI:G8?uMolVwpnT&u#`  compressed literal with commas in place of semi-colons
.,;|t                               replace with semi-colons, which aren't allowed in compressed literals
`/zOXzN`",data,{s:bits8[],`x\0_;}`cC,main(){`cC,puts(,address,s);` C,return(0);} ".,"|t
                                    compressed literal for "foreign", followed by a string template
"Nm\{<\3VdH,FF:c~7&u!n"96|E         carefully chosen string literal interpreted in base 96
"eawu":B                            encoded in custom base "eawu"
`dzJxVHC"`'{`pS7yzeENLM%_'`         two compressed literals with a '{' in the middle
"(String[]a){System."               literal
x6)                                 last 6 characters of register x
"`");}}"                            literal with escaped uote
"0;pKll>r&.sSP}JLNL==(>eP>-2\6fc8|)4&.:,1jA66O{t0>GpALk4I{.iDM:Gr_50ga"
90|E                                literal of ascii characters decoded in base 90
"[+-><],.":B                        re-encoded with a custom base of brainfuck
72:/                                split at position 72
~                                   push the right half to the input stack, effectively the beginning
" `yo| :after{content:`y H;e;P1;@/;W;o;/l;;o;Q/r;l;d;2;P0 ('&%:9]!~}|z2Vxwv-,POqponl$Hjihf|B@@>,=<M:9&7Y#VV2TSn.Oe*c;(I&%$#`"mCBA?zxxv*Pb8``qo42mZF.{Iy*@dD'<;_?!\}}|z2VxSSQ main(){puts("
                                    big string template including y register a few times
y9(                                 first 9 characters of y
Lr$                                 wrap all stacks in array and concatenate
3Mm                                 split into 3 equal parts and print as lines


Shortest terminating program whose output size exceeds Graham's number

Haskell, 59 57 55 63

(f%s)1=s;(f%s)n=f.(f%s)$n-1
main=print$((flip((%3)%(3^))3)%4)66

How it works: % simply takes a function and composes it n-1 times on top of s; i.e. %3 takes a function f and returns a function of n that equals applying it f to 3, n-1 times in a row. If we iterate the application of this higher-order function, we get a fast-growing sequence of functions – starting with exponentiation, it's exactly the sequence of Knuth-arrow-forest sizes:
((%3)%(3^))1 n = (3^)n     = 3ⁿ = 3↑n
((%3)%(3^))2 n = ((3^)%3)n = (3↑)ⁿ⁻¹ $ 3  = 3↑↑n
((%3)%(3^))3 n = (((3^)%3)%3)n = (3↑↑)ⁿ⁻¹ $ 3  = 3↑↑↑n
 and so on. ((%3)%(3^))n 3 is 3 ↑ⁿ 3, which is what appears in the calculation to Graham's number. All that's left to do is composing the function (\n -> 3 ↑ⁿ 3) ≡ flip((%3)%(3^))3 more than 64 times, on top of 4 (the number of arrows the calculation starts with), to get a number larger than Graham's number. It's obvious that the logarithm (what a lamely slow function that is!) of g₆₅ is still larger than g₆₄=G, so if we print that number the output length exceeds G.

⬛


Shortest Longest Increasing Subsequence Code

Python 3, 66

Note that all numbers are in range [1, 999], we can use an array b to maintain the longest subsequence length ending with each number. b[x] = d means that the longest subsequence ending with x has length d. For each number from the input, we update the array using b[x] = max(b[:x]) + 1 and then we got the job done by taking max(b) finally.

The time complexity is O(n) O(m n), where m is always 1000 and n is the number of input elements.

def f(a):
 b=[0]*1000
 for x in a:b[x]=max(b[:x])+1
 return max(b)

Wow, looks like already ungolfed :)
You can test it using stdin/stdout by adding a line:

print(f(map(int,input().split())))


C, 50 + 3008 = 3058 bytes

I've tried out several simple compression methods, and found that outputting the UTF-16 input (trailing newline removed) directly is the best way. Input from stdin.

int b[999];main(){read(0,b,3008);write(1,b,3008);}

Python 3, 62 + 2145 = 2207 bytes

Evil built-in. Input filename is A, which is an xz-compressed file of UTF-16 version.

import lzma
print(lzma.open('A','rt',encoding='utf16').read())

Compressor code:

import lzma
open('A','wb').write(lzma.compress(open('utf16_file.txt','rb').read(),lzma.FORMAT_ALONE))


05AB1E, 13 12 10 bytes

Saved 2 bytes thanks to Emigna.

Since there is no trigonometric functions to be called using OP's assumption that the earth is locally a plane, it becomes possible to make an 05AB1E solution.

•1#oC•+¹*t

           For understanding purposes input is referred to as 'h'
•1#oC•     Push 12742000 [ = 2*R, where R is the radius of earth]
      +    Compute 2*R+h
       ¹*  Multiply by h. Result is (2*R*+h)*h
         t Take the square root of it and implicitly display it

Try it online!


Build a random number generator that passes the Diehard tests

Perl 28 / 13 ≈ 2.15

sub r{$s^=~($s^=$s/7215)<<8}

log file here

Perl 29 / 13 ≈ 2.23

sub r{$s^=~($s^=$s<<8)/60757}

log file here

These are something of a variation on a Xorshift, using floating point division instead of a right shift. They both pass 13 of 15 tests, failing only tests 6 and 7.

I'm not exactly sure how long the cycle is, but because the following code doesn't terminate in any short period of time, it's likely the full 232:

$start = r();
$i++ while $start != r();
print $i;

Perl 39 / 10 = 3.9

$s=$^T;sub r{~($s=$s*$s%4294969373)||r}

Note: if you're looking for a Blum-Blum-Shub-esque PRNG, Keith Randall's solution is far better than either of these.

As with my original solution below, this is also an implementation of the Blum Blum Shub, with one major difference. I uses a modulus slightly larger than 232 (M = 50971 • 84263), and whenever a value is encountered that it is not a valid 32-bit integer (that is, larger than 232), it returns the next value in the rotation instead. In essense, these values are pruned out, leaving the rest of the rotation undisturbed, resulting in a nearly uniform distribution.

It seems to have helped. In addition to passing the same 9 tests as before, it now also convincingly passes the Minimum Distance test. A sample log file can be found here.

Perl 33 / 9 ≈ 3.67 (Invalid?)

 $s=$^T;sub r{$s=$s*$s%4294951589}

Note: this solution might be considered invalid, as the top-most 0.00037% of the range will never be observed.

A quick and dirty implementation of the Blum Blum Shub. I claim the following results:

 1. passed - Birthday Spacings
 2. FAILED - Overlapping Permutations
 3. passed - Ranks of 31x31 and 32x32 Matrices
 4. passed - Ranks of 6x8 Matrices
 5. FAILED - Monkey Tests on 20-bit Words
 6. FAILED - Monkey Tests OPSO, OQSO, DNA
 7. FAILED - Count the 1s in a Stream of Bytes
 8. passed - Count the 1s for Specific Bytes
 9. passed - Parking Lot Test
10. FAILED - Minimum Distance Test
11. passed - Random Spheres Test
12. FAILED - The Squeeze Test
13. passed - Overlapping Sums Test
14. passed - Runs Test
15. passed - The Craps Test

A sample log file can be found here, feel free to dispute any of the results. The file for diehard can be generated in the following manner:

print pack('N', r()) for 1..4194304

and then piping the output into a file. Minimum Distance looks like it might have passed, but if you run it multiple times it's always very close to 1.0, which indicates failure.

Details

In general, the Blum Blum Shub is a terrible PRNG, but it's performance can be improved by choosing a good modulus. The M I've chosen is 7027 • 611207. Both of these prime factors, p and q, have modular residue 3 (mod 4), and gcd(φ(p-1), φ(q-1)) = 2, which is as low as it can be.

Although these are the only criteria listed on the wiki page, it doesn't seem to be enough. Almost all of the modulo I tried failed every test. But there's a handful that will pass some of the tests, and the one I've chosen seems to be exceptionally good, for whatever reason.

As a final note, Test 5 on its own seems to be a fairly good indicator of how good the PRNG is. If it doesn't almost pass Test 5, it will fail the rest of them spectacularly.

BONUS: Perl 62 / 14 ≈ 4.43

$t=$^T;sub r{$t|=(($s=$s/2|$t%2<<31)^($t/=2))<<31for 1..37;$t}

Just for geekery, this is a 32-bit version of the PRNG used in the original Tetris for NES. Amazingly, it passes 14 of the 15 tests!

 1. passed - Birthday Spacings
 2. passed - Overlapping Permutations
 3. passed - Ranks of 31x31 and 32x32 Matrices
 4. passed - Ranks for 6x8 Matrices
 5. passed - Monkey Tests on 20-bit Words
 6. passed - Monkey Tests OPSO, OQSO, DNA
 7. FAILED - Count the 1s in a Stream of Bytes
 8. passed - Count the 1s for Specific Bytes
 9. passed - Parking Lot Test
10. passed - Minimum Distance Test
11. passed - Random Spheres Test
12. passed - The Squeeze Test
13. passed - Overlapping Sums Test
14. passed - Runs Test
15. passed - The Craps Test

Sample log file can before here.

Admittedly, the 1..37 bit isn't an exact transcription. In the orginal version, the entropy routine is updated 60 times per second, and then queried at random intervals, largely dependent on user input. For anyone who cares to disassemble the ROM, the entropy routine begins at 0xAB47.

Python-style pseudo-code:

carry = entropy_1 & 1
entropy_1 >>= 1
entropy_2 = (entropy_2 >> 1) | (carry << 31)
carry = (entropy_1 & 1) ^ (entropy_2 & 1)
entropy_1 |= carry << 31


Perl, 109 95 93 96 89 bytes

s/^d/1d/;/^(\d+)d(\d+)(\+\d+)?$/;$d+=1+rand$2|0for
1..$1;$_=$1*$2?$d+$3:'Invalid input'

Requires the -p switch, which accounts for two of the bytes. Try it online on Ideone.

How it works

Because of the -p switch, a line is read from STDIN and stored in $_.
The command s/^d/1d/ prepends a 1 to $_ if it begins with a d, i. e., if the number of dice has not been specified.
The regular expression /^(\d+)d(\d+)(\+\d+)?/ checks if the line consists of a number, a literal d, another number and, optionally, a third number preceded by a + sign.

If there is a match, the numbers will be saved in $1, $2 and $3.

In this case, the input will be valid if and only if $1 and $2 are both positive.
$d += 1 + rand $2 | 0 adds a pseudo-randomly chosen integer from 1 to the specified number of sides to $d (initially treated as zero).
for 1 .. $1 does the above once for every integer between 1 and the number of dice.
The command $_ = $1 * $2 ? $d + $3 : 'Invalid input' does the following:

If $1 * $2 is zero, it sets $_ to Invalid input.
Otherwise, the input is valid and it sets $_ to the sum of the dice rolls and the modifier.

Because of the -p switch, Perl prints the contents of $_.
Since there a no further input lines, the script exits.


CJam, 156 151 144 bytes
q~0f+{{1=}$_,2%{{W=}$())+aa\{1=}$\}L?\_,2//)W%a+z\+_{0f=_,1={~" BYE"+a}*" vs "*N\}%"Round "U):U+\+\{{2=0=}$W=_2=(;2\t}%_W=2=}g~0=a"Champion"\]N*

This can definitely be golfed further.
The input is in an array of array format, like:
[["James" 1 [12 6 15]] ["Sarah" 4 [3 2 5]] ["Franko" 2 [20 1 5]] ["Max" 5 [22 10 7]] ["Arthur" 3 [20 15 20]]]

where each array element is the detail about the user in [name seed score_array] format
The output for the above input is:
Round 1
Franko vs Max
Arthur vs Sarah
James BYE
Round 2
James vs Max
Arthur BYE
Round 3
Arthur vs Max
Champion
Arthur

Try it online here


Use currying when you need a lambda with 2 arguments
If you want a function with 2 arguments, currying syntax always saves 1 byte. For example:
f=(a,b)=>a+b

Is one byte longer than:
f=a=>b=>a+b

The first function can be called with f(number_1, number_2), whilst the latter is called using f(number_1)(number_2).
Try it online!


Jelly, 11 bytes

~1¦&N$^µ</¿

Try it online! or verify all test cases.

Background

We can extract the last set bit of an integer n as follows.

n + 1 toggles all trailing set bits of n and the adjacent unset bit. For example, 100112 + 1 = 101002.

Since ~n = -(n + 1) = -n - 1, -n = ~n + 1, so -n applies the above to the bitwise NOT of n (which toggles all bits), thus toggling all bits before the last 1.

For example, -101002 = ~101002 + 1 = 010112 + 1 = 011002.

By taking n & -n the bitwise AND of n and -n all bits before the last set bit are nullified (since unequal in n and -n), thus yielding the last set bit of n.

For example, 101002 & -101002 = 101002 & 011002 = 001002.

Thus XORing n with n & -n unsets the last set bit of n.

Conversely, to unset the last set bit of n, it suffices to apply the above to ~n, from where we derive the formula n ^ (~n & -~n).

How it works

~1¦&N$^µ</¿  Main link. Argument: A (list of pairs)

          ¿  While loop:
        </     Condition: Reduce p by less-than. True iff x < y.
       µ       Body chain:
~1¦              Apply bitwise NOT to the x, first item of the pair.
     $           Convert the two links to the left into a monadic chain.
    N              Negate; multiply [~x, y] by -1, yielding [-~x, -y].
   &               Logical AND. Yields [-~x & ~x, -y & y].
      ^            Vectorized XOR with p. Yields [(-~x & ~x) ^ x, (-y & y) ^ y].


Python, 443 440 chars

R=range
N=37
V=91447186090
M={'e':R(0,N,2),'o':R(1,N,2),'r':[i for i in R(N)if V>>i&1],'b':[i for i in R(1,N)if~V>>i&1],'1-18':R(1,19),'19-36':R(19,N)}
for i in R(1,4):M['c%d'%i]=R(i,N,3);M['d%d'%i]=R(i*12-11,i*12+1)
for i in R(1,N):M[`i`]=[i]
B=[]
r=raw_input()
while'ok'!=r:x,k=r.split();B+=[(sum((M[y]for y in x.split(',')),[]),int(k))];r=raw_input()
z=input()
c=0
i=1
for b,k in B:v=36/len(b)*k*(z in b);print i,v;c+=k-v;i+=1
print'c',c

Makes M, a map from bet names to a list of numbers that win that bet.  Then it reads the bets in, storing each one as a pair (list of numbers, dollar amount) in the list B.  Finally, reads in the spin z and computes the payouts.


Mathematica, 56 bytes

#//.x_/;(b=Max[d=IntegerDigits@x]+1)<11:>d~FromDigits~b&

Try it online! (Using Mathics.)

I thought I'd check out what the sequence looks like:

And here is a plot of the number of steps it takes to find the result:

(Click for larger versions. See the revision history for plots only up to n = 1000.)

Looks like a very interesting mixture of large scale structure and fine scale chaos. I wonder what's up with the wider gaps around 30,000 and 60,000.


Windows Command Prompt

& was unexpected at this time.


JavaScript (ES7), 48 bytes

Based upon a suggestion from @RickHitchcock

Expects X in uppercase. Takes input in currying syntax (p)(X).

p=>X=>eval(p.replace(/[X^]/g,c=>c<{}?'*X':'**'))

Try it online!

JavaScript (ES7), 49 bytes

Same approach as @DeadPossum. Takes input in currying syntax (p)(x).

p=>x=>eval(p.split`x`.join`*x`.split`^`.join`**`)

Try it online!


Pyth, 63 53 bytes
J26AcU*J2JW=Y?@Q%ZlQ.iHG.iGH=+Z1AcYJI&qYSY!%ZlQB;/ZlQ

Try it online!
J26          # Set J to 26.
AcU*J2J      # Assign G and H to range(0, 26) and range(26, 52) respectively.
W            # While
?@Q%ZlK      # If the current element of Q (input list)
.iHG         # is 1, then interleave H and G
.iGH         # Otherwise, interleave G and H
=Y           # Assign that value to Y
=+Z1         # Increment Z by 1
AcYJ         # Now reassign G and H to the first and last 26 elements of Y respectively
I&qYSY!%ZlQB # If Y is already sorted and we are at the end of input list, then break
;/ZlQ        # Print Z divided by length of input list


(Error) quines, hello world, polyglots, oh my!

C, Bash, C++, score 174.5 175
C, 301 bytes - Quine
#include<stdio.h>
int main(){
#ifdef __cplusplus
printf("Hello, World!"
#else
char*c="#include<stdio.h>%cint main(){%c#ifdef __cplusplus%cprintf(%cHello, World!%c%c#else%cchar*c=%c%s%c;printf(c,10,10,10,34,34,10,10,34,c,34,10,10%c#endif%c);}//";printf(c,10,10,10,34,34,10,10,34,c,34,10,10
#endif
);}//

Try it online!
Bash, 48 49 bytes - Error quine
.code.tio: line 1: .code.tio:: command not found

Try it online! (the trailing newline was added, see comments)
C++, 349 350 bytes - Hello, World!
#include<stdio.h>
int main(){
#ifdef __cplusplus
printf("Hello, World!"
#else
char*c="#include<stdio.h>%cint main(){%c#ifdef __cplusplus%cprintf(%cHello, World!%c%c#else%cchar*c=%c%s%c;printf(c,10,10,10,34,34,10,10,34,c,34,10,10%c#endif%c);}//";printf(c,10,10,10,34,34,10,10,34,c,34,10,10
#endif
);}//.code.tio: line 1: .code.tio:: command not found

Try it online!

Explainations and notes
The C quine is inspired by this C quine (the short version), and contains C++ code for the Hello, World!.
The Bash error quine works due to the TIO implementation, but given that error messages are generally implementation defined, it might be hard to print them in some standard way (other than directly outputting to stderr, which is just like a regular quine... how unoriginal would that be). The submitted Bash program may be an invalid Bash program, but it is still a valid error quine in Bash. (Edit: note the trailing newline that is now legal to output.)
The C++ Hello, World! doesn't output a trailing newline, but the challenge doesn't require it. After the preprocessor preprocessing, the only code source left is the main function with a simple printf call.
What was used in this answer are similarities between C and C++, very useful for polyglots (C is not entirely contained by C++, but it is contained enough) (for example: the usage of the C standard library is almost the same in these two languages which allows for a single #include directive, the main function definition is also similar enough to factorize the beginning and end out of the preprocessor-picked variations). The preprocessor and the __cplusplus macro are almost necessary at this point as they allow the C and C++ interpreters (or compilers, whatever) to pick only a specific subset of the program. The trailing line comment // ensures that the concatenation with a TIO Bash error doesn't upsets the C++ parser as it will completely ignore it.
I didn't find a way to to golf it even further. An other approach or a different set of languages are probably to be considered. For example, maybe using Argh! or INTERCAL for the error quine (or any other language in which error output is part of the language specification (these languages are rare, even among esolangs)). It might also be more interesting to use an other strategy than this """polyglot""" that makes each language ignore the code designed for the other languages instead of actually running most of the code.


Triangular Grids: Simply Connected Polyiamonds

Snails, 95 bytes
F&
lr|=((ul.)2 ,l~a~)d|!((ul.)2 ,l~a~)u}\*}+l\ ,~a~|{\ (lr|=((ul.)2 ,l~a~)d|!((ul.)2 ,l~a~)u}+~

This really suffered from duplication, as I haven't implemented macros or any kind of back-reference. What it does is to check that for each star, there exists a path to the leftmost star on the top line; and for each space, there is a path to an edge of the grid.
F&                         ,, option F: pad lines with spaces to the length of the longest
                           ,, option &: print 1 iff match succeeds from every cell
lr                         ,, direction left or right, or
      | =((ul.)2 ,l~a~) d  ,, direction down, if we are an even number of orthogonal moves from the top left
      | !((ul.)2 ,l~a~) u  ,, or, direction up if we are odd number of moves from the top left
    }  \*                  ,, literal '*'
}+                         ,, 1 or more times
l\ ,~a~                    ,, check that we are on the leftmost * in the top line

|                          ,, the part before this is for starting on '*'; part after for starting on ' '

{ \                        ,, literal ' '
    (   lr                 ,, direction left or right, or
      | =((ul.)2 ,l~a~) d  ,, same drill as before...
      | !((ul.)2 ,l~a~) u
}+                         ,, 1 or more times
~                          ,, end on an out of bounds cell


JavaScript (ES6),  103 100 93 92  90 bytes
Saved 9 bytes thanks to @ShieruAsakoto
Takes input as an array of columns. Returns an array of characters.

a=>a.map(s=>"H-L-D--VGQ87MR6TZ-KJ9WC05BUXF1YI2EON3S-A-P4"[parseInt(s,35)%1161%219%152%43])

Try it online!


Fix my notation for lists of matrices, part 1

Jelly, 20 15 13 11 bytes

Fðs⁹œsZµḢḢL

Try it online!

Background

Like most things, this challenge is rather simple once you've figured out what you have to do. And I eventually did, after three deletions and one rollback...

First, we must figure out the dimensions of the matrices. That's easier done than said: the first element of the first element is the first row of the first output matrix, so its length is equal to the number of columns of the square output matrices.

For example, if the input is

[  [[1, 0, 0],   [[ 127,  63,   31],   [[1, 0, 0],   [[0, 0, 0],
    [0, 1, 0],    [  15,   0,  -15],    [0, 0, 1],    [0, 0, 0],
    [0, 0, 1]],   [ -31, -63, -127]],   [0, 1, 0]],   [0, 0, 0]]  ]

the first element of the first element is [1, 0, 0], whose length is ℓ = 3.

If we flatten the input and split it into chunks of that length, we get all rows of the output matrices, albeit in the wrong order. For our example input, this gives

[  [1, 0, 0], [127,  63,   31], [1, 0, 0], [0, 0, 0],
   [0, 1, 0], [ 15,  0,   -15], [0, 0, 1], [0, 0, 0],
   [0, 0, 1], [-31, -63, -127], [0, 1, 0], [0, 0, 0]  ]

To obtain the final output, we must first split the row array into ℓ chunks of equal length. For our example input, this gives

[ [[1, 0, 0], [127,  63,   31], [1, 0, 0], [0, 0, 0]],
  [[0, 1, 0], [ 15,  0,   -15], [0, 0, 1], [0, 0, 0]],
  [[0, 0, 1], [-31, -63, -127], [0, 1, 0], [0, 0, 0]] ]

Each column is now one of the output matrices, so transposing the resulting matrix of arrays is all that's left to do. For our example input, that gives

[
 [[1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]],

 [[127,  63,   31],
  [ 15,   0,  -15],
  [-31, -63, -127]],

 [[1, 0, 0],
  [0, 0, 1],
  [0, 1, 0]],

 [[0, 0, 0],
  [0, 0, 0],
  [0, 0, 0]]
]

as desired.

How it works

Fðs⁹œsZµḢḢL  Monadic link. Argument: A (ragged array)

F            Monadic chain. Argument: A

F            Flatten A. This yields the vector V.

       µḢḢL  Monadic chain. Argument: A

        Ḣ    Head; retrieve the first element of A.
         Ḣ   Head; retrieve the first element of the first element of A.
          L  Compute ℓ, the length of the resulting array.

 ðs⁹œsZ      Dyadic chain. Left argument: V. Right argument: ℓ

  s⁹         Split V into chunks of length ℓ.
    œs       Split the result into ℓ chunks of equal length.
      Z      Zip/transpose the result.


Use lambdas instead of full functions

To save a few bytes, you can make your answer a lambda instead of a full function:

Predecessor function:
(q (
  (n)
  (s n 1)))

Golfed:
(q((n)(s n 1)))

This is only useful if the function doesn't recurse.


C, 2765 (optimal)

Edit

Now all in a single C file. This just finds all the optimal solutions. They all must have 6 words of 15 letters and one 10-letter word consisting of 8 letters of value 1 and two blanks. For that I only need to load a fraction of the dictionary and I don't have to look for 15 letter words with blanks.
The code is a simple exhaustive depth-first search.

#include <stdio.h>
#include <stdint.h>
#include <string.h>
struct w {
    struct lc { uint64_t hi,lo; } lc;
    char w[16];
} w15[6000], w10[40000];
int n15,n10;
struct lc pool = { 0x12122464612, 0x8624119232c4229 };
int pts[27] = {0,1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10};
int f[27],fs[26], w15c[27],w15l[27][6000];
int count(struct lc a, int l) { return (l < 16 ? a.lo << 4 : a.hi) >> 4*(l&15) & 15; }
int matches_val(uint64_t a, uint64_t b) {
    uint64_t mask = 0x1111111111111111ll;
    return !((a - b ^ a ^ b) & mask);
}
int matches(struct lc all, struct lc a) { return matches_val(all.hi,a.hi) && matches_val(all.lo,a.lo); }
int picks[10];
void try(struct lc cur, int used, int level) {
    int c, i, must;
    if (level == 6) {
    for (i = 0; i<27; i++) if (count(cur, i) && pts[i]>1) return;
    for (i = 0; i < n10; i++) if(!(used & (1 << (w10[i].w[0] & 31))) && matches(w10[i].lc, cur)) {
        for (c = 0; c<level; c++) printf("%s ",w15[picks[c]].w);
        printf("%s\n",w10[i].w);
    }
    return;
    }
    for (i = 0; i < 26;i++) if (count(cur,fs[i])) break;
    must = fs[i];
    for (c = 0; c < w15c[must]; c++) { i = w15l[must][c]; if(!(used & (1 << (w15[i].w[0] & 31))) && matches(cur, w15[i].lc)) {
    struct lc b = { cur.hi - w15[i].lc.hi, cur.lo - w15[i].lc.lo };
    picks[level] = i;
    try(b, used + (1 << (w15[i].w[0] & 31)), level+1);
    }}
}
int cmpfs(int *a, int *b){return f[*a]-f[*b];}
void ins(struct w*w, char *s, int c) {
    int i;
    strcpy(w->w,s);
    for (;*s;s++)
    if (*s&16) w->lc.hi += 1ll << 4*(*s&15); else w->lc.lo += 1ll << 4*(*s&15) - 4;
    if (c) for (i = 0; i < 27;i++) if (count(w->lc,i)) f[i]++, w15l[i][w15c[i]++] = w-w15;
}
int main() {
    int i;
    char s[20];
    while(scanf("%s ",s)>0) {
    if (strlen(s) == 15) ins(w15 + n15++,s,1);
    if (strlen(s) == 10) ins(w10 + n10++,s,0);
    }
    for (i = 0; i < 26;i++) fs[i] = i+1;
    qsort(fs, 26, sizeof(int), cmpfs);
    try(pool, 0, 0);
}

Usage:

$time ./scrab <sowpods.txt
cc -O3    scrab.c   -o scrab
JUXTAPOSITIONAL DEMISEMIQUAVERS ACKNOWLEDGEABLY WEATHERPROOFING CONVEYORIZATION FEATHERBEDDINGS LAURUSTINE
JUXTAPOSITIONAL DEMISEMIQUAVERS ACKNOWLEDGEABLY WEATHERPROOFING CONVEYORIZATION FEATHERBEDDINGS LUXURIATED
JUXTAPOSITIONAL DEMISEMIQUAVERS ACKNOWLEDGEABLY WEATHERPROOFING CONVEYORIZATION FEATHERBEDDINGS LUXURIATES
JUXTAPOSITIONAL DEMISEMIQUAVERS ACKNOWLEDGEABLY WEATHERPROOFING CONVEYORIZATION FEATHERBEDDINGS ULTRAQUIET
JUXTAPOSITIONAL DEMISEMIQUAVERS ACKNOWLEDGEABLY WEATHERPROOFING CONVEYORIZATION FEATHERBEDDINGS UTRICULATE
JUXTAPOSITIONAL DEMISEMIQUAVERS WEATHERPROOFING ACKNOWLEDGEABLY CONVEYORIZATION FEATHERBEDDINGS LAURUSTINE
JUXTAPOSITIONAL DEMISEMIQUAVERS WEATHERPROOFING ACKNOWLEDGEABLY CONVEYORIZATION FEATHERBEDDINGS LUXURIATED
JUXTAPOSITIONAL DEMISEMIQUAVERS WEATHERPROOFING ACKNOWLEDGEABLY CONVEYORIZATION FEATHERBEDDINGS LUXURIATES
JUXTAPOSITIONAL DEMISEMIQUAVERS WEATHERPROOFING ACKNOWLEDGEABLY CONVEYORIZATION FEATHERBEDDINGS ULTRAQUIET
JUXTAPOSITIONAL DEMISEMIQUAVERS WEATHERPROOFING ACKNOWLEDGEABLY CONVEYORIZATION FEATHERBEDDINGS UTRICULATE
OVERADJUSTMENTS QUODLIBETARIANS ACKNOWLEDGEABLY WEATHERPROOFING EXEMPLIFICATIVE HYDROGENIZATION RUBIACEOUS
OVERADJUSTMENTS QUODLIBETARIANS WEATHERPROOFING ACKNOWLEDGEABLY EXEMPLIFICATIVE HYDROGENIZATION RUBIACEOUS

real    0m1.754s
user    0m1.753s
sys 0m0.000s

Note every solution is printed twice because when adding a 15-letter 'W' word 2 orders are created because there are 2 'W' tiles.

The first solution found with the point breakdown:

JUXTAPOSITIONAL 465
DEMISEMIQUAVERS 480
ACKNOWLEDGEABLY 465
WEATHERPROOFING 405
CONVEYORIZATION 480
FEATHERBEDDINGS 390
LAURUSTINE (LAURU?TI?E) 80
no tiles left

Edit: explanation

What makes searching the entire space possible? While adding a new word I only take into account words that have the rarest remaining letter. This letter need to be in some word anyway (and a 15 letter word since this will be a non 1-value letter, though I don't check for that). So I start with words containing J, Q, W, W, X, Z which have counts around 50, 100, 100, 100, 200, 500. At lower levels I get more cutoff because some words are eliminated by the lack of letters. Breadth of the search tree at each level:

0: 1
1: 49
2: 3046
3: 102560
4: 724040
5: 803959
6: 3469

Of course a lot of cutoff is gained by not checking non-optimal solutions (blanks in 15 letter words or shorter words). So it is lucky that 2765 solution can be achieved with this dictionary (but it was close, only 2 combinations of 15 letter words give a reasonable leftover). On the other hand it is easy to modify the code to find lower scoring combinations where not all the leftover 10 letters are 1-valued, though it would be harder to prove this would be an optimal solution.

Also the code shows classic case of premature optimization. This version of matches function makes the code only 30% slower:

int matches(struct lc all, struct lc a) {
    int i;
    for (i = 1; i < 27; i++) if (count(a, i) > count(all, i)) return 0;
    return 1;
}

I even figured out how to make the bit magic parallel comparison even shorter than in my original code (highest nibble cannot be used in this case, but this is not a problem, as I only need 26 out of 32 nibbles):

int matches_val(uint64_t a, uint64_t b) {
    uint64_t mask = 0x1111111111111111ll;
    return !((a - b ^ a ^ b) & mask);
}

But it gives zero advantage.

Edit

Writing the explanation above I realized that most of the time is spent on scanning the list of words for those containing a specific letter not in the matches function. Calculating the lists upfront gave 10x speedup.


Retina, 27 19 bytes

Byte count assumes ISO 8859-1 encoding.

+1%`,
;$'¶$`];[
;
,

Try it online!

Explanation

Of course this computes all partitions using string processing. The basic idea is that we can generate all partitions by deciding for each , individually whether or not we want to split the list there. This kind of stuff can be done in Retina by matching each , in turn and using a replacement which gives both possible outputs.

The input acts as the base case: the partition where all elements are still in a single list.

+1%`,
;$'¶$`];[

Now we repeatedly (+) match the first (1) comma (,), on each line (%) (treating that line as a separate string, which is relevant for $' and ``$1 ` in the substitution).

That comma gets replaced with:

;   A semicolon. This is just a stand-in for the comma, so we know we've already
    processed it and it won't be substituted again by the next iteration.
$'  Everything after the match. This completes the first (unchanged) version of
    the current line.
¶   A linefeed. Since the next iteration will scan for all lines again, this doubles
    the number of strings we're working with.
$`  Everything before the match. This completes the second (split) version of
    the current line.
];[ A semicolon around which we split the list.

Remember that everything in front of the match and after the match remains in the string anyway, so the full result is actually $`;$'¶$`];[$' which explains why we insert the suffix and prefix in that order.

This loop stops once all commas are gone.

;
,

Finally, replace the semicolons with commas again to match the input format.


It's as easy as 1,2,3 (except you have to add them up)

Jelly, 12 11 bytes

+ɼ0x;R}ʋ/€S

Try it online!

A full program that takes a list of lists of integers as its argument and returns a list of integers. Can be adapted to work as a link by resetting the register to zero after each call (as implemented in the footer on TIO).

Saved a byte now list can be non-empty.


Java 8, 17 bytes

s->1024-s.sum()/2

Port of @LuisFelipeDeJesusMunoz' JavaScript answer.
Try it online.
Explanation:
s->           // Method with IntStream parameter and int return-type
  1024-       //  Return 1024, minus:
   s.sum()    //   The sum of the input-IntStream
          /2  //   Divided by 2


Shortest python3 code for: Find the difference between a number and a power of two not exceeding a given number

Python 3, 39 bytes

print(int('0'+bin(int(input()))[3:],2))

Try it online!
Subtracting the largest power of two less than a number is the same as removing the first 1 from its binary representation.
Unfortunately python rather mysteriously errors on trying to convert the empty binary string to an int so we need '0'+ if we want it to work on zero or one.  If we relax the requirements to only require two or more then we can remove 4 bytes.
Python 3, 35 bytes

print(int(bin(int(input()))[3:],2))

Try it online!


x86_64 machine code, 4 bytes
The BSF (bit scan forward) instruction does exactly this!
0x0f    0xbc    0xc7    0xc3

In gcc-style assembly, this is:

    .globl  f
f:
    bsfl    %edi, %eax
    ret

The input is given in the EDI register and returned in the EAX register as per standard 64-bit c calling conventions.
Because of two's complement binary encoding, this works for -ve as well as +ve numbers.
Also, despite the documentation saying "If the content of the source operand is 0, the content of the destination operand is undefined.", I find on my Ubuntu VM that the output of f(0) is 0.
Instructions:

Save the above as evenness.s and assemble with gcc -c evenness.s -o evenness.o
Save the following test driver as evenness-main.c and compile with gcc -c evenness-main.c -o evenness-main.o:

#include <stdio.h>

extern int f(int n);

int main (int argc, char **argv) {
    int i;

    int testcases[] = { 14, 20, 94208, 7, 0, -4 };

    for (i = 0; i < sizeof(testcases) / sizeof(testcases[0]); i++) {
        printf("%d, %d\n", testcases[i], f(testcases[i]));
    }

    return 0;
}

Then:

Link: gcc evenness-main.o evenness.o -o evenness
Run: ./evenness

@FarazMasroor asked for more details on how this answer was derived.
I am more familiar with c than the intricacies of x86 assembly, so typically I use a compiler to generate assembly code for me.  I know from experience that gcc extensions such as __builtin_ffs(), __builtin_ctz() and __builtin_popcount() typically compile and assemble to 1 or 2 instructions on x86.  So I started out with a c function like:

int f(int n) {
    return __builtin_ctz(n);
}

Instead of using regular gcc compilation all the way to object code, you can use the -S option to compile just to assembly - gcc -S -c evenness.c.  This gives an assembly file evenness.s like this:

    .file   "evenness.c"
    .text
    .globl  f
    .type   f, @function
f:
.LFB0:
    .cfi_startproc
    pushq   %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
    .cfi_def_cfa_register 6
    movl    %edi, -4(%rbp)
    movl    -4(%rbp), %eax
    rep bsfl    %eax, %eax
    popq    %rbp
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size   f, .-f
    .ident  "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4"
    .section    .note.GNU-stack,"",@progbits

A lot of this can be golfed out.  In particular we know that the c calling convention for functions with int f(int n); signature is nice and simple - the input param is passed in the EDI register and the return value is returned in the EAX register.  So we can take most of instructions out - a lot of them are concerned with saving registers and setting up a new stack frame.  We don't use the stack here and only use the EAX register, so don't need to worry about other registers.  This leaves "golfed" assembly code:

    .globl  f
f:
    bsfl    %edi, %eax
    ret

Note as @zwol points out, you can also use optimized compilation to achieve a similar result.  In particular -Os produces exactly the above instructions (with a few additional assembler directives that don't produce any extra object code.)
This is now assembled with gcc -c evenness.s -o evenness.o, which can then be linked into a test driver program as described above.
There are several ways to determine the machine code corresponding to this assembly.  My favourite is to use the gdb disass disassembly command:
$ gdb ./evenness
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
...
Reading symbols from ./evenness...(no debugging symbols found)...done.
(gdb) disass /r f
Dump of assembler code for function f:
   0x00000000004005ae <+0>: 0f bc c7    bsf    %edi,%eax
   0x00000000004005b1 <+3>: c3  retq
   0x00000000004005b2 <+4>: 66 2e 0f 1f 84 00 00 00 00 00   nopw   %cs:0x0(%rax,%rax,1)
   0x00000000004005bc <+14>:    0f 1f 40 00 nopl   0x0(%rax)
End of assembler dump.
(gdb)

So we can see that the machine code for the bsf instruction is 0f bc c7 and for ret is c3.


C++ x150 x450 x530

Instead of array I used bits (and dark magic).
Thanks @ace for the faster random function.

How does it work:
the first 15th bits of the integer s represent the array S[15]; the zeroes represent -1, the ones represent +1.
The array F is build in a similar way. But with two bit for each symbol.

00 represent -1
01 and 10 represent 0
11 represent 1

Cause S and F have a different representation I have to interleave S with itself to be comparable with F.

0 (-1) became 00 (-1 in the representation of F)
1 (+1) became 11 (+1 in the representation of F)

Now we can simply use Carnot to compute the inner product.
Remember that one variable can only assume value 00 or 11

0 . 00 = 11 (-1 * -1 = +1)
0 . 01 = 10 (-1 *  0 =  0)
0 . 10 = 01 (-1 *  0 =  0)
0 . 11 = 00 (-1 * +1 = -1)
1 . 00 = 00 (+1 * -1 = -1)
1 . 10 = 10 (+1 *  0 =  0)
1 . 01 = 01 (+1 *  0 =  0)
1 . 11 = 11 (+1 * +1 = +1)

Looks like a not xor to me. :)

Sum the ones is just a game of shift and mask, nothing really complex.

#include <array>
#include <ctime>

// From standford bithacks
// http://graphics.stanford.edu/~seander/bithacks.html
inline int32_t interleaveBit(int32_t x)
{
   static const uint32_t B[] = { 0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF };
   x = (x | ( x << 8)) & B[3];
   x = (x | ( x << 4)) & B[2];
   x = (x | ( x << 2)) & B[1];
   x = (x | ( x << 1)) & B[0];
   return x | (x << 1);
}

inline int32_t sumOnes(int32_t v)
{
   static int b[] = { 1, 0, 0, 1};
   int s = 0;
   for( int i = 0; i < 8; ++i)
   {
      const int a = 3&(v>>(i*2));
      s += b[a];
   }
   return s;
}

inline int32_t sumArray(int32_t v)
{
   static int b[] = { -1, 0, 0, 1};
   int s = 0;
   for( int i = 0; i < 8; ++i)
   {
      const int a = 3&(v>>(i*2));
      s += b[a];
   }
   return s;
}

uint32_t x, y = 24252, z=57768, w=1564; //PRNG seeds

int32_t myRand()
{
   uint32_t t;
   t = x ^ (x<<1);
   x = y;
   y = z;
   z = w;
   w = w ^ ( w >> 19) ^ t ^ (t >> 8);
   return w;
}

int main()
{
   std::array<int, 8> leadingZero{0};
   x = static_cast<int32_t>(time(nullptr)); // seed PRNG
   const int maxS = 1 << 15;
   for(int s = 0; s < maxS; ++s)
   {
      const int32_t x = interleaveBit(s);
      for(int i = 0; i < 1000; ++i)
      {
         int32_t random;
         do
         {
            random = 0xFFFF & myRand();
         }while(sumOnes(random) == 0);
         int j = 7;
         while( j >= 0 )
         {
            const int32_t h = (x >> (j*2));
            const int32_t l = 0xFFFF & (~(random ^ h)); // inner product
            if(sumArray(l) == 0)
            {
               leadingZero[j]++;
            } else
            {
               break;
            }
            j--;
         }

      }
   }
   for(int i = 7; i >= 0; --i)
   {
      printf("%d ", leadingZero[i]);
   }
   printf("\n");
   return 0;
}

Here a sample output:

6332350 2525218 1041716 438741 192917 87159 41023 19908

real 0m0.372s
user 0m0.371s
sys  0m0.001s

The program has been compiled with:

gcc -std=c++11 -O3 -msse4.2 -Wall -lstdc++ 26371.cpp -o fastPy

on Fedora 20 with gcc 4.8.2
The Cpu is a i7 8core.

Probably I can gain some ms tweaking compiler parameters.

While this is the OP solution time on my machine:

time pypy 26371.py
[6330609, 2523914, 1040885, 439303, 192708, 86987, 40710, 19498]

real 0m53.061s
user 0m53.016s
sys  0m0.022s

Edit:

Just adding openmp and change the order of the for I have a x3 gain, leading to a x450 performance improvement against OP code. :D
In this case the leadingZero array must be atomic. The random global... are random, they will be more random.

 #pragma omp parallel for
 for(int i = 0; i < 1000; ++i)
 {
    int32_t random;
    do
    {
       random = 0xFFFF & myRand();
    }while(sumOnes(random) == 0);
    for(int s = 0; s < maxS; ++s)
    {
       const int32_t x = interleaveBit(s);
       int j = 7;
       while( j >= 0 )
       {
          const int32_t h = (x >> (j*2));
          const int32_t l = 0xFFFF & (~(random ^ h)); // inner product
          if( sumArray(l) == 0 )
          {
             leadingZero[j]++;
          } else
          {
             break;
          }
          j--;
       }
    }
 }

need to add -fopenmp to the compiler flag

Edit:2
As suggester by user71404 I changed the sumOnes and sumArray functions and now it's uber fast.

real  0m0.101s
user  0m0.101s
sys   0m0.000s

With openmp is slower, cause the atomics add too much overhead.

real  0m0.253s
user  0m1.870s
sys   0m0.001s

Without atomics is even faster, but I get wrong result.

2137992 1147218 619297 321243 155815 70946 32919 15579

real   0m0.048s
user   0m0.338s
sys    0m0.001s

To understand sumArray consider that 16 bit represent and array of 8 numbers.
00 have no 1 and represent -1
01 and 10 have one 1 and represent 0
11 have two 1s and represent 1
So that built-in count the number of bit set to 1 [http://en.wikipedia.org/wiki/Hamming_weight] and to each group we remove 1. Cool.

sumOnes is just black magic.

Here the latest compile flags and code.

gcc -std=c++11 -mfpmath=sse -O3 -flto -march=native -funroll-loops -Wall -lstdc++

#include <cstdint>
#include <cstdio>
#include <ctime>

inline int32_t interleaveBit(int32_t x)
{
   static const uint32_t B[] = { 0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF };
   x = (x | ( x << 8)) & B[3];
   x = (x | ( x << 4)) & B[2];
   x = (x | ( x << 2)) & B[1];
   x = (x | ( x << 1)) & B[0];
   return x | (x << 1);
}

inline int32_t sumOnes(int32_t v)
{
   /* 0xAAAA == 0b1010 1010 1010 1010 */
   return !!(0xAAAA & (v ^ ~(v << 1)));
}

inline int32_t sumArray(int32_t v)
{
   return __builtin_popcount(v) - 8;
}

uint32_t x, y = 24252, z = 57768, w = 1564; //PRNG seeds

int32_t myRand()
{
   uint32_t t;
   t = x ^ (x << 1);
   x = y;
   y = z;
   z = w;
   w = w ^ ( w >> 19) ^ t ^ (t >> 8);
   return w;
}

int main()
{
   int leadingZero[8] = { 0 };
   x = static_cast<int32_t>(time(nullptr)); // seed PRNG
   const int maxS = 1 << 15;
   for( int i = 0; i < 1000; ++i )
   {
      int32_t random;
      do
      {
         random = 0xFFFF & myRand();
      } while(sumOnes(random) == 0 );
      for( int s = 0; s < maxS; ++s )
      {
         const int32_t x = interleaveBit(s);
         int j = 7;
         while( j >= 0 )
         {
            const int32_t h = (x >> (j * 2));
            const int32_t l = 0xFFFF & (~(random ^ h)); // inner product
            if( sumArray(l) == 0 )
            {
               leadingZero[j]++;
            } else
            {
               break;
            }
            j--;
         }
      }
   }
   printf("[%d, %d, %d, %d, %d, %d, %d, %d]\n",
      leadingZero[7], leadingZero[6],
      leadingZero[5], leadingZero[4],
      leadingZero[3], leadingZero[2],
      leadingZero[1], leadingZero[0]);
   return 0;
}


8086 machine code, 82 80

Contents of the x.com file:

B7 3D 89 DF B1 80 F3 AA 0D 0A 24 B4 01 CD 21 42
38 D8 74 F7 38 17 77 02 88 17 88 C3 31 D2 3C 0D
75 E9 BF 21 3D B1 5E 31 C0 F3 AE E3 EE 4F BB 04
01 8A 05 D4 0A 86 E0 0D 30 30 89 47 02 3C 30 77
04 88 67 03 43 89 3F 89 DA B4 09 CD 21 47 EB D7

It only supports repetitions of up to 99 characters.

Source code (served as input for the debug.com assembler), with comments!

a
    mov bh, 3d         ; storage of 128 bytes at address 3d00
    mov di, bx
    mov cl, 80
    rep stosb          ; zero the array
    db 0d 0a 24
; 10b
    mov ah, 1
    int 21             ; input a char
    inc dx             ; calculate the run length
    cmp al, bl         ; is it a repeated character?
    je  10b
    cmp [bx], dl       ; is the new run length greater than previous?
    ja  11a
    mov [bx], dl       ; store the new run length
; 11a
    mov bl, al         ; remember current repeating character
    xor dx, dx         ; initialize run length to 0
    cmp al, d          ; end of input?
    jne 10b            ; no - repeat
    mov di, 3d21       ; start printing run lengths with char 21
    mov cl, 5e         ; num of iterations = num of printable characters
; 127
    xor ax, ax
    repe scasb         ; look for a nonzero run length
    jcxz 11b           ; no nonzero length - exit
    dec di
    mov bx, 104        ; address of output string
    mov al, [di]       ; read the run length
    aam                ; convert to decimal
    xchg al, ah
    or  ax, 3030
    mov [bx+2], ax
    cmp al, 30         ; was it less than 10?
    ja  145
    mov [bx+3], ah     ; output only one digit
    inc bx             ; adjust for shorter string
; 145
    mov [bx], di       ; store "x=" into output string
    mov dx, bx         ; print it
    mov ah, 9
    int 21
    inc di
    jmp 127            ; repeat
; 150

rcx 50
n my.com
w
q

Here are some golfing techniques used here that I think were fun:

array's address is 3d00, where 3d is the ascii-code for =. This way, the address for array's entry for character x is 3d78. When interpreted as a 2-character string, it's x=.
Output buffer is at address 104; it overwrites initialization code that is no longer needed. End-of-line sequence 0D 0A 24 is executed as harmless code.
The aam instruction here doesn't provide any golfing, though it could...
Writing the number twice, first assuming it's greater than 10, and then correcting if it's smaller.
Exit instruction is at an obscure address 11b, which contains the needed machine code C3 by luck.


Retina, 95 bytes

Byte count assumes ISO 8859-1 encoding.

+`^((.+)¶(.+)¶(.+¶)*)(\w+ )?(void )(\w+)(..{.*})
$1$5final $2 $7=new $2(){public $6$3$8};
\w+¶

The code contains a trailing newline.

Takes input separated by newlines. Class name on the first line, inner method name on the second line, methods on following lines.
For example:

Hi
rand
private void method2(){return;}
protected int method3(){return 4;/*guaranteed to be random*/}
public void method1(){}
void method4(int param){}
void method5(){}

Try it online!


APL, 83 bytes

{0=⍴o←(,G)/Z←,⍳⍴G←⍵:0⋄1+∇G⊣{G[⊂⍵]←0⋄0=⍴A←G[A]/A←(A∊Z)/A←⍵∘+¨(+,-)↓∘.=⍨⍳3:⍬⋄∇¨A}⊃o}

Unlike some other languages, APL does not have a built-in for this (that I know of).

This function takes a 3-dimensional array of bits. It uses a 3-dimensional flood fill to remove blocks one by one, and counts how many blocks it can remove before the input is empty.

Non-golfed version with comments here.


CJam, 10 bytes

{"_~"+_}_~

Test it here.

Explanation

{"_~" e# Generalised quine framework, leaves the block and the string "_~"
      e# on the stack.
+     e# Prepend the block to the string.
_     e# Duplicate the resulting array.
}_~


SQL Server 2012+, 84 bytes
SELECT Round(Geometry::ConvexHullAggregate(Geometry::Point(x,y,0)).STArea(),0)FROM A

Makes use of the geometry functions and aggregates in SQL Server.
Coordindates are from table A with columns x and y.


Retina, 68 61 bytes

+`\b(\w+?)(?<!\b\1 .*)(\w+)$
$1 $2
(?=.* (.+)$(?<=\b\1 .+))
<empty>

<empty> is an empty line. Note the trailing space on line 3. You can run the above code from a single file with the -s flag.

Explanation

+`\b(\w+?)(?<!\b\1 .*)(\w+)$
$1 $2

This first step implements rules 1 to 6. It is a regex substitution which is applied repeatedly until the string stops changing (that's what the + is for). In each step we add a single space into the string from left to right (following the rules of the challenge). The regex matches the shortest string of digits which hasn't appeared in the already processed part of the string. We ensure that we're looking at a prefix of the remaining string with the word boundary \b and checking that we can reach the end of the string without passing spaces with (\w+)$. The latter also ensures that we only perform one replacement per step.

(?=.* (.+)$(?<=\b\1 .+))
<empty>

This matches any space (which is at the end of the regex), provided that the last segment of the string is the same as any other segment in the string, and replaces them with the empty string. That is, we undo the first step if it resulted in an invalid final segment, implementing rule 7.


Column-wise summation of overlapping slices

J, 11, 9 8 bytes

-1 byte thanks to miles!

[:+//.]\

How it works?

The left argument is s, the right one - L

]\ - splits L into sublists with length s

/. - extracts the oblique diagonals (anti-diagonals)

+/ - adds them up

[: - makes a fork from the above verbs

Here's an example J session for the first test case:

   a =. 1 2 3 4 5 6 7 8 9

   ] 3 ]\ a
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9

   ] </. 3 ]\ a
┌─┬───┬─────┬─────┬─────┬─────┬─────┬───┬─┐
│1│2 2│3 3 3│4 4 4│5 5 5│6 6 6│7 7 7│8 8│9│
└─┴───┴─────┴─────┴─────┴─────┴─────┴───┴─┘

   ] +//. 3 ]\ a
1 4 9 12 15 18 21 16 9

Try it online!


JavaScript (ES6), 213 bytes - 20% bonus = 170.4

s=>eval('for(p=o="";m=s.match(r="ﬄ|ﬃ|ﬂ|ﬁ|ﬀ|Ĳ|ĳ|Œ|œ|Æ|æ|ffl|ffi|fl|fi|ff|IJ|ij|OE|oe|AE|ae",x=r.split`|`);s=s.slice(i+t.length-(p=t<"z")))o+=s.slice(p,i=m.index)+x[(x.indexOf(t=m[0])+11)%22];o+s.slice(p)')

Explanation

s=>                           // s = input string
  eval(`                      // use eval to avoid writing {} or return
    for(                      // iterate over each ligature match
      p=                      // p = 1 if the last match was a non-unicode ligature
        o="";                 // o = output string
      m=s.match(              // find the next ligature

        // r = regex string for ligatures (unicode and non-unicode)
        r="ﬄ|ﬃ|ﬂ|ﬁ|ﬀ|Ĳ|ĳ|Œ|œ|Æ|æ|ffl|ffi|fl|fi|ff|IJ|ij|OE|oe|AE|ae",
        x=r.split\`|\`        // x = arrray of r

      );
      s=s.slice(i+t.length    // remove the part that has been added to the output
        -(p=t<"z"))           // if we matched a non-unicode ligature, keep the last
    )                         //     character so it can be part of the next match
      o+=s.slice(p,i=m.index) // add the text before the match to the output
        +x[(x.indexOf(        // add the opposite type of the matched ligature
          t=m[0]              // t = matched text
        )+11)%22];            // (index + 11) % 22 returns the opposite index
    o+s.slice(p)              // return o + any remaining characters
  `)

Test

var solution = s=>eval('for(p=o="";m=s.match(r="ﬄ|ﬃ|ﬂ|ﬁ|ﬀ|Ĳ|ĳ|Œ|œ|Æ|æ|ffl|ffi|fl|fi|ff|IJ|ij|OE|oe|AE|ae",x=r.split`|`);s=s.slice(i+t.length-(p=t<"z")))o+=s.slice(p,i=m.index)+x[(x.indexOf(t=m[0])+11)%22];o+s.slice(p)')
<input type="text" id="input" value="ﬀiffffij" oninput="result.textContent=solution(input.value)" />


Does the nth char equal the nth from last char?

JavaScript (ES6), 26 bytes

s=>n=>s[n]==s.substr(~n,1)

Alternatively:

s=>n=>s[n]==s.slice(~n)[0]

This one almost works, but fails when n == 0 (because s.slice(-1,0) == ""):

s=>n=>s[n]==s.slice(~n,-n)

Another 26-byte solution that @RickHitchcock pointed out:

s=>n=>s[n]==s[s.length+~n]


05AB1E, 11 9 bytes (Thanks to Adnan)

Dg2›iÇü‹Ù

Try it online!

Wavy Cases:

0 - Decreasing Wavy

1 - Increasing Wavy

Not Wavy Cases:

[0,1] - Not wavy, initially decreasing, but then has an increase/equality that broke the pattern.

[1,0] - Not wavy, initially increasing, but then has a decrease/equality that broke the pattern

Input String - Not possible to be wavy in the first place due to length.

Explanation:

Dg2›iÇü‹Ù   # Full program

D           # Push 2 copies of input.
 g2›i       # If length is greater than 2.
     Ç      # Push ASCII values for all characters in the string.
      ü     # Push pairwise array.
       ‹    # Vectorize 1 if negative difference, 0 if positive difference.
        Ù   # Uniquify using right most unique values first.
            # Else just print the string back, letting them know it's not valid input.


The Final Stand - Defeat the Zombie Horde

Java ( less grotesque: 8415 5291 3301)
Ok. Basically, I'm embarrassed no-one has submitted a solution. So a few days ago I began trying to solve this problem, b/c it's great.. Follow that link to watch my progress on it via GitHub.
Edit
New solver version, much more "golfed", with corrected cycle checker as identified by MT0. It also supports fast-forwarding routes, tuneable by changing how much memory is available to the VM. Latest BIG edit: realized that I had a few other small index errors and premature optimizations, that resulted in a failure to consider quite a large number of types of wins. So that's fixed, carefully. The new version is both smaller and below.
For our reference route, java -Xmx2GB ZombieHordeMin does the trick quite nicely (be warned, it will take a while).
Cool factoid
In a fascinating twist, there are MANY solutions at length 24, and my solver finds one different from MT0's, but identical in principle, except that it starts by visiting the the other outposts connected to 1. Fascinating! Totally counter human intuition, but perfectly valid.
Solution Highlights
So here's mine. It's (partially) golfed, b/c it's an exponential, almost-brute-force solver. I use an IDDFS (iterative deepening depth first search) algorithm, so it's a great general solver that doesn't skip, so it solves both parts of the OP's question, namely:

If a winning route is found (infinite zombies), output 'x'.
If all routes end in death (finite zombies), output the largest number of zombies killed.

Give it enough power, memory, and time, and it will do just that, even slow-death maps. I spent some more time improving this solver, and while more can be done, it's a bit better now. I also integrated MT0's advice on the best infinite-zombies solution, and removed several premature optimizations from my win-checker that prevented the previous version from finding it, and now I do in fact find a very similar solution to the one MT0 described.
A few other highlights:

As mentioned, uses an IDDFS to find the shortest possible winning route.
Since it is at core a DFS, it will also discover if every route ends in the death of our hero, and keeps track of the "best" route in terms of most zombies killed. Die a hero!
I've instrumented the algorithm to make it more interesting to watch Removed for golfing purposes. Follow one of the links to github to see the ungolfed version.
There are a number of comments throughout as well, so feel free to re-implement for your own solution building on my approach, or show me how it should be done!
Memory-adaptive route fast-forwarding

Up to available system memory, will keep track of "end routes" that did not result in death.
Using a fancy route compression and decompression routine, progress from a prior iteration of IDDFS is restored to prevent rediscovery all prior visited routes.
As an intentional side-bonus, acts as a dead-end route cull. Dead end routes aren't stored, and will never be visited again in future depths of IDDFS.

History of the solver

I tried a bunch of one-step look-ahead algorithms, and while for very simple scenarios they would work, ultimately they fall flat.
Then I tried a two-step look-ahead algorithm, which was.. unsatisfying.
I then began building an n-step lookahead, when I recognized that this approach is reducible to DFS, yet DFS is far ... more elegant.
While building the DFS, it occurred to me that IDDFS would ensure (a) find best HERO (death) route or (b) first winning cycle.
Turns out building a win-cycle checker is easy, but I had to go through several very very wrong iterations before I got to a provably successful checker.
Factored in MT0's win-path to remove three lines of premature optimization that made my algorithm blind to it.
Added an adaptive route-caching algorithm that will use all the memory you give it to prevent unnecessary redoing of work between IDDFS calls, and also culls dead-end routes up to the limits of memory.

The (golfed) code
On to the code (get the ungolfed version here or here):
import java.util.*;public class ZombieHordeMin{int a=100,b,m,n,i,j,z,y,D=0,R,Z,N;int p[][][];Scanner in;Runtime rt;int[][]r;int pp;int dd;int[][]bdr;int ww;int[][]bwr;int[][]faf;int ff;boolean ffOn;public static void main(String[]a){(new ZombieHordeMin()).pR();}ZombieHordeMin(){in=new Scanner(System.in);rt=Runtime.getRuntime();m=in.nextInt();N=in.nextInt();p=new int[m+1][m+1][N+1];int[]o=new int[m+1];for(b=0;b<N;b++){i=in.nextInt();j=in.nextInt();z=in.nextInt();o[i]++;o[j]++;D=(o[i]>D?o[i]:D);p[i][j][++p[i][j][0]]=z;if(i!=j)p[j][i][++p[j][i][0]]=z;D=(o[j]>D?o[j]:D);}m++;}void pR(){r=new int[5000][m+3];r[0][0]=a;Arrays.fill(r[0],1,m,1);r[0][m]=1;r[0][m+1]=0;r[0][m+2]=0;ww=-1;pp=dd=0;pR(5000);}void pR(int aMD){faf=new int[D][];ff=0;ffOn=true;for(int mD=1;mD<=aMD;mD++){System.out.printf("Checking len %d\n",mD);int k=ffR(0,mD);if(ww>-1){System.out.printf("%d x\n",ww+1);for(int win=0;win<=ww;win++)System.out.printf(" %d:%d,%d-%d",win,bwr[win][0],bwr[win][1],bwr[win][2]);System.out.println();break;}if(k>0){System.out.printf("dead max %d kills, %d steps\n",pp,dd+1);for(int die=0;die<=dd;die++)System.out.printf(" %d:%d,%d-%d",die,bdr[die][0],bdr[die][1],bdr[die][2]);System.out.println();break;}}}int ffR(int dP,int mD){if(ff==0)return pR(dP,mD);int kk=0;int fm=ff;if(ffOn&&D*fm>rt.maxMemory()/(faf[0][0]*8+12))ffOn=false;int[][]fmv=faf;if(ffOn){faf=new int[D*fm][];ff=0;}for(int df=0;df<fm;df++){dS(fmv[df]);kk+=pR(fmv[df][0],mD);}fmv=null;rt.gc();return kk==fm?1:0;}int pR(int dP,int mD){if(dP==mD)return 0;int rT=0;int dC=0;int src=r[dP][m];int sa=r[dP][0];for(int dt=1;dt<m;dt++){for(int rut=1;rut<=p[src][dt][0];rut++){rT++;r[dP+1][0]=sa-p[src][dt][rut]+r[dP][dt];for(int cp=1;cp<m;cp++)r[dP+1][cp]=(dt==cp?1:r[dP][cp]+1);r[dP+1][m]=dt;r[dP+1][m+1]=rut;r[dP+1][m+2]=r[dP][m+2]+p[src][dt][rut];if(sa-p[src][dt][rut]<1){dC++;if(pp<r[dP][m+2]+sa){pp=r[dP][m+2]+sa;dd=dP+1;bdr=new int[dP+2][3];for(int cp=0;cp<=dP+1;cp++){bdr[cp][0]=r[cp][m];bdr[cp][1]=r[cp][m+1];bdr[cp][2]=r[cp][0];}}}else{for(int chk=0;chk<=dP;chk++){if(r[chk][m]==dt){int fR=chk+1;for(int cM=0;cM<m+3;cM++)r[dP+2][cM]=r[dP+1][cM];for(;fR<=dP+1;fR++){r[dP+2][0]=r[dP+2][0]-p[r[dP+2][m]][r[fR][m]][r[fR][m+1]]+r[dP+2][r[fR][m]];for(int cp=1;cp<m;cp++)r[dP+2][cp]=(r[fR][m]==cp?1:r[dP+2][cp]+1);r[dP+2][m+2]=r[dP+2][m+2]+p[r[dP+2][m]][r[fR][m]][r[fR][m+1]];r[dP+2][m]=r[fR][m];r[dP+2][m+1]=r[fR][m+1];}if(fR==dP+2&&r[dP+2][0]>=r[dP+1][0]){ww=dP+1;bwr=new int[dP+2][3];for(int cp=0;cp<dP+2;cp++){bwr[cp][0]=r[cp][m];bwr[cp][1]=r[cp][m+1];bwr[cp][2]=r[cp][0];}return 0;}}}dC+=pR(dP+1,mD);if(ww>-1)return 0;}for(int cp=0;cp<m+3;cp++)r[dP+1][cp]=0;}}if(rT==dC)return 1;else{if(ffOn&&dP==mD-1)faf[ff++]=cP(dP);return 0;}}int[]cP(int dP){int[]cmp=new int[dP*2+3];cmp[0]=dP;cmp[dP*2+1]=r[dP][0];cmp[dP*2+2]=r[dP][m+2];for(int zip=1;zip<=dP;zip++){cmp[zip]=r[zip][m];cmp[dP+zip]=r[zip][m+1];}return cmp;}void dS(int[]cmp){int[]lv=new int[m];int dP=cmp[0];r[dP][0]=cmp[dP*2+1];r[dP][m+2]=cmp[dP*2+2];r[0][0]=100;r[0][m]=1;for(int dp=1;dp<=dP;dp++){r[dp][m]=cmp[dp];r[dp][m+1]=cmp[dP+dp];r[dp-1][cmp[dp]]=dp-lv[cmp[dp]];r[dp][m+2]=r[dp-1][m+2]+p[r[dp-1][m]][cmp[dp]][cmp[dP+dp]];r[dp][0]=r[dp-1][0]+r[dp-1][cmp[dp]]-p[r[dp-1][m]][cmp[dp]][cmp[dP+dp]];lv[cmp[dp]]=dp;}for(int am=1;am<m;am++)r[dP][am]=(am==cmp[dP]?1:dP-lv[am]+1);}}

Get the code from github here, to track any changes I make. Here are some other maps I used.
Output example
Example output for reference solution:
    $ java -d64 -Xmx3G ZombieHordeMin > reference_route_corrected_min.out
    5 6 1 2 4 2 3 4 3 1 4 2 4 10 2 5 10 1 1 50
    Checking len 1
    Checking len 2
    Checking len 3
    Checking len 4
    Checking len 5
    Checking len 6
    Checking len 7
    Checking len 8
    Checking len 9
    Checking len 10
    Checking len 11
    Checking len 12
    Checking len 13
    Checking len 14
    Checking len 15
    Checking len 16
    Checking len 17
    Checking len 18
    Checking len 19
    Checking len 20
    Checking len 21
    Checking len 22
    Checking len 23
    Checking len 24
    25 x
     0:1,0-100 1:3,1-97 2:1,1-95 3:2,1-94 4:5,1-88 5:2,1-80 6:4,1-76 7:2,1-68 8:1,1-70 9:2,1-68 10:1,1-66 11:2,1-64 12:1,1-62 13:2,1-60 14:1,1-58 15:2,1-56 16:1,1-54 17:2,1-52 18:1,1-50 19:2,1-48 20:1,1-46 21:2,1-44 22:1,1-42 23:2,1-40 24:1,1-38

Read the route output like this: step:source,route-to-get-here-ammo. So in the above solution, you would read it as:

At step 0, at outpost 1 with ammo 100.
At step 1, use route 1 to get to outpost 3 with ending ammo 97
At step 2, use route 1 to get to outpost 1 with ending ammo 95
...

Closing notes
So, I hope I've made my solution harder to beat, but PLEASE TRY! Use it against me, add in some parallel processing, better graph theory, etc. A couple of things I figure could improve this approach:

aggressively "reduce" loops to cut out needless retread as the algorithm progresses.

An example: in the example problem, consider the loops 1-2-3 and other permutations as "one step", so that we can make our way to end-cycle more quickly.
E.g. if you are at node 1, you can either (a) go to 2, (b) go to 1, (c) go through 1-2-3 as one step and so on. This would allow a solved to fold depth into breadth, increasing the number of routes at a particular depth but greatly speeding time-to-solution for long cycles.

cull dead routes. My current solution doesn't "remember" that a particular route is dead-ended, and has to rediscover it every time. It would be better to keep track of the earliest moment in a route that death is certain, and never progress beyond it. did this...
if careful, you could apply the dead route culling as a sub-route cull. By example, if 1-2-3-4 always results in death, and the solver is about to test the route 1-3-1-2-3-4, it should immediately stop descending that path as it is guaranteed to end in disappointment. It would still be possible to calculate # of kills, with some careful math.
Any other solution that trades memory for time, or allows aggressive avoidance of following dead-end routes. did this too!


Find a numeric coincidence when representing numbers in various bases

Python 2, 158 bytes

Came a bit too easily, so I might be missing something obvious!

s=lambda n,b:(n/b and s(n/b,b)or'')+chr(48+n%b+39*(n%b>9))
def f(a,b,c):
 for n in range(b,36**4):
  x=s(n,a);y=s(n,b)
  if int(x,b)==int(y,c):print x,y;break

The base conversion function is lovingly stolen from @ugoren's solution to Print integers in any base up to 36. The code simply tries all possible values for the smaller number and the rest is fully determined. We start counting from base2 to ensure both sequences are at least length 2.

>>> f(8, 10, 16)
100 64
>>> f(8, 10, 17)
>>> f(16, 20, 24)
20 1c


C, 61 62 chars

i;main(){write(1,"Hello World\n"+i++,1);i>13||fork()||main();}

The pthread library functions all have loooooong names, so instead I fired up an entire separate process for each character. fork() is so much shorter.

It was necessary to use write() instead of putchar() because the stdio buffering functions are not thread-safe.

Edited: Back up to 62 chars. In my zeal, dropping down to 61 chars also dropped the thread-safety.


05AB1E, 26 21 bytes

None: 0
 Cube: 1
 Regular Domino Cuboid: 2
 Shapeshifter Cuboid: 3
 Brick Cuboid: 4
 Floppy Cuboid: 5

•S3X@I¨%÷'•5L¦3ãPÙIkè

Try it online!
or as a Test suite

Explanation

•S3X@I¨%÷'•            # push base-214 compression of the number 123224454212324512210
           5L¦         # push the list [2,3,4,5]
              3ã       # cartesian product with repetion of size 3
                P      # product of each sublist
                 Ù     # remove duplicates
                  Ik   # get the index of input in that list (-1 if non-existant)
                    è  # get the element at this index in the above number

The only place I see that we could save bytes here is find a better way of generating the number 123224454212324512210.

It is only 1-off from a prime, so one possible save would be to find the index of that prime and generate the index in less than 9 bytes.
I don't know how well the pi-function works for 21-digit primes but that could be a possibility.


Find pairs of numbers with a particular LCM and GCD

Mathematica, 8 bytes

{4,5092}

Proof that 4 and 5092 are the only solutions: The original problem can be rewritten as

  x (x + 2010) = 2014 GCD(x, x+2010)2

Let's write x as 2a2 3a3 5a5… and x + 2010 as 2b2 3b3 5b5… Then the equation becomes

  2a2+b2 3a3+b3 5a5+b5… = 2014 22min(a2,b2) 32min(a3,b3) 52min(a5,b5)…

Since 2014 = 2 × 19 × 53, we have

  ap + bp = 2min(ap, bp) + { 1 if p ∈ {2, 19, 53}, 0 else }

Thus

  ap = bp if p ≠ 2, 19, 53
  ap = bp±1 else

Thus

  x + 2010 = 2±1 19±1 53±1 x

There are only 8 possible choices, and we could easily check that 4 and 5092 are the only positive integer solutions.

Wait, I hear people screaming standard loophole…

Mathematica, 45 bytes

Select[Range[9^7],2014GCD[#,s=#+2010]^2==s#&]


MATL, 8 bytes
t2L)P5M(

Try it online! Or verify all test cases.
Explanation
t     % Implicit input. Duplicate
      % STACK: 'abcdefghi', 'abcdefghi'
2L    % Push [2, 2, 1j]. This represents 2:2:end when used as an index
      % STACK: 'abcdefghi', 'abcdefghi', [2, 2, 1j]
)     % Get entries at those indices
      % STACK: 'abcdefghi', 'bdfh'
P     % Flip
      % STACK: 'abcdefghi', 'hfdb'
5M    % Push [2, 2, 1j] again
      % STACK: 'abcdefghi', 'hfdb', [2, 2, 1j]
(     % Write entries at those indices. Implicit display
      % STACK: 'ahcfedgbi'


JavaScript (ES6), 276 228 125 117 105 bytes
a=>btoa`i·yø!9%z)ª»-ºü1j;ÝÈ%¥·¡ªÜ"·ç¹Ê1`.replace(/.../g,b=>(a[b[0]]+a[b[1]]+a[b[2]])/3&1||'').length

(the above contains some unprintable ascii characters that won't show up here, so here's a version without the btoa that can be copied and run)
a=>'abcdefghijklmnopqrstuvwxajvdksglpbehqtwimrfnucox'.replace(/.../g,b=>(a[b[0]]+a[b[1]]+a[b[2]])/3&1||'').length

Breaks a reference string into letter triplets that match up with mill group keys. Input is in the form of an object, where keys are the letters a-x, starting from the bottom left and ending in the top right, moving left-to-right first. Values are 1 for white, -1 for black, and 0 for blank.
Example
{b:1,d:-1,e:1,f:-1,i:1,k:-1,l:-1,m:1,n:-1,r:1,u:-1} => 2
{j:1,d:-1,k:-1,l:-1,b:1,e:1,i:1,m:1,r:1,f:-1,n:-1,u:-1,o:1} => 2
{a:-1,j:-1,v:-1,k:-1,l:-1,h:1,e:1,b:1} => 3
{} => 0
{k:-1,j:-1,l:1} => 0
{k:-1,j:-1,l:1} => 1
{a:-1,j:-1,v:-1,d:-1,k:-1,s:-1,g:-1,l:-1,p:-1,i:1,m:1,r:1,f:1,n:1,u:1,c:1,o:1,x:1} => 8

These examples are taken from OP's examples, converted to the letter-key and number-value object. The first is from the example image, while the others are from the example set.


Husk, 12 bytes

↔↑ṁe"|"¡Θ" /

Try it online!

Builds the infinite triangle upside-down, then takes the required number of lines and reverses them before printing.

Explanation

↔↑ṁe"|"¡Θ" /
       ¡        Repeat and accumulate results:
        Θ          prepend a space
         " /       starting from the string " /"
                   (this will create all the lines of the slanted side)
  ṁ             For each line:
   e"|"            put it in a list with a "|" line
  ṁ             and merge all these lists together
 ↑              Take the number of lines required by the input
↔               Reverse the result


MATLAB, 1960 bps

Here is my updated attempt:

fs = 44100; %44.1kHz audio rate
fc = 2450;  %2.45kHz carrier - nice fraction of fs!
fsym = fc/5; %symbol rate

tmax = 4; %about 4 seconds worth

preamblesyms = 6;

t = 1/fs:1/fs:(tmax+preamblesyms/fsym);

symbols = preamblesyms+fsym*tmax;
symbollength = length(t)/symbols;
bits = symbols*3;
bitstream = [zeros(1,preamblesyms*3),rand(1,bits-preamblesyms*3)>0.5]; %Add a little preamble of 18 bits
data = bin2dec(char(reshape(bitstream,3,symbols)'+'0'))';

greycode = [0 1 3 2 6 7 5 4];

%Encode the symbols using QAM8 - we use effectively grey code so that
%adjacent symbols in the constellation have only one bit difference
%(minimises error rate)
encoded = zeros(2,symbols);
encoded(1,data==1) = 1/sqrt(2);
encoded(1,data==3) = 1;
encoded(1,data==2) = 1/sqrt(2);
encoded(1,data==7) = -1/sqrt(2);
encoded(1,data==5) = -1;
encoded(1,data==4) = -1/sqrt(2);
encoded(2,data==0) = 1;
encoded(2,data==1) = 1/sqrt(2);
encoded(2,data==2) = -1/sqrt(2);
encoded(2,data==6) = -1;
encoded(2,data==7) = -1/sqrt(2);
encoded(2,data==4) = 1/sqrt(2);

%Modulate onto carrier
carrier = [sin(2*pi*fc*t);cos(2*pi*fc*t)];
signal = reshape(repmat(encoded(1,:)',1,symbollength)',1,[]);
signal(2,:) = reshape(repmat(encoded(2,:)',1,symbollength)',1,[]);
modulated = sum(signal.*carrier)';

%Write out an audio file
audiowrite('audio.wav',modulated,fs);

%Wait for the user to run through the POTS simulator
input('');

%Read in the filtered data
filtered=audioread('audio.pots-filtered.wav')';

%Recover the two carrier signals
preamblecos = filtered(symbollength+1:symbollength*2);
preamblesin = filtered(symbollength+1+round(symbollength*3/4):symbollength*2+round(symbollength*3/4));

%Replicated the recovered carriers for all symbols
carrierfiltered = [repmat(preamblesin,1,symbols);repmat(preamblecos,1,symbols)];

%Generate a demodulation filter (pass up to 0.66*fc, stop at 1.33*fc
%(really we just need to kill everything around 2*fc where the alias ends up)
d=fdesign.lowpass('Fp,Fst,Ap,Ast',0.05,0.1,0.5,60);
Hd = design(d,'equiripple');

%Demodulate the incoming stream
demodulated = carrierfiltered .* [filtered;filtered];
demodulated(1,:)=filtfilt(Hd.Numerator,1,demodulated(1,:));
demodulated(2,:)=filtfilt(Hd.Numerator,1,demodulated(2,:));

%Split signal up into bit periods
recovereddemodulated=[];
recovereddemodulated(1,:,:) = reshape(demodulated(1,:),symbollength,symbols);
recovereddemodulated(2,:,:) = reshape(demodulated(2,:),symbollength,symbols);

%Extract the average level for each bit period. Only look at the second
%half to account for slow rise times in the signal due to filtering
recoveredsignal=mean(recovereddemodulated(1,round(symbollength/2):symbollength,:));
recoveredsignal(2,:)=mean(recovereddemodulated(2,round(symbollength/2):symbollength,:));

%Convert the recovered signal into a complex number.
recoveredsignal=recoveredsignal(2,:) + 1j*recoveredsignal(1,:);

%Determine the magnitude and angle of the symbol. The phase is normalised
%to pi/4 as that is the angle between the symbols. Rounding this to the
%nearest integer will tell us which of the 8 phases it is closest to
recoveredphase = round(angle(recoveredsignal)/(pi/4));
recoveredphase = mod(recoveredphase+8,8)+1; %Remap to an index in the grey code vector.

%Determine the symbol in the QAM8 constellation
recoveredencoded=greycode(recoveredphase);
recoveredencoded(1:preamblesyms)=0; %Assume the preamble is correct for comparison

%Turn it back in to a bit stream
bitstreamRecovered = reshape(dec2bin(recoveredencoded)'-'0',1,[]);

%And check if they are all correct...
if(all(bitstream==bitstreamRecovered))
    disp(['Woop, ' num2str(fsym*4) 'bps']);
else
    error('Its corrupt Jim.');
end

Since my first attempt, I have played around a bit. There is now a small preamble at the beginning (18 bit periods, but could be shorter) which contains just a cosine wave. I extract this and replicated it to create correctly phased sine and cosine carriers for demodulation - as it is a very short preamble, I haven't counted it in the bit rate as per your instructions.

Also since the first attempt I am now using a QAM8 constellation to achieve 3 bits per symbol instead of 2. This effectively doubles the transfer rate. So with a ~2.4kHz carrier I am now achieving 1960bps.

I've also improved the symbol detection so that the averaging doesn't get affected by slow rise times caused by the filtering - basically only the second half of each bit period is averaged to remove the impact of rise times.

Still nowhere near the 40kbps theoretical channel bandwidth from the Shannon-Hartley theory (assuming the 30dB SNR)

Just for those that like horrible sounds, this is the new entry:

And in case anyone is interested, this is the previous 960bps entry


Retina, 14 bytes
a`.((.) \2)*.|

Try it online!
Explanation
a forces the match to be on the entire string
.((.) \2)*. just means any character (.) followed by a captured group repeated 0 to many times ((...)*) of any character saved into a second captured group ((.)) followed by a space and the same character that was matched in the second capture group (\2). The final . just matches the last character
| allows the empty string to match by having an alternative match of the empty string


Digit sum of central binomial coefficients

C++ (GMP) - (287,000,000 / 422,000) = 680.09

Shamelessly combine Kummer's Theorem by xnor and GMP by qwr.
Still not even close to the Go solution, not sure why.

Edit: Thanks Keith Randall for the reminder that multiplication is faster if the number is similar in size. I implemented multi-level multiplication, similar to memory coalescing concept on memory management. And the result is impressive. What used to take 51s, now takes only 0.5s (i.e., 100-fold improvement!!)

OLD CODE (n=14,000,000)
Done sieving in 0.343s
Done calculating binom in 51.929s
Done summing in 0.901s
14000000: 18954729

real    0m53.194s
user    0m53.116s
sys 0m0.060s

NEW CODE (n=14,000,000)
Done sieving in 0.343s
Done calculating binom in 0.552s
Done summing in 0.902s
14000000: 18954729

real    0m1.804s
user    0m1.776s
sys 0m0.023s

The run for n=287,000,000

Done sieving in 4.211s
Done calculating binom in 17.934s
Done summing in 37.677s
287000000: 388788354

real    0m59.928s
user    0m58.759s
sys 0m1.116s

The code. Compile with -lgmp -lgmpxx -O3

#include <gmpxx.h>
#include <iostream>
#include <time.h>
#include <cstdio>

const int MAX=287000000;
const int PRIME_COUNT=15700000;

int primes[PRIME_COUNT], factors[PRIME_COUNT], count;
bool sieve[MAX];
int max_idx=0;

void run_sieve(){
    sieve[2] = true;
    primes[0] = 2;
    count = 1;
    for(int i=3; i<MAX; i+=2){
        sieve[i] = true;
    }
    for(int i=3; i<17000; i+=2){
        if(!sieve[i]) continue;
        for(int j = i*i; j<MAX; j+=i){
            sieve[j] = false;
        }
    }
    for(int i=3; i<MAX; i+=2){
        if(sieve[i]) primes[count++] = i;
    }
}

mpz_class sum_digits(mpz_class n){
    clock_t t = clock();
    char* str = mpz_get_str(NULL, 10, n.get_mpz_t());
    int result = 0;
    for(int i=0;str[i]>0;i++){
        result+=str[i]-48;
    }
    printf("Done summing in %.3fs\n", ((float)(clock()-t))/CLOCKS_PER_SEC);
    return result;
}

mpz_class nc2_fast(const mpz_class &x){
    clock_t t = clock();
    int prime;
    const unsigned int n = mpz_get_ui(x.get_mpz_t());
    const unsigned int n2 = n/2;
    unsigned int m;
    unsigned int digit;
    unsigned int carry=0;
    unsigned int carries=0;
    mpz_class result = 1;
    mpz_class prime_prods = 1;
    mpz_class tmp;
    mpz_class tmp_prods[32], tmp_prime_prods[32];
    for(int i=0; i<32; i++){
        tmp_prods[i] = (mpz_class)NULL;
        tmp_prime_prods[i] = (mpz_class)NULL;
    }
    for(int i=0; i< count; i++){
        prime = primes[i];
        carry=0;
        carries=0;
        if(prime > n) break;
        if(prime > n2){
            tmp = prime;
            for(int j=0; j<32; j++){
                if(tmp_prime_prods[j] == NULL){
                    tmp_prime_prods[j] = tmp;
                    break;
                } else {
                    mpz_mul(tmp.get_mpz_t(), tmp.get_mpz_t(), tmp_prime_prods[j].get_mpz_t());
                    tmp_prime_prods[j] = (mpz_class)NULL;
                }
            }
            continue;
        }
        m=n2;
        while(m>0){
            digit = m%prime;
            carry = (2*digit + carry >= prime) ? 1 : 0;
            carries += carry;
            m/=prime;
        }
        if(carries>0){
            tmp = 0;
            mpz_ui_pow_ui(tmp.get_mpz_t(), prime, carries);
            for(int j=0; j<32; j++){
                if(tmp_prods[j] == NULL){
                    tmp_prods[j] = tmp;
                    break;
                } else {
                    mpz_mul(tmp.get_mpz_t(), tmp.get_mpz_t(), tmp_prods[j].get_mpz_t());
                    tmp_prods[j] = (mpz_class)NULL;
                }
            }
        }
    }
    result = 1;
    prime_prods = 1;
    for(int j=0; j<32; j++){
        if(tmp_prods[j] != NULL){
            mpz_mul(result.get_mpz_t(), result.get_mpz_t(), tmp_prods[j].get_mpz_t());
        }
        if(tmp_prime_prods[j] != NULL){
            mpz_mul(prime_prods.get_mpz_t(), prime_prods.get_mpz_t(), tmp_prime_prods[j].get_mpz_t());
        }
    }
    mpz_mul(result.get_mpz_t(), result.get_mpz_t(), prime_prods.get_mpz_t());
    printf("Done calculating binom in %.3fs\n", ((float)(clock()-t))/CLOCKS_PER_SEC);
    return result;
}

int main(int argc, char* argv[]){
    const mpz_class n = atoi(argv[1]);
    clock_t t = clock();
    run_sieve();
    printf("Done sieving in %.3fs\n", ((float)(clock()-t))/CLOCKS_PER_SEC);
    std::cout << n << ": " << sum_digits(nc2_fast(n)) << std::endl;
    return 0;
}


K, 196 215 240 (40 points)

When reduced to a single line it's 240 chars but I've added newlines here for readability. The question doesn't state exactly what the output needs to look like so I've come up with something fairly minimal.

r:0#t:#[c:#w:_0:0;"?"]
a:_:'0:`a;
l:8;
while[~(l=0)|(c=0);
  q:{x@&~x in y}[>#:'=,/a:a@&a like\:t;r];
  if[1=#a;-1 a;j:-1"WIN";exit 0];
  -1"Guess ",u:*q;
  r,:u;
  $[|/u=w;[c-:+/u=w;@[`t;&u=w;:;u]];-1($l-:1)," lives remaining"];
  -1 t;
  $[0=l;-1"LOSE";0=c;j;]]

The wordlist is a file called a in same directory as the code.

$ q hm.k -q
engineer
Guess e
e????ee?
Guess s
7 lives remaining
e????ee?
Guess i
e??i?ee?
engineer
WIN

EDIT: It now reanalyses the word on each step and determines which is the most likely letter based on previous guesses.

EDIT2: If there is only one possible answer (after reanalysis) the computer wins, rather than continuing to guess each individual letter


JavaScript, 134 129 113 bytes

setInterval("d=-new Date;document.body.innerHTML=`<pre>${d/864e5+17986|0}:`+new Date(d).toJSON().slice(11,19)",1)

Edit: Saved 2 bytes thanks to @Shaggy. Saved 11 bytes thanks to @l4m2.


Python 3 - multicore or go home

# The venerable C atoi function hails from a more innocent time. These days,
# we have multicore processors and programs must adapt or be left behind.
import re
import multiprocessing as mp

def atoi(a):
    m = re.match(r"^\s*(-?)(\d+).*$", a)
    if m is None:
        raise ValueError(a)
    sign = -(m.group(1) == "-") * 2 + 1
    places = enumerate(reversed(bytes(m.group(2), "ascii")))
    with mp.Pool(processes=mp.cpu_count()) as pool:
        return sign * sum(pool.map(_digit, places))

def _digit(t):
    i, b = t
    return 10 ** i * (b - 48)

if __name__ == '__main__':
    import unittest
    error_case = unittest.TestCase().assertRaises(ValueError)
    assert atoi(" -4555553") == -4555553
    assert atoi("1") == 1
    assert atoi("    0") == 0
    assert atoi("100asdf") == 100
    assert atoi("-5") == -5
    assert atoi("1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz") == 1
    assert atoi("1.2") == 1
    with error_case:
        atoi("foobar")
    with error_case:
        atoi("a1234")

Now I have 2 + cpu_count() problems.