/**
 * This exercise focuses on slicing a list based on a given selection, start, and end index.
 *
 * @param selection a list of indices representing the selected elements
 * @param start an integer representing the start index of the sublist
 * @param end an integer representing the end index of the sublist
 * @return a sublist extracted from the given selection list based on the provided start and end index
 *
 * Task:
 * - Extract a sublist from the given selection list based on the provided start and end index.
 * - Return the sublist as a new list.
 *
 * Note:
 * - The solution should handle the case where the start or end index is not a valid entry in the selection list.
 * - Negative indices should be treated like positive indices.
 *
 * Hint:
 * - Use list slicing to extract the desired sublist.
 */
fun cutSelectionStartEnd(selection: List<Int>, start: Int, end: Int): List<Int> {

    val normalizedStart = if (start < 0) selection.size + start else start
    val normalizedEnd = if (end < 0) selection.size + end else end
    return selection.slice(IntRange(normalizedStart, normalizedEnd))
}
/**
 * This exercise focuses on slicing a list based on a given selection, start, and end index.
 *
 * @param selection a list of indices representing the selected elements
 * @param start an integer representing the start index of the sublist
 * @param end an integer representing the end index of the sublist
 * @return a sublist extracted from the given selection list based on the provided start and end index
 *
 * Task:
 * - Extract a sublist from the given selection list based on the provided start and end index.
 * - Return the sublist as a new list.
 *
 * Note:
 * - The solution should handle the case where the start or end index is not a valid entry in the selection list.
 * - Negative indices should be treated like positive indices.
 *
 * Hint:
 * - Use list slicing to extract the desired sublist.
 */
fun cutSelectionStartEnd(selection: List<Int>, start: Int, end: Int): List<Int> {
/**
 * This exercise focuses on slicing a list based on a given selection, start, and end index.
 *
 * @param selection a list of indices representing the selected elements
 * @param start an integer representing the start index of the sublist
 * @param end an integer representing the end index of the sublist
 * @return a sublist extracted from the given selection list based on the provided start and end index
 *
 * Task:
 * - Extract a sublist from the given selection list based on the provided start and end index.
 * - Return the sublist as a new list.
 *
 * Note:
 * - The solution should handle the case where the start or end index is not a valid entry in the selection list.
 * - Negative indices should be treated like positive indices.
 *
 * Hint:
 * - Use list slicing to extract the desired sublist.
 */
fun cutSelectionStartEnd(selection: List<Int>, start: Int, end: Int): List<Int> {

    val normalizedStart = if (start < 0) selection.size + start else start
    val normalizedEnd = if (end < 0) selection.size + end else end
    return selection.slice(IntRange(normalizedStart, normalizedEnd))
}