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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:34:46+00:00 2026-05-20T10:34:46+00:00

As you may have understood with the title, I need some smart thinking here

  • 0

As you may have understood with the title, I need some smart thinking here 🙂

I have a List<List<Object>> object. If you think of the Object objects as integers, you could see it like this :

{{1,2},{10,20,30},{100}}

I need to get all possible lists containing exactly one element of each list, that is, come up with this :

{{1,10,100},{1,20,100},{1,30,100},{2,10,100},{2,20,100},{2,30,100}}

Of course you don’t know at compiling time how much items the lists will contain, so you cannot rely on an overlapping of for loops…

How would you come up with this? Time constraints are not relevant to my problem because the lists will likely contain few elements.

  • 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-20T10:34:47+00:00Added an answer on May 20, 2026 at 10:34 am

    I won’t implement it, but here’s an idea for a recursive algorithm:

    • if we are dealing with a list containing a single list of elements (i.e.e.g {{1,2,3}}), then the result is – of course – a list of lists containing one element each (i.e.e.g. {{1},{2},{3}}
    • if we have more than one list in the list of lists, we do a recursive call of the algorithm. We take all resulting lists from this recursive call and combine each element of the first list of the list of lists with each list from the recursive call.

    Here’s raw Python code:

    def combiner(ll):
        if len(ll)==1:
            return [[x] for x in ll[0]] # base case
        firstlist = ll[0]
        result = []
        for i in combiner(ll[1:]): # recursive call
            for firstelem in firstlist:
                result.append([firstelem]+i) # combining lists
        return result
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

as you may have understood from the title, my question is that if it's
Ok so my question title may have been a little confusing. Here's my example:
I think I may have a misunderstanding of <xsl:variable\> and <xsl:value-of\> so perhaps someone
I think I may have accidently disabled stylecop in my Visual Studio 2008 enviroment.
Ok so the title may have been confusing so i have posted 2 code
I need some help at understanding how foreign keys and cascades work. I understood
I have a list of items that are in this format: 05/01 – Some
well, the title pretty much says it all. here's a little info: i have
This may not be explained the best but here it goes. I have a
You may have seen JavaScript sliders before: http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html What I'm envisioning is a circular

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.