How to create permutations of words in c-sharp
From Collectivesolver
In this example you can see how to create permutations of words(keywords) is C# (C-Sharp)
using System; using System.IO; using System.Collections.Generic; namespace Permutations_Words { class Class1 { static void Main(string[] args) { permutation_words(); } private static void permutation_words() { string[] stringInput = { "word-1", "word-2", "word-3" }; // You need to add your own words. You can add more or less the 3 words ShowPermutations<string>(stringInput, stringInput.Length); } static void ShowPermutations<T>(IEnumerable<T> input, int count) { string path_write = @"c:\temp\Test.txt"; // You can change the path and file name StreamWriter sw = File.CreateText(path_write); int j; foreach (IEnumerable<T> permutation in PermutationUtils.Permute<T>(input, count)) { j = 0; foreach (T pword in permutation) { if (j == 0) sw.Write(pword); else sw.Write(" " + pword); j++; } sw.WriteLine(); } sw.Close(); } } class PermutationUtils { public static IEnumerable<IEnumerable<T>> Permute<T>(IEnumerable<T> list, int count) { if (count == 0) { yield return new T[0]; } else { int startingElementIndex = 0; foreach (T startingElement in list) { IEnumerable<T> remainingItems = AllExcept(list, startingElementIndex); foreach (IEnumerable<T> permutationOfRemainder in Permute(remainingItems, count - 1)) { yield return Concat<T>(new T[] { startingElement }, permutationOfRemainder); } startingElementIndex += 1; } } } public static IEnumerable<T> Concat<T>(IEnumerable<T> x, IEnumerable<T> y) { foreach (T item in x) { yield return item; } foreach (T item in y) { yield return item; } } public static IEnumerable<T> AllExcept<T>(IEnumerable<T> input, int indexToSkip) { int index = 0; foreach (T item in input) { if (index != indexToSkip) yield return item; index += 1; } } } }
Result:
word-1 word-2 word-3
word-1 word-3 word-2
word-2 word-1 word-3
word-2 word-3 word-1
word-3 word-1 word-2
word-3 word-2 word-1
- You can use the program with your keywords for your PPC campaign on adword, adcenter, yahoo marketing and others
- Tested on visual studio 3.5
Permutation keyword example for google adword
using System; using System.IO; using System.Collections.Generic; namespace Permutations_Words { class Class1 { static void Main(string[] args) { permutation_words(); } private static void permutation_words() { string[] stringInput = { "make", "money", "on", "the", "internet" }; ShowPermutations<string>(stringInput, stringInput.Length); } static void ShowPermutations<T>(IEnumerable<T> input, int count) { string path_write = @"c:\temp\Test.txt"; // You can change the path and file name StreamWriter sw = File.CreateText(path_write); int j; foreach (IEnumerable<T> permutation in PermutationUtils.Permute<T>(input, count)) { j = 0; foreach (T pword in permutation) { if (j == 0) sw.Write(pword); else sw.Write(" " + pword); j++; } sw.WriteLine(); } foreach (IEnumerable<T> permutation in PermutationUtils.Permute<T>(input, count)) { sw.Write("\""); j = 0; foreach (T pword in permutation) { if (j == 0) sw.Write(pword); else sw.Write(" " + pword); j++; } sw.Write("\""); sw.WriteLine(); } foreach (IEnumerable<T> permutation in PermutationUtils.Permute<T>(input, count)) { sw.Write("["); j = 0; foreach (T pword in permutation) { if (j == 0) sw.Write(pword); else sw.Write(" " + pword); j++; } sw.Write("]"); sw.WriteLine(); } sw.Close(); } } class PermutationUtils { public static IEnumerable<IEnumerable<T>> Permute<T>(IEnumerable<T> list, int count) { if (count == 0) { yield return new T[0]; } else { int startingElementIndex = 0; foreach (T startingElement in list) { IEnumerable<T> remainingItems = AllExcept(list, startingElementIndex); foreach (IEnumerable<T> permutationOfRemainder in Permute(remainingItems, count - 1)) { yield return Concat<T>(new T[] { startingElement }, permutationOfRemainder); } startingElementIndex += 1; } } } public static IEnumerable<T> Concat<T>(IEnumerable<T> x, IEnumerable<T> y) { foreach (T item in x) { yield return item; } foreach (T item in y) { yield return item; } } public static IEnumerable<T> AllExcept<T>(IEnumerable<T> input, int indexToSkip) { int index = 0; foreach (T item in input) { if (index != indexToSkip) yield return item; index += 1; } } } }
Result:
make money on the internet
make money on internet the
make money the on internet
make money the internet on
make money internet on the
make money internet the on
make on money the internet
make on money internet the
make on the money internet
make on the internet money
make on internet money the
make on internet the money
make the money on internet
make the money internet on
make the on money internet
make the on internet money
make the internet money on
make the internet on money
make internet money on the
make internet money the on
make internet on money the
make internet on the money
make internet the money on
make internet the on money
money make on the internet
money make on internet the
money make the on internet
money make the internet on
money make internet on the
money make internet the on
money on make the internet
money on make internet the
money on the make internet
money on the internet make
money on internet make the
money on internet the make
money the make on internet
money the make internet on
money the on make internet
money the on internet make
money the internet make on
money the internet on make
money internet make on the
money internet make the on
money internet on make the
money internet on the make
money internet the make on
money internet the on make
on make money the internet
on make money internet the
on make the money internet
on make the internet money
on make internet money the
on make internet the money
on money make the internet
on money make internet the
on money the make internet
on money the internet make
on money internet make the
on money internet the make
on the make money internet
on the make internet money
on the money make internet
on the money internet make
on the internet make money
on the internet money make
on internet make money the
on internet make the money
on internet money make the
on internet money the make
on internet the make money
on internet the money make
the make money on internet
the make money internet on
the make on money internet
the make on internet money
the make internet money on
the make internet on money
the money make on internet
the money make internet on
the money on make internet
the money on internet make
the money internet make on
the money internet on make
the on make money internet
the on make internet money
the on money make internet
the on money internet make
the on internet make money
the on internet money make
the internet make money on
the internet make on money
the internet money make on
the internet money on make
the internet on make money
the internet on money make
internet make money on the
internet make money the on
internet make on money the
internet make on the money
internet make the money on
internet make the on money
internet money make on the
internet money make the on
internet money on make the
internet money on the make
internet money the make on
internet money the on make
internet on make money the
internet on make the money
internet on money make the
internet on money the make
internet on the make money
internet on the money make
internet the make money on
internet the make on money
internet the money make on
internet the money on make
internet the on make money
internet the on money make
"make money on the internet"
"make money on internet the"
"make money the on internet"
"make money the internet on"
"make money internet on the"
"make money internet the on"
"make on money the internet"
"make on money internet the"
"make on the money internet"
"make on the internet money"
"make on internet money the"
"make on internet the money"
"make the money on internet"
"make the money internet on"
"make the on money internet"
"make the on internet money"
"make the internet money on"
"make the internet on money"
"make internet money on the"
"make internet money the on"
"make internet on money the"
"make internet on the money"
"make internet the money on"
"make internet the on money"
"money make on the internet"
"money make on internet the"
"money make the on internet"
"money make the internet on"
"money make internet on the"
"money make internet the on"
"money on make the internet"
"money on make internet the"
"money on the make internet"
"money on the internet make"
"money on internet make the"
"money on internet the make"
"money the make on internet"
"money the make internet on"
"money the on make internet"
"money the on internet make"
"money the internet make on"
"money the internet on make"
"money internet make on the"
"money internet make the on"
"money internet on make the"
"money internet on the make"
"money internet the make on"
"money internet the on make"
"on make money the internet"
"on make money internet the"
"on make the money internet"
"on make the internet money"
"on make internet money the"
"on make internet the money"
"on money make the internet"
"on money make internet the"
"on money the make internet"
"on money the internet make"
"on money internet make the"
"on money internet the make"
"on the make money internet"
"on the make internet money"
"on the money make internet"
"on the money internet make"
"on the internet make money"
"on the internet money make"
"on internet make money the"
"on internet make the money"
"on internet money make the"
"on internet money the make"
"on internet the make money"
"on internet the money make"
"the make money on internet"
"the make money internet on"
"the make on money internet"
"the make on internet money"
"the make internet money on"
"the make internet on money"
"the money make on internet"
"the money make internet on"
"the money on make internet"
"the money on internet make"
"the money internet make on"
"the money internet on make"
"the on make money internet"
"the on make internet money"
"the on money make internet"
"the on money internet make"
"the on internet make money"
"the on internet money make"
"the internet make money on"
"the internet make on money"
"the internet money make on"
"the internet money on make"
"the internet on make money"
"the internet on money make"
"internet make money on the"
"internet make money the on"
"internet make on money the"
"internet make on the money"
"internet make the money on"
"internet make the on money"
"internet money make on the"
"internet money make the on"
"internet money on make the"
"internet money on the make"
"internet money the make on"
"internet money the on make"
"internet on make money the"
"internet on make the money"
"internet on money make the"
"internet on money the make"
"internet on the make money"
"internet on the money make"
"internet the make money on"
"internet the make on money"
"internet the money make on"
"internet the money on make"
"internet the on make money"
"internet the on money make"
[make money on the internet]
[make money on internet the]
[make money the on internet]
[make money the internet on]
[make money internet on the]
[make money internet the on]
[make on money the internet]
[make on money internet the]
[make on the money internet]
[make on the internet money]
[make on internet money the]
[make on internet the money]
[make the money on internet]
[make the money internet on]
[make the on money internet]
[make the on internet money]
[make the internet money on]
[make the internet on money]
[make internet money on the]
[make internet money the on]
[make internet on money the]
[make internet on the money]
[make internet the money on]
[make internet the on money]
[money make on the internet]
[money make on internet the]
[money make the on internet]
[money make the internet on]
[money make internet on the]
[money make internet the on]
[money on make the internet]
[money on make internet the]
[money on the make internet]
[money on the internet make]
[money on internet make the]
[money on internet the make]
[money the make on internet]
[money the make internet on]
[money the on make internet]
[money the on internet make]
[money the internet make on]
[money the internet on make]
[money internet make on the]
[money internet make the on]
[money internet on make the]
[money internet on the make]
[money internet the make on]
[money internet the on make]
[on make money the internet]
[on make money internet the]
[on make the money internet]
[on make the internet money]
[on make internet money the]
[on make internet the money]
[on money make the internet]
[on money make internet the]
[on money the make internet]
[on money the internet make]
[on money internet make the]
[on money internet the make]
[on the make money internet]
[on the make internet money]
[on the money make internet]
[on the money internet make]
[on the internet make money]
[on the internet money make]
[on internet make money the]
[on internet make the money]
[on internet money make the]
[on internet money the make]
[on internet the make money]
[on internet the money make]
[the make money on internet]
[the make money internet on]
[the make on money internet]
[the make on internet money]
[the make internet money on]
[the make internet on money]
[the money make on internet]
[the money make internet on]
[the money on make internet]
[the money on internet make]
[the money internet make on]
[the money internet on make]
[the on make money internet]
[the on make internet money]
[the on money make internet]
[the on money internet make]
[the on internet make money]
[the on internet money make]
[the internet make money on]
[the internet make on money]
[the internet money make on]
[the internet money on make]
[the internet on make money]
[the internet on money make]
[internet make money on the]
[internet make money the on]
[internet make on money the]
[internet make on the money]
[internet make the money on]
[internet make the on money]
[internet money make on the]
[internet money make the on]
[internet money on make the]
[internet money on the make]
[internet money the make on]
[internet money the on make]
[internet on make money the]
[internet on make the money]
[internet on money make the]
[internet on money the make]
[internet on the make money]
[internet on the money make]
[internet the make money on]
[internet the make on money]
[internet the money make on]
[internet the money on make]
[internet the on make money]
[internet the on money make]
- Just copy and paste the list of keywords result into your ad group.

