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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:05:02+00:00 2026-05-29T10:05:02+00:00

Team: I am building a business rules engine that is contextually aware — but

  • 0

Team:

I am building a business rules engine that is contextually aware — but it’s weighted — or in other words each business rule has a level of granularity defined by the segments of a key. The segments are not combinatorial in that they cannot be weighted in any order, but rather permutable like a combination lock (interestingly enough improperly named but widely accepted).

However, to reduce the amount of code that’s necessary to provide the business rules we are only building exclusion files meaning that each segment could end up with a specific key value or ALL.

So, now that we have an abstract background, let’s take a concrete example. The defined segments are as follows:

  1. Line of Business (LOB)
  2. Company
  3. State

Now, let’s assume for this example that the LOB is ABC, Company is G and State is WY. If you break that down I should get the following permutations:

  • ABC_G_WY
  • ABC_G_ALL
  • ABC_ALL_WY
  • ABC_ALL_ALL
  • ALL_G_WY
  • ALL_G_ALL
  • ALL_ALL_WY
  • ALL_ALL_ALL

However, I need an algorithm to solve that problem. The segments must also be returned in the aforementioned order because you must always find the most finite rule first.

I look forward to your responses and thank you all in advance!

  • 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-29T10:05:03+00:00Added an answer on May 29, 2026 at 10:05 am
    public static void Main(string[] args)
    {
        List<string> inputValues = new List<string>() { "ABC", "G", "WY" };
        List<string> results = new List<string>();
    
        int permutations = (int)Math.Pow(2.0, (double)inputValues.Count);
    
        for (int i = 0; i < permutations; i++)
        {
            int mask = 1;
            Stack<string> lineValues = new Stack<string>();
            for (int j = inputValues.Count-1; j >= 0; j--, mask <<= 1)
            {
                if ((i & mask) == 0)
                {
                    lineValues.Push(inputValues[j]);
                }
                else
                {
                    lineValues.Push("ALL");
                }
            }
            results.Add(string.Join("_", lineValues.ToArray())); //ToArray can go away in 4.0(?) I've been told.  I'm still on 3.5
        }
    
        foreach (string s in results)
        {
            Console.WriteLine(s);
        }
    
        Console.WriteLine("Press any key to exit...");
        Console.ReadKey(true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with a team that's building an engine for a variety of 2D
I'm working on a student project team building application. I'm familiar with optimization but
I'm building an Asp.net MVC 2 application. I have an entity called Team that
My team is building a product that has a lot of components that rely
I am building a website for a team that I am on. We have
I'm on a team that's currently building a MOSS 2007 based application (which relies
Im building an GUI that will help my team mates to execute some jars
My team are generally .Net developers but we are currently building a Drupal site,
I'm building a web application that will allow team collaboration. That is, a user
I'm part of a team building an ADO.NET based web-site. We sometimes have several

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.