Riddle Thread

This is a discussion on Riddle Thread within the A Brief History of Cprogramming.com forums, part of the Community Boards category; The only way I could think that could work is if the dwarves followed the pattern (starting with the first): ...

  1. #76
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Bonus Riddle

    The only way I could think that could work is if the dwarves followed the pattern (starting with the first):
    [1] identifiy the next dwarfs hat color (and die)
    [2] identify own hat color (and live)
    ...thus saving n/2 dwarves...
    Last edited by CornedBee; 03-28-2009 at 11:54 AM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #77
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262

    Bonus Riddle

    I assume this is not allowed:
    The one in the back guesses his own color. And they say "I think I have ***" if the one in front of them has a white hat and, "***, I think", if the one in front of them has a black hat.

    If that's not allowed, then they could change some slight way they speak the word that is only audible if you know they're doing it.

    Not allowed, I guess?



    But,so, they start at the back of the line? And there are no limitations to the number of hats? Eg. they may all be black?
    Last edited by CornedBee; 03-28-2009 at 11:55 AM.

  3. #78
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,741

    Bonus Riddle

    The tallest dwarf exchanges hats with the next tallest and says the color of his original hat. The second dwarf says this color, lives, and switches hats again with a shorter dwarf. This always saves at least n-1 dwarfs since they all, at one point, wore the same color hat.
    Last edited by CornedBee; 03-28-2009 at 11:55 AM.

  4. #79
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Bonus Riddle

    Very clever! But wouldn't that be cheating?
    Last edited by CornedBee; 03-28-2009 at 11:55 AM. Reason: typoz
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #80
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262

    Yet another riddle

    Okay, Perspective's riddle reminded me of a riddle I heard a while ago. A riddle I liked a lot .

    Three people are lined up. They may not look back or touch each other. They can only see the people in front of them.
    So let's say we have person A, B and C. A can see B and C. B can see C. C can't see anyone.

    Then, someone comes with 5 stickers: 3 black and 2 white, and puts one on the back of each. So, again, A can see B's and C's dots, B can see C's dot.

    They are not allowed to speak unless they want to say which color they think the dot they have on their back is. If one gets it wrong, they all die. If one gets it right, they all live.


    They're smart, and all always survive. How?

  6. #81
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312

    Bonus Riddle

    Quote Originally Posted by Perspective View Post
    Since Snafuist posts all of the riddles he doesn't get the fun of trying to solve them.
    I already had, but it's good to see you join.

    There are a few questions remaining:

    Do the dwarves know in advance the value of n, i.e. the total number of dwarves?
    Do the dwarves know in advance the number of black hats?
    Do the dwarves know whether a guess was right or wrong?
    And just to be sure: the dwarf that can see all other dwarves will start making a guess, right?

    Greets,
    Philip
    Last edited by CornedBee; 03-28-2009 at 11:55 AM.
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  7. #82
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Bonus Riddle

    Quote Originally Posted by EVOEx View Post
    I assume this is not allowed:
    The one in the back guesses his own color. And they say "I think I have ***" if the one in front of them has a white hat and, "***, I think", if the one in front of them has a black hat.

    If that's not allowed, then they could change some slight way they speak the word that is only audible if you know they're doing it.

    Not allowed, I guess?



    But,so, they start at the back of the line? And there are no limitations to the number of hats? Eg. they may all be black?
    This is the first solution I came up with when I heard the problem But it is indeed cheeting.

    Dwarves can not trade hats either.

    Sebastiani has a correct strategy for saving half of the dwarves, be we can do better!
    Last edited by CornedBee; 03-28-2009 at 11:56 AM.

  8. #83
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Bonus Riddle

    >Do the dwarves know in advance the value of n, i.e. the total number of dwarves?

    Yes, or they could count at the time of the game.

    >Do the dwarves know in advance the number of black hats?

    No. There could be anywhere from 0 to n black hats.

    >Do the dwarves know whether a guess was right or wrong?

    nope!

    >And just to be sure: the dwarf that can see all other dwarves will start making a guess, right?

    Yes.


    Here's a clue: The information any dwarf has is the colour of the hats in front of him and the answers of all dwarves behind him.
    Last edited by CornedBee; 03-28-2009 at 11:56 AM.

  9. #84
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312

    Yet another riddle

    Quote Originally Posted by EVOEx View Post
    They're smart, and all always survive.
    I doubt that. If all get a black sticker, there's no way to tell.

    But I can think of at least some ways that will make them survive:
    If A sees two white stickers, he can immediately answer "black". He must remain silent in all other cases. If A doesn't say anything, then B and C know that their respective stickers are not both white. Hence if B sees a white sticker, he can immediately answer "black". If he doesn't, then C knows that his hat is not white, so he can answer "black".

    Greets,
    Philip
    Last edited by CornedBee; 03-28-2009 at 11:56 AM.
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  10. #85
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262

    Yet another riddle

    Exactly .

    So why, if you provide the right answer, would there be no way to tell if all were black?
    Last edited by CornedBee; 03-28-2009 at 11:57 AM.

  11. #86
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312

    Yet another riddle

    So why, if you provide the right answer, would there be no way to tell if all were black?
    Because the situations WBB and BBB are indistinguishable for all dwarves.

    Greets,
    Philip
    Last edited by CornedBee; 03-28-2009 at 11:57 AM.
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  12. #87
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Yet another riddle

    Unless they know which two stickers are not used.
    Last edited by CornedBee; 03-28-2009 at 11:57 AM.

  13. #88
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262

    Yet another riddle

    Okay, let's say we have BBB.
    The one on the back remains silent. So the two on front know they are not WW.
    The one in the middle remains silent, because he doesn't see W in front of him.
    The one in the front now knows he has B.

    Exactly your method . Same for WBB.
    Last edited by CornedBee; 03-28-2009 at 11:57 AM.

  14. #89
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312

    Bonus Riddle

    I have a solution, but I think it involves cheating:

    The first dwarf simply says the color of the hat directly in front of him. The 2nd dwarf thus knows its own hat color. If the third dwarf has a white hat, the 2nd one says his own hat color immediately, otherwise he waits a minute until he says his hat color. This way, the next dwarf knows is own hat color and the dwarves continue this way, saving at least n-1 dwarves.

    I can't stop thinking of the hats as a bitstring, but I don't see how this will help.

    Greets,
    Philip
    Last edited by CornedBee; 03-28-2009 at 11:58 AM.
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  15. #90
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262

    Bonus Riddle

    Quote Originally Posted by Snafuist View Post
    I can't stop thinking of the hats as a bitstring, but I don't see how this will help.
    It does help. The bitstring can be anything. And if we're not "cheating", everyone can either say 1 or 0. The one in the back can say only 1 or 0, being able to help only ONE person in the bitstring, as a range of bits can never be compressed as a single bit, assuming the string is entirely random.

    So, we need some way to say more than 1 or 0. But I would consider this cheating. Sure, we can communicate in other ways, but I don't think it's fair here...
    Last edited by CornedBee; 03-28-2009 at 11:58 AM.

Page 6 of 8 FirstFirst 12345678 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 04:34 AM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 03:55 PM
  3. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 07:50 AM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 10:34 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21