Perl, 103+2 = 105 bytes

s/$/$"x y===c/gem;$a=$_;$_.=$"while$a=~s/^./!($_.=$&)/gem;s/$1/-/g,$b="$&$b"while/\s(\w)(\1|-)+ /;say$b

Run with -n0 (2 byte penalty).
Explanation:
# -n0: read entire input into `$_` at start of program
# (technically speaking it reads to the first NUL byte, but there aren't any)

# We want to be able to extract columns from the input, so we need to add spaces
# to the ends of each line such that each column is complete. Adding too many
# space is OK, so to ensure we have enough, we add a number of spaces equal to the
# length of the input.
s/$/             # At the end of {something},
$" x             # append a number of spaces ($" is a space by default)
y===c            # obtained by counting the characters in $_
/gem;            # where {something} is each (g) line (m)

$a = $_;         # store a copy of the transformed input in $a

# The next step is to create a transposition of the input. To do that, we
# repeatedly extract the first column of $a and append it to $_. This will lead to
# a bunch of junk whitespace at the end of $_ (of varying lengths, because once a
# line is empty it's omitted from the extracted column), but we're OK with that.
# To transpose properly, we'd want to place newlines between the extracted
# columns; however, it happens that the rest of the program treats space the same
# way it would newline, and separating via spaces is shorter, so we do that.

while (          # keep looping as long as there are matches
  $a =~ s/^./    # replace the first character of {something related to $a}
  !(             # with the null string (NOT of something truthy)
    $_.=$&)      # but append that character ($&) to $_
  /gem) {        # {something} is each (g) line (m) of $a
  $_.=$"         # append a space ($", equivalent to newline here) to $_
}

# Finally, we repeatedly replace every character in the topmost line with the -
# character (treating a line as continuous through the - character but not through
# other characters), thus finding the lines from top to bottom. Because we
# appended the transpose of $_ to $_ above, each line appears twice: once
# horizontally, once vertically. We find only the horizontal copy, but replace
# both with hyphens.
# (Note: I rewrote the regex into a bit more readable of a form in this ungolfed
# version, because the original version wouldn't allow me room to write comments
# inside it. The two should be equivalent; I tested the golfed version.)
while (          # keep looping as long as there are matches
  /\s(\w)        # match a space or newline, $1 (a letter/digit/underscore),
    (\1|-)+      # any positive number of $1s and hyphens,
    \ /x) {      # and a space
  s/$1/-/g,      # changes all $1s to spaces; set $& to $1, $1 becomes invalid
  $b = "$&$b"    # prepend $& to $b
}

# We need to output the lines from first (i.e. bottom) to last (i.e. top).
# We found them in the opposite order, but reversed them via prepending
# (not appending) the partial results to $b.
say $b           # output $b

One slight subtlety here comes with input like this:

   ABC
DDDDDDDDD
   ABC
   ABC
   ABC

Look at the fourth line here. If the order of writing were BACBD, there could genuinely be a horizontal line of Bs along there without violating any of the assumptions of the problem (other than that there's only one line of each colour, something that we don't check). In order to get around this, we ensure in the last regex that each line starts with a letter (or digit or underscore, but those are impossible), and rely on the fact that parallel lines will be found left-to-right and top-to-bottom (because the regex will find the first match within the string). As such, the first character of each ambiguous line here gets overwritten before the line itself is seen as a match, and that prevents the regex matching.


Single for loop, 80 75 72 68 bytes

I will try to make the code smaller too, but as far as single for loop goes:

for(i=5;i<30;)console.log(k=i/5|0,"*",l=i%5+1,"=",k*l,++i%5?"":"\n")

Try it in your console! (Although IE gives the best results)


CJam, 96

This uses a lot of nasty bytes, so here's a hex dump of it:

00000000  22 ee 51 1e 53 41 15 ee  51 20 53 41 15 9a 5f 5a  |".Q.SA..Q SA.._Z|
00000010  b9 5f 41 15 8c 5f 41 f9  38 24 2a 15 7e 55 1c 5f  |._A.._A.8$*.~U._|
00000020  b9 30 5f b9 41 15 a8 26  2a 26 2a 15 36 45 91 c3  |.0_.A..&*&*.6E..|
00000030  ed cb 41 f3 df eb 41 db  20 cb c9 41 e9 df c9 c3  |..A...A. ..A....|
00000040  f3 7f 45 36 15 22 7b 69  32 6d 64 5c 5f 63 5c 37  |..E6."{i2md\_c\7|
00000050  6d 64 22 20 5f 6f 2d 7c  7e 2e 22 3d 2a 3f 7d 2f  |md" _o-|~."=*?}/|

You can run the file with the java interpreter; it may be necessary to use ISO-8859-1 encoding, such as:
java -Dfile.encoding=ISO-8859-1 …

Try it online

Equivalent (and much longer) ASCII version:

[238 81 30 83 65 21 238 81 32 83 65 21 154 95 90 185 95 65 21 140 95 65 249 56 36 42 21 126 85 28 95 185 48 95 185 65 21 168 38 42 38 42 21 54 69 145 195 237 203 65 243 223 235 65 219 32 203 201 65 233 223 201 195 243 127 69 54 21]:c
{i2md\_c\7md" _o-|~."=*?}/

Try it online

Explanation:

There are 7 characters that have repetitions:  _o-|~.. Each of them can be encoded as a number n from 0 to 6. For each repeating sequence, I am encoding both the character's index (n) and the number of repetitions (k) in a single byte: 2 * (k * 7 + n), written as a character with that code. And I am encoding any single characters as 2 * c + 1, where c is the ASCII code. Everything goes in the initial string, and the rest of the program is decoding it:

{…}/      for each character in the string
  i       convert to integer (extended-ASCII code)
  2md     integer division by 2, obtaining the quotient (q) and remainder (r)
           r decides whether it's a repetition or single character
  \_      swap q and r, and duplicate q
  c\      convert q to character and move it before the other q
           this is for the r=1 case (single character)
  7md     divide q by 7, obtaining the quotient (k) and remainder (n)
  "…"=    get the corresponding character from that string (decoding n)
  *       repeat the character k times
  ?       use the single character or the repetition, depending on r

Old version (109):

" H(_2)
 H(o2)
 B/-6\/
 A/ | 4|2 3
 9* 2/\-3/\
 C~2 3~2 3
.6"{_'M,48>&{~*}&}/3/"Have you mooed today?"`*N

Try it online


QuadR, 17 + ≡ flag = 28 bytes

\d+\[\pL*]
∊(⍎⍵M∩⎕D)⍴⊂⍵M∩⎕A

Try it online!

Find:

 \d+\[\pL*] find digit(s) followed by bracketed Letters

Replace with:

⎕A uppercase Alphabet

 ⍵M∩ intersection of Match and that

 ⊂ enclose (to treat as a whole)

 (…)⍴ reshape to length:

  ⎕D Digits

  ⍵M∩ intersection of Match and that

  ⍎ execute (converts text to number)

 ∊ ϵnlist (flatten)

This is equivalent to the Dyalog APL function:

'\d+\[\pL*]'⎕R{∊(⍎⍵.Match∩⎕D)⍴⊂⍵.Match∩⎕A}⍣≡


Generate a congruent list with the smallest sum

Python 2, 62 54 bytes

lambda L:map(sorted(set(L),key=L.count)[::-1].index,L)

Try it online!

Edit: saved 8 bytes via map thanx to Maltysen


Pyth, 30 bytes

