board coloring, C/C++ Programming

Assignment Help:
programing code on board coloring in clanguage

Related Discussions:- board coloring

What is the main advantage to using a data file, Problem: (a) What is ...

Problem: (a) What is the main advantage to using a data file? (b) What is meant by opening a data file? How is this accomplished? Illustrate your answer clearly with a sui

Define the data type modifiers in c language, Define the Data Type Modifier...

Define the Data Type Modifiers in C language? There are three data types(int, float & double) above have the following modifiers. 1. short 2. long 3. signed 4. unsigned

C program to calculate area of cube, Aim: To implement program to calculat...

Aim: To implement program to calculate area of cube using inline function. Code: inline void area_cube(float side) {             float area;             are

Write a program that reads a line of characters, Write a program that reads...

Write a program that reads a line of characters from the user and displays that entire line after converting any uppercase characters to lowercase also change any lowercase charact

How to write program, how to write a program for all the types of beam reac...

how to write a program for all the types of beam reactions

Padovan string, padovan string problem program 1 : package test.padovan...

padovan string problem program 1 : package test.padovanstring; public class PadovanString {     public int stringOccurrences(int n, String str){        if(n >= 40)

Destructor on a local variable, Should I explicitly call a destructor on a ...

Should I explicitly call a destructor on a local variable? Explain it.

Tool for checking memeory leak, what would be the best tool for debuggingg ...

what would be the best tool for debuggingg memory leaks in c/c++ programming

diana

9/4/2012 4:22:43 AM

Board Coloring :: Aspiration 2020 :: Question number 6
Board Coloring

Problem Description


In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color.
Fill the other elements in the board, such that none of the adjacent elements (vertically, horizontally and diagonally) should be of the same color.
Find out the minimum number of colors that should be used to fill the blank spaces in the board, so that the above condition is met.
Color representation is -: 0, 1, 2, 3, 4, 5, 6, 7…………………….
There is sample board:

For Example:

Given Board :

The matrix representation of board is :
[ _ 1 _ _ ]
[ 2 _ _ _ ]
[ _ _ 2 _ ]
[ 2 _ _ _ ]
In the above example the blank space is represented by ''_'' .
The minimum number of colors needed to fill the board in the example is 4.

Instruction to work with Open PBT Client:

Specify the work directory path in the ''Work Directory Path'' field. The path should correspond to your solution project directory.
Download the support files by clicking the Get Dev Files.
You will find the following three folders:
bin
src
lib
in your work directory.
Code the solution in . java file inside the src folder
All required files will be downloaded to your work directory. Creating additional files is strongly discouraged.

Step 1:
In your solution file:

Implement your logic in public int color(char[][] board) in class BoardColoring .
char[][] board : board is 2 dimensional matrix of order M X M where M = 4.

You can create more methods but, do it in the same class.

Step 2:
In your solution keep in mind the following constraints.

In this problem you have to write a program to find the minimum no of colors to fill a board where some of the elements of different color are already placed.
Method color() will take 2 D board as a input.
Method color() will return minimum no of colors which can fill the board with given condition.
The board should be a 2-dimensional M X M matrix, where M =4 otherwise return 0
Fill the other elements in the board, such that none of the adjacent elements (vertically, horizontally and diagonally) should be of the same color.

The Prototype of the method is:

public int color(char[][] board).
This method takes following arguments.

board is 2 dimensional matrix of order M X M where M = 4.

This method returns minimum no of color by which board can be filled.

The constraints are:

The board should be a 2-dimensional M X M matrix, where M =4 otherwise return 0
Fill the other elements in the board, such that none of the adjacent elements (vertically, horizontally and diagonally) should be of the same color.

Example 1
Input : { 2 0 _ 1 }
{ _ 1 _ _ }
{ _ 2 _ 0 }
{ _ _ _ 1 }
Output : 5

Explanation:
We need a minimum 5 different colors to complete the board.

Example 2
Input : { 2 0 _ 1 3}
{ _ 1 _ _ 2}
{ _ 2 _ 0 1}
{ _ _ _ 1 2}
{ _ _ _ _ 0}
Output : 0


Explanation:
Size of the board is greater than 4X4.

Example 3
Input : { _ 0 }
{ 1 _ }
Output : 0


Explanation:
Size of the board is less than 4X4.

For Java solutions
Package Name : test.boardcoloring
File Name : BoardColoring.java
Class Name : BoardColoring
Method Names : public int color(char[][] board)

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd