Closed Thread Icon

Topic awaiting preservation: Quines... Pages that link to <a href="https://ozoneasylum.com/backlink?for=9014" title="Pages that link to Topic awaiting preservation: Quines..." rel="nofollow" >Topic awaiting preservation: Quines...\

 
Author Thread
wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 02-07-2004 17:51

I was feeling bored in the utmost this afternoon, so I wrote a quine. I checked it and I am pretty certain it is perfect. I might hav slipped with the quotes or something, but I think it works. Its not overly small, but its a lot more readable than the only other JS one I've seen. Here we go:

<script>var ctext='99,116,101,120,116,61,99,116,101,120,116,46,115,112,108,105,116,40,34,44,34,41,59,118,97,114,32,109,105,110,101,61,34,34,59,109,105,110,101,43,61,34,60,115,99,114,105,34,59, 109,105,110,101,43,61,34,112,116,62,32,118,97,114,32,99,116,101,120,116,61,39,34,59,102,111,114,32,40,118,97,114,32,105,61,48,59,32,105,60,99,116,101,120,116,46,108,101,110,103,116 ,104,45,49,59,32,105,43,43,41,32,109,105,110,101,43,61,99,116,101,120,116,91,105,93,43,34,44,34,59,109,105,110,101,43,61,99,116,101,120,116,91,99,116,101,120,116,46,108,101,110,103 ,116,104,45,49,93,43,34,39,59,34,59,102,111,114,32,40,118,97,114,32,105,61,48,59,32,105,60,99,116,101,120,116,46,108,101,110,103,116,104,59,32,105,43,43,41,32,109,105,110,101,43,61 ,40,83,116,114,105,110,103,46,102,114,111,109,67,104,97,114,67,111,100,101,40,99,116,101,120,116,91,105,93,41,41,59,97,108,101,114,116,40,109,105,110,101,41,60,47,115,99,114,105,11 2,116,62';ctext=ctext.split(",");var mine="";mine+="<scri";mine+="pt> var ctext='";for (var i=0; i<ctext.length-1; i++) mine+=ctext[i]+",";mine+=ctext[ctext.length-1]+"';";for (var i=0; i<ctext.length; i++) mine+=(String.fromCharCode(ctext[i]));alert(mine)</script>

(BTW, that's all meant to be on one line)
Shall we have a competition:
1) who can write the shortest quine
2) who can write the most obfuscated quine.

This probably won't appeal to many people, but any entries would be very interesting!

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer!

ninmonkey
Nervous Wreck (II) Inmate

From:
Insane since: Nov 2003

posted posted 02-07-2004 20:11

I found a little error:

I used mozilla firebirds javascript console to evaluate it (so it didn't have <script> and </script> ) and when I came out it had

code:
<script>... code ... </scri

It added the tags, and the second one only says "scri".

Here's one in perl:

code:
#!/usr/bin/perl -w
use strict;
open(F,$0);
print <F>;
close(F);

Tell me if you know how I could shorten it (besides removing the first 2 lines).

[This message has been edited by ninmonkey (edited 02-07-2004).]

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 02-07-2004 20:53

What is a quine?

What is your script supposed to do? Maybe if I knew what a 'quine' is I wouldn't have to ask this question.




-- not necessarily stoned... just beautiful.

ninmonkey
Nervous Wreck (II) Inmate

From:
Insane since: Nov 2003

posted posted 02-07-2004 21:24
quote:
dictionary.com - quine
A program that generates a copy of its
own source text as its complete output. Devising the shortest
possible quine in some given programming language is a common
hackish amusement.



wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 02-07-2004 22:00

Sorry, I didn't explain. Its just like ninmonkey quoted. If you run that source code, it should come up with an exact copy of itself.
I am having the same problem too ninmonkey when I try to do it. I would guess that as the problem is with the last three letter, and if you look the last three numbers spill onto an extra line, it will have something to do with funny line breaks. Would it be better to host it somewhere?
I assure you it does work...

Wrayal

EDIT: Hosted at http://www.wrayal.4t.com/quine.html
Unfortunately this site screws with all your sources, but if you look, its in there. Not much more I can do - Sorry!

Go to kimber-ja.demon.co.uk and click on the link to the raytracer!

[This message has been edited by wrayal (edited 02-07-2004).]

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 02-08-2004 07:05

wrayal: I tried 3 different things

<SCRIPT>alert(document.scripts[0].outerHTML)</SCRIPT>

<script>location="view-source:"+location</script>

function a(){alert(a+"a()")}a()

[edit] here comes a variant of the last one, but this time, you can simply paste it in the address bar of your browser

javascript:function a(){prompt("QUINE?","javascript:"+a+"void(a())")}void(a())

[/edit]



[This message has been edited by poi (edited 02-08-2004).]

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 02-08-2004 09:13

QUINE is fun

<script>a='prompt("quine?","<script>a=%27"+a+"%27;"+unescape(a))%3C/script>';prompt("quine?","<script>a='"+a+"';"+unescape(a))</script>

or

a='document.write("a=%27"+a+"%27;"+unescape(a))';document.write("a='"+a+"';"+unescape(a))



[This message has been edited by poi (edited 02-08-2004).]

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 02-08-2004 14:07

Somehow I get the feeling that there is cheating inherent in
"function a(){alert(a+"a()")}a()"
and other similar quines using particular special functions in javascript. Doesn't stop them being very clever though
Anybody else got any alternatives. I always thought writing a quine would be really hard. But if you think about it, the most common way (the one I used) is actually really easy. It's just the quotes and the script tags that are a pain!

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer!

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 02-08-2004 20:14

wrayal: I admit that my 2 first quines are more in DHTML than in JavaScript only. But I'm not a QUINE expert so I don't know if using the introspection capabilities of the language "validates" the 3rd & 4th ones.

However, the latest two uses *your* method, but with the built in encoding/decoding functions, which makes it way easier and shorter. The ' are encoded %27 and the < %3C, and since the unescape( ) function allows it, I've decoded the other characters to gain some bytes ( 36 in the 5th, and 20 in the 6th ).



[This message has been edited by poi (edited 02-09-2004).]

« BackwardsOnwards »

Show Forum Drop Down Menu