Posts

A very big sum Solution in Python

----------- SOLUTION ----------- #!/bin/python3 import math import os import random import re import sys # Complete the aVeryBigSum function below. def aVeryBigSum(ar, ar_count):     sum = 0     for i in range(ar_count):         sum = sum + int(ar[i])     return sum if __name__ == '__main__':     fptr = open(os.environ['OUTPUT_PATH'], 'w')     ar_count = int(input())     ar = list(map(str, input().rstrip().split()))     result = aVeryBigSum(ar, ar_count)     fptr.write(str(result) + '\n')     fptr.close()

Hackerrank Birthday Cake Candles Challenge Solution in Python

You are in charge of the cake for your niece's birthday and have decided the cake will have one candle for each year of her total age. When she blows out the candles, she’ll only be able to blow out the tallest ones. Your task is to find out how many candles she can successfully blow out. For example, if your niece is turning   years old, and the cake will have   candles of height  ,  ,  ,  , she will be able to blow out  candles successfully, since the tallest candles are of height   and there are   such candles. Function Description Complete the function  birthdayCakeCandles  in the editor below. It must return an integer representing the number of candles she can blow out. birthdayCakeCandles has the following parameter(s): ar : an array of integers representing candle heights Input Format The first line contains a single integer,  , denoting the number of candles on the cake. The second line contains   space-separated integers, where each integer   

Mini-Max Sum solution in Python

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. For example,  . Our minimum sum is   and our maximum sum is  . We would print 16 24 Function Description Complete the  miniMaxSum  function in the editor below. It should print two space-separated integers on one line: the minimum sum and the maximum sum of   of   elements. miniMaxSum has the following parameter(s): arr : an array of   integers Input Format A single line of five space-separated integers. Constraints Output Format Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly  four  of the five integers. (The output can be greater than a 32 bit integer.) Sample Input 1 2 3 4 5 Sample Output