Simple Diff

String list of two lines is input. 

One character by comparing the characters of each other from the left, when the same character output both. 
In the case of different characters, and outputs the character of low character code, the other side outputs '*'. 

If the character to be output to the earlier list of one is lost, outputs '*'.

Please refer to Tests for details. I'm not good at English.(><

IN

abcdefghijklmnopqrstuvwxyz
apple

OUT

abcdefghijklmnop***qrstuvwxyz
a**************pple**********

IN

worldwideweb
wonderland

OUT

wo***rl*d**wideweb
wonderla*nd*******

IN

hypertext preprocessor
monty python

OUT

h****y*pertext preprocessor*****
*monty p*******************ython

IN

object oriented programming
aspect oriented programming

OUT

*objec****t oriented programming
a*****spect oriented programming
Login to submit solution


45 symbols pyth
Mon Oct 31 16:54:01 2016 Sait2000
K,wwW>CKZ=KmXZhd*@>MCdZ\*.pK=hZ)jm.[d\*eSlMKK
50 symbols pyth
Mon Oct 24 09:02:40 2016 Sait2000
K,wwW>CKZ=KmXhAdZ+*>J@GZ@HZ\*J.pK=hZ)jm.[d\*eSlMKK
52 symbols pyth
Mon Oct 24 09:01:02 2016 Sait2000
KA,wwW>CKZ=KAmXhAdZ+*>J@GZ@HZ\*J.pK=hZ)jm.[d\*eSlMKK
60 symbols pyth
Thu Sep 22 13:28:27 2016 Sait2000
A,wwW>C,GHZAm++<hAdZ*>@GZ@HZJ\*>GZ.p,GH=hZ).[GJKeS,lHlG.[HJK
61 symbols pyth
Thu Sep 22 13:25:26 2016 Sait2000
A,wwW&>GZ>HZAm++<hAdZ*>@GZ@HZJ\*>GZ.p,GH=hZ).[GJKeS,lHlG.[HJK
65 symbols pyth
Thu Sep 22 13:18:36 2016 Sait2000
A,wwW&>GZ>HZAm++<hdZ*>@hdZ@edZJ\*>hdZ,,GH,HG=hZ).[GJKeS,lHlG.[HJK
71 symbols pyth
Thu Sep 22 13:12:14 2016 Sait2000
A,wwW&>GZ>HZA,++<GZ*>@GZ@HZJ\*>GZ++<HZ*<@GZ@HZJ>HZ=hZ).[GJKeS,lHlG.[HJK
158 symbols python3
Thu Sep 22 13:35:25 2016 Sait2000
a=input()
b=input()
c=0
s='*'
while a[c:]and b[c:]:a,b=[a[:c]+s*(a[c]>b[c])+a[c:]for a,b in((a,b),(b,a))];c+=1
print(a.ljust(len(b),s)+'\n'+b.ljust(len(a),s))
159 symbols python3
Thu Sep 22 12:45:15 2016 Sait2000
a=input()
b=input()
c=0
s='*'
while a[c:]and b[c:]:a,b=a[:c]+s*(a[c]>b[c])+a[c:],b[:c]+s*(a[c]<b[c])+b[c:];c+=1
print(a.ljust(len(b),s)+'\n'+b.ljust(len(a),s))
163 symbols python3
Thu Sep 22 12:34:45 2016 Sait2000
i=input
l=len
a=i()
b=i()
c=0
while a[c:]and b[c:]:a,b=a[:c]+'*'*(a[c]>b[c])+a[c:],b[:c]+'*'*(a[c]<b[c])+b[c:];c+=1
print(a.ljust(l(b),'*')+'\n'+b.ljust(l(a),'*'))
171 symbols python3
Thu Sep 22 12:16:51 2016 Sait2000
i=input
l=len
a=i()
b=i()
c=0
while a[c:]and b[c:]:
 if a[c]<b[c]:b=b[:c]+'*'+b[c:]
 elif a[c]>b[c]:a=a[:c]+'*'+a[c:]
 c+=1
print(a.ljust(l(b),'*')+'\n'+b.ljust(l(a),'*'))
175 symbols perl
Wed Aug 27 05:41:11 2014 gabrielmad
#!/usr/bin/perl -0paF\n
@x=$F[0]=~/./g;@y=$F[1]=~/./g;$x[$i]ne$y[$i]?splice\(ord$x[$i]<ord$y[$i]?@y:@x),$i++,0,'*':$i++while$i<(@x<@y?@x:@y);push\(@y<@x?@y:@x),'*'while@x!=@y;$"='';$_="@x\n@y"
178 symbols perl
Tue Aug 26 20:58:39 2014 gabrielmad
#!/usr/bin/perl -0paF\n
@x=$F[0]=~/./g;@y=$F[1]=~/./g;$x[$i]ne$y[$i]?splice\(ord$x[$i]<ord$y[$i]?@y:@x),$i++,0,'*':$i++while$i<(@x<@y?@x:@y);push\(@y<@x?@y:@x),'*'while@x!=@y;$_=join'',@x,"\n",@y
179 symbols python3
Thu Sep 22 12:14:27 2016 Sait2000
i=input
l=len
a=i()
b=i()
c=0
while a[c:]and b[c:]:
 if a[c]!=b[c]:
  if a[c]<b[c]:b=b[:c]+'*'+b[c:]
  else:a=a[:c]+'*'+a[c:]
 c+=1
print(a.ljust(l(b),'*')+'\n'+b.ljust(l(a),'*'))
181 symbols python3
Thu Sep 22 12:12:29 2016 Sait2000
i=input
l=len
a=i()
b=i()
c=0
while c<min(l(a),l(b)):
 if a[c]!=b[c]:
  if a[c]<b[c]:b=b[:c]+'*'+b[c:]
  else:a=a[:c]+'*'+a[c:]
 c+=1
print(a.ljust(l(b),'*')+'\n'+b.ljust(l(a),'*'))
186 symbols haskell
Wed Mar 18 07:30:02 2015 YoshikuniJujo
main=interact$unlines.d.lines
e='*'
p f g[x,y]=[f x,g y]
d["",t]=[map(\_->e)t,t]
d[s,""]=[s,map(\_->e)s]
d[a@(x:s),b@(y:t)]|x<y=p(x:)(e:)$d[s,b]|x>y=p(e:)(y:)$d[a,t]|0<1=p(x:)(y:)$d[s,t]
192 symbols python3
Thu Sep 22 12:11:29 2016 Sait2000
i=input
l=len
a=i()
b=i()
c=0
while c<min(l(a),l(b)):
 if a[c]!=b[c]:
  if a[c]<b[c]:b=b[:c]+'*'+b[c:]
  else:a=a[:c]+'*'+a[c:]
 c+=1
m=max(l(a),l(b))
print(a.ljust(m,'*')+'\n'+b.ljust(m,'*'))
198 symbols python3
Thu Sep 22 12:04:50 2016 Sait2000
i=input
l=len
a=i()
b=i()
c=0
while c<min(l(a),l(b)):
 if a[c]!=b[c]:
  if a[c]<b[c]:b=b[:c]+'*'+b[c:]
  else:a=a[:c]+'*'+a[c:]
 c+=1
m=max(l(a),l(b))
a+='*'*(m-l(a))
b+='*'*(m-l(b))
print(a+'\n'+b)
208 symbols python3
Fri Sep 19 22:26:21 2014 z423x5c6
i=input
l=len
a=i()
b=i()
c=0
while c<min(l(a),l(b)):
 if a[c]!=b[c]:
  if ord(a[c])<ord(b[c]):b=b[:c]+'*'+b[c:]
  else:a=a[:c]+'*'+a[c:]
 c+=1
m=max(l(a),l(b))
a+='*'*(m-l(a))
b+='*'*(m-l(b))
print(a+'\n'+b)
211 symbols python3
Tue Aug 19 22:29:36 2014 z423x5c6
i=input
a=i()
b=i()
c=0
while c<min(len(a),len(b)):
 if a[c]!=b[c]:
  if ord(a[c])<ord(b[c]):b=b[:c]+'*'+b[c:]
  else:a=a[:c]+'*'+a[c:]
 c+=1
while len(a)<len(b):a+='*'
while len(b)<len(a):b+='*'
print(a+'\n'+b)

View all solutions