Question: 2 0 2 2 / 2 0 2 3 SOUTHERN CALIFORNIA REGIONAL INTERNATIONAL COLLEGIATE PROGRAMMING CONTEST Problem 7 Color Tubes There is a new puzzle
SOUTHERN CALIFORNIA REGIONAL INTERNATIONAL COLLEGIATE PROGRAMMING CONTEST
Problem
Color Tubes
There is a new puzzle generating buzz on social mediaColor Tubes. The rules are relatively simple: you are given tubes filled with colored balls. Each tube can hold at most balls, and each color appears on exactly balls so there are colors
Using a series of moves, you are supposed to reach a Color Tubes state each tube should either hold balls of a single color or it should be empty. The only move allowed is to take the top ball from onf tube and place it into a different tube that has room for it ie holds at most two balls before the move
You want to write a program to solve this puzzle for you. Initially, you are not interested in an optimal solution, but you want your program to be good enough to solve any puzzle configuration using at most moves.
The first line of input contains a single integer which is the number of colors.
Each of the next lines contains three spaceseparated integers and which are the descriptions of each tube, where is the color of the ball on the bottom, is the color of the ball in the middle, and is the color of the ball on the top. The tubes are numbered from to and are listed in order. The colors are numbered from to The number describes an empty space. It is guaranteed that no empty space will be below a colored ball.
On the first line output an integer the number of moves that your program will use to solve the puzzle. Remember, has to be at most
On the next lines, output two spaceseparated integers and that describe a move In each move, you are taking the uppermost ball out of tube and placing it in tube where it will fall until it hits the uppermost ball already in that tube, or the bottom of the tube if the tube is empty.
Your solution will be deemed incorrect if it uses more than moves, or any of the moves are not allowed, or the final configuration is not a Color Tubes state.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
