Robbie Hatley's Solutions To The Weekly Challenge #267
For those not familiar with "The Weekly Challenge", it is a weekly programming puzzle with two parts, cycling every Sunday. You can find it here: The Weekly Challenge This week (2024-04-28 through 2024-05-04) is weekly challenge #267. Its tasks are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 267-1: Product Sign Submitted by: Mohammad Sajid Anwar You are given an array of @ints. Write a script to find the sign of the product of all integers in the given array. The sign is 1 if the product is positive, -1 if the product is negative, and 0 if product is zero. Example 1 input: [-1, -2, -3, -4, 3, 2, 1] Expected output: 1 Example 2 input: [1, 2, 0, -2, -1] Expected output: 0 Example 3 input: [-1, -1, 1, -1, 2] Expected output: -1 The sign of the product is the product of the signs, and sign(x) is given by "0 if x is 0, else x/abs(x)". So these subs should work: use v5.36; use List::Util 'product'; su...