Pyth, 54 51 bytes
J128m.MZ,0h.mb,255?<dJ.E-tJc-tJdQs+c-dJQJm-255id16E

Try it here!
Explanation

J128m.MZ,0h.mb,255?<dJ.E-tJc-tJdQs+c-dJQJm-255id16E   # Q = modifier, E = input list

J128                                                  # set J to 128
                                         m        E   # map each input d
                                              id16    # convert to decimal
                                          -255        # get the complement
    m                                                 # map each complement d
                  ?<dj                                # if d < 128
                      .E-tJc-tJdQ                     # use the ceil-formula
                                 s+c-dJQJ             # otherwise use the floor-formular
          .mb,255                                     # minimum of the result and 255
    .MZ,0h                                            # maximum of the result and 0


Lazybones

This bot is lazy. He picks a random spot and direction and continues to build in that direction without moving too much. There are only 2 cases where he does something different:

"make money" by closing a peg with only 1 remaining fence
choose a new spot and direction if placing the fence is not possible or would allow the other bot to "make money"

package pigpen.players;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import pigpen.Board;
import pigpen.Pen;
import pigpen.PigPen;
import pigpen.Player;

public class Lazybones extends Player {
    private static class Fence {
        private static boolean isOk(Board board, boolean vertical, int row, int col) {
            if (vertical) {
                Pen left = board.getPenAt(row, col - 1);
                Pen right = board.getPenAt(row, col);
                if (left.id() < 0 && right.id() < 0 ||
                        left.fences()[Pen.RIGHT] > 0 ||
                        right.fences()[Pen.LEFT] > 0 ||
                        left.remaining() == 2 ||
                        right.remaining() == 2) {
                    return false;
                }
            } else {
                Pen top = board.getPenAt(row - 1, col);
                Pen bottom = board.getPenAt(row, col);
                if (top.id() < 0 && bottom.id() < 0 ||
                        top.fences()[Pen.BOTTOM] > 0 ||
                        bottom.fences()[Pen.TOP] > 0 ||
                        top.remaining() == 2 ||
                        bottom.remaining() == 2) {
                    return false;
                }
            }
            return true;
        }

        private static Fence pickRandom(Board board) {
            List<Fence> ok = new ArrayList<>();
            List<Fence> notOk = new ArrayList<>();
            for (int row = 0; row < board.rows; row ++) {
                for (int col = 0; col < board.cols; col ++) {
                    (isOk(board, false, row, col) ? ok : notOk)
                            .add(new Fence(false, row, col));
                    (isOk(board, true, row, col) ? ok : notOk)
                            .add(new Fence(true, row, col));
                }
                (isOk(board, true, row, board.cols) ? ok : notOk)
                        .add(new Fence(true, row, board.cols));
            }
            for (int col = 0; col < board.cols; col ++) {
                (isOk(board, false, board.rows, col) ? ok : notOk)
                        .add(new Fence(false, board.rows, col));
            }
            if (ok.isEmpty()) {
                return notOk.get(PigPen.random(notOk.size()));
            } else {
                return ok.get(PigPen.random(ok.size()));
            }
        }

        private final boolean vertical;
        private final int row;
        private final int col;

        public Fence(boolean vertical, int row, int col) {
            super();
            this.vertical = vertical;
            this.row = row;
            this.col = col;
        }

        private Fence next(Board board, boolean negative) {
            int newRow = vertical ? (negative ? row - 1 : row + 1) : row;
            int newCol = vertical ? col : (negative ? col - 1 : col + 1);
            if (isOk(board, vertical, newRow, newCol)) {
                return new Fence(vertical, newRow, newCol);
            } else {
                return null;
            }
        }

        private int[] getResult(Board board) {
            if (vertical) {
                if (col < board.cols) {
                    return board.getPenAt(row, col).pick(Pen.LEFT);
                } else {
                    return board.getPenAt(row, col - 1).pick(Pen.RIGHT);
                }
            } else {
                if (row < board.rows) {
                    return board.getPenAt(row, col).pick(Pen.TOP);
                } else {
                    return board.getPenAt(row - 1, col).pick(Pen.BOTTOM);
                }
            }
        }
    }

    private Fence lastFence = null;
    private boolean negative = false;

    @Override
    public int[] pick(Board board, int id, int round) {
        List<Pen> money = board.getList().stream()
                .filter(p -> p.remaining() == 1).collect(Collectors.toList());
        if (!money.isEmpty()) {
            return money.get(PigPen.random(money.size())).pick(Pen.TOP);
        }
        if (lastFence != null) {
            lastFence = lastFence.next(board, negative);
        }
        if (lastFence == null) {
            lastFence = Fence.pickRandom(board);
            negative = PigPen.random(2) == 0;
        }
        return lastFence.getResult(board);
    }
}


Haskell, 23 22 bytes

f 0=0
f n=n-f(f$f$n-1)

Simply uses the definition of the sequence. f(f$f$n-1) is equivalent to f (f (f (n-1))).

Test:

main = putStrLn . show $ map f [0..20]
-- => [0,1,1,2,3,4,4,5,5,6,7,7,8,9,10,10,11,12,13,13,14]

Thanks to Anders Kaseorg for a byte!


Perl - 96
(Pretty good, given the theoretical max 97 score)
s{}[Hel0o, w3$=d!];y<"#%&'*.124578:?@BCDEFGIJKLMNOQ/-9>(
    6PRSTUVWXYZ^_`abfghjmqvxz|~\cAk-u)+print

(Note that second line starts with an actual \t tab character)
The code is 98 characters long and contains every ascii char exactly once, plus an extra -.
98 - 2 = 96
There are no string literals here, but removal of any single character breaks the program.
Deobfuscation
There are 3 statements in this program (well, actually 2 but I abused + as some kind of statement separator)

s{}[Hel0o, w3$=d!]
This is a very stretched case of the sed operator. It is more commonly written as s/a/b/, or s:a:b:, but perl allows much more fantasy here: s(a)(b) s(a)^b^ s(a)[b], and even s qaqbq.
It replaces an empty string (inside {}) with Hel0o w360d! (inside []) ($= interpolates to 60 by default). Because of the lack of an ~= operator, it operates on $_.

y<"#%&'*.124578:?@BCDEFGIJKLMNOQ/-9>(\n\t6PRSTUVWXYZ^_`abfghjmqvxz|~\cAk-u)
This is also a very stretched case, but of a tr operator, which is also called y (y< >( )).
Let's look at the replacement table:
" # %&'*.124578:?@BCDEFGIJKLMNOQ    /-9
\n\t6PRSTUVWXYZ^_`abfghjmqvxz|~\cA  k-u
I have moved some characters around so that existing string is not broken. The only actually working part here is /-9 -> k-u. It replaces 0 with l, 3 with o, and 6 with r.
Again because of lack of the ~= operator, it operates on $_
So now we have the complete phrase in the $_ variable.

print
Lack of arguments makes it print just the $_ variable.


Python advice: Portability of introspective function call

From the documentation:

  The resulting list is sorted alphabetically

As for the differences, I think you will have to check (and specifying in your answer is probably a good idea). There are clear differences between python 2 and 3, for example, __nonzero__ was renamed to __bool__.

I have never heard of any differences between implementations, but I can't find any references on this.

I don't think this has been used before in part because it will rarely save you any characters over doing something like:

F=str.capitalize
s='abc'
c=F(s)

You would need to use several different functions from dir() in order for this to be worth it.


Permutations with Indistinguishable Items

Python, 48 bytes
f=lambda l:l==[]or len(l)*f(l[1:])/l.count(l[0])

A recursive implementation.
In the formula, n! / (n_1! * n_2! * ...), if we remove the first element (say it's 1), the number of permutation for the remaining n-1 elements is
(n-1)! / ((n_1-1)! * n_2! * ...) ==
n! / n / (n_1! / n_1! * n_2! * ...) ==
n/n_1 * (n! / (n_1! * n_2! * ...)`)

So, we get the answer by multiplying by n/n1, the reciprocal-fraction of elements that equal the first one, by the recursive result for the rest of the list. The empty list gives the base case of 1.


Mathematica, 98 92 89 bytes

This solution solves S = 30 immediately:

