HackerRank itertools.combinations() solution in python |python question solution

 itertools.combinations(iterable, r)This tool returns the  length subsequences of elements from the input iterable.Combinations are emitted in lexicographic sorted order. So, if the input iterable is sorted, the combination tuples will be…

Continue ReadingHackerRank itertools.combinations() solution in python |python question solution

HackerRank Symmetric Difference solution in python | python question solution

ObjectiveToday, we're learning about a new data type: sets.ConceptIf the inputs are given on one line separated by a character (the delimiter), use split() to get the separate values in the form of…

Continue ReadingHackerRank Symmetric Difference solution in python | python question solution

HackerRank Collections.OrderedDict() solution in python | python question solution

collections.OrderedDictAn OrderedDict is a dictionary that remembers the order of the keys that were inserted first. If a new entry overwrites an existing entry, the original insertion position is left unchanged.ExampleCode>>> from…

Continue ReadingHackerRank Collections.OrderedDict() solution in python | python question solution

HackerRank No Idea! problem solution in Python | python question solution

There is an array of  integers. There are also  disjoint sets,  and , each containing  integers. You like all the integers in set  and dislike all the integers in set . Your initial happiness is . For each  integer…

Continue ReadingHackerRank No Idea! problem solution in Python | python question solution

HackerRank Find Angle MBC solution in python | python question solution

  is a right triangle,  at .Therefore, .Point  is the midpoint of hypotenuse .You are given the lengths  and .Your task is to find  (angle , as shown in the figure) in degrees.Input FormatThe first line contains the length of…

Continue ReadingHackerRank Find Angle MBC solution in python | python question solution

HackerRank Collections.namedtuple() solution in python | python question solution

 collections.namedtuple()Basically, namedtuples are easy to create, lightweight object types.They turn tuples into convenient containers for simple tasks.With namedtuples, you don’t have to use integer indices for accessing members of a tuple.ExampleCode 01>>> from…

Continue ReadingHackerRank Collections.namedtuple() solution in python | python question solution

HackerRank Exceptions problem solution in python | python problem solution

ExceptionsErrors detected during execution are called exceptions.Examples:ZeroDivisionErrorThis error is raised when the second argument of a division or modulo operation is zero.>>> a = '1'>>> b = '0'>>> print int(a) /…

Continue ReadingHackerRank Exceptions problem solution in python | python problem solution

HackerRank DefaultDict Tutorial solution in Python | python problem solution

 The defaultdict tool is a container in the collections class of Python. It's similar to the usual dictionary (dict) container, but the only difference is that a defaultdict will have a default value if…

Continue ReadingHackerRank DefaultDict Tutorial solution in Python | python problem solution

HackerRank Introduction to Sets solution in python | python question solution

A set is an unordered collection of elements without duplicate entries.When printed, iterated or converted into a sequence, its elements will appear in an arbitrary order.Example>>> print set()set([])>>> print set('HackerRank')set(['a', 'c', 'e',…

Continue ReadingHackerRank Introduction to Sets solution in python | python question solution