JavaScript (ES6), 347 336 326 325 308 bytes

for(a=btoa`...`.split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Before running, replace the ... with the result of running this code:

atob("zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh")

Or you could just use the uncompressed version:

for(a="zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh".split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Still probably not optimal. 11 bytes saved in part by @Titus.


Pyth, 28 22
L.AmqdSdmfhTmxhkbek^b2

Creates a function y that you can call with a tuple containing the two arrays. Returns "True" if a total ordering exists, "False" if not.
A helper program that defines and calls the above function with stdin:
L.AmqdSdmfhTmxhkbek^b2y,rw7rw7

Try it here.
We first read both arrays. Then we will create all combinations of both arrays. Then for each combination we will assume the first array is authoritative, and check if it's consistent with the second array.


Computing a specific coefficient in a quotient of polynomials

MATL, 6 bytes

Y-PiQ)

The inputs contain the coefficients in order of decreasing powers.

Try it online! Or verify all test cases

Explanation

  (De)convolution is the key to success

     % Implicit inputs: two numerical vectors
Y-   % Deconvolution
P    % Flip
i    % Input: integer
Q    % Add 1
)    % Get the entry at that position
     % Implicit display


Code Golf: 6174 - Kaprekar's mythical constant

Ruby 1.9, 122 characters
puts"Iterations: #{(1..7).find{s=$_.chars.sort*"";puts [r=s.reverse,?-,s,?=,$_="%04d"%(r.to_i-s.to_i)]*" ";~/6174/}}."

Example invocation:
$ echo 1211 | ruby -ln kaprekar.rb

I've counted the -ln flag as 4 characters (difference between the normal invocation ruby kaprekar.rb and ruby -ln kaprekar.rb).


05AB1E/GolfScript/Jelly 11 6 bytes / 3 languages = 2

"'İ*@'

Both 05AB1E and GolfScript have the nice property that they do implicit prints of strings, so we only lose 3 bytes on them (because 05AB1E doesn't need the closing quote).

Also, my first 05AB1E, GolfScript, and Jelly programs.


Blindfolded Arithmetic

Possibly a fairly easy language to start off with, relatively
speaking.  (There are limits on how difficult a language I can make
because I have to prove it Turing-complete myself!)

For this language, the program set is the set of Blindfolded
Arithmetic programs as given in the section "program" below, the input
set is the set of positive integers, and the output set is the set of
integers (the entire set, not just the positive integers).

This language is fairly interesting – maybe even practically useful –
because it has a more or less total lack of control flow, being
entirely based on computations on numbers you can't see.  That makes
it potentially useful as a language for implementing programs inside
homomorphic encryption
systems.

Specification

Blindfolded Arithmetic is an esoteric programming language with the
following specifications:

Data storage

A state of a running Blindfolded Arithmetic program consists of six
variables, each of which can store an integer.  (There are no limits
on how large or small these integers can get; in particular, they can
go negative.)  The variables are called a, b, c, d, e, and
i.

At the start of the program, a to e inclusive are each initialised
to 0, and i is initialised to a positive integer taken from user
input.  (If no input is available, i is initialised to 1.)

If the program ceases execution (this can only occur due to division
by zero), the value of i immediately before the division was
attempted is used as the program's output.

Program

A Blindfolded Arithmetic program is a list of commands, each of which
has one of the following forms (where v can be replaced by any
variable name, potentially a different name each time it's used):

v = v + v
v = v - v
v = v * v
v = v / v

Note that each operand of the commands must be a variable; this
language does not allow the use of literal integers.

Execution of the program is performed by running each of the commands
in sequence, and then looping back to the start and continuing to run
the commands in sequence again, ad infinitum (or until there's an
attempt to divide by zero, which ends the program).

Each command has the same semantics as you'd expect from the notation,
which is no different from that used by most practical programming
languages: the values of the second and third variables metioned in
the command are taken, an arithmetic operation
(add/subtract/multiply/divide respectively for the four forms of
command) is applied to them, and the resulting value stored into the
first variable.  Division here is integer division, rounding
towards 0.

There is no control flow of any kind, other than program exit; the
commands always cycle in sequence, up until a division by zero (if
any) occurs and ends the program.  In particular, there's no way to
directly read variables, only to use them as a source of calculations
whose results impact the values assigned to other variables.


Canvas, 10 bytes

⇵-×<ｎ¹［↔｝］

Try it here!


R (24 characters)
length(sequence(scan()))

What this does:

scan reads input from STDIN (or a file)
sequence generates integer sequences starting from 1 and concatenates the sequences.  For example, sequence(c(2, 3)) results in the vector 1 2 1 2 3
length calculates the number of elements in the concatenated vector

Example 1:
> length(sequence(scan()))
1: 123
2: 468
3:
Read 2 items
[1] 591

Example 2:
> length(sequence(scan()))
1: 702
2: 720
3:
Read 2 items
[1] 1422


C#, 496 452 bytes

Edit: found a bug with bounds checking... but also striped a load of bytes having been forced to understand my own code. Unrolling the local function helped a bit, and removed the C# 7 specific code. This question has been a lot of fun.

using C=System.Console;class P{static void Main(){string D="",L;int W=0,H=0,z=0,d,q,c,j,b;for(;(L=C.ReadLine())!=null;H+=W=L.Length)D+=L;var B=new int[H];for(d=W;(d=-d)>0||++z<H*H;)for(c=1,q=z%H;c<=z/H&q%W+c<W&q>=d&q<H+d&&D[q]==(d>0?92:47)&D[j=q+c]==(d<0?92:47);q-=d+1,c+=2){for(b=0;j>q;)b+=D[--j-d]==45?2:0;for(char h='-',e;c==z/H&b>c;C.WriteLine(h+" "+c/2))for(b=c++;b>1;j=q+=d+1,b-=2)for(;j<q+b;)B[j]=h=B[j]<1&h==45&(e=D[j++])!=47&e!=92&e>32?e:h;}}}

Try it Online

Complete program, expects space-padded input to standard in, outputs to standard out. The output is one entry per line, with trailing line feed. Cookies are outputted in increasing size order, upper-left most first. It took me a good while to understand the rules, but I think it passes all the examples provided.

It works by repeatedly searching the entire grid for valid Hamantaschen, incrementing the 'allowed' size. For each cell, it checks up and down, following the \ and / on either side as far as it can. If it notices that the next row has lots of -, and the current size is the 'allowed' size, then it determines the filling and prints out the entry.

The filling is found by exploring the entire space of the cookie, looking for an 'unused' cell. When an unused cell is found, it is marked as used (since we increase the allowed size, we know we are the smallest cookie that contains it), and we record the filling.

Formatted and commented code:

using C=System.Console;

class P
{
    static void Main()
    {
        //   32
        // - 45
        // / 47
        // \ 92
        // range 32..127 (no mod for you)

        string D="", // the whole map
            L; // initally each line of the map, later each line of output

        int W=0, // width
            H=0, // length (width * height)
            z=0, // search tracker
            d, // check direction (this is backwards (1 byte saving!))
            q, // check tracker
            c, // counter (truely, this is the distance from the right to the left)
            //M, // c max (now inlined as z/H)
            j, // horiontal tracker
            b; // - count, and reverse counter

        // read map and width
        for(;(L=C.ReadLine())!=null; // read a line, while we can
                H+=W=L.Length) // record the width, and increment height
            D+=L; // add the line to the map

        var B=new int[H]; // whether this filling has been used already (0 -> false, >0 -> true)

        for(d=W; // init direction
            (d=-d)>0|| // swap direction, else increment z (this allows us to run the check for the same z twice with opposite direction)
            ++z<H*H; // for all M, for all q (z<H -> M=z/H=0 -> no valid cookies, so we can safetly skip them)
            )
            for(//M=z/H, // c allow (now inlined)
                c=1, // reset counter
                q=z%H; // note position
                c<=z/H& // counter check
                // no need for a left check: if we run off the left end, then the right check will necessarily fail
                q%W+c<W& // right check
                q>=d& // high check
                q<H+d&& // low check (short-circuit lookups)
                D[q]==(d>0?92:47)&D[j=q+c]==(d<0?92:47); // /\ or \/ check, and set j=q+c
                    q-=d+1, // move left tracker
                    c+=2) // increase counter (move right tracker)
            {
                // count the number of '-' into b
                for(b=0; // zero b
                    j>q; // for each element in the row below
                        ) // empty
                    b+=D[--j-d]==45?2:0; // add 2 to b if we tap a '-'

                // j = q

                // check valid before looking up cHaracter (so we don't mark unused stuff as taken)
                // if we are at the current max count, and we have enough -, then we are valid and should be commited
                for( // this runs either one or zero times, we only have a for here (rather than an if) so we can ditch a pair of braces
                    char h='-', // default filling
                         e; // filling we are considering
                    c==z/H&b>c;
                        C.WriteLine(h+" "+c/2)) // print filling and count
                    // continuously compute character
                    for(b=c++; // count b backwards, starting from c (add 1 to c so we can /2 in print)
                        b>1;j=q+=d+1,b-=2) // count q backwards toward z%H (where q came from), and b backwards toward 1 (for each row)
                        for(;j<q+b;) // for each cell in row
                            B[j]= // mark cell as taken (h,e > 0)
                            h= // record filling
                                B[j]<1& // check cell not already used
                                h==45& // '-'
                                (e=D[j++])!=47& // '/'
                                e!=92& // '\'
                                e>32 // ' '
                                ?e:h; // take first filling we can
                    // c runs out after this (exists both loops), so no need to action
            }
    }
}

Outputs for the 4 test cases:

testcase #1
. 2
. 2
@ 3
- 4
* 4

testcase #2
- 1
- 1
- 2
d 2
* 2
- 3

testcase #3
- 1
- 1
- 1
- 1
- 2
- 2
: 2

testcase #4
- 1
- 1
- 2
$ 2
# 2
- 3
x 4
- 4


C/C++, 53 50 39 bytes

f(a,m,n)int*a;{a[m]^=a[n]^=a[m]^=a[n];}

Try it online

Saved 11 bytes thanks to @Dennis


Count from 1 to n in Negabinary and Negaquaternary

Julia, 124 81 73 bytes

n->(a=2863311530;b=3435973836;[base(2,(i+a)$a)*base(4,(i+b)$b)for i=1:n])

This creates an unnamed function that accepts an integer and returns an array. Each element of the array is a successive number between 1 and n in negabinary concatenated to itself in negaquaternary.

The negabinary representation of an integer can be computed using Schroppel's shortcut:

base(2, (i + 2863311530) $ 2863311530)

For an integer i, this is i + 2863311530, XOR 2863311530, encoded in base 2. The negaquaternary shortcut is similar:

base(4, (i + 3435973836) $ 3435973836)


Pyth, 11

jC.>R~hZC.z

Try it here

jC.>R~hZC.z    ##  implicit: .z = list of input split by lines
        C.z    ##  transpose .z to get columns
  .>R~hZ       ##  shift each column by it's index
               ##  equivalent to .e.>bk
jC             ##  transpose back and join by newlines


Jelly, 13 bytes

pWạ\Ṛ$</¿€SÞḢ

Try it online!

How it works

pWạ\Ṛ$</¿€SÞḢ  Main link. Argument: n

 W             Wrap; yield [n].
p              Cartesian product; promote the left argument n to [1, ..., n] and take
               the product of [1, ..., n] and n, yielding [[1, n], ..., [n, n]].
         €     Map the link to the left over the pairs [k, n].
        ¿          While...
      </               reducing the pair by less-than yields 1:
  ạ\                       Cumulatively reduce the pair by absolute difference.
    Ṛ                      Reverse the result.
                   In essence, starting with [a, b] := [k, n], we keep executing
                   [a, b] := [b, |a - b|], until the pair is no longer increasing.
          SÞ   Sort the resulting pairs by their sums.
            Ḣ  Head; extract the first pair.


Python 3, 284 257 characters

div.py

n,t=input().split()
d=int(t)
l=lambda x:len(str(x))
s=l(n)
def p(x):print(' '*(l(d)+s-l(x)+1)+str(x))
p(int(n)//d)
p('-'*s)
p(t+'|'+n)
s=z=f=0
while t:
 try:
  while z<d:z=z*10+int(n[s]);s+=1
 except:t=0
 if z*f:p(z)
 if t:f=1;t=z//d*d;p(t);p('-'*l(z));z-=t

Usage: python3 div.py
Input: from keyboard

test.py

import sys
sys.stdin=open('input'); sys.stdout=open('output','w')
for line in open('input'): exec(open('div.py').read())

output matches expected

Versions:
 1. 284
 2. 257: s,z,f=0,0,0→s=z=f=0; z and f→z*f; better looping; removed a few newlines.


Remove first encountered elements from a second list

APL(Dyalog Unicode), 8 6 bytes SBCS
/⍨∘~∘≠

Try it on APLgolf!
A function submission which takes L1 on the left and L2 on the right.
-2 bytes from Bubbler.
Explanation
/⍨∘~∘≠
/⍨     remove elements from L! identified by:
   ~   the bitwise negation of
     ≠ unique mask of L2


Surjection from one string to two strings

Python 2, 42 bytes

lambda s:(s.split("1"+len(s)/2*"0")*2)[:2]

Try it online!

The inverse is:

def F(a,b):
    return a+"1"+len(a+b)*"0"+b

A tempting idea for the inverse is to encode the pair of input strings by putting some separator string in between them. That way, we can extract the pair by splitting on this separator. The issue is that the separator may appear in the inputs string.

We get around this by making the separator longer than the total length of both strings. We use 1 followed by a number of 0's equal to the number of characters in both strings. For example,

abc, defgh -> abc100000000defgh

Note that no matter how many 0's and 1's are in the two inputs, there's no way to get another copy of the separator to appear.

We can recover the separator from the combined string by using a number of zeroes equal to half its length rounded down. I had wanted to compute this as 10**_, but Python's repr appends an annoying L to large numbers, which messes it up.

We need to the submission function still give two outputs when the input string doesn't contain the required separator. In this case, splitting just gives the original string, but we copy it twice to be compliant.

Python 2, 35 bytes (not working)

lambda s:s.split(s[:len(s)/3])[-2:]

Try it online!

This would work except it gives an error for the empty string. The idea is to have the inverse encode a,b -> sep + a + sep + b, where the separator sep has the same length as a+b so we can extract it as the first third of the string. A similar idea of putting the separator interspersed runs into the same issue.

Python 2, 43 bytes

lambda s:[s[i::2].lstrip()[1:]for i in 0,1]

Try it online!

The idea for encoding is to intersperse the two input strings with alternating characters. The problem there is that they may have different lengths. So, we pad them to the same length by prepending each one with some number of leading spaces then | (any non-space char will do). For example, abcd, ef goes to

|abcd
  |ef

This can be undone for each string by stripping off all leading spaces then removing the first character. Note that any spaces or | in the actual strings are left unharmed.

Python 3.8 (pre-release), 44 bytes

lambda s:(s[(i:=s.find('_'))+1:2*i],s[2*i:])

Try it online!

Inverse:

F=lambda a,b:(len(a)+1)*"?"+"_"+a+b

For instance, F("ab","cdef") = ???_abcdef. The number of symbols before the _ tells us where to split the remainder -- it's one more than the length of the first string.

We need the submission not to error when there's no _, but this works out because Python's string find uses -1 for missing, which still gives valid slices.


Scala 3, 49 44 bytes
a=>b=>(-b*b to b*b)map(p=>a-p->p)find(_*_==b)

Try it onlne!
Takes (a)(b) and returns an Option[(Int, Int)]. It's now a little more inefficient since it goes from \$-b^2\$ to \$b^2\$ instead of \$-|b|\$ to \$|b|\$, including values that \$p\$ and \$q\$ could never be, but it saves 4 bytes.
a => b =>
  (-b*b to b*b)              //Make a range of all possible q's and then some
    map(q => (a - q, q))     //Make a tuple of (p, q)
    find(_ * _ == b)         //Find a pair such that p * q = b


Pyth, 12 bytes
%"%0*d",+E>0

Try it here!


Fourth of July Edition: Print lines of a file containing multiples of a specific number

Perl, 67 chars

open F,"input.txt";print grep/(\d+)(?(?{!$^N+$^N%$ARGV[0]})(*F))/,<F>

Please note that the given character count is taking advantage of one of Perl's more horrific features, namely that a special variable of the form $^X can be written in two characters instead of three, by replacing the ^X with a literal ctrl-X character.

And, of course, this solution wouldn't be possible without a couple of Perl's arguably-equally-terrifying regex extensions that allows one to embed actual code inside of a regex pattern. (But at least those features are clearly documented as being potentially scary.)

[EDITED to fix bug in argument-handling due to not reading the description carefully enough.]


Avoid explicit loops at all costs

Forth has two looping constructs, x y do ... loop, and lesser known [begin] ... [until] x y where x and y are values for limit and index, or conditions to be noted, respectively.

These are very slow, very wordy (haha) and overall rather bloaty, so only use them if you need to.

Instead, like a proper functional language (which Forth is, really), one should prefer recursivity over explicit loops because it tends to be shorter and makes a better use of the language.


CJam, 56 55 53 52 50 bytes
S'O:Ori:X0>"\/"=" / \\\ / "+Xz*1>O]s3/X"z"<~N*X\O?

Look at that size! The main culprits are N = 0 special case and the \ instead of / in the vertical helix.
Here is how it works:
S'O:O                                  e# Put a space on stack. Now put char O on stack
                                       e# and assign it to variable O. This is not really
                                       e# helping in golfing as using 'O everywhere is
                                       e# same number of bytes
     ri:X                              e# Read input as in integer and store it in X
         0>"\/"=                       e# If X is greater than 0, choose /, otherwise \
                " / \\\ / "            e# Put this string on stack
                           +           e# Append to chosen \ or /
                            Xz*        e# Repeat it abs(X) times
1>                                     e# Remove the first character from repeated string
  O]                                   e# Put char O on stack, wrap everything in an array
                                       e# and convert it to string.
    3/                                 e# Split the string into parts of length 3
      X"z"<~                           e# If X is positive, transpose the array to get a
                                       e# horizontal helix, otherwise it would be vertical
            N*                         e# Join the parts with newline
              X\O?                     e# If X was 0, then pick char O instead of this
                                       e# final joined string.

The code is divided into three parts:

The part X0>"\/"=" / \\\ / "+ gives either "/ / \\\ / " or "\ / \\\ / " which is crucial as the helix is simply made up of alternate "/ \" and "\ /" joined by either " / " or " \ ". For instance, if you consider input to be 2, then your final repeated string would be "/ / \\ / / / \\ / " (without escaping). This obviously has extra /  at the beginning and an extra space at the ending.
Second part is to correct the above string with additional things and split. For an input 2, the desired final string without newlines would be " O / \\\ / / / \\\ / O", but after the above point, we only have "/ / \\\ / / / \\\ / ". So we remove the first character, add a space and 'O at the beginning and another 'O at the end. Then we finally split it into parts of 3
Finally, we decide whether to transpose this split string for a vertical helix or not; Join the parts by newlines; And choose between this and a single character 'O (for input 0 case)

Try it online here


Python 2, 72 65 bytes

Note: This solution works for positive integers:

lambda a,b,c,n:len([x for x in range(1,n+1)if x%a*(x%b)*(x%c)<1])

Try it online!


Check if a number is a product of consecutive integer numbers

Java - 124

String f(int t){int s=2,h=3,p=s,i;String o="";for(;p!=t&&s*s<t;p=p<t?p*h++:p/s++);if(p==t)for(i=s;i<h;o+++=i+" ");return o;}

Starting at 2, this loops until the start number is > the square root of the target (or target is reached exactly). If the product is low, it multiplies by the high number and increments it. If high, it divides by the starting number and increments it.
For example, for 30, it would check:
2*3     = 6 (too low, multiply)
2*3*4   = 24 (too low, multiply)
2*3*4*5 = 120 (too high, divide)
3*4*5   = 60 (too high, divide)
4*5     = 20 (too low, multiply)
4*5*6   = 120 (too high, divide)
5*6     = 30 (bingo!)

Outputs a space-separated string of factors in ascending order.
With line breaks:
String p(int t){
    int s=2,h=3,p=s,i;
    String o="";
    for(;p!=t&&s*s<t;p=p<t?p*h++:p/s++);
    if(p==t)
        for(i=s;i<h;o+=i+" ");
    return o;
}


GolfScript, 23 bytes

n/{"()"1/{.2$\-,*}%*n}/

The loophole I'm exploiting is the ruling that:

  You may add extra unnecessary parentheses if you want to, if it makes your code shorter

Basically, for each line, this code counts the number of characters on the line that are not opening parentheses, and prepends that many extra opening parentheses to the line, and then does the same for closing parentheses.  This is incredibly inefficient, but does ensure that all the parentheses on the output line are balanced.

For example, given the input:

This line has no parentheses
alert(Math.max(1, 2
1+1)*2).toString()
function() { alert('Hello, World!'); })(

this program will output:

((((((((((((((((((((((((((((This line has no parentheses))))))))))))))))))))))))))))
(((((((((((((((((alert(Math.max(1, 2)))))))))))))))))))
(((((((((((((((((1+1)*2).toString())))))))))))))))
(((((((((((((((((((((((((((((((((((((function() { alert('Hello, World!'); })()))))))))))))))))))))))))))))))))))))

Ps. You can also test this code online.


Ruby 109 108

Saved one whole character by using randomization instead of searching!

h,*t=[*$<]
t.shuffle!until t.each_cons(2).all?{|c|a,b=c.map{|y|y.lstrip.split /[,\s]+/}
a[1]==b[0]}
puts h,t

This only prints to stdout, so to save to a file use ruby csv.rb in.csv > out.csv.

$ cat test.csv
ID,    Before,   After,   Value
 1,         3,       5,    Cat
 2,         5,        ,    Apple
 3,         4,       1,    Dog
 4,          ,       3,    Elephant
 5,         1,       2,    Banana
$ ruby csv.rb test.csv
ID,    Before,   After,   Value
 2,         5,        ,    Apple
 5,         1,       2,    Banana
 1,         3,       5,    Cat
 3,         4,       1,    Dog
 4,          ,       3,    Elephant

Old version

puts gets,[*$<].permutation.find{|x|x.each_cons(2).all?{|c|a,b=c.map{|y|y.lstrip.split /[,\s]+/}
a[1]==b[0]}}

It simply finds the permutation of the lines where, for each line, the second column (Before) equals the first column (ID) of the next line.


Python 3.4

Using the turtle module. The turtles are different colours and they always face in the same direction, so they can be easily seen to be moving along straight lines by just focusing on one of them. Despite this the circle illusion is still strong.

The illusion still seems quite strong even with just 3 or 4 turtles:

The framerate is reduced considerably for all of these GIF examples, but it doesn't seem to detract from the illusion. Running the code locally gives a smoother animation.

import turtle
import time
from math import sin, pi
from random import random

def circle_dance(population=11, resolution=480, loops=1, flip=0, lines=0):
    population = int(population)
    resolution = int(resolution)
    radius = 250
    screen = turtle.Screen()
    screen.tracer(0)
    if lines:
        arrange_lines(population, radius)
    turtles = [turtle.Turtle() for i in range(population)]
    for i in range(population):
        dancer = turtles[i]
        make_dancer(dancer, i, population)
    animate(turtles, resolution, screen, loops, flip, radius)

def arrange_lines(population, radius):
    artist = turtle.Turtle()
    for n in range(population):
        artist.penup()
        artist.setposition(0, 0)
        artist.setheading(n / population * 180)
        artist.forward(-radius)
        artist.pendown()
        artist.forward(radius * 2)
    artist.hideturtle()

def make_dancer(dancer, i, population):
    dancer.setheading(i / population * 180)
    dancer.color(random_turtle_colour())
    dancer.penup()
    dancer.shape('turtle')
    dancer.turtlesize(2)

def random_turtle_colour():
    return random() * 0.9, 0.5 + random() * 0.5, random() * 0.7

def animate(turtles, resolution, screen, loops, flip, radius):
    delay = 4 / resolution      # 4 seconds per repetition
    while True:
        for step in range(resolution):
            timer = time.perf_counter()
            phase = step / resolution * 2 * pi
            draw_dancers(turtles, phase, screen, loops, flip, radius)
            elapsed = time.perf_counter() - timer
            adjusted_delay = max(0, delay - elapsed)
            time.sleep(adjusted_delay)

def draw_dancers(turtles, phase, screen, loops, flip, radius):
    population = len(turtles)
    for i in range(population):
        individual_phase = (phase + i / population * loops * pi) % (2*pi)
        dancer = turtles[i]
        if flip:
            if pi / 2 < individual_phase <= 3 * pi / 2:
                dancer.settiltangle(180)
            else:
                dancer.settiltangle(0)
        distance = radius * sin(individual_phase)
        dancer.setposition(0, 0)
        dancer.forward(distance)
    screen.update()

if __name__ == '__main__':
    import sys
    circle_dance(*(float(n) for n in sys.argv[1:]))

For contrast here are some that really do rotate:

...or do they?

The code can be run with 5 optional arguments: population, resolution, loops, flip and lines.

population is the number of turtles
resolution is the time resolution (number of animation frames per repetition)
loops determines how many times the turtles loop back on themselves. The default of 1 gives a standard circle, other odd numbers give that number of loops in the string of turtles, while even numbers give a string of turtles disconnected at the ends, but still with the illusion of curved motion.
flip if non-zero causes the turtles to flip direction for their return trip (as suggested by aslum so that they are never moving backwards). As default they keep a fixed direction to avoid the visual distraction at the endpoints.
lines if non-zero displays the lines on which the turtles move, for consistency with the example image in the question.

Examples with flip set, with and without lines. I've left my main example above without flip as I prefer not to have the sporadic jump, but the edge of the circle does look smoother with all the turtles aligned, so the option is there for people to choose whichever style they prefer when running the code.

It might not be immediately obvious how the images above were all produced from this same code. In particular the image further up which has a slow outer loop and a fast inner loop (the one that looks like a cardioid that someone accidentally dropped). I've hidden the explanation of this one below in case anyone wants to delay finding out while experimenting/thinking.

   The animation with an inner and outer loop of different sizes was created by setting the number of loops to 15 and leaving the number of turtles at 23 (too low to represent 15 loops). Using a large number of turtles would result in 15 clearly defined loops. Using too few turtles results in aliasing (for the same reason as in image processing and rendering). Trying to represent too high a frequency results in a lower frequency being displayed, with distortion.

Trying out different numbers I found some of these distortions more interesting than the more symmetrical originals, so I wanted to include one here...


C, C++, Perl, Bash – 230
#include <stdio.h>
#define c const char*\
s="just another %s hacker\n"
//bin/test;printf "$s" Bash;exit
int main(){c;printf(s,sizeof'a'-1?"C":"C++");}
/*==;seek DATA,0,0;@a=readline DATA;eval'$'.$a[2];printf $s,"Perl";
__DATA__*/

This was fun! :-)
230 chars including a newline at end of file. To run, save as both poly.c and poly.cpp and do:
$ gcc -Wall -Wextra -pedantic poly.c && ./a.out
just another C hacker
$ g++ -Wall -Wextra -pedantic poly.cpp && ./a.out
just another C++ hacker
$ perl poly.c
just another Perl hacker
$ bash poly.c
just another Bash hacker


Generate a Markdown Template for your Post

RProgN 2, 28 Bytes
«"  %s"F"#RProgN 2, 28 Bytes"


MATL, 36 34 bytes
tnq?`t&+stn:*sytn2/)+ 7M(6Lt3$)tnq

Input is a 2D array with ; as row separator
Try it online! Or verify all test cases.
Explanation
tnq       % Take input. Duplicate, get number of elements, subtract 1
?         % If greater than 0
  `       %   Do...while
    t     %     Duplicate
    &+    %     Sum matrix with its transpose
    s     %     Sum each column. Gives a row vector
    tn:   %     Vector [1 2 ...] with the same size
    *     %     Multiply element-wise
    s     %     Sum of vector. This will be added to center entry of the matrix
    y     %     Duplicate matrix
    tn2/  %     Duplicate, get half its number of elements. Gives non-integer value
    )     %     Get center entry of the matrix, using linear index with implicit rounding
    +     %     Add center entry to sum of previous vector
    7M    %     Push index of center entry again
    (     %     Assgined new value to center of the matrix
    6Lt   %     Array [2 j1-1], twice. This will be used to remove shell
    3$)   %     Apply row and col indices to remove outer shell of the matrix
    tnq   %     Duplicate, number of elements, subtract 1. Falsy if matrix has 1 entry
          %   End do...while implicitly. The loop is exited when matrix has 1 entry
          % End if implicitly
          % Display stack implicitly


