Skip to content

Instantly share code, notes, and snippets.

@manwar
Last active July 18, 2024 21:59
Show Gist options
  • Save manwar/869986761714ecafdb830fe27341be18 to your computer and use it in GitHub Desktop.
Save manwar/869986761714ecafdb830fe27341be18 to your computer and use it in GitHub Desktop.
The Weekly Challenge - 280.

The Weekly Challenge - 280

Early Bird Club members ONLY

Task 1: Twice Appearance

Submitted by: Mohammad Sajid Anwar

You are given a string, $str, containing lowercase English letters only.

Write a script to print the first letter that appears twice.

Example 1

Input: $str = "acbddbca"
Output: "d"

Example 2

Input: $str = "abccd"
Output: "c"

Example 3

Input: $str = "abcdabbb"
Output: "a"

Task 2: Count Asterisks

Submitted by: Mohammad Sajid Anwar

You are given a string, $str, where every two consecutive vertical bars are grouped into a pair.

Write a script to return the number of asterisks, *, excluding any between each pair of vertical bars.

Example 1

Input: $str = "p|*e*rl|w**e|*ekly|"
Ouput: 2

The characters we are looking here are "p" and "w**e".

Example 2

Input: $str = "perl"
Ouput: 0

Example 3

Input: $str = "th|ewe|e**|k|l***ych|alleng|e"
Ouput: 5

The characters we are looking here are "th", "e**", "l***ych" and "e".


Last date to submit the solution 23:59 (UK Time) Sunday 4th August 2024.


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