HackerRank collections.Counter() solution in Python | python problem solution

 collections.Counter()A counter is a container that stores elements as dictionary keys, and their counts are stored as dictionary values.Sample Code>>> from collections import Counter>>> >>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3]>>> print Counter(myList)Counter({2:…

Continue ReadingHackerRank collections.Counter() solution in Python | python problem solution

HackerRank Merge the Tools! solution in python | python problem solution

 Consider the following:A string, , of length  where .An integer, , where  is a factor of .We can split  into  substrings where each subtring, , consists of a contiguous block of  characters in . Then, use each  to create string  such that:The characters…

Continue ReadingHackerRank Merge the Tools! solution in python | python problem solution

HackerRank The Minion Game solution in python | python question solution

Kevin and Stuart want to play the 'The Minion Game'.Game RulesBoth players are given the same string, .Both players have to make substrings using the letters of the string .Stuart has to…

Continue ReadingHackerRank The Minion Game solution in python | python question solution

HackerRank Capitalize! problem solution in Python | python problem solution

You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck.Given a…

Continue ReadingHackerRank Capitalize! problem solution in Python | python problem solution

HackerRank Alphabet Rangoli problem solution in python | python problem solution

You are given an integer, . Your task is to print an alphabet rangoli of size . (Rangoli is a form of Indian folk art based on creation of patterns.)Different sizes of…

Continue ReadingHackerRank Alphabet Rangoli problem solution in python | python problem solution

HackerRank Designer Door Mat problem solution in Python | python problem solution

Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications:Mat size must be X. ( is an odd natural number, and  is  times .)The…

Continue ReadingHackerRank Designer Door Mat problem solution in Python | python problem solution

HackerRank Text Wrap problem solution in Python | python problem solution

You are given a string  and width .Your task is to wrap the string into a paragraph of width .Function DescriptionComplete the wrap function in the editor below.wrap has the following parameters:string string: a long stringint max_width: the…

Continue ReadingHackerRank Text Wrap problem solution in Python | python problem solution

HackerRank Text Alignment problem solution in Python | python problem solution

In Python, a string of text can be aligned left, right and center..ljust(width)This method returns a left aligned string of length width.>>> width = 20>>> print 'HackerRank'.ljust(width,'-')HackerRank---------- .center(width)This method returns a centered string of…

Continue ReadingHackerRank Text Alignment problem solution in Python | python problem solution

HackerRank String validators problem solution in python | python problem solution

Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc.str.isalnum()This method checks if all the characters…

Continue ReadingHackerRank String validators problem solution in python | python problem solution