aboutsummaryrefslogtreecommitdiff
path: root/challenge-213/manfredi/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2023-04-18 19:00:15 +0100
committerGitHub <noreply@github.com>2023-04-18 19:00:15 +0100
commitab171f3e67db1a665c6170d9f38b0950e80c16a6 (patch)
tree6c2d619a1150e8e1deb033a19f2330b1ec03f26d /challenge-213/manfredi/python/ch-1.py
parentde2186a2d7c9f9a7d7732abf8ed6eed63dfc641c (diff)
parentf1186e64cbf6f59757c30790db1d787fd1efc06a (diff)
downloadperlweeklychallenge-club-ab171f3e67db1a665c6170d9f38b0950e80c16a6.tar.gz
perlweeklychallenge-club-ab171f3e67db1a665c6170d9f38b0950e80c16a6.tar.bz2
perlweeklychallenge-club-ab171f3e67db1a665c6170d9f38b0950e80c16a6.zip
Merge pull request #7922 from manfredi/challenge-213
Perl Solution for Task #1
Diffstat (limited to 'challenge-213/manfredi/python/ch-1.py')
-rwxr-xr-xchallenge-213/manfredi/python/ch-1.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-213/manfredi/python/ch-1.py b/challenge-213/manfredi/python/ch-1.py
new file mode 100755
index 0000000000..25a1e70ea3
--- /dev/null
+++ b/challenge-213/manfredi/python/ch-1.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# Python 3.9.2 on Debian GNU/Linux 11 (bullseye)
+
+print('challenge-213-task1')
+
+# Task 1: Fun Sort
+# You are given a list of positive integers.
+# Write a script to sort the all even integers first then all odds in ascending order.
+
+def fun_sort(items: list[int]) -> list[int]:
+ items.sort()
+ out_even = [item for item in items if not item % 2 ]
+ out_odd = [item for item in items if item % 2 ]
+ out_even.extend(out_odd)
+ return out_even
+
+def main():
+ print(fun_sort([3, 6, 1, 4, 5, 2]))
+ print(fun_sort([1, 2]))
+ print(fun_sort([1]))
+
+
+if __name__ == '__main__':
+ main()