Posts

Showing posts from November, 2020

Challenge - #38 - Introduction to Sets

  def  average(array):      # your code goes here     lst =  list ( set (array))     avg_height =  sum (lst)/ len (lst)      return  avg_height if  __name__ ==  '__main__' :     n =  int ( input ())     arr =  list ( map ( int ,  input ().split()))     result = average(arr)      print (result)

Challenge - #37 - Triangle Quest 2

for  i  in   range ( 1 , int ( input ())+ 1 ):  #More than 2 lines will result in 0 score. Do not leave a blank line also      print  ((( 10 **i)// 9 )** 2 )

Challenge - #36 - Find Angle MBC

  # Enter your code here. Read input from STDIN. Print output to STDOUT import  math AB =  int ( input ()) BC =  int ( input ()) tita = (math.atan(AB/BC)) tita_to_degree =  round (math.degrees(tita)) print (tita_to_degree, chr ( 176 ),sep =  '' )

Challenge - #35 - Polar Coordinates

  # Enter your code here. Read input from STDIN. Print output to STDOUT import  cmath z =  complex ( input ()) r , phi = cmath.polar(z) print (r,phi,sep =  '\n' )

Challenge - #34 - Default Dict Tutorial

 from collections import defaultdict d = defaultdict(list) n,m = list(map(int, input().split())) for i in range(n):     d[input()].append(i+1) for i in range(m):     print(' '.join(map(str, d[input()])) or -1)

Challenge - #33 - collections.Counter()

  # Enter your code here. Read input from STDIN. Print output to STDOUT from  collections  import  Counter no_of_shoes =  int ( input ()) size_lst =  map ( int ,  input ().split()) no_of_customers =  int ( input ()) shoes = Counter(size_lst) income =  0 for  i  in   range (no_of_customers):     size, price =  map ( int ,  input ().split())      if  shoes[size]:         income += price         shoes[size] -=  1 print (income)

Challenge - #32 - Compress The String!

  # Enter your code here. Read input from STDIN. Print output to STDOUT from  itertools  import  groupby result = [( len ( list (c)), int (k))  for  k,c  in  groupby( input ())] print (*result)

Challenge - #31 - itertools.combinations_with_replacement

  # Enter your code here. Read input from STDIN. Print output to STDOUT from  itertools  import  combinations_with_replacement s, k =  input ().split() k =  int (k) for  i  in   list (combinations_with_replacement( sorted (s), k)):      print ( '' .join(i))