- C 100%
| dead-crit.c | ||
| LICENSE | ||
| README.md | ||
Find Dead Crit
Interesting game based on grid. Nice problem for beginner in C.
Problem Description
There is a 9x9 grid. The 9x9 grid is divided into 9 3x3 grids. A 3x3 grid is called a Crit. Each Crit has a name.
The coordinate of the top left cell of the grid is (0, 0). The grid is shown below with each Crit’s name as follows:
- Grid
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
| 0 | |||||||||
| 1 | |||||||||
| 2 | |||||||||
| 3 | |||||||||
| 4 | |||||||||
| 5 | |||||||||
| 6 | |||||||||
| 7 | |||||||||
| 8 |
- Crits
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
| 0 | SUN | MERCURY | VENUS | ||||||
| 1 | |||||||||
| 2 | |||||||||
| 3 | EARTH | MARS | JUPITER | ||||||
| 4 | |||||||||
| 5 | |||||||||
| 6 | SATURN | URANUS | NEPTUNE | ||||||
| 7 | |||||||||
| 8 | |||||||||
Each Crit has a prestige. The prestige of a Crit is the sum of all values inside the Crit. There are 9 values inside every Crit. A Crit which has the lowest prestige of all Crits is called dead Crit. Initially, all elements of all 81 cells of the 9x9 grid are -1.
Write a program in standard C to print the name of the dead Crit.
Input
There will be several lines of input. Each line will have 3 space separated integers:
<row> <col> <value>
Each input line will modify the content with <value> of corresponding <row>, <col> of the 9x9 grid. The <row> and <col> are from 0 to 8. The <value> is from -99 to 99.
Output
After every input line, print out the name of the dead Crit.
- If there are multiple dead Crits, print the name of the dead Crit which has the lowest row number.
- If there are multiple dead Crits in the lowest row, print the name of the dead Crit which has lowest column number.
Sample Input & Output Explanation
| Sample Input | Explanation | Sample Output |
| 0 0 0 | Initially the prestige of all Crits is -9. This input changes the prestige of SUN to -8, making it the Crit with largest prestige. All other Crits still have the prestige -9. Among them, MERCURY has the lowest row and column number. | MERCURY |
| 0 3 1 | After this modification to the grid, MERCURY’s prestige has increased. Each of the remaining 7 Crits has the same prestige, of which VENUS has the lowest row and column number. | VENUS |
| 0 6 2 | Explanation is similar to the above. | EARTH |
| 3 0 3 | MARS | |
| 3 3 4 | JUPITER | |
| 3 6 5 | SATURN | |
| 6 0 6 | URANUS | |
| 6 3 7 | NEPTUNE | |
| 6 6 8 | This input will increase NEPTUNE’s prestige, making SUN’s prestige the lowest one. | SUN |
| 3 3 -3 | MARS’ prestige is decreased so much that it becomes the lowest, making it the dead Crit. | MARS |
| 0 3 -3 | Explanation is similar to the above. | MERCURY |