blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
ce67aac3ef941b8c78ffe50a2df26bb1bb19569a
PNeekeetah/Leetcode_Problems
/Monotone_Increasing_Digits.py
3,843
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 17 13:16:13 2021 @author: Nikita The whole idea is to : 1. Split number into digits 2. Find the longest monotonically increasing sublist; can coincide with list of digits, in which case return the list of digits instead 3. Find an index in the sublist whe...
d6a5af0ff6cbbc8da67900e3ca24d796a6579116
PNeekeetah/Leetcode_Problems
/Maximum_Depth_of_N-ary_Tree.py
753
3.609375
4
""" Beats 13% in terms of runtime and 0% in terms of memory usage. Took me 5 minutes to come up with this. First submission succesful. """ # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children def bfs_max_level(root: "Node") ...
b8e952e4c1f342830f9e3833f18d2673cca2c1f1
PNeekeetah/Leetcode_Problems
/Valid_Anagram.py
1,599
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 3 18:43:09 2020 @author: Nikita """ class Solution: def __init__(self) -> None: pass def bestSolution(self, s: str, t: str) -> bool: pass def isAnagram(self, s: str, t: str) -> bool: """ Parameters -----...
ec267c61ce1040776fe5ddefa2cd6f17b9449b2a
PNeekeetah/Leetcode_Problems
/Recusion1/Pow_x_n_.py
1,160
3.875
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 6 17:20:13 2021 @author: Nikita """ class Solution: def myPow(self, x: float, n: int) -> float: # This is that problem that was done russian multiplication i.e.: # You multiply the number with itself regardless/ Write n in binary form / if %2 == 1, ...
d4357c2fe4cb35bb1bf0e944e95051116f13e104
Ortega-Neto/TrabalhoImplex
/HillClimbSimulatedAnnealing.py
6,829
3.515625
4
# Alunos: Luiz Carlos Ortega Neto # RGA:2020.1906.011-3 # Curso: Engenharia de Software # Rodolfo Miguel Alves dos Santos # RGA: 2017.1906.118-1 # Curso: Engenharia de Software import math import datetime import random # Realiza a leitura do arquivo input e chama a # função tr...
ffb1b716f5bd61be5449a01fb936aa9e9eb9b18d
ostermuellerj/DIJKSTRA
/pathfinder.py
4,598
3.828125
4
import cv2 import numpy as np import math,random STARTX=20 STARTY=20 ENDX=90 ENDY=70 def blackWhite(img, threshold=128): img[img>threshold]=255 img[img<threshold]=0 return img """ - cost = (dx^2 + dy^2)^.5 + dz^2 distances in px - get terrain and change color of roads you build - pre-game day: calculate cost fro...
144fae23bf32ae69dec1f839eabfe6354be2b958
MayurMah/hackerrank
/larry's_array.py
1,513
3.671875
4
#!/bin/python3 import math import os import random import re import sys # Complete the larrysArray function below. def rotate(a): a_min = min(a) if a_min == a[1]: return [a[1], a[2], a[0]] elif a_min == a[2]: return [a[2], a[0], a[1]] else: return a def larrysArray(A): r...
c8855027c8e282c05395a321e2c09d49a490ca9f
sivacoumar-delage/AZ-203
/Labs/Develop Azure Platform as a Service Compute Solutions/Create Azure App Service Web Apps/4 - Run background tasks with by using WebJobs - Files/HelloWorld.py
190
3.96875
4
#!/usr/bin/env python import datetime now = datetime.datetime.now() print("Hello World from Python ! Today is " + now.strftime("%Y-%m-%d") + " and it's " + now.strftime("%H:%M:%S") + " !")
d67b034f09a95479b2dddfbd22f6a5b76c6b4467
neylsoncrepalde/python_exercises
/PrecoDaPizza/__init__.py
1,211
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 18 21:30:37 2018 __init__ @author: neylson """ from carrinhodecompras import CarrinhoDeCompras from pizza import Pizza # Cria 3 pizzas pizza1 = Pizza() pizza2 = Pizza() pizza3 = Pizza() # Adiciona ingredientes pizza1.adicionaIngrediente("Mussarela...
83a176b611cc1d0d96b9a0ab38bc20d1716166f5
Bulgakoff/Exceptions07
/lesson03_copy/list_in_func.py
962
4.03125
4
numbers = [1, 2, 3, 4] def input_list(numb): numb[1] = 100 return numb result = input_list(numbers) print(result) print(f'изменения в нутри функции без копий {numbers}') # копия a.copy() a = [1, 2, 3, 4, 34] b = a.copy() b[1] = 300 print(f'--> копия a.copy() {a}') # копия срезом: a = [1, 2, 3, 4, 34] b = a[...
d63fa3763e072958671eb1a17592228e869e8ad5
Bulgakoff/Exceptions07
/lesson02_and_or/and_true.py
819
4.0625
4
import math # есть список чисел numbers = [2, 3, 5, 6, 7, 6543, 44, 22] n = [] for number in numbers: if number > 0: sqrt = math.sqrt(number) if sqrt < 2: n.append(number) print(n) numbers = [2, 3, 5, 6, 7, 6543, 44, 22] n = [] for number in numbers: if number: sqrt = math...
5c03408eae6cce6626a9b6173f0cc31997bf44d4
shravanc/data_mining
/project/main.py
8,260
3.671875
4
#1. # ==============Importing Libraries==================== import pandas as pd # ==============Importing Libraries==================== #2. # ===============Load Data ========================== # use dataframe and view head and tail for understanding the data #df = pd.read_csv('mushroom.csv', header=None) df = pd....
bea5e9551d74d0f00cf6c3b14b94c216a0ace8e6
cayybh1314/lect05
/money_challenge_v5.0.py
2,795
3.84375
4
""" 作者:赵钦超 功能:52周存钱挑战 版本: 1.0 日期: 20/04/2019 2.0新增功能: 记录每周的存款数 3.0新增功能:使用循环直接计数 3.0新增功能:使用循环直接计数 4.0增加功能:灵活设置每周的存款数,增加的存款数及存款周数 5.0增加功能:根据用户输入的日期,判断是一年中的第几周,然后输出相应的存款金额 """ import math import datetime #函数外的变量是全局变量, saving = 0 def save_money_in_n_week(money_per_week,increase_money,...
2a05a3331fe672bf748eaacd5f97626262baec76
ljmerza/coursera-machine-learning
/machine-learning/ex1/python/ex1.py
4,314
3.65625
4
#/usr/bin/python3 import numpy as np import matplotlib.pyplot as plt from warmUpExercise import warmUpExercise from computeCost import computeCost from plotData import plotData from gradientDescent import gradientDescent # Machine Learning Online Class - Exercise 1: Linear Regression # Instructions # ------------ ...
e5d918d68c629cf44b8cf97dad3accfb61d37aed
DKuan/Reinforcement_Learning2018
/gridworld/grid_world.py
2,003
3.609375
4
""" This file is wrote for the gridworld env, conclude a main module named Grid_World The class is inherit from the class of Envrionment_Base, and rewrite two methods """ import sys sys.path.append('../') from base.Environment_Base import Environment_Base import numpy as np class Grid_World(Environment_Base): """ R...
c357ea3c5ba4716ebbeac0054911dba12520509f
ShamailMulla/Predicting-Biological-Response
/PredictingBiologicalResponse_Initialisations.py
1,869
3.734375
4
import pandas as pd from numpy import array from sklearn import cross_validation from sklearn.utils import resample #Loading the Biological Responses Dataset into memory def LoadData(): # Load the entire dataset try: print "Loading the datasets..." training_data = pd.read_csv("train.csv") ...
861c582601a30e613d1e427d290d3268129fc304
Mat1005/esercizi
/es26p293.py
1,015
3.953125
4
''' Deriva dalla classe Quadrato una nuova classe Rettangolo aggiungendo un secondo lato per l'altezza e riscrivine i metodi per il calcolo del perimetro e dell'area. ''' class Quadrato: def __init__(self, lato): self.lato = lato def perimetro(self): perimetro = self.lato * 4 prin...
7445cabfb842213fe5d87eb5354721eb466f3293
anuunnikrishnan/Python
/PYTHON 1/pythoncollections/OOPS/class/filter.py
423
3.703125
4
# filter using normal function # list=[1,6,4,2,7,9] # for i in list: # if i%2==0: # print(i) # else: # pass # def isEven(num): # if(num%2==0): # return True # else: # return False # lst=[10,20,21,23,25,28,30] # evelist=list(filter(isEven,lst)) # print(evelist) # filter u...
12e8a7d2b11be67c55c589ed954f75cc510b87ee
anuunnikrishnan/Python
/PYTHON 1/pythoncollections/python collctions/tuple.py
461
4.03125
4
# tuple1=(10,20,30,40,50) # print(tuple1) # tuple1[0]=100 # print(tuple1) # print(tuple1*2) # print(tuple1+tuple2) # print(20 in tuple1) # print(len(tuple1)) # print(max(tuple1)) # print(min(tuple1)) # NESTING LIST AND TUPLE Employees=[(101,"ayush",22,1000),(102,"john",29,2000),(103,"james",45,3000)] # for i in Employ...
b27497a0a7e81e6e94e1d899d81e2a6d5c152c79
anuunnikrishnan/Python
/PYTHON 1/Multithreading/thread class.py
494
4.0625
4
# creating thread using thread class from threading import * # here we use inheritance MyThread class inherits base class Thread class MyThread(Thread): def run(self): for i in range(10): print("Inside Mythread run method") t=MyThread() t.run() # t.start() # start and run are inbuilt methods in ...
881b254a67b28bea23973d47524d545e4aaf7d66
anuunnikrishnan/Python
/PYTHON 1/EXAM/remove duplicates.py
274
3.96875
4
def remove(lst): lst2=[] for i in lst1: if i not in lst2: lst2.append(i) print(lst2) lst1=[] n=int(input("enter the number of elements")) for i in range(0,n+1): el=int(input("enter the no. of elements")) lst1.append(el) remove(lst1)
9e1410360375b272ba579033a7ec38f64f7d19d2
anuunnikrishnan/Python
/PYTHON 1/pythoncollections/OOPS/inheritance/inheritance example.py
516
3.921875
4
# class One: # def m1(self): # print("am inside parent m1 method") # class Two(One): # pass # # obj=Two() # obj.m1() class One: def m1(self): print("am inside parent m1 method") class Two(one): def m2(self): print("hello") obj=Two() obj.m1() # simple inheritance # class Pare...
d96da5e1702646e15715c7fa1867d3557f44e259
anuunnikrishnan/Python
/PYTHON 1/Data Structure/Stack.py
904
4.09375
4
stack=[] top=-1 def push(element): global top if((top+1)>=size): print("Stack is full") else: top+=1 stack.insert(top,element) print("Element Inserted") def pop(element): global top if(top<0): print("stack is empty") else: print("deleted element",s...
b62d20e845d5fd6267d8f034e8b89c536b8acd47
anuunnikrishnan/Python
/PYTHON 1/pythoncollections/python collctions/dictionary file read.py
286
3.671875
4
dict={} for x in f: lst=x.split(",") if lst[0] not in dict: dict.update({lst[0]:int(lst[1])} else: temp=dict[lst[0]] if(int(lst[1]>temp)): temp=lst[1] dict.update({lst[0]:int(lst[1])}) for i in dict: print(i,":",dict[i]))
afe3770867137b1e3ecc421c091ad4f86f09c124
anuunnikrishnan/Python
/PYTHON 1/EXAM/calculator.py
763
3.953125
4
class Calculator: def __init__(self,num1,num2): self.num1=num1 self.num2=num2 def add(self): return(self.num1+self.num2) def sub(self): return(self.num1-self.num2) def mul(self): return(self.num1*self.num2) def div(self): if(self.num2==0): ...
fc1fb59854e652c33c31e680bc554010c7da4bbd
anuunnikrishnan/Python
/PYTHON 1/EXAM/lcm.py
227
4.09375
4
def lcm(a,b): for i in range(1,a*b,1): if i%a==0 and i%b==0: print("LCM of given numbers is :",i) break a=int(input("enter the first number")) b=int(input("enter the second number")) lcm(a,b)
1b0cbd82cd2edd6ec4b0c115bf4cb0f5bfdf3722
anuunnikrishnan/Python
/PYTHON 1/pythoncollections/python collctions/linearsearch.py
464
3.90625
4
def linearsearch(lst,element): flg=0 for i in lst: if(i==element): flg+=1 break else: flg=0 if(flg==0): return False else: return True lst=[] lim=int(input("enter how many elements u want to add")) for i in range(0,lim): val=int(in...
e36b94294778a0ab52065a8e39b377ac7c72b2e7
Deddryk/projecteuler
/solutions/problem42/solve.py
819
3.625
4
# Author: Deddryk """ Solution to problem 42. Since the longest word in words.txt is only 14 characters, this is easily solved by generating all triangle numbers less than 26*14, then checking for each word value in that set. """ def word_value(word): value = 0 for character in word: value += ord(ch...
3cac60c5737d9e23712629fc6e70bc6dc870eb6f
sharinrajappa99/artistic_sharin
/addition.py
135
4.03125
4
# reading values from keyboard and perform addition a = int(input("enter a value")) b =int(input("enter b value")) sum = a+b print(sum)
5bd3dc79a4a166677414e10fde1e9addbec32abd
BOTSlab/Fermat-Spirals
/fermat_spiral.py
13,337
4.15625
4
''' Methods for generating fermat spirals from input spirals @author ejbosia ''' import spiral as S from spiral import calculate_point, calculate_point_contour from shapely.geometry import Point, LineString from shapely_utilities import cut, distance_transform_diff ''' Find the next endpoint in the path - this i...
8661d933bf731b111cda9345752a0307ff4adca8
rodrigomanhaes/model_mommy
/model_mommy/generators.py
1,794
4.34375
4
# -*- coding:utf-8 -*- __doc__ = """ Generators are callables that return a value used to populate a field. If this callable has a `required` attribute (a list, mostly), for each item in the list, if the item is a string, the field attribute with the same name will be fetched from the field and used as argument fo...
6c036ab3ae9e679019d589fbd8de8be45486773f
gbrough/python-projects
/palindrome-checker.py
562
4.375
4
# Ask user for input string # Reverse the string # compare if string is equal # challenge - use functions word = None def wordInput(): word = input("Please type a word you would like to see if it's a palindrome\n").lower() return word def reverseWord(): reversedWord = word[::-1] return reversedWord def palin...
0405cb4e5f22e2b1f3492b88bec17179418d424a
yeegahng/python_playground
/baseball.py
8,976
3.6875
4
import random import os from datetime import datetime def input_number_count(): while True: numCount = input("게임 숫자 길이를 결정하세요: ") if numCount.isdigit() and len(numCount) >= 1: return numCount else: print(numCount, "는 유효한 값이 아닙니다. 재시도 하세요.") def get_target_numbers(...
cfa0ce43e6a8a1a0f3ec4b93ca625e6564bcb5a9
skyu0221/Kattis-UVa
/UVa/uva_10136.py
3,155
3.90625
4
''' * UVa problem: 10136 * * Topic: Geometry * * Level: 2 points * * Brief problem description: * * Given some point find the circle that contains the most points. * * Solution Summary: * * If only one point, result is one. Otherwise set two points on the * circle and find how many p...
8b487bbcd2e8f7d0c69cf34e2374d4dfb686c9e0
marcelinoandre/python-logica-para-data-science
/02-declaracao-de-variaveis/2.10.Atividades3.py
267
3.625
4
#Professor Fernando Amaral #3 Reajuste salario = float(input("Informe o salário: ")) reajuste = float(input("Informe o percentual de reajuste (%): ")) novosalario = salario + salario * (reajuste / 100) print("O salário reajustado é igual a ", novosalario)
3f3d61e245217a56a7fe6117fb3aeac3212c40d3
marcelinoandre/python-logica-para-data-science
/03-estrutura-de-decisao/3.4.Problemas3.py
523
3.9375
4
#Professor Fernando Amaral #3 Habilitação para vaga idade = int(input("Informe a Idade: ")) atividade = float(input("Informe o tempo de atividade profissional: ")) if (idade < 70) or (atividade>=25) or (idade >= 70 and atividade>=30): print("Habilitado!") else: print("Não Habilitado") #Testes #70 de ...
cbfd392f079fba16fb29a7487a8b9d0a1ddc5d80
marcelinoandre/python-logica-para-data-science
/07-listas-pacotes-funcoesexternas/7.9.Atividade2.py
577
4.03125
4
#Professor Fernando Amaral quantidade = int( input("Informe a quantidade de números: ")) while quantidade <2: print("Quantidade inválida, tente novamente") quantidade= int(input()) lista = list(range(0,quantidade)) for n in range(0, quantidade): print("Informe o número da posição ",...
5f09cde9a637518bee1de2b8156877f34c23bf4b
marcelinoandre/python-logica-para-data-science
/04-estrutura-de-repeticao/5tabuada-de-10-10.py
204
3.765625
4
#Impressão de tabuadas de 1 ao 10 for tab in range(1, 11): print(f'Tabuada do {tab}') for n in range(0, 11): print(f'{tab} X {n} = {tab * n}') print('\n##################################33')
1c1ba2ac5ac23f5c083e9a035fb779f7842eef9e
marcelinoandre/python-logica-para-data-science
/02-declaracao-de-variaveis/2.8.Atividades1.py
241
3.828125
4
#Professor Fernando Amaral #1 Área retângulo largura = float(input("Informe a largura do retângulo: ")) altura = float(input("Informe a altura do retângulo: ")) area = largura * altura print("A área do retângulo é de : ",area)
b5d6e1d712d736e14224c92782066f5bfd8ea338
marcelinoandre/python-logica-para-data-science
/04-estrutura-de-repeticao/4.9.Atividade2.py
217
3.59375
4
#Professor Fernando Amaral #2 Soma soma = 0 for tab in range(0, 5): texto = "Informe o " + str(tab+1) + "º número: " soma = soma + int(input(texto)) print("A soma é igual a : ", soma )
881d9ba1f1dea7860a6fd2f30f62ed0f8246bea3
marcelinoandre/python-logica-para-data-science
/07-listas-pacotes-funcoesexternas/7.10.Atividade3.py
407
4.125
4
from math import sqrt lista = list(range(0,5)) for n in range(0, 5): print("Informe o número da posição ", n+1, " da primeira lista") lista[n] = float(input()) for n in range(0, 5): print("Raiz quadrada: "sqrt(lista[n])) if sqrt(lista[n]) % 1 == 0 : print("Raiz quadrada é um valo...
b1d4cc85fcdb5f252e559865733eaaa37d484353
IrisStream/Graph_Search
/search_algorithm.py
7,721
4.03125
4
import pygame import math import graphUI import queue from node_color import white, yellow, black, red, blue, purple, orange, green """ Feel free print graph, edges to console to get more understand input. Do not change input parameters Create new function/file if necessary """ def changeColor(graph, node, color): ...
bd547e776452dda0b6167ab895d6a913744926b5
Shreets/Python-basics-III
/search&sort/quick_sort.py
672
3.765625
4
array = [7, 2, 1, 6, 8, 5, 3, 4] arr_length = len(array) start = 0 def partition(array, start, end): pivot = array[end] for i in range(start, end): if array[i] <= pivot: temp = array[i] array[i] = array[start] array[start] = temp start = start+1 tem...
d3f1def9a4e865af55034473a96f94d60b2b68cd
chenmeister22/CAIS
/ITP 115 Final Project/ Diner.py
2,085
3.96875
4
from MenuItem import MenuItem #This class represents the Diner object. class Diner(object): STATUSES = ["Seated","Ordering","Eating","Paying","Leaving"] def __init__(self,name): self.name = name self.order = [] self.status = 0 #fn getName #input: none #return: nam...
b9de4baf7dc9b4553fb0182bf98ffcb5f32fd045
risooonho/programming-fundamentals
/assign4/tryme3.txt
627
3.734375
4
# function new_line: prints a new line def new_line(): print() # function three_lines: prints 3 new lines def three_lines(): new_line() new_line() new_line() # function nine_lines: prints 9 new lines def nine_lines(): three_lines() three_lines() three_lines() # function clear_screen: clears s...
203ed7d0a573c6a397ed113a6865823cf190155a
pupil96/pupil96doPython100homework
/doPython100_1.py
342
3.671875
4
# 有1,2,3,4,四个数字,能组成多少个位数互不相同的,且不重复的三位数。 # 它们都是多少 count = 0 for i in range(1, 5): for j in range(1, 5): for k in range(1, 5): if i != j and j != k and k != j: print(i, j, k) count += 1 print("total:", count)
4ea5ef75cfa3f221b0ffcc7566498c006154c905
pupil96/pupil96doPython100homework
/doPython100_8_2.py
2,291
3.671875
4
# 9*9 # 9+9 # 22*22 # 32*32 # 9+9+9 # 9*9*9 # 19*19 def my_9x9table(): print("==============9x9===============") for row in range(1, 10): for column in range(1, row+1): print("%s*%s=%s\t" % (row, column, row * column), end="") print("") print("--------------------------------") def my_9p...
2e2a478d79e961c62ea484d14b8d84d1d1abd426
bluepostit/di-python-2018
/week1/day1/day1-exercise3.py
953
4.09375
4
# Bar calculator customer_name = input("What is the customer's name? ") waiter_name = input("What is the waiter's name? ") item_name = input("What is the name of the item ordered? ") price = input("What is the price of 1 " + item_name + "? ") amount_of_items = input("How many " + item_name + "s were ordered? ") discoun...
854d6b5e0fbb456edf0320cdebda7821a62e0575
bluepostit/di-python-2018
/week2/day4/exercise1/farm.py
585
3.703125
4
class Farm: def __init__(self, name): self.name = name self.animals = {} def add_animal(self, animal, count=1): if animal in self.animals: self.animals[animal] = self.animals[animal] + count else: self.animals[animal] = count def get_info(self): ...
383821b7169cbec93c79eb70ceefab9c35859652
btwooton/RosalindProblemSolutions
/consensus.py
3,420
3.734375
4
def read_fasta(in_file): """ (text_file) -> dict{str: str} Reads in a file containing at most 10 DNA strings of equal length in FASTA format and returns a dictionary where the key is the FASTA label and the value is the corresponding DNA string """ result = {} strings = [] i = 0 ...
f923ed96a0797a0af291a871c14806c2dd7ec434
patrickhahn497/CryptographyHandler
/CryptoHandler.py
2,029
3.90625
4
#ord(char) turns from char to ascii #chr(int) turns from ascii to char alphanum = {} numalpha = {} for count in range(0, 26): alphanum[chr(97+count)] = count numalpha[count] = chr(97+count) class shift_cipher: message = "" key = 0 cipher = "" def encrypt(self): """Starts encryption p...
5ebe1f88e466c99ba52f3dd43a17e692b30c96b2
chena/aoc-2017
/day12.py
2,625
4.21875
4
""" part 1: Each program has one or more programs with which it can communicate, and they are bidirectional; if 8 says it can communicate with 11, then 11 will say it can communicate with 8. You need to figure out how many programs are in the group that contains program ID 0. For example, suppose you go door-to-door...
a660963bfa3a66a3f569bc21159165f337dfd7af
chena/aoc-2017
/day07.py
5,549
3.765625
4
""" part 1: One program at the bottom supports the entire tower. It's holding a large disc, and on the disc are balanced several more sub-towers. At the bottom of these sub-towers, standing on the bottom disc, are other programs, each holding their own disc, and so on. At the very tops of these sub-sub-sub-...-tower...
6e33fd4e81dcfdce22916bd20d4230e472490dae
chena/aoc-2017
/day05.py
1,882
4.53125
5
""" part 1: The message includes a list of the offsets for each jump. Jumps are relative: -1 moves to the previous instruction, and 2 skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads outside the list. In addition, these instructions are a little strange;...
89eb9fcbc126bcf690502e708354b616070d6320
shy2913/python-tutorial-2
/pw.py
190
3.78125
4
a = {1: '파랑구름', 2: '이현준', 3: '민현준'} # print(a.keys()) # print(a.values()) # print(a.items()) for k, v in a.items(): print("키는"+str(k)) print("벨류는"+v)
fd9b4f2254756449af5753826032fc9c8aad3739
Sahilsingh0808/Project-CUOG
/script.py
5,569
3.546875
4
import pandas as pd import re def removeSpaces(str): return str.strip() def StringManipulate(str,master,check): # print(str) if(check==0): #string starts with number c1=master[0:2] c2=master[3:6] c3=str[0:2] c4=str[3:6] c5 = "N/A" c5No=-1...
61d76b391477a15b3ebf73b0824a3b8790e6b122
cadgo/python
/tkinter/freedraw.py
537
3.671875
4
from Tkinter import * canvas_with= 500 canvas_height=150 def paint(event): python_green= "#476042" x1, y1 = ( event.x - 1 ), ( event.y - 1) x2, y2 = ( event.x + 1 ), ( event.y + 1) w.create_oval( x1, y1, x2, y2, fill=python_green) master = Tk() master.title("painting using ovals") w ...
3759b0e3f59ca41e1cd8a970b322c222a6f5dfc4
codingant007/deep-musings
/catsVsdogs/mlp.py
2,186
3.984375
4
""" This tutorial introduces the multilayer perceptron using Theano. A multilayer perceptron is a logistic regressor where instead of feeding the input to the logistic regression you insert a intermediate layer, called the hidden layer, that has a nonlinear activation function (usually tanh or sigmoid) . One can use ...
9aa62f6d1b2da6472076c7c15708bf76de5e0071
hanifadzkiya/Kuri
/ciphertext.py
1,003
3.859375
4
def getPoint(char): # Determine if char is UpperCase or LowerCase # Return 65 if UpperCase and 97 if LowerCase if(ord(char) < 97): return 65 else: return 97 def caesar_cipher(text,key): result = "" #Encrypt Process for idx in range(len(text)): point = getPoint(text[idx]) if(text[idx] == " "): result...
3697205195e253939bba281e9c1d992ac89fd836
parva-jain/Codeforces-Contests
/Educational Codeforces Round 100/Python Solutions/D_Pairs.py
825
3.5625
4
def binarySearch(A,B,n): low,high = 0,n while(low < high): mid = low + (high-low+1)//2 flag = 1 for index in range(mid): if(A[index] > B[n+index-mid]): flag = 0 if(flag == 0): high = mid - 1 else: low = mid return ...
b976daff9f36cd3eaf7bcace9d1b84ada3c0ae8f
Michaeljgaunt/Perceptron
/src/Perceptron.py
9,400
3.546875
4
#The Perceptron.py file contains the main function of the perceptron. import argparse import sys import time import Process if __name__ == "__main__": #Saving the start time to time how long the perceptron takes. start_time = time.time() #Parsing the command line arguments. parser = argparse.Arg...
d42ecceedf925c992c64ad311cbf801eb3757f84
yasukoe/study_python
/comprehension.py
253
4.375
4
# comprehension 内包表記 # print([i for i in range(10)]) # print([i*3 for i in range(10)]) # print([i*3 for i in range(10) if i % 2 ==0]) print(i*3 for i in range(10) if i % 2 ==0) #Generator print({i*3 for i in range(10) if i % 2 ==0}) #set type
8e5f1f84977602fa414e773c9dc53923567c6ac1
p10rahulm/python-boilerplate
/singlylinkedlist.py
1,442
4.09375
4
class Node(object): def __init__(self, data, next): self.data = data self.next = next class SingleList(object): head = None tail = None def show(self): print("Showing list data:") current_node = self.head while current_node is not None: print("dat...
c23d52707ba2c1e8c0997245cf6b587811ae5100
p10rahulm/python-boilerplate
/2ndhighestinarray.py
419
3.796875
4
def secondhighest(listA): best = listA[1] secbest = listA[1] for i in range(len(listA)): if listA[i]>secbest: if listA[i] > best: secbest = best best = listA[i] else: secbest = listA[i] return secbest if __name__ == "__main...
5cc4a0dd0c2e0acc5c45777b3abc0f7accfd4f60
p10rahulm/python-boilerplate
/PriorityQueue.py
4,659
4.09375
4
# See http://en.wikipedia.org/wiki/Priority_queue # You should choose binary or fibonacci heap, based on how you plan to use it: # # O(log(N)) insertion time and O(1) findMin+deleteMin time - bin search heap, or # O(1) insertion time and O(log(N)) findMin+deleteMin time # In the latter case, you can choose to implement...
73230b77bf283158295a833244a3343b44d9bbdc
weeklyvillain/TDDA69
/labb1/excercises.py
7,516
4.09375
4
def sum(term, lower, successor, upper): if lower > upper: return 0 else: return term(lower) + \ sum(term, successor(lower), successor, upper) print(sum(lambda n: n, 1, lambda n: n+1, 10)) # 1.1 a) def sum_iter(term, lower, successor, upper): def iter(lower, result): ...
164dda3ecb9d27c153dbc9d143ba05437c47f656
luisprooc/data-structures-python
/src/bst.py
1,878
4.1875
4
from binary_tree import Node class BST(object): def __init__(self, root): self.root = Node(root) def insert(self, new_val): current = self.root while current: if new_val >= current.value: if not current.right: current.right = Node(new_...
db24f2fe60a0f54e6e9a7ade8bc3f894748b9d57
andreodendaal/coursera_algo_toolkit
/week6_dynamic_programming2/1_maximum_amount_of_gold/scratch.py
377
3.71875
4
# 5 7 12 18 = 19 from itertools import combinations def find_sum_in_list(numbers, target): results = [] for x in range(len(numbers)): results.extend( [ combo for combo in combinations(numbers, x) if sum(combo) <= target ] ) print(results) if __name_...
4a5bb679a7fe9362ba4c4af787b4779880f7dc89
andreodendaal/coursera_algo_toolkit
/week3_greedy_algorithms/4_collecting_signatures/covering_segments2.py
2,624
3.6875
4
# Uses python3 import sys from collections import namedtuple import operator Segment = namedtuple('Segment', 'start end') def optimal_points(segments): points = [] common_points = [] #write your code here segments.sort(key=operator.itemgetter(0)) intersected = set() for s in segments: ...
4c457cfafbaf04446c0a88770758c83c0afb0183
andreodendaal/coursera_algo_toolkit
/week3_greedy_algorithms/4_collecting_signatures/covering_segments.py
2,260
3.734375
4
# Uses python3 import sys from collections import namedtuple import operator Segment = namedtuple('Segment', 'start end') def optimal_points(segments): points = [] common_points = [] #write your code here segments.sort(key=operator.itemgetter(0)) max_common = 0 last_segment = [0, 0] fo...
507d6fd793dcd4f4b98c09445412db9e14ebc422
andreodendaal/coursera_algo_toolkit
/week5_dynamic_programming1/3_edit_distance/edit_distance2.py
936
3.890625
4
# Uses python3 # not working def edit_distance(side, top): #write your code here if len(side) > len(top): top, side = side, top previous_row = list(range(len(top) + 1)) for i_side, c_side in enumerate(side): this_row = [i_side + 1] for i_top, c_top in enumerate(top): ...
e9e3e13b70cce187278c1f2daa598227c7fdd8ff
andreodendaal/coursera_algo_toolkit
/week3_greedy_algorithms/6_maximum_salary/largest_number5.py
653
3.890625
4
#Uses python3 import sys from collections import deque def largest_number(a): #write your code here maxlen = len(max(a)) for x in orderedDigits: res += x return res if __name__ == '__main__': input = sys.stdin.read() data = input.split() a = data[1:] print(largest_numbe...
ebd9ebdc183f2715043a9e8c129fe09879bbd211
pedrolarben/ADLStream
/ADLStream/data/stream/file_stream.py
2,399
4
4
from abc import ABC, abstractmethod from ADLStream.data.stream import BaseStream class FileStream(BaseStream, ABC): """Abstract File Stream. This class implements the logic to read lines from a file. Every class inheriting `FileStream` must have the properties below and implement `decode` function w...
f6809bee04d36711a76ddfc90c373829b1e38c6e
pedrolarben/ADLStream
/ADLStream/data/preprocessing/min_max_scaler.py
2,501
3.59375
4
"""Implements a min max scaler""" from ADLStream.data.preprocessing import BasePreprocessor class MinMaxScaler(BasePreprocessor): """Transform features by scaling each feature between zero and one. This estimator scales and translates each feature (column) individually such that it is in the the range (0...
14bbc49fbdf92652b863b7c63c73ebdeeb2109ca
KangSuzy/algorithms
/baekjoon/2558.py
438
3.625
4
""" A+B - 2 성공 시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율 1 초 128 MB 28030 20373 18793 75.693% 문제 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A, 둘째 줄에 B가 주어진다. (0 < A, B < 10) 출력 첫째 줄에 A+B를 출력한다. 예제 입력 1 1 2 예제 출력 1 3 """ a = int(input()) b = int(input()) print(a+b)
94601175635333ee151609b9e84fb9e74e287902
KangSuzy/algorithms
/books/e02-1-findmin.py
305
3.53125
4
# 최솟값 구하기 # 입력: 숫자 n 개가 들어있는 리스트 # 출력: 숫자 n개 중 최솟값 def find_min(a): n = len(a) min_n = a[0] for i in range(1, n): if min_n > a[i]: min_n = a[i] return min_n a = [17, 92, 18, 33, 58, 7, 33, 42] print(find_min(a))
757cfb65fc22c1f8f9326a25018defb7aafbad56
2FLing/CSCI-26
/codewar/camel_case.py
531
4.25
4
# Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case). # Examples # to_camel_case("the-stealth-warrior") # r...
2c530ea2273c32b38ad6c265793265faf2b332f5
grypyAndy/AndelaCohort
/binary Search tests/binarySearch.py
1,805
4.09375
4
class BinarySearch(list): count = 0 array = [] limits = 0 length = 0 def __init__(self,a,b): '''the constructor definition section that shows the slicing of arrays into values with specified consecutive value difference. Initialises length to the length of the array. ''' s...
90af91648991cf8e3eb1773f1acc098f3c80453c
florianboergel/cs181-s16
/homework4/problem3.py
4,667
3.5
4
# CS 181, Spring 2016 # Homework 4: Clustering # Name: # Email: import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.image as mpimg from sklearn.cluster import KMeans as BaseKMeans # only for comparison class KMeans(BaseKMeans): # K is the K in KMeans # useKMeansPP is a boolean...
5a5581ad8604d9d61d579ab1661be5c7d70cdcb6
rodrigocamarena/Homeworks
/sess3&4ex4.py
2,915
4.5
4
print("Welcome to the universal pocket calculator.") print("1. Type <+> if you want to compute a sum." "\n2. Type <-> if you want to compute a rest." "\n3. Type <*> if you want to compute a multiplication." "\n4. Type </> if you want to compute a division." "\n5. Type <quit> if you want to exit....
47d28df344ae5c3f56a26af641ea59eacbe6fded
ConnectWithNoor/Python-Projects
/1. Pong Arcade Game.py
5,227
3.96875
4
# Implementation of classic arcade game Pong # Noor Muhammad # Run this code in http://codeskulptor.org for better performance using google chrome or firefox brower # Date : 9th August, 2018 import simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIG...
7536d2a8c16cc9bda41d4a4d3894c0a8a0911446
artemis-beta/phys-units
/phys_units/examples/example_2.py
1,160
4.34375
4
############################################################################## ## Playing with Measurements ## ## ## ## In this example the various included units are explored in a fun and ## ## ...
83d3fea7b5b0c365fef336765d25e35eed0c2a23
cd205/Intelligent-Produce-Picker
/randomSnippets.py
234
4.09375
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 8 08:35:57 2019 @author: DoddC """ a=[[1,2,3],[4,5,6]] print(list(zip(*a))) A = [['a', 'b'], ['c'], ['d', 'e', 'f']] B = [inner for outer in A for inner in outer] print(B)
bab0963953161775f45624b4dec5a7e939ba768c
smith-erik/project-euler
/1-10/p4.py
617
3.765625
4
#!/usr/bin/python3 def main(): basenum_length, largest = 3, 0 maxnum = 10 ** basenum_length - 1 x, y = 0, 0 for a in range(maxnum, 1, -1): for b in range(a, 1, -1): if isPalindrome(a * b) and a * b > largest: largest = a * b x, y = a, b print("%d ...
ee6ccbdfe3820dc078599b69d44a926b7e5582c5
smith-erik/project-euler
/1-10/p3.py
1,261
3.671875
4
#!/usr/bin/python3 from math import floor, sqrt, ceil def slow(n0): maxprime = ceil(sqrt(n0)) print("Ceil of square root of 600851475143 is %d." % maxprime) for i in range(maxprime - 1, 1, -1): if n0 % i == 0 and isPrimeSlow(i): print(str(i)) return print("Reached end o...
3c419f360e36ed45af7d7935aa2f824bb2dc472a
Cleancode404/ABSP
/Chapter8/input_validation.py
317
4.1875
4
import pyinputplus as pyip while True: print("Enter your age:") age = input() try: age = int(age) except: print("Please use numeric digits.") continue if age < 0: print("Please enter a positive number.") continue break print('Your age is', age)
535abf66682849ae67da351273ce93c149266666
LarryStanley/mathCampClass
/onlyEdgeTriangelDemo.py
155
3.78125
4
while True: n = int(input("> ")) for i in range(n): print( " "*(n-i) , "/" , " "*(i*2) , "\\" , sep="") print( “-“ * (2*n+1+1) )
709fd3983a724b5ffc96259db8b23a70aecce1a7
LarryStanley/mathCampClass
/gradeDemo.py
369
3.828125
4
while True: n= int(input("> ")) if n>100 or n<0: print("揉揉眼睛再打好嗎??") elif n>89: print("你有卷哥的潛力") elif n>69: print("學分穩穩拿穩穩過") elif n>60: print("精準的操控") elif n==60: print("老師看來人不錯歐!!") else: print("sorry啦~明年加油")
f7495c6acbdb108c47b4f65b34be9ed3d9464389
DanielAlfonso17/CNYT-2019-2
/Laboratorio 2/Laboratorio2.py
5,653
3.859375
4
import math import unittest """ Funciones Requeridas """ def sumaImaginarios(c1,c2): c3 = [0,0] c3[0] = c1[0] + c2[0] c3[1] = c1[1] + c2[1] return (round(c3[0],2),round(c3[1],2)) def productoImaginarios(c1,c2): c3 = [0,0,0,0] res = [0,0] m = 0 for j in c1: fo...
bf005c98b3c7beabc0e2000cfd0cfd404010a9a9
AlexRoosWork/PythonScripts
/delete_txts.py
767
4.15625
4
#!/usr/bin/env python3 # given a directory, go through it and its nested dirs to delete all .txt files import os def main(): print(f"Delete all text files in the given directory\n") path = input("Input the basedir:\n") to_be_deleted = [] for dirpath, dirnames, filenames in os.walk(path): for...
d1d9e251365161bf6d2843e2a3cf3fef7539e6f9
k2seok/test
/test.py
1,143
3.625
4
def solution(s): answer = 1 for _length in range(2, len(s) + 1): for _idxS in range(0, len(s) - 1): if(_idxS + _length > len(s)): #print("idx overflow") break; _nowLen = (int)(_length / 2); left = s[_idxS:_idxS + _nowLen]; ...
4bbc2922211dcb479a3ad5b78a82d523f3fb026f
lgozar/OOP
/temp_main.py
2,921
3.96875
4
from board import Board #import the board class from time import sleep from lcd_class import LCD #import the LCD class from buzzer_class import Buzzer #import the Buzzer class from temp_class import Temperature #import the temperature class from button_class import Button #import the button class from rgb_class import...
077b6324530663d194051c400796558c37ef95c3
thereal-quangd0/learning-python-the-hard-way
/ex03-colonel-sanders-and-his-damn-chicken-nonsense.py
1,338
3.796875
4
print "Counting hella chickens" print "Hens =>", 25 + 30 / 6 print "Rosters =>", 100 - 25 * 3 % 4 print "Counting their eggs" print "Total eggs = >", 3 + 2 + 1 - 5 + 4 % 2 - 1 /4 + 6 # End of this chicken nonsense.. print "Is it true tht 3 + 2 < 5 - 7? Results on the following line:" print 3 + 2 < 5 - 7 print "Wh...
3b61ef043f3f4203de6988d7bb80b3a541be9d01
hernandeznii/DiceChart
/DiceChart.py
4,411
3.8125
4
''' Created on January 28, 2020 Created a method that provides probabilities for rolling sums on a set of dice. @author: Nelson H ''' from random import randint import itertools import string class Dice: def __init__(self, number_of_sides): self.number_of_sides = number_of_sides self.sides_list ...
8ae3f309e572b41a3ff5205692f0ae4c90f11962
Trenchevski/internship
/python/ex6.py
867
4.21875
4
# Defining x with string value x = "There are %d types of people." % 10 # Binary variable gets string value with same name binary = "binary" # Putting string value to "don't" do_not = "don't" # Defining value of y variable using formatters y = "Those who know %s and those who %s." % (binary, do_not) # Printing value of...
9f028756114c0717b242d6fbd9ed05a3f1346744
blxsheep/DataStructure_KMITL
/firstgreater.py
471
3.703125
4
arr1, arr2 = input('Enter Input : ').split('/') arr1 = list(map(int,arr1.split())) arr2 = list(map(int,arr2.split())) arr1.sort() idx=0 for i in range(len(arr2)): #print('Target is {0}'.format(arr2[i])) b =False while(arr1[idx] <= arr2[i]): if(idx>=len(arr1)-1): print('No F...
885838faeb529fb55b40ee7f4405c45e891d836a
blxsheep/DataStructure_KMITL
/lab4.1.py
929
3.90625
4
class Queue : item = [] def __innit__(self): self.item = [] def isEmpty(self): return self.item== [] def push(self,ob): self.item.append(ob) def popfront(self): k = self.item[0] del self.item[0] return k def peek(self): return ...
d3a3b0f530c6e02e273b7a7af53bf5236b761e52
dracorlll/projectEuler
/problem15.py
225
3.609375
4
# Engin Yüksel # 30.01.2021 00:34 # https://projecteuler.net/problem=15 def factorial(n): fact = 1 for i in range(1, n + 1): fact = fact * i return fact print(factorial(40) / (factorial(20) * factorial(20)))
e6cd6f9707418a3fb1b2e34adcdbeea14306f28e
dracorlll/projectEuler
/problem27.py
642
3.53125
4
# Engin Yüksel # 4.02.2021 06:33 # https://projecteuler.net/problem=27 def isPrime(num): prime = False for i in range(2, num): if num % i == 0: prime = False break prime = True if num == 2: prime = True return prime product, maximum = 0, 0 for i in ran...
86a93c1238bcea7c98cd8af258213c33f004fe1b
djorll/ProjectEuler
/projecteuler17 Number letter counts.py
2,157
3.953125
4
# If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 # letters used in total. # # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? # # NOTE: Do not count spaces or hyphens. For example, 3...