Removing chords

Report a typo

Wow! This problem is kind of tricky. If you're ready to put your thinking cap on, brace yourself, and good luck! Otherwise, you can skip it for now and return any time later.

You have the lyrics of a song; however, it was written by a guitarist who put chords within the text. It was a beginner guitarist, so he only knows the Am, A, Em, E, Dm, D, G, and C chords.

Write a program that reads the lyrics of a song, removes all chords with extra spaces from it, and prints out the clean lyrics text.

Input: text: String

Output: cleanText: String

Sample Input 1:

Am C G I'm waking up to ash and dust D Am I wipe my brow and I sweat my rust C G D I'm breathing in the chemicals. Am C G I'm breaking in, shaping up, D then checking out on the prison bus Am C G This is it, the apocalypse. G Whoa

Sample Output 1:

I'm waking up to ash and dust I wipe my brow and I sweat my rust I'm breathing in the chemicals. I'm breaking in, shaping up, then checking out on the prison bus This is it, the apocalypse. Whoa

Sample Input 2:

G D Em C When I find myself in times of trouble, Mother Mary comes to me G D C G Speaking words of wisdom, let it be G D Em C And in my hour of darkness, She is standing right in front of me G D C G Speaking words of wisdom, Let it be

Sample Output 2:

When I find myself in times of trouble, Mother Mary comes to me Speaking words of wisdom, let it be And in my hour of darkness, She is standing right in front of me Speaking words of wisdom, Let it be
Write a program in Kotlin
fun main() {
val text = readln()

}
___

Create a free account to access the full topic