PWC 184
PWC 184 Both the tasks for this week have narrowly defined input requirements. I don't write a function to handle them. I want to avoid input validation and error handling chores, and any self-respecting function needs both. I present throwaway scripts or one-liners with the inputs explicitly written into the script or ARGV. Challenge 1 (Sequence number) We are given a list of strings, each one formatted as two lower-case alphabets (/[a-z]/) followed by 4 numeric characters (/[0-9/), e.g., ('ab1234', 'cd5678', 'ef1342'). We are asked to replace the starting alphabets with a two-digit string of numbers indicating their position in the list starting with zero, e.g., ('001234', '015678', '021342'). I do this with one-liners in Perl 5, Raku and Julia. Perl 5: perl -e ' my $ctr=0; for my $x ("00" .. "99") {print $x . substr($ARGV[$ctr++],2,4) . " "; last if $ctr >= @ARGV;} print "\n"; '