Skip to content
the poor coder

Home / Author

Poor Man

2,994 posts
2020

Python Re.findall() & Re.finditer()

re.findall() The expression re.findall() returns all the non-overlapping matches of patterns in a string as a list of strings. Code re.finditer() The expression re.finditer() returns an iterator yielding MatchObject…

Hackerrank2 min read
2020

Python Group(), Groups() & Groupdict()

group() A group() expression returns one or more subgroups of the match. Code groups() A groups() expression returns a tuple containing all the subgroups of the match. Code groupdict() A groupdict() expression returns a…

Hackerrank2 min read
2020

Hackerrank - Power - Mod Power Solution

So far, we have only heard of Python's powers. Now, we will witness them! Powers or exponents in Python can be calculated using the built-in power function. Call the power function as shown below: or It's also possible…

Hackerrank1 min read
2020

Hackerrank - Mod Divmod - Solution

One of the built-in functions of Python is divmod, which takes two arguments and and returns a tuple containing the quotient of first and then the remainder .

Hackerrank1 min read
2020

Hackerrank- Find a string Solution

In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to…

Hackerrank1 min read
2020

Hackerrank - Company Logo Solution

A newly opened multinational brand has decided to base their company logo on the three most common characters in the company name. They are now trying out various combinations of company names and logos based on this…

Hackerrank1 min read
2020

Hackerrank Piling Up! Solution

There is a horizontal row of N cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow these directions: if is on top of then .

Hackerrank1 min read
2020

Hackerrank Collections Deque Solution

collections.deque() A deque is a double-ended queue. It can be used to add or remove elements from both ends. Deques support thread safe, memory efficient appends and pops from either side of the deque with…

Hackerrank2 min read
2020

Hackerrank OrderedDict solution

collections.OrderedDict An 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…

Hackerrank2 min read
2020

Hackerrank namedtuple 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…

Hackerrank2 min read
2020

Hackerrank - Defaultdict 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 that key has not…

Hackerrank2 min read
2020

Hackerrank Collections Counter Solution

collections.Counter() A counter is a container that stores elements as dictionary keys, and their counts are stored as dictionary values. Sample Code Task is a shoe shop owner. His shop has number of shoes. He has a…

Hackerrank2 min read
2020

Hackerrank - Compress the String! Solution

In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out . You are given a string . Suppose a character '' occurs…

Hackerrank1 min read
2020

Hackerrank - Matrix Script Solution

Neo has a complex matrix script. The matrix script is a X grid of strings. It consists of alphanumeric characters, spaces and symbols (!,@,#,$,%,&). To decode the script, Neo needs to read each column and select only…

Hackerrank1 min read
2020

Hackerrank - Text Alignment 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. .center(width) This method returns a centered string of length width…

Hackerrank2 min read
2020

Hackerrank Combination With Replacement Solution

itertools.combinations_with_replacement(iterable, r) This tool returns length subsequences of elements from the input iterable allowing individual elements to be repeated more than once. Combinations are emitted in…

Hackerrank1 min read
2020

Hackerrank -itertools.combinations() 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…

Hackerrank1 min read
2020

Hackerrank -itertools.permutations() Solution

itertools.permutations(iterable[, r]) This tool returns successive length permutations of elements in an iterable. If is not specified or is None, then defaults to the length of the iterable, and all possible full…

2 min read
ESC