-
-
Notifications
You must be signed in to change notification settings - Fork 43.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance and Refactor: 83% - 86% faster Project Euler 104 #10615
Open
ManpreetXSingh
wants to merge
11
commits into
TheAlgorithms:master
Choose a base branch
from
ManpreetXSingh:refactor-project-euler-104
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Performance and Refactor: 83% - 86% faster Project Euler 104 #10615
ManpreetXSingh
wants to merge
11
commits into
TheAlgorithms:master
from
ManpreetXSingh:refactor-project-euler-104
Conversation
This file contains 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
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
algorithms-keeper
bot
added
awaiting reviews
This PR is ready to be reviewed
enhancement
This PR modified some existing files
labels
Oct 18, 2023
ManpreetXSingh
changed the title
Refactor project euler 104
Performance and Refactor: 83% - 86% faster Project Euler 104
Oct 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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_end
andis_pandigital_start
to check both sides of the given numberAdded is_pandigital_start()
Refactored is_pandigital_end()
check1()
->is_pandigital_end()
check_last
->digit_count
digit_count
from11 -> 10
second for loop
->all()
because of ruff error SIM110f
is removedRefactored
solution()slow_solution()a: int, b: int, ck: int, max_k: int
a, b, c
->fk_2, fk_1, fk
becausefk
is k'th fibonacci number,fk_2 = f(k-2)
etc.a1, b1, c1
->mk_2, mk_1, mk
becausemk_2 = f(k-2) % billion
etc.m
->billion
tocheck
->end_pandigital
x
->k
range(1_000_000)
->range(3, 1_000_000)
andtocheck[x + 3]
->end_pandigital[k]
Updated docstrings
Added 83% - 86% performance improvement
Checklist: