Well.. keep in mind that numbers are symbols - symbols with an elegant
recursive definition, for that matter.
Anyways, if you want a symbolic result, you could do something like
this (closely related to the other implementation, if you look
closely):
dss=:-:<:3 #.inv 15 21 19 11 5 7
nms=: ;:'n ne se s sw nw'
show11=:3 :0
path=: +/\dss{~nms i.y
furthest=: (i. >./)+/||:path
(symb11 {:path),&<symb11 furthest{path
)
symb11=:3 :0
r=.''
while. 0<+/|y do.
pick=. (i. <./) +/"1|dss -~"1/ y
y=.y-pick{dss
r=.r,pick{nms
end.
r=. /:~r NB. put in cannonical form
r=. (\:~ #~#/.~r) /:~ r
(":,.#/.~ r),.' ',.>~.r
)
show11 10 6 1 1#;:'se ne s nw'
┌─────┬─────┐
│10 se│10 se│
│ 5 ne│ 6 ne│
└─────┴─────┘
Or, if you prefer, you could replace that while loop with an induction:
symb11=:3 :0
seq=. (] - [: {&dss@(i. <./) +/@:|@:-"1/&dss)^:(0<+/@:|)^:a: y
r=. /:~ nms {~ dss i. 2 -/\ seq NB. put in cannonical form
r=. (\:~ #~#/.~r) /:~ r
(":,.#/.~ r),.' ',.>~.r
)
I hope this helps,
--
Raul
On Wed, Dec 13, 2017 at 5:31 PM, Jimmy Gauvin <[email protected]> wrote:
> Comments inline
>
> On Wed, Dec 13, 2017 at 4:55 PM, Raul Miller <[email protected]> wrote:
>
>> This?
>>
>
> Well, kind of ... if all you want are the answers, which makes good
> business sense.
>
> On the other hand, doing it symbolically would take some variant of a
> parser.
>
> PS Really like your 3D coordinates (and their generation scheme)
>
>
>> dss=:-:<:3 #.inv 15 21 19 11 5 7
>> nms=: ;:'n ne se s sw nw'
>> a11=:3 :0
>> ({:,>./)+/||:+/\dss{~nms i.y
>> )
>>
>> a11 10 6 1 1 #;:'se ne s sw'
>> 15 16
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Wed, Dec 13, 2017 at 4:22 PM, Jimmy Gauvin <[email protected]>
>> wrote:
>> > HI,
>> >
>> > I have been thinking about Brian's "cancellation" approach and maybe we
>> can
>> > sort of formalize it.
>> >
>> > Associative relations for cancelling paths:
>> >
>> > 0 = N + S = S + N
>> > 0 = NE + SW = SW + NE
>> > 0 = NW + SE = SE + NW
>> >
>> > Associative relations for simplifying paths:
>> >
>> > N = NE + NW = NW + NE
>> > S = SE + SW = SE + SW
>> > NE = N + SE = SE + N
>> > NW = N + SW = SW + N
>> > SE = S + NE = NE + S
>> > SW = S + NW = NW + S
>> >
>>
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm