Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Quantitiative Aptitude
  • Logical Reasoning
  • Verbal Ability
  • Aptitude Quiz
  • Quantitiative Aptitude Quiz
  • Verbal Ability Quiz
  • Aptitude For Placements
  • Interview Corner
  • Practice Sets
Open In App
Next Article:
Puzzle - Chameleons go on a date
Next article icon

Puzzle - Chameleons go on a date

Last Updated : 01 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Question: 

13 purple, 15 yellow, and 17 maroon chameleons are found on an island. When two different-coloured chameleons come together, they both turn into the third colour. Do all chameleons eventually have the same hue after a certain number of pairwise meetings?

Solution:

As per the question, whenever 2 chameleons of different colours meet, both of them get converted into the third colour chameleon, which means that the number of Chameleons of the two colours (which met) decreases by 1, whereas the number of chameleons of the third colour (they converted into after meeting) increases by 2. 
Let us denote the chameleons of different colours purple, yellow and maroon by p, y and m respectively, and then the initial state is (13, 15, 17). 
Now, let us suppose that initially, a purple and maroon meet. The vector changes to (12, 17, 16) and after continuing, we would get to this state (0, 41,4). 
When Yellow and Maroon meet first : (15, 14, 16) and after continuing, the end state is (43, 0, 2).
When Purple and Yellow meet first: (12, 14, 19)and after continuing, the end state is (0, 2, 43).
Therefore, we observe that the difference between the Chameleons of two different colours is never going to be 0, and in the absence of such a scenario we can't get all the Chameleons to turn into one single colour.

Alternative Solution:

As per the question, the conditions there is the same number of chameleons, and the total number of chameleons never changes. So, the alternate way to see this situation is by a mathematical formula. Initially, we have:
Purple + Yellow + Maroon = 45
There are 3 possibilities for colour-changing. A Purple can meet a Yellow, a Purple can meet a Maroon, and a Yellow can meet a Maroon. In each case, two colour types decrease by 1, and the third colour type increases by 2. The three possibilities can be represented by:
(Purple – 1) + (Yellow – 1) + (Maroon + 2) = 45
(Purple – 1) + (Yellow + 2) + (Maroon – 1) = 45
(Purple + 2) + (Yellow – 1) + (Maroon – 1) = 45
The reduction in the number for the colours that meet is exactly offset by the increase in the number for the other colour.
To solve the question, let's find an invariant that considers the pairing of Yellow and Purple chameleons considering the difference between Yellow and Purple chameleons:
Yellow – Purple
There are 3 possibilities for colour-changing. A Purple can meet a Yellow, a Purple can meet a Maroon, and a Yellow can meet a Maroon. Let's compute what happens to the quantity Yellow – Purple for those possibilities in order:
(Yellow – 1) – (Purple – 1) = Yellow – Purple
(Yellow + 2) – (Purple – 1) = Yellow – Purple + 3
(Yellow – 1) – (Purple + 2) = Yellow – Purple – 3
We conclude that the difference can either be the same, or it can go up or down by 3 because when a Purple and a Yellow meet, the number of each reduces by 1 so the difference between them stays the same. When one colour reduces by 1 and the other colour increases by 2, for a total difference of plus or minus 3.
So, the difference between Yellow and Purple is always the same as at the start, plus or minus a multiple of 3.
Let's begin with 13 Purple and 15 Maroon so:
Yellow – Purple = 2
Irrespective of how the chameleons meet, this difference will always be 2 plus a multiple of 3. So we have:
Yellow – Purple = 2 + 3k, for some integer k
For the chameleons to be of the same colour there are 3 ways this could happen:
(45 Purple, 0 Yellow, 0 Maroon), so Yellow – Purple = -45 = 3(-15)
(0 Purple, 45 Yellow, 0 Maroon), so Yellow – Purple = 45 = 3(15)
(0 Purple, 0 Yellow, 45 Maroon), so Yellow – Purple = 0 = 3(0)
If all chameleons became of the same colour, then the difference Yellow – Purple would be a multiple of 3.
But it's not possible as per the question as the difference Yellow – Purple will never be a multiple of 3–it will always be 2 more than a multiple of 3.
Therefore, it is not possible for the 13 Purple, 15 Yellow, and 17 Maroon chameleons to ever all become the same colour.


Next Article
Puzzle - Chameleons go on a date

T

talktojacko6ds
Improve
Article Tags :
  • Aptitude
  • Logical Puzzles

Similar Reads

    Puzzle | Bilateral Conversations
    There are n students in a class, each in possession of a different personality attribute. As they are new in the school, so they want to know about each other. To help the students, the teacher decides to conduct an activity. The rule for the activity is that the students will share the personality
    2 min read
    Puzzle | Two Brothers and Facebook
    Sahil and Ritik are brothers. One day they were discussing who is smarter. But gradually the discussion turned into an argument. Mother came and tried to handle the situation. She gave them a problem to solve and the one who will solve the problem first, would be considered smarter than the other. T
    3 min read
    Puzzle | Farmer, Goat, Wolf and Cabbage
    There is a farmer who wishes to cross a river but he is not alone. He also has a goat, a wolf, and a cabbage along with him. There is only one boat available which can support the farmer and either of the goat, wolf or the cabbage. So at a time, the boat can have only two objects (farmer and one oth
    3 min read
    Puzzle | Handshakes
    A couple invites n - 1 other couples to dinner. Once everyone arrives, each person shakes hands with everyone he doesn’t know. Then, the host asks everyone how many hands they shook and each person replies with a different number. Assuming that everyone knows his or her own spouse, how many hands di
    2 min read
    Puzzle | Camels and Travelers
    In a desert there are some camels and some travelers. How many camels and travelers are there if both the following statements are TRUE? If each traveler sit on the camel, one traveler doesn't get a camel. If two traveler share each camel there is one camel left out. Answer: Camels-> 3 Travelers-
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences