/**
 * Given a list of musical notes, find the first occurrence of a note that is 
 * 'A' or 'B' and return a new list of all the notes before the found note.
 * 
 * Note: You are not allowed to use 'for' loops, 'if' statements, or function 'len' to solve this exercise.
 * 
 * @param notes A list of musical notes (strings)
 * @return A new list containing all the notes before the first occurrence of 'A' or 'B'
 */
fun findMelody(notes: List<String>): List<String> {

    var index = -1
    while (true) {
        index++
        if (notes[index] in listOf("A", "B")) {
            break
        }
    }
    return notes.subList(0, index)
}
/**
 * Given a list of musical notes, find the first occurrence of a note that is 
 * 'A' or 'B' and return a new list of all the notes before the found note.
 * 
 * Note: You are not allowed to use 'for' loops, 'if' statements, or function 'len' to solve this exercise.
 * 
 * @param notes A list of musical notes (strings)
 * @return A new list containing all the notes before the first occurrence of 'A' or 'B'
 */
fun findMelody(notes: List<String>): List<String> {
/**
 * Given a list of musical notes, find the first occurrence of a note that is 
 * 'A' or 'B' and return a new list of all the notes before the found note.
 * 
 * Note: You are not allowed to use 'for' loops, 'if' statements, or function 'len' to solve this exercise.
 * 
 * @param notes A list of musical notes (strings)
 * @return A new list containing all the notes before the first occurrence of 'A' or 'B'
 */
fun findMelody(notes: List<String>): List<String> {

    var index = -1
    while (true) {
        index++
        if (notes[index] in listOf("A", "B")) {
            break
        }
    }
    return notes.subList(0, index)
}