Skip to content

Missing Edge Case for odd_even_transposition_parallel.py #10925

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
RaymondDashWu opened this issue Oct 24, 2023 · 9 comments
Closed

Missing Edge Case for odd_even_transposition_parallel.py #10925

RaymondDashWu opened this issue Oct 24, 2023 · 9 comments
Labels

Comments

@RaymondDashWu
Copy link
Contributor

RaymondDashWu commented Oct 24, 2023

Repository commit

28302db

Python version (python --version)

3.11.6

Dependencies version (pip freeze)

Only default libraries used in this file

Expected behavior

When creating tests for this file I found a bug. Creating a list with 0 to 11 (or higher) in reverse leads to odd behavior. However, creating a list from 0 to 10 and 0 to 5 seems to work.

odd_even_transposition(list(range(11)[::-1])) outputs
[1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10]

Actual behavior

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

@moroii69
Copy link

maybe try

sorted_lst = sorted(lst)
print(sorted_lst)

@RaymondDashWu
Copy link
Contributor Author

Hi @ufraan, I'm not sure what you're referring to. The code you provided would output a sorted list but the error is in the algorithm's implementation.

@RaymondDashWu
Copy link
Contributor Author

It occurs to me that this may be an issue with how M1 Macs handle multiprocessing based on this:

https://stackoverflow.com/questions/65859890/python-multiprocessing-with-m1-mac

Can anyone confirm if odd_even_transposition(list(range(11)[::-1])) works as expected?

@bhavesh1oo
Copy link
Contributor

I ran the odd_even_transposition(list(range(11)[::-1])) test case and it is giving the output
Sorted List

1 0 3 2 5 4 7 6 9 8 10

@hoarffrost
Copy link

Hey, @RaymondDashWu , I just found what is the problem with this algorithm, so can you please assaign me this issue. Thank you...✌️

@RaymondDashWu
Copy link
Contributor Author

Awesome @gyan313 ! Issues aren't assigned in this repo so feel free to just make a PR.

@hoarffrost
Copy link

Hey, @RaymondDashWu , I just opened a pr #10976 , can you review that please❤️...Thanks

@RaymondDashWu
Copy link
Contributor Author

Hey, @RaymondDashWu , I just opened a pr #10976 , can you review that please❤️...Thanks

Ah I didn't realize there was a hard coded range(10) in there. Nice catch! I'm not a maintainer though so I won't be the one merging the PR.

@RaymondDashWu
Copy link
Contributor Author

Marking this as closed since a PR has been made containing the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants