From ec3eb82c6fbf7b795c2646713b23538127571937 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 18 Apr 2023 20:20:03 +0100 Subject: - Added solutions by Mark Anderson. - Added solutions by Leo Manfredi. - Added solutions by W. Luis Mochan. - Added solutions by Niels van Dijke. - Added solutions by Luca Ferrari. - Added solutions by Laurent Rosenfeld. - Added solutions by Robert DiCicco. --- challenge-213/robert-dicicco/python/ch-1.py | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 challenge-213/robert-dicicco/python/ch-1.py (limited to 'challenge-213/robert-dicicco/python') diff --git a/challenge-213/robert-dicicco/python/ch-1.py b/challenge-213/robert-dicicco/python/ch-1.py new file mode 100644 index 0000000000..75d2a80d93 --- /dev/null +++ b/challenge-213/robert-dicicco/python/ch-1.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +''' +----------------------------------- +AUTHOR: Robert DiCicco +DATE : 2023-04-17 +Challenge 213 Fun Sort ( Python ) +----------------------------------- +''' +import numpy as np + +mylists = [[1,2,3,4,5,6],[1,2],[1]] + +for arr in mylists: + print("Input: @list = ",arr) + evens = np.array([num for num in arr if num % 2 == 0]) + odds = np.array([num for num in arr if num % 2 == 1]) + if (evens.size and odds.size): + combo = np.concatenate((evens,odds)) + print(combo) + else: + print(evens) if evens.size else print(odds) +''' +----------------------------------- +SAMPLE OUTPUT + python .\FunSort.py +Input: @list = [1, 2, 3, 4, 5, 6] +[2 4 6 1 3 5] +Input: @list = [1, 2] +[2 1] +Input: @list = [1] +[1] +----------------------------------- +''' + + -- cgit