05AB1E, 10 bytes

æʒø`O²‹_i,

Try it online!

Explanation

æ           # compute powerset of input
 ʒ          # filter out falsy values (we don't actually filter, it just saves a byte)
  ø         # zip into a list of keys and a list of values
   `        # push separately to the stack
    O       # sum values
     ²‹_i   # if not less than input_2
         ,  # print list of keys


(RGS 2/5) How many strings can you count within these character classes?

CP-1610 machine code (Intellivision),  23  22 DECLEs1 ≈ 28 bytes

As per the exception described in this meta answer, the exact score is 27.5 bytes (220 bits)

A routine taking a null-terminated string as an inline argument through R4 and returning the result in R1.

2B9 001     |         MVII    #1,     R1
2A0         | @@read  MVI@    R4,     R0
080         |         TSTR    R0
204 00F     |         BEQ     @@rtn
378 05B     |         CMPI    #'[',   R0
22C 007     |         BNEQ    @@read
2A0         |         MVI@    R4,     R0
00C         |         INCR    R4
320         |         SUB@    R4,     R0
020         |         NEGR    R0
008         |         INCR    R0
004 11C 1DC |         CALL    MULT
091         |         MOVR    R2,     R1
220 012     |         B       @@read
0A7         | @@rtn   JR      R4

A note about subroutine calls

The CP-1610 instruction for calling subroutines is JSR Rx, $address. This instruction saves the return address in Rx instead of pushing it on the stack as many other CPUs do.

This allows to pass a block of arguments that immediately follows the function call. This is a common practice in CP-1610 programming and that's what we use here.

        JSR     R4,     count     ; call to subroutine through R4
        STRING  "[*-0]", 0        ; argument
        ...                       ; we will return here

Obviously, the subroutine is responsible for reading the correct number of arguments and eventually jumping to the expected return address.

Full commented test code

        ROMW    10                ; use 10-bit ROM width
        ORG     $4800             ; map this program at $4800

PNUM    QEQU    $18C5             ; EXEC routine: print a number
MULT    QEQU    $1DDC             ; EXEC routine: signed multiplication

        ;; ------------------------------------------------------------- ;;
        ;;  main code                                                    ;;
        ;; ------------------------------------------------------------- ;;
main    PROC

        SDBD                      ; set up an interrupt service routine
        MVII    #isr,   R0        ; to do some minimal STIC initialization
        MVO     R0,     $100
        SWAP    R0
        MVO     R0,     $101

        EIS                       ; enable interrupts

        MVII    #$200,  R3        ; R3 = backtab pointer

        JSR     R4,     count     ; test cases
        STRING  "", 0
        CALL    print
        JSR     R4,     count
        STRING  "a", 0
        CALL    print
        JSR     R4,     count
        STRING  "[*-0]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[0-9][0-9]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[a-z]d[A-z]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[<->]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[!-&]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[d-z]abf[d-z]fg", 0
        CALL    print
        JSR     R4,     count
        STRING  "[[-]]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[a-a][b-b]cde[---]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[--[][--]]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[[-[].[]-]]", 0
        CALL    print

        DECR    R7                ; done: loop forever

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  prints the result of a test case                             ;;
        ;; ------------------------------------------------------------- ;;
print   PROC

        PSHR    R5                ; save the return address on the stack

        MOVR    R1,     R0        ; R0 = number to print
        MVII    #4,     R1        ; R1 = number of digits
        MOVR    R3,     R4        ; R4 = backtab pointer
        ADDI    #5,     R3        ; advance by 5 characters for the next one
        PSHR    R3                ; save R3
        CLRR    R3                ; R3 = attributes (black)
        CALL    PNUM              ; invoke the EXEC routine
        PULR    R3                ; restore R3

        PULR    R7                ; return

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  ISR                                                          ;;
        ;; ------------------------------------------------------------- ;;
isr     PROC

        MVO     R0,     $0020     ; enable display

        CLRR    R0
        MVO     R0,     $0030     ; no horizontal delay
        MVO     R0,     $0031     ; no vertical delay
        MVO     R0,     $0032     ; no border extension
        MVII    #$D,    R0
        MVO     R0,     $0028     ; light-blue background
        MVO     R0,     $002C     ; light-blue border

        JR      R5                ; return from ISR

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  our routine                                                  ;;
        ;; ------------------------------------------------------------- ;;
count   PROC

        MVII    #1,     R1        ; initialize R1 to 1

@@read  MVI@    R4,     R0        ; R0 = current character
        TSTR    R0                ; end of string?
        BEQ     @@rtn             ; if yes, return

        CMPI    #'[',   R0        ; is this a '['?
        BNEQ    @@read            ; if not, just go on with the next character

        MVI@    R4,     R0        ; R0 = ASCII code of the starting character
        INCR    R4                ; skip the '-'
        SUB@    R4,     R0        ; subtract the ASCII code of the ending character
        NEGR    R0                ; negate
        INCR    R0                ; increment
        CALL    MULT              ; compute R2 = R0 * R1
        MOVR    R2,     R1        ; and save the result in R1

        B       @@read            ; go on with the next character

@@rtn   JR      R4                ; return

        ENDP

Output

screenshot from jzIntv

1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'.


MATL, 7 bytes
qZqd2=s

This solution exploits the fact that the prime gap (the difference between successsive prime numbers) is always >= 2 (with the exception being the gap between 2 and 3). Because of this fact, all twin primes will be successive prime numbers. In this solution we just compute the differences between all primes less than the input n and count how many of these differences are equal to 2.
Try it Online
Explanation
    % Implicitly grab input, N
q   % Subtract one from the input (N-1)
Zq  % Get an array of all primes <= (N-1)
d   % Compute successive differences (prime gaps)
2=  % Create a boolean array indicating which prime gaps are equal to 2
s   % Count the TRUE values in this array to determine the twin number
    % Implicitly display the result

