Guitar has six major chords A, B, C, D, E and F
Suppose it takes 1 sec to play one chord.
A sweet melody is defined by a regular expression pattern (for eg E*(F|A) + B)
A band wants to play a melody for X seconds. What is the minimun margin of error(in terms of the number of seconds) the band can
encounter.
X < 500
melody pattern length < 30
This question looks nice. Can you add more details? Like what are the symbols allowed for regex?
@sundar1995
The symbol allowed in the regex are - *, +, |
@ajkrish95
X* means 0 or more occurrence of X. Example ( “”, “X”, “XX”, “XXX” … )
X+ means 1 or more occurrence of X. Example (“X”, “XX”, “XXX”, … )
X|Y means either X or Y
() helps to treat the expression inside () as one entity.
For the pattern given in the question - E*(F|A)+B. All these are valid string - FB, AB, EAB, EFB, EFAB, EFFB, EEEFFAFFAAB and so on.