Skip to content

Missing Edge Case for odd_even_transposition_parallel.py #10925

Closed

Description

@RaymondDashWu

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]

Activity

  1. ufraaan commented on Oct 25, 2023

    @ufraaan

    maybe try

    sorted_lst = sorted(lst)
    print(sorted_lst)

  2. RaymondDashWu commented on Oct 25, 2023

    @RaymondDashWu
    ContributorAuthor

    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.

  3. RaymondDashWu commented on Oct 25, 2023

    @RaymondDashWu
    ContributorAuthor

    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?

  4. bhavesh1oo commented on Oct 25, 2023

    @bhavesh1oo
    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

  5. hoarffrost commented on Oct 25, 2023

    @hoarffrost

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

  6. RaymondDashWu commented on Oct 25, 2023

    @RaymondDashWu
    ContributorAuthor

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

  7. hoarffrost commented on Oct 26, 2023

    @hoarffrost

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

  8. RaymondDashWu commented on Oct 26, 2023

    @RaymondDashWu
    ContributorAuthor

    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.

  9. RaymondDashWu commented on Oct 27, 2023

    @RaymondDashWu
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions