Let's say you write a passage and you are close to the end of the line wanting to write down a large word. In most languages, you just leave some blank and move to the next line, like a sir.
Example - English:
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah this man is unaccountable
But if you are (un)lucky enough to be Greek, when you are close to terminate a line, you cannot just move to the next one. Everything must look nice and in balance, so you SEPARATE the word
Example - Greek:
μπλα μπλα μπλα μπλα μπλα μπλα μπλα μπλα μπλα μπλα μπλα μπλα αυτός ο άνδρας είναι ανεξή-
Of course this separation is not done randomly, but instead there is a complicated set of rules, as to how & when to separate, which is actually an entire learning chapter back in primary school that every kid hates.
You are given a greek word (just a string of greek letters). You need to do a greek syllabication, i.e. separate the greek word in syllabes, according to the set of rules given below, so that the user will have the option to separate the word in the end of the line correctly.
1) αγαπη (love) = α-γα-πη
2) ακροπολη (acropolis) = α-κρο-πο-λη
3) βασικα (basically) = βα-σι-κα
ALPHABET & SIMPLIFIED RULES
rule 0) Every vowel defines a different syllable, unless rule 4
rule 1) When there is consonant between two vowels, it goes with the second vowel
(ex. γ --> α-γα-πη)
rule 2) When there are two consonants between two vowels, they go with the second vowel, if there is a greek word starting from these two consonants (we assume that that's always the case in our exercise)
(ex. βλ --> βι-βλι-ο)
rule 3) When we have 3 consonants between two vowels-->same as rule 2
rule 4) Following configurations are considered as "one letter" and are never separated: ει, οι, υι, αι, ου, μπ, ντ, γκ, τσ, τζ
rule 5) Always separate same consonants (ex. αλ-λη)
Your code should take as input string (or some other format you wish) a greek word and return the same word, with dashes in between, determining the points where the word can be separated, i.e. do a greek syllabication.
TestCases: [πολη (city)] --> [πο-λη] [τρεχω (run)] --> [τρε-χω] [αναβαση (climbing)] --> [α-να-βα-ση] [οαση (oasis)] --> [ο-α-ση] [ουρα (tail)] --> [ου-ρα] [μπαινω (enter)] --> [μπαι-νω] [εχθροι (enemies)] --> [ε-χθροι] [ελλαδα (greece)] --> [ελ-λα-δα] [τυροπιτα (cheese pie)] --> [τυ-ρο-πι-τα] [αρρωστη (sick)] --> [αρ-ρω-στη]
Shortest code wins, but every effort is appreciated :)