# Input/Output Problem #2

See here for basic rules on problem.

Input/Output Problem #1

Problem #2

Make an optimal machine that accepts any letter combination that begins with a consonant and alternates vowel consonant from then on. ("Y" is considered both vowel and consonant)

– user52327
Nov 14, 2018 at 14:45

Vowel: A,E,I,O,U,Y
Consonant: B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z

Original Edits:

...

• I thought of that too, but can an input/output diagram have two ends? Nov 14, 2018 at 11:45
• @OmegaKrypton I'm not absolutely sure but I rather think you can have 2 ends :)
– user52327
Nov 14, 2018 at 11:48
• This diagram fails if the string is a single "Y". Should Y be also listed in the consonants? Thanks Nov 14, 2018 at 11:48
• You don't need a point for fail, you just need a Start and any sequence that doesn't end on a red dotted circle fails. Also yes you can have multiple ends. Nov 14, 2018 at 11:48
• It also accepts an empty string, but an empty string does not begin with a consonant. Nov 14, 2018 at 12:09

Can I have:

$$\oplus\xrightarrow{consonant}\color{red}\bullet\xrightarrow{\;\;vowel\;\;}\color{red}\bullet$$
$$\qquad\qquad\quad\,\mid\qquad\qquad\mid$$
$$\qquad\qquad\quad\,\xleftarrow{\;consonant\;}$$

• Not correct if the sequence ends with a vowel. Nov 14, 2018 at 12:31
• @BenFranks; oh right, so is this any better?
– JMP
Nov 14, 2018 at 12:35
• it is correct now but can be optimised. Remember the start can be an end. Nov 14, 2018 at 12:38
• like this? I did move the \oplus to the last red, but this accepts an empty string, which I feel is cheating
– JMP
Nov 14, 2018 at 12:41
• this is correct :) Nov 14, 2018 at 12:49

I think it is following since its not specified that if it should end on vowel or consonant.

If the failed state is must,

If it should alternate and end on consonant then:

• It shall alternate ... this is not correct
– user52327
Nov 14, 2018 at 11:53
• @Jannis I have edited my answer please check Nov 14, 2018 at 11:55
• It shall not end on an consonant ... read the question again
– user52327
Nov 14, 2018 at 11:55
• @Jannis where is that in the question? Nov 14, 2018 at 11:56
• Nowhere stands sth about how to end the chain ...
– user52327
Nov 14, 2018 at 11:57

My solution has 5 nodes.
(EDIT: I made it too complicated, and a 3-node solution is possible. I'm leaving this answer as-is, because it works and is interesting.)

Note that the Consonant and Vowel labels in the picture exclude Y, e.g. Vowel means AEIOU only.

It does not accept an empty string.
It accepts a string of Y's.
It accepts a string starting with any even number of Y's only if it is followed by a consonant, but not if it is followed by a vowel.
It accepts a string starting with any odd number of Y's only if it is followed by a vowel, but not if it is followed by a consonant.
The left two nodes of the square deal with any Y prefixes. The right two nodes are used once a non-Y has been seen. I needed the extra starting node in order to disallow an empty string, since the question says the string must begin with a consonant.

Pen-and-paper solution... doop de doo.

• Your solution would accept a sequence that begins with a vowel which breaks one of the requirements. Nov 14, 2018 at 11:53
• @BenFranks Rats, you're right...
– Jafe
Nov 14, 2018 at 11:54

My attempt:

I don't know if the "But not Y" part is neccessary, but here goes

• MS Paint lives on! Nov 14, 2018 at 14:12

You can shape it like a triangle. 3 way solution. This assumes what Y is both consonant and vowel, basiclly it cycles between Start and the node O until the rule is broken.

 c c ---> ---> Start O Fail <--- ---> a a