This question already has an answer here:
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 will be read from stdin. The input will consist of a line containing two numbers,
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 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.
5 6 ...... ..#... ..#... ..#... ......
5 6 ...... ...... .###.. ...... ......
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.
The winner will be decided on August 1 at 11:59pm EST.
As of August 1st, the winner is @mniip with a Lua solution consisting of only 9 unique characters.