View on GitHub

hackerrank

HackerRank personal solutions

Python

A step by step guide to Python, a language that is easy to pick up yet one of the most powerful.

Introduction

Name Preview Code Difficulty
Say “Hello, World!” With Python Get started with Python by printing to stdout. Python Easy
Python If-Else Practice using if-else conditional statements! Python Easy
Arithmetic Operators Addition, subtraction and multiplication. Python Easy
Python: Division Division using future module. Python Easy
Loops Practice using “for” and “while” loops in Python. Python Easy
Write a function Write a function to check if the given year is leap or not Python Medium
Print Function Learn to use print as a function Python Easy

Basic Data Types

Name Preview Code Difficulty
Lists Perform different list operations. Python Easy
Tuples Learn about tuples and compute hash(T). Python Easy
List Comprehensions You will learn about list comprehensions. Python Easy
Find the Runner-Up Score! For a given list of numbers, find the second largest number. Python Easy
Nested Lists In a classroom of N students, find the student with the second lowest grade. Python Easy
Finding the percentage Store a list of students and marks in a dictionary, and find the average marks obtained by a student. Python Easy

Strings

Name Preview Code Difficulty
sWAP cASE Swap the letter cases of a given string. Python Easy
String Split and Join Use Python’s split and join methods on the input string. Python Easy
What’s Your Name? Python string practice: Print your name in the console. Python Easy
Mutations Understand immutable vs mutable by making changes to a given string. Python Easy
Find a string Find the number of occurrences of a substring in a string. Python Easy
String Validators Identify the presence of alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters in a string. Python Easy
Text Alignment Generate the Hackerrank logo with alignments in Python. Python Easy
Text Wrap Wrap the given text in a fixed width. Python Easy
Designer Door Mat Print a designer door mat. Python Easy
String Formatting Print the formatted decimal, octal, hexadecimal, and binary values for $n$ integers. Python Easy
Alphabet Rangoli Let’s draw rangoli. Python Easy
Capitalize! Capitalize Each Word. Python Easy
The Minion Game Given a string, judge the winner of the minion game. Python Medium
Merge the Tools! Split a string into subsegments of length $k$, then print each subsegment with any duplicate characters stripped out. Python Medium

Sets

Name Preview Code Difficulty
Introduction to Sets Use the set tool to compute the average. Python Easy
Symmetric Difference Learn about sets as a data type. Python Easy
No Idea! Compute your happiness. Python Medium
Set .add() Add elements to set. Python Easy
Set .discard(), .remove() & .pop() Different ways to omit set elements. Python Easy
Set .union() Operation Use the .union() operator to determine the number of students. Python Easy
Set .intersection() Operation Use the .intersection() operator to determine the number of same students in both sets. Python Easy
Set .difference() Operation Use the .difference() operator to check the differences between sets. Python Easy
Set .symmetric_difference() Operation Making symmetric difference of sets. Python Easy
Set Mutations Using various operations, change the content of a set and output the new sum. Python Easy
The Captain’s Room Out of a list of room numbers, determine the number of the captain’s room. Python Easy
Check Subset Verify if set A is a subset of set B. Python Easy
Check Strict Superset Check if A is a strict superset of the other given sets. Python Easy

Math

Name Preview Code Difficulty
Polar Coordinates Convert complex numbers to polar coordinates Python Easy
Find Angle MBC Find the desired angle in the right triangle. Python Medium
Triangle Quest 2 Create a palindromic triangle. Python Medium
Mod Divmod Get the quotient and remainder using the divmod operator in Python. Python Easy
Power - Mod Power Perform modular exponentiation in Python. Python Easy
Integers Come In All Sizes Exercises with big integers in Python. Python Easy
Triangle Quest Print a numeric triangle of height N-1 using only 2 lines. Python Medium

Itertools

Name Preview Code Difficulty
itertools.product() Find the cartesian product of 2 sets. Python Easy
itertools.permutations() Find all permutations of a given size in a given string. Python Easy
itertools.combinations() Print all the combinations of a string using itertools. Python Easy
itertools.combinations_with_replacement() Find all the combinations of a string with replacements. Python Easy
Compress the String! groupby() Python Medium
Iterables and Iterators Find the probability using itertools. Python Medium
Maximize It! Find the maximum possible value out of the equation provided. Python Hard

Collections

Name Preview Code Difficulty
collections.Counter() Use a counter to sum the amount of money earned by the shoe shop owner. Python Easy
DefaultDict Tutorial Create dictionary value fields with predefined data types. Python Easy
Collections.namedtuple() You need to turn tuples into convenient containers using collections.namedtuple(). Python Easy
Collections.OrderedDict() Print a dictionary of items that retains its order. Python Easy
Word Order List the number of occurrences of the words in order. Python Medium
Collections.deque() Perform multiple operations on a double-ended queue or deque. Python Easy
Piling Up! Create a vertical pile of cubes. Python Medium
Company Logo Print the number of character occurrences in descending order. Python Medium

Date and Time

Name Preview Code Difficulty
Calendar Module Print the day of a given date. Python Easy
Time Delta Find the absolute time difference. Python Medium

Errors and Exceptions

Name Preview Code Difficulty
Exceptions Handle errors detected during execution. Python Easy
Incorrect Regex Check whether the regex is valid or not. Python Easy

Classes

Name Preview Code Difficulty
Classes: Dealing with Complex Numbers Create a new data type for complex numbers. Python Medium
Class 2 - Find the Torsional Angle Find the angle between two planes. Python Easy

Built-Ins

Name Preview Code Difficulty
Zipped! Compute the average by zipping data. Python Easy
Input() A Python 2 challenge: Input() is equivalent to eval(raw_input(prompt)). Python Easy
Python Evaluation Evaluate the expressions in Python using the expression eval(). Python Easy
Athlete Sort Sort the table on the kth attribute. Python Medium
Any or All Return True, if any of the iterable is true or if all of it is true using the any() and all() expressions. Python Easy
ginortS An uneasy sort. Python Medium

Python Functionals

Name Preview Code Difficulty
Map and Lambda Function This challenge covers the basic concept of maps and lambda expressions. Python Easy
Validating Email Addresses With a Filter This question covers the concept of filters. Python Medium
Reduce Function Python Practice Python Medium

Regex and Parsing

Name Preview Code Difficulty
Detect Floating Point Number Validate a floating point number using the regular expression module for Python. Python Easy
Re.split() Split the string by the pattern occurrence using the re.split() expression. Python Easy
Group(), Groups() & Groupdict() Using group(), groups(), and groupdict(), find the subgroup(s) of the match. Python Easy
Re.findall() & Re.finditer() Find all the pattern matches using the expressions re.findall() and re.finditer(). Python Easy
Re.start() & Re.end() Find the indices of the start and end of the substring matched by the group. Python Easy
Regex Substitution Substitute a string using regex tools. Python Medium
Validating Roman Numerals Use regex to validate Roman numerals. Python Easy
Validating phone numbers Check whether the given phone number is valid or not. Python Easy
Validating and Parsing Email Addresses Print valid email addresses according to the constraints. Python Easy
Hex Color Code Validate Hex color codes in CSS. Python Easy
HTML Parser - Part 1 Parse HTML tags, attributes and attribute values using HTML Parser. Python Easy
HTML Parser - Part 2 Parse HTML comments and data using HTML Parser. Python Easy
Detect HTML Tags, Attributes and Attribute Values Parse HTML tags, attributes and attribute values in this challenge. Python Easy
Validating UID Validate all the randomly generated user identification numbers according to the constraints. Python Easy
Validating Credit Card Numbers Verify whether credit card numbers are valid or not. Python Medium
Validating Postal Codes Verify if the postal code is valid or invalid. Python Hard
Matrix Script Decode the Matrix. Python Hard

XML

Name Preview Code Difficulty
XML 1 - Find the Score Learn about XML parsing in Python. Python Easy
XML2 - Find the Maximum Depth Find the maximum depth in an XML document. Python Easy

Closures and Decorators

Name Preview Code Difficulty
Standardize Mobile Number Using Decorators Use decorators to standardize mobile numbers. Python Easy
Decorators 2 - Name Directory Use decorators to build a name directory. Python Easy

Numpy

Name Preview Code Difficulty
Arrays Convert a list to an array using the NumPy package. Python Easy
Shape and Reshape Using the shape and reshape tools available in the NumPy module, configure a list according to the guidelines. Python Easy
Transpose and Flatten Use the transpose and flatten tools in the NumPy module to manipulate an array. Python Easy
Concatenate Use the concatenate function on 2 arrays. Python Easy
Zeros and Ones Print an array using the zeros and ones tools in the NumPy module. Python Easy
Eye and Identity Create an array using the identity or eye tools from the NumPy module. Python Easy
Array Mathematics Perform basic mathematical operations on arrays in NumPy. Python Easy
Floor, Ceil and Rint Use the floor, ceil and rint tools of NumPy on the given array. Python Easy
Sum and Prod Perform the sum and prod functions of NumPy on the given 2-D array. Python Easy
Min and Max Use the min and max tools of NumPy on the given 2-D array. Python Easy
Mean, Var, and Std Use the mean, var and std tools in NumPy on the given 2-D array. Python Easy
Dot and Cross Use NumPy to find the dot and cross products of arrays. Python Easy
Inner and Outer Use NumPy to find the inner and outer product of arrays. Python Easy
Polynomials Given the coefficients, use polynomials in NumPy. Python Easy
Linear Algebra NumPy routines for linear algebra calculations. Python Easy

Debugging

Name Preview Code Difficulty
Words Score Calculate the total score of the list of words. Python Medium
Default Arguments Debug a function which uses a default value for one of its arguments. Python Medium