Performance and Refactor: 83% - 86% faster Project Euler 104#10615
Closed
ManpreetXSingh wants to merge 11 commits intoTheAlgorithms:masterfrom
ManpreetXSingh:refactor-project-euler-104
Closed
Performance and Refactor: 83% - 86% faster Project Euler 104#10615ManpreetXSingh wants to merge 11 commits intoTheAlgorithms:masterfrom ManpreetXSingh:refactor-project-euler-104
ManpreetXSingh wants to merge 11 commits intoTheAlgorithms:masterfrom
ManpreetXSingh:refactor-project-euler-104
Conversation
Renamed check_last -> digit_count Removed redundant element from digit_count Removed redundant flag variable
Algorithm remains the same, only variables are renamed # Variable names: a, b, c -> fk_2, fk_1, fk # fk for k'th Fibonacci number a1, b1. c1 -> mk_2, mk_1, mk to_check -> end_pandigital m -> billion x -> k # k as in fk and mk
10 tasks
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: