Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elcuervo/hamming
https://github.com/elcuervo/hamming
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/elcuervo/hamming
- Owner: elcuervo
- License: mit
- Created: 2021-04-29T13:28:36.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T00:52:27.000Z (almost 3 years ago)
- Last Synced: 2024-11-28T23:28:24.625Z (about 1 month ago)
- Language: Ruby
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hamming
## Install
```bash
gem install hamming
```## Usage
Hamming calculates the distance between two hashes or two vectors.
### Distance
Since hashes exist on a metric space you can measure how far a hash is from another.
```ruby
hash_a = "859091ce633aaebb"
hash_b = "859091ce633aaeba"
Hamming.distance(hash_a, hash_b)# You can also transform hashes based on your storage:
Hamming.vector_to_hash(hash)
Hamming.hash_to_vector(vector)
```