Skip to content

Instantly share code, notes, and snippets.

@paplorinc
paplorinc / SecretSanta.groovy
Created November 28, 2016 13:42
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()