text:
I am passive aggressive and want to insult my boss without him finding out
It's been a rough few months at work and I feel like I just want to scream right to my boss' face. I am, however, not one to directly confront people I have a problem with. I also don't want to lose my job.
So here's an idea: I want to be able to insult him, without him ever finding out. And I realized the perfect way: I need some sort of software that encodes an insult inside an otherwise perfectly fine message. And seeing as how he's known to not see forests for trees, I think I know just how:
Write me a program that takes as input a string of unknown length, but containing no line breaks. This will be the raw message I want to send.
If possible, return the string formatted such that the message "DIE IN A GREASE FIRE" makes up the entire left column. With new paragraphs where spaces in between words should go. Now, as I am very angry, it is equally important that every letter is in upper case.
You may not modify the string in any other way, i.e. you may not turn all of the string into upper case characters.
If the string in question cannot be formatted in this way, you are to return the original string. Read input from standard input.
Normal rules apply: No HTTP requests, no consulting Marvin from THGTTG, etc.
Example input:

Dear Boss, how are things? It has come to my attention that I received
  all the blame for the mishap last Friday. Not just the majority of it.
  Every last bit of it. Is it wrong for me to think that the rest of the
  team were at least in part responsible? After all, all six of us were
  involved from the get-go. Not that I think I should stand without
  blame. Not at all. All I'm saying is this: I do my best. I try hard. I
  improve constantly. And I am constantly taking responsibility.
  Generally speaking, I am very okay with taking full responsibility for
  my actions. But after this spring, it seems I get more than I deserve.
  Remember the Flakenhauser contract? Everything went down just about as
  smooth as one could have hoped. Or so it seemed at first. It was just
  at the very last minute that things fell apart. All of the team agreed
  that it was more akin to a freak accident than sloppy planning or
  mismanaged resources. Still, I - alone - took blame for it. Even
  though I said nothing then, my tolerance level for taking the blame
  took a serious dent then. From that point on, I have felt it necessary
  to always try twice as hard, just to escape scrutiny. And still, here
  we are again. In spite of all my accomplishments. Right where we
  always seem to end up these days. Every single project. It's becoming
  unbearable.

Example output:

Dear Boss, how are things?
  It has come to my attention that I received all the blame for the mishap last Friday. Not just the majority of it.
  Every last bit of it.
Is it wrong for me to think that the rest of the team were at least in part responsible? After all, all six of us were involved from the get-go.
  Not that I think I should stand without blame. Not at all.
All I'm saying is this: I do my best. I try hard. I improve constantly. And I am constantly taking responsibility.
Generally speaking, I am very okay with taking full responsibility for my actions. But after this spring, it seems I get more than I deserve.
  Remember the Flakenhauser contract.
  Everything went down just about as smooth as one could have hoped. Or so it seemed at first. It was just at the very last minute that things fell apart.
  All of the team agreed that it was more akin to a freak accident than sloppy planning or mismanaged resources.
  Still, I - alone - took blame for it.
  Even though I said nothing then, my tolerance level for taking the blame took a serious dent then.
From that point on, I have felt it necessary to always try twice as hard, just to escape scrutiny. And still, here we are again.
  In spite of all my accomplishments.
  Right where we always seem to end up these days.
  Every single project. It's becoming unbearable.

This is code golf. Shortest code wins.

Do the line breaks have to occur only after sentence-ending punctuation? Or could I have a line break, before some proper now or maybe even within an abbreviation, as long as the following letter is upper case? That being said, insult-related challenges didn't fare well here in the past, but you might be able to get away, because you didn't ask for the participants' creativity in coming up with new obscenities.

Line breaking before proper nouns is perfectly fine.

Just to make sure, does that line break apply also to new paragraphs (for a space in the hidden sentence)? Could that I in the word IN come from the middle of a sentence?

The I in IN can come from the middle of a sentence, as long as the I was in upper case in the original input.

I really hope that your boss is as incapable of "seeing the forest through the trees" as you say, because that insult is not that well hidden.

@NateKerkhofs I think it's backwards: since the secret message is just a few characters in an entire message, I think that the insult is the trees, and the message is the forest.  We really hope that the boss sees the forest, not the trees.

Was Arnold Schwarzenegger's letter your inspiration?

Can we break words? For example, could "FIFA" be used for its "I"?

@Dennis No. This is part of what I meant by not modifying the original string in any other way.

@200_success good old Arnie did spring to mind!

I must admit I did a bit of a double-take when I saw this in the Hot Questions list. When I saw it was PCG and not The Workplace...well...I won't say I wasn't a little disappointed.

@ChristoferOlsson: I initially interpreted your question that way, but it only says "format", not how, and at least one other answer interpreted it differently. Thanks for clearing that up.

@Dennis: I did ponder these things somewhat before posting, but it seems I didn't do that enough. A lesson for future golfing questions I might ask.

Can we assume that there will be no control characters at all in the string?

CJam, 56 53 bytes
q_"DIEIINAAGGREASEFFIRE"{S@:A+S@+#:BA<AB>}%(!B)*\N*@?

Try it online!
How it works
q_                     Read all input from STDIN and push a copy.
"DIEIINAAGGREASEFFIRE" Push the characters we're searching for in form of a
                       string. We'll try to prepend a linefeed to all of them.
                       Some characters are duplicated to prepend two linefeeds.
{                      For every character C in that string:
  S@                   Push ' ' and rotate the string on the stack on top of it.
  :A                   Save the string (initially the input) in A.
  +                    Prepend the space to A.
  S@+                  Construct the string " C".
  #                    Compute the index of " C" in the modified A.
  :B                   Save the index in the variable B.
  A<                   Push the substring of A up to the index.
  AB>                  Push the substring of A after the index.
}%
(                      Shift the first element of the resulting array.
!                      Compute the logical NOT. This pushes 1 if and only if the
                       array's first element is an empty string, which is true
                       if and only if the input string started with a D.
B)                     Push the last value of B and increment. If the last match
                       was successful and, therefore, all matches were successful,
                       B != -1, so B + 1 != 0.
*                      Compute the product of the two topmost items on the stack.
\                      Swap the resulting Booleanr with the array of substrings.
N*                     Join the array, separating by linefeeds.
@                      Rotate the input string on top of the stack.
?                      Select the joined array if the Boolean is 1 and the input
                       string otherwise.

Why do I find myself upvoting so many of your answers? Oh yeah, because they're crazy.

What does it do to input that contains VERY ANGRY words in ALL CAPS?

@AdamDavis: Prepending spaces to “C” and “A” makes sure that WORDS won't be broken by linefeeds.

Perl - 60 bytes
#!perl -p
$_=(join$/,$_=~('DIE\IN\A\GREASE\FIRE'=~s/./($&.*)/gr))||$_

Counting the shebang as one.
This solution uses the innermost string to build up the following regex:
(D.*)(I.*)(E.*)(\.*)(I.*)(N.*)(\.*)(A.*)(\.*)(G.*)(R.*)(E.*)(A.*)(S.*)(E.*)(\.*)(F.*)(I.*)(R.*)(E.*)

which is similar to the regex used in m.buettner's solution. The generated regex is then matched against the input. In a list context, this will return an array containing each of the match groups, which are joined together by a newline (the reason for the 'match nothing' groups (\.*), is to insert an additional newline). If there is no match, the original string is output instead.

Perl - 73 bytes
#!perl -pl
$s=$_}for(map$s!~s/.*?(?=$_)//?$\='':$&,'DIEI.NA.G.REASEF.IRE$'=~/./g){

Counting the shebang as two.
This splits up the string at the appropriate delimiters, and collects the pieces in an array. If any of them fail to match, the output record separator (which was set to a newline with the -l option) is unset, and so the string is output unmodified.

Doesn't the shebang need an absolute path?

why the dots (DIEI.NA.  ...?

@celtschk Maybe, depending on your system, and how you intend to invoke the script. Invoked as ./script.pl, then most likely yes. If invoked as perl script.pl, then no.

@edc65 The . after I will insert an additional newline before I (because it matches again at the same position). Perhaps a bit counter-intuitive.

But if you invoke as perl script.pl, then shouldn't the shebang line be completely ignored (since for Perl, it's a comment)? I just tested with #!perl --invalid and got no error (while --invalid as option on the command line gives an error).

@celtschk The switches on the shebang will still be interpreted. You can test this by adding the -M option to the shebang, which will die with the fatal error: Too late for "-M" option at line 1. But the main reason I put it there, I too avoid needing to explain that it needs to be run as perl -pl script.pl - in its current form, it runs as-is.

Ah, interesting. I wonder why it didn't error out on --invalid, then ... (it also seems to interpret the executable name; using just p instead of perl gives Can't exec p at test3.pl line 1.)

GolfScript, 53 bytes
Looks like Dennis and I came up with pretty similar things in parallel... But here's my attempt.
Click on the links before each code block to try it online. Unfortunately, the online interpreter won't allow you to run code larger than 1024 characters, so I had to perform some... "compression" of the test input. But it does still work.
Squished version
..(\;68=(>"IEIINAAGGREASEFFIRE"{1$.@?:^<n@^>}/](]^0<=

Unsquished, commented version
.       # (Save input)
.(\;    # Get first character
68=(>   # If 'D', work with input; else, work with one-character string
"IEIINAAGGREASEFFIRE"
{       # For each character
 1$.@   # (Duplicate message twice)
 ?:^    # Find first index of character
 <n     # Extract part before index and add a newline
 @^>    # Extract part including and after index as new "message"
}/      # (Close loop)
](]^0<= # If last line was successfully matched, select result; else, select input

A point raised by Dennis: All GolfScript programs print an automatic final newline. Whether or not this should invalidate my solution as-is, I'm not sure. I believe it would cost 4 characters to suppress the final newline by adding "":n somewhere near the end.

You don't seem to check if the character is the first character of a word. For example. "FIFA" should only be used for F, not for "I" or "A".

@Dennis I didn't see any part of the specification that requires that. But if you imposed that restriction on yourself, lifting that from your solution seems like it would solidify its superior golfed-ness.

This is how m.buettner and I interpreted the question (I'd have to take a closer look at the other answers), but you're right, it doesn't say anywhere that we cannot break words.

JavaScript 116
Javascript implementation of m-buettner's idea
console.log((RegExp('^('+[...'DIE IN A GREASE FIRE$'].join('.*)(')+')').exec(z=prompt())||[,z]).slice(1).join('\n'))

Test snippet

z="Dear Boss, how are things? It has come to my attention that I received all the blame for the mishap last Friday. Not just the majority of it. Every last bit of it. Is it wrong for me to think that the rest of the team were at least in part responsible? After all, all six of us were involved from the get-go. Not that I think I should stand without blame. Not at all. All I'm saying is this: I do my best. I try hard. I improve constantly. And I am constantly taking responsibility. Generally speaking, I am very okay with taking full responsibility for my actions. But after this spring, it seems I get more than I deserve. Remember the Flakenhauser contract? Everything went down just about as smooth as one could have hoped. Or so it seemed at first. It was just at the very last minute that things fell apart. All of the team agreed that it was more akin to a freak accident than sloppy planning or mismanaged resources. Still, I - alone - took blame for it. Even though I said nothing then, my tolerance level for taking the blame took a serious dent then. From that point on, I have felt it necessary to always try twice as hard, just to escape scrutiny. And still, here we are again. In spite of all my accomplishments. Right where we always seem to end up these days. Every single project. It's becoming unbearable.";

T1.textContent = (RegExp('^('+[...'DIE IN A GREASE FIRE$'].join('.*)(')+')').exec(z)|| [,z]).slice(1).join('\n')

z='From that FIFA point on'
T2.textContent = (RegExp('^('+[...'DIE IN A GREASE FIRE$'].join('.*)(')+')').exec(z)|| [,z]).slice(1).join('\n')
pre { border: 1px solid black }
T1

T2 (the FIFA test)

JavaScript it is.

This fails on the FIFA test (OP comments)

@Mwr247 hard to understand: what FIFA test did you try?

Try the test string with the following edit: From that FIFA point on. It puts a new line before the FA, and before the space before FI.

@Mwr247 not for me. Tested with Firefox, I get the same exact line, no newlines in it

Ruby - 140
a="DIEINAGREASEFIRE";n=[4,6,7,13];i=0;o='';s=ARGV[0]
s.chars.each{|c|
if c==a[i]
i+=1;o+="\n";o+="\n"if n-[i]!=n
end
o<<c
}
puts((i<16)?s:o)

No regexes in this one. It simultaneously walks the characters in the ARGV[0] input, and a string containing characters we need to break on to make our left-column message. Was originally going to stick spaces after the letters that need to have a newline, but found that it was a bit shorter to hardcode the indexes at which to insert the line break.
Once all is said and done, it checks to see that the i index has incremented enough times to have gone through every letter that needed breaking. If it hasn't, we just print out the original string. If it has, we give 'em the formatted one.
n-[i]!=n was a neat trick to save characters when checking whether or not the current index was one that needed an extra line break (as compared to n.include? i). Also saved some characters by using {}s instead of do/end despite being a multiline block, and used a ternary condition on the final puts to save characters when determining which one to output.
Not the shortest, but I thought it would be neat to do without regular expressions.

Perl, 184 bytes
Not a spectacular score for Perl, but here is a simple regex solution
$_=<>;s/^(D.*) (I.*) (E.*) (I.*) (N.*) (A.*) (G.*) (R.*) (E.*) (A.*) (S.*) (E.*) (F.*) (I.*) (R.*) E/$1\n$2\n$3\n\n$4\n$5\n\n$6\n\n$7\n$8\n$9\n$10\n$11\n$12\n\n$13\n$14\n$15\nE/;print;

Surely it's possible to build the regex in code and save a ton?

@PeterTaylor certainly, but I neither have the time nor Perl knowledge to do that right now. I might have a look later today.

Even so it beats my PERL answer, which I won't bother posting now :p

Save 4 chars: print($_) == print. +1 point for readability: It is remarkably easy to see what is going on which is not exactly the case for other solutions.

This is considered simple in Perl?

@LincolnBergeson I said "simple regex" ;) ... as far as regex solutions to code golf challenges go, this is fairly straight-forward.

Python3 (166 138)
Golfed:
s='';o=input()
for n in o.split():s+=[n,'\n'+n.title()][n[0]==("DIEINAGREASEFIRE"*len(o))[s.count('\n')]]+' '
print([o,s][s.count('\n')==16])

Ungolfed-ish:
format_s = ''
unformat_s = input()
for n in unformat_s.split():
    format_s += [n, '\n' + n.title()][n[0] == ("DIEINAGREASEFIRE"*len(unformat_s))[format_s.count('\n')]] + ' '
print([unformat_s, format_s][format_s.count('\n') == 16])

Although the use of the lambda pleases me somewhat, that mass number of variables used and the somewhat messy development has the opposite effect. Regex may have been a good idea too. Hay ho, at least it works :).
Edit: replaced lambda variable with count builtin, and shortened split statement.

Ruby 115
n,a,c,i=[4,6,7,13],gets,'',0;a.chars{|x|x=='DIEINAGREASEFIRE'[i]?(i+=1;c+="\n"if n-[i]!=n;c+="\n#{x}"):c+=x};puts c

Ruby 95
a,c,i=gets,"",0;a.chars{|x|x=="DIEINAGREASEFIRE"[i]?(i+=1;c+="\n#{x}"):(c+=x)};puts c

J - 110 103 bytes
Why doesn't J have good functions to handle strings, but only array functions? I'll revise this if I figure out something smart.
Edit: Shortened and fixed output (it had extra spaces before) and checking. I also improved the explanation.
f=:[:>,&.>/@('IEIINAAGGREASEFFIRE'&t=:(}.@[t{.@[(}:@],(((0{I.@E.)({.;LF;}.)])>@{:))])`]@.(0=#@[))@< ::]

Explanation:

I'll denote function usage as [<left argument>] <function name> <right argument>, e.g. f <text>. I also won't explain every detail because the function is quite long.
@ applies the right function to the left function, eg. f@g x == f(g(x))
t=:(}.@[t{.@[(}:@],(((0{I.@E.)({.;LF;}.)])>@{:))])']@.(0=#@[) is a recursive function <delimiters> t <boxed string> that splits the string with every delimiter, in order. Fails if some delimiter is not found.
(((0{I.@E.)({.;LF;}.)])>@{:) splits the string from the left side of the delimiter, adding a linefeed between them.
>@{: gets the last string from a list (the one which hasn't been split yet)
0{I.@E. gets the index to split at, failing if the delimiter doesn't exist.
{.;LF;}. concatenates left side of the split, linefeed and right side of the split
}:@], concatenates results of the earlier splits and the result of the last function (last meaning: look up)
']@.(0=#@[) checks if there's any delimiters left, and calls the function described above (5 lines) if there is. Otherwise returns.
'IEIINAAGGREASEFFIRE'& sets the left argument of t to that string
[:>,&.>/@ joins the results of splitting
::] if something fails (I made the search for the split index the weak point), return the original string.

Examples (too long?):
   f 'Dear Boss, how are things? It has come to my attention that I received all the blame for the mishap last Friday. Not just the majority of it. Every last bit of it. Is it wrong for me to think that the rest of the team were at least in part responsible? After all, all six of us were involved from the get-go. Not that I think I should stand without blame. Not at all. All I''m saying is this: I do my best. I try hard. I improve constantly. And I am constantly taking responsibility. Generally speaking, I am very okay with taking full responsibility for my actions. But after this spring, it seems I get more than I deserve. Remember the Flakenhauser contract? Everything went down just about as smooth as one could have hoped. Or so it seemed at first. It was just at the very last minute that things fell apart. All of the team agreed that it was more akin to a freak accident than sloppy planning or mismanaged resources. Still, I - alone - took blame for it. Even though I said nothing then, my tolerance lev...
Dear Boss, how are things?
It has come to my attention that I received all the blame for the mishap last Friday. Not just the majority of it.
Every last bit of it.

Is it wrong for me to think that the rest of the team were at least in part responsible? After all, all six of us were involved from the get-go.
Not that I think I should stand without blame. Not at all.

All I'm saying is this: I do my best. I try hard. I improve constantly. And I am constantly taking responsibility.

Generally speaking, I am very okay with taking full responsibility for my actions. But after this spring, it seems I get more than I deserve.
Remember the Flakenhauser contract?
Everything went down just about as smooth as one could have hoped. Or so it seemed at first. It was just at the very last minute that things fell apart.
All of the team agreed that it was more akin to a freak accident than sloppy planning or mismanaged resources.
Still, I - alone - took blame for it.
Even though I said nothing then, my tolerance level for taking the blame took a serious dent then.

From that point on,
I have felt it necessary to always try twice as hard, just to escape scrutiny. And still, here we are again. In spite of all my accomplishments.
Right where we always seem to end up these days.
Every single project. It's becoming unbearable.
   f 'Die in a grease fire. It''s fun. Every time.'
Die in a grease fire. It's fun. Every time.
   f 'hai'
hai

Python3 (165)
def c(m,h,l=[]):
 if h:s=m.rindex(h[0]);l=[m[s:]]+l;return c(m[:s],h[1:],l)
 return[m]+l
i=input()
try:print('\n'.join(c(i,"ERIF ESAERG A NI EID")))
except:print(i)

Ungolfed
def headings_remaining(headings): return len(headings) > 0
def head(s): return s[0]
def tail(s): return s[1:]
def prepend(l,e): l.insert(0, e)
def reverse(s): return s[::-1]

def chunk(message,headings,output_list=[]):
    if headings_remaining(headings):
        split_index = message.rindex(head(headings))
        message_init = message[:split_index]
        message_last = message[split_index:]

        prepend(output_list, message_last)
        return chunk(message_init, tail(headings), output_list)
    else:
        prepend(output_list, message)
        return output_list

input_message=input()
try:
    headings=reverse("DIE IN A GREASE FIRE")
    print('\n'.join(chunk(input_message,headings)))
except ValueError: # Couldn't keep splitting chunks because didn't find heading
    print(input_message)

Explanation
chunk recursively splits off the end of the message containing the last heading and prepends it to a list.
Caveat: this won't work if there are no spaces at all between two proposed headings in your letter for some reason, but that seems unlikely in a letter to your boss.

JavaScript (ES6), 93 115 bytes
alert(prompt(x=[...'DIEI1NA1G1REASEF1IRE',i=0]).replace(/\b./g,a=>i<20&&a.match(x[i])?(+x[++i]?i++&&`

`:`
`)+a:a))

I used replace to step through the string, with a match for /\b./g so as to only find characters that either followed a space or began the string. Then I checked each character to see if it matched the current index in the array I was looking for, and added a newline before it if it did, and incremented i.
EDIT:
Missed the need to create newlines between words. I've done that now, which brings it up to 115.

PHP, 328 bytes
Given a file named 'G' containing the raw text to "enmessage"
<?php
$a=implode(file("G"));$b=str_split('DIEINAGREASEFIRE');foreach(array_unique($b) as $c){foreach(str_split($a) as $h=>$d){if($c==$d)$l[$c][]=$h;}}$e=-1;$n=$a;foreach($b as $f=>$c){foreach($l as $j=>$m){if($c==$j){foreach($m as $k=>$h){if($h>$e){$n=substr($n,0,$h)."\n".$c.substr($a,$h+1);$e=$h+2;break 2;}}}}}echo nl2br($n);

Explanation (~ungolfed && commented code) :
<?php
$string=implode(file("G"));          // raw text to deal with
$msg=str_split('DIEINAGREASEFIRE');  // hidden message (make it an array)

 // 2D array : [letters of the message][corresponding positions in txt]
foreach(array_unique($msg) as $letter) {
    foreach (str_split($string) as $pos=>$let) {
        if ($letter==$let) $l[$letter][]=$pos; //1 array per seeked letter with its positions in the string
    }
}

$currentPos=-1;
$newString=$string;
foreach ($msg as $key=>$letter) { // deal with each letter of the desired message to pass
    foreach($l as $cap=>$arrPos) {// search in letters list with their positions
        if($letter==$cap) {       // array of the current parsed letter of the message
            foreach($arrPos as $kk=>$pos) { // see every position
                if ($pos>$currentPos) {     // ok, use the letter at that position
                    $newString=substr($newString,0,$pos)."\n".$letter.substr($string,$pos+1); // add line break
                    $currentPos=$pos+2; // take new characters into account (\n)
                    break 2;            // parse next letter of the message
                }
            }
        }
    }
}                    /* (note that I could have added some other (random) line breaks management, so that
                      * the message is not TOO obvious... !*/
echo nl2br($newString);

PHP, 136 bytes
for($f=" ".join(file(F));$c=DIEINAGREASEFIRE[$i++];){while(($p=strpos($f,$c,$p))&&$f[$p-1]>" ");$p?$f[$p-1]="\n":$i=20;}echo$i<20?$f:"";

if the whole insult can be put; prints the modified string with a leading space or linebreak; empty output if not.
Run with -r.
breakdown
for($f=" ".join(file(F));       // read input from file "F"
    $c=DIEINAGREASEFIRE[$i++];) // loop through insult characters:
{
    while(($p=strpos($f,$c,$p))     // find next position of $c
        &&$f[$p-1]>" ");            // ... preceded by a space
    $p?$f[$p-1]="\n"                // if found, replace the space with a newline
    :$i=20;                         // else break the loop
}
echo$i<20?$f                // if modified text has the full insult, print it
    :"";                    // else print nothing

Zsh + sed, 167 ... 158 bytes
cp a z;b=DIE_IN_A_GREASE_FIRE
for c (${(s::)b}){sed -i "$ s/ $c/ \n$c/" a
((##$b[j++]==95))&&sed -i '$ i\\' a}
$b()<a;`<a|cut -c -1|sed 's/^$/_/g'|rs -g0`||<z

Try it Online!
The long email one-liner is stored in file a. Using sed -i '$ <blah>' always edits the last line of a. The last line $ is incrementally reduced as we insert \n characters.
Cut out quite a few bytes in the early versions of this solution. Added ~50 bytes for the 'original string' requirement. Ignored the STDIN thing per meta consensus.
Could be a lot shorter (101 bytes) if we ignore the requirement for extra line breaks
cp a z;b=DIEINAGREASEFIRE;for c (${(s::)b})sed -i "$ s/ $c/ \n$c/" a
$b()<a;`<a|cut -c -1|rs -g0`||<z

Old versions that don't fully meet the requirements:
 106 bytes
 115 bytes
 146 bytes
 153 bytes
 167 bytes

I notice this requires that the capital letters chosen are the first word in a sentence. This makes good sense, but it seems to me that the challenge doesn't actually say to do this, just to pick any words that are capitalized and fit correctly into the sequence. I suppose it could be left up to interpretation, but at least some of the other answers interpret this differently than you did.

Good point, I can save more bytes :)

Python - 190 Bytes
l,r="IExINxAxGREASExFIRE","\n";k=p=raw_input();y=i=0
for c in l:
    if c!="x":
        h=len(p);x=p[y:h].find(c)
        if x==-1:i+=1
        p=p[0:x+y-1]+r+p[x+y:h];y=x+y;r="\n"
    else:r=r+r
if i!=0:p=k

Ungolfed
This is my first golf attempt :) Looking to learn some great coding techniques, regardless, I just focused on using find and then some string splicing to find the appropriate characters and format the output.
Variables -
l.r = l is assigned characters we will be using as our guide to create our new formatted paragraph. r is assigned the new line character for us in spacing the new output.
k,p = The input paragraph. K is used to revert to the original as it is not reassigned during execution of the script. I check against x to know when to add a double new line for spacing purposes.
y,i = y is a "cursor" of sorts, keeps track of the last position a character was found so we find through the paragraph correctly for splicing purposes, i is sanity check, if we don't hit all of our characters we revert the paragraph (p variable) to it's original input via the k variable.
h = Input length, which we use in splicing.
x = The position of the current character represented by C, used for splicing as well.
c = Characters in l to iterate and search for.
The following code is reworded and broken out from the original code for readability to as what is happening:
letters,return="IExINxAxGREASExFIRE","\n"
input1=input2=raw_input()
lastpos=sanity=0

for char in letters:
    if char != "x":
        inputlength=len(input1)
        charposition=input1[lastpos:inputlength].find(char)
        if charposition==-1:
            sanity+=1
        input1=input1[0:position+lastpos-1]+return+input1[position+lastpos:inputlength]
        lastpos=position+lastpos
        return="\n"
    else:return=return+return
if sanity!=0:
    input1=input2

I would appreciate your feedback! I am looking to learn.

I offered an edit with some tricks in it. Just ask me if any of them needs an explanation. Note that it could be golfed further, by a lot, but I'll leave that down to you. :)

@TheRare Thanks! I really like the "i=+x<0" line you offered in your edit, as opposed to my "if x==-1:i+=1" line. Just to make sure i'm reading it right, this is one of the ternary things I was reading about last night, right? It basically reads, "if x is less than 0 (-1 returned when it cant find the char): add x to i" Correct? So it still satisfies the sanity check with a -1 or less for a value, right? Want to make sure I am reading that right, cause that is a great space saver!

Actually it adds x<0 to i. In python True is the same as 1 and False is the same as 0. So if x is -1, it adds 1 and otherwise 0. i+= is the same as i=i+

Try what True == 1 gives. :)


text:
Create a World Cup overview
I'm not to sure about the title so feel free to suggest a better one.
Task/challenge
Create an overview for the World Cup tracking the cup from the group phase till the finals.
Group phase
There are 8 groups (Group A, B, C, .., H) which can be found >> here <<
Each group has 4 teams/countries.
There will be 6 matches per group.
Scoring (for matches)
- Winning gives you 3 points
- Draw gives both teams 1 point
- Loss gives no points.
After those 6 matches the 2 teams with the highest score will go on to the second stage.
If there are 2 or more teams with the same score the decision will be made based on the match between those teams.
Lets say the Netherlands and Chile have equal points, then whoever won that match will go on to the second stage.
It can happen there is still a draw, in that case a decision will be made based on goal difference.
The goal difference is calculated by Goals_Scored - Goals_Conceded. (both goals during group phase)
There is a possibility that even this will keep a draw. In this case you will have to select the team manually in your program (or use the bonus {1})
Second Stage
During this round you can no longer gain points. You either win or lose.
If there is a draw after the regular playtime (90 minutes) there will be overtime. Overtime is 2x 15 minutes.
If there is no winner after that they will take penalties.
Each team takes 5 shots and the team with most goals wins.
If there is no winner after those 5 shots the teams will keep shooting until 1 team scores and the other doesn't.
For the penalties you can either manually select the winner or use the bonus.
All matches will stay like this from now on.
Useful information
After the group phase the matches will be as follows:
Round of 16
Number 1 Group A Vs. Number 2 Group B {Match 49}
Number 1 Group C Vs. Number 2 Group D {Match 50}
Number 1 Group E Vs. Number 2 Group F {Match 51}
Number 1 Group G Vs. Number 2 Group H {Match 52}
Number 1 Group B Vs. Number 2 Group A {Match 53}
Number 1 Group D Vs. Number 2 Group C {Match 54}
Number 1 Group F Vs. Number 2 Group E {Match 55}
Number 1 Group H Vs. Number 2 Group G {Match 56}
Quarter finals
Winner Match 49 Vs. Winner Match 50 {Match 57}
Winner Match 51 Vs. Winner Match 52 {Match 58}
Winner Match 53 Vs. Winner Match 54 {Match 59}
Winner Match 55 Vs. Winner Match 56 {Match 60}
Semi finals
Winner Match 57 Vs. Winner Match 58 {Match 61}
Winner Match 59 Vs. Winner Match 60 {Match 62}
3rd/4th place
Loser Match 61 Vs. Loser Match 62 {Match 63}
Finals
Winner Match 61 Vs. Winner Match 62 {Match 64}
Functionality
Your program should be able to do the following:
- Display the groups.
- Accept scores for group phase.
- Fill in the entire schedule for the second stage.
- Accept manually selecting a winner (if you're not using the bonus)
Scoring
This is code-golf so your score is based on the length of your code and the lowest score wins.
Bonus
The first bonus requires some explaining.
Its about the score difference bit. If there is no winner after that FIFA will look at the world ranking.
You will earn a bonus of -20 points if you use the world ranking to determine the winner.
The second bonus will get you -60 points, to gain this bonus you will need to be able to display how the team won in the second stage.
Either a normal win, Won by scoring in overtime (also show how many times was scored in overtime for both teams) or won by shooting penalties (show penalties scored for both teams)
This was quite a bit to write so I might got carried away and forgot to explain or tell a few things.
Feel free to ask and suggest things I might have forgotten or aren't clear yet.
Restrictions

You can't use external resources. So you're not allowed to download all the info from the internet or anything similar.
The one exception is that you are allowed to use the internet for looking up the world ranking if you're going after the bonus.

Remember the world cup is not a one day event. So try to make it user friendly.
Having the user type in all team names and all scores each time they run your program is not user friendly.
The assumption that the use will keep your program open at all times is false, say hello to windows auto update and black outs. :)
Have fun and happy coding.

Why subtract the country names from the code? Including it would add an interesting kolmogorov-complexity component to the challenge, I think. Also I don't think fetching and evaluating the web request for the first bonus is remotely possible in 20 characters.

@m.buettner Agreed to the bonus, any suggestion how many points it should award? And im not familiar with the kolmogorov-complexity, I will look it up and edit the challenge accordingly.

With kolmogorov-complexity, I was just implying that it would be an interesting part of the challenge to compress the country names and setting up the groups.

@m.buettner I will remove the bit of subtracting the names, should I also add the Kolmogorov tag to this challenge then?

I'd like to solve this challenge in C#/WinForms. Do I have to include the generated code for the GUI into my score?

I suppose you mean the styling of your forms right? In that case no you don't have to include that.

Maybe this should be updated for the Rugby World Cup which is just starting now...

source: Stack Exchange

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

sort: votes


text:
Disco Zoo animal hunt
This question is inspired by the game Disco Zoo
Background
Disco Zoo is a game where you can go into the wild and rescue animals. Once you have found an animal you can put it in your zoo for your visitors to see.
To find animals you first select a field to search, and you get to see a 5x5 grid where the animals are hiding. At the top of the screen you can see which animals are hiding in the field.
Each animal has a different pattern, which never changes for the same animal. E.g. (X is pattern, o is padding)
Animal=Sheep    Animal=Unicorn
Pattern:        Pattern:

 XXXX            Xoo
                 oXX

Some animals use 2 blocks, some 3 and some 4. The pattern will be translated, but not rotated.
Task
The user gives you a pattern or the name of an animal (your choice) and you have to generate an optimum strategy to search for that animal/pattern. A strategy is a set of blocks from the 5x5 grid; an optimum strategy is one which guarantees to find at least 1 block from the pattern, and where there is no strategy with fewer blocks which can make the same guarantee.
For sheep and unicorns the optimum strategy would be searching the middle column:
ooXoo
ooXoo
ooXoo
ooXoo
ooXoo

Another example:
Animal: Hippo
Pattern:       Optimum strategy:
               ooooo
 XoX           oXXoo
 ooo           oXXoo
 XoX           ooooo
               ooooo

The Disco Zoo wiki's Patterns page lists all the animals and their patterns. You may hard-code the patterns. The wiki also lists optimum strategies for all the animals. Feel free to look at them but you're not allowed to hard-code them.
Input: Either a pattern made of X and O or the name of the animal.
Output: a 5x5 grid made of X or O where X marks an optimum strategy.

This is a very nice problem, I wrote a program able to find a solution for every pattern, however it cannot find optimals one (well, it actually is finding optimals solution, but for the somehow harder problem where patterns can wrap around borders...)

Ruby 221
->a{l=a.join(?o*(5-w=a[0].size))
s=?o*25
q=(0..25-l.size).select{|i|i/5==(i+w-1)/5}.map{|i|(?o*i+l+s)}
(h=q[0].size.times.map{|i|q.count{|p|p[i]<?o}}
s[c=h.index(h.max)]=?X
q.reject!{|p|p[c]<?o})while q!=[]
s.scan /.{5}/}

Input and Output
This is a Ruby function that takes one parameter representing the animal and returns the solution, both being represented as string arrays.
For example, the Hippo is represented as:
['XoX',
 'ooo',
 'XoX']

and its solution is:
['ooooo',
 'oXXoo',
 'oXXoo',
 'ooooo',
 'ooooo']

Test
Here's a working version. Feel free to experiment with it and enter more animals as parameters.
Algorithm
I found this problem very interesting and I experimented to solve it in different ways, including brute force, which is less feasible, but possible for the given inputs (it would be terribly inefficient for the input ['X'] though).
The algorithm I found to be the most efficient is the following:

Compute all possible positions for the animal on the 5x5 board
Given the existing positions, compute a map of frequencies for each of the 25 cells
Take one of the cells that contain the max number of "hits" and make it part of the solution. Exclude all positions that are "hit" in that particular cell.
Repeat steps 2-3 until there are no positions left.

I don't have a proof of optimality for this algorithm, but it tested most animals present on the wiki page and it returned optimal solutions for all.
Note that for some animals the solutions are not identical to the ones presented in the wiki, but involve the same number of blocks.
For example, the Wooly Rhino page presents this solution:
ooooo
ooooo
oXXXo
ooooo
ooooo

and the algorithm returns this one:
ooooo
oooXo
ooXXo
ooooo
ooooo

which is also correct and optimal (3 blocks).
Here's the (slightly more) readable version of the program:
SIZE = 5

# return all possible placements for the animal on a 5x5 board
def get_placements(animal)
  # represent the 5x5 board and the animal as linear arrays
  linear_animal = animal.join(?o*(SIZE - animal[0].size))
  d = SIZE*SIZE
  (0..d-linear_animal.size)
    .select{|i| i/5 == (i+animal[0].size-1)/5} # to avoid wrap-around positions
    .map { |i|
      (?o*i + linear_animal + ?o*d)[0...d]
    }
end

# given a set of possible placements,
# return a map of frequencies for every cell
def heatmap(placements)
  placements[0].size.times.map do |i|
    placements.count {|p|p[i] < ?o}
  end
end

# given an animal, return the solution as an array of 5 5-character strings
def solve(animal)
  placements = get_placements animal
  solution = []

  while placements.any?
    h = heatmap(placements)

    solution << chosen = h.index(h.max)

    placements = placements.reject {|pl| pl[chosen] < ?o }
  end

  (0...25).map{|i| solution.include?(i) ? ?X : ?o }.join.scan /.{5}/
end

Python3, 474 bytes
R=range
E=enumerate
V=lambda d,p,X,Y:not all((x+X,y+Y)in d for x,y in p)
def f(p):
 d={(x,y):[]for x in R(5)for y in R(5)}
 p=[(x,y)for x,r in E(p)for y,v in E(r)if'X'==v]
 X,Y,C=0,0,0
 while 1:
  C+=1
  Q,W=[],[]
  for x,y in p:d[(x+X,y+Y)]+=[C]
  Y+=1
  if V(d,p,X,Y):
   if V(d,p,X:=X+1,Y:=0):break
 M=[]
 while any(d.values()):t=max(d,key=lambda x:len(d[x]));M+=[t];d={i:{*d[i]}-{*d[t]}for i in d}
 s=[['0'for _ in R(5)]for _ in R(5)]
 for x,y in M:s[x][y]='1'
 return s

Try it online!

all_licenses: 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/


text:
Let's move the Mars rover!
Summary
The task is to navigate the Mars rover and tell its final coordinates and direction.
Input:
First input:
First your program must take the input which will be in the following format:
[X-Coordinate],[Y-Coordinate],[Direction]

The direction must be: N or S or E or W (Starting letters of North, South, West, East)
Example:  10,20,N ( x = 10, y = 20, direction = N(North))
Second input:
The second input consists of series of R, L, M for right, left and move respectively.
For R and L (right and left) the direction of rover must change accordingly.
For M the rover must move 1 unit ahead in the direction which it was before moving.
Rules for calculating coordinates:
N = Y + 1
E = X + 1
S = Y - 1
W = X - 1

Output:
The final coordinates and the current direction of the rover.

Example:
Enter initial data:      1,2,N

Enter the instructions:  MRMLM

Output:                  2,4,N

The coordinates can be any integer and can be negative.
All the standard loopholes aren't allowed. If providing demo on sites like http://ideone.com etc. is possible, then please do so, so that I can verify :)
This is a popularity contest so be creative!
Following others' advice, I decide to make this a code-golf.

Are there limits to the coordinates?

This might be more interesting as [tag:code-golf] instead of [tag:popularity-contest]. What kind of bonus is given for the use of ideone?

@KyleKanos I saw people using it, so just used. Rephrased it ;)

@TeunPronk you can check my edit now.

You know, if you're experiencing negative feedback on your challenges, try running them through the sandbox first.

@m.buettner thanks! I'm not that active here, so didn't knew it. But I thought this will be well received but I was wrong ;)

I believe your example output is wrong. It should be 0,2,N

@TeunPronk nope. It is correct mate. First move, so it becomes 1,3,N  next turn right which means 1,3,E then move in the same direction so 2,3,E, now turn left so it becomes 2,3,N now move which makes it 2,4,N

Well im seeing this as a top view. If its moving north the Y value will be decreased

@TeunPronk how will moving north decrease Y by 1? It will increment it.

@AmitJoki It depends on which way positive-y is. For example, in computer graphics y is often decreasing as it moves up. You should explicitly state that N = +Y, E = +X if that's your intention.

Well if you look at a compass North is pointing up. the top left of a grid is usually indexed as 0,0. So moving up will decrease the number

@Geobits thanks. Stated explicitly.

@TeunPronk sorry, I hadn't known that. I've added it explicitly now.

For future reference, this is called the Cartesian Coordinate system (AKA world-coordinates).  @TeunPronk was thinking of screen-coordinates.

Changing rules (popularity-contest to code-golf) after publishing the task is not really friendly. Please think longer before publishing puzzles and dont change them afterwards...

Thoughtworks interview question?

@BobbyAlexander nope! This was a problem given in a pamphlet from a computer institute for their advertisement. I successfully completed this in C#. This problem was what kindled my interest in programming, so its special. BTW, do you really think I would be attending interviews when I'm a school boy ;)

@AmitJoki: No I didn't. I was just wondering about the source of the question. This is a popular interview question for Thoughtworks.

Hardmode - tracks the lat long, M moves 1 meter in that direction, takes into account the spherical nature of the planet. Godmode - downloads elevation data and kills the program if you fall off a cliff. >:-)

And since the robot is at the north pole, and there is no way to go further north, all answers are actually invalid.  ;-)

@TeunPronk I don't know whether there are limits to the coordinates, but this is a popularity contest, and making the rover fall off the edge of Mars and come crashing towards Earth probably won't increase your popularity.

Ruby ≥ 2.0, 101
E,N,W,S=*0..3
x,y,i=eval"a="+gets
gets.bytes{|c|x+=c%2*1i**i=i+1-c&3}
$><<[(x+y.i).rect,"NWSE"[i]]*?,

This solution can be tested here: https://ideone.com/C4PLdE
Note that the solution linked on ideone is one character longer (1.i instead of 1i in line 3). The reason for this is that ideone only supports Ruby 1.9, which doesn't allow the short-hand syntax for complex literals.

waiting to see it golf further :)

You can replace x,y,i=eval"[#{gets}]" with eval"x,y,i="+gets to save some chars.

@voidpigeon: I'm not sure that actually works due to eval's scoping rules: ruby -e 'eval"x=1";p x' throws a NameError for x at p x. It does work when using constants (eval"X,Y,I="+gets), but since I modify i, this would require an additional i=I to prevent warnings about redefining a constant. But maybe we're talking about different Ruby versions?

@Ventero You're right. I tested it in irb and it gave me the proper array as output so I assumed it worked. I really like the eval approach though.

@voidpigeon Ah, you're right, that actually allows a slightly different optimization: x,y,i=eval"*a="+gets. Thanks!

Javascript (ES6) 145 141 127
Edit: Removed the need for a translation array using method from edc65's C solution
[x,y,d]=(p=prompt)(s='NESW').split(','),[...p(d=s.search(d))].map(c=>c!='M'?(d+=c>'M'||3,d%=4):d%2?x-=d-2:y-=d-1),p([x,y,s[d]])

Ungolfed/Commented:
s='NESW' // initialize variable for direction mapping
[x,y,d]=prompt().split(',') // get first input, split by commas, map to variables x,y,d
d=s.search(d) // get numeric value for direction
[...prompt()].map(c=> // get second input, map a function to every character in it
    c!='M'? // if char is not M
        (d+=c>'M'||3, // increment d by 1 if char greater than M, otherwise 3
         d%=4) // modulo by 4 to wrap direction
    : // else
        d%2? // if odd direction
            x-=d-2 // move x position
        : // else
            y-=d-1 // move y position
)
prompt([x,y,s[d]]) // output result

you can do this?! [a,b,c] = x.split(...)

@edc65 Yup! Destructuring Assignment

Have a look at my C answer. maybe the g array is not needed

Javascript (E6) 175
Edit
Fixed bug, possibly out of range return value for d
139 Logic, 36 I/O
F=(x,y,d,m,D='NESW')=>(d=D.search(d),[...m].map(s=>({M:_=>(y-=[-1,0,1,0][d],x-=[0,-1,0,1][d]),R:_=>d+=1,L:_=>d+=3}[s](),d%=4)),[x,y,D[d]]);
p=prompt,p(F(...p().split(','),p()))

Basic ungolfed
function F(x,y,d,m) // In golf code use arrow sintax instead of 'function'
{
  var D='NESW';
  d = D.search(d); // map from letters to offset position 0..3
  var driver = { // driver object, each function map one of  command letters M,R,L
    M: function() {
      y -= [-1, 0, 1, 0][d]; // subtract to be sure to have a numeric and not string result
      x -= [0, -1, 0, 1][d]; // subtract to be sure to have a numeric and not string result
    },
    R: function() {
       d += 1;
    },
    L: function() {
       d += 3; // with modulo 4 will be like -= 1
    }
  }
  m = [...m]; // string to array, to use iteration function
  m.forEach(  // array scan, in golf versione use map do nearly the same and is shorter
    function (s) {
      driver[s](); // call driver function
      d = d % 4;   // restrict value to modulo 4
    }
  );  // in golf version, use comma separated expression to avoid 'return'
  return [x,y, D[d]] // return last status
}

Test
Test in javascript console in Firefox. It's simpler to test the function F avoiding the popups.
F(1,2,'N','MRMLM')

Output
[ 2, 4, "N" ]

Nice, this looks a lot like my solution.

Java - 327
class R{public static void main(String[]a){char c,e=a[2].charAt(0),z[]={78,69,83,87};Integer x=Integer.valueOf(a[0]),y=x.valueOf(a[1]),d=e<70?1:e==83?2:e>86?3:0,i=0;for(;i<a[3].length();d=c>81?(d+1)%4:c<77?(d+3)%4:d){c=a[3].charAt(i++);if(c==77){x=d==1?x+1:d>2?x-1:x;y=d<1?y+1:d==2?y+1:y;}}System.out.print(x+","+y+","+z[d]);}}

With whitespace:
class R{
    public static void main(String[]a){
        char c,e=a[2].charAt(0),z[]={78,69,83,87};
        Integer x=Integer.valueOf(a[0]),y=x.valueOf(a[1]),d=e<70?1:e==83?2:e>86?3:0,i=0;
        for(;i<a[3].length();d=c>81?(d+1)%4:c<77?(d+3)%4:d){
            c=a[3].charAt(i++);
            if(c==77){
                x=d==1?x+1:d>2?x-1:x;
                y=d<1?y+1:d==2?y+1:y;
            }
        }
        System.out.print(x+","+y+","+z[d]);
    }
}

As usual with Java, about half of this is just parsing the input and forming the output. The logic is pretty straightforward.

C 164 180 186
Edit Fixed input format and removed strchr
Edit Removed offset array, calc using bits
p,x,y;main(){char c,d,l[100];scanf("%d,%d,%c%s",&x,&y,&d,l);for(d=d<83?d&1:d>>2&1|2;c=l[p++];d&=3)c-77?d+=c+1:d&1?x+=d-2:(y+=1-d);printf("%d %d %c",x,y,"NESW"[d]);}

Ungolfed
p, x, y;
main()
{
  char c, d, l[100];
  scanf("%d,%d,%c%s",&x,&y,&d,l);
  for (d = d<'S'?d&1:d>>2&1|2; c = l[p++]; d &= 3)
    c-'M'
    ? d += c+1
    : d & 1 ? x+=d-2 : (y+=1-d);
  printf("%d %d %c", x, y, "NESW"[d]);
}
/*
M 77
R 82 0101 0010 R&3+1==3
L 76 0100 1100 L&3+1==1
*/

C, 148 150 151
p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%23)x[d&1]-=c%2*~-(d&2);printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach.
Specifically:

d%8%5 maps the characters ENWS to 0,1,2,3 respectively
c%23 turns L into 7, M into 8 and R into 13. Because d (the direction variable) is always used mod 4, this effectively makes L add -1 mod 4, M add 0 mod 4, and R add 1 mod 4.
d&1 is 1 for NS and 0 for EW directions.
d&2 is 2 for WS and 0 for NE directions.
~-(d&2) is 1 for WS and -1 for NE directions.
c%2 is 1 for M and 0 for LR.

Why 23, and what is c%(2*(1-(d&2)))

@tolos: Added some explanation. Also shortened by 2 characters :)

Python 3 (with turtle graphics), 251 199 bytes
Wise pythonistas, please be gentle, for this is my first ever attempt at a program written in your fine language.
Turtles on Mars!
from turtle import*
p="NESW"
mode("logo")
x,y,d=input().split(',')
setx(int(x))
sety(int(y))
seth(p.find(d)*90)
for c in input():fd(1)if c=="M"else[lt,rt][c>'L'](90)
print(pos(),p[int(heading()/90)])

This challenge maps quite naturally to logo-style turtle graphics, for which python has an import, of course.
Reads input from two lines from STDIN.
Output:
$ { echo 1,2,N; echo MRMLM; } | python ./rover.py
(2.00,4.00) N
$

What I especially like about this program is it actually graphically displays the rover's path.  Add exitonclick() to the end of the program so the graphical output persists until user click:

I'm pretty sure this can be golfed significantly more - any suggestions welcome!  I'm making this CW, because I hope the community can golf it some more.
Changes:

s is now a list, inlined.
Used ternary for body of for loop.
Inlined n, removed unnecessary slice.
Removed unnecessary space in import statement.
Removed import string to use builtin string method
Switched to Python 3 to shorten raw_input

GolfScript, 116 98 88 84 71
~'NESW':^@?:&;{4%[{&(4%:&;}{&[{)}{\)\}{(}{\(\}]=~}{&)4%:&;}]=~}/]`&^1/=

This should get the coordinates and the instructions as arguments the following way:1 2 'N' 'MRMLM'.
The arguments are made into a string and are pushed into the stack.
If you want to test this online, go to web golfscript and paste a semicolon followed with a string with the arguments (e.g. ;"1 2 'N' 'MRMLM'") before the code (here's a link with an example).
Examples of output:
1 2 'N' 'MRMLM'                    -> [2 4]N
5 6 'E' 'MMLMRMRRMMML'             -> [5 7]S
1 2 'N' 'MMMMRLMRLMMRMRMLMRMRMMRM' -> [1 8]N

My Previous Attempts
84 chars:
~:i;'NESW':k\?:d;{i(\:i;4%[{d(4%:d;}{d[{)}{\)\}{(}{\(\}]=~}{d)4%:d;}]=~i}do]`d k 1/=

88 chars:
~:i;'NESW':k\?:d;{i(\:i;'MRL'?[{d[{)}{\)\}{(}{\(\}]=~}{d)4%:d;}{d(4%:d;}]=~i}do]`d k 1/=

98 chars:
 ~1/:i;:d;{'NESW'd?}:k;{k[{)}{\)\}{(}{\(\}]=~}:M;{k'ESWN'1/=:d;}:R;{k'WNES'1/=:d;}:L;{i(\:i;~i}do d

116 chars:
[~])\~"NESW":k 1/:d?{d(1/+:d;}:f*:y;:x;{("MRL"?[{k d 0=?[{y):y}{x):x}{y(:y}{x(:x}]=~;}{f}{d)1/\+:d;}]=~.}do x y d 0=

btw: the old versions of the post are stored so you can see howthey were in the past (just click on the "Edited xxx ago" link)

Javascript (353)
This is my first real attempt at code golf, seems to work at least!
var xx=[0,1,0,-1];var yy=[1,0,-1,0];var d=["N","E","S","W"];var e=0;var x,y=0;function sa(p){q=p.split(",");x=+q[0];y=+q[1];e=+d.indexOf(q[2]);}function sb(t){var g=t.split(",");for(var u=0;u<g.length;u++){if(g[u]=='R'){e++;if(e>3)e=0;}if(g[u]=='L'){e--;if(e<0)e=3;}if(g[u]=='M'){x+=+xx[e];y+=+yy[e];}}alert(x+","+y+","+d[e]);}sa(prompt());sb(prompt());

I can see unnecessarily long variables names ;). Also, in code golf nobody cares about proper variable scoping, so drop those var s.

Python (263)
input =  raw_input("Initial: ")
input2 = raw_input("Command: ")

position = [int(input[0]), int(input[2]), input[4]]

bearings = "NESW"
turns = {"L" : -1, "M": 0, "R" : 1}
move = {"N" : [0, 1], "E" : [1, 0], "S" : [0, -1], "W" : [-1, 0]}

for c in input2:
    turn = turns[c];
    if (turn == 0):
        position[0] += move[position[2]][0]
        position[1] += move[position[2]][1]
    else:
        position[2] = bearings[(bearings.index(position[2]) + turn)%4]

print "Output: ", ','.join((str(s) for s in position))

There must be a more elegant way of doing this also, it doesn't need the branch after the else.
http://ideone.com/eD0FwD
The input is awful, I wanted to do it with split(',') but came across casting issues between the ints and strings. Ideally I also wanted to add the old position with the moving position... oh it's code-golf now. Oh well whatever, I'll leave it here, might give inspiration. Other ideas I had were using modulo 4 of the direction after mapping the initial bearing to an index. Also merging the turns and move arrays to one since none of the keys collide.
even so, shortening variable names and removing spaces it's 263:
i=raw_input()
j=raw_input()
p=[int(i[0]),int(i[2]),i[4]]
b="NESW"
m={"N":[0,1],"E":[1,0],"S":[0,-1],"W":[-1,0],"L":-1,"M":0,"R":1}
for c in j:
    if (m[c]==0):
        p[0]+=m[p[2]][0]
        p[1]+=m[p[2]][1]
    p[2] = b[(b.index(p[2])+m[c])%4]
print ','.join(str(s) for s in p)

C - 350
Save as rover.c:
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){char c,*C="NWSE-WN";float x,y,d,k=M_PI/2;scanf("%f,%f,%c",&x,&y,&c);d=(strchr(C,c)-C)*k;do{switch(getchar()){case'R':d+=k;break;case'L':d-=k;break;case'M':x+=sin(d);y+=cos(d);break;case EOF:printf("%g,%g,%c\n",x,y,C[(int)(sin(d)+2*cos(d)+4.5)]);}}while(!feof(stdin));return 0;}

Compile:
gcc -o rover rover.c -lm

Sample run:
$ echo 1,2,N MRMLM | ./rover
2,4,N

Ideone
Ungolfed:
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
    /* String is used for input and output, pi/2 == 90 degrees */
    char c, *C = "NWSE-WN";
    float x, y, d, k = M_PI/2;

    /* Get starting parameters */
    scanf("%f,%f,%c", &x, &y, &c);

    /* Convert the direction NWSE into radians */
    d = (strchr(C, c) - C) * k;

    /* Process each character */
    do
    {
        /* Recognize R(ight), L(eft), M(ove) or EOF */
        switch (getchar())
        {
            case 'R':
                /* Turn right 90 degrees */
                d += k;
                break;

            case 'L':
                /* Turn left 90 degrees */
                d -= k;
                break;

            case 'M':
                /* Advance 1 unit in the direction specified */
                x += sin(d);
                y += cos(d);
                break;

            case EOF:
                /* Output - formula is specially crafted so that S,E,W,N
                    map to indices 2,3,5,6 to reuse part of string */
                printf("%g,%g,%c\n", x, y, C[(int)(sin(d) + 2*cos(d) + 4.5)]);
        }
    }
    while (!feof(stdin));

    return 0;
}

Python 2.7 - 197 192 bytes
q='NESW';x,y,d=raw_input().split(',');x=int(x);y=int(y);d=q.find(d);v={0:'y+',1:'x+',2:'y-',3:'x-'}
for c in raw_input():exec['d+','d-',v[d]]['RL'.find(c)]+'=1;d=d%4'
print`x`+','+`y`+','+q[d]

I'm actually super proud of this one.
Explanation
First, let's clean up this mess. I used semicolons instead of line breaks in a lot of places because I think it makes me cool. Here it is normally (this is still 197 bytes, it hasn't been ungolfed at all). Yes, there's still a semicolon, but that one actually saves a byte.
q='NESW'
x,y,d=raw_input().split(',')
x=int(x)
y=int(y)
d=q.find(d)
v={0:'y+',1:'x+',2:'y-',3:'x-'}
for c in raw_input():m=v[d];exec['d+','d-',m]['RL'.find(c)]+'=1;d=d%4'
print`x`+','+`y`+','+q[d]

Let's begin!
q='NESW'

First we define q as the string 'NESW'. We use it twice later, and len("q='NESW';qq") < len("'NESW''NESW'").
x,y,d=raw_input().split(',')

Here we split the first line of inpupt at each comma. Our x coord is stored in x, y in y, and the first letter of our direction in d.
x=int(x)
y=int(y)

Then we just make the coords ints. (I was shocked that I couldn't think of a better way to convert two strings to ints. I tried x,y=map(int,(x,y)) but that turns out to be longer.)
d=q.find(d)

This converts our direction to an integer. 0 is north, 1 is east, 2 is south and 3 is west.
v={0:'y+',1:'x+',2:'y-',3:'x-'}

This is where the fun starts.
When we go north, Y increases by 1. So this dictionary takes 0 and gives the string 'y+', for "increase y". It gives similar results for other directions: y or x followed by + or -.
We'll come back to this.
for c in raw_input():
    m=v[d]
    exec['d+','d-',m]['RL'.find(c)]+'=1;d=d%4'

I've gone to the liberty of ungolfing this one slightly.
For each character in the second line of input, we do two things. First, we set the variable m to whatever our dictionary from before gives us for our current direction. There's no reason we need this to happen every time, but it's easier than just making it happen when we need it.
Next, we create a list with three elements: 'd+', 'd-', and m. EDITOR'S NOTE: I think I can get away with not using the variable m at all. I think I can just put v[d] in the list directly. That'll save me a couple bytes if it works, but I don't feel like testing it until I'm done this explanation so y'all can deal. (Yep, it worked.)
We look for the current character of the input in the string 'RL'. str.find returns -1 if it doesn't find the character, so this converts an R to a 0, an L to a 1 and anything else to -1. Of course, the only other input we can have is M, but it's less characters to make it work for everything.
We use that number as the index for the list we created. Python list indices start at the end if they're negative, so we get the first element if the input is R, the second if it's L, and the last if it's M. For for convenience's sake, I'm about to assume that we're facing north, but a similar principle applies for other directions.
The possible values we're working with are 'd+' for R, 'd-' for L and 'y+' for M. Then, we attach '=1;d=d%4' to the end of each one. That means our possible values are...
d+=1;d=d%4
d-=1;d=d%4
y+=1;d=d%4

That's valid python code! That's valid python code that does exactly what we want to do for each of those input characters! (The d=d%4 part just keeps our directions sane. Again, don't need to do it every time, but it's less characters.)
All we have to do is execute the code we get for each character, print it out (converting our direction back to a string), and we're done!

Bash+coreutils, 159 bytes
t()(tr $2 0-3 $1<<<$d)
IFS=, read x y d
d=`t '' NESW`
for s in `fold -1`;{
[ $s = M ]&&((`t yxyx;t ++-`=1))||d=$[(d`tr LR -+<<<$s`1+4)%4]
}
echo $x,$y,`t NESW`

Input is read from 2 lines of STDIN.
Output:
$ { echo 1,2,N; echo MRMLM; } | ./rover.sh
2,4,N
$

Haskell - 412 bytes
import Text.Parsec
import Text.Parsec.String
n='N'
s='S'
e='E'
w='W'
d(x,y,c)'M'|c==n=(x,y+1,c)|c==s=(x,y-1,c)|c==e=(x+1,y,c)|c==w=(x-1,y,c)
d(x,y,c)e=(x,y,i c e)
i 'N''R'=e
i 'N''L'=w
i 'S''R'=w
i 'S''L'=e
i 'E''R'=s
i 'E''L'=n
i 'W''R'=n
i 'W''L'=s
f=many digit
g=char ','
o=oneOf
main=interact(\s->show$parse(do x<-f;g;y<-f;g;c<-o"NSEW";newline;b<-many$o"MRL";return$foldl(\x c->d x c)(read x,read y,c)b)""s)

Tested with :
$ printf "1,2,N\nMRMLM" | ./rv
Right (2,4,'N')

Hah hah!   Great to see Haskell so far behind the pack, for a change :D

f=many digit MUCH LOL - SUCH WOW

Splitting the input and using read multiple times took more characters to do than using parsec...

Python 2.7, 170 149
N,E,S,W=q='NESW'
x,y,d=input()
d=q.find(d)
for c in raw_input():exec['d+','d-','yx'[d%2]+'+-'[d/2]]['RL'.find(c)]+'=1;d%=4'
print`x`+','+`y`+','+q[d]

Things I changed from the original:
Aliased raw_input, changed the v[d] dictionary, which should have been a list anyways, to some string selection, used %=.
Edit: used tuple unpacking and eval(raw_input())==input() to save 21 characters.
Heavily borrowed from @undergroundmonorail, but with lots of improvements.

Nice! I like this a lot.

Python, 135 137 138
S,W,N,E=0,1,2,3;a,b,d=input();v=[b,a]
for c in map(ord,raw_input()):d+=c%23;v[d&1]+=c%2*~-(d&2)
print'%d,%d,%s'%(v[1],v[0],'SWNE'[d&3])

Abuses the ASCII values of L, M and R to avoid using any conditional statements.
Try it in ideone.

PowerShell, 170 167 166
[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{iex(-split'$y++ $x++ $y-- $x--')[$d%4]}}
"$x,$y,"+'NESW'[$d%4]

Can't seem to golf this down further, which is a bit embarrassing. But all the obvious hacks don't really work here.
I can't iex the input because a) N, S, E and W would have to be functions for that to work (or I'd need to prefix that with $ and b) 1,2,N would have to parse the N in expression mode, not being able to run a command.
The switch seems to be the shortest way of doing the movement. Hash table with script blocks or strings isn't shorter either and for every other way apart from the switch I'd have the overhead of the explicit loop.
I can't get rid of the IndexOf because a pipeline with ? is longer, still.
I also can't get rid of the explicit types in the initial declaration because I have mixed types there, so a simple |%{+$_} doesn't help and every other option is longer.
Sometimes I hate input handling in PowerShell.

Python3 (288)
Implementation using heavy use of ternary ifs.
m=['N','E','S','W']
cords=[int(n) for n in input().split()] + [input()] #Convert first inputs to integers and retrieve third
for n in input(): #Get instructions
    if n=='M':
        i=[1,0][cords[2] in m[1:3]] #See if vertical or horizontal
        j=[-1,1][cords[2] in m[0:2]] #See if negative or positive
        cords[i]+=j
    else:
        i=[-1,1][n=='R'] #Translate turn to numerals
        cords[2]=m[m.index(cords[2])+i] #Change direction relative to current orientation
print(cords)

Omitting the obvious input grumbles, giving the direction strings intrinsic values may have benefited the script size. However, the approach here is perfectly functional (so I believe)

Welcome to PPCG.  This is code-golf, so the shortest answer wins.  You can start by making your variable names one char long.

Bash/SHELF, 243 235
"SHEll goLF" is a golfing library for Bash which provides a few useful aliases. This is a valid answer as the library existed and was on GitHub before the challenge was posted.
Sorry, I can't get this to work on ideone.
How to run
This takes the initial position (separated by commas as specified; this adds a lot of characters to the code) as its first argument, and the instructions on standard input.
source shelf.sh #you must load SHELF first
source rover.sh 1,2,N<<<MRMLM #now run the script via source so it has access to SHELF

Sample output
2,4,N

Code
o=$1
D(){ o=`y NESW $1<<<$o`;}
for x in `Y . '& '`;{
d $x R&&D ESWN
d $x L&&D WNES
d $x M&&z=(`y , \ <<<$o`)&&case ${z[2]} in N) z[1]=$[z[1]+1];;S) z[1]=$[z[1]-1];;W) z[0]=$[z[0]-1];;E) z[0]=$[z[0]+1];;esac&&o=`P ${z[@]}|y \  ,`
}
p $o

