This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Topic : Algorithms | |
Subtopic : StairCase | |
Language : Python | |
Problem Statement : Write a program that prints a staircase of size 'n'. | |
Url : https://www.hackerrank.com/challenges/staircase/problem | |
''' | |
#!/bin/python3 | |
import math |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Topic : Algorithms | |
Subtopic : StairCase | |
Language : C++ | |
Problem Statement : Write a program that prints a staircase of size 'n'. | |
Url : https://www.hackerrank.com/challenges/staircase/problem | |
*/ | |
#include <bits/stdc++.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(1,int(input())): #More than 2 lines will result in 0 score. Do not leave a blank line also | |
print( int((i*(pow(10, i) - 1)) / 9 )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
def ginortS(input_string): | |
small = "" | |
capital = "" | |
odd = "" | |
even = "" | |
for i in input_string: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# compile the patterns | |
pattern = re.compile( | |
r'^' | |
r'(?!.*(\d)(-?\1){3})' | |
r'[456]\d{3}' | |
r'(?:-?\d{4}){3}' | |
r'$') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
class Complex(object): | |
def __init__(self, real, imaginary): | |
self.real = real | |
self.imaginary = imaginary | |
def __add__(self, no): | |
return Complex(self.real + no.real, self.imaginary + no.imaginary) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plusMinus(arr): | |
countPositive = 0 | |
countNegative = 0 | |
n = len(arr) | |
for i in range(n): | |
if arr[i] > 0: | |
countPositive += 1 | |
elif arr[i] < 0: | |
countNegative += 1 | |
countZero = n - countPositive-countNegative |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void plusMinus(vector<int> arr) { | |
float countPositive = 0; | |
float countNegative = 0; | |
float n = arr.size(); | |
for(int i;i<n;i++) { | |
if (arr[i] > 0) | |
countPositive++; | |
else if (arr[i] < 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plusMinus(arr): | |
countPositive = 0 | |
countNegative = 0 | |
n = len(arr) | |
for i in range(n): | |
if arr[i] > 0: | |
countPositive += 1 | |
elif arr[i] < 0: | |
countNegative += 1 | |
countZero = n - countPositive-countNegative |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_vowel(letter): | |
return letter in ['a', 'e', 'i', 'o', 'u', 'y'] | |
def score_words(words): | |
score = 0 | |
for word in words: | |
num_vowels = 0 | |
for letter in word: | |
if is_vowel(letter): | |
num_vowels += 1 |