PWC 197
PWC 197 I did not attempt the challenges in Julia this time. I have solutions in Perl 5 and Raku. Challenge 1 (Move Zero) We are given a list of integers, say (3,0,1,0,5). We are asked to sort the list so that all zeros move to the end, and the remaining items are in their original relative order. In my example, the sorted list would be (3,1,5,0,0). This is a one-liner in Perl 5 and Raku. Perl 5: perl -wl -e ' my @o = sort { ($a == 0) ? 1 : ( ($b == 0) ? -1 : 0 ) } @ARGV; print "@o" ' $@ Raku: raku -e ' say @*ARGS.sort( { ($^a == 0) ?? 1 !! ( ($^b == 0) ?? -1 !! 0 ) } ) ' $@ The logic is via the block argument to sort. This takes two parameters $a and $b representing two elements in the list being compared. If the comparison returns -1, then $a precedes $b in the sorted list. If the comparison returns 1, then $b precedes $a in the sorted list. If the comparison returns 0, then the order doesn't matter. The sort pattern here follows this logic: If both