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


Groups > comp.lang.javascript > #24895 > unrolled thread

Bijective basechanger

Started byjonas.thornvall@gmail.com
First post2014-06-17 06:42 -0700
Last post2014-07-22 12:16 -0700
Articles 20 on this page of 60 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

Page 3 of 3 — ← Prev page 1 2 [3]


#25151

Fromjonas.thornvall@gmail.com
Date2014-07-01 02:39 -0700
Message-ID<841ac7ab-d05e-43ea-9b43-65c99ca623b9@googlegroups.com>
In reply to#25027
Den onsdagen den 25:e juni 2014 kl. 22:15:24 UTC+2 skrev Scott Sauyet:
> Scott Sauyet wrote:
> 
> 
> 
> > And I can see why that bug is there, but not a quick way to fix it.  It 
> 
> > probably warrants a better approach.  If I find time, I will see if I can
> 
> > come up with one.
> 
> 
> 
> This might work better:
> 
> 
> 
>     var zeroless = function(str) {
> 
>         if (!str || str === "0") {return "";}
> 
>         var lastChar = str.slice(-1);
> 
>         var beginning = str.slice(0, -1);
> 
>         return lastChar === "0" ? 
> 
>                zeroless("" + (beginning - 1)) + "A" :
> 
>                zeroless(beginning) + lastChar;
> 
>     };           
> 
> 
> 
> It is certainly much cleaner and more elegant.
> 
> 
> 
> It would not be hard to extend to other bases.
> 
> 
> 
> Does it capture all your test cases?
> 
> 
> 
>   -- Scott

It work good for base 10 but i get collisions using both your and my script using other bases.

http://web.comhem.se/jonasth/bijbase.html

Encoding 30 in base 3 should be 233=2(3^2)+2(3^1)+3(3^0) but encode to 33=9.
Encoding 10 in base 2 should be 122=1(2^2)+2(2^1)+2(2^0) but encode to 22=6.
 
Do you see a possible fix?

I also will try encode the result to base 26 as the standard input bases encodes to in script, rather then use space separation.

[toc] | [prev] | [next] | [standalone]


#25198

FromScott Sauyet <scott.sauyet@gmail.com>
Date2014-07-03 07:33 -0700
Message-ID<00c43bf0-1dcd-45f6-ab25-6662e770b0ce@googlegroups.com>
In reply to#25151
On Tuesday, July 1, 2014 5:39:05 AM UTC-4, jonas.t...@gmail.com wrote:
>skrev Scott Sauyet:
>> This might work better:
>> 
>>     var zeroless = function(str) {
>>         if (!str || str === "0") {return "";}
>>         var lastChar = str.slice(-1);
>>         var beginning = str.slice(0, -1);
>>         return lastChar === "0" ? 
>>                zeroless("" + (beginning - 1)) + "A" :
>>                zeroless(beginning) + lastChar;
>>     };           
>> 
>> It is certainly much cleaner and more elegant.
>> 
>> It would not be hard to extend to other bases.
> 
> It work good for base 10 but i get collisions using both your and my
> script using other bases.
> 
> http://web.comhem.se/jonasth/bijbase.html
> 
> Encoding 30 in base 3 should be 233=2(3^2)+2(3^1)+3(3^0) but 
> encode to 33=9.
> 
> Encoding 10 in base 2 should be 122=1(2^2)+2(2^1)+2(2^0) but 
> encode to 22=6.

Did you actually try to update this for other bases?  I hadn't done the
work here, leaving it as "an exercise for the reader".

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;
    };

I think it captures those cases as well.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#25199

