[Question]
  [
> 
> Yes, I know there is a [similar question](https://codegolf.stackexchange.com/questions/5136/code-golf-word-unscrambler), but this one specifically concerns any possible words, even with letters left over, while the linked one restricts to a permutation of the input
> 
> 
> 
## Objective
Have you ever had those moments in a Scrabble game where you're staring at your letters, trying to find a good word, and your mind is just blank? Some of us feel cheaty and turn to word unscrambling software like [this one](https://wordunscrambler.me/) to help us. This challenge is to build your own word unscrambler.
Given a list of possible words and a string of characters conforming to the regex `([A-Z]|[a-z])+`, your program has to find all the words whose letters are all found in the scrambled string.
Sample inputs:
```
asto, [as, so, to, oats] -> [as, so, to, oats]
asto, [as, to] -> [as, to]
ast, [as, so, to] -> [as]
zzyzx, [as, to, so] -> []
trom, [as, to, too, or] -> [to, or]
roomt, [as, to, too, or] -> [to, too, or]
```
## Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest answer wins.
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
œ&ƑƇ
```
[Try it online!](https://tio.run/##y0rNyan8///oZLVjE4@1/z@8XMn7UdOayP//o5USi5V0FJSK80FkCZjMTywpVorVUYDJAUWReHCVqCogMhhiJfkQI4vwSv0HSkAEkWgQVVVVWVUBVlyUnwuii/Lzc0uUAA "Jelly – Try It Online")
## How it works
```
œ&ƑƇ - Main link. Takes a list of words L on the left, a word W on the right
   Ƈ - Keep those words from L such that:
  Ƒ  -   They are unchanged after taking:
œ&   -     The multiset intersection with W
```
[Answer]
# [Vyxal 2.6pre1](https://github.com/Vyxal/Vyxal/releases/tag/v2.6.0pre1), ~~5~~ 3 bytes
```
Þ×↔
```
[Don't Try it Online! (the site runs a few commits 2.4.1)](https://lyxal.pythonanywhere.com/?flags=r&code=%C3%9E%C3%97%E2%86%94&inputs=%27zzyzx%27%0A%5B%5B%27a%27%2C%27s%27%5D%2C%5B%27t%27%2C%27o%27%5D%2C%5B%27o%27%2C%27r%27%5D%2C%5B%27m%27%2C%27o%27%2C%27s%27%2C%27t%27%5D%5D&header=&footer=)
Haha builtin go brr.
-2 thanks to Lyxal.
```
  ↔ # The elements in common between
Þ×  # All combinations of the letters
    # And the input.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 66 bytes
```
lambda s,l:[w for w in l if all(w.count(c)<=s.count(c)for c in w)]
```
[Try it online!](https://tio.run/##jY7NTsQwDITvfYq5JZHCSnBcEV5kWaFQWm2ktI4Sl7B9@ZK0YmH5kTjZY38zdjjzica7pTePi7fD84tF0n5/yOgpIsON8HA9rPcy71qaRpatujfp0leurVxWx8UNgSIjdk0@Od/hdt9AJg2vNGjiAIPBBtm9Wq8RbX5yY5hYql0K3rEUuHmAUKpBiG5k9JsXxqzuRdjEJDQOpSlFpCrEOhJkOYljDfh723wPKOLKUvUK/XbkkyzMPJ/nt@ukjd2oQnCk4QfAtL0TP9L4ohsRiQb@r@XL@B0 "Python 2 – Try It Online")
[Answer]
# [Python 3.10](https://docs.python.org/3.10/), 74 bytes
```
lambda w,l:[x for x in l if C(x)<=C(w)]
from collections import*
C=Counter
```
[Attempt This Online!](https://staging.ato.pxeger.com/run?1=fY87DsIwEET7nGLlKkahR4hU7rgCpAghFpZsb2RvlM9VaCIhuBOX4AwEQmN-1ezsPo12jpeqowPa4STT7bkmOV9c1zo3u30OTaKXmxYkOmhBWdCgJIi45atUxA3PIunQQIFalwUptB6UqdDRLBKpwNpS6V6Jt8opS7GMWe4JWQKbcRiF-YdhzxXDnDzLOI9-waN5P3-LCpi-7_o2zJjYgKKxyAdEOL3lQtYhGvoPT62HYdI7)
In versions before 3.10 `C(x)<=C(w)` would have been `not C(x)-C(w)` instead.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 61 bytes
```
s=>l=>l.filter(w=>w.map(g=c=>g|=w[c]=s.indexOf(c,w[c]+1))|~g)
```
[Try it online!](https://tio.run/##fZFBboMwEEX3PsXssBVi1HVkdl33AMRSHGIoETCRPSo0pb06tZMmJVJVyYvx/99vNOOjeTO@dM2J1j0e7Fyp2au8DUdWTUvW8UHlg@zMideqVHk9qaEotfKy6Q92fKl4mUZh9STE9FWLmayn0njrQcGOGU@YQmF8Cj4U8YKGvIZ1/oe6jBP@hkIdrQfQzdXsfH4/j/dX0b96mpHDbmEQxkbu6tK1Zg6xo/9CN4HtJLmm40L6U9sQT7Z9IjbsPq@s0D2b8pW3TW9B5fDBAErsPQV4CvsUrA47ie4PIUthW0yxURZAtzCGUMULKaXRgu/D6ilAs@2wympx@Ygx0mNg1GKhjPKITc@TRNxp2FrZYn2hoZYeHXEBK0gSUAq4fYTDNIWtiWUsTB5gn2IzfwM "JavaScript (Node.js) – Try It Online")
Input / output words as list of characters.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 46 bytes
```
->b,a{a.select{|w|d=b*1;w.all?{|c|d[c]&&=''}}}
```
[Try it online!](https://tio.run/##bc9BDoIwEAXQPaeYjVRNbeJWgx6k6WJaMCwgQ9oahLZnryxIxOj2vz@ZfPvUU35U@XTTHAMK13SN8SGOsa708XwdBXbdPUQTa2lUWVaMpZSyLEAydJ4Yh90o0YEj8ASE3inFf9TTJ/0@WfN5nubXpr7gKt5SvwVPyxu7oiXq/T8tlGjQtCEusyIM8JCaA4oeh315MS1ad1ApvwE "Ruby – Try It Online")
Takes the list of tiles as a string; words are input and output as lists of characters. The inconsistent formats can be avoided at a cost of a few extra bytes: [47 bytes](https://tio.run/##bc9BDoIwEAXQPafoRqqm9gAa9CBNF9MCcQEZ0o5BaHv2SgyJGF3Of38yGfcwU26rfLoaAQGkb7rGUohjrCtz5PwySui6W4g21srqsqw4TyllVTDFwRNywXajAs88MkKGQF5r8aOEn/R7Zc3neZqfm/qCq5DDfguEyxm3okPs6Z8WWjZg7yEuf0U2sFYZae/gvGAgexj25fk9HnTKLw "Ruby – Try It Online") to use lists of characters exclusively and [52 bytes](https://tio.run/##bc3BCoMwEATQu1@xlxoQG@i52H5IyGGNigdlS7Il1STfnnoQammv82YY@2yXPDT5fGtrDChdP/WGQ/Sxa9rqcvXSjGidxGm6h2hip4wuy0aIlFJWBSiBjknUcPIKHTgCJiBkp3X9o0yf9Huy5@u6rK9DfcNd2NJ8BKbtxu5oiWb@p4WWPZoxRI7wgEFVrFN@Aw "Ruby – Try It Online") for strings.
All variants work the same way. For each letter of a word, remove the first occurrence of that letter from the list of tiles or return `nil` (falsy) if there is no such tile. The word can be formed if this procedure succeeds for all its letters.
[Answer]
# [Factor](https://factorcode.org/) + `math.combinatorics math.unicode`, 53 bytes
```
[ <permutations> '[ _ [ subseq? ] with ∃ ] filter ]
```
[Try it online!](https://tio.run/##fZC9asNAEIR7PcXgJlX8APlRypAmjUkljDlfVviw71baXSFLxlWaPGdeRDlQEoIh2WqZb3YHpnbeWKaX1dPz4w2is93Sc9yG5LIcvM5Sl4LnV0ItA5TajpInxZ4k0QGNkNnQSEiGxgW5FvZ7MjhVzg/aHrdFcSqQp@1PWYYyjMHOFGfcl1g4NV78dmT8B5lvf@DllX6zcRzG4yU1zrHy5TDh@K9BmGMOOE8V7hqS2JmzwElLXFXYoIJ229zGA9bog@3w8f6W1zocjATrqZ4bKKNrsJw@AQ "Factor – Try It Online")
In plain English, select all words from the dictionary that appear in any permutation of the scrabble letters.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 12 bytes
```
Φη⬤ι¬›№ιλ№θλ
```
[Try it online!](https://tio.run/##JYqxCoAwDER/pWSqUL/ASQTdxL10KCJYiAZj9PdjbW@44z1u3SOvFFF14XSKHRPKxnZ3pke0yZmZxE68xd8O9ORLltg4U@H6oaRT9cBEh4AzHuKdB4RqlyGGELR98QM "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
 η              Word list
Φ               Filtered where
   ι            Current word
  ⬤             All letters satisfy
      №ιλ       Count of letter
    ¬›          Does not exceed
         №θλ    Count available
                Implicitly print
```
[Answer]
# [J](http://jsoftware.com/), 24 bytes
```
(1 e.[E.e.~#])&(/:~@>)#[
```
[Try it online!](https://tio.run/##bY3BCsIwDIbve4rgwLSwVb0WFUH05MnrEDakQ4QRWHPQHvbqdR11k@EhkD/fl@TpFwpr2GlAyGANuq9cwfF6OXuxAaOKkzKqS29yKVa6O@xlWniZJOb@IKhsaalkKqliC7meDWrYYmWZcLSZotU3MyoyHTLK3ztfKTqI43rPB@jc270iDn/byWAacrC4pWaSIvgntkQNo/8A "J – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~7~~ 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
æ€œ˜Ã
```
-2 bytes thanks to *@ovs*.
Inputs in the order `letters, words-list`.
[Try it online](https://tio.run/##yy9OTMpM/f//8LJHTWuOTj4953Dz//9F@fm5JVzRSonFSjpKJflgAkTmFynFAgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWXC/8PLHjWtOTr59JzDzf91/kdHRyslFivpKBXnA4kSEJGfWFKsFKsDFAZyY3UUYCrAPAxRmD6IFJp6sDRQpqqqsqoCQ64kH2xdEUhFSVF@Ll4FRfn5uUDjYwE).
**Explanation:**
```
æ      # Get the powerset of the (implicit) first input-string of letters
 €œ    # Get the permutations of each string in this list
   ˜   # Flatten this nested list to a single list of strings
    Ã  # Keep the words from the second (implicit) input-list that are also in this list
       # (after which the result is output implicitly)
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 49 bytes
```
A`^|(.)(.*\1)*(?<!^.*(?(2)^)(?<-2>.*\1)*\1(.|¶)+)
```
[Try it online!](https://tio.run/##K0otycxLNPyvqhGcoMOlwnVo23/HhLgaDT1NDT2tGENNLQ17G8U4PSClYaQZpwnk6RrZQWRiDDX0ag5t09TW/P8/sbgkXyexWKc4XwfIyE8sKeaCCZXkg5hwSa6qqsqqCogEUISrpCg/F8oryQdqLeIqys/PLUERAgA "Retina – Try It Online") Takes newline-separated input but link is to test suite that splits on commas for convenience. Explanation:
```
A`^|
```
Delete the first line, plus...
```
(.)(.*\1)*
```
... any lines that have more of a particular letter...
```
(?<!^.*(?(2)^)(?<-2>.*\1)*\1(.|¶)+)
```
... than the first line does.
[Answer]
# [ayr](https://github.com/ZippyMagician/ayr), ~~10~~ 9 bytes
```
[#*/&,:/:
```
Takes the words on the left and the letters on the right
# Explained
```
       /:  Each left
     ,:    Membership
  */&      And then reduce with multiplication
[#         Filter words with this mask
```
`*/ 1 0 0 1 0` is the same as `^./ 1 0 0 1 0` but shorter.
[Answer]
# [Python](https://www.python.org), 88 bytes
```
lambda a,w:filter(" ".join(map("".join,permutations(a))).count,w)
from itertools import*
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LYwxCgIxEEV7TxGmSpbs1iJ4D0EtRt1gZJMJkwmLZ7EJiN7J27gYm_9-897jne5ypVifbnt4FXH9-rObMJwuqNDOG-cnGVmDguFGPuqASUP7No0ciqB4ilmjMWY4U4liZ7NyTEH5xRSiKSsfErF0_36f2EfRndMgTBTAqj1gXgBCbX8ghqMxTaq18Qs)
Assumes the words don't contain spaces, but the `" "` can be changed to any other character that the words won't contain.
Unusually for Python, this declarative approach (map+filter) is shorter than a list comprehension.
[Answer]
# [Perl 5](https://www.perl.org/) + `-F -M5.10.0`, 38 bytes
```
say grep{$t=$_;$t=~s/$_// for@F;!$t}<>
```
[Try it online!](https://tio.run/##FYm7CoAwDAD3foVCV20dnHzg1M1vKBmqCGJKk0VEP91Y4Tg4Loa0tyIEZ7GmEC/Ng/Zd9kNGe2OKBdPkulLz3Y8igMQKWDEqoGzIicCkCDP4j0AvRt7wIKmcVHNbN7a2Hw "Perl 5 – Try It Online")
## Explanation
The letters (first line of input) are implicitly stored in `@F` via the `-F` flag.
We `grep` through the word list (`<>`), temporarily storing the word (`$_`) in `$t`, then `for` each letter in `@F`, `s///`ubstitute it (`$_`) for the empty string, returning a truthy value (which includes the word in the set to be printed by `say`) if `$t` is now empty (all letters of the word were removed because they exist in the input letters).
[Answer]
# [Perl 5](https://www.perl.org/), ~~52~~ 47 bytes
```
sub{$c=pop;grep{$C=$c;!grep{$C!~s/$_//}/./g}@_}
```
[Try it online!](https://tio.run/##jY5PT4NAEMXP5VNMycYFspGTF8kqiUcTe/GmDaEIWBVm3V1jC8Gvjss/28am6Wnmvfm9tytS@XHVkoy36mtVk4QLFEEuU1GTO06SYD7u8x/lk8j3G//Sz5swatrAylA6FsATjZVGyvrFDKo6QXuLYqwVXQK/OXFdsmMtRhzkOr0jjz23wyewqrbV5rBzCAzohGmJxT9K4/BFOfXqPz3GJGKhz83t2Sbu1qYBoNg6JHmNpWLkG@WLGelGuDwkUTDeIcxR8wuSOeGE9AF3AIRclxrecF06lFHWwS6kn3tO32jNbsHG9@fStmbXYHue97B4hMW9MQKraX8B "Perl 5 – Try It Online")
(shaved 5 extra bytes from Dom Hastings' suggestions)
[Answer]
# [K4](https://kx.com/download/), 28 bytes
**Solution:**
```
{y@&x{&/1>(#:'=y)-#:'=x}/:y}
```
**Examples:**
Count letter occurrences, subtract and spit out words that match...
```
q)k){y@&x{&/1>(#:'=y)-#:'=x}/:y}["trom";("as";"to";"too";"or")]
"to"
"or"
q)k){y@&x{&/1>(#:'=y)-#:'=x}/:y}["asto";("as";"so";"to";"oats")]
"as"
"so"
"to"
"oats"
q)k)()~{y@&x{&/1>(#:'=y)-#:'=x}/:y}["zzyzx";("as";"to";"so")]
1b
```
**Explanation:**
```
{y@&x{&/1>(#:'=y)-#:'=x}/:y} / the solution
{                          } / lambda taking implicit x and y args
    x{                 }/:y  / apply inner lambda to x and each y
                     =x      / group x
                  #:'        / count length of each group
                 -           / subtract from
          (     )            / do this together
              =y             / group y
           #:'               / count length of each group
        1>                   / 1 greater than subtraction result?
      &/                     / all
   &                         / indices where true
 y@                          / index into y with these indices
```
**Alternatives:**
* `{y@&&/'1>(#:''=:'y)-\:#:'=x}`, also 28 bytes
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
ṖvKf↔
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%E1%B9%96vKf%E2%86%94&inputs=roomt%0A%5B%22as%22%2C%20%22to%22%2C%20%22too%22%2C%20%22or%22%5D&header=&footer=)
This has to be the first time I've found a use for `K` on strings lol
## Explained
```
ṖvKf↔
Ṗ      # All permutations of the input word
 vK    # and get the divisors (substrings that split the string into more than once piece - idk how this actually makes this work)
   f   # flatten that
    ↔  # remove words from the input list that aren't in ^
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 9 bytes
```
@E{.nyM.p
```
[Try it online!](https://tio.run/##K6gsyfj/38G1Wi@v0lev4P9/pZKi/FwlLqXEYiUdBaWSfAgJpvKLlAA "Pyth – Try It Online")
```
@E{.nyM.p
     yM.P   // Collect all subsets of all permutations of the input
  {.n       //     -> Flatten and de-duplicate the list
 E          // Read the word list
@           // Get the intersections of the two lists.
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-f`](https://codegolf.meta.stackexchange.com/a/14339/), ~~6~~ 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
øVáUl
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWY&code=%2bFbhVWw&input=WyJhcyIsICJ0byIsICJ0b28iLCAib3IiXQoidHJvbSI)
```
-f flag to output the elements of first input
   that return a truthy value when passed through
ø       - true if word contains any of:
  Vá    - permutations of alphabet 
   Ul   - of same length of word hence equal 
```
Or [try that](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWY&code=%2bFbhVWw&input=WyJhcyIsICJ0byIsICJ0b28iLCAib3IiXQoicm9vbXQi)
]