/**
 * This function takes in a list of skeletons and an integer numPieces. It concatenates the pieces of each skeleton into a single string in alphabetical order.
 * The function then checks if the length of the resulting string is equal to or greater than numPieces. If it is, it returns the concatenated string, otherwise, it returns null.
 *
 * @param skeletons A list of strings representing individual skeleton pieces.
 * @param numPieces An integer representing the minimum number of combined skeleton pieces required.
 * @return The concatenated string of skeleton pieces if the length is equal to or greater than numPieces, otherwise null.
 *
 * Example:
 * combineSkeletons(listOf("skull", "femur", "ribcage", "arm"), 7) -> "armfemurribcageskull"
 * combineSkeletons(listOf("skull", "femur", "ribcage"), 10) -> null
 */
fun combineSkeletons(skeletons: List<String>, numPieces: Int): String? {

    val combinedString = skeletons.sorted().joinToString("")

    return if (combinedString.length >= numPieces) {
        combinedString
    } else {
        null
    }
}
/**
 * This function takes in a list of skeletons and an integer numPieces. It concatenates the pieces of each skeleton into a single string in alphabetical order.
 * The function then checks if the length of the resulting string is equal to or greater than numPieces. If it is, it returns the concatenated string, otherwise, it returns null.
 *
 * @param skeletons A list of strings representing individual skeleton pieces.
 * @param numPieces An integer representing the minimum number of combined skeleton pieces required.
 * @return The concatenated string of skeleton pieces if the length is equal to or greater than numPieces, otherwise null.
 *
 * Example:
 * combineSkeletons(listOf("skull", "femur", "ribcage", "arm"), 7) -> "armfemurribcageskull"
 * combineSkeletons(listOf("skull", "femur", "ribcage"), 10) -> null
 */
fun combineSkeletons(skeletons: List<String>, numPieces: Int): String? {
/**
 * This function takes in a list of skeletons and an integer numPieces. It concatenates the pieces of each skeleton into a single string in alphabetical order.
 * The function then checks if the length of the resulting string is equal to or greater than numPieces. If it is, it returns the concatenated string, otherwise, it returns null.
 *
 * @param skeletons A list of strings representing individual skeleton pieces.
 * @param numPieces An integer representing the minimum number of combined skeleton pieces required.
 * @return The concatenated string of skeleton pieces if the length is equal to or greater than numPieces, otherwise null.
 *
 * Example:
 * combineSkeletons(listOf("skull", "femur", "ribcage", "arm"), 7) -> "armfemurribcageskull"
 * combineSkeletons(listOf("skull", "femur", "ribcage"), 10) -> null
 */
fun combineSkeletons(skeletons: List<String>, numPieces: Int): String? {

    val combinedString = skeletons.sorted().joinToString("")

    return if (combinedString.length >= numPieces) {
        combinedString
    } else {
        null
    }
}