473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Permutations

This is a bit of a basic question.

I have an array of names that the user has entered (up to 4). I want to
check every permutation of those names against the four different name fields
in the database (First, Last, Middle and Alias). No repetition in names, each
search term is used once per query.

How do I generate every permutation of the names? e.g. ABCD, ABDC, ACBD,
ACDB... etc?

Is there a formula, or do I just hardcode?

Ideally, I'd like a formula that returns every permutation for an array of
size N, but a specific solution for N=4 is okay too.
--
David Streeter
Synchrotech Software
Sydney Australia
Aug 1 '08 #1
2 3396
On Aug 1, 5:38 am, SurturZ <surt...@newsgroup.nospamwrote:
This is a bit of a basic question.

I have an array of names that the user has entered (up to 4). I want to
check every permutation of those names against the four different name fields
in the database (First, Last, Middle and Alias). No repetition in names, each
search term is used once per query.

How do I generate every permutation of the names? e.g. ABCD, ABDC, ACBD,
ACDB... etc?

Is there a formula, or do I just hardcode?

Ideally, I'd like a formula that returns every permutation for an array of
size N, but a specific solution for N=4 is okay too.
--
David Streeter
Synchrotech Software
Sydney Australia
Hi,
That link may help you:
http://www.mredkj.com/vbnet/permutation.html

Thanks,

Onur Güzel
Aug 1 '08 #2
Thanks!

I actually went ahead and wrote a recursive function to do it, but yours
might be a better solution.

I'm glad that it's non-trivial.

I was also surprised that there is no factorial function in the Math
namespace... so employers can continue to use it as an interview question I
suppose! :-)
--
David Streeter
Synchrotech Software
Sydney Australia
"kimiraikkonen" wrote:
On Aug 1, 5:38 am, SurturZ <surt...@newsgroup.nospamwrote:
This is a bit of a basic question.

I have an array of names that the user has entered (up to 4). I want to
check every permutation of those names against the four different name fields
in the database (First, Last, Middle and Alias). No repetition in names, each
search term is used once per query.

How do I generate every permutation of the names? e.g. ABCD, ABDC, ACBD,
ACDB... etc?

Is there a formula, or do I just hardcode?

Ideally, I'd like a formula that returns every permutation for an array of
size N, but a specific solution for N=4 is okay too.
--
David Streeter
Synchrotech Software
Sydney Australia

Hi,
That link may help you:
http://www.mredkj.com/vbnet/permutation.html

Thanks,

Onur Güzel
Aug 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Steve Goldman | last post by:
Hi, I am trying to come up with a way to develop all n-length permutations of a given list of values. The short function below seems to work, but I can't help thinking there's a better way. ...
20
by: John Trunek | last post by:
I have a set of X items, but want permutations of length Y (X > Y). I am aware of the permutation functions in <algorithm>, but I don't believe this will do what I want. Is there a way, either...
2
by: Alex Vinokur | last post by:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any numbers and words? -- Alex Vinokur mailto:alexvn@connect.to...
11
by: Girish Sahani | last post by:
Hi guys, I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) def permute(string): l= l.append(string) string1 = '' for i in...
20
by: anurag | last post by:
hey can anyone help me in writing a code in c (function) that prints all permutations of a string.please help
7
by: Christian Meesters | last post by:
Hi, I'd like to hack a function which returns all possible permutations as lists (or tuples) of two from a given list. So far, I came up with this solution, but it turned out to be too slow for...
1
by: JosAH | last post by:
Greetings, last week we talked a bit about generating permutations and I told you that this week will be about combinations. Not true; there's a bit more to tell about permutations and that's...
5
by: Shraddha | last post by:
Suppose we are having 3 variables...a,b,c And we want to print the permutations of these variables...Such as...abc,acb,bca...all 6 of them... But we are not supposed to do it mannually... I...
2
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the...
82
by: Bill Cunningham | last post by:
I don't know if I'll need pointers for this or not. I wants numbers 10^16. Like a credit card 16 digits of possible 10 numbers, so I guess that would be 10^16. So I have int num ; These are of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.