Re: Not a python question, just programming logic trap?
Den torsdag 14 mars 2019 kl. 06:09:02 UTC+1 skrev Rick Johnson: > jonas.t...@gmail.com wrote: > > Nah i can't see the error is due to the "If clause" branching possibly it > > should been an elseif at instead of separate if. No there is something > > going wrong with the variables. > > Well, then you'd be wise to unpack those variables and inspect them. I've done that there is nothing wrong with them the error comes when writing out to the canvas, and i rounded them so it is integer pixels. To be honest i think there maybe something with the canvas that goes wrong. A block of fixed length can't expand. I run console.logg() barLength=xFrontStart-xBackEnd and it is constant at every call within if clause. It is just that when canvas write out the values apparently the draw rectangle function somehow hold other values. Well i restart the whole render programming, doing it right from start this time reading values from the record buffer and see if the animation problem magically dissapear. It could be something undefined affect the the variables. -- https://mail.python.org/mailman/listinfo/python-list
Not a python question, just programming logic trap?
Anyone who is good at see logic traps in programming? comp.lang.javascript is defunct so i try here. Using the metronome. https://midisequenser.000webhostapp.com I've tried to understand how following code can lead to that after the keyreleased the front of the keyed scrollbar raise/extend faster while the backend stay correct "in sync". One could think/imagine xFrontStart=scrollBarPos-FRONTOFFSET; somehow executed more then once after release, but how could it, the keyrelease is true only in that part of code and only done once??? var FRONTOFFSET=0; var xKeylength=0; var xFrontStart=0; var xBackEnd=0; var keyreleased=false; function pianoSCROLL(){ if(mess.data[0]==NOTE_ON && keyreleased==false){ xBackEnd=keylength; ctm.fillStyle = "magenta"; ctm.fillRect(xBackEnd,(PistartX+keyHeight*88)-(keyHeight*(mess.data[1]-8)), xFrontStart, keyHeight); if(FRONTOFFSET==0) {FRONTOFFSET=scrollBarPos;} xFrontStart=scrollBarPos-FRONTOFFSET; } else if(mess.data[0]==NOTE_OFF && keyreleased==false){ console.log("keyreleased!"); keyreleased=true; xBarLength=Math.round(xFrontStart-xBackEnd); ctm.fillStyle = "black"; ctm.fillRect(keylength, (PistartX+keyHeight*88)-(keyHeight*(mess.data[1]-8)), Mwidth, keyHeight+2); } if (keyreleased) { //console.log("timebar backend moving"); ctm.fillStyle = "black"; ctm.fillRect(keylength, (PistartX+keyHeight*88)-(keyHeight*(mess.data[1]-8)), Mwidth, keyHeight+2); ctm.fillStyle = "orange"; ctm.fillRect(xBackEnd,(PistartX+keyHeight*88)-(keyHeight*(mess.data[1]-8)),xFrontStart, keyHeight); xFrontStart=scrollBarPos-FRONTOFFSET; xBackEnd=Math.round(xFrontStart-xBarLength); console.log("xBackEnd="+xBackEnd+" xBarLength="+xBarLength+" xFrontStart="+xFrontStart); } } -- https://mail.python.org/mailman/listinfo/python-list
Output not defined
Can any web programmer tell me why output is not defined? I know this is python group but my code is so rudimentary that probably any sufficient good webprogrammer can figure it out, but i am lost."I've tried comp.lang.javascript" Problem is I've looked upon this for a week or two, and i just can't figure out why output is not defined. My hangup is probably because it works without problem when i run it in under windows XP browser, and that make me confused."I started program it in XP but now i want to transition into more modern browsers, Linux and windows 10" https://3d16zci4vuzyxt8hxvovrg-on.drv.tw/Website/midi.html Any help or even suggestion would be greatly appreciated. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den onsdag 13 juli 2016 kl. 12:05:03 UTC+2 skrev jonas.t...@gmail.com: > Den onsdag 13 juli 2016 kl. 04:29:48 UTC+2 skrev Steven D'Aprano: > > On Wed, 13 Jul 2016 03:35 am, jonas.thornv...@gmail.com wrote: > > > > > No it is only compressible down to a limit given by the algorithm. > > > > Right! Then there is data that you can't compress. > > > > Suppose you have some data: > > > > data = "ABABABABABAB...ABAB" > > > > And you compress it "down to a limit": > > > > x = compress(compress(compress(data))) > > print(x) > > => prints "@nx7%k!b" > > > > Now let's try again with something else: > > > > data = "AABBB..." > > > > And you compress it "down to a limit": > > > > x = compress(compress(compress(compress(data > > print(x) > > => prints "wu*$cS#k-pv32zx[&+r" > > > > > > One more time: > > > > data = "AABBAABBAABBAABBAABB" > > x = compress(data) > > print(x) > > => prints "g^x3@" > > > > > > We agree on this. Now you say, "Give me some random data, anything at all, > > and I'll compress it!", and I run a random number generator and out pops: > > > > data = "@nx7%k!b" > > > > or possibly: > > > > data = "wu*$cS#k-pv32zx[&+r" > > > > or: > > > > data = "g^x3@" > > > > > > and I say "Compress that!" > > > > But we've already agreed that this is as compressed as you can possibly make > > it. You can't compress it any more. > > > > So there's *at least some* random data that you can't compress. Surely you > > have to accept that. You don't get to say "Oh, I don't mean *that* data, I > > mean only data that I can compress". Random data means its random, you > > don't get to pick and choose between data you can compress and data that > > you can't. > > > > Now the tricky part is to realise that its not just short sequences of > > random data that can't be compressed. The same applies for LONG sequences > > to. If I give you a gigabyte of raw video, you can probably compress that a > > fair bit. That's what things like x264 encoders do. The x265 encoder is > > even better. But they're lossy, so you can't reverse them. > > > > But if I give you a gigabyte of random data, you'll be lucky to find *any* > > patterns or redundancies that allow compression. You might be able to > > shrink the file by a few KB. And if you take that already compressed file, > > and try to compress it again, well, you've already hit the limit of > > compression. There no more redundancy left to remove. > > > > It doesn't matter how clever you are, or what a "folding structure" is, or > > how many times you iterate over the data. It's a matter of absolute > > simplicity: the pigeonhole principle. You can't argue with the numbers. > > > > If you start with a 100 digit decimal number, there are 10**100 different > > pigeons. If you can compress down to a 6 digit decimal number, there are > > 10**6 pigeon holes. You cannot put 10*100 pigeons into 10**6 pigeon holes > > without doubling up (which makes your compression lossly). > > > > So either some numbers cannot be compressed, or some numbers are compressed > > to the same result, and you can't tell which was the original. That's your > > choice: a lossless encoder means some numbers can't be compressed, a lossy > > encoder means you can't reverse the process exactly. > > > > > > > > > > > > -- > > Steven > > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > > enough, things got worse. > > Ok, try to see it this way very big numbers can be described as the > sum or difference between a sequense of a few polynomials. Unfortunately we > lack the computational skill/computing power to find them. > > That is not the case using foldings/geometric series. The sum or difference of a few small polynomials would still of course be a polynomial. But as i say it is a case of enrich the interpretation of the symbolic set that you look at you replace digits bits/integers with arithmetic describing them. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den onsdag 13 juli 2016 kl. 04:29:48 UTC+2 skrev Steven D'Aprano: > On Wed, 13 Jul 2016 03:35 am, jonas.thornv...@gmail.com wrote: > > > No it is only compressible down to a limit given by the algorithm. > > Right! Then there is data that you can't compress. > > Suppose you have some data: > > data = "ABABABABABAB...ABAB" > > And you compress it "down to a limit": > > x = compress(compress(compress(data))) > print(x) > => prints "@nx7%k!b" > > Now let's try again with something else: > > data = "AABBB..." > > And you compress it "down to a limit": > > x = compress(compress(compress(compress(data > print(x) > => prints "wu*$cS#k-pv32zx[&+r" > > > One more time: > > data = "AABBAABBAABBAABBAABB" > x = compress(data) > print(x) > => prints "g^x3@" > > > We agree on this. Now you say, "Give me some random data, anything at all, > and I'll compress it!", and I run a random number generator and out pops: > > data = "@nx7%k!b" > > or possibly: > > data = "wu*$cS#k-pv32zx[&+r" > > or: > > data = "g^x3@" > > > and I say "Compress that!" > > But we've already agreed that this is as compressed as you can possibly make > it. You can't compress it any more. > > So there's *at least some* random data that you can't compress. Surely you > have to accept that. You don't get to say "Oh, I don't mean *that* data, I > mean only data that I can compress". Random data means its random, you > don't get to pick and choose between data you can compress and data that > you can't. > > Now the tricky part is to realise that its not just short sequences of > random data that can't be compressed. The same applies for LONG sequences > to. If I give you a gigabyte of raw video, you can probably compress that a > fair bit. That's what things like x264 encoders do. The x265 encoder is > even better. But they're lossy, so you can't reverse them. > > But if I give you a gigabyte of random data, you'll be lucky to find *any* > patterns or redundancies that allow compression. You might be able to > shrink the file by a few KB. And if you take that already compressed file, > and try to compress it again, well, you've already hit the limit of > compression. There no more redundancy left to remove. > > It doesn't matter how clever you are, or what a "folding structure" is, or > how many times you iterate over the data. It's a matter of absolute > simplicity: the pigeonhole principle. You can't argue with the numbers. > > If you start with a 100 digit decimal number, there are 10**100 different > pigeons. If you can compress down to a 6 digit decimal number, there are > 10**6 pigeon holes. You cannot put 10*100 pigeons into 10**6 pigeon holes > without doubling up (which makes your compression lossly). > > So either some numbers cannot be compressed, or some numbers are compressed > to the same result, and you can't tell which was the original. That's your > choice: a lossless encoder means some numbers can't be compressed, a lossy > encoder means you can't reverse the process exactly. > > > > > > -- > Steven > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. Ok, try to see it this way very big numbers can be described as the sum or difference between a sequense of a few polynomials. Unfortunately we lack the computational skill/computing power to find them. That is not the case using foldings/geometric series. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den onsdag 13 juli 2016 kl. 04:29:48 UTC+2 skrev Steven D'Aprano: > On Wed, 13 Jul 2016 03:35 am, jonas.thornv...@gmail.com wrote: > > > No it is only compressible down to a limit given by the algorithm. > > Right! Then there is data that you can't compress. > > Suppose you have some data: > > data = "ABABABABABAB...ABAB" > > And you compress it "down to a limit": > > x = compress(compress(compress(data))) > print(x) > => prints "@nx7%k!b" > > Now let's try again with something else: > > data = "AABBB..." > > And you compress it "down to a limit": > > x = compress(compress(compress(compress(data > print(x) > => prints "wu*$cS#k-pv32zx[&+r" > > > One more time: > > data = "AABBAABBAABBAABBAABB" > x = compress(data) > print(x) > => prints "g^x3@" > > > We agree on this. Now you say, "Give me some random data, anything at all, > and I'll compress it!", and I run a random number generator and out pops: > > data = "@nx7%k!b" > > or possibly: > > data = "wu*$cS#k-pv32zx[&+r" > > or: > > data = "g^x3@" > > > and I say "Compress that!" > > But we've already agreed that this is as compressed as you can possibly make > it. You can't compress it any more. > > So there's *at least some* random data that you can't compress. Surely you > have to accept that. You don't get to say "Oh, I don't mean *that* data, I > mean only data that I can compress". Random data means its random, you > don't get to pick and choose between data you can compress and data that > you can't. > > Now the tricky part is to realise that its not just short sequences of > random data that can't be compressed. The same applies for LONG sequences > to. If I give you a gigabyte of raw video, you can probably compress that a > fair bit. That's what things like x264 encoders do. The x265 encoder is > even better. But they're lossy, so you can't reverse them. > > But if I give you a gigabyte of random data, you'll be lucky to find *any* > patterns or redundancies that allow compression. You might be able to > shrink the file by a few KB. And if you take that already compressed file, > and try to compress it again, well, you've already hit the limit of > compression. There no more redundancy left to remove. > > It doesn't matter how clever you are, or what a "folding structure" is, or > how many times you iterate over the data. It's a matter of absolute > simplicity: the pigeonhole principle. You can't argue with the numbers. > > If you start with a 100 digit decimal number, there are 10**100 different > pigeons. If you can compress down to a 6 digit decimal number, there are > 10**6 pigeon holes. You cannot put 10*100 pigeons into 10**6 pigeon holes > without doubling up (which makes your compression lossly). > > So either some numbers cannot be compressed, or some numbers are compressed > to the same result, and you can't tell which was the original. That's your > choice: a lossless encoder means some numbers can't be compressed, a lossy > encoder means you can't reverse the process exactly. > > > > > > -- > Steven > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. It is not that the data is not compressible i just need more chunks or random data, it is the footprint of the algorithm that has a certain it is a structure afterall albeit richer in interpretation than the numerical field. You exchange size for computational complexity, but that may be true for any compression algorithm. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den onsdag 13 juli 2016 kl. 00:24:23 UTC+2 skrev Ian: > On Tue, Jul 12, 2016 at 11:35 AM,wrote: > > > > No it is only compressible down to a limit given by the algorithm. > > Then your algorithm does not compress random data as you claimed. > > For some input, determine the limiting output that it ultimately > compresses down to. Take that output and feed it through your > algorithm as if it were the original input. If the data are to be > considered random, then this input is just as probable as the > original. What output does the algorithm now create? If it just > returns the input unchanged, then how do you discern the original > input from this input when decompressing? If it returns a different > output of the same size, then repeat the process with the new output. > Now there are *two* outputs of that size that can't be repeated. There > are only finitely many possible outputs of that size, so eventually > you're going to have to get to one that either repeats an output -- in > which case your algorithm produces the same output for two different > inputs and is therefore incorrect -- or you will get to an input that > produces an output *larger* in size than the original. The later sounds reasonable that is start toggle between states. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den onsdag 13 juli 2016 kl. 00:24:23 UTC+2 skrev Ian: > On Tue, Jul 12, 2016 at 11:35 AM,wrote: > > > > No it is only compressible down to a limit given by the algorithm. > > Then your algorithm does not compress random data as you claimed. > > For some input, determine the limiting output that it ultimately > compresses down to. Take that output and feed it through your > algorithm as if it were the original input. If the data are to be > considered random, then this input is just as probable as the > original. What output does the algorithm now create? If it just > returns the input unchanged, then how do you discern the original > input from this input when decompressing? If it returns a different > output of the same size, then repeat the process with the new output. > Now there are *two* outputs of that size that can't be repeated. There > are only finitely many possible outputs of that size, so eventually > you're going to have to get to one that either repeats an output -- in > which case your algorithm produces the same output for two different > inputs and is therefore incorrect -- or you will get to an input that > produces an output *larger* in size than the original. The dataset must have a certain size that is the only requirment, of course you can not compress something into nothing, at least the arithmetic ruleset need to be encoded but what would be the point to just compress something less than a couple of bytes. And of course the number of rounds you applied the algorithm must be stored. But that is no problem for small datasets. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den tisdag 12 juli 2016 kl. 21:40:36 UTC+2 skrev jonas.t...@gmail.com: > Den tisdag 12 juli 2016 kl. 20:20:52 UTC+2 skrev Michael Torrie: > > On 07/12/2016 11:46 AM, jonas.thornv...@gmail.com wrote: > > > Well the algorithm start with looking up a suitable folding structure > > > "close enough to the number", then it works down the folding > > > structure finding the fold where the difference or sum between the > > > folds closest to zero. > > > > > > You do the same prinicple with the remainder until zero is achieved. > > > > > > So our first fold can either be bigger or smaller, and it seek a > > > configuration for the fold that close in max on the actual random > > > number. The second fold could be a fold that depending upon our first > > > fold was bigger or smaller than number either will add or subtract > > > lower layers of the fold. > > > > > > There will come out a difference that need to be folded, the process > > > is repeated until there is nothing to fold. > > > > > > It is basicly a search algorithm looking for suitable folding > > > structures. > > > > Better patent it quickly then. And you will win a noble prize for math > > if you could do what you say you could. > > I must stress when i say number here i really mean +10 decimal digit. So > i basicly search in on big numbers that i compress. So i divide the dataset > into suitable sizes for compression. And the dataset chunks that comes out from the process can also be treated like a new datafile, so the compression is iterative down to a limit. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den tisdag 12 juli 2016 kl. 20:20:52 UTC+2 skrev Michael Torrie: > On 07/12/2016 11:46 AM, jonas.thornv...@gmail.com wrote: > > Well the algorithm start with looking up a suitable folding structure > > "close enough to the number", then it works down the folding > > structure finding the fold where the difference or sum between the > > folds closest to zero. > > > > You do the same prinicple with the remainder until zero is achieved. > > > > So our first fold can either be bigger or smaller, and it seek a > > configuration for the fold that close in max on the actual random > > number. The second fold could be a fold that depending upon our first > > fold was bigger or smaller than number either will add or subtract > > lower layers of the fold. > > > > There will come out a difference that need to be folded, the process > > is repeated until there is nothing to fold. > > > > It is basicly a search algorithm looking for suitable folding > > structures. > > Better patent it quickly then. And you will win a noble prize for math > if you could do what you say you could. I must stress when i say number here i really mean +10 decimal digit. So i basicly search in on big numbers that i compress. So i divide the dataset into suitable sizes for compression. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den tisdag 12 juli 2016 kl. 20:20:52 UTC+2 skrev Michael Torrie: > On 07/12/2016 11:46 AM, jonas.thornv...@gmail.com wrote: > > Well the algorithm start with looking up a suitable folding structure > > "close enough to the number", then it works down the folding > > structure finding the fold where the difference or sum between the > > folds closest to zero. > > > > You do the same prinicple with the remainder until zero is achieved. > > > > So our first fold can either be bigger or smaller, and it seek a > > configuration for the fold that close in max on the actual random > > number. The second fold could be a fold that depending upon our first > > fold was bigger or smaller than number either will add or subtract > > lower layers of the fold. > > > > There will come out a difference that need to be folded, the process > > is repeated until there is nothing to fold. > > > > It is basicly a search algorithm looking for suitable folding > > structures. > > Better patent it quickly then. And you will win a noble prize for math > if you could do what you say you could. I doubt it i never got anyone before for my ideas. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den tisdag 12 juli 2016 kl. 17:19:54 UTC+2 skrev Steven D'Aprano: > On Wed, 13 Jul 2016 12:29 am, jonas.thornv...@gmail.com wrote: > > > Den tisdag 12 juli 2016 kl. 05:01:20 UTC+2 skrev Lawrence D’Oliveiro: > >> On Tuesday, July 12, 2016 at 5:52:27 AM UTC+12, jonas.t...@gmail.com > >> wrote: > >> > >> > What kind of statistic law or mathematical conjecture or is it even a > >> > physical law is violated by compression of random binary data? > >> > >> Try compressing already-compressed data. > >> > >> Does that answer your question? > > > > Yes that is my question, and also a claim i can do it. > > Can you also make a perpetual motion machine, square the circle, and find an > exact rational fraction equal to pi? > > > What gets me is the people who *say* that they can compress already > compressed data. We know they can't, because if they could, they could > compress it again and again and again and again until there was only a > single bit, AND STILL REVERSE IT, using no external storage. Your lookup > tables are part of the compressed data. If the "compressed file" plus the > lookup table is bigger than the original file, then you haven't really > compressed anything. You've just moved some of it from the file into a > lookup table. > > So why do people claim that they can compress already compressed data? Who > are they fooling? Themselves? > > > > -- > Steve Well the algorithm start with looking up a suitable folding structure "close enough to the number", then it works down the folding structure finding the fold where the difference or sum between the folds closest to zero. You do the same prinicple with the remainder until zero is achieved. So our first fold can either be bigger or smaller, and it seek a configuration for the fold that close in max on the actual random number. The second fold could be a fold that depending upon our first fold was bigger or smaller than number either will add or subtract lower layers of the fold. There will come out a difference that need to be folded, the process is repeated until there is nothing to fold. It is basicly a search algorithm looking for suitable folding structures. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den tisdag 12 juli 2016 kl. 17:12:01 UTC+2 skrev Steven D'Aprano: > On Wed, 13 Jul 2016 12:24 am, jonas.thornv...@gmail.com wrote: > > > Den måndag 11 juli 2016 kl. 20:38:51 UTC+2 skrev Steven D'Aprano: > >> On Tue, 12 Jul 2016 03:52 am, jonas.thornv...@gmail.com wrote: > >> > >> > What kind of statistic law or mathematical conjecture or is it even a > >> > physical law is violated by compression of random binary data? > >> > >> The pigeon hole principle. If you have 100 pigeon holes, and 101 pigeons, > >> then clearly at least one pigeon hole must have two pigeons in it. > [...] > > But it seem your reasoning is based upon interpretation of the actual > > digits, bits and bytes value. > > Not at all. If you think that, you've misread my example. There's no > interpretation of the bytes: they are just 8-bit numbers from 0 to 255. You > cannot losslessly compress all 256 of them to just four 2-bit numbers. > > > > There could be different interpretation > > worlds of course you would have to chose one using digits, An > > interpretationworld here could be reading out different word lengths of > > the dataset and maybe a lookup table. > > Any lookup table you have counts as part of the compressed data. > > > > But it could also be arithmetic rules that magically recreate a number > > from a number of folds or difference of folds. > > Oh, sure, if you believe in magic, anything is possible. Just close your > eyes, click your heels together, and wish really, really hard. > > Suppose I could compress ANY random data, no matter what, down to 10% of the > original size. Okay, let's start with a million bits of data. Compress it > down to 100,000 bits. > > But I believe that I can compress *anything*, any random collection of data. > Okay, let me compress it again. Now I have 10,000 bits. > > Compress it again. Now I have 1,000 bits. > > Compress it again. Now I have 100 bits. > > Compress it again. Now I have 10 bits. > > Compress it again. Now I have 1 bit, either a 0 or a 1. > > > Can you not see how absurd this is? I have claimed that I can take *any* > random set of data, and by compressing it again and again and again, > compress it down to ONE BIT, either a 0 or a 1, WITHOUT LOSS. Somehow I > have to take that 0 bit and uncompress it back to the Complete Works Of > William Shakespeare, and *also* uncompress it back to the recent Deadpool > movie, AND uncompress it back to last year's Ant Man movie, AND uncompress > it back to some funny picture of a cat. > > How can I possibly know which of the billions and billions of different > files this 0 bit represents? > > If you pass me a 0 bit, and say "uncompress this", and I get The Lord Of The > Rings novels, and then you pass me another 0 bit, and I uncompress it and > get The Hobbit, well, how did I tell the two bits apart? They're both zero. > > > > The alternative is to say, it doesn't matter how clever you are, you can't > compress *everything*. There are some things that simply won't compress. > Eventually you get something no longer compresses. If you could compress > EVERYTHING, then you could compress the compressed data, and compress the > compressed-compressed data, and so on, until you've got only a single bit. > And that is ridiculous. > > > > -- > Steven > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. No it is only compressible down to a limit given by the algorithm. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den tisdag 12 juli 2016 kl. 05:01:20 UTC+2 skrev Lawrence D’Oliveiro: > On Tuesday, July 12, 2016 at 5:52:27 AM UTC+12, jonas.t...@gmail.com wrote: > > > What kind of statistic law or mathematical conjecture or is it even a > > physical law is violated by compression of random binary data? > > Try compressing already-compressed data. > > Does that answer your question? Yes that is my question, and also a claim i can do it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den måndag 11 juli 2016 kl. 20:38:51 UTC+2 skrev Steven D'Aprano: > On Tue, 12 Jul 2016 03:52 am, jonas.thornv...@gmail.com wrote: > > > What kind of statistic law or mathematical conjecture or is it even a > > physical law is violated by compression of random binary data? > > The pigeon hole principle. If you have 100 pigeon holes, and 101 pigeons, > then clearly at least one pigeon hole must have two pigeons in it. > > To keep the numbers small and manageable, let's say we are going to compress > one byte at a time. Now a byte has eight bits, so there are exactly 256 > possible bytes: > > > 0001 > 0010 > ... > 1110 > > > Now, suppose I claim that I can LOSSLESSLY (that is, reversibly) compress > any random byte to just two bits. The lossless part is important: its not > hard to compress random data by irreversibly throwing some of it away, and > there's no violation there. > > So I claim that you can give me any random byte, I will compress it to just > two bits: > > 00 > 01 > 10 > 11 > > and then be able to decompress it back again to give you the original byte > once more. > > Obviously I'm trying to pull a fast one! There's no way I can do this. I can > squeeze 256 pigeons into just four pigeon holes, but only by doubling them > up. Suppose I compress these three bytes to 00: > > > 0110 1001 > 1100 0110 > > Now when I go to uncompress 00, what should I return? There is no way for me > to know which of the three was the original value. > > (If I'm cunning, I'll have sneakily stored some data *elsewhere*, say, in > the file name, or in a database, so that you need this extra hidden data to > uncompress the 00 back to a full byte. But then I'm not compressing eight > bits down to two. I'm compressing eight bits down to two bits plus > who-knows-how-many-bits of hidden data.) > > So the pigeon hole principle tells us one of two things: > > (1) If you compress random data, then it must be lossy; I can compress eight > bits to two, but then I can't uncompress it back again, at least not > without throwing away some data. > > (2) Or, if the compression is lossless, then some data must be expanded > rather than compressed. If you pick data at random, some of it will be > expanded. > > Suppose I have a compression algorithm that infallibly and reversibly > compresses as follows: > > <--> 00 > 0001 <--> 01 > 0010 <--> 10 > 0011 <--> 11 > > That part is fine. But what will my algorithm do with the other 252 bytes? > At *best* it will leave them untouched: > > 0100 <--> 0100 > ... > <--> > > which is no compression at all, but at worst it will actually expand them > and make them bigger. (After all, it's likely that my compression format > has at least a bit of overhead.) > > In practice, compression algorithms are designed to look for particular > kinds of order or structure in the data, and compress that. That's fine for > the sorts of non-random data we care about: pictures are rarely pictures of > static, text files are rarely random collections of bits. But if you do > throw a random set of bits at a lossless compression algorithm, it will at > best not compress it at all, and at worst actually make the file bigger. > > > > What is to say that you can not do it if the symbolic representation is > > richer than the symbolic represenatation of the dataset. > > > > Isn't it a fact that the set of squareroots actually depict numbers in a > > shorter way than their actual representation. > > Sure. But you need to know what √2 means. It *represents* the number > 1.41421356237... but doesn't compress it. There's nothing you can do to the > symbol √2 that will uncompress back to the infinite series of digits. All > you can do is look it up somewhere to see what the digits are. > > > Now the inpretator or program must know the rules. And i have very good > > rules to make it happen. > > Right. How much information is in the rules? More than you save with > the "compression". Consider: > > 1.41421356237 compressed down to √2, that's 13 characters down to 2. Great! > But to *uncompress*, you need to store a rule: > > √2=1.41421356237 > > and that's *sixteen* characters. So your "compression" is: > > original: 13 > compressed to: 2 > plus rule: 16 > > means you have "compressed" 13 characters to 18. > > Now, this is still worth doing if you need to repeat the √2 many times, so > long as you don't have to repeat the rule. That's useful. But it's not > compression. It's more like keeping an index to a database, or a scrap of > paper with the title of a book written on it: > > "See Lord Of The Rings, by J.R.R. Tolkien" > > That's a lot smaller than the actual book: eight words, instead of who knows > how many tens of thousands. But you can't call it compression: you can't > sit down with the scrap of paper *and nothing else* and uncompress it back > to the entire LOTR trilogy. > > > >
Re: Compression of random binary data
Den måndag 11 juli 2016 kl. 20:24:37 UTC+2 skrev jonas.t...@gmail.com: > Den måndag 11 juli 2016 kl. 20:09:39 UTC+2 skrev Waffle: > > On 11 July 2016 at 20:52,wrote: > > > What kind of statistic law or mathematical conjecture or is it even a > > > physical law is violated by compression of random binary data? > > > > > > I only know that Shanon theorised it could not be done, but were there > > > any proof? > > > > Compression relies on some items in the dataset being more frequent > > than others, if you have some dataset that is completely random it > > would be hard to compress as most items have very similar number of > > occurrances. > > > > > What is to say that you can not do it if the symbolic representation is > > > richer than the symbolic represenatation of the dataset. > > > > > > Isn't it a fact that the set of squareroots actually depict numbers in a > > > shorter way than their actual representation. > > > > A square root may be smaller numerically than a number but it > > definitely is not smaller in terms of entropy. > > > > lets try to compress the number 2 for instance using square roots. > > sqrt(2) = 1.4142 > > the square root actually takes more space in this case even tho it is > > a smaller number. so having the square root would have negative > > compression in this case. > > with some rounding back and forth we can probably get around the fact > > that sqrt(2) would take an infinite amout of memory to accurately > > represent but that neccesarily means restricting the values we are > > possible of encoding. > > > > for sqrt(2) to not have worse space consumprion than the number 2 > > itself we basically have to trow away precision so sqrt(2) ~= 1 > > now i challenge you to get that 2 back out of that 1.. > > Well who it to say different kind of numbers isn't treated differently, i > mean all numbers isn't squares. All numbers isn't naturals. But it could be all numbers are foldable. Both the integer parts and the real parts.And be expressed by the folding differences. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
Den måndag 11 juli 2016 kl. 20:09:39 UTC+2 skrev Waffle: > On 11 July 2016 at 20:52,wrote: > > What kind of statistic law or mathematical conjecture or is it even a > > physical law is violated by compression of random binary data? > > > > I only know that Shanon theorised it could not be done, but were there any > > proof? > > Compression relies on some items in the dataset being more frequent > than others, if you have some dataset that is completely random it > would be hard to compress as most items have very similar number of > occurrances. > > > What is to say that you can not do it if the symbolic representation is > > richer than the symbolic represenatation of the dataset. > > > > Isn't it a fact that the set of squareroots actually depict numbers in a > > shorter way than their actual representation. > > A square root may be smaller numerically than a number but it > definitely is not smaller in terms of entropy. > > lets try to compress the number 2 for instance using square roots. > sqrt(2) = 1.4142 > the square root actually takes more space in this case even tho it is > a smaller number. so having the square root would have negative > compression in this case. > with some rounding back and forth we can probably get around the fact > that sqrt(2) would take an infinite amout of memory to accurately > represent but that neccesarily means restricting the values we are > possible of encoding. > > for sqrt(2) to not have worse space consumprion than the number 2 > itself we basically have to trow away precision so sqrt(2) ~= 1 > now i challenge you to get that 2 back out of that 1.. Well who it to say different kind of numbers isn't treated differently, i mean all numbers isn't squares. All numbers isn't naturals. -- https://mail.python.org/mailman/listinfo/python-list
Compression of random binary data
What kind of statistic law or mathematical conjecture or is it even a physical law is violated by compression of random binary data? I only know that Shanon theorised it could not be done, but were there any proof? What is to say that you can not do it if the symbolic representation is richer than the symbolic represenatation of the dataset. Isn't it a fact that the set of squareroots actually depict numbers in a shorter way than their actual representation. Now the inpretator or program must know the rules. And i have very good rules to make it happen. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compact connected regular graphs
Den söndag 6 mars 2016 kl. 12:01:02 UTC+1 skrev Mark Lawrence: > On 06/03/2016 10:39, jonas.thornv...@gmail.com wrote: > > How come all graphs using 42 links and more then 84 nodes have compact > > regular connected solutions? > > > > Did turn off animation for more than a couple of thousands of links so the > > animation is off when searching but script give message and numerical > > results on search. > > > > http://jt.node365.se/nodes15.html > > > > Do anyone know? > > > > > > http://jt.node365.se/Compact.rtf > > > > Where is the Python question here? > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence It is the Python that squeeze the information out of the graphs. -- https://mail.python.org/mailman/listinfo/python-list
Compact connected regular graphs
How come all graphs using 42 links and more then 84 nodes have compact regular connected solutions? Did turn off animation for more than a couple of thousands of links so the animation is off when searching but script give message and numerical results on search. http://jt.node365.se/nodes15.html Do anyone know? http://jt.node365.se/Compact.rtf -- https://mail.python.org/mailman/listinfo/python-list
Re: Condition fullfilled to early but only "sometimes"
Den tisdag 1 mars 2016 kl. 08:49:57 UTC+1 skrev Ian: > It's not at all clear what the problem is from your description. What > is it that you expect the code to do? What is it doing instead that > violates your expectation? Why are you asking for Javascript help on a > Python mailing list? > > On Mon, Feb 29, 2016 at 10:40 PM,wrote: > > I've been looking at the code for two days so i am a bit crosseyed. > > If anyone could help me set the condition so the loop catch the last > > pair/pairs, it is kind of weird that it succeed sometimes and break to > > early and report fail others. > > > > I would be very greatful if anyone can see why it break to early and return > > fail. Although it is clearly a succes looking at the last remaining pair > > none connected pair.It should report fail for the network permutations that > > stall due to link exhausting, but not stall creating last pair. > > > > It just a minor bug due to some condition that i just not get. > > Have a go 5 munutes maybe someone catch the faulthy condition. > > > > http://jt.node365.se/mydebug1.html > > -- > > https://mail.python.org/mailman/listinfo/python-list Here is a script to draw networks, drag and drop nodes. So the function will go here, right now only node deep one work. http://jt.node365.se/nodes11.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Condition fullfilled to early but only "sometimes"
Den tisdag 1 mars 2016 kl. 08:49:57 UTC+1 skrev Ian: > It's not at all clear what the problem is from your description. What > is it that you expect the code to do? What is it doing instead that > violates your expectation? Why are you asking for Javascript help on a > Python mailing list? > > On Mon, Feb 29, 2016 at 10:40 PM,wrote: > > I've been looking at the code for two days so i am a bit crosseyed. > > If anyone could help me set the condition so the loop catch the last > > pair/pairs, it is kind of weird that it succeed sometimes and break to > > early and report fail others. > > > > I would be very greatful if anyone can see why it break to early and return > > fail. Although it is clearly a succes looking at the last remaining pair > > none connected pair.It should report fail for the network permutations that > > stall due to link exhausting, but not stall creating last pair. > > > > It just a minor bug due to some condition that i just not get. > > Have a go 5 munutes maybe someone catch the faulthy condition. > > > > http://jt.node365.se/mydebug1.html > > -- > > https://mail.python.org/mailman/listinfo/python-list Here is example output and as you can see there is no reason to not create the last pair, the link is not a copy it should be created but condition somehow wrong *sometimes*. Hurray failed generate network ***not quite if single pair two nodes missing 0'st NODE Links-> 7,3,5 1'st NODE Links-> 4,6,3 2'st NODE Links-> 5,9,3 3'st NODE Links-> 0,1,2 4'st NODE Links-> 1,8,5 5'st NODE Links-> 0,2,4 6'st NODE Links-> 1,7,9 7'st NODE Links-> 0,6,8 8'st NODE Links-> 4,7 9'st NODE Links-> 2,6 -- https://mail.python.org/mailman/listinfo/python-list
Re: Condition fullfilled to early but only "sometimes"
Den tisdag 1 mars 2016 kl. 08:49:57 UTC+1 skrev Ian: > It's not at all clear what the problem is from your description. What > is it that you expect the code to do? What is it doing instead that > violates your expectation? Why are you asking for Javascript help on a > Python mailing list? > > On Mon, Feb 29, 2016 at 10:40 PM,wrote: > > I've been looking at the code for two days so i am a bit crosseyed. > > If anyone could help me set the condition so the loop catch the last > > pair/pairs, it is kind of weird that it succeed sometimes and break to > > early and report fail others. > > > > I would be very greatful if anyone can see why it break to early and return > > fail. Although it is clearly a succes looking at the last remaining pair > > none connected pair.It should report fail for the network permutations that > > stall due to link exhausting, but not stall creating last pair. > > > > It just a minor bug due to some condition that i just not get. > > Have a go 5 munutes maybe someone catch the faulthy condition. > > > > http://jt.node365.se/mydebug1.html > > -- > > https://mail.python.org/mailman/listinfo/python-list The program creates search for uniform networks, that is x nodes each with y links. Only a subset of permutations possible "easiest found out with pen and paper". So to the left is the node and to the right the nodes it links to. When you run new network, sometimes it is full every node have x links, you create a uniform network. But often ir reports fail the links was exhausted and you stuck into a loop, that i fortunatily have the conditions to break. But it *sometimes* break to early when there is still one or two pairs that would had worked. Not it is easy to make a fix for those, but it certainly would be more beautiful setting the correct condition. function createLinks() { var i = 0; var j = 0; while(i < nodes) { // This see so that links already generated accounted for if one link than j j = arr[i].nodelinks.length; stupid = nodes - 1; temparr = new Array(); while(j < links) { dublett = false; // Onlygenerate random values bigger than "i" else all links exhausted if(i == 0) { aLink = Math.floor(Math.random() * (nodes - 1)); aLink ++ ; } else { aLink = Math.floor(Math.random() * (stupid - i)) + i + 1; } if (aLink == nodes)aLink -- ; if (temparr[0] == null) { temparr[0] = aLink; } for(k = 0; k < arr[i].nodelinks.length; k ++ ) { if(aLink == arr[i].nodelinks[k]) { dublett = true; } } inmylist = false; var t = 0; for(var m = 0; m < temparr.length; m ++ ) { if(temparr[m] == aLink) { inmylist = true; } } if (inmylist == false) { temparr[temparr.length] = aLink; } else { inmylist = false } scope = (nodes - 1) - i; if (temparr.length >= scope) { myboolean = false; return myboolean; } if(dublett == false && arr[aLink].nroflinks < links) { arr[i].nodelinks[arr[i].nodelinks.length] = aLink; arr[aLink].nodelinks[arr[aLink].nodelinks.length] = i; arr[i].nroflinks ++ ; arr[aLink].nroflinks ++ ; j ++ ; } } i ++ ; } myboolean = true; return myboolean; } -- https://mail.python.org/mailman/listinfo/python-list
Condition fullfilled to early but only "sometimes"
I've been looking at the code for two days so i am a bit crosseyed. If anyone could help me set the condition so the loop catch the last pair/pairs, it is kind of weird that it succeed sometimes and break to early and report fail others. I would be very greatful if anyone can see why it break to early and return fail. Although it is clearly a succes looking at the last remaining pair none connected pair.It should report fail for the network permutations that stall due to link exhausting, but not stall creating last pair. It just a minor bug due to some condition that i just not get. Have a go 5 munutes maybe someone catch the faulthy condition. http://jt.node365.se/mydebug1.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Loop awareness
Den måndag 29 februari 2016 kl. 21:32:51 UTC+1 skrev Ian: > On Mon, Feb 29, 2016 at 1:07 PM,wrote: > > This program creates a uniform linktree of x nodes, and it knows when it > > get stuck in a loop generating random values. > > > > Because the networks random generated, only a subset of the permutations > > will generate a uniform network most get stuck in loops generating random > > values. But the program keep track the exhausted links and knows when no > > uniform network possible. > > > > Is this related to the halting problem? > > > > http://jt.node365.se/mydebug1.html > > No, the halting problem is that you can't algorithmically determine > whether an *arbitrary* program given *arbitrary* input will ever halt. > When you narrow down the scope of the problem considerably, as you've > done here, then it's no longer necessarily undecidable. Here i told it to only report the unfiorm subset of working networks. http://jt.node365.se/mydebug2.html -- https://mail.python.org/mailman/listinfo/python-list
Loop awareness
This program creates a uniform linktree of x nodes, and it knows when it get stuck in a loop generating random values. Because the networks random generated, only a subset of the permutations will generate a uniform network most get stuck in loops generating random values. But the program keep track the exhausted links and knows when no uniform network possible. Is this related to the halting problem? http://jt.node365.se/mydebug1.html -- https://mail.python.org/mailman/listinfo/python-list
Re: General computer language, syntax question.
Den måndag 29 februari 2016 kl. 14:57:04 UTC+1 skrev jonas.t...@gmail.com: > Den måndag 29 februari 2016 kl. 14:45:37 UTC+1 skrev jonas.t...@gmail.com: > > I have a problem programming uniform networks, "x nodes with y links" that > > turn out to be really hairy to solve for me and i feel i really lack the > > programming features > > > > "Actually i program in javascript" but the problem seem general for all > > programming languages including Pyhton. > > > > For a beautiful solution it would require "If in list/array return boolean" > > "If not in list/array return boolean". > > > > But there is no such feature Python nor Javascript, so instead i set > > boolean value "inlist" to false and loop thru, to see if it is already in > > list. If not it is added to list. > > > > So if the current node i generate links for is x and i try to generate a > > link to node z, and z's links exhausted i will add it to exhausted list. > > > > And if there is node-x exhausted entries in list, well then script should > > break because it will lock into a cycle. The cyclic lockup is due to only a > > subset of the networks on the form (links*deep)+1=nodes is possible. > > > > So what i need is to know howto write "if list/array ***empty*** do > > {something}" > > > > I sure know howto check if an array have 1 element 2,3,4 but how do you > > check for empty. > > > > I think it is crazy that you can not do general comparissons of the type > > If in list/array > > If not in list/array > > > > But it is even more crazy that you can not check if list/array is empty, > > that is just madness. > > I mean for for example Javascript > if (typeof array[index] !== 'undefined' && array[index] !== null) { > or this one > if (array[index] != null) { > > I mean how do they come up with such convoluted syntax, do they pull it out > of ass? Well one can always say it is needed because undefined not equal to > null. > > But would not if (array[index]==empty) suffice and be alot clearer? Sorry but would not if (array==empty) suffice and be alot clearer? -- https://mail.python.org/mailman/listinfo/python-list
Re: General computer language, syntax question.
Den måndag 29 februari 2016 kl. 14:45:37 UTC+1 skrev jonas.t...@gmail.com: > I have a problem programming uniform networks, "x nodes with y links" that > turn out to be really hairy to solve for me and i feel i really lack the > programming features > > "Actually i program in javascript" but the problem seem general for all > programming languages including Pyhton. > > For a beautiful solution it would require "If in list/array return boolean" > "If not in list/array return boolean". > > But there is no such feature Python nor Javascript, so instead i set boolean > value "inlist" to false and loop thru, to see if it is already in list. If > not it is added to list. > > So if the current node i generate links for is x and i try to generate a link > to node z, and z's links exhausted i will add it to exhausted list. > > And if there is node-x exhausted entries in list, well then script should > break because it will lock into a cycle. The cyclic lockup is due to only a > subset of the networks on the form (links*deep)+1=nodes is possible. > > So what i need is to know howto write "if list/array ***empty*** do > {something}" > > I sure know howto check if an array have 1 element 2,3,4 but how do you check > for empty. > > I think it is crazy that you can not do general comparissons of the type > If in list/array > If not in list/array > > But it is even more crazy that you can not check if list/array is empty, that > is just madness. I mean for for example Javascript if (typeof array[index] !== 'undefined' && array[index] !== null) { or this one if (array[index] != null) { I mean how do they come up with such convoluted syntax, do they pull it out of ass? Well one can always say it is needed because undefined not equal to null. But would not if (array[index]==empty) suffice and be alot clearer? -- https://mail.python.org/mailman/listinfo/python-list
General computer language, syntax question.
I have a problem programming uniform networks, "x nodes with y links" that turn out to be really hairy to solve for me and i feel i really lack the programming features "Actually i program in javascript" but the problem seem general for all programming languages including Pyhton. For a beautiful solution it would require "If in list/array return boolean" "If not in list/array return boolean". But there is no such feature Python nor Javascript, so instead i set boolean value "inlist" to false and loop thru, to see if it is already in list. If not it is added to list. So if the current node i generate links for is x and i try to generate a link to node z, and z's links exhausted i will add it to exhausted list. And if there is node-x exhausted entries in list, well then script should break because it will lock into a cycle. The cyclic lockup is due to only a subset of the networks on the form (links*deep)+1=nodes is possible. So what i need is to know howto write "if list/array ***empty*** do {something}" I sure know howto check if an array have 1 element 2,3,4 but how do you check for empty. I think it is crazy that you can not do general comparissons of the type If in list/array If not in list/array But it is even more crazy that you can not check if list/array is empty, that is just madness. -- https://mail.python.org/mailman/listinfo/python-list
Primality sieve challenge
Maybe we could have a challenge finding the base with best reducion factor upto base 100 00? One probably do not want to store more vectors than that in memory, and i guess Reducing composites in the integer field http://jt.node365.se/composite.html I've made my own kind of primality sieve that work by reducing lthe number field into composite "legs" and prime "egs". The legs that contain just composites in the numberfield will be thrown away sieved? I asked the people at sci.math if there was a known upper limit for the reduction using this type of counters in the integer field, they said no. I wonder if there is a name for this type of sieve/counter within information theory? My idea is to find a base with very high percentage of composite legs, remove all start numbers that produce only composites in their legs, and then store the other egs that contain prime in an array. That array will than serve the purpose modelling the new integer field, using the searched base with highest composite reduction. The script seaching the bases take a few seconds, so there could be alot of improvements. I have a feeling that using bignumb bases as sieves will be out of range for us mere mortals, but who knows maybe for computer theorists. -- https://mail.python.org/mailman/listinfo/python-list
Re: Primality sieve challenge
Den söndag 17 januari 2016 kl. 10:44:47 UTC+1 skrev jonas.t...@gmail.com: > Maybe we could have a challenge finding the base with best reducion factor > upto base 100 00? One probably do not want to store more vectors than > that in memory, and i guess > > Reducing composites in the integer field > http://jt.node365.se/composite.html > > > I've made my own kind of primality sieve that work by reducing lthe number > field into composite "legs" and prime "egs". The legs that contain just > composites in the numberfield will be thrown away sieved? > > I asked the people at sci.math if there was a known upper limit for the > reduction using this type of counters in the integer field, they said no. > > I wonder if there is a name for this type of sieve/counter within information > theory? > > My idea is to find a base with very high percentage of composite legs, remove > all start numbers that produce only composites in their legs, and then store > the other egs that contain prime in an array. > > That array will than serve the purpose modelling the new integer field, using > the searched base with highest composite reduction. > > > The script seaching the bases take a few seconds, so there could be alot of > improvements. I have a feeling that using bignumb bases as sieves will be out > of range for us mere mortals, but who knows maybe for computer theorists. At least i am impressed how well it reduce the composite integer field but of course you need a big array... The math guys said just construct the base using the primes 2*3*5*7*11*13*17... and so on. NEWBASE = 510510 -- BASE= 510510 Composite legs= 92.91551585669234% === One could say it is a bit clumsy but i think it is neat be able to peel of numbers that do not even need to be considered for primality test. -- https://mail.python.org/mailman/listinfo/python-list
Keen eyes
This is not python just a short snippet of javascript that refuse tracing, i've staired blind upon it but since it does something weird with allocating memory i have no idea what is going on and the parrots and monkeys at comp.lang.javascript refuse to give a hint. Something in those loops really wrong but it is no giant numbers. function factor_it(i){ prime=true; sqroot=Math.floor(Math.sqrt(i)); for (j=2;j
Re: Keen eyes
Den lördag 16 januari 2016 kl. 23:30:48 UTC+1 skrev Chris Angelico: > On Sun, Jan 17, 2016 at 9:23 AM,wrote: > > function factor_it(i){ > > prime=true; > > sqroot=Math.floor(Math.sqrt(i)); > > for (j=2;j > {return prime}} > > return prime; > > } > > A couple of potential problems here. The first thing that comes to > mind is that floating point inaccuracy is going to bite you long > before the numbers "seem huge" to someone who's thinking about 2**53. > The second is an off-by-one error: a perfect square may come up as > prime. > > Check for those and see how it looks. > > Also, check your double-use of the 'prime' variable, which also > appears to be global here. > > ChrisA Thank you Chris, this is not really for factoring it is meant to create a composite sieve. Well all the legs just holding composites will be false. Regarding the problem no number bigger than 100 is sent to the function, there is something weird with either the loop structure or the break. What should happen... j=1 i=j 1+10 break (because prime in leg) j++; well j is 2 and so is i 2+10,2+20,2+30,2+40.2+50,2+60,2+70,2+80,2+90 ((condidion break loop i>100 j++ ->i=3 3+10 break (because prime in leg) j++ And so on... And as you can see the outer loop does this until j reaches ***base which is 10***. In all it is about 50 operations So how can it allocate all memory? -- https://mail.python.org/mailman/listinfo/python-list
Re: Keen eyes
Den lördag 16 januari 2016 kl. 23:30:48 UTC+1 skrev Chris Angelico: > On Sun, Jan 17, 2016 at 9:23 AM,wrote: > > function factor_it(i){ > > prime=true; > > sqroot=Math.floor(Math.sqrt(i)); > > for (j=2;j > {return prime}} > > return prime; > > } > > A couple of potential problems here. The first thing that comes to > mind is that floating point inaccuracy is going to bite you long > before the numbers "seem huge" to someone who's thinking about 2**53. > The second is an off-by-one error: a perfect square may come up as > prime. > > Check for those and see how it looks. > > Also, check your double-use of the 'prime' variable, which also > appears to be global here. > > ChrisA Thank you Chris your comment resolved it double use of j in two different functions and loops. -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 02:09:17 UTC+2 skrev Ben Bacarisse: Ian Kelly ian.g.ke...@gmail.com writes: On Mon, Jun 29, 2015 at 4:56 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Jun 29, 2015 at 4:39 PM, jonas.thornv...@gmail.com wrote: http://jt.node365.se/baseconversion8.html snip By the way, I think you have a bug. I did my time testing by concatenating the default input number to itself several times. At 5184 decimal digits, which was the last case I tried, the 58th output digit was 111, after which point the remaining 672 output digits are all 12665464, which seemed rather improbable. Yes, it's a bug. Because it's off-topic, I won't say more here but I posted a simpler test case to comp.lang.javacript just now (1000 converted to base 100). I would not normally reply here, but I wanted to acknowledge your post as prompting me to look for other cases. Followup-to: set. -- Ben. Thank you, for finding the bug Ben, it turned out i did basicly same thing two times. One of the times was the more general case and that turned out to do the correct thing. jt.node365.se/baseconversion9.html It still bug out on very big numbers if base outside integer scope. I am very keen on suggestions regarding the logic to make it faster. I will read in base into an array holding bignumb, and then it should work for anybase and any number as far i can understand. -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 11:43:55 UTC+2 skrev jonas.t...@gmail.com: Den tisdag 30 juni 2015 kl. 11:35:06 UTC+2 skrev jonas.t...@gmail.com: Den tisdag 30 juni 2015 kl. 11:08:01 UTC+2 skrev Christian Gollwitzer: Am 30.06.15 um 10:52 schrieb jonas.thornv...@gmail.com: It still bug out on very big numbers if base outside integer scope. I am very keen on suggestions regarding the logic to make it faster. Concerning the algorithmic complexity, it can't be faster than square time in the number of digits N. Baseconversion needs to do a sequence of division operations, where every operation gves you one digit in the new base. The number of digits in the new base is proportional to the number of digits in the old base (the ratio is log b1/log b2). Therefore it will be O(N^2). Christian Any new digit will be found in SQRT(base) comparissons. Averaged case will be in (SQRT(base)*(SQRT(base)+1))/2 Well that averaging was balloney. How do i write that the digit will be found in. Average values from 1 to SQRT(base)? Regarding the time it seem to double the digits quadruple the time. And that is still linear or? -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 11:08:01 UTC+2 skrev Christian Gollwitzer: Am 30.06.15 um 10:52 schrieb jonas.thornv...@gmail.com: It still bug out on very big numbers if base outside integer scope. I am very keen on suggestions regarding the logic to make it faster. Concerning the algorithmic complexity, it can't be faster than square time in the number of digits N. Baseconversion needs to do a sequence of division operations, where every operation gves you one digit in the new base. The number of digits in the new base is proportional to the number of digits in the old base (the ratio is log b1/log b2). Therefore it will be O(N^2). Christian Any new digit will be found in SQRT(base) comparissons. Averaged case will be in (SQRT(base)*(SQRT(base)+1))/2 -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 15:22:44 UTC+2 skrev jonas.t...@gmail.com: Den tisdag 30 juni 2015 kl. 11:43:55 UTC+2 skrev jonas.t...@gmail.com: Den tisdag 30 juni 2015 kl. 11:35:06 UTC+2 skrev jonas.t...@gmail.com: Den tisdag 30 juni 2015 kl. 11:08:01 UTC+2 skrev Christian Gollwitzer: Am 30.06.15 um 10:52 schrieb jonas.thornv...@gmail.com: It still bug out on very big numbers if base outside integer scope. I am very keen on suggestions regarding the logic to make it faster. Concerning the algorithmic complexity, it can't be faster than square time in the number of digits N. Baseconversion needs to do a sequence of division operations, where every operation gves you one digit in the new base. The number of digits in the new base is proportional to the number of digits in the old base (the ratio is log b1/log b2). Therefore it will be O(N^2). Christian Any new digit will be found in SQRT(base) comparissons. Averaged case will be in (SQRT(base)*(SQRT(base)+1))/2 Well that averaging was balloney. How do i write that the digit will be found in. Average values from 1 to SQRT(base)? Regarding the time it seem to double the digits quadruple the time. And that is still linear or? 2x seem linear to me? -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 18:12:46 UTC+2 skrev Michael Torrie: Do you have some Python code to show us? No i just thought you would find the digit search algorithm interesting. -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 01:11:51 UTC+2 skrev Ian: On Mon, Jun 29, 2015 at 4:56 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Jun 29, 2015 at 4:39 PM, jonas.thornv...@gmail.com wrote: http://jt.node365.se/baseconversion8.html Back of the envelope mental calculation, that appears to be quadratic, not linear. Doubling the length of the input results in an approximate quadrupling of the time taken to produce the output. That noted, this is off-topic for this list, which is for discussion about Python. Please take this to somewhere else like comp.lang.javascript instead. By the way, I think you have a bug. I did my time testing by concatenating the default input number to itself several times. At 5184 decimal digits, which was the last case I tried, the 58th output digit was 111, after which point the remaining 672 output digits are all 12665464, which seemed rather improbable. It isn't i used the power to check with wolfram, but there is a plus 1 bug as ben noticed. But not in this slower version. http://jt.node365.se/baseconversion5.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 11:35:06 UTC+2 skrev jonas.t...@gmail.com: Den tisdag 30 juni 2015 kl. 11:08:01 UTC+2 skrev Christian Gollwitzer: Am 30.06.15 um 10:52 schrieb jonas.thornv...@gmail.com: It still bug out on very big numbers if base outside integer scope. I am very keen on suggestions regarding the logic to make it faster. Concerning the algorithmic complexity, it can't be faster than square time in the number of digits N. Baseconversion needs to do a sequence of division operations, where every operation gves you one digit in the new base. The number of digits in the new base is proportional to the number of digits in the old base (the ratio is log b1/log b2). Therefore it will be O(N^2). Christian Any new digit will be found in SQRT(base) comparissons. Averaged case will be in (SQRT(base)*(SQRT(base)+1))/2 Well that averaging was balloney. How do i write that the digit will be found in. Average values from 1 to SQRT(base)? -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 11:08:01 UTC+2 skrev Christian Gollwitzer: Am 30.06.15 um 10:52 schrieb jonas.thornv...@gmail.com: It still bug out on very big numbers if base outside integer scope. I am very keen on suggestions regarding the logic to make it faster. Concerning the algorithmic complexity, it can't be faster than square time in the number of digits N. Baseconversion needs to do a sequence of division operations, where every operation gves you one digit in the new base. The number of digits in the new base is proportional to the number of digits in the old base (the ratio is log b1/log b2). Therefore it will be O(N^2). Christian There is not a single division except for the 2 one, used in halfinterval search This algorithm only use multiplication and a modified GCD search algorithm. http://jt.node365.se/baseconversion9.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Linear time baseconversion
Den tisdag 30 juni 2015 kl. 01:11:51 UTC+2 skrev Ian: On Mon, Jun 29, 2015 at 4:56 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Jun 29, 2015 at 4:39 PM, jonas.thornv...@gmail.com wrote: http://jt.node365.se/baseconversion8.html Back of the envelope mental calculation, that appears to be quadratic, not linear. Doubling the length of the input results in an approximate quadrupling of the time taken to produce the output. That noted, this is off-topic for this list, which is for discussion about Python. Please take this to somewhere else like comp.lang.javascript instead. By the way, I think you have a bug. I did my time testing by concatenating the default input number to itself several times. At 5184 decimal digits, which was the last case I tried, the 58th output digit was 111, after which point the remaining 672 output digits are all 12665464, which seemed rather improbable. No there is no bug, try 12665465^77 wolfram alpha gives 7976781785088446084873306945009387424538813088491673402748035781202063831184317457635773873975198429536727051788368983080016275695338973787545408588270715883570324803120051806974411884509607864124408509087974736382639726555779113221450078243163340395784592348080359062163885323462144257596380766496966084237358222613649636595300081207683175410584139478853066960795599027150403706812116411354218686846750615496852415389467898730884554700066802269059177874281189887271741594702334892800692129299635716260471508809448693000376806594431400299072265625 Try that number you get a ONE followed by 77 ZEROS -- https://mail.python.org/mailman/listinfo/python-list
Linear time baseconversion
http://jt.node365.se/baseconversion8.html -- https://mail.python.org/mailman/listinfo/python-list
Python functionality in Javascript
Check this out using a 8 digit base with a 100 digit number no problem. http://jt.node365.se/baseconversion3.html -- https://mail.python.org/mailman/listinfo/python-list
Re: find all multiplicands and multipliers for a number
Den lördag 11 april 2015 kl. 09:35:22 UTC+2 skrev Steven D'Aprano: On Sat, 11 Apr 2015 04:08 pm, Paul Rubin wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: It may be a bit slow for very large numbers. On my computer, this takes 20 seconds: py pyprimes.factors.factorise(2**111+1) [3, 3, 1777, 3331, 17539, 25781083, 107775231312019L] This takes about 4 seconds on a Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz laptop (64 bit linux): Nice for some who have fast machines, but on my old jalopy, your code takes 110 seconds, more than five times slower than mine. It also returns the wrong result: [3, 3, 3, 3, 7, 19, 73, 87211, 262657, 1.4411518807585587e+17] Oops, you have a float in there, how did that happen? We can tell your code gives the wrong result. It claims that 7 is a factor of 2**111+1: py n = 2**111 + 1 py itertools.islice(fac(n), 0, 5) itertools.islice object at 0xb7c8f914 py list(itertools.islice(fac(n), 0, 5)) [3, 3, 3, 3, 7] but that can't be right: py n % 7 2L Seven in not a factor of 2**111 + 1. The reason your code gives wrong results is that you perform true division / rather than integer division // which means that you with n a float, which loses precision: py (n/9) % 3 # nine is a factor 0.0 py (n//9) % 3 # exact, without rounding 1L -- Steven Love it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Generarl programming question.
Den lördag 11 april 2015 kl. 17:26:03 UTC+2 skrev Steven D'Aprano: On Sun, 12 Apr 2015 01:00 am, jonas.thornv...@gmail.com wrote: If two functions crossreference eachother back and forth what happen with the local variables. Nothing. They are local to the function that creates them. Will there be a new instance of function holding the variables or do they get messed up? No to both of those. You have two functions, each with it's own locals. def spam(): colour = red print(Inside spam: colour is:, colour) eggs() print(Inside spam after calling eggs: colour is:, colour) eggs() def eggs(): colour = yellow print(Inside eggs: colour is:, colour) Calling spam() gives you this output: py spam() Inside spam: colour is: red Inside eggs: colour is: yellow Inside spam after calling eggs: colour is: red Inside eggs: colour is: yellow Even if the functions call each other (mutual recursion) each function's local variables remain local. -- Steven I don't think it matter butt eggs also calls spam, once more. -- https://mail.python.org/mailman/listinfo/python-list
Re: Generarl programming question.
Den lördag 11 april 2015 kl. 17:16:09 UTC+2 skrev Chris Angelico: On Sun, Apr 12, 2015 at 1:00 AM, jonas.thornv...@gmail.com wrote: If two functions crossreference eachother back and forth what happen with the local variables. Will there be a new instance of function holding the variables or do they get messed up? You mean if one function calls another, and that function calls the first? That's called mutual recursion: def func1(x): if x % 2: return x + 1 return func2(x - 2) def func2(x): if x % 3: return x + 2 return func1(x - 3) The 'x' inside each function is completely separate, no matter how many times they get called. They're usually stored on something called a call stack - you put another sheet of paper on top of the stack every time you call a function, local variables are all written on that paper, and when you return from a function, you discard the top sheet and see what's underneath. For more information, search the web for the key terms in the above description, particularly the ones I put in quotes. If this isn't what you're talking about, the best way to clarify your question is probably to post a simple (even stupidly trivial, like the one above) example, and ask a question about that code. Someone'll doubtless help out! ChrisA Thanks i was worried, i try to make a generic base choice algorithm that should work for anybase, and i just realised that the bignumb add would need to call the bignumb subtraction and viceversa. I thought there may be instances but i was not sure. But I have a feeling the code will be hard to debug. -- https://mail.python.org/mailman/listinfo/python-list
Generarl programming question.
If two functions crossreference eachother back and forth what happen with the local variables. Will there be a new instance of function holding the variables or do they get messed up? -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den torsdag 9 april 2015 kl. 17:02:24 UTC+2 skrev Chris Angelico: On Fri, Apr 10, 2015 at 12:53 AM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Ouch, you're right, I tried to stick with Marko's example and forgot the basics. I meant signed ints, but the removable condition should be something like: if ( x0 y0 zx ) ... i.e., some condition that is never true (either false or undefined). Thanks for the correction. Ah, yep. And yes, that's absolutely right - the compiler's allowed to treat that as never true. ChrisA I guess when working on highlevel arithmetic one does not need to think about such trivial? things, the expression is broken down into pairs fed into the functions and the parser handle the signs? -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den torsdag 9 april 2015 kl. 17:04:53 UTC+2 skrev Ian: On Thu, Apr 9, 2015 at 8:54 AM, jonas.thornv...@gmail.com wrote: Aside from the base changer i've written a bignumb anybase generic multiplication, addition and subtraction routine. My goal is to make the arithmetic in the base of choice whatever size. And i think i can do it, i already have mult, add , subt working in anybase but not bignumb. Does this mult work for arbitrary size? Or will it but out at some point? Dunno, I have no interest in verifying your code for you. Especially since this is a Python list and said code is not Python. If you want to build confidence that your code works, I suggest writing some unit tests for it. (I'd also suggest keeping it separate from your html in a .js file, which would make it a lot easier to test and reuse.) Well with the condition i can get the bignumb arithmetic fully working, i am on my way of working bignumb arithmetic in anybase. I think this will be the first implementation ever to use arithmetic in the base of your choice. And i know for a fact (i've factored RSA in the 200 digit range on a 486 in a couple of hours 98-) So there is more to this than fancy overlay, it is about the digit representation at the binary level, and how the binary groups interpretated. So in the end, even with none optimised type like Javascript integer it will save operations at high level as well as lowlevel. That said highlevel and highbase arithmetic will work alot faster than binary. And using modular arithmetic you may find out that some operations requiering exponential work like factoring will turn out to be done in polynomial time. SCRIPT LANGUAGE=Javascript /* MULTIPLY TWO VARIABLES */ //CONVERT A DECIMAL NUMBER INTO ANYBASE function newbase(decNumber,base){ var out =[]; digits=1; digmult=1; while(digmult*base=decNumber){ digmult=digmult*base digits++; } digsave=digmult; while(decNumber0 || digits0){ loop=1; digit=0; for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } out[digits]=digit; digmult=digmult*digit; decNumber=decNumber-digmult; digsave=digsave/base; digmult=digsave; digits--; } return out; } function naiveMult(base, multOne, multTwo) { var total = []; var addResult = []; total[0] = 0; //Check which array bigger minimize multiplications if (multOne.lengthmultTwo.length){ mshort=multOne.length; mlong=multTwo.length;} else { mshort=multOne.length; mlong=multTwo.length;} for (var i = 0; i mshort; i ++ ) { multresult = []; remainder = 0; tempVal = 0; tempDig = 0; j = 0; if(i 0) { for(zero = 0; zero i; zero ++ ) multresult[zero] = 0; } while(j mlong) { intMult++; tempVal = (multOne[i] * multTwo[j]) + remainder; remainder = 0; if (tempVal = base) { tempDig = tempVal % base; remainder = (tempVal - tempDig) / base; multresult[j + i] = tempDig; } else { multresult[j + i] = tempVal; } j ++ ; } if(remainder != 0) { multresult[j + i] = remainder; } addResult=naiveAdd(base, total, multresult); total=addResult; } return total; } /* ADD TWO VARIABLES */ function naiveAdd(base, arrOne, arrTwo) { shortArr=[]; longArr=[]; addResult = []; remainder = 0; //Find shortest and longest array if (arrOne.length = arrTwo.length) {shortArr = arrTwo; longArr = arrOne;} else {shortArr = arrOne;longArr = arrTwo;} for (i = 0; i shortArr.length; i ++ ) { intAdd ++ ; arrOne[i] = parseInt(arrOne[i]); arrTwo[i] = parseInt(arrTwo[i]); if (isNaN(arrOne[i])) arrOne[i] = 0; if (isNaN(arrTwo[i])) arrTwo[i] = 0; addResult[i] = arrOne[i] + arrTwo[i] + remainder; if (addResult[i] = base) { addResult[i] = addResult[i] - base; remainder = 1; } else { remainder = 0; } } //Copying values from the shorter string while(ilongArr.length) {longArr[i]=parseInt(longArr[i]);addResult[i]=longArr[i]+remainder; remainder=0; i++;} //If strings of equal lenght but there is a remainder; if (remainder == 1) addResult[i++] = 1; else addResult.splice(i, 1); return addResult; } /* MAIN */ function fetchValues() { intMult=0; intAdd=0; base=10; x=1; y=1; document.calc.result.value=; document.calc.stats.value=; document.calc.outbase.value=; strEval = document.calc.eval.value; genArr = strEval.split(*); //fONE=newbase(genArr[0],base); //document.write(fONE[2]); //document.calc.outbase.value +=fONE+ + \n; //fTWO=newbase(genArr[1],base); //document.calc.outbase.value +=fTWO+\n;
Re: Best search algorithm to find condition within a range
Den torsdag 9 april 2015 kl. 16:08:48 UTC+2 skrev Chris Angelico: On Thu, Apr 9, 2015 at 11:57 PM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Because, in: z = x+y; // all signed ints if ( z x ) ... either there was no overflow (and the condition is false), or there was, and the result is undefined, i.e., zx can be considered false also. Do you mean all unsigned ints here? Because if y is negative, the condition will be true without overflow. If you didn't, then I'm puzzled as to where the undefined behaviour is coming from. ChrisA Aside from the base changer i've written a bignumb anybase generic multiplication, addition and subtraction routine. My goal is to make the arithmetic in the base of choice whatever size. And i think i can do it, i already have mult, add , subt working in anybase but not bignumb. Does this mult work for arbitrary size? Or will it but out at some point? SCRIPT LANGUAGE=Javascript /* MULTIPLY TWO VARIABLES */ //CONVERT A DECIMAL NUMBER INTO ANYBASE function newbase(decNumber,base){ var out =[]; digits=1; digmult=1; while(digmult*base=decNumber){ digmult=digmult*base digits++; } digsave=digmult; while(decNumber0 || digits0){ loop=1; digit=0; for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } out[digits]=digit; digmult=digmult*digit; decNumber=decNumber-digmult; digsave=digsave/base; digmult=digsave; digits--; } return out; } function naiveMult(base, multOne, multTwo) { var total = []; var addResult = []; total[0] = 0; //Check which array bigger minimize multiplications if (multOne.lengthmultTwo.length){ mshort=multOne.length; mlong=multTwo.length;} else { mshort=multOne.length; mlong=multTwo.length;} for (var i = 0; i mshort; i ++ ) { multresult = []; remainder = 0; tempVal = 0; tempDig = 0; j = 0; if(i 0) { for(zero = 0; zero i; zero ++ ) multresult[zero] = 0; } while(j mlong) { intMult++; tempVal = (multOne[i] * multTwo[j]) + remainder; remainder = 0; if (tempVal = base) { tempDig = tempVal % base; remainder = (tempVal - tempDig) / base; multresult[j + i] = tempDig; } else { multresult[j + i] = tempVal; } j ++ ; } if(remainder != 0) { multresult[j + i] = remainder; } addResult=naiveAdd(base, total, multresult); total=addResult; } return total; } /* ADD TWO VARIABLES */ function naiveAdd(base, arrOne, arrTwo) { shortArr=[]; longArr=[]; addResult = []; remainder = 0; //Find shortest and longest array if (arrOne.length = arrTwo.length) {shortArr = arrTwo; longArr = arrOne;} else {shortArr = arrOne;longArr = arrTwo;} for (i = 0; i shortArr.length; i ++ ) { intAdd ++ ; arrOne[i] = parseInt(arrOne[i]); arrTwo[i] = parseInt(arrTwo[i]); if (isNaN(arrOne[i])) arrOne[i] = 0; if (isNaN(arrTwo[i])) arrTwo[i] = 0; addResult[i] = arrOne[i] + arrTwo[i] + remainder; if (addResult[i] = base) { addResult[i] = addResult[i] - base; remainder = 1; } else { remainder = 0; } } //Copying values from the shorter string while(ilongArr.length) {longArr[i]=parseInt(longArr[i]);addResult[i]=longArr[i]+remainder; remainder=0; i++;} //If strings of equal lenght but there is a remainder; if (remainder == 1) addResult[i++] = 1; else addResult.splice(i, 1); return addResult; } /* MAIN */ function fetchValues() { intMult=0; intAdd=0; base=10; x=1; y=1; document.calc.result.value=; document.calc.stats.value=; document.calc.outbase.value=; strEval = document.calc.eval.value; genArr = strEval.split(*); //fONE=newbase(genArr[0],base); //document.write(fONE[2]); //document.calc.outbase.value +=fONE+ + \n; //fTWO=newbase(genArr[1],base); //document.calc.outbase.value +=fTWO+\n; arrOne=genArr[0].split().reverse(); arrTwo=genArr[1].split().reverse(); base = document.calc.formbase.value; out=naiveMult(base,arrOne,arrTwo); document.calc.stats.value +=Multiplications = +intMult+\n; document.calc.result.value += Product = + out.reverse()+\n; } /SCRIPT !DOCTYPE html html lang=en headmeta charset=utf-8//head body bgcolor=gold onload=fetchValues() H1Big numbers/H1P FORM name=calc onSubmit=fetchValues(); return false; BINPUT DEC-input type=submit name=calc value=Calc input type=text name=eval value=32432439*12 size=300br BASE input type=text name=formbase value=10 size=10br This calculationinput type=text name=outbase value= size=60br FONT COLOR=white RESULTbr textarea name=result rows=20 cols=120/textareabr STATUS/Bbr textarea name=stats cols=120 rows=40
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 03:00:12 UTC+2 skrev Gregory Ewing: Steven D'Aprano wrote: What digits would you use for base one-million? Interesting question. Unicode currently has about 75,000 CJK characters, so we would need to find about 12 more independently developed cultures with similar writing systems to get enough characters. I suggest revisiting the issue when interstellar travel and exploration have been better developed. -- Greg No need Greg it is an easy task creating visual interpretable symbols from low to high using lines in a point/pixel space. I could create the set in a day. And if i use colour space it is even easier. The hard part is making the point space visible and interpretabel without calculation and holding remainders in head. But then again when numbers have more than 5 digitplaces people tend to interpretate them digitwise anyway. 10010 is interpretated as a single digit by brain. 7582560 people mostly interpretate as 7 m 582 000 and 560. You can tell how people group and think about numbers by having them reading up a very long telephone number. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 02:38:57 UTC+2 skrev Steven D'Aprano: On Wed, 8 Apr 2015 03:44 am, Ian Kelly wrote: to_base(2932903594368438384328325832983294832483258958495845849584958458435439543858588435856958650865490, 429496729) [27626525, 286159541, 134919277, 305018215, 329341598, 48181777, 79384857, 112868646, 221068759, 70871527, 416507001, 31] They're not exactly *digits* though, are they? Without an easy to use set of 429496729 different symbols, the whole exercise is rather pointless. It's not more compact: 97 decimal digits, versus 121 characters in the list representation. 110 if you strip out the spaces between items. It's certainly not more memory efficient: the long int 293...490 takes 56 bytes, compared to 80 bytes for just the list, not including the memory used by its 12 int items. (Results may vary in other versions of Python.) You can't do arithmetic on it faster than Python's built-ins. Besides, it isn't clear to me whether Jonas wants to convert decimal 293...490 *into* base 429496729 as you have done, or *base 429496729* 293...490 into decimal. -- Steven Well Steven you just draw a line under connecting them all, and now you are allowed to call whatever combination you write down a single digit. And you have just created 429496729 unique symbols ;), in a pencil stroke. I know at least one intergalactic poster that will be impressed ;) -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 09:16:24 UTC+2 skrev Ian: On Tue, Apr 7, 2015 at 4:35 PM, jonas.thornv...@gmail.com wrote: I am not sure you guys realised, that althoug the size of the factors to muliply expands according to base^(exp+1) for each digitplace the number of comparissons needed to reach the digit place (multiple of base^exp+1) is constant with my approach/method. No it isn't. You do one comparison on every iteration of your while loop, and you do one iteration for every digit. How is that constant? Ok the number of comparissons is linear for each digitplace not exponential. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 09:16:24 UTC+2 skrev Ian: On Tue, Apr 7, 2015 at 4:35 PM, jonas.thornv...@gmail.com wrote: I am not sure you guys realised, that althoug the size of the factors to muliply expands according to base^(exp+1) for each digitplace the number of comparissons needed to reach the digit place (multiple of base^exp+1) is constant with my approach/method. No it isn't. You do one comparison on every iteration of your while loop, and you do one iteration for every digit. How is that constant? The for loop should be replaced with a version of binary search making comparisson instead of adding to digit. It will be alot faster with a base using 32-bits. But the point is the number of operations is linear for each digitplace with my approach/method, you will multiply bigger numbers. But the numbers of comparissons and multiplications is linear over the digitspace. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 15:40:46 UTC+2 skrev Mel Wilson: On Tue, 07 Apr 2015 23:19:49 -0700, jonas.thornvall wrote: And you have just created 429496729 unique symbols ;), in a pencil stroke. No. You did that, when you said base 429496729. Representing the symbols in a computer is no problem, any Python long int can do that. To display the symbols, you can use PIL to make up glyphs out of coloured pixels 864x864. You can keep your glyphs in GIFs. Where you keep them is up to you. Keeping them in Tumbolia and computing them out as required will work well. Well many interpretate a numeral digit as a single unique symbol representing a number written out in one pensttroke. I just pointed out that using handwriting or underscore a compination can be considered a numerical digit in itself. There is no need for inventing a new set of characters representing 32-bit numbers. You will not be able to learn them by heart anyway, unless they build on a interpretation system binaries, decimals. Of course you could rather easily create a new set building on Points and lines and their interpretation. Well just saying the Babylonians and Sumerians already did this, even the old greek had some sort of system with 120 unique digits. But what would be the need for such system when we so easy can create a unique permutation representing any number, using our 10 digits. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 19:34:39 UTC+2 skrev Mel Wilson: On Wed, 08 Apr 2015 07:56:05 -0700, jonas.thornvall wrote: There is no need for inventing a new set of characters representing 32-bit numbers. You will not be able to learn them by heart anyway, unless they build on a interpretation system binaries, decimals. See Jorge Luis Borges, _Funes the Memorious_. Gotta keep up with the literature. One thing is true though the bigger the chunks the less operations doing add. So arithmetic may turn out to be obsolete and replaced with search in lookuptables. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 21:28:34 UTC+2 skrev jonas.t...@gmail.com: Den onsdag 8 april 2015 kl. 19:34:39 UTC+2 skrev Mel Wilson: On Wed, 08 Apr 2015 07:56:05 -0700, jonas.thornvall wrote: There is no need for inventing a new set of characters representing 32-bit numbers. You will not be able to learn them by heart anyway, unless they build on a interpretation system binaries, decimals. See Jorge Luis Borges, _Funes the Memorious_. Gotta keep up with the literature. One thing is true though the bigger the chunks the less operations doing add. So arithmetic may turn out to be obsolete and replaced with search in lookuptables. When doing by hand and working within the digitspace of a single decimal digit like 3+4 the operation is implicit. You do not really add anything you use a lookup table. But if you take an expression like 193+169, most people perform the arithmetic. Unless they do not happen to be your favourit numbers and you learnt the sum by heart. Top down or bottom up is basicly the choices. -- https://mail.python.org/mailman/listinfo/python-list
Best search algorithm to find condition within a range
I want todo faster baseconversion for very big bases like base 1 000 000, so instead of adding up digits i search it. I need the fastest algorithm to find the relation to a decimal number. 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. * for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } * So i am looking for the digit where following condition true. if((digit)*digmultdecNumber) AND if((digit+1)*digmultdecNumber) then BREAK; 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. SCRIPT LANGUAGE=Javascript //CONVERT A DECIMAL NUMBER INTO ANYBASE function newbase(decNumber,base){ digits=1; digmult=1; while(digmult*base=decNumber){ digmult=digmult*base digits++; } digsave=digmult; while(decNumber0 || digits0){ loop=1; digit=0; for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } out[digits]=digit; digmult=digmult*digit; decNumber=decNumber-digmult; digsave=digsave/base; digmult=digsave; digits--; } return out; } var out= []; base=256; number=854544; out=newbase(number,base); out.reverse(); document.write(Number = ,out,BR); /script -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 15:30:36 UTC+2 skrev Dave Angel: On 04/07/2015 05:44 AM, jonas.thornv...@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)*digmultdecNumber)break; } * So i am looking for the digit where following condition true. if((digit)*digmultdecNumber) AND if((digit+1)*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. SCRIPT LANGUAGE=Javascript //CONVERT A DECIMAL NUMBER INTO ANYBASE function newbase(decNumber,base){ digits=1; digmult=1; while(digmult*base=decNumber){ digmult=digmult*base digits++; } digsave=digmult; while(decNumber0 || digits0){ loop=1; digit=0; for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } out[digits]=digit; digmult=digmult*digit; decNumber=decNumber-digmult; digsave=digsave/base; digmult=digsave; digits--; } return out; } var out= []; base=256; number=854544; out=newbase(number,base); out.reverse(); document.write(Number = ,out,BR); /script 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 I am doing it just like i would do it by hand finding the biggest digit first. To do that i need to know nearest base^exp that is less than the actual number. Add up the digit (multiply) it to the nearest smaller multiple. Subtract that number (base^exp*multiple). Divide / Scale down the exponent with base. And record the digit. And start looking for next digit doing same manipulation until remainder = 0. And that is what i am doing. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon: On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote: On 04/07/2015 05:44 AM, jonas.thornv...@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. How do you know the baseconversion is the bottleneck, if you haven't written any Python code yet? He doesn't. He doesn't comprehend that as far as a computer is concerned an integer has no specific 'base', it's only when presented in a form for humans to read that it gets base information added in the representation. He's making these and other similar errors in the javascript groups too. I suspect he's one of those people that spends his time thinking up elaborate solutions that he has no idea how to implement as a response to dreamt up non existent problems. -- Denis McMahon, denismfmcma...@gmail.com Bullshit declare two integers in any language one 7 and one 4 and then write x=7+4; if you find a programming language where that does not yield 11 tell me. Integers are internally assumed to be base 10 otherwise you could not calculate without giving the base. All operations on integers addition, subtraction, multiplication and division assume base 10. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 16:32:56 UTC+2 skrev Ian: On Tue, Apr 7, 2015 at 3:44 AM, jonas.thornv...@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. I need the fastest algorithm to find the relation to a decimal number. 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. * for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } * So i am looking for the digit where following condition true. if((digit)*digmultdecNumber) AND if((digit+1)*digmultdecNumber) then BREAK; I'm not sure that I understand what it is that you're trying to accomplish. Are you trying to find the digits without using division because division is slow? If that's the case, then let me show you something. $ python -m timeit -s n = 1523837293 n // 100 100 loops, best of 3: 0.286 usec per loop $ python -m timeit -s n = 1523 n * 100; (n+1) * 100 100 loops, best of 3: 0.455 usec per loop In Python, one addition and two multiplications are already slower than a single division. The only way you're going to beat division by using trial multiplication is if the first digit that you try is always correct. To do that, you would need an oracle feeding your search algorithm, and then you might as well just use the oracle. One could start at half base searching, but then i Think i've read that using 1/3 closing in faster? Do you mean binary search? That would be an improvement over the linear search algorithm you've shown. Whether a trinary search might be faster would depend on the distribution of the numbers you expect. If they're evenly distributed, it will be slower. 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? On average, a random Oracle with a search space of 100 will need 100 guesses. Well of course you use same principles like a binary search setting min and max, closing in on the digit. In this case the searched numbers base^exp and number base^exp+1. But since the search is within large bases upto 32-bit space, so base 4294967295 is the biggest allowed. I need to find the nearest less exp in base for each (lets call them pseudo digits). But as you see there it will take time to add them up. So better doing a binary search, you know min-max half (iteration). You can do the same for a random oracle min max within range, and if the number of tries in general over 22 i think a random oracle do it better than a binary search. It was a long time since i did this, but i do know there is a threshold where searching min max with the oracle will be faster than the binary search. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 18:34:32 UTC+2 skrev Dave Angel: On 04/07/2015 11:40 AM, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 16:32:56 UTC+2 skrev Ian: On Tue, Apr 7, 2015 at 3:44 AM, jonas.thornv...@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. I need the fastest algorithm to find the relation to a decimal number. 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. * for (digit=0;digit=base;digit++) { if((digit+1)*digmultdecNumber)break; } * snip One could start at half base searching, but then i Think i've read that using 1/3 closing in faster? Do you mean binary search? That would be an improvement over the linear search algorithm you've shown. Whether a trinary search might be faster would depend on the distribution of the numbers you expect. If they're evenly distributed, it will be slower. 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? On average, a random Oracle with a search space of 100 will need 100 guesses. Well of course you use same principles like a binary search setting min and max, closing in on the digit. In this case the searched numbers base^exp and number base^exp+1. But since the search is within large bases upto 32-bit space, so base 4294967295 is the biggest allowed. I need to find the nearest less exp in base for each (lets call them pseudo digits). But as you see there it will take time to add them up. So better doing a binary search, you know min-max half (iteration). You can do the same for a random oracle min max within range, and if the number of tries in general over 22 i think a random oracle do it better than a binary search. It was a long time since i did this, but i do know there is a threshold where searching min max with the oracle will be faster than the binary search. Once again, there's no point in doing a search, when a simple integer divide can give you the exact answer. And there's probably no point in going left to right when right to left would yield a tiny, fast program. I haven't seen one line of Python from you yet, so perhaps you're just yanking our chain. I'm not here to optimize Javascript code. Using only Python 3.4 and builtin functions, this function can be implemented straightforwardly in 7 lines, assuming number is nonnegative integer, and base is positive integer. It definitely could be done smaller, but then the code might be more confusing. -- DaveA So you can tell me the first (higest) digit of the integer 2932903594368438384328325832983294832483258958495845849584958458435439543858588435856958650865490 Using base 429496729? How long time did it take to find it? -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 17:00:53 UTC+2 skrev MRAB: On 2015-04-07 15:36, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon: On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote: On 04/07/2015 05:44 AM, jonas.thornv...@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. How do you know the baseconversion is the bottleneck, if you haven't written any Python code yet? He doesn't. He doesn't comprehend that as far as a computer is concerned an integer has no specific 'base', it's only when presented in a form for humans to read that it gets base information added in the representation. He's making these and other similar errors in the javascript groups too. I suspect he's one of those people that spends his time thinking up elaborate solutions that he has no idea how to implement as a response to dreamt up non existent problems. Bullshit declare two integers in any language one 7 and one 4 and then write x=7+4; if you find a programming language where that does not yield 11 tell me. Integers are internally assumed to be base 10 otherwise you could not calculate without giving the base. All operations on integers addition, subtraction, multiplication and division assume base 10. Sorry to say this, but that's nonsense. It doesn't matter what base it's working in internally; usually it's base 2 (binary), because that's simpler to implement. It's only when you're converting from or to text that you need specify a base. Humans prefer base 10, so they've make that the default. No that is not what i am saying, i am saying if you do operations on two integers the machine will assume base 10. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon: On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote: On 04/07/2015 05:44 AM, jonas.thornv...@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. How do you know the baseconversion is the bottleneck, if you haven't written any Python code yet? He doesn't. He doesn't comprehend that as far as a computer is concerned an integer has no specific 'base', it's only when presented in a form for humans to read that it gets base information added in the representation. He's making these and other similar errors in the javascript groups too. I suspect he's one of those people that spends his time thinking up elaborate solutions that he has no idea how to implement as a response to dreamt up non existent problems. -- Denis McMahon, denismfmcma...@gmail.com Well Denis if it hasn't a base then how can you add integers, the integer operations assume base 10. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 17:07:36 UTC+2 skrev Ian: On Tue, Apr 7, 2015 at 8:36 AM, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon: On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote: On 04/07/2015 05:44 AM, jonas.thornv...@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. How do you know the baseconversion is the bottleneck, if you haven't written any Python code yet? He doesn't. He doesn't comprehend that as far as a computer is concerned an integer has no specific 'base', it's only when presented in a form for humans to read that it gets base information added in the representation. He's making these and other similar errors in the javascript groups too. I suspect he's one of those people that spends his time thinking up elaborate solutions that he has no idea how to implement as a response to dreamt up non existent problems. -- Denis McMahon, denismfmcma...@gmail.com Bullshit declare two integers in any language one 7 and one 4 and then write x=7+4; if you find a programming language where that does not yield 11 tell me. Integers are internally assumed to be base 10 otherwise you could not calculate without giving the base. All operations on integers addition, subtraction, multiplication and division assume base 10. You're conflating the internal representation of the integer with the formatting that is done to display the integer. When you do print(x), the computer doesn't just dump the internal representation of x onto the display. It formats x as character data and displays *that*. For integers, the vast majority of programming languages will do the formatting as base 10 by default, since that is the format preferred by most humans. No i don't i say the operations assume base ten other wise INT A=7,B=4 Calculate C=A+B would not yield 11 as an answer. The programming languages assume integer operations are done in base 10, at least the one where you can not specify in what base the integer arithmetic is done. And there probably is such languages, Python maybe? -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den tisdag 7 april 2015 kl. 21:27:20 UTC+2 skrev Ben Bacarisse: Ian Kelly ian.g.ke...@gmail.com writes: On Tue, Apr 7, 2015 at 12:55 PM, Terry Reedy tjre...@udel.edu wrote: On 4/7/2015 1:44 PM, Ian Kelly wrote: def to_base(number, base): ... digits = [] ... while number 0: ... digits.append(number % base) ... number //= base ... return digits or [0] ... to_base(2932903594368438384328325832983294832483258958495845849584958458435439543858588435856958650865490, 429496729) [27626525, 286159541, 134919277, 305018215, 329341598, 48181777, 79384857, 112868646, 221068759, 70871527, 416507001, 31] About 15 microseconds. % and probably // call divmod internally and toss one of the results. Slightly faster (5.7 versus 6.1 microseconds on my machine) is Not on my box. $ python3 -m timeit -s n = 100; x = 42 n % x; n // x 1000 loops, best of 3: 0.105 usec per loop $ python3 -m timeit -s n = 100; x = 42 divmod(n,x) 1000 loops, best of 3: 0.124 usec per loop I get similar results, but the times switch over when n is large enough to become a bignum. -- Ben. I am not sure you guys realised, that althoug the size of the factors to muliply expands according to base^(exp+1) for each digitplace the number of comparissons needed to reach the digit place (multiple of base^exp+1) is constant with my approach/method. -- https://mail.python.org/mailman/listinfo/python-list
Re: Best search algorithm to find condition within a range
Den onsdag 8 april 2015 kl. 00:57:27 UTC+2 skrev Steven D'Aprano: On Tue, 7 Apr 2015 07:44 pm, jonas.thornv...@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. What digits would you use for base one-million? Base 2 uses 0 1. Base 3 uses 0 1 2. Base 10 uses 0 1 2 3 4 5 6 7 8 9. Base 16 uses 0 1 2 3 4 5 6 7 8 9 A B C D E F. Base one million uses what? How would you write down 12345 in base one-million? -- Steven Well digit places have to be comma separated i think i told you, in low bases we have unique digits so there is no problems write out numbers without separaation of digitplaces. But when the base is higher than the number of digits you have a choice to make. Either you invent a new numeral(number digit. I think you realise that BB = 11,11 So your example would of course be ,12345 I hope you see A,B,C,D,E,F is only replacement for 10,11,12,13,14,15 -- https://mail.python.org/mailman/listinfo/python-list
Re: More or less code in python?
Den söndag 15 mars 2015 kl. 20:01:36 UTC+1 skrev Paul Rubin: jonas.thornv...@gmail.com writes: I though it would be interesting doing comparissons in timing adding massive digits in different bases. Especially in Python. Python has built-in bignums. Try print 2**500. I know. -- https://mail.python.org/mailman/listinfo/python-list
Re: More or less code in python?
Den söndag 15 mars 2015 kl. 20:01:36 UTC+1 skrev Paul Rubin: jonas.thornv...@gmail.com writes: I though it would be interesting doing comparissons in timing adding massive digits in different bases. Especially in Python. Python has built-in bignums. Try print 2**500. I will try implement the common operators + - * / pow sqrt operators mod floor and and a generic parser taking arguments in any base. -- https://mail.python.org/mailman/listinfo/python-list
Re: More or less code in python?
Den söndag 15 mars 2015 kl. 19:32:02 UTC+1 skrev Joel Goldstick: On Sun, Mar 15, 2015 at 2:07 PM, jonas.thornv...@gmail.com wrote: SCRIPT LANGUAGE=Javascript function naiveAdd(base,arrOne,arrTwo) { if (arrOne.length=arrTwo.length) {length=arrOne.length;} else {length=arrTwo.length;} out=; remainder=0; for (i=0;ilength;i++){ one=arrOne[i]; two=arrTwo[i]; one=parseInt(one); two=parseInt(two); if (isNaN(one)) one = 0; if (isNaN(two)) two = 0; sum=one+two+remainder; if (sum=base) { sum=sum-base; remainder=1;} else {remainder=0;} out=,+sum+out; } if (remainder==1) out=remainder+out; return out; } base=16; strOne=2,2; strTwo=13,13; arrOne=strOne.split(,); arrTwo=strTwo.split(,); arrOne.reverse(); arrTwo.reverse(); naiveAdd(base,arrOne,arrTwo); document.write(Sum = ,out,BR); /SCRIPT -- https://mail.python.org/mailman/listinfo/python-list I'm guessing less, if your question is whether this code would be fewer lines in python. However, it would be nice if you formatted it so that it is readable, and gave a description of what you think the code is doing, or should be doing. Its an odd question in that python generally runs on a server and javascript in a browser -- Joel Goldstick http://joelgoldstick.com I though it would be interesting doing comparissons in timing adding massive digits in different bases. Especially in Python. -- https://mail.python.org/mailman/listinfo/python-list
More or less code in python?
SCRIPT LANGUAGE=Javascript function naiveAdd(base,arrOne,arrTwo) { if (arrOne.length=arrTwo.length) {length=arrOne.length;} else {length=arrTwo.length;} out=; remainder=0; for (i=0;ilength;i++){ one=arrOne[i]; two=arrTwo[i]; one=parseInt(one); two=parseInt(two); if (isNaN(one)) one = 0; if (isNaN(two)) two = 0; sum=one+two+remainder; if (sum=base) { sum=sum-base; remainder=1;} else {remainder=0;} out=,+sum+out; } if (remainder==1) out=remainder+out; return out; } base=16; strOne=2,2; strTwo=13,13; arrOne=strOne.split(,); arrTwo=strTwo.split(,); arrOne.reverse(); arrTwo.reverse(); naiveAdd(base,arrOne,arrTwo); document.write(Sum = ,out,BR); /SCRIPT -- https://mail.python.org/mailman/listinfo/python-list
Re: More or less code in python?
Den söndag 15 mars 2015 kl. 19:32:02 UTC+1 skrev Joel Goldstick: On Sun, Mar 15, 2015 at 2:07 PM, jonas.thornv...@gmail.com wrote: SCRIPT LANGUAGE=Javascript function naiveAdd(base,arrOne,arrTwo) { if (arrOne.length=arrTwo.length) {length=arrOne.length;} else {length=arrTwo.length;} out=; remainder=0; for (i=0;ilength;i++){ one=arrOne[i]; two=arrTwo[i]; one=parseInt(one); two=parseInt(two); if (isNaN(one)) one = 0; if (isNaN(two)) two = 0; sum=one+two+remainder; if (sum=base) { sum=sum-base; remainder=1;} else {remainder=0;} out=,+sum+out; } if (remainder==1) out=remainder+out; return out; } base=16; strOne=2,2; strTwo=13,13; arrOne=strOne.split(,); arrTwo=strTwo.split(,); arrOne.reverse(); arrTwo.reverse(); naiveAdd(base,arrOne,arrTwo); document.write(Sum = ,out,BR); /SCRIPT -- https://mail.python.org/mailman/listinfo/python-list I'm guessing less, if your question is whether this code would be fewer lines in python. However, it would be nice if you formatted it so that it is readable, and gave a description of what you think the code is doing, or should be doing. Its an odd question in that python generally runs on a server and javascript in a browser -- Joel Goldstick http://joelgoldstick.com It add two postive numbers working in any base you prefer. There is no restriction on the size of operands, it dependens upon the memory of your computer or string limitations in the implementation of ECMASCRIPT.(If there is). Basicly the function doing addition in Python shell, but you can chose base you work in. -- https://mail.python.org/mailman/listinfo/python-list
Re: Brython (Python in the browser)
Den fredagen den 27:e december 2013 kl. 07:14:35 UTC+1 skrev Pierre Quentel: Hi, Ever wanted to use Python instead of Javascript for web client programming ? Take a look at Brython, an implementation of Python 3 in the browser, with an interface with DOM elements and events Its use is very simple : - load the Javascript library brython.js : script src=/path/to/brython.js - embed Python code inside a tag script type=text/python - run the Python script on page load : body onload=brython() The Python code is translated into Javascript and executed on the fly Brython supports the DOM API, HTML5, SVG, with some syntaxic sugar to make the interface more concise (a la jQuery) ; interaction with Javascript libraries is very straightforward. The Brython site provides documentation and many examples After 1 year of intense development, Brython now covers most of the Python3 syntax and can run most of the modules of the Python3.3 standard distribution unmodified, including complex packages like unittest. The team aims at covering 100% of all of Python that makes sense in a browser environment Home page : http://www.brython.info Development site : https://bitbucket.org/olemis/brython/src Downloads : https://bitbucket.org/olemis/brython/downloads Community : https://groups.google.com/forum/?fromgroups=#!forum/brython I am not sure i understand the concept correct it is not serverside, i have to install the libraries on my local computer, and it is accessible via javascript, not on its own in browsers? In the future will it always be a library that has to be downloaded and installed? Could in not be implemented like an activeX plugin as flashplayer, when you come to a Brython side you have a message to download plugin? If i understand correct, now one can implement Brython script in JAVASCRIPT invoked HTML on a server, but it will not work for people surfing the web because the browsers lack support for Brython libraries? Is Brython thought to be a webapplication or can it read/write to files? So what is its future? 1. A standard incorporated and implemented by browsers? 2. A plugin like flashplayer? 3. A standalone library to be downloaded and installed on the local computer to run python scripts one make? -- https://mail.python.org/mailman/listinfo/python-list
Line based graphic in canvas (vectorgraphic?) scale incorrectly on HDMI monitor.
Is there a way to make linebased graphic used in canvas scale correct on any monitor? I run in 1920*1080 on a Philips TV used as monitor does it matter, lines tend to get longer vertical then horizontal? Strange is i really do not see it writing out recangles. -- https://mail.python.org/mailman/listinfo/python-list
Re: Line based graphic in canvas (vectorgraphic?) scale incorrectly on HDMI monitor.
Den lördagen den 21:e december 2013 kl. 20:03:17 UTC+1 skrev Ned Batchelder: On 12/21/13 1:30 PM, jonas.thornv...@gmail.com wrote: Is there a way to make linebased graphic used in canvas scale correct on any monitor? I run in 1920*1080 on a Philips TV used as monitor does it matter, lines tend to get longer vertical then horizontal? Strange is i really do not see it writing out recangles. I'm not sure how we can help without seeing any code. There's no information here that we can use to make a concrete suggestion. -- Ned Batchelder, http://nedbatchelder.com A vertical and horisontal line of same length will be plottet out like this. There is really no code to show yet, i just write out some lines and noted that writing out a verital line of length 400 is longer then a horisontal line of same length e.g. line(100,100,500,100); is shorter line(300,100,300,500); is longer __ | | | | | | -- https://mail.python.org/mailman/listinfo/python-list
Re: Line based graphic in canvas (vectorgraphic?) scale incorrectly on HDMI monitor.
Den lördagen den 21:e december 2013 kl. 20:56:54 UTC+1 skrev Ned Batchelder: On 12/21/13 2:12 PM, jonas.thornv...@gmail.com wrote: Den l�rdagen den 21:e december 2013 kl. 20:03:17 UTC+1 skrev Ned Batchelder: On 12/21/13 1:30 PM, jonas.thornv...@gmail.com wrote: Is there a way to make linebased graphic used in canvas scale correct on any monitor? I run in 1920*1080 on a Philips TV used as monitor does it matter, lines tend to get longer vertical then horizontal? Strange is i really do not see it writing out recangles. I'm not sure how we can help without seeing any code. There's no information here that we can use to make a concrete suggestion. -- Ned Batchelder, http://nedbatchelder.com A vertical and horisontal line of same length will be plottet out like this. There is really no code to show yet, i just write out some lines and noted that writing out a verital line of length 400 is longer then a horisontal line of same length e.g. line(100,100,500,100); is shorter line(300,100,300,500); is longer __ | | | | | | Sounds like you don't have square pixels. Either use a monitor which does, or adjust your coordinates to take the shape of the pixel into account, or try different resolution settings to see if one of them does have square pixels. Also, the settings on the monitor matter also, you may be able to adjust them to correct the shape of the pixel. -- Ned Batchelder, http://nedbatchelder.com It is weird because it seem to be compensated writing out rectangles, but not for linegraphics. -- https://mail.python.org/mailman/listinfo/python-list
Install Tkinter for Windows 7 64-bit
I have installed Python 3.3, and i want to add a library with some basic functions like canvas and basic geomteric objects, fonts etc. Preferably something similar to the Javascript canvas. I've looked for graphic packages, and from what i can see something called Tkinter may be what i look for. However i have no luck install it, i installed something called Visual studio in hope it would incorporate Tkinter, but it did not and it also do not seem to work with 3.3 only 3.1 and below. Next i found ActiveStateTCL that from what i could see incorporated Tkinter library? But i have no luck runn the Tkinter example file i downloaded in idel, it still says no module called Tkinter. === Traceback (most recent call last): File D:\Python33\test2.py, line 16, in module from Tkinter import Tk, Canvas, Frame, BOTH ImportError: No module named 'Tkinter' === Maybe i should use some other module, i just need a canvas and the basic geometric objects functions line,rectangle,circle and some font. JT -- https://mail.python.org/mailman/listinfo/python-list
Re: Install Tkinter for Windows 7 64-bit
Here is the example file i have tried. #!/usr/bin/python # -*- coding: utf-8 -*- ZetCode Tkinter tutorial This program draws three rectangles filled with different colors. author: Jan Bodar last modified: January 2011 website: www.zetcode.com from Tkinter import Tk, Canvas, Frame, BOTH class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title(Colors) self.pack(fill=BOTH, expand=1) canvas = Canvas(self) canvas.create_rectangle(30, 10, 120, 80, outline=#fb0, fill=#fb0) canvas.create_rectangle(150, 10, 240, 80, outline=#f50, fill=#f50) canvas.create_rectangle(270, 10, 370, 80, outline=#05f, fill=#05f) canvas.pack(fill=BOTH, expand=1) -- https://mail.python.org/mailman/listinfo/python-list
Re: Install Tkinter for Windows 7 64-bit
Den måndagen den 11:e november 2013 kl. 17:43:12 UTC+1 skrev Chris “Kwpolska” Warrick: On Mon, Nov 11, 2013 at 5:38 PM, jonas.thornv...@gmail.com wrote: But i have no luck runn the Tkinter example file i downloaded in idel, it still says no module called Tkinter. IDLE* === Traceback (most recent call last): File D:\Python33\test2.py, line 16, in module from Tkinter import Tk, Canvas, Frame, BOTH ImportError: No module named 'Tkinter' === In Python 3, 'Tkinter' was renamed to 'tkinter' (both sans quotes). Please change the file to reflect that (as the traceback points out, line 16). -- Chris “Kwpolska” Warrick http://kwpolska.tk PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Algorithm that makes maximum compression of completly diffused data.
Den fredagen den 8:e november 2013 kl. 03:43:17 UTC+1 skrev zipher: I am not sure if it is just stupidness or laziness that prevent you from seeing that 4^8=65536. I can see that 4^8 = 65536. Now how are you going to render 65537? You claimed that you could render *any* number efficiently. What you've proven is that a small subset of numbers can be rendered efficiently. I think the idea would be to find the prime factorization for a given number, which has been proven to be available (and unique) for any and every number. Most numbers can compress given this technique. Prime numbers, of course, would not be compressed. -- MarkJ Tacoma, Washington 3^2-2^2=5 -- https://mail.python.org/mailman/listinfo/python-list
Re: Algorithm that makes maximum compression of completly diffused data.
Den torsdagen den 7:e november 2013 kl. 23:26:45 UTC+1 skrev Chris Angelico: On Fri, Nov 8, 2013 at 5:59 AM, Mark Janssen dreamingforw...@gmail.com wrote: I think the idea is that you could take any arbitrary input sequence, view it as a large number, and then find what exponential equation can produce that result. The equation becomes the compression. Interesting idea, but I don't see how this has anything to do with compressing arbitrary data. We already have a compact notation for representing a large number as 2^24*x+2^16*y+2^8*z+q, so I don't see how this will be any better, other than eliding NULs. ChrisA I guess what matter is how fast an algorithm can encode and decode a big number, at least if you want to use it for very big sets of random data, or losless video compression? -- https://mail.python.org/mailman/listinfo/python-list
Re: Algorithm that makes maximum compression of completly diffused data.
Den fredagen den 8:e november 2013 kl. 03:17:36 UTC+1 skrev Chris Angelico: On Fri, Nov 8, 2013 at 1:05 PM, jonas.thornv...@gmail.com wrote: I guess what matter is how fast an algorithm can encode and decode a big number, at least if you want to use it for very big sets of random data, or losless video compression? I don't care how fast. I care about the laws of physics :) You can't stuff more data into less space without losing some of it. Also, please lose Google Groups, or check out what other people have said about making it less obnoxious. ChrisA Please, you are he obnoxious, so fuck off or go learn about reformulation of problems. Every number has an infinite number of arithmetical solutions. So every number do has a shortest arithmetical encoding. And that is not the hard part to figure out, the hard part is to find a generic arithmetic encoding. I am not sure if it is just stupidness or laziness that prevent you from seeing that 4^8=65536. -- https://mail.python.org/mailman/listinfo/python-list
Re: Algorithm that makes maximum compression of completly diffused data.
Den lördagen den 2:e november 2013 kl. 22:31:09 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Well then i have news for you. Well, then, why don't you share it? Let me try to get you to understand WHY what you say is impossible. Let's say you do have a function f(x) that can produce a compressed output y for any given x, such that y is always smaller than x. If that were true, then I could call f() recursively: f(f(...f(f(f(f(f(x)...)) and eventually the result get down to a single bit. I hope it is clear that there's no way to restore a single bit back into different source texts. Here's another way to look at it. If f(x) is smaller than x for every x, that means there MUST me multiple values of x that produce the same f(x). Do you see? If x is three bits and f(x) is two bits, that means there are 8 possible values for x but only 4 values for f(x). So, given an f(x), you cannot tell which value of x it came from. You have lost information. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Well let me try to explain why it is working and i have implemented one. I only need to refresh my memory it was almost 15 years ago. This is not the solution but this is why it is working. 65536=256^2=16^4=***4^8***=2^16 Yes i am aware that 256 is a single byte 8 bits, but the approach is valid anyway. -- https://mail.python.org/mailman/listinfo/python-list
Re: Algorithm that makes maximum compression of completly diffused data.
Den måndagen den 4:e november 2013 kl. 14:53:28 UTC+1 skrev jonas.t...@gmail.com: Den lördagen den 2:e november 2013 kl. 22:31:09 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Well then i have news for you. Well, then, why don't you share it? Let me try to get you to understand WHY what you say is impossible. Let's say you do have a function f(x) that can produce a compressed output y for any given x, such that y is always smaller than x. If that were true, then I could call f() recursively: f(f(...f(f(f(f(f(x)...)) and eventually the result get down to a single bit. I hope it is clear that there's no way to restore a single bit back into different source texts. Here's another way to look at it. If f(x) is smaller than x for every x, that means there MUST me multiple values of x that produce the same f(x). Do you see? If x is three bits and f(x) is two bits, that means there are 8 possible values for x but only 4 values for f(x). So, given an f(x), you cannot tell which value of x it came from. You have lost information. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Well let me try to explain why it is working and i have implemented one. I only need to refresh my memory it was almost 15 years ago. This is not the solution but this is why it is working. 65536=256^2=16^4=***4^8***=2^16 Yes i am aware that 256 is a single byte 8 bits, but the approach is valid anyway. You see if the program behave intelligent some small operations can perform wonder on a number. -- https://mail.python.org/mailman/listinfo/python-list
Re: Algorithm that makes maximum compression of completly diffused data.
Den måndagen den 4:e november 2013 kl. 15:27:19 UTC+1 skrev Dave Angel: On Mon, 4 Nov 2013 05:53:28 -0800 (PST), jonas.thornv...@gmail.com wrote: Den lördagen den 2:e november 2013 kl. 22:31:09 UTC+1 skrev Tim Roberts: Here's another way to look at it. If f(x) is smaller than x for every x, that means there MUST me multiple values of x that produce the same f(x). Do you see? If x is three bits and f(x) is two bits, that means there are 8 possible values for x but only 4 values for f(x). So, given an f(x), y= cannot tell which value of x it came from. You have lost information. Well let me try to explain why it is working and i have implemented one. I only need to refresh my memory it was almost 15 years ago. This is not the solution but this is why it is working. 65536=256^2=16^4=***4^8***=2^16 Yes i am aware that 256 is a single byte 8 bits, but the approach is valid = anyway. And e ^ (I * pi) == -1 So what. ? e is an approximation... and your idea is not general for any n. Better file that patent, before the patent office realizes the analogy to the perpetual motion machine. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den lördagen den 2:e november 2013 kl. 21:19:44 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: I certainly do not like the old bracket style it was a catastrophe, but in honesty the gui editor of python should have what i propose, a parser that indent automaticly at loops, functions and end. Many editors do that. Vim, which is what I use, certainly does. I promise you it will save millions of hours of bug searching all over world in a month. I suspect you meant dozens rather than millions... Look, both schemes have their pitfalls. With an end requirement, it's easy to have code where the indenting doesn't match the actual nesting, and that causes human confusion. Without the end requirement, it's not hard to type code where you forget to dedent. Those are just two manifestations of the exact same problem. Neither scheme is provably superior to the other. It's just a choice that a language designer has to make. I happen to like Python's choice. You'll get used to it. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. What does Vim stand for Voyager interstellar mission? -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den lördagen den 2:e november 2013 kl. 21:19:44 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: I certainly do not like the old bracket style it was a catastrophe, but in honesty the gui editor of python should have what i propose, a parser that indent automaticly at loops, functions and end. Many editors do that. Vim, which is what I use, certainly does. I promise you it will save millions of hours of bug searching all over world in a month. I suspect you meant dozens rather than millions... Look, both schemes have their pitfalls. With an end requirement, it's easy to have code where the indenting doesn't match the actual nesting, and that causes human confusion. Without the end requirement, it's not hard to type code where you forget to dedent. Those are just two manifestations of the exact same problem. Neither scheme is provably superior to the other. It's just a choice that a language designer has to make. I happen to like Python's choice. You'll get used to it. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Was there a VIM discussion group? -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. It maybe common practice in program languages, but to me it is slightly confusing to have the while/for loop on the same indent level, as the regular statements. Because when the while loop ends there is no other identification then that the indent stopped, and to me it is easy to interpret that terms that actually straight under the loop belongs to it. But of course it is a matter of adjust the way i look at the code. Thanks for help guys. -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 09:52:16 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. It maybe common practice in program languages, but to me it is slightly confusing to have the while/for loop on the same indent level, as the regular statements. Because when the while loop ends there is no other identification then that the indent stopped, and to me it is easy to interpret that terms that actually straight under the loop belongs to it. But of course it is a matter of adjust the way i look at the code. Thanks for help guys. To show you guys that i am not totally uneducable i actually followed your sugestions ;D. (Is there any support similar javascript canvas for drawing, and HTML for interactivity, textbox, buttons in python?). I have been programming some PHP long time ago, basicly only remember you had to have a server running to interact via HTML. #!/usr/bin/python import math # Function definition is here def sq(number): square=1 factor=2 multip=exponent*exponent print(x,= , end=) while number=multip: while square=number: factor+=1 square=factor*factor factor-=1 print(factor,^2+,sep=,end=) square=factor*factor number=number-(factor*factor) square=1 factor=1 print(number) #Set exponent here exponent=3 print(Exp=x^,exponent,sep=) #Set range of numbers x for x in range (1,100): sq(x); -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 10:48:36 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 09:52:16 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. It maybe common practice in program languages, but to me it is slightly confusing to have the while/for loop on the same indent level, as the regular statements. Because when the while loop ends there is no other identification then that the indent stopped, and to me it is easy to interpret that terms that actually straight under the loop belongs to it. But of course it is a matter of adjust the way i look at the code. Thanks for help guys. To show you guys that i am not totally uneducable i actually followed your sugestions ;D. (Is there any support similar javascript canvas for drawing, and HTML for interactivity, textbox, buttons in python?). I have been programming some PHP long time ago, basicly only remember you had to have a server running to interact via HTML. #!/usr/bin/python import math # Function definition is here def sq(number): square=1 factor=2 multip=exponent*exponent print(x,= , end=) while number=multip: while square=number: factor+=1 square=factor*factor factor-=1 print(factor,^2+,sep=,end=) square=factor*factor number=number-(factor*factor) square=1 factor=1 print(number) #Set exponent here exponent=3 print(Exp=x^,exponent,sep=) #Set range of numbers x for x in range (1,100): sq(x); Forgot change the static square that was written out, i am a bit undecuable afterall... #!/usr/bin/python import math # Function definition is here def sq(number): square=1 factor=2 multip=exponent*exponent print(x,= , end=) while number=multip: while square=number: factor+=1 square=factor*factor factor-=1 print(factor,^,exponent,+,sep=,end=) square=factor*factor number=number-(factor*factor) square=1 factor=1 print(number) #Set exponent here exponent=3 print(Exp=x^,exponent,sep=) #Set range of numbers x for x in range (1,100): sq(x); -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Well Tim ***one could argue*** why not do a (i think it is called parser) that react to loop, end and function. And lazy like me do not have to think about what is not part of program. I certainly do not like the old bracket style it was a catastrophe, but in honesty the gui editor of python should have what i propose, a parser that indent automaticly at loops, functions and end. I promise you it will save millions of hours of bug searching all over world in a month. -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 11:08:11 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Well Tim ***one could argue*** why not do a (i think it is called parser) that react to loop, end and function. And lazy like me do not have to think about what is not part of program. I certainly do not like the old bracket style it was a catastrophe, but in honesty the gui editor of python should have what i propose, a parser that indent automaticly at loops, functions and end. I promise you it will save millions of hours of bug searching all over world in a month. Instead of having going over indent manually, you just drop in an end it is so simple, no marking no meny indent unindent it is automaticly done. And that was the purpose of python to remove idiocies, like brackets and indents. -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence: On 30/10/2013 09:52, jonas.thornv...@gmail.com wrote: Please stop sending us double spaced crap. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence I am not sure what you want. You want me to remove the empty line in function? I do it for it is easier to read for me. -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 11:11:17 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 11:08:11 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Well Tim ***one could argue*** why not do a (i think it is called parser) that react to loop, end and function. And lazy like me do not have to think about what is not part of program. I certainly do not like the old bracket style it was a catastrophe, but in honesty the gui editor of python should have what i propose, a parser that indent automaticly at loops, functions and end. I promise you it will save millions of hours of bug searching all over world in a month. Instead of having going over indent manually, you just drop in an end it is so simple, no marking no meny indent unindent it is automaticly done. And that was the purpose of python to remove idiocies, like brackets and indents. You could have it in the menu indent parser on off. If on you write out ends, and the text is automaticly indented, by using end or a reserved sign. It is quite simple i could program it in a day... -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence: On 30/10/2013 09:52, jonas.thornv...@gmail.com wrote: Please stop sending us double spaced crap. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence I think it is not me it is probably google groups, well maybe they should consider changing linebreak sign as stored in database. -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 11:11:17 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 11:08:11 UTC+1 skrev jonas.t...@gmail.com: Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: jonas.thornv...@gmail.com wrote: I suddenly realised i mixed code from a plain square system with the generic exponential modulus system. Here is the code, what it does is encode numbers in an exponential modulus base. So it is basicly a numbersystem of my own you do not need to write out + ^ and exponent because the numbersystem create unique values for every natural number. Well without the + ^ it is hard to read but so are binary, ternary and hexadecimal. I think the requirment for a numbersystem is that it have a working arithmetic, and mine have. So here is the working code, to write out exponential modulus number for and exponent. #!/usr/bin/python import math # Function definition is here def sq(number): exp=1 factor=2 multip=math.pow(2,exponent) print(x,= , end=) while number=multip: while exp=number: factor+=1 exp=math.pow(factor,exponent) factor-=1 print(factor,^,exponent,+,sep=,end=) exp=math.pow(factor,exponent) number=number-exp exp=1 factor=1 print(number) #Set exponent here exponent=2 print(Exp=x^,exponent,sep=) #Set range of numbers x for x in range (1,100): sq(x) Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of end. It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. Well Tim ***one could argue*** why not do a (i think it is called parser) that react to loop, end and function. And lazy like me do not have to think about what is not part of program. I certainly do not like the old bracket style it was a catastrophe, but in honesty the gui editor of python should have what i propose, a parser that indent automaticly at loops, functions and end. I promise you it will save millions of hours of bug searching all over world in a month. Instead of having going over indent manually, you just drop in an end it is so simple, no marking no meny indent unindent it is automaticly done. And that was the purpose of python to remove idiocies, like brackets and indents. -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 15:22:50 UTC+1 skrev Alister: On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote: Op 30-10-13 13:17, Chris Angelico schreef: On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: I broadly agree with your post (I'm of the school of thought that braces are better than indentation for delimiting blocks), but I don't think this argument holds water. All you need to do is be consistent about tabs OR spaces (and I'd recommend tabs, since they're simpler and safer), and you'll never have this trouble. Easier said than done. First of all I can be as consistent as possible, I can't just take code from someone else and insert it because that other person may be consistenly doing it different from me. I disagree it is very easy. 1) make sure you editor is set to inset 4 spaces rather than tab when pressing the tab key. consistency in your own code is now not an issue. 2) when importing code from someone else a simple search replace of tab with 4 spaces will instantly correct the formatting on code using tab without breaking code that doesn't. Then if you are working on different machines, the settings of your editor may not always be the same so that you have tabs on one machine and spaces on an other, which causes problem when you move the code. that is fixed by setting your environment consistantly but step 2 above will fix it if you forget. Also when you have an xterm, selecting a tab and pasting it into another it will turn the tab into spaces. Read pep 11 always use 4 spaces for indentation not tab. All these things usually can be ignored, they typically only show up when you print something and things aren't aligned as you expect but with python you are forced to correct those things immediately, forcing you to focus on white space layout issues instead of on the logic of the code. Also, the parser should tell you if you mix tabs and spaces, so that won't trip anything either. Maybe you mean something different than I understand but a program throwing a syntax error because there is a tab instead of a number of spaces or vice versa, is something I would understand as tripping. no more than failing to close a brace in a C like language indentation is the syntax of python you will grow to love it, like most people I found it distracting at first even though i tended to indent other code (inconsistently)to make it readable. -- I am what you will be; I was what you are. Alister i do not ask for changing the actual implementation with indents that the compiler/interpretator work with. What i ask for is some courtesy relative the programmers using IDLE, to incorporate a simple automatic parser that let them who like to write slopy formatted with end instead to do so. And the parser in editor automaticly go in and autoindent *function, loops, if and allow end that the editor autoindent to end of loop. It can not be that hard i have implemented my own python using this... -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence: On 30/10/2013 14:31, jonas.thornv...@gmail.com wrote: Would you please be kind enough to read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython TIA. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence I am all for automatiation to be honest i rather go in change the code for google than do it manual. Maybe those who complain should adress Google? There must be a simple solution or? -- https://mail.python.org/mailman/listinfo/python-list