Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vb.net - generate specific word list

Posted on 2014-01-07
4
Medium Priority
?
775 Views
Last Modified: 2014-01-08
Hello there,
I have a list of 100 words for example

dog
cat
bird
monkey
mouse
fish
whale
horse
chicken

I would like to know how can I generate a unique and complete list using 3 words
something like this

chicken_cat_whale
horse_fish_mouse

etc..
0
Comment
Question by:XK8ER
4 Comments
 
LVL 30

Expert Comment

by:Brad Howe
ID: 39764073
Does order or repetition count?
0
 
LVL 1

Author Comment

by:XK8ER
ID: 39764097
dog_dog_cat doesnt work
dog_cat_dog  doesnt work

they must be different.. the order doesn't matter..
0
 
LVL 7

Expert Comment

by:Kishan Zunjare
ID: 39764812
Put all 100 words in array, and apply for loop over 100 words; take a new hashtable, create a string of 3 words combining with underscore(_). Add this key value pair in hashtable, before adding you can check whether string is already added or not..

Hope this will help you.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39766324
Using LINQ:

Module Module1
    Sub Main()
        Dim wordList As New List(Of String)() From
        {
            "dog",
            "cat",
            "bird",
            "monkey",
            "mouse",
            "fish",
            "whale",
            "horse",
            "chicken"
        }

        Dim query = From firstWord In wordList
                    From secondWord In wordList
                    From thirdWord In wordList
                    Where firstWord <> secondWord AndAlso
                          firstWord <> thirdWord AndAlso
                          secondWord <> thirdWord
                    Select String.Format("{0}_{1}_{2}", firstWord, secondWord, thirdWord)

        For Each item In query
            Console.WriteLine(item)
        Next

        Console.ReadKey()
    End Sub
End Module

Open in new window


The multiple From effectively give you a Cartesian join of all the words. Then it simply becomes a matter of excluding the ones you don't want--in this case, the ones containing duplicates.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question