text:
Divide food to the poor equally!
The problem
Through a terrible procastination accident you are reborn as Scrooge McDuck for a day. To make the most out of the situation you decide to give away food to the poor. Since you also are a mathematician you store the food in a vector v(1,2,3).
You want to give each family approximately the same food. To make things simple each family has n members.  The task is to write a code to split the vector v into rows of length n where each row has the same amount of ''food''.
Equality is measured by the standard deviation; how different the sum of each row (the food each family receives) is from the mean.
Input
Input should be an integer n and a vector v The length of v does not have to be divisible by n; zero pad it if that is the case.
Example
v = (4, 9, 3, 6, 19, 6, 9, 20, 9, 12, 19, 13, 7, 15)
n = 3

Should return
 4     6    19
 9     9    13
 3    20     7
 6     9    15
19    12     0

The sum of each row is 29,31,30,30,31, so the standard deviation is 0.748331 for n = 2. Note the presence of a 0 that we added.
The output
The code should output the standard deviation. You can also print the matrix but this is not a requirement.
The score
The winner is judged not by the shortest code, but by the sum of the standard deviations, given the test vector and n = 2, 3, and 23. e.g.
Score = your_func(2, foodvec) + your_func(3, foodvec) + your_func(23, foodvec)

Use the following vector to test http://pastebin.com/ybAYGHns and test for n=2,3,23. The final score is the sum of those three tests.
The vector is somewhat big since Scrooge has a lot of food saved up.

Will you test the running time on your own machine?

The running time is only implemented to avoid extremely long running times. Eg leaving the computer on over night. The running times should anyways be small for the given test vector and not matter much to the score.

They are part of the score, and therefore matter. For a fair competition, all submissions should be timed on the same machine.

What do the (1,2,3) in v(1,2,3) signify? How should the situation where n does not divide cleanly into the length of v be handled?

Then you add zeros to v until they are equally matched. They numbers signify the weight of each index  (which can not be divided further). The point is to divide the food into groups of length n. Where each group should have the same weight.

IIUC the code should reorder v, so that the stdev is minimized?

stdev for the rows should be minimized yes.

The question looks nice, but the scoring is poor.

Any suggestions for a more fair scoring system?

Either you take up all answers and run it on your machine to get a fair score, or remove the scoring element all together. (By that, I mean, think of a different scoring criteria)

I changed it to std, plain and simple =)

@N3buchadnezzar but then it brings us to the question that now each and every answer can simply find the minimum stddev possible.

Can more than one 0 appear in the same row? Consider v = [12, 4, 4, 4, 0, 0], n = 3 for instance.

@KennyTM I would assume you could have as many 0's in a row as you want to get the lowest variance.

@N3buchadnezzar the phrasing of the question is a bit strange, where you provide the number of columns vs. rows...rows would seem to make more sense; e.g. "divide the food into n rows because there are n families", versus "divide into however many rows you want, just make sure there are this many columns that match the number of family members...but some will get screwed because you're 0 padding...(the zero padding can also open up some loopholes I think)"

@N3buchadnezzar Any reason for keeping this question open?

