MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Finding extra digit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53986] Re: Finding extra digit
  • From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
  • Date: Sun, 6 Feb 2005 00:44:55 -0500 (EST)
  • References: <cu208g$m0j$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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,
> please help!
> 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,
> and please mail me your help
> seidovzf at yahoo.com
> 



  • Prev by Date: Re: Re: Re: New Web Site for Mathematica Users using WikiMedia
  • Next by Date: Re: Mathematica
  • Previous by thread: Re: Finding extra digit
  • Next by thread: Re: Finding extra digit