Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions challenge-213/manfredi/perl/ch-1.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env perl

use v5.36;

say "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.

while (<DATA>) {
chomp;
my @list = sort { $a <=> $b } split /,/;
my @even = grep { ! ($_ % 2) } @list;
my @odd = grep { $_ % 2 } @list;
my @out = (@even, @odd);
print "@out\n";
}


__DATA__
3,6,1,4,5,2
1,2
1
24 changes: 24 additions & 0 deletions challenge-213/manfredi/python/ch-1.py
Original file line number Diff line number Diff line change
@@ -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()