03-21-2006, 08:19 AM
Quote:Now, I quote once more, your second to last line, above, as:*****Code:Ok, here's the rules:
1) It must be considered an algorithm, formula or method.
Add 15 to X ---- X=X+15 This is not an algorithm, agreed?
If it were, then every line of code in a program would be.
2) You must describe the algorithm first, i.e., what is its purpose.
3) Then show the one line of code.
4) Multiple statments on one line; like: x=x+1 : x=x and 15
are not considered as one line of code.
A good example is one we've already seen with the XOR.
The purpose is to turn a switch on if it's off, and turn it off if it's on.
The one line of code is: sw=sw xor sw
or equally cool: sw=1-sw
Quote:The purpose is to turn a switch on if it's off, and turn it off if it's on.Which is exactly what the one-liner I submitted does. Or, have I mis-read your original rules?
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.