/**
 * This function plays a series of notes with a given tempo.
 *
 * @param notes A list of music notes to be played
 * @param tempo The tempo (in beats per minute) at which the notes should be played
 */
fun playMusic(notes: List<Pair<String, Double>>, tempo: Int) {

    // Define the duration of each beat based on the tempo
    val beatDuration = 60.0 / tempo

    // Initialize the current note index and time elapsed
    var noteIndex = 0
    var elapsedTime = 0.0

    // Outer while loop controlling the entire song playback
    while (noteIndex < notes.size) {
        val currentNote = notes[noteIndex]

        // Inner while loop controlling the timing of each individual note
        while (elapsedTime < currentNote.second) {
            // Play the note
            println(currentNote.first)

            // Sleep for the duration of a beat
            Thread.sleep((beatDuration * 1000).toLong())

            // Increase the elapsed time by one beat
            elapsedTime += beatDuration
        }

        // Move to the next note in the list
        noteIndex++
    }
}
/**
 * This function plays a series of notes with a given tempo.
 *
 * @param notes A list of music notes to be played
 * @param tempo The tempo (in beats per minute) at which the notes should be played
 */
fun playMusic(notes: List<Pair<String, Double>>, tempo: Int) {
/**
 * This function plays a series of notes with a given tempo.
 *
 * @param notes A list of music notes to be played
 * @param tempo The tempo (in beats per minute) at which the notes should be played
 */
fun playMusic(notes: List<Pair<String, Double>>, tempo: Int) {

    // Define the duration of each beat based on the tempo
    val beatDuration = 60.0 / tempo

    // Initialize the current note index and time elapsed
    var noteIndex = 0
    var elapsedTime = 0.0

    // Outer while loop controlling the entire song playback
    while (noteIndex < notes.size) {
        val currentNote = notes[noteIndex]

        // Inner while loop controlling the timing of each individual note
        while (elapsedTime < currentNote.second) {
            // Play the note
            println(currentNote.first)

            // Sleep for the duration of a beat
            Thread.sleep((beatDuration * 1000).toLong())

            // Increase the elapsed time by one beat
            elapsedTime += beatDuration
        }

        // Move to the next note in the list
        noteIndex++
    }
}