If you instead want the not the number of pairs but the number of primes that are part of a pair, the following would work
qZqt!-|H=az

Try it Online


JavaScript (ES6), 168 174 ... 155

This answer has been edited an embarrassing number of times. Hopefully, the current version is both reliable and decently golfed.

Returns a boolean.

s=>[...s].map(c=>++n%9?+c?n+=--c:a[i='pP/KkQqRrBbNn'.search(c),i&=i>4&a[i]>(i>6)||i]=-~a[i]:x+=c=='/',a=[x=n=0])&&!([p,P,s,k,K]=a,n-71|x-7|s|k*K-1|p>8|P>8)

Formatted and commented

s => [...s].map(c =>                  // for each character 'c' in the FEN string 's':
  ++n % 9 ?                           //   if we haven't reached the end of a rank:
    +c ?                              //     if the character is a digit:
      n += --c                        //       advance the board pointer by c - 1 squares
    :                                 //     else:
      a[                              //       update the piece counter array:
        i =                           //         i = piece identifier (0 to 12)
          'pP/KkQqRrBbNn'.search(c),  //             with special case: '/' --> 2
        i &=                          //         we count it as a promoted pawn instead if:
          i > 4 &                     //           it's a Q, R, B or N and we already have
          a[i] > (i > 6) ||           //           2 of them for R, B, N or just 1 for Q
          i                           //           else, we keep the identifier unchanged
      ] = -~a[i]                      //         '-~' allows to increment 'undefined'
  :                                   //   else:
    x += c == '/',                    //     check that the expected '/' is there
  a = [                               //   initialize the piece counter array 'a'
    x =                               //   initialize the '/' counter 'x',
    n = 0 ]                           //   initialize the board pointer 'n'
) &&                                  // end of map()
!(                                    // now it's time to perform all sanity checks:
  [p, P, s, K, k] = a,                //   copy the 5 first entries of 'a' to new variables
  n - 71 |                            //   have we reached exactly the end of the board?
  x - 7 |                             //   have we identified exactly 7 ends of rank?
  s |                                 //   have we encountered any unexpected '/' character?
  k * K - 1 |                         //   do we have exactly one king on each side?
  p > 8 |                             //   no more than 8 black pawns, including promotions?
  P > 8)                              //   no more than 8 white pawns, including promotions?

Test cases

let f =

s=>[...s].map(c=>++n%9?+c?n+=--c:a[i='pP/KkQqRrBbNn'.search(c),i&=i>4&a[i]>(i>6)||i]=-~a[i]:x+=c=='/',a=[x=n=0])&&!([p,P,s,k,K]=a,n-71|x-7|s|k*K-1|p>8|P>8)

console.log(f("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")) // True
console.log(f("2br2k1/1p2n1q1/p2p2p1/P1bP1pNp/1BP2PnP/1Q1B2P1/8/3NR2K")) // True
console.log(f("r2r2k1/p3q2p/ppR3pr/rP4bp/3p4/5B1P/P4PP1/3Q1RK1")) // False (black has 7 pawns and 4 rooks - impossible)
console.log(f("6k1/pp3ppp/4p3/2P3b1/bPP3P1/3K4/P3Q1q1")) // False (only 7 ranks)
console.log(f("3r1rk1/1pp1bpp1/6p1/pP1npqPn/8/4N2P/P2PP3/1B2BP2/R2QK2R")) // False (9 ranks)
console.log(f("5n1k/1p3r1qp/p3p3/2p1N2Q/2P1R3/2P5/P2r1PP1/4R1K1")) // False (2nd rank has 9 squares/pieces)
console.log(f("rnbqkbnr/pppppppp/8/35/8/8/PPPPPPPP/RNBQKBNR")) // True
console.log(f("rnbqkbnr/pppppppp/8/9/7/8/PPPPPPPP/RNBQKBNR")) // False (additional test case suggested by Rick Hitchcock)
console.log(f("rnbqkbnr/pppp/ppp/8/8/8/8/PPPPPPPP/RNBQKBNR")) // False (additional test case)


Shortest Code to randomly place points and connect them

Java : 318 282 265

Because, ya know, Java:

class M{public static void main(String[]a){new Frame(){public void paint(Graphics g){int i=0,j,d=640,n=25,x[]=new int[n],y[]=x.clone();for(setSize(d,d);i<n;i++)for(j=0,x[i]=(int)(random()*d),y[i]=(int)(random()*d);j<i;g.drawLine(x[i],y[i],x[j],y[j++]));}}.show();}}

Its just a simple loop that makes random dots and draws lines between the current dot and all previous ones.

Example with 25 dots:

With line breaks and imports:

import java.awt.*;
import static java.lang.Math.*;

class M{
    public static void main(String[]a){
        new Frame(){
            public void paint(Graphics g){
                int i=0,j,d=640,n=25,x[]=new int[n],y[]=x.clone();
                for(setSize(d,d);i<n;i++)
                    for(j=0,x[i]=(int)(random()*d),y[i]=(int)(random()*d);
                        j<i;
                        g.drawLine(x[i],y[i],x[j],y[j++]));
            }
        }.show();
    }
}

Edit: Since we're not counting imports, I imported a couple more things to save some characters later.

Edit 2: OP added an allowance for hardcoding number of dots. -17 chars :)


Retina, 78 73 bytes
(0(8|[569].?.?|..?0?)(?=[^0]....))?(...?)?(...?)(..)$
$1$#1*-$3$#3* $4 $5

Inspired by both @mazzy's PowerShell answer and @NahuelFouilleul's Perl 5 answer, so make sure to upvote them both as well!
-5 bytes thanks to @Neil.
Try it online.
Explanation:

Match the digit groups like this:
(                                )? # An optional group 1, which consists of:
 0                                  #  A leading 0
  ( |         |     )               #  followed by either (ignored inner group 2):
   8                                #   A single 8
    |[569]                          #   or one of 569,
          .?.?                      #      with one or two optional chars
              |.                    #   or any character,
                .?                  #      with one optional character,
                  0?                #      and an optional trailing 0
                     (?=        )   #  followed by an uncaptured inner group with:
                        [^0]        #   A character which is NOT a 0
                            ....    #   followed by any four characters
(    )?                             # An optional group 3, which consists of:
 ..                                 #  Two characters,
   .?                               #  followed by an optional character
(    )                              # A mandatory group 4,
 ...?                               #  which is similar as group 3
(  )                                # Followed by a mandatory group 5
    $                               # (at the end of the string), which consists of:
 ..                                 #  Any two characters

Then replace it with:
$1                                  # The content of group 1 (possibly empty)
  $#1*                              # If group 1 isn't empty:
      -                             #  A "-"
       $3                           # The content of group 3 (possibly empty)
         $#3*                       # If group 3 isn't empty:
             <sp>                   #  A " "
                 $4                 # The content of group 4
                   <sp>             # A " "
                       $5           # The content of group 5


Husk, 11 10 9 bytes

VS≡`ȯU¡!1

1-based.
Returns the index of a generator if one exists, 0 otherwise.
Try it online!

Explanation

V          Does any row r of the input satisfy this:
      ¡!    If you iterate indexing into r
   `    1   starting with 1
    ȯU      until a repetition is encountered,
 S≡         the result has the same length as r.


MATL, 20 bytes

XJZyXyi:"!J2$1!*s1$e

Try it online!

Explanation

This avoids the matrix multiplication by doing it manually, using element-wise multiplication with broadcast followed by vectorized sum. Specifically, to multiply matrices M and N, both of size s×s:

Transpose M. Call the resulting matrix P.
Permute the dimensions of N such that N is "turned" with a rotation axis along the first dimension, giving an s×1×s 3D array, say Q.
Multiply each element of P times each element of Q, with implicit broadcast. This means that P is automatically replicated s times along the third dimension, and Q is replicated s times along the second, to make them both s×s×s, before the actual element-wise multiplication takes place.
Sum along the first dimension to yield a 1×s×s array.
Squeeze the leading singleton dimension out, to produce an s×s result.

Commented code:

XJ      % take matrix A. Copy to clipboard J
ZyXy    % generate identity matrix of the same size
i:      % take exponent n. Generate range [1 2 ... n] (possibly empty)
"       % for each element in that range
  !     %   transpose matrix with product accumulated up to now (this is step 1)
  J     %   paste A
  2$1!  %   permute dimensions: rotation along first-dimension axis (step 2)
  *     %   element-wise multiplication with broadcast (step 3)
  s     %   sum along first dimension (step 4)
  1$e   %   squeeze out singleton dimension, i.e. first dimension (step 5)
        % end for. Display


Python 3, 529 bytes
thanks Thomas and Beta for pointing out some things that should've been obvious to me, saving me some bytes
massive improvement: using string slicing instead of dict lookup
s="""    {18}
    {10}{14}
    {2}{6}
    {0}{1}
 {17}{9} %s {3}{11}
 {13}{5}    {7}{15}

    {8}{4}
    {16}{12}
    {19}"""
e="H HeLiBe B C N O F NeNaMgAlSiP S ClArK Ca"
r="hydrogen   helium     lithium    beryllium  boron      carbon     nitrogen   oxygen     fluorine   neon       natrium    sodium     magnesium  aluminium  silicon    phosphoroussulfur     chlorine   argon      kalium     potassium  calcium    "
n=r.find(input().lower())//11
n-=(n>10)+(n>18)
print(s.format(*[' *'[i<=n]for i in range(20)])%e[n*2+1:n*2+3])

Not the prettiest of programs or outputs, but hey, we needed something to kick this challenge off. Try it online.


Python 2 or 3,  33  30 bytes

-3 thanks to Maxwell

lambda l:'o'in map(max,l[:-1])

An unnamed function accepting a list of lines

Try it online!

How?

There needs to be a section of rope obscured by Jimmy that is not the bottom one.

lambda l:'o'in map(max,l[:-1])
lambda l:                      # a function taking l (the lines as strings)
                       l[:-1]  # strip off the last line
               map(max,      ) # maximum of each line (where '|'>'o'>'\'>'/'>' ')
         'o'in                 # was 'o' one of them? (hence Jimmy obscured all the rope)


Jelly, 15 bytes

“v0¡µṾ;ḢŒ!QḊX”v

Just to get things started; this is almost certainly beatable. This is basically just a combination of a universal quine constructor and a "pick a random permutation other than the input" function; the latter may be improvable, the former almost certainly is.

Explanation

Universal quine constructor

“v0¡µṾ;Ḣ”v
“       ”v   Evaluate the following, given {itself} as argument:
 v0¡µ          No-op (which starts with "v")
     Ṿ         Escape string
      ;Ḣ       Append first character of {the argument}

This can be seen to be a quine if run by itself. It's also a proper quine by most definitions I know of; it doesn't read its own source (rather, it contains a literal that's "eval"ed, and is given a copy of itself as an argument), it can carry a payload (as seen here!), and the v outside the string literal is encoded by the v inside.

Pick a random anagram

Œ!QḊX
Œ!     All permutations
  Q    Discard duplicates
   Ḋ   Discard the first (i.e. the string itself)
    X  Choose random element

This is really inefficient on a string this long, so I haven't been able to test the program as a whole, but I've tested it on shorter strings and it appears to function correctly.


GolfScript, 107 91

.4:ab-1:ba=;1
%ba%{...fi@@=
c43.=;)('"([{
}])"'~?~'"([{
}])"')(;=.34c
=@@if...}%ab%
1;=ab:1-ba:4.

Newlines are artistic. fi, c43 and c are noops, but the entire code is executed.

Prints -3-1-1 for convenient palindromes, -4-1-1 otherwise. Try it online!

Alternate version, 155 bytes

At the cost of 64 bytes, this can be improved upon:

0!*1{!}\;:);0:f;0:i;-1:ab;9:ba;
...=;1%ab%{....i@f@@fi@@=@.=@\)
+""'"([{}])"'~+?+~'"([{}])"'""+
(\@=.@=@@if@@f@i....}%ba%1;=...
;ab:9;ba:1-;i:0;f:0;(:;\{!}1*!0

As before, the entire code is executed and every single byte affects the output.

Prints 010 for convenient palindromes, -100 otherwise. Try it online!

Tests and examples

$ base64 > palindrome.gs -d <<< LjQ6YWItMTpiYT07MSViYSV7Li4uZmlAQD1jNDMuPTspKCciKFt7fV0pIid+P34nIihbe31dKSInKSg7PS4zNGM9QEBpZi4uLn0lYWIlMTs9YWI6MS1iYTo0Lg==
$ wc -c palindrome.gs
91 palindrome.gs
$ rev palindrome.gs | tr '([{}])' ')]}{[(' | diff - palindrome.gs
$ echo -n 'r(a[c{"e"}c]a)r' | golfscript palindrome.gs
-3-1-1
$ echo -n 'totallynotapalindrome' | golfscript palindrome.gs
-4-1-1
$
$ base64 > pal.gs -d <<< MCEqMXshfVw7Oik7MDpmOzA6aTstMTphYjs5OmJhOy4uLj07MSVhYiV7Li4uLmlAZkBAZmlAQD1ALj1AXCkrIiInIihbe31dKSInfis/K34nIihbe31dKSInIiIrKFxAPS5APUBAaWZAQGZAaS4uLi59JWJhJTE7PS4uLjthYjo5O2JhOjEtO2k6MDtmOjA7KDo7XHshfTEqITA=
$ wc -c pal.gs
155 pal.gs
$ rev pal.gs | tr '([{}])' ')]}{[(' | diff - pal.gs
$ echo -n 'r(a[c{"e"}c]a)r' | golfscript pal.gs
010
$ echo -n 'totallynotapalindrome' | golfscript pal.gs
-100
$ for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs
> [ "$(echo -n 'r(a[c{"e"}c]a)r' | golfscript tmp.gs 2> /dev/null)" = "010" ] && echo $i
> done; rm tmp.gs
1
for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs
>  [ "$(echo -n '42' | golfscript tmp.gs 2> /dev/null)" = "-100" ] && echo $i
> done | grep '^1$'; rm tmp.gs

How it works

.             # Duplicate the input string.
4:ab-1:ba     # Save 4 in “ab” and -1 in “ba”.
=;            # Compare 4 to -1 and discard the result.
1%            # Save every element from the input string in a new string.
ab%           # Reverse the input string.
{             # For each character in the input string:
  ...         # Duplicate the character thrice.
  fi          # Variable “fi” is undefined; this does nothing.
  @@=         # Verify that the character is equal to itself; push 1.
  c43         # Variable “c43” is undefined; this does nothing.
  .=;         # Verify that 1 is equal to itself and discard the result.
  )(          # Increment and decrement the character.
  '"([{}])"'~ # Push that string and evaluate it. Result: '([{}])'
  ?           # Retrieve the character's position in '([{}])'. -1 means not found.
  ~           # Negate the position.. Examples: -1 -> 0    0 -> -1    2 -> -3
  '"([{}])"') # Push that string and pop its last element. Result: '"([{}])' 34
  (;          # Decrement 34 (the ASCII code of a double quote) and discard.
  =           # Retrieve the corresponding character.
  .34         # Duplicate the character and push 34.
  c           # Variable “c” is undefined; this does nothing.
  =           # If the character is a double quote, the index was -1.
  @@if        # In that case, replace the double quote with the original character.
  ...         # Duplicate the new character thrice.
}%            #
ab%           # Save every fourth element in a new string to discard dummy values.
1;            # Push 1 and discard.
=             # Push 1 if the modified string matches the original, 0 otherwise.
ab:1-         # Save 4 in “1” and subtract.
ba:4.         # Save -1 in “4” and duplicate.

0!*           # Pop and push the input string.
1{!}\;:);     # Make “)” an alias for “!”.
0:f;0:i;      # Variables.
-1:ab;9:ba;   # Moar variables.
...=;         # Duplicate the input string.
1%ab%         # Reverse the copy.
{             # For each character in the input string:
  ....        # Duplicate the character four times.
  i@          # Push 0 and rotate a string copy on top of it.
  f@@fi@@     # Push 0 and rotate 0 on top of it.
  =@          # Push 1 and rotate a string copy on top of it.
  .=@         # Push 1 and rotate 1 on top of it.
  \)+         # Negate a 1 and add. Result: 1
  ""          # Push that string.
  '"([{}])"'  # Push that string.
   ~+         # Evaluate the second string and concatenate. Result: '([{}])'
   ?          # Retrieve the characters position in '([{}])'. -1 means not found.
   +~         # Add 1 to the position and negate. Ex.: -1 -> -1 | 0 -> -2 | 1 -> -3
  '"([{}])"'  # Push that string.
  ""          # Push that string.
  +           # Concatenate. Result: '"([{}])"'
  (\          # Pop the first double quote and swap it with the rest of the string.
  @=.         # Retrieve the corresponding character and duplicate it.
  @=          # If the character is a double quote, the index was -1.
  @@if        # In that case, replace the double quote with the original character.
  @@          # Rotate the modified character to the bottom.
  f@i....     # Push dummy values.
  }%          #
  ba%         # Save every ninth element in a new string to discard dummy values.
  1;          # Push 1 and discard.
  =           # Push 1 if the modified string matches the original, 0 otherwise.
  ...;        # Duplicate thrice and discard the last copy.
  ab:9;ba:1-; # Variables.
  i:0;f:0;    # Moar variables.
  (:;\        # Negate, override “;” and swap.
  {!}1*!0     # Negate twice and push 0.


Retina, 56 bytes

Byte count assumes ISO 8859-1 encoding.

T`'\`
S_`\W|_|(?<=[a-z])(?=[A-Z][a-z])
T`L`l
T`l`L`¶.
¶

Try it online!

Explanation

This implements the specification quite literally:

T`'\`

Remove apostrophes and backticks.

S_`\W|_|(?<=[a-z])(?=[A-Z][a-z])

Split the string around non-word characters (in regex this also excludes digits and underscores), or underscores or positions that have a lower case letter on the left and and upper case, lower case on the right. This would create some empty segments when there are two non-letter, non-digit characters in a row, or more important at the beginning of the string. We get rid of those with the _ option. Here, "splitting" means put each remaining part on its own line.

T`L`l

Convert everything to lower case.

T`l`L`¶.

Convert each character that occurs after the linefeed to upper case. This will conveniently skip the first word because there's no linefeed in front of it.

¶

Get rid of the linefeeds to join everything back together.


05AB1E, 20 bytes
"34çìD«QiF"34çìD«QiF

Outputs the input if it's not equal to the program. If it is equal, it will output the error:

** (RuntimeError) Could not convert "34çìD«QiF"34çìD«QiF to integer.

Try it online.
Explanation:
It's based on this base quine: "34çìD«"34çìD«.

"34çìD«QiF"           # Push string "34çìD«QiF"
           34ç        # Push 34, converted to a character: '"'
              ì       # Prepend it to the string: '"34çìDJQiF'
               D«     # Append a copy of itself: '"34çìDJQiF"34çìDJQiF'
                 Qi   # If it's equal to the (implicit) input-string:
                   F  #  Start a loop, using the (implicit) input-string as argument,
                      #  resulting in the error
                      # (implicit else: use the implicit input as implicit output)


Brachylog, 23 22 20 19 bytes

Thanks to Zgarb, H.PWiz and Fatalize for saving some amount of bytes.

~cᶠ{oᵐoc≤₁&≡ᵃlᵐ⌉}ˢ⌋

Try it online!

I'm sure there's more to golf here...

Explanation

~cᶠ      Find all lists that concatenate into the input, i.e. all partitions
         of the input.
{        Discard all partitions for which this predicate fails, and replace
         the rest with the output of this predicate.
  oᵐ       Sort each sublist of the partition.
  o        Sort the entire list.
  c≤₁      And require concatenation of the result to be sorted.
  &        Then:
  ≡ᵃ       Append the partition to itself.
  lᵐ       Map "length" over this list, i.e. we get the length of each block, as
           well as the length of the partition itself.
  ⌉        Take the maximum.
}ˢ
⌋        Take the minimum of all those maxima.


Recursive Mathematical Puzzle from a high school contest

I solved this in excel, as my work machine doesn't have any languages on it. obviously the input/output part doesn't quite match the question... so psuedocode answer :

Setup

Array Heights[200][1500]

for v = 1 to 200
  Heights[v][1] = 1
for d = 1 to 1500
  Heights[1][d] = d
for d = 2 to 200
  for d = 2 to 1500
    Heights[v][d] = Heights[v-1][d-1] + Heights[v][d-1] + 1

'Heights' now contains all the answers within range. (sort of)

Solutions

for each input (V,N) :
d = 1
while (d <= 1500) and (Heights[V][d] < N)
  d++
print d

A few notes:

if speed is vital the search in the 'solution' part can be replaced with a binary search
because of the 1500 limit on floors, you never need to consider more than 11 vases. (in fact if V > log2(N+1), then answer is just round up log2(N+1) )  ((ie binary vase drop search))
There is slight ambiguity in the question regarding the first floor. It says 'if it breaks on the 1st floor, he will live on the 1st floor' which leads to 'if it breaks on the 2nd floor, he will live on the 1st floor regardless of whether or not it breaks on the 1st'...


Python 3, 88

f=lambda x,w,s=[]:[x or print(*s)]+[x.find(y)or f(x[len(y):],w,s+[y])for y in w.split()]

String to split is x, the dictionary string is w.

The idea is to repeatedly check which strings y of the dictionary are a prefix for the current string x. The expression x.find(y) evaluates to the Falsey 0 only if x starts with y (substrings not present give -1), so the short-circuiting of or makes the function recurse down only when the prefixes matches. The prefix is chopped off with x[len(y):] and the list of subwords is updated in s.

When the whole string x has been consumed, we print the subwords s, automatically joined by spaces.


k (29 20 chars)

{i!(1_i),*i:(-#x)?x}

    {i!@[i:(-:#x)?x;,/|2 0N#!#x]}

Example

k){i!(1_i),*i:(-#x)?x}`person1`person2`person3`person4`person5
person2| person1
person5| person3
person4| person2
person1| person5
person3| person4

Explanation - as above, shuffles list and maps to rotation of itself.


JavaScript (ES6), 16840 16825 16814 bytes

Saved a couple of bytes by:

inserting the last acid prefix in the packed string as suggested by ETHproductions
choosing the next character group in a slightly more efficient way when there's a tie

Assumes Windows-1252 character encoding. Outputs without a trailing newline.

Below is a simplified version without any actual data.

[...Array(256)].map((_,i)=>i<52|i>126&i<161|i==92|i==96?0:s=s.split(String.fromCharCode(i)).join(`...dictionary...`.slice(j,j+=2)),j=0,s=`...packed_data...`)&&[...s].map(c=>'methion|threon|glutamin|alan|prol|phen|leuc|ser|val|glutam|glyc|histid|isoleuc|tryptoph|argin|aspart|lys|asparagin|tyros|cystein'.split`|`[c.charCodeAt()-32]).join`yl`+'ine'

And here is the full version:

Try it online!

The TIO link includes some additional code to print the MD5 of the output rather than printing the output itself:

ec73f8229f7f8f2e542c316a41cbfff4

How?

This was compressed by:

Mapping the 20 distinct amino acids to ASCII characters 32 to 51.
Repeatedly replacing the most frequent 2-character group by a new ASCII character in the following ranges:

52-91
93-95
97-126
161-255

Which leaves us with a dictionary of 336 bytes (168 entries of 2 characters) and a final compressed string of 16161 bytes.

The above code is doing the exact opposite.


Use Chr$(...) to Print numbers

By default, all numbers printed using Yabasic print with a space following them, and to remove this space while printing characters individually, one may use the formula below.
It is important to note that this only works for printing digits 0 - 9, meaning that this works best for iterating across numbers digit by digit.
...
?Left$(Str$(n),1);
...

Try it online!
However, if the context allows, this can be golfed down to this formula.
...
?Chr$(n+48);
...

Try it online!


Latching Clock
Score - 53,508 (of which only 36,828 is actively used due to the L-shaped design)

High Quality recording - https://1drv.ms/u/s!ArQEzxH5nQLKhvt_HHfcqQKo2FODLQ
Golly pattern - https://1drv.ms/u/s!ArQEzxH5nQLKhvwAmwCY-IPiBuBmBw
Guiding Principles -

Since this was my first time using a cellular automaton I avoided stringing together large premade components. One valid approach I did not take would have been a binary adder starting at zero and continuously adding one to the last output, followed by a binary to BCD converter, display demultiplexer, 7-segment decoder and 7-segment display.
It should be possible to cold start the clock. I imposed on myself the additional restriction that a single electron head placed at a specific conductor cell should correctly start the clock. I did not want to require careful manual synchronisation of many disparate flip-flops and individual timing elements before beginning the simulation.

Part I: The Minute Counter
Mathematics
Counting from 0 to 9 in binary (for the least significant minutes digit) goes as follows -
0 - 0000
1 - 0001
2 - 0010
3 - 0011
4 - 0100
5 - 0101
6 - 0110
7 - 0111
8 - 1000
9 - 1001
Reading that as columns, the least significant (2^0 units bit stream) goes 01010101, the 2^1 units stream goes 0011001100, the 2^2 units stream goes 0000111100 and the 2^3 units stream goes 0000000011.
The first one's easy - just flip-flip 01 forever. The third is a stream of four 1s, six 0s, phase shifted by six zeros. The fourth is a stream of eight 0s and two 1s.
The second is a bit harder as it's got a nasty asymmetry. However, I notice that (where . is concat operator):
0011001100 . 0011001100 = 0011001100 . NOT(1100110011) = 00110011001100110011 XOR 00000000001111111111 = 5(0011) XOR 00000000001111111111
(Incidentally, as alluded to later, the majority of my clock runs on a 60-beat ticker. The 00000000001111111111 double length wave is where the need for the 120-beat ticker comes in).
Design
The output streams from top to bottom go Units of Minutes (2^0, 2^1, 2^2, 2^3) then Tens of Minutes (2^0, 2^2, 2^1). Note that the bottom two wires are crossed.

120-beat main clock.
Where to place an electron for a cold start. Without any electron tail it splits in two directions but the diode immediately above catches one of these giving a nice cycling electron going around and round the 120-beat loop.
12-beat secondary clock.
Coil of conductor + diode starts the secondary 12-beat clock. Words cannot describe how fiddly this little piece was to sync. You have to sync the 120 and 60 beat clocks, then sync in the 12-beat and frequency halver 24-beat pseudo clocks, followed by tying back the 24-beat clock to the 120-beat clock otherwise the XOR gate doesn't work.
Phase shift.
Flip-flop. A single electron on the input hits the set line first then after a very specific amount of time, hits the reset line giving precisely one pulse in, one pulse out.
Adding humps here - on the reset line, increases the delay between set and reset on the flip-flop. Each extra hump gives an extra pulse. The flip-flop below has nine extra humps, so ten pulses between set and reset.
XOR gate for my tricky 2^1 units of minutes line.
AND-NOT gate and very specific part lengths means each electron pulse which comes past doubles back on itself and annihilates the electron behind. Frequency halver. Creates a 24-beat clock from the 12-beat secondary source.
60-beat secondary clock, which actually does most of the work. It's just easier to start a fast clock from a slower one, so the slowest clock (120-beats) is the master, even though it's barely used. The 60-beat clock is the heart of this thing.
Feedback wire which carries electrons only when the 60-beat clock is ticking. It's used in conjunction with an AND-NOT gate to stop the clock being restarted repeatedly from the 120-beat master. Otherwise many horrible things happen & Ctrl-Z is saviour.
The diode where the 60-beat clock is started from.
This whole device is a flip flop, AND gate, and AND-NOT gate combined. It gives a latch. One pulse in starts it, one pulse in stops it.
Loop of wire to calibrate the latch to 10 pulses on, 10 pulses off for a one in ten pulse input. Without it we get 12 pulses on, 8 pulses off. These ten on ten off latches form the basic components of the ten minute blocks in the same way the 6-micron (1 pulse) flip-flops formed the basic components of the minute units.
The cold start initial pulse caused all sorts of problems including being two beats out of phase with the clocks it starts. This messes up the latches. This AND gate catches and disposes of out of sync pulses - in particular the starting pulse.
This is a part of the design I somewhat regret in retrospect. It takes an electron, splits it into five and annihilates the five electrons behind, taking 111111 to 100000.
This takes an electron and stitches it on the front. Two phases ahead to be precise. It takes 100000 and makes 101000. Combined with part 16 we get 111111 -> 100000 -> 101000. In retrospect I wish I'd done 111111 -> 101010 -> 101000; it would have achieved the same effect in less space.
The above patterns are then pushed into the bottom latch to achieve 20 on, 40 off. This is split, half is phase shifted by 20 units, and then these form the two high order bit streams of the tens of minutes.

Part II: The Hour Counter
Explanation
The input to the hour counter is a single electron pulse, once an hour. The first step is to reduce this to a single electron pulse, once every twelve hours. This is achieved using several "latch & catch" primitives.
A "latch" is a 6-micron flip-flop connected to an AND-NOT and an AND gate to give a 6-micron on/off latch. A "catch" takes a continuous stream of electrons as input, allows the first through, then annihilates every other electron behind, until the stream ends at which point the catch resets.
Placing a latch, followed by a catch, in series, results in one electron in -> turns on the latch, one electron out the other end (rest caught by catch). Then second electron in -> turns off latch, catch silently resets. Net effect: first electron passes through, second electron is annihilated, and so on and so forth, irrespective of how long the delay is between those electrons.
Now chain two "latch & catch" in series, and you have only one in four electrons passing through.
Next, take a third "latch and catch", but this time embed an entire fourth latch and catch on the flip-flop SET line, between the AND-NOT gate and the flip-flop SET. I'll leave you to think about how this works, but this time only one in three electrons passes through, irrespective of how long the delay is between those electrons.
Finally, take the one in four electrons, and the one in three, combine them with an AND gate, and only one in twelve electrons pass through. This whole section is the messy squiggle of paths to the top left of the hour counter below.
Next, take the electron every twelve hours and split back into one every hour, but output each onto a different conductor wire. This is achieved using the long coiled conductor with thirteen exit points.
Take these electrons - one an hour down different conductors, and hit a flip-flop SET line. The RESET line on that same flip flop is then hit by the next hour's conductor, giving sixty pulses down each wire per hour.
Finally - take these pulses and pass them into seven and a half bytes of ROM (Read-Only Memory) to output the correct BCD bitstreams. See here for a more detailed explanation of WireWorld ROM: http://www.quinapalus.com/wires6.html
Design

One electron per hour input.
First latch.
First catch.
"Latch & catch" embedded on an outer "latch & catch" SET line.
AND gate.
AM/PM latch (turned on/off once every twelve hours).
Each loop of wire is 6x60=360 units long.
Flip/Flop turned on its side to create a smaller profile.
Seven and a half bytes of ROM.

Notes

Due to its one electron per minute, 6-micron design, run the simulation at six generations per minute (one generation every 10 seconds) for a real-time clock.
The AM/PM line is high (1) for AM, low (0) for PM. This might seem a slightly unusual way round to choose, but there is justification. During a cold start of the clock, the AM/PM line is naturally low (0) initially. As soon as the AM/PM line is pulled high (1), this indicates that the count has begun at 12:00AM. All output before this point should be disregarded, all output after this point is considered meaningful.

Useful Links

I learned the basics of WireWorld from http://www.quinapalus.com/wi-index.html. An excellent resource.

To create and simulate the cellular automaton I used Golly: http://golly.sourceforge.net/

I took the AND gate design from http://mathworld.wolfram.com/WireWorld.html

And I've only just found this webpage so didn't use it but it looks great: http://karlscherer.com/Wireworld.html


dc, 8 bytes
I've been waiting to use dc's feature, that the input is both data and code, for quite some time.
0d?n47Pp

The idea behind the script is that all of the number crunching will be done by the question's state representation, a valid input string. The main script's task is then to initialize the counters, read the input (and execute it as code at the same time), and print the result when done, as a fraction.
Here are the strings I use to represent the state. The OP allows non-char types!

'o' -> "1r[1-]sX0>X0-+r1+r"
'c' -> "1r[1-]sX0>X1-+r1+r"
'd' -> "1r[1-]sX0>X1-+r1+rrr"

The extra "rr" part at the end changes nothing, it is there to differentiate the d state from c.

'b' -> "1r[1-]sX0>X2-+r1+r"

Try it online! The default input there is the last example.
Test run: from the 2nd example. Negative numbers in dc are given with _ as the minus sign. This is allowed by this meta consensus.
dc -f question_record.dc <<< "_1 1r[1-]sX0>X1-+r1+rrr 2 1r[1-]sX0>X1-+r1+r"
-1/2

Explanation of the script:
0d
# push 0 twice. The bottom cell will keep track of the number of questions, and the
#top cell of the sum part of the score.
?
# read input, which in this case is actually pairs of (data, code), that do all the
#number crunching
n47Pp
# print the 2 cells as a fraction: print top, print '/' (ASCII 47), print bottom

Explanation of the state's representation: I take the c state as example code
The stack at the start of this snippet is composed of the two bottom counters, plus the integer data (the votes) that was pushed on top before this. The snippet contains both the integer value of the state (minus points) and the dc code needed to apply it.
1r[1-]sX0>X1-+r1+r

I work with the following iterative algorithm (pseudo-code) to calculate the "positive question record":
result = 0
# main script: `0`
sum = 0
# main script: `d`
for each input question; do
# main script:`?`
    sum += 1
    # snippet: `1`
    sum -= v (0 if total votes are positive, 1 if negative)
    # snippet: `r[1-]sX0>X`
    sum -= minus_points (based on state)
    # snippet: `1-`, or `0-`, or `2-`
    result++
    # snippet: `r1+`
done
result = sum / result
# main script:`n47Pp`


Parity of Nth Term in Fibonacci Integer Sequences

Python, 29 bytes

lambda a,b,n:[a,b,a+b][n%3]%2

The generalized Fibonacci sequence modulo 2 has cycle length of 3. So, we reduce n mod 3 and take that element of the first three.

31 bytes:
lambda a,b,n:0<a%2*2+b%2!=n%3+1

True for odd, False for even


Python 2, 82 75 bytes
n=0
while 1:
 n+=1
 if`n`[::-1]==`n`*all(n%i**2for i in range(2,n)):print n

Try it Online!
If this was a decision problem (54 bytes):
lambda n:`n`[::-1]==`n`*all(n%i**2for i in range(2,n))

Explanation:
`n`[::-1]==`n`                     # If n is a palindrome. `n` is repr(n).
                                   # We check that it's the same
                                   # backwards and forwards.
              *                    # Multiplplying 2 booleans is AND
all(n%i**2for i in range(2,n))     # Check that squares of all #'s < n do not divide n


Golfscript, 142 137 chars

Unfortunately some of the characters are control codes, so I'm going to have to post a hexdump and a link rather than a direct copy of the source:

00000000  27 2b 27 3a 28 27 2d 27  36 35 2a 3a 5e 28 6e 27  |'+':('-'65*:^(n'|
00000010  7c 27 3a 29 27 20 27 3a  7c 36 34 2a 3a 40 27 20  ||':)' ':|64*:@' |
00000020  7c 0a 7c 20 27 3a 76 5b  27 77 12 5d 5b 3a 6b 6f  ||.| ':v['w.][:ko|
00000030  52 7f 7b 7e 2f 65 1f 6d  6c 27 7b 7d 2f 5d 3a 24  |R.{~/e.ml'{}/]:$|
00000040  2c 2c 7b 3a 78 3b 5b 27  60 40 50 20 00 10 2c 08  |,,{:x;['`@P ..,.|
00000050  1a 04 00 02 05 01 03 27  7b 7d 2f 5d 7b 24 78 3d  |.......'{}/]{$x=|
00000060  26 21 5b 34 38 78 2e 31  30 2f 37 2a 2b 2b 5d 7c  |&![48x.10/7*++]||
00000070  2b 3d 7d 25 33 2f 7d 25  7a 69 70 7b 7c 2a 7d 25  |+=}%3/}%zip{|*}%|
00000080  76 2a 76 40 29 6e 28 5e  28                       |v*v@)n(^(|

leds.gs

Note that all of the characters are 7-bit values and legal Unicode code points, so the number of characters is the same as the number of bytes in UTF-8.

Basically there are two hard-coded arrays. The first is a 15-element bitmap indicating which of the 7 segments control each grid cell. The second is the 7-segment encoding of the 16 characters. Then it's just a case of using bitwise and to work out which segments are turned on and doing some string manipulation.


Retina, 119 bytes

The previous version didn't manage correctly the space in "platonic solids", this one works and is shorter :)

ew
rw
eds
ed
(\w+) ?([^oatr ]\w{3}.+)real
and real $2$1
C
S
gne
in
o
o-
ti
ty
T`TL`Tl
p\w+y.+
$&.
s$
s!
real -p
RealPl

Try it online!

This transforms the input into the output through a series of substitutions.

The most interesting part is this substitution (kind of a regex golf):

(\w+) ?([^oatr ]\w{3}.+)real
and real $2$1

Which does almost all the job, by splitting the first word, placing its pieces in the right places, removing extra spaces, and building the structure of the output. To work correctly on the "Tumbleweeds" test case this depends on the previous substitution "eds"->"ed".

The rest is mostly composed by substitutions that deal with special cases. Other interesting parts are:

T`TL`Tl

This turns everything except "T" (for Tumblr) to lowercase.

p\w+y.+
$&.
s$
s!

This places a "." at the end of each sentence containing a word with a "y" some letters after a "p" ("petty" and "payer" in practice). Then places a "!" at the end of all sentences ending with an "s" (all the others).


Python 188 bytes

r=range(10)
h=zip(r,r)
w=input()
p=lambda n:all(n%~i for i in range(1,int(n**.5)))%n
while w:
 n,s=h.pop(1)
 for i in r:
    d=s+i;i+=10*n
    if i%d<1:h+=[(i,d)]
    if p(n/s)and p(i):print i;w-=1

This could be made shorter, but my primary concern was efficiency. This code maintains a list of the 'right truncable harshad numbers', as well as the their digital sum, and then uses this list to extend itself by one digit iteratively, allowing only new truncable numbers. I don't see any way to obtain the efficiency required without maintaining such a list. Runtime for n<=50 is less than one second.

A less efficient version, which calculates everthing as it goes (139 bytes, has an acceptable runtime for n<=31):

s=9
w=input()
while w:
 n=s=s+2;x=2;f=0
 while n>9:n/=10;z=sum(map(int,`n`));x-=n%z;f=f or(n/z<3)+n/z
 if(1<<s)%s==(1<<f)%f==x:print s;w-=1


Octave, 29 27 bytes
Thanks to @RickHithcock for pointing out a mistake, now corrected. Also, 2 bytes off thanks to @StewieGriffin!

@(s)'yn'(mod(sum(s+1),2)+1)

Try it online!
Explanation
The ASCII code point of 'y' is odd, and that of 'n' is even. The code

adds 1 to each char in the input string to make 'y' even and 'n' odd;
computes the sum;
reduces the result to 1 if even, 2 if odd;
indexes (1-based) into the string 'yn'.


Prime factorization (Ruby ,570 542 bytes)

Rev 0

Below is a table of the prime factorizations of the 36 required numbers (copied from Wolfram, hopefully with no errors.) Only 31 prime factors are involved if I have counted correctly, and some of these always occur together, for example 137*547*1093 and 683*2731*8191.

It should be possible to condense the information in the table, or perhaps even employ a search strategy. This should beat simply compressing the numbers.

Unfortunately the numbers are too big even for a 128-bit integer, which means I can't use C. Ruby and Python do support arbitrary precision integers. I have put the table in valid Ruby syntax, which makes it my first ever Ruby program!

puts 2**5  *3**3  *5    *7
puts 2**3  *3**2  *5    *7           *13
puts 2**2  *3**2  *5    *7**2        *13      *19
puts 2**9  *3**3  *5          *11                         *31
puts 2**7  *3**3  *5**2                  *17              *31
puts 2**9  *3**2        *7    *11    *13                  *31
puts 2**8  *3     *5    *7                    *19             *37       *73
puts 2**10 *3**3  *5**2                               *23 *31                 *89
puts 2**13 *3**3  *5          *11                                 *43                 *127
puts 2**14 *3     *5    *7                    *19         *31                                   *151
puts 2**13 *3**2        *7    *11    *13                          *43                 *127
puts 2**5  *3**4        *7**2 *11**2          *19**2                                  *127
puts 2**8  *3**2        *7**2        *13      *19**2          *37       *73           *127
puts 2**7  *3**10 *5                     *17          *23                        *107                                               *3851
puts 2**7  *3**6  *5                     *17          *23                                  *137           *547           *1093
puts 2**14 *3**2        *7**2        *13      *19**2      *31                         *127      *151
puts 2**5  *3**4        *7**2 *11**2          *19**4                                            *151                *911
puts 2**9  *3**4        *7    *11**3                      *31**2     *61    *83                      *331
puts 2**8  *3**2        *7**2        *13      *19**4            *37     *73                     *151                *911
puts 2**25 *3**3  *5**2                       *19         *31                                                  *683            *2731       *8191
puts 2**17 *3**10       *7                    *19**2  *23       *37     *73      *107 *127                                           *3851
puts 2**17 *3**6        *7                    *19**2  *23       *37     *73           *127 *137           *547           *1093
puts 2**25 *3**4        *7    *11**2          *19**2                                  *127                     *683            *2731       *8191
puts 2**25 *3**5        *7**2        *13      *19**2                                  *127                     *683            *2731       *8191
puts 2**17 *3**10       *7                    *19**4  *23       *37     *73      *107           *151                *911             *3851
puts 2**25 *3**10 *5                          *19     *23                        *107                          *683            *2731 *3851 *8191
puts 2**17 *3**6        *7                    *19**4  *23       *37     *73                *137 *151      *547      *911 *1093
puts 2**25 *3**6  *5                          *19     *23                                  *137           *547 *683      *1093 *2731       *8191
puts 2**25 *3**4        *7    *11**2          *19**4                                            *151           *683 *911       *2731       *8191
puts 2**25 *3**5        *7**2        *13      *19**4                                            *151           *683 *911       *2731       *8191
puts 2**33 *3**4        *7    *11**3                      *31        *61    *83                      *331                                        *43691 *131071
puts 2**33 *3**10       *7    *11                     *23                   *83  *107                *331                      *3851             *43691 *131071
puts 2**33 *3**6        *7    *11                     *23                   *83            *137      *331 *547           *1093                   *43691 *131071
puts 2**37 *3**4        *7    *11**3                      *31        *61    *83                      *331                                        *43691        *174763*524287
puts 2**37 *3**10       *7    *11                     *23                   *83  *107                *331                      *3851             *43691        *174763*524287
puts 2**37 *3**6        *7    *11                     *23                   *83            *137      *331 *547           *1093                   *43691        *174763*524287

Rev 1
Just starting to gather some terms.

#683*2731*8191=15278451143, 137*547*1093=81908327, 107*3851=412057, 174763*524287=91625968981, 19**2*151*911=49659521, 83*331=27473, 11**3*31*61=2516921,37*73=2701,19*19=361

puts 2**5  *3**3  *5       *7
puts 2**3  *3**2  *5       *7           *13
puts 2**2  *3**2  *5       *7**2        *13      *19
puts 2**9  *3**3  *5             *11                         *31
puts 2**7  *3**3  *5**2                     *17              *31
puts 2**9  *3**2           *7    *11    *13                  *31
puts 2**8  *3     *5       *7                    *19                *2701
puts 2**10 *3**3  *5**2                                  *23 *31                 *89
puts 2**13 *3**3  *5             *11                                 *43                 *127
puts 2**14 *3     *5       *7                    *19         *31                               *151
puts 2**13 *3**2           *7    *11    *13                          *43                 *127
puts 2**5  *3**4           *7**2 *11**2          *19**2                                  *127
puts 2**8  *3**2           *7**2        *13      *19**2            *2701                 *127
puts 2**7  *3**10 *5                        *17          *23                                                                           *412057
puts 2**7  *3**6  *5                        *17          *23                                                                *81908327
puts 2**14 *3**2           *7**2        *13      *19**2      *31                         *127  *151
puts 2**5  *3**4           *7**2 *11**2          *19**2                                            *49659521
puts 2**9  *3**4           *7                                *31    *2516921  *27473
puts 2**8  *3**2           *7**2        *13      *19**2            *2701                           *49659521
puts 2**25 *3**3  *5**2                          *19         *31                                                            *15278451143
puts 2**17 *3**10          *7                    *19**2  *23       *2701                 *127                                           *412057
puts 2**17 *3**6           *7                    *19**2  *23       *2701                 *127                               *81908327
puts 2**25 *3**4           *7    *11**2          *19**2                                  *127                                                   *15278451143
puts 2**25 *3**5           *7**2        *13      *19**2                                  *127                                                   *15278451143
puts 2**17 *3**10          *7                    *19**2  *23       *2701                           *49659521                            *412057
puts 2**25 *3**10 *5                             *19     *23                                                                            *412057 *15278451143
puts 2**17 *3**6           *7                    *19**2  *23       *2701                           *49659521                *81908327
puts 2**25 *3**6  *5                             *19     *23                                                                *81908327           *15278451143
puts 2**25 *3**4           *7    *11**2          *19**2                                            *49659521                                    *15278451143
puts 2**25 *3**5           *7**2        *13      *19**2                                            *49659521                                    *15278451143
puts 2**33 *3**4           *7                                       *2516921   *27473                                                               *43691 *131071
puts 2**33 *3**10          *7    *11                     *23                   *27473                                             *412057           *43691 *131071
puts 2**33 *3**6           *7    *11                     *23                   *27473                                       *81908327               *43691 *131071
puts 2**37 *3**4           *7                                       *2516921   *27473                                                               *43691        *91625968981
puts 2**37 *3**10          *7    *11                     *23                   *27473                                             *412057           *43691        *91625968981
puts 2**37 *3**6           *7    *11                     *23                   *27473                                       *81908327               *43691        *91625968981

Rev 2, 570  542 bytes (thanks to Martin for the improvement)

As this is my first Ruby program, I just stuck with the simple approach of continuing to gather terms. Compression of the numbers would be great if anyone knows how to do that.

I could save a few more bytes by evaluating some of the literal-only expressions in the variable assignment part, but I decided to leave them for clarity.

e=361
f=e*e*137561
g=27473
h=2516921
j=2701
k=81908327*729
m=412057*59049
n=15278451143*2**25
p=g*43691*2**33*7
q=131071
r=91625968981*16
s=127
t=1024
w=250240
x=1467648
y=7439488
puts [30240,32760,2178540,23569920,45532800,142990848,510720*j,t*42833475,t*510840*s,t*149417520,t*3099096*s,15367968*e*s,x*e*j*s,w*m,w*k,t*429378768*e*s,15367968*f,8999424*g*h,x*j*f,n*397575,t*m*y*j*s,t*k*y*j*s,n*68607*e*s,n*154791*e*s,t*20608*j*f*m,2185*n*m,t*20608*j*f*k,2185*k*n,68607*f*n,154791*f*n,81*h*p*q,253*p*m*q,253*p*k*q,81*h*p*r,253*p*m*r,253*p*k*r]


Check if three letters can form a "Godel-Escher-Bach cube"

Mathematica 423

I added a section called "How blocking works".

Ungolfed

(*The binary data of the alphabet are stored as a single string in s. vars imports it and converts it into an array.)

vars=IntegerDigits[#,10,5]&/@Transpose[ImportString[s,"Table"]];
get[char_]:=(ToCharacterCode[char]-64)[[1]];
cube=Flatten[Table[{i,j,k},{i,5},{j,5},{k,5}],2];

(* character slice along axis *)
slice[char_,layer_,axis_,bit_]:=Insert[(Reverse@#),layer,axis]&/@Position[Reverse@vars[[get[char]]],bit]

(* cuboid assembly  *)
charBlocks[{char_,axis_,bit_}]:=Flatten[Table[slice[char,k,axis,bit],{k,5}],1]

(* letters are those whose HOLES should be sculped out of the full cube *)
sculpturePoints[letters_(*{char_,axis_,bit_}*)]:=Complement[cube,Union[Join@@(charBlocks/@letters(*{char,axis,bit}*))]];

collapse[letters_(*{char_,axis_,bit_}*),axis_]:=Union[Reverse/@(Delete[#,axis]&/@sculpturePoints[letters(*{char,axis,bit}*)])](*/.{x_,y_}\[RuleDelayed] {6-x,y}*)

vQ[l_]:=collapse[l,3]==collapse[{l[[1]]},3]\[And]collapse[l,2]==collapse[{l[[2]]},2]\[And]collapse[l,1]==collapse[{l[[3]]},1]

validQ@l_:= vQ[{{l[[1]],3,0},{l[[2]],2,0},{l[[3]],1,0}}]

perspective[letts_,view_:1]:=
Graphics3D[{AbsolutePointSize[10],Cuboid/@sculpturePoints[letts]},
ImageSize-> 120,
ViewPoint-> Switch[view,1,{0,0,\[Infinity]},2,{0,-\[Infinity],0},3,{\[Infinity],0,0},4,Top,5,Front,6,Right,True,{0,0,\[Infinity]}],
PlotLabel-> Switch[view,1,"top orthogonal view",2,"front orthogonal view",3,"right orthogonal view",4,"top close-up view",5,"front close-up view",6,"right close-up view"],
ImagePadding->10]

Example

Is the cube {"B", "G", "E"} valid? (i.e. Will the three letters project correctly onto the walls?)

validQ[{"B", "G", "E"}]

  False

Illustrations

The figures below show how BGE is rendered. The upper row of figures takes orthogonal perspectives, as if the viewer were positioned at infinite distances from the cube.
The lower row shows how the blocks would look from close up.  The 3D figures can be manually rotated to inspect precisely where the individual unit cubes are positioned.

A problem occurs with the letter "G". There is nothing connecting the serif to the rest of the letter.

pts = {{"B", 3, 0}, {"G", 2, 0}, {"E", 1, 0}}
GraphicsGrid@Partition[Table[perspective[pts, view], {view, 1, 6}], 3]

BEG, however, should work fine.

 validQ[{"B", "E", "G"}]

  True

pts2 = {{"B", 3, 0}, {"E", 2, 0}, {"G", 1, 0}}
GraphicsGrid@Partition[Table[perspective[pts2, view], {view, 1, 6}], 3]

How Does Blocking Work?

Please excuse me if this seems obvious, but perhaps some folks will want to visualize how
how letters interfere with each other, canceling their 3D pixels.

Let's follow what happens to the letter G, in the BGE cube rendering.

We'll be paying special attention to the voxel (3D pixel or unit cube) below. That is the pixel that disappears in the BGE cube.  It is the pixel corresponding to Row 4, Column 5 in the bit array and in the corresponding array plot.

In the x y plane, the pixel corresponds to the gray disk at point (5,2). But because we're going to work in 3D, we need to consider the 5 positions in the shaft from (5,1,2) to (5,5,2).  If any of those pixels survives sculpting by the letters B and E, we'll be able to see the pixel of interest in the 3D projection on the wall.

Letters interfere when pixels are removed from the solid block.  In the left, the black arrow represents the carving out of  pixels, corresponding to the bit at the bottom right; it has the value 0 for the letter B.  Carving out removes the pixel at (5,1,2), along with those directly above and below it. Four pixels remain to be accounted for.

But as the right pane shows, the letter E sculpts out the remaining pixels of interest, (5,2,2) (5,3,2), (5,4,2) and (5,5,2). (This is due to the fact that the letter E has bits equal to 0 in the fourth row, from column 2 through column 5.) As a result, not a single pixel remains among those that were needed to ensure shade at point (5,2) on the far wall (for the letter G).  Instead, there will be a bright spot corresponding to a hole in the letter G!  The cube BGE is no good because it incorrectly renders G.

Golfed  423 chars

The function h served the same role as validQ in the unGolfed code.
The rendering function, perspective, is not included because it does not contribute to, and is not required by, the challenge.

x=Reverse;q=Flatten;
g@c_:=(ToCharacterCode[c]-64)[[1]];
r[{c_,a_,b_}]:=q[Table[Insert[(x@#),k,a]&/@Position[x@(IntegerDigits[#,10,5]&/@
Transpose[ImportString[s,"Table"]])[[g[c]]],b],{k,5}],1]
p@l_:=Complement[q[Table[{i,j,k},{i,5},{j,5},{k,5}],2],Union[Join@@(r/@l)]];
w[l_,a_]:=Union[x/@(Delete[#,a]&/@p[l])]
v@l_:=w[l,3]==w[{l[[1]]},3]\[And]w[l,2]==w[{l[[2]]},2]\[And]w[l,1]==w[{l[[3]]},1]

h@l_:= v[{{l[[1]],3,0},{l[[2]],2,0},{l[[3]],1,0}}]


Numbers divisible by the sum and product of their digits

05AB1E, 13 12 bytes

Thanks to Emigna for saving a byte!

µNNSONSP‚ÖP½

Explanation:

µ          ½   # Get the nth number for which the following holds:
  NSO          #   The sum of digits of the current number
     NSP       #   And the products of digits of the current number
 N      ‚ÖP    #   Divides the current number
               # If the nth number has been reached, quit and implicitly print N

Uses the CP-1252 encoding. Try it online!


Jelly, 9 bytes
%⁴2*^µÐḶL

Takes two command-line arguments.
%⁴2*^µÐḶL        A monadic link. Inputs: a_0. b also taken from command line.
%⁴2*^              Variadic link. Input: a
%⁴                   a modulo b. ⁴ is second input, b.
  2*                 Get 2 to that power
    ^                and bitwise xor with a.
     µ             Start a new, monadic link (input: a_0)
      ÐḶ             All elements of the cycle created when the preceding link
                     is applied repeatedly, starting with a_0.
        L            Length.

Try it here.


JavaScript (ES6), 690 bytes

f=(n=0)=>n<139?[...'DEFJKLMPQRVXYZ~0123456789'].map(c=>s=(e=s.split(c)).join(e.pop()),s=`P2other day9Xme8a 03 09Oh ~F8t6.|H2Yme9XYM9H2VZXV M.|H2said4oZ"Why7run?|Xse2yFEin't9Go8anyDun."|Xsays4o M9"That'sEDood idea."|"Now legsDe8going9ge8m2F8of 6!"1ran9A~Lm469Bu8riKbehindZWasQa80.|In Ln8ofZT6 wasE4Re34Re9OhDlory be!P2lowes5Was4en fee8up9So IQFKI'd jump9J4rus8my luck.1jumped9IntoQ2air9Bu8XmissedQa5A ~up46.|Now7fRt9J7Lwn9XCauKtha5OnQ2~back down!Pis isQ2end9T6Ein8no moR9Unless Xsee9Tha80 onc2moR.9,|8t 7 don'8yF 6heR58branch94 t39ADRa8big2e 1|J so X0bear~way Z me9YlookedE8XI Vsized upRreQ4hP|ThMhimLfroKgh8JAndFouE aD g`)&&s.split`|`[(i=+'11223344012340'[n%14])&&i+(n/14<<2)]+`
`+f(n+1):''

console.log(f())

How?
The 41 unique lyric lines (including the empty one) are stored in a pipe-separated string s.
"|The other day,|I met a bear,|A great big bear,|...|Unless I see,|That bear once more."

This string is compressed by replacing the most frequent sub-strings with characters that are not used anywhere else. The character set is "DEFJKLMPQRVXYZ~0123456789" and the substitutions are processed as follows (note that this is the decompression order):
 1. "D" -> " g"         | 10. "R" -> "re"         | 19. "3" -> "9A grea8big"
 2. "E" -> " a"         | 11. "V" -> "sized up"   | 20. "4" -> " t"
 3. "F" -> "ou"         | 12. "X" -> "I "         | 21. "5" -> "8branch9"
 4. "J" -> "And"        | 13. "Y" -> "looked a8"  | 22. "6" -> "here"
 5. "K" -> "gh8"        | 14. "Z" -> " me9"       | 23. "7" -> " don'8you "
 6. "L" -> "fro"        | 15. "~" -> "way "       | 24. "8" -> "t "
 7. "M" -> "him"        | 16. "0" -> "bear"       | 25. "9" -> ",|"
 8. "P" -> "|Th"        | 17. "1" -> "|And so I " |
 9. "Q" -> "4h"         | 18. "2" -> "e "         |

The compressed format is the one used in several popular JS packers such as RegPack: the substituted string is stored just after a last occurrence of the substitution character. Below is an example for "TwoBearsThreeBearsFourBearsFiveBears!", where "Bears" is packed as "~":

Hence the decompression formula:
c => s = (e = s.split(c)).join(e.pop())

Once s has been decompressed, we rebuild the original verses by applying the pattern:
00 - Line A
01 - Line A
02 - Line B
03 - Line B
04 - Line C
05 - Line C
06 - Line D
07 - Line D
08 - (empty)
09 - Line A
10 - Line B
11 - Line C
12 - Line D
13 - (empty)