blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9fb4042c554473553486d2e9c2bfe22484c535fa
VDSMath/SudokuLogica2018.2
/GridToString.py
1,303
3.5
4
#TRABALHO 1 - ESTUDO DIRIGIDO: SUDOKU #GRUPO: Gabriel Raposo(115117041), Matheus Vinicius(116023504), Pedro Nascimento(116037448) #PROFESSOR: Joao Carlos DISCIPLINA: Logica PERIODO: 2018/2 from SudokuCheck import CheckIfValid SAVE_PATH = "Maps/" DEFAULT_NAME = "correctInput" LIST_SIZE = 1000 currentMap = 0 def Save...
cef02555c04d85baaab43d484ab3ff5786e21644
CodecoolBP20172/pbwp-3rd-si-game-statistics-PeterBernath
/reports.py
2,238
3.59375
4
def create_list(file_name): results = [] with open(file_name) as inputfile: for line in inputfile: results.append(line.strip().split('\t')) return results def count_games(file_name): results = create_list(file_name) return len(results) def decide(file_name, year): res...
26a24947f2c2f7b8cf589f1466f864467a26b6e6
shivaverma/Machine-Learning-Intro
/codes/k-mean _basic.py
517
3.5
4
# author: Shiva Verma, Mail: shivajbd@gmail.com # k-mean clustering import numpy as np from sklearn.cluster import KMeans def predict_label(feature_data, p): c = KMeans(n_clusters=2) # initialize with two centers c.fit(feature_data) # fitting the data return c.predict(...
e2dba5567511a1b835a5c221e419f7f78b9ff556
SR2k/leetcode
/second-round/92.反转链表-ii.py
3,373
3.953125
4
# # @lc app=leetcode.cn id=92 lang=python3 # # [92] 反转链表 II # # https://leetcode-cn.com/problems/reverse-linked-list-ii/description/ # # algorithms # Medium (55.02%) # Likes: 1133 # Dislikes: 0 # Total Accepted: 242.2K # Total Submissions: 440K # Testcase Example: '[1,2,3,4,5]\n2\n4' # # 给你单链表的头指针 head 和两个整数 lef...
e64450c52f65ff365c173d3ec4226c08969d8072
vim-hjk/python-algorithm
/code/merge_2.py
910
4
4
def mergesort(num): if len(num) > 1: mid = len(num) // 2 left = num[:mid] right = num[mid:] left_list = mergesort(left) right_list = mergesort(right) return merge(left_list, right_list) else: return num def merge(left_list, right_list): left_idx = 0...
30918426df8675f94c22725eec6b02ef35510d3b
Foknetics/AoC_2018
/day11/day11-1.py
829
3.671875
4
def power_level(x, y): serial_number = 5034 rack_id = x+10 power_level = rack_id*y power_level += serial_number power_level = power_level * rack_id try: power_level = int(str(power_level)[-3]) except IndexError: power_level = 0 return power_level - 5 best_cell = (0, 0) b...
c1659bf55cf21f40eaf6aff2b2f6fe6b91c016d6
iriza99/RepoWorkflow
/AnalisisPyhton.py
689
3.578125
4
import pandas as pd import matplotlib.pyplot as plt # Read the dataset athletes_data = pd.read_csv("Forbes Richest Atheletes (Forbes Richest Athletes 1990-2020).csv") # Group athletes by year and calculate mean earnings for each group athletes_by_year = athletes_data.groupby('Year') mean_earnings_by_year = at...
b43df81d1e999e1bdad2278727f0bff951884a64
thiagomachadox/datascience-visualizacaocompython
/datascience_visualization/7_salvarfiguras.py
745
3.71875
4
#Grafico Scatterplot import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [2, 3, 7, 1, 0] #variavel do tamanho dos x no plt.scatter() z = [30, 40 , 50, 100] #Variaveis a serem acessadas na plotagem titulo = "Scatterplot: gráfico de dispersão" eixox = "Eixo x" eixoy = "Eixo y" #Legendas plt.title(ti...
9e1d63c13e5fa7d99a8ac77cec4dfc78bcac4edd
kmark1625/Project-Euler
/p35.py
1,823
3.765625
4
def main(): print num_circular_primes(1000000) def num_circular_primes(max_num): count = 0 for i in range(1,max_num): if is_circular_prime(i): count += 1 return count def is_circular_prime(num): circular = True rotations = circular_rotations(num) for num in rotations: if not is_prime(num):...
a57bed7e8e1807d505ec50d1f1ea915666a53576
ZhengyangXu/LintCode-1
/Python/Search a 2D Matrix II.py
1,452
3.9375
4
""" Write an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it. This matrix has the following properties: * Integers in each row are sorted from left to right. * Integers in each column are sorted from up to bottom. * No duplicate integers in each row or colum...
23ccb927a00abafb519db980859ae354fab3080d
Thmyris/COMU-BilimselHesaplama
/Odev2.Root finding, Newton Raphson Method.py
852
3.71875
4
def f(x): return(x**2-4*x+3) def dfdx(x): return (2*x-4) x = int(input("koke yakin bir x sayisi tahmin edin: ")) if (f(x) == 0): # yani fonksiyona gonderdigimiz x'in # y degeri 0 ise direk koku bulmusuz demektir. print("tahmininiz denklemin kokudur") else: print("En yakin kok hesaplaniyor..."...
528062e3ad00a55e7f33743dae5280a4fbd30e49
SergeyMikhaylov21/Test
/training4.py
279
3.6875
4
import re patt = re.compile('^«[А-ЯЁ]?, [а-яё]*, [1-9]»$') with open ('C:\\Users\\student\\Desktop\\Китай.txt', 'r', encoding='utf-8') as f: s = f.read() words = s.split() for word in words: if patt.search(word): print (word)
9e132d0343059d0387378d11cd7c6213a576db76
matijanjic/XLSXtoPPTX
/XLSXtoPPTX.py
3,084
3.640625
4
# A script that takes an existing excel file, reads the required columns that hold the info # (word, sentence, word audio, sentence audio, sentence picture etc.) and arranges it all into a # pptx presentation. The use case is pretty specific, my wife needed it for her phd experiment. # Audio files were generated usin...
5e10e6c3148a4c7722901811788eb24257719622
GolfettoGuilherme/EstudoPython
/estudo_funcoes.py
205
3.75
4
print("Estudo de funcoes") def soma(num1, num2): total = num1 + num2 print(total) return total total_soma = soma(100,155) total_soma_1 = soma(7, 1000) print(total_soma) print(total_soma_1)
377c0e6d5b65461e706dccc549a7f1e960e30808
spendyala/deeplearning-docker
/01-PythonAlgorithms/random/ques_1.py
2,118
3.84375
4
'''You have a list of timestamps. Each timestamp is a time when there was a glitch in the network. If 3 or more glitches happen within one second (duration), you need to print the timestamp of the first glitch in that window. input_lst = [2.1, 2.5, 2.9, 3.0, 3.6, 3.9, 5.2, 5.9, 6.1, 8.2, 10.2, 11.3, 11.8, 11.9] The...
e7696743425c10dede99b88f8a4d7039120e5d5a
pakey/leetcode
/Leetcode/spiral_iterator.py
1,078
3.8125
4
# 给定二维数组实现螺形输出 # arrays = [ # [1, 2, 3, 4], # [5, 6, 7, 8], # [9, 10, 11, 12], # ] # 输出:[1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7] def myfunc(arrays): rows = len(arrays) if rows == 0: return [] elif rows == 1: return arrays[0] else: cols = len(arrays[0]) if col...
7f51c7f32b7864714f706236bc58a93499bf3c4a
Combatjuan/adventofcode
/2018/day02/day2a.py
1,044
3.84375
4
#!/usr/bin/env python3 DEBUG = False def debug_print(s): print(s) def check(s): """Returns two booleans, the first is whether there are character twins. The second is whether there are character triplets.""" t = sorted(s) t.append("\n") has_twins = False has_triplets = False run_count = 1...
d6f97f1b3ccec803b57faaf2ea543c0437016e73
24sh1999/Imaportant
/Cousion_fo_binaryTree.py
1,737
3.5625
4
## Problem Name: Cousion in Binary Tree(leetcode 30 day challenge) ## class Solution: def isCousins(self, root: TreeNode, x: int, y: int) -> bool: def dfs(root, depth, parent): if not root or len(result) == 2: return if ...
a0a0ed5db95408a3963dffb4100a4ab71a2627a3
rafaelperazzo/programacao-web
/moodledata/vpl_data/187/usersdata/265/65010/submittedfiles/al1.py
123
3.9375
4
# -*- coding: utf-8 -*- c = float(input('digite o valor da temperatura em celcius: ')) f = ((9*c)+160)/5 print('%.2f' %f)
edfaa589b3233ab9b054ff973d69dd2215c0c1fa
sakurasakura1996/Leetcode
/leetcode_weekly_competition/201weekly_competition/problem1554_整理字符串.py
1,687
3.734375
4
""" 1544. 整理字符串 给你一个由大小写英文字母组成的字符串 s 。 一个整理好的字符串中,两个相邻字符 s[i] 和 s[i + 1] 不会同时满足下述条件: 0 <= i <= s.length - 2 s[i] 是小写字符,但 s[i + 1] 是相同的大写字符;反之亦然 。 请你将字符串整理好,每次你都可以从字符串中选出满足上述条件的 两个相邻 字符并删除,直到字符串整理好为止。 请返回整理好的 字符串 。题目保证在给出的约束条件下,测试样例对应的答案是唯一的。 注意:空字符串也属于整理好的字符串,尽管其中没有任何字符。 示例 1: 输入:s = "leEeetcode" 输出:"leetcode" 解释:无论你第一...
c653b82f51e3f15a3d9259180c2e82e611be5cbe
alesandroninazarena/frro-soporte-2019-06
/Practico-01/ejercicio-14.py
1,031
4.15625
4
#Programe un algoritmo recursivo que encuentre la salida de un laberinto. lab = [[True, False, True, True], [False, False, True, False], [True, True, True, False], [True, False, True, True]] def salida_laberinto(fila, columna): if (fila == 3) and (columna ==1): print("Salida encontra...
8146cf27c4f9456b13ea359a574bff98b8b9a21c
ljyadbefgh/python_test
/test1/test2_1.py
75
3.703125
4
#if语句 a=5 if a>10: print("a大于10") else: print("a小于10")
d41c527cf5ea31817dca7ad4fe99ca1989f6c2ea
bruiken/ModelChecking
/variableorderings/baseordering.py
730
3.96875
4
class Ordering: """ Abstract class for variable ordering. Implementations should implement the "order_variables" function. """ def __init__(self, ordering_type): """ Constructor for a variable ordering. :param ordering_type: type of the ordering (algorithm used) """ ...
ab2c0267f4a8588da803034ab985fc31da2fac3f
frankschmitt/advent_of_code
/2022/01-calorie_counting/CalorieCounting.py
1,150
3.515625
4
from pipe import Pipe, map, sort, take class Elf: calories = [] def __init__(self, calories = []): self.calories = calories self.sum_calories = sum(self.calories) @Pipe def split_elves(iterable): e = [] for line in iterable: if line == "\n": yield Elf(e) e = [] el...
d1ea58bfdf46067949d310551e9b3fd80f4ba0bd
1mozolacal/Machine_Learning_Challenge
/refCode/testPlot.py
749
3.75
4
# example from https://python-graph-gallery.com/122-multiple-lines-chart/ # libraries import matplotlib.pyplot as plt import numpy as np import pandas as pd # Data df=pd.DataFrame({'x': range(1,11), 'y1': np.random.randn(10), 'y2': np.random.randn(10)+range(1,11), 'y3': np.random.randn(10)+range(11,21) }) print(df) #...
4d7e78b8b438933d6d60b9425e958c12524edcb5
MrMohammadY/dollar-toman-exchanger
/main.py
401
3.90625
4
from constants import dollar_to_toman def price_menu(): show_menu = True while show_menu: number_of_dollars = int(input('how much dollar you have?\n enter 0 to quit\n')) if not number_of_dollars: show_menu = False result = dollar_to_toman(dollar = number_of_dollars) ...
ac13f29f084aa3a4b13c627ac33cdb5c77ff781b
graytoli/pdxcode_labs
/python_labs/pdx_lab11.py
628
4.1875
4
# Lab 11: Simple Calculator, version 1 operator = input('What operation would you like to perform? ').strip() operand1 = float(input('What is the first number? ').strip()) operand2 = float(input('What is the second number? ').strip()) if operator == '+': solution = operand1 + operand2 elif operator == '-': so...
36d9c23461c7ccce151b5b06fc746888889a0ae6
mryyomutga/TechnicalSeminar
/src/textbook/chapter6/chapter6-1/chapter6-1-3.py
922
4.125
4
# -:- coding: utf-8 -*- # オブジェクト指向について3 class BMI: """BMIを計算する""" def __init__(self, weight, height): """コンストラクタ""" self.weight = weight self.height = height self.calcBMI() def calcBMI(self): """BMIを計算する""" h = self.height / 100 self.bm...
5f5ba40c58089852a49998739f358e3e02ac3f13
koten0224/Leetcode
/1137.n-th-tribonacci-number/n-th-tribonacci-number.py
183
3.609375
4
class Solution: def tribonacci(self, n: int) -> int: a,b,c=0,1,1 if n<3:return (a,b,c)[n] for _ in range(2,n): a,b,c=b,c,a+b+c return c
2c962fc4dc6957ce1ab4bc9cd18e67171ad91662
Jfprado11/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/0-square_matrix_simple.py
141
3.578125
4
#!/usr/bin/python3 def square_matrix_simple(matrix=[]): new_list = [list(map(lambda x: x * x, x)) for x in matrix] return (new_list)
d371488a2a4a7cf643d377a3d15176e37535dc55
satori-koishi/Spider_All
/GitImgcaptcha/Calculation.py
1,274
3.71875
4
def calculation(expression): ChartDict = {'零': '0', '一': '1', '二': '2', '三': '3', '四': '4', '五': '5', '六': '6', '七': '7', '八': '8', '九': '9', '0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9'} test = expression ...
12c7065f8de6b34641092c344ec4a7ed9680e7d6
Ritvik-Sapra/IDEA2
/code.py
1,829
3.828125
4
import json # Function to convert txt file to json def json_converter(filename): # Creating an empty dictionary dict = {} firstPass = True out_file = open('output.json', 'w') with open(filename) as fh: # Processing meta data for line in fh: # Starting of meta data ...
c216c1c29270c9e66a64c4efe91777ea2f635bfd
Dawinia/LeetCode
/Array/605. 种花问题.py
418
3.6875
4
class Solution: def canPlaceFlowers(self, flowerbed, n: int) -> bool: size, i = len(flowerbed), 0 cnt = 0 while i < size: if flowerbed[i] == 0 and (i == 0 or flowerbed[i - 1] == 0) and (i == size - 1 or flowerbed[i + 1] == 0): flowerbed[i] = 1 cnt...
67f45200f327edc790034183d06e4c17e4120528
wissenschaftler/PythonChallengeSolutions
/Level 2/ocr.py
292
3.53125
4
# The URL of this level: http://www.pythonchallenge.com/pc/def/ocr.html strFile = open("ocr.txt",'r') #ocr.txt is where the data is wholeStr = strFile.read() fnlStr = [] for i in wholeStr: if (65 <= ord(i) <= 90) or (97 <= ord(i) <= 122): fnlStr.append(i) print ''.join(fnlStr)
c63f1d78a9ddff61c1cf24a68b1e734a74d3cb42
datim/tools
/file_sorter.py
9,417
3.875
4
#!/bin/python # # This program sorts files into directorys by year. It also re-names the files to put a date and timestamp at the front import sys import os import argparse import time import shutil import datetime import pdb import hashlib ###################################### class FileSorter: """ Sorts and co...
c434a7faff005b69e03c49e16c3681a288b91940
jinliangyu/LeetCode
/137. Single Number II.py
1,298
3.921875
4
""" Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? """ # Time: O(n) # Space: O(1) class Solution(object): def singleNumber(self, nums): ""...
fe4f71cf1194e0df8507cd7b654da1ca23b2d6b0
dankoga/URIOnlineJudge--Python-3.9
/URI_1171.py
380
3.5625
4
if __name__ == '__main__': number_freq = dict() data_size = int(input()) for _ in range(data_size): n = int(input()) if n in number_freq: number_freq[n] += 1 else: number_freq[n] = 1 for number, freq in [(x[0], x[1]) for x in sorted(number_freq.items())]: ...
7240c24b4748df9dfb107d62dabd25b23ac790b6
daniel-reich/ubiquitous-fiesta
/H3t4MkT9wGdL9P6Y3_18.py
173
4.0625
4
def oddish_or_evenish(num): total = 0 for i in str(num): total += int(i) if total % 2 == 0: return 'Evenish' else: return 'Oddish'
15c7409661d31ed26dacd6bdd58bd817a39637e2
siddharth-mallappa/1BM17CS103
/P2a_SearchList.py
290
3.859375
4
lst1=[] def check(num): if num in lst1: return True return False n=int(input("Enter the number of elements in the list")) for i in range(0,n): ele=int(input()) lst1.append(ele) key=int(input("Enter the search element")) res=check(key) print(res)
8ca928328c372128d344e31dc18e3d5a488d976a
rickandersonaia/ud036_StarterCode
/media.py
1,230
3.765625
4
import webbrowser class Movie(): """ This class defines a movie object and displays movies in a browser def __init__() takes 6 parameters self - movie_title - the title of the movie - what?! Blah, blah, blah, all the rest of this documentation is redundant because the code is self doc...
8d2cdb511765122b12d9b2550e31bbe30a5ab4b5
Se7enquick/Python-HW
/HW5/hw5.1.py
739
3.5625
4
'''def lower(a): #ex 1 return a.lower() def upper(b): return b.upper() list1 = ['LOWER'] list2 = ['upper'] result1 = list(map(lower, list1)) result2 = list(map(upper, list2)) print(result1, result2) def square(num): #ex 2 for x in range (2, num): if num % x == 0: return '.' retu...
a5ee9185ac4c0f21909aae7851ccf6b5b74dfd69
abhinai96/Python_conceptual_based_programs
/datastructures/Lists/sort using without inbult function.py
177
3.609375
4
lst=[5,2,3,4,1] for i in range(len(lst)): min_val=min(lst[i:]) min_index=lst.index(min_val) lst[i],lst[min_index]=lst[min_index],lst[i] print(lst)
c42d55490407bfcfd3a591030db63cd5be9b2b58
kmgowda/kmg-leetcode-python
/find-and-replace-in-string/find-and-replace-in-string.py
768
3.65625
4
// https://leetcode.com/problems/find-and-replace-in-string class Solution(object): def findReplaceString(self, S, indexes, sources, targets): """ :type S: str :type indexes: List[int] :type sources: List[str] :type targets: List[str] :rtype: str """ ...
7f73d3f4fb8e15af1c22ed96a4b2818edf625988
Christopher-Cannon/python-docs
/Example code/25 - class.py
484
4
4
# Define person class class person: def __init__(self, first, last): self.first, self.last = first, last def return_full_name(self): return "{} {}".format(self.first, self.last) # Get names from user first_name = str(input("What is your first name? -> ")) last_name = str(input("What is your la...
338538af142456f1907d3b0476148e4a38862707
stvnc/Python-Project
/Modul01/day03/umurBudiAndi.py
619
3.546875
4
''' Rasio umur Budi dan Andi adalah 4:10 Total umur keduanya adalah 49 Budi = 4/10 Andi Andi + 4/10 Andi = 49 ----- x10 10 Andi + 4 Andi = 490 14 Andi = 490 Andi = 35 Andi + Budi = 49 35 + Budi = 49 Budi = 14 2 tahun lagi? Andi + 2 = 37 Budi + 2 = 16 ''' rasioAndi...
de1dfae1c63ad672645df6b3a675c779e6ec8c79
luhao2013/Algorithms
/offer/32.从1到n整数中1出现的次数.py
1,538
3.765625
4
""" 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数? 为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现6次,但是对于后面问题他就没辙了。 ACMer希望你们帮帮他,并把问题更加普遍化,可以很快的求出任意非负整数区间中1出现的次数(从1 到 n 中1出现的次数)。 """ # -*- coding:utf-8 -*- class Solution: def NumberOf1Between1AndN_Solution(self, n): # write code here if n <= 0: retur...
3963cb955a88492c0be78848ca6f3e87765d2b9c
jettthecoder/Cool-Python-Projects
/Email Validator.py
349
4.5
4
print("Email Validator") email = input("Enter Your Email: ") valid_email_domains = ["gmail.com", "hotmail.com", "aol.com", "ymail.com"] name, domain = email.split("@") if domain in valid_email_domains: print(f"Hello {name} you have a valid domain name of {domain}") else: print(f"Hello {name} you have a less kno...
3a5558d313dfd7bd9e0a6968cff75c52a635c0dc
Dzhevizov/SoftUni-Python-Advanced-course
/File Handling - Exercise/03. File Manipulator/solution.py
1,092
3.59375
4
import os command_data = input() while not command_data == "End": command_data = command_data.split("-") command = command_data[0] if command == "Create": file_name = command_data[1] file = open(file_name, "w") file.close() elif command == "Add": file_name = command_...
7e182f73008c97658b5a2208dd45cc4ddb56b782
vlikevanilla/drawbot_examples
/floating_bezier_lines.py
4,386
3.859375
4
############################## # Draw Wiggles using Drawbot # ############################## """ Script by Roberto Arista, you can find the related tutorial here: https://medium.com/@roberto_arista/how-to-draw-a-wiggle-between-two-points-with-python-and-drawbot-788006c18fb0 You can find drawbot here: http://www.drawbo...
440c08735d36b094209f0dee6063421244ab2dd6
chelsea-banke/p2-25-coding-challenges-ds
/Exercise_50.py
416
4
4
# Create a function that will receive n as argument and return an array of n # random numbers from 1 to n. The numbers should be unique inside the array. import random def array_of_random_numbers(n): result = [] count = 0 while count < n: x = random.randint(1, n) if x not in result: ...
2061fc140a1a90e7f722eb58a26e6e952399b591
CaMeLCa5e/Notes-on-functions
/BuiltInFunc.py
4,815
3.8125
4
""" Standard Library Built-in functions """ abs() #Returns absolute value all() Return True if all elements in iterable are True def all(iterable) for element in interable: if not element: return False return True any() def any(iterable) for element in iterable: if element: return True return False ...
a180779aeacea89646d3c44591d073601a509d9a
arian81/playground
/python3_hard_way/ex4.py
502
3.8125
4
cars=100 space_in_a_car=4 drivers=30 passengers=90 cars_not_driven=cars-drivers cars_driven=drivers carpool_capacity=cars_driven*space_in_a_car average_passengers_per_car=passengers/cars_driven print("There are", cars, "cars available") print("There are only", drivers, "drivers available") print("There wi...
fbd52b6923aea96c0a980e36948bddd386f1899d
amusitelangdan/pythonTest
/20200103py/var_args.py
1,914
4.03125
4
# -*- coding: utf-8 -*- def power(x, n = 2): if not isinstance(n , int): raise TypeError('n must be int') if not isinstance(x, (int, float)): raise TypeError( 'x must be int or float ' ) return x ** n print (power(2)) # 可变参数, 计算值 def calc(numbers, n = 2): sum = 0 if not isinstance(nu...
362f1f1eaa46d846a0deda4b6e1c9aad80586873
hefrankeleyn/pythonWP
/homework_003/demo02.py
226
3.78125
4
usernames=[] if usernames: print('There have people.') else: print('This is empty.') num=3 if num<5: print('you are lower 5.') elif num<10: print('you are lower 10') elif num<15: print('you are lower 15')
fd5eeaeb16d6dd39522b0c20b65257c301f17585
kateamon/trees
/photo_process.py
3,578
3.59375
4
""" This Python script takes photos from a source directory: Flips those image left-right Saves the flipped images into a separate output directory, with _flip appended to the original filename before .jpg. Use glob2 third-party library to generate a list of all jpg image filenames. The string indexing [:-...
4bdccf30ae69caf40fb1ff617f3ad93a5beb28d6
XUSushi/Group-project_First-Version
/01_语音识别/语音识别_配置_陈思明/CHEN_only bing_test.py
1,123
3.5625
4
#!/usr/bin/env python3 import speech_recognition as sr # obtain path to "english.wav" in the same folder as this script # .wav的音频和本脚本应放在同一目录下 from os import path AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "test.wav") # AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "french.aiff") # AU...
d8f46ed26fba8b3b860572edc034cff1646b6cb3
Ahmed-Abdelhak/Problem-Solving
/Leetcode.30.contest/4. Move Zeros.py
1,427
3.953125
4
# Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. # Example: # Input: [0,1,0,3,12] # Output: [1,3,12,0,0] # Note: # You must do this in-place without making a copy of the array. # Minimize the total number of operations. class S...
4174c30174c5f16e8964a7daf080de38b5a898d8
bhajojo/PythonTraining
/Python Training Code/Loops/ForNEstedLoop.py
113
3.765625
4
for x in range(10,20): print "in outer For Loop" for y in range(20, 30): print y print x
12aa7c4e16851c9d3fe720ada29bf322040ca422
pubkraal/Advent
/2018/08/parsetree.py
1,627
3.546875
4
#!/usr/bin/env python3 import sys from functools import reduce class Node: def __init__(self, child_nodes=0, metadata=0): self.num_nodes = child_nodes self.num_metadata = metadata self.child_nodes = [] self.metadata = [] def add_node(self, node): self.child_nodes.add(n...
887cb4782c8e446160ccf1c570faa8596c8daf67
rglusic/prg105
/chapter 5/AutomobileCosts.py
1,665
4.375
4
""" Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, and maintenance. The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. ...
6d38b2f91ad2aeeb89d25e2d49988b3d102ade90
tonygomo/instilled-code-challenge
/test.py
1,904
3.59375
4
import unittest from main import InvalidInputError, parse_fragments, calculate_uvt class TestParseFragments(unittest.TestCase): def test_parse_strings(self): """It should parse correctly formatted strings.""" parsed = parse_fragments('0-1000', '1500-2000') self.assertEqual(parsed, ...
95ae6598375d7cebdb7bdf80fd42877c751dbb51
hoanghuyen98/fundamental-c4e19
/Session04/homeword/turtle_1.py
344
3.90625
4
from turtle import* import random colors = ['blue', 'orange', 'purple', 'white','yellow','red','pink','green'] shape("turtle") speed(-1) bgcolor("black") for i in range(24): for j in range(4): color(random.choice(colors)) forward(100) left(90) left(15) color(random.choice(colors)) ...
34b88de508d78da511a34bd26e032e2de052d420
samhithaaaa/Array-4
/maxsubarraysum.py
290
3.53125
4
#time complexity is o(n) #space complexity is o(1) class Solution: def maxSubArray(self,nums): local =nums[0] globall=nums[0] for i in range(1,len(nums)): local=max(local+nums[i],nums[i]) globall=max(globall,local) return globall
e2805f4cd166d256f6e05b1279e6af7ae781a7bc
MitalAshok/semantics2021_toy_languages
/semantics2021_toy_languages/L1.py
43,696
3.8125
4
"""An implementation of L1 Values: 𝑏 ∈ 𝔹 = { true, false } 𝑛 ∈ ℤ = { ..., -1, 0, 1, ... } 𝑙 ∈ 𝕃 = { l, l0, l1, l2, ... } Operations: op ∈ { +, ≥ } Grammar: (Quoted strings are literal, spaces (U+0020) do not matter between tokens, including integer digits, but they do matter in literal tokens) 𝑒 ::= 𝑒 ";"...
b61a4fee235835f980841354bbc07e1703b37f17
gasgustavo/pacman_search_agent
/pacman/search/hanoitower.py
4,242
3.90625
4
from copy import deepcopy import search import random # Module Classes class HanoiTowerSearchProblem(search.SearchProblem): """ Implementation of a SearchProblem for the Hanoi Tower problem Each state is represented by an instance of an Hanoi Tower. """ def __init__(self, hanoi_size, slot_s...
1f0ea88bb9cf7996cfed17129e2c4402e70dc5c8
ailunz/CIS2001-Winter2018
/FirstWeek/Hello.py
4,866
4.1875
4
import math # first_name = input("Enter your first name: ") # last_name = input("Enter your last name: ") # # print('Hello ' + first_name + ' ' + last_name + '!') # #anything after this gets ignored by python # # #using int will only work with integers, no decimal places # hourly_wage = int(input("How much do you earn...
6cb77ec39c118f9ae536315a1e35cbd156946369
liaochengyu/Data-Visualization
/code/Legends, Titles, and Labels with Matplotlib.py
416
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # url: https://pythonprogramming.net/matplotlib-intro-tutorial/ import matplotlib.pyplot as plt x=[1,2,3] y=[5,7,4] x2=[1,2,3] y2=[10,14,12] plt.plot(x,y,label='first line') plt.plot(x2,y2,label='second line') plt.legend() plt.xlabel('plot number') plt.ylabel('importan...
323a60561d12c2f1a84226fc31b2d518bad64466
Andrewlearning/Leetcoding
/leetcode/LinkedList/删除/1171. 从链表中删去总和值为零的连续节点(前缀和+两数之和).py
1,426
3.65625
4
""" Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return the head of the final linked list. You may return any such answer. Input: head = [1,2,-3,3,1] Output: [3,1] Note: The answer [1,2,1] would also be accepted....
5ff45c3cab06347efd5686f8a5a4d106f1e696fa
garymale/python_learn
/python_oneline.py
2,579
3.890625
4
# _*_ coding: utf-8 _*_ # 一行代码启动一个Web服务 # python -m SimpleHTTPServer 8080 # python3 -m http.server 8080 # # 一行代码实现变量值互换 # a, b = 1, 2; a, b = b, a; # # # # 一行代码解决FizzBuzz问题: 打印数字1到100, 3的倍数打印“Fizz”来替换这个数, 5的倍数打印“Buzz”, 既是3又是5的倍数的打印“FizzBuzz” # print(' '.join(["fizz"[x % 3 * 4:]+"buzz"[x % 5 * 4:] or str(x) for x i...
aa60f672ccd0187013e6c80883dae6672839e209
ivan-ver/Guess_the_number
/main.py
2,810
3.75
4
import numpy as np def guess_the_number(target_number: int, max_number: int) -> int: """Функция подбора загаданного числа Args: target_number (int): Загаданное число max_number (int): Верхняя граница диапазона "угадывания" числа Returns: int: Количество попыток """ min_nu...
e2cbab0232b1b4e53a1cf6f1c91c1bbeb25d6cdc
emark1/Assignment-1
/yourname.py
269
4.5
4
#String Interpolation first_name = input("What is your first name? ") last_name = input("What is your last name? ") print("Thanks! Your name is " + first_name + " " + last_name) full_name = (f"Or, interpolated, your name is {first_name} {last_name}") print(full_name)
0e8265bde58646f2f2eebc70229c891971314c55
MatthewMing11/TriMat
/gmath.py
897
3.625
4
import math from display import * def magnitude(vector): return math.sqrt(math.pow(vector[0],2)+math.pow(vector[1],2)+math.pow(vector[2],2)) #vector functions #normalize vector, should modify the parameter def normalize(vector): print(vector) length = magnitude(vector) if length==0: return vec...
d76297c540142657072e2abd2327529776fbb155
abr-98/FADACS_Parking_Prediction
/models/adda_models/callback.py
2,475
3.578125
4
class Callback(object): """ Abstract base class used to build new callbacks. """ def __init__(self): pass def set_params(self, params): self.params = params def set_trainer(self, model): self.trainer = model def on_epoch_begin(self, epoch, loss): ...
db56d84911eac1cae9be782fd2ebb047c625fce2
pranaychandekar/dsa
/src/sorting/bubble_sort.py
1,488
4.46875
4
import time class BubbleSort: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=Jdtq5uKz-w4 :Authors: pranaychandekar """ @staticmethod def bubble_sort(unsorted_list: list): """ This method s...
efb0aa150fb9eb13c889ca0dccefd5ba65c9bc44
raviolliii/PythonMinis
/sudoku/sudoku.py
1,220
3.546875
4
def printBoard(board): for row in board: for c in row: print(c, end = " ") print() def getZeroPositions(board): posList = [] for r in range(len(board)): for c in range(len(board[r])): if not board[r][c]: posList.append((r, c)) return posList def getSquarePossibilites(board, pos): startx = 6 if p...
efba9f428cc0e30431bd5694046c072513990cf6
nlucero-sg/AdventOfCode
/day13.py
3,999
3.578125
4
class Node: def __init__(self, x, y): self.x = x self.y = y class Edge: def __init__(self, node_1, node_2): self.nodes = frozenset([node_1, node_2]) class Map: def __init__(self): self.nodes = set() self.edges = set() def add_node(self, node): self.n...
06d3202cc7b26472e7f324264c8940510e0c555d
KruKuma/attendanceRecord
/moduleAttendanceRecords.py
10,717
4
4
# moduleAttendanceRecords.py # Author: Naphatsakorn Khotsombat # Description: The Module Attendance Records programme will allow a lecturer do the following tasks for any # module that they teach. import numpy as np # Added numpy to improve array def writeLine(): """ Funct...
f71a6d1b7f131057c5721642272ca7ce9c24f18b
yilinmiao/movie_trailer_website
/media.py
725
3.703125
4
import webbrowser class Movie(): """ This class provides a way to store movie related information Args: movie_title (str) box_art (str): Movies' Posters. trailer_link (str): Youtube Links. Attributes: movie_title (str) box_art (str): Movies' Posters. trail...
e2aa6452df5ca62c12a065ceedda14b00bad2f8a
jaewon-jun9/rpa
/excel/old/excelrange.py
1,109
3.8125
4
def excelNum(string): num=0 for i,j in enumerate(string): if ord(j)>57: num=num+(ord(j.upper())-64)*(26**(len(string)-i-1)) else: num=num+int(j)*10**(len(string)-i-1) return num def excelString(string): row=excelNum(list(filter(str.isalpha,string))) col=excelN...
db3c761c7af7b7428950d5850d0b05c984a036f8
JJong0416/Algorithm
/Programmers/2Level/SummerWinterCoding/an_intact_square_62048/choboman.py
381
3.53125
4
# w : 가로, h : 세로 def solution(w, h): total_paper = w * h temp_paper = w + h answer = 0 if w > h: pass else: w, h = h, w # w가 최대공약수로 변환되어 나옴 # 유클리드 호제법 while h > 0: w, h = h, w % h answer = total_paper - temp_paper + w return answer print(solu...
cecb39bc407023869dd40c694c6657ebedc1ae56
mgcarbonell/30-Days-of-Python
/15_comprehension.py
4,655
4.8125
5
# there are many types of comprehrension in python, but most commonly used is list comprehension. # List comprehension is used to create a new list from some other iterable. It might be another list or even a zip object. names = ["mary", "Richard", "Noah", "KATE"] # Take a look at the names list and notice that they...
adec65f0c1d2daffbf7f1e12dfdd1c32f02d6b30
bibinjose/hackerrank
/week challenge/revisedRussianRoulette.py
587
3.609375
4
#https://www.hackerrank.com/contests/w36/challenges/revised-russian-roulette #!/bin/python3 import sys def revisedRussianRoulette(doors): min=0 counter=0 max=(doors.count(1)) for door in doors: if door==1: counter+=1 if counter==2: counter=0 ...
4fcb1e9201edb4458edfbcfb1125f692d3387a7b
Veraph/Python-Note
/tutorial/guest.py
200
3.9375
4
# create a file and let user write filename = 'guest.txt' name = input("please give me your name: \n") with open(filename, 'a') as file_object: file_object.write(name) file_object.write('\n')
63971f4a58abca6542113cafd1741d8c7f65f6b9
eastdog/4fun
/mooc/Algorithmic thinking/module1/application1.py
3,054
3.53125
4
# -*- coding: utf-8 -*- __author__ = 'victor' """ for application number 1 """ import random import matplotlib.pyplot as plt from project1 import in_degree_distribution from project1 import make_complete_graph from math import log class DPATrial: """ Simple class to encapsulate optimized trials for DPA algori...
2e9cdf371db5840a21196a7fb44ffe424f5c6827
Holi0317/duty-notify
/utils/cache.py
903
3.609375
4
import os CACHE_DIR = 'cache' def make_cache(name, content): """ Create cache with given content. :param str name -- Name, or key of the cache. :param str content -- Content of the cache :return bool -- If True, the content is changed with previously cached content. I.E. should process the u...
d7acd1d3336f73d4022a3d2f7a3006888c1e13d0
kyokagong/leetcode
/surroundedRegion.py
1,508
3.875
4
#-*-coding:utf-8-*-# # 利用bfs 对搜索到的o点进行 广度搜索,搜索这个点的下和右的o点 # 虽然是 accept了,但是本地运行会报 'str' object does not support item assignment 错误 class Solution(object): def solve(self, board): """ :type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead. """ ...
357e54c2ff5b3ea34c59687e699a22818e0d584e
EdgarRamirezFuentes/Python
/Fundamentos/21.herencia.py
1,282
4.0625
4
class Person: def __init__(self, name, age): self.__name = name self.__age = age ## Getters def getName(self): return self.__name def getAge(self): return self.__age ## Setters def setName(self, name): self.__name = name def set...
7abd554f57038331f50493564ad9f38177345a73
kimsyversen/Ruter-workflow-for-Alfred
/src/Route.py
1,131
3.5625
4
# encoding: utf-8 class Route(object): def __init__(self, from_place_id, to_place_id, from_place_name, to_place_name, arrival_time, departure_time, travel_time, line, number_of_changes_required, current_time, from_place_district,to_place_district, deviations): self.from_place_id = from_place_i...
28fb330fd0cdbf2060b8b9fe8812bcf20209edce
paulosalvatore/ProjetoPython
/reverse.py
66
3.671875
4
lista = [1, 2, 3, 4, 5] print(lista) lista.reverse() print(lista)
b5dfeba63547bfb16dc8b4d5eba9f26087b8bdf2
tjr226/Algorithms
/knapsack/knapsack.py
2,760
4.0625
4
#!/usr/bin/python import sys from collections import namedtuple Item = namedtuple('Item', ['index', 'size', 'value']) def knapsack_solver(items, capacity): knapsack_matrix = [[0 for column in range(capacity + 1)] for row in range(len(items) + 1)] ''' This function uses the format (rows, columns) ''' ro...
ebf210a9748154f00c213e00e0cfbb17adc9efbd
agrim123/algo-ds
/Algorithms/Pattern Searching/KMP (Knuth Morris Pratt) Pattern Searching/kmp.py
1,383
3.5625
4
""" KMP (Knuth Morris Pratt) Pattern Searching - Worst case complexity is O(n) """ def KMPSearch(pattern, text): M = len(pattern) N = len(text) # create lps[] that will hold the longest prefix suffix # values for pattern lps = [0]*M j = 0 # index for pattern[] # Preprocess the patte...
7ec493228168143a0f7b00df0f09424d7a51db8e
vashist99/ds-and-algo
/Search - Linear/Python3/linearSearch.py
531
3.890625
4
# Author: Vishal Gaur # Created: 03-01-2021 22:21:11 # function to search an element using linear seaching def linearSearch(a, x): for i in range(len(a)): if a[i] == x: return i return -1 # Driver Code to test above function arr = [45, 76, 12, 19, 43, 48, 56, 67] x = 18 res = line...
87a2a552723f7ccd1171539c8e2615ae8723ac1f
A7madNasser/DataCamp
/Statistical Thinking in Python -Part 1/03 - Thinking probabilistically-- Discrete variables.py
13,728
4.59375
5
''' 1. Generating random numbers using the np.random module We will be hammering the np.random module for the rest of this course and its sequel. Actually, you will probably call functions from this module more than any other while wearing your hacker statistician hat. Let's start by taking its simplest function, np.ra...
9d242e04fe2d2ef1617701b751a2760bb6d87f45
nivedha1998/nivedha
/H124.py
164
3.625
4
I=int(input()) while(I>0): j=0 while(j<I): if (j==(I-1)): print("1") else: print("1",end=" ") j+=1 I-=1
be825daaab69cf112ecc4486321f21363fc147c4
dezson/leetcoding-july
/word_search.py
855
3.5625
4
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: def dfs(board,x,y,word,i): if x < 0 or x >= len(board) or y < 0 or y >= len(board[0]) or i >= len(word): return False if board[x][y] == word[i]: temp = board[x][y] ...
7a191b28da2dde5b7b854789b6ff4a298e7f67de
Aasthaengg/IBMdataset
/Python_codes/p02273/s840823588.py
947
3.65625
4
import math def make_3_points(p1, p2): """p1, p2 を分割する3点を作成する。 p1, p2 を両端の点とする線分を3等分する2点 s, t を 頂点とする正三角形の頂点 (s, u, t) のタプルを返す。 """ s = ((2 * p1[0] + p2[0]) / 3, (2 * p1[1] + p2[1]) / 3) t = ((p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3) theta = math.radians(60) x = t[0] - s[...
92a1483e1cb03480feac8829374b13a9ae5a92bd
kapil87/LeetCode
/buySellStocksPeakValley.py
380
3.578125
4
def maxProit(prices): i = 0 maxprofit = 0 while i < (len(prices) -1): while (i < len(prices)-1 and prices[i] >= prices[i+1]): i +=1 valley = prices[i] while (i < len(prices)-1 and prices[i] <= prices[i+1]): i +=1 peak = prices[i] #print peak, v...
3be62500739d20bf9fbd49b5fbeffe26628dbbad
windard/ModernCryptography
/cryptopals/quiz5.py
641
3.609375
4
# coding=utf-8 def repeatxor(strings,key): result = "" for i,x in enumerate(strings): result += hex(ord(x) ^ ord(key[(i % len(key))]))[2:] if len(hex(ord(x) ^ ord(key[(i % len(key))]))[2:]) == 2 else "0"+hex(ord(x) ^ ord(key[(i % len(key))]))[2:] return result def decode_xorvigenere(ciphertext,key): return "".j...
534eaef921f513d64d04c11b75204f0bb861832c
jhassinger/Python_Hard_Way
/ex16.py
1,002
4.3125
4
# import argv from sys import argv # assign arguments to variables script and filename script, filename = argv # printing instructions to user print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." # wait for user to hit enter or escape r...
86bba1089ce109d812667c92ce692c3fc90d9441
p23he/oiler
/ProjectEuler/Problem 35.py
737
3.6875
4
#The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. #There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. #How many circular primes are there below one million? import math def is_prime(n): upp = math...