Code Wars V
     

Program / Task Name:

   Shooting Star

Level:

 

 Intermediate

Point Value:

 

 6

 

Task Description

The Really Simple Game Company has just hired you.  Your first programming assignment is to write the “Shooting Stars” game.  This game is played on a 3 X 3 grid.  Each location on the grid has either a star or no star.  An asterisk represents a “star” and a period represents “no star”.  Each location on the grid is numbered 1-9, going from left to right then top to bottom.

Grid Mapping

1

2

3

4

5

6

7

8

9

The object of the game is to destroy all of the stars.  To do this you shoot star bombs at the grid, until there are no stars left.  You shoot a star bomb by typing the number of the grid location.  For any location you shoot at and the ones adjacent vertically and horizontally, if there is a star there it disappears and if there is no star there it creates one.  There is one star in the center for the start of the game and looks like this:

...
.*.
...

 

If the first character is a ‘5’, the resulting grid would look like:

.*.
*.*
.*.
 

Program Input

Any key character can be input, but for a shot action all are ignored except numeric digits 1-9.

Program Output

At the beginning of the program print out “Welcome to Shooting Stars”, a blank line, the initial star grid and then another blank line.  Do not print out any characters entered.  Any character entered that is not a 1-9 causes should be ignored.  After a valid numeric digit is input, print out the new playing grid of stars with a blank line after the star grid.  If all stars have been destroyed, then print out “You WIN!!!” and exit the program.

 

hp Code Wars
Hello -- Dominos?...
   
  (c) 2004 Hewlett-Packard Company