C Quine - Gen_Witt

redgen_witt wrote
on March 17th, 2010 at 09:45 pm
Previous Entry Share Next Entry

C Quine

I was reading an article that claimed that a good interview question would be to have the candidate write a quine. A quine is a program that, when given no input, outputs its source. I've known about them for a while but had always assumed they were too tricky to be worth the trouble. It took me about 45 minutes. It's surprisingly straight forward. Curiously the fixed point theorem says that this must be possible for any programming language that is both Turing complete and has output.

I took this as an opertunity to get a github account. I guess that makes me one of the cool kids. The Source. It's got a makefile and a test and everything. I choose the MIT license, just in case anybody cares.

For the record, I think it's a lousy interview question. And yes, I know my solution isn't the most elegant, I just sort of brute forced it.
mood: amused amused

(Leave a comment)
From:lifftchi
Date:2010-03-18 05:03 am (UTC)
(Link)
"Isn't the most elegant" might be an understatement.

On the other hand, the canonical bash quine is something like "cat $0", so whatever.
(Reply) (Thread)

(Leave a comment)