micahondiwa / hackerrank_python_challenge

My solution to the HackerRank python challenge problems.

Home Page:https://www.hackerrank.com/dashboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HackerRank Python Challenge

Files

File Questoon
0-say_hello.py Say "Hello, World!" with python.
1-if_else.py Given an integer, n , perform the following conditional actions: If n is odd, print Weird. If n is even and in the inclusive range of 2 to 5, print Not Weird. If n is even and in the inclusive range of 6 to 20, print Weird. If n is even and greater than 20, print Not Weird. Input Format - A single line containing a positive integer, n. Constraints: 1 <= 1 n <= 100. Print Weird if the number is weird. Otherwise, print Not Weird.
2-arithmetic_operations.py Given numbers a and b: The first line contains the sum of the two numbers. The second line contains the difference of the two numbers (first - second).The third line contains the product of the two number.
3-division.py Given two integers a, and b. Add logic to print two lines. The first line should contain the result of integer division, a // b . The second line should contain the result of float division, a / b .
4-loops.py The provided code stub reads and integer, n, from STDIN. For all non-negative integers i < n , print i^2.
5-leap_year.py An extra day is added to the calendar almost every four years as February 29, and the day is called a leap day. It corrects the calendar for the fact that our planet takes approximately 365.25 days to orbit the sun. A leap year contains a leap day. In the Gregorian calendar, three conditions are used to identify leap years: The year can be evenly divided by 4, is a leap year, unless: The year can be evenly divided by 100, it is NOT a leap year, unless: The year is also evenly divisible by 400. Then it is a leap year.
6-print_string.py The included code stub will read an integer, n, from STDIN. Without using any string methods, try to print the following: 123...n. Note that "..." represents the consecutive values in between.
7-list_comprehension.py Let's learn about list comprehensions! You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i, j, k) on a 3D grid where the sum of i + j + k is not equal to n.
8-runner_up.py Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up.
9-nested_lists.py Given the names and grades for each student in a class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line.
10-find_percentage.py The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal.
11-lists.py Consider a list (list = []). You can perform the following commands: insert i e: Insert e integer at position i. print: Print the list. remove e: Delete the first occurrence of integer e. append e: Insert integer e at the end of the list. sort: Sort the list. pop: Pop the last element from the list. reverse: Reverse the list.
12-what_is_your_name.py You are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following: Hello firstname lastname! You just delved into python.
13-capitalize Write a python code that capitalizes the first letter of every word in a sentence.
14-plus_minus.py Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with places after the 6 decimal.
15-mini_max_sum.py Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
16-median.py A function that returns the median value of an array.
17-lonelyInteger.py Given an array of integers, where all elements but one occur twice, find the unique element.
18-diagonalDifference.py Given a square matrix, calculate the absolute difference between the sums of its diagonals.
19-countingSort.py Given a list of integers, count and return the number of times each value appears as an array of integers.
20-maxSum.py function that calculates the maximum sum of k consecutive values in an array using a sliding window approach.
21-binary_gap.py Takes a number N, convers to binary, determines the length of binary gap (the number of consecutive zeros), and returns the maximum binary length.