The ‘I-Game’

You all know that IEEEXtreme 4.0 finished recently. I thought of publishing some of the problems given at the competition. Give it a try if you have a little time. Most of the questions are really cool. Try to develop algorithms to solve the questions. I’ll try to publish all the questions whenever possible.

Here’s The problem called ‘I-Game’ straight from Xtreme 4.0 (Hope I’m not violating any copyright laws) Have Fun Coding….


I-Game Part I

Electronic devices are getting smaller and smaller, so the only way to push its buttons is by using a special mini-screwdriver. Since it is an IEEE screwdriver, its head is shaped as the letter I, which means that touching a button (marked with an “X”) on the grid may actually hit six others buttons (marked with an “*”). In the initial state of the game all lights are off. Touching a button will flip the light state of the pressed buttons. Touching buttons on the edge of the grid reduces the number of extra buttons affected.

Task

Please, write a program to simulate the I-game on a 10×10 grid: given a list of points the I-screwdriver touched as an input you should give the lights state as an output.

Input

A list of 0 ≤ x,y ≤ 9 coordinates, each one in a single line.
X Y
X = Column
Y = Row
Note: Grid Starts at 0 0 and ends at 9 9

Output

The resulting light pattern as a 10×10 square listed as “X” for on and “.” for off.

Sample Input 1

6 7
0 0
6 7

Sample Output 1

X . . . . . . . . .

X X . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

Sample Input 2

5 5
1 7
6 6

Sample Output 2

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . X X X . . .

. . . . . . X X . .

X X X . X X . . . .

. X . . . X X X . .

X X X . . . . . . .

. . . . . . . . . .
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s