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
89c9d520c3f3df07c2f7cbbc4660da72c90a9480
oll-dev/MelbourneData
/Distributions/distanceuni.py
472
3.734375
4
# Import libraries import pandas as pd import matplotlib.pyplot as plt import math # Read in the dataset dataset = pd.read_csv(r'../Melbourne_housing_FULL.csv', skip_blank_lines=True) nnDistance = [] # No null values for p in dataset.Distance: nnDistance.append(float(p)) # Create plot plt.hist(nnDistance, color...
78f24f31387201dd43658f287b1756c30dca1b72
BaijunY/smart_alarm
/playground/play_sound.py
706
3.640625
4
import pygame import RPi.GPIO as GPIO # set pin for amplifier switch amp_switch_pin = 5 GPIO.setwarnings(False) # configure RPI GPIO GPIO.setmode(GPIO.BCM) # set pin to output GPIO.setup(amp_switch_pin, GPIO.OUT) def play_mp3_file(mp3_file): # set output high in order to turn on amplifier GPIO.output(amp_sw...
10da70857a710cd710169d439954b39431a34bd2
SpAnDaNpAtIl/AE-484-assignment-2
/assingment2.py
2,192
3.75
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 27 13:36:38 2020 @author: spand """ import numpy as np import matplotlib.pyplot as plt P = 100 Ao = 10 L = 100 E = 200000 #lets create a class which stores the numbered position of spring and in general total number of springs in the system class Spring...
e403c03d6b4efb2e29c6fefbce8f068811045fb1
philthefeel/master_bioinfo
/PYT/U126437_exercise_block1_part4_and_part5.py
3,519
3.84375
4
def FASTA_iterator (fasta_filename): """ Creates a generator to iterate trough a FASTA file""" file=open(fasta_filename,"r") seq='' for line in file: if line[0]==">": if seq != "": yield (lastid,seq) seq='' lastid=line.strip()[1:] ...
273837f2a145d22f44b3b489691eecdc8935f492
yy326edu/idcovert
/main.py
773
3.578125
4
# -*- coding:utf-8 -*- print "Developed by YangYi" def qu0x(a, b): n_a = str(a)[2:] n_b = str(b)[2:] if len(n_b) == 3: n_all = n_a + "0" + n_b return n_all elif len(n_b) == 2: n_all = n_a + "00" + n_b return n_all else: n_all = n_a + n_b return n_all...
4112553651ca14075a16b479491892fa8e21e8d3
westernesque/a-history-of-birds
/venv/Lib/site-packages/pyrr/aambb.py
4,606
3.671875
4
# -*- coding: utf-8 -*- """Provides functions to calculate and manipulate Axis-Aligned Minimum Bounding Boxes (AAMBB). AAMBB are a simple 3D rectangle with no orientation. It is up to the user to provide translation. AAMBB differ from AABB in that they allow for the content to rotate freely and still be within the AAM...
195fef24c755a1de891075ef60f7e27817747e0a
westernesque/a-history-of-birds
/data/fonts/line.py
954
3.875
4
class Line: def __init__(self, space_width, font_size, max_length): # print(type(space_width)) self.space_size = space_width * font_size self.max_length = max_length self.words = [] self.current_line_length = 0 def attempt_to_add_word(self, word): additi...
d524fd3c65d72d9fa829afe033a5b207d198a8a6
superyuki2/PokemonBattleSim
/main.py
11,571
3.5625
4
import sys import copy import random import pokeAndmoves import pokemon import staticMethods as sm import moveEffects as me class Player: def __init__(self, human): self.pokemonSet = [] #All Pokemon self.curPoke = None #Current Pokemon self.stealthRock = False #Stealth Rock self.reflect = 0 #Reflect self.s...
30fd42def3861c42eb68cb218ff55394f76845eb
cecezhou/wordsegmentation
/models.py
8,428
3.5
4
# python spellchecking library import enchant import helpers class NoSpaceText: def __init__(self, inputText, maxWordLength): self.text = inputText self.length = len(inputText) # length we assume is the max length of a word in the text self.maxWordLength = maxWordLength # holds values for variables, var0 i...
5d875830c4b577788414a8185fc4a18d37e06eb0
Pelinaslan/Project-Euler-Solutions
/solution-006.py
352
3.515625
4
""" Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. //25164150 """ karetoplam=0 toplam=0 for i in range(101): karetoplam=karetoplam+(i*i) toplam=toplam+i if(karetoplam>(toplam*toplam)): print(karetoplam-(toplam*toplam)) else: prin...
1a301231c4aef0a5417a9f0efa015da6b8ce9627
wt-l00/work
/translateseccomp.py
190
3.609375
4
#! /usr/bin/python3 # coding: UTF-8 file = open('sample.txt') file_data = file.read() for line in file_data.split('\n'): if '@' in line: for tmp in line.split(':'): print(tmp)
da3e46522a54ff4971dda36cb3a0ad19de85e874
donchanee/python_trick
/Chaining_Comparison.py
502
4.25
4
# Chaining comparison operators: >>> x = 5 >>> 1 < x < 10 True >>> 10 < x < 20 False >>> x < 10 < x*10 < 100 True >>> 10 > x <= 9 True >>> 5 == x > 4 True ''' In case you're thinking it's doing 1 < x, which comes out as True, and then comparing True < 10, which is also True, then no, that's really not what happens...
dc095f0f81bf1d8b7cfe144bf886bf65471dd56a
NihaMomin/Probability-Stats-Project
/Task_1_2_4_8.py
4,853
3.53125
4
import matplotlib.pyplot as plt import turtle import math import numpy as np import pylab import random from scipy.integrate import quad # Task 1 def get_distance_1D(choice , numSteps , prob , x, y): steps = np.random.choice(choice , numSteps , p = prob) exp = 0 for i in range(len(choice)): exp += choice[i]...
919dca96bea9dc4769f99d2dbae7d006152a81f8
fsrcabo/tareasobligatrias
/05_calculator.py.py
2,844
4
4
# En este programa se creará una calculadora #Zona importaciones import os #zona definición de variables y diccionario selec=1 bucledowhilefalso=0 diccionario={'Suma':'n1+n2', 'Resta':'n1-n2', 'Multiplicación':'n1*n2', 'Division':'n1/n2', 'Exponencial':'n1^n2'} #Zona de definición e implementación de fun...
caefedbd70ce1eb050129f51b129fcd18e2d9b57
KlimDos/exercism_traning
/python/checkio/most-wanted-letter.py
962
3.640625
4
import re import operator import pprint def count_letters(text: str): dict = {} text = text.lower() for i in text: try: new_value = int(dict.get(i))+1 dict[i] = new_value #print ("try") except: dict[i] = 1 #print ("exeption") ...
ed37d9243eda6d10b8f2cb0e8c3c55791ed99e38
KlimDos/exercism_traning
/python/yacht/yacht.py
2,457
4.1875
4
""" This exercise stub and the test suite contain several enumerated constants. Since Python 2 does not have the enum module, the idiomatic way to write enumerated constants has traditionally been a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a...
e0129a1560c841f709bd4f9159311e70812f4399
Ak4shh/Snake_game
/main.py
5,279
3.859375
4
import pygame import time import random pygame.init() #init() - Initializes pygame modules clock = pygame.time.Clock() #color codes in terms of RGB white = (255, 255, 255) yellow = (255, 255, 102) black = (0, 0, 0) red = (213, 50, 80) green = (0, 255, 0) blue = (50, 153, 213) orange = (255, 128, 0) ...
077f43db92b2089e34e4393751f3b5cf2cc142a5
Shalima2209/Programming-Python
/set1.6.py
76
3.546875
4
list1 = ['a','d','a','b','t','u','a','a','g','w'] print(list1.count('a'))
336152ac95245e4b7b59387b1ec96501cecd2940
Shalima2209/Programming-Python
/rectangle.py
882
4.125
4
class rectangle: def __init__(self,length,breadth): self.length=length self.breadth=breadth def area(self): return self.length*self.breadth def perimeter(self): return 2*(self.length + self.breadth) a=int(input("length of rectangle1 : ")) b=int(input("breadth of rect...
6d5c93a9db98f2c014efd4db207a6ab94a15e055
LangdalP/EulerCode
/Problem1-24/Problem012/per.py
629
3.78125
4
triSum = 0 triNum = 1 numdivides = 500 test = [] while True: divide = 1 useless = 0 lastProd = 0 triSum += triNum if triSum % 2 == 0 and triSum % 3 == 0: for j in range(2, triSum//2+1): if triSum % j == 0: if lastProd == j: divide = divide * 2 #print("hallo", divide, lastProd, triSum, triNum) ...
50a15874ba0f273c15fb437cc8a780f3f7efc95f
LangdalP/EulerCode
/Problem1-24/Problem006/per.py
232
3.65625
4
def sumsquares(num): sum = 0 for i in range(1,num+1): sum = sum + i ** 2 return sum def squaresum(num): square = 0 for i in range(1,num+1): square = square + i return square ** 2 n = 100 print(squaresum(n)-sumsquares(n))
95ffb362efff42e21d1e1027229b9fd3aa36cb01
Wangsenlol/compuational_physics_N2015301020139
/Chapter1/1.3.py
1,261
3.734375
4
import numpy as np #to import matplotlib's package import matplotlib.pyplot as plt x1=[] y1=[] a=10 #assign a value to a b=1 #assign a value to b det_x1=0.1 #time step x1.append(0) #assign a value to first item of x1[] y1.append(0) #assign a value to f...
fc8f8a9f443d86e5ca2d4f8894ee830400b232a3
Wenyi-hub/Codesaving
/original code for peak finding.py
572
3.71875
4
import numpy as np import matplotlib.pyplot as plt from scipy.signal import find_peaks np.random.seed(0) Y = np.zeros(1000) # insert @deinonychusaur's peaker function here #peaks, _ = find_peaks(Y, height=1, distance=100) # make data noisy Y = Y + 10e-4 * np.random.randn(len(Y)) # find_peaks gets the maxima, so we...
b86eaae4ccd2e2c5f6a09bd38b6865e2cbb27c68
ThomasMGilman/ETGG-2801_2
/lab 3/Shapes.py
4,150
3.515625
4
import random import math def seedRandom(): random.seed() def appendVec2(array, x, y): array.append(x) array.append(y) def appendVec3(array, x, y, z): appendVec2(array, x, y) array.append(z) def mirrorAppendVec2(array, x, y): appendVec2(array, x, y) appendVec2(array, -x, -y) def createR...
2ec9ff3889150a013e3a66c6c0fcfc16b9971f6a
qq714412541/leetcode
/leetcode_all/10_str_expression_regularexpressionmatch/Regular_expression_match.py
2,000
3.59375
4
class Solution: def isMatch(self, s: str, p: str) -> bool: if s == '' and p == '': return True elif s == '' or p == '': print('#####') return False else: while s and p: if len(s) >= 2 and len(p) >= 2: ...
c5035772d7ed21a8de0b3a0117f16c0210e326da
qq714412541/leetcode
/leetcode_offer/52_first_same_node/first_same_node.py
2,842
3.53125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: testA = headA testB = headB countA = 0 countB...
bc2100c40ae6e88d5302ab6e58acbb971cc20b63
qq714412541/leetcode
/algorithm_athesiss/1_sorting/2_selection_sort.py
692
3.953125
4
def selection_sort(arr:list): if len(arr) < 2: return arr else: for i in range(len(arr)): comp = float('inf') index = int temp = int for j in range(i,len(arr)): if comp > arr[j]: comp = arr[j] ...
41fb068cb64cdfe6f5669424379b0cc3b78d5467
Shiminmandy/ista130_introduction_to_programming
/assignments/assignment8/dict_practice.py
1,212
3.703125
4
# -*- coding:utf-8 -*- # @Description: draft # @Author: Shimin # @Copyright # @Version:0.0.1 fishmap = {1:"Bream", 2: "whatever"} print(fishmap) print(fishmap[1]) # 创建词典 person = {} person['name'] = 'Tom' # 字典名person[key] = 'value' person['age'] = 22 person['city'] = 'Shanghai' person['ID'] = '12345' print(perso...
aa1922b844acc6965988582e9e1a0b2b767fb07a
Shiminmandy/ista130_introduction_to_programming
/assignments/assignment3/conditions.py
4,137
4.21875
4
# -*- coding:utf-8 -*- # @Description: python assignment3 # @Author: Shimin # @Copyright # @Version:0.0.1 def word_length(str, int): if len(str) > int: print(f"Longer than {int} characters: {str}") elif len(str) == int: print(f"Exactly {int} characters: {str}") else: print(f"Shorter...
62e87e73791ea3c88a8daceb280755eefd79b4a1
DumunVolodymyr/IOT-Project-Telegram-Bot
/Vector.py
1,851
3.921875
4
x1 = int (input("Введіть координату х першого вектора ")) y1 = int (input("Введіть координату y першого вектора ")) z1 = int (input("Введіть координату z першого вектора ")) vector1 = [] vector1.append(x1) vector1.append(y1) vector1.append(z1) x2 = int (input("Введіть координату х другого вектора ")) y2 = int (input("В...
9fcf454504903164d2b7ccd918a14519871a29d2
jerrycmh/leetcode
/Search/22_generate_parentheses.py
581
3.546875
4
class Solution(object): def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ if n == 0: return [] def backtrack(cur_string, left, right): if len(cur_string) == 2*n: res.append(cur_string) ...
0c7ead4c19911c01ab2d28578d0d975762d3abbc
jerrycmh/leetcode
/Search/79_Word_Search.py
854
3.734375
4
class Solution: def exist(self, board: 'List[List[str]]', word: 'str') -> 'bool': if not board and not word: return True if not board and word: return False for i in range(len(board)): for j in range(len(board[0])): if self.helper(...
2ec96983a1ca2f3288029359bfda8848f95dac9b
jerrycmh/leetcode
/Search/37_Sudoku_Solver.py
1,313
3.78125
4
class Solution(object): def solveSudoku(self, board): """ :type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead. """ self.board = board self.solve() def findValid(self): for row in range(9): fo...
3047dfb37e42c97786d49755783b648b2cb3ebf9
jerrycmh/leetcode
/Graph/847_Shortest_Path_Visit_All_Nodes.py
693
3.5
4
class Solution: def shortestPathLength(self, graph): node_count = len(graph) masks = [1 << i for i in range(node_count)] all_visited = (1 << node_count) - 1 queue = [(i, masks[i]) for i in range(node_count)] visited = [{masks[i]} for i in range(node_count)] steps = 0 while queue: size = len(queue) ...
819cd8c814b4c1d27bcb26e1f57433035663b7f0
jerrycmh/leetcode
/DP/70_Climb_Stairs.py
331
3.65625
4
class Solution: def climbStairs(self, n): """ :type n: int :rtype: int """ if n==1: return 1 if n==2: return 2 num_seq = [1, 2] for i in range(1, n-1): num_seq.append(num_seq[i]+num_seq[i-1]) return ...
83942228196c9efed49a1cb353538983aaf21ffe
jerrycmh/leetcode
/List/61_Rotate_List.py
826
3.765625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def rotateRight(self, head: ListNode, k: int) -> ListNode: if not head: return None if not k: return head size = 0 ite = hea...
c6c0723f54f6204745c4d8c2620dfee652216da7
ClassicalGalileo/FLVSproject
/Restaurant/Porject.py
3,788
3.890625
4
from dishes import * from drinks import * tax = 1.065 def main(): print("Welcome to the Chiara Bristo, here you'll find authentic French-Italian food") print("Here's our menu, have fun!") print("Press Enter to Continue... ") input() print(" _________________________________________...
81eaba6af9dbd82cf128e9ccaffc75535cf3ca5f
EdgarEmmanuel/TD1-In-Python
/exo1.py
234
3.90625
4
import math a = int(input("saisissez le nombre a : ")) b = int(input("saisissez le nombre b : ")) print("le quotient entier est : ",math.floor(a/b)) print("le reste de la division est : ",a%b) print("le quotient reel est : ",a/b)
fef670fad5c9e1e5b97f79850c1fe31ed774a6ff
EdgarEmmanuel/TD1-In-Python
/exo9.py
1,016
3.78125
4
import math #version 1 heure_depart = int(input("Entrez l'heure de depart en entier : ")) minutes_depart = int(input("Entrez minutes de depart en entier : ")) heure_arrivee = int(input("Entrez l'heure d'arrivee en entier : ")) minutes_arrive = int(input("Entrez minutes d'arrivee en entier : ")) total_minutes_depart...
f3dd5ca760ddb1f1ebb76873d71af6f287d0dc4e
EdgarEmmanuel/TD1-In-Python
/exo10.py
582
4.09375
4
#trier la liste numbers = [] for i in range(0,3): val = int(input("saisir la valeiur du nombre : ")) numbers.append(val) print("---------Affichage du tableau Avant tri ------------") for j in range(0,len(numbers)): print(numbers[j]," | ") print("--------- Apres tri par ordre croissant ----------") ...
44f1950b3405ea49f81543f033d8cbf6f363031a
devforfu/ancli
/examples/functions.py
151
3.5
4
def compute(a: int, b: int): print(plus_one(plus_one(square(a) + square(b)))) def square(x): return x ** 2 def plus_one(x): return x + 1
c2bccd3dc5edb3734482d4540c954292ae6bc85f
shun-lin/Shun-LeetCode-OJ-solutions
/Algorithm/ImplmentingQueueUsingStacks.py
1,718
4.40625
4
class MyQueue(object): def __init__(self): """ Initialize your data structure here. """ # stack is first in last out so in python we can use append to add and # pop front # we want to implement a queue which is first in first out self.stacks = [[], []] ...
4380229cf665be145aeedbcc1b2e725e7ab1046f
shun-lin/Shun-LeetCode-OJ-solutions
/Algorithm/invertBinaryTree.py
706
3.90625
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 invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ # runt...
e61fd75e6c1d687c4fa2af74773b776df071e28d
shun-lin/Shun-LeetCode-OJ-solutions
/Algorithm/LeafSimiliarTree.py
1,272
3.890625
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 leafSimilar(self, root1, root2): """ :type root1: TreeNode :type root2: TreeNode :rty...
c26d8aeb159043068959769ecf785895f7625952
shun-lin/Shun-LeetCode-OJ-solutions
/Algorithm/TwoSum.py
628
3.734375
4
# Given an array of integers, return indices of the two numbers such that they add up to a specific target. # You may assume that each input would have exactly one solution class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype...
8554864ba43f66ef0cde06d31354b372cedb36f4
vivekchand/puzzles
/5.py
299
3.6875
4
# SPOJ Problem 5. The Next Palindrome def is_palindrome(num): l = (str(num)) pal = 1 for i in range(len(l)): if l[i] != l[len(l)-i-1]: pal = 0 return pal t = int(raw_input()) for x in range(t): n = int(raw_input()) while True: n = n + 1 if is_palindrome(n): print n break
a6cf684d47958428cfc598b3ab401815cf09877f
plan-bug/LeetCode-Challenge
/microcephalus7/categories/sorted/922.my.py
469
3.5625
4
# 짝/홀 로 list 분리 # 홀,짝,홀,짝 순으로 list 합체 from typing import List class Solution: def sortArrayByParityII(self, A: List[int]) -> List[int]: odd = [i for i in A if i % 2 != 0] even = [i for i in A if i % 2 == 0] plus = [] for i in range(len(odd)): plus.append(even[i]) ...
3fd0a1b91997dd377e1c0cbd661e6caea3624880
plan-bug/LeetCode-Challenge
/microcephalus7/categories/linkedList/206.py
582
3.875
4
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: # head = [1,3,5,7,9] prev, curr = None, head # prev = None, curr = [1,3,5,7,9] while curr is not None: ...
864a40685f1388d99aa0a3fd149db4ff1db63eb7
plan-bug/LeetCode-Challenge
/microcephalus7/categories/Recursion/1137.1.py
325
3.625
4
class Solution: solutions = { 0:0,1:1,2:1 } def tribonacci(self, n: int) -> int: if n in self.solutions: return self.solutions[n] solution = self.tribonacci(n-1) + self.tribonacci(n-2) + self.tribonacci(n-3) self.solutions[n] = solution return solution ...
a8678e6fa975c5e7abcbf5e0adc03d089594cbd0
plan-bug/LeetCode-Challenge
/microcephalus7/categories/BFS/559.1.py
431
3.5
4
# 각 Node 의 children 들을 나열하고 그걸 list 에 새로 담는 형식 class Solution: def maxDepth(self, root: 'Node') -> int: if not root: return 0 stack = [root] res = 0 while stack: tem = [] res += 1 for i in stack: for j in i.children: ...
b91e402567bf8b9eb7aa1628d77c570367aa3d84
plan-bug/LeetCode-Challenge
/microcephalus7/categories/sorted/242.my.py
397
3.578125
4
# string 각 각각 list 로 변경 # 정렬 한 후 값 같으면 True 아니면 False from typing import List class Solution: def isAnagram(self, s: str, t: str) -> bool: return sorted(list(s)) == sorted(list(t)) and True or False solution = Solution() print(solution.isAnagram("anagram", "nagaram")) print(solution.isAnagram("cat", "d...
6efde4c737acf1d15a8ce20a26a0a0768a8453a7
plan-bug/LeetCode-Challenge
/microcephalus7/categories/queue/346.2.py
361
3.5
4
# deque 사용 # queue 의 첫번째가 t-3000 보다 커질때 까지 queue 첫번째 요소 제거 class RecentCounter: def __init__(self): self.queue = deque() def ping(self, t: int) -> int: queue = self.queue queue.append(t) while(queue and queue[0] < t-3000): queue.popleft() return len(queue)
d9e3e4885e15e10ad8a66afd17c7a28f29199ec5
plan-bug/LeetCode-Challenge
/landwhale2/easy/876. Middle of the Linked List.py
928
3.796875
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: cut = 0 def middleNode(self, head: ListNode) -> ListNode: new_head = ListNode() self.cut = self.length(head, 0) // 2 return self....
a10ddfb017e1d848c89281debd5abbe083ac1688
plan-bug/LeetCode-Challenge
/microcephalus7/categories/backtracking/46.py
246
3.625
4
# 순열 # 순서가 있는 조합 from itertools import permutations class Solution: def permute(self, nums): return list(map(lambda x: list(x), permutations(nums))) solution = Solution() print(solution.permute(["A", "B", "C"]))
5afdcecd441d656d8e7a599aa78a9ac4125a2c45
plan-bug/LeetCode-Challenge
/microcephalus7/categories/hashTable/1512.my.py
391
3.5625
4
# i,j 짝 맞춤 # comprehension 에 조건으로 해결 from typing import List class Solution: def numIdenticalPairs(self, nums: List[int]) -> int: return len([(i, j)for i in range(len(nums)) for j in range(len(nums)) if i < j if nums[i] == nums[j]]) solution = Solution() print(solution.numIdenticalPairs([1, 2, 3])) pri...
85edd52ca6731eba6bf89d41b568e0fdc923a313
plan-bug/LeetCode-Challenge
/microcephalus7/categories/linkedList/876.2.py
273
3.515625
4
class Solution: def __init__(self) -> None: self.arr = [] def middleNode(self, head: ListNode) -> ListNode: if head: self.arr.append(head) self.middleNode(head.next) else: return self.arr[len(self.arr)//2]
a6ead6e68dd46c3f13ff2dcbe94cd01e3a0f5504
plan-bug/LeetCode-Challenge
/microcephalus7/categories/greedy/1046.my.py
719
3.546875
4
# while 문 # list 길이에 따라 breake # list 안에서 최대값 2개 추출 (추출된 값 버림) # 최대값 각각 뺀 수 list 안에 삽입 (뺀 수 0일 시 삽입 안 함) from typing import List class Solution: def lastStoneWeight(self, stones: List[int]) -> int: while True: if(len(stones) == 1 or len(stones) == 0): break y = ma...
31680b38d1c94d927e3b550e7d1fec8dea9416c3
plan-bug/LeetCode-Challenge
/microcephalus7/categories/sorted/976.my.py
575
4.03125
4
# 정렬 후 iterable # 3수 묶어서 삼각형 법칙에 맞을 경우 list 넣음 # list 비어 있을 시 return 0 # list 안 비었을 시 return 최대값 from typing import List class Solution: def largestPerimeter(self, A: List[int]) -> int: A.sort() array = [sum(A[i:i+3]) for i in range(len(A)-2) if A[i+2] < sum(A[i:i+2])] re...
7e5a6b7ec127cfe6e82cf3f4b180799dce5f5734
plan-bug/LeetCode-Challenge
/microcephalus7/categories/hashTable/1002.py
496
3.640625
4
# A의 요소 전부 튜플로 변형 # 모든 요소 더 한 list 생성 # list 에서 count 한 수에 3씩 나누어 몫 만큼 새로운 요소에 더함 from collections import Counter from functools import reduce from typing import List class Solution: def commonChars(self, A: List[str]) -> List[str]: return list(reduce(lambda x, y: x & y, [Counter(A[i]) for i in range(len(...
bba3f7e394f1aa96c70691b9434e0c4baffc637c
LeeWannacott/python-text-editor
/python_terminal.py
7,973
3.640625
4
import tkinter as tk from tkinter.scrolledtext import ScrolledText import io, hashlib, queue, sys, time, threading, traceback import code class Pipe: """mock stdin stdout or stderr""" def __init__(self): self.buffer = queue.Queue() self.reading = False def write(self, data): sel...
09a4bf54f13dee45f673fcb7b8770c88ab7dc584
Vishnu8649/task3
/2/defaultdic.py
316
4.25
4
import collections as c def default(): ''' demonstrating working of default dict ''' d={1:'a', 2:'a', 3:'b', 4:'c',5:'d', 6:'c'} print 'Before reversal', d new=c.defaultdict(list) for k,v in d.items(): new[v].append(k) print 'Reversed dictionary is', dict(new) default()
9946cde9c118e8259319b543847c7fda23e48b75
Klimo22/Apps
/my list/Calculator.py
327
3.609375
4
from tkinter import * root = Tk() root.minsize(height = 400, width = 800) root.title('calculator') entry = Entry(root) entry.pack() label = Label(root) def cal(): label.config(text=''+ str(eval(entry.get()))) label.pack() button = Button(root, text='calculate', command = cal ) button.pack() root.mai...
e064c21b78829ef1a99ce2e205c7298cca798afc
gmaher/flask-react-be
/src/crypto/password.py
938
4.3125
4
import bcrypt def hash_password(pw, rounds=10): """ Uses the bcrypt algorithm to generate a salt and hash a password NOTE: ONLY PASSWORDS < 72 CHARACTERS LONG!!!! :param pw: (required) password to hash :param rounds: number of rounds the bcrypt algorithm will run for """ if not type(pw) ==...
04ec25075188b9c4cbae806786951d96205f4d32
hadiazb/Python
/probando-py.py
856
4.09375
4
matrizA = [] matrizB = [] matrizC = [] c = int(0) filasA = int(input("Ingresa las filas de A: ")) columnasA = int(input("Ingresa las columnas de A: ")) filasB = int(input("Ingresa las filas de B: ")) columnasB = int(input("Ingresa las columnas de B: ")) if columnasA != filasB: print("No existe solucion") else: pr...
3207b1deeb5506e7d1346291901a759cc2549fca
TianfangLan/LetsGoProgram
/Python/week_notes/week2_QueueADT_v1.py
1,718
4.34375
4
class EmptyQueueException(Exception): pass class Queue(): ''' this class defines a Queueu ADT and raises an exception in case the queue is empty and dequeue() or front() is requested''' def __init__(self): '''(Queue) -> Nonetype creates an empty queue''' # representation invariant ...
49b9733e6cf771eabffdda29869560808eb971d4
TianfangLan/LetsGoProgram
/Python/week_notes/week11_hash_tables.py
5,810
4.0625
4
from week4_SLL import * class HashTable(): ''' A very basic hash table that stores integer numbers assuming that collision never happens!''' def __init__(self, n): '''(HashTable, int) ->NoneType creates an empty list of length n''' self._array = [None]*n self._length = n ...
fbbc61c42e2b8540c29db63ab30514c38d7d9948
TianfangLan/LetsGoProgram
/Python/week_notes/week3_stack.py
3,000
4.3125
4
from week3_node import Node class Stack(): ''' represents a Stack implemented by a node list ''' def __init__(self): '''(Stack) ->NoneType initializes the references of an empty Stack''' self._size = 0 self._head = None def is_empty(self): '''(Stack) -> bool ...
9584eb1513bfa7ec1f22e1206b83b2615bdf5e75
ArthurHGSilva/Atividades-Python
/Exercícios_parte4/exercício5.py
630
3.515625
4
dep_inicial = float(input('Coloque o valor do depósito: ')) tx = float(input('Coloque a taxa de juros: ')) mes = 1 saldo = dep_inicial while mes <= 24: if mes < 2: dep_inicial = (dep_inicial * (tx / 100)) + dep_inicial print('Saldo do mês', mes, 'é %.3f' %dep_inicial) else: ...
f7068520fbd7e15129b46ca5995c0a305ec9e07c
ArthurHGSilva/Atividades-Python
/Exercícios_parte3/exercício8.py
552
4.125
4
num1 = float(input('Coloque o valor do primeiro número: ')) num2 = float(input('Coloque o valor do segundo número: ')) operacao = input('Coloque a operação desejada: ') if operacao == '+': resultado = num1 + num2 print('Adição\t', resultado) elif operacao == '-': resultado1 = num1 - num2 p...
7c22d525a20d77ed2ea46e671fd19ccd45c28c02
ArthurHGSilva/Atividades-Python
/Exercícios_parte2/exercício.cigarro.py
243
3.640625
4
cig_dias = int(input('Quantos cigarros por dia você fuma? ')) anos_fu = int(input('Há quantos anos você fuma? ')) total_cig = anos_fu * 365 * cig_dias red_vida = total_cig * (10/(60*24)) print('Você perdeu', red_vida, 'dias de vida')
1984f433935f426db72926f81b9255bb59b97174
ArthurHGSilva/Atividades-Python
/Exercícios_parte7/exercício4.py
200
3.90625
4
def triangulo(base, altura): return (base * altura / 2) base = float(input('Coloque o valor da base: ')) altura = float(input('Coloque o valor da altura: ')) print(triangulo(base, altura))
c6df86c1f8d26111ae0565d26734d20c42974058
junho222/python_section4
/4-3-1.py
497
4
4
#a = 'hello' #print(type(a)) #print(a[0:3]) #print(a[-1:]) #for t in a : #print(type(t)) #리스트 자료형(순서o, 중복o, 수정o, 삭제o) #선언 a = [] b = list() c = [0,0,1,2] d = [0,1,'car','apple','apart'] e = [0,1,['car','apple','apart']] #인덱싱 print("#========#") print('d -', type(d), d) print('d -', d[1]) print('d -', d[0]+d[...
a43fd3d57eb137748e534424d0e306207c38f3d1
Chunar5354/qrcode_learn
/set_keyword.py
582
3.515625
4
# 一个获得随机密码并生成其二维码的程序 import qrcode import random len_key = random.randint(11,16) index_key = 0 key_list = [] while index_key <= len_key: key_num = random.randint(33,122) # ASCII码的字符和数字、字母范围 key_word = chr(key_num) # ASCII码的转换 key_list.append(key_word) index_key += 1 keyword = ''.join(key_list) # 列表...
201354d22f018fa4d04e9a5bd8af11f54f936f13
Bloodhard/Repl.it
/Exercicio11.py
450
3.84375
4
def soma_lista(som): total = 0 for i in som: total= total+i return total som=[] neg=[] resultado=0 contador=0 while contador <=50: num=float(input('Digite um total de 50 numeros: \n')) if num >=0: som.append(num) print ('\nOs numeros positivos são:\n',som ) if num <0: neg.append(num...
9a38108148e79dceeb7444869a2a0e4734bd58e5
Bloodhard/Repl.it
/Exercicio6.py
232
3.875
4
dividendo= 1000 divisor= 1 resultado= 0 while divisor <= 50: resultado+= dividendo/divisor print(dividendo, '/', divisor,'=', resultado ) dividendo-=3 divisor+= 1 print('O resultado das expressões foram:', resultado)
17498cbb6c66f3015e2dcac3a40d1ada6a1326f7
Bloodhard/Repl.it
/Exercicio13.py
858
4
4
def cargos(): if idade >= 15 and idade <=17: menor.append(nome) return def maiores(): if idade >= 21: maior.append(nome) return def sala(): if salario >= 1500 and salario <= 2000: sal.append(salario) return def dinheirao(): if salario >= 3500: money.append(salario) return menor...
84d2d2299bb6b6447095c8b95128af18edb6e4ee
swathiswaminathan/shopping_list
/shopping_list.py
905
4.03125
4
shopping_list = [] def add_item(item, list): if item.lower() in list: print "%s is already in the list." % (item) else: list.append(item.lower()) return a_to_z(list) def a_to_z(list): return list.sort() def remove_item(item, list): if item.lower() not in list: print "%...
d53805112e8b8dd00c773d8ec5d0f546396de495
lbarrios/codejam
/2016/Qualification/A-Counting_Sheep/A.py
555
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- TOTAL_DIGITS=10 T = input() for testcase in range(1,T+1): N = input() result = "" if N == 0: result = "INSOMNIA" else: #print "N: %s"%N number, count = 0, 0 digits = [False for i in range(TOTAL_DIGITS)] while count < 10: number += N #print "Number: %s"...
2e75f9970869f09b5a419e5186dd1337f5f85038
GRCosta/vgp245
/Class 3/Assignment 3.py
1,878
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 25 16:32:24 2018 @author: grcos """ import unittest class TestClassMethods(unittest.TestCase): def test_hp(self): self.assertTrue("hp", 200) def tes_ph_dmg(self): self.assertEqual("ph_dmg", 100) if __name__ == '__main__': unitt...
a4256cef3ba9111e3fcce600799eb8088ae82345
vijaygao/jianzhioffer
/栈的压入弹出序列.py
1,410
3.84375
4
''' 输入两个整数序列,第一个序列表示栈的压入顺序, 请判断第二个序列是否可能为该栈的弹出顺序。 假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序, 序列4,5,3,2,1是该压栈序列对应的一个弹出序列, 但4,3,5,1,2就不可能是该压栈序列的弹出序列。( 注意:这两个序列的长度是相等的) ''' # -*- coding:utf-8 -*- class Solution: def IsPopOrder(self, pushV, popV): # write code here stack = [] while len(popV) != 0: ...
d9da29d4bad320f80b3355736e0fc45a4dfdc9ae
vijaygao/jianzhioffer
/跳台阶.py
1,113
3.65625
4
# -*- coding:utf-8 -*- class Solution: # 每次最多跳一步,或者两部 # def jumpFloor(self, number): # # write code here # if number == 0: # return 0 # if number == 1: # return 1 # if number == 2: # return 2 # if number >= 3: # temp = [1, 2...
483d92c6292cb81cb00a0a8f5908adc692fec421
maih1/DAA
/maze.py
1,273
3.6875
4
def printMaze(maze): for i in maze: print ("\t",i) def solvemaze(r, c): #destination (maze[n-1][n-1]) if (r==n-1) and (c==n-1): solution[r][c] = 1 return True if r>=0 and c>=0 and r<n and c<n and solution[r][c] == 0 and maze[r][c] == 0: solution[r][c...
920a4fda37027cde89d73bbc18a39a3c54ba01a8
warriorframework/Katanaframework
/katana/utils/directory_traversal_utils.py
7,463
3.640625
4
import glob import os import re import errno import shutil def get_sub_dirs_and_files(path, abs_path=False): """ Gets the direct child sub-files and sub-folders of the given directory Args: path: Absolute path to the directory abs_path: If set to True, it returns a list of absolute paths ...
8c5e5dae99043509cbb7900bb7cad95039596d01
pitcharath/PSIT
/Graph.py
490
3.984375
4
# importing the required module import matplotlib.pyplot as plt # line 1 points x1 = [1,2] y1 = [2,4] # plotting the line 1 points plt.plot(x1, y1, label = "line 1") # setting x and y axis range plt.ylim(0,5) plt.xlim(0,5) # naming the x axis plt.xlabel('x - axis') # naming the y axis plt.ylabel('y -...
100d8856267a9448a28480334657caa0f47899c0
mrklyndndcst/100-Days-of-Code-The-Complete-Python-Pro-Bootcamp-for-2022
/Intermediate/D018_Turtle_and_the_Graphical_User_Interface/exercise4.py
319
3.5
4
import turtle as t import random screen = t.Screen() t.colormode(255) def cc(): return random.randint(0, 255) timmy = t.Turtle() timmy.pensize(10) timmy.speed(0) run = True while run: timmy.forward(50) timmy.left(random.choice([0, 90, 180, 270])) timmy.color(cc(), cc(), cc()) screen.exitonclick()
d272d06fe24c55eb16adcb702dfa63bfcb3431d6
mrklyndndcst/100-Days-of-Code-The-Complete-Python-Pro-Bootcamp-for-2022
/Beginner/D002_Understanding_Data_Types_and_How_to_Manipulate_Strings/2.2.BMI_Calculator.py
271
4.0625
4
# 🚨 Don't change the code below 👇 height = input("enter your height in m: ") weight = input("enter your weight in kg: ") # 🚨 Don't change the code above 👆 # Write your code below this line 👇 a = float(height) b = int(weight) print(round(b/a**2))
54492efbf4c23f590bef414dcfc611dc28dde4a0
mrklyndndcst/100-Days-of-Code-The-Complete-Python-Pro-Bootcamp-for-2022
/Beginner/D004_Randomisation_and_Python_Lists/ProjectD4_Rock_Paper_Scissors.py
1,551
4.15625
4
import random rock = "👊" paper = "✋" scissors = "✌️" choices = [rock, paper, scissors] player = int(input(f"What do you choose? type 1 for {rock}, 2 for {paper} or 3 for {scissors}\n")) print("You choose") if player < 1 or player > 3: print("Invalid") ai = random.randint(1 , 3) print("Artificial Intell...
e999d005eff83eca21ec9e1f4acb28cc96ba4d0b
zhanglulu15/python-learning
/python学习基础及简单实列/basic learing 6.py
246
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 26 10:41:55 2018 @author: lulu """ count = 3 while count <= 5: print("the count less than 5",count) count = count + 1 else: print("the count greater than 5",count)
8e698e0466fe516b89ebe79c9d22a3091081c677
zhanglulu15/python-learning
/python学习基础及简单实列/baics learing4.py
611
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 26 10:18:32 2018 @author: lulu """ #continue 和 break 的用法 i = 0 while i < 10: i += 1 if i % 2 > 0: continue print(i) i = 2 while 30: #循环条件为一个具体的数字,表明循环条件肯定成立 print(i) i += 1 if i >10: break #这是一个无...
791ec2976479aa04d6d66a006b9931738cccffbb
zhanglulu15/python-learning
/python学习基础及简单实列/定义函数.py
433
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 29 19:36:58 2018 @author: lulu """ a = 10 tmp = 5 a = tmp a = 5 print(a) apple = 100 def fun(a): a = a + 10 return a print(fun(1)) a = 3 def fun1(a): a = a +9 return a print(fun1(a)) print(a) def fun2(mylist): mylist.append(...
9c87579c351c2490da2a0532e06c9ab82489b803
zhanglulu15/python-learning
/python学习基础及简单实列/练习4.py
406
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 19 21:23:28 2018 @author: lulu """ #计算三角形面积 a = float(input('输入边长a:')) b = float(input('输入边长b:')) c = float(input('输入边长c:')) if a+b < c or a+c <b or b+c <a: print('三角形不合法') else: s = (a + b + c)/2 area = s*(s-a)*(s-b)*(s-c)*0.5 prin...
9d126640e9d0d47e72cf5aab25c6964611bc6cb6
zhanglulu15/python-learning
/python学习基础及简单实列/untitled8.py
1,172
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 27 21:49:58 2018 @author: lulu """ """ 将一个整数分解质因数,例如:输入90,打印出 90 = 2*3*3*5 程序分析:对n进行质因数分解,应先找到一个最小的质数k,然后按下述步骤完成 step1:如果对这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可 step2:如果n小于或者大于k,则说明应该打印出k的值,并用n除以k的商,重复执行第一步 step3:如果n不能被k整除,则用k+1作为k的值,重复执行第一步 """ x = int(in...
a96646f9c07a2d778bb2e53a75502dc80be587ae
angelakarenzi5/Password-locker
/Credentials.py
1,899
3.703125
4
class Credentials: """ Class that generates new instances of Credentials """ Credentials_list = [] #Empty Credentials list def __init__(self, website_name,user_name,password): # docstring removed for simplicity self.website_name = website_name self.user_name = user...
52c689ac08f7020700ec0ede437162eb1c0e7f81
Valuoch/pythonClass
/pythonoperators.py
1,375
4.53125
5
#OPERATORS #special symbols in python to carry out arithmetic and logical computations #They include; #1.arithmetic- simple math operations eg addition, sustraction, multiplication(*), division(/), modulas(%), floor(//),exponent(**)etc #x=10 #y=23 #print(x+y) #print(x-y) #print(x/y) #print(x*y) #print(x%y) #print(x//y)...
e326da4da327918a2902444b5f7c533f1c96f575
rodolphefarrando/Trajectory-Prediciton-DAIT
/myclass/softmax.py
2,250
3.609375
4
import numpy as np from random import shuffle from past.builtins import xrange def softmax_loss_vectorized(W, X, y): """ Softmax loss function, vectorized version. Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array o...
105311d3b14debeffbb10bf3a9358ed683f764fd
def4ke/wfm-items
/icons/templates/arcanes/convert.py
1,276
3.5625
4
import os from PIL import Image def convert(image): border = 5 if not image: image = input('Image: ') with Image.open(image) as image_icon: print('Process %s' % image) image_icon = image_icon.convert('RGBA') # Resize texture height = 342 image_icon = image_...
223b14636c91e7c069540110fbd19173b556fac2
riot-girl/programming-club-2
/WeeklyChallenge_Week06_pamemart.py
1,451
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Level 2. Weekly Challenge 6: OOP Inheritance, Polymorphism and Interfaces """ __author__ = "Pam Martínez" __contact__ = "pamemart@cisco.com" __copyright__ = "Copyright 2021, Cisco Systems" __credits__ = ["MXC Programming Club, Miguel Gutiérrez"] __date__...
569fdb30e2d0c62bf97906913a77250064de3b97
colbeseder/gchq-christmas-puzzle-2015
/GCHQ christmas card.py
7,496
3.5
4
""" Solver for GCHQ Christmas Card Puzzle 2015 """ from itertools import combinations from data import * ## rows_data, columns_data MAX_RUNS = 25 # Don't want to leave it running all day UNKNOWN = 0 # Or blank FILLED = 1 EMPTY = 2 symbols = {} symbols[UNKNOWN] = "?" symbols[FILLED] = "X" #"\u25a0" symbols[EMPTY]...
fa69e98f0a0136e20e37b3eecdff769fe5d581d6
verizm/codeforces
/elefant.py
187
3.78125
4
coord = int(input("")) steps = [5, 4, 3, 2, 1] counter = 0 for step in steps: didvizion = coord // step counter += didvizion ost = coord % step coord = ost print(counter)
9fabf40c63fa8f3fa92ae1d095d03f740cd08981
verizm/codeforces
/chat.py
141
3.875
4
s = input("") hello = "hello" i = -1 try: for char in hello: i = s.index(char, i + 1) print('YES') except: print('NO')