/**
 * Given a music sheet and an index, this function will attempt to find the length of the note at the given index.
 * The music sheet is represented as a list of pairs, where each pair represents a note and its length.
 * The pairs are formatted as Pair(note: String, length: Int) where 'note' is a string representing the note and 'length' is an integer representing the length of the note.
 *
 * @param musicSheet A list representing the music sheet.
 * @param index The index of the note to find the length.
 * @return The length of the note at the given index.
 *
 * Example:
 * musicSheet = listOf(Pair("C", 4), Pair("D", 8), Pair("E", 16), Pair("F", 32))
 * findNoteLength(musicSheet, 2) // 16
 */
fun findNoteLength(musicSheet: List<Pair<String, Int>>, index: Int): Int {

    return try {
        // Access the note at the given index
        val (_, length) = musicSheet[index]
        length
    } catch (e: IndexOutOfBoundsException) {
        // Handle IndexOutOfBoundsException when the note does not have a length
        0
    }
}
/**
 * Given a music sheet and an index, this function will attempt to find the length of the note at the given index.
 * The music sheet is represented as a list of pairs, where each pair represents a note and its length.
 * The pairs are formatted as Pair(note: String, length: Int) where 'note' is a string representing the note and 'length' is an integer representing the length of the note.
 *
 * @param musicSheet A list representing the music sheet.
 * @param index The index of the note to find the length.
 * @return The length of the note at the given index.
 *
 * Example:
 * musicSheet = listOf(Pair("C", 4), Pair("D", 8), Pair("E", 16), Pair("F", 32))
 * findNoteLength(musicSheet, 2) // 16
 */
fun findNoteLength(musicSheet: List<Pair<String, Int>>, index: Int): Int {
/**
 * Given a music sheet and an index, this function will attempt to find the length of the note at the given index.
 * The music sheet is represented as a list of pairs, where each pair represents a note and its length.
 * The pairs are formatted as Pair(note: String, length: Int) where 'note' is a string representing the note and 'length' is an integer representing the length of the note.
 *
 * @param musicSheet A list representing the music sheet.
 * @param index The index of the note to find the length.
 * @return The length of the note at the given index.
 *
 * Example:
 * musicSheet = listOf(Pair("C", 4), Pair("D", 8), Pair("E", 16), Pair("F", 32))
 * findNoteLength(musicSheet, 2) // 16
 */
fun findNoteLength(musicSheet: List<Pair<String, Int>>, index: Int): Int {

    return try {
        // Access the note at the given index
        val (_, length) = musicSheet[index]
        length
    } catch (e: IndexOutOfBoundsException) {
        // Handle IndexOutOfBoundsException when the note does not have a length
        0
    }
}