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

  • Home
  • SEARCH
  • 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 4001284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:53:09+00:00 2026-05-20T07:53:09+00:00

If you know what this kind of problem is called, let me know (unless

  • 0

If you know what this kind of problem is called, let me know (unless you actually know the answer to the question).

If I have a set Z of objects, is there an algorithm for diving them up between a bunch of containers (each holding a certain number of objects)?

To slightly complicate the problem, let’s assume the set of objects we start with has a subset X. There are X containers, and each container must hold a single element of X, in addition to other objects (if it has room).

The best way I can think of doing this currently is looking at the disjunction of Z and X, let’s call it Y. Then we can generate the z choose x combinations, and then expand that out for all possible combinations of x.

Example:
The actual problem is basically generating all events in a space. Suppose we have two event triggers (X) and 2 event arguments (Y), where Z = X U Y. Each event must have a trigger, and it can have 0…N arguments (depending on the type of event, but that isn’t important for now. A trigger can also be an argument. Clearly, in this situation we can have a single event with one trigger and 3 arguments (one of which is the second trigger)

Our event space is as follows (Trigger[Arguments], + indicates a new event):

X1[] + X2[]
X1[Y1] + X2[]
X1[Y2] + X2[]
X1[] + X2[Y1]
X1[] + X2[Y2]
X1[Y1] + X2[Y2]
X1[Y2] + X2[Y1]
X1[X2]
X1[X2,Y1]
X1[X2,Y2]
X1[X2,Y1,Y2]
X2[X1]
X2[X1,Y1]
X2[X1,Y2]
X2[X1,Y1,Y2]

I’m pretty sure that’s all the combinations.

Update:
After thinking a bit more about the problem, I have a few thoughts on constraints and stuff: Rules for creating “events”:
1) There is an event for every trigger, and every event must have a trigger
2) Event must have > 0 arguments
3) Events cannot share arguments
4) Triggers can be used as arguments

For a brute force solution, perhaps one could generate all permutations of the triggers + events and then eliminate results that don’t match the above 4 rules, and treat the ordering as grouping of events?

Thanks for any problem names or ideas!

  • 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-20T07:53:09+00:00Added an answer on May 20, 2026 at 7:53 am

    Algorithm:

    For all nonempty subsets Triggers of X:
        For all maps from (X \ Triggers) to X:
            For all maps from Y to (X union {None}):
                print the combination, where an assignment of y in Y to None means y is omitted
    

    In Python:

    def assignments(xs, ys):
        asgns = [[]]
        for x in xs:
            asgns1 = []
            for y in ys:
                for asgn in asgns:
                    asgn1 = asgn[:]
                    asgn1.append((x, y))
                    asgns1.append(asgn1)
            asgns = asgns1
        return asgns
    
    def combinations(xs, ys):
        xroleasgns = assignments(xs, ('argument', 'trigger'))
        for xroleasgn in xroleasgns:
            triggers = [x for (x, role) in xroleasgn if role == 'trigger']
            if (xs or ys) and not triggers:
                continue
            xargs = [x for (x, role) in xroleasgn if role == 'argument']
            for xargasgn in assignments(xargs, triggers):
                for yargasgn in assignments(ys, [None] + triggers):
                    d = dict((x, []) for x in triggers)
                    for xarg, t in xargasgn:
                        d[t].append(xarg)
                    for yarg, t in yargasgn:
                        if t is not None:
                            d[t].append(yarg)
                    print ' + '.join('%s[%s]' % (t, ','.join(args)) for (t, args) in d.iteritems())
    
    
    """
    >>> assign.combinations(['X1','X2'],['Y1','Y2'])
    X1[X2]
    X1[X2,Y1]
    X1[X2,Y2]
    X1[X2,Y1,Y2]
    X2[X1]
    X2[X1,Y1]
    X2[X1,Y2]
    X2[X1,Y1,Y2]
    X2[] + X1[]
    X2[] + X1[Y1]
    X2[Y1] + X1[]
    X2[] + X1[Y2]
    X2[] + X1[Y1,Y2]
    X2[Y1] + X1[Y2]
    X2[Y2] + X1[]
    X2[Y2] + X1[Y1]
    X2[Y1,Y2] + X1[]
    
    
    """
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is kind of a dumb question, but does anyone have an
I know this question has kind-a started religious wars in past and there might
This may be subjective, I don't know: I have this problem, which I'm kind
It is design problem. Let's assume that we have this kind of model in
I know this kind of questions have been asked already many times before. The
Answer: I know this is not the kind of thing that goes well as
I know this is an old question and must have been answered hundred times
I know that this kind of issue is most discussed. But I would like
What does this bit of code represent? I know it's some kind of if
I know this is largely an opinion, but I'm interested if you have one

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.