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

Home > Logic
Five Sentences (Posted on 2004-10-12) Difficulty: 3 of 5
Which of the following 5 sentences are true?

a) It is not the case that 2 consecutive sentences are both false.
b) There are fewer false than true sentences.
c) It is not the case that 3 consecutive sentences are all false.
d) It is not the case that 2 consecutive sentences are both true.
e) There are exactly 3 false sentences.

See The Solution Submitted by Brian Smith    
Rating: 3.2308 (13 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Computer solution | Comment 7 of 34 |

Here's a Java program to show uniqueness. 

 public static void main(String[] args) {
  boolean valid;
  boolean[] b;
  int k;

  b = new boolean[5];
  for (int i = 0; i < 32; i++) {
   valid = true;
   k = i;
   for (int j = 0; j < 5; j++) {
    b[j] = k % 2 == 0;
    k /= 2;
   }
   
   if (b[0] ^ nConsecBool(b,false,2)) {
    if (b[1] ^ numberFalse(b)>2) {
     if (b[2] ^ nConsecBool(b,false,3)) {
      if (b[3] ^ nConsecBool(b,true,2)) {
       if (b[4] ^ numberFalse(b)!=3) {
        print(b);
       }
      }
     }
    }
   }
  }
 }
 
 private static boolean nConsecBool(boolean[] b, boolean bool, int n) {
  for (int i=0; i<b.length; i++) {
   int k=0;
   for (int j=i; j<b.length && j<i+n; j++) {
    if (b[j]==bool) k++;
   }
   if (k>=n) return true;
  }
  return false;
 }
 
 private static int numberFalse(boolean[] b) {
  int k=0;
  for (int i=0; i<b.length; i++) {
   if (!b[i]) k++;
  }
  return k;
 }
 
 private static void print(boolean[] b) {
  char[] alpha = {'a','b','c','d','e'};
  
  for (int i=0; i<b.length; i++) {
   System.out.println(alpha[i]+":"+b[i]);
  }
 }


  Posted by David Shin on 2004-10-12 18:32:17
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
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