Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Members have full access to the forums. Advertisements are removed for registered users.

# Thread: Game Logic

1. ## Game Logic

Blitz Cyvasse(Can Anybody make Java Code for This Problem)->
Tyrion Lannister is a master player of cyvasse, a game of strategy and war similar to chess. He has challenged
Bronn, the captain of his guard, during Joffrey Baratheon’s nameday celebrations. In his inebriated state,
Tyrion is finding it harder and harder to beat Bronn as the evening wears on. Unfortunately, he has staked
too much in his pride and it is imperative that he win all games to avoid humiliation.
Cyvasse is played with a grid of n x m cells (n rows and m columns), with tiles of grass, forest, water or
mountains covering each cell. Players have pieces occupying tiles corresponding to infantry, cavalry, artillery
and one dragon each. Players can attack their own pieces too. Tyrion decides to use his dragon to destroy an
entire row of the board at a time. Bronn being not so experienced, simply mirrors Tyrion’s tactics. However,
there is a catch. In subsequent moves, a player can only destroy a row with number of corresponding tile
position differing from that of the last destroyed row as an odd prime. Two tile positions differ if they one is
filled and other is empty. Eg. 1100011 and 0001000 differ at 5 positions which is odd prime. ‘1’ denotes a
filled position and ‘0’ denotes an empty position. Both of them mutually decide to concede when they have
no move left.
Given n, m and the state of each tile (occupied or unoccupied), does Tyrion have a winning strategy if he
takes he first move?
Input
First line contains T , the number of test cases. T test cases follow.
First line of each test case contain 2 space separated integers n and m as specified above.
An nxm matrix follows denoting the initial state of the game. A ‘1’ denotes that the position is filled up. ‘0’
denotes an empty position
Constraints
n <= 100
m <= 1000
Output
For each test case, output on a separate line “YES” (quotes for clarity) if he has a winning strategy else
“NO” (quotes for clarity)
Sample Input
3
10 11
11110000000
11111111110
11111111000
11000000000
11000000000
11111000000
10000000000
11111110000
11111000000
11111000000
8 11
1

2. ## Re: Game Logic

What have you tried? - Matt Gemmell