All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic
The not-always-lying islanders (Posted on 2021-12-22) Difficulty: 3 of 5
On a remote island, its inhabitants might lie at any given moment. However, they are restricted by the island code NOT to tell 3 lies in a row.
A group of visitors to the island meets an inhabitant of the island.
Responding to various queries of the visitors he made precisely 17 consecutive statements.
How many combinations of truths/lies can there be?

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 4 |
The below computer program finds 76424, a different solution from Brian Smith. The below is wrong. I misread the statement as not allowing more than 3 lies in a row. It should be not to allow more than 2 lies in a row.

global seq seqSet lieCt
seq=[]; seqSet=[]; lieCt=0;
addOn;
disp(length(seqSet))

function addOn
global seq seqSet lieCt

for i=[true false]
       lieCtSave=lieCt;
       seqSave = seq;
 
   if i==true
      seq=[seq true]; 
      lieCt=0;
   else
      if lieCt<3
         seq=[seq false];
         lieCt=lieCt+1;
      else
       seq=seqSave;
       lieCt=lieCtSave;
         break
      end
   end
   if length(seq)<17
       addOn
   else
       seqSet=[seqSet; seq];
   end
       seq=seqSave;
       lieCt=lieCtSave;
end

end

finds 76424 ways.

The first 25 and last 26 of these are shown below (1 = truth, 0 = lie), with a section from the middle shown in between:

>> for k=1:25 disp(seqSet(k,:))
end
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0
 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1
 1 1 1 1 1 1 1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 0 1 0 0 0 1 0 0 0 1 0 1 1 0 0
 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 1
 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0
 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0 1
 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0
 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 1
 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0
 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1
 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0
 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1
 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0

Edited on December 22, 2021, 1:15 pm
  Posted by Charlie on 2021-12-22 13:05:05

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information