/**
 * Given a list of integers and a number, append the number to the list and return a Pair containing the updated list
 * and the sum of all the elements in the list.
 *
 * @param lst A list of integers.
 * @param num An integer to append to the list.
 * @return A Pair containing the updated list and the sum of all the elements in the list.
 *
 * Example:
 * appendToListAndReturnTuple(listOf(1, 2, 3), 4)
 * Output: ([1, 2, 3, 4], 10)
 */
fun appendToListAndReturnTuple(lst: MutableList<Int>, num: Int): Pair<List<Int>, Int> {

    lst.add(num)
    return Pair(lst, lst.sum())
}
/**
 * Given a list of integers and a number, append the number to the list and return a Pair containing the updated list
 * and the sum of all the elements in the list.
 *
 * @param lst A list of integers.
 * @param num An integer to append to the list.
 * @return A Pair containing the updated list and the sum of all the elements in the list.
 *
 * Example:
 * appendToListAndReturnTuple(listOf(1, 2, 3), 4)
 * Output: ([1, 2, 3, 4], 10)
 */
fun appendToListAndReturnTuple(lst: MutableList<Int>, num: Int): Pair<List<Int>, Int> {
/**
 * Given a list of integers and a number, append the number to the list and return a Pair containing the updated list
 * and the sum of all the elements in the list.
 *
 * @param lst A list of integers.
 * @param num An integer to append to the list.
 * @return A Pair containing the updated list and the sum of all the elements in the list.
 *
 * Example:
 * appendToListAndReturnTuple(listOf(1, 2, 3), 4)
 * Output: ([1, 2, 3, 4], 10)
 */
fun appendToListAndReturnTuple(lst: MutableList<Int>, num: Int): Pair<List<Int>, Int> {

    lst.add(num)
    return Pair(lst, lst.sum())
}