Help me come up with an obfuscated way to multiply a number by 2, accurate to the second decimal.
Ideas:
- use the Russian multiplication technique
- trig / other mathematical identities
- monte carlo methods
- but of course bonus points for CS trickery
edit:
Just remembered that it’s probably more appropriate to think of this in terms of significant figures, not accurate decimal places. So go for 4 matching leading digits.
The following perl one-liner doubles the first command-line argument:
You may say that using perl is cheating because everything is obfuscated in perl. You would not be entirely wrong.
Here’s a slightly different approach in (unobfuscated) python: