爱因斯坦迷题:谁养鱼?(Java算法)

时间:2022-06-06 13:11:10

爱因斯坦迷题:谁养鱼?


原题为:
 1.有5栋5种颜色的房子
 2.每一位房子的主人国籍都不同
 3.这五个人每人只喝一个牌子的饮料,只抽一个牌子的香烟,只养一种宠物
 4.没有人有相同的宠物,抽相同牌子的烟,喝相同牌子的饮料
 已知条件:
 1.英国人住在红房子里
 2.瑞典人养了一条狗
 3.丹麦人喝茶
 4.绿房子在白房子的左边
 5.绿房子主人喝咖啡
 6.抽pallmall烟的人养了一只鸟
 7.黄房子主人抽dunhill烟
 8.住在中间房子的人喝牛奶
 9.挪威人住在第一间房子
 10.抽混合烟的人住在养猫人的旁边
 11.养马人住在抽dunhill烟人的旁边
 12.抽bluemaster烟的人喝啤酒
 13.德国人抽prince烟
 14.挪威人住在蓝房子旁边
 15.抽混合烟的人的邻居喝矿泉水
 问题:谁养鱼?
 这道迷题出自1981年柏林的德国逻辑思考学院。
 据说世界上只有2%的人能出答案。
 就连大名鼎鼎的爱因斯坦也成为此题大伤脑筋。

 

 公布答案了:
 ==========Start==========
 答案1
 挪威人  丹麦人  英国人  德国人  瑞典人 
 黄房子  蓝房子  红房子  绿房子  白房子 
 猫  马  鸟  鱼  狗 
 水  茶  牛奶  咖啡  啤酒 
 DUNHILL  混合烟  PALLMALL PRINCE  BLUEMASTER 
 -----------------------------------------------
 答案2
 挪威人  德国人  英国人  丹麦人  瑞典人 
 绿房子  蓝房子  红房子  黄房子  白房子 
 鸟  猫  马  鱼  狗 
 咖啡  水  牛奶  茶  啤酒 
 PALLMALL PRINCE  混合烟  DUNHILL  BLUEMASTER 
 -----------------------------------------------
 答案3
 挪威人  德国人  英国人  丹麦人  瑞典人 
 绿房子  蓝房子  红房子  黄房子  白房子 
 鸟  鱼  马  猫  狗 
 咖啡  水  牛奶  茶  啤酒 
 PALLMALL PRINCE  混合烟  DUNHILL  BLUEMASTER 
 -----------------------------------------------
 答案4
 挪威人  德国人  瑞典人  英国人  丹麦人 
 绿房子  蓝房子  黄房子  红房子  白房子 
 鱼  猫  狗  马  鸟 
 咖啡  水  牛奶  啤酒  茶 
 混合烟  PRINCE  DUNHILL  BLUEMASTER PALLMALL 
 -----------------------------------------------
 答案5
 挪威人  德国人  瑞典人  英国人  丹麦人 
 绿房子  蓝房子  白房子  红房子  黄房子 
 鸟  猫  狗  马  鱼 
 咖啡  水  牛奶  啤酒  茶 
 PALLMALL PRINCE  混合烟  BLUEMASTER DUNHILL 
 -----------------------------------------------
 答案6
 挪威人  德国人  瑞典人  丹麦人  英国人 
 绿房子  蓝房子  白房子  黄房子  红房子 
 鸟  猫  狗  鱼  马 
 咖啡  水  牛奶  茶  啤酒 
 PALLMALL PRINCE  混合烟  DUNHILL  BLUEMASTER 
 -----------------------------------------------
 答案7
 挪威人  德国人  瑞典人  丹麦人  英国人 
 绿房子  蓝房子  白房子  黄房子  红房子 
 鸟  鱼  狗  猫  马 
 咖啡  水  牛奶  茶  啤酒 
 PALLMALL PRINCE  混合烟  DUNHILL  BLUEMASTER 
 -----------------------------------------------
 我不是推理的,是用程序做的。代码如下(代码比较烂:-)):


 

