0
\$\begingroup\$

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.

\$\endgroup\$
12
  • \$\begingroup\$ 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?) \$\endgroup\$
    – flawr
    Commented Jul 16, 2014 at 9:16
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 16, 2014 at 10:55
  • 1
    \$\begingroup\$ Although this question can be seen as an extreme specialisation of codegolf.stackexchange.com/q/11690/194 so it might be better to just close it as a dupe than try to fix it. \$\endgroup\$ Commented Jul 16, 2014 at 10:58
  • 1
    \$\begingroup\$ @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! \$\endgroup\$
    – C0deH4cker
    Commented Jul 16, 2014 at 15:27
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – Cruncher
    Commented Jul 16, 2014 at 15:46

2 Answers 2

7
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – user16991
    Commented Sep 3, 2014 at 20:30
0
\$\begingroup\$

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.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.