/**
 * This exercise requires the carpenter to perform negative indexing and string concatenation operations.
 *
 * The carpenter needs to return a new string by concatenating two given strings based on the provided index.
 * The index specifies the position from the end of the first string where the concatenation should occur.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @param index The index position from the end of string1 where the concatenation should occur.
 * @return The new string obtained by concatenating the two given strings.
 *
 * Example:
 * carpenterTask("woodworking", "masterpiece", 3) => "woodmasterpiece"
 * carpenterTask("beautiful", "artwork", 4) => "beautywork"
 */
fun carpenterTask(string1: String, string2: String, index: Int): String {

    val newString = string1.takeLast(index) + string2  // Perform string concatenation using negative indexing
    return newString
}
/**
 * This exercise requires the carpenter to perform negative indexing and string concatenation operations.
 *
 * The carpenter needs to return a new string by concatenating two given strings based on the provided index.
 * The index specifies the position from the end of the first string where the concatenation should occur.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @param index The index position from the end of string1 where the concatenation should occur.
 * @return The new string obtained by concatenating the two given strings.
 *
 * Example:
 * carpenterTask("woodworking", "masterpiece", 3) => "woodmasterpiece"
 * carpenterTask("beautiful", "artwork", 4) => "beautywork"
 */
fun carpenterTask(string1: String, string2: String, index: Int): String {
/**
 * This exercise requires the carpenter to perform negative indexing and string concatenation operations.
 *
 * The carpenter needs to return a new string by concatenating two given strings based on the provided index.
 * The index specifies the position from the end of the first string where the concatenation should occur.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @param index The index position from the end of string1 where the concatenation should occur.
 * @return The new string obtained by concatenating the two given strings.
 *
 * Example:
 * carpenterTask("woodworking", "masterpiece", 3) => "woodmasterpiece"
 * carpenterTask("beautiful", "artwork", 4) => "beautywork"
 */
fun carpenterTask(string1: String, string2: String, index: Int): String {

    val newString = string1.takeLast(index) + string2  // Perform string concatenation using negative indexing
    return newString
}