Fromjonas.thornvall@gmail.com
Date2014-07-03 09:54 -0700
Message-ID<1c2765a2-fc63-4692-b780-b1b3f11ed592@googlegroups.com>
In reply to#25198
Den torsdagen den 3:e juli 2014 kl. 16:33:05 UTC+2 skrev Scott Sauyet:
> On Tuesday, July 1, 2014 5:39:05 AM UTC-4, jonas.t...@gmail.com wrote:
> 
> >skrev Scott Sauyet:
> 
> >> This might work better:
> 
> >> 
> 
> >>     var zeroless = function(str) {
> 
> >>         if (!str || str === "0") {return "";}
> 
> >>         var lastChar = str.slice(-1);
> 
> >>         var beginning = str.slice(0, -1);
> 
> >>         return lastChar === "0" ? 
> 
> >>                zeroless("" + (beginning - 1)) + "A" :
> 
> >>                zeroless(beginning) + lastChar;
> 
> >>     };           
> 
> >> 
> 
> >> It is certainly much cleaner and more elegant.
> 
> >> 
> 
> >> It would not be hard to extend to other bases.
> 
> > 
> 
> > It work good for base 10 but i get collisions using both your and my
> 
> > script using other bases.
> 
> > 
> 
> > http://web.comhem.se/jonasth/bijbase.html
> 
> > 
> 
> > Encoding 30 in base 3 should be 233=2(3^2)+2(3^1)+3(3^0) but 
> 
> > encode to 33=9.
> 
> > 
> 
> > Encoding 10 in base 2 should be 122=1(2^2)+2(2^1)+2(2^0) but 
> 
> > encode to 22=6.
> 
> 
> 
> Did you actually try to update this for other bases?  I hadn't done the
> 
> work here, leaving it as "an exercise for the reader".
> 
> 
> 
> 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;
> 
>     };
> 
> 
> 
> I think it captures those cases as well.
> 
> 
> 
>   -- Scott

I will check it tomorrow and report back on the progress, thank you Scott.

[toc] | [prev] | [next] | [standalone]


#25202

Fromjonas.thornvall@gmail.com
Date2014-07-04 02:14 -0700
Message-ID<a0a98cd4-2b15-4c71-8108-a3ab66705f65@googlegroups.com>
In reply to#25198
Den torsdagen den 3:e juli 2014 kl. 16:33:05 UTC+2 skrev Scott Sauyet:
> On Tuesday, July 1, 2014 5:39:05 AM UTC-4, jonas.t...@gmail.com wrote:
> 
> >skrev Scott Sauyet:
> 
> >> This might work better:
> 
> >> 
> 
> >>     var zeroless = function(str) {
> 
> >>         if (!str || str === "0") {return "";}
> 
> >>         var lastChar = str.slice(-1);
> 
> >>         var beginning = str.slice(0, -1);
> 
> >>         return lastChar === "0" ? 
> 
> >>                zeroless("" + (beginning - 1)) + "A" :
> 
> >>                zeroless(beginning) + lastChar;
> 
> >>     };           
> 
> >> 
> 
> >> It is certainly much cleaner and more elegant.
> 
> >> 
> 
> >> It would not be hard to extend to other bases.
> 
> > 
> 
> > It work good for base 10 but i get collisions using both your and my
> 
> > script using other bases.
> 
> > 
> 
> > http://web.comhem.se/jonasth/bijbase.html
> 
> > 
> 
> > Encoding 30 in base 3 should be 233=2(3^2)+2(3^1)+3(3^0) but 
> 
> > encode to 33=9.
> 
> > 
> 
> > Encoding 10 in base 2 should be 122=1(2^2)+2(2^1)+2(2^0) but 
> 
> > encode to 22=6.
> 
> 
> 
> Did you actually try to update this for other bases?  I hadn't done the
> 
> work here, leaving it as "an exercise for the reader".
> 
> 
> 
> 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;
> 
>     };
> 
> 
> 
> I think it captures those cases as well.
> 
> 
> 
>   -- Scott

It works Scott, i checked binary and ternary 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. I will try figure out why my while loop approach fail.

Andover CT seem to be quite a beautiful little town, very Sleep Hollow spirit over it all.

Thanks again Scott

[toc] | [prev] | [next] | [standalone]


#25223

FromScott Sauyet <scott.sauyet@gmail.com>
Date2014-07-05 12:12 -0700
Message-ID<14887dfc-6279-4e80-aee9-da37c50845b4@googlegroups.com>
In reply to#25202
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

[toc] | [prev] | [next] | [standalone]


#25227

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2014-07-05 22:19 +0200
Message-ID<XnsA361E317EDF65eejj99@194.109.133.133>
In reply to#25223
Scott Sauyet <scott.sauyet@gmail.com> wrote on 05 jul 2014 in 
comp.lang.javascript:

> Recursion should generally be IMHO *easier* to understand.
> It's the process of breaking your problem down into smaller
> sub-problems and solving those.

*Recursion* is the calling of a function by itself 
for a [possibly large] number of times, 
with varying parameters. Example:

================================
function fibonacci(n) {
  return (n<2) ?n :fibonacci(n-1) + fibonacci(n-2);
};

var x = 20;
document.write( x + ": " + fibonacci(x) + '<br>' );
================================

