Island of Knights, Knaves and Spies Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraAbout the island of Knights and KnavesAbout Knights and Knaves and their consistencyThe way to Acarien, with Knights and KnavesIf The Knights and Knaves got togetherKnights , Knaves and Spies - Part 1Knights , Knaves and Spies - Part 2Meta Knights and Knaves Puzzle with HatsKnights, Knaves and Normals - the tough oneKnights Knaves and SpiesSolve the following knights and knaves problem

Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?

Could moose/elk survive in the Amazon forest?

First instead of 1 when referencing

How to avoid introduction cliches

Crossed out red box fitting tightly around image

Mistake in years of experience in resume?

What is this word supposed to be?

How much of a wave function must reside inside event horizon for it to be consumed by the black hole?

Contradiction proof for inequality of P and NP?

How much cash can I safely carry into the USA and avoid civil forfeiture?

Raising a bilingual kid. When should we introduce the majority language?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

Intern got a job offer for same salary than a long term team member

My admission is revoked after accepting the admission offer

"Rubric" as meaning "signature" or "personal mark" -- is this accepted usage?

What is /etc/mtab in Linux?

What *exactly* is electrical current, voltage, and resistance?

Did the Roman Empire have penal colonies?

Scheduling based problem

Island of Knights, Knaves and Spies

How do I prove this combinatorial identity

What does a straight horizontal line above a few notes, after a changed tempo mean?

How to have a sharp product image?

Does Mathematica have an implementation of the Poisson binomial distribution?



Island of Knights, Knaves and Spies



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraAbout the island of Knights and KnavesAbout Knights and Knaves and their consistencyThe way to Acarien, with Knights and KnavesIf The Knights and Knaves got togetherKnights , Knaves and Spies - Part 1Knights , Knaves and Spies - Part 2Meta Knights and Knaves Puzzle with HatsKnights, Knaves and Normals - the tough oneKnights Knaves and SpiesSolve the following knights and knaves problem










5












$begingroup$


There is an island with $N$ inhabitants (for example $A_1, A_2, dots, A_N$), each of them is either a knight, a knave, or a spy. As usual:




  • knights will always tell the truth upon answering a question,


  • knaves will always lie,

  • and spies can do both (however they always alternate the truth value of their answers, i.e. if they lied they definitely will tell the truth upon the next answer, and vice versa).

