162 points · by eigenbom · 11y ago · 53 comments
Here's mine.
$ python -c 'import random;L=sorted(str(random.randint(1,9)) for i in range(4));a=raw_input(L);print(eval(a)==24,sorted(filter(str.isdigit,a))==L)'
['2', '6', '7', '8']8*(7+2-6)
(True, True)
Try to make it print (True, True) without abusing eval too much (intended to be +-*/() only with digits as tokens).A nicer interface, but too long:
import random;L=sorted(str(random.randint(1,9)) for i in range(4));a=raw_input(" ".join(L)+"\n> ");print(eval(a)==24,sorted(filter(str.isdigit,a))==L) python3 -c "import random;p=lambda:random.choice('7♪♫♣♠♦♥◄☼☽');[print('|'.join([p(),p(),p()]),end='\r') for i in range(8**5)]" while(true){f()}- show it on http://www.reddit.com/r/tinycode/
- if you aim for low character count instead of low byte count, you can pass your code through my unicide packer here: http://xem.github.io/obfuscatweet/
- Golf your code even more (using the tips of the other comments), and use all the remaining chars to add features to your game and fill the 140 chars of a tweet :)
Cheers
Here's a 2048/Threes-clone in <700 characters (or 5 tweets): https://twitter.com/eigenbom/status/615424395192877056
Personally I find it handy for messing around in jsfiddle and the like:
<pre id="out"></pre>
[...]
out.innerHTML += some_result;e.g:
<input name="test">
<div id="test">
document.getElementById('test'); // <input> in IE6
I believe this also wound up in some Webkit and Opera releases, perhaps for emulation. Someone more knowledgeable about it all should feel free to correct me if I'm wrong though.(Edited for code formatting, I don't comment too much these days)
http://xem.github.io/articles/#implicitgetelementbyid_en
Cheers :)
curl http://www.hackerz-r-us.ru/really_awesome_game.sh | sudo bash #YouveBeenP0wnd
Depending on how much you cheat, you can get about two bytes of data per Twitter character. That'd allow 256 bytes of game to live comfortably within a single twit, which is a quarter of an unexpanded ZX81 RAM. By comparison, that would take almost ten seconds to load off tape. You should be able to get a respectable ZX81 game in that.
With something like the JtyOne Javascript ZX81 emulator (http://www.zx81stuff.org.uk/zx81/jtyone.html) and some Twitter interaction, the whole process should be pretty seamless --- click on a twit to play; modify it using the ZX81's built-in cough IDE; click on a button to reshare...
http://countercomplex.blogspot.co.at/2011/10/algorithmic-sym...
Most of these would also fit in a single tweet ..
(I'm really more of a hardware guy myself, love to strip the SID's from any C64's I find in the trash .. and of course synths (analog and digital) are really a different subject altogether .. but I'll check out chipsounds on a DAW next time I get a chance. Ta!)
The code you posted is essentially equivalent to "s = s + 1; a.style.margin = s + e % 300".
s += 1
a.style.margin = (s + e) % 300http://lalwanivikas.github.io/window-game/
(Concept inspired from Jennifer Dewalt's project, but code is entirely mine :))
<!DOCTYPE html><title>X</title><script>s=0,t=Date.now()</script><p onclick="(e=Date.now()-t)<15e3?style.margin=++s+e%300+'px':alert(s)">X
(Note that the original version is at least 36 bytes larger than it need be: https://github.com/omnus/tiny-twitch/pull/1)