(p={0};l={1};Do[l=Complement[##&@@{2#,Mod[a=#-1,2]#~Mod~3~Mod~2a/3}&/@l,p=p⋃l],{#}];l)&

This is an unnamed function taking S as its only parameter and returning a list of the Collatz cousins.

The algorithm is a simple breadth-first search. The Collatz cousins for a given S are all the integers that can be reached from the Collatz cousins for S-1 via 2*n or odd numbers that can be reached via (n-1)/3. We also need to ensure that we only produce those integers which were reached for the first time after S steps, so we keep track of all previous cousins in p and remove those from the result. Since we're doing that anyway, we can save a few bytes by computing the steps from all previous cousins (not just those from S-1) to save a few bytes (that makes it slightly slower, but not noticeably for the required S).

Here is a slightly more readable version:

(
  p = {0};
  l = {1};
  Do[
    l = Complement[
      ## & @@ {2 #, Mod[a = # - 1, 2] #~Mod~3~Mod~2 a/3} & /@ l,
      p = p ⋃ l
    ]~Cases~_Integer,
    {#}
  ];
  l
) &


Retina, 24 23 bytes

(.)(?<=\1(.{0,9}).)
$.2

Try it online!

A fairly simple regex substitution. We match each character and try to find a copy of it 0-9 characters before it. If we find it, we replace the character with the number of characters we had to match to get to the copy.

The results don't quite match the test cases, because this one uses the largest possible digit instead of the smallest possible one.


Convert numbers to symbols without string or char literals

C, 90 bytes

The line between a character and an integer literal is a very fine one in C.

a[]={8,0,31,2,3,4,61,5,9,7};main(d){for(;~(d=getchar());)putchar(d>47&d<58?a[d-48]+33:d);}


Split a word into parts with equal scores

Perl, 115 118 123

@_=~/./g;for$i(1..1<<@_){$l=$
r;$i&1<<$_?$l:$r+=64-ord$_[$_
]for 0..$#_;$l-$r||$i&1<<$_&&
print$_[$_]for 0..$#_;say""}

Run with perl -nE '<code goes here>'. That 'n' is counted in the code size.

Respaced:

@_ = /./g;
for $i (1 .. 1<<@_) {
  $l = $r;
  $i & 1<<$_ ? $l : $r -= 64 - ord $_[$_] for 0 .. $#_;

  $l - $r      ||
  $i & 1<<$_   &&
  print $_[$_]
    for 0 .. $#_;

  say ""
}

With comments and variable names:

# split a line of input by character
@chars = /./g;

# generate all binary masks of same length
for $mask (1 .. 1<<@_) {

  # start at "zero"
  $left_sum = $right_sum;

  # depending on mask, choose left or right count
  # 1 -> char goes left; 0 -> char goes right
  $mask & 1<<$_ ? $left_sum : $right_sum
    -= 64 - ord $chars[$_]   # add letter value
      for 0 .. $#chars;      # for all bits in mask

  # if left = right
  $left_sum - $right_sum ||

  # if character was counted left (mask[i] = 1)
  $mask & 1<<$_          &&

  # print it
  print $chars[$_]

  # ...iterating on all bits in mask
    for 0 .. $#chars;

  # newline
  say ""
}

Some of the tricks used:

1..1<<@_ covers the same bit range as 0..(1<<@_)-1 , but is shorter. (note that considering the problem from further away, including the range boundaries multiple times wouldn't result in a wrong output anyway)
$left_range and $right_range aren't reset to actual "0" numeric zero: since we just accumulate and compare them in the end, all we need is them to start at the same value.
subtracting 64-ord$_[$_] instead of adding ord$_[$_]-64 wins an invisible character: since it ends with a delimiter, it makes the space before for unnecessary.
Perl lets you assign to a variable determined by the ternary conditional operator: cond ? var1 : var2 = new_value.
boolean expressions chained with && and || are used instead of proper conditionals.
$l-$r is shorter than $l!=$r
will output a newline even on splits that don't balance.  Empty lines are ok by the rules!  I asked!


Haskell, 16 bytes

minimum.map head

Try it online!


Perl, 46 characters (safe)

Output:

((()))*++,---../00011123445556667779::;;<<==??@@AAACEFGHHHIKKMMNOOOPPQQQRRSSSVWXXYY[[[\]]]^^^```aaeeffggghjjjnpppqqrttuwxxyzz{{{

Code:

print _______________________________________;

I somehow managed to delete the original in the space of a week, but I think this is right:

   print chr()x(($i=($i*41+7)%97)&3)for(40..123);


Solve a matrix equation by Jacobi's method (Revised)

APL (Dyalog), 78 68 65 49 bytes

Exactly the type of problem APL was created for.
-3 thanks to Erik the Outgolfer. -11 thanks to ngn.
Anonymous infix function. Takes A b e as left argument and x as right argument. Prints result to STDOUT as vertical unary using 1 as tally marks, followed by 0 as punctuation. This means that even a 0-result can be seen, being no 1s before the 0.
{⎕←∨/e<|⍵-b⌹⊃A b e←⍺:⍺∇D+.×b-⍵+.×⍨A-⌹D←⌹A×=/¨⍳⍴A}

Try it online!
Explanation in reading order
Notice how the code reads very similarly to the problem specification:
{…} on the given A, b, and e, and and the given x,
 ⎕← print
 ∨/ whether there is any truth in the statement that
 e< e is smaller than
 |⍵- the absolute value of x minus
 b⌹ b matrix-divided by
 ⊃A b e the first of A, b, and e (i.e. A)
 ←⍺ which are the left argument
 : and if so,
  ⍺∇ recurse on
  D+.× D matrix-times
  b- b minus
  ⍵+.×⍨ x, matrix multiplied by
  A- A minus
  ⌹D the inverse of D (the remaining entries)
  ← where D is
  A× A where
  =/¨ there are equal
  ⍳ coordinates for
  ⍴A the shape of A (i.e. the diagonal)
Step-by-step explanation
The actual order of execution right-to-left:
{…} anonymous function where ⍺ is A b e and ⍵ is x:
 A b c←⍺ split left argument into A, b, and e
 ⊃ pick the first (A)
 b⌹ matrix division with b (gives true value of x)
 ⍵- differences between current values of x and those
 | absolute values
 e< acceptable error less than those?
 ∨/ true for any? (lit. OR reduction)
 ⎕← print that Boolean to STDOUT
 : and if so:
  ⍴A shape of A
  ⍳ matrix of that shape where each cell is its own coordinates
  =/¨ for each cell, is the vertical  and horizontal coordinates equal? (diagonal)
  A× multiply the cells of A with the that (extracts diagonal)
  ⌹ matrix inverse
  D← store in D (for Diagonal)
  ⌹ inverse (back to normal)
  A- subtract from A
  ⍵+.×⍨ matrix multiply (same thing as dot product, hence the .) that with x
  b- subtract that from b
  D+.× matrix product of D and that
  ⍺∇ apply this function with given A b e and that as new value of x


Jelly, 6 5 bytes

Thanks to @Lynn for saving 1 byte.

ṢFµJ⁼

Try it online! (comes with test-suite footer)

Explanation

ṢFµJ⁼    Main link. Argument: piles
Ṣ          Sort the piles by the size of the top bucket.
 F         Stack the piles, putting the left one to the top.
   J       See what a full pile with this many buckets would look like.
    ⁼      See if that looks like the pile you built.


Python 2, 165 180 bytes

At first I was thinking about writing my first Pyth program, got it to count the digits after the potential comma. But then I got quite annoyed, I don't know how you'd enjoy that language, guess it's just for winning purposes. Anyway here's my solution (edited since it didn't work for large numbers):

def t(i):
 o,a='',i
 while a[-1]=='0':
  a=a[:-1]
 while a[0]=='0':
  a=a[1:]
 if a[-1]=='.':a=a[:-1]
 if'.'in a:o=str(len(a)-a.index('.')-1)
 else:o='0'
 if a!=i:o+=" "+a
 print o

In case anybody wants to build on my work in Pyth: ~b@+cz"."" "1Wq@b_1"0"~b<b_1)plrb6 To see where you're at, you might want to insert a p between @+.


Python 2, 71 bytes

m,s=input()
for c in s.split('=')[:-1]:s=float(c or s);m-=1/s
print m<0

Try it online!

Python's dynamic type system can take quite some abuse.

Splitting the input string s.split('=') turns k equal signs into k-1 empty-string list elements (except at the end, where one must be cut off). For example,

"3.0===20====".split('=')[:-1] == ['3.0', '', '', '20', '', '', '']

The code iterates over these elements, updating the current speed s each time it sees a number. The update is done as s=float(c or s), where if c is a nonempty string, we get float(c), and otherwise c or s evaluates to s, where float(s) just keeps s. Note that c is a string and s is a number, but Python doesn't require doesn't require consistent input types, and float accepts either.

Note also that the variable s storing the speed is the same one as taking the input string. The string is evaluated when the loop begins, and changing it within the loop doesn't change what is iterated over. So, the same variable can be reused to save on an initialization. The first loop always has c as a number, so s=float(c or s) doesn't care about s's initial role as a string.

Each iteration subtracts the current speed from the allowance, which starts as the speed limit. At the end, the speed limit has been violated if this falls below 0.


Python 2, score: 11111111155
Score: sum(10**x+x-1 for x in range(1,11))
This program obtains the maximum possible score for any given x.
def f(x):
    s="0"*x
    while 1:
        for c in "1234567890":
            p=s+c
            if p[len(p)-x:]not in s:
                s=p
                break
        else:
            break
    return s

Try it online
This takes a long time to run for large inputs (like 6), because it's building strings thousands or millions of characters long. It also maintains a set of substrings and checks if a possible next substring is contained in it. It's not very efficient. I first tried a recursive solution, as well as a solution with a fixed number of iterations or something, but this was my working one.
Explanation:
I solved this by recognizing a pattern in the optimal solutions for x=1,2, which I created by hand as below. I roughly implemented the method I used to create f(2) in the function above, except that I just did zero last altogether.
1   0123456789
2   00102030405060708091121314151617181922324252627282933435363738394454647484955657585966768697787988990

This algorithm tries every number in order, with zero last. Failing to do zero last will result in an early termination. f(2), for example, would stop at 00102030405060708090, because all possible values starting with 0 have been exhausted. When doing this by hand, I simply started with f(1), added zeros between each digit, then went to every combination starting with a 1 (leaving out zero), then twos (leaving out zero and one), etc. Essentially, the algorithm must try the digit that you started with last.
The score is sum(10**x+x-1 for x in range(1,11)).
I used this formula to compute the score, because the output for all values 1-10 would probably take many days (months?) to complete. The highest I received the output for was f(6), which took ~10-15 minutes. It'd take at least 10000 times that for f(10). The lengths of s and p go from 1 to 10**x. The for loop runs exactly 10 times, no matter what.
Output:
They are slightly different than above because zeros are done last:
1   0123456789
2   00112131415161718191022324252627282920334353637383930445464748494055657585950667686960778797088980990
3   000111211311411511611711811911012212312412512612712812912013213313413513613713813913014214314414514614714814914015215315415515615715815915016216316416516616716816916017217317417517617717817917018218318418518618718818918019219319419519619719819919010210310410510610710810910022232242252262272282292202332342352362372382392302432442452462472482492402532542552562572582592502632642652662672682692602732742752762772782792702832842852862872882892802932942952962972982992902032042052062072082092003334335336337338339330344345346347348349340354355356357358359350364365366367368369360374375376377378379370384385386387388389380394395396397398399390304305306307308309300444544644744844944045545645745845945046546646746846946047547647747847947048548648748848948049549649749849949040540640740840940055565575585595505665675685695605765775785795705865875885895805965975985995905065075085095006667668669660677678679670687688689680697698699690607608609600777877977078878978079879979070870970088898808998908098009990900

I was going to make a pastebin of f(6), but it's past the maximum size limit a guest can create.
Validator - Counts how many unique subsets there are. If the result is 10**x, it's correct.


Sort the distinct elements of a list in descending order by frequency

APL (14)

{∪⍵[⍒+⌿∘.≡⍨⍵]}

This is a function that takes a list, e.g.:

      names
 John  Doe  Dick  Harry  Harry  Doe  Doe  Harry  Doe  John
      {∪⍵[⍒+⌿∘.≡⍨⍵]} names
 Doe  Harry  John  Dick

Explanation:

∘.≡⍨⍵: compare each element in the array to each other element in the array, giving a matrix
+⌿: sum the columns of the matrix, giving how many times each element occurs
⍒: give indices of downward sort
⍵[...]: reorder ⍵ by the given indices
∪: get the unique elements


Python 3, 14 bytes

lambda n:n%360

Try it online!


Python 2: 360* 387 586 594 - Characters

Reduced further

m,n,p=map(int,raw_input().split("/"));p-=1924;d=int("5od2nauh6qe4obvj8rf5pd2math6re3ocvi8sf5pd2l9uh6rf3nbvi7sg5pd2k9th6rf4navj7sg5oc1m9ti7qe3navj8sg5pc1math6qd3nbvj8sf4oc1ma"[p],36);p-=31*m-31+n<(d<21)*31+d;print"Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog Pig".split()[p%12],"Wood Fire Earth Metal Water".split()[p%10/2],["Yang","Yin"][p%2]

The above code works for the following interval:  5 Feb 1924 – 31 Dec 2043

Example: after pasting the above code in the python interpreter cursor

>>> m,n,p=map(int,raw_input().split("/"));p-=1924;d=int("5od2nauh6qe4obvj8rf5pd2math6re3ocvi8sf5pd2l9uh6rf3nbvi7sg5pd2k9th6rf4navj7sg5oc1m9ti7qe3navj8sg5pc1math6qd3nbvj8sf4oc1ma"[p],36);p-=31*m-31+n<(d<21)*31+d;print"Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog Pig".split()[p%12],"Wood Fire Earth Metal Water".split()[p%10/2],["Yang","Yin"][p%2]

and then press Enter, input a date like this

6/13/2018

and then press Enter again, output will be

Dog Earth Yang

* reduced further 27 bytes with Brian's help see comments.


JavaScript (ES6), 48 bytes
Expects (day1)(day2).
a=>b=>((g=s=>parseInt(s,34)%72%23)(a)-g(b)+21)%7

Try it online!
How?
We need a hash function \$g\$ that turns a day string into an index. The results of this function are actually quite flexible:

They can be in ascending or descending order: 0,1,2,3,4,5,6 or 6,5,4,3,2,1,0. (We'll have to compute either \$g(a)-g(b)\$ or \$g(b)-g(a)\$ accordingly.)
Day #0 may be any day of the week. For instance, 3,4,5,6,0,1,2 or 4,3,2,1,0,6,5 are also valid.
The results may be greater than \$6\$ as long as they are correct modulo \$7\$. Because the sign of the modulo is the sign of the dividend in JS, we'll have to do something like (g(a) - g(b) + k) % 7 anyway, where \$k\$ is a large enough multiple of \$7\$.

The following function was found by brute-force:
g = s => parseInt(s, 34) % 72 % 23

which gives:
 day         | base34 -> dec | mod 72 | mod 23 | mod 7
-------------+---------------+--------+--------+-------
 "Monday"    |      30369728 |   56   |   10   |   3
 "Tuesday"   |    1358300452 |    4   |    4   |   4
 "Wednesday" | 1702996445748 |   12   |   12   |   5
 "Thursday"  |   45612914380 |   52   |    6   |   6
 "Friday"    |      21127508 |   44   |   21   |   0
 "Saturday"  |   43748842416 |   24   |    1   |   1
 "Sunday"    |      38623568 |   32   |    9   |   2


GolfScript, 24 / 6 characters
{26,{65+.32+}%?)},{31&}$

Example:
> Johnny walked the dog to the park.
aaddeeeghhhJkklnnoooprtttwy

If the input is restricted to printable ascii the code can be shortened by three characters using {95&.64>\91<&}, as filter.
Can be tested here.
The can-be-ignored version is even shorter (6 chars):
{31&}$

and yields output
> Johnny walked the dog to the park.
      aaddeeeghhhJkkl.nnoooprtttwy


C

2^16 possible outputs (or 2^8 times the number of used characters).
Uses Linux's MD5 implementation, which is, AFAIK, fine. But this gives the same hash, for example, for "40" and "42".
EDIT: Renamed bcopy to memcpy (swapped parameters of course).
EDIT: Converted from program to function, to meet requirements better.

#include <string.h>
#include <openssl/md5.h>

void f(const unsigned char *input, unsigned char output[16]) {

    /* Put the input in a 32-byte buffer, padded with zeros. */
    unsigned char workbuf[32] = {0};
    strncpy(workbuf, input, sizeof(workbuf));

    unsigned char res[MD5_DIGEST_LENGTH];
    MD5(workbuf, sizeof(workbuf), res);

    /* NOTE: MD5 has known weaknesses, so using it isn't 100% secure.
     * To compensate, prefix the input buffer with its own MD5, and hash again. */
    memcpy(workbuf+1, workbuf, sizeof(workbuf)-1);
    workbuf[0] = res[0];
    MD5(workbuf, sizeof(workbuf), res);

    /* Copy the result to the output buffer */
    memcpy(output, res, 16);
}

/* Some operating systems don't have memcpy(), so include a simple implementation */
void *
memcpy(void *_dest, const void *_src, size_t n)
{
    const unsigned char *src = _src;
    unsigned char *dest = _dest;
    while (n--) *dest++ = *src++;
    return _dest;
}


05AB1E, 7 bytes

Òœ.ΔJÂQ

Try it online!

Explanation:

Ò            # prime factorization of the input
 œ           # permutations
  .Δ         # find the first one such that
    J        # concatenated
     ÂQ      # is a palindrome

(.Δ conveniently defaults to -1, so no extra work needed)


Python 2, 77 75 74 70 bytes
Thanks to @MartinEnder for suggesting the limit of 9e5 which enderd up working after a change.Thanks to @mschauer for suggesting an infinite stream, saving 4 bytes.
def f(n=0):
 i=f()
 while 1:n+=1;yield next(i)if'7'in`n`or n%7<1else n

This is a generator that yields an infinite stream of the numbers.


Bash, 4 11 bytes
Added 7 bytes to fix a bug kindly pointed out by Shaggy.

sort -sk1,1

Try it online!
Performs a stable sort (the s command line argument) based on the first field (k1,1) separated by whitespace.


Perl 6, 46 bytes

{.kv.map(*=>*+>1),.keys.grep:{.{$^k}%2}}o*.Bag

Try it online!

Explanation

{                                      }o*.Bag  # Convert to Bag and feed into block
                 ,  # 2-element list
 .kv  # Key-value list (key is sock type, value is count)
    .map(       )  # Map to
         *=>*+>1   # Pair of sock type and count right-shifted by 1
                  .keys  # Keys (sock types)
                       .grep:  # Filter
                             {.{$^k}%2}  # Count is odd


Scheme

Why should I be constrained on the platform used? Especially on such a developer-unfriendly platform as Windows! Anyways... doesn't matter since this code compiles on all Scheme implementations that provide the standard libraries srfi-1, srfi-27 and srfi-43 (that means almost all of them), on virtually (pun intended) every platform. The only non-portable-across-all-implementatons construct I use is "import", but I might as well have used "use" or "require" among others. This minor incompatibility between implementations will be fixed this year, don't worry.

Because of the holy wars pertaining to the Lisp family of languages on the matters of minimalism, the last standard in final status (R6RS) was rejected by most implementors, prefering instead to stick to R5RS until the steering comitee broke up. They came up with the idea to split the language in two, the first being a minimalistic core (assigned to working group 1). The second will be a superset of the first which will better suit daily usage. Both will form R7RS, which will be released this year. This will solve many incompatibilities between implementations.

;; Sudoku generator (v0.2)

;; list ops          randomness     vector ops
(import srfi-1) (import srfi-27) (import srfi-43)

(define rand (random-source-make-integers
                 default-random-source))

(define (shuffle! vec)
  (let swap! ([n (vector-length vec)])
    (let* ([i (rand n)] [n (- n 1)])
      (when (> n 1) (vector-swap! vec n i) (swap! n)))))

(define (make-row)
  (let ([row (vector-unfold (lambda (i) (+ i 1)) 9)])
    (shuffle! row) row))

(define (make-rows)
  (let f ([i 8] [r (make-row)])
    (cons r
      (if (zero? i) (list)
          (f (- i 1) (vector-copy r 1 10 (vector-ref r 0)))))))

(define (split-in ls n)
  (let ([n (quotient (length ls) n)])
    (let f ([ls ls])
      (if (null? ls) ls (cons (take ls n) (f (drop ls n)))))))

(define (make-grid)
  (let ([g (list->vector
              (map list->vector
              (zip (split-in (make-rows) 3))))])
    (shuffle! g) (vector-for-each shuffle! g)
    (vector-concatenate (vector->list g))))

Difficulty: none

I felt the code was too complicated so I rewrote it from scratch. For clue pruning, I am currently working on encoding the board in CNF notation. Since I have access to the original grid, testing for uniqueness is easier. Pruning is done by priority (we prefer to prune cells who maximize the number of possibilities in its surroundings).

So far, this only generates a valid complete grid using only a vector of numbers from 1 to 9 that swaps each index with a random index. This random row is used to derive the other rows by successive rotation. This works because there are only 8 other possible rows, given one sudoku row.

Thus, so far we have ensured there are no row or column conflicts possible. As a matter of fact, the sudoku is based on latin squares which are roman grids of size n*n (a square) which must have unique numbers on every row and column in the range 1 to n. A sudoku is a latin square of size 9*9, with an added constraint: regions.

The next step is to split the list of rows in 3, which now looks like this, given an initial row of (1 2 3 4 5 6 7 8 9):

;; this is a latin square
(((1 2 3 4 5 6 7 8 9)
  (2 3 4 5 6 7 8 9 1)
  (3 4 5 6 7 8 9 1 2))
 ((4 5 6 7 8 9 1 2 3)
  (5 6 7 8 9 1 2 3 4)
  (6 7 8 9 1 2 3 4 5))
 ((7 8 9 1 2 3 4 5 6)
  (8 9 1 2 3 4 5 6 7)
  (9 1 2 3 4 5 6 7 8)))

Given a grid like that, I can "zip" the lists (perform matrix transposition) so that it now looks like this:

;; this is now a sudoku
(((1 2 3 4 5 6 7 8 9)
  (4 5 6 7 8 9 1 2 3)
  (7 8 9 1 2 3 4 5 6))
 ((2 3 4 5 6 7 8 9 1)
  (5 6 7 8 9 1 2 3 4)
  (8 9 1 2 3 4 5 6 7))
 ((3 4 5 6 7 8 9 1 2)
  (6 7 8 9 1 2 3 4 5)
  (9 1 2 3 4 5 6 7 8)))

Magic! No row, column or region conflicts! What needs to be done next is to shuffle the three lists of rows, and the three rows within them. To do that, we convert all lists to vectors, then reuse the same shuffle procedure used with the first row. The last step is to collapse everything back to a grid of 9 rows.

I will post updates later. I am currently more advanced than this, but the rest is still in development (I promise you the cleverness and simplicity of my algorithms will surprise you). This was not done in one day, but with great amounts of research for optimal algorithms.


Smallest possible runnable Mach-O executable

Smallest runnable Mach-O has to be at least 0x1000 bytes. Because of XNU limitation, file has to be at least of PAGE_SIZE.
See xnu-4570.1.46/bsd/kern/mach_loader.c, around line 1600.

However, if we don't count that padding, and only count meaningful payload, then minimal file size runnable on macOS is 0xA4 bytes.

It has to start with mach_header (or fat_header / mach_header_64, but those are bigger).

struct mach_header {
    uint32_t    magic;      /* mach magic number identifier */
    cpu_type_t  cputype;    /* cpu specifier */
    cpu_subtype_t   cpusubtype; /* machine specifier */
    uint32_t    filetype;   /* type of file */
    uint32_t    ncmds;      /* number of load commands */
    uint32_t    sizeofcmds; /* the size of all the load commands */
    uint32_t    flags;      /* flags */
};

It's size is 0x1C bytes.
magic has to be MH_MAGIC.
I'll be using CPU_TYPE_X86 since it's an x86_32 executable.
filtetype has to be MH_EXECUTE for executable, ncmds and sizeofcmds depend on commands, and have to be valid.
flags aren't that important and are too small to provide any other value.

Next are load commands.
Header has to be exactly in one mapping, with R-X rights -- again, XNU limitations.
We'd also need to place our code in some R-X mapping, so this is fine.
For that we need a segment_command.

Let's look at definition.

struct segment_command { /* for 32-bit architectures */
    uint32_t    cmd;        /* LC_SEGMENT */
    uint32_t    cmdsize;    /* includes sizeof section structs */
    char        segname[16];    /* segment name */
    uint32_t    vmaddr;     /* memory address of this segment */
    uint32_t    vmsize;     /* memory size of this segment */
    uint32_t    fileoff;    /* file offset of this segment */
    uint32_t    filesize;   /* amount to map from the file */
    vm_prot_t   maxprot;    /* maximum VM protection */
    vm_prot_t   initprot;   /* initial VM protection */
    uint32_t    nsects;     /* number of sections in segment */
    uint32_t    flags;      /* flags */
};

cmd has to be LC_SEGMENT, and cmdsize has to be sizeof(struct segment_command) => 0x38.
segname contents don't matter, and we'll use that later.

vmaddr has to be valid address (I'll use 0x1000), vmsize has to be valid & multiple of PAGE_SIZE, fileoff has to be 0, filesize has to be smaller than size of file, but larger than mach_header at least (sizeof(header) + header.sizeofcmds is what I've used).

maxprot and initprot have to be VM_PROT_READ | VM_PROT_EXECUTE. maxport usually also has VM_PROT_WRITE.
nsects are 0, since we don't really need any sections and they'll add up to size.
I've set flags to 0.

Now, we need to execute some code. There are two load commands for that: entry_point_command and thread_command.
entry_point_command doesn't suit us: see xnu-4570.1.46/bsd/kern/mach_loader.c, around line 1977:

1977    /* kernel does *not* use entryoff from LC_MAIN.  Dyld uses it. */
1978    result->needs_dynlinker = TRUE;
1979    result->using_lcmain = TRUE;

So, using it would require getting DYLD to work, and that means we'll need __LINKEDIT, empty symtab_command and dysymtab_command, dylinker_command and dyld_info_command. Overkill for "smallest" file.

So, we'll use thread_command, specifically LC_UNIXTHREAD since it also sets up stack which we'll need.

struct thread_command {
    uint32_t    cmd;        /* LC_THREAD or  LC_UNIXTHREAD */
    uint32_t    cmdsize;    /* total size of this command */
    /* uint32_t flavor         flavor of thread state */
    /* uint32_t count          count of uint32_t's in thread state */
    /* struct XXX_thread_state state   thread state for this flavor */
    /* ... */
};

cmd is going to be LC_UNIXTHREAD, cmdsize would be 0x50 (see below).
flavour is x86_THREAD_STATE32, and count is x86_THREAD_STATE32_COUNT (0x10).

Now the thread_state. We need x86_thread_state32_t aka _STRUCT_X86_THREAD_STATE32:

#define _STRUCT_X86_THREAD_STATE32  struct __darwin_i386_thread_state
_STRUCT_X86_THREAD_STATE32
{
    unsigned int    __eax;
    unsigned int    __ebx;
    unsigned int    __ecx;
    unsigned int    __edx;
    unsigned int    __edi;
    unsigned int    __esi;
    unsigned int    __ebp;
    unsigned int    __esp;
    unsigned int    __ss;
    unsigned int    __eflags;
    unsigned int    __eip;
    unsigned int    __cs;
    unsigned int    __ds;
    unsigned int    __es;
    unsigned int    __fs;
    unsigned int    __gs;
};

So, it is indeed 16 uint32_t's which would be loaded into corresponding registers before thread is started.

Adding header, segment command and thread command gives us 0xA4 bytes.

Now, time to craft the payload.
Let's say we want it to print Hi Frand and exit(0).

Syscall convention for macOS x86_32:

arguments passed on the stack, pushed right-to-left
stack 16-bytes aligned (note: 8-bytes aligned seems to be fine)
syscall number in the eax register
call by interrupt

See more about syscalls on macOS here.

So, knowing that, here's our payload in assembly:

push   ebx          #; push chars 5-8
push   eax          #; push chars 1-4
xor    eax, eax     #; zero eax
mov    edi, esp     #; preserve string address on stack
push   0x8          #; 3rd param for write -- length
push   edi          #; 2nd param for write -- address of bytes
push   0x1          #; 1st param for write -- fd (stdout)
push   eax          #; align stack
mov    al, 0x4      #; write syscall number
#; --- 14 bytes at this point ---
int    0x80         #; syscall
push   0x0          #; 1st param for exit -- exit code
mov    al, 0x1      #; exit syscall number
push   eax          #; align stack
int    0x80         #; syscall

Notice the line before first int 0x80.
segname can be anything, remember? So we can put our payload in it. However, it's only 16 bytes, and we need a bit more.
So, at 14 bytes we'll place a jmp.

Another "free" space is thread state registers.
We can set anything in most of them, and we'll put rest of our payload there.

Also, we place our string in __eax and __ebx, since it's shorter than mov'ing them.

So, we can use __ecx, __edx, __edi to fit the rest of our payload.
Looking at difference between address of thread_cmd.state.__ecx and end of segment_cmd.segname we calculate that we need to put jmp 0x3a (or EB38) in last two bytes of segname.

So, our payload assembled is 53 50 31C0 89E7 6A08 57 6A01 50 B004 for first part, EB38 for jmp, and CD80 6A00 B001 50 CD80 for second part.

And last step -- setting the __eip. Our file is loaded at 0x1000 (remember vmaddr), and payload starts at offset 0x24.

Here's xxd of result file:

00000000: cefa edfe 0700 0000 0300 0000 0200 0000  ................
00000010: 0200 0000 8800 0000 0000 2001 0100 0000  .......... .....
00000020: 3800 0000 5350 31c0 89e7 6a08 576a 0150  8...SP1...j.Wj.P
00000030: b004 eb38 0010 0000 0010 0000 0000 0000  ...8............
00000040: a400 0000 0700 0000 0500 0000 0000 0000  ................
00000050: 0000 0000 0500 0000 5000 0000 0100 0000  ........P.......
00000060: 1000 0000 4869 2046 7261 6e64 cd80 6a00  ....Hi Frand..j.
00000070: b001 50cd 8000 0000 0000 0000 0000 0000  ..P.............
00000080: 0000 0000 0000 0000 0000 0000 2410 0000  ............$...
00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000a0: 0000 0000                                ....

Pad it with anything up to 0x1000 bytes, chmod +x and run :)

P.S. About x86_64 -- 64bit binaries are required to have __PAGEZERO (any mapping with VM_PROT_NONE protection covering page at 0x0). IIRC they [Apple] didn't make it required on 32bit mode only because some legacy software didn't have it and they're afraid to break it.


Output the language name times the number of characters

V, 2 bytes

iV

Try it online!

Citing Arnauld, with Levenshtein distance of 1:

  I now have 15 seconds of experience in V programming. So, this may actually be golfable.


Ruby, 44 bytes

t=''
26.times{|x|puts' '*(12-x/2)+(t<<65+x)}

Try it online!


Raku, 17 bytes

{S!\⅟!1/!.EVAL}

Try it online!

Returns a rational number type. Raku actually natively supports unicode literals and operators, though it doesn't do ⅟, so we need to substitute for that. Also, division by zero won't cause an error, but returns a value that causes an Exception when you try to use or print it.


Python 3, 71 bytes

lambda s:sum(t<=(*s,)for t in{*permutations(s)})
from itertools import*

Try it online!


Red, 259 bytes

c:"https://codegolf.stackexchange.com/review/"t: copy c
d:"low-quality-posts/stats"e:"first-posts/stats"
f: func[s q][parse find s q[thru{-count">^M^/}any" "copy n to" "(print[q n])]]
f read to-url append c d"DJMcMayhem"
f read to-url append t e"Martin Ender"

Try it online!

Unfortunately doesn't work in TIO - results in timeout, although works normally in Red console.


JavaScript (ES7), 50 bytes
This is using a slightly modified version of the formula that I've used and explained in this post.

x=>y=>(i=4*(x*x>y*y?x:y)**2)-(x<y||-1)*(i**.5-x-y)

Try it online!
or Try a version that displays the spiral.


JavaScript (ES6), 86 82 81 80 bytes
Input is expected in currying syntax f(s)(r), with:

s = string
r = ratio + direction: a negative float for inward or a positive float for outward

let f =

s=>r=>s.replace(/./g,(c,i)=>c+' '.repeat(n+=i<l?-r:r),l=s.length/2,n=r>0&&l*r+r)

console.log(f("INTERSTELLAR")(-1));
console.log(f("INTERSTELLAR")(-0.5));
console.log(f("CODEGOLF")(2));
console.log(f("CODEGOLF")(0.4));


CPAN, 16

use Acme::Bleach;

CPAN has it all.  Or at least, just the right module.


Lua, 258 248 242 bytes
u,s,p=1>0,0>1,0;io.read():gsub("%d+",function(a)if(not s)then p=u and p+a or p-a;if(p>=10 or p<=0)then s,p=1>0,p>0 and 10 or 0;end;u,s=not u,not s else s=0>1;end end)if(not s)then p=u and 10 or 0;u=not u;end;print(10*p.."% "..(u and"U"or"D"))

Ungolfed
u,s,p=true,false,0;                          -- Up direction, Stopped, Position
io.read():gsub("%d+",function(t)             -- For each number in input
    if(not s)then                            -- If door wasn't stopped
        p=u and p+t or p-t;                  -- Position = Moving up ? +t : -t
        if(p>=10 or p<=0)then                -- If door fully opened or closed
            s,p=true,p>0 and 10 or 0;        -- Then door stopped at 0 or 10
        end
        u,s=not u,not s;                     -- Toggle direction and toggle stopped
    else
        s=false;                             -- If stopped, nothing happened, un-stop.
    end
end)
-------------------- Done pressing the button --------------------
if(not s)then                                -- If left off moving
    p=u and 10 or 0;                         -- Finish movement
    u=not u;                                 -- Toggle direction
end
print(10*p.."% "..(u and"U"or"D"))           -- Output answer

I don't see how your test cases can be right...
20 20 -- Initial push, after 20, garage is at 100, push to start it down, after 20, garage is at 0, push to start it up, garage finishes up.
10 10 -- Same as above
1 2 3 -- 0 U Moving, wait 1, 1 D Stopped, wait 2, 0 U stopped, wait 3, 100 D stopped

 OP Fixed


Pyth, 38 bytes

M|strFGjHGsm?>Fd_g_d\Lgd?qFd\Z\R.:rzZ2

Demonstration.

M|strFGjHGsm?>Fd_g_d\Lgd?qFd\Z\R.:rzZ2
                                          Implicit: z = input(), Z = 0
                                          g is a function of a 2 letter string
                                          and an insert letter.
M                                         def g(G, H): return
    rFG                                   Take the string range between the
                                          letters in G.
   t                                      Remove the first letter to get just
                                          the letters in between.
  s                                       Concatenate.
 |                                        Logical or (if nothing in between)
       jHG                                H.join(G)
                                  rzZ     Convert input to lowercase.
                                .:   2    Take 2 letter substrings.
           m                              Map d over the substrings
            ?>Fd                          If the first character of `d`
                                          is greater than the second,
                 _g_\L                    g(d[::-1], 'L')[::-1]
                      gd                  else, g(d,
                        ?qFd              if the letters of d are the same,
                            \Z            'Z'
                              \R          else 'R')
          s                               Concatenate and print.


JavaScript (ES7),  86 83  82 bytes
Saved 3 bytes thanks to @xnor
Saved 1 byte thanks to @VarunVejalla
An approximation of Thomsen's approximation.

(a,b,c)=>(519*((a*b)**(p=1.535)+c**p*(b**p+a**p))/(31+27*a*b*c/(a+b+c)**3))**(1/p)

Try it online!


Mathematica, 61 bytes

Thanks to miles for saving 2 bytes, plus a whole bunch of bytes I counted for no reason!

Last@Select[{n,(#/n)^(1/n)}~Table~{n,2Log@#},IntegerQ@*Last]&

Computes a table of pairs {n,x}, where x = (i/n)^(1/n), using all possible values of n; keeps only those for which the corresponding x is an integer; then returns the pair with the largest value of n.

Here, "all possible values of n" ranges from 1 to 2*ln(i). This ignores the solution {n,x} = {i,1}, but that's okay since the solution {n,x} = {1,i} will suffice if it's the best choice. So x never needs to get smaller than 2, which means that n*2^n ≤ i, and all such n are less than 2*ln(i).

One can show using calculus that the pair {n,x} that minimizes their sum in this context is the same as the pair {n,x} with largest n (not counting {i,1}). That's why the initial Last is good enough to find the optimal pair.


Pure Bash, 32 bytes
eval echo \$[{1,${1// /\}*{1,}}]

Reads input list (single space separated) passed as a command-line arg.
Three different shell expansions are used:

${1// /\}*{1,} is a parameter expansion that replaces spaces in 2 3 5 7 with }*{1, to give 2}*{1,3}*{1,5}*{1,7.  \$[{1, and }] are added to the start and end respectively to give \$[{1,2}*{1,3}*{1,5}*{1,7}].  The \$[ is backslash-escaped to prevent attempts to do arithmetic expansion at this stage.
\$[{1,2}*{1,3}*{1,5}*{1,7}] is a brace expansion.  Because brace expansion typically happens before parameter expansion, we use have to useeval to force the parameter expansion to happen first.  The result of the brace expansion is $[1*1*1*1] $[1*1*1*7] $[1*1*5*1] ... $[2*3*5*7].
$[1*1*1*1] $[1*1*1*7] $[1*1*5*1] ... $[2*3*5*7] is a list of arithmetic expansions, which are then evaluated to give the list of numbers we require.

Output:
$ ./comboprime.sh "2 3 5 7"
1 7 5 35 3 21 15 105 2 14 10 70 6 42 30 210
$


The Euclidean Algorithm (for finding the greatest common divisor)

CJam, 46 43 39 bytes

q~]$3*~\{N5$"=("3$:G'*3$Gmd")+"\}h]7>NG

Try it online in the CJam interpreter.

How it works

q~]    e# Read all input, evaluate it and wrap the results in an array.
$3*    e# Sort the array and repeat it thrice.
~\     e# Dump the array and swap its last two elements.
{      e# Do:
  N    e#   Push a linefeed.
  5$   e#   Copy the sixth topmost element from the stack.
  "=(" e#   Push that string.
  3$:G e#   Copy the fourth topmost element from the stack. Save it in G.
  '*   e#   Push that character.
  3$   e#   Copy the fourth topmost element from the stack.
  Gmd  e#   Push quotient and remainder of its division by G.
  ")+" e#   Push that string.
  \    e#   Swap the string with the remainder.
}h     e#   If the remainder is positive, repeat the loop.
]7>    e# Wrap the stack in an array and discard its first seven elements.
NG     e# Push a linefeed and G.


Mathematica, 80 71 bytes

Thanks to JungHwan Min for saving 9 bytes!

Do[#!=Length[i~IntegerReverse~Range[2,i-2]~Cases~i]||Echo@i,{i,3,∞}]&

(∞ is the three-byte character U+221E.)
Pure function taking a nonnegative integer as input. i~IntegerReverse~Range[2,i-2] creates a list of the reversals of the number i in all the bases from 2 to i-2; then Length[...~Cases~i] counts how many of these reversals are equal to i again. #!=...||Echo@i halts silently if that count is not equal to the input, and echoes i if it is equal to the input. That procedure is embedded in a straightforward infinite loop.


Python 2, 80 79 77 bytes
-1 byte thanks to Surculose Sputum.
24-hour time, input as hours, minutes.

h,m=input();i=h
exec"print'ALCADcaamucgimbroraaasoni'[i-h::5],i%24,m;i+=1;"*5

Try it online!
Example output for 0, 30 (12:30AM):
Accra 0 30
Lagos 1 30
Cairo 2 30
Amman 3 30
Dubai 4 30


05AB1E, 2 bytes
₂∍

Try it online!

Explanation
 ₂                - 26
  ∍               - Extend/shorten to this length

Extend will repeat the string until it is length 26, shorten will remove chars from the right until it is length 26.
This means that some strings will be slightly more likely (the repeated ones since ab, abab, ababab, ababababab etc all produce ababababababababababababab, but it will fall within the 1%, since these cases of collision only occur for strings below length 26.

05AB1E, 8 bytes (Winning)
HSAsèJ₆∍

Try it online!
Program's name: faegdahbbafaegdahbbafaegdahbbafaegda

Explanation
HSAsèJ          - Convert it to a string of the first 10 letters of the english alphabet
      ₆∍        - Extend shorten to base 36 (10^36 > 2^100)

Can definitely be shorter, but why bother. It wins.


Pyth, 118 bytes

M++28@j15973358 4G&qG2!%H4FN.pmv>dqhd\0cz\.I&&&hN<hN13eN<eNhgFPNaYK+++*365JhtN/+3J4smghdJthNeNInK60aY-K+12>K60;-eSYhSY

Try it online: Demonstration or Test Suite.

Necessary knowledge of Julian and Gregorian Calendars

Julian and Gregorian Calendar are quite similar. Each calendar divides a year into 12 months, each containing of 28-31 days. The exact days in a month are [31, 28/29 (depends on leap year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]. The only difference between the calendars are their definition of a leap year. In the Julian Calendar any year divisible by 4 is a leap year. The Gregorian Calendar is a bit more specific. Any year divisible by 4 is a leap year, except the year divisible by 100 and not divisible by 400.

So in the 20th century only one year is different. The year 1900, which is a leap year in the Julian Calendar, but not a leap year in the Gregorian Calendar. So the only date, that exists in the one calendar but not in the other calendar is the day 29.02.1900.

Because of the different leap year definition, there's a difference between a date in the Julian Calendar and the Gregorian Calendar. 12 days difference for a date before the 29.02.1900, and 13 days difference for dates after the 29.02.1900.

Simplified Pseudo-Code

Y = []  # empty list
for each permutation N of the input date:
   if N is valid in the Julian Calendar:
      K = number of days since 0.01.1900
      append K to Y
      if K != 60:  # 60 would be the 29.02.1900
         L = K - (12 if K < 60 else 13)
         append L to Y
print the difference between the largest and smallest value in Y

Detailed Code Explanation

The first part M++28@j15973358 4G&qG2!%H4 defines a function g(G,H), which calculates the number of days in month G of a year H in the Julian Calendar.

M                            def g(G,H): return
      j15973358 4               convert 15973358 into base 4
     @           G              take the Gth element
  +28                           + 28
 +                &qG2!%H4      + (G == 2 and not H % 4)

And the next part is just the for loop, and the ifs. Notice that I interpret N in the format (month, year, day). Just because it saves some bytes.

FN.pmv>dqhd\0cz\.
             cz\.        split input by "."
    mv>dqhd\0            map each d of ^ to: eval(d[d[0]=="0":])
FN.p                     for N in permutations(^):

I&&&hN<hN13eN<eNhgFPN
I                          if
    hN                        month != 0
   &                          and
      <hN13                   month < 13
  &                           and
           eN                 day != 0
 &                            and
             <eNhgFPN         day < 1 + g(month,year):

aYK+++*365JhtN/+3J4smghdJthNeN
          JhtN                    J = year
     +*365J   /+3J4               J*365 + (3 + J)/4
    +              smghdJthN      + sum(g(1+d,year) for d in [0, 1, ... month-2])
   +                        eN    + day
  K                               K = ^
aYK                               append K to Y

InK60aY-K+12>K60
InK60                             if K != 60:
     aY-K+12>K60                    append K - (12 + (K > 60)) to Y

;-eSYhSY
;          end for loop
 -eSYhSY   print end(sorted(Y)) - head(sorted(Y))


JavaScript, 125 112 105 bytes

To use, add f= at the beginning and invoke like f(argument).

a=>a.map(b=>b.map(p=>+p?p:p?eval(p.replace(/[A-I][1-9]/g,m=>`a[${m[1]-1}][${(m.charCodeAt(0)-65)}]`)):0))

Choices:

Does not require =.
The left most cell of second row is A2.
Does not require any prefix or suffix.
"" (Empty String) to denote empty cell.
JavaScript.
JavaScript.
Cookies.

Explanation:

This solution iterates over all the cells of the worksheet (each element of the sub-arrays of the given array) and if non-empty String is found, replaces its cell references with the corresponding references in terms of the given array and evaluates the expression with eval() (yeah, that evil thing that haunts you in your nightmares). This solution assumes that the constants provided in the input array are of Integer type.

Test Cases

f=a=>a.map(b=>b.map(p=>+p?p:p?eval(p.replace(/[A-I][1-9]/g,m=>`a[${m[1]-1}][${(m.charCodeAt(0)-65)}]`)):0))

console.log(f([[1,2,3],["A1+B1+C1",10,11]]));
console.log(f([[1,2,5,4,6,89,0],[0,1,2,3,"A2+A1",5,6]]));
console.log(f([[1,2,4,5],["A1/B1*C1+A1+Math.pow(5,B1)",2,3,4]]));


Can you make your way through the Ulam spiral?

JavaScript (ES6), 169 bytes
Saved 1 byte thanks to @att
Expects (z)(x,y). Returns false if there's a solution or true otherwise.

z=>F=(X,Y,i=z,k)=>--i?[-1,0,1,2].every(d=>(g=d=>n%--d?g(d):d==1)(n=(k=2*Math.max(x=X+d%2,-x,y=Y+~-d%2,-y))*k-~(-y<x?y-k-x:k+x-y))|F[k=[x,y]]||F(x,y,i,F[k]=1)|--F[k]):X|Y

This is fast enough for all existing test cases, but I guess it's likely to time out on some other ones.
Try it online!
Commented
NB: the spiral formula is similar to the one I used in my answer to Spiral neighbourhoods.
z =>                              // outer function taking z
F = (                             // main recursive function taking:
  X, Y,                           //   (X, Y) = current position
  i = z,                          //   i = move counter initialized to z
  k                               //   k = local variable whose initial value is ignored
) =>                              //
  --i ?                           // decrement i; if it's not equal to 0:
    [-1, 0, 1, 2].every(d =>      //   for each direction d:
      ( g = d => n % --d ? g(d)   //     g is a recursive primality test function
                         : d == 1 //     which is invoked ...
      )(                          //
        n =                       //     ... on the 1-indexed square ID n defined as:
          ( k = 2 * Math.max(     //       k² + (k + x - y) * s + 1
              x = X + d % 2, -x,  //       with:
              y = Y + ~-d % 2, -y //         x = X + dx
            )                     //         y = Y + dy
          ) * k -                 //         k = 2 * max(|x|,|y|) = 2 * max(x,-x,y,-y)
          ~(-y < x ? y - k - x    //         s = -1 if -y < x or 1 otherwise
                   : k + x - y)   //
      )                           //     abort if n is prime
      | F[k = [x, y]]             //     or (x, y) was already visited
      || F(x, y, i, F[k] = 1)     //     otherwise mark (x, y) as visited and do a
                                  //     recursive call with the new position
      | --F[k]                    //     clear the mark afterwards
    )                             //   end of every()
  :                               // else:
    X | Y                         //   falsy if and only if X = Y = 0


Python 2, 50 39 bytes

-10 thanks to @JonathanAllan

f=lambda x:x>9and-~f(sum(map(int,`x`)))

Try it online!


Return the integers with square digit-sums

Pyke, 6 bytes
#s,DBq

Try it here!
#      - Filter list on truthiness:
 s     -    digital_root(^)
  ,    -   sqrt(^)
    Bq -  int(^) == ^


Only use subframe logic when it's smaller

And, for more complex machines, it's often much smaller.

Subframe generally imposes the overhead of creating solid SPRK (about 3 pixels for most directions, an extra pixel compared to just a BTRY), FILT 'channels' (for fast BRAY transfer), and minimizing the amount of nonsubframe logic, even if it's smaller, due to it being many times (4x to 20x-30x slower!) slower.

Subframe logic is often good for complex operations (which is most of the challenges here), but for simpler ones, subframe logic is probably not optimal.


How many contiguous "strings" can you find in a set of strings?

///, 6634204313747905 > 958

From

string/.~~~~~/0

to

string/0     /.~

This relies on the program not being required to terminate. I started from a core-range of 958 much like the other solutions, from

string//

to

string//~~~~~~~~

However, in this case, // is not a comment. In /// everything that's not a slash is just printed (hence this always prints string before doing anything else). A slash then starts a substitution pattern of the form /pattern/replacement/. If only one or two / are found, then the program simply terminates. However, the above range obviously also includes strings with three or more slashes. The trick here is that the pattern to be searched for is empty, and substitutions are performed iteratively until the pattern cannot be found any more. Since the empty string can always be found, this substitution never terminates, and hence the program never gets around to print anything after the initial string.

But since this doesn't rely on // being a comment, we can actually go a bit further! E.g. the previous and next string around this range, respectively, are:

string/.~~~~~~~~
string/0

These still don't contain a full substitution instruction so they also only print string and then terminate. Let's see how far we can go! I'll focus on the upper end of the range (the lower end works analogously). What if we get another /? The first time this happens is

string/0       /

But that's still not a valid replacement pattern, so all is well. It looks like we need three slashes to break the magic. The first time we get three slashes is at

string/0      //

What now? Well, the pattern to be searched for is 0 (and a bunch of spaces), to be replaced with an empty string. That pattern is never found, so the substitution completes immediately. But luckily, there is nothing to print afterwards in the source code, so the result is still only string. Neat. :)

So we need a valid substitution instruction and more source code afterwards to not print string:

string/0     //

And this is indeed the first code that doesn't work to spec, as it prints string followed by a space. So the last code that works is

string/0     /.~

We can apply the same argument to the beginning of the range, the last failing code being

string/.~~~~~//~

such that the first code that works is

string/.~~~~~/0


Automate your first grade counting exercise

Perl 6, 119 113 bytes

{my \n=<① ⑳ ㉑ ㉟ ㊱ ㊿>.map:{|map *.uniname.words[2..*].join,$^a..$^b}
/\d/??n[^$_]!!1..1+first $_,n,:k}

Unicode database FTW!

Uses upper-case written-out numbers without hypen, e.g. TWENTYTWO.
Returns a list of strings, or a range of numbers. (Both use space as separator when printed with put.)


Jelly, 26 24 23 21 bytes

ÆDf÷ß€FðḊ¡
1ç#2+Ð¡1¤Ṫ

Try it online!

How it works

1ç#2+Ð¡1¤Ṫ  Main link. Argument: n (integer)

        ¤   Combine the three links to the left into a niladic chain.
   2          Set the left argument and the return value to 2 (third positive
              Fibonacci number).
       1      Yield 1 (second positive Fibonacci number).
    +Ð¡       Compute the sum of the return value and right argument, replacing the
              return value with the sum and the right argument with the previous
              return value.
              Do this n times, collecting all return values in a list.
              This returns A, the first n Fibonacci numbers greater than 1.
1             Set the return value to 1.
 ç#           Call the helper link with left argument k = 1, 2, 3... and right
              argument A = [2, 3, 5...] until n of them return a truthy value.
              Collect the matches in a list.
           Ṫ  Tail; extract the last (n-th) match.

ÆDf÷ß€FðḊ¡    Helper link. Left argument: k. Right argument: A

        Ḋ     Dequeue; yield r := [2, ..., k].
       ð ¡    If r in non-empty, execute the chain to the left. Return k otherwise.
ÆD              Yield the positive divisors of k.
   ÷            Divide k by all Fibonacci numbers in A.
  f             Filter; keep divisors that belong to k÷A, i.e., all divisors
                d for which k÷d belongs to A.
    ß€          Recursively call the helper link for each kept divisor d, with left
                argument d and right argument A.
      F         Flatten the result, yielding a non-empty array iff any of the
                recursive calls yielded a non-empty array or a number.
                If the left argument is 1, the helper link returns 1, so the
                array will be non-empty if the consecutive divisions by Fibonacci
                numbers eventually produced a 1.


Python, 992

Takes input from stdin and prints the solution.   Note that SE has turned my tab characters into four spaces - anything indented beyond one space should be a tab.

It shouldn't be too hard to beat this, but I thought I'd post it since no one else had posted a solution.

L=len
R=range
j=[(-1,0),(1,0),(0,-1),(0,1)]
P=lambda y,x,q:(y,x)==(0,w)and[q+[(y,x)]]or sum([P(y+e,x+d,q+[(y,x)])for e,d in j if not(y+e,x+d)in q and 0<=x+d<=w and 0<=y+e<=h],[])
def C(q,y,x,v):
 if(y,x)in v:return
 v.add((y,x))
 for e,d in j:
    Y,X=y+e,x+d;a,b=[(y+(e+s*d+1)/2,x+(d+s*e+1)/2)for s in[-1,1]]
    if 0<=X<w and 0<=Y<h and not(a in q and b in q and abs(q.index(a)-q.index(b))==1):C(q,Y,X,v)
def G(s,c):
 if not s:return not c
 for y,x in r:
    p=set((Y+y,X+x)for Y,X in s[0])
    if c&p==p and G(s[1:],c-p):return 1
def B(q):
 for y,x in r:
    c=set();C(q,y,x,c);s=[h for(w,h)in p if w in c]
    if s and not G(s,c):return 1
h,p,g=0,[],[]
try:
 while 1:
    s=raw_input()
    if'('in s:l,o=s.split('->');p.append(map(eval,[o,'('+l.replace(')','),')+')']))
    else:g.append(list(s))
except:h=L(g)/2-1;w=L(g[0])/2-1
r=[(x/w,x%w)for x in R(w*h)]
for s in P(h,0,[]):
 if not B(s):break
for(a,b),(c,d)in zip(s,s[1:]):g[1+2*a][1+2*b]=g[1+a+c][1+b+d]=g[1+2*c][1+2*d]='*'
print'\n'.join(''.join(r)for r in g)

Quick rundown of how it works:

P finds all possible paths.

C finds all the squares that are connected to a given square.

G determines whether or not a set of shapes fit exactly in a set of squares.

B determines whether or not a path is bad by checking each connected set of squares and checking if their shapes fit.

Examples

input:

(0,0)(0,1)->(2,1)
(0,0)(0,1)->(0,1)
(0,0)->(0,2)
=========
|       |
| X X X |
|       |
| X X X |
|       |
| X X X |
|       |
=========

output (all tetris pieces are grouped into the top-right):

=========
|***   *|
|*X*X X*|
|* *   *|
|*X*X X*|
|* * ***|
|*X*X*X |
|* ***  |
=========

input:

(0,0)(0,1)(0,2)(1,2)(2,2)->(0,0)
(0,0)(1,0)(0,3)(1,3)->(2,1)
(0,0)(1,0)(2,0)->(1,3)
===========
|         |
| X X X X |
|         |
| X X X X |
|         |
| X X X X |
|         |
| X X X X |
|         |
===========

output (this is the only one that's the same as the example solution):

===========
|      ***|
| X X X*X |
|      ***|
| X X X X*|
|        *|
| X X X X*|
|*** *****|
|*X*X*X X |
|* ***    |
===========

input:

(0,0)(1,0)(2,0)->(1,0)
(0,0)(1,0)(2,0)->(1,6)
(0,0)(0,1)(0,2)->(1,3)
=================
|               |
| X X X X X X X |
|               |
| X X X X X X X |
|               |
| X X X X X X X |
|               |
=================

output (rightmost 2 pieces are grouped together):

=================
|*** *** *******|
|*X*X*X*X*X X X |
|* * * * *******|
|*X*X*X*X X X X*|
|* * * * *******|
|*X*X*X*X*X X X |
|* *** ***      |
=================


Perl, 74 (73 + 1) bytes

Assumes -n flag (+1 byte).
say is a feature of version 5.10 and needs to be enabled.
This can be done by flag -M5.010 or easier with -E instead of -e.
Therefore I follow the other Perl answer in the calculation method of the costs.
It also reports repetitions as long as they do not overlap.

s/(.+)(?{$i=1})(\1(?{$i++}))+/say"$1 * $i"/ge||say"No repetitions found!"

Usage and tests

echo 112211221122 | perl -nE 's/(.+)(?{$i=1})(\1(?{$i++}))+/say"$1 * $i"/ge||say"No repetitions found!"'
1122 * 3

echo 123123 | perl -nE 's/(.+)(?{$i=1})(\1(?{$i++}))+/say"$1 * $i"/ge||say"No repetitions found!"'
123 * 2

echo 1234 | perl -nE 's/(.+)(?{$i=1})(\1(?{$i++}))+/say"$1 * $i"/ge||say"No repetitions found!"'
No repetitions found!

echo 123123456456 | perl -nE 's/(.+)(?{$i=1})(\1(?{$i++}))+/say"$1 * $i"/ge||say"No repetitions found!"'
123 * 2
456 * 2

Ungolfed with comments

s/
    (.+)              # catches the repeat unit
    (?{ $i=1 })       # initialize counter $1 with 1
    (
        \1            # next repetition
        (?{ $i++ })   # increase counter
    )+                # repeat unit must appear at least twice
/
    say "$1 * $i"     # print result as a side effect of the replacement;
                      # "say" adds a new line at the end
/gex                  # g: global, find all repetitions (without overlap)
                      # e: replacement text is executed as code
                      # x: only ungolfed: readability and comments
    ||                # s/// returns the number of replacements,
                      # this is zero, if no repetitions could be found
    say "No repetitions found!"


PowerShell, 95 92 87 bytes
-8 bytes thanks to mazzy!
This takes two parameters, m and k, and calculates all (m,k) perfect numbers (up to the maximum for a 64-bit signed integer).

param($m,$k)for(;$n=++$x){1..$m|%{$a=0;1..$n|%{$a+=$_*!($n%$_)};$n=$a}
,$x*!($a-$k*$x)}

Try it online!


Splitting with numbers to save the quotemarks:

"alpha,bravo,charlie".split(",") // before
"alpha0bravo0charlie".split(0)   // after


PowerShell, 118 113 112 108 102 101 99  96 - 10% = 86

Code

$s=(Read-Host)*180;for(){Write-Host($s.substring(($i=++$i%80),80)+"`r")-N -F R -B 0;sleep -m 99}

With the caveat that it now begins the first loop with the second character; The rules don't say it has to start from the front of the string, and the first one is included overall, so that's fine by me. I will get it to 100 chars somehow - edit: thanks @ConnorLSW for the edits to get it below 100.

Instructions

Run PowerShell (normal console, it doesn't work in PowerShell ISE)
Paste the single line version into PoSH, press enter
Type a message, press enter
Ctrl-C to break

Output

Notes

A more readable version with the variable names and parameters filled out a bit:

$test = (Read-Host) * 180
for () {
    Write-Host ($text.substring(($i=++$i%80), 80)+"`r") -NoNewLine -ForegroundColor Red -BackgroundColor Black
    sleep -Miliseconds 99
}

The parameters only need to be long enough to be unique, so -F R is unique enough to set a Red ForegroundColor, for example.
'Black' has to be 'Bla' to be unique compared to 'Blue', but -B 0 sets it to color Enum value 0 which is interpreted as Black.

Alternative, more 'correct' marquee:

The reference code doesn't handle strings longer than 80 characters nicely, skipping anything in the message past ~160 characters, and it glitch-resets every 99*len(string) characters. e.g. if the sign width was 5 characters long, it does this:

   here is my long test input
 0 |here |
 1  |ere i|          ^^^^ never shown
 2   |re is|
 3    |e is |
 4     | is m|
 0 |here |
 1  |ere i|
    ...

This version indexes modulo the text length instead of the sign width, so it runs through the whole string. 106 - 10% = 95 chars.

$l=($s=Read-Host).Length;for(){Write-Host(($s*160).substring(($i=++$i%$l),80)+"`r")-N -F R -B 0;sleep -m 99}

Alternative: sign which cycles like the .gif in the question, 118-10%=106

Because it looks better.

$s=' '*80+(read-host)+' '*80;for(){write-host($s.Substring(($i=++$i%($s.length-80)),80)+"`r")-N -F R -B 0;sleep -m 99}


Mathematica, 169 bytes

All those annoying options. :(

f=Export[p=GoldenRatio;"a.png",ParametricPlot[p^(2t-3){Cos[a=t*Pi],Sin@a},{t,0,#/2},PlotRange->{r={m=-p^(#-3),-m},r},PlotStyle->Black,Axes->1<0,ImageSize->p^#~Floor~4]]&

This function saves the spiral to a.png in wherever your current working directory is.

The result of f[9]:

The result of f[12]:

I hope I understood all the bits about the scaling correctly.

There's not a whole lot to say about the code. I'm using ParametricPlot to draw curve as a parameterised function in t which advances by 1/2 for each quarter turn. The rest is done in the options:

PlotRange->{r={m=-p^(#-3),-m},r} makes sure we have an square aspect ratio which just covers the outermost point of the spiral.
PlotStyle->Black overwrites Mathematica's blue default colour.
Axes->1<0 is just Axes->False (and turns off the axes, who knew!).
ImageSize->p^#~Floor~4 sets the correct dimensions in pixels, by noticing that ⌊n/4⌋*4 just means "n rounded down to the nearest multiple of 4".


Largest monetary amount impossible to make with two types of coin

J, 7,6 3 bytes

-1 byte thanks to FrownyFrog !

-3 bytes thanks to Grimmy!

*-+

Try it online!

     -    subtract
      +   the sum of the arguments
    *     from their product


Bijection: tree-like lists - natural numbers

Python 2, 118 114 109 105 103 97 94 bytes

f=lambda x:x>[]and f(x[:-1])*2+1<<f(x[-1])
g=lambda n:[g(len(w))for w in bin(n).split('1')[1:]]

Try it online!

Same encoding as the example...


Python, 172 chars
lambda a:'-mbda#l.fn()+1: \\\'i'.find(a)+1#\\\\\\\\\\\\\\((((((((())))))))))fffffffbd####lllll......nnnnnnnn+1+1+1+1+1+1+1+1+1+1+11:::::::::::::              '''''''''''''''iiiiiiiiiiiiiiiii

Using str.find()+1 to generate 0 for any character not in program.
Using comment for complement.


Avoid duplicate entries using a sign change

JavaScript

Take a conventional algorithm and write it with a bug:

function merge(a, b) {
  var ai = 0, bi = 0, oi = 0;
  var o = [];
  while (ai < a.length && bi < b.length) {
    var v = a[ai] < b[bi] ? a[ai++] : b[bi++];
    if (v !== o[oi + 1]) {
      o[oi++] = v;
    }
  }
  while (ai < a.length) o[oi++] = a[ai++];
  while (bi < b.length) o[oi++] = b[bi++];
  return o;
}

This code contains exactly one literal 1. If it is changed to -1, then duplicates will be removed. It can be used on any comparable values.


TI-BASIC, ~269

Input N
Lbl 1
2→P                                       :"  test N for divisibility by each prime
Lbl 2
If int(N/P)=N/P:Goto 3    :"composite"
If PP>N:Goto 4
P+1→P
Goto 2
Lbl 3
Disp "                NOT PRIME.               "
Stop
Lbl 4
If int((N+2)/3)=(N+2)/3                    :" determine which nearby value to test
Then:N-2→R
Else:N+2→R
End
2→P
Lbl 5
If int(R/P)=R/P:Goto 6    :"composite"
If PP>R:Goto 7
P+1→P
Goto 5
Lbl 6
Output("ISOLATED PRIME.")
Lbl 7          :" TI-BASIC how two ways of printing:
               :" Disp goes to the main screen,
               :" and Output goes to the graphical screen.
               :" This program uses both methods.
If R=N+2:Goto 5              :" go to print "lower twin prime"
Disp "UPPER TWIN PRIME"
Goto 7          :" only 16 chars can be printed per line, so we'll do the period separately (last line of program)
Lbl 5
Output("LOWER TWIN PRIME")
Lbl 7
Disp "."

   The NOT PRIME string has sixteen leading spaces, so nothing (except an ellipsis) will be printed, as noted in the comments.
 The ISOLATED PRIME string uses the Output() function, which requires two numbers (the coordinates of the printing location). This triggers an Argument Error.
 The LOWER TWIN PRIME string is indicated by the link to Lbl 5, which was already defined as the start of the twin prime test, causing an infinite loop.
 The UPPER TWIN PRIME string is followed by a link to the period, but Lbl 7 was already defined above, triggering an infinite loop.


GolfScript, 82 72 67 characters
.,n*{:c,,{[).2$1<*\c>+1$.,,{).2$<\3$<=},,.@>@@>]}%\;{~S)}%$0+0=}:S~

Reasonably fast for a GolfScript program, examples:
> hyghgy
4

> pbgbrgrp
5

The algorithm used works through the colors left-to-right recursively, according to the following statements:

Ignore all parts from the left which already have the required color. Overpainting them again will not provide a better answer.

If the complete stick already has the desired color, return 0 steps as result.

Otherwise, take the target color of the now leftmost part (i.e. the first not in the desired color).

Paint 1 part with the target color and recurse.
Paint 2 parts with this color and recurse.

...

Paint the whole remaining stick with this color and recurse.

Take the minimum of all those numbers and add 1 (for the current step). Return this as the optimal number of steps.

This algorithm works, because the leftmost part has to be painted at one time anyways, so why not do it immediately - in any possible fashion.
.,n*         # prepare the initial situation (target stick, unpainted stick)
             # used n instead of '-' for the unpainted parts, because it is shorter
{            # Define the operator S which does t c S -> n
             #   - t: the desired target colors
             #   - c: the stick as it is colored currently
             #   - n: minimum number of steps required to go from c to t
  :c         # Assign the current configuration to the variable c
  ,,{[       # Map the list [0 1 2 .. L-1]
             # We will build a list of all possible configurations if we paint
             # the stick with the 0th part's color (either 1 or 2 or 3 or ... parts)
    ).       # Increase the number, i.e. we paint 1, 2, 3, ... L parts, copy
    2$1<     # Take the first color of the target configuration
    *        # ...paint as many parts
    \c>+     # ...and keep the rest as with the current stick
    1$       # take the target configuration
             # Top of stack now e.g. reads
             #    h----- hyghgy (for i=0)
             #    hh---- hyghgy (for i=1)
             # Next, we strip the common leading characters from both strings:
    .,,      # Make list [0 1 2 ... L-1]
    {        # Filter {}, all the numbers for which the first j+1 parts are the same
      ).     # incr j
      2$<    # take leftmost j parts of stick A
      \3$<   # take leftmost j parts of stick B
      =      # are they equal?
    },,      # The length of the result is the number of common parts.
    .@>      # cut parts from A
    @@>      # cut parts from B
  ]}%
  \;         # Remove the target from the stack (not needed anymore)
             # We now have a list of possible paintings where 1, 2, ..., L parts were
             # painted from the left with the same color.
             # All configurations were reduced by the common parts (they won't be
             # painted over anyways)
  {~S)}%     # Call the method S recursively on the previously prepared configurations
  $0+0=      # $0= -> sort and take first, i.e. take the minimum, 0+ is a workaround
             # if the list was empty (i.e. the operator was called with a stick of length 0).
}:S
~            # Execute S


Number of unique outputs by substituting variables

Mathematica, O(k^2(k!)^2) time
Length[Union@@(Fold[Flatten[{StringReplace[#,#2->"0"],StringReplace[#,#2->"1"]}]&,#,Union[Characters[#]]]&/@#)]&

Hopefully I calculated the time complexity correctly. Input is a list of formulas such as {"bacb","bcab","cbba","abbc"}. Runs in less than 30 seconds for every test case on my machine, but who cares about absolute times?
Explanation:

First off, the & at the end makes it a pure function, with # referring to the first argument, #2 being the second argument, etc.
Length[*..*] takes the length of the list contained inside it.
Union@@(*..*) takes the contained list and supplies it as the arguments for Union, which returns a list of the unique elements in any of its arguments.
*..*&/@# takes a pure function and maps it over the list of formulas, so that {a,b,c} becomes {f[a],f[b],f[c]}. Note that in nested pure functions, #n refers to its innermost arguments.
Fold[*..*&,#,*..*] takes a accumulator function, starting value, and list, and returns f[f[...[f[starting value,l_1],l_2],...],l_n].
Union[Characters[#]] takes all the characters in the current formula and gets all the unique elements, giving us the variables.
Flatten[*..*] flattens its argument, so that {{{a},b},{{c,{d}}}} becomes {a,b,c,d}.
{*..*,*..*} is simply a way to combine the two results using the above Flatten.
StringReplace[#,#2->"0/1"] takes the previous result and returns it with the current variable replaced with either 0 or 1.


Language

For example, Python is an interpreted language, not a compiled language, so it would surely be faster if you wrote it in C to begin with.

Rust, C++, C, javascript, and Haskell seem to be popular choices. One would have to evaluate them.


Order is important
Swap lines that are referenced more frequently than other lines with less referenced lines that are referenced by a small digit number.
Example:
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> Input
>> #10
>> [10]
>> Output 11 12

The input is referenced twice and the line number is 10. If this line is moved up to line 1. Both 10s are replaced by 1s. In this example 2 bytes were saved.
> Input
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
>> #1
>> [1]
>> Output 11 12

Moving line 11 and 12 up saves another 2 bytes.
> Input
>> #1
>> [1]
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
>> Output 2 3

I wrote a script that takes a Whispers program as input and prints the optimized re-ordered program.
TIO | Github


Jelly, 4 bytes
OÆPẠ

Try it online!
Explanation
Remember that a string is an array of characters, so operations like O will apply to each individual character.
OÆPẠ
O        Ord; cast each character to a number
 ÆP      Is it ÆPrime? gives 1 for truthy and 0 for falsey
   Ạ     Ạll; returns 1 if the array contains no falsey values


Retina, 15 bytes

(^.+?|\1)+$
$#1

Try it online!

Matches the entire string by repeating a substring (shorter substrings are prioritised due to the ungreedy .+?) and replaces the entire string with the number of repetitions we used.


LOGO 37 - 25% = 27.75 (with variables)

REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]

LOGO 49 - 25% = 36.75 (as a function)

TO P:R:S REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]END

Triangle

Called with variables

Make "R 100
Make "S 3
REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]

Used as a function P 100 3

Square

Called with variables

Make "R 100
Make "S 4
REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]

Used as a function P 100 4

Pentagon

Called with variables

Make "R 100
Make "S 5
REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]

Used as a function P 100 5

Decagon

Called with variables

Make "R 100
Make "S 10
REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]

Used as a function P 100 10

Circle

Called with variables

Make "R 100
Make "S 360
REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]

Used as a function P 100 360


What do you see in an inkspot? Rorschach generation'

Python

Not quite the best or smoothest, but here's a python solution:

from PIL import Image
import random
import sys

imgsize = (int(sys.argv[1]), int(sys.argv[2]))
color = (0, 0, 0)
img = Image.new("RGB", imgsize, "white")

for j in range(0,int(sys.argv[3])):
    start = (random.randrange(0, imgsize[0]/2), random.randrange(0, imgsize[1]))
    point = start
    img.putpixel(point, color)

    blotsize = random.randrange(0, int(sys.argv[4]))
    for i in range(blotsize):
        directions = [(point[0], point[1]+1), (point[0], point[1]-1), (point[0]+1, point[1]), (point[0]-1, point[1])]
        toremove = []
        for direction in directions:
            if direction[0]>=(imgsize[0]/2) or direction[1]>=imgsize[1] or direction[0]<0 or direction[1]<0:
                toremove.append(direction)
        for d in toremove:
            directions.remove(d)
        point = random.choice(directions)
        img.putpixel(point, color)

cropped = img.crop((0, 0, imgsize[0]/2, imgsize[1]))
img = img.transpose(Image.FLIP_LEFT_RIGHT)
img.paste(cropped, (0, 0, imgsize[0]/2, imgsize[1]))

img.save("blot.png")

It just makes a "wandering path" for a blot, and makes several of those.

An example usage:

py inkblot.py width height blots blotsize
py inkblot.py 512 512 20 10000

And some example images:


Produce an image based on an elementary cellular automata ruleset

Python 2, 178 167 ... 128 bytes

-13 bytes thanks to @Surculose Sputum!

-2 bytes thanks to @dingledooper!

thanks @Surculose Sputum again for saving some bytes and fixing the boundary bug!!!!

n=input()
print'P1 31 16'
c='%061d'%10**30
exec"print' '.join(c[15:46]);c='0'+''.join(n[int(c[u:u+3],2)]for u in range(60));"*16

Try it online!

Output a 31x16 pbm image in stdout. You might need a magnifying glass to see those tinnie images though.

  '01111000' =>  (30 in reverse)
  '01011000' =>  (26 in reverse)


CJam, 20 bytes

Laq~{'a+_@f*\f+z}/N*

Try it online.

La                      Push [[]]
  q~                    Push input n
    {           }/      For i in 0..n-1 ...
     'a+                  Add to char 'a to give current char
        _@f*              Join each row by char
            \f+           Add char to the end of each row as well
               z          Zip to transpose
                  N*    Join result by newlines

20/21-byte alternatives:

Laaq~{'a+aff+:sz}/N*
Laaq~{'a+\Laf+f*z}/N*
Laq~{'a+f{_@*\+}z}/N*


Calculate your stack exchange reputation

Bash, 247 202 192 bytes

n=$1 bash <(sed 's/E/)echo /;s/C/ Aaccept/;s/A/answer /
s/.*)/((&)\&\&/'<<<'a=(n+1)/15,a-1)s=s;q=question
aE$aC$s
r=n%5,r-4)d=d&&
r>1E1Ced
1-r%2E1 Adownvote$d
n-=15*a,n>8)q=A
n>3E1 $q upvote')

How it works

After the sed command does it job, the following bash script gets executed:

((a=(n+1)/15,a-1))&&s=s;q=question
((a))&&echo $a answer accept$s
((r=n%5,r-4))&&d=d&&
((r>1))&&echo 1 answer accepted
((1-r%2))&&echo 1 answer downvote$d
((n-=15*a,n>8))&&q=answer
((n>3))&&echo 1 $q upvote

To obtain the optimal solution (minimal number of events to get n reputation), it suffices to compute the number of accepted answers (a) necessary to get to a reputation below 16 (1 answer accept) and handle the residue as follows:

1  (no rep change)
2  answer accepted, answer downvoted
3  answer accepted
4  question upvote, answer downvote
5  question upvote, answer downvoted
6  question upvote
7  question upvote, answer accepted, answer downvoted
8  question upvote, answer accepted
9  answer upvote, answer downvote
10 answer upvote, answer downvoted
11 answer upvote
12 answer upvote, answer accepted, answer downvoted
13 answer upvote, answer accepted
14 answer accept, answer downvote
15 answer accept, answer downvoted


Python 2, 282 272 246 bytes

Similar to Arnauld the input is assumed to be already stripped from the starting number since it is implicit.
H=input().split("\n")
T=[float(c[2:])if c[2:]else 99for c in H]
P=[min(int(10*(t-min(T))),50)for t in T]
S=sorted(list(set(T)))
i=0
u="_"
for h,p,t in zip(H,P,T):i+=1;s=S.index(t)+1;print`i`+u+"|"*(s>1)+u*p+[h,"%d(%s)"%(s,h)][t<99]+u*(41-p+(s<2))


Write a Boolfuck Compiler or Interpreter

Perl - 171 bytes

#!perl -0
%h=qw(< --$p > ++$p + $$p^=1 [ while($$p){ ] } ; $o|=$$p<<$g++;$g&=7or$o=!print+chr$o , $f&=7or$_=getc;$$p=1&ord>>$f++);$p=-1e9;eval<ARGV>=~s/./$h{$&};/gr;$g&&print+chr$o

Counting the shebang as 1 byte.

This translates the source into perl, and then evaluates the translation. The target program is taken as a command line argument, input sent to the program should be piped via stdin.

Sample usage:

$ perl boolf.pl hello.blf
Hello, world!

Details

Each of the commands is translated as follows:

< ⇒ --$p;
> ⇒ ++$p;
+ ⇒ $$p^=1;
[ ⇒ while($$p){
] ⇒ }
; ⇒ $o|=$$p<<$g++;$g&=7or$o=!print+chr$o;
, ⇒ $f&=7or$_=getc;$$p=1&ord>>$f++;

Negative integers are valid variable names, which is exploited here. $p, the cell pointer, is initialized as -1000000000, which is approximately at the center of the valid range, -2147483648 .. -1.

I've violated the specification in one regard: output is not printed all at once at the end, but rather as soon as a full byte has been collected. It's slightly longer this way, but I think it's more useful, as it allows for interactive scripts. For example, the Rot13 program below can be run in 'interactive mode', terminating the program with an eof char (^D on linux, ^Z on windows).

  Edit - Demonstration of Endianness

  There seems to be some doubt as to whether this interpreter reads bits in the proper (little-endian) order. I offer the following Boolfuck program, which reads a total of 8 bits, one at a time, and outputs each value read as its numeric ascii representation (0 outputs character 48, 1 outputs character 49). Each value is output entirely before the next bit is even read.

,;[+];;;+;;+;;
,;[+];;;+;;+;;
,;[+];;;+;;+;;
,;[+];;;+;;+;;
,;[+];;;+;;+;;
,;[+];;;+;;+;;
,;[+];;;+;;+;;
,;[+];;;+;;+;;

  Sample usage:

$ echo a | perl boolf.pl test.blf
10000110

  From the problem description:
  "Bytes are read in little-endian order; the first bit read from the character a, for instance, is 1, followed by 0, 0, 0, 0, 1, 1, and finally 0."

  According to this description, the bits are read in the proper order.

Stress Testing

First, a script to translate Brainfuck programs into Boolfuck:

#!perl -n0

%h = (
  '+' => '>[>]+<[+<]>>>>>>>>>[+]<<<<<<<<<',
  '-' => '>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]<<<<<<<<<',
  '<' => '<<<<<<<<<',
  '>' => '>>>>>>>>>',
  ',' => '>,>,>,>,>,>,>,>,<<<<<<<<',
  '.' => '>;>;>;>;>;>;>;>;<<<<<<<<',
  '[' => '>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]',
  ']' => '>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]'
);

$o .= $h{$_} for /./g;
$o =~ s/<(?R)?>//g;
print $o

The Rot13 program from the Brainfuck Wiki Page translates thusly (with slight modification for null byte eof, rather than 255):

,>,>,>,>,>,>,>,>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]>>>>>>>>>+<<<<<<<<+[>+]
<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]>>>>>>>>>>>>>>>>>>>[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<
[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]+<<<<<<<<+[
>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]>>>>>>>>>>[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>
>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]
>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+
<]>>>>>>>>>[+]<<<<<<<<<+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<
]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<<+<<<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+<]<<<<<<<<<+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]>>>>>>>>>>>>>>>>>>+<<<<<
<<<+[>+]<[<]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]>>>>>>>>>>>>>>>>>>>>>>>>>>>+
<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]<<<<<<<<<+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+
<]<<<<<<<<<<<<<<<<<[>]+<[+<]>>>>>>>>>[+]>>>>>>>>>>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>
[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]+<<<<<<
<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]+<<<<<<
<<+[>+]<[<]>>>>>>>>>]<[+<]<<<<<<<<;>;>;>;>;>;>;>;>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<
<<[>]+<[+<]>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]+<
<<<<<<<+[>+]<[<]>>>>>>>>>[+]<<<<<<<<,>,>,>,>,>,>,>,>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]

On a 26 character string, this runs in approximately 0.17 seconds:

$ echo abcdefghijklmnopqrstuvwxyz | timeit perl boolf.pl rot13.blf
nopqrstuvwxyzabcdefghijklm

Elapsed Time:     0:00:00.171

The squares.b from Daniel Cristofani's site:

>[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<<<<[>]+<[+<]>>>>>>>>>[+]<<<<<
<<<[>]+<[+<]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<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>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]+<<<<<<<<+[>+]<[<]
>>>>>>>>>[+<<<<<<<<[>]+<[+<]>>>>>>>>>>[>]+<[+<]>>>>>>>>>[+]<<<<<<<<<+<<<<<<<<+[>+]<[<
]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]>>>>>>>>>>>>>>>>>>+<<<<<<<<+[>+]<[<]>>>
>>>>>>]<[+<]<<<<<<<<<+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]<
<<<<<<<<+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]>>>>>>>>>+<<<<
<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]>;>;>;>;>;>;>;>;<<<<<<<;>;>;>;>;>;>;>;<<<<<<
<;>;>;>;>;>;>;>;>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]

