#### Archived

This topic is now archived and is closed to further replies.

# "Mind Bender"

This topic is 5575 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

For a math class at school, we have to figgure out this ''mind bender'' puzzle by next week. Its basically where we have to find out five peoples first & last names, the color of house they live in, what order their houses are in, and what car they drive using about 8 clues that were given to us. I don''t feel like figguring that out (its hard) so Im going to write a simple program that does it =D Btw, theres 4 people total Im kind of stuck on how I''d do this though.. Heres what I have so far: I''d create a structure for each person (each object of the structure would be their first name) example: struc person { LPCTSTR firstname; LPCTSTR lastname; LPCSTR car; LPCSTR housecolor; bool is_male; int house_number; }; What my program would do is go through every possible combination of people''s ''stuff'' and check each combo and make sure that each ''person'' object meets the criteria which will be programmed in also. Once it finds the correct one, it''ll display it for me.. Im stuck on how I''m going to increment (or go through) the combinations :-/ Im thinking maybe I could do something like this (but Im not sure because I don''t know if it''ll work): person personcombo[how_many_ever_combos_of_people_there_are]; [Fill that array with ''person'' objects w/ the values set to every single combination of names, cars, house colors, etc..)] person p1, p2, p3, p4; [Now, think of p1, p2, p3, and p4 as being digits on a digital display of some sort. start out by making p4 the value of personcombo[0], then check to see if thats the correct combo, then make it personcombo[1], and etc... Make it go all the way up to how_many_ever_combos_of_people_there_are, and make it go back to personcombo[0] again. Then, p3 starts out at 0, and p4 goes through the loop again. Then p3 goes up one and p4 goes through the loop again, and etc.. If this makes any senes..] ANyways, you think this idea for looping through the different combos might work? Any problems with this (Will it take FOREVER to work and find the combo? will it use too much RAM?) Thanks

##### Share on other sites
On a 1000mhz computer, it won''t take all that long.

There are 5 people and 5 variabels, the first variabel (first name) is defining the person, so it''s actually 5 people and 4 variabels... I think only about 150 options at maximum. Yeah, it should be possible to do this in just a few seconds

It''s just a matter of generating every possible solution one by one, and checking it against 8 if-statements. On average, you will have found a solution to be wrong after 4 if-statements, and there is a 50% change you only need to check half of the generated options before you find the winner. Generating all the options ahead of time might take a bit of memory, but you don''t have to do that. You can simply fill 5 structs with the information, and then inside the loop that fills them check if they are right. If not, continue with generating a new option, if it is right, exit your loop and display the information.

This is quite a novel approach to such a mind bender, I was confronted with one a few weeks ago, and damn I wish I came up with this idea

This is the polish virus. It is not an executable, but if you would kindly format your entire harddrive, we would be happy.

##### Share on other sites
Allright, I'll try it

thx

EDIT: My Comp is 900MHz so that shouldn't be a problem

[edited by - Xtremehobo on March 19, 2003 10:04:22 AM]

##### Share on other sites
Life is short - cycles and memory is cheap and plenty

[edited by - Eskhan on March 19, 2003 5:09:16 PM]

##### Share on other sites
Anyone heard this one?
There isthese 4 american soldiers in vietnam, and
some of them are injured, and they have to cross this
bridge in the middle of the night. They only have one flash
light with them, so they have to go in pairs.
Lets call the guys A, B, C and D.
They have to cross the bridge in 17 minutes or less,
because the bridge is rigged to blow.
A is very athletic, he can cross the bridge in 1 minute
B is tired, he can cross it in 2 minutes
C is hurt in the knee, he can do it in 5 minutes
D is almost uncounscient, he can cross the bridge in 10 minutes

Now, they have to go in pairs, and they travell at the
speed of the slowest guy, so if A and C cross, they''ll take
5 minutes, ''cause thats as fast as C can do it. Then A
comes back with the flashlight and takes another person,
and so on, and so on, till they cross the bridge in 17 minutes
or less...

Can you do it? (sorry for the lenghty explanation...)

heres an example (not a solution):

A&B cross the bridge, A returns (3 minutes, (2+1)
A&D cross the bridge, A returns (11 minutes, 10+1)
A&C cross the bridge, end (5 minutes)
total equals 19 minutes, which is 2 minutes longer than
the 17 minutes they have...

if you get the solution, don''t post it right away, give others
the time to think...

[Hugo Ferreira][Positronic Dreams]
Need [3D Artist] & [Sound Designer]
for small project. Contact me plz...
[-NO TO WAR ON IRAQ-]

##### Share on other sites
quote:
Original post by pentium3id
Can you do it? (sorry for the lenghty explanation...)

How should this be possible? 10 + 5 + 2 + 1 already is > 17.

- VizOne

##### Share on other sites
Funny you should mention that pentium3id, I had this very question on a phone interview with microsoft. The answer is actually simple:

First A&B go over, sending 1 back: 2over + 1back = 3
Then C&D go over, sending 2 back: 10over + 2back = 12 15 total
Then A&B go over +2over- > total = 17 mins

That was fun over the phone, let me tell ya.

============================
A guy, some jolt, and a whole lot of code

[edited by - Tyson on March 19, 2003 7:25:40 PM]

[edited by - Tyson on March 19, 2003 7:31:07 PM]

##### Share on other sites
thanx for posting the solution already, i
though i said to now post it untill ppl thought about it...

[Hugo Ferreira][Positronic Dreams]
Need [3D Artist] & [Sound Designer]
for small project. Contact me plz...
[-NO TO WAR ON IRAQ-]

##### Share on other sites
quote:

First A&B go over, sending 1 back: 2over + 1back = 3
Then C&D go over, sending 2 back: 10over + 2back = 12 15 total
Then A&B go over +2over- > total = 17 mins

wheee! That''s nice!

- VizOne

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631423
• Total Posts
3000003
×