mastermind.utils package¶
This module defines the generate_feedback function, which takes a guess and a secret code, and returns the number of black and white pegs.
- mastermind.utils.get_feedback.generate_feedback(guess: tuple, secret: tuple, number_of_colors: int) list [source]¶
Generates feedback based on the guess and the secret code.
- Parameters:
guess (tuple) – The player’s guess.
secret (tuple) – The secret code.
number_of_colors (int) – The number of colors in the game.
- Returns:
A list containing the number of black and white pegs.
- Return type:
list
- mastermind.utils.render_dataframe.render_dataframe(df)[source]¶
Prints the Pandas DataFrame in a human-readable format.
- Parameters:
df (pandas.DataFrame) – The DataFrame to be rendered.
- class mastermind.utils.stack.Stack(data: list | None = None)[source]¶
Bases:
object
A simple stack data structure implementation using the deque from the collections module.
- _stack¶
The internal deque used to store the stack elements.
- Type:
collections.deque
- property as_list: list¶
Returns the stack as a list, with the top item first.
- Returns:
The stack as a list.
- Return type:
list
- is_empty() bool [source]¶
Checks if the stack is empty.
- Returns:
True if the stack is empty, False otherwise.
- Return type:
bool
- pop() Any [source]¶
Removes and returns the top item from the stack.
- Returns:
The top item from the stack.
- Return type:
Any
- Raises:
IndexError – If the stack is empty.