Every way to split text into words
Someone removed the spaces from a sentence. Given the string text and a list words, return every way to put spaces back so that each piece is in words. A word may be used any number of times. Return each sentence once, as a string with single spaces, in any order; if text cannot be split, return an empty list.
Everything is lowercase a–z; 1 ≤ len(text) ≤ 30, and words may contain repeats. No test has more than 20 answers, but some have no answer and a huge number of dead ends: those must still finish fast.
Examples
word_splits("nowhere", ["no","now","where","here","he","re"])→["no where","now he re","now here"]word_splits("icecream", ["ice","cream","icecream"])→["ice cream","icecream"]word_splits("planet", ["plan","lane","net"])→[]