Python 3 using PyPy: 6.368014 + 0.701679 + 0.486916 = 7.556608
Optimal for n = 2
There are 1000 numbers, so we want to distribute the food to 500 families. If the food vector is sorted (food[1] >= food[2] >= ... >= food[500]), then the minimal std is reached by giving the first family the food items food[1] and food[500], the second family food[2] and food[499], the third family food[3] and food[498], ...
I thought of a quite easy proof. Basically I expanded the product of the std, removed the terms that appear in each food partition, and proofed that the result is minimal. If someone wants a more detailed explanation, just ask me nice.
Approximation for n > 2
I don't think, that there's a fast way of finding the optimal solution for n > 2.
I start with an heuristic solution. I distribute the food items in sorted (descending) order to the family with the lowest food so far (only to such families, which have received less than n food items).
Afterwards I improve the solution, by swapping 1 food item between a pair of families.
I use the N families with to lowest food and the N families with the most food so far. After all possible swaps, I choose the best swap, and call the local search recursively.
The bigger the value of N is, the lower will be the std (but also the running time will be longer). I used N = 20 and when I can't find swap, I try again with N = 100. PyPy finishes all 3 test cases in less than 8 minutes.
Code
def findSmallestStd(food, n):
    food.sort(reverse=True)
    while len(food) % n:
        food.append(0)
    family_count = len(food) // n

    if n == 2: # optimal
        return list(zip(food[:len(food)//2], reversed(food[len(food)//2:])))
    else: # heuristic approach
        partition = [[] for _ in range(family_count)]
        for food_item in sorted(food, reverse=True):
            partition.sort(key=lambda f: sum(f) if len(f) < n else float('inf'))
            partition[0].append(food_item)
        return local_search(partition, calc_std(partition))

def local_search(partition, best_std, N = 20):
    # find indices with smallest and largest sum
    families1 = nsmallest(N, partition, key=sum)
    families2 = nlargest(N, partition, key=sum)
    best_improved_swap = None

    for family1, family2 in product(families1, families2):
        for index1, index2 in product(range(len(family1)), range(len(family2))):
            family1[index1], family2[index2] = family2[index2], family1[index1]
            std = calc_std(partition)
            if std < best_std:
                best_std = std
                best_improved_swap = (family1, family2, index1, index2)
            family1[index1], family2[index2] = family2[index2], family1[index1]

    if best_improved_swap:
        family1, family2, index1, index2 = best_improved_swap
        family1[index1], family2[index2] = family2[index2], family1[index1]
        partition = local_search(partition, best_std)
    elif N < 100:
        return local_search(partition, best_std, 100)
    return partition

The complete code and the output is available on Github: Code, Output
edit
I was confused about the std-calculation, that N3buchadnezzar proposed in the original question. I updated it to the correct mathematical definition, so we can compare different solutions.
edit 2
In my last submission I varied the family count. E.g. the best solution for n = 2 used 507 families. N3buchadnezzar told me, that there have to be exactly ceil(len(food) / n) families. So I changed my code a little bit. Basically removed the loop over the family counts and improved the local search.

Seems good. My best result for the n=3 case is 1.7523 (using the correct std). In about a few seconds run time.
http://pastebin.com/0N7frDC7
But asking this question and how to do it in a proper matter is done messy. I think I will re-ask a similar question later =) (And leave this one running for now)
The vector should have been a tad bigger, because then my running time explodes :p

@N3buchadnezzar Is the number of families fixed. In my solution I try all number of families >= ceil(len(food) / 2). I get my best results for n = 2 using 507 families, n = 3 for 483 families and for n = 23 using 46 families. Is this allowed, or must there be 500, 334 and 44 families?

For now it must be 500, 334 and 44. In the next (similar) question this will be changed however. I thought about changing it, but now it is too late.

Python 2: 6.368013505 + 96.84345115 + 5.572725419 = 108.784190072
This is probably not a very optimized or smart approach but it gave me decent results so i decided to post it. I sorted the list and chopped the list in groups of n long. The odd groups get reversed and then I zipped them together (just look at the code really). It's small and quick and it works fairly well on a big amount of numbers (not so much on a small amount, it scored around 3.5 on the example).
So this is my function:
def myFunction(v, n):
  v = sorted(v)
  while len(v) % n != 0:
     v = [0] + v
  lists = list(grouper(v, len(v)/n))
  for i in range(len(lists)):
     if i%2 == 0:
         lists[i] = lists[i][::-1]
  zippedList = list(zip(*lists))
  for i in range(len(zippedList)):
     zippedList[i] = sum(zippedList[i])
  print(zippedList)
  return numpy.std(zippedList)

def grouper(l, n):
   for i in range(0, len(l), n):
      yield l[i:i+n]

Because it's such an easy (read lazy) solution, it's very fast. The entire program took about 0.1s to run. With pypy it would be even faster but Numpy is apparently still not ported to pypy and i don't feel like manually calculating the standard deviation so yeah. If I made any huge mistakes (both on programming and english grammer) or have recommendations, tell me. It's the first time I gave a code challenge a try.

+1, because you made me realize, that my definition of std was rubbish. I updated my answer, so that we can compare the actual results. Btw, this was a code challenge, not code golf. ;-)

I wondered why your score was so high but I havent looked at your complete code +1 for your way better answer.

@Jakube Is using different functions for different values of n allowed? Also your use of zeros is a bit cheaty but that isn't really explained very well in the question

I'm not sure. It doesn't say anywhere, how many families there are. I will ask N3buchadnezzar, what is allowed and what not. If I run the code for only the minimal possible number of families, I get a result of 6.4 + 8 + 0.5 = 14.9

You were right, we have to use 500, 334 and 44 families. But I improved my program and got even better (and allowed) solutions.


text:
Partial Ordering of Regex Patterns
For the purpose of this challenge, we say that a regex pattern matches a string if the entire string is matched by the pattern, not just a substring.
Given two regex patterns A and B, we say that A is more specialized than B  if every string that is matched by A is also matched by B  but not the other way around.
We say that A is equivalent to B if both patterns match exactly the same set of strings.
If neither pattern is more specialized than the other nor are they equivalent, we say that A and B are incomparable.
For example, the pattern Hello, .*! is more specialized than .*, .*!; the patterns (Hello|Goodbye), World! and Hello, World!|Goodbye, World! are equivalent; and the patterns Hello, .*! and .*, World! are incomparable.
The relation "more specialized than" defines a strict partial order on the set of regex patterns.
In particular, for all patterns A and B, exactly one of the following is true:

A is more specialized than B (A  B).
A and B are equivalent (A = B).
A and B are incomparable (A ∥ B).

When A and B are incomparable, we can further distinguish between two cases:

A and B are disjoint (A ∥ B), meaning that no string is matched by both of them.
A and B are intersecting (A ≬ B), meaning that some strings are matched by both.

Challenge
Write a program or a function that takes a pair of regex patterns and compares them using the above order.
That is, if the two patterns are A and B, the program should determine whether A  B, A = B or A ∥ B.
×92% Bonus An additional bonus is given if, when the patterns are incomparable, the program determines whether they're intersecting or disjoint.
Input and Output
The program should accept two regex patterns, as strings, in the flavor defined below.
You may read the input through STDIN, the command line, as function arguments or an equivalent method.
You may assume that the patterns are valid.
The program should produce one of exactly four distinct outputs (or five distinct outputs if you're going for the above bonus,) depending on the result of the comparison (the exact outputs are up to you.)
You may write the output to STDOUT, return it as the function's result or use an equivalent method.
Regex Flavor
You may support whatever regex features you like, but you must support the following ones:

Alternation with |.
Quantification with *.
Grouping with ( and ).
Matching any character (possibly excluding newlines) with ..
(Optional: ×80% Bonus) Matching simple and negated character classes with […] and [^…], respectively.
You don't have to support any predefined character classes (e.g. [:digit:]) but you should support character ranges.
Character escaping with \.
It should at least be possible to esacpe special characters (i.e. |*().[^-]\) and preferably also common special characters in other flavors (e.g. {}), but the behavior when escaping nonspecial characters is unspecified.
In particular, you don't have to support special escape sequences such as \n for a newline and the like.
A possible implementation is simply to take the character following the \ as a literal.

You may assume the existance of an input character that cannot be matched by any literal (i.e. it can only be matched by . and negated character classes.)
Additional Rules

You may use regex libraries or builtin regex functionality only for the purpose of string matching and replacement.
You may ignore any locale-related issues, such as collation rules.
To state the obvious: your program must terminate.
It should execute in a reasonable amount of time given typical patterns (definitely no more than an hour, preferably a lot less.)

Scoring
This is code-golf.
Your score is the product of the code size, in bytes, and any of the bonuses.
The lowest score wins.
Test Cases
The format of the test cases is as follows:
<Test ID>
<Pattern A>
<Ordering>
<Pattern B>

<Test ID>
<Pattern A>
<Ordering>
<Pattern B>

...

Where <Test ID> is an identifier for the test case, <Pattern A> and <Pattern B> are the regex patterns and <Ordering> is the ordering between them, and is one of:

<: <Pattern A> is more specialized than <Pattern B>.
>: <Pattern B> is more specialized than <Pattern A>.
=: The patterns are equivalent.
|: The patterns are incomparable and disjoint.
X: The patterns are incomparable and intersecting.

The special value <empty pattern> stands for the empty pattern.
A. Basic patterns

A1
Hello
=
Hello

A2
Hello
|
World

A3
Hell(|o)
=
Hell|Hello

A4
x
<
.

A5
.
>
x

A6
\.
<
.

A7
x|y
=
y|x

A8
x|y
X
y|z

A9
x|y
|
a|b

A10
x|y|z
>
x|z

A11
x.
X
.x

A12
.*
>
<empty pattern>

A13
()*
=
<empty pattern>

A14
x*
>
xxxx

A15
x*
>
x|xx|xxxx*

A16
x*
=
|x|xx|xxxx*

A17
x*
<
.*

A19
(.|..)*
=
.*

A20
(...)*
X
(..)*

A21
...*
X
(..)*

A22
...*
<
..*

A23
(...)*
|
Four

A24
a*
X
a.*

A25
a*
|
b.*

A26
x*
=
(x|)*

A27
(((.*)*)*)*
=
.*

B. Complex patterns

B1
aaa*
=
aa*a

B2
aa*a
=
a*aa

B3
a*
X
aaax||a|aa|aaa

B4
aaaaaaaaaaaaaa*
X
(aa)*|(aaa)*

B5
a*b*
<
(a|b)*

B6
((a|b)(a|b))*
>
(ab|ba)*

B7
((a|b)(a|b))*
=
(aa|ab|ba|bb)*

B8
.*.*
=
.*

B9
(x*y*z*)*
=
(x|y|z)*

B10
(...|.....)*
>
.........*

B11
(...|.....)*
=
|...|.....|......|.........*

B12
(...|......)*
<
|...|.......*

B13
(...|....|.....)*
=
|....*

B14
(...|x...............|x..x)*
>
(...|x..............|x..x)*

B15
(...|x...............|x..x)*
<
(..|...|x..............|x..x)*

B16
(____)*_x__(____)*
|
(____)*x___(____)*

B17
(____)*_x__(____)*
X
(_____)*x_____(_____)*

B18
(____)*_x__(____)*
|
(______)*x______(______)*

B19
(____)*_x__(____)*
<
_*x__*

C. Basic patterns with character classes

C1
[x]
=
x

C2
[xy]
|
xy

C3
[abc]
=
a|b|c

C4
[abc]
>
[ab]

C5
[abc]
<
[abcd]

C6
[ab]
X
[bc]

C7
[ab]
|
[cd]

C8
[abc]*
>
(a|b)*

C9
[^xyz]
>
a

C10
[^xyz]
|
x

C11
[^xyz]
|
[xyz]

C12
[^xyz]
X
[wxyz]

C13
[^xyz]
X
[^abc]

C14
[0-9]
=
[0123456789]

C15
[a-z]
>
[b-y]

C16
[a-z]
=
a|[b-y]|z

C17
[^0-9]*
>
Hello, World!

C18
[^0-9]*
|
123

C19
[^abc]
<
.

C20
[^abc]*
X
.

C21
[^a]|a
=
.

C22
[^abcd]|[a-c]|d
=
.

C23
[^a]*
X
b[^c]*

C24
[^a]*
|
a[^c]*

D. Complex patterns with character classes

D1
http://[^/][^/]*/.*
>
http://(www\.|)google\.com/.*

D2
http://[A-Za-z][A-Za-z]*\.wikipedia\.org/
X
(http://|)en\.wikipedia\.org/(|wiki(|/.*))

D3
[A-Za-z0-9._%+\-][A-Za-z0-9._%+\-]*@[A-Za-z0-9.\-][A-Za-z0-9.\-]*\.[A-Za-z][A-Za-z](|[A-Za-z]|[A-Za-z][A-Za-z])
X
email@address.com

D4
[A-Za-z0-9._%+\-][A-Za-z0-9._%+\-]*@[A-Za-z0-9.\-][A-Za-z0-9.\-]*\.[A-Za-z][A-Za-z](|[A-Za-z]|[A-Za-z][A-Za-z])
>
email@address\.com

D5
[A-Za-z0-9._%+\-][A-Za-z0-9._%+\-]*@[A-Za-z0-9.\-][A-Za-z0-9.\-]*\.[A-Za-z][A-Za-z](|[A-Za-z]|[A-Za-z][A-Za-z])
>
[A-Za-z0-9._%+\-][A-Za-z0-9._%+\-]*@gmail\.com

D6
JohnDoe@[A-Za-z0-9.\-][A-Za-z0-9.\-]*\.[A-Za-z][A-Za-z](|[A-Za-z]|[A-Za-z][A-Za-z])
<
[A-Za-z0-9._%+\-][A-Za-z0-9._%+\-]*@[A-Za-z0-9.\-][A-Za-z0-9.\-]*\.[A-Za-z][A-Za-z](|[A-Za-z]|[A-Za-z][A-Za-z])

D7
[A-Za-z0-9._%+\-][A-Za-z0-9._%+\-]*@gmail\.com
X
JohnDoe@[A-Za-z0-9.\-][A-Za-z0-9.\-]*\.[A-Za-z][A-Za-z](|[A-Za-z]|[A-Za-z][A-Za-z])

D8
[^, a-z][^,]*(|(, [^, ][^,]*)* and [^, ][^,]*)\.
>
One, two and three\.

D9
[^, a-z][^,]*(|(, [^, ][^,]*)* and [^, ][^,]*)\.
|
one, two and three\.

D10
[^, a-z][^,]*(|(, [^, ][^,]*)* and [^, ][^,]*)\.
|
One, two\.

D11
[^, a-z][^,]*(|(, [^, ][^,]*)* and [^, ][^,]*)\.
<
(.*(,|))*

D12
[A-Z][^,]*(|(, [a-z][^,]*)* & [a-z][^,]*)\.
<
[^, a-z][^,]*(|(, [^, ][^,]*)* (and|et|[&+]) [^, ][^,]*)\.

Test Program
The following snippet can be used to compare regex patterns:

<textarea class="pattern" id="pattern1" oninput="compare()">Hello, .*!</textarea>

<textarea class="pattern" id="pattern2" oninput="compare()">.*, .*!</textarea>

Loading...

Wow. Any answer submitted to this gets an automatic +1 from me. Determining whether two formal languages are isomorphic is hard enough. Determining whether one is a sublanguage of another is a complete undergraduate CS project. @___@

Is there any specified behavior for invalid regex patterns?

@PaulGuyot No. You can assume the patterns are valid.

I wonder - did you write won yourself (to see how feasible it is for a code golf question) or didn't you?

@proudhaskeller I did; I wrote the test snippet. It's a tough challenge, and there aren't going to be any one-liners here, but it's golfable.

Python 2, 522 bytes * .92 = 480.24 537.28
Edit 2: -60 bytes
Edit: Added explanation.
Defined is the function f which takes the two pattern strings as arguments and returns '<', '=', '>', '|', or 'X'. Less than one minute is needed to process all test cases.
The code consists of the following, but with \r, \n \t, and hex escapes (but not \0) replaced with their actual byte values.
#encoding=Latin
exec"""x\xda]RMo\xdb0\x0c\xbd\xe7Wx\'K\x96\x92\xc5mOR\xb8\xdf1@%|\x98%X\x80a\x19\x96\x02\x03n\xf2\xdfG:i;\xec$\x92z|\x8f_\x1b\x84%m~\xca\xbe\x1c\x0e\xbd\x0fU\x10Agi\x0e\x87\xea\n\x1f\xf9n{=\xea\0\x93\x08\xd2\xaez\xd0\x99\xcc,m\x07g\xbb\x80s\x9b\x08\xee\x8cRo"\xf3\x8bHy!-\x95\xd7\xa9\x8aS\xb50O5\xc3&\xb68\x0b\xe7\xb1\x19t\x92\x8a\x1d\xaf]\xc2f\x94\x92\x111T\xf3\xf1j\xba\x1b\x081r\xa2\x97\xea\xa5\x11\x03\x9bI\xca\xe6\xed\xe7\xab\xbd\xde`\xb6\x8b"\xd1\xc5\xf7\xd7?^l\xa7\xaeKK\xd7i\x91\x92\x8b\xaaE\x16\x8e\x9c\x12#3\x86\xe0"\xc6\xc9\x15\xfd\x86\xae\\\xde\xcc^\xa7\x94;,\xea\x94t\x08\x84\xa6J\x82\xee%\xb1\xe8\xacW\xb9\xb3\x14f\xd9\x84\xeb\x89\xe1\x8b\xd5\xa3r\xeb\xbf\x81D\rS\xf5\x8b/\xd7e\xaao\xf0\xeb\xf2\xbbv\xdd\xf1\x15\x1f\x93\xe4Aq\xff\x19\xc6\x98\x8b\xa8E\xad\xb2\xaae-m\x843\xc5\xd7!\x8e\xbe\xca.\x1a4\x01\xe8E;@-\xe4\xad9\xd5\xa7\x10\xa7\x9eg\xcea\x10\x83\x0e\xd2\r\x973\xb2o\xb8\xd7\x06\xc2\x0f\xa8\xdf\xdfk\x1b\x15\xb4v\x84H\xc9\xad]\xc1\x83C;\x03m\xc3\x16p\x1f\xe3\x1d\xbf\xa4\xe2\xbe\x8d\x1eX)\x1e\t\x9dv\xf3\xa9\xcd\xe8xGU\x9e\x0b\t\x97\xd6\x0c\x8c\xf2\nxa\xa9\x19u\xaf\xf2iN3\r\xd1\xae\x0f\xe3\x13\x0c@h\xb5W\xb0\xaad3\xef\t\x91s]R=~\xc3^Lv\xc7\x16\x15\xf4\xfb\xa7\x88ze_~B\x06\x80\x99\x03\x86\x7f\x0bY\x06U\xd2.\xeaV\x95\x87$\xd1\xce\xff\x8b\xbf\x9a\x99\xe0\x03u\xa1 =o0<n\xd0\xef]s`b\xb7\x98\x89\xael\xd2\x85\xceO:>\x80j\xfa\xdeb\x95\x95k\x91N\xbe\xfc'5\xac\xe7\xe8\x15""".decode('zip')

The above statement causes the following code to be executed:
z=frozenset
def f(f,s):
 u={s};d,l,f=n(f);w,h,s=n(s);_=0;r=[[z(f[0]),z(s[0])]]
 for e,o in r:
  p=z(zip([e]*h,o)+zip(e,[o]*l))
  if p-u:_|=((l in e)+2*(h in o))*4/3;u|=p;r+=[[reduce(z.__or__,(oo[i+1]for i in ii if ff[i]in[t,4][t<4:]),z())for ii,oo,ff in(e,f,d),(o,s,w)]for t in z([d[i]for i in e]+[w[i]for i in o])]
 return'|=><X'[_-3]
def n(s):
 s=list('('+s+')');i=0
 while s[i:]:f=s[i];h='()|*.'.find(f);s[i]=(h,f)[h<0];s[i:i+1]*=f!='\\';i+=1;l=i;h=1;w=e=[];p=[0];t=[{l}]
 while i:
  d=[i];i-=1;o=[i];f=s[i];t=[{i}]+t
  if f<1:h-=1;e+=zip(o*l,d+s.pop());w.pop()
  if f==1:h+=1;w=w+o;s+=[[]];e+=[o+d]
  if f==2:s[-1]+=d;e+=[(i,w[-1])]
  if h==p[-1]:e+=[t[-1:]+o,[i,1+t.pop()]];p.pop()
  if f==3:p+=[h];t+=o
 for f,o in e:
  for n in t:n|=(n,t[o])[f in n]
 return s+[1],l,t

If the second code sample is stored in the string s, something similar to the first can be produced by the expression '#encoding=Latin\nexec"""%s"""'%__import__('zlib').compress(s). It may be necessary to fix some characters such as null bytes or backslashes. The unzipped code is nearly 1000 800 bytes so perhaps it is more obfuscated than golfed...but at least I managed to golf the encoding a bit: from Latin1 to Latin.
Explanation
The program works by using the indices of the string as a crude way to keep track of the states of parsing a string. The n function builds transition tables. First it parses the string and finds all instances of two kinds of transitions. First, there are transitions that don't involve adding another letter to the string. For example, jumping from a * to the beginning of a quantified expression. Secondly, there are transitions of adding a character, which simply move forward by one index. Then the transitive closure of the no-character transitions is calculated, and those are substituted for the destinations of the 1-character transitions. So it returns a mapping of an index and a character to a set of indices.
The main function does a BFS over possible input strings. It tracks a set of all possible indices for whatever fragment of a string it is considering. What we are interested in finding is states that are either accepted by both regexes, or by one and not the other. To show that a regex is accepted, it is only necessary to find one possible path of transitions to the end of the pattern. But to show that one is rejected, it is necessary to have analyzed all possible paths. Therefore, to determine if the sets of possible states for pattern A and pattern B are already covered by ones that have been analyzed before, pairs of a single state in one regex and the set of all possible states in the other are recorded. If there are no new ones, then it is OK to go back. Of course, it would also be possible, and less characters, to simply record pairs of the sets of all states for both patterns, but then the computer would explode.

Very nice! Passes all tests in groups A and B (no character classes, it seems.) I can't get the compressed version to work, though, or get the same byte count. Either way, you can claim the x 0.92 bonus when you calculate your score. And, of course, an explanation is welcome!

Haskell, 560 553 618
might get some of the bonuses done in the future.
this is not fully golfed yet.
import Data.List
c%j|'\\':h:s<-j=[s|c==h]|(a,b):_<-[(a,b)|x<-[0..length j],(a,'|':b)<-[splitAt x j],snd(k b)==[]]=c%a++c%b|'(':s<-j,(a,_:'*':b)<-k s=map(++j)(c%a)++c%b|'(':s<-j,(a,_:b)<-k s=map(++b)(c%a)|h:'*':s<-j=map(++j)(c%[h])++c%s
c%"."=[""|c>'\0']
c%s@[_]=c%('\\':s)
c%(a:b)=map(++b)(c%[a])
c%s=[""|c>'\0']
a&b=nub[(x,nub$b>>=(c%))|c<-[' '..'~'],x<-c%a]
g e(k@(a,l):r)|j<-a&l\\e=g(k:e)(j++r)
g e[]=e
a#b=or[all(null.('\0'%))m|(x,m)<-g[][(a,[b])],""<-'\0'%x]
a!b|a#b,b#a='x'|a#b='>'|b#a='<'|0<1='='
k"("=("","(")
k(c:s)|'('<-c,(x,y)<-k$tail b=('(':a++')':x,y)|')'<-c=("",')':s)|0<1=(c:a,b)where(a,b)=k s
k j=(j,j)

a hand-wavy explanation of the algorithm:
reg!reg' returns the required char, one of "=<>x".
a#b is true iff not every string that a matches is also matched by b.
c%reg is a list of regular expressions such that reg matches c:s iff one of the regexps in the output matches s. i is basically partially matches the regex.
except if c is '\0'. then it forces reg to not get any more input, returning [] if reg must get more input to match and [""] otherwise.
# works by generating a finite list of all possible "regex-state" the two regexps will be in after an arbitrary string. then to check if a<b we check weather there is a "regex-state" in which a is fully matched but b isn't fully matched.

Cool! You're obviously on the right track. However, right now it fails test B4.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Distinguish between Masculine and Feminine Nouns in French within 100 characters
You are to write a very small program within 100 characters. Your program must distinguish between masculine and feminine french nouns. The output should be un if it is masculine and une if it is feminine. Often, there are certain statistical rules you can follow (e.g. if it ends in an "e" it is more likely feminine than masculine).
Input:
A french word; it may consist of any  lowercase letters and dashes, including lowercase letters with accents.
Example input: ami
Output:
un if the word is masculine and une if the word is feminine.
Example output: un
You do not have to get every word right; your goal is to be as accurate as possible.
Scoring: Your answer must be within 100 characters. Statements such as print or console.log or alert do not count as part of your total bytes. You may also write a function or method that performs this task, in which case the first few bytes (e.g. f=x=>) which are part of the function declaration do not count to your total. Your total score is the number of incorrect answers. Ties are broken by code size.
Nouns to test with:
un ami
un café
un chapeau
un concert
un crayon
un garage
un garçon
un lit
un livre
un mari
un musée
un oncle
un ordinateur
un pantalon
un piano
un pique-nique
un portable
un père
un sandwich
un saxophone
un stade
un stylo
un théâtre
un téléphone
un voisin
une botte
une boum
une chaise
une chaussette
une chemise
une clarinette
une copine
une femme
une fille
une glace
une heure
une lampe
une maison
une montagne
une personne
une piscine
une pizza
une radio
une raquette
une salade
une souris
une sœur
une table
une télé
une voiture

I would have added un squelette to the list just to make things hard.

CJam, 0 incorrect, 32 29 bytes
This code uses a few odd characters (some of them unprintable), but they are all well within extended ASCII range. So again, I'm counting each character as a single byte.
"un"'el2b"zPB:  ":i+:%2/*

Due to the unprintable characters, I'm sure Stack Exchange swallows some, so you might want to copy the code from the character counter (it shows bytes with UTF-8 encoding, which is suboptimal for this challenge; also, the link doesn't seem to work in Firefox, but does in Chrome).
A hexdump is provided for reference:
00000000: 2275 6e22 2765 6c32 6222 7a50 423a 1a14  "un"'el2b"zPB:
00000010: 0e09 0422 3a69 2b3a 2532 2f2a 0a            ":i+:%2/*.

Test it here.
After some more discussion in chat, we figured that the regex golfing wouldn't bring us much further. So following an earlier (joking) suggestion of mine we started looking into manipulating the character codes of the words with certain functions, such that all words from one group would yield a number with some property that is easy to check. And we got luckier than we expected! Here is what the code does to the words:

Implicitly convert the characters in the word to their code points.
Interpret those as digits in base 2 (yes, the digits will be much larger than 0 or 1, but CJam can handle that).
Repeatedly take the result modulo... the following numbers: [133, 122, 80, 66, 58, 26, 20, 14, 9, 4]. This sequence of numbers is itself encoded as the code points of a string (this is where the weird and unprintable characters come in).
As if by magic, all 25 masculine nouns yield 0 or 1, and all 25 feminine nouns yield 2 or 3 with this procedure. So if we divide this by 2 (integer division) we get zeroes for masculine nouns and ones for feminine nouns.

To round it off, we push "un" on the stack, the we push a single e. Then we read the input word from STDIN and perform the above computation, and finally multiply the e by the result.
I have never folded modulo onto any list before, and I feel like I never will again...
Many thanks for xnor and Sp3000 for throwing ideas around and helping with the search for divisor chain.

Not only shorter, but 2 minutes faster. The horror!

@sudo ;) ... one of the rare times I'm able to beat you... I'd be very much interested in an explanation of yours though :)

