# Tough Puzzle: The Parrot Sequence - crack it!

Question asked by Kaustubh Katdare in #Brainy Puzzles on Feb 22, 2008

Kaustubh Katdare · Feb 22, 2008

Rank A1 - PRO

**Puzzle Taken from Mind and Visual Puzzles! -**

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?

Posted in: #Brainy Puzzles

Kaustubh Katdare · Mar 5, 2008

Rank A1 - PRO

No Takers? Too tough for the CEans? 😁

mahul · Mar 5, 2008

Rank C1 - EXPERT

1) 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??

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??

vissin · Apr 15, 2008

Rank D2 - MASTER

*Hmm... I'd like to have a parrot that can count and that has such good hold on English grammar.*

mdronsubbs · May 16, 2008

Rank D1 - MASTER

the 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

skamthe81 · Jun 6, 2008

Rank E1 - BEGINNER

Good one.....................big_K.............

give us dome more

give us dome more

xheavenlyx · Jun 7, 2008

Rank B1 - LEADER

Mahul'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!

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!

mahul · Jun 7, 2008

Rank C1 - EXPERT

I 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?

xheavenlyx · Jun 8, 2008

Rank B1 - LEADER

Yes 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 till sequences 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.

Actually, just today I wrote the draft code for the parrot seq.

Next step is to take any input and keep writing till

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.

bayazidahmed · Jul 22, 2008

Rank C3 - EXPERT

break the number, count (by parsing) and display

prakash.athani · Sep 26, 2008

Rank D2 - MASTER

Here is the program for Parrot sequence. I tried it in Java.

prakash.athani · Sep 26, 2008

Rank D2 - MASTER

//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

xheavenlyx · Sep 26, 2008

Rank B1 - LEADER

Here 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:

Name of Program is:

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:

**cecode - Google Code**Name of Program is:

**CE_ParrotProgie.exe**prakash.athani · Sep 29, 2008

Rank D2 - MASTER

//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); }

xheavenlyx · Oct 25, 2008

Rank B1 - LEADER

wow, C and Java. have to read it though 😀

agriz · Jun 19, 2010

Rank E2 - BEGINNER

**Check out another one**

The link to the puzzle is : Funny Ball Game

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.

silverscorpion · Jun 20, 2010

Rank A3 - PRO

You 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.

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.

agriz · Jun 20, 2010

Rank E2 - BEGINNER

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.

Awesome. Really Awesome.

suhanimody · Jun 29, 2012

Rank E2 - BEGINNER

4 number will appear on 10th term. i.e. the term on position 10 which will be 132113124113112211

sidd26 · Aug 11, 2012

Rank E2 - BEGINNER

a) The sequence 333 never appears.

b)The digit 4 occurs at the 11 page .

b)The digit 4 occurs at the 11 page .

sndgpr26 · Aug 23, 2012

Rank D1 - MASTER

4 will not appear at any costThe_Big_KPuzzle Taken from Mind and Visual Puzzles! -

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 · Aug 24, 2012

Rank C2 - EXPERT

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.