找回密码
 欢迎注册
楼主: 无心人

[分享] Haskell自我娱乐帖

[复制链接]
 楼主| 发表于 2008-5-12 20:10:47 | 显示全部楼层
前20正整数的4次幂划分 Prelude List> sum (map (^4) n20) 722666 Prelude List> div 722666 2 361333 Prelude List> let f1 x = (sum (map (^4) x)) == 361333 Prelude List> let l4_20 = filter f1 (selectDistinct 10 n20) Prelude List> l4_20 [[5,7,9,10,12,13,14,16,17,18],[4,5,7,8,12,13,15,16,17,18],[1,4,5,8,10,13,14,16,1 7,19],[2,5,6,7,8,13,14,15,18,19],[1,3,4,9,10,11,12,16,17,20],[2,3,6,7,9,11,12,15 ,18,20],[1,2,3,6,9,10,11,14,19,20],[1,2,3,4,6,8,11,15,19,20]] Prelude List> length l4_20 8 共4组
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-5-12 20:15:35 | 显示全部楼层
同样道理证明16的没4次幂划分 Prelude List> sum (map (^4) n16) 243848 Prelude List> div 243848 2 121924 Prelude List> let f1 x = (sum (map (^4) x)) == 121924 Prelude List> let l4_16= filter f1 (selectDistinct 8 n16) Prelude List> l4_16 [] Prelude List> n16 [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-5-12 20:19:40 | 显示全部楼层
考虑5次幂情况 尝试求和得到下列结果 Prelude List> let n22=[1..22] Prelude List> let n24=[1..24] Prelude List> let n26=[1..26] Prelude List> let n28=[1..28] Prelude List> let n30=[1..30] Prelude List> let n32=[1..32] Prelude List> sum (map (^5) n16) 3347776 Prelude List> sum (map (^5) n20) 12333300 Prelude List> sum (map (^5) n22) 21571033 Prelude List> sum (map (^5) n24) 35970000 Prelude List> sum (map (^5) n26) 57617001 Prelude List> sum (map (^5) n28) 89176276 Prelude List> sum (map (^5) n30) 133987425 Prelude List> sum (map (^5) n32) 196171008 Prelude List> sum (map (^5) n18) 6657201 从16到32,可能数字是16, 20, 24, 28, 32
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-5-12 20:24:29 | 显示全部楼层
5次幂划分 16, 20没找到结果
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-5-12 20:28:32 | 显示全部楼层
24的5次幂划分得到结果!!!! Prelude List> div 35970000 2 17985000 Prelude List> let f5 x = (sum (map (^5) x)) == 17985000 Prelude List> let l5_24 = filter f5 (selectDistinct 12 n24) Prelude List> l5_24 [[1,2,5,7,10,13,14,15,19,20,21,23],[3,5,6,7,8,9,12,17,19,20,21,23],[3,4,7,8,9,11 ,12,13,17,21,22,23],[1,2,5,6,10,14,15,16,18,19,20,24],[1,2,4,10,11,13,14,15,16,1 8,22,24],[3,4,6,8,9,11,12,16,17,18,22,24]] Prelude List> length l5_24 6 共三组
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-6-20 10:23:29 | 显示全部楼层
let position=[1,2,3,4,5] let color=['R', 'B', 'Y', 'W', 'G'] let contnationality=['E','G', 'S', 'D', 'N'] let pet=['D', 'C', 'B', 'H', 'F'] let drink=['T', 'C', 'M', 'W', 'B'] let cigarette=['P', 'D', 'B', 'R', 'U'] let t6 = [(x1, x2, x3, x4, x5, x6) | x1 <- position, x2 <- color, x3 <- contnationality, x4 <- pet, x5 <- drink, x6 <- cigarette] [ 本帖最后由 无心人 于 2008-6-20 15:59 编辑 ]
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-6-20 10:25:54 | 显示全部楼层
位置编号:1,2,3,4,5 颜色编号: R, B, Y, W, G 国籍编号:E英国,G德国,S瑞典,D丹麦,N挪威 宠物:D狗,C猫,B鸟,H马,F鱼 饮料:T茶,C咖啡,M牛奶,W矿泉水,B啤酒 香烟:P = PALLMALL D = DUNHILL B = BULEMASTER R=PRINCE U=混合 [ 本帖最后由 无心人 于 2008-6-20 11:12 编辑 ]
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-6-20 10:38:04 | 显示全部楼层
相邻的界定 let isNeighbor x y = abs(x-y) == 1 1、英国人住在红房子里 2、瑞典人养了一条狗 3、丹麦人喝茶 4、绿房子在白房子的左边 5、绿房子主人喝咖啡 6、抽PALL MALL 烟的人养了一只鸟 7、黄房子主人抽DUNHILL烟 8、住在中间房子的人喝牛奶 9、挪威人住在第一间房子 10、抽混合烟的人住在养猫人的旁边 11、养马人住在抽DUNHILL烟人的旁边 12、抽BLUE MASTER烟的人喝啤酒 13、德国人抽PRINCE烟 14、挪威人住在蓝房子旁边 15、抽混合烟的人的邻居喝矿泉水
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-6-20 10:58:39 | 显示全部楼层
xor 实现 let xor a b = (a || b) && (not (a && b)) 条件1: let filter1 (x1, x2, x3, x4, x5, x6) = not (xor (x2 == 'R') (x3 == 'E')) 条件2: let filter2 (x1, x2, x3, x4, x5, x6) = not (xor (x4 == 'D') (x3 == 'S')) 条件3: let filter3 (x1, x2, x3, x4, x5, x6) = not (xor (x5 == 'T') (x3 == 'D')) 条件5: let filter5 (x1, x2, x3, x4, x5, x6) = not (xor (x2 == 'G') (x5 == 'C')) 条件6 let filter6 (x1, x2, x3, x4, x5, x6) = not (xor (x6 == 'P') (x4 == 'B')) [ 本帖最后由 无心人 于 2008-6-20 16:02 编辑 ]
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2008-6-20 11:11:52 | 显示全部楼层
条件7: let filter7 (x1, x2, x3, x4, x5, x6) = not (xor (x2 == 'Y') (x6 == 'D')) 条件8: let filter8 (x1, x2, x3, x4, x5, x6) = not (xor (x1 == 3) (x5 == 'M')) 条件9: let filter9 (x1, x2, x3, x4, x5, x6) = not (xor (x1 == 1) (x3 == 'N')) [ 本帖最后由 无心人 于 2008-6-20 11:54 编辑 ]
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-11-21 21:21 , Processed in 0.028799 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表