Wait, I'm confused. If magic exists, why are you wasting it on a silly programming challenge site and not solving world peace or something? (No, but seriously, woah. +1)

Ruby, 0 incorrect, 63 56 53 52 51 50 bytes
All characters are in extended ASCII, specifically ISO 8859-1, so I'm counting each character as a single byte.
f=->s{s[/la|tt|i.e|[égdzœu]..$|^b|^f|so|^ta/]?'une':'un'}

It looks like your test set was a bit too short. I've generated the regex with Peter Norvig's meta regex golfer.
You can call the above function like f["ami"]. You can use this test harness to check all test cases:
puts "ami café chapeau concert crayon garage garçon lit livre mari musée
      oncle ordinateur pantalon piano pique-nique portable père sandwich
      saxophone stade stylo théâtre téléphone voisin botte boum chaise
      chaussette chemise clarinette copine femme fille glace heure lampe
      maison montagne personne piscine pizza radio raquette salade souris
      sœur table télé voiture".split.map{|s|f[s]+" "+s}

Test it on Coding Ground.
Edit: Using Peter Norvig's second script I found a different regex, that was actually one byte longer, but which I could shorten by two bytes by hand.
Edit: Sp3000 set the regex golfer he wrote for my recent regex challenge on it, and found a 36 35 34 byte regex for me to use. Thanks for that!

Reliving the nightmares of meta regex golf here because table is a substring of portable, and switching which set to match isn't very useful because the second set seems easier to match...

CJam, 0 errors (36 32 29 28 bytes)
{"un"oEb72^"+ÕåWïº"583b2b='e*o}:F;

This is a named function, so I'm only counting the inner code. Also, o is a print statement, so it doesn't contribute to the byte count.
Try the test cases in the CJam interpreter.
How it works
"un"o       " Print 'un'.                                                  ";
Eb          " Consider the input a base 14 number.                        ";
72^         " XOR the result with 72.                                     ";
"+ÕåWïº"    " Push that string.                                           ";
583b2b      " Convert from base 583 to base 2.                            ";
=           " Retrieve the corresponding element (0 or 1) from the array. ";
'e*o        " Print 'e' that many times.                                  ";

Just a hash function and a table lookup.

Lexurgy, 18 incorrect, 65 bytes
A quick check for whether the word ends with e.
a:
*=>|une/e _ $
else:
*=>|un/ _ $
b propagate:
[]=>*/_ |
c:
|=>*

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Verify a Minesweeper board
Your goal is to check whether a completed Minesweeper board is valid. This means that each number is a correct count of mines in cells adjacent to it, including diagonals. The board does not wrap around.
As usual, you should give a function or program, and shortest code in bytes wins.
See also past challenges to generate, solve, and fully implement Minesweeper.
Input:
A single string like this: 02X2 13X2 X211.

The rows of the minesweeper board are given separated by spaces. So, the above represents the 3x4 board:
02X2
13X2
X211
Each cell is a character: X for a mine, or a number 0 through 8.
All rows have the same length.
There are at least 3 rows and 3 columns.
The input doesn't start or end with a space, but you may include a newline at the end if you wish.

Output:
A consistent Truthy on correct boards, and a consistent Falsey value on incorrect boards. Consistent means that all Truthy outputs are the same and all Falsey outputs are the same.
Test cases
Each line is a separate test case.
True:
02X2 13X2 X211
XXXX XXXX XXXX XXXX
XX4X2 5X6X4 XX6XX 4XX54 2X4XX

False:
02X2 13X2 X212
XXXX XXXX X7XX XXXX
XX5X2 5X6X4 XX6XX 4XX54 2X5XX

You should probably specify the consistent falsy output must be distinct from the consistent truthy output ;-)

@JanDvorak That should be implied by them being Truthy and Falsey respectively.

Not really. "truthy" and "falsy" are just two labels that you're letting us define. I can see no restriction they be actually truthy or falsy respectively in the language we use. The only word that may require them to be distinct is the "indicating" verb. I'm not sure it counts as a spec (it's still forbidden as a standard loophole, though).

@JanDvorak 'truthy' and 'falsy' are actually somewhat common terms if I'm not mistaken basically used to describe things (not necessarily bools) that evaluate to true or false when typed to bools. For example 0 is generally falsy and 1 is generally truthy.

@KSab I know of their standard usage. But I don't see anything in the spec saying that our chosen truthy value is actually truthy in the language we use. In Ruby 0 is truthy, yet it would be a perfectly valid falsy output in this challenge (right?)

@JanDvorak I linked to the meta post on Truthy/Falsey. Does that make the terms clear?

Posted several comments in that meta thread. Let's see how it goes. As for this question, is it OK if I emit a truthy value for invalid inputs and a falsy value for valid inputs?

@JanDvorak Nope, Truthy/Falsey has to match correct/incorrect.

Can't I even choose True as my falsy output and False as my truthy output?

@JanDvorak Do you mean the text "True" and text "False"? Can your language convert those to bools or use them in an if? If so, they should act correctly.

@MartinBüttner A 3x3 block of mines is valid; there's a test case like it.

@JanDvorak If you used Ruby and output 0 to mean false, I would say that you had incorrectly used a truthy value instead of a falsy one.

Python 2, 132 129 128
def f(s):w=s.find(' ');E=dict(enumerate(s));return all(E[i]in' X'+`sum(E.get(i+d/3*~w+d%3+w,5)>'O'for d in range(9))`for i in E)

I used enumerate in a golf...and even used range elsewhere in the same program. Clearly something is wrong here.
Edit: Iterate over dict(enumerate(s)) rather than enumerate(s), so enumerate does not need to be called twice.

What a clever use of ~! And of dictionaries to make out-of-bounds indexing work right.

@xnor Your comment about the ~ operator ironically made me notice I was using it twice for no reason at all, where using it only once would obviously accomplish the same thing. I thought the dictionary part was funny, thanks.

Pyth, 43
Jhxzd!f-@zT+" X"`sm/:+*JNztd+d2\Xm+T*kJU3Uz

Try it here.
Explanation:

Jhxzd: This is the location of the first space in the input + 1. (z in the input, d is space.) It is the separation in the input between vertically adjacent cells on the board.
!f: This is the logical not (!) of a filter (f), which will be True if and only if the expression is falsy for every element of the sequence.
-@zT: Take the character at location T (the lambda variable) from the input, and remove any appearances of: (This will be truthy if the character is not removed, and falsy if it is.
+" X": Remove space, X, and
`: Repr of
sm: sum  of map to
/           \X: count of "X" in
:+*JNz: The slice of the input prefixed by J dummy characters
td+d2: From d-1 to d+2.
m+T*kJU3: For d in [T, T+J, T+2*J].
Uz For T in range(len(input)).

Downvoters: Why the downvotes?

APL (NARS2000) (74)
{~0∊(G>9)∨G=(⍴G)↑{+/∊9<⍵∘⌷¨G∘.⊖(G←2-⍳3)∘.⌽⊂Z}¨⍳⍴Z←G↑⍨2+⍴G←¯1+⎕D⍳⊃⍵⊂⍨⍵≠' '}

Also works in Dyalog APL if ⎕ML is set to 3.
Explanation:

⊃⍵⊂⍨⍵≠' ': split ⍵ on the spaces and use the lists to form a matrix.
G←¯1+⎕D⍳: find the index in ⎕D for each value, subtract 1, and store this in G. (⎕D contains the digits, any non-digit will turn into 10).
Z←G↑⍨2+⍴G: add two lines and columns of zeroes at the edge of the matrix, to deal with the wraparound
{...}¨⍳⍴Z: for each position in Z, find the amount of bombs in the Moore neighbourhood of that position:

G∘.⊖(G←2-⍳3)∘.⌽⊂Z: rotate Z left, right, up, down, left-up, right-up, left-down, and right-down.
⍵∘⌷¨: for each of these, find the element at ⍵ in each of these rotated matrices
+/∊9<: count how many elements are higher than 9 (this is the amount of bombs).

(⍴G)↑: remove the added lines of zeroes again,
G=: check whether each element in G is equal to the amount of bombs surrounding that position (this should be true for all non-bomb squares),
(G>9)∨: and check whether the elements in G are higher than 9 (these are the bombs).
~0∊: return 1 if the resulting matrix contains no zeroes (=all squares are either bombs or the correct number), and 0 if it does.

Did you count bytes or characters? You should count bytes.

@TimS.: There are loads of 1-byte APL encodings, here's one.

C#, 321 320 305
bool s(string B){var L=B.Split(' ').Select(s=>' '+s+' ').ToList();var b=new string(' ',L[0].Length);L.Insert(0,b);L.Add(b);Func<int,int,IEnumerable<int>>E=Enumerable.Range;return E(1,b.Length-2).All(x=>E(1,L.Count-2).All(y=>L[y][x]=='X'||L[y][x]-'0'==E(x-1,3).Sum(X=>E(y-1,3).Sum(Y=>L[Y][X]=='X'?1:0))));}

First attempt golfing anything, and I know that C# isn't the ideal language.
I hope writing an instance method is allowed, otherwise add another 7 characters for static.
Spaced out:
bool s(string B) {
    var L = B.Split(' ').Select(s => ' ' + s + ' ').ToList();
    var b = new string(' ', L[0].Length);
    L.Insert(0, b);
    L.Add(b);
    Func<int, int, IEnumerable<int>> E = Enumerable.Range;
    return E(1, b.Length - 2).All(x =>
        E(1, L.Count - 2).All(y =>
            L[y][x] == 'X' ||
            L[y][x] - '0' == E(x - 1, 3).Sum(X =>
                E(y - 1, 3).Sum(Y =>
                  L[Y][X] == 'X' ? 1 : 0))));
}

Using Linq saves some space compared to for loops, but it's harder to debug.
I learned a few things like converting char => int by subtracting '0'.
It seemed simpler to pad out the board with spaces so iterating over it would be easier.

Can't you just replace -'0' with -48. Works for me and saves a few bytes for various 'X' and ' '

Python 2, 121
def f(B):n=B.find(' ')+1;R=range(len(B));print all(B[I]in' X'+`sum(2>I%n-i%n>-2<I/n-i/n<2<B[i]>'W'for i in R)`for I in R)

This is heavily inspired by feersum's answer. The order of the day is overkill: rather than checking for mines in the 9 neighbors of the cell, check every single cell to see whether it's a neighboring mine.
We check if two cells are neighbors with 2>r>-2<c<2, where r and c are the row and column differences of cells, equivalent to {r,c}<{-1,0,1}. These coordinates are computed from the cell indices I and i as c=I%n-i%n and r=I/n-i/n. It's more efficient to index directly into the string and extract rows and columns than to convert it to a 2D object like a list of lists. The mine check is B[i]>'W', equivalent here to B[i]=='X'.
Using enumerate would have saved two characters over the ugly range(len(B)) except that it returns an iterator object which does not support two nested loops through it.

I think a negative modulus should work for n; then you could use ~B.find.

@feersum Unfortunately, that messes up the / because it rounds negatives downward too.

Python 2, 140
s=input();w=s.index(' ')+1
print all(c in'X 'or(int(c)==sum(s[max(0,a-1):max(0,a+2)].count('X')for a in[i-w,i,i+w]))for i,c in enumerate(s))

JavaScript (ES6), 135 133 125 122
f=s=>s.split(" ")[e="every"]((l,i,a)=>[...l][e]((c,j)=>!(-[-1,0,k=1][e]((y,m,q)=>q[e](x=>k+=(a[i+y]||0)[j+x]=="X"))-c+k)))

Provide input to the function as a string:
f("XX4X2 5X6X4 XX6XX 4XX54 2X4XX");

For an explanation, see the old version, below. The new version replaces the for loops with every calls, and uses the variable e="every" to do someArray[e](...) instead of someArray.every(...).
Also, the counter k is now indexed at 1 so that the k+=... expression is always truthy, in order to keep the every loop running. We eliminate that extra 1 by subtracting the true result (which numerically coerces to 1) returned by the every operation [-1,0,k=1][e](...).

Old version:
f=s=>s.split(" ").every((l,i,a)=>[...l].every((c,j)=>{q=[-1,k=0,1];for(y of q)for(x of q)k+=(a[i+y]||0)[j+x]=="X";return c=="X"||k==c}))

Code with spaces and comments:
f=s=>s.split(" ")                 // split on spaces
      .every((l,i,a)=>             // for every line
                                   //     l: line string, i: line number, a: whole array
          [...l].every((c,j)=>{    // for every character
                                   //     c: character, j: index in string
              q=[-1,k=0,1];        // define counter k=0 and q=[-1,0,1]
              for(y of q)          // use q to loop adjacent spaces
                  for(x of q)

                      k+=              // add the following boolean to k:

                          (a[i+y]      //   from line number i+y...
                                 ||0)  //   (or a dummy zero, to prevent lookups on undefined)
                          [j+x]        //   ...get index j+x from the above value...
                                =="X"; //   ...and compare it to "X"

              return !(k-c)     // after the loop, this character passed if
                                // the char equals the number of counted X's (so k-c is 0)
                                // or it is an X itself (so `k-c` is NaN)
          })
      )

The JavaScript every array method takes a callback and applies the callback to every element of the array. If any callback returns a falsey value, the every call returns false.
Booleans in JS are coerced to 1 or 0 when part of an addition. For each surrounding space, we "add" the boolean result of comparing its value to X and then add that value to the counter k in the expression k += (... == "X"). Therefore, k contains a count of the number of surrounding Xs, because true counts as 1 and false counts as 0.

Instead of c=="X" try !c/1, which saves you a huge amount of a whooping pair of bytes! If it fails, try !!c/1. The reasoning is that 'X'/1 => NaN, and NaN is falsie. You check if c=='X', why not try to check if it isn't false?

@IsmaelMiguel That evaluates the same as (!c)/1, which doesn't help, unfortunately; I'd need to have the parentheses for !(c/1), which cost 2. Also, 0/1 is falsey, so the invalid input "0X" would have the incorrect result true. The best I can do while still respecting zeroes is to combine the two conditions into a negated phrase, like !(+c+1&&k-c), but that's the same length as what I already have.

@IsmaelMiguel Thanks for getting me thinking about it though -- I've realized that !(k-1-c) tests both conditions, because if k matches c (minus the 1 offset), then the negation makes the 0 true, and if c is not a number, we get NaN and the negation is also true.

You really were hungry! You ate 10 bytes since the initial code! I really like the solution you came up with. +1 for your solution!

CJam, 70 65 63 bytes
1l_S#):L)S*+:Q{Ii33/2%[0~1LL)L(L~)L~_))]W):Wf+Qf='X/,(scI==&}fI

This can be golfed a lot.
Gives 1 for a valid board and 0 for an invalid board.
Test cases
{-1:W;
1l_S#):L)S*+:Q{Ii33/2%[0~1LL)L(L~)L~_))]W):Wf+Qf='X/,(scI==&}fI
}6*]N*

Input
02X2 13X2 X211
XXXX XXXX XXXX XXXX
XX4X2 5X6X4 XX6XX 4XX54 2X4XX
02X2 13X2 X212
XXXX XXXX X7XX XXXX
XX5X2 5X6X4 XX6XX 4XX54 2X5XX

Output
1
1
1
0
0
0

Try it online here

JavaScript (ES6) 98
Using some to apply a function to each character of the string.
The function returns

false if blank
NaN if 'X' (repeatedly subtracting values from a non numeric char like 'X' gives NaN)
A numeric value of 0 if there are the right number of adiacent 'X', else non 0.
The inner check is made using map just because it's shorter than forEach

some returns true at the first truthy value (in this case, nonzero) meaning a failed check. The result is negated to give a more recognizable true/false.
F=v=>![...v].some(
  (x,p)=>x!=' '&&[1,-1,l=v.search(' '),-l,++l,-l,++l,-l].map(q=>x-=v[p+q]=='X')|x
)

Test In FireFox / FireBug console
;["02X2 13X2 X212","XXXX XXXX X7XX XXXX","XX5X2 5X6X4 XX6XX 4XX54 2X5XX"
,"02X2 13X2 X211","XXXX XXXX XXXX XXXX","XX4X2 5X6X4 XX6XX 4XX54 2X4XX","111 1X1 111"]
.forEach(t => console.log(t, F(t)))

Output
02X2 13X2 X212 false
XXXX XXXX X7XX XXXX false
XX5X2 5X6X4 XX6XX 4XX54 2X5XX false
02X2 13X2 X211 true
XXXX XXXX XXXX XXXX true
XX4X2 5X6X4 XX6XX 4XX54 2X4XX true
111 1X1 111 true

R, 156 chars
a=b=do.call(rbind,strsplit(scan(,""),""));for(i in 1:nrow(a))for(j in 1:ncol(a))b[i,j]=sum(a[abs(i-row(a))<2&abs(j-col(a))<2]=="X");v=a!="X";all(b[v]==a[v])

With indents, spaces and line breaks, for legibility:
a = b = do.call(rbind,strsplit(scan(,""),"")) #Reads stdin and turn into a matrix
for(i in 1:nrow(a)) #Ugly, ugly loop
    for(j in 1:ncol(a))
        b[i,j] = sum(a[abs(i-row(a))<2 & abs(j-col(a))<2]=="X")
v = a!="X"
all(b[v]==a[v])

Examples:
> a=b=do.call(rbind,strsplit(scan(,""),""));for(i in 1:nrow(a))for(j in 1:ncol(a))b[i,j]=sum(a[abs(i-row(a))<2&abs(j-col(a))<2]=="X");v=a!="X";all(b[v]==a[v])
1: XX4X2 5X6X4 XX6XX 4XX54 2X4XX
6:
Read 5 items
[1] TRUE
> a=b=do.call(rbind,strsplit(scan(,""),""));for(i in 1:nrow(a))for(j in 1:ncol(a))b[i,j]=sum(a[abs(i-row(a))<2&abs(j-col(a))<2]=="X");v=a!="X";all(b[v]==a[v])
1: XXXX XXXX XXXX XXXX
5:
Read 4 items
[1] TRUE
> a=b=do.call(rbind,strsplit(scan(,""),""));for(i in 1:nrow(a))for(j in 1:ncol(a))b[i,j]=sum(a[abs(i-row(a))<2&abs(j-col(a))<2]=="X");v=a!="X";all(b[v]==a[v])
1: XX5X2 5X6X4 XX6XX 4XX54 2X5XX
6:
Read 5 items
[1] FALSE

Vyxal 3 g, 23 bytes
Ṃᵛf:Þȯᵛᵛ'XCZᵗZ⌊ᵛᶻ0cᵛᵛ≈f

Try it Online!

authors: alexa дизайн

authors: احمد البنداري

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Implement a PCG
What better problem for PCG.SE than to implement PCG, A Better Random Number Generator? This new paper claims to present a fast, hard-to-predict, small, statistically optimal random number generator.
Its minimal C implementation is just about nine lines:
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org
// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)

typedef struct { uint64_t state;  uint64_t inc; } pcg32_random_t;

uint32_t pcg32_random_r(pcg32_random_t* rng)
{
    uint64_t oldstate = rng->state;
    // Advance internal state
    rng->state = oldstate * 6364136223846793005ULL + (rng->inc|1);
    // Calculate output function (XSH RR), uses old state for max ILP
    uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
    uint32_t rot = oldstate >> 59u;
    return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
}

(from: http://www.pcg-random.org/download.html)
The question is: can you do better?
Rules
Write a program or define a function that implements PCG on 32-bit unsigned integers.
This is fairly broad: you could print out an infinite sequence, define a pcg32_random_r function and corresponding struct, etc.
You must be able to seed your random number generator equivalently to the following C function:
// pcg32_srandom(initstate, initseq)
// pcg32_srandom_r(rng, initstate, initseq):
//     Seed the rng.  Specified in two parts, state initializer and a
//     sequence selection constant (a.k.a. stream id)

void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, uint64_t initseq)
{
    rng->state = 0U;
    rng->inc = (initseq << 1u) | 1u;
    pcg32_random_r(rng);
    rng->state += initstate;
    pcg32_random_r(rng);
}

(from: pcg_basic.c:37)
Calling the random number generator without seeding it first is undefined behaviour.
To easily check your submission, verify that, when seeded with initstate = 42 and initseq = 52, the output is 2380307335:
$ tail -n 8 pcg.c
int main()
{
    pcg32_random_t pcg;
    pcg32_srandom_r(&pcg, 42u, 52u);

    printf("%u\n", pcg32_random_r(&pcg));
    return 0;
}
$ gcc pcg.c
$ ./a.out
2380307335

Scoring
Standard scoring.
Measured in bytes.
Lowest is best.
In case of tie, earlier submission wins.
Standard loopholes apply.
Sample solution
Compiles under gcc -W -Wall cleanly (version 4.8.2).
Compare your submission to this to make sure you get the same sequence.
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

typedef struct { uint64_t state;  uint64_t inc; } pcg32_random_t;

uint32_t pcg32_random_r(pcg32_random_t* rng)
{
    uint64_t oldstate = rng->state;
    // Advance internal state
    rng->state = oldstate * 6364136223846793005ULL + (rng->inc|1);
    // Calculate output function (XSH RR), uses old state for max ILP
    uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
    uint32_t rot = oldstate >> 59u;
    return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
}

void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, uint64_t initseq)
{
    rng->state = 0U;
    rng->inc = (initseq << 1u) | 1u;
    pcg32_random_r(rng);
    rng->state += initstate;
    pcg32_random_r(rng);
}

int main()
{
    size_t i;
    pcg32_random_t pcg;
    pcg32_srandom_r(&pcg, 42u, 52u);

    for (i = 0; i < 16; i++)
    {
        printf("%u\n", pcg32_random_r(&pcg));
    }
    return 0;
}

Sequence:
2380307335
948027835
187788573
3952545547
2315139320
3279422313
2401519167
2248674523
3148099331
3383824018
2720691756
2668542805
2457340157
3945009091
1614694131
4292140870

So is your task language related?

@Knerd Nope. The C is just an example.

Can't wait to see a small javascript implementation..

CJam, 109 107 104 98 91 bytes
This uses some characters outside the ASCII range, but they are all within extended ASCII, so I'm counting each character as a byte (instead of counting as UTF-8).
{[2*0:A)|:B{AA"XQô-L-"256b*B1|+GG#%:A;__Im>^27m>_@59m>_@\m>@@~)31&m<|4G#%}:R~@A+:AR];}:S;

This is basically an exact port of the C code.
The seed function is a block stored in S, and the random function is a block stored in R. S expects initstate and initseq on the stack and seed the PRNG. R doesn't expect anything on the stack and leaves the next random number on it.
Since calling R before calling S is undefined behaviour, I'm actually defining R within S, so until you use the seed block, R is just an empty string and useless.
The state is stored in variable A and the inc is stored in B.
Explanation:
"The seed block S:";
[       "Remember start of an array. This is to clear the stack at the end.";
2*      "Multiply initseq by two, which is like a left-shift by one bit.";
0:A     "Store a 0 in A.";
)|:B    "Increment to get 1, bitwise or, store in B.";
{...}:R "Store this block in R. This is the random function.";
~       "Evaluate the block.";
@A+:A   "Pull up initstate, add to A and store in A.";
R       "Evaluate R again.";
];      "Wrap everything since [ in an array and discard it.";

"The random block R:";
AA            "Push two A's, one of them to remember oldstate.";
"XQô-L-"256b* "Push that string and interpret the character codes as base-256 digits.
               Then multiply A by this.";
B1|+          "Take bitwise or of 1 and inc, add to previous result.";
GG#%:A;       "Take modulo 16^16 (== 2^64). Store in A. Pop.";
__            "Make two copies of old state.";
Im>^          "Right-shift by 18, bitwise xor.";
27m>_         "Right-shift by 27. Duplicate.";
@59m>         "Pull up remaining oldstate. Right-shift by 59.";
_@\m>         "Duplicate, pull up xorshifted, swap order, right-shift.";
@@            "Pull up other pair of xorshifted and rot.";
~)            "Bitwise negation, increment. This is is like multiplying by -1.";
31&           "Bitwise and with 31. This is the reason I can actually use a negative value
               in the previous step.";
