I’m using a program see here: Visual Basic Regular Expression Question. I enter letters and the program returns all possible combinations from list. I want change this line of code…
Dim result = fruits.Where(Function(fruit) Not fruit.Except(letters).Any())
If I have this list:
Dim fruit as List(Of string) from {"apple","orange","pear","banana"}
And I input “p a p l e r” then it would return “apple” and “pear”, but if I enter “a p l e r” then it would return just “pear”. The idea is to return all words, which can be made of entered letters without duplicating any single letter. How to optimize this Linq code?
This could be cleaner, but it works:
edit – I removed some unneeded order by clauses, and simplified the grouping
edit again – after some more thinking, here’s a version that has more lines, but is much clearer and better factored:
If I did anything else to this, I would make CanBeMadeFrom and StringToFrequencyTable into extension methods.