Explanation
d is for comparison; it returns 0 if its two arguments are equal and 1 otherwise, it can then have other commands chained onto it with && and ||.
y is like tr (but done through sed).
Y is like sed 's/.../.../g' for its two arguments.
P is echo -e -n; p is just echo -e.
o=$1 #save first argument to variable
D(){ o=`y NESW $1<<<$o`;} #define an alias to turn R or L
for x in `Y . '& '`;{ #add a space after every character on stdin and loop for each one
d $x R&&D ESWN #turn R using alias
d $x L&&D WNES #turn L using alias

The next bit is profoundly ugly, with about 145 chars on one line. If the current command is M, turn the commas in $o into spaces, convert to array and save to $z. Then, do a switch...case block for the last element of $z (the direction the rover is pointing. Change coordinates accordingly, then convert $z back into a comma-separated string and save to $o.
d $x M&&z=(`y , \ <<<$o`)&&case ${z[2]} in N) z[1]=$[z[1]+1];;S) z[1]=$[z[1]-1];;W) z[0]=$[z[0]-1];;E) z[0]=$[z[0]+1];;esac&&o=`P ${z[@]}|y \  ,`
} #end loop
p $o #print output

Shouldn't the sourcing of shelf.sh be part of the solution instead? Like you'd have to require certain packages in Ruby or import them in Python as well if you need them.

@Joey good point, but I don't think people import PYG when writing a Python program with it, or Rebmu (AFAIK) when writing a Rebol program with it

Haskell, 291
data D=W|S|E|N deriving(Show,Read,Enum)
main=interact$(\(x,y)->tail$map show y++[show(toEnum x::D)]>>=(',':)).(\(a:b:_)->foldl(\(f,j@[g,h])i->case i of 'M'->(f,[g+rem(f-1)2,h+rem(f-2)2]);'L'->(mod(f+1)4,j);'R'->(mod(f-1)4,j))((\(c,d,e)->(fromEnum(e::D),[c::Int,d]))$read('(':a++")"))b).lines

I wasn't sure how flexible the input and output string format was, so I made sure it looked exactly like the example (minus the prompts, of course), but that added a lot of extra characters. Ideone link

PHP - 224
Well, I gave it a try.
$n=explode(",",$argv[1]);$d=($e=$n[2])==W?0:($e==N?1:($e==E?2:3));for(;$i<strlen($n[3]);)if(($o=$n[3][$i++])==M)$n[$d%2]+=$d>1?-1:1;else$d=$o==R?($d+1)%4:($d==0?3:$d-1);echo"{$n[0]},{$n[1]},".($d==1?N:($d==2?E:($d==3?S:W)));

Input in STDIN, e.g.:
$ php mars_rover.php 1,2,N,MMMRRRRRMM
-1,5,E
$ php mars_rover.php 1,2,N,MMMMRLMRLMMRMRMLMRMRMMRM
1,8,N
$ php mars_rover.php 3,-2,W,MMMMLM
7,-3,S

Python 3 (143)
I=input
a,b,D=I().split(',')
w='ENWS'
d=w.find(D)
x=int(a)+int(b)*1j
for c in I():x+=(c=='M')*1j**d;d+='ML'.find(c)
print(x.real,x.imag,w[d%4])

http://ideone.com/wYvt7J
We use Python's built-in complex number type to store the pair of coordinates. The direction is computed by taking the imaginary unit 1j to the power of d, which stores the direction mod 4. Rotating is done by incrementing or decrementing d. The expression 'ML'.find(c) gives the amount we want to change d: 1 for L, 0 for M, and -1 (the default for not found) for R.
Python doesn't have a short way to convert a complex number to a tuple, so we have to make costly calls to .real and .imag.


text:
Generate four type-4 GUIDs for me
The type 4 GUID is described by Wikipedia, quoth:

Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number (4 bits) as well as two reserved bits. All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479).

Write a program that loads 488 bits (61 bytes) of cryptographic quality randomness and output them as 4 GUIDs using the format quoted above.

