无心人 发表于 2008-6-20 11:14:50

条件12
let filter12 (x1, x2, x3, x4, x5, x6) = not (xor (x4 =='B') (x6 == 'B'))
条件13:
let filter13 (x1, x2, x3, x4, x5, x6) = not (xor (x3 =='G') (x6 == 'R'))
所有简单条件罗列完

let t1 = filter filter1 t6
let t2 = filter filter2 t1
let t3 = filter filter3 t2
let t5 = filter filter5 t3
let t6_1 = filter filter6 t5
let t7 = filter filter7 t6_1
let t8 = filter filter8 t7
let t9 = filter filter9 t8
let t12 = filter filter12 t9
let t13 = filter filter13 t12

lengtht13
输出: 144

无心人 发表于 2008-6-20 11:35:25

条件4
绿房子在白房子左面
即绿房子序号 小于等于白房子
目前只能说白房子序号大于等于2
let filter4_1 (x1, x2, x3, x4, x5, x6) = ((x2 == 'W') && (x1 >= 2))|| not (x2 == 'W')
且绿房子序号小于5
let filter4_2 (x1, x2, x3, x4, x5, x6) = ((x2 == 'G') && (x1 < 5))|| not (x2 == 'G')

let t4 = filter filter4_2 (filter filter4_1 t13)
length t4
134组

无心人 发表于 2008-6-20 12:02:10

目前各位置候选数
1、15
2、37
3、15
4、37
5、33

无心人 发表于 2008-6-20 15:57:23

中午考虑了

把10个简单条件筛选后的144个结果
就应该按编号分5个表分开了

而这5个表现在如果进行组合的话
理论的组合数大概在1亿内
但考虑相互之间存在很多冲突

考虑冲突情况

此时的实际数字应该是很小的

而余下的五个条件的利用

我想也应该是在组合了5个表的基础上应用

不过,haskell如何组合5个表,且使符合不冲突的条件
我还是不会作的 哈

无心人 发表于 2008-6-20 16:09:14

let is1 (x1, x2, x3, x4, x5, x6)= (x1 == 1)
let is2 (x1, x2, x3, x4, x5, x6)= (x1 == 2)
let is3 (x1, x2, x3, x4, x5, x6)= (x1 == 3)
let is4 (x1, x2, x3, x4, x5, x6)= (x1 == 4)
let is5 (x1, x2, x3, x4, x5, x6)= (x1 == 5)

let l1 = filter is1 t13
let l2 = filter is2 t13
let l3 = filter is3 t13
let l4 = filter is4 t13
let l5 = filter is5 t13

分解后元素数量
l121
l237
l312
l437
l537

无心人 发表于 2008-6-20 16:15:10

let filter4_G (x1, x2, x3, x4, x5, x6) = not (x2 == 'G')
let filter4_W (x1, x2, x3, x4, x5, x6) = not (x2 == 'W')
let l11 = filter filter4_W l1
let l51 = filter filter4_G l5
length l11
15
length l51
33

应用条件4得到的结论
1不能有白房子
5不能有绿房子

无心人 发表于 2008-6-20 16:21:13

应用条件14
2是蓝房子

let filter2_B (x1, x2, x3, x4, x5, x6) = (x2 == 'B')
let l21 = filter filter2_B l2
length l21
11

无心人 发表于 2008-6-20 16:32:25

条件10
抽混合烟的人和养猫的不是一个
let filter10 (x1, x2, x3, x4, x5, x6) = not ((x4 == 'C') && (x6 == 'U'))
条件11
养马的和抽DUNHILL烟的不是一个
let filter11 (x1, x2, x3, x4, x5, x6) = not ((x4 == 'H') && (x6 == 'D'))
条件15
抽混合烟的和喝矿泉水的不是一个
let filter15 (x1, x2, x3, x4, x5, x6) = not ((x5 == 'W') && (x6 == 'U'))

无心人 发表于 2008-6-20 16:36:59

对5个表过滤三个条件

let l13 = filter filter10 (filter filter11 (filter filter15 l11))
let l23 = filter filter10 (filter filter11 (filter filter15 l21))
let l33 = filter filter10 (filter filter11 (filter filter15 l3))
let l43 = filter filter10 (filter filter11 (filter filter15 l4))
let l53 = filter filter10 (filter filter11 (filter filter15 l51))

Prelude> l13
[(1,'B','N','H','B','U'),(1,'B','N','F','B','U'),(1,'Y','N','C','W','D'),(1,'Y','N','C','B','D'),(1,'Y','N','F','W','D'),(1,'Y','N','F','B','D'),(1,'G','N','H','C','U'),(1,'G','N','F','C','U')]
Prelude> l23
[(2,'B','G','C','W','R'),(2,'B','G','C','B','R'),(2,'B','G','H','W','R'),(2,'B','G','H','B','R'),(2,'B','G','F','W','R'),(2,'B','G','F','B','R'),(2,'B','S','D','B','U'),(2,'B','D','H','T','U'),(2,'B','D','F','T','U')]
Prelude> l33
[(3,'R','E','H','M','U'),(3,'R','E','F','M','U'),(3,'B','G','C','M','R'),(3,'B','G','H','M','R'),(3,'B','G','F','M','R'),(3,'B','S','D','M','U'),(3,'Y','S','D','M','D'),(3,'W','G','C','M','R'),(3,'W','G','H','M','R'),(3,'W','G','F','M','R'),(3,'W','S','D','M','U')]
Prelude> l43
[(4,'R','E','H','B','U'),(4,'R','E','F','B','U'),(4,'B','G','C','W','R'),(4,'B','G','C','B','R'),(4,'B','G','H','W','R'),(4,'B','G','H','B','R'),(4,'B','G','F','W','R'),(4,'B','G','F','B','R'),(4,'B','S','D','B','U'),(4,'B','D','H','T','U'),(4,'B','D','F','T','U'),(4,'Y','S','D','W','D'),(4,'Y','S','D','B','D'),(4,'Y','D','C','T','D'),(4,'Y','D','F','T','D'),(4,'W','G','C','W','R'),(4,'W','G','C','B','R'),(4,'W','G','H','W','R'),(4,'W','G','H','B','R'),(4,'W','G','F','W','R'),(4,'W','G','F','B','R'),(4,'W','S','D','B','U'),(4,'W','D','H','T','U'),(4,'W','D','F','T','U'),(4,'G','G','C','C','R'),(4,'G','G','H','C','R'),(4,'G','G','F','C','R'),(4,'G','S','D','C','U')]
Prelude> l53
[(5,'R','E','H','B','U'),(5,'R','E','F','B','U'),(5,'B','G','C','W','R'),(5,'B','G','C','B','R'),(5,'B','G','H','W','R'),(5,'B','G','H','B','R'),(5,'B','G','F','W','R'),(5,'B','G','F','B','R'),(5,'B','S','D','B','U'),(5,'B','D','H','T','U'),(5,'B','D','F','T','U'),(5,'Y','S','D','W','D'),(5,'Y','S','D','B','D'),(5,'Y','D','C','T','D'),(5,'Y','D','F','T','D'),(5,'W','G','C','W','R'),(5,'W','G','C','B','R'),(5,'W','G','H','W','R'),(5,'W','G','H','B','R'),(5,'W','G','F','W','R'),(5,'W','G','F','B','R'),(5,'W','S','D','B','U'),(5,'W','D','H','T','U'),(5,'W','D','F','T','U')]
Prelude>

Prelude> length l13
8
Prelude> length l23
9
Prelude> length l33
11
Prelude> length l43
28
Prelude> length l53
24

总理论组合数8*9*11*28*24 = 532224
现在已可穷举
谁作下穷举

[ 本帖最后由 无心人 于 2008-6-20 16:39 编辑 ]

无心人 发表于 2008-6-20 16:45:17

应用条件7
黄房子人抽DUNHILL烟
应用条件11
养马人住在抽DUNHILL烟人的旁边

因为2是兰房子, 绿房子在白房子左面
可能组合是
1、G B X X W
2、G B X W X
3、G B W X X
4、X B G X W
5、X B G W X
6、X B X G W
看有可利用7, 11条件的么
页: 1 2 [3] 4 5 6
查看完整版本: Haskell自我娱乐帖