Skip to main content

Connect-K in Java Data Structures Compelete Source code

Buy now

Introduction:

In the game of Connect-K, red and blue pieces are dropped into an N-by-N table. The
the table stands up vertically so that pieces drop down to the bottom-most empty slots in their column. For example, consider the following two configurations:-

Legal Position -

.......
..................R
.....RB....
BRB...
RBBR.. -

Illegal Position -

............................Bad
 - ..BR......
R....
RBBR..

In these pictures, each '.' represents an empty slot, each 'R' represents a slot filled with a red piece, and each 'B' represents a slot filled with a blue piece. The left configuration is legal, but the right one is not. This is because one of the pieces in the third column (marked with the arrow) has not fallen down to the empty slot below it.
A player wins if they can place at least K pieces of their colour in a row, either horizontally,
vertically, or diagonally. The four possible orientations are shown below:

- Four in a row -

R RRRR R RR R RR R RR R R
In the "Legal Position" diagram at the beginning of the problem statement, both players had lined up two pieces in a row, but not three.
You have a tricky plan to ensure victory with Connect-K! When your opponent is not looking, you are going to rotate the board 90 degrees clockwise onto its side. Gravity will then cause the pieces to fall down into a new position as shown below:

- Start -

........................R......RB....BRB...RBBR.. - Rotate -
.......R......BB..... BRRR...RBB.................. - Gravity -
.....................R......BB.....BRR....RBBR... Unfortunately, you only have time to rotate once before your opponent will notice.All that remains is picking the right time to make your move. Given a board position, you should determine which player (or players!) will have K pieces in a row after you rotate the board clockwise and gravity takes effect in the new direction.
NotesYou can rotate the board only once.Assume that gravity only takes effect after the board has been rotated completely. Only check for winners after gravity has finished taking effect.

Input

The first line of the input gives the number of test cases, T. T test cases follow, each beginning with a line containing the integers N and K. The next N lines will each be exactly N characters long, showing the initial position of the board, using the same format as the diagrams above.
The initial position in each test case will be a legal position that can occur during a game of Connect-K. In particular, neither player will have already formed K pieces in a row.

Output

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1), and y is one of "Red", "Blue", "Neither", or "Both". Here, y indicates which player or players will have K pieces in a row after you rotate the board.

Limits

1 ≤ T ≤ 100.3 ≤ K ≤ N. Small dataset 3 ≤ N ≤ 7.Large dataset
3 ≤ N ≤ 50.

Example

You can search the Internet for another algorithm that has not been taught in class, and present, subject to the approval of the lecturer. Whatever the algorithm chose, the group will have to find (or implement) a Java implementation and show it, run it and discuss the code of such algorithm in a PowerPoint presentation in front of the class at the end of the course. Submission

Code Screenshots:



Order Now:

Buy now

CONTACT DETAILS

For any other questions or other tasks please feel free to contact me
via email: mhassnainjamil@gmail.com
via WhatsApp: +92-324-7042178
via skype: hassnainjamil1

Comments

Popular posts from this blog

The Zoo Management System - entity relationship diagram & MS Access Database

Zoo Management System - Project Details: You are the employee of a big, worldwide working Zoo Management Company. Your company is responsible for the Zoo management. Your boss thinks it would be a great idea to store all data for each Zoo in a brand new self-developed ZOO Management System. Up to now, the ZOO management company has maps of each ZOO available. Your boss knows that you took a course in introduction on an ERP system, so he asks you if you could help designing such a system. Each ZOO must have the same organizational structure, which should look like this: Each Zoo has a Zoo-Address. Each Zoo has many visitors (Visitor Ticket Process (VTP). Many Zoo-Attractions belong to a Zoo. Module 1: Entity Relationship Diagram Design a ER (entity-relationship) diagram for your ZOO Management System. Use the information provided below with the entities and its attributes. Put the entities in the correct relationship to each other (organizational structure). Module 2: DB Implem...

Human Physiology by Stuart Ira Fox [PDF] (12th edition) free download

Sudoku Game Project in Java with full source code including GUI task

Introduction The purpose of the project is to try in practice the use of recursion and object-oriented program design. Please make sure to read this entire note before starting your work. Pay close attention to the sections on deadlines, deliverables, and exam rules. The problem Your task in this part of the project is to write a solver for Sudoku puzzles. Sudoku puzzles are a kind of crossword puzzles with numbers where the following two conditions have to be met: In each row or column, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different.  For each of the nine non-overlapping 3x3 blocks, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they ust all be different. The following two figures show a Sudoku puzzle and its solution. The input The input of your program, the Sudoku puzzles, is given in text files. More specifically, they are represented as nine lines of nine characters separated by spaces. The characters can be of two...