Created
March 30, 2018 12:19
-
-
Save baens/0054d6af6515a90305d4d4d2a9599185 to your computer and use it in GitHub Desktop.
cc-2018-03-30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix fun Int.toThePowerOf(exponent: Int): Int = Math.pow(this.toDouble(), exponent.toDouble()).toInt() | |
fun main(args: Array<String>) { | |
val sets = mutableListOf<Set<String>>() | |
sets.add(emptySet()) | |
for(setNumber in 1 until 2.toThePowerOf(args.size)) { | |
val set = mutableSetOf<String>() | |
for(itemNumber in 0 until args.size) { | |
if (2 toThePowerOf itemNumber and setNumber != 0) { | |
set.add(args[itemNumber]) | |
} | |
} | |
sets.add(set) | |
} | |
println(sets) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment