爱因斯坦谜题:谁养鱼(C#版)  

 一个偶然的机会再次接触到了爱因斯坦谜题,一时来了兴致,用C#做了一个程序,看看到底是谁养鱼(大学毕业后接触过这道题,不过很遗憾,那时的我没有成为2%的人,所以不知道是谁在养鱼)?

这道迷题出自1981年柏林的德国逻辑思考学院,据说世界上只有2%的人能出答案,就连大名鼎鼎的爱因斯坦也成为此题大伤脑。爱因斯坦谜题的中文表述是这样的:

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.抽混合烟的人的邻居喝矿泉水

问题:谁养鱼?

很遗憾的是,这个中文表述有问题,至少有以下几方面的歧义:

一、如何区分左右?二、已知条件中的第4条,绿房子在白房子的左边,是紧邻?还是可以分开?三、第一个房子,从什么方向开始算起,左,还是右?

如果仅把上面的第二点提到的绿房子在白房子的左边,不限于紧邻,则会出现7组符合条件的组合,3个答案:丹麦人养鱼(3组)、德国人养鱼(3组)、挪威人养鱼(1组)。

这显然不符合爱因斯坦谜题的本意,所以又查了查英文原题,结果真相大白,其严谨的表述有效的消除了以上的歧义。那最终的结果究竟又如何呢?

英文原题:

The Einstein Puzzle

 

There are 5 houses in five different colors. They are lined up in a row side by side.

In each house lives a person with a different nationality.

These 5 owners drink a certain drink, smoke a certain brand of tobacco and keep a certain pet.

No owners have the same pet, smoke the same tobacco, or drink the same drink.

As you look at the 5 houses from across the street, the green house is adjacent(woog注释:adjacent adj,毗连的,邻近的,接近的;n,近邻) to the left of the white house

The Big Question is:

Who owns the Fish?

 

CLUES:

1、The Brit lives in the red house

2、The Swede keeps dogs as pets

3、The Dane drinks tea

4、The green house is on the immediate left of the white house as you stare at the front of the 5 houses

5、The green house owner drinks coffee

6、The person who smokes Pall Mall raises birds

7、The owner of the yellow house smokes Dunhill

8、The man living in the house right in the center drinks milk

9、The Norwegian lives in the first house

10、The man who smokes Blends lives next to the one who keeps cats

11、The man who keeps horses lives next to the one who smokes Dunhill

12、The owner who smokes Bluemaster drinks juice

13、The German smokes Prince

14、The Norwegian lives next to the blue house

15、The man who smokes Blend has a neighbor who drinks water.

 

相关代码如下(考虑了两种情况,当#define FastCompute时,仅有一组答案):

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值