8088 Assembly, IBM PC DOS, 164 159 156 155 bytes
Binary:
00000000: d1ee 8a0c 03f1 53fd ac3a d075 0343 e2f7  ......S..:.u.C..
00000010: 85db 741c 5f8a d043 f6c3 0174 0a57 bd64  ..t._..C...t.W.d
00000020: 0155 83eb 0374 0957 bd5d 0155 4b4b 75f7  .U...t.W.].UKKu.
00000030: 8ad0 2c2f 7213 518a f0b0 24b1 31bf 6a01  ..,/r.Q...$.1.j.
00000040: fcf2 aefe ce75 fa59 57e2 bc5a 85d2 740c  .....u.YW..Z..t.
00000050: b409 cd21 b220 b402 cd21 ebef c364 6f75  ...!. ...!...dou
00000060: 626c 6524 7472 6970 6c65 246f 6824 6f6e  ble$triple$oh$on
00000070: 6524 7477 6f24 7468 7265 6524 666f 7572  e$two$three$four
00000080: 2466 6976 6524 7369 7824 7365 7665 6e24  $five$six$seven$
00000090: 6569 6768 7424 6e69 6e65 24              eight$nine$

Build and test executable using xxd -r from above, or download PHONE.COM.
Unassembled listing:
D1 EE       SHR  SI, 1              ; point SI to DOS PSP (80H) for input string
8A 0C       MOV  CL, BYTE PTR[SI]   ; load input string length into CX
03 F1       ADD  SI, CX             ; move SI to end of input
53          PUSH BX                 ; push a 0 to signal end of output stack
        CHAR_LOOP:
FD          STD                     ; set LODS direction to reverse
AC          LODSB                   ; load next char from [SI] into AL, advance SI
3A D0       CMP  DL, AL             ; is it same as previous char?
75 03       JNZ  NEW_CHAR           ; if not, it's a different char
43          INC  BX                 ; otherwise it's a run, so increment run length
E2 F7       LOOP CHAR_LOOP          ; move on to next char
        NEW_CHAR:
85 DB       TEST BX, BX             ; is there a run greater than 0?
74 1C       JZ   GET_WORD           ; if not, look up digit name
5F          POP  DI                 ; get name for the current digit
8A D0       MOV  DL, AL             ; save current char in DL
43          INC  BX                 ; adjust run count (BX=1 means run of 2, etc)
F6 C3 01    TEST BL, 1              ; is odd? if so, it's a triple
74 0A       JZ   IS_DBL             ; is even, so is a double
57          PUSH DI                 ; push number string ("one", etc) to stack
BD 0164     MOV  BP, OFFSET T       ; load "triple" string
55          PUSH BP                 ; push to stack
83 EB 03    SUB  BX, 3              ; decrement run count by 3
74 09       JZ   GET_WORD           ; if end of run, move to next input char
        IS_DBL:
57          PUSH DI                 ; push number string to stack
BD 015D     MOV  BP, OFFSET D       ; load "double" string
55          PUSH BP                 ; push to stack
4B          DEC  BX                 ; decrement by 2
4B          DEC  BX
75 F7       JNZ  IS_DBL             ; if not end of run, loop double again
        GET_WORD:
8A D0       MOV  DL, AL             ; save current char into DL
2C 2F       SUB  AL, '0'-1          ; convert ASCII char to 1-based index
72 13       JB   NOT_FOUND          ; if not a valid char, move to next
51          PUSH CX                 ; save outer loop counter
8A F0       MOV  DH, AL             ; DH is the index to find, use as scan loop counter
B0 24       MOV  AL, '$'            ; word string is $ delimited
B1 31       MOV  CL, 031H           ; search through length of word data (49 bytes)
BF 016A     MOV  DI, OFFSET W       ; reset word data pointer to beginning
FC          CLD                     ; set DF to scan forward for SCAS
        SCAN_LOOP:
F2/ AE      REPNZ SCASB             ; search until delimiter '$' is found in [DI]
FE CE       DEC  DH                 ; delimiter found, decrement counter
75 FA       JNZ  SCAN_LOOP          ; if counter reached 0, index has been found
59          POP  CX                 ; restore outer loop position
57          PUSH DI                 ; push string on stack
        NOT_FOUND:
E2 BC       LOOP CHAR_LOOP          ; move to next char in input
        OUTPUT_STACK:
5A          POP  DX                 ; get string from top of stack
85 D2       TEST DX, DX             ; it is the last?
74 0C       JZ   EXIT               ; if so, exit
B4 09       MOV  AH, 09H            ; DOS display string function
CD 21       INT  21H                ; write string to console
B2 20       MOV  DL, ' '            ; load space delimiter
B4 02       MOV  AH, 02H            ; DOS display char function
CD 21       INT  21H                ; write char to console
EB EF       JMP  OUTPUT_STACK       ; continue looping
        EXIT:
C3          RET                     ; return to DOS

D   DB "double$"
T   DB "triple"
W   DB "$oh$","one$","two$","three$","four$","five$","six$","seven$","eight$","nine$"

TL;DR:
The input string is read right to left to make it easier to find a triple.  The output is pushed onto the x86 stack to simplify reversing out the display order and also facilitate rearranging the "double" and "triple" words to precede the digit's name.
If the next digit is different than the last, the name is looked up in the list of words and pushed on to the stack.  Since there's no formal concept of an "indexed array of variable-length strings" in machine code, the list of words is scanned i (the word's index) number of times for the string delimiter ($) to find the corresponding word. Helpfully, x86 does have a pair of short instructions (REPNZ SCASB which is similar to memchr() in C), that simplifies this (thanks CISC!).
If the digit is the same as the previous one, the counter for the length of a "run" is incremented and continues looping leftward on the input.  Once the run is over, the digit's name is taken from the stack since it will need to placed after the "double" or "triple" for each grouping.  If the length of the run is odd (and run length is > 1), the digit's name followed by the string "triple" is pushed to the stack and the run length is reduced by 3.  Since the run length will now be even, the step is repeated for "double" until the run length is 0.
When the input string has reached the end, the stack is dumped out with each saved string written to the screen in reverse order.
I/O:
A standalone PC DOS executable, input from command line output to console.

Download and test PHONE.COM.


The highest prime factor of neighboring numbers

Mathematica, 82 74 bytes

Thanks to Martin Ender for saving 8 bytes!

