text:
Conway's Game of Life with smallest *set* of source characters
The goal of this challenge is to write a program that will simulate a single round of Conway's Game of Life on an existing grid.
Input format:
Input will be read from stdin. The input will consist of a line containing two numbers, r and c, separated by a single space. These will be the number of rows and columns of the input grid, respectively.
Following the dimensions will be the grid itself, one row per line. Each character in the row will either be a . (meaning a dead cell) or a # (meaning a living cell).
Output format:
Output will be written to stdout. The output should be formatted exactly the same way as the input (including the width and height). It should consist of the state of the grid after simulating one generation. In this way, it should be possible to simulate as many generations as desired by piping the output of one run of your program into it again in a new run. Note that your program must actually perform the simulation and cannot use external resources such as other programs or network access.
Grid boundaries are to be considered dead zones.
Sample input:
5 6
......
..#...
..#...
..#...
......

Sample output:
5 6
......
......
.###..
......
......

Scoring
Programs will be scored on the total unique bytes in the program's source. The smaller the score, the better.
Here is the scoring system that will be used to judge entries (Python):
data = open(fname, "rb").read()
unique = set(data)
score = len(unique)
print("Score for %s: %d" % (fname, score))

If two entries happen to tie, then the total length in bytes of the source will be used as a tiebreaker.
Of course, there have to be some limitations as to what programming languages may be used. Clearly I cannot allow Whitespace or Brainf*ck in this challenge or there would be no chance for other languages. Therefore, I will implement a whitelist of allowed languages. If you wish to use a language that is not present in the whitelist, post a comment and I will decide whether to add it to the list.
Language Whitelist

Assembly
C
C#
C++
Go
Haskell
Java
Lisp
Lua
Objective-C
Perl
PHP
Python
Ruby
Rust
Swift

The winner will be decided on August 1 at 11:59pm EST.
UPDATE:
As of August 1st, the winner is @mniip with a Lua solution consisting of only 9 unique characters.

How should the input/output be implemented? (Do we have to use standard input/output or read files or write a function or assume the string is saved in a variable etc?)

Is this an [tag:atomic-code-golf]?

If you have to restrict languages then a) it's a deficiency of the question; b) make sure you do it right! If you're going to disqualify Brainfuck for having an 8-character symbol set you must surely disqualify JavaScript. There are several answers on this site which use JSFuck to reduce JS to a 6-character symbol set.

Although this question can be seen as an extreme specialisation of http://codegolf.stackexchange.com/q/11690/194 so it might be better to just close it as a dupe than try to fix it.

And it really isn't like Java can win anyway. public static void main(String[] a){} is already 21!

@flawr I updated the question to clarify this

@impinball No this isn't atomic-code-golf. That is when the challenge defines a subset of tokens allowed. I am not defining the allowed subset of tokens, but rather leaving it open and allowing people to pick the smallest subset of characters they can use.

@PeterTaylor That's like saying we should close every new code-golf challenge since there have already been other code-golf challenges before. This is not a dupe. That question was overly general and had no specific challenge besides creating a really small program. Also I removed Javascript from the list of allowed languages. Had not known about that before!

@Cruncher Yeah likely not, but I decided I might as well allow it to see if some really smart person could make it very small. I know for example in java you can encode the entire program in UNC notation (a whole bunch of \uXXXX's), so it has that going for it

@C0deH4cker in that case, you can encode any java program in 12 characters. There's no cleverness in writing it. Unless you do something special to avoid all 4's or something.

er... no javascript?

The linked question is not relevant to this one. The other question is asking to write a program which encodes the source code of a program. This one is asking to implement conways game of life. The only similarity is the scoring mechanism of this challenge vs the outcome of the answers in the other challenge.

Lua 5.2 - 9 characters
The only chars used are load"\045:

load"load\"load\\\"load\\\\\\\"load\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05504\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505o\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055ad\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\04\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505o\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055ad\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\04\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0505\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05504\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0505\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05504\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505o\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055ad\\\\\\\\\\\\\\\\040\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505o\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055ad\\\\\\\\\\\\\\\\040\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\040\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05504\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05504\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0555\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\050\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\045\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\045\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\044\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050do\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\050\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\050\\\\\\\\\\\\\\\\04\\\\\\\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\050\\\\\\\\\\\\\\\\04\\\\\\\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050a\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\050\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\0555\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05504\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0555\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0555\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\04\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505o\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\040\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\0500\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\055\\\\\\\\05\\\\04\\05\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\0555\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055a\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\040\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0555\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\050\\\\\\\\\\\\\\\\05\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0555\\\\\\\\\\\\\\\\0\\\\\\\\0540\\\\\\\\\\\\\\\\050\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050a\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\0555\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\04\\\\05\\055o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\040\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0555\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\054\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\05\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050a\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\0555\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055o\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\054\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\05\\\\055\\\\\\\\\\\\\\\\04\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\04\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\\0\\\\\\\\05\\\\04\\05\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\050\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0554\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\05505\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\055\\\\\\\\054\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\0550\\\\\\\\04\\\\05\\055\\\\\\\\\\\\\\\\\\\\\\\\04\\\\05\\055\\\\\\\\04\\\\05\\0550d\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\"\\\\\\\"\\\\\\\"\\\"\\\"\\\"\"\"\""""

The thing was generated using this simple script:
local data = io.read"*a"
while data:match'[^load\\"045]' do
    data = 'load"' .. data:gsub('[^load045]', function(x)
            if x == '\\' or x == '"' then
                return '\\' .. x
            else
                return ('\\%03d'):format(x:byte())
            end
        end) .. '"""'
end
print(data)

The GOL implementation is not really interesting, just a usual loop with extra cols/rows in the grid instead of bound checking.

I must say I don't have the faintest idea how this thing works, even after a cursory glance at lua documentation. A word of explanation would be appreciated.

C: 41 distinct characters, 372 total
I didn't try very hard to reduce the number of distinct characters.
f,h,i,o,c,m,n;main(){scanf("%d %d",&h,&f);printf("%d %d\n",h,f);char a[h+1+1][f+1+1];for(i=1-1;i<h;a[i][1-1]=a[i][f]=1-1,i++)scanf("%s",a[i+1]+1);for(i=1-1;i<f;a[1-1][i]=a[h][i]=1-1,i++);for(i=1;i<h+1;i++){for(o=1;o<f+1;o++){c=1-1;for(n=-1;n<1+1;n++){for(m=-1;m<1+1;c+=a[i+n][o+m]=='#'&&(m||n),m++);}putchar(a[i][o]=='#'? (c>1&&c<4?'#':'.'):c==3?'#':'.');}putchar('\n');}}

You can see the non-reduced version here.


text:
Output nth term in Catalan type sequence
Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1.
This seems to be a much better explanation of the sequence A071159.

Integers whose decimal expansion start with 1, do not contain zeros and each successive digit to the right is at most one greater than the previous.
1, 11, 12, 111, 112, 121, 122, 123, 1111, 1112, 1121, 1122, 1123, 1211, 1212, 1221, 1222, 1223, 1231, 1232, 1233, 1234, 11111, 11112, ...

Personally I find the description for the sequence rather unhelpful, and find it is easier to understand with a graph.
                              1
          11-------------------------------------12
      111----112                     121---------122----------123
1111-1112    1121-1122-1123    1211-1212    1221-1222-1223    1231-1232-1233-1234

I find the graph rather interesting as it is very self-repeating. For instance, the left-most node on a branch is always identical to the root node. Might be easier to see on this graph.
Challenge
Submit a solution that can output the nth item of sequence A071159.
Rules
Your submission should be able to calculate any item before number 23713. A071159(23713) is the first time a 10 would appear as a single digit (12345678910; comma-separated 1,2,3,4,5,6,7,8,9,10).

What about 1213?

@Ypnypn Doesn't exist.

@TheRare Which means the two sequences (normalizing sequence and A071159) are not equivalent and the task therefore does not match its description.

@tolos Can you please clarify which of the two sequences you want to have? Until then I am voting to close as "unclear what you are asking".

Btw. the variable normalizing sequence seems to be A193023.

Thanks for the sequence Howard, it's of interest for a hobby project (which needs a bit of work now =p). I left the challenge as-is and updated the description. Here's my implementation of A071159: http://codepad.org/4Zc5E7gz

Function? Read from stdin? Either?

GolfScript (29 chars)
~([1]{.{.10*)\10%{.)}*}%|}9*=

This is a pretty naïve implementation, although reasonably fast.
~(         # Evaluate input, decrement to get a 0-based index
[1]        # Initial row of tree
{          # Loop: stack is the first n rows of the tree as an array
  .        # Duplicate the array
  {        # Map: extend each element of the array into its children
    .10*)  # Get the first child; stack is   rows x 10x+1
    \10%   # How many more children does x have?
    {.)}*  # Those children are found by successive incrementation
  }%       # End map
  |        # Add the new unique elements (i.e. the new bottom row) to the rows
}9*        # Repeat 9 times, so that the array has 23713 correct values and one incorrect
=          # Array lookup

Python 2 (83) (86)
r=[1]
exec"r=[1]+[i+w*10for w in r for i in range(1,w%10+2)];"*9
print r[input()-1]

Explanation to come.
A completely different approach of counting up an testing for membership in the sequence (87 chars). Take ridiculously long for larger numbers,
n=0
k=input()
while k:n+=1;k-=all(0<int(b)<2+int(a)for a,b in zip('0'+`n`,`n`))
print n

Haskell (73)
c=1:((\n->[10*n+d|d<-[1..n`mod`10+1]])=<<)c;main=readLn>>=print.((0:c)!!)

And ungolfed:
step n = [ 10*n + d | d <- [1 .. lastDigit+1] ]
    where lastDigit = n `mod` 10

soln = 1 : concatMap step soln

main = do
    n <- readLn
    let nthTerm = soln !! (n - 1)
    print nthTerm

soln is a list containing the entire A071159 sequence.
The step function is not very interesting, just a straightforward list comprehension that takes a number to the list of its children in the OP's tree.
The main function's only trick is to do 1-based indexing of [1,11,12,...] by using 0-based indexing on [0,1,11,12,...], saving a character.
The real fun is in the recursive definition of soln, which does the breadth-first traversal of the OP's tree. A couple characters are saved by replacing concatMap with its generalization =<<.

save three characters:  c=1: instead of c=[1]++

Thanks, @MtnViewMark! Don't know what happened there..

JAVA (146)
I know I'm not winning this, but oh well:
public class a{public static void main(String[]a){float b=Float.parseFloat(a[0]);float c=1;for(int i=2;i<=b;i++)c*=(i+b)/i;System.out.print(c);}}

Just straightforward from Wikipedia, any tips for further golfing this will be appreciated.

you ca save a char by turning for(int i=2;i<=b;i++)c*=(i+b)/i into for(int i=2;i<=b;)c*=(i+b)/i++

Oops, just noticed that I'm calculating the Nth catalan number which is not what was asked, I'll be updating this as soon as I have the answer.

Powershell (136)
$n=Read-Host;$x=,'1';$a=1;While($x.length-lt$n){$b=[int]$x[$a-1].Substring($x[$a-1].length-1);1..($b+1)|%{$x+=$x[$a-1]+$_};$a++}$x[$n-1]

Probably some wasted characters here, but I'm still learning. $a traverses the list as it's being built (each level of the tree). $b takes the last digit of the current item, then the loop after that adds on 1 to $b+1 to the end of the current item and adds it to the array $x.
Loop is a bit inefficient, as the $n-1 index is necessary because it doesn't always stop on the nth number of the sequence that you want.
But hey, it's my first draft. And it replicated the correct sequence output based on the input here.
Also an input of 23713 produces an output of 12345678910.

It's funny how I tend to find Powershell to be the most obfuscated language.

