Hey,
I am looking for an algorithm to do as follows:
my @array = qw (A B C); # This array may have several parameters,
for
ex. A B C D
I will like to generate following (not sure if this will be called
permutation):
NULL
C
B
A
B C
A C
A B
A B C
Available permutation algorithms generate a
permutation (List resultSoFar, List remainingElements)
{
if(length(remainingElements)=0)
return;
for i = 1 to length(remainingElements)
{
print resultSoFar+remainingElements[i];
permutation (resultSoFar+remainingElements[i],
remainingElements-remainingElements[i]);
On 2/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I will like to generate following (not sure if this will be called
permutation):
NULL
C
B
A
B C
A C
A B
A B C
I think you're looking to generate all possible combinations of n elements.
Essentially below I'm trying to simulate
yes..i agree with rajiv..you seem to be generating combinations rather
than permutations..the algo that i have given generates permutations
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
I'm sorry. My algo is terribly wrong!
On 2/3/07, Rajiv Mathews [EMAIL PROTECTED] wrote:
Combination(Array Elements, Array Answer)
{
if(Elements.size() == 0) print Answer, return;
for(i in Elements)
//Select the particular element -- equiv to 1 say
Do you know if the faulty marble is lighter or heavier?
On 2/2/07, Atamurad Hezretkuliyev [EMAIL PROTECTED] wrote:
Hi,
Can somebody help me with this puzzle? I tried to solve it but couldn't.
Puzzle 1
Weighing marbles
Given are 12 marbles. One of these marbles is slightly heavier or
We don't know if the marble is heavier or lighter ... which makes it
interesting :)
Here's a very clever solution:
http://mathforum.org/kb/message.jspa?messageID=1085028tstart=0
On 2/2/07, aditi saha [EMAIL PROTECTED] wrote:
Do you know if the faulty marble is lighter or heavier?
On 2/2/07,
Split the marbles into sets of 4 each
Compare the first and second sets
If both the sets are equal (the problem is in third set)
{
choose 2 of the marbles in the third set
compare with 2 marbles from the first set(which we know are good)
if comparision is equal
{
compare one of
On Feb 2, 5:02 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hey,
I am looking for an algorithm to do as follows:
my @array = qw (A B C); # This array may have several parameters,
for
ex. A B C D
I will like to generate following (not sure if this will be called
permutation):
NULL