Skip to content

Instantly share code, notes, and snippets.

@voddan
Created June 4, 2016 14:30
Show Gist options
  • Save voddan/25f151f3ad33b07c6dc485f7a59262dd to your computer and use it in GitHub Desktop.
Save voddan/25f151f3ad33b07c6dc485f7a59262dd to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
val n = 100
val sumNumbers = Ring(n).sum()
println("In theory, the sum of numbers 0..${n - 1} is ${n * (n - 1) / 2}.")
println("Which is consistent with a practical result of $sumNumbers.\n")
BinaryBits(5).asSequence().filter {it.sum() == 2}.take(5).forEach { println(it) }
println("\npermutations of 3 elements:")
for(configuration in Permutations(3)) {
println(configuration)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment