Python, 5333 4991

I believe this is the first contender to score significantly better than a random oracle.

def H(s):n=int(s.encode('hex'),16);return n%(8**8-ord('+%:5O![/5;QwrXsIf]\'k#!__u5O}nQ~{;/~{CutM;ItulA{uOk_7"ud-o?y<Cn~-`bl_Yb'[n%70]))


Tips for golfing in The Shakespeare Programming Language

(Well... since this is my adopted language 1, I feel like I'm obliged to add something here)

Use short variable names

Yeah, yeah, yeah, that's pretty standard to code-golf, you just use one-letter-length variable names, no news here. Or is there? Because the chaps that created SPL were wacky enough not to allow any name for their language's variables: they must come from Shakesperian plays which, in terms of character length, is a pain in the royal tush - but, if you're coding in SPL, you already know that. So, my advice would be to use characters with short names, like Ajax, Ford, Page or Puck, instead of The Archbishop of Canterbury, per instance.

That's all I got, I'm afraid.

1- since my Java skills are equivalent of those of a newborn.


APL (56)

{⎕ML←3⋄⊃{⍵,⍴∪⍵}¨W[⍙]⍴⍨↑+/∆∘.=∆←∆[⍙←⍒∆←↑∘⍴∘∪¨W←⍵⊂⍨⍵≠' ']}

This is a function (question says that's allowed) that takes a string and returns a matrix of words and unique lengths.

Usage:

      {⎕ML←3⋄⊃{⍵,⍴∪⍵}¨W[⍙]⍴⍨↑+/∆∘.=∆←∆[⍙←⍒∆←↑∘⍴∘∪¨W←⍵⊂⍨⍵≠' ']}'The quick brown fox jumps over the lazy dog.'
quick 5
brown 5
jumps 5

Explanation:

⎕ML←3: set migration level to 3 (so that ⊂ is partition instead of enclose)
W←⍵⊂⍨⍵≠' ': store in W the given string, where each partition consists of non-whitespace characters.
⍙←⍒∆←↑∘⍴∘∪¨W: get the amount (⍴) of unique (∪) elements in each part (¨) of W, and store these in ∆, then get the sort order when sorted downwards on this (⍒) and store that in ⍙.
∆[⍙...]: sort ∆ by ⍙, so now we have the unique lengths in order.
∆∘.=∆←∆: store the sorted ∆ back in ∆, and see which elements of ∆ are equal.
↑+/: sum the rows (now we know how many elements are equal to each element) and then take the first item (now we know how many elements are equal to the first element, i.e. how many of the words are tied for first place.)
W[⍙]⍴⍨: sort W by ⍙, and take the first N, where N is the number we just calculated.
{⍵,⍴∪⍵}¨: for each of these, get the word itself and the amount of unique characters in the word
⊃: format as matrix


Ruby 1.8, 95 characters

#!ruby -nrdate
7.times{|i|puts (Date.parse($_)+i).strftime"%A #{"\023\004\016\016\035"[$_[-3]%5]-9+rand(21)}"}

The character escapes inside the string should be replaced by the character literals they represent.

Found a shorter way to pack the data, Ruby 1.9 would be 4 characters longer now (add .ord after $_[-3]).
112 -> 105 by stealing Joey's idea of not splitting the input.
105 -> 101. Note that the first line is actually parsed by the Ruby interpreter itself, so it even works when running the solution like echo "Thursday Winter" | ruby1.8 forecast.rb
101 -> 96. Stole Joey's idea again to just embed the temperatures into a string instead of an array.
Whoops, just noticed it should be rand(21), not rand(20).
96 -> 95. Removed unnecessary whitespace.


JavaScript (ES6),  146 ... 138  125 bytes
Saved 2 bytes thanks to @Klaycon
Takes input as [x,y]. Brute-forces a path.
p=>eval("for(n=0;s=([X,Y]=p,k=0,++n+'').replace(/./g,n=>n<4&&'ENWS'[X+=~-n%2,Y+=~-~-n%2,k+=(n&2^6)+(k-~n)%3,n]),X|Y|k%6;);s")

Try it online!
How?
The position of the top face is \$k \bmod 6\$:
$$\begin{array}{c|c|c|c|c|c}
0&1&2&3&4&5\\[5px]
\hline
\text{top}&\text{left}&\text{back}&\text{bottom}&\text{right}&\text{front}
\end{array}$$
The current direction is \$n\$:
$$\begin{array}{c|c|c|c}
0&1&2&3\\[5px]
\hline
\text{East}&\text{North}&\text{West}&\text{South}
\end{array}$$
Given \$k\$ and \$n\$, the new position of the top face is:
$$k'=k+((n\operatorname{and}2)\operatorname{xor}6)+((k+n+1)\bmod3)$$
The values of \$k'\bmod6\$ given \$n\$ and \$k\bmod6\$ are summarized in the following table:
$$\begin{array}{c|cccccc}
k \bmod 6 & 0 & 1 & 2 & 3 & 4 & 5\\
\hline
n = 0 & 1 & 3 & 2 & 4 & 0 & 5\\
n = 1 & 2 & 1 & 3 & 5 & 4 & 0\\
n = 2 & 4 & 0 & 2 & 1 & 3 & 5\\
n = 3 & 5 & 1 & 0 & 2 & 4 & 3
\end{array}$$
Commented
Note: this is a version without eval() for readability
p => {                   // p = [x, y] = starting position
  for(                   // main loop:
    n = 0;               //   start with n = 0
    s = (                //   s is the move string that we're going to build
      [X, Y] = p,        //     start with [X, Y] = starting position
      k = 0,             //     start with k = 0
      ++n + ''           //     increment n and coerce it to a string
    ).replace(/./g, n => //   for each digit n in the resulting string:
      n < 4 &&           //     abort if n is greater than or equal to 4
      'ENWS'[            //     replace it with a direction character
        X += ~-n % 2,    //       X += dx
        Y += ~-~-n % 2,  //       Y += dy
        k +=             //       update k
          (n & 2 ^ 6) +  //
          (k - ~n) % 3,  //
        n                //       actual index for the direction character
      ]                  //
    ),                   //   end of replace()
    X | Y | k % 6;       //   stop when X = Y = k mod 6 = 0
  );                     // end of for()
  return s               // return the solution
}                        //


Clean, 263 244 222 bytes

v n s=sortBy(\(a,b)(c,d).b>d)([(t,3.0)\\t<-s|fst t=="DC"]++w(n-3*(length s))[(t,1.0)\\t<-s|fst t<>"DC"])
w 0s=w 0 s=[(p,r+2.0)\\(p,r)<-s]
w n s#s=sortBy(\a b.A a>A b)s
#(p,r)=hd s
=w(n-1)[(p,r+1.0):tl s]
A((_,p),r)=p/sqrt(r*r+r)

Call like

Start = v 538 [("DC", 1000000.0), ("RH", 1.0)]

Ungolfed version, full program (census.icl):

module census

import StdEnv

Start = votes 538 [("DC", 1000000.0), ("RH", 1.0)]

votes n states
# dc = filter (((==)"DC")o fst) states
= sortBy (\(a,b)(c,d).b>d) ([(t,3.0) \\ t <- dc] ++ votes` (n-3*length states) [(t,1.0)\\t<-removeMembers states dc])
where
    votes` 0 states = map (\(p,r).(p,r+2.0)) states
    votes` n states
    # states = sortBy (\a b.A a > A b) states
    # (p,r) = hd states
    = votes` (n-1) [(p,r+1.0):tl states]

    A ((_,p),r) = p / sqrt(r*r+r)


Let's give VIM some love (96 chars)

let n=input('')|for x in range(1,n/2-1)|for y in range(1,n)|if x*y==n|ec x."*".y|en|endfo|endfo

The abbreviations ec, en and endfo stand for echo, endif and endfor respectively.

I was rather disappointed that I couldn't use fo; that expands to fold.


Calculate all the squares up to x using only addition and subtraction

C, 55 52 bytes

int s(int n,int*r){for(int i=0,j=-1;n--;*r++=i+=j+=2);}

simply sums odd numbers

n: number of squares to compute
r: output array for storing the results
j: takes the successive values 1, 3, 5, 7, ...
i: is incremented by j on each iteration

Edit

4 chars can be saved using the implicit int declaration (>C99), but this costs 1 char because for initializers cannot contain a declaration in >C99. Then the code becomes

s(int n,int*r){int i=0,j=-1;for(;n--;*r++=i+=j+=2);}

Usage

void main() {
    int r[20];
    s(20, r);
    for (int i = 0; i < 20 ; ++i) printf("%d\n", r[i]);
}

Output

1
4
9
16
25
36
49
(...)
361
400


Magic email transformation! Or: help the NSA extract your metadata from your email address

Java 8, 254 240 236 bytes

(a,b,c)->{String A[]=a.split("@"),C[]=c.split("@"),x="";for(String p:C[0].split("\\."))x+=(p.charAt(0)+"").toUpperCase()+p.substring(1)+" ";return a.equals(b)?c:A[0].equals(b)?C[0]:A[1].split("\\.")[0].equals(b)?C[1].split("\\.")[0]:x;}

-4 bytes thanks to @LukeStevens.
Explanation:
Try it here.
(a,b,c)->{                  // Method with three String parameters and String return-type
  String A[]=a.split("@"),  //  Split `a` by "@" into two parts
         C[]=c.split("@"),  //  Split `c` by "@" into two parts
         x="";              //  Temp-String
  for(String p:C[0].split("\\."))
                            //  Loop over the first part of `c`, split by dots
    x+=                     //   Append String `x` with:
       (p.charAt(0)+"").toUpperCase()
                            //    The first character as uppercase
       +p.substring(1)      //    + the rest of the String
       +" ";                //    + a space
                            //  End of loop (implicit / single-line body)
  return a.equals(b)?       //  If input `a` and `b` are exactly the same:
    c                       //   Return `c`
   :A[0].equals(b)?         //  Else-if the first part of `a` equals `b`:
    C[0]                    //   Return the first part of `c`
   :A[1].split("\\.)[0].equals(b)?
                            //  Else-if the domain of `a` equals `b`
    C[1].split("\\.)[0]     //   Return the domain of `c`
   :                        //  Else:
    x;                      //   Return String `x`
}                           // End of method


Simulate reproduction in a population of oozes

Python 3, 114 bytes

from random import*
def f(n,s=b'o'):k=randrange(len(s));return n and f(n-1,s[:k]+b'oO8o'[-~s[k]%3::3]+s[k+1:])or s

Try it online!

Interesting observation: the ascii values of oO8 are 111, 79, and 56, respectively. If you take these modulo 3, you get 0, 1 and 2.

Additional observation: you can validate the generation of your final string by substituting 'o' with 3, 'O' with 4 and '8' with 5; then taking the sum of your list and subtracting 3 from the total.

This works for all strings regardless of random variations, because each replacement in your string increases this sum by 1:

'o' (3) -> 'O'  (4)
'O' (4) -> '8'  (5)
'8' (5) -> 'oo' (3+3 = 6)

We then just need to correct for the offset of 3.

Validate it online!


What is a good way to deal with tasks that require arrays using Haskell?

The glib answer is: Don't use arrays. The not-so-glib answer is: Try to rethink your problem so that it doesn't need arrays.

Often, a problem with some thought can be done without any array like structure at all. For example, here's my answer to Euler 28:

-- | What is the sum of both diagonals in a 1001 by 1001 spiral?
euler28 = spiralDiagonalSum 1001

spiralDiagonalSum n
    | n < 0 || even n = error "spiralDiagonalSum needs a positive, odd number"
    | otherwise = sum $ scanl (+) 1 $ concatMap (replicate 4) [2,4..n]

What gets expressed in the code here is the pattern of the sequence of numbers as they grow around the rectangular spiral. There was no need to actually represent the matrix of numbers itself.

The key to thinking beyond arrays is to think about what the problem at hand actually means, not how you might represent it as bytes in RAM. This just comes with practice (perhaps a reason I code-golf so much!)

Another example is how I solved the finding maximal paths code-golf. There, the method of passing the partial solutions as a wave through the matrix, row by row, is expressed directly by the fold operation. Remember: On most CPUs, you can't deal with the array as a whole at once: The program is going to have to operate through it over time. It may not need the whole array at once at any time.

Of course, some problems are stated in such a way that they are inherently array based. Languages like ><>, Befunge, or Brainfuck have arrays at their heart. However, even there, arrays can often be dispensed with. For example, see my solution to interpreting Brainfuck, the real core of its semantics is a zipper. To start thinking this way, focus on the patterns of access, and the structure closer to the meaning of problem. Often this needn't be forced into a mutable array.

When all else fails, and you do need to use an array - @Joey's tips are a good start.


Bash, 388 375 characters

Note that I am aware that further clarifications may come which will invalidate my solution.
Feel free to carry out any necessary modification in the requirement.
I posted this because the challenge is complex and may help to see how someone else understood it when editing for clarification.

set -f
IFS=
read -pfilename?\> f
[ $f = DELETE ]&&{
read -pdelete?\> f
[ -f $f ]&&>$f||echo FILE NOT FOUND
exit
}
[ -f $f ]&&mapfile t<$f
echo "${t[*]}--"
while read -plineno?\> l;do
[ $l = q ]&&break
[ $l = a ]&&t+=('
')||{ ((l>=${#t[@]}))&&echo Error!&&continue
read -pcontent?\> c
[ $c ]&&t[l]="$c
"||t=(${t[@]::l} ${t[@]:l+1})
}
echo "${t[*]}--"
done
echo -n "${t[*]}">$f

Thanks to:

GammaFunction for suggesting set -f to make some quoting unnecessary (13 characters).


Winning Strategies for a String Construction Game

Python, 132

def f(S,n):
 if n<1:return S
 a,b=[f({x[1:]for x in S if x[0]==c},n-1)for c in'01']
 return{'A'+y for y in a|b}|{'B'+y for y in a&b}

Example run:

f({'000','001','010','011','100','101','110','111'},3) ==
{'ABA', 'ABB', 'AAA', 'AAB', 'BBB', 'BBA', 'BAB', 'BAA'}

This is only kind-of golfed, mostly to show the algorithm. The inputs and output are sets of strings. Python doesn't seem to have the right features to express parts of this compactly, so it would be cool if someone wrote this in a better-suited language.

Here's how the recursion can be expressed mathematically. Unfortunately, PPCG still lacks math rendering, so I'll have to use code blocks.

The objects of interest are sets of strings. Let | represent set union and & represent set intersection.

If c is a character, let c#S represent prepending the character c to all strings in S. Conversely, let the contraction c\S be the one-character-shorter strings of S that follow initial character c, e.g., 0\{001,010,110,111} = {01,10}.

We can uniquely split a set of strings S with chars in 01 by their first character.

S = 0#(0\S) | 1#(1\S)

Then, we can express the desired function f as follows, with the bases cases in the first two lines and the recursive can in the last line:

f({})   = {}
f({''}) = {''}
f(S)    = A#(f(0\S)|f(1\S)) | B#(f(0\S)&f(1\S))

Note that we don't need to use the length n.

Why does this work? Let's think about the move-strings that let Alice win for a set of strings S.

If the first character is A, Alice can pick the first move ('0' or '1'), letting her choose to reduce the problem to S0 or S1. So now the remaining move-string has to be in  at least one of f(S0) or f(S1), hence we take their union |.

Similarly, if the first character is 'B', Bob gets to pick, and he'll pick the worse one for Alice, so the remaining move-string must be in the intersection (&).

The base cases simply check if S is empty or not at the end. If we're tracking the length of the strings n, by subtracting 1 each time we recurse, the bases can instead be written:

f(S) = S if n==0

The recursive solution also explains the fun fact that f(S) has the same size as S. It's true for the base cases, and for the inductive case

f(S) = A#(f(0\S)|f(1\S)) | B#(f(0\S)&f(1\S))

we have

size(f(S)) = size(A#(f(0\S)|f(1\S)) | B#(f(0\S)&f(1\S)))
           = size(A#(f(0\S)|f(1\S))) + size(B#(f(0\S)&f(1\S))))
           = size((f(0\S)|f(1\S))) + size((f(0\S)&f(1\S))))
           = size(f(0\S)) + size(f(1\S))  [since size(X|Y) + size(X&Y) = size(X) + size(Y)]
           = size(0\S) + size(1\S)
           = size(S)


Jelly, 21 20 18 17 bytes

ṡṂ€€×"
‘×¥\ç"Ụ€FṀ

Try it online! or verify all test cases.

Background

Let M be a matrix of bits such as

0 0 0 1 1 0 0 0 0
1 1 0 1 1 0 0 1 0
1 1 0 1 1 1 1 1 0
1 1 0 0 1 1 1 0 0
0 1 0 0 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 1 0

We start by counting the number of 1 bits in each column of M, resetting the count every time we encounter a 0 bit.

For our example matrix, this gives

0 0 0 1 1 0 0 0 0
1 1 0 2 2 0 0 1 0
2 2 0 3 3 1 1 2 0
3 3 0 0 4 2 2 0 0
0 4 0 0 5 3 3 1 1
1 5 1 1 6 4 4 2 2
2 6 2 2 0 5 5 3 0

Next, we compute all contiguous sublists of each row. We achieve this by generating all slices of length k, where k varies between 1 and the number of entries in each row.

For the penultimate row, this gives

[1], [5], [1], [1], [6], [4], [4], [2], [2]
[1, 5], [5, 1], [1, 1], [1, 6], [6, 4], [4, 4], [4, 2], [2, 2]
[1, 5, 1], [5, 1, 1], [1, 1, 6], [1, 6, 4], [6, 4, 4], [4, 4, 2], [4, 2, 2]
[1, 5, 1, 1], [5, 1, 1, 6], [1, 1, 6, 4], [1, 6, 4, 4], [6, 4, 4, 2], [4, 4, 2, 2]
[1, 5, 1, 1, 6], [5, 1, 1, 6, 4], [1, 1, 6, 4, 4], [1, 6, 4, 4, 2], [6, 4, 4, 2, 2]
[1, 5, 1, 1, 6, 4], [5, 1, 1, 6, 4, 4], [1, 1, 6, 4, 4, 2], [1, 6, 4, 4, 2, 2]
[1, 5, 1, 1, 6, 4, 4], [5, 1, 1, 6, 4, 4, 2], [1, 1, 6, 4, 4, 2, 2]
[1, 5, 1, 1, 6, 4, 4, 2], [5, 1, 1, 6, 4, 4, 2, 2]
[1, 5, 1, 1, 6, 4, 4, 2, 2]

Next, we map each slice to the product of its minimum and its length. For each slice, this computes the area of the rectangle of 1 bits of maximum height that has the given slice as bottom row.

For the slices of length 3 of the penultimate row of our example matrix, this gives

3 3 3 3 12 6 6

All that's left to do is take the maximum across all slices of all rows.

For our example matrix, this gives 12.

How it works

‘×¥\ç"Ụ€FṀ  Main link. Argument: M (2D list of bits)

   \        Reduce the columns of M by the link to the left.
  ¥           Combine the two atoms to the left into a dyadic chain.
‘               Increment the left argument.
 ×              Multiply the result with the right argument.
      Ụ€    Grade up each; yield the indices of each row of M, sorted by their
            values. The order is not important here; we just need the indices.
    ç"      Apply the helper link to each element of the result to the left and
            the corresponding element of the result to the right.
        F   Flatten the resulting, nested list.
         Ṁ  Extract the maximum.

ṡṂ€€×"      Helper link. Arguments: R (row), X (indices of R)

ṡ           For each k in X, split R into overlapping slices of length k.
 Ṁ€€        Compute the minimum of each individual slice.
    ×"      Multiply the minima of all slices of length k by k.


Generate the set of prepend-append permutations in lexicographically sorted order

CJam, 22 20 19 17 bytes

]]l~{)f+_1fm>|}/p

Code expansion:

]]                   "Put [[]] onto stack. What we will do with this array of array is";
                     "that in each iteration below, we will first append the next";
                     "number to all present arrays, then copy all the arrays and";
                     "move the last element to first in the copy";
  l~                 "Read input number. Lets call it N";
    {         }/     "Run this code block N times ranging from 0 to N - 1";
     )f+             "Since the number on stack starts from 0, add 1 to it and append";
                     "it to all arrays in the array of array beginning with [[]]";
        _1fm>        "Copy the array of array and move last element from all arrays";
                     "to their beginning";
             |       "Take set union of the two arrays, thus joining them and eliminating";
                     "duplicates. Since we started with and empty array and started adding";
                     "numbers from 1 instead of 2, [1] would have appeared twice if we had";
                     "simply done a concat";
                p    "Print the array of arrays";

How it works:

This is a debug version of the code:

]]l~ed{)edf+ed_ed1fm>ed|ed}/edp

Let's see how it works for input 3:

[[[]] 3]                                 "]]l~"            "Empty array of array and input";
[[[]] 1]                                 "{)"              "First iteration, increment 0";
[[[1]]]                                  "{)f+"            "Append it to all sub arrays";
[[[1]] [[1]]]                            "{)f+_"           "Copy the final array of array";
[[[1]] [[1]]]                            "{)f+_1fm>"       "shift last element of each";
                                                           "sub array to the beginning";
[[[1]]]                                  "{)f+_1fm>|}"     "Take set based union";
[[[1]] 2]                                "{)"              "2nd iteration. Repeat";
[[[1 2]]]                                "{)f+"
[[[1 2]] [[1 2]]]                        "{)f+_";
[[[1 2]] [[2 1]]]                        "{)f+_1fm>";
[[[1 2] [2 1]]]                          "{)f+_1fm>|}";
[[[1 2] [2 1]] 3]                        "{)";
[[[1 2 3] [2 1 3]]]                      "{)f+"
[[[1 2 3] [2 1 3]] [[1 2 3] [2 1 3]]]    "{)f+_";
[[[1 2 3] [2 1 3]] [[3 1 2] [3 2 1]]]    "{)f+_1fm>";
[[[1 2 3] [2 1 3] [3 1 2] [3 2 1]]]      "{)f+_1fm>|}";
[[[1 2 3] [2 1 3] [3 1 2] [3 2 1]]]      "{)f+_1fm>|}/";

Try it online here


Python (518)

from pylab import*
D=dict(zip('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',[map(int,bin(7145037215283832782017591362181079009730769141301710950254702714880607436795)[2+n*7:9+n*7])for n in range(36)]))
def T(A,C):y,x=A.shape;M=zeros((2*x-1,x+y));p=A[::-1].T;q=A.T[::-1];M[:y,:x]=C[0]*A;M[:x,:y]=C[1]*p;M[:x,-2*y:-y]=C[2]*q;M[x-1:x-1+y,:x]=C[3]*A;M[x-1:,:y]=C[4]*p;M[x-1:,-2*y:-y]=C[5]*q;M[2*x-1-y:2*x-1,:x]=C[6]*A;return M
def R(S,N):
 V=ones((1,3))
 for i in range(N):V=concatenate([T(V,D[C])for C in S],1)
 ion();imshow(V)

Call as R('CODEGOLF', 3)
first i make a dictionary that maps letters to their 7-bit SSD-representaion, where each bit stands for one bar, the .-corners are simply overwritten by the most recent bar
.000.
1   2
1   2
1   2
.333.
4   5
4   5
4   5
.666.

The function T(BaseArray, BooleanArray) makes a big empty array for one letter and puts rotated copies of BaseArray along the bars as indicated by BooleanArray. Finally R(String, N_levels) connects all the letters form the input and uses the result as BaseArray for the next iteration.
While technically correct, the result is quite ugly because of interpolation and the default colourmap

Unglofed
from pylab import*
D=dict(zip('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
           [map(int,bin(7145037215283832782017591362181079009730769141301710950254702714880607436795)[2+n*7:9+n*7])for n in range(36)]))

def T(A,C):
    y,x = A.shape
    M = zeros((2*x-1,x+y))
    if C[0]: M[:y,           :x] = A
    if C[1]: M[:x,           :y] = A[::-1].T
    if C[2]: M[:x,      -2*y:-y] = A.T[::-1]
    if C[3]: M[x-y+y/2:x+y/2,:x] = A # middle bar shifted upwards by half thickness
    if C[4]: M[x-1:,         :y] = A[::-1].T
    if C[5]: M[x-1:,    -2*y:-y] = A.T[::-1]
    if C[6]: M[2*x-1-y:2*x-1,:x] = A
    return M

def R(S,N):
    V = ones((1,3))
    for i in range(N):
        V = concatenate([T(V, D[C]) for C in S], 1)
    imsave('%s_%s.png'%(S,N), V ,cmap='gray')

The initial seed V kinda controls the font on the deepest level. [1 1 1] make the smallest possible 3x5 letters

With V = ones((1,11)) you get long and thin letters

And with
V=array([[0,1,1,1,1,1,1,1,1,0],
         [1,0,0,0,0,0,0,0,0,1],
         [0,1,1,1,1,1,1,1,1,0]])

you can make hollow letters


Python 3, score ... 48 29  20
+1,eval(bytes([57]))

A completely different approach from the last 2 versions (and also result in manageable generated program). Check out the revision history for some (possibly) interesting ideas.

Given an arbitrary Python program:
print(1)

it can be transformed, without changing the behavior:
exec("print(1)")

eval(rb'exec("print(1)")')

eval(bytes([101, 120, 101, 99, 40, 34, 112, 114, 105, 110, 116, 40, 49, 41]))

The number list is getting long, so I'll use a shorter list for demonstration. Note that only printable ASCII characters can appear in the string representation and the first character is e, so the first number is 101 and all numbers are at least 32.
eval(bytes([101, 32, 32]))

Rewrite the first number to 57+1+1+1+...+1+1+1, the rest into 9+1+1+...+1; then add some ,9 at the end of the list. This is always possible because of the conditions mentioned before, and the program's behavior is unchanged because the byte 9 is \t, a whitespace character.
eval(bytes([57+1+1+...+1, 9+1+1+...+1+1, 9+1+1+...+1, 9, 9,..., 9]))

