Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'python,': 0.02; 'algorithm': 0.04; 'yet.': 0.04; 'motivated': 0.05; 'that?': 0.05; '[];': 0.09; 'python': 0.11; 'random': 0.14; "wouldn't": 0.14; 'algorithm.': 0.16; 'remainder': 0.16; 'say.': 0.16; 'subject:search': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'written': 0.21; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'integer': 0.24; "haven't": 0.24; "i've": 0.25; 'least': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'am,': 0.29; 'converting': 0.30; 'fastest': 0.30; 'code': 0.31; 'break;': 0.31; 'decimal': 0.31; 'class': 0.32; 'guess': 0.33; 'limitation': 0.33; 'actual': 0.34; 'skip:d 20': 0.34; "i'd": 0.34; 'could': 0.34; 'message.': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'oracle': 0.36; 'var': 0.36; 'doing': 0.36; 'next': 0.36; 'error.': 0.37; 'half': 0.37; 'skip:o 20': 0.38; 'todo': 0.38; 'to:addr:python-list': 0.38; 'realize': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'space': 0.40; 'how': 0.40; 'even': 0.60; 'read': 0.60; 'most': 0.60; "you're": 0.61; 'email addr:gmail.com': 0.63; 'skip:n 10': 0.64; 'pick': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'between': 0.67; 'received:74.208': 0.68; 'fact,': 0.69; 'truth': 0.81; 'trial': 0.83; '");': 0.84; '000,': 0.84; 'break.': 0.84; 'subject:find': 0.84; 'yet?': 0.84; 'subject:Best': 0.91; '000': 0.93 Date: Tue, 07 Apr 2015 09:29:59 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Best search algorithm to find condition within a range References: <2e3a3c01-20b3-4948-9b32-bd80ed46822b@googlegroups.com> In-Reply-To: <2e3a3c01-20b3-4948-9b32-bd80ed46822b@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:f/YLReg7VdqLPb6+ZhCKy0UFshvqiFfjIGrg1Vr1wxKyp4C50My CLspekMPjfoZeGp8U5JYB5jnXxXTmyKLjGrNvxKfbYPv5ukFCffKz18U9HO7y4Muf7MynBb MIx+AjGeDfXWOD0VP8bVJocOCDBXPypFJUxlmzgf9tS15YYdFzC7tj0fie3qm4IoRLsNlm0 TTu9MbAPYDnWYFd1/QhdQ== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 103 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428413413 news.xs4all.nl 2823 [2001:888:2000:d::a6]:46070 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88575 On 04/07/2015 05:44 AM, jonas.thornvall@gmail.com wrote: > > > I want todo faster baseconversion for very big bases like base 1 000 000, so instead of adding up digits i search it. For this and most of the following statements: I can almost guess what you're trying to say. However, I cannot. No idea why you're adding up digits, that sounds like casting out nines. And in base-N, that would be casting out (N-1)'s. What's the it you're trying to search? How do you know the baseconversion is the bottleneck, if you haven't written any Python code yet? > > I need the fastest algorithm to find the relation to a decimal number. What relation would that be? Between what and what? > Digmult is an instance of base at a digitplace (base^x) what i try to find is the digit for the below condition is true and the loop break. > You haven't defined a class "Base" yet. In fact, I don't see any Python code in the whole message. > > ********************************* > for (digit=0;digit<=base;digit++) { > if((digit+1)*digmult>decNumber)break; > } > ********************************* > > So i am looking for the digit where following condition true. > > if((digit)*digmultdecNumber) then BREAK; You could try integer divide. That's just something like digit = decNumber // digmult But if you think hard enough you'd realize that > > One could start at half base searching, but then i Think i've read that using 1/3 closing in faster? > > I Think also i remember that if the search space so big that at least 22 or 23 guesses, needed.A random Oracle may even faster? > > Just pick up a number and get lucky, is it any truth to that? > > Below the actual algorithm. > > > > > If that code were in Python, I could be more motivated to critique it. The whole algorithm could be much simpler. But perhaps there is some limitation of javascript that's crippling the code. How would you do it if you were converting the base by hand? I certainly wouldn't be doing any trial and error. For each pass, I'd calculate quotient and remainder, where remainder is the digit, and quotient is the next value you work on. -- DaveA