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 132219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:13:41+00:00 2026-05-11T06:13:41+00:00

I am facing the problem of having several integers, and I have to generate

  • 0

I am facing the problem of having several integers, and I have to generate one using them. For example.

Int 1: 14 Int 2: 4 Int 3: 8 Int 4: 4  Hash Sum: 43 

I have some restriction in the values, the maximum value that and attribute can have is 30, the addition of all of them is always 30. And the attributes are always positive.

The key is that I want to generate the same hash sum for similar integers, for example if I have the integers, 14, 4, 10, 2 then I want to generate the same hash sum, in the case above 43. But of course if the integers are very different (4, 4, 2, 20) then I should have a different hash sum. Also it needs to be fast.

Ideally I would like that the output of the hash sum is between 0 and 512, and it should evenly distributed. With my restrictions I can have around 5K different possibilities, so what I would like to have is around 10 per bucket.

I am sure there are many algorithms that do this, but I could not find a way of googling this thing. Can anyone please post an algorithm to do this?.

Some more information

The whole thing with this is that those integers are attributes for a function. I want to store the values of the function in a table, but I do not have enough memory to store all the different options. That is why I want to generalize between similar attributes.

The reason why 10, 5, 15 are totally different from 5, 10, 15, it is because if you imagine this in 3d then both points are a totally different point

Some more information 2

Some answers try to solve the problem using hashing. But I do not think this is so complex. Thanks to one of the comments I have realized that this is a clustering algorithm problem. If we have only 3 attributes and we imagine the problem in 3d, what I just need is divide the space in blocks.

In fact this can be solved with rules of this type

if (att[0] < 5 && att[1] < 5 && att[2] < 5 && att[3] < 5)      Block = 21   if ( (5 < att[0] < 10) &&  (5 < att[1] < 10) &&  (5 < att[2] < 10) &&  (5 < att[3] < 10))      Block = 45 

The problem is that I need a fast and a general way to generate those ifs I cannot write all the possibilities.

  • 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. 2026-05-11T06:13:42+00:00Added an answer on May 11, 2026 at 6:13 am

    Given the inputs a, b, c, and d, each ranging in value from 0 to 30 (5 bits), the following will produce an number in the range of 0 to 255 (8 bits).

    bucket = ((a & 0x18) << 3) | ((b & 0x18) << 1) | ((c & 0x18) >> 1) | ((d & 0x18) >> 3) 

    Whether the general approach is appropriate depends on how the question is interpreted. The 3 least significant bits are dropped, grouping 0-7 in the same set, 8-15 in the next, and so forth.

    0-7,0-7,0-7,0-7 -> bucket 0 0-7,0-7,0-7,8-15 -> bucket 1 0-7,0-7,0-7,16-23 -> bucket 2 ... 24-30,24-30,24-30,24-30 -> bucket 255 

    Trivially tested with:

    for (int a = 0; a <= 30; a++)     for (int b = 0; b <= 30; b++)         for (int c = 0; c <= 30; c++)             for (int d = 0; d <= 30; d++) {                 int bucket = ((a & 0x18) << 3) |                              ((b & 0x18) << 1) |                              ((c & 0x18) >> 1) |                              ((d & 0x18) >> 3);                 printf('%d, %d, %d, %d -> %d\n',                          a,  b,  c,  d,   bucket);             } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer What changes you need depends mostly on what queries you… May 11, 2026 at 2:11 pm
  • added an answer Your first assumption is correct. To your second question, it… May 11, 2026 at 2:11 pm
  • added an answer Okay, let's step through your program line by line. I'm… May 11, 2026 at 2:11 pm

Related Questions

I'm a junior student in IT. I am facing a problem with the output
I am facing a problem with .NET generics. The thing I want to do
I am facing the dreaded Unhandled Exception raised by Flup. The sad part is
I am facing problem with an Oracle Query in a .net 2.0 based windows
I am facing strange issue on Windows CE: Running 3 EXEs 1)First exe doing
With reference to this programming game I am currently building. alt text http://img12.imageshack.us/img12/2089/shapetransformationf.jpg To
The project I am working on requires some executions to be done at a
Okay, I know I'm doing something wrong - but can't figure out a better
I am working on a C++ app which internally has some controller objects that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.