Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25256
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2014-07-06 15:02 -0700 |
| References | (9 earlier) <00c43bf0-1dcd-45f6-ab25-6662e770b0ce@googlegroups.com> <a0a98cd4-2b15-4c71-8108-a3ab66705f65@googlegroups.com> <14887dfc-6279-4e80-aee9-da37c50845b4@googlegroups.com> <229bebfa-500a-4d38-be50-1092fa2ade64@googlegroups.com> <3d5b0993-0ae5-4927-9e5c-857e100bb5da@googlegroups.com> |
| Message-ID | <04dee63d-0161-4642-8980-26199b50ce1f@googlegroups.com> (permalink) |
| Subject | Re: Bijective basechanger |
| From | jonas.thornvall@gmail.com |
Den söndagen den 6:e juli 2014 kl. 23:59:27 UTC+2 skrev jonas.t...@gmail.com:
> Den söndagen den 6:e juli 2014 kl. 20:11:52 UTC+2 skrev jonas.t...@gmail.com:
>
> > Den lördagen den 5:e juli 2014 kl. 21:12:57 UTC+2 skrev Scott Sauyet:
>
> >
>
> > > jonas.thornvall@gmail.com wrote:
>
> >
>
> > >
>
> >
>
> > > > skrev Scott Sauyet:
>
> >
>
> > >
>
> >
>
> > > >> Here is my approach:
>
> >
>
> > >
>
> >
>
> > > >>
>
> >
>
> > >
>
> >
>
> > > >> var zeroless = function(nbr, base) {
>
> >
>
> > >
>
> >
>
> > > >> if (!nbr || nbr === 0) {return "";}
>
> >
>
> > >
>
> >
>
> > > >> if (!base) {base = 10;}
>
> >
>
> > >
>
> >
>
> > > >> var str = "" + nbr.toString(base);
>
> >
>
> > >
>
> >
>
> > > >> var lastChar = str.slice(-1);
>
> >
>
> > >
>
> >
>
> > > >> var beginning = str.slice(0, -1);
>
> >
>
> > >
>
> >
>
> > > >> return lastChar === "0" ?
>
> >
>
> > >
>
> >
>
> > > >> zeroless(parseInt(beginning, base) - 1, base) +
>
> >
>
> > >
>
> >
>
> > > >> (base).toString(base + 1).toUpperCase() :
>
> >
>
> > >
>
> >
>
> > > >> zeroless(parseInt(beginning, base), base) + lastChar;
>
> >
>
> > >
>
> >
>
> > > >> };
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > It works Scott, i checked binary and ternary
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I'm glad it works. But this really wasn't a big leap from
>
> >
>
> > >
>
> >
>
> > > the earlier version I posted that worked only in base 10.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > i must say every time i look at recursive function calls
>
> >
>
> > >
>
> >
>
> > > > it is really hard for me to follow the code, but i probably
>
> >
>
> > >
>
> >
>
> > > > should learn howto code it.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Recursion should generally be IMHO *easier* to understand.
>
> >
>
> > >
>
> >
>
> > > It's the process of breaking your problem down into smaller
>
> >
>
> > >
>
> >
>
> > > sub-problems and solving those.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > This solution works (in base 10) by splitting the digits in
>
> >
>
> > >
>
> >
>
> > > two parts: the final digit and the set up to the final digit.
>
> >
>
> > >
>
> >
>
> > > If the final digit is not zero 0, then we're in the easy case,
>
> >
>
> > >
>
> >
>
> > > and all we do is process the remaining digits and append that
>
> >
>
> > >
>
> >
>
> > > final digit to that result. If that final digit is a 0, then
>
> >
>
> > >
>
> >
>
> > > we have to think of it as a 10, which means we have to subtract
>
> >
>
> > >
>
> >
>
> > > one from the remaining digits before processing them and
>
> >
>
> > >
>
> >
>
> > > appending the "A" for 10. The only thing left is to work out
>
> >
>
> > >
>
> >
>
> > > the base of the recursion, which turns out to be pretty easy,
>
> >
>
> > >
>
> >
>
> > > because we can just check if the number is zero.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > I will try figure out why my while loop approach fail.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > That's probably a good idea.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > Thanks again Scott
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > You're welcome. You could express your gratitude well by
>
> >
>
> > >
>
> >
>
> > > learning to quote appropriately on USENET. Your posts are
>
> >
>
> > >
>
> >
>
> > > very hard to read.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > One final question. Is this actually useful for something?
>
> >
>
> > >
>
> >
>
> > > Or is it mostly a puzzle?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > -- Scott
>
> >
>
> >
>
> >
>
> > Actually it is necessary to be able to factor big primeproducts in none exponential time. I think it was around 4 hours on a 486DX around 1998. Of course the number system itself is not the solution on howto factor large primeproducts, but it is part of the approach how to do it.
>
>
>
> Well that was my use for it back then but it seem it may have some arithmetic benefits. And it is probably also related to compression.
>
>
>
> My math is to none exsitant right now to dwelve into if it is related to
>
> http://mittheory.wordpress.com/
But here is a strong Correlation back to -98
https://www.youtube.com/watch?v=lDlofPAOZy0
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 06:42 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-17 12:08 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 13:23 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 13:24 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-17 13:54 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 14:07 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 14:15 -0700
Re: Bijective basechanger John Harris <niam@jghnorth.org.uk.invalid> - 2014-06-23 17:23 +0100
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 14:23 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-17 14:41 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-17 20:28 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 13:04 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-18 16:30 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 17:45 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 17:49 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-19 11:21 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-19 14:44 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-19 14:48 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-19 14:55 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-19 19:59 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-21 09:25 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-21 11:15 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 18:05 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 18:19 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 18:25 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-18 18:46 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-23 16:00 -0700
Re: Bijective basechanger "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-23 17:51 -0700
Re: Bijective basechanger John Harris <niam@jghnorth.org.uk.invalid> - 2014-06-23 17:18 +0100
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-23 11:27 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-06-23 15:29 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 03:26 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 03:28 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 04:24 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 05:36 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-06-24 13:05 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 14:13 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-25 05:36 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-06-25 12:45 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-06-25 13:15 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-01 02:39 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-07-03 07:33 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-03 09:54 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-04 02:14 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-07-05 12:12 -0700
Re: Bijective basechanger "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-05 22:19 +0200
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-07-05 13:50 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-06 11:11 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-06 14:59 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-06 15:00 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-06 15:02 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-16 23:31 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-07-04 02:28 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-07-05 12:14 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-25 22:38 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 03:32 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 03:44 -0700
Re: Bijective basechanger jonas.thornvall@gmail.com - 2014-06-24 11:10 -0700
Re: Bijective basechanger Scott Sauyet <scott.sauyet@gmail.com> - 2014-06-24 11:45 -0700
Re: Bijective basechanger "Chris M. Thomasson" <no@spam.invalid> - 2014-07-22 12:16 -0700
csiph-web