Python论坛  - 讨论区

标题:Re: Re: 回复:Re[2]: 回复:Re[10]: [python-chinese] 趣味问题――号码分配――执行测试

2004年04月27日 星期二 22:38

刘鑫 liux at gdcn.com
Tue Apr 27 22:38:26 HKT 2004

Zoom.Quiet,您好!

	这样比较不公平的,呵呵,两位的都生成了完整的排列列表,我的没有,直接以公式算出来的,要比的话,应该是我的算法和Ye Tao的比,我们俩个的是一种类型。

======= 2004-04-27 21:49:30 您在来信中写道:=======

>Hollo liux:
>重新封装了一下子,最初您的代码再进行比较:
>
>]python CBiterative.py
>
> run at: 2004-04-27 21:19:39
> end at: 2004-04-27 21:19:39
> 本次运行共用时 0.0秒
>当罐有 9 个时,全部
>"本解决方案不进行排列尝试"  种排列中,CBiterative算法解得:133496 种!
>
>太夸张了!快的都不用时间???
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>]python codeBall.py
>
> run at: 2004-04-27 21:18:26
> end at: 2004-04-27 21:18:46
> 本次运行共用时 20.6990001202秒
>当罐有 9 个时,全部 362880 种排列中,合题的为:133496 种!
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>]python CBfilter.py
>
> run at: 2004-04-27 21:20:27
> end at: 2004-04-27 21:43:32
> 本次运行共用时 1385.171秒
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>在下家里的环境:
>Python 2.3.3 (CJK/SJIS) (#51, Feb 13 2004, 22:04:56) [MSC v.1200 32 bit (Intel)]
> on win32
>
>--------[ AIDA32 (c) 1995-2002 Unlimited Possibilities ]-------
>    Version                                           AIDA32 v2.00
>    Author                                            fiery at freemail.hu
>    Homepage                                          http://hardware.jatekok.hu/aida32/
>    Report Type                                       Quick Report
>    Computer                                          ZQSTUDIO-ORG
>    Generator                                         Zoomq
>    Operating System                                  Microsoft Windows Server 2003 Server (Enterprise Edition) 5.2.3790 (.NET Beta)
>    Date                                              2004-04-27
>    Time                                              21:21
>--------[ CPU ]-------
>    CPU Properties:
>      CPU Type                                          Intel Celeron II, 1007 MHz (9 x 111)
>      CPU Alias                                         Celeron III, Coppermine Lite, Coppermine-128
>      L1 Code Cache                                     16 KB
>      L1 Data Cache                                     16 KB
>      L2 Cache                                          128 KB (On-Die, Full-Speed)
>--------[ Memory ]--------
>    Physical Memory:
>      Total                                             639 MB
>      Used                                              359 MB
>      Free                                              279 MB
>      Utilization                                       56 %
>
>
>呜乎哀哉!看来代码是否有Python 的特质,漂亮并不代表是否执行效率高!?
>
>简单,正确的思路是关键哪………………
>
>/******** [2004-4-27]21:19:23 ; you wrote:
>
>
>
>liux at gdcn.com> ----- 原邮件 -----
>
>liux at gdcn.com> 从: "Zoom.Quiet" <zoomq at infopro.cn>
>
>liux at gdcn.com> 日期: 星期二, 四月 27日, 2004 下午5:59
>
>liux at gdcn.com> 主题: Re[2]: 回复:Re[10]:
>liux at gdcn.com> [python-chinese]趣味问题――号码分配――执行测试
>
>
>
>>> Hollo Who: 
>>> 
>>> 嗯嗯…………""" 
>>> 返回一个迭代器,称为生成器迭代器,或者更常用的,生成器。通过重复地调用生成器的next()方法来运行生成器的函数体,直到抛出一个异常...
>>> """ 
>>> yield 是用以将普通函式,声明为 构造函式的?! 
>>> 为什么不用class.... 学习中! 
>>> 非常精美哪! 
>>> 
>>> 随手使用文件输出修改了一下子, 
>>> 并加入计时,进行效率比较: 
>>> 
>>> ]python codeBall.py 
>>> 
>>> run at: 2004-04-27 17:43:02 
>>> end at: 2004-04-27 17:43:03 
>>> 本次运行共用时 0.547000169754秒 
>>> 成功输出数据到文件:CodeBall.log 
>>> 当罐有 8 个时,全部 40320 种排列中,合题的为:14833 种! 
>>> 
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
>>> 
>>> ]python CBfilter.py 
>>> 
>>> run at: 2004-04-27 17:42:44 
>>> end at: 2004-04-27 17:42:50 
>>> 本次运行共用时 6.25秒 
>>> 成功输出数据到文件:CBfilte.log 
>>> 
>>> 不会吧!在下最笨的方法居然会快捷一些? 
>>> 大家评评理,不可能的吧! 
>>> 
>>> 在下的测试环境: 
>>> Python 2.3.3 (CJK) (#51, Feb 13 2004, 21:18:21) [MSC v.1200 32 bit 
>>> (Intel)] on win32 
>>> 
>>> --------[ AIDA32 (c) 1995-2002 Unlimited Possibilities ]-------- 
>>> Version AIDA32 v2.00 
>>> Author 
>>> fiery at freemail.hu Homepage 
>>> http://hardware.jatekok.hu/aida32/ 
>>> Report Type Quick Report 
>>> Computer ZQSTUDIO 
>>> (ZqStudio) Generator 
>>> Administrator Operating System 
>>> Microsoft Windows Server 2003 Server (Enterprise Edition) 5.2.3790 
>>> (.NET Beta) 
>>> --------[ CPU ]------------ 
>>> CPU Properties: 
>>> CPU Type Intel 
>>> Pentium 4A, 2525 MHz (6.25 x 404) 
>>> CPU Alias Northwood, 
>>> A80532 L1 Trace Cache 12K 
>>> Instructions L1 Data Cache 
>>> 8 KB 
>>> L2 Cache 0 
>>> --------[ Memory ]------- 
>>> 
>>> Physical Memory: 
>>> Total 255 MB 
>>> Used 200 MB 
>>> Free 54 MB 
>>> Utilization 79 % 
>>> 
>>> 嗯嗯!在Linux 中再试一试: 
>>> ++++++++++++++++++++++++++++++++++++++++++++++++ 
>>> Python 2.3.3 (#1, Feb 12 2004, 22:21:49) 
>>> [GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2 
>>> 
>>> PII 266 128Mb; RedHat 8.0 
>>> ++++++++++++++++++++++++++++++++++++++++++++++++ 
>>> [Zoomq at redhat8 zCodeBall]$ python codeBall.py 
>>> 
>>> run at: 2004-04-27 18:03:10 
>>> end at: 2004-04-27 18:03:17 
>>> 本次运行共用时 6.66619110107秒 
>>> 成功输出数据到文件:CodeBall.log 
>>> 当罐有 8 个时,全部 40320 种排列中,合题的为:14833 种! 
>>> 
>>> [Zoomq at redhat8 zCodeBall]$ python CBfilter.py 
>>> 
>>> run at: 2004-04-27 18:03:55 
>>> end at: 2004-04-27 18:04:25 
>>> 本次运行共用时 30.2400951385秒 
>>> 成功输出数据到文件:CBfilte.log 
>>> 
>>> 没有天理哪! 
>>> 难道Python 喜欢笨伯? 
>>> 
>>> 在下只是组织了一下子,最直接的排除法, 
>>> 先生成所有排列,然后过滤去不吻合的是也乎是也乎………… 
>
>liux at gdcn.com> Bruce的代码用了递归,而且有几处还可以优化,再说从效率上讲,你的代码也不差呀^_^
>>> 
>>> /******** [2004-04-27]16:40:42 ; you wrote: 
>>> 
>>> Who Bruce>
>>> 把我的程序也贴上来给大家参考,顺便演示一下yield的用法(记得前一段时间有人问
>>> Who Bruce> 过),:-) 
>>> Who Bruce> 用这个程序算10个球得出来的结果是1334961: 
>>> 
>>> Who Bruce> 比较简短,就不放附件里了。 
>>> 
>>> Who Bruce> def f(l,start=1): 
>>> Who Bruce> if len(l)==0:yield "" 
>>> Who Bruce> else: 
>>> Who Bruce> tmp="" 
>>> Who Bruce> for x in l: 
>>> Who Bruce> if x == start:continue 
>>> Who Bruce> for y in f(filter(lambda z:z!=x,l),start+1): 
>>> Who Bruce> yield str(x)+y 
>>> 
>>> Who Bruce> def main(): 
>>> Who Bruce> ans=[] 
>>> Who Bruce> for x in f(range(1,5),1): 
>>> Who Bruce> print x 
>>> Who Bruce> ans.append(x) 
>>> Who Bruce> print 'total:',len(ans) 
>>> 
>>> Who Bruce> main() 
>>> 
>>> 
>>> 
>>> >>From: liux at gdcn.com 
>>> >>Reply-To: python-chinese at lists.python.cn 
>>> >>To: "Zoom.Quiet" <zoomq at infopro.cn>, python-chinese at lists.python.cn
>>> >>Subject: 回复:Re[10]:
>>> [python-chinese]趣味问题――号码分配――修订代码 
>>> >>Date: Tue, 27 Apr 2004 16:02:57 +0800 
>>> >> 
>>> >><< codeBall.py >> 
>>> >><< outputLog.py >> 
>>> >><< PnC.py >> 
>>> >>_______________________________________________ 
>>> >>python-chinese list 
>>> >>python-chinese at lists.python.cn 
>>> >>http://python.cn/mailman/listinfo/python-chinese 
>>> >>_______________________________________________ 
>>> >>python-chinese list 
>>> >>python-chinese at lists.python.cn 
>>> >>http://python.cn/mailman/listinfo/python-chinese 
>>> 
>>> 
>>> 
>>> ********************************************/ 
>>> 
>>> -- 
>>> Free as in Freedom 
>>> 
>>> Zoom.Quiet 
>>> 
>>> #=========================================# 
>>> ]Time is unimportant, only life important![ 
>>> #=========================================# 
>>> 
>>> sender is the Bat!2.02 CE 
>>> 
>
>
>
> 
>
>
>********************************************/
>
>-- 
>Free as in Freedom
>
> Zoom.Quiet                           
>
>#=========================================#
>]Time is unimportant, only life important![
>#=========================================#
>
>sender is the Bat!2.02 CE
>

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        刘鑫
        liux at gdcn.com
          2004-04-27


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年04月28日 星期三 01:11

Anew Anewboy at citiz.net
Wed Apr 28 01:11:50 HKT 2004

Zoom.Quiet,您好!

	我用的是Win2k advance server 英文版+Sp4, 但好像就是不行。我后来试过用非unicode的wxpython
但是看上去是很正常的中文字在Copy到剪切板后立刻变成乱码!(但其怪的是贴到IE中是乱码,贴到Total commander 中却一切正常,晕倒.......)

======= 2004-04-26 22:57:00 您在来信中写道:=======

>Hollo CHEN:
>
>  win2k 可以的,
>在下以前就是在win2k 打包的win2k3 还没有试过……
>
>
>/******** [2004-4-26]22:56:48 ; you wrote:
>
>C:\>>python setup.py py2exe
>CHEN Guang (Oliver)> 其余的参数都放在 setup.py 内部了。
>CHEN Guang (Oliver)> 我没试过 win2000 
>
>CHEN Guang (Oliver)>  --- Anew
>CHEN Guang (Oliver)> <Anewboy at citiz.net> 的正文:> CHEN Guang
>CHEN Guang (Oliver)> \(Oliver\),您好!
>>> 
>>> 
>>>
>CHEN Guang (Oliver)> 我所用的系统是win2000,因该是和XP一样也支持unicode的,但是就是不行......
>>> 	你用py2exe打包的时候用什么参数吗?
>>> 
>>> ======= 2004-04-26 14:56:00 您在来信中写道:=======
>>> 
>>> >Anew 您好
>>> >我在 Win98 下运行也出现过类似的问题,后来改在 winXP
>>> >下运行就好了,XP 下做出来的 EXE 文件拿到 98
>>> >下也好用的。
>>> >
>>> > --- Anew <Anewboy at citiz.net> 的正文:>
>>> >python-chinese,您好!
>>> >> 
>>> >> 
>>> 我用py2exe打包的时候发生的一个问题。出现以下错误:
>>> >> 	
>>> >> 	LookupError: unknown encoding: gb2312
>>> >> 
>>> >> 
>>> >>
>>>
>>>但如果不打成exe,直接运行的话没什么问题,但只要打成exe就是会出错!
>>> >>    
>>> >>
>>>
>>>想得到的办法我都试了,可是就是不行,这是我的setup文件:
>>> >> 
>>> >> from distutils.core import setup
>>> >> import py2exe
>>> >> 
>>> >> setup(windows=["MainGuiApp.py"], 
>>> >>       options = {"py2exe": {"packages":
>>> >> ['encodings']}}, 
>>> >> ) 
>>> >> 
>>> >> 
>>> >> 	附: 引起错误的语句: unicode(html.getContent(),
>>> >> "gb2312")
>>> >> 
>>> >>         致
>>> >> 礼!
>>> >>  				
>>> >> 
>>> >>         Anew
>>> >>         Anewboy at citiz.net
>>> >>           2004-04-25
>>> >> > _______________________________________________
>>> >> python-chinese list
>>> >> python-chinese at lists.python.cn
>>> >> http://python.cn/mailman/listinfo/python-chinese
>>> >>  
>>> >
>>>
>>>_________________________________________________________
>>> >Do You Yahoo!? 
>>> >惠普TT游戏剧,玩游戏,中大奖!
>>>
>>>http://cn.rd.yahoo.com/mail_cn/tag/SIG=1402c0to2/**http%3A%2F%2Fhp.allyes.com%2Flaserjet%2Fgamestory%2Findex.html%3Fjumpid%3Dex_hphqapcn_MongooseLJ1010%2F201073CN407016%2FYahoo
>>> >_______________________________________________
>>> >python-chinese list
>>> >python-chinese at lists.python.cn
>>> >http://python.cn/mailman/listinfo/python-chinese
>>> >
>>> 
>>> = = = = = = = = = = = = = = = = = = = =
>>> 			
>>> 
>>>         致
>>> 礼!
>>>  
>>> 				 
>>>         Anew
>>>         Anewboy at citiz.net
>>>           2004-04-26
>>> 
>>> > _______________________________________________
>>> python-chinese list
>>> python-chinese at lists.python.cn
>>> http://python.cn/mailman/listinfo/python-chinese
>>>  
>
>CHEN Guang (Oliver)> _________________________________________________________
>CHEN Guang (Oliver)> Do You Yahoo!? 
>CHEN Guang (Oliver)> 惠普TT游戏剧,玩游戏,中大奖!
>CHEN Guang (Oliver)> http://cn.rd.yahoo.com/mail_cn/tag/SIG=1402c0to2/**http%3A%2F%2Fhp.allyes.com%2Flaserjet%2Fgamestory%2Findex.html%3Fjumpid%3Dex_hphqapcn_MongooseLJ1010%2F201073CN407016%2FYahoo
>CHEN Guang (Oliver)> _______________________________________________
>CHEN Guang (Oliver)> python-chinese list
>CHEN Guang (Oliver)> python-chinese at lists.python.cn
>CHEN Guang (Oliver)> http://python.cn/mailman/listinfo/python-chinese
>
>
>********************************************/
>
>-- 
>Free as in Freedom
>
> Zoom.Quiet                           
>
>#=========================================#
>]Time is unimportant, only life important![
>#=========================================#
>
>sender is the Bat!2.02 CE
>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        Anew
        Anewboy at citiz.net
          2004-04-27


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号