?tJ{-VtQQ"NAAP"+hJ%"n%+d"-hQhJ

Test suite

To check whether it's a arithmetic procession, this uses a vectorized subtraction between each element and the previous, -VtQQ. A ternary checks if there are multiple values in the result (?tJ{) and prints NAAP if so. Then, to get the + or - right, the mod-formating %+d is used.


05AB1E, 14 12 13 bytes
-2 bytes thanks to @KevinCruijssen
+1 byte thanks to @Grimmy
∞.Δ23SmJœIÅ?Z

Try it online!

Explanation
∞.Δ                  - First number that...
   23Sm              - Power of 2 and 3 [n^2, n^3]
       J             - Concatenated
        œ            - Permutations of this number
         IÅ?Z        - any of these start with the number

By the way it's quite slow...


brainfuck, 35 bytes

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

Try it online!

This is the first language I thought of because it is really good for no-letter no-number challenges lol.


Python - 370

Ok, nice one, finally got the pi thing working with thanks to link1 and link2.

from decimal import *
def f(s,n):
 j=len(s)
 getcontext().prec=j+n+5
 d=Decimal
 e=d(0)
 for k in range(0,j+n+5):
  e+=(d(16)**(-k)*(d(4)/(8*k+1)-d(2)/(8*k+4)-d(1)/(8*k+5)-d(1)/(8*k+6)))
 c=`e`.split("'")[1].replace('.','')
 t=''
 for i,l in enumerate(s):
  o=ord(l)
  for v in[0,32]:
   if 64+v<o<91+v:
    l=chr(((o-65-v)+int(c[i+n-1]))%26+65+v)
  t+=l
 print t

Example output:

>>> f('house',2)
isvxn

and another:

Wimt fcy d dnyh uhkvkv qhvadil

       >>> f('This was a very secret message',1)


Common Lisp, 2650 2221 1992 1186 1111 bytes

Update: "Easy" golfing now done, further gains will require bigger changes.

Update 2: With the competition getting fiercer, the new version no longer favors positions inside the current playing field rectangle (that would be 57 bytes extra). This option, as well as a simple speed optimization, is by enabled by default in the downloadable version with the simulator, but not in the official answer below.

Update 3: Minor interface changes for major byte count gains.

I created a simple Web UI as well. The full package (a single LISP file and the tile images) can be downloaded here. To try it, install hunchentoot, zpng and png-read with quiclisp, load in carcassonne.lisp, and connect to localhost:8080. The code has been tested on CCL/Windows and SBCL/Linux. The above mentioned libraries are only needed for the UI/simulator part; the solution itself is plain ANSI Common Lisp.

(defun c(f p &aux b a s z(c 55))
  (macrolet((d(v l &body b)`(dotimes(,v,l),@b))
            (b(b c)`(d i c(d j c(setf,b,c))))
            (r(&rest p)`(aref,@p))
            (n(u v i j)`(and(setf l(*(f,u,v)l))
                            (find(r f(+,u,i)(+,v,j))`(0,(r f,u,v))))))
    (labels((p(p w)(d y(ceiling w 2)(d x(- w y y)(rotatef(r p y #6=(+ x y))(r p #6##7=(- w y))(r p #7##8=(- w x y))(r p #8#y)))))
            (a(y x)(or(if(= 0(r f y x))1 #4=(and(= 1(incf(r s y x)))(=(r f y x)z)(push`(,y,x)a)0))0))
            (f(y x)(setf z(r f y x))(if #4#(loop for((y x))= a while(pop a)maximize(+(a(1- y)x)(a y(1- x))(a(1+ y)x)(a y(1+ x))))1)))
      (d i 8(when(d x #1=(array-dimension f 0)(or(= 0(r f(- #1#52 i)x))(return t)))(setf f(adjust-array f`(#2=,(+ #1#c)#2#))))(p f(1- #1#)))
      (d i 4(d u #9=(/ #1#c)(d v #9#
        (let((y(* u c))(x(* v c))(l 9e9))
          (when(= 0(r f y x))
            (b #10=(r f(+ y i)(+ x j))(r p i j))
            (setf s(make-array`(,#1#,#1#))a())
            (ignore-errors(if(> #11=(*(loop for d from 1 to 53
                                            sum(+(n y #3=(+ x d)-1 0)(n #5=(+ y d)(+ 54 x)0 1)(n(+ 54 y)#3#1 0)(n #5#x 0 -1)))
                                      (1+ l))
                                (or(car b)0))
                             (setf b`(,#11#,i,y,x))))
            (b #10#0)))))
         (p p 54))
      (when b(d j(cadr b)(p p 54))(b(r f(+(third b)i)(+(nth 3 b)j))(r p i j)))
      `(,f,b))))

All line feeds and line-starting spacing are for cosmetics only, to ensure legibility, and not counted into the total sum.

You should call the function c with two arguments: The current play field, and the tile to place. Both should be 2D arrays; the tile 55x55 and the field a multiple of that. Additionally, the field array must be adjustable. The function returns a two-element list with the new field as its first argument. The second element is NIL if the tile cannot be placed, or otherwise a list containing the top-left coordinates and rotation of the latest tile on that array and the score for that tile. This information can be used for visualization purposes.

Note that in further calls, you must use the new field returned by c even if the second list element is NIL (the original array may have been adjust-arrayed and thus invalidated).

The code is now a bit on the slow side, byte count optimization resulting in redundant calculations. The example below completed in about three minutes on my system.

Example run for all 85 tiles:

Web UI screenshot:


Counting from 1 to an Integer… in Binary

APL, 10 characters

Another on in APL. Assumes⎕IO←1 (the default). No bonus points. Reads the number from the input device. If your APL uses 64 bit integers instead of 32 bit integers, substitute 64 for 32 as needed.

Notice that APL transparently converts to floating point numbers when the range of an integer is exceeded. It's hard thus to exactly say what integer size APL works with.

⍉(32⍴2)⊤⍳⎕

explanation

2          ⍝ the number 2
32⍴2       ⍝ a vector of 32 twos.
(32⍴2)⊤X   ⍝ X represented as base 2 to 32 digits precision
⍳X         ⍝ a vector of the integers from 1 to X
⎕          ⍝ a number queried from the terminal
(32⍴2)⊤⍳⎕  ⍝ the output we want, flipped by 90°
⍉(32⍴2)⊤⍳⎕ ⍝ the output we want in correct orientation (⍉ is transpose)


Perl, 254 + 1

for((@a[0..5],@b)=split;$a[1]>0;@c=@a,@a=@b,@b=@c){say"$a[0] attacks $b[0]!\n",rand$b[5]/2<rand$a[4]?do{($==rand($a[2])-rand$b[3]/2)<1and$==1;"$a[0] hits $b[0] for $= damage!\n$b[0] has ",($b[1]-=$=)>0?"$b[1] health left.":"been slain!"}:"$b[0] dodges!"}

Run with perl -nM5.010 (or perl -nE '<code>').  Per meta, the -n switch counts as one extra character.
No fancy golfing tricks in this code, except maybe the use of $= as the damage variable to save an int.

Edit: Hopefully, the damage calculation is correct now.


Dyalog APL, 15 bytes

Takes x as left argument and y as right argument.
+,×,*,-,-⍨,÷,÷⍨

Simply a long train of forks (3-trains):
+, the sum, followed by
×, the product, followed by
*, the exponentiation, followed by
-, the difference, followed by
-⍨, the swapped difference, followed by
÷, the ratio, followed by
÷⍨ the swapped ratio
TryAPL online!


Python 3, 375 bytes
f=lambda i:"\n\n".join("\n".join(map(" ".join,zip(*[[x.replace("0"," ")[a*5:a*5+5]for a in range(5)]for x in[["{:025b}".format(int(c,36))for c in'0 JPCFL J2UKE 92Y3Y J2KAM JOMCF JOMC0 92B72 AYP81 JFM3J JFMHO AZC7M AB6ZJ B5I5T B43N5 92YWE J2UJ4 92YY7 J2UQC 926UM JFM2S AYE5Q AY8G4 AYHKH AT6Q9 AT6KK AWU7'.split()][x!=" "and ord(x)-64]for x in j.upper()]])))for j in i.split("\n"))

See this code running on ideone.com.
The same code, but somehow nicely indented, formatted and commented:
f = lambda i: \

    # join multiline strings together using an empty line as separator:
    "\n\n".join(

        # join the string lines of one big output line together:
        "\n".join(

            # join the corresponding rows of the letters together using " ":
            map(" ".join, zip(*

                # make a list (output line) of list (output characters)
                # of strings (single character's rows):
                [

                    # replace 0s with spaces and split the bit strings into
                    # chunks of 5 characters - the rows of each letter:
                    [x.replace("0", " ")[a*5 : a*5+5] for a in range(5)]

                    for x in [

                        # split the space separated character codes and
                        # convert them from base 36 to
                        # base 2 strings of length 25:
                        ["{:025b}".format(int(c, 36)) for c in

                         # the encoded font data (reformatted):
                         '0 JPCFL J2UKE 92Y3Y J2KAM JOMCF JOMC0 92B72 '
                         'AYP81 JFM3J JFMHO AZC7M AB6ZJ B5I5T B43N5 92YWE '
                         'J2UJ4 92YY7 J2UQC 926UM JFM2S AYE5Q AY8G4 AYHKH '
                         'AT6Q9 AT6KK AWU7'.split()]

                        # select element 0 if we want a space, else find
                        # out the index from the ASCII code of the letter:
                        [x != " " and ord(x) - 64]

                        # repeat for every character in the input line:
                        for x in j.upper()
                    ]
                ]
            ))

        # repeat for every line in the input
        ) for j in i.split("\n")
    )

I also decided to go for base 36 encoding as that's the highest base Python's built-in int() natively supports. Here is a short Python 3 script I wrote (ungolfed) that converts font definitions like in the question into base 36 codes: My converter on ideone.com
The result consists of the character 1 as enabled pixel and a space   as disabled pixel. Here's a single example run:
Input (line break as \n):
Hello World
Python rocks

Output:
1   1 11111 1     1      111        1   1  111  1111  1     1111
1   1 1     1     1     1   1       1   1 1   1 1   1 1     1   1
11111 1111  1     1     1   1       1 1 1 1   1 1111  1     1   1
1   1 1     1     1     1   1       11 11 1   1 11    1     1   1
1   1 11111 11111 11111  111        1   1  111  1 1   11111 1111

1111  1   1 11111 1   1  111  1   1       1111   111   111  1   1  111
1   1  1 1    1   1   1 1   1 11  1       1   1 1   1 1   1 1  1  1
1111    1     1   11111 1   1 1 1 1       1111  1   1 1     111    111
1       1     1   1   1 1   1 1  11       11    1   1 1   1 1 1       1
1       1     1   1   1  111  1   1       1 1    111   111  1  1   111


C: replace AES FIPS-197 SubBytes table by constant-time code


Calculate the a ^ b WITHOUT using *, / and ^

k (19 bytes)

This is slow and uses lots of memory:

{#,//(x#,:)/[y;0b]}

The /s are not division, it's the converge operator.


Animating the Separation of Fluids by Density

Python, 300 298 chars

import random
C=random.choice
R=raw_input
G=list(R().replace('_','\n'))
S=w=G.index('\n')
while S:
 print''.join(G);S=[];R()
 for i,c in enumerate(G):
    B=[(d,j)for j,d in enumerate(G[i+w:i+w+3])if'/'<d<c]
    if B:S+=[(i,[i+w+j for d,j in B if d==min(B)[0]])]
 if S:i,B=C(S);j=C(B);G[i],G[j]=G[j],G[i]

Run it like cat inputfile - | fluid.py.  The input file should be a single line using _ as a line separator.


I'll time your function, but I don't work weekends

Rebmu: 17 (27 - 10, obfuscated) or 30 unobfuscated

Rebmu is specifically designed to play code golf while being readable (for those who get the "trick"), so the obfuscation rule is against its principle.  But:

DnowRjRkILd/7 6[pDT[adJk]]

It works all day on weekdays:

Input Integer: 10
Input Integer: 20
0:00:00.000008

...but on weekends it just does nothing:

Input Integer: 10
Input Integer: 20

Explanation:

Using the unmushing and noticing capital runs of letters are separate words, and the lack of a leading capital run means we're not making a set-word, we get the abbreviated Rebol:

d: now
r j
r k
il d/7 6 [
    p dt [
        ad j k
    ]
]

Un-abbreviating it, what you wind up with is:

;-- save current date and time into "d"
d: now

;-- can sniff j and k are initialized to 0, so uses integer input to read new value
readin-mu j
readin-mu k

;-- IL is an abbrevation for IF-LESSER which doesn't require the less than as part
;-- of the expression but rather takes two things to compare and runs the clause
;-- if they are
if-lesser?-mu d/7 6 [
    print delta-time [
        add j k
    ]
]

Date numbers in Rebol are numbered 1 for Monday up to 7 for Sunday.  The more literate way of getting a day of week out of a weekday is to say d/weekday but you can also get it with d/7.  My preferred solution without changing things just to adapt to this problem would be more like:

rJrKilNOW/weekday 6[pDT[adJk]]

But if were to update the vocabulary for general application to this style of problem, which it probably comes up often enough to not want to fall through to verbose Rebol every time, I'd probably make MON thru SUN be 1 - 7) and abbreviate NOW WEEKDAY, at which point it would look probably more like...

rJrKilNW/wkdySAT[pDT[adJk]]

Notes

As usual, you can make "the program" itself a wee bit shorter if you allow the inputs to be passed to Rebmu as arguments and just accept the evaluation result (here, either a value of type time or NONE) without printing it:

  rebmu/args [DnowILd/7 6[dt[adJk]] [J10 K20]

Also delta-time, dates, image generation, and a crazy number of things are already included in Rebol's half-megabyte, zero-install executable.


Ruby 2.0, 145 179 characters

puts$<.sort_by{|a|(1..3).map{|i|"#{a[/^(\d+:)?(.+?)(-[^-]+)?
/,i]}".scan(/(\D*)(\d*)/).map{|w,n|w.bytes.map{|c|c<126?c>58?c:c+99:-1}+[0,n.hex]}}}

Correctly sorts both the linked reference input (though it generates a slightly different output order due to different sorting of equivalent version numbers, e.g. 1.06-2 vs 1.6-2) and the included test data.


MATL, 14 bytes

:UG\u&-G\8#uX<

Try it online! Or verify the first 30 values.

Explanation

:      % Implicit input. Range
U      % Square, element-wise
G      % Push input again
\      % Modulo, element-wise
u      % Unique elements
&-     % Table of pair-wise differences
G      % Push input
\      % Modulo, element-wise
8#u    % Number of occurrences of each element
X<     % Minimum. Implicit display


MATL, 32 bytes

1i1)/Gd"GX@QtZ\3L)/)y7M)*s_G1)/h

Try it online! Or verify all test cases.

How it works

1        % Push 1
i        % Take input: f, of size L
1)       % Get its first entry: f(1)
/        % Divide: gives 1/f(1). This is g(1). It will later be expanded into
         % a vector to include g(2), g(3), ... g(L)
G        % Push input again
d        % Consecutuve differences: gives a vector of L-1 numbers
"        % For each: this iterates L-1 times
  G      %   Push input again
  X@Q    %   Push iteration index plus 1: gives 2, 3, ..., L respectively in
         %   each iteration. This is n in the formula for computing g(n)
  t      %   Duplicate
  Z\     %   Divisors of n. Gives a vector with the values of d in the formula
  3L)    %   Remove last. This corresponds to the condition d<n in the formula
  /      %   Divide. Gives a vector with n/d for d<n
  )      %   Index. Gives a vector with f(n/d)
  y      %   Duplicate from below. Pushes a copy of g as built so far
  7M     %   Push vector containing d for d<n, again
  )      %   Index. Gives a vector with g(d)
  *      %   Multiply, element-wise. Gives a vector containing f(n/d)*g(d)
  s      %   Sum
  _      %   Negate
  G      %   Push input again
  1)     %   Get its first entry: f(1)
  /      %   Divide. This gives g(n)
  h      %   Contatenate. This attaches the newly computed g(n) to the vector
         %   containing the previous values of g
         % End (implicit)
         % Display (implicit)


x86 Machine Code, 15 14 bytes

F3 0F B8 C1 0F BD D1 03 C0 42 2B D0 D6 C3

This is a function using Microsoft's __fastcall calling convention (first and only parameter in ecx, return value in eax, callee is allowed to clobber edx), though it can trivially be modified for other calling conventions that pass arguments in registers.

It returns 255 as truthy, and 0 as falsey.

It uses the undocumented (but widely supported) opcode salc.

Disassembly below:

;F3 0F B8 C1
  popcnt eax, ecx ; Sets eax to number of bits set in ecx

;0F BD D1
  bsr edx, ecx    ; Sets edx to the index of the leading 1 bit of ecx

;03 C0
  add eax, eax

;42
  inc edx

;2B D0
  sub edx, eax

  ; At this point,
  ;   edx = (index of highest bit set) + 1 - 2*(number of bits set)
  ; This is negative if and only if ecx was binary-heavy.

;D6
  salc           ; undocumented opcode. Sets al to 255 if carry flag
                 ; is set, and to 0 otherwise.

;C3
  ret

Try it online!

Thanks to Peter Cordes for suggesting replacing lzcnt with bsr.


Excel, 92 91 Bytes

From the VBA editor's immediate window, run the following command:
Range("A1:I9").Formula="=IF(ROW()<COLUMN(),"""",COLUMN()&""×""&ROW()&""=""&COLUMN()*ROW())"
The output is directly on the active worksheet.

I golfed an extra byte by swapping the order of an if to change >= to <.  I didn't update the screenshot, but it only affects the formula at the top, not the output.


Octave, 19 bytes

@(x)[[q,r]=qr(x),r]

Try it online!

My first Octave answer \o/

Octave’s qr has quite a few alternatives in other languages that return both Q and R: QRDecomposition (Mathematica), matqr (PARI/GP), 128!:0 - if I recall correctly - (J), qr (R)...


Evaluate Index of Multidimensional Coordinates

MATL, 8 bytes

PiX[vPi)

This uses 1-based indexing for the node and for the dimensions. So the first nodes are 1, 2 etc; and the "x" dimension is 1, "y" is 2 etc.

Try it online!

Explanation

The key is to use function X[ (corresponding to ind2sub in Matlab or Octave), which converts a linear index into multidimensional indices. However, the order of dimensions if the opposite as defined in the challenge, so P (flip) is needed before calling the function, and again after concatenating (v) its ouputs.

P    % Implicit input: size as a row vector. Flip
i    % Input: node (linear) index
X[   % Convert from linear index to multidimensional indices. Produces
     % as many outputs as entries there are in the size vector
v    % Concatenate all outputs into a column vector
P    % Flip
i    % Input: dimension
)    % Index: select result for that dimension. Implicitly display


Python 2 + numpy + OpenCV, 576 bytes

from cv2 import*
from numpy import*
n=input()/4
f="m.png"
i=imread(f)
b=array([0]*3)
y=array([165,195,225])
j=inRange(i,b,b+120)
k=inRange(i,y,y+25)
for x,y in zip(*where(j)):j[x,y]=k[x+3,y]-j[x+1,y]>1
j=j[506:732,152:557]
p=[array([11,9])]
for c in sorted(zip(*where(j)),key=lambda c:c[1]):r=range(p[-1][1]+1,c[1]+1);p+=map(array,zip(map(int,interp(r,*zip(p[-1],c)[::-1])),r))
for x,c in enumerate(p[25:-25:n]):s=-1/true_divide(*p[x*n+50]-p[x*n+25]);k=6/(1+s**2)**.5;line(i,*map(tuple,[(c+[int(k*s)+506,int(k)+152])[::-1],(c-[int(k*s)-506,int(k)-152])[::-1],b]))
imwrite(f,i)

This program is almost entirely ungolfed, and there are aspects of it that are somewhat inaccurate at the moment, but at least it works for the most part. Additionally, there is a little bit of hardcoding, but it's only for an approximate window enclosing the border and the coordinate of the first pixel on the border (the latter of which I will actually most likely remove later).
The image used by the program is halved in area (i.e. 1120 x 865), and so the length of lines drawn and the distance between lines is smaller.


PHP 5.3+, 173 167 166 159 156 151 127 121 bytes

echo[Condor,Albatross,Eagle,Birdie,Par,$b=Bogey,"Double $b","Triple $b","Haha you loser"][min(4+$s-$p,8)]?:"Hole in one";

Notice-free version, 139 137 bytes

echo$s-1?["Condor","Albatross","Eagle","Birdie","Par",$b="Bogey","Double $b","Triple $b","Haha you loser"][min(4+$s-$p,8)]:"Hole in one";

Set $score and $par variables before the echo and you're off.

exploded view

echo [Condor,
      Albatross,
      Eagle,
      Birdie,
      Par,
      $b = Bogey,
      "Double $b",
      "Triple $b",
      "Haha you loser"][ min( 4+$s-$p,8 ) ]
  ?: "Hole in one";

Edits
-6: Not storing the array, just calling it if need be.
-1: Flipping the ternary around.
-7: The lowest $s-$p with $s>1 is -4, so the max() isn't necessary, since 4+$s-$p >= 0.
-3: Array -> explode(), thanks CoolestVeto!
-5: Cheaty string literal undefined constant plus $r[-1] -> false, thanks Ismael Miguel!
-24: Moving from an explode() function to a printf/%s setup, with some tweaks, more thanks to Ismael Miguel for the change of direction.
-6: Swerve, we're back to echo again!


Replace string!="" with string>""

SB allows you to do greater/less comparisons on strings, based on their codepoints. However, the empty string is considered the smallest string there is.

So for situations where you do string!="" you can use either string>"" or ""<string, since every string is greater than "" and "" is less than every string. Depending on whether you use < or > depends on if the statement needs whitespace before or after to be valid syntax, which can also save you bytes.

For example:

WHILE S$!=""

can be turned into

WHILE S$>""

and further golfed to

WHILE""<S$


C, 174 bytes
a[99],c,p,j,M,m;main(i){for(i=j=1;c=getchar(),~c;i++)c<11?a[i]=j++,i=0:c&4?a[i]=j:0;for(m=j;c=a[i++];c>a[i-2]?M-m>1&&c-m>1?M=c,m=j,p++:M<c?M=m=c:M:m>c?m=c:0);printf("%d",p);}

Requires a trailing newline in the input, otherwise +4 bytes.


C 145 134 Characters

N,A[999],i,j,f;main(){gets(&i);for(;~scanf("%d",A+N);)N++;for(;j<N;j++,f=f&&!puts(""))while(i=A[j]+1)f=printf("%d ",j),A[j]=-1,j=--i;}

http://www.ideone.com/BrWJT


Mask an IP address and give its broadcast

JavaScript (ES6), 92 bytes

(a,m)=>a.split`.`.map((n,i)=>(v=m[i],m[i]=n&v|v^255,n&v),m=m.split`.`).join`.`+" "+m.join`.`

Explanation

(a,m)=>
  a.split`.`
  .map((n,i)=>(
      v=m[i],
      m[i]=n&v|v^255,
      n&v
    ),
    m=m.split`.`
  ).join`.`
  +" "+m.join`.`

Test

var solution = (a,m)=>a.split`.`.map((n,i)=>(v=m[i],m[i]=n&v|v^255,n&v),m=m.split`.`).join`.`+" "+m.join`.`
<input type="text" id="input" value="10.25.30.40 255.252.0.0" />
<button onclick="result.textContent=solution.apply(null,input.value.split` `)">Go</button>


Pyth - 24 23 bytes
There has to be a better way to find the divisors...
ho.a-.n3cFNfsIeTm,dcQdS

Test Suite.


JavaScript (ES6), 75 bytes

(s,a)=>/^(.*).*(\n\1.*)*$/.exec(a.filter(e=>e.startsWith(s)).join`
`)[1]||s

Explanation: Filters on all matching prefixes, then joins with newlines and matches against a regex that finds the longest common prefix of all lines. If there are no prefixes then the regex returns an empty string in which case we simply return the original string.


Windows PowerShell, 74
for($d="date $args"|iex;($d+='1').day*$d.dayofweek-65){}'{0:yyy-MM-d}'-f$d

Fairly straightforward. One perhaps confusing bit is the use of "Get-Date $args" | Invoke-Expression to get either the current date (if $args is empty) or the date specified in $args without raising an error.
72-byte variant:
for($d="date $args"|iex;($d+=9).day*$d.dayofweek-65){}'{0:yyy-MM-d}'-f$d

Takes ages, though ... this doesn't increment the datetime by a whole day each iteration but instead only 900 nanoseconds. But two bytes shorter.
67-byte variant:
for($d="date $args"|iex;($d+='1').day*$d.dayofweek-65){}'{0:d}'-f$d

This is a bit locale-sensitive; if it fails on your machine, try setting your date format to ISO-8601 beforehand. :-)
Oh, and it can be made into 65 bytes just like the 72-byte version.
History:

2011-02-17 00:33 (92) First attempt.
2011-02-17 00:35 (85) Improved getting an initial date.
2011-02-17 00:37 (79) Compared the product instead of day and day of week individually. Admittedly stolen from Ventero.
2011-02-17 00:40 (76) Pulled the first line into the for. Comparison just as subtraction instead of -eq which saves another two bytes.
2011-02-17 00:53 (75) Unix date format string is a bit shorter.
2011-02-17 11:42 (74) Reverted to the default date pattern but yyy-MM-d suffices (since the year is always longer than three characters and the day is always 13. Thanks to Ty Auvil for this.


GS2, 2 bytes

ç7

Try it online!

How it works

    (implicit) Push the sting of all characters in STDIN on the stack.
ç   Push the string of all printable ASCII characters.
 7  Perform symmetric set difference.
    (implicit) Print the result to STDOUT.


Code: Mathematica, Output: Julia, ~98.9457% (20177/20392 bytes)

optimise[n_] :=
  Module[{bits, trimmedBits, shift, unshifted, nString, versions,
    inverted, factorised, digits, trimmedDigits, exponent, base,
    xored, ored, anded},
   nString = ToString@n;
   versions = {nString};

   (* Try bitshifting *)
   bits = IntegerDigits[n, 2];
   trimmedBits = bits /. {x___, 1, 0 ..} :> {x, 1};
   shift = ToString[Length[bits] - Length[trimmedBits]];
   unshifted = ToString@FromDigits[trimmedBits, 2];
   AppendTo[versions, unshifted <> "<<" <> shift];

   (* Try inverting *)
   inverted = ToString@FromDigits[1 - PadLeft[bits, 32], 2];
   AppendTo[versions, "~" <> inverted];

   (* Try invert/shift/invert *)
   trimmedBits = bits /. {x___, 0, 1 ..} :> {x, 1};
   shift = ToString[Length[bits] - Length[trimmedBits]];
   unshifted = ToString@FromDigits[trimmedBits, 2];
   AppendTo[versions, "~(~" <> unshifted <> "<<" <> shift <> ")"];

   (* Try factoring *)
   factorised = Riffle[
      FactorInteger[n]
        /. {a_, 1} :> ToString@a
       /. {a_Integer, b_Integer} :> ToString[a] <> "^" <> ToString[b]
      , "+"] <> "";
   AppendTo[versions, factorised];

   (* Try scientific notation *)
   digits = IntegerDigits[n, 10];
   trimmedDigits = digits /. {x___, d_ /; d > 0, 0 ..} :> {x, d};
   exponent = ToString[Length[digits] - Length[trimmedDigits]];
   base = ToString@FromDigits[trimmedDigits, 10];
   AppendTo[versions, base <> "e" <> exponent];

   (* Don't try hexadecimal notation. It's never shorter for 32-bit uints. *)
   (* Don't try base-36 or base-62, because parsing those requires 12 characters for
      parseint("...") *)

   SortBy[versions, StringLength][[1]]
  ];

mathpack[n_] :=
 Module[{versions, increments},
  increments = Range@9;
  versions = Join[
    optimise[#2] <> "+" <> ToString@# & @@@ ({#, n - #} &) /@
      Reverse@increments,
    {optimise@n},
    optimise[#2] <> "-" <> ToString@# & @@@ ({#, n + #} &) /@
      increments,
    optimise[#2] <> "*" <> ToString@# & @@@
      Cases[({#, n / #} &) /@ increments, {_, _Integer}],
    optimise[#2] <> "/" <> ToString@# & @@@ ({#, n * #} &) /@
      increments
    ];
  SortBy[versions, StringLength][[1]]
 ];

The function takes a number and returns the shortest string it finds. Currently it applies four simple optimisations (I might add more tomorrow).

You can apply it to the entire file (to measure its score) as follows:

input = StringSplit[Import["path/to/benchmark.txt"]];
numbers = ToExpression /@ input;
output = mathpack /@ numbers;
N[StringLength[output <> ""]/StringLength[input <> ""]]

Note that some of these optimisations assume that you're on a 64-bit Julia, such that integer literals give you an int64 by default. Otherwise, you'll be overflowing anyway for integers greater than 231. Using that assumption we can apply a few optimisations whose intermediate steps are actually even larger than 232.

EDIT: I added the optimisation suggested in the OP's examples to bitwise xor two large numbers in scientific notation (actually, for all of xor, or and and). Note that extending the xormap, ormap and andmap to include operands beyond 232 might help finding additional optimisations, but it doesn't work for the given test cases and only increases run time by something like a factor of 10.

EDIT: I shaved off another 16 bytes, by checking all n-9, n-8, ..., n+8, n+9 for whether any of those can be shortened, in which case I represented the number based on that, adding or subtracting the difference. There are a few cases, where one of those 18 numbers can be represented with 3 or more characters less than n itself, in which case I can make some extra savings. It takes about 30 seconds now to run it on all test cases, but of course, if someone actually "used" this function, he'd only run it on a single number, so it's still well under a second.

EDIT: Another incredible 4 bytes by doing the same for multiplication and division. 50 seconds now (the divided ones don't take as long, because I'm only checking these if the number is actually divisible by the factor of interest).

EDIT: Another optimisation that doesn't actually help with the given test set. This one could save a byte for things like 230 or 231. If we had uint64s instead, there'd be a lot of numbers where this could be a huge saving (basically, whenever the bit representation ends in a lot of 1s).

EDIT: Removed the xor, or, and optimisations altogether. I just noticed they don't even work in Julia, because (quite obviously) scientific notation gives you a float where bit-wise operators are not even defined. Interestingly, one or more of the newer optimisations seem to catch all of the cases that were shortened by these optimisations, because the score didn't change at all.


Ruby, 654 590 566 542 505 bytes

This was fun. I used ASCII. I wasn't able to test every possible combination yet, so if you find a glitchy test case, please let me know.

require'set'
u=(0..gets.to_i).to_set
a,b,c=eval(gets).map &:to_set
i=' '
m,M,n,N,o,O,p,P,q,Q,r,R,s,S=[a-b-c,b-a-c,c-a-b,a&b-c,b&c-a,a&c-b,a&b&c].map{|u|[t=u.to_a*i,t.size]}.flatten
H,V,X=?─,?│,?┼
puts'┌'+H*(A=[1+M+[P,S].max,1+R].max)+?┐+(u-a-b-c).to_a*i,V+i*M+?┌+(b=H*(T=-M+U=A-1)+X+H*(B=[N,Q].max))+?┐,V+m+V+p+i*(T-P)+V+n+i*(B-N)+V,'│┌'+H*(K=M-1)+X+b+X+H*(C=[O-B-1,0].max)+?┐,(v=V*2+i*K)+V+s+i*(T-S)+V+q+i*(B-Q)+V+i*C+V,v+?└+b+?┘+i*C+V,V*2+r+i*(U-R)+V+o+i*(-O+D=B+C+1)+V,'└┼'+H*U+?┘+i*D+V,' └'+H*(A+D)+?┘

It expects the input on STDIN in the following format

10
[[1,2,3,4,5,9],[1,2,3,6,8],[7,2,9]]

And will then reward you with this beauty

┌───────┐0 10
│   ┌───┼───┐
│4 5│1 3│6 8│
│┌──┼───┼───┼┐
││  │2  │   ││
││  └───┼───┘│
││9     │7   │
└┼──────┘    │
 └───────────┘

I don't think I can be bothered to add an ungolfed version. Please have a look at the original version in the edit history for a somewhat more readable version.

This could certainly be golfed further by making the set boundaries less tight or even keeping them fixed like some of the graphical ones do, but I prefer that it looks nice and is done "properly" despite being golfed.


Python 2, 48 bytes

i=0
for c in input():exec"i=i%s2&-2"%c
print i/2

Does +2, -2, *2, or /2. By doing +2 and -2 rather than +1 and -1, we're working in doubled units, so the final output needs to be halved. Except, the floor-division / now needs to round down to a multiple of 2, which is done with &-2.


Rev 1 BBC BASIC, 155 ascii chars, tokenised filesize 132 bytes
INPUTn$
FORi=91TO185p=i MOD2j=i MOD47IFj<42j+=i DIV141*42p=(j>41EORASC(MID$("XLd^bFznvh",VAL(MID$(n$,j/7+1,1))+1)))>>(j MOD7)AND1
IFp LINEi*2,60,i*2,0
NEXT

saved a few bytes by incorporating the offset of 43 into the i loop. In order to avoid breaking the MOD2 an additional 47 had to be added for a total of 90.
This moves the barcode further from the origin, as shown, if that is acceptable:

Rev 0 BBC BASIC, 157 ascii chars, tokenised filesize 137 bytes
INPUTn$
FORi=1TO95p=i MOD2j=(i+43)MOD47IFj<42j+=i DIV51*42p=(i>50EORASC(MID$("XLd^bFznvh",VAL(MID$(n$,j/7+1,1))+1)))>>(j MOD7)AND1
IFp LINEi*2,0,i*2,60
NEXT

Download interpreter at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html
The default screen mode is black text on a white background. This differs from original BBC BASC.
Ungolfed version with test printing
Calculation of a data bar depends on IF j<42 and must all be done on one line. In the ungolfed version it is done in three steps. In the golfed version the last two steps are combined into a single huge expression p=...
I had to reverse the order of the bitmaps, because I use >>(j MOD 7) to access the bits, which means I access the least significant bit first. Once this is done, all the left bitmaps are conveniently in the ASCII range.
  INPUTn$
  FOR i=1TO95                            :REM iterate through 95 bars
    p=i MOD2                             :REM calculate colour of format bar 1=black
    j=(i+43)MOD47                        :REM repetition is 42 data bars + 5 format bars. offset and modulo. if j<42 it is a data bar and we must change p.

    REM if i DIV 51=1 we are in the second half, so add 42 to j. Find the bitmap for left hand value, from character j/7 of the input.
    REM i>50 evaluates to false=0 true=-1. XOR this with p to invert bitmap for right hand side. Shift and AND with 1.
    IF j<42 j+=i DIV51*42:p=ASC(MID$("XLd^bFznvh",  VAL(MID$(n$,j/7+1,1))+1  )) :p=(i>50EORp)>>(j MOD7) AND 1

    IF j MOD 7 = 0 PRINT                  :REM format test output
    PRINT ;p;                             :REM print test output
    IF p LINEi*2-2,0,i*2-2,60             :REM if p=1 plot bar. there are 2 logical units for each pixel.
  NEXT

Typical output, ungolfed version, with test output


Enumerate all possible grids of integers with constraints

APL (Dyalog), 42 bytes

{o/⍨(⍵≡+/,+⌿)¨o←3 3∘⍴¨(,o∘.,⊢)⍣8⊢o←⍳1+⌈/⍵}

Try it online!

Uses ⎕IO←0 which is default on many systems. The other stuff in the header is just pretty printing for the matrices (boxed display).

Input is list of six values, rows sums first, then column sums.

How?

o←⍳1+⌈/⍵ - o gets the range 0 to the maximum (⌈/) of input

,o∘.,⊢ - cartesian product with o and flatten (,)

⍣8 - repeated for eight times

3 3∘⍴¨ - shape every 9-items list into a 3×3 matrix

¨o← - save these matrices to o, and for each

+/,+⌿ - check if the rows sums (+/) concatenated to the column sums (+⌿)

⍵≡ - correspond with the input

o/⍨ - filter o (the matrices array) by truthy values


Python, 72 68 66 bytes
We can ignore left/right - if we assume it's always pointed at us we'll always take the right action. Then if our assumption was wrong we did a useless jump/duck, but that doesn't matter - we'll still be safe.
Similarly, there is no incentive to do nothing. Rather, it's shorter code to always duck, and jump when necessary. Ducking will only be unsafe if the bullet bill is exactly one above the block we're standing on. In that case we will take our x position, bullet bill's y position, take the absolute difference, divide by bullet bill's speed and jump 0.2 seconds before that.
lambda a,b,_,s,x,y:["duck","jump "+`max(0,abs(a-x)/s-.2)`][y+1==b]

Call like this:
f=lambda a,b,_,s,x,y:["duck","jump "+`max(0,abs(a-x)/s-.2)`][y+1==b]
f(5, 1, "left", 2.5, 0, 0)


Python 2, 97 95 94 92 bytes

-2 bytes thanks to Luka
This version produces an exception  on n=0,but without printing anything

n=input()*2
m=abs(n)
for i in range(2,m+1)[::n/m]:print(i/2*'/-\-'[i%2::2][::n/m]).center(m)

Try it online!

Non-error version, Python 2, 94 bytes

n=input()*2
x=n>0 or-1
for i in range(2,x*n+1)[::x]:print(i/2*'/-\-'[i%2::2][::x]).center(n*x)

Try it online!


05AB1E, 4 bytes
.¥{¥

Try it online!
Explanation
.¥{¥
.¥   # Undelta the input list
  {  # Sort it
   ¥ # And get the deltas


Python 2 - 380 bytes

Try it online

Shorter answer, thanks to @ovs. This one requires list of integers and string as input. Example: 28,26,"ABCDEFGHIJKLM()NOPQRSTUVWXYZ".
Check edits for older version, that accepts plain string like "28,26,ABCDEFGHIJKLM()NOPQRSTUVWXYZ"

I=input()
c=-1
G=I[c]
I=map(int,I[:c])
u=r=""
L=[u]*len(G)
H=len(G.split('(')[0])
L[H:H+1]='()'
d=1
s=0
f="".join
for h in I:
 s+=1;c+=h*d;d=(1,-1)[H-c<0];T=f(L)
 if H<=c<H+2:u='o'if s==len(I)else'X';break
 if c<0:r="^"+T;break
 if c>len(G):r=T+"$";break
 L[c]=G[c]
else:
 m=H-c if~d else c-H-1
 if d>0:c+=1
 L=L[:c]+[str(m)]+L[c:];r=f(L)
print r or("%s)"%u).join(f(L).split(')'))

Explanation (for older version, but approach is same):

I=input().split(',')             # split input
G=I[-1]                          # last element - Green
I=map(int,I[:-1])                # convert all other (hits) to int
L=[""]*len(G)                    # empty list of same length as Green, used to ouput
H=len(G.split('(')[0])           # index of hole
L[H]='('                         # hole is always printed
L[H+1]=')'
c=-1                             # current index on Green
d=1                              # direction of hit
u=r=""                           # strings for output and in-hole marker (X)/(o)
s=0                              # number of current hit
for h in I:
    s+=1
    c+=h*d                       # move current by hit * direction
    d=(1,-1)[H-c<0]              # calculate new direction
    T="".join(L)                 # used to remove code duplication
    if H<=c<H+2:                 # if in hole
        u='o'if s==len(I)else'X' # check whether it is last hit or not
        break
    if c<0:                      # if out of Green on the left
        r="^"+T                  # add '^' and join all visited indices
        break
    if c>len(G):                 # if out of Green on the right
        r=T+"$"                  # add '&' after join all visited indices
        break
    L[c]=G[c]                    # mark visited index
else:                            # rare occasion of for-else construction - executes if never break out of loop
                                 # which means, that we are out of hits and not in hole
    m=H-c if~d else c-H-1        # calculate distance to hole
    if d>0:
        c+=1
    L=L[:c]+[str(m)]+L[c:]       # expand L list with distance
    r="".join(L)                 # join list
t="".join(L).split(')')
if r:
    print r                      # ouput r in all cases exept in-hole
else:
    print t[0]+"%s)"%u+t[1]      # output for in-hole cases


m3ph1st0s's programming puzzle 2 (C++): "Call hard!"

In thinking about it some more, the problem states "insert two more lines where the comment specifies" not "statements". Taking that into consideration, here is another shorter answer (though it depends on how you define "the first line will NOT call any function, including cout"):

std::
cout<<q;

The first line qualifies which cout will be used, and the second line includes the actual operator that results in calling operator<< for the std::ostream & const char* operands.


Bash, 34

dd if=/dev/sda of=file.wav count=1

If you don't want hard drive 'randomness', (a lot slower)

dd if=/dev/random of=file.wav count=9

SPIN, 28

word x=0
repeat
 word[?x]=?x


Python - 774 722 707 698 685 chars
import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
def j(s):
 v,g,l=[0]*15,[0]*4,''
 for c in s:
  r,s=c[0],c[1];v[t.find(r)]+=1;g[q.find(s)]+=1
 c,h,k,m,f=0,0,[0,0,[],[],[]],0,0
 for x,i in e(v):
  for b in[2,3,4]:
   if i==b:k[b]+=[x]
 v[1]=v[14]
 for x,i in e(v):
  if i:
   c+=1
   if c==5:m,h=1,x
   if i==1:l+=_([x])
  else:c=0
 f,l,d=max(g)//5*2,l[::-1],'';z=f+m
 if z==3:d='z'+l
 if k[4]:d='y'+_(k[4])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+l
 return d or l
p=sys.argv
print(1+(j(p[1:6])<j(p[6:])))

I chose to generate a string for each hand that represents it, starting with a character for the type of hand, followed by characters describing the particular variation of the type (for example, which card did you just have 4 of?), followed by the values of the remaining cards in case of a tie (if both players have the same double pair, the 5th card will have to decide who wins). I've tested it quite extensively, but I don't actually play poker, so I hope I got it right. Also, I know it's not fully golfed yet, I can probably shave off a few dozen chars later on.


Ruby, 80 76 + 2 = 78

With command-line flags p0, run

gsub$1,$2%p=$`[/e/]while~/(.) = (?!\1)(.)/
$_="Alex is #{p ?:wrong: :right}"

Explanation:

This uses pure string manipulation. p0 reads the full input as a single string into the variable $_. Then, we repeatedly match that string against the regular expression /(.) = (?!\1)(.)/, which finds all strings of the form "X = Y" where X and Y aren't the same letter, and assigns X to $1 and Y to $2. When such a match is found, gsub$1,$2 replaces all instances of X with Y in the string. We also check whether this match occurred before or after the "therefore" with

$`[/e/]

If it occurred after, it's an unjustified claim and Alex is wrong. We track whether any such occurrences have happened using p=. The use of p as a tracking variable prevents things from breaking if the loop never hits even once, since p will return nil if it's never been assigned to.

As of this post, the CJam solution is longer. A proud, if no doubt fleeting moment.

Edit: Yup, quickly dethroned. Also, to finish the explanation, with the p flag the final value of $_ is output at the end of execution, so the last line is the output.


R, 39 37 bytes

!sum((y=1:(x=scan()))[!x%%y]^2)^.5%%1

Try it online!

Uses the classic "test if perfect square" approach, taking the non-integral part of the square root S^.5%%1 and taking the logical negation of it, as it maps zero (perfect square) to TRUE and nonzero to FALSE.

Thanks to Robert S for saving a couple of bytes!


Minsky Register Machine (25 non-halt states)

Not technically a function, but it's in a computing paradigm which doesn't have functions per se...

This is a slight variation on the main test case of my first MRM interpretation challenge:

Input in registers n and k; output in register r; it is assumed that r=i=t=0 on entry. The first two halt instructions are error cases.


Extend the most recent "nice" OEIS sequence: stepping stone puzzle on a grid

C + OpenMP, N=5
New version with a proper handling of the 112-1113 case.
a(5) = 49
 0 46 26  0  0  0  0  0  0  0  0 35  0

 0 20  0  6 28 48  0  0  0  0 34  1 36

39 19  1  2  3 17  0 30  0  0 33  0 37

 0  0 18  7  1  4  9  0 21 32  0  0  0

 0 40  0  8 38  5 43 10 11  0 44  0  0

 0  0 22  0 13  0 15  0  1 12  0  0  0

47 23  0 14 27  0 31 16 29  0  0  0  0

 0 24  1  0 41  0  0  0 45  0  0  0  0

49 25  0 42  0  0  0  0  0  0  0  0  0

How it works
The program will only work for N=5, for higher numbers you'd need some adjustments. First lets take a look how an easier approach for N=4 would look like. We need at least 112 next to each other in some arrangement. Because there are only two 1s left, every other number cannot be made only by new 1s.
So starting from the six possible starting positions for 112:
1 1   1 2 1   1 _ 1   1 _   1 _ _   1 _ _
2 _           _ 2 _   2 1   _ 2 1   _ 2 _
                                    _ _ 1

we can take a look at every space placed two spots away and check their sum (Note: with some proper case handling, you should be fine to check the direct neighbors, though I took the safe route).
      0 0 0 0 0 0
      0 1 2 2 1 0

1 1 -> 0 3 . . 1 0
2 _    0 3 . 4 1 0
0 2 2 2 0 0
0 0 0 0 0 0
For every spot: check if the sum is the next needed number (in this case 3) or if we can still place some 1s: is the sum plus some newly added 1s the next needed number. In the latter case, we need to make sure that the new 1s don't interfere with existing numbers > 1, e.g.
3 1
1 1 1
  2

wouldn't be valid as the 2-placement would have been illegal, but
1 1
2   3 1
    1

would be fine. Note that I only increase the bounding box for two spots around non-1 numbers. So for the lower right corner, the next spots to try are as following:
1 _ _ _
_ 3 1 _
_ 1 _ _
_ _ _ _
  x

The x spot wouldn't get checked, as its number would only neighbor new 1s – and for N=4 this is not possible as mentioned before.
For N>4 this get a little more complicated: it is not guaranteed that every number will be connected to the first 112. Another cluster might start independently: 1113. But after that every number cannot be made only of new 1s, thus will be connected to either 1113 or 112. Note that we don't have to handle anything else in the N=5 case (but would need for N>5): having two clusters with 1 and 11114 will already be handled, as 2 and 3 must also be placed in 11114; so every 11114 will already be checked by 112 or 1113.
So we need to get a bounding box to find out how close 112 and 1113 can be placed. For this we run two boards that cannot touch, scoring them by the sum of the distances they managed to get away from the starting position. This is the best they manage:
  0  0  0  0  0  0  0  0  0

  0  0  0  0  0  0  0  0  0

  0  0  0  0 15  0  0  0  0

  0  0 11 10  5  0  0  0  0

  0  0  0  1  4 12  0  0  0

  0  0  0  0  2  1 13  0  0

  0  0  0  0  0  0 14  0  0

  0  0  0  0  0  0  0  0  0

  0  0  0  0  0  0  0  0  0

  …

  0  0  0  0  0  0  0  0

  0  0  0  0  0  0  0  0

  0  0 17  9  0  3  1  0

  0  0  0  8  1  6  1  0

  0  0  0 16  7  0  0  0

  0  0  0  0  0  0  0  0

  0  0  0  0  0  0  0  0

They cannot leave 5 tiles. So if we place the initial 3 within a 20x20 (+ a padding of 4 for off-by-one-errors :-)) field centered around the 2, we either get two disconnected clusters that have a score independent on where they are exactly, or two clusters that eventually will join up. So anything up to
1 1 _ _ _ _ _ _ _ _ _ _ _ 1 1
_ 2 a b c d e _ e d c b a 3 1

will be checked with 11 spaces in between; enough that they cannot meet up.
With all this, then just recursively try out all the possibilities in a depth-first-search. Always modifying only one board, we only need memory for a(N) recursive steps.
OMP is only used to check the initial boards in parallel. This is far from a balanced workload; the final position needs about twice as long as the others. However, it is the easiest to implement. :-)
The program
Compiled with clang -O3 -o main main.c -fopenmp and ran with time OMP_NUM_THREADS=4 ./main.
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef uint8_t mem_t;
typedef uint16_t sum_t;
#define S 64
const int startx = S/2, starty = S/2;
// for N > 5, adjust the unrolled loops in step
#define MAX_CELL 5
#define MAX_BOARDS 2

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)

const int ys[8] = {0,1,1,1,0,-1,-1,-1};
const int xs[8] = {1,1,0,-1,-1,-1,0,1};

inline
void add_sum(sum_t v, int y, int x, sum_t sum[S][S]) {
    for(int d=0;d<8;d++)
        sum[y+ys[d]][x+xs[d]] += v;
}
inline
void add_placed(sum_t v, int y, int x, mem_t placed[S][S]) {
    for(int d=0;d<8;d++)
        placed[y+ys[d]][x+xs[d]] += v;
}

typedef struct board {
  int y0, y1, x0, x1;
  mem_t b[S][S], placed[S][S];
  sum_t sum[S][S];
} board_t;

void st_print(int c, int max, board_t *b) {
    printf("%d cells, %d max\n", c, max);
    for(int y=b->y0;y<=b->y1;y++){
        for(int x=b->x0;x<=b->x1;x++) printf("%*d", 3, b->b[y][x]);
        puts("\n");
    }
}

void step(int c, mem_t max, board_t *bs, int bl, mem_t *best_max, board_t best_b[MAX_BOARDS], int optimize_spread) {
    // check board size
    for(int i=0;i<bl;i++) {
            if (bs[i].y0 < 2 || bs[i].y1 >= S - 2 || bs[i].x0 < 2 || bs[i].x1 >= S - 2) {
                    st_print(c, max, &bs[i]);
                printf("board too small %d %d %d %d", bs[i].y0, bs[i].y1, bs[i].x0, bs[i].x1);
                exit(1);
            }
    }
    // new best
    if (c == MAX_CELL) {
        int score = 0;
            if (optimize_spread) {
                    for (int i=0;i<bl;i++)
                        score += MAX(starty - bs[i].y0,
                                 MAX(bs[i].y1 - starty,
                                 MAX(startx - bs[i].x0,
                                     bs[i].x1 - startx)));
            } else {
                    score = max;
            }
            if (*best_max < score) {
                for (int i=0;i<bl;i++)
                        memcpy(&best_b[i], &bs[i], sizeof(board_t));
                *best_max = score;
            }
    }
    // place with 0 new 1-cells
    if(!optimize_spread || max != 2)
    for(int i=0;i<bl;i++) {
            board_t *b=bs+i;
            for(int y=b->y0;y<=b->y1;y++)
            for(int x=b->x0;x<=b->x1;x++)
            if(b->sum[y][x] == max + 1 && !b->b[y][x]) {
                b->b[y][x] = max + 1;
                add_sum(max+1,y,x,b->sum);
                add_placed(1,y,x,b->placed);
                int y0o = b->y0, y1o = b->y1, x0o = b->x0, x1o = b->x1;
                b->y0 = MIN(b->y0, y-2);
                b->y1 = MAX(b->y1, y+2);
                b->x0 = MIN(b->x0, x-2);
                b->x1 = MAX(b->x1, x+2);
                step(c, max + 1, bs, bl, best_max, best_b, optimize_spread);
                b->y0 = y0o, b->y1 = y1o, b->x0 = x0o, b->x1 = x1o;
                add_placed(-1,y,x,b->placed);
                add_sum(-(max+1),y,x,b->sum);
                b->b[y][x] = 0;
            }
    }
    // sorry for the repetition, couldn't get clang to optimize it otherwise
    // place with 1 new 1-cells
    if(!optimize_spread || max != 2)
    if(c + 1 <= MAX_CELL)
    for(int i=0;i<bl;i++) {
            board_t *b=bs+i;
            for(int y=b->y0;y<=b->y1;y++)
            for(int x=b->x0;x<=b->x1;x++)
            if(b->sum[y][x] == (max + 1) - 1 && !b->b[y][x]) {
                for(int d1=0;d1<8;d1++) {
                    if (b->placed[y+ys[d1]][x+xs[d1]]) continue;

                    b->b[y+ys[d1]][x+xs[d1]] = 1;
                    b->b[y][x] = max + 1;
                    add_sum(max+1,y,x,b->sum);
                    add_sum(1,y+ys[d1],x+xs[d1],b->sum);
                    add_placed(1,y,x,b->placed);
                        int y0o = b->y0, y1o = b->y1, x0o = b->x0, x1o = b->x1;
                        b->y0 = MIN(b->y0, y-2);
                        b->y1 = MAX(b->y1, y+2);
                        b->x0 = MIN(b->x0, x-2);
                        b->x1 = MAX(b->x1, x+2);
                        step(c + 1, max + 1, bs, bl, best_max, best_b, optimize_spread);
                        b->y0 = y0o, b->y1 = y1o, b->x0 = x0o, b->x1 = x1o;
                    add_placed(-1,y,x,b->placed);
                    add_sum(-(max+1),y,x,b->sum);
                    add_sum(-1,y+ys[d1],x+xs[d1],b->sum);
                    b->b[y+ys[d1]][x+xs[d1]] = 0;
                    b->b[y][x] = 0;
                }
            }
    }
    // place with 2 new 1-cells
    if(!optimize_spread || max != 2)
    if(c + 2 <= MAX_CELL)
    for(int i=0;i<bl;i++) {
            board_t *b=bs+i;
            for(int y=b->y0;y<=b->y1;y++)
            for(int x=b->x0;x<=b->x1;x++)
            if(b->sum[y][x] == (max + 1) - 2 && !b->b[y][x]) {
                for(int d1=0;d1<8-1;d1++) {
                    if (b->placed[y+ys[d1]][x+xs[d1]]) continue;
                for(int d2=d1+1;d2<8;d2++) {
                    if (b->placed[y+ys[d2]][x+xs[d2]]) continue;

                    b->b[y+ys[d1]][x+xs[d1]] = 1;
                    b->b[y+ys[d2]][x+xs[d2]] = 1;
                    b->b[y][x] = max + 1;
                    add_sum(max+1,y,x,b->sum);
                    add_sum(1,y+ys[d1],x+xs[d1],b->sum);
                    add_sum(1,y+ys[d2],x+xs[d2],b->sum);
                    add_placed(1,y,x,b->placed);
                        int y0o = b->y0, y1o = b->y1, x0o = b->x0, x1o = b->x1;
                        b->y0 = MIN(b->y0, y-2);
                        b->y1 = MAX(b->y1, y+2);
                        b->x0 = MIN(b->x0, x-2);
                        b->x1 = MAX(b->x1, x+2);
                        step(c + 2, max + 1, bs, bl, best_max, best_b, optimize_spread);
                        b->y0 = y0o, b->y1 = y1o, b->x0 = x0o, b->x1 = x1o;
                    add_placed(-1,y,x,b->placed);
                    add_sum(-(max+1),y,x,b->sum);
                    add_sum(-1,y+ys[d1],x+xs[d1],b->sum);
                    add_sum(-1,y+ys[d2],x+xs[d2],b->sum);
                    b->b[y+ys[d1]][x+xs[d1]] = 0;
                    b->b[y+ys[d2]][x+xs[d2]] = 0;
                    b->b[y][x] = 0;
                }
                }
            }
    }
    // place with 3 new 1-cells
    if(c + 3 <= MAX_CELL)
    for(int i=(optimize_spread && max == 2);i<bl;i++) {
            board_t *b=bs+i;
            for(int y=b->y0;y<=b->y1;y++)
            for(int x=b->x0;x<=b->x1;x++)
            if(b->sum[y][x] == (max + 1) - 3 && !b->b[y][x]) {
                for(int d1=0;d1<8-2;d1++) {
                    if (b->placed[y+ys[d1]][x+xs[d1]]) continue;
                for(int d2=d1+1;d2<8-1;d2++) {
                    if (b->placed[y+ys[d2]][x+xs[d2]]) continue;
                for(int d3=d2+1;d3<8;d3++) {
                    if (b->placed[y+ys[d3]][x+xs[d3]]) continue;

                    b->b[y+ys[d1]][x+xs[d1]] = 1;
                    b->b[y+ys[d2]][x+xs[d2]] = 1;
                    b->b[y+ys[d3]][x+xs[d3]] = 1;
                    b->b[y][x] = max + 1;
                    add_sum(max+1,y,x,b->sum);
                    add_sum(1,y+ys[d1],x+xs[d1],b->sum);
                    add_sum(1,y+ys[d2],x+xs[d2],b->sum);
                    add_sum(1,y+ys[d3],x+xs[d3],b->sum);
                    add_placed(1,y,x,b->placed);
                        int y0o = b->y0, y1o = b->y1, x0o = b->x0, x1o = b->x1;
                        b->y0 = MIN(b->y0, y-2);
                        b->y1 = MAX(b->y1, y+2);
                        b->x0 = MIN(b->x0, x-2);
                        b->x1 = MAX(b->x1, x+2);
                        step(c + 3, max + 1, bs, bl, best_max, best_b, optimize_spread);
                        b->y0 = y0o, b->y1 = y1o, b->x0 = x0o, b->x1 = x1o;
                    add_placed(-1,y,x,b->placed);
                    add_sum(-(max+1),y,x,b->sum);
                    add_sum(-1,y+ys[d1],x+xs[d1],b->sum);
                    add_sum(-1,y+ys[d2],x+xs[d2],b->sum);
                    add_sum(-1,y+ys[d3],x+xs[d3],b->sum);
                    b->b[y+ys[d1]][x+xs[d1]] = 0;
                    b->b[y+ys[d2]][x+xs[d2]] = 0;
                    b->b[y+ys[d3]][x+xs[d3]] = 0;
                    b->b[y][x] = 0;
                }
                }
                }
            }
    }
}

void set_starting_board(board_t* b, int i) {
    int x0 = startx, y0 = starty;
    b->b[y0][x0] = 2;
    if (i == 0) b->b[y0-1][x0-1] = 1,
                b->b[y0+1][x0+1] = 1;
    if (i == 1) b->b[y0-1][x0-1] = 1,
                b->b[y0][x0+1] = 1;
    if (i == 2) b->b[y0][x0-1] = 1,
                b->b[y0][x0+1] = 1;
    if (i == 3) b->b[y0-1][x0] = 1,
                b->b[y0][x0+1] = 1;
    if (i == 4) b->b[y0-1][x0-1] = 1,
                b->b[y0-1][x0+1] = 1;
    if (i == 5) b->b[y0-1][x0] = 1,
                b->b[y0-1][x0+1] = 1;

    for(int y=1;y+1<S;y++)
    for(int x=1;x+1<S;x++)
    for(int yd=-1;yd<=1;yd++)
    for(int xd=-1;xd<=1;xd++)
    if(yd!=0||xd!=0)
        b->sum[y][x] += b->b[y+yd][x+xd];
    for(int y=1;y+1<S;y++)
    for(int x=1;x+1<S;x++)
    for(int yd=-1;yd<=1;yd++)
    for(int xd=-1;xd<=1;xd++)
        b->placed[y][x] += b->b[y+yd][x+xd] > 1;

}

int get_bounding_box() {
    int x0 = startx, y0 = starty;
    board_t best_b[6][3] = {0};
    mem_t best_max[6] = {0};

 #pragma omp parallel for
    for(int i=0;i<6;i++) {
        board_t bs[] = {(board_t){y0 - 3, y0 + 3, x0 - 3, x0 + 3, {0}, {0}, {0}},
                            (board_t){y0, y0, x0, x0, {0}, {0}, {0}}};
            set_starting_board(&bs[0], i);
        step(2, 2, bs, 2, &best_max[i], best_b[i], 1);
    }

    int best_i=0, mm = 0;
    for(int i=0;i<6;i++)
        if (best_max[i] > mm)
            mm = best_max[i],
            best_i = i;
    printf("most spread of distant 112 and 1113: %d\n", best_max[best_i]);
    st_print(MAX_CELL, best_max[best_i], &best_b[best_i][0]);
    st_print(MAX_CELL, best_max[best_i], &best_b[best_i][1]);

    return best_max[best_i] + 4;
}

int main(int argc, char **argv) {
    int bb = get_bounding_box();

    int x0 = startx, y0 = starty;
    board_t best_b[6][3] = {0};
    mem_t best_max[6] = {0};

 #pragma omp parallel for
    for(int i=0;i<6;i++) {
        board_t bs[] = {(board_t){y0 - bb, y0 + bb, x0 - bb, x0 + bb, {0}, {0}, {0}},};
            set_starting_board(&bs[0], i);
        step(2, 2, bs, 1, &best_max[i], best_b[i], 0);
    }

    int best_i=0, mm = 0;
    for(int i=0;i<6;i++)
        if (best_max[i] > mm)
            mm = best_max[i],
            best_i = i;
    st_print(MAX_CELL, best_max[best_i], &best_b[best_i][0]);

    return 0;
};


Golf you a Double Quine for greater good!

Whitespace and Perl, 992 975 characters

Good Evening Ladies and Gentlemen.

To start with, here is my submission encoded in base64, which I feel is the best way to communicate a large Whitespace program. (You really don't want to use an encoding that leaves any whitespace as-is, so there's no point in selecting something more "readable".)

c2F5PDwgeDI7c2F5PDwwLDAgIApzYXk8PCB4MjtzYXk8PDAsMCAgCgoJCQogICAJCSAgCSAgCSAJ
CSAgCSAgCQkgCSAJIAkJCQkJICAJCSAJCQkgCQkJCQkgCSAJIAkJIAkgCSAgIAkJCQkJICAgCQkg
IAkgCQkgCSAJCSAJICAgIAkJCQkgCSAgCSAJCSAJICAgIAkgCQkgICAJICAgICAgCQkJIAkJCQkJ
IAkJCSAJCQkJICAgICAJCQkgCSAgICAgIAkJCQkJICAgICAgCQkgICAJCSAgICAJCQkJCQkJCSAg
CSAJIAkgICAJCQkgICAJCQkJCSAgCQkJCSAJICAgIAkgCQkJCQkgCSAgICAgCSAgCSAJICAgICAg
CSAgICAJICAgICAJCSAgIAkJCSAJIAkJCQkJCSAJCSAJIAkgICAgICAgCQkgIAkgICAgICAgICAg
IAkJICAgCSAJCQkgCSAgICAgCQkJCQkJIAkgICAgCQkJCSAJCQkJICAJCQkgICAJCQkgCSAgCSAg
IAkJCQkgIAkJIAkJCSAgIAkJCSAJCQkgCQkJICAJCSAJICAJIAkJCSAJIAkgCQkgICAgIAkgCSAJ
ICAJICAJIAkJICAgICAJIAkgICAgCQkJCSAgCSAJCSAJIAkJIAkgIAkgCSAJCSAJCSAJCSAJCQkg
CQkJICAgIAkJCSAgCSAgCQogICAJICAgICAJCQkJCSAJCSAJIAkgCSAJICAJCQkgICAJICAgCSAg
ICAJCSAJICAgICAgICAgCSAgIAkJCQkgCQkgICAgCQkgCSAJICAJCQkgCQkJCSAJCQkgICAJICAg
IAkgCSAJCQkgIAkJCQkgCSAJCSAJIAkgCQkJCSAJICAJIAkJIAkgICAJCiAKICAKICAgIAogCSAg
CQoKICAJCiAKICAgIAkJCQkgCSAKCSAJCQkKICAgICAJCQkJIAkgCgkgCSAgCiAgIAkJCgkgIAoK
CQkJCiAKCgoJIAkKICAgCSAgIAkgIAoKIAkKIAkgIAkKCiAJIAogICAJIAoKIAkKCiAJIAoKIAkK
CQogCSAgIAkgCgogCQoKCgoKICAgCiAgIAogCiAKIAkKCiAJCgogICAgCiAKIAoJIAogCiAgICAJ
IAoJIAkJIAoJICAgCSAKCSAJIAogCSAgCgogIAogCiAgICAJCQoJIAkJICAJCSAJCQkKCSAgCiAg
CQkJICAgCgkgCQkgICAJICAgICAKCSAgIAkKICAgICAJCQoJIAkgIAogICAJCQoJICAKCgkJCiAK
CgoJCjAK

Here's an excerpt that highlights all of the visible parts of the source. ⇥ is used to indicate a tab and ↲ to indicate a newline.

say<< x2;say<<0,0  ↲
say<< x2;say<<0,0  ↲
↲
⇥⇥↲
   ⇥⇥  ⇥ [... etcetera ... skipping rest of a really long line ...]↲
   ⇥⇥⇥ ⇥⇥[... etcetera ... shorter but still quite a long line ...]↲
 ↲
  ↲
    ↲
 ⇥  ⇥↲
[... etcetera ... whole lotta whitespace in here ...]
⇥⇥↲
 ↲
↲
↲
⇥↲
0↲

Perl was the natural choice for the second language in this challenge, being one of the best general-purpose languages for writing compact quines. My shortest Perl quine is 19 bytes:

say<< x2
say<< x2

– and you can see how it was the seed for the Perl half of the double quine. My best Whitespace quine, in comparison, is 541 bytes long. (Though shorter ones do exist – 445 bytes is the best I've seen.)

From the Perl interpreter's point of view, the first line of the double quine's source file contains the two statements that make up the entire program proper, as the remaining contents are two quoted strings. The first string is the repeated line of Perl, and is delimited by the blank third line. The second string is all whitespace, and runs from the fourth line of the source all the way to the 0 delimiter at the bottom of the file.

When taken as a Whitespace program, the first four lines contain three instructions that are largely useless. (Their effect is to push two zero values onto the stack, and then discard the second one.) They're included just to get safely past the newlines that the Perl program requires – the real program starts after that. Rather than quote the unreadable source any further, here's a paraphrasing of the instructions that make up the Whitespace program, in an assembly-like format:

# Representation of "say<< ;say<<0,0  \n" in base 122 as ASCII chars.
PERLCODE = 44892457841068708924520433691075560592081

# Represention of the whitespace program, following the "push PERLCODE"
# instruction, in base 3 (see comments on wsout).
WSCODE = 9823454421986355730445143846606456399449033186160554878002671428613111806443504867738858766142050504887335990409088441824104338753030405625930185

# Set up the stack and the heap. The first three instructions are not
# particularly useful; they're just there to skip past the newlines in
# the Perl code. (Though the initial zero on the stack does get used
# at the very end.)

        push    0
        push    0
        jneg    wsout

        push    WSCODE
        push    PERLCODE
        dup
        dup
        push    0
        copy    1

# Output the first four lines of the file.

perl:   dup
        mod     122
        putchar
        div     122
        dup
        jnzero  perl
        pop
        jzero   perl
        push    68              # represents "jneg wsout"
        call    wsout

# Output the rest of the file.

        copy    1
        call    pushout
        push    2
        call    wsout
        call    pushout
        call    wsout
        putnum
        push    2
        call    wsout
        exit

# pushout: Output a Whitespace push instruction, using the number on
# the top of the stack as the instruction's argument. (Recursion is
# used to output the bits MSB-first.)

pushout:
        push    0
        dup
        call    wsout
        call    wsout
bits:   dup
        jzero   bitend
        dup
        mod     2
        swap
        div     2
        call    bits
bitend: call    wsout
        ret

# wsout: Output a sequence of whitespace characters as represented by
# the number on the top of the stack. The number is read in base 3,
# LSB-first, with 0 = SPC, 1 = TAB, 2 = NL. Calling wsout with a value
# of zero will output a single space.

wsout:
        dup
        mod     3
        mul     -23             # some ugly math that transforms
        mod     -24             # (0, 1, 2) into (32, 9, 10)
        add     32
        putchar
        div     3
        dup
        jnzero  wsout
        pop
        ret

The giant numbers at the top are what we Whitespace users have to use in lieu of actual strings. Don't bother trying to run this on a Whitespace interpreter that doesn't have proper bignum support.

Finally, here's the program again, but this time with C-style escapes, since it was specifically requested:

say<< x2;say<<0,0  \nsay<< x2;say<<0,0  \n\n\t\t\n   \t\t  \t  \t \t\t  \t  \t\t \t \t \t\t\t\t\t  \t\t \t\t\t \t\t\t\t\t \t \t \t\t \t \t   \t\t\t\t\t   \t\t  \t \t\t \t \t\t \t    \t\t\t\t \t  \t \t\t \t    \t \t\t   \t      \t\t\t \t\t\t\t\t \t\t\t \t\t\t\t     \t\t\t \t      \t\t\t\t\t      \t\t   \t\t    \t\t\t\t\t\t\t\t  \t \t \t   \t\t\t   \t\t\t\t\t  \t\t\t\t \t    \t \t\t\t\t\t \t     \t  \t \t      \t    \t     \t\t   \t\t\t \t \t\t\t\t\t\t \t\t \t \t       \t\t  \t           \t\t   \t \t\t\t \t     \t\t\t\t\t\t \t    \t\t\t\t \t\t\t\t  \t\t\t   \t\t\t \t  \t   \t\t\t\t  \t\t \t\t\t   \t\t\t \t\t\t \t\t\t  \t\t \t  \t \t\t\t \t \t \t\t     \t \t \t  \t  \t \t\t     \t \t    \t\t\t\t  \t \t\t \t \t\t \t  \t \t \t\t \t\t \t\t \t\t\t \t\t\t    \t\t\t  \t  \t\n   \t     \t\t\t\t\t \t\t \t \t \t \t  \t\t\t   \t   \t    \t\t \t         \t   \t\t\t\t \t\t    \t\t \t \t  \t\t\t \t\t\t\t \t\t\t   \t    \t \t \t\t\t  \t\t\t\t \t \t\t \t \t \t\t\t\t \t  \t \t\t \t   \t\n \n  \n    \n \t  \t\n\n  \t\n \n    \t\t\t\t \t \n\t \t\t\t\n     \t\t\t\t \t \n\t \t  \n   \t\t\n\t  \n\n\t\t\t\n \n\n\n\t \t\n   \t   \t  \n\n \t\n \t  \t\n\n \t \n   \t \n\n \t\n\n \t \n\n \t\n\t\n \t   \t \n\n \t\n\n\n\n\n   \n   \n \n \n \t\n\n \t\n\n    \n \n \n\t \n \n    \t \n\t \t\t \n\t   \t \n\t \t \n \t  \n\n  \n \n    \t\t\n\t \t\t  \t\t \t\t\t\n\t  \n  \t\t\t   \n\t \t\t   \t     \n\t   \t\n     \t\t\n\t \t  \n   \t\t\n\t  \n\n\t\t\n \n\n\n\t\n0\n


JavaScript (ES8), 81 74 71 bytes

f=
(x,b,n,g=x=>x.toString(b))=>g(x-x%1)+'.'+g(x%1).substr(2,n).padEnd(n,0)

<input id=x><input type=number min=2 max=36 value=10 id=b><input type=number min=1 max=20 value=10 id=n>

Works for x between 1e-6 and 1e21, b from 2 to 36 (exactly as required) and n from 1 to anything from 10 to 48 depending on the base before floating-point errors creep in. Edit: Saved 7 bytes with help from @Birjolaxew. Saved a further 3 bytes with help from @tsh. Previous 74-byte version also worked with negative numbers:

f=
(x,b,n,[i,d]=`${x.toString(b)}.`.split`.`)=>i+`.`+d.slice(0,n).padEnd(n,0)

<input id=x><input type=number min=2 max=36 value=10 id=b><input type=number min=1 max=20 value=10 id=n>


Mathematica
The following implementation challenges the player to find one or more solutions to the eight queens problem. (It was too easy to simply have the program output the answers.)
Clicking on any of the squares in the chessboard toggles between "queen" and .
When show attacks is checked, any attacks between queens are highlighted.
The following picture queenImg.

In the board below, no queen attacks another:

Placing a fourth queen on a conflicting square results in two reciprocal attacks.

The following is one of the solutions.

DynamicModule[{qns = ConstantArray[0, {8, 8}]},
Manipulate[
ClickPane[
Dynamic[ArrayPlot[
 Array[Boole[(Mod[#1, 2] == 0 \[And]
       Mod[#2, 2] == 0) \[Or] (Mod[#1, 2] == 1 \[And]
       Mod[#2, 2] == 1)] &, {w, w}],
 ColorRules -> {1 -> White, 0 -> LightBrown}, Mesh -> True,
 Epilog -> {Red, Thickness[.005],
   If[attacks,
    Line[Cases[
       Tally@Flatten[z[##] & /@ (Reverse /@ Position[qns, 1]),
         1], {a_, n_} /; n > 1][[All, 1]]], {}],
   Table[Inset[queenImg, p, Automatic, 10/w], {p,
     Position[qns, 1] - .5}]}]], (qns = flip[qns, Ceiling@#]) &],
{{attacks, True, "show attacks"}, {True, False}},
Initialization -> (w = 8;
z[{r_, c_}] := {row[r], col[c], diag1[r, c], diag2[r, c]};
row[r_] := {{0, r - .5}, {8, r - .5}};
col[c_] := {{c - .5, 0}, {c - .5, 8}};
diag1[r_, c_] := {{0, r - c}, {8 - (r - c), 8}};
diag2[r_, c_] := {{0, c + r - 1}, {c + r - 1, 0}};
flip[a_, pos_] := MapAt[(# - 1)^2 &, a, pos])]]


Python 3, 177 170 163 130 bytes

lambda a,b:s(d(a)^d(b))
def s(n,x=0,s=''):
 while n:n-=1;s+=chr(n%256);n>>=8
 return s
def d(n,c=0):
 while s(c)!=n:c+=1
 return c

Try it online!

-14 bytes thanks to notjagan

-33 bytes thanks to Leaky Nun (and switched endianness)

I have no business trying to golf anything in Python, but I didn't want to use Lua since this method needs large exact integers to work on reasonable length stings. (Note: the algorithm is still Really Slow when ramping up the string length.) This is mostly just to provide an answer ;)

Each string is self-inverse, and the empty string is the identity. This simply performs xor under a simple bijection between strings and non-negative integers. s is a helper function that computes the bijection (one way only), and d is the inverse.

Non-slow version (148 bytes, courtesy of Leaky Nun):

lambda a,b:s(d(a)^d(b))
def s(n,x=0,s=''):
 while n:n-=1;s=chr(n%256)+s;n>>=8
 return s
def d(n,c=0):
 while n:c=c*256+ord(n[0])+1;n=n[1:]
 return c

Try it online!

I'm going to hijack this for a group-theory primer as well.

Any right inverse is a left inverse: inv(a) + a = (inv(a) + a) + e = (inv(a) + a) + (inv(a) + inv(inv(a))) = inv(a) + (a + inv(a)) + inv(inv(a)) = (inv(a) + e) + inv(inv(a)) = inv(a) + inv(inv(a)) = e

This also means that a is an inverse of inv(a).

Any right identity is a left identity: e + a = (a + inv(a)) + a = a + (inv(a) + a) = a

The identity is unique, given other identity f: e = e + f = f

If a + x = a then x = e: x = e + x = (inv(a) + a) + x = inv(a) + (a + x) = inv(a) + a = e

Inverses are unique, if a + x = e then: x = e + x = (inv(a) + a) + x = inv(a) + (a + x) = inv(a) + e = inv(a)

Following the proofs should make it fairly easy to construct counterexamples for proposed solutions that don't satisfy these propositions.

Here's a more natural algorithm I implemented (but didn't golf) in Lua. Maybe it will give someone an idea.

function string_to_list(s)
  local list_val = {}
  local pow2 = 2 ^ (math.log(#s, 2) // 1) -- // 1 to round down
  local offset = 0
  list_val.p = pow2
  while pow2 > 0 do
    list_val[pow2] = 0
    if pow2 & #s ~= 0 then
      for k = 1, pow2 do
        list_val[pow2] = 256 * list_val[pow2] + s:byte(offset + k)
      end
      list_val[pow2] = list_val[pow2] + 1
      offset = offset + pow2
    end
    pow2 = pow2 // 2
  end
  return list_val
end

function list_to_string(list_val)
  local s = ""
  local pow2 = list_val.p
  while pow2 > 0 do
    if list_val[pow2] then
      local x = list_val[pow2] % (256 ^ pow2 + 1)
      if x ~= 0 then
        x = x - 1
        local part = ""
        for k = 1, pow2 do
          part = string.char(x % 256) .. part
          x = x // 256
        end
        s = s .. part
      end
    end
    pow2 = pow2 // 2
  end
  return s
end

function list_add(list_val1, list_val2)
  local result = {}
  local pow2 = math.max(list_val1.p, list_val2.p)
  result.p = pow2
  while pow2 > 0 do
    result[pow2] = (list_val1[pow2] or 0) + (list_val2[pow2] or 0)
    pow2 = pow2 // 2
  end
  return result
end

function string_add(s1, s2)
  return list_to_string(list_add(string_to_list(s1), string_to_list(s2)))
end

The idea is basically to split the string based on the power-of-two components of its length, and then treat these as fields with a missing component representing zero, and each non-missing component representing numbers from 1 up to 256^n, so 256^n+1 values total. Then these representations can be added component-wise modulo 256^n+1.

Note: This Lua implementation will have numeric overflow problems for strings of sizes greater than 7. But the set of strings of length 7 or less is closed under this addition.

Try it online!


Python 2, 72 bytes

lambda s:''.join((-~i*(w+w[-2:0:-1]))[i]for i,w in enumerate(s.split()))

Try it online!


JavaScript (Node.js),  122 120 106  103 bytes
Recursively builds the output character by character. The coordinates are 0-indexed.

(w,h,x,y)=>(s=new Date%9023,g=X=>Y<h?Buffer([X-w?(x-X|y-Y?s+1:s%96)%95+32:13])+g(X<w?X+1:!++Y):'')(Y=0)

Try it online!
How?
Problem
To generate the haystack and the needle, we could either:

generate a random haystack and process some loop to generate a random needle until it's different from the haystack
shuffle the whole range of printable characters and pick the first 2 of them

Unfortunately, both approaches are rather lengthy in JS.
Solution
We use instead a method that guarantees to generate 2 distinct characters with a single random number and without any loop.
We pick a random seed \$s\$ in \$[0..9022]\$ and define the haystack \$h\$ and needle \$n\$ as:
$$\begin{align}&h=(s+1)\bmod 95\\
&n=(s\bmod 96)\bmod 95\end{align}$$
(we then need to add \$32\$ to turn them into printable ASCII codes)
Basically, \$h\$ follows the pattern:
$$1,2,3,...,94,0,1,2,3,...$$
while \$n\$ follows the pattern:
$$0,1,2,3,...,94,\color{red}0,0,1,2,3,...$$
The sequences are progressively shifted relative to each other because of the extra \$0\$ in the needle pattern.
This code shows that it does eventually lead to all possible pairs \$(h,n)\$ with \$h\neq n\$ (there are \$95\times 94=8930\$ of them).
And because we need only one random number, we can afford to use the current timestamp in milliseconds as our entropy source with new Date%9023 instead of the longer Math.random()*9023.
Commented
(w, h, x, y) => (      // w = width, h = height, (x, y) = coordinates
  s = new Date % 9023, // s = random seed in [0..9022]
  g = X =>             // g = recursive function taking X
    Y < h ?            //   if we've not reached the end of the grid:
      Buffer([         //     append the next character:
        X - w ?        //       if we haven't reached the end of the line:
          ( x - X |    //         if this is not the position of the needle:
            y - Y ?    //
              s + 1    //           append the haystack character
            :          //         else:
              s % 96   //           append the needle character
          ) % 95 + 32  //
        :              //       else:
          13           //         append a linefeed
      ]) +             //
      g(X < w ? X + 1  //     append the result of a recursive call
              : !++Y)  //     with either (X+1, Y) or (0, Y+1)
    :                  //   else:
      ''               //     stop recursion
)(Y = 0)               // initial call to g with X = Y = 0


Jelly, 10 bytes

0ÆḞ©w¥1#;®

Try it online!

How it works

0ÆḞ©w¥1#;®  Main link. Argument: n

0           Set the return value to 0.
       #    Call the second link to the left with arguments k = 0, 1, 2, ... until
      1     one match has been found.
     ¥        Combine the two links to the left into a dyadich chain.
 ÆḞ             Compute the k-th Fibonacci number...
   ©              and copy it to the register.
    w           Yield 1 if n occurs inside the Fibonacci number, 0 otherwise.
         ®  Yield the value stored in the register.
        ;   Concatenate the index and the Fibonacci number.


PowerShell, 189 195 bytes

param($m,$q)('$m',"'(\d*)~(\d*)','($q-ge(`$1)-and$q-le(`$2))'","'\(\)',$q","'((?<=,|skip )\d+|\d+(?=,| skip))','($q-eq`$1)'","'skip','-and!'"-join'-replace'|iex|% Sp* ','|%{"($_)"})-join'-or'|iex

Try it online! (with a single MPN and value)
Try all test cases with -100..100 as values
View the intermediate code generated, for all test cases (with 666 as the value)

Explanation
I realized early on that the infinities make this untenable for generating arrays and testing for values.
I looked into ranges but in .Net they don't have the range needed (the length of the range is limited to a signed (32 bit) integer, so even if it were ok to limit the range to a signed 32-bit int, I wouldn't have been able to handle all ranges.
So I started to just think about this in terms of starts and ends, and ultimately a series of boolean tests and started creating a bunch of regex replaces to turn an MPN into a boolean expression that PowerShell understands.
I basically broke this down into a few rules:

Ranges were easier to work with first because they can't be expressions on either end, but the open-endedness was a pain to implement shortly. The premise is 2~8 is like saying n >=2 && n <=8, but when one of the ends is missing, leave out the && and the missing side. When both are missing, I was going to originally just replace it with $true. What I ended up doing was not really testing for the missing sides at all, but I made sure to wrap each number in ().
and then do a straight substitution that replaces empty parentheses () with the input value. So, in the case of an MPN like ~8 with an input value of 55, the first replace will generate (55-ge()-and55-le(8)), then the second replace comes along to make it (55-ge55-and55-le(8)), essentially nullifying that part of the range.
Next I had to deal with individual numbers in the MPN, but had to take care not to mess with the ones I inserted from before. It's really just numbers in comma , separated lists, and individual numbers before or after a skip, so I used unfortunatley long lookarounds.
skip is basically the same as -and -not so I do a straight replace of skip to -and! (using ! as shorthand for -not).
The next tricky thing was the low order of precendence for the remaining commas. I originally just replaced them with -or but it didn't account for subsequent expressions so 16,17 skip 16 was generating code like ($n-eq16)-or($n-eq17) -and! ($n-eq16). It needed parentheses, but that seemed unworkable with a straight replace. Since all the other things were replaced except commas, and they have the lowest precedence, I just split the entire generated string on the remaining commas, then wrapped each element in parentheses, and rejoined it with -or.

Ultimately the generated code is just piped into Invoke-Expression (iex) to be executed and then we get the boolean result (you can see the code that gets generated instead of the result here).
This took way too long, and I'm sure there's some room to squeeze out a few more bytes, but I can't look at it anymore :-p


Python 2, 33 bytes

lambda k:pow(3,10**k*2/3+1,10**k)

Try it online!

The pow function efficiently computes the modular exponent 3**(10**k*2/3+1)%10**k.

We're asked to find a solution to r**3 = 3 (mod 10**k). We want to find an exponent e for which the map x -> x**e is inverse to cubing x -> x**3 working mod 10**k, just as the decryption and encryption exponents in RSA cancel to produce the original value. This means that (x**3)**e = x (mod 10**k) for all x. (We'll assume throughout that gcd(x,10) = 1.)  Then, we can recover r by inverting the cubing to get r = 3**e (mod 10**k).

Expanding out (r**3)**e = r (mod 10**k), we get

r**(3*e-1) = 1 (mod 10**k)

We're looking for an exponent 3*e-1 that guarantees that multiplying that many copies gives us 1.

Multiplication modulo 10**k forms a group for invertible numbers, that is those with gcd(x,10) = 1. By Lagrange's Theorem, x**c = 1 where c is the count of elements in the group. For the group modulo N, that count is the Euler totient value φ(N), the number of values from 1 to N that are relatively prime to N. So, we have  r**φ(10**k) = 1 (mod 10**k). Therefore, its suffices for 3*e-1 to be a multiple of φ(10**k).

We compute

φ(10**k) = φ(5**k) φ(2**k)= 4 * 5**(k-1) * 2**(k-1) = 4 * 10**(k-1)`

So, we want 3*e-1 to be a multiple of 4 * 10**(k-1)

3*e - 1 = r * 4 * 10**(k-1)
e = (4r * 10**(k-1) + 1)/3

Many choices are possible for r, but r=5 gives the short expression

e = (2 * 10**k + 1)/3

with e a whole number. A little golfing using floor-division shortens e to 10**k*2/3+1, and expressing r = 3**e (mod 10**k) gives the desired result r.


05AB1E, 3 1 byte

Saved 2 bytes thanks to Adnan

ι

Try it online!
or as a Test Suite

Explanation

ι  # uninterleave

Does exactly what the challenge asks for


Cobra - 585

Still many improvements to be made

class P
    def main
        i='I see '
        f='s of '
        w=' I think to myself\nWhat a wonderful world'
        a='\nAnd[w]'
        t=' the '
        s=' sayin\', "'
        print "[i]trees of green, red roses, too,\n[i]them bloom, for me and you[a].\n\n[i]skie[f]blue, and cloud[f]white,\nThe bright blessed day,[t]dark sacred night[a].\n\nThe colors of[t]rainbow, so pretty in[t]sky,\n are also on[t]face[f]people going by.\n[i]friends shaking hands,[s]How do you do?\"\nThey're really[s]I love you.\"\n\nI hear babies cryin'. I watch them grow.\nThey'll learn much more than I'll ever know\nAnd[w]\n\nYes,[w]"


MATLAB, 40 bytes
while 1;w=webcam;pause(.5);delete(w);end

Creates an infinite while loop and each time through the loop, a webcam object is initialized (turns on the webcam), the script is paused for 0.5 seconds using pause, and then the webcam object is deleted (turning the webcam off).


Python, 41 bytes

lambda r,s,p:[s>p<=r>0,p>r<=s>0,r>s<=p>0]

Try it online!

Takes counts as (r,s,p). Outputs a three-element list with True at the position of the winner, or all False's if there's a tie or only a single figure appearing.

Rock:     [True, False, False]
Scissors: [False, True, False]
Paper:    [False, False, True]
Tie:      [False, False, False]

We use an alternate characterization without multiplication (except when only one figure is present). Below is the condition for Rock winning, with Scissors and Paper having similar conditions.

  Rock wins if: Paper has the fewest, strictly fewer than Scissors but possibly the same as Rock.

We can write this in Python as s>p<=r using inequality chaining.

Unfortunately, this doesn't correctly handle the special case when r=p=0, saying that Rock wins even though only Scissors is present. To fix this, we strengthen the condition for Rock to win to include r>0 via s>p<=r>0, which makes the only-Scissors case give all False for every condition, matching a tie.

44 bytes

lambda r,s,p:r*s==s*p==p*r or[s>p<=r,p>r<=s]

Try it online!

Takes counts as (r,s,p). Outputs as:

Rock:     [True, False]
Scissors: [False, True]
Paper:    [False, False]
Tie:      True

The "Tie" case also includes where there's only a single figure present.


JavaScript (ES6), 36 28 27 bytes

Saved 1 byte by inverting the result, as suggested by LarsW

Takes input in lowercase. Returns false for a strong word and true for a non-strong word.

s=>/[^aeiouy]{2}/.test(s+0)

How?

We append a 0 (non-vowel) at the end of the input string and look for two consecutive non-vowel characters. This allows us to cover both cases that make a word not strong:

it contains two consecutive consonants
or it ends with a consonant

Test cases

let f =

s=>/[^aeiouy]{2}/.test(s+0)

;[
  "hate", "love", "popularize", "academy", "you", "mouse", "a", "euouae",
  "acorn", "nut", "ah", "strong", "false", "parakeet"
]
.forEach(s => console.log(s + ' --> ' + f(s)))


APL (87 85)

1-⍨⊃⍒(,↑{7↑'*'=⍞}¨⍳7)∘(+.=)¨{49↑,(16/2)⊤⎕UCS⍵}¨↓10 3⍴'嵝䍝뫂傁ဣ␋䠁䊫낫䢝䊅넂垵僡ᑨ嘙쐅嘹䜝䪀슪퀪岹亝尵䌧뮢'

Explanation:

Each possible ASCII number is encoded in 48 bits. (The 49th bit is always zero anyway). The string 嵝䍝뫂傁ဣ␋䠁䊫낫䢝䊅넂垵僡ᑨ嘙쐅嘹䜝䪀슪퀪岹亝尵䌧뮢 has three characters per ASCII number, each of which encodes 16 bits.

↓10 3⍴: split the data string into 10 3-char groups, each of which encodes a number.
{...}¨: for each of the groups:

(16/2)⊤⎕UCS⍵: get the first 16 bits of each of the three characters
,: concatenate the bit arrays into one array
49↑: take the first 49 elements. There are only 48, so this is equivalent to adding a 0 at the end.

,↑{7↑'*'=⍞}¨⍳7: read 7 lines of 7 characters from the keyboard, make a bit array for each line where 1 means the character was a *, and join them together.
(+.=)¨: for each possible digit, calculate how much bits the input had in common with the digit.
⍒: get the indices for a downwards sort of that list, so that the first item in the result is the index of the largest number in the previous list.
⊃: take the first item, which is the index of the digit
1-⍨: subtract one, because APL indices are 1-based.


math.unicode
this thing is a golfing jewel. http://docs.factorcode.org/content/vocab-math.unicode.html
Here, I should let it speak for itself.
Word    Stack effect    Equivalent   (Byte  Char) Savings (best case)
¬       ( obj -- ? )    not           1     2
²       ( m -- n )      2 ^ , 2^      1     2
³       ( m -- n )      3 ^           1     2
¹       ( m -- n )      1 ^           1     2
¼       ( -- value )    1/4 , 1 4 /   1     2
½       ( -- value )    1/2           1     2
¾       ( -- value )    3/4           1     2
×       ( x y -- z )    *             -1    0
÷       ( x y -- z )    /             -1    0
Π       ( seq -- n )    product       5     6
Σ       ( seq -- n )    sum           1     2
π       ( -- pi )       pi            0     0
φ       ( -- n )        phi           1     2
‰       ( m -- n )      1000 /        4     5
‱       ( m -- n )      10000 /       5     6
ⁿ       ( x y -- z )    ^             -1    0
⅓       ( -- value )    1/3           1     2
⅔       ( -- value )    2/3           1     2
⅕       ( -- value )    1/5           1     2
⅖       ( -- value )    2/5           1     2
⅗       ( -- value )    3/5           1     2
⅘       ( -- value )    4/5           1     2
⅙       ( -- value )    1/6           1     2
⅚       ( -- value )    5/6           1     2
⅛       ( -- value )    1/8           1     2
⅜       ( -- value )    3/8           1     2
⅝       ( -- value )    5/8           1     2
⅞       ( -- value )    7/8           1     2

Those are the simple constants. Now for the functions:
Word    Stack effect        Equivalent  (Byte  Char) Savings (best case)
∀       ( seq quot -- ? )   all?         1    3
∃       ( seq quot -- ? )   any?         1    3
∄       ( seq quot -- ? )   none?        2    4
∈       ( elt seq -- ? )    member?      4    6
∉       ( elt seq -- y )    ∈ ¬          3    2
∋       ( seq elt -- ? )    swap member? 9    11
∌       ( seq elt -- y )    ∋ ¬          3    2
−       ( x y -- z )        -            -1   0
∕       ( x y -- z )        /            -1   0
∖       ( s1 s2 -- set )    diff         1    3
√       ( x -- y )          sqrt         1    3
∛       ( x -- y )          ⅓ ^          2    2
∜       ( x -- y )          ¼ ^          2    2
∞       ( -- value )        1/0.         1    3
∧       ( o1 o2 -- ? )      and          0    2
∨       ( o1 o2 -- ? )      or           -1   1
∩       ( s1 s2 -- set )    intersect    6    8
∪       ( s1 s2 -- set )    union        2    4
≠       ( o1 o2 -- ? )      = ¬          1    2
≤       ( x y -- ? )        <=           -1   1
≥       ( x y -- ? )        >=           -1   1
⊂       ( s1 s2 -- ? )      subset?      4    6
⊃       ( s1 s2 -- ? )      superset?    6    8
⊄       ( s1 s2 -- ? )      ⊂ ¬          3    2
⊅       ( s1 s2 -- ? )      ⊃ ¬          3    2
⊼       ( o1 o2 -- ? )      ∧ ¬          3    2
⊽       ( o1 o2 -- ? )      or ¬         2    3
⌈       ( x -- y )          floor        2    4
⌊       ( x -- y )          ceiling      4    6

Yes, I did make that table by hand, and yes, I did the math in my head, so there might be some, er, wrong numbers. I'll go write a program to do it for me, now :P


Jelly, 11 9 bytes
Thanks to @Dennis for -2 bytes!
Rg=1O÷H-*

I wanted to generate the numbers coprime to N by folding set difference over all of the roots of unity from 1 to N, but I couldn't figure out how so I used @Dennis's method.
Rg=1O÷H-*         Monadic chain:          6
R                 Range                   [1,2,3,4,5,6]
 g                Hook gcds with range    [1,2,3,2,1,6]
  =1              [gcds equal to one]     [1,0,0,0,1,0]
    O             Replicate indices       [1,5]
     ÷H           Divide by half of N     [1/3,5/3]
       -          Numeric literal: - by itself is -1.
        *         Take -1 to those powers [cis π/3,cis 5π/3]

Try it here. Valid in this version of Jelly, but may not be in versions after February 1, 2016.


Python 3, 113 104 bytes

a=int(input());print(['%sK,%sT,%sC'%(i%a,i/a%a+i%a,i%a)for i in range(a**3)if i%a*3+i/a%a*5+i/a/a*7==a])

First attempt at code golf. Brute force list comprehension. I'm assuming the list output is acceptable?

Counting tries + conversion as 7 points removes the if statement. Inspired by xor's python 2 answer.

Try it here


Vim, 57 bytes

:%s/\a/ &
:%norm +hkyiwjP
:g/\d/norm diw-@"yl+P
:%s/ //g

Try it online!


Perl 5, 149 147 bytes (+15 bytes if you want to be really strict)

Generates all Turing machines, use H as oracle to see if they halt and if so runs them, count the number of 1s and take the maximum

#!/usr/bin/perl -p
$"=",",@t=1..$_;map{H($f=sub{my%v;$v{$n}=$1while/(A?)(\d+)(\W)$2$v{$n+=$3.1}/;map/A/,%v})&&\$G[&$f]}glob join"V{,A}{@t,0}{+,-}",0,<{@t}{,A}>;$_=$#G

Slightly breaks the conditions on f though not in an very bad way.

$n is the starting position on the tape and is a global. So on each new run it starts where the previous Turing machine left off. But since the tape state is local and starts empty it doesn't matter where you start, so it's not actually used to communicate anything (adding $n to the my solves that at a cost of 5 bytes)
I pass the actual Turing machine in global $_. That's also easily solved by e.g. a for loop over my variable $g and use it in $f via closure  with while$g=~/.../ at the cost of 10 bytes. However the current way has the advantage that I can also see $_ inside H and return true for a few halting Turing machines so that I can really compute BB(1) and BB(2) and BB(3) (BB(3) takes 90 minutes on my computer)

Try it online!

The TIO link implements an actual (sort of) halting function in the header.

The default version has the actual size 1 to 3 busy beaver hard-coded and returns true only for that particular Turing machine. All others return false
If you add a 1 on the next input line after the size then H will be a real halting function but only for a tape that runs from -10 to 10. It will return false for any Turing machine that repeats its complete state or reaches the edge of the tape (so 19 tape positions can actually be used). It returns true for any Turing machine that halts on this restricted tape. This is enough to really calculate BB(1), BB(2) and BB(3) (you'll need lots of patience and memory for BB(3) but it does work). It also prints out some info about long running machines it finds along the way.
If instead you add -1 on the next input line after the size then H will behave like what is described for extra argument 1 but will also show the full execution trace of every Turing machine it tries.

Each Turing machines is represented by a strings that describe all input tuples with their corresponding output state. A tape value is either A (for 1) or empty (for 0). The states are numbered from 1 to n, 0 is the halting state. A tuple is the concatenation of:

value to write to tape (A or empty)
new state (1 to n or 0)
direction to move the head (+ or -)
input state (1 to n)
input tape value (A or empty)

The full string consists of a dummy 0 and then 2n tuples in increasing order all separated by V. So for example a 2 state busy beaver Turing machine in this notation is:

0VA2+1VA2-1AVA1-2VA0+2A

which represents these 4 tuples:

A2+1     in state 1 seeing 0, write 1 move right go to state 2
A2-1A    in state 1 seeing 1, write 1 move left  go to state 2
A1-2     in state 2 seeing 0, write 1 move left  go to state 1
A0+2A    in state 2 seeing 1, write 1 move right go to state 0 (halt)


Calculate a probability exactly and quickly

Python

A closed-form formula of p(n) is

An exponential generating function of p(n) is

where I_0(x) is the modified Bessel function of the first kind.

Edit on 2015-06-11:
- updated the Python code.

Edit on 2015-06-13:
- added a proof of the above formula.
- fixed the time_limit.
- added a PARI/GP code.

Python

def solve():
  # straightforward implementation

  from time import time
  from itertools import count

  def binom(n, r):
    return facts[n] // (facts[r] * facts[n - r])

  def p(N):
    ans = 0
    for i in range(1 + N // 2):
      t = binom(2 * (N - 2 * i), N - 2 * i)
      t *= binom(N, 2 * i)
      t *= binom(4 * i, 2 * i)
      ans += t
    e = (ans & -ans).bit_length() - 1
    numer = ans >> e
    denom = 1 << (3 * N - 1 - e)
    return numer, denom

  facts = [1]
  time_limit = 10.0 + time()

  for i in count(1):
    facts.append(facts[-1] * (2 * i - 1))
    facts.append(facts[-1] * (2 * i))

    n, d = p(i)

    if time() > time_limit:
      break

    print("%d %d/%d" % (i, n, d))

solve()

PARI/GP

p(n) = polcoeff( (exp(x/2) + 1) * besseli(0, x/4) ^ 2, n) * n!;

Proof:
This problem is similar to a 2-dimensional (restricted) random walk problem.

If A[i] = A[i+1], we can move from (x, y) to (x+1, y+1) [1 way], (x, y) [2 ways] or (x-1, y-1) [1 way].

If A[i] != A[i+1], we can move from (x, y) to (x-1, y+1) [1 way], (x, y) [2 ways] or (x+1, y-1) [1 way].

Let a(n, m) = [x^m]((x+1)^n + (x-1)^n), b(n) = [x^n](1+x)^{2n} and c(n) be the number of ways to move from (0, 0) to (0, 0) with n steps.

Then, c(n) = \sum_{i=0}^n a(n, i) * b(i) * b(n-i).

Since p(n) = c(n) / 8^n, we can get the above closed-form formula.


Python

Grab a random wikipedia article, and take a sequence of html characters of length num, and get their numerical values

import urllib2
from random import randint
def getRandom(num):
    response = urllib2.urlopen('http://en.wikipedia.org/wiki/Special:Random')
    html = response.read()
    html = html.replace(" ", "")
    htmllen = len(html)
    #I especially love how I still grab a random number here
    l =  randint(0, htmllen - num)
    data = html[l:l+num]
    return [ ord(x) for x in list(data) ]

print getRandom(25)


Retina, 35 bytes

T`̀-ͯ᪰-᫿᷀-᷿⃐-⃿︠-︯

Try it online!

Simply removes all characters in the ranges given in the challenge from the input. The code is super unreadable of course, but the code is conceptually no different from something like T`0-9A-Za-z which would delete all alphanumeric characters.


J, 54 bytes

#~3 :'0<*/,+/ .*/^:8~y#|:y#,/,"1/({0&,:)3 3$#:13'"1@e.

A function taking a list in the order ABCDEFGHI.

Given an adjacency matrix A of a graph of order n, the graph is connected if and only if all the entries of (A + I)n are nonzero, where I is the n×n identity matrix.

We start with the (fixed) adjacency-plus-identity matrix of the 3×3 king grid (in the order ABCDEFGHI,) namely:

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

.
For each label l, we select the rows and columns corresponding to the nodes of label l.
This gives us the adjacency-plus-identity matrix of the subgraph of l-labeled nodes.
We then use this matrix to test if the subgraph is connected, as described above.

We construct the above matrix by noting that if we let

    0 0 0
Z = 0 0 0
    0 0 0

and

    1 1 0
O = 1 1 1
    0 1 1

, then the matrix can be seen as the 3×3 block matrix

O O Z
O O O
Z O O

, which has the same pattern as O!
O is produced by repeating the pattern 1 1 0 1 in a 3×3 block.