Toki pona is a minimalist constructed language, and thus it has minimalist phonotactics (rules describing what sounds make valid words).
Toki Pona has 8 consonant sounds
j and 5 vowel sounds
u. A single basic syllable in toki pona consists of any 1 consonant, any one vowel and optionally an
n. So all of the following are valid:
pi ko wa san jen
There are four exceptions of sequences that are forbidden they are
ji, wu, wo, ti.
With the basic syllables we can build words. A word is just a string of basic syllables with two special rules:
- When we have an
nfollowed by either
mwe drop the
- The initial syllable of a word can drop the initial consonant. e.g.
pawenare both legal and distinct words. This does allow for words consisting of just a vowel.
Your task is to take a non-empty string consisting of lowercase alphabetic characters (
z) and determine if it makes a valid toki pona word.
When the input is a valid word you should output one value and when it is not you should output another distinct value.
This is code-golf so answers will be scored in bytes with the goal being to minimize the size of the source.
awen jan e monsuta kepekin ike sinpin pakala tamako jamo pankulato pawen an nene nenen
bimi ponas plani womo won tin wu miji sunmo anna sam kain op p n