Max@@(±n_:=#//.x_/;l[t=x+n]>l@x:>t;l=FactorInteger[#][[-1,1]]&)/@{±-1,±1}&

Unnamed function taking an integer input and returning an integer.

±n_:=#//.x_/;l[t=x+n]>l@x:>t defines a unary function ± which keeps increasing the global function's integer input by n as long as the largest prime factor is increasing. (The largest-prime-factor function is defined with l=FactorInteger[#][[-1,1]]&.) {±-1,±1} therefore applies that function twice to the input integer, with increment -1 and again with increment 1. Then, Max@@(...l...)/@... takes the larger of the two largest-prime-factors thus found.

Previous submission:

Max@@(l=FactorInteger[#][[-1,1]]&)/@(#//.x_/;l[t=x+#2]>l[x]:>t&@@@{{#,-1},{#,1}})&


Python: 8 chars code, 387420489 chars output -- Ratio: 48427561.125 : 1

'a'*9**9

We can have the ratio tend to infinity by adding more **9s:

'a'*9**9**9
'a'*9**9**9**9
etc.

For example:

'a'*9**9**9**9**9**9

which has a ratio of ~10101010108.568 (unimaginably large number).


Python 2, 58 bytes

n=1
for c in input():n=n<<7|ord(c)
print'1'+bin(n^n/2)[4:]

Try it online!


Python 2, 329 310 bytes

from itertools import*
w,h=input()
R=range(w*h)
p=product
n=0
Z=[(x,y)for x,y in p(R,R)if abs(x%w-y%w)+abs(x/w-y/w)<2]
for s,f,W in p(R,R,p(*[((),z)for z in Z if z[0]<z[1]])):
 V={s};C=[s];v=0
 while C:
  c=C.pop();v|=c==f!=s;V|={c}
  for o,q in Z:C+=(c==o)*len({q,(o,q),(q,o)}-(V|set(W)))/3*[q]
 n+=v
print n

This is the golfed (and much more inefficient) version of the program I was using while discussing the problem with @Nathan. I can save a few bytes by replacing some space indents with tabs, but I'll save that for later.

The algorithm is simply generate every maze, then flood fill from the start, seeing if we pass the finish at some point or not.


Python 2, 387

I feel it's kinda long though.
Do suggest improvements or any fixes...

i=raw_input()
z="""#h(a?(a&1)^h(a/2)~a@0
#y(i,m,l,c=0?h(i&m)|y(i>>l,m,l,c+1)*2~c<4@0
#p(i?y(i,4369,1)*16+y(i,15,4)
k=i.replace(" ","")
m=int(k[:16],2)
c=int(k[-8:],2)
#s(i?s(i>>4)+" "+bin(i&15^16)[3:]~i@""
#q(j=16):d=m^1<<j;!s(d)[1:]~p(d)==c@q(j-1)~j@-1
#f(?1~p(m)==c@q()"""
for k,l in("?","):!"),("!","return "),("@"," else "),("#","def "),("~","if "):z=z.replace(k,l)
exec z
print f()

Slightly ungolfed...

def y(i,m,l,c=0):
    h=lambda a:(a&1)^h(a/2)if a else 0 # Calculate how many set bits in i
    return h(i&m)|y(i>>l,m,l,c+1)*2if c<4 else 0 # Sets the parity bits accordingly recursively

p=lambda i:y(i,4369,1)*16+y(i,15,4) # Returns the y and x parity together

i="1010 0111 1101 1011 1011 0111"

k=i.replace(" ","") # Remove all spaces
m=int(k[:16],2)     # Extracts the matrix
c=int(k[-8:],2)     # Extracts the parities

s=lambda i:s(i>>4)+" "+bin(i&15^16)[3:]if i else""
# Converts from int to space separated hexas in binary

def f(i):
    if p(m)==c:return 1 # If calculated parities matches the test
    for i in range(16): # Else, for each of the 16 bits in the matrix
        d=m^1<<i        # xor it
        if p(d)==c:return s(d)[1:] # return the matrix if its parities matches the test
    return -1 # If all else fails, return -1

print f(i)


Jelly, 79 bytes

“¡-Ị’b26
“µııẈḟ(µ⁹\fy¦°Ẓ=ȮH@Q0Ẋƈẏ9Ė=ẹṬɗƇ’ðœ?øØa;ØA;⁾'-ð,ø5Rx¢
¢yHx2+\©ð_ø®ṪHµẠ¬

Try it online!


Jelly, 11 9 bytes

JBÇṙ€1ỤỤịṢ

Try it online! Explanation:

J           Create a range 1-(length of input array).
 B          Convert all the elements to binary.
  ṙ€1       Rotate each element left by 1.
     ỤỤ     Find each element's position within the sorted list.
       ịṢ   Apply that permutation to the sort of the input.


The answer to life, the universe, and ASCII-art

Python 3, 224 220 219 215 211 194 bytes

Thanks to @TFeld for 1 5 bytes: if(j%27<1)*j instead of if j*(j%27<1) and simplified print statement.
Thanks to @Leaky Nun for 4 bytes:Inverting 0 and 1, did not require the padding by zeros 7*'0'
@Leaky nun saved 17 bytes with his awesome golfing skills(Thanks a lot!!!!): awesome use of modular indexing

i=j=0
k=int("OHZE5WCKDTW6JYMO1JNROAAJQVAN6F8KEO0SMKJM86XIBMCEH5FXXONZGBAVCN3689DS",36)
while k:j+=1;print(k%2*'theanswertolifetheuniverseandeverything'[i%39]or' ',end='\n'*(j%27<1));i+=k%2;k//=2

Try it online!

Explanation:

Uses base-36 compression to compress this binary number(new-line excluded)

111111100011111111000000111
111111000011111100000000011
111110000011111000111110001
111100000011111000111110001
111000100011111000111110001
110001100011111111111000011
100011100011111111100001111
000111100011111110000111111
000000000000111100011111111
000000000000111000111111111
111111100011111000111111000
111111100011111000000000000
111111100011111000000000000

We basically have two counters i and j. On encountering a 1 we print a space; Else if 0 is encountered we print next letter from the string and increase i. j increases for each 0 or 1. We also print new-lines whenever necessary i.e. when j%27<1 becomes true.


It's not who votes that counts; it's who counts the votes

Scala
Long live Alberto Arbusto!
import scala.io.Source
import java.util.concurrent.atomic.LongAdder

object Votes extends App {
  val votes = Source.stdin.getLines.toIndexedSeq
  val registeredCandidates = Seq(
    "Alberto Arbusto",
    "Juan Perez",
    "Mickey Mouse",
    "Jorge Sangre"
  )

  val summaries = registeredCandidates map (Summary.apply(_, new LongAdder))

  var currentCandidate: String = _

  for (vote <- votes.par) {
    currentCandidate = vote
    summaries.find(s => s.candidate == currentCandidate).map(_.total.increment)
  }

  for (summary <- summaries.sortBy(-_.total.longValue)) {
    println(summary)
  }
}

case class Summary(candidate: String, total: LongAdder) {
  override def toString = s"${total.longValue} ${candidate}"
}

Alberto Arbusto will almost always come out slightly ahead of Jorge Sangre, provided enough votes are cast (~10,000). There's no need to tamper with the votes themselves.

 There's a race condition. And by putting Alberto Arbusto earlier in the list, we increase his chances of winning the race.

Side note: This code is loosely based on a "custom" connection pool that I encountered on a project. It took us weeks to figure out why the application was perpetually out of connections.


Haskell, 77 75 bytes, no differentiation builtins

x@(a:b)&y@(c:d)=a*c:zipWith(+)(b&y)(x&d)
s=1:s&(1:scanl(*)1[-1,-2..])
(s!!)

Try it online!
How it works
We represent a function as its infinite list of Taylor series coefficients about \$x = 1\$:
$$
f(x) = \sum_{n=0}^\infty \frac{f^{(n)}(1)}{n!} (x - 1)^n
$$
is represented by \$[f(1), f'(1), f''(1), ...]\$.
The & operator multiplies two such functions using the product rule.  This lets us recursively define the function \$s(x) = x^x\$ in terms of itself using the differential equation
$$
s(1) = 1, \\
s'(x) = s(x) \cdot (1 + \ln x),
$$
where
$$
\ln x = \sum_{n=1}^\infty \frac{(-1)^{n-1}(n - 1)!}{n!}(x - 1)^n.
$$


List ALL prime-factorized natural numbers in ANY order

Haskell

import Data.List

merge :: [[a]] -> [[a]] -> [[a]]
merge [] ys = ys
merge (x:xs) ys = x : merge ys xs

atmostonefromeach :: [[a]]-> [[a]]
atmostonefromeach = foldr weave undefined

weave :: [a] -> [[a]] -> [[a]]
weave pwrs odds = merge (map (:[]) pwrs) $
foldr (\odd -> merge (odd: (map (:odd) (pwrs)))) undefined odds

primes = nubBy (\x y->gcd x y > 1) [2..]

shw factors = show (product (map (\(p,k)->p^k) factors)) ++ ":" ++ concatMap(\(p,k) -> ' ': show p ++ '^': show k) factors

powers p = map (\x->(p,x)) [1..]

main = mapM_ (putStrLn . shw) $ ([]:) $ atmostonefromeach $ map powers primes

output:

1:
2: 2^1
3: 3^1
4: 2^2
5: 5^1
8: 2^3
6: 2^1 3^1

...

The program constructs,
from the list Q=[q0,q1,..] of composite numbers with all prime factors > p,
the list of those with primes factors >= p, as
merge(P, merge((map(q0*)P1), merge(map(q1*)P1),...
where P=[p^1,p^2,...] and P1=[p^0,p^1,..].

The name odds in function weave describes the case p==2,
where Q is the set of all odd numbers > 1.


Bash + coreutils, 35 bytes

factor $[`date +%Y`+543]|awk NF==11

Output is either a non-empty string (truthy) or an empty string (falsy).
Try it online!
Alternate version: 37 bytes.
date -d 543year +%Y|factor|awk NF==11

Not as golfy, but I like this one.
Try it online!
How it works
The arithmetic expansion
$[`date +%Y`+543]
executes date +%Y to get the current (full) year and adds 543 to the year.
Factor takes the sum as an argument and prints it prime factorization: first the number to be factored, then a list of individual prime factors.
Finally, awk filters the input, printing only lines with exactly 11 fields (the number plus 10 prime factors).


Pyth, 37 35 34 bytes
The code contains unprintable characters, so here is the xxd hexdump:
0000000: 5663 7a34 7040 2e22 216f d78c 40bf d4f0  Vcz4p@."!o..@...
0000010: 38d6 7dfe 7312 3ff8 ea22 6958 4e7b 4e55  8.}.s.?.."iXN{NU
0000020: 5433                                     T3

Here's a printable version at 36 bytes:
Vcz4p@"ni >\\1   <d+[o*e-!]"iXN{NUT3

Try it online. Test suite.
Explanation
Vcz4p@."…"iXN{NUT3       implicit: z = input
  z                      input
 c 4                     split to 4-character blocks
V                        loop over that in N
           X               replace...
            N                in current part
             {N              unique chars in current part, in order
               UT            with numbers 0-9
          i      3         interpret as base 3
     @                     take that item of
      ."…"                   string "ni >\\1   <d+[o*e-!]"
    p                      and print without newline


Jelly, 26 24 23 20 19 17 16 bytes
-1 byte thanks to @miles (unnecessary for each, €, when taking determinants)
-2 bytes, @miles again! (unnecessary chain separation, and use of Ð€ quick)
ZœcLÆḊ
œcÐ€JÇ€€Ȧ

TryItOnline! or all 8 tests
How?
œcÐ€JÇ€€Ȧ  - Main link: matrix as an array, M
    J      - range of length -> [1,2,...,len(a)] (n)
  Ð€       - for each of right argument
œc         -     combinations of M numbering n
     Ç€€   - call the last link (1) as a monad for €ach for €ach
        Ȧ  - all truthy (any determinant of zero results in 0, otherwise 1)
                 (this includes an implicit flattening of the list)

ZœcLÆḊ - Link 1, determinants of sub-matrices: row selection, s
Z      - transpose s
   L   - length of s
 œc    - combinations of transposed s numbering length of s
    ÆḊ - determinant


Coin Change Problem Enumeration Using N Coins And Each Denomination

MATL, 22 bytes

Z^!S!Xu!tsi=Z)"1G@m?@!

Input order is: array of denominations, number of coins taken (n), desired sum (y).

Each combination is displayed on a different line. Empty output is displayed as an empty string (so nothing).

Try it online!

The code runs out of memory in the online compiler for the example in the challenge, but works offline with a standard, reasonably modern computer:

>> matl
 > Z^!S!Xu!tsi=Z)"1G@m?@!
 >
> [1 2 3]
> 15
> 36
1 1 1 1 2 3 3 3 3 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 3 3 3 3 3 3
1 1 2 2 2 2 2 3 3 3 3 3 3 3 3
1 2 2 2 2 2 2 2 3 3 3 3 3 3 3

Explanation

Z^      % Implicitly input array of denomminations and number of coins n. Compute
        % Cartesian power. This gives 2D array with each "combination"
        % on a different row
!S!     % Sort each row
Xu      % Deduplicate rows
!       % Transpose: rows become columns. Call this array A
ts      % Push a copy, compute sum of each column
i       % Input y (desired sum)
=       % Logical array that contains true if the "combination" has the desired sum
Z)      % Keep only those columns in array A
"       % For each column
  1G    %   Push array of denominations again
  @     %   Push current column
  m     %   Is each denomination present in the column?
  ?     %   If so
    @!  %     Push current column again. Transpose into a row
        %   End if
        % End for
        % Implicitly display stack contents


Is this a three-digit number ending in one?

JavaScript (ES7), 43 40 39 bytes

f=(n,b)=>n<b*b?0:n%b==1&n<b**3|f(n,-~b)

Test cases

f=(n,b)=>n<b*b?0:n%b==1&n<b**3|f(n,-~b)

console.log('[Truthy]')
console.log(f(5))
console.log(f(73))
console.log(f(101))
console.log(f(1073))
console.log(f(17))
console.log(f(22))
console.log(f(36))
console.log(f(55))
console.log(f(99))
console.log(f(46656))
console.log(f(46657))
console.log(f(46658))
console.log(f(46659))
console.log(f(46660))
console.log(f(46663))
console.log(f(46665))
console.log(f(46666))
console.log(f(46670))
console.log(f(46671))

console.log('[Falsy]')
console.log(f(8))
console.log(f(18))
console.log(f(23))
console.log(f(27))
console.log(f(98))
console.log(f(90))
console.log(f(88))
console.log(f(72))
console.log(f(68))
console.log(f(46661))
console.log(f(46662))
console.log(f(46664))
console.log(f(46667))
console.log(f(46668))
console.log(f(46669))

Commented

f = (n,           // given n = input
        b) =>     // and using b = base, initially undefined
  n < b * b ?     // if n is less than b²:
    0             //   n has less than 3 digits in base b or above -> failure
  :               // else:
    n % b == 1 &  //   return a truthy value if n is congruent to 1 modulo b
    n < b**3 |    //   and n is less than b³ (i.e. has less than 4 digits in base b)
    f(n, -~b)     //   or the above conditions are true for some greater value of b


Mathematica, 106 bytes
StringReplace[Rest@#~StringRiffle~"\n","package "~~__~~";"->"package "<>#[[1]]<>";"]&@StringSplit[#,"\n"]&

Works by splitting the string into its lines and returning all but the first line with any package declarations replaced with the new package.


Tribute to John Conway: Collatz in FRACTRAN

9 8 7 fractions

$$\frac{5}{4}, \frac{63}{22}, \frac{14}{55}, \frac{66}{35}, \frac{1}{7}, \frac{2}{3}, \frac{44}{5}$$

Takes input as \$3^n\$.

Try it online!

How it works

The first transition is

$$3^n \xrightarrow{\frac{2}{3}} 2 \cdot 3^{n - 1},$$

which we will consider the “real” representation of the number \$n\$, because some intermediate control flows will bypass the above transition.

If \$n = 1\$, the program now halts immediately.

If \$n = 2k\$ is even, we have

$$\begin{multline*}
2 \cdot 3^{2k - 1}
\xrightarrow{\frac{2}{3}}
2^2 \cdot 3^{2k - 2}
\xrightarrow{\frac{5}{4}}
3^{2k - 2} \cdot 5
\xrightarrow{\left(\frac{2}{3} \cdot \frac{2}{3} \cdot \frac{5}{4}\right)^{k - 1}}
5^k
\xrightarrow{\frac{44}{5}}
2^2 \cdot 5^{k - 1} \cdot 11
\\
\xrightarrow{\frac{5}{4}}
5^k \cdot 11
\xrightarrow{\frac{14}{55}}
2 \cdot 5^{k - 1} \cdot 7
\xrightarrow{\left(\frac{66}{35} \cdot \frac{5}{4} \cdot \frac{14}{55}\right)^{k - 1}}
2 \cdot 3^{k - 1} \cdot 7
\xrightarrow{\frac{1}{7}}
2 \cdot 3^{k - 1},
\end{multline*}$$

which represents \$\frac{n}{2}\$.

If \$n = 2k + 1\$ is odd, we instead have

$$\begin{multline*}
2 \cdot 3^{2k}
\xrightarrow{\left(\frac{2}{3} \cdot \frac{5}{4} \cdot \frac{2}{3}\right)^k}
2 \cdot 5^k
\xrightarrow{\frac{44}{5}}
2^3 \cdot 5^{k - 1} \cdot 11
\xrightarrow{\frac{5}{4}}
2 \cdot 5^k \cdot 11
\\
\xrightarrow{\frac{63}{22}}
3^2 \cdot 5^k \cdot 7
\xrightarrow{\left(\frac{66}{35} \cdot \frac{63}{22}\right)^k}
3^{3k + 2} \cdot 7
\xrightarrow{\frac{1}{7}}
3^{3k + 2}
\xrightarrow{\frac{2}{3}}
2 \cdot 3^{3k + 1},
\end{multline*}$$

which represents \$3k + 2 = \frac{3n + 1}{2}\$, which is two steps ahead of \$n\$.


Isn't the point of math to just use numbers?

JavaScript ES6, 255 247 237 225 219 bytes

s=>(s+'='+ +eval(s).toFixed(3))[h=(a,b,l)=>' '+[a,...btoa(b).split`z`][l],t='replace'](/\D/g,l=>h('divided by',`¶)³:eºÌæ{¬Íê®j[3¦§·<`,'*+-/=.'.indexOf(l)))[t](/\d/g,l=>h('ZERO',`8Ñ3Mc³LtD1NQÅ!Q3HóHED71tó4D`,l))

I'll resume golfing tomorrow. Gotta sleep :/

Base encoding may cause issues. If it does, I'll add a pastebin and possibly a hex dump.

If you find any issues (or the spec changes) don't hesitate to tell me, I'll fix it as soon as possible.

Explanation

s=>     // Function with argument "s"
 (s+'='                  // Add an equal sign to the input
   + +eval(s).toFixed(3)    // Add the value of the expression rounded to 3 places
 )[h=(a,b,l)=>           // Function h with args a,b, and l
                         // Return...
     ' '+                    // A space added to...
     [a,...btoa(b).split`z`] // Base decode the compressed words
     [l]                     // Grab the correct word
  ,t='replace'            // Alias replace command

 ](/\D/g,                // Replace non-digits with...
    l=>h(                                   // Function h
       'divided by',`¶)³:eºÌæ{¬Íê®j[3¦§·<`, // Base encoded words
       '*+-/=.'.indexOf(l)                  // Replace operator with correct word
    )

 )[t](                             // Replace again
    /\d/g,l=>                      // Replaces Digits with...
      h('ZERO',`8Ñ3Mc³LtD1NQÅ!Q3HóHED71tó4D` // Base encoded words
        ,l                                   // The associated number
      )
 )


V, 26 22 21 bytes

Thanks to @CowsQuack for 4 bytes by combining regexes! And @ØrjanJohansen for another byte with some regex combinations.

Ó1../3
Ó./&1
Ó31/0
A1

Try it online!

Uses substitute multiple times and appends a 1 at the end.  Nothing too fancy.  I have a version that remaps 1 and 0 in insert mode to get the desired effect, but it's quite a bit longer.

(Multiple replacement version: Try it online!)


Python 3 -- 375(534 chars)

It can process the example file d2.in in about 10 seconds, using Pypy3. With CPython 3, it will cost 60 seconds.

It's interesting and weird that some old golf tricks would make the score worse! For example, replacing <space>+<space> by + would increase the score from 375 to 384; replacing all range by R will also increase the score to 384.

Golfed

import sys
from collections import deque
def T(B):
 for i in range(0,len(B),8):
  x=0
  for j in range(min(8,len(B)-i)): x |= B[i + j] << (7-j)
  yield x
V=sys.argv
C=F=0
B=bytearray()
I=open(V[1],'rb')
H=I.read(4)
P=deque([(x>>(7-j)) & 1 for x in b'1AY&SY' for j in range(8)])
Q=deque([0]*48)
for x in I.read():
 for j in range(8):
  b=(x>>(7-j)) & 1
  B.append(b)
  Q.popleft()
  Q.append(b)
  if Q!=P: continue
  C+=1
  M,B=B[:-48],B[-48:]
  if F:F.write(bytes(T(M)))
  F=open(V[2] + str(C),'wb')
  F.write(H)
F.write(bytes(T(B)))

Base64

QlpoOTFBWSZTWSoMWQ0AAMLfgAAQYf901zlibSo/t//kMAFaCIaCQANTTTKMnlGg8oeRpPaoNDDAAAAAaAAAAABKaSGmmpplD0jQaAABo00ZNqLfKsdHBd3QgkQ2wY3RfYpMMjPpsyit5Ee6+k6E6ObzlFT2vmgbSKPkni7ZgDkcwTRiLFBmNCuEX/HtOC8KJ+Rg51SkMCiAGXZpXbvaK+DzMLvaEhAM8reCB8HFAsNYfRghS9+i5/IpLrDzGZVhsbVOpQzHIIVZ7zCCgDkcElOMvTuvfw2bruKz2WQuvEg99gDa8T3Kw2GdyMNjEVFVVQj4sU1MaOTUcwQROwt86LfUZAOJE6HqnB60CFO38NJmpifx+trcQ8x5alqRiEGoKC2wJpPkCXpT7fbtFDbLCLQaplK23qMTC5gqGwCghjN3zEtwyKhCz3kixqBr7gya6yPG03rMOGY9hlmV3tS0W/SdC2taUpCoNSEaEnUXckU4UJAqDFkN


Javascript

var x=prompt('Enter a value under 100');
while (x != 100) {
  x=x+1;
}
console.log('End!');

   prompt() returns a string and the loop appends the character '1', it will never be equal to 100.


BASH, 14 + 6*18 = 122

Cheap, but a win.

locate

Example:

boothby@not ~ $ locate camp
/home/boothby/Desktop/kodak/Pictures/camp.jpg
/home/boothby/Desktop/kodak/Pictures/camp2.jpg
/home/boothby/Downloads/sage-5.12/local/share/doc/networkx-1.7.dev_20131124172629/examples/graph/napoleon_russian_campaign.py
/usr/src/linux-headers-3.8.0-19/arch/arm/plat-samsung/include/plat/camport.h
/usr/src/linux-headers-3.8.0-33/arch/arm/plat-samsung/include/plat/camport.h

Feature: this is super efficient since it caches the file information in a database.  The above runs on my computer in 0.187s.

... and 17 additional features:

   -b, --basename
          Match only the base name against the specified  patterns.   This
          is the opposite of --wholename.

   -c, --count
          Instead of writing file names on standard output, write the num‐
          ber of matching entries only.

   -d, --database DBPATH
          Replace the default database with DBPATH.  DBPATH is  a  :-sepa‐
          rated  list of database file names.  If more than one --database
          option is specified, the resulting path is  a  concatenation  of
          the separate paths.

          An empty database file name is replaced by the default database.
          A database file name - refers to the standard input.  Note  that
          a database can be read from the standard input only once.

   -e, --existing
          Print  only  entries  that  refer  to files existing at the time
          locate is run.

   -L, --follow
          When checking whether files exist (if the --existing  option  is
          specified),  follow trailing symbolic links.  This causes broken
          symbolic links to be omitted from the output.

          This is the default behavior.  The  opposite  can  be  specified
          using --nofollow.

   -h, --help
          Write  a summary of the available options to standard output and
          exit successfully.

   -i, --ignore-case
          Ignore case distinctions when matching patterns.

   -l, --limit, -n LIMIT
          Exit successfully after finding LIMIT entries.  If  the  --count
          option  is  specified,  the  resulting  count is also limited to
          LIMIT.

   -m, --mmap
          Ignored, for compatibility with BSD and GNU locate.

   -P, --nofollow, -H
          When checking whether files exist (if the --existing  option  is
          specified),  do not follow trailing symbolic links.  This causes
          broken symbolic links to be reported like other files.

          This is the opposite of --follow.

   -0, --null
          Separate the entries on output using  the  ASCII  NUL  character
          instead  of  writing each entry on a separate line.  This option
          is designed for interoperability with the --null option  of  GNU
          xargs(1).

   -S, --statistics
          Write  statistics  about  each  read database to standard output
          instead of searching for files and exit successfully.

   -q, --quiet
          Write no messages about errors  encountered  while  reading  and
          processing databases.

   -r, --regexp REGEXP
          Search  for  a  basic regexp REGEXP.  No PATTERNs are allowed if
          this option is used, but this option can be  specified  multiple
          times.

   --regex
          Interpret all PATTERNs as extended regexps.

   -V, --version
          Write  information  about  the  version and license of locate on
          standard output and exit successfully.

   -w, --wholename
          Match only the whole path name against the specified patterns.

          This is the default behavior.  The  opposite  can  be  specified
          using --basename.


JavaScript (Node.js), 145 bytes
Saved 2 bytes thanks to @user202729
Expects a BigInt. Outputs # instead of \n for readability.
f=(n,k=0n,p=10n**k,x=55n+8n*k,q=p*3n/5n*x||30n)=>n<q?(g=p=>j--&&([["Fizz"][p%3n]]+[["Buzz"][p%5n]]||p)+'#'+g(++p))(p+n/x*(j=15n))[n%x]:f(n-q,-~k)

Try it online!
How?
Method
We use a recursive function that quickly computes the number of characters required to build all blocks of 15 terms using numbers of \$1\$, \$2\$, ..., \$N\$ digits. This takes \$\approx \log(n)\$ iterations, where \$n\$ is the input.
The only block that is explicitly generated is the last one, which contains the character we're looking for.
Formulae
Below is the template of a block of 15 terms of the sequence, where # is the separator and @ is a placeholder for a full number. (Note that the leading term modulo \$15\$ can be anything between \$0\$ and \$14\$. The length of the block doesn't depend on that.)
        <--------- 55 characters and 8 full numbers ---------->
        FizzBuzz#@#@#Fizz#@#Buzz#Fizz#@#@#Fizz#Buzz#@#Fizz#@#@#
        ^        ^ ^ ^    ^ ^    ^    ^ ^ ^    ^    ^ ^    ^ ^
mod 15: 0        1 2 3    4 5    6    7 8 9    10  11 12  13 14

All terms in such a block are meant to have the same number of digits \$k+1\$. For \$k>0\$, the length of the block is \$55+8k\$ characters. For \$k=0\$, we can only build a partial block of 9 terms whose length is \$30\$ characters:
<------ 30 characters ------->
1#2#Fizz#4#Buzz#Fizz#7#8#Fizz#

The number of terms with \$k+1\$ digits is \$9\times 10^k\$.
The number of blocks with \$k+1\$ digits is:
$$\left\lceil10^k\times\dfrac{9}{15}\right\rceil=\left\lceil10^k\times\dfrac{3}{5}\right\rceil$$
(where the ceiling is only needed for \$k=0\$)
And the number of characters is:
$$\cases{
30&k=0\\
10^k\times\dfrac{3}{5}\times (55+8k)&k>0
}$$
Commented
f = (                      // f is a recursive function taking:
  n,                       //   n = input
  k = 0n,                  //   k = exponent
  p = 10n ** k,            //   p = 10 ** k
  x = 55n + 8n * k,        //   x = length of a block of 15 terms, using numbers of
                           //       k + 1 digits
  q = p * 3n / 5n * x      //   q = number of characters added when all numbers of
      || 30n               //       k + 1 digits are used (p = 1 is an edge case)
) =>                       //
n < q ?                    // if n is less than q:
  ( g = p =>               //   g is a recursive function that builds the block of 15
                           //   terms in which lies the character we're looking for
    j-- &&                 //     abort if j = 0 (decrement it afterwards)
    (                      //     otherwise:
      [["Fizz"][p % 3n]] + //       append 'Fizz' if p is a multiple of 3
      [["Buzz"][p % 5n]]   //       append 'Buzz' if p is a multiple of 5
      || p                 //       append p if it's neither a multiple of 3 or 5
    ) + '#' +              //       append the separator
    g(++p)                 //       append the result of a recursive call to g
  )(p + n / x * (j = 15n)) //   initial call to g: we set j to 15 and add to p the
                           //   number of terms that can be generated with n
                           //   characters, using only full blocks of 15 terms
  [n % x]                  //   extract the character at n modulo x
:                          // else:
  f(n - q, -~k)            //   recursive call to f with n - q and k + 1


GolfScript (129 86 81 85 75 chars)

{:C[{.`{1$-\{+15\-}+%}:T+/}/10,1>C~+-:^{.{^T&}+C/,2<*T}/5^{1&}$][]*^&0=}:N;

Expected input format: [[int int ...][int int ...]] where the first list is my numbers and the second list is my opponent's numbers. For interactive testing, add ~N to the end of the script and supply a string in that format: e.g.

$ golfscript.rb 15.gs <<<"[[5][2 8]]"
9
$ golfscript.rb 15.gs <<<"[[2][5 8]]"
6

Heuristics:

If I can win this turn, do it
If opponent would win next turn, block
If I can force opponent to a square which prevents them from creating a fork, do it
5 is the only number which can contribute to winning in 4 ways, so grab it if available.
Favour evens over odds

Test framework:

{:Set;[1 5 9 1 6 8 2 4 9 2 5 8 2 6 7 3 4 8 3 5 7 4 5 6]3/{.Set&=},!!}:isWin;
{
    # Mine His
    .isWin{
        "Lost "@`@`++puts
    }{
        # If there are available moves, it's my move.
        # If I won before my move, I've still won after it.
        1$1$+,9<!!{
            # my move
            1$1$[\\]N 2$\+
            # Mine His Mine'
            .isWin!{
                # his move
                10,1>2$2$+-{
                    2$\+1$\
                    # Mine His Mine' Mine' His'
                    fullTest
                    # Mine His Mine'
                }/
            }*;
        }*;;
    }if
}:fullTest;
# I move first
'[][]fullTest'puts [][]fullTest
# He moves first
'[][1]fullTest'puts [][1]fullTest
'[][2]fullTest'puts [][2]fullTest
'[][5]fullTest'puts [][5]fullTest


Python: 5360 test-cases solved using 69519 blocks, 594 bytes

This should be the optimal values.

Approach:

First I'll test if the test-case is actual solvable. I do this by initializing a list of length 64 by ones and set all positions to zero, if there the corresponding pixel of the three views is zero.
Then I simple view at the puzzle from all 3 directions, and look if the views are the same as the input views. If there're equal, the puzzle is solvable (we already found the worst solution), otherwise it's unsolvable.

Then I do a branch-and-bound approach for finding the optimal solution.

Branching: I have a recursive function. The recursion depth tells how many values are fixed already. In each call of the function I call itself twice, if the value at the current index is 1 (this value can be 0 or 1 in the optimal solution), or once, if the value is 0 (it has to be zero in the optimal solution).

Bounding: I use two different strategies here.

I calculate the views from the 3 sides in each function call and look If they still match the input values. If they don't match, I don't call the function recursively.
I keep the best solution in memory. It there already more fixed ones in the current branch than in the best solution, I can already close that branch. Additionally I can estimate a lower bound for the number of activated blocks, which are not fixed. And the condition becomes #number of activated fixed blocks + #lower bound of activated blocks (under the not fixed blocks) < #number of activated blocks in the best solution.

Here's the Python code. It defines a function f which expects 3 lists containing 1s and 0s and returns either 0 (not solvable) or a list of 1s and 0s representing the optimal solution.

S=sum;r=range
def f(t,f,s):
 for i in r(4):s[4*i:4*i+4]=s[4*i:4*i+4][::-1]
 c=[min(t[i%16],f[(i//16)*4+i%4],s[i//4])for i in r(64)]
 m=lambda:([int(S(c[i::16])>0)for i in r(16)],[int(S(c[i+j:i+j+16:4])>0)for i in r(0,64,16)for j in r(4)],[int(S(c[i+j:i+j+4])>0)for i in r(0,64,16)for j in r(0,16,4)])==(t,f,s)
 Z=[65,0];p=[]
 def g(k):
  if k>63and S(c)<Z[0]:Z[:]=[S(c),c[:]]
  if k>63or S(c[:k])+p[k]>=Z[0]:return
  if c[k]:c[k]=0;m()and g(k+1);c[k]=1
  m()and g(k+1)
 for i in r(64):h,R=(i//16)*4+4,(i//4)%4;p+=[max(S(f[h:]),S(s[h:]))+max((R<1)*S(f[h+i%4-3:h]),S(s[h+R-3:h]))]
 g(0);return Z[1]

The code length is 596 bytes/chars. And here's the test framework:

from hashlib import md5
from time import time

N = 1000000
start=time();count=blocks=0
for n in range(N):
 bits = list(map(int,"{:048b}".format(int(md5("{:06}".format(n).encode("utf-8")).hexdigest()[:12], 16))))
 result = f(bits[:16], bits[16:32], bits[32:])
 if result:
  count += 1
  blocks += sum(result)
  print("Seed: {:06}, blocks: {}, cube: {}".format(n, sum(result), result))
print()
print("{} out of {} puzzles are solvable using {} blocks.".format(count, N, blocks))
print("Total time: {:.2f} seconds".format(time()-start))

You can find an ungolfed version of the program here. It's also a little bit faster.

Results:

5360 out of 1000000 puzzles are solvable. In total we need 69519 blocks. The number of blocks varies from 6 blocks to 18 blocks. The hardest puzzle took about 1 second to solve. It's the puzzle with the seed "347177", which looks like

Top:      Front:    Side:
x x . .   x x x x   x . x .
x x x x   x x x x   x x x x
x x x x   x x x x   x x x x
x x . x   x x x x   x . x x

and has an optimal solution with 18 cubes. The following is a few from top for each of the layers:

Top 1:    Top 2:    Top 3:    Top 4:
. . . .   . x . .   . x . .   x . . .
. . x x   . . x .   x . . .   . x x .
. . . .   . . . x   x x x .   . . . .
x x . .   x . . .   . . . x   . . . x

The total running time for all test-cases was about 90 seconds. I used PyPy to execute the my program. CPython (the default Python interpreter) is a bit slower, but also solves all puzzles in only 7 minutes.

You can find the complete output here: The output is self-explanatory. E.g. the output for the puzzle above is:

Seed: 347177, blocks: 18, cube: [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]


Ruby, 114

f,s=$*[0].split /\d*(?=[A-Z]|\Z)/
puts (n=Hash[*<<X.split-%w[0 1]].invert)[f]+" "+n[s].sub(/(i..|.gen|..)\Z/,"ide")
Hydrogen H 0
Helium He 0
Lithium Li 1
Beryllium Be 1
Boron B 0
Carbon C 0
Nitrogen N 0
Oxygen O 0
Fluorine F 0
Neon Ne 0
Sodium Na 1
Magnesium Mg 1
Aluminium Al 1
Silicon Si 0
Phosphorus P 0
Sulfur S 0
Chlorine Cl 0
Argon Ar 0
Potassium K 1
Calcium Ca 1
Scandium Sc 1
Titanium Ti 1
Vanadium V 1
Chromium Cr 1
Manganese Mn 1
Iron Fe 1
Cobalt Co 1
Nickel Ni 1
Copper Cu 1
Zinc Zn 1
Gallium Ga 1
Germanium Ge 1
Arsenic As 0
Selenium Se 0
Bromine Br 0
Krypton Kr 0
Rubidium Rb 1
X

Uses a paste of the element text that I haven't counted in the score. I remove the metal tag (since I'm assuming the compounds are always given with the metal first, so I don't actually need it) and build a dictionary with it. I identify the part to replace with "ide" by checking the end of the string for three letters starting with i, four letters ending with gen, or otherwise just the last two characters.


PHP, 12 bytes

<?=@date(B);

But it can only be so short because PHP has built-in Swatch Internet Time support. So this answer isn't much fun.

<?= exits HTML mode and evaluates an expression, then echoes it.

@ silences an error.

date() outputs the current time, formatting it with a given format string.

B is an undefined constant. In PHP, if you reference a constant that doesn't exist, you get back a string containing its name, and it also produces a “notice”-level error. Here, the @ suppresses that error. B is the date() format code for Swatch Internet Time.

; terminates the expression.

If we assume PHP is being run with the default error-reporting settings, where “notices” are silenced, we could skip the @, and it would only be 11 bytes.


Gol><> 0.3.11, 13 12 11 bytes

iEh`^=:@)+M

Try it online. Even though this will work fine in the next update, I've listed it as 0.3.11 just in case.

Explanation

i               Read char
 Eh             If EOF, halt and output top of stack as num
   `^=          Push 1 if char is ^, else 0
      :@        Dup and rotate, giving [is^ is^ votecount]
        )       Compare greater than, pushing 1 or 0 as appropriate
         +M     Add and subtract 1

Note that the first use of @ pulls a 0 from the bottom of the stack to initialise the vote count for the first iteration

To illustrate with a full table:

Votes before    Button    Is ^?    Compare <    Add     Subtract 1
     1            ^         1         0          1          0
     1            v         0         0          0         -1
     0            ^         1         1          2          1
     0            v         0         0          0         -1
    -1            ^         1         1          2          1
    -1            v         0         1          1          0


Mathematica, 353 288 285 275 bytes

n=Input[];f@_=" ";g={z={0,0}};i=f@z=0;For[r=Range,i++<n,g=Reap[(j=i;o={};For[d=0,j>0,o=Rest@o,If[o=={},o=Join@@({e={#,d-#},-e,e={d-#,-#},-e}&/@r@++d)];If[f[c=#&@@o+#]==" ",f@c=i;Sow@c;--j]])&/@g][[2,1]]];Riffle[(x=#;ToString@f@{x,#}&/@m~r~M)&/@r[m=Min@{g,0},M=Max@g],"
"]<>""

Ungolfed:

n = Input[];
f@_ = " ";
g = {z = {0, 0}};
i = f@z = 0;
For[r = Range, i++ < n,
  g = Reap[(
        j = i;
        o = {};
        For[d = 0, j > 0, o = Rest@o,
         If[o == {},

          o = Join @@ ({e = {#, d - #}, -e, e = {d - #, -#}, -e} & /@
              r@++d)
          ];
         If[f[c = # & @@ o + #] == " ",
          f@c = i;
          Sow@c;
          --j
          ]
         ]
        ) & /@ g
     ][[2, 1]]
  ];
Riffle[(
     x = #;
     ToString@f@{x, #} & /@ m~r~M
     ) & /@ r[m = Min@{g, 0},
    M = Max@g
    ], "
  "] <> ""

Here is an example output for n = 5:

      5
     5555
    555555
   5555555
  555555555
 55555555555
5555554445555
5555544444555
 5555443305555
 55554432144555
 55555443234555
  5555544344555
   555554445555
    5555555555
      5555555
       55555
       55

Input 8 takes about 4.5 minutes.

For a quick breakdown of my algorithm:

I'm using two look-up tables, f and g. The first one is just a sparse map containing the non-empty cells. The latter is a list containing all coordinate pairs for each cell-value (I think I don't even need to keep track of old ones here). I'm iterating through the coordinates in g to extend every cell from the last iteration. To do that I iterate over Manhattan distances, creating all possible vectors for each distance, and checking if the resulting cell is still empty (in which case I fill it). Repeat until enough new cells have been created.

When I'm done, I find the minimum and maximum coordinate in g and I create an appropriate grid, which is filled by looking up the cells in f. The rest is just joining everything into a single string with line breaks.


The Strange Unsorting Machine for Nefarious Purposes

GolfScript (score 27 - 120 = -93)

~].,{{.2$<{\}*}*]}*.(;+2%n*

Note: that $ is referencing an element on the stack. There is sorting, but it's done with an manually coded bubble sort.

Thanks to Howard, for -90 => -92; and Ilmari, who inspired -92 => -93.


The first published picture of the Mandelbrot set

Ruby 2.5, 98 bytes

-15.upto(15){|y|68.times{|x|z=0;250.times{z=0.035*x-1.9751+y/17.21i+z*z};putc z.abs<2?42:32};puts}

Try it online!
Very straightforward implementation, with a little bit of trickery to allow using times instead of upto in the inner loop.
Unfortunately, loop merging is two bytes longer, although it may help in other languages:
-1034.upto(1104){|x|z=0;250.times{z=x%69*0.035-2.0101+x/69/17.21i+z*z};putc x%69>0?z.abs<2?42:32:10}


05AB1E, 18 bytes

Saved 1 byte thanks to Kevin Cruijssen

mθ=²¹°÷DÝ¹m@O<=ìï=

Try it online!


MagicHash, 30 bytes

x=1
y#a=2
x#a=1
main=print$x#x

-XMagicHash outputs 1, -XNoMagicHash outputs 2

MagicHash allows variable names to terminate in a #. Therefore with the extension, this defines two functions y# and x# which each take a value and return a constant 2, or 1. x#x will return 1 (because it is x# applied to 1)

Without the extension, this defines one function # which takes two arguments and returns 2. The x#a=1 is a pattern that never gets reached. Then x#x is 1#1, which returns 2.


Visigoth

Visigoth tries to burn its enemies to the ground. It hopes to do this before anyone else gets to its land.

Run: python visigoth.py

#!/usr/bin/python

''' Charge the enemy and burn them to the ground. '''

import sys

data = sys.stdin.readlines()

startx, starty, x, y = [int(i) for i in data[0:4]]
field = [list(i) for i in data[4:]]

otherbots = []
for i in range(32):
    for j in range(32):
        if field[i][j]=='@': #bot
            if i!=y and j!=x:
                otherbots.append([j,i])

min_bot = otherbots[0]
for bot in otherbots:
    if abs(bot[0]-x)+abs(bot[1]-y) < abs(min_bot[0]-x)+abs(min_bot[1]-y):
        min_bot = bot

dx = min_bot[0]-x
dy = min_bot[1]-y

if abs(dy)>abs(dx):
    if dy>0:
        move = 'U'
    else:
        move = 'D'
else:
    if dx>0:
        move = 'R'
    elif dx<0:
        move = 'L'
    else:
        move = 'S'

if max(abs(x-startx), abs(y-starty))>4:
    if 0<x<31 and 0<y<31:
        dirs = {'U':(-1,0), 'D':(1,0), 'L':(0,-1), 'R':(0,1)}
        for i in dirs:
            if field[dirs[i][0]][dirs[i][1]] in ('.', 'W'):
                action = 'B'+i
                break
        else:
            # No free land nearby, go out in a blaze of glory
            action = 'BS'
    else:
        action = 'BS'
else:
    # Don't set own field on fire
    action = 'XS'

print move+action

This is my first entry, constructive criticism is appreciated!


Husk, 27 26 24 bytes

→foΛεẊδṁ≠ÖLm↓≠⁰←ġ→PΠmṠe¬

Brute force, so very slow.
Try it online!

Explanation

Husk reads naturally from right to left.

←ġ→PΠmṠe¬  Hypercube sequences ending in second input, say y=[1,1,0]
     mṠe¬  Pair each element with its negation: [[0,1],[0,1],[1,0]]
    Π      Cartesian product: [[0,0,1],[1,0,1],..,[1,1,0]]
   P       Permutations.
 ġ→        Group by last element
←          and take first group.
           The permutations are ordered so that those with last element y come first,
           so they are grouped together and returned here.

ÖLm↓≠⁰  Find first input.
  m     For each permutation,
   ↓≠⁰  drop all elements before the first input.
ÖL      Sort by length.

foΛεẊδṁ≠  Check path condition.
fo        Keep those lists that satisfy:
    Ẋ      For each adjacent pair (e.g. [0,1,0] and [1,1,0]),
      ṁ    take sum of
       ≠   absolute differences
     δ     of corresponding elements: 1+0+0 gives 1.
  Λε       Each value is at most 1.

→  Finally, return last element (which has greatest length).


Alice, 14 12 bytes

/O
\i@/t&Yd&

Try it online!

Inverse function (not golfed):

/o     Q
\i@/~~\ /dt&Z

Try it online!

Explanation

Alice has a built-in bijection between ℤ and ℤ2, which can be computed with Y (unpack) and its inverse Z  (pack). Here is an excerpt from the docs explaining the bijection:

  The details of the bijection are likely irrelevant for most use cases. The main point is that it lets the user encode two integers in one and extract the two integers again later on. By applying the pack command repeatedly, entire lists or trees of integers can be stored in a single number (although not in a particularly memory-efficient way). The mapping computed by the pack operation is a bijective function ℤ2 → ℤ (i.e. a one-to-one mapping). First, the integers {..., -2, -1, 0, 1, 2, ...} are mapped to the natural numbers (including zero) like {..., 3, 1, 0, 2, 4, ...} (in other words, negative integers are mapped to odd naturals and non-negative integers are mapped to even naturals). The two natural numbers are then mapped to one via the Cantor pairing function, which writes the naturals along the diagonals of the first quadrant of the integer grid. Specifically, {(0,0), (1,0), (0,1), (2,0), (1,1), (0,2), (3,0), ...} are mapped to {0, 1, 2, 3, 4, 5, 6, ...}. The resulting natural number is then mapped back to the integers using the inverse of the earlier bijection. The unpack command computes exactly the inverse of this mapping.

As alluded to above, we can use this unpack operation to map ℤ to ℤk as well. After applying it to the initial integer, we can unpack the second integer of the result again, which gives us a list of three integers. So k-1 applications of Y give us k integers as the result.

We can compute the inverse by packing the list up with Z from the end.

So the program itself has this structure:

/O
\i@/...d&

This is just a basic template for a program which reads a variable number of decimal integers as input and prints a variable number as the result. So the actual code is really just:

t   Decrement k.
&   Repeat the next command k-1 times.
Y   Unpack.

One thing I'd like to address is "why would Alice have a built-in for a ℤ → ℤ2 bijection, isn't that golfing language territory"? As with most of Alice's weirder built-ins, the main reason is Alice's design principle that every command has two meanings, one for Cardinal (integer) mode and one for Ordinal (string) mode, and these two meanings should be somehow related to give Cardinal and Ordinal mode the feeling that they are mirror universes where things are sort of the same but also different. And quite often I had a command for one of the two modes I wanted to add, and then had to figure out what other command to pair it with.

In the case of Y and Z Ordinal mode came first: I wanted to have a function to interleave two strings (zip) and separate them again (unzip). The quality of this that I wanted to capture in Cardinal mode was to form one integer from two and be able to extract the two integers again later, which makes such a bijection the natural choice.

I also figured that this would actually be very useful outside of golfing, because it lets you store an entire list or even tree of integers in a single unit of memory (stack element, tape cell or grid cell).


Python 3, 64 bytes

lambda a:[*{*permutations(a[0])}-{*a}][0]
from itertools import*

Try it online!


Search text for a prefix and list all its suffixes in the text

R, 63 bytes

function(s,p,z=el(strsplit(s,' ')))sub(p,'',z[startsWith(z,p)])

Try it online!

The positive-lookbehind implementation is unfortunately 5 bytes longer due to the huge regmatches/gregexpr combination :

function(s,p)regmatches(s,gregexpr(paste0('(?<=',p,')[^ ]*'),s,,T))


Haskell, 1.08404005439

import System.Environment
import Data.Ratio
import Data.Lists

main = do
   arg <- fmap head getArgs
   let number = read (arg ++ "5")
   let (_,_:decs) = span (/= '.') arg
   let acc = (read $ "0." ++ (decs >> "0") ++ "4999") :: Double
   putStr $ replace " % " "/" $ show $ approxRational number acc

This uses the approxRational function which converts a floating point number to a fraction with a accuracy of a given epsilon. It simply returns this fraction. As Haskell prints rationals with a % in-between, we have to replace it with the division sign /.

The accuracy parameter is calculated from the input number. We have to take into account that all the digits have to match, so 4.39 is fine for 4.3 but 4.29 isn't. I append a 5 to the number and the accuracy is a 4999 at the same decimal place as the appended 5, e.g.

12.347       -- input number
12.3475      -- append 5
 0.0004999   -- accuracy epsilon for the "approxRational" function.

E.g. 34.147425 -> 43777/1282.

Edit: the rules for accuracy have changed. The test case includes numbers with up to 11 decimal places and all have to match.

Edit II: it seems that the provides Python script doesn't strip off trailing newlines, so I've changed from putStrLn to putStr.

Edit III: again, new scoring rules


Python (27 characters)

In the Python shell, the following script will output the desired result:

TzoubyFssps;!jowbmje!tzouby

Yes! it outputs:

SyntaxError: invalid syntax


C (gcc), 413 394 389 379 378 360 342 327 307 299 298 293 bytes

#define F;for(b[8]=b[v=24]=3,n=0;n
#define B,b[n]==
a[]=L"14444448888888822222",b[32],r[24],n,k,j,t=20,v;main(i){srand(&i)F<v;*b=b[16]=1)r[n++]=n/3-~n F<4;a[k]=a[t])b[i=4+n++*8]=a[k=rand()%t--]-48 F<16;r[j]=r[v])b[r[j=rand()%v--]]=a[n++]-48 F<32;n++)printf("%d%d%d%d%d\n"B 1 B 3 B 4 B 8 B 2);}

Try it online!

#define F;for(b[8]=b[v=24]=3,n=0;n
#define B,b[n]==
a[]=L"14444448888888822222",b[32],r[24],n,k,j,t=20,v;main(i){srand(time(0))F<v;*b=b[16]=1)r[n++]=n/3-~n F<4;a[k]=a[t])b[i=4+n++*8]=a[k=rand()%t--]-48 F<16;r[j]=r[v])b[r[j=rand()%v--]]=a[n++]-48 F<32;n++)printf("%d%d%d%d%d\n"B 1 B 3 B 4 B 8 B 2);}

try it online -earlier algorithm 307 bytes

Many thanks to @ceilingcat for more byte savings (360 to 342 - then 342 to 328 and 327 to 307 - then modified algorithm from 328 to 299 and 298 to 293).

Compiles ok without #include<stdio.h> using the -w compiler flag, thanks to @Arnaud for pointing this out.

As written it generates a fresh sequence each time. If we are allowed manual intervention of a new number in srand to generate a different drum sequence with say srand(6); then we can save 16 bytes.

Thanks to @Arnaud who made asked the question about generating the transpose matrix, which is what this program does. Thanks also for suggesting the change from int to char for a[20] that saves 15 bytes. Also thanks for @Post Rock Garf Hunter who figured out a way to remove white space near the Bs and then saved more bytes fixing up the #defines so that F is included in R. `#define' tokens often seem to need whitespace so they are cleanly identified.

This code works on tio.run, but elsewhere may need to include time.h.

How the program works

logic:

setup
4 sounds are fixed (at 1,9,17,25)
remaining sounds to be distributed randomly are in a[20]
b[32] holds output - one cell for each beat (1 to 32, but in C of course 0 to 31)
4 of the b cells must have something (at 5,13,21,29)
remaining sounds randomly scattered to empty cells
r[24] holds list of empty cells (2,3,4, 6,7,8 etc. in C 0,1,2, 4,5,6 etc.)
execute
put in 4 fixed sounds
choose random sound from a to put in each of 4 cells with sounds
choose random cell from r to put in random sound from remaining a sounds (simplification to algorithm is possible here by putting remaining sounds one by one from 1 to 16 (or 0 to 15) in a random cell, but this gave more bytes..., but now thanks to @ceilingcat this is now smaller see tio.run link for details)
print result

this is a long version of the code without the #define and other space savers to show the logic, but with small differences e.g. in final version a is char * not int *

#include<stdio.h>
#include<stdlib.h>
int main()
{
  int a[20]={1,4,4,4,4,4,4,8,8,8,8,8,8,8,8,2,2,2,2,2},
    b[32]={},r[24],n,k,j,t=20,v=24;
  time_t q;srand(time(&q));
//random initialization

  for(n=0;n<24;n++n=0;n<v;n++)r[n]=n+n/3+1;
// set up r with list of cells that don't definitely have sound 012,456 etc.

  b[0]=b[16]=1;b[8]=b[24]=16;
//put in fixed sounds

  for (n=0;n<4;n++)
    {k=rand()%t--;b[4+n*8]=a[k];a[k]=a[t];}
//choose a random sound from a to put in each of 4 cells that must  have sound
// each sound selected is then replaced by the sound at the end of the list
// and the length of the list is reduced by one

  for (n=0;n<16;n++)
    {k=rand()%t--;j=rand()%v--;b[r[j]]=a[k];a[k]=a[t];r[j]=r[v];}
// random cell from remaining `r` cells and random sound are selected
// again after selection from list final item replaces selected and length
// reduced by one

  for (n=0;n<32;n++)
    {printf("%d%d%d%d%d\n",(b[n]==1),(b[n]==16),(b[n]==4),(b[n]==8),(b[n]==2));}
 // print out 0 and 1 from logical tests to print transpose matrix
  return 0;
}


Split string on first occurrence of each character

Jelly, 4 bytes

QƤĠị

Try it online!

Explanation

QƤĠị  Input is a string, say s = "adam"
 Ƥ    For each prefix of s: ["a","ad","ada","adam"]
Q     remove duplicates: ["a","ad","ad","adm"]
  Ġ   Group indices by equal values: [[1],[2,3],[4]]
   ị  Index into s: ["a","da","m"]

The internal representation of the strings, which the TIO link displays, is slightly different.


Mathematica, 26 bytes

Pause[Beep[];60/#]~Do~∞&

Do is normally used as a "for" loop in the narrowest sense: repeat this piece of code for each i from x to y... or even just repeat this piece of code n times. Instead of a number n we can give it infinity though to create an infinite loop. The loop body is Pause[Beep[];60/#] which is just a golfy way of writing Beep[];Pause[60/#] where # is the function argument.

If it's admissible for the solution to blow up the call stack eventually, we can save one byte with a recursive solution:

#0[Beep[];Pause[60/#];#]&


JavaScript (Node.js),  286 284 270  266 bytes
Pieces and positions are 0-indexed. Angles are in \$[0..3]\$.

a=>a.map(([p,r,x])=>(g=y=>y>3?g(+!Y--):b[Y+y]&(m[y]=('0x'+`717433667233ff4717333327661${1e12+0x5e7056a566ffff57efa65n.toString(4)}`[(p*2+r*56+y*99+13)%113])<<x)?m.map(v=>(g=x=>v&&g(x+1,H[x]=v&1?Y:~~H[x],v>>=1))(0,b[++Y]|=v)):g(y+1))(Y=a.length*4),m=[b=[-1]],H=[])&&H

Try it online!
or try an enhanced version that also displays the final board.
Shape encoding
All pieces are stored as exactly 4 nibbles (4x4 bits) with the rows sorted in reverse order and the leftmost pixel mapped to the least significant bit. In other words, the binary representation of the shape is mirrored both vertically and horizontally.
Example:

Hash function and lookup table
Given a piece \$p \in [0..6]\$, a rotation \$r \in [0..3]\$ and a row \$y \in [0..3]\$, we use the following hash function to get the index \$n\$ of the corresponding bitmask from a lookup table:
$$n=(2p+56r+99y+13)\bmod 113$$
Only the first \$82\$ entries are explicitly stored. Everything else is set to \$0\$.
These entries are packed as:
`717433667233ff4717333327661${1e12+0x5e7056a566ffff57efa65n.toString(4)}`

which expands to the following 82 nibbles:
"717433667233ff47173333276611000000000000113213001112221112123333333311133233221211"

Using hexadecimal in the final format is only required for the two horizontal representations of the \$I\$ piece, hence the "ff" in the above string.
The parameters of the hash function were brute-forced in a way that optimizes leading and trailing zeros. The fact that the string can be compressed some more by using 1e12 for the zeros in the middle and a conversion from base-16 to base-4 for the right part is just a welcome but unexpected side effect. :-)
Here is a demonstration of the unpacking process for all pieces and all rotations.
Commented
a => a.map(([p, r, x]) => (     // for each piece p with rotation r and position x:
  g = y =>                      //   g = recursive function taking y
    y > 3 ?                     //   if y is greater than 3:
      g(+!Y--)                  //     reset y to 0, decrement Y and try again
    :                           //   else:
      b[Y + y] & (              //     test if we have a collision of the board with
        m[y] =                  //     the y-th row m[y] of the current piece
          ('0x' + `717...`[     //     which is extracted from a lookup table
            (p * 2 + r * 56 +   //     using the hash function described in the
             y * 99 + 13) % 113 //     previous paragraph
          ]) << x               //     and shifted to the left according to x
      ) ?                       //     if we have a collision:
        m.map(v => (            //       we iterate again on the piece rows stored in m[]
          g = x =>              //         g = recursive function taking x
            v &&                //         if v is not equal to 0:
            g(                  //           do a recursive call:
              x + 1,            //             increment x
              H[x] =            //             update the height at x:
                v & 1 ?         //               if this bit is set:
                  Y             //                 set it to Y
                :               //               else:
                  ~~H[x],       //                 leave it unchanged or force it to 0
                                //                 if it was still undefined
              v >>= 1           //             shift v to the right
            )                   //           end of recursive call
          )(0,                  //         initial call to g with x = 0
               b[++Y] |= v)     //         increment Y and copy the piece row to the board
        )                       //     end of map()
      :                         //   else (no collision):
        g(y + 1)                //     do a recursive call to test the next row
  )(Y = a.length * 4),          //   initial call to g with y = Y = 4 * the number of pieces
                                //   (assuming the worst case: piled vertical I pieces)
  m = [b = [-1]], H = []        //   initialize m[], b[] and H[]
                                //   we set a full line at the bottom of b[]
) && H                          // end of map(); return H[]


brainfuck, 60 56 bytes

,[>++++++++[-<----<++++>>]<[>>]<[[<]>.[[-]>[.>]<[<]>]],]

Try it online!

Requires a trailing space and prints a leading space. Both of these could be circumvented, but that ends up at 112 bytes.

Explanation

,[  Loop over each byte of input
  Tape: 32 w o r-32 d'
  >++++++++[-<----<++++>>]   Subtract 32 from the character and add 32 to the previous char
  Tape: 32 w o r d-32 0'
  <[>>]<   If the last character was a space
  Tape: 32 w o r d-32 0'
  or
  Tape: 32 w o r d' space-32
  [
    [<]>.   Move to the end of the word and print out the space
    [   Loop over each letter
      [-]    Remove the first letter (initially space)
      >[.>]  Print the rest of the word
      <[<]>  Move back to the first letter
    ]
    Tape: clear
  ]
,]  Get the next byte of input


Pyth, 9 bytes

Borrowing the x & (x*2) != 0 algorithm from @alephalpha
Borrowing Pyth boilerplate from @Jakube

My first attempt at Pyth:
f!.&TyThQ

Try it here
               implicit: Q = input()
f      hQ      find the first integer T >= Q + 1,
               that satisfies the condition:
 !.&TyT        T & (T * 2) is 0


Reverse-Engineer the N-Bonacci sequence[s]

Ruby, 94
I'm quite surprised how far I've been able to golf this within the same algorithm!  I started with over 200!
->a{1.step.find{|s|x=[1]*(s+z=a.size)
x<<x[-s,s].inject(:+)while x.max<a.max&&s>1
x[-z,z]==a}}

Ungolfed:
l=->a{
    # ooh! a built-in infinite incrementer!
    1.step.find{|s|
        # if n == 1, z is important, otherwise s.
        x=[1]*(s+z=a.size)
        ## add the next nacci number until we hit or overshot max.
        ## if s == 1, we don't increment, so don't bother
        x<<x[-s,s].inject(:+)while x.max<g&&s>1
        # eval to true if there's a match, false if not
        x[-z,z]==a
    }
}


Pyth, 11 10 bytes
"u+G]G"z\]

"Answers must be at least 30 characters."


Write a program to compose a quine of a specified length

GolfScript → GolfScript: (4 + 0 + 0) / 2 = 2

~1`*

Program length: 4
Minimum supported size: 0
Maximum supported size: unbounded
All sizes supported: yes

This program simply reads an integer n from its input, and outputs an n-digit integer consisting of n 1 digits.  For example, the input 5 yields the output 11111.  In GolfScript, any integer literal (without leading zeros) is a quine, and since GolfScript integers can be arbitrarily large, the maximum supported length is only bounded by the amount of memory available.

For the input 0, the code outputs an empty program, which is also a quine in GolfScript.

Ps. The generated quines work for several other languages too, including PHP.


Japt, 6 bytes
Works with strings or integers.
æøV kV

Test it

Explanation
Implicit input of array U and string/integer V.
æ

Get the first element (subarray) in U that ...
øV

Contains V.
kV

Remove V and implicitly return the resulting single-element array.


A greeting bot for a colleague from work

JavaScript (ES6), 43 bytes

f=(D,t,d)=>5>>d&t>749&t<811&&!f[D]*(f[D]=1)

Try it online!
Input

the date as a string in yyyymmdd format
the time as a string in hhmm format
the day of week as a 0-indexed integer, with 0 = Tuesday, 1 = Wednesday, ..., 6 = Monday

Output
Returns 0 or 1.
Commented
f = (            // named function, as the underlying object will be used as storage
  D,             // D = date (string)
  t,             // t = time (string)
  d              // d = day of week (integer)
) =>             //
  5              // 5 is 0000101 in binary, where 1's are set for Tuesday and Thursday
  >> d &         // test the relevant bit for the requested day of week
  t > 749 &      // test whether we are in the correct time slot
  t < 811        //
  && !f[D] *     // make sure that this date was not already invoked at a correct time
  (f[D] = 1)     // and store it in the underlying object of f()


APL (155)

∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕

This defines an operator ∆ 'bag', which defines bag operations for given functions. I.e. +∆ would be addition. It then reads a line from the keyboard and evaluates it as an APL expression.

The functions are:

+∆, addition
-∆, subtraction
×∆, multiplication
÷∆, division
⊂∆, counting
≡∆, equivalence (though due to golfing any unrecognized function will do equivalence)

Explanation:

∆←{...}: define an operator ∆:

O←⍺⍺: store the given function in O (⎕CR won't work with ⍺⍺ directly)
O←⎕CR'O': get the string representation of that function
'+'=O...:: for addition,

⍺,⍵: join the two lists together
R[⍋R←...]: and sort the result

'-'=O:: for subtraction,

⍺{...}⍵: run the following recursive function:

⍵≡⍬:⍺: if the subtrahend is empty, return the minuend
⍺/⍨(⍳⍴⍺)≢⍺⍳⊃⍵∇1↓⍵: otherwise, remove the first element of the subtrahend from both the subtrahend and the minuend and try again

(⍬=⍴⍵)∧K←'×'=O: for multiplication, and if the right argument is not a bag:

⍵/⍺: replicate each element in the left argument by the right argument

K:: ...and if the right argument is a bag:

⍺/⍵: replicate each element in the right argument by the left argument (this is so that multiplication is commutative)

'÷'=O:: for division,

⍵≤⍺∘.+⍺: see which elements in ⍺ occur at least ⍵ times,
⍺/⍨: select those from ⍺,
∪: and remove all duplicates from that list

'⊂'=O:: for counting,

⍵{...}⍺: run the following recursive function:

(∪⍺)≢∪⍵:0: if one list contains elements the other doesn't, the result is 0
1+⍺∇⍵-∆⍺: otherwise, subtract the dividend from the divisor, try again, and increment the result.

⋄: if none of the above, do the equivalence test:

⍺[⍋⍺]≡⍵[⍋⍵]: sort both lists and see if they are equal

⎕: read an expression from the keyboard, evaluate it, and output the result.

Test cases:

      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 2 2 3 +∆ 1 2 4
1 1 2 2 2 3 4
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 2 2 4 -∆ 1 2
2 4
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 2 3 -∆ 2 4
1 3
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 2 3 3 4 ×∆ 3
1 1 1 2 2 2 3 3 3 3 3 3 4 4 4
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      2 ×∆ 1 3
1 1 3 3
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 1 2 2 2 ÷∆ 2
1 2
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 2 2 3 3 3 ÷∆ 3
3
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 1 2 2 2 2 3 3 3 ⊂∆ 1 2 3
2
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      3 2 1 2 ≡∆ 1 2 2 3
1
      ∆←{O←⍺⍺⋄'+'=O←⎕CR'O':R[⍋R←⍺,⍵]⋄'-'=O:⍺{⍵≡⍬:⍺⋄(⍺/⍨(⍳⍴⍺)≠⍺⍳⊃⍵)∇1↓⍵}⍵⋄(⍬≡⍴⍵)∧K←'×'=O:⍵/⍺⋄K:⍺/⍵⋄'÷'=O:∪⍺⌿⍨⍵≤+/⍺∘.=⍺⋄'⊂'=O:⍵{(∪⍺)≢∪⍵:0⋄1+⍺∇⍵-∆⍺}⍺⋄⍺[⍋⍺]≡⍵[⍋⍵]}⋄⎕
⎕:
      1 2 3 ≡∆ 1 2 2 3
0


Wolfram Language (Mathematica), 16+83=99 bytes

Library import statement (16 bytes):

<<Combinatorica`

Actual function body (83 bytes):

Length@HamiltonianCycle[MakeGraph[#~Position~1~Join~{1>0},##||Norm[#-#2]==1&],All]&

Try it online!

Note that the question just ask for the number of Hamiltonian path in the graph.

However, (for some reason) the HamiltonianPath function doesn't really work with directed graph (example). So, I used the workaround described in this Mathematica.SE question:

Add an vertex (called True) that is connected to all other vertices.
Count the number of Hamiltonian cycle on the resulting graph.

The graph is constructed using MakeGraph (annoyingly there are no directly equivalent built-in), using the boolean function ##||Norm[#-#2]==1&, which returns True if and only if one of the arguments is True or the distance between the two vertices are 1.

Tr[1^x] cannot be used instead of Length@x, and <2 cannot be used instead of ==1.

HamiltonianPath can be used if the graph is undirected, with the function body takes 84 bytes (exactly 1 byte more than the current submission):

Length@HamiltonianPath[MakeGraph[#~Position~1,Norm[#-#2]==1&,Type->Undirected],All]&

Try it online!


2016 Time Capsule String: Climb The Integer Ladder

CJam, 23 snippets, 11 wildcards, 45 bytes

Q!
Q!)
Z
4
4)
6
7
8
9
A
B
C
D
E
F
G
H
I
J
QT|T+e`
O!)1
L!`e`(:)
6mf

Try it online! | wildcard counter (ignore the newlines)


Something that one must know before starting to golf:

In MATLAB calculations a character behaves the same as its ascii code.

'abc' - 'a'  % Returns: [0 1 2]
'123' - '0'  % Returns: [1 2 3]
'“' == 8220  % Returns: 1 (logical)
'a':'e'==100 % Returns: [0 0 0 1 0] (logical)


Implement multiplication by a constant with addition and bit shifts

Python - 414 393 331

This is my entry, which finds the least possible addition/subtraction operations, and subsequently evaluates to a C expression. Not sure it is optimal as multiplication of subexpressions may offer less operations.

import itertools as l
def w(N,s=''):
 for k,v in enumerate(min([t for t in l.product((1,0,-1),repeat=len(bin(N))-1)if sum([v*2**k for k,v in enumerate(t)])==N],key=lambda t:sum(abs(k)for k in t))):
  if v!=0:s+='{:+d}'.format(v)[0];s+='((x)<<{})'.format(k)if k>0 else'(x)'
 return '#define XYZZY{}(x) ({})'.format(N,s.lstrip('+'))

For the cases 2, 10, 100, 14043, 65535:

#define XYZZY2 (((x)<<1))
#define XYZZY10 (((x)<<1)+((x)<<3))
#define XYZZY100 (((x)<<2)+((x)<<5)+((x)<<6))
#define XYZZY14043 (-(x)-((x)<<2)-((x)<<5)-((x)<<8)-((x)<<11)+((x)<<14))
#define XYZZY65535(x) (-(x)+((x)<<16))

The final 65535 took around 11 minutes to compute. Suggestions for improvement (also speedwise) are welcome :-). Thanks to mbomb007 and plg for golfing improvements.


05AB1E, score: 22 49 69 (5 4 bytes)
ê¥êн

Uses the 05AB1E encoding, where the bytes have the codepoints [234,165,234,14] (ê¥ are 69 apart).
+27 score by porting @Arnauld's approach of sorting.
+20 score (and even -1 byte at the same time) thanks to @Grimmy.
Try it online or verify all test cases.
Explanation:

ê     # Sort and uniquify the (implicit) input-list (in ascending order)
 ¥    # Get the deltas of this sorted list
  ê   # Sort and uniquify this again
   н  # Pop this list and push its first item
      # (which is output implicitly as result)


Jelly,  39  37 bytes
Soon to be crushed by MATL and, quite possibly, APL
p`œc⁸ḣ1ạ§ỊẸʋƇ@;QɗƬƊṪṢƊƑƇŒṬZṚŒṪƲƬṂ$€QL

Try it online! (It's pretty slow - a(6) took ~30 minutes locally!)
To see them instead try this (L -> ŒṬ€G€j⁾¶¶).
How?
Builds all index lists, where each represents the locations of 1s on a grid of 1s and 0s, up to those for a square of side n, filters for those that have their 1s fully connected, then selects the "minimal" of each after any amount of rotation + vertical translation, and finally de-duplicates and yields the length.
   p`œc⁸ḣ1ạ§ỊẸʋƇ@;QɗƬƊṪṢƊƑƇŒṬZṚŒṪƲƬṂ$€QL - Link: integer, n
   A....B..................C............ - break down below

A: p`œc⁸ - Get all ways to have n 1s on an n*n grid as multidimensional indices
    `    - use n as both arguments of:
   p     -   Cartesian product -> all pairs of [1..n] - these are in sorted order
       ⁸ - chain's left argument, n
  œc     - combinations (no replacement) - ...and so each of these are in sorted order

B: ḣ1ạ§ỊẸʋƇ@;QɗƬƊṪṢƊƑƇ - Keep only the fully-connected ones (call input "All")
                     Ƈ - filter keep those for which:
                    Ƒ  -   is invariant under:
                   Ɗ   -     last three links as a monad:
                Ɗ      -       last three links as a monad:
    1                  -         one
   ḣ                   -         head to index - i.e. [firstPair] (initial "Current")
               Ƭ       -         collect up while distinct, applying:
              ɗ        -           last three links as a dyad - i.e. f(Current, All):
           @           -             with swapped arguments - i.e. f(All, Current):
          Ƈ            -               filter keep those (of All) for which:
         ʋ             -                 last four links as a dyad - i.e. f(All, Current):
     ạ                 -                   absolute difference (vectorises)
      §                -                   sum each
       Ị               -                   insignificant? (effectively "in (0,1)?")
        Ẹ              -                   any? - i.e. any are neighbours/same?
            ;          -             concatenate (the result with Current)
             Q         -             deduplicate (-> Current for the next Ƭ-loop)
                 Ṫ     -       tail
                  Ṣ    -       sort

C: ŒṬZṚŒṪƲƬṂ$€QL - Count the distinct results
             €   - for each:
            $    - last two links as a monad:
          Ƭ      -   collect up while distinct, applying:
         Ʋ       -     last four links as a monad:
   ŒṬ            -       2d array from multidimensional indices
     Z           -       transpose
      Ṛ          -       reverse (transpose + reverse = rotate 1/4 anti-clockwise)
       ŒṪ        -       truthy multidimensional indices
           Ṃ     -   minimum
              Q  - de-duplicate
               L - length


Common Lisp, 88 82 80 bytes
(format t"~@(~{~R~^, ~}~).
~:*~@(~{~:R~^, ~}~)."(loop as i to 99 collect(1+ i)))

(It is part of the language, I hope you don't mind)
Output
One, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty-one, twenty-two, twenty-three, twenty-four, twenty-five, twenty-six, twenty-seven, twenty-eight, twenty-nine, thirty, thirty-one, thirty-two, thirty-three, thirty-four, thirty-five, thirty-six, thirty-seven, thirty-eight, thirty-nine, forty, forty-one, forty-two, forty-three, forty-four, forty-five, forty-six, forty-seven, forty-eight, forty-nine, fifty, fifty-one, fifty-two, fifty-three, fifty-four, fifty-five, fifty-six, fifty-seven, fifty-eight, fifty-nine, sixty, sixty-one, sixty-two, sixty-three, sixty-four, sixty-five, sixty-six, sixty-seven, sixty-eight, sixty-nine, seventy, seventy-one, seventy-two, seventy-three, seventy-four, seventy-five, seventy-six, seventy-seven, seventy-eight, seventy-nine, eighty, eighty-one, eighty-two, eighty-three, eighty-four, eighty-five, eighty-six, eighty-seven, eighty-eight, eighty-nine, ninety, ninety-one, ninety-two, ninety-three, ninety-four, ninety-five, ninety-six, ninety-seven, ninety-eight, ninety-nine, one hundred.
First, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, eighteenth, nineteenth, twentieth, twenty-first, twenty-second, twenty-third, twenty-fourth, twenty-fifth, twenty-sixth, twenty-seventh, twenty-eighth, twenty-ninth, thirtieth, thirty-first, thirty-second, thirty-third, thirty-fourth, thirty-fifth, thirty-sixth, thirty-seventh, thirty-eighth, thirty-ninth, fortieth, forty-first, forty-second, forty-third, forty-fourth, forty-fifth, forty-sixth, forty-seventh, forty-eighth, forty-ninth, fiftieth, fifty-first, fifty-second, fifty-third, fifty-fourth, fifty-fifth, fifty-sixth, fifty-seventh, fifty-eighth, fifty-ninth, sixtieth, sixty-first, sixty-second, sixty-third, sixty-fourth, sixty-fifth, sixty-sixth, sixty-seventh, sixty-eighth, sixty-ninth, seventieth, seventy-first, seventy-second, seventy-third, seventy-fourth, seventy-fifth, seventy-sixth, seventy-seventh, seventy-eighth, seventy-ninth, eightieth, eighty-first, eighty-second, eighty-third, eighty-fourth, eighty-fifth, eighty-sixth, eighty-seventh, eighty-eighth, eighty-ninth, ninetieth, ninety-first, ninety-second, ninety-third, ninety-fourth, ninety-fifth, ninety-sixth, ninety-seventh, ninety-eighth, ninety-ninth, one hundredth.

Explanations
See Formatted Output to Character Streams.

(format t "<control string>" <arguments>) formats the control string according to the (variadic) arguments and prints to standard output (because t)

(loop ...) builds the list of integers from 1 to 100

~@( ... ~) capitalizes the string returned by the inner control string

~{ ... ~} iterates over the current argument and applies the inner formatting to each element

Inside the iteration, everything that follows ~^ is not printed on the last iteration: this is used to add the comma-space separator between elements.

~R outputs current argument as a cardinal

~:R outputs current argument as an ordinal

~% outputs a new line

~:* reset the current argument to be processed as the previous one, which is used here to reuse the list of integers a second time.

Saved 2 bytes thanks to PrzemysławP.


Jelly, 5 bytes
rŒp§ċ

A dyadic Link accepting the lower bound tuple on the left and the total on the right which yields the count.
Try it online!
How?
rŒp§ċ - Link: T, N       e.g. [2,1,3], 5
r     - inclusive range       [[2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]]
 Œp   - Cartesian product     [[2,1,1],[2,1,2],[2,1,3],[2,1,4],[2,1,5],[2,2,1],...,[5,5,4],[5,5,5]]
   §  - sums                  [ 4,      5,      6,      7,      8,      5,     ..., 14,     15]
    ċ - count (Ns)            2


Pyth, 104 bytes
f!s[nhd-8xd3@.+d+3@d1nh@d2/d4nh@d3/d0!&/3@d4!-/d0/d@d4!-10x_d1@d5n@d6a4@.+d6n@d7@d@d7!+3@d8@ds/LdS3)^U5T

It... uh... takes a while to run. Try it online... if the server doesn't time out or run out of memory.
Explanation coming SoonTM.  Prints all the valid solutions as a 0-based list (ten elements long in which A is represented by 0, B by 1, and so on).
This is a naive solution that can probably be golfed a lot.  Just wanted to get something out there.


substring conversion (in Haskell). Can you beat this?

Perl, 44 chars

Two different tweaks can get it to this length, one suggested by Primo:

s/#\K[\da-f]{6}/sprintf"%06x",~hex ff.$&/eg

Another one by playing around with the /ee modifier:

s/#\K[\da-f]{6}/"sprintf'%06x',~0xff$&"/eeg

Requires -p command line switch (1 char included in count).

Works for lower-case hex numbers (as in example).  An i switch added to the regex would make it work for upper-case as well (though not preserving the case of the original number).


Husk, 15 bytes

TṪS`?' €…"AZ"ġ>

Try it online!

Explanation

TṪS`?' €…"AZ"ġ>  Implicit input, e.g. "HELLO"
             ġ>  Split into strictly increasing substrings: x = ["H","EL","LO"]
        …"AZ"    The uppercase alphabet (technically, the string "AZ" rangified).
 Ṫ               Outer product of the alphabet and x
  S`?' €         using this function:
                   Arguments: character, say c = 'L', and string, say s = "EL".
       €           1-based index of c in s, or 0 if not found: 2
  S`?'             If this is truthy, then c, else a space: 'L'
                 This gives, for each letter c of the alphabet,
                 a string of the same length as x,
                 containing c for those substrings that contain c,
                 and a space for others.
T                Transpose, implicitly print separated by newlines.


Write The Shortest Program to Calculate Height of a Binary Tree

Jelly, 3 bytes

ŒḊ’

A monadic Link accepting a list representing the tree: [root_value, left_tree, right_tree], where each of left_tree and right_tree are similar structures (empty if need be), which yields the height.

Try it online!

How?

Pretty trivial in Jelly:

ŒḊ’ - Link: list, as described above
ŒḊ  - depth
  ’ - decremented (since leaves are `[value, [], []]`)


Jelly, 5 bytes
:Æṣ’$

:       integer divide
Æṣ’$    the decremented divisor sum

This uses \$\lfloor\frac{n}{\sigma(n)-n-1}\rfloor\$ instead of \$\frac{n-1}{\sigma(n)-n-1}\$, but it still works because \$\frac{1}{\sigma(n)-n-1}\$ can never be greater than or equal to 1.
Try it online!


Photomosaics or: How Many Programmers Does it Take to Replace a Light Bulb?

Mathematica, with control for granularity
This uses the 48 x 48 pixel photos, as required.  By default, it will swap those pixels for a corresponding 48x48 pixel square from the image to be approximated.
However, the size of the destination squares  can be set to be smaller than 48 x 48, allowing for greater fidelity to detail.  (see the examples below).
Preprocessing the palette
collage is the image containing the photos to serve as the palette.
picsColorsis a list of individual photos paired with their mean red, mean green, and mean blue values.
 targetColorToPhoto[]` takes the average color of the target swath and finds the photo from the palette that best matches it.
parts=Flatten[ImagePartition[collage,48],1];
picsColors={#,c=Mean[Flatten[ImageData[#],1]]}&/@parts;
nf=Nearest[picsColors[[All,2]]];

targetColorToPhoto[p_]:=Cases[picsColors,{pic_,nf[p,1][[1]]}:>pic][[1]]

Example
Let's find the photo that best matches RGBColor[0.640, 0.134, 0.249]:

photoMosaic
photoMosaic[rawPic_, targetSwathSize_: 48] :=
 Module[{targetPic, data, dims, tiles, tileReplacements, gallery},
  targetPic = Image[data = ImageData[rawPic] /. {r_, g_, b_, _} :> {r, g, b}];
  dims = Dimensions[data];
  tiles = ImagePartition[targetPic, targetSwathSize];
  tileReplacements = targetColorToPhoto /@ (Mean[Flatten[ImageData[#], 1]] & /@Flatten[tiles, 1]);
  gallery = ArrayReshape[tileReplacements, {dims[[1]]/targetSwathSize,dims[[2]]/targetSwathSize}];
  ImageAssemble[gallery]]

`photoMosaic takes as input the raw picture we will make a photo mosaic of.
targetPic will remove a fourth parameter (of PNGs and some JPGs), leaving only R, G, B.
dims are the dimensions of targetPic.
tiles are the little squares that together comprise the target picture.
targetSwathSize is the granularity parameter; it defaults at 48 (x48).
tileReplacements are the photos that match each tile, in proper order.
gallery is the set of tile-replacements (photos) with the proper dimensionality (i.e. the number of rows and columns that match the tiles).
ImageAssembly joins up the mosaic into a continuous output image.

Examples
This replaces each 12x12 square from the image, Sunday, with a corresponding 48 x 48 pixel photograph that best matches it for average color.
photoMosaic[sunday, 12]

Sunday (detail)

photoMosaic[lightbulb, 6]

photoMosaic[stevejobs, 24]

Detail, stevejobs.

photoMosaic[kiss, 24]

Detail of the Kiss:

photoMosaic[spheres, 24]


JavaScript (ES6),  106 104  100 bytes
Saved 2 bytes thanks to @Shaggy

a=>a.filter(n=>n,[...a].map((v,i)=>a[a[p>v&(n=~~a[i+1])<p?k:i+(k=i,n>v&p<n)]+=x=a[i],p=v,i]-=x,p=0))

Try it online!
Commented
We first update the original input array a[] by iterating on a copy of it. During this step, all values 'attracted' by other ones are set to \$0\$.
Because the array is parsed from left to right, we can just add \$a_i\$ to \$a_{i+1}\$ whenever a value is attracted by its right neighbor.
Example: \$4\rightarrow5\rightarrow6\$ is turned into \$[0,\color{red}9,6]\$ and then \$[0,0,\color{red}{15}]\$.
But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the first attractor \$a_k\$ of this sequence (with \$k<i\$) rather than simply \$a_{i-1}\$.
Example: \$6\leftarrow5\leftarrow4\$ is turned into \$[\color{red}{11},0,4]\$ and then \$[\color{red}{15},0,0]\$.
[...a]                 // create a copy of a[]
.map((v, i) =>         // for each value v in a[] at position i:
  a[                   //   this statement updates a[i]:
    a[                 //     this statement updates either a[i] or an adjacent value:
      p > v &          //       if the previous value p is greater than v
      (n = ~~a[i + 1]) //       and the next value n
      < p ?            //       is less than p (attraction to the left):
        k              //         use k (k is initially undefined, but this code cannot
                       //         be triggered during the first iteration)
      :                //       else:
        i + (          //         use either i or i + 1:
          k = i,       //           set k to i
          n > v &      //           use i + 1 if n is greater than v
          p < n        //           and p is less than n (attraction to the right)
        )              //
    ] += x = a[i],     //     add x = a[i] to the entry defined above
    p = v,             //     update the previous value to v
    i                  //     actual index to update a[i]
  ] -= x,              //   subtract x from a[i]
  p = 0                //   start with p = 0
)                      // end of map()

We then filter out all entries equal to \$0\$.
a.filter(n => n)


JavaScript (ES6), 35 bytes

a=>a.filter((e,i)=>e|a[i-1]|a[i+1])

Works on floats too for two extra bytes.


Python

This question is boring.  I'd rather sleep.

from time import sleep
sleep(input())

Input a number.


JavaScript (ES6),  103  100 bytes
See also my other answer for less bitwise operations, more maths, and a closed-form expression
Both functions expect and return an integer.
8-bit → 12-bit ( 56  53 bytes)

f=n=>n&&(w=f(n-1),w+=(x=w&w-1)&x-1?w-x:1)+(w&w/2&w/4)

Try it online!
How?
This is a recursive function that computes the next valid 12-bit word \$w_{n+1}\$ directly from the previous valid word \$w_n\$.
Step 1: Update w according to the total number of bits set
Given w from the previous iteration we first compute:
x = w & (w - 1)

which is w without its least significant bit.
Likewise, we remove the least significant bit from x by doing:
x & (x - 1)

If the result is zero, we just increment w.
If the result is non-zero, it means that there are already 3 bits set in w and we are not allowed to insert a 4th one. In that case, we add the least significant bit of w (which is w - x) to w. This results in at most as many bits set in the updated value than in the original one, or less in case of carry propagation.
Examples:
110010 +  10 -> 110100
101100 + 100 -> 110000

Step 2: Update w according to the number of consecutive bits set
We now have to make sure that there are not 3 consecutive bits set in w. We do that by adding the result of a bitwise AND between w, w / 2 and w / 4.
Example:
01110 + (01110 & 00111 & 00011) -> 01110 + 10 -> 10000

12-bit → 8-bit (47 bytes)

f=w=>w&&!(w&w/2&w/4|(y=(x=w&--w)&x-1)&y-1)+f(w)

Try it online!
How?
In this version, we decrement w at each iteration and increment the final result whenever w is a valid 12-bit word. We stop when w = 0.
We use the following methods to test the validity of w. They are similar to the ones used above.

we compute w & w / 2 & w / 4 to make sure that there are not 3 consecutive bits set
we compute a chain of three w & (w - 1) to make sure that there are no more than 3 bits set


APL (Dyalog Classic), 55 bytes

{⍵⌊d⍴1+⌊/¨⌷∘⍵¨¨a/⍨¨Ö↓2=×/↑|∘.-⍨a←,⍳d}⍣≡0@(⊂⌽⎕)⊢9⍴⍨d←8 8

{⍵⌊d⍴1+⌊/¨⌷∘⍵¨¨a/⍨¨Ö↓2=×/↑|∘.-⍨a←,⍳d}⍣≡0@(⊂⌽⎕)⊢9⍴⍨d←8 8
                                       0@(⊂⌽⎕)⊢9⍴⍨d←8 8 ⍝ create an 8x8 grid of 9s with a 0 at the start position
                           ∘.-⍨a←,⍳d                    ⍝ all differences between coordinates
                     2=×/↑|                             ⍝ is 2 equal to the product of the absolute values?
               a/⍨¨Ö↓                                   ⍝ filter where true (finds knight moves)
          ⌷∘⍵¨¨                                         ⍝ index into the board
     1+⌊/¨                                              ⍝ 1 plus the minimum (finds minimum distance)
   d⍴                                                   ⍝ 8x8 reshape
 ⍵⌊                                                     ⍝ the minimum of the new and old moves
{                                   }⍣≡                 ⍝ apply until converged (minimum distances found)

Try it online!


Retina, 61 60 59 bytes

G`[HCDS].
^$
23456789TJQK
/^2/&L$`.
$&H¶$&D¶$&C¶$&S
@V`
O?`

Try it online! Edit: Saved 1 2 bytes thanks to @MartinEnder. Explanation:

G`[HCDS].

Delete all unreversed cards. This should leave one reversed card or no cards.

^$
23456789TJQK
/^2/&L$`.
$&H¶$&D¶$&C¶$&S

If the input is (now) empty, create a pack of cards.

@V`

Randomly select one card and reverse it (unreverses the single reversed card).

O?`

Shuffle the card(s).


Charcoal, 52 34 33 bytes

Ｎθ↶ＦＮＦ⊗⊕θ«+⊖⊗×⊕﹪κ²∨↔⁻θ∧κ⊖κ¹¿›κθ↷↶

Try it online! Link is to verbose version of code. Explanation:

Ｎθ

Input the size of the meander.

↶

Pivot upwards as the drawing starts at the right and works left.

ＦＮ

Loop over the desired number of meanders.

Ｆ⊗⊕θ«

Loop over the segments of the meander.

+

Print a +.

∨↔⁻θ∧κ⊖κ¹

Compute the kth element of the list \$ n, n, n-1, n-2 ... 3, 2, 1, 1, 1, 2, 3, ... n \$.

⊖⊗×⊕﹪κ²...

Alternate between doubling and quadrupling the lengths since the horizontal lines are twice as long, but decrement the result before printing to take account of the + that was just printed.

¿›κθ↷↶

Pivot appropriately for the next segment.


Find distance between the closest 3D points

R, 34 bytes

function(...)min(dist(rbind(...)))

Try it online!
This is a nice opportunity to use R's ... syntax to define a function that can accept a variable number of arguments; in this case, the x,y,z coordinates of each point.
The dist function calculates the pairwise distance between all rows of a matrix, using a chosen method - luckily, the default is 'euclidean' and so isn't specified in this case.
Of course, it could be even shorter if we allow the input to already be combined-together as a matrix, but this wouldn't be so neat...
R, 23 bytes

function(m)min(dist(m))

Try it online!


05AB1E, 13 bytes

Ò.»â€˜ʒ÷DÙQ}θ

Try it online!

A port of my Pyth answer.

Ò gets the prime factÒrs of each.
.» folds a dyadic command, â (cârtesiân product) between each two elements in the list from right to left with opposite right/left operands.
€˜ flattens €ach.
ʒ...} filtʒrs those which satisfy the following condition:

÷ pairwise integer division with the input.
D Duplicate (pushes two copies of the item to the stack).
Ù removes duplicate elements, keeping a ÙniqÙe occurrence of each element.
Q checks for eQuality.

θ gets the last element.


Bash, 41, 39, 34, 33, 26 bytes
EDIT:

Converted from function to a script
One byte off by removing the ignore case flag
Replaced wc -l with grep -c, saving 5 bytes. Thanks @Riley !

A rather trivial solution in bash + coreutils
Golfed
bc -l<<<`grep -c $1`/${#1}

Test
>cat /usr/share/dict/words| ./test ulous
7.60000000000000000000

>grep -i ulous /usr/share/dict/words | wc -l
38


JavaScript (ES6), 153 176 bytes
EDIT: In non-strict mode, JS interprets 0-prefixed numerical expressions as octal (e.g. 017 is parsed as 15 in decimal). This is a fixed version that supports leading zeros.

let f =

s=>[...Array(3**(l=s.length,l-1))].map((_,n)=>m=eval((x=s.replace(/./g,(c,i)=>c+['','+','-'][o=(n/3**i|0)%3,j-=!o,o],j=l)).replace(/\b0+/g,' '))-100|j>m?m:(S=x,j),m=l)&&m+' '+S

console.log(f("123456789"))
console.log(f("20172117"))


Python 2, 128 119 105 bytes
def F(p):
 v=n=1
 for r in map(None,*p.split("\n")):A,B=map(r.count,"()");n+=B-A;v*=n<2>A+B
 return n*v>0

Did you know that you can map None in Python 2?
Explanation
We want to start by transposing the Prelude so that columns become rows. Usually we would do this with zip, but since zip truncates to the shortest row length and itertools.zip_longest is far too long for code-golf, it seems like there's no short way to do what we want...
Except for mapping None:
>>> print map(None,*[[1,2,3],[4],[5,6]])
[(1, 4, 5), (2, None, 6), (3, None, None)]

Unfortunately (or rather, fortunately for all non-golf purposes), this only works in Python 2.
As for n and v:

n acts like a stack, counting 1 - <number of unmatched '(' remaining>. For every ( we see we subtract 1, and for every ) we see we add 1. Hence if n >= 2 at any point, then we've seen too many )s and the program is invalid. If n doesn't finish on 1, then we have at least one unmatched ( remaining.
v checks validity, and starts at 1. If the program is ever invalid (n >= 2 or A+B >= 2), then v becomes 0 to mark invalidity.

Hence if the program is valid, then by the end we must have n = 1, v = 1. If the program is invalid, then by the end we must either have v = 0, or v = 1, n <= 0. Therefore validity can be succinctly expressed as n*v>0.
(Thanks to @feersum for a multitude of good suggestions which took off 14 bytes!)
Previous, more readable submission:
def F(p):
 p=map(None,*p.split("\n"));v=n=0
 for r in p:R=r.count;A=R("(");B=R(")");n+=A-B;v|=A+B>1or n<0
 return n<1>v


Not-PHP Python (73):

[a[:g]+a[g+1:]==(a[:g]+a[g+1:])[::-1] for g in range(len(a))].index(1)

Where a is the string you want to check. This, however, throws an error if you can't turn it in an palindrome. Instead, you could use

try:print [a[:g]+a[g+1:]==(a[:g]+a[g+1:])[::-1] for g in range(len(a))].index(True)
except ValueError:print -1

EDIT: No, wait, it does work!

try: eval("<?php $line = fgets(STDIN); ?>")
except: print [a[:g]+a[g+1:]==(a[:g]+a[g+1:])[::-1] for g in range(len(a))].index(1)

Thanks, this does indeed raise the php-contents of this script by about 25% (that's what you want, right?)


I'm not the language you're looking for!

C89/C99, 171 152 136 114 111 107 105 bytes

Thanks at @Hurkyls, @Qwertiys, @jimmy23013 and @MD XF for your hints.

golfed version:

c;main(){c=-4.5//**/
-4.5;printf("This program wasn't written in C%d, it was built for C%d!",90-c,98+c);}

ungolfed version:

c;

main()
{
    c = -4.5//**/
    -4.5;
    printf("This program wasn't written in C%d, it was built for C%d!",90-c,98+c);
}

Little description:

C versions previous C99 just had the multiline comment like this:

/*foo*/

with C99 the single line comment was introduced. like this:

//foo

so if you compile a line like this:

c =-4.5//**/
-4.5;

the for the c99 compiler compiling-related code would be:

c = -4.5 -4.5;

while the for a c89 compiler relevant code would be:

(as the first / isn't part of a comment and therfor treat as operator)

c = -4.5 / -4.5;


Swift 1.2, 812 588 670 bytes

Edit: Removed 224 bytes by replacing the large arrays of numbers with a Range and converting it to an Array instead.

Edit2: Added looping vertically

typealias S=String
typealias I=Int
var A:(I)->S={S(UnicodeScalar($0))},B:(I)->(I,I)={a in(a%10,a/10)},a=Array(48...57).map{A($0)},b=[a+(Array(65...90)+[32,43,94,61]).map{A($0)},a+(Array(97...122)+[45,43,94,61]).map{A($0)}],z=Process.arguments
z.removeAtIndex(0)
func C(e:I,f:I)->I{let(a,b)=B(e),(c,d)=B(f)
return min(abs(d-b), abs(4-(d-b)))+min(abs(c-a),abs(10-(c-a)))}
func D(c:S,_ e:I=10,_ f:Bool=false,_ g:Bool=false)->I{if count(c)==0{return C(e,39)}
let h=c.startIndex,i=c.endIndex,j=S(c[h])
if let k=find(b[f ?1:0],j){return C(e,k)+D(c[advance(h,1)..<i],k,(g ?(!f):f),false)}else{return min(C(e,37)+D(c,37,!f,true),C(e,38)+D(c,38,!f,false))}}
print(D(" ".join(z)))

To run, put the code in a .swift file and run it with swift <filename> <your name>

This uses the simple approach where the two 'keyboards' are stored as arrays.

B:(I)->(I,I)={a in(a%10,a/10)}
Converts an index from the array to an x,y position on the virtual keyboard.

func C(e:I,f:I)->I{let(a,b)=B(e),(c,d)=B(f)
 return abs(d-b)+min(abs(c-a),abs(10-(c-a)))} Takes a start/end index and returns the minimum number of moves to get from once to the other (accounting for horizontal wrap)

func D(c:S,_ e:I=10,_ f:Bool=false,_ g:Bool=false)->I Is the main recursive function that does most of the calculations.  It calculates the distance from the current position to the target character, unless the case should change, then it calculates both the shift and the caps lock methods and takes the smallest.

Running swift codegolf.swift Code Golf prints 43


Jelly,  13 12 10  6 bytes
-4 thanks to Dennis, yes FOUR! (use of group indices and Cartesian product)
⁵pḅ1ĠU

Uses 1-indexing and the list option for output.
Try it online! (The footer formats the output in Python representation)
...or see a 0-indexed, formatted version.
How?
⁵pḅ1ĠU - Main link: no arguments
⁵      - literal 10
 p     - Cartesian product (with the leading constant of 10 and implicit ranges)
       -       = [[1,1],[1,2],[1,3],...,[10,8],[10,9],[10,10]]
  ḅ1   - to base one (proxy for sum each without the monad)
       -       = [2,3,4,5,6,7,8,9,10,11,3,4,5,6,7,8,9,10,11,12,4,...,18,19,20]
    Ġ  - group indices by value
       -       = [[1],[2,11],[3,12,21],...,[90,99],[100]]
     U - upend = [[1],[11,2],[21,12,3],...,[99,90],[100]]


Find the index of reflection of a substring of a palindrome

J, 26 25 bytes
[:(-:@i.>./)[:(*/*#)/.=/~

Try it online!
how
=/~ creates a function table comparing all possible pairs of characters.  Taking 'nasanita' as an example:
1 0 0 0 1 0 0 0
0 1 0 1 0 0 0 1
0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 1
1 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
0 1 0 1 0 0 0 1

Notice the /-direction diagonals.  If one of those is all ones, it corresponds to an embedded palindrome.
J has an adverb /. which lets us to apply a verb to each diagonal.
We choose the verb (*/*#) -- the sum multiplied by the length.  Thus it will be the length of the diagonal if it's all ones, and 0 otherwise:
1 0 0 0 5 0 0 0 0 0 0 0 0 0 1

i.>./ Find the index of the max element within that list.  In this case the index of 5 is 4.
-:@ And divide it by 2.


Python 2, 58 bytes

u=-abs(200-input()%400)-4
print u/100+5>(u-8)*5/4%7>u%4/-3

Try it online!

A direct formula.