来看看这道爱因斯坦出的智商测试题, 他说世界上有98%的人回答不出, 看看你是否属于另外的2%:
[list]
[*]1. 有5栋5种颜色的房子
[*]
[*]2. 每一位房子的主人国籍都不同
[*]
[*]3. 这5个人每人只喝一个牌子的饮料, 只抽一个牌子的香烟, 只养一种宠物
[*]
[*]4. 没有人有相同的宠物, 抽相同牌子的香烟, 喝相同的饮料
[/list]
已知:
[list]
[*]1. 英国人住在红房子里
[*]
[*]2. 瑞典人养了一条狗
[*]
[*]3. 丹麦人喝茶
[*]
[*]4. 绿房子在白房子左边
[*]
[*]5. 绿房子主人喝咖啡
[*]
[*]6. 抽PALL MALL烟的人养了一只鸟
[*]
[*]7. 黄房子主人抽DUNHILL烟
[*]
[*]8. 住在中间那间房子的人喝牛奶
[*]
[*]9. 挪威人住在第一间房子
[*]
[*]10. 抽混合烟的人住在养猫人的旁边
[*]
[*]11. 养马人住在DUNHILL烟的人旁边
[*]
[*]12. 抽BLUE MASTER烟的人喝啤酒
[*]
[*]13. 德国人抽PRINCE烟
[*]
[*]14. 挪威人住在蓝房子旁边
[/list]
[b]请问 是谁养鱼?
[/b]
[b]问题补充:[/b]
[code="java"]class Person
attr_accessor :nationality, :residing, :drinking, :smoking, :pet, :number
def initialize(number, residing = nil)
@number = number
@residing = residing
end
end
class Residing
attr_accessor :number, :host, :color
def initialize(number, color = nil, host = nil)
@number = number
@host = host
@color = color
end
end
residing_1 = Residing.new(1, "yellow") # making use of condition 9, 7
person_1 = Person.new(1, residing_1)
person_1.nationality = "Norway" #making use of condition 9
person_1.smoking = "DUNHILL" #making use of condition 7
person_1.pet = "cat"
#"cat"
residing_2 = Residing.new(2, "blue") # making use of condition 14
person_2 = Person.new(2, residing_2)
person_2.pet = "horse" # condition 11
person_2.nationality = "Denmark"
person_2.drinking = "tea"
person_2.smoking = "blend cigarette"
#"Denmark" "tea" "blend"
residing_3 = Residing.new(3, nil) #making use of condition 8
person_3 = Person.new(3, residing_3)
person_3.nationality = "English"
person_3.drinking = "milk" #making use of condition 8
person_3.residing.color = "red" #making use of conditon 1
person_3.smoking = "PALL MALL"
person_3.pet = "bird"
#"PALL MALL" "bird"
residing_4 = Residing.new(4, "green")# making use
person_4 = Person.new(4, residing_4)
person_4.drinking = "coffee" # making use of condition 5
person_4.nationality = "German"
person_4.smoking = "PRINCE"
#"Germ" "PRINCE"
residing_5 = Residing.new(5, "white")# making use of condition 9,14,4
person_5 = Person.new(5, residing_5)
person_5.nationality = "Sweden"
person_5.pet = "dog"
person_5.smoking = "BLUE MASTER"
person_5.drinking = "beer"
#"Sweden" "dog"
#"BLUE MASTER" "beer"
#after the initialization of the status,input as the followings
arr = [person_1, person_2, person_3, person_4, person_5]
arr.each do |i|
i.pet ||= "fish"
puts "Nationality: #{i.nationality}; house-color: #{i.residing.color}, drink #{i.drinking},
smoke #{i.smoking}, raise the pet #{i.pet} "
end[/code]