Do not waste randomness.

All random bits must appear in the encoded output.
All encoded bits must be traceable to either a single random bit or one of the six fixed bits that must appear in each GUID.

Use the cryptographic quality random number generator supplied by your language's standard library.
Do not use a library or external resource that generates GUIDs.
The hyphens must appear in their correct positions.
The fixed bits of this form of GUID must appear in their correct positions.
You may use a standard library function designed to output a GUID from 128 bits.
Normal code-golf rules apply.

For example...
> gentype4
6FA53B63-E7EA-4461-81BE-9CD106A1AFF8
856970E9-377A-458E-96A7-43F587724573
E4F859AC-0004-4AA1-A3D2-AECB527D1D24
766811C5-0C44-4CC8-8C30-E3D6C7C6D00B

Update:
I asked for four GUIDs in order to allow a whole number of random bytes to be gathered without leaving any remainder. I also specified that none of the bits should be wasted in order to avoid the easy answer of getting 16 random bytes and dropping the 4 in. (No, shift the other bits along first.)
Update 2:
If your language's standard library doesn't have a cryptographic quality random byte generator, you may instead assume that there is a 61 byte file present with enough random bytes for you to use when the program starts. The file should be called "/dev/urandom" or another filename with 12 characters.

If my language doesn't have a way to request a certain number of random bits/bytes, but can get a random number from 0 to n-1 using something like random(n), can I just use random(1<<k) as a way to get k random bits? Also, is it ok to get them in small pieces (e.g. 4 or 2 bits at a time) through multiple calls?

I was hoping to see how different languages can access cryptographic quality randomness. I'll add an exception for those languages without such means.

Well, now you're assuming it can read external files :p What I could use is a sequence of numbers (separated by space) given through the standard input.. but maybe I'm asking too much and should just not participate (in that language). And an unrelated note: the wikipedia quote refers to UUIDs, not GUIDs.

A close duplicate: http://codegolf.stackexchange.com/q/20363

PHP, 338 bytes
<?php $r=openssl_random_pseudo_bytes(61);$b="";$s="substr";for($i=0;$i<61;)$b.=str_pad(decbin(ord($r[$i++])),8,0,0);function p($B,$L){return str_pad(dechex(bindec($B)),$L,0,0);}for($i=0;$i<4;$i++)echo p($s($b,$p=122*$i,32),8)."-".p($s($b,$p+32,16),4)."-4".p($s($b,$p+48,12),3)."-".p("10".$s($b,$p+60,14),4)."-".p($s($b,$p+74,48),12)."\n";

Some output
> php 32309.min.php
635fa088-4a66-47fc-9e50-2ccb2445b643
6e5c23c7-ba16-427e-960b-5316980ce4e3
fdb570ca-2e5e-4594-ab2e-db8446599b8f
203f2538-b5f4-47f0-89ac-012ca14b2f99
> php 32309.min.php
a6981255-0ab2-4d82-aab4-d1c64d2bb7eb
c348e728-f817-45d2-9bbf-b40426baa461
9b2baed2-e58b-41ef-a6fb-57e96db74a68
63e464e7-ab55-4e2a-a2a0-abdc535481dc
> php 32309.min.php
af7e68d3-b3ed-4e19-85b2-280270f746c6
0a86c610-8d0c-4c0a-bafe-44a6886d71f8
98c742b8-6a3b-47ff-97c7-ccab70d79a3c
59a93afc-ff81-4c97-a57b-72f0de384acb
> php 32309.min.php
72b352fc-0174-4051-969e-cacc0adbf941
50e4f859-76fe-45f6-baf5-d5fcceb41f72
5a18408e-6e7e-43a6-bd71-09d22a0fbf14
ae5a1391-5367-467e-8ecc-785ca72cbf95

