Find Pattern in String (retired)
Description:
Your task is to determine, whether a string contains a given pattern or not.
The pattern's letters in a string can be alternated by any number of other letters and/or duplicated any number
of times. The string is valid if all letters from the pattern are present, and their sequence is preserved.
Examples:
Pattern: codewars
String: cccxxfoovbfffooddwqerdddeeuwrwrreqwwbnmjwwayaqrrarrs
ccc
xxfoo
vbfffood
dwqe
rdddeeuwrw
rreqwwbnmjwwa
yaqr
rarrs
VALID
String: cccxxfeevbfffooddwqordddoouwrwrroqwwbnmjwwayaqrrarrs
ccc
xxfe
evbfffo
od
dw
qor
dddoouwrwrroqwwbnmjwwa
yaqrrarrs
INVALID, wrong sequence
String: cooddwwwwwwaaaaarrrrsss
INVALID, 'e' is missing.
Write a function pattern_in_string
, which takes pattern and string as arguments and returns 'FOUND'
if the patern was found, or 'NOT FOUND' otherwise. Apart from the sample test cases, you will not know
neither pattern nor string, so you need to come up with some general algorithm. Strings in performance tests
are 60k - 240k letters long, so it must be quite efficient, too.
Length of a pattern can be 3 - 10, and letters may repeat.
Both strings and patterns will contain only lower case English letters.
HAVE FUN!
Similar Kata:
Stats:
Created | Jul 5, 2020 |
Warriors Trained | 19 |
Total Skips | 0 |
Total Code Submissions | 289 |
Total Times Completed | 13 |
Python Completions | 13 |
Total Stars | 0 |
% of votes with a positive feedback rating | 29% of 12 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 7 |
Total Rank Assessments | 12 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |