Nice!

(I feel like I should have seen that...)

Thanks,

-- 
Raul

On Sun, Oct 31, 2021 at 2:27 PM xash <xash@λ.land> wrote:
>
> With mixed bases, for e.g. 3:
> 3 2 1 #: i. 6
>
> An equivalent function of permh is thus:
> (>:@i.@- #: i.@!) 3
>
> If you want to map arbitrary n to a permutation with unknown length,
> you could use something like this (I love J for things like !^:_1):
> (#:~ [:>:@i.@-@<.@>: !^:_1)"0 (2+i.4) NB. needs special cases for 0/1
>
> On Sun Oct 31, 2021 at 4:20 PM CET, Raul Miller wrote:
> > (I really do not know the "right" historical terminology for talking
> > about this, thus the subject line and the odd intro I am using here.)
> >
> > In the Tower of Hanoi puzzle, we move a stack of disks from one tower
> > to another, moving only the top piece.
> >
> > But imagine that we could remove the disks in any order we choose,
> > instead of only moving the top piece each time. And, imagine that
> > instead of having three towers we had only two and that we cannot
> > place disks back in the first tower. And, imagine that we have to put
> > each disk down in the second tower in the order that we removed the
> > disk from the first tower.
> >
> > In other words, this is a setup for generating arbitrary permutations.
> > Except, indexing changes as we progress through the permutation.
> >
> > In other words, the indices of the removed disks for each permutation
> > could be generated this way:
> >
> > permh=: (i.1 0)"_`([: ,/ i. ,"0 1/ $:@<:)@.*
> >
> > For example:
> >
> > permh 3
> > 0 0 0
> > 0 1 0
> > 1 0 0
> > 1 1 0
> > 2 0 0
> > 2 1 0
> >
> > I am wondering if there's a concise way of expressing this using A.
> > (or, some other expression which would eliminate the need to generate
> > all such permutations when finding a specific permutation).
> >
> > Or, failing that, what terms would I search on to find previous work
> > addressing this kind of thinking?
> >
> > Thanks,
> >
> > --
> > Raul
> > ----------------------------------------------------------------------
> > 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