/*
* Created on 2005-11-8
*
1.有5栋5种颜色的房子
2.每一位房子的主人国籍都不同
3.这五个人每人只喝一个牌子的饮料,只抽一个牌子的香烟,只养一种宠?
4.没有人有相同的宠物,抽相同牌子的烟,喝相同牌子的饮料
已知条件:
1.英国人住在红房子?
2.瑞典人养了一条狗
3.丹麦人喝?
4.绿房子在白房子的左?
5.绿房子主人喝咖啡
6.抽pallmall烟的人养了一只?
7.黄房子主人抽dunhill烟
8.住在中间房子的人喝牛奶
9.挪威人住在第一间房子
10.抽混合烟的人住在养猫人的旁?
11.养马人住在抽dunhill烟人的旁?
12.抽bluemaster烟的人喝啤酒
13.德国人抽prince烟
14.挪威人住在蓝房子旁?
15.抽混合烟的人的邻居喝矿泉水
问题:谁养鱼?
这道迷题出自1981年柏林的德国逻辑思考学院。据说世界上只有2%的人能出答案。就连大名鼎鼎的爱因斯坦也成为此题大伤脑?
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package  com.netengine.test;
/**
@author  cds
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public   class  WhoFeedsFish {

    
public   static   final   int  NATIONALITY_ENGLISH  =   1 ;
    
public   static   final   int  NATIONALITY_SWIDISH  =   2 ;
    
public   static   final   int  NATIONALITY_DAMARK   =   3 ;
    
public   static   final   int  NATIONALITY_NORWAY   =   4 ;
    
public   static   final   int  NATIONALITY_GERMAN   =   5 ;
    
private   int [] nationalities  =  { 1 , 2 , 3 , 4 , 5 };

    
public   static   final   int  COLOR_RED     =   1 ;
    
public   static   final   int  COLOR_GREEN   =   2 ;
    
public   static   final   int  COLOR_YELLOW    =   3 ;
    
public   static   final   int  COLOR_WHITE   =   4 ;
    
public   static   final   int  COLOR_BLUE  =   5 ;
    
private   int [] colors  =  { 1 , 2 , 3 , 4 , 5 };

    
public   static   final   int  PET_DOG    =   1 ;
    
public   static   final   int  PET_BIRD   =   2 ;
    
public   static   final   int  PET_CAT   =   3 ;
    
public   static   final   int  PET_HORSE  =   4 ;
    
public   static   final   int  PET_FISH   =   5 ;
    
private   int [] pets  =  { 1 , 2 , 3 , 4 , 5 };

    
public   static   final   int  DRINK_TEA     =   1 ;
    
public   static   final   int  DRINK_COFFEE  =   2 ;
    
public   static   final   int  DRINK_MILK    =   3 ;
    
public   static   final   int  DRINK_BEER    =   4 ;
    
public   static   final   int  DRINK_WATER   =   5 ;
    
private   int [] drinks  =  { 1 , 2 , 3 , 4 , 5 };

    
public   static   final   int  TOBACCO_PALLMALL    =   1 ;
    
public   static   final   int  TOBACCO_DUNHILL     =   2 ;
    
public   static   final   int  TOBACCO_BLUEMASTER  =   3 ;
    
public   static   final   int  TOBACCO_PRINCE      =   4 ;
    
public   static   final   int  TOBACCO_MIXED       =   5 ;
    
private   int [] tobaccoes  =  { 1 , 2 , 3 , 4 , 5 };

    
private   int [][] key  = {nationalities,colors,pets,drinks,tobaccoes};

    
private   int [][] values  =  {
        {
1 , 2 , 3 , 4 , 5 },
        {
1 , 2 , 3 , 5 , 4 },
        {
1 , 2 , 4 , 3 , 5 },
        {
1 , 2 , 4 , 5 , 3 },
        {
1 , 2 , 5 , 3 , 4 },
        {
1 , 2 , 5 , 4 , 3 },
        {
1 , 3 , 2 , 4 , 5 },
        {
1 , 3 , 2 , 5 , 4 },
        {
1 , 3 , 4 , 2 , 5 },
        {
1 , 3 , 4 , 5 , 2 },
        {
1 , 3 , 5 , 2 , 4 },
        {
1 , 3 , 5 , 4 , 2 },
        {
1 , 4 , 2 , 3 , 5 },
        {
1 , 4 , 2 , 5 , 3 },
        {
1 , 4 , 3 , 2 , 5 },
        {
1 , 4 , 3 , 5 , 2 },
        {
1 , 4 , 5 , 2 , 3 },
        {
1 , 4 , 5 , 3 , 2 },
        {
1 , 5 , 2 , 3 , 4 },
        {
1 , 5 , 2 , 4 , 3 },
        {
1 , 5 , 3 , 2 , 4 },
        {
1 , 5 , 3 , 4 , 2 },
        {
1 , 5 , 4 , 2 , 3 },
        {
1 , 5 , 4 , 3 , 2 },
        {
2 , 1 , 3 , 4 , 5 },
        {
2 , 1 , 3 , 5 , 4 },
        {
2 , 1 , 4 , 3 , 5 },
        {
2 , 1 , 4 , 5 , 3 },
        {
2 , 1 , 5 , 3 , 4 },
        {
2 , 1 , 5 , 4 , 3 },
        {
2 , 3 , 1 , 4 , 5 },
        {
2 , 3 , 1 , 5 , 4 },
        {
2 , 3 , 4 , 1 , 5 },
        {
2 , 3 , 4 , 5 , 1 },
        {
2 , 3 , 5 , 1 , 4 },
        {
2 , 3 , 5 , 4 , 1 },
        {
2 , 4 , 1 , 3 , 5 },
        {
2 , 4 , 1 , 5 , 3 },
        {
2 , 4 , 3 , 1 , 5 },
        {
2 , 4 , 3 , 5 , 1 },
        {
2 , 4 , 5 , 1 , 3 },
        {
2 , 4 , 5 , 3 , 1 },
        {
2 , 5 , 1 , 3 , 4 },
        {
2 , 5 , 1 , 4 , 3 },
        {
2 , 5 , 3 , 1 , 4 },
        {
2 , 5 , 3 , 4 , 1 },
        {
2 , 5 , 4 , 1 , 3 },
        {
2 , 5 , 4 , 3 , 1 },
        {
3 , 1 , 2 , 4 , 5 },
        {
3 , 1 , 2 , 5 , 4 },
        {
3 , 1 , 4 , 2 , 5 },
        {
3 , 1 , 4 , 5 , 2 },
        {
3 , 1 , 5 , 2 , 4 },
        {
3 , 1 , 5 , 4 , 2 },
        {
3 , 2 , 1 , 4 , 5 },
        {
3 , 2 , 1 , 5 , 4 },
        {
3 , 2 , 4 , 1 , 5 },
        {
3 , 2 , 4 , 5 , 1 },
        {
3 , 2 , 5 , 1 , 4 },
        {
3 , 2 , 5 , 4 , 1 },
        {
3 , 4 , 1 , 2 , 5 },
        {
3 , 4 , 1 , 5 , 2 },
        {
3 , 4 , 2 , 1 , 5 },
        {
3 , 4 , 2 , 5 , 1 },
        {
3 , 4 , 5 , 1 , 2 },
        {
3 , 4 , 5 , 2 , 1 },
        {
3 , 5 , 1 , 2 , 4 },
        {
3 , 5 , 1 , 4 , 2 },
        {
3 , 5 , 2 , 1 , 4 },
        {
3 , 5 , 2 , 4 , 1 },
        {
3 , 5 , 4 , 1 , 2 },
        {
3 , 5 , 4 , 2 , 1 },
        {
4 , 1 , 2 , 3 , 5 },
        {
4 , 1 , 2 , 5 , 3 },
        {
4 , 1 , 3 , 2 , 5 },
        {
4 , 1 , 3 , 5 , 2 },
        {
4 , 1 , 5 , 2 , 3 },
        {
4 , 1 , 5 , 3 , 2 },
        {
4 , 2 , 1 , 3 , 5 },
        {
4 , 2 , 1 , 5 , 3 },
        {
4 , 2 , 3 , 1 , 5 },
        {
4 , 2 , 3 , 5 , 1 },
        {
4 , 2 , 5 , 1 , 3 },
        {
4 , 2 , 5 , 3 , 1 },
        {
4 , 3 , 1 , 2 , 5 },
        {
4 , 3 , 1 , 5 , 2 },
        {
4 , 3 , 2 , 1 , 5 },
        {
4 , 3 , 2 , 5 , 1 },
        {
4 , 3 , 5 , 1 , 2 },
        {
4 , 3 , 5 , 2 , 1 },
        {
4 , 5 , 1 , 2 , 3 },
        {
4 , 5 , 1 , 3 , 2 },
        {
4 , 5 , 2 , 1 , 3 },
        {
4 , 5 , 2 , 3 , 1 },
        {
4 , 5 , 3 , 1 , 2 },
        {
4 , 5 , 3 , 2 , 1 },
        {
5 , 1 , 2 , 3 , 4 },
        {
5 , 1 , 2 , 4 , 3 },
        {
5 , 1 , 3 , 2 , 4 },
        {
5 , 1 , 3 , 4 , 2 },
        {
5 , 1 , 4 , 2 , 3 },
        {
5 , 1 , 4 , 3 , 2 },
        {
5 , 2 , 1 , 3 , 4 },
        {
5 , 2 , 1 , 4 , 3 },
        {
5 , 2 , 3 , 1 , 4 },
        {
5 , 2 , 3 , 4 , 1 },
        {
5 , 2 , 4 , 1 , 3 },
        {
5 , 2 , 4 , 3 , 1 },
        {
5 , 3 , 1 , 2 , 4 },
        {
5 , 3 , 1 , 4 , 2 },
        {
5 , 3 , 2 , 1 , 4 },
        {
5 , 3 , 2 , 4 , 1 },
        {
5 , 3 , 4 , 1 , 2 },
        {
5 , 3 , 4 , 2 , 1 },
        {
5 , 4 , 1 , 2 , 3 },
        {
5 , 4 , 1 , 3 , 2 },
        {
5 , 4 , 2 , 1 , 3 },
        {
5 , 4 , 2 , 3 , 1 },
        {
5 , 4 , 3 , 1 , 2 },
        {
5 , 4 , 3 , 2 , 1 }
    };

    
public   void  printKey(){
        
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
            print(
" nationality " ,key[ 0 ][i]);
        }
        System.out.println();
        
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
            print(
" color " ,key[ 1 ][i]);
        }
        System.out.println();
        
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
            print(
" pet " ,key[ 2 ][i]);
        }
        System.out.println();
        
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
            print(
" drink " ,key[ 3 ][i]);
        }
        System.out.println();
        
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
            print(
" tobacco " ,key[ 4 ][i]);
        }
        System.out.println();

    }

    
public   void  print(String item, int  index){
        
if ( false ){
            }
else   if ( " nationality " .equals(item)){
                
switch (index){
                    
case   1 :
                    System.out.print(
" 英国人\t\t " );
                    
break ;
                    
case   2 :
                    System.out.print(
" 瑞典人\t\t " );
                    
break ;
                    
case   3 :
                    System.out.print(
" 丹麦人\t\t " );
                    
break ;
                    
case   4 :
                    System.out.print(
" 挪威人\t\t " );
                    
break ;
                    
case   5 :
                    System.out.print(
" 德国人\t\t " );
                    
break ;
                }
                }
else   if ( " color " .equals(item)){
                    
switch (index){
                        
case   1 :
                        System.out.print(
" 红房子\t\t " );
                        
break ;
                        
case   2 :
                        System.out.print(
" 绿房子\t\t " );
                        
break ;
                        
case   3 :
                        System.out.print(
" 黄房子\t\t " );
                        
break ;
                        
case   4 :
                        System.out.print(
" 白房子\t\t " );
                        
break ;
                        
case   5 :
                        System.out.print(
" 蓝房子\t\t " );
                        
break ;
                    }
                    }
else   if ( " pet " .equals(item)){
                        
switch (index){
                            
case   1 :
                            System.out.print(
" 狗\t\t " );
                            
break ;
                            
case   2 :
                            System.out.print(
" 鸟\t\t " );
                            
break ;
                            
case   3 :
                            System.out.print(
" 猫\t\t " );
                            
break ;
                            
case   4 :
                            System.out.print(
" 马\t\t " );
                            
break ;
                            
case   5 :
                            System.out.print(
" 鱼\t\t " );
                            
break ;
                        }
                        }
else   if ( " drink " .equals(item)){
                            
switch (index){
                                
case   1 :
                                System.out.print(
" 茶\t\t " );
                                
break ;
                                
case   2 :
                                System.out.print(
" 咖啡\t\t " );
                                
break ;
                                
case   3 :
                                System.out.print(
" 牛奶\t\t " );
                                
break ;
                                
case   4 :
                                System.out.print(
" 啤酒\t\t " );
                                
break ;
                                
case   5 :
                                System.out.print(
" 水\t\t " );
                                
break ;
                            }
                            }
else   if ( " tobacco " .equals(item)){
                                
switch (index){
                                    
case   1 :
                                    System.out.print(
" PALLMALL\t\t " );
                                    
break ;
                                    
case   2 :
                                    System.out.print(
" DUNHILL\t\t " );
                                    
break ;
                                    
case   3 :
                                    System.out.print(
" BLUEMASTER\t\t " );
                                    
break ;
                                    
case   4 :
                                    System.out.print(
" PRINCE\t\t " );
                                    
break ;
                                    
case   5 :
                                    System.out.print(
" 混合烟\t\t " );
                                    
break ;
                                }
                            }


                        }

                        
private   boolean  check01(){
                            
boolean  ret  =   true ;
                            
//   条件1:英国人住在红房子里  01
                             for ( int  i  =   0 ; i  <  nationalities.length; i  ++ ){
                                
if (key[ 0 ][i]  ==  NATIONALITY_ENGLISH){
                                    
if (key[ 1 ][i]  !=  COLOR_RED){
                                        ret 
=   false ;
                                    }
                                    
break ;
                                }
                            }
                            
return  ret;
                        }

                        
private   boolean  check02(){
                            
boolean  ret  =   true ;
                            
//   条件2:瑞典人养了一条狗  02
                             for ( int  i  =   0 ; i  <  nationalities.length; i  ++ ){
                                
if (key[ 0 ][i]  ==  NATIONALITY_SWIDISH){
                                    
if (key[ 2 ][i]  !=  PET_DOG){
                                        ret 
=   false ;
                                    }
                                    
break ;
                                }
                            }
                            
return  ret;
                        }

                        
private   boolean  check1(){
                            
boolean  ret  =   true ;
                            
//   条件4:绿房子在白房子的左边  1
                             for ( int  i  =   0 ; i  <  colors.length; i  ++ ){
                                
if (key[ 1 ][i]  ==  COLOR_GREEN){
                                    
for ( int  j  =   0 ; j  <  colors.length; j  ++ ){
                                        
if (key[ 1 ][j]  ==  COLOR_WHITE){
                                            
if (i  >  j){
                                                ret 
=   false ;
                                            }
                                            
break ;
                                        }
                                    }
                                }
                            }
                            
return  ret;
                        }

                        
private   boolean  check3(){
                            
//   条件8:住在中间房子的人喝牛奶  3
                             return  key[ 3 ][ 2 ==  DRINK_MILK ? true : false ;
                        }

                        
//  条件9:挪威人住在第一间房子  0
                         private   boolean  check0(){
                            
if (key[ 0 ][ 0 !=  NATIONALITY_NORWAY){
                                
return   false ;
                            }
                            
return   true ;
                        }

                        
private   boolean  check011(){
                            
//   14.挪威人住在蓝房子旁边  01
                             boolean  ret  =   false ;
                            
for ( int  i  =   0 ; i  <  nationalities.length; i  ++ ){
                                
if (key[ 0 ][i]  ==  NATIONALITY_NORWAY){
                                    
for ( int  j  =   0 ; j  <  colors.length; j  ++ ){
                                        
if (key[ 1 ][j]  ==  COLOR_BLUE){
                                            
if (Math.abs(i  -  j)  ==   1 ){
                                                
return   true ;
                                                }
else {
                                                    
return   false ;
                                                }

                                            }
                                        }
                                    }
                                }
                                
return  ret;
                            }


                            
////////////////////////////////////////////////////////////////// /


                            
private   boolean  check(){
                                
boolean  ret  =   true ;

                                
//   条件1:英国人住在红房子里  01
                                ret  =  check01();
                                
if (ret == false ) return   false ;
                                
//   条件2:瑞典人养了一条狗  02
                                ret  =  check02();
                                
if (ret == false ) return   false ;
                                
//   条件3:丹麦人喝茶  03
                                 for ( int  i  =   0 ; i  <  nationalities.length; i  ++ ){
                                    
if (key[ 0 ][i]  ==  NATIONALITY_DAMARK){
                                        
if (key[ 3 ][i]  !=  DRINK_TEA){
                                            
return   false ;
                                        }
                                        
else {
                                            
break ;
                                        }
                                    }
                                }

                                
//   条件4:绿房子在白房子的左边  1
                                ret  =  check1();
                                
if (ret == false ) return   false ;
                                
//   条件5:绿房子主人喝咖啡  13
                                 for ( int  i  =   0 ; i  <  colors.length; i  ++ ){
                                    
if (key[ 1 ][i]  ==  COLOR_GREEN){
                                        
if (key[ 3 ][i]  !=  DRINK_COFFEE){
                                            
return   false ;
                                        }
                                        
else {
                                            
break ;
                                        }
                                    }
                                }

                                
//   条件6:抽pallmall烟的人养了一只鸟  24
                                 for ( int  i  =   0 ; i  <  tobaccoes.length; i  ++ ){
                                    
if (key[ 4 ][i]  ==  TOBACCO_PALLMALL){
                                        
if (key[ 2 ][i]  !=  PET_BIRD){
                                            
return   false ;
                                        }
                                        
else {
                                            
break ;
                                        }
                                    }
                                }

                                
//   条件7:黄房子主人抽dunhill烟  14
                                 for ( int  i  =   0 ; i  <  colors.length; i  ++ ){
                                    
if (key[ 1 ][i]  ==  COLOR_YELLOW){
                                        
if (key[ 4 ][i]  !=  TOBACCO_DUNHILL){
                                            
return   false ;
                                        }
                                        
else {
                                            
break ;
                                        }
                                    }
                                }

                                
//   条件8:住在中间房子的人喝牛奶  3
                                ret  =  check3();
                                
if (ret == false ) return   false ;
                                
//   条件9:挪威人住在第一间房子  0
                                ret  =  check0();
                                
if (ret == false ) return   false ;
                                
//   条件10:抽混合烟的人住在养猫人的旁边  24
                                 for ( int  i  =   0 ; i  <  tobaccoes.length; i  ++ ){
                                    
if (key[ 4 ][i]  ==  TOBACCO_MIXED){
                                        
for ( int  j  =   0 ; j  <  pets.length; j  ++ ){
                                            
if (key[ 2 ][j]  ==  PET_CAT){
                                                
if (i  -  j  !=   1   &&  i  -  j  !=   - 1 ){
                                                    
return   false ;
                                                }
                                                
break ;
                                            }
                                        }
                                    }
                                }

                                
//   条件11:养马人住在抽dunhill烟人的旁边  24
                                 for ( int  i  =   0 ; i  <  pets.length; i  ++ ){
                                    
if (key[ 2 ][i]  ==  PET_HORSE){
                                        
for ( int  j  =   0 ; j  <  tobaccoes.length; j  ++ ){
                                            
if (key[ 4 ][j]  ==  TOBACCO_DUNHILL){
                                                
if (i  -  j  !=   1   &&  i  -  j  !=   - 1 ){
                                                    
return   false ;
                                                }
                                                
break ;
                                            }
                                        }
                                    }
                                }

                                
//   条件12:抽bluemaster烟的人喝啤酒  34
                                 for ( int  i  =   0 ; i  <  tobaccoes.length; i  ++ ){
                                    
if (key[ 4 ][i]  ==  TOBACCO_BLUEMASTER){
                                        
if (key[ 3 ][i]  !=  DRINK_BEER){
                                            
return   false ;
                                        }
                                        
else {
                                            
break ;
                                        }
                                    }
                                }

                                
//   13.德国人抽prince烟  04
                                 for ( int  i  =   0 ; i  <  nationalities.length; i  ++ ){
                                    
if (key[ 0 ][i]  ==  NATIONALITY_GERMAN){
                                        
if (key[ 4 ][i]  !=  TOBACCO_PRINCE){
                                            
return   false ;
                                        }
                                        
else {
                                            
break ;
                                        }
                                    }
                                }

                                
//   14.挪威人住在蓝房子旁边  01
                                ret  =  check011();
                                
if (ret == false ) return   false ;
                                
//   15.抽混合烟的人的邻居喝矿泉水  34
                                 for ( int  i  =   0 ; i  <  tobaccoes.length; i  ++ ){
                                    
if (key[ 4 ][i]  ==  TOBACCO_MIXED){
                                        
for ( int  j  =   0 ; j  <  drinks.length; j  ++ ){
                                            
if (key[ 3 ][j]  ==  DRINK_WATER){
                                                
if ((i  -  j  !=   1 &&  (i  -  j  !=   - 1 )){
                                                    
return   false ;
                                                }
                                                
else {
                                                    
break ;
                                                }
                                            }
                                        }
                                    }
                                }




                                
return  ret;
                            }

                            
public   void  run(){
                                
int  count  =   0 ;
                                
for ( int  a  =   0 ; a  <   120 ; a  ++ ){
                                    
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
                                        key[
0 ][i]  =  values[a][i];
                                    }
                                    
if ( ! check0()){ continue ;}


                                    
for ( int  b  =   0 ; b  <   120 ; b  ++ ){
                                        
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
                                            key[
1 ][i]  =  values[b][i];
                                        }
                                        
if ( ! check01()  ||   ! check011()  ||   ! check1()){ continue ;}

                                        
for ( int  c  =   0 ; c  <   120 ; c  ++ ){
                                            
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
                                                key[
2 ][i]  =  values[c][i];
                                            }
                                            
if ( ! check02()){ continue ;}

                                            
for ( int  d  =   0 ; d  <   120 ; d  ++ ){
                                                
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
                                                    key[
3 ][i]  =  values[d][i];
                                                }
                                                
// if(!check()){continue;}

                                                
for ( int  e  =   0 ; e  <   120 ; e  ++ ){
                                                    
for ( int  i  =   0 ; i  <   5 ; i  ++ ){
                                                        key[
4 ][i]  =  values[e][i];
                                                    }
                                                    
if ( ! check()){ continue ;}
                                                    System.out.println(
" 答案 "   +  ( ++ count));
                                                    printKey();
                                                    System.out.println(
" ----------------------------------------------- " );

                                                }

                                            }

                                        }

                                    }
                                }
                            }

                            
public   static   void  main(String[] args){
                                WhoFeedsFish wff 
=   new  WhoFeedsFish();
                                System.out.println(
" ==========Start========== " );
                                wff.run();
                                System.out.println(
" ==========End========== " );
                            }
                        }