Ungolfed
<?php
$r = openssl_random_pseudo_bytes(61);
$b = "";
$s = "substr";
for($i=0 ; $i<61 ;) $b .= str_pad(decbin(ord($r[$i++])), 8, 0, 0);

function p($B, $L) {
    return str_pad(dechex(bindec($B)), $L, 0, 0);
}

for($i=0 ; $i<4 ; $i++) {
    echo p($s($b, 122*$i, 32), 8)."-";
    echo p($s($b, 122*$i+32, 16), 4)."-4";
    echo p($s($b, 122*$i+48, 12), 3)."-";
    echo p("10".$s($b, 122*$i+60, 14), 4)."-";
    echo p($s($b, 122*$i+74, 48), 12)."\n";
}

openssl_random_pseudo_bytes? That's.. verbose. PHP keeps amazing me - in the wrong way.

J - 114 bytes
I took the simplest approach available. The function takes amount of GUID's required (you could replace the ] near the end with 4: to make it return 4 always) and outputs that many of them, separated by newlines.
Edit: I missed that no generated bits must go to waste... This answer doesn't comply and I don't know how to make it to.
f=:[:}.(,LF,(x@8:,'-',x@4:,'-4',x,'-',('89AB'{~?@4:),x,'-',(x=:'0123456789ABCDEF'{~?@$&16)@(12"_))@3:)^:(]`(''"_))

If an extra newline is allowed after the output, this could be written in 111 bytes.
f=:(,LF,~(x@8:,'-',x@4:,'-4',x,'-',('89AB'{~?@4:),x,'-',(x=:'0123456789ABCDEF'{~?@$&16)@(12"_))@3:)^:(]`(''"_))

Example:
   f 4
B23B10E3-6593-40F7-A5B0-D25A2763D781
3901709C-654E-4AF0-B23E-7252E859D35B
91E8D566-8E84-48CD-9B9D-EFC4E3F62C4E
F4578389-097C-4C38-A3C0-31EABFDCD630
   f 5
AF234012-8A9F-47A3-9BF5-4B28AF580E9C
A3FE1785-8B40-44E9-8D69-CFF1BE06AC06
84A2CEB9-744F-4B86-B37F-747D0FD3F3FC
0FD8B7A6-9642-42C3-89ED-DB4A35D83CF8
4F860D9B-6E20-4AF8-B6BF-0F8CB307B9B0

@billpg This version generates a 32-bit integer for each necessary hexadecimal digit (for everything but the 4, - and linefeed). Is that okay?

Golfscript, 75
Fixed now!
{{'0123456789ABCDEF'{.,rand>1<}:|~}:&8*'-':^&&&&^4&&&^'89AB'|&&&^{&}12*n}4*

Output example:
>ruby golfscript.rb p.gs
140BC879-EAC4-4170-B349-A616523458DB
E26B34A4-8E86-4508-9EE5-3C76BF7456B6
89F9B995-CC9E-4EF0-AA25-70703B80AF82
5F6A513C-9E97-45A4-A9D1-E9D3DF71EF99

>ruby golfscript.rb p.gs
38D7A76B-BEEB-4C98-A148-D1EA8C31E85F
807373E4-5CFE-4953-9D5E-671205EE1E8F
8BD88B76-5890-4543-9787-2753AB15D24B
CD7DF25F-632B-4902-A46C-A1E10BE83EC5

You can test it yourself here.

That bug is pretty.

Was pretty atleast.

Is "rand" in GS a cryptographic quality random number generator?

Python, 287 bytes
from random import choice
s="0123456789abcdef"
def gen4():
  for i in range(4):
    m,n="",""
    l = []
    d = choice(s[8:12])
    for k in range(30):
      l.append(choice(s))
    m="".join(l)
    n=m[:12]+"4"+m[12:15]+d+m[15:]
    print(n[:8]+"-"+n[8:12]+"-"+n[12:16]+"-"+n[16:20]+"-"+n[20:])

There's already a Python answer, but that just used .uuid, so here's one without it. Wish i could get it shorter though.
Still beat PHP :P

Python (85)
import os,uuid
for i in [1]*4:print uuid.UUID(os.urandom(16).encode('hex'),version=4)

os.urandom(n): Return a string of n random bytes suitable for cryptographic use.
I assume generating more than 488 bits is ok?

Standard library function is part of the library that comes with your language. os and uuid both are part of it.

I added the "Don't waste any bits" rule because I wanted to see some bit fiddling. Just being able to drop in the 4 wiping out other bits seemed too simple a task.

That's also why I specified four GUIDs to be output, so you'd have a whole number of random bytes to deal with.

Python 2 - 188 / 182
This should obey the requirements faithfully:
import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:eval('"%X"%(a.next()*4+a.next())+'*n+'"-"')
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

If python's UUID is acceptable for outputting a nicely-formatted uuid from a 32-digit hex string, then this version has 182 bytes:
import os,uuid
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
exec('s='+'"%X"%(a.next()*4+a.next())+'*30+'"";print uuid.UUID(s[3:15]+"4"+s[:3]+"%X"%(8+a.next())+s[15:]);')*4

a is a generator comprehension that gives 2 bits at a time from an initial source of 61 random bytes.
Thanks TheRare for tips

You don't need to set x in t, just return it. for i in range(n):s+="%X"%(t()*4+t()) could be written exec's+="%X"%(t()*4+t());'*n and thus function h could be written in one line. You can use the same trick in the following loop too, just replace n by 4.

Whoops, yes you do need to set it. Sorry! The rest still works though.

@TheRare exec also seems to interfere with global, but still there is something to gain, thanks for reminding me about it

Ah, sorry. I completely forgot that global causes it to break. What if you changed it to something like this (didn't check if it's shorted, but global s is not needed): def h(n):s='';exec's+="%X"%(t()*4+t());'*4;return s+'-'<LINEFEED HERE>print'\n'.join(h(8)+h(4)+'4'+h(3)+"%X"%(8+t())+h(3)+h(12)for _ in 1,2,3,4)

Or even h=lambda n:''.join("%X"%(t()*4+t())for _ in[0]*n)+'-';print'\n'.join(h(8)+h(4)+'4'+h(3)+"%X"%(8+t())+h(3)+h(12)for _ in[0]*4) (both are untested)

You could replace the 1,2,3,4 by [0]*4, come to think of it and remove the space in front of it. (I updated the comment above).

Javascript (ES6) - 177 163 158
Removed .toUpperCase(), replaced substring with substr and substr(0,3) to substr(1)
function f(){g=()=>(((1+Math.random())*0x10000)|0).toString(16).substr(1);for(i=0;i<4;i++)alert((g()+g()+"-"+g()+"-4"+g().substr(1)+"-"+g()+"-"+g()+g()+g()))}

EcmaScript 5 version of the above script:
function f(){function g(){return (((1+Math.random())*0x10000)|0).toString(16).substr(1)}for(i=0;i<4;i++)alert((g()+g()+"-"+g()+"-4"+g().substr(1)+"-"+g()+"-"+g()+g()+g()))}

Doesn't f=x=> work as the function definition? I've never used ES6 though.

@TheRare Nope..

Common Lisp

SBCL, 223
(define-alien-routine("arc4random_uniform"a)int(u
int))(labels((g(n)(a(expt 2 n)))(h()(g 16)))(dotimes(i 4)(format
t"~4,'0X~4,'0X-~4,'0X-~4,'0X-~4,'0X-~4,'0X~4,'0X~4,'0X~%"(h)(h)(h)(+
16384(g 12))(+ 32768(g 14))(h)(h)(h))))

CLISP, 299
(use-package :ffi)(def-call-out
a(:name"arc4random_uniform")(:arguments(u int))(:return-type
int)(:language :c)(:library :default))(labels((g(n)(a(expt 2
n)))(h()(g 16)))(dotimes(i 4)(format
t"~4,'0X~4,'0X-~4,'0X-~4,'0X-~4,'0X-~4,'0X~4,'0X~4,'0X~%"(h)(h)(h)(+
16384(g 12))(+ 32768(g 14))(h)(h)(h))))

About arc4random_uniform(3)
Both of these call the C function arc4random_uniform(3) in BSD libc. Some systems do not have this function.
Beware that my declaration of arc4random_uniform(3) is wrong. The correct declaration is
u_int32_t arc4random_uniform(u_int32_t);

where u_int32_t is an old BSDism for an unsigned 32-bit integer. (The standard type in C99 is uint32_t without the first underscore.) My wrong declaration is
int arc4random_uniform(int);

where int is a signed 32-bit integer. (I know systems where int only has 16 bits, but I would not run Lisp there.) I am wrong to use signed for unsigned, but my program works because I only pass small non-negative integers. In code golf, int is shorter than unsigned-int in SBCL or uint in CLISP.
To use arc4random_uniform(3) in Lisp, I define a Lisp function a. Here it is in SBCL:
; (use-package :sb-alien)  ; SBCL does this by default!
(define-alien-routine ("arc4random_uniform" a)
  int       ; return type
  (u int))  ; argument named u

And in CLISP:
(use-package :ffi)
(def-call-out a
  (:name "arc4random_uniform")
  (:arguments (u int))
  (:return-type int)
  (:language :c)
  (:library :default))

CLISP has two languages, :c for traditional K&R C and :stdc for C89, but I find no difference, so I use the shorter name.
Now (a u) returns a random integer at least 0 and less than u. If u is 2n, then I get exactly n bits. For example, (a (expt 2 14) provides 14 bits. Because of my wrong declaration, u must be less than 231. If I want 32 bits, I may call (a 16) twice.
Rest of program
; after defining A
(labels ((g (n) (a (expt 2 n)))
         (h () (g 16)))
  (dotimes (i 4)
    (format t
            "~4,'0X~4,'0X-~4,'0X-~4,'0X-~4,'0X-~4,'0X~4,'0X~4,'0X~%"
            (h) (h) (h) (+ 16384 (g 12)) (+ 32768 (g 14)) (h) (h) (h))))

I define two local functions. (g n) generates n random bits. (expt 2 n) is much shorter than a left shift: 1<<n in C would become (let((v 0))(setf(ldb(byte 1 n)v)1)v) in Common Lisp!
(h) is an alias for (g 16). This alias costs 13 characters: 11 in (h()(g 16)), plus 2 to upgrade flet to labels, because h needs g in scope. Each call to (h) saves 3 characters, and I have 6 calls, so I save 18 after I spend 13.
When formatting each GUID, (+ 16384(g 12)) is shorter than (logior #x4000 (g 12) and (+ 32768(g 14)) is shorter than (logior #x8000 (g 14)).
One can generate the long format string "~4,'0X~4,'0X-~4,'0X-~4,'0X-~4,'0X-~4,'0X~4,'0X~4,'0X~%" (56 characters) with the expression (format()"~{~A~}~~%"(mapcar(lambda(e)(if e(format()"~~4,'0X")'-))'(t t()t()t()t()t t t))) (89 characters), but the literal string is shorter.

05AB1E, 41 bytes
4F30F15ÝΩh}J•2,ÈĆ•13в£'-4и4DL7+hΩ‚.ιÁ.ιJ,

Try it online.
Explanation:
4F                  # Loop 4 times:
  30F               #  Inner loop 30 times:
     15Ý            #   Push the list [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
        Ω           #   Pop and push a random integer from this list
         h          #   Convert the integer to hexadecimal
          }J        #  After the inner loop: join the characters on the stack together
•2,ÈĆ•              #  Push compressed integer 40106286
      13в           #  Convert it to base-13 as list: [8,4,0,3,0,3,12]
         £          #  Split the string into parts of that size
                    #   i.e. "FBA4C1C6FE22479659019DA439B7D6"
                    #    → ["FBA4C1C6","FE22","","479","","659","019DA439B7D6"]
'-4и               '#  Push a list of 4 "-"s: ["-","-","-","-"]
    4               #  Push a 4
     DL             #  Duplicate it to create the list [1,2,3,4]
       7+           #  Add 7 to each: [8,9,10,11]
         h          #  Convert each to hexadecimal: [8,9,"A","B"]
          Ω         #  Pop and push a random value from this list
                    #   i.e. "B"
           ‚        #  Pair it together with the 4
            .ι      #  Interleave it with the list of "-": ["-",4,"-","B","-","-"]
              Á     #  Rotate it once towards the right: ["-","-",4,"-","B","-"]
               .ι   #  Interleave it with the earlier created list
                    #   → ["FBA4C1C6","-","FE22","-","",4,"479","-","","B","659","-","019DA439B7D6"]
                 J  #  Join this list together to a string
                    #   → "FBA4C1C6-FE22-4479-B659-019DA439B7D6"
                  , #  And output it with trailing newline

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •2,ÈĆ• is 40106286 and •2,ÈĆ•13в is [8,4,0,3,0,3,12].
Without the requirement that no random bits must go to waste, this could have been 36 bytes, by utilizing the builtin ǝ (based on my answer here):
4FŽΣÌvy4*F15ÝΩh}'-}J¨4DL7+hΩ‚Ž5Ā2äǝ,

Try it online.

Coconut 1.4.1, 114 bytes
from random import*
for C in[->f'{randrange(16**_):0{_}x}']*4:print(C 8,C 4,'4'+C 3,choice'89ab'+C 3,C 12,sep='-')

Try it online!
This works on the old version on TIO, for newer versions you might need parentheses around '89ab'.

authors: Xi'an ні війні


text:
Show the input RGB color
Write a program that takes R, G, and B values as command arguments and then displays that color some way. It doesn't matter how, as long as at least 100 pixels have the color. Shortest code wins.

This would be improved a lot if you specified how much of the input colour should be displayed. Is just one pixel OK? I recommend you make it a requirement that the screen/window background colour (or the majority of the screen/window) be displayed in the input colour. Even so, it's rather simple.

Is COLOR command of Windows prompt valid? It has only 16 possibilities of color from 0 to F

I should win it!

JavaScript, 25
document.bgColor=prompt()

You'll have to specify the three components in hexadecimal. This is code golf, so no commas or whitespace.

Hexadecimal: cheeky, but I like it!

Wouldn't you need a '#'+, then?

@Doorknob: HTML is too cool to choke on malformed input: http://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color

I should win it!

JavaScript, 57 characters
document.body.setAttribute('bgcolor','rgb('+prompt()+')')

Enter the RGB values in the prompt input box, comma separated.
(I feel so dirty, using bgcolor :O )

bgcolor? That really brings me back to a simpler time...

xterm: 18 bytes
xterm -bg \#$1$2$3

Input the color as three 1- or 2-digit hex numbers, e.g., if this command is in the file "xterm.sh", then
./xterm.sh ff 00 00
./xterm.sh f 0 0

opens a terminal window with a red background.
If you prefer, you can omit the blanks between the components:
./xterm.sh f00

The "-bg" option is not available in some old versions of xterm.  It's missing from version 271 but present in versions 215, 251, 261, and 297.

Bash, 69
read c;set $c;printf '\e]4;1;rgb:'"$1"'/'"$2"'/'"$3"'\e\\\e[31mc\e[m'

Partially stolen from here.
Just input your values in hex (e.g. FF 00 00).
Tested on xterm-256color.
Bash, 43
printf '\e]4;1;rgb:FF/00/00\e\\\e[31mc\e[m'

Here you have to input the values yourself.
Edit: For 100 Pixels+ Just choose font-size infinite :D.

Bash/sh + ImageMagick: 28 bytes
display -size 96 xc:\#$1$2$3

Input the color as three 1- or 2-digit hex numbers, with or without whitespace between them.

I was thinking xsetroot -solid '#xyz', but this is better.  (And the effect of xsetroot is only visible if you aren't using a desktop environment that covers the X11 root window with a window showing a background, rather than drawing the background on the root window directly.)

xterm is shorter: "xterm -bg #$1$2$3"; I'll post that as a new answer.

Javascript in PCCG, 65 105
Edit 2 shortened as suggested by @manatwork
Edit
Thanks @blender
question.style.background='#'+prompt('R G B').split(' ').join('')

Just for fun

You can replace document.getElementById('question') with just question.

You can assign to the background property. (As a side effect will reset backgroundImage and alike, but not a problem in this case.)

C# WPF : 54
new Windows(){Background=Color.FromArgb(RGB);}.Show();

Postscript 61 56
Fills the graphics window with the color, components as decimals in the range 0..1.
ARGUMENTS{cvr}forall setrgbcolor clippath fill showpage

Run using ghostscript's -- option which enables argument processing.
gs -- rgb.ps .9 .2 .2

Java, 215
import java.awt.*;class C{public static void main(String[]a){Frame f=new Frame();f.setSize(9,99);f.setBackground(new Color(Integer.parseInt(a[0]),Integer.parseInt(a[1]),Integer.parseInt(a[2])));f.setVisible(true);}}

Tcl/Tk, 15
. co -bg #$argv

Tcl/Tk, 22
. configure -bg #$argv

If called with
wish show_color.tcl 6666AA

one gets

Tcl/Tk, 27
grid [canvas .c -bg #$argv]

If called with
wish show_color.tcl 6666AA

one gets


text:
Unique Array Combinations
The goal is to write a function or program which takes a set of integer arrays and returns a set of all possible arrays which meet the following criteria:

A valid array must contain at least one number from each of the input arrays.
A valid array cannot contain more than one number from a single input array.
A valid array cannot contain duplicate values.

Additional rules:

Order of the output does not matter.
Input/Output can be in any format you wish.
If no valid arrays exist, the result should be an empty array or blank string.

Examples:
input:
[[1,2],
 [2,1,0],
 [0,3,1]]

output:
[[2,3],
 [1]]

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

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

input:
[[1,2,3],
 [2,3,4],
 [1,4]]

output:
[]

Related: Helping the farmer

Some explanation of what do you mean with 'overlap array'? Or a link...

@edc65 I've removed the term from the question to avoid confusion. They're just arrays.

@edc65, it's exact set cover with some of the input implicit. So the input sets are the elements to cover, and for each element of their union there is a set consisting of those input sets which contain that element.

GolfScript, 36 characters
:I[[]]\{{{|$}+1$/}%|}/{I{1$&,(},!*},

Input/output is standard GolfScript arrays, see in this example.
:I              # save input to variable I

# part 1: generate all possible sets with zero or one numbers from each array
# (zero or one is one char shorter than exactly one which would work also)
[[]]\           # push the set with an empty set
{               # iterate over all input sets
  {             #   iterate over the numbers in the current set
    {|$}+1$/    #     add this number to any set in the result
  }%
  |             #   join with the result set
}/

# part 2: filter for valid sets (i.e. exactly one number from each array)
{               # start of filter block
  I{            #   filter the input array of sets
    1$&         #     calculate overlap of the current set with the input set
    ,(          #     remove if length is equal to one
  },
  !             #   is the list empty? (i.e. all input matched the filter criterion)
  *             #   get rid of the second item on the stack
},              # end of filter block

CJam, 35 bytes
q~:Q{m*{(+$_&}%}*_&{Q{1$&,(},,*!},p

Input is a list of list like:
[[1 3 4 7]
 [1 2 5 6]
 [3 4 8]
 [8 9]]

and output is the list of unique lists that match all conditions, like for above input,
[[1 8] [2 3 9] [3 5 9] [3 6 9] [2 4 9] [4 5 9] [4 6 9] [2 7 8] [5 7 8] [6 7 8]]

How it works:
q~:Q                                 "Evaluate the input and store it in Q";
    {          }*                    "Run this block for each adjacent pair in the array";
     m*                              "Calculate Cartesian product of the pair";
       {     }%                      "Map each cartesian product with the code block";
        (+$                          "Flatten the array and sort it";
           _&                        "Make the array unique";
                 _&                  "Only take unique cartesian products";
                   {            },   "Filter the cartesian products based on the code block";
                    Q{     },        "Put Q on stack and run it through this filter";
                      1$&            "Take ∩ of the input array with the cartesian product";
                         ,(          "Check that length of the ∩ should be greater than 1";
                             ,*!     "Now we have all the lists from the input list of list"
                                     "which matched more than 1 element from this cartesian"
                                     "product. So if this list is non empty, discard this"
                                     "cartesian product";
                                  p  "Print the filtered out valid unique arrays";

Try it online here

Mathematica, 135 84 72 bytes
f=Cases[Union/@Tuples@#,l_/;!MemberQ[#,k_/;Length@Intersection[k,l]>1]]&

Less golf:
f = Cases[
   Union /@ Tuples@#,
   l_ /; ! MemberQ[#, k_ /; Length@Intersection[k, l] > 1]
] &

This defines a function f that expects the input as a plain Mathematica list of lists, e.g.
f[{{1, 2}, {2, 1, 0}, {0, 3, 1}}]

Basically, I'm creating a list of all lists that fulfil conditions 1 and 3, and then I'm filtering out those that violate conditions 2. There might be a shortcut for one of the two, which I'll have to think about in more depth tomorrow. Found that shortcut!

Ruby — 80 73 characters
@Howard knocks off 7 characters:
f=->a{a[0].product(*a).map(&:uniq).uniq.select{|l|a.all?{|x|(l&x).one?}}}

Some sample input:
a = [[1, 2], [2, 1, 0], [0, 3, 1]]
b = [[1,3,4,7], [1,2,5,6], [3,4,8], [8,9]]
c = [[1,2,3], [2,3,4], [1,4]]
d = [[]]
e = [[1,2]]

Output:
f[a] # => [[1], [2, 3]]
f[b] # => [[1, 8], [3, 2, 9], [3, 5, 9], [3, 6, 9], [4, 2, 9], [4, 5, 9], [4, 6, 9], [7, 2, 8], [7, 5, 8], [7, 6, 8]]
f[c] # => []
f[d] # => []
f[e] # => [[1], [2]]

Haskell — 90 characters
I'm just learning Haskell, so I imagine this can be vastly improved. Same basic strategy as my Ruby solution.
import Data.List
f a=[l|l<-nub.map nub$sequence a,all(\x->length x==1)(map(intersect l)a)]

I think you can also use the shorter version .product(*a) since the invalid solutions are filtered afterwards anyways.

ruby, 143 114
Now shorter thanks to @Ventero.
h={};i=eval$*[0];v=i.flatten.uniq
loop{h[a=v.sample(1+rand(v.size)).sort]||=h[a]||i.any?{|o|(o&a).size!=1}?1:p(a)}

Usage:
ruby uniq_arr.rb '[[1,3,4,7],[1,2,5,6],[3,4,8],[8,9]]'
[2, 3, 9]
[6, 7, 8]
[3, 5, 9]
[1, 8]
[2, 7, 8]
[4, 6, 9]
[5, 7, 8]
[2, 4, 9]
[3, 6, 9]
[4, 5, 9]

Making it stop (eventually) is easy, but requires some code. It stops one h contains 2**l-1 elements, l being the number of unique elements in i, i.flatten.uniq.size
http://ideone.com/zTlXZw

Some general improvements: $* is short for ARGV and allows dropping the whitespace after eval, loop{...} is a shorter infinite loop, rand is the same as Random.rand and p is a shorter way than $_ to get nil (the function does nothing and returns nil if called without arguments). Also, I think your reduce can be replaced with i.any?{|o|(o&a).size!=1}.

Python, 157 characters
This is a straightforward brute-force implementation.
from itertools import*
a=input()
v=set(chain(*a))
print[x for x in chain(*[combinations(v,r)for r in range(len(v))])if all(1==len(set(x)&set(y))for y in a)]