20
3
What is the shortest way to see if an input is a wordinian using any programming language?
A wordinian is a word that contains words of length 1 to the original word's length. For example,
bin
'I' is a word
'in' is a word
'bin' is a word
Or,
stage
'a' is a word
'ta' is a word (yes it is)
'age' is a word
'stag' is a word
'stage' is a word
Input
Your code should take a word and a dictionary as inputs, in any reasonable format.
Output
The output should be a value to indicate true or false, to tell us if the word is a wordinian.
For more info on wordinians click here.
Here is a list of words that I will be using as inputs and subwords. Also, in response to @xnor, it has to contain subwords of each length, not a chain of subwords. Note that only one word will be used as an input.
@FryAmTheEggman I can't put a whole dictionary on here. What if it's any word that exists? – Jacques Marais – 2016-08-15T18:00:13.097
6I'd recommend passing in a dictionary as input. That way, its easy to come up with test cases (as you can make your own small dictionary) – Nathan Merrill – 2016-08-15T18:04:37.467
2Does it just have to contain subwords of each length, or do they have to be a chain where each subword adds one letter to the previous? – xnor – 2016-08-15T18:07:51.250
@FryAmTheEggman I edited my question to supply a list of all words. – Jacques Marais – 2016-08-15T18:25:08.370
@xnor I updated the question to answer your question. – Jacques Marais – 2016-08-15T18:25:24.713
@trichoplax Ok thanks. Also, will something like this list work?
– Jacques Marais – 2016-08-15T18:31:40.103@trichoplax Actually, I think this list should work: https://raw.githubusercontent.com/dwyl/english-words/master/words.txt
– Jacques Marais – 2016-08-15T18:35:54.310I updated my question to include the new list.
@trichoplax The new list contains about 479k words. I think that should be enough. How can this question get reopened though? – Jacques Marais – 2016-08-15T18:38:34.733
@trichoplax Ok thanks for all your help! – Jacques Marais – 2016-08-15T18:39:48.310
@JacquesMarais This challenge is clear to me, but I'd definitely include some test cases! – Nathan Merrill – 2016-08-15T18:40:52.470
@trichoplax Ok I use the ENABLE2K list now, thanks. So you mean a to take the whole list as an input and find the wordinians, instead of taking one word as an input? – Jacques Marais – 2016-08-15T18:50:22.047
1@JacquesMarais the concept is to take a word and a dictionary, and return true if the word is a wordinian (according to the dictionary) – Nathan Merrill – 2016-08-15T18:52:08.357
@NathanMerrill I don't think I understand you correctly now. So you use one word and check through the dictionary to see if the word is a wordinian? – Jacques Marais – 2016-08-15T18:53:20.390
Yep. Aka, if your dictionary was ["bin","i"], then "bin" wouldn't be a wordinian because "in" isn't in the dictionary. The function call would be
func("bin",["bin","i"])
– Nathan Merrill – 2016-08-15T18:55:37.060Oh, ok, I see @NathanMerrill. Thanks, I'll use that instead. But how can implement that into the question? – Jacques Marais – 2016-08-15T18:56:51.580
I've edited to suggest how you might word it, rather than trying to discuss it in comments too much. This is just a suggestion so feel free to reverse the edit or amend it to suit your intention. – trichoplax – 2016-08-15T19:08:55.547
What do you mean by "contains"? From the examples it seems to be "contains a substring" rather than "contains a subsequence", but it would be good to make that explicit. – Peter Taylor – 2016-08-15T20:06:09.997
Can I assume the length of the word and the dictionary (and all entries in the dictionary) have length of at least 1? – Οurous – 2016-08-15T22:50:15.090
Does the output have to be a value? Or can it be something else (such as an array) according to our definition of truthy/falsy?
– Luis Mendo – 2016-08-15T22:56:41.060@JacquesMarais UrbanDictionary hardly counts as a valid source for the English language. – mbomb007 – 2016-08-16T21:50:08.403
Three of the ten answers beat the accepted answer in bytes. This is a code-golf, and as such the shortest answer should be the accepted answer. Was there a different winning criterion? – Steven H. – 2016-08-18T19:18:20.417
@JacquesMarais No problem! For the future, if you want to select the answer with the highest votes us here at PPCG call that a
– Steven H. – 2016-08-20T16:46:08.877Popularity-Contest
.