Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39164

Re: Python 3.3 vs. MSDOS Basic

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <johimm@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:Python': 0.05; 'modified': 0.05; 'false.': 0.07; 'through,': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; '"m"': 0.16; '"python': 0.16; '#python': 0.16; '524': 0.16; 'corp.': 0.16; 'count,': 0.16; 'n!=1:': 0.16; 'reversing': 0.16; 'subject:3.3': 0.16; 'time.time()': 0.16; 'thanks,': 0.18; 'windows': 0.19; 'import': 0.21; '3.x': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'replace': 0.27; 'lines': 0.28; 'comparison': 0.29; 'function': 0.30; 'skip:8 10': 0.32; 'print': 0.32; 'url:home': 0.33; '(c)': 0.33; 'received:google.com': 0.34; 'built-in': 0.35; 'false': 0.35; 'received:209.85': 0.35; 'bad': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'end': 0.40; 'your': 0.60; 'first': 0.61; 'here': 0.65; 'subject:. ': 0.66; 'subject:Basic': 0.84; 'taken.': 0.84; 'dennis': 0.91
X-Received by 10.50.188.231 with SMTP id gd7mr1800020igc.9.1361238464421; Mon, 18 Feb 2013 17:47:44 -0800 (PST)
Newsgroups comp.lang.python
Date Mon, 18 Feb 2013 17:47:44 -0800 (PST)
In-Reply-To <mailman.1985.1361234188.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=184.12.171.61; posting-account=gOhz-QoAAADlgnQgp9p6Upzop7QLwHqQ
References <e8a634af-4e29-4f45-b327-2dfd1fab5269@googlegroups.com> <mailman.1985.1361234188.2939.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 184.12.171.61
MIME-Version 1.0
Subject Re: Python 3.3 vs. MSDOS Basic
From John Immarino <johimm@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.1992.1361238473.2939.python-list@python.org> (permalink)
Lines 140
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361238473 news.xs4all.nl 6928 [2001:888:2000:d::a6]:43426
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39164

Show key headers only | View raw


