[Question]
  [
Given strings X and Y, determine whether X is a [subsequence](http://en.wikipedia.org/w/index.php?title=Subsequence&oldid=594253998) of Y. The empty string is regarded as a subsequence of every string. (E.g., `''` and `'anna'` are subsequences of `'banana'`.)
### Input
* X, a possibly-empty case-sensitive alphanumeric string
* Y, a possibly-empty case-sensitive alphanumeric string
### Output
* True or False (or equivalents), correctly indicating whether X is a subsequence of Y.
### I/O examples
```
X      Y        output
''     'z00'    True
'z00'  'z00'    True 
'z00'  '00z0'   False
'aa'   'anna'   True
'anna' 'banana' True
'Anna' 'banana' False
```
### Criteria
* The shortest program wins, as determined by the number of bytes of source code.
### Example programs
* Several programs that could be adapted are in this [related posting](https://stackoverflow.com/q/6877249/1033647).
  
[Answer]
# [Perl 5](https://www.perl.org/), 17 bytes (+1?), full program
```
s//.*/g;$_=<>=~$_
```
[Try it online!](https://tio.run/##K0gtyjH9/79YX19PSz/dWiXe1sbOtk4l/v//xLy8RK6kxDwgLOb6l19QkpmfV/xftwAA "Perl 5 – Try It Online")
Invoke with the `p` flag to the perl interpreter, as in `perl -pe 's//.*/g;$_=<>=~$_'`. Per [the established scoring rules when this challenge was originally posted](https://codegolf.meta.stackexchange.com/questions/273/on-interactive-answers-and-other-special-conditions), this flag costs one extra byte. Under [more recent rules](https://codegolf.meta.stackexchange.com/questions/14337/command-line-flags-on-front-ends), AFAICT, it may be free.
Either way, the input strings should be supplied on separate newline-terminated lines on stdin. Output (to stdout) will be `1` if the first input string is a substring of the second, or nothing at all if it's not.
Note that *both* input lines must have a newline at the end, or the program won't work correctly. Alternatively, you can add the `l` command line flag to the invocation to make perl strip the newlines; depending on the scoring rules in effect, this may or may not cost one extra byte. Note that using this flag will also append a newline to the output.
## Original version (snippet, 18 bytes / chars)
```
$x=~s//.*/g,$y=~$x
```
Input is given in the variables `$x` and `$y`, result is the value of the expression (in scalar context). Note that `$x` is modified in the process.
(Yes, I know using `$_` instead of `$x` would let me save four chars, but doing that in a snippet that feels a bit too cheesy for me.)
### How does it work?
The first part, `$x=~s//.*/g`, inserts the string `.*` between each character in `$x`. The second part, `$y=~$x`, treats `$x` as a regexp and matches `$y` against it. In Perl regexps, `.*` matches zero or more arbitrary characters, while all alphanumeric characters conveniently match themselves.
[Answer]
### Ruby, 32 characters
```
s=->x,y{y=~/#{[*x.chars]*".*"}/}
```
This solution returns `nil` if `x` isn't a subsequence of `y` and a number otherwise (i.e. ruby equivalents to `false` and `true`). Examples:
```
p s['','z00']        # => 0   (i.e. true)
p s['z00','z00']     # => 0   (i.e. true)
p s['z00','00z0']    # => nil (i.e. false)
p s['anna','banana'] # => 1   (i.e. true)
p s['Anna','banana'] # => nil (i.e. false)
```
[Answer]
## Haskell, ~~51~~ 37
```
h@(f:l)%(g:m)=f==g&&l%m||h%m;x%y=x<=y
```
Thanks to Hammar for the substantial improvement. It's now an infix function, but there seems to be no reason why it shouldn't.
Demonstration:
```
GHCi> :{
GHCi| zipWith (%) [""   , "z00", "z00" , "anna"  , "Anna"]
GHCi|             ["z00", "z00", "00z0", "banana", "banana"]
GHCi| :}
[True,True,False,True,False]
```
[Answer]
# [Python](https://www.python.org), 45 bytes
```
lambda a,b:{1,l:=iter(b)}>{c in l for c in a}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=XY3BCoMwDIbvPkVurUOh3obgYO_hJd1aLHSpuLqh4pPsIoztnXybWd3JHJL_-0jI61t3vnI0vXVRflqv0-OcWrzJKwImMh-yxOaF8arhMh5PwwUMgQXtGlgjjv8jeFbGKsjyujHkueYH9UDLDdWt5_FS2940V4wlwHohWLT2PQjRB0IMgEQYIIwFJRKu4rwXKO_Otl7ZLmhynkXbwx8)
Builds on [@qwatry's method](https://codegolf.stackexchange.com/a/217976) used in [@xnor's answer](https://codegolf.stackexchange.com/a/180287): `iter` consumes elements as they are searched for, so `c in l` "uses up" the character if it is found.
Some trickery lets us combine the `all` and the iterator assignment:
* `{c in l for c in a}` is a set comprehension which effectively deduplicates its contents, so it's always one of `{}`, `{False}`, `{True}`, or `{False, True}`
* `1` and `0` are equivalent to `True` and `False`
* The `>` operator tests if `{True, iter(b)}` is a strict superset of the result, which is true only if that result is `{}` or `{True}`, i.e. all the `c in l` expressions were true
* By including `l:=iter(b)` in the set, we can sequence the evaluation order correctly with minimal parentheses by reusing the set's `{}` grouping
* It also lets us use `>` instead of `>=` because the iterator will never be present in the boolean set
* Otherwise, `>=` would be necessary because `{True}` is not a strict superset of `{True}`
[Answer]
## Python (48 chars)
```
import re;s=lambda x,y:re.search('.*'.join(x),y)
```
Same approach as Howard's Ruby answer. Too bad about Python's need to import the regex package and its "verbose" `lambda`. :-)
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 42 bytes
```
lambda a,b:''in[a:=a[a[:1]==c:]for c in b]
```
[Try it online!](https://tio.run/##XcqxDoMgFAXQWb@CDUgcMF0aEoZ@B2W4WI0k9kkItqk/T8XR5d2ce1/85Xml2z2mMplnWfD2LzB0XnMeyEIbWFjdO2MG7aY1sYEFYt6V7xyWkfW6bY5vM36wiEBxy0LKtokpUBaTOCYpC@cd47tSvD3vFUrtVUAFiFBR46AH4Swel@IP "Python 3.8 (pre-release) – Try It Online")
**[Python 3.8 (pre-release)](https://docs.python.org/3.8/), 48 bytes**
```
lambda a,b,j=0:all((j:=1+b.find(c,j))for c in a)
```
[Try it online!](https://tio.run/##XctBCsMgEAXQdTyFO2eoFEM3JeCi9@hmTCJR7ERC2tJc3sYss5nP@5/Jv3Wa@XbPS/H2WRK93ECStNPRmo5SAoidbS/u6gMP0OuI6OdF9jKwJCzfKaRRtp1o9h87fihB4PxeAVE0eQm8god9QixKaak2Y5Q47hnGbFVEFcRMFTV2OmI6isep@AM "Python 3.8 (pre-release) – Try It Online")
In Python 3.10+, we don't need parens around the walrus expression for [46 bytes](https://ato.pxeger.com/run?1=XYxBDoIwEEXXcIru2molZWdIuuAMbt1MgYYmdSCkaOQqbkiM3onb2CIb3czP-z9vHu_-7tsO56dR59fozeG4ZA4uugYCQgurZAHOMVsonRmLNauE5fvcdAOpiEUCfLN2t9a6huRFmgRRNVcIFvajZ5ynST9Y9MywMPHNmJcTpYLQSUqarvcfpJwiAUQARIgQI6AGhLUof4vv7w8).
**[Python 2](https://docs.python.org/2/), 48 bytes**
```
lambda a,b:re.search('.*'.join(a),b)>0
import re
```
[Try it online!](https://tio.run/##XctBCsMgEIXhdTyFu9EiYrsMpNB7dDO2Bi3JKNZSmstbzTKbeXw/TPoVH@lS5@leF1ztEzkqO2an3w7zwwvQJ9CvGEigVFZeDQtrirnw7OrXh8Xx88iG9jMFSp8iJBtSDlTELFqUsgIoDpsxwPZ7hDFbF2IHEmFHn0aLhHu4HcIf "Python 2 – Try It Online")
Copied from [this answer of Lynn](https://codegolf.stackexchange.com/a/180248/20260). The `>0` can be omitted if just truthy/falsey output is OK.
**[Python 2](https://docs.python.org/2/), 49 bytes**
```
def f(a,b):l=iter(b);print all(c in l for c in a)
```
[Try it online!](https://tio.run/##XcwxDsMgDAXQOZzCGyBloB1TZehRTAuKJctBiKpqLk8CmdLF3@9LdvqVZZV7re8QIRocvZ14phKy8faRMkkBZDYvIAGGuGboK9r6XYgD3CY1HFczSfoUY9VwPqlaj6A357Tq8x/ObU2IDSiCDS0OehTsxfNa7A "Python 2 – Try It Online")
A dazzling new method [introduced to me by qwatry](https://codegolf.stackexchange.com/a/217976/20260). The idea is that turning `b` into the iterator `l` will consume values whenever they are read. So, checking `c in l` will consume values left to right until it finds one that equals `c` or it reaches the end.
**[Python 2](https://docs.python.org/2/), 50 bytes**
```
f=lambda a,b:b and f(a[a[:1]==b[0]:],b[1:])or''==a
```
[Try it online!](https://tio.run/##XcuxCoMwGATgWZ8i228gQ@wYyNDnCBnux4qC/Q2SUurLp4mjyx3fwaVfXnZ5lDL7DW@eoGDYsYJMah4QENwYvedgo4uGw@ii3g8i71G@y7q91Oj6rn78KumTB9136VglD/VsWOtCZBSd1lJ/5R3Wnk1AA0TQ0KqSIbiG5234Aw "Python 2 – Try It Online")
**[Python 2](https://docs.python.org/2/), 50 bytes**
```
lambda a,b:reduce(lambda s,c:s[c==s[:1]:],b,a)==''
```
[Try it online!](https://tio.run/##XcuxDoMgEMbxWZ6CDUgYsCMJQ5/DOhyIkcReiWBMfXkKppPLffn9k4vfvHzwUWbzKiu87QQUpNWbn3bn@b8k6XQanDFp0P2oR2klCGMYK8cSVk97Tbr6ZQLGPXNBurgFzHzmNQpRGJOUnUoxct07lDqbABoAERraVFpAuMLzFn4 "Python 2 – Try It Online")
[Answer]
## Python, 59 characters
```
def s(x,y):
 for c in y:
  if x:x=x[c==x[0]:]
 return x==""
```
I figured my answer would be better expressed in Python.
Edit: Added r.e.s.'s suggestions.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 bytes
```
⊆ᵈ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFSuVv2obcOjpuZHHcuVSopKU5VqQKy0xJziVKXaciU9BaWHuzprH26d8P9RV9vDrR3//0dHKynpKFUZGCjF6kSDaXSegUEVhJuYCOQl5uUlQnggho5SUmJeIlTEEVUkFgA "Brachylog – Try It Online")
As with [this answer,](https://codegolf.stackexchange.com/a/180657/85334) `⊆` is a built-in predicate that declares a relationship between the input and output variables, and `ᵈ` is a meta-predicate that modifies it to declare that same relationship between the first and second elements of the input variable instead (and unify the output variable with the second element but as this is a decision problem that doesn't end up mattering here). `X⊆Y` is an assertion that X is a subsequence of Y, therefore so is `[X,Y]⊆ᵈ`.
This predicate (which of course outputs through success or failure which prints `true.` or `false.` when it's run as a program) takes input as a list of two strings. If input is a bit more flexible...
# [Brachylog](https://github.com/JCumin/Brachylog), 1 byte
```
⊆
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFSuVv2obcOjpuaHWzsedSxXKikqTVWqAbHSEnOKU5Vqy5X0FJQe7uqsfbh1wv9HXW3//0dHKynpKFUZGCjF6kSDaXSegUEVhJuYCOQl5uUlQnggho5SUmJeIlTEEVUkFgA "Brachylog – Try It Online")
Takes string X as the input variable and string Y as the output variable. Outputs through success or failure, as before. [If run as a full program,](https://tio.run/##SypKTM6ozMlPN/r//1FX2///Sol5eYlK/5WSEvOAUAkA) X is supplied as the input and Y is supplied as the first command line argument.
[Answer]
## GolfScript (22 chars)
```
X[0]+Y{1$(@={\}*;}/0=!
```
Assumes that input is taken as two predefined variables `X` and `Y`, although that is rather unusual in GolfScript. Leaves `1` for true or `0` for false on the stack.
[Answer]
## C (52 chars)
```
s(char*x,char*y){return!*x||*y&&s(*x-*y?x:x+1,y+1);}
```
[Test cases](http://ideone.com/kMU8Y)
[Answer]
# Burlesque (6 chars)
6 chars in Burlesque:
 `R@\/~[`
(assuming x and y are on the stack. See [here](http://eso.mroman.ch/cgi/burlesque.cgi?q=%22anna%22%22banana%22R%40%5C%2F~%5B) in action.)
[Answer]
# C, 23:
```
while(*y)*x-*y++?0:x++;
```
result in \*x
<http://ideone.com/BpITZ>
[Answer]
## PHP, 90 characters
```
<?function s($x,$y){while($a<strlen($y))if($y[$a++]==$x[0])$x=substr($x,1);return $x=="";}
```
[Answer]
### Scala 106:
```
def m(a:String,b:String):Boolean=(a.size==0)||((b.size!=0)&&((a(0)==b(0)&&m(a.tail,b.tail))||m(a,b.tail)))
```
[Answer]
## CoffeeScript ~~112~~ ~~100~~ ~~95~~ 89
My first attempt at code golf... hope I don't shame my family!
```
z=(x,y)->a=x.length;return 1if!a;b=y.indexOf x[0];return 0if!++b;z x[1..a],y[b..y.length]
```
**Edit**: turns out Coffeescript is more forgiving than I thought with whitespace.
**Thanks to r.e.s. and Peter Taylor for some tips for making it a bit sleeker**
[Answer]
# C #, ~~70~~ ~~113~~ ~~107~~ 90 characters
```
static bool S(string x,string y){return y.Any(c=>x==""||(x=x.Remove(0,c==x[0]?1:0))=="");}
```
[Answer]
# Mathematica 19 17 27
`LongestCommonSequence` returns the longest non-contiguous subsequence of two strings. (Not to be confused with `LongestCommonSubsequence`, which returns the longest contiguous subsequence.
The following checks whether the longest contiguous subsequence is the first of the two strings. (So you must enter the shorter string followed by the larger string.)
```
LongestCommonSequence@##==#& 
```
**Examples**
```
LongestCommonSequence@## == # &["", "z00"]
LongestCommonSequence@## == # &["z00", "z00"]
LongestCommonSequence@## == # &["anna", "banana"]
LongestCommonSequence@## == # &["Anna", "banana"]
```
True True True False
The critical test is the third one, because "anna" is contained non contiguously in "banana".
[Answer]
# PHP, 41 Bytes
prints 1 for true and nothing for false
```
<?=!levenshtein($argv[1],$argv[2],0,1,1);
```
If only insertions from word 1 to word 2 done the count is zero for true cases
[levenshtein](http://php.net/manual/en/function.levenshtein.php)
[Try it online!](https://tio.run/nexus/php#ZczBCoJAEAbgu09hW7AKE@x21ZIuPUE328MkUyvIKm55MHp2U9fEaE7D//H/cVLpyruVNWGmgzRlWwacA2@F4Mpfn@sneeDSIZrB729A/1eFaL98wsLOXcQe0RiccLk7xsCvaHDypR7/1A0rtBus7034Sg5dnOxXBTVkrH5QboJRUqnAPTsFAiTIMOoo0yW7GBa9uw8 "PHP – TIO Nexus")
## PHP, 57 Bytes
prints 1 for true and 0 for false
Creates a Regex
```
<?=preg_match(_.chunk_split($argv[1],1,".*")._,$argv[2]);
```
[Try it online!](https://tio.run/nexus/php#Zc9NDoIwEAXgPacg1aRgKiluQYkbT@AOm2YkhRqxNAVcYDw78ifBOMv3zbxkwkhLbaWFEZBIJ47RFhGMCW4oxcxenU0tLDKmfTSD3U2P9q9S2nz5BHk53wJ0CErBhMveISb4CgomX@rxT8diBuUaTPZ0X9GhDaO9NiLjD6i6L7iXyFrdeanzW@UMW7HPiE@Qt0Gux8kY7ZgbtCKRBbooFLzbDw "PHP – TIO Nexus")
[Answer]
# [Haskell](https://www.haskell.org/), 36 bytes
```
(a:b)%(c:d)=([a|a/=c]++b)%d
s%t=s<=t
```
[Try it online!](https://tio.run/##TYq9DsIgFIV3n@LmRhJINTI33sGncGgYbqlaIhIiTMRnF2nj0JzhO38zp@fN@1ol96MS0vaTIjnwh09kTde1btolkSmdKdcXuwAE8e1Chj0UF68uzyCFggERAA6ARWv8Y4kcAuM6XBZn2nHzaNC6rBw5NG2cqV979/xI9Whj/AE "Haskell – Try It Online")
---
**37 bytes**
```
(.map concat.mapM(\c->["",[c]])).elem
```
[Try it online!](https://tio.run/##TYtBCsMgEEX3PcUgLRhIghew0AN03UXiYiraSHUijSsPX6uhizCL9z7/z4Lb23hfrJwLHwNG0CtpTE3vfNbDdWKsn7RSXTcab0Lhl07aU0BHICF@HCU4Q3bx4dICtYT6AAA9sCwE@6NFJEK2F7dmqg4Piwoh8s4nUr2DqfLV1uNrK4OO8Qc "Haskell – Try It Online")
I think `mapM` postdates this challenge. If we can assume the characters are printable, we can do 
**36 bytes**
```
(.map(filter(>' ')).mapM(:" ")).elem
```
[Try it online!](https://tio.run/##TYrBCsIwEETvfsWwKE1AJWchQj/AswftYS2JDSYhtDn1441p8VD28N7szMDTx3hfrH4WcQ6chHU@m1FcGzRSLp@buBCouvEmFHGQ2u4CuwiNNLqYscfs0t3lAbXEgwjAETQrRX8skWNkWot2sa4ON4sKpeaVL471NtaVb289v6dy6lP6AQ "Haskell – Try It Online")
---
**37 bytes**
```
(null.).foldr(?)
c?(h:t)|c==h=t
c?s=s
```
[Try it online!](https://tio.run/##TYqxCgIxEER7v2IJFgnokVpYDr/CQq9YozHBNRcusQl@uzF3WBxTvHnMOErPO3O1eKkyvJk71dmRb5Ps1cb00h2y@hhEh7lpwlRf5AMgxMmHDFsoPp58dmDhLAQA7EAUrcUfs1IIJJbhOLehHVePBq3LwiuFllUb6tdYpkeqexPjDw "Haskell – Try It Online")
[Answer]
## JavaScript (no regex), 45 bytes
```
y=>x=>(i=0,[...y].map(c=>c==x[i]&&i++),!x[i])
```
Should be called like
```
f(haystack)(needle)
```
[Answer]
# C - 74 71 64
This doesn't beat Peter Taylor's solution, but I think it's pretty fun (plus, this is a complete working program, not just a function)
```
main(int c,char**v){for(;*v[1]!=0;++v[1])v[2]+=*v[1]==*v[2];return*v[2];}
```
---
```
main(int c,char**v){for(;*v[1];++v[1])v[2]+=*v[1]==*v[2];return*v[2];}
```
---
```
main(c,v)char**v;{while(*v[1])v[2]+=*v[1]++==*v[2];return*v[2];}
```
And ungolfed:
```
main(int argc, char** argv){
   char * input = argv[1];
   char * test  = argv[2];
   // advance through the input string. Each time the current input
   // character is equal to the current test character, increment
   // the position in the test string.
   for(; *input!='\0'; ++input) test += *input == *test;
   // return the character that we got to in the test string.
   // if it is '\0' then we got to the end of the test string which
   // means that it is a subsequence, and the 0 (EXIT_SUCCESS) value is returned
   // otherwise something non-zero is returned, indicating failure.
   return *test;
}
```
To test it you can do something like:
```
./is_subsequence banana anna && echo "yes" || echo "nope"    
# yes
./is_subsequence banana foobar && echo "yes" || echo "nope"    
# nope
```
[Answer]
## Python, ~~66~~ ~~62~~ ~~59~~ 58 chars
Kind of a fun solution, definitely a neat problem.
```
def f(n,h,r=0):
 for c in h:r+=n[r:r+1]==c
 return r==len(n)
```
[Answer]
## Ruby ~~32~~ ~~30~~ 28
```
f=->a,b{b.match a.tr'','.*'}
```
This will return `MatchData` instance if `a` is subsequence of `b` or `nil` otherwise.
**Old version that find substring instead of subsequence**
## Ruby 15
```
f=->a,b{!!b[a]}
```
Using `String#[](str)` method that returns `str` if `str` is a substring of `self` and `!!` to return `Boolean` if returned value can be usable as boolean (and don't need to be `true` or `false`) then it can be only 13 chars:
```
f=->a,b{b[a]}
```
It will return `nil` if `a` is not a substring of `b`.
[Answer]
# SWI-Prolog, SICStus
The built-in predicate [sublist/2](http://www.swi-prolog.org/pldoc/doc_for?object=sicstus_lists%3asublist/2) of SICStus checks whether all the items in the first list also appear in the second list. This predicate is also available in SWI-Prolog via compatibility library, which can be loaded by the query `[library(dialect/sicstus/lists)].`.
Sample run:
```
25 ?- sublist("","z00").
true.
26 ?- sublist("z00","z00").
true .
27 ?- sublist("z00","00z0").
false.
28 ?- sublist("aa","anna").
true .
29 ?- sublist("anna","banana").
true .
30 ?- sublist("Anna","banana").
false.
```
The byte count can technically be 0, since all we are doing here is querying, much like how we run a program and supply input to it.
[Answer]
# [Red](http://www.red-lang.org), 82 bytes
```
func[x y][parse/case y collect[foreach c x[keep reduce['to c 'skip]]keep[to end]]]
```
[Try it online!](https://tio.run/##bckxDoMwDEDRnVNYWRibuVuv0NXy4DqOikBJlIAEXD6QpQKp438/q6tvdUidf0L1SxBcYSNMnIs@hIvCBhKnSWVGH7OyfEFgxVE1QVa3iGI/x9P6Mg6JqA08QYMjopryEGbwYAyY3VrT/aDVf7N2vyLzaRwCX60lmA8Hvvnr5vUA "Red – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 3 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
æQà
```
[Try it online](https://tio.run/##yy9OTMpM/f//8LLAwwv@/09KzANCrsS8vEQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWXC/8PLAg8v@K/zPzpaSUlHqcrAQClWRyEazMDgGhhUQfmJiUBuYl5eIpQLYukoJSXmJcKEHFGFYgE).
Or alternatively:
```
æså
```
[Try it online](https://tio.run/##yy9OTMpM/f//8LLiw0v//09KzANCrsS8vEQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWXC/8PLig8v/a/zPzpaSUlHqcrAQClWRyEazMDgGhhUQfmJiUBuYl5eIpQLYukoJSXmJcKEHFGFYgE).
With both programs the first input is \$Y\$ and the second input is \$X\$.
**Explanation:**
```
æ    # Get the powerset of the (implicit) input-string `Y`
 Q   # Check for each if it's equal to the (implicit) input-String `X`
  à  # And check if any are truthy by taking the maximum
     # (after which this result is output implicitly)
æ    # Get the powerset of the (implicit) input-String `Y`
 s   # Swap to take the (implicit) input-String `X`
     # (could also be `I` or `²` to simply take input)
  å  # Check if this string is in the powerset-list of strings
     # (after which this result is output implicitly)
```
[Answer]
# x86-16 machine code, ~~12~~ 10 bytes
**Binary:**
```
00000000: 41ac f2ae e303 4a75 f8c3                 A.....Ju..
```
**Unassembled listing:**
```
41          INC  CX                 ; Loop counter is 1 greater than string length 
        SCAN_LOOP: 
AC          LODSB                   ; load next char of acronym into AL 
F2 AE       REPNZ SCASB             ; search until char AL is found 
E3 03       JCXZ DONE               ; stop if end of first string reached 
4A          DEC  DX                 ; decrement second string counter 
75 F8       JNZ  SCAN_LOOP          ; stop if end of second string reached 
        DONE: 
C3          RET                     ; return to caller
```
Callable function. Input: `Y` string pointer in `SI`, length in `CX`. `X` string pointer in `DI`, length in `DX`. Output is `ZF` if `Truthy`.
**Example test program:**
This test program uses additional PC DOS API I/O routines to take multi-line input from `STDIN`.
[![enter image description here](https://i.stack.imgur.com/KLrYN.png)](https://i.stack.imgur.com/KLrYN.png)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~18~~ 17 bytes
```
ＦηＦ⁼ι∧θ§θ⁰≔Φθμθ¬θ
```
[Try it online!](https://tio.run/##HYg7DoQwDAV7TuHSlkCip6IAaRvEFbzhFynrKB/Q3t4E5hXzNObgaDw71c1HwIPg9RBOdgltDb0sGIryR5b1/9yWCtCnZHfB0bq8xif/qIZAXTVHKxknnzEQdaoswtWXpUyby90 "Charcoal – Try It Online") Link is to verbose version of code. Uses Charcoal's default Boolean output of `-` for true, nothing for false. Explanation:
```
Ｆη
```
Loop over the characters of `Y`.
```
Ｆ⁼ι∧θ§θ⁰
```
See if this character is the next character of `X`.
```
≔Φθμθ
```
If so then remove that character from `X`.
```
¬θ
```
Were all the characters of `X` consumed?
[Answer]
# [Factor](https://factorcode.org/) + `math.combinatorics`, 19 bytes
```
[ all-subsets in? ]
```
[Try it online!](https://tio.run/##Zc@xCsIwGATgPU9xzW7JrKA4iYtLcRKHP6HBQJuW5newpc8eQ2ul4o33ccNZMtx08VqcL6ctauJHbppaO0@pdiYglBzQdiXzq@2cZ1AITep3QgwCKQOkhOyVkhjxSQZebII1J8MvKtUvmsEuRpSIvKfV8GtTLTV5mn1lx3@zYhTxBqqqTXjq6ZHzB9yjnd/sa2qRxzc "Factor – Try It Online")
[Answer]
# Haskell + [hgl](https://gitlab.com/WheatWizard/haskell-golfing-library), 2 bytes
```
iS
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ8FNlczcgvyiEoXC0sSczLTM1BSFgKLUnNKUVC6oRABXte7S0pI0XYtFmcEQxs3purVcXLmJmXkKtgop-VwKCgVFCioKmcEKSol5eYlKCkpJiXlAqIQsAxStMjBAEQLxMUUTQQaAzcFUa2BQharYEWKfE8Q-iPMWLIDQAA)
So this is a builtin. There are actually a couple of builtins. There's also `fiS` which is the same function but the arguments flipped, there `iSW eq` which how `iS` is defined internally. There's `fe<ss` which gets all subsequences of `y` and checks if `x` is among them. There's `ap eq<lSW` which tests if the longest common subsequence is equal to the second element.
But these are no fun. Let's have a true no builtins solution
# Regex based, 17 bytes
```
pP<rXx<ic".*"<m p
```
Also
```
pP<rXx<ic".*"<!<p
```
This works like all the other regex answers here. It adds `.*` between items and then matches a regex.
# Parser based, 15 bytes
```
pP<mF(aK h'<χ)
```
This works similarly to the regex answer. It replace every character in the string with a parser that matches anything ending in that character. It then sequences all the parsers and checks if there is any partial matches.
It's cheaper than the regex which is a little surprising.
# Reflections
The regex answer is the one with the most room for improvement.
* There should be functions that build and apply regexes all in one. It's silly to have to build and then apply the regex separately. This would save 3 bytes on the regex solution
* Hard to imagine a situation in which `<!<` is going to be useful. Here we can see it's not saving anything. Maybe this should be shortened, the docs should have some info about when it is useful.
* There should be more versions of `ic` and `is`. Some that add copies to the outside, and a versions that are mapped with pure like the regex answer.
With the above changes the regex answer could look like
```
pPX<icp".*"
```
The only other suggestion I have is that *maybe* `aK h'` should get a synonym. It's basically "ends with", which seems like a concept that might come up again.
]