Trying to re-rwite for clarity. Referring to my previous lists: I would like to trim a dictionary so that all words that "consume" more than n letters "x" are deleted. So: Only words with 2 "a"'s and words with 1 "b" and words with 2 "d"'s etc. will be kept. According to this, "boffa" is deleted, but "bode" is kept.
The dictionary is large, so my lists below are just an illustration. One list is the dictionary, the other list contains the numbers for consumption on each and every word.
So I have three lists: "sa", "sb" and "sc". "sa" gives the number of usable characters for each word in "sc". Words can be of any size. List "sc"can only consist of letters in "sa".
List "sc" is the resulting list. The word "bobb" cannot exist in "sc" because it uses too many "b"'s. How to exclude words that consume too many letters?
sa = {"l", "a", "a", "b", "d", "d", "e", "g", "i", "o", "p", "s","v"} sb = {"absid", "ad", "adagio", "basa", "be", "bebbe", "bebi", "bebis", "bebisapa", "bebo", "bebodd", "bebop", "bedagad", "beediga", "befogad", "begabba", "begiva", "beige", "beigea", "bes","bese", "bevis", "bevisa", "bi", "bibba", "bida", "biff", "biffa", "biff", "bifoga", "bio", "biogas", "bo", "boa", "bob", "bobb", "bod", "bodega", "boffa", "bog", "boggi", "bov" }` The answer by @MichaelSeifert solves the answer nicely. Thank you everyone, what a generous and knowledgeable people you are!
listbwhose characters are a subset of the ones inlista? From the statedlistb, what is the expected output? You've stated that "carefree" is out, but which ones should it accept? $\endgroup$listbshould be strings? $\endgroup$lista, should that be interpreted as "any number of this character is allowed", or "none of this character is allowed"? For some cases you seem to be saying the former (e.g.,freedomis allowed even thoughlistadoesn't contain anm), and for some you seem to be saying the latter (e.g.,girlshould not be allowed, even though none of its characters are inlista.) $\endgroup$