m<|           "Left-shift, bitwise or.";
4G#%          "Take modulo 4^16 (== 2^32).";

And here is the equivalent of the test harness in the OP:
42 52 S
{RN}16*

which prints the exact same numbers.
Test it here. Stack Exchange strips the two unprintable characters, so it won't work if you copy the above snippet. Copy the code from the character counter instead.

Confirmed: works as advertised.

C, 195
I figured someone ought to post a more compact C implementation, even if it stands no chance of winning. The third line contains two functions: r() (equivalent to pcg32_random_r()) and s() (equivalent to pcg32_srandom_r()). The last line is the main() function, which is excluded from the character count.
#define U unsigned
#define L long
U r(U L*g){U L o=*g;*g=o*0x5851F42D4C957F2D+(g[1]|1);U x=(o>>18^o)>>27;U t=o>>59;return x>>t|x<<(-t&31);}s(U L*g,U L i,U L q){*g++=0;*g--=q+q+1;r(g);*g+=i;r(g);}
main(){U i=16;U L g[2];s(g,42,52);for(;i;i--)printf("%u\n",r(g));}

Although the compiler will complain, this should work properly on a 64-bit machine. On a 32-bit machine you'll have to add another 5 bytes to change #define L long to #define L long long (like in this ideone demo).

Confirmed: works as advertised for me (GCC 4.8.2 on Mint 64-bit).

I would have to rule that the srandom function is part of your submission and should be included in the character count. (After all, perhaps you could think of some clever way to optimize this.) This would bring your current score up to 197, by my count.

@WChargin Ah, OK then. I counted 195 bytes.

Julia, 218 199 191 bytes
Renaming data types plus a few other little tricks helped me to cut down the length by additional 19 bytes. Mainly by omitting two ::Int64 type assignments.
type R{T} s::T;c::T end
R(s,c)=new(s,c);u=uint32
a(t,q)=(r.s=0x0;r.c=2q|1;b(r);r.s+=t;b(r))
b(r)=(o=uint64(r.s);r.s=o*0x5851f42d4c957f2d+r.c;x=u((o>>>18$o)>>>27);p=u(o>>>59);x>>>p|(x<<-p&31))

Explanation of the names (with according names in the ungolfed version below):
# R     : function Rng
# a     : function pcg32srandomr
# b     : function pcg32randomr
# type R: type Rng
# r.s   : rng.state
# r.c   : rng.inc
# o     : oldstate
# x     : xorshifted
# t     : initstate
# q     : initseq
# p     : rot
# r     : rng
# u     : uint32

Initialize seed with state 42 and sequence 52. Due to the smaller program you need to state the data type explicitely during initialization now (saved 14 bytes of code or so). You can omit the explicit type assignment on 64-bit systems:
r=R(42,52) #on 64-bit systems or r=R(42::Int64,52::Int64) on 32 bit systems
a(r.s,r.c)

Produce first set of random numbers:
b(r)

Result:
julia> include("pcg32golfed.jl")
Checking sequence...
result round 1: 2380307335
target round 1: 2380307335   pass
result round 2: 948027835
target round 2: 948027835   pass
result round 3: 187788573
target round 3: 187788573   pass
             .
             .
             .

I was really surprised, that even my ungolfed Julia version below is so much smaller (543 bytes) than the sample solution in C (958 bytes).
Ungolfed version, 543 bytes
type Rng{T}
    state::T
    inc::T
end

function Rng(state,inc)
    new(state,inc)
end

function pcg32srandomr(initstate::Int64,initseq::Int64)
    rng.state =uint32(0)
    rng.inc   =(initseq<<1|1)
    pcg32randomr(rng)
    rng.state+=initstate
    pcg32randomr(rng)
end

function pcg32randomr(rng)
    oldstate  =uint64(rng.state)
    rng.state =oldstate*uint64(6364136223846793005)+rng.inc
    xorshifted=uint32(((oldstate>>>18)$oldstate)>>>27)
    rot       =uint32(oldstate>>>59)
    (xorshifted>>>rot) | (xorshifted<<((-rot)&31))
end

You initialize the seed (initial state=42, initial sequence=52) with:
rng=Rng(42,52)
pcg32srandomr(rng.state,rng.inc)

Then you can create random numbers with:
pcg32randomr(rng)

Here is the result of a test script:
julia> include("pcg32test.jl")
Test PCG
Initialize seed...
Checking sequence...
result round 1: 2380307335
target round 1: 2380307335   pass
result round 2: 948027835
target round 2: 948027835   pass
result round 3: 187788573
target round 3: 187788573   pass
             .
             .
             .
result round 14: 3945009091
target round 14: 3945009091   pass
result round 15: 1614694131
target round 15: 1614694131   pass
result round 16: 4292140870
target round 16: 4292140870   pass

As I’m an abysmal programmer, it took me almost a day to get it working. The last time I tried coding something in C (actually C++) was almost 18 years ago, but a lot of google-fu finally helped me to create a working Julia version. I have to say, I have learned a lot during just a few days on codegolf.
Now I can start to work on a Piet version. That’s gonna be a whole lot of work, but I really, really want a (good) random number generator for Piet ;)

authors: ουτεδωδενεχωβρειονομα


text:
Produce the word 'codegolf' without using any of its characters in code
You need to produce the word codegolf

Rules:

None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code.
Case of the word must be one of three:

All Upcase (CODEGOLF)
All Downcase (codegolf)
Capitalized (Codegolf)

You only need to produce it somehow so there can be other characters in the output as well. For example, 21§HCodegolf092 is an acceptable result.
The shortest code (counting in bytes) to do so in any language wins.

I guess it will be less trickier in some languages than others (Brainfuck, Javascript, etc.)

I feel like we've had basically this challenge before, but I can't seem to find it.

Why the downvotes?

The downvotes are probably because "print X without X" is a type of challenge that's been done to death and people are tired of it. So, it's not your question but the site's history, which I can't blame you for not knowing.

@xnor - Thanks for explaining, I'm new to this stack site. :P

Related. Also related

Sigh... This is impossible in java. If c or l were allowed I might be able to do it. I would also need o or f.

