Created
November 28, 2016 13:42
-
-
Save l0rinc/6da9efda122c112ef0cc54bc47625dbe to your computer and use it in GitHub Desktop.
SecretSanta
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
def names = ['Agnes', 'Akos', 'Anna', 'Berend', 'Geza', 'Istvan', 'Karel', 'Lorinc', 'Marta', 'Noemi', 'Orsi', 'Zsofi'].sort() | |
names = names*.padRight(names*.length().max()) | |
def draws = (0..<names.size()).toList().sort() { Math.random() } | |
draws.eachWithIndex { source, target -> assert source != target } | |
def linkBase = 'https://www.google.ro/search?q=' | |
def encode = { "%${Integer.toHexString(it).toUpperCase()}" } | |
def encodedNames = names[draws]*.bytes*.collect(encode)*.join() | |
[names, encodedNames].transpose().forEach { source, target -> | |
println "${source}: ${linkBase}${target}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment