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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:42:18+00:00 2026-05-15T09:42:18+00:00

Okay – I’m not even sure that the term is right – and I’m

  • 0

Okay – I’m not even sure that the term is right – and I’m sure there is bound to be a term for this – but I’ll do my best to explain. This is not quite a cross product here, and the order of the results are absolutely crucial.

Given:

IEnumerable<IEnumerable<string>> sets = 
      new[] { 
              /* a */ new[] { "a", "b", "c" },
              /* b */ new[] { "1", "2", "3" },
              /* c */ new[] { "x", "y", "z" }
            };

Where each inner enumerable represents an instruction to produce a set of concatenations as follows (the order here is important):

set a* = new string[] { "abc", "ab", "a" };
set b* = new string[] { "123", "12", "1" };
set c* = new string[] { "xyz", "xy", "x" };

I want to produce set ordered concatenations as follows:

set final = new string { a*[0] + b*[0] + c*[0], /* abc123xyz */
                         a*[0] + b*[0] + c*[1], /* abc123xy  */
                         a*[0] + b*[0] + c*[2], /* abc123x   */
                         a*[0] + b*[0],         /* abc123    */
                         a*[0] + b*[1] + c*[0], /* abc12xyz  */
                         a*[0] + b*[1] + c*[1], /* abc12xy   */
                         a*[0] + b*[1] + c*[2], /* abc12x    */
                         a*[0] + b*[1],         /* abc12     */
                         a*[0] + b*[2] + c*[0], /* abc1xyz   */
                         a*[0] + b*[2] + c*[1], /* abc1xy    */
                         a*[0] + b*[2] + c*[2], /* abc1x     */
                         a*[0] + b*[2],         /* abc1      */
                         a*[0],                 /* abc       */
                         a*[1] + b*[0] + c*[0], /* ab123xyz  */

                         /* and so on for a*[1] */
                         /* ... */

                         a*[2] + b*[0] + c*[0], /* a123xyz   */

                         /* and so on for a*[2] */
                         /* ... */

                         /* now lop off a[*] and start with b + c */

                         b*[0] + c*[0],         /* 123xyz    */

                         /* rest of the combinations of b + c
                            with b on its own as well */

                         /* then finally */
                         c[0],
                         c[1],
                         c[2]};

So clearly, there are going to be a lot of combinations!

I can see similarities with Numeric bases (since the order is important as well), and I’m sure there are permutations/combinations lurking in here too.

The question is – how to write an algorithm like this that’ll cope with any number of sets of strings? Linq, non-Linq; I’m not fussed.

Why am I doing this?

Indeed, why!?

In Asp.Net MVC – I want to have partial views that can be redefined for a given combination of back-end/front-end culture and language. The most basic of these would be, for a given base view View, we could have View-en-GB, View-en, View-GB, and View, in that order of precedence (recognising of course that the language/culture codes could be the same, so some combinations might be the same – a Distinct() will solve that).

But I also have other views that, in themselves, have other possible combinations before culture is even taken into account (too long to go into – but the fact is, this algo will enable a whole bunch of really cool that I want to offer my developers!).

I want to produce a search list of all the acceptable view names, iterate through the whole lot until the most specific match is found (governed by the order that this algo will produce these concatenations in) then serve up the resolved Partial View.

The result of the search can later be cached to avoid the expense of running the algorithm all the time.

I already have a really basic version of this working that just has one enumerable of strings. But this is a whole different kettle of seafood!

Any help greatly appreciated.

  • 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-15T09:42:19+00:00Added an answer on May 15, 2026 at 9:42 am

    This is my try:

    void Main()
    {
        IEnumerable<IEnumerable<string>> sets = 
              new[] { 
                      /* a */ new[] { "a", "b", "c" },
                      /* b */ new[] { "1", "2", "3" },
                      /* c */ new[] { "x", "y", "z" }
                    };
    
        var setCombinations = from set in sets
                              select (from itemLength in Enumerable.Range(1, set.Count()).Reverse()
                                      select string.Concat(set.Take(itemLength).ToArray()));
    
        IEnumerable<string> result = new[] { string.Empty };
    
        foreach (var list in setCombinations) {
            result = GetCombinations(result, list);
        }
        // do something with the result
    }
    
    IEnumerable<string> GetCombinations(IEnumerable<string> root, IEnumerable<string> append) {
        return from baseString in root
               from combination in ((from str in append select baseString + str).Concat(new [] { baseString }))
               select combination;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I kinda asked this question already, but noticed that i might have not
Okay i know i have to use the JDBC etc, but im not sure
Okay i have this problem with every page i make. im not sure what
Okay, I feel a bit foolish for having to ask this but I guess
Okay, this is probably a very basic question; but, I'm just getting back in
Okay, this should be really simple, but I have searched all over for the
Okay I do apologise that I'm out of my depth here. I'm not the
Okay, so this is the line that's returning null. What am I doing wrong
Okay, I'll be straight with you guys: I'm not sure exactly how Domain Driven
Okay, this might be a very silly beginner question, but: I've got an ClassA,

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.