/**
 * Given a list of game elements and a list of new elements,
 * append the new elements to the game elements only if they
 * are not already present.
 *
 * @param gameElements List of game elements.
 * @param newElements List of new elements to be appended.
 * @return Updated list of game elements.
 *
 * Examples:
 * appendNewElements(listOf("sword", "shield"), listOf("bow", "sword")) // Output: ['sword', 'shield', 'bow']
 * appendNewElements(listOf("enemy", "tree"), listOf("tree", "rock")) // Output: ['enemy', 'tree', 'rock']
 */
fun appendNewElements(gameElements: MutableList<String>, newElements: List<String>): List<String> {

    for (element in newElements) {
        if (element !in gameElements) {
            gameElements.add(element)
        }
    }
    return gameElements
}
/**
 * Given a list of game elements and a list of new elements,
 * append the new elements to the game elements only if they
 * are not already present.
 *
 * @param gameElements List of game elements.
 * @param newElements List of new elements to be appended.
 * @return Updated list of game elements.
 *
 * Examples:
 * appendNewElements(listOf("sword", "shield"), listOf("bow", "sword")) // Output: ['sword', 'shield', 'bow']
 * appendNewElements(listOf("enemy", "tree"), listOf("tree", "rock")) // Output: ['enemy', 'tree', 'rock']
 */
fun appendNewElements(gameElements: MutableList<String>, newElements: List<String>): List<String> {
/**
 * Given a list of game elements and a list of new elements,
 * append the new elements to the game elements only if they
 * are not already present.
 *
 * @param gameElements List of game elements.
 * @param newElements List of new elements to be appended.
 * @return Updated list of game elements.
 *
 * Examples:
 * appendNewElements(listOf("sword", "shield"), listOf("bow", "sword")) // Output: ['sword', 'shield', 'bow']
 * appendNewElements(listOf("enemy", "tree"), listOf("tree", "rock")) // Output: ['enemy', 'tree', 'rock']
 */
fun appendNewElements(gameElements: MutableList<String>, newElements: List<String>): List<String> {

    for (element in newElements) {
        if (element !in gameElements) {
            gameElements.add(element)
        }
    }
    return gameElements
}