Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ACSL Tiles is a one - person game played with rectangular tiles. Each tile has a single - digit number between 1 and 9 inclusive
ACSL Tiles is a oneperson game played with rectangular tiles. Each tile has a singledigit number between and inclusive at each end. At the start of the game, there are rows, each with a number. The goal of the game is to build rows by placing a tile at the right end of a row whose last number matches a number on the tile. Tiles can be reoriented; thus, the tiles and are the same tile. If a tile cannot be placed on any row, it is placed in the discard pile. When all tiles have been played or discarded, find the sum of the singledigit numbers on all of the tiles in this discard pile.
At each turn, try the next tile in your hand to see if it 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 if necessary. Start looking at Row when the game starts. However, if the last tile placed was a double ie both numbers are the same another tile must be placed on that row before any other match can be considered. If the tile cannot be placed, add it to the discard pile.
Input:
Output:
Explanation:
The game starts with rows having numbers
The tile is placed on Row ; the tile is placed on Row ; the tile is placed on Row as because Row is checked first after a tile is placed on Row ; the tile is placed on the discard pile; the tile is placed on Row
The and the tiles are placed in the discard pile because they don't match the tile; the tile is placed on Row as ; the tile is placed on Row ; the is placed on Row as ; and the is placed on Row
The final outcome is shown below:
The sum of the singledigit numbers on the tiles in the
discard pile is
TASK:
Complete the function findDiscardSum
The function has two parameters: a digit integer, originalRows, representing the initial numbers from Row to Row and a string of digit numbers, tiles, each separated by a single space. Each digit number represents the two numbers on each tile, both between and inclusive.
The function returns an integer representing the sum of all of the singledigit numbers on the tiles in the discard pile.
You may create additional functions that are called from findDiscardSum if needed in solving the problem.
Please write a solution in C Python, or Java for this problem that also accounts for many test cases
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