PWC 235
PWC 235 I tried to restrict to Perl 4 syntax for both challenges this week, as documented in Rex Swain's Perl 4 reference or the 1st edition of Programming perl. I do use nested subroutines, which I am not sure would actually work in Perl 4, though they comply with the syntax. My programs are tested on Perl 5.38. (The -l in the shebang line works only in Perl 5. The Perl 4 equivalent was -L012 [in Unix], which is no longer available.) My solutions to this week's challenges highlight the usefulness of the splice array operator. Challenge 1 (Remove One) We are given an array of integers and asked to verify if removing any one element will leave the remaining elements in monotonically ascending order. A helper sub-subroutine &ascending checks if a particular array is in ascending order, by comparing it element-by-element to its sorted version. Here it is: local *ascending = sub { local @ascending=(sort {$a <=> $b} @_); foreach (0 .. $#_) {($_[