Background
A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be interpreted as "stupid pointless annoying mail".
Challenge
Given a string a, and a word t, capitalise the correct letters of the words in a such that they spell out t. You should always move left-to-right through a, and capitalise the first occurrence of each letter.
For example, if a is all the worlds a stage, and t is LAG, then we walk along the letters of all the worlds a stage:
- we look for the first
land capitalise it:aLl the worlds a stage - now we look for the next
a, but it must be after the previously foundl:aLl the worlds A stage - now we look for a
g:aLl the worlds A staGe.
You may assume a will only contain lowercase ASCII letters and spaces.
You may assume t will only contain ASCII letters. You should choose whether t will be input in uppercase or lowercase.
You do not need to handle empty inputs or inputs that have no possible backronymisation.
Test cases
a t output
================================================================
never gonna give you up VIP neVer gonna gIve you uP
all the worlds a stage LAG aLl the worlds A staGe
why WHY WHY
baacbbcca baacbbccba ABC bAacBbCcba
x X X
xxxx X Xxxx
yellow submarine time YEET YEllow submarinE Time
Rules
- You may use any standard I/O method; also, you can use lists of characters or lists of codepoints instead of strings.
- Standard loopholes are forbidden
- This is code-golf, so the shortest code in bytes wins