Skip to content

Instantly share code, notes, and snippets.

@l0rinc
Created November 28, 2016 13:42
Show Gist options
  • Save l0rinc/6da9efda122c112ef0cc54bc47625dbe to your computer and use it in GitHub Desktop.
Save l0rinc/6da9efda122c112ef0cc54bc47625dbe to your computer and use it in GitHub Desktop.
SecretSanta
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