Skip to content

Instantly share code, notes, and snippets.

@trygvea
Last active December 14, 2015 19:29
Show Gist options
  • Save trygvea/5137377 to your computer and use it in GitHub Desktop.
Save trygvea/5137377 to your computer and use it in GitHub Desktop.
Simple strings with identical hashcode
def alphabet = ('A'..'Z')+ ['Æ','Ø','Å']
def combinations = [:]
alphabet.each { first ->
alphabet.each { second ->
alphabet.each { third ->
def str = "" + first + second + third
def hash = str.hashCode()
if (combinations[hash]) {
println combinations[hash]+" has same hashcode as "+str+"!!!!!! ("+hash+")"
}
combinations[hash] = str
}
}
}
println "finito"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment