Ruby, 200 characters
f={}
r=0..20
(f[gets[1]]=$_[6..-1].gsub /\^/,'**'
s=r.map{' '*21}
f.map{|n,k|r.map{|y|x=y*0.5-5
v=(2*eval(k)).round
v.abs<11&&y!=10&&s[10-v][y]=n
s[y][10]='+|'[y%2]
s[10][y]='+-'[y%2]}}
puts s)while 1

A plain ruby implementation using the standard evaluator for expressions (^ will be replaced so that the examples given above work fine). It is not very robust and assumes the input exactly as specified in the question.


Perl (5.22.2), 0 bytes

Try it online!

I knew there'd be some language out there that leaked memory on an empty program. I was expecting it to be an esolang, but turns out that perl leaks memory on any program. (I'm assuming that this is intentional, because freeing memory if you know you're going to exit anyway just wastes time; as such, the common recommendation nowadays is to just leak any remaining memory once you're in your program's exit routines.)

Verification

$ echo -n | valgrind perl
…snip…
==18517==
==18517== LEAK SUMMARY:
==18517==    definitely lost: 8,134 bytes in 15 blocks
==18517==    indirectly lost: 154,523 bytes in 713 blocks
==18517==      possibly lost: 0 bytes in 0 blocks
==18517==    still reachable: 0 bytes in 0 blocks
==18517==         suppressed: 0 bytes in 0 blocks
==18517==
==18517== For counts of detected and suppressed errors, rerun with: -v
==18517== ERROR SUMMARY: 15 errors from 15 contexts (suppressed: 0 from 0)


Java

String getParamName(String param) throws Exception {
    StackTraceElement[] strace = new Exception().getStackTrace();
    String methodName = strace[0].getMethodName();
    int lineNum = strace[1].getLineNumber();

    String className = strace[1].getClassName().replaceAll(".{5}$", "");
    String classPath = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath() + className + ".class";

    StringWriter javapOut = new StringWriter();
    com.sun.tools.javap.Main.run(new String[] {"-l", "-c", classPath}, new PrintWriter(javapOut));
    List<String> javapLines = Arrays.asList(javapOut.toString().split("\\r?\\n"));
    int byteCodeStart = -1;
    Map<Integer, Integer> byteCodePointerToJavaPLine = new HashMap<Integer, Integer>();
    Pattern byteCodeIndexPattern = Pattern.compile("^\\s*(\\d+): ");
    for (int n = 0;n < javapLines.size();n++) {
        String javapLine = javapLines.get(n);
        if (byteCodeStart > -1 && (javapLine == null || "".equals(javapLine))) {
            break;
        }
        Matcher byteCodeIndexMatcher = byteCodeIndexPattern.matcher(javapLine);
        if (byteCodeIndexMatcher.find()) {
            byteCodePointerToJavaPLine.put(Integer.parseInt(byteCodeIndexMatcher.group(1)), n);
        } else if (javapLine.contains("line " + lineNum + ":")) {
            byteCodeStart = Integer.parseInt(javapLine.substring(javapLine.indexOf(": ") + 2));
        }
    }

    int varLoadIndex = -1;
    int varTableIndex = -1;
    for (int i = byteCodePointerToJavaPLine.get(byteCodeStart) + 1;i < javapLines.size();i++) {
        if (varLoadIndex < 0 && javapLines.get(i).contains("Method " + methodName + ":")) {
            varLoadIndex = i;
            continue;
        }

        if (varLoadIndex > -1 && javapLines.get(i).contains("LocalVariableTable:")) {
            varTableIndex = i;
            break;
        }
    }

    String loadLine = javapLines.get(varLoadIndex - 1).trim();
    int varNumber;
    try {
        varNumber = Integer.parseInt(loadLine.substring(loadLine.indexOf("aload") + 6).trim());
    } catch (NumberFormatException e) {
        return null;
    }
    int j = varTableIndex + 2;
    while(!"".equals(javapLines.get(j))) {
        Matcher varName = Pattern.compile("\\s*" + varNumber + "\\s*([a-zA-Z_][a-zA-Z0-9_]*)").matcher(javapLines.get(j));
        if (varName.find()) {
            return varName.group(1);
        }
        j++;
    }
    return null;
}

This currently works with a few gotchas:

If you use an IDE to compile this it might not work unless it is run as Admin (depending on where the temporary class files are saved)
You must compile using javac with the -g flag. This generates all debugging information including local variable names in the compiled class file.
This uses an internal Java API com.sun.tools.javap which parses the bytecode of a classfile and produces a human readable result. This API is only accessible in the JDK libraries so you must either use the JDK java runtime or add tools.jar to your classpath.

This should now work even if the method is called multiple times in the program. Unfortunately it does not yet work if you have multiple invocations on a single line. (For one that does, see below)

Try it online!

Explanation

StackTraceElement[] strace = new Exception().getStackTrace();
String methodName = strace[0].getMethodName();
int lineNum = strace[1].getLineNumber();

String className = strace[1].getClassName().replaceAll(".{5}$", "");
String classPath = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath() + className + ".class";

This first part gets some general information about what class we're in and what the name of the function is. This is accomplished by creating an exception and parsing the first 2 entries of the stack trace.

java.lang.Exception
    at E.getParamName(E.java:28)
    at E.main(E.java:17)

The first entry is the line that the exception is thrown on which we can grab the methodName from and the second entry is where the function was called from.

StringWriter javapOut = new StringWriter();
com.sun.tools.javap.Main.run(new String[] {"-l", "-c", classPath}, new PrintWriter(javapOut));

In this line we are executing the javap executable that comes with the JDK. This program parses the class file (bytecode) and presents a human-readable result. We'll use this for rudimentary "parsing".

List<String> javapLines = Arrays.asList(javapOut.toString().split("\\r?\\n"));
int byteCodeStart = -1;
Map<Integer, Integer> byteCodePointerToJavaPLine = new HashMap<Integer, Integer>();
Pattern byteCodeIndexPattern = Pattern.compile("^\\s*(\\d+): ");
for (int n = 0;n < javapLines.size();n++) {
    String javapLine = javapLines.get(n);
    if (byteCodeStart > -1 && (javapLine == null || "".equals(javapLine))) {
        break;
    }
    Matcher byteCodeIndexMatcher = byteCodeIndexPattern.matcher(javapLine);
    if (byteCodeIndexMatcher.find()) {
        byteCodePointerToJavaPLine.put(Integer.parseInt(byteCodeIndexMatcher.group(1)), n);
    } else if (javapLine.contains("line " + lineNum + ":")) {
        byteCodeStart = Integer.parseInt(javapLine.substring(javapLine.indexOf(": ") + 2));
    }
}

We're doing a couple different things here. First, we are reading the javap output line by line into a list. Second we are creating a map of bytecode line indexes to javap line indexes. This helps us later to determine which method invocation we want to analyze. Finally we are using the known line number from the stack trace to determine which bytecode line index we want to be looking at.

int varLoadIndex = -1;
int varTableIndex = -1;
for (int i = byteCodePointerToJavaPLine.get(byteCodeStart) + 1;i < javapLines.size();i++) {
    if (varLoadIndex < 0 && javapLines.get(i).contains("Method " + methodName + ":")) {
        varLoadIndex = i;
        continue;
    }

    if (varLoadIndex > -1 && javapLines.get(i).contains("LocalVariableTable:")) {
        varTableIndex = i;
        break;
    }
}

Here we are iterating over the javap lines one more time in order to find the spot where our method is being invoked and where the Local Variable Table starts. We need the line where the method is invoked because the line before it contains the call to load the variable and identifies which variable (by index) to load. The Local Variable Table helps us actually look up the name of the variable based on the index we grabbed.

String loadLine = javapLines.get(varLoadIndex - 1).trim();
int varNumber;
try {
    varNumber = Integer.parseInt(loadLine.substring(loadLine.indexOf("aload") + 6).trim());
} catch (NumberFormatException e) {
    return null;
}

This part is actually parsing the load call to get the variable index. This can throw an exception if the function isn't actually called with a variable so we can return null here.

int j = varTableIndex + 2;
while(!"".equals(javapLines.get(j))) {
    Matcher varName = Pattern.compile("\\s*" + varNumber + "\\s*([a-zA-Z_][a-zA-Z0-9_]*)").matcher(javapLines.get(j));
    if (varName.find()) {
        return varName.group(1);
    }
    j++;
}
return null;

Finally we parse out the name of the variable from the line in the Local Variable Table. Return null if it isn't found although I've seen no reason why this should happen.

Putting it all together

 public static void main(java.lang.String[]);
    Code:
...
      18: getstatic     #19                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: aload_1
      22: aload_2
      23: invokevirtual #25                 // Method getParamName:(Ljava/lang/String;)Ljava/lang/String;
...
    LineNumberTable:
...
      line 17: 18
      line 18: 29
      line 19: 40
...
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0      83     0  args   [Ljava/lang/String;
          8      75     1     e   LE;
         11      72     2   str   Ljava/lang/String;
         14      69     3  str2   Ljava/lang/String;
         18      65     4  str4   Ljava/lang/String;
         77       5     5    e1   Ljava/lang/Exception;

This is basically what we're looking at. In the example code the first invocation is line 17. line 17 in the LineNumberTable shows that the beginning of that line is bytecode line index 18. That is the System.out load. Then we have aload_2 right before the method call so we look for the variable in slot 2 of the LocalVariableTable which is str in this case.

For fun, here's one which handles multiple function calls on the same line. This causes the function to not be idempotent but that's kind of the point. Try it online!


Jelly, 2 bytes

Ṿ¡

Try it online!

Ṿ¡  Main link; left argument (text) is x, right argument (repetitions) is y
 ¡  Repeat y times:
Ṿ   Uneval x; produce code that outputs x

hehe builtins


Retina, 102 100 93 88 bytes

Byte count assumes ISO 8859-1 encoding.

$
!¶$`
m`(?<=^(\w+ )*)(?=_.*¶(?<-1>\w+ )*(\w+))
$2
(([a-z])+)(?<-2>_)*(_*)\3|!\D+
$3$1$3

The strings will are separated by a linefeed. If there is an odd number of underscores left, the extraneous one will be after the word.

Try it online!

Explanation

I guess this is the "duplicate-append-lookback-match-add-centre approach", or something close...

$
!¶$`

We start by duplicating the input (separated with a ! and a linefeed). The purpose of this is that we can then process both lines by fetching words from the next line (instead of having to treat the second line separately).

m`(?<=^(\w+ )*)(?=_.*¶(?<-1>\w+ )*(\w+))
$2

This prepends the correct word to each gap. We start by counting the current word position with the lookbehind (?<=^(\w+ )*) (the position is stored as the depth of group 1). Then the lookahead a) ensures that we're at the beginning of a gap by matching _, then skips to the next line with .*¶, matches the correct number of words with (?<-1>\w+ )* to get to the right position, and then matches the word found there with (\w+) into group 2.

(([a-z])+)(?<-2>_)*(_*)\3|!\D+
$3$1$3

This stage does three things:

It removes the underscores corresponding to each word length. This is done by counting the word length into group 2 with ([a-z])+ and then matching that many underscores (which are never written back).
It shifts the word to the centre of the gap by capturing half of the remaining underscores with (_*)\3 and writing $3$1$3 back.
It removes the duplicated input by matching !\D+ and replacing it with nothing.


Separate a list into even-indexed and odd-indexed parts

Python, 23 bytes
lambda x:x[::2]+x[1::2]

Try it online


APL (Dyalog Unicode), 57 35 bytesSBCS

–22 thanks to a novel solution by ngn.
Anonymous tacit function taking a character matrix as argument.
{⊃'+-|+'↓⍨2⊥5 4 2⊃¨⊂⍱∘⌽⍨' '≠,⍵}⌺3 3

Try it online!
{…}⌺3 3 on each 3-by-3 neighbourhood, apply the following function:
 ,⍵ ravel (flatten)
 ' '≠ Boolean where non-space
 ⍱∘⌽⍨ that NOR it's reverse (incl. neither top NOR bottom, neither left NOR right)
 5 4 2⊃¨⊂ pick 5th, 4th, and 2nd element from that entire list
  i.e. empty self, no vertical, no horizontal
 2⊥ evaluate in base-2 (binary)
  i.e. ≥4:empty self; 3:no neighbours; 2:no horizontal neighbours; 1:no vertical; 0: has both
 '+-|+'↓⍨ drop that many elements from this string
  i.e. empty self:; alone:+; vertical neighbour(s) only:|+; horizontal:-|+; both:+-|+
 ⊃ pick the first element (pad with space if non are available)
  i.e. empty self: ; alone:+; vertical neighbour(s) only:|; horizontal:-; both:+

Old solution
Anonymous tacit function taking a character matrix as argument.
{' +-|+'⊃⍨1⍳⍨(' '=5⊃,⍵),(∧/,⊢)∨/2 2⍴1⌽' '≠(9⍴0 1)/,⍵}⌺3 3

Try it online!
{…}⌺3 3 on each 3-by-3 neighbourhood, apply the following function:
 ,⍵ ravel (flatten)
 (…)/ filter using the following mask:
  9⍴0 1 cyclically reshape [0,1] to length 9 (selects N, W, E, S)
 ' '≠ Boolean where non-space
 1⌽ rotate one step left; [W,E,S,N]
 2 2⍴ reshape to 2-by-2 matrix; [[W,E],[S,N]]
 ∨/ row-wise OR reduction: [horizontal,vertical]
 (…) apply the following tacit function:
  ⊢ the identity; [horizontal,vertical]
  ∧/, preceded by its AND reduction; [both,horizontal,vertical]
 (…), prepend the following:
  ,⍵ ravel (flatten) the neighbourhood
  5⊃ pick the 5th element (itself)
  ' '= Boolean if space (i.e. empty)
 Now we have [empty,both,horizontal,vertical]
 1⍳⍨ index of leftmost 1 (gives 5 if no neighbours at all)
 ' +-|+'⊃⍨ use that to pick symbol


05AB1E, 2 bytes

fP

Try it online!

How it works

f   Implicitly take input and compute the integer's unique prime factors.
 P  Take the product.


-ENDED- Do something that looks like something else

Javascript

var а;
a = 1;
а++;
alert( a );

Answer: It outputs 1. The comments below explain it pretty well - there are two different variables here, a - 'LATIN SMALL LETTER A' and а - 'CYRILLIC SMALL LETTER A'.

There was 1 correct answer, 50 people thought it outputs 2, and with a total of 52 answers, the score is (50 - 1) / 52 = 49 / 52 = 94,23%


Retina, 31 29 bytes

,$';$`
\d+
$*
;(11+)\1*,\1+;

Try it online!

Outputs a positive integer for valid inputs and zero for invalid ones.

I wouldn't recommend waiting for the larger test cases...

Explanation

,$';$`

At each position of the input insert a comma, then everything before that position, then a semicolon, then everything after this position. What does that do? It gives us all possible splittings of a number (split by ,, separated by ;), and then the input again at the end. So input 123 becomes

,123;1,23;12,3;123,;123
     ^     ^     ^

where I've marked the original input characters (the stuff that isn't marked is what we inserted). Note that this creates invalid splittings that aren't actual splittings and it also doesn't care whether the trailing component is all zeros, but we'll avoid accepting those later. The benefit of creating the invalid splittings is that we know that each valid splitting has a ; in front and after it, so we can save two bytes on word boundaries.

\d+
$*

Convert each number to unary.

;(11+)\1*,\1+;

Match a splitting by matching both halves as multiples of some number that's at least 2.


Humans hate pows and programmers hate humans - let's connect them!

Python 2, 204 190 bytes
This is my first ever codegolf.
s=raw_input()
p=' KMG'
if s[-1]<='9':
 e=0;r=int(s)
 while r>=1024:r/=1024.0;e+=1
else:
 e=p.index(s[-1]);r=eval(s[:-1])
 while e>0:r*=1024;e-=1
print(`r`if r%1!=0 else`int(r)`)+p[e].strip()


C (gcc), 126 bytes

M=N+1

Levenshtein(polyglot(M),polyglot(N)) is 36 bytes

#include<stdio.h>
#define print(a) main(){int z[1];if(sizeof(0,z)==4)printf("C(gcc)");else printf("Perl5");}
print("C++(gcc)")

Try it online!


JavaScript (ES6), 110 104 bytes
Saved 4 bytes thanks to edc65

let f =

_=>`1o
6o
3o
 9
/44\\__
|2J5|1\\
|3A4|1|
|4V3|1|
|5A2|__/
\\9/`.replace(/\d/g,n=>' _'[n>>3].repeat(++n))

console.log(f())

How it works
The compression of the original ASCII art is achieved by replacing all sequences of 2 to 10 consecutive spaces and the two sequences of 10 consecutive underscores with a single digit:

Each sequence of N consecutive spaces is encoded with the digit N-1.
The underscore sequences are encoded with a 9.

We use N-1 rather than N so that we never have to use more than one digit. Hence the need for ++n when decoding.
The expression n>>3 (bitwise shift to the right) equals 0 for n = 1 to n = 7 and equals 1 for n = 8 (not used) and n = 9. Therefore, ' _'[n>>3] gives an underscore for 9, and a space for all other encountered values.
The only special case is the sequence of 10 consecutive spaces just above "JAVA". Encoding it with a 9 would conflict with the underscore sequences. So we need to split it into two sequences of 5 spaces, encoded as 44.


Jelly, 12 bytes

Æf*³<‘Ạ
1Ç#Ṫ

Takes n and k (one-indexed) as command-line arguments.

Try it online!

How it works

1Ç#Ṫ     Main link. Left argument: n. Right argument: k

1        Set the return value to 1.
 Ç#      Execute the helper link above for r = 1, 2, 3, ... until k of them return
         a truthy value. Yield the list of all k matches.
   Ṫ     Tail; extract the last match.

Æf*³<‘Ạ  Helper link. Argument: r

Æf       Compute all prime factors of r.
  *³     Elevate them to the n-th power.
    <‘   Compare all powers with r + 1.
      Ạ  All; return 1 if all comparisons were true, 0 if one or more were not.


Charcoal, 7 5 bytes

θ‖Ｏ↙↘

Try it online! Link is to verbose version of code. Edit: Saved 2 bytes thanks to @CarlosAlejo. Explanation:

θ       Print the input string, making the top row
 ‖Ｏ     Reflect with overlap...
   ↙    ... down and left, to create the left side
    ↘   ... down and right, to create the bottom and right sides

(Multiple directions to the Reflect command run consecutively rather than simultaneously.)


Jelly, 19 bytes

R»2ɓ²Rg⁸>1Tḟ⁸ḟḢṭµ/Ṫ

Try it online!


Haskell 226 228 234 268 bytes

Naive answer in Haskell

import Data.List
o=map
u=sum
p=foldr(\x t->o([x]:)t++[(x:y):r|(y:r)<-t>>=permutations])[[]]
m x=foldl(\[m,n]x->[m+(x-m)/(n+1),n+1])[0,0]x!!0
a!z=abs$u z-a
s t=(length t,u$o((m$o u t)!)t)
a n=head.sortOn s.filter(all$(<=n).u).p

Or ungolfed

partition' :: [a] -> [[[a]]]
partition' [] = [[]]
partition' (x:xs) = [[x]:ps     | ps <- partition' xs]
                 ++ [(x:p):rest | ps <- partition' xs, (p:rest) <- permutations ps]

-- from Data.Statistics
mean :: [Double] -> Double
mean xs = fst $ foldl (\(m, n) x -> (m+(x-m)/n+1, n+1)) (0, 0) xs

diff :: Double -> [Double] -> Double
diff avg xs = abs $ sum xs - avg

rawScore :: [[Double]] -> Double
rawScore xs = sum . map (diff avg) $ xs where avg = mean . map sum $ xs

score :: [[Double]] -> (Int, Double)
score xs = (length xs, rawScore xs)

-- from Data.Ord
comparing :: (Ord b) => (a -> b) -> a -> a -> Ordering
comparing p x y = compare (p x) (p y)

candidates :: Double -> [Double] -> [[[Double]]]
candidates n xs = filter (all (\ ys -> sum ys <= n)) . partition' $ xs

answer :: Double -> [Double] -> [[Double]]
answer n xs = minimumBy (comparing score) $ candidates n xs

With some test cases

import Text.PrettyPrint.Boxes

testCases :: [(Double, [Double])]
testCases = [(6 , [2,5])
            ,(4 , [1,1,1,1,1])
            ,(6 , [2,3,2])
            ,(6 , [2,3,2,3])
            ,(6 , [2,3,2,3,2])
            ,(12, [10,8,6,4,2])
            ,(6 , [4,4,4])
            ,(12, [12,7,6,6])]

runTests tests = transpose
                 $ ["n", "Bookings", "Output"]
                 : map (\(n, t) -> [ show . floor $ n
                                   , show . map floor $ t
                                   , show . map (map floor) $ a n t]) tests

test = printBox
     . hsep 3 left . map (vcat top) . map (map text) . runTests $ testCases

Where test yields

n    Bookings       Output
6    [2,5]          [[2],[5]]
4    [1,1,1,1]      [[1,1],[1,1,1]]
6    [2,3,2]        [[2,2],[3]]
6    [2,3,2,3]      [[2,3],[2,3]]
6    [2,3,2,3,2]    [[2,2,2],[3,3]]
12   [10,8,6,4,2]   [[10],[8,2],[6,4]]
6    [4,4,4]        [[4],[4],[4]]
12   [12,7,6,6]     [[12],[7],[6,6]]

Edit

Thanks to @flawr and @nimi for advice.

Squashed p a bit.

Shaved off a couple bytes.


CJam, 100 96 94 91 bytes

"+WcbKF AQH;_{GM8Lyf=_tmTn"141bDb3/l72b970%={Z"O>HVa=4a"98bZb+"P.SW"f=3/=}%N*

StackExchange mangles unprintables, so rather than copying and pasting here is the permalink. Additionally, here's the test program.

(Thanks to @Optimizer for telling me about f and @MartinBüttner for telling me about CJam's modulo indexing.)

Cygwin's hexdump:

0000000 0122 2b1e 571a 6308 621f 4b05 2046 5141
0000010 1608 1848 5f3b 1115 1d7b 4d47 4c38 6679
0000020 5f3d 6d74 0c54 226e 3431 6231 6244 2f33
0000030 376c 6232 3739 2530 7b3d 225a 1b4f 483e
0000040 6156 343d 2261 3839 5a62 2b62 5022 532e
0000050 2257 3d66 2f33 7d3d 4e25 002a
000005b

Explanation

To construct the recipes, we use 13 different rows (also listed are explanations why this is minimal):

0    W..    (required by planks)
1    ...    (required by many)
2    .PP    (required by many)
3    PPP    (required by chest)
4    .P.    (required by bowl)
5    ..P    (required by stairs)
6    S.S    (required by ladder)
7    SSS    (required by ladder)
8    .S.    (required by sign)
9    .SP    (required by axe)
10   P.P    (required by bowl)
11   PSP    (required by fence)
12   SPS    (required by gate)

We encode the rows via Z"O>HVa=4a"98bZb+"P.SW"f=3/, which gives

["W.." "..." ".PP" "PPP" ".P." "..P" "S.S" "SSS" ".S." ".SP" "P.P" "PSP" "SPS"]

The first bit "+WcbKF AQH;_{GM8Lyf=_tmTn"141bDb3/ encodes the recipes, giving

[[3 3 8] [1 0 0] [1 0 0] [3 8 8] [1 3 3] [2 8 8] [6 7 6] [1 0 0] [1 10 3] [1 1 2] [2 2 2] [1 11 11] [1 1 4] [1 0 1] [1 10 4] [2 9 8] [3 10 3] [1 2 2] [4 8 8] [1 4 4] [1 1 3] [1 12 12] [4 4 8] [5 2 3]]

Note how the first entry is [3 3 8], which is the recipe for sign.

l72b970%= reads in the input, then applies some magic to work out which recipe to take from the list. Even though we only have 21 recipes there are 24 in the list — the extra few spots correspond to the [1 0 0]s.

After reading the input, picking the recipe and converting the recipe to rows, we put in some newlines N* and auto-print.

CJam, 89 86 83 bytes

'W"9=!%)S@*m:@DQzk?V$%qyR55AmVEpPNW}"132b3b"P.S"f=+3/3/l57b5342%24%(=N*

... it turns out that hardcoding all the outputs does a bit better in CJam. I'm pretty disappointed.

Once again we have some unprintables so here's the permalink and test program.

Cygwin's hexdump:

0000000 5727 0222 3d39 1021 2925 531e 2a40 6d0b
0000010 403a 1844 7a51 3f6b 2456 7125 5279 3506
0000020 4135 046d 1a56 7045 1550 164e 1057 7d01
0000030 3122 3233 3362 2262 2e50 2253 3d66 332b
0000040 332f 6c2f 3735 3562 3433 2532 3432 2825
0000050 4e3d 002a
0000053

Explanation

The outputs are encoded using base 3, with the lone W being tacked onto the front before the string is split into 3s to give rows, and the rows are split into groups of 3s to give recipes.

Like above, base converting and modulo magic is used to select the recipe. There are 22 recipes (one unused) but we need to take modulo 24, so we actually need to explicitly specify 24% this time rather than relying on modulo indexing.


Pyth, 9 bytes
osjN2U^2Q

order by the sum of the base 2 representation (jN2) over the range (U) of 2 ^ Q.
(Q = eval(input())).
Try it here.


Mathematica, 25 17 bytes

Input[]/.!x_:>1-x

Takes input from a user prompt. Assumes Mathematica's notebook environment for implicit printing. To make it a command-line script, wrap it in Print[...] or to make it an argumentless function (which then takes input from the prompt), append &.

Mathematica has both of the required operators (with the required precedence), so we can just "eval" the input (which is done automatically by Input[]), but the logical negation operator doesn't work on integers (so it will remain unevaluated). If there's a !x left in the result, we replace it with 1-x.

A couple of fun facts about the evaluation:

Mathematica actually also has the double factorial operator !!, which computes n*(n-2)*(n-4)*..., but applied to 0 or 1 it still gives 1, so it doesn't matter that 0!!!!! will actually be parsed as ((0!!)!!)!.
Even though Mathematica leaves !0 and !1 unevaluated, it does know that ! is self-inverse, so it will automatically cancel all pairs of leading !. After the ToExpression we're always left with one of 0, 1, !0, !1.


JavaScript (ES6), 160 156 146 143 135 bytes
Saved 10 bytes thanks to @tsh
Takes input as an array of characters.

a=>(a.map(c=>(i='GPDTJQKA'.search(c))>2|c?t-=h--*c?c>4:i-2:m|=1<<i,m=t=0,h=13),t+=!h*40+(m&2)*(m&!h?5:-5)+m%2*10,t+=m&4?t|m&3?t:5:0)*10

Try it online!
Commented
a => (                     // a[] = input array
  a.map(c =>               // for each card c in a[]:
    (i =                   //   convert c into an index i (-1 to 7)
      'GPDTJQKA'.search(c) //   in the string 'GPDTJQKA'
    ) > 2                  //   if c is a heart symbol (TJQKA)
    | c ?                  //   or c is numeric (2-9):
      t -=                 //     update t (total number of points / 10):
        h--                //       decrement h (number of hearts)
        * c ?              //       if c is numeric:
          c > 4            //         decrement t if c is greater than 4
        :                  //       else:
          i - 2            //         subtract 1 (for Ten) to 5 (for Ace) from t
    :                      //   else:
      m |= 1 << i,         //     update the bitmask m of special cards (G=1, P=2, D=4)
    m = t = 0, h = 13      //   start with m = 0, t = 0 and h = 13
  ),                       // end of map()
  t +=                     // update t (pass #1):
    !h * 40 +              //   add 40 to t if we have all hearts (-(-200) + 200)
    (m & 2) * (            //   if we have the Pig:
      m & !h ?             //     if we have all hearts and the Goat:
        5                  //       add 10 to t (the Pig is worth +100)
      :                    //     else:
        -5                 //       subtract 10 from t (the Pig is worth -100)
    ) +                    //
    m % 2 * 10,            //   add 10 to t if we have the Goat (the Goat is worth +100)
  t +=                     // update t (pass #2):
    m & 4 ?                //   if we have the Double:
      t | m & 3 ?          //     if t is non-zero or we have either the Pig or the Goat:
        t                  //       double t by adding it to itself
      :                    //     else:
        5                  //       add 5 to t (the Double alone is worth +50)
    :                      //   else:
      0                    //     leave t unchanged
) * 10                     // multiply the final result by 10


JavaScript (ES6), 47 45 bytes
Saved 2 bytes thanks to @ETHproductions
Takes input as a triplet [a, b, c] where a and b are the gene sequences and c is the list of 0-indexed cross-points.

x=>x[i=j=0].map(_=>x[(j+=x[2][j]==i)&1][i++])

Try it online!
Commented
x =>                    // given x = [ geneSeqA, geneSeqB, crossPoints ]
  x[i = j = 0]          // initialize i = gene sequence pointer and j = cross point pointer
  .map(_ =>             // for each value in the first gene sequence:
    x[(                 //   access x[]
      j += x[2][j] == i //     increment j if i is equal to the next cross point
    ) & 1]              //   access either x[0] or x[1] according to the parity of j
    [i++]               //   read gene at x[0][i] or x[1][i]; increment i
  )                     // end of map()


Evaluate Words Based on "Rules" (Skeptics.SE Crossover)

Python3, 105 103 bytes
This is my first golf here so be kind =)
-2 bytes tanks to Chas Brown
lambda d,b,x,y,z:sum((x+y in i)-2*((z*b+x+y+z)[:3]in i)-(y+x in i)+2*((z*b+y+x+z)[:3]in i)for i in d)>0

Takes the dictionary d as any iterator of strings; a boolean 'b' (True being after); and the three letters x,y,z as Strings;
Try it online!
Explanation: might add later


05AB1E, 6 bytes
∞b.ΔIÖ

Try it online! or verify all test cases (courtesy of @KevinCruijssen)

Explanation
∞b           - Infinite binary list
  .Δ         - Find the first value such that..
    IÖ       - It's divisible by the input


P Pr Pre Pref Prefi Prefix Prefixe Prefixes

Haskell, 20 bytes

Edit: Yet a byte shorter with a completely different scan.

An anonymous function slightly beating the trivial import.

scanr(\_->init)=<<id

Try it online!

Uses =<< for the abbreviation (scanr(\_->init)=<<id) l = scanr(\_->init) l l.
Scans a list l from right to left, collecting intermediate results with the function \_->init.
That function ignores the elements scanned through (they're only used to get the right total length for the collected results), so really iterates applying init to the initial value of the scan, which is also l.


Find the smallest positive integer which has all integers from 1 to n as factors

Python, 46 bytes

g=lambda n,c=0:n<1or(c%n<1)*c or g(n,c+g(n-1))

Take that, past xnor!

50 bytes:

g=lambda n,i=1:n<1or(i*n%g(n-1)<1)*i*n or g(n,i+1)

I apparently golfed this problem 5 months ago, and I don't remember how this code works or why I golfed it. I think I have a golfing problem.

(Edit: It's from this answer. Thanks to Dennis for inspiring the solution and saving 4 bytes.)

Apparently, this code recursively finds lcm(1..n) as lcm(lcm(1..n-1),n). So, the function g expresses g(n) as the smallest positive multiple i*n of n that's also a multiple of g(n-1). (It could instead search multiples of g(n-1) for multiples of n, but this is golfier because g(n-1) only needs to be referenced once. Thanks to Dennis for this improvement.)

Here's the rest of the file, full of other golfing attempts:

f=lambda a,b:a and f(b%a,a)or b
g=lambda n:reduce(lambda a,b:a*b/f(a,b),range(1,n+1))

f=lambda a,b:a and f(b%a,a)or b
g=lambda n:n==1 or n*g(n-1)/f(n,g(n-1))

import math
g=lambda n:n==1 or n*g(n-1)/math.gcd(n,g(n-1))

g=lambda n,k=1:k*all(k%~i==0for i in range(n))or g(n,k+1)
g=lambda n,k=1:min(k%~i for i in range(n))and g(n,k+1)or k

l=lambda a,b:a%b and l(b,a%b)*a/(a%b)or a
g=lambda n:n<1or l(n,g(n-1))

g=lambda n,i=1:n==0 or (g(n-1)*i if g(n-1)*i%n==0 else g(n,i+1))

g=lambda n,i=1:n<1or g(n-1)*i*(g(n-1)*i%n<1)or g(n,i+1)

g=lambda n,i=1:n<1or(i*g(n-1)%n<1)*i*g(n-1)or g(n,i+1)

g=lambda n,r=1,c=1:r if n<2 else (g(n-1,r,r)if r%n==0 else g(n,r+c,c))

g=lambda n,r=1,c=1:r*(n<1)or r%n and g(n,r+c,c)or g(n-1,r,r)

g=lambda n,i=1:n<1or(i*g(n-1)%n or i)*g(n-1)or g(n,i+1)

def g(n):
 if n==0:return 1
 a=b=g(n-1)
 while b%n:b+=a
 return b

g=lambda n,i=1:n<1or g(n-1)*i%n and g(n,i+1)or g(n-1)*i

g=lambda n:n<1or min(range(n,3**n,n),key=g(n-1).__rmod__)

g=lambda n,i=1:n<1or(i*n%g(n-1)<1)*i*n or g(n,i+1)

r=n=input()
while n:
 c=r
 while r%n:r+=c
 n-=1
print r

r=n=input()
while n:
 c=r
 while r%n:r+=c
 n-=1
print r

r=1
for n in range(input()):
 c=r
 while r%~n:r+=c
print r

r=n=input()
while n:
 exec"r+=c*(r%n>0);"*n
 n-=1;c=r
print r

r=n=input();exec("r+=r%n and c;"*n+"n-=1;c=r;")*n;print r

It's eerie looking at my own past work. In trying to golf it, I keep thinking "maybe I can save some bytes by ..." and then seeing there's already a piece of code that attempted to do just that.

You think you've thought of everything, past xnor? Well, I'll show you!


Ruby, 250
->x{d=y=0
x.size.downto(0){|n|y=n
a=["|
"*2*n]
"XNRDqpm@A".bytes{|z|p=[?|,' ','']
h=s=""
(n*2).times{|i|
i%n<1&&(d=z>>i/n*3&7)&&h=[?_,' '][d/3%2]*n
s=p[d%3]+h+p[d/6]+"
"+s
h=' '*n}
z!=68&&s=' '*(1-d%3/2)+?_*n+"
"+s
a<<s};puts a
a.index(x)&&break}
y}

Given that there are so many possible invalid inputs, the only way to do this was to generate all the correct digits and check to see if the input matches.
I build each digit up from bottom to top, in 2 halves plus the top line. Although there are 12 possibilities (considering that the left segment can be on, off, or in the case of 3and 7completely absent) only 7 are actually present and careful choice of encoding enables all info (except the top line) to be encoded into a single character.
the digit 1 doesn't really fit the pattern and is handled separately, being used to initialize the array.
Ungolfed in test program
This version uses . instead of spaces for diagnostic reasons.
#Encoding used for half-digits (radix 3,2,2 most significant digit at right)

#000    |_|  0

#100    ._|  1  . = space

#200    X_|  2  X = no space (for digits 3 and 7)

#010    |.|  3

#110    ..|  4

#210    X.|  5

#001    |_.  6

f=->x{d=y=0                                        #d and y required to be intialized for scoping reasons
  x.size.downto(0){|n|y=n                          #Assume max possible size of character = length of input and iterate down through all possible sizes n
    a=["|\n"*2*n]                                  #Make an array containing the digit 1 (different shape to others)
    "XNRDqpm@A".bytes{|z|                          #Each character encodes the pattern for a digit. Iterate through them
      p=['|','.','']                               #Possible components for left and right of digit
      h=s=""                                       #h initialized for scoping reasons. s will contain the digit string
      (n*2).times{|i|                              #For each row
        i%n<1&&                                    #If i%n==1 we are at the bottom of a half digit
        (d=z>>i/n*3&7)&&                           #so extract info from z and store in d
        h=[?_,'.'][d/3%2]*n                        #h is the horizontal part of the half digit, either _ or spaces
        s=p[d%3]+h+p[d/6]+"\n"+s                   #Build one row of digit, working upwards: left,middle,right
        h='.'*n                                    #If row i%n!=0 (not bottom row of half digit)the middle section must contain spaces
      }                                            #We now have both halves of the digit, only the top segment missing
      z!=68&&s='.'*(1-d%3/2)+?_*n+".\n"+s          #If z!=68 (digit 4) add a top to the digit, with appropriate leading and trailing spaces
      a<<s                                         #Add the completed digit of size n to a
    }
    #puts a                                        #Diagnostic: uncomment to print all the strings checked
    a.index(x)&&break                              #If string x is in a, break

  }
y                                                  #and return last value of n
}

# digit 7, size 2. Trailing newline required. Outputs 2
puts f[
"__.
..|
..|
..|
..|
"]


Python 3, 59 bytes

lambda l:[' '*i+'%c '%(i+65)*-~i for i in range(ord(l)-64)]

Try it online!

Python 3, 61 bytes

lambda l:[' '*i+-~i*(chr(i+65)+' ')for i in range(ord(l)-64)]

Try it online! (link to pretty-print version)


Convert a percentage to a "simple" ratio

T-SQL, 385 bytes
SELECT TOP 1IIF(i>.99,'>',IIF(i<.01,'<',''))+n+' in '+d
FROM t,(SELECT ISNULL(PARSENAME(value,2),'1')n,PARSENAME(value,1)d FROM
STRING_SPLIT('100,90,80,70,60,50,40,30,20,15,12,10,9,8,7,6,5,2.9,4,2.7,3.10,3,3.8,2.5,3.7,4.9,2,5.9,4.7,3.5,5.8,2.3,7.10,5.7,3.4,7.9,4.5,5.6,6.7,7.8,8.9,9.10,11.12,14.15,19.20,29.30,39.40,49.50,59.60,69.70,79.80,89.90,99.100',','))m
ORDER BY ABS(i-ABS(n)/d)

Input is via pre-existing table t with numeric field i, per our IO standards.
That input table is joined with an in-memory table parsed from a string via STRING_SPLIT (which separates rows) and PARSENAME (which separates numerator and denominator via .).
The table is sorted by distance from the input value i, and returns the top row, formatted appropriately.


Print largest integer you can with the fewest characters

JavaScript (10)

alert(1/0)

Prints "Infinity", did I win? :)


Perl 6, 37 33 bytes

-4 bytes thanks to nwellnhof!

{^.keys.max+1 xx.values.max∖$_}

Try it online!

Anonymous code block that takes a Bag and returns a Bag of values.

Explanation:

{                             } # Anonymous code block
 ^.keys.max+1  # Create a range from 1 to the maximum value of the list
              xx  # Multiply the list by:
                .values.max      # The amount of the most common element
                           ∖$_   # Subtract the original Bag


CJam, 19 bytes

q_1>_@.=:!1b\,d/4mO

100% chunky source code that calculates chunkiness.

Try this chunky goodness online.

How it works

q_                  e# Read from STDIN and push a copy.
  1>_               e# Discard the first character and push a copy.
     @              e# Rotate the original on top.
      .=            e# Vectorized comparison (1 if equal, 0 if not).
        :!          e# Mapped logical NOT (0 if equal, 1 if not).
          1b        e# Base 1 conversion (sum).
            \,      e# Swap with the shortened string and push its length.
              d/    e# Cast to double and divide.
                4mO e# Round to four decimal places.

Obviously, NaN rounded to 4 decimal places is 0.


Python 3, 33 bytes

lambda n:{*range(n%3,13,3)}-{n,0}

Try it online!

Python 2, 35 bytes

lambda n:[(n+c)%12+1for c in 2,5,8]

Try it online!


Hyperprogramming: N+N, N×N, N^N all in one

Jelly, 12 bytes

N+N

“(ẹ+)‘FQṖṪỌv

Try it online!

N×N

““((ẹẹ++))‘‘FFQQṖṖṪṪỌỌvv

Try it online!

N^N

“““(((ẹẹẹ+++)))‘‘‘FFFQQQṖṖṖṪṪṪỌỌỌvvv

Try it online!

How it works

Jelly has several different types of string literals; all of them start with a “. If the literal contains more than one “, a string array is returned, and “ separates the strings from each other.

For example, “abc“def” yields ['abc', 'def'].

Depending on the last character of the literal (any of ”«»‘’, where « is currently unimplemented), one can choose between the different types of literals. For ‘, we get the code points in Jelly's code page instead of the corresponding Unicode characters.

For example, “abc“def‘ yields [[97, 98, 99], [100, 101, 102]].

The three literals in the programs correspond to the following code point arrays.

“(ẹ+)‘           -> [40, 214, 43, 41]
““((ẹẹ++))‘      -> [[], [40, 40, 214, 214, 43, 43, 41, 41]]
“““(((ẹẹẹ+++)))‘ -> [[], [], [40, 40, 40, 214, 214, 214, 43, 43, 43, 41, 41, 41]]

N+N

“(ẹ+)‘FQṖṪỌv                          Main link. Argument: n

“(ẹ+)‘                                As before.
      F                               Flatten the array. Yields an integer array.
       Q                              Unique; deduplicate the integers.
                                      This yields [40, 214, 43, 41].
        Ṗ                             Pop; remove the last element.
         Ṫ                            Tail; extract the last element.
                                      This yields 43, the Unicode code point of +.
          Ọ                           Unordinal; cast to character.
           v                          Eval; execute the character as a Jelly
                                      program with argument n.

N×N

““((ẹẹ++))‘‘FFQQṖṖṪṪỌỌvv              Main link. Argument: n

““((ẹẹ++))‘                           As before.
           ‘                          Increment all integers.
            FF                        Flatten the array. Yields an integer array.
              QQ                      Unique; deduplicate the integers.
                                      This yields [41, 215, 44, 42].
                ṖṖ                    Pop twice; remove the last two elements.
                  ṪṪ                  Tail; extract the last element.
                                      This yields 215, the Unicode code point of ×.
                    ỌỌ                Unordinal; cast to character.
                      v               Eval; execute the character as a Jelly
                                      program with argument n.
                       v              Eval; convert the return value (n×n) to a
                                      string and execute that string as a Jelly
                                      program with argument n. Since the string
                                      consists of a single integer literal, that
                                      integer is returned, ignoring the argument.

Note that F, Q, Ṫ, and Ọ do not alter 1D arrays, arrays without duplicates, integers, and characters (respectively).

N^N

“““(((ẹẹẹ+++)))‘‘‘FFFQQQṖṖṖṪṪṪỌỌỌvvv  Main link. Argument: n

“““(((ẹẹẹ+++)))‘                      As before.
                ‘‘                    Increment all integers twice.
                  FFF                 Flatten the array. Yields an integer array.
                     QQQ              Unique; deduplicate the integers.
                                      This yields [42, 216, 45, 43].
                        ṖṖṖ           Pop thrice; remove the last three elements.
                           ṪṪṪ        Tail; extract the last element.
                                      This yields 42, the Unicode code point of *.
                              ỌỌỌ     Unordinal; cast to character.
                                 v    Eval; execute the character as a Jelly
                                      program with argument n.
                                  vv  Eval twice. See N×N.


Jelly, 20 bytes

O2ȷ:ı*S
ẆÇÐḟḢ⁸œṣFµÐL

Try it online! Or see the test-suite.

How?

O2ȷ:ı*S - Link 1, distance travelled: list of UDLR characters
O       - ordinals -> U:85 D:68 L:76 R:82
 2ȷ     - 2000
   :    - integer division -> U:23 D:29 L:26 R:24 (Note mod 4 these are 3 1 2 0)
    ı   - square root of -1  - i.e. (0+1j)
     *  - exponentiate -> U:(0-1j) D:(0+1j) L:(-1+0j) R:(1+0j)
      S - sum - 0 iff the path is a loop

ẆÇÐḟḢ⁸œṣFµÐL - Main Link: list of UDLR characters
         µÐL - loop until no change occurs:
Ẇ            -   all sublists
  Ðḟ         -   filter discard those which are truthy (non-zero) under:
 Ç           -     call last Link (1) as a monad
    Ḣ        -   head - X = first, shortest loop (if none this yields 0)
     ⁸       -   chain's left argument
      œṣ     -   split at sublists equal to X
        F    -   flatten


Split a list into sized chunks, but not counting items failing predicate

Brachylog, 37 bytes

hW&t~c.k{↰₂ˢl}ᵐ;WxĖ∧.bhᵐ↰₂ᵐ∧.t↰₂ˢl≤W∧

Try it online!

I was pleasantly surprised to find that this - pretty much a restatement of the question - successfully terminates and produces correct output.

Assumes the predicate is present as predicate 2 below this code. Outputs a list of lists ("chunks"), or false for an empty input.

Explanation:

hW&               % First input is W, the expected "weight" of each chunk
                  %  (i.e. the number of items passing predicate in each chunk)

t                 % Take the second input, the list of items
 ~c.              % Output is a partition of this list
    k{    }ᵐ      % For each partition (chunk) except the last,
      ↰₂ˢ         %   Select the items in the chunk that pass the predicate
         l        %   Get the length of that
                  % (So now we have the list of the "weights" of each chunk)
            ;Wx   % Remove the input expected weight from this list, and
               Ė  %  the result of this should be empty.
                  %  This verifies that the list of weights is either
                  %  composed of all W-values, or is empty (when input is [0 0 0] for eg.)

    ∧.bhᵐ↰₂ᵐ      % And, the first element of each chunk (except the first) should
                  %  pass the predicate. This is another way of saying:
                  %  "Items failing the predicate are allocated to the earliest chunk"

    ∧.t↰₂ˢl≤W     % And, the final chunk (which we haven't constrained so far)
                  %  should have weight ≤ the input expected weight
                  %  This disallows putting everything in the final chunk and calling it a day!

    ∧             % (no further constraints on output)


Sum of multiples of powers of ten of an integer

Jelly, 14 bytes

DḊƬḌINḟ0ȯ0j”+K

A full program which prints the result

Try it online!

How?

DḊƬḌINḟ0ȯ0j”+K - Main Link: integer, n       e.g. 805
D              - to base ten                      [8,0,5]
  Ƭ            - collect until a fixed point:
 Ḋ             -   dequeue                        [[8,0,5],[0,5],[5],[]]
   Ḍ           - from base ten (vectorises)       [ 805,    5,    5,  0]
    I          - incremental differences          [    -800,   0,   -5 ]
     N         - negate                           [     800,   0,    5 ]
      ḟ0       - filter discard zeros             [     800,         5 ]
        ȯ0     - OR zero (replacing an empty list with 0)
          j”+  - join with '+' characters         [     800,  '+',   5 ]
             K - join with space characters       [800,' ','+',' ',5]
               - implicit, smashing print         "800 + 5"


This one works:

var re = /(^|\s)((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi;

/*
(^|\s)                            : ensure that we are not matching an url
                                    embeded in an other string
(https?:\/\/)?                    : the http or https schemes (optional)
[\w-]+(\.[\w-]+)+\.?              : domain name with at least two components;
                                    allows a trailing dot
(:\d+)?                           : the port (optional)
(\/\S*)?                          : the path (optional)
*/

Passes the tests at http://jsfiddle.net/9BYdp/1/

Also matches:

example.com. (trailing dot)
example.com:8080 (port)


Pyth, 22 21 bytes

hfqzho>xNT0Sf}TY.z.:z

isaacg and me got the same 21 solution more or less at the same time. So he deleted his solution.

Try it online: Pyth Compiler/Executor

Explanation

                         implicit:  z = first input line
                                   .z = all other input lines
 f                .:z   filter all substrings T of z, which satisfy:
            f   .z        filter .z for lines Y, which satisfy:
             }TY            T in Y
           S              sort these lines alphabetically
     o                    order these lines N by:
      >xNT0                 (index of T in N) > 0
                          (sorting in Pyth is stable, so this brings the lines,
                           which start with T, to the beginning
                           without messing up the alphabetically order)
  qzh                     z == first element of ...
h                       print first elment


JavaScript (ES6), 333 329 327 323 283 bytes

Needs to be run from within the api.stackexchange.com domain (relevant meta). Returns a Promise containing the URL (relevant meta).

f=async i=>await(u="/questions/",s="?tagged=code-golf&site=codegolf",q=await(await(await fetch(u+s)).json()).items.filter(x=>x.owner.user_id!=i&x.answer_count<11).sort(_=>.5-Math.random())[0],await(await fetch(u+q.question_id+s)).json()).items.some(x=>x.owner.user_id==i)?f(i):q.link

Try it

f=async i=>await(u="//api.stackexchange.com/questions/",s="?tagged=code-golf&site=codegolf",q=await(await(await fetch(u+s)).json()).items.filter(x=>x.owner.user_id!=i&x.answer_count<11).sort(_=>.5-Math.random())[0],await(await fetch(u+q.question_id+s)).json()).items.some(x=>x.owner.user_id==i)?f(i):q.link
k.previousSibling.value=58974 // me
k.onclick=_=>f(+k.previousSibling.value).then(p=>k.nextSibling.innerText=p)
<input type=number><button id=k>Fetch</button><pre>

Bookmarklet

And here it is as a customisable bookmarklet, which will load a random question you've yet to answer. To use it, simply add a new bookmark to your browser's toolbar and drop the full code into the URL field.

Unlike the above solution, this works with all questions on a site therefore it may be slow to run (depending on the site and tags) and could also be expensive in the number of queries it needs to make to the API, as the API can only return 100 questions at a time.

To customise, change the following variables

k: Your API key - you can register for one here.
s: The Stack Exchange site you want to grab a question for.
i: Your user ID on that site.
t: The tags you want to filter by. There are 4 options available for this one:

"": An empty string; if you don't want to filter by any tags,
"code-golf;string": A semi-colon separated list of tags you want to filter by,
prompt("Tags:"): You will be prompted to enter the tags you want to filter by, or,
prompt("Tags:","code-golf;string"): You will be prompted to enter the tags you want to filter by, with a default list provided.

javascript:(f=(

/* See https://codegolf.stackexchange.com/a/122400/58974 for documenation */
k="",
s="codegolf",
i=58974,
t="code-golf",

p=1,q=[],r=1)=>fetch((u="//api.stackexchange.com/questions/")+(d=`?key=${k}&tagged=${t}&site=`+s)+`&page=${p}&pagesize=100`).then(r=>r.json()).then(j=>r&&(q=[...q,...j.items.filter(x=>x.owner.user_id!=i&(a=x.answer_count)&a<11)])^j.has_more?f(i,k,s,t,p+1,q,1):q.sort(_=>.5-Math.random())[0]).then(y=>fetch(u+y.question_id+"/answers"+d).then(r=>r.json()).then(j=>j.items.some(x=>x.owner.user_id==i)?f(i,k,s,t,q,0):window.location=y.link)))()


Husk, 13 bytes

►oΛ≈S+TzṀ↑Nḣ¶

Try it online!

Explanation

►oΛ≈S+TzṀ↑Nḣ¶  Implicit input, say "ab\nc".
            ¶  Split at newlines: ["ab","c"]
           ḣ   Take prefixes: [["ab"],["ab","c"]]
       z  N    Zip with [1,2,3..
        Ṁ↑     by taking that many characters from each row: [["a"],["ab","c"]]
►o             Find rightmost element that satisfies this:
  Λ            all strings in
    S+T        the list concatenated to its transpose
   ≈           have the same length: ["a"]
               Implicitly print separated by newlines.


Directory Structure Graphical Treefication

JavaScript (ES6), 237 128 bytes

f=(s,r=`.\n`+s.replace(/^ */gm,"$&└── "),q=r.replace(/^(.*)( |└)(?=.+\n\1[|└])/m,(_,i,j)=>i+`|├`[+(j>' ')]))=>q==r?r:f(s,q)

Where \n represents the literal newline character. Explanation: r is created from s by prepending the . line and inserting the └── at the end of each line's indent. This is now correct for the last line of the input, but each └ must be "extended" upwards as far as possible. This is the job of q, which searches for a └ and recursively replaces the spaces directly above it with |s unless it reaches another └ which gets turned into ├ instead. The recursion ends when no further replacements can be made. Note that if the character above the └ is a space or a └ then the text to the left of the └ is always the same as that on the previous line so I can just use \1 to test that the one character is above the other.


R, 53 50 48 bytes

f=function(x,y=rev(x))if(c(y,F))c(f(y[-1]),y[1])

Try it online!
Repeatedly takes the bottom card & flips the deck.


How drunk am I and when can I drive again?

TSQL, 301, 299, 219, 206 Bytes

Input goes into temp table #I (you said any format :)

SELECT * INTO #I FROM (
  VALUES
    (4,'shots','booze')
   ,(1,'glasses','wine')
   ,(2,'bottles','beer')
   ,(3, 'glasses','water')
) A (Q, V, N)

Code:

SELECT IIF(L<0,0,L),IIF(10*L-.5<0,0,10*L-.5)FROM(SELECT SUM(Q*S*P)L FROM(VALUES('bo%',.5),('be%',.1),('wi%',.2),('wa%',-.1))A(W,S),(VALUES('s%',.2),('g%',2),('b%',5))B(X,P),#I WHERE N LIKE W AND V LIKE X)A;

Thanks for the ideas to improve it, Micky T :)


TI-BASIC (TI-84), 30 32 31 bytes

-1 byte thanks to @SolomonUcko!

While Ans>9:Disp Ans:prod(int(10fPart(Ans10^(seq(-X-1,X,0,log(Ans:End:Ans

Input is in Ans.
Output is displayed as the challenge requests.  The trailing Ans is needed to print the last step.

I will admit, I did not think of this formula myself, rather I found it here and modified it to better fit the challenge.

EDIT:  Upon rereading the challenge, I realized that the program must terminate if the product is one digit.  Hence, 2 bytes were to be added to account for this.

Example:

24456756
        24456756
prgmCDGF8
        24456756
          201600
               0
11112
           11112
prgmCDGF8
           11112
               2

Explanation:

While Ans>9               ;loop until the product is one digit
Disp Ans                  ;display the current product
prod(                     ;get the product of...
 int(                     ; the integer part of...
  10fPart(                ; ten times the fractional part of...
  Ans                     ; each element in the following list times the
                          ;  current product
  10^(                    ; multiplied by the list generated by using each
                          ;  element of the following list as an exponent
                          ;  for 10^n
   seq(-X-1),X,0,log(Ans  ; generate a list of exponents from -1 to -L where
                          ;  L = the length of the current product
End
Ans                       ;leave the final product in "Ans" and implicitly
                          ; print it

Visual Model:
Ans starts off as 125673.
This model only covers the logic behind multiplying the digits; everything else is easier to understand.

seq(-X-1,X,0,log(Ans  =>  seq(-X-1,X,0,5.0992
   {-1 -2 -3 -4 -5 -6}
10^(...
   {.1 .01 .001 1E-4 1E-5 1E-6}
Ans...
   {12567.3 1256.73 125.673 12.5673 1.25673 .125673}
fPart(...
   {.3 .73 .673 .5673 .25673 .125673}
10...
   {3 7.3 6.73 5.673 2.5673 1.25673}
int(...
   {3 7 6 5 2 1}
   (the digits of the number, reversed)
prod(...
   1260
   (process is repeated again)

seq(-X-1,X,0,log(Ans  =>  seq(-X-1,X,0,3.1004
   {-1 -2 -3 -4}
10^(...
   {.1 .01 .001 1E-4}
Ans...
   {126 12.6 1.26 .126}
fPart(...
   {0 .6 .26 .126}
10...
   {0 6 2.6 1.26}
int(...
   {0 6 2 1}
prod(...
   0
   (product is less than 10.  loop ends)

Notes:

TI-BASIC is a tokenized language.  Character count does not equal byte count.

10^( is this one-byte token.

This program will not provide the correct sequence of products with integers greater than 14 digits long due to the limitations of decimal precision on the TI calculators.


My python is a little rusty because I haven't used it in a very long time, but how about something like this:

def generate_dice(count, sides = 12):
  dice = []
  for i in range(count):
    dice.append([])

  value = 0
  for sindex in range(sides):
    if sindex % 2:
      for dindex in range(count):
        value += 1
        dice[dindex].append(value)
    else:
      for dindex in reversed(range(count)):
        value += 1
        dice[dindex].append(value)
  return dice

The pattern here is simpler than the one you linked, but it appears to work as long as the number of sides on the dice is even. I originally did this in C# and then converted it to python.


Greater than less than greater than something fishy

Retina, 20 bytes

Byte count assumes ISO 8859-1 encoding.

$.'
S`>
%O#`\d+
¶
>

Try it online! (The first line enables a linefeed-separated test-suite.)

Explanation

A simple way to find a valid permutation is to start by inserting the numbers from 0 to N in order, and then to reverse the numbers surrounding each substring of >s. Take <><<>>><< as an example:

0<1>2<3<4>5>6>7<8<9
  ---   -------      these sections are wrong, so we reverse them
0<2>1<3<7>6>5>4<8<9

Both of those tasks are fairly simple in Retina, even though all we can really work with are strings. We can save an additional byte by inserting the numbers from N down to 0 and reversing the sections surrounding < instead, but the principle is the same.

Stage 1: Substitution

$.'

We start by inserting the length of $' (the suffix, i.e. everything after the match) into every possible position in the input. This inserts the numbers from N down to 0.

Stage 2: Split

S`>

We split the input around > into separate lines, so each line is either an individual number or a list of numbers joined with <.

Stage 3: Sort

%O#`\d+

Within each line (%) we sort (O) the numbers (\d#) by their numerical value (#). Since we inserted the number in reverse numerical order, this reverses them.

Stage 4: Substitution

¶
>

We turn the linefeeds into > again to join everything back into a single line. That's it.

As a side note, I've been meaning to add a way to apply % to other delimiters than linefeeds. Had I already done that, this submission would have been 14 bytes, because then the last three stages would have been reduced to a single one:

%'>O#`\d+


235

Substantially based on the guts of SoniEx2's 239 answer.

local o,k,F=type,next,{}for n=0,2 do
F[n]=function(a,r,t,G)if n<1 or o{}~=o(a)then return a end
t={}r=r or{}r[a]=n<2 and t G=F[n%2]for x,y in k,a do
t[r[x]or G(x,r)]=r[y]or G(y,r)end
return t end end
table.copy={shallow=F[2],deep=F[1]}

The advantage comes from using the same function prototype for both functions. Instantiating the same function prototype with different upvalues allows it to fill both roles.

Ungolfed:

-- ungolfed
-- note that type and next must have local copies to meet the spec
local o, k, F = type, next, {}
for n = 0, 2 do
  -- F[0] will be the identity function
  -- F[1] will be table.copy.deep
  -- F[2] will be table.copy.shallow
  F[n] = function(a, r, t, G)
    -- a is the table input
    -- r is the optional "custom recursion table" that is required
    -- t and G are just locals
    -- the spec implies (but does not state) that the global environment shouldn't be polluted
    -- r will only be used by recursive calls

    -- if n < 1, this is F[0], so act is the identity
    -- o is type, o{} is "table"
    -- if a is not a table, just return it
    if n < 1 or o{} ~= o(a) then
      return a
    end

    -- t will be the copy
    t = {}

    -- r will be the map that remembers which tables in the original map to which tables in the copy
    -- or, if it is passed in, it is a table that controls the behavior of the copy
    r = r or {}

    -- F[0] doesn't each here
    -- F[1] must add t to the map
    -- F[2] must not add t to the map
    -- (adding false will not hurt F[2] -- only true values will be picked up below)
    -- (behavior may not be exactly as desired for shallow copy, but spec doesn't require this feature)
    r[a] = n < 2 and t

    -- this is the function we will call to copy members
    -- for F[1] table.copy.deep, this is F[1] itself
    -- for F[2] table.copy.shallow, this is F[0] the identity
    -- (for F[0], we never get this far)
    -- the byte count seems equivalent making this a local vs putting it
    -- in both places it is used, but this is probably more efficient
    G=F[n%2]

    -- loop over and copy members
    -- first try r (which will only have non-1 entries for tables in F[1])
    -- then try G
    -- note that instead of calling "pairs" as usual, we can observe that pairs(a)
    -- is defined to return next, a, nil -- we use these (with implicit nil) directly
    for x, y in k, a do
      t[r[x] or G(x,r)] = r[y] or G(y,r)
    end

    return t
  end
end

-- export the functions as required
table.copy = {
  shallow = F[2],
  deep = F[1]
}

Hopefully I understood the spec correctly. This passes the provided test cases and there is enough similarity in the construction that I'm reasonably sure it does the same thing.

Note -- Initially I didn't understand the part about the "custom recursion table", but I have edited my answer to support it.

Note 2 -- Improved answer. I've also decided that the provided reference solution in 239 bytes does not exactly match my understanding of how the custom recursion table ought to work, since it cannot be used to add false into the copy. However, I believe my solution works as well as the provided one.


Brachylog, 12 bytes

ṁ↔ᵐ↔?aaᵐ.&≜∧

Try it online!

Contrary to most Brachylog answers, this takes the input through the Output variable ., and outputs the result through the Input variable ? (confusing, I know).

Explanation

ṁ              We expect a square matrix
 ↔ᵐ↔?          When we reverse the rows and then the matrix, we get the initial matrix back
    ?a         Take an adfix (prefix or suffix) of that square matrix
      aᵐ       Take an adfix of each row of that adfix matrix
        .      It must be the input matrix
         &≜    Assign values to cells which are still variables (will assign 0)
           ∧   (disable implicit unification between the input and the output)

8 bytes, gives all valid matrices

Technically, this program also works:

ṁ↔ᵐ↔?aaᵐ

But this will leave as variables the cells which can take any value (they show as _XXXXX, which is an internal Prolog variable name). So technically this is even better than what is asked, but I guess it's not what the challenge asks for.


204 characters

(K((O(R(O(NKORO)*(NK(O(RK)?)?)?)?)?)?K)*(O(R(O(NKORO)*(N(K(O(RK?[^KO]|[^KR])|[^KO])|[^K])|[^KN])|[^KO])|[^KR])|[^KO])|[^K])*(K((O(R(O(NKORO)*(NK(O(RK)?)?)?)?)?)?K)*(O(R(O(NKORO)*(N(K(O(RK?)?)?)?)?)?)?)?)?

Generated by turning .*KORONKORKO.* into a finite state machine, inverting the finite state machine, and turning it back into a regex.


Print the first character of the previous answers

7-bit ASCII, 15 bytes

Updated: I did not realize that padding should occur at the end.

Correct version, padded at end:

hexdump (xxd):

0000000: e1c3 af0e 1438 a8b6 8f37 7a7b 7250 b6    .....8...7z{rP.

Printouts (not sure which is correct):

�ï8��z{rP�

áÃ¯8¨¶7z{rP¶

Old version, incorrectly padded at the front:

pá×
T[G½=¹([

The language / format here is 7-bit ascii, where each group of 7 bits corresponds to an ASCII character. It is used in transferring SMS data. A decoder is located here.

No widely accepted ruling exists on whether answers to fixed output questions which are not written in a programming language are allowed. See this meta post for more information. (I apologize, I misread that post earlier.)


Check if number is a sum of consecutive numbers or not

JavaScript (31)

alert(!!((n=~~prompt())&(n-1)))

From my testing, I believe this gives correct solutions.

http://jsfiddle.net/3e9FZ/

Edit: (SPOILER ALERT!) Here is the justification for this answer:

All odd numbers greater than 1 can be trivially written as the sum of two consecutive numbers (ex 15 = 7+8, 23=11+12, etc.).
For even numbers having an odd factor where the odd factor is less than twice the even factor.  For example, 4*7, because 7 < (2*4 = 8).  Simply add 7 numbers with 4 at the center, 1+2+3+4+5+6+7.
For even numbers having an odd factor where the odd factor is more than twice the even factor.  For example, 4*9, because 9 > (2 * 4 = 8).  Double the even factor, and halve the odd factor to get 8*4.5.  You will add the 8 numbers centered at 4.5, i.e., 1+2+3+4+5+6+7+8.
The only numbers left are the even numbers having no odd factor, i.e., the powers of two.  The formula for the sum of a consecutive set of numbers is (avg * count).  Now if the count is odd, then avg is a whole number, and (avg * count) has an odd factor.  If count is even, then avg must be #.5, and thus avg * 2 is odd, and so avg * count has an odd factor.  Therefore, any sum using the formula (avg * count) must have an odd factor, which powers of two do not, and therefore have no solution.


TeX 212

I am using a typesetting system, not ASCII.  The column width can be changed by changing 90pt in the fourth line, but I don't know if that's enough to qualify for the 50 bytes discount.  The distance between the two copies of the text can be changed by changing the 9pt, also in the fourth line.  The code can probably be made shorter.  One can replace each newline by a single space, but not remove them completely.

\let\e\expandafter\read5to\t\read5to\.\def\a#1
{\def\~##1#1##2\a{\def\t{##1\hbox{\
#1\~{}}##2}\a}\e\~\t\a}\e\a\.{}\shipout\hbox
spread9pt{\hsize90pt\fontdimen3\font\hsize\vbox{\t}\
\let\~\ \def\ {}\vbox{\t}}\end.

After calling tex filename.tex in the terminal, the user is prompted to give the main text, then prompted again for a list of words to shift.  No empty line in between.  The (space-separated) list of words given in the second line should appear exactly as it is in the main text (punctuation is treated just like a letter would be, only spaces delimit words).


Average distance of two points in unit n-dimensional hypercube

Mathematica, 68 bytes

NIntegrate[(1-((E^-u^2+u*Erf@u√π-1)/u^2)^#)/u^2,{u,0,∞}]/√π&

Implementation of the formula using NIntegrate to approximate its value.


Husk, 6 bytes

U¡(ṁΣd

Try it online!

Explanation

U¡(ṁΣd
 ¡(       Iterate the following function on the input:
     d       Split the number into digits
   ṁΣ        Map each digit to its triangular number, then sum the results
U         Take the results of iteration until before the first repeated one


SOGL, 103 94 93 bytes

Ψ ~Δ№Q‘η¦»vζh‛←&M⁶╥7[P≈╔6≡⁸(φΔ\⅔Σ‚>≡ā⁷⁽○¹‘Ξ⁵K4s³‘⁽Bθ2n{@∑" the ”+Κ:bΚē‽:C}TPb"n@²‘+Tō, upcPøP

Try it here!

...‘                 push "bottom of the sea" - kept for the loop, here for
    ...‘             push "hole in log in bump on frog on wart on hair on fly on flea on smile on"
        ...‘         push "there's a "
            ⁽        uppercase the 1st letter of that
             B       save "There's a " in B
              θ      split the long data string on spaces
               2n    split in arrays of length 2

{                     for each of those:
 @∑                   join the current array with spaces - e.g. "hole in"
   " the ”+           append " the " to it
           Κ          prepend that to "bottom of the sea" (or whatever it is now)
            :         create a copy
             bΚ       prepend B to it - finishes current line
               ē‽:C}  if (E++), save a copy of that in C (for the last line)

TP                   print the current line twice
  b"...‘+            B + "hole" - "There's a hole"
         T           output that, keeping item
          ō,         output ", "
             up      print the kept item lowercased
               cP    print the contents of C
                 øP  print an empty line


APL (Dyalog),14 bytes

Prompts for start state as Boolean list and then for number of iterations

(1∘⌽≠¯1∘⌽)⍣⎕⊢⎕

Try it online!

⎕ numeric prompt (for Boolean list of start state)

⊢ on that, apply

(…)⍣⎕ the following tacit function, numeric-prompt times

 ¯1∘⌽ the argument rotated one step right

 ≠ different from (XOR)

 1∘⌽ the argument rotated one step left


Python 3, 32 bytes
-13 bytes thanks to @Arnauld
-1 byte thanks to @Dingus

import os
print(os.getuid()<1e3)

Try it online!


Python (24)

lambda s:s in(s+s)[1:-1]

Checks if the string is a substring of itself concatenated twice, eliminating the first and last characters to avoid trivial matches. If it is, it must be a nontrivial cyclic permutation of itself, and thus the sum of repeated segments.


Ranges

One thing that is really helpful is creating ranges using the ... or ..< operators

For example

array[0..<n] //first n elements of array
array[k..<n] //kth through nth elements of array
array[k...n] //kth through n-1 elements of array

So, to get the 2nd through 4th values of an array

let myArray = ["ab", "cd", "ef", "gh", "ij", "kl", "mn", "op"]
print(myArray[1..<4]) //["cd", "ef", "gh"]

Practical Use

let a = [3, 1, 4, 1, 5, 9]

Using

for v in a[0...3]{print(v)}

Is 8 bytes shorter than

for n in 0...3{let v=a[n];print(v)}


Vim 26 bytes

ihello world<ESC>qq~gsul@qq0@q

Explanation (no .gif yet):

First, we must enter the 'hello world' text. This is pretty straightforward. It's just:

ihello world<ESC>

At this point, the cursor is on the 'd' in 'world'. Next:

qq              " Start recording into register 'q'
  ~             " Swap the case of the character underneath the cursor, and move the cursor to the right
   gs           " Sleep for one second
     u          " Undo the last change (of swapping case).
      l         " Move one character to the right (Get it? 'l' == 'Right' because vim is intuitive!)
                " This will cause the error to break on the last character of the input.
       @q       " Call register 'q'
         q      " Stop recording
          0     " Move to the first character
           @q   " Call the recursive macro

There are also two other 26 byte versions I found:

ihello world<ESC>qq~gsulq011@q
ihello world<ESC>011@='~gsul'<cr>


Python

print 'Hello World'

Explanation:

The standard of the Programming Puzzles & Code Golf Stack Exchange is to

  Read the question carefully. What, specifically, is the question asking for? Make sure your answer provides that

This code is not answering the question, so it breaks the standard.


Implement hyperexponentiation/tetration without the use of '^'

J, score is 7 (12 chars - 5 points for avoiding multiplication)
+/@$/@$~/@$~
usage:
   4 +/@$/@$~/@$~ 3
1.34078e154
t=.+/@$/@$~/@$~  NB. define a function
   4 t 3
1.34078e154
   2 t 2
4

Just few nested folds:

Using multiplication it would be */@$~/@$~
Using power it would be ^/@$~ where $~ creates array, / is a fold function.


update key1 value obj = \key2 -> if key2 == key1 then value else obj key2
access = id

Given the above definitions, your examples should work. Also, you can define an empty dictionary as const x where x is the default value for keys not in the dictionary.


Minimal number of banknotes to pay a bill

Python 2, 87 80 68 bytes

f=lambda x:x>1and min((y%10)**6%305%3+f(y/10*x/y)for y in[x,-x])or x

Try it online!
-7 bytes thanks to @tsh, and -12 bytes thanks to @dingledooper. Thanks to everyone else for their own golf suggestions.
Instead of tearing down the banknotes in the top-down way, this solution builds up the answer from the bottom. Since the number of banknotes needed to pay \$10n\$ is exactly the same as that for \$n\$, we can tear down the banknotes from the one's digit in the following sense:

If the one's digit is 0, remove the 0 and recurse.

Otherwise, consider two ways to fulfill the one's digit:

Alice pays n%10 to Bob, and then Alice pays whatever banknotes are needed to pay floor(n/10) * 10. Recurse with floor(n/10).
Bob pays 10-n%10 to Alice, and then Alice pays whatever banknotes are needed to pay ceil(n/10) * 10. Recurse with ceil(n/10).

Then we can evaluate the two cases and take their minimum.

In the code, an infinite recursion happens if we don't special-case x=1 as well as x=0, because the ceiling of 1/10 is still 1.


05AB1E,  27 26  24 bytes

Saved 1 byte thanks to @KevinCruijssen
Saved 2 bytes thanks to @Grimmy

Note: This code was based on my understanding that only the capitalization of the first letter was customizable. It has since been clarified that it applies to all letters, leading to this significantly shorter answer by Grimmy.

Expects mEpBPhHond for the capitalization of the first letter.

ćC•>·¿*•s÷θD>,₂I3(èH÷+·,

Try it online!

How?

We define the following magic constant:

$$M=1902159854$$

The number of carbon atoms is given by:

$$c=\left(\left\lfloor\frac{M}{n}\right\rfloor\bmod 10\right)+1$$

where \$n\$ is the first character of the input turned into an 05AB1E code point (0-9, A-Z, a-z, ...).

 input |  n  | floor(M/n) | mod 10
-------+-----+------------+--------
 meth- |  48 |   39628330 |   0
 Eth-  |  14 |  135868561 |   1
 prop- |  51 |   37297252 |   2
 But-  |  11 |  172923623 |   3
 Pent- |  25 |   76086394 |   4
 hex-  |  43 |   44236275 |   5
 Hept- |  17 |  111891756 |   6
 oct-  |  50 |   38043197 |   7
 non-  |  49 |   38819588 |   8
 dec-  |  39 |   48773329 |   9

Commented

                         # example input: 'Heptyne'
ć                        # extract the first character -> 'H'
 C                       # turn it into an integer -> 17
  •>·¿*•                 # push the magic constant 1902159854
        s÷               # swap + integer division -> 1902159854 / 17 = 111891756
          θ              # keep the last digit (therefore a modulo 10) -> 6
           D>            # duplicate and increment the copy
             ,           # print the number of carbon atoms
              ₂          # push 26
               I         # push the input string
                3(è      # extract the 3rd to last character -> 'y'
                   H     # parse it as base-36 -> 34
                    ÷    # integer division -> 26 / 34 = 0
                     +   # add to the number of carbon atoms - 1 -> 6
                      ·  # double
                       , # print the number of hydrogen atoms


Recover polynomial \$f(x)\$ from \$f^2(x)\$

Python 2, 638 634 608 603 572 560 508 470 bytes (without brute force as well)
Tthanks to @randomdude999 for the golfing down the code by like 100 bytes as well as everyone who has helped point out smaller golfing tricks!

from gmpy2 import*
R=range
r=reduce
p=lambda n,i=1:n/i and[l+[i]for l in p(n-i,i)]+p(n,i+1)or[[]][n:]
e=lambda f,x:r(lambda y,z:y*x+z,f)
def s(g):
 n=isqrt(len(g));N=n+1;t,_=iroot(abs(g[0]),N)
 for F in(t,-t):
	f=[F]
	for i in R(1,N):f+=[0];f[i]=(g[i]-sum(fac(n)/fac(n-len(j))/r(mul,[fac(j.count(k))for k in R(i+1)])*r(mul,[f[k]for k in j])*F**(N-len(j))for j in p(i))-(i==n)*f[1]*F**~-n)/n/F**n
	if n<2:f[1]=g[1]/-~F
	if all(e(f,e(f,i))==e(g,i)for i in R(N*N)):return f

Try it online!
Explanation
In the code, the functions

m computes the multinomial coefficient \$\binom{n}{k_0,k_1,\dots,n-\sum k}\$
p list out all partitions of n (code from https://codegolf.stackexchange.com/a/84192/61039 (without this code was 601 bytes))
e evaluates our polynoimal
s does the actual functional square root

The way it works is by computing the coefficients of \$f\$ (of degree \$n\$) using the \$n+1\$th highest coefficients of \$f\circ f\$, then checks if the computation is correct as multiple polynomials can lead to the same highest coefficients. The way the computation works is by considering the following series of manipulations:
\begin{align*}
f(x)&=\sum_{i=0}^na_ix^i\\
f(f(x))&=\sum_{i=0}^na_i\left(\sum_{j=0}^na_jx^j\right)^i\\
&=\sum_{i=0}^na_i\sum_{k_0+k_1+\dots+k_n=i}\binom{i}{k_0,k_1,\dots,k_n}\prod_{j=0}^n a_j^{k_j}x^{jk_j}\\
&=\sum_{i=0}^na_i\sum_{k_0+k_1+\dots+k_n=i}\binom{i}{k_0,k_1,\dots,k_n}\left(\prod_{j=0}^na_j^{k_j}\right)x^{\sum_{j=0}^njk_j}\\
&=\sum_{k_0+k_1+\dots+k_n\leq n}a_{k_0+k_1+\dots+k_n}\binom{k_0+k_1+\dots+k_n}{k_0,k_1,\dots,k_n}\left(\prod_{j=0}^na_j^{k_j}\right)x^{\sum_{j=0}^njk_j}\\
&=\sum_{i=0}^{n^2}\left(\sum_{\sum_{j=0}^njk_j=i,k_i\geq0}a_{k_0+k_1+\dots+k_n}\binom{k_0+k_1+\dots+k_n}{k_0,k_1,\dots,k_n}\left(\prod_{j=0}^na_j^{k_j}\right)\right)x^i\\
\end{align*}
From here, if \$i>n^2-n\$, then \$k_1+\dots+k_n=n\$, forcing \$k_0=0\$ since \$a_{>n}=0\$. Furthermore,
$$\sum_{j=0}^njk_j=n\sum_{j=0}^nk_j-\sum_{j=0}^njk_{n-j}=n^2-\sum_{j=0}^njk_{n-j}$$
so the coefficient of \$x^{n^2-i}\$ for \$i<n\$ simplifies to
\begin{align*}
&\hphantom{=}a_n\sum_{\substack{\sum_{j=1}^njk_j=n^2-i\\k_0=0\\k_i\geq0}}\binom{n}{k_0,k_1,\dots,k_n}\left(\prod_{j=0}^na_j^{k_j}\right)\\
&=a_n\sum_{\substack{\sum_{j=0}^njk_{n-j}=i\\\sum_{j=0}^nk_j=n\\k_i\geq0}}\binom{n}{k_0,k_1,\dots,k_n}\left(\prod_{j=0}^na_j^{k_j}\right)\\
&=a_n\sum_{\substack{\sum_{j=0}^njk_j=i\\k_0=n-\sum_{j=1}^nk_j\\k_i\geq0}}\binom{n}{k_0,k_1,\dots,k_n}\left(\prod_{j=0}^na_{n-j}^{k_j}\right)
\end{align*}
and the \$\sum_{j=1}^njk_j=i\$ is really asking for partitions of \$i\$.
To extend this analysis to \$i=n\$ to get \$a_0\$, we simply notice that we need to include the case that \$1(n-1)+(n-1)n=n^2\$, i.e. we simply add \$a_0^{n-1}a_1\$.
The reason why this helps is this expansion gives us

\$x^{n^2}\$ coefficient of \$f\circ f\$ is \$a_n^{n+1}\$
\$x^{n^2-i}\$ coefficient is linear in \$a_i\$ for \$0<i<n\$ as the only term containing \$a_i\$ is \$na_0^na_i\$

As all terms in the coefficient of \$x^{n^2-i}\$ in \$f\circ f\$ only depends on \$a_{<i}\$ other than \$na_0^na_i\$, we can easily compute \$a_i\$. The only issue is when \$n\$ is odd, which gives us \$2\$ solutions for \$a_n\$.


Retina, 112 109 99 94 91 bytes

^
.
+r`(?<!^\1+). (.+)
$'$0
.(?=.* (.+) (.+))(?=\1* |\2* )
o
o(\.*)o((\1\.*o)*) .*
O$1O$2

Not very competitive, I think, but number theory in Retina is always quite fun. :)

Takes input as unary numbers using . as the unary digit.

Try it online.

Explanation

^
.

This inserts a . and a space in front of the input. This will ultimately become the output.

+r`(?<!^\1+). (.+)
$'$0

This prepends the LCM of a and b to the string. Since we already have a . there, we'll end up with lcm(a,b)+1. This is accomplished by repeatedly prepending b as long as a does not divide this new prefix. We capture a into a group one and then check if we can reach the beginning of the string by matching that capture at least once. b is then inserted into the string via the rarely used $' which inserts everything after the match into the substitution.

.(?=.* (.+) (.+))(?=\1* |\2* )
o

This one matches characters at positions which are divided by a or b. It makes use of the fact that the result is symmetric: since lcm(a,b) is divided by both a and b going left by subtracting instances of a or b yields the same pattern as going right from 0 by adding them. The first lookahead simply captures a and b. The second lookahead checks that there is a multiple of each a or b characters before the first space.

o(\.*)o((\1\.*o)*) .*
O$1O$2

As stated on Wikipedia, in addition to Bézout's identity it is also true that

  The greatest common divisor d is the smallest positive integer that can be written as ax + by.

This implies that the GCD will correspond to the shortest gap between two os in the output. So we don't have to bother finding the GCD at all. Instead we just look for first instance of the shortest gap. o(\.*)o matches a candidate gap and captures its width into group 1. Then we try to reach the first space by alternating between a backreference to group 1 and os (with optional additional .s). If there is a shorter gap further to the right, this will fail to match, because we cannot get past that gap with the backreference. As soon as all further gaps are at least as wide as the current one, this matches. We capture the end of the LCM-string into group 2 and match the remainder of the string with .*. We write back the uppercase Os (with the gap in between) as well as the remainder of the LCM string, but discard everything starting from the space, to remove a and b from final result.


Haskell, 100 bytes, cracked by nimi

main=interact$iddoidlinesidwordsdoidoidoid=doiddoid<-dooiidoid<-dooiddoiddodoid

This is a full program and a dadaistic poem.

Code with withspace (Try it online!)
main=interact$id doid lines id words
doid oi d o id=do
 iddoid<-do oi id
 oid<-do o iddoid
 do d oid

Still looking quite poetic, if you ask me.
De-obfuscated
main = interact f
f s = do
 l <- lines s
 w <- words l
 id w

Explanation
The do-notation is only syntactic sugar, so f can equivalently be written as
f s = lines s >>= words >>= id

For lists the >>=-operator is defined as concatMap, so f becomes
f = concat . map id . concat . map words . lines

So given an input "a b\nc", lines splits the input at newlines ["a b","c"], words splits each line at white space yielding [["a","b"],["c"]] (as I realised only now this includes newlines, so lines actually isn't needed). Concatenating once gives ["a","b","c"], id is the identity function and as such has no effect and the final concatenation yields the string "abc".


APL (Dyalog), 75 73 72 bytes

Prompts for T, R, and F in that order. R must b given in Dyalog transformation format and F must be given in PCRE format.

⍞⎕R(⍞∘{(⊣⌿d)l¨⍨(1∘⌷≠(⊢⌿d∊⎕A,l⎕A)∧≠⌿)d≠(l←819⌶)d←↑⍺⍵.Match↑¨⍨≢⍺})⍠1⊢⍞

Try it online!

⍞ prompt for T

⊢ yield that (separates 1 and T)

⍞⎕R(…)⍠1 prompt for F and Replace matches with the result of the following function:

 ⍞∘{…} derive a monadic function by tying the prompted-for R as left argument to:

  ≢⍺ count the number of letters in R

  ⍺⍵.Match↑¨⍨ take that many letters from each of R and the match
   ⍺ is the left argument, which we tied R as.
   ⍵ is a namespace in which Match contains the currently found string.

  ↑ mix those two into a two-row matrix

  d← store as d

  (…)  apply the following tacit function to that:

   819⌶ lowercase (mnemonic: 819 looks like Big)

   l← store that function as as l

  d≠ Boolean where d differs (i.e. gives 0/1 for each lowercase/uppercase letter)

  (…) apply the following tacit function to that:

   ≠⌿ vertical XOR

   (…)∧ Boolean AND with the following array:

    l⎕A lowercased Alphabet

    ⎕A, prepend uppercase Alphabet

    d∊ Boolean for each letter in d whether a member of that (i.e. whether a letter)

    ⊢⌿ last row i.e. for character of the match whether it is a letter

   1∘⌷≠ XOR with the first row, i.e. whether each character of R is uppercase

  (…)l¨⍨ use that to lowercase (if 0) or uppercase (if 1) each letter of:

   ⊣⌿ the first row, i.e. R

* Byte count for Dyalog Classic using ⎕OPT  instead of ⍠.


Read n random lines from a potentially huge file

Ruby, 104 94 92 90 bytes
File name and number of lines are passed into the command line. For example, if the program is shuffle.rb and the file name is a.txt, run ruby shuffle.rb a.txt 3 for three random lines.
-4 bytes from discovering the open syntax in Ruby instead of File.new
f=open$*[0]
puts [*0..f.size/n=f.gets.size+1].sample($*[1].to_i).map{|e|f.seek n*e;f.gets}

Also, here's a 85-byte anonymous function solution that takes a string and a number as its arguments.
->f,l{f=open f;puts [*0..f.size/n=f.gets.size+1].sample(l).map{|e|f.seek n*e;f.gets}}


"Sorry, young man, but it's Turtles all the way down!"

Mathematica 200 198 188 171 168

Spaces added for clarity:

f[i_, b_, h_, j_, r_, n_] :=
 (a = h; p = j; s = k = {}; t = Flatten;
  (Switch[#,
      6, s = {a, p, s},
      8, {a, p, s} = s,
      _C, k = {k, Line@{p, p += {Cos@a, Sin@a}}}];
     If[# < 9, a += I^# b ]) & /@ t@Nest[# /. r &, i, n];
  Graphics@t@k)

Where:

  i : Initial state;
  b : rotation angle
  h : initial angle
  j : initial position
  r : production rules
  n : iterations

Production rules grammar:

  2 = Turn Left (-);
  4 = Turn Right (+);
  6 = Push and Turn Left  ("[");
  8 = Pop  and Turn Right ("]");
  C[i] = Draw (Any number of symbols)
  Any other symbol = Do Nothing, just use it in producing next state (Any number of symbols)

The {2,4,6,8} sequence is there because I'm using I^n (I = imaginary unit) to make turns.

Examples:

f[{C[1], X}, Pi/2, 0, {0, 0}, {X -> {X, 4, Y, C[1]}, Y -> {C[1], X, 2, Y}}, 10]

f[{C@1}, Pi/2, 0, {0,0}, {C@1->{C@1, 2, C@1, 4, C@1, 4, C@1, 2, C@1}}, 6]

f[{C[1]}, Pi/4, Pi/2, {0, 0}, {C[2] -> {C[2], C[2]}, C[1] -> {C[2], 6, C[1], 8, C[1]}}, 10]

f[{C[1]}, Pi/3, 0, {0, 0}, {C@1 -> {C@2, 4, C@1, 4, C@2}, C@2 -> {C@1, 2, C@2, 2, C@1}}, 10]

f[{X},5/36 Pi, Pi/3, {0,0},{X->{C@1, 4, 6, 6, X, 8, 2, X, 8, 2, C@1, 6, 2, C@1, X, 8, 4, X},
                            C@1->{C@1, C@1}}, 6]


Decompose a number with bit-xor without the digits 0, 3, 7

Common Lisp, 240 224 183 173 169 bytes

Common Lisp is a bit verbose for golfing. However, this decomposes 100-digit numbers in under a second, and 200-digit integers in less than ten seconds, so no need for penalties. The algorithm is deterministic.

(defun s(z)(and #1=(some(lambda(q)(position q(format()"~a"z)))"037")(+ z(floor z(expt 10 #1#)))))
(defun d(x)(do((y x(or(s y)(s #3=(logxor x y))(return`(,y,#3#)))))(())))

The line feed between the functions is for typographic purposes only. Test run with the 100-digit reference input:

(time (d 5296080632396965608312971217160142474083606142654386510789497504098664630388377556711796340247136376))
took 677,000 microseconds (0.677000 seconds) to run.
      20,989 microseconds (0.020989 seconds, 3.10%) of which was spent in GC.
During that period, and with 8 available CPU cores,
     671,875 microseconds (0.671875 seconds) were spent in user mode
           0 microseconds (0.000000 seconds) were spent in system mode
 54,221,104 bytes of memory allocated.
(1864921261592819619661568919418981552559955289196969112566252282429216186594265918444566258544614425
 5891958562486995519825158818455999516899524658151445485616155916296966645869599949958954491929662561)

As a bonus, I'm including a version of the code that incrementally builds the solution top-down. It can manage a 1000-digit number in less than ten seconds, but cannot compete in golf due to the additional code.

(defun decompose (x)
  (flet ((s (z)
           (mapcan #'(lambda (c) (and #1=(position c #2=(format () "~a" z))
                                 (list (- (length #2#) #1# 1))))
                   '(#\0 #\3 #\7))))
    (do ((y x (let ((p (nconc (s y) (s #3=(logxor x y)))))
                (or p (return`(,y,#3#)))
                (+ y (expt 10 (apply #'max p))))))
        (nil))))

* (time (decompose (parse-integer (make-string 1000 :initial-element #\7))))
took 9,226,000 microseconds (9.226000 seconds) to run.
        90,966 microseconds (0.090966 seconds, 0.99%) of which was spent in GC.
During that period, and with 8 available CPU cores,
     9,234,375 microseconds (9.234375 seconds) were spent in user mode
             0 microseconds (0.000000 seconds) were spent in system mode
 487,434,560 bytes of memory allocated.
(8889898889152488921298888992819221914229899249999918899888899888888889999989141219898898888988988898888888888899142442899924898918898898988988895189988898888924192198992454114198911989191888889898888918888988988998888891421118891899122898888998989898888898988898888999988918888898889189918889888888899888989219188898998888988892119889198888988888894888912188898989952999888888888898899998988898889228918998949999998898898991141888898999988912121292118899889998989899999892889941898888911888898889118998898888911889889888891452888998889288921141888888942189888899988891918889118888888888989892198899199914111188988889421111188889118888918989988912989999998989891119888898888888892621229888988888999619888952462219889189899998899888889989898891118989218888888898962988891188899888888888999888888888888888888888891269188921288888888998898899214191188888888898992188998898889919888889989889899988892115549998888898889218899988998911898989199918898918988898888891889888989119899888889888998918889112189998
 4184469818464841952189561886965821566229261221619858498284264289194458622668559698924621446851546256444641488616184155821914881485164244662156846141894655485889656891849662551896595944656451462198891289692696856414192264846811616261884188919426294584158925218559295881946496911489245664261126565546419851585441144861859822815144162828551969425529258169849412525611662488849586554989254181228254465226521648916188265491499166186964881248156451994924294646681548996645996894665198811511522424996844864211629888924642289925565591484541149414914699289441561496451494562955652129199261462268846144518142486845251946444998812988291119592418684842524648484689261441456645518518812265495165189812912919529151991611962525419626921619824496626511954895189658691229655648659252448158451924925658586522262194585891859285841914968868466462442488528641466655911199816288496111884591648442984864269495264612518852292965985888414945855422266658614684922884216851481646226111486498155591649619266595911992489425412191)
* (apply #'logxor *)
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777


How many decimals are there before I'd need to add 1 when rounding?

CJam, 17 bytes

rie40mQsJ~>'4f>1#

Try it online.


R, 20 bytes

Is this what you are after?  Uses table to count the occurrences of each of the scan input values.  Tests if count is > 1 and sums the trues.

sum(table(scan())>1)

Try it online!


Logo, 129 87 bytes

Graphical solution, implemented as function

This was built on Calormen.com's Logo interpreter.  The S function takes the number of characters as a parameter and draws them in a spiral.  The T function outputs letters upright to prevent them from rotating with the spiral..  I decided that it looked nicer (and golfed out 42 bytes) to omit correcting the letter orientation.  I also tightened up the spacing which did not change the byte count.  If you were to actually roll up an alphabet, it would look more like this anyway.

Updated Version (letters roll)

TO S:r
PU IF:r[REPEAT:r[LABEL CHAR((REPCOUNT-1)%26)+65
RT 99/SQRT(REPCOUNT)FD 12]]END

Invocation

Invoke as follows: S iterations

Sample output

S 1000

Old Version (letters always upright)

TO T:l:h
RT:h
LABEL CHAR(:l%26)+65
LT:h
END
TO S:r
PU IF:r[REPEAT:r[T REPCOUNT-1 90-HEADING
RT 95/SQRT(REPCOUNT)FD 15]]END

Old output removed to save space.  See it here.


JavaScript (ES6), 209 bytes
Does work, but will most likely hit the StackExchange API limit very quickly. It will probably take a while to output the link, as it's checking randomly for a valid question.
_=>fetch(`//api.stackexchange.com/2.2/questions/${new Date%2e4}?site=codegolf`).then(_=>_.json()).then((a,b=a.items)=>{if(!b.length||b[0].tags.includes`tips`||b[0].closed_date)f();else console.log(b[0].link)})

f=_=>fetch(`//api.stackexchange.com/2.2/questions/${new Date%2e4}?site=codegolf`).then(_=>_.json()).then((a,b=a.items)=>{if(!b.length||b[0].tags.includes`tips`||b[0].closed_date)f();else console.log(b[0].link)})

f();


05AB1E, 11 10 9 bytes

-1 byte thanks to Emigna
-1 byte thanks to Adnan

µN>Ð<‚ÒOË

Explanation:

µ            While the counter variable (which starts at 0) is not equal to the input:
 N>          Store the current iteration index + 1, and then create an array with
   Ð<‚       [current iteration index + 1, current iteration index]
      ÒO     Get the sum of the prime factors of each element
        Ë    If all elements in the array are equal,
             implicitly increment the counter variable

1-indexed.

Try it online!


Wolfram Language (Mathematica), 52 bytes

#//.x_:>N@{M@x,E^M@Log@x,1/M[1/x],M[x^2]^.5}&
M=Mean

Try it online!

In my first approach I used these builtins
Mean GeometricMean  HarmonicMean and RootMeanSquare

Here are some substitutions for saving bytes

HarmonicMean -->  1/Mean[1/x]  by @Robin Ryder (3 bytes saved)
GeometricMean --> E^Mean@Log@x by @A. Rex (2 bytes saved)
RootMeanSquare --> Mean[x^2]^.5 by @A. Rex (4 bytes saved)

finally we can assign Mean to M (as proposed by @ovs) and save 5 more bytes


Python, 52
Input is a set. Output is a list of lists.
f=lambda a:[p+[x]for x in a for p in f(a-{x})]or[[]]

This is shorter than the answer that does all the work with a builtin.


JavaScript (ES6), 149 144 bytes

s=>`    o O Oa   ___
   o     a  | $& |
  TS__[O]a  |___|
 {======|a_|"""""|
./o--000'a"\`-0-0-'`.replace(/a(.*)/g,(_,c)=>s.replace(/./g,c))

I don't think the engine itself can be compressed, but perhaps it's possible.

Test snippet

let f =

s=>`    o O Oa   ___
   o     a  | $& |
  TS__[O]a  |___|
 {======|a_|"""""|
./o--000'a"\`-0-0-'`.replace(/a(.*)/g,(_,c)=>s.replace(/./g,c))

O.innerHTML = f("CODE GOLF")
<input value="CODE GOLF" oninput="O.innerHTML=f(this.value.replace(/\n/g,'&lt;br&gt;'))">


Jelly, 8 bytes

ṣ0¬¬M¦j0

Try it online! or verify all test cases.

How it works

ṣ0¬¬M¦j0  Main link. Argument: A (list of Booleans)

ṣ0        Split at zeroes. This leaves a 2D list of ones.
  ¬       Negate each 1, replacing it with 0.
     ¦    Conditional application:
    M       Yield all maximal indices.
            In lexicographical list comparison, a shorter list of zeroes is less
            than a longer one, so this identifies the longest runs.
   ¬        Negate the items in those lists, changing zeroes back to ones.
      j0  Join, separating by single zeroes.


Recreate the ASCII-table as an ASCII-table

Python 2 3.6, 185 183 175 159 156 bytes

Saved 8 bytes thanks to FlipTack!

Still quite new to golfing in Python.

for a in["Dec  Chr   | "*3,"-"*39]+["".join(f"{l:<5}{('Space',chr(l),'DEL')[(l>32)+(l>126)]:<6}| "for l in(i,32+i,64+i))for i in range(32,64)]:print(a[:-5])

Uses a nested list comprehension to generate the table body.

Ungolfed:

lines =   \
  ["Dec  Chr   | "*3, "-"*39] +                      # first two lines
    ["".join(                                        # join 3 parts of each line
      f"{l:<5}{('Space',chr(l),'DEL')[(l>32)+(l>126)]:<6}| "
        for l in (i,32+i,64+i)                       # generate 3 parts of a line
      )
      for i in range(32,64)]

for line in lines: print line[:-5]

Update: apparently using f-string here is shorter than the % operator.

Old attempt, 185 183 175 bytes

print("Dec  Chr   | "*3)[:-5]+"\n"+"-"*34
a=lambda x:('Space',chr(x),'DEL')[(x>32)+(x>126)]
for l in range(32,64):print("%-5d%-6s| "*3%(l,a(l),l+32,a(l+32),l+64,a(l+64)))[:-5]

Ungolfed:

print ("Dec  Chr   | "*3)[:-5] + "\n" + "-"*34
def a(x):
    return "Space" if x==32 else "DEL" if x==127 else chr(x)
for line in range(32,64):
    print ("%-5d%-6s| "*3 % (line, a(line), line+32, a(line+32),
      line+64, a(line+64))) [:-5]


Combinations of stepwise increasing integers

Ruby, 65 55 bytes

->n{(0..2**~-n-2).map{|x|w=1;(1..n).map{|d|w+=x[n-d]}}}

Try it online!
How:
Partial sum of bits (starting with 1) of all numbers up to 2n-1-2
For example: if the number is 111010011 it becomes:
  1 1 1 0 1 0 0 1 1
  | | |   |     | |
  v v v   v     v v
 +1+1+1  +1    +1+1
  -----------------
1 2 3 4 4 5 5 5 6 7
|
Initialized to 1


JavaScript (ES7), score 17, 176 bytes

They said it couldn't be done, so I did it :D (thanks to a lot of help from @FullDecent)

""**""
~(~/~//~/~/)/~/~/
3
4
!NaN- -!NaN- -!NaN- -!NaN- -!NaN
6
7
8
9
++[[]][+[]]+[+[]]
11
'lengthlength'.length
222>>2>>2
`${``^``}xE`^``
0XF
C=CSS==CSS;C<<C<<C<<C<<C
555555555555555555555%55

Unused characters:

#&,:?@ABDGHIJKLMOPQRTUVWYZ\_bcdfijkmopqrsuvwyz|

I don't think 18 is possible, but I said the same thing about 17...

Explanation

JavaScript is a very weakly typed language; if you try to perform a mathematical operation on a non-number value, JS will try its hardest to convert it to a number first. This allows for a lot of interesting solutions. I've tried to avoid using the digits as much as possible so they can be used later on.

** is the exponentiation operator in ES7. The empty string when coerced to a number becomes 0, so this calculates 0 ** 0, which is 1 according to JavaScript.
A little ridiculous, but it works. /~/ is a regex literal, and ~/~/ returns -1, so this is ~(-1 / -1) / -1 = ~(1) / -1 = -2 / -1 = 2. (credits to @GOTO0 for the idea)
Simply 3.
Now simply 4.
NaN is falsy, so !NaN is true, which is equivalent to 1. The expression thus becomes 1 - -1 - -1 - -1 - -1 = 1 + 1 + 1 + 1 + 1 = 5.
Simply 6.
Simply 7.
Simply 8.
Simply 9.
This uses a little JSF*** magic. +[] is 0, so [[]][+[]] returns the first element of [[]] (that is, []), and ++ increments this to 1. Then +[+[]] adds the array [0], which is coerced to a string and makes "10".
Simply 11. I originally had used 11&1111 for 3 and 33/3 for 11 until I realized yet again just how dumb I am...
This strategy would work on any number: create a string of length 12 and use .length.
I just messed around with 2s and >s for a while to get this one. I got lucky again: 222 >> 2 is 55, and 55 >> 2 is 13.
This one is rather tricky. The basic idea is to create 14 in hex (0xE), but we need the digit 0 elsewhere. So instead we prepend the result of ``^`` to the string xE; the empty string coerced to a number is 0, so this returns 0 ^ 0 = 0. Then the result is XORed with the empty string, which converts both values to numbers; "0xE" ^ "" is 14.
This is now pretty easy: 0XF is a hexadecimal literal with a value of 15.
The trickiest of all? First we set the variable C to CSS == CSS (that is, true). Then we take the result and perform << C four times, which basically multiplies 1 by 2 ** 4.
JavaScript starts to lose integer precision at 253, which allows 555...555%55 to return a number that's not 0 or 5. I happened to get very lucky while playing around here.

Strategies that would work on many numbers:

-!NaN would work on any number (currently 5), though it gets large very fast.
~/~/ would work on any number (currently 2), though it gets very large very fast.
+[] would work on any number (currently 10), though it's by far easiest on 10 or 11.
.length would work on any number.
`${-``}xE`-`` would work on pretty much any number if you do it right.
C<<C would work on any power of two (currently 16), or any int at all if you included |.


If a program terminates and there is no one to see it, does it halt?

JavaScript, 39

(function f(x){for(;x!=++x;)f(x+1)})(0)

Explanation

Since JavaScript does not precisely represent large integers, the loop for(;x!=++x;) terminates once x hits 9007199254740992.

The body of the for loop will be executed Fib(9007199254740992) - 1 times, where Fib(n) is the nth fibonacci number.

From testing, I know my computer will do less than 150,000 iterations per second. In reality, it would run much slower because the stack would grow very large.

Thus, the program will take at least (Fib(9007199254740992) - 1) / 150000 seconds to run. I have not been able to calculate Fib(9007199254740992) because it is so large, but I know that it is much larger than 101000 * 150,000.

EDIT: As noted in the comments, Fib(9007199254740992) is approximately 4.4092*101882393317509686, which is indeed large enough.


vi, 118 115

Y2PA,<ESC>Ypj~Y2PIbo-b<c-o>wBanana-fana fo-f<c-o>wFee-fi-mo-m<c-o>2$!<ESC>HJJ:%s/\vo-(([bfm])\2([^aeiou]*))?([bfm]?)[^aeiou]*/o-\3\4
ZZ

The code includes 5 control characters, which I've put in brackets. Each only counts as a single character towards the character count.

EDIT: Moving the first join (J) to later and changing the paste-before (P) to a paste-after (p) saved me 1 character. Also, not capturing the o- in the regex saved me 2 more characters.


Charcoal, 73 bytes

θ§⪪”%↖↙1¬¢/vy⁵⸿ψＪPP±≔Ｓ×5Jρνξ–Ｇu ◧；Yx³F▶ψ;εB↥:P¹N﹪J$α✂χ✳⦄⟲*±¶Sp:ς↘Ｖ◧◧”x℅θ

Try it online! I/O is in lower case. Based on this verbose version. Explanation:

                Implicitly print:
θ               Input character
                Implicitly print:
   ”...”        Long compressed string "oneycombx...xingerbread"
  ⪪            Split on
        x       The string "x"
 §              Circularly indexed by
          ℅     Character code of
           θ    Input character


Output: Calendar Month (without native calendar generating functions)

Ruby, 170 168 characters
g=gets.to_i
require'date'
d=Date.new g/100,g%100
puts'Mo Tu We Th Fr Sa Su'
l=['']*(d.jd%7)+[*1..(d>>1).jd-d.jd]
56.times{|i|$><<"#{l[i].to_s.rjust 2} #{?\n if i%7>5}"}

Bugfix: didn't require the neccessary library (+16)
used julian date modulo 7 instead of current week day directly (-3)
used /100 and %100 to parse date instead of regex (-13). Taken from LegoStormtroopr's answer.
removed the parentheses around the argument to rjust and Date.new(-2)