Posts

Showing posts from April, 2024

Robbie Hatley's Solutions To The Weekly Challenge #266

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-21 through 2024-04-27) is weekly challenge #266. Its tasks are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 266-1: Uncommon Words Submitted by: Mohammad Sajid Anwar You are given two sentences, $line1 and $line2. Write a script to find all "uncommmon" words in any order in the given two sentences, or return ('') if none are found. A word is "uncommon" if it appears exactly once in one of the sentences and doesn’t appear in other sentence. Example 1: Input: $line1 = 'Mango is sweet' $line2 = 'Mango is sour' Output: ('sweet', 'sour') Example 2: Input: $line1 = 'Mango Mango' $line2 = 'Orange' Output: ('Orange') Example 3: Input: $line1 = 'Mango is Ma

Robbie Hatley's Solutions To The Weekly Challenge #265

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-14 through 2024-04-20) is weekly challenge #265. Its tasks are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 265-1: 33% Appearance Submitted by: Mohammad Sajid Anwar You are given an array of integers, @ints. Write a script to find an integer in the given array that appeared 33% or more. If more than one found, return the smallest. If none found, then return undef. Example 1: Input: @ints = (1,2,3,3,3,3,4,2) Output: 3 1 appeared 1 times. 2 appeared 2 times. 3 appeared 4 times. 3 appeared 50% (>33%) in the given array. Example 2: Input: @ints = (1,1) Output: 1 1 appeared 2 times. 1 appeared 100% (>33%) in the given array. Example 3: Input: @ints = (1,2,3) Output: 1 1 appeared 1 times. 2 appeared 1 times. 3 appeared 1 times. Since all three app

Robbie Hatley's Solutions To The Weekly Challenge #264

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-07 through 2024-04-13) is weekly challenge #264. Its tasks are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 264-1: Greatest English Letter Submitted by: Mohammad Sajid Anwar You are given a string, $str, made up of only alphabetic characters [a..zA..Z]. Write a script to return the greatest english letter in the given string. (A letter is "greatest" if it occurs as lower and upper case. Also letter ‘b’ is greater than ‘a’ if ‘b’ appears after ‘a’ in the English alphabet. Example 1: Input: $str = 'PeRlwEeKLy' Output: L There are two letters E and L that appears as lower and upper. The letter L appears after E, so the L is the greatest english letter. Example 2: Input: $str = 'ChaLlenge' Output: L Example 3: Input: $str = &

Robbie Hatley's Solutions To The Weekly Challenge #263

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-03-31 through 2024-04-06) is weekly challenge #263. Its tasks are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 263-1: Target Index Submitted by: Mohammad Sajid Anwar You are given an array of integers @ints and a target element $k. Write a script to return the list of indices in the sorted array where the element is same as the given target element. Example 1: Input: @ints = (1, 5, 3, 2, 4, 2), $k = 2 Output: (1, 2) Sorted array: (1, 2, 2, 3, 4, 5) Target indices: (1, 2) as $ints[1] = 2 and $ints[2] = 2 Example 2: Input: @ints = (1, 2, 4, 3, 5), $k = 6 Output: () No element in the given array matching the given target. Example 3: Input: @ints = (5, 3, 2, 4, 2, 1), $k = 4 Output: (4) Sorted array: (1, 2, 2, 3, 4, 5) Target index: (4) as $ints[4] = 4