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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:10:31+00:00 2026-05-29T23:10:31+00:00

I am trying to figure how how to find all the combinations given the

  • 0

I am trying to figure how how to find all the combinations given the following information:

I start with a JSON dataset:

var choices = { 1: {'Q': 100, 'R': 150, 'W' : 250, 'T', 30},
                2: {'Q': 90, 'R': 130, 'W' : 225, 'T', 28},
                3: {'Q': 80, 'R': 110, 'W' : 210, 'T', 25},
                4: {'Q': 70, 'R': 90, 'W' : 180, 'T', 22},
                5: {'Q': 60, 'R': 70, 'W' : 150, 'T', 18},
                6: {'Q': 50, 'R': 50, 'W' : 110, 'T', 15},
                7: {'Q': 40, 'R': 30, 'W' : 80, 'T', 11},
                8: {'Q': 30, 'R': 25, 'W' : 50, 'T', 8},
                9: {'Q': 20, 'R': 10, 'W' : 25, 'T', 5},
                10: {'Q': 10, 'R': 5, 'W' : 15, 'T', 3}
              };

What I’m trying to figure out is how I can take this dataset, and generate all possible combinations when selecting either the ‘Q’, ‘R’, ‘W’, or ‘T’ element for each row.

So I hope my end result will be something like this

var allChoices = { 0: {1: {'Q': 100},
                       2: {'R': 130},
                       3: {'W' : 210},
                       4: {'W' : 180},
                       5: {'T', 18},
                       6: {'R': 50,},
                       7: {'Q': 40,},
                       8: {'T', 8},
                       9: {'R': 10},
                      10: {'W' : 15},
                     },
                 1: {...},
                 ...
                 1048576: {...}

              };

I used JSON because I think it is the easiest to visualize but does anyone know how I could go about accomplishing this in c#?

Let me know if this not clear enough I’m having a hard time figuring out how exactly to ask this question.

  • 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-29T23:10:33+00:00Added an answer on May 29, 2026 at 11:10 pm

    Here’s How to do it using depth first Recursion. Takes about 3 seconds to run on my machine. Also this will work for an arbitrary sized pairing by changing the PAIRCOUNT to say 5 if you had 5 columns instead of 4 and just .add the additional Pairs as appropriate.

        void Main()
        {
            var OriginValues = new List<KeyValuePair<char, int>>();
            OriginValues.Add(new KeyValuePair<char, int>('Q', 100));
            OriginValues.Add(new KeyValuePair<char, int>('R', 150));
            OriginValues.Add(new KeyValuePair<char, int>('W', 250));
            OriginValues.Add(new KeyValuePair<char, int>('T', 30));
    
            OriginValues.Add(new KeyValuePair<char, int>('Q', 90));
            OriginValues.Add(new KeyValuePair<char, int>('R', 130));
            OriginValues.Add(new KeyValuePair<char, int>('W', 225));
            OriginValues.Add(new KeyValuePair<char, int>('T', 28));
    
            OriginValues.Add(new KeyValuePair<char, int>('Q', 80));
            OriginValues.Add(new KeyValuePair<char, int>('R', 110));
            OriginValues.Add(new KeyValuePair<char, int>('W', 210));
            OriginValues.Add(new KeyValuePair<char, int>('T', 25));
    
            ///... and the other 7
    
            var AllPermutation = new List<List<KeyValuePair<char, int>>>();
            Recurse(OriginValues, ref AllPermutation);
    
            //all results will be in AllPermutation now
    
        }
    
        const int PAIRCOUNT = 4;
        void Recurse(List<KeyValuePair<char, int>> OriginValues, ref List<List<KeyValuePair<char, int>>> result, List<KeyValuePair<char, int>> itemset = null)
        {
            itemset = itemset ?? new List<KeyValuePair<char, int>>();
            var temp = new List<KeyValuePair<char, int>>(itemset);
            if (itemset.Count == OriginValues.Count / PAIRCOUNT)
            {
                result.Add(temp);
                return;
            }
            for (int x = 0; x < PAIRCOUNT; x++)
            {
                temp.Add(OriginValues[itemset.Count * PAIRCOUNT + x]);
                Recurse(OriginValues, ref result,  temp);
                temp = new List<KeyValuePair<char, int>>(itemset);
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how to find all matches of string in
I'm trying to figure out an algorithm to find the highest 2 numbers in
I am trying to figure out how to find the % based on two
I'm trying to figure out a way to find out which files were affected
I am really having trouble trying to figure out how to find certain records
So I'm trying to find all the uppercase letters in a string put in
I am trying to find all combination of numbers in a list that gives
How do I find number of all the series (combinations of an array that
Im trying to find all p tags with inline style attrs style=text-align:center; that contain
Hey I'm trying to figure something out.. I want to get all Carts that

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.