/**
 * This function searches for books in the library based on genre and author.
 *
 * @param library A nested list containing books. Each book is represented as a list with elements [title, genre, author].
 * @param genre The genre of the books to search for.
 * @param author The author of the books to search for.
 * @return A list of titles of books that match the genre and author.
 */
fun searchBooks(library: List<List<String>>, genre: String, author: String): List<String> {

    val matchingBooks = mutableListOf<String>()

    for (book in library) {
        if (book[1] == genre && book[2] == author) {
            matchingBooks.add(book[0])
        }
    }

    return matchingBooks
}

val library = listOf(
    listOf("Book 1", "Fiction", "Author 1"),
    listOf("Book 2", "Fantasy", "Author 2"),
    listOf("Book 3", "Fiction", "Author 1"),
    listOf("Book 4", "Mystery", "Author 3"),
    listOf("Book 5", "Fantasy", "Author 2"),
    listOf("Book 6", "Science Fiction", "Author 4")
)
/**
 * This function searches for books in the library based on genre and author.
 *
 * @param library A nested list containing books. Each book is represented as a list with elements [title, genre, author].
 * @param genre The genre of the books to search for.
 * @param author The author of the books to search for.
 * @return A list of titles of books that match the genre and author.
 */
fun searchBooks(library: List<List<String>>, genre: String, author: String): List<String> {
/**
 * This function searches for books in the library based on genre and author.
 *
 * @param library A nested list containing books. Each book is represented as a list with elements [title, genre, author].
 * @param genre The genre of the books to search for.
 * @param author The author of the books to search for.
 * @return A list of titles of books that match the genre and author.
 */
fun searchBooks(library: List<List<String>>, genre: String, author: String): List<String> {

    val matchingBooks = mutableListOf<String>()

    for (book in library) {
        if (book[1] == genre && book[2] == author) {
            matchingBooks.add(book[0])
        }
    }

    return matchingBooks
}

val library = listOf(
    listOf("Book 1", "Fiction", "Author 1"),
    listOf("Book 2", "Fantasy", "Author 2"),
    listOf("Book 3", "Fiction", "Author 1"),
    listOf("Book 4", "Mystery", "Author 3"),
    listOf("Book 5", "Fantasy", "Author 2"),
    listOf("Book 6", "Science Fiction", "Author 4")
)