Title: R23-T055: Add extended_euclid trace and non-coprime doctests to chinese_remainder_theorem by code-paul-creator · Pull Request #65 · S-AI-Projects/TheAlgorithms-Python · GitHub
Open Graph Title: R23-T055: Add extended_euclid trace and non-coprime doctests to chinese_remainder_theorem by code-paul-creator · Pull Request #65 · S-AI-Projects/TheAlgorithms-Python
X Title: R23-T055: Add extended_euclid trace and non-coprime doctests to chinese_remainder_theorem by code-paul-creator · Pull Request #65 · S-AI-Projects/TheAlgorithms-Python
Description: Description Traces extended_euclid(10, 6) and chinese_remainder_theorem(5, 1, 7, 3) step by step (by hand and with pdb) and turns the observations into doctests: intermediate results of the recursion, the gcd identity, and the documented behaviour for non-coprime moduli. Related Issue Fixes: #55 Type of Change Bug Fix New Feature UI/UX Improvement Performance Improvement Tests Documentation Refactoring / Maintenance CI/CD Changes Made Added doctests to extended_euclid: intermediate results (2,0)->(1,0), (4,2)->(0,1), (6,4)->(1,-1), the identity ax + by == gcd (2 for (10, 6)), and the a < b swap case (5, 7). Added doctests to chinese_remainder_theorem: the result satisfies both congruences for coprime moduli, and a non-coprime input (6, 1, 4, 3) documented as unsupported. Existing 8 doctests unchanged (21 total). Added work/R23-T055/TRACE.md (tables of both traces, pdb steps, the surprise) and trace_driver.py. Screenshots / Recordings Testing python -m pytest --doctest-modules maths/chinese_remainder_theorem.py -> passed (21 doctests) ruff check maths/chinese_remainder_theorem.py -> all checks passed pdb traces recorded in work/R23-T055/TRACE.md and checked by hand Checklist I have tested my changes locally. I have added or updated tests, if needed. I have updated documentation, if needed. I have followed the project's coding guidelines. I have run the relevant tests and checks. I have addressed previous review feedback, if applicable. Additional Notes Finding: the existing doctest chinese_remainder_theorem(6, 1, 4, 3) -> 14 passes but 14 is not a valid solution (14 % 6 = 2, 14 % 4 = 2). 6 and 4 are not coprime, so extended_euclid(6, 4) gives ax + by = 2 instead of 1 and the formula breaks silently. A valid answer exists (7, modulo 12). Not fixed here (doctests only); documented in the new doctests and in work/R23-T055/TRACE.md. A follow-up could raise ValueError when gcd(n1, n2) != 1.
Open Graph Description: Description Traces extended_euclid(10, 6) and chinese_remainder_theorem(5, 1, 7, 3) step by step (by hand and with pdb) and turns the observations into doctests: intermediate results of the recursi...
X Description: Description Traces extended_euclid(10, 6) and chinese_remainder_theorem(5, 1, 7, 3) step by step (by hand and with pdb) and turns the observations into doctests: intermediate results of the recursi...
Opengraph URL: https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/65
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0138bea1-9881-7285-4289-7a0c65092a59 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E8D8:22B798:8B7AF:C5AC3:6AFDF925 |
| html-safe-nonce | a2c5a383f27106eda86ec59253bf9a94987d0fded108d4f84ece473ca192235c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEQ4OjIyQjc5ODo4QjdBRjpDNUFDMzo2QUZERjkyNSIsInZpc2l0b3JfaWQiOiIyNDk3ODgzODQ4MzMwNDI3MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c15a89204fbe586578cdeb8b5d28979be6158c82aae71d32cd688c2a98522cb4 |
| hovercard-subject-tag | pull_request:5254567176 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/65/files |
| twitter:image | https://avatars.githubusercontent.com/u/260575160?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/260575160?s=400&v=4 |
| og:image:alt | Description Traces extended_euclid(10, 6) and chinese_remainder_theorem(5, 1, 7, 3) step by step (by hand and with pdb) and turns the observations into doctests: intermediate results of the recursi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ee3343385a977757dd145b28fabf4a119780f2615a5a36c5a89f66c9b3b5616d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/S-AI-Projects/TheAlgorithms-Python git https://github.com/S-AI-Projects/TheAlgorithms-Python.git |
| octolytics-dimension-user_id | 351892385 |
| octolytics-dimension-user_login | S-AI-Projects |
| octolytics-dimension-repository_id | 1444141022 |
| octolytics-dimension-repository_nwo | S-AI-Projects/TheAlgorithms-Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 63476337 |
| octolytics-dimension-repository_parent_nwo | TheAlgorithms/Python |
| octolytics-dimension-repository_network_root_id | 63476337 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/Python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 43ae91995f6e2d5ff7a491f3de438f1f723adeaa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width