Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
RokuMarkn
Visitor

Quines

"EnTerr" wrote:

That's like saying "10 LIST" is a legal quine (self-printing program).


Yeah, someone once responded to my challenge to write a Perl Quine by writing a program that opened and read the source file and printed it. Hey, I haven't seen anyone write a Brightscript Quine yet. Any takers?

--Mark
0 Kudos
8 REPLIES 8
TheEndless
Channel Surfer

Re: How long is your code?

"RokuMarkn" wrote:
"EnTerr" wrote:

That's like saying "10 LIST" is a legal quine (self-printing program).

Yeah, someone once responded to my challenge to write a Perl Quine by writing a program that opened and read the source file and printed it. Hey, I haven't seen anyone write a Brightscript Quine yet. Any takers?

--Mark

Quine is new to me, but does this count?
For Each file In ListDir("pkg:/source"):print ReadAsciiFile("pkg:/source/" + file):Next
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
EnTerr
Roku Guru

Re: How long is your code?

"RokuMarkn" wrote:
Hey, I haven't seen anyone write a Brightscript Quine yet. Any takers?

Done! Can i have a cookie?

[spoiler=83 chars:3udiu46y]No cheating! Giving out the answer spoils all the fun, pain and suffering. Here is an alphabetical anagram of my solution (it runs on fw3 too; PM me for the unscrambled version if not wanting to try the quine challenge on your own):
""(((((((((())))))))))++11333333444455668888:=??SSSSScccccccccchhhhhhhhhhrrrrrrrrrr

Can there be an even shorter one, i wonder?![/spoiler:3udiu46y]
0 Kudos
EnTerr
Roku Guru

Re: How long is your code?

"TheEndless" wrote:
Quine is new to me, but does this count?
For Each file In ListDir("pkg:/source"):print ReadAsciiFile("pkg:/source/" + file):Next

No, that's cheating. Such rejection may sound arbitrary ("why can't i read external data?"). I don't know if this will help as justification but since above is a one-line program, i should be able to run it in console and it should print exactly what i just typed, which i should be able to copy&paste in the console again to get the same output (etc etc ad nauseam).

The challenge is to do something that feels impossible when you try at first. Have to write a non-empty program/snippet - using only the means of the language - that prints itself. It should survive compilation (if there ever was one for B/S) where source file disappears.
0 Kudos
RokuMarkn
Visitor

Re: How long is your code?

My first attempt came out to 84 chars, although based on your anagram I think we're using rather different techniques.

--Mark
0 Kudos
RokuMarkn
Visitor

Re: How long is your code?

Well, here's mine. Don't look if you're still playing.
[spoiler=84 chars:266a1re8]
q=chr(34):p="q=chr(34):p=:?mid(p,1,12);q;p;q;mid(p,13)":?mid(p,1,12);q;p;q;mid(p,13)
[/spoiler:266a1re8]
0 Kudos
EnTerr
Roku Guru

Re: How long is your code?

"RokuMarkn" wrote:
My first attempt came out to 84 chars, although based on your anagram I think we're using rather different techniques.

I had success so far only using the form
S="¿":¿
where ¿ is code that prints S="¿":¿ by using S; it starts with "?" and has no " quotes. The anagram amusingly is very obvious which function i liberally (ab)used... courtesy of the order of the alphabet.

I keep thinking eval() may come useful but nothing so far.

Shouldn't we split this thread from around here viewtopic.php?f=34&t=87203#p493015 into a new "quine" one?
0 Kudos
RokuMarkn
Visitor

Re: How long is your code?

"EnTerr" wrote:

Shouldn't we split this thread from around here viewtopic.php?f=34&t=87203#p493015 into a new "quine" one?


Yes.

--Mark
0 Kudos
EnTerr
Roku Guru

Re: How long is your code?

"RokuMarkn" wrote:
Well, here's mine. Don't look if you're still playing.
[spoiler=84 chars:z505pj9s]...[/spoiler:z505pj9s]

Interestingly, there is some space for "optimization" (shortenization? briefization?) there:
  • replacing the first MID with LEFT shortens it from 84 to 82 chars

  • dropping `q` and using chr(34) in all 4 places keeps length at 82; does not seem to help but wait, wait for it...

  • ... omitting ";" wherever possible* (2x3 places) now brings length down to 76, woo-hoo!


Btw. saying that you used different technique made me thinking yesterday what else can i do... and i remembered a string function documented last year (it's available in fw3 though). With its help my personal record now is down to 62! **
[spoiler=62 chars ramagan:z505pj9s]
""(((()))),,,,0013344::==??SSSSSS^^^bbcceehhiirrssssttttttuuuu
[/spoiler:z505pj9s]

(*) i know, border-line criminal but the B/S parser is the de-facto standard on the language (like perl) and it does not require ";" nor extra whitespace in print
(**) i wonder if someone else (e.g. @belltown) can bring that count even lower
0 Kudos