Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-19-2010, 07:59 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Programming Exercise #7: Quine

Hello all, and welcome to the return of Programming Exercises! If people still like this, maybe I'll do more.

Your mission, should you choose to accept it, is to write a quine. What is a quine you might ask? Well, a quine is a bit of self-replicating code. In particular, it is a code that produces its own source code as its only output.

Write as short a quine as you can!

This is unlike any previous exercise, but you may also want to take a look at exercises #1, #2, #3, #4, #5, and #6 for previous discussions or for fun.

e: Now open for suggestions for the difficulty of PE#8.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/

Last edited by Tolnaftate2004; 05-20-2010 at 06:27 AM..
Reply With Quote
  #2  
Old 05-19-2010, 08:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
PHP Code:
function onCreated() {
  
temp.lines.loadLines("weapons/weaponQuine.txt");
  
lines.saveLines("data/output.txt"false);

Do I win?
__________________
Reply With Quote
  #3  
Old 05-19-2010, 08:22 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by cbk1994 View Post
Do I win?
I had a feeling this would be the first post. Very clever.

Let's try to avoid joining classes, using public functions, and using file I/O. The script should be self-contained and independent of filename and other files.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #4  
Old 05-19-2010, 12:22 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
urgh, i can only come up with infinite-code

Edit:
could just post it here for others to see~
PHP Code:
function onCreated() {
  echo(
"
    function onCreated() {
    echo(/"
function onCreated() {
      
/*infinity echos here*/ 
      
}/");
    }
  "
);

__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you

Last edited by Deas_Voice; 05-19-2010 at 12:42 PM.. Reason: meh...
Reply With Quote
  #5  
Old 05-19-2010, 04:14 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
PHP Code:
function onCreated() { temp.'"'temp."function onCreated() { temp.q = '%s'; temp.s = %s%s%s; temp.s = format(temp.s, temp.q, temp.q, temp.s, temp.q); echo(temp.s); }"temp.format(temp.stemp.qtemp.qtemp.stemp.q); echo(temp.s); } 
__________________
Quote:
Reply With Quote
  #6  
Old 05-19-2010, 06:17 PM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Don't get this at all.. you should make programming exercises for people who are at a more average level.
Reply With Quote
  #7  
Old 05-19-2010, 07:00 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by DeCeaseD View Post
Don't get this at all.. you should make programming exercises for people who are at a more average level.
There's not much to it, write code that outputs itself.
__________________
Quote:
Reply With Quote
  #8  
Old 05-20-2010, 05:48 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by fowlplay4 View Post
PHP Code:
function onCreated() { temp.'"'temp."function onCreated() { temp.q = '%s'; temp.s = %s%s%s; temp.s = format(temp.s, temp.q, temp.q, temp.s, temp.q); echo(temp.s); }"temp.format(temp.stemp.qtemp.qtemp.stemp.q); echo(temp.s); } 
This is very nice.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #9  
Old 05-21-2010, 05:07 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by fowlplay4 View Post
PHP Code:
function onCreated() { temp.'"'temp."function onCreated() { temp.q = '%s'; temp.s = %s%s%s; temp.s = format(temp.s, temp.q, temp.q, temp.s, temp.q); echo(temp.s); }"temp.format(temp.stemp.qtemp.qtemp.stemp.q); echo(temp.s); } 
Shortened

PHP Code:
function onCreated(){temp.s="function onCreated(){temp.s=\"%s\";temp.s=format(temp.s,temp.s);echo(temp.s);}";temp.s=format(temp.s,temp.s);echo(temp.s);} 
(It may not be -exactly- the same, but I think the lack of escaped quotes in the output is acceptable)

I propose the next exercise be a function generate prime numbers (with an arbitrary upper limit).
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 05-21-2010, 05:55 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by coreys View Post
Shortened

PHP Code:
function onCreated(){temp.s="function onCreated(){temp.s=\"%s\";temp.s=format(temp.s,temp.s);echo(temp.s);}";temp.s=format(temp.s,temp.s);echo(temp.s);} 
(It may not be -exactly- the same, but I think the lack of escaped quotes in the output is acceptable)

I propose the next exercise be a function generate prime numbers (with an arbitrary upper limit).
That was what I originally had, but it wasn't a true replication so I had go to the way I did with the quote variable. Ideally you should be able to paste your output, apply and have it still working.
__________________
Quote:
Reply With Quote
  #11  
Old 05-21-2010, 06:06 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by coreys View Post
(... but I think the lack of escaped quotes in the output is acceptable)
It is not. (You can however take advantage of the fact that s maps to temp.s after definition.)

Quote:
Originally Posted by coreys View Post
I propose the next exercise be a function generate prime numbers (with an arbitrary upper limit).
Noted, but it's a pretty trivial calculation.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #12  
Old 05-22-2010, 06:14 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Tolnaftate2004 View Post
Noted, but it's a pretty trivial calculation.
*shrug* it's a worthwhile exercise I think. Although the real trick would be getting it to generate prime numbers 'concurrently' (not really concurrent, but as close as you can get to it, using scheduleEvent() for example) :P
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #13  
Old 05-19-2010, 07:04 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
which helps out the graal community in so many ways!! o_o
__________________
Reply With Quote
  #14  
Old 05-19-2010, 08:24 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
It helps polish the experienced scripters skills.
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #15  
Old 05-19-2010, 08:37 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
So by not posting anything, everyone completed the exercise in a way? ez
__________________
Reply With Quote
Reply

Tags
programming-exercise, quine

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.