Tough Puzzle: The Parrot Sequence - crack it!

Kaustubh Katdare

Kaustubh Katdare

@thebigk Oct 26, 2024
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]

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Mar 4, 2008

    No Takers? Too tough for the CEans? 😁
  • mahul

    mahul

    @mahul-ZxpiLA Mar 4, 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

    @vissin-cphOJO 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

    @mdronsubbs-ovd1Y0 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

    @skamthe81-8B6NjL Jun 5, 2008

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

    give us dome more
  • xheavenlyx

    xheavenlyx

    @xheavenlyx-CbvN62 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

    @mahul-ZxpiLA 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

    @xheavenlyx-CbvN62 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 <x> 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

    @bayazidahmed-qg0JR9 Jul 22, 2008

    break the number, count (by parsing) and display
  • prakash.athani

    prakash.athani

    @prakashathani-RsvHp8 Sep 26, 2008

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

    prakash.athani

    @prakashathani-RsvHp8 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

    @xheavenlyx-CbvN62 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: #-Link-Snipped-#
    Name of Program is: #-Link-Snipped-#
  • prakash.athani

    prakash.athani

    @prakashathani-RsvHp8 Sep 29, 2008

     
    //Parrot sequence in C
     
    #include<stdio.h>
    #include<conio.h>
     
    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

    @xheavenlyx-CbvN62 Oct 25, 2008

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

    agriz

    @agriz-Qm2A5x Jun 19, 2010

    Check 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.
  • silverscorpion

    silverscorpion

    @silverscorpion-iJKtdQ 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

    @agriz-Qm2A5x 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

    @suhanimody-G7yl05 Jun 28, 2012

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

    sidd26

    @sidd26-VcMz6s Aug 10, 2012

    a) The sequence 333 never appears.
    b)The digit 4 occurs at the 11 page .
  • sndgpr26

    sndgpr26

    @sndgpr26-Yb3sXd Aug 22, 2012

    The_Big_K
    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]
    4 will not appear at any cost
  • sweet_honey

    sweet_honey

    @sweet-honey-areuMs Aug 23, 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.