View Feed
group-icon
Brainy Puzzles
Puzzle Solvers: Interesting brainy puzzles shared by fellow puzzlers
385 Members
Join this group to post and comment.
Kaustubh Katdare
Kaustubh Katdare • Feb 22, 2008

Tough Puzzle: The Parrot Sequence - crack it!

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?

[​IMG]
Kaustubh Katdare
Kaustubh Katdare • Mar 5, 2008
No Takers? Too tough for the CEans? 😁
mahul
mahul • Mar 5, 2008
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??
vissin
vissin • Apr 15, 2008
Hmm... I'd like to have a parrot that can count and that has such good hold on English grammar.
mdronsubbs
mdronsubbs • May 16, 2008
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
skamthe81 • Jun 6, 2008
Good one.....................big_K.............

give us dome more
xheavenlyx
xheavenlyx • Jun 7, 2008
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!
mahul
mahul • Jun 7, 2008
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
xheavenlyx • Jun 8, 2008
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.
bayazidahmed
bayazidahmed • Jul 22, 2008
break the number, count (by parsing) and display
prakash.athani
prakash.athani • Sep 26, 2008
Here is the program for Parrot sequence. I tried it in Java.
prakash.athani
prakash.athani • Sep 26, 2008
 
//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
xheavenlyx • Sep 26, 2008
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: cecode - Google Code
Name of Program is: CE_ParrotProgie.exe
prakash.athani
prakash.athani • Sep 29, 2008
 
//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
xheavenlyx • Oct 25, 2008
wow, C and Java. have to read it though 😀
agriz
agriz • Jun 19, 2010
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
silverscorpion • Jun 20, 2010
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.
agriz
agriz • Jun 20, 2010
silverscorpion
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.

Awesome. Really Awesome.
suhanimody
suhanimody • Jun 29, 2012
4 number will appear on 10th term. i.e. the term on position 10 which will be 132113124113112211
sidd26
sidd26 • Aug 11, 2012
a) The sequence 333 never appears.
b)The digit 4 occurs at the 11 page .
sndgpr26
sndgpr26 • Aug 23, 2012
The_Big_K
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?

[​IMG]
4 will not appear at any cost
sweet_honey
sweet_honey • Aug 24, 2012
sidd26
b)The digit 4 occurs at the 11 page .
4 doesnt occur at any page..
it goes only with 1,2 and 3 in all the pages.

yes, every time the last digit is 1.

Share this content on your social channels -