|
-
Array analysis problem
I have an interesting challenge for you all. I have a problem whereby I need to find all possible combinations of the contents of an array, and create a new array with these values. For example, with an array of 3 elements:
["A", "B", "C"]
You would get:
A
B
C
AB
BC
AC
ABC
(and of course, none)
Final count: 2 raised to the power of 3, or an array with 8 elements (different orders of the same combinations don't matter, so we don't differentiate between AC and CA).
So - I could probably figure out a brute-force method to solve this, but can anyone come up with an elegant solution, assuming that the size and contents of the array is unknown at design time? I was thinking there must be some way to do this recursively, but I haven't quite determined the best approach...
BTW - no, this is not a classroom assignment...
Thanks -
Bob Rouse
Dimension Data
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks