Yes, I think it was ok to generalise,  but I’d missed what they meant by 
proportionality. 
So, if I define a different quadruplet,
      q=:  6 + 7*1 2 5 10
where 1:2 = 5:10,  Jose’s function works fine:
      (-/ .* % -/ .+)@:(2 2&$) q
6
which is the required offset. 

fwiw, 
   dgcd q. NB. gcd of differences
7
   (|~ dgcd) q
6 6 6 6

Sorry for the confusion,
Mike

Please reply to mike_liz....@tiscali.co.uk.      
Sent from my iPad

> On 15 Aug 2018, at 00:33, Jose Mario Quintana <jose.mario.quint...@gmail.com> 
> wrote:
> 
> After I saw your message I searched for the particular Quora problem and
> this is what I found,
> 
> https://www.quora.com/What-number-must-be-subtracted-from-21-38-55-and-106-each-so-that-the-remainders-technically-differences-are-proportional
> 
> It seems to me that the shape of the array is restricted to be exactly 4
> and the numbers do not have to be integers.  Am I wrong?
> 
> 
> On Tue, Aug 14, 2018 at 7:00 PM, 'Mike Day' via Programming <
> programm...@jsoftware.com> wrote:
> 
>> It should work on arrays of the form
>>   a + b * i,  where a and b are integer scalars, and i is an integer
>> vector.
>> So, if
>>   q=:  6 + 7*1 2 5 11 23,
>> applying this function yields
>>   (-/ .* % -/ .+)@:(2 2&$) q
>> 7.4
>> I think you need instead something like
>> Difference’s greatest common divisor,
>>      dgcd =:  +./@:(2 -~/\ ])
>> So
>>      dgcd q
>> 7
>> 
>> It’s a bit more complicated to recover the factors, 1 2 5 ..., which seem
>> to be required in the Quora problem:
>>   (](([-|~)%])dgcd) q
>> 1 2 5 11 23
>> This works for the original array, too,
>>      (](([-|~)%])dgcd) 21 38 55 106
>> 1 2 3 6
>> 
>> And
>>      dgcd 21 38 55 106
>> 17
>> 
>> Sorry for any formatting problems - typing on iPad,
>> 
>> Mike
>> 
>> 
>> Please reply to mike_liz....@tiscali.co.uk.
>> Sent from my iPad
>> 
>>> On 14 Aug 2018, at 23:18, Jose Mario Quintana <
>> jose.mario.quint...@gmail.com> wrote:
>>> 
>>> (-/ .* % -/ .+)@:(2 2&$)21 38 55 106
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to