From fce260d3f192788c9f679f2902b3d265f1d3f42c Mon Sep 17 00:00:00 2001 From: Aditya Paliwal Date: Thu, 1 Oct 2020 23:59:29 +0530 Subject: [PATCH 1/2] New method to solve We can decrease the number of line by this method. --- kangaroo.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kangaroo.py b/kangaroo.py index b89d2b5..280e8ea 100644 --- a/kangaroo.py +++ b/kangaroo.py @@ -11,3 +11,14 @@ else: print "NO" +''' +This can be done in another way too +''' +# Another way to do the same thing. This takes less lines. +posDiff=x2-x1 +velDiff=v1-v2 + +if v1>v2 and posDiff%velDiff ==0: + print "YES" +else: + print "NO" From 204e54050d689fea63495b48cd00b26f499346d6 Mon Sep 17 00:00:00 2001 From: Aditya Paliwal Date: Fri, 2 Oct 2020 00:03:41 +0530 Subject: [PATCH 2/2] New method updated This decreases the space --- triangle.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/triangle.py b/triangle.py index 7017bdb..7d436ea 100644 --- a/triangle.py +++ b/triangle.py @@ -15,3 +15,14 @@ print("valid") else: print("invalid") + +''' +We can decrease lines by just using 'or' keyword in else section. +''' + +else: + if ((int(l[0])+int(l[1]))%2==0) or ((int(l[0])+int(l[1])%2==0 )) or ((int(l[0])+int(l[1])%2==0 )) or (((int(l[0])+int(l[1]))%2==0)): + print("valid") + else: + print("invalid") +