blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2e0c505f8829e26ba1e53b46675c190f9f92adb8
SirKitboard/Notes
/CSE373/Assignment2/frequentElement.py
793
3.546875
4
# A: array, n: length def findPossibleFrequentElement(A, n): possibleIndex = 0, count = 1 for index, element in A: if(A[possibleIndex] == element): count+=1 else: count-=1 if(count == 0): possibleIndex = index count = 1 return a[possib...
7a2e59b37a4c7764ad4ee1bfff9c381d31781a58
SirKitboard/Notes
/CSE307/Homework 7/HW7Project/Operations/Boolean.py
1,865
3.546875
4
# Aditya Balwani # SBUID: 109353920 from Nodes import Node from Exceptions import * class Xor(Node.Node): """ A node representing the boolean and """ def __init__(self, left, right): self.left = left self.right = right def evaluate(self): left = self.left.evaluate() ...
022993679aa89bd6767c9158614cc4115e583ec2
m5z/project-euler
/p065.py
231
3.59375
4
def program(): a, b = 2, 3 m = 1 for n in xrange(3, 101): if n % 3 == 0: a, b = b, a + b + b * m m += 2 else: a, b = b, a + b print sum(map(int, list(str(b)))) if __name__ == '__main__': program()
309a6ffa0e22dd514624041f3ba43e31c566def6
m5z/project-euler
/p063.py
242
3.625
4
def program(): count = 9 p = 2 while p < 100: b = 2 ln = 1 while ln <= p: n = b ** p ln = len(str(n)) if ln == p: count += 1 b += 1 p += 1 print count if __name__ == '__main__': program()
972308267fed1d0e211ac327bec7beba408c8f57
b20bharath/Python-specialization
/python-access_web_data/XMLurllib.py
645
3.53125
4
# extract an xml from the given website and display the sum of the values present in count tag of comment elements present in that xml # URL: http://py4e-data.dr-chuck.net/comments_254940.xml import urllib.request, urllib.parse, urllib.error import xml.etree.ElementTree as ET import ssl ctx = ssl.create_default...
c814681303df9ad7e47a20fbfb1f03fcbab21402
b20bharath/Python-specialization
/python-data structures basic/dictionaries_file.py
724
3.796875
4
# Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail name = input("Enter file:") if len(name) < 1 : name = "mbox-short.txt" handle = open(na...
e48d5a9ed6e57a44324b61340491e261099e3804
chauhanvishu/bbc
/bb/file handling/q3.py
256
3.5
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 23 00:02:04 2018 @author: aksha """ with open("sam.txt", "r") as f: with open("output.txt", "w") as f1: for word in f: f1.write(word) print("New copied file created is output.txt")
fc39fd067665d105dfc95052d3cc6ebbb9a1686b
chauhanvishu/bbc
/bb/CLASS 1/q5.py
708
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 22 21:52:47 2018 @author: aksha """ class Expenditure(): def __init__(self, expenditure, savings): self.expenditure = expenditure self.savings = savings def Display(self): print("\n\nExpenditure is : " + str(self.expenditure)) p...
6ec66df47ad75fe57ed438786d135a3615a81a0c
chauhanvishu/bbc
/bb/CLASS 1/q3.py
502
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 22 21:51:05 2018 @author: aksha """ class Temperature(): def convertFahrenhiet(self,celsius): print("Temperature in Fahrenhiet is : " + str((celsius*(9/5))+32)) def convertCelsius(self,farenhiet): print("Temperature in Celsius is : " +...
d53208cbb137eaefbffe0ca6742ee5099c6f3521
chauhanvishu/bbc
/cc/quu1.py
401
4.09375
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 18 22:50:50 2018 @author: aksha """ year = 2000 if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) else: print("{0} is...
4b3712977fa17f5ab732c39a01953f239c1e6717
chauhanvishu/bbc
/bb/thread/q2.py
333
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 22 22:13:14 2018 @author: aksha """ import threading import time class mythread(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print("\nThread Starting") i=1 while i<=5: print(i...
f17500b45cc7197b4b1ed6c4a077d5de3f4813b4
christopherchoe/holbertonschool-higher_level_programming
/0x0A-python-inheritance/4-inherits_from.py
268
3.828125
4
#!/usr/bin/python3 def inherits_from(obj, a_class): """ Function returns True if object is instance of inherited from class otherwise return False """ if issubclass(type(obj), a_class) and type(obj) != a_class: return True return False
10e84373d04717c084c69eb2d0f9976a4221912e
christopherchoe/holbertonschool-higher_level_programming
/0x03-python-data_structures/10-divisible_by_2.py
254
3.9375
4
#!/usr/bin/python3 def divisible_by_2(my_list=[]): if type(my_list) is list: new_list = [True]*len(my_list) for i in range(len(my_list)): if my_list[i] % 2 is 1: new_list[i] = False return new_list
e6fe341768d007766eb33da4d29d8e88b06f8b17
christopherchoe/holbertonschool-higher_level_programming
/0x0B-python-input_output/12-student.py
968
3.828125
4
#!/usr/bin/python3 """ defines a class Student """ class Student(): """ student with name and age """ def __init__(self, first_name, last_name, age): """ initialization """ self.first_name = "" self.last_name = "" self.age = 0 if isinstance(first...
2822ffe79f1192682f91fadeda428b8a069fbbb9
christopherchoe/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/7-islower.py
113
3.65625
4
#!/usr/bin/python3 def islower(c): if ord(c) < 123 and ord(c) > 96: return (True) return (False)
7e99b4f65e36ff6b672ad7d5b2e704005c04565c
diwakarmalla/myarray
/deco.py
576
3.75
4
def decorator(func): print(" i have decorated some function") return 5 def decorator2(func): print(" i have decorated some function") return func import datetime def decorator3(func): def wrapper(x): today = str(datetime.datetime.today()) with open('log_square.txt', 'a') as f: ...
b9fd0e77353b1a8a8a2df55e5e8bbdaa89565265
Mosquitooo/Practice
/Python/backup/20150701.zip/loop_branch.py
329
3.78125
4
#!/bin/python number = 23 runing = True def success(): print "loop over" while runing: guess = int(raw_input('enter a number')) if guess == number: print "you get it" runing = False; #break elif guess < number: print "<" else: print ">" else: success() print "done" print succes...
018ade1b9b20f2eecbe4c050430263db50dd1777
hansamalhotra/learn-python-the-hard-way
/ex16.py
596
3.703125
4
from sys import argv script, filename = argv print("We're going to erase %r" % filename) print("If you don't want that, hit Ctrl-C ") print("If you want that, hit Return Key") input("? ") print("Opening the file...") target = open(filename, 'w') print("\nTruncating the file. Goodbye! ") target.truncate() print(...
23810686b53ae6c212e1f8577f97ea0782969aa8
hansamalhotra/learn-python-the-hard-way
/ex7.py
480
4.15625
4
print("Mary had a little lamb.") #prints string print("It's fleece was white as %s." % 'snow') #puts string into string and prints print("And everywhere that Mary went.") #similar print("." * 10) #repeated 10 times end1 = "C" end2 = "h" end3 = "e" end4 = "e" end5 = "s" end6 = "e" end7 = "B" end8 = "u" end9 = "r...
50262f0c9916dd3f0046c2ea8b71992291dcf07f
hansamalhotra/learn-python-the-hard-way
/ex15.py
602
4.09375
4
from sys import argv #imports the module argv which takes arguments from terminal script, filename = argv #assigns these arguments txt = open(filename) #opens the file you just passed through script and returns to object called txt print("Here's your file %r: " % filename) #display file name print(txt.read...
d1d4ab6aa0195f30c9da2f7756e539c71d4fd4fd
Pati20/Python-course
/Lista 3./zadanie4.py
455
3.796875
4
# Author: Patrycja Paradowska # 28 marca 2020r. Lista 3. Python, Zadanie 4. Quicksort from typing import List def quicksort(l: List): if len(l) == 0 or len(l) == 1: return l first, others = l[0], l[1:] elts_lt_x = list(filter(lambda x: x <= first, others)) elts_greq_x = list(filter(lambda x: x...
5d726923bf18c6b30f4847ef1e92765c8d51d57e
Pati20/Python-course
/Lista 3./zadanie1.py
330
3.640625
4
# Author: Patrycja Paradowska # 28 marca 2020r. Lista 3. Python, Zadanie 1. Transpozycja macierzy from typing import List def transposition(matrix: List[str]) -> List[str]: return [" ".join(row.split()[i] for row in matrix) for i in range(len(matrix))] matrix = ["1.1 2.2 3.3", "4.4 5.5 6.6", "7.7 8.8 9.9"] print...
19abee9c2646c62a4f39a38ff48c4962c95829fd
mtypy/Reptile
/day_02/代理.py
543
3.53125
4
# 导入模块 import requests # 定义请求地址 url = "http://www.baidu.com" # 自定义请求头 headers = { "User-Agent": "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" } # 定义代理服务器 proxies = { # "http": "http://IP地址:端口号", # "https": "https://IP地址:端口号" "http"...
fa96fa8b2340a1944b8cbe1fce3db725c664288c
MaxShi007/leetcode_solutions
/8. 树的DFS/113. Path Sum II.py
841
3.796875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # 返回二维列表,内部每个列表表示找到的路径 def pathSum(self, root, expectNumber): # write code here if not root: return [] ...
87c96d4ad94518c7c82d1d44f86658e8cdb24ae7
MaxShi007/leetcode_solutions
/23. 二叉搜索树/二叉树的下一个结点.py
703
3.6875
4
# -*- coding:utf-8 -*- # class TreeLinkNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # self.next = None class Solution: def GetNext(self, root): # write code here if not root: return None if root.right: ...
8b7cf8cd4ee360ded0f0af7daa0624957d8193a9
MaxShi007/leetcode_solutions
/2. 双指针/剑指 Offer 21. 调整数组顺序使奇数位于偶数前面.py
412
3.640625
4
class Solution: def reOrderArray(self, array): # write code here if not array or len(array) == 1: return array i = 0 for j in range(len(array)): if array[j] % 2 != 0: k = j while k > i: array[k], array[k-1] =...
12a900b8d6ca1967e38b032979dc2005b71cbe8c
MaxShi007/leetcode_solutions
/8. 树的DFS/剑指 Offer 54. 二叉搜索树的第k大节点.py
625
3.703125
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # 返回对应节点TreeNode def KthNode(self, pRoot, k): # write code here res = [] self.in_order(pRoot, res, k) if k <= 0 or k...
36b734b2f014677e31ceb12121602cc881529178
SirIsaacNeutron/UCI-CS-Helper-Bot
/test_uci_cs_helper.py
5,506
3.75
4
import unittest from uci_cs_helper import text_about_switching_to_cs as text class TestBot(unittest.TestCase): """Note: these tests are based off real texts and posts from /r/UCI. """ def test_detecting_texts_true(self): """Test the bot's ability to detect text that is legitimately abo...
002f873f63adb23aadfcf2ed40a541e792b1b659
naydichev/advent-of-code-solutions
/2020/13/puzzle2.py
775
3.703125
4
#!/usr/bin/env python3 def main(): with open("bus.pi") as f: _, busses = parse(f.readlines()) busses = [b if b != "x" else 1 for b in busses] time = 0 lcm = 1 for idx, bus in enumerate(busses): # while the (time + index) is not an even multiple of time while (time + idx) %...
335c7ae912658cdbe72c61f3d47f1bf3cfa85fd9
naydichev/advent-of-code-solutions
/2018/07/puzzle_1.py
854
3.546875
4
#!/usr/bin/python from copy import deepcopy def main(): with open("instructions.pi") as f: raw_steps = f.read().split("\n") steps = parse_steps(raw_steps) order = determine_step_order(steps) print(order) def parse_steps(raw_steps): steps = {chr(k): set() for k in range(ord('A'), ord('Z...
643f2e31dd0b4fa6984e139fa648a97eac43a953
naydichev/advent-of-code-solutions
/2018/11/puzzle_1.py
1,158
3.734375
4
#!/usr/bin/python def main(): fuel_cells = build_fuel_cells(serial=7315) find_max_power = search_fuel_cells(fuel_cells) print("Max fuel cell starts at coordinate", find_max_power) def build_fuel_cells(serial): fuel_cells = [None] for x in range(1, 301): fuel_cells.append([None]) ...
47eaba90c42b947b276d7ca38c10231446ee9826
naydichev/advent-of-code-solutions
/2015/13/puzzle_2.py
2,272
3.71875
4
#!/usr/bin/env python3 from collections import defaultdict, namedtuple from itertools import permutations Happiness = namedtuple("Happiness", [ "a", "amount", "b" ]) def main(raw): data = parse(raw) people = to_people(data) add_me(people) max_happiness = 0 for possible in permutations(people.k...
bd044b2c446d466e663f4553cdef4233fee73af3
naydichev/advent-of-code-solutions
/2018/06/puzzle_1.py
4,330
3.859375
4
#!/usr/bin/python from collections import defaultdict class Coordinate: ID = 0 def __init__(self, x, y): self.center_x = x self.center_y = y self.id = Coordinate.ID Coordinate.ID += 1 def distance_from_xy(self, y, x): return abs(x - self.center_x) + abs(y - self.c...
0b1f2a2bf7518f9f2cc41d1653f2580da4229da8
naydichev/advent-of-code-solutions
/2019/01/puzzle_2.py
384
4
4
#!/usr/bin/env python3 import math def fuel_for_mass(mass): return math.floor(mass / 3) - 2 fuel = 0 with open("mass_values.pi") as f: for line in f: fuel_for_line = fuel_for_mass(int(line)) while fuel_for_line > 0: fuel += fuel_for_line fuel_for_line = fuel_for_mass(f...
a2b39ffb6d724b49db4684f8d162f10c4635571b
naydichev/advent-of-code-solutions
/2020/13/puzzle1.py
733
3.78125
4
#!/usr/bin/env python3 def main(): with open("bus.pi") as f: now, busses = parse(f.readlines()) busses = list(filter(lambda x: x != "x", busses)) quickest_bus = None wait_time = None for bus in busses: n = now // bus next_arrival = bus * (n + 1) waits = next_arri...
d04facfafb9e8a241f78ea331fc73c97ba74632e
naydichev/advent-of-code-solutions
/2018/23/puzzle_1.py
1,024
3.546875
4
#!/usr/bin/python class Nanobot: def __init__(self, x, y, z, radius): self.x = x self.y = y self.z = z self.radius = radius def __repr__(self): return "{}(x={}, y={}, z={}, radius={})".format(self.__class__.__name__, self.x, self.y, self.z, self.radius) def main(nanobo...
c551d0a6fb6f3768cce7e01ae4f49fdcffa487e8
naydichev/advent-of-code-solutions
/2015/19/puzzle_1.py
951
3.796875
4
#!/usr/bin/env python3 from collections import namedtuple Replacement = namedtuple("Replacement", "char to") def main(molecule, raw_replacements): replacements = parse(raw_replacements) possibles = set() for rep in replacements: loc = molecule.find(rep.char, 0) while loc != -1: ...
b5dc55107a67331a936f8a5dcf024cc1c1efb444
cody0322/cody0322.github.io
/Python 基礎計算/子集合超集合判斷.py
443
3.84375
4
s1,s2,s3 = set(),set(),set() print("集合1") while True: x = input() if x == "end": break s1.add(int(x)) print("集合2") while True: x = input() if x == "end": break s2.add(int(x)) print("集合3") while True: x = input() if x == "end": break s3.add(in...
b14736269744436a9f6e962785e80b67502cad4f
arpansahu/HackerRank
/Data Structures/Strings/minimum no of changes two make two strngs anagrams/minimum no of changes two make two strngs anagrams.py
565
3.53125
4
# Complete the anagram function below. def anagram(s): if len(s) % 2 == 1: return -1 else: dict1 = [0] * 26 count = 0 for i in range(len(s)): if i < int(len(s) / 2): dict1[ord(s[i]) - ord('a')] += 1 else: dict1[ord(s[i]) -...
2f245233a5fd0928cf624143dcfa8af73588d489
ksg97031/pyalgo
/cracking_the_coding_interview/chapter01/is_unique_chars.py
378
3.890625
4
from string import ascii_lowercase # character range in 'a' ~ 'z' def is_unique_chars(s): checker= 0 for c in list(map(ord, s)): bit_pos = c - 97 val = 1 << bit_pos if checker & val == val: return False checker |= val return True assert is_unique_chars(ascii_low...
6920ef8f1058c53a063c301b4ff4af1804ea76d5
ksg97031/pyalgo
/cracking_the_coding_interview/chapter01/is_permutation.py
718
3.921875
4
def is_permutation(str1, str2): if len(str1) != len(str2): return False return sorted(list(str1)) == sorted(list(str2)) assert is_permutation("dog", "god") assert not is_permutation("dog", "goda") assert not is_permutation("dog", "goe") def is_permutation2(str1, str2): if len(str1) != len(str2): ...
75fc18849aa15166e43088e4198b8085267ba6e6
Fahadh4444/Coding-Interview-Questions
/TalentBattle/Matrix Longest Equal Value Path/Matrix Longest Equal Value Path.py
1,118
3.796875
4
directions = [[1, 1], [1, -1], [1, 0], [0, 1]] def consecutivePath(matrix): arr = [] m = len(matrix) n = len(matrix[0]) for i in range(m): for j in range(n): if(matrix[i][j] not in arr): if(check(matrix, i, j) == 1): arr.append(matrix[i][j]) ...
51cddb5a96447714197f6aa585f5801f3570d0ff
Praveen5195/Guvi
/SumOfNatNumFOr.py
113
4.21875
4
num = int(input("Enter a number: ")) sum = 0 for n in range(0,num): sum += num print("The sum is",sum)
959f64587ad3025ed4fe6881d840111769b2c044
iluxonchik/distributed-computing-with-python-book
/chapter_2/generators.py
430
4.3125
4
def mygenerator(n): while n: n -= 1 yield n if __name__ == '__main__': for i in mygenerator(3): print(i) # calling the generator function does not generate the sequence, # but rather creates a generator object print(mygenerator(3)) # to acrivate the generator object, y...
a21a4f8cb979ff0e583521410a41778cf2794249
Raani909/project-1
/kk.py
139
3.625
4
a=5 b=6 print(type(a)) print(type(b)) sum=a +b print(sum) input=input('how many apple do you want?') input1=int(input) print(sum+input1)
9d6eeff622ae2b8db348bd57ea0c0f7f3d8a8ac2
letterli/py-cookbook
/algorithm/sort/selection_sort.py
481
3.75
4
# -*- coding: utf-8 -*- # 选择排序 时间复杂度O(n^2) def selection_sort(alist): for fillslot in range(len(alist)-1, 0, -1): position_of_max = 0 for location in range(1, fillslot+1): if alist[location] > alist[position_of_max]: position_of_max = location alist[fillslot], ...
514186d00ea3032b857737fd479a0ac6891b849d
letterli/py-cookbook
/algorithm/sort/bubble_sort.py
774
3.765625
4
# -*- coding: utf-8 -*- # 冒泡排序法 时间复杂度 O(n^2) def bubble_sort(alist): for passnum in range(len(alist) - 1, 0, -1): for i in range(passnum): if alist[i] > alist[i+1]: alist[i], alist[i+1] = alist[i+1], alist[i] alist = [5, 45, 233, 64, 98, 46] bubble_sort(alist) print alist # 短...
7be71dd72201a98d9d04ad512a7af834e21325ad
letterli/py-cookbook
/books/pyauto/chapter1/IPy/conversion_system.py
731
3.734375
4
#! /usr/bin/env python # _*_ coding: utf-8 _*_ # 二进制 八进制 十六进制 转换 # 将十六进制 八进制 二进制 转换成 十进制 print int('0x23', 16) print int('023', 8) print int('1111000', 2) # 将 十进制 转换成 十六进制 八进制 二进制 print bin(120) print oct(19) print hex(120) # 自定义函数实现转化 base = [str(x) for x in range(10)] + [ chr(x) for x in range(ord('A'),ord('...
dcd5709033b39ba17bae733e4ccc7ffa2fe679eb
fusnik1/AlwaysDeadweight
/main.py
1,127
3.828125
4
myMonitorDiagonal = 21.5 monitorRatio = 27/myMonitorDiagonal useRatio = True while(True): userInput = input("Get Launch Angle (Distance/<EnemyDirection>/Wind/<WindDirection>): ") distanceString = userInput.split("/")[0] enemyDirection = userInput.split("/")[1] windspeedString = userInput.split("/")[2] windDirect...
95d8d9e32cecc2acd565ae25ada7e901b0d808ac
thedamnchillguy/RouthHurwitzCriterion
/routh.py
5,035
3.859375
4
from math import ceil from math import floor def routh_hurwitz(coeff, ord = 0): # Segment 1 ord = len(coeff) - 1 chareqn = "" j = 0; for i in range(ord, -1, -1): # Forming the Characteristic Equation String if coe...
a35779cdf476da920b75b9b92169734bf6783510
ysong-2018/Intro-Machine-Learning
/classifiers/mnist_utils.py
3,810
3.5625
4
# Utility routines for the MNIST data set. from sklearn import metrics from sklearn.externals import joblib import itertools import numpy as np import matplotlib.pyplot as plt from PIL import Image #-------------------------------------------------------------------------------------------------------- def compute_me...
ff683dac4995cfa7eda7e76ff7d1d94e970a32ad
xiaomi3792/Python_Study
/part2/Part.2.D.7-tdd.py
740
3.90625
4
# def is_leap(year): # return year % 4 == 0 and (year % 100 !=0 or year % 400 == 0) # # print(is_leap(300)) # 根据闰年的定义: # # 年份应该是 4 的倍数; # 年份能被 100 整除但不能被 400 整除的,不是闰年。 # 所以,相当于要在能被 4 整除的年份中,排除那些能被 100 整除却不能被 400 整除的年份。 def is_leap(year): r = False if year % 4 == 0: r = True if year % 100 =...
ecddd09e6058582e27e433e1073314e9fc1125d0
ALLYOURSR/oag_int_python
/neural_net/NeuralNetFactory.py
5,816
3.546875
4
import tensorflow as tf from objects import NeuralNet from enums import NeuralNetTypes class NeuralNetFactory: def __init__(self): pass def build_net(self, neural_net_type:NeuralNetTypes, num_inputs, run_params): """Instantiates and returns a neural net""" if neural_net_type is NeuralN...
7c2d148d6286e5f9ec27b136d0760ee011ef9333
sameergawande/python-lib
/morsels/get_earliest.py
360
4.03125
4
#!/usr/bin/env python3 def get_earliest(date1,date2): mm1,dd1,yyyy1=date1.split("/") mm2,dd2,yyyy2=date2.split("/") if (yyyy1 < yyyy2): return date1 elif (yyyy1 < yyyy2): return date2 elif (mm1 < mm2): return date1 elif (mm1 > mm2): return date2 elif (dd1 < dd2): return date1 else: return date2 prin...
ad70b1a0304d80aff34c2a77d52071cdbc007c03
i79Animal/DTP
/experiments.py
177
3.625
4
from datetime import datetime, timedelta today = datetime.today() monday = today - timedelta(days=7) sunday = today print(monday.strftime("%d.%m")+'-'+sunday.strftime("%d.%m"))
ee9cd9a907b986e63d2f78cac8364a4d9c2f2872
grokworksllc/Boolean_Converter
/ods_booleanbullfrog.py
2,726
3.515625
4
import csv from collections import defaultdict from pyexcel_ods import get_data import json try: target_ods_read = input('Enter the name of an ods spreadsheet containing a column with '\ 'text that you want to convert to boolean: ') except IOError: print('Can\'t find input that ods file') try: target_...
f59c91d45ac522341b484b2be65f918ccb835e9c
jerrywu65/Leetcode_python
/problemset/011 Container With Most Water.py
913
3.90625
4
''' Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You ma...
dcba3aa13cf886932a2edeca81f25c8e1cde94b5
jerrywu65/Leetcode_python
/problemset/015 3Sum.py
1,449
3.796875
4
''' Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [...
ec8dee048b70026e8c02a186b94b920b883fabfd
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Test_prep/Test_exam_Dec12/multiply_table.py
257
3.75
4
num_str = input() num_1 = int(num_str[0]) num_2 = int(num_str[1]) num_3 = int(num_str[2]) for i in range(1, num_3 + 1): for j in range(1, num_2 + 1): for k in range(1, num_1 + 1): print(f'{i} * {j} * {k} = {k * j * i};')
414952b72675ee8f920613163d946bdb4a78b7d2
ralevn/Python_scripts
/hackerranked/sort_2d_array.py
729
3.78125
4
#!/bin/python3 """ https://www.hackerrank.com/challenges/python-sort-sort/problem """ import sys if __name__ == "__main__": n, m = input().strip().split(' ') n, m = [int(n), int(m)] arr = [] for arr_i in range(n): arr_t = [int(arr_temp) for arr_temp in input().strip().split(' ')] arr.a...
8328c57e20d3238040b282d39fbaf53f1d244d3c
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/multidimentional/matrix_init_1.py
238
3.578125
4
n, m = [int(x) for x in input().split()] text = input() count = 0 matrix = [] for row in range(n): matrix.append([]) for col in range(m): matrix[row].append(count) count += 1 print(*matrix, sep='\n')
e8e5785b628f70c7c401d12b1ae71b5d517a3727
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Data_types/integer_operations.py
147
3.59375
4
num1,num2,num3,num4 = int(input()), int(input()), int(input()), int(input()) result = int ( ( num1 + num2 ) / num3 ) * num4 print(result)
a2863f505feb72941dcaf4c97fb64a96c7265f70
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/Comprtehensions/bunker.py
696
3.609375
4
category_names = input().split(', ') n = int(input()) category_items = {} for c in category_names: category_items[c] = [] tot_items = 0 tot_quality = 0 for _ in range(n): item = input().split(' - ') category = item[0] item_name = item[1] item_qqs = item[2] quantity = int(item...
3fec3d6660478c1a5748cdb2c1a8815e406febda
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Exam_prep/concert.py
1,029
3.671875
4
bands = {} played = {} line = input() while line != 'start of concert': if line.split('; ')[0] == 'Add': name = line.split('; ')[1] members = line.split('; ')[2].split(', ') if name not in bands: bands[name] = members else: for m in members: ...
fb8c285b94c43688521ec8c995403f7bc81061d9
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/Functions/function_executor.py
506
3.75
4
def sum_numbers(num1, num2): return num1 + num2 def multiply_numbers(num1, num2): return num1 * num2 def func_executor(*args): result = [] for t in args: func = t[0] arguments = t[1] result.append(func(*arguments)) return result print(func_executor((sum_numbe...
ceb5672137e5041a57d735e4fa73bd3a709e1723
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/Functions/odd_even.py
349
3.765625
4
def even_odd_sum(cmd, listn): if cmd == 'Odd': result = sum([i for i in listn if i % 2 != 0]) elif cmd == 'Even': result = sum([i for i in listn if i % 2 == 0]) return result command = input() listn = [int(i) for i in input().split(' ')] list_len = len(listn) print(even_odd_su...
d36336bfb63a7944c720e9833da05397e009a773
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Lists_advanced/Excercises/office_chairs.py
510
3.5625
4
number_of_rooms = int(input()) room_list = [input().split(' ') for i in range(number_of_rooms)] free_chairs = 0 is_all_ok = True print(room_list) for i in range(len(room_list)): chairs = room_list[i][0].count('X') taken = int(room_list[i][1]) if chairs >= taken: free_chairs += (chairs...
32244d83bd1e367e43622d6d14ce942d9c0e485f
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Lists_advanced/More_Excercises/Messaging.py
503
3.5625
4
def number_sum(n): sumn = 0 for d in n: sumn += int(d) return sumn def find_index(i, text): recalc_i = i % len(text) return recalc_i def remove_index(i, text): list_text = list(text) list_text.pop(i) return ''.join(list_text) num_list = [n for n in input().spl...
c5e27c08af2fb119a62f4b40ddb57ce292c6f85c
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Exam_prep/registration.py
581
3.65625
4
import re num = int(input()) user_pattern = r'U\$([A-Z][a-z]{2,})U\$' password_pattern = r'P@\$([a-zA-Z]{5,}\d+)P@\$' success = 0 for i in range(num): registration = input() user = re.findall(user_pattern, registration) password = re.findall(password_pattern, registration) if len(user) > 0 ...
25067c9619447ffd220818f784c41bad35369f6b
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/Comprtehensions/flatten_list.py
142
3.796875
4
lists = [x.split() for x in input().split('|')[::-1]] flattened = [num for sublist in lists for num in sublist] print(' '.join(flattened))
280ce28773e981816b2770ca73130113a1e0b729
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/text_processing/valid_user_name.py
407
3.96875
4
def check_validity(text: str): is_valid = True if not (3 <= len(text) <= 16): is_valid = False return is_valid for ch in text: if not (ch.isalnum() or ch == '-' or ch == '_'): is_valid = False break return is_valid user_names = input().split(...
522f5173beeb0763f166742824577a61f5a28eb0
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Exam_prep/mirror_words.py
712
3.6875
4
import re text_string = input() pattern = r'(#|@)(?P<word1>[A-Za-z]{3,})\1\1(?P<word2>[A-Za-z]{3,})\1' words = [] for m in re.finditer(pattern, text_string): words.append((m.group('word1'), m.group('word2'))) if len(words) == 0: print('No word pairs found!') else: print(f'{len(words)} word pa...
ea58761138dfb8c19a5c1614e0a7066ed6a5315b
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/Functions/negativ_vs_positive.py
554
3.796875
4
def seprate(lista): listp = [p for p in lista if p >= 0] listn = [n for n in lista if n < 0] return sum(listn), sum(listp) def compare(n, p): abs_n = abs(n) abs_p = abs(p) if abs_n > abs_p: print('The negatives are stronger than the positives') elif abs_p > abs_n: ...
33ea336fa54830ad6f5690f976f5ec9216742298
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Test_prep/Real_Exam_Dec_14/christmas_market.py
1,472
3.828125
4
budget = float(input()) star_price = 5.69 angel_price = 8.49 lights_price = 11.20 wreath_price = 15.50 candle_price = 3.59 product = input() product_count = 0 sum_spent = 0 while product != 'Finish' and budget - sum_spent >= 0: if budget - sum_spent <= 0: print(f'Not enough money! You need ...
4e104d9f639e4f8e8ab9d60a978359e2df6874e7
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Functions/smallest_number.py
144
3.9375
4
def smallest (n1, n2 ,n3): return min(n1, n2, n3) n1 = int(input()) n2 = int(input()) n3 = int(input()) print(smallest(n1, n2, n3))
b78c50bd6bd35ce87b304ade37dd81d0b411d32f
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Nested_Loops/sum_prime_non_prime.py
834
4.34375
4
line_enetered = '' def is_prime (n): if n <= 3: return True else: if n % 2 == 0: return False else: for i in range(2, n //2): if n % i == 0: return False else: continue retu...
3ed91bb93a93ed4acb5e3b76938f6e5726cb2c18
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/Comprtehensions/word_lengths.py
209
3.875
4
names = input().split(', ') # [print(f'{name} -> {len(name)}') for name in names] # output = [(f'{name} -> {len(name)}') for name in names] print(', '.join([f'{name} -> {len(name)}' for name in names]))
86040cce6570f65603bfafc2c5ae10975ec521ad
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Loops/jenny_secret_message.py
362
4.15625
4
"""https://softuni.bg/trainings/resources/officedocument/42863/basic-syntax-conditional-statements-and-loops-exercise-python-fundamentals-september-2019/2442""" name = input() while name != 'End' and name !='Johny': print(f'Hello, {name}!') name = input() if name == 'Johnny': print('Hello, my lo...
16e5cbad32fff96a206239bf84e7c73595497fbb
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Excercises/time_pluss_15_min.py
205
3.53125
4
hh, mm = int(input()), int(input()) if 0 <= mm < 45: mm = mm + 15 elif hh != 23: hh = hh + 1 mm = mm + 15 -60 else: hh = 0 mm = mm + 15 - 60 print (f'%d:%02d' %(hh,mm))
95e9ee19fb5e694ed72c333a207e5acda668acaa
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Functions/factoriel_division.py
211
3.859375
4
def factorial (n): fact = 1 for i in range(1, n + 1): fact *= i return fact n1 = int(input()) n2 = int(input()) fn1, fn2 = factorial(n1), factorial(n2) print(f'{fn1 / fn2:.2f}')
373bd6d5e0ffce61a26f2207fdc0ed2dde5d2664
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Test_prep/Real_Exam_Dec_14/tax_calculator.py
1,050
3.890625
4
engine_power = int(input()) place = input() eco = input() tax_rate = 0.00 if place == 'Sofia': if engine_power <= 37: tax_rate = 1.43 elif 38 <= engine_power <= 55: tax_rate = 1.50 elif engine_power > 55: tax_rate = 2.68 elif place == 'Vidin': if engine_power <= 37:...
151840e14149f51109bf421f7c74a323cf9eab6c
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Exam_prep/need_for_speed_3.py
1,739
3.796875
4
number_of_cars = int(input()) cars = {} for _ in range(number_of_cars): line = input() car = line.split('|')[0] mileage = int(line.split('|')[1]) fuel = int(line.split('|')[2]) cars[car] = [mileage, fuel] command = input() while command != 'Stop': if command.split(' : ')[0] == 'Dri...
d7cc1a6d401c1eae9f3b865f26d857919e521a1a
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Lists_advanced/the_office.py
544
4.03125
4
def average (li): return sum(li) / len(li) employee_happiness = [int(n) for n in input().split(' ')] happiness_factor = int(input()) factored_happiness = [n * happiness_factor for n in employee_happiness] happy_employees = len([emp for emp in factored_happiness if emp >= average(factored_happiness)]) ...
9174abe1d62631d402dfdaa60c81dffca30fec9c
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Loops/maximum_multiple.py
228
3.8125
4
divisor = int(input()) bound = int(input()) ## понеже търсим мах. въртим от горе на долу for i in range(bound, divisor , -1): if i % divisor == 0: print(i) break
f0314012ddfc930c92119ea6f1046907676299d6
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/mid_exam_prep/black_flag.py
410
3.890625
4
days = int(input()) per_day = int(input()) expected = float(input()) plunder = 0.0 for d in range(1, days + 1): plunder += per_day if d % 3 == 0: plunder += 0.5 * per_day if d % 5 == 0: plunder *= 0.7 if plunder >= expected: print(f'Ahoy! {plunder:.2f} plunder gained.'...
a02283733dd487b36a1867186e87beca99ac7a51
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Exam_prep/inbox_manager.py
880
3.734375
4
collection = {} line = input() while line != 'Statistics': if line.split('->')[0] == 'Add': user = line.split('->')[1] if user not in collection: collection[user] = [] else: print(f'{user} is already registered') elif line.split('->')[0] == 'Send': ...
0ed2673df84bdf72771affd870b47d97622e1671
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Nested_Loops/number_pyramid.py
245
3.65625
4
n = int(input()) counter = 0 for i in range(1, n + 1): if counter >= n: break for j in range (1, i + 1): counter += 1 print(f'{counter} ', end='') if counter >= n: break print()
1f22df9bf2ebe333ce42e576c382abc86294a367
ralevn/Python_scripts
/hackerranked/collection.py
486
3.5
4
from collections import Counter shoeNum = int(raw_input()) shoeSizeLst = map(int,raw_input().split()) custNum = int(raw_input()) custDemand = [(0,0)]*(custNum) for i in xrange(custNum): x,y = map(int,raw_input().split()) custDemand[i] = (x,y) shoeSizeCount = Counter(shoeSizeLst) print shoeSizeCount print shoeS...
643ae16c70de0171c31818c28c2283c093b35086
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Excercises/Fruit_or_vegetable.py
218
4.125
4
product = input() if product in ['banana', 'apple', 'kiwi', 'cherry', 'lemon', 'grapes']: print ('fruit') elif product in ['tomato', 'cucumber', 'pepper', 'carrot']: print('vegetable') else: print ('unknown')
1b29a1284f5c1c15383469baed4e7516730aa059
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Simple_operations/greetings2.py
520
4.15625
4
f_name, s_name, age = input(), input(), int(input()) #### 1st method text = f"{f_name} {s_name} {age - 10}" print(text) #### 2nd method print('my name is %20s %s and I am %d old' % (f_name, s_name, age + 5)) #### 3d Method print("Once upon a time {0} also know as {1}. \nWhen he was already {2} happened something...
d0e208c60a563cd58cdd4fb778d689b3b0157437
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Test_prep/training_lab.py
330
3.703125
4
len, width = float(input()), float(input()) rows_num = len // 1.2 ## маса 40см + място 80см # print(rows_num) col_num = ((width -1) // 0.7) ## - 1м коридор делено на дължината на масата # print(col_num) work_place_n = (col_num * rows_num) -3 print(int(work_place_n))
2f099c2d137fb672012fd84de9e5399365a05507
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Exam_prep/activation_keys.py
1,407
3.5
4
activation_key = input() raw_key = activation_key line = input() while line != 'Generate': if line.split('>>>')[0] == 'Contains': substr = line.split('>>>')[1] if substr in activation_key: print(f'{activation_key} contains {substr}') else: print('Substring ...
54786c0679c8a15339aea87789607951f8f7ad25
ralevn/Python_scripts
/PyCharm_projects_2020/Advanced/queues_stacks/match_brackets.py
437
3.890625
4
text = input() opening_brackets = [] for i in range(len(text)): if text[i] == "(": opening_brackets.append(i) ## keep the index of opening brackets elif text[i] == ")": start_index = opening_brackets.pop() ## the start index will be = the last entered "(" and popped out ...
e28a99ecf373bf9d4639e5c13ad0d70e94c79f31
ralevn/Python_scripts
/PyCharm_projects_2020/Fundamentals/Functions/More_excercises/center_point.py
366
3.890625
4
from math import sqrt def find_distance (x, y): distance = sqrt(abs((x ** 2) + (y ** 2))) return int(distance) points = [tuple([float(input()) for i in range(2)]) for j in range(2)] d1 = find_distance(points[0][0], points[0][1]) d2 = find_distance(points[1][0], points[1][1]) if d1 <= d2: p...
76e564d41c70fd8ccb5f88d8fbede71ad88472eb
ralevn/Python_scripts
/inputval.py
102
3.6875
4
#!/bin/python2.7 val0 = raw_input("Please enter a string: " ) print (val0+ '; ')*3,"Ha Ha Ha :) :)"
8d10321fad0612b5c81e7b6fb137c22953864c16
anonymokata/249eb978-f1b5-11e9-a5a8-1eaabddf5c68
/tests/test_eraser.py
3,864
3.984375
4
import unittest from eraser import Eraser from paper import Paper import string class EraseTests(unittest.TestCase): def setUp(self): self.paper = Paper() self.eraser = Eraser(durability=1000) # tests _erase_char private method def test_should_do_nothing_if_index_out_of_bounds(self): ...
6a608da32cf56a62ec3c5648f11f84c0706efc03
aneezJaheez/CZ2001-Algorithms-Projects
/Substring Search/Algorithm Code/OriginalAlgo.py
12,450
3.90625
4
import time #Original Algorithm #==================================================================================================================================================================================== #=======================================================================================================...
737270cfd05b7036d14cab11441de3f8d730e80a
alexisdavalos/Intro-Python-I
/src/14_cal.py
2,397
4.5
4
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py [month] [year]` and does the following: - If the user doesn't specify any input, your program should ...
08d0e11930a33e247bdb9592c31973a12e67f26b
siriusJinwooChoi/Algorithm_class
/list_test.py
1,045
3.546875
4
import sys def firsttest(): s = raw_input() print s s = s.split() print s s.sort() print s def secondtest(): s = raw_input() tlist = s.split() #First Solution """ for a in range(len(tlist)-1): for b in range(1, len(tlist)-a): if int(tlist[b-1]) > int(tl...
590d36e68c1b8032bef2c5d2b3aaadb531ad6604
mlatif01/pop_1
/pop1 section 5 - Recursion/pop_1_section5.py
911
3.890625
4
#Recursion #1. Recursive Sum def rec_sum(val): if val == 0: return 0 else: tot = rec_sum(val - 1) res = val + tot return res x = int(input()) print(rec_sum(x)) #2. Recursive Exponentiation a = float(input()) n = int(input()) def power(a, n): if n == 0: return 1 ...