Skip to content

Instantly share code, notes, and snippets.

@kijuky
Created September 18, 2011 16:37
Show Gist options
  • Save kijuky/1225246 to your computer and use it in GitHub Desktop.
Save kijuky/1225246 to your computer and use it in GitHub Desktop.
佐賀Groovy勉強会 - 演習1:小町算
import groovyx.gpars.GParsPool
GParsPool.withPool {
def array = ["+", "-", "*", "/"]
def combi = GroovyCollections.combinations((1..2).collectParallel{ array }) // arrayから2つ選びだす順列
println combi //=> [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]]
combi.each {
def s = "1"
def i = 2
it.each {
s += it + (i++)
}
//println s
def eval = new Eval()
eval.me("if (" + s + " == 6) println \"" + s + "\"") // evaluation! と表示する
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment