HackerRank Python Solution - Strings - Designer Door Mat

Mr. Vincent works in a doormat manufacturing company. One day, he designed a new doormat with the following specifications:
  • Mat size must be N x M. (N is an odd natural number, and M is 3 times N.)
  • The design should have 'WELCOME' written in the center.
  • The design pattern should only use |,. and - characters.

HackerRank Python Solution - Built-Ins - ginortS

  • You are given a string S. S contains alphanumeric characters only.
  • Your task is to sort the string S in the following manner:
    • All sorted lowercase letters are ahead of uppercase letters.
    • All sorted uppercase letters are ahead of digits.
    • All sorted odd digits are ahead of sorted even digits.

HackerRank Python Solution - Built-Ins - Any or All

any():
  • This expression returns True if any element of the iterable is true. If the iterable is empty, it will return False.
Code:

>>> any([1>0,1==0,1<0])
True
>>> any([1<0,2<1,3<2])
False

HackerRank Python Solution - Built-Ins - Athlete Sort

  • You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight, and so on). You are required to sort the data based on the Kth attribute and print the final resulting table. Follow the example given below for a better understanding.
  • Note that K is indexed from 0 to M-1, where M is the number of attributes.
  • Note: If two attributes are the same for different rows, for example, if two athletes are of the same age, print the row that appeared first in the input.

HackerRank Python Solution - Built-Ins - eval()

  • The eval() expression is a very powerful built-in function of Python. It helps in evaluating an expression. The expression can be a Python statement or a code object.
  • For example:
>>> eval("9 + 5")
14
>>> x = 2
>>> eval("x + 3")
5
  • Here, eval() can also be used to work with Python keywords or defined functions and variables. These would normally be stored as strings.

You might also like

Deploy your Django web app to Azure Web App using App Service - F1 free plan

In this post, we will look at how we can deploy our Django app using the Microsoft Azure app service - a free plan. You need an Azure accoun...