Re: [Jprogramming] Fibonacci Encoding

2019-07-22 Thread Raul Miller
On Sat, Jul 20, 2019 at 7:30 AM 'Jon Hough' via Programming wrote: > > Am I making any sense here?" > > Sorry, I am struggling to understand your point. Converting to ASCII > is just to pack the bytes. It seems more purposeful than leaving as > an array of 0s and 1s. It isn't a necessary step, but

Re: [Jprogramming] Fibonacci Encoding

2019-07-20 Thread 'Mike Day' via Programming
FWIW, here’s my code for changing back to decimal representation. z2d =: 3 : 0 if. _1 < <./ y do. +/ #/ y join Fb else. +/ */ y join Fb end. ) join =: 3 : 0 join/ y : l =. - ({:@$x) >. {:@$y r =. (l{."1 x),: l{."1 y if. 2<#$r do. (l{."1 x), l{."1 y end. ) eg d2z 100 1 0 0 0 0 1

Re: [Jprogramming] Fibonacci Encoding

2019-07-20 Thread 'Jon Hough' via Programming
"In other words, it's not the fibonacci part that's the problem for me, it's whatever you are using to convert to ascii that's the problem. (Note also that there's no need to add any 1s into the represented result - you just terminate the sequence by eliminating what would be trailing ascii nul c

Re: [Jprogramming] Fibonacci Encoding

2019-07-20 Thread 'Jon Hough' via Programming
"You mention the possibility of 1 1 1 appearing in an encode result and that making decode awkward without a loop. My guess is that that can happen if you encode multiple numbers into a single result where two adjacent encodings produce the 1 1 1. Is that right?" This is correct. Simplest exampl

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread Roger Hui
Since the Fibonacci numbers grow exponentially (powers of phi, -:1+%:5), the representation is logarithmic and therefore efficient. (For example, "Arabic notation" is logarithmic. Roman numerals are not.) On Thu, Jul 18, 2019 at 9:49 PM Devon McCormick wrote: > So you're decomposing a given

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread Raul Miller
; > >f2=:13 :'{."1([:+/\|.)^:(i.y)1 1' > > > >Fibs2=: 13 :'}.f2 y' > > > >Fibs2 10 > > 1 2 3 5 8 13 21 34 55 > > > >(genfibs 1400)-:Fibs2 1400 > > 1 > >1 > > 1 > > On to underst

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread Raul Miller
7;}.f2 y' > >Fibs2 10 > 1 2 3 5 8 13 21 34 55 > >(genfibs 1400)-:Fibs2 1400 > 1 >1 > 1 > On to understand encode and decode. > > -Original Message- > From: Programming On Behalf Of > 'Jon Hough' via Programming > Sent: T

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread Raul Miller
I understand the fibonacci aspect. Using Roger Hui's code: ,.fsum 449239438124834384923493383837734733747181x 280571172992510140037611932413038677189525 107168651819712326877926895128666735145224 40934782466626840596168752972961528246147 15635695580168194910579363790217849593217 3691087032

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread 'Bo Jacoby' via Programming
The Fibonacci Number System is treated on page 296 in the great book Concrete Mathematics.  https://en.wikipedia.org/wiki/Concrete_MathematicsDen fredag den 19. juli 2019 12.23.43 CEST skrev 'Mike Day' via Programming : Just time to list d2z,  dec to Zeckendorf...   _8{.Fb NB. Revers

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread 'Mike Day' via Programming
Just time to list d2z, dec to Zeckendorf... _8{.Fb NB. Reverse list of fibs... 34 21 13 8 5 3 2 1 d2z. NB. Dec to z 3 : 0 f =. Fb, 0 if. y = 0 do. ,0 return. end. if. y e. f do. (#~>./\ ) Fb = y return.end. reduce =. | }. +/\ inv f&(( (] - I.{[)^:a:)) n =. y NB. 12 ==> 12 4 1 }: (#~>.

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread 'Mike Day' via Programming
I did a quick compare - on the hoof, so briefly- my d2z and z2d, ie decimal-Zeckendorf switches appear faster than decode/encode - no time to say how or why! More later, Mike Sent from my iPad > On 19 Jul 2019, at 01:26, 'Jon Hough' via Programming > wrote: > > The encoding follows the

Re: [Jprogramming] Fibonacci Encoding

2019-07-19 Thread Linda Alvord
e. -Original Message- From: Programming On Behalf Of 'Jon Hough' via Programming Sent: Thursday, July 18, 2019 10:46 AM To: Programming Forum Subject: [Jprogramming] Fibonacci Encoding Positive integers can be encoded using Fibonacci numbers. For the sake of easer, assume Fibo

Re: [Jprogramming] Fibonacci Encoding

2019-07-18 Thread Brian Schott
You mention the possibility of 1 1 1 appearing in an encode result and that making decode awkward without a loop. My guess is that that can happen if you encode multiple numbers into a single result where two adjacent encodings produce the 1 1 1. Is that right? Anyhow, could you produce a workarou

Re: [Jprogramming] Fibonacci Encoding

2019-07-18 Thread Devon McCormick
So you're decomposing a given number into a unique(?) sum of F=.Fibonaccis represented by a Boolean with a 1 for each F? That is, the Boolean does not waste space by representing non-F numbers: the positions 0 1 2 3 4.. represent 1 2 3 5 8...? It looks potentially efficient if you have very large

Re: [Jprogramming] Fibonacci Encoding

2019-07-18 Thread 'Jon Hough' via Programming
The encoding follows the following algorithm: "To encode an integer N: Find the largest Fibonacci number equal to or less than N; subtract this number from N, keeping track of the remainder. If the number subtracted was the ith Fibonacci number F(i), put a 1 in place i−2 in the code word (coun

Re: [Jprogramming] Fibonacci Encoding

2019-07-18 Thread Raul Miller
I'm not quite sure I understand your encoding scheme. Specifically, you're encoding into a sequence of characters, but when decoding, you're not using (8#2)#:a.i.y and it looks like you've cooked up some mechanism to compensate for how |."1#: behaves ... In other words, I think that the fibonacci

Re: [Jprogramming] Fibonacci Encoding

2019-07-18 Thread Roger Hui
See also http://code.jsoftware.com/wiki/Essays/Fibonacci_Sums On Thu, Jul 18, 2019 at 7:57 AM 'Mike Day' via Programming < [email protected]> wrote: > FWIW, I spent some time on Zeckendorf representation a year or so ago. > There’s some Rossetti Code stuff on it. I didn’t get round to sh

Re: [Jprogramming] Fibonacci Encoding

2019-07-18 Thread 'Mike Day' via Programming
FWIW, I spent some time on Zeckendorf representation a year or so ago. There’s some Rossetti Code stuff on it. I didn’t get round to sharing my results, but could do so privately or on the forum if there’s interest. I worked up functions for various arithmetic compositions, including harder o

[Jprogramming] Fibonacci Encoding

2019-07-18 Thread 'Jon Hough' via Programming
Positive integers can be encoded using Fibonacci numbers. For the sake of easer, assume Fibonacci numbers are 1,2,3,5,... (only one 1). We can encode a positive integer uniquely using non-consecutive Fibonacci numbers. For example 4 = 1 + 3 (note: 1 and 3 a re non-consecutive) 5 = 5 (already a Fi