@TheRare Yeah, when it's done really well (aka not by me) Powershell can be really freaking confusing to look at from the outside. Still got nothin' on Brainfuck or Golfscript or stuff like that...

Honestly, I find both of those cleaner.

source: Stack Exchange

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

sort: votes


text:
Calculate a rock rolling down a hill
Introduction
Sisyphus was having some troubles at work lately. It seems he just never gets anything done, and he would love to find a solution to this problem.
His current employment requires rolling a rock up a hill. He usually does his job well, but every time he is near the top of the hill it rolls down again.
He is getting really frustrated with his job and wants to solve the problem scientifically by having a computer simulate the rock rolling down the hill.
It so happens that Sisyphus isn't particularly good at programming, so maybe you can help him out?
The Challenge
After this silly introduction, let's come to business. Your program will receive an illustration of the hill and the rock which looks similar to this:
#o
##
###
######
########

Where # represents a part of the hill and o represents the rock.
You now have to implement a program which moves the rock 1 layer down. For example, the output of the above should be:
#
##o
###
######
########

If there is a horizontally even area, the hill just rolls horizontally, so...
o
########

...this would just make the stone roll sideways.
 o
########

If there is a vertical area, the rock falls down one step, so...
#o
#
#
#####

...would yield...
#
#o
#
#####

You will also receive the width and height of the image respectively in one line above the image. So, in complete, our sample input would look like this:
10 5
#o
##
###
######
#########

(Note that the whitespace here are spaces. Select the text and see what I mean.)
Some details

When the rock is already in the last line when running the program, you can choose to either terminate the program or output the unchanged input

The hill only ever goes downwards

Your program should format the output exactly the same as the input (including the dimensions), so if you pipe the output of the program to itself, it calculates the next step.

You can assume there is always a way to the bottom, so input where the path is "blocked" may cause undefined behaviour

You can assume there is always a space in the last line. The rock should "rest" there, so after calling the program a few times, always piping it's output into itself, you should end up with the rock in the last line, laying where the space previously was.

You may accept input in any form you like (stdin, file,...). You have to post the WHOLE program (so all pre-initialized variables count as code).

The lines are terminated with \n.

You can get some example inputs here (make sure you copy the spaces correctly!)

This is code-golf, so the working submission with the least bytes wins.

The winner will be chosen on July 26th, 2014. You can post solutions after that, but you can't win

If you have any questions, let me know in the comments.
Happy golfing!

Will there be a trailing column of whitespace as in your last example? (because the others don't have it)

@m.buettner In the last example there are only 9 #s, so there is one space at the end because the width is 10. In this case (after a few iterations) the rock would lay where the whitespace is (so at the bottom-right corner).

Yes, I realise that, I was just wondering whether we can assume that's always the case, because it's not for your other examples. (That being said, your other examples don't have any trailing whitespace at all.)

Oh now I see what you're talking about... I hadn't thought about that at all, I'll edit it. Thanks!

Also, yes, you can assume the last line always contains a space for the rock to "rest"

@Quincunx wow, I don't know how I could forget that... I fixed it, thanks

@undergroundmonorail basically you always "fall" one step in a direction (orthogonal or diagonal), so you can either roll sideways, roll one down (diagonally) or fall 1 down

@HackerCow I thought I figured it out so I deleted my comment, but it turns out I was wrong :P Thanks for the clarification.

@HackerCow Also, You will also receive the width and height of the image respectively but in the example the height comes first. Just FYI.

Damnit, that's a mistake in the exaple (in the pastebin examples width comes first... That explains why @m.buettner's solution didn't work for the pastebin examples :P

Missed a great chance to call it "Rock and Roll"

@HackerCow No, my answer ignores width and height completely.

@m.buettner Well, that's a problem then... on the last example it stays 1 spot above the last line

@HackerCow That's because your pastebin doesn't include the trailing column of spaces you promised me. ;) (only the first of the three lines is actually 10 characters long)

I know, shame on me D: I added it in afterwards though and it still doesn't work (not sure if that messes with the line endings or something)

@HackerCow you're right. Fixed by removing a character :D

Regex (.NET, Perl, PCRE, JavaScript, ... flavours), 25 bytes
Yes, this will create some debate again, whether a regular expression is a valid program, but I'll pre-empt that and say that this submission is just for fun and doesn't need to be considered for the winner. (As opposed to the 31 byte Perl variant at the bottom ;).)
So here is a pure regex replacement solution.
Pattern (note the trailing space):
o(( *)\n#*)(?=\2) |o

Replacement (note the leading space):
 $1o

The byte count is for the sum of the two.
You can test it at http://regexhero.net/tester/. Make sure to choose Unix-style line endings and "preserve pasted formatting" when pasting. If it still doesn't work, you still have pasted Windows-style line endings. The easiest fix in that case is to replace \n with \r\n in the pattern to see that it works.
Here is a 48 byte ECMAScript 6 function using this
f=(s)=>s.replace(/o(( *)\n#*)(?=\2) |o /,' $1o')

Finally, I've also got an actual program. It's 31 bytes of Perl (including two bytes for p and 0 flags; thanks to Ventero for the suggestion!).
s/o(( *)\n#*)(?=\2) |o / $1o/

If you want to test it, don't even save it in a file, just do
perl -p0e 's/o(( *)\n#*)(?=\2) |o / $1o/' < hill.txt

Doesn't work for me unfortunately (in the online tester). It just always moves the rock to the right. 40 bytes is a great start though, that will be hard to beat!

@HackerCow You're right, I just noticed there's a problem. Fixing...

@HackerCow No I think it actually works, but "preserve formatting" overwrites the line ending, so if you paste Windows-style line endings it doesn't work (try replacing \n with \r\n)

For me the rock don't fall when is against the right wall, ie. it only matches it when it has a trailing space.

@BrunoJ the input is guaranteed to have a trailing whitespace

Ah yes, that worked. I also explicitly stated the lines end with \n, so that answer is valid. It's also fun to watch :D +1

How am I supposed to beat this? Great solution

@qwr You could just claim that this is not an actual "program" and hence should be disqualified. :P (like this guy)

By looking at the other answers so far I seriously doubt anyone can beat this (even the JS version)... luckily there's still golfscript :P

@HackerCow I tried making a GolfScript program from this (with Peter Taylor's help), but it was longer than the JS version. I've got a 33 byte Perl program now, though. GolfScript etc. might still be able to win with a non-regex approach.

Python - 190
Slicing and concatenation horror, along with way too many variables. I'm certain this can be golfed more, but I can't think of any clever python functions right now. Input is stored in string s.
r=" "
o="o"
i=s.index(o)
b=i+int(s.split(r)[1])
q=s[:i]+r
x=s[b+3:]
try:
 a=s[b+1:b+3]
 if a[0]==r:s=q+s[i+1:b+1]+o+r+x
 elif a[1]==r:s=q+s[i+1:b+2]+o+x
 else:s=q+o+s[i+2:]
except:1
print(s)

Since python strings are immutable, I replace a character by concatenating all the characters before, my new character, and all the characters after. I use the hill width and indexing to determine where the rock should roll to.

My eyes hurt. +1

Ruby, 65/55 characters
Figured I'd see how long a solution is that doesn't just throw a regex on the problem.
r=gets p
r[r[(r[k=1+~/o/+x=r.to_i,2]=~/ /||-x)+k]&&=?o]=" "
$><<r

As expected, it's not as short as m.buettner's regex solution - but not much longer either.
When using interpreter flags, this can be shortened to 55 characters (53 for the code, 2 for the flags):
sub$_[($_[k=1+~/o/+x=$_.to_i,2]=~/ /||-x)+k]&&=?o," "

Run the code like this:
ruby -p0e 'sub$_[($_[k=1+~/o/+x=$_.to_i,2]=~/ /||-x)+k]&&=?o," "' < input

HTML JavaScript - 251 chars
(251 if you count the code inside the single quotes that reads the input and returns the output. 359 if you count the input box, input string, button, etc. 192 if you count just that does the work.)
Golf code:

10 5
#o
##
##
######
#########
<button onclick='i=document.getElementById("i");h=i.innerHTML;if(p=h.
match(/([\s\S]*?)([# ]+)(o *\n)(#+)([\s\S]*)/)){if(p[4].length>p[2].length+1)p[3]=p[3].
replace("o "," o");else{p[3]=p[3].replace("o"," ");p[5]="o"+p[5].substr(1);}p[0]="";
h=p.join("");}i.innerHTML=h;'>Go</button>

http://goo.gl/R8nOIK

Click "Go" over and over.
Method
I uses String.match() to break hill into 5 parts, then I change one or two parts.  I'm learning JavaScript, so any suggestions would be appreciated.
Readable Code

10 5
#o
##
##
######
#########

<button onclick='

    // get image
    io = document.getElementById("io");
    image = io.innerHTML;

    // break image into five parts
    // 1(10 5\n#         \n##        \n) 2(### ) 3(o     \n) 4(######) 5(    \n######### )
    if (parts = image.match(/([\s\S]*?)([# ]+)(o *\n)(#+)([\s\S]*)/)) {

        // move rock to the right
        if (parts[4].length > parts[2].length + 1)
            parts[3] = parts[3].replace("o ", " o");

        // or move rock down
        else {
            parts[3] = parts[3].replace("o", " ");
            parts[5] = "o" + parts[5].substr(1);
        }

        // return new image
        parts[0] = "";
        image = parts.join("");

        // MAP io:i image:h parts:p
    }
    io.innerHTML = image;
'>Go</button>

awk, 152
awk 'NR==1{w=$2}{if(NR<=w&&$0~/o/){r=index($0,"o");g=$0;getline;if(index($0,"# ")<=r){sub("o"," ",g);sub(" ","o")}else{sub("o "," o",g)}print g}print}'

More Readable
    awk '
  NR==1{  //If we're at the first line, set the width from the second column in the header.
    width=$2
  }
  {
    if(NR<=width && $0~/o/){   //If not at the bottom, look for the line with the rock.
      rockIndex=index($0,"o"); //Set the position of the rock.
      orig=$0;                 //Remember the current line so we can compare it to the next.
      getline;                 //Get the next line.

      if(index($0,"# ")<= rockIndex){  //Move down: if the rock is on a cliff or on a slope,
        sub("o"," ",orig);             //update the orig so that the rock is removed
        sub(" ", "o")                  //and update the current (first available position).
      }
      else {                           //Move right: if the rock is on flat ground,
        sub("o "," o", orig)           //update the orig so the the rock is advanced.
      }
      print orig                       //Print the line we skipped (but stored
    }                                  //and updated based on the line we're now on).
    print                              //Print the line we're now on.
  }
'

Python 2 - 289 252 bytes
p=raw_input
w,h=map(int,p().split())
m=[p()for a in[0]*h]
j=''.join
f=lambda s:s.replace('o ',' o')
for i,r in enumerate(m):
 x=r.find('o')
 if x+1:y=i;break
if m[y+1][x]=='#':m=map(f,m);x+=1
print w,h
print'\n'.join(map(j,zip(*map(f,map(j,zip(*m))))))

I made some significant improvements but this is still terrible. A couple more bytes can be saved by converting this to Python 3 but I can't be arsed.
First, I find the rock. If the character immediately below it is '#', replace every instance of 'o ' with ' o'. Since there's guaranteed to be an extra space at the end, this will always move the rock to the right.
Regardless of if I just did that or not, I transpose the whole grid with zip(*m). Then, I do another replacement of 'o ' with ' o'. If there's a space to the right of the rock, that means that in the real grid there's a space below it, so it gets moved. Then I transpose back and print.

Wouldn't this mess up the OP's 3rd example, where there's empty space to the right of and below the rock, and move it diagonally?

@dor It shouldn't. I only move to the right if the space below is #, and I do that check before I do the check to move vertically.

Python (201)
import sys
print(input())
g=list(sys.stdin.read())
o='o'
x=g.index(o)
n=x+g.index('\n')+1
try:
 if g[n]==' ':g[n]=o
 elif g[n+1]==' ':g[n+1]=o
 else:g[x+1]=o
 g[x]=' '
except:1
print(*g,sep='',end='')

R, 234
require(stringr)
g=scan(,"")
g=do.call(rbind,strsplit(str_pad(g,m<-max(nchar(g)),"r"),""))
if(g[(x<-which(g=="o"))+1]==" "){g[x+1]="o";g[x]=""}else{if(!is.na(g[x+1])){g[x+(n<-nrow(g))]="o";g[x]=""}}
for(i in 1:n) cat(g[i,],"\n",sep="")

String manipulation is not R's strongest point.
More readably:
require(stringr) # load package `stringr`, available from CRAN. required for `str_pad`
g=scan("")       # read input from console
g=do.call(       # applies the first argument (a function) to the second argument (a list of args to be passed)
  rbind,         # "bind" arguments so that each one becomes the row of a matrix
  strsplit(      # split the first argument by the second
    str_pad(g,max(nchar(g)),"r"," "), # fill each row with whitespace
    "")
)
if(g[(x<-which(g=="o"))+1]==" ") { # if the next element down from the "o" is " "...
  g[x+1]="o";g[x]=""               # make it an "o" and replace the current element with ""
} else {
  if(!is.na(g[x+1])) {             # if the next element down is not empty (i.e. out of range)
    g[x+nrow(g)]="o"; g[x]=""      # move "o" right
  }
}
for(i in 1:n) cat(g[i,],"\n",sep="") # print to console

php 485 484 chars
I know this is massive compared to entry by m.buettner but is best I can do for now. I think there must be a quicker way to turn the input string into a multi dimensional array but it is very late now.
And although it it uncompetitive I liked this puzzle. Would like the extension to show where the ball ends up, or after a set number of steps, perhaps added after the width and height on the input line. Could add that very easily to this version.
Here is my code: Input is in the first variable.
<?
$a.='10 5
#o
##
###
######
#########';$b=array();$c=explode("\n",$a);$d=explode(" ",$c[0]);$e=$d[0];$f=$d[1];unset($c[0]);$g=0;foreach($c as $h){$b[$g]=str_split($h);++$g;}for($i=0;$i<$f;++$i){for($j=0;$j<$e;++$j){if($b[$i][$j]=='o'){$k=$j;$l=$i;$b[$i][$j]=' ';}}}if($b[$l+1][$k]!='#'){$b[$l+1][$k]='o';}else if($b[$l+1][$k+1]!='#'){$b[$l+1][$k+1]='o';}else{$b[$l][$k+1]='o';}echo"$e $f\n";for($i=0;$i<$f;++$i){for($j=0;$j<$e;++$j){echo $b[$i][$j];}echo "\n";}

You can see it here in action on codepad
Edit: Changed codepad and code above as was outputting 0 instead of o, which caused problem when I tried to feed the output back into the program. Fixed now and saved one char!

Groovy - 263 261 256 chars
Golfed. Read the file into a String, and use a function p to emulate a function String.putAtIndex(index,value):
o="o"
b=" "
s=new File(args[0]).text
z={s.size()-it}
s=s[0..z(2)]
w=s.find(/\n.*?\n/).size()-1
p={i,v->s=s[0..i-1]+v+((i<z(0)-2)?s[i+1..z(1)]:"")}
try{
t=s.indexOf o
i=w+t
j=i+1
x=t+1
(s[i]==b)?x=i:(s[j]==b)?x=j:0
p x,o
p t,b
}catch(Exception e){}
print s

Ungolfed (somewhat):
o = "o"
b = " "
s = new File(args[0]).text
z = {s.size()-it}
s = s[0..z(2)]
w = s.find(/\n.*?\n/).size()-1

putAtIndex = { i,val ->
    s = s[0..i-1] + val + ((i<z(0)-2)?s[i+1..z(1)]:"")
}

try {
    t=s.indexOf o
    i=w+t
    j=i+1
    x=t+1
    // default x as horizontal move
    // check for (a) directly below (b) below and over one
    (s[i]==b) ? x=i : ( (s[j]==b) ? x=j : 0)
    putAtIndex x,o
    putAtIndex t,b
} catch (Exception e) {}
print s

Nice. I don't know the language, but I'm almost sure you can get rid of (at least) two bytes if you write try{ instead of try { and catch(Exception instead of catch (Exception.

Indeed! Thanks for the note....

C (182)
char b[1024],*x,*n;main(z){read(0,b,1024);n=index(b,10)+1;x=index(n,'o');z=index(n,10)-n;n=x+z+1;if(n[1]){if(*n==32)*n='o';else if(n[1]==32)n[1]='o';else x[1]='o';*x=32;}printf(b);}

Or, if you actually want to read the code:
char b[1024],*x,*n; //1024 byte buffer hard coded
main(z){
    read(0,b,1024);
    n=index(b,10)+1; //start of line 2
    x=index(n,'o');
    z=index(n,10)-n; //10='\n'
    n=x+z+1; //reusing n
    if(n[1]){ //if not 0
        if(*n==32) //32=' '
            *n='o';
        else if(n[1]==32)
            n[1]='o';
        else
            x[1]='o';
        *x=32;
    }
    printf(b);
}

Clojure - 366 chars
Without regex. Required input file named "d". Golfed:
(def s(slurp "d"))(def w(-(.length(re-find #"\n.*?\n" s))2))(def t(.indexOf s "o"))(def i(+ t w 1))(defn g[i,j,x,c](cond (= x i) \ (= x j) \o :else c))(defn j[i,j] (loop[x 0](when(< x (.length s))(print(g i j x (.charAt s x)))(recur(inc x)))))(try(cond(= \ (.charAt s i))(j t i)(= \ (.charAt s (inc i)))(j t (inc i)):else (j t (inc t)))(catch Exception e (print s)))

Ungolfed:
(def s (slurp "d"))
(def w (- (.length (re-find #"\n.*?\n" s)) 2))
(def t (.indexOf s "o"))
(def i (+ t w 1))
(defn g [i,j,x,c] (cond (= x i) \ (= x j) \o :else c))

(defn j [i,j] (loop [x 0]
     (when (< x (.length s))
     (print (g i j x (.charAt s x))) (recur (inc x)))))

(try (cond (= \ (.charAt s i)) (j t i)
           (= \ (.charAt s (inc i))) (j t (inc i))
           :else (j t (inc t)))(catch Exception e (print s)))

Sample run (just one case, for brevity):
bash-3.2$ cat d
6 7
#
#
#
## o
####
####
#####

bash-3.2$ java -jar clojure-1.6.0.jar hill.clj
6 7
#
#
#
##
####o
####
#####

I'm a newbie. Suggestions welcome.

MATLAB, 160
function r(f)
F=cell2mat(table2array(readtable(f)));
m=@(d)mod(d-1,size(F,1));C=find(F=='o');P=find(F==' ');N=min(P(P>C&m(P)>=m(C)));F([C,N])=F([N,C]);
disp(F);

The painful part is the file-input. The actual computation would be only 114 bytes:
function F=r(F)
m=@(d)mod(d-1,size(F,1));C=find(F=='o');P=find(F==' ');N=min(P(P>C&m(P)>=m(C)));F([C,N])=F([N,C]);

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


text:
ASCII Train Golf
Consider these seven ASCII train cars.
Engine (E)
            __
======      \/
| [] |=========
|              )
================
 O-O-O   O-O-O \\

Passenger car (P)
===============
| [] [] [] [] |
===============
 O-O       O-O

Boxcar (B)
===============
|-|-|  |  |-|-|
===============
 O-O       O-O

Tanker (T)
 _____---_____
(             )
===============
 O-O       O-O

Hopper (H)
_______________
\ | | | | | | /
===============
 O-O       O-O

Flatbed (F)
===============
 O-O       O-O

Caboose (C)
    =====
====|   |====
| []     [] |
=============
 O-O     O-O

Write a program that when given a sequence of the characters EPBTHFC, outputs its ASCII train representation, using -- for the car couplings. The leftmost input characters become the rightmost train cars. The train is always facing right.
For example, an input of EEHTBPFC should produce
                                                                                __                __
    =====                                                                                ======      \/    ======      \/
====|   |====                   ===============  ===============   _____---_____   _______________  | [] |=========   | [] |=========
| []     [] |                   | [] [] [] [] |  |-|-|  |  |-|-|  (             )  \ | | | | | | /  |              )  |              )
=============--===============--===============--===============--===============--===============--================--================
 O-O     O-O    O-O       O-O    O-O       O-O    O-O       O-O    O-O       O-O    O-O       O-O    O-O-O   O-O-O \\  O-O-O   O-O-O \\

Details

This is code golf; the shortest program in bytes wins.
Any sequence of one or more of the letters EPBTHFC is valid input.
Your program must be able to output all 7 car types exactly as they appear above.
Take input from the command line or directly from the user (e.g. message box). Output to stdout. (Quotes around input are fine.)
The height of the output should either be 6 or the maximum height needed for the train cars being drawn.
Do not put couplings (--) at the front of the first car or the back of the last car.

Related: http://codegolf.stackexchange.com/q/3628/194 , http://codegolf.stackexchange.com/q/4638/194

Will there always be an E at the front and could there be an E somewhere in the middle?

There could be an E at the back or in the middle or no E's at all. Same goes for every other car type.

"the shortest program wins." => do we count bytes or characters?

@xem, bytes unless otherwise specified

@PeterTaylor: As shown in the example output, presumably.

@Calvin'sHobbies Would you mind clarifying the rules on trailing whitespace and the width of the output - does it have to be a rectangle, or can it have trailing spaces beyond the rectangle defined by non-whitespace characters, or can it be trimmed within the rectangle?

@VisualMelon Having trailing whitespace of any sort is fine. The output lines may form a rectangle or may be staggered or may have no trailing spaces at all. There should be no leading whitespace before the last car, however.

@Calvin'sHobbies Thanks for the clarification, I'm not sure I like having the trailing white-space, but it shaved off 7bytes ;) great question BTW, good fun

Another related question: http://codegolf.stackexchange.com/q/4690/9498

Perl, 265 bytes
Since this entry contains bytes that do not correspond to printable ASCII characters, it cannot be copy-pasted here directly.  Instead, I am providing it as a hex dump.  Users on Unix-ish systems can reconstruct the script by feeding the following hex dump to the xxd -r command:
0000000: 7573 6520 436f 6d70 7265 7373 275a 6c69  use Compress'Zli
0000010: 623b 6576 616c 2075 6e63 6f6d 7072 6573  b;eval uncompres
0000020: 7320 2778 daad 9241 6b83 3014 c7ef f914  s 'x...Ak.0.....
0000030: ef10 6add f67c 5ed6 8b06 c646 476f dda1  ..j..|^....FGo..
0000040: 3723 c183 1d85 8212 c740 087e f625 a6a3  7#.......@.~.%..
0000050: b1f6 24fd 3de1 3d7f e8fb e790 b74a 74ed  ..$.=.=......Jt.
0000060: f9f4 c3e9 25cf a328 6310 a094 6b4c 8c78  ....%..(c...kL.x
0000070: 2569 5406 8a12 8cf8 c7ab 09b1 ff71 0222  %iT..........q."
0000080: 833d da02 b874 2981 c10d 3333 df74 39c1  .=...t)...33.t9.
0000090: f531 d6dc 0f03 8f9f 9666 a12d 7021 6e7a  .1.......f.-p!nz
00000a0: 6416 2807 228e dd99 3584 c40f cc52 53ac  d.(."...5....RS.
00000b0: 9160 82a2 4559 0bcd a22c ff2e 1cc1 0e63  .`..EY...,.....c
00000c0: 9d09 6f85 25b8 13b3 8470 3fe3 5c27 a1eb  ..o.%....p?.\'..
00000d0: df5a 7735 b44d 2b86 9eb6 5fef 87dd e707  .Zw5.M+..._.....
00000e0: a5b8 219d b1ae eaed 3743 4709 f1aa d83c  ..!.....7CG....<
00000f0: f1d5 3357 257d 6be7 1039 9186 63a3 214d  ..3W%}k..9..c.!M
0000100: 9257 f607 1251 a1e7 27                   .W...Q..'

The script uses the Perl 5.10 say feature, and so needs to be run with perl -M5.010.  It takes a single command line argument consisting of the letters EPBTHFC and outputs the corresponding train car arrangement.  For example, the input FEH produces the following output:
                             __
                 ======      \/
_______________  | [] |=========
\ | | | | | | /  |              )
===============--================--===============
 O-O       O-O    O-O-O   O-O-O \\  O-O       O-O

The readable code at the beginning of the script simply decompressed the zlib-compressed string containing the body of the script and evals it.  The decompressed code, in turn, looks like this:
@a=split$/,<<'';
            __
======      \/
| [] |=========
|              )
================--
 O-O-O   O-O-O \\

===============
| [] [] [] [] |
===============--
 O-O       O-O

===============
|-|-|  |  |-|-|
===============--
 O-O       O-O

 _____---_____
(             )
===============--
 O-O       O-O

_______________
\ | | | | | | /
===============--
 O-O       O-O

===============--
 O-O       O-O

    =====
====|   |====
| []     [] |
=============--
 O-O     O-O

$i=reverse pop=~y/EPBTHFC/0-6/r;
say$i=~s/./$a[6*$&+$_]/gr=~s/--$//r for 0..5

Note that all the train cars have their lines padded with spaces to a uniform length, and include the coupling (which is stripped from the rightmost car by the output loop).  The DEFLATE compression used by zlib is very good at compressing such repetitive data, so there's no need to try and compress it by hand.
Note that this is a quick first attempt.  I'm sure it would be possible to shave several bytes off the length by playing with variations such as reordering the train cars in the source.

Python, 464
from curses import*
E,P,B,T,H,F,C='eJyNkM0NgDAIhe9MwVEPpBN0AxMHsKaLdHgfpVr7E+NHUyCQR4C5EiP5jKXBUeLj5ORvkDes5DtEiHeBoWo+hI36NtN9XurrRaVMQTSTEBizPo3+SGBBICLZ0/K9y0whtlDA/Gruj8SwyaRJA9tSPz16qmdTxqO9VeAvC5VloQ=='.decode('base64').decode('zlib').split('L')
i=[s.split('\n')for s in map(eval,raw_input()[::-1])]
h=max(sum(map(bool,s))for s in i)
w=initscr()
x=0
for t in i:[w.addstr(y,x,t[y+6-h])for y in range(h)];x+=len(t[-2])
w.addstr(h-2,x-2,'  ')
w.getch()
endwin()

I went for an approach using curses. It can't really compete, but I had some fun with it (~630 bytes):

from curses import*
E,P,B,T,H,F,C='eJyFkMENwCAIRe9M8Y/tgTiBGzTpALVxEYcvSFqiNO2DCAb8BgCnVsodu5ZEDceJlm/kPrBSniDsLCY1i6VsNDeZ6uMt1GEKMJU3ARYD1DX7F5DRBGbukZbvKeL7OkJF/nZL/wJxhrlFE6vooYtuviwlrso1JF745GMr'.decode('base64').decode('zlib').split('L')
i=[s.split('\n')for s in map(eval,raw_input()[::-1])]
h=max(sum(map(bool,s))for s in i)
w=initscr()
m=w.getmaxyx()[1]
for o in range(-sum(2+len(t[-2])for t in i),m):
 x=o
 for t in i:
  if m>x>o:w.addnstr(h-2,max(x,0),'--'[max(0,-x):],m-x);x+=2
  [w.addnstr(y,max(x,0),t[y+6-h][max(0,-x):],m-x)for y in range(h)if x<m];x+=len(t[-2])
 w.move(h,0);w.refresh();w.clear();napms(90)
endwin()

Wow, that animation is great! (+1) Animated GIFs work in posts, so you could edit the actual image in instead of a link, which would make your solution look fancier. ;)

@Doorknob Thanks. I'll put the image in - I just wasn't sure if an animated GIF would be too annoying.

@grc annoying? are you sure you didn't mean AWESOME?

There's nothing better than an ASCII art gif. +1!

Send it to Homebrew! sl 2.0

_curses.error: addstr() returned ERR on line 7 with EPBTHFC  on a 100x20 window. EPBTH works but does not animate. Any ideas? Python 2.7.3 on Ubuntu.

For the first version, the window needs to be larger than the train. The animated version should work fine, but I haven't put it up yet (I'll do it now).

Python (582 488 476 450 Chars)
import sys
A=sys.argv[1]
h=0
c='eJyVkrEKAzEIhnef4h97g9x+kOVKS7d2uK0peZE8fNXQS3NCpb+BREU/YnIhfKkUgJKpBfIsgYrnCzV9pIFBE6WDCHcWk1zbMy0PGovg/GMPw+6rujwaAY0CWtb/ESwG6NJTjNhChMxQxMy2g06/R+URtxBRRlGWC3SbY8Q1vkXgh4gz+Qb7v7Jy/US1P7TKP3NvbG3fy/V/Cw=='.decode('base64').decode('zlib').split(':')
C={}
for x in c:X=x.split('\n');C[X[0]]=X[1:-1]
for c in A:h=max(h,1+('F..CE'.find(c)+1or 3))
for y in range(6-h,6):print(' -'[y==4]*2).join(C[c][y]for c in A[::-1])

The ascii-salad is a base64 encoded zlib-compressed string containing the figures...

string.decode('base64') 2. j=lambda y:y==4and'--'or'  ' 3. 1-space indents 4. for c in A[::-1]:i.append(C[c][y]) 5. f.append(j(y).join(i)

Also, last 6 lines could be for l in((y==4and'--'or'  ').join(C[c][y]for c in A[::-1])for y in range(6-h,6)):print l

I offered an edit with some improvements.

Come to think of it, the last line could be for y in range(6-h,6):print(y==4and'--'or'  ').join(C[c][y]for c in A[::-1])

@TheRare Incorporated your second(!) improvement! Thy!

How about a third one?

Yes, please! The goal must be to beat the Perl answer with 265 bytes ;-)

For that you would need a better compression. I'm not willing to improve your approach, only the implementation of it.

Quite right! I'm currently thinking about a figlet-solution with a font containing the train cars...

Python, 402 369
import sys
for n in range(6):
 l= sys.argv[1][::-1]
 for x,y in zip("EPBTHFC",range(0,42,6)):
  l=l.replace(x,'eJytktsNgCAMRVfpp340TMAHEziAGBZhePvgLYmGeGosXqQXSAEqIfDbWUElb0SKcF4QbUaljr0srCA6OJCC5jV7cDAyUYY6eQPlic9/kleqoKNVL6QANkmj37zohglElMzK9naJy16hhxRPR6ph/jzXB2XBS76bZpQa3Hex7Qpm1hOtg+Yb0a6PSA=='.decode('base64').decode('zlib').split('A')[y+n]).strip('-')
 print l

Thanks you for the improvements, ugoren!

Thank you for formatting my code! I'm kinda new to this and honestly I do not know what I'm doing.

Save some chars: range(6), for x,y in zip("EPBTHFC",range(0,42,6)):

Java 10, 637 617 600 595 593 592 chars
interface T{static void main(String[]u){String g=" ",n=g+g,m=n+g,s=m+m,h=s+s,q=h+m,o=" O-O",w=o+s+o+n,y="=",d=y+y+y,p="_____",b=d+d,e=b+b,f=n+n,t=e+d,c="|",l=g+c,z=l+l+l,v="|-|-|",k=" []",x=k+k,r=k+l,a[]={h+"__"+n,b+s+"\\/"+n,c+r+b+d+g,c+h+n+")",t+y,o+"-O"+n+o+"-O \\\\",q,q,t,c+x+x+l,t,w,q,q,t,v+g+l+n+v,t,w,q,q,g+p+"---"+p+g,"("+h+" )",t,w,q,q,p+p+p,"\\"+z+z+" /",t,w,q,q,q,q,t,w,h+g,f+d+y+y+f,d+y+c+m+c+d+y,c+k+f+r,e+y,o+f+o+n,n,n,n,n,"--",g};var O=System.out;for(int i=-1,j;i++<5;O.println())for(j=u[1].length();j-->0;O.print(a["EPBTHFC".indexOf(u[1].charAt(j))*6+i]+(j>0?a[42+i]:"")));}}

Try it online!
Readable:
interface T{
    static void main(String[]u){
        // constants - carriages' parts, a[] - array of carriages
        String g=" ",n=g+g,m=n+g,s=m+m,h=s+s,q=h+m,o=" O-O",w=o+s+o+n,y="=",d=
                y+y+y,p="_____",b=d+d,e=b+b,f=n+n,t=e+d,c="|",l=g+c,z=l+l+l,v=
                "|-|-|",k=" []",x=k+k,r=k+l,a[]={h+"__"+n,b+s+"\\/"+n,c+r+b+d+
                g,c+h+n+")",t+y,o+"-O"+n+o+"-O \\\\",q,q,t,c+x+x+l,t,w,q,q,t,v
                +g+l+n+v,t,w,q,q,g+p+"---"+p+g,"("+h+" )",t,w,q,q,p+p+p,"\\"+z
                +z+" /",t,w,q,q,q,q,t,w,h+g,f+d+y+y+f,d+y+c+m+c+d+y,c+k+f+r,e+
                y,o+f+o+n,n,n,n,n,"--",g};
        // output ASCII train
        var O=System.out;
        for(int i=-1,j;i++<5;O.println())
            for(j=u[1].length();j-->0;O.print(
                    a["EPBTHFC".indexOf(u[1].charAt(j))*6+i]+(j>0?a[42+i]:"")));
    }
}

Train carriages. The lower line of each carriage is one character longer because of engine but the lower line of couplings is one character shorter. Double backslashes are escaped characters, they are interpreted as a single backslash:
String a[] = {
        // Engine (E)
        "            __  ",
        "======      \\/  ",
        "| [] |========= ",
        "|              )",
        "================",
        " O-O-O   O-O-O \\\\",
        // Passenger car (P)
        "               ",
        "               ",
        "===============",
        "| [] [] [] [] |",
        "===============",
        " O-O       O-O  ",
        // Boxcar (B)
        "               ",
        "               ",
        "===============",
        "|-|-|  |  |-|-|",
        "===============",
        " O-O       O-O  ",
        // Tanker (T)
        "               ",
        "               ",
        " _____---_____ ",
        "(             )",
        "===============",
        " O-O       O-O  ",
        // Hopper (H)
        "               ",
        "               ",
        "_______________",
        "\\ | | | | | | /",
        "===============",
        " O-O       O-O  ",
        // Flatbed (F)
        "               ",
        "               ",
        "               ",
        "               ",
        "===============",
        " O-O       O-O  ",
        // Caboose (C)
        "             ",
        "    =====    ",
        "====|   |====",
        "| []     [] |",
        "=============",
        " O-O     O-O  ",
        // Car coupling
        "  ",
        "  ",
        "  ",
        "  ",
        "--",
        " "};

Train EPBTHFC:
                                                                                __
    =====                                                                                ======      \/
====|   |====                   _______________   _____---_____   ===============  ===============  | [] |=========
| []     [] |                   \ | | | | | | /  (             )  |-|-|  |  |-|-|  | [] [] [] [] |  |              )
=============--===============--===============--===============--===============--===============--================
 O-O     O-O    O-O       O-O    O-O       O-O    O-O       O-O    O-O       O-O    O-O       O-O    O-O-O   O-O-O \\

Java (583 characters)
With basic homemade compression - not sure it's so efficient though :-)
The train string (e.g. EEHTBPFC) must be passed as parameter.
class C{public static void main(String[]a){String s="",y="thAthA",x=" *!*h*!* A",q="vjA",r=q+x+y;String[]m=("hP78A^\\#$8A% &' %j.,A%hh) Ajj.A *!*!*8*!*!* /A"+y+q+"% &' &' &' &' %A"+r+q+"%!%!%,%,%!%!%A"+r+" [9[ A(tP)A"+r+"ss+A# % % % % % % $A"+r+y+q+x+"tPADRDAF%8%FA% &'P&' %AvRA *!*P*!* ").split("A");for(int l,z,i,j=0;j<6;j++){for(i=a[0].length()-1;i>=0;i--){z=a[0].charAt(i);r=m["EPBTHFC".indexOf(z)*6+j];for(int c:r.toCharArray()){c-=32;for(l=0;l<=c/12;l++)s+=" -=\\/|[]()O_".charAt(c%12);}if(i>0)for(l=0;l<(z=='E'&&j!=4?1:2);l++)s+=j==4?"-":" ";}s+="\n";}System.out.println(s);}}

Unfolded:
class C{
    public static void main(String[]a){
        String s="",y="thAthA",x=" *!*h*!* A",q="vjA",r=q+x+y;
        String[]m=("hP78A^\\#$8A% &' %j.,A%hh) Ajj.A *!*!*8*!*!* /A"+y+q+"% &' &' &' &' %A"+r+q+"%!%!%,%,%!%!%A"+r+" [9[ A(tP)A"+r+"ss+A# % % % % % % $A"+r+y+q+x+"tPADRDAF%8%FA% &'P&' %AvRA *!*P*!* ").split("A");
        for(int l,z,i,j=0;j<6;j++){
            for(i=a[0].length()-1;i>=0;i--){
                z=a[0].charAt(i);
                r=m["EPBTHFC".indexOf(z)*6+j];
                for(int c:r.toCharArray()) {
                    c-=32;
                    for(l=0;l<=c/12;l++)
                        s+=" -=\\/|[]()O_".charAt(c%12);
                }
                if(i>0)for(l=0;l<(z=='E'&&j!=4?1:2);l++)s+=j==4?"-":" ";
            }
            s+="\n";
        }
        System.out.println(s);
    }
}

557 bytes

C#, 758 664 603 562bytes
Not a great score, 200 or so bytes in the poorly encoded string, and about 80 bytes devoted to decoding it. Frustrating amount of code spent sorting out the coupling on the engine! It now leaves white-space trailing at the front of the train, which is untidy but within the rules, and it also has the dimensions of the data-string hard coded, something I was reluctant to do initially.
using c=System.Console;class P{static void Main(){string d=c.ReadLine(),a="",z=@"99 1_5 4=78 5=5 \/1 3=|2 |3=14 29= 4_2-4_ 14_| [] |8= | []4 [] |14 | [] [] [] [] 1|-|-|1 |1 |-|-|(12 )\ | | | | | | /|13 )103= O-O4 O-O1 O-O6 O-O1 O-O6 O-O1 O-O6 O-O1 O-O6 O-O1 O-O6 O-O1 O-O-O2 O-O-O c";int j=0,e;foreach(var h in z)if(h>47&&h<58)j=j*10+h-48;else for(j++;j>0;j--)a+=h;int[]x={0,13,28,43,58,73,88,104};for(;j<6;j++){z="";foreach(var h in d)z=a.Substring(j*104+x[e="CFPBTHE".IndexOf(h)],x[e+1]-x[e])+(j==4?"--":"  ")+z;c.WriteLine(z.Replace("c ",@"\\").Trim('-'));}}}

Formatted a bit:
using c=System.Console;
class P{static void Main(){
    string d=c.ReadLine(),a="",z=@"99 1_5 4=78 5=5 \/1 3=|2 |3=14 29= 4_2-4_ 14_| [] |8= | []4 [] |14 | [] [] [] [] 1|-|-|1 |1 |-|-|(12 )\ | | | | | | /|13 )103= O-O4 O-O1 O-O6 O-O1 O-O6 O-O1 O-O6 O-O1 O-O6 O-O1 O-O6 O-O1 O-O-O2 O-O-O c";

    int j=0,e;

    foreach(var h in z)
        if(h>47&&h<58)
            j=j*10+h-48;
        else
            for(j++;j>0;j--)
                a+=h;

    int[]x={0,13,28,43,58,73,88,104};

    for(;j<6;j++)
    {
        z="";
        foreach(var h in d)
            z=a.Substring(j*104+x[e="CFPBTHE".IndexOf(h)],x[e+1]-x[e])+(j==4?"--":"  ")+z;
        c.WriteLine(z.Replace("c ",@"\\").Trim('-'));
    }
}}

The string is compressed very simply by replacing repeated character with a string representation of the number of characters followed by the character (minus 1), or just the character if there is only one of them (I wanted to stick with ASCII and avoid doing anything at the sub-char level). Encoder (not included in score):
string compress(string str)
{
    str += (char)0; // too lazy to write a proper loop
    string res = "";

    char prev = str[0];
    int count = 1;

    for (int i = 1; i < str.Length; i++)
    {
        char cur = str[i];
        if (cur != prev)
        {
            if (count != 1)
                res += (count - 1).ToString();
            res += prev;

            prev = cur;
            count = 1;
        }
        else
        {
            count++;
        }
    }

    return res;
}

Here is my solution in PHP (v5.4 compatible), 512bytes. Could be shorter, but just made a quick build to try this out.
<?php $m=array_combine(str_split('EPBTHFC'),explode('$',gzinflate(base64_decode('jZDBDYAwCEXvfwoOHvRAnKAzOICYLtLhhVYlrY320RQI5BMgcmJEyJRUViTaD0rhRvOKBaEBtLGa1ooXmdA2FdXnJfQ0rgkW9RRYjcieRQMKupzCzNlj/t6jIxBrIDrdbR1QwH+PRaVkn107+cWM971cxPwJ'))));$t=['','','','','',''];$i=str_split(strrev(strtoupper($argv[1])));foreach($i as $w=>$n){$c=$m[$n];$c=explode("\n",$c);foreach($t as $j=>&$p){$p.=str_pad($c[$j],$n=='E'?18:($n=='C'?15:17),$j==4?'-':' ');if($w==count($i)-1)$p=rtrim($p,' -');}}echo implode("\n",$t)."\n";

This is a spread-out version for easy reading:
<?php
$m=array_combine(
  str_split('EPBTHFC'),
  explode('$',
    gzinflate(
      base64_decode(
        'jZDBDYAwCEXvfwoOHvRAnKAzOICYLtLhhVYlrY320RQI5BMgcmJEyJRUViTaD0rhRvOKBaEBtLGa1ooXmdA2FdXnJfQ0rgkW9RRYjcieRQMKupzCzNlj/t6jIxBrIDrdbR1QwH+PRaVkn107+cWM971cxPwJ'
      )
    )
  )
);
$t=['','','','','',''];
$i=str_split(strrev(strtoupper($argv[1])));
foreach($i as $w=>$n)
{
  $c=$m[$n];
  $c=explode("\n",$c);
  foreach($t as $j=>&$p)
  {
    $p.=str_pad($c[$j],$n=='E'?18:($n=='C'?15:17),$j==4?'-':' ');
    if($w==count($i)-1)$p=rtrim($p,' -');
  }
}
echo implode("\n",$t)."\n";

Python, 491 bytes
import zlib as z,sys,base64 as d
y=eval(z.decompress(d.b64decode('eNqlksEOwiAMhl/lv1WTkd1NdtFovLmDt7HwIOK729LJmJDY6F8SyA/0g6YPOtNhIhQKAaCOhiS1fJ+siGlGHN5Sa6N9vriKLdwcB+/r7D3NHY2fYCRI7dT50kPyiM0zUCKUCiEe/yA6DkCGrKzEu5XIVWc559Iszu5bYdvEq5UYtmLH8/fW6K3Ei/mPP1W+QTxVxCVXbtklk3RnLHtG1OqYkqOU5wsfZZmx')))
w=sys.argv[1][::-1]
x=[""]*6
v=range
u=len(w)
for j in v(6):
 for i in v(u):
  if j==5 and w[i]=='E':k="\\ "
  elif j==4 and i!=u-1:k="--"
  else:k="  "
  x[j]+=y[w[i]][j]+k
for q in x:print q

I like how it came out, even though it won't be a winner.

You could change if j==5...x[j]+=y[w[i]][j]+k to x[j]+=y[w[i]][j]+('\\ 'if j==5 and w[i]=='E'else'--'if j==4 and i!=u-1 else'  ') to save a bit. (Also you can put a tab instead of two spaces in front of x[j]....)

C (gcc), 501 499 490 489 484 483 481 bytes
-2 -9 -1 -5 -1 -2 bytes thanks to ceilingcat.
#define A": O-Og O-O:o=:"
char*p,*q,s[80];i=6,k,n;main(j,a)char**a;{for(;i--;puts(q))for(k=strlen(a[1]);k--;*q=0,printf("%-*s%s",j?j^6?15:13:16,s,k?i^1?!j*!i+"  ":"--":q)){j=index(p="EPBTHFC",a[1][k])-p;for(n=j*6+i,p=" O-O-Oc O-O-O \\\\:p=:|n ):| [] |i=:f=f \\/:l __"A"| [] [] [] [] |:o=::"A"|-|-|  |  |-|-|:o=::"A"(m ): e_c-e_::"A"\\ | | | | | | /:o_::"A":::: O-Oe O-O:m=:| []e [] |:d=|c |d=:d e=::";n--;)for(;*p++-58;);for(q=s;*p^58;q+=n)memset(q,*p++,n=islower(*p)?*p++-96:1);}}

Try it online!

GNU sed, 491 bytes
s/./& #/g
s:E:0S__s%1esss\\/s%2|bpef %3|Ss)%4E=@5 o-Os o-O \\\\:g
s/P/zE%3|bbbbp%4E@5ut/g
s/B/zE%3|-|-|s|s|-|-|%4E@5ut/g
s/T/z l---l %3(S )%4E@5ut/g
s:H:zlll%3\\pppppp /%4E@5ut:g
s/F/zSs %3Ss %4E@5ut/g
s/C/0S %1ssf==ss%2f=|spf=%3|bssbp%4ee=@5 ts t/g
s/z/0Ss %1Ss %2/g
s/%/s%/g
s/@/--%/g
s/u/ tss /g
s/t/os/g
s/S/ssssss/g
s/s/  /g
s/E/eef/g
s/e/ff/g
s/f/===/g
s/b/ []/g
s/p/ |/g
s/o/O-O/g
s/l/_____/g
s/^/0123456;/
:
s/([0-6])(.*;)\1([^%#]+)[%#](.*)/\1\3!\2\4/
t
s/(--!)?[1-6]/\n/g
s/[0!;]//g

Try it online!
Explanation
This is basically a super naïve custom compression scheme. The first line appends to each letter in the input a space and #, to mark the end of each part:
s/./& #/g

The next 7 lines replace each letter with a compressed representation of the corresponding ASCII image:
s:E:0S__s%1esss\\/s%2|bpef %3|Ss)%4E=@5 o-Os o-O \\\\:g
s/P/zE%3|bbbbp%4E@5ut/g
s/B/zE%3|-|-|s|s|-|-|%4E@5ut/g
s/T/z l---l %3(S )%4E@5ut/g
s:H:zlll%3\\pppppp /%4E@5ut:g
s/F/zSs %3Ss %4E@5ut/g
s/C/0S %1ssf==ss%2f=|spf=%3|bssbp%4ee=@5 ts t/g

The next 14 lines do the "decompression". For example, an S decompresses to six ses, and an s decompresses to two spaces, so S becomes 12 spaces.
s/z/0Ss %1Ss %2/g
s/%/s%/g
s/@/--%/g
s/u/ tss /g
s/t/os/g
s/S/ssssss/g
s/s/  /g
s/E/eef/g
s/e/ff/g
s/f/===/g
s/b/ []/g
s/p/ |/g
s/o/O-O/g
s/l/_____/g

Decompressed, the lines of each car are preceded by a line number, and each car is terminated by #. The rest of the code prepends 0123456; (the line numbers and delimiter) to the pattern space and then, in a loop, replaces each digit with the corresponding line of each car.
s/^/0123456;/
:
  s/([0-6])(.*;)\1([^%#]+)[%#](.*)/\1\3!\2\4/
  t

Finally, it cuts the pattern space into lines by splitting on digits and cleans up extraneous characters:
s/(--!)?[1-6]/\n/g
s/[0!;]//g

There's a lot of room for improvement here. I wasn't rigorous at all about finding an optimal set of compressions, and using a lookup table instead of 14 separate s///gs would be an easy win. I may or may not noodle with this some more.

Python 3, 529 bytes
a=['']*6
T,R="EPBTHFC",{'S':' '*3,'E':'='*3,'W':'[] ','U':'_'*5,'P':'| ','H':'O-O'}
A=('SSSS__  ',)+('S'*5,)*5+('SSSS ',),('EESS\/  ',)+('S'*5,)*5+('S E==S ',),('PW|EEE ','E'*5,'E'*5,' U---U ','U'*3,'S'*5,'E=|S|E='),('P SSSS)','PWWWW|','|-|-P P |-|-|','(SSSS )','\ PPPPPP/','S'*5,'PWS W|'),('E'*5+'=--',)+('E'*5+'--',)*5+('EEEE=--',),(' H-OSH-O \\\\ ',)+(' HSS HS',)*5+(' HS  HS',)
for C in input():
 for I in range(6):
  a[I]=A[I][T.index(C)]+'  '*(I<4)+a[I]
  for k in R:a[I]=a[I].replace(k,R[k])
a[4]=a[4][:-2]
[*map(print,a)]

Try it online!
Figured I would post it because it does not use any compression, unlike most of the other answers here.

Javascript (Node.js), 1216 bytes
var c={E:['            __  ','======      \\/  ','| [] |========= ','|              )','================',' O-O-O   O-O-O \\',],P:['               ','               ','===============','| [] [] [] [] |','===============',' O-O       O-O'],B:['               ','               ','===============','|-|-|  |  |-|-|','===============',' O-O       O-O'],T:['               ','               ',' _____---_____ ','(             )','===============',' O-O       O-O '],H:['               ','               ','_______________','\\ | | | | | | /','===============',' O-O       O-O '],F:['               ','               ','               ','               ','===============',' O-O       O-O '],C:['             ','    =====    ','====|   |====','| []     [] |','=============',' O-O     O-O ']};var o=[];for(var w=0;w<process.argv[2].length;w++){o.push(process.argv[2].charAt(w));}var arg=o.reverse().join('');var s=['  ','  ','  ','  ','--','  '];for(var x=0;x<6;x++){var k=[];for(var y=0;y<arg.length;y++){if(!['B','C','E','F','H','P','T'].includes(arg.charAt(y))){y++;}k.push(c[arg.charAt(y)][x]);}var v='';for(var q in k){v+=k[q]; if(arg.charAt(q)=='E'&&x== 5){v+='\\ ';}else if(q<k.length-1){v+=s[x];}}console.log(v);}

Uncompressed
var c = { // define cars
    E: [
        '            __  ',
        '======      \\/  ',
        '| [] |========= ',
        '|              )',
        '================',
        ' O-O-O   O-O-O \\',
    ],
    P: [
        '               ',
        '               ',
        '===============',
        '| [] [] [] [] |',
        '===============',
        ' O-O       O-O'
    ],
    B: [
        '               ',
        '               ',
        '===============',
        '|-|-|  |  |-|-|',
        '===============',
        ' O-O       O-O'
    ],
    T: [
        '               ',
        '               ',
        ' _____---_____ ',
        '(             )',
        '===============',
        ' O-O       O-O '
    ],
    H: [
        '               ',
        '               ',
        '_______________',
        '\\ | | | | | | /',
        '===============',
        ' O-O       O-O '
    ],
    F: [
        '               ',
        '               ',
        '               ',
        '               ',
        '===============',
        ' O-O       O-O '
    ],
    C: [
        '             ',
        '    =====    ',
        '====|   |====',
        '| []     [] |',
        '=============',
        ' O-O     O-O '
    ]
};
//reverse string - why is there no builtin for this?
var o = [];
for(var w = 0; w < process.argv[2].length; w++){
    o.push(process.argv[2].charAt(w));
}
var arg = o.reverse().join('');
//train car seperators
var s = ['  ','  ','  ','  ','--','  '];
// for each row
for(var x = 0; x < 6; x++){
    var k = []; //empty array for each car string
    for(var y = 0; y < arg.length; y++){
        //ignore non-included characters
        if(!['B','C','E','F','H','P','T'].includes(arg.charAt(y))){
            y++;
        }
        // add car
        k.push(c[arg.charAt(y)][x]);
    }
    var v = '';
    for(var q in k){
        v += k[q]; // append car
        if(arg.charAt(q) == 'E' && x == 5){ // to deal with annoying engine thing, see below
            v += '\\ ';
        } else if(q < k.length - 1){ // if not last car
            v += s[x]; // append separator
        }
    }
    console.log(v); //output
}

The annoying thing about this challenge is the coupling near the engine.
All the other cars are just one solid block, but the \ on the front takes up the same vertical space as the coupling. See here:
            __
======      \/
| [] |=========
|              )
================--
 O-O-O   O-O-O \\

Note: Enter via the CLI e.g. node asciitrain.js EBCEFH. This was badly golfed.

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


text:
Generate me some appropriate license plates!

The scenario: You are a software designer working for a gov't-run company that designs license plates for cars and other vehicles. You've been asked to develop software that generates license plates. Before you got to work, your bosses laid down these ground rules.

A license plate cannot contain:

ASS
666
69<any number here>
<any number here>69
KKK
SHT

Rules and requirements:

License plate must be randomly generated.
Once a random license plate is generated, the same license plate cannot be generated again.
You must output at least 200 unique license plates. You can generate more if you want to.
You may store generated plates in a file to "remember" them.
The license plate contains 2 sections, one containing only three letters, and one containing only three numbers, separated by a dash, like this: 233-ADF or ADF-233.
You can only use numbers and capital letters.
License plates can be written to stdout, or a file.
Each "side" of a license plate will contain either three numbers or letters.
This is a code-golf, so shortest, most popular, answer wins. Winner will be chosen after seven days.

General rules

Answer should include, but not limited to, the following.
Language name.
Character count.
File size.
How the code is run.
The code itself.
Example: Python 234 chars or Python 23mb.

If I need to clarify any additional details, please mention it in the comments and I will add it to my post. Anyways, good luck, and generate me some appropriate license plates!

Update 1: Winner will be chosen slightly earlier.
Turns out I have to go on a trip soon, so I will be choosing a winner around 00:00 UTC, July 25. After the winner is chosen, you can still submit entires, just know that a winner has been chosen. Bai.

Update 2: Winners!
We have winners! Yay! Cheese and wine to everyone who participated! Here's who won.

1st place: Àngel - Bash (95 characters)
2nd place: Martin Büttner - Mathematica (182 bytes)
2nd place: Emilio M Bumachar - Pyg (92 ?)
2nd place: Peter Taylor - Golfscript (98 characters)
3rd place: Mark Thomas - Ruby (127 characters)

Wow, three second place ties. Wow. The competition is over, but feel free to submit entries if you want to. Bai!

"Once a random license plate is generated, the same license plate cannot be generated again." What about non-random licence plates?

@PeterTaylor I'm a bit confused, what do you mean by "non-random"?

The obvious way to do this (and probably the way it works in real life) is to generate the numbers in order.

@PeterTaylor Sure, you can do that.

Would suggest adding random requirement, else it is really trivial.

@bitpwner I did add that.

"Randomly generated" is imprecise. I presume you mean "uniformly selected at random from the unused legal licence plates" rather than, say, uniformly selected at random from the legal licence plates beginning AAA-

@PeterTaylor Yes, you are correct.

please tell how many digits should be in every plate, and what characters are valid - it varies from country to country

@proudhaskeller Each section contains three letters and three numbers, separated by a -, like this: ADD-127 or 345-GHD.

oh so its only 3 characters. it wasn't specified. thanks

I'm now somewhat tempted to write a program to generate random license plates that contain some obscene or otherwise inappropriate string not found in your list.

@IlmariKaronen Like what? Should what you're thinking of even be said aloud here?

I'm sure you could think of plenty, but just to name a few obvious variations, you seem to have disallowed SHT-___ but not SHI-7__, _SH-17_ or __5-HIT.

@IlmariKaronen I think it might be a little late to add new "banned words" as there are already 14 answers.

Similarly, A55-___ is  allowed by these rules.

@dan04 If you read carefully, one side is letters, while the other side is numbers. Numbers and letters can't mix on the same side.

The real government database of license plates is much larger. http://jalopnik.com/5975180/these-are-the-hilarious-vanity-license-plates-you-cant-have-in-georgia They are vanity plates in Georgia though

I'm 16 and I don't think I'm immature enough to put the banned words in my code lol, yet we have to be told its forbidden, what is this world coming to lol

Is it ok if a program generates plates having digits only on the left side e.g. 233-ADF or only on the right side e.g. ADF-233?

@CristianCiupitu Yes, it is.

bash (95 chars)
Save the script as m in a folder in your PATH with execute bit set.
Run as bash m. The plates are stored in file p
l(){ tr -dc $1</dev/urandom|head -c3;};egrep -ve"ASS|666|69|KKK|SHT" -fp>>p<<<`l 0-9`-`l A-Z`;m

This is equivalent to running the following:
# Print three random numbers and three random letters
echo $(tr -dc 0-9 < /dev/urandom | head -c3)-$(tr -dc A-Z < /dev/urandom | head -c3) |

# Print only plates not matching the blacklist or any line of p
# Append the plates ton p
egrep -v -e "ASS|666|69|KKK|SHT" -f p >> p

# Execute itself again
m

Caveat: The final m should actually be exec m (+5 chars) in order to avoid leaving processes waiting for completion (but you can have thousands without much problem)
Credit goes to  http://www.cyberciti.biz/faq/linux-random-password-generator/ for the idea of using tr -dc

Is it to me or the uniqueness requirement is missing?

@Cristian-Ciupitu: The grep -v is excluding both the blacklist and the list of plates we already generated (grep is expecting p to contain one pattern per line, but as the plates don't contain regular expression metacharacters, they only match themselves). We only generate one or zero plates per iteration, so after each iteration the full (updated) list of plates to exclude will be read by grep. :D

PYG - 92
Pe(Se(Re.sub(".*(666|69|ASS|KKK|SHT).*","",J(RSm(STuc*3,3)+[j]+RSm(STd*3,3)))for j in'-'*K))

Now able to select uniformly from all unused plates, keeping to OP's specs, while being shorter by 1 more character.
It's theoretically possible that the list of 999 plates will contain enough repetitions so that the trimmed set will be less than 200. But the odds of that are infinitesimally small. In ten trials, the lowest length I got was 994.
EDIT: changed 999 to K (which is pyg for 1000), to save two chars at the advice of  bitpwner.

Did you filter out the disallowed values? Don't see any KKK or 666 anywhere.

@bitpwner: I use only the digits from 0 to 5 and letters from A to J, so the disallowed values cannot occur.

Very clever! Nobody ever said those others had to be used. Nice.

OP agreed to the randomness being "uniformly selected at random from the unused legal licence plates". See comments in question. Unless your definition of uniform means uniform from any range. And you can change 999 to K, saving u 2 chars.

Not sure I'd count output as random if there's valid plates that are impossible to generate...

Mathematica, 182 bytes
Ugh, this is long
l={};While[Length[l=Union@Pick[l,StringFreeQ[l,"ASS"|"666"|"69"|"KKK"|"SHT"]]]<200,AppendTo[l,RandomSample[FromCharacterCode/@{48+9~(r=RandomInteger)~3,65+25~r~3}]~Riffle~"-"<>""]];l

Ungolfed
l = {};
While[
  Length[
    l = Union@
      Pick[l, StringFreeQ[l, "ASS" | "666" | "69" | "KKK" | "SHT"]]
  ] < 200,
  AppendTo[l,
   RandomSample[
      FromCharacterCode /@ {48 + 9~(r = RandomInteger)~3,
        65 + 25~r~3}]~Riffle~"-" <> ""]
  ];
l

Pretty straight-forward. Generates random plates, and filters out duplicates and forbidden ones until 200 are found.

GolfScript (98 chars)
260{3?}:^~,{.10^+`-3>'-'+\10^/26^+26base(;{65+}%+.-1%}%{'ASSKKKSHT66669'3/{1$\?)!},*},{,^^rand}$n*

This generates all possible licence plates in a random order using some ugly base conversion followed by filtering. There are a lot of them, so don't expect it to execute quickly, but the question didn't place any constraints on execution time.

JavaScript (ES6) - 213
It can probably be improved. Tested on Firefox Console.
Change that alert to a console.log() if you want to test
r=x=>~~(Math.random()*x)+'';l=x=>[...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'][r(26)];a=[];while(a.length<200)p=r(10)+r(10)+r(10)+'-'+l()+l()+l(),!/ASS|666|69|KKK|SHT/.test(p)&&a.indexOf(p)<0&&a.push(p);a.forEach(x=>alert(x))

Wow, that has to be the longest single line of code I've ever seen.

@DatEpicCoderGuyWhoPrograms you obviously haven't seen my 400+ char single-line JS regex ;)

@eric_lagergren That sounds like it would have been a pain to write...

@DatEpicCoderGuyWhoPrograms You can write it over multiple lines then remove the unnecessary whitespaces. There are multiple online services who offer that + other shortening (replacing function /var etc. names) to reduce js file sizes and subsequently save bandwidth.

@SBoss, I guess, whenever I do code-golf, I always try to write it in it's golfed form first, which never works.

@DatEpicCoderGuyWhoPrograms optimize afterwards. I figure out how to correctly solve the problem, then I try and find shortcuts, and then I finally optimize my code :P a lot simpler

Ruby — 136 133 129 characters
Hideous. Think there's room for improvement, though. Just drop the code in irb or pry and hit enter to run:
f=->*t{[0,1,2].map{t.sample}*''}
g=->l{(a=f[*?A..?Z]+?-+f[*?0..?9];l|=[a]if/69|666|ASS|SHT|KKK/!~a)until l.size>199;l}
puts g[[]]

Python 2.7 - 258 chars
I'm not a professional programmer or anything, so I'd say I'm satisfied with the result.
import random as o
r=o.randint
t,j,k=[],0,""
b=["SHT","KKK","ASS","69","666"]
for i in range(200):
 l,j=b[0],b[4]
 while any(w in l for w in b):
  l,j="",""
  for i in range(3):
   l+=chr(r(65,90))
   j+=str(r(0,9))
 t.append(l+'-'+j)
print "\n".join(set(t))

Filesize is 4.0 K, run with python file.py !

Shouldn't that pass be a continue? You can also save some chars by indenting with a 1 space instead of 4.

Also for i in range(0,200): could be replaced with for i in range(200):.

@CristianCiupitu I couldn't get it to do the full 200 when using continue.. But pass did the trick. Plus, it's shorter. And when I tried for i in range(200), it only did 199 ^^ I counted them afterwards by making a duplicates variable and putting duplicates += 1 before pass and counting the occurrences for - in the list/string.

@CristianCiupitu range(200) worked after all - the 4 spaces in the code block are actually \t and replacing them by 1 space didn't change the character count... Thanks for the suggestions!

A user suggested in a suggested edit to simply remove if k in t: pass, as it does nothing.

This user did.

@Doorknob Does that mean duplicates weren't being removed? continue should work after all then... my apologies

There's also another issue: the plates have letters before digits every time, their order is not randomized.

@CristianCiupitu But... The license plate contains 2 sections, one containing only three letters, and one containing only three numbers, separated by a dash, like this: 233-ADF or ADF-233.

@Adam, your program generates only the second type of plates, it won't generate something like 233-ADF.

@CristianCiupitu I thought only one of two was required :/

@Adam, that was also my first thought, but then I realized the order matters too. Though the best option would be to ask the OP to clarify this.

Ruby,  127 chars
My attempt at a "readable" Ruby version:
a=[]
until a.size==200 do
  p="#{rand(899)+100}-#{('A'..'Z').to_a.sample(3).join}"
  a<<p unless p=~/69|666|ASS|SHT|KKK/
end
puts a

Note that this generates compliant license plates, but won't generate the entire set of possible plates (as with most of these answers). That doesn't seem to be a requirement.

Python - 208
Hi heres my stab at license plate generation. This solution is similar to @bitpwner's solution but without the string module and instead of a list for the license plate I chose to use a set and its also allows numbers first.
import random as r,re
f=r.randint
l=lambda x:chr(f(65, 90))if x else`f(0,9)`
d=set()
while len(d)<200:
 k=f(0,1);j=1-k;c=l(k)+l(k)+l(k)+'-'+l(j)+l(j)+l(j)
 if not(re.search("666|69|ASS|KKK|SHT",c)):d.add(c)

Sample output:
set(['DQJ-641', '086-QRY', '981-GAZ', 'UHN-718', '114-VMI', 'GLO-887',  ...

Python, 252 bytes
Here's my contribution. I'm impressed with it, but I know others have done better with python.
from random import randint as r
f=()
while len(f)<200:
 t=str(r(0,999))
 if not("666" in t or "69" in t):
  u=''.join(chr(r(65,90)) for _ in [1,2,3])
  if not("KKK" in u or "SHT" in u or "ASS" in u):f+=("%s-%s"%(t.zfill(3),u),)
 f=tuple(set(f))
print f

Python - 165
Those imports...
import random as r,re
j="666|69|ASS|KKK|SHT"
t=r.randint
while len(j)<2e3:
 exec"x="+"chr(t(0,25)+65)+"*3+"'-'"+"+`t(0,9)`"*3
 if not re.search(j,x):print x;j+='|'+x

If there is a need to begin randomly with either numbers or alphabets, which I don't think is really needed, then 190.
import random as r,re
j="666|69|ASS|KKK|SHT"
t=r.randint
while len(j)<2e3:
 exec"x="+"chr(t(0,25)+65)+"*3+"'-'"+"+`t(0,9)`"*3
 x=x[::r.choice((-1,1))]
 if not re.search(j,x):print x;j+='|'+x

Chars or bytes?

May I suggest PYG? https://gist.github.com/Synthetica9/9796173

I count 208 chars, and does your solution allow numbers first?

@willem The four spaces for indentation are actually tabs, and alphabets first only.

PHP 341 324 320
Was the best I could do.
<?$a="p";$b=fopen($a,'a+');while($c<200){$d=rand(100,999);$e='';for($f=0;$f<3;++$f)$e.=chr(rand(65,90));$g=(rand(1,2)==1)?"$d-$e":"$e-$d";$h=array('ASS','666','69','kkk','SHT');$i=1;foreach($h as $j)!preg_match("/$j/",$g)?:++$i;if($i==1){$k=fread($b,filesize($a));if(!strpos($k,$g)){fwrite($b,$g);echo"$g
";++$c;}}}

To run the code just save as a .php file and browse to it on any web server. It will attempt to create the blacklist file p.txt if it does not exist already. However you may need to define it with a full server path if you do not have root access.
The code itself is here pre golfification:
<?
// create random plate
// check it does not break rules
// check is not on all time blacklist file
// Add to blacklist file
// Output to screen

// open file handle
$file = "p"; // filename and path if not root access
$fh = fopen($file, 'a+');

// do 200
while($x<200) {

    // get random number
    $rand_number = rand(100,999);

    // get random letters
    $letters = '';
    for($y=0; $y<3; ++$y) $letters .= chr(rand(65,90));

    // mix up combination
    $string = (rand(1,2)==1) ? "$rand_number-$letters" : "$letters-$rand_number";

    // assume is ok
    $ok = 1;

    // Set checks to be excluded on new plates.
    $checks = array('ASS','666','69','kkk','SHT');

    // do the exclusions
    foreach ($checks as $check) !preg_match("/$check/", $string) ? : ++$ok;

    // if all ok, check is not on the blacklist
    if($ok == 1) {

        // read blacklist
        $blacklist = fread($fh, filesize($file));

        // if not on blacklist, add it to file, echo it to output, increment counter
        if (!strpos($blacklist, $string)) {
            fwrite($fh, $string);
            echo "$string
";
            ++$x;
        }
    }
}

Was as short as I could get it :-(
Sample Output
XWU-888
PUD-534
355-QXG
WDE-402
113-QID
362-YBW
TBK-594
939-XDT
148-ARZ
838-ICY
723-ZDA
.... does exactly 200 new plates.

EDIT: tidied up a couple of if statements to use short form.

If the plates do not have to be mixed up - ie can be numbers then letters only, I could lose this line
$string = (rand(1,2)==1) ? "$rand_number-$letters" : "$letters-$rand_number";

You could use a single-character filename (e.g., p instead of p.txt) and save yourself 4 characters, too.

@Mark I didn't know you could do that. Tested it and it worked fine. Read up on file extensions and they do not work quite the way I thought they did. Thank you, that was very interesting.

F#, 264 chars
Not really a language designed for golfing, but I'm sure this could be improved.  Using Seq.exists with a lambda is pretty annoying, as are the many parens and lack of implicit conversion.
Uses recursion, keeps going forever.
let g=System.Random()
let c()=char(g.Next(65,90))
let k(i:string)l=Seq.exists(fun e->i.Contains(e))l
let rec p d:unit=
 let l=sprintf"%i-%c%c%c"(g.Next(100,999))(c())(c())(c())
 if k l d||k l ["ASS";"666";"69";"KKK";"SHT"]then p d else
  printfn"%s"l
  p(l::d)
p[]

Can be run in FSI.

Python 203
I'm not sure if this technically counts, but I liked it so I'm posting it anyway. While I do generate the answers pseudo-randomly, as pretty much everyone else did, I strategically picked the random seed such that invalid answers wouldn't end up in the output. So, my answer isn't actually capable of generating the entire set of valid answers, without also generating the invalid ones.
from random import*;seed(1);L='ABCDEFGHIJKLMNOPQRSTUVWXYZ';D='0123456789';C=choice
for i in 'x'*200:s=randint(0,1);a=''.join(C(L)for _ in'000');b=''.join(C(D)for _ in'000');i=[a,b];print i[s-1]+'-'+i[s]

Perl - 123 Characters
while(@p<200){$l=(AAA..ZZZ)[int rand 999]."-".(100+int rand 899);@p=grep!/ASS|666|69|KKK|SHT|$l/,@p;push@p,$l}$,=$/;print@p

Ungolfed:
while(@p < 200){ # Repeat until we get 200 plates
    $l = (AAA..ZZZ)[int rand 999]."-".(100+int rand 899); # generate the license plate
    @p = grep !/ASS|666|69|KKK|SHT|$l/, @p; # remove disallowed license ones and duplicates
    push @p, $l # add a license plate
}
$,=$/; # so they print with newlines
print @p # print the plates

If anyone has ideas to golf it further, let me know, I am interested. If you want further explanation of part of the code, leave a comment and I'd be happy to explain more too.

Cobra - 198
class P
    def main
        l,r=[],Random()
        while l.count<200
            a,b=r.next(1000),''
            for i in 3,b+='[r.next(65,91)to char]'
            if not ('69'in'[a]'or 666==a or b in'ASS KKK SHT'),l+=['[a]-'+b]
        print l

Delphi, 161 bytes
Here is my take on this. It outputs license plates to stdout without line feed between them. If LF is needed (not specified in the rules), than that adds extra 4 bytes.
Golfed version:
var S,L:string;begin repeat Str(100+Random(69),S);S:=S+'-';while Length(S)<7do S:=S+Chr(65+Random(10));if Pos(S,L)=0then L:=L+S;until Length(L)>1393;Write(L)end.

Ungolfed:
var
  S, L: string;
begin
  repeat
    Str(100 + Random(69), S); // generate and add first three numbers
    S := S + '-'; // add dash
    while Length(S) < 7 do // generate and add last three letters
      S := S + Chr(65 + Random(10));
    if Pos(S, L) = 0 then // check if its not in the L string and add it
      L := L + S;
  until Length(L) > 1393; // exit loop once L string has more than 1393 chars (199 * 7 = 1393)
  Write(L); // output L to stdout
end.

How to run:
app.exe > plates.txt

Python3, 257 chars
import string as X,re,random as R
I=[0,1,2]
s={}
while len(s)<200:
 L=R.sample([[R.choice(X.digits) for i in I],[R.choice(X.ascii_uppercase) for i in I]],2);L=''.join(L[0]+['-']+L[1])
 if re.search('ASS|KKK|SHT|69|666',L) or L in s:continue
 print(L);s[L]=0

Sample output:
# python3 shortened.py
EUN-215
546-SIL
464-ZTR
XIX-794

You can save a byte by separating line 5 and 6 by ; instead of \n .

@undergroundmonorail, you're right, thank you!

PHP, 267
This is about as short as I can get it.
<?php $g=file("p",2)?:[];$b=["ASS","666","KKK","SHT"];for($i=0;$i<200;){$m="A";$n=rand(702,18277);for($j=0;$j<$n;$j++){$m++;}$m.=-rand(100,999);if(!(strpos($m,"69")|in_array($m,$b)|in_array($m,$g))){$g[]=$m;echo"$m\n";$i++;}}file_put_contents("p",implode("\n",$g));?>

Plates are stored in file "p".
<?php
$g=file("p",2)?:[]; // Read existing plates
$b=["ASS","666","KKK","SHT"]; // Don't generate these
for($i=0;$i<200;){ // 200 plates
    $m="A"; // Base letter
    $n=rand(702,18277); // 3 random letters
    for($j=0;$j<$n;$j++){$m++;} // Increment until letters are reached (SLOW, but short)
    $m.=-rand(100,999); // Add a dash and three numbers
    if(!(strpos($m,"69")|in_array($m,$b)|in_array($m,$g))){ // Check that it's valid and unused
        $g[]=$m;echo"$m\n";$i++; // Echo it, add it to used array and increment counter
    }
}
file_put_contents("p",implode("\n",$g)); // Save the plates
?>

R, 229 characters
I'm sure this could be improved:
l=function(x)paste0(sample(x,3,r=T),collapse="")
a=function()c(l(LETTERS),l(0:9))
A=list()
for(i in 1:200)while(any(sapply(c("ASS","666","69","KKK","SHT"),grepl,A[[i]]<-a()))|A[i]%in%A[-i])A[[i]]=a()
lapply(A,paste,collapse="-")

Run in the console, prints a list of license plates.

ECMAScript 6 - 155 168 158
Warning: 200 alert dialogs (change alert to console.log to test)
for(i=0,s={},r=Math.random,l=x=>String.fromCharCode(65+r()*26);i<200;)/ASS|666|69|KKK|SHT/.test(p=(r()+'-'+l()+l()+l()).slice(-7))?0:s[p]=s[p]||(alert(p),i++)

Edit: Oops. Original version printed duplicates...
Edit 2: Closer to the original score now - switched from a set to an associative array with some fugly duplicate checks allowing it to print as it goes
Tested in Firefox console.

Congratulations improving my solution

I'm getting a "Syntax error" on: l=x=>String.fromCharCode(65+r()*26);. I guess I don't know what's happening with l=x=>...

@KevinFegan - I'm guessing you're not using Firefox... f=a=>b is an ES6 feature that's basically shorthand for function f(a) { b } and it's only(?) supported by Firefox at the moment.

Yes, I'm using IE 9, and it definately doesn't work here. I'll try it on Firefox. Thanks.

Javascript - 283 327 Characters
Edit:
After implementing the suggestions from Alconja, here's my new version:
m=Math.random;function y(v){return "ASS|KKK|SHT|666".indexOf(v)<0&&v.indexOf("69")<0?0:!0}function c(){return String.fromCharCode(m()*26+65)}for(i=0;i<200;i++){do {do {n=(m()+"").slice(2,5)}while(y(n));do {l=c()+c()+c()}while(y(l));r=l+"-"+n}while(o.indexOf(r)>=0);o+=r+"\n"}alert(o)
/* 1 line - 283 Characters */

1) Remove Variable:s and use literal:"\n" [-4][323]
2) Remove "var o="",i,r,n,l," [-17][306]
3) Remove Variable:t and use literal:"ASS|KKK|SHT|666" [-4][302]
4) Set m=Math.random and use "m" instead [-7][296]
5) Use (m()+"") rather than m().toString() [-6][290]
6) Remove unneeded ";" [-7][283]

Old-version: Javascript - 327 Characters
I'm sure there's some room for improving... I'm pretty inexperienced at Code-golfing:
var o="",s="\n",i,r,n,l,t="ASS|KKK|SHT|666";function y(v){return t.indexOf(v)<0&&v.indexOf("69")<0?0:!0;}function c(){return String.fromCharCode(Math.random()*26+65);}for(i=0;i<200;i++){do {do {n=Math.random().toString().slice(2,5);}while(y(n));do {l=c()+c()+c();}while(y(l));r=l+"-"+n;}while(o.indexOf(r)>=0);o+=r+s;}alert(o);
/* 1 line - 327 Characters */

Here is a formatted, "Ungolfed" version with "un-minified" variable/function names:
var outp="",lsep="\n",ndx,res,nbr,ltr,tbl="ASS|KKK|SHT|666";
function fnvfy(vinp){
  return tbl.indexOf(vinp)<0&&vinp.indexOf("69")<0?0:!0;
}
function fnchr(){
  return String.fromCharCode(Math.random()*26+65);
}
for(ndx=0;ndx<200;ndx++){
  do {
    do {
      nbr=Math.random().toString().slice(2,5);
    }
    while(fnvfy(nbr));
    do {
      ltr=fnchr()+fnchr()+fnchr();
    }
    while(fnvfy(ltr));
    res=ltr+"-"+nbr;
  }
  while(outp.indexOf(res)>=0);
  outp+=res+lsep;
}
alert(outp);

Here is a "debug" version that can be pasted into URL of browser favorite/bookmark. Output is placed in a "TEXTAREA" on a new "window" instead of "alert()":
javascript:(function(){var outp="",lsep="\n",ndx,res,nbr,ltr,tbl="ASS|KKK|SHT|666";function fnvfy(vinp){return tbl.indexOf(vinp)<0&&vinp.indexOf("69")<0?0:!0;}function fnchr(){return String.fromCharCode(Math.random()*26+65);}for(ndx=0;ndx<200;ndx++){do {do {nbr=Math.random().toString().slice(2,5);}while(fnvfy(nbr));do {ltr=fnchr()+fnchr()+fnchr();}while(fnvfy(ltr));res=ltr+"-"+nbr;}while(outp.indexOf(res)>=0);outp+=res+lsep;}var x=window.open();x.document.write('\n\n\n<form name=sa><textarea name=t rows=25 cols=80 wrap>'+outp+'</textarea>
\n\n');x.document.close();})()
/* */

Here is the "debug" version, formatted:
javascript:
(function(){
  var outp="",lsep="\n",ndx,res,nbr,ltr,tbl="ASS|KKK|SHT|666";
  function fnvfy(vinp){
    return tbl.indexOf(vinp)<0&&vinp.indexOf("69")<0?0:!0;
  }
  function fnchr(){
    return String.fromCharCode(Math.random()*26+65);
  }
  for(ndx=0;ndx<200;ndx++){
    do {
      do {
        nbr=Math.random().toString().slice(2,5);
      }
      while(fnvfy(nbr));
      do {
        ltr=fnchr()+fnchr()+fnchr();
      }
      while(fnvfy(ltr));
      res=ltr+"-"+nbr;
    }
    while(outp.indexOf(res)>=0);
    outp+=res+lsep;
  }
  var x=window.open();
  x.document.write('\n\n\n<form name=sa><textarea name=t rows=25 cols=80 wrap>'+outp+'</textarea>
\n\n');
  x.document.close();
}
)()

Without touching your actual algorithm, here's a few generic javascript golfing tips: Javascript is inherently forgiving with bad syntax, so you don't need to use var (just assigning will do, 323), you don't need ;s unless there's another statement following (eg. the last character in the line, or before a }, 316), watch for anything that takes more space to declare/use than just inline (eg. your s variable, 312), ditto for the reverse if something is used more than once (eg. Math.random(...) to r=Math.random ... r(...), 307, (x+"") is shorter than x.toString(), 300

@Alconja - Thanks for the help. I was able to reduce the size by 44 characters.

JavaScript (ES6) 184
As usual, test in FireFox console and change alert to console.log or be prepared to press escape 200 times.
R=x=>Math.random()*++x|0
for(l='ABCDEFGHIKJLMNOPQRSTUVWXYZ',i=0,u={};i<200;)
!(/69|666|ASS|SHT|KKK/.test(k=l[R(25)]+l[R(25)]+l[R(25)]+'-'+R(9)+R(9)+R(9))&u[k])&&alert(k,u[k]=++i);

I don't know about the console, but web pages are only allowed 5 free alerts before Firefox starts offering to disable them: http://mxr.mozilla.org/mozilla-central/ident?i=MAX_SUCCESSIVE_DIALOG_COUNT

@Neil of course, but offering to disable is not disabling. Shouldn't you enjoy 200 (or more http://codegolf.stackexchange.com/a/32278/21348) popups?

PHP,167
while(count($a)<200){$c="";for(;++$y&3;)$c.=chr(rand(65,90));$d=rand(100,999);$c=rand()&1?"$d-$c":"$c-$d";preg_match("/ASS|666|69|KKK|SHT/",$c)||$a[$c]=1;}print_r($a);

that's 100 chars less than current PHP's best :)
while(count($a)<200)
{
    $c="";
    for(;++$y&3;) $c.=chr(rand(65,90));
    $d=rand(100,999);
    $c=rand()&1?"$d-$c":"$c-$d";
    preg_match("/ASS|666|69|KKK|SHT/",$c)||$a[$c]=1;
}
print_r($a);

hope you like it. In case it is allowed:
while(count($a)<200){$c="";for(;++$y&3;)$c.=chr(rand(65,90));$c.=-rand(100,999);preg_match("/ASS|666|69|KKK|SHT/",$c)||$a[$c]=1;}print_r($a);

is only 141 chars but doesn't shuffle chars and numbers.
Any suggestions wellcome :)