Quine

Allosentient
Posts: 273
Joined: Thu Apr 10, 2008 9:47 pm

Post by Allosentient »

Yes, the 10,000 cycle limit is tough, but makes the challenge very interesting. I suspect there are many ways to solve it.
User avatar
efe
Posts: 45
Joined: Sun Oct 26, 2008 10:28 am
Location: germany

Post by efe »

I'm making progress in this challenge, but my new solution still takes more than 10000 cycles.
My approach is to write a python program that prints out a hvm-quine.

The quine works like this C-Example: http://www.madore.org/~david/programs/selfrep/selfprt.c

For this kind of quine it is easier to construct a python program for building the hvm code instead of writing the hvm directly.

My quine is 1530 instructions long and executes in 16694 cycles. But I see some potential to make it shorter...
User avatar
efe
Posts: 45
Joined: Sun Oct 26, 2008 10:28 am
Location: germany

Post by efe »

new record :) : 13832 cycles, 1412 instructions

now it gets tricky ...
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

My solution was 7889 cycles, 295 instructions. The more instructions you have, the more cycles it takes to print them out again later on! That said, your cycles/instructions ratio is a lot better than mine.
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

Hi efe,

My first answer was 305 instructions long (oh, longer than gfoot's!), without any optimization. So, maybe you're thinking something a bit too complex, I guess.

Today I tried optimizing my code in size, and made it into 109 instructions long. It takes 1879 cycles.

EDIT: I optimized my code again and it is 97 instructions long.
Last edited by tails on Sat Nov 29, 2008 10:53 pm, edited 1 time in total.
User avatar
efe
Posts: 45
Joined: Sun Oct 26, 2008 10:28 am
Location: germany

Post by efe »

Finally, I made it :D !

My solution takes 9751 cycles and is 636 instructions long.
There are some optimizations possible, but it is still a miracle to me how to do it with just 109 instructions.
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

Congratulations!
tog
Posts: 70
Joined: Fri Nov 14, 2008 11:23 am
Location: Germany

Post by tog »

I also got it. Thanks to gfoot for pointing me to the standard techniques, which I didn't expect to exist at all :oops:. I didn't have any problems with the cycle limit. My first try (also without any optimizations) was already small enough (260 instructions, 5614 cycles),
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

Hmm, I hope that wasn't too much of a giveaway then!
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post by therethinker »

I'm pretty sure mine was less than 200 instructions, but I can't quite remember. I'm pretty sure it was about 1.5 lines in the JS implementation. I may be making this up, though :P It didn't loop too much either, so I'd be surprised if it was over 500 instructions...

I didn't love mine, I didn't think it was too optimized. However, looking at your solution sizes, I think I actually did pretty well :P
Allosentient
Posts: 273
Joined: Thu Apr 10, 2008 9:47 pm

Post by Allosentient »

wow, i'd like to see both that one and the long one!
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

hmmn, maybe i'll make a harder quine challenge...
tog
Posts: 70
Joined: Fri Nov 14, 2008 11:23 am
Location: Germany

Post by tog »

gfoot wrote:Hmm, I hope that wasn't too much of a giveaway then!
No, I don't think so. This hint only led me to learn about general techniques for quines. And learning is what the challenges are all about, right?
nighthalk
Posts: 41
Joined: Fri Jul 31, 2009 8:22 pm

Post by nighthalk »

holy @#$%# this is a tough one, managed to get mine down to 865 instructions, (curse that cycle limit) and i seriously have no idea how those insane people can get it to 97, too many symbols need to be stored which takes too many instructions to save which propagates through the functions needed to print all this =p
User avatar
dangermouse
Posts: 89
Joined: Sun Jun 05, 2011 8:14 pm
Location: deep space computing AG
Contact:

Post by dangermouse »

arhgs, mine is 309 chars and needs 11722 cycles to quine the quine! i think i need to do some deep analysis on the char representation to see how i can optimize it... :shock:

btw efe's essay on quines is impressive! there are even multiquines and a fix point theorem! crazy!
Post Reply