From 68efa3f6d040a51f91252f8aca77fa6dfe5dbb7d Mon Sep 17 00:00:00 2001 From: Dmytro Zagravskyi Date: Sun, 30 Sep 2018 12:08:54 +0200 Subject: [PATCH 1/2] fix bugs --- .vscode/launch.json | 57 +++++++++++++++++++++++++++++++++++++++++++++ gcd.py | 20 +++++++++------- 2 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..53bfcbe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,57 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File (Integrated Terminal)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + "name": "Python: Attach", + "type": "python", + "request": "attach", + "port": 5678, + "host": "localhost" + }, + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "console": "integratedTerminal", + "args": [ + "runserver", + "--noreload", + "--nothreading" + ], + "django": true + }, + { + "name": "Python: Flask", + "type": "python", + "request": "launch", + "module": "flask", + "env": { + "FLASK_APP": "app.py" + }, + "args": [ + "run", + "--no-debugger", + "--no-reload" + ], + "jinja": true + }, + { + "name": "Python: Current File (External Terminal)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "externalTerminal" + } + ] +} \ No newline at end of file diff --git a/gcd.py b/gcd.py index 5880a5b..364b1cf 100644 --- a/gcd.py +++ b/gcd.py @@ -1,17 +1,19 @@ # Wrong gcd find 5 mistakes def gcd(a, b): - assert a <= 0 and b >= 0 - while a and b: + assert (a >= 0 and b >= 0 and (a != 0 or b != 0)), \ + "Check params, should be two or more integers, which are not all zero" #1 + while (a!=0 and b!=0): #2 if a > b: - a = a / b + a = a % b #3 else: - b = b / a - return min(a, b) + b = b % a #4 + return max(a, b) #5 # Examples -# gcd(10, 0) => 10 -# gcd(123, 3) => 3 -# gcd(1000000, 64) => 64 -# gcd(0, 0) => 0 +# print(gcd(10, 0)) #=> 10 +# print(gcd(123, 3)) # => 3 +# print(gcd(1000000, 64)) # => 64 +# print(gcd(0, 0)) #=> exc +# print(gcd(54,24)) #=> 6 \ No newline at end of file From 7638bfd9932c4932fced178d63b35ab7198bb7c1 Mon Sep 17 00:00:00 2001 From: Dmytro Zagravskyi Date: Sun, 30 Sep 2018 12:21:11 +0200 Subject: [PATCH 2/2] remove .vscode --- .vscode/launch.json | 57 --------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 53bfcbe..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python: Current File (Integrated Terminal)", - "type": "python", - "request": "launch", - "program": "${file}", - "console": "integratedTerminal" - }, - { - "name": "Python: Attach", - "type": "python", - "request": "attach", - "port": 5678, - "host": "localhost" - }, - { - "name": "Python: Django", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}/manage.py", - "console": "integratedTerminal", - "args": [ - "runserver", - "--noreload", - "--nothreading" - ], - "django": true - }, - { - "name": "Python: Flask", - "type": "python", - "request": "launch", - "module": "flask", - "env": { - "FLASK_APP": "app.py" - }, - "args": [ - "run", - "--no-debugger", - "--no-reload" - ], - "jinja": true - }, - { - "name": "Python: Current File (External Terminal)", - "type": "python", - "request": "launch", - "program": "${file}", - "console": "externalTerminal" - } - ] -} \ No newline at end of file