Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me solve this progrem in python. PROBLEM: ACSL Tiles is a one - person game played with rectangular tiles. Each tile has a single

Help me solve this progrem in python. PROBLEM: ACSL Tiles is a one-person game played with rectangular tiles. Each tile has a single-digit number, 09, at each end. At the start of the game, there are 4 rows, each with a single-digit number from 09; thus the number 405 represents the starting numbers 0,4,0,5. Tiles can be re-oriented; thus, the tiles 04 and 40 are the same tile. Tiles, called the hand, are given to the player, and other tiles are put into a draw pile. The initial number of tiles in your hand and in the draw pile varies from game to game. The goal of the game is to build rows by placing a tile from your hand at the right end of a row whose last number matches one of the numbers on the tile. If no tiles in your hand can be placed, tiles are added to the end of your hand from the draw pile, until a tile from the draw pile can be placed. More specifically, on each turn, try to match your tiles starting with the first one in your hand. See if any can be added to one of the rows, starting with the row after the one where the last tile was placed, rotating back to Row 1 if necessary. Start looking at Row 1 when the game starts. However, if the last tile placed was a double (i.e., both numbers are the same), another tile must be placed on that row before any other match can be considered. If you cannot place any tiles in your hand, add tiles from the draw pile to your hand until a tile can be placed. The game ends when you've placed all tiles in your hand OR you cannot place any of the tiles in your hand and you've exhausted the draw pile. At that point, find the sum of the single-digit numbers that are still in your hand. Row 1: Row 2: Row 3: Row 4: The tile 56 is placed on Row 1; the tile 27 is placed on Row 3; the tile 73 is placed on Row 4(note that it's rotated, so that the 3 matches); the tile 34 is kept in your hand; and the tile 99 is placed on Row 2. The 99 is a double, so the next tile to be placed must match a 9. None of the tiles in your hand match, so 36 is added to your hand from the draw pile. That tile cannot be placed, so it stays in your hand. Next the 92 is drawn; it can be placed on Row 2. Your hand is now 344532176457181136 and the draw pile is 225082. The following moves are made: 32 on Row 2(rotated),34 on Row 2,45 on Row 2,17 on Row 3(rotated),64 on Row 1,57 on Row 2,18 on Row 3. Here is what the board looks like: Row 1: Row 2: 5\begin{tabular}{|l|l|}\hline 5 & 6\\\hline \end{tabular}64\begin{tabular}{|l|l|}\hline 9 & 9\\\hline \end{tabular}9223344557 Row 3: 2277118 Row 4: 337 The tiles left in your hand are 11 and 36; neither can be placed, so draw 22(it cannot be placed), then 50(it cannot be placed), and then 82. The 82 can be placed on Row 3. Your hand is now 11362250 and the draw pile is empty. The 22 tile can be placed and then the game is over. The final board is as follows: Your hand is 113650, so the sum of the single-digit numbers on those tiles is 1+1+3+6+5+0=16. INPUT: Input an integer, between 0 and 9999 inclusive, that gives the initial numbers from Row 1 to Row 4. It is followed by two strings of numbers, from 0 to 99 inclusive, each separated by a single space. The first string has the tiles in your hand; the second string has the tiles in the draw pile. The numbers in each string represent the two numbers on each tile; a single-digit number indicates that at least one of the numbers on the tile is a 0. OUTPUT: After placing the tiles using the rules above, output the sum of the single-digit numbers on the tiles left in your hand. If you've placed all of your tiles, then you'll output a 0. SA MPI F. INPITT: SAMPLE OUTPUT: 1.162.03.1024.165.71 TEST OUTPUT: 1.382.133.114.675.0

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

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions