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 |
|---|---|---|---|---|---|---|
ac7dc6d68a7edbca700464651ae8dc253926786f | shuowenwei/LeetCodePython | /Medium/LC986.py | 1,285 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/interval-list-intersections/
https://labuladong.gitee.io/algo/4/32/138/
https://mp.weixin.qq.com/s/Eb6ewVajH56cUlY9LetRJw
LC1288, LC56, LC986
"""
class Solution(object):
def intervalIntersection(self, firstList, secondList):
... |
f783eb67fce72502d836672bf4d9d9c8c8b8568d | shuowenwei/LeetCodePython | /Easy/LC896MonotonicArray.py | 999 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/monotonic-array/
"""
class Solution(object):
def isMonotonic(self, A):
"""
:type A: List[int]
:rtype: bool
"""
increasing = True
decreasing = True
for i in range(len(A)-1):
... |
2d2e56586c7ffaadc9b2a89bdab2594da2c9a837 | shuowenwei/LeetCodePython | /Easy/LC206.py | 1,240 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/reverse-linked-list/
labuladong: https://labuladong.gitee.io/algo/2/17/17/
labuladong: https://labuladong.gitee.io/algo/2/17/18/
LC206
"""
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, nex... |
15bcb8c510f672993e48687c3e339fc8d627f86d | shuowenwei/LeetCodePython | /Easy/LC9PalindromeNumber.py | 534 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
LC009PalindromeNumber
https://leetcode.com/problems/palindrome-number/
"""
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if (x < 0 or ( x > 0 and x%10==0)):
return False
... |
ef41d18074c6fe5a888de9b272813fce50b1ad0b | shuowenwei/LeetCodePython | /Hard/LC315.py | 1,774 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/count-of-smaller-numbers-after-self/
https://leetcode.com/problems/count-of-smaller-numbers-after-self/discuss/445769/merge-sort-CLEAR-simple-EXPLANATION-with-EXAMPLES-O(n-lg-n)
find python version in the comments
# merge sort
"""
clas... |
ba01856a0e89ff753e0789e5de3451a84f701aba | shuowenwei/LeetCodePython | /Medium/LC792.py | 2,151 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/number-of-matching-subsequences/
LC392, LC792
"""
class Solution(object):
def numMatchingSubseq(self, s, words):
"""
:type s: str
:type words: List[str]
:rtype: int
"""
# solution 1: Bin... |
42bf70c29f39baf9ea87fba83ce7aba493d670e5 | shuowenwei/LeetCodePython | /Medium/LC162.py | 1,981 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/find-peak-element/
https://leetcode.com/problems/find-peak-element/discuss/50259/My-clean-and-readable-python-solution
LC162, LC153
"""
class Solution(object):
def findPeakElement(self, nums):
"""
:type nums: List[int]... |
778b1193d5e6b261d04b87f5018e002fe223d291 | shuowenwei/LeetCodePython | /Hard/LC1597TODO.py | 2,404 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression/
https://leetcode.ca/all/1597.html
refer to https://leetcode.ca/2020-04-14-1597-Build-Binary-Expression-Tree-From-Infix-Expression/
"""
class Node(object):
def __init__(self, val, lef... |
c2d5cd895201f9730a404d8decebd4d355c85de1 | shuowenwei/LeetCodePython | /Medium/LC1011.py | 1,429 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/
LC875, LC1011, lC1891
"""
class Solution(object):
def shipWithinDays(self, weights, days):
"""
:type weights: List[int]
:type days: int
:rtype: int
"""
... |
85b05995e1e41afb86b4d3d4795f09096a75c111 | shuowenwei/LeetCodePython | /Medium/LC583.py | 2,239 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/delete-operation-for-two-strings/
https://labuladong.gitee.io/algo/3/24/78/
https://mp.weixin.qq.com/s/ZhPEchewfc03xWv9VP3msg
LC53, LC1143, LC583, LC712, LC72, LC516
"""
class Solution(object):
def minDistance(self, word1, word2):
... |
1a60eb06b4c4236c4c1edc1229531260e779f29f | shuowenwei/LeetCodePython | /Easy/LC374GuessNumberHigherOrLower.py | 1,375 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/guess-number-higher-or-lower/
"""
# The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
# def guess(num):
class Solution(object):
def gue... |
c7dfcd2bf3ef2d5f01736af65ec10357a7b1f0b9 | shuowenwei/LeetCodePython | /Medium/LC314TODO.py | 1,503 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/binary-tree-vertical-order-traversal/
https://www.techiedelight.com/vertical-traversal-binary-tree/
LC314, LC987
Meta VO
"""
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val =... |
10cfe5e5de66a6c62386c92d7983f266fba1a92d | shuowenwei/LeetCodePython | /Medium/LC722.py | 1,266 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/remove-comments/
https://leetcode.com/problems/remove-comments/discuss/109210/Simple-Python-one-pass-with-clear-inline-explanation!!!
"""
class Solution(object):
def removeComments(self, source):
"""
:type source: Lis... |
7a3499473fd9658201011b06c5912b1d62b2c491 | shuowenwei/LeetCodePython | /Medium/LC138.py | 2,115 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/copy-list-with-random-pointer/
https://leetcode.com/problems/copy-list-with-random-pointer/discuss/258935/Detailed-Explanation-with-Pictures-C%2B%2BJavaScript
"""
# Definition for a Node.
class Node:
def __init__(self, x, next=None,... |
ada70994e5bc706e33eed63300b77eb30bf0fe18 | shuowenwei/LeetCodePython | /Medium/LC136.py | 746 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/single-number/
LC136, LC137, LC260
"""
class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
"""
The idea hinges on 3 properties of xor:
... |
90f07193f4135f6eae211b1d4ba51fe3463c8e75 | shuowenwei/LeetCodePython | /Medium/LC990.py | 2,236 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/
LC323, LC130, LC990, LC547, LC847
LC261, LC1135, LC1584
"""
class UnionFind(object):
def __init__(self, count):
self.cnt = count
self.parent = [i for i in range(co... |
0ba265b919b8300589a00e0de4814a3469b7a9b4 | shuowenwei/LeetCodePython | /Medium/LC1130.py | 1,035 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/
https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/discuss/340004/Python-Easy-DP
"""
class Solution(object):
def mctFromLeafValues(self, arr):
"""
:type arr: List[int]... |
52864630521d72d84c495793dd9db6172192a4d3 | shuowenwei/LeetCodePython | /Medium/LC372.py | 1,373 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/super-pow/
https://labuladong.gitee.io/algo/4/30/121/
LC172, LC793, LC204, LC372, LC268, LC50
"""
class Solution(object):
def superPow(self, a, b):
"""
:type a: int
:type b: List[int]
:rtype: int
... |
d222131ef24738e28562d536642ff6cc2d06ffff | shuowenwei/LeetCodePython | /Easy/LC746MinCostClimbingStairs.py | 1,875 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/min-cost-climbing-stairs/
solution link:
https://leetcode.com/problems/min-cost-climbing-stairs/discuss/190960/Easy-Python-solution-and-beat-100
"""
class Solution:
def minCostClimbingStairs(self, cost):
"""
:type ... |
5bb03f5ea55003bf288abba6147227e8797e6d73 | shuowenwei/LeetCodePython | /Easy/LC941.py | 755 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/valid-mountain-array/
"""
class Solution(object):
def validMountainArray(self, arr):
"""
:type arr: List[int]
:rtype: bool
"""
if len(arr) < 3:
return False
summit... |
76127e1392a2a4c21e0419fe631a859e3c0c5deb | shuowenwei/LeetCodePython | /Easy/LC69Sqrt(x).py | 640 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/sqrtx/
"""
class Solution:
def mySqrt(self, x: int) -> int:
if x == 1:
return 1
left = 0
right = x
while left < right:
mid = (left + right)//2
mid_squre = ... |
ae7b3bc9c61499a03d1ad15c1e2d62f77fa5ddff | shuowenwei/LeetCodePython | /Medium/LC1161.py | 1,053 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/
"""
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = righ... |
4cf75a589c24399cac2e3d3f2548d4f3c9be351b | shuowenwei/LeetCodePython | /Medium/LC236.py | 1,879 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
https://mp.weixin.qq.com/s/9RKzBcr3I592spAsuMH45g
LC235, LC236, LC1650
"""
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# ... |
0028fd93bff43d3d758133c1d7b9ca2dc5e832f6 | shuowenwei/LeetCodePython | /Easy/LC14.py | 720 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/longest-common-prefix/
"""
class Solution(object):
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
if len(strs) == 0:
return ''
res = ... |
c77fff387f40067196e009217d050d206df79402 | shuowenwei/LeetCodePython | /Hard/LC843.py | 1,022 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/guess-the-word/
https://leetcode.com/problems/guess-the-word/discuss/133862/Random-Guess-and-Minimax-Guess-with-Comparison
"""
# """
# This is Master's API interface.
# You should not implement it, or speculate about its implementation
#... |
d61a5fe6d5b68073a738d19b93e24a35695cc1d4 | luckymime28/Skyjam | /skyjam.py | 1,851 | 4.1875 | 4 | print("- If you need more info or you're confused type 'help'")
def help():
print("\n-So basically, this is my first exploit I ever created \n-My name is luckymime28, and this is my exploit skyjam.py \n-skyjam.py is a password combination maker and list creator \n-Simply follow the instructions on screen and you ... |
1c2ac0372cd46f24e4a6a18d3fb7808154166a31 | EthanCornish/AFPwork | /Chapter4-Functions-Tutorial#1.py | 759 | 4.125 | 4 |
# Function Tutorial
# Creating a main function
# In the main function print instructions and ask for a value
def main():
print('Hello')
print('This program will ask you for a temperature\nin fahrenheit.')
print('-----------------------------------------------------------')
value = int(input('Enter a ... |
cf9ef9b45f5695f58ebd3344624944d2a21fb4d1 | Eshan-bd/project_euler | /007.py | 372 | 3.84375 | 4 |
def findPrime(n):
i = 1
j = 3
primeNums = [2]
while i<n:
prime = True
for k in primeNums:
if ( j%k == 0 ):
prime = False
if prime == True:
i += 1
primeNums.append(j)
j += 2
print(primeNums[n])
def main():
find... |
13525c8a723e4a396c81bd5d556bbdcadc735166 | tespintom/itp-w1-create-box | /create_box/main.py | 321 | 3.796875 | 4 | """This is the entry point of the program."""
def create_box(height, width, character):
box = ''
for h in range(height):
row = ''
for w in range(width):
row += character
row += '\n'
box += row
return box
if __name__ == '__main__':
create_box(3, 4, '*')... |
09f9c14a1c2deb1654ab1ee0dd9961a03ffb8654 | zstall/Django-Python-Full-Stack-Web-Devloper-master | /Python_Level_One_Notes/func_check.py | 1,777 | 3.921875 | 4 | # def arrayCheck(nums):
# n = 0
# while n < (len(nums)-2):
# if nums[n]==1 and nums[n+1]==2 and nums[n+2]==3:
# print("True")
# return True
# n += 1
# print("False")
# return False
#
# arrayCheck([1, 1, 2, 3, 1])
# arrayCheck([1, 1, 2, 4, 1])
# arrayCheck([1, 1, 2... |
a6a0f34b11b3848d253a0b2b6b107b10d1cdc84e | zstall/Django-Python-Full-Stack-Web-Devloper-master | /Python_Level_One_Notes/lists.py | 858 | 3.984375 | 4 | # Lists
my_list = ['a', 'b', 'c', 'd', 'e']
my_list_two = ["string", 1, 2, 3, 4, 5, True, "abc", [1,2,3]]
print(len(my_list_two))
print(len(my_list))
print(my_list[-1]) # last item of the Lists
print(my_list[1:4]) # Can slice Lists
my_list[0] = "NEW"
print(my_list)
my_list.append("f")
print(my_list)
x ... |
c294d7078169d6e27181e0a820314ef2908d5803 | brulecap/coding_dojo | /Python/oop/car.py | 964 | 4.0625 | 4 | # declare Car class
class Car(object):
def __init__(self, price, speed, fuel, mileage):
self.price = price
self.speed = speed
self.fuel = fuel
self.mileage = mileage
if self.price > 10000:
self.tax = .15
else:
self.tax = .12
# This method displays all instance variables
def display_all(self):
pri... |
a3326358c93fbaf511290063c53c163e59cb97b3 | sigrung17/max_int | /sequence.py | 321 | 4.09375 | 4 | n = int(input("Enter the length of the sequence: ")) # Do not change this line
number1 = 0
number2 = 1
number3 = 2
summ = 0
print(number2)
print(number3)
for i in range(n-2):
summ = number1 + number2 + number3
print(summ)
number1 = number2
number2 = number3
number3 = summ ... |
b746b558b48869a769065b37a8ab347c443552d5 | TERESIA012/My-password-locker | /user_test.py | 1,569 | 3.5625 | 4 | import unittest #importing the unnitest
from user import User #importing the user Class from the user module
class TestUser(unittest.TestCase):
def setUp(self):
"""
setUp method runs before the tests
"""
self.new_user=User("Tess012","passWord") #create user object
def ... |
38bc3104b4e580662119afc61d4480bab16eaed6 | CA2528357431/python-note-class | /11/PythonApplication67.py | 369 | 3.859375 | 4 | # rewrite
class animal:
def eat(self):
print("eat")
def drink(self):
print("drink")
class cat(animal):
def miao(self):
print("miao")
def eat(self):
print("no")
class tom(cat):
def joke(self):
print("joke")
a=tom()
a.eat()
a.miao()
b=cat()
b.eat()
#r... |
087ff56bc467752a266fc1b0659814edc994703b | LottaR17/Instagram-Bot | /tags.py | 394 | 3.5 | 4 | import re
def Gettags(textfile):
with open(textfile) as file:
new_list = set([])
for line in file:
line.strip()
print line
temp_list = re.split(r'\W+',line)
for i in temp_list:
if i not in new_list:
new_list.add(i)
... |
b9a677cc9f0a33e268725ae6783918ef8da38fef | Rikerd/FileRenamer | /fileRenamer.py | 3,091 | 3.890625 | 4 | from pathlib import Path
# Find directory
def findDirectory()->Path:
'''Returns directory'''
pathInput = input("Enter folder directory: ")
path = Path(pathInput)
if path.exists() == False or not path.is_dir():
print("Directory not found!")
return findDirectory()
else:
print... |
96b0f2c36c2a68eb20748984a9bf68fba23df92a | DPastl/advent_of_code_code | /2020/day_1/day_1_solution_1.py | 747 | 3.53125 | 4 | def test_list(high_to_low_list, test_num):
for high_num in high_to_low_list:
sum = test_num + high_num
if sum == 2020:
return [test_num, high_num]
elif sum < 2020:
return None
if __name__ == '__main__':
with open ('input.txt', 'r') as inputfile:
numbers =... |
e5d7b2b6605af8e659e3f904aaf0ebb63717d670 | sjmoran/coding_questions | /connected_components.py | 936 | 3.640625 | 4 | from collections import deque, defaultdict
def bfs(G, root, explored, components):
q = deque([])
q.append(root)
explored.add(root)
components[root] = [root]
while len(q) > 0:
node = q.popleft()
neighbours = G[node]
for node in neighbours:
if node not in explored... |
00cf386591cc8fd3c76000485910db1c5428f682 | yakagika/stat_py | /temp/who_are_you.py | 1,553 | 4 | 4 | #-*- coding:utf-8 -*-
# あなたはなんの動物かと尋ねてニンゲンですと答えないと終わらない
# プログラムを作ってみます
# 先に変数を用意します
answer = input("あなたはなんの動物ですか?\n")
# while文でニンゲンですと答えるまで終わらないプログラムを書きます
while answer != "ニンゲン":
# 答えによっていろいろな反応を組み込んでみましょう
if answer == "ウチュウジン":
print("本当に!? 怖いのでさようなら!\n")
# while ループを終了します
break
e... |
76487462d2fd0c18698ce6abf7634792b1f1c7ae | shulinye/dotfiles | /scripts/forfun/mathquiz.py | 2,182 | 3.671875 | 4 | #/usr/bin/env python3
from fractions import Fraction
import operator
import random
import signal
from time import sleep
mapping = {'+': operator.add,
'*': operator.mul,
'-': operator.sub,
'/': operator.truediv}
operators = list(mapping)
TIMEOUT = 10
def handler(signum, frame):
r... |
5fc5f217581a224b9f22be8c91a204a7936a8885 | seanmortimer/udemy-python | /python-flask-APIs/functions.py | 856 | 4.1875 | 4 | def hello(name):
print(f'Heeyyy {name}')
hello('Sean ' * 5)
# Complete the function by making sure it returns 42. .
def return_42():
# Complete function here
return 42 # 'pass' just means "do nothing". Make sure to delete this!
# Create a function below, called my_function, that takes two arguments and... |
efec18c95cfde0c8c97dc1eaa0190bc71d81f04b | Magni0/Hangman-with-graphics | /src/main.py | 2,554 | 3.765625 | 4 | from terminal_display import UpdateDisplay
from graphic import HangManGraphic as gr
from retry import Retry
from get_word import GetWord
# called in order of how the man is drawn
man = [gr.head, gr.chest, gr.l_arm, gr.r_arm, gr.l_leg, gr.r_leg]
print("{:#^50}".format(" Welcome To HangMan "))
print("type quit at any t... |
832adbc3d78e3496afb1bb180fc1e8ed42be1b76 | LiamWoodRoberts/HackerRank | /Anagrams.py | 741 | 4.125 | 4 | '''Solution to:
https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem
function finds the number of anagrams contained in a certain string'''
def substrings(word):
strings=[]
for l in range(1,len(word)):
sub = [word[i:i+l] for i in range(len(word)-l+1)]
strings.append(sub)
... |
ea016cd090935ab61ec3df9f1d8a0e7d2003ca59 | amywangg/Development | /Python/collectionsModule.py | 967 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 29 09:53:53 2018
@author: awang3
"""
# Counter
from collections import Counter
one = [1,1,1,1,1,2,2,2,2,3,4,4,4,4,4,5,5,5]
print(Counter(one))
s = "Hi my name is amy how many words are there in the sentence"
words= s.split()
print(Counter(words))
c=Counter(words)
prin... |
5340e012ce08b8e1e96266e82025d97954a26f09 | Igor999/Figures | /Rectange2.py | 748 | 3.796875 | 4 | from Rectangle import Rectangle, Square, Circle
import math
rect_1 = Rectangle(3, 4)
rect_2 = Rectangle(12, 5)
# print(rect_1.get_area())
# print(rect_2.get_area())
square_1 = Square(5)
square_2 = Square(10)
# print((square_1.get_area_square()),
# square_2.get_area_square())
circle_1 = Circle(10, math.pi)
c... |
bc87ddd8f2ebe27d2c862732bf5452dbc44a044e | mihir30/STICKER-DEFECT-DETECTION | /matching.py | 1,219 | 3.71875 | 4 |
import cv2
import imutils
original = cv2.imread("master.png")
new = cv2.imread("m2.png")
#resize images
original = imutils.resize(original, height = 300)
new = imutils.resize(new, height = 300)
#find difference between the images
diff = original.copy()
cv2.absdiff(original, new, diff)
gray = cv2.cvtCo... |
1f7c5f1ff557332dffa6062b2936d58d1170d819 | dasaderi/SWDB-2015 | /presentations/python/tutorial_part_2/f1_scripts.py | 246 | 3.78125 | 4 | def distance_between_points_2d(p1, p2):
dx = p1[0] - p2[0]
dy = p1[1] - p2[1]
return (dx**2 + dy**2)**.5
p1 = (1,2)
p2 = (3,4)
print distance_between_points_2d(p1,p2)
p3 = (4,5)
p4 = (2,3)
print distance_between_points_2d(p3,p4)
|
c3d699c8b6426f134905725899e2f9166370e243 | DavidHld/condproject | /david.py | 8,510 | 3.984375 | 4 | import time
# Definição da Class que sustenta todo o código
class Condomino:
"""
Essa class é responsável não só por compreender as instâncias "Condômino" do nosso problema mas também por armazená-la e manipulá-la. Note que é iniciada uma lista
assim que a Class é chamada. Qualquer linha que não e... |
007645e7354dc34cd6c6ae8c68cfe5944741b909 | drishtiyadav/UCI-Data-Analytics | /03-Python/PyBank/main.py | 2,814 | 3.609375 | 4 | import os
import csv
csvpath = os.path.join('..', 'PyBank', 'PyBank.csv')
with open(csvpath, newline='') as csvfile:
PyBank = csv.reader(csvfile, delimiter=',')
csv_header = next(PyBank)
# Opening the output file to write the output
with open("Output.txt", "w") as outfile:
# Initializing the empty lists fo... |
019e067239dc0e737d7c2ba604b78d94bfe6e9f3 | chandankuiry/Churn_prediction | /Random_forest.py | 4,322 | 3.515625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 4 13:05:59 2018
@author: chandan
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('Churn_dataset.csv')
#delete the ID and DOB column .I deleted the DOB column because there are some DOB which is 1895
c... |
5b834237840d8632f5d3b630fcf8d2843ab2aaa9 | tordjoha/kattis-problems | /python/batter-up.py | 202 | 3.609375 | 4 | x = int(raw_input())
y = raw_input().split(" ")
numbers = map(float, y)
sumNum = sum(x for x in numbers if x > 0)
numNeg = sum(1 for number in numbers if number < 0)
slug = sumNum/(x-numNeg)
print(slug) |
167f6d923d2029347466e7ff3d4b0adcf2f04b9e | tordjoha/kattis-problems | /python/no-duplicates.py | 247 | 3.828125 | 4 | x = input().split()
wordList = [] #unique words
allList = [] #all words
for i in x:
if i not in wordList:
wordList.append(i)
for j in x:
allList.append(j)
if len(wordList) == len(allList):
print('yes')
else:
print('no')
|
62276b22a1df2bd167d2050df013859d26bca7b4 | tordjoha/kattis-problems | /python/quadrant.py | 176 | 3.859375 | 4 | x = int(raw_input())
y = int(raw_input())
if x > 0 and y > 0:
print("1")
elif x < 0 and y > 0:
print("2")
elif x < 0 and y < 0:
print("3")
elif x > 0 and y < 0:
print("4") |
8cb649a9590ff95b66948a23038a8c8689b8984f | tordjoha/kattis-problems | /python/apaxians.py | 96 | 3.765625 | 4 | input = raw_input()
x = input[0]
for char in input[1:]:
if char != x[-1]:
x += char
print(x)
|
b06163bce11c5edd9b1bdb64efc0ea9fa818f325 | tordjoha/kattis-problems | /python/sumsquaredigits.py | 486 | 3.671875 | 4 | numberOfDataSets = int(input())
def sumDigits(n, base):
total = 0
while (n > 0):
remainder = n % base
total += remainder*remainder
n = int(n/base)
return total
for i in range(0, numberOfDataSets):
dataSet = input().split(" ")
dataSetNumber = int(dataSet[0])
dataSetBase ... |
5eac6713f1d6422af6809f4386a3631154311fce | wulei2018/AI4K | /demo/scale_small.py | 706 | 3.78125 | 4 |
# 把生成花瓣案例的花瓣数据集缩小到1/4像素(供搭建超分模型使用)
import glob
import cv2
import os
images_path = "E:/ai_data/flower/images/*"
small_images_dir = "E:/ai_data/flower/small_images"
for image_file in glob.glob(images_path):
# print(image_file) #E:/data/images\image_00001.jpg
file_name = image_file.split('\\')... |
3ca4a8a67488fd15fe04dc9fe43b6d2888e27827 | wulei2018/AI4K | /RCAN_PyTorch/video2img_blend.py | 1,443 | 3.578125 | 4 | #图片全都放在一个目录下
import os
import subprocess
import argparse
#视频转图片
def getImg(video_path,img_path,suffix):
if not os.path.exists(img_path):
os.makedirs(img_path)
for file in os.listdir(video_path):
folder_file = '{}/{}'.format(video_path,file) #videos/gt/10091373.mp4
file_name,extend = os.... |
33c6e8b415f3ac6d59ec1d4f251f2f6fcc4bc21c | Devopriya-Tirtho/Artificial-Intelligence-Lab | /Lab 01/LabExercise1.py | 420 | 3.6875 | 4 | tupleList1=[('child','Rakib','Hasib'),('child','Sohel','Rakib'),('child','Rebeka','Rakib'),('child','Hasib','Rashid')]
X=str(input("Grandchild:"))
print('Grandparent:',end=' ')
i=0
while(i<=3):
if((tupleList1[i][0]=='child')&(tupleList1[i][1]==X)):
for j in range (4):
if((tupleList1[i][0]=='chil... |
459ac69685949947f07d08c54096d387fb55e3c4 | Geutodun/Python-practice | /practice20.py | 745 | 3.5 | 4 | def x(): #함수 설정
print("레이저")
x() #함수
def deposit(M, N): #숫자 더하기
print("입금이 완료되었습니다. 잔액은 {0} 원입니다".format(M + N))
return M + N
def withdraw(M, N): #숫자 뺴기
if M >= N: #남은게 잔액보다 많으면
print("출금이 완료되었습니다. 잔액은 {0} 원 남았습니다".format(M - N))
return M - N
else:
... |
e3851711accb8f10a32f030a680ce473b4c5bf98 | Capnsockless/Randomizer-Collection | /UniqueIntRandomizer.py | 1,989 | 3.625 | 4 | import random
import json
import ast
import os
os.chdir("D:\Randomizers")
def open_json(jsonfile): #open function for jsonfiles
with open(jsonfile, "r") as fp:
return json.load(fp)
def save_json(jsonfile, name): #save function for jsonfiles
with open(jsonfile, "w") as fp:
json.dump(name, fp)
... |
297983aa507358d9041b55561d46a4dff506402a | manji-0/atcoder | /libs/unionfind.py | 953 | 3.75 | 4 | class UnionFind:
def __init__(self, n):
self.__n = n
self.root = [0] + [-1] * n
self.rnk = [0] * (n + 1)
def find_root(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = self.find_root(self.root[x])
return self.root[x]
d... |
ab09ed283ad8ef27a51ed0c06a9e3d0d83898dda | manji-0/atcoder | /abc/237/c.py | 430 | 3.546875 | 4 | def main():
S = list(input())
if S == S[::-1]:
print("Yes")
return
if S[-1] != "a":
print("No")
return
scnt = 0
tcnt = 0
while S[-1] == "a":
S.pop()
tcnt += 1
S = S[::-1]
while S[-1] == "a":
S.pop()
scnt += 1
if S... |
f5d20cf55a43622ee2277e6a53aadf8af2479aad | manji-0/atcoder | /agc/036/a.py | 434 | 3.6875 | 4 | def main():
S = int(input())
X1 = 0
Y1 = 0
Y2 = 0
X3 = 0
F = factor(S)
X2 = F
while ((X2 > 10**9) or (S//X2 > 10**9)):
print(X2)
x = factor(S//X2)
if not x:
X2 *= x
Y3 = S // X2
print(X1,Y1,X2,Y2,X3,Y3)
def factor(n):
for i ... |
fa6f90c032ba5600126299490240ca9286e0e994 | keyman9848/Python3PracticalPrograms | /Python3编程100例/20th.py | 442 | 3.890625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/3/6 22:10
# @Author : cunyu
# @Site : cunyu1943.github.io
# @File : 20th.py
# @Software: PyCharm
# 初始距离
distance = 100
total = 0
total += distance
# 第10次落地时,经历了9次弹起到落地
for i in range(9):
distance /= 2
total += 2 * distance
... |
e4f4ceb4d589dd53aec181ef69d65046d27216f7 | XQXZ/python- | /日历.py | 743 | 4.03125 | 4 | def is_leap_year(year):
if year %4 == 0 and year % 100 != 0 or year % 400 == 0:
return True
else:
return False
def get_num_of_days_in_month(year,month):
if month in (1,3,5,7,8,10,12):
return 31
elif month in (4,6,9,11):
return 30
elif is_leap_year(year):
retu... |
4a0e8b5efeb37c0b538ed7b264f9a39ad9d67440 | Rockwell70/GP_Python210B_Winter_2019 | /examples/office_hours_code/class_inheritence.py | 953 | 4.15625 | 4 | class rectangle:
def __init__(self, width, length):
self.width = width
self.length = length
def area(self):
return self.width * self.length
def present_figure(self):
return f'This figure has a width of {self.width}, a length of {self.length} and an area of {self.area()}'
... |
77b412d9121baf177d930b1072f9870b7f7f6b79 | Rockwell70/GP_Python210B_Winter_2019 | /examples/office_hours_code/donor_models.py | 2,082 | 4.34375 | 4 | #!/bin/python3
'''
Sample implementation of a donor database using classes
'''
class Person:
'''
Attributes common to any person
'''
def __init__(self, donor_id, name, last_name):
self.donor_id = donor_id
self.name = name
self.last_name = last_name
class Donation:
'''
... |
38ce46230cc6f2c490b97ef27681975750f48ed7 | Rockwell70/GP_Python210B_Winter_2019 | /examples/office_hours_code/sunday_puzzle.py | 1,425 | 4.1875 | 4 | '''
From: https://www.npr.org/2019/01/20/686968039/sunday-puzzle-youre-halfway-there
This week's challenge: This challenge comes from listener Steve Baggish of Arlington, Mass.
Take the name of a classic song that became the signature song of the artist who performed it.
It has two words; five letters in the first, thr... |
a9bd7059ce579e17c1cb3171db3ca0ecdb21bf11 | Rockwell70/GP_Python210B_Winter_2019 | /students/jeff_shabani/session01/codingbat_sum13.py | 233 | 3.640625 | 4 | def sum13(nums):
for i in range(0, len(nums)):
if nums[i] == 13:
if i == len(nums)-1:
nums.pop()
else:
nums[i] = 0
nums[i+1] = 0
return sum(nums) |
743d9f47b48e48ecbee6a07aad02b717bcb0f92d | petrarka/bmstu_tisd | /some files we do/2sem/knathkshrl1.py | 9,546 | 3.78125 | 4 | from math import *
import numpy as np
from tkinter import *
import matplotlib.pyplot as plt
## h*.. - элементы интерфейса
## x0, x1 - края интервала, eps - точность,
## nmax - максимальное число итераций
## a,b - края отрезка, step - шаг
## ans - значения корня, itter - количество итераций,
## inter - интерв... |
df0e5c1e846a630da059f9b5da882a57bf271efb | petrarka/bmstu_tisd | /some files we do/2sem/natkhkshrl.py | 6,400 | 3.765625 | 4 | ## Сортировка вставками с бинарным поиском
## Сангинов Азамат ИУ7-21
## testtime, testarr - тестовый массив и время его сортировки
## n1, n2, n3 - поля для ввода размеров
## start_butt - кнопка запуска
from tkinter import *
from random import *
import time
from decimal import *
## Бинарн... |
ee7422d32bd21faf9ef3fb227bd893db0c36bbde | petrarka/bmstu_tisd | /some files we do/1sem/integra_hellsing.py | 5,667 | 3.53125 | 4 | from math import sin,cos
from decimal import *
def in_function(x):
return x-1
def calc_pram(a,b,n,eps):
n = n
n1 = n*2
if a<0 and b>0:
resu = calc_pram(a,0,n,eps) + calc_pram(0,b,n,eps)
return resu
else:
while abs(calc_integra(a,b,n) - calc_integra(a,b,n1))... |
7d85e7b88b3ba9ffce5d21164dcbba0fea78aa2c | petrarka/bmstu_tisd | /some files we do/1sem/2/dz2.py | 1,357 | 4.21875 | 4 | # Программа для вычисления квадратного уравнения
# Сангинов Азамат ИУ7-11Б
from math import sqrt
# a, b, c - коэфициенты уравнения
# d - дискриминант
# x - корень квадратного уравнения
print('Квадратное уравнение имеет вид: a*x^2 + b*x + c = 0')
a = float(input('Введите коэффициент ... |
525b2c4cbb3a5e67610a6a41273e951726699b49 | saalimon/insira | /functions/dataprep.py | 4,058 | 3.625 | 4 | import pandas as pd
import numpy as np
def data_separator (df):
'''This function recieve a dataframe that will seperate & convert data into proper category'''
#Init list for checking ordinal and returning list
ordinal_list = ['day','month','year','time_from_date','date','time']
unique_list = ['id'... |
2806a5b3d7eb2fd54a328cb79fe5cc7ba52ddfea | ignatov9/school | /classwork/00_27_10_cometa.py | 227 | 3.625 | 4 | A = int (input ('Введите год рождения \n'))
B = int (input ('Введите год смерти \n'))
C = int (input ('Кратность \n'))
k=0
while A<=B:
A=A+1
if A%C==0:
k=k+1
print (k)
|
e2428ceb143962e8dc63cfc1aa7a9a10a9fc483f | arvagas/Intro-Python-II | /src/player.py | 431 | 3.515625 | 4 | # Write a class to hold player information, e.g. what room they are in
# currently.
class Player:
def __init__(self, name, current_room, items = []):
self._name = name
self.current_room = current_room
self.items = items
def __str__(self):
return (
f'\nName: {self._nam... |
e140b5b27bc26b022671aa7dacc9910157d0b746 | andreeqm/InstructiuneaIF | /pr5_if.py | 343 | 3.515625 | 4 | zc=int(input("Introduceti ziua curenta zc="))
lc=int(input("Introduceti luna curenta lc="))
ac=int(input("Introduceti anul curent ac="))
zn=int(input("Introduceti ziua nasterii zn="))
ln=int(input("Introduceti luna nasterii ln="))
an=int(input("Introduceti anul nasterii an="))
if(lc>ln) :
print((ac-an)+1)
e... |
9e75539b26ebd623a8d83ba7e5c37bc109f3662b | andreeqm/InstructiuneaIF | /pr1_if.py | 402 | 3.796875 | 4 | e1=int(input("Introdueti numarul curent e1=))
p1=int(input("Introduceti punctajul p1="))
e2=int(input("Introduceti numarul curent e2="))
p2=int(input("Introduceti punctajul p2="))
e3=int(input("Introduceti numarul curent e3="))
p3=int(input("Introduceti punctajul p3="))
if(p1>p2)and(p1>p3) :
print("e1")
if(... |
bdd7cadc898f491e2794d54ac507435c607d388c | raymondgggg/Python-Programs | /lab11.py | 1,676 | 4 | 4 | #Problem 3.18
print("3.18")
usr_input = input('Is anyone in your party a vegetarian?(yes/no)')
usr_input2 = input('Is anyone in your party vegan?(yes/no)')
usr_input3 = input('Is anyone in your party gluten-free?(yes/no)')
print()
print("Here are your choices: ")
if usr_input == 'yes':
##main street, corner, mama,... |
82c426836fee0560e917848084af4ca124e74dff | raymondgggg/Python-Programs | /Homework09.py | 1,189 | 3.859375 | 4 | #Homework 09
#Raymond Guevara
#018504731
#Algorithm Workbench
#Question 1
print("Question 1")
height = int(input("Please enter your height: "))
print()
#Question 2
print("Question 2")
color = input("please enter your favorite color: ")
print()
#Question 3
print("Question 3")
a = -8/3 #Solved for variable "a" usin... |
6bd985b668b55337eb6bebf7b03b035863168f14 | raymondgggg/Python-Programs | /Lab14pt2.py | 539 | 3.953125 | 4 | #Raymond Guevara
#Lab 14 part 2
#01804731
# 8.2 sum of digits in a String
print("Sum of digits in a String")
usr_input = input("Please enter a series of numbers: ")
count = 0
for i in usr_input:
count += int(i)
print(count)
print()
#8.11 word separator
print("8.11 Word separator")
usr_input = input("Enter a sent... |
55cfec56c9b3ec5d5b179be1d91967538f9d7f78 | Lopez-Ae-Reinhard/Sakura | /Helper/custom_list_tools.py | 10,758 | 3.53125 | 4 | """
针对列表的自定义工具
配合lambda使用
"""
class ListHelper:
@staticmethod
def find_all(target, func_condition):
"""
查找列表中满足条件的所有元素
:param target: 列表
:param func_condition: 判断条件\
# 函数/方法类型\
# --参数:列表内对象\
# --返回值:是否满足条件bool类型
:... |
b919877757cf437eeeb1e2f1e7b46e65efc1ab86 | gelodgreat/basicpython | /basics/conditionals.py | 195 | 3.59375 | 4 | list_a = [1, 2, 3]
list_b = [2, 3, 4]
list_c = [1, 2, 3]
print(list_a == list_b)
print(list_a == list_c)
name = "Angelo"
nameCounter = len(name)
print nameCounter != 6
print nameCounter%2 ==0 |
dbb4834b46daf881299ee3d8c2f782fb322174e5 | 13051699665/shell | /hello.py | 125 | 3.65625 | 4 | aa=input("请输入1到100之间的数字:")
if 1 <= int(aa) <= 100:
print("漂亮")
else:
print("太臭了")
|
fd88d96eb1d51cc5023631df32739767694d8921 | NickAnson/TruSearch | /main.py | 1,853 | 3.609375 | 4 | from tkinter import *
import tkinter as tk
import random
def linSearchGraph(nums, screen, canvas, size):
start = 0
for i in range(len(nums)):
canvas.create_rectangle(start * (800 / size), 800 - nums[i], start * (800 / size) + (800 / size), 800,
fill='black')
sta... |
61b3686f71de4537aa4321bfc19e6b5c7a518085 | jahidhasanshuvo/problem-solving-python | /CTCI/StringsChapter1/matrixRotation1.7.py | 1,170 | 3.953125 | 4 | size = int(input())
def declareMatrix(size):
matrix = list()
for i in range(0, size):
matrix.append(input().split(' '))
return matrix
def printMatrix(matrix):
for i in range(0, len(matrix)):
for j in range(0, len(matrix[i])):
print(matrix[i][j], end=' ')
print()
matri... |
e66528ae9602fba2ca810c94e4779ab199772392 | jahidhasanshuvo/problem-solving-python | /graph/cycleDetection.py | 729 | 3.625 | 4 | def cycleDetect(node, parent):
visited[node] = True
print(node)
for child in graph[node]:
if not visited[child]:
if cycleDetect(str(child), node):
return True
elif child!=parent:
return True
return False
numberof... |
3441645c6450a445831a6bf3a90254008be97653 | jahidhasanshuvo/problem-solving-python | /graph/problems/aBugsLife.py | 1,493 | 3.625 | 4 | def DFS(node, type, level):
if visited[node]:
if checkType[node] != type:
print("false return")
return False
else:
visited[node] = True
checkType[node] = type
print(node, type)
for childnode in graph[node]:
print("childnode",childnode,"... |
eb3057689fc57e496ee0e3f64cf50ef1ef723fe1 | Cody-Hayes97/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 706 | 4.25 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# return zero if the ength of the word is less ... |
884abdc80c21ceb1d2c85e579be14f74ee9eb4d9 | a-domingu/generatorfind | /tests/pruebas.py | 1,305 | 3.921875 | 4 |
class Clasetotal:
def firstn(self, n):
num = 0
while num < n:
yield num
num += 1
class Clase2:
class Clase3:
def firstn(self, n):
num = n**2
while num > n:
yield num
num -= 1
def primera():
def segund... |
c4db19da767f045ca4d078a9b9931ddc2056eaf7 | brandongatlin/100_days_of_python | /day_5.py | 1,041 | 4.03125 | 4 | from random import choice
letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
symbols = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_']
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def generate_random(list):
return choice(l... |
1479ba18c8b5ee41d265e3ea89749e5fb2e3bc1c | brandongatlin/100_days_of_python | /day_29.py | 3,054 | 3.703125 | 4 | from json.decoder import JSONDecodeError
from tkinter import *
from tkinter import messagebox
import pyperclip
import json
# ---------------------------- PASSWORD GENERATOR ------------------------------- #
def gen_password():
password_input.insert(0, 'raNd0M')
# ---------------------------- SAVE PASSWORD ----------... |
34795b385fba3fa875c01516ce4db3eb2ff118c5 | brandongatlin/100_days_of_python | /day_4.py | 1,229 | 3.96875 | 4 | from random import choice
armoury = ['R', 'P', 'S']
def get_player_weapon():
weapon = input('Choose your weapon... (R, P or S) \n').upper()
if weapon in armoury:
return weapon
else:
return get_player_weapon()
def get_computer_weapon():
return choice(armoury)
def find_winner(player_weapon, computer... |
f4849a5c42bc65b637a82a93a2a76b8ad2dd66d2 | KremerAD/StatPract | /One.py | 763 | 3.75 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[18]:
name = input("Введите имя:")
age = int(input("Введите возвраст:"))
age = str(2118-age)
print(name + " исполнится 100 лет в "+ age)
# In[1]:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
for x in a:
if x <= 5:
print(x)
# In[ ]:
import random
num = rando... |
6e7c390872c7a2f5b578425904aa5dfbdd562cf5 | nikhil-suwalka/Visualization-of-various-sorting-algorithms | /main.py | 5,818 | 3.71875 | 4 | import tkinter as tk
from tkinter import font
from random import randrange
import time
import sys
sys.setrecursionlimit(20000)
number = []
for i in range(160):
number.append(randrange(0, 100000))
temp = []
for i in range(6):
temp.append(number.copy())
number = temp
total_bubble = 0
def b... |
bbd9b01442de38d8930085a40270bb95e1988d33 | kxyden-k/Age-Calculator-GUI | /age calculator.py | 1,575 | 3.90625 | 4 | import tkinter as tk
import datetime as dt
def time_conversion():
"""
Does all time related calculations
"""
age = date.get()
deadlineDate= dt.datetime.strptime(age,'%Y/%m/%d')
difference = current_time - deadlineDate
years = ((difference.total_seconds()) / (365.2421897 * 24 * 3600))
... |
0a1bf196667cd63dc6f5fe840a88b74aa9593883 | RutujaWanjari/Python_Basics | /RenameFileNames/rename_filenames.py | 885 | 4.375 | 4 | # This program demonstrates how to access files from relative path.
# Also it changes alphanumeric file names to totally alphabetic names.
# To successfully run this program create a directory "AllFiles" and add multiple files with alphanumeric names.
from pathlib import Path
import os
# Path is a class from "pathlib... |
8e770c9b0a9e2b0324cba403a21ce0040ac196f7 | Fockerdev/MyPyProg | /Py1.py | 3,924 | 3.953125 | 4 | __author__ = 'Focker'
import sys;
print('welcome');
my_int = 7
'''my_float = 1.23
my_bool = True
'''
print(my_int);
def f1():
toy = 12;
return toy;
print(f1());
# return my_int;
webster = {
"Aardvark": "A star of a popular children's cartoon show.",
"Baa": "The sound a goat makes.",
"Carpet... |
52027489ed08f93ec5752c055a216e71785a3354 | quasarjohn/interpol | /tokenizer.py | 3,224 | 3.609375 | 4 | import sys
import re
from enum import Enum
class Tokenizer:
def tokenize(self, lines):
tokens_list = []
for line_number, line in enumerate(lines):
tokens = []
# use space as delimiter
for word in line.split(' '):
token = Token(val=word)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.