Ambrus wrote:
> I'd like to know about a nice way to generate
> ... Gijswijt's sequence ... A090822 in the OEIS
> http://www.research.att.com/~njas/sequences/A090822
I'd have to spend some time to come up with a "nice" way, but a
transliteration of the OEIS sequence description renders:
A090822=:(,>./@:((](0:i.~-:"_
_1)&>(<@(]\)~-@:#&>))<\)@:|.)^:(<:`(,@:1:))
A090822 9
1 1 2 1 1 2 2 2 3
Sanity check:
a090822 =: 0 ". TAB -.~ LF&=`(,:& ' ') } noun define
1 1 2 1 1 2 2 2 3 1 1 2 1 1 2 2 2 3 2 1 1
2 1 1 2 2 2 3 1 1 2 1 1 2 2 2 3 2 2 2 3 2
2 2 3 3 2 1 1 2 1 1 2 2 2 3 1 1 2 1 1 2 2
2 3 2 1 1 2 1 1 2 2 2 3 1 1 2 1 1 2 2 2 3
2 2 2 3 2 2 2 3 3 2 2 2 3 2 1
)
assert (-: A090822@:#) a090822
I may not get the time to nicen up the verb, but if I did, I might start
with the richer/more sophisticated affix primitives (e.g. using \.
[suffixes] to obviate the |., or E. to eliminate the ]\ etc), or maybe use
cutesy tricks like *./\ to determine how many repetitions occur in series.
That sort of thing. Of course, these changes would maintain the fundamental
"structural" character of the solution (focusing on shapes and indexes,
rather than values).
I expect some of the more mathematically-minded Jers could come up with a
value-oriented verb that would surpass in elegance any structural approach.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm