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
820fe96bf5999b72070a7752307bba89fe184022
nicolasportela/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
650
3.984375
4
#!/usr/bin/python3 """Defines a function to sum the perimeter""" def island_perimeter(grid): """Returns the perimeter""" perimeter = 0 for x in range(len(grid)): for y in range(len(grid[0])): if grid[x][y] == 1: if ((y == 0) or (grid[x][y-1] == 0)): ...
fc7c23db5c0df9282afcc3f96599d9f10bb0e0ed
GazizovK/MOMO_2020_Spring
/Assignment6/optimization.py
11,389
3.546875
4
from collections import defaultdict import numpy as np from time import time def make_history(history, labels, values): if history is not None: for label, value in zip(labels, values): if label == 'x' and value.size > 2: continue history[label].append(value) def s...
6d8f223d0f47bf1fe0c88b542da54e6cc3aaff15
engelsong/DataStructure
/02-线性结构2. 一元多项式求导 (25).py
895
3.546875
4
# coding=utf-8 class queue(object): def __init__(self): self.queue = [] self.front = -1 self.rear = -1 def isempty(self): isempty = 0 if len(self.queue) == 0: isempty = 1 return isempty def add(self, element): self.rear = self.rear + 1...
6dc4be9c7765ff497f61756989d714ee0fd004e5
engelsong/DataStructure
/04-树8. Complete Binary Search Tree (30).py
703
3.640625
4
from math import log def getroot(num): height = int(log(num + 1, 2)) NumInLast = num - 2 ** height + 1 NumOfLeft = 2 ** (height - 1) - 1 + min(NumInLast, 2 ** (height - 1)) return NumOfLeft Num = int(raw_input()) lst = map(int, raw_input().split()) lst.sort() res = [None for i in range(Num)] def s...
ffb75906be937634f172cb6ccb91117679d6850c
engelsong/DataStructure
/Travesal_BiTree.py
2,666
3.8125
4
class stack(object): def __init__(self, size): self.stack = [] self.top = -1 self.size = size def isempty(self): isempty = 0 if self.top == -1: isempty = 1 return isempty def isfull(self): isfull = 0 if self.top == self.size - ...
79b628c32d4b14eadd2977e20a58691a27b75451
rajshrivastava/LeetCode
/src/1222. Queens That Can Attack the King.py
726
3.5
4
class Solution: def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]: self.canAttack = [] #queens = set([ tuple(queen) for queen in queens]) def checkNext(x, y, i,j): if x+i<0 or x+i>7 or y+j<0 or y+j>7: return #i...
8e5c36d7add1f014c78eca8b3f3c70aa096240b9
rajshrivastava/LeetCode
/src/979. Distribute Coins in Binary Tree.py
716
3.640625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def distributeCoins(self, root: TreeNode) -> int: def count_Nodes_Coins(node = root): no...
9d0fa41307a587309a13fb00bc321e99b4fc8103
rajshrivastava/LeetCode
/src/92. Reverse Linked List II.py
935
3.875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: def reverse(node, count): prev = None curr = no...
66f34c737e361f4c4b0fe8bd0c7a7b8be1235fab
rajshrivastava/LeetCode
/src/706. Design HashMap.py
1,805
3.703125
4
class Bucket(): def __init__(self): self.bucket = [] def update(self, key, value): for i, k_v in enumerate(self.bucket): if k_v[0] == key: self.bucket[i] = (key, value) return self.bucket.append((key, value)) ...
5368c1c72141f2c65dc28018a9007b8465b308a4
neha52/Algorithms-and-Data-Structure
/Project1/algo2.py
2,928
4.21875
4
# -*- coding: utf-8 -*- array = [] #create an array. x = float (input ("Enter the value of X: ")) n = int(input("Enter the number of elements you want:")) if(n<2): #check if array more than two elements. print ("Enter valid number of elements!") else: print ('Enter numbers in array: ') #take i...
b460734e68a15b381cfa5dbe0ea2f30158ad1d4d
kaushikacharya/statement_verification_evidence_finding
/src/utils.py
5,522
4.125
4
#!/usr/bin/env python from math import floor import re from xml.dom import minidom import xml.etree.ElementTree as ET def is_number(s): """Identify whether input string is a number or not. References ---------- https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ...
c8f9733abcfe82e3feaefc39910acf8a53850099
devfort/wildlifenearyou
/zoo/ext/parsedatetime-0.8.6/parsedatetime/tests/TestComplexDateTimes.py
2,681
3.546875
4
#!/usr/bin/env python """ Test parsing of complex date and times """ import unittest, time, datetime import parsedatetime.parsedatetime as pt # a special compare function is used to allow us to ignore the seconds as # the running of the test could cross a minute boundary def _compareResults(result, check): ...
bfc1fed9a73fae8ba4dadd855e6491d646e853f6
yulbasik/study
/practice_2.py
526
3.890625
4
sm = 0 lr = 0 def largest(n): numb = None if numb is None or numb < n: numb = n return numb def smallest(n): small = None if small is None or small > n: small = n return small while True: int = raw_input('enter number:') if int == 'done': print'Done!' ...
4458c315692f45f9f03336f7983520fb25b7994d
yulbasik/study
/bv.py
169
3.984375
4
word = 'God will help me' index = len(word) - 1 length = len(word) while index < length and index != -1: letter = word[index] print letter index = index - 1
69f2d1632f8a6dfb8bc2608f19f489278541ac3f
isabellagrassucci/First-assignment
/5-math.py
947
3.609375
4
#math #1-polar coordinates import cmath z= complex(input()) distance= abs(z) a= cmath.phase(z) print (distance) print (a) #math #2-find angle mbc import math l1= int(input()) l2= int(input()) l= l1/l2 rad= math.atan(l) deg= str(round(math.degrees(rad))) print ((deg)+"°") #math #3-triangle quest ...
4ae9c001d49e8b3bfd2057a46bbcd8def73ab4b9
Gainsboroow/Path-Finder-Visualiser
/PathFinderVisualiser.py
11,707
3.515625
4
""" Path Finder Visualiser Created by Gainsboroow Github : https://github.com/Gainsboroow Github Repository : https://github.com/Gainsboroow/Path-Finder-Visualiser How to use : Left Click to move the starting point. Right Click to create walls. F5 to start the path finding. F4 to reset the Canvas. """ ...
e6699129478e545ec69361dd8137ec79a99896ac
wwojtyla64/Repozytorka
/takie tam/Małe-programy.py
1,894
3.859375
4
# WYPISYWANIE LICZB OD-DO-CO ILE ##pocz = int(input("Podaj poczatek: ")) ##kon = int(input("Podaj koniec: ")) ##co_ile = int(input("Podaj różnice miedzye elementami : ")) ## ##for i in range(pocz,kon,co_ile): ## print(i) # ODWRACANIE WPROWADZONEGO SLOWA(CZY PALINDROM?) ##message=input("Na...
b4715559816c5f2954712c962863153dfd4a8c5f
firesofmay/Algo_Class_I
/Programming Question - 1/Answer.py
2,063
3.796875
4
path = "/media/New Volume/Currently Reading/Algorithms Class - Stanford/Algo_Class_I/Programming Question - 1/IntegerArray.txt" #Taking the input from the file, splitting it on newline, we get last element as empty, hence we take all elements except that input = open(path).read().split("\r\n")[:-1] #Map the List of s...
7269e985628888920507e3e31b3de27541b63339
Shuaiyicao/leetcode-python
/7.py
298
3.65625
4
class Solution: # @return an integer def reverse(self, x): neg = False if x < 0: neg = True x = -x res = 0 while x != 0: res = res * 10 + x % 10 x /= 10 if neg: res = -res return res
75a3f17dada5ee58155b9d8a3ff2709a557977da
Shuaiyicao/leetcode-python
/61.py
739
3.765625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @param k, an integer # @return a ListNode def rotateRight(self, head, k): if head == None: return None ...
6e9b0ab70f0b8c34d0ba3c351cfe508ba8e9bf64
Shuaiyicao/leetcode-python
/99.py
1,475
3.6875
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param root, a tree node # @return a tree node def __init__(self): self.trouble = [] def dfs(self, node): ...
a5ad8298f1494b116bbe3cd43b121459ec087e28
Shuaiyicao/leetcode-python
/2.py
887
3.703125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @return a ListNode def addTwoNumbers(self, l1, l2): first = 0 base = 1 while l1 != None: first += l1.val * base ...
0adef141a3259fadac624f467c2c875e383d3be8
Shuaiyicao/leetcode-python
/34.py
1,157
3.71875
4
class Solution: # @param A, a list of integers # @param target, an integer to be searched # @return a list of length 2, [index1, index2] def lower_bound(self, A, target): first = 0 length = len(A) while length > 0: half = length / 2 middle = first...
bcf414808b27937a92f5a48479979e997cd37330
Shuaiyicao/leetcode-python
/151.py
301
3.6875
4
class Solution: # @param s, a string # @return a string def reverseWords(self, s): if s == '': return s a = s.split() words = [] first = True for item in reversed(a): words.append(item) return ' '.join(words)
8fd144e18a57b1a812204b3a56ee417871de6d9f
Shuaiyicao/leetcode-python
/101.py
1,195
3.890625
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param root, a tree node # @return a boolean def __init__(self): self.mapper = {} def dfs(self, node, depth): ...
baaa66d122de5a2aab6c753e3c964007d780738f
glotyuids/NeuroNetwork
/layer.py
6,084
3.625
4
# -*- coding:utf-8 -*- """ """ import random from neuron import Neuron MIN_NUM_OF_NEURONS = 2 MAX_NUM_OF_NEURONS = 30 NUM_OF_COLUMNS = 1 DEPTH = 3 PS = ' ' PST = PS * DEPTH class Layer(object): """layer implementation""" def __init__(self, num=None, next=None): super(Layer, sel...
6493e65da694193aedd6686deabeabc2d8d660c9
Adraxem/Instagram-Unfollower
/Instagram_Script.py
8,092
3.546875
4
import tkinter as tk import time from Instagram_class import followerr from selenium import webdriver import csv #Opening a tkinter window and assigning text messages to it and designating geometry w.r.t. pixels window = tk.Tk() window.title('Instagram Script') window.geometry('480x110') lab = tk.Label(window,text=...
13256d65493cae1d1ca7302450edad65d42b7f4a
Italoko/Perceptron-de-Rosenblatt
/Perceptron.py
2,082
3.546875
4
import numpy as np import copy class Perceptron: def __init__(self): self.weights = [] self.bias = 1 #Soma Ponderada def net_activation(self,input): return np.sum(np.multiply(input,self.weights)) #Função Sinal def net_propagation(self,y): if y > 0 : ...
0a21b7fd03c1ecda27b157a0e416e5149cddcdb0
dbwls89876/Ru
/BAEKJOON/Step/11. Bruteforce/1541_잃어버린 괄호.py
417
3.640625
4
s = input() b = "" c = 0 check = False result = 0 for a in s : if a == '+': c += int(b) b = "" continue elif a == '-': c += int(b) if(check): result -= c b = "" c = 0 continue else: result += c check = True b = "" c = 0 continue ...
679425af21b2ce17248f38b842ab6717df10d1a9
Langutang/Spark_Basics
/spark_basics_.py
2,906
4.1875
4
''' Spark is a platform for cluster computing. Spark lets you spread data and computations over clusters with multiple nodes (think of each node as a separate computer). Splitting up your data makes it easier to work with very large datasets because each node only works with a small amount of data. As each node works...
4b54f5ba41f51d9f4f8c45b378f879d5dbb7ea52
julianyraiol/questoes-engenharia-de-dados
/questao1.py
638
3.875
4
def median(array): size = len(array) if size % 2 == 1: middle = size // 2 return array[middle] else: middle = size // 2 return (array[middle - 1] + array[middle]) / 2 def read_file(): try: numbers = [] with open('in.txt', 'r') as file_in: co...
2d7035f94fd3140eaeb1ac3b566b13640bacf608
jimbex/python-gui
/gui/calculator/physics.py
5,511
3.578125
4
from tkinter import * from math import * jimbex = Tk() jimbex.title("Physiscs Calculator") #motion all kinds e = Entry(jimbex, width = 40) e.grid(row = 0, column = 0, columnspan = 4, pady = 5) def button_click(number): #e.delete(0, END) current = e.get() e.delete(0, END) e.insert(0, str(current) + str(numb...
c311677bfa32da175c0e9cd0085f73e77c332c8a
jimbex/python-gui
/gui/calculator/trig.py
2,174
3.578125
4
from tkinter import * from math import * root = Tk() root.title("Trig Calc") cos = Button(root, text = "cos", padx= 26, pady = 20, fg = "white", bg = "black") cos.grid(row = 1, column = 4) sin = Button(root, text = "sin", padx= 27.5, pady = 20, fg = "white", bg = "black") sin.grid(row = 2, column = 4) tan = Button(...
c758cf7f38b5b3c3d59027ccd873bc1e0357dce9
jimbex/python-gui
/gui/practice.py
655
3.78125
4
from tkinter import * root = Tk() root.title("jago") e = Entry(root, width = 50, bg = "grey", fg = "black") e.pack() #def myClick(): # l = Label(root, text = "Hello" + e.get()) # l.pack() def button_click(number): #e.delete(0, END) current = e.get() e.delete(0, END) e.insert(0, str(current) + str(number)) d...
2a0d90186273fbf99d44ea07c07e67a0452370ba
ghleokim/algorithm
/200913/k/test2.py
1,691
3.5625
4
def add_count(s_choice, count_orders): if count_orders.get(s_choice) is None: count_orders[s_choice] = 0 count_orders[s_choice] += 1 return def combination(order, c, choice, visited, count_orders): n = len(order) if len(choice) == c: add_count(''.join(choice), count_orders) ...
2f52c10c29c4c65cbc6579d8726b6abe640fd174
ghleokim/algorithm
/190903/solvingclub_0904_vetical.py
1,138
3.609375
4
""" 2 ABCDE abcde 01234 FGHIJ fghij AABCDD afzz 09121 a8EWg6 P5h3kx """ # from pprint import pprint # board = [[0 for _ in range(15)] for __ in range(5)] # for i in range(5): # for en, c in enumerate(input()): # board[i][en] = c # res = [] # for i in range(15): # for j in range(5): # if boa...
16b8d26e96d281642da0f5187e0651c7552d271b
sunsgneckq/CS-88
/homework/hw05/hw05.py
6,683
4.1875
4
def tree(root, branches=[]): for branch in branches: assert is_tree(branch), 'branches must be trees' return [root] + list(branches) def root(tree): return tree[0] def branches(tree): return tree[1:] def is_tree(tree): if type(tree) != list or len(tree) < 1: return False fo...
d07674970d95b0ab207982ccf70f771840a8486d
Liam1809/Classes
/Polymorphism.py
798
4.28125
4
a_list = [1, 18, 32, 12] a_dict = {'value': True} a_string = "Polymorphism is cool!" print(len(a_list)) print(len(a_dict)) print(len(a_string)) # The len() function will attempt to call a method named __len__() on your class. # This is one of the special methods known as a “dunder method” (for double underscore) w...
f54ab61de5b187d24e9c83cf7ea5c355898f7826
l-gonz/urjc-sat-final
/miscosas/feeds/feedparser.py
836
3.859375
4
from abc import ABC, abstractmethod class FeedParser(ABC): """ Base class to make parsers for the Feed and Item models """ @abstractmethod def __init__(self, stream): """ Parameters ---------- stream : HttpResponse The data to parse """ ...
65efc622284a9ee5d2328d827fc44982829df5de
pdhamdhere/misc
/psets.py
462
3.53125
4
import argparse import sys def pSet(s): powerSet = [] length = len(s) numSets = 1 << length for i in range(numSets): subSet = [] for j in range(length): if i & (1 << j): subSet.append(s[j]) print(i , subSet) powerSet.append(subSet) return...
373a79b79a4eaa734b8af8dd31cf112da0c81d6a
whispor/hahaha
/进程/队列.py
678
3.53125
4
from multiprocessing import Queue # 默认队列数量不限,指定为3个 q = Queue(3) # 向队列中插入 q.put("haha1") q.put("haha2") q.put("haha3") # put方法中可选参数 # q.put("haha4", block=True, timeout=1) # 如果队列已满,等待1s,如果还是满的就抛出队列已满的异常 # 判断当前队列是否已满 print("判断当前队列是否已满:", q.full()) if not q.full(): q.put("haha4", block=True, timeout=1) # print(q.g...
ca9e867dc5180b24b864fc1412d41cb70baafc52
whispor/hahaha
/线程/线程间共享全局变量.py
902
3.921875
4
from threading import Thread import time # num =10 # def test1(): # global num # for i in range(3): # num += 1 # print("执行test1函数num的值:", num) # def test2(): # print("执行test2函数的值:", num) # if __name__ == "__main__": # t1 = Thread(target=test1) # t2 = Thread(target=test2) # t1.star...
38133ff4b5b0c8b8ee037a8c8ffc471d275fca89
ssimper/game
/game/mg03.py
4,694
3.828125
4
import random class Labyrinth: def __init__(self): self.paths = set() #set of paths self.rand_pos = set() #set of items self.walls = set() #set of walls self.size_x = 0 #board width self.size_y = 0 #board height def fonction(self, the_file): """Function that reads the file, generate a set of paths and ...
94282eea9613d8968ad996d68122436497a893a7
UvinduPathirana/CurrencyConverter
/app.py
464
3.859375
4
ask = input("What do you want to convert? (Ex: lkr to usd or anything like this)") if ask == "lkr to usd": print("how much lkr?") ask1 = int(input("print")) b = ask1 * 193 print(b) elif ask == "lkr to euro": print("how much lkr?") ask1 = int(input("print")) b = ask1 * 235 ...
975b8f82a69e5a12405b96e313125407e9d57924
sharda2001/Dictionary_PYTHON
/ascending_ques_.py
83
3.5625
4
a={"g":4,"b":5,"k":3,"d":1,"a":8} b=list(a.items()) b.sort() dic=dict(b) print(dic)
b8d48e762771bcc2b6b2eccb9e06f495e9af27d8
sharda2001/Dictionary_PYTHON
/TABLE_dict_.py
208
3.515625
4
user=int(input("enter the number: ")) a=[] i=1 dic={} while i<=(user): b=[] j=1 a.append(i) while j<=10: c=i*j b.append(c) dic[i]=b j=j+1 i=i+1 print(dic)
21f30ec4f5beee611fb8158dc8d0254d43bb175c
AlexanderZ3/Python3-Exercise
/1.leetcode/reverse_num.py
271
3.9375
4
def reverse(x): rev = 0 while x!=0: last = x % 10 x /= 10 rev = rev*10 +last if rev>=(2**31) or rev<-(2**31): rev = 0 return rev print("enter an int num:") x = int(input('>>>')) print(reverse(x)) # 为什么输出老是0
d40649d94f47379c6d65161e755b1a18e1ff38ee
AlexanderZ3/Python3-Exercise
/Tutorial/20个常用工具的Python库.py
3,184
3.59375
4
''' 转载:http://www.python123.org/tutorials/58b41f2a28c8f30100bd41dc 读者们好。今天我将介绍20个属于我常用工具的Python库,我相信你看完之后也会觉得离不开它们。他们是: 1. Requests.Kenneth Reitz写的最富盛名的http库。每个Python程序员都应该有它。 ------ok 2. Scrapy.如果你从事爬虫相关的工作,那么这个库也是必不可少的。用过它之后你就不会再想用别的同类库了。 ___---- 3. wxPython....
2f380f7e0ead0e394a5a08b3e1731670b12c537a
AlexanderZ3/Python3-Exercise
/爬虫/教程之——循环.py
875
3.8125
4
# while 循环 ''' 循环使用 else 语句 在 python 中,while … else 在循环条件为 false 时执行 else 语句块: ''' count = 0 while count < 5: print (count, " is less than 5") count = count + 1 else: print (count, " is not less than 5") # 2. for循环 import math as m for letter in 'Python': # 第一个实例 print ('当前字母 :',...
acbe72d3a98bd2e8a55db00bcd1fb6904b2568e1
AlexanderZ3/Python3-Exercise
/1.leetcode/Reverse_int_Number.py
318
4.09375
4
def reverse(x): """ :type x: int :rtype: int """ rev = 0 while(x!= 0): last = x %10 x /= 10 rev = rev *10 + pop if rev>=(2**31) or rev <-(2**31): rev = 0 return rev print("please enter a int number:") x = int(input()) print(reverse(x))
430b590521146506046ccc37bdb85a99a3958d7f
Aditya7799/171IT204_Sem5
/Soft Computing/Lab 4/GeneticAlgorithm.py
3,054
3.59375
4
import random import NaiveBayes population_size=30 # Total number of chromosome chromLength=22 # Represents the number of attributes in the dataset except the class label CrossoverRate=0.25 MutationRate=0.10 #This function randomly initializes each chromosome def initializeChromosome(): C=[] for i in range(populati...
f527fd40093d862fe281b4cf417582c43197a89c
sunho-park/Notebook
/homework/p41~47.py
453
3.90625
4
''' def add(a, b): return a+b add(1, 2) try: add([1, 2]) except TypeError: print("add expects two inputs") add(*[1, 2]) def doubler(f): return 2*f(x) return g def f1(x): return x+1 g = doubler(f1) assert g(3) == 8, "(3 + 1)*2 should equal 8" assert g(-1) == 0, "(-1 + 1)*2 should equal 0" ''' d...
357cbeeeb1c3d52d554345202690dd1063556e89
sunho-park/Notebook
/textbook/8_pandas.py
12,068
3.875
4
# pandas을 pd로 import합니다 import pandas as pd # Series 데이터입니다 fruits = {"banana": 3, "orange": 2} print(pd.Series(fruits)) # Pandas를 pd로 import합니다 import pandas as pd # DataFrame 데이터입니다 data = {"fruits": ["apple", "orange", "banana", "strawberry", "kiwifruit"], "year": [2001, 2002, 2001, 2008, 2006], "...
c34e39fd54c2f48c3e928cbfc93725b7a8e52206
viveksai95/BasicPython
/demerit.py
93
3.5625
4
#demerit a = int(input()) if a <= 70: print("Ok") else: b = ((a-70)/5) print(b)
213f778161826cc0f8dc49782c269cdd1d10c1b7
viveksai95/BasicPython
/minmax.py
169
4.125
4
#minmax list_a = [1,2,3,4,5] least = list_a[0] for i in list_a: #print(i) if i < least: least = i #print(min(list_a)) #print(max(list_a)) print(least)
bf8905fbdc1e621f5f9ceacd59fac49ddf4643d3
chyld/pythonista
/complex.py
1,865
3.5
4
import math class Complex: def __init__(self, real,imag): self.real = real self.imag = imag def __add__(self, other): r = self.real + other.real i = self.imag + other.imag return Complex(r, i) def __sub__(self, other): r = self.real - other.real i =...
64d623f45656d59be34a1343caadca9bc62dfe3e
chyld/pythonista
/grades.py
198
3.5625
4
n = int(input()) people = {} for person in range(n): person, g1, g2, g3 = input().split() people[person] = (float(g1) + float(g2) + float(g3)) / 3 print("{0:.2f}".format(people[input()]))
9d3b1a09c4718c33d0f5eeafc226f4d0a96dd09d
DiamaiD/Studium
/Semester_1/programm1/Klausurvorbereitung/probeklausur WS2019_2020/Aufgabenstellungen und Lösungen/ex_keywords.py
747
3.8125
4
###################################################################### ## visible code import math import random import string ###################################################################### ## student code def find_index(start: int, c: str, s: str): for i in range(start, len(s)): if s[i] == c: ...
85d8e3f1425ea25840ae2a1175837a6d0f50a040
DiamaiD/Studium
/Semester_1/programm1/Klausurvorbereitung/probeklausur WS2019_2020/Aufgabenstellungen und Lösungen/ex_unique.py
513
3.828125
4
###################################################################### ## visible code import math import random import string ###################################################################### ## student code def unique(xs: list) -> list: '''Takes a sorted list of integers `xs` and returns a list that conta...
f74f982f3e19719fd9e28e3732bf4ffa4bec48fd
DiamaiD/Studium
/Semester_1/programm1/Übungsblätter/info1/.svn/pristine/f7/f74f982f3e19719fd9e28e3732bf4ffa4bec48fd.svn-base
351
3.703125
4
#!/usr/bin/python3 def primes(n: int) -> list: primzahlen = [] for x in range(n): x += 1 notprime = 0 for prime in primzahlen: if (x % prime) == 0 and prime != 1: notprime = 1 break if notprime == 0 and x != 1: primzahlen.a...
d3fa653f8029265850b04a95897eada7ae38acc2
DiamaiD/Studium
/Semester_1/programm1/Klausurvorbereitung/probeklausur WS2019_2020/ex_classes.py
1,351
3.71875
4
#!/usr/bin/python class Ingredient(): def __init__(self, name: str, preis: int, vegetarisch: bool): self.name = name self.preis = preis self.vegetarisch = vegetarisch class Recipe(): def __init__(self, name: str, zutaten: list): self.name = name self.zutaten = zutaten ...
f92fbdcd25807e043750af3ac11c0639a08b6a4e
DiamaiD/Studium
/Semester_2/Algorithmen/vg112/.svn/pristine/ae/ae8450253a7189b646df51906f3e2aa9f4b37c6c.svn-base
2,030
4
4
""" Class representing a directed graph as adjacency list Copyright 2020, University of Freiburg Philipp Schneider <philipp.schneider@cs.uni-freiburg.de> """ class AdjacencyMatrix: ''' represents a weighted graph as adjacency matrix where the entry i,j in the matrix corresponds to the we...
b98540ca1e8cdd89ee9041794ccb8e7725ac88d5
DiamaiD/Studium
/Semester_2/Algorithmen/vg112/uebungsblatt-04/HashTable.py
3,555
3.8125
4
""" Hash table with open addressing. Copyright 2020, University of Freiburg. Philipp Schneider <philipp.schneider@cs.uni-freiburg.de> """ import math import random import time class HashTable: ''' Hash table open adressing. ''' def __init__(self, size, lin_prob=True): ''' Constructo...
9307e1c587b3c03a5542766b0c3987522fbf21f2
DiamaiD/Studium
/Semester_1/programm1/Übungsblätter/info1/.svn/pristine/82/82f00db5963926adda415355fd6896ff17086198.svn-base
779
4.03125
4
#!/usr/bin/python3 def flatten(xs: list) -> list: """a function to flatten a list to its sub components""" flatlist = [] for i in xs: if isinstance(i, list): flatlist += flatten(i) else: flatlist += [i] return flatlist def test_flaten_1(): """test recursion ...
98343ff127188d15a334145328da1da8f9c45156
aaronabraham311/CSSI-Coursera
/week4_divide_and_conquer/majority_element.py
1,263
3.96875
4
# Uses python3 import sys def get_majority_element(a, left, right): # Base cases (either array has size 1 or 2) if left == right: return -1 if left + 1 == right: return a[left] # Recursive calls to get majority element in left and right subarrays left_majority_element = get_majori...
d53ec8b7c52938b5a4f57c273cca46e1b83c69f4
jorika/Python-CodeAcademy
/162-For your hobbies.py
126
3.828125
4
hobbies = [] # Add your code below! for user in range(3): new = raw_input('Select a hobbie') hobbies.append(new)
23883b944a433a830773f4cc133b1da89425ea4e
jay27111995/Computer-vision-journal
/2_resize_and_save.py
775
3.921875
4
import cv2 img = cv2.imread('first.png', cv2.IMREAD_GRAYSCALE) # get the dimensions of the image x, y = img.shape # Did you notice that now img is an object ? # what does imread return ? In what format ? print("The dimensions of the image are %d and %d" %(x, y)) # Now lets resize our image img2 = cv2.resize(img...
4b5b01bd033f6ffc25a91e51be15ee8f2a80237d
dovtov/Python
/Reverse_Integer.py
475
3.75
4
class Solution: def reverse(self, x): """ :type x: int :rtype: int """ if x > 2**31 or x < -2**31: return 0 if x >= 0: sign = 1 else: sign = -1 x *= -1 reversed = 0 while (x/10) > 0 : ...
2119d927dfc57b87873f089b801b84d690290e60
yfalexbh/orie5270
/homework3_graph/graph.py
4,100
4.28125
4
import heapq def negative_cycle(name_txt_file): """ Find a negative cycle in the graph using Bellman-Ford algorithm param name_txt_file: the name of the text file in string return: if there is a negative cycle in the graph, a boolean """ d = _read_txt_helper(name_txt_file) # create a synth...
7908d01dec7abc76935cac61a1ea35f9c7bc5c51
blaufer/Monopoly-Statistics
/modules/monopoly_boards.py
2,182
3.75
4
from operator import itemgetter def monopoly_board(): # Create the board as a list of lists and board_dict is used for # output board = [[i,0] for i in range(0,40)] spaces = ['Go','Mediterranean Ave','Community Chest', 'Baltic Avenue','Income Tax','Reading Railroad', 'Oriental Ave','Ch...
bc4f0821b318bb76855bcbaafdbf90b1b9de670a
sofiia-tesliuk/Loon_HashCode_2015
/scripts/satelite.py
4,548
3.671875
4
import random class Satellite: def __init__(self, loon, target_cell): self.loon = loon self.r = loon.start_cell_r self.c = loon.start_cell_c self.altitude = 0 self.target_cell = target_cell def launch(self): if self.target_cell is not None: self.alt...
2ab337712c44f9dd7fffb98548c8e3a7d0cea93f
tillyoswellwheeler/python-learning
/multi-question_app/app.py
929
4.15625
4
#-------------------------------------------- # Python Learning -- Multi-Question Class App #-------------------------------------------- from Question import Question #------------------------------------- # Creating Question Object and App question_prompts = [ "What colour are apples?\n(a) Red/Green\n(b) Purple...
0443bd0c80489e9a063851c62583a9fb7956bc4a
tillyoswellwheeler/python-learning
/2d-lists_&_nested-loops.py
625
4.40625
4
#----------------------------------------- # Python Learning -- 2D & Nested Loops #----------------------------------------- #----------------------------------------- # Creating a 2D array number_grid = [ [1, 3, 4], [3, 4, 5], [3, 6, 7], [2] ] #----------------------------------------- # Accessing r...
69e4a76a2265aa14a5efaaef542c8335fdd2a3e1
tillyoswellwheeler/python-learning
/inheritance.py
607
4.4375
4
#------------------------------------- # Python Learning -- Inheritance #------------------------------------- #------------------------------------- # class Chef: def make_chicken(self): print("Chef makes chicken") def make_ham(self): print("Chef makes ham") def make_special_dish(self)...
d16589bfe23eaa72097e6fd6ea740bc4008a9415
tillyoswellwheeler/python-learning
/LPTHW/Ex15.py
1,123
4.40625
4
# ------------------------------------ # LPTHW -- Ex15. Reading Files # ------------------------------------ from sys import argv # this means when you run the python, you need to run it with the name of the python command # and the file you want to read in script, filename = argv # This opens the file and assigns ...
6ce643ebb78b3c690a942a3404d2aaee5be48243
tillyoswellwheeler/python-learning
/LPTHW/Ex5.py
886
4.03125
4
# ------------------------------------ # LPTHW -- Ex5. More Variables and Printing # ------------------------------------ my_name = 'TOW' my_age = 300 my_height = 250 my_weight = 180 my_eyes = 'blue' my_teeth = 'Yellow' my_hair = 'Purple' print(f"Let's talk about {my_name}.") print(f"He's {my_height} inches tall.") ...
3b53ded3529182c474956c618b39591739102b00
Kirros/codeeval
/src/primepal.py
397
3.671875
4
import math __author__ = 'Kirros' MAX = 1000 def is_prime(n): if n < 2: return False for f in range(2, int(math.sqrt(n)) + 1): if n % f == 0: return False return True def is_palindrome(n): string = str(n) return string == string[::-1] for i in reversed(range(1, MA...
f530464d5feebd4aaa6079af857d276d9255726c
kleitus448/GameBalls
/base_class.py
1,337
3.65625
4
import random import pygame class Ball(): def __init__(self,pos,speed,color): #self.Square = pygame.Rect(*pos,random.randrange(59,60),random.randrange(59,60)) self.rad = random.randint(20,30) self.speed = speed self.pos = pos self.color = color self.SCarry = False def draw(self, screen): pyga...
e6a3d195d45d1c5f058db311209f735f5998ff42
et2409-PYTHON/Intro-to-Programming--Activity-10.6
/ioVarsLab.py
930
4.0625
4
age = 48 name = "Eyvette Thompson" gpa = 3.5 print "I am {} years old".format(age) print "My name is {}".format(name) print "In school my GPA was {}".format(gpa) operand1 = 27.882 operand2 = 258.03 print "{} + {} = {}".format(operand1,operand2,operand1+operand2) print "{} - {} = {}".format(operand1,opera...
90141e449b496856b47aef6deac1b910de73e842
joebentley/rpg
/battle.py
2,967
3.78125
4
import os import sys import random import time # Fight scene between player and enemy! # # If player wins, delete the enemy from the room. # Calculate damage from given attacker and defender def calculate_damage(attacker, defender): armor = 0 # Does defender have armor? if hasattr(defender, 'armor') and defe...
667b8d8309a3d89c1ef2b5f8456381ba89cf13d2
emmanuel-odonkor/Python-Programming-Project
/PYTHON_FORMULAS3.py
15,080
4.1875
4
def areaofrectangle(length,breadth): L = length B = breadth a = L * B print("THE AREA OF A THE RACTANGLE WITH LENGTH OF",L,"AND BREADTH OF",B,"IS",round(a,4)) def perimeterofrectangle(length,breadth): L = length B = breadth P = (2 * L) + (2 * B) print("THE PERIMETER OF THE RECTANGLE WJTH LENGTH",L,"A...
3b7cb432a98f5024f313ea5038a1a682c5096983
RealLitb/projecteuler
/problem7.py
350
3.84375
4
import math from itertools import count def isprime(n): if n % 2 == 0: return False for x in count(start = 3, step = 2): if x * x > n: return True if n % x == 0: return False for i, p in enumerate(filter(isprime, count())): if i == 10000: print ("100...
d8f3eec97a25b8d8025c17840012680e29e74cb2
RealLitb/projecteuler
/problem19.py
516
3.609375
4
days = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def sundays(y, mod7): num_sundays = 0 leap_offset = y % 4 == 0 for d in days: if mod7 == 0: num_sundays += 1 mod7 = (mod7 + d + (leap_offset if d == 28 else 0)) % 7 return num_sundays, mod7 num_sundays_global = 0 mod...
c8fe777997267fc5e4823bfc63dedbc86ace73f9
PressSergo/Microservices_Elevator_Cell
/Docker/Python/code/Example/Example/algorims/analysis/LinearCell.py
204
3.546875
4
import matplotlib.pyplot as plt import random X1 = [random.random() for i in range(0,20)] Y1 = [random.random()+2*i for i in X1] plt.scatter(X1, Y1) plt.grid() plt.xlabel("X") plt.ylabel("Y") plt.show()
251e9e883c6cab7381167ee7aefc6f1d42fca71d
malvat/AlgorithmsAndDataStructure
/Problems/Coin Change/BruteForce.py
364
4.0625
4
""" Finding number of coins (of certain denominations) that add up to a given amount of money. @wikipedia """ import sys d = [1, 2, 5] def coin_change(amount): if amount == 0: return 0 res = sys.maxsize for i in d: if amount >= i: res = min(res, coin_change(amount - i) ...
0bc1e75b9b72d3dc658993e020e7067a3ad5e468
sriram161/Data-structures
/PriorityQueue/priorityqueue.py
1,580
4.21875
4
""" Priotity Queue is an abstract data structure. Logic: ------- Priority queue expects some sort of order in the data that is feed to it. """ import random class PriorityQueue(object): def __init__(self, capacity): self.capacity = capacity self.pq = [] def push(self, value...
7a7668d66c6c336c2a3781d568403261fa00a75e
sriram161/Data-structures
/sort/selection_sort.py
937
3.828125
4
""" Logic: ------ NOTE ----- Space Complexity: ----------------- Time Complexity: ----------------- """ def min_index(a): min_idx = 0 for i in range(len(a)): if a[i] < a[min_idx]: min_idx = i return min_idx def selection_sort(a): """ Iterative approach. """ n = len(a) f...
e5ff9962f378009f45335657e72b049ccf3a978f
OrShay/PARTIA-Backend-Python
/participant/participant.py
1,011
3.75
4
class Participant: """ This class represent a participant of the event """ def __init__(self, name: str, food_preference, allergies, glass_preference, chaser_preference): self._username = name # as shown in partia_app self._food_preference = food_preference self._allergies = a...
3cbd3d784ac465f5f5e6d728bf9a32d403bc2fa2
jiawei2020/python-case
/AnalysisCovidFinal.py
1,147
3.734375
4
# import modules import pandas as pd from matplotlib import pyplot as plt # Task 1: read the data # Read data/coronavirus_dataset.csv into virus_cases_worldwide virus_cases_worldwide = pd.read_csv("data/coronavirus_dataset.csv") # See the result print(virus_cases_worldwide) # Task 2: get the confirmed case...
bde558a5809abdf639e9e0b3472316c0645755d5
ellenmacpherson/module_3
/ch05_externaltests/calculator_tests.py
724
3.6875
4
import unittest from calculator import Calculator class calculator_testing(unittest.TestCase): def setUp(self): self.calc = Calculator() def test__add(self): result = self.calc.add(2, 2) self.assertEqual(result, 4) def test__subtract(self): result = self.calc.subtract(10,...
b8a94e1676e994b371089e31711de3a9b9ab162b
koassika/Projet
/minmax.py
1,524
3.734375
4
#!/bin/env python3 import sys , getliste """ Soit L le type liste dont les éléments sont soit tous de type int, soit tous de type L. Par exemple, l = [ [1,2], [ [2,3,4], [5,4,3,2], [[3,1],[2]]], [0,9] ] est de type L. Ce programme est appelé avec une liste de type L sur la ligne de commande, et s...
bb1ec36d13f51edb2867f544a69d0976b0a23e20
karthikapresannan/karthikapresannan
/functions/pattern.py
119
3.546875
4
row=4 for num in range(row+1): for i in range(num): print(num,end="") print("") # 1 # 22 # 333 # 4444
0504e228dd8834e44a06fdcb11bd0df58e144267
karthikapresannan/karthikapresannan
/object_oriented_programs/polymorphsim/operator_overloading.py
523
3.78125
4
class book: def __init__(self,pages): self.pages=pages def __add__(self, other): return book(self.pages + other.pages) #######obj.pages(100)+obj1.pages(200) def __sub__(self, other): return book(self.pages - other.pages) ...
81a066ef247cc6377113bbe744fb6ea7f7c2f0e8
karthikapresannan/karthikapresannan
/object_oriented_programs/oops.py
300
3.65625
4
class person: def set_person(self,age,name): self.name=name self.age =age def set_person(self, age, name): self.name = name self.age = age obj=person() obj.set_person(25,"ram") obj.print_person() obj1=person() obj1.set_person(26,"varun") obj1.print_person()
1d6c29c0fd2c836701fd9de268d1141ff606dc47
karthikapresannan/karthikapresannan
/python_database/@mysub,div.py
456
3.578125
4
def my_sub(func): def innerfunc(num1,num2): if(num1<num2): num1,num2=num2,num1 return func(num1,num2) return innerfunc @my_sub def sub(num1,num2): return num1-num2 print(sub(10,20)) def my_div(func): def innerfunc(num1,num2): if(num1<num2): num1,num...
3ad9e14ba5f53e1ececf3afd1b32e1b12c6fb3a5
karthikapresannan/karthikapresannan
/object_oriented_programs/inheritance.py
188
3.640625
4
class parent: def phone(self): print("inside parents phone method") class Child(parent): #single inheritance pass ch=Child() ch.phone() #lst=list() #lst.append()
cfbb7a84d30cc05f9aa919233f99524b076fe0aa
VishmayaGithub/classes
/empty/hello.py
141
4.125
4
age = int(input("enter a value")) if(age>18): print("adult") elif(age<18): print("Child") else: print("baby")
4a85c568a7e7f64ff0690515a5e2ef71c5dd2af4
griffs37/CA_318
/python/8163.sol.py
451
3.6875
4
def make_adjacency_matrix(edge_list): adjacency_matrix = [] num = 0 pass for lists in edge_list: for item in lists: if ord(item) > num: if (ord(item)-64) > num: num = ord(item)-64 for lists in edge_list: adjacency = [] i = 1 for i in range(num): letter = chr(ord("A") + i) if letter in li...
98082b9e10c1250be6b115aa7278315a0a4b9cdc
griffs37/CA_318
/python/8311.sol.py
1,013
4.15625
4
def make_sum(total, coins): # Total is the sum that you have to make and the coins list contains the values of the coins. # The coins will be sorted in descending order. # Place your code here greedy_coin_list = [0] * len(coins) # We create a list of zeros the same length as the coins list we read in i = 0...
509c09651c05b6e5c8529581a4000169160e3a95
Deline123/MyProject
/fractelDragon.py
555
3.65625
4
import turtle turtle.hideturtle() turtle.tracer(0) turtle.penup() turtle.setpos(-100, -150) turtle.pendown() axiom = "FX" axmTemp = "" itr = 15 dl = 1.2 angl = 90 translate = {"+":"+", "-":"-", "F":"F", "X":"X+YF+", "Y":"-FX-Y"} for k in range(itr): for ch in axiom: axmTemp += translate[ch] axiom = axmTemp a...