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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:11:49+00:00 2026-05-28T14:11:49+00:00

I’ve got this – possibly trivial – loop/combinations problem similar to binary combinations. I

  • 0

I’ve got this – possibly trivial – loop/combinations problem similar to binary combinations. I don’t know how to approach it efficiently. Consider this scenario, I need unique loop to pass through all these combinations in a sequence:

Round  ABC

01.    000 <- values of A=0, B=0, C=0
02.    001
03.    010
04.    011
05.    100
06.    101
07.    110
08.    111

09.    002
10.    012
11.    102
12.    112
13.    020
14.    021
15.    120
16.    121 <- values of A=1, B=2, C=1
17.    022
18.    122
19.    220
20.    221
21.    222

Except there are 12 letters (A-L), and also the “bit” size is not just 0,1 or 2 but any integer number (from 0 possibly up-to 1000 or 1024, not to make it crazy). I know it’s a huge load of combinations, but I’ll just scrap just top few that also fulfill my other conditions. So no need to worry about computational madness.

Disclaimer: The order has to be exactly as shown above. NOT a multiple FOR loops going first 0-1024 for C, then B.

Thanks in advance, I just can’t seem to find the way to “algorithm it”.

Update: Added whole sequence for combinations of ABC/012

regards,
Kate

Explanation:

I’ve encountered this problem when trying to tackle problem of analyzing sum of money for its combination of coins/notes:

For example $5001 to find out x optimal combinations.

10x $500 + 1x $1
50x $100 + 1x $1
..

Now letters (A,B,C..) correspond to a number of possible values of banknotes or coins ($1, $5,.. $100). While base correspond to a number of pieces of that banknotes/coins (for example $5001/$5000 = 1piece max.)

  • 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-28T14:11:50+00:00Added an answer on May 28, 2026 at 2:11 pm

    if I guess your sequence right, you will have it easier to generate it recursively

    here an approach in Java, which should generate a sequence that matches your scenario.
    I hope it helps you (maybe I add more explanation later):

    public static void init() {
        // define constants
        final int length = 3;
        final char maxValue = '3';
    
        // define buffer
        final char[] array = new char[length]; java.util.Arrays.fill(array, '0');
        final boolean[] alreadySet = new boolean[length]; java.util.Arrays.fill(alreadySet, false);
    
        // fill first digit, then let the recursion take place
        for(char c = '1'; c <= (char)(maxValue); c++) {
            // iterate from lowest to highest digit
            for(int i = array.length-1; i >= 0; i--) {
                // set value
                array[i] = c;
                alreadySet[i] = true;
                // print value
                System.out.println(new String(array));
                // call recursion
                recursive(array, c, i, alreadySet, length);
                // unset value
                alreadySet[i] = false;
                array[i] = '0';
            }
        }
    }
    
    public static void recursive(char[] array, char lastValue, int lastIndex, boolean[] alreadySet, int leftToSet) {
        // if we didn't set all digits
        if(leftToSet > 0) {
            // iterate from lowest to highest digit
            for(int i = array.length-1; i >= 0; i--) {
                // missing all digits already set
                if(!alreadySet[i]) {
                    // count from 1 to lastValue-1
                    for(char c = '1'; c < lastValue; c++) {
                        // set value
                        array[i] = c;
                        alreadySet[i] = true;
                        // print value
                        System.out.println(new String(array));
                        // call recursion
                        recursive(array, c, i, alreadySet, leftToSet-1);
                        // unset value
                        alreadySet[i] = false;
                        array[i] = '0';
                    }
                }
            }
    
            char c = lastValue;
            // iterate from lowest to highest digit
            for(int i = array.length-1; i > lastIndex; i--) {
                // missing all digits already set
                if(!alreadySet[i]) {
                    // set value
                    array[i] = c;
                    alreadySet[i] = true;
                    // print value
                    System.out.println(new String(array));
                    // call recursion
                    recursive(array, c, i, alreadySet, leftToSet-1);
                    // unset value
                    alreadySet[i] = false;
                    array[i] = '0';
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
i got an object with contents of html markup in it, for example: string

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.