Search Results

Search found 16 results on 1 pages for 'quine'.

Page 1/1 | 1 

  • Shortest Ruby Quine

    - by AaronThomson
    Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case for using a quine as an interview question. I'm not sure I agree but thats not what this question is about. He goes on to construct a quine in Ruby and refactor it to make it shorter. He then challenges the reader to try to make it even shorter. I played around with it for a while and came up with the following: s="s=;puts s[0,2]+34.chr+s+34.chr+s[2,36]";puts s[0,2]+34.chr+s+34.chr+s[2,36] This is the first time I have ever attempted a quine and I can't figure out how to make it any shorter. What is the shortest Ruby quine you can come up with? Please post an explanation if your implementation requires it.

    Read the article

  • Is this a valid quine?

    - by fsm
    def start(fileName): fileReader = open(fileName) for row in fileReader: print row, if __name__ == "__main__": import sys if len(sys.argv) <= 1: print "usage quine /path/to/file" sys.exit(-1) fileName = sys.argv[0] start(fileName) python quine.py foo

    Read the article

  • Code golf: Reverse quine

    - by Eduardo León
    Write a program that outputs the reverse of its source code as a string. If the source is abcd efg (i.e., the C string "abcd\nefg") Then the output should be gfe dcba (i.e., the C string "gfe\ndcba") Bonus points for using esoteric languages such as brainf*ck. *EDIT:** Removed the unnecessary \0 characters.+

    Read the article

  • How could a quine in my programming language look?

    - by ads
    I have created a turing-complete programming language (already proven) so it must be possible to write a quine for it, right? But all quines I know store their source code in a string and then replace a special character in it using something like chr and ord. My language only has the following Basic arithmetics Int and string types Variables == operator Conditional gotos I have no idea how I could write a quine as I have no real string manipulation available, I can only output constant strings. Yet, it is 100% turing-complete.

    Read the article

  • Is it possible to create a quine in every turing-complete language?

    - by sub
    I just wanted to know if it is 100% possible, if my language is turing-complete, to write a program in it that prints itself out (of course not using a file reading function) So if the language just has the really necessary things in order to make it turing complete (I would prove that by translating Brainf*ck code to it), like output, variables, conditions and gotos (hell yes, gotos), can I try writing a quine in it? I'm also asking this because I'm not sure that a quine directly fits into Turing's law that the turing machine is capable of any computational task. I just want to know so I don't try for years without knowing that it may be impossible.

    Read the article

  • C program that prints out another C program in Japanese

    - by Bryan Bueter
    There was a C program written for a contest that was formatted in ASCII art as a Japanese character. When compiled and ran it printed out another program formatted in a different Japanese character, then another, then finally it printed out the first again. I was looking for the code to that and could not find it on the internet. I dont remember what contest nor what the name of the program was. Thanks.

    Read the article

  • is it possible to write a program which prints its own source code utilizing a "sequence-generating-

    - by guest
    is it possible to write a program which prints its own source code utilizing a "sequence-generating-function"? what i call a sequence-generating-function is simply a function which returns a value out of a specific interval (i.e. printable ascii-charecters (32-126)). the point now is, that this generated sequence should be the programs own source-code. as you see, implementing a function which returns an arbitrary sequence is really trivial, but since the returned sequence must contain the implementation of the function itself it is a highly non-trivial task. this is how such a program (and its corresponding output) could look like #include <stdio.h> int fun(int x) { ins1; ins2; ins3; . . . return y; } int main(void) { int i; for ( i=0; i<size of the program; i++ ) { printf("%c", fun(i)); } return 0; } i personally think it is not possible, but since i don't know very much about the underlying matter i posted my thoughts here. i'm really looking forward to hear some opinions!

    Read the article

  • Is it possible to write a Java printf statement that prints the statement itself?

    - by polygenelubricants
    Is it possible to have a Java printf statement, whose output is the statement itself? Some snippet to illustrate: // attempt #1 public class Main { public static void main(String[] args) { System.out.printf("something"); } } This prints something. So the output of attempt #1 is not quite exactly the printf statement in attempt #1. We can try something like this: // attempt #2 public class Main { public static void main(String[] args) { System.out.printf("System.out.printf(\"something\");"); } } And now the output is System.out.printf("something"); So now the output of attempt #2 matches the statement in output #1, but we're back to the problem we had before, since we need the output of attempt #2 to match the statement in attempt #2. So is it possible to write a one-line printf statement that prints itself?

    Read the article

  • What should I call the process of converting an object to a string?

    - by shabbychef
    We are having a game of 'semantic football' in the office over this matter: I am writing a method for an object which will represent the object as a string. That string should be such that when typed (more likely, cut and pasted) into the interpreter window (I will keep the language name out of this for now), will produce an object which is, for our purposes, identical to the one upon which the method was called. There is a spirited discussion over the 'best' name for this method. The terms pickle, serialize, deflate, etc have been proposed. However, it seems that those terms assume some process for the de-pickling (unserialization, etc) that is not necessarily the language interpreter itself. That is, they do not specifically refer to the case where strings of valid code are produced. This is closer to a quine, but we are re-producing the object not the code, so this is not quite right. any suggestions?

    Read the article

  • Can you help me think of problems for my programming language?

    - by I can't tell you my name.
    I've created an experimental toy programming language with a (now) working interpreter. It is turing-complete and has a pretty low-level instruction set. Even if everything takes four to six times more code and time than in PHP, Python or Ruby I still love programming all kinds of things in it. So I got the "basic" things that are written in many languages working: Hello World Input - Output Countdowns (not as easy as you think as there are no loops) Factorials Array emulation 99 Bottles of Beer (simple, wrong inflection) 99 Bottles of Beer (canonical) Conjatz conjecture Quine (that was a fun one!) Brainf*ck interpreter (To proof turing-completeness, made me happy) So I implemented all of the above examples because: They all used many different aspects of the language They are pretty interesting They don't take hours to write Now my problem is: I've run out of ideas! I don't find any more examples of what problems I could solve using my language. Do you have any programming problems which fit into some of the criteria above for me to work out?

    Read the article

  • Things you should implement in your own programming language

    - by I can't tell you my name.
    I've created an experimental toy programming language with a (now) working interpreter. It is turing-complete and has a pretty low-level instruction set. Even if everything takes four to six times more code and time than in PHP, Python or Ruby I still love programming all kinds of things in it. So I got the "basic" things that are written in many languages working: Hello World Input - Output Countdowns (not as easy as you think as there are no loops) Factorials Array emulation 99 Bottles of Beer (simple, wrong inflection) 99 Bottles of Beer (canonical) Conjatz conjecture Quine (that was a fun one!) Brainf*ck interpreter (To proof turing-completeness, made me happy) So I implemented all of the above examples because: They all used many different aspects of the language They are pretty interesting They don't take hours to write Now my problem is: I've run out of ideas! I don't find any more examples of what problems I could solve using my language. Do you have any programming problems which fit into some of the criteria above for me to work out?

    Read the article

1