Skip to content
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

method 2 in quick_sort.md may have a syntax error #23

Open
xlui opened this issue Oct 4, 2017 · 1 comment
Open

method 2 in quick_sort.md may have a syntax error #23

xlui opened this issue Oct 4, 2017 · 1 comment

Comments

@xlui
Copy link

xlui commented Oct 4, 2017

the statement is awesome but there are bugs in the code of method 2

def qsort(L):
    return (qsort([y for y in L[1:] if y <  L[0]]) +
                  L[:1] + 
                  [y for y in L[1:] if y == L[0] + qsort([y for y in L[1:] if y > L[0]]) ) \
                  if len(L) > 1 else L

'[' does not appear in pairs.

maybe you need a ']' after if y == L[0] in line 4.

@xlui
Copy link
Author

xlui commented Oct 4, 2017

And organize too long code in this way may ba more clear

def qsort(L):
    return (qsort([y for y in L[1:] if y <  L[0]]) +
                  L[:1] + 
                  [y for y in L[1:] if y == L[0]] +
                  qsort([y for y in L[1:] if y > L[0]]) ) \
                  if len(L) > 1 else L

just in my opinion 😄

@xlui xlui changed the title method 2 in quick_sort.md may be wrong method 2 in quick_sort.md may have a syntax error Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant