I've only just seen this thread, so little to offer, except to point
out that
the same approach may be used for this modified problem, which is how I
misread it
to start with:
"... remove all integers that contain certain digits, eg 2 4 5 9"
Then Marshall's method may be adapted fairly trivially:
,(+/~10&*)/ 2#,:(i.10)-. 2 4 5 9 NB. numbers <: 100 to save space here
0 1 3 6 7 8 10 11 13 16 17 18 30 31 33 36 37 38 60 61 63 66 67 68 70 71 73 76
77 78 80 81 83 86 87 88
NB. now remove low numbers
(#~>:&10) ,(+/~10&*)/ 2#,:(i.10)-. 2 4 5 9 NB. 10 <: numbers <: 100
10 11 13 16 17 18 30 31 33 36 37 38 60 61 63 66 67 68 70 71 73 76 77 78 80 81
83 86 87 88
NB. or, if all leading zeros are also to be removed,
,}.(+/~10&*)/ 2#,:(i.10)-. 2 4 5 9
10 11 13 16 17 18 30 31 33 36 37 38 60 61 63 66 67 68 70 71 73 76 77 78 80 81
83 86 87 88
- so you do need an extra bit of work to satisfy the lower bound
Other constructive methods allow similar amendment.
Mike
On 03/10/2017 22:00, Marshall Lochbaum wrote:
I doubt you'll find a much faster J solution than:
,(+/~10&*)/ 4#,:>:i.6
or the uglier but slightly quicker
,+// (10<.@^i._4)*/>:i.6
Marshall
On Tue, Oct 03, 2017 at 03:16:41PM -0500, Skip Cave wrote:
Another interesting Quora problem:
Given the integers from 1000 to 9999, remove all integers that contain a 7,
8, 9, or zero, and list the remaining integers.
Skip
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm