Solved

vb.net - generate specific word list

Posted on 2014-01-07
4
692 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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