473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Quite Smart RIddle

I'm new here and I have a quite smart riddle for you people:
Try to write a program which prints itself.
I have a pretty interesting article about this programming problem with
the answer, but first of all try to solve it by yourself.

Have a good day.

Jun 9 '06 #1
6 1912
I know the article 'll be Ken Thompson's classical code.
I tried to do it.
But never came anywhere near to his idea.
Still i don't know how he is printing it using the string.
If anyone know can you please explain it to me?

Deepak.
sn*****@gmail.com wrote:
I'm new here and I have a quite smart riddle for you people:
Try to write a program which prints itself.
I have a pretty interesting article about this programming problem with
the answer, but first of all try to solve it by yourself.

Have a good day.


Jun 9 '06 #2
sn*****@gmail.com <sn*****@gmail.com> wrote:
I'm new here and I have a quite smart riddle for you people:
Try to write a program which prints itself.
I have a pretty interesting article about this programming problem with
the answer, but first of all try to solve it by yourself.


A Quine?
What'd you say if I showed you a quine in C that was also a palindrome?
(That's if I can still find it, although you can probably google for it).
Look on wikipedia for Quine. There you can find information about them
if you are interested.

If you are talking about a quine then you have to know that the program
prints its source code and not itself.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Jun 9 '06 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

sn*****@gmail.com wrote:
[a post that is, sans C code, generally considered of topic in clc]
I'm new here and I have a quite smart riddle for you people:
Try to write a program which prints itself.
I have a pretty interesting article about this programming problem with
the answer, but first of all try to solve it by yourself.
Most of us have written C quines at least once.
I suggest that you google for 'quine'. There are quite a few C solutions
available.
Have a good day.


You too.

- --

Lew Pitcher, IT Specialist, Corporate Technology Solutions,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEiZaLagVFX4UWr64RAgFeAJ48wUfdiEhyw63aHl/1CXh1XuU2ZgCg8d3+
nFjXk3M9/ny90RSI4ThT65k=
=KZZr
-----END PGP SIGNATURE-----
Jun 9 '06 #4
Quines are quite interesting. There is an article at Wikipedia which
shows a C version.
____
Compilr - http://www.caller.me.uk/Compilr - the online C, C#, VB.NET,
Fortran compiler

Jun 9 '06 #5

bc*****@gmail.com wrote:
Quines are quite interesting. There is an article at Wikipedia which
shows a C version.
____
Compilr - http://www.caller.me.uk/Compilr - the online C, C#, VB.NET,
Fortran compiler


Thank you all-I didn't know that the name of its problem is Quine

Jun 9 '06 #6

sn*****@gmail.com wrote:
I'm new here and I have a quite smart riddle for you people:
Try to write a program which prints itself.
I have a pretty interesting article about this programming problem with
the answer, but first of all try to solve it by yourself.


Ok:

/*This is my ugly C quine.*/
#include <stdio.h>
char *quine="void quotate(char
*s){while(*s){if(*s=='\\\\'||*s=='\\\"')putchar('\ \\\');putchar(*s);s++;}}int
main(){printf(\"/*This is my ugly C quine.*/\\n#include
<stdio.h>\\nchar
*quine=\\\"\");quotate(quine);printf(\"\\\";\\n%s\ ",quine);}";
void quotate(char
*s){while(*s){if(*s=='\\'||*s=='\"')putchar('\\'); putchar(*s);s++;}}int
main(){printf("/*This is my ugly C quine.*/\n#include <stdio.h>\nchar
*quine=\"");quotate(quine);printf("\";\n%s",quine) ;}

Not very compact or clever, but it works (before Google Groups messes
with the line breaks, anyway).

Jun 9 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Juha Haataja | last post by:
I have been learning Python since April, and would like a few comments from the experts on list processing. I managed to implement a Python code for solving the so-called Einstein's Riddle, see...
63
by: pythonchallenge | last post by:
For the riddles' lovers among you, you are most invited to take part in the Python Challenge, the first python programming riddle on the net. You are invited to take part in it at:...
0
by: pythonchallenge | last post by:
For the riddles' lovers among you, you are most invited to take part in the Python Challenge, the first python programming riddle on the net. You are invited to take part in it at:...
1
by: Sara Khalatbari | last post by:
Hey guys! Thanks for helping me find time&date. Have you seen this? This is the first programming riddle on the net with 20 levels! http://www.pythonchallenge.com/ ...
41
by: puzzlecracker | last post by:
Given an array of size n and populated with consecutive integers from 1 to n i.e. in random order. Two integers are removed, meaning zero is placed in their places. Give O (n) efficient algorithm...
8
by: Axter | last post by:
I normally use a program call Doxygen to document my source code.(http://www.stack.nl/~dimitri/doxygen) This method works great for small and medium size projects, and you can get good...
33
by: Ney André de Mello Zunino | last post by:
Hello. I have written a simple reference-counting smart pointer class template called RefCountPtr<T>. It works in conjunction with another class, ReferenceCountable, which is responsible for the...
1
by: ImortalSorrow | last post by:
Please I need urgent help with this program! Everything is working well except a part where i want to repeat the riddle if the answer isnt correct. here's the code..hope someone can help me! ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.