In J,  {8#<a. should work. However, the interpreter spots the memory problem that this would cause, and throws an error.

@TheBestOne You can use unicode representation in Java, assuming none of them have edfg in the character code. This will undoubtedly make it much longer, though.

@TheNumberOne Boilerplate: class A{public static void main(){System.out.printf("CODEGOLF")}} I think you can do \uxxxx in Java instead of those. And nope, u is not disallowed.

Bash(works if there are no other files matching /bin/?at), 14
/bin/?at /*/u*

This expands to cat <files>, where the files include /dev/urandom. Because of the infinite monkey theorem, this will eventually output "codegolf".

Well, I almost surely upvoted you.

It got stuck on /dev/ptmx on my system.

@user23013 Sorry, didn't think of that. Will edit.

And /*/?at worked for me.

PHP, 8 bytes
CODEGOLF

Does not contain 'c', 'o', 'd', 'e', etc.
(You might want to ban their uppercase versions as well.)

Hahahaha, you know what I meant. Let me rephrase the question.

C - lots of characters
Without include, define, char, printf, return and lots of other useful things, it's a real challenge to try to do this in C.
I thought of outputting upside down letters, i.e. ɟloƃǝpoɔ, but the l and o are the same.
So here's the best I can do, which many people might remember as being very much like their first C assignment.
int main()
{
    puts("                   @                       @     @@ ");
    puts("                   @                       @    @   ");
    puts("                   @                       @    @   ");
    puts("  @@@    @@@    @@@@   @@@    @@@@   @@@   @  @@@@@ ");
    puts(" @   @  @   @  @   @  @   @  @   @  @   @  @    @   ");
    puts(" @      @   @  @   @  @@@@@  @   @  @   @  @    @   ");
    puts(" @   @  @   @  @   @  @      @   @  @   @  @    @   ");
    puts("  @@@    @@@    @@@@   @@@    @@@@   @@@   @    @   ");
    puts("                                 @                  ");
    puts("                                 @                  ");
    puts("                              @@@                   ");
}

To compile: gcc -o codegolf codegolf.c, surprisingly gcc, at least my installation, doesn't complain about missing includes or returns.
Running:
 $ ./codegolf
                   @                       @     @@
                   @                       @    @
                   @                       @    @
  @@@    @@@    @@@@   @@@    @@@@   @@@   @  @@@@@
 @   @  @   @  @   @  @   @  @   @  @   @  @    @
 @      @   @  @   @  @@@@@  @   @  @   @  @    @
 @   @  @   @  @   @  @      @   @  @   @  @    @
  @@@    @@@    @@@@   @@@    @@@@   @@@   @    @
                                 @
                                 @
                              @@@

If you squint your eyes and/or zoom out, it kind of looks okay!

Pyth, 9 bytes with updated rules
^v"\107"8

v"\107" evals a string containing G, octal escaped, which is the pyth variable for the alphabet.
^G8, is the result, which prints all 8 letter strings in the lowercase alphabet, including codegolf. Runs out of memory on my machine, unfortunately.

Unfortunately, this uses the now-banned capital G. What bad luck with your choice of Pyth's letters!

@xnor Fixed. Only tripled the length.

This answer inspires me to suggest a new Pyth constant: A fixed, extremely long string of random characters. Or a De Brujin graph if you want to be efficient.

@xnor Would that help for any non trivial challenges?

Not really, I'm just amused at the idea of one-character solutions. Unless iterating over it saves chars when you want to do something a huge but finite number of times?

Actually, @xnor's idea could be somewhat useful in other cases. In xnor's wythoff question, I had to use U39 to generate a list that was long enough to make each cold posisition. If I had needed 26 or less I could have used UG. I don't really know if it would be worth adding an arbitrarily long enumerable, but it would have other applications (Perhaps a -b flag for "big"?)

Javascript (2,786 Bytes)
I'm not competing with this answer, just pointing out that it can be done.
([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()([][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()(([]+{})[+[]])[+[]]+(!+[]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+[]))+([]+{})[+!![]]+(![]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]+!![]]

Output:
codegolf

I think most users of this site are already aware of the existence of jsfuck

Ooh. Sorry, I'm new.

CJam, 15 bytes
"r~utv~}w"{H^}%

I guess it should be shorter than Marbelous.

PHP, 13 bytes
<?=~œ›š˜“™;

StackExchange may swallow some of the control characters. Here's a hexdump of the program:
3c 3f 3d 7e 9c 90 9b 9a 98 90 93 99 3b

It bitwise inverts the string, and prints it using the PHP short tag syntax.

Perl - 12
say a.."z"x8

This also takes advantage of rule 3. It prints every word from a to zzzzzzzz.
Run with:
perl -E'say a.."z"x8'

Java, 118 Bytes
This is probably the lamest answer. Java programs have many key words. In order to print anything you have to use System.out. Despite all of these restrictions I can remove all of the letters in codegolf from my program except two letters.
With c and o allowed, 118 bytes:
c\u006cass a{pub\u006cic static voi\u0064 main(String[]a){Syst\u0065m.out.print("\143\157\144\145\143\157\154\146");}}

With l and o allowed, 123 bytes:
\u0063lass a{publi\u0063 stati\u0063 voi\u0064 main(String[]a){Syst\u0065m.out.print("\143\157\144\145\143\157\154\146");}}

With c and f allowed, 128 bytes:
c\u006cass a{pub\u006cic static v\u006fi\u0064 main(String[]a){Syst\u0065m.\u006fut.print("\143\157\144\145\143\157\154\146");}}

With l and f allowed, 133 bytes:
\u0063lass a{publi\u0063 stati\u0063 v\u006fi\u0064 main(String[]a){Syst\u0065m.\u006fut.print("\143\157\144\145\143\157\154\146");}}

With no restrictions on boilerplate code, 98 bytes:
class a{public static void main(String[]a){System.out.print("\143\157\144\145\143\157\154\146");}}

Expanded:
class a{

    public static void main(String[]a){
        System.out.print("\143\157\144\145\143\157\154\146");
    }

}

I think my answer is much lamer than yours!

Why not use a lambda? ()->"\143\157\144\145\143\157\154\146" ?

@NonlinearFruit Err... Java 8 was still pretty new, this answer is from late 2014.

CJam, 10 bytes
'P,{_m*}3*

It runs very slowly, and it should run out of memory on most computers. But if it exited successfully finally, it will print a lot of things including CODEGOLF.

'P, would save at least 66 exabytes of memory. :P

Marbelous - 9 bytes
7A
/\/\??

This will with a probability approaching 1 print a string containing all three acceptable outputs, since it prints an endless string of random ascii characters (up to and including the lowercase 'z' with ascii value 7A).
Nothing was specified about whether this program should terminate.
And just to make it clear, the characters get printed as they get generated, not after the program terminates (which is never).

Brainfuck (66 Bytes)
Can you do it in Brainfuck? Yes? Than I do it in Brainfuck!
++++[++++>---<]>.[->+++++<]>.-----------.+.++.++++++++.---.------.

Output:
CODEGOLF

Python 2.7, 52 48 bytes
print('%'+`map`[13])*8%(67,79,68,69,71,79,76,70)

Output:
CODEGOLF

This answer creates a format string using a 'c' found in the representation string of the built-in map function. The program then uses the format string to convert each integer into a character that creates the 'CODEGOLF' string.

dc, 20
4850170388041124934P

Prints the ASCII byte stream 0x434F4445474F4C46.

Javascript (29 bytes / 25 characters)
this['bt\x6fa']("àÄâÅ")

SE strips out the control characters, so here's a hex dump:
74 68 69 73 5B 27 62 74 5C 78 36 66 61 27 5D 28 22 08 C3 A0 C3 84 18 C3 A2 C3 85 22 29

With escape characters (34 / 29)
this['bt\x6fa']("\bàÄ\x18âÅ")

J, 6 (12?) char
A sentence returning CODEGOLF at the REPL, along with every other combination of 8 ASCII characters and a whole bunch of spaces, newlines, and box-drawing characters.
{8#<a.

If you want to toss this into STDOUT, prepend 1!:2&4 to double the charcount.

C, 49 48 bytes
-1 byte thanks to ceilingcat.
main(){int a[]={1701080931,1718382439};puts(a);}

C11, 46 45 bytes
main(){puts((int[]){1701080931,1718382439});}

It's obviously possible in C.
Works in 32bit little-endian systems.

Rule 3 lets you omit the 3 in the square brackets.

Brainfuck (145 Bytes)
+++++++++++[>++++++>++++++>++++++>++++++>++++++>++++++>++++++>++++++<<<<<<<<-]>+.>+++++++++++++.>++.>+++.>+++++.>+++++++++++++.>++++++++++.>++++.

Output:
CODEGOLF

CJam, 18 bytes
"1n¯]"245bHb{'B+}%

This answer prints the result instantaneously without consuming infinite system memory :)
It is just base conversion of the string CODEGOLF to both save bytes and to avoid using any of the restricted characters.
Just try it out here

Alright, here we go again.
The Hexadecimal Stacking Pseudo-Assembly Language (156):
(Technically not a valid entry, or so I'm told)

200066
400000
200063
400000
200009
400000
210000
200066
400000
200009
400000
210000
200067
400000
200065
400000
200064
400000
200066
400000
200009
400000
210000
200063
400000
140000

Output: codegolf

Shell, 21
tr 2-@ A-P<<<4@568@=7

ROT13, 8 bytes
pbqrtbys

rot13 is part of bsdgames.

Unnamed Two-Dimensional Programming Language, 26 bytes
67&79&68&69&71&79&76&70&s;

Output:
CODEGOLF

You can try it out here (Replace the code in the code() function with this code).
If it is acceptable, the final semicolon can be removed and the program will loop infinitely (in theory, not in the interpreter, as the interpreter gives up after 2048 instructions to avoid a browser-crashing infinite loop)  for a score of 25 bytes.
This works by pushing the values for the characters CODEGOLF to the stack, printing them, and terminating.

Jelly, 7 bytes
“£ṙɲI⁵»

Try it online!

what is this witchcraft

@Syxer It's a valid Jelly program. This is a compressed string using Jelly's compression. You can see that because 1) “ starts a string 2) » ends a compressed string. The string is then automatically output, no trailing newline AFAIK. To learn more about this language invented by Dennis, click on the Jelly link on my post.

Oh I know it's Jelly. Jelly witchcraft is scary though.

Vitsy, 6 bytes
<ZR^72

This has a 1 in 36028797018963968 chance of printing the right order of characters per character output with ~10000 characters output a second. This means that, by 3.17 million years from now, you'll almost certainly have seen it.
:)
Using a method found here.
Try it online!

Lua, 33 bytes
CODEGOLF (33 bytes)
print("\67\79\68\69\71\79\76\70")

Codegolf (40 bytes)
print("\67\111\100\101\103\111\108\102")

codegolf (40 bytes)
print("\99\111\100\101\103\111\108\102")

Pyke, 5 bytes
~aHpr

Try it here!

05AB1E, 5 bytes
’ƒËŠˆ

Uses the CP-1252 encoding. Try it online!


text:
Confuse the Dakotas
You have been hired by the government of North Dakota to encrypt the state's communications. Write two programs, one to encrypt a message and one to decrypt that message.
The government is not really tech-savvy, so the encryption algorithm does not need to be sophisticated; just make sure the result doesn't look similar to the original at first glance.
However, you're secretly loyal to the South Dakotan government. Your job is to mix up the communications, so that every mention of North Dakota becomes South Dakota upon decryption, and vice versa. This also applies to North/South Dakotan and North/South Dakotans.
For example:

North Dakota is the wealthiest county in North America, while South Dakotans are poorer than southern Florida. - the North Dakotan government

will undergo encryption and then decryption, resulting in:

South Dakota is the wealthiest county in North America, while North Dakotans are poorer than southern Florida. - the South Dakotan government

The algorithm which accomplishes this in the most secretive, tricky manner, as evidenced by having the most upvotes, will be accepted.

Would a simple string.replace work? Because you said the people are not really into technologie ;)

@Knerd I'd imagine you could, but it is a popcon...

@Sp3000 yeah, you are right...

Case sensitive ?

@Optimizer Your choice.

I'm voting to close this question as off-topic because underhanded questions are no longer allowed under site policy.

Ruby
class Dakota

  PRIVATE_KEY = 8411088

  def self.encrypt(str)
    str.gsub(/[A-Z]/){|c|"0#{c.downcase}"}.gsub(/[a-z]+/){|s|xor(s.to_i(36),$')}
  end

  def self.decrypt(str)
    str.gsub(/\d+/){|s|out = s.to_i.to_s(36);out[0] = out[0].upcase if s[0]==?0; out}
  end

  def self.xor(n, config)
    n^=PRIVATE_KEY if private_env?(config)
    n
  end

  def self.private_env?(config)
    config =~ /^ .#{private}/i
  end

end

puts code = Dakota.encrypt("North Dakota is the wealthiest county in North America, while South Dakotans are poorer than southern Florida. - the North Dakotan government")

puts out = Dakota.decrypt(code)

Demo

This took me ages to figure out. Well done, sir!

CJam
This is the encoder:
232375064392749269032321519657657089927649992440902190178063558812627752920796248165803740235420850037801568815744960725761679066919872746899310628404239458 128b:c~

and this is the decoder:
364380128038419794871782113211824472986419260504039724627500790722811712426518562428698978399810134993565366126560239807690210155343815201005388714282 128b:c~

Try it online here
This only works with capital N, S and D in North/South Dakota
Pass the input string to the first function from STDIN. Get the encoded string, pass it to the second function to get the decoded and converted output.

@Rainbolt LOL. Its WinterBash. Everything goes! (Surprised that you even had votes left)

As I said. LOL.

"This does nothing. HaHaHaHa! . The main logic lies in the decoder."; Why is there a . between HaHaHaHa! and The?

@TheBestOne because ... reasons.

Try decoding this: 364380128038419794871782113211824472986419260504039724627500790722811712426518562428698978399810134993565366126560239807690210155343815201005388714282.

Java
I discovered that division by zero does not cause errors in this program. This program fully encodes the Strings into a form that cannot be traced to the North Dakotan government. Due to the strange behaviour mentioned above, encoding and decoding might not work correctly in all cases.
class Program{

    public static void main(String[] args){
        String input = String.join(" ", args);
        String encode = encode(input);
        System.out.println("Encoded: " + encode);
        System.out.println("Decoded: " + decode(encode));
    }

    static String encode(String input){
        String answer = "";
        input = input.replaceAll("North Dakota", "☃");//Temporarily switch these so that spies
        input = input.replaceAll("South Dakota", "North Dakota");//think the message is from South Dakota
        input = input.replaceAll("☃", "South Dakota");//if they decode the message.
        for(int i =0; i < input.length(); i++){
            answer += (char)(~input.charAt(i)) + "";
        }
        return answer;
    }

    static String decode(String input){
        String answer = "";
        int i;
        for(i=0; i < input.length(); i++){
            answer += (char)(~input.charAt(i)) + "";
        }
        int funnyNumber = (i+\u002f*0)/0;//Division by 0 should cause an error???
        answer.replaceAll("South Dakota", "☃");
        answer.replaceAll("North Dakota", "South Dakota");
        answer.replaceAll("☃", "North Dakota");
        //For some reason, this does not cause errors either:
        funnyNumber = ((500/0)*\u002f+-2);
        return answer;
    }
}

Question: What does funnyNumber equal?

Whoa, did Java 8 add a static method join to the String class? *Silent celebration!*

Ah, I see what you did there. funnyNumber has a value of i - 2. I personally don't feel that hiding characters in unicode is very underhanded, though.

@Quincunx Correct, funnyNumber does equal i - 2.

Cool; I never knew that \u works outside of strings.

@Ypnypn - Java is viewing it as a character, and has built-in conversion from char to int.

It won't compile in Java 7 for a few reasons... out of curiosity I reduced it to printing the output of this:
int funnyNumber = (147+'\u002f'*0)/0;
...Which does cause a division by zero error.

@Desty This won't compile in Java 7 because of String.join. \u002f is not meant to be interpreted as a character literal.

Yes, I had to snip calls to String.join, although I'm sure it's not hard to work around it. The \u002f literal also will not compile as-is in Java 7, hence why I tried writing it as a character literal. Why does it work in Java 8?

@Desty Try System.out.println(2+\u002f*2/0*\u002f+-2).

Ah, I understand what it's doing now... no wonder it didn't work in isolation :)

The really funny thing about this answer is that (presumably accidentally) it still answers the question if you totally remove both the lines with the funnyNumber stuff...

JavaScript
function encrypt (input) {
    input = input.replace(/north d/gi, 'hisdf')
    input = input.replace(/south d/gi, 'hisde')
    var data = input
    var res = []
    for (var i = 0; i < data.length; i++) {
        res.push(~data.charCodeAt(i))
    }
    return res.toString()
}
function decrypt (input) {
    console.log(input)
    input = input.replace(/-105,-106,-116,-101,-102/g, '-79,-112,-115,-117,-105,-33,-69').replace(/-105,-106,-116,-101,-103/g, '-84,-112,-118,-117,-105,-33,-69 ')
    input = input.split(',')
    var res = ""
    for (var i = 0; i < input.length; i++) {
        var itm = input[i]
        res += String.fromCharCode(~parseInt(itm))
    }
    return res
}
var data = encrypt(prompt('What do you want to encrypt?'))
var data = decrypt(data)
alert(data)

My solution is probably not the most clever one. But it works :) Here is a fiddle
First I replace north d with hisdf and south d with hisde, then I invert all the characters bitwise and push them in an array. The array I convert into a string and then replace the inverted character values with the correct ones. Before that, I replace the values of hisdf and hisde switched.

What if my actual string contained hisde somewhere ?

@Optimizer well, than we it breaks :D

@Roger Nope, becuase it replaces north d and south d :)

