Question
IN C++ Welcome to the Toothpick Puzzle, where the goal is to get an equal number of toothpicks in each stack, in three moves. Stack:
IN C++
Welcome to the Toothpick Puzzle, where the goal is to get an equal
number of toothpicks in each stack, in three moves.
Stack: A B C
Number of Toothpicks: 11 7 6
A move consists of moving toothpicks from one stack to a second stack,
where the number of toothpicks moved is exactly the number that is in the
destination stack. In other words, to move from stack B (7 toothpicks)
to stack C (6) as shown above, we would move 6 from B to C, leaving us
with 1 in B and 12 in stack C.
Here we go...
Stack: A B C
Number of Toothpicks: 11 7 6
1. Enter FROM and TO stack letters: a c
Stack: A B C
Number of Toothpicks: 5 7 12
2. Enter FROM and TO stack letters: ab
Sorry, not enough toothpicks in A. Retry...
2. Enter FROM and TO stack letters: ca
Stack: A B C
Number of Toothpicks: 10 7 7
3. Enter FROM and TO stack letters: ab
Stack: A B C
Number of Toothpicks: 3 14 7
Nope, sorry, that's not it. Try again.
Ending program...
(THE LANGUAGE IS C++) (C++) (C++)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started