Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

Students also viewed these Databases questions