Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to solve this weird multiple loops scenario (Java or C#)?
    primarykey
    data
    text
    <p>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:</p> <pre><code>Round ABC 01. 000 &lt;- 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 &lt;- values of A=1, B=2, C=1 17. 022 18. 122 19. 220 20. 221 21. 222 </code></pre> <p>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. </p> <p>Disclaimer: The order has to be exactly as shown above. NOT a multiple FOR loops going first 0-1024 for C, then B.</p> <p>Thanks in advance, I just can't seem to find the way to "algorithm it".</p> <p>Update: Added whole sequence for combinations of ABC/012</p> <p>regards, Kate</p> <p>Explanation:</p> <p>I've encountered this problem when trying to tackle problem of analyzing sum of money for its combination of coins/notes: </p> <p>For example $5001 to find out x optimal combinations.</p> <pre><code>10x $500 + 1x $1 50x $100 + 1x $1 .. </code></pre> <p>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.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload