Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

answers in short lines #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions HackerRank-A Very Big Sum/A_Very_Big_Sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
16 changes: 2 additions & 14 deletions HackerRank-Apple and Orange/Apple_and_Orange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 9 additions & 10 deletions HackerRank-Diagonal Difference/Diagonal_Difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
12 changes: 4 additions & 8 deletions HackerRank-Extra Long Factorials/Extra_Long_Factorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
8 changes: 2 additions & 6 deletions HackerRank-Mini-Max Sum/Mini-Max_Sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 1 addition & 8 deletions HackkerRank-Angry Professor/Angry_Professor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down