/**
 * Given a starting positive integer and an ending positive integer,
 * this function counts the number of patterns that can be created using
 * all the positive integers in between (inclusive).
 *
 * @param start Starting positive integer of the pattern.
 * @param end Ending positive integer of the pattern.
 * @return Number of patterns that can be created.
 *
 * Example:
 * countPatterns(1, 3) -> 6
 * countPatterns(3, 5) -> 20
 * countPatterns(1, 4) -> 24
 */
fun countPatterns(start: Int, end: Int): Int {

    var patternCount = 0

    // Iterate over each positive integer within the specified range
    for (i in start..end) {
        // Consider a positive integer as the first element of the pattern
        // and try to create patterns with other positive integers
        val remainingNumbers = (start..end).toMutableList()
        remainingNumbers.remove(i)

        // Iterate over the remaining positive integers to form the patterns
        for (j in remainingNumbers) {
            patternCount++
        }
    }

    return patternCount
}
/**
 * Given a starting positive integer and an ending positive integer,
 * this function counts the number of patterns that can be created using
 * all the positive integers in between (inclusive).
 *
 * @param start Starting positive integer of the pattern.
 * @param end Ending positive integer of the pattern.
 * @return Number of patterns that can be created.
 *
 * Example:
 * countPatterns(1, 3) -> 6
 * countPatterns(3, 5) -> 20
 * countPatterns(1, 4) -> 24
 */
fun countPatterns(start: Int, end: Int): Int {
/**
 * Given a starting positive integer and an ending positive integer,
 * this function counts the number of patterns that can be created using
 * all the positive integers in between (inclusive).
 *
 * @param start Starting positive integer of the pattern.
 * @param end Ending positive integer of the pattern.
 * @return Number of patterns that can be created.
 *
 * Example:
 * countPatterns(1, 3) -> 6
 * countPatterns(3, 5) -> 20
 * countPatterns(1, 4) -> 24
 */
fun countPatterns(start: Int, end: Int): Int {

    var patternCount = 0

    // Iterate over each positive integer within the specified range
    for (i in start..end) {
        // Consider a positive integer as the first element of the pattern
        // and try to create patterns with other positive integers
        val remainingNumbers = (start..end).toMutableList()
        remainingNumbers.remove(i)

        // Iterate over the remaining positive integers to form the patterns
        for (j in remainingNumbers) {
            patternCount++
        }
    }

    return patternCount
}