Find Jobs
Hire Freelancers

You wrote a program that simulated the game "Mastermind". In this lab, you will write a program that assists a player with the game.

$30-250 USD

Completed
Posted over 11 years ago

$30-250 USD

Paid on delivery
you wrote a program that simulated the game “Mastermind”. In this lab, you will write a program that assists a player with the game. Specifically, your program will compute all potentially successful key patterns, given a guess pattern and the feedback characters for the guess pattern. This assistant program might be especially useful as an iPhone or Android app that a player could use while actually playing Mastermind. Mastermind Assistant As with Lab #6, your program should first ask the user for the pattern length, n (an integer). Then, your program should ask the user for the guess pattern she attempted, which will have n characters, each of which is from a through f (as in Lab #6). Next, your program should ask the user for the number of black pegs in the feedback. Finally, your program should ask the user for the number of white pegs in the feedback. Recall that the number of black pegs indicates the number of characters in the guess that are in exactly the correct position. The number of white pegs indicates the number of characters in the guess pattern that appear in the key pattern, but that are in the wrong position in the guess pattern. For more details on the meaning of the black and white pegs, refer back to the handout for Lab #6. Your program must use recursion to compute and print all key patterns that have the potential to be the correct key pattern. It should not print any patterns that cannot possibly be the correct key pattern, due to the number of black and white pegs in the feedback. For example, if the guess pattern is abcd and the number of black pegs is 3, it is certain that bacd is not a key pattern, as it has 2 characters that differ from the guess. The list of potential key patterns must be printed in the exact order shown in the examples below. Observe that key patterns, if viewed as English-language words, are printed in alphabetical order. Example #1: Enter the pattern length: 3 Input the guess pattern: abc Enter the number of black pegs in the feedback: 2 Enter the number of white pegs in the feedback: 0 The possible key patterns are: aac aba abb abd abe abf acc adc aec afc bbc cbc dbc ebc fbc Example #2: Enter the pattern length: 2 Input the guess pattern: ab Enter the number of black pegs in the feedback: 0 Enter the number of white pegs in the feedback: 2 The possible key patterns are: ba Example #3: Enter the pattern length: 12 Input the guess pattern: aaaaaabbbbbb Enter the number of black pegs in the feedback: 10 Enter the number of white pegs in the feedback: 2 The possible key patterns are: aaaaababbbbb aaaaabbabbbb aaaaabbbabbb aaaaabbbbabb aaaaabbbbbab aaaaabbbbbba aaaabaabbbbb aaaabababbbb aaaababbabbb aaaababbbabb aaaababbbbab aaaababbbbba aaabaaabbbbb aaabaababbbb aaabaabbabbb aaabaabbbabb aaabaabbbbab aaabaabbbbba aabaaaabbbbb aabaaababbbb aabaaabbabbb aabaaabbbabb aabaaabbbbab aabaaabbbbba abaaaaabbbbb abaaaababbbb abaaaabbabbb abaaaabbbabb abaaaabbbbab abaaaabbbbba baaaaaabbbbb baaaaababbbb baaaaabbabbb baaaaabbbabb baaaaabbbbab baaaaabbbbba You may assume that the user enters valid input. For example, for patterns of length 3, the sum of the number of black and white pegs can never exceed 3. For full marks, your program must compute its result in a reasonable amount of time for large pattern lengths, such as 10. Write your program in a file called Lab7.c.
Project ID: 2646134

About the project

1 proposal
Remote project
Active 12 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
I can help You
$30 USD in 1 day
5.0 (43 reviews)
5.5
5.5

About the client

Flag of UNITED ARAB EMIRATES
Abu Dhabi, United Arab Emirates
5.0
1
Payment method verified
Member since Nov 14, 2012

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.