Repository navigation
Description
Student: Paulami Bhosle
Task: R23-T059 · 9 of 10
Repository: https://github.com/S-AI-Projects/TheAlgorithms-Python
Assigned working branch: student/e26b07f0792
Goal
Check the algorithm's real running time against its theoretical complexity. Expected attempts grow ×16 per extra leading hex zero – measure attempts and time for difficulty 1–5.
Steps
- State the expected time complexity with a short derivation.
- Write work/R23-T059/bench.py timing the main function with
timeitfor at least 6 input sizes (doubling). - Plot time vs n (matplotlib) and compare with the expected curve.
- Add the complexity, with your evidence, to the function's docstring.
- Make the code change in the repository: blockchain/simple_proof_of_work.py: expected-attempts complexity (16^difficulty) in the docstring, backed by your measurements. Re-run the automated check and the repo's own tests afterwards.
- Prepare the PR: on branch R23-T059, commit the code change plus your work/R23-T059/ evidence, put your findings in the PR description and open the PR against the org fork. For a later upstream PR, create a second branch containing only the code change (no work/ folder).
Done when
☐ bench.py measures attempts and time for difficulty 1–5 (at least 20 runs each), showing ≈16× growth per level.
☐ blockchain/simple_proof_of_work.py docstring states the expected 16^difficulty attempts, matching the measurements.
☐ Existing 7 doctests and the negative-difficulty raise are unchanged.
Additional task guidance
Additional curated task guidance
Item:
blockchain/simple_proof_of_work.py (62 lines; 7 doctests)
Task type:
Measure complexity
Code change (goes into the PR):
blockchain/simple_proof_of_work.py: expected-attempts complexity (16^difficulty) in the docstring, backed by your measurements.
Automated check:
uv run python work/R23-T059/bench.py && uv run pytest blockchain/simple_proof_of_work.py
Prerequisites:
Linux/WSL2/Codespaces with uv (https://docs.astral.sh/uv/getting-started/installation/); run uv sync --group=test once – it installs the Python version CI uses (.python-version = 3.15t) and the test dependencies, about 1–2 GB
Upstream PR rules:
Follow CONTRIBUTING.md: type hints on every parameter/return, doctests for valid and erroneous input, snake_case file names, no duplicate of an existing implementation, no hand edits to DIRECTORY.md. CI (pytest with doctests, ruff) must pass – bots close PRs without tests or type hints. Keep work/ (benchmarks, notes, property tests) out of the upstream branch; put results in the PR description.
Source (pinned):
https://github.com/TheAlgorithms/Python/blob/574d100b7181956e9c8384552fd078165e4cc326/blockchain/simple_proof_of_work.py
Change:
No change recorded
PR destination:
Preserved pilot guidance
Submission checklist
- Complete this task and its checks.
- Add the required evidence and link your pull request here.
- Select this S-AI-Projects fork as the PR base repository.
- Request instructor review.
Keep this PR focused on this task. Do not submit assignment PRs to the upstream repository.
Activity