Rondo Form is a type of musical structure, in which there is a recurring theme/refrain . Your
Fantastic news! We've Found the answer you've been seeking!
Question:
Rondo Form is a type of musical structure, in which there is a recurring theme/refrain. Your job is to determine whether a given input is a valid Rondo Form or not. Here are the rules for valid Rondo forms:
- Rondo forms always start and end with an A section.
- In between the A sections, there should be contrasting sections(of arbitrary length) notated as B (or BB, BBB, BBBBB, etc), then C, then D, etc... No letter should be skipped.
- There shouldn't be any repeats in the sequence (such as ABBACCA).
Create a program that validates whether a given string is a valid Rondo Form.
- Inputs will be given as all uppercase.
- For the purpose of this problem, accept ABA(ACA, ADA, etc) as valid Rondo Forms. In other words, we allow a single section to be repeated in this problem; however, double, triple, etc. sections can NOT be repeated(per 3rd bullet above).
Examples
ABACADAEAFAGAHAIAJA ? True ABA ? True ABBACCA ? False ACAC ?False A ? False ABBACCCADAEA ? True
Sample Input 1
ABBACADA
Sample Output 1
True
Related Book For
Posted Date: