Performance and Refactor: 83% - 86% faster Project Euler 104 #10615
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your change:
Related Issue #8594
Feedback is welcome and greatly appreciated!
Refactored is_pandigital_both()
check()->is_pandigital_both()is_pandigital_endandis_pandigital_startto check both sides of the given numberAdded is_pandigital_start()
Refactored is_pandigital_end()
check1()->is_pandigital_end()check_last->digit_countdigit_countfrom11 -> 10second for loop->all()because of ruff error SIM110fis removedRefactored
solution()slow_solution()a: int, b: int, ck: int, max_k: inta, b, c->fk_2, fk_1, fkbecausefkis k'th fibonacci number,fk_2 = f(k-2)etc.a1, b1, c1->mk_2, mk_1, mkbecausemk_2 = f(k-2) % billionetc.m->billiontocheck->end_pandigitalx->krange(1_000_000)->range(3, 1_000_000)andtocheck[x + 3]->end_pandigital[k]Updated docstrings
Added 83% - 86% performance improvement
Checklist: