Skip to content

Comments

Add Word Scramble interactive CLI game#13660

Closed
MahyudeenShahid wants to merge 4 commits intoTheAlgorithms:masterfrom
MahyudeenShahid:master
Closed

Add Word Scramble interactive CLI game#13660
MahyudeenShahid wants to merge 4 commits intoTheAlgorithms:masterfrom
MahyudeenShahid:master

Conversation

@MahyudeenShahid
Copy link

Title:
add interactive word scramble game

Description:
This pull request adds a new interactive CLI Word Scramble game implemented in a single Python file.

Files added:

  • word_scramble_game.py

This file implements:

  • Word scrambling and guessing logic
  • Category and difficulty system
  • Hint, skip, and quit functionality
  • Time-based scoring and simple streak/combo bonuses
  • JSON persistence for high scores and basic stats (files created at runtime)

Describe your change:

  • Add an algorithm or mini-project
  • Fix a bug or typo in an existing algorithm
  • Add or change doctests
  • Documentation change

Checklist:

  • I have read CONTRIBUTING.md
  • This pull request is entirely my own work — I have not plagiarized
  • I know that pull requests will not be merged if they fail the automated tests
  • This PR only changes one algorithm file
  • The new Python file is placed inside an existing directory (not in a new personal folder)
  • The filename is lowercase with no spaces or dashes (word_scramble_game.py)
  • All functions and variable names follow Python naming conventions
  • Function parameters and return values include type hints where applicable
  • The file includes docstrings and doctest examples for key functions (where practical)
  • The algorithm does not require any third-party dependencies

Reference:

Commit message:
add interactive word scramble game algorithm

This commit introduces a new interactive CLI game called Word Scramble. It features difficulty levels, multiple rounds, a hint system, scoring with time bonuses, and persistent high scores.
@algorithms-keeper algorithms-keeper bot added require descriptive names This PR needs descriptive function and/or variable names require type hints https://docs.python.org/3/library/typing.html labels Oct 21, 2025
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

}


def load_high_scores():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: load_high_scores. If the function does not return a value, please provide the type hint as: def function() -> None:

return []


def save_high_scores(scores):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: save_high_scores. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: scores


def save_high_scores(scores):
"""Save high scores to disk (keep only top 10)."""
scores = sorted(scores, key=lambda s: s["score"], reverse=True)[:10]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: s

json.dump(scores, fh, indent=2)


def load_stats():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: load_stats. If the function does not return a value, please provide the type hint as: def function() -> None:

return {"games_played": 0, "best_streak": 0}


def save_stats(stats):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: save_stats. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: stats

return int(base * mult + time_bonus)


def play_round(word, difficulty):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: play_round. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: word

Please provide type hint for the parameter: difficulty

print(f"Not quite. {same_positions} letter(s) in the correct position. Try again.")


def pick_word_by_difficulty_and_category(difficulty, category=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: pick_word_by_difficulty_and_category. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: difficulty

Please provide type hint for the parameter: category

return random.choice(pool)


def celebratory_art():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: celebratory_art. If the function does not return a value, please provide the type hint as: def function() -> None:

save_stats(stats)


def main_menu():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: main_menu. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 21, 2025
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 21, 2025
Refactor Word Scramble game code to improve type hints and fix minor formatting issues.
@algorithms-keeper algorithms-keeper bot removed require descriptive names This PR needs descriptive function and/or variable names require type hints https://docs.python.org/3/library/typing.html labels Oct 21, 2025
Copy link
Author

@MahyudeenShahid MahyudeenShahid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix remaining lint/type issues

@cclauss
Copy link
Member

cclauss commented Oct 21, 2025

Please read the definition of an algorithm in CONTRIBUTING.md. This repo does to do games, we do algorithms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants