Last active
December 14, 2015 19:29
-
-
Save trygvea/5137377 to your computer and use it in GitHub Desktop.
Simple strings with identical hashcode
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 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