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
04a2c18e0fbf6bf7fe89944932797c44dd4a079c
siyeons/ALGORITHM
/Leetcode/Array/stock.py
292
3.5625
4
def maxProfit(prices) -> int: max_price = 0 for i, price in enumerate(prices): for j in range(i, len(prices)): min_price = min(prices[i], prices[j]) max_price = max((prices[j] - min_price), max_price) print(max_price) maxProfit([7, 1, 5, 3, 6, 4])
5d8449618d74df499912d92126f720a9b7bee095
wan-h/Brainpower
/Code/Tools/Opencv/findContours.py
646
3.609375
4
# coding: utf-8 # Author: wanhui0729@gmail.com ''' 找轮廓 ''' import cv2 import numpy as np # 构造图像 image = np.zeros([224, 224, 3]) image[100: 150, 100: 150, :] = 255 image = image.astype(np.uint8) # 需要进行灰度转换 gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 找轮廓 # mode为轮廓检索模式 # method为轮廓近似办法 contours, hierarchy = cv2.f...
1763647d788bb762efadc842646acb981e903954
wan-h/Brainpower
/Code/leetcode/code/factorial-trailing-zeroes.py
1,280
3.890625
4
# coding: utf-8 # Author: wanhui0729@gmail.com # https://leetcode.com/problems/factorial-trailing-zeroes/description/ ''' Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120, one tra...
1be762f3c6167d90b97ff2e764d0b160f2ffdc33
wan-h/Brainpower
/Code/leetcode/code/ugly-number.py
1,050
3.859375
4
# coding: utf-8 # Author: wanhui0729@gmail.com # https://leetcode.com/problems/ugly-number/description/ ''' Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example 1: Input: 6 Output: true Explanation: 6 = 2 × 3 Example...
73ca2c5ba03eaee1c7218cb42da9a4b5e44d92c1
wan-h/Brainpower
/Code/language/Python/grammer/itertools/count_example.py
295
3.625
4
# coding: utf-8 # Author: wanhui0729@gmail.com from itertools import count ''' def count(firstval=0, step=1): x = firstval while 1: yield x x += step ''' start = 1 step = 2 c = count(start, step) for v in c: print(f"Get count value: {v}") if v > 10: break
199bcf8d16f3da10c847145937b5aba7c5e17c00
wan-h/Brainpower
/Code/leetcode/code/remove-covered-intervals.py
1,485
3.734375
4
# coding: utf-8 # Author: wanhui0729@gmail.com # https://leetcode.com/problems/remove-covered-intervals/ ''' Given a list of intervals, remove all intervals that are covered by another interval in the list. Interval [a,b) is covered by interval [c,d) if and only if c <= a and b <= d. After doing so, return the number...
0da02c917c58ed21c189b2f40a5f82c5f013cfa4
wan-h/Brainpower
/Code/CS/DesignPatterns/TransferObjectPattern.py
1,819
3.78125
4
# coding: utf-8 # Author: wanhui0729@gmail.com # 创建传输对象。 class StudentVO(object): def __init__(self, name: str, rollNo: int): self.name = name self.rollNo = rollNo def getName(self): return self.name def setName(self, name: str): self.name = name def getRollNo(self): ...
07ce601c5beba090e3d3438148d516923b788314
wan-h/Brainpower
/Code/leetcode/code/valid-palindrome.py
1,645
3.859375
4
# coding: utf-8 # Author: wanhui0729@gmail.com # https://leetcode.com/problems/valid-palindrome/description/ ''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1:...
070b9f42dd4b162225be1ad5e59ab3bfc49fcef0
wan-h/Brainpower
/Code/language/Python/grammer/utils/timer.py
1,289
3.703125
4
# coding: utf-8 # Author: wanhui0729@gmail.com ''' 定时器实现 ''' import time import sched from datetime import datetime from threading import Timer ''' 使用threading模块定时器 ''' def threading_timer(inc): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) # time.sleep(3) 执行时间会和延时时间叠加 # Timer三个参数分别为:间隔时间、被调用触发的函数,...
08aee891d44cb5af88a8bfcb4e8f7935eb3a9dfd
wan-h/Brainpower
/Code/language/Python/grammer/utils/bisect_.py
864
3.546875
4
# coding: utf-8 # Author: wanhui0729@gmail.com ''' 二分搜索 ''' import bisect import random HAYSTACK = [1, 4, 5, 6, 8, 12, 15, 20, 21, 23, 23, 26, 29, 30] NEEDLES = [0, 1, 2, 5, 8, 10, 22, 23, 29, 30, 31] ROW_FMT = '{0:2d} @ {1:2d} {2}{0:<2d}' def demo(bisect_fn): for needle in reversed(NEEDLES): posit...
da56bfc5e0d549f6b37a4bf334d2f7e6d792cfc1
wan-h/Brainpower
/Code/CS/DesignPatterns/AbstractFactoryPattern.py
3,242
3.859375
4
# coding: utf-8 # Author: wanhui0729@gmail.com # 为形状创建一个接口 class Shape(object): def draw(self): pass # 实现shape的实体类 class Rectangle(Shape): def draw(self): print("Inside Rectangle::draw() method.") class Square(Shape): def draw(self): print("Inside Square::draw() method.") class Circ...
14c5c4f1f7b5cfad967efab0316a7fcbd1b192a9
wan-h/Brainpower
/Code/CS/DesignPatterns/CompositeEntityPattern.py
1,475
3.546875
4
# coding: utf-8 # Author: wanhui0729@gmail.com # 创建依赖对象。 class DependentObject1(object): data = "" def setData(self, data: str): self.data = data def getData(self): return self.data class DependentObject2(object): data = "" def setData(self, data: str): self.data = data ...
2a74e625036220952780694421fa956cfbed26e5
ArtakSukiasyan/TheBisectionMethod
/The_Bisection_Method/The_Bisection_Method.py
271
3.8125
4
def F(x): return pow(x,3)-x-1; def X(a,b): return (a+b)/2 a=1; b=2; E=1e-2; x=X(a,b) k=0 while abs(F(x))>E: if ((F(a)*F(x))<0): b=x else: a=x k+=1 x=X(a,b) print ("x = ", x) print ("step is equal ", k)
b7ac37f68b8e9f4a4118f24acfad3613ba33908f
macrocj/Python
/Stacks_and_Queues/Print_LinkedList_in_reverse_order.py
1,097
3.828125
4
''' Author: '' Created on '10/4/2018' Version: 1.0 ''' from builtins import range class LinkedList: def __init__(self): self.head = None class ListNode: def __init__(self, data, next): self.data = data self.next = next def append(self,data): new_node = sel...
f25076287a74b5b714d7fbf1521db6e07cec81dc
macrocj/Python
/Linked_list/remove_Kth_last_element_from_Linklist.py
2,788
3.90625
4
#Author: JC #Date: 9/9/2018 #Version: 1.0 #remvoe the kth last element from a linked list # Kth last element means it count backward class ListNode: def __init__(self, data): self.data = data self.next = None class LinkList: def __init__(self): self.head = None def append(self,data)...
e678be2c98479af58d6e52b3bb64e59f6ca79fa2
macrocj/Python
/String/Snake_string.py
583
3.796875
4
#Author: JC #Date: 8/12/2018 #Version: 1.0 def snake_string(s): result = [] # output the first row, i.e., s[1], s[5]. s[9] for i in range(1, len(s), 4): result.append(s[i]) # output the second row, i.e. s[0], s[2],s[4] for i in range(0, len(s), 2): result.append(s[i]) # output t...
e11971fc47565b2584b19066b99421aa03df2def
macrocj/Python
/Recursion/online_random_sample.py
710
3.515625
4
#Author: JC #Date: 7/26/2018 #Version: 1.0 import itertools, random def online_random_sample(stream, k): # Store the first k elements. sampling_results = list(itertools.islice(stream,k)) # Have read the first k elements num_seen_so_far = k for x in stream: #num_seen_so_far += 1 # G...
255cf54629ee31650beb5e29c039d5d62c748d31
macrocj/Python
/Linked_list/Test_for_Cyclicity.py
2,628
3.734375
4
#Author: JC #Date: 9/8/2018 #Version: 1.0 class ListNode: def __init__(self,data): self.data = data self.next = None class Node: def __init__(self, data, next=None): self.next = next self.data = data class Linklist: def __init__(self): self.head = None def append...
772ae32538f95a9d3d9094843e43a60098fa8fe6
macrocj/Python
/Linked_list/Cyclic_right_shift.py
2,526
3.921875
4
#Author: JC #Date: 9/30/2018 #Version: 1.0 # write a program that takes as input as singly linked list # and a nonnegative interger k, and return the list # cyclically shifted to the right by k. class LInkList: def __init__(self): self.head = None class ListNode: def __init__(self, data, next...
dacf4d65918a24c48658736bf7c3b30afa7fcb45
2008winstar/python
/demo7.py
204
3.5
4
import sys def unique_list(a_list): return list(set(a_list[:])) lst = [1, 2, 3, 3, 5, 7, 8, 2, 1, 8] print(unique_list(lst)) dt = { 'abc': 3 } print(dt.get('abc')) print(sys.getrefcount(5))
087a936728d5675f60407495eba4a43775ac16b8
2008winstar/python
/algorithm/gcd.py
109
3.53125
4
def gcd(p, q): """求最大公约数""" return p if q == 0 else gcd(q, p % q) print(gcd(120, 20))
dcfd58f478a014b6d0a329b1bc645abcc593fcf8
wd-hub/cam_intrinsic_calibration_single_image
/main.py
8,444
4.09375
4
# CS231A Homework 1, Problem 3 import numpy as np from utils import mat2euler import math ''' COMPUTE_LINE_EQUATIONS points - a list of two points on a line as [[x1, y1], [x2, y2]] Returns: coefficients a, b, c of line ax + by + c = 0 ''' def compute_line_equation(points): pt1 = points[0] pt2 = points[...
e37de75b4b15d71da1d709b52889d49cbef78bd8
volodiny71299/Right-Angled-Triangle
/02_number_checker.py
1,010
4.3125
4
# number checker # check for valid numbers in a certain range of values # allow float def num_check(question, error, low, high, num_type): valid = False while not valid: try: response = num_type(input(question)) if low < response < high: return response ...
72fec5c4ecd14a1f4827e7e0e31a2238252b993b
volodiny71299/Right-Angled-Triangle
/04_SOHCAHTOA_v3.py
4,070
4.09375
4
# work out angle length using inverse(ratio) # https://stackoverflow.com/questions/46958547/finding-an-unknown-length-of-a-side-using-sohcahtoa-trigonometry # checks for valid input from the user, keeps going until valid def string_check(choice, options): for var_list in options: # if the unit is valid...
2571fb011cab5aed53fa2d7a10bb66470982bbf9
volodiny71299/Right-Angled-Triangle
/01_ask_what_calculate.py
962
4.40625
4
# ask user what they are trying to calculate (right angled triangle) valid_calculations = [ ["angle", "an"], ["short side", "ss"], ["hypotenuse", "h"], ["area", "ar"], ["perimeter", "p"] ] calculation_ok = "" calculation = "" for item in range(0,3): # ask user for what they are trying to cal...
856568a6db9ad1b0a752788aecfd5167728f988d
DixinLuo/Jiuzhang
/Find_Peak_Element_II.py
1,816
3.71875
4
""" Link: http://www.lintcode.com/en/problem/find-peak-element-ii/ Question: There is an integer matrix which has the following features: The numbers in adjacent positions are different. The matrix has n rows and m columns. For all i < m, A[0][i] < A[1][i] && A[n - 2][i] > A[n - 1][i]. For all j < n, A[j][0] < A[j][1...
c1b8ec1d16ffea4c6c7f278ce6e504beb7f74a48
vanillamice/Semster-1-project
/gui.py
2,883
3.5
4
from tkinter import * import math def main(): ############################################################ #Decoder logic function def decoder(inpt): Z = int(inpt) #Logic W = math.floor(((math.sqrt(8*Z+1) - 1) / 2)) T = (math.pow(W,2)+ W)/2 global Y Y = Z - T ...
62f4557a62d00ea28319f6c8b9dbd85e8821eaa6
Tixon74/test
/Python/lesson_2/exersize_10.py
127
3.59375
4
int_num = int(input()) n = 0 while int_num > 0: if int_num % 10 == 5: n += 1 int_num = int_num // 10 print(n)
e7f44bdf1b5193d69f16bbcd46551a1397a61901
Tixon74/test
/Python/lesson_2/exersize_5.py
94
3.734375
4
int_num = int(input()) while int_num > 0: print(int_num % 10) int_num = int_num // 10
8f24a35c4ff8b1ebbb4e476e7ac6dd74d4a652dc
pjarcher913/python-challenges
/src/fibonacci/module.py
1,020
4.15625
4
# Created by Patrick Archer on 29 July 2019 at 9:00 AM. # Copyright to the above author. All rights reserved. """ @file asks the user how many Fibonacci numbers to generate and then generates them """ """========== IMPORTS ==========""" """========== GLOBAL VARS ==========""" """========== MAIN() ==========""" ...
5e970c9792a20ad8c23395058c0262450dc9ba35
Tskon/Pyton-gb
/lesson3/game.py
1,918
3.765625
4
import math while (True): answer = int(input('Введите число от 1 до 100: ')) if (1 > answer or answer > 100): print('Неверный ввод') else: break minNum = 1 maxNum = 100 lieCount = 0 isCpuRight = False tryCount = 0 while(True): tryCount += 1 cpuAnswer = math.ceil((minNum - 1) + (maxNum - (minNum - ...
d8086395f3fd65a1656505d0acdc011365fb14d8
Tskon/Pyton-gb
/lesson7/task1.py
407
4.09375
4
# Решить с помощью генераторов списка # Даны два списка фруктов. Получить список фруктов, присутствующих в обоих исходных списках. list1 = ['Банан', 'Яблоко', 'Апельсин'] list2 = ['Банан', 'Груша', 'Апельсин'] print([fruit for fruit in list1 if fruit in list2])
cfc949e732347cebc4b073cc891826075cb9520e
julianvalerio/ExemploPython
/Listas/Listas.py
1,817
4.1875
4
import copy #lista de listas ou matrizes notas = [['nota1', 'nota2', 'nota3'], [7, 8.2, 6]] print(notas[0][1],notas[1][1]) #uso do for# nomes = ['julian', 'rodrigues', 'valerio'] #for i in ['julian', 'rodrigues', 'valerio'] for i in range(len(nomes)): print('Indice '+str(i)+ ' descrição ' + nomes[i]) #dessa f...
a6f02ea2ddfb943c67836820441671faae76dafb
julianvalerio/ExemploPython
/aula5/advinhaNum.py
647
4.09375
4
#jogo para advinhar numero sorteado import random def verificaNum(numsec): for num in range(1,7): numero=int(input('Tente um numero ')) if numero < numsec: print('O numero sorteado é maior') elif numero > numsec: print('O numero sorteado é menor') else: ...
023adfd4d89632f1c35f383442fe0cb73862699d
kontur-courses/clean-code
/python/Chess/location.py
732
3.96875
4
class Location: def __init__(self, x: int, y: int): self.x = x self.y = y def __str__(self): return f"({self.x}, {self.y})" def __eq__(self, other): if isinstance(other, Location): return self.x == other.x and self.y == other.y return False def __mu...
5331545298fce43f346628ac997e8eb92f244865
namntran/100_days_python3
/day1_print.py
240
3.859375
4
#print function print("Day 1 - Python print function") print("The function is declared like: ") print("print('what to print')") print("Hello world!\nHello world!\nHello world!") print("Hello" + " Angela") print("Hello" + " " + "Angela")
cde1f10a689c4e1e582263526dcf2216841fba87
Biuku/Graph-Theory----The-Game
/xxalgo.py
3,379
3.609375
4
""" April 29, 2021 """ import pygame import math as m from setup.printr import Printr from arr import Arr from plot import Plot from drawline import DrawLine class Algo(Arr): def __init__(self, win): pygame.init() self.win = win super().__init__() self.printr = Printr(self.win) ...
2e82025ba405e7452313d64e31b9c8aa886d6b41
LionWar22/Lista_de_exercicios
/ex07.py
215
3.625
4
print("Calcula area do trapazio") base_maior = float(input("Base maior: ")) base_menor = float(input("Base menor: ")) altura = float(input("Altura: ")) print("Area: {}".format(((base_maior+base_menor)*altura)/2))
907713923e03a90a8e76d56f8f51d4b5d6b7fb1c
guoqi1123/data-structure
/arraylist.py
1,460
3.890625
4
# my implementation of arraylist class ArrayList(object): # an arraylist data structure using python List def __init__(self): self.len = 1 self.appendPtr = 0 self.vals = [None for i in range(self.len)] def __repr__(self): string = "[" for i in range(self.appendPtr): string += str(self.vals[i]) if i...
24e0e7150ed8aada1a96e404dea1106ffc59b10f
lordlycastle/F21GP-Processing
/flocking/physics_object.py
1,025
3.5625
4
from vector3 import Vector3 class PhysicsObject(object): def __init__(self, mass=1, position=Vector3(), velocity=Vector3(), rotation=Vector3(), acceleration=Vector3()): self.mass = mass self.position = position ...
428d3ff299c28971a56b3100e84ece3398ee0f38
opaleva/Small-Projects
/Loan-Calculator/console-loan-calculator.py
2,338
3.84375
4
from math import ceil, log def calculate_time(loan_principal: int, payment: float, i: float) -> str: years, months = divmod(ceil(log(payment / (payment - i * loan_principal), 1 + i)), 12) if months == 0: return f"It will take {years} years to repay this loan!" elif months == 1: return f"It...
98020dfa94c5bd00b8e10d4edd30ccfbc7aa3df2
phu-n-tran/LeetCode
/monthlyChallenge/2020-09(septemberchallenge)/9_29(**)WordBreak.py
3,352
3.96875
4
# -------------------------------------------------------------------------- # Name: Word Break # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if ...
2da62f4d1ad3daede829cf1f0f9968a89e3a3327
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_23_CountTreeNodes.py
3,283
4.25
4
# -------------------------------------------------------------------------- # Name: Count Complete Tree Nodes # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a complete binary tree, count the number of nodes. Note: 1. Definition of ...
c4cccf258eab393d27882e0e80b006df10784546
phu-n-tran/LeetCode
/monthlyChallenge/2020-05(mayChallenge)/5_02_jewelsAndStones.py
1,349
4.15625
4
# -------------------------------------------------------------------------- # Name: Jewels and Stones # Author(s): Phu Tran # -------------------------------------------------------------------------- """ You're given strings J representing the types of stones that are jewels, and S representing the s...
234bb4077ed44e440f12ab1816ef81a47c60f7b7
phu-n-tran/LeetCode
/monthlyChallenge/2020-09(septemberchallenge)/9_05_AllElementsInTwoBinarySearchTrees.py
3,954
4.125
4
# -------------------------------------------------------------------------- # Name: All Elements in Two Binary Search Trees # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given two binary search trees root1 and root2. Return a list containing al...
d5f26636ceb79648e09bf8c20946ed28cd30e1be
phu-n-tran/LeetCode
/monthlyChallenge/2020-10(octoberchallenge)/10_07_RotateLinkedList.py
3,816
4.375
4
# -------------------------------------------------------------------------- # Name: Rotate List (Linked List) # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a linked list, rotate the list to the right by k places, where k is non-negative. ...
e06c8dc685efe8ac8878f2a5b54ee456edb9c882
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_28_ReconstructItinerary.py
3,742
4.3125
4
# -------------------------------------------------------------------------- # Name: Reconstruct Itinerary # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a list of airline tickets represented by pairs of departure and arrival airports [from...
0482288b53ef2ee63980d4d388ae8dc7d9b6ae7f
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_29_UniquePaths.py
2,214
4.5
4
# -------------------------------------------------------------------------- # Name: Unique Paths # Author(s): Phu Tran # -------------------------------------------------------------------------- """ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...
ccb914482f1d42315f9a80f933a9c3e49f22ae94
phu-n-tran/LeetCode
/monthlyChallenge/2020-07(julychallenge)/7_12(*)ReverseBits.py
2,902
3.53125
4
# -------------------------------------------------------------------------- # Name: Reverse Bits # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 000000101001010000011110100...
35663c24eb56dcd1532806c3f048d292b9665df8
phu-n-tran/LeetCode
/monthlyChallenge/2020-07(julychallenge)/7_22_BinaryTreeZigzagTraverse.py
4,523
4.34375
4
# -------------------------------------------------------------------------- # Name: Binary Tree Zigzag Level Order Traversal # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a binary tree, return the zigzag level order traversal of its nodes...
5211f0e668533aaf0bf7e085992db10889071a41
phu-n-tran/LeetCode
/monthlyChallenge/2020-09(septemberchallenge)/9_21(***)CarPooling.py
4,136
3.84375
4
# -------------------------------------------------------------------------- # Name: Car Pooling # Author(s): Phu Tran # -------------------------------------------------------------------------- """ You are driving a vehicle that has capacity empty seats initially available for passengers. The vehic...
19b982e988ec7216dbcf3e8a0b086118420a54c5
phu-n-tran/LeetCode
/monthlyChallenge/2020-10(octoberchallenge)/10_12_BuddyStrings.py
4,638
4
4
# -------------------------------------------------------------------------- # Name: Buddy Strings # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given two strings A and B of lowercase letters, return true if you can swap two letters in A so the r...
c143b389b2ae888603c7d70e27f3267fcf4a71f6
phu-n-tran/LeetCode
/monthlyChallenge/2020-08(augustchallenge)/8_16(**)BuyAndSellStock3.py
4,073
4.5625
5
# -------------------------------------------------------------------------- # Name: Best Time to Buy and Sell Stock III # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Say you have an array for which the ith element is the price of a given stock on da...
73daf20cf998a47a6ef0c1787983695e64bee1e8
phu-n-tran/LeetCode
/monthlyChallenge/2020-09(septemberchallenge)/9_30_FirstMissingPositive.py
4,136
4.03125
4
# -------------------------------------------------------------------------- # Name: First Missing Positive # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given an unsorted integer array, find the smallest missing positive integer. Example 1: ...
68cb6a414b42c04874e1a204a7bd2ffd16f3dba9
phu-n-tran/LeetCode
/monthlyChallenge/2020-07(julychallenge)/7_02_BTLevelOrderTraversal2.py
2,801
4.21875
4
# -------------------------------------------------------------------------- # Name: Binary Tree Level Order Traversal II # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a binary tree, return the bottom-up level order traversal of its nodes'...
e2ea95ec0f13c3367ab83aa0709e489909e6e4a6
phu-n-tran/LeetCode
/monthlyChallenge/2020-07(julychallenge)/7_30(***)WordBreak2.py
5,771
3.859375
4
# -------------------------------------------------------------------------- # Name: Word Break II # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add space...
8b44d5e5d54030407e3a5837d8dd2975a1351ef1
phu-n-tran/LeetCode
/monthlyChallenge/2020-09(septemberchallenge)/9_17(***)RobotBoundedInCircle.py
4,858
4.125
4
# -------------------------------------------------------------------------- # Name: Robot Bounded In Circle # Author(s): Phu Tran # -------------------------------------------------------------------------- """ On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can rec...
d185f50d94c5554bf274bfe32d3a967af95de8d2
phu-n-tran/LeetCode
/monthlyChallenge/2020-10(octoberchallenge)/10_11()RemoveDuplicateLetters.py
2,180
3.625
4
# -------------------------------------------------------------------------- # Name: Remove Duplicate Letters # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a string s, remove duplicate letters so that every letter appears once and only onc...
5b5cda38002926df07c4809361992ba67ed62c2a
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_18_HIndex_V2.py
2,119
4.25
4
# -------------------------------------------------------------------------- # Name: H-Index II # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a re...
862417cfb9e359619f04610c0a1ee27492e43ddc
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_13_LargestDivisibleSubset.py
2,169
4.15625
4
# -------------------------------------------------------------------------- # Name: Largest Divisible Subset # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a set of distinct positive integers, find the largest subset such that every pair (S...
7a9993af1e06e3306ecae27f31a5a84d890d402b
phu-n-tran/LeetCode
/monthlyChallenge/2020-07(julychallenge)/7_23_SingleNumber3.py
2,379
3.921875
4
# -------------------------------------------------------------------------- # Name: Single Number III # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given an array of numbers nums, in which exactly two elements appear only once and all the other...
11a322f4ea19971ade4c1402a54a276d99a29469
FailBoatBigBrains/materiais-feitos
/intro/blocos.py
248
3.953125
4
words = ['cat', 'window', 'defenestrate'] number = 0 for word in words: number = number + 1 print("estou na iteração ", number) print(word) if True: print('dentro do if') else: print('dentro do else') print('fora de tudo')
89ca3fa4f2b2d38489041805ba6f1e3d5a044c75
FailBoatBigBrains/materiais-feitos
/loops/break.py
300
4.09375
4
""" Break significa: pare ESSA iteração mas NÃO vá a proxima iteração! """ for number in range(5): print('number = ', number) if number%2 == 0: print(number, ' é par') else: print('entrou break, PARE ESSE FOR') break print(number, ' era par')
4400020fc8ef675a1d97c4f0971005d21576e8a8
hongviet97/codeForces
/231A.py
145
3.53125
4
n = int(input()) counter = 0 for i in range (0, n): x = input() # prin5t(x) if x.count("1") >= 2: counter += 1 print(counter)
4b6dd21b7fc6a84c5b457ffbce97d484d72ee84a
dlgiang/python-practice
/03-list-less-than-ten/list-less-than-ten.py
290
3.78125
4
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] inputNum = int(input("Input a number: ")) def findLessThan(selectNum): result = [] for number in a: if number < selectNum: result.append(number) return result result = findLessThan(inputNum) print(result)
478a441612c081505ac9d3a72bc39a30895f683b
gersonmontenegro/python_basic_course
/diccionarios.py
799
3.84375
4
my_dict ={ 'David': 35, 'Erika': 32, 'Jaime': 50 } # print(my_dict['Erika']) # print(my_dict.get('Juan', 20)) # print(my_dict.get('Jaime', 20)) # reasign my_dict['Jaime'] = 20 # add new key my_dict['GRS'] = 41 # remove del my_dict['David'] # iterate by key # for key in my_dict.keys(): # print(f'{key} ...
2724b451390bb25c1d9f25a8418c497940f89f2e
gersonmontenegro/python_basic_course
/listas.py
1,107
3.6875
4
my_list = [1, 2, 3] my_list[1] = 99 my_list.append(4) my_list.append('Grs') # my_list.pop() # for i in my_list: # print(i) my_list_copy = my_list my_list_copy[0] = 114 # print(my_list) # print(f'1: {id(my_list)}, 2: {id(my_list_copy)}') # clone the list # 1 # my_immutable_list = list(my_list) # my_immutable_l...
a64bda1ba363eecd4b0ce26dedbc68820f6fe2b3
agulhane090398/Python
/MENU DRIVEN DATABASE PROBLEM.py
5,510
3.578125
4
import cx_Oracle ## CREATE CONNECTION dsn_tns = cx_Oracle.makedsn('DESKTOP-6N33FGK', '1521', service_name='XE') # if needed, place an 'r' before any parameter in order to address special characters such as '\'. conn = cx_Oracle.connect(user='hr', password='hr', dsn=dsn_tns) # if needed, place an 'r' before any pa...
0be05c6395f9c05bdb844feab0c0a1ead1432358
JayRizzo/Random_Scripts
/testy_class_init.py
1,144
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ============================================================================= """Answer for https://stackoverflow.com/q/52360498/1896134.""" # ============================================================================= class MyIntroduction(): """Doc PlaceHolder."...
cb8cb4431ddc8182c23adff86c9e3f1b21d1f63c
mily-chan/scripts-python
/calculadora.py
500
4.1875
4
def calculadora(n1, n2, operador): if operador == '+': print( n1 + n2) elif operador == '-': print( n1 - n2) elif operador == '*': print(n1 * n2) else: print( n1 / n2) n1 = int(input("Digite um número: ")) while True: operador= input("Digite o operador válido (+, -, *...
e4934d2af0069ac3c766b66f4e3e5328d251a43d
mily-chan/scripts-python
/Desafio da mamae.py
272
3.640625
4
print("==== N Ú M E R O S P A R E S ====") for i in range(0, 102, +2): print(i) print("===================================") print("==== N Ú M E R O S Í M P A R E S ====") for i in range(99, 0, -2): print(i) print("=======================================")
1b5a7ea658443fab4fb3ba7c1590180ae0bf478e
mily-chan/scripts-python
/desafio 39.py
634
4
4
from datetime import date atual = date.today().year nasc = int(input("qual foi o ano de nascimento: ")) idade = atual - nasc print("quem nasceu em {} tem {} anos em {}.".format(nasc, idade, atual)) if idade == 18: print("voce tem que se alistar imediatamente!") elif idade < 18: saldo = 18 - idade print(" fa...
413c7a341742e431e8fa21d100680017e6c1bdb5
mily-chan/scripts-python
/2 desafio.py
95
3.734375
4
n1 =input("escolha um numero") n2 =input("escolha outro numero") print("a soma e ",n1+n2,"!")
b817c9de833fa98c234580fd312ea66ef27cf9f5
demo112/1809
/PythonWeb/Flask/1809Flask/Falskday01/Day01/FlaskDemo01/run01.py
1,777
4.09375
4
from flask import Flask #将当前运行的主程序构建成Flask应用,以便接收用户(request)的请求并给出响应(response) app = Flask(__name__) #@app.route() 定义Flask中的路由,就是访问路径,'/'表示的是整个网站的根路径 #index()表示的是匹配上路由之后的处理程序-视图函数,所有的视图必须要有一个return用于表示响应的内容 # @app.route('/') # def index(): # print('这是输出在终端上的内容') # return "This is my first flask demo" #http:...
58714a9472d8c81820b342293edbcfba5652ff47
DSheth97/Competive-Coding
/lastocc.py
940
3.640625
4
''' # Sample code to perform I/O: name = input() # Reading input from STDIN print('Hi, %s.' % name) # Writing output to STDOUT # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail ''' # Write your code here s=input() c=input() v=int(input...
cd7b2c7816be7b1348e2663848f82b19146e0e17
DSheth97/Competive-Coding
/sdd.py
118
3.78125
4
s= input("enter string") #a=s.split("") a=[i for i in s] r=zip(a,a) print(list(r)) m="".join(list(r)) print(m)
a56839dfb787ef45e6aabcf927556face50a5e04
DSheth97/Competive-Coding
/jkeks.py
153
3.546875
4
def sq(x): return x*x l=[[1,2,3],[4,5,6],[7,8,9]] print(len(l)) for i in range(len(l)): result=map(sq,l[i]) print(list(result))
b5417062aa6dcb59479ede03ca230bc711ebc49e
Cod3Bende4/Problems
/P1_Start_Finish.py
1,841
3.953125
4
# Problem [Start_Finish]: # 1. There is a Maze[n*m Matrix] # 2. There are two poins inside the Maze, one is START and one is FINISH # 3. Take matrix size as input and take co-ordinates from users as START and FINISH, for example (1,1) for taking first element as START and (n,m) for taking last element as START, same g...
e860a058e51c4be54e10868bde50fe0322046c12
shonky/Programming-Practice
/Algorithms/insertionSort.py
865
4.09375
4
class InsertionSort(object): def __init__(self): array = [] key = 1 temp = 1 array = [] key = 1 temp = 1 def setArray(self, sArray): self.array = sArray def swap(self, keyI1, keyI2): temp1 = self.array[keyI1] self.array[keyI1] = self.array[keyI2] self.array[keyI2] = temp1 temp1 = 0 #include...
7826cb5e1727e067b3d0d68c65edff3a1b6fedb0
vijaynyalpelli/test_Apps
/Fibonacci.py
365
4.0625
4
def fibbonaci (number): if (number == 0): print ("No numbers") elif (number == 1): print ("0, ", end="") else: a = 0; b = 1; i = 0; while (i < number): print (a) b = a + b a = b - a i = i + 1 number = int(input(...
dc5ed68335e5e347ff63f49820da67d827fd1db6
batman950/shubh
/quiz_sqlite.py
760
3.75
4
import sqlite3 import json con = sqlite3.connect('mydata.db') con.execute("""CREATE TABLE IF NOT EXISTS quiz(ques varchar(50),opt varchar(50))""") cursor = con.cursor() cursor.execute("""INSERT INTO quiz(ques,opt) VALUES("what is an apple?","a:fruit b:veg")""") cursor.execute("""INSERT INTO quiz(ques,opt) VALUES("what...
297e50bd424edd128d12eff2f518d0195e15c66c
batman950/shubh
/class.py
604
3.765625
4
class Enemy: life = 3 def attack(self): print("ahh") self.life -= 1 def energy(self): if self.life <= 0: print("enemy dead") else: print('enemy ALIVE:life left=' + str(self.life)) enemy1 = Enemy() enemy2 = Enemy() enemy2.attack() enemy2.attack() en...
f8555d55d63104450ef3615a25bfcf5e0f89e865
batman950/shubh
/quiz.py
768
3.734375
4
import json print("demo quiz") name = input("please enter ur name:\n") print("get ready quiz begins shortly\n" "heres the first question\n") f = open("quiz.json", "r") data = f.read() d2 = json.loads(data) s = 0 s = int(s) print(d2[0],"\n") print(d2[1],"\n") ans = "a" opt = input("whats ur answer?please enter ...
3251c47210cc108e2c90b08fb10664504818710f
aichi-t/PongGame
/pong.py
2,916
3.75
4
# Simple pong game import turtle import winsound import sys # The window of the game win = turtle.Screen() win.title("Pong made by Aichi") win.bgcolor("black") win.setup(width=800, height=600) # Stops the window from refreshing win.tracer(0) # Score scoreA = 0 scoreB = 0 # Paddle A paddleA = turtle.Turtle() paddle...
9e94cef4720df15272e491ec6cb6237f80cf57c1
bodgergely/algos
/src/python/randomize.py
1,541
3.640625
4
import random import sys import math def swap(A, i, j): a = A[i] A[i] = A[j] A[j] = a def randomize_in_place(A): n = len(A) for i in range(0, n): r = random.randint(i, n-1) swap(A, i, r) def permute_with_all(A): n = len(A) for i in range(0, n): r = random.randint(0...
7431e717e09901dd3ee531fd1c94000993888af5
balaorcl/hello-streamlit
/markdown.py
705
3.78125
4
import streamlit as st import pandas as pd import numpy as np import plotly_express as px ''' # Club and Nationality App This very simple webapp asslows you to select and visualize players from certain clubs and nationalities. ''' df = st.cache(pd.read_csv)("football_data.csv") clubs = st.sidebar.multiselect("Show Pla...
9399a6f06adbc064f76c8e33ad63b45dbdc0295b
YuehChuan/python-design-patterns
/code/visitor.py
678
3.765625
4
class Node(object): def __init__(self, name, children=()): self.name = name self.children = list(children) def __str__(self): return '<Node %s>' % self.name class Visitor(object): @classmethod def visit(cls, node): yield node for child in node.children: ...
a0e16320f55255fedfeca55dabf8ebcfcc31cbd0
YuehChuan/python-design-patterns
/code/mvc.py
1,361
3.765625
4
class Model(object): products = { 'milk': {'price': 1.50, 'quantity': 10}, 'eggs': {'price': 0.20, 'quantity': 100}, 'cheese': {'price': 2.00, 'quantity': 10} } def get(self, name): return self.products.get(name) class View(object): def show_item_list(self, item_list):...
1de6d8fe5ea539e9ae52d551b9b1de971d3ff9f8
StoneChen142/ChenSt-CS
/Pong Game/Pong Game.py
20,014
3.65625
4
### SRC - This is a very impressive attempt at pong. You have clearly learnt a lot. ### SRC - We will now start looking at how we can use OOP to simplify the code. import pygame import random import math import time from pygame.locals import * def text_objects(msg, color, size): if size == "small": font =...
991b9c3589afa22aa0f210593e73f9eef4e03cf8
StoneChen142/ChenSt-CS
/Encryption/Encryption1.py
1,080
3.96875
4
# Encryption f=open("text.txt","rt") data=f.read() length=len(data) f.close() #Encrypt ### SRC - can you change this to a full Caeser Cipher by wrapping ### the letters, i.e. z should become c... encrypted_text="" i=0 while i<length: word=data[i] if word.islower(): encrypted_text = encrypted_text + c...
d610a26c9472ea5f23cae577951298e8b19fe21d
NaziaNishat/Computer_Data-Network_Security
/Assignment 1/CheckFrequency.py
1,568
3.828125
4
import re def printWords(s): # split the string s = s.split(' ') # iterate in words of string for word in s: # if length is even if len(word)==1: print(word) oneWord = [] twoWord = [] threeWord = [] with open("data.txt", "r") as my_file: for line in my_file: str = line.split(' ') for word i...
1bc671468def6d78f3232a66e7e4daa6ecced6b5
tkm5/TatlePython
/basic/if.py
447
3.984375
4
age = 20 # threshold age_alcohol = 21 age_drive = 18 if age >= age_alcohol: print("you can drink beer!") elif age < age_drive: print("You can't even drive") else: print("you are too young to drink beer but you can drive") if not 0 < age < 120: print("The value is invalid") # Nane a = None if ...
0d4a8efcd07413447880d4e8d388be1f5829514e
shadishahi/Assignment-2
/sum.py
168
4
4
sum=0 while True: n = input('Please Enter Your Number: ') if (n == 'exit'): break else: n = int(n) sum += n print(sum)
34ba10cc90456e512e2947b2bc534a5ae932871e
liuyzGIt/python_book
/algorithms_4/codes/02_sort_example.py
6,681
3.859375
4
class Example: def __init__(self, elems): self.elems = list(elems) def sort(self): pass def less(self, v, w): return v < w def exchange(self, i, j): self.elems[i], self.elems[j] = self.elems[j], self.elems[i] def show(self): return ...
da2015d009f2b06f24fe294492d93009570b1cc4
liuyzGIt/python_book
/algorithms_and_data_structures_using_python/codes/01_logicgate.py
2,853
3.765625
4
class LogicGate: """逻辑门基类""" def __init__(self, name): self.name = name self.output = None def get_label(self): return self.name def get_output(self): """获取逻辑门的输出""" self.output = self.perform_logic_gate() return self.output ...
6a70c6f480117894ccdeff9caeab40a6b71e30a7
Ipl-Abe/PythonCodes
/mytest.py
292
3.703125
4
import os import numpy as np from matplotlib import pyplot as ply msg = 'Hello World' mat1 = np.array([1,2,3]) print(msg) print(mat1) x = np.arange(5) y = (1,2,3,4,5) width = 0.3 yerr = (.1, .08, .1, .0, .5) #plt.bar(x, y, width, align='center',yerr=yerr, ecolor='r') pyplot.show()
1fd2a8cf948edc2bdc1f9a23189267e763037c6f
polyhedron-gdl/introduction-to-monte-carlo-for-finance
/2018/notebooks/py/n05_mcs_multi_asset_path.py
8,354
4.09375
4
# coding: utf-8 # ### Introduction to Monte Carlo Simulation in Finance # # Multiasset Simulation # # ## Cholesky Decomposition # # The **Choleski Decomposition** makes an appearance in Monte Carlo Methods where it is used to simulating systems with correlated variables. Cholesky decomposition is applied to the co...
343f817d61fd256be873c92f7bb96f640545d1d7
mike239x/small-projects
/fancy mouse/app.py
1,886
3.71875
4
import sys, pygame from math import * # expected size of the window size = width, height = 600, 400 #600, 400 class color: red = 250, 50, 50 violet = 238,130,238 lgreen = 0, 250, 0 black = 0, 0, 0 gray = 100,100,100 lgray = 210,210,210 white = 250,250,250 maze_layer = {} def draw_maze(s)...
f2616ddd2cc399f668dbfa9baf8fbcadb0c50040
lxzun/Hellow_world
/Baekjoon_codes/수_정렬.py
422
3.5625
4
def counting_sort(num, M): result = [-1] * len(num) C = [0] * (M + 1) for i in num: C[i] += 1 for i in range(M): C[i + 1] += C[i] for j in reversed(range(len(num))): result[C[num[j]] - 1] = num[j] C[num[j]] -= 1 return result N = int(input()) n...
3c0f0a521673804115a95c46c68918659c665424
lxzun/Hellow_world
/Baekjoon_codes/수_정렬2.py
417
3.796875
4
def heapsort(un, idx, size): M = idx l_idx = 2*idx + 1 r_idx = 2*idx + 2 if l_idx < size and un[l_idx] > un[M]: M = l_idx if r_idx < size and un[r_idx] > un[M]: M = r_idx if M != idx: un[M], un[idx] = un[idx], un[M] heapsort(un, M, size) N = int(input()) num = [int(in...