> 
> > max=0
> 
> 
> 
> 	"max" is a bad name -- it masks the built-in max() function
> 
> 
> 
> > m=0
> 
> > while m<=1000000:
> 
> >     m+=1
> 
> 
> 
> 	Since "m" is only modified here and has a value of 1 for the first
> 
> pass through, you can replace those three lines with
> 
> 
> 
> for m in xrange(1, 1000001): #python 2.x, just use range() for 3.x
> 
> 
> 
> >     count=0
> 
> >     n=m
> 
> 
> 
> >     while n!=1:
> 
> >         count+=1
> 
> >         if n%2==0:
> 
> >             n=n//2
> 
> >         else:
> 
> >             n=3*n+1
> 
> 
> 
> 	Avoid the comparison to 0 by reversing the then/else actions... Any
> 
> 0 result is false.
> 
> 
> 
> -=-=-=-=-
> 
> import time
> 
> 
> 
> mx = 0
> 
> 
> 
> start = time.time()
> 
> for m in xrange(1, 1000001):
> 
>     count = 0
> 
>     n = m
> 
>     while n > 1:
> 
>         count += 1
> 
>         if n % 2:   # 0 means false
> 
>             n = 3 * n + 1
> 
>         else:
> 
>             n = n // 2
> 
> 
> 
>     if count > mx:
> 
>         mx, num = count, m
> 
> 
> 
> end = time.time()
> 
> 
> 
> print num, mx
> 
> print end-start
> 
> -=-=-=-=-
> 
> Microsoft Windows XP [Version 5.1.2600]
> 
> (C) Copyright 1985-2001 Microsoft Corp.
> 
> 
> 
> E:\UserData\Wulfraed\My Documents>cd "Python Progs"
> 
> 
> 
> E:\UserData\Wulfraed\My Documents\Python Progs>Script1.py
> 
> 837799 524
> 
> 83.2030000687
> 
> 
> 
> E:\UserData\Wulfraed\My Documents\Python Progs>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> 	Wulfraed                 Dennis Lee Bieber         AF6VN
> 
>         wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Thanks, your suggestions are well taken.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python 3.3 vs. MSDOS Basic John Immarino <johimm@gmail.com> - 2013-02-18 11:13 -0800
  Re: Python 3.3 vs. MSDOS Basic Chris Angelico <rosuav@gmail.com> - 2013-02-19 08:55 +1100
  Re: Python 3.3 vs. MSDOS Basic Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-18 14:54 -0700
    Re: Python 3.3 vs. MSDOS Basic Tim Daneliuk <tundra@tundraware.com> - 2013-02-19 08:46 -0600
      Re: Python 3.3 vs. MSDOS Basic Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-19 11:31 -0700
        Re: Python 3.3 vs. MSDOS Basic Tim Daneliuk <tundra@tundraware.com> - 2013-02-20 08:21 -0600
          Re: Python 3.3 vs. MSDOS Basic Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-20 11:38 -0700
            Re: Python 3.3 vs. MSDOS Basic Tim Daneliuk <tundra@tundraware.com> - 2013-02-20 16:49 -0600
              Re: Python 3.3 vs. MSDOS Basic Tim Daneliuk <tundra@tundraware.com> - 2013-02-20 16:59 -0600
      Re: Python 3.3 vs. MSDOS Basic Serhiy Storchaka <storchaka@gmail.com> - 2013-02-19 22:28 +0200
      Re: Python 3.3 vs. MSDOS Basic Chris Angelico <rosuav@gmail.com> - 2013-02-20 08:39 +1100
        Re: Python 3.3 vs. MSDOS Basic Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-02-20 18:32 +1300
  Re: Python 3.3 vs. MSDOS Basic Chris Angelico <rosuav@gmail.com> - 2013-02-19 08:56 +1100
  Re: Python 3.3 vs. MSDOS Basic Chris Angelico <rosuav@gmail.com> - 2013-02-19 08:58 +1100
    Re: Python 3.3 vs. MSDOS Basic John Immarino <johimm@gmail.com> - 2013-02-18 17:39 -0800
      Re: Python 3.3 vs. MSDOS Basic Chris Angelico <rosuav@gmail.com> - 2013-02-19 14:01 +1100
        Re: Python 3.3 vs. MSDOS Basic Nick Mellor <thebalancepro@gmail.com> - 2013-02-18 20:17 -0800
        Re: Python 3.3 vs. MSDOS Basic Nick Mellor <thebalancepro@gmail.com> - 2013-02-18 20:17 -0800
    Re: Python 3.3 vs. MSDOS Basic John Immarino <johimm@gmail.com> - 2013-02-18 17:39 -0800
      Re: Python 3.3 vs. MSDOS Basic Neil Cerutti <neilc@norwich.edu> - 2013-02-20 17:06 +0000
  Re: Python 3.3 vs. MSDOS Basic Chris Angelico <rosuav@gmail.com> - 2013-02-19 09:01 +1100
  Re: Python 3.3 vs. MSDOS Basic Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-18 15:15 -0700
  Re: Python 3.3 vs. MSDOS Basic Alexander Blinne <news@blinne.net> - 2013-02-19 01:11 +0100
  Re: Python 3.3 vs. MSDOS Basic Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-18 19:36 -0500
    Re: Python 3.3 vs. MSDOS Basic John Immarino <johimm@gmail.com> - 2013-02-18 17:47 -0800
    Re: Python 3.3 vs. MSDOS Basic John Immarino <johimm@gmail.com> - 2013-02-18 17:47 -0800
  Re: Python 3.3 vs. MSDOS Basic Terry Reedy <tjreedy@udel.edu> - 2013-02-18 19:50 -0500
    Re: Python 3.3 vs. MSDOS Basic Piet van Oostrum <piet@vanoostrum.org> - 2013-02-19 12:42 +0100
      Re: Python 3.3 vs. MSDOS Basic Alexander Blinne <news@blinne.net> - 2013-02-20 01:23 +0100
        Re: Python 3.3 vs. MSDOS Basic Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-19 18:04 -0700
  Re: Python 3.3 vs. MSDOS Basic Terry Reedy <tjreedy@udel.edu> - 2013-02-19 00:28 -0500
  Re: Python 3.3 vs. MSDOS Basic Anssi Saari <as@sci.fi> - 2013-02-19 12:52 +0200
  Re: Python 3.3 vs. MSDOS Basic Serhiy Storchaka <storchaka@gmail.com> - 2013-02-19 13:13 +0200
  Re: Python 3.3 vs. MSDOS Basic Olive <diolu.remove_this_part@bigfoot.com> - 2013-02-19 15:02 +0100

csiph-web