[
  {
    "path": ".gitignore",
    "content": "*.class\n*.jar\n*.war\n*.ear\n/.idea/\nDiscreteMathToolkit.iml\nout/\ngradle.properties\n*.log\n*.ctxt\n.mtj.tmp/\n*.zip\n*.tar.gz\n*.rar\nhs_err_pid*\n.gradle/\nbuild/\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: java\n\njdk:\n  - oraclejdk8\n\ninstall: true\n\nscript:\n  - ./gradlew check\n\nafter_success:\n  - bash <(curl -s https://codecov.io/bash)"
  },
  {
    "path": "KotlinDiscreteMathToolkit.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\"KotlinDiscreteMathToolkit\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$\" external.system.id=\"GRADLE\" external.system.module.group=\"com.marcinmoskala\" external.system.module.version=\"1.0.3\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"NewModuleRootManager\" inherit-compiler-output=\"true\">\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <excludeFolder url=\"file://$MODULE_DIR$/.gradle\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/out\" />\n    </content>\n    <orderEntry type=\"inheritedJdk\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n  </component>\n</module>"
  },
  {
    "path": "README.md",
    "content": "# DiscreteMathToolkit\nSet of extensions for Kotlin that provides Discrete Math functionalities as an Kotlin extension functions.\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.marcinmoskala/DiscreteMathToolkit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.marcinmoskala/DiscreteMathToolkit)\n[![Build Status](https://travis-ci.org/MarcinMoskala/KotlinDiscreteMathToolkit.svg?branch=master)](https://travis-ci.org/MarcinMoskala/KotlinDiscreteMathToolkit)\n[![codecov](https://codecov.io/gh/MarcinMoskala/KotlinDiscreteMathToolkit/branch/master/graph/badge.svg)](https://codecov.io/gh/MarcinMoskala/KotlinDiscreteMathToolkit)\n[![codebeat badge](https://codebeat.co/badges/70bb9b0e-a47e-477a-933d-adc7220ae926)](https://codebeat.co/projects/github-com-marcinmoskala-kotlindiscretemathtoolkit-master)\n[![Analytics](https://ga-beacon.appspot.com/UA-92159206-7/main-page?pixel)](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit)\n\nTo stay current with news about library [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40marcinmoskala)](https://twitter.com/marcinmoskala?ref_src=twsrc%5Etfw)\n\n# Permutations\n\n```kotlin\nsetOf(1, 2, 3).permutations() // {[1, 2, 3], [2, 1, 3], [3, 2, 1], [1, 3, 2], [2, 3, 1], [3, 1, 2]}\nsetOf(1, 2, 3).permutationsNumber() // 6\nlistOf(1, 2, 2).permutations() // {[1, 2, 2], [2, 1, 2], [2, 2, 1]}\nlistOf(1, 2, 2).permutationsNumber() // 3\n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/PermutationTest.kt)\n\n# Combinations\n\n```kotlin\nsetOf(1, 2, 3, 4).combinations(3) // { {1, 2, 3}, {1, 2, 4}, {1, 4, 3}, {4, 2, 3} }\nsetOf(1, 2, 3, 4).combinationNumber(3) // 4\n\nsetOf(1, 2, 3, 4).combinationsWithRepetitions(2) // [{1=2}, {1=1, 2=1}, {1=1, 3=1}, {1=1, 4=1}, {2=2}, {2=1, 3=1}, {2=1, 4=1}, {3=2}, {3=1, 4=1}, {4=2}]\nsetOf(1, 2, 3, 4).combinationsWithRepetitionsNumber(2) // 10\n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/CombinationTest.kt) and [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/CombinationWithRepetitionTest.kt)\n\n# Powerset\nPowerset of any set S is the set of all subsets of S, including the empty set and S itself.\n\n```kotlin\nsetOf(1, 2, 3).powerset() // { {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} }\nsetOf(1, 2, 3).powersetSize() // 8\n```\n# Product\nProduct is the result of multiplying. \n\n```kotlin\n(3..4).product() // 12\nlistOf(10, 10, 10).product() // 1000\n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/ProductTest.kt).\n\n# Factorial\nFactorian of n (n!) is a product of all positive integers less than or equal to n. \n\n```kotlin\n3.factorial() // 6L\n10.factorial() // 3628800L\n20.factorial() // 2432902008176640000L\n```\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/FactorialTest.kt).\n\n# Numbers divisible and non-divisible by\n\n```kotlin\n(1..1000).countNonDivisiveBy(2) // 500\n(1..1000).countNonDivisiveBy(3) // 777\n(1..1000).countNonDivisiveBy(2, 6, 13) // 462\n(1..1000).countNonDivisiveBy(3, 7, 11) // 520\n\n(1..1000).countDivisiveBy(2) // 500\n(1..1000).countDivisiveBy(3) // 333\n(1..1000).countDivisiveBy(2, 6, 13) // 538\n(1..1000).countDivisiveBy(3, 7, 11) // 480\n```\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/NumbersDivisibleTest.kt).\n\n# Splits of sets and numbers\nIn Descrete Math there are two functions used to count number of splits:\nS(n, k) - Stirling function - number of splits of n different elements to k groups\nP(n, k) - number of splits of n identical elements to k groups\n\n```kotlin\n(1..n).toSet().splitsNumber(1) // 1\n(1..n).toSet().splitsNumber(n) // 1\nsetOf(1, 2, 3).splitsNumber(2) // 3\nsetOf(1, 2, 3, 4).splitsNumber(2) // 7\nsetOf(1, 2, 3, 4, 5).splitsNumber(3) // 25\nsetOf(1, 2, 3, 4, 5, 6, 7).splitsNumber(4) // 350\nsetOf(1, 2, 3).splits(2) // { { {1, 2}, {3} },{ {1, 3}, {2} },{ {3, 2}, {1} } }\n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/SetSplitTest.kt)\n\n```kotlin\nn.splitsNumber(1) // 1\nn.splitsNumber(n) // 1\n7.splitsNumber(4) // 3\n11.splitsNumber(4) // 11\n9.splitsNumber(5) // 5\n13.splitsNumber(8) // 7\n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/NumberSplitTest.kt)\n\n# Iterable multiplication\n\nMultiplication of iterables returns iterable with pairs of each possible connections of elements from first and iterable:\n\n```kotlin\nlistOf(1, 2) * listOf(\"A\", \"B\") // returns List<Pair<Int, String>>\n// [(1, \"A\"), (1, \"B\"), (2, \"A\"), (2, \"B\")] \nlistOf('a', 'b') * listOf(1, 2) * listOf(\"A\", \"B\") // returns List<Triple<Char, Int, String>>\n// [\n//    ('a', 1, \"A\"), ('a', 1, \"B\"), \n//    ('a', 2, \"A\"), ('a', 2, \"B\"), \n//    ('b', 1, \"A\"), ('b', 1, \"B\"), \n//    ('b', b, \"A\"), ('b', 2, \"B\")\n// ] \n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/IterableMultipliationTest.kt).\n\n# Cartesian product of lists\n\nSimilar to iterable multiplication but produces sequence of lists:\n\n```kotlin\nlistOf('A', 'B', 'C', D).cartesianProduct(listOf('x', 'y')) // returns List<List<Char>>\n// [\n//     ['A', 'x'],\n//     ['A', 'y'],\n//     ['B', 'x'],\n//     ['B', 'y'],\n//     ['C', 'x'],\n//     ['C', 'y'],\n//     ['D', 'x'],\n//     ['D', 'y']\n// ]\nlistOf(0, 1).cartesianProduct(repeat = 2) // returns List<List<Int>>\n// [\n//     [0, 0],\n//     [0, 1],\n//     [1, 0],\n//     [1, 1]\n// ]\nlistOf(1, 2).cartesianProduct(listOf(\"ABC\")) // returns List<List<Any>>\n// [\n//     [1, \"ABC\"],\n//     [2, \"ABC\"]\n// ]\n```\n\nMore examples [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/CartesianProductTest.kt).\n\n# Java support\n\nLibrary is fully supporting usage from Java. All functions can be used as static function of DiscreteMath. For example:\n\n```java\nDiscreteMath.permutationsNumber(set)\nDiscreteMath.permutationsNumber(list)\nDiscreteMath.factorial(10) // 3628800L\n```\n\nReturned list and sets are Java standard lists and sets. More examples of Java usage [here](https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit/blob/master/src/test/java/com/marcinmoskala/math/tests/JavaTest.java).\n\n# Install\n\nGradle:\n```groovy\ncompile \"com.marcinmoskala:DiscreteMathToolkit:1.0.3\"\n```\n\nMaven:\n```\n<dependency>\n  <groupId>com.marcinmoskala</groupId>\n  <artifactId>DiscreteMathToolkit</artifactId>\n  <version>1.0.3</version>\n</dependency>\n```\n\nJar to download together with sources and javadoc can be found on [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cmarcinmoskala).\n\nLicense\n-------\n\n    Copyright 2017 Marcin Moskała\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n"
  },
  {
    "path": "_config.yml",
    "content": "theme: jekyll-theme-midnight"
  },
  {
    "path": "build.gradle",
    "content": "apply plugin: 'kotlin'\nif (project.hasProperty(\"signing.keyId\")) {\n    apply plugin: 'signing'\n}\napply plugin: 'maven-publish'\napply plugin: \"jacoco\"\n\nrepositories {\n    mavenCentral()\n}\n\nbuildscript {\n    ext.kotlin_version = '1.3.72'\n    ext.junit_version = '5.6.1'\n    ext.kotest_version = '4.0.6'\n    repositories {\n        mavenCentral()\n    }\n    dependencies {\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n    }\n}\n\njacocoTestReport {\n    reports {\n        xml.enabled = true\n        html.enabled = true\n    }\n}\n\ncheck.dependsOn jacocoTestReport\n\ndependencies {\n    compile \"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version\"\n    testImplementation \"org.junit.jupiter:junit-jupiter-api:$junit_version\"\n    testImplementation \"org.junit.jupiter:junit-jupiter-engine:$junit_version\"\n    testImplementation \"io.kotest:kotest-runner-junit5-jvm:$kotest_version\"\n    testImplementation \"io.kotest:kotest-property-jvm:$kotest_version\"\n}\n\n// Publishing\n\ntest {\n    // show standard out and standard error of the test JVM(s) on the console\n    testLogging.showStandardStreams = true\n}\n\ntask sourceJar(type: Jar) {\n    classifier \"sources\"\n    from sourceSets.main.allJava\n}\n\ntask javadocJar(type: Jar, dependsOn: javadoc) {\n    classifier \"javadoc\"\n    from javadoc.destinationDir\n}\n\nartifacts {\n    archives sourceJar, javadocJar\n}\n\nsigning {\n    sign configurations.archives\n}\n\npublishing {\n    publications {\n        mavenJava(MavenPublication) {\n            customizePom(pom)\n\n            groupId \"com.marcinmoskala\"\n            artifactId \"DiscreteMathToolkit\"\n            version '1.0.5'\n\n            from components.java\n\n            // create the sign pom artifact\n            pom.withXml {\n                def pomFile = file(\"${project.buildDir}/generated-pom.xml\")\n                writeTo(pomFile)\n                def pomAscFile = signing.sign(pomFile).signatureFiles[0]\n                artifact(pomAscFile) {\n                    classifier = null\n                    extension = 'pom.asc'\n                }\n            }\n\n            artifact(sourceJar) {\n                classifier = 'sources'\n            }\n            artifact(javadocJar) {\n                classifier = 'javadoc'\n            }\n\n            // create the signed artifacts\n            project.tasks.signArchives.signatureFiles.each {\n                artifact(it) {\n                    def matcher = it.file =~ /-(sources|javadoc)\\.jar\\.asc$/\n                    if (matcher.find()) {\n                        classifier = matcher.group(1)\n                    } else {\n                        classifier = null\n                    }\n                    extension = 'jar.asc'\n                }\n            }\n        }\n    }\n    repositories {\n        maven {\n            url \"https://oss.sonatype.org/service/local/staging/deploy/maven2\"\n            credentials {\n                username sonatypeUsername\n                password sonatypePassword\n            }\n        }\n    }\n}\n\ndef customizePom(pom) {\n    pom.withXml {\n        def root = asNode()\n\n        root.dependencies.removeAll { dep ->\n            dep.scope == \"test\"\n        }\n\n        root.children().last() + {\n            resolveStrategy = Closure.DELEGATE_FIRST\n\n            name 'DescreteMathToolkit'\n            description 'Set of extensions for Kotlin that provides Discrete Math functionalities as an Kotlin extension functions.'\n            url 'https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit'\n\n            scm {\n                connection 'scm:https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit'\n                developerConnection 'scm:https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit'\n                url 'https://github.com/MarcinMoskala/KotlinDiscreteMathToolkit'\n            }\n\n            licenses {\n                license {\n                    name 'The Apache License, Version 2.0'\n                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'\n                }\n            }\n\n            developers {\n                developer {\n                    id 'MarcinMoskala'\n                    name 'Marcin Moskala'\n                    email 'marcinmoskala@gmail.com'\n                }\n            }\n        }\n    }\n}\n\nmodel {\n    tasks.generatePomFileForMavenJavaPublication {\n        destination = file(\"$buildDir/generated-pom.xml\")\n    }\n    tasks.publishMavenJavaPublicationToMavenLocal {\n        dependsOn project.tasks.signArchives\n    }\n    tasks.publishMavenJavaPublicationToMavenRepository {\n        dependsOn project.tasks.signArchives\n    }\n}"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Mon Jun 08 23:32:02 CEST 2020\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.5.1-all.zip\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env sh\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave ( ) {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=$(save \"$@\")\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windows variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/CartesianProductExt.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\n\npackage com.marcinmoskala.math\n\n/**\n * Cartesian product of a list with itself, specify the number of repetitions with the optional repeat keyword argument.\n * For example, A.cartesianProduct(repeat=4) means the same as A.cartesianProduct(A, A, A).\n * Throws an [IllegalArgumentException]: if [repeat] is less or equals to 0\n * Throws an [IllegalArgumentException]: if size of result should exceeds [Int.MAX_VALUE]\n */\nfun <T> List<T>.cartesianProduct(repeat: Int = 2): Sequence<List<T>> {\n    require(repeat > 0) { \"Parameter repeat should be greater than 0\" }\n    return product(*Array(repeat) { this })\n}\n\n/**\n * Cartesian product of lists.\n * Throws an [IllegalArgumentException]: if size of result should exceeds [Int.MAX_VALUE]\n */\nfun <T> List<T>.cartesianProduct(vararg lists: List<T>): Sequence<List<T>> =\n        product(this, *lists)\n\nprivate fun <T> product(vararg iterables: List<T>): Sequence<List<T>> = sequence {\n\n    require(iterables.map { it.size.toLong() }.reduce(Long::times) <= Int.MAX_VALUE) {\n        \"Cartesian product function can produce result whose size does not exceed Int.MAX_VALUE\"\n    }\n\n    val numberOfIterables = iterables.size\n    val lstLengths = ArrayList<Int>()\n    val lstRemaining = ArrayList(listOf(1))\n\n    iterables.reversed().forEach {\n        lstLengths.add(0, it.size)\n        lstRemaining.add(0, it.size * lstRemaining[0])\n    }\n\n    val nProducts = lstRemaining.removeAt(0)\n\n    (0 until nProducts).forEach { product ->\n        val result = ArrayList<T>()\n        (0 until numberOfIterables).forEach { iterableIndex ->\n            val elementIndex = product / lstRemaining[iterableIndex] % lstLengths[iterableIndex]\n            result.add(iterables[iterableIndex][elementIndex])\n        }\n        yield(result.toList())\n    }\n}"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/CombinationsExt.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\n/**\n * In mathematics, a combination is a way of selecting items from a collection, such that (unlike permutations) the\n * order of selection does not matter.\n *\n * For set {1, 2, 3}, 2 elements combinations are {1, 2}, {2, 3}, {1, 3}.\n * All possible combinations is called 'powerset' and can be found as an\n * extension function for set under this name\n */\nfun <T> Set<T>.combinations(combinationSize: Int): Set<Set<T>> = when {\n    combinationSize < 0 -> throw Error(\"combinationSize cannot be smaller then 0. It is equal to $combinationSize\")\n    combinationSize == 0 -> setOf(setOf())\n    combinationSize >= size -> setOf(toSet())\n    else -> powerset()\n            .filter { it.size == combinationSize }\n            .toSet()\n}\n\nfun <T> Set<T>.combinationsNumber(combinationSize: Int): Long = when {\n    combinationSize < 0 -> throw Error(\"combinationSize cannot be smaller then 0. It is equal to $combinationSize\")\n    combinationSize >= size || combinationSize == 0 -> 1\n    else -> size.factorial() / (combinationSize.factorial() * (size - combinationSize).factorial())\n}\n\nfun <T> Set<T>.combinationsWithRepetitions(combinationSize: Int): Set<Map<T, Int>> = when {\n    combinationSize < 0 -> throw Error(\"combinationSize cannot be smaller then 0. It is equal to $combinationSize\")\n    combinationSize == 0 -> setOf(mapOf())\n    else -> combinationsWithRepetitions(combinationSize - 1)\n            .flatMap { subset -> this.map { subset + (it to (subset.getOrElse(it) { 0 } + 1)) } }\n            .toSet()\n}\n\nfun <T> Set<T>.combinationsWithRepetitionsNumber(combinationSize: Int): Long = when {\n    combinationSize < 0 -> throw Error(\"combinationSize cannot be smaller then 0. It is equal to $combinationSize\")\n    combinationSize == 0 -> 1\n    else -> (size + combinationSize - 1).factorial() / (combinationSize.factorial() * (size - 1).factorial())\n}"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/FactorialFun.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\nfun Int.factorial(): Long = (1..this).product()"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/IterableMultiplication.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\noperator fun <T, R> List<T>.times(l: List<R>): List<Pair<T, R>> = flatMap { e1 -> l.map { e2 -> e1 to e2 } }\n\n@JvmName(\"listOfPairTimes\")\noperator fun <T, P, R> List<Pair<T, P>>.times(l: List<R>): List<Triple<T, P, R>> = flatMap { (e1, e2) -> l.map { e3 -> Triple(e1, e2, e3) } }"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/NumSplitFunc.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\n// Number of splits of n identical elements to k groups\nfun Int.splitsNumber(groupsNum: Int): Int = when {\n    groupsNum < 0 -> throw Error(\"groupsNum cannot be smaller then 0. It is now equal to $groupsNum\")\n    groupsNum == 0 -> if (this == 0) 1 else 0\n    groupsNum == 1 || groupsNum == this -> 1\n    groupsNum > this -> 0\n    else -> (1..groupsNum).sumBy { i -> (this - groupsNum).splitsNumber(i) }\n}\n\n"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/NumbersDivisible.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\nfun IntRange.divisiveBy(vararg numbers: Int)\n        = filter { n -> numbers.any { n % it == 0 } }\n\nfun IntRange.countDivisiveBy(vararg numbers: Int)\n        = count { n -> numbers.any { n % it == 0 } }\n\nfun IntRange.nonDivisiveBy(vararg numbers: Int)\n        = filter { n -> numbers.all { n % it != 0 } }\n\nfun IntRange.countNonDivisiveBy(vararg numbers: Int)\n        = count { n -> numbers.all { n % it != 0 } }"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/PermutationsExt.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\n/**\n *  Permutations are all different ways to arrange elements from some collection (https://en.wikipedia.org/wiki/Permutation).\n *  For sets it's number is n!, for lists it is n! / (n1! * n2! * ...) where n1, n2... are numbers elements that are the same.\n */\n\n/* This function returns number of all permutations of elements from set. It is equal to n! where n is size of set. */\nfun <T> Set<T>.permutationsNumber(): Long = size.factorial()\n\n/* This function returns number of all permutations of elements from list. It is equal to n! / (n1! * n2! * ...) where n1, n2... are numbers elements that are the same. */\nfun <T> List<T>.permutationsNumber(): Long = if (size < 1) 1L else size.factorial() / groupBy { it }.map { it.value.size.factorial() }.product()\n\n/* This function returns all permutations of elements from set. These are different ways to arrange elements from this list.  */\nfun <T> Set<T>.permutations(): Set<List<T>> = toList().permutations()\n\n/* This function returns all permutations of elements from list. These are different ways to arrange elements from this list.  */\nfun <T> List<T>.permutations(): Set<List<T>> = when {\n    isEmpty() -> setOf()\n    size == 1 -> setOf(listOf(get(0)))\n    else -> {\n        val element = get(0)\n        drop(1).permutations()\n                .flatMap { sublist -> (0..sublist.size).map { i -> sublist.plusAt(i, element) } }\n                .toSet()\n    }\n}\n\ninternal fun <T> List<T>.plusAt(index: Int, element: T): List<T> = when {\n    index !in 0..size -> throw Error(\"Cannot put at index $index because size is $size\")\n    index == 0 -> listOf(element) + this\n    index == size -> this + element\n    else -> dropLast(size - index) + element + drop(index)\n}"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/Power.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\n\npackage com.marcinmoskala.math\n\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\ninfix fun Number.pow(power: Number): Double =\n        Math.pow(this.toDouble(), power.toDouble())\n\ninfix fun Int.pow(power: Int): Int =\n        Math.pow(this.toDouble(), power.toDouble()).toInt()"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/PowersetExt.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\nfun <T> Collection<T>.powerset(): Set<Set<T>> = powerset(this, setOf(setOf()))\n\nprivate tailrec fun <T> powerset(left: Collection<T>, acc: Set<Set<T>>): Set<Set<T>> = when {\n    left.isEmpty() -> acc\n    else ->powerset(left.drop(1), acc + acc.map { it + left.first() })\n}\n\nval <T> Collection<T>.powersetSize: Int\n    get() = 2.pow(size)"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/ProductExt.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\nfun Iterable<Int>.product(): Long = fold(1L) { a, n -> a * n }\n\n@JvmName(\"productLong\")\nfun Collection<Long>.product(): Long = fold(1L) { a, n -> a * n }"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/SetSplitFunc.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\n// Stirling function - number of splits of n different elements to k groups\nfun <T> Set<T>.splitsNumber(groupsNum: Int): Int = when {\n    groupsNum < 0 -> throw Error(\"groupsNum cannot be smaller then 0. It is equal to $groupsNum\")\n    groupsNum == 0 -> if (isEmpty()) 1 else 0\n    groupsNum == 1 || groupsNum == size -> 1\n    groupsNum > size -> 0\n    else -> (1..(size - 1)).toSet().splitsNumber(groupsNum - 1) + groupsNum * (1..(size - 1)).toSet().splitsNumber(groupsNum)\n}\n\n// Takes set of elements and returns set of splits and each of them is set of sets\nfun <T> Set<T>.splits(groupsNum: Int): Set<Set<Set<T>>> = when {\n    groupsNum < 0 -> throw Error(\"groupsNum cannot be smaller then 0. It is equal to $groupsNum\")\n    groupsNum == 0 -> if (isEmpty()) setOf(emptySet()) else emptySet()\n    groupsNum == 1 -> setOf(setOf(this))\n    groupsNum == size -> setOf(this.map { setOf(it) }.toSet())\n    groupsNum > size -> emptySet()\n    else -> setOf<Set<Set<T>>>()\n            .plus(splitsWhereFirstIsAlone(groupsNum))\n            .plus(splitsForFirstIsInAllGroups(groupsNum))\n}\n\nprivate fun <T> Set<T>.splitsWhereFirstIsAlone(groupsNum: Int): List<Set<Set<T>>> = this\n        .minusElement(first())\n        .splits(groupsNum - 1)\n        .map { it.plusElement(setOf(first())) }\n\nprivate fun <T> Set<T>.splitsForFirstIsInAllGroups(groupsNum: Int): List<Set<Set<T>>> = this\n        .minusElement(first())\n        .splits(groupsNum)\n        .flatMap { split -> split.map { group -> split.minusElement(group).plusElement(group + first()) } }"
  },
  {
    "path": "src/main/java/com/marcinmoskala/math/SublistsBySplittersExt.kt",
    "content": "@file:JvmName(\"DiscreteMath\")\n@file:JvmMultifileClass\npackage com.marcinmoskala.math\n\nfun <T> List<T>.sublistsBySplitters(isSplitter: (T) -> Boolean): List<List<T>> = when {\n    isEmpty() -> listOf(listOf())\n    isSplitter(last()) -> sublistFromRest(isSplitter)\n            .flatMap { listOf(it + last(), it) }\n    else -> sublistFromRest(isSplitter)\n            .map { it + last() }\n}\n\nprivate fun <T> List<T>.sublistFromRest(isSplitter: (T) -> Boolean) = dropLast(1).sublistsBySplitters(isSplitter)"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/CartesianProductPropertyTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.cartesianProduct\nimport io.kotest.core.spec.style.StringSpec\nimport io.kotest.property.Arb\nimport io.kotest.property.arbitrary.int\nimport io.kotest.property.arbitrary.list\nimport io.kotest.property.forAll\n\n\ninternal class CartesianProductPropertyTest : StringSpec({\n\n    val intListGen = Arb.list(\n            Arb.int(0..100),\n            2..5\n    )\n\n    val listOfIntListsGen = Arb.list(\n            intListGen,\n            2..5\n    )\n\n    \"output product size is product of sizes of inputs\" {\n        forAll(listOfIntListsGen) { list ->\n            val head = list[0]\n            val tail = list.drop(1).toTypedArray()\n            head.cartesianProduct(*tail).toList().size == list.map { it.size }.reduce(Int::times)\n        }\n    }\n\n    \"cartesian product with repeat of empty list is empty list\" {\n        forAll(Arb.int(2..10)) { repeat ->\n            emptyList<Int>().cartesianProduct(repeat).toList().isEmpty()\n        }\n    }\n\n    \"cartesian product of empty list and non empty list is empty list\" {\n        forAll(intListGen) { list ->\n            emptyList<Int>().cartesianProduct(list).toList().isEmpty()\n        }\n    }\n\n    \"cartesian product of non empty list and empty list is empty list\" {\n        forAll(intListGen) { list ->\n            list.cartesianProduct(emptyList()).toList().isEmpty()\n        }\n    }\n\n    \"set of elements in product is the same as in input\" {\n        forAll(listOfIntListsGen) { list ->\n            val head = list[0]\n            val tail = list.drop(1).toTypedArray()\n            head.cartesianProduct(*tail).toList().flatten().toSet() ==\n                    list.flatten().toSet()\n        }\n    }\n})"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/CartesianProductTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.cartesianProduct\nimport io.kotest.property.Arb\nimport io.kotest.property.arbitrary.int\nimport io.kotest.property.arbitrary.next\nimport org.junit.jupiter.api.Assertions.assertThrows\nimport org.junit.jupiter.api.Test\nimport org.junit.jupiter.api.Assertions.assertEquals\n\n\ninternal class CartesianProductTest {\n\n    @Test\n    fun `cartesian product with size more than MAX_INT throws`() {\n        assertThrows(IllegalArgumentException::class.java) {\n            listOf(1, 2, 3, 5, 6, 7, 8, 9, 0).cartesianProduct(10).toList()\n        }\n    }\n\n    @Test\n    fun `cartesian product with repeat less than 1 throws`() {\n        val repeat = Arb.int(-100..0).next()\n        assertThrows(IllegalArgumentException::class.java) {\n            listOf(1, 2, 3).cartesianProduct(repeat)\n        }\n    }\n\n    @Test\n    fun `cartesian product with repeat = 1`() {\n        val actual = listOf(1, 2, 3).cartesianProduct(1).toList()\n        val expected = listOf(\n                listOf(1),\n                listOf(2),\n                listOf(3)\n        )\n        assertEquals(expected, actual)\n    }\n\n    @Test\n    fun `cartesian product with repeat`() {\n        val actual = listOf(1, 2, 3).cartesianProduct(2).toList()\n        val expected = listOf(\n                listOf(1, 1),\n                listOf(1, 2),\n                listOf(1, 3),\n                listOf(2, 1),\n                listOf(2, 2),\n                listOf(2, 3),\n                listOf(3, 1),\n                listOf(3, 2),\n                listOf(3, 3)\n        )\n        assertEquals(expected, actual)\n    }\n\n    @Test\n    fun `cartesian product of different sizes`() {\n        val actual = listOf(1, 2, 3).cartesianProduct(listOf(8, 9)).toList()\n        val expected = listOf(\n                listOf(1, 8),\n                listOf(1, 9),\n                listOf(2, 8),\n                listOf(2, 9),\n                listOf(3, 8),\n                listOf(3, 9)\n        )\n        assertEquals(expected, actual)\n    }\n\n    @Test\n    fun `cartesian product of same sizes`() {\n        val actual = listOf(1, 2).cartesianProduct(listOf(8, 9)).toList()\n        val expected = listOf(\n                listOf(1, 8),\n                listOf(1, 9),\n                listOf(2, 8),\n                listOf(2, 9)\n        )\n        assertEquals(expected, actual)\n    }\n\n    @Test\n    fun `cartesian product of 3 lists`() {\n        val actual = listOf(1, 2).cartesianProduct(\n                listOf(3, 4),\n                listOf(5, 6)\n        ).toList()\n        val expected = listOf(\n                listOf(1, 3, 5),\n                listOf(1, 3, 6),\n                listOf(1, 4, 5),\n                listOf(1, 4, 6),\n                listOf(2, 3, 5),\n                listOf(2, 3, 6),\n                listOf(2, 4, 5),\n                listOf(2, 4, 6)\n        )\n        assertEquals(expected, actual)\n    }\n\n    @Test\n    fun `cartesian product of 3 lists with different size`() {\n        val actual = listOf(0, 1, 2).cartesianProduct(\n                listOf(3, 4),\n                listOf(5, 6)\n        ).toList()\n        val expected = listOf(\n                listOf(0, 3, 5),\n                listOf(0, 3, 6),\n                listOf(0, 4, 5),\n                listOf(0, 4, 6),\n                listOf(1, 3, 5),\n                listOf(1, 3, 6),\n                listOf(1, 4, 5),\n                listOf(1, 4, 6),\n                listOf(2, 3, 5),\n                listOf(2, 3, 6),\n                listOf(2, 4, 5),\n                listOf(2, 4, 6)\n        )\n        assertEquals(expected, actual)\n    }\n\n    @Test\n    fun `cartesian product of 2 lists with different types`() {\n        val expected = listOf(\n                listOf(\"A\", 1),\n                listOf(\"A\", 2),\n                listOf(\"A\", 3),\n                listOf(\"B\", 1),\n                listOf(\"B\", 2),\n                listOf(\"B\", 3)\n        )\n        val actual = listOf(\"A\", \"B\").cartesianProduct(listOf(1, 2, 3)).toList()\n        assertEquals(expected, actual)\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/CombinationTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.combinations\nimport com.marcinmoskala.math.combinationsNumber\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class CombinationTest {\n\n    @Test\n    fun `combinations function is throwing error when asked for subsets of size smaller then 0`() {\n        val set = setOf(1, 2, 3, 4)\n        for (subsetSize in -10..-1) {\n            assertIsThrowingError { set.combinations(subsetSize) }\n        }\n    }\n\n    @Test fun `combinationsNumber function is throwing error when asked for subsets of size smaller then 0`() {\n        val set = setOf(1, 2, 3, 4)\n        for (subsetSize in -10..-1) {\n            assertIsThrowingError { set.combinationsNumber(subsetSize) }\n        }\n    }\n\n    @Test fun `Test combinationsNumber for Sets with different sizes`() {\n        val set = setOf(1, 2, 3, 4)\n        val subsetSizeToCombinationNumber = mapOf(\n                0 to 1L,\n                1 to 4L,\n                2 to 6L,\n                3 to 4L,\n                4 to 1L,\n                5 to 1L\n        )\n        for ((subsetSize, expectedCombinationNumber) in subsetSizeToCombinationNumber) {\n            assertEquals(expectedCombinationNumber, set.combinationsNumber(subsetSize))\n        }\n    }\n\n    @Test fun `Test combinations for Sets with different sizes`() {\n        val set = setOf(1, 2, 3, 4)\n        val sizeToCombinations = mapOf(\n                0 to setOf(setOf()),\n                1 to setOf(setOf(1), setOf(2), setOf(3), setOf(4)),\n                2 to setOf(setOf(1, 2), setOf(2, 3), setOf(3, 4), setOf(1, 3), setOf(2, 4), setOf(1, 4)),\n                3 to setOf(setOf(1, 2, 3), setOf(1, 2, 4), setOf(1, 3, 4), setOf(2, 3, 4)),\n                4 to setOf(setOf(1, 2, 3, 4)),\n                5 to setOf(setOf(1, 2, 3, 4))\n        )\n        for ((subsetSize, expectedCombinations) in sizeToCombinations) {\n            assertEquals(expectedCombinations, set.combinations(subsetSize))\n        }\n    }\n\n    @Test fun `Test combinations size and combinationsNumber correctness`() {\n        val set = (1..6).toSet()\n        (1..7).forEach { i -> assertEquals(set.combinationsNumber(i), set.combinations(i).size.toLong()) }\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/CombinationWithRepetitionTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.combinationsWithRepetitions\nimport com.marcinmoskala.math.combinationsWithRepetitionsNumber\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class CombinationWithRepetitionTest {\n\n    @Test fun `combinationsWithRepetitions function is throwing error when asked for subsets of size smaller then 0`() {\n        val set = setOf(1, 2, 3, 4)\n        for (subsetSize in -10..-1) {\n            assertIsThrowingError { set.combinationsWithRepetitions(subsetSize) }\n        }\n    }\n\n    @Test fun `combinationsWithRepetitionsNumber function is throwing error when asked for subsets of size smaller then 0`() {\n        val set = setOf(1, 2, 3, 4)\n        for (subsetSize in -10..-1) {\n            assertIsThrowingError { set.combinationsWithRepetitionsNumber(subsetSize) }\n        }\n    }\n\n    @Test fun `Test combinationsWithRepetitionsNumber for Sets with different sizes`() {\n        val set = setOf(1, 2, 3)\n        val subsetSizeToCombinationNumber = mapOf(\n                0 to 1L,\n                1 to 3L,\n                2 to 6L,\n                3 to 10L,\n                4 to 15L,\n                5 to 21L\n        )\n        for ((subsetSize, expectedCombinationNumber) in subsetSizeToCombinationNumber) {\n            assertEquals(expectedCombinationNumber, set.combinationsWithRepetitionsNumber(subsetSize))\n        }\n    }\n\n    @Test fun `Simple combinationsWithRepetitions test`() {\n        val set = setOf(1, 2, 3)\n        val sizeToCombinations = mapOf<Int, Set<Map<Int, Int>>>(\n                0 to setOf(mapOf<Int, Int>()),\n                1 to setOf(mapOf(1 to 1), mapOf(2 to 1), mapOf(3 to 1)),\n                2 to setOf(mapOf(1 to 1, 2 to 1), mapOf(2 to 1, 3 to 1), mapOf(1 to 1, 3 to 1), mapOf(1 to 2), mapOf(2 to 2), mapOf(3 to 2))\n        )\n        for ((subsetSize, expectedCombinations) in sizeToCombinations) {\n            assertEquals(expectedCombinations, set.combinationsWithRepetitions(subsetSize))\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/FactorialTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.factorial\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class FactorialTest {\n\n    @Test fun `Test factorial results`() {\n        val numberWithFactorial = mapOf(\n                0 to 1L,\n                1 to 1L,\n                2 to 2L,\n                3 to 6L,\n                4 to 24L,\n                10 to 3628800L,\n                15 to 1307674368000L,\n                20 to 2432902008176640000L\n        )\n        for ((i, factorialResult) in numberWithFactorial) {\n            assertEquals(factorialResult, i.factorial())\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/IterableMultipliationTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.times\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class IterableMultipliationTest {\n\n    @Test fun `When one list empty then multiplication is also returning empty`() {\n        assertEquals(listOf<Int>(), listOf<Int>() * listOf<Int>())\n        assertEquals(listOf<Int>(), listOf<Int>(1) * listOf<Int>())\n        assertEquals(listOf<Int>(), listOf<Int>() * listOf<Int>(1))\n        assertEquals(listOf<Int>(), listOf<Int>(1, 2) * listOf<Int>())\n    }\n\n    @Test fun `When size of one list is 1 then multiplication of it with other list returns list with size of second with element of it paired with element from other list`() {\n        assertEquals(listOf(\"A\" to 1, \"A\" to 2), listOf(\"A\") * listOf(1, 2))\n        assertEquals(listOf(\"A\" to 1, \"A\" to 2, \"A\" to 3), listOf(\"A\") * listOf(1, 2, 3))\n        assertEquals(listOf(\"A\" to 1, \"A\" to 2, \"A\" to 2), listOf(\"A\") * listOf(1, 2, 2))\n    }\n\n    @Test fun `Simple list multiplication returns each combination of pairs from lists`() {\n        assertEquals(listOf(\"A\" to 1, \"A\" to 2, \"B\" to 1, \"B\" to 2), listOf(\"A\", \"B\") * listOf(1, 2))\n    }\n\n    @Test fun `Multiplication of tree lists is returning triple with each combination of each lists`() {\n        assertEquals(listOf(\n                Triple(\"A\", 1, 'a'),\n                Triple(\"A\", 1, 'b'),\n                Triple(\"A\", 2, 'a'),\n                Triple(\"A\", 2, 'b'),\n                Triple(\"B\", 1, 'a'),\n                Triple(\"B\", 1, 'b'),\n                Triple(\"B\", 2, 'a'),\n                Triple(\"B\", 2, 'b')\n        ), listOf(\"A\", \"B\") * listOf(1, 2) * listOf('a', 'b'))\n    }\n\n    @Test fun `Size of result of list multipication is equeal to multiplication of list sizes`() {\n        val list1 = (1..5).toList()\n        val list2 = (1..10).toList()\n        val list3 = (1..25).toList()\n        assertEquals(list1.size * list2.size, (list1 * list2).size)\n        assertEquals(list1.size * list3.size, (list1 * list3).size)\n        assertEquals(list2.size * list3.size, (list2 * list3).size)\n        assertEquals(list1.size * list1.size, (list1 * list1).size)\n        assertEquals(list2.size * list2.size, (list2 * list2).size)\n        assertEquals(list3.size * list3.size, (list3 * list3).size)\n        assertEquals(list1.size * list2.size * list3.size, (list1 * list2 * list3).size)\n        assertEquals(list1.size * list1.size * list1.size, (list1 * list1 * list1).size)\n        assertEquals(list2.size * list2.size * list2.size, (list2 * list2 * list2).size)\n        assertEquals(list3.size * list3.size * list3.size, (list3 * list3 * list3).size)\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/JavaTest.java",
    "content": "package com.marcinmoskala.math.tests;\n\nimport com.marcinmoskala.math.DiscreteMath;\nimport org.junit.jupiter.api.Assertions;\nimport org.junit.jupiter.api.BeforeAll;\nimport org.junit.jupiter.api.Test;\n\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\npublic class JavaTest {\n\n    private static Set<Integer> smallSet = new HashSet<>();\n    private static List<Integer> smallList = new ArrayList<>();\n\n    @BeforeAll\n    static public void setUp() {\n        smallSet.add(0);\n        smallSet.add(1);\n        smallSet.add(2);\n        smallList.add(0);\n        smallList.add(1);\n        smallList.add(1);\n    }\n\n    @Test\n    public void permutationsTest() {\n        Assertions.assertEquals(6, DiscreteMath.permutationsNumber(smallSet));\n        Assertions.assertEquals(3, DiscreteMath.permutationsNumber(smallList));\n    }\n\n    @Test\n    public void combinationsTest() {\n        Assertions.assertEquals(3, DiscreteMath.combinationsNumber(smallSet, 2));\n        Assertions.assertEquals(6, DiscreteMath.combinationsWithRepetitionsNumber(smallSet, 2));\n    }\n\n    @Test\n    public void powersetTest() {\n        Assertions.assertEquals(8, DiscreteMath.getPowersetSize(smallSet));\n    }\n\n    @Test\n    public void productTest() {\n        Assertions.assertEquals(0, DiscreteMath.product(smallList));\n    }\n\n    @Test\n    public void factorialTest() {\n        Assertions.assertEquals(3628800L, DiscreteMath.factorial(10));\n    }\n\n    @Test\n    public void splitsOfSetTest() {\n        Assertions.assertEquals(3, DiscreteMath.splitsNumber(smallSet, 2));\n    }\n\n    @Test\n    public void splitsOfNumberTest() {\n        Assertions.assertEquals(3, DiscreteMath.splitsNumber(7, 4));\n    }\n\n    @Test\n    public void iterableMultiplicationTest() {\n        Assertions.assertEquals(smallList.size() * smallList.size(), DiscreteMath.times(smallList, smallList).size());\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/NumberSplitTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.splitsNumber\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class NumberSplitTest {\n\n    @Test fun `splitsNumber function for number is throwing error when asked for groupsNum of size smaller then 0`() {\n        for (groupsNum in -10..-1) {\n            for (num in 0..10) {\n                assertIsThrowingError { num.splitsNumber(groupsNum) }\n            }\n        }\n    }\n\n    @Test\n    fun `n number can be only one way splitted to one or n components`() {\n        for (n in 1..100) {\n            assertEquals(1, n.splitsNumber(1))\n            assertEquals(1, n.splitsNumber(n))\n        }\n    }\n\n    @Test\n    fun `For 0 splits, number splits function is returning 1 for 0 and 0 otherwise`() {\n        assertEquals(1, 0.splitsNumber(0))\n        for (n in 1..100) {\n            assertEquals(0, n.splitsNumber(0))\n        }\n    }\n\n    @Test\n    fun `Number splits function is correct according to recurrence definition`() {\n        for (n in 1..10) {\n            for (k in 1..(n - 1)) {\n                assertEquals(n.splitsNumber(k), (1..k).sumBy { i -> (n - k).splitsNumber(i) })\n            }\n        }\n    }\n\n    @Test\n    fun `Simple number splits examples are calculated correctly`() {\n        assertEquals(3, 7.splitsNumber(4))\n        assertEquals(11, 11.splitsNumber(4))\n        assertEquals(5, 9.splitsNumber(5))\n        assertEquals(7, 13.splitsNumber(8))\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/NumbersDivisibleTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.countDivisiveBy\nimport com.marcinmoskala.math.countNonDivisiveBy\nimport com.marcinmoskala.math.divisiveBy\nimport com.marcinmoskala.math.nonDivisiveBy\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class NumbersDivisibleTest {\n\n    @Test fun `Simple count divisible test`() {\n        assertEquals(462, (1..1000).countNonDivisiveBy(2, 6, 13))\n        assertEquals(520, (1..1000).countNonDivisiveBy(3, 7, 11))\n        assertEquals(768, (1..1000).countNonDivisiveBy(6, 9, 33))\n    }\n\n    @Test fun `Simple count nondivisible test`() {\n        assertEquals(1000 - 462, (1..1000).countDivisiveBy(2, 6, 13))\n        assertEquals(1000 - 520, (1..1000).countDivisiveBy(3, 7, 11))\n        assertEquals(1000 - 768, (1..1000).countDivisiveBy(6, 9, 33))\n    }\n\n    @Test fun `Simple divisible test`() {\n        assertEquals(listOf(1, 5, 7), (1..10).nonDivisiveBy(2, 3))\n    }\n\n    @Test fun `Simple nondivisible test`() {\n        assertEquals(listOf(2, 3, 4, 6, 8, 9, 10), (1..10).divisiveBy(2, 3))\n    }\n\n    @Test fun `Divisible (and non divisible) size and count matches`() {\n        val r = (1..100)\n        for(i in 1..10) {\n            for(j in 1..10) {\n                assertEquals(r.countDivisiveBy(i, j), r.divisiveBy(i, j).size)\n                assertEquals(r.countNonDivisiveBy(i, j), r.nonDivisiveBy(i, j).size)\n            }\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/PermutationTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.permutations\nimport com.marcinmoskala.math.permutationsNumber\nimport com.marcinmoskala.math.plusAt\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class PermutationTest {\n\n    @Test fun `Test permutation numbers for Sets with different sizes`() {\n        val setSizeToPermutations = mapOf(\n                0 to 1L,\n                1 to 1L,\n                2 to 2L,\n                3 to 6L,\n                4 to 24L\n        )\n        for ((setSize, expectedNumber) in setSizeToPermutations) {\n            val set = (1..setSize).toSet()\n            assertEquals(expectedNumber, set.permutationsNumber())\n        }\n    }\n\n    @Test fun `Test permutation numbers for Lists with different sizes and different elements`() {\n        val listSizeToPermutations = mapOf(\n                0 to 1L,\n                1 to 1L,\n                2 to 2L,\n                3 to 6L,\n                4 to 24L\n        )\n        for ((listSize, expectedNumber) in listSizeToPermutations) {\n            val set = (1..listSize).toList()\n            assertEquals(expectedNumber, set.permutationsNumber())\n        }\n    }\n\n    @Test fun `Test permutation numbers for Lists with different sizes and same elements`() {\n        val listToPermutations = mapOf(\n                listOf(1, 1, 1, 1) to 1L,\n                listOf(1, 1, 2, 2) to 6L,\n                listOf(1, 1, 1, 2) to 4L\n        )\n        for ((list, expectedNumber) in listToPermutations) {\n            assertEquals(expectedNumber, list.permutationsNumber())\n        }\n    }\n\n    @Test fun `Get all permutations for different elements`() {\n        val setToPermutations = mapOf(\n                setOf<Int>() to setOf<List<Int>>(),\n                setOf(1, 2) to setOf(listOf(1, 2), listOf(2, 1)),\n                setOf(1, 2, 3) to setOf(listOf(1, 2, 3), listOf(2, 1, 3), listOf(1, 3, 2), listOf(2, 3, 1), listOf(3, 1, 2), listOf(3, 2, 1))\n        )\n        for ((set, allExpectedPermutations) in setToPermutations) {\n            assertEquals(allExpectedPermutations, set.permutations())\n        }\n    }\n\n    @Test fun `Check permutations number in allPermutations for bigger numbers`() {\n        val set = (1..5).toSet()\n        assertEquals(set.permutationsNumber(), set.permutations().size.toLong())\n    }\n\n    @Test fun `Simple plusAt tests`() {\n        val list = listOf(1,2,3)\n        assertIsThrowingError { list.plusAt(-1, 100) }\n        assertIsThrowingError { list.plusAt(-100, 100) }\n        assertIsThrowingError { list.plusAt(1000, 100) }\n        assertEquals(listOf(100, 1, 2, 3), list.plusAt(0, 100))\n        assertEquals(listOf(1, 100, 2, 3), list.plusAt(1, 100))\n        assertEquals(listOf(1, 2, 3, 100), list.plusAt(3, 100))\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/PowerTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.pow\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Assertions.assertTrue\nimport org.junit.jupiter.api.Test\n\n@Suppress(\"USELESS_IS_CHECK\")\ninternal class PowerTest {\n\n    @Test\n    fun `Power for Number tests`() {\n        assertEquals(4.0, (2 as Number).pow(2))\n        assertEquals(81.0, (3 as Number).pow(4))\n        assertEquals(100000.0, (10 as Number).pow(5))\n        assertTrue((10 as Number).pow(5) is Double)\n    }\n\n    @Test\n    fun `Power for Int tests`() {\n        assertEquals(4, 2.pow(2))\n        assertEquals(81, 3.pow(4))\n        assertEquals(100000, 10.pow(5))\n        assertTrue(10.pow(5) is Int)\n    }\n\n    @Test\n    fun `Power for Double tests`() {\n        assertEquals(4.0, 2.0.pow(2))\n        assertEquals(81.0, 3.0.pow(4))\n        assertEquals(100000.0, 10.0.pow(5))\n        assertTrue(2.0.pow(5) is Double)\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/PowersetTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.pow\nimport com.marcinmoskala.math.powerset\nimport com.marcinmoskala.math.powersetSize\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class PowersetTest {\n\n    @Test fun `Sublists from empty list is only empty list`() {\n        val emptyList = setOf<Int>()\n        assertEquals(setOf(emptyList), emptyList.powerset())\n    }\n\n    @Test\n    fun `Powerset simple example test`() {\n        val set = setOf(\n                setOf(1, 2, 3),\n                setOf(1, 2),\n                setOf(1, 3),\n                setOf(2, 3),\n                setOf(1),\n                setOf(2),\n                setOf(3),\n                setOf())\n        assertEquals(set, setOf(1, 2, 3).powerset())\n    }\n\n    @Test\n    fun `Size of n element set powerset is 2^n`() {\n        for(n in 1..6) {\n            val set = (1..n).toSet()\n            val size = 2.pow(n)\n            assertEquals(size, set.powerset().size)\n            assertEquals(size, set.powersetSize)\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/ProductTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.product\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class ProductTest {\n\n    @Test\n    fun `Product of empty IntRange is 1`() {\n        assertEquals(1, (0..-1).product())\n    }\n\n    @Test\n    fun `Test products of different IntRanges`() {\n        val rangeToProduct = mapOf(\n                2..4 to 24L,\n                1..4 to 24L,\n                3..4 to 12L,\n                100..100 to 100L\n        )\n        for ((range, product) in rangeToProduct)\n            assertEquals(product, range.product())\n    }\n\n    @Test\n    fun `Test products of different Int Collections`() {\n        val collectionToProduct = mapOf(\n                listOf(1,2,3) to 6L,\n                listOf(2,3) to 6L,\n                listOf(3) to 3L,\n                listOf(10, 10, 10) to 1000L\n        )\n        for ((collection, product) in collectionToProduct)\n            assertEquals(product, collection.product())\n    }\n\n    @Test\n    fun `Test products of different Long Collections`() {\n        val collectionToProduct = mapOf(\n                listOf(1L,2L,3L) to 6L,\n                listOf(2L,3L) to 6L,\n                listOf(3L) to 3L,\n                listOf(10L, 10L, 10L) to 1000L\n        )\n        for ((collection, product) in collectionToProduct)\n            assertEquals(product, collection.product())\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/SetSplitTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.splits\nimport com.marcinmoskala.math.splitsNumber\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class SetSplitTest {\n\n    fun set(size: Int) = (1..size).toSet()\n\n    @Test fun `splitsNumber function for set is throwing error when asked for groupsNum of size smaller then 0`() {\n        for (groupsNum in -10..-1) {\n            for (num in 0..10) {\n                assertIsThrowingError { set(num).splitsNumber(groupsNum) }\n            }\n        }\n    }\n\n    @Test fun `splits function for set is throwing error when asked for groupsNum of size smaller then 0`() {\n        for (groupsNum in -10..-1) {\n            for (num in 0..10) {\n                assertIsThrowingError { set(num).splits(groupsNum) }\n            }\n        }\n    }\n\n    @Test\n    fun `n elements can be only one way splitted to one or n groups`() {\n        for (n in 1..100) {\n            assertEquals(1, set(n).splitsNumber(1))\n            assertEquals(1, set(n).splitsNumber(n))\n        }\n    }\n\n    @Test\n    fun `For 0 splits, Stirling function is returning 1 for 0 and 0 otherwise`() {\n        assertEquals(1, set(0).splitsNumber(0))\n        for (n in 1..100) {\n            assertEquals(0, set(n).splitsNumber(0))\n        }\n    }\n\n    @Test\n    fun `Stirling function is correct according to recurrence definition`() {\n        for (n in 1..10) {\n            for (k in 1..(n - 1)) {\n                assertEquals(\n                        set(n).splitsNumber(k),\n                        set(n - 1).splitsNumber(k - 1) + k * set(n - 1).splitsNumber(k)\n                )\n            }\n        }\n    }\n\n    @Test\n    fun `Simple set splits number for examples are calculated correctly`() {\n        assertEquals(1, set(3).splitsNumber(1))\n        assertEquals(3, set(3).splitsNumber(2))\n        assertEquals(7, set(4).splitsNumber(2))\n        assertEquals(25, set(5).splitsNumber(3))\n        assertEquals(140, set(7).splitsNumber(5))\n        assertEquals(350, set(7).splitsNumber(4))\n    }\n\n    @Test\n    fun `There is no splits to 0, except empty set`() {\n        assertEquals(setOf(emptySet<Int>()), set(0).splits(0))\n        for (n in 1..100) assertEquals(emptySet<Set<Int>>(), set(n).splits(0))\n    }\n\n    @Test\n    fun `Split to 1 is returning only base set`() {\n        (1..10).map { set(it) }.forEach { s -> assertEquals(setOf(setOf(s)), s.splits(1)) }\n    }\n\n    @Test\n    fun `Split to set size is returning set with each element separated`() {\n        (1..10).map { set(it) }.forEach { s -> assertEquals(setOf(s.map { setOf(it) }.toSet()), s.splits(s.size)) }\n    }\n\n    @Test\n    fun `Simple set split is correct`() {\n        assertEquals(setOf(setOf(setOf(1, 2), setOf(3)), setOf(setOf(1, 3), setOf(2)), setOf(setOf(3, 2), setOf(1))), setOf(1, 2, 3).splits(2))\n    }\n\n    @Test\n    fun `Splits size and splitsNumber matches`() {\n        for (i in 1..5) for (j in 1..5) {\n            val s = set(i)\n            assertEquals(s.splitsNumber(j), s.splits(j).size)\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/SublistsBySplittersTest.kt",
    "content": "package com.marcinmoskala.math.tests\n\nimport com.marcinmoskala.math.sublistsBySplitters\nimport org.junit.jupiter.api.Assertions.assertEquals\nimport org.junit.jupiter.api.Test\n\ninternal class SublistsBySplittersTest {\n\n    @Test fun `Sublists from empty list is only empty list`() {\n        val emptyList = listOf<Int>()\n        assertEquals(listOf(emptyList), emptyList.sublistsBySplitters { true })\n        assertEquals(listOf(emptyList), emptyList.sublistsBySplitters { false })\n    }\n\n    @Test\n    fun `Sublists order is from biggest list to empty with elements in natural order`() {\n        assertEquals(listOf(listOf(1, 2), listOf(1), listOf(2), listOf()), listOf(1, 2).sublistsBySplitters { true })\n        assertEquals(listOf(listOf(1, 2), listOf(1)), listOf(1, 2).sublistsBySplitters { it % 2 == 0 })\n    }\n\n    @Test\n    fun `Sublist creation for mixed splitters and simple`() {\n        assertEquals(setOf(listOf(1, 2, 3), listOf(1, 3)), listOf(1, 2, 3).sublistsBySplitters { it % 2 == 0 }.toSet())\n        assertEquals(setOf(listOf(1, 2, 3, 4), listOf(1, 2, 3), listOf(1, 3, 4), listOf(1, 3)), listOf(1, 2, 3, 4).sublistsBySplitters { it % 2 == 0 }.toSet())\n    }\n\n    @Test\n    fun `Big sublists results sizes are correct`() {\n        // 10 splitters, so 2^10 = 1024 lists\n        assert((1..20).toList().sublistsBySplitters { it % 2 == 0 }.size == 1024)\n        assert((1..40).toList().sublistsBySplitters { it % 4 == 0 }.size == 1024)\n    }\n}"
  },
  {
    "path": "src/test/java/com/marcinmoskala/math/tests/TestUtils.kt",
    "content": "package com.marcinmoskala.math.tests\n\ninternal fun <T> assertIsThrowingError(f: () -> T) {\n    try {\n        f()\n    } catch (r: Error) {\n        return\n    }\n    assert(false)\n}"
  }
]