Re: Finding extra digit
- To: mathgroup at smc.vnet.net
- Subject: [mg54015] Re: Finding extra digit
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Mon, 7 Feb 2005 03:13:11 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
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