According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order).
Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words.
The challenge is to code-golf a program capable of taking a single word as input (assumed lower case, for all intents and purposes) and to return output that (if available) lists all consecutive letter sets (also in lower case) if it is a close-knit word, and empty output if it is not a close-knit word.
Input: education Output: cde Input: foghorn Output: fgh Input: cabaret Output: abc Input: hijacking Output: ghi, hij, ijk Input: pneumonia Output: mno, nop Input: klaxon Output: <<no output>> Input: perform Output: <<no output>> Input: learning Output: <<no output>>
- Whereas input is to be assumed to be a single lower-case word and output must be lower-case, the nature of the output will vary according to the choice of your coding language. Please select a form of output that will best suit the nature of the challenge, whether it be STDOUT, file output, array, etc.
- Because this is code-golf, it will be a case of lowest number of bytes being the clear winner.
- No silly loopholes.
- I will not accept answers that have the consecutive letters in non-alphabetical order... So
cabwill not be deemed a suitable output for
cabaret, for example.
- Special note, while the "triplets" don't necessarily have to be in alphabetical order, but the characters within the triplets must be... so in the case of the word "performance", for example, the output
mno,nopwill be accepted, as will
nop,mno. In the case of the word "hijacking", there are six ways that the triplets of
ijkcould be arranged in a list, and all six permutations are acceptable as output.
Other than that, on your marks, get set, golf!