Thread: The Magic Gopher - New beginners programming challenge

  1. #1
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    The Magic Gopher - New beginners programming challenge

    This is a programming challenge based around a maths 'mindreading' puzzle game.

    you can play it here to see what the puzzle involves.

    Your challenge is to replicate the game in a console project.

    You must accept the player input for each calculation step and obviously ouput messages telling the player what calc they need to do next.
    A chart of characters must be displayed directing the player to remember their symbol
    A results screen must then be shown displaying the players chosen character - which of course will amaze them...
    The control between each step should be of the type 'press any key to continue' - or assign a particular key if you wish.

    Finally the program should allow the user to play again.

    Appending to the console will not be accepted as a clean enough output so you must use suitable clearscreen calls where required.

    I am up for seeing comical user instructions and output messages by the way.

    windows console only sorry - +no text libraries etc
    c or c++

    Winner is first through with a robust working implementation
    Contest period until 1st October - if no winners received before then i will assess any other entries for the best one.
    Last edited by rogster001; 09-09-2012 at 04:54 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    I couldn't resist to this

    I've gone and written ( and tested of course ) a complete console version of this rascal!
    Well ok, it has no fancy ASCII graphics or something, it just outputs some text but it ok.
    I'm not posting it though, don't want to give away the solution.

    Lol, that little guy had me there for about 5 minutes before I featured what was going on!
    Devoted my life to programming...

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    This game does not work for me. I picked a number and ended up with 18 the first time and he was right, but then I picked a number and ended up with 8, and he was wrong. Maybe when the contest is over someone can explain what's going on.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    This game does not work for me.
    O_o

    If the agent didn't "guess" correctly, you didn't follow instructions.

    you can play it here to see what the puzzle involves.
    Wow. I really like this version. It does something for this that I haven't seen before that serves as a perfect way to distract players from the trick.

    Soma
    Last edited by phantomotap; 09-10-2012 at 12:21 AM.

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Haha, its absolutely fantastic isnt it - I was like Greaper when i first saw it - it cracked me up - i had to play about ten times just for the fun - was freaked out, I wrote it in turboC with the old fashioned text graphics colours, still love it now. Took me a while to work out what was going on - I did not have the benefit of the internet to just instantly know the trick, - i had played game in public library and then thought about it later. - You can now find stuff about the solution etc on a google search - i leave it up to the contestant if they want the fun of cracking it themselves or just implement from an explanation of the 'trick' without any figuring out for that bit - up to you. And whiteflags man - it always works dude ! Plus it maps to bigger numbers too...
    Last edited by rogster001; 09-10-2012 at 02:31 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I was able to "crack the code" the second time through by looking at all numbers that contained the "winning" symbol. This was a very fun program to write. How do we submit?

  7. #7
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Problem:
    This requires non-standard functions to
    a) press any key
    b) 'suitable' clear screen

    Also, no version of this program ever required input, other than to get the next instruction displayed. "accept the player input for each calculation step" in fact lets the program cheat.


    Here is the first version I ran into.
    Last edited by WaltP; 09-10-2012 at 07:25 PM.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  8. #8
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    I have my version....
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  9. #9
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    You can submit your entires to me by PM - and apologies for the 'must accpet input bit' you are right - my version just prompts the user to do each thing, i should have remebered that, just a message prompt is all that is required - by the way who cares about the non standard functions for this? Its a bit of fun mate
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  10. #10
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Apparently I can't send attachments via PM, so I pasted the source code into the body of my message - I hope that's alright.

    I already wrote the program to accept user input for each step, so I just kept it like that. Besides, it will ensure the user does the math correctly.

    I also got a little silly at the beginning of the program, since you said you were fine with that.

    I also failed to realize yesterday that this was for "new beginners" - I'm not great at programming, but am by no means a new beginner. If that disqualifies me, so be it. This is just the first time I've been around when a contest was running and I was eager to participate.

  11. #11
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    no worries - will check your entry now - i always put beginners in contest post titles, kinda did it by default this time- i am not advanced enough myself to really challenge seniors so mainly its to kinda say, let newbies have a go, which i see you note, but hey this one was for fun, no way trying to seriously exclude anybody, am interested to see this program haha, cheers.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  12. #12
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Submitted a non-qualifying C# entry just because. It was fun! Thanks for putting the contest up.
    If you understand what you're doing, you're not learning anything.

  13. #13
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Yes thanks for that one too - Used to have a c# compiler - only reason i didnt include those entries cos not got it any more - its a supported language on the cBoard so perhaps i should sort that out for any future contest i think of posting. - nice twist on the idea using the crazy words instead of symbols!
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  14. #14
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Matticus - winner - Great program, good show, well done, first through the post and agreed to hold off to allow for any newbie programmer entires.

    Met all the requirements including my erroneous 'request input' also included the fantastic 'Mind Forge' feature - which of course guaranteed success every time - I hear Mr Spock may well be learning this as an enhancement to his native Vulcan Mind Meld as we speak.

    Mention to Waltp for a very neat bit of code with nice output, very concise. which in fact dealt with the problem without resorting to non-standard calls -negating CLS. Waltp also submmitted user input version.

    Thanks to itsme86 for a nice C# entry - Included an excellent take on the game where random crazy words were generated instead of the symbols. in future if i post a contest i will be sure to allow C# as it is a forum on these pages.

    Thanks to all, hope you had fun coding this.

    @The entrants -Be nice to see your code versions posted.

    @Matticus - you are now the toast of the town mate, - people will no longer cross the street to avoid you! expect an audience with the pope sometime soon ;-> !
    Last edited by rogster001; 09-22-2012 at 06:09 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  15. #15
    Registered User
    Join Date
    Aug 2011
    Posts
    91
    first of all, thank you so much for putting up the contest. i was about to go nuts when i played the game the british corporation logos just made me feel that this was something done by extremely brilliant people and there was some sort of AI built into it.. anyway thanks again.

    Its only been recently since I started to code my own programs of Intermediate complexity..and coding your challenge has been really a pleasurable experience..

    it might not be so efficient or very well structured but its something i came up with.

    enough blabber heres the code. please do give your review and please your tips how to improve..and I have tested it many times, hope its correct..
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    #include<conio.c>
     #include<stdio.h>
    int main() 
    
    {	
    while(1)
    {
    	int j=1,temp,i,print_complete;
    	char choice;
    	char multiple_9= (rand()%20)+14;
    	//cout<<multiple_9;
    	
    	
    	cout<<endl<<endl<<endl<<endl<<endl<<endl;
    	cout<<"********************************************************************************";
    	cout<<endl<<endl<<endl<<"================================================================================";
    	cout<<endl<<endl<<endl<<"\t"<<"@@@@@@  YOU HAVE ENTERED THE GATES OF THE MATH GENIE  !!!!  @@@@@";
    	cout<<endl<<endl<<endl<<"\t\t"<<"!!!!!! GET READY TO BE MESMERIZED !!!!!!";
    	cout<<endl<<endl<<endl<<"================================================================================";
    	cout<<endl<<endl<<"\t\t   PRESS ENTER IF YOU DARE TO CONTINUE";
    	cout<<endl<<"********************************************************************************";
    	cin.get();
    	clrscr();
    	cout<<"\n\n\n\n\n\n\n\n\n";
    	cout<<endl<<"********************************************************************************";
    	cout<<endl<<endl<<endl<<endl<<endl<<endl<<"\t        THINK OF A NUMBER WITH TWO DIGITS (FOR EXAMPLE 43)";
    	cout<<endl<<endl<<endl<<"\t\t\t    PRESS ENTER TO CONTINUE";
    	cout<<endl<<"********************************************************************************";
    	cin.get();
    	clrscr();
    	cout<<"\n\n\n\n\n\n\n\n\n";
    	cout<<endl<<"********************************************************************************";
    	cout<<"\n\n\nNOW ADD THE TWO DIGITS OF THE NUMBER(EXAMPLE: 4+3=7)";
    	cout<<endl<<"********************************************************************************";
    	cin.get();
    	clrscr();
    	cout<<"\n\n\n\n\n\n\n\n\n";
    	cout<<endl<<"********************************************************************************";
    	cout<<"\n\n\nNOW SUBTRACT THE NEW NUMBER FROM YOUR ORIGINAL NUMBER(EXAMPLE: 43-7=36)";
    	cout<<endl<<"********************************************************************************";
    	cin.get();
    	clrscr();
    	cout<<"\n\n\n\n\n\n\n\n\n";
    	cout<<endl<<"********************************************************************************";
    	cout<<"\n\nFINALLY LOOK AT THE SYMBOL NEXT TO YOUR NUMBER AND REMEMBER IT";
    	cout<<endl<<"********************************************************************************";
    	cin.get();
    	clrscr();
    	cout<<endl<<endl<<endl;
    	
    	for(i=95;i>=0;i--)
    	{print_complete=0;
    		temp=i;
    		j=1;
    		while(j<10)
    		{
    			if(temp>=0)
    			{
    				
    				cout<<temp<<" ";
    				if((temp%9)==0)
    				cout<<multiple_9<<" ";
    				else
    				cout<<(char)((rand()%10)+14)<<" ";
    			}
    			if(temp==8)
    			{
    				print_complete=1;
    				break;
    			}
    			temp=temp-11;
    			j++;
    		}
    		if(print_complete==1)
    		{
    			
    			break;
    		}
    	cout<<endl<<endl;
    	}
    	cout<<"\n\n\nPRESS ENTER TO CONTINUE";
    	cin.get();
    clrscr();
    
    cout<<"\n\n\n\n\n\n\n";
    cout<<endl<<"********************************************************************************";
    cout<<endl<<endl<<"\t\t\tTHE SYMBOL YOU REMEMBERD IS :"<<multiple_9;
    	cout<<endl<<"********************************************************************************";
    	cin.get();
    	
    clrscr();
    cout<<"\n\n\n";
    cout<<endl<<"********************************************************************************";
    cout<<endl<<endl<<endl<<"\t\t\tDARE TO TRY AGAIN???? IF NO,PRESS N"<<endl;
    cout<<endl<<"********************************************************************************";
    cin>>choice;
    
    if(choice=='n'||choice=='N')
    break;
    }
    }
    its 1.00 am here..So I go to bed satisfied of having tried for so long.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++/C Beginners Codebreak challenge
    By rogster001 in forum Contests Board
    Replies: 55
    Last Post: 03-11-2010, 06:59 AM
  2. Beginners C Programming Challenge
    By UCnLA in forum C Programming
    Replies: 23
    Last Post: 04-01-2008, 07:46 PM
  3. Beginners C Programming Challenge
    By UCnLA in forum C Programming
    Replies: 2
    Last Post: 03-18-2008, 12:15 PM
  4. What ever happened to gopher?
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 06-01-2004, 07:06 PM
  5. C programming challenge
    By lost in C in forum C Programming
    Replies: 6
    Last Post: 03-11-2002, 01:27 AM