There are 4 women who want to cross a bridge. They all begin on the same side. You have 17 minutes to get all of them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each woman walks at a different speed. A pair must walk together at the rate of the slower woman's pace.
Woman 1: 1 minute to cross
Woman 2: 2 minutes to cross
Woman 3: 5 minutes to cross
Woman 4: 10 minutes to cross
For example if Woman 1 and Woman 4 walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Woman 4 then returns with the flashlight, a total of 20 minutes have passed and you have failed the mission. What is the order required to get all women across in 17 minutes?
Friday, June 19, 2009
PUZZLE II ANSWER
Sadly, the LAST programmer (first to be asked) has a 50/50 shot of living. But on the plus side, if you trust him, everyone else can live! Here's how it works: The last programmer counts the number of red hats in front of him. If it's odd, he says "red". If it's even, he says "blue". The next programmer in line then looks at the number of red hats in front of him. If the person behind him called out "red", and he sees an odd number of red hats, he *knows* his hat is blue, and can call it out. And if he sees an even number of red hats, he *knows* his hat is red. Etc. This proceeds all the way up the line-- and assuming nobody makes a mistake.
The Simple C Program :
int row[]={0,1,0,1,0,0,0,1,0,1, 0,1,0,0,0,0,0,0,0,1, 0,0,0,0,1,0,0,0,0,1, 0,1,0,0,0,0,1,0,0,0, 0,0,0,0,0,1,0,0,1,1, 0,0,0,0,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,1, 0,0,0,0,0,0,0,0,0,0, 0,1,0,1,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,1,1};
int Rslt[]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0};
int count=99;
int lIntNumber=0;
for(int i=99;i>0;i--)
{
lIntNumber=0;
for(int j=count;j>0;j--)
{
lIntNumber+=row[j-1]; //lIntNumber^=row[j-1];
}
if(lIntNumber%2==0)
Rslt[i]=0;
else
Rslt[i]=1;
if(i!=99)
{
int lIntPrv=0;
for(int k=i+1;k<100;k
{ lIntPrv+=Rslt[k]; //lIntPrv^=Rslt[k];
}
if(lIntPrv%2==1 && Rslt[i]==1)//OK
Rslt[i]=0;
else if(lIntPrv%2==1 && Rslt[i]==0)
Rslt[i]=1;
else if(lIntPrv%2==0 && Rslt[i]==0)//OK
Rslt[i]=0;
else if(lIntPrv%2==0 && Rslt[i]==1)
Rslt[i]=1;;
}
count--;
}
int lIntRslt=0;
for(int lIntLoop=0;lIntLoop<100;lintloop++)
{
if(Rslt[lIntLoop]==row[lIntLoop])
lIntRslt++;
}
The output most of the times comes 99.
The Simple C Program :
int row[]={0,1,0,1,0,0,0,1,0,1, 0,1,0,0,0,0,0,0,0,1, 0,0,0,0,1,0,0,0,0,1, 0,1,0,0,0,0,1,0,0,0, 0,0,0,0,0,1,0,0,1,1, 0,0,0,0,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,1, 0,0,0,0,0,0,0,0,0,0, 0,1,0,1,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,1,1};
int Rslt[]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0};
int count=99;
int lIntNumber=0;
for(int i=99;i>0;i--)
{
lIntNumber=0;
for(int j=count;j>0;j--)
{
lIntNumber+=row[j-1]; //lIntNumber^=row[j-1];
}
if(lIntNumber%2==0)
Rslt[i]=0;
else
Rslt[i]=1;
if(i!=99)
{
int lIntPrv=0;
for(int k=i+1;k<100;k
{ lIntPrv+=Rslt[k]; //lIntPrv^=Rslt[k];
}
if(lIntPrv%2==1 && Rslt[i]==1)//OK
Rslt[i]=0;
else if(lIntPrv%2==1 && Rslt[i]==0)
Rslt[i]=1;
else if(lIntPrv%2==0 && Rslt[i]==0)//OK
Rslt[i]=0;
else if(lIntPrv%2==0 && Rslt[i]==1)
Rslt[i]=1;;
}
count--;
}
int lIntRslt=0;
for(int lIntLoop=0;lIntLoop<100;lintloop++)
{
if(Rslt[lIntLoop]==row[lIntLoop])
lIntRslt++;
}
The output most of the times comes 99.
Subscribe to:
Comments (Atom)