Created
June 23, 2020 14:18
-
-
Save ashkrit/258ba868145b39743d3b5a5badcfbbfa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
Using bits count to find distance between 2 integer. Some of application are error deduction while data transfer | |
*/ | |
public class HammingDistance { | |
public static int weight(int value) { | |
return Bits.countBits(value); | |
} | |
public static int distance(int value1, int value2) { | |
return Bits.countBits(value1 ^ value2); | |
} | |
public static int distance(String value1, String value2) { | |
throw new IllegalArgumentException("Not implemented"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment