This question already has an answer here:
- Is string X a subsequence of string Y? 50 answers
The Typical Way to Make an Acronym Out of a Phrase Is to Take the First Letter of Each Word:
TTWMAOPITFLEW. howeveR, sometimEs, you can make an acronym of random leTters In a seNtence such As like this:
RETINA. The only condition is that the letters have to be in the correct order. For instance:
LORDcan be acronymised from
LEODcannot be acronymised from
Hello World, as no
ls are before
Your task is to take two strings as input as to determine if one can be acronymised into the other.
The first input, the phrase, will only contain letters (
a-z) and spaces, and the second input, the acronym, will only contain letters (
a-z). The acronym will always be shorter, or of equal size, to the phrase, and both the acronym and the phrase will be, at minimum, 1 letter long. You may choose which case (upper or lower) you want the inputs to be.
You may choose any two values to represent
false, as long as those values are consistent.
This is code-golf so the shortest code in bytes wins
HELLO WORLD, LORD -> true CODE GOLF AND CODING CHALLENGES, DANGLE -> true SANDBOX FOR PROPOSED CHALLENGES, CODE -> false HELLO WORLD, LLLD -> true HELLO WORLD, LLDL -> false NEW YORK POLICE DEPARTMENT, NOODLE -> false MASSACHUSETTS INSTITUTE OF TECHNOLOGY, MUTTON -> true BOB, BOB -> true PRESIDENT OF THE UNITED STATES, I -> true