Re: Finding extra digit
- To: mathgroup at smc.vnet.net
- Subject: [mg54033] Re: Finding extra digit
- From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
- Date: Tue, 8 Feb 2005 05:31:11 -0500 (EST)
- References: <cu78mn$m7l$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Bill Rowe" <readnewsciv at earthlink.net> wrote in message news:cu78mn$m7l$1 at smc.vnet.net... > On 2/6/05 at 12:44 AM, steve_usenet at _removemefirst_luttrell.org.uk > (Steve Luttrell) wrote: > >>This example does the sort of thing you want: > >>Define a couple if integers differing by one digit. >>In[1]:={n1,n2}={1234567,1234568}; > >>Split the integers into their component digits. In[2]:= >>{d1,d2}=Map[IntegerDigits,{n1,n2}] Out[2]= >>{{1,2,3,4,5,6,7},{1,2,3,4,5,6,8}} > >>Find the digits the integers have in common In[3]:= >>i=Intersection[d1,d2] Out[3]= {1,2,3,4,5,6} > >>Find which digits of n2 do NOT lie in the above common set. In[4]:= >>Complement[d2,i] Out[4]= {8} > > This will not work in general. For example, condider n1 = 811 and n2 =818. > The two integers differ by one digit. But since both are composed from the > same digits, there are no unique digits in either number. > -- > To reply via email subtract one hundred and four > Agreed. I am not doing a digit by digit comparison as I should have done. In effect I have shattered the two numbers into their component digits before I start, and then I am comparing these two sets. Steve Luttrell