Dyalog APL, 166 bytes
{l←!!5*≢⍵⋄z←⊂''⋄n←,∘.,⍨⋄k←{⊃,/n\l/⊂⍵}⋄f←{⊃⊃{⍺∊';|':(2↓⍵),⍨⍺{';'=⍺:n/⍵⋄,/⍵}2↑⍵⋄⍺='_':⍵,⍨⊂z⋄'+'=⍺:⊂∘k∘⊃@1,⍵⋄⍺,⍵}/⌽1,⍵}⋄w←f⍵⋄⊃q/⍨{0=≢((z,k'01')~w∪f⍵)∪w∩f⍵}¨q←k'10!_|;+'}

The solution is a function that works by brute-forcing. It cannot be run in reasonable time nor with reasonable memory on any of the inputs, so no TIO link is provided; this is due to looping over every possible regex over the factorial of the factorial of 5 to the power of the input length. Note that the numbers involved go out of Dyalog's maximum number size for an input regex of length greater than 1. To test this, take a look at the function f, which returns a value that includes all matches less than the calculated upper bound l, and test it on the complementarity check {0=≢ ... ⍵∩f⍵}. Using smaller values of l can make the function provide wrong results, so note that before reducing its value.

There is an upper bound for the minimum length of the complementary regex as a function of the length of the input regex, and an upper bound for the length of the longest string the two regexes need to be tested against to determine their complementarity. These parameters are used to brute force the complementary regex, by comparing the strings accepted by the input regex and the regex being tested for complementarity.
We start by comparing the length of a regular expression to the number of states of its respective DFA.
The non-deterministic finite automaton (NFA) for the regex 1 is the following (using (Sn) to denote accepting states)
   1
Si-->(Sf)

The regex _ representing an \$\epsilon\$-transition can be represented by an NFA that has less than 2 states, as can the regex ! representing non-acceptance.
 _

(Si)

 !

Si

