@@ -55,20 +55,21 @@ def times10(nstring):
5555 over = True
5656 n1s .append (int (list (str (r ))[rcount % len (str (r ))]))
5757 newcarry = (int (times10 (str (carry ))) + int (n1s [i ])) % n2
58- if over and newcarry == 0 and r == 0 :
59- res += str ((int (times10 (str (carry ))) + int (n1s [i ])) // n2 )
60- return sign + re .sub ("^$" , "0" , re .sub ("^\." , "0." , res .strip ("0" ).rstrip ("." )))
61- x = 0
62- while x < len (carries ):
63- if over and carries [x ]== newcarry and (x % len (str (r )))== ((rcount + 1 ) % len (str (r ))):
58+ if over :
59+ if newcarry == 0 and r == 0 :
6460 res += str ((int (times10 (str (carry ))) + int (n1s [i ])) // n2 )
65- result = sign + re .sub ("^$" , "0" , re .sub ("^\." , "0." , re .sub ("^0+" , "" , res [:i - rcount + x ] + "[" + res [i - rcount + x :] + "]" )))
66- if result [result .index ("[" ) - 1 ]== result [result .index ("]" ) - 1 ]:
67- result = result [:result .index ("[" ) - 1 ] + "[" + result [result .index ("[" ) - 1 ] + result [result .index ("[" ) + 1 :result .index ("]" ) - 1 ] + "]"
68- if result .index ("]" )== result .index ("[" ) + 3 and result [result .index ("[" ) + 1 ]== result [result .index ("[" ) + 2 ]:
69- result = result [:result .index ("[" ) + 1 ] + "]"
70- return result .replace ("[" , rstr1 ).replace ("]" , rstr2 )
71- x += 1
61+ return sign + re .sub ("^$" , "0" , re .sub ("^\." , "0." , res .strip ("0" ).rstrip ("." )))
62+ x = 0
63+ while x < len (carries ):
64+ if carries [x ]== newcarry and (x % len (str (r )))== ((rcount + 1 ) % len (str (r ))):
65+ res += str ((int (times10 (str (carry ))) + int (n1s [i ])) // n2 )
66+ result = sign + re .sub ("^$" , "0" , re .sub ("^\." , "0." , re .sub ("^0+" , "" , res [:i - rcount + x ] + "[" + res [i - rcount + x :] + "]" )))
67+ if result [result .index ("[" ) - 1 ]== result [result .index ("]" ) - 1 ]:
68+ result = result [:result .index ("[" ) - 1 ] + "[" + result [result .index ("[" ) - 1 ] + result [result .index ("[" ) + 1 :result .index ("]" ) - 1 ] + "]"
69+ if result .index ("]" )== result .index ("[" ) + 3 and result [result .index ("[" ) + 1 ]== result [result .index ("[" ) + 2 ]:
70+ result = result [:result .index ("[" ) + 2 ] + "]"
71+ return result .replace ("[" , rstr1 ).replace ("]" , rstr2 )
72+ x += 1
7273 res += str ((int (times10 (str (carry ))) + int (n1s [i ])) // n2 )
7374 if over :
7475 carries .append (carry )
0 commit comments