Questions tagged [hamming-distance]

The Hamming distance is a mathematical distance function for a pair of strings (sequences) that can be computed with a binary calculation. It counts the number of symbols in the string that are different. Posts that are not about implementation may belong on https://math.stackexchange.com.

For the special case of two binary strings, it may be implemented as the bitcount of their XOR:

int H(int a, int b){
    return popcount(a^b);
}
291 questions
0
votes
1 answer

Breaking XOR repeated key

I want to break XOR repeated key, I dont now anything about the key nor the message, only thing I know that it is using repeated key. Encoded message s beenbase64'd after being encrypted with repeating-key XOR so I converted base 64 to base16 first…
Nikola Lošić
  • 479
  • 1
  • 6
  • 18
0
votes
1 answer

Partial Substring Matching in Python

I'm interested in creating a program that will search for a certain string (known henceforth as string A) in a large library of other strings. Basically, if string A existed in the library it would be discarded and another string's existence would…
0
votes
3 answers

Finding the best matching sequence

I have 2 files of sequences. Say ham1.txt : AAACCCTTTGGG AGGTACTTTTTT TCTCTTTTTTTT and so on ham2.txt: AAACCCTTTGGG GAGAGGGAGGGC AGGTACTTTTTT CTCTTAATTTCC TCTCTTTTTTTT GTTTTTAAAAAA I want to match sequences in ham1.txt to those in ham2.txt…
Ssank
  • 3,367
  • 7
  • 28
  • 34
0
votes
2 answers

Explanation of older post: Appending a List and Recursion (Hamming Distance) - Python 3

An older post had this code in it: def hamming(num, dist): if dist == 0: return num else: outputlist = list() for item in range(len(num)): if len(num[item:]) > dist - 1: if num[item] ==…
user3290553
  • 87
  • 1
  • 2
  • 9
0
votes
2 answers

Appending a List and Recursion (Hamming Distance) - Python 3

I'm supposed to write a program that takes a string of binary code and a number, and outputs all the strings within that hamming distance of the original string. I have a function that does everything, but in the output there are lists within lists.…
user3361007
  • 15
  • 1
  • 5
0
votes
1 answer

Object Detection with Hamming distance

I am using FAST and FREAK to get the descriptors of a couple of images and then I apply knnMatch with a BruteForceMatcher matcher and next I am using a loop to separate the good matches: float nndrRatio = 0.7f; std::vector keypointsA,…
Str1101
  • 859
  • 2
  • 12
  • 22
0
votes
1 answer

Hamming weight for vector C++

I'm working on a the Hamming weight for a vector and what I do is count in linear way all the 1 in the vector, is there any more efficient way? int HammingWeight(vector a){ int HG=0; for(int i=0; i
Trouner
  • 316
  • 2
  • 13
0
votes
0 answers

8-Puzzle Solver unexpected behavior

I am working on a 8-Puzzle Solver -using best-first search+ Hamming distance(tiles out of place) heuristic- which was required from us as a project. I first defined a Stat Struct in a separated cpp file which looks like this in the header file…
-1
votes
2 answers

Finding the closest sub-string by Hamming distance

I need to find the substring of s that is closest to a string by Hamming distance and have it return a tuple of the index of the closest substring, the Hamming distance of the closest substring to p, and the closest substring itself. I have this…
-1
votes
1 answer

Designing a circuit that calculates Hamming distance?

I came across this question and I couldn't find it in textbooks or the internet. Seems pretty unique. I guess there would be some comparators and adders involved, but I have no clue where to start.
-1
votes
1 answer

Combinations in java

I write a java code to write all combinations of bit string with length N" . this code print all combination but I want to have all combination with exactly N length and "H" 1's. like N=4 & H=2 => 0011,0101,0110,1100,1010,1001 public void…
-1
votes
1 answer

C++ Hamming Function

This program is supposed to create three arrays of class object My_array. The first array is filled with random numbers. The second array is an exact copy of the first. The third array is entered by the user. The program checks to make sure that the…
-1
votes
1 answer

Minimal Hamming distance subvector

Let U small alphabet 0, 1 or A, C, G, T, k <= n. I want to find minimum Hamming distance between u = (u_1,...,u_k) and the contiguous subsequences of v = (v_1,...,v_n) of length k in time O(n log n). Is it possible? Thank you for any help!
-1
votes
3 answers

Take care about precedence of * and ++ in C/C++, (and any keystroke when programming)

Somebody write this function void strToUpper(char *p) { while (*p) { *p = TOUPPER(*p); *p++; //<-- Line to pay attention } } I asked, why do you put the * before p++? answer: because "It's the same", I corrected the code…
-1
votes
1 answer

Error detecting code and Hamming distance

The Hamming distance of v and w equals 2, but without parity bit it would be just 1. Why is this the case?
methuselah
  • 12,766
  • 47
  • 165
  • 315
1 2 3
19
20