The number of ,9 added must satisfy that the total number of 9s is equal to the number of +1.
Then replace all the 9 with eval(bytes([57]), and prepend +1,.
+1,eval(bytes([57+1+1+...+1,eval(bytes([57])+1+1+...+1+1,eval(bytes([57])+1+1+...+1,eval(bytes([57]),eval(bytes([57]),...,eval(bytes([57])]))

Done! It's easy to see that this string has the eraser string +1,eval(bytes([57]).

It's trivial to see that there exists a Python snippet that solves the given problem.

g=lambda s, e: not s or any(
	s[i:].startswith(e) and g(s[:i]+s[i+len(e):], e)
	for i in range(len(s)-len(e)+1))
f=lambda s: min((s[i:j] for j in range(len(s)+1) for i in range(j) if g(s, s[i:j])), key=len)
print(f(input()))

Try it online!


Grid Based Digital Logic (Duodyadic Tiles)

C, 332 309 272 270 266 259 247 225 bytes

#define C(x)*c-x?
i,k,T,L,m;f(c,t,l)char*c,*t,*l;{while(L=l[i]){for(k=0;T=t[k];c++)L=C(49)C(43)C(92)C(85)C(41)C(33)C(38)C('|')C(94)T=48:(T^=L-48):(T|=L):(T&=L):(T^=1,L^1):(T=L):T:(m=T,T=L,m):L:(T=49),t[k++]=T;c++;l[i++]=L;}}

View results online here!
This defines a function void f(char*, char*, char*), which should take the board as its first input, then the top row of input, and then the left row of input.
Here's what I used to test it:
#include "stdio.h"
int main() {
    char buf[1024],top[33],left[33];
    /* Copy and paste an example circuit as the first input,
       and put a 'Q' immediately after it.
       Note that the Q is never touched by the function f, and is used
       solely as a delimiter for input. */
    scanf("%[^Q]Q ",buf);
    /* Then enter your top inputs */
    scanf("%[01]%*[^01]", top);
    /* Then your left ones */
    scanf("%[01]", left);
    /* OUTPUT: Bottom\nRight */
    f(buf, top, left);
    return 0;
}

Thus, by inputting Sp3000's 2-bit multiplier:
UUUU))))
UU++)))&
UUU+)  U
UU++&))U
U++&+)^U
U)&\&)UU
   U+^UU
   \&UUUQ
11110000
00000000

We get:
00001001
11111111

On another note, with Sp3000's half adder in mind, I'd like to see a full adder... One of you guys did it! I don't think the system stands on its own as a programming language, but it's been very interesting. This seems like an excellent target for metagolf, though!
A Short Explanation:
Here's the unraveled, commented code:
/* We define the first half of the ?: conditional operator because, well,
   it appears over and over again. */
#define C(x)*c-x?
/* i,k are counting variables
   T,L are *current* top and left inputs */
i,k,T,L,m;
f(c,t,l)char*c,*t,*l;{
    /* The outer loop iterates from top to bottom over l and c */
    while(L=l[i]){
        /* Inner loop iterates from left to right over t and c */
        for(k=0;T=t[k];c++)
            /* This line looks awful, but it's just a bunch of character
            comparisons, and sets T and L to the output of the current c */
            L=C(49)C(43)C(92)C(85)C(41)C(33)C(38)C('|')C(94)T=48:(T^=L-48):(T|=L):(T&=L):(T^=1,L^1):(T=L):T:(m=T,T=L,m):L:(T=49),
            /* Write our output to our input, it will be used for the next row */
            t[k++]=T;
        c++; /*Absorbs the newline at the end of every row */
        /* Keep track of our right-most outputs,
        and store them in the handy string passed to the function. */
        l[i++]=L;
    }
    /* Bottom output is now stored entirely in t, as is right output in l */
}

We iterate over c, left to right (then top to bottom), rewriting the t inputs each time and pushing out a right-most output which is shoved into the l string. We can imagine this as replacing the top row of c with 1's and 0's iteratively, and keeping track of the bits that are pushed out at the right.
Here's a more visual sequence, row by row:
 111
1&+^  =>  110 ->0  =>     ->0  =>     0 Thus, "01" has been written to l,
1+&+     1+&+         110 ->1         1
                                  110   And "110" is stored currently in t.

This obviously gets more complicated with different symbols and sizes, but the central idea holds. This works only because data never flows up or left.


Remove duplicates from list and order it by count? (python 3)

44 bytes

sorted({}.fromkeys(s),key=s.count,reverse=1)

Try it online!
An improvement to the below, replacing the key with a built-in rather than a lambda, and using reverse to swap the comparisons. We'd like to do [::-1] on the final result instead, but that doesn't do the right stable tiebreaks.

47 bytes

sorted({}.fromkeys(s),key=lambda y:-s.count(y))

Try it online!
A simple transposition of your code, moving your {}.fromkeys de-duplication trick before the sorting. Since sorting converts to a list, extracting the keys from a dictionary, this saves the list() call of the original.
For ease of reference, the original code is:
53 bytes

list({}.fromkeys(sorted(s,key=lambda y:-s.count(y))))

Try it online!


Python 2, 101 99 bytes

r=range(input())
for x in sorted(r,key=lambda x:x*-(x&2)):print bytearray([97+i,32][i<x]for i in r)

xsot saved two bytes by realizing x*-(x&2) suffices as a sorting key — the bottom half of the resulting image is unaffected due to sorted guaranteeing a stable sort.


Make Plan 9 Cat Turing Complete in as Few Bytes as Possible

266 256 250 245 149 bytes (probably)

Thanks to @someone for suggesting using a cyclic tag system (originally I was using a modified version of Brainfuck).

Real computers aren't actually Turing-complete, because they have a finite amount of memory, whereas a Turing-machine has an infinite amount of memory. This is an implementation of a cyclic tag system with 9999 bytes of memory (although you could very easily change that), and with an initial word of 1 (I'm not entirely sure if cyclic tag systems with a fixed initial word are Turing-complete, but they probably are). The length of the program must be ≤8192, in this format:

00 (the first byte is ignored)
01 01 02 00 (first rule: 001 (null character to mark end))
02 02 02 01 02 00 (second rule: 11101)
03 (marks end of program)

There is no I/O. The added code should be C99-compliant (provided the input code doesn't use more than 9999 bytes of memory at once), but I'm pretty sure you can't (portably) declare main as void in C99.

#include <u.h>
#include <libc.h>

void
cat(int f, char *s)
{
    char buf[8192],m[9999];
    long n;

    while((n=read(f, buf, (long)sizeof buf))>0){char m[9999],*M=m+9998,*s=m,*e=m+1,*i=buf;*m=2;m[1]=0;do{for(i++;*i;i++){if(*i>2)i=buf+1;if(*s>1){*e++=*i;if(e>M)e=s;}}if(++s>M)s=m;}while(*s);
        /*if(write(1, buf, n)!=n)
            sysfatal("write error copying %s: %r");*/}
    if(n < 0)
        sysfatal("error reading %s: %r", s);
}

void
main(int argc, char *argv[])
{
    int f, i;

    argv0 = "cat";
    if(argc == 1)
        cat(0, "<stdin>");
    else for(i=1; i<argc; i++){
        f = open(argv[i], OREAD);
        if(f < 0)
            sysfatal("can't open %s: %r", argv[i]);
        else{
            cat(f, argv[i]);
            close(f);
        }
    }
    exits(0);
}

Slightly de-golfed, and printing each step:

#include <u.h>
#include <libc.h>

void
cat(int f, char *s)
{
    char buf[8192];
    size_t n;

    while((n=read(f, buf, (long)sizeof buf))>0) {
        char mem[9999];
        *mem=2;mem[1]=0;
        char* mem_end = &mem[9998];
        char*start=mem,*end=mem+1,*i=buf;
        do {
            for (char* p = start; p < end; p++) {
                printf("%d",*p - 1);
            }
            printf("\n");
            for (i++;*i;i++) {
                if(*i>2)i = buf+1;
                if (*start > 1){
                    *end++=*i;
                    if (end > mem_end)
                        end = mem;
                }
            }
            if (++start>mem_end)start=mem;
        } while (*start);
        /*if(write(1, buf, n)!=n)
            sysfatal("write error copying %s: %r");*/
    }
    if(n < 0)
        sysfatal("error reading %s: %r", s);
}

void
main(int argc, char *argv[])
{
    int f, i;

    argv0 = "cat";
    if(argc == 1)
        cat(0, "<stdin>");
    else for(i=1; i<argc; i++){
        f = open(argv[i], OREAD);
        if(f < 0)
            sysfatal("can't open %s: %r", argv[i]);
        else{
            cat(f, argv[i]);
            close(f);
        }
    }
    exits(0);
}

The following Python script converts any cyclic tag system into code which is accepted by this program:

productions =   [[0,0,1],
                 [0],
                 [0,0],
                 [0,1,1,1]]
f = open("turing_machine","w")
f.write("\0") # First byte is ignored
for production in productions:
    for c in production:
        f.write(chr(c+1))
    f.write("\0")
f.write("\3")
f.close()

When you run the output of this program with the de-golfed version, you get:

1
001
01
1
0111
111
110
1000
0000111
000111
00111
0111
111
11001
10010
001000
01000
1000
0000
000
00
0


I reverse the source code, you negate the input!

J, 3 bytes

-&0

Try it online!

-&0 is "argument minus 0"

0&- is "0 minus argument"


JavaScript (ES6), 62 61 bytes

Saved 1 byte thanks to @JohanKarlsson

Takes input in currying syntax (a)(b). Returns a boolean.

a=>b=>(r=s=>s[0]+s.replace(/-|_/g,'').toUpperCase())(b)==r(a)

Test cases

let f =

a=>b=>(r=s=>s[0]+s.replace(/-|_/g,'').toUpperCase())(b)==r(a)

console.log(f("count")("Count"))                           // falsey
console.log(f("lookMaNoSeparator")("answer"))              // falsey
console.log(f("_test")("test"))                            // falsey
console.log(f("aVariableName")("a_variable_name"))         // truthy
console.log(f("numbers_are_cool123")("numbersAreCool123")) // truthy


Z80Golf, 19 14 bytes

00000000: 2f6f 3e10 37ed 6a3d 30fb ee07 c03c       /o>.7.j=0....<

Try it online!

-5 bytes thanks to @Bubbler

Example with input 0x41-Try it online!
Assembly

Example with input 0xC2-Try it online!

Example with input 0xE0-Try it online!

Example with input 0xF4-Try it online!

Assembly:

;input: register a
;output: register a
byte_count:			;calculate 7^(log2(255^a))||1
	cpl			;xor 255
	ld l,a
	log2:
		ld	a,16
		scf
	log2loop:
		adc	hl,hl
		dec	a
		jr	nc,log2loop
	xor 7
	ret nz
	inc a

Try it online!


J (31 40)

f=:3 :';(,&LF@dlb&.|.)&.><"1|:>LF cut y'

This is a function that takes a string, and returns a string (i.e. a character vector with linefeeds inserted in the right places, and not a matrix.)

Edit: no trailing whitespace on any line.

Test:

   f=:3 :';(,&LF@dlb&.|.)&.><"1|:>LF cut y'

   string=:stdin''
I am a text.
Transpose me.
Can you do it?
^D

   $string
42
   $f string
53
   f string
ITC
 ra
aan
mn
 sy
apo
 ou
ts
eed
x o
tm
.ei
 .t
  ?


Jelly,  18  17 bytes

ṙ""Ḅ}
Z€çŻṖ$$Z€çḊ

Try it online!

How?

ṙ""Ḅ} - Link 1, rotation helper: 3d matrix to rotate, 3d matrix of rotation instructions
    } - use the right argument for:
   Ḅ  -   un-binary (vectorises) - get the rotation amounts as a 2d matrix
  "   - zip with:
 "    -  zip with:
ṙ     -    rotate (the current row) left by (the current amount)

Z€çŻṖ$ $Z€çḊ - Main Link: 3d matrix, M
Z€           - transpose €ach (layer of M)
       $     - last two links as a monad:
     $       -   last two links as a monad:
   Ż         -     prepend a zero
    Ṗ        -     pop (i.e. remove the tail)
  ç          -   call the last Link as a dyad (i.e. f(Z€ result, ŻṖ$ result) )
        Z€   - transpose €ach (layer of that)
           Ḋ - dequeue (i.e. remove the head layer of M)
          ç  - call the last Link as a dyad (i.e. f(Z€çŻṖ$$Z€ result, Ḋ result) )

Note: $$ (or possibly $$ ... $$?) seems to mess up the code-block formatting (but only once posted, not in the preview), so I added a space to make my life easier.


Remove boxes under preservation of shape


Pyth, 34 bytes

L?gbQ+y/bQ%bQ]bjms`Md.usyMsrN8tE]1

Try it online!


Aheui, 1555 bytes

살밦발따밝따빠따밦발다빠따다빠밞빠따받다빠따밝발따두
수터더떠벋벓떠뻐더벖떠뻐벍뻐터터떠벌벖떠뻐떠벋벎뻐더
방뺘우차빠발발다빠따빠뚜
우노여뗘뻐떠뻐더벌벌썪러
샦우싹어
아삳부
ㅇ아삭뺘우차빠불
ㅇ유어우여려더벌
ㅇ요ㅇ빠받반타탸우처삳뺘우처밝밤뚜
ㅇㅇ우쑨여텨여볋여뗘여뼈여뎌벅떠벓
ㅇ요아삭뺘우차삳빠박탸유처발불
ㅇㅇ우어ㅇ여따뱖볆뚜텨벎떠뻐떠
ㅇ요ㅇ우어쎤여뎌여별여어
ㅇㅇㅇ빠밤탸우처밣빠따밞다뿌
ㅇ요ㅇ우어쎤여뗘벎더떠벋벓떠
ㅇㅇㅇ빠밦탸우처밞밦따빠뚜
ㅇ뇨ㅇ숙어쎤여뗘벎떠벅터벖
ㅇㅇㅇ빠박탸우처밝밤따밣따북
ㅇ됴ㅇ우어썬여텨더벓벓떠뻐더
ㅇㅇㅇ빠받탸우처밣밝다빠따붇
ㅇ뵬ㅇ우어썬여뎌떠벍벓떠뻐터
ㅇㅇㅇ빠밤탸우처밣밝다빠따붇
ㅇ뵬ㅇ우어썬여뎌떠벌벓떠뻐터
ㅇㅇㅇ빠발탸우처밣밝다빠따뿌
ㅇ묘ㅇ우어썬여뎌떠벎더벌벖떠
ㅇㅇㅇ빠밦탸우처밣밝다빠따빠뚜
ㅇ쇽ㅇ우어썬여뎌떠벓더벓떠뻐벖
ㅇㅇㅇ빠밝탸우처밞밞따빠따붒
ㅇ됴ㅇ우어썬여뗘벓더더벍떠뻐
ㅇㅇㅇ빠밣탸우처발발따발따붒
ㅇ뵥ㅇ우어썬여뗘벎더범떠벓떠
ㅇㅇㅇ빠밟탸우처밝발따빠따붏
ㅇ숃어어어쎤여뎌벓떠벎떠범더
ㅇ마샬우싹샥우파뺘무차파쑨
ㅇㅇ오유여어유여ㅇ며ㅇㅇ우
오ㅇㅇㅇㅇㅇㅇㅇㅇㅇㅇㅇ어
우ㅇㅇ어ㅇㅇ어어
샨희맣어

Try it online! (trailing new line for input is necessary)

Why not?

Hours of coding, and another hours of packing and layouting. I think it can be golfed furthermore, but it already took so much effort. I really wanted  to pack it into a rectangle.

Because 10^20 is larger than 2^64, not every implementation of Aheui will not support 경-scale numbers.
Luckily, Python and pyaheui implementation (which is used on  TIO) uses much-larger precision numbers, so it can support not only 경, but more than 해, 자, 양, 구, 간, 정, 재, 극.
And my code can be easily extended to use more larger unit suffixes.

This code will not terminate on input 0, but this spec was not defined in the question (which should output 영).

Explanation-ish Unpacked Code

ㅣPush unit suffixes (만, 억, 조, 경) to stack ㄹ
ㅣ
술
밦발따밝따빠따밦발다우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
빠따다빠밞빠따받다빠따밝발따다다우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
빠밞받따빠따밦발따타타우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
빠밝빠따밦다빠따밣받따다타우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣ
ㅣGet input as number
ㅣ
사방우
우ㅡ어
ㅣ
ㅣSplit input by four digits
ㅣ
ㅣㅣIf input is zero, end the loop
아아뺘우차우
우ㅇㅡ어　ㅣ
ㅣㅣ우ㅡㅡ어
ㅣㅣㅣTake mod 10000 to stack ㄲ
ㅣㅣ빠발발다빠따빠따라싺우
ㅣㅣ우ㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣDivide by 10000
ㅣㅣ발발다빠따빠따나우
ㅣ오ㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣ
ㅣReverse stack ㄲ to stack ㄱ
ㅣ
샦우싹어
우어
ㅣ
ㅣProcess four digits
ㅣ
아우ㅣUse ㄷ stack for index (0, 2, 4, 6)
ㅣ아삳바우
ㅣ우ㅡㅡ어
ㅣㅣ
ㅣㅣㅣConvert four digits into korean
ㅣ아아숙
ㅣㅣㅣㅣIf current multiplier is zero, escape
ㅣㅣㅣ뺘우차우
ㅣ우ㅇㅡ어　ㅣ
ㅣㅣㅣ우ㅡㅡ어
ㅣㅣㅣㅣTake mod 10
ㅣㅣㅣ빠발발다라우
ㅣㅣㅣ우ㅡㅡㅡㅡ어
ㅣㅣㅣㅣIf remainder - 1 is 0 (remainder is 1) and index is 0 (ones digit), push 일 on stack ㄴ
ㅣㅣㅣ빠받반타탸우처삳뺘우처밝밤따밣따박다빠따밣타싼우
ㅣㅣㅣ우ㅡㅡㅡㅡ어ㅡㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣIf remainder is not 0
ㅣㅣㅣ삭뺘우차우
ㅣㅣㅣ우ㅡ어　ㅣ
ㅣㅣㅣㅣ우ㅡㅡ어
ㅣㅣㅣㅣ숟
ㅣㅣㅣㅣㅣIf index is [2, 4, 6], push [십, 백, 천] on stack ㄴ
ㅣㅣㅣㅣ빠박탸우처발발따빠따밞타밞따밞따발다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밤탸우처밣빠따밞다빠따밣받따다밞따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밦탸우처밞밦따빠따밦타박따밞따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣㅣ
ㅣㅣㅣㅣㅣIf remainder is [2 ... 9], push [이 ... 구] on stack ㄴ
ㅣㅣㅣㅣ숙
ㅣㅣㅣㅣ빠박탸우처밝밤따밣따박다빠따밣밣다타싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠받탸우처밣밝다빠따받타빠따밣밝따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밤탸우처밣밝다빠따받타빠따밣발따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠발탸우처밣밝다빠따빠따밦발다밞따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밦탸우처밣밝다빠따빠따밦빠따밣다밣따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밝탸우처밞밞따빠따밦빠따밝다다밣따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밣탸우처발발따발따밦따밣따밤다밞따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밟탸우처밝발따빠따밣다밤따밞따밣다싼우
ㅣㅣㅣ우ㅡㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ
ㅣㅣㅣㅣIncrease index, move onto next digit
ㅣㅣㅣ삳박다삭마발발다나우
ㅣㅣ오ㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣ
ㅣㅣㅣPop zero
ㅣ아무
ㅣㅣㅣ
ㅣㅣㅣㅣMove one suffix to stack ㄱ
ㅣㅣㅣㅣIf all suffix has been used, escape
ㅣㅣ아샬우싹삭우
ㅣ우ㅇㅡ어　　ㅣ
ㅣㅣㅣ우ㅡㅡㅡ어
ㅣㅣㅣㅣIf next multiplier is zero, discard next multiplier and suffix, then check next
ㅣㅣㅣㅣIf next multipler is not zero, move suffix to stack ㄴ and continue
ㅣㅣㅣㅣIf all multiplier has been processed, escape
ㅣㅣㅣ야우파뺘우차파싼우
오ㅇㅇㅡㅇㅡㅡㅇㅡㅡㅡ어
우어ㅇㅡ어ㅡㅡㅣ
ㅣㅡ오ㅡㅡ머머어
샨희맣어


JavaScript(ES6), 418, 237, 233, 236 bytes

f=(s)=>(d='\n//',s.split(d+'\n').map((x,y)=>y%2?'//'+(l=x.slice(2).split(d),t=l.pop().split('*'),l.map((i,j)=>t.map((k,m)=>m==j?k+'/':m<j?k+'|':k.replace(/ /g,'-')+'-').join('')+'<'+i).join(d)+d+t.join('|')+d+t.join('v')):x).join('\n'))

Whew, this is my first submission on CG. Took, I think, a totally different tack from Washington Guedes. Ended up 54 bytes shorter than his first pass. Minifying all this by hand was grueling. My one regret is not being able to eliminate the while loop yet, which would also let me cut the return.

Total rewrite, taking partial inspiration from a couple of the other answers. I got to close the whole thing in maps, making returning much better. The code snippet contains the commented version.

Took a few more bytes off, and made the example operate on itself. (You're gonna need a bigger monitor.) :)

Forgot an entire letter in the spec! Fortunately, adding the leading '<' was a tiny, trivial fix.

var comments = `
//
// New function, declare the comment delimiter
// Chop the string by the fancy comment delimiter
// Iterate over the array.
// Because of how it's delimited, and how JS splits strings, only the even elements will contain fancy comments.
// Add the original comment delimiter to the front of the first line, because join won't.
// we've got a single fancy comment, split it into lines.
// Take the last line, our asterisk template, and split it on the asterisks themselves. We were only gonna replace them anyway.
// Now we get to the real work. Iterate the remaining lines.
// For each chunk of whitespace in the template array, toss a different character on the end based on where we are in the series of lines.
// if we're at the matching asterisk, insert a slash
// Otherwise, if we're at a prior asterisk, add a pipe.
// Finally, replace anything afer the matching asterisk with dashes, join the template, and add it to the line text.
// Join the lines with the delimiter
// Add the pipe line...
// And the v line...
// For odd chunks, just return the chunk.
// Join all the code chunks and autoreturn.
//      *        *               *          *   *     *                     *                    *            *            *          *         *                                        *           *             *          *  *
//
`
f=(s)=>(d='\n//',s.split(d+'\n').map((x,y)=>y%2?'//'+(l=x.slice(2).split(d),t=l.pop().split('*'),l.map((i,j)=>t.map((k,m)=>m==j?k+'/':m<j?k+'|':k.replace(/ /g,'-')+'-').join('')+'<'+i).join(d)+d+t.join('|')+d+t.join('v')):x).join('\n'))

str = `
//
// This is a test
// with two lines
// actually three
// *  *       *
//
var myCode = function () {

}
// This doesn't cause any trouble.

moreCode(stuff--)

//
// another test?
//  *
//

`
document.getElementById('before').textContent = str;
document.getElementById('after').textContent = f(str);
document.getElementById('self').textContent = f(comments)+'f='+f.toString();
Test cases before:

Test cases after:

Self-annotated:


Wolfram Language (Mathematica), 40 bytes

Max[x=2Tr/@Subsets@#,-x-1,Tr[1^#]]<2^#2&

Try it online!

Condition 1 is implied by checking condition 3 for all subsets, including the one-element ones. So we take the max of

twice the sum of each subset,
one less than twice the negative of the sum of each subset, and
the length of the whole set

and check if that's less than 2^#2 (where #2 is the bit-width input).

At the cost of only 6 more bytes, we can replace Subsets@# with GatherBy[#,Arg], which is much more efficient because it computes only the two worst-case subsets: the subset of all nonnegative values, and the subset of all negative values. (This works because Arg has a value of 0 on the former and π on the latter.)


Can you help Tony Stark become an Ironman?


Find the missing number in an undelimited string

Haskell, 115 112 bytes

g b|a<-[b!!0..last b]=last$0:[c|c<-a,b==filter(/=c)a]
maximum.map(g.map read.words.concat).mapM(\c->[[c],c:" "])

The first line is a helper function definition, the second is the main anonymous function.
Verify test cases (I had to run shorter tests because of time restrictions).

Explanation

This is a brute force solution: split the string into words in all possible ways, parse the words to integers, see whether it's a range with one element missing (returning that element, and 0 otherwise), and take the maximum over all splittings.
The range-with-missing-element check is done in the helper function g, which takes a list b and returns the sole element in the range [head of b..last of b] that's not in b, or 0 if one doesn't exist.

g b|                         -- Define g b
    a<-[b!!0..last b]=       -- (with a as the range [head of b..last of b]) as:
    last$0:[...]             --  the last element of this list, or 0 if it's empty:
            c|c<-a,          --   those elements c of a for which
            b==filter(/=c)a  --   removing c from a results in b.
mapM(\c->[[c],c:" "])        -- Main function: Replace each char c in input with "c" or "c "
map(...)                     -- For each resulting list of strings:
  g.map read.words.concat    --  concatenate, split at spaces, parse to list of ints, apply g
maximum                      -- Maximum of results (the missing element, if exists)


JavaScript (ES7),  198 185 179  178 bytes
Expects a matrix of integers with -1 for a wall and 0 for an empty cell. Returns a matrix of Boolean values.

m=>(g=(Y,w,n,X)=>w>=W&&w>W|n>N?0:m[Y+1]||1/m[Y][X+1]?m.map((r,y)=>r.map((v,x)=>v>0?1:(X-x)**2+(Y-y)**2^1?0:r[r[x]=1,g(y,w-v,-~n,x),x]=v)):o=g(-1,W=w,N=n))(0,0,W=++m[0][0]/0,0)&&o

Try it online!
Commented
This is a depth-first search. Visited cells are marked with 1. We keep track of the number of broken walls in w and the total number of visited cells in n. We abort as soon as the current path is worse than the best path found so far.
m => (                         // m[] = input matrix
  g = (                        // g is a recursive function taking:
    Y, w, n, X                 //   (X, Y) = current position
                               //   w = number of broken walls
  ) =>                         //   n = number of visited cells
  w >= W && w > W | n > N ?    // if (w, n) is worse than (W, N):
    0                          //   abort
  :                            // else:
    m[Y + 1] ||                //   if there's a cell below the current cell
    1 / m[Y][X + 1] ?          //   or a cell on the right:
      m.map((r, y) =>          //     for each row r[] at position y in m[]:
        r.map((v, x) =>        //       for each value v at position x in r[]:
          v > 0 ?              //         if v is positive:
            1                  //           yield 1
          :                    //         else:
            (X - x) ** 2 +     //           if the squared distance between
            (Y - y) ** 2 ^ 1 ? //           (X, Y) and (x, y) is not equal to 1:
              0                //             do nothing
            :                  //           else:
              r[r[x] = 1,      //             mark r[x] as visited by setting it to 1
                g(y, w - v,    //             do a recursive call at (x, y) with n+1
                  -~n, x),     //             if v = -1, w is also incremented
                x              //             actual index ...
              ] = v            //             ... to restore r[x] to v afterwards
        )                      //       end of inner map()
      )                        //     end of outer map()
    :                          //   else (bottom-right cell):
      o = g(-1, W = w, N = n)  //     update (W, N) and use a last recursive call
                               //     with X undefined and Y=-1 to build the output o
)(0, 0, W = ++m[0][0] / 0, 0)  // initial call to g at (0, 0); set the cell at (0, 0)
                               // to 1 and set W to +inf
&& o                           // return o

The purpose of the last recursive call o = g(-1, W = w, N = n) is to create a copy of the current maze where all visited cells are marked with true and all other cells are marked with false.
For this call, it's important to notice that:

because W = w and N = n, the abort test is always false
because Y = -1, the test on m[Y + 1] is always true
because X is undefined, the squared distance is always NaN

Therefore, what is actually done is simply:
m.map((r, y) => r.map((v, x) => v > 0 ? 1 : 0))


Mathematica, 61 bytes

#[[SortBy[Range@Length@#,FactorInteger[#][[1,1]]PrimeQ@#&]]]&

Unnamed function taking a list of characters as input and returning a list of characters.

FactorInteger[#][[1,1]] yields the smallest prime factor of # (and returns 1 if # equals 1). Therefore FactorInteger[#][[1,1]]PrimeQ@# yields a strange expression: [#'s smallest prime factor] False if # is not prime, and # True if # is prime (these are unevaluated products of a number and a boolean).

Range@Length@# yields a list of the numbers up to the length of the input. Then SortBy sorts those numbers by the funny function described above. Mathematica is really type-sensitive in many ways, but cheerfully mixes them in other ways: expressions of the form [number] False are alphabetically sorted before expressions of the form [number] True, while ties are broken by sorting the numbers numerically. That produces exactly the permutation we want here, and #[[...]] permutes the characters of the input accordingly.


7. Julia, 17 bytes
works due to Int64 overflowing to negative numbers

x->(x-8479)^6%5+5

Try it online!
Updated list:
58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7

I found those numbers by guessing and brute-forcing :

for i in Iterators.product(-9999:9999,1:20,1:20)
    d = diff(((L.+i[1]) .^ i[3]) .% i[2])
    if all(==(-1), d) || all(==(1),d)
        println(i)
        println(((L.+i[1]) .^ i[3]) .% i[2])
        break
    end
end

Try it online!


Python 2, 83 81 79 72 bytes

-9 bytes thanks to @ovs!
-2 bytes thanks to @dingledooper!

m,n,a,B=input()
r=0
for s in n,m+n,m,m:r+=B**n;n-=~s
print~-B**n/~-B*a-r

Try it online!

Calculate aaaa...aaa in base B, then subtract 1 at the appropriate digits.


Print all ASCII alphanumeric characters without using them

Octave, 52 46 40 bytes

['['-('"':'+'),'{'-(_='!':':'),_+'@','']

This evaluates to

9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAabcdefghijklmnopqrstuvwxyz

Explanation

Here we are using the fact that characters are implicitly converted to integers when arithmetic operations like +- or the range function : are applied. When concatenated with an empty string ([...,'']), the numbers again are converted to characters.

Try it online!


Python - 272 261 258 251 224

I think I can golf this more. I'm pretty sure this works, but I haven't finished testing it on all of the test cases yet. I finished testing it. It works for all of the test cases.

a=sorted(input())
b=[]
r=range
for i in a:
 c=set(a)-set(b);w=h=1;x,y=i
 if i in b:continue
 while not{(x,y+h)}-c:h+=1
 while all((x+w,y+j)in c for j in r(h)):w+=1
 for j in r(w):
  for k in r(h):b+=(j+x,k+y),
 print x,y,w,h

I'm working on adding images of the results.
Edit: Here are the results from the example and the test cases:

I'm trying to write this in Perl, but I can't figure out how to get multidimensional arrays from stdin without a huge number of characters. Does anyone have any suggestions?


Perl 6, 77 bytes

->$,\t,\p{flat(1..*Zxx t)[[p].&{@(.sort)=0..*;$_}].&{|$_,(p Z-$_)».abs.sum}}

Try it online!

Simply matches the n'th smallest T-Shirt to the person with the n'th smallest size.

I'm not absolutely sure if that is guaranteed to give the correct result for all possible inputs, but it works for the test-cases given in the task description.

Perl 6, 97 bytes

->\d,\t,\p{flat(1..*Zxx t).permutations.map({|$_,(p Z-$_)».&{$_>d??∞!!.abs}.sum}).min(*[*-1])}

Try it online!

Dumb brute-force solutions.
Takes around 15 minutes for the test-cases with 10 people, so the test-case with 20 people should only take, uh, millions of years... :D

(Memory usage should remain steady though, because permutations and map return lazy one-off sequences, and min also only needs to keep one element in memory.)

Both versions take three input arguments:

The number D.
The array for the T-Shirts.
The array for the people.


O(K log N), many characters of Python

Edit: Improved by replacing merge sort with radix sort.

This is an improvement over my previous answer, but I'm posting it separately because it's a different strategy, and so the post doesn't get super-long.

This is now optimal because simply reading the input can take 2*K*lg N time in the worst case -- 2*K numbers each with lg N bits.

The goal is to have minimal dependence on N. To do this, rather than store counts for each pile index, we realize that all piles in a contiguous cluster unaffected by the endpoints of any interval must have the same counts. So, if we see that an interval starts with 5, and there's no changes until 15, then those 10  piles have the same value.

Each change in pile size from a pile to the next one is caused by an interval starting or ending. We call these "events". Each event increases or decreases the current pile size by 1. If, from one event to the next, there's some number of piles, each of those piles has the current size.

We extract the 2*k events from the intervals, and sort them using a radix sort, taking advantage of the values being 1 through N. This take takes O(K*log(N)) because the numbers have O(lg N) bits.

We then run over the events, and for each one, update the list of counts to the previous event, which requires adding a number up to N (so lg N bits). This takes O(log(N)) per step, and so O(K*log(N))

Finally, having gotten the counts of the pile sizes, it's easy to quickly find the median by computing the cumulative number of piles up to a given size (or, rather, we subtract it from our desired count). This also takes O(K*log(N)).

The algorithm does the huge test case in under a second.

The code (ungolfed) is below with comments.

# Process input
def get_ints(line):
 vals = line.split()
 return (int(vals[0]),int(vals[1]))

s = input()

lines = s.split("\n")
N,K = get_ints (lines[0])
intervals = [get_ints(line) for line in lines[1:]]

mins,maxes=map(list,zip(*intervals))

#Each event will represent an increase or decrease of a pile from the previous one
#Each min increases the count by 1
#Each max causes the count to decrease by 1, starting with the next pile
events = [(a,1) for a in mins] + [(b+1,-1) for b in maxes]
events.append((N+1,0))

#Do a radix sort on the first element of each pair
#Each number has O(lg N) digits, so this takes O(k lg N)
events.sort()

#Count of the number of piles of each size
#pile_sizes[size] counts the number of piles of that size
pile_sizes = [0]*K
cur_pile = 1
cur_size = 0

#For each event, we track the pile size after the event
#Then, on the next event, we know there were some number of piles of that size
#The number of piles equals the distance between events
#Multiple events on the same pile have zero distance and don't affect the counts
for event in events:
 event_pile = event[0]
 piles_current_size = event_pile - cur_pile
 pile_sizes[cur_size] += piles_current_size
 cur_pile = event_pile
 cur_size += event[1]

#Get the i_th largest pile size from a list of pile size counts
def get_order_stat(counts,i):
 for val in range(len(counts)):
  cur_count = counts[val]
  if i<cur_count:
   return val
  i-=cur_count
 return None

median = get_order_stat(pile_sizes,N//2)

print(median)


A regex to match three consecutive integers iff the third integer is the sum of the first two


Wren, 126 124 bytes

As always Wren is the longest. I hate Wren's verbosity.

Fn.new{|a|a.map{|i|i>0?"":"-"+(i.abs.toString[-1..-(i.abs.toString.count)])}.map{|i|Num.fromString(i)}.reduce{|x,y|x<y?x:y}}

Try it online!

Explanation

Fn.new{                                                                                // new anonymous function
       |a|                                                                                // with the parameter a
          a.map{|i|                                                                                // for each item in this parameter
                                  (i>0)?"":"-"                                                                       // The sign of each item. If the item is larger than 0, return the null string, otherwise return a negative sign.
                                              +(                                           )                         // Append this with the following string:
                                                i.abs                                                                // The absolute value of i
                                                     .toString                                                       // Convert this value to a string
                                                              [-1..-(i.abs.toString.count)]                          // Reverse this string
                   Num.fromString(                                                          )                        // convert this to a number from a string
                                                                                }.reduce{|x,y|x<y?x:y}} // Find the minimum value of the list


What is the missing number (divisibility by 9)

Python, 21 bytes

lambda s:-int(s,19)%9

Try it online!

I used I to represent a missing digit.


Haskell, 55 53 bytes

f(a:b:c)=min a b:f(max a b:c)
f x=x
foldr(\_->f)=<<id

Usage example: foldr(\_->f)=<<id $ [3,1,6,4,3,8,3,1,1,2] -> [1,1,1,2,3,3,3,4,6,8]. Try it online!.

How it works: f does one iteration by keeping the minimum of the first two elements and appending a recursive call with the maximum of the first two elements and all the other elements. It stops when there are less than two  elements in the list. The main function calls f length <input> times by iterating over the input list via fold but ignoring the elements.


Mathematica, 19 bytes

Sum[n!^n!,{n,0,#}]&

Apologies for the extremely clear code  ;)


Normalized Malbolge to Malbolge translator

Malbolge Unshackled (20-trit rotation variant), 7,784e6 bytes

Size of this answer exceeds maximum postable program size (eh), so the code is located in my GitHub repository.

How to run this?

This might be a tricky part, because naive Haskell interpreter will take ages upon ages to run this. TIO has decent Malbogle Unshackled interpreter, but sadly I won't be able to use it (limitations).

The best one I could find is the fixed 20-trit rotation width variant, that performs very well, converting 0,5 characters per second.

To make the interpreter a bit faster, I've removed all the checks from Matthias Lutter's Malbolge Unshackled interpreter.

My modified version can run around 6,3% faster.

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char* translation = "5z]&gqtyfr$(we4{WP)H-Zn,[%\\3dL+Q;>U!pJS72Fh"
        "OA1CB6v^=I_0/8|jsb9m<.TVac`uY*MK'X~xDl}REokN:#?G\"i@";

typedef struct Word {
    unsigned int area;
    unsigned int high;
    unsigned int low;
} Word;

void word2string(Word w, char* s, int min_length) {
    if (!s) return;
    if (min_length < 1) min_length = 1;
    if (min_length > 20) min_length = 20;
    s[0] = (w.area%3) + '0';
    s[1] = 't';
    char tmp[20];
    int i;
    for (i=0;i<10;i++) {
        tmp[19-i] = (w.low % 3) + '0';
        w.low /= 3;
    }
    for (i=0;i<10;i++) {
        tmp[9-i] = (w.high % 3) + '0';
        w.high /= 3;
    }
    i = 0;
    while (tmp[i] == s[0] && i < 20 - min_length) i++;
    int j = 2;
    while (i < 20) {
        s[j] = tmp[i];
        i++;
        j++;
    }
    s[j] = 0;
}

unsigned int crazy_low(unsigned int a, unsigned int d){
    unsigned int crz[] = {1,0,0,1,0,2,2,2,1};
    int position = 0;
    unsigned int output = 0;
    while (position < 10){
        unsigned int i = a%3;
        unsigned int j = d%3;
        unsigned int out = crz[i+3*j];
        unsigned int multiple = 1;
        int k;
        for (k=0;k<position;k++)
            multiple *= 3;
        output += multiple*out;
        a /= 3;
        d /= 3;
        position++;
    }
    return output;
}

Word zero() {
    Word result = {0, 0, 0};
    return result;
}

Word increment(Word d) {
    d.low++;
    if (d.low >= 59049) {
        d.low = 0;
        d.high++;
        if (d.high >= 59049) {
            fprintf(stderr,"error: overflow\n");
            exit(1);
        }
    }
    return d;
}

Word decrement(Word d) {
    if (d.low == 0) {
        d.low = 59048;
        d.high--;
    }else{
        d.low--;
    }
    return d;
}

Word crazy(Word a, Word d){
    Word output;
    unsigned int crz[] = {1,0,0,1,0,2,2,2,1};
    output.area = crz[a.area+3*d.area];
    output.high = crazy_low(a.high, d.high);
    output.low = crazy_low(a.low, d.low);
    return output;
}

Word rotate_r(Word d){
    unsigned int carry_h = d.high%3;
    unsigned int carry_l = d.low%3;
    d.high = 19683 * carry_l + d.high / 3;
    d.low = 19683 * carry_h + d.low / 3;
    return d;
}

// last_initialized: if set, use to fill newly generated memory with preinitial values...
Word* ptr_to(Word** mem[], Word d, unsigned int last_initialized) {
    if ((mem[d.area])[d.high]) {
        return &(((mem[d.area])[d.high])[d.low]);
    }
    (mem[d.area])[d.high] = (Word*)malloc(59049 * sizeof(Word));
    if (!(mem[d.area])[d.high]) {
        fprintf(stderr,"error: out of memory.\n");
        exit(1);
    }
    if (last_initialized) {
        Word repitition[6];
        repitition[(last_initialized-1) % 6] =
                ((mem[0])[(last_initialized-1) / 59049])
                    [(last_initialized-1) % 59049];
        repitition[(last_initialized) % 6] =
                ((mem[0])[last_initialized / 59049])
                    [last_initialized % 59049];
        unsigned int i;
        for (i=0;i<6;i++) {
            repitition[(last_initialized+1+i) % 6] =
                    crazy(repitition[(last_initialized+i) % 6],
                        repitition[(last_initialized-1+i) % 6]);
        }
        unsigned int offset = (59049*d.high) % 6;
        i = 0;
        while (1){
            ((mem[d.area])[d.high])[i] = repitition[(i+offset)%6];
            if (i == 59048) {
                break;
            }
            i++;
        }
    }
    return &(((mem[d.area])[d.high])[d.low]);
}

unsigned int get_instruction(Word** mem[], Word c,
        unsigned int last_initialized,
        int ignore_invalid) {
    Word* instr = ptr_to(mem, c, last_initialized);
    unsigned int instruction = instr->low;
    instruction = (instruction+c.low + 59049 * c.high
            + (c.area==1?52:(c.area==2?10:0)))%94;
    return instruction;
}

int main(int argc, char* argv[]) {
    Word** memory[3];
    int i,j;
    for (i=0; i<3; i++) {
        memory[i] = (Word**)malloc(59049 * sizeof(Word*));
        if (!memory) {
            fprintf(stderr,"not enough memory.\n");
            return 1;
        }
        for (j=0; j<59049; j++) {
            (memory[i])[j] = 0;
        }
    }
    Word a, c, d;
    unsigned int result;
    FILE* file;
    if (argc < 2) {
        // read program code from STDIN
        file = stdin;
    }else{
        file = fopen(argv[1],"rb");
    }
    if (file == NULL) {
        fprintf(stderr, "File not found: %s\n",argv[1]);
        return 1;
    }
    a = zero();
    c = zero();
    d = zero();
    result = 0;
    while (!feof(file)){
        unsigned int instr;
        Word* cell = ptr_to(memory, d, 0);
        (*cell) = zero();
        result = fread(&cell->low,1,1,file);
        if (result > 1)
            return 1;
        if (result == 0 || cell->low == 0x1a || cell->low == 0x04)
            break;
        instr = (cell->low + d.low + 59049*d.high)%94;
        if (cell->low == ' ' || cell->low == '\t' || cell->low == '\r'
                || cell->low == '\n');
        else if (cell->low >= 33 && cell->low < 127 &&
                (instr == 4 || instr == 5 || instr == 23 || instr == 39
                    || instr == 40 || instr == 62 || instr == 68
                    || instr == 81)) {
            d = increment(d);
        }
    }
    if (file != stdin) {
        fclose(file);
    }
    unsigned int last_initialized = 0;
    while (1){
        *ptr_to(memory, d, 0) = crazy(*ptr_to(memory, decrement(d), 0),
                *ptr_to(memory, decrement(decrement(d)), 0));
        last_initialized = d.low + 59049*d.high;
        if (d.low == 59048) {
            break;
        }
        d = increment(d);
    }
    d = zero();

    unsigned int step = 0;
    while (1) {
        unsigned int instruction = get_instruction(memory, c,
                last_initialized, 0);
        step++;
        switch (instruction){
            case 4:
                c = *ptr_to(memory,d,last_initialized);
                break;
            case 5:
                if (!a.area) {
                    printf("%c",(char)(a.low + 59049*a.high));
                }else if (a.area == 2 && a.low == 59047
                        && a.high == 59048) {
                    printf("\n");
                }
                break;
            case 23:
                a = zero();
                a.low = getchar();
                if (a.low == EOF) {
                    a.low = 59048;
                    a.high = 59048;
                    a.area = 2;
                }else if (a.low == '\n'){
                    a.low = 59047;
                    a.high = 59048;
                    a.area = 2;
                }
                break;
            case 39:
                a = (*ptr_to(memory,d,last_initialized)
                        = rotate_r(*ptr_to(memory,d,last_initialized)));
                break;
            case 40:
                d = *ptr_to(memory,d,last_initialized);
                break;
            case 62:
                a = (*ptr_to(memory,d,last_initialized)
                        = crazy(a, *ptr_to(memory,d,last_initialized)));
                break;
            case 81:
                return 0;
            case 68:
            default:
                break;
        }

        Word* mem_c = ptr_to(memory, c, last_initialized);
        mem_c->low = translation[mem_c->low - 33];

        c = increment(c);
        d = increment(d);
    }
    return 0;
}

It's working!


Python 3, 177 bytes

c is a dictionary of the parents of each type, a and b are the two expression to check. Types are represented by strings, while intersects and unions are represented by lists with of expressions, with the first element set to 0for intersect and 1 for union

Returns 0 if they are not assignable to each other, 1 if a is assignable to b, 2 if b is assignable to a and 3 if both are assignable to each other

lambda c,a,b:y(a,b,c)+2*y(b,a,c)
y=lambda a,b,c:(b in c[a]or a==b if b[0]in c else[all,any][b[0]](y(a,x,c)for x in b[1:]))if a[0]in c else[any,all][a[0]](y(x,b,c)for x in a[1:])

Try it online!


Whitespace, 0

I couldn't resist. S= space, T= tab, N = newline, all have ASCII codes <= 32.

SSSSNSSSSNTTSSSSSTNTNTTNSSSNSSSSTNTTTNTSTNSSSSTNSSSSTNTTTSSSSTNTSSTTTSSSSSTSNTNTTSSSSTSNTTTNTTSNSSSSNSSSSTSNTTTSSSSNTTTTSSSTTSNSNSNNSSTNSSSSNTTTTNSTSSSSTSTSNTNSSNNN

Base64 encoded for easy copy & paste.

ICAgIAogICAgCgkJICAgICAJCgkKCQkKICAgCiAgICAJCgkJCQoJIAkKICAgIAkKICAgIAkKCQkJ
ICAgIAkKCSAgCQkJICAgICAJIAoJCgkJICAgIAkgCgkJCQoJCSAKICAgIAogICAgCSAKCQkJICAg
IAoJCQkJICAgCQkgCiAKIAoKICAJCiAgICAKCQkJCQogCSAgICAJIAkgCgkKICAKCgo=


Find minimal set of rows to retain all unique values in each column

Python3 + PuLP library

This is equivalent to a set covering problem (where the elements are column/value pairs) which can be transformed into an integer linear programming problem.

from pulp import *

def opt(mat):
    num_rows = len(mat)
    covering_rows = {}
    for row_nr, vals in enumerate(mat):
        for pair in enumerate(vals):
            covering_rows.setdefault(pair, []).append(row_nr)
    prob = LpProblem("Minimal Covering Set of Rows", LpMinimize)
    vars = LpVariable.dicts("R", range(num_rows), 0, 1, LpInteger)
    prob += lpSum([vars[i] for i in range(num_rows)])
    for rowlist in covering_rows.values():
        prob += lpSum([vars[r] for r in rowlist]) >= 1
    prob.solve()
    assert prob.status==LpStatusOptimal, "Couldn't solve"
    return [r for r in range(num_rows) if value(vars[r])==1]

On debian, the relevant package is called python3-pulp.

The function handles matrices with 20 columns and 100 rows in about one minute on weak hardware. The best way to substantially improve the speed is probably to use a better solver, which the PuLP library allows by adding an argument to the solve method call.


JavaScript (ES6), 140 bytes

s=>[...s.replace(/\S./g,([a,b],i)=>r[r[i+=+b?-b:~~a]=r[i]?C:a,++i]=r[i]?C:b,r=[],C='#')&&r].map((c,i)=>c?r[i-1]==C|r[i+1]==C?C:c:' ').join``

Try it online!
Commented
s =>                      // given the input string s
  [ ...s.replace(         // search in s ...
    /\S./g,               //   ... all substrings consisting of 2 non-whitespace characters
    ([a, b], i) =>        //   let a be the 1st character, b the 2nd one and i the position
      r[                  //   update r[]:
        r[i +=            //     apply the car velocity to i:
          +b ? -b         //       if b is a digit, then move b cells backwards
                  : ~~a   //       else: use a to move forwards (or don't move at all)
        ] = r[i] ? C : a, //     if r[i] is set, overwrite it with '#'; otherwise, insert a
        ++i               //     increment i for the 2nd character
      ] = r[i] ? C : b,   //     if r[i] is set, overwrite it with '#'; otherwise, insert b
      r = [],             //   initialize r[] to an empty array
      C = '#'             //   define C as the 'crash' character
  ) && r ]                // end of replace(); return a fully iterable copy of r[]
  .map((c, i) =>          // for each entry c at position i in this array:
    c ?                   //   if c is defined:
      r[i - 1] == C |     //     if either the previous
      r[i + 1] == C ?     //     or the next cell is '#' (in the original array):
        C                 //       replace the current cell with '#'
      :                   //     else:
        c                 //       let c unchanged
    :                     //   else:
      ' '                 //     insert a space
  ).join``                // end of map(); join the result


J, 15 9 7 bytes

Very easy. Takes depth and list as left and right arguments.

-~/\~&2

As an explicit definition without all the adverbial trickery, this reduces to

4 : '(2 -~/\ ])^:x y'

-~/\~&2 y – The forwards difference of y.
x -~/\~&2 y – The x-th forwards difference of y.

If I were to make a serious (i. e. non-golfed) definition of this function, I would probably do something like this:

(}. - }:) : ($:@[&0)

The monadic case computes the forward difference whereas the dyadic case computes the x-th forward difference.

Even simpler, but not exactly equal:

+/\inv

+/\ yields a vector of the sums of the prefixes of the argument. inv (defined as ^:_1) is a conjunction that inverses a verb. This works wherever J knows how to inverse a verb and for the case of +/\, J knows how to.


05AB1E, 5 14 15 18 rotations (5 6 7 8 unique, 61 213 1488 4367 bytes)
.ï i…( )7ÝJ»•αγʒδÓ₂©8¥ŽQxΣxêÿ•sÅвJIvN”</[(0._-=:"ÆŸ,*”0¶:º•DùÙÂ+;Èγтáì³ÓW©ÎÂ_`ƒ≠îj*ΓçÊ~ÞÒ¸β¦oåb/õ47/vÎΓ”›≠øØZµλÝº•20вè¶¡Nè4äyè.;ëĀiηû»ëтÝ3Å€"Fizz"}5Å€á”ÒÖ”J}¦»]q]À=F₂Aë}š.?ćvD¡SaA„iĀë∍sna„>+?Å8IàQô2$4Žнв₄iï.
ï                                                                                …
i                                                                                _
Å                                                                                |
f                                                                                _
ë                                                                                Ć
∞                                                                                Ƶ
€                                                                                м
,                                                                                ×
]                                                                                T
q                                                                                ä
]                                                                                »
.                                                                                q
                                                                                ”
.                                                                                !
…                                                                                ï
ë                                                                                ‚
p                                                                                ,
i                                                                                ™
ï                                                                                Ÿ
.ïi_i“Ûà€‰€ž€¢‡Í! :D“ćuìëdiU„ $„ |}…-~-`)X·>δ∍»}ëĀi1ú.γžOså}R`¦??н©?н®ì.•gÍĆdQ¸G•Â‡D?,ë“«Î‡Ä¦í¥Â“#€¦`«'kì)™•1¢₂P•3вè4ô»]q]»ì” ©¢ØŽ”)s”E1BA50 Ž¬”Ð”î€ot”ëFëgiÊ¹Š'iĀëå4B23iï.                                 \””

Try it online (integer input): ascii-art Do you want to code a snowman?
Try it online (string input): ascii-art It took me a lot of time to make this, pls like. (YouTube Comments #1)
Try it online (no input): string 1, 2, Fizz, 4, Buzz
Try it online with all rows reversed (integer input): ascii-art It's my Birthday :D
Try it online with all rows reversed (string input): string Covefify a string
Try it online with all rows reversed (no input): kolmogorov-complexity Hare Krishna Hare Krishna Krishna Krishna Hare Hare
Try it online with each row reversed (integer input): number You're on a 8 day streak!
Try it online with each row reversed (string input): string No A, just CAPS LOCK
Try it online with each row reversed (no input): kolmogorov-complexity Print a Tabula Recta!
Try it online with both the rows and each row itself reversed (integer input): number Am I a Rude Number?
Try it online with both the rows and each row itself reversed (string input): string Don't google "google"
Try it online with both the rows and each row itself reversed (no input): kolmogorov-complexity Sing Happy Birthday to your favourite programming language
Try it online rotated 90 degrees clockwise (integer input): number Fibonacci function or sequence
Try it online rotated 90 degrees clockwise (no input): number Count up forever
Try it online rotated 90 degrees clockwise and then each row reversed (integer input): number Is this number a prime?
Try it online rotated 90 degrees clockwise and then each row reversed (no input): quine Print the last, middle and first character of your code
Try it online rotated 90 degrees counterclockwise (no input): kolmogorov-complexity Build me a brick wall!
Try it online rotated 90 degrees counterclockwise and then each row reversed (no input): string "Hello, World!"
Explanation:

In general, I mostly rely on the builtin q. This will stop the program, making everything after it no-ops.
In addition, for the four main rotations, I split them up into integer/string/no input with:
.ïi         # If the (implicit) input is an integer:
            #  Do something with the integer-input
ëĀi         # Else-if the (implicit) input-string is NOT empty:
            # (using the Python-truthify builtin `Ā`)
            #  Do something else with the string-input
ë           # Else (there is no input):
            #  Do something else without input

For the two clockwise rotations it's similar, but only with integer or no input (since there aren't any other challenges available with input from the list in the challenge).
And for the two counterclockwise rotations it's just a kolmogorov-complexity output without input.
Some things I had to fix for the rotations include:

