Posts

Showing posts from February, 2024

Robbie Hatley's Solutions To The Weekly Challenge #258

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-02-25 through 2024-03-02) is weekly challenge #258. Its tasks are as follows: Task 258-1: Count Even Digits Number Submitted by: Mohammad Sajid Anwar You are given a array of positive integers, @ints. Write a script to find out how many integers have even number of digits. Example 1: Input: @ints = (10, 1, 111, 24, 1000) Output: 3 There are 3 integers having even digits i.e. 10, 24 and 1000. Example 2: Input: @ints = (111, 1, 11111) Output: 0 Example 3: Input: @ints = (2, 8, 1024, 256) Output: 1 I'm "traveling light" this week, so my solutions for 258-1 and 258-2 are about 50 times shorter than the programs I normally write for The Weekly Challenge. My solution for 258-1 is especially short; it uses "grep" to filter @ARGV for numbers with an even number of digi...

Robbie Hatley's Solutions To The Weekly Challenge #256

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-02-11 through 2024-02-17) is weekly challenge #256. Its tasks are as follows: Task 256-1: Maximum Pairs Submitted by: Mohammad Sajid Anwar You are given an array of distinct words, @words. Write a script to find the maximum pairs in the given array. The words $words[i] and $words[j] can be a "pair" if one is reverse of the other. Example 1: Input: @words = ("ab", "de", "ed", "bc") Output: 1 There is one pair in the given array: "de" and "ed" Example 2: Input: @words = ("aa", "ba", "cd", "ed") Output: 0 Example 3: Input: @words = ("uv", "qp", "st", "vu", "mn", "pq") Output: 2 This problem is easily solved using a nested...

Robbie Hatley's Solutions To The Weekly Challenge #255

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-02-04 through 2024-02-10) is weekly challenge #255. Its tasks are as follows: Task 255-1: Odd Character Submitted by: Mohammad Sajid Anwar You are given two strings, $s and $t. The string $t is generated using the shuffled characters of the string $s with an additional character. Write a script to find the additional character in the string $t. Example 1: Input: $s = "Perl" $t = "Preel" Output: "e" Example 2: Input: $s = "Weekly" $t = "Weeakly" Output: "a" Example 3: Input: $s = "Box" $t = "Boxy" Output: "y" Since this problem speaks of "characters" instead of "letters", I'll consider "a" and "A" to be different "characters", and use a case-se...