An implementation of Conway's Game of Life in less than 140 bytes of JavaScript.
See the example: ubilabs.net/projects/game-of-live
life (
input, // input array
size // size (width and height) of stage
)
// returns the modificated input string
Created by Martin Kleppe (@aemkei) at Ubilabs.
See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.
To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.
140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.
Worked on the classic game of life and got a 92 byte result with the same functionality as previous iterations, as well as a 118 byte result with wrapping issues fixed, which can be seen here: http://output.jsbin.com/zebuxi
I decided to use arrow functions when I noticed they were implemented on chrome and firefox, which saved quite a few bytes in combination with Array.prototype.map. I also implemented a flattened walk loop instead of a precalculated walk as most other implementations I've seen, which saved bytes even without the arrow functions.
I encourage you to check out the javascript as I wrote it because I left a history of changes by copy pasting into a new line every iteration: http://jsbin.com/zebuxi/edit?js
Thanks to @aemkei I've really enjoyed reading the code you've written for 140bytes and on your website, a real inspiration.