*Breaking your problem down into smaller sub-problems*
is called "modular programming". 


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#25228

FromScott Sauyet <scott.sauyet@gmail.com>
Date2014-07-05 13:50 -0700
Message-ID<663c3ce6-51a8-41ed-b8c6-cde5d96ab5eb@googlegroups.com>
In reply to#25227
Evertjan. wrote:
> Scott Sauyet wrote: 
>> Recursion should generally be IMHO *easier* to understand.
>> It's the process of breaking your problem down into smaller
>> sub-problems and solving those.
> 
> *Recursion* is the calling of a function by itself 
> for a [possibly large] number of times, 
> with varying parameters. Example:

Yes, of course.  I should not have said "the process" but
"a process".  It was pretty clear from context that the OP
understood that recursion involved a function calling itself
(even that is not fully accurate, but it will do.)  What he
didn't seem to get was *why*.  That's what I was trying to
explain.  Thanks for the clarification.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#25251

Fromjonas.thornvall@gmail.com
Date2014-07-06 11:11 -0700
Message-ID<229bebfa-500a-4d38-be50-1092fa2ade64@googlegroups.com>
In reply to#25223
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.

[toc] | [prev] | [next] | [standalone]


#25254

Fromjonas.thornvall@gmail.com
Date2014-07-06 14:59 -0700
Message-ID<3d5b0993-0ae5-4927-9e5c-857e100bb5da@googlegroups.com>
In reply to#25251
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/

[toc] | [prev] | [next] | [standalone]


#25255

Fromjonas.thornvall@gmail.com
Date2014-07-06 15:00 -0700
Message-ID<58ec0c78-3f2a-447d-9cd9-0ef7e669e472@googlegroups.com>
In reply to#25254
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

[toc] | [prev] | [next] | [standalone]


#25256

Fromjonas.thornvall@gmail.com
Date2014-07-06 15:02 -0700
Message-ID<04dee63d-0161-4642-8980-26199b50ce1f@googlegroups.com>
In reply to#25254
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

[toc] | [prev] | [next] | [standalone]


#25414

Fromjonas.thornvall@gmail.com
Date2014-07-16 23:31 -0700
Message-ID<299995f1-7c3f-4356-8d44-47cbe9461a4c@googlegroups.com>
In reply to#25223
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

Well i decided to recode my general purpose basechanger "not bijective".
Feel free to comment, i seem unable to get rid of the fact it create leading zeroes.

The old version below it.

<script language=Javascript>
function encbase(number, bas)
{
   basestr = "";
   basemultip = 1;
   digit = 1;

   while (basemultip < number)
   {
      basemultip = basemultip * bas;
      digit = digit + 1;
   }

   while (number > 0 && digit > 0)
   {
      set = 0;
      i = 0;
      while (i * basemultip <= number && i < bas)
      {
         j = i;
         i ++ ;
         set = 1;
      }
      if (set == 1)
      {
         subtrahend = basemultip * j;
         number = number - subtrahend;
         basestr = basestr + j + " ";
      }
      else if (set == 0 && number != 0)basestr = basestr + 0 + " ";
      basemultip = basemultip / bas;
      digit -- ;
   }
   while (digit > 0)
   {
      basestr = basestr + 0 + " ";
      digit -- ;
   }
   return basestr;
}
bas = 3;
k = 30;
for(k = 1; k < 1000; k ++ )
{
   encbase(k, bas);
   document.write(k, " = ", basestr, "<BR>");
}
</script>


Here comes the old version

function encbase(number, bas)
{
   basestr = "";
   basemultip = 1;
   digit = 0;
   unr = 0;
   while (basemultip < number)
   {
      basemultip = basemultip * bas;
      digit = digit + 1;
   }
   while (number > 0)
   {
      unr ++ ;
      set = 0;
      for(i = bas; i > 0; i -- )
      {
         subtrahend = basemultip * i;
         if (number >= subtrahend)
         {
            number = number - subtrahend;
            set = 1;
            basestr = basestr + i + " ";
         }
      }
      if(set == 0 && number != 0)basestr = basestr + 0 + " ";
      basemultip = basemultip / bas;
   }
   while (digit >= unr)
   {
      basestr = basestr + 0 + " ";
      unr ++ ;
   }
   return basestr;
}

[toc] | [prev] | [next] | [standalone]


#25203

