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
112fcda1d6f018e0cd3e0fd88447ff6c008e9f72
shinrain/leetcode-python
/code/WildcardMatching.py
687
3.515625
4
class Solution: # @param s, an input string # @param p, a pattern string # @return a boolean def isMatch(self, s, p): n=len(p) if n==0: return len(s)==0 [ss, star,i,j]=[0,-1,0,0] while i<len(s): if j<n and (s[i]==p[j] or p[j]=='?'): ...
c923bd682893453bc5ccd1b88ea86f75637584c6
shinrain/leetcode-python
/code/MergekSortedLists.py
1,342
3.828125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param a list of ListNode # @return a ListNode def mergeKLists(self, lists): n=len(lists) if n==0: return None if n==1:...
7621c5aaaf43b9ed199f22dc3aaa10a78ff55801
shinrain/leetcode-python
/code/IntersectionofTwoLinkedLists.py
995
3.703125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param two ListNodes # @return the intersected ListNode def getIntersectionNode(self, headA, headB): if headA==None or headB==None: ret...
f6dc26b4cd5ed6c73c6b6b6b20595def397c7310
shinrain/leetcode-python
/code/SimplifyPath.py
343
3.671875
4
class Solution: # @param path, a string # @return a string def simplifyPath(self, path): w=path.strip().split("/") st=[] for s in w: if s=="..": if len(st)!=0: st.pop() elif s=="": pass elif s!=".": st.append(s) if len(st)==0: return "/" re="" while len(st)!=0: re="/"+st...
542da8ba9391eb804892dadbd587cef0b2ad6eaf
shinrain/leetcode-python
/code/RegularExpressionMatching.py
390
3.59375
4
class Solution: # @return a boolean def isMatch(self, s, p): if len(p)==0: return len(s)==0 if len(p)>1 and p[1]=="*": while len(s)>0 and (s[0]==p[0] or p[0]=="."): if self.isMatch(s,p[2::]): return True s=s[1::] return self.isMatch(s,p[2::]) else: if len(s)>0 and (s[0]==p[0] or p[0]=="...
fbc85b614c000f49fc611003b141fef46e3fade3
shinrain/leetcode-python
/code/SwapNodesinPairs.py
631
3.78125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param a ListNode # @return a ListNode def swapPairs(self, head): if head is None or head.next is None: return head d=ListNode(...
fc05047221f091fd84a7282116b8001f2565e598
shinrain/leetcode-python
/code/WordLadder.py
833
3.59375
4
class Solution: # @param start, a string # @param end, a string # @param dict, a set of string # @return an integer def ladderLength(self, start, end, dict): if start==end: return 1 count = 1 [a,b] =[set([start]), set([end])] d1=copy.deepcopy(dict) d2=copy.deepcopy(dict) while len(a)!=0 and len(b)!=...
9e599533e252d2ada147494582f73aae1e0727e5
shinrain/leetcode-python
/code/ConvertSortedListtoBinarySearchTree.py
572
3.59375
4
class Solution: # @param head, a list node # @return a tree node def helper(self, l, r): if l>r: return None if l==r: root= TreeNode(self.list.val) self.list=self.list.next else: mid=l+(r-l)/2 left=self.helper(l,mid-1) root=TreeNode(self.list.val) root.left=left self.list=self.lis...
1e9d80d8eb694f99eed2cb6da78a189d5be37a2f
tsubasa283paris/OneNightJinroBot
/management/JobManager.py
1,463
3.734375
4
class Job(): def __init__(self, jobname, iamwolf, iamteamwolf): self.jobname = jobname self.iamwolf = iamwolf self.iamteamwolf = iamteamwolf class JobManager(): def __init__(self): # 役職を追加する場合ここに足してください。特殊な行動を持つ場合いろいろ書き換えてください…。 self.jobs = [] self.jobs.append(Jo...
9297aa3e1a270a47a6e5f0f5edf14416e3cc58d3
apoorvpandey0/Graphs-Python
/Lecture-11 bridgeFinder.py
1,651
3.59375
4
# Bridge finding algorithm g = { 0:[1,9], 1:[0,8], 2:[3], 3:[2,7,4,5], 4:[3], 5:[3,6], 6:[5,7], 7:[8,10,6,3], 8:[1,9,7], 9:[0,8], 10:[7,11], 11:[10] } id = 0 # The always incrementing counter N = len(g) ids = [0 for i in range(N)] visited...
1b176c3696f00b8ab2bf9dfcd6cbd61a7542a0b0
apoorvpandey0/Graphs-Python
/islandsFinder.py
591
3.75
4
a=[ [1,1,1,0,0,1,1], [1,0,1,0,0,0,0], [1,0,1,0,0,1,0], [1,1,1,0,0,0,1] ] print(a) rows = len(a) cols = len(a[0]) islands = 0 def traverse(x,y): if x<0 or y<0 or x>rows-1 or y>cols-1 : #Boundary Conditions return a[x][y] = 2 #i.e. we have visited the element if x<rows-1 and a[x+1][y]==1 : #Down traverse(...
297265b6b28200ebfb3ab78a66d54316a7b0eb3f
alanhernandez74/proyecto
/ejercicios.4
171
3.546875
4
#!/usr/bin/env python #_*_ coding: utf_8 _*_ def max(n1,n2): if n1<n2: print n2 elif n2<n1: print n1 else: print"son iguales"
5001d593ca8a9d95f4708e7c0b22d7cfc5004636
greatteacher/lesson2part1
/answers3.py
608
3.578125
4
Voc_Ella = {'как дела?': 'хорошо!', 'что делаешь?': 'иду к бабушке', 'ты человек?': 'как посмотреть', 'где ты живешь?': 'в лесу', 'как тебя зовут?': 'Красная шапочка', 'что ты несешь?': 'Пирожки', 'why do java developers wear glasses?': 'because they don"t C#'} def ask_user (): while True: user_say = (in...
e8f89995be06d4778c15c9050e6c9d86c30a799d
greatteacher/lesson2part1
/lesson2list3school.py
1,021
3.546875
4
School = [ {'school_class':'4a', 'Marks': [5,5,5,5,5,5,4,4,5,5]}, {'school_class':'4b', 'Marks': [4,4,4,4,5,4]}, {'school_class':'4c', 'Marks': [3,3,3,3,3,3,2]}, {'school_class':'4г', 'Marks': [2,3,2,2,2,2,2,2]} ] Cur_class_students =0 Student_sum = 0 School_score =0 for element in School: Stud...
56e854cbb153f7989f298d236da1af61a7ccb9c8
sheikh210/LearnPython
/data_structures/dictionaries/dictionaries_practice_2.py
919
4
4
computer_parts = {"1": "computer", "2": "monitor", "3": "keyboard", "4": "mouse", "5": "hdmi cable", "6": "dvd drive", } current_choice = None computer_parts_dict = {} while current_choice != "0": if curren...
e857a43a220a5e158610933d8f478046e6559ae8
sheikh210/LearnPython
/functions/challenge_palindrome_sentence.py
345
4.1875
4
def is_palindrome(string: str) -> bool: return string[::-1].casefold() == string.casefold() def is_sentence_palindrome(sentence: str) -> bool: string = "" for char in sentence: if char.isalnum(): string += char return is_palindrome(string) print(is_sentence_palindrome("Was it a...
e4e6df7f0136d45eaa671d592b74fe4767774cfe
sheikh210/LearnPython
/functions/challenge_fizz_buzz.py
1,549
4.3125
4
# Write a function that returns the next answer in a game of Fizz Buzz # You start counting, in turn. If the number is divisible by 3, you say "fizz" instead of the number # If the number if divisible by 5, you say "buzz" instead of the number # If the number is divisible by 3 & 5, you say "fizz buzz" instead of the nu...
7f5ade077d195863562b3d90d89cf9bebd1d715b
sheikh210/LearnPython
/data_structures/sets/sets_intro.py
1,506
4.25
4
# Sets are unordered and DO NOT contain any duplicate values - Think of sets like a collection of dictionary keys # Elements in a set MUST be immutable (hashable) # DEFINING A SET # ********************************************************************************************************************** # Method 1 - Decla...
be2ee3849059461c8ab75c919f0f7258ef839ddb
sheikh210/LearnPython
/randomGenerator.py
829
3.953125
4
import random lower_limit = 1 upper_limit = 10 answer = random.randint(lower_limit, upper_limit) print("GUESS A NUMBER BETWEEN {}-{}: ".format(lower_limit, upper_limit)) numOfGuesses = 1 guess = 0 while guess != answer: guess = int(input("Guess: ")) if guess < lower_limit or guess > upper_limit: pri...
f65ef5cbe41c4dc99f5cfcfb85722b7a0e6b773c
sheikh210/LearnPython
/data_structures/lists/challenge_spam.py
1,441
4
4
# Write code to print out all the meals, but with spam removed # You can choose which approach to use: # 1. Remove spam from each list, then print the list # 2. Print out the items in each list, as long as it's not spam # BONUS: Write both sets of code menu = [ ["egg", "bacon"], ["egg", "sausage", "bacon"]...
3fe345a031d676a89e6b6f7df7d3220661422ded
sheikh210/LearnPython
/modules_and_functions/time_and_datetime/time_elapsed.py
463
3.828125
4
import time # from time import time as my_timer from time import perf_counter as my_timer import random input("Press 'ENTER' to start") wait_time = random.randint(1, 6) time.sleep(wait_time) start_time = my_timer() input("Press 'ENTER' to stop") end_time = my_timer() print("Started at " + time.strftime("%X", time....
3a4c87d32c166a0cc1b696e2bb77f0daf3767e26
sheikh210/LearnPython
/general/unpacking.py
374
3.890625
4
a = b = c = d = e = f = 12 print(c) # The values on the right side of the expression ARE a tuple x, y, z = 1, 2, 82 print(x) print(y) print(z) print() print("Unpacking a tuple") data = 1, 2, 82 # data represent a tuple x, y, z = data print(x) print(y) print(z) print() print("Unpacking a list") data_list = [12, 1...
fa8f9774d5fa2fef7ddb629ef970f17161636a48
tevanc14/TextJustifier
/text_justifier.py
1,383
3.734375
4
import os from line_splitter import LineSplitter from space_distributor import SpaceDistributor class TextJustifier: """Justifies input.txt with output in output.txt""" def __init__(self): self.input_text = self.read_input() self.output_text = [] def read_input(self): """Reads i...
9d0b54d49d1479e7a6531c5280fe35395f70c0a9
Shabarish1346/PythonLearn
/Week 8/maxInListRecusrsive.py
232
3.5
4
def max_element(input_list) : if(len(input_list)==1): return input_list[0] maxNum = max_element(input_list[1:]) if(maxNum < input_list[0]): maxNum = input_list[0] return maxNum
28bcdc51a1f457bcd88984b8277e9e86a491044a
Shabarish1346/PythonLearn
/Week 2/SittingFriendsCircle.py
235
3.609375
4
emp1=int(input()) emp2=int(input()) emp3=int(input()) emp4=int(input()) emp5=int(input()) if((emp1+emp2)%2==0 and (emp3+emp2)%2==0 and (emp3+emp4)%2==0 and (emp4+emp5)%2==0 and (emp5+emp1)%2==0): print("YES") else: print("NO")
3972020da2af483a0b7078cc531d4696dd318c41
andrii-myk/lection_4
/caesar.py
746
4.0625
4
def encrypt(text, offset): result = "" for letter in text: if (letter >= 'a' and letter <= 'z'): s = (ord(letter) - ord('a') + offset) % 26 + ord('a') result += chr(s) else: s = (ord(letter) - ord('A') + offset) % 26 + ord('A') result += chr(s) ...
db830245a33c5fad9275dda33d1d866886347806
294150302hxq/python_learn
/leetcode/215_kthlargest_in_array.py
1,014
3.890625
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/12/27 @desc: """ class Solution(object): def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ self.quick_sort(nums, 0, len(nums) - 1, k...
195461cccf36a5442a85cb1b616daf3ac85b5588
294150302hxq/python_learn
/leetcode/rm_nth_from_end.py
930
3.9375
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/5/19 @desc: """ class ListNode(object): def __init__(self, x): self.val = x self.next = None def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode ...
f24b4667a34d625af419c1089153646650c6a281
294150302hxq/python_learn
/leetcode/844_backspace_string_compare.py
885
3.75
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/8/4 @desc: """ class Solution(object): def backspaceCompare(self, S, T): """ :type S: str :type T: str :rtype: bool """ S_stack = [] T_stack = [] for ch in S...
105161c948e073a982292b0cf67e85304e82268e
294150302hxq/python_learn
/leetcode/98_is_btree.py
605
3.78125
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/9/15 @desc: """ class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isValidBST(self, root): """ :type ro...
99433588538ce16b364c51cf99076bcfcfbca589
294150302hxq/python_learn
/leetcode/50_pow.py
792
3.5
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/11/20 @desc: """ class Solution(object): def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ # if x == 0: # return 0 # if n < 0: ...
7ec374e224f70ff44cee7b3d87124220d5f7f0df
294150302hxq/python_learn
/leetcode/10_pattern_match.py
721
3.640625
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/7/13 @desc: """ class Solution(object): def isMatch(self, s, p): # 如果p为空了,s为空返回真,否则返回假 if not p: return not s # 如何p不为空,那么只有当s不为空,且p的第一位和s的第一位匹配上才算是真,否则为假 first_match = bool(s) and p[0] in...
4b41e8712b63dc180c98b7c73c8a7d795040ee89
294150302hxq/python_learn
/leetcode/1_two_sum.py
1,492
3.6875
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/6/28 @desc: """ from collections import defaultdict class Solution(object): # Brute Force def twoSum1(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int...
b56f52a7d452b41506df0b0aba26f8566c2bdc29
trahnagrom/controlled-assessment
/currency-converter2.py
2,102
4.3125
4
currencies= { "Pound Sterling": 1, "Euro": 1.2, "US Dollar": 1.6, "Japanese Yen": 200 } short_hand = { "GBP": "Pound Sterling", "EUR": "Euro", "USD": "US Dollar", "JPY": "Japanese Yen" } c_type1 = raw_input("What Currency are you converting from? GBP/EUR/USD/JPY: ") if ...
edc2c7cb9713e75c3e53ad3d984ee45d2f69a99a
arunkumar-js25/DS-Algorithm
/Find Shortest Path of Chess Knight Problem.py
1,273
3.84375
4
from _collections import deque class Node: def __init__(self,x,y,dist=0,path=None): self.x = x self.y = y self.dist = dist self.path = path def __hash__(self): return hash((self.x,self.y,self.dist)) def __eq__(self, other): return (self.x,self.y,self.dist) ...
c587e29b6eeddd3c06f9e198ca0d7c5ca1578495
michelleful/DissertationMaterials
/overgeneration_pathologies/ot/gen.py
2,246
3.640625
4
"""Function for generating possible inputs and output candidates.""" import itertools class Gen: """Generate possible inputs and output candidates.""" def __init__(self, segments='CCCVV', root_length=3): """Initialize the list of segments.""" # residue should be at least 1 segment long ...
ebcd0f5e0cb4ba05adbaa24615fcd66c821e7642
ChaofeiLiu/D.S
/Recursion/q3.py
640
3.796875
4
#!/usr/bin/env/ python # -*— coding=utf-8 -*- # @FileName :q3.py # @Time :2020/8/14 # @Author: chaofei_liu #turtle递归可视化显示 import turtle def koch(size, n): if n == 0: turtle.fd(size) else: for angle in [0, 60, -120, 60]: turtle.left(angle) koch(size / 3, n - 1) def ma...
aa3391bbe66e3f6d5283199256778ae37f860ecb
ChaofeiLiu/D.S
/DS_link_stack/Stack_for_list.py
632
3.765625
4
#!/usr/bin/env/ python # -*— coding=utf-8 -*- # @FileName :Stack_for_list.py # @Time :2020/8/4 # @Author: chaofei_liu class Stack(): def __init__(self): self.items = [] def is_Empty(self): return self.items == [] def push(self,item): self.items.append(item) def pop(self): ...
8070960c76c0e02a329a955370d9a14dda1fea74
LeoHeller/PyDrone
/modules/utils.py
1,700
3.65625
4
"""Helper functions.""" import threading import time import time as t update = "Sun Sep 9 22:08:04 2018" name = "Leo Heller" # filename = os.path.basename(main.__file__) def setupdate(): """Change the last update date.""" global update update = t.ctime() def head(): """Print header.""" prin...
da2bb25557eb5c595eabc9f1e4bd4b1333a22fdd
ajaykrprajapati/pythoncodes
/foreign_codes/cas_.py
567
3.859375
4
from collections import defaultdict def nth_most_rare(elements, n): """ :param elements: (list) List of integers. :param n: (int) The n-th element function should return. :returns: (int) The n-th most rare element in the elements list. """ d = defaultdict(int) for i in elements: d[...
4a1c675e7dbc7ff9a248be7552b13e7dbe5dc3a4
Dvandenburg117/cs435-Project1
/BalancedBinarySearchTree.py
9,028
3.71875
4
import random class Node(): def __init__(self,value): self.right = None self.left = None self.val = value self.height = 1 self.lvlctr = 0 #get height of given node def getHeight(root): if root is None: return 0 return root.height def getTrav...
202fbbd61746598732a60d84b858db5a3fda18ef
matooons/notes
/python/101.py
13,955
3.796875
4
# """ # [ # [0, 1, 2, 3, 4], # [1, 2, 3, 4, 5], # [2, 3, 4, 5, 6], # [3, 4, 5, 6, 7], # [4, 5, 6, 7, 8], # ] # """ # def manual_incrementing_matrix(n): # matrix = [ [ None for y in range(n) ] for x in range(n) ] # counter = 0 # for idx, el in enumerate(matrix): # for nested_id...
74269318512c52a38151a35698b3d2e711412bf2
MATTPostx/First
/dat.py
775
4.1875
4
y = "John" print(y) cars = {"Ford", "Volvo", "BMW"} cars.append(cars) for x in cars: print(x) def my_name(): print("hello") my_name() # print(array) # for array in cars: # print(array) # first_number = int(input('Type the first number:')) ;\ # second_number = int(input('Type the second number: ')) ;\...
426ed7b6a1db968eac60457221f26c16c3e79887
meechaguep/MCOC-Intensivo-de-Nivelacion
/21082019/000352.py
1,307
4.40625
4
print "Este dia estudiaremos listas" #intento 1 lista1= [14,21,3,-14,-21,-3] print "la lista es:" print lista1 #intento 2 print "agreguemos un numero a la lista" lista1= [14,21,3,-14,-21,-3] lista1.append(1313) print lista1 #intento 3 print "ahora agreguemos una frase a esta lista de numeros" ...
db0254a976f098a879546af4851e65a579cdfa5b
meechaguep/MCOC-Intensivo-de-Nivelacion
/29082019/014008.py
2,592
4.1875
4
import numpy as np #intro to numerical computing with numpy l1= [1,3,5,7] l2= [9,11,13,15] print l1 + l2 #agrega l2 a l1 suma_entre_elementos= [] for elemento1, elemento2 in zip(l1, l2): suma_entre_elementos.append(elemento1+elemento2) print suma_entre_elementos #se suma cada elemento gg = l...
0083e6651821c504cf941fb4678a7d5e3a33f967
meechaguep/MCOC-Intensivo-de-Nivelacion
/19082019/001908.py
307
3.890625
4
print "comenzando la nivelacion" name= "matias" altura= 1.72 peso=75. bmi= peso/ (altura**2) print "tu bmi es: " print bmi if bmi <25: print name print "no estas con sobrepeso" elif bmi==25: print name print "estas en el limite" else: print name print "no estas con sobrepeso"
7077f31353fac17071e673809049d1ab273b8cbe
crswint/crs_3200k
/crs_HW5.py
4,817
3.6875
4
## #1 all parts, #2 all except i import sqlite3 as dbapi # 1) a) Create a new database called census.db con = dbapi.connect('U:/Shared/GIS/StuData/crswin5726/Python/census.db') # b) Make a db table called Density, that will hold the name of the # province or territory (text), the population (integer) and the land #...
5ae7c6cbd0c3dde124716e3717bf7f9e1fe2019f
sravani66/my-programming
/flsk1.py
3,064
3.5
4
'''from flask import Flask app = Flask("sravani") @app.route('/') def hi(): #did not pass any argument in route so not defined in fn return 'good evening' app.run(port=5252)''' '''from flask import Flask app = Flask(__name__) @app.route('/hello/<guest>') #to change name dynamically on the ...
dcbb40a00904ebfdd0efdb11bbe2c66e04e2507e
dorahero/leetcode-practice
/Algorithms/Medium/92-Reverse-Linked-List-II/92-Reverse-Linked-List-II.py
1,309
3.90625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def reverseBetween(self, head, left, right): pos = 1 curr = head prev = None while pos < left: ...
ac1fc1eaf62fb8e7dd5ff1c64e971c96a834dc66
dorahero/leetcode-practice
/Algorithms/Medium/2-Add-Two-Numbers/AddTwoNumbers.py
1,071
3.640625
4
class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def addTwoNumbers(self, l1, l2): def length(ln): c = 0 while ln: c += 1 ln = ln.next return...
362da4493ac61cff8d8701e7ea6f10e132f32b29
dorahero/leetcode-practice
/Algorithms/Medium/73-Set-Matrix-Zeroes/73-Set-Matrix-Zeroes.py
826
3.5
4
class Solution(object): def setZeroes(self, matrix): m = len(matrix) n = len(matrix[0]) _ = [0 for x in range(n)] # record 0 location tmp = set() for i in range(m): counter = 0 for j in range(n): if matrix[i][j] == 0: ...
c49d6768c2da369eb1e256ac06eb2b3b288ec3e4
dorahero/leetcode-practice
/Algorithms/Medium/75-Sort-Colors/75-Sort-Colors.py
410
3.65625
4
class Solution(object): def sortColors(self, nums): n = len(nums) for i in range(n): for j in range(n-i-1): if nums[j] > nums[j+1]: _ = nums[j] nums[j] = nums[j+1] nums[j+1] = _ return nums if...
3dfea2f8eaed62e037cadcc0cc5ba5f6514ca5c9
kevinwong2016/python_leetcode
/leetcode53.py
1,246
3.5
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 06 21:02:58 2017 @author: wangyao """ ##穷举法 class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ ans = [] for i in range(0,len(nums)): for j in range(i,len(nums)): ...
c8aee1f101784124a55e84bde9d4f6775d099879
Consolate/ChallengeTwo
/accounts/filestore.py
4,279
4.03125
4
#creating filestorage file cusnames=[] cuspassword=[] cusbalance=[] #openeing the storage file to collect customer old data namefile=open("cusnamefile.txt","r") passfile=open("cuspassfile.txt","r") balfile=open("cusbalfile.txt","r") # put data from the storage files into the empty list #check list of cust...
f2ac0a972ca77549185807cdc8c29652ffc8c86b
LSSTDESC/TXPipe
/txpipe/extensions/cluster_mag/buffer.py
1,157
3.609375
4
import numpy as np class Buffer: """ This is a helper for the randoms generation that buffers its output so it's not trying to write loads of small chunks of data out. It stores a buffer of things to write out later of specified size. It's not trying to be more generally useful at this stage - i...
4fff67a575351e4a6158e307010cf4418e34ab41
mdko/PyRTL-Extras
/pyrtl_extras/format.py
4,881
4.125
4
from collections import defaultdict from warnings import warn import sys import pyrtl # TODO update to taken in the number itself (user can partially apply if they want) # TODO use number's width as default for one of the arguments # TODO simplify/explain arguments more def binf(width, max_width): """ Prints ...
cba93f01637e3b17db1461fe6dca21b120f4ed34
DeSales-Code-Jam-2020/code-jam2020-nickh671
/q4.py
649
3.84375
4
def main(str1): result = '' shift = '' start = 0 for i in range(len(str1)): if str1[i] not in ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']: shift += str1[i] else: start += i break if start == 0: result += str1 re...
737faedbc0ed134e6a56bf2db19dcf9b46563327
legeannd/codigos-cc-ufal
/APC/AULA 4/q3.py
127
3.859375
4
def areac(raio): return 3.14*(raio*raio) raio = float(input("Digite o raio\n")) print("A area do circulo eh ",areac(raio))
82cb1fd257e84ba308a2bcf20d6450cfd8fda462
spuentesv/condicionales_python
/ejercicios_profunidzacion/profundizacion_2.py
1,797
4.25
4
# Condicionales [Python] # Ejercicios de profundización # Autor: Inove Coding School # Version: 2.0 # NOTA: # Estos ejercicios son de mayor dificultad que los de clase y práctica. # Están pensados para aquellos con conocimientos previo o que dispongan # de mucho más tiempo para abordar estos temas por su cuenta. # R...
d83cafe9dfbb4e86078dee11bb8a99424200bb10
JBJDC/Machine-Learning-
/logistic regression/graddesc.py
2,490
3.5
4
# graddesc.py 用梯度下降法进行求解 import argparse from math import exp, log import matplotlib.pyplot as plt import numpy as np # data fields x = None y = None def main(): global x, y parser = argparse.ArgumentParser( description='Using gradient descending method to solve the logistic regression problem.') ...
5fb91934701791831a70a461054f9690098d9fe8
TianGong42/PythonPractice
/chapter4/ex4_13.py
396
3.5
4
# 有一家自助式餐馆,只提供五种简单的食品。请想出五种简单的食品,并将其存储在一个元组中。 menus = ("饺子","葱油拌面","红烧肉","青椒土豆丝","玉米") for menu in menus: print(menu) # menus[0] = "粽子" print("修改后的菜单") menus = ("饺子","葱油拌面","红烧肉","手抓饼","烤冷面") for menu in menus: print(menu)
34d8170427201cee612910dc018111c37d57d610
TianGong42/PythonPractice
/chapter6/ex6_1.py
328
3.5
4
# 使用一个字典来存储一个熟人的信息,包括名、姓、年龄和居住的城市。 # 该字典应包含键first_name、last_name、age和city。将存储在该字典中的每项信息都打印出来。 people = { 'first_name':'周', 'last_name':'树人', 'age':25, 'city':'绍兴' } print(people)
8984de3b41c0203b431ef31ed34cc9e2ec0e1fdd
TianGong42/PythonPractice
/chapter5/ex5_8.py
593
4.03125
4
# 创建一个至少包含5个用户名的列表,且其中一个用户名为'admin'。 # 想象你要编写代码,在每位用户登录网站后都打印一条问候消息。遍历用户名列表,并向每位用户打印一条问候消息。 # users = ['张三', '李四', '王五', '赵六', 'admin'] users = [] if users: for user in users: if user == 'admin': print("Hello " + user + ", would you like to see a status report?") else: print(...
f046a41619e540ff11639f8f8a1b8834efca64a9
ndn/somacube
/python/rotation.py
3,540
3.9375
4
""" Some math. Rotation matrixes: 1 0 0 rotate around x axis = 0 cos(a) -sin(a) 0 sin(a) cos(a) cos(a) 0 sin(a) rotate around y axis = 0 1 0 -sin(a) 0 cos(a) ...
0a24d97defcca7fe24bcaec53337ba790151a76f
crystalballz/LearnPythonTheHardWay
/ex3.py
700
4.46875
4
print "I will now count my chickens:" # Hens and Roosters are counted separately print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 # Not too many eggs since there are more Roosters than Hens print "Now I will count the eggs:" print 3 + 2 + 1 - 5+ 4 % 2 - 1 / 4 + 6 # Verifies if the statement that follows is...
501cfa1c2a55e14db0a151e0059906576938a028
thegamingcoder/leetcode
/695.max-area-of-island.py
1,315
3.53125
4
# # [695] Max Area of Island # # https://leetcode.com/problems/max-area-of-island/description/ # # algorithms # Easy (52.20%) # Total Accepted: 34K # Total Submissions: 65.2K # Testcase Example: '[[1,1,0,0,0],[1,1,0,0,0],[0,0,0,1,1],[0,0,0,1,1]]' # # Given a non-empty 2D array grid of 0's and 1's, an island is a gr...
4eb752a59c5017a2d617def3e0ef8186c3c61bf4
thegamingcoder/leetcode
/357.count-numbers-with-unique-digits.py
746
3.75
4
# # [357] Count Numbers with Unique Digits # # https://leetcode.com/problems/count-numbers-with-unique-digits/description/ # # algorithms # Medium (46.26%) # Total Accepted: 49.8K # Total Submissions: 107.6K # Testcase Example: '2' # # Given a non-negative integer n, count all numbers with unique digits, x, # where...
4702b00f3a29caeb86b9ed48c3a1e63ebfca6d57
navjeethundal/TextAdventureGame
/TextAdventureGame.py
20,731
4.21875
4
#Author: Navjeet Hundal #Version 1.0 #This program is a text based game that you go between rooms and doors to find a way out. #Limitation: can only accept intergers from the user #Features: (1) Entrance room with three differnt options #(2) Kitchen where you can change the state of the lever #(3) Pantry where you ca...
6e429333ecfa42181d1d03e0a0f6656f813816e5
IrinaMun/python-base
/Lesson9/task4.py
1,548
3.9375
4
""" 4. Реализовать класс Stationery (канцелярская принадлежность). определить в нём атрибут title (название) и метод draw() (отрисовка). Метод выводит сообщение «Запуск отрисовки»; создать три производных класса Pen (ручка), Pencil (карандаш), Handle (маркер); в каждом классе переопределить метод draw(). Для каждого кл...
7104c19f0dd2e557dccd1c8ea59af2e8566e268e
DanUk2/Programming
/Lesson3.py
2,326
3.921875
4
#x = ['mix', 'xyz', 'apple', 'xanadu', 'rovio'] #new_list_a = [] #contain the words beginning with x #new_list_b = []# contain the rest #for word in x: #if word[0] =="x": #new_list_a.append(word) #else: #new_list_b.append(word) #print( sorted(new_list_a) + sorted(new_list_b) ) # #the list of...
5cbd64931dd241511babd072442c30d9133ff108
DanUk2/Programming
/Lesson4.py
1,731
4.0625
4
## exercise 1 # my_dict = {'item1': 4, 'item3' : 5, 'item2' : 6} # new_dict = {} # # x = {"item1":12, "item2":2} # new_x = {k:v*2 for k,v in x.items()} ## Testing try execpt block # while True: # try: # a = int(input("Give me one number:" )) # b = int(input("Give me another number:" )) # ...
b42440f25b8c34dbf198e4d0dd4d0c9cb75a3958
Sendhan/demographic-data-analyzer
/boilerplate-demographic-data-analyzer/demographic_data_analyzer.py
6,606
4.125
4
import pandas as pd def calculate_demographic_data(print_data=True): # Read data from file df = pd.read_csv("adult.data.csv") # How many of each race are represented in this dataset? This should be a Pandas series with race names as the index labels. race = df['race'].squeeze() race_count = {} ...
89d5d07376abc2813ef4c5d556aed9c0e55ba21b
Chitranshuvarshney/Stone-Paper-Scissor-Game
/game.py
1,072
4.21875
4
import random # This is the stone, Paper & Scissor Game! def gameWin(comp, you): if comp == you: return None elif comp == 'stone': if you=='paper': return True elif you=='scissor': return False elif comp == 'paper': if you=='stone': ...
62556dbef2c0471ad40c586d33e6fdd4a2d41cb3
GaboFDC/PYADS
/Python Patterns/creational/FactoryMethod.py
988
3.953125
4
class Logger(): """Abstract logger""" def log(self, message): pass class ConsoleLogger(Logger): """Concrete logger to the console""" def log(self, message): print(message) class FileLogger(Logger): """Concrete logger to a file""" def log(self, message): with open('fa...
bcf8eae95a023dada9353ba3876b6850eb759449
atharva10764/Python-Masterclass
/Strings.py
416
3.65625
4
print("Today is a good day to learn python") print("Python is fun") print("i love 'python' ") print("hello" + " world") greeting = "hello" name = "Atharva" print(greeting + name) age = 20 print(age) print(type(greeting)) print(type(age)) age_in_words ="20 years" print(name+f" is {age} years old") print(type(age)) p...
99d42d33f0ab8c776ef84238adc69f3976d39f35
valeri1383/Python-OOP
/Iterators and Generators Lab/Vowels.py
619
3.625
4
class vowels: def __init__(self, text): self.text = text self.current_idx = 0 self.vowels = ['a', 'e', 'u', 'o', 'y', 'i'] def __iter__(self): return self def __next__(self): if self.current_idx < len(self.text): temp = self.current_idx ...
469e3b0f8bf96ec6b03dc419dd3950f507cd8b92
valeri1383/Python-OOP
/Defining Classes/Rhombus of Stars.py
291
3.53125
4
def first_half(n): for i in range(n + 1): print(f"{' ' * (n - i)}{'* ' * i}") def second_half(n): for j in range(1, n): print(f"{' ' * j}{'* ' * (n - j)}") def rhombus_of_stars(n): first_half(n) second_half(n) rhombus_of_stars(int(input()))
74d28c62fdd5e9f42400b6391ff75bf2a5ac343b
valeri1383/Python-OOP
/Iterators and Generators Lab/Squares.py
126
3.59375
4
def squares(n): start = 1 while start <= n: yield start ** 2 start += 1 print(list(squares(5)))
329171889db30e69e1b69221e2a58bce03f208cd
pvskp/unicamp
/MC102/1semestre_2021/caça_ao_tesouro.py
2,492
3.703125
4
# Caça ao tesouro: # Programa que recebe um campo no formato de uma matriz # 8x8 composta por '.', 'x' e 'o'. Além da quantidade de sensores disponíveis para procurar o tesouro, suas posiçoes e seu alcance. # 'x' representa o tesouro buscado, 'o' representa um bloqueio, por onde o alcance dos sensores não consegue pa...
c2dd15e9377967a39cc6a89047e79d5597037cea
yousef-ctrl/Lib-System
/library_systems.py
4,350
3.859375
4
import time ''' The module communicates between the main file and "library_database.txt". ''' class Book: ''' The class edit your books with a special form. ''' def __init__(self, writer, name): ''' You must write a writer and a name for your books. First parameter is writer of...
f05b23e4bc342d134cd21578b3e68c7b5463bf09
sk33loy4/fizz
/implementation.py
261
3.921875
4
def FizzBuzz(x): if x%3==0 and x%5==0: return "FizzBuzz" elif x%3==0: return "Fizz" elif x%5==0: return "Buzz" else: return x for i in range(100): if i==0: continue else: print(FizzBuzz(i))
cd4e2454f047f81247a11a7446e76638a91fbfb8
BlazejNowicki/ASD
/c02/zad4.py
414
3.78125
4
def partition(A, p, r): x=A[r] i=p-1 for j in range(p,r): if A[j]<=x: i += 1 A[i],A[j]=A[j],A[i] A[i+1],A[r] = A[r],A[i+1] return i+1 def quicksort(A, p, r): while p<r: q=partition(A,p,r) quicksort(A,p,q-1) p=q+1 if __name__ == "__main__"...
bed6bafc0c32c30ce9b389bf7545f828174d4145
BlazejNowicki/ASD
/algorithms/kruskal_mst.py
873
3.625
4
from queue import PriorityQueue class Node: def __init__(self, id): self.id = id self.parent = self self.rank = 0 def find_set(x): if x!= x.parent: x.parent = find_set(x.parent) return x.parent def union(x,y): x = find_set(x) y = find_set(y) if x.rank > y.rank:...
0742d27f8c451e1f62e8abd2491da8391a6d4857
BlazejNowicki/ASD
/algorithms/BST.py
3,272
3.9375
4
class BSTNode: def __init__(self, key): self.key = key self.left = None self.right = None self.parent = None # definicja tree jako klasy aby uniknąć zwracania referencji do root np podczas uswania elementu który jest korzeniem class BSTtree: def __init__(self): self.ro...
0150551fb0e68dfbcb43402252ad9b68e5442053
BlazejNowicki/ASD
/dp_greedy/z5/zad3.py
418
3.640625
4
def longest_subsequence(A, B): n = len(A) m = len(B) T = [[0 for _ in range(n+1)] for _ in range(m+1)] for i in range(1, m+1): for j in range(1, n+1): if A[j-1] == B[i-1]: T[i][j] = T[i-1][j-1] + 1 else: T[i][j] = max(T[i-1][j-1], T[i-1][j]...
b4de3027e76196ea67b8f0c5772135b24cbb24f1
BlazejNowicki/ASD
/wyklady/dijkstra_matrix.py
964
3.59375
4
INF = 10**5 def edge_list_to_adjacency_matrix(G, n): GG = [[-1 for _ in range(n)] for _ in range(n)] for w,u,v in G: GG[u][v] = w GG[v][u] = w return GG def min_dist(dist, visited): min = INF for i in range(len(dist)): if not visited[i] and dist[i] < min: min = ...
ef87e83c071480095ebbd027355cf65f536af9a1
BlazejNowicki/ASD
/stare_kolokwia/build_string_from_two.py
442
3.6875
4
def possible(a, b, c): if len(a)+len(b) < len(c): return False letters = [0]*26 for l in c: letters[ord(l)-ord('a')] -= 1 for l in a: letters[ord(l)-ord('a')] += 1 for l in b: letters[ord(l)-ord('a')] += 1 for val in letters: if val < 0: return False r...
9dae1f888701fc16e9c8fc382c13b09e9cdbab9a
BlazejNowicki/ASD
/stare_kolokwia/sort_strings.py
858
3.703125
4
from random import shuffle def get_index(string, pos): if len(string) < pos: return 0 else: return ord(string[pos-1])-ord('a')+1 def counting_sort(A, B, position): length = len(A) C = [0]*7 for i in range(length): C[get_index(A[i], position)] += 1 for i in range(1, 7): ...
c3ff8a72e694e0f0b2d5c991ca5b4e16c8e7cd49
BlazejNowicki/ASD
/offline/zad1_mg.py
901
3.65625
4
from random import randint, seed def mergesort_rec(T, l, r): if abs(l - r) < 2: return [T[l]] m = (l + r) // 2 left = mergesort_rec(T, l, m) right = mergesort_rec(T, m, r) out = [0] * (len(left) + len(right)) l_index, r_index = 0, 0 for i in range(len(out)): if r_index ...
319204240fe3fcc3f9f3ab55ea16bf109e40c0b3
conzmr/IntelligentSystems
/Partial1/maze/main.py
7,096
3.546875
4
from Graph import Graph from Maze import Maze from random import randint from PIL import Image graph = Graph() graphMaze = Graph() width = 0 height = 0 image = 0 pixels = 0 def mazeGeneration(): cells = [] visited = [] found = False x = randint(1, width-2) start = '0 ' + str(x) visited.append(start) cells.appe...
00bb61dee6599e2bf4ef6683f41d97766e3b25cc
Matheswaaran/Py_pgm
/prime.py
249
4
4
#!/bin/python import sys def isPrime(n): count = 0 for i in range(1,n): if n%1 == 0: count = count + 1 if count == 2: return True else: return False n = int(raw_input()) if isPrime(n) == True: print "Prime" else: print "Not Prime"
cb912c7a13d1cae124b2bc8fa1b0428e6d6b7586
Muskan2917/Python_Pattern_Programs
/Pattern7.py
400
3.96875
4
""" A Program To Print The Following Pattern. A B C D E A B C D E A B C D E A B C D E A B C D E """ #Program code to print above pattern for x in range(1,6): for y in range(65,70): print(chr(y),end=" ") print() """ OUTPUT: C:\python3.7\python.exe C:/Users/lenovo/PycharmProjects/1frog/Python_Pa...
e87c6eec4aa35123f575d1efcf63eaaa5c7247aa
Muskan2917/Python_Pattern_Programs
/Pattern15.py
361
4
4
""" A Program To Print The Following Pattern. * * * * * * * * * * * * * * * """ #Program code to print above pattern for x in range(1,6): for y in range(6,x,-1): print("*",end=" ") print() """ OUTPUT: C:\python3.7\python.exe C:/Users/lenovo/PycharmProjects/1frog/Python_Pattern/Pattern15.py...
3e08cc356934039836f4a9871c3c0d72b700ac86
jatzmail/JATZ-Mail-1
/JATZ Mail version 0.1.py
1,522
3.921875
4
import smtplib from tkinter import * def sendOut(): for i in range(1): sender_email = '' #Person to send email from rec_email = email_sendTo.get() #Person to recieve the email password = input(str('Enter Password To Senders Account: ')) #Password to the sender's account pr...
18633193865e7e3bd223e6b9b4e58a6d764a32f0
apasswater/tripPlanner
/tripPlanner_old.py
2,104
4.09375
4
############################################### '''This is old and shitty code''' '''Check if the city the user typed in is already an existing trip''' def does_trip_exist(destination): extisting_trip = False for i in trip_dict: if trip_dict[i].has_key(destination): friend = trip_dict[i].get(destination)[0] ...
31f85dde84c5fd9b76e5733393c67b4a860a557e
PushkarDhakad2505/Programming
/Hackerrank/hr making anagram.py
216
3.65625
4
str1=input() str2=input() str11=[] for i in str1: j=0 str11.append(str1[j]) j+=1 print(str11) for i in str1: if(i not in str2): str11.remove(i) print('a') print(str1)
fb880e6e1ea0a689fd73ee8ddfa6284bf95973a1
PushkarDhakad2505/Programming
/compitative/compitative/hr pe 3 largest prime factor.py
618
3.859375
4
def subArraySum(arr, n, sum): curr_sum = arr[0] start = 0 i = 1 while i <= n: while curr_sum > sum and start < i-1: curr_sum = curr_sum - arr[start] start += 1 if curr_sum == sum: print ("Sum found betwee...
120928aabf5866183931eefa78dcd9a7f28019b2
PushkarDhakad2505/Programming
/Hackerrank/HR string validator.py
567
3.625
4
s=input() flag1=0 flag2=0 flag3=0 flag4=0 flag5=0 for i in s: if i.isalnum(): flag1=1 if i.isalpha(): flag2=1 if i.isdigit(): flag3=1 if i.islower(): flag4=1 if i.isupper(): flag5=1 if(flag1): print("True") else: print("Fl...
55a18a68d68732c142fdf3959b2b0c1ae78e5a37
JohnaleJ/python-challenge
/PyPoll/main.py
2,277
3.671875
4
# Importing the os module to utilize various os import os electioncsvpath = os.path.join('Resources', 'election_data.csv') # Importing csv and reading the csv file import csv with open(electioncsvpath, newline= '') as electioncsvfile: #CSV reader with delimiter electioncsvreader = csv.reader(electioncsvfile, ...
6aad455ccc8ba911e1f452b85757accd03d86302
Arthur-AZ-Zhou/arthur_test
/python/PythonForKids/p134-137.py
998
3.609375
4
#Randit import random print(random.randint(1,100)) print(random.randint(100,1000)) print(random.randint(1000,10000)) import random num = random.randint(1,100) x = 0 while True: guess = input("Guess a number between 1 and 100 ") if int(guess) == num: x = x+1 print("You have AMAZING guessing skill...