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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:25:40+00:00 2026-05-14T05:25:40+00:00

I would like to generate a combination of words. For example if I had

  • 0

I would like to generate a combination of words. For example if I had the following list:
{cat, dog, horse, ape, hen, mouse}
then the result would be n(n-1)/2
cat dog horse ape hen mouse
(cat dog) (dog horse) (horse ape) (ape hen) (hen mouse)
(cat dog horse) (dog horse ape) (horse ape hen) etc

Hope this makes sense…everything I found involves permutations

The list I have would be a 500 long

  • 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-14T05:25:40+00:00Added an answer on May 14, 2026 at 5:25 am

    Try this! :

    Public Sub test()
    
        Dim myAnimals As String = "cat dog horse ape hen mouse"
    
        Dim myAnimalCombinations As String() = BuildCombinations(myAnimals)
    
        For Each combination As String In myAnimalCombinations
            'Look on the Output Tab for the results!
            Console.WriteLine("(" & combination & ")")  
        Next combination
    
    
    End Sub
    
    
    
    Public Function BuildCombinations(ByVal inputString As String) As String()
    
        'Separate the sentence into useable words.
        Dim wordsArray As String() = inputString.Split(" ".ToCharArray)
    
        'A plase to store the results as we build them
        Dim returnArray() As String = New String() {""}
    
        'The 'combination level' that we're up to
        Dim wordDistance As Integer = 1
    
        'Go through all the combination levels...
        For wordDistance = 1 To wordsArray.GetUpperBound(0)
    
            'Go through all the words at this combination level...
            For wordIndex As Integer = 0 To wordsArray.GetUpperBound(0) - wordDistance
    
                'Get the first word of this combination level
                Dim combination As New System.Text.StringBuilder(wordsArray(wordIndex))
    
                'And all all the remaining words a this combination level
                For combinationIndex As Integer = 1 To wordDistance
    
                    combination.Append(" " & wordsArray(wordIndex + combinationIndex))
    
                Next combinationIndex
    
                'Add this combination to the results
                returnArray(returnArray.GetUpperBound(0)) = combination.ToString
    
                'Add a new row to the results, ready for the next combination
                ReDim Preserve returnArray(returnArray.GetUpperBound(0) + 1)
    
            Next wordIndex
    
        Next wordDistance
    
        'Get rid of the last, blank row.
        ReDim Preserve returnArray(returnArray.GetUpperBound(0) - 1)
    
        'Return combinations to the calling method.
        Return returnArray
    
    End Function
    

    The first function is just something that shows you how to call the second function. It really depends on how you get your 500 list – you can copy and paste it over the animal names, or you can load a file with the words in it. If it doesn’t fit on one line you can try:

        Dim myAnimals As New StringBulder 
        myAnimals.Append("dog cat ... animal49 animal50") 
        myAnimals.Append(" ") 
        myAnimals.Append("animal51 ... animal99") 
        myAnimals.Append(" ") 
        myAnimals.Append("animal100 ... animal150") 
    

    etc.

    then

    Dim myAnimalCombinations As String() = BuildCombinations(myAnimals.ToString)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to efficiently generate a unique list of combinations of numbers based
I would like to generate a patch with all commits from a local branch.
I would like to generate POJO, XML for a given database. Database: ( contents
i would like to generate a very simple report with some images and text
I would like to generate a short, unique ID without having to check for
I would like to generate a graphical sitemap for my website. There are two
I would like to generate the mysql-password hash from js. I know the method
I would like to generate a regex for a string like S67-90. I used
Question 1 We would like to generate a site map for our CMS site
I am creating a function that I would like to generate random strings from

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.