Runs in about 2.4s:

$ timeit perl boolf.pl out.dat
0
1
4
9
16
25
36
49
64
81
100
121
144
169
196
225
256
289
324
361
400
441
484
529
576
625
676
729
784
841
900
961
1024
1089
1156
1225
1296
1369
1444
1521
1600
1681
1764
1849
1936
2025
2116
2209
2304
2401
2500
2601
2704
2809
2916
3025
3136
3249
3364
3481
3600
3721
3844
3969
4096
4225
4356
4489
4624
4761
4900
5041
5184
5329
5476
5625
5776
5929
6084
6241
6400
6561
6724
6889
7056
7225
7396
7569
7744
7921
8100
8281
8464
8649
8836
9025
9216
9409
9604
9801
10000

Elapsed Time:     0:00:02.421


Bash, 102 bytes

find ! -newerat 0-1day -delete
touch -a a
echo You have a $((1+(`stat -c %X-%Y a`)/86400)) day streak!

Warning, do not run in any folder you care about. It deletes any file not accessed in the last day in the working directory.

Uses a file a to store data, using the accessed/modified timestamps.


Answering the bonus: the best score for numbers <1e9 is 5/3=1.666..., generated by 144411449 (and maybe others?).

But you can do better with larger numbers.  Generally if n has a score of x, then you can concatenate two copies of n and get the same score x.  If you're lucky and n has the same first and last digit, then you can drop one of those digits in the concatenation and improve your score slightly (one less than double the number of squares and one less than double the number of digits).

