Skip to content

Instantly share code, notes, and snippets.

@manwar
Last active April 2, 2025 14:19
Show Gist options
  • Save manwar/9a1f0f3a274b391ea670f54dc13fc8f2 to your computer and use it in GitHub Desktop.
Save manwar/9a1f0f3a274b391ea670f54dc13fc8f2 to your computer and use it in GitHub Desktop.
The Weekly Challenge - 318

The Weekly Challenge - 318

Early Bird Club members ONLY

Task 1: Group Position

Submitted by: Mohammad Sajid Anwar

You are given a string of lowercase letters.

Write a script to find the position of all groups in the given string. Three or more consecutive letters form a group. Return "" if none found.


Example 1

Input: $str = "abccccd"
Output: "cccc"

Example 2

Input: $str = "aaabcddddeefff"
Output: "aaa", "dddd", "fff"

Example 3

Input: $str = "abcdd"
Output: ""

Task 2: Reverse Equals

Submitted by: Roger Bell_West

You are given two arrays of integers, each containing the same elements as the other.

Write a script to return true if one array can be made to equal the other by reversing exactly one contiguous subarray.


Example 1

Input: @source = (3, 2, 1, 4)
       @target = (1, 2, 3, 4)
Output: true

Reverse elements: 0-2

Example 2

Input: @source = (1, 3, 4)
       @target = (4, 1, 3)
Output: false

Example 3

Input: @source = (2)
       @target = (2)
Output: true


Last date to submit the solution 23:59 (UK Time) Sunday 27th April 2025.


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