Hi all,

I just started reading

https://code.jsoftware.com/wiki/Doc/Articles/Play202

and tried to make up a solution

rehrperm =: 3 : 'if.1>:y do.,:y$0 else.,/ (i.y) ,"0 1 (rehrperm <:y) {"2 1 (-."1 0)~ i.y end.'

I didn’t use if.do.end. nor did I care for
calls with y < 1 but changed this after
I finished reading the article where I found
Roger Hui’s solution to not be far from mine:

huiperm =: 3 : 'if.1>:y do.,:y$0 else.,/(0,.huiperm&.<:y){"2 1\:"1=i.y end.'

so you see it’s really mostly the same

Here’s a comparison

   1e3 timespacex 'huiperm 9'
0.0560188 7.55032e7

   1e3 timespacex 'rehrperm 9'
0.088764 1.04862e8

I’m glad to not be too far off Hui’s performance,
“only” factors 1.6 and 1.4, respectively.

--
----------------------
mail written using NEO
neo-layout.org

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to