├── README.md ├── Day6.py ├── Day7.py ├── Day10.py ├── Day5.py ├── Day0.py ├── Day 3.py ├── Day9.py ├── Day8.py ├── Day 1.py ├── Day 2.py └── Day4.py /README.md: -------------------------------------------------------------------------------- 1 | # 30-days-code 2 | Hackerrank 30 days coding 3 | -------------------------------------------------------------------------------- /Day6.py: -------------------------------------------------------------------------------- 1 | n=int(input()) 2 | for k in range(0,n): 3 | s=input() 4 | even="" 5 | odd="" 6 | 7 | for i in range(0,len(s)): 8 | if i%2==0: 9 | even+=s[i] 10 | else: 11 | odd+=s[i] 12 | print(even,odd) 13 | -------------------------------------------------------------------------------- /Day7.py: -------------------------------------------------------------------------------- 1 | import math 2 | import os 3 | import random 4 | import re 5 | import sys 6 | 7 | 8 | 9 | if __name__ == '__main__': 10 | n = int(input()) 11 | 12 | arr =list( map(int, input().rstrip().split())) 13 | print(" ".join(map(str,arr[::-1]))) 14 | -------------------------------------------------------------------------------- /Day10.py: -------------------------------------------------------------------------------- 1 | n=int(input()) 2 | current=0 3 | max=0 4 | while n>0: 5 | 6 | rem=n%2 7 | 8 | if rem==1: 9 | current+=1 10 | if current>max: 11 | max=current 12 | else: 13 | current=0 14 | n = n // 2 15 | print(max) 16 | -------------------------------------------------------------------------------- /Day5.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | 9 | 10 | 11 | if __name__ == '__main__': 12 | n = int(input()) 13 | for i in range(1,11): 14 | p=n*i 15 | print(n,'x',i,'=',p) 16 | -------------------------------------------------------------------------------- /Day0.py: -------------------------------------------------------------------------------- 1 | #Read a full line of input from stdin and save it to our dynamically typed variable, input_string. 2 | input_string = input() 3 | 4 | # Print a string literal saying "Hello, World." to stdout. 5 | print('Hello, World.') 6 | 7 | 8 | # TODO: Write a line of code here that prints the contents of input_string to stdout. 9 | print(input_string) 10 | -------------------------------------------------------------------------------- /Day 3.py: -------------------------------------------------------------------------------- 1 | import math 2 | import os 3 | import random 4 | import re 5 | import sys 6 | 7 | 8 | 9 | if __name__ == '__main__': 10 | n = int(input()) 11 | if n%2==1: 12 | print("Weird") 13 | else: 14 | if n>=2 and n<=5: 15 | print("Not Weird") 16 | elif n>=6 and n<=20: 17 | print("Weird") 18 | elif n>20: 19 | print("Not Weird") 20 | -------------------------------------------------------------------------------- /Day9.py: -------------------------------------------------------------------------------- 1 | import math 2 | import os 3 | import random 4 | import re 5 | import sys 6 | 7 | # Complete the factorial function below. 8 | def factorial(n): 9 | if n<=1: 10 | return 1 11 | else: 12 | return n*factorial(n-1) 13 | 14 | 15 | if __name__ == '__main__': 16 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 17 | 18 | n = int(input()) 19 | 20 | result = factorial(n) 21 | 22 | fptr.write(str(result) + '\n') 23 | 24 | fptr.close() 25 | -------------------------------------------------------------------------------- /Day8.py: -------------------------------------------------------------------------------- 1 | # Enter your code here. Read input from STDIN. Print output to STDOUT 2 | import sys 3 | 4 | n = int(sys.stdin.readline().strip()) 5 | phoneBook = dict() 6 | 7 | for i in range(0, n): 8 | entry = sys.stdin.readline().strip().split(' ') 9 | phoneBook[entry[0]] = entry[1] 10 | 11 | query = sys.stdin.readline().strip() 12 | while query: 13 | phoneNumber = phoneBook.get(query) 14 | if phoneNumber: 15 | print(query + '=' + phoneNumber) 16 | else: 17 | print('Not found') 18 | query = sys.stdin.readline().strip() 19 | 20 | -------------------------------------------------------------------------------- /Day 1.py: -------------------------------------------------------------------------------- 1 | i = 4 2 | d = 4.0 3 | s = 'HackerRank ' 4 | # Declare second integer, double, and String variables. 5 | integer=int(input()) 6 | floatt=float(input()) 7 | string=input() 8 | 9 | # Read and save an integer, double, and String to your variables. 10 | 11 | # Print the sum of both integer variables on a new line. 12 | print(i+integer) 13 | 14 | # Print the sum of the double variables on a new line. 15 | print(d+floatt) 16 | 17 | # Concatenate and print the String variables on a new line 18 | # The 's' variable above should be printed first. 19 | print(s+string) 20 | -------------------------------------------------------------------------------- /Day 2.py: -------------------------------------------------------------------------------- 1 | import math 2 | import os 3 | import random 4 | import re 5 | import sys 6 | 7 | # Complete the solve function below. 8 | #def solve(meal_cost, tip_percent, tax_percent): 9 | #def solve(meal_cost, tip_percent, tax_percent): 10 | if __name__ == '__main__': 11 | 12 | meal_cost = float(input().strip()) 13 | tax_percent = int(input().strip()) 14 | tip_percent = int(input().strip()) 15 | tip_percent=meal_cost*tip_percent/100 16 | tax_percent=meal_cost*tax_percent/100 17 | totalcost=meal_cost+tip_percent+tax_percent 18 | print(round(totalcost)) 19 | -------------------------------------------------------------------------------- /Day4.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self,initialAge): 3 | # Add some more code to run some checks on initialAge 4 | if initialAge<0: 5 | print("Age is not valid, setting age to 0.") 6 | self.age=0 7 | else: 8 | self.age=initialAge 9 | 10 | def amIOld(self): 11 | if self.age<13: 12 | print("You are young.") 13 | elif self.age<18: 14 | print("You are a teenager.") 15 | else: 16 | print("You are old.") 17 | 18 | 19 | # Do some computations in here and print out the correct statement to the console 20 | def yearPasses(self): 21 | # Increment the age of the person in here 22 | self.age+=1 23 | 24 | t = int(input()) 25 | for i in range(0, t): 26 | age = int(input()) 27 | p = Person(age) 28 | p.amIOld() 29 | for j in range(0, 3): 30 | p.yearPasses() 31 | p.amIOld() 32 | print("") 33 | --------------------------------------------------------------------------------