Tough Puzzle: The Parrot Sequence - crack it!
Puzzle Taken from #-Link-Snipped-# -
The parrot sequence
Gaston owns a clever parrot called Paco which can describe out loud numbers read from a piece of paper displayed in front of him. One day
Gaston tried this funny experiment: he wrote the digit 1 on a sheet and showed it to Paco, who answered âone 1â. Gaston wrote down the parrotâs answer âone 1â or â11â on a new sheet and showed it to Paco, who readily answered âtwo 1âsâ. Again, Gaston wrote down his reply âtwo 1âsâ or â21â on another sheet and showed it to Paco, who replied âone 2, one 1â or â1211â... Gaston continued this experiment until he obtained a long sequence of numbers 1, 11, 21, 1211, 111221, 312211, etc... in which each next term is obtained by describing the previous term.
Can you say how many sheets of paper Gaston will need until:
a) the string of digits 333 appears, or
b) the digit 4 occurs in the sequence?
Can you also confirm that the last digit of any term of the parrot sequence is always 1?
![[IMG]](proxy.php?image=http%3A%2F%2Fwww.archimedes-lab.org%2Fim_maths%2Fmon_p_116_PUZZ.gif&hash=d5f133a486d00c5fa537372c5344f9d4)
The parrot sequence
Gaston owns a clever parrot called Paco which can describe out loud numbers read from a piece of paper displayed in front of him. One day
Gaston tried this funny experiment: he wrote the digit 1 on a sheet and showed it to Paco, who answered âone 1â. Gaston wrote down the parrotâs answer âone 1â or â11â on a new sheet and showed it to Paco, who readily answered âtwo 1âsâ. Again, Gaston wrote down his reply âtwo 1âsâ or â21â on another sheet and showed it to Paco, who replied âone 2, one 1â or â1211â... Gaston continued this experiment until he obtained a long sequence of numbers 1, 11, 21, 1211, 111221, 312211, etc... in which each next term is obtained by describing the previous term.
Can you say how many sheets of paper Gaston will need until:
a) the string of digits 333 appears, or
b) the digit 4 occurs in the sequence?
Can you also confirm that the last digit of any term of the parrot sequence is always 1?
![[IMG]](proxy.php?image=http%3A%2F%2Fwww.archimedes-lab.org%2Fim_maths%2Fmon_p_116_PUZZ.gif&hash=d5f133a486d00c5fa537372c5344f9d4)
Replies
-
Kaustubh KatdareNo Takers? Too tough for the CEans? 😁
-
mahul1) 333 will never appear. this is because for 333 to appear, we would need 333 in the previous sequence too( we got to have 3 three's for three consecutive three's to appear. let us consider the previous sequence was x333y. this can be like x 3's and 3 3's or 3 3's and 3 y's. either way we need to have 3 3's in the previous sequence). reasoning in this way this can only happen if we start off with 3 three's which we did not(we started with 1). hence 333 can never appear.
2) 4 can never appear either. for that we would need xxxx in the previous sequence( where x is any digit). let us consider that the sequence was yxxxxz. this can be like y x's, x x's, x z's or x x's , x x's. in the first case it would rather be spelt as (x+y) x's and in the latter as 2x x's. thus a four can also never appear. in fact the max no that can appear is 3.
3) yes the last digit will always be 1. in fact the last digit will be the always be the no we started with. this can be proved again by contradiction. let the last two digits be xy(where y != 1 and x is any no). now this is actually x y's. since x !=0 , then the previous sequence would also end with a y. and the same would repeat till the first sequence. thus the last digit is always the digit we started with, in this case 1.
proved.
correct _k?? -
vissinHmm... I'd like to have a parrot that can count and that has such good hold on English grammar.
-
mdronsubbsthe digits 333 never appears because the whole digits end with 1's and 2's....for 333 to appear the prev digits shud also be the same ..so its not at all possible
-
skamthe81Good one.....................big_K.............
give us dome more -
xheavenlyxMahul's explanation is good 😀
Can anyone write a psudo code for this? like give 15 sequences. or 30 sequences etc? 😁
I tore my hair out while trying to write it in Python...good one! give moreee! -
mahulI think I got you, but still I would like to confirm. Are you asking us to write a code that generates the parrot sequence?? Maybe take the initial input would be provided by the user?
-
xheavenlyxYes that. And hell, it can be difficult for new programmers like me. I havent used C for so long. Presently i am on Python.
Actually, just today I wrote the draft code for the parrot seq.
Next step is to take any input and keep writing tillsequences are complete.
Yea, so try to write the code. This can be a competition too. We can have coding competitions 😀 In the end we can upload these files on celab.tk for ppl to download and test. 😀 Code will be reveled LATER. -
bayazidahmedbreak the number, count (by parsing) and display
-
prakash.athaniHere is the program for Parrot sequence. I tried it in Java.
-
prakash.athani
//An attempt in Java to produce parrot sequence //Works for fair inputs. //For larger serieses the int in the program should be replaced by long import java.io.*; class ParrotSequence{ //This is main. Here we give initial number to parrot Paco.Also our choice if we want to continue. public static void main(String args[]) throws IOException { int n,choice,result; DataInputStream din=new DataInputStream(System.in); System.out.println("Give initial number to parrot Paco :"); n=Integer.parseInt(din.readLine()); do { result=count(n); System.out.println("Paco's reply :"+result); System.out.println("Do you want to give Paco's count back to Paco?(1/0) :"); choice=Integer.parseInt(din.readLine()); if(choice==1) { n=result; } }while(choice==1); }//End of main() // I am sure Paco won't count in the following way. But following count produces Paco's count static int count(int num) { int rev=reverse(num); int result=0,temporaryResult=0,newDigit=0,currentDigit=0,count=0; currentDigit=rev%10; while(rev>0) { newDigit=rev%10; if(currentDigit==newDigit) { switch(newDigit) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 0:count=count+1;break; } currentDigit=newDigit; rev=rev/10; } else { temporaryResult=count*10+currentDigit; result=result*100+temporaryResult; currentDigit=newDigit; count=0; } } temporaryResult=count*10+newDigit; result=result*100+temporaryResult; return(result); } // This function returns the reverse of any number passed to it static int reverse(int number) { int reverse=0,remainder; while(number>0) { remainder=number%10; reverse=reverse*10+remainder; number=number/10; } return reverse; } }//End of class ParrotSequence
-
xheavenlyxHere is the one I tried. Its written on Python.
It was basically made as a demo for future Crazyengineers software distributions. Contains Installation with CE logo, desktop Icon, Start menu item etc.
Download it from: #-Link-Snipped-#
Name of Program is: #-Link-Snipped-# -
prakash.athani
//Parrot sequence in C #include
#include int main() { long count(long); long n,result; int choice; clrscr(); printf("Give the initial number to parrot PACO(Default:1) :"); scanf("%d",&n); do { result=count(n); printf("PACO's count :%ld\n",result); printf("Do you want to continue ?(1/0) :"); scanf("%d",&choice); if(choice==1) n=result; }while(choice==1); getch(); return 0; } long count(long n) { long reverse(long); long result=0,rev=reverse(n); int currentDigit=0,newDigit=0,temporaryResult=0,count=0; currentDigit=rev%10; while(rev>0) { newDigit=rev%10; if(newDigit==currentDigit) { switch(newDigit) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 0:count=count+1;break; } currentDigit=newDigit; rev=rev/10; } else{ temporaryResult=count*10+currentDigit; result=result*100+temporaryResult; currentDigit=newDigit; count=0; } } temporaryResult=count*10+newDigit; result=result*100+temporaryResult; return(result); } long reverse(long n) { int remainder; long reverse=0; while(n>0) { remainder=n%10; reverse=reverse*10+remainder; n=n/10; } return(reverse); } -
xheavenlyxwow, C and Java. have to read it though 😀
-
agrizCheck out another one
The link to the puzzle is : #-Link-Snipped-#
Many people tried and nobody found a solution to this.
It is a puzzle between human and computer.
Post here if you beat the computer. -
silverscorpionYou cant beat the computer. There are 21 balls and you can pick upto 4 balls at a time. So, the strategy is to pick in multiples of 5, so that after 20, only one ball remains.
So, you start. If you pick 1, the computer picks 4. If you pick 2, computer picks 3 and so on. So, as long as you pick first, you cant win no matter how you play. If the computer picks first, then by the same strategy, you can win. -
agrizsilverscorpionYou cant beat the computer. There are 21 balls and you can pick upto 4 balls at a time. So, the strategy is to pick in multiples of 5, so that after 20, only one ball remains.
So, you start. If you pick 1, the computer picks 4. If you pick 2, computer picks 3 and so on. So, as long as you pick first, you cant win no matter how you play. If the computer picks first, then by the same strategy, you can win.
Awesome. Really Awesome. -
suhanimody4 number will appear on 10th term. i.e. the term on position 10 which will be 132113124113112211
-
sidd26a) The sequence 333 never appears.
b)The digit 4 occurs at the 11 page . -
sndgpr26
4 will not appear at any costThe_Big_KPuzzle Taken from #-Link-Snipped-# -
The parrot sequence
Gaston owns a clever parrot called Paco which can describe out loud numbers read from a piece of paper displayed in front of him. One day
Gaston tried this funny experiment: he wrote the digit 1 on a sheet and showed it to Paco, who answered âone 1â. Gaston wrote down the parrotâs answer âone 1â or â11â on a new sheet and showed it to Paco, who readily answered âtwo 1âsâ. Again, Gaston wrote down his reply âtwo 1âsâ or â21â on another sheet and showed it to Paco, who replied âone 2, one 1â or â1211â... Gaston continued this experiment until he obtained a long sequence of numbers 1, 11, 21, 1211, 111221, 312211, etc... in which each next term is obtained by describing the previous term.
Can you say how many sheets of paper Gaston will need until:
a) the string of digits 333 appears, or
b) the digit 4 occurs in the sequence?
Can you also confirm that the last digit of any term of the parrot sequence is always 1?
-
sweet_honey
4 doesnt occur at any page..sidd26b)The digit 4 occurs at the 11 page .
it goes only with 1,2 and 3 in all the pages.
yes, every time the last digit is 1.
You are reading an archived discussion.
Related Posts
CEans,
I'm convinced that we need to reorganize our sections on CE. While we finalize on the new structure, how many of you think that we need a separate section...
HI,,,,,,,,kindly tell me hw to go to the projects ideas section ?
i m from EE branch of 2nd yr.
Hi friends i am a new user
plz help me to complete my project using c++
plz tell me basic hardware requirement for c++
CEans,
Each year, VNIT Nagpur organizes central India's biggest event - Aarohi (Aaroh'08: Central India's Biggest Cultural Youth Festival, Celebrating 20 years of exuberance) . I'm glad to inform you...
how would be pairing wrist watch and a mobile phone using bluetooth and make the both to vibrate and siren when they are kept apart by a fixed distance be...