blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
6eff70e2d978b89ddd53e28c4e16a70fce9b43d7
Lobo2008/LeetCode
/113_Path_Sum_II.py
3,895
3.890625
4
""" Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 Return: [ [5,4,11,2], [5,8,4,5] ...
08279e371c560a93d448f36f57f203cc0b194688
Lobo2008/LeetCode
/212_Word_Search_II.py
3,190
3.90625
4
""" Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. Example: Input: ...
a0bfc34b5087331432998cb698a7dec6cc9a843a
Lobo2008/LeetCode
/16_3Sum_Closest.py
10,353
3.90625
4
""" Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closest to the tar...
5e8afcd27ad33b1f3ff0e83fd6d0227cde78f8ce
Lobo2008/LeetCode
/172_Factorial_Trailing_Zeroes.py
2,130
3.640625
4
""" Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120, one trailing zero. 大概是,阶乘结果的0的数量? 5 = 5x4x3x2x1 = 120 10 = 10x9x8x7x6x5x4x3x2x1=3628800 方法一: 如果我们要判断出0的个数,如果我们直接求N!那么数据会很大,...
3ac89a123fd5bd63ef80f404d8a3a13641faf047
Lobo2008/LeetCode
/221_Maximal_Square.py
1,840
3.625
4
""" Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4 """ class Solution: def maximalSquare(self, matrix): """ :type matrix: List[List[str]] :rtype: int ...
4037956b9303d8030bf8e6dc550d3ea5dee51e7e
sureindia-in/contrastiveExplanation
/contrastiveRegressor/generate_Gompertz_sales.py
2,749
3.765625
4
''' Generate sales for toy example (Experiment #2) carlos.aguilar.palacios@gmail.com ''' import numpy as np import seaborn as sns import matplotlib.pyplot as plt import scipy from sklearn.preprocessing import MinMaxScaler import pandas as pd def Gompertz_distribution(t=np.linspace(0, 5, 50), b_scale=1, eta_sh...
4b3fe35e32f2184441be0ef7d9ced13a25f0e9b6
TudorCovaci/FP
/Student management/Repos/GradeRepo.py
1,574
3.828125
4
class GradeRepo: """ Class for grade repositories """ def __init__(self): """ Constructor """ self._data = [] def __len__(self): """ Returns the length of the repository """ return len(self._data) def __str__(self): """ ...
4657d0953674309d7f531e7a30c978894864ca4e
ezefranca/tob-stt
/rasa-bot/utils.py
935
3.546875
4
def write_story(intent, utter, file, iterations=1): result_string = '' for i in range(iterations): name = input("What concept: ").strip('\n') utter_name = name.replace(' ', '_') result_string += f'\n## {intent} {name}\n' + \ f'* {intent}\n' + \ ...
9e54b2d6778065c6077e094dae2720ee4d9f0063
jrpresta/FantasyTrades
/entites.py
896
3.78125
4
class User: def __init__(self, user, objs): self.user = user self.players = objs self.preferences = [] def add_obj(self, new_obj): self.players += new_obj def add_preferences(self, preferences): """Trying an ordered list of preferences""" self.preferences =...
3569b04b976c954b03aaa668ed19f2f0dcfa32be
bkp2/Lesson3
/07_wall.py
532
3.703125
4
# -*- coding: utf-8 -*- # (цикл for) import simple_draw as sd # Нарисовать стену из кирпичей. Размер кирпича - 100х50 # Использовать вложенные циклы for # TODO здесь ваш код for x in range(1200, 0, -100): for y in range(0, 1200, 50): x -= 50 point_left = sd.get_point(x,y) point_right = sd...
252a87d8a7dbe9766c4a0267abc893cd6dbbd480
moon729/PythonAlgorithm
/5. 재귀 알고리즘/gcd.py
268
4.03125
4
#euclidean algorithm def gcd(x:int, y:int) -> int: if x < y: x, y = y, x if y == 0: return x else: return gcd(y, x%y) if __name__ == '__main__': x = int(input('x : ')) y = int(input('y : ')) print(f'gcd(x,y) = {gcd(x,y)}')
12d523ff33e120c1acc810313d9077697c40390d
moon729/PythonAlgorithm
/6.정렬 알고리즘/quick_sort1.py
900
3.796875
4
#퀵 정렬 알고리즘 구현 from typing import MutableSequence def qsort(a: MutableSequence, left: int, right: int) -> None: pl = left #왼쪽 커서 pr = right #오른쪽 커서 x = a[(left + right) // 2] #피벗(가운데 원소) while pl <= pr: while a[pl] < x: pl += 1 while a[pr] > x : pr -= 1 if pl <= pr: ...
7daa3469d5686be5fde9a5e512c5463c13d984cd
hexmaster111/ll
/hexto10.py
571
3.90625
4
num = raw_input("Enter your number: ") option = raw_input(" hex to binary(1)\n binary to hex(2)\n hex to decimal(3)\n binary to decimal(4)\n decimal to binary(5)\n decimal to hex(6)\n") if option == str("1"): print(bin(int(num, 16))) elif option == str("2"): print(hex(int(num, 2))) elif option == str("3"): prin...
7d6aa86ccbe11b0c93c7aa678c30390735d07983
IUL1AN27/Instructiunea-String
/Problema 5 string.py
163
3.5625
4
cnp=str(input('Introduceti CNP-ul persoanei: ')) if cnp.isnumeric() and len(cnp) == 13: print('CNP-ul este corect') else: print('CNP-ul este gresit')
175dde5385d04b42e6d2621a174e98b011fb7762
ImaniLargin1996/Hangman
/Main
490
3.78125
4
#!python import random ############################################### #PART 4 #show previously guessed letters, part3 = ['ocean', 'jump', 'computer', 'chair', 'rope'] selected_word = random.choice(part3) letters = list(selected_word) #print(letters) characters = len(letters) #print(characters) def printblanks(num):...
80dc0a675b980a943ed09d24bbe69361fd920b5c
sayantanHack/Product-from-given-list
/list of num 2.py
335
3.8125
4
listofnum = [2,4,1,5,6,40,-1] num = int(input("Which number you want as a product : ")) i=None j = None for i in range(len(listofnum)): if num%listofnum[i]==0: if num/listofnum[i] in listofnum: print('The numbers multiplied are : ',listofnum[i],'and',int(num/listofnum[i...
343973f2294a73e3ab24a9f9cf55ed005409303d
dheerajthodupunoori/problem-solving
/directed-acyclic-graph-clone.py
2,357
3.78125
4
#directed graph from collections import deque class GraphNode: def __init__(self,value): self.val = value self.adjacent = [] class GraphOperations: def __init__(self): print("Graph operations classe is initialized") self.graph = set() def addEdge(self,source,destinatio...
8e4d614f8aa1fd2dca9865c0ce93d31e8c6bf38d
dheerajthodupunoori/problem-solving
/indeed-karat/single_rectangle.py
1,511
3.875
4
# https://leetcode.com/discuss/interview-question/1062462/Indeed-Karat-Questions # https://leetcode.com/discuss/interview-question/1063081/Indeed-or-Karat-(Video-Screen)-or-Find-Rectangles # Given a 2D array of 0s and 1s, return the position of the single rectangle made up of 1s. # # # Example input grid1 = [[0, 0, 0,...
bf37a1b14897908681734a83eaf4ad44876586c2
dheerajthodupunoori/problem-solving
/grid-word-search.py
1,462
3.75
4
class WordSearch: def __init__(self,grid): self.grid=grid self.directions = [[0,-1],[-1,0],[0,1],[1,0]] self.R = len(grid) self.C = len(grid[0]) print(self.grid) def searchWord(self,word,row,col,position): # print(word,position,word[position],row,col) ...
fa18a5a720dfda793bf43408392742fd3ce420db
dheerajthodupunoori/problem-solving
/indeed-karat/find_word_from_string.py
2,069
4.0625
4
# You are running a classroom and suspect that some of your students are passing around the answers to multiple # choice questions disguised as random strings. # # Your task is to write a function that, given a list of words and a string, finds and returns the word in the list # that is scrambled up inside the string, ...
5cd5a6757593631413b06660993ab63c23614d80
BonoboJan/M03-Ofim-tica
/multiplode.py
434
4
4
#coding:utf8 #Jandry Joel #23/02/18 num1=input("Introduzca el primer valor: ") num2=input("Introduzca el segundo valor: ") if (num1==0) or (num2==0) : print "Introduzca valores diferentes a 0." else: if num1>num2 : mayor=num1 menor=num2 else: mayor=num2 menor=num1 if ma...
4139ad8790694f9b950b29fccddd249c06ddcee7
BonoboJan/M03-Ofim-tica
/Bucles/ejercicio-bucle-informes.py
266
3.671875
4
#coding:utf8 # Inicializaciones salir = "N" anyo=2001 while ( salir=="N" ): # Hago cosas print "Informes año", anyo # Incremento anyo= anyo +1 # Activo indicador de salida si toca if ( anyo>2016 ): # Condición de salida salir = "S"
6ef2ad7e067cc031fdddf6134e86f5263f369f87
PehhViny/aulaslpoo2sem21
/aula2.py
159
3.796875
4
def main (): nota1 = int(2) nota2 = int(8) soma = nota1 + nota2 media = soma / 2 if media >= 5: print ("passou") else: print ("Bombou") main()
eff175292e48ca133ae5ca276a679821ebae0712
soumilshah1995/Data-Structure-and-Algorithm-and-Meta-class
/DataStructure/Deque/DEQChallenge.py
1,505
4.15625
4
""" DEQUE Abstract Data Type DEQUE = Double ended Queue High level its combination of stack and queue you can insert item from front and back You can remove items from front and back we can use a list for this example. we will use methods >----- addfront >----- add rear >----- remove front >----- remove rear we...
5d37cc5141b7f47ec6991ffa4800055fef50eab8
soumilshah1995/Data-Structure-and-Algorithm-and-Meta-class
/DataStructure/Queue/Queue.py
786
4.125
4
class Queue(object): def __init__(self): self.item = [] def enqueue(self, item): self.item.insert(0, item) def dequeue(self): if self.item: self.item.pop() else: return None def peek(self): if self.item: return self.item[-1...
2bb127606086c19cfbc3309b0adb8a43fdd4955d
mcfee-618/FluentAlgorithm
/01linkedlist/src/reverse.py
347
3.953125
4
# 反转链表 class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseList(self, head: ListNode) -> ListNode: p1 = head p2 = None while p1 != None: p3 = p1.next p1.next = p2 p2 = p1 p1 = p3 ...
e69ecf21f161fdbfc6ffb31b1519bc03b7c76d4c
KevinBXu/GrapheneImages
/helper.py
4,833
3.5
4
import gmsh import matplotlib.pyplot as plt import math #find the distance between two (x, y) coordinates using the max metric def distance(p1, p2): x = abs(p1[0]-p2[0]) y = abs(p1[1]-p2[1]) return max(x,y) #find the distance between two (x, y) coordinates using the euclidean metric def euclide...
8acb397fd77fe9ce1478a5ba99452d2b60072cb4
Pygame-Tetris-2020/tetris-2020
/Buttons.py
3,562
3.75
4
# -*- coding: cp1252 -*- # /usr/bin/env python # Simon H. Larsen # Buttons # Project started: d. 26. august 2012 import pygame from pygame.locals import * import sett from music import * pygame.init() class Button: def create_button(self, surface, color, x, y, length, height, width, ...
248b3fd83910de6de72e29571472a7bf20e6bbdb
hyunillkang/Path-Finding-Algorithms-Maze-Solving
/create_maze.py
3,912
3.78125
4
import os import msvcrt class Maze: def __init__(self, rows, cols): self.rows = rows self.cols = cols self.contents = [] class Cursor: def __init__(self, row, col): self.row = row self.col = col def createMazeFrame(rows, cols): maze = Maze(rows, cols) for i in ...
4d3404edff3a1c83505fcff636da20ba887d0c5d
AncientAbysswalker/Projekt-Euler
/Euler Projekt 004 - Largest Palindrome Product/EulerProjekt_4.py
907
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 8 @author: Ancient Abysswalker """ from math import floor def isPalindrome(number): number=str(number) for digit in range(0,floor(len(number)/2)): if number[digit] != number[-1-digit]: return False return True #Probl...
470f6de5fff526bc52c8d3290a2c0ae2e4349f09
AncientAbysswalker/Projekt-Euler
/Euler Projekt 020 - Factorial digit sum/EulerProjekt_20.py
165
3.6875
4
# -*- coding: utf-8 -*- """ Created on Jul 26 @author: Abysswalker """ from math import factorial print(sum(int(digit) for digit in str(factorial(100))))
103e2d92ddd591cfbdac2b546f36bf13c2c8abbb
AncientAbysswalker/Projekt-Euler
/Euler Projekt 041 - Pandigital prime/EulerProjekt_41.py
997
3.984375
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 24 @author: Abysswalker """ from os import path #Import Primes from file def primeFile(): filepath = path.join(path.dirname(__file__),"primes.txt") primes=set() print("Checking existance of generated prime file") if not path.exists(filepath): rai...
193a157b59d30a240f7f2a937b06627bc5394398
svaishn/ImageManipulationAlgorithms
/SingleColor-B-BW.py
682
3.515625
4
# Author Bhargav K # Email bhargav.gamit@gmail.com # Single Color Channel using blue # gray = blue from PIL import Image i = Image.open("input.png") #pixel data is stored in pixels in form of two dimensional array pixels = i.load() width, height = i.size j=Image.new(i.mode,i.size) #cpixel[0] contains red value cp...
67c68086d85a19377908e5f5d32b27bb3087f0bd
svaishn/ImageManipulationAlgorithms
/ColourInversionAlgo.py
874
3.890625
4
# Author Sri Vennela Vaishnapu # Email vennelavaishnapu2003@gmail.com # Inversion algorithm # colour = GetPixelColour(x, y) # invertedRed = 255 - Red(colour) # invertedGreen = 255 - Green(colour) # invertedBlue = 255 - Blue(colour) # PutPixelColour(x, y) = RGB(invertedRed, invertedGreen,invertedBlue) from PIL impor...
6e3361a86bea6a371d31e1f2fba02beeda2ed26e
rylan-michael/virtual-memory-problems
/main.py
8,089
3.78125
4
import random import pandas as pd import numpy as np import matplotlib.pyplot as plt from collections import deque import time def rand_page_ref_str(page_numbers, reference_length): """Generate a random reference string. A reference string is used for evaluating performance of page replacement ...
6b1fa7ff2a58e8234123622bda5f0fde81e3af8b
kiddliao/lh_CODE
/lh_algorithm/lh_algorithm_binary_tree.py
3,271
3.90625
4
class TreeNode: def __init__(self,x): self.val=x self.left=None self.right=None #非递归的前序遍历,进栈顺序是前序遍历,出栈顺序中序遍历 #https://blog.csdn.net/monster_ii/article/details/82115772 class newTree: def __init__(self,x): self.head=self.new(None,x,0) self.pre,self.mid,self.post=...
46c7075a38738a5ead62a7e751700bcf98762d6c
ArthMx/AdamANN
/Old/DeepNN.py
10,384
3.515625
4
''' Created 02/05/2018 ANN with N layers and Softmax or sigmoid as the last layer. Architecture of the NN : (Tanh or ReLU) x N-1 times + (Softmax or sigmoid) for output ''' import numpy as np import matplotlib.pyplot as plt import time def ReLU(Z): ''' Compute the ReLU of the matrix Z ''' relu = np....
595ed88dcc47f971db5e50291b398318bb41d94c
Oldby141/learning
/function/isnot.py
707
3.9375
4
x = [] y = None print(not x is None)####################true print(not y is None)#F print(not x)#################true print(not y)#True print(x is None)#flase print(y is None)#true print(y == None)#true x = 1 y = [0] print(not x)#f print(not y)#f print(x is None)#f print(y is None)#f print(y == None)#f x = 0 y = [1] pr...
45445aa84587ad80f81ce639b1a9e41fa79921f0
Oldby141/learning
/day3/装饰器.py
867
3.671875
4
import time def timer(func): def deco(): start_time=time.time() func() end_time = time.time() print("run time%s"%(end_time-start_time)) return deco @timer def test1(): time.sleep(2) print("in the test1") def test2(): time.sleep(2) print("in the test2") #test1=ti...
c9e1cdd80a02af2a839e1ca7a9df489a7c99faa6
Oldby141/learning
/day2/文件修改.py
533
3.6875
4
f = open("yesterday",'r',encoding="UTF-8") #f_new = open("yesterday2","w",encoding="UTF-8") for line in f: if "肆意的快乐" in line: print('s') line=line.replace("肆意的快乐","s")#########888888888888****** print(line) f.close() #f_new.close() line="肆意的快乐" print(line.replace("肆意的快乐","s")) s=line.rep...
c4765e62289e7318c56271e9f27942544b572842
Oldby141/learning
/day6/继承.py
1,397
4.375
4
#!_*_coding:utf-8_*_ # class People:#经典类 class People(object):#新式类写法 Object 是基类 def __init__(self,name,age): self.name = name self.age = age self.friends = [] print("Run in People") def eat(self): print("%s is eating...."%self.name) def talk(self): print("...
1ccf0eaf6041212bfe68e638106f25a7ad542014
Oldby141/learning
/day7/__new__.py
497
3.78125
4
#!_*_coding:utf-8_*_ # class Foo(object): # def __init__(self, name): # self.name = name # # # f = Foo("alex") # print(type(f)) # print(type(Foo)) def func(self): print('hello %s'% self.name) def __init__(self,name,age): self.name = name self.age = age Foo = type('Foo',(object,),{'talk':func,...
5f50045fadf52e7e1cd0055939d51eda7bbdfea0
smahmud5949/age_calc
/age calculator demo.py
412
3.859375
4
import datetime #import arrow #utc = arrow.utcnow() date_in = int(input("Input date : ")) month_in = int(input("Input Month : ")) year_in = int(input("Input year : ")) year = datetime.datetime.now().year #month = datetime.datetime.now().month #date = datetime.datetime.now().date() print ("You're "+ str(y...
a93ea52f80a206de46fe65cfdabec30969e9af62
zooee/PyDevtest1
/PythonFirst/Gui.py
611
3.53125
4
#coding=utf-8 ''' Created on 2016年4月27日 @author: Administrator ''' #from PIL import Image from tkinter import * class Application(Frame): def __init__(self,master=None): Frame.__init__(self, master) self.pack() self.createWidgets() def createWidgets(self): ...
321ca3270dd210a1765db6af8c49ae749a7ed928
Bobslegend61/python_sandbox
/string.py
625
3.828125
4
# single line strig name = 'Alabi' print(name) # multiline string sentence = '''This is a sentense and the sentences continues from here. ''' print(sentence) # Strings are arrays a = 'Hello, World' print(a[0]) # slice syntax print(a[2:5]) print(a[-5:-2]) # length print(len(a)) # STRING METHODS # strip - acts l...
67646a311652dff6d31d4f26b778218b52162f5e
sophia1215/pyCollection
/json-douban.py
2,000
3.578125
4
import json import requests class Douban(object): def __init__(self): self.start_url = "https://movie.douban.com/j/search_subjects?type=movie&tag=%E7%83%AD%E9%97%A8&sort=recommend&page_limit=20&page_start={}" # 存放所有電影的 url self.url = [] self.headers = { ...
2ab7daef2997c1ebbc28e1c89a469c0176a18844
seannich/RatVenture_ETI_Assignment
/ratventure/ratventure_functions.py
11,308
3.875
4
import os import sys import pickle import random class Player: """ Player class for when the player first starts the game """ def __init__(self): self.name = 'The Hero' self.damage = '2-4' self.minDamage = 2 self.maxDamage = 4 self.defence = 1 self.hp = 20...
42595d662e824cbe692fbc043979c3949da91c70
romenskiy2012/py
/Essentials/vector.py
192
3.71875
4
def combine(array,text): string = "" while len(list(array)) > 0: string += str(array.pop(0)) if len(list(array)) > 0: string += text return string
f20b7b521016022b89d77f5beb10bd18836b256b
talk2mat2/snbank
/bank.py
4,790
3.859375
4
#customer text file file= "./customer.txt" #staff details read from json object file system using json(dictionary) file system of python def readstaff(files): import json with open(files,'r') as staffdetails: json_data = json.load(staffdetails) return json_data staff= readstaff('./staff.txt...
d83917e8b2f6639193c940d0d166b8641fa06f9e
1ggera/programitas_python
/ejercicios_python/lists_and_dicts.py
1,040
3.921875
4
#Una lista puede guardar diccionarios y los diccionarios pueden guardar listas. #creamos nuestra función principal def run(): my_list = [1, "Hello", True, 4.5] my_dict = {"firstname": "Gerard", "lastname": "García"} super_list = [ {"firstname": "Gerard", "lastname": "García"}, {"firstname": "Alberto", "...
7ec4cc3cff68130c5eb9ded95204bf00a1d720d3
travisoneill/project-euler
/python/.521.py
3,548
3.53125
4
from generators import primes2 from primesandfactors import prime_factors def run(limit): start = [1] p = 2 for prime in primes2(11): if prime == 2: continue def steps(n): a, b, c = 1, 2, 4 step = 3 while step < n: a, b, c = b, c, a+b+c step += 1 return c def step...
b4e897435f26761ca83642abe3750738145310a2
travisoneill/project-euler
/python/080.py
4,308
3.53125
4
from benchmark import benchmark def square_root(n, precision): if n < 0: raise 'No sqrt for negative numbers' if n == 0: return 0 log_10 = -1 m = n while n > 0: log_10 += 1 n //= 10 exponent = 2 * (precision - log_10 // 2 ) - 2 return int_sqrt(m * 10**exponent) def int_sqrt...
25ce186e86fc56201f52b12615caa13f98044d99
travisoneill/project-euler
/python/007.py
327
3.953125
4
from math import sqrt def is_prime(n): if n < 2: return False for i in range(2, int(sqrt(n)) + 1): if n % i == 0: return False return True def nth_prime(n): count = 2 i = 3 while count < n: i+=2 if is_prime(i): count += 1 print(i) nth_prime(...
4d5d9b686f9635b85c2bea281be1e197e054b5c2
travisoneill/project-euler
/python/020.py
127
3.734375
4
from math import factorial n = factorial(100) digit_sum = 0 while n > 0: digit_sum += n % 10 n //= 10 print(digit_sum)
7db9acc6ee427d7d4fe61d6d53416e46ebad2a37
travisoneill/project-euler
/python/037.py
712
3.6875
4
from primesandfactors import is_prime def run(): primes = {} def primetest(n): if n in primes: return primes[n] else: primes[n] = is_prime(n) return primes[n] def is_truncatable_prime(n): power = 1 while n % 10**power != n: if...
56ed71edf7bbf02583707e2d4139d3a90c07dfe1
Thamarai-Selvam/Color-it
/app.py
1,683
4
4
import random import tkinter colors = ['Red', 'Green', 'Blue', 'Yellow', 'Black', 'White', 'Pink', 'Brown'] points = 0 # points gained time = 30 # time left to complete def start(e): # start game method if time == 30: timer() nextColor() def nextColor(): # array traverse to find next color...
9118bb6ac1537fa2ea231501bb177f97748de482
Yang-J-LIN/KC3F
/run_picar.py
6,150
3.625
4
# This is the main code to run the pi car. import time import numpy as np from cv2 import cv2 as cv import driver import image_processing import camera_capturer import utils DEBUG = False PERIOD = 0 # the period of image caption, processing and sending signal OFFSET = 371 def cruise_control(bias, k_p=1, k_i=0...
8a9b6e0a0e3c93af99710309d448b95617a2f8cc
zombaki/PythonPrac
/LeetSubdomainVisit.py
1,084
3.515625
4
'''class Solution(object): def subdomainVisits(self, cpdomains): """ :type cpdomains: List[str] :rtype: List[str] """ d={} for i in cpdomains: #print i li=i.split() #print li for b in li[1].split('.'): #print b d[b]=d.get(b,0)+int...
d568dfb4b19222718d1505aa36fd16b7e80eb551
zombaki/PythonPrac
/robotPaths.py
348
3.9375
4
def numberOfPaths(m, n): # If either given row number is first # or given column number is first print m,n if(m == 1 or n == 1): return 1 #print m,n # If diagonal movements are allowed # then the last addition # is required. return numberOfPaths(m-1, n) + numberOfPaths(m, n-1) m=3 n...
29d6f7af5cf7bd4970a0db8064981c0309a5a18a
lambdacubed/genetic-algorithm
/plot_functions.py
1,780
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This module contains functions used for plotting. """ import numpy as np # general useful python library import matplotlib.pyplot as plt # plotting library # TODO make this a part of people and get rid of plot_functions def plot_performance(iteration_number, figur...
e577cde6b041510ab0bc4db9b398af65afdb0894
FermiQ/molecular_features
/molreps/methods/props_py.py
3,108
4.0625
4
"""Functions using only python. Note: All functions are supposed to work out of the box without any dependencies, i.e. do not depend on each other. """ def element_list_to_value(elem_list, replace_dict): """ Translate list of atoms as string to a list of values according to a dictionary. T...
c1be175fdd677df021128b43da0c2a3fc71c6afb
zakari-gif/Emoticon
/EmoticonsV5_EAD 2/Q6/Q6Emoticon.py
1,168
3.59375
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 16 19:47:50 2017 @author: lfoul """ import pygame import math class Emoticon: # Constructor def __init__(self, sensor) : self.sensor = sensor # Sets the emoticon parameters def setEmoticonParameters(self, size) : ...
34ca6f24ac93cbae0d56e5e3664071dee70739a2
zakari-gif/Emoticon
/EmoticonsV5_EAD 2/Q1/Q5Button.py
1,298
3.78125
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 16 19:47:50 2017 @author: lfoul """ import pygame from Q3GeneralConfiguration import GeneralConfiguration class Button: # Constructor def __init__(self, sensor) : self.sensor = sensor # Gets the sensor positi...
4f3dc041a0fd1b96c2dd21c4ba2e6afecc34e7fd
Fuerfenf/Basic_things_of_the_SQL
/DB_SQLite/Python_moduls/sqlite3/sqlite_insert_table_db.py
834
3.515625
4
import sqlite3 try: db_connect = sqlite3.connect('C:\sqlite\database\Egor_test.db') sqlite_create_table_query = '''CREATE TABLE SqliteDb_developers ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, email text NOT NULL U...
f1b55b29f5091414848893f10f636c509ce57ce7
WU731642061/LeetCode-Exercise
/python/code_189.py
1,986
4.375
4
#!/usr/bin/env python3 """ link: https://leetcode-cn.com/problems/rotate-array/ 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。 """ def rotate1(nums, k): """ 第一种思路是利用数组拼接,向右移动N位其实就是将[-n:]位数组拼接到[:-n]数组的前面 需要注意的是k可能会大于数组本身的长度,那么每移动len(nums)位,数组与原数组重合, 所以只需要计算 k % len(nums)后需要移动的结果 """ length = len(nums) ...
56b78459da8cd4ca3b2bc16de38822105f02c82c
WU731642061/LeetCode-Exercise
/python/code_234.py
2,578
4.15625
4
#!/usr/bin/env python3 """ link: https://leetcode-cn.com/problems/palindrome-linked-list/ 请判断一个链表是否为回文链表。 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true 进阶: 你能否用 O(n) 时间复杂度和 O(1) 空间复杂度解决此题? """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # ...
bbf989f691633baf5f10f5541798b6bf11deeb87
WU731642061/LeetCode-Exercise
/python/code_104.py
1,778
4.09375
4
#!/usr/bin/env python3 """ link: https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/ 输入一棵二叉树的根节点,求该树的深度。从根节点到叶节点依次经过的节点(含根、叶节点)形成树的一条路径,最长路径的长度为树的深度。 给定二叉树 [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7 返回它的最大深度3 思考: 一开始做树的算法题总是蒙蔽的,因为要摆脱常规的逻辑思维,也有一部分原因是,平时很少去用到深度优先、广度优先的算法思想。 这道题的解法有点类...
e6d5a9aab18adc542bb443de968fa140a34a3c8d
emrecanstk/python-ornekler
/sifre-olustur.py
1,624
3.78125
4
# emrecanstk/python-ornekler # Şifre Oluşturan Program import random,time print("Şifre Oluşturucu") # programın isminin ekrana bastırılması # listelerin tanımlanması liste,sifre = [],[] b_harfler = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","R","S","T","...
2b803b5c53b0fc9cc03049f7b8eb61f39d38125d
thSheen/pythonaz
/Basic/Variables.py
479
4.125
4
greeting = "Hello" Greeting = "World" _NAME = "Thiago" Thiago34 = "What" t123 = "Wonderful" print(greeting + ' ' + _NAME) print(Greeting + ' ' + Thiago34 + ' ' + t123) a = 12 b = 3 print(a + b) print(a - b) print(a * b) print(a / b) print(a // b) # // to whole numbers, it's important use it to prevent future errors ...
e833103aba8776889386a62829fd73c852e1edda
thSheen/pythonaz
/Basic/String.py
489
3.953125
4
parrot = "Hello Everybody" print(parrot) print(parrot[0]) # The first le print(parrot[3]) print(parrot[0:2]) print(parrot[:4]) # Without a first number, it will start from the first letter print(parrot[6:]) # Without a last number, it will end in the last letter print(parrot[-1]) print(parrot[0:6:3]) number = "9,234,4...
e20a50eb4d2e531139de86a6a43017c5fe9d821f
kelvinlim/lnpireceiver
/read_drivingdata.py
1,597
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Example code to read in the driving_task data from the REST API server @author: kolim https://www.nylas.com/blog/use-python-requests-module-rest-apis/ import request Also has section on authentication using access tokens Oauth https://www.dataquest.io/blog/python-a...
a15efdc2554db34cdce12ad5364ab2b55a26d2f3
Caotick/ADA-ML
/labs-ML/ex04/template/split_data.py
662
3.546875
4
# -*- coding: utf-8 -*- """Exercise 3. Split the dataset based on the given ratio. """ import numpy as np def split_data(x, y, ratio, seed=1): """ split the dataset based on the split ratio. If ratio is 0.8 you will have 80% of your data set dedicated to training and the rest dedicated to testing...
7d947aad5ede437823a02baeedee6c31209c6acc
Benican/fogstream_courses
/Temp/задача1.py
571
3.96875
4
speed = int(input('Введите скорость движения, км/ч. ')) time = int(input('Введите время движения, ч. ')) circle_length = 109 if speed > 0: number_of_circle = (speed*time)/circle_length stop_point = round(circle_length * (number_of_circle - int(number_of_circle))) else: number_of_circle = (speed*time)/c...
00780f56a0ce3179679bb1e3950b5bb4ea501469
sreedhar17/Python_Challenges
/src/main/python/cadbury.py
645
3.609375
4
def TotalCount(M, N, P, Q): count=0 for l in range(M, N + 1): for b in range(P, Q + 1): count+=CountPerChocolateBar(l, b) return count def CountPerChocolateBar(l, b): count=0 while True: longer=max(l, b) shorter=min(l, b) count+=1 diff=longer - ...
073670125f405c6bab1408f80ca0ec785f43be24
sreedhar17/Python_Challenges
/src/main/python/plusMinusRatio.py
315
3.703125
4
def plusMinus(arr): print(arr) len_arr=len(arr) print("length::",len_arr) tot_pos=0 tot_neg=0 tot_zeros=0 print(sum((tot_pos+1,tot_neg+1) for i in range(len(arr)) if arr[i]>0 for j in range(len(arr)) if arr[j]<0 )) if __name__=="__main__": arr=[-4,3,-9,0,4,1] plusMinus(arr)
1f2896854030a6921beb38d932dac7c0fff4f2b7
FinleyLi/109-TSH_Python_3.8.3
/20201103-13(review).py
4,155
3.59375
4
#!/usr/bin/env python # coding: utf-8 # 日期: 2020. 11. 03 # 課程: 程式語言與設計 # """ # 09/11 # """ # In[2]: # 四則運算 pv = 10000*(1+0.03) print(pv/0.03) # In[4]: # 記憶體位置 id(pv) # In[5]: # 字串相加 str1 = 'Just' str2 = 'in' str3 = str1 + str2 print(str3) # """ # 09/15 # """ # In[7]: # BMI身體質量指數 # 體重 Wight = 72 # 身高 #...
77555730fb4447f6f6b5e38b317236727fda094c
dvlupr/Fall2018-PY210A
/students/KyleBarry/session03/mailroom.py
2,227
3.796875
4
#Establish some data to work with in a dictionary donors = {"Timothy Tander": [100, 200, 300], "Tara Towers": [200, 400, 600], "Charlie Day": [700, 100, 2000], "Sandra Connors": [1800, 2300, 7000], "Betsy Hammond": [500, 190, 212, 55]} donors["Timothy Tander"].append(800) d...
a445f67e1b70aaa5538b3e007d26911b3f50da41
Bertil1/PPVolumeCalculator
/main.py
315
3.828125
4
print('Enter PP length in cm:') pplength = float(input()) print('Enter PP thickness:') ppthickness = float(input()) ppvolume = ppthickness/2**2*3.14*pplength print('your pp is %s cm3'%ppvolume) if ppvolume > 23: print('U Hav Beeg PP') elif ppvolume < 19: print('U Hav Smol PP') else: print('U Hav Normie PP')
b777cc4d1682a6a3c1e5a450c282062c4a0514da
jrobind/python-playground
/games/guessing_game.py
755
4.21875
4
# Random number CLI game - to run, input a number to CLI, and a random number between # zero and the one provided will be generated. The user must guess the correct number. import random base_num = raw_input('Please input a number: ') def get_guess(base_num, repeat): if (repeat == True): return raw_input(...
e88333ce7bd95d7fb73a07247079ae4f5cb12d11
graciofilipe/differential_equations
/udacity_cs222/final_problems/geo_stat_orb.py
2,907
4.375
4
# PROBLEM 3 # # A rocket orbits the earth at an altitude of 200 km, not firing its engine. When # it crosses the negative part of the x-axis for the first time, it turns on its # engine to increase its speed by the amount given in the variable called boost and # then releases a satellite. This satellite will ascend t...
f337411ac670c33d0cc7fc1243cbe62247ae0bd9
shinta834/purwadhika1
/jawaban1.py
321
3.765625
4
def kalimat(x): if len(x)>200: print('Batas Karakter Maksimal Hanya 200') elif len(x)==0: print('Masukkan Sebuah Inputan') else: text = '*{}*' print(text.format(x.upper().replace(' ',''))) x= input('Masukkan Sebuah Kalimat : ') kalimat(x) # ini adalah sebuah CONTO...
deecbd966d71fcdeba94c765506d6ce009741cab
DamianKa/money_for_retirement
/money_for_retirement.py
505
3.953125
4
#how much you need to retire print ("The How Much You Need to Retire Calculator") monthly_spend = int(input("How much money in terms of today's money will you need on retirement (per month)? £")) ir = int(input("What return from investments you can achieve in the long term? %")) inflation = int(input("What average re...
9b773f07693eab8e686808d640d95e890c12af00
pradeepkumar1234/pyt1
/voworcon.py
223
4.0625
4
ch=input("") if((ch>='a' and ch<='z') or (ch>='A' and ch<='Z')): if(ch=='a',ch=='e',ch=='i',ch=='o',ch=='u',ch=='A',ch=='E',ch=='I',ch=='O',ch=='U'): print("Vowel") else: print("Constant") else: print("invalid")
ddc0bf0fdf77f46bf646a5ee2654d391e031647d
rojiani/algorithms-in-python
/dynamic-programming/fibonacci/fib_top_down_c.py
978
4.21875
4
""" Fibonacci dynamic programming - top-down (memoization) approach Using Python's 'memo' decorator Other ways to implement memoization in Python: see Mastering Object-Oriented Python, p. 150 (lru_cache) """ def fibonacci(n): # driver return fib(n, {}) def fib(n, memo= {}): if n == 0 or n == 1: ...
55b2a9b005f15e7d65f87a5d76667f1a25b2ba60
rojiani/algorithms-in-python
/dynamic-programming/0_1_knapsack/0_1_knapsack.py
3,762
3.71875
4
class Item(object): def __init__(self, name, value, weight): self.name = name self.value = value self.weight = weight def get_name(self): return self.name def get_value(self): return self.value def get_weight(self): return self.weight def __str__(self): retu...
cc504fd886f0062c2a11435754683f4ba5e71d21
gaoalexander/fundamental-data-structures-and-algorithms
/algorithms/merge-sort.py
1,986
3.984375
4
import math #------------------------------------------------------------ # MERGE SORT (NOT IN PLACE!) # def merge(lhs, rhs): # len_lhs = len(lhs) # len_rhs = len(rhs) # len_sum = len_lhs + len_rhs # lhs_new = list(lhs) # rhs_new = list(rhs) # lhs_new.append(math.inf) # rhs_new.append(math.inf) # merged = ...
29fcf40ceb7369d30377d7e67dfaabd121977717
sent1nu11/mail-merge
/main.py
584
3.59375
4
#TODO: Create a letter using starting_letter.docx #for each name in invited_names.txt #Replace the [name] placeholder with the actual name. #Save the letters in the folder "ReadyToSend". #Hint1: This method will help you: https://www.w3schools.com/python/ref_file_readlines.asp #Hint2: This method will also he...
d3e8817579165225de18abb7e43ed4c2a8a33273
patchiu/math-programmmmm
/D_IN/Simpson's Rule.py
959
4
4
##Simpson's Rule def simps(f,a,b,N=50): '''Approximate the integral of f(x) from a to b by Simpson's rule. Simpson's rule approximates the integral int_a^b f(x) dx by the sum: (dx/3) um_{k=1}^{N/2} (f(x_{2i-2} + 4f(x_{2i-1}) + f(x_{2i})) where x_i = a + i*dx and dx = (b - a)/N. Paramet...
0d24f2150c3cd07c0d69a8353f3d01e681c3f1cc
ppdraga/Python.ClientServerApps
/lesson-2/task-5.py
445
3.578125
4
# Реализовать скрипт для преобразования данных в формате csv в формат yaml import csv import yaml from pprint import pprint with open("lesson-2/data-read.csv", "r") as file: reader = csv.reader(file) headers = next(reader) data = dict(zip(headers, reader)) # print(headers) pprint(data) with open(...
c0ef9cd59e3fe5840bf90305b6fbcdb35776baca
wudiee/Algorithms
/linked_list.py
860
3.953125
4
class Node: def __init__(self,data,loc,next = None): self.data = data self.loc = loc self.next = next def init_list(): global node1 node1 = Node(5,0) node2 = Node(10,1) node3 = Node(17,2) node4 = Node(9,3) node5 = Node(13,4) node6 = Node(7,5) node7 = Node(19,6) node1.next = node2 node...
28c8eb708788676cdfe917b75ae064399fb65bd0
uffehellum/dailypy
/daily700/daily740/daily744.py
6,562
3.640625
4
import unittest # Implement an LFU (Least Frequently Used) cache. # It should be able to be initialized with a cache size n, and contain the following methods: # # set(key, value): sets key to value. # If there are already n items in the cache and we are adding a new item, # then it should also remove the least f...
fb6432dc5ea2b79baa5b37c4eb51d758f4b53efb
uffehellum/dailypy
/daily700/daily700/daily707.py
725
3.53125
4
import unittest def min_range(listeners, towers): largest = 0 t1 = towers[0] i = 0 for listener in listeners: d1 = abs(listener - t1) if d1 <= largest: continue if i + 1 < len(towers): t2 = towers[i + 1] d2 = abs(t2 - listener) if...
5a01369663f7250eae51cb0cfb46fa227e864f4c
azarrias/udacity-nd256-problems
/src/stock_prices.py
3,264
4.34375
4
""" Stock Prices Greedy algorithm You are given access to yesterday's stock prices for a single stock. The data is in the form of an array with the stock price in 30 minute intervals from 9:30 a.m EST opening to 4:00 p.m EST closing time. With this data, write a function that returns the maximum profit obtainable. ...
fc72c287a60083ec4a03c9b476cbe4a55a2d68c5
azarrias/udacity-nd256-problems
/src/coin_change.py
3,681
4.125
4
""" Coin Change You are given coins of different denominations and a total amount of money. Write a function to compute the fewest coins needed to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. As an example: Input: coins = [1, 2, 3], amount = 6 O...
5c77c6cf0be7ab2271674c4d70cffb98c18d94f7
JasonHinds13/CodeJamSolutions
/IEEEXtreme10/Food-Truck/food-truck.py
1,939
3.765625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import time from math import radians, cos, sin, asin, sqrt def conv_time(t): return int((t.split(" ")[1]).replace(":","")) def conv_date(d): date = d.split(" ")[0] return time.strptime(date, "%m/%d/%Y") def get_nums(lis): l = [] ...
cab3c1c48f7f2b8eb988d2cd9901d4d832804e6c
carolyn-davis/numpy-pandas-visualization-exercises
/pandas_series_exercises.py
15,811
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jul 16 10:51:27 2021 @author: carolyndavis """ import numpy as np import pandas as pd import matplotlib.pyplot as plt # ============================================================================= # EXERCISES PART 1: # =====...
30d42da6fa8c107b6f17ef550ef47ca81ece6233
swford89/python_code_challenges
/code_challenge_01.py
1,158
4.09375
4
# Coding Nomads - Code Challenge #1: The Sieve of Eratosthenes # Scott Ford # April 30th, 2021 def sieve(n): """to find all the prime numbers up to a specified maximum""" sieve_list = [] if n in range(2,65536): # make sure min and max values are >= 2 and < 65,536 ...
e4a241281be2170d39e066a092c8bf0fed1ea3b7
wangmx116/wdd
/ML-exercise1-4/ex3/ex3.py
5,563
3.984375
4
## Machine Learning Online Class - Exercise 3 | Part 1: One-vs-all import scipy.io import numpy as np from matplotlib import use use('TkAgg') import matplotlib.pyplot as plt from oneVsAll import oneVsAll from predictOneVsAll import predictOneVsAll from displayData import displayData from predict import predict np.set...
75c14cfafe64264b72186017643b6c3b3dacb42f
Malak-Abdallah/Intro_to_python
/main.py
866
4.3125
4
# comments are written in this way! # codes written here are solutions for solving problems from Hacker Rank. # ------------------------------------------- # Jenan Queen if __name__ == '__main__': print("Hello there!! \nThis code to practise some basics in python. \n ") str = "Hello world" print(str[2:]) ...
2fbba8408416247b6cbdd3918efbe04a242634d4
Malak-Abdallah/Intro_to_python
/general.py
255
3.546875
4
from itertools import permutations if __name__ == '__main__': word=list(map(str,input().split(" "))) len = int(word[1]) per=permutations(list(word[0]),len) arr=sorted(per) for x in arr: strr=x[0]+x[1] print(strr)