Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Agent Instructions for TheAlgorithms/Python

## Objective

Fix the bug in `other/password.py` (Issue #15633).

## Rules (Based on CONTRIBUTING.md and AGENTS.md)

1. **Code Style:** Use Python 3.15+, descriptive variable names, and type hints.
2. **Doctests:** Every modified function must have doctests.
3. **Exceptions:** Raise `ValueError` for invalid inputs.
4. **PR Requirements:** You must check at least one box in the PR template.
5. **Scope:** Only change one algorithm file. Do not update README.md or DIRECTORY.md.

## Task Instructions

1. Fork the repository and create a new branch.
2. Edit `other/password.py` to add a `ValueError` guard in `alternative_password_generator`.
3. Run `python -m doctest -v other/password.py` to ensure tests pass.
4. Submit a PR with the description "Fixes #15633".
21 changes: 19 additions & 2 deletions other/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,31 @@
# chars_incl= characters that must be in password
# i= how many letters or characters the password length will be
def alternative_password_generator(chars_incl: str, i: int) -> str:
"""
Generate a password that includes the required characters and has a total length of i.

Check failure on line 30 in other/password.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E501)

other/password.py:30:89: E501 Line too long (90 > 88)
>>> len(alternative_password_generator("abcdefgh", 8))
8
>>> len(alternative_password_generator("abcdefgh", 5))
Traceback (most recent call last):
...
ValueError: Requested length must be at least the number of required characters.
>>> len(alternative_password_generator("abc", 3))
3
"""
# Password Generator = full boot with random_number, random_letters, and
# random_character FUNCTIONS
# Put your code here...
# chars = chars_incl + random_letters(ascii_letters, i / 3 + remainder) +
# random_number(digits, i / 3) + random_characters(punctuation, i / 3)
if i < len(chars_incl):
raise ValueError(
"Requested length must be at least the number of required characters."
)

i -= len(chars_incl)
quotient = i // 3
remainder = i % 3
# chars = chars_incl + random_letters(ascii_letters, i / 3 + remainder) +
# random_number(digits, i / 3) + random_characters(punctuation, i / 3)

chars = (
chars_incl
+ random(ascii_letters, quotient + remainder)
Expand Down
Loading