/**
 * Given a range with start and stop parameters, create a subset of the given string by slicing it,
 * and return only the characters that are present in both the range and the string.
 *
 * @param start The starting index of the range.
 * @param stop The stopping index (exclusive) of the range.
 * @param string The input string to extract the subset from.
 * @return A subset of the string containing only the characters that are present in both the range and the string.
 *
 * Example:
 * getIntersectionRange(3, 9, "Hello, World!") // Returns 'lo, Wor'
 *
 * Note:
 * - The start index is inclusive, while the stop index is exclusive.
 * - The characters are case-sensitive.
 * - If the start index is greater than or equal to the stop index, an empty string should be returned.
 */
fun getIntersectionRange(start: Int, stop: Int, string: String): String {

    var subset = ""
    if (start < stop && start < string.length && stop <= string.length) {
        subset = string.substring(start, stop).filter { it in string }
    }
    return subset
}
/**
 * Given a range with start and stop parameters, create a subset of the given string by slicing it,
 * and return only the characters that are present in both the range and the string.
 *
 * @param start The starting index of the range.
 * @param stop The stopping index (exclusive) of the range.
 * @param string The input string to extract the subset from.
 * @return A subset of the string containing only the characters that are present in both the range and the string.
 *
 * Example:
 * getIntersectionRange(3, 9, "Hello, World!") // Returns 'lo, Wor'
 *
 * Note:
 * - The start index is inclusive, while the stop index is exclusive.
 * - The characters are case-sensitive.
 * - If the start index is greater than or equal to the stop index, an empty string should be returned.
 */
fun getIntersectionRange(start: Int, stop: Int, string: String): String {
/**
 * Given a range with start and stop parameters, create a subset of the given string by slicing it,
 * and return only the characters that are present in both the range and the string.
 *
 * @param start The starting index of the range.
 * @param stop The stopping index (exclusive) of the range.
 * @param string The input string to extract the subset from.
 * @return A subset of the string containing only the characters that are present in both the range and the string.
 *
 * Example:
 * getIntersectionRange(3, 9, "Hello, World!") // Returns 'lo, Wor'
 *
 * Note:
 * - The start index is inclusive, while the stop index is exclusive.
 * - The characters are case-sensitive.
 * - If the start index is greater than or equal to the stop index, an empty string should be returned.
 */
fun getIntersectionRange(start: Int, stop: Int, string: String): String {

    var subset = ""
    if (start < stop && start < string.length && stop <= string.length) {
        subset = string.substring(start, stop).filter { it in string }
    }
    return subset
}