Adding an additional space between the .ï and i at the start of the first line, and a space on each subsequent line. Without this space, the middle character for subprogram of the Print the last, middle and first character of your code challenge would have a newline character as the center, which isn't possible without screwing up the layout. With that added space, the middle character in that rotation also becomes a space (the first and last characters are both .).
Adding \” at the end of the final line. This is to close this string and discard it for the programs with all rows and each row itself reversed, which will now contain a leading ””\ followed by a bunch of no-op spaces.
For most rotations I reuse the . for the .ï (is_integer check), but for one rotation it's .… instead. . opens up 2-byte builtins, but since .… doesn't exist, the . is a no-op instead in this case.

As for an explanation of each individual program:
ascii-art Do you want to code a snowman?: …( )7ÝJ»•αγʒδÓ₂©8¥ŽQxΣxêÿ•sÅвJIvN”</[(0._-=:"ÆŸ,*”0¶:º•DùÙÂ+;Èγтáì³ÓW©ÎÂ_`ƒ≠îj*ΓçÊ~ÞÒ¸β¦oåb/õ47/vÎΓ”›≠øØZµλÝº•20вè¶¡Nè4äyè.;
See this answer of mine, except that the actual newline is replaced with a 0, which we replace to a newline after creating the string with 0¶:.
ascii-art It took me a lot of time to make this, pls like. (YouTube Comments #1): ηû»
See the second program in this answer of mine (provided by @Grimmy).
string 1, 2, Fizz, 4, Buzz: тÝ3Å€"Fizz"}5Å€á”ÒÖ”J}¦»
See this answer of @Grimmy.
ascii-art It's my Birthday :D: _i“Ûà€‰€ž€¢‡Í! :D“ćuìëdiU„ $„ |}…-~-`)X·>δ∍»}
See this answer of @Grimmy, with additional trailing } to close the if-statement.
string Covefify a string: 1ú.γžOså}R`¦??н©?н®ì.•gÍĆdQ¸G•Â‡D?,
See this answer of @Grimmy.
kolmogorov-complexity Hare Krishna Hare Krishna Krishna Krishna Hare Hare: “«Î‡Ä¦í¥Â“#€¦`«'kì)™•1¢₂P•3вè4ô»
See this comment of mine on the answer of @Emigna.
“«Î‡Ä¦í¥Â“  # Push dictionary string "drama share irish dna"
 #          # Split it on spaces: ["drama","share","irish","dna"]
  €¦        # Remove the first character of each word:
            #  ["rama","hare","rish","na"]
    `       # Push them separated to the stack
     «      # Merge the last two together: "rishna"
      'kì  '# Prepend a "k": "krishna"
         )  # And wrap everything on the stack into a list again:
            #  ["rama","hare","krishna"]
          ™ # Titlecase each: ["Rama","Hare","Krishna"]
•1¢₂P•      # Push compressed integer 27073120
 3в         # Convert it to base-3 as list: [1,2,1,2,2,2,1,1,1,0,1,0,0,0,1,1]
   è        # Index each integer into the list of words
    4ô      # Split the list of words into parts of size 4
      »     # Join each inner list by spaces, and then each string by newlines
            # (after which the result is output implicitly as result)

See this 05AB1E tip of mine (sections How to use the dictionary?, How to compress large integers?, and How to compress integer lists?) to understand why “«Î‡Ä¦í¥Â“ is "drama share irish dna"; •1¢₂P• is 27073120; and •1¢₂P•3в is [1,2,1,2,2,2,1,1,1,0,1,0,0,0,1,1].
number You're on a 8 day streak!: ₄внŽ4$2ôQàI8Å?+>„ans∍
See this answer of mine.
string No A, just CAPS LOCK: „AaS¡Dvć?.š
See this this answer of @Emigna, although without õ? and with .š instead of š, since his answer is built in the legacy version of 05AB1E instead of the new one.
kolmogorov-complexity Print a Tabula Recta!: A₂F=À
See this answer of @Adnan, although with ₂F instead of Dv, since I personally prefer to keep my programs as straight-forward as possible despite codegolfing (where ₂ is the builtin for 26, and F loops that many times).
number Am I a Rude Number?: 32B4å
See this answer of mine.
string Don't google "google": 'Š¹ÊigëF
Although there is this pretty old answer of @Adnan which worked on one of the earliest versions of 05AB1E when he posted it back in 2016, it doesn't even work anymore in the latest legacy version on TIO from around mid-2017, let alone in the latest 05AB1E version. So instead I now use this (which is also 2 bytes shorter anyway):
'Š¹        '# Push the dictionary string "google"
   Êi       # If the (implicit) input-string is NOT equal to "google":
     g      #  Pop and push the length of the (implicit) input-string
            #  (which will be output implicitly as result)
    ë       # Else:
     F      #  Start a loop using the (implicit) input-string,
            #  which will result in an error if it isn't an integer

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why 'Š¹ is "google".
kolmogorov-complexity Sing Happy Birthday to your favourite programming language: ”to€î”Ð”¬Ž 05AB1E”s)”ŽØ¢© ”ì»
See this 05AB1E answer of @Grimmy.
number Fibonacci function or sequence: Åf
Åf          # Given the (implicit) input-integer `n`, get the n'th Fibonacci number
            # (after which it is output implicitly as result)

number Count up forever: ∞€,
See this answer of @Sagittarius.
number Is this number a prime?: p
p           # Given the (implicit) input-integer, check if it's a prime number
            # (1 if truthy; 0 if falsey)
            # (after which it is output implicitly as result)

quine Print the last, middle and first character of your code: .…. .
As I already mentioned earlier, I added an additional no-op space to the program so the middle character in this orientation would be a space character, instead of a newline character. The first and last characters are ., so we'll have the following sub-program:
.           # No-op, since `.…` isn't an available 2-byte builtin
 …. .       # Push 3-char string ". ."
     q      # Stop the program, making everything after that no-ops
            # (after which the result is output implicitly)

kolmogorov-complexity Build me a brick wall!: .…_|_ĆƵм×Tä»
See this answer of @Adnan, although golfed by 2 bytes by replacing "_|__" with …_|_Ć (push 3-char string "_|_"; and then enclose, appending its own first character) and 175 with Ƶм (compressed integer).
string "Hello, World!": ”Ÿ™,‚ï!”
See this answer of @Adnan, except with trailing ” to close the string.
The ] you see before the q in each program is to close all open if-else statements and loops before doing this q.
I'm unable to fit anything more in it from the list in the challenge description. The ones left are three (kolmogorov-complexity/ascii-art) that require you to output something without input (which I have already used in all eight rotations) and four quine-related challenges, which are just impossible with this kind of layout in 05AB1E.
If there would have been more challenges taking integer/string inputs, those could have been added as well.


JavaScript (ES2018), 62 54 bytes

s=>!/0(.{30}|.{60,62}(.{31})*)0|( .{30}){4} /s.test(s)

Input is a single string:

without trailing new line
contain only space, '0', and '\n'
30 characters each line, 5 lines, 154 character in total

Flag s means a dot match anything (including '\n'). This feature currently supported by Chrome 63+, Opera 50+, Safari 11.1+, based on compat-table. You may test this function with these supported browser. You will get an exception when loading the page if your browser do not support this feature.

How it works:

No column with no 0:

do not match /( .{30}){4} /

No two 0s in one column:

do not match /0.{30}(.{31})*0/

No 0 not connect to its neighbors:

do not match /0.{60}(.{31})*0/, /0.{62}(.{31})*0/

Merge all these regex, and you will finally got this one.

f =

s=>!/0(.{30}|.{60,62}(.{31})*)0|( .{30}){4} /s.test(s)
<textarea id=i style="width:100%;height:100px">            0 0
  0        0 0 000
00 0     00       000 0      0
    000 0            0 0   00
       0                000   </textarea>
<button onclick="o.value=f(i.value.slice(0,154))">Validate</button>
Result: <output id=o></output>

Thanks to Martin Ender point out that do a single ! operator may save 8 bytes.


Python (38)

Full code with tests here. A ton of the tests were wrong, so I modified them. Most of the changes are marked with the string "patch" in a comment, but I'm sure I forgot to mark some.

It was completely unclear if diffMinutes(a, b) was abs(a-b), a-b or b-a, so I went with b-a because I had to change less tests that way.

Also, ampm is a terrible variable name. isAM would be a far more readable name, and isPM would be preferable, as true and false are often associated with 1 and 0, and PM is a higher/later value.

The interesting part (getters and setters in the link above):

def getMinutesFromMidnight(clock):
    return clock.hours * 60 % 720 + 720 * (not clock.ampm) + clock.minutes

def diffMinutes(a,b):
    return getMinutesFromMidnight(b) - getMinutesFromMidnight(a)

class Clock(object):
    def __init__(self):
        self.hours = 12
        self.minutes = 0
        self.ampm = True

    def addHours(self, hours):
        self.addMinutes(hours * 60)

    def addMinutes(self, minutes):
        minutes = getMinutesFromMidnight(self) + minutes
        self.hours = minutes / 60 % 12 or 12
        self.minutes = minutes % 60
        self.ampm = minutes % 1440 < 720


Bernardino identifies unaltered dollar words

Python, 39 38 bytes

lambda s:sum(ord(i)-96for i in s)==100

Try it online!

-1 byte thanks to @JonathanAllan


C: 3863 1144 1023 999 942 927

The original solution saves 2 pnm files per run (one with g appended, before dithering). Because the dithering wasn't beautiful for the first few lines, there is a hack in place to render more lines than needed, and crop during output.

The golfed solution has a simpler dithering and saves only the dithered image.
(no warnings with gcc -std=c11 -pedantic -Wall -Wextra)

Example images from 3 original program runs and one run of the golfed version (last image):

Golfed version

  #include <math.h>
  #include <time.h>
  #include <stdlib.h>
  #include <stdio.h>
  #define D float
  #define R rand()/RAND_MAX
  #define Z(a,b,c) if(10.*R>a)T(h,s,j+b+c*R,g);
  #define U a[y][x]
  #define V e[y+1][x
  #define F(x) for(i=0;i<x;++i)
  int i,x,y,W=800,H=600;unsigned char a[600][800],c;D e[601][802],r,b,k,l,m,n,f,w,
  d,q=.01;void T(D h,D s,D j,D g){r=b=0;do{j+=.04*R-.02;h+=sin(j)*q;s+=cos(j)*q;b
  +=q;g+=q;f=525/d;r=.25-g/44;m=w*f+s*f+W/2;n=2*f-h*f+H/2;f*=r;for(y=n-f-2;y<n+f+2
  ;++y)if(y>=0&&y<H)for(x=m-f-2;x<m+f+2;++x)if(x>=0&&x<W)if(k=m-x,l=n-y,f>sqrt(k*k
  +l*l))if(U>d*3)U=d*3;}while(b<10*r+12*r*R&&r>q);if(r>q){Z(2,.26,.35)Z(2,-.26,-
  .35)Z(7,-.05,.1)}}int main(){FILE* o=fopen("i","wb");srand(time(0));F(W*H){y=i/W
  ;a[y][i%W]=(y<313)?255:6e3/(2*y-H);}F(200)w=1e2*R-60,d=80.*R+5,T(0,0,1.58,0);F(W
  *H){x=i%W;y=i/W;k=U+e[y][x+1];U=-(k>0);l=(k-U)*.1;e[y][x+2]+=l*4;V]+=l*2;V+1]+=l
  *3;V+2]+=l;}fprintf(o,"P5 800 600 255 ");fwrite(a,1,W*H,o);}

Original version

  #include <math.h>
  #include <stdio.h>
  #include <stdlib.h>

  #define W 800
  #define H 600
  #define SPEED 0.01
  #define HEIGHT 11.0

  #define R(m) ((double)(m) * rand() / RAND_MAX)
  #define RAD(deg) ((deg) / 180.0 * M_PI)
  #define LIMIT(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))

  void shade(void);
  void growTree(double dist, double side, double h, double s, double alpha, double grown);
  void plot(double dist, double side, double h, double s, double alpha, double diam);
  void dither(void);
  void writeImg(int dither);

  unsigned char img[H+10][W];
  double err[H+10+2][W+4];
  long tim;

  int main(void)
  {
     int i;
     tim = time(0);
     srand(tim);
     shade();
     for(i = 0; i < 200; ++i)
     {
        growTree(5 + R(75), -60 + R(120), 0.0, 0.0, RAD(90), 0.0);
     }
     writeImg(0);
     dither();
     writeImg(1);
  }

  void shade(void)
  {
     int y;
     for(y = -10; y < H; ++y)
     {
        double dist = H * 3.5 / (2 * y - H);
        unsigned char color = dist / 80 * 255;
        if(y <= H / 2 || dist > 80) color = 255;
        memset(img[y+10], color, W);
     }
  }

  void growTree(double dist, double side, double h, double s, double alpha, double grown)
  {
     double diam, branchLength = 0.0;

     do
     {
        alpha += R(RAD(3)) - RAD(1.5);
        h += sin(alpha) * SPEED;
        s += cos(alpha) * SPEED;
        branchLength += SPEED;
        grown += SPEED;
        diam = (1.0 - grown / HEIGHT) * 0.5;
        plot(dist, side, h, s, alpha, diam);
     } while(branchLength < 5 * diam + R(6 * diam) && diam > 0.02);

     if(diam > 0.02)
     {
        int br = 0;

        if(R(10) > 2) br++,growTree(dist, side, h, s, alpha + RAD(15) + R(RAD(20)), grown);
        if(R(10) > 2) br++,growTree(dist, side, h, s, alpha - RAD(15) - R(RAD(20)), grown);
        if(R(10) < 2 || br == 0) growTree(dist, side, h, s, alpha - RAD(2.5) + R(RAD(5)), grown);
     }
  }

  void plot(double dist, double side, double h, double s, double alpha, double diam)
  {
     int x, y;
     double scale = H / 4.0 * 3.5 / dist;
     double x0 = side * scale + s * scale + W / 2.0;
     double y0 = H / 2.0 + 2.0 * scale - h * scale;
     diam *= scale;
     h *= scale;
     s *= scale;
     for(y = y0 - diam / 2 - 2; y < y0 + diam / 2 + 2; ++y)
     {
        if(y < -10 || y >= H) continue;
        for(x = x0 - diam / 2 - 2; x < x0 + diam / 2 + 2; ++x)
        {
           double dx, dy, d;
           if(x < 0 || x >= W) continue;
           dx = x0 - x;
           dy = y0 - y;
           d = diam / 2 - sqrt(dx * dx + dy * dy) + 0.5;
           if(d > 0)
           {
              unsigned char color = dist / 80 * 255;
              if(img[y+10][x] > color) img[y+10][x] = color;
           }
        }
     }
  }

  void dither(void)
  {
     int x0, x, y;
     for(y = -10; y < H; ++y)
     {
        for(x0 = 0; x0 < W; ++x0)
        {
           double error, oldpixel;
           unsigned char newpixel;
           if(y%2) x = W - 1 - x0;
           else x = x0;
           oldpixel = img[y+10][x] + err[y+10][x+2];
           newpixel = oldpixel > 127 ? 255 : 0;
           img[y+10][x] = newpixel;
           error = oldpixel - newpixel;
           err[y+10  ][x+1+2*(1-y%2)] += error * 7 / 48;
           err[y+10  ][x+4*(1-y%2)] += error * 5 / 48;
           err[y+10+1][x  ] += error * 3 / 48;
           err[y+10+1][x+1] += error * 5 / 48;
           err[y+10+1][x+2] += error * 7 / 48;
           err[y+10+1][x+3] += error * 5 / 48;
           err[y+10+1][x+4] += error * 3 / 48;
           err[y+10+2][x  ] += error * 1 / 48;
           err[y+10+2][x+1] += error * 3 / 48;
           err[y+10+2][x+2] += error * 5 / 48;
           err[y+10+2][x+3] += error * 3 / 48;
           err[y+10+2][x+4] += error * 1 / 48;
        }
     }
  }

  void writeImg(int dither)
  {
     FILE* fp;
     char buffer[32];
     sprintf(buffer, "%ld%s.pnm", tim, dither ? "" : "g");
     fp = fopen(buffer, "wb");
     fprintf(fp, "P5\n%d %d\n255\n", W, H);
     fwrite(&img[10][0], 1, W * H, fp);
     fclose(fp);
  }


Determine stability of a system using the Routh-Hurwitz stability criterion

Haskell - 264 bytes

p(a:b:s)=(a,b):p s
p[a]=[(a,0)]
p[]=[]
s((a:w),m@(b:v))=a:s(m,m%zipWith(\c d->(b*c-a*d)/b)w v)
s((a:_),_)=[a]
m%(0:v)|all(==0)v=fst$foldr(\b(d,p)->(b*p:d,2+p))([],0)m
m%v=v
q(a:s)|all((>0).(a*))s="1\n"
q _="0\n"
main=interact$(>>=q.s.unzip.p.map read.words).lines

Running the sample inputs:

& runhaskell 11847-Stability.hs
1 12 6 10 10 6 14
1 1 -2
1 2 1 2
1 3 1 3 16
1 2 3 6 2 1
1 2 14 88 200 800
1 2 3 6 2 1
1 3 6 12 8
1 4 5 2 4 16 20 8
0
0
1
0
0
0
0
1
0

(The output is interleaved with the input if you type it one line at a time, as per spec. If you bulk paste, you see all the output after the input.)


Use underscores

This is probably the most important tip. Nearly every golfed Röda program uses underscores.

The underscore syntax is syntactic sugar for for loops. The following lines of code are equivalent:

ls""|fileLength x for x|sort|pull
ls""|fileLength _|sort|pull

Each underscore adds a new variable to an invisible for loop that is around the statement. The loop pulls one value from the stream for each variable/underscore and then repeats, until no values are left.

Underscores can be used anywhere in statements:

a[x:y+1]=[1]*(1+y-x) /* Sets range x..y (inclusive) */
seq x,y|a[_]=1       /* 6 bytes less */

If you must refer to the same underscore value more than once, or use the values in reverse order, you can put a number after the underscore:

a|[_^_1]  /* maps x to x^x */
a|[_2-_1] /* maps each pair (x,y) to y-x, eg. [1,2,4,8] -> [1, 4] */


Python 3, 79 digits (probably optimal)

A simple depth first search that allows up to two consecutive zeros.

from sympy.ntheory.primetest import isprime

def dfs(n=0, k=1):
    yield n
    if 100*n > k:
        yield from dfs(n, k*10)
    for i in range(1,10):
        if isprime(k*i + n):
            yield from dfs(k*i + n, k*10)

l = 1
for prime in dfs():
    if prime > l:
        d = len(str(prime))
        print(f'{d} digits: {prime}')
        l = 10**d

Try it online! Validate the result!

Finds 200400201909005006060042636079002004200130030090050030780060900408062003 (72 digits) in 8 seconds on TIO. I let the program run on my computer a little longer and the highest recurrent prime it found is 7030560306007020600400306654060053003909007054300609009069003056030702030330347 (validation). The program actually completed after finding this number, so this is probably the longest prime meeting the challenges requirement.

Note that sympys isprime could theoretically return true for pseudoprimes >2^64, though no examples are known as of now.

Python 3, 24 digits

only considers numbers without zeros

from sympy.ntheory.primetest import isprime

def dfs(n=0, k=1):
    yield n
    for i in range(1,10):
        if isprime(k*i + n):
            yield from dfs(k*i + n, k*10)

l = 1
for prime in dfs():
    if prime > l:
        print(f'{len(str(prime))} digits: {prime}')
        l *= 10

Try it online! Validate the result!

Finds 357686312646216567629137 in less then a second on TIO.


Unscramble the letters by letter frequency analysis

JavaScript (V8), 185 bytes

c=>(l={},[...c].map(i=>l[i]=(l[i]|0)+1),e=Object.entries(l).sort((a,b)=>b[1]-a[1]).map(i=>i[0]).filter(i=>parseInt(i,36)>9),[...c].map(i=>"EARIOTNSLCUDPMHGBFYWKVXZJQ"[e.indexOf(i)]||i))

Try it online!
Doesn't currently pass the second test case, but instead is based on OP's description of how the unscrambling works. The test case seems to be incorrect at the moment, as some groups of letters (like F or P) repeat letters.
Explanation:
c=>(                            // Define arrow function with argument c
l={},                           // Create an empty object l
[...c].map(i=>                  // For each character i in c...
  l[i]=(l[i]|0)+1),               // Increment l[i] (the number of times i appears)
e=Object.entries(l)             // Format l as an array ["x", <number of times "x" appears>] in variable e
.sort((a,b)=>b[1]-a[1])         // Sort e so most common characters are first
.map(i=>i[0])                   // Get rid of number of times appeared
.filter(i=>parseInt(i,36)>9),   // Filter out non-letters using base 36 conversion :)
[...c].map(i=>                  // For each character i in c...
  "EARIOTNSLCUDPMHGBFYWKVXZJQ"[   // Get the nth item from the frequency chart...
    e.indexOf(i)]                   // Where n is the index of i in e
    ||i))                         // Unless it isn't a letter, where i stays i


APL, 34 or 44 bytes
The first version is 34 symbol long and is restricted to characters from the original single-byte APL charsets, such as the one still supported in Dyalog APL:
↑c/⍨n=+/¨c←,∘.,⍨v/⍨~v∊v∘.×v←1↓⍳n←⎕

Explanation:
                               n←⎕   ⍝ ask for a number, store as n
                          v←1↓⍳n     ⍝ generate all integers from 2 to n
                      v∘.×v          ⍝ compute the product table of any two such integers
                v/⍨~v∊               ⍝ select those that don't appear in the product table
         c←,∘.,⍨                     ⍝ generate all possible pairs of these primes
    n=+/¨c                           ⍝ check which pairs have a sum equal to n
↑c/⍨                                 ⍝ take the first that does

The second version is only 22 symbol long, because it exploits the π function to check for prime numbers, but that's only available in NARS2000 which uses Unicode, so the byte count is 44 in UCS-2:
2⍴(⌿⍨{∧/0π⍵})(⍪,⌽)⍳⎕-1

Explanation:
                   ⎕    ⍝ ask for a number N
                  ⍳ -1  ⍝ generate all naturals from 1 to N-1
             (⍪,⌽)      ⍝ arrange it into a table of all pairs of naturals with sum N
     {∧/0π⍵}            ⍝ check which pairs are made of all primes
2⍴(⌿⍨       )           ⍝ return the first pair that does

Examples
(⎕: is the prompt asking for a number)
      2⍴(⌿⍨{∧/0π⍵})(⍪,⌽)⍳⎕-1
⎕:
      4
2 2
      2⍴(⌿⍨{∧/0π⍵})(⍪,⌽)⍳⎕-1
⎕:
      6
3 3
      2⍴(⌿⍨{∧/0π⍵})(⍪,⌽)⍳⎕-1
⎕:
      8
3 5
      2⍴(⌿⍨{∧/0π⍵})(⍪,⌽)⍳⎕-1
⎕:
      124
11 113


JavaScript (ES6), 129 114 bytes

f=n=>[...Array(p=1<<n)].map((_,i)=>(p+i).toString(2).slice(1)).sort((a,b)=>g(a)-g(b),g=a=>[...a].reverse().join``<a)

I appear to have stumbled on the code that happens to generate the given example for 4 bits. Edit: Saved 15 bytes thanks to @ConorO'Brien.


Pyth, 44 bytes

The number generation took 20 bytes, and the formatting took 24 bytes.

jsMC+Led.e.<bkC,J<s.u+B+hNyeNeNQ,1 1Qm*;l`dJ