Fromjonas.thornvall@gmail.com
Date2014-07-04 02:28 -0700
Message-ID<cc8f85ab-a8bd-4d1e-b179-bf63584d8023@googlegroups.com>
In reply to#25198
Den torsdagen den 3:e juli 2014 kl. 16:33:05 UTC+2 skrev Scott Sauyet:
> On Tuesday, July 1, 2014 5:39:05 AM UTC-4, jonas.t...@gmail.com wrote:
> 
> >skrev Scott Sauyet:
> 
> >> This might work better:
> 
> >> 
> 
> >>     var zeroless = function(str) {
> 
> >>         if (!str || str === "0") {return "";}
> 
> >>         var lastChar = str.slice(-1);
> 
> >>         var beginning = str.slice(0, -1);
> 
> >>         return lastChar === "0" ? 
> 
> >>                zeroless("" + (beginning - 1)) + "A" :
> 
> >>                zeroless(beginning) + lastChar;
> 
> >>     };           
> 
> >> 
> 
> >> It is certainly much cleaner and more elegant.
> 
> >> 
> 
> >> It would not be hard to extend to other bases.
> 
> > 
> 
> > It work good for base 10 but i get collisions using both your and my
> 
> > script using other bases.
> 
> > 
> 
> > http://web.comhem.se/jonasth/bijbase.html
> 
> > 
> 
> > Encoding 30 in base 3 should be 233=2(3^2)+2(3^1)+3(3^0) but 
> 
> > encode to 33=9.
> 
> > 
> 
> > Encoding 10 in base 2 should be 122=1(2^2)+2(2^1)+2(2^0) but 
> 
> > encode to 22=6.
> 
> 
> 
> Did you actually try to update this for other bases?  I hadn't done the
> 
> work here, leaving it as "an exercise for the reader".
> 
> 
> 
> 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;
> 
>     };
> 
> 
> 
> I think it captures those cases as well.
> 
> 
> 
>   -- Scott

Are you by any chance the same person who sometime post/used to post at sci.crypt (Scott bijective)?

[toc] | [prev] | [next] | [standalone]


#25224

FromScott Sauyet <scott.sauyet@gmail.com>
Date2014-07-05 12:14 -0700
Message-ID<c5bfdd35-60a5-4898-aba1-eecb1cfc5e19@googlegroups.com>
In reply to#25203
jonas.thornvall@gmail.com wrote: 
> Are you by any chance the same person who sometime 
> post/used to post at sci.crypt (Scott bijective)?

Nope, sorry.  I've posted on sci.math, but not in years,
and never to my recollection on sci.crypt.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#25038

Fromjonas.thornvall@gmail.com
Date2014-06-25 22:38 -0700
Message-ID<21a3cdad-7770-45e0-a44b-3f282aba376b@googlegroups.com>
In reply to#25010
Den tisdagen den 24:e juni 2014 kl. 22:05:12 UTC+2 skrev Scott Sauyet:
> jonas.thornvall@gmail.com wrote: 
> 
> 
> 
> > It seem like i use two different encoding schemes / read outs, but
> 
> > are both consistent and without collsions?
> 
> > 
> 
> > Enc1.  2010=19AA positional
> 
> > 
> 
> > Enc2.  2010=1AA grouped
> 
> 
> 
> I don't understand that second one.  But obviously 210 => 1AA by the
> 
> encoding used elsewhere.
> 
> 
> 
>   -- Scott

Well enc 2 is a more free approach to encode things where you simply attach strings it *probably* ain't that good for arithmetics.

"1A"+"A" ="2010" 

[toc] | [prev] | [next] | [standalone]


#24997

Fromjonas.thornvall@gmail.com
Date2014-06-24 03:32 -0700
Message-ID<ab540b6c-2f95-4e94-b634-27273f27ef45@googlegroups.com>
In reply to#24981
Den tisdagen den 24:e juni 2014 kl. 00:29:57 UTC+2 skrev Scott Sauyet:
> jonas.thornvall@gmail.com wrote:
> 
> > 10=A
> 
> > 100=9A
> 
> > 1000=99A
> 
> > ...
> 
> > 2000=199A
> 
> > 2001=19A1
> 
> > 2010=19AA
> 
> > 2014=1A14
> 
> >
> 
> > 1091020134=????????? Brainteaser
> 
> >
> 
> > A generic basechanger for anybase is rather easy to accomplish, but i am
> 
> > a bit stumped where to start with doing conversion into bijective bases,
> 
> > i was thinking counting up the base multiples upto the number to
> 
> > convert, and bone it out from there saving the differences. But i just
> 
> > can't recall howto do it.
> 
> >
> 
> > Is there an easy obvious way todo this?
> 
> 
> 
> Is this the sort of thing you're looking for?
> 
> 
> 
>     var zeroless = function(str) {return str.split("").reverse().map(
> 
>     (function() {
> 
>       var borrow = false;
> 
>       return function(ch, idx, arr) {
> 
>         ch = + ch;
> 
>         if (borrow) (ch = (ch == 0) ? 9: ch - 1);
> 
>         if (ch == 0 && idx == arr.length - 1) {return '';}
> 
>         borrow = (ch == 0 || ch == 9);
> 
>         return (ch == 0) ? 'A' : ch;
> 
>       };
> 
>     }())).reverse().join("");};
> 
> 
> 
>     zeroless("100"); //=> "9A"
> 
>     zeroless("2010"); //=> "19AA", etc.
> 
> 
> 
> You could easily extend it to an arbitrary base (up to 35, I suppose),
> 
> by adding a `base` parameter and replacing the 9's with `(base - 1)`
> 
> and the `'A'` with `(base).toString(base + 1).toUpperCase()`.
> 
> 
> 
> And by the way, this reports:
> 
> 
> 
>     zeroless("1091020134") //=> "A8AA1A134"
> 
> 
> 
> Is there some point to this, or is it just a puzzle?
> 
> 
> 
>   -- Scott
Most bases has special applications and zeroless is necessary for factorisation of big numbers.

[toc] | [prev] | [next] | [standalone]


#24998

Fromjonas.thornvall@gmail.com
Date2014-06-24 03:44 -0700
Message-ID<4b0a18e8-fb1b-49c9-9704-a3f4a1eef879@googlegroups.com>
In reply to#24981
Den tisdagen den 24:e juni 2014 kl. 00:29:57 UTC+2 skrev Scott Sauyet:
> jonas.thornvall@gmail.com wrote:
> 
> > 10=A
> 
> > 100=9A
> 
> > 1000=99A
> 
> > ...
> 
> > 2000=199A
> 
> > 2001=19A1
> 
> > 2010=19AA
> 
> > 2014=1A14
> 
> >
> 
> > 1091020134=????????? Brainteaser
> 
> >
> 
> > A generic basechanger for anybase is rather easy to accomplish, but i am
> 
> > a bit stumped where to start with doing conversion into bijective bases,
> 
> > i was thinking counting up the base multiples upto the number to
> 
> > convert, and bone it out from there saving the differences. But i just
> 
> > can't recall howto do it.
> 
> >
> 
> > Is there an easy obvious way todo this?
> 
> 
> 
> Is this the sort of thing you're looking for?
> 
> 
> 
>     var zeroless = function(str) {return str.split("").reverse().map(
> 
>     (function() {
> 
>       var borrow = false;
> 
>       return function(ch, idx, arr) {
> 
>         ch = + ch;
> 
>         if (borrow) (ch = (ch == 0) ? 9: ch - 1);
> 
>         if (ch == 0 && idx == arr.length - 1) {return '';}
> 
>         borrow = (ch == 0 || ch == 9);
> 
>         return (ch == 0) ? 'A' : ch;
> 
>       };
> 
>     }())).reverse().join("");};
> 
> 
> 
>     zeroless("100"); //=> "9A"
> 
>     zeroless("2010"); //=> "19AA", etc.
> 
> 
> 
> You could easily extend it to an arbitrary base (up to 35, I suppose),
> 
> by adding a `base` parameter and replacing the 9's with `(base - 1)`
> 
> and the `'A'` with `(base).toString(base + 1).toUpperCase()`.
> 
> 
> 
> And by the way, this reports:
> 
> 
> 
>     zeroless("1091020134") //=> "A8AA1A134"
> 
> 
> 
> Is there some point to this, or is it just a puzzle?
> 
> 
> 
>   -- Scott

Try zeroless binary and ternary
1=1
2=2
11=3
12=4
21=5
22=6
111=7
112=8
121=9
122=10

[toc] | [prev] | [next] | [standalone]


#25006