You must determine the correct identities of all $A_i$'s by asking questions, which have to be of one of the following forms:



  • Is $A_j$ a knight/knave/spy? (It includes the $i=j$ case, so you particularly can ask "Are you a knight/knave/spy?") The answer will be either "yes" or "no".

  • How many knights/knaves/spies are among you? The answer will be an integer between $0$ and $N$, inclusively (so, for example for $N=20$, even a knave wouldn't answer $25$, $-3$, or $8.5$).

It's very easy to construct a solution with $2N$ questions, namely asking each islander twice: "Are you a spy?", because



  • a knight will say "no" at both times (since knights never lie, and a knight is indeed not a spy),

  • a knave will say "yes" both times (vice versa, a knave always lies, and still isn't a spy),

  • and a spy will give different answers each time (because spies never lie or tell the truth twice in a row).

So, after 2 questions we can reveal the identity of one given islander.



The question to this puzzle is: Can the number of questions be less than $2N$, and if it can, what's the minimum number of questions needed? (In the solution above, the second type of questions was not even used.)










share|improve this question











$endgroup$











  • $begingroup$
    I take it we should assume that all the islanders know what everyone is?
    $endgroup$
    – Gareth McCaughan
    4 hours ago










  • $begingroup$
    I assume you are looking for a strategy that guarantees that you will know the identity of every islander with fewer than 2N questions even in the worst case. Correct?
    $endgroup$
    – Hugh Meyers
    1 hour ago











  • $begingroup$
    ... and if so, then I suppose the worst case has to be that everyone is a knave thus making the second question valueless.
    $endgroup$
    – Hugh Meyers
    1 hour ago






  • 1




    $begingroup$
    Can I subdivide groups? For example, If I split off a group of M < N and ask the second question, will they respond (0..M) or (0..N)?
    $endgroup$
    – Chris Cudmore
    53 mins ago















5












$begingroup$


There is an island with $N$ inhabitants (for example $A_1, A_2, dots, A_N$), each of them is either a knight, a knave, or a spy. As usual:




  • knights will always tell the truth upon answering a question,


  • knaves will always lie,

  • and spies can do both (however they always alternate the truth value of their answers, i.e. if they lied they definitely will tell the truth upon the next answer, and vice versa).

You must determine the correct identities of all $A_i$'s by asking questions, which have to be of one of the following forms:



  • Is $A_j$ a knight/knave/spy? (It includes the $i=j$ case, so you particularly can ask "Are you a knight/knave/spy?") The answer will be either "yes" or "no".

  • How many knights/knaves/spies are among you? The answer will be an integer between $0$ and $N$, inclusively (so, for example for $N=20$, even a knave wouldn't answer $25$, $-3$, or $8.5$).

It's very easy to construct a solution with $2N$ questions, namely asking each islander twice: "Are you a spy?", because



  • a knight will say "no" at both times (since knights never lie, and a knight is indeed not a spy),

  • a knave will say "yes" both times (vice versa, a knave always lies, and still isn't a spy),

  • and a spy will give different answers each time (because spies never lie or tell the truth twice in a row).

So, after 2 questions we can reveal the identity of one given islander.



The question to this puzzle is: Can the number of questions be less than $2N$, and if it can, what's the minimum number of questions needed? (In the solution above, the second type of questions was not even used.)










share|improve this question











$endgroup$











  • $begingroup$
    I take it we should assume that all the islanders know what everyone is?
    $endgroup$
    – Gareth McCaughan
    4 hours ago










  • $begingroup$
    I assume you are looking for a strategy that guarantees that you will know the identity of every islander with fewer than 2N questions even in the worst case. Correct?
    $endgroup$
    – Hugh Meyers
    1 hour ago











  • $begingroup$
    ... and if so, then I suppose the worst case has to be that everyone is a knave thus making the second question valueless.
    $endgroup$
    – Hugh Meyers
    1 hour ago






  • 1




    $begingroup$
    Can I subdivide groups? For example, If I split off a group of M < N and ask the second question, will they respond (0..M) or (0..N)?
    $endgroup$
    – Chris Cudmore
    53 mins ago













5












5








5





$begingroup$


There is an island with $N$ inhabitants (for example $A_1, A_2, dots, A_N$), each of them is either a knight, a knave, or a spy. As usual:




  • knights will always tell the truth upon answering a question,


  • knaves will always lie,

  • and spies can do both (however they always alternate the truth value of their answers, i.e. if they lied they definitely will tell the truth upon the next answer, and vice versa).

You must determine the correct identities of all $A_i$'s by asking questions, which have to be of one of the following forms:



  • Is $A_j$ a knight/knave/spy? (It includes the $i=j$ case, so you particularly can ask "Are you a knight/knave/spy?") The answer will be either "yes" or "no".

  • How many knights/knaves/spies are among you? The answer will be an integer between $0$ and $N$, inclusively (so, for example for $N=20$, even a knave wouldn't answer $25$, $-3$, or $8.5$).

It's very easy to construct a solution with $2N$ questions, namely asking each islander twice: "Are you a spy?", because



  • a knight will say "no" at both times (since knights never lie, and a knight is indeed not a spy),

  • a knave will say "yes" both times (vice versa, a knave always lies, and still isn't a spy),

  • and a spy will give different answers each time (because spies never lie or tell the truth twice in a row).

So, after 2 questions we can reveal the identity of one given islander.



The question to this puzzle is: Can the number of questions be less than $2N$, and if it can, what's the minimum number of questions needed? (In the solution above, the second type of questions was not even used.)










share|improve this question











$endgroup$




There is an island with $N$ inhabitants (for example $A_1, A_2, dots, A_N$), each of them is either a knight, a knave, or a spy. As usual:




  • knights will always tell the truth upon answering a question,


  • knaves will always lie,

  • and spies can do both (however they always alternate the truth value of their answers, i.e. if they lied they definitely will tell the truth upon the next answer, and vice versa).

You must determine the correct identities of all $A_i$'s by asking questions, which have to be of one of the following forms:



  • Is $A_j$ a knight/knave/spy? (It includes the $i=j$ case, so you particularly can ask "Are you a knight/knave/spy?") The answer will be either "yes" or "no".

  • How many knights/knaves/spies are among you? The answer will be an integer between $0$ and $N$, inclusively (so, for example for $N=20$, even a knave wouldn't answer $25$, $-3$, or $8.5$).

It's very easy to construct a solution with $2N$ questions, namely asking each islander twice: "Are you a spy?", because



  • a knight will say "no" at both times (since knights never lie, and a knight is indeed not a spy),

  • a knave will say "yes" both times (vice versa, a knave always lies, and still isn't a spy),

  • and a spy will give different answers each time (because spies never lie or tell the truth twice in a row).

So, after 2 questions we can reveal the identity of one given islander.



The question to this puzzle is: Can the number of questions be less than $2N$, and if it can, what's the minimum number of questions needed? (In the solution above, the second type of questions was not even used.)







combinatorics optimization liars






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Gareth McCaughan

68.3k3173267




68.3k3173267










asked 4 hours ago









trolley813trolley813

1,40648




1,40648











  • $begingroup$
    I take it we should assume that all the islanders know what everyone is?
    $endgroup$
    – Gareth McCaughan
    4 hours ago










  • $begingroup$
    I assume you are looking for a strategy that guarantees that you will know the identity of every islander with fewer than 2N questions even in the worst case. Correct?
    $endgroup$
    – Hugh Meyers
    1 hour ago











  • $begingroup$
    ... and if so, then I suppose the worst case has to be that everyone is a knave thus making the second question valueless.
    $endgroup$
    – Hugh Meyers
    1 hour ago






  • 1




    $begingroup$
    Can I subdivide groups? For example, If I split off a group of M < N and ask the second question, will they respond (0..M) or (0..N)?
    $endgroup$
    – Chris Cudmore
    53 mins ago
















  • $begingroup$
    I take it we should assume that all the islanders know what everyone is?
    $endgroup$
    – Gareth McCaughan
    4 hours ago










  • $begingroup$
    I assume you are looking for a strategy that guarantees that you will know the identity of every islander with fewer than 2N questions even in the worst case. Correct?
    $endgroup$
    – Hugh Meyers
    1 hour ago











  • $begingroup$
    ... and if so, then I suppose the worst case has to be that everyone is a knave thus making the second question valueless.
    $endgroup$
    – Hugh Meyers
    1 hour ago






  • 1




    $begingroup$
    Can I subdivide groups? For example, If I split off a group of M < N and ask the second question, will they respond (0..M) or (0..N)?
    $endgroup$
    – Chris Cudmore
    53 mins ago















$begingroup$
I take it we should assume that all the islanders know what everyone is?
$endgroup$
– Gareth McCaughan
4 hours ago




$begingroup$
I take it we should assume that all the islanders know what everyone is?
$endgroup$
– Gareth McCaughan
4 hours ago












$begingroup$
I assume you are looking for a strategy that guarantees that you will know the identity of every islander with fewer than 2N questions even in the worst case. Correct?
$endgroup$
– Hugh Meyers
1 hour ago





$begingroup$
I assume you are looking for a strategy that guarantees that you will know the identity of every islander with fewer than 2N questions even in the worst case. Correct?
$endgroup$
– Hugh Meyers
1 hour ago













$begingroup$
... and if so, then I suppose the worst case has to be that everyone is a knave thus making the second question valueless.
$endgroup$
– Hugh Meyers
1 hour ago




$begingroup$
... and if so, then I suppose the worst case has to be that everyone is a knave thus making the second question valueless.
$endgroup$
– Hugh Meyers
1 hour ago




1




1




$begingroup$
Can I subdivide groups? For example, If I split off a group of M < N and ask the second question, will they respond (0..M) or (0..N)?
$endgroup$
– Chris Cudmore
53 mins ago




$begingroup$
Can I subdivide groups? For example, If I split off a group of M < N and ask the second question, will they respond (0..M) or (0..N)?
$endgroup$
– Chris Cudmore
53 mins ago










2 Answers
2






active

oldest

votes


















2












$begingroup$

It takes




at most about $5N/3$ questions.




Suppose




we know a knight or spy and want to find the identities of $k$ islanders. We can find the division of $k$ into knights, knaves, or spies by asking the knight/spy at most five questions of the second type. Suppose the most represented type is X. Then we ask the knight/spy whether each of the $k$ is X. This determines exactly which of them is X, so we can determine the remainder by asking the knight/spy whether each of them is one of the remaining types. In the worst case, each of the classes is equally represented among the $k$, so that this takes about $5k/3$ questions.




Now




our strategy is to find a knight/spy. First we use the known two question strategy to determine the identity of an islander. If they are a knave, we keep asking them whether other islanders are knaves. Each knave discovered in this way requires only one question, so in the worst case we quickly discover a knight/spy, and we use about $5N/3$ questions in total.







share|improve this answer











$endgroup$




















    1












    $begingroup$

    Wrong answer



    [EDITED to add:] Oops, the following is all wrong; thanks to @hexomino for pointing out in comments that I misinterpreted the question. I'm leaving this here rather than deleting it because (1) it's possible that some idea in it is salvageable and (2) I don't believe in making myself look better by deleting my mistakes :-). (I might delete it later to reduce clutter.)



    The minimal number of questions




    is less than $2N$, at least when $N$ is not too small. In fact, it's never more than $frac43N$ plus a few.




    Here's why.




    First, use two "are you a spy?" questions to establish what #1 is, and also (if they're a spy) which way around their truth-telling and lying answers are. We now have three cases. If #1 is a knight then we can just ask them about everyone else, and we're done in $N+1$ questions. If #1 is a spy then we ask them about everyone else -- once, asking "what is X?", when they are telling the truth, and twice, asking binary questions, when they are lying. Every 4 questions we find out about 3 people, so we take approximately $frac43N$ questions.







    The hardest case is when #1 is a knave. Here's one way to proceed. Ask them "is X a knave?" about each other person in turn. If they say "no" then we have correctly identified that X is a knave, and if that's all that ever happens then again we're done in $N+1$ questions. If at some point they say "yes" then we have found a non-knave. We can then ask that person two questions to figure out exactly what they are and (if they're a spy) what their "phase" is, and then proceed as above, asking them about everyone else in turn.







    In the worst case: we take two questions to establish that #1 is a knave; we take one more question to establish that #2 is knot a knave; we take two questions to establish that #2 is a spy and phind his phase; we then have $N-2$ people to figure out, divide them into $leftlceilfracN-23rightrceil$ groups of at most 3, and use 4 questions for each group, for a total of $leftlceilfracN-23rightrceil+5$ questions. I make no claim that this is optimal, though.







    share|improve this answer











    $endgroup$








    • 1




      $begingroup$
      I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
      $endgroup$
      – hexomino
      1 hour ago










    • $begingroup$
      oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
      $endgroup$
      – Gareth McCaughan
      1 hour ago











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "559"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fpuzzling.stackexchange.com%2fquestions%2f83179%2fisland-of-knights-knaves-and-spies%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2












    $begingroup$

    It takes




    at most about $5N/3$ questions.




    Suppose




    we know a knight or spy and want to find the identities of $k$ islanders. We can find the division of $k$ into knights, knaves, or spies by asking the knight/spy at most five questions of the second type. Suppose the most represented type is X. Then we ask the knight/spy whether each of the $k$ is X. This determines exactly which of them is X, so we can determine the remainder by asking the knight/spy whether each of them is one of the remaining types. In the worst case, each of the classes is equally represented among the $k$, so that this takes about $5k/3$ questions.




    Now




    our strategy is to find a knight/spy. First we use the known two question strategy to determine the identity of an islander. If they are a knave, we keep asking them whether other islanders are knaves. Each knave discovered in this way requires only one question, so in the worst case we quickly discover a knight/spy, and we use about $5N/3$ questions in total.







    share|improve this answer











    $endgroup$

















      2












      $begingroup$

      It takes




      at most about $5N/3$ questions.




      Suppose




      we know a knight or spy and want to find the identities of $k$ islanders. We can find the division of $k$ into knights, knaves, or spies by asking the knight/spy at most five questions of the second type. Suppose the most represented type is X. Then we ask the knight/spy whether each of the $k$ is X. This determines exactly which of them is X, so we can determine the remainder by asking the knight/spy whether each of them is one of the remaining types. In the worst case, each of the classes is equally represented among the $k$, so that this takes about $5k/3$ questions.




      Now




      our strategy is to find a knight/spy. First we use the known two question strategy to determine the identity of an islander. If they are a knave, we keep asking them whether other islanders are knaves. Each knave discovered in this way requires only one question, so in the worst case we quickly discover a knight/spy, and we use about $5N/3$ questions in total.







      share|improve this answer











      $endgroup$















        2












        2








        2





        $begingroup$

        It takes




        at most about $5N/3$ questions.




        Suppose




        we know a knight or spy and want to find the identities of $k$ islanders. We can find the division of $k$ into knights, knaves, or spies by asking the knight/spy at most five questions of the second type. Suppose the most represented type is X. Then we ask the knight/spy whether each of the $k$ is X. This determines exactly which of them is X, so we can determine the remainder by asking the knight/spy whether each of them is one of the remaining types. In the worst case, each of the classes is equally represented among the $k$, so that this takes about $5k/3$ questions.




        Now




        our strategy is to find a knight/spy. First we use the known two question strategy to determine the identity of an islander. If they are a knave, we keep asking them whether other islanders are knaves. Each knave discovered in this way requires only one question, so in the worst case we quickly discover a knight/spy, and we use about $5N/3$ questions in total.







        share|improve this answer











        $endgroup$



        It takes




        at most about $5N/3$ questions.




        Suppose




        we know a knight or spy and want to find the identities of $k$ islanders. We can find the division of $k$ into knights, knaves, or spies by asking the knight/spy at most five questions of the second type. Suppose the most represented type is X. Then we ask the knight/spy whether each of the $k$ is X. This determines exactly which of them is X, so we can determine the remainder by asking the knight/spy whether each of them is one of the remaining types. In the worst case, each of the classes is equally represented among the $k$, so that this takes about $5k/3$ questions.




        Now




        our strategy is to find a knight/spy. First we use the known two question strategy to determine the identity of an islander. If they are a knave, we keep asking them whether other islanders are knaves. Each knave discovered in this way requires only one question, so in the worst case we quickly discover a knight/spy, and we use about $5N/3$ questions in total.








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 52 mins ago

























        answered 1 hour ago









        noednenoedne

        9,63312667




        9,63312667





















            1












            $begingroup$

            Wrong answer



            [EDITED to add:] Oops, the following is all wrong; thanks to @hexomino for pointing out in comments that I misinterpreted the question. I'm leaving this here rather than deleting it because (1) it's possible that some idea in it is salvageable and (2) I don't believe in making myself look better by deleting my mistakes :-). (I might delete it later to reduce clutter.)



            The minimal number of questions




            is less than $2N$, at least when $N$ is not too small. In fact, it's never more than $frac43N$ plus a few.




            Here's why.




            First, use two "are you a spy?" questions to establish what #1 is, and also (if they're a spy) which way around their truth-telling and lying answers are. We now have three cases. If #1 is a knight then we can just ask them about everyone else, and we're done in $N+1$ questions. If #1 is a spy then we ask them about everyone else -- once, asking "what is X?", when they are telling the truth, and twice, asking binary questions, when they are lying. Every 4 questions we find out about 3 people, so we take approximately $frac43N$ questions.







            The hardest case is when #1 is a knave. Here's one way to proceed. Ask them "is X a knave?" about each other person in turn. If they say "no" then we have correctly identified that X is a knave, and if that's all that ever happens then again we're done in $N+1$ questions. If at some point they say "yes" then we have found a non-knave. We can then ask that person two questions to figure out exactly what they are and (if they're a spy) what their "phase" is, and then proceed as above, asking them about everyone else in turn.







            In the worst case: we take two questions to establish that #1 is a knave; we take one more question to establish that #2 is knot a knave; we take two questions to establish that #2 is a spy and phind his phase; we then have $N-2$ people to figure out, divide them into $leftlceilfracN-23rightrceil$ groups of at most 3, and use 4 questions for each group, for a total of $leftlceilfracN-23rightrceil+5$ questions. I make no claim that this is optimal, though.







            share|improve this answer











            $endgroup$








            • 1




              $begingroup$
              I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
              $endgroup$
              – hexomino
              1 hour ago










            • $begingroup$
              oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
              $endgroup$
              – Gareth McCaughan
              1 hour ago















            1












            $begingroup$

            Wrong answer



            [EDITED to add:] Oops, the following is all wrong; thanks to @hexomino for pointing out in comments that I misinterpreted the question. I'm leaving this here rather than deleting it because (1) it's possible that some idea in it is salvageable and (2) I don't believe in making myself look better by deleting my mistakes :-). (I might delete it later to reduce clutter.)



            The minimal number of questions




            is less than $2N$, at least when $N$ is not too small. In fact, it's never more than $frac43N$ plus a few.




            Here's why.




            First, use two "are you a spy?" questions to establish what #1 is, and also (if they're a spy) which way around their truth-telling and lying answers are. We now have three cases. If #1 is a knight then we can just ask them about everyone else, and we're done in $N+1$ questions. If #1 is a spy then we ask them about everyone else -- once, asking "what is X?", when they are telling the truth, and twice, asking binary questions, when they are lying. Every 4 questions we find out about 3 people, so we take approximately $frac43N$ questions.







            The hardest case is when #1 is a knave. Here's one way to proceed. Ask them "is X a knave?" about each other person in turn. If they say "no" then we have correctly identified that X is a knave, and if that's all that ever happens then again we're done in $N+1$ questions. If at some point they say "yes" then we have found a non-knave. We can then ask that person two questions to figure out exactly what they are and (if they're a spy) what their "phase" is, and then proceed as above, asking them about everyone else in turn.







            In the worst case: we take two questions to establish that #1 is a knave; we take one more question to establish that #2 is knot a knave; we take two questions to establish that #2 is a spy and phind his phase; we then have $N-2$ people to figure out, divide them into $leftlceilfracN-23rightrceil$ groups of at most 3, and use 4 questions for each group, for a total of $leftlceilfracN-23rightrceil+5$ questions. I make no claim that this is optimal, though.







            share|improve this answer











            $endgroup$








            • 1




              $begingroup$
              I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
              $endgroup$
              – hexomino
              1 hour ago










            • $begingroup$
              oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
              $endgroup$
              – Gareth McCaughan
              1 hour ago













            1












            1








            1





            $begingroup$

            Wrong answer



            [EDITED to add:] Oops, the following is all wrong; thanks to @hexomino for pointing out in comments that I misinterpreted the question. I'm leaving this here rather than deleting it because (1) it's possible that some idea in it is salvageable and (2) I don't believe in making myself look better by deleting my mistakes :-). (I might delete it later to reduce clutter.)



            The minimal number of questions




            is less than $2N$, at least when $N$ is not too small. In fact, it's never more than $frac43N$ plus a few.




            Here's why.




            First, use two "are you a spy?" questions to establish what #1 is, and also (if they're a spy) which way around their truth-telling and lying answers are. We now have three cases. If #1 is a knight then we can just ask them about everyone else, and we're done in $N+1$ questions. If #1 is a spy then we ask them about everyone else -- once, asking "what is X?", when they are telling the truth, and twice, asking binary questions, when they are lying. Every 4 questions we find out about 3 people, so we take approximately $frac43N$ questions.







            The hardest case is when #1 is a knave. Here's one way to proceed. Ask them "is X a knave?" about each other person in turn. If they say "no" then we have correctly identified that X is a knave, and if that's all that ever happens then again we're done in $N+1$ questions. If at some point they say "yes" then we have found a non-knave. We can then ask that person two questions to figure out exactly what they are and (if they're a spy) what their "phase" is, and then proceed as above, asking them about everyone else in turn.







            In the worst case: we take two questions to establish that #1 is a knave; we take one more question to establish that #2 is knot a knave; we take two questions to establish that #2 is a spy and phind his phase; we then have $N-2$ people to figure out, divide them into $leftlceilfracN-23rightrceil$ groups of at most 3, and use 4 questions for each group, for a total of $leftlceilfracN-23rightrceil+5$ questions. I make no claim that this is optimal, though.







            share|improve this answer











            $endgroup$



            Wrong answer



            [EDITED to add:] Oops, the following is all wrong; thanks to @hexomino for pointing out in comments that I misinterpreted the question. I'm leaving this here rather than deleting it because (1) it's possible that some idea in it is salvageable and (2) I don't believe in making myself look better by deleting my mistakes :-). (I might delete it later to reduce clutter.)



            The minimal number of questions




            is less than $2N$, at least when $N$ is not too small. In fact, it's never more than $frac43N$ plus a few.




            Here's why.




            First, use two "are you a spy?" questions to establish what #1 is, and also (if they're a spy) which way around their truth-telling and lying answers are. We now have three cases. If #1 is a knight then we can just ask them about everyone else, and we're done in $N+1$ questions. If #1 is a spy then we ask them about everyone else -- once, asking "what is X?", when they are telling the truth, and twice, asking binary questions, when they are lying. Every 4 questions we find out about 3 people, so we take approximately $frac43N$ questions.







            The hardest case is when #1 is a knave. Here's one way to proceed. Ask them "is X a knave?" about each other person in turn. If they say "no" then we have correctly identified that X is a knave, and if that's all that ever happens then again we're done in $N+1$ questions. If at some point they say "yes" then we have found a non-knave. We can then ask that person two questions to figure out exactly what they are and (if they're a spy) what their "phase" is, and then proceed as above, asking them about everyone else in turn.







            In the worst case: we take two questions to establish that #1 is a knave; we take one more question to establish that #2 is knot a knave; we take two questions to establish that #2 is a spy and phind his phase; we then have $N-2$ people to figure out, divide them into $leftlceilfracN-23rightrceil$ groups of at most 3, and use 4 questions for each group, for a total of $leftlceilfracN-23rightrceil+5$ questions. I make no claim that this is optimal, though.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 1 hour ago

























            answered 1 hour ago









            Gareth McCaughanGareth McCaughan

            68.3k3173267




            68.3k3173267







            • 1




              $begingroup$
              I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
              $endgroup$
              – hexomino
              1 hour ago










            • $begingroup$
              oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
              $endgroup$
              – Gareth McCaughan
              1 hour ago












            • 1




              $begingroup$
              I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
              $endgroup$
              – hexomino
              1 hour ago










            • $begingroup$
              oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
              $endgroup$
              – Gareth McCaughan
              1 hour ago







            1




            1




            $begingroup$
            I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
            $endgroup$
            – hexomino
            1 hour ago




            $begingroup$
            I think if #1 is a knight we still need 2N-2 questions because you can only ask questions like "Is A_j a knight?" not "What is A_j?" meaning that in the worst case you would still need two questions to determine each one, right?
            $endgroup$
            – hexomino
            1 hour ago












            $begingroup$
            oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
            $endgroup$
            – Gareth McCaughan
            1 hour ago




            $begingroup$
            oh, damn, I misread the question. You're right; we don't get to ask "what is X?" questions at all.
            $endgroup$
            – Gareth McCaughan
            1 hour ago

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Puzzling Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fpuzzling.stackexchange.com%2fquestions%2f83179%2fisland-of-knights-knaves-and-spies%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Oświęcim Innehåll Historia | Källor | Externa länkar | Navigeringsmeny50°2′18″N 19°13′17″Ö / 50.03833°N 19.22139°Ö / 50.03833; 19.2213950°2′18″N 19°13′17″Ö / 50.03833°N 19.22139°Ö / 50.03833; 19.221393089658Nordisk familjebok, AuschwitzInsidan tro och existensJewish Community i OświęcimAuschwitz Jewish Center: MuseumAuschwitz Jewish Center

            Valle di Casies Indice Geografia fisica | Origini del nome | Storia | Società | Amministrazione | Sport | Note | Bibliografia | Voci correlate | Altri progetti | Collegamenti esterni | Menu di navigazione46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)Sito istituzionaleAstat Censimento della popolazione 2011 - Determinazione della consistenza dei tre gruppi linguistici della Provincia Autonoma di Bolzano-Alto Adige - giugno 2012Numeri e fattiValle di CasiesDato IstatTabella dei gradi/giorno dei Comuni italiani raggruppati per Regione e Provincia26 agosto 1993, n. 412Heraldry of the World: GsiesStatistiche I.StatValCasies.comWikimedia CommonsWikimedia CommonsValle di CasiesSito ufficialeValle di CasiesMM14870458910042978-6

            Typsetting diagram chases (with TikZ?) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to define the default vertical distance between nodes?Draw edge on arcNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to place nodes in an absolute coordinate system in tikzCommutative diagram with curve connecting between nodesTikz with standalone: pinning tikz coordinates to page cmDrawing a Decision Diagram with Tikz and layout manager