Here’s one implementation of what I’d suggested for construction from all
3-digit representations of 0-999, working in characters rather than numerals.
Staying in characters saves time and space, not shown here, compared to
evaluating the representations. Also, I’m pre-evaluating the 3-digit
representations, so timing and sizing the calculation, below, might be
misleading, compared, say, to sd3, which includes the calculation of all
numbers from 1000 to 9999.
Alignment ok in fixed font!
d3 =: }."1 ":,.1000+i.1000 NB. 3 digit strings,
'000','001'...'999'
trips =: |: 3 10$'0123456789' NB. identical triples:
'000','111'....
exp =: ,/@:(0 1 2 3(|."0 1/)(,/@:(,"1/)))NB. Expand 3dig nums with triples
clean =: ~.@: #~'0'~:{."1 NB. Unique elements of required 6dig
nums
$clean d3 exp trips
33219 6
({~5?# )clean d3 exp trips
691777
722254
780009
575999
588854
It’s apparently agreed that we’re happy to accept 4-,5-,6-tuples of repeated
digits.
Cheers,
Mike
Sent from my iPad
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm