blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
73e634eceda346c3231886d8ff21c353c7acb4e2
hyejun18/daily-rosalind
/scripts/bioinformatics-textbook-track/BA1N.py
1,239
3.625
4
################################################## # Generate the d-Neighborhood of a String # # http://rosalind.info/problems/BA1N/ # # Given: A DNA string Pattern and an integer d. # # Return: The collection of strings Neighbors(Pattern, # d). # # AUTHOR : dohlee ################################################## ...
bdc138369b8b099a297d62b4899a9f9552c8bff5
hyejun18/daily-rosalind
/prepare/template_scripts/bioinformatics-textbook-track/BA6A.py
663
3.984375
4
################################################## # Implement GreedySorting to Sort a Permutation by Reversals # # http://rosalind.info/problems/BA6A/ # # Given: A signed permutation P. # # Return: The sequence of permutations corresponding # to applying GreedySorting to P, ending with the # identity permutation. ...
d7dd8d3659b183bdc137b14bc9ade88fa784f90a
hyejun18/daily-rosalind
/prepare/template_scripts/bioinformatics-stronghold/REVP.py
694
3.5
4
################################################## # Locating Restriction Sites # # http://rosalind.info/problems/REVP/ # # Given: A DNA string of length at most 1 kbp in # FASTA format. # # Return: The position and length of every reverse # palindrome in the string having length between # 4 and 12. You may retur...
a3c36b8ac7764876db6a8b3b152ab11c3e590cf3
hyejun18/daily-rosalind
/prepare/template_scripts/bioinformatics-stronghold/FIBD.py
643
3.75
4
################################################## # Mortal Fibonacci Rabbits # # http://rosalind.info/problems/FIBD/ # # Given: Positive integers n <=q 100 and m <=q 20. # # Return: The total number of pairs of rabbits that # will remain after the n-th month if all rabbits # live for m months. # # AUTHOR : dohlee ...
ed00bf3957415041b54f01a7f097abad6c69124f
hyejun18/daily-rosalind
/prepare/template_scripts/python-village/INI3.py
741
3.734375
4
################################################## # Strings and Lists # # http://rosalind.info/problems/INI3/ # # Given: A string s of length at most 200 letters # and four integers a, b, c and d. # # Return: The slice of this string from indices # a through b and c through d (with space in between), # inclusivel...
511c77b94551510d74c2c030ab142f9f66fbce46
hyejun18/daily-rosalind
/prepare/template_scripts/algorithmic-heights/DAG.py
696
3.65625
4
################################################## # Testing Acyclicity # # http://rosalind.info/problems/DAG/ # # Given: A positive integer k <= 20 and k simple # directed graphs in the edge list format with # at most 10^3 vertices and 3 \cdot 10^3 edges # each. # # Return: For each graph, output "1" if the graph...
77c1eca55998c24262742054d8cad2b7515a8d9f
hyejun18/daily-rosalind
/scripts/bioinformatics-textbook-track/BA7G.py
695
3.734375
4
################################################## # Adapt SmallParsimony to Unrooted Trees # # http://rosalind.info/problems/BA7G/ # # Given: An unrooted binary tree with each leaf # labeled by a string of length m. # # Return: A labeling of all other nodes of the tree # by strings of length m that minimizes the p...
48cad2b7b5ba3d2bed09e69038e997c2620b0ed3
hyejun18/daily-rosalind
/scripts/bioinformatics-textbook-track/BA1J.py
1,746
3.71875
4
################################################## # Find Frequent Words with Mismatches and Reverse Complements # # http://rosalind.info/problems/BA1J/ # # Given: A DNA string Text as well as integers k # and d. # # Return: All k-mers Pattern maximizing the sum # Countd(Text, Pattern) + Countd(Text, Pattern) # ov...
d7ab35b654fabc04373b3556842b2778f2ce30d6
hyejun18/daily-rosalind
/prepare/template_scripts/bioinformatics-textbook-track/BA10J.py
819
3.609375
4
################################################## # Solve the Soft Decoding Problem # # http://rosalind.info/problems/BA10J/ # # Given: A string x, followed by the alphabet # from which x was constructed, followed by the # states States, transition matrix Transition, # and emission matrix Emission of an HMM (, St...
1885e32289e1c5c2cf4b27a0b75853bc3bdc07bc
hyejun18/daily-rosalind
/prepare/template_scripts/bioinformatics-stronghold/PROB.py
805
3.5625
4
################################################## # Introduction to Random Strings # # http://rosalind.info/problems/PROB/ # # Given: A DNA string s of length at most 100 bp # and an array A containing at most 20 numbers # between 0 and 1. # # Return: An array B having the same length as A # in which B[k] represe...
a2758ee37e4775b1a5f53ebf59dd33805489e1d7
hyejun18/daily-rosalind
/scripts/bioinformatics-textbook-track/BA1C.py
830
4.03125
4
################################################## # Find the Reverse Complement of a String # # http://rosalind.info/problems/BA1C/ # # Given: A DNA string Pattern. # # Return: Pattern, the reverse complement of Pattern. # # AUTHOR : dohlee ################################################## # Your imports here # ...
7a7446495e2bdfd25a8f36440a186dac1489fc58
hyejun18/daily-rosalind
/scripts/python-village/INI3.py
879
3.5625
4
################################################## # Strings and Lists # # http://rosalind.info/problems/INI3/ # # Given: A string s of length at most 200 letters # and four integers a, b, c and d. # # Return: The slice of this string from indices # a through b and c through d (with space in between), # inclusivel...
67d1a5c2050f5c7cce5ed527da52e7ee1849b15f
hieubkvn123/MnistClassificationUsingNumpy
/activations.py
351
3.59375
4
import math import numpy as np class SigmoidLayer(object): def __init__(self): self.trainable = False self.inputs = None def forward(self, inputs): self.z = 1 / (1 + np.exp(-inputs)) return self.z def backward(self, prev_grad): # gradients with respect to inputs self.dA = np.multiply(prev_grad , np....
d82b916e59e936f07d55b63887fc38545f10e3c2
shantanuwadnerkar/plume_nav
/src/plume/plume_tools/scripts/testing.py
145
3.59375
4
#! /usr/bin/env python def abc(*dir): if not dir: dir = 1 else: dir = dir[0] dir = dir + 1 print(dir) abc()
0c484ac68b03f25604adf8c9e25d963ffcfaf025
robynfsj/cfg-python-project
/manipulate.py
1,091
3.515625
4
import read from datetime import datetime # Extract data required in a suitable format. def manip_data(): input_data = read.read_data() # Create output data list of dictionaries. output_data = [] for row in input_data: output_data.append({ "start": row["Start"], "end":...
48424c1f2e7f66f48dae342309f003f47cc8487a
khushi-developer/PythonPrograms
/tut20.py
522
3.953125
4
#Excercise 3 n = 18 i=0 while(True): if i<5: print("Guess the number i have entered") num = int(input()) if num>n: print("number is greater","remaining attept are",4-i) i=i+1 continue elif num<n: print("Number is lesser""remaining at...
cf01ddd54c89f812543518aec4af50b407c75f93
khushi-developer/PythonPrograms
/PracticeProb6.py
860
3.84375
4
class Player: def playtime(self,name): print(f"player {name} is playing now") import random ls1 = [2, 3, 5, 7] num = random.choice(ls1) print(num) self.count=0 while True: n = int(input("Enter the number")) if num == n: ...
a8ebec4eb0fc008aaf8891839406e6617576fc3c
khushi-developer/PythonPrograms
/PracticeProb4.py
791
3.984375
4
# try: # n=int(input("Enter number of test cases")) # # for i in range(n): # s = input("Enter string or number:") # if(s==s[::-1]): # print("String or number is palindrome") # else: # print("String or number is not palindrome") # # except Exception as e: # pri...
2243cf086f6bd22f24ef93293aa0566f474a5bb8
khushi-developer/PythonPrograms
/tut17.py
499
3.921875
4
#while loop """ i=0 while i<45: print(i,end=" ") i=i+1 """ #tut 18 Break and continue statement """ i=0 while(True): if i+1<5: i=i+1 continue print(i+1,end=" ") if i==44: break i=i+1 """ print("--------------------------------------") while(True): print("Enter num...
678a4b81126ed4d74de689b6b80ffb13fdd4f9e5
khushi-developer/PythonPrograms
/polymorphismss.py
304
3.515625
4
class A: def prit1(self): print("This is A") class B(A): def prit1(self): print("This is B") class C(A): def prit1(self): print("This is C") class D(B,C): def prit1(self): print("This is D") a=A() b=B() c=C() d=D() print(a.prit1()) print(d.prit1())
ca9d21168f9785ef71604b41b289221324d03330
khushi-developer/PythonPrograms
/tut22.py
162
4.34375
4
# short hand If Else a=int(input("Enter a \n")) b=int(input("Enter b \n")) if a<b: print("b is greater") print("b is greater") if a<b else print("a is greater")
87c3052efc3d75729f1d07cca9838e9e0acfa646
khushi-developer/PythonPrograms
/PracticeProb8.py
373
3.96875
4
n = int(input("Enter number")) numbers = [] for i in range(11): f = n * i if i == 3: numbers.append(f+3) continue numbers.append(f) # print(f) # print(numbers) lis = [] for i in range(11): f = n * i lis.append(f) # print(lis) if numbers == lis: print("Table is correct!") ...
1ef5666c7efe8c6a20bc4f8b114070837574250b
khushi-developer/PythonPrograms
/tut114.py
462
4
4
# Exercise 2 faulty calculator print("Enter number1") num1=int(input()) print("Enter operator") op=input() print("Enter number1") num2=int(input()) if num1==45 and num2==3 and op=='*': print(559) elif num1==12 and num2==5 and op=='/': print(103) elif num1==99 and num2==3 and op=='+': print(113) elif ...
9836d6ee60251536235c4d305d2ff727d1a069e2
Fahmi-adzkar/Fisika-Komputasi
/Integral Metode Trapezoid/main.py
219
3.75
4
from trapezoid import * def f(x): return x**2+4 a=float(input('batas bawah = ')) b=float(input('batas atas = ')) n=int(input('jumlah grid = ')) integral=trapezoid(f,a,b,n) print('Integral = ', integral)
df07aab0f9d361eea1c680a234411bfc54160221
Fahmi-adzkar/Fisika-Komputasi
/Gerak Jatuh Bebas Dengan Gesekan/gerak jatuh bebas dengan gesekan udara.py
1,022
3.65625
4
import numpy as np from printSoln import * from euler import * import matplotlib.pyplot as plt # input data g=9.8 c=7.0 m=70.0 # persamaan diferensial biasa def F(x,y): F = np.zeros(1) F[0] = g - (c/m)*y[0] return F x = 0.0 # Start of integration xStop = 10.0 # End of integration y = np.a...
fb7adb7458167c3f1d02dc709c95037816b15d5b
ArtZubkov/test-tasks
/task4/task4.py
1,579
3.609375
4
import sys import os.path #Основная функция def task4(filename): #Открываем и читаем файл with open(filename) as file: nums = file.read() if nums == '': print('Empty file') sys.exit() nums = nums.split('\n') #Формируем целочисленный список for i in ran...
6a6468dc982e95af935fbd3a353794d55da10dc2
emiliobort/python
/Practica1/Programas/Ejercicio2.py
1,118
4.125
4
# Visualizar un cuadrado con su vértice inferior izquierdo en el origen from turtle import * #Inicializamos la pantalla pantalla = Screen() pantalla.setup(425,225) pantalla.screensize(400,200) #Asignamos las variables x e y, y pedimos al usuario valores del lado x = 0 y = 0 lado = int(input("Dame el tamaño del lado...
8e25103e919eeca1662023491a97b11311cf11f3
emiliobort/python
/Practica1/Programas/Ejercicio8.py
784
3.875
4
horas_dia = 24 mes = 31 duracion = int(input("Dame el total de horas: ")) if (duracion < horas_dia or duracion > (horas_dia * mes)): print("No es un horario correcto") else: if (duracion >= horas_dia and duracion < 30*horas_dia): print("El precio es de 11 €") elif (duracion >= (2 * h...
1883e0f0543f61433256dd82f4489b6a5d8d3026
emiliobort/python
/Practica4/Programas/Ejercicio1.py
337
3.859375
4
def es_narcista(n): es_narcista = True comparar = n suma_potencia = 0 while es_narcista and n != 0: suma_potencia = suma_potencia + (n%10)**3 n = n//10 if suma_potencia != comparar: es_narcista = False return es_narcista numero = int(input("Dame un numero: ")) print(es_n...
8960fb3709eaa748f2917bfdb433a98a5851d34b
emiliobort/python
/Practica2/Programas/Ejercicio7.py
865
4.09375
4
from turtle import * from random import * pantalla = Screen() pantalla.setup(425,225) pantalla.screensize(400,200) tortuga = Turtle() tortuga.shape("turtle") # Tortuga con forma de tortuga. tortuga.stamp() # Sello de la tortuga en el punto (0,0) dentro = True # Condicion para finalizar el bucle while. while dentr...
d7480bdb3e2b1a5918e8601aa179d92bb71470a8
emiliobort/python
/Practica4/Con prueba/prac04ej08.py
464
3.953125
4
# -*- coding: utf-8 -*- from modulo_test import test def crear_lista_digitos(numero): lista = [] while numero > 0: numero2 = numero%10 lista = [numero2] + lista numero = numero//10 return lista # –- Programa principal –- # Ejecutar el test sólo al ejecutar el fichero (y no al imp...
67fe63072ed9d3592f98210b9a05ea8080a68d8c
emiliobort/python
/Practica4/Con prueba/prac04ej03.py
1,022
3.515625
4
# -*- coding: utf-8 -*- from modulo_test import test from prac04ej02 import divisores def son_amigos (n1,n2): amigos = False lista_n1 = [] lista_n2 = [] suma_n1 = 0 suma_n2 = 0 lista_n1 = divisores(n1) lista_n2 = divisores(n2) del lista_n1[-1] del lista_n2[-1] for elem in lis...
8be40c00c68bf65cb1f274e85a8daf8698bbb910
ferasalsaab/neuralnilm_prototype
/neuralnilm/init.py
1,262
3.78125
4
""" Functions to create initializers for parameter variables """ import numpy as np from lasagne.utils import floatX from lasagne.init import Initializer class Identity(Initializer): """Initialise with the identity matrix. Can be used to initialise ReLU RNNs as per [#le2015ReLU-RNNs]_. :references: ...
ad83c19b444d3472dd1a205c5a8e9eca45332845
dh-trier/musicovers
/ZZ_HelperModules/basic_image_functions.py
1,564
3.84375
4
#!/usr/bin/env python3 """ This module offers some basic functions for image processing with Pillow. """ from os.path import join from PIL import Image def load(file): """ Load an Image file :param file: Source file :return: Image object """ image = Image.open(file) return image def sa...
ad351ca484312ebb24ecc713e6509d76cbc42a92
bopopescu/Glowing-Grass
/NicksGardens/venv/Pseudocode.py
420
3.765625
4
import datetime customer_details_csv = open('contact_details.csv', 'r').read() day = int(input("Input day: ")) month = int(input("Input month: ")) year = int(input("Input year: ")) date = str(datetime.date(year,month,day)) print(date) if date in customer_details_csv: print("Date used") else: print("Date not ...
31d77a16ba0de53c6feb137d32f7301dcfff0eea
gengyanqikobe/Home_PC_share
/Practices/from_git/10_tkinter.py
1,255
3.515625
4
#联系tkinter import tkinter import tkinter.messagebox def main(): flag = False #顶层窗口 top = tkinter.Tk() #窗口大小 top.geometry('360x360') #标题 top.title('游戏') #创建标签对象并添加到顶层窗口 label = tkinter.Label(top,text = 'hello,world',font = 'Arial -32',fg = 'red') label.pack(expand = 1...
b0a98e8288538d2ce200d81ed705b40598741b0c
gengyanqikobe/Home_PC_share
/Practices/test/test_t/5Card_1.py
880
3.578125
4
list_a = [] sta = False for i in range(0,5): #print(i) a = int(input("请输入0到13的整数:")) if int(a) >13 or int(a) < 0: print('wrong number!!!') break else: list_a.append(a) sta = True def card_continues(cards): if len(cards)< 5: return False cards.sort(...
0740c91255edfd2a2db8588650323a8f2b68f540
gengyanqikobe/Home_PC_share
/Practices/test/test_t/thread_ing.py
701
3.984375
4
import threading from time import ctime,sleep def fun(num): for i in range(0,int(num)): #输出这个线程的名字 print('i come from %s,num :%s,%s'%(threading.current_thread().getName(),i,ctime())) sleep(1) #fun(100) def main(thread_num): thread_list = list() #先创建线程对象 for i in range(0,thread_...
b55ba7d97f59fc7880315d61ad51b301c5e8b355
gotgith/Algorithms
/Algorithms-master/chapter_08_minimum_span_tree/edge.py
1,351
3.609375
4
class Edge: def __init__(self, a=None, b=None, weight=None): # 若为有向图,默认从a指向b self._a = a self._b = b self._weight = weight def v(self): return self._a def w(self): return self._b def wt(self): return self._weight # 知道边的一个顶点,来获得边的另外一个顶点 ...
ab7359095507751f8175e295940aa726877f1140
gotgith/Algorithms
/Algorithms-master/chapter_06_union_find/union_find.py
5,414
3.65625
4
class UnionFind1: def __init__(self, n): self._count = n self._id = [i for i in range(n)] def _find(self, p): assert 0 <= p < self._count return self._id[p] def is_connected(self, p, q): return self._find(p) == self._find(q) def union(self, p, q): asser...
b4413f8ff733eab329d952541340432da8538119
gotgith/Algorithms
/Algorithms-master/chapter_03_advanced_sort/quick_sort.py
3,355
4.0625
4
import random from time import time from chapter_02_basic_sort.insertion_sort import insertion_sort_in_range def quick_sort(arr): random.seed(time()) __quick_sort(arr, 0, len(arr) - 1) def __quick_sort(arr, l, r): """对arr[l...r]前闭后闭部分进行快速排序""" if l >= r: return p = __partition(arr, l, r)...
fef45c90ec5b5d470309d7f8eb2e0ecca7a90a57
shivakumarcd/python
/solution/first_python_code.py
7,202
3.859375
4
''' Shiv's learning Python with previous OO coding experience (Java) referring https://www.youtube.com/watch?v=N4mEzFDjqtA - 43mins install : 00:17 Basics : 02:23 Arithmetic : 04:21 ...
c3a879a54be0d08112ccfa53e0256d35d5c06958
8589/codes
/python/leetcode/data_struct/856_Score_of_Parentheses.py
837
3.5625
4
class Solution: def scoreOfParentheses(self, s): """ :type S: str :rtype: int """ res, stack = 0, [] for c in s: if c == "(": stack += 0, else: pre = stack.pop() if pre == 0: v...
8b9cebd6286468bcffc2146380b1047c001b6f39
8589/codes
/python/leetcode/tree/450_Delete_Node_in_a_BST.py
3,582
4.03125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def deleteNode(self, root, key): """ :type root: TreeNode :type key: int :rtype: Tre...
065e4b6a03e3488a42cd799c9bb9a2c77fa0852e
8589/codes
/python/leetcode/graph/topological_sorting.py
1,161
4.03125
4
# http://www.geeksforgeeks.org/topological-sorting/ def topological_sort(number_vertexes, edges): reversed_links = [[] for _ in xrange(number_vertexes)] for i, j in edges: if j > i: reversed_links[j].append(i) visited =[False] * number_vertexes result =[] acc = [i for i in xran...
594989dbb67fcb101a9f56c59cf3a2c4a49f62da
8589/codes
/python/leetcode/search/33_Search_in_Rotated_Sorted_Array.py
1,853
3.546875
4
class Solution: def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ from bisect import bisect_left if not nums: return -1 first = nums[0] if target == first: return 0 l, r = 0, len(num...
fde62e4934535d24076b257bc19d3ead0115bf65
8589/codes
/python/leetcode/tree/776_Split_BST.py
668
3.765625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def splitBST(self, root, target): """ :type root: TreeNode :type target: int :rtype: List...
7fb3cc72a68a4ff0290441ffc6e27d214c3bb7d6
8589/codes
/python/my_test/decorator/with_with.py
753
3.8125
4
def print_method_info(func): '''This decorator dumps out the arguments passed to a function before calling it''' argnames = func.func_code.co_varnames[:func.func_code.co_argcount] fname = func.func_name def echo_func(*args,**kwargs): print fname, "(", ', '.join( '%s=%r' % entry ...
e8b33f28ca051fa8ca33a383eefa020e6bd5a6d5
8589/codes
/python/leetcode/stack_from_queue.py
958
3.625
4
from my_queue import * class MyStack(object): def __init__(self): super(MyStack, self).__init__() self.queue = MyQueue() def pop(self): tmp_queue = MyQueue() while self.queue.size() > 1: tmp_queue.en(self.queue.de()) result = self.queue.de() self.que...
36d31c608750b0f412f801df82881c0a07e6acd8
8589/codes
/python/leetcode/tests/ladder_length.py
3,544
3.640625
4
def is_diff_one(str1, str2): diff_sum = 0 for i in xrange(len(str1)): if str1[i] != str2[i]: diff_sum+=1 if diff_sum >= 2: return False return True def find_diff_one_indexes(begin_word, word_list, exclude_indexs): result = [] for i in xrange(len(word...
32640ac43500ba203a0e2b1ed65dde780cb35811
8589/codes
/python/leetcode/list/142_Linked_List_Cycle_II.py
1,672
3.84375
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None ''' with O(n) time and O(1) space without modifying the list let n is total length of list, x is the length before entry of loop, l is the length, w...
ae360cb6e78c4f201e8a49899d3b3af0b01c64f6
8589/codes
/python/leetcode/search/binary_search.py
1,266
4.0625
4
def binary_search(nums, target): """ input: int[] nums, int target return: int """ if not nums: return -1 left, right = 0, len(nums)-1 while left <= right: mid = (left + right) // 2 if nums[mid] == target: return mid elif nums[mid] > target: ri...
ca6ded700e2f580325b6437db4b83e166d4b4a2c
8589/codes
/python/leetcode/array/524_Longest_Word_in_Dictionary_through_Deleting.py
943
3.8125
4
class Solution: def findLongestWord(self, s, words): """ :type s: str :type d: List[str] :rtype: str """ res = "" def check(word): pre = 0 for c in word: if c not in s[pre:]: return False ...
9f2cac4237fd10122c8731f5e1c456964c4f59e7
8589/codes
/python/my_test/list_comprehension/flatten.py
339
4.03125
4
def flatten1(lst): return [item for sublist in lst for item in sublist] def flatten(lst): result = [] for sublist in lst: if isinstance(sublist, list): for item in sublist: result.append(item) else: result.append(sublist) return result print fla...
20c13fa236de48a3a418bbac633f32554381c7c1
8589/codes
/python/my_test/interview/generator.py
504
4.125
4
''' show how to use generator, every generator is iteration, but not vice verse. ''' def yrange(n): # print n i = 0 # print i while i < n: # print i yield i i = i + 1 y_iter = yrange(10) # print y_iter.next() # print y_iter.next() for i in y_iter: print i # if __name__...
228d5a9779817e710c6cd75962b005055a7c5650
8589/codes
/python/my_test/class/high_level.py
844
3.75
4
class Basic(object): """it's the basic which handles methods in the basic level.""" def __init__(self, basic_arg): super(Basic, self).__init__() self.basic_arg = basic_arg def basic_func1(self, index): # print index return index def basic_func2(self, index): ...
ce509e0cd30de508a3257c89ff4db6aab84717be
8589/codes
/python/leetcode/algorithm/backtracking/top_14_Find_shortest_route_in_landmines.py
2,374
3.828125
4
# http://www.geeksforgeeks.org/top-20-backtracking-algorithm-interview-questions/ def solve(board): m = len(board) n = len(board[0]) shortest_len = [m * n] dirs = [(1,0),(-1,0),(0,1),(0,-1)] for i in range(m): for j in range(n): if board[i][j] == 0: for di, dj in ...
abeeadb3f62e6957d975878c29d57f493da07806
8589/codes
/python/leetcode/hackerrank/bigger_is_greater/main.py
1,243
3.875
4
def find_smallest_big(the_str): for i in range(len(the_str)-2,-1,-1): smallest_index = None for j in range(i+1, len(the_str)): if the_str[i] < the_str[j]: if smallest_index: if the_str[smallest_index] > the_str[j]: smallest_inde...
15c8e21fdde43a03f5c2a8a7e883b8bdb9887f4c
8589/codes
/python/leetcode/hackerrank/bomberman_game/main.py
2,380
3.625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT def get_full_matrix(row_count, col_count): return [["O" for j in xrange(col_count)] for i in xrange(row_count)] def get_detonated_matrix(row_count, col_count, matrix): for i in xrange(row_count): for j in xrange(col_count): ...
54fc741fe545859c407647afd99f89c4dd38fcdd
8589/codes
/python/my_test/opencv/blur_example.py
3,428
3.53125
4
import cv2 import numpy from picture_sudoku.helpers import cv2_helper MAX_KERNEL_LENGTH = 31 ''' the methods which name starts with "__blur_by_" will be invoked when trackbar changes. And when you add this type method, the app will show a image for you. The __controle__ is the control trackbar. ''' BL...
2c0463410d1242de1684cb3b6b1dfd82d3d6b178
8589/codes
/python/leetcode/wonderful/Find_Duplicate_Subtrees.py
603
3.796875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def findDuplicateSubtrees(self, root): def tuplify(root): if root: tuple = root.val, ...
1e8ae821de99c465e1261ca6eee3407c1166b0b1
8589/codes
/python/leetcode/word_search_2.py
2,154
3.765625
4
from collections import defaultdict class TrieNode: def __init__(self): self.children = defaultdict(dict) self.word = None def add(self, word): cur = self for c in word: # print(c, cur.children) if c not in cur.children: cur.children[c] = T...
bb205be1ec3cffea1306eb2bf764670b2f9241a5
8589/codes
/python/leetcode/array/845_Longest_Mountain_in_Array.py
1,267
3.609375
4
class Solution: def longestMountain(self, a): """ :type A: List[int] :rtype: int """ if not a or len(a) < 3: return 0 a = [float("inf")] + a + [float("inf")] res = 0 pre_min = None for i in range(1, len(a)-1): (i, a[i])....
cf58c224c4d580821202f1ea6b287ddafddb749a
8589/codes
/python/my_test/interview/graph.py
1,485
3.640625
4
import tree def has_routes(start_node, end_node): visted_list=[] doing_list = [start_node] while len(doing_list)>0: cur_node = doing_list.pop() visted_list.append(cur_node) for child in cur_node.children: # child.pp() if child == end_node: ret...
c9ae681c560471418b677a2bcfc4252703661d46
8589/codes
/python/leetcode/hackerrank/sherlock_and_anagrams/consecutive_sum.py
1,030
3.75
4
def consecutive(num): limit = num // 2 + 1 res = 0 for s in range(1, limit): for n in range(2, limit): if (2*s+n-1) * n == 2 * num: res += 1 break return res def consecutive(num): res = 0 n = 3 while 2 * num >= n * (n+1): if num % ...
8155da53637141b9a76eb07a3168526fed260131
8589/codes
/python/leetcode/array/817_Linked_List_Components.py
665
3.53125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def numComponents(self, head, g): """ :type head: ListNode :type g: List[int] :rtype: int """ mem = set(g) cu...
28ffd00872dcd0fb87f5039bfceffe734a6b1ef2
tamoghnaaa2012/End-semester
/Q1.py
1,273
3.5625
4
import math def N_raphson(f, derivative, x0, tol): step = 0 last_X = x0 next_X = last_X + 1 * tol # "different than lastX so loop starts OK #print("{:<12} {:<12}".format("Iterations", "Absolute error")) while (abs(next_X - last_X) >= tol) and step < 200: # this is how you terminate the loo...
e409312236d348fd120e9780e4d8840bc697aea8
cryzzpie/Python-Support-Bot-
/#support bot.py
1,091
3.890625
4
#support bot jmeno = input ("what is your name?") print("Hello" ,jmeno, "," "and welcome! my name is support bot and i will be helping you today!") print("What can i help you with today" ,jmeno, "?" ",") help = int(input("(1) I didnt recieve my pament yet) ")) if help ==1: print("Hmm was the payment sent later than...
a5eaf5cc98c6aa37fbeb170cd98631833be34eaa
RavinduTharaka/COHDSE182F-001.repo
/01_ceaser.py
997
4.1875
4
def encrypt(string, shift): a = '' for char in string: if char.isalpha(): if char == ' ': a = a + char elif char.isupper(): a = a + chr((ord(char) + shift - 65) % 26 + 65) else: a = a + chr((ord(char) + shift - 97) % 26 + 97) else: print("Please enter...
a95d63bd44731d74fdd4dfcda3d85c252414db0f
Gino-Y/pythonProject
/numpyTest01.py
210
3.59375
4
import numpy as np array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) print(array) print(array.ndim) #维度 print(array.shape) #行列数 print(array.size) #元素数
c6832aa64efca9c74e97ccfb5d977b5b597a6c7d
CodecoolBP20161/a-mentor-s-life-in-an-oo-way-padlab-2
/student.py
3,253
3.78125
4
from person import Person import csv class Student(Person): def __init__(self, first_name, last_name, year, gender, depend_level, knowledge_level, is_bet_on_expected_result, table_football_level, energy_level): super().__init__(first_name, last_name, year, gender) self.depend_le...
5aead1ccbbc0f84928da14679a90206662a7ed90
kavanomo/teamMarf
/rasp_pi/test_files/motor_tests/platform.py
662
3.765625
4
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) # The swivel head motor. 13 - D1 on/off. 15 - D2 direction GPIO.setup(13, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(15, GPIO.OUT, initial=GPIO.LOW) while(1): text = input("Direction (U - Up, D - Down): ") if(text == 'U'): print("We're going up")...
4cb409b39650f537786d269d710db01bf755d0d1
Blacktrooth/lcmemphis
/vigenere.py
967
4.03125
4
import string from helpers2 import alphabet_position, rotate_character def encrypt(text, rot): alphabets = string.ascii_letters keystream = 0 encrypted = "" rot.lower() for i in range(len(text)): keychar = keystream % len(rot) if text[i] in alphabets.lower(): new_char = ...
11822488c26af258226565def99aecef9e664f29
nickharker/nickharker
/Overlap Compare Two CSVs.py
998
3.53125
4
import csv def haversine(lon1, lat1, lon2, lat2): """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) """ # convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) # haversine formula dlon = l...
42eddc6e4849a79e4add55b0dd0410bb6ca3c5b6
dmigranov/TOOI-labs
/Lab1_first_one/lab1.py
673
3.53125
4
import csv def areSimilar(row1, row2): for i in range(0, min(len(row1), len(row2))): if row1[i] == row2[i]: return True; return False; with open('1.csv', 'r') as csvfile1: csvreader1 = csv.reader(csvfile1, delimiter=',', quotechar='"') for row1 in csvreader1: with open('1...
455df05ba80c2cf8604a497e94abfa5a1bd8629f
dmigranov/TOOI-labs
/Lab9/lab9.py
2,114
4.03125
4
import math #1 print("#1") class Box: figures = [] def addFigure(self, fig): self.figures.append(fig) def printBox(self): for f in self.figures: if isinstance(f, Circle): print("Circle of radius", f.radius, "and area of", f.area) elif isinstance(f,...
013c615a759e09b8cee59381354de8f2005f433e
mihaidobri/Neural-Networks
/plot_activation_functions.py
528
3.515625
4
import numpy as np import matplotlib.pyplot as plt #activations functions to try def sigmoid(z): # Apply sigmoid activation function to scalar, vector, or matrix return 1 / (1 + np.exp(-z)) def tanh(z): # Apply TANH activation function to scalar vector or matrix return (2 / (1 + np.exp(-2 * z))) - ...
94966afe1d5193357801b3f78231fa895865af50
RainysLiu/WebCrawler
/day7/面向对象创建进程.py
982
3.640625
4
import time from multiprocessing import Process class SingProcess(Process): def __init__(self, name): # 手动调用父类 super().__init__() self.name = name def run(self): for x in range(6): print('%s is sing a song'%self.name ) time.sleep(1) print('唱歌进程结束'...
ef40086fb79ab7d1d5c97e5fc56823cd35500cd0
MedAziz11/PS
/LinkedLists.py
2,882
3.921875
4
#21. Merge Two Sorted Lists def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: curr = root = ListNode() while l1 and l2: if l1.val>l2.val: curr.next = curr = ListNode(l2.val) l2 = l2.next else: curr.next = curr = ListNode(l1.val) l1 = l1.next curr.next = l1 or l2 return root.next ...
8d8318cb18927555be4e6910779306de632dda35
erik-sandoval/Algorithms
/recipe_batches/recipe_batches.py
1,395
4.0625
4
#!/usr/bin/python import math """ I need to create a function that takes in a recipe and the list of ingredients I have on hand. It needs to compare the recipe to the ingredients as well as their amounts set in as values. If an item is not found or a value does not have enough ingredients for one part, return 0. Else...
2ba24a00f94dbfa7bc49347d7054b57147b59e19
AMAN-SHARMA1/python_prog.
/t5.py
133
3.671875
4
t5=() while 1: item=input('enter your item') t5=t5+(item,) i=input('want to add more y/n') if i.lower()=='n': break print(t5)
c51c11414d7ca59eedeb0607b5df55ec4c238656
lewie0chewie/cti110
/P2HW1_DistanceTraveled_VenturaLuis.py
556
4
4
# CTI-110 # P2HW1 - Distance Traveled # Luis Ventura # 2/25/2018 # Assign value to the speed variable speed = 70 # Assign value to the time variable time1 = 6 time2 = 10 time3 = 15 # Get distance traveled distance1 = speed * time1 distance2 = speed * time2 distance3 = speed * time3 print ("Traveli...
b54ece015da6564cd0c5c839f67149774f0e0888
niteshsrivats/IEEE
/Python SIG/Classes/Class 6/regularexp.py
2,377
4.375
4
# Regular expressions: Sequence of characters that used for # searching and parsing strings # The regular expression library 're' should be imported before you use it import re # Metacharacters: characters with special meaning # '.' : Any character "b..d" # '*' : Zero or m...
61a02ababf85608615ad57dcf4d114226d5cbc67
niteshsrivats/IEEE
/Python SIG/Hackerrank/Fibonacci Series.py
588
4.09375
4
import time def recursive_fibonacci(n): if n == 0 or n == 1: return 1 return recursive_fibonacci(n-1) + recursive_fibonacci(n-2) def iterative_solution(n): first, second = 0, 1 for i in range(n): first, second = second, first + second print(second) n = int(input...
617f1bd946c1ed95d651e7895f97c5946b2d1280
niteshsrivats/IEEE
/Python SIG/Classes/Class 5/numpy.py
2,009
3.609375
4
import numpy as np # numpy includes the math library and string library # Every Object in numpy is an ndarray # Data types: # int8, int16, int32, int64 - Also represented as 'i1', 'i2', 'i4', 'i8' # uint8, uint16, uint32, uint64 - Also represented as 'u1', 'u2', 'u4', 'u8' # float16, float32, float64 - Also represent...
dd94841e37423c8906b6207accb60043b59ab309
animtel/leetcode-py-problems
/top_interview_questions/easy/7_reverse_integer.py
1,132
3.625
4
# 1. Two Sum problem: https://leetcode.com/problems/reverse-integer/ from typing import List class Solution: def reverse(self, x: int) -> int: max_size = (2**31)-1 min_size = -2**31 use_neg_sign = False if x < 0: use_neg_sign = True x *= -1 rev = ...
ccc33d37e50ac30abab0cfe943bf35f5d763cd57
caoxin1988/algo
/python/binary_tree/binary_search_tree.py
2,012
3.828125
4
import numpy as np class Node(object): def __init__(self, data): self.val = data self.left = None self.right = None class BinarySearchTree(object): def __init__(self): self.root = None def add_element(self, data): node = self.root if node is None: ...
8f731987a24cb13640d161d6eee668bdedfb165d
Nithesh24/Sharingan_animation-turtle
/main.py
1,627
3.734375
4
import turtle as t import time t.tracer(0, 0) screen = t.Screen() t.title("GenJutsu") def cir(): t.home() t.goto(0,-140) t.shape('blank') t.color('black','red') t.width(4) t.begin_fill() t.circle(200) t.end_fill() t.penup() t.left(90) t.forward(160) t.right(90) t.pe...
7b7bf882c2cf84cd0a3a3da65d852f0718fd403f
roshanpiu/core-python-getting-started
/27_classes_and_types.py
5,095
4.4375
4
# Classes - Define the structure and behavior of objects # Act as a template for creating new objects and controls object's initial state, attributes and methods # Classes can make simple problems unnecessarily complex # Python Let's you strike the right balance between python and classes # All types in python has a cl...
93ba38b836c845e8653086b6e319c92264d5cc5c
roshanpiu/core-python-getting-started
/10_modules.py
1,203
4.09375
4
from urllib.request import urlopen # Generally better to write functions that doesn't produce side effects def fetch_words(): story = urlopen('http://sixty-north.com/c/t.txt') story_words = [] for line in story: line_words = line.decode('utf8').split() for word in line_words: story_words.appe...
6463be85c78bf126dc35a47851845f2568ea313b
roshanpiu/core-python-getting-started
/21_sets.py
752
4.0625
4
# Sets are unordered collections for unique elements # Sets are mutable # Elements in a set must be immutable s1 = {1, 2, 3, 4} print(s1, type(s1)) # Can be used to remove duplicates s2 = set([1, 2, 3, 3]) print(list(s2)) # membership and non-membership 1 in s2 10 not in s2 s2.add(10) print(s2) s2.remove(10) print(...
7cf2b50bbdde704588a4d655cdf89f281661d2a8
alanvenneman/Practice
/Order.py
2,959
3.765625
4
class Order: def __init__(self): self.__order_number = "" self.__price = 0 self.__date = "" self.cart = [] def get_grand_total(self): for item in self.cart: self.cart.append(item) class Product(Order): def __init__(self, pc, pd, pp, co, si, ge): ...
77f86f9689a16c3a8d9438a24b5d13b67bd6c6f0
alanvenneman/Practice
/Final/pricelist.py
614
4.125
4
items = ["pen", "notebook", "charge", "scissors", "eraser", "backpack", "cap", "wallet"] price = [1.99, .5, 4.99, 2.99, .45, 9.99, 7.99, 12.99] pricelist = zip(items, price) for k, v in pricelist: print(k, v) cart = [] purchase = input("Enter the first item you would like to buy: ") cart.append(purchase) second =...
27921442e7ed231840677bbd46ce4c0fe6c5c87b
alanvenneman/Practice
/fan_stantiation.py
1,665
3.984375
4
from Fan import Fan blue_fan = Fan() ask_color = input("Please select a color for your fan\n" "1 - blue\n2 - red\n3 - black\n") if ask_color == 1: Fan.set_color(blue_fan, 'blue') elif ask_color == 2: Fan.set_color(blue_fan, 'red') elif ask_color == 3: Fan.set_color(blue_fan, 'black') else...
788ff4f2bddf0676e608edafccef508769654284
alanvenneman/Practice
/Shapes.py
4,796
4.53125
5
# coding=utf-8 """ Create a shape Class with one data member called side1 and two class methods called getArea and getPerimeter. They are empty methods or abstract methods. You can write empty methods as def getArea(self): pass Or def getArea(self): … Or def getArea(self): return Or def getArea(self...
0f48da996ee40df3672c6b8cfe34f92ffcbdecb6
Malcolm-Tompkins/ICS3U-Unit1-04-Python-Area_Perimeter
/Area_Perimeter.py
352
3.96875
4
#!/usr/bin/env/ Python3 # Created by Malcolm Tompkins # Created on April 26, 2021 #A program that calculates the area and perimeter of a 5 x 3 rectangle def main(): print("Dimensions of rectangle:") print("5cm x 3cm\n") print("Area is: {}cm^2".format(5*3)) print("Perimeter is: {}cm".format(2*5+3)) i...
4e7693939c6098c938fce30f8915f19b80dc2ecd
SteveWalsh1989/Coding_Problems
/Trees/bst_branch_sums.py
2,265
4.15625
4
""" Given a Trees, create function that returns a list of it’s branch sums ordered from leftmost branch sums to the rightmost branch sums __________________________________________________________________ 0 1 / \ 1 2 3 / \ / \ 2 4 5 6 7 / \ ...
a21b1e8a04826d5391cfa5eac83e0d4b12d22859
SteveWalsh1989/Coding_Problems
/Arrays/sock_merchant.py
634
4.3125
4
def check_socks(arr, length): """ checks for number of pairs of values within an array""" pairs = 0 # sort list arr.sort() i = 0 # iterate while i < (length - 1): # set values current = arr[i] next = arr[i + 1] # check if the same sock or different ...
373b36434f5625dc7422978c8ff2a7d33846bd7b
SteveWalsh1989/Coding_Problems
/Trees/bst_construction.py
6,226
3.671875
4
""" Write a Trees class that supports: - inserting new nodes - removing nodes - a node can be replaced by the left most node of it’s right sided child as it is smaller than any other node on it’s side and strictly greater than any node from the left hand child’s nodes from the original node - searching for values _...
3bec8b10583c167760f6c51962fa5adf39bd7f74
roher1727/ML2
/ApSupervisado/Clasificacion/ArbolClasificacion/arbol_clasificacion.py
5,225
3.640625
4
import pandas as pd import numpy as np #data=pd.read_csv('2012.csv') #Importamos los datos de un archivo CSV #data2=np.array(data).tolist() #Utilizando pandas nos retorna un DataFrame así que lo convertimos a una lista de listas training_data = data2 etiquetas = ["aprobadas", "cursadas", "sexo", "prom_bacho","prom_...