Re: A list of numbers without "73"

• To: mathgroup at smc.vnet.net
• Subject: [mg63012] Re: [mg63005] A list of numbers without "73"
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sun, 11 Dec 2005 04:56:34 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Clear[S,S2];

S[1]=Range[1, 9];
S[i_?Positive]:=S[i]=
Delete[Union[Table[
k*(1-Boole[StringMatchQ[ToString[k], "*73*"]]),
{k, 10^(i-1), 10^i-1}]], 1];

S2[1]=Range[1, 9];
S2[i_?Positive]:=S2[i]=
DeleteCases[Range[10^(i-1), 10^i-1],
_?(StringMatchQ[ToString[#], "*73*"]&)]

And@@Table[S[i]==S2[i],{i, 4}]

True

Timing[S[6]][[1]]

36.1983 Second

Timing[S2[6]][[1]]

28.961 Second

%/%%

0.800065

S[6]==S2[6]

True

Bob Hanlon

>
> From: "Thomas Schmelzer" <thomas.??? at balliol.ox.ac.uk>
To: mathgroup at smc.vnet.net
> Date: 2005/12/10 Sat AM 06:03:40 EST
> Subject: [mg63012] [mg63005] A list of numbers without "73"
>
> Experts,
>
> 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}]
>
> S[i_] := S[i] =
> If[i == 1, L,
> Delete[Union[
> Table[k*(1 - Boole[StringMatchQ[ToString[k], "*73*"]]), {k,
> 10^(i - 1), 10^i - 1}]], 1]]
>
>
>
> Best
>
> Thomas
>
>
>
>
>

```

• Prev by Date: Re: Assign a value to a variable
• Next by Date: Re: Re: Zero or one
• Previous by thread: Re: A list of numbers without "73"
• Next by thread: Re: A list of numbers without "73"