@Knerd Yep, I saw the 'd' at the end just as you posted that. /facepalm

AWK: Encoder: 165 bytes, Decoder: 61 bytes
The encoder (also in charge of replacing South by North and vice versa):
{a="(th Dakota(ns?)?)";b="\\1";split(gensub("@"a,"Sou"b,"g",gensub("Sou"a,"Nor"b,"g",gensub("Nor"a,"@"b,"g")))" ",y,"");for(i=1;i<length(y);i+=2)printf(y[i+1] y[i])}

The decoder:
{split($0,y,"");for(i=1;i<length(y);i+=2)printf(y[i+1] y[i])}

Some test:

North Dakota is the wealthiest county in North America, while South Dakotans are poorer than southern Florida. - the North Dakotan government

encodes into:

oStu haDokati  sht eewlahteitsc uotn yniN rohtA emirac ,hwli eoNtr haDokatsna erp ooer rhtnas uohtre nlFrodi.a- t ehS uohtD katonag voremnne t

(that should be scrambled enough for a not really tech-savvy government :o) )
It then decodes into:

South Dakota is the wealthiest county in North America, while North Dakotans are
poorer than southern Florida. - the South Dakotan government

But that was expected :o)
Note: North Dakota, North Dakotan, North Dakotans, South Dakota, South Dakotan and South Dakotans have to be correctly capitalized.

JavaScript, ES6
Sweet and simple to begin with.
Encoder:
E=a=>btoa(a)

Decoder:
D=a=>atob(a_.replace(/(nor|sou)(th dakota)/gi, (_,x,y)=>({n:"sou",s:"nor",N:"Sou",S:"Nor"})[x[0]]+y)

Try it below on a latest Firefox:

E=a=>btoa(a)
D=a=>atob(a).replace(/(nor|sou)(th dakota)/gi, (_,x,y)=>({n:"sou",s:"nor",N:"Sou",S:"Nor"})[x[0]]+y)
var string = prompt()
alert("Encoded string: " + E(string));
alert("Decode string: " + D(E(string)));

Your code doesn't work, you should replace dakotan with dakota :)

@Knerd no, you should not.

Yes you should, with your code you only replace North Dakotan not North Dakota same goes for south

@Knerd, oh that's what you meant. I though you meant I should replace occurance of dakotan with dakota

Yep, I see you canged it, you solution is so smooth :D Do you actually encrypt or just replace?

@Knerd Just replace.

Cause, I think the OP wanted the code to encrypt a message and then with another code to decrypt it.

@Knerd Ah, let me fix that.

This is not really underhanded at all. I'd be tempted to downvote but not sure if that's cool in a popularity contest?

C
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

#define MASK_B 0xFFFFFFULL
#define MASK_C 0xFFULL
#define ll unsigned long long int
#define transform(a,b) ((a)>(b))?(a):(b)
static const ll magic_num = 0x756f736874726f6e;
#define BITS(a,b) (magic_num&(MASK_C<<((a+b)*8)))>>((a+b)*8)

char * key;
ll keylen;
FILE * file;

char * encrypt(in)
char * in;
{
    char * out;
    size_t length = strlen(in);
    out = (char *) malloc(sizeof (char) * (length + 1));
    for (ll i = 0; i < length; i++)out[i] = key[i % keylen]^in[i];
    out[length] = '\0';
    return out;
}

char * decrypt() {
    size_t len = 0;
    fpos_t pos;
    char * out;
    fgetpos(file, &pos);
    do if (fgetc(file) == EOF) break; else len++; while (1);
    out = (char *) malloc(sizeof (char) * (len + 1));
    fsetpos(file, &pos);
    char chr;
    ll idx = 0;
    do {
        chr = fgetc(file);
        if (chr == EOF) break;
        out[idx++] = chr^key[idx % keylen];
    } while (1);
    out[len] = '\0';
    return out;
}

void * bits(flag, mask)
ll flag;
char * mask;
{
    int dx = (flag & (~0&MASK_C)<<16) ? 5 : 0;
    key[0] = BITS(dx, 0),key[1] = BITS(dx, 1),key[2] = BITS(dx, 2),key[3] = BITS(3, 0),key[4] = BITS(3, 1);
    strncpy(&key[5], " dakota", 8);
    if (flag & ~(MASK_B^MASK_C)) {
        dx = (char)flag & MASK_C;
        if (islower(*mask)) *mask = key[dx - 1];
        else *mask = toupper(key[dx - 1]);
    } else if (!(flag & ~~0))
        return (void *) key;
    return (void*) key[transform(arc4random_uniform(12), 12)];
}

int genkey(in)
char * in;
{
    size_t bound_upper = strlen(in);
    char * index1 = malloc(sizeof(char) * (bound_upper + 1));
    char * index2 = malloc(sizeof(char) * (bound_upper + 1));
    char * index;
    index1 = strcpy(index1,in);
    index2 = strcpy(index2,in);
    ll spice = 0;
    key = (char *) malloc(sizeof (char) * 13);
    char *hits = (char *) malloc(sizeof (char) * bound_upper);
    for (unsigned long j = 0; j < bound_upper; j++){
        hits[j] = 0;
    }

    for (int iter = 0; iter < 2; iter++) {
        ll rotation = 0, flag = MASK_C << (8 * (iter + 1)), flag2 = MASK_C << (8 * (2 - iter)),abs=0;
        char * tmpstr;
        index = iter ? index2 : index1;
        do {
            spice = spice + arc4random_uniform(bound_upper) % bound_upper;
            if (!rotation) {
                tmpstr = strcasestr(index, bits(flag, in));
                if (tmpstr == NULL)
                    goto out;
                index = tmpstr;
            } else {
                bits(flag2 | rotation, index++);
                hits[abs] = iter + 1;
            }
            rotation = (rotation + 1) % (4);
            abs = index - (iter ? index2 : index1);
        } while (flag);
out:
        index = in;
        rotation = 0;
    }
    for(int k = 0;k < bound_upper;k++){
        index[k]=(hits[k]==1?index1[k]:(hits[k] ? index2[k]: index[k]));
        spice += arc4random_uniform(spice)|spice^arc4random();
    }
    free(key);
    spice = spice % bound_upper;
    if (!spice)
        spice = bound_upper;
    keylen = (keylen | spice) & MASK_B;
    key = (char *) malloc(sizeof (char) * (keylen + 1));
    for (ll i = 0; i < keylen; i++)
        key[i] = (arc4random_uniform(126 - ' ') % (126 - ' ')) + ' ';
    key[keylen] = '\0';
    return keylen;
}

int main(argc, argv)
int argc;
char *argv[];
{
    if (argc != 4) return 1;
    char * result;
    if (!strcmp(argv[1], "encrypt")) {
        (void) genkey(argv[2]);
        result = encrypt(argv[2]);
        printf("Decryption Key: '%s'\n", key);
        file = fopen(argv[3], "wb");
        if (file == NULL) printf("Could not open file for writing: %s", argv[3]);
        if (fwrite(result, sizeof (char), strlen(result), file) != strlen(result)) printf("Error occurred while writing ciphertext to file!");
    }
    if (!strcmp(argv[1], "decrypt")) {
        file = fopen(argv[3], "rb");
        if (file == NULL) printf("Could not open file for reading: %s", argv[3]);
        key = argv[2];
        keylen = strlen(argv[2]);
        result = decrypt();
        printf("Plaintext: '%s'\n", result);
    }
    return 0 & fclose(file);
}

Compile with: gcc -Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic file.c
For maximum evil, written in K&R C with a dash of pointer abuse.
Lasciate ogni speranza, voi ch'entrate.
Buśhaīila rukgâī, naǵkxarańga ba tdhuløk.
Also, everything's in the bits function and the genkey function.
Run:
[...@...] testing_golf$ ./a.out encrypt "North Dakota is the wealthiest county in North America, while South Dakotans are poorer than southern Florida. - the North Dakotan government" cipher
Decryption Key: ')=1aj3'
[...@...]: testing_golf$ ./a.out decrypt ")=1aj3" cipher
Plaintext: 'South Dakota is the wealthiest county in North America, while North Dakotans are poorer than southern Florida. - the South Dakotan government'

Note: When specifying the key in decrypt mode, it may be necessary to escape some of the characters in the key with backslashes.

authors: Андрей Аверин