Created
February 24, 2012 22:17
-
-
Save thbkrkr/1904154 to your computer and use it in GitHub Desktop.
devoxxfr codestory #1
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
#!/usr/bin/groovy | |
map = [ 3:"Foo", 5:"Bar", 7:"Qix" ] | |
for (i in 1..100) { | |
r = "" | |
map.each{ k, v -> r += isDiv(i, k, v) } | |
map.each{ k, v -> r += has(i, k, v) } | |
println i + " -> " + ((r == "") ? i : r) | |
} | |
def isDiv(n, d, x) { | |
if (n % d == 0) return x else return "" | |
} | |
def has(n, m, x) { | |
h = "" | |
for (i in 0..<(n+"").count(m+"")) h += x | |
return h | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment