### PWC 218

PWC 218 Challenge 1 (Maximum Product) We are given a list of integers, which can include negative integers and zero as well as positive integers. We are asked to find the product of any three elements of the list which is the highest of any product so formed. It is stipulated that the list must have at least three elements. To solve, I sort the list in numeric order. Then the maximum product is given by one of the following: The product of the lowest two elements and the maximum element. This is if the lowest two elements are both negative (so that their product is positive). The product of the highest three elements. Here is the core subroutine: use List::Util qw(max); local *maximum_product = sub { local *myprod=sub { $_[0]*$_[1]*$_[2]; }; #-- main part of &maximum_product my @list = sort {$a <=> $b} @_; (scalar(@list) < 2) && (die "Need at least 3 elements in input"); max( &myprod( $list[0], $list[