Winter Coding Challenge… #1?
Inherently pointless coding challenges just to stretch the brain :)
- In your language of choice, create a quine. A quine is a program that outputs its own source code. No restrictions, except that the file may not be blank (I’ve seen that before ;D) This is mostly a thinking puzzle, so you’ll work it out with time.
- If your previous quine used the filesystem API (commands to read/write files), create a quine that does not. If your previous quine did not use the filesystem API, create a quine that depends on it.
- Now we start doing special types of quines. This one has two steps. Create a program that outputs the reverse of its source code. That output (the reverse of the original program), when run, should output the original program. Your language of choice may not seem to allow this sort of quine, but it probably does if you get /*really*/ clever with it ;)
- If your previous quine used the filesystem API, create a quine that does not. If your previous quine did not use the filesystem API, create a quine that depends on it.
Yay! Have fun, and let me see what you come up with :D Tip for the non-filesystem solutions: don’t be afraid to repeat yourself. On the filesystem solutions, it’s cooler if it works regardless of what the file is named, but not every language necessarily supports that.
If you’d like some spoilers, here are my answers in Ruby. If you’re genuinely interested in trying this, though, I’d recommend resisting looking at these for a good 24 hours, and then to only look one at a time, just in case you’re inspired upon seeing the general principle :)
You may note that my answers to 3 and 4 cheat ever so slightly, since the problem isn’t very well-defined ;)
Have fun!