Esthetic numbers: Difference between revisions

m
J: more efficient implementation of stretch goal.
(J)
m (J: more efficient implementation of stretch goal.)
Line 3,039:
1010 1012 1210 1212 1232 1234</lang>
 
Stretch goal (the slow way):
 
<lang J> $e=: (#~ isesthetic) x:1e8+i.1+3e7
126
q:126
2 3 3 7</lang>
 
14 9$e
(Result e not displayed here -- it's the same as <tt>next^:8]1</tt> below.)
 
Note: in some of these casesBut, it's would bemuch more efficient to take a generative approach (generating sequences of digits from a base digit, rather than generating sequential integers discarding those which are not suitable). :
 
<lang J>graph=: </./|:/:~~.10 10#:(#~ isesthetic)100+i.900
next=: [:; (0 10#.],.graph {::"0 1~10|])each
 
14 9$enext^:8]1
101010101 101010121 101010123 101012101 101012121 101012123 101012321 101012323 101012343
101012345 101210101 101210121 101210123 101212101 101212121 101212123 101212321 101212323
Line 3,059 ⟶ 3,067:
123432323 123432343 123432345 123434321 123434323 123434343 123434345 123434543 123434545
123434565 123434567 123454321 123454323 123454343 123454345 123454543 123454545 123454565
123454567 123456543 123456545 123456565 123456567 123456765 123456767 123456787 123456789</langlagn>
 
Note: in some of these cases, it would be more efficient to take a generative approach (generating sequences of digits from a base digit, rather than generating sequential integers discarding those which are not suitable).
 
=={{header|Java}}==
6,951

edits