File tree Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change 11def helpingStephan (x , y ):
2- xSplit = str (x ).split ("." )
3- ySplit = str (y ).split ("." )
4-
5- XdigitsAfterDecimal = "0"
6- if len (xSplit ) > 1 :
7- XdigitsAfterDecimal = xSplit [1 ]
8-
9- YdigitsAfterDecimal = "0"
10- if len (ySplit ) > 1 :
11- YdigitsAfterDecimal = ySplit [1 ]
12-
13-
14- digitsAfterDecimal = max (len (XdigitsAfterDecimal ), len (YdigitsAfterDecimal ))
2+ digitsAfterDecimal = 5
153
164 x *= 10 ** digitsAfterDecimal
175 y *= 10 ** digitsAfterDecimal
@@ -21,13 +9,14 @@ def helpingStephan(x, y):
219
2210 r = - 1
2311 while r != 0 :
24- r = round (a % b , 6 ) * 1.0
12+ r = round (a % b , 6 )
2513 a = b
2614 b = r
2715
2816 return a / 10 ** digitsAfterDecimal
2917
3018def main ():
19+ assert helpingStephan (1 , 1 ) == 1
3120 assert helpingStephan (2.4 , 4.8 ) == 2.4
3221 assert helpingStephan (36.21 , 4.19 ) == 0.01
3322 assert helpingStephan (4 , 6 ) == 2
You can’t perform that action at this time.
0 commit comments