Fromjonas.thornvall@gmail.com
Date2014-06-24 11:10 -0700
Message-ID<8c65ce0f-a999-4b0a-b571-ced9631f0c37@googlegroups.com>
In reply to#24981
Den tisdagen den 24:e juni 2014 kl. 00:29:57 UTC+2 skrev Scott Sauyet:
> jonas.thornvall@gmail.com wrote:
> 
> > 10=A
> 
> > 100=9A
> 
> > 1000=99A
> 
> > ...
> 
> > 2000=199A
> 
> > 2001=19A1
> 
> > 2010=19AA
> 
> > 2014=1A14
> 
> >
> 
> > 1091020134=????????? Brainteaser
> 
> >
> 
> > A generic basechanger for anybase is rather easy to accomplish, but i am
> 
> > a bit stumped where to start with doing conversion into bijective bases,
> 
> > i was thinking counting up the base multiples upto the number to
> 
> > convert, and bone it out from there saving the differences. But i just
> 
> > can't recall howto do it.
> 
> >
> 
> > Is there an easy obvious way todo this?
> 
> 
> 
> Is this the sort of thing you're looking for?
> 
> 
> 
>     var zeroless = function(str) {return str.split("").reverse().map(
> 
>     (function() {
> 
>       var borrow = false;
> 
>       return function(ch, idx, arr) {
> 
>         ch = + ch;
> 
>         if (borrow) (ch = (ch == 0) ? 9: ch - 1);
> 
>         if (ch == 0 && idx == arr.length - 1) {return '';}
> 
>         borrow = (ch == 0 || ch == 9);
> 
>         return (ch == 0) ? 'A' : ch;
> 
>       };
> 
>     }())).reverse().join("");};
> 
> 
> 
>     zeroless("100"); //=> "9A"
> 
>     zeroless("2010"); //=> "19AA", etc.
> 
> 
> 
> You could easily extend it to an arbitrary base (up to 35, I suppose),
> 
> by adding a `base` parameter and replacing the 9's with `(base - 1)`
> 
> and the `'A'` with `(base).toString(base + 1).toUpperCase()`.
> 
> 
> 
> And by the way, this reports:
> 
> 
> 
>     zeroless("1091020134") //=> "A8AA1A134"
> 
> 
> 
> Is there some point to this, or is it just a puzzle?
> 
> 
> 
>   -- Scott

Your Javascript function calling technic is far for advanced for me i thought you called the functions with str as argument and the result was stored in zeroless?

How can i run it?

<script type="text/javascript">
str = 902310;

 var zeroless = function(str) {return str.split("").reverse().map(
    (function() {
      var borrow = false;
      return function(ch, idx, arr) {
        ch = + ch;
        if (borrow) (ch = (ch == 0) ? 9: ch - 1);
        if (ch == 0 && idx == arr.length - 1) {return '';}
        borrow = (ch == 0 || ch == 9);
        return (ch == 0) ? 'A' : ch;
      };
    }())).reverse().join("");}; 

document.write(zeroless);
</script>

[toc] | [prev] | [next] | [standalone]


#25008

FromScott Sauyet <scott.sauyet@gmail.com>
Date2014-06-24 11:45 -0700
Message-ID<76ea0a63-d652-41ff-a50c-e2fa064e7d48@googlegroups.com>
In reply to#25006
jonas.thornvall@gmail.com wrote: 
> skrev Scott Sauyet:
>> jonas.thornvall@gmail.com wrote:

>> Is this the sort of thing you're looking for?
>> 
>>    var zeroless = function(str) {
>>      // [... function body elided ... ]  
>>    };
>> [ ... ]
>>    zeroless("1091020134") //=> "A8AA1A134"
> 
> Your Javascript function calling technic is far for advanced for
> me i thought you called the functions with str as argument and 
> the result was stored in zeroless?

No that is a function definition.  I defined the function named
`zeroless`.  In this case it's much the equivalent of 

    function zeroless(str) {
      // ...
    }
    
although there are some significant differences between the techniques.

 
> How can i run it?

    var result = zeroless("902310");
    
    // then do what you want wtih `result`, including `console.log`ging 
    // it, `document.write`ing it, or whatever else.

Best of luck,

  -- Scott

[toc] | [prev] | [next] | [standalone]


#25530

From"Chris M. Thomasson" <no@spam.invalid>
Date2014-07-22 12:16 -0700
Message-ID<lqmdat$mq9$1@speranza.aioe.org>
In reply to#24895
> wrote in message 
> news:e8847026-67f9-417c-9166-d1368bb9a704@googlegroups.com...
> [...]

FWIW, you might be interested in the following code:

https://gist.github.com/zumbojo/1073996







[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | comp.lang.javascript


csiph-web