Skip to content

Instantly share code, notes, and snippets.

@manwar
Created May 8, 2026 09:35
Show Gist options
  • Select an option

  • Save manwar/af6c51fbdb673d98c51935bd666767c0 to your computer and use it in GitHub Desktop.

Select an option

Save manwar/af6c51fbdb673d98c51935bd666767c0 to your computer and use it in GitHub Desktop.
The Weekly Challenge - 375

The Weekly Challenge - 375

Early Bird Club members ONLY

Task 1: Single Common Word

Submitted by: Mohammad Sajid Anwar

You are given two array of strings.

Write a script to return the number of strings that appear exactly once in each of the two given arrays. String comparison is case sensitive.

Example 1

Input: @array1 = ("apple", "banana", "cherry")
       @array2 = ("banana", "cherry", "date")
Output: 2

Example 2

Input: @array1 = ("a", "ab", "abc")
       @array2 = ("a", "a", "ab", "abc")
Output: 2

"a" appears once in @array1 but appears twice in @array2, therefore, not counted.

Example 3

Input: @array1 = ("orange", "lemon")
       @array2 = ("grape", "melon")
Output: 0

Example 4

Input: @array1 = ("test", "test", "demo")
       @array2 = ("test", "demo", "demo")
Output: 0

Example 5

Input: @array1 = ("Hello", "world")
       @array2 = ("hello", "world")
Output: 1

String comparison is case sensitive.

Task 2: Find K-Beauty

Submitted by: Mohammad Sajid Anwar

You are given a number and a digit (k).

Write a script to find the K-Beauty of the given number. The K-Beauty of an integer number is defined as the number of substrings of given number when it is read as a string has length of 'k' and is a divisor of given number.

Example 1

Input: $num = 240, $k = 2
Output: 2

Substring with length 2:
24: 240 is divisible by 24
40: 240 is divisible by 40

Example 2

Input: $num = 1020, $k = 2
Output: 3

Substring with length 2:
10: 240 is divisible by 10
02: 240 is divisible by 2
20: 240 is divisible by 20

Example 3

Input: $num = 444, $k = 2
Output: 0

Substring with length 2:
First "44": 444 is not divisible by 44
Second "44": 444 is not divisible by 44

Example 4

Input: $num = 17, $k = 2
Output: 1

Substring with length 2:
17: 17 is divisible by 17

Example 5

Input: $num = 123, $k = 1
Output: 2

Substring with length 1:
1: 123 is divisible by 1
2: 123 is not divisible by 2
3: 123 is divisible by 3

Last date to submit the solution 23:59 (UK Time) Sunday 24th May 2026.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment