Reficio™ - Reestablish your software!

Hardcore Java: Quine and Backward quine

Browsing through old university folders I found interesting pieces of code that I wrote some time ago for a contest at IBM. Have you ever heard of a quine? If not, here’s the definition by Wikipedia:

In computing, a quine is a computer program which produces a copy of its own source code as its only output. (…). For amusement, programmers sometimes attempt to develop the shortest possible quine in any given programming language.

Now, when everything is clear – let’s amuse ourselves and write a shortest possibile quine in Java :)
After some experimenting, I ended up with a Java code which consisted of 135 characters (the code is wrapped for better readability):

That’s all you think? – no class, no main method? Yes, but let’s make some test in order to prove the correctness of the presented approach (note: you won’t run it in eclipse – you have to use command line) :

OK, but grouches may say that it is an old trick – and that’s actually true. You can google much stuff concerning that problem. So, let’s raise the bar and write a shortest backward quine – a program which will output its content backwardly. I haven’t found a word about it on the Internet. My version contains 191 characters:

Is your version shorter :) ? Groovy version is gonna be much briefer – I will code it and post soon…

Comments

  1. arrange z says:

    I enjoy what you guys tend to be up too. This sort of clever work
    and coverage! Keep up the good works guys I’ve incorporated you guys to blogroll.

Trackbacks

  1. [...] couple of days ago. I had a little play around with them today, unfortunately some of the more exotic hacks have been broken now that the JVM requires a main method declaration. My best effort scraped in at [...]

Speak Your Mind

*