Stefan
Member
Less than 2/3 of the 15-puzzle sim now. I guess 3x3 is easier to implement.
edit: can save 6 bytes by moving to one line
EDIT: hey, if anything goes, why not just replace "document.body.innerHTML=h.join("")" with "alert(h)"? and while we're at it, remove the spaces from h too... that would bring it down to 251 or so.
15 puzzle in 194 characters. http://jsfiddle.net/pq6VK/3/
Or 169 with alert(h) if you prefer
Good job, but... nah, not ok.
For the 15-puzzle I'd say there is a natural and straight-forward minimum-requirements standard and we should follow it:
- Proper 4x4 view (like Tom's original).
- Properly laid out up/down/left/right keys (doesn't have to be the arrow keys, could be i/n/a/f, for example).
- Proper scrambling function (single key press), because proper hand-scrambling is hard. I suggest random state or at least 9999 random moves (maybe more, we should actually analyze this (this could be an interesting side project)).
- Proper net view
What exactly does that mean?
Indeed, and that's why I think my 15 puzzle is acceptable FWIW it does actually have properly laid out up/down/left/right keys (use the arrow keys) although of course any other key can do turns too. The "proper 4x4 view" and "proper scrambling function" are the same kind of concessions we already made on the 3x3x3 sim without much complaint. I could add the 4x4 view back easily enough (i.e. without wasting a huge number of characters) but the proper scrambling function would be difficult due to the way I use q....I find it really hard to define a reasonable minimum standard.
Indeed, and that's why I think my 15 puzzle is acceptable
The "proper 4x4 view" and "proper scrambling function" are the same kind of concessions we already made on the 3x3x3 sim without much complaint.
unless we have a very specific idea of what makes an acceptable scrambler (e.g. must be random state with randomly placed hole) it's only natural to keep saving bytes by making the scrambler worse or even absent.
There's an old saying among perl programmers. "Every program has one unnecessary line of code, and a bug."
According to that, you could reduce this program to a single line of code, with a bug.
Let me make this a proper challenge by defining the requirements:
- Must look like Tom's original or "equivalent" (you can for example make it graphical, or use 10..15 instead of A..F)
- Must have reasonably laid out up/down/left/right keys working like Tom's original (or use the mouse or whatever in a convenient way).
- Must have one-key/click random state scrambling.
- Optional: Timer, starting with the first move after scrambling, updating at least every 0.1 seconds during the attempt, stopping with a certain key/click, showing at least "seconds.centiseconds" (the time formatted like that, not that string) and "DNF" if stopped when puzzle not solved.
- Optional: Show a sub-10 solve (by anyone)
1 line of code with a bug ok. heres my 3x3sim in c++
main(){}
bug: doesnt actually simulate a 3x3
There's an old saying among perl programmers. "Every program has one unnecessary line of code, and a bug."
According to that, you could reduce this program to a single line of code, with a bug.