n=11449441 has a score of 1.625 and has the same first & last digit.  Using that fact, we get the following sequence of scores:

1.625 for 11449441
1.666 for 114494411449441
1.682 for 1144944114494411449441
1.690 for 11449441144944114494411449441
1.694 for 114494411449441144944114494411449441

which gives an infinite sequence of numbers which are strictly (although decreasingly) better than previous numbers, and all but the first 2 better than the best score for numbers < 1e9.

This sequence may not be the best overall, though.  It converges to a finite score (12/7=1.714) and there may be other numbers with better scores than the limit.

Edit: a better sequence, converges to 1.75

1.600 14441
1.667 144414441
1.692 1444144414441
1.706 14441444144414441
1.714 144414441444144414441


JavaScript (ES7),  319  309 bytes
Expects (g)(k) and returns [x,y].
The formula for the spiral coordinates was inspired by this answer from Neil.

g=>k=>{a=[];p=[];r=[];H=Math.hypot;F=n=>{while((j=p[n]=-~p[n],C=_=>((i+2>>2)-i%2*j)*~-(i--&2),x=C(i=(--j*4+1)**.5|0,j-=i*i>>2),y=C(),n)&&a.every(([N,X,Y])=>~N+n|H(X,Y)<2*H(x,y))&&!F(n-1,p[n]--)||a.some(([_,X,Y,R])=>H(X-x,Y-y)<R**.5+q**.5,q=-~r[n]));a.push([n,x,y,r[n]=q])};while(~~r[g-1]<k)F(g-1);return[x,y]}

