Python solve problem with string operation

giacomo boffi pecore at pascolo.net
Thu Jan 16 19:38:02 EST 2014


giacomo boffi <pecore at pascolo.net> writes:

> % python a.py
> 34131237

% cat a.py 
i="344111133311222223377";n=0
while n+1!=len(i):i,n=(i[:n]+i[n+1:],n) if i[n+1]==i[n] else (i,n+1)
print i
% python a.py 
34131237
%
-- 
for Nikos



More information about the Python-list mailing list