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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:09:32+00:00 2026-06-17T07:09:32+00:00

For a project I’m working on, I need a way to calculate a unique

  • 0

For a project I’m working on, I need a way to calculate a unique integer representation of a data structure with type [(int, int)], i. e. a collection of (nonnegative) integer pairs. The requirement is that while the ordering within the pair matters, the collection itself is order-insensitive. After some searching, I’ve come believe that a suitable solution would be to encode each pair using the Cantor pairing function and xor the results.

The range will be fairly small, say 1-700 for the first integer in the pair, 1-10 for the second one and the list will contain around 5-15 of these pairs.

If you believe there’s a better solution, let me know, but an answer “yes, this will work” would be terrific as well 🙂

  • 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-06-17T07:09:33+00:00Added an answer on June 17, 2026 at 7:09 am

    [This answer assumes that when you say “unique”, you really mean that; collisions are unacceptable.]

    If the aim is to somehow uniquely map an arbitrary-sized collection of integer (pairs) onto a single (reasonably-sized) integer, then the answer is essentially “that’s not possible”. This can easily be demonstrated by appealing to the pigeonhole principle.

    If the size of your collections is extremely limited, and the range of the input integers is extremely limited, then you may be able to do something. But in the general case, I’d suggest looking for a different solution to whatever your top-level problem is.


    Update

    As a worked example, let’s consider the parameters you added to your question. 700 * 10 = 7000, so you need roughly 13 bits to uniquely represent each possible pair. With a maximum of 15 pairs, that’s 195 bits needed in total.

    Now, if order doesn’t matter, then you can theoretically drop log2(15!) = 40 bits.* So in theory, you need an output datatype with 155 bits. Is that tractable?


    * How one achieves this in practice is another question… 😉

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

Sidebar

Related Questions

My project has a need to cache on the iOS device data retrieved from
Project layout: /project_a /shared /project_b /shared /shared project_a and project_b both need to contain
The project that I am working on (Node.js) implies lots of operations with the
Project I'm working on uses jQuery. I have a series of Ajax calls being
Project A contains a WPF Window (Data Entry Form) with a stack panel of
Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on
Project Structure I have a silverlight project SLProj, that references a silverlight class library
Project was working on PC number 1. Copied project to external drive and trying
Project Scenario Technology : Dotnetnuke (Approx. 100 - 150 screens) Data Architecture : LINQ
The project I am currently working on has, in the checkout, an option to

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.