Answer is correct, performance is poor, actually, the poorest:
n=.1e5 to 999999
n
100000 100001 100002 100003 100004 100005 100006 100007 100008 100009 100010
100011 ...
$((1 e."1 [:{.@$@~."1 (1)|: 2}."1 (_2)}."1 (1 0 2)|: (0 1 2)|."0 1/ '
',"1 ":"0@]) #]) n
33219
ts'((1 e."1 [:{.@$@~."1 (1)|: 2}."1 (_2)}."1 (1 0 2)|: (0 1 2)|."0 1/ ''
'',"1 ":"0@]) #]) n'
0.8453641 67116000
Compare to performances in
http://jsoftware.com/pipermail/programming/2021-July/058348.html and below.
R.E. Boss
-----Original Message-----
From: Programming <[email protected]> On Behalf Of
Arthur Anger
Sent: dinsdag 6 juli 2021 06:44
To: [email protected]
Subject: Re: [Jprogramming] Cut
Skip et al.--
I have not closely followed all the various replies to the triple-digit
challenge, but I haven't recognized any really direct approach to the solution.
Mine consists of:
--Format each number as a row of characters --Shift (not rotate) each row twice
relative to itself --Drop the two columns of partial overlap at each end --Take
the Nub of each 3-element column so generated --Find each group containing a
nub of size 1 --Select the corresponding original numbers
It took me a few days to co-ordinate all the proper operations, ranks, and
transposes. Here's the test:
vals=. 123334 122344 121212 111222 112122 555432
((1 e."1 [:{.@$@~."1 (1)|: 2}."1 (_2)}."1 (1 0 2)|: (0 1 2)|."0 1/ ' ',"1
":"0@]) #]) vals
123334 111222 555432
--Art
On Sat, 3 Jul 2021 18:13:15 -0500, Skip Cave <[email protected]> wrote:
Can I use cut to find all the 6-digit integers that have three consecutive
identical digits? Or is there a more efficient way?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm