I am a big fan of Games Magazine and have always enjoyed puzzles, so I decided to start a simple fun thread about puzzles. This is a perfect way to learn some tips and tricks using LabVIEW.
Since this is a programming challenge credit should be giving to speed...but I think presentation should also factor in.
The first puzzle, is a puzzle about crossing a rickety bridge in the dark. It was originally published in Games Magazine but I do not have the original reference. Four people named 1, 2, 5, and 10 have to quickly cross the bridge. They have a single flashlight and everyone needs to get safely across. 1 takes one minute, 2 takes two minutes, 5 takes five minutes, and 10 takes ten minutes. Only two people are allowed across at any one time, and you must walk the speed of the slower person.
We will have 1 and 2 go across first = 2 mins.
1 goes back = 1 min.
1 and 5 goes across = 5 mins.
for a total of 8 mins. so far.
The trick is to do this in the minimum time possible (and no you don't get to throw the flashlight).
There are solutions on the web but I would suggest if you've never seen this puzzle to avoid looking up the answer since solving it is more fun.
The trick is to be creative and have fun and I look forward to seeing your solutions.
Only two people are allowed across at any one time, and you must walk the speed of the slower person.
Does that line clear things up a bit I did try to find the original source but no luck, I'll keep looking.
I was afraid I would confuse people. Let me know if it's clear now?
Okay, it is not as trivial as I thought. (I was at work, and work was distracting me ) I thought the easy solution was 1&8 across (8) 1 back (1) 1&4 across (4) 1 back (1) 1 and 2 across (2), total 16 minutes.
Then I realized the trick was to try to minimize the times of the going over even if it costs you some time on the going back. And the only way to do that was to merge the 4 guy with the 8 guy, but never let one of them walk back because you've already had 1 & 2 go across ahead of them.
1 & 2 across (2) 1 back (1) 4 & 8 across (8) 2 back (2) 1&2 across (2), total 15 minutes.
Is there any better solution?
Of course this could be done in LabVIEW or any programming language. Probably generating a table that sets up all the permutations of over and back for the different people, doing the calculations, then sorting the list to find the one that has the lowest total.
The other possibility is that it is an interactive game where a user clicks on each person, the program determines whether it is a valid move, logs it and totals the time. Then it could keep track of the lowest time to date and the corresponding moves and allows the player to try again.
I had forgotten about Games magazine. My sister used to get it back when we were kids. I would read it and do the puzzles after she was done with it. They had a lot of really good logic puzzles that sometimes seemed downright impossible. Is the magazine still around?
"In your description you stated that only two people are allowed to cross, but in your example you indicate that 1 goes back alone. This would seem to contradict the rules of crossing."
Ravens Fan wrote:
"1&8 across (8) 1 back (1) 1&4 across (4) 1 back (1) 1 and 2 across (2), total 16 minutes."
Sorry for the late reply, Enthusiast's are a tough crowd
OK some clarification is needed. The idea is that the bridge can only handle at most two people. One person can certainly cross alone and needs to in order to bring the flashlight safely back to the others. You need the flashlight for safety as it is a dark rickety bridge
The actual description of this puzzle was something like two sentences so you have to make assumptions about not cheating, etc.
Raven's Fan is on the right track but were he came up with 4 and 8 I'll never know. It's interesting to note with software it could be any four positive integers. It would be interesting to see which give the best result for example. For now lets stick with 1, 2, 5, and 10.
Also if you get a solution I was hoping people would post in LabVIEW.
I can tell you the answer which was also in the original problem and it is "17". There is no doubt most people can solve this on paper in a few minutes but I think you will enjoy the solution. In a way it is not common sense. For example 1 is not the person who is used the most, as most people would think.
Enjoy, I will post a solution once I feel people have had an adequate go at it
I have no idea where I got 1, 2, 4, and 8 from either. I think went back to read the original message I saw the 8 total minutes in the example and must have run with that.
I must have started thinking in binary numbers, 1, 2, 4, 8
My original guess should have been
1&10 across (10) 1 back (1) 1&5 across (5) 1 back (1) 1 and 2 across (2), total 19 minutes.
and the correct guess as tst said:
1 & 2 across (2) 1 back (1) 5 & 10 across (10) 2 back (2) 1&2 across (2), total 17 minutes.
The other correct answer would be 2 coming back first and 1 coming back 2nd which would be the same total time.
I did post a couple of ideas in reply 5. But I don't feel like putting in all the effort to actually code something up. Too many projects at work and at home I should be doing.
Which were you thinking of as the challenge, LV program to solve and finding the solution? Or a LV program as a game to help a person to discover the solution.?