$ 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)
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)]"
However, there is no guarantee that this will work since it assumes that `this` isn't used by that function.
E.g. if you want to do something like that with console.log or document.querySelector, you have to use bind:
var log = console.log.bind(console);
var qs = document.querySelector.bind(document);
The start tag is mandatory. The end tag may be omitted if the <p> element is immediately followed by an <address>, <article>, <aside>, <blockquote>, <div>, <dl>, <fieldset>, <footer>, <form>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <header>, <hr>, <menu>, <nav>, <ol>, <pre>, <section>, <table>, <ul> or another <p> element, or if there is no more content in the parent element and the parent element is not an <a> element.
Actually, what you call "very specific cases" are in fact, well, all reasonable cases. That list consists of all block level elements that can appear in `body`, so the statement could be reworded, that "<p> cannot contain any block-level element, so any inline element after <p> falls in, any block level element ends opened <p>".
Funny fact is that presence of optional end tags means nearly nothing for HTML parsers used in current browsers, they just ignore them. Some border cases regarding white space exists, or at least existed in the past, but in general, if you feed browser with document
- 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 :)
Here's a 2048/Threes-clone in <700 characters (or 5 tweets):
Personally I find it handy for messing around in jsfiddle and the like:
out.innerHTML += some_result;
document.getElementById('test'); // <input> in IE6
(Edited for code formatting, I don't comment too much these days)
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.
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) % 300
(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