Extreme Hat Game
Description:
In this generalized version of the riddle, each 'player' has a hat and must guess what color it is. The players are lined up such that they can see the hats of everyone in front of them, but not their own hat or those of the players behind them. Each player must guess the color of their own hat, taking turns from back to front. In order to win, only one guess may be wrong.
The team will be told which colors of hats will be present (but not how many of each color) and given time to develop a strategy before they get their hats.
Your task is to create the team's strategy by writing a function that returns the guess for a player based on the information they have.
Inputs
a list of all colors of hat (possibly) present.
Colors can be any Eq type; not just Strings.
a list of previous guesses, starting from the back (empty for the first player).
a list of the hats the player can see, starting with the one directly in front of them (empty for the last player).
Output
- the guess, which should be one of the elements from the list of colors passed in
All inputs in the test cases will follow the rules of the riddle. Your solution should work for any number of colors, but the test cases will only go up to 5 colors and 100 players. Tests assume the first person to guess is wrong, since it is impossible to know what color hat they have.
Similar Kata:
Stats:
Created | Jul 1, 2022 |
Published | Jul 3, 2022 |
Warriors Trained | 304 |
Total Skips | 54 |
Total Code Submissions | 201 |
Total Times Completed | 41 |
Haskell Completions | 12 |
Python Completions | 35 |
Total Stars | 11 |
% of votes with a positive feedback rating | 100% of 17 |
Total "Very Satisfied" Votes | 17 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 7 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |