This game is so small it fits inside a tweet

The challenge was to build a game whose source would fit inside a tweet:

> I challenge you to make a game whose source fits in a single tweet

And here’s one of the responses:

> main(b){char s[9];b=0;for(;b<12&&*(int*)(s+5)!=*(int*)s;){b%4||gets(s+5);b<4&&(s[b]='a'+rand()%4);putchar("-x"[s[b++%4+5]==s[b%4]]);}} Build it, run it, you'll end up with this game here. Crazy.



5 thoughts on “This game is so small it fits inside a tweet”

  1. This reminds me of an Apple II magazine, back in the 1980s, that would publish one- or two-line BASIC programs sent in (via the postal service!) from readers. These were usually games or graphical toys, that would achieve impressive results with very little code.

    Other readers, like myself, would then type in, run, play with, and learn from these programs. It’s nice to see Twitter bring back some of this fun, even if copy-and-paste has replaced transcribing it from a printed magazine.

  2. Used to play in Perl and C. Good times on 16 bit. Thanks for the reminder, I’d forgotten all about that.

  3. This is (should be) the standard type of question one would ask when interviewing programmers. A similar challenge would be finding the bug in similarly condensed code.

  4. You actually end up with something different. Try it: Copy the code from the tweet (follow the link to the tweet on Twitter, the one displayed here uses some characters that will mess up the program) and open up a text editor that can save plain text (Sublime, BBEdit, Visual Studio Code). Paste the text into the editor field and then save it as “game.c” on your desktop. Now open up Terminal and copy paste the following:

    gcc ~/Desktop/game.c && ~/Desktop/a.out

Leave a Reply

Your email address will not be published. Required fields are marked *