Challenging Programming Question.

Reply

Join Date: Jan 2008
Posts: 483
Reputation: DangerDev has a spectacular aura about DangerDev has a spectacular aura about 
Solved Threads: 59
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Pro in Training

Challenging Programming Question.

 
0
  #1
Jan 21st, 2008
Hi all
Post some challenging programming question, which are really hard to solve...
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Challenging Programming Question.

 
0
  #2
Jan 21st, 2008
http://en.wikipedia.org/wiki/Integer_factorization
Fortune and glory will be yours if you can solve this one.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 483
Reputation: DangerDev has a spectacular aura about DangerDev has a spectacular aura about 
Solved Threads: 59
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Pro in Training

Re: Challenging Programming Question.

 
0
  #3
Jan 22nd, 2008
Originally Posted by Salem View Post
http://en.wikipedia.org/wiki/Integer_factorization
Fortune and glory will be yours if you can solve this one.

that's really nice, many ppl are working on that...
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 483
Reputation: DangerDev has a spectacular aura about DangerDev has a spectacular aura about 
Solved Threads: 59
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Pro in Training

Re: Challenging Programming Question.

 
0
  #4
Jan 22nd, 2008
Hi
Solve this:
write a program to generate its own source code.
(plz dnt come up with solution like, reading source file, etc.)
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: Challenging Programming Question.

 
0
  #5
Jan 23rd, 2008

^^ A Perl solution
Last edited by sarehu; Jan 23rd, 2008 at 1:02 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: Challenging Programming Question.

 
0
  #6
Jan 23rd, 2008
Also, generally, making quines is easy. You just have the following formula:

You'll make a program in three parts:
Part 1: If needed, make a function that prints a string once, and then prints it in the string literal notation you used to write the string, and then prints Part 3. Then in the 'main' function, pass the string you write in part 2 to this function.
Part 2: Write Part 1 in string form.
Part 3: This is the text that follows immediately after the string in Part 2.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: Challenging Programming Question.

 
0
  #7
Jan 23rd, 2008
Example:
#include <stdio.h>
#include <string.h>

void f(char* s) {
    char* p;
    p = s;
    printf("%s\"",p);
    while (*p) {
        if (strchr("\\\n\"", *p)) {
            printf("\\%c", *p == '\n' ? 'n' : *p);
        }
        else {
            putchar(*p);
        }
        ++p;
    }
    printf("\");\n}\n");
}

int main(void) {
    f("#include <stdio.h>\n#include <string.h>\n\nvoid f(char* s) {\n    char* p;\n    p = s;\n    printf(\"%s\\\"\",p);\n    while (*p) {\n        if (strchr(\"\\\\\\n\\\"\", *p)) {\n            printf(\"\\\\%c\", *p == '\\n' ? 'n' : *p);\n        }\n        else {\n            putchar(*p);\n        }\n        ++p;\n    }\n    printf(\"\\\");\\n}\\n\");\n}\n\nint main(void) {\n    f(");
}
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 483
Reputation: DangerDev has a spectacular aura about DangerDev has a spectacular aura about 
Solved Threads: 59
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Pro in Training

Re: Challenging Programming Question.

 
0
  #8
Jan 23rd, 2008
its nice sarehu...
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the IT Professionals' Lounge Forum


Views: 1734 | Replies: 7
Thread Tools Search this Thread



Tag cloud for IT Professionals' Lounge
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC