text:
Write a binary counter in quine
Write two code fragments, which we will call s_zero and s_one.
Program (l, n) consists of l copies of s_zero and s_one corresponding with the digits of n in binary, padded with s_zero on the left.
For example, if s_zero = foo and s_one = bar then
Program (4, 0) = foofoofoofoo
Program (4, 1) = foofoofoobar
Program (4, 2) = foofoobarfoo
etc.
Program (l, n) must print the source of Program (l, (n + 1) mod (2^l)) to standard out. In the example above, foobarfoofoo must print foobarfoobar when executed.
Your score is the sum of the lengths of fragments s_zero and s_one

Near duplicate to http://codegolf.stackexchange.com/questions/35974/code-that-runs-the-game-of-life-on-itself - computation done by quining program with 2 different code blocks.

Can the program read its own source code?

@feersum I disagree. This one is a lot easier, in particular, you don't need to be able to determine line breaks. Furthermore, I think the task does make a difference, otherwise every generalised quine challenge would be a dupe of the basic quine challenge.

The advantage of the simpler task is that it encourages competition to create the shockingly short answers seen so far- I hope that justifies this challenge as different!

Probably worth noting that s_zero and s_one have to be different. Otherwise I have many solutions with 2*n scores.

CJam, 29 + 29 = 58 bytes
The 0 code:
0{"_~"]]z(3\+2b(2b2>a\+z~[}_~

The 1 code:
1{"_~"]]z(3\+2b(2b2>a\+z~[}_~

Explanation
0                       " Push the current bit. ";
{"_~"                   " The basic quine structure. ";
    ]                   " Make an array of the current bit, the function and _~.
                          That is the code fragment itself. ";
    ]                   " Make an array of all code fragments in the stack. ";
    z(                  " Extract the array of the bits. ";
    3\+2b(2b2>          " Convert from base 2, decrease by one and convert back,
                          keeping the length. ";
    a\+z                " Put the bits back to the original position. ";
    ~                   " Dump the array of code fragments back into the stack. ";
    [                   " Mark the beginning position of the array of the next code fragment. ";
}_~

every single time ...

CJam, 47 + 47 = 94 bytes
The 0 code:
{`"_~"+]:+T2*0+:T)\AsSerS/_,(@2Y$#+2bU@->]zs}_~

The 1 code:
{`"_~"+]:+T2*1+:T)\AsSerS/_,(@2Y$#+2bU@->]zs}_~

Excuse the expletive.
I'm sure I can still shave off a few bytes there. I'll add an explanation once I decide that I can't be bothered to golf it any further.
Test it here.

Python 3.8 (pre-release), 264 250 120 + 120 = 240 bytes
Code 0: (120 bytes)
for i in(c:=[]),0:
 c+=0,;exec(s:="i or print(end=f'for i in(c:=[]),0:\\n c+={c[0]^all(c:=c[1:-1])},;exec(s:=%r)#'%s)")#

Try it online!
Code 1: (120 bytes)
for i in(c:=[]),0:
 c+=1,;exec(s:="i or print(end=f'for i in(c:=[]),0:\\n c+={c[0]^all(c:=c[1:-1])},;exec(s:=%r)#'%s)")#

Try it online!
Test Suite
Try it online!
How it works:

c store the binary number of the program on the form of a list

The for loop execute twice :

the first time, it assigns c to the correct value
the second time, it prints the code replacing a char by 1 or 0 depending on c. The nth time c[0]^all(c:=c[1:-1]) is called, it returns the nth leftmost bit of c+1

the next for loop are ignored thanks to the comment #
The printing is a derivate of this quine : exec(s:="print('exec(s:=%r)'%s)")

CJam, 45 + 45 = 90 bytes
The 0 code:
{`]W=L0+:L,Ua*L2b)2b+L,W*>\f{X$!s/\s*"_~"}}_~

The 1 code:
{`]W=L1+:L,Ua*L2b)2b+L,W*>\f{X$!s/\s*"_~"}}_~

Explanation soon.
Try it online here

GolfScript, 37 + 37 = 74 bytes
0{`".~"+:q;]-2%1\{1$^.@&q@}%\;-1%~}.~

1{`".~"+:q;]-2%1\{1$^.@&q@}%\;-1%~}.~

Not quite as short as user23013's CJam solution, but I figured I'd post this anyway, if only to (marginally) increase the diversity of the languages used.
My solution not directly based on any of the existing solutions (and, indeed, I haven't examined them in detail, as I still don't read CJam very well), but they all feature variants of the same basic quine structure ({".~"}.~ in GolfScript, {"_~"}_~ in CJam).  That's not really very surprising, since it seems to be one of the most efficient ways to write a quine with an arbitrary payload in these languages.
There are several parts of this code I don't really like, and I suspect it may be possible to golf this further, but I've spent too much time on this as it is.


text:
Generate the Stöhr sequence
I am learning Ruby and wrote my first nontrivial code to solve this problem.
The challenge is to generate the first n elements of the Stöhr sequence, S, which is defined as follows:

S[0] = 1
S[n] is the smallest number that cannot be expressed as the sum of two distinct previous elements in the sequence.

Thus the sequence begins with 1, 2, 4, 7, and 10. The next element is 13, because 11 (=1+10) and 12 (=2+10) are sums of previous elements, but 13 is not.
I am looking for the shortest code. My own, in Ruby, is 108 characters long, but maybe I'll wait to see what others come up with before posting it?

I like the answers so far. Now, it's perhaps too late to go back and change the requirements, but I suppose I should have mentioned that I'm particularly interested in solutions that use the definition of the sequence itself (i.e., the code doesn't know in advance that eventually the numbers go up by 3). So: moral bonus points if you can do that.

Such is the problem with mathematical sequences. If you know the pattern, it will usually be shorter.

This sequence is arithmetical without any use(?).

@user75200 The sequence is not arithmetical, as you can see from the differences in the first three elements, but the subsequence starting at the third element is indeed arithmetical. It is used in connection to the Postage Stamp problem.

APL, 7
In APL you can choose if you want to work with index 0 or index 1.
You do this by setting global variable ⎕IO←0
If we choose to work in index 0 we have:
+\3⌊1⌈⍳

Explanation:
⍳    creates a sequence 0...n   (0 1 2 3 4 5)
1⌈   takes whichever is bigger, number in sequence or 1 (1 1 2 3 4 5)
3⌊   takes whichever is lower, number in sequence or 3 (1 1 2 3 3 3)
+\   partial sums for the sequence (1 2 4 7 10 13)

Try it on tryapl.org

Can't you work with 1 based index and then create 1 to n array and simply prepend it with another 1 ? If that can be done, is it shorter ?

The code I got to was longer. This was my code for index 1, 10 chars: +\3⌊1,⍳¯1+
Also, the index-0 version works with argument 0 too, while this one does not.

Ah. yeah . APL really shined through here ..

Haskell - 11 21
Lazy infinite sequence
1:2:[4,7..]

Function that returns just supplied number of members (sigh)
flip take$1:2:[4,7..]

You have to take an input and print only the first n numbers.

@Optimizer Well, technically, you have to "generate the first n elements of the Stöhr sequence"—it doesn't say you can't generate the rest of them as well! It doesn't say that you have to take an input, either. swish's original code actually does generate the first n terms, for any n.

@WChargin trying to being oversmart isn't new. Taking the OP's wording too literally and producing extra output than required both are considered as standard loopholes.

@Optimizer Actually, being lazy means no extra output would be generated until you ask for it, and you can ask for any terms you want.

@swish I don't understand. What is lazy here ?

@Optimizer The chunk that produces the sequence.

How do I tell it to stop at 14th number ?>

@Optimizer take 14$1:2:[4,7..]

@swish yes and that is your second code, which should actually be counted.

Let us continue this discussion in chat.

You can shorten the take version using section syntax

@Optimizer The point is that the computer won't do any extra calculation if it wasn't needed.

@proudhaskeller Do you mean (\take`(1:2:[4,7..]))`? It's the same length, or can it be shorten somehow?

@swish my bad, I thought the parenthesis around the list are redundant.

Hm! A lazy list (generator) is against the rules, but a lambda isn't? Here you go then... 16 bytes: \n->1:2:[4,7..n].

Python 2, 37 35 bytes
lambda n:[1,2][:n]+range(4,n*3-4,3)

Making use of a pattern...

You can include the 4 in the range: lambda n:[1,2][:n]+range(4,n*3-4,3)

Nice find. Edited to 35 now.

CJam, 14 bytes
1l~{_p_3e<+}*;

Test it here.
Starts at 1. Then, S[n] = S[n-1] + min(S[n-1], 3).
1l~{_p_3e<+}*;
1              "Push 1.";
 l~            "Read and evaluate input N.";
   {       }*  "Repeat this block N times.":
    _p         "Duplicate the last number and print it.";
      _3e<     "Duplicate it again, and take minimum with 3.";
          +    "Add to last number.";
             ; "Discard final number to prevent output.";

This generalises easily to h-Stöhr sequences if we replace 3 by 2h-1.

Brainfuck, 13 chars
+.+.++.[+++.]

Or 30 chars if we want to limit it to n outputs:
,->+.<[->+.<[->++.<[->+++.<]]]

I think you need to print the first n elements, not an infinite stream of them...

@Sp3000 Is using charcodes as numeric input and output accepted generally? Can't find on meta. With that it would be fairly easy to correct to BF code.

Personally I'm not sure what the general consensus is for this, sorry. I've had a bit of a problem with this too.

for the first n elements, i think i could do ->+.<[->+.<[->++.<[->+++.<]]] (29 chars), but that's not as elegant.
And i don't think the language is specifically limited to using ASCII codes for input and output.

Your code have to answer the question even if it's not that elegant. I would suggest to edit the post and correct the answer to ,->+.<[->+.<[->++.<[->+++.<]]]. (You missed the input reading comma at the beginning.)

I started a discussion on meta to sort this out.

Hey, this program doesn't work at all.

Python, 136 bytes
def f(n):
 if n<1:return[1]
 x=f(n-1);y=set(x)|{a+b for a in x for b in x if a!=b};return x+[min([a for a in range(1,max(y)+2)if{a}-y])]

Straight from the definition. I'm not sure how much I can golf this — it's certainly a lot longer than I expected.

J, 14 chars
This just hardcodes the [1,2, 4+3*k (k=0..n-1) ] sequence and takes the first N.
   ({.1,2,4+3*i.) 10
1 2 4 7 10 13 16 19 22 25

.
J, 18 chars
This one uses a linear combination of [0,1,2,3...], [1,1,0,0...] and [0,1,1,1...].
Should be shorter but can't seem to golf it.
   ((3&*+<&2-2**)@i.) 10
1 2 4 7 10 13 16 19 22 25

Prelude, 32 20
Edit: ...with twice the voices now!
?(1-)
4 +3
2  ^
1 !^

This assumes the Python interpreter with NUMERIC_OUTPUT = True. Like the Brainfuck submission this answer assumes that input is given in the form of a code point. This is partly to get more attention for this meta discussion (and partly, because I love Prelude). So if you want to print the first 32 numbers, say, you need to put a space on STDIN. Of course, this means there's an upper limit to the valid inputs, but this answer isn't winning anyway, so I think within the limitations of Prelude this is fine.
Explanation
In Prelude, all lines are executed in parallel, which line having its own stack, initialised to an infinite amount of zeroes. There is only a single instruction pointer (pointing at columns), so if you enter a loop on one voice, all other voices will loop along with it.
In the following I've transpose the code, so that I can annotate lines instead of columns:
?421  Read a character into the first stack. Push 4, 2, 1 onto the other stacks, respectively.
      Generally, the fourth stack will hold the next number to be printed, the third stack the
      one after that, and the second stack the number two steps ahead.
(     Start a loop if the input wasn't 0.
1+ !  Push a 1 onto the first stack. Add the top elements in the second stack. On the first
      iteration this will be 0 and 4, so it does nothing. On all further iterations
      this will increment the last number by 3.
-3^^  Subtract one from the first stack. Push a 3 onto the second stack for the next iteration.
      Copy the last value from the second to the third, and the third to the fourth stack.
)     If the top of the first stack is not 0, jump back to the column after the (.

JavaScript (ES6) 92
As a recursive function based upon the problem definition
S=(n,v=1,s=[],r=0)=>[for(a of s)for(b of s)r+=(a-b&&a+b==v)]|r||(s.push(v),--n)?S(n,v+1,s):s

Using the pattern 1,2, 1+3*k : 58
S=(n)=>(i=>{for(t=1;n>r.push(t+=i);i+=(i<3));})(0,r=[])||r

Side note: finding the h-Stöhr sequence (verifying the sum of up to h numbers instead of just 2). The R function tries all possibile sums of up a given number of list elements.
S=(n,h=2,s=[],v=1,R=(t,v,l,i=0,r=t,w)=>{
  for(;r&&l&&v[i];i++)
    w=[...v],r=!R(t-w.splice(i,1),w,l-1)
  return!r;
})=>R(v,s,h)||(s.push(v),--n)?S(n,h,s,v+1):s

Ungolfed roughly equivalent (and ES5 compatible)
function S(n, v, s)
{
  var r=0,a,b
  v = v||1
  s = s||[]
  for(a of s)
    for(b of s)
    {
      if (a != b && a+b == v)
        r++;
    }
  if (r == 0)
  {
    s.push(v);
    --n;
  }
  if (n != 0)
     return S(n,v+1,s)
  else
     return s
}

Test In FireFox/FireBug console. Simple function:
S(20)

[1, 2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55]

Advanced function:
S(10,5)

[1, 2, 4, 8, 16, 32, 63, 94, 125, 156]

><> (fish), 72 65 49 46 chars
1n1-:?!;' 'o2n1-v
v1&no' ':<4&;!?:<
>-:?!;&3+^

Input is supplied to interpreter:
>fish.py stohr.fish -v 10
1 2 4 7 10 13 16 19 22 25

My first ><> program, suggestions appreciated.

Oh, good! I was hoping someone would write a ><> program.

Perl6   22 / 30
I'm going to see if Perl6 can deduce the sequence for me.
To do that I used the REPL built into Perl6
$ perl6
> 1,2,4,7...*
Unable to deduce arithmetic or geometric sequence from 2,4,7 (or did you really mean '..'?)
> 1,2,4,7,10...*
1 2 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 ...

Hmm, I see the pattern that Perl deduced. After 4 to get the next value you just add 3.
1,2,4,*+3...*

Which saves one character making the code to get an infinite list of the numbers in the Stöhr sequence 13 characters long.
This code only does something useful in the REPL since it prints the gist of the result for us. To get it to print otherwise you would have to explicitly tell Perl to print the results.
$ perl6 -e 'say 1,2,4,*+3...*'

( * + 3 is simply a way to get a code reference which returns 3 added to it's only argument. Other ways to write it would be { $_ + 3 }, or -> $i { $i + 3 }, or { $^i + 3 } or sub ($i){ $i + 3 } )

The shortest way to create something Callable to generate the first n elements is to get a slice of the elements.
{(1,2,4,*+3...*)[^$_]} # 22

In void context that would generate the first $_ values, then promptly throw them away.
In anything other than void context it creates an anonymous code block ( a basic subroutine without a name ) which takes one argument.
# store it in a scalar variable
my $sub = {(1,2,4,*+3...*)[^$_]};
say $sub.(5);
# 1 2 4 7 10

# use it immediately
say {(1,2,4,*+3...*)[^$_]}.(5);
# 1 2 4 7 10

# pretend it always had a name
my &Stöhr-first = {(1,2,4,*+3...*)[^$_]};
say Stöhr-first 5;

If you really think it has to have a name to qualify as a valid for this challenge you would probably do this:
sub s(\n){(1,2,4,*+3...*)[^n]} # 30

Though since s is also used for the substitution operator, to call this the parens are non-optional. ( You could have given it a different name I suppose )
say s(5);
# 1 2 4 7 10

Unless specified otherwise in the challenge, submissions to code golf challenges have to be full programs or functions, not just snippets.

@MartinBüttner to be fair 1,2,4,*+3...* actually creates an object that will generate the values needed. I don't think that many people would actually create something Callable around something like that in Perl6.

><>, 31 bytes
4i1nao:?!;2nao1-:?!;$:nao3+$d0.

Reads in a single char, uses its code point (e.g. space = 32) and prints the numbers one on each line.

I see there is already a MUCH better java answer but i spent a while on this and i'm going to post it. even if it sucks.
Java 313 char (+4 to fit it on screen)
import java.util.*;public class S{public static void main(String[] a){
Set<Integer> S=new HashSet<Integer>();S.add(1);int i=1,k=0;
while(S.size()<=new Integer(a[0])){if(S.contains(i)){}else{k=0;for(int j:S){
for(int l:S){if(l!=j){if((j+l)==i)k=1;}}}if(k==0)S.add(i);}i++;}for(int x:S)
{System.out.println(x);}}}

always grateful to get any tips or pointers on how to improve

Jelly, 6 bytes
Ż«3»1Ä

Try it online!
Exactly the same as the APL answer, uses the fact that the partial sums are \$1, 1, 2, 3, 3, 3, ...\$
Alternative 6 byters
How it works
Ż«3»1Ä - Main link. Takes n on the left
Ż      - [0, 1, 2, ..., n]
 «3    - Min with 3; [0, 1, 2, 3, 3, 3, ...]
   »1  - Max with 1; [1, 1, 2, 3, 3, 3, ...]
     Ä - Cumulative sum

The alternatives all work by generating the partial sums, just in different methods

Ruby - 108 88
q=->n{*k=1;(m=k[-1];k<<([*m+1..2*m]-k.combination(2).map{|i,j|i+j})[0])while k.size<n;k}

This uses the definition of the sequence.
More readable version:
q=->n{
    *k=1
    (
        m = k[-1]
        k << ([*m+1..2*m] - k.combination(2).map{|i,j|i+j})[0]
    ) while k.size < n
    k
}

print q[10]
[1, 2, 4, 7, 10, 13, 16, 19, 22, 25]

Ruby golf tips: *k=1 instead of k=[1]. foo while bar instead of while bar;foo;end. [*s..e] instead of (s..e).to_a. .map instead of to_a.map. {|a,b|a+b} instead of {|i|i.inject(:+)}.

@histocrat Thanks, that's very helpful!

T-SQL 204
Assumes that the input is in a variable called @N. I can make a procedure if you want, but there really isn't a good way to get STD_IN in T-SQL.
Also, yay for moral bonus!
DECLARE @Q INT=0,@B INT=2
DECLARE @ TABLE(A INT)WHILE @N>0
BEGIN
SET @N-=1
WHILE @B>1
BEGIN
SET @Q+=1
SELECT @B=COUNT(*)FROM @ C,@ B WHERE C.A+B.A=@Q
END
INSERT INTO @ VALUES(@Q)SET @B=2
END
SELECT*FROM @

Nice! I don't know much about SQL—how is @N used here? I see that it's set near the beginning, but then it doesn't seem to be referenced later.

It looks like @N is the "i" of the "for loop".

Jacob is right. The @N is the "i" of the for loop, which is a while loop in SQL. Essentially it cross joins the table with itself and finds pairs that add to @Q. If there's at least two pairs (i.e. not just a number with itself), then it skips it. Otherwise, it adds it to the table. @ is the name of the table.

Mathematica, 27 bytes
Hmmm, still no Mathematica answer? Here are two:
NestList[#+3~Min~#&,1,#-1]&
Array[i=1/2;i+=3~Min~i&,#]&

both define an unnamed pure function which receives an integer and returns a list of integers. This is based on the same recurrence relation as my CJam submission. Note that the Array-based code starts from 1/2, because the recurrence relation is always applied before the value is returned.

Java, 46
n->IntStream.iterate(2,x->x==2?1:x+3).limit(n)

This is a function in Java 8.

Python - not even close (139)
Acting under the assumption that this weren't easily calculable as others have done, the shortest solution I've found is below:
from itertools import combinations as C
x,i,n=[],1,input()
while len(x)<=n:
 if i not in [sum(y) for y in C(x,2)]:x.append(i)
 i+=1
print n

Clojure - 130118
(defn s[n](last(take n(iterate #(if(<(count %)3)(conj %(+ (apply + %)1))(conj %(+(last %)(second %)(first %))))[1]))))

Un-golfed version:
(defn stohr [n]
  (last
    (take n
      (iterate #(if (< (count %) 3)
                   (conj % (+ (apply + %) 1))
                   (conj % (+ (last %) (second %) (first %)))) [1]))))

Share and enjoy.

STATA 51
di 1 2 _r(a)
loc b=3*$a-2
forv x=4(3)`b'{
di `x'
}

TI-BASIC, 41 27 30 bytes
For your calculator
Input N:For(I,1,N:I:If I>2:(I-2)3+1:Disp Ans:End

GML, 67 bytes
n=argument0;for(i=1;i<=n;i++){t=i;if i>2t=(i-2)*3+1show_message(t)}

source: Stack Exchange

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

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

sort: votes


text:
Automated Bulls and Cows Player
This is a code golf challenge to see the shortest implementation of an automated guesser in the pen and paper game bulls and cows.
The game works as follows:
A (usually 4 digit) secret code with only distinct integers 0-9 is picked by one player. A second player guesses codes that each receive a rank. This rank contains 1 bull for every digit that is correctly placed in the guess, and 1 cow for every digit in the guess that is in the secret code, but not in the correct location within the code.
The code should assume a format as follows:

The combination will be a 4 digit number containing only distinct digits 0-9. (eg. 0123 is valid, 0112 is not)
After each guess, you will be given a string as a response telling you how many bulls and how many cows are in your answer.  It will be formatted as xByC, in which x is the number of bulls and y is the number of cows. (i.e. 4B0C means you have won). You can assume that a made-up method called "rateGuess", which takes your guess as a string will provide the response.

I will edit the question to contain the game rules. This is the game that was the basis for mastermind, but the questions are different. The question you linked to asks you to rank the guesses, while this question asks you to guess the code assuming a given ranking method.

Okay, so you want us to write a Mastermind solver. In that case, the question is, how good does it have to be? Does it have to play optimally? And I think we've had several Mastermind-solving questions as well. There's this for code golf and this for a code challenge.

I hadn't seen any mastermind solver questions, but that could be because I am used to referring to the game as bulls and cows, and I didn't see any results for that name. The only criteria that the answer is ranked by in this case will be size of implementation.

But if you don't require optimal play, I could just submit random guesses. There's got to be some (objective) criterion for how well it should perform if you want to make this a code golf.

Pyth - 11 bytes
This will eventually guess the correct answer. On average 2500 tries. Literally just takes random guesses no matter what the input is. Since you can't define rateGuess in pyth just takes (uneeded) input from stdin and outputs to stdout.
Ofql{T4^UT4

O         Pick random
 f        filter
  ql{T4   set length is four (checks for duplicates)
  ^  4    Caretesian product with 4 repeats
   UT     Unary range till 10

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


text:
Binary encryption
This is based on xkcd #153.
Make a program or named function which takes 2 parameters, each of which is a string or a list or array of bytes or characters. The second parameter will only contain characters drawn from lrfu (or the equivalent ASCII bytes). It should be interpreted as a series of instructions to be performed on a bit sequence represented by the first parameter.
The processing performed must be equivalent to the following:

Convert the first parameter into a single bitstring formed by concatenating the bits of each character (interpreted as one of 7-bit ASCII, an 8-bit extended ASCII, or a standard Unicode encoding). E.g. if the first parameter is "AB" then this would be one of 10000011000010 (7-bit), 0100000101000010 (8-bit or UTF-8), 00000000010000010000000001000010, or 01000001000000000100001000000000 (UTF-16 in the two endiannesses), etc.
For each character in the second parameter, in order, execute the corresponding instruction:

l rotates the bitstring left one. E.g. 10000011000010 becomes 00000110000101.
r rotates the bitstring right one. E.g. 10000011000010 becomes 01000001100001.
f flips (or inverts) each bit in the bitstring. E.g. 10000011000010 becomes 01111100111101.
u reverses the bitstring. E.g. 10000011000010 becomes 01000011000001.

Convert the bitstring into an ASCII string which uses one character per bit. E.g. 10000011000010 becomes "10000011000010". This is because not all sets of 7/8 bits have a character assigned to them.

Example (in Python):
>>> f("b", "rfu")
01110011

It turns "b" into its 8-bit ASCII binary representation 01100010, rotates it right (00110001), flips each bit (11001110), and reverses it (01110011).
Flexibility
Other characters may be used instead of the characters l, r, f, and u, but they must be clearly documented.
Scoreboard
Thanks to @Optimizer for creating the following code snippet. To use, click "Show code snippet", scroll to the bottom and click "► Run code snippet".

var QUESTION_ID = 45087; var answers = [], page = 1;var SCORE_REG = /\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/;function url(index) {return "http://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=votes&site=codegolf&filter=!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";}function getAnswers() {$.ajax({url: url(page++),method: "get",dataType: "jsonp",crossDomain: true,success: function (data) {answers.push.apply(answers, data.items);if (data.has_more) getAnswers();else process()}});}getAnswers();function shouldHaveHeading(a) {var pass = false;try {pass |= /^(#|<h).*/.test(a.body_markdown);pass |= ["-", "="].indexOf(a.body_markdown.split("\n")[1][0]) > -1;} catch (ex) {}return pass;}function shouldHaveScore(a) {var pass = false;try {pass |= SCORE_REG.test(a.body_markdown.split("\n")[0]);} catch (ex) {}return pass;}function getRelDate(previous) {var current = Date.now();var msPerMinute = 60 * 1000;var msPerHour = msPerMinute * 60;var msPerDay = msPerHour * 24;var msPerMonth = msPerDay * 30;var msPerYear = msPerDay * 365;var elapsed = current - previous;if (elapsed < msPerMinute) {return Math.round(elapsed/1000) + ' seconds ago';}if (elapsed < msPerHour) {return Math.round(elapsed/msPerMinute) + ' minutes ago';}if (elapsed < msPerDay ) {return Math.round(elapsed/msPerHour ) + ' hours ago';}if (elapsed < msPerMonth) {return 'approx. ' + Math.round(elapsed/msPerDay) + ' days ago';}if (elapsed < msPerYear) {return 'approx. ' + Math.round(elapsed/msPerMonth) + ' months ago';}return 'approx. ' + Math.round(elapsed/msPerYear ) + ' years ago';}function process() {answers = answers.filter(shouldHaveHeading);answers = answers.filter(shouldHaveScore);answers.sort(function (a, b) {var aB = +(a.body_markdown.split("\n")[0].match(SCORE_REG) || [Infinity])[0],bB = +(b.body_markdown.split("\n")[0].match(SCORE_REG) || [Infinity])[0];return aB - bB});answers.forEach(function (a) {var answer = $("#answer-template").html();answer = answer.replace("{{BODY}}", a.body).replace("{{NAME}}", a.owner.display_name).replace("{{REP}}", a.owner.reputation).replace("{{VOTES}}", a.score).replace("{{DATE}}", new Date(a.creation_date*1e3).toUTCString()).replace("{{REL_TIME}}", getRelDate(a.creation_date*1e3)).replace("{{POST_LINK}}", a.share_link).replace(/{{USER_LINK}}/g, a.owner.link).replace('{{img}}=""', "src=\"" + a.owner.profile_image + '"');answer = $(answer);if (a.is_accepted) {answer.find(".vote-accepted-on").removeAttr("style");}$("#answers").append(answer);});}
body { text-align: left !important}
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

{{VOTES}}accepted

{{BODY}}

share

answered {{REL_TIME}}

{{NAME}}
{{REP}}

What can the second parameter be? Can it be "rrfrburb"? Also, when one shifts or reverses bits, does one do it for each individual letter, or the string as a whole? More test cases would make it clearer.

Do you mean shift or rotate? a leftshift in C will result in the leftmost bit being lost and the rightmost bit becoming zero. For a rightshift on an unsigned number the reverse happens. For a signed number I'm not sure if there is a universally defined behaviour for what gets shifted in for negative numbers (is it 0 or 1?) Either way, information is always lost when a shift is carried out, which isnt the case for a rotate.

FWIW there's already one question based on that XKCD.

@PeterTaylor Time to intruce an xkcd-tag?

@flawr, I don't think it would have any advantage over the existing ability to search for 'xkcd'

I've rewritten to be more compact, essentially by inlining the clarifications but also by adding some more (e.g. "Unicode" isn't an encoding). Please check that you don't think I've introduced any substantive changes.

@PeterTaylor You've written it correctly. I don't think it adding anything substantial enough to change anything except clarity is better.

Does the exact I/O format matter? For example, would an output of ['0', '1', '1', '1', '0', '0', '1'] be okay?

@KSFT I think I'm going to have to say no to that. Make it a string by joining it.

Wait, so there will be 4 differant answers depending on the input interpretaion right?

@Maltysen The question lists possible interpretations. You should use whatever makes your code shortest.

Please word your spec more carefully. Your question says that other letters may be used for instructions, but you accepted an answer that uses digits. Did you mean "characters" instead of "letters"?

@MartinBüttner Yes. I accepted it as it was the shortest. I've changed that now, and will make sure to not make that mistake again.

@Reticality Fair enough, I updated my answer accordingly (which is now the shortest).

CJam, 34 32 bytes
1l+256b2b1>l{~"11W:mm%!<>">4%~}/

It uses the following characters for instructions:
0: left rotation
1: right rotation
2: reverse
3: flip

The input is taking from STDIN with the word on the first line and the instruction string on the second line.
Test it here.
Explanation
Getting the bit string is really just a matter of interpreting the character codes as the digits of a base-256 number (and getting its base-2 representation). The tricky thing is that the latter base conversion won't pad the result with 0s on the left. Therefore, I add a leading 1 to the initial input, and then split off that 1 again in the binary representation. As an example, if the input is ab, I turn that into an array [1 'a 'b], interpret that as base-256 (characters are automatically converted to character codes), which is 90466 and the to base-2, which is [1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0]. Now if I just remove that leading 1 I've got the bitstream I'm looking for.
That's what this part of the code does:
1l+256b2b1>

Now I read the list of instructions and execute a block for each character in the instruction string:
l{...}/

The first thing to do is to evaluate the character and actual integers0, 1, 2 or 3. Now the real golfy magic... depending on the instruction I want to run a short piece of code that implements the operation:
Integer:  Code  Operation
0         1m<   "Left rotation";
1         1m>   "Right rotation";
2         W%    "Reverse";
3         :!    "Flip each bit";

I could store these in an array of blocks and choose the right block to run, but encoding them in a string is actually shorter:
"11W:mm%!<>">4%~

First, I use the integer associate with the instruction to slice off the beginning of the string. So for left rotation, the string is unchanged, for right rotation the first character is discarded and so on. Then I select every fourth character from the string, starting from the first, with 4%. Notice how the four code snippets are distributed throughout the string. Finally I just evaluate the string as code with ~.
The bit string is printed automatically at the end of the program.

Why 1m< rather than (+? You're working on an array rather than a number, aren't you?

@Peter oh right, thanks. I'll fix that later.

CJam, 34 bytes
Another approach in CJam.
1l+256b2b1>l_S/,1&@f=_,,@f{W%~}\f=

The input text is on the first line and the instructions are on the second line.
Instructions:
)        Rotate left.
(        Rotate right.
 (space) Flip.
~        Reverse.

This is pretty clever. A shame that f~ isn't implemented though, isn't it? ;)

Pyth 33
jku@[+eGPG+tGhG_Gms!dG)sHwsmjCk2z

Uses:
0    : rotate right
1    : rotate left
2    : reverse order
3    : flip values

Pyth github
Try it online here.
This is a program that takes the string as it's first argument and the string of commands as the second argument. In the online version, you should give the strings separated by a newline, like so:
AbC
0321

Explanation:
                                    : z=input() (implicit)
jk                                  : join("", ...)
  u@[                 )sHw          : reduce(select from [...] the value at int(H), input(), ...)
     +eGPG                          : [ G[-1] + G[:1],
          +tGhG                     : G[1:] + G[1],
               _G                   : G[::-1],
                 ms!dG              : map(lambda d: int(not(d)), G) ]
                          smjCk2z   : first arg = sum(map(lambda k:convert_to_base(ord(k),2),z)

Something I couldn't quite squeeze in: Pyth's reduce automatically uses G for the previous value, and H for the next value.

Loosing your touch ? Just 1 byte shorter than CJam ?

@Optimizer Actually, I can beat that by using the same instructions. But I didn't think this would be valid because the challenge says "Other letters may be used instead of lrfu, but they must be clearly documented." (emphasis mine)

Matlab (166 bytes)
This uses letters abcd instead of lrfu respectively.
function D=f(B,C)
D=dec2bin(B,8)';
D=D(:);
g=@circshift;
for c=C
switch c-97
case 0
D=g(D,-1);
case 1
D=g(D,1);
case 2
D=char(97-D);
case 3
D=flipud(D);
end
end
D=D';

Some tricks used here to save space:

Using abcd letters lets me subtract 97 once, and then the letters become 0, 1, 2, 3. This saves space in the switch-case clauses.
Defining circshift as a one-letter anonymous function also saves space, as it's used twice.
Since D consists of '0' and '1' characters (ASCII codes 48 and 49),  the statement D=char(97-D) corresponds to inversion between '0' and '1' values. Note that this 97 has nothing to do with that referred to above.
Complex-conjugate transpose ' is used instead of transpose .'.

Scala - 192
def f(i:String,l:String)=(i.flatMap(_.toBinaryString).map(_.toInt-48)/:l){
case(b,'l')⇒b.tail:+b.head
case(b,'r')⇒b.last+:b.init
case(b,'f')⇒b.map(1-_)
case(b,'u')⇒b.reverse}.mkString

Python 2, 142
j="".join
f=lambda S,I:reduce(lambda s,i:[s[1:]+s[0],s[-1]+s[:-1],s[::-1],j([`1^int(c)`for c in s])][int(i)],I,j([bin(ord(c))[2:]for c in S]))

Similar to my pyth answer in approach: I build a list of all the strings and index into it based on the value of the instruction string that I iterate over using reduce.
Uses:
0  ->  Rotate left
1  ->  Rotate right
2  ->  Reverse order
3  ->  Invert bits

Python 2 - 179
b="".join([bin(ord(i))[2:]for i in input()])
for i in input():b=b[-1]+b[:-1]if i=="r"else b[1:]+b[0]if i=="l"else[str("10".find(j))for j in b]if i=="f"else b[::-1]
print"".join(b)

C#, 418 bytes
using System;using System.Collections.Generic;using System.Linq;class P{string F(string a,string o){var f=new Dictionary<char,Func<string,IEnumerable<char>>>{{'l',s=>s.Substring(1)+s[0]},{'r',s=>s[s.Length-1]+s.Substring(0,s.Length-1)},{'u',s=>s.Reverse()},{'f',s=>s.Select(c=>(char)(97-c))}};return o.Aggregate(string.Join("",a.Select(c=>Convert.ToString(c,2).PadLeft(8,'0'))),(r,c)=>new string(f[c](r).ToArray()));}}

Formatted:
using System;
using System.Collections.Generic;
using System.Linq;

class P
{
    string F(string a, string o)
    {
        // define string operations
        var f = new Dictionary<char, Func<string, IEnumerable<char>>>
        {
            {'l', s => s.Substring(1) + s[0]},
            {'r', s => s[s.Length - 1] + s.Substring(0, s.Length - 1)},
            {'u', s => s.Reverse()},
            {'f', s => s.Select(c => (char) (97 - c))}
        };
        // for each operation invoke f[?]; start from converted a
        return o.Aggregate(
            // convert each char to binary string, pad left to 8 bytes and join them
            string.Join("", a.Select(c => Convert.ToString(c, 2).PadLeft(8, '0'))),
            // invoke f[c] on result of prev operation
            (r, c) => new string(f[c](r).ToArray())
        );
    }
}

JavaScript (E6), 163 167
Fully using the input flexibility, a named function with 2 array parameters.

First parameter, array of bytes corresponding to 7 bit character codes
Second parameter, array of bytes corresponding to ascii characters 'F','L','R','U' --> 70, 76, 82, 85

The function returns a character string composed of '1' and '0'
F=(a,s,r='')=>
  a.map(c=>r+=(128|c).toString(2).slice(-7))-
  s.map(c=>a=c<71?a.map(c=>1-c):c<77?a.concat(a.shift):c<83?[a.pop(),...a]:a.reverse(),a=[...r])
  ||a.join('')

Example f("b", "rfu") translate to F([98],[82,70,85]), result is 0111001
Note using character strings is so much longer in javascript! Byte count 186
F=(a,s,r='')=>
  [for(c of a)r+=(128|c.charCodeAt()).toString(2).slice(-7)]-
  [for(c of(a=[...r],s))a=c<'G'?a.map(c=>1-c):c<'M'?a.concat(a.shift):c<'S'?[a.pop(),...a]:a.reverse()]
  ||a.join('')

Example F("b", "RFU"), result is 0111001 again

J, 164
([: >@:}. (([: }. >&{.) ; >@:{.@:>@:{. 128!:2 >@:}.)^:({.@:$@:>@:{.))@:(>@:((<;._1 ' 1&|."1 _1&|."1 -. |."1') {~ 'lrfu' i. 0&({::)@:]) ; ;@:([: (8$2)&#: a. i. 1&({::)))

Formatted:
nextop=:([: }. >&{.)
exec=: (>@:{.@:>@:{.) apply"1 >@:}.
times=: ({.@:$@:>@:{.)
gapply=: [: >@:}. (nextop ; exec)^:(times) f.

tobin=: ;@:([: (8#2)&#:(a.i.1&{::))
g=:'1&|.';'_1&|.';'-.';'|.'
tog =:  g {~ ('lrfu' i. 0&{::@:])
golf=: gapply @: (>@:tog;tobin)  f.

Example
golf ('rfu';'b')
0 1 1 1 0 0 1 1

golf ('lruuff';'b')
0 1 1 0 0 0 1 0

(8#2)#: 98
0 1 1 0 0 0 1 0

golf ('lruuff';'AB')
0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0

tobin '';'AB'
0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0

Ruby, 151
f=->i,s{s.chars.inject(i.unpack("B*")[0]){|a,c|
a.reverse! if c==?u
a.tr!"01","10" if c==?f
a<<a.slice!(1..-1) if c==?l
a<<a.slice!(0..-2) if c==?r
a}}

Fairly straightforward. Loops trough the characters in s and performs an action for any of them.


text:
Rise and Shine!
Challenge
The challenge is to create a program which takes a date, a latitude, and a longitude, and prints the time of the sunrise on that date for the given location.
The program must work for any valid date between January 1, 2000, and December 31, 2999.
Internal and external sunrise functions are disallowed. Date libraries are allowed only to format the output into ISO 8601, and to determine the local time from utc
Clarifications

You do not need to take into account altitude or the refraction of light from the sun.
Date input and output must be in correct ISO8601 format
The date, latitude, and longitude will be given as a space separated string, in that order, on stdin
Printing a value means outputting to stdout
The output should have a precision of +/- 1 minute
The time outputted must be in the local time of the location specified, and include the local time zone offset
Bonus

Score * 0.1 if you do not use a date library at all

Resources

http://en.wikipedia.org/wiki/Sunrise_equation
http://www.esrl.noaa.gov/gmd/grad/solcalc/solareqns.PDF

Test Cases
Input                                        Output
41.8376 -87.6818 2265-03-19                  2265-03-19T06:05-06:00
40.6643 -73.9385 2265-03-06                  2265-03-06T06:31-05:00
43.65 -79.38 2265-03-14                      2265-03-14T06:41-05:00
41.8376 -87.6818 2265-03-05                  2265-03-05T06:28-06:00
43.65 -79.38 2265-02-19                      2265-02-19T07:19-05:00
43.65 -79.38 2265-02-06                      2265-02-06T07:37-05:00
41.8376 -87.6818 2265-02-14                  2265-02-14T06:57-06:00
41.8376 -87.6818 2265-02-05                  2265-02-05T07:08-06:00
43.65 -79.38 2265-10-19                      2265-10-19T06:47-05:00
40.6643 -73.9385 2265-10-06                  2265-10-06T06:07-05:00
40.6643 -73.9385 2265-10-14                  2265-10-14T06:16-05:00
40.6643 -73.9385 2265-10-05                  2265-10-05T06:06-05:00
43.65 -79.38 2265-05-19                      2265-05-19T04:58-05:00
43.65 -79.38 2265-05-06                      2265-05-06T05:13-05:00
40.6643 -73.9385 2265-05-14                  2265-05-14T04:50-05:00
43.65 -79.38 2265-05-05                      2265-05-05T05:14-05:00
41.8376 -87.6818 2265-08-19                  2265-08-19T05:14-06:00
43.65 -79.38 2265-08-06                      2265-08-06T05:23-05:00
43.65 -79.38 2265-08-14                      2265-08-14T05:32-05:00
41.8376 -87.6818 2265-08-05                  2265-08-05T04:59-06:00
41.8376 -87.6818 2400-03-19                  2400-03-19T06:12-06:00
43.65 -79.38 2400-03-06                      2400-03-06T07:01-05:00
43.65 -79.38 2400-03-14                      2400-03-14T06:47-05:00
40.6643 -73.9385 2400-03-05                  2400-03-05T06:39-05:00
40.6643 -73.9385 2400-02-19                  2400-02-19T07:01-05:00
40.6643 -73.9385 2400-02-06                  2400-02-06T07:17-05:00
40.6643 -73.9385 2400-02-14                  2400-02-14T07:08-05:00
43.65 -79.38 2400-02-05                      2400-02-05T07:46-05:00
43.65 -79.38 2400-10-19                      2400-10-19T06:54-05:00
41.8376 -87.6818 2400-10-06                  2400-10-06T06:11-06:00
40.6643 -73.9385 2400-10-14                  2400-10-14T06:23-05:00
43.65 -79.38 2400-10-05                      2400-10-05T06:38-05:00
43.65 -79.38 2400-05-19                      2400-05-19T05:06-05:00
41.8376 -87.6818 2400-05-06                  2400-05-06T04:58-06:00
40.6643 -73.9385 2400-05-14                  2400-05-14T04:57-05:00
41.8376 -87.6818 2400-05-05                  2400-05-05T04:59-06:00
40.6643 -73.9385 2400-08-19                  2400-08-19T05:29-05:00
40.6643 -73.9385 2400-08-06                  2400-08-06T05:16-05:00
43.65 -79.38 2400-08-14                      2400-08-14T05:40-05:00
41.8376 -87.6818 2400-08-05                  2400-08-05T05:07-06:00
41.8376 -87.6818 2733-03-19                  2733-03-19T06:39-06:00
41.8376 -87.6818 2733-03-06                  2733-03-06T07:01-06:00
43.65 -79.38 2733-03-14                      2733-03-14T07:15-05:00
43.65 -79.38 2733-03-05                      2733-03-05T07:30-05:00
40.6643 -73.9385 2733-02-19                  2733-02-19T07:27-05:00
40.6643 -73.9385 2733-02-06                  2733-02-06T07:43-05:00
41.8376 -87.6818 2733-02-14                  2733-02-14T07:30-06:00
40.6643 -73.9385 2733-02-05                  2733-02-05T07:44-05:00
40.6643 -73.9385 2733-10-19                  2733-10-19T06:55-05:00
41.8376 -87.6818 2733-10-06                  2733-10-06T06:37-06:00
41.8376 -87.6818 2733-10-14                  2733-10-14T06:46-06:00
43.65 -79.38 2733-10-05                      2733-10-05T07:04-05:00
41.8376 -87.6818 2733-05-19                  2733-05-19T05:12-06:00
40.6643 -73.9385 2733-05-06                  2733-05-06T05:33-05:00
40.6643 -73.9385 2733-05-14                  2733-05-14T05:25-05:00
43.65 -79.38 2733-05-05                      2733-05-05T05:49-05:00
40.6643 -73.9385 2733-08-19                  2733-08-19T05:55-05:00
41.8376 -87.6818 2733-08-06                  2733-08-06T05:35-06:00
41.8376 -87.6818 2733-08-14                  2733-08-14T05:43-06:00
40.6643 -73.9385 2733-08-05                  2733-08-05T05:42-05:00
40.6643 -73.9385 2455-03-19                  2455-03-19T06:21-05:00
40.6643 -73.9385 2455-03-06                  2455-03-06T06:42-05:00
41.8376 -87.6818 2455-03-14                  2455-03-14T06:24-06:00
40.6643 -73.9385 2455-03-05                  2455-03-05T06:43-05:00
43.65 -79.38 2455-02-19                      2455-02-19T07:30-05:00
40.6643 -73.9385 2455-02-06                  2455-02-06T07:20-05:00
40.6643 -73.9385 2455-02-14                  2455-02-14T07:11-05:00
40.6643 -73.9385 2455-02-05                  2455-02-05T07:21-05:00
40.6643 -73.9385 2455-10-19                  2455-10-19T06:32-05:00
41.8376 -87.6818 2455-10-06                  2455-10-06T06:14-06:00
40.6643 -73.9385 2455-10-14                  2455-10-14T06:27-05:00
41.8376 -87.6818 2455-10-05                  2455-10-05T06:13-06:00
41.8376 -87.6818 2455-05-19                  2455-05-19T04:48-06:00
43.65 -79.38 2455-05-06                      2455-05-06T05:24-05:00
40.6643 -73.9385 2455-05-14                  2455-05-14T05:01-05:00
41.8376 -87.6818 2455-05-05                  2455-05-05T05:03-06:00
41.8376 -87.6818 2455-08-19                  2455-08-19T05:25-06:00
41.8376 -87.6818 2455-08-06                  2455-08-06T05:12-06:00
43.65 -79.38 2455-08-14                      2455-08-14T05:43-05:00
43.65 -79.38 2455-08-05                      2455-08-05T05:33-05:00
41.8376 -87.6818 2015-03-19                  2015-03-19T05:57-06:00
40.6643 -73.9385 2015-03-06                  2015-03-06T06:23-05:00
41.8376 -87.6818 2015-03-14                  2015-03-14T06:06-06:00
43.65 -79.38 2015-03-05                      2015-03-05T06:49-05:00
41.8376 -87.6818 2015-02-19                  2015-02-19T06:42-06:00
43.65 -79.38 2015-02-06                      2015-02-06T07:30-05:00
41.8376 -87.6818 2015-02-14                  2015-02-14T06:49-06:00
40.6643 -73.9385 2015-02-05                  2015-02-05T07:03-05:00
40.6643 -73.9385 2015-10-19                  2015-10-19T06:12-05:00
40.6643 -73.9385 2015-10-06                  2015-10-06T05:58-05:00
41.8376 -87.6818 2015-10-14                  2015-10-14T06:03-06:00
41.8376 -87.6818 2015-10-05                  2015-10-05T05:53-06:00
40.6643 -73.9385 2015-05-19                  2015-05-19T04:37-05:00
41.8376 -87.6818 2015-05-06                  2015-05-06T04:42-06:00
40.6643 -73.9385 2015-05-14                  2015-05-14T04:41-05:00
40.6643 -73.9385 2015-05-05                  2015-05-05T04:51-05:00
41.8376 -87.6818 2015-08-19                  2015-08-19T05:04-06:00
43.65 -79.38 2015-08-06                      2015-08-06T05:13-05:00
43.65 -79.38 2015-08-14                      2015-08-14T05:22-05:00
43.65 -79.38 2015-08-05                      2015-08-05T05:12-05:00

This is code-golf, so least bytes wins.

Highly related (possible duplicate?): http://codegolf.stackexchange.com/q/16209/3808

@Doorknob Wasn't aware of it, but that is extremely similar. Is it too much so to keep the question up? (I assume yes)

I don't think it's feasible to golf the local time zone without a date library.

@KennyTM well spotted that's a huge issue, for example crossing the border from China to Pakistan the official time changes by 3 hours. Globby, do you want official time or "longitude-correct" time?

The second website you linked has several different values for the "zenith", one of the inputs. Which one should we use?

@KennyTM removed from the question

@KSFT use the official

Which one do you consider "official"?

@KSFT 90.833 degrees


text:
Printing a "Hello World" one-liner in bourne shell without directly using white space char
I'm currently trying to solve a tricky/silly challenge and i've come to a dead end.
The challenge is basically to form a one-liner /bin/sh compatible command line
which essentially outputs "Hello World" without directly typing White space or Tab characters in the command itself.
for example something like -
echo Hello World

would be invalid since we used white space twice in the command line.
Any ideas?

Welcome to PPCG! While this is probably a rare case which justifies a language-specific challenge (as it's trivial in many languages but particularly hard in sh), all challenges here need an objective winning criterion. If you get multiple correct answers, which one is the best?

The most you can do is to use newlines between command and parameters: http://pastebin.com/DU5Gyde7 But this is not POSIX sh anymore.

@MartinBüttner, are you sure about the [tag:bash] tag? The question explicitly asks for “/bin/sh compatible”.

@manatwork Whoops, good point. Changed to a new [tag:sh].

One which works in dash, so I suppose it is sh compatible;
IFS=@;command=echo@Hello@World;$command

Yup@this@one@works!@great!

Or simply echo${IFS}Hello${IFS}World

Yup, $IFS tricks are good.  Here's another way for bash (but not Posix sh): a=({Hello,world});cat<<<${a[@]}

@DigitalTrauma, actually {echo,Hello,world} is enough in bash and ksh.

@manatwork Thats brilliant!


text:
Magnetic Sculptures... in Space!
Background
This is a continuation of my earlier challenge, where the task was to compute the shape of a sculpture obtained by dropping magnets into a huge pile.
Good news: the eccentric artist liked your work, and has another project for you. He still works with magnetic sculptures, but has decided to expand his art studio -- into space! His current method is to blast a single cube-shaped magnet into the orbit, and shoot other magnets at it to create a huge magnetic satellite.
Input
Your input is a finite list of 0s and 1s, given either in the native list format of your language, or a string. It is interpreted as a "blueprint" of a work of art, and is processed in order from left to right as follows.
You start with a single magnet floating at some integer coordinate of the 2D plane, and keep adding more magnets as per the directives. The directive 0 rotates the entire sculpture 90 degrees in the counter-clockwise direction. In the case of the directive 1, the artist finds the leftmost column of the sculpture, and shoots a new magnet to it from below. The new magnet sticks to the bottom-most existing magnet in the column, and becomes a part of the sculpture. Note that the magnet does not stick to other magnets in the neighboring column, unlike in the earlier challenge; its speed is now astronomical!
Output
The artist wants to know whether the complete sculpture will fit into his garage (how he'll get it down from the orbit remains unclear). Thus, your output is the width and height of the sculpture, ordered from lower to higher. They can be given as a two-element list, a pair, or as a string separated by a comma.
Example
Consider the input sequence
[1,0,1,1,0,1,0,0,1,1]

To process it, we start with one magnet floating in space:
#

The first directive is 1, so we shoot a new magnet from below:
#
#

The next directive is 0, so we rotate the sculpture:
##

The next two directives are 1,1, which means we'll shoot two magnets to the leftmost column:
##
#
#

Then, we rotate again and shoot once, as directed by 0,1:
#
###
#

Finally, we rotate twice and shoot twice:
  #
###
# #
#

The resulting sculpture has width 3 and height 4, so we output [3,4].
Rules
You can give either a function or a full program. The lowest byte count wins, and standard loopholes are disallowed.
Test Cases
[1,0,1] -> [2,2]
[1,0,1,1,0,1,0,0,1,1] -> [3,4]
[1,1,0,1,1,0,1,0,1,1] -> [4,5]
[1,1,0,1,1,0,1,0,1,1,0] -> [4,5]
[1,0,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1] -> [3,3]
[0,1,0,1,1,1,1,0,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,0,0,0,1,0,1,0,1,1,0,0,1,1] -> [5,7]
[1,0,1,1,1,1,0,1,0,0,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,0,0,1,1,0,1,0,1,1,1,1,0,1,1,0,0,1,1,1,1,0,0,0,0,1,1,0,0,1,1,0,1,0,0,1,1,0,1,1,0,0,1,0,1,0,0,1,0,1,1,1,0,1,1,0,0,1,0,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0] -> [11,12]

Shouldn't [1,1,0,1,1,0,1,0,1,1,0] return [5,4] and not [4,5]? The sculpture is rotated at the end.

@algorithmshark I made the same mistake. The Output section specifies that the result should be ordered.

@MartinBüttner is right. The justification is that orientation does not matter when you're in space. :P

Pyth: 34 33 bytes
Sml{dCuS?+G,hhGtehGHm,_ekhkGQ],ZZ

Input is a list of ones and zeros, like in the question. Try it online: Pyth Compiler/Executor
Explanation:
It's a one-on-one translation of the following Python 2 code (126 bytes).
print sorted(map(len,map(set,zip(*reduce(lambda s,i:([[-b,a]for a,b in s],s+[[min(s)[0],min(s)[1]-1]])[i],input(),[[0,0]])))))

I create a list of coordinates of the single magnets. This is initialized with the magnet [0,0]. Then for each of the integers of the blueprint I manipulate the list in the following way. If the next integer is 0, I rotate the sculpture by changing the coordinates for each magnet [a,b] to [-b,a] (basically multiplying with a rotation matrix). If the next integer is a 1, I search for the minimal piece [a,b] (which is automatically the lowest magnet of the leftmost column) and append the magnet [a,b-1] to the list.
After all the input is processed, I create 2 sets (for removing duplicates), one for the x-values and one for the y values, and print the sizes of them in sorted order.
Sml{dCuS?+G,hhGtehGHm,_ekhkGQ],ZZ
                             ],ZZ  starting list G=[(0,0)]
      u                     Q],ZZ  for H in input(): manipulate G
       S                              Sort G after each manipulation
        ?          H                  G = ... if H==1 else ...
                    m,_ekhkG            [(-b,a) for a,b in G)] (rotate)
         +G,hhGtehG                     G+[(G[0][0],G[0][1]-1)]
                                        (G[0] is the lowest magnet in the leftmost column)
     C                             Zip the coords together
                                    (creates 2 lists, x- and y-coords)
 ml{d                              for each of those list compute number of unique values
S                                  sort and print

An idea for improvement: Using complex numbers as coords for the magnets. A rotation is just a multiplication by j and subtracting j from the lowest magnet in the leftmost column. Sadly finding this lowest leftmost magnet takes way too many chars in Python, not even talking of finding the rectangle.

CJam, 48 bytes
S]l~{{)S/);Sa+S*a+_z,f{_N*@\+<}}{zW%}?}/_,\z,]$p

Test it here.
Expects input as a CJam-style array (i.e. spaces instead of commas) and will present the output similarly. If you want to use the test cases from the question directly, copy them straight into the input field (include the -> and results) and use this test harness, which converts the lines to the correct input format (and discards the results):
qN/{S/0=","Ser}%{[

S]\~{{)S/);Sa+S*a+_z,f{_N*@\+<}}{zW%}?}/_,\z,]$p

}/

Explanation
I'm just implementing the rules very literally. I'm keeping a grid with the current sculpture (as an array of strings), and then for each instruction I either rotate the grid, or I add a new block. The main tricks to save bytes are:

Add to the bottom row from the right. This is completely equivalent. I'm just one rotation ahead, and since the grid starts out rotationally invariant, that doesn't matter.
Use a space to represent occupied blocks and a newline character to represent empty blocks. So if you actually printed out the grid you wouldn't see a whole lot and it wouldn't even look rectangular. I'm doing this, because most array-based operators only do what you want if the grid element in question is wrapped in an array. And with S and N I have access to strings containing the space and newline character (i.e. the character wrapped in an array), instead of having to use, say, 1a and 0a to get an array containing a number.

Let's go through the code:
"Overall program structure:";
S]l~{{...}{...}?}/_,\z,]$p
S]                         "Push a string with a space and wrap it in an array.
                            This is the initial grid containing a single block.";
  l~                       "Read the input and evaluate it.";
    {           }/         "For each instruction in the input...";
     {...}{...}?           "Execute the first block if it's 1, the second if it's 0.";
                  _,       "Duplicate the resulting grid and get its length. This
                            is one of the dimensions.";
                    \      "Swap with the other copy of the grid.";
                     z,    "Zip/transpose it and get its length. This is the other
                            dimension of the grid.";
                       ]$p "Wrap both in an array, sort them, and print the result.";

"The rotation block is simple. A rotation is equivalent to two reflection operations
 along different axes. The simplest ones available are to transpose the grid (which
 is a reflection about the diagonal) and reversing the rows (which is a reflection
 about the horizontal). In CJam these are z for zip/tranpose and W% for reversing
 an array. So I simply put these together in the right order to get a counter-
 clockwise rotation:";
zW%

"Now the interesting part, adding new blocks and growing the grid. This part consists
 of two steps: appending a block to the rightmost block in the bottom row (allowing
 for empty blocks after it). And then potentially padding the rest of the grid with
 new empty cells if the bottom row got longer.";
)S/);Sa+S*a+_z,f{_N*@\+<}
)                         "Split off the bottom row.";
 S/                       "Split the row on occupied blocks.";
   );                     "Split off the final substring - this discards trailing
                           empty cells.";
     Sa+                  "Add a new substring containing an occupied block to the row.";
        S*                "Join all substrings together with spaces, putting back in
                           all the occupied blocks.";
          a+              "Wrap it in an array to add the row back onto the grid.";

 "At this point we need to make sure the grid is still rectangular. The easiest way
  (I found) is to find the maximum row length, add that many empty blocks to each
  line and then truncate the lines to that length.";

            _             "Duplicate the grid.";
             z,           "Zip/transpose it and get the length. This is the length
                           of the longest row in a ragged array.";
               f{       } "Map this block onto each row, passing in the target length.";
                 _N*      "Duplicate the target length and get a string of that many
                           empty cells.";
                    @\    "Pull up the row and then swap it with those empty cells.";
                      +   "Add the empty cells to the end of the row.";
                       <  "Truncate to the target length.";

No idea how this works, but it does!

@LuisMendo Added an explanation. If something is unclear and you're interested, feel free to drop me another comment. ;)

I've no idea about CJam, and it doesn't seem to be an easy language precisely. You had my +1 already :-)

Matlab (92)
S=1;for d=input(''),if d,S(find(S(:,1),1,'last')+1,1)=1;else,S=rot90(S);end;end,sort(size(S))

Standard input is used. Data should be introduced in the form [1,0,1,1,0,1,0,0,1,1].
Ungolfed:
S = 1; %// initial magnet
for d = input('') %// get directives, and pick them sequentially
    if d %// if directive is 1
        S(find(S(:,1),1,'last')+1,1) = 1; %// add 1 after lowest 1 in column 1. Grow if needed
    else %// if directive is 0
        S = rot90(S); %// rotate counterclockwise. Handy Matlab built-in function
    end
end
sort(size(S)) %// display size sorted

Example run:
>> clear all
>> S=1;for d=input(''),if d,S(find(S(:,1),1,'last')+1,1)=1;else,S=rot90(S);end;end,sort(size(S))
[1,0,1,1,0,1,0,0,1,1]
ans =
     3     4

Python - 211
import numpy as n
p=input()
q=len(p)
a=n.zeros([2*q+1]*2)
a[q,q]=1
for i in p:
 if i:x=a[:,n.where(a.any(0))[0][0]];x[len(x)-n.where(x[::-1])[0][0]+1]=1
 else:a=n.rot90(a)
z=a[:,a.any(1)]
print z[a.any(0)].shape

The output should be sorted from from lower to higher!
Also your program breaks for the input [1].

CJam, 47 bytes
1]]q~{{0f+(W%_1#(1tW%a\+z{1b},}{W%}?z}/),\,)]$p

This takes CJam styled (space separated instead of comma) array input from STDIN and prints the result to STDOUT.
Example:
[1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1]

gives
[3 3]

output.
Explanation to follow after I am convinced that this cannot be golfed further.
Try it online here


text:
KOTH: Number fight
Number fight game

Setup

Each ai is given a random number from 1 to 100. The starting number is the average of these two numbers.

Gameplay

Each ai knowing its own target, the opposite target and the current number, chooses which function to apply to the current number.

WIN conditions

The first ai that reaches its number wins.

Scoring details

The score is given in a tournament: each ai will fight all the other ais and it will get a score equal to the average of the points scored against the opponents.

The controller script is limited to Python-only functions, but if you can provide a controller that allows other languages your are welcome.
Controller script for reference:
import random

def increment(a): return a + 1
def decrement(a): return a - 1
def double(a)   : return 2 * a
def halve(a)    : return a // 2
def square(a)   : return a**2
def sqrt(a)     : return int(a**0.5)
def nop(a)      : return a

ALLOWED_FUNCTIONS = [increment, decrement, double, halve,
                     square, sqrt, nop]

def number_obtainer_master(ai_1,ai_2,logging):
    """
    Handles a number-fight game between two bots.

    SETUP: Each one of the 2 ais gets a random number from 1 to 100
    as its target. The starting number is the average of the two numbers.

    GAMEPLAY: Each ai should try to reach its goal before the opponent,
    the first ai that reaches its number wins.
    Note: After 500 turns, if noone has won, the game is declared drawn.
    """
    target_numbers = [random.randint(1,100), random.randint(1,100)]
    starting_number = sum(target_numbers) // 2
    number = starting_number
    if logging:
        print("""The match is about to start, the contending AIs are:
{} - whose target is {}
{} - whose target is {}
The starting number is: {}\n\n""".format(ai_1.__name__,target_numbers[0],
                                     ai_2.__name__,target_numbers[1],
                                     starting_number))
    for turn in range(500):
        if logging:
            print("""\n         --- Turn: {} --- """.format(turn))
        ais = [ai_1,ai_2]
        for ai in ais:
            if ai == ai_1:
                ai_function = ai(target_numbers[0],target_numbers[1],number)
            else:
                ai_function = ai(target_numbers[1],target_numbers[0],number)
            if ai_function not in ALLOWED_FUNCTIONS:
                raise ValueError("Invalid function was returned")
            number = ai_function(number)
            if logging:
                print("{} chose {}: the number now is: {}".format(
                ai.__name__,ai_function.__name__,number))
            if number in target_numbers:
                if logging:
                    print("{} won.\n\n".format(ai.__name__))
                return 1 if number == target_numbers[0] else 0
    if logging:
        print("After 500 turns the match is not ended yet: tie.\n\n")
    return 0.5

def compare_strength(ai_1,ai_2,accuracy):
    """
    Returns how many times ai_1 is better than ai_2.
    Harder than it should be to compensate advantage of going first.
    """
    ai_1_score = sum([number_obtainer_master(ai_1,ai_2,False) for _ in range(accuracy//2)])
    ai_1_score = sum([ 1 - number_obtainer_master(ai_2,ai_1,False) for _ in range(accuracy//2)])
    return ai_1_score / accuracy # 1 means perfect

def tournament(ais,accuracy):
    """
    Lets each ai fight all the other ais and returns a nicely sorted leaderboard.
    """
    scores = []
    for ai in ais:
        score = sum ( (compare_strength(ai,opponent,accuracy) for opponent in ais if opponent != ai) ) / len(ais)
        scores.append((ai.__name__,score))
    return sorted(scores, key=lambda x: x[1], reverse= True)

## Default simple ais

def sleeping_ai(self_target,opposite_target,current_number):
    return nop

def simplistic_ai(self_target,opposite_target,current_number):
    return increment if current_number < self_target else decrement

def cleverish_ai(self_target,opposite_target,current_number):
    target,n = self_target,current_number
    if n*2 < target:
        return double
    elif n//2 == target:
        return halve
    elif n**2 == target:
        return square
    return increment if current_number < self_target else decrement

def increment_ai(self_target,opposite_target,current_number):
    return increment

## Partecipants ais

print(tournament([sleeping_ai,simplistic_ai,
                 cleverish_ai,increment_ai],200))

You should probably describe what functions are available and what they do (in English, not in code). Also, you should describe how you will provide input and how you will expect output (again, in English). You'll have a much higher participation rate if we don't have to dive into your Python.

Since this is a perfect information game with very limited game state, I believe there is an unbeatable algorithm to this. That generally doesn't make for the best KotH, but it may be better suited as another type of challenge.

I voted for closing. But not because it is unclear what you're asking. This type is simply not suited for KOTH. Every 'good' ai will have a line in it, to only play a move, where the opponent can't finish in one turn. Therefore each battle will end tied, except the first player can reach the number in one move.


text:
Logical Dot Shapes
The Game
Recently, much of my time has been taken up by an addicting game on my phone, called Logic Dots, which inspired me to write this challenge. It's easier to explain the rules if I show you the game display, so here is a screenshot of an unsolved, and solved puzzle:

Now here, there are three main things to notice.

The game board (the 4x4 grid of squares in the center)
The required shapes (the linked dots in the second bar from the top, under the score and menu, etc.), which are all lines, or a by 1 rectangles
The numbers over the rows and columns, which denotes how many dots need to be in the column, for a solution

The objective of the game is to fit the required shapes into the grid. You can rotate the shapes, but they cannot go in diagonally.
In the solution, notice that all shapes are created exactly once (because they are only in the required shapes once), and in this case they are all horizontal but they can also be vertical. The pink filled in squares denote squares not used.
Here is a bigger, and slightly more complicated grid:

Notice that in the unsolved puzzle, there are already a few squares filled i.n The greyed out squares signify blocked squares that you CANNOT place a dot on. The dots with tails tell you that a dot is in that spot, and it links to at least one more dot in the direction of the tail, but not in any other direction (including the opposite direction).
Notation
For the rest of this post, I will refer to the board using the following symbols:

<, >, ^, v - Signifies a pre-placed dot with a tail extending in the direction of the point
* - Signifies a dot. If given on an unsolved grid (input), it is an individual shape. If in output, then it is connected to the dots around it.
# - Signifies a blocked grid square (where you cannot place a dot)
-, | (hyphen and bar) - Signify a dot with a right and left tail, and a dot with an up and down tail respectively
** (space character) -** Signifies an empty space

Using these symbols, the latter example case (unsolved) can be represented as follows:
 <

    #
 ^ #

And the solution can be represented as:
*< * *
   *
     *
 *   *
 * *#*
 ^ # *

Note that no two shapes can touch horizontally, vertically or diagonally, so the following case is not valid:
 ***
**
  **

Challenge
Your challenge is to solve any logic dots puzzle, from 4x4 to 9x9 inclusive. You will receive four lines of input, then the game board. The lines will be as follows:

1st line, Shapes - The shapes to find, each given in the form sizexquantity (eg. 3x2 for two shapes of length three) and separated by a space. Example line: 3x1 2x1 1x1
2nd line, Columns - A space separated list of the required dot count for each column. Example line: 1 1 2 2
3rd line, Rows- A space separated list of the required dot count for each row. Example line: 3 0 3 0
4th line, Board size - A single integer, the board size, B

The board is then given, and is B lines of input representing the board using the notation mentioned above. For example, the complete input for the latter example case is as follows:
4x1 3x1 2x2 1x2
1 4 0 3 0 5
4 1 1 2 3 2
6
 <

    #
 ^ #

Your program will then output the solved board, in the same notation. The matching output for the above input is as follows:
** * *
   *
     *
 *   *
 * *#*
 * # *

Note that a game board can have multiple solutions. In this case, just output one valid solution. Also, your program must output a correct solution within 10 seconds on a reasonable desktop computer for a complicated 10x10 grid.
This is code golf, so least bytes wins.

Test Cases
Input 1
3x2 1x4
2 2 3 1 2
4 0 3 0 3
5

    #
  #
    *

Output 1
*** *

 ***#
  #
* * *

Input 2
3x1 1x6
2 0 4 0 3
3 1 2 1 2
5
*

   #

Output 2
* * *
  *
  * *
*  #
  * *

Input 3
5x1 4x1 2x1 1x2
1 2 3 3 2 2
0 5 0 4 0 4
6
#
  -

 #
   <

Output 3
#
 *****

 ****
 #
* ** *

Yes, that is correct @flawr

@flawr t no two shapes can touch horizontally, vertically or diagonally (this should be at the beginning, not lost almost near the end, but anyway...)

@globby Wouldn't every empty space be replaced with #, I suppose the # is when you single tap an empty space in the game. When you finish a level it fills all empty cells.

@TeunPronk No. # are spaces which are predetermined that you cannot place a dot in the level, like the gray squares in the second example.

@globby ah ok, clear now ^^

Does it need to run in a reasonable amount of time?

@KSFT within 10 seconds for complicated 9x9 grids on a reasonable computer

Better than offer a bounty, you should add more interesting test cases and fix the errors in your question. For instance, the last output before the current test cases still contains < and ^

Python 2: 766 739 696 663 633 bytes
def f(B,S,o=0):
 if[]==S:print'\n'.join(B);exit()
 s=S[0]
 for i in r:
  for j in R(Z-s+1):
   if(B[i][j]in' '+'>v'[o])*(B[i][j+s-1]in' '+'<^'[o])*({' ','-|'[o]}>=set(B[i][j+1:j+s-1]))*all(B[x][y]in'# 'for x,y in [(x,y)for y in R(j-1,j+s+1)for x in i-1,i+1]+[(i,j-1),(i,j+s)]if 0<=x<Z>y>=0):q=B[:];q[i]=q[i][:j]+'*'*s+q[i][j+s:];q=(q,t(q))[o];any((t(q)+q)[k].count('*')>m[k]for k in R(Z+Z))or f(q,S[1:])
 o or f(t(B),S,1)
y=raw_input;S=[];s=str.split
for i in s(y()):u,v=map(int,s(i,'x'));S+=[u]*v
m=map(int,s(y())+s(y()));Z=input();R=range;r=R(Z);B=[y()for _ in r];J=''.join;t=lambda x:map(J,zip(*x))
f(B,S[:len(S)-J(B).count('*')])

See it working online: Ideone.com (The online version may be too slow for large and difficult grids, offline it should be fine)
Input is via stdin, just copy and past the lines from the OP (but be careful, stackexchange sometimes deletes spaces or lines).
Some basic ideas of this code:
It uses a recursive function f. f tries to place one shape at the board. For each possible location it calls itself with the modified board. There are 3 loops in it. o determines the orientation (2 - horizontal, 3 - vertical). It will always place the shape horizontal, therefore at the end of o=2, it will transpose the board with the function t. i is the row and j are all possible starting columns. Then a lot of checks happen, if the ends of the shape have valid chars, if the middle of the shape has valid chars and if the surrounding is empty.

I was struggling to cut the last 6 bytes, when I saw your last edit (-30) and gave up... You have my vote for what it's worth

JavaScript (ES6) 661 667 695 702 745 755 786 790 784 798
Work in progress, can be shortened.
Probably too slow on a complex grid. Maybe not.
Edit A bit longer, a lot faster.
Edit 2 Bug fix, columns/rows check. Incidentally, now it's faster
The M function is the main. The w parameter is a multiline string with all the input. The function parses the input and prepare a starting board. Characters <>^v|-* in the starting board are replaced with ,, each , has to be replaced with * in the correct solution.
The R function tries recursively to place all shapes in the board. When a shape is placed, it calls itself passing a shorter list of shapes and the modified board. When all shapes are placed, a solution can still be invalid if there are , not replaced by *.
The P function test if a shape can be placed a a given position and orientation. It checks all the costrains (inside the board, no overlap, no touch, valid row and column count)
M=w=>(
  [x,c,r,z]=w=w[S='split'](n='\n'),
  (b=[...w.slice(4).join(n)])
  .map((c,p)=>~(k='*<>-*^v|'.indexOf(c))&&[(q=k>3?z:1,0),k&1&&-q,k&2&&q].map(o=>b[p+o]=0),
    c=c[S](e=' '),r=r[S](e),w=z++,f='*',s='',x[S](e).map(v=>s+=v[0].repeat(v[2]))),
  R=(s,b,x=0,y=0,n=s[0],V=i=>b[i]>'#',
    P=(p,o,q,t,g,l,d=[...b])=>{
        if(l<z-n&!V(p+o*l-o)&!V(p+o*l+o*n))
        {
          for(i=-1;v=d[p],++i<w;p+=o,t-=v==f)
            if(i>=l&i-n<l)
              for(v!=e&v!=0|[q,w,~z].some(w=>V(p+w)|V(p-w))?t=0:d[p]=f,j=o*i,u=k=0;
                  ++k<z;(u+=d[j]==f)>g[i]?t=0:j+=q);
          return t>=n&&d.join('')
        }
    })=>{
    if(b){
      if(!n)return~b.search(0)?0:b;
      for(s=s.slice(1);y<w||(y=0,++x<w);++y)
        if(h=R(s,P(y*z,1,z,r[y],c,x))||n>1&&R(s,P(x,z,1,c[x],r,y)))return h
    }
  })(s,b)

Test In FireFox/FireBug console
;['3x2 1x4\n2 2 3 1 2\n4 0 3 0 3\n5\n     \n     \n    #\n  #  \n    *\n'
,'3x1 1x6\n2 0 4 0 3\n3 1 2 1 2\n5\n*    \n     \n     \n   # \n     \n'
,'5x1 4x1 2x1 1x2\n1 2 3 3 2 2\n0 5 0 4 0 4\n6\n#     \n  -   \n      \n      \n #    \n   <  \n'
,'4x1 3x1 2x2 1x2\n1 4 0 3 0 5\n4 1 1 2 3 2\n6\n <    \n      \n      \n      \n    # \n ^ #  \n']
.forEach(x=>console.log(x,M(x).replace(/ /g,'`'))) // space replaced with ` for clarity

Output (total execution time < 1sec)
3x2 1x4
2 2 3 1 2
4 0 3 0 3
5

    #
  #
    *

***`*
`````
`***#
``#``
*`*`*

3x1 1x6
2 0 4 0 3
3 1 2 1 2
5
*

   #

*`*`*
``*``
``*`*
*``#`
``*`*

5x1 4x1 2x1 1x2
1 2 3 3 2 2
0 5 0 4 0 4
6
#
  -

 #
   <

#`````
`*****
``````
`****`
`#````
*`**`*

4x1 3x1 2x2 1x2
1 4 0 3 0 5
4 1 1 2 3 2
6
 <

    #
 ^ #

**`*`*
```*``
`````*
`*```*
`*`*#*
`*`#`*

Looks like @globby forgot about that bounty. Anyways, had a lot of fun in this race.


text:
Ordering an array of negatives, zero and positives integers with one iteration
Take an array of integers containing negative numbers, positive numbers and zeros. Group it with one iteration and in place such that all of the negative numbers come first, followed by all of the zeros, followed by all of the positive numbers.
Example:
Input:  5, 3, 0, -6, 2, 0, 5
Output: -6, 0, 0, 3, 2, 5, 5

Note that the numbers do not need to be fully sorted: just sorted by sign.
So, the final array will look like this: -, -, ..., -, -, 0, 0, ..., 0, 0, +, +, ..., +, +
Rules

You may only use the input array and a constant amount of additional memory (i.e. you may not create any more arrays)
You may only use one loop, which may execute only as many times as the length of the array. You may not use built-in functions which conceal any kind of loop. This includes built-in sort functions.
The result should be in the format I described

The winner will be the person who will submit the shortest code (counted in bytes) that changes the initial array into a correct format (like described above).

Aka the Dutch national flag problem.

@PeterTaylor Thx, now I understand what is the task!

Exactly this http://codegolf.stackexchange.com/questions/504/stable-positive-negative-separation/42723 other than the use 1 iteration and 1 array limit.

Built-in sort functions are not allowed, right?

Is sorting by value not allowed or just not necessary?

@KSFT If the values are sorted by value, it's not a wrong answer supposing there is one iteration in array.

@KSFT Calling sort(...) is not fine since it probably does more than one iterations.

@IonicăBizău can you specify the exact output for input [-1, -2, 0, 2, 1] and if there are more than 1 outputs possible ?

@Optimizer [-1, -2, 0, 2, 1], [-2, -1, 0, 2, 1], [-1, -2, 0, 1, 2], [-2, -1, 0, 1, 2] Any of these results is correct.

@Optimizer I don't think it has to be constant space, and you only need to group the elements by sign, not sort.

@Optimizer It doesn't matter. It should be one iteration, and the result should be in -...0...+ format.

@Optimizer, yes.

Is iterating the array a constant number of times okay?

@PeterTaylor Yes for which comment ?

@Optimizer, the most recent one.

@PeterTaylor Well, that is not even possible :) . But since this is not pure sorting, it should be possible at least.

@Optimizer, the canonical solution is linked from the first comment.

@PeterTaylor I meant sorting an array in linear time and constant space.

@Optimizer,  No.

@Optimizer It was a joke, because you asked a bunch of questions and got a reply that just said "yes", but I guess it didn't work because of all the comments in between. I need to refresh more, I guess.

Is this challenge even possible?

@Ypnypn Yes, see the algorithm from the Wikipedia page (linked in the first comment).

C, 92
This could probably be reduced by at least 10 bytes; there are many expressions going to waste.
The first argument should point to the beginning of the array; the second should point after the end of the array.
*x;f(b,e)int*b,*e;{for(x=b;x<e;x++)*x>0&&--e-x?*x--^=*e^=*x^=*e:*x<0?b-x?*x^=*b=*x:0,b++:0;}

Ungolfed with random test generator:
*x;
f(b,e)int*b,*e;{
    for(x=b;x<e;x++) {
        if(*x<0) {
            if(b == x)
                b++;
            else
                *b++ = *x, *x=0;
        } else if(*x>0 && x != --e) {
            *x^=*e^=*x^=*e;
            x--;
        }
    }
}

int main()
{
    int a[999];
    srand(time(0));
    int n = rand() % 50;
    int i;
    for(i = 0; i < n; i++) printf("%d ", a[i] = rand() % 9 - 4);
    f(a, a+n);
    puts("");
    for(i = 0; i < n; i++) printf("%d ", a[i]);
    return 0;
}

I tried this in Code Blocks and it does not compile, there are 3 errors. What you compiled with? x* is not defined and you made variables before {.

@bacchusbeale You can compile it with gcc in the default (C89) mode. CodeBlocks isn't a compiler so I can't tell which compiler you are using, but it works with gcc. The reason it may not work with all compilers is K&R-style declarations, which don't comply with the ANSI standard.

C,90
Straightforward implementation of the algorithm in the wikipedia article per Peter Taylor's comment on the question.
Expects to find the data in an array called a like the other C answer. n,p and z are pointers for the insertion of negative and positive numbers and zeroes. n and p are taken as arguments pointing to the first and last elements of the data.
f(n,p){int t,z;for(z=n;p-z;z++)(t=a[z])?a[z]>0?a[z]=a[p],a[p--]=t:(a[z]=a[n],a[n++]=t):0;}

ECMAScript 157 Bytes
Takes the numbers as space separated or comma separated set from
a prompt dialog and returns the result with a alert dialog.
for(v=prompt().split(/,?\s+/),s=function(j,n){t=v[j],v[j]=v[n],v[n]=t},i=j=0,n=v.length-1;j<=n;)
!(~~v[j]<0&&!s(i++,j++)||~~v[j]>0&&!s(j,n--))&&j++;alert(v);

STATA 242
Follows the wikipedia page exactly. Thanks @PeterTaylor
Takes input as a space separated set of numbers from std in and outputs as such as well to std out.
di _r(a)
token $a//converts to array (kind of)
loc i=0
loc j=0
loc q=wordcount($a)
loc n=`q'-1
while `j'<=`n' {
loc t=``j''
if `t'<0{
loc `j'=``i''
loc `i'=`t'
loc ++i
loc ++j
}
else if `t'>0{
loc `j'=``n''
loc `n'=`t'
loc --n
}
else
loc ++j
}
//used only to output
forv x=1/`q'{
di ``x'' _c
}

Python 2: 116 bytes
a=input();i=j=0;n=len(a)
while j<n:b=a[j];r,s=b<0,b>0;c=i*r+n*s-s+j*(b==0);a[c],a[j]=b,a[c];i+=r;n-=s;j+=b<1
print a

This is a golfed Python translation of the Dutch national flag pseudo-code.
Possible 112 bytes
Not sure, if this is allowed. It creates a second array of size 3 (constant amount of additional memory!).
a=input();i=j=0;n=len(a)-1
while j<=n:b=a[j];k=(i,j,n)[cmp(b,0)+1];a[k],a[j]=b,a[k];i+=b<0;n-=b>0;j+=b<1
print a

C++
Un-golfed solution: n counts the negatives added to front of array.
For each element if negative swap with element at n, if zero swap with element at n+1 else swap with last element.
void p(int* k,int n)
{
for(int i=0;i<n;i++)
{
cout<<*(k+i)<<' ';
}
cout<<endl;
}

void s(int *x,int i,int j)
{
int t=*(x+j);
*(x+j)=*(x+i);
*(x+i)=t;
}
void f(int *x,int L)
{
int n=0;
int k;
for(int i=1;i<L;i++)
{
k=*(x+i);
if(k<0)
{
s(x,i,n);
n++;
}
else if(k==0)
{
s(x,i,n+1);
}
else if(k>0)
{
s(x,i,L-1);
}
}
}

int main()
{
int x[]={5,2,-1,0,-2,4,0,3};
f(x,8);
p(x,8);
return 0;
}

CJam - 72 67
q~_,(:N;{_U=:B0>{U1$N=tNBtN(:N;}{B{U1$T=tTBtT):T;}{}?U):U;}?UN>!}gp

Input: [5 3 4 0 -6 2 0 5]
Output: [-6 0 0 4 2 3 5 5]
Try it at http://cjam.aditsu.net/
Explanation:
This is another implementation of the algorithm from wikipedia, using T for i and U for j (both automatically initialized to 0).
q~                    read and evaluate the array (let's call it "A")
_,(:N;                keep A on the stack and set N ← size of A - 1
{                     do...
    _U=:B             keep A on the stack and set B ← A[U] (also leaving B on the stack)
    0>{               if B > 0
        U1$N=t        A[U] ← A[N]
        NBt           A[N] ← B
        N(:N;         N ← N - 1
    }{                else
        B{            if B ≠ 0
            U1$T=t    A[U] ← A[T]
            TBt       A[T] ← B
            T):T;     T ← T + 1
        }{            else (do nothing)
        }?            end if
        U):U;         U ← U + 1
    }?                end if
UN>!}g                ...while not (U > N)
p                     print representation of A

Rebol - 149 142 140
a: to-block input i: j: 1 n: length? a while[j <= n][case[a/:j < 0[swap at a ++ i at a ++ j]a/:j > 0[swap at a j at a -- n]on[++ j]]]print a

This is a direct port of the Dutch national flag wikipedia pseudocode.  Below is how it looks ungolfed:
a: to-block input
i: j: 1
n: length? a

while [j <= n] [
    case [
        a/:j < 0 [swap at a ++ i at a ++ j]
        a/:j > 0 [swap at a j at a -- n]
        on       [++ j]
    ]
]

print a

Usage example:
rebol dutch-flag.reb <<< "5 3 0 -6 2 0 5"
-6 0 0 2 3 5 5

NB. Rebol arrays (blocks) don't use commas - [5 3 0 -6 2 0 5]
And if its OK wrap this up into a function which takes an array and modifies it in place then we can get it down to 128 chars:
>> f: func[a][i: j: 1 n: length? a while[j <= n][case[a/:j < 0[swap at a ++ i at a ++ j]a/:j > 0[swap at a j at a -- n]on[++ j]]]n]

>> array: [5 3 0 -6 2 0 5]
== [5 3 0 -6 2 0 5]

>> print f array
-6 0 0 2 3 5 5

>> ;; and just to show that it as modified array

>> array
== [-6 0 0 2 3 5 5]

In fact if didn't need to return array (ie. just modify) then you could shave off 1 more char.

PHP (146)
function f($s){for($i=0,$n=count($s)-1;$j++<=$n;)if($k=$s[$j]){$l=$k>0?n:i;$x=$s[$$l];$s[$$l]=$k;$s[$j]=$x;$k>0?$n--|$j--:$i++;}echo print_r($s);}

http://3v4l.org/ivRX5
PHP's relatively verbose variable syntax is a bit painful here...


text:
Warhol these pictures
We've all seen the famous painting of Marilyn Monroe created by Andy Warhol.

Let's try to replicate that effect with the usual suspects.
Your task is to write a program/programs that do as many as possible of the following tasks:

With one image as the input, generate four color palettes from that image and print a 4x4 grid with different "Warhol'd" color variants of that image.
With two images as input, generate two color palettes from each image and print a Warhol'd grid of the first image.
With four images as input, generate one color palette from each image and print a Warhol'd grid of the first image.

Of course, it would be cheating to hardcode palettes you like the best, so your program has to determine a set of colors that is both distinct and aesthetically pleasing. Warhol used five distinct colors in each panel, so five is your goal as well.
Here are some photos that you could use to showcase your program:

Try to achieve a wide range of palette colorings and of course make them as aesthetically pleasing as possible.
This is a popularity contest, so the answer with the most net votes wins.
(Formatting largely copied from Paint by Numbers, which was a partial inspiration for this challenge as was American Gothic in the palette of Mona Lisa: Rearrange the pixels)

Related from Mathematica.SE ... and seeing that I have really lost the motivation to do anything but copy the accepted answer, because I won't be able to do better anyway.

(Oh right, it requires one intermediate manual step... although I suspect that step will be very similar to Paint by Numbers.)

Martin, What is the intermediate manual step you referred to?

@DavidCarraher Drawing the red blobs.

I'm voting to close this question as off-topic because it seems to be an art contest, with programming serving only a purely functional role of implementing artistic effects.

I like how one picture I generated and one I actually took have become our norms.

Everyone completely misinterpreted this question.  "With one image as the input, generate four color palettes from that image and print a 4x4 grid with different "Warhol'd" color variants of that image. "
It's not just "pick a random color out of a list" such as the first answer, you are meant to programmatically generate a limited palette based on the colors of another image (similar to the two other challenges I linked to)
The interesting element I feel is that picking five random colors from a picture won't yield good results, so how does one determine aesthetics programmatically.

@Calvin'sHobbies That would explain why I couldn't find sources for those two when compiling images for Paint by Numbers. :D

Mathematica
namedColors = {Red, Green, Blue, Black, White, Gray, Cyan, Magenta, Yellow, Brown, Orange, Pink, Purple};
    myRules =
      Table[Rule[namedColors[[i]], RandomChoice[namedColors]], {j, 4}, {i,
         Length[namedColors]}];

myImages = {--images here--};

Grid@Table[ColorQuantize[ColorReplace[myImages[[i]], myRules[[j]]],5],
{i, Length[myImages]}, {j, 4}]


text:
Grow words from fertile vocabularies
An incremental word chain is a sequence of words of a vocabulary such that each word is the result of either prepending or appending a single character to the previous word, ignoring capitalization. An example of such a chain can be found below.

I → is → his → hiss

Your task is to write a program that for a given vocabulary finds the longest incremental word chain. The input is provided from standard input a vocabulary as one word per line. The words are composed of the lowercase letters a to z only. The output of your program shall go to standard output and shall be one word per line a longest word chain of the input vocabulary, starting with the shortest word.
This is code golf, the solution with the least character count wins. Different forms of input or output are not possible, but the terms standard input and standard output may be interpreted in a reasonable way for the language you are solving this problem in.
Please demonstrate that your code works by publishing the longest word chain you find on the xz-compressed vocabulary found here. This vocabulary was generated by executing the following series of commands on the file british-english-insane from the SCOWL project in the C locale:
tr 'A-Z' 'a-z' <british-english-insane | sed -n '/^[a-z]*$/p' | sort -u | xz -9e >voc.xz

A solution in polynomial time is possible and highly appreciated.

@MartinBüttner I agree with you that these challenges are similar, but an important difference is that in my challenge the graph is acyclic, so a solution in polynomial time can be found.

Title and description don't match, as the title allows only appending whereas the description also allows prepending. Description trumps title, doesn't it?

@nimi You are correct. To put it simply, I didn't find a formulation of the problem that fits in the title and is correct. Maybe you can help me find one?

FUZxxi,  How about "Growing Words"?

@DavidCarraher Better this way?

Yes, I think it is better.  Calls attention nicely.

Is the input supposed to be the actual words, the name of a file containing the words, or something else?

@KSFT The input is a newline separated list of words.

Ruby 139 127
h={}
$<.map{|l|h[l.strip]=1}
v=->w,c=[]{w<?a?c:h[w]&&(v[w.chop,z=[w]+c]||v[w[1..-1],z])}
puts h.map{|k,_|v[k]||0}.max_by &:size

Runs in ~3.5 seconds and prints:
r
ra
rah
rahm
brahm
brahma
brahman
brahmani
brahmanis
brahmanism
brahmanisms

@britishtea fixed!

Ruby, 127
Runs in about 6.5 seconds. Uses a couple of cool tricks. ARGF ($< or stdin, really) is enumerable! If an array is passed as a block argument, it can be "exploded" and assigned to a parameter using {|w,| ... }. Notice the comma.
I found an even shorter solution which uses Array#& (set intersection) to do the lookup of words, but that runs extremely slow, unfortunately.
Thanks to w0lf for shaving off a few characters
D={}
$<.map{|l|D[l.strip!]=l}
puts D.map{|w,|c=[w]
w.chars.all?{w=c[0]
r=D[w.chop]||D[w[1..-1]]
r ?c=[r]+c :p}
c}.max_by &:size

Output
r
ra
rah
rahm
brahm
brahma
brahman
brahmani
brahmanis
brahmanism
brahmanisms

Readable version
D = {}
$<.lines { |l| D[l.strip] = l.strip }

chains = D.map do |word, _|
  chain = [word]

  word.chars.all? do
    word   = c.first
    result = D[w.chop] || D[w[1..-1]]

    result ? chain.unshift(result) : nil
  end
end

puts chains.max_by(&:size)

Nice! You can save some more chars: max_by(&:size) --> max_by &:size and r ?c.unshift(r):p} --> r ?c=[r]+c :p}

Python 2, 208 bytes
Here is a not very small solution. It firsts creates an index of the word parts, then recursively searches for the longest chain.
import sys
d={}
b=lambda k:d.setdefault(k,[]).append(e)
for e in sys.stdin:e=e[:-1];b(e[1:]);b(e[:-1])
def f(a):
 g=a
 for c in d.get(a[-1],[]):g=max(g,f(a+[c]),key=len)
 return g
for e in f([''])[1:]:print e

It returns:
a
ab
rab
arab
arabi
arabin
arabine
carabine
carabiner
carabinero
carabineros

in 6.2 seconds.
The code before minifier looks like this:
import sys

lookup = {}
addindex = lambda k: lookup.setdefault(k, []).append(word)

for word in sys.stdin :
    word = word[:-1];
    addindex(word[1:]);
    addindex(word[:-1])
print 'Indexed' # DEBUG

def find(wordlist):
    best = wordlist
    for newword in lookup.get(wordlist[-1], []) :
        best = max(best, find(wordlist+[newword]), key=len)
    return best

for word in find([''])[1:] :
    print word

Please read from standard input and write the entire chain to standard output.

Now uses stdin. I found a way to save a few bytes too.

Your program is still incorrect. It has to print the entire chain, not just the last word in it. Also, it has to print the word chain in the format specified in the question.

I take it that I am now presenting in the correct format?

I hope the down-voter is more pleased with the improved answer :-)

Yeah, the current format looks good.

Haskell, 175 Bytes
import Data.Set
main=interact$unlines.snd.maximum.g.lines
g l=Prelude.map(f(0,[]))l where f z@(d,r)w|notMember w(fromList l)=z|1<2=max(f(d+1,w:r)(tail w))(f(d+1,w:r)(init w))

finds
r
ra
ran
fran
franc
franci
francis
francisc
francisca
franciscan
franciscans

Spent about 30 bytes for the use of a Set data structure for efficient lookups but that are useless (in code golf!) otherwise.
How it works: for every word from the input build recursively a list with valid child words. Take the longest list and print it. A "child word" is the word with either first or last letter missing. It is "valid" if it's in the input. If both child words exist, take the one that builds the longer sublist.

"r" is not a word, so isn't this solution invalid?

@DavidG.Stork It's part of the given dictionary.

@agweber:  My goodness, "r" is now in the dictionary.  I programmed in Mathematica an interesting, related problem (longest sequence of words where an insertion could occur anywhere) and, using the WordData all led to either "i" or "a".

@DavidG.Stork Even if "r" is not a word the a → ra chain is still valid :)

J: 246 bytes
's p'=:(*(>./i)>:])|:(6 s:[:s:}.;}:)S:0 w[i=:6 s:v=:s:w=:~.a:,<;._2 fread'voc'
l=:[:,([:(#S:0)5 s:_6 s:])"0
f=:3 :'(y{~])^:(~:0:)^:a:"0 y'
q=:_6 s:]
d=:[:+/@:*"1 f
ds=:d s[dp=:d p
n=:(ds<:dp)}s,:p[m=:ds>.dp
echo}:"1 q(r{i),.(r=:([:I.]=>./)m){f n

output:
`franciscans `franciscan `francisca `francisc `francis `franci `franc `fran `fra `fr `f

Version with comments.

Please obey the output format.

Also, why is this community wiki?

So someone else can edit it if they want. It's not really well golfed and I don't have time to work on it.


text:
Rock-paper-scissors competition simulator
You decided to organize a rock-paper-scissors championship to find out who is the best. You don't want to let luck to decide the winner so everyone has to give you his or her tactic in writing before the competition. You also like simple things so a move of a competitor (showing rock, paper or scissors) has to be based only the previous turn (RvR, RvP, RvS, PvR, PvP, PvS, SvR, SvP or SvS). In the first turn a player has to show a fixed sign.
You decided to write a program (or function) to simulate the championship.
Details of the competition

There will be at least 2 contestants.
Every player plays exactly one match with everyone else.
One match lasts 7 rounds.
In every round the winner gets 2 points the loser gets none. In the event of a tie both player score 1 point.
A players score in a match is the sum of his or her points over the turns of the match.
A players final score in the championship is the sum of his or her points over all matches.

Details of the input:

your program or function receives N 10 character long strings each of them corresponds to a players strategy. All characters are (lowercase) r p or s meaning that in the given situation the player will show rock paper or scissors.
The first letter codes the first turn (in every match for that competitor). The second shows what happens if the last round was rock vs rock. The next ones are RvP, RvS, PvR, PvP, PvS, SvR, SvP and SvS where the first letter is the player's sign and the second is the opponent's. E.g. rrpsrpsrps means the player starts with rock and then copies the opponent's last move.
You can input the list of strings as a list/array or similar data of your language or as one string. In the latter case some kind of separator character is a must.

Details of the output:

Your program or function should output the final scores of each player in the same order as the input was supplied.
Scores should be separated by spaces or newlines. Trailing space or newline is allowed.

Examples:
Input:
['rrpsrpsrps', 'rpppsprrpr']
Output:
5 9 (turns are rvr rvp pvs svp pvr rvp pvs)
Input:
['rrpsrpsrps', 'rpppsprrpr', 'ssssssssss']
Output:
13 17 12 (matches are 5-9 (1st vs 2nd), 8-6 (1st vs 3rd) and 8-6 (2nd vs 3rd))
This is code-golf so the shortest entry wins.

Inspired by Numberphile? ;-)

Is the second example correct? I think the 1st looses against the 3rd with 6-8 and the second looses against the third with 6-8.

@Jakube Corrected example input. Thx.

Python 2: 201 188 chars
def f(Q):c=lambda m:'rps'.index(m);l=len(Q);r=[0]*l;i=0;exec'p,q=i/l,i%l;m,n=c(Q[p][0]),c(Q[q][0]);exec"r[p]+=(p!=q)*(m+1-n)%3;m,n=c(Q[p][m*3+n+1]),c(Q[q][n*3+m+1]);"*7;i+=1;'*l*l;return r

The logic of the program: I convert the letters to number (r=0,p=1,s=2). m is the number of the first, n the number of the second person. Because the game is cyclic, (m-n)%3 already determines the result. And of course, I can shift the result by one f=(m+1-n)%3. Now f=0 means, second player q wins, f=1 means a tie, and f=2, first player p wins. It also is already the score for player 1. Therefore I only need to add all values (p!=q)*(m+1-n)%3 for each player.
Test it with print f(['rrpsrpsrps', 'rpppsprrpr', 'ssssssssss'])