Try it online!
How?
One tricky point in the challenge is to figure out how many circles of generation \$n-1\$ must be processed before we can start generation \$n\$.
In this implementation, we don't attempt to put a new circle of generation \$n\$ at \$(x_0,y_0)\$ until there's at least one circle of generation \$n-1\$ at \$(x_1,y_1)\$ which is at least twice as far from the center of the spiral:
$$\sqrt{{x_1}^2+{y_1}^2}\ge2\times \sqrt{{x_0}^2+{y_0}^2}$$


Write numbers as a difference of Nth powers

Jelly, 8 bytes

p*ƓIFẹ+d

This is a monadic link that takes the number as argument and reads n from STDIN.

Try it online!

How it works

p*ƓIFẹ+d  Main link. Argument: k

p         Cartesian product; yield all pairs [b, a] with b and a in [1, ..., k].
  Ɠ       Get; read an integer n from STDIN.
 *        Power; map each [b, a] to [b**n, a**n].
   I      Increments; map each [b**n, a**n] to [a**n-b**n].
    F     Flatten the resulting list of singleton arrays.
     ẹ    Every; find all indices of k in the list we built.
      +   Add k to the indices to correct the offset.
       d  Divmod; map each index j to [j/k, j%k].


C, 168 characters

i;main(c){for(srand(&c);i++<3;putchar(rand()%10?i=0,c:c-126?c+1:33))c=getchar();
puts("ERROR CODE 4625: UNRECOVERABLE ERROR, PLEASE CONTACT YOUR SYSTEM ADMINISTRATOR");}

This solution's seeding of the PRNG takes advantage of the fact that modern OSes change the stack's location in memory on each run, as a basic measure against stack-smashing exploits.