From 740787d860ade032c39914dc1cd967fa2499e26f Mon Sep 17 00:00:00 2001 From: Yousseff Muhammed EL Masry Date: Sat, 6 Jun 2020 06:46:13 +0200 Subject: [PATCH 1/6] Update Extra_Long_Factorials.py --- .../Extra_Long_Factorials.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/HackerRank-Extra Long Factorials/Extra_Long_Factorials.py b/HackerRank-Extra Long Factorials/Extra_Long_Factorials.py index 8bd1b70..fed06d9 100644 --- a/HackerRank-Extra Long Factorials/Extra_Long_Factorials.py +++ b/HackerRank-Extra Long Factorials/Extra_Long_Factorials.py @@ -8,13 +8,9 @@ # Complete the extraLongFactorials function below. def extraLongFactorials(n): - ans=1 - while(n!=1): - ans*=n - n-=1 - print (ans) + if n == 1: + return 1 + return n * extraLongFactorials(n-1) if __name__ == '__main__': - n = int(input()) - - extraLongFactorials(n) + print(extraLongFactorials(int(input()))) From 64618972a92fa956a72083e7f9799f267a1f9c6d Mon Sep 17 00:00:00 2001 From: Yousseff Muhammed EL Masry Date: Sat, 6 Jun 2020 06:58:35 +0200 Subject: [PATCH 2/6] Update A_Very_Big_Sum.py --- HackerRank-A Very Big Sum/A_Very_Big_Sum.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/HackerRank-A Very Big Sum/A_Very_Big_Sum.py b/HackerRank-A Very Big Sum/A_Very_Big_Sum.py index bc7e073..9f5ed0f 100644 --- a/HackerRank-A Very Big Sum/A_Very_Big_Sum.py +++ b/HackerRank-A Very Big Sum/A_Very_Big_Sum.py @@ -5,12 +5,10 @@ import random import re import sys + # Complete the aVeryBigSum function below. def aVeryBigSum(ar): - sum = 0 - for i in range(len(ar)): - sum+=ar[i] - return sum + return sum(ar) if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') From db088ca51dedbd3028512bc8b1dcf1b84c021d9d Mon Sep 17 00:00:00 2001 From: Yousseff Muhammed EL Masry Date: Sat, 6 Jun 2020 07:24:47 +0200 Subject: [PATCH 3/6] Update Apple_and_Orange.py --- HackerRank-Apple and Orange/Apple_and_Orange.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/HackerRank-Apple and Orange/Apple_and_Orange.py b/HackerRank-Apple and Orange/Apple_and_Orange.py index f5bad10..4c89c02 100644 --- a/HackerRank-Apple and Orange/Apple_and_Orange.py +++ b/HackerRank-Apple and Orange/Apple_and_Orange.py @@ -8,20 +8,8 @@ # Complete the countApplesAndOranges function below. def countApplesAndOranges(s, t, a, b, apples, oranges): - acount = 0 - bcount = 0 - for i in range(len(apples)): - temp = a+apples[i] - if(temp in range(s,t+1)): - acount+=1 - for i in range(len(oranges)): - temp = b+oranges[i] - if(temp in range(s,t+1)): - bcount+=1 - print (acount) - print (bcount) - - + print(len([a+i for i in apples if a+i >= s and a+i <= t ])) + print(len([b+i for i in oranges if b+i >= s and b+i <= t])) if __name__ == '__main__': st = input().split() From cb547a2e5eb2313eae85b476d28d99514259156c Mon Sep 17 00:00:00 2001 From: Yousseff Muhammed EL Masry Date: Sat, 6 Jun 2020 07:43:14 +0200 Subject: [PATCH 4/6] Update Angry_Professor.py --- HackkerRank-Angry Professor/Angry_Professor.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/HackkerRank-Angry Professor/Angry_Professor.py b/HackkerRank-Angry Professor/Angry_Professor.py index a5a27a8..ee5ad9e 100644 --- a/HackkerRank-Angry Professor/Angry_Professor.py +++ b/HackkerRank-Angry Professor/Angry_Professor.py @@ -8,14 +8,7 @@ # Complete the angryProfessor function below. def angryProfessor(k, a): - count=0 - for i in range(len(a)): - if(a[i]<=0): - count+=1 - if(count>=k): - return "NO" - return "YES" - + return "NO" if len(list(filter(lambda x:x<=0, a)))>=k else "YES" if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') From 62ebc0bf872ca28fcc25a68cdc1724092fb5809c Mon Sep 17 00:00:00 2001 From: Yousseff Muhammed EL Masry Date: Sat, 6 Jun 2020 07:54:54 +0200 Subject: [PATCH 5/6] Update Mini-Max_Sum.py --- HackerRank-Mini-Max Sum/Mini-Max_Sum.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/HackerRank-Mini-Max Sum/Mini-Max_Sum.py b/HackerRank-Mini-Max Sum/Mini-Max_Sum.py index b4ea822..48d4233 100644 --- a/HackerRank-Mini-Max Sum/Mini-Max_Sum.py +++ b/HackerRank-Mini-Max Sum/Mini-Max_Sum.py @@ -8,12 +8,8 @@ # Complete the miniMaxSum function below. def miniMaxSum(arr): - sum=0 - for i in range(len(arr)): - sum+=arr[i] - print ( sum-max(arr), sum-min(arr)) - + s=sum(arr) + print(s-max(arr),s-min(arr)) if __name__ == '__main__': arr = list(map(int, input().rstrip().split())) - miniMaxSum(arr) From 35c87b770755b4fb15b5c09e4f6b28e38db7ff89 Mon Sep 17 00:00:00 2001 From: Yousseff Muhammed EL Masry Date: Sat, 6 Jun 2020 08:02:26 +0200 Subject: [PATCH 6/6] Update Diagonal_Difference.py --- .../Diagonal_Difference.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/HackerRank-Diagonal Difference/Diagonal_Difference.py b/HackerRank-Diagonal Difference/Diagonal_Difference.py index 7cfabd2..b29761d 100644 --- a/HackerRank-Diagonal Difference/Diagonal_Difference.py +++ b/HackerRank-Diagonal Difference/Diagonal_Difference.py @@ -6,21 +6,20 @@ import re import sys -# Complete the diagonalDifference function below. +# +# Complete the 'diagonalDifference' function below. +# +# The function is expected to return an INTEGER. +# The function accepts 2D_INTEGER_ARRAY arr as parameter. +# + def diagonalDifference(arr): - prim =0 - sec=0 - length = len(arr[0]) - for count in range(length): - prim += arr[count][count] - sec += arr[count][(length-count-1)] - return abs(prim-sec) - + return abs(sum([arr[i][i] for i in range(len(arr))])-sum([arr[i][len(arr)-i-1] for i in range(len(arr))])) if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') - n = int(input()) + n = int(input().strip()) arr = []