Submitted by: Mohammad Sajid Anwar
You are given an array of sentences.
Write a script to return the maximum number of words that appear in a single sentence.
Input: @sentences = ("Hello world", "This is a test", "Perl is great")
Output: 4
Input: @sentences = ("Single")
Output: 1
Input: @sentences = ("Short", "This sentence has six words in total", "A B C", "Just four words here")
Output: 6
Input: @sentences = ("One", "Two parts", "Three part phrase", "")
Output: 3
Input: @sentences = ("The quick brown fox jumps over the lazy dog", "A", "She sells seashells by the seashore", "To be or not to be that is the question")
Output: 10
Submitted by: Mohammad Sajid Anwar
You are given three arrays, @codes, @names and @status.
Write a script to validate codes in the given array.
A code is valid when the following conditions are true:
- codes[i] is non-empty and consists only of alphanumeric characters (a-z, A-Z, 0-9) and underscores (_).
- names[i] is one of the following four categories: "electronics", "grocery", "pharmacy", "restaurant".
- status[i] is true.
Return an array of the codes of all valid coupons, sorted first by their names in the order
Input: @codes = ("A123", "B_456", "C789", "D@1", "E123")
@names = ("electronics", "restaurant", "electronics", "pharmacy", "grocery")
@status = ("true", "false", "true", "true", "true")
Output: ("A123", "C789", "E123")
Input: @codes = ("Z_9", "AB_12", "G01", "X99", "test")
@names = ("pharmacy", "electronics", "grocery", "electronics", "unknown")
@status = ("true", "true", "false", "true", "true")
Output: ("AB_12", "X99", "Z_9")
Input: @codes = ("_123", "123", "", "Coupon_A", "Alpha")
@names = ("restaurant", "electronics", "electronics", "pharmacy", "grocery")
@status = ("true", "true", "false", "true", "true")
Output: ("123", "Alpha", "Coupon_A", "_123")
Input: @codes = ("ITEM_1", "ITEM_2", "ITEM_3", "ITEM_4")
@names = ("electronics", "electronics", "grocery", "grocery")
@status = ("true", "true", "true", "true")
Output: ("ITEM_1", "ITEM_2", "ITEM_3", "ITEM_4")
Input: @codes = ("CAFE_X", "ELEC_100", "FOOD_1", "DRUG_A", "ELEC_99")
@names = ("restaurant", "electronics", "grocery", "pharmacy", "electronics")
@status = ("true", "true", "true", "true", "false")
Output: ("ELEC_100", "FOOD_1", "DRUG_A", "CAFE_X")
Last date to submit the solution 23:59 (UK Time) Sunday 28th December 2025.