Calculate the number of possible color combinations

Assignment Help Computer Engineering
Reference no: EM132101899

In the popular game Mastermind, one player creates a secret code of four pegs, each of which can be chosen from one of six colors. (The number of pegs and colors may be different than this in different versions, but your implementation will use these values, but be extendible to other values. Also, a color can be reused, thus there really are six choices for each of the four pegs.) The other player then has to guess the color of each peg, with the order mattering.

The player who made the secret code then has to give feed back to the player guessing. This feedback is in the form of white and black pegs. A black peg means that the guesser has chosen the correct color in the correct slot. These are first "calculated" and awarded. Once these are counted, these pegs are ignored.

Then the white pegs are awarded. These are for pegs that are the correct color but are in the incorrect slot. There is no "double dipping" of pegs in the response, so the sum total of white and black pegs the guesser can receive is four, and no one peg in the guesser's answer may earn them more than one black or one white peg.

Your task will be to analyze a partially completed game and calculate the number of possible color combinations that are completely consistent with all of the given information. Due to the fact that the manufacturer may release different versions of the game with a different number of possible colors and a different number of possible slots, your program should work where these two values are given as variables.

The Input (read from standard input)

The first line of input will contain a single positive integer, c (c = 100), representing the number of input cases. The first line of each input case will contain three space-separated positive integers, n, the number of slots to fill in, k (k = 2), the number of possible colors for each slot, and m (m = 20), the number of moves that have currently been played. It's guaranteed that kn = 106. The following m lines will contain information about each player guess for that round.

Each of these lines will start with n space separated non-negative integers, each in between 0 and k-1, inclusive, representing the player's guess, in order, for filling the slots of the secret combination. The last two integers (also space separated) on each line will be b and w, representing the number of colors in correct locations guessed correctly in the combination and the number of colors in the incorrect locations guessed correctly, respectively.

The Output (to standard out)

For each input case, output a single integer, on a line by itself, representing the number of possible combinations consistent with the partially played game for the case. You are guaranteed that each input case will have at least one possible combination meaning that the information given for the input case is correct and the person reporting the number of matches has done so.

Sample Input Sample Output

3 1

464 36

012302 200

224102

433211
135413
6 10 3
01234500

77889904

99778840

10 2 1

010101010154

Reference no: EM132101899

Questions Cloud

Create a new java application to manage linked lists : Create a new List (call it clockList) of type MyLinkedList . Insert five Clock objects numbers to the list (not ordered).
Create an array with thirty data elements : Suppose a data array has 30 numbers sorted from low to high already, where no two numbers are equal.
Why did the set timeout : IF i want to conect a raspberry pi 3 with a GSM modum through a serial port , and since the GSM modum is talking at 9600 (by datashet).
Compare two sets of characters : Your program will include a function called searcher that uses pointers to both the source string and the character set, and which returns a pointer to a char.
Calculate the number of possible color combinations : In the popular game Mastermind, one player creates a secret code of four pegs, each of which can be chosen from one of six colors.
Lists which enumerate coefcients of polynomials : The leading coeffcient of the output polynomial can not be zero. If the result is the zero polynomial, please output the empty list.
How many different 5-card poker hands are there : How many different 5-card Poker hands are there? How many of these are 1 pair?
Why do not the administrators just use random numbers : Why don't the administrators just use random numbers? Would these be the same for a proxy firewall? How would a NAC work with a firewall?
How would your own code of ethics guide you in dealing : Philosophy 110 : Explain the pros and cons of the positions on the topic you have chosen and state your position on the topic.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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