/**
 * The farmer has a string which represents the types of vegetables he has in his farm. He wants to create a list
 * of tuples, where each tuple contains the vegetable type and the initial quantity. Write a function that takes
 * a string and a character as input, and splits the string into a list of words at the specified character. Then,
 * iterate over the list, and for each word, create a tuple with the vegetable name and initial quantity 1. Finally,
 * return the list of tuples.
 *
 * Example:
 * splitAndAppend("carrot,potato,tomato", ",") -> [('carrot', 1), ('potato', 1), ('tomato', 1)]
 *
 * Note:
 * - The input string will always be non-empty.
 * - The input character will always be present in the string.
 * - The vegetable names do not contain spaces.
 */
fun splitAndAppend(string: String, char: Char): List<Pair<String, Int>> {

    val words = string.split(char)
    val vegetablesTupleList = mutableListOf<Pair<String, Int>>()
    for (word in words) {
        vegetablesTupleList.add(Pair(word, 1))
    }
    return vegetablesTupleList
}
/**
 * The farmer has a string which represents the types of vegetables he has in his farm. He wants to create a list
 * of tuples, where each tuple contains the vegetable type and the initial quantity. Write a function that takes
 * a string and a character as input, and splits the string into a list of words at the specified character. Then,
 * iterate over the list, and for each word, create a tuple with the vegetable name and initial quantity 1. Finally,
 * return the list of tuples.
 *
 * Example:
 * splitAndAppend("carrot,potato,tomato", ",") -> [('carrot', 1), ('potato', 1), ('tomato', 1)]
 *
 * Note:
 * - The input string will always be non-empty.
 * - The input character will always be present in the string.
 * - The vegetable names do not contain spaces.
 */
fun splitAndAppend(string: String, char: Char): List<Pair<String, Int>> {
/**
 * The farmer has a string which represents the types of vegetables he has in his farm. He wants to create a list
 * of tuples, where each tuple contains the vegetable type and the initial quantity. Write a function that takes
 * a string and a character as input, and splits the string into a list of words at the specified character. Then,
 * iterate over the list, and for each word, create a tuple with the vegetable name and initial quantity 1. Finally,
 * return the list of tuples.
 *
 * Example:
 * splitAndAppend("carrot,potato,tomato", ",") -> [('carrot', 1), ('potato', 1), ('tomato', 1)]
 *
 * Note:
 * - The input string will always be non-empty.
 * - The input character will always be present in the string.
 * - The vegetable names do not contain spaces.
 */
fun splitAndAppend(string: String, char: Char): List<Pair<String, Int>> {

    val words = string.split(char)
    val vegetablesTupleList = mutableListOf<Pair<String, Int>>()
    for (word in words) {
        vegetablesTupleList.add(Pair(word, 1))
    }
    return vegetablesTupleList
}