Given a string describing a cutting rule and another string, cut parts out of the second string using the rule described by the first string.
Both strings will consist of letters
A-Z, whichever one you choose (they don't have to be represented the same way). The way the second string is to be modified is described below:
Take the first string and imagine filling in the gaps between non-adjacent (increasing) letters with
=; for example,
abc==fg. Then, line up the two strings and return all characters from the first string that aren't above an equal sign. For example, given
qrstuvw as inputs:
qrstuvw - Modify abc==fg - Modifier qrs--vw -> qrsvw
If the modifier is shorter after filling with equal signs, all trailing characters in the second string should be included. If the modifier is longer, the trailing characters are ignored.
The modifier isn't guaranteed to be sorted.
abcfg, qrstuvw -> qrsvw abqrs, qwertyuiopasdfghjklzxcvbnm -> qwjklzxcvbnm za, qr -> qr azazaz, qwertyuioplkjhgfdsazxcvbnmnbvcxzasdfghjklpoiuytrewq -> qmn
Reference Implementation (used to generate test cases) -> TIO
- Standard Loopholes Apply
- You may take input as two strings, two lists of characters, a matrix of characters, etc. (any other reasonable format is acceptable)
- You may output as a string or a list of characters (or some other standard format for strings)
- This is code-golf, so the shortest answer in bytes in each language is declared the winner for its language. No answer will be accepted.
- Either string may be empty.