blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
abba1dbd2ee82a32bf53986395d516462bf6c771
CheukYuen/Leetcode-python-master
/Lintcode/Binary-search/Maximum Number in Mountain Sequence.py
528
3.9375
4
def mountainSequence(nums): # Write your code here if not nums or len(nums) == 0: return None start = 0 end = len(nums) - 1 while start + 1 < end: mid1 = (end - start) / 2 + start mid2 = end - (end - mid1) / 2 if nums[mid1] < nums[mid2]: start = mid1 + 1 ...
bfa821532ce7980cded0593ba4abe188f0b252ab
rohanroy556/SpamFilter
/tkinter/event_button.py
336
3.921875
4
from tkinter import * root = Tk() def printName(): print("Hello my name is rohan") def eventButton(event): print("Yo Rohan") button_1 = Button(root, text="Print my name", command=printName) button_1.pack() button_2 = Button(root, text="Event button") button_2.bind("<Button-1>", eventButton) button_2.pack() ...
2746e22b25add1f703135e68f88929bf49c5a8df
rais2-pivotal/pythonsamples
/loopwhiledone_minmax.py
370
3.90625
4
#!/usr/bin/env python answer = 0 numarray = [] while True: answer = input("Enter a number: ") if answer == 'done': break try: val = int(answer) numarray.append(val) except ValueError: print("Invalid input") continue print("Min from array is: " + str(min(numarray)) +...
c61687cc3193ff8ceb6f0a2908d4cd63fdc35cb2
carogalvin/schedule_python
/rehearsals.py
988
3.53125
4
import dates class RehearsalDate: # date: string in the form "yyyy-mm-dd" # actorList: a list of strings that are actor names # sceneList: a list of strings that are scenes def __init__(self, date, actorList, sceneList): self.date = date self.day = dates.dayOfWeek(date) self.act...
9c669273f980d26fb6312af5423f8116d4d2e3d9
smohorzhevskyi/Python
/First_homework_3.py
723
4.03125
4
""" Вывести символ * построчно, начиная с одной звездочки и, в зависимости от количества строк, заданных пользователем, последовательно увеличивая на 1 звездочку на каждой новой строке. Если пользователь вводить числа меньшие 1 – бросить исключение. """ def checknum(N): if N < 0: raise Exception(...
91df76fd65b8139d98ea8798cbdf0b602dc136c1
bodetc/CarND-Term1-Lessons
/Lesson7-MiniFlow/nn.py
707
3.84375
4
""" This script builds and runs a graph with miniflow. There is no need to change anything to solve this quiz! However, feel free to play with the network! Can you also build a network that solves the equation below? (x + y) + y """ from miniflow import * x, y, z = Input(), Input(), Input() f = Add(x, y, z) g = M...
9a41c9fcb363dff199b0461573452484e84d2b98
Zejjs/VigenereCrack
/vigenere.py
11,289
3.9375
4
import string import languageFunctions from frequencyFinder import english_frequency_score from myMath import factors def decipher_vigenere(cipher_text, key): """ Function deciphers a standard Vigenere encrypted cipher text using a key Args: cipher_text: string to be deciphered ...
80cf71037f56b17cade8bb498fe6c95a06c7bd29
nkiryanov/ya-algorithms
/2-b/a_max_num.py
244
3.65625
4
def main(): x = -1 max = 0 while x != 0: x = int(input()) if x == max: count += 1 if x > max: max = x count = 1 print(count) if __name__ == "__main__": main()
a8eef524c257d159ab49712885ea29456ee84c7e
nguyenhi1/comp110-21f-workspace
/lessons/memory_diagram1_Q1.py
519
3.8125
4
def f(x: int, y: int) -> int: if x + y > 10: print("howdy!") return x else: return x + y def g(x: int) -> int: if x % 2 == 0: print("It's even.") x = x + 1 else: x = x * 2 return x def bar(x: int, y: int) -> int: if x > y: print("wooh...
80afd7553c779399471076378320e7d4b45d90ff
geriwald/coding-exercises
/DailyCodingProblem/P01_matchingPairs.py
602
4.03125
4
# Good morning! Here's your coding interview problem for today. # This problem was recently asked by Google. # Given a list of numbers and a number k, return whether any two numbers from the list add up to k. # For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. # Bonus: Can you do this in on...
bf9e5cc350182cd100d4ebf8d9ef72d2048f4997
MrzvUz/Python
/Python_Entry/test.py
5,180
4
4
# def checkDriverAge(): # age = input("What is your age?: ") # if int(age) < 18: # print("Sorry, you are too young to drive this car. Powering off") # elif int(age) > 18: # print("Powering On. Enjoy the ride!"); # elif int(age) == 18: # print("Congratulations on your first year ...
5dfb86530af8899659e2207bd94a706f2d428732
ZhouZoey/LeetCode-python
/leet13_RomanToInteger.py
599
3.625
4
import math class Solution(object): def romanToInt(self, s: str) -> int: tmp = {"I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000} total = 0 for i in range(len(s) - 1): ...
7dd3d6e7af3dd86d230e5f29b4c9c5fbff512027
Angel-cuba/Python-UDEMY
/ColeccionesMetodos/metodolista.py
352
4.21875
4
#append...agrega un elemento sobre el final lista = ["Angel", "Luis", "Araoz"] print(lista) lista.append("Vera") print(lista) ################### ##metodo extend lista1 = ["Maria", "Yamil", "Dupi"] lista.extend(lista1) print(lista) ################# # lista.count("Maria") lista1 = ["Maria", "Yamil", "Dupi"] lista1.inse...
8214df322b0fd8476857b0c3f64acf66822d7159
maxfactory/pythontest
/python/6/6.4/aliens.py
949
3.765625
4
# # 字典列表 # alien_0 = {'color':'green','points':5} # alien_1 = {'color':'yellow','points':10} # alien_2 = {'color':'red','points':15} # aliens = [alien_0,alien_1,alien_2] # for alien in aliens: # print(alien) #-------------------------------------- # 使用range()生成30个外星人 # 创建一个用于存储外星人的空列表 aliens = [] # 创建30个绿色的外星人 for ...
7cf128b2711edbc944c733114947819282dee77a
ZhiyuSun/leetcode-practice
/剑指Offer/51_数组中的逆序对.py
4,829
3.609375
4
""" 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。   示例 1: 输入: [7,5,6,4] 输出: 5 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ from typing import List # 2021.04.03 可以做,但是超时 class Solution: def reversePairs(self, nums: List...
9a433e00068611293acaa0f8bf8c6250905050fb
kesarb/leetcode-summary-python
/practice/solution/0605_can_place_flowers.py
526
3.625
4
class Solution(object): def canPlaceFlowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ count = 0 value_list = [0] + flowerbed + [0] res = False for i in range(1, len(value_list) - 1): if ...
5ab33d727ccdfe97ec6abe974b0f7b9ce7026fec
SanyaGera/Pyhton-codes
/Tuples.py
266
4.125
4
#Given an integer, n , and n space-separated integers as input, create a tuple,t, of those n integers. Then compute and print the result of hash(t). #Solution n = int(raw_input()) integer_list = map(int, raw_input().split()) t=tuple(integer_list) print(hash(t))
928b351778f548cf9d3f1dd4a7457c37719caf10
philipdongfei/Think-python-2nd
/Chapter09/Ex9_6.py
879
3.96875
4
def is_abecedarian(word): word = word.lower() preletter = word[0] for letter in word[1:]: if letter < preletter: return False else: preletter = letter return True def word_is_abecedarian(path): fin = open(path) count = 0 total = 0 smallest = '' ...
ef0f7a993719f68e6b29b95015a454393e54d295
GaoZWei/Python_Study
/code/json/json3.py
199
3.796875
4
# 序列化 python=>json import json student = [ {'name': 'gao', 'age': 18, 'flag': False}, {'name': 'gao', 'age': 18}] json_str = json.dumps(student) print(json_str) print(type(json_str))
c10301b8b772b30c045b102d736f988705136058
Parkhyunseo/PS
/SDS/ds/ds_F_2504.py
1,110
3.5625
4
import sys text = list(input()) stack = [] small = 0 big = 0 temp = 1 total = 0 for i in range(len(text)): if text[i] == '(': stack.append('(') small += 1 temp *= 2 if i < len(text) - 1: if text[i+1] == ')': total += temp elif text...
b71206e5162df0164dac57e6d160181fb12f5849
hodinhtan/python_advance_concept
/abstract-class.py
926
4.03125
4
from abc import ABC, abstractmethod class Polygon(ABC): @abstractmethod def draw(self): pass def getArea(self): pass def getCircuit(self): pass @abstractmethod def xaoxao(self): pass class Rectangle(Polygon): def __init__(self, w ,h ): self.w = w ...
4a5258f9feed4dd309de54dfc44b70be154b5f9b
paulghaddad/solve-it
/exercism/python/collatz-conjecture/collatz_conjecture.py
564
4.1875
4
## Iterative Solution def steps(number): if number < 1: raise ValueError('The number must be greater than 0') steps = 0 while number > 1: steps += 1 if number%2 == 0: number //= 2 else: number = 3*number + 1 return steps # Recursive Solution de...
353010ef12264ff6722cb11bfd6210c667832296
TechOpsX/python-function
/4_return_value.py
391
3.71875
4
def no_return_func(): a = 1 def return_one_value(): return 1 def return_two_value(): return 1, 2 if __name__ == "__main__": print(no_return_func()) print(return_one_value()) print(return_two_value()) a, b = return_two_value() print(a, b) # 只接受一个值,可以用_作为占位符,放弃接收值 _, c = ret...
e487b11b85d3c93f078511b59fc98d03791a091c
shiryu92/pdf
/map.py
586
3.625
4
''' Author: shiryu92 Module: Map file to memory Date: 30/07/2015 ''' import mmap class MFile: ''' Map file to memory ''' def __init__(self, filepath); ''' Init file path ''' self.filepath = filepath self.file = None self.map = None def mapfile(self): ''' Map file ''' try: file = open(...
415ac9e48fd0b333878687fe110d5811d2649848
cholojuanito/image-processing
/lighting-shading/lighting.py
7,623
3.59375
4
""" Modified code from Peter Colling Ridge Original found at http://www.petercollingridge.co.uk/pygame-3d-graphics-tutorial """ import pygame import numpy as np import wireframe as wf import basicShapes as shape from math import pi class WireframeViewer(wf.WireframeGroup): """ A group of wireframes which can b...
2b202bc07212a75fc08b4599a7bc9af41a9a9cef
odys-z/hello
/docs/_downloads/414531146a8ac482e05ce04ab1710685/q784.py
1,846
4.21875
4
''' 784. Letter Case Permutation https://leetcode.com/problems/letter-case-permutation/ Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. You can return the output in any order. Example 1: Input: ...
e19a9eecc148c13eaf86491cbde5a70313156500
eronekogin/leetcode
/2023/minimum_skips_to_arrive_at_meeting_on_time.py
790
3.640625
4
""" https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time/ """ class Solution: def minSkips(self, dist: list[int], speed: int, hoursBefore: int) -> int: """ dp[j] / speed stands for the minimum arrival time after j skips. """ N = len(dist) dp: list[float]...
84f41ccdefd2d16b6cbae57b7cc57899b3b88561
jee599/2D_TeamProject
/homework/turtle.py
258
3.6875
4
import turtle t = turtle.Pen() def star(n): for i in range(n): t.up() t.goto(0,0) t.right(360/n) t.forward(100) for j in range (5): t.down() t.right(144) t.forward(30) star(10)
c4de7d19db341d69cb1426c2d502461fd96caedc
franklarios/pycompsci
/chp1/chaos2point0.py
328
3.90625
4
# File: chaos2point0.py # A simple program illustrating chaotic behavior. Uses 2.0 instead of 3.9 # original chaos.py script. def main(): print("This program illustrates a chaotic function") x = eval(input("Enter a number between 0 and 1: ")) for i in range(10): x = 2.0 * x * (1-x) print(x)...
3712344d3aa8e97838bd4338a3e10c733d02423c
hbferreira1/python-introduction
/exponenciacao.py
307
3.828125
4
def exponenciacao(): n1 = int(input("número: ")) n2 = int(input("elevado a: ")) for i in range(20): print(n1 **n2) n2 = n2 + 1 print(n1 ** n2) if (n1 ** n2) >= 1000: break print("O número já é maior que 1000") exponenciacao()
9d9089011cf2895fcb479a97fa99b6991b83ce59
jaehyunan11/leetcode_Practice
/Amazon_LEETCODE/7.Reverse_Integer.py
455
3.609375
4
class Solution: def reverse(self, x): # int -> str -> int (change to str to flip and then change to int) # [1:] due to -1 sign result = int(str(x)[::-1]) if x >= 0 else -int(str(x)[1:][::-1]) if -2**31 <= result <= (2**31)-1: return result else: retur...
0f4fb8bbb3eb784938f6ef799a4740487af20fe8
deniseicorrea/Aulas-de-Python
/python/ex052.py
375
3.984375
4
numero = int(input('Digite um número: ')) tot = 0 for c in range(1, numero + 1): if numero % c == 0: print('\033[33m', end= '') tot += 1 else: print('\033[31m', end= '') print(f'{c}', end= ' ') print(f'\n\033[mO número {numero} foi divisível {tot} vezes') if tot == 2: print('Núme...
e49a7788363799cf47064f8a4862a7cc5fb8a1ba
tolgaouz/Standford-cs231n-Assignment-Solutions
/assignment1/cs231n/classifiers/softmax.py
4,050
3.828125
4
import numpy as np from random import shuffle def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array of shape (D, C) containing weights. - X:...
c88c38a855e4ea3a0640503ce826777c6d158346
tibigame/ShogiNotebook
/ShogiNotebook/util.py
492
3.65625
4
from typing import Tuple def xor(x: bool, y: bool)-> bool: """排他的論理和""" return x and not y or not x and y def reverse_bw(pos: Tuple[int, int], is_black=True)-> Tuple[int, int]: """先後の符号を反転したタプルを返す""" if is_black: return pos return 10 - pos[0], 10 - pos[1] def d_print(string: str, debug...
569174fdb66ccaf8480775cd56c8acfea6d69444
sshukla31/solutions
/dynamic_programming/max_sub_square_matrix.py
2,150
4.1875
4
""" Find Maximum Sub Square for a given matrix 1) Create a temp matrix of (row+1) * (col+1) 2) Fill up first row and col with 0 3) Start with [row+1][col+1] cell 4) If matrix[row][col] == 1, then, min( matrix[row-1][col-1], matrix[row][col-1], matrix[row-1][col-1] ) + 1 5) Keep a max_co...
12a84a19ccadb409b56f117a820c8e853377a4a0
ittoyou/1805
/13day/列表清空.py
95
3.75
4
list = [1,2,3,4,5,6,7,8,9] for i in range(len(list)-1,-1,-1): list.pop(i) print(list)
1def0b375d6b7f6d8ec10e58f8aefc784c923486
Egan-eagle/python-exercises
/week1&2.py
3,145
4.3125
4
# Egan Mthembu # A program that displays Fibonacci numbers using people's names. def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i name = "Mthembu" first = name[0] last = name[-1] firstno = ord(first) lastno...
856a725aae4747329aac945ad964500d52eca519
Nafisa-tabassum2046/my-pycharm-project
/while loop use anis.py
584
3.8125
4
# i = 1 # while(i<=20): # print(i) # i = i+1 # print("program end for serial number") # i= 1 # while(i<=100): # print(i) # i = i+2 # print("program end for odd number") # i = 2 # while(i<=200): # print(i) # i = i+2 # print("program end for even number") # #while use kore jog a...
605c154695d64ac41fd40fea6f8115bb4e62ba16
btjanaka/algorithm-problems
/codejam/2020-qual-nesting-depth.py
1,008
3.71875
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (CodeJam) 2020-qual-nesting-depth # Title: Nesting Depth # Link: https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/0000000000209a9f # Idea: Similar to the classic balanced parentheses problem, except that we # now keep track of an additional number te...
30870e39e580766e30728810f5907c507dc17c7c
henryztong/PythonSnippet
/数据库/sqlite3数据库/db_set.py
1,023
4.125
4
from sqlite3 import connect # 定义一个数据库,生成在当前目录中 db_name = 'test.db' # 创建连接 con = connect(db_name) # 创建游标 cur = con.cursor() # 创建表 # cur.execute('create table star (id integer,name text,age integer,address text)') # # 设定数据 # rows = [(1,'小米',22,'北京'),(2,'小明',23,'天津'),(3,'小王',24,'成都')] # # 遍历并插入数据 # for item in rows: ...
d13b652626ee2c553717b475d3946461b7a80ad7
chengqiangaoci/back
/sp1/python全栈/面向对象编程/子类中调用父类方法.py
1,545
4.125
4
#__两个下划线开头,声明该方法为私有方法,不能在类地外部调用,即不能被实例调用 # class Vehicle():#定义交通工具 # Country = "China" # def __init__(self,name,speed,load,power): # self.name = name # self.speed = speed # self.load = load # self.power = power # def run(self): # print("开动了") # class Subway(Vehicle):#地铁 # def __init__(self,name,speed,load...
4576775d13176ae57a1fb0ea5e75b0af8a9cd7e6
Nigirimeshi/leetcode
/0202_happy-number.py
3,382
3.921875
4
""" 快乐数 标签:数学 链接:https://leetcode-cn.com/problems/happy-number 编写一个算法来判断一个数 n 是不是快乐数。 「快乐数」定义为: 对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和, 然后重复这个过程直到这个数变为 1,也可能是 无限循环 但始终变不到 1。 如果 可以变为 1,那么这个数就是快乐数。 如果 n 是快乐数就返回 True ;不是,则返回 False 。 示例: 输入:19 输出:true 解释: 1^2 + 9^2 = 82 8^2 + 2^2 = 68 6^2 + 8^2 = 100 1^2 + 0^2 + 0^2 = 1 我的解...
517e6b2b7806c3b6268e7c8d42991954ad9921ae
corey-marchand/madlib-cli
/madlib_cli/__init__.py
1,350
4.25
4
def mad_lib_game(): Adjective_one = input("Enter a adjective: ") Adjective_two = input("Enter another adjective: ") Adjective_three = input("Enter another adjective: ") Adjective_four = input("Enter another adjective: ") Large_animal = input("Enter the name of a large animal: ") Small_animal = ...
b0c1b193befa5949ad1de68086fa7c5ce0fe76a4
kebingyu/python-shop
/the-art-of-programming-by-july/chapter1/string-permutation-3.py
684
3.859375
4
# -*- coding: utf-8 -*- """ 如果不是求字符的所有排列,而是求字符的所有组合,应该怎么办呢? 当输入的字符串中含有相同的字符串时,相同的字符交换位置是不同的排列,但是同一个组合。 举个例子,如果输入abc,它的组合有a、b、c、ab、ac、bc、abc。 """ def combination1(word, length):#{{{ if length == 1: return [word[0]] else: head = word.pop() ret = [head] comb = combination1(word, len...
6353c367270445fdbe93063a9b2b5acb37e76c72
prajwal041/ProblemSolving
/Learning/Inno/matching.py
809
3.609375
4
from difflib import SequenceMatcher def longestSubstring(str1, str2): # initialize SequenceMatcher object with # input string seqMatch = SequenceMatcher(None, str1, str2) # find match of longest sub-string # output will be like Match(a=0, b=0, size=5) match = seqMatch.find_longest_match(0, le...
6aea66f17ee283745e39085f1fb7975f481b09d3
gregariouspanda/Julia-learns-python
/create_dictionary.py
590
3.546875
4
import sys import string def create_dictionary(file_name): f = open(file_name,'r') s = f.read() rlst=s.split() lst = ['$'] for word in rlst: if word[-1] in string.punctuation: lst.append(word[:-1]) if word[-1] == ',': lst.append(word[-1]) ...
ed898d550613f1c9ca77d28c02eed6ec98c6d6fa
nosrefeg/Python3
/mundo3/exercicios/089.py
929
3.796875
4
alunos = [] while True: dados = [input('Digite o nome do aluno: '), [float( input('Digite a primeira nota: ')), float(input('Digite a segunda nota: '))]] alunos.append(dados[:]) confirm = input('Quer continuar? (S/N) ').strip().upper() while confirm not in 'SN': confirm = input('Quer c...
da87ac782415f4e2fb3b3a493f3b07bc37f20093
SARWAR007/PYTHON
/Python Projects/list_map.py
271
3.921875
4
def find_greater(list_all): #desired_no = list_all[1] for index in list_all: if (index > 6): print(index) return index list1 = [1,6,8,40,5,3,7] number = 6 find_greater(list1) print(list(filter(find_greater,[1,6,8,40,5,3,7])))
dc31e639ec8805a7175a690112fcd06527dafa8e
Aasthaengg/IBMdataset
/Python_codes/p02747/s965569589.py
235
3.625
4
s = str(input()) if len(s)%2: print('No') exit() for i in range(len(s)): if not i%2 and s[i] == "h": continue elif i%2 and s[i] == "i": continue else: print("No") exit() print('Yes')
184bfa6475a42ba88e07e7fb3a86a5fc003f891c
Monsieurvishal/PythonProjects
/RockPaperScissorsGame/RockPaperScissorsGame.py
2,250
3.859375
4
# @author Neel Patel # @file RockPaperScissorsGame.py from random import randint best, out = input("Best ______ out of _______?").split() best = int(best) out = int(out) moves = ["rock", "paper", "scissors"] comp_wins, player_wins = 0, 0 def comp_win(comp_param, player_param, win_param): print("Computer played...
b6c1f624880055a2674e368d13d4268a6fe9cde9
leinian85/year2019
/month02/code/re/day01/exercise02.py
629
3.640625
4
""" regex.py re模块功能函数演示 """ import re str = "Alex:1994,Sunny:1996" pattern = r"(\w+):\d+" l = re.findall(pattern, str) print(l) # compile pattern = r"\w+:\d+" regex = re.compile(pattern) l = regex.findall(str) print(l) l = regex.findall(str, 10) print(l) # 替换目标字符串 """ regex1.py re模块 功能演示函数 生成 match对象的函数 """ str = "...
42a581b88db7e3c204d65c887e03e30c0aa64719
YashasviBhatt/Python
/binaryToDecimal.py
1,288
4.3125
4
# Program to find the decimal equivalent of binary number having n digits def BinaryToDecimal(bin_num,bin_len): # creating a list enlisted with binary codes of decimal numbers binary_input_list = ["{:b}".format(num) for num in range(0,2**bin_len)] multiplier=1 dec_eqvlnt=0 flag=0 for ...
dabe119a78c2945102f76109f7f96f2b05604961
s1273274/CS-104-03
/Richter Scale.py
769
4.0625
4
End=True while End == True: richter = float (input("Enter the Richter scale value. if you type -99 it will kill the program:")) if richter == -99: break while richter < 0: richter = float(input("Please enter a valid number: ")) if(richter >= 8.0): print("Most structures will fall") co...
3ea7e87553aa7e74944d5c6c2a6d1a28de480411
mwisslead/Random
/Levenshtein/levenshtein.py
389
3.65625
4
import sys def levenshtein(a, b, i, j): if min(i,j) == 0: return max(i,j) return min( levenshtein(a, b, i-1, j) + 1, levenshtein(a, b, i, j-1) + 1, levenshtein(a, b, i-1, j-1) + (0 if a[i-1] == b[j-1] else 1) ) def main(argv): print(levenshtein(argv[1], argv[2], len(arg...
d917c2ae2d8a4f62a219a03df7605081735fa50c
mihaip/adventofcode
/2019/06/part1.py
648
3.671875
4
#!/usr/local/bin/python3 class Object(object): def __init__(self, id): self.id = id self.children = [] root = Object("COM") objects = {"COM": root} def get_object(id): if id not in objects: objects[id] = Object(id) return objects[id] with open("input.txt") as f: for line in f...
036328079b28c95691235104367621209a1a6f9f
cececombemale/Application_Security_Image_Crop
/image_crop.py
1,048
3.609375
4
from PIL import Image import sys import math # get the file name try: name = sys.argv[1] except: print("You did not enter the file name of the image you would like to crop, try again by rerunning the program") sys.exit(0) #open the image try: img = Image.open(name) except: print("The image could not be open...
246c5cb9b5cc692d884586fcad9f9a1a998f0129
pzh2587758/pzhthon3.6code
/py3.6原码/str_bytearray_memoryview之间的关系.py
2,349
3.5
4
"""正好最近用到memoryview来回答下这个问题。 bytearray是可变(mutable)的字节序列,相对于Python2中的str,但str是不可变(immutable)的。 在Python3中由于str默认是unicode编码,所以只有通过bytearray才能按字节访问。 memoryview为支持buffer protocol[1,2]的对象提供了按字节的内存访问接口,好处是不会有内存拷贝。 默认str和bytearray支持buffer procotol。 下面两种行为的对比: 简单点就是,str和bytearray的切片操作会产生新的切片str和bytearry并拷贝数据,使用memoryv...
5fe8c282104a1b2c413e13537131237b5beeafd9
vanihb/assign1
/Assignment two/lcm.py
329
4.125
4
def cal_lcm(a,b): if a>b: large=a else: large=b while(True): if((large%a == 0) and (large%b == 0)): lcm=large break large += 1 return lcm n1=int(input("enter num1:")) n2=int(input("enter num2:")) print("lcm of two numbers is:",cal_lcm(...
e3acec9febad760df63d26effd6492ed2b4c63cd
ullumullu/adventofcode2020
/challenges/day5.py
1,814
4
4
""" --- Day 5: Binary Boarding --- Part1: As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass? Part 2: What is the ID of your seat? """ from typing import Tuple, Iterator def binary_range_search(search_cmds: Iterator[str], search_rang...
ed58a590566ec4fc800221be1eb7bd41a34cecc3
christian-miljkovic/python_projects
/python_project 2/MiljkovicChristian_assign2_part1.py
894
4.28125
4
# Christian Miljkovic # CSCI-UA.0002 section 03 # Assignment #2 #print out the intorduction print("Hello! I'm here to help you calculate your tip.") #have user input the cost of the bill bill=float(input("How much was your bill? (enter a positive integer without $): ")) #ask the user how much tip they want to ...
7e89e3eef42cd1d2350906adc19382d3dccb1099
charu11/pythonPro
/expo.py
195
3.953125
4
# exponent function def raise_to_power(base_num, power_num): result = 1 for index in range(power_num): result = result * base_num return (result) print(raise_to_power(4, 3))
01a46ffa2b4575f1c067e75b4993b48dca979b45
mynameischokan/python
/Numbers, Dates, and Times/1_14.py
1,522
4.59375
5
""" ************************************ **** 3.14. Finding the Date Range for the Current Month ************************************ ######### # Problem ######### # You have some code that needs to loop over each date in the current month, # and want an efficient way to calculate that date range. ######### # Solut...
a7bc54d4283d597ce799cfe2c73f7ebb03815238
andrewgordon17/Bois
/bois_plot.py
2,459
3.546875
4
from matplotlib import pyplot as plt from matplotlib import animation from bois_classes import Swarm from movement_functions import * #This code creates a swarm and graphs its progress in matplotlib #Variables that affect the swarm NUMBER_OF_BOIS = 500 BOI_SIZE = .005 RADIUS = .2 #Radius a Boi can see SHOW_RADIUS = F...
b1c9015b9eebbc84fe97f18b5ea2ac6078315f1b
divyank0/euler_project
/50.py
670
3.53125
4
from math import sqrt as sqrt; from math import floor as floor; import sys; def is_prime(aa): return all(aa%ii for ii in range(2,floor(sqrt(aa))+1)); s=0; p=[]; for i in range(2,1000000): if is_prime(i)==True: p.append(i); print("ffff"); c=0; s=0; cc=0; count=0; for j in p: ...
d2f729fdf61294277c45136d2f5a7b4807258cce
cintax/dap_2019
/inverse_series.py
328
3.921875
4
#!/usr/bin/env python3 import pandas as pd def inverse_series(s): ind = list(s.index) val = s.values #print(ind, val) return pd.Series(list(s.index),s.values) def main(): s1 = pd.Series([1,2,3,4,5], index = list("abcde")) print(s1) print(inverse_series(s1)) if __name__ == "__main__": ...
957d280dc9a510caa08e1977e3da78d8243ccb82
NohYeaJin/programmers_problem
/programmers_english_play.py
946
3.5625
4
def solution(n, words): num = len(words) answer = [] for i in range(1,num,1): if(words[i][0]!=words[i-1][len(words[i-1])-1]): i = i + 1 num1 = i % n if(num1==0): num1 = n num2 = int(i / n) else: num2 = i/...
4eb0d27d92af4012dcd5e181cc6f20bc6d187020
ashish-bisht/must_do_geeks_for_geeks
/dp/python/laregest_inc_subseq/recursive.py
567
3.765625
4
def largest_increasing_subseq(nums): return helper(nums, 0, float("-inf")) def helper(nums, index, last_num): if index >= len(nums): return 0 with_cur_num = 0 if nums[index] > last_num: with_cur_num = 1 + helper(nums, index+1, nums[index]) without_cur_num = helper(nums, index+1,...
dad98be673e722ea9104571f965c8e0cece07277
BushBaBy1989/Sickle-Cell-Disease
/SickleCellDisease.py
2,992
3.78125
4
#Files we needs to read and write DNAReadFile = open('DNA.txt', 'r') #These 2 files first used for writing DNANormalFile = open('normalDNA.txt', 'w') DNAMutateFile = open('mutatedDNA.txt', 'w') #Function that translates DNA sequence to Amino Acid Sequence def translate(DNAinput): #Needed Variables ...
6da7b5027f14c0966cca70fda2561e7d6628a106
sarkarChanchal105/Coding
/Leetcode/python/Medium/replace-words.py
1,439
4.15625
4
""" https://leetcode.com/problems/replace-words In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example, when the root "an" is followed by the successor word "other", we can form a new word "another". Given a diction...
ae0b9e5553f9dcc57079fc1bd3ffb2b1c931fa97
mannawar/MIT-lecture-series-Practise
/MIT-Lec10.py
466
3.6875
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 13 10:34:30 2019 @author: Mannawar Hussain """ #linear search on unsorted list def linear_search (L,e): found = False for i in range (len(L)): if e == L[i]: found = True return found #linear search on sorted list def s...
c30eb44e7920fff2ba1884cde731e434853f8987
WolfPack3/Saman_Documents
/Handover/Binck/SpaceRemoval.py
1,707
3.578125
4
import argparse import csv import os parser = argparse.ArgumentParser() parser.add_argument('-in-csv', help='pathname of input csv file') parser.add_argument('-out-csv', help='pathname of output csv file') args = parser.parse_args() # get the index of the first and last none space character def get_firs...
10a3ee806354f40087ab72f0e57c9689e4d663e2
istd50043-2020-fall/sutd50043_student
/lab11/ex2/ex2.py
423
3.578125
4
from mapreduce import * def read_db(filename): db = [] with open(filename, 'r') as f: for l in f: db.append(l) f.close() return db test_db = read_db("./data/price.csv") # TODO: FIXME # the result should contain a list of suppliers, # with the average sale price for al...
0fa23cc3d8b8c532ec75fc1e90fae284d44e6808
jpgsaraceni/python
/intermediario.py
7,099
3.640625
4
""" DICIONÁRIOS <dic> = {<chave>: <valor>, <...>} // cria dicionário <dic> = dict(<chave>: <valor>) ACRESCENTAR CHAVE <dic>[<nova chave>] = <valor> ACESSAR CHAVE <dic>[<chave>] DELETAR CHAVE del <dic>[<chave>] CHECAR CHAVE if <ch...
a474e19f5f4451e5bc647ba25d29e1663c271f72
yohn-dezmon/unzipping-combining-json
/moreBasic.py
768
3.890625
4
import json # here I'm trying to understand how to access the respective json objects from each JSON file within # the array x = '{ "name":"John", "age":30, "city":"New York"}' y = json.loads(x) print(y["age"]) file1 = "/Users/HomeFolder/Desktop/CongressBills/bills 2/hjres/hjres4/data.json" file2 = "/Users/HomeFo...
6a159a65ea848c61eb4b35980b2bd524a5487b56
BzhangURU/LeetCode-Python-Solutions
/T522_Longest_Uncommon_Subsequence_II.py
2,209
4.125
4
##Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings. ## ##A subsequence is a sequence that can be derived from one s...
4feaf30132801c5f195e35a3cf5758d9670b5901
willineed/nu
/Lab 4 Camel.py
3,101
4.125
4
import random print("Welcome to Camel!") print("You have stolen a camel to make your way across the great Mobi desert.") print("The natives want their camel back and are chasing you down! Survive your") print("desert trek and outrun the natives.") traveled = 0 miles_traveled = 0 thirst = 0 camel_tiredness = 0...
7361412af609d8c287a2259684afd6dbf1dc6e5c
aparece1241/PythonProjects
/myPythonProject/arcade/newGame/newGame(rewrite).py
23,570
3.59375
4
from tkinter import * import arcade import random import json import os SCREEN_WIDTH = 1000 SCREEN_HEIGHT = 600 SCREEN_TITLE = "NEW GAME" FIRTTIME_RUN = True gamedata = [{"name" : "", "score" : 0 ,"waves" : 0 }, {"name" : "", "score" : 0 ,"waves" : 0 }, {"name" : "", "score" : 0 ,"waves" : 0...
e106dac64df3fe60e3ca115cd7b3e25b20d4e32c
EliasPapachristos/Python-Udacity
/iterators_generators.py
1,281
4.3125
4
lessons = ["Why Python Programming", "Data Types and Operators", "Control Flow", "Functions", "Scripting"] def my_enumerate(iterable, start=0): # Implement your generator function here count = start for el in iterable: yield count, el count += 1 for i, lesson in my_enumerate(lessons, 1):...
1f858c8755bb4c927e9269b9b01871f4d2b15e24
Wmeng98/Leetcode
/CTCI/Python/notes.py
5,949
3.8125
4
# Python ''' Note Python 3's int doesn't have a max size (bounded by memory) float('inf') is for infinity, guaranteed to be higher than any other int value range vs. xrange (deprc in python3) If you want to write code that will run on both Python 2 and Python 3, use range() as the xrange function is deprecat...
7f03a18b6dca6ae96ee5cecb4bcd8803b970a272
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/mrkpet004/question1.py
470
4.09375
4
"""program to print out the first occurrence of a string from an input list of strings peter m muriuki""" #get list of strings and store them in an array name_str=input("Enter strings (end with DONE):\n") strings=[] while name_str!="DONE": strings.append(name_str) name_str=input("") print ("\n"+"Uniqu...
5e2ae9a2fc0e17b439329cb612195720c2b1695d
reshmaladi/Python
/1.Class/Language_Python-master/Language_Python-master/LC5_1.py
119
3.8125
4
x=eval(input("Enter no1\t")) y=eval(input("Enter no2\t")) if x>y: print(x-y) elif x==y: print(x,y) else: print(x+y)
fff9952f6a04f5e30cbb030e79a3dea4ce24788e
oceancoll/leetcode
/5.最长回文字符串/answer.py
1,175
3.8125
4
# coding:utf-8 """ 最长回文子字符串 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例 2: 输入: "cbbd" 输出: "bb" """ def longestPalindrome(s): """ 最长回文字符串 固定一个点向两边扩散的方法 https://leetcode-cn.com/problems/longest-palindromic-substring/solution/hu...
a13e010650f6bd885f5876f393392689ab7ae958
calgns/Fatorial
/facW.py
1,077
3.953125
4
fatorial = 1 contador = 4.65 while contador > 1: # um jeito de fazer as coisas print(f'{contador:,.2f} x ', end=''). print('{%g} x ' % contador, end='') # end = '' , alinhou as coisas, sem ele seria na vertical. fatorial *= contador # e eu deixei ele dentro de {chaves} por querer. não precisa usar chaves...
9a1ee4199c00c8da03b1f4ffe555ebc67b80f11f
here0009/LeetCode
/Python/666_PathSumIV.py
1,885
4.0625
4
""" If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers. For each integer in this list: The hundreds digit represents the depth D of this node, 1 <= D <= 4. The tens digit represents the position P of this node in the level it belongs to, 1 <= P <= 8. The pos...
994dba1d4c17082098128729072273cb8f9c369d
tsmith328/AoC2015
/Day01/Day1.py
394
3.703125
4
floor = 0 with open("input1.txt") as f: i = 1 skip = False while True: c = f.read(1) if not c: break if c == "(": floor += 1 else: floor -= 1 if floor == -1 and not skip: print("Entered basement on instruction number:",...
d648b539168897d283ff38fc30c3f409bbb31553
CoreyFedde/voiceapp311
/BostonData/Intents/SetAddressIntent.py
1,354
3.671875
4
from lambda_function.lambda_function import * def set_address_in_session(intent, session): """ Sets the address in the session and prepares the speech to reply to the user. """ # print("SETTING ADDRESS IN SESSION") card_title = intent['name'] session_attributes = {} should_end_session ...
c9415195d2a8a2f61bf3daae3199a7ecf2409ac8
MagicDataStructures/Trabajo_01_prueba
/src/trabajo01_1.py
4,243
3.5625
4
class Pawn: def __init__(self, color): self.color = color; def __str__(self): if self.color == 0: return '??'; else: return '?'; class Rook: def __init__(self, color): self.color = color; def __str__(self): if self.color == 0: ...
4189247227a6de559076207b14c6a6491a4c98a4
ismaildawoodjee/nifi-data-pipeline
/sourcefiles/reading_writing_files/write_file.py
370
3.890625
4
"""Writing to a CSV file""" import csv def write_example_csv(): with open("example.csv", "w", newline="", encoding="utf-8") as file: writer = csv.writer(file) header = ["name", "age"] writer.writerow(header) row = ["Wesley", 26] writer.writerow(row) if ...
37d8579ce1f4989454f9f9f11947574e33ef521a
agentnova/LuminarPython
/Luminaarpython/collections/set/set.py
487
3.71875
4
emptyset = set() a = {1, 2, 3, 4} a.add(7) print(a) st = {1, 2, 3, 4} st2 = {4, 5, 89} st.update(st2) print(st) # duplicate not allowed # insertion order not presered # not mutable # can store multiple types of values a = {1, 4, 5} b = {5, 7, 3} print(a.union(b)) print(a.intersection(b)) print(a.difference(b)) # cr...
a2db305d2c7e785ce30b4a5c577e8e9917f67481
Jaandlu/Boggle
/scrabble_score.py
1,546
3.859375
4
import random import string score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, "x": 8, "z": 10} class Player: d...
cd483b8ee5ce41bba0cb1778dad4ac8eca9d7873
dh256/adventofcode
/2018/Day17/day17.py
10,030
3.625
4
from collections import namedtuple import click Point = namedtuple('Point', 'x y') SAND = '.' WATERFLOW = '|' WATERSTANDING = '~' CLAY = '#' SPRING = '+' class Grid(): def __init__(self,clay_strands): self.spring=Point(500,0) self.clay_strands = clay_strands # add in sand self.grid...
f864abf62c7849c31b37836ca10ae6ef773a1f48
hbrinkhuis/HTBR.AoC2020
/day3.py
515
3.71875
4
import math import stdfuns data = stdfuns.open_file_split('day3.txt') rows = len(data) columns = len(data[0]) matrix = [[i for i in j] for j in data] def traverse(right, down): trees = 0 for i, val in enumerate(range(0, rows, down)): if matrix[val][(i*right) % columns] == '#': trees += ...
d63ef14d19b241c3d5732f4aeda66da9a8c11072
matty-boy79/python_learning
/lambda.py
136
3.765625
4
""" I DON'T UNDERSTAND THIS!!!! """ def myfunc(n): return lambda a: a * n mydoubler = myfunc(3) print(mydoubler(11))
282a5cbd558cc73bf488ba32a713448e526c85c7
ivenpoker/Python-Projects
/Projects/Online Workouts/w3resource/String/program-68.py
1,916
4.15625
4
#!/usr/bin/env python3 ############################################################################################ # # # Program purpose: Create two strings from a given string. Create the first string # # ...
6efceec38b9e224017629512747906318c0756cb
komodikus/pentest_tools
/search_and_sort_files/main.py
1,349
3.734375
4
from tkinter import filedialog from tkinter import Tk import os import shutil from variables import default_dir, folder_to_copy, neededs_formats def create_folder_for_format(folder_to_copy, file_format): if not os.path.exists(folder_to_copy + '/{}'.format(file_format)): os.makedirs(folder_to_copy + '/{}'....
c5240f3b9000152ab09f64d3ea639ad063e34de3
djrrb/Python-for-Visual-Designer-Summer-2021
/session-3/bezierPathDemo.py
550
3.71875
4
# make a shape using BezierPath # shape height sh = 200 # determine the length of each handle randomly rightHandleLength = randint(-150, 150) leftHandleLength = randint(-150, 150) # define a bezier path bp = BezierPath() # move to my starting point bp.moveTo((0, 0)) # straight line across bp.lineTo((width(), 0)) # s...
784cf90317229acc2a138f879c94b3b779a7af2c
Sushilkumar168141/cryptix_ctf_dump
/welcome_to_the_real_deal/ape.py
339
3.5
4
import random from math import sqrt a='' with open('hashed.txt','r') as file: a=file.read() x = [] x = a.split(':') wordlist=[] msg = [] for j in x[:-1]: wordlist.append(j) #msg.append() print(wordlist) for word in wordlist: msg.append(int(word,0)) print(msg) unhashed_number = int(pow(numerator/denominator,2)) s...
f165a3b01862f08e7f366f9a2022c987944ba863
Anshul-GH/jupyter-notebooks
/UdemyPythonDS/DS_BinarySearchTree/App.py
369
3.84375
4
from DS_BinarySearchTree.BinarySearchTree import BST bst = BST() bst.insert(12) bst.insert(10) bst.insert(-2) bst.insert(1) print('Traversing the original tree:') bst.traverseInOrder() print('Max value in the tree:', bst.getMax()) print('Min value in the tree:', bst.getMin()) print('Traversing the tree with one nod...
bec1dde8f4d25459a8daaa4e3d6aab04bf47bb50
Nkhinatolla/PoP
/Lection-4/while.py
141
3.609375
4
i = 5 while i < 15: print(i, end = " ") i = i + 2 print() j = 1 while j < 15: j = j + 1 if (j == 4): continue print(j, end = " ")
aac81fa6b8af0af8f37bddc2b09f3a57bd7b0c40
mnickey/argParse
/argparse_basic.py
3,740
4.3125
4
""" positional arguments """ # import argparse # parser = argparse.ArgumentParser() # parser.add_argument("square", help="display a square of a given number", # type=int) # args = parser.parse_args() # print args.square**2 """ optional arguments """ # import argparse # parser = argparse.ArgumentParser() # parser....