-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Added solution for Project Euler problem 119 #2931
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
Conversation
33eb596
to
e03214f
Compare
c8f232f
to
77d2401
Compare
project_euler/problem_119/sol1.py
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove both the newlines before the imports :)
You could've directly applied the suggestion but it's up to you.
project_euler/problem_119/sol1.py
Outdated
|
||
def solution() -> int: | ||
""" | ||
Returns the value of a30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please improve on docstring
and add doctest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated docstring and added doctests
project_euler/problem_119/sol1.py
Outdated
powers = [] | ||
for i in range(2, 100): | ||
for j in range(2, 100): | ||
n = int(math.pow(i, j)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a more descriptive variable name than n
?
project_euler/problem_119/sol1.py
Outdated
digi_to_powers = [] | ||
for digit in range(2, 100): | ||
for power in range(2, 100): | ||
digit_to_power = int(math.pow(digit, power)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe number
instead of digit_to_power
and digit_to_powers
instead of digi_to_powers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, sorry for the typo. Fixed it.
Name: Digit power sum Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284. We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum. You are given that a2 = 512 and a10 = 614656. Find a30 Reference: https://projecteuler.net/problem=119 reference: TheAlgorithms#2695
Name: Digit power sum Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284. We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum. You are given that a2 = 512 and a10 = 614656. Find a30 Reference: https://projecteuler.net/problem=119 reference: TheAlgorithms#2695 Co-authored-by: Ravi Kandasamy Sundaram <[email protected]>
Name: Digit power sum Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284. We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum. You are given that a2 = 512 and a10 = 614656. Find a30 Reference: https://projecteuler.net/problem=119 reference: TheAlgorithms#2695 Co-authored-by: Ravi Kandasamy Sundaram <[email protected]>
Name: Digit power sum
Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284.
We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum.
You are given that a2 = 512 and a10 = 614656.
Find a30
Reference: https://projecteuler.net/problem=119
reference: #2695
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.