One can cheat the Rosetta Code task for topswops by using a much faster solution:

topswop=: |.@{.,}.
topswopz=: [: ;](] <@,"_ 1 (topswop"0 1 {:))L:0~(1+[:I.(=1+i.@#)@{:)L:0

i,.0, ([: # 0 {:: _2 {[: topswopz^:(0<#)^:a: [: (<@,:@topswop"0 1~}.) >:@i.)"0 }.i=.1+i.10
 1  0
 2  1
 3  2
 4  4
 5  7
 6 10
 7 16
 8 22
 9 30
10 38

This version is like sequence OEIS A000376 instead of A000375. They differ for the first time at N=12.

For the requirements of the task it is sufficient I think. I used this as an alternative but deleted it once I figured out it was a different sequence.


What do you think?  Entering it anyway?


--
Met vriendelijke groet,
@@i = Arie Groeneveld

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

Reply via email to