The Wayback Machine - https://web.archive.org/web/20250620194054/https://github.com/TheAlgorithms/Python/pull/3643
Skip to content

HacktoberFest: Added a solution for Project Euler problem_024 #3643

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

Closed
wants to merge 8 commits into from

Conversation

GantaChaitra
Copy link

@GantaChaitra GantaChaitra commented Oct 22, 2020

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
@GantaChaitra
Copy link
Author

Hey can you please help me out ! .. I am a beginner and I am not understanding how to fix this ..

@poyea
Copy link
Member

poyea commented Oct 23, 2020

Thanks for submitting. Please follow the instruction in project_euler. There's a readme on the requirement for parameters.

@@ -0,0 +1,35 @@
"""A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this line:
project_euler/problem_024/sol2.py:1:89: E501 line too long (280 > 88 characters)

"""A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:

012 021 102 120 201 210
What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this line too:
project_euler/problem_024/sol2.py:4:89: E501 line too long (94 > 88 characters)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @poyea !!

"""A permutation is an ordered arrangement of objects.
For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4.
If all of the permutations are listed numerically or alphabetically
, we call it lexicographic order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better put the comma to the previous line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay !

Comment on lines 28 to 42
"""
Output: $ python3 -m doctest -v sol2.py
Trying:
solution()
Expecting:
'2783915460'
ok
1 items had no tests:
sol2
1 items passed all tests:
1 tests in sol2.solution
1 tests in 2 items.
1 passed and 0 failed.
Test passed.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not very necessary

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure , i will remove those lines :)

>>> solution()
'2783915460'
"""
lexi_perm = "".join(list(permutations("0123456789"))[999999])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make 999999 as the default parameter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont want to add one more line of code

from itertools import permutations


def solution():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some type hints.

@stale
Copy link

stale bot commented Nov 23, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Nov 23, 2020
@stale stale bot removed the stale Used to mark an issue or pull request stale. label Nov 27, 2020
@ghost ghost added the awaiting reviews This PR is ready to be reviewed label Nov 27, 2020
@GantaChaitra
Copy link
Author

Hey ... I will change code and push it again after adding some type hints .

@dhruvmanila
Copy link
Member

Hey, thank you for your contribution but we're not accepting solutions to existing problems, maybe try solving a problem that doesn't exist in the directory? Thank you for your cooperation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed
4 participants