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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:51:32+00:00 2026-06-14T10:51:32+00:00

I’ve been making a lot of progress on a problem I’ve been trying to

  • 0

I’ve been making a lot of progress on a problem I’ve been trying to solve lately, but I could use some advice on a particular ordering problem. I’m trying to find a way to represent the lexicographical order of a list of numbers, each having it’s own range (defined before ordering is a concern).

Each list has 7 elements. Each element can have a range of anywhere from 0 to 0-3. Perhaps a concrete example will help.

I have an array with 7 elements [2, 1, 0, 1, 3, 2, 3]. This list abstractly represents a number of possible lists for which I want to generate a lexicographical order. (Edit: To be more clear. The values at each digit represent the maximum value that that digit can be in the set of possible lists. As such, the first digit in the example could be thought of as a base 4 number, the second as a base 2 number, the third as a base 1 number, etc.) The first few elements to this list would be as follows:

  1. [0, 0, 0, 0, 0, 0, 0]
  2. [1, 0, 0, 0, 0, 0, 0]
  3. [2, 0, 0, 0, 0, 0, 0]
  4. [0, 1, 0, 0, 0, 0, 0]
  5. [1, 1, 0, 0, 0, 0, 0]
  6. [2, 1, 0, 0, 0, 0, 0]
  7. [0, 0, 0, 1, 0, 0, 0]
  8. [1, 0, 0, 1, 0, 0, 0]

Hopefully the pattern is clear. I would then like to be able to efficiently call a function f(m) which returns the mth value in this sequence. I found this article which feels like it gets really close to what I’m looking for (it provides an efficient way to get the lexicographical mth place in a set with fixed value combinations), but I’m having trouble bridging the gap between the two ideas (although I have recreated the results in the article and I believe I understand them somewhat).

Anyone have any ideas on how to create a function f(m) which returns the mth value in a sequence defined by a 7 element list similar to the one provided in the above example?

P.S. I apologize if this problem has been restated in some other form and I have not found it. I have done significant searching, but nothing seems to quite map back on to this. Links, brainstorming, general ideas are all welcome!

Edit 2: Fixed the error in my example where the first element was 3 instead of 2.

  • 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-14T10:51:33+00:00Added an answer on June 14, 2026 at 10:51 am

    Edit: Replaced the original answer with the far more straightforward conversion. Check the earlier revision if you really want to see the backward solution.

    Note that the initial array you give does not match the sample list (the first element of the array should be 2). I’ll use the corrected array in my answer.

    Given an input array [2, 1, 0, 1, 3, 2, 3], the number of possible elements at each position is,

    [3,2,1,2,4,3,4]
    

    giving us 3*2*1*2*4*3*4 = 576 possibilities.

    To determine leftmost (low order) element the value of the mth member of the list, where 0 <= m < 576, we need to find the remainder of m/3, or m mod 3. The next element would be (m div 3) mod 2, and so on. In pseudocode, then:

    increment all elements of A by 1
    
    // we now have A = [3,2,1,2,4,3,4]
    // m is given
    // result is in R[7]
    for i = 0 to 6
        R[i] = m mod A[i];
        m = m div A[i];
    end
    

    If you adjust your sample list above to start at 0 you should get the same results. Here’s a sample calculation using A = [3,2,1,2,4,3,4] and m = 11:

    11 mod 3 = 2 (11 div 3 = 3)
     3 mod 2 = 1 (3 div 2 = 1)
     1 mod 1 = 0 (1 div 1 = 1)
     1 mod 2 = 1 (1 div 2 = 0)
     0 mod 4 = 0
     0 mod 3 = 0
     0 mod 4 = 0
    

    So the 11th list element (zero-based) is [2,1,0,1,0,0,0].

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
This could be a duplicate question, but I have no idea what search terms
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.