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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:01:08+00:00 2026-05-29T17:01:08+00:00

I have a set S . It contains N subsets (which in turn contain

  • 0

I have a set S. It contains N subsets (which in turn contain some sub-subsets of various lengths):

1. [[a,b],[c,d],[*]]
2. [[c],[d],[e,f],[*]]
3. [[d,e],[f],[f,*]]
N. ...

I also have a list L of ‘unique’ elements that are contained in the set S:

a, b, c, d, e, f, *

I need to find all possible combinations between each sub-subset from each subset so, that each resulting combination has exactly one element from the list L, but any number of occurrences of the element [*] (it is a wildcard element).

So, the result of the needed function working with the above mentioned set S should be (not 100% accurate):

- [a,b],[c],[d,e],[f];
- [a,b],[c],[*],[d,e],[f];
- [a,b],[c],[d,e],[f],[*];
- [a,b],[c],[d,e],[f,*],[*];

So, basically I need an algorithm that does the following:

  1. take a sub-subset from the subset 1,
  2. add one more sub-subset from the subset 2 maintaining the list of ‘unique’ elements acquired so far (the check on the ‘unique’ list is skipped if the sub-subset contains the * element);
  3. Repeat 2 until N is reached.

In other words, I need to generate all possible ‘chains’ (it is pairs, if N == 2, and triples if N==3), but each ‘chain’ should contain exactly one element from the list L except the wildcard element * that can occur many times in each generated chain.

I know how to do this with N == 2 (it is a simple pair generation), but I do not know how to enhance the algorithm to work with arbitrary values for N.

Maybe Stirling numbers of the second kind could help here, but I do not know how to apply them to get the desired result.

Note: The type of data structure to be used here is not important for me.

Note: This question has grown out from my previous similar 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-29T17:01:09+00:00Added an answer on May 29, 2026 at 5:01 pm

    These are some pointers (not a complete code) that can take you to right direction probably:

    1. I don’t think you will need some advanced data structures here (make use of erlang list comprehensions). You must also explore erlang sets and lists module. Since you are dealing with sets and list of sub-sets, they seems like an ideal fit.
    2. Here is how things with list comprehensions will get solved easily for you: [{X,Y} || X <- [[c],[d],[e,f]], Y <- [[a,b],[c,d]]]. Here i am simply generating a list of {X,Y} 2-tuples but for your use case you will have to put real logic here (including your star case)
    3. Further note that with list comprehensions, you can use output of one generator as input of a later generator e.g. [{X,Y} || X1 <- [[c],[d],[e,f]], X <- X1, Y1 <- [[a,b],[c,d]], Y <- Y1].
    4. Also for removing duplicates from a list of things L = ["a", "b", "a"]., you can anytime simply do sets:to_list(sets:from_list(L)).

    With above tools you can easily generate all possible chains and also enforce your logic as these chains get generated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two sets A and B. Set A contains unique elements. Set B
I have set of data which contains images also. I want to cache this
I have a set of zip files which contains several ieee-be encoded binary and
I have an array set inside a velocity template that contains some paths. The
I have a list of items which I would like to partition into subsets.
I have a string which contains a comma delimited list of id's which I
I have a set of data, with columns x and y. This set contains
I have a CompositeControl that contains a DropDownList. I have set the AutoPostBack property
I have a set of data that contains garbled text fields because of encoding
I have a data type that contains a set and a method that expects

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.