Challenge: Advanced Formatted Tavern Menu

Hello! I would to share my solution for the second challenge. I would appreciate any feedback!

const val LIST_WIDTH = 45
val menuList = File("data/tavern-menu-items.txt")
    .readText()
    .split("\n")
    .toMutableList()

fun main() {
    val header = "Welcome to $TAVERN_NAME"
    val headerLength = header.length
    val indentForHeader = constructIndent("*", (LIST_WIDTH - headerLength - 2) / 2)
    print("\n$indentForHeader $header $indentForHeader\n\n")

    while (menuList.isNotEmpty()) {
        val (category) = menuList[0].split(",")
        val indentForCategory = constructIndent(" ", (LIST_WIDTH - category.length - 4) / 2)
        println("$indentForCategory~[$category]~$indentForCategory")

        for (i in (0 until menuList.size).reversed()) {
            val (currentItemCategory, itemName, price) = menuList[i].split(",")
            if (currentItemCategory == category) {
                printItem(itemName, price)
                menuList.removeAt(i)
            }
        }
    }

/*    patronList.forEachIndexed { index, patron ->
        println("Good evening, $patron -- you are #${index + 1} in line.")
        placeOrder(patron, menuList.shuffled().first())
    }

    (0..9).forEach {
        val first = patronList.shuffled().first()
        val last = lastName.shuffled().first()
        val name = "$first $last"
        uniquePatrons += name
    }
    println(uniquePatrons)

    var orderCount = 0
    while (orderCount <= 9) {
        placeOrder(uniquePatrons.shuffled().first(), menuList.shuffled().first())
        orderCount++
    }*/
}

private fun constructIndent(symbol: String, rep: Int): String {
    val result = StringBuilder()
    repeat(rep) {
        result.append(symbol)
    }
    return result.toString()
}

private fun printItem(itemName: String, price: String) {
    val itemWords: MutableList<String> = itemName.split(" ").toMutableList()
    itemWords.forEachIndexed { index, word ->
        when (word.toLowerCase()) {
            "of" -> {}
            else -> itemWords[index] = word.capitalize()
        }
    }
    val itemCapitalized = itemWords.joinToString(" ")
    val space = constructIndent(".", LIST_WIDTH - itemName.length - price.length)
    print("$itemCapitalized$space$price\n")
}

This was challenging! But here is my solution:

fun displayMenu(menuList: List<String>) {

    // Types
    val typeSet = mutableSetOf<String>()
    menuList.forEach {data ->
        val type = data.split(',')[0]
        typeSet.add(type)
    }

    // Menu Header
    val menuHeader = "*** Welcome to Taernyl's Folly ***"
    println(menuHeader)

    // Menu Items
    typeSet.forEach { type ->

        // Type
        val typePadding = (menuHeader.length + type.length) / 2
        println("~[${type.capitalize()}]~".padStart(typePadding))

        // Items
        menuList.forEach { menuData: String ->
            val data = menuData.split(',')
            if (data[0] == type) {
                val type = data[0]
                val name = data[1]
                val price = data[2]

                // Capitalize
                val capitalizedName = name.split(" ").joinToString(" ") { word ->
                    word.capitalize()
                }

                val itemPadding = menuHeader.length - price.length - 1
                println("${capitalizedName.padEnd(itemPadding, '.')}\$$price")
            }
        }

    }
}