Join Regular Classroom : Visit ClassroomTech

Hackwithinfy Solution 2021

Making Strings Equal

Solution in Python

#codewindow.in
#MAKE STRING EQUAL
#Code in PYTHON

res=0
def equal(s,n):
    global res
    k=list(s)
    while len(k)!=n:
        k.pop(0)
        res+=1
    return ''.join(k)

a=input()
b=input()
c=input()
s=len(a)+len(b)+len(c)
m=min(len(a),len(b),len(c))

if len(a)>m:
    a=equal(a,m)

if len(b)>m:
    b=equal(b,m)

if len(c)>m:
    c=equal(c,m)

if a==b==c:
    print(res)
else:
    print(s)
#end
Recent Posts