Try it online!

jsMC+Led.e.<bkC,J<s.u+B+hNyeNeNQ,1 1Qm*;l`dJ   input as Q
                   .u          Q,1 1           repeat Q times, starting with [1,1],
                                               collecting all intermediate results,
                                               current value as N:
                                               (this will generate
                                                more than enough terms)
                       +hNyeN                  temp <- N[0] + 2*N[-1]
                     +B      eN                temp <- [temp+N[-1], temp]

now, we would have generated [[1, 1], [3, 4], [11, 15], [41, 56], ...]

jsMC+Led.e.<bkC,J<s                 Qm*;l`dJ
                  s                            flatten
                 <                  Q          first Q items
                J                              store in J
                                     m    dJ   for each item in J:
                                         `     convert to string
                                        l      length
                                      *;       repeat " " that many times

jsMC+Led.e.<bkC,
              C,     transpose, yielding:
[[1, ' '], [1, ' '], [3, ' '], [4, ' '], [11, '  '], ...]
(each element with as many spaces as its length.)
        .e            for each sub-array (index as k, sub-array as b):
          .<bk            rotate b as many times as k

[[1, ' '], [' ', 1], [3, ' '], [' ', 4], [11, '  '], ...]

jsMC+Led
    +Led              add to each sub-array on the left, the end of each sub-array
   C                  transpose
 sM                   sum of each sub-array (reduced concatenation)
j                     join by new-lines


Jelly, 10 bytes (fork)

+×_:%*6ƭ"Ṛ

I was just working on implementing a quick for this the other day, so it's quite surprising to see a use for it so soon. It still only exists as a fork, so you cannot try it online.

Sample output

$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[1,2,3,4,5,6,7,8,9]'
[10, 16, -4, 0, 0, 1296, 10, 16, 8]
$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[5,3,6,1,1]'
[6, 3, 0, 0, 1]
$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[2,1,8]'
[10, 1, 6]
$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[11,4,-17,15,2,361,5,28]'
[39, 20, -378, 7, 2, 3.32948887119979e-44, 9, 308]

Explanation

+×_:%*6ƭ"Ṛ  Input: array
      6ƭ    Tie 6 dyads
+             Addition
 ×            Multiplication
  _           Subtraction
   :          Integer division
    %         Modulo
     *        Power
        "   Vectorize with
         Ṛ  Reverse


Convert from base 10 to base 2 without built-in base conversions

JavaScript, 46

for(x=prompt(o='');x;x>>>=1)o=(x&1)+o;alert(o)


CJam, 32 28 23 12 bytes

0le!f{~*}:e>

Try it online in the CJam interpreter.

Thanks to @user23013 for helping me save 16 whole bytes!

Idea

Permuting the characters in the input string divides it into integers (groups of consecutive digits) separated by spaces. By pushing a zero and then evaluating the permuted input string, we push two or more integers. Multiplying the topmost two will result either in the product of the input divided into exactly two integers or some suboptimal value.

Code

 le!         e# Push all possible character permutations of the input.
0   f{  }    e# For each permutation:
             e#   Push 0, then the permuted string.
      ~      e#   Evaluate the string. Pushes one or more integers.
       *     e#   Multiply the two topmost integers.
         :e> e# Retrieve the greatest integer in the array.