### HackerRank 30 days of coding – Day 9 ( Recursion)

Task :Write a factorial function that takes a positive integer, N as a parameter and prints the result of N!(N factorial).     Sample Input 3 Sample Output 6 #!/bin/python import math import os import random import re import sys def factorial(n): if n<0: return-1 elif n<2: return1 else: return n*factorial(n-1) if __name__ == ‘__main__’: … More HackerRank 30 days of coding – Day 9 ( Recursion)

### HackerRank 30 days of coding – Day5 ( Loop)

Task : Given an integer, n, print its first 10 multiples. Each multiple n*i (where 1<=i<=10) should be printed on a new line in the form: n x i = result.   Sample Input 2 Sample Output 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 … More HackerRank 30 days of coding – Day5 ( Loop)

### HackerRank 30 days of coding – Day7 ( Array)

TASK : Given an array, A, of integers,N print A’s elements in reverse order as a single line of space-separated numbers. Sample Input 4 1 4 3 2 Sample Output 2 3 4 1 Solution (Python): import math import os import random import re import sys if __name__ == ‘__main__’:       n = int(raw_input())       … More HackerRank 30 days of coding – Day7 ( Array)

### HackerRank 30 days of coding – Day6 ( Lets review)

TASK : Given a string, S, of length N that is indexed from 1 to N-1 , print its even-indexed and odd-indexed characters as space-separated strings on a single line Note: 0 is considered even string. Sample Input 2 Hacker Rank Sample Output Hce akr Rn ak   Solution (Python): T=input() for t in range … More HackerRank 30 days of coding – Day6 ( Lets review)

### HackerRank 30 days of coding – Day4 ( Class vs. Instance)

Sample Input 4 -1 10 16 18 Sample Output Age is not valid, setting age to 0. You are young. You are young. You are young. You are a teenager. You are a teenager. You are old. You are old. You are old.   Solution(Python) : class Person:        def __init__(self,initialAge):               if initialAge>=0:               … More HackerRank 30 days of coding – Day4 ( Class vs. Instance)

### HackerRank 30 days of coding – Day3 ( Intro to Conditional Statements)

Sample Input 0 3 Sample Output 0 Weird Sample Input 1 24 Sample Output 1 Not Weird Solution:  #!/bin/python import math import os import random import re import sys List1=[2,3,4,5] List2=[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] def Weird(): if N%2!=0: print”Weird” elif N%2==0 and N in List1: print”Not Weird” elif N%2==0 and N in List2: print”Weird” elif N%2==0 and 100>=N>20: … More HackerRank 30 days of coding – Day3 ( Intro to Conditional Statements)

### HackerRank 30 days of coding – Day2

TaskGiven the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal’s total cost. Note: Be sure to use precise values for your calculations, or … More HackerRank 30 days of coding – Day2

### HackerRank 30 days of coding – Day1

HackerRank is a great tool to get yourself on track with coding. This is also a great platform in case you would like to do some competitive coding. I had started my journey with HackerRank few days ago with their 30 days code program.In this program they provide you one problem daily and you need … More HackerRank 30 days of coding – Day1