Created
September 11, 2023 14:29
-
-
Save athursto/6651d37929c492ad9079585e3f75abc6 to your computer and use it in GitHub Desktop.
Casidoo 9.11.23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""9.11.2023""" | |
"""This week's question: Given an array of integers, sort them into two separate sorted arrays of even and odd numbers. | |
If you see a zero, skip it.""" | |
def separate_and_sort(array): | |
zeros_out = [num for num in array if num!= 0] | |
zeros_out.sort() | |
even_list, odd_list = [num for num in zeros_out if num % 2 == 0], [num for num in zeros_out if num % 2 != 0] | |
return even_list, odd_list | |
test_array_2 = [4,3,2,1,5,7,8,9] | |
print(separate_and_sort(test_array_2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment