Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:44:54+00:00 2026-05-26T18:44:54+00:00

I have been trying to solve a programming problem, one of the modules of

  • 0

I have been trying to solve a programming problem, one of the modules of which requires me to generate Hamming sequences. The function takes input two numbers first a binary number N and another a decimal number K. It should now generate all possible numbers having a Hamming distance of up to K from N.

It would be really helpful if you provide me with an algorithm about how to solve this problem.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:44:55+00:00Added an answer on May 26, 2026 at 6:44 pm

    The algorithm is pretty simple. You just need to chose all possible binary numbers contains from 0 to K ones. And then xor it with N, just like this:

        public static Char[] Xor(Char[] a, Char[] b)
        {
            Char[] c = new Char[a.Length];
            for (Int32 i = 0; i < a.Length; ++i)
                if (a[i] == b[i])
                    c[i] = '0';
                else
                    c[i] = '1';
    
            return c;
        }
    
        public static void Generate(Char[] original, Char[] current, int position, int k)
        {
            if (position == original.Length)
            {
                Console.WriteLine(Xor(original, current));
                return;
            }
    
            if (k > 0)
            {
                current[position] = '1';
                Generate(original, current, position + 1, k - 1);
            }
    
            current[position] = '0';
            Generate(original, current, position + 1, k);
        }
    
        // Find all Number with hamming distance up to 2 from 01100
        Generate("01100".ToCharArray(), "00000".ToCharArray(), 0, 2);
    

    Note: count of numbers that have Hamming distance up to K from N can be extremely big, as soon it exponentially grows depend on value of K.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to solve this problem for a while, but couldn't with
I have an interesting problem here I've been trying to solve for the last
I have been trying to solve this problem the whole day: How do I
I have been trying to solve Project Euler's problem #59 for a while, and
I have a problem that I have been trying to solve since days! I
I have been trying to solve this Concurrent Programming exam exercise (in C#): Knowing
I have been trying to solve this strange problem with a website I am
I have been trying to solve this problem for hours (searched here as well
I have been trying to solve this problem for three days now, it's really
I have been trying to solve this one for a while now and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.