Re: Finding extra digit

• To: mathgroup at smc.vnet.net
• Subject: [mg54007] Re: Finding extra digit
• From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
• Date: Mon, 7 Feb 2005 03:12:51 -0500 (EST)
• References: <cu208g\$m0j\$1@smc.vnet.net> <cu4c41\$c45\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Warning: My suggested solution ignores the order of the digits, so for
instance {n1,n2}={1234567,1234568} and {n1,n2}={1234567,8654321} will
produce the same result.

Steve Luttrell

Having seen the other responses I now realise that the order of the digits
was probably important to you. If so, then ignore my suggestion which
"Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk> wrote in
message news:cu4c41\$c45\$1 at smc.vnet.net...
> 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 also produces useful results when the integers differ by more than
> one
> digit, or when the integers have an unequal number of digits.
>
> Steve Luttrell
>
> "Zak Seidov" <seidovzf at yahoo.com> wrote in message
> news:cu208g\$m0j\$1 at smc.vnet.net...
>> Dear Math gurus,
>> What is an easy way to find extra digit in the integer n2,
>> which differs from integer n1
>> EXACTLY by ONE digit.
>> I use a very dirt program,
>> but guess that you can suggest smth (much) better.
>> Thanks a lot,