Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93089368

Have any Question?


Related Questions in Computer Engineering

Requested files diceh dicecpp diceanddangercpp

Requested files: Dice.h, Dice.cpp, DiceAndDanger.cpp, DiceAndDanger_test.cpp With this program, you will begin the practice of breaking source code into distinct modules that are responsible for limited scopes of behavio ...

Suppose you are writing software for a radio station that

Suppose you are writing software for a radio station that manages its playlists. The program will generate candidate playlists from a record library automatically and station personnel can then check and modifythem. Disc ...

Select a company or any existing business this can be the

Select a company or any existing business. This can be the company you currently work for. If you cannot find information about the security infrastructure of a company, you may make up the details as realistic as possib ...

Suppose alice shares a secret block cipher key kab with bob

Suppose Alice shares a secret block cipher key, K_AB with Bob, and a different secret block cipher key, K_AC with Charlie. Describe a method for Alice to encrypt an m-block message such that it can only be decrypted with ...

You run a small pizza shop named pizza hat initially you

You run a small pizza shop named Pizza Hat. Initially you sold pizzas for $8 and every week you sold around 3000 pizzas. Each pizza costs you $3 to make. One day you decided to o¤er discounts to customers to see if you c ...

Question what sequence of numbers would be printed by the

Question : What sequence of numbers would be printed by the following recursive function if we started it with N assigned the value 1? def Exercise (N): print(N) if (N Exercise(N + 1) print(N)

It has been argued that although there may be more claims

It has been argued that although there may be more claims when road conditions are slippery in the winter, this should not affect the average claim. Malpeque took a sample of 50 claims from the winter of 2018 and found t ...

Has globalizationnbspincreased or decreased social and

Has globalization increased or decreased social and economic disparities around the globe? Can you please provide details.

What are information silos what are the problems caused by

What are information silos? What are the problems caused by information silos? How organizations can solve the problems caused by information silos?

Discuss the importance of metadata and some of the various

Discuss the importance of metadata and some of the various ways (Microsoft) SQL Server allows you to expose that information. References welcomed to learn where to find obscure IT information (books, articles, websites)

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As