├── README.md └── Warmup ├── 01.Solve Me First.py ├── 02.Simple Array Sum.py ├── 03.Compare the Triplets.py ├── 04.A Very Big Sum.py ├── 05.Diagonal Difference.py ├── 06.Staircase.py ├── 07.Mini-Max Sum.py ├── 08.Birthday Cake Candles.py ├── 09.Plus Minus.py └── 10.Time Conversion.py /README.md: -------------------------------------------------------------------------------- 1 | # Problem-Solving-Hackerrank 2 | Here you can find all "Problem Solving" portion related solutions. 3 | -------------------------------------------------------------------------------- /Warmup/01.Solve Me First.py: -------------------------------------------------------------------------------- 1 | def solveMeFirst(a,b): 2 | # Hint: Type return a+b below 3 | return a+b 4 | 5 | 6 | num1 = int(input()) 7 | num2 = int(input()) 8 | res = solveMeFirst(num1,num2) 9 | print(res) 10 | -------------------------------------------------------------------------------- /Warmup/02.Simple Array Sum.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import os 4 | import sys 5 | 6 | 7 | # Complete the simpleArraySum function below. 8 | # 9 | def simpleArraySum(ar): 10 | # 11 | # Write your code here. 12 | return sum(ar) 13 | # 14 | 15 | if __name__ == '__main__': 16 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 17 | 18 | ar_count = int(input()) 19 | 20 | ar = list(map(int, input().rstrip().split())) 21 | 22 | result = simpleArraySum(ar) 23 | 24 | fptr.write(str(result) + '\n') 25 | 26 | fptr.close() 27 | -------------------------------------------------------------------------------- /Warmup/03.Compare the Triplets.py: -------------------------------------------------------------------------------- 1 | x = list(map(int, input().split())) 2 | y = list(map(int, input().split())) 3 | score=score1=0 4 | for i in range(len(y)): 5 | if x[i]>y[i]: 6 | score+=1 7 | elif x[i]0: 8 | pos.append(i) 9 | elif i<0: 10 | neg.append(i) 11 | elif i==0: 12 | zero.append(i) 13 | print("%.6f"%(len(pos)/len(arr))) 14 | print("%.6f"%(len(neg)/len(arr))) 15 | print("%.6f"%(len(zero)/len(arr))) 16 | 17 | -------------------------------------------------------------------------------- /Warmup/10.Time Conversion.py: -------------------------------------------------------------------------------- 1 | s=input() 2 | def timeconversion(s): 3 | if (s[-2:]=="AM" and s[:2]=='12' ): 4 | return "00"+s[2:8] 5 | elif (s[-2:]=="AM"): 6 | return s[0:8] 7 | elif(s[-2:]=="PM" and s[:2]=='12'): 8 | return s[0:8] 9 | else: 10 | return str(int(s[:2])+12)+s[2:8] 11 | k=timeconversion(s) 12 | print(k) 13 | 14 | 15 | --------------------------------------------------------------------------------