Re: A list of numbers without "73"
- To: mathgroup at smc.vnet.net
- Subject: [mg63022] Re: A list of numbers without "73"
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 11 Dec 2005 04:56:43 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 12/10/05 at 6:03 AM, thomas.??? at balliol.ox.ac.uk (Thomas Schmelzer) wrote: >S(i) should be a list of positive integers without the substring >"73". >My code seems to be very inefficient. I multiply all numbers with 0 >if they contain "73", sort the new list, make the union (remove >double elements) and delete the first element. Therefore it is >necessary to use an if statement in order not to delete the first >element of the numbers 1-9. Any more sophisticated ideas? >L := Table[k, {k, 1, 9}] >Delete[Union[ >Table[k*(1 - Boole[StringMatchQ[ToString[k], "*73*"]]), {k, >10^(i - 1), 10^i - 1}]], 1]] It appears you want to generate a list of positive integers between 1 and 10^n - 1 with all integers having the sequence 73 being deleted. If so, a simpler approach would be s[n_]:= Select[Range[10^n-1], !StringMatchQ[ToString@#, "*73*"]&] checking that this works as intended In[55]:= Complement[Range[999], s[3]] Out[55]= {73, 173, 273, 373, 473, 573, 673, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 773, 873, 973} -- To reply via email subtract one hundred and four