blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
fdf6aa007dfba64cf600b70523fcb90b2e4e9bb1
serdardoruk/Bloomberg-Common-DS-Algo-Python-Solutions
/FirstAscendingDescending.py
993
3.890625
4
''' Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array. Examples : Input: arr[] = {8, 10, 20, 80, 100, 200, 400, 500, 3, 2, 1} Output: 500 Input: arr[] = {1, 3, 50, 10, 9, 7, 6} Output: 50 Corner case (No decreasing part) Input: arr[] = {10, 20, 30, 40, ...
510e94f4b0917901104ed715d07790e5d413af43
serdardoruk/Bloomberg-Common-DS-Algo-Python-Solutions
/PalindromeNumber.py
850
4.0625
4
''' https://leetcode.com/problems/palindrome-number/ Palindrome Number Easy 2256 1539 Add to List Share Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From l...
508e321b0c580032ee4d1c423bfca4f03270cbcc
serdardoruk/Bloomberg-Common-DS-Algo-Python-Solutions
/WordBreakII.py
1,573
3.953125
4
''' 140. Word Break II Hard 1845 372 Add to List Share Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. Note: The same word in the dictionary may be re...
5cebd3fee5dfa14baeae66573ce3250ad938a3b5
Kanataki/Hangman
/newultimate.py
1,479
3.71875
4
import random words = [line.strip() for line in open("words.txt")] word = random.choice(words) def game(): wordlist = list(word) dashes = list('_'*len(word)) print "".join(wordlist) print "".join(dashes) #play = "yes"4 dick_figures = 0 hang_figures = [ """ ______ | | | | | ""...
1c84d366773bdc62c9be558f5fe22ccabc5021ec
sahibzada-hadi/HackerRank-Solutions
/PlusMinus-Solution.py
806
3.828125
4
#!/bin/python3 import math import os import random import re import sys # Complete the plusMinus function below. def plusMinus(arr): count_plus = 0 count_negative = 0 count_zero = 0 pos_ratio = 0.0 neg_ratio = 0.0 zero_ratio = 0.0 for item in arr: if item > 0: count_plu...
1708611d71c2d8dac1a71708e60a277761f62ca9
whoisalan/leetcode
/test.py
883
3.65625
4
def maxsum(list1): index1,index2 = 0,0 sum = 0 for i in range(len(list1)-1): if list1[i] > 0 index2+=1 sum+=i if list1[i] < 0: if list1[] def maxSum(array): length = len(array) sum=array[0] result=array[0] for i in range(0,n): if...
bf8722a00a1c5d47c458ec6271dcb26a19e7ba15
whoisalan/leetcode
/others/prime.py
148
3.5625
4
list1 = [] i = 2 for i in range(2,101): j = 2 for j in range (2,i): if i%j == 0: break else: list1.append(i)
0305c352287750329378aa6af675574d43405a0a
whoisalan/leetcode
/easy/559MaximumDepthofN-aryTree.py
874
3.734375
4
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def maxDepth(self, root): """ :type root: Node :rtype: int """ depth = 1 node = root i...
d356084288eb030e6180b368b5e1082b2f923d61
alionov/stepik_autotest
/2-1_5.py
1,371
3.515625
4
import math import time def calc(x): return str(math.log(abs(12*math.sin(int(x))))) # Импортируем вебдрайвер from selenium import webdriver # Открываем ссылку link = "http://suninjuly.github.io/math.html" browser = webdriver.Chrome() browser.get(link) # Ищем элемент, где записано значение X x_eleme...
a423bd03b5483bf62e9ed5181c4329220e2d550f
gsvetleen/Python-Intermediate
/datesanddatetime/timeExample.py
641
3.875
4
import timeExample # %c -> locale's appropriate date and time representation print("The epoch on this system starts at " + timeExample. strftime('%c', timeExample.gmtime(0))) print("The current timezone is {0} with an offset of {1}".format( timeExample.tzname[0], timeExample.timezone)) if timeExample.dayli...
10f3de900aa99d395d646d5d9e7deca3f7267223
BergC/leetcodepython
/35_search_insert_position/solution.py
274
3.828125
4
class Solution: def searchInsert(self, nums, target): if target in nums: return nums.index(target) nums.insert(0, target) nums.sort() return nums.index(target) answer = Solution().searchInsert([1, 3, 5, 6], 7) print(answer)
48c6c705591607d4503aa23019d6587dcaa3890a
BergC/leetcodepython
/13_roman_integer/13_roman_integer.py
1,007
3.78125
4
class Solution: def romanToInt(self, s: str) -> int: """ Convert a roman numeral to its integer value. https://leetcode.com/problems/roman-to-integer/ :param s: String representing a roman numeral. :return: Integer value of the input. """ roman_numerals = { ...
b13bcac0a9858a26200b3297b54bd6b602b90229
Boopalan7/Quiz-application
/quiz.py
1,934
4.0625
4
import random class QA: def __init__(self, question, correctAnswer, otherAnswers): self.question = question self.corrAnsw = correctAnswer self.otherAnsw = otherAnswers qaList = [QA("Who is the first President of America ?", "George Washington", ["Thomas Jefferson", "Andrew Jackson","John Adams"]...
c0323082cde83d2745f1176ce5895d2aeb912260
kitapkurduhatice/Python
/2.py
120
3.5625
4
sayi1=int(input("Sayı giriniz:")) sayi2=int(input("Sayı giriniz:")) toplam=sayi1+sayi2 print("Sonucunuz:",toplam)
1e4467022acbca6be1e0396a81359fec6da0dae7
aafankadri/Job-Category-Prediction
/ass_9_1.py
699
3.5
4
name = input("Enter file:") if len(name) < 1 : name = "mbox-short.txt" handle = open(name) text = handle.read() #words = text.split() words = list() for line in handle: if not line.startswith("From:") : continue line = line.split() words.append(line[1]) counts = dict() for word in words: ...
495c443eb0086ffd6a36125f8c2695e66e408064
jeremy-techson/PythonBasics
/files2.py
903
3.5625
4
import os with open("data.txt", mode="w", encoding="UTF-8") as file: file.write('''When do you think people die? When they are shot through the heart by a bullet of a pistol? NO. When they are ravaged by an incurable disease? No. When they drink a soup made from a poisonous mushroom!? NO! It's when... they are fo...
e267a34267b31cae25ca650817d9f6ec23097ccc
jeremy-techson/PythonBasics
/tuples.py
621
4.375
4
# Tuples are immutable list numbers = (1, 2, 3, 4, 5) print(numbers) # Operations available to tuples are almost the same with list print(numbers[0:3]) print("Length: ", len(numbers)) numbers = numbers + (6, 7) print(numbers) print("7 in tuple?", 7 in numbers) for num in numbers: print(num, end=", ") print(""...
c7dbd04e9366c46b9f96519166897c682d0cf1aa
aniketratnaparakhi/BasicPythonProgramm
/SimplePythonDay1/BasicPython.py
426
3.71875
4
# edc # Hellow World print("Hellow World") #o/p:- Hellow World # Arithmatic Operation print(2+3) #Addition 5 print(2*3) #Multiplication 6 print(5-6) #substraction -1 print(4/2) #Division 2.0 print(2**2) #Square 4 print(2**3) #cube Num1= int(input("Enter the 1st Number \n"))# take a intiger Num2= i...
b8823ce5da6e4663b7f66b8f4a8e1d6e6a013dec
vpeevski/python_scripts
/lists.py
901
3.875
4
from collections import deque fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana'] print('Apples cout is: ', fruits.count('apple')) print('All Fuits are:', len(fruits)) fruits.reverse() print('Reversed fruis: ', fruits) print('Last is: ', fruits.pop()) print('New last is: ', fruits.pop()) fruitsDe...
6ac861dc0d079cbb07c0e8344df6e7e3a476eec6
Mukezz/FirstAIProject
/numlist.py
220
3.71875
4
listNum = [10,20,30,40,0] if listNum[0] == listNum[-1]: print("Result is True") else: print("Result is False") for i in list --> CHANGES ADDED FROM GITHUB --> Branch Testing --> MAKING CHANGES AGAIN IN GITHUB
eea23e527e5c4e069c628b375ccc8f8f5e80f69c
joseSantorcuato/RaspberryPI-Python
/sesion2/17for.py
270
4.0625
4
#Taller e&m # -*- coding: utf-8 -*- mi_tupla = ("Electronica", 2017, "CDYM", 2, "Nuevos medios", "Python") for x in range(0, 6): print mi_tupla[x]# %d formatea como numero, %s como string string = "Para desglosar una cadena de texto" for x in string: print x
2cdace9a31f08ae9f788a4871315cfd2c100928f
KenanSultan/bestseller_search
/main.py
1,223
3.796875
4
import inquirer from search import * while True: options = [ inquirer.List('opt', message="What would you like to do?", choices=['1: Look up year range', '2: Look up month/year', '3: Search for author', '4: Search for title', 'Q: Quit'], ), ] choi...
fb5aeea26dd41fbeb9a6857358ee9d55bad7e798
RafaelSanzio0/FACULDADE-PYTHON.2
/Material para n2/N2 ESTUDO/Funções/SomaDigito.py
626
4.34375
4
'''9) Dado um número inteiro positivo, escreva um programa modularizado para calcular a soma de seus dígitos. O seu programa deve contar uma função que lê um número inteiro e positivo, bem como uma função, chamada somaDigitos, que recebe um inteiro e positivo n e retorna um inteiro e positivo, representando a soma do...
36020dbf86285bcb3904085cdd86a2abe920d528
RafaelSanzio0/FACULDADE-PYTHON.2
/Material para n2/N2 ESTUDO/Listas/ListaAmigos.py
1,968
4.21875
4
def msg(): print("-=-="*20) print("LISTA DE AMIGOS :)") msg() def op(): print("\n") print("(1) - Cadastrar um amigo no final da lista") print("(2) - Mostrar o nome de todos na lista") print("(3) Cadastrar um amigo no início da lista") print("(4) Remover um nome") print("(5) Substituir u...
2092b035b798d67177d2b6b7588447967ccf3724
RafaelSanzio0/FACULDADE-PYTHON.2
/Material para n2/N2 ESTUDO/Funções/testes.py
142
3.5625
4
def rfunc(n): if n == 0: return 0 else: return rfunc(n - 1) + 2 numero = int(input()) rec = print(rfunc(numero))
2bfd50f716265e9d9d3d745fc2f9e62b4b5f89d6
erb13020/coursera-bioinformatics-specialization
/src/ApproximatePatternCount.py
600
3.8125
4
from src import HammingDistance as hd def approximatePatternCount(genome, pattern, d): ''' Find number of approximate occurrences of a pattern in a string. Input: Strings Pattern and Genome along with an integer d. Output: Count(Text, Pattern) with at most d mismatches. ''' match_count = 0 ...
8dd362690f83a01a8744306fa7d5ff57d25a363b
badholiday/two-farts-taped-together
/choose_your_own_adventure_3.py
9,261
3.875
4
import sys, time, random ##player traits player_name = "" player_is_male = False player_is_white = False player_recognizes = False ##game over states game_over = "GAME OVER" follow_prompt = "Follow the prompt!" ##functions typing_speed = 130 #wpm def slow_type(t): print(t) for l in t: ...
11121d6f2a64ceaf2e32796057b0929958d5c081
krishna924/PythonTutorial
/classExample/BasicObj.py
249
3.703125
4
# Oops Concepts class Cars(object): def __init__(self, make, model): self.carmake = make self.carmodel = model o1 = Cars('bmw', '530i') o2 = Cars('Merc', 'C300') print(o1.carmake + o1.carmodel) print(o2.carmodel + o2.carmake)
ec15085394fcf8206b399909b5645459b06f753e
krishna924/PythonTutorial
/asignments/Exception_handeling.py
298
3.625
4
class excep(object): map1 = {'make' : 'hyundai', 'model': 'sonata', 'year': '2006'} def access(map, key): try: a = map[key] print(a) except: print('Theis is an exception') o1 = excep() o1.access('map1', 'key') o2 = excep('make1')
1714abff11de20ca94b8dd0b9bc6421d7778301a
tjguk/kelston_mu_code
/20181117/get_age.py
628
4
4
"""Ask for someone's date of birth and calculate their age """ import sys import datetime year = int(input("What year were you born? ")) month = int(input("What month were you born? ")) day = int(input("What day were you born? ")) yes_no = input("So you were born on %02d/%02d/%04d. Is that correct? [yes/no]" % (day, ...
2500df19b972bec81642da911c1ee72101bf0ee8
tjguk/kelston_mu_code
/20181124/primes.py
635
4.21875
4
"""A simple function which will indicate whether a number is a prime or not """ def is_prime(n): # # Check every number up to half of the number # we're checking since if we're over half way # we must have hit all the factors already # for factor in range(2, 1 + (n // 2)): if n % factor ...
316e325d6eb23a574569332c4796dc70118847bc
ardenzhan/dojo-python
/arden_zhan/Python/Python Fundamentals/string_list.py
862
4.125
4
''' String and List Practice .find() .replace() min() max() .sort() len() ''' print "Find and Replace" words = "It's thanksgiving day. It's my birthday, too!" print "Position of first instance of day:", words.find("day") print words.replace("day", "month", 1) print "" print "Min and Max" x = [2,54,-2,7,12,98] print "...
5953ab160c08927bfcef4ecbab0c0ae0be8ce6f4
ardenzhan/dojo-python
/arden_zhan/Python/Python Fundamentals/multiplication_table.py
297
4.03125
4
'''Multiplication Table''' for row in range(0, 12 + 1): if row == 0: result = "x" else: result = str(row) for y in range(1,13): if row == 0: row = 1 product = str(y * row) result += "{}{}".format(" ", product) print result
4d79f25d46800b34809bfa18691f99567f91ce20
ardenzhan/dojo-python
/arden_zhan/Python/Python Fundamentals/scores_and_grades.py
800
4.34375
4
'''Scores and Grades''' # generates ten scores between 60 and 100. Each time score generated, displays what grade is for particular score. ''' Grade Table Score: 60-79; Grade - D Score: 70-79; Grade - C Score: 80-89; Grade - B Score: 90-100; Grade - A ''' # import random # #random_num = random.random() # #random funct...
21793499df8a6323dd8bd8bb5634ddd6f08c9d67
muhammad-masood-ur-rehman/Skillrack
/Python Programs/difference-between-lcm-and-hcf-of-two-numbers.py
766
3.75
4
Difference between LCM and HCF of two numbers Two whole numbers N1 and N2 are passed as input. The program must print the difference between the LCM and HCF of these two numbers. Input Format: First line will contain the value of the first number N1 Second line will contain the value of the second number N2 Output For...
c63063ed71536d139b127cc48d2aae18a915e8ba
muhammad-masood-ur-rehman/Skillrack
/Python Programs/adam-number.py
665
4.375
4
Adam number A number is said to be an Adam number if the reverse of the square of the number is equal to the square of the reverse of the number.  For example, 12 is an Adam number because the reverse of the square of 12 is the reverse of 144, which is 441, and the square of the reverse of 12 is the square of 21, whic...
7451ad703a6c8c56d0976ef8e6d481ef3e7feae0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-unit-digit-3-or-6.py
667
4.34375
4
Sum - Unit Digit 3 or 6 The program must accept N integers as the input. The program must print the sum of integers having the unit digit as 3 or 6 as the output. If there is no such integer then the program must print -1 as the output. Boundary Condition(s): 1 <= N <= 100 1 <= Each integer value <= 10^5 Example Input...
1c96e07d40bd8283d1b28ac27fe4c5d8af4d31e4
muhammad-masood-ur-rehman/Skillrack
/Python Programs/replace-border-with-string.py
907
4.3125
4
Replace Border with String The program must accept a character matrix of size RxC and a string S as the input. The program must replace the characters in the border of the matrix with the characters in the string S in the clockwise direction. Then the program must print the modified matrix as the output. Example Inpu...
96800d4314d825c7d1660a34401f3c767dc419aa
muhammad-masood-ur-rehman/Skillrack
/Python Programs/longest-common-subsequence-length.py
1,101
3.71875
4
Longest Common Subsequence Length The program must accept two string values A and B as the input. The program must print the length of the longest common subsequence of the two string values as the output. A common subsequence is a group of characters present in both the string values in the same order. Boundary Condi...
e95beda3e8ab7e968d41e574268d2a4e0a07dadb
muhammad-masood-ur-rehman/Skillrack
/Python Programs/money-with-baba.py
852
4
4
Money with Baba Baba is very kind to beggars and every day Baba donates half of the amount he has when ever a beggar requests him. The money M left in Baba's hand is passed as the input and the number of beggars B who received the alms are passed as the input. The program must print the money Baba had in the beginning...
bdbaafc12d7c0ea170f3a9f3a1866647199f04b7
muhammad-masood-ur-rehman/Skillrack
/Python Programs/reverse-asterisk-triangle-pattern.py
818
3.828125
4
Reverse Asterisk Triangle Pattern Reverse Asterisk Triangle Pattern: The program must accept an integer N as input and print the pattern as given in the Example Input/Output Section. Boundary Condition(s): 3 <= N <= 50 Input Format: The first line contains the value of N. Output Format: The first N*N lines contain the...
ada01c186d7844f188d4231a43681cedd802029c
muhammad-masood-ur-rehman/Skillrack
/Python Programs/product-of-current-and-next-elements.py
1,369
4.125
4
Product of Current and Next Elements Given an array of integers of size N as input, the program must print the product of current element and next element if the current element is greater than the next element. Else the program must print the current element without any modification. Boundary Condition(s): 1 <= N <= ...
5c30823a56d59cc5c51b764f4781fed4b1ba1997
muhammad-masood-ur-rehman/Skillrack
/Python Programs/find-duplicates-in-folder.py
1,562
4.1875
4
Find Duplicates In Folder The directory structure of a file system is given in N lines. Each line contains the parent folder name and child file/folder name. If a folder has two files/folders with the same name then it is a duplicate. Print all the duplicate file/folders names sorted in ascending order. If there is no...
1b4b76f80ed204a2bd55c9bc17e08579158ac462
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-greater-than-50.py
529
3.984375
4
Sum Greater than 50 Sum Greater than 50: Given two integers A and B as input, the program must print YES if the sum of A and B  is greater than 50. Else the program must print NO. Boundary Condition(s): 1 <= A, B <= 999999 Input Format: The first line contains the value of A and B separated by space(s). Output Format:...
63f9c82f95090e789395286b4f977b74ac621a4b
muhammad-masood-ur-rehman/Skillrack
/Python Programs/matching-word-replace.py
1,307
4.3125
4
Matching Word - Replace ? The program must accept two string values P and S as input. The string P represents a pattern. The string S represents a set of words. The character '?' in P matches any single character. The program must print the word in S that matches the given pattern P as the output. If two or more words...
5de0252734c9525ea7956e7cd76d14401e1b3d7d
muhammad-masood-ur-rehman/Skillrack
/Python Programs/python-program-for-interlace-odd-even-from-a-to-b.py
1,509
4.4375
4
Python Program for Interlace odd / even from A to B Two numbers A and B are passed as input. The program must print the odd numbers from A to B (inclusive of A and B) interlaced with the even numbers from B to A. Input Format: The first line denotes the value of A. The second line denotes the value of B. Output Format...
c2b2db90bec32dd87464306cbc8a57b91b3d0243
muhammad-masood-ur-rehman/Skillrack
/Python Programs/odd-even-row-pattern-printing.py
940
4.59375
5
Odd Even Row - Pattern Printing Given a value of N, where N is the number of rows, the program must print the character '*' from left or right depending on whether the row is an odd row or an even row. - If it is an odd row, the '*' must start from left. - If it is an even row, the '*' must start from right. After the...
c814e030ef9e52e97e009845a8f4f3cf63801c98
muhammad-masood-ur-rehman/Skillrack
/Python Programs/consecutive-vowels-count.py
551
3.84375
4
Consecutive Vowels Count Given a string S1, print the count C which represents the number of times a vowel is followed by another vowel in the string S1. Input Format: The first line contains S1 Output Format: The first line contains C. Boundary Conditions: 1 <= Length of S1 <= 1000 Example Input/Output 1: Input: lion...
25e72d166e88791aaac58cdd83ed552c38b3867f
muhammad-masood-ur-rehman/Skillrack
/Python Programs/check-sorted-order.py
1,127
4.125
4
Check Sorted Order The program must accept N integers which are sorted in ascending order except one integer. But if that single integer R is reversed, the entire array will be in sorted order. The program must print the first integer that must be reversed so that the entire array will be sorted in ascending order. Bo...
87438d1c00f99b9d8ad19b0b8b0e9ac9d89e74bd
muhammad-masood-ur-rehman/Skillrack
/C Programs/reverse-every-word.c
731
4.03125
4
Reverse Every Word The program must accept a string S containing multiple words as the input. The program must reverse every word in the string S. Then the program must print the modified string S as the output. Input : Friday and Saturday Output : yadirF dna yadrutaS Explanation: After reversing every word in the str...
a8d6708bf1f9958cd05214bf00e43a3cf3dcdfe0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/count-overlapping-string-pattern.py
1,039
4.1875
4
Count Overlapping String Pattern Two string values S and P representing a string and pattern are passed as the input to the program. The program must print the number of overlapping occurrences of pattern P in the string S as the output. Note: The string S and pattern P contains only lowercase alphabets. Boundary Cond...
b89f9c1aa9bcdc0c8e77d835550d4ad908aa4b3f
muhammad-masood-ur-rehman/Skillrack
/Python Programs/infinite-sequence-nth-digit.py
910
4
4
Infinite Sequence Nth Digit Infinite Sequence Nth Digit: The program must accept an integer value N and print the Nth digit in the integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 and so on till infinity. Boundary Condition(s): 1 <= N <= 10^9 Input Format: The first line contains N. Output Format: Th...
6ee5cd6a8e090682bf699c788e467ccb8cfb975c
muhammad-masood-ur-rehman/Skillrack
/Python Programs/first-m-multiples-of-n.py
558
4.46875
4
First M multiples of N The number N is passed as input. The program must print the first M multiples of the number Input Format: The first line denotes the value of N. The second line denotes the value of M. Output Format: The first line contains the M multiples of N separated by a space. Boundary Conditions: 1 <= N <...
15125f1513e68e317ad5bc79e4f09f7c6dbb4dbd
muhammad-masood-ur-rehman/Skillrack
/Python Programs/direction-minimum-shift.py
2,093
4.3125
4
Direction & Minimum Shift The program must accept two string values S1 and S2 as the input. The string S2 represents the rotated version of the string S1. The program must find the minimum number of characters M that must be shifted (Left or Right) in S1 to convert S1 to S2. Then the program must print the direction (...
c88a8f7c2ef64b308a95bd5b040b5f98df2f40b1
muhammad-masood-ur-rehman/Skillrack
/Python Programs/remove-characters-from-left.py
1,445
4.28125
4
Remove Characters from Left Remove Characters from Left: The program must accept two string values S1 and S2 as the input. The program must print the minimum number of characters M to be removed from the left side of the given string values so that the revised string values become equal (ignoring the case). If it is n...
aa6ea506e424f5b0a50f4537652395b31a901596
muhammad-masood-ur-rehman/Skillrack
/Python Programs/rotate-matrix-pattern.py
1,377
4.46875
4
Rotate Matrix Pattern The program must accept an integer matrix of size N*N as the input. The program must rotate the matrix by 45 degrees in the clockwise direction. Then the program must print the rotated matrix and print asterisks instead of empty places as the output. Boundary Condition(s): 3 <= N <= 100 Input For...
9b32abbfa42cfd5432b46d51ff0cb735193d648c
muhammad-masood-ur-rehman/Skillrack
/Python Programs/tree-shadow-within-matrix.py
2,954
3.90625
4
Tree Shadow within Matrix Certain number of trees are planted in a rectangular matrix field. The trees were planted in an R*C rectangular matrix but certain trees did not grow due to lack of ground water. Hence the cells in the matrix which have the trees are indicated by 1 and the cells which do not have trees in it ...
67f89367d4681a69b6958cf77ee20852a3375d30
muhammad-masood-ur-rehman/Skillrack
/Python Programs/print-soap-name.py
668
3.71875
4
Print Soap Name The following are the soap code characters for the soaps. C or c - Cinthol D or d - Dove L or l - Lux P or p - Pears H or h - Hamam For any other character - Lifebuoy The program must accept the soap code character and print the output accordingly. Input Format: The first line contains the  soap code c...
75428a18eee428fe2ba56c0d874d4ae45eac515b
muhammad-masood-ur-rehman/Skillrack
/Python Programs/polynomial-addition.py
821
4.09375
4
Polynomial Addition Write an algorithm and the subsequent Python program to add the two given polynomials. Assume that the coefficients of each polynomial are stored in a separate list. d=int(input()) p1=[] p2=[] for i in range(d+1): c=int(input()) p1=[c]+p1 #first element is the coefficient of x^0 d=int(input())...
ba4f8c63505647e95ef433c95b096623d19e8ca6
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-of-tenth-and-unit-digits.py
468
4.0625
4
Sum of Tenth and Unit Digits The program must accept a number N and print the sum of tenth and unit digits. Input Format: The first line denotes the value of N. Output Format: The first line contains the sum of tenth and unit digits. Boundary Conditions: 10 <= N <= 9999999 Example Input/Output 1: Input: 231 Output: 4 ...
25dd3e9cef5568f0757a730c305771436c8e074e
muhammad-masood-ur-rehman/Skillrack
/Python Programs/convert-km-hr-to-m-s.py
625
4.03125
4
Convert KM/HR to M/S Speed S of a car is passed as input. It is in kilometers per hour. Write a program to convert the speed from kilometer per hour to meter per second. Boundary Condition: 0 < S < 4500 Input: Speed of a car is passed as input. Output: Speed is converted into meter per second and it is printed in a ne...
0bb5bff0ecb0c1f30c673a5356d78e8cdb9d2bc4
muhammad-masood-ur-rehman/Skillrack
/Python Programs/square-pattern-printing-for-n.py
723
4.03125
4
Square Pattern Printing For N Square Pattern Printing For N: Given N, print the pattern as described in the Example Input/Output. Input Format: The first line will contain N. Output Format: N lines will contain the required pattern. Boundary Conditions: 1 <= N <= 50 Example Input/Output 1: Input: 5 Output: 1 2 3 4 5 2...
4c9e97cb0df3263bfe2c45fdd38fa236d63d3aa0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/search-hexadecimal-value-matrix.py
1,300
4.0625
4
Search Hexadecimal Value - Matrix The program must accept a character matrix of size RxC containing only hexadecimal digits and an integer X as the input. The program must print YES if the hexadecimal value of X is present horizontally (left to right) in the matrix. Else the program must print NO as the output. Bounda...
ea0db6b3d47d53eb6f0af778758c28ad62eb8ec3
muhammad-masood-ur-rehman/Skillrack
/Python Programs/pattern-printing-numbers-zoho.py
584
3.890625
4
Pattern Printing - Numbers [ZOHO] Based on the input value of N, the program must print the pattern described below. Input Format: First line will contain the value of N. Output Format: N lines will contain the number pattern as described below with each value separated by a single space. Boundary Conditions: 1 <= N <...
8ec84a6f4492aa2fc49b4fee6a9e6a9ca41083f6
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-of-digits-is-even-or-odd.py
690
4.125
4
Sum of Digits is Even or Odd Sum of Digits is Even or Odd: Given an integer N as input, the program must print Yes if the sum of digits in a given number is even. Else it must print No. Boundary Condition(s): 1 <= N <= 99999999 Input Format: The first line contains the value of N. Output Format: The first line contain...
4dda396268be58a73b9ad4db6aaaf50024c79912
muhammad-masood-ur-rehman/Skillrack
/C Programs/remaining-balloon-numbers.c
2,258
3.59375
4
Remaining Balloon Numbers Remaining Balloon Numbers: There are N filled balloons each painted with a random number B(i) where i is from 1 to N and the balloons are tied up to a rope in a straight line. M kids who play football arrive and they decide to burst the balloons with the numbers divisible by their jersey numb...
1321a5a0862b67f2f4568189562a86f3444a201e
muhammad-masood-ur-rehman/Skillrack
/Python Programs/batsman-score.py
844
4.125
4
Batsman Score Batsman Score: Given an integer R as input, the program must print Double Century if the given integer R is greater than or equal to 200. Else if the program must print Century if the given integer R is greater than or equal to 100. Else if the program must print Half Century if the given integer R is gr...
f31a385ab7c2c70a424d55f95fd64019967550d6
muhammad-masood-ur-rehman/Skillrack
/Python Programs/smaller-matrix-search-zoho.py
1,945
4.03125
4
Smaller Matrix Search [ZOHO] Smaller Matrix Search [ZOHO]: A bigger NxN matrix is passed as the input. Also a smaller MxM matrix is passed as input. The program must print TRUE if the smaller matrix can be found in the bigger matrix. Else the program must print FALSE. Input Format: First line will contain the value of...
a5d6435650bfca903e04648484bae8dde87f90b7
muhammad-masood-ur-rehman/Skillrack
/Python Programs/n-triangles-pattern.py
1,425
4
4
N Triangles Pattern The program must accept an integer N as the input. The program must print N triangles numbered from 1 to N based on the following conditions. - The Xth triangle contains (2*X)-1 lines. - The 1st line contains the integer 1. - The 2nd line contains the integers from 2 to 1. - The 3rd line contains t...
7cb9fc8d85e5a38b864f0ef7780ab9cd4524a97d
muhammad-masood-ur-rehman/Skillrack
/Python Programs/meeting-late-comers-in-python.py
918
4.0625
4
Meeting Late Comers In Python A certain number of people attended a meeting which was to begin at 10:00 am on a given day. The arrival time in HH:MM format of those who attended the meeting is passed as the input in a single line, with each arrival time by a space. The program must print the count of people who came l...
dc3805fb23ea3f2f06c3263183c16edd3967deed
muhammad-masood-ur-rehman/Skillrack
/Python Programs/toggle-case.py
617
4.3125
4
Toggle Case Simon wishes to convert lower case alphabets to upper case and vice versa. Help Simon by writing a program which will accept a string value S as input and toggle the case of the alphabets. Numbers and special characters remain unchanged.  Input Format: First line will contain the string value S  Output For...
cd8de721b5a119f128606b24071ed7a2c4aafed0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/top-left-to-bottom-right-diagonals-program-in-python.py
1,296
4.28125
4
Top-left to Bottom-Right Diagonals Program In Python The program must accept an integer matrix of size RxC as the input. The program must print the integers in the top-left to bottom-right diagonals from the top-right corner of the matrix. Boundary Condition(s): 2 <= R, C <= 50 1 <= Matrix element value <= 1000 Input ...
6c7286a208f6e7c8152d488ceb97ebb1df8c7bbf
muhammad-masood-ur-rehman/Skillrack
/Python Programs/unique-alphabet-count.py
596
4.3125
4
Unique Alphabet Count A string S is passed as input to the program which has only alphabets (all alphabets in lower case). The program must print the unique count of alphabets in the string. Input Format: - The first line will contain value of string S+ Boundary Conditions: 1 <= Length of S <= 100 Output Format: The ...
5ae44003eed074094a44f7b9f3edf268e48f022f
muhammad-masood-ur-rehman/Skillrack
/Python Programs/python-program-to-print-fibonacci-sequence.py
575
4.5625
5
Python Program To Print Fibonacci Sequence An integer value N is passed as the input. The program must print the first N terms in the Fibonacci sequence. Input Format: The first line denotes the value of N. Output Format: The first N terms in the Fibonacci sequence (with each term separated by a space) Boundary Condit...
aa30202fc51e19c757cfb512b9d9d25f606e42c9
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-of-prime-numbers.py
1,011
3.984375
4
Sum of Prime Numbers Given an integer matrix of size M*N as input, the program must print the sum of prime numbers present in the given matrix. Boundary Condition(s): 1 <= M, N <= 50 Input Format: The first line contains the values of M and N separated by a space. The next M lines contain N elements each separated by ...
1f324b05cc4653d7803396cc3e4c24e6fd7a1a35
muhammad-masood-ur-rehman/Skillrack
/Python Programs/smallest-palindromic-integer-greater-than-x.py
3,716
3.59375
4
Smallest Palindromic Integer - Greater than X The program must accept N unique digits and an integer X as the input. The program must print the smallest palindromic integer, which is formed from the given N digits and is greater than X. Note: At least one non-zero digit is always present in the given N digits. Input F...
10e61b1d76df5b45f241b64dc305f9420d297a2e
muhammad-masood-ur-rehman/Skillrack
/Python Programs/print-numbers-frequency-based.py
1,045
4.46875
4
Print Numbers - Frequency Based An array of N positive integers is passed as input. The program must print the numbers in the array based on the frequency of their occurrence. The highest frequency numbers appear first in the output. Note: If two numbers have the same frequency of occurrence (repetition) print the sma...
eaa670cfee26978ca08dad310a0225d13088d1b6
muhammad-masood-ur-rehman/Skillrack
/Python Programs/value-equals-previous-two.py
1,842
3.984375
4
Value Equals Previous Two An array of N integers is passed as the input. The program must find the combination of integers forming a sequence whose length is more than 4 which satisfies the below conditions. - The ith  index must satisfy arr[i] = arr[i-1] + arr[i-2] - The length of the sequence must be the maximum pos...
1370e5de23f56dad4a80ed2d09096913b7899778
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sparse-matrix.py
706
4.34375
4
Sparse Matrix Write an algorithm and the subsequent Python program to check whether the given matrix is sparse or not. A matrix is said to be a “Sparse” if the number  of zero entries  in the matrix,  is greater than or equal to the number  of non-zero entries. Otherwise it is  “Not sparse”. Check for boundary conditi...
82212ae4feda9fea0df5846fdc235aee5d457ddf
muhammad-masood-ur-rehman/Skillrack
/Python Programs/all-digits-pairs-count.py
1,119
4.21875
4
All Digits - Pairs Count The program must accept N integers as the input. The program must print the number of pairs X where the concatenation of the two integers in the pair consists of all the digits from 0 to 9 in any order at least once. Boundary Condition(s): 2 <= N <= 100 1 <= Each integer value <= 10^8 Input Fo...
ab098a203784a8fd6091c256f2ae176c3422cff1
ZeldaZach/AdventOfCode2020
/entries/day12/main.py
2,508
3.78125
4
import math import pathlib from typing import List, Tuple def circle_x(degrees: int) -> int: return int(math.cos(math.radians(degrees))) def circle_y(degrees: int) -> int: return int(math.sin(math.radians(degrees))) def rotate_x_y(x: int, y: int, degrees: int) -> Tuple[int, int]: """ Rotate X and ...
7fd99e0b695b8b97308b730661c665a8acff02f9
ZeldaZach/AdventOfCode2020
/entries/day15/main.py
869
3.515625
4
import pathlib from typing import List def day15_part1(data: List[int], rounds: int = 2020) -> int: history = {value: index for index, value in enumerate(data)} # Axiom: All data points are unique to start # This means our first prior_value must be 0 prior_value = 0 for time in range(len(data), ...
27381d83b8d936ffeff2ef2e10665d913a7a166b
alexandroid1/PytonStarter_Lesson1_PC
/calculator.py
370
4.1875
4
x = float(input("First number: ")) y = float(input("Second number: ")) operation = input("Operation") result = None if operation == '+': result = x + y elif operation == '-': result = x-y elif operation == '*': result = x*y elif operation == '/': result = x/y else: print('Unsupported operation') i...
70f77d776c25ec8bb620e789c5f579451bb5ba09
tapans/Algorithms-Puzzles-Challenges
/CTCI_6e/1.9_string_rotation.py
1,072
4.15625
4
#!/usr/bin/python import unittest def isSubstring(s1, s2): ''' Returns True if s2 is a substring of s1 ''' return s1 in s2 def is_string_rotation(s1,s2): ''' Returns True if s2 is a rotation of s1 using only one call to isSubstring. False o/w Time Complexity: let a be len of s1, b be len of s2,...
c86d32c8a9dee13f8afe84f0c65fc48029cd22b3
tapans/Algorithms-Puzzles-Challenges
/CTCI_6e/linked_list_node.py
375
3.734375
4
class Linked_List_Node: def __init__(self, data, next): self.data = data self.next = next self.visited = False def __str__(self): return str(self.data) def get_length(self): length = 1 while self.next != None: self = self.next length += 1 return length def print_ll(self): print self whi...
5e5f47e051736a8acfc6d536135480cac0ac0864
tapans/Algorithms-Puzzles-Challenges
/CTCI_6e/1.6_string_compression.py
972
4.03125
4
#!/usr/bin/python import unittest def simple_string_compress(s): ''' Replace consecutive instance of same alphabet with a number ex: aaaaabbccc becomes a5b2c3 Time Complexity: O(n) Space Complexity: O(n) ''' old_len = len(s) if old_len <= _count_compression(s): return s prev = s[0] curr_count = 1 ne...
822f6dc8571702f43a19c9990b1641b1756696d9
tapans/Algorithms-Puzzles-Challenges
/CTCI_6e/1.1_is_unique.py
485
3.90625
4
#!/usr/bin/python import unittest def is_unique(s): ''' Returns True if string s has unique chars. False o/w Time Complexity: O(n) Space Complexity: O(n) ''' seen = {} for c in s: if c in seen: return False else: seen[c] = c return True class Test_Is_Unique(unittest.TestCase): def test_unique_...
7b95790b93f6265d2d962a4afe0d9b9848e7b049
Gadhy/Trabajo-Nro-6
/zena/condiciones multiples/validadormultiple10.py
829
3.96875
4
import os #INPUT frecuencia= float(input("FRECUENCIA: ")) #PROCESSING velocidad_angular= 2*frecuencia #VALIDADOR validador_de_la_velocidad_angular=(velocidad_angular<30) #OUTPUT print("#################################################") print("################## VELOCIDAD ANGULAR ############") print("##############...
d08ffd501fe059ff248ceb58721001a714a5ef01
kbui00/Python
/Learning files/CodeCademy/Pig Latin.py
70
3.5
4
while False: str_input = input('Enter an English word: ')
d39e5d6e0b507b04eef4ada1ac5090d7f396b22d
XiaoqingNLP/SwordOffer
/exp61.py
677
3.8125
4
class Solution: def IsContinuous(self, numbers): if not numbers or len(numbers) != 5: return 0 numbers.sort() num0 = 1 if numbers[0]==0 else 0 for i in range(len(numbers[1:])): if numbers[i] == 0: num0 += 1 elif numbers[i] ...
1dbbd5c585cf84babf622bac75cead11752214be
XiaoqingNLP/SwordOffer
/exp31.py
749
3.515625
4
# -*- coding:utf-8 -*- class Solution: def IsPopOrder(self, pushV, popV): if not pushV or not popV or len(pushV) != len(popV): return stack = [] for i in range(len(popV)): if stack and stack[-1] == popV[i]: stack.pop() continue...
cb6158af7fc4756af191307b8a7258aed6d31f5a
XiaoqingNLP/SwordOffer
/tmp13.py
1,344
3.609375
4
# -*- coding:utf-8 -*- class Solution: def check(self, i, j, threshold): return sum(map(int,str(i)+str(j))) < threshold def movingCount(self, threshold, rows, cols): if threshold < 0 or rows <=0 or cols <= 0: return 0 class Context: acc = 0 ...
b99e8a73cb1f273a053ce19fea24fb21b268cad4
rogercp/Graphs
/projects/ancestor/ancestor.py
1,152
3.5
4
from util import Stack,Queue def retrieve_ancestors(ancestors,node): ancestor_nodes = [] for edge in ancestors: if edge[1] is node: ancestor_nodes.append(edge[0]) return ancestor_nodes def earliest_ancestor(ancestors, starting_node): stack = Stack() stack.push([starting_nod...
6cc8e0ef66b8081d02e8d32f3a9f2c630da61b36
akhileshravi/100-days-of-code
/Old_Attempt_13Days/001/Height_balanced_binary_tree.py
1,265
3.71875
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param A : root node of tree # @return an integer def depthbal(self, A): if A is None: return 0, True f...
aae39fe8b35084e4fdcbca3d878b4e9b897213bd
DrJayLight/Guess_My_Department
/testlistboxselection.py
704
3.515625
4
import Tkinter as tk class SampleApp(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.lb = tk.Listbox(self) self.lb.insert("end", "one") self.lb.insert("end", "two") self.lb.insert("end", "three") self.lb.pack(side="top", fill="...
e5312e7b20e2f737d77d3b14b6663139d88d4557
wcompton019/HW2
/stack.py
3,596
3.921875
4
# HW2: Stack # Budget 10+ hours by Oct. 8 to complete this assignment if you received an autograder score of less than 50 on HW1. # You may use code from class or prior assignments, but may not use internal Python data structures such as lists or arrays. # You are strongly encouraged to use a Linked List. You ca...
338936772ec9b895ae5ed9f16e04139ca699235c
Veena-Arcot/veena1
/student_extract.py
524
3.546875
4
import sqlite3 roll_no int(input("Enter roll no of a student")) def viweall(roll_no): conn = sqlite3.connect("college.db") cur=conn.cursor() cur.execute("SELECT * FROM attedance where roll_no* ?",(roll_no,)) global data data=cur.fetchall() def feedfile(data): f=open("details_for_a_student...
5206d49c9218e20e1c29648a9f0a0eed01b96644
mironmiron3/SoftuniPythonFundamentals
/RegEx/FurnitureGroupdictMethod.py
471
3.640625
4
import re pattern = r">>(?P<furniture>[a-zA-Z]+)<<(?P<price>\d+(\.\d+)?)!(?P<quantity>\d+)" text = input() total_money_spent = 0 print("Bought furniture:") while not text == "Purchase": match = re.search(pattern, text) if match: print(match.groupdict()['furniture']) total_money_spent ...
89d9a4815e9ec1066f5bc43f1509e70ba270342b
mironmiron3/SoftuniPythonFundamentals
/SoftUniParking.py
759
3.859375
4
n = int(input()) registrar = {} for act in range(n): command = input().split() if command[0] == "register": if command[1] in registrar and registrar[command[1]] != command[2]: print(f"ERROR: already registered with plate number {registrar[command[1]]}") else: regi...
3ca9a3b428f6f84978e9a36a1ba89e0e89b656c1
mironmiron3/SoftuniPythonFundamentals
/FunctionsBasics/WinningTicketTextProcess.py
989
3.796875
4
winning_symbols = ['@', '#', '$','^'] def is_valid(ticket): if len(ticket) == 20: return True return False def is_jackpot(ticket): for item in winning_symbols: if item * 20 in ticket: return True return False def is_winning(ticket): for item in winning_symb...