[Jprogramming] Zig Zag problem
'Mike Day' via Programming
programming at jsoftware.com
Fri Sep 30 11:04:07 UTC 2016
You (Erling) said (earlier) "And what did I and Henry do? /Erling"
In reply to both messages (this and the previous one), I was only trying
to deal with David Lambert's message/enquiry about confidence in the
results. No criticism intended.
As I suggested towards the end of that tedious attempt at explanation, I
think the insight that it's sufficient to sort 0 1 2 3 2 1 0 2 3 ... or
whatever
is brilliant.
Mike
On 30/09/2016 11:18, Erling Hellenäs wrote:
> It seems like there should be a way to generate the indexes directly
> and skip the sort. I did not find an easy way to do this. You Mike
> solved it but the solution seemed a little complicated. /Erling
>
>
> On 2016-09-30 00:27, 'Mike Day' via Programming wrote:
>> It's easier to see if we stick to indices rather than an arbitrary
>> string.
>>
>> Indices of elements in descending vertical columns in the zig-zag layout
>> for m rows belong to
>> (i.m) + 2 * (m-1) * i. n ,
>> where n is sufficient to exhaust the array,
>> and indices of the RISING diagonals are, for m>1,
>> m + (i.m-2) + 2 * (m-1) * i.n ,
>> but we really need them in the descending direction, so we require
>> m + (i.2-m) + 2 * (m-1) * i.n,
>> so the indices in the final array will be :
>> top row:
>> (1 >. 2*(m-1)) * i.n
>> intermediate rows 0<k<m, (if m>2) :
>> k, (k+2*(m-(1+k))), ... , (k + 2*i*(m-1)),(k + (2*i*(m-1)) +
>> 2*(m-(1+k))) ...
>> bottom row, if m>1:
>> (m-1) + 2*(m-1) * i.n
>>
>> It's easier to see with a specific example; eg for m = 4:
>> The zigzag tableau:
>> 0 8 16
>> 1 7 9 15 17
>> 2 6 10 14 18
>> 3 5 11 13 19
>> 4 12 ....
>> becomes:
>> 0 8 16 ... 1 7 9 15 17 ... 2 6 10 14 18 ... 3 5 11 13 19 ... 4 12 ...
>>
>> which the various verbs do return:
>> 4 cv i.20
>> 0 6 12 18 1 5 7 11 13 17 19 2 4 8 10 14 16 3 9 15
>>
>> or, for a longer string,
>> 4 cv i.30
>> 0 6 12 18 24 1 5 7 11 13 17 19 23 25 29 2 4 8 10 14 16 20 22 26 28 3
>> 9 15 21 27
>>
>> No doubt Roger could "prove" the result as a J theorem.
>>
>> It's a beautiful leap of insight to see that labelling the tableau as
>> follows:
>> 0 0 0
>> 1 1 1 1 1
>> 2 2 2 2 2
>> 3 3 3 3 3
>> 4 4 ....
>>
>> shows that the much simpler
>> /: 0 1 2 3 4 3 2 1 0 1 2 3 ...
>> does the trick.
>>
>> Any use,
>> Mike
>>
>>
>>
>> On 29/09/2016 22:19, David Lambert wrote:
>>>
>>> Foul mood day, beware!
>>>
>>> 1) there are no examples for other than 3 rows. How can you tell if
>>> a solution is correct in general?
>>>
>>> 2) Pepe proved, by tacitly implementing a Turing machine, that tacit
>>> j is Turing complete. Hence the problem can be solved tacitly if
>>> it's amenable to machine solution.
>>>
>>> On 09/28/2016 08:00 AM, programming-request at forums.jsoftware.com wrote:
>>>> Date: Wed, 28 Sep 2016 00:59:06 +0000 (UTC)
>>>> From: "'Jon Hough' via Programming"<programming at jsoftware.com>
>>>> To:<programming at jsoftware.com>
>>>> Subject: Re: [Jprogramming] Zig Zag problem
>>>> Message-ID:<278656873.5830960.1475024346493 at mail.yahoo.com>
>>>> Content-Type: text/plain; charset=UTF-8
>>>>
>>>> Yes, thanks. I didn't think this problem could be solved purely
>>>> tacitly, but seems I was wrong.
>>>>
>>>> By the way, small nitpick, but your solution fails for the case of
>>>> number of rows = 1:
>>>> 1 tconvert 'SOMETEXT'
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the Programming
mailing list