Posts

Showing posts from December, 2020

Challenge - #47 - Exceptions

  # Enter your code here. Read input from STDIN. Print output to STDOUT for  i  in   range ( int ( input ())):     a,b =  input ().split()      try :          print ( int (a)// int (b))      except  ZeroDivisionError  as  e :          print ( 'Error Code:' ,e)      except  ValueError  as  e:          print ( 'Error Code:' ,e)

Challenge - #46 - Sum and Prod

  import  numpy n,m =  map ( int ,  input ().split()) array = numpy.array([ input ().split()  for  i  in   range (n)],  int ) print (numpy.prod(numpy. sum (array,axis= 0 )))

Challenge - #45 - Floor, Ceil, and Rint

import  numpy numpy.set_printoptions(legacy= '1.13' ) A = numpy.array( input ().split(), float ) print (numpy.floor(A),numpy.ceil(A),numpy.rint(A),sep= '\n' )

Challenge - #44 - Array Mathematics

 import numpy n,m = map(int, input().split()) A = numpy.array([list(map(int, input().split())) for i in range(n)]) B = numpy.array([list(map(int, input().split())) for i in range(n)]) print(A+B,A-B,A*B,A//B,A%B,A**B,sep='\n')

Challenge - #43 - Time Delta

  #!/bin/python3 import  math import  os import  random import  re import  sys from  datetime  import  datetime # Complete the time_delta function below. def  time_delta(t1, t2):     #just this three lines are the answer everything else is already written for you      time1 = datetime.strptime(t1,  '%a %d %b %Y %H:%M:%S %z' )      time2 = datetime.strptime(t2,  '%a %d %b %Y %H:%M:%S %z' )      return   str ( int ( abs (time1-time2).total_seconds())) if  __name__ ==  '__main__' :     fptr =  open (os.environ[ 'OUTPUT_PATH' ],  'w' )     t =  int ( input ())      for  t_itr  in   range (t):         t1...

Challenge - #42 - Calendar Module

  # Enter your code here. Read input from STDIN. Print output to STDOUT import  calendar  days_list = [ 'MONDAY' , 'TUESDAY' , 'WEDNESDAY' , 'THURSDAY' , 'FRIDAY' , 'SATURDAY' , 'SUNDAY' ] m,d,y =  map ( int ,  input ().split()) day_index = calendar.weekday(y,m,d) print (days_list[day_index])

Challenge - #41 - set.add()

# Enter your code here. Read input from STDIN. Print output to STDOUT country_set =  set () for  i  in   range ( int ( input ())):     country_set.add( input ()) print ( len (country_set))

Challenge - #40 - No Idea!

  n,m =  map ( int ,  input ().split()) array =  list ( map ( int ,  input ().split())) set_a =  set ( map ( int ,  input ().split())) set_b =  set ( map ( int ,  input ().split())) happiness =  0   for  i  in  array :      if  i  in  set_a :         happiness +=  1      elif  i  in  set_b :         happiness -=  1      else  :          pass print (happiness)

Challenge - #39 - Symmetric Difference

  # Enter your code here. Read input from STDIN. Print output to STDOUT m =  int ( input ()) m_set =  set ( map ( int ,  input ().split())) n =  int ( input ()) n_set =  set ( map ( int ,  input ().split())) m_diff_n = m_set.difference(n_set) n_diff_m = n_set.difference(m_set) result =  list (m_diff_n) +  list (n_diff_m) sorted_result =  sorted (result) print (*sorted_result,sep =  '\n' )