Can I use cut to find all the 6-digit integers that have three consecutive
identical digits? Or is there a more efficient way?

sep=:10#.^:_1] NB. Separate digits.

to=:[+i.@:>:@-~ NB. Generate integer ranges.


$ sn=.sep n=.1e5 to 999999 NB. Generate all the 6 digit integers and
separate their digits.

900000 6

Now what? Can I apply cut to sn to find all 6-digit integers with three
consecutive identical digits? Or is there a better way?


123334 is correct

122344 is not correct

121212 is not correct

111222 is correct

112122 is not correct

555432 is correct


NB. Test vector: tv=. 123334 122344 121212 111222 112122 555432

Skip


Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to