blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6d9abcc79d4d5c4d1270195597069341db58f2fc
dheena18/python
/day6 ex7.py
74
3.96875
4
days=int(input("enter the days:")) age=days/365 print("the age is:",age)
7a4fbea460e5eb1eedc5d4b143e29c29e15dc74e
bphermansson/RpiArduinoI2C
/RpiArduinoI2C.py
960
3.84375
4
# An Arduino is connected to the Rpi via I2C. As the Rpi has to be master we use an extra Gpio, this is # used by the Arduino to nofify the Rpi that is has something to say. # The Arduino pulls a pin high which creates an interrupt here (gpioInt) # The code then reads from the I2C bus. # http://wiki.minnowboard.org...
8c8723414190e52daeee596b3d5e0c6ecb653002
shashank-23995/Practice
/Python/Day_10/Exercise_1/problem1.py
385
4.03125
4
# Write a program which uses while loop to sum the squares of the integers # (starting from 1) until the toal until the total exceeds 200. Print the final total and # the last number to be squared and added number = 1 total = 0 while(total <= 200): total = total + (number * number) number += 1 print("total ...
8c537d838885a4e3f62e56935d608f7059f09323
lightbits/euler
/problem63.py
1,194
4.1875
4
# The 5-digit number, 16807=7^5, is also a fifth power. # Similarly, the 9-digit number, 134217728=8^9, is a ninth power. # How many n-digit positive integers exist which are also an nth power? ############ # Solution # ############ def numDigits(n): result = 0 while (n > 0): n = n // 10 result += 1 return r...
feb4e56eee1cacc7046f66a1ddad18038063620f
sarkarChanchal105/Coding
/Leetcode/python/Medium/non-decreasing-array.py
1,072
3.859375
4
""" https://leetcode.com/problems/non-decreasing-array/ Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2). Example 1: I...
55d0cccc5b93505ff0af1bbf01afb21696fedcc0
why1679158278/python-stu
/python资料/day8.7/day06/exercise09.py
745
3.65625
4
""" 遍历练习: 在终端中打印dict_HongKong所有键(一行一个) 在终端中打印dict_XinJiang所有值(一行一个) 在终端中打印dict_LiaoNing所有键和值(一行一个) 在dict_LiaoNing字典中查找93对应的键名称 """ dict_HongKong = {"region": "香港", "new": 80, "now": 1486} dict_XinJiang = { "region": "新疆", "new": 22, "now": 618 } dict_LiaoNing = { "...
a937f33002856b7bc4a530eb332983d77908c859
trewarner/ErrorCode-404
/ErrorCode-404.py
2,137
3.75
4
#This Code Will Help You Delect Errors In Your Code def analyze(code): code = code.strip() if code.startswith("def"): if not (code[-1]==':'): print ("ERROR: Missing colon.") elif code.startswith("if"): if not (code[-1]==':'): print ("ERROR: Missing colon.") elif c...
f9a61f2a3f3c17badf63ea15d8227320f22d78ab
Pandinosaurus/ensae_teaching_cs
/_todo/programme/seance2_recherche_dicho.py
798
3.8125
4
# coding:latin-1 l = [2, 3, 6, 7, 9] # si la liste n'est pas trie, il faut crire : l.sort () x = 7 a = 0 b = len(l)-1 while a <= b : m = (a+b)//2 # ne pas oublier // sinon la division est relle if l[m] == x : position = m # ligne A break elif l[m] < x : a = m+1 else : ...
40e76ded64ff93d666fc4794a21b0c32afbedda5
eukevintt/curso-em-video-pyhton
/Mundo 1/PythonExercicios/ex005.py
260
3.9375
4
print('===== EXERCICIO 005 =====') print('Faça um programa que leia um número inteiro e mostre na tela o seu sucessor e antecessor') n = int(input('Digite um número: ')) print('O sucessor do número {} é {} e o antecessor é {}'.format(n, (n+1), (n-1)))
7ab5236a9a1b7c0e454dc98a9c063afc0082ea1b
haijiwuya/python-collections
/base/10.file/introduce.py
2,592
4.09375
4
# open(file, mode='r', buffering=-1,encoding_=None, errors=None, closed=True,opener=None) # file要打开文件的名字(路径) # 返回一个对象,这个对象代表了当前打开的文件 file_name = 'a.txt' file = open(file_name) print(file) # 读取文件 # read()可以接收一个size作为参数,该参数用来指定要读取的字符的数量 # 每一次读取都是从上次读取到的位置开始读取的 # 如果字符的数量小于size,则会读取剩余所有的 # 如果已经到了文件的最后了,则会返回''空串 content = ...
0ba83af9d1a1891b0186258a9b639933a85e7cea
macson777/test_repo
/src/hw_14/task_14_2/matrix_funcs.py
544
3.625
4
def max_elem_matrix(matrix): elem_max = matrix[0][0] for row in matrix: for elem in row: if elem > elem_max: elem_max = elem return elem_max def min_elem_matrix(matrix): elem_min = matrix[0][0] for row in matrix: for elem in row: ...
9a66e7e89119caa1f0c886730cbb1ce93ec800be
candytale55/Learn_Python_3_Code_Challenges-Dictionaries
/count_first_letter.py
970
4.09375
4
# count_first_letter takes a dictionary named names as a parameter. names should be a dictionary where the key is a last name and the value is a list of first names. def count_first_letter(names): new_dict = {} for key,values in names.items(): if key[0] not in new_dict: new_dict[key[0]] = len(values) ...
2162e3fc924f0d6f35d149a3709291cee5e7f9e9
jenee/ProjectEuler
/009/specialPythagoreanTriplet.py
877
3.953125
4
''' http://projecteuler.net/problem=9 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ''' import math maxFactor = 1000 #maxFactor = int(m...
6b319cade886ef5d30fd7c65b7f5ba018582cb1f
Qiaogun/handpose-mouse-simulation
/script.py
132
3.546875
4
strng_res = "" for i in range(0,21): strng_res += "x"+ str(i) + "," + "y" + str(i) + "," + "z" + str(i) + "," print(strng_res)
c1c5b3e4fd0f9230576a710cd2714f4418adb24d
mattbellis/matts-work-environment
/python/number_theory/triangle_areas/triangle_areas.py
1,490
3.515625
4
import numpy as np import matplotlib.pylab as plt ################################################################################ def area(a,b,c): s = 0.5*(a+b+c) A = np.sqrt(s*(s-a)*(s-b)*(s-c)) return A ################################################################################ lo = 3 hi = 31 x ...
ab551360a70ea05bb3f6dae8accff97c6a907f3c
Anju-PT/pythonfilesproject
/advancedpython/regularexpression/keralaregistration.py
157
3.515625
4
import re n= input("enter:") x="([K][L][0-9]{2}[A-Z]{2}[0-9]{4}$)" match=re.fullmatch(x, n) if match is not None: print("valid") else: print("valid")
39bab0769a24c89ecb08e4f5a8df1e95369ded53
pranavladkat/polyfit
/src/main.py
1,348
3.90625
4
import numpy as np import matplotlib.pyplot as plt from regression import Regression def main(): #read input data my_data = np.genfromtxt('regression_data.txt', dtype=float, delimiter=',') # create input and output numpy arrays x = my_data[:,0] y = my_data[:,1] # create regres...
4c76f9d0594b86bd045a896ce4d5bd0617871367
Kurossa/programming
/python/learning/task_7a.py
4,190
4
4
#!/usr/bin/python3 # Subtask 1 # # Create 2 class # 1st class will by named Person and during creation you will pass name, surename, age, height i.e. person1 = Person('Marek', Kowalski, 33,183) . # It will have 4 methods to get, name, surename, age, height i.e. GetName() # # 2nd class RandomPerson will contains 2 lis...
0d74d243edc86d3fee051bf4cf0b2a81319161a6
INF1007-2021A/c03_ch3_exercices-HammBel
/exercice.py
1,330
4.34375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def average(a: float, b: float, c: float) -> float: result = (a + b + c) / 3 return result def to_radians(angle_degs: float, angle_mins: float, angle_secs: float) -> float: angle_rads = (angle_degs + angle_mins / 60 + angle_secs / 3600) * math.p...
7a00d264395f0c74b0726bb853822f68ddb111cc
hieupc2002/dainam-1405
/So nguyen to.py
302
3.90625
4
a = int(input()) flag = True if a<2: flag = False elif a==2: flag = True elif a%2==0: flag = False else: for i in range(3 ,a , 2): if a%i==0: flag = False if flag == True: print( a , " là số nguyên tố") else: print( a , " không là số nguyên tố")
57fce800f9b6cce6d95f40630d956abfebb7c240
akshays94/algo-ds
/arrays/largest-range.py
1,799
4.03125
4
''' largest range: write a function that takes in an array of integer and returns an array of length 2 representing the largest range of numbers contained in that array ''' def largest_range_1(arr): arr.sort() max_size = 1 best_range = [arr[0]] * 2 curr_max = 1 curr_range = [ar...
55359c95c90d537588617dd2cf616b686406b2cc
hewei-bit/PYTHON_learning
/Leetcode/1.数据结构/1.队列&栈/3.栈/4.逆波兰表达式求值.py
1,462
4.03125
4
""" 150. 逆波兰表达式求值 有效的运算符包括 +, -, *, / 。每个运算对象可以是整数,也可以是另一个逆波兰表达式。 说明: 整数除法只保留整数部分。 给定逆波兰表达式总是有效的。换句话说,表达式总会得出有效数值且不存在除数为 0 的情况。 示例 1: 输入: ["2", "1", "+", "3", "*"] 输出: 9 解释: 该算式转化为常见的中缀算术表达式为:((2 + 1) * 3) = 9 示例 2: 输入: ["4", "13", "5", "/", "+"] 输出: 6 解释: 该算式转化为常见的中缀算术表达式为:(4 + (13 / 5)) = 6 """ from typing impo...
631443c2572730d5db0e0cae013c47235dc071a3
davidhodev/Artificial-Intelligence-Projects
/EightPuzzleFinal.py
13,998
3.796875
4
import math from queue import PriorityQueue # DAVID HO DH2487 #Creating a Node class to store each 8 puzzle node class Node: def __init__(self, data, goal, path, fValueListString, linearListString, move=""): self.data = data self.goal = goal self.fValue = self.manhattanDistance(goal) + (len...
834abd51e7470af5f98f34947b234f60c6c58fb0
osulyanov/drawing_math_calc_api
/polygon.py
4,060
3.515625
4
import sys import side import extras import math def is_shape_valid(shape): """ Checks whether the given shape can be solved :param shape: dict :return: bool """ lines_types = {} for line in shape['lines']: if not side._check_line(line): return False return Tr...
6bba672f1a2a75020ce60c2378f3b27ffc003ea0
lychlov/LintBrush
/Google/WordSquare.py
591
3.5
4
class Solution: """ @param words: a list of string @return: a boolean """ def validWordSquare(self, words): # Write your code here k = 0 while k < len(words): for i in range(k): try: if words[k-i][k]==words[k][k-i]: ...
77ce97ea6222807073b146bb69a4c9a2739765f7
jisenber/Pak_Adventures
/Pak_Adventures.py
14,353
4.0625
4
from sys import exit medals = [] rooms = ["peanut_butter_room", "snorlax_room", "oil_room", "garlic_room", "chocolate_room"] def lobby(): print "\nYou are in the lobby, and you have the following medals:" for y in medals: print y print "\nchoose a room where you have not acquired a medal." for i, x in enumerate(...
078d5d8768ffac3aa383805845ea9c287a9d25f4
AdamZhouSE/pythonHomework
/Code/CodeRecords/2531/60639/265206.py
514
3.671875
4
def get(arr): return arr[1] inp=input() string=[] for i in range(len(inp)): string.append(inp[i]) list=[] for i in range(len(string)): if string[i] not in list: list.append(string[i]) else: continue order=[[] for i in range(len(list))] for i in range(len(list)): order[i].append(list...
71167e42882779979dbb16ea6741a97b81e1d702
PaulSwenson/BoardGames
/card_deck/card_deck/deck.py
8,286
4.25
4
#!/usr/bin/env python """ standard_card_game.py Framework for a deck to simulate card games with a standard deck. """ # standard includes import random import types # TODO: move these variables to a types.SimpleNamespace to ensure they are private # variables for local use suits = ['heart', 'spade', 'club', 'diamon...
5ec5974d71e08d4312dc9e06b54beff2eae9c34c
full-time-april-irvine/kent_hervey
/python/python_fundamentals/submission_user_class.py
1,514
3.921875
4
class User: def __init__(self, username, email_address): self.name = username self.email = email_address self.account_balance = 0 def make_deposit (self, amount): self.account_balance += amount def make_withdrawal(self,amount): self.account_balance -= amount d...
f564ac30171da22d210ebd0017bd41afa04619e6
Alferdize/Data-Structure-and-Algorithms
/Algorithms/binary_search.com/Largest_binary_search_subtree.py
755
3.65625
4
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root): # Write your code here max_size = [0] max_node = [None] def traverse(node): if not n...
0393c454845d37d7ea1312d26d6e17056b7a3514
BigSkyChance/DiscordLeaderPick
/SecureMethod.py
678
3.578125
4
**************************************** Method of pulling name from hat Must Be pulled 3 times to become leader **************************************** import secrets from DiscordLeaderPick import main def ThreePick(): names = GetNames() winlst = dict.fromkeys(names, 0) # this inits a dictionary using the name...
2b31cecba017e9f45df77c99d47f10a77d91c05c
adschristian/studying-python
/strings/exercicio13.py
1,984
4.28125
4
# author: Christian Alves # Jogo da palavra embaralhada. Desenvolva um jogo em que o usuário tenha que adivinhar uma palavra que será mostrada com as letras embaralhadas. O programa terá uma lista de palavras lidas de um arquivo texto e escolherá uma aleatoriamente. O jogador terá seis tentativas para adivinhar a palav...
c53970ee70713f993634c3be9dde8c65f44b3b98
KillTheReptiles/LaboratorioRepeticionRemoto
/positivos.py
290
4.1875
4
print("Comienzo") print() numero = int(input("Escriba un numero positivo: ")) while numero < 0: print("Has escrito un numero negativo, Fin:D") break while numero > 0: print("Has escrito un numero positivo") numero = int(input("Escriba positivo: ")) print() print("Final")
3a98dcd21538a2ea1d5a636b3f7bd47fd328ac27
nandiryandi/Program-Sederhana-Python
/rumus-bangundatar-ruang/bangundatar/DuaBilangan.py
189
3.828125
4
bil1 = int(input("Masukan Angka Pertama: ")) bil2 = int(input("Masukan Angka Kedua : ")) jumlah = float(bil1) + float(bil2) print("Jumlah {0}+{1} adalah {2}" .format(bil1, bil2, jumlah))
f3a0bfdd73ce48a0b42cac89cbcac02ca83d6eaf
r-waki/tdd-training
/money.py
653
3.734375
4
from abc import ABCMeta class Money(metaclass=ABCMeta): def __init__(self, amount): self.amount = amount def __eq__(self, money): return (self.amount == money.amount and self.__class__ == money.__class__) def dollar(amount): return Dollar(amount) def franc(am...
0ae6d3bb3bee6b500af09974b8f7f863a1195677
DiegoT-dev/Estudos
/Back-End/Python/CursoPyhton/Mundo 01/Exercícios/ex012.py
133
3.515625
4
p = float(input('Valor na etiqueta: R$')) pf = p-(p*5/100) print('O valor final, aplicando o desconto de 5% é R${:.2f}'.format(pf))
f65546cc6289ebcdf3182ecfd81c39be6f13a0fc
andres074/segundo_programa
/sleep_3.py
548
3.96875
4
'''Crea un programa que pregunte al usuario que adivine un numero del 1 al 10, pero ese numero se va a generar aleatoriamente. Hacer esperar al usuario 3 segundos antes de dar la respuesta.''' import random from time import sleep while True: number_to_guess = random.randint(1,10) usser_number= input('Adivina ...
8f56c2df73dd50509b7b4483f7375a97b209be15
Punarvagowda/PESU-IO-SUMMER
/coding_assignment_module1/1 comma separated.py
151
3.84375
4
values = input("Enter numbers seperated by comma\n") list = values.split(",") tuple = tuple(list) print('List: ',list) print('Tuple: ',tuple)
41b727f7d0196c42dd8a03b8e954b864ad64e7e1
riyaoyao/Small-Program-Python
/3_NumStatic.py
379
3.625
4
# 程序说明:统计文件中的制定单词出现次数 fp = './File/words.txt' # 打开文件,如果打开成功,用read读取文件的全部内容 file = open(fp) text = file.read() word = 'love' num = 0 while text.find(word)!=-1: num = num + 1 # split(str,num)第二个参数为分割次数 text = text.split(word, 1)[1] print(num) file.close()
9d17915f5742bbe69f78a61573905a71821c0669
feritkerimli/PragmatechFoundationProject
/Python_Tasks/Week08Weekend_Tasks/task03.py
212
3.546875
4
myList=[1,34,56,100,-12,87,987,1,3,5,56,67] def doubleElements(lst): s="" for i in range(0,len(lst),2): s+=str(lst[i])+" " print("Double index elements:",s) doubleElements(myList)
38316270cff7011ed43181a5a426dcb0675fb285
pkc-3/python
/Ch02/p43.py
396
4.375
4
#표준입력장치 예 # (1) 문자형 숫자 입력 num = input("숫자입력:") print('num type :',type(num)) print('num=', num) print('num=', num*2) # (2) 문자형 숫자를 정수형으로 변환 num1 = int(input("숫자입력:")) print('num1=', num1*2) # (3) 문자형 숫자를 실수형으로 변환 num2 = float(input("숫자입력:")) result = num1 + num2 print('result =', result)
d5bcd59363be747a4229c2aee4fc50dc8ed4a826
HamletXiaoyu/python_demo
/leetcode.py
1,562
3.78125
4
#!/usr/bin/env python #coding=utf-8 #title : leetcode #description : #author : #email : #date : #notes : ''' You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add t...
26735a6976f2135525cc8f2a3420e0fa70e250de
AgentT30/InfyTq-Foundation_Courses
/Programming Funcamentals Using Python/Day 5/bank.py
1,914
3.640625
4
def withdraw(account_list, balance_list, amount): for index in range(0, len(account_list)): if(account_list[index] == account_number): flag = True value = index if(flag == True): balance = balance_list[value] new_balance = balance-amount if(new_balance >= ...
409e7d03ff283095aaf9c22ed75c57c3c35211fb
CoderDojoDC/python-table
/turtle/turtlegraph.py
199
3.78125
4
#!/usr/bin/env python import turtle, math t = turtle.Turtle() screen = t.getscreen() t.penup() for x in range(-10,10): y = math.acos(x) t.setpos(x,y) t.pendown() turtle.exitonclick()
5fc1c8eec016a69271839a3ca33e2c919c480a05
hzwangchaochen/red-bull
/leetcode/python/merge_intervals.py
327
3.828125
4
#Definition of Interval. class Interval(object): def __init__(self, start, end): self.start = start self.end = end class Solution: """ @param intervals: interval list. @return: A new interval list. """ def merge(self, intervals): intervals.sort() # write your co...
20358eeda2798de0e93373fd303d34c451d4d010
martin-porra/ejercicio2unidad3
/clasesabor.py
560
3.5625
4
class sabor: __numero = 0 __nombre = '' __descripcion = '' vendidos=0 def __init__(self,des,nom,num): self.__descripcion = des self.__nombre = nom self.__numero = num def nombre(self): return self.__nombre def vendi(self): self.vendidos = self.vendidos ...
5a7bd0827b51e1f4b3dc63729a8660b2954cba3e
kwiegand/Advent-of-Code-2020
/2/puz1.py
893
3.546875
4
input = open("input.txt", 'r') password=[] for line in input: password.append(line) count = len(password) print("Read in " + str(count) + " passwords") record = [] bad_records = 0 brec_index = [] for i in range(0, count): field = password[i].split(' ') hyphen_index = field[0].find('-') min = int(field[0][0:hy...
612b81411bc56e09563460cc95f84941545c8174
ccgallego/ComputacionGrafica
/Primer Parcial/teclas.py
1,228
3.609375
4
import pygame if __name__ == '__main__': pygame.init() pantalla = pygame.display.set_mode([640,480]) pos=[10,10] reloj=pygame.time.Clock() pygame.draw.circle(pantalla,[0,255,0],pos,10) pygame.display.flip() var_y=0 var_x=0 x=0 y=0 fin=False while not fin: for ev...
69220dbd8294995d5a813c97db60a4fb85a52eeb
FGCR/CT_Python
/Solutions/LeetCode/125_ValidPalindrome.py
303
3.765625
4
import re def ValidPalindrome(sentence): trimmed = re.sub('[^0-9a-z]','',sentence.lower()) reversed_trimmed = trimmed[::-1] if reversed_trimmed == trimmed: return True return False print(ValidPalindrome("A man, a plan, a canal : Panama")) print(ValidPalindrome("race a car"))
f90df2fea291251b4c623ae5ecd4bb4583143112
Cicyy/Tryouts
/EnglishWord.py
255
4.125
4
#Prog asking for english word# original = raw_input("Enter a word:") empty_string = "" if len(original) > 0: print original elif len(empty_string) == 0: print "Empty" else: print "Exit" raw_input("Press Enter to exit, thank you!")
cdb0937cf63a65055cf9117b975bffcb893b47fd
starrye/LeetCode
/all_topic/esay_topic/599. 两个列表的最小索引总和.py
2,210
3.90625
4
#!/usr/local/bin/python3 # -*- coding:utf-8 -*- """ @author: @file: 599. 两个列表的最小索引总和.py @time: 2020/5/6 15:21 @desc: """ from typing import List """ 假设Andy和Doris想在晚餐时选择一家餐厅,并且他们都有一个表示最喜爱餐厅的列表,每个餐厅的名字用字符串表示。 你需要帮助他们用最少的索引和找出他们共同喜爱的餐厅。 如果答案不止一个,则输出所有答案并且不考虑顺序。 你可以假设总是存在一个答案。 示例 1: 输入: ["Shogun", "Tapioca Express", "Bu...
a320079ffe63602d292d012d54442444754b7916
Ashwinkrishnan17/Guvi1
/integer division and mod.py
113
3.6875
4
a,b,c = input().split() x = int(a) y = int(c) if(b == "/"): z = x // y print(z) else: z = x % y print(z)
47522a166a29a64f6096f8c064aa881d3d4b2d46
thinkofher/mymines
/src/mine/tools.py
1,908
3.765625
4
from itertools import product def cords_directions(delete_self=True): """ Returns list with combinations of directions for searching in neighborhood """ # Create all possible combinations of neighboor location # Example: (-1, 1), (0, 1), (1, 0) ... neighborhood_combinations = list(product(...
866d37a18b9650661a583b34c67d4fb93e1e6392
wonanut/LeetCode-2020
/src/2020-01/week4/236-lowest-common-ancestor-of-a-binary-tree.py
1,632
3.84375
4
""" 236:二叉树的最近公共祖先 链接:https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/ 难度:中等 标签:二叉树、递归 评价:经典二叉树递归题目,我没写出来,待整理。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class S...
421e87fe749f156492cfeeecfca43250faa1c9f8
ayushedu/algorithmproblems
/linkedlist/intersect.py
684
3.828125
4
from node import Node def search(node, llist): """Search data in linkedlist""" while llist: if llist == node: return True llist = llist.next return False def intersect(first, second): """Return matching nodes complexity O(N^2) """ rs = [] while first: ...
210bf27dc89dd06b13035e92f7c0f1d9024b83f5
ErickIR/SnakePython
/helper.py
605
3.53125
4
def calculate_distance(P, Q): X = (Q[0] - P[0]) ** 2 Y = (Q[1] - P[1]) ** 2 return (X + Y) ** 0.5 def is_wall_colliding(pos, WIDTH, HEIGHT): return pos[0] >= (WIDTH) or pos[0] <= 0 or pos[1] >= (HEIGHT) or pos[1] <= 0 def are_blocks_colliding(block, other): return block[0] == other[0] and ...
78cadacdb7273ab2c781540edcf667324760433f
Tigge/advent-of-code-2015
/day_12.py
646
3.890625
4
#!/usr/bin/env python3 import re import json def number_sum(): return sum(map(int, re.findall("-?[0-9]+", open("day_12.txt").read()))) def number_red_sum(): inp = json.load(open("day_12.txt")) def visit(obj): if type(obj) is list: return sum(map(visit, obj)) elif type(obj) ...
1ebb0c0890eb52d5fa4f12d6f5d864e8ad8dd109
mustard-seed/graph_algo
/test_digraph.py
578
3.765625
4
from digraph.digraph import Digraph if __name__ == '__main__': numV = 13 edges = [ [4, 2], [2, 3], [3, 2], [6, 0], [0, 1], [2, 0], [11, 12], [12, 9], [9, 10], [9, 11], [7, 9], [10, 12], [11, 4], [4, 3], [3, 5], [6, 8], [8, ...
ab912e06484174e40cce2162e8e5c57865fec30b
MarcosPenin/FuncionesPython
/Funciones/Funciones2.py
901
4.25
4
"""Crea una función “calcularMaxMin” que recibe una lista con valores numéricos y devuelve el valor máximo y el mínimo. Crea un programa que pida números por teclado y muestre el máximo y el mínimo, utilizando la función anterior.""" def calcularMaxMin(lista): a=max(lista) b=min(lista) return a,b list...
26d4e3533246ae8c57e0298eeabefba71bca6dd8
tusharsadhwani/leetcode
/linked_list_cycle.py
1,731
3.703125
4
from typing import Callable, Optional class ListNode: def __init__(self, val: int) -> None: self.val = val self.next: Optional[ListNode] = None def create_cyclic_node_list(values: list[int], pos: int) -> ListNode: """Creates a potentially cyclic ListNode out of a list of values""" curren...
ab900b3593b45da58fd39d2bb6e1c4fd888da996
peluza/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/9-multiply_by_2.py
111
3.71875
4
#!/usr/bin/python3 def multiply_by_2(a_dictionary): return ({k: 2 * v for (k, v) in a_dictionary.items()})
71b1419c85d85f9c6d082c0f78b54eac94a0ab7b
wenzhiquan/leetcode
/leetcode_all/#118-easy-pascal's_triangle.py
712
3.625
4
#!usr/bin/env python # -*- coding:utf-8 -*- # @author: wenzhiquan # @author: 15/4/3 # @description: class Solution: # @return a list of lists of integers def generate(self, numRows): if numRows == 0: return [] else: result = [[1] for i in range(numRows)] for...
d68c5aa7b050c0fca5a268cb5a404c5e2b05fac2
DyDyktiv/low_lvl_course_of_Python
/2 week/2.20 Ice cream.py
155
3.984375
4
k = int(input()) if ((k % 5 % 3 == 0 or k % 5 % 3 == 1 or k % 5 % 3 == 2) and k > 10) or \ k % 5 % 3 == 0: print('YES') else: print('NO')
c29fa32508432a90aa235a5fdb76a61041240050
khushbooag4/NeoAlgo
/Python/ds/Linear_Probing_In_Hashing.py
1,481
3.78125
4
""" Linear Probing is a technique for resolving hash collisions of calues of hash function.It is a form of open addressing. In this scheme, each cell of a hash table stores a single key–value pair. When the hash function causes a collision by mapping a new key to a cell of the hash table that is already occupied by an...
99cbf0a8edb3e155d4c555bc2dcce1b0518c2540
neethupauly/Luminarmaybatch
/python collections/sets/Adding_program.py
239
3.640625
4
# enter limit 4 # enter elements1 # enter elements4 # enter elements7 # enter elements8 # {1,4,7,8} limit=int(input("enter limit")) s=set() for i in range(limit): elements=int(input("enter elements")) s.add(elements) print(s)
a69d212c267ca5f13e64891180720b9e908b81bf
mingrui4/Machine-Learning-Mini-Projects
/mp8/k_means.py
1,737
3.6875
4
from copy import deepcopy import numpy as np import pandas as pd import sys from sklearn.cluster import KMeans ''' In this problem you write your own K-Means Clustering code. Your code should return a 2d array containing the centers. ''' # Import the dataset df = pd.read_csv('data/iris.data') data= df.iloc[:,[0,1,2...
a8ebe0de03668ab428d468639333e7b436387cd0
spencer517/python_calculator
/src/CsvReader.py
254
3.5625
4
import csv class CsvReader: def __init__(self, file): self.data = [] with open(file) as txt: csv_txt = csv.DictReader(txt, delimiter=',') for row in csv_txt: self.data.append(row) pass
5e2ba4f475cdb5f93f4a9bb10d246434b807eeec
saberkid/PolyGlot
/utils/alphabet_former.py
2,634
3.53125
4
# coding=utf-8 #some code to separate the language from one another in order to better encode them import math X = open("../data/train_set_x_cleaned_nothing.csv","r") Y = open("../data/train_set_y.csv","r") #get rid of the first line Slovak = [] French = [] Spanish = [] German = [] Polish = [] All = [] X.readline() Y.r...
fe048f3c300cd69927b5893d625223cc6d2f9c19
licheebrick/leetcode
/python/array/15_3sum.py
2,519
3.71875
4
from collections import defaultdict from collections import deque import sys class Tree(object): def __init__(self, left=None, right=None, data=None): self.left = left self.right = right self.data = data class Vertex(object): def __init__(self): self.d = 0 self.e = Non...
1dce5dcd60368faca864576fd2bb57c0d6d8d9a8
1987617587/lsh_py
/basics/day10/bank.py
8,692
3.640625
4
""" # author Liu shi hao # date: 2019/11/16 11:39 # file_name: bank """ # 12. # 银行账户管理系统(BAM) # 写一个账户类(Account): # 属性: id:账户号码 长整数 # password:账户密码 # name:真实姓名 # person_id:身份证号码 字符串类型 # email:客户的电子邮箱 # balance:账户余额 # 方法: # deposit: 存款方法,参数是浮点数型的金额 # withdraw:取款方法,参数是浮点数型的金额 # 初始化方法: # 1.将Account类作成完全封装,注意:要辨别每个属性的是否需要公...
3e112864da1354142c3b7d0c4a634a4a7e7880a9
ripiuk/treasure-hunt
/treasure_hunt/func_implement.py
1,385
4.09375
4
""" Implementation using functional programming approach """ import typing as typ from treasure_hunt.utils import list_to_str def _make_treasure_path(treasure_map: typ.Tuple[typ.Tuple[int, ...], ...], curr_row: int = 1, curr_col: int = 1) -> typ.List[int]: """ Recursion functional im...
da5df88e0630e69d01dc377139dde4001e1cb976
MayKeziah/CSC110
/studentclass.py
653
3.6875
4
class student: def __init__(self, Firstname, Lastname, Score): self.firstname = Firstname self.lastname = Lastname self.score = float(Score) print("New student object created:", self.firstname) def getFirstname(self): return self.firstname def getLastname(self): ...
1e7d9f10ceb347c5475496e0aad4a0610cd420a3
Hilldrupca/LeetCode
/python/Arrays 101/Inserting Items Into an Array/duplicatezeroes.py
1,020
3.859375
4
from typing import List class Solution: def duplicateZeroes(self, arr: List[int]) -> None: ''' In-place duplication of zeroes in a list of integers. At each zero element, remaining elements are shifted right to make room for new zero. Elements beyond the original le...
991e56d96202448a8a8a7e8ca3fa3121b551eb02
borshec/w3resource_exercises
/20.py
81
3.921875
4
s = input("Enter string:") n = int(input("Enter number of repeats:")) print(n*s)
87a12d01e5bf49e8a7a1db4a5355cf523300d899
TomatoVampire/PythonNetwork
/TimeQuery/Server.py
1,465
4.03125
4
''' 实现一个基于客户服务器的系统时间查询程序。传输层使用 TCP 。 交互过程: 1)客户端向服务器端 发送字符串 ” 。 2)服务器端收到该字符串后,返回当前系统时间。 3)客户端向服务器端发送字符串 ” 。 4)服务器端返回 ” Bye”,然后结束 TCP 连接。 ''' from socket import * import time serverPort = 12000 serverSocket = socket(AF_INET, SOCK_STREAM) serverSocket.bind(('', serverPort)) #print(time.asctime(time.localtime(time.time...
338d1bc93adcabe66c64386b3b5fe0fd3552b01a
chunyuema/ProPython
/generator.py
991
4.375
4
# Generator: Functions that return an iterable set of items are called generators. def sqaure(nums): res = [] for num in nums: res.append(num*num) return res # This currently returns a list newNums = sqaure([1, 2, 3, 4]) print(newNums) # Convert into generator def sqaureYield(nums): for num...
4680ec7fcd8427b8796002f4c66a781ef96e063a
bashtheshell/adventofcode_2020
/day3/day_3.py
1,407
3.625
4
grid = [] with open('2020_day_3_input', 'r') as input_file: for each_line in input_file: grid.append(each_line.split()) print ("--- PART 1 ---") horizontal_length = len(grid[0][0]) horizontal_position=0 tree_counter=0 for i in range(len(grid)): if i == len(grid) - 1: break horizontal_po...
b0c0c0d030d38fd0eb83356cd38bf7221bc995f9
f5sivaprakash/ecspython
/day2.py
118
3.59375
4
print("Hi,please provide temp.in deg.celsius") cel =float (input()) print(type(cel)) fah =(32+((9/5)*cel)) print(fah)
41debca1cf52f3e007c1d33b2e1a56d97e7e71d2
shaoda06/python_work
/Part_I_Basics/exercises/exercise_10_10_common_words.py
1,345
4.375
4
# 10-10. Common Words: Visit Project Gutenberg (http://gutenberg.org/ ) # and find a few texts you’d like to analyze. Download the text files for these # works, or copy the raw text from your browser into a text file on your # computer. # You can use the count() method to find out how many times a word or # phrase app...
8285112d982cdfae29abac6082dc36487bbdbc2f
Sealeon/Hello-World
/Hello World.py
634
4.03125
4
# Says Hello, World after some coercing. # Hello World++ # Emily Knight # 21/01/2020 from tkinter import * from tkinter import messagebox patience = 3 def message(): global patience if patience != 0: patience -= 1 messagebox.showwarning("This is", "Hello, world!") else: messagebox...
59dc5d051ff3c37706a3ed3a1e14f1c9e9e11963
snytav/intro-to-deep-learning-with-pytorch
/quiz-script/softmax-function-quiz.py
429
3.78125
4
# Softmax_Fucntion Quiz # This Script does not Work # Default format created by Udacity import numpy as np # Quiz : Write a function that takes as input a list of numbers, and returns the list of values given by the softmax function. # ==Answer== def softmax(L): expL = np.exp(L) sum_expL = sum(expL) resu...
3fb554f5a65a6ec562a838a6fce67c0e346a29c3
Federic04/Unidad4POOEventos
/ventanaConGeometriaPlace.py
4,537
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 26 21:11:03 2020 @author: morte """ from tkinter import * from tkinter import ttk, font # Gestor de geometría (place) class Aplicacion(): __ventana=None __clave=None __usuario=None def __init__(self): self.__ventana = Tk() ...
f21b4fb45708b8a119178324ccaa0332babb5f89
snailweeds/2021knupython
/2.variables+datatypes/string_datatypes.py
1,347
3.796875
4
s2 = "Hello Haedal!" print(s2) s6 = '''Hello Haedal!''' print(s6) # 이스케이프 코드 longtext1 = """Hello, Haedal! My name is Haedal Programmiing.""" # 개행 가능 print(longtext1) longtext2 = 'Hello, Haedal!\nMy name is Haedal Programmiing.' # 개행 불가능 print(longtext2) # String Interpolation a = 123 new_q = f'{a}' print(new_q) #...
b238cc16fd08c22893c80c74e8f8294c7fc87cf3
arijit1410/cs498
/assignment2/utils/gradient_check.py
1,214
3.609375
4
# Credit: http://cs231n.github.io/assignments2018/assignment1/ from typing import Callable import numpy as np def eval_numerical_gradient( f: Callable[[np.ndarray], np.ndarray], x: np.ndarray, verbose: bool = True, h: float = 0.00001, ): """A naive implementation of numerical gradient of f at x ...
2c5e0083bd6574f78f6e00b8848c9b206cb93558
necroant/PY100_Oct2020_Prac
/game/game.py
3,674
3.609375
4
import numpy as np from random import choice N = 3 # field size FIRST_PLAYER = 'x' SECOND_PLAYER = 'o' EMPTY_CELL = '.' INIT_FIELD_SET = { 2: ( '0', '1', '2', '3' ), 3: ( '0', '1', '2', '3', '4', '5', '6', '7', '8' ), 4: ( '0', '1', '2', '3',...
1590ef3670b4fcf98990bec2937d751b2f4e907a
WestonMJones/Coursework
/RPI-CSCI-2300 Introduction to Algorithms/labs/Lab1/lab1 part 2.py
533
3.78125
4
import timeit def fib2(n): if n==0: return 0 elif n==1: return 1 else: nums = [0, 1] for i in range(2,n+1): nums.append(nums[i-2]+nums[i-1]) return nums[n] #Main code if __name__=='__main__': t2 = timeit.Timer("fib2(n)",global...
6d4db69356b5952140860cdddc08e4bf736653e0
royredman4/Chess_Game
/Chess_Movement.py
3,530
3.90625
4
try: # for Python2 from Tkinter import * except ImportError: # for Python3 from tkinter import * from Game_Initialization import Get_Piece from Chess_Pieces import Chess_Piece #x_let = {"A":0, "B":1, "C":2, "D":3, "E":4, "F":5, "G":6, "H":7} #y_let = {"1":0, "2":1, "3":2, "4":3, "5":4, "6":...
652c313b75c35d9dbfac9699a010479b3e060ffe
rushigandhi/CCC-Practice
/2013/Senior/From_1987_to_2013.py
229
3.65625
4
year = int(input()) + 1 while True: yearLine = str(year) yearList = list(yearLine) yearSet = set(yearLine) if len(yearSet) == len(yearLine): print(str(yearLine)) break else: year += 1
385a5314dbcdde5e3a2e0d07c821118c47a144f5
transcendtron/course_python
/code/03/dict.py
1,006
4.03125
4
# 字典 user = { 'name': 'Green', 'age': 12, 'gender': 'male' } # user = {'name': 'Green', 'age': 12, 'gender': 'male'} print(user['name']) # get address = user.get('address') # 返回None,因为没有address这个key name = user.get('name') # 返回Green # 修改 user['address'] = 'china' # 添加一个address键值对 user['age'] = 18 ...
b9eef6a3d922ad449452cc5baa72f5640693b47e
saparia-data/data_structure
/geeksforgeeks/strings/17_minimum_indexed_character.py
1,956
3.875
4
''' Given a string str and another string patt. Find the character in patt that is present at the minimum index in str. If no character of patt is present in str then print 'No character present'. Input: The first line of input contains an integer T denoting the number of test cases. Then the description of T test ca...
e2658197ef78e18692c5ab1febe638b94adfc6b7
Karthik-Sankar/Algorithms
/grading.py
815
3.65625
4
#!/bin/python3 #Difficulty Level - Easy #Quesstion Link - https://www.hackerrank.com/challenges/grading/problem #My Submission Link - https://www.hackerrank.com/challenges/grading/submissions/code/52600497 import sys def solve(grades): res = [] nf = 0 for i in grades: if(i<38): res.appe...
9f91ade333bcd0e4d8cf470c3e078be1c4768e83
thaisNY/GuanabaraPy
/29.py
138
3.53125
4
vel = int(input('Qual a velociade do seu carro?')) if vel > 80 : print('Você vai pagar uma multa de {} reais'.format(((vel - 80)*7)))
13966d924e45e21f69b44bf5059ce6c21837300e
jeremyyew/tech-prep-jeremy.io
/code/techniques/2-two-pointers/M15-three-sum.py
5,336
3.609375
4
import itertools from typing import List # My version of someone else's solution below. For modularity, I abstract the two-sum scan, and pass it an array slice instead of indices. # We simply require the twoSum to return the values that add up to the target (instead of indices), with no duplicates, and it cannot assu...
4b378baddc3e5025daa25d34bbe616f05352f898
sgreene570/conwaylife
/life.py
1,991
4.125
4
#!/usr/bin/python3 # Conways game of life in python # Work in progress for fun # Goal: Make the game of life as pythonic as possible # @author: Stephen Greene import argparse import random import time from copy import copy, deepcopy import os DEAD_CELL = 0 LIVE_CELL = 1 REFRESH_RATE = .2 def main(): parser = ...
183f503beef626d8bd0508d9468b1f376589dde5
JohnByrneJames/SpartaGlobalRepo
/Python-Files/Revision-Files/OOP-FIles/oop_classes.py
2,029
4.53125
5
# Classes # Naming convention for creating a class is to capitalise the first letter # Syntax - class 'class_name' # Everything in a class is an object class PyCalculator: def __init__(self, number1, number2): # Self keyword points to the class itself self.num1 = number1 self.num2 = number2 d...
19335e4a60882e276b44679b043692806aebfd02
StinkyMilo/UnfairHangman
/unfair_hangman.py
3,990
3.8125
4
from random import randint import json # Rules for word formatting (editable in word_formatting.py): Must have vowels (this does exclude some but it feels too unfair otherwise), can't be an acronym, can't have special characters. Taken from https://github.com/dwyl/english-words # Initialize words words = json.loads(ope...
356d23939c29ae5e86a444ce5f13c4e449b6d88d
hnathehe2/ENGR-102
/Lab9/Lab9B_Collect.py
1,244
3.65625
4
# By submitting this assignment, all team members agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Names: Shion Ito # Hanh Nguyen # Anh Hoang # Nicholas Arredondo # Sec...
656fa4cdb773b180b234f45c1a67559f87cb1514
kemaric/Kemari-Projects
/Python/SetIntersection.py2.py
596
3.5
4
"""Sample code to read in test cases:""" import sys def setIntersection(strint): set1, set2 = strint.split(";") set1 = set1.split(",") set2 = set2.split(",") intersect = (set(set1) and set(set2)) - (set(set1)^set(set2)) list(intersect).sort() result = ",".join(intersect) if result == "": ...
25cfdb7e8d8c3eb37cf32fa03d1b32941c97c377
shuvava/python_algorithms
/bst/test_bst_node_query.py
3,838
3.78125
4
#!/usr/bin/env python # encoding: utf-8 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Copyright (c) 2017-2022 Vladimir Shurygin. All rights reserved. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' Test of base_bst module https://docs.python.org...
bda2d75e02c7489ebc59babfb15c6eed62006629
resoliwan/algo
/search_sort/selection_sort.py
491
3.90625
4
def selectionSort1(alist): largestIndex = 0 for passNum in range(len(alist) - 1, 0, -1): for i in range(passNum): # print('passNum: {}, i: {}'.format(passNum, i)) if alist[largestIndex] < alist[i]: largestIndex = i alist[largestIndex], alist[passNum] = al...