Thus, a regex with only characters from 01_! with length n will have an NFA with max size n+1.
The regex ab;, where a and b are sub-regexes, denotes the concatenation of a and b and can be described as the following. (Si# denotes an initial state and (S##) denotes a final state.)
  Si1-->...-->(Sf1)   Si2-->...-->(Sf2)    ;

                     ε
NFA= Si1-->...-->Sf1-->Si2-->...-->(Sf2)

The regex a+ denotes one or more occurrences of a.
  Si1-->...-->(Sf1)   +

            ε
      +------------+
      v            |
NFA= Si1-->...-->(Sf1)

This produces an NFA with the same size as that of a. Again, a regex with only characters from 01_!; with length n will have an NFA with max size n+1.
The regex ab| denotes an alternative of either a or b.
  Si1-->...-->(Sf1)   |   Si2-->...-->(Sf2)

      Si1-->...-->(Sf1)
NFA=
      Si2-->...-->(Sf2)

Both Si1 and Si2 are starting states in the above NFA. This does not fit the traditional definition of an NFA, where an NFA has only 1 starting state, but the size of the resulting deterministic finite automaton (DFA) does not increase. If needed, the NFA for + can be changed so that there is an ε-transition from the final state to the second state, and the NFAs for _ and ! changed to have 2 states each, so that a traditional NFA can be constructed for alternation with ε-transitions between Si1 and Si2.
An NFA resulting from alternation will be as large as the sum of the two sub-regexes that make it up. A regex of length n will have an NFA with a maximum size of n+1.
By the powerset construction, an NFA with size \$n\$ will result in a DFA with size \$2^n\$. So a regex of length \$n\$ will have a minimal DFA upper-bounded by \$2^{n+1}\$. A DFA can be inverted by simply switching the final and non-final states, so its complement will have the same number of states as itself.
With this information, we need an upper limit on the size of the complementary regex as a function of the length of the number of states of the DFA. To do this, I use an algorithm to convert a DFA to a regex; the idea is to represent every possible path from Si to any other state, as well as accounting for loops by tracking every loop that starts and ends at Si, in a recursive manner. For every state that can be reached in 1 step from Si, the process is repeated and a path is constructed from this new state to every other state except the states that have already been encountered, i.e. Si in the first iteration, since loops back to Si would already be covered by tracking loops. An example of the construction can make this clearer.
0<c0>;1<c1>;|+_|
0<r0>;1<r1>;<a>||
;

This is a regex that represents a DFA that I will call the "base form". The base form for a state is a regex that traverses paths from that state to every state in the DFA except for, as we will see, states that have been explicitly excluded for a particular iteration. The accept/reject status of each path is denoted by <a>, being _ for accept or ! for reject. The second line of the regex accounts for this "breadth-first" filling, by transitioning to states that are 1 step way, and recursing the base form (as represented by <r0> and <r1>) on those states. Each time we recurse, we exclude the original "parent" state from the graph traversal to prevent the algorithm from infinitely looping. Loops in the regex are tracked in the first line, where, also, every possible path is traversed, halting when reaching the parent state, but these sub-regexes, as denoted by <c0> and <c1>, consider only the parent state to be the accepting state.
At each level of recursion, the number of excluded states increases by 1, until every possible state is covered at which point the algorithm ends.
The base form, without the recursive parts, is of length 16. Each iteration spawn 4 new sub-regexes, and there are as many iterations as states in the DFA.
If a DFA has n states, an upper bound for the regex length is \$16 + 16×4 + 16×4×4 + ... + 16×4^{n-1}\$. This is a geometric series and can also be written as
$$\frac{16}{3}\left(4^n-1\right)$$
Now given a regex with length s, the length of its complement is bounded by
$$h=\frac{16}{3}\left(4^{2^{n+1}}-1\right)$$
(I felt that this upper bound could be improved to a mere exponential instead of a double exponential, potentially saving some bytes, but I was proven wrong by this answer.)
We can check if two regexes are equivalent by brute force, but to do that we need to know the upper limit of the input length to test. If the DFAs of the two regexes are a and b, we can construct another DFA c whose states are the Cartesian product of the states of a and b, so each state of DFA c can be labeled as a 2-tuple (a_j,b_k) where a_j and b_k are states of DFA a and b respectively. The transition of DFA c's state (a_j,b_k) under input letter l is the tuple of the transition of each state a_j and b_k in DFAs a and b respectively under letter l. The final states of DFA c are all the states (a_j,b_k) where either both a_j and b_k are final states or they are both non-final states. DFA c accepts a word if both DFAs a and b accept this word, i.e. DFAs a and b do not yield complementary results on this word. DFAs a and b are complementary iff DFA c does not accept any word. By the pumping lemma, to check for this, we only need to check of input word sizes up to the number of states of DFA c, minus 1.
The size of the DFA of the complementary regex is 2^(h+1) and that of the input regex is 2^(n+1). Thus we only need to check for input lengths up to 2^(h+1)×2^(n+1)-1.
$$2^{\frac{16}{3}\left(4^{2^{n+1}}-1\right)+1+n+1}-1$$
We need to find a golfy way to write a function that is always greater than the triple exponential above for n≥1. Factorials grow faster than exponentials and are 1 byte shorter and so can be useful. However, the factorial of 1 is still 1, so we cannot simply chain 3 factorials together. The first function can instead be an exponential b*n, APL for b to the power of n, after which two factorials can be added in place of the remaining double exponential, yielding !!b*n. \$b=3\$ is too small for the base case of n=1, \$b=4\$ is slightly smaller, but \$b=5\$ goes above the function.
$$l=(5^{≢\omega}!)!$$
This gives the first statement of the APL code, l←!!5*≢⍵ assign to the variable l the factorial ! of the factorial ! of 5 to the power of * the length ≢ of ⍵ the right argument.
The submission
{l←!!5*≢⍵⋄z←⊂''⋄n←,∘.,⍨⋄k←{⊃,/n\l/⊂⍵}⋄f←{⊃⊃{⍺∊';|':(2↓⍵),⍨⍺{';'=⍺:n/⍵⋄,/⍵}2↑⍵⋄⍺='_':⍵,⍨⊂z⋄'+'=⍺:⊂∘k∘⊃@1,⍵⋄⍺,⍵}/⌽1,⍵}⋄w←f⍵⋄⊃q/⍨{0=≢((z,k'01')~w∪f⍵)∪w∩f⍵}¨q←k'10!_|;+'}

The regex is parsed and its matches returned by the function f. It works on the reversed regex, and 'fold'ing ('reducing' in APL-speak) over it. It returns all matches of a regex, with the special case of the regex a+ only returning up to the first l repetitions of sub-regex a, thus keeping the list of matches finite. By having this behaviour of +, all input matches up to a length of l are included in the result of f, i.e. nothing less than what is needed to test for complementarity. APL reduces from right to left, due to order of operations being from right to left. Each intermediate results of the reduce is formed by the matches of each sub-regex encountered thus far. For the initial case, a 1 is prepended to the regex before reversing it, after which the reduce operation is applied.
f←{⊃⊃{⍺∊';|':(2↓⍵),⍨⍺{';'=⍺:n/⍵⋄,/⍵}2↑⍵⋄⍺='_':⍵,⍨⊂z⋄'+'=⍺:⊂∘k∘⊃@1,⍵⋄⍺,⍵}/⌽1,⍵}

The right argument ⍵ contains the matches of each sub-regex encountered so far. The left argument ⍺ is the next character of the regex that is being processed. Each case of the regex character is checked using = equality or ∊ belongs-to when multiple cases can be joined into 1.
Of particular note, ! in the regex is treated the same as 0 or 1, resulting in a match of the character !. Due to how the regexes are checked for complementarity, this works fine. Its exact mechanism is ⍺,⍵, concatenate ⍺, a single character being either of 0, 1, or !, with ⍵.
_ matches the empty string, z in the APL code refers to z←⊂'' present earlier in the entire submission; ⍵,⍨⊂z the enclosed empty string, i.e. signifying that only the empty string is being matched, is prepended to ⍵.
The mechanism of + is dependent on the function k←{⊃,/n\l/⊂⍵}, which given a list of strings ⍵, performs the Cartesian concatenation (Cartesian product, but using concatenation instead of set union) of l copies of ⍵, where the Cartesian concatenation is defined earlier as n←,∘.,⍨. This is achieved using the @ operator, applying the function ⊂∘k∘⊃ on the list of matches at index 1, the ⊂ enclose and ⊃ pick functions are required due to the behaviour of @.
Concatenation and alternation are considered together. On 2↑⍵ the list of the first two elements of ⍵, n/ (reduce by n Cartesian concatenation) is applied in the case of concatenation, and ,/ (reduce by concatenation). The remaining ⍵ is concatenated at the end of this result.
After the execution of the reduce operation, its first set of matches is retrieved using ⊃.
The regex does not give errors even on incorrect regexes. The handling of + uses the @ operator which expects the argument to be indexable. When + is by itself, ⍵ is the scalar 1, so @ on 1 would not work, but the , applied on ⍵ converts it into a list, preventing an error. + then takes the Cartesian concatenation of 1 with l copies of itself.
; and | with too few arguments are implicitly handled by the functionality of the ↑ take function and the ↓ function. 2↑ takes the first 2 elements of the right argument, but if the right argument is shorter, the result is padded with sufficient prototype values, for example the prototype of a strictly numeric array is 0, while that of a character array is the space character ' '.
However, even with this treating of anomalous regexes, these regexes will not be returned by the entire complementary regex function as a complementary regex. This is due to the fact that they cannot be shorter than the respective shortest valid postfix regex, and even if these incorrect regexes are of the same length as the shortest valid regex, they are ordered lexicographically later than a valid regex, with the order being specified later while performing the complementarity check by 10!_|;+, and only the first (again, ordered lexicographically) complementary regex is picked as a result to the function submission.
Complementarity check
The checking for complementarity is done by the following part. q←k'10!_|;+' generates all possible regexes up to a length of l (k computes this function as mentioned earlier) and assigns this to q. The ordering specified by this part is what prevents incorrect regexes from being returned by the function.
For each of these strings ¨, the following function is computed, (⍵ denotes the right argument, in this case, each string for which the following function is applied on)
{0=≢((z,k'01')~w∪f⍵)∪w∩f⍵}

w is assigned earlier to the matches of the input regex. w∩f⍵ computes the intersection of w, the matches of the input, with f⍵, the matches of ⍵. For complementary regexes, this should be the empty set.
w∪f⍵ computes the union of w and f⍵. ~ performs set complement. z is ⊂'', the enclosed empty string. k'01' computes all binary strings with length up ≤ l, so z,k'01' is a list containing all these binary strings, along with the empty string.
The result of (z,k'01')~w∪f⍵ is all the binary strings that are not present in w∪f⍵, so it contains the strings that are matches by neither the input regex nor ⍵. For complementary regexes this should be the empty set.
((z,k'01')~w∪f⍵)∪w∩f⍵ is the union of the two sets above. This should be empty if the regexes are complementary. Its emptiness is checked by counting the number of elements contained within it using ≢, and comparing this result with 0. (Using ⍬ doesn't work because in Dyalog APL, empty lists can have different prototype lists.)
This function explained above returns 1 is the regexes are complementary, and 0 if they are not. The first truthy regex is picked by ⊃q/⍨, being returned by the function.
Alternative approaches
Initially, I thought that using the approach recommended in the challenge of doing the conversion regex → NFA → DFA → regex would yield a short solution in APL because of APL's strength with matrices (by storing the NFA/DFA as a 3-dimensional array, with each of its 2-dimensional arrays being adjacency matrices for transitions involving each input character and ε-transitions). I got to implement a part of this for the regex matching challenge that popped up recently, but I got a solution much longer than what I had expected at over 250 bytes. It's the handling of individual matrix entries that made the program long, for example, I had to include specific transitions between specific states, like an ε-transition from state 1 to states 2 and 3 for alternation. However the handling of the entire array or its component matrices was short, as was needed to execute the NFA on the input string. And besides, all that the >250 byte program did was only to determine if 1 string matches the input regex. Maybe storing the NFA in a "sparse" format with list of lists of numbers representing states might end up being shorter that the matrix-oriented approach.
I tried another approach to that regex matching challenge by listing all the matches of the input regex, with + repetitions bounded by the input length, and checking if the input string belongs to this list, which yielded a >140-byter, almost half the length of my previous approach. This approach ended up being adapted into function f of my submission to this challenge. Unlike the approach mentioned in the previous paragraph, this approach generates the list of all input matches, so I do not have to separately run the regex matching function on each of the possible inputs to see which ones it matches, thus saving a great deal of bytes.
Moreover, I had also tried ⎕r, Dyalog APL's PCRE replace function, for this challenge but that resulted in a postfix → PCRE converter at >110 bytes. Besides, similarly to the approach where I stored the NFA in an array, implementing the matching as well as finding all of the matches of this regex on all (bounded) input strings added too many bytes.
It was when I stumbled upon ankh-morpork's Prolog submission to the regex decomposition challenge and by the power of Prolog DCGs that I started working on this regex complement challenge in Prolog. However my Prolog skills was not good enough to make it work, and seeing how my approach ended up becoming un-Prolog-y and more APL-y I switched to APL and started this solution with the knowledge I had gathered from attempting the regex matching challenge. This brute-force approach proved to be significantly short than any other approach I could think of, so I went ahead with this. I left the calculation of the upper bound to the very end, i.e. the l← bit, and golfed the rest of my program from an initial size of >210 bytes.
The complementary check might be further golfable, perhaps there's a nice way to get rid of the parentheses, or an alternative logic. In function f, under the case when ⍺∊';|', I feel the 2↑⍵ and 2↓⍵ surrounding the code has a shorter alternative; I tried @1 2⊢⍵, but this results in an error for invalid regexes requiring me to use an error guard.


Python 3.5, Score of ??

As of now I don't have the output for all 101 inputs, but once I run the program for all the test cases I will update with my score.

from math import *

memoized = {}
same = {}

def _(mathmania, n):
    memoized[n] = mathmania
    return mathmania

def is_prime(n):
    if n == 2:
        return True
    if n % 2 == 0 or n <= 1:
        return False
    for divisor in range(3, int(sqrt(n)) + 1, 2):
        if n % divisor == 0:
            return False
    return True

def pair_key(pair):
    low, high = pair
    diff = high - low
    if diff == 0:
        return 100
    low_done, high_done, diff_done = low in memoized, high in memoized, diff in memoized
    if high_done and memoized[high] == None or low_done and memoized[low] == None:
        return -1
    return (high_done + diff_done + (diff + 1 == low)) * 33 + low / high

def major_pairs(n):
    for i in range(n, int(sqrt(n)), -1):
        d = n / i
        if i - d < d - 1:
            break
        if d == int(d):
            yield (int(d), i)

def fact_key(pair):
    i, f = pair
    if i in memoized:
        if memoized[i] == None:
            return -1
        return 1
    return i / f

def near_fact(n, level):
    s = 4
    if n in same:
        s = same[n]
    for i in range(s, n ** 2 ** level):
        f = factorial(i)
        if f > (n - 1) ** 2 ** level:
            if f < (n + 1) ** 2 ** level:
                same[n] = i
                yield (i, f)
            else:
                return

def generate_mathmania(n):
    if n in memoized and memoized[n] != None:
        return memoized[n]
    memoized[n] = None
    binx = log(n, 2)
    if binx == int(binx):
        if binx == 2:
            return _("e", n)
        if binx == 1:
            return _("er", n)
        if binx == 0:
            return _("rl", n)
        return _("e(" + generate_mathmania(int(binx)) + ")", n)
    sq = sqrt(n)
    if sq == int(sq):
        return _(generate_mathmania(int(sq)) + "e", n)
    low, high = max(major_pairs(n), key=pair_key)
    if pair_key((low, high)) == -1:
        level = 1
        while True:
            try:
                i, f = max(near_fact(n, level), key=fact_key)
            except:
                level += 1
                continue
            if fact_key((i, f)) == -1:
                return _(generate_mathmania((n - 1) ** 2 + 1) + "rc", n)
            if f == n ** 2 ** level:
                return _(generate_mathmania(i) + "f" + "r" * level, n)
            if f < n ** 2 ** level:
                return _(generate_mathmania(i) + "f" + "r" * level + "c", n)
            return _(generate_mathmania(i) + "f" + "r" * level + "l", n)
    if low != 1:
        if low == high:
            return _(generate_mathmania(low) + "e", n)
        if high - low == 1:
            return _(generate_mathmania(high) + "f", n)
        return _(generate_mathmania(high) + "f(" + generate_mathmania(high - low + 1) + ")", n)
    good = None
    for i in range(n ** 2 - 1, (n - 1) ** 2, -1):
        if i in memoized:
            return _(generate_mathmania(i) + "rc", n)
        if not is_prime(i):
            good = i
    if good:
        return _(generate_mathmania(good) + "rc", n)
    for i in range((n + 1) ** 2 - 1, n ** 2, -1):
        if i in memoized:
            return _(generate_mathmania(i) + "rl", n)
        if not is_prime(i):
            good = i
    if good:
        return _(generate_mathmania(good) + "rl", n)
    return _(generate_mathmania((n - 1) ** 2 + 1), n)

Additionally, I was unable to verify the outputs of some of the test cases I tried due to sheer number size, and at that point @BradGilbertb2gills's online interpreter times out. Hopefully all the outputs work.


GolfScript, 33 characters
~\),(@{:^1$[=]:y-.,2//y*^~}*;' '*

The input must be provided on stdin.
Examples (you may test online):
> 7 1
2 3 4 1 5 6 7

> 3 4
3 1 2

> 11 2
2 3 4 5 6 11 1 7 8 9 10


C++   75.0
The program is designed to work with arbitrary text strings. They can be of any different lengths as long as neither exceeds 13824 characters. It uses 1,897 16-bit integers, which is equivalent to 949 32-bit integers. At first I was writing it in C, but then realized there was no function for reading a line.
The first command-line argument should be a filename. If a second argument exists, a summary of the edits is printed. The first line in the file is ignored while the second and third are the strings.
The algorithm is a doubly blocked version of the usual algorithm. It performs basically the same number of operations, but is of course much less accurate, since if a common subsequence gets split over the edge of a block, much of the potential savings are lost.
#include <cstring>
#include <inttypes.h>
#include <iostream>
#include <fstream>

#define M 24
#define MAXLEN (M*M*M)
#define SETMIN(V, X) if( (X) < (V) ) { (V) = (X); }
#define MIN(X, Y) ( (X) < (Y) ? (X) : (Y) )

char A[MAXLEN+1], B[MAXLEN+1];
uint16_t d0[M+1][M+1], d1[M+1][M+1], d2[M+1][M+1];

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

    if(argc < 2)
        return 1;

    std::ifstream fi(argv[1]);

    std::string Astr, Bstr;
    for(int i = 3; i--;)
        getline(fi, i?Bstr:Astr);
    if(!fi.good()) {
        printf("Error reading file");
        return 5;
    }
    if(Astr.length() > MAXLEN || Bstr.length() > MAXLEN) {
        printf("String too long");
        return 7;
    }

    strcpy(A, Astr.c_str());
    strcpy(B, Bstr.c_str());

    uint16_t lA = Astr.length(), lB = Bstr.length();
    if(!lA || !lB) {
        printf("%d\n", lA|lB);
        return 0;
    }
    uint16_t nbA2, nbB2, bA2, bB2, nbA1, nbB1, bA1, bB1, nbA0, nbB0, bA0, bB0; //block, number of blocks
    uint16_t iA2, iB2, iA1, iB1, jA2, jB2, jA1, jB1; //start, end indices of block

    nbA2 = MIN(M, lA);
    nbB2 = MIN(M, lB);
    for(bA2 = 0; bA2 <= nbA2; bA2++) {
        iA2 = lA * (bA2-1)/nbA2,  jA2 = lA * bA2/nbA2;
        for(bB2 = 0; bB2 <= nbB2; bB2++) {
            if(!(bA2|bB2)) {
                d2[0][0] = 0;
                continue;
            }
            iB2 = lB * (bB2-1)/nbB2,  jB2 = lB * bB2/nbB2;
            d2[bA2][bB2] = ~0;
            if(bB2)
                SETMIN(d2[bA2][bB2], d2[bA2][bB2-1] + (jB2-iB2));
            if(bA2)
                SETMIN(d2[bA2][bB2], d2[bA2-1][bB2] + (jA2-iA2));

            if(bA2 && bB2) {
                nbA1 = MIN(M, jA2-iA2);
                nbB1 = MIN(M, jB2-iB2);
                for(bA1 = 0; bA1 <= nbA1; bA1++) {
                    iA1 = iA2 + (jA2-iA2) * (bA1-1)/nbA1, jA1 = iA2 + (jA2-iA2) * bA1/nbA1;
                    for(bB1 = 0; bB1 <= nbB1; bB1++) {
                        if(!(bA1|bB1)) {
                            d1[0][0] = 0;
                            continue;
                        }
                        iB1 = iB2 + (jB2-iB2) * (bB1-1)/nbB1, jB1 = iB2 + (jB2-iB2) * bB1/nbB1;
                        d1[bA1][bB1] = ~0;
                        if(bB1)
                            SETMIN(d1[bA1][bB1], d1[bA1][bB1-1] + (jB1-iB1));
                        if(bA1)
                            SETMIN(d1[bA1][bB1], d1[bA1-1][bB1] + (jA1-iA1));

                        if(bA1 && bB1) {
                            nbA0 = jA1-iA1;
                            nbB0 = jB1-iB1;
                            for(bA0 = 0; bA0 <= nbA0; bA0++) {
                                for(bB0 = 0; bB0 <= nbB0; bB0++) {
                                    if(!(bA0|bB0)) {
                                        d0[0][0] = 0;
                                        continue;
                                    }
                                    d0[bA0][bB0] = ~0;
                                    if(bB0)
                                        SETMIN(d0[bA0][bB0], d0[bA0][bB0-1] + 1);
                                    if(bA0)
                                        SETMIN(d0[bA0][bB0], d0[bA0-1][bB0] + 1);
                                    if(bA0 && bB0)
                                        SETMIN(d0[bA0][bB0], d0[bA0-1][bB0-1] + (A[iA1 + nbA0 - 1] != B[iB1 + nbB0 - 1]));
                                }
                            }
                            SETMIN(d1[bA1][bB1], d1[bA1-1][bB1-1] + d0[nbA0][nbB0]);
                        }
                    }
                }

                SETMIN(d2[bA2][bB2], d2[bA2-1][bB2-1] + d1[nbA1][nbB1]);
            }
        }
    }
    printf("%d\n", d2[nbA2][nbB2]);

    if(argc == 2)
        return 0;

    int changecost, total = 0;
    for(bA2 = nbA2, bB2 = nbB2; bA2||bB2; ) {
        iA2 = lA * (bA2-1)/nbA2,  jA2 = lA * bA2/nbA2;
        iB2 = lB * (bB2-1)/nbB2,  jB2 = lB * bB2/nbB2;
        if(bB2 && d2[bA2][bB2-1] + (jB2-iB2) == d2[bA2][bB2]) {
            total += changecost = (jB2-iB2);
            char tmp = B[jB2];
            B[jB2] = 0;
            printf("%d %d deleted {%s}\n", changecost, total, B + iB2);
            B[jB2] = tmp;
            --bB2;
        } else if(bA2 && d2[bA2-1][bB2] + (jA2-iA2) == d2[bA2][bB2]) {
            total += changecost = (jA2-iA2);
            char tmp = B[jA2];
            A[jA2] = 0;
            printf("%d %d inserted {%s}\n", changecost, total, A + iA2);
            A[jA2] = tmp;
            --bA2;
        } else {
            total += changecost = d2[bA2][bB2] - d2[bA2-1][bB2-1];
            char tmpa = A[jA2], tmpb = B[jB2];
            B[jB2] = A[jA2] = 0;
            printf("%d %d changed {%s} to {%s}\n", changecost, total, B + iB2, A + iA2);
            A[jA2] = tmpa, B[jB2] = tmpb;
            --bA2, --bB2;
        }
    }

    return 0;
}


Perl 6, 60 bytes

{$/=[$^x,*.polymod($^y xx*).sum*($y-1)...($y-1)²];$/-1,|$/}

Expanded:

{    # bare block lambda with placeholder parameters ｢$x｣ ｢$y｣

  $/ = [          # store in ｢$/｣ ( so that we don't have to declare it )

    # generate a sequence

    $^x,          # declare first parameter, and seed sequence generator

    # Whatever lambda

    *\            # the parameter to this lambda

    .polymod(     # broken down with a list of moduli

      $^y         # declare second parameter of the outer block lambda
      xx *        # an infinite list of copies of it

    )
    .sum
    *
    ( $y - 1 )

    # end of Whatever lambda

    ...           # repeat until it reaches

    ( $y - 1 )²
  ];

  # returns
  $/ - 1,         # count of values minus one
  |$/             # Slip ｢|｣ the list into the result
}

Usage:

# store it in the lexical namespace so that it is easier to understand
my &code = {$/=[$^x,*.polymod($^y xx*).sum*($y-1)...($y-1)²];$/-1,|$/}

say code  739,  7; # (2 739 42 36)
say code 1712, 19; # (3 1712 360 648 324)


Python 2.7
42.575 = ( 6,812,000 / 160,000 ) approx

Code:
import gmpy2

def fac1(n):
    m=lambda(L):([]if len(L)%2==0 else[L.pop()])+map(lambda(l):l[0]*l[1],zip(L[1::2],L[-2::-2]))
    L=map(gmpy2.mpz,xrange(1,n+1))
    Number = (len(L)-1).bit_length()
    while Number:Number-=1;L=m(L)
    return L[0]

def fac2(n):
    global E; E=0
    def f(i):
        global E; E+=i//2
        return[]if i==1 else f(i//2)+range(3,i,2)+[[1,i][i%2]]
    m=lambda(L):([]if len(L)%2==0 else[L.pop()])+map(lambda(l):l[0]*l[1],zip(L[1::2],L[-2::-2]))
    L=map(gmpy2.mpz,f(n))
    N=(len(L)-1).bit_length()
    while N: N-=1;L=m(L)
    return L[0]<<E

Test:
import time

start = time.time()
baseline(160000)
print time.time()-start

start = time.time()
fac1(6811000)
print time.time()-start

start = time.time()
fac2(6812000)
print time.time()-start

start = time.time()
gmpy2.fac(26000000)
print time.time()-start

Output:
10.0069999695
10.0729999542
10.0360000134
9.98699998856

How it works:
Bigger multiplications take more time, thus we want to do as many small multiplications as possible. This is especially true in Python where for numbers less that 2^64 we use hardware arithmetic, and above that we use software. So, in m(L), we start with a list L; if it's odd length we remove one number from consideration to make it even again. Then we multiply element 1 with element -2, element 3 with -4, etc, so that
m([1,2,3,4,5,6,7,8]) = [2*7, 4*5, 6*3, 8*1] = [14, 20, 18, 8]
m([10,12,6]) = [360,112]
m([120,6]) = [40320]

This approach ensures we're using hardware arithmetic for as long as possible, following which we switch onto the efficient gmc arithmetic library.
In fac2, we take a more classic divide and conquer approach as well, where we split out every multiple of 2 and bitshift them at the end for a trivial performance boost. I've included it here because it's usually around 0.5% faster than fac1.
Golfed Version of fac1 (because I can), 220B
import gmpy2
def f(n):
    m=lambda(L):([]if len(L)%2==0 else[L.pop()])+map(lambda(l):l[0]*l[1],zip(L[1::2],L[-2::-2]))
    L=map(gmpy2.mpz,xrange(1,n+1));N=(len(L)-1).bit_length()
    while N:N-=1;L=m(L)
return L[0]


Pyth - 17 46 45 52 * .85 - 35 = 9.2 bytes
Filters the input (With the new # filter meta-op!) for a line with ~ in it, then indexes that to the input, and then divides that by the length of the input. If there are none with ~, it errors, and triggers the except clause of .x and prints the string.
.x+*100-1cxK.zh@#\~KlK\%." u(C$éáPãbÉãç*îÂe[W

Try it online here.


Python - 219 178 172 175

First crack at it.  I'm sure there's room for improvement.

edit1: After suggestions, and copying words file to local file named 'w'
edit2: Fixed a bug where it wasn't using the right number of letters per side.  Added 3 chars :(

r=range
s=raw_input()
print[a for a in(''.join(s[m:m+n]for m in r(o*n,len(s),4*n))for o in r(4)for n in(1,2,4,6,8))if not set(a.lower().split())-set(map(str.strip,open('w')))]


Divide a number by 3 without using *, /, +, -, % operators

C, 167503724710

Here's my solution to the problem. I admit it is unlikely to win a strict code golf competition, but it doesn't use any tricks to indirectly call built-in division functionality, it is written in portable C (as the original Stack Overflow question asked for), it works perfectly for negative numbers, and the code is exceptionally clear and explicit.

My program is the output of the following script:

#!/usr/bin/env python3
import sys

# 71
sys.stdout.write('''#include <stdint.h>
#include <stdio.h>
int32_t div_by_3(int32_t input){''')

# 39 * 2**32
for i in range(-2**31, 2**31):
    # 18 + 11 + 10 = 39
    sys.stdout.write('if(input==%11d)return%10d;' % (i, i / 3))

# 95
sys.stdout.write(r'''return 7;}int main(int c,char**v){int32_t n=atoi(a[1]);printf("%d / 3 = %d\n",n, div_by_3(n));}''')

Character count: 71 + 39 * 2**32 + 95 = 167503724710

Benchmarks

It was asked how long this would take and how much memory it would use, so here are some benchmarks:

Script execution time — Running ./test.py | pv --buffer-size=1M --average-rate > /dev/null for about 30 seconds gives a rate of about 14.8 MB/s. The rate of output can reasonably be assumed to be roughly constant, so the running time to completion should be about 167503724710 B / (14.8 * 1048576 B/s) ≈ 10794 s.
Compilation time — The TCC compiler claims to compile C code at 29.6 MB/s, which makes for a compilation time of 167503724710 B / (29.6 * 1048576 B/s) ≈ 5397 s. (Of course this can run in a pipeline with the script.)
Size of compiled code — I tried estimating it using ./test.py | tcc -c - -o /dev/stdout | pv --buffer-size=1M --average-rate > /dev/null, but it seems tcc doesn't output anything until it reads the entire source file in.
Memory usage to run — Since the algorithm is linear (and tcc doesn't optimize across lines), the memory overhead should be only a few kilobytes (apart from the code itself, of course).


What is the average of n, the closest prime to n, the square of n and the closest Fibonacci number to n?

Python 160 Chars

p=lambda n:any(n%x<1for x in range(2,n))
N=input()
a=0;b=1
while b<N:a,b=b,a+b
c=d=N
while p(c)and p(d):c-=1;d+=1
print (N+N*N+[b,a][2*N-a-b<0]+[c,d][p(c)])/4.0

A little explanation about the closestFib part:

  When the while loop ends a is smaller
  than N and b is either equal to or
  greater than N. Now the
  [b,a][2*N-a-b<0] part. Look at it as
  [b,a][(N-a)-(b-N)]. (N-a) is the
  difference between N and a and
  similarly (b-N) the difference between
  b and N. If the difference between
  these two is less than 0 it means a is
  closer to N and vice-versa.


Refactor variable names in JavaScript code

Ruby, 134 (113?) characters
*c,o,n=*$<;puts (c*?\n).gsub(/('|")((\\?+.)*?)\1|\/\*[\s\S]*?\*\/|\/\/.*|\/(\[\g<2>\]|\g<2>)+?\/\w*|([\w$]+)/){$5==o.chop&&n.chop||$&}

Unicode is not supported. If Unicode identifiers are to be supported, replace \w with [[:word:]]  and [\w$] with ([[:word:]]|\$) (and adjust the backreferences).
If unescaped slashes inside regexp literals (such as /[/]/) don't need to be supported, we can handle them together with string literals (116 characters). This also gives us string flags:
*c,o,n=*$<;puts (c*?\n).gsub(/\/\*[\s\S]*?\*\/|\/\/.*|('|"|\/)((\\?+.)*?)\1\w*|([\w$]+)/){$4==o.chop&&n.chop||$&}

Ungolfed version:
*code, old, new = *$<

puts code.join("\n").gsub (/
     ('|")((\\?+.)*?)\1           #strings
   | \/\*[\s\S]*?\*\/             #multiline comments
   | \/\/.*                       #single-line comments
   | \/(\[\g<2>\]|\g<2>)+?\/\w*   #regexes
   | ([\w$]+)                     #identifiers and keywords
/x){
  if $5 == old.chop then new.chop else $& end
}


CJam, 7 chars

qS/_&S*

Can probably be much shorter... but whatever I've almost never used CJam. ^.^

q reads input, S/ splits on spaces, _& duplicates and applies a setwise AND (therefore getting rid of duplicates), and S* re-joins on space.

Online interpreter link


Advent Challenge 2: The Present Vault Raid!

Wolfram Language (Mathematica), 129 bytes

Block[{a=#},Clear@f;s_~f~e_:=If[s==e,1,s~f~e=0;s~f~e=Min[(hMax[#~f~h&/@a@s,Boole[h==s]])/@a@e]];Tr[Max[(e#3~f~e)/@#2]^#2]]&

Try it online!

Similar approach to my answer to this question.

The function takes 3 arguments as input: adjacency list represented as an association (tool to generate adjacency list from edge list), elves position and santa position.

Note that Clear[f] is necessary, because function submissions must be reusable.

The code below is ungolfed code with partial explanation. More explanation later.

reverseBoole = # != 0 &

(* Or@@{a, b} === reverseBoole[booleOr[Boole[{a, b}]]] *)
booleOr = Max

booleAnd = Min

(* Boole@f[s, e] = Santa can catch Elf ? *)

mainfunc = Block[{adjlist = #},
  Clear[f];
  f[s_, e_] := If[ s == e, f[s, e] = 1,
    f[s, e] = Boole[False];
    f[s, e] = booleAnd[
      (e1  booleOr[
        ( s1  f[s1, e1] ) /@ adjlist[s],
        Boole[e1 == s]
      ]) /@ adjlist[e]
    ]
  ];
  If [ 0 == booleOr[ ( e  f[#3, e] ) /@ #2 ] , 0, Length[#2] ]
]&


Hard code golf: Regex for divisibility by 7


Find the rows which make each column have one True (was: Knuth's Algorithm X)

Haskell, 100 93 92 87 83 80 bytes

Knuth's algorithm:

g&c=filter(g.any(`elem`c))
(u:v)%a=[c:s|c<-id&u$a,s<-(not&c)v%(not&c$a)]
x%_=[x]

Calculates all covers nondeterministically depth-first in the list monad. Use head to calculate only one since Haskell is lazy. Usage:

*Main> [[1],[2],[3],[4],[5],[6],[7]]%[[1, 4, 7], [1, 4], [4, 5, 7], [3, 5, 6], [2, 3, 6, 7], [2, 7]]
[[[1,4],[2,7],[3,5,6]]]

For more speed by using Knuth's suggestion of selecting column with least ones, use this: (115 bytes, flat list for universe). Finds first solution to the large pentomino cover problem in under a minute when compiled.

import Data.List
[]%_=[[]]
w%a=[c:s|c<-a,c\\(head.sortOn length.group.sort$w:a>>=id)/=c,s<-(w\\c)%[b|b<-a,c\\b==c]]

Thanks to @Zgarb for saving 1+3 bytes!

Thanks to @ChristianSievers for his sage advice and saving 5 bytes and some.

Ungolfed (with flat list universe):

knuthX [] _ = [[]]
knuthX (u:niverse) availableRows = --u chosen deterministically
  [ chosen:solution
  | let rows = filter (elem u) availableRows
  , chosen <- rows  --row chosen nondeterministically in list monad
  , solution <- knuthX
                  (filter (not.(`elem`chosen)) niverse)
                  (filter (not.any(`elem`chosen)) availableRows)
  ]


Solve the eight queens problem at compile-time

My meta-program finds all 92 solutions. They are printed as error messages:

error: ‘solution’ is not a member of ‘std::integral_constant<int, 15863724>’

This means the first queen should be placed at y=1, the second at y=5, the third at y=8 and so on.

The meta-program consists of two mutually recursive meta-functions put_queen and put_queens:

#include <type_traits>

template<int queens, int rows, int sums, int difs, int x, int y>
struct put_queen;

template<int queens, int rows, int sums, int difs, int x>
struct put_queens : std::integral_constant<int,
    // try all 8 possible values for y
       put_queen<queens, rows, sums, difs, x, 1>::value
     | put_queen<queens, rows, sums, difs, x, 2>::value
     | put_queen<queens, rows, sums, difs, x, 3>::value
     | put_queen<queens, rows, sums, difs, x, 4>::value
     | put_queen<queens, rows, sums, difs, x, 5>::value
     | put_queen<queens, rows, sums, difs, x, 6>::value
     | put_queen<queens, rows, sums, difs, x, 7>::value
     | put_queen<queens, rows, sums, difs, x, 8>::value
> {};

template<int queens, int rows, int sums, int difs, int x, int y>
struct put_queen : std::conditional<
    // if blocked
    rows & (1 << y)
 || sums & (1 << (x + y))
 || difs & (1 << (x - y + 8)),
    // then backtrack
    std::integral_constant<int, 0>,
    // else recurse
    put_queens<queens * 10 + y,
               rows | (1 << y),
               sums | (1 << (x + y)),
               difs | (1 << (x - y + 8)),
               x + 1
    >
>::type {};

The variable queens stores the y coordinates of the queens placed on the board so far.
The following three variables store the rows and diagonals that are already occupied by queens.
x and y should be self-explanatory.

The first argument to conditional checks whether the current position is blocked.
If it is, we backtrack by returning the (meaningless) result 0.
Otherwise, the queen is placed on the board, and the recursion continues with the next column.

When x reaches 8, we have found a solution:

template<int queens, int rows, int sums, int difs>
struct put_queens<queens, rows, sums, difs, 8> {
    // print solution as error message by accessing non-existent member
    enum { value = std::integral_constant<int, queens>::solution };
};

Since integral_constant has no member solution, the compiler prints queens as an error message.

To start the recursion, we inspect the value member of the empty board:

int go = put_queens<0, 0, 0, 0, 0>::value;

The complete program can be found at ideone.


APL (Dyalog Unicode), 36 bytesSBCS

Anonymous tacit prefix function.

⎕UCS{4↑⍺⍺t⎕R(1⌽∪¨t←2/¨⍺⍺2*⍳16)⍺⍺⍵~0}

Try it online!

⎕UCS{…} derived function where ⍵ is the argument and ⍺⍺ converts to/from code points:

 ⍵~0 the argument without zeros

 ⍺⍺ convert to code points

 t⎕R(…) Replace the texts t (defined below) with the corresponding texts from:

  ⍳16 the indices from 1 to 16

  2* two raised to the power of those

  ⍺⍺ convert them to characters

  2/¨ make two of each

  t← assign to t

  ∪¨ get the unique element from each (i.e. deduplicate them)

  1⌽ cyclically rotate the first string to the end

 ⍺⍺ convert to code points

 4↑ take the first four elements, padding with zeros


Where will the gem-picking robot end up?

Python 2, 205 198 bytes

def s(g,w,r):
 p=g.index(0)
 while 1:
    a=[((r+[0]).index(v),n)for n,v in enumerate(g)if(abs(n-p)in[1,w])>(p-n)%w*(p/w!=n/w)];m,n=min(a)
    if~-sum(k[0]==m<len(r)for k in a):return p/w,p%w
    p=n;g[p]-=1

-6 bytes thanks to @ovs
-1 byte thanks to @user202729
Try it online!
Take the input grid as a flattened list with width also passed. Outputs 0-indexed (x,y) coordinates of the final position (I doubt index in the flattened list would be acceptable).
Explanation:
# Function of flattened grid g, width w, pRiorities r
def s(g,w,r):
    # starting position p
    p = g.index(0)
    while 1:
        a = [
            # pair (priority rank of the cell, cell id)
            # priority rank is n for v=0
            ((r+[0]).index(v),n)
            # for each adjacent cell id n with v gems
            for n,v in enumerate(g) if abs(n-p) in [1,w] and (p%w==n%w or p/w==n/w)
        ];
        # min comparison is done by tuple, so it selects one with minimum priority rank
        # m = min priority rank; n = corresponding cell id
        m,n = min(a)
        if sum( # how many adjacent cells
            k[0]==m # have priority rank equal to m
            <len(r) # and the cell value is not 0
            for k in a
        ) ^ 1: # If this count is not 1, then the robot is stuck; return
            return(p/w, p%w)
        # Otherwise, continue with updated position,
        p = n;
        # and take one gem
        g[p] -= 1


Python 3, 180 174 168 160 152 bytes

from sys import*
J=''.join
L=str.lower
s,a,b=J(stdin).split(', ')
print(J('FBFBiuIUzzZZzzZZ'[L(k)==L(b)::2][k!=L(k)::2]*(L(k)in L(a+b))or k for k in s))

This is just a more golfed version of Stephen's answer, in Python 3. This chips away 42% of his bytes. Python 2 would save one byte on the print, but such is the price of progress. This handles newlines properly.

Thanks to Blckknight for saving 8 bytes on input.


Write a program to output the nth fibonacci number in quinary

Python, 226 bytes
s='s=%r;a,b=0,1;exec"a,b=b,a+b;"*input();print"".join(map(lambda i:(s%%s)*int(i)+(s%%s)[::-1]*(1-int(i)),bin(a)[2:]))';a,b=0,1;exec"a,b=b,a+b;"*input();print"".join(map(lambda i:(s%s)*int(i)+(s%s)[::-1]*(1-int(i)),bin(a)[2:]))

It's quite a heavy modification to the standard Python Quine. It uses a,b=0,1;exec"a,b=b,a+b;" to generate Fibonacci numbers.


C, 106
Golfed version
f(n){
  for(int i,h=n*2<<n;h--;(i/3|i/3*2)-i||(putchar(i>>h%n&1?45:124),h%n||puts(h%(n*2)?"":"\n")))
    i=h/2/n;
}

Original version
i,j,n;
main(){
  scanf("%d",&n);
  for(i=1<<n;i--;)if((i/3|i/3*2)==i){
    for(j=1<<n;j/=2;)printf("%c",i&j?'-':'|');puts("");
    for(j=1<<n;j/=2;)printf("%c",i&j?'-':'|');puts("\n");
  }
}

How it works
The variable i runs from 1<<n-1 down to 0, producing all possible binary numbers with n digits. 0 encodes for | and 1 encodes for -. We are interested in numbers that contain 1's in pairs. Obviously such numbers are divisible by 3.
When a number is divided by 3, the original number can be recovered by multiplying the result by 2 and adding it to itself (effectively mutliplying by 3.) Most numbers will require a carry, but when the process is carried out on the numbers of interest, no carry is required, so in these cases only, OR can be used instead of addition. This is used to test for the numbers of interest, as they are the only ones where the expression i/3|i/3*2 returns the original value of i. See example below.
1111=15 ---> 0101=5 ---> 1111=15 (valid, 0101|1010==0101+1010)
1001=9  ---> 0011=3 ---> 0111=7 (invalid, 0011|0110 != 0011+0110)
The test value is always equal or less than the original value. As numbers that are not multiples of 3 also return a number less than the original when divided by 3 then multipled by 3, the test gives the desired FALSE on these numbers too.
In the original version a couple of loops in j are used to scan through the bits of i and produce the output. In the golfed version a single for loop is used, in which h runs through all numbers from (n*2)*(1<<n)-1 down to 0. Values of i are generated by h/2/n. The variable j is no longer used, as the equivalent quantity is obtained from h%n. The use of n*2 enables both lines to be printed from the same loop, with some nifty multiplexing in the puts statement to print either one or two newlines at the end of the row.
Note that the meat of this is in the increment position of the for() bracket and therefore gets executed after the i=h/2/h.
Sample output n=6:
$ ./a
6
------
------

----||
----||

--|--|
--|--|

--||--
--||--

--||||
--||||

|----|
|----|

|--|--
|--|--

|--|||
|--|||

||----
||----

||--||
||--||

|||--|
|||--|

||||--
||||--

||||||
||||||


APL (Dyalog Extended), 130 119 bytesSBCS

Anonymous tacit prefix function.

((∊∘⎕A⊂⊢)'FactorialSquareTriangularCubePositiveNegativePrimeComposite')/⍨{⍵∊¨(⊂∘!,×⍨⍮+\)⍳|⍵},(|∊⍳∘|*3⍨),<,>,1∘⍭,0∘⍭∧1∘<

Try it online!

(…)/⍨ filters the list of strings on the left by the bit mask on the right:

 (…)'Fac…ite' apply the following tacit function to the long string:

  ∊∘⎕A element-wise membership of the uppercase alphabet

  ⊂ partitions (i.e. True begins a new partition)

  ⊢ the unmodified argument

The last 46 bytes return a bit vector indicating [Factorial, Square, Triangular, Cube, Positive, Negative, Prime, Composite]:

{⍵∊¨(⊂∘!,×⍨⍮+\)⍳|⍵},(|∊⍳∘|*3⍨),<,>,1∘⍭,0∘⍭∧1∘<

Try it online!

{…} the first three bits (factorial, square, triangular) come from this anonymous lambda:

 ⍵∊¨(…)… is the argument a member of each of the following three lists?

  ⊂∘! the enclosed factorials

  , followed by

  ×⍨ the squares (lit. the multiplication selfies)

  ⍮ juxtaposed with

  +\ the running sum

 ⍳ of the integers one through

 |⍵ the absolute value of the argument

(…) the next bit (cube) comes from the following tacit function:

 | is the absolute value of the argument

 ∊ a member of

 ⍳∘| the integers 1 through the absolute value of the argument

 * raised to the power of

 3⍨ three

< the next bit is simply whether it is positive (zero is less than)

> the next bit is simply whether it is negative (zero is more than)

1∘⍭ the next bit is whether it is prime

0∘⍭ the final bit is whether it is non-prime

∧

1∘< one is less than it


CJam, 274

q~:K;:B;:A;{0aA*aB*:M5*5f*:I;K{[Bmr:QAmr:P]5f*:R;3Ym*{R.+:)2{1$0=I=2$W=@tI@0=@t:I;}:F~}/R2f+1FK({MQ=P=:EY4mr:D#&1{{MQMQ=PE2D#+tt:M;}:G~7,1>[W0_1_0_W]2/D=:Off*{[QP]5f*2f+.+_:H1F_OW%.+2FOW%.m2F}/H2FO~P+:P;Q+:Q;MQ=P=:E_5YD2%-*=!JK2-=+*1{D2+4%:D;G}?}?}fJ]}0?}g'P2NA5*SI,N2NI:+N*

Try it online

Uses PBC, outputs in PGM format. You can remove the :+ near the end to get a nicer visual output in the browser.

It's very slow for larger input, especially if the step count is close to the area.

Example result for input 4 3 10 (scaled 500%):

Brief explanation:

The general approach is:

repeat all the following steps until successful:
initialize 2 matrices: one recording which sides are being used in each cell, and one for the image
if s=0, we're done, else:
pick a random cell and draw a square, then do the following s-1 times:
pick a random direction; if that side is already used, fail and start over
mark the side as used and draw the actual pipe in the image (drawing 3 adjacent lines of length 6, starting right "after" the center pixel of the current cell, then adding a dot to cap the end of the pipe)
update the current position (moving to the next cell)
check if the cell is empty or it's a valid crossing; if not, fail and start over
mark the side in the opposite direction as used in this cell, then continue the loop


Husk, 7 5 bytes
ṙ¹η◄∫

Try it online!
No loops, no recursion, just a straightforward simple operation. Encodes [ as 1 and ] as -1.
ṙ¹η◄∫
ṙ¹       Rotate the list left by
  η        the (1-based) index
   ◄         of the minimum
    ∫      in the list of cumulative sums

This comes from observing that the list of cumulative sums will have a minimum at the point where the most closed brackets are preceding open brackets. By moving all the previous brackets to the end, we can guarantee that there won't be any prefix containing more closed than open brackets.

Previous answer, 7 bytes
Ωȯ¬▼∫ṙ1

Try it online!
Encodes [ as 1 and ] as -1, following HyperNeutrino's idea to use the cumulative sum, but then uses an additional observation:
Since we are working with an equal number of open and closed brackets, the total sum will always be 0. If at any point the string is unbalanced, the cumulative sum at that point will be negative. From this, we can say that a string will be balanced if the minimum of its cumulative sum is exactly 0.
Ω(¬▼∫)ṙ1
      ṙ1    Rotate by 1
Ω           until
   ▼         the minimum
    ∫        of the cumulative sums
  ¬          is 0


05AB1E, 8 bytes
Code:
µN¹åNp*½

Explanation:
µ          # Run this until the counting variable has reached the input value.
 N¹å       # Check if the input number is in the range variable.
    Np     # Check if the range variable is prime.
      *    # Multiply those two numbers (which is basically an AND operator).
       ½   # If true, increment the counting variable.
           # After the loop, the stack is empty and implicitly prints N.

Uses CP-1252 encoding. Try it online!.


Bash + coreutils, 43 30

Saved 7 bytes thanks to @Yossarian
Saved 3 bytes thanks to @AndersKaseorg

seq 0 23|date -f- +%R\ %l:00%P

seq generates integers 0-23, one per line.
date interprets each line as a datetime.  Bare integers appear to be sufficient to be recognised as hours of the day by date.  date then outputs each time with the required formatting using the available time format specifiers.

Assumes LANG=C locale, as per this meta answer.
Ideone.


Python 3, 83 81 bytes

lambda a,b,c,d:g(*a)+g(*b)+c[0]+"-"+d[2:]
g=lambda c,*s:c[:c in"aeiou"]or c+g(*s)

Try it online!

-2 bytes thanks to @JonathanAllan!

Explanation:

g is a recursive function that takes in a splatted string and return the string, truncated after the first vowel.

lambda c,*s gather the splatted string into the first character c and the rest s.
c[:c in"aeiou"] or c+g(*s) evaluates to:

if c is a vowel, then c[:c in"aeiou"] evaluates to c[:1] which is c. Since c is Truthy, it is returned.
if c is not a vowel, then c[:c in"aeiou"] evaluates to c[:0] aka the empty string. The empty string is Falsy, so c+g(*s) (the recursive case) is returned.

Old solution, kept here for sentimental reason

Python 3, 89 bytes

lambda a,b,c,d:g(a)+g(b)+c[0]+"-"+d[2:]
g=lambda s:s[:[x in"aeiou"for x in s].index(1)+1]

Try it online!


Snails, 29
A
\+|\-)lr!\-|(\+|\|)n!\|}!\+

I added line comments with ,,, in order to make a commented version.
A                    ,, Count all accepting paths
        \+ | \- )    ,, Literal '+' or '-'
        lr           ,, Set direction to left or right
        !\-          ,, Assert next char is not '-'
    |                ,, Or...
        ( \+ | \| )  ,, Literal '+' or '|'
        n            ,, Turn 90 degrees right or left (from initial direction right)
        !\|          ,, Assert next char is not '|'
}                    ,, Group everything previous
!\+                  ,, Assert next char is not '+'


Valentine's day greetings card generator

C

What can be more romantic than syntax highlighting?

  *xx=       "De"
 "ar %"     "s:\n"
"Consta"   "nts ar"
"e red, " "variable"
"s are blue.\nIf lo"
"ve had a syntax, I"
 "'d highlight you"
  ".\n",n[9];main(
    ){printf(xx,
      gets(n))
        ;xx;
         }

Output:

$ echo Ilana | ./vanentine
Dear Ilana:
Constants are red, variables are blue.
If love had a syntax, I'd highlight you.


Batch, 284 bytes

@set e=echo
@%e%off
set s=
set t=
goto %1
:RED
set t= `
%e%   `~ ~ ~ ~ ~ ~`
:ORANGE
%e%   %t%~  ~  ~%t%
:YELLOW
%e%    %t%~   ~%t%
%e%%s%%t%~%t%
:GREEN
%e%%s%al   la
%e%     j%s% j
%e%  jaf %s%  oku
%e% y %s%%s%  l
%e%E%s%%s%%s%l
%e%--------------------

Note: Lines 1 and 7 have one trailing space, line 3 has six and line 4 has three.


Malbolge, 482 370 353 bytes

R1: Removed commas inbetween (as not required by the challenge)

R2: Shave off a few bytes

('<;_#!=6Z|{8xUwvt,PrqonKmk)"FhCUTdb?`+<;:[Z7YtVU2T|/g-O+i(gJrHc#EC~B{@zZxw:tt'r5Qo"!l/K-hUfe?bP``_Lo~[}|X2VCTR3Q+N`_^9+7Hji3ffdAc~w|u;]\wpon4VUSSQ.PONcb(JI^]#DCYX|@?>=<:u9NMRKo32MFj.C,Ae)>'<%:^"!~5:3WxwwuRts0q(Lnml)"Fhgfe"y?a`_zyxq7YXWlUj0RgfkjMb(JI^c\[Z~BAV?T=Rv987Mq44310FEi-,G@)>b&%#"8=6Z{{yyw/Sut1*)('Km$k(!Efe{zyx>`uz]r8ZXnm3TTih.PkNchg`&HFF[DY}Az

Try it online!


Haskell, 22 bytes

(.zip).(.).map.uncurry

Try it online!
Not particularly interesting, just a reimplementation of zipWith converted to pointfree form:
\f x y -> map (uncurry f) (zip x y)
\f x -> map (uncurry f) . zip x
\f x -> (map (uncurry f) .) zip x
\f -> (map (uncurry f) .) . zip
\f -> (. zip) (map (uncurry f) .)
\f -> (. zip) ((.) (map (uncurry f)))
\f -> (. zip) ((.) ((map . uncurry) f))
\f -> (. zip) ((.) . (map . uncurry) $ f)
\f -> (. zip) . ((.) . (map . uncurry)) $ f
(. zip) . ((.) . (map . uncurry))


PHP code, 1808 971 bytes

Quick and dirty implementation in PHP. First brute-force all possible slice shapes, next brute-force all positions and orientations of the slices.

Usage: cat pizza.txt | php pizza.php

Edit: reduced code size by more than 45% by rewring algorithm using recursion rather than nested loops. However, this eats memory (and pizza's ;-)). Pizza's larger than 8x8 will probably run out of memory. The nested loop variant can easily handle any size, but is twice the code size.

<?php define('A',98);$n=fgets(STDIN);$d=array();$m=$u=str_pad('',A,'+');$s=0;while($g=fgets(STDIN)){$g=rtrim($g);assert(strlen($g)<=A-2);$s++;$m.='+'.str_pad(rtrim($g),A-2,' ').'+';for($l=0;$l<strlen($g);$l++)if($g[$l]=='#')$d[]=$s*A+$l+1;}$m.=$u;$r=count($d)/$n;x(reset($d),array(array()),0,0,0,0);die('No pizza for you!');function x($e,$c,$b,$a,$q,$t){global$r,$m,$d;$h=$a*A+$b;if(!in_array($e+$h,$d))return;if(in_array($h,$c[0]))return;$c[0][]=$h;$c[1][]=$b*A-$a;$c[2][]=-$a*A-$b;$c[3][]=-$b*A+$a;if(count($c[0])<$r)do{x($e,$c,$b+1,$a,$b,$a);x($e,$c,$b,$a+1,$b,$a);x($e,$c,$b-1,$a,$b,$a);x($e,$c,$b,$a-1,$b,$a);$v=($b!=$q||$a!=$t);$b=$q;$a=$t;}while($v);else w($c,$m,0,reset($d),0);}function w(&$p,$f,$o,$e,$i){global$n,$d;foreach($p[$i]as$h){$j=$e+$h;if(!isset($f[$j])||$f[$j]!='#')return;$f[$j]=chr(ord('0')+$o);}if(++$o==$n){for($k=A;$k<strlen($f)-A;$k++)if($k%A==A-1)echo PHP_EOL;else if($k%A)echo$f[$k];exit;}foreach($d as$j)for($i=0;$i<4;$i++)w($p,$f,$o,$j,$i);}

Ungolfed, documented code

Below is the documented, original code. To keep my sanity, I worked with the full source code, and wrote a simple minifier script to strip statements like assert() and error_reporting(), remove unnecessary brackets, rename variables, functions and constants to generate the golfed code above.

<?php
error_reporting(E_ALL) ;

// Width of each line of pizza shape.
// Constant will be reduced to single character by minifier,
// so the extra cost of the define() will be gained back.
define('WIDTH', 98) ;

// Read number of slices
$nrSlices = fgets(STDIN) ;

// Read pizza shape definition and
// convert to individual $positionList[]=$y*width+$x and
// linear (1D) $pizzaShape[$y*WIDTH+$x] with protective border around it.
//
// WARNING: assumes maximum pizza width of WIDTH-2 characters!
$positionList = array() ;
$pizzaShape = $headerFooter = str_pad('', WIDTH, '+') ;
$y = 0 ;
while ($line = fgets(STDIN))
{  $line = rtrim($line) ;
   assert(strlen($line) <= WIDTH-2) ;
   $y++ ;
   $pizzaShape .= '+'.str_pad(rtrim($line), WIDTH-2, ' ').'+' ;
   for ($x = 0 ; $x < strlen($line) ; $x++)
   {  if ($line[$x] == '#') $positionList[] = $y*WIDTH + $x+1 ;
   }
}
$pizzaShape .= $headerFooter ;

// Determine size of a slice
$sliceSize = count($positionList)/$nrSlices ;

// Build all possible slice shapes. All shapes start with their first part at
// the top of the pizza, and "grow" new parts in all directions next to the
// existing parts. This continues until the slice has the full size. This way
// we end up with all shapes that fit at the top of the pizza.
//
// The shape is defined as the offsets of the parts relative to the base
// position at the top of the pizza. Offsets are defined as linear offsets in
// the 1-D $pizzaShape string.
//
// For efficiency, we keep track of all four possible rotations while building
// the slice shape.
//
growSlice(reset($positionList), array(array()), 0, 0, 0, 0) ;
die('No pizza for you!') ;

function growSlice($basePosition, $shapeDeltas, $dx, $dy, $prevDx, $prevDy)
{  global $sliceSize, $pizzaShape, $positionList ;

   // Check validity of new position
   // Abort if position is not part of pizza, or
   // if position is already part of slice
   $delta = $dy*WIDTH + $dx ;
   if (!in_array($basePosition+$delta, $positionList)) return ;
   if (in_array($delta, $shapeDeltas[0])) return ;

   // Add all four rotations to shapeDeltas[]
   $shapeDeltas[0][] = $delta ;
   $shapeDeltas[1][] = $dx*WIDTH - $dy ;
   $shapeDeltas[2][] = -$dy*WIDTH - $dx ;
   $shapeDeltas[3][] = -$dx*WIDTH + $dy ;

   // Have we built a full slice shape?
   if (count($shapeDeltas[0]) < $sliceSize)
   {  // Grow shape either at current position or at previous position
      do
      {  growSlice($basePosition, $shapeDeltas, $dx+1, $dy,   $dx, $dy) ;
         growSlice($basePosition, $shapeDeltas, $dx,   $dy+1, $dx, $dy) ;
         growSlice($basePosition, $shapeDeltas, $dx-1, $dy,   $dx, $dy) ;
         growSlice($basePosition, $shapeDeltas, $dx,   $dy-1, $dx, $dy) ;
         $retry = ($dx != $prevDx || $dy != $prevDy) ;
         $dx = $prevDx ;
         $dy = $prevDy ;
      } while ($retry) ;
   } else
   {  // Try to cover the entire pizza by translated and rotated instances of
      // the slice shape.
      fitSlice($shapeDeltas, $pizzaShape, 0, reset($positionList), 0) ;
   }
}

function fitSlice(&$shape, $pizza, $id, $basePosition, $rotation)
{  global $nrSlices, $positionList ;

   // Try to fit each part of the slice onto the pizza. If the part falls
   // outsize the pizza, or overlays another slice we reject this position
   // and rotation. If it fits, we mark the $pizza[] with the slice $id.
   foreach ($shape[$rotation] as $delta)
   {  $position = $basePosition + $delta ;
      if (!isset($pizza[$position]) || $pizza[$position] != '#') return ;
      $pizza[$position] = chr(ord('0')+$id) ;
   }

   // If $nrSlices slices have been fitted, we have found a valid solution!
   // In that case, we display the solution and quit.
   if (++$id == $nrSlices)
   {  for ($pos = WIDTH ; $pos < strlen($pizza)-WIDTH ; $pos++)
      {  if ($pos % WIDTH == WIDTH-1) echo PHP_EOL ;
         else if ($pos % WIDTH) echo $pizza[$pos] ;
      }
      exit ;
   }

   // The current slice did fit, but we have still more slices to fit.
   // Try all positions and rotations for the next slice.
   foreach ($positionList as $position)
   {  for ($rotation = 0 ; $rotation < 4 ; $rotation++)
      {  fitSlice($shape, $pizza, $id, $position, $rotation) ;
      }
   }
}


Find the smallest prime from a substring

Golfscipt, 33 32 bytes = -18 score
2{:x,2>{x\%!},!!x`3$?)!|}{)}/;;x

Explanation:

2{...}{)}/ - starting with 2, while something is true, increment the top of the stack

;;x - discard the intermediate values collected by {}{}/ and the input, then put the last value tested there

:x,2> - store the value as x, then produce a list from 2 to x-1

{x\%!},!! - keep those that x is divisible by, then coerce to boolean (not empty)

x`3?)! - look up the input in the text form of x (-1 if not found), increment, negate.

| - or


Inverse of Conway base 13 function in \$\mathbb{Q}\$

Python 2, 254 237 219 216 207 bytes
-3 bytes thanks to @KevinCruijssen !
Can save 1 more byte by replacing X=e**(A+B) with X=e**A**B, but the result will be humongous, and the time taken to run will be very long.

e=13
a,A,b,B,y,Y=input()
X=e**(A+B)
x=a*X/A+2
r=abs(y)
s="AB"[y<0]+`r/Y`+"C"
R=[]
exec"R=[r]+R;r=r%Y*10;s+=`r/Y`;"*-~Y
n=~R.index(r)
T=e**-n-1
S=e**len(s)*T
print(int(s,e)*T+int(s[n:],e))*((x>0)*2-1)+x*S,X*S

Try it online! or Check all test cases!
A program that takes in 6 integers from STDIN, and prints out the numerator and denominator of the result.
Big idea

First, find a number \$c\$ such that \$a < c < b\$ and \$c\$ has finite base-13 representation. Note that \$c\$ should be "sufficiently far away" from \$a\$ and \$b\$. This will be the prefix of \$x\$.
For example: \$a = 1.1..._{13}, b = 1.3..._{13}\$ then \$c = 1.2_{13}\$. We say that \$c\$ is sufficiently far away from \$a\$ and \$b\$, since we can add any suffix to \$c\$ and it is guaranteed to stay in the range \$(a,b)\$.

Then find the suffix of \$x\$ by finding the base-10 representation of \$y\$, then replacing +-. with ABC. E.g with \$y = 1/3\$, the suffix is \$+0.(3)=A0C(3)\$

Join the prefix and suffix together. E.g \$x = 1.2A0C(3)\$.

Details
Finding the prefix:
The prefix has the form \$x/X\$, where \$X\$ is a power of 13.
Consider the integers \$\Bigl \lfloor \frac{aX}{A} \Big \rfloor \$ and \$\Bigl \lfloor \frac{bX}{B} \Big \rfloor \$ (where \$X = 13^i\$), which are the truncations of \$a/A\$ and \$b/B\$ to a certain base-13 precision. If there is an integer \$x\$ between those 2 numbers such that \$x\$ is at least 2 away from both numbers, then \$x/X\$ can be the prefix. This is because no matter what suffix is added, the value of \$x/X\$ won't change by more than \$1/X\$.
\$X=13^{A+B}\$ is guaranteed to be large enough to see a large gap between the truncation of \$a/A\$ and \$b/B\$.
This is the part that finds the prefix:
X=e**(A+B)
x=a*X/A+2

Finding the suffix:
First, the long division \$y/Y\$ is performed to find the decimal representation (with repeated digit). r is the current remainder, and R keeps track of the seen remainder after each digit division, in order to detect repeating decimals. \$y/Y\$ is calculated until \$Y+1\$ digits after the decimal point, which is sufficient to detect repeating groups of digits.
r=abs(y)
s="AB"[y<0]+`r/Y`+"C"
R=[]
exec"R=[r]+R;r=r%Y*10;s+=`r/Y`;"*-~Y

The suffix has the form \$stttt... = s(t)\$, where \$s\$ is the result of truncated \$y/Y\$ above, and \$t\$ is the repeating decimals found in \$s\$.
n=~R.index(r)
t = s[n:]

Thus, our result should have the form \$\frac{x + 0.sttt..._{13}}{X}\$ (or \$\frac{x - 0.sttt..._{13}}{X}\$ if \$x\$ is negative)
To convert 0.s(t) in base 13 to fraction, the following formula is used:
$$ 0.s(t) = 0.sttt... = \frac{s.(t)}{13^i} $$
$$ s.(t) = s.ttt... = s + \frac{t}{13^j-1} $$
where \$i, j\$ are the number of digits in \$s, t\$.


Make a program for printing a string in my esolang MAWP!

JavaScript (Node.js),  276 266  263 bytes
Saved 3 bytes thanks to @KevinCruijssen

i=>[v=[],O='',[...2**29+'4'].map(F=x=>F[v[x]=+x]=x)].map(s=_=>v.map(x=>v.map(y=>[x+y,x*y,y-x].map((z,o)=>(!F[z]&&V.push(z))|(S=~~s[x]-~s[y])<s[z]|S==s[z]&F[x]<2?F[s[z]=S,z]=F[x]+F[y]+'MWA'[o]:0)),V=[])&&v.push(...V))&Buffer(i).map(n=>O+=F[n]+';')||O.replace(1,'')

Try it online!
MAWP interpreter
Here is a simple MAWP interpreter I wrote to check the results.

function MAWP(code) {
  let stack = [ 1 ], out = "";

  function assertStkSz(n) { if(stack.length < n) throw "stack error"; }

  [...code].forEach(c => {
    switch(c) {
      case 'M': assertStkSz(2); stack.push(stack.pop() + stack.pop()); break;
      case 'A': assertStkSz(2); stack.push(stack.pop() - stack.pop()); break;
      case 'W': assertStkSz(2); stack.push(stack.pop() * stack.pop()); break;
      case 'P': assertStkSz(2); stack.push(stack.pop() / stack.pop() | 0); break;
      case ';': assertStkSz(1); out += String.fromCharCode(stack.pop()); break;
      default : stack.push(+c); break;
    }
  })
  return out;
}

Try it online!


Jelly, 18 17 bytes

SṚ0;+Sṭ
1WWÇ⁸¡ṪṙḢ

Uses 0-based indexing.

Try it online!

How it works

1WWÇ⁸¡ṪṙḢ  Main link. Arguments: n, r

1          Set the return value to 1.
 W         Wrap; yield [1].
  W        Wrap; yield [[1]].
           This is the triangle with one row.
   Ç⁸¡     Call the helper link n times.
           Each iteration adds one row to the triangle.
      Ṫ    Tail; take the last array, i.e., the row n of the triangle.
       ṙ   Rotate row n r units to the left.
        Ḣ  Head; take the first element, i.e., entry r of row n.

SṚ0;+Sṭ    Helper link. Argument: T (triangle)

S          Take the column-wise sums, i.e., sum the ascending diagonals of the
           centered triangle, left to right.
 Ṛ         Reverse the array of sums. The result is equal to the sums of the
           descending diagonals of the centered triangle, also left to right.
  0;       Prepend a 0. This is required because the first element of the next row
           doesn't have a descending diagonal.
     S     Take the column-wise sum of T.
    +      Add the ascending to the descending diagonals.


Python 3.6, 124 bytes

Loops over length of input string like officialaimm's solution

import re,time
def d(s):
 for i in range(len(s)):print(*'\n'*75,*re.split(f'(.{{1,{i+1}}})',s)[1::2],sep='\n');time.sleep(1)

143 bytes to only go to width of longest line a al Frxstrem's Bash answer

import re,time
def d(s):
 for i in range(max(map(len,s.split()))):print(*'\n'*75,*re.split(f'(.{{1,{i+1}}})', s)[1::2],sep='\n');time.sleep(.5)

Uses "re.split((.{1,i+1}))" to break the string into groups of characters.  Because '.' doesn't match '\n', the groups don't wrap around from one line to the next. If the regex uses a capturing group, then re.split() returns a list with the matched groups at the odd indexes.  These are retrieved with [1::2].

Uses python 3.6 f-string to make the re pattern depend on group width i.

The * in front of re.split() uses python 3.6 unpacking to turn the list into arguments to the print statement.  Similarly, *'\n'*75, turns into 75 '\n' arguments to the print statement.  With the print keyword argument sep='\n', the result is printing about 150 blank lines to clear the screen, followed by each group of characters on a separate line.


Convert human readable time interval to date components


CJam, 62 61 63 bytes

Try it online

Nq_N#):D;+_,2/{:P"^<v>^

"_P4$=#:X)=t_,0PX[1DW*WDSP]=-e>e<}h;1>

Expanded and commented:

Nq              "Read the input grid";
_N#):D;         "Calculate the vertical delta (line length + 1)";
+               "Prepend a newline to the grid";
_,2/            "Calculate the initial position as the length of the grid
                 string divided by 2";
{               "Do...";
  :P"^<v>^

"
  _P4$=           "Get the character indexed by the position in the grid";
  #:X             "Map the character to an operation number:
                   '^'=>0, '<'=>1, 'v'=>2, '>'=>3, '^'=>4, '\n'=>5, '\n'=>6
                   (the unreachable duplicate mappings are important below)";
  )=t             "Set the character indexed by the position in the grid to
                   the result of mapping the operation number + 1 backwards";
  _,0PX[1DW*WDSP]="Map the operation number to a negated delta (this occurs
                   after rotating routers, which means that operation n should
                   act like the character corresponding to operation n + 1):
                   0=>1, 1=>-delta, 2=>-1, 3=>delta, 5=>position";
  -e>e<           "Subtract the negated delta from the position and clamp it to
                   [0, length of the grid string] (array indices are circular,
                   so the length of the grid string will act like the index 0
                   and point to the initial newline next iteration, which will
                   *really* set the position to 0)";
}h              "... while the position is not 0 (i.e. not at the initial
                 newline)";
;1>             "Clean up and remove the initial newline";

My solution operates on the input as a flat string, so there's only one position value to keep track of and virtually no pre/postprocessing; there are only 2 bytes of preprocessing to add newline to the beginning of the grid and 2 bytes of postprocessing to remove it from the output. But these 4 bytes are well worth the cost as they let me keep newlines in and "execute" them like routers, but they "rotate" into another newline and set the position to zero. And the main loop ends when the position becomes zero.


(old problem) JavaScript (Node.js), 99 94 92 88 86 83 80 78 bytes

f=(x,t=[...21+Array(999)])=>x?f(s=x-1,t.map(d=>-s+(s+=(t=~~d*x+t/10|0)%10))):s

Try it online!

well, first language without large number support

Thank Arnauld for 4 bytes

f = (x, t = ['2', '1', ...','.repeat(998)]) => // init x, t=1
  x ?
    f( // recursive x':=x-1, t'=t*x
      s = x-1, // s init to 0 when x==1, in next recursion just return
      t.map (
        b = // init b to NaN
        d =>
          -s + ( //  to return the added value
            s+= ( // -s + (s + k) == k
              b=
                ~~d*x+b/10 | 0
                // ~~d converts ',' to 0
                // b is initally NaN, after first iteration
                // it's zero, then the last digit sum result with carry
            ) % 10
          )
      )
    )
:
  s // the sum from x==1


CJam, 34 32 28 characters
{"ɚ광䃻噣攍圍숵셳ﶓ訙➰鑓쥾"2G#b126b:c~}

This is a compressed form of the following 31 bytes solution
{:D%0a*\+0\{+U):UD={0:U}*}%0-p}

This can be golfed further.
Try it online here
Input is in format of [small_array] index_where_small_array_begins divisor
For example:
[1 2 3] 5 3{"ɚ광䃻噣攍圍숵셳ﶓ訙➰鑓쥾"2G#b126b:c~}~

will give output
[1 5]

Explanation (outdated):
{                                   "Begin of function block";
 :D                                 "Store the divisor in D";
   %                                "Calculate index_where_small_array_begins%divisor";
    0a*                             "Get an array of 0 on length above number";
       \+                           "Prepend it to the small_array";
         _,{            }*          "Run this code block length(small_array) times";
            0\                      "Put 0 before small_array. This 0 marks the"
                                    "current sum of the current mini_array";
              {      }D*            "Run this code block divisor times";
               0+                   "Add 0 at the end of mini array";
                 (                  "Take out the first element from the mini array";
                  @                 "Rotate the stack to get current sum on top";
                   +                "Add the first element to the current sum";
                    \               "Swap to put current mini_array on top of stack";
                          ;]        "Pop the residual array and wrap the sums in an array";
                            0-p     "Remove 0 and print the sum_of_mini_arrays_array";
                               }    "End of function block";


Ruby, 46 51 58 bytes

->l{l.permutation(3).select{|a,b,c|a+b==c}.map(&:sort)|[]}

Try it online!

Ok, not so straightforward, but now seems to work.


Solitaire Dreams - Creating a winnable solitaire starting hand


Python 3, 348
Saved 5 bytes thanks to Mathias Ettinger.
Saved 7 bytes thanks to DSM.
Ooof, this is a long one. I also hate that there's not a good way to do test cases.
from random import*
*l,='123456789'
q=['-']*9
r=randint
p=print
f=' to flip: '
while l!=q:
 p(*l,sep='');t=r(1,6)+r(1,6)*(l[6:]!=q[6:]);p('You rolled: %s'%t);d={int(input('Which lever'+f))for _ in' '*int(input('How many levers'+f))}
 if len(set(d))-len(d)+1-all(str(x)in l for x in d)+t-sum(d):exit('Game Over')
 for x in d:l[x-1]='-'
p('You win!')


J - 181 190 170 char

This was a nightmare. I rewrote it from scratch, twice, because it just kept bugging me. This is a function taking a single string argument, outputting to STDOUT.

(0&$`((2{.{:@>&.>)((j{.]),-i@=`p@.~:~/@[,]}.~#@p+j=.0{p I.@E.])i 5;@}.&,'/';"0;&.>)@.(2<#)@}.[4:1!:2~{:@>@p=.>@{.@[)@((0;(0,:~1 0,.2);'\';&<1 0)<;._1@;:'/'&,)i=. ::](^:_)

To explain, I will break it up into subexpressions.

i =. ::](^:_))
parse =: ((0;(0,:~1 0,.2);'\';&<1 0)<;._1@;:'/'&,)
print =: 4:1!:2~{:@>@p=.>@{.@[
eval  =: 0&$`((2{.{:@>&.>)sub 5;@}.&,'/';"0;&.>)@.(2<#)@}.
sub   =: ((j{.]),-i@=`p@.~:~/@[,]}.~#@p+j=.0{p I.@E.])i

interp =: (eval [ print) @ parse i

i (short for iterate) is an adverb. It takes a verb argument on the left and returns a verb (f)i, which when applied to an argument, applies f repeatedly to the argument until one of two things happens: it finds a fixed point (y = f y), or it throws an error. The fixed-point behaviour is inherent to ^:_, and ::] does the error handling.
parse tokenizes the input into what I call half-parsed form, and then cuts it up at the unescaped '/'. It binds escaping backslashes to their characters, but doesn't get rid of the backslashes—so we can either revert it or finish it depending on which we want.

The bulk of the interesting work occurs in ;:. This is a sequential-machine interpreter primitive, taking a description of the machine ((0;(0,:~1 0,.2);'\';&<1 0)) on the left and something to parse on the right. This does the tokenizing. I will note that this specific machine actually treats the first character unspecial, even if it's a \ and should bind. I do this for a few reasons: (1) the state table is simpler, so it can be golfed further; (2) we can easily just add a dummy character to the front to dodge the problem; and (3) that dummy-character gets half-parsed at no extra cost, so I can use it to set up for the cutting phase, next.

We also use <;._1 to cut the tokenized result on unescaped / (which is what I choose to be the first char). This is handy for pulling out the output, pattern, and replacement from out/patt/repl/rest all in one step, but unfortunately also cuts up the rest of the program, where we need those / to stay untouched. I splice these back in during eval, because making <;._1 leave them alone ends up costing a lot more.
The fork (eval [ print) executes print on the result from parse for its side-effects, and then runs eval. print is a simple verb that opens up the first box (the one we know for sure is output), finishes parsing it, and sends it to STDOUT. However, we also take the chance to define a utility verb p.

p is defined as >@{.@[, so it takes its left arg (acts like the identity if given only one arg), takes the first item of that (identity when given a scalar), and unboxes it (identity if already unboxed). This will come in very handy in sub.
eval evaluates the remainder of the processed program. If we don't have a full pattern or a full replacement, eval throws it out and just returns an empty list, which terminates evaluation by making ;: (from parse) error out on the next iteration. Else, eval fully parses the pattern and replacement, corrects the remainder of the source, and then passes both to sub. By explosion:

                                              @}.  NB. throw out printed part
                                       @.(2<#)     NB. if we have a pattern and repl:
      2{.                                          NB.  take the first two cuts:
             &.>                                   NB.   in each cut:
         {:@>                                      NB.    drop escaping \ from chars
     (          )                                  NB.  (these are pattern and repl)
                                   &.>             NB.  in each cut:
                                  ;                NB.   revert to source form
                            '/';"0                 NB.  attach a / to each cut
                          &,                       NB.  linearize (/ before each cut)
                     5  }.                         NB.  drop '/pattern/repl/'
                      ;@                           NB.  splice together
    (            sub                  )            NB.  feed these into sub
   `                                               NB. else:
0&$                                                NB.  truncate to an empty list

sub is where one (possibly infinite) round of substitutions happens. Because of the way we set up eval, the source is the right argument, and the pattern and replacement are bundled together in the left. Since the arguments are ordered like this and we know the pattern and replacement don't change within a round of substitutions, we can use another feature of i—the fact that it modifies only the right argument and keeps passing in the same left—to delegate to J the need to worry about keeping track of the state.

There are two spots of trouble, though. The first is that J verbs can have at most two arguments, so we don't have an easy way to access any that are bundled together, like pattern and replacement, here. Through clever use of the p utility we defined, this isn't that big of a problem. In fact, we can access the pattern in one character, just by using p, because of its >@{.@[ definition: the Unbox of the First item of the Left arg. Getting the replacement is tricker, but the shortest way would be p&|., 2 chars shorter than manually getting it out.

The second problem is that i exits on fixed points instead of looping forever, and if the pattern and replacement are equal and you make a substitution, that looks like a fixed point to J. We handle this by entering an infinite loop of negating 1 over and over if we detect they are equal: this is the -i@=`p@.~:~/ portion, replacing p&|..

                                    p    E.]    NB. string search, patt in src
                                      I.@       NB. indices of matches
                                  0{            NB. take the first (error if none)
                               j=.              NB. assign to j for later use
                           #@p+                 NB. add length of pattern
                       ]}.~                     NB. drop that many chars from src
                   /@[                          NB. between patt and repl:
                  ~                             NB.  patt as right arg, repl as left
              @.~:                              NB.  if equal:
        -i@=                                    NB.   loop forever
            `p                                  NB.  else: return repl
 (j{.])                                         NB. first j chars of src
       ,              ,                         NB. append all together
(                                           )i  NB. iterate

This cycle repeats due to the use of i, until something outside of sub errors out. As far as I'm aware, this can only happen when we are out of characters, of when we throw out an incomplete set of pattern-and-replacement.

Fun facts about this golf:

For once, using ;: is shorter than manually iterating through the string.
0{ should have a chance to error out before sub goes into an infinite loop, so this it should work fine if the pattern matches the replacement but never shows up in the remainder of the source. However, this may or may not be unspecified behaviour, since I can't find a citation either way in the docs. Whoopsie.
Keyboard interrupts are processed as spontaneous errors inside running functions. However, due to the nature of i, those errors get trapped too. Depending on when you hit Ctrl+C, you might:

Exit out of the negate-forever loop, error out of the sub loop by trying to concatenate a number to a string, and then go on interpreting /// as if you finished substituting a string with itself an infinite number of times.
Leave sub halfway through and go on interpreting a half-subbed /// expression.
Break out of the interpreter and return an unevaluated /// program to the REPL (not STDOUT, though).

Example usage:

   f=:(0&$`((2{.{:@>&.>)((j{.]),-i@=`p@.~:~/@[,]}.~#@p+j=.0{p I.@E.])i 5;@}.&,'/';"0;&.>)@.(2<#)@}.[4:1!:2~{:@>@p=.>@{.@[)@((0;(0,:~1 0,.2);'\';&<1 0)<;._1@;:'/'&,)i=. ::](^:_)
   f 'no'
no
   f '/ world! world!/Hello,/ world! world! world!'
Hello, world!
   f '/foo/Hello, world!//B\/\\R/foo/B/\R'
Hello, world!
   f '//'  NB. empty string

   f '/\\/good/\/'
good


Rust, 1210 1200 bytes

use std::collections::HashMap as H;type I=i64;type E=Vec<(I,I)>;fn d(g:&E)->bool{let mut s:Vec<(E,Vec<I>)>=vec![];for e in g{let(v,w)=e;let f=(*v,*w);let z=|x|s.iter().position(|p|p.1.contains(x));match(z(v),z(w)){(Some(i),Some(j))=>{if i!=j{let mut p=s.remove(i);let q=s.remove(j-(i<j)as usize);p.0.extend(q.0);p.1.extend(q.1);s.push(p)}else{s[i].0.push(f)}}(Some(i),_)=>{s[i].0.push(f);s[i].1.push(*w)}(_,Some(j))=>{s[j].0.push(f);s[j].1.push(*v)}_=>{s.push((vec![f], vec![*v, *w]))}}}s.iter().map(|h|{let mut p=H::new();let mut r=H::new();let mut i=0;for e in&h.0{let(v,w)=e;i+=2;p.insert(i-1,i);p.insert(i,i-1);r.entry(v).or_insert(vec![]).push(i-1);r.entry(w).or_insert(vec![]).push(i)}let mut r:Vec<Vec<I>>=r.values().cloned().collect();r.sort();let mut x=0;let m=r.iter().flat_map(|v|1..v.len()).fold(1,|p,n|p*n);for mut w in 0..m{let mut t=H::new();for u in&r{let mut v=u.clone();let s=v.pop().unwrap();let mut f=s;while v.len()>0{let o=v.remove(w%v.len());w/=v.len()+1;t.insert(f,o);f=o}t.insert(f,s);}let mut f=vec![];let mut n=0;for s in p.keys(){if!f.contains(s){n+=1;let mut c=s;loop{f.push(*c);c=&t[&p[c]];if c==s{break}}}}x=x.max(n)}1-(r.len()as I-g.len()as I+x as I)/2}).sum::<I>()<2}

A toroidal example:
Try it online!

That's this toroidal graph:

A non-toroidal example: Try it online!

That's this non-toroidal graph:

The original code I wrote, before golfing, was the following. It has printouts so you can see what's happening:

use std::collections::HashMap;

#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
struct Vertex(u64);
type Edge = (Vertex, Vertex);
type Graph = Vec<Edge>;

fn full_genus(graph: &Graph) -> usize {
    componets(graph).iter().map(|g| genus(g)).sum()
}
fn genus(graph: &Graph) -> usize {
    #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug, PartialOrd, Ord)]
    struct HalfEdge(usize);
    let mut edge_pairing: HashMap<HalfEdge, HalfEdge> = HashMap::new();
    let mut vertex_groups: HashMap<&Vertex, Vec<HalfEdge>> = HashMap::new();
    let mut i = 0;
    for edge in graph {
        let (vert1, vert2) = edge;
        let half1 = HalfEdge(i);
        i += 1;
        let half2 = HalfEdge(i);
        i += 1;
        edge_pairing.insert(half1, half2);
        edge_pairing.insert(half2, half1);
        vertex_groups.entry(vert1).or_insert(vec![]).push(half1);
        vertex_groups.entry(vert2).or_insert(vec![]).push(half2);
    }
    let mut vertex_groups: Vec<Vec<HalfEdge>> = vertex_groups.values().cloned().collect();
    vertex_groups.sort();
    println!("{:?}", edge_pairing);
    println!("{:?}", vertex_groups);

    let mut max_faces = 0;
    let num_rotations = vertex_groups
        .iter()
        .map(|v| v.len() - 1)
        .map(|n| {
            let mut prod = 1;
            for i in 0..n {
                prod *= i + 1;
            }
            prod
        })
        .fold(1, |p, n| p * n);
    println!("\nNum rotations: {}\n", num_rotations);
    for rotation_index in 0..num_rotations {
        let mut working_index = rotation_index;
        let mut rotation: HashMap<HalfEdge, HalfEdge> = HashMap::new();
        let mut pretty_rotation: Vec<Vec<HalfEdge>> = vec![];
        for group in &vertex_groups {
            let mut removal_group = group.clone();
            let start = removal_group.pop().unwrap();
            let mut from = start;
            let mut pretty_group = vec![from];
            while !removal_group.is_empty() {
                let index = working_index % removal_group.len();
                working_index /= removal_group.len();
                let to = removal_group.swap_remove(index);
                rotation.insert(from, to);
                pretty_group.push(to);
                from = to;
            }
            rotation.insert(from, start);
            pretty_rotation.push(pretty_group);
        }
        let mut seen_on_face: Vec<HalfEdge> = Vec::new();
        let mut num_faces = 0;
        for start_halfedge in edge_pairing.keys() {
            if !seen_on_face.contains(start_halfedge) {
                num_faces += 1;
                let mut current_halfedge = start_halfedge;
                loop {
                    seen_on_face.push(*current_halfedge);
                    let pair_halfedge = &edge_pairing[current_halfedge];
                    current_halfedge = &rotation[pair_halfedge];
                    if current_halfedge == start_halfedge {
                        break;
                    }
                }
            }
        }
        if num_faces > max_faces {
            max_faces = num_faces;
            let euler_characteristic: isize =
                vertex_groups.len() as isize - graph.len() as isize + max_faces as isize;
            let genus_num: isize = 1 - euler_characteristic / 2;
            println!(
                "Faces: {}, Genus <= {} on rotation {}",
                max_faces, genus_num, rotation_index
            );
            println!("{:?}\n", pretty_rotation);
        }
        if rotation_index % 1e7 as usize == 0 {
            println!("Faces: {} <= {} on rotation {}", num_faces, max_faces, rotation_index);
        }
    }
    let euler_characteristic: isize =
        vertex_groups.len() as isize - graph.len() as isize + max_faces as isize;
    let genus_num: isize = 1 - euler_characteristic / 2;
    assert!(genus_num >= 0);
    genus_num as usize
}

fn componets(graph: &Graph) -> Vec<Graph> {
    let mut graphs: Vec<(Graph, Vec<Vertex>)> = vec![];
    for edge in graph {
        let (vert1, vert2) = edge;
        let g_index1 = graphs.iter().position(|(_g, h)| h.contains(&vert1));
        let g_index2 = graphs.iter().position(|(_g, h)| h.contains(&vert2));
        match (g_index1, g_index2) {
            (Some(i1), Some(i2)) => {
                if i1 != i2 {
                    let (mut graph1, mut vs1) = graphs.remove(i1);
                    let new_i2 = if i1 < i2 { i2 - 1 } else { i2 };
                    let (graph2, vs2) = graphs.remove(new_i2);
                    graph1.extend(graph2);
                    vs1.extend(vs2);
                    graphs.push((graph1, vs1));
                } else {
                    graphs[i1].0.push(edge.clone());
                }
            }
            (Some(i1), None) => {
                graphs[i1].0.push(edge.clone());
                graphs[i1].1.push(vert2.clone());
            }
            (None, Some(i2)) => {
                graphs[i2].0.push(edge.clone());
                graphs[i2].1.push(vert1.clone());
            }
            (None, None) => {
                let edges = vec![edge.clone()];
                let vs = vec!(vert1.clone(), vert2.clone());
                graphs.push((edges, vs));
            }
        }
    }
    graphs.into_iter().map(|(g, _h)| g).collect()
}

fn main() {
    let graph = vec![
        (Vertex(0), Vertex(1)),
        (Vertex(0), Vertex(2)),
        (Vertex(0), Vertex(3)),
        (Vertex(0), Vertex(4)),
        (Vertex(0), Vertex(5)),
        (Vertex(1), Vertex(2)),
        (Vertex(1), Vertex(3)),
        (Vertex(1), Vertex(4)),
        (Vertex(1), Vertex(5)),
        (Vertex(2), Vertex(3)),
        (Vertex(2), Vertex(4)),
        (Vertex(2), Vertex(5)),
        (Vertex(3), Vertex(4)),
        (Vertex(3), Vertex(5)),
    ];
    let result = full_genus(&graph);
    println!("Result: {}", result);
}

This program finds the minimum genus surface that the given graph can be embedded in. A graph is toroidal if that genus is at most 1, the genus of the torus.

The code works by separating the graph into its connected components, finding their genii separately, and adding up the results.

To find the genus of a connected graph, I brute force search over all possible rotation systems of the graph, and figure out which one has the most faces. A rotation system is simply an ordering on the edges emerging from each vertex, saying what order those edges are in going around the vertex. Each rotation system has a straightforward minimum genus it can be embedded in, and having more faces directly corresponds to having lower genus. Since every possible embedding corresponds to some rotation system, if there is a toroidal embedding, my program will find the corresponding rotation system and declare that the graph is toroidal, and vice versa.

This program is very slow, because it searches through a number of rotation systems equal to the product over all degrees d of the vertices of (d-1)!. However, it can search through a little over 10 million such rotation systems per minute, so it can verify the toroidality or non-toroidality of simple graphs like the ones shown above.


Taylor Series of a Function with Periodic Derivatives

JavaScript (ES6), 183 bytes

(c,a,n)=>[...Array(n)].map((_,i)=>(s=c[i%c.length].replace(/x/g,a),i?s=s.replace(/^-?/,c=>c?` - `:` + `)+(a>0?`*(x-${a})`:a<0?`*(x+${-a})`:`*x`):s,i>1?s+`^${i}/${f*=i}`:s),f=1).join``

Lots of tedious string manipulation. Explanation:

(c,a,n)=>                               Parameters
 [...Array(n)].map((_,i)=>(             Loop i from 0 to n-1
  s=c[i%c.length]                       Get the right element from the cycle
   .replace(/x/g,a),                    Substitute a in for x
  i?                                    If i > 0
   s=s.replace(/^-?/,c=>c?` - `:` + `)  Turn the sign into an operator
    +(a>0?`*(x-${a})`                   If a > 0 then * (x - a)
     :a<0?`*(x+${-a})`                  If a < 0 then * (x + -a)
     :`*x`)                             If a == 0 then * x
   :s,                                  No change if i < 1
  i>1?                                  If i > 1
   s+`^${i}/${f*=i}`                    Append ^ i / i!
   :s),                                 No change if i < 2
  f=1                                   0! == 1
 ).join``                               Join all the results together

170 bytes if you remove all the whitespace:

(c,a,n)=>[...Array(n)].map((_,i)=>(s=c[i%c.length].replace(/x/g,a),i?s=(s[0]=='-'?'':'+')+s+(a>0?`*(x-${a})`:a<0?`*(x+${-a})`:`*x`):s,i>1?s+`^${i}/${f*=i}`:s),f=1).join``


Python 3, 80, 75 bytes

lambda B,k:[i for i in range(1,-~B*k)if all(i%j for j in range(2,B+1))][:k]

Try it online!

Thanks to shooqie for saving 5 bytes.

This assumes that the k'th B-rough number will never exceed \$B * k\$, which I don't know how to prove, but seems like a fairly safe assumption (and I can't find any counterexamples).

Alternate solution:

Python 2, 78 bytes

B,k=input()
i=1
while k:
 if all(i%j for j in range(2,B+1)):print i;k-=1
 i+=1

Try it online!

This solution does not make the above solution. And is much more efficient.


Reading Code in 8 Ways to Output 8 Numbers

J, 3 * 3 = 9

1[2
+2+
2+2

Executing all directions:

       ". '1[2+2+2+2','2+2+2+1[2','1+2[2+2+2','2+2[2+1+2','2+2+2+2[1','2[1+2+2+2','2+2+2[2+1',:'2+1+2[2+2'
1 7 3 4 8 2 6 5

Explanation:

In J execution goes from right to left and there is no operator precedence.
The [ (left) takes the left side of its two operand so it essentially cancels the whole right side of our expression e.g. 1+2[2+2+2 becomes 1+2[6 and then 1+2.
The left expressions are additions with a total of 1, 2, 3 and 4 operands. There are two of each n-operand expressions one with the number 1 and one with only 2s. The additions with 1 generate the odd numbers and the others generate the even ones.


Bash + GNU utilities, 97 96 93 85 80 76 73 58 56 51 bytes

(${d=date +%a -d$3-}$1-$2;$d$2-$1)|uniq|sed N\;cErr

Try it online!

5 bytes off thanks to user41805, who pointed out that I could use sed's c command instead of the final s command.

2 bytes off thanks to Nahuel Fouilleul. (Nahuel also helped by shaving 4 bytes off in an earlier version that has since been revamped.)

When I noticed that the separators can be any non-digit character, I changed the code to use spaces as the separator.

This is called with a command like

checkdate 01 06 2020

The output is on stdout.  (There's spurious output on stderr.)


Haskell, O(n3)

import Data.Array

data Op = Plus | Minus | Times

exampleTerms :: [Integer]
exampleTerms = [5, 5, 3, 8, -2]

exampleOps :: [Op]
exampleOps = [Times, Minus, Plus, Times]

main = print $ maximalOrder exampleTerms exampleOps

type MinMax = (Integer, Integer)

-- Given an operator and minimal/maximal values for left- and right-hand sides,
-- compute the minimal/maximal value of the expressions joined together with this operator.
combine :: Op -> MinMax -> MinMax -> MinMax
combine Plus  (lmin, lmax) (rmin, rmax) = (lmin + rmin, lmax + rmax)
combine Minus (lmin, lmax) (rmin, rmax) = (lmin - rmax, lmax - rmin)
combine Times (lmin, lmax) (rmin, rmax) = (minimum ps, maximum ps)
    where ps = [lmin * rmin, lmin * rmax, lmax * rmin, lmax * rmax]

maximalOrder :: [Integer] -> [Op] -> Integer

maximalOrder []    _                 = error "maximalOrder: No terms"
maximalOrder terms ops
    | length terms /= length ops + 1 = error "maximalOrder: Mismatched terms/ops lists."

maximalOrder terms ops = snd $ minMax 0 (termCount - 1) where
    termCount :: Int
    termCount = length terms

    termsA :: Array Int Integer
    termsA = array (0, termCount-1) $ zip [0..] terms

    opsA :: Array Int Op
    opsA = array (0, termCount-2) $ zip [0..] ops

    dp :: Array (Int, Int) MinMax
    dp = array ((0,0), (termCount-1,termCount-1))
         [((start, end), minMax start end)
             | start <- [0..termCount-1], end <- [start..termCount-1]]

    minMax :: Int -> Int -> MinMax
    minMax start end
        | start == end =
            let x = termsA ! start
            in (x,x)
        | otherwise =
            let xs = [combine (opsA ! i) (dp ! (start,i)) (dp ! (i+1,end)) | i <- [start..end-1]]
            in (minimum (map fst xs), maximum (map snd xs))

This computes the minimal and maximal values of every substring in the expression, by going through each intervening operator and finding the minimal/maximal result of treating that operator as the root of the expression.  It collects these results into the overall minimal and maximal values for this substring.

This algorithm runs in O(n3) time and uses O(n2) space.  Finding the minimal/maximal value of an expression string, once its substrings have been visited, takes O(len), where len is the length of the substring.  The minimal/maximal value of every substring needs to be computed:

1..5
1..4 2..5
1..3 2..4 3..5
1..2 2..3 3..4 4..5
1..1 2..2 3..3 4..4 5..5

In this case, it takes 5*1 + 4*2 + 3*3 + 2*4 + 1*5.  In general, the number of operations grows in a cubic fashion.

At the heart of the algorithm is the combine function, which takes an operator and the minimal/maximal values of each of its operands, and produces the minimal/maximal results.

To maximize the result:

If adding two numbers, maximize both arguments.
If subtracting two numbers, maximize the left argument and minimize the right argument.
If multiplying two numbers, try the following:

Maximize both arguments.  This gives us the maximal result when multiplying two positive numbers.
Minimize both arguments.  This gives us the maximal result when multiplying two negative numbers, since a negative times a negative equals a positive.
Minimize the left argument and maximize the right argument, or vice versa.  We'd rather multiply two positives or two negatives and get a positive result, but if we have to multiply a positive and a negative and get a negative result, we want it to be as close to zero as possible.  To do so, we minimize the positive number and maximize the negative number.


6 languages, 169 bytes

Expects 0\n or 1\n as input, and prints words in:

Python 2 (Dutch vals/waar),
Python 3 (French faux/vrai),
Ruby (English false/true),
CJam (Norwegian usant/sant),
Golfscript (Danish usand/sand),
Befunge-93 (Italian falso/vero).

"#{puts gets>?1;exit}"" "#"& 1v
""
print('vwfvaaarlauasrxi'[int(1/2*4+int(input()))::4])
""#";;;;ri"u">"sant"+o
""""
__END__
]0=~"u">"sand"""#@,,,,"vero"  _"oslaf",,,,,@


Tips for golfing in Turing Machine But Way Worse

Use the negative tape
For code-golf questions where you need to process input, it is easier to move onto the negative tape to push a bit to the tape instead of having to travel to the end of the input on the positive tape (and sometimes that way may even be impossible when you need to support NUL bytes).
For example, when you need to push  to the tape and you have input, going on the negative tape would be much shorter than having to go to the end of the input.
0 0 0 0 1 0 0
1 0 1 0 1 0 0
0 1 0 0 2 1 1

would be much shorter than
0 0 0 1 1 0 0
1 0 1 1 0 0 0
0 1 0 1 2 0 0
1 1 1 1 0 0 0
0 2 0 1 3 0 0
1 2 1 1 0 0 0
0 3 0 1 4 0 0
1 3 1 1 0 0 0
0 4 0 1 5 0 0
1 4 1 1 0 0 0
0 5 0 1 6 0 0
1 5 1 1 0 0 0
0 6 0 1 7 0 0
1 6 1 1 0 0 0
0 7 0 1 8 0 0
1 7 1 1 0 0 0
0 8 0 0 9 0 0
0 9 1 0 a 1 1

and the second solution doesn't even work with NUL bytes.


Make a webpage where it looks like the browser is hanging / crashing

  <title>Connecting...</title>

http://c99.nl/f/64943.html


Convert short month names to their longer counterparts [Ended]

It's really simple with a little polynomial interpolation!

First, I looked at the list of short month names

["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]

and checked the sum of their characters ASCII values

[313,301,320,323,327,333,331,317,328,326,339,300]

then subtracted 300 from those to get a grasp of what I'm dealing with here, and prepared an Array that contains all the longer versions of the months' names.

[13,1,20,23,27,33,31,17,28,26,39,0]
mons = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

I guess you can see what's going on now - all I need is a function getIndex that maps 13 to 0, 1 to 1, 20 to 2, and so on, so I can simply do

getMonthName shortname = mons !! (getIndex shortname)

Luckily, Wolfram|Alpha can do this for me! The numbers get a bit large, but Haskell can handle that with grace. We just need to make sure to round the results, because floating-point-arithmetic is a little imprecise!
So there you go, fast, elegant, and idiomatic Haskell:

import Data.Char

getIndex x = round $ 11 -
    (220797068189915461*x)/11644212222720 +
    (184127469431441671621*x^2)/6982771136140800 -
    (8800438195450444577647153*x^3)/1013060436431307264000 +
    (2826703553741192361967823*x^4)/2026120872862614528000 -
    (269098602165195540339443*x^5)/2026120872862614528000 +
    (13744405529566098359*x^6)/1692665725031424000 -
    (13060656886070844161*x^7)/39727860252208128000 +
    (5939638907108115199*x^8)/675373624287538176000 -
    (303426664924585177*x^9)/2026120872862614528000 +
    (2983240583426137*x^10)/2026120872862614528000 -
    (12901227927103*x^11)/2026120872862614528000

mons = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
getMonthName = (mons!!).getIndex.subtract 300.fromIntegral.sum.fmap (ord.toLower)

Run it simply like this:

λ> getMonthName "DeC"
"December"

λ> getMonthName "jan"
"January"