blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
82c32d9a23545e03f84220f84f442b4fdd167110
yennanliu/CS_basics
/leetcode_python/String/reverse-words-in-a-string.py
1,802
3.921875
4
""" 151. Reverse Words in a String Medium Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Return a string of the words in reverse order concatenated by a single space. Note that s may contain l...
4dac5b3abcd6ad05d713f0a88ff043d48cbece50
yennanliu/CS_basics
/leetcode_python/Stack/car-fleet.py
4,164
4.1875
4
""" 853. Car Fleet Medium There are n cars going to the same destination along a one-lane road. The destination is target miles away. You are given two integer array position and speed, both of length n, where position[i] is the position of the ith car and speed[i] is the speed of the ith car (in miles per hour). ...
0b287229e013794f1906dfcfcf293642d45ae7ca
yennanliu/CS_basics
/leetcode_python/Breadth-First-Search/surrounded-regions.py
16,205
3.5625
4
""" 130. Surrounded Regions Medium Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. Example 1: Input: board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"]...
bfb97ddd95c553087ba647664e39f27e7a8cea94
yennanliu/CS_basics
/leetcode_python/Binary_Search_Tree/sum-of-root-to-leaf-binary-numbers.py
7,060
3.859375
4
""" 1022. Sum of Root To Leaf Binary Numbers Easy You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which ...
3aa8e261ece68f27870d908117e1b5f2dda4f26c
yennanliu/CS_basics
/leetcode_python/Array/beautiful-array.py
1,099
3.6875
4
# V0 # V1 # https://blog.csdn.net/fuxuemingzhu/article/details/83539773 class Solution(object): def beautifulArray(self, N): """ :type N: int :rtype: List[int] """ res = [1] while len(res) < N: res = [2 * i - 1 for i in res] + [2 * i for i in res] ...
5e7fd2fb0b178bf5138256719d59b350904b4795
yennanliu/CS_basics
/leetcode_python/Tree/binary-tree-maximum-path-sum.py
5,915
3.9375
4
""" 124. Binary Tree Maximum Path Sum Hard A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. The path sum of a path is the sum of...
5438eb169a4fb26d9d6796fd1f834de15cdbaac9
yennanliu/CS_basics
/leetcode_python/Binary_Search_Tree/delete-node-in-a-bst.py
9,623
3.84375
4
""" 450. Delete Node in a BST Medium Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion can be divided into two stages: Search for a node to remove. If the node is found, delete the node...
13df11e3559714314dfdda2e6f8e66c44317c2b0
yennanliu/CS_basics
/leetcode_python/Depth-First-Search/path-sum.py
4,253
3.9375
4
""" 112. Path Sum Easy Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. A leaf is a node with no children. Example 1: Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum =...
e21178720f6c4a17fd9efa5a90062082a6c94655
Guimez/SecsConverter
/SecondsConverter.py
1,067
4.46875
4
print() print("===============================================================================") print("This program converts a value in seconds to days, hours, minutes and seconds.") print("===============================================================================") print() Input = int(input("Please, enter a val...
d7e740b5f7aa6cc4cb3ed8cc01419935c88721aa
HichamDz38/python-code-challenges
/Simulate_Dice.py
2,441
3.828125
4
""" this script is for solving the chalenge: Simulate dice from: Python Code Challenges link: https://www.linkedin.com/learning/python-code-challenges """ import random import timeit # this module to compare between the solutions from collections import Counter from random import ra...
249640877d5808193ec3a9446872a56d09392603
gh4683/PythonWorkshop
/Ifelse.py
475
3.890625
4
user_text = int(input('Please enter a number:')) if user_text <50: print('Number too small') elif user_text <100: print('Number in range') else: print('Number too big') #expressions #first letter capital in python a = False b = True if(a and b): print('hi') if(a or b): print(...
27bedbd78e2870e19985fc7cc3f47035531644cf
digression99/python_study1
/function_global.py
771
3.71875
4
x = 50 def global_change(): global x print('x is', x) x = 2 print('changed x : ', x) global_change() print('done') def say(message, times = 1): print(message * times) say('hello') say('world', 10) def func(a, b=5, c=10): print('a is ', a, ' b is ', b, ' c is ', c) #using keywords func(c=20...
402c3652ade91fef3e02de9847d27485a48804a1
digression99/python_study1
/func_return.py
343
3.8125
4
def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: return y print(maximum(2, 3)) def returnInputs(): x = int(input('enter number : ')) if (x < 10): return x else: return None print(returnInputs()) #pass?? def some...
bae41e45f2bdcc889e0792f9fc7a0329dd039036
mariiamatvienko/codereview
/matvienkome/first/task2.py
195
3.71875
4
""" Користувач вводить текст,вивести слова, де є символ 9 """ import string text=input("enter:" ) word=text.split() if word in text==9: print(word)
b49439c444dc57551d6917db0ce69e7a0b0b1fce
marciopocebon/abstract-data-types
/python/src/queues/priority_queue_list.py
787
3.5625
4
from src.list.node import Node from priority_queue_interface import PriorityQueueInterface from helper import Helper class PriorityQueueList(PriorityQueueInterface): """ implementation of a priority queue using an unordered python list """ def __init__(self): """ create an empty queue """ self.items = [] ...
bbd7be6a8c04fc251cfe6cdf75f7e22904da8ba0
marciopocebon/abstract-data-types
/python/src/queues/linked_priority_queue.py
1,365
3.984375
4
from src.list.node import Node from priority_queue_interface import PriorityQueueInterface class PriorityQueueLinkedList(PriorityQueueInterface): """ implementation of an ordered priority queue using a linked list """ def __init__(self): """ create an empty queue """ self.length = 0 self.head = None...
2c1655e7277a52b43dfdb65f8f1e6ab05e9edd74
marciopocebon/abstract-data-types
/python/src/queues/queue_list.py
556
3.6875
4
from queue_interface import QueueInterface from src.list.node import Node class QueueList(QueueInterface): """ implementation of a queue using a python list """ def __init__(self): """ create an empty queue """ self.list = [] def isEmpty(self): """ check if queue is empty """ return (self.list ...
e91fe4052e648227fb7e22cd20ab5c2617999232
marciopocebon/abstract-data-types
/python/src/trees/main.py
2,139
3.828125
4
""" Trees - made up of nodes.. also contains cargo - recursive data structure - a node that contains an object referente and two three references examples: - binary tree: each node contains a reference to two other nodes. These references are referred to as the left and right subtrees GRAMMAR root =...
59c97dea54dfb56aa435ce9cc3d8e953e98beca4
pranter21/Santotomas_estructuras_programacion
/guia5_python/G5_ejercicio3.py
1,842
3.75
4
#!/usr/bin/env python # coding=utf-8 from colored import bg, fg, attr """ @author: Adrian Verdugo @contact: adrianverdugo273@gmail.com @github: adrian273 """ # array para los datos de los trabajadores data_workers = [] total = 0 """ @type = variables para dar estilos """ colors = [bg('blue') + fg(15),...
42dc9d7704616aaa8699d8f6db657647e04574a4
captiannandrew/clock.py
/alarm.py
619
3.71875
4
import time import webbrowser print "What time do you want to wake up?" print "Please enter in military time in the following format example: 06:25" alarm = raw_input(">") Time = time.strftime("%H:%M") while Time != alarm: #sec_time will show the amount of time that is passing in seconds. sec_time = time.st...
f01559b6a85841e1673d4edd92a71637dd68eee4
PshySimon/Sentiment-Analysis
/models/basic/FNN.py
718
4.03125
4
""" 前馈神经网络 分三层: 输入层 隐藏层 输出层 """ import torch import torch.nn as nn class FNN(nn.Module): def __init__(self, input_size, hidden_size, output_size): super().__init__() self.input_size = input_size self.input = nn.Linear(input_size, hidden_size) self.hidden = n...
a5989e420af0d6b9b58c99141f83049572ff4cd0
minizhao/LintCode_python
/Python/Word_Sorting.py
873
3.828125
4
#单词给定字典后排序,思路先把对应的字符重新找回来,然后用argsort class Solution: """ @param alphabet: the new alphabet @param words: the original string array @return: the string array after sorting """ def str_reg(self,words): words_dict={} for idx,w in enumerate(words): t=''.join([str(self...
e260dc253c0afda935baef691bc82d36146d1037
jordieduk/TicTacToe
/Tic Tac Toe 001.py
1,462
3.796875
4
'''Joc del 3 en ratlla''' import random import time import os def presentacion_1(): #Retorna el nivell en que vol jugar l'usuari print() print(" TRES EN RAYA") print() print() print(" 1. Fàcil") print(" 2. Difícil") print() ...
bc164300728d4ca8b1ab907188b7a6e04f333976
shivupa/numerical_methods_release
/IPython_notebooks/01_Introduction/test_answers.py
3,066
3.953125
4
def check_x(x_variable): if type(x_variable)==float: print('Your x-value is a float! Great job!') else: print('Your x-value is not a float. Try again!') def check_y(y_variable): if type(y_variable)==int: print('Your y-value is an int! Great job!') else: print('Your y-val...
085f72e9fa8ce8bd92a4b6798dcbb577184c95a8
ayush-09/Interview-Questions
/Recursion/Flood Fill Algo.py
1,191
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 13 20:51:27 2021 @author: ayush """ class Solution: def floodFill(self, image, sr, sc, newColor): if image == None or image[sr][sc]== newColor: return image self.fill(image,sr,sc,image[sr][sc], newColor) return image def fill(self,image,r,c,init...
c637cbea9b4da0b7608c44d7614df3fcc7acf3e6
jasminekaur-prog/timetable-management-in-python
/viewsubjects.py
1,749
3.828125
4
from tkinter import * import sqlite3 from tkinter.messagebox import showinfo from tkinter.ttk import * class demo: def showdata(self): self.t1.delete(*self.t1.get_children()) s="select * from subjects where degreename='"+self.cb1.get()+"' and semester="+self.cb2.get() self.cr.execute(s) ...
b18737a279e3b4511d708ae94bd53bc59a2be024
datastarteu/python-edh
/Lecture 1/Lecture.py
2,367
4.28125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 10 18:00:20 2017 @author: Pablo Maldonado """ # The "compulsory" Hello world program print("Hello World") ########################### ### Data types ########################### ## What kind of stuff can we work with? # First tipe: Boolean x = True y = 100 < 10 y x*y x+...
4a97380f1123c0120e4c67ccc533c514c2985bad
MrMcGoats/fando_irc_bot
/calc_goal.py
1,455
3.796875
4
import datetime from pytz import timezone est=timezone("Canada/Eastern") #AlttpFando hates the west and east coasts. They also hate central NA and all of Europe and Asia, among many other places def calc_goal(day=datetime.datetime.now(est).day,month=datetime.datetime.now(est).month,year=datetime.datetime.now(est).ye...
e405c11103832e08b2c6fe28369d3d9675f48e16
KitCassetta/AntFarm
/Python Exercises/CS521/Cassetta_Ant_Assignment_5/create_dbs.py
2,392
3.984375
4
import sqlite3 import collections def create_baseball_db(database='baseball_stats.db'): '''1. baseball_conn connects to a database 2. baseball_cursor points to the beginning of the database''' baseball_conn = sqlite3.connect(database) baseball_cursor = baseball_conn.cursor() return baseball_conn, ...
6661df001d951e347b4970b1229e238a6aa9e5fa
KitCassetta/AntFarm
/Python Exercises/CS521/Cassetta_Ant_Assignment_6/Cassetta_Ant_Assignment_6.py
6,092
3.53125
4
import os import csv import threading import queue stocks_rows = queue.Queue(0) stocks_records = queue.Queue(0) class PackageHome: """Identify package location, confirm resource data directory is present. Return directory path. """ def __init__(self): pass def DataFile(self): self.module...
bbce463ced7623f559a30d1e7c1a9330185c22e1
KitCassetta/AntFarm
/Python Exercises/re_examples/regex_example.py
992
3.84375
4
from collections import namedtuple import re my_py = 'foo' print(my_py) Color = namedtuple('Color', ['red', 'blue', 'green']) color = Color(55,150,255) print(color.red) test_string = 'my test string dept, alpha' #pattern looks for 0 or more #whitespace charachters, returns list print(re.split(r'\s*', 'Here are ...
5a5f041391049d4e7fa05338ae258462dcbf3e12
iulidev/dictionary_search
/search_dictionary.py
2,798
4.21875
4
""" Implementarea unui dictionar roman englez si a functionalitatii de cautare in acesta, pe baza unui cuvant In cazul in care nu este gasit cuvantul in dictionar se va ridica o eroare definita de utilizator WordNotFoundError """ class Error(Exception): """Clasa de baza pentru exceptii definite de utilizator""" ...
f5e53663ffebb12b9c08c4a7fce158bc7bc825c5
khailcon/utm2dd
/utm2dd/utm2dd.py
5,206
3.71875
4
"""Translate UTM strings into Decimal Degrees. This module builds off the utm package to translate batches of UTM coordinates into latitude and longitude coordinates. This module works with UTM coordines formatted as follows: "10M 551884.29mE 5278575.64mN" Digits can by of any length. """ import pandas as p...
0c0c008725536fbec41b75b6a231bbf57b0c9c34
7honarias/python_sin_fronteras
/print_name_rever.py
254
3.984375
4
#!/usr/bin/python3 name = "Pedro" lastname = "Perez" fullName = name + ' ' + lastname b = len(fullName) - 1 while b >= 0: print(fullName[b], end='') b -= 1 print() # tambien se puede dar vuelta al String de la siguiente manera print(fullName[::-1])
fee4f8a695c22ca3381db5beea8f63ebb9f2b76d
jkcampb/AdventOfCode2020
/python/Day02/day02.py
1,471
3.734375
4
def parseLine(line): parts1 = line.strip().split(': ') password = parts1[1] parts2 = parts1[0].split(' ') character = parts2[1] minmax = parts2[0].split('-') charMin = int(minmax[0]) charMax = int(minmax[1]) return password, character, charMin, charMax def checkPassword1(password, ...
c6296821328e5c88a278ad9e52fc5b11e841437a
ahmedbazina/Information-of-Bees-Dissertation
/Testing/merge.py
1,143
3.859375
4
import pandas as pd from time import sleep print("Welcome to Excel worksheet merger") print("All files must me .xlsx file format") print("Please add the following answers") print("........................................") sleep(1) file1 = input("Please enter the 1st excel file name\n") file2 = input("Please enter th...
9a29a3683e98e61ce934b563c882338fcaf58d0f
arathore14/Python
/studentClass.py
3,475
4.3125
4
#STUDENT CLASS______________ class Student(object): """Student Class- Creates objects based on Students' characteristics ----------------------------------------------------------------------""" totalEnrollment = 0 enrolled = "y" #totalEnrollment +=1 def __init__ (self, name, g_num, status='', ...
e54b91e16653f4dd729c5c833cc0d8c3782b796e
ewilso73/some_devnet_code
/basic_dblr.py
604
4.0625
4
import sys def doubler(number): """ Given a number, double it and return the value. """ result = number * 2 return result if __name__ == '__main__': try: input = float(sys.argv[1]) except (IndexError, ValueError) as e: print("++++++++++++++++++++++++++++++++++++++++++++") print("+++++++++ Welcome to the D...
f2a52f5987b2b1fa880ed00d6e209039a545a7fe
gbroady19/CS550
/Bankaccount.py
831
3.546875
4
import random class BankAccount: def __init__(PIN, balance,name,status): self.accountnum = random.randrange(1000,10000) self.PIN = PIN self.balance = balance self.status = status self.name = name def deposit(self, deposit): self.balance += deposit status = "Hello, "+self.name+" you have sucessfull...
10a329cc5fb0bb952d64bfec69f9e53c207626a2
gbroady19/CS550
/Choatee.py
1,299
3.75
4
class Choate Student: #constructor #scale out of 10 def __init__(self, name,energy,fullness, happiness, workload, gpa, form, money): self.fullness= fullness self.energy = energy self.time = energy self.happiness= happiness self.homework = workload self.grades = gpa self.allowance = money self.na...
b1b5fccea6b19c73343208eb5ad89a09b85e9a5d
gbroady19/CS550
/mandelbrout.py
1,372
3.875
4
''' investigate mandelbrout fractal feel comfortable manipulating pixels For each pixel (Px, Py) on the screen, do: { x0 = scaled x coordinate of pixel (scaled to lie in the Mandelbrot X scale (-2.5, 1)) y0 = scaled y coordinate of pixel (scaled to lie in the Mandelbrot Y scale (-1, 1)) x = 0.0 y = 0.0 it...
67f949e3b376c4216941f908f3ce257ef3fa2a62
gbroady19/CS550
/countx.py
245
3.640625
4
ui = list(input("Put in a string, i'll tell ya how many x's are in there\n\n>>")) counts = 0 def count(ui): global counts try: del ui[ui.index("x")] counts += 1 count(ui) except ValueError: pass return counts print(count(ui))
26bba9452271974e2f8ee870f1f9df4b9492fcb8
parenkepka/euler
/1.py
962
3.890625
4
# Если выписать все натуральные числа меньше 10, кратные 3 или 5, то получим 3, 5, 6 и 9. Сумма этих чисел равна 23. # Найдите сумму всех чисел меньше 1000, кратных 3 или 5. x = 0 y = 0 a = 0 b = 0 c = 0 d = 0 #считаем сумму чисел кратную 3 while True: if x < 1000: y += x x += 3 ...
4fff8fcaf940e4bfff96a4074e24cd8f2b02234c
mcvittal/RecipeChooser
/get_data.py
1,819
3.515625
4
#!/usr/bin/env python import sqlite3 def clean_singleresult(result): tmp = [] for row in result: tmp.append(row) tmp2 = [] for row in tmp: tmp2.append(row[0]) return tmp2 conn = sqlite3.connect("db.db") conn2 = sqlite3.connect("db.db") c2 = conn2.cursor() c = conn.cursor() # Get ...
2c3ea109dacfefb3a2392a0f581eff505ab43fbe
wazapyer321/Machine-learning-Neural-network-project-
/cars_ML.py
2,173
3.671875
4
import tensorflow import pandas as pd import numpy as np import sklearn from sklearn.utils import shuffle from sklearn.neighbors import KNeighborsClassifier from sklearn import linear_model,preprocessing #k-Nearest Neighbors - p.1 - irregular data ( video time stamp 55:00 ) #data is is not 100% ( like missing...
8be94bc4445de4bbc0c2ad37d191353f8c1bab96
naduhz/tutorials
/automate-the-boring-stuff/Collatz Sequence.py
343
4.21875
4
#Collatz Sequence def collatz(number): if number % 2 == 0: print(number // 2) return number // 2 elif number % 2 == 1: print(3 * number + 1) return 3 * number + 1 print('Enter any number: ') anyNumber = int(input()) while anyNumber != 1: anyNumb...
e7fb8e21eb70c9d4e86e6143cc5c1f5feb6ce9a5
naduhz/tutorials
/sentdex-machine-learning/regression/best-fit-slope.py
1,700
3.578125
4
from statistics import mean import numpy as np import random import matplotlib.pyplot as plt from matplotlib import style style.use("fivethirtyeight") # np.random.seed(42) # X = np.random.randint( # 100, # size=30, # ) # Y = np.random.randint(100, size=30) def create_dataset(size, variance, step=2, correlat...
8641c008b5ecc1bd7f0d0a8fe4e7cd3263ffcf1b
lime2002/Test
/kerta.py
117
3.640625
4
val1 = int(input("anna luku:\n")) for i in range(1,13): print(i, "kertaa", val1, "on",val1 * i)
c3b263423bfae66657217dae4e0e68de771f711a
nelsondelimar/examples
/grav-corrections/functions.py
7,859
3.65625
4
import numpy as np import matplotlib.pyplot as plt def somigliana(phi): ''' This function calculates the normal gravity by using the Somigliana's formula. input: phi: array containing the geodetic latitudes [degree] output: gamma: array containing the values of normal gravity ...
c0744cc7d837a7463a20a65549d4f2eb646f12f3
kurusunagisa/Dragonfly-Key-Exchange
/implement/makeHash.py
719
3.6875
4
import hashlib class Hash: def __init__(self, alice: bytes, bob: bytes, password: bytes): self.a = alice self.b = bob self.password = password def makeHash(self, counter): #print(type(counter)) old = str(max(self.a, self.b) + min(self.a, self.b) + self.password + chr(...
a1a03ca9bf6725f42073a30ee6e15b25de0fabda
shuaibr/Encryption-and-Security
/Decimation.py
5,098
3.578125
4
import math import string import mod import matrix import utilities_A4 #----------------------------------------------------------- # Parameters: plaintext (str) # key (str,int) # Return: ciphertext (str) # Description: Encryption using Decimation Cipher # key is tuple (baseStrin...
e102e140b57dc6c635051299ba434ed878c306fb
tobby168/sorting-implemented-by-python
/quick_sort.py
1,073
3.953125
4
import random from sorting import less, exchange, check def quick_sort(array): # shuffle the array is needed to ensure the runtime random.shuffle(array) sort(array, 0, len(array) - 1) def sort(array, lo, hi): if hi <= lo: return # sort the array recursively j = partition(array, lo, hi) sort(array...
73b0ac3a0ecc258b9ecaca3ab767e0615ea43a11
candyer/codechef
/pac6/pac6.py
935
3.796875
4
# # https://www.codechef.com/problems/PAC6 # Dijkstra's algorithm from collections import defaultdict from heapq import heappop, heappush def dijkstra(n, start, to, graph): cost = {i: float('inf') for i in range(1, n + 1)} cost[start] = 0 visit = [] heappush(visit, [0, start]) while visit: start_cost, start...
238719364eba297337db98445d723cf5a7b8f03e
candyer/codechef
/LoC July 2018/COLCHEF/COLCHEF.py
1,232
3.796875
4
# https://www.codechef.com/LOCJUL18/problems/COLCHEF class DisjointSet(): def __init__(self): self.leader = {} self.group = {} def add_edge(self, a, b): leadera = self.leader.get(a) leaderb = self.leader.get(b) if leadera is not None: if leaderb is not None: if leadera == leaderb: return ...
5ebb6b2173c0439331775b86d1cd568cf4ef516e
candyer/codechef
/August Challenge 2019/CHEFDIL/CHEFDIL.py
247
3.609375
4
# https://www.codechef.com/AUG19A/problems/CHEFDIL def solve(s): count = s.count('1') if count % 2 == 1: return 'WIN' return 'LOSE' if __name__ == '__main__': t = int(raw_input()) for _ in range(t): s = raw_input() print solve(s)
12c63524b2a4c95228d029c63a3ad0737626a81f
candyer/codechef
/July Challenge 2019/CHFM/CHFM.py
649
3.671875
4
# https://www.codechef.com/JULY19A/problems/CHFM def solve(n, array): total = sum(array) if total % n != 0: return 'Impossible' mean = total / n if mean in array: return array.index(mean) + 1 return 'Impossible' if __name__ == '__main__': t = int(raw_input()) for _ in range(t): n = int(raw_input()) ar...
60e3841effa56896a1bfec7d58471dde203cc37c
candyer/codechef
/cook82A/cook82A.py
528
3.671875
4
# https://www.codechef.com/COOK82/problems/COOK82A def solve(d): if d['RealMadrid'] < d['Malaga'] and d['Barcelona'] > d['Eibar']: return 'Barcelona' return 'RealMadrid' if __name__ == '__main__': t = int(raw_input()) d = {} for _ in range(t): for i in range(4): team, score = raw_input().split() d[team...
c9f8feb5dceca65df1e800cdf743dd417983e1d3
candyer/codechef
/September Challenge 2018/MAGICHF/MAGICHF.py
950
3.59375
4
# https://www.codechef.com/SEPT18B/problems/MAGICHF ####################### ###### solution 1 ##### ####################### def solve(n, x, s, actions): boxes = [False] * (n + 1) boxes[x] = True res = x for a, b in actions: if boxes[a]: boxes[a], boxes[b] = boxes[b], boxes[a] res = b elif boxes[b]: bo...
8c372c9e8b2cd423dee2041c078f197b32cb2697
candyer/codechef
/July Challenge 2019/GUESSPRM/GUESSPRM.py
943
3.578125
4
# https://www.codechef.com/JULY19A/problems/GUESSPRM import sys def prime_factors(num): factors = set() while num % 2 == 0: factors.add(2) num /= 2 i = 3 while i * i <= num: if num % i: i += 2 else: factors.add(i) num /= i if num > 1: factors.add(num) return factors if __name__ == '__main__'...
e0fe974306b3c2f14a02260f37a0de56a68dee1d
SshODUA/HIllel_HW
/my_game.py
4,001
3.890625
4
import random class Unit: _random_chance = 0 def __init__(self, name='unnamed_unit', health=100, attack=0, defence=0): self._name_of_unit = name self._health_of_unit = health self._attack_level = attack self._defence_level = defence @property def name(self): r...
ef86e3fe5c10173bbb50a43da06cb55c853e85af
aulawrence/wheel_sieve
/wheel_sieve/ecm/ecm_polyeval.py
9,024
3.671875
4
"""Elliptic Curve Method with Brent-Suyama Extension and Polyeval. """ import random import time from math import gcd import numpy as np from wheel_sieve.common import PRIME_GEN, InverseNotFound, CurveInitFail from wheel_sieve.ecm.ecm_brent_suyama import ( apply_polynomial, get_difference_seq, step_differen...
feb32f51fe01731f53996c1150e064b43312deae
denbeigh2000/py-hashtable
/hashtable_smart_collisions.py
3,526
3.703125
4
#!/usr/bin/python2 MAX_MISS_COUNT = 3 class HashTable(object): def __init__(self, capacity=1000, max_density=0.4): self.size = 0 self.capacity = capacity assert type(max_density) == float and max_density > 0 \ and max_density < 1 self.max_density = max_density ...
ef8f4436a14c20f6cc4c76704ed1b478ffa1bad1
madelaineyogi/portfolio
/wróżba.py
637
3.78125
4
#ciasteczko z wróżbą #program generuję wróżbę wrozba1 = 'jakie piękne oczy!' wrozba2 = 'niezły masz cios!' wrozba3 = 'ratunku!' wrozba4 = 'spójrz w górę!' wrozba5 = 'kto jak nie ty?' print('witaj w programie wróżb!') print('Mam nadzieję, że Ci się spodoba') liczba = int(input('Wybierz liczbę od 1 do 5 ')...
5a1def67bb4c3d2ca68e48b2f7679eade6bc23e5
madelaineyogi/portfolio
/Nowy ulubiony smak.py
334
3.609375
4
#nowy ulubiony smak print('Cześć!') input('Jak masz na imię?') smak1 = input('Jaki jest twój ulubiony smak?') smak2 = input('a jaki jest twój drugi ulubiony smak?') print('A co powiesz na smak ' + smak1 + " i " + smak2 + '?') print('Ja uważam, że byłby pyszny!') input('\nAby zakończyć naciśnij Enter'...
fb62ea58d94033c64ebde7f7afb5d008e8206ad1
VivaswatOjha/3DTetris
/tetromino.py
4,347
3.671875
4
import numpy as np class Tetromino: def __init__(self, block, cube, x, y, z): self.block = block self.cube = cube self.pos = np.array([x,y,z]) def can_fall(self): """ Given the current state of the cube, determines whether the tetromino can fall another ...
828cd3837ca9a08e3300dc373a3af1cf48ce2ea7
gamemering/CP3_Nuttaphat_Sumroeng
/Exercise8_Nuttaphat_S.py
2,259
3.71875
4
usernameInput = input("Username :") passwordInput = input("Password :") if usernameInput == "admin" and passwordInput == "1234": print("Login Success\n-----------------------------") print(" ร้าน G shop Bekery ยินดีให้บริการ \n") print(" รายการสินค้า \n") print("1.ขนมปังใส...
d1de6f1cc0c71785f177cd4eb8e691320631ef15
Renestl/jetbrains-Numeric-Matrix-Processor
/processor/processor.py
997
3.796875
4
def init_matrix(rows): matrix = [] for row in range(rows): temp = list(map(int, input().split(' '))) matrix.append(temp) return matrix def add_matrix(): a_rows, a_cols = input().split() matrix_a = init_matrix(int(a_rows)) b_rows, b_cols = input().split() matrix_b = init_...
e2bb2d975de5ede39c8393da03e9ad7f48a19b7f
TenzinJam/pythonPractice
/freeCodeCamp1/try_except.py
1,080
4.5
4
#try-except block # it's pretty similar to try catch in javascript # this can also help with some mathematical operations that's not valid. such as 10/3. It will go through the except code and print invalid input. The input was valid because it was a number, but mathematically it was not possible to compute that number...
625d6d7af86693494b3afea155ae3308557ca12e
clamli/ml_algorithms
/knn_kdtree/myutil.py
562
3.59375
4
import numpy as np def get_median(data): """input: list : one-dimension feature output: int/float : middle value --------- """ data.sort() half = len(data) // 2 return data[half] def eucli_distance(point_1, point_2): """input: list : point_1, point_2 output: ...
c1c368937073a6f68e60d72a72d5c5f36f0243c1
kristinnk18/NEW
/Project_1/Project_1_uppkast_1.py
1,481
4.25
4
balance = input("Input the cost of the item in $: ") balance = float(balance) x = 2500 monthly_payment_rate = input("Input the monthly payment in $: ") monthly_payment_rate = float(monthly_payment_rate) monthly_payment = monthly_payment_rate while balance < x: if balance <= 1000: for month in range(1, ...
be515f0adc638fd089a400065d74d2292bbaaecd
kristinnk18/NEW
/Skipanir/Lists/dotProduct.py
780
4.25
4
# Input vector size: 3 # Element no 1: 1 # Element no 2: 3.0 # Element no 3: -5 # Element no 1: 4 # Element no 2: -2.0 # Element no 3: -1 # Dot product is: 3.0 def input_vector(size): input_vector = [] element = 1 for i in range(size): vector = float(input("Element no {}: ".format(element))) ...
06119d936bbe22687f7b163aee7cda895eae7957
kristinnk18/NEW
/Skipanir/whileLoops/Timi_3_2.py
327
4.1875
4
#Write a program using a while statement, that given the number n as input, prints the first n odd numbers starting from 1. #For example if the input is #4 #The output will be: #1 #3 #5 #7 num = int(input("Input an int: ")) count = 0 odd_number = 1 while count < num: print(odd_number) odd_number += 2 cou...
5bb9558126505e69beda2cfb5e076e33a7cffa48
kristinnk18/NEW
/Skipanir/whileLoops/Timi_3_6.py
426
4.125
4
#Write a program using a while statement, that prints out the two-digit number such that when you square it, # the resulting three-digit number has its rightmost two digits the same as the original two-digit number. # That is, for a number in the form AB: # AB * AB = CAB, for some C. count = 10 while count <= 10...
ab3da913e858ba47242ef8a7cb929c1db24754c8
kristinnk18/NEW
/Skipanir/algorithms/max_number.py
281
4.21875
4
number = int(input("input a number: ")) max_number = number while number > 0: if number > max_number: max_number = number number = int(input("input a number: ")) print(max_number) # prentar ut stærstu töluna sem er innsleginn þangað til talan verður < 0.
8d51a0547e26c0a4944ff04866cc37fd83c2ad35
kristinnk18/NEW
/Skipanir/Lists/pascalsTriangle.py
444
4.1875
4
def make_new_row(x): new_list = [] if x == []: return [1] elif x == [1]: return [1,1] new_list.append(1) for i in range(len(x)-1): new_list.append(x[i]+x[i+1]) new_list.append(1) return new_list # Main program starts here - DO NOT CHANGE height = int(input("Height o...
ba84c78af7329d6da036e7084d7df719b63ded62
kristinnk18/NEW
/Skipanir/strings/strings_print.py
2,441
3.71875
4
message = "Hello world" print(len(message)) # prentar út lengd orðsins: 11 print(message[2]) # prentar staf númer 3 "l" (0,1,2) í orðinu hello world: l print(message[:3]) # prentar stafi 0 - 3: "hel" print(message[6:]) # prentar "world" # ".upper" er dæmi um method, segir til um hvernig einhvað er prentað út. ...
26f7474ef39d8d92a78e605b92bdb46e73b77e45
Bioluwatifemi/Assignment
/assignment.py
345
4.15625
4
my_dict = {} length = int(input('Enter a number: ')) for num in range(1, length+1): my_dict.update({num:num*num}) print(my_dict) numbers = {2:4, 3:9, 4:16} numbers2 = {} your_num = int(input('Enter a number: ')) for key,value in numbers.items(): numbers2.update({key*your_num:value*you...
7dec563787bc186d055102d26d263cfc5642290d
dpaneda/code
/jams/euler/1.py
123
3.828125
4
#!/usr/bin/env python total = 0 for n in range(1, 1000): if (n % 3 == 0) or (n % 5 == 0): total += n print(total)
64ac7fadb4588dc03787d57fc330ae1c72fcdca2
dpaneda/code
/tuenti_contest/06.py
478
3.546875
4
#!/usr/bin/python import sys import time # Number of leds of each number digit_led = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6] def count_leds(time): leds = 0 for num in (time.tm_hour, time.tm_min, time.tm_sec): leds += digit_led[num % 10] leds += digit_led[num / 10] return leds for line in sys.stdi...
04b8a42e431c3b620a5939cdb5178b6849024ba1
dpaneda/code
/jams/euler/25.py
509
3.640625
4
#!/usr/bin/python import time import numpy import sys from math import sqrt, log memo = {0:0, 1:1} def fib(n): if not n in memo: memo[n] = fib(n-1) + fib(n-2) return memo[n] def fibonacci2(n): root5 = sqrt(5) phi = 0.5 + root5/2 return int(0.5 + phi**n/root5) phi = (1 + 5**0.5) / 2 ...
e08f50c6ba5612f962b32408f67ac4c2711709ad
dpaneda/code
/jams/advent/2019/1/b.py
219
3.71875
4
#!/usr/bin/env python3 import sys total = 0 for line in sys.stdin.readlines(): mass = int(line) fuel = int(mass / 3) - 2 while fuel > 0: total += fuel fuel = int(fuel / 3) - 2 print(total)
b92642078421a425bc95c02c0707db4a389f8bcc
dpaneda/code
/jams/hacker_cup/2017/1/pie.py
416
3.5625
4
#!/usr/bin/python3 import math def solve(): perc, x, y = list(map(int, input().split())) x -= 50 y -= 50 point_degree = math.degrees(math.atan2(y, x)) r = math.sqrt(x * x + y * y) degree = (perc * 360) / 100 if point_degree <= degree and r <= 50: return 'black' return 'white' ...
a1bddb898c5730456341ff76c2984304adea970b
dpaneda/code
/jams/gcj/2019/R1C/a.py
1,595
3.515625
4
#!/usr/bin/python2 R = set('R') P = set('P') S = set('S') RP = set(['R', 'P']) RS = set(['R', 'S']) PS = set(['P', 'S']) found = False def get_movements(robots, n): movements = set() for r in robots: movements.add(r[n % len(r)]) return movements def options(movement): if movement == R: ...
8525be49d98a31c1a435a931593a124cacea41c6
dpaneda/code
/jams/euler/47.py
819
3.65625
4
#!/usr/bin/env python3 import math def is_prime(n): for m in range(2, 1 + int(math.sqrt(n))): if n % m == 0: return False return True np = {} def next_prime(n): if n in np: return np[n] n2 = n + 1 while not is_prime(n2): n2 += 1 np[n] = n2 return n2 def factorize(n): factors = set...
f233f2888af40bef40d1433d7f5dc2c876dff724
Fadzayi-commits/Programming_Assignment_11
/GreaterThan_givenK.py
235
3.609375
4
def string_k(k, str): string = [] text = str.split(" ") for x in text: if len(x) > k: string.append(x) return string k = 3 str = "Data Science for greeks" print(string_k(k, str))
9ebaea9f7e635cacb4146b4e0959501fc2383ae8
daveclouds/python
/OperatorsPrintFunc.py
145
4.09375
4
n = int(input('Enter number: ')) if n <= 100: print('The number is less than 100 ') if n >= 100: print('The number is grather than 100')
7028471a2d611b32767fb9d62a2acaab98edb281
free4hny/network_security
/encryption.py
2,243
4.5625
5
#Key Generation print("Please enter the Caesar Cipher key that you would like to use. Please enter a number between 1 and 25 (both inclusive).") key = int(input()) while key < 1 or key > 25: print(" Unfortunately, you have entered an invalid key. Please enter a number between 1 and 25 (both inclusive) only.") ...
aacace9f445f6f26d1f1e12c1e38802cb4d58c69
Kiara-Marie/ProjectEuler
/4 (palindrome 3digit product).py
706
4.34375
4
def isPalindrome(x): "Produces true if the given number is a palindrome" sx = str(x) # a string version of the given number lx = len(sx) # the number of digits in the given number n = lx - 1 m = 0 while 5 == 5: if sx[m] != sx[n] : return (False) break elif...
d0555755d49ee71ab56a5ca994832811f450f4dc
bbrecht02/python-exercises
/cursoemvideo-python/ex005.py
152
4.15625
4
num = int(input("digite um número:")) print("observando o valor {}, seu antecessor é: {}, e seu sucessor é: {}".format(num,num-1,num+1))
626ce95b24de2cd3b3ba907e84678c862d4b3d27
bbrecht02/python-exercises
/cursoemvideo-python/ex041.py
362
3.859375
4
from datetime import * ano_nascimento= int(input("ano de nascimento: ")) data= date.today().year idade= data-ano_nascimento print(idade) if idade>0 and idade <=9: print("Mirim") elif idade>9 and idade<=14: print("Infantil") elif idade>14 and idade<=19: print("Junior") elif idade>19 and idade<=25: print(...
5d26d4692fa576ad61abb1240404e982fac24c1e
bbrecht02/python-exercises
/cursoemvideo-python/ex030.py
145
4.03125
4
num= int(input("Digite um número qualquer:\n")) if num%2==0: print("esse número é PAR") else: print("esse número é IMPAR")
ee8f08a14c3437149abbfa0fdd0cb086192bdff7
bbrecht02/python-exercises
/cursoemvideo-python/ex045.py
1,029
3.734375
4
import time from random import * print("Suas Opções:\n[0] PEDRA\n[1]PAPEL\n[2]TESOURA") User= int(input("Qual sua opção: ")) opcoes= ["pedra", "papel", "tesoura"] option = randint(0, 2) pc= opcoes[option] print("JO") time.sleep(1.5) print("KEN") time.sleep(1.5) print("PO!!!") print("-=-=-=-=-=-=-=-=-=-=-=...
80ade572ba368b6ff7587525d07db2cc1e2424d4
bbrecht02/python-exercises
/cursoemvideo-python/ex008.py
418
4.21875
4
metro= float(input("Escreva uma distancia em metros:")) print ("A medida de {} m corresponde a:".format(metro)) # km= metro*10**-3 print ("{} km".format(km)) # hm= metro*10**-2 print ("{} hm".format(hm)) # dam= metro*10**-1 print ("{} dam".format(dam)) # dm= metro*10**1 print ("{} dm".format(dm)) # cm= m...
57752f34621d817489ad5eec925e6340bb989080
bbrecht02/python-exercises
/cursoemvideo-python/ex043.py
411
3.921875
4
kg= float(input("Qual seu peso?(kg)")) h= float(input("Qual sua altura?(m)")) imc= kg/(h**2) print ("{:.1f}".format(imc)) if imc<18.5: print("voce esta ABAIXO DO PESO") elif imc>18.5 and imc<=25: print("Seu peso esta NORMAL") elif imc>25 and imc<=30: print("voce esta em SOBREPESO") elif imc>30 and imc <=...
5e542511e7b161224edb1041c062cbb4835f6eed
peikleh/Neural_Net
/neural_net.py
1,017
3.515625
4
import numpy as np import os, binascii class Network(object): def __init__(self, sizes): self.num_layers = len(sizes) self.sizes = sizes self.biases = [np.random.randn(y, 1) for y in sizes[1:]] self.weights = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])] def feedforward(self, ...
9369e45b19cd7daf571e3e7b6166923a7a1e5a1a
TEC-2014092195/IC1802-introduccion-a-la-programacion
/Asignaciones/Matrices con ceros.py
2,063
4.0625
4
##Utiliza una matriz por ejemplo 3x3 ## [[1, 0, 0], [5, 4, 0], [2, 8, 7]] ## donde en forma piramidal cuenta que haya ceros recorriendola ##de abajo hacia arriba ##corridas: ## 1-- [2, 8, 7] ## 2-- [5, 4, 0] ## 3-- [1, 0, 0] ##para que sea superior debe cumplir el ejemplo de arriba con cero...
3406b3c6b70c53bb47120065653fa94d8d878311
TEC-2014092195/IC1802-introduccion-a-la-programacion
/Asignaciones/Clases (1)/Clase_Camisa.py
530
3.78125
4
class camisa: color="" talla="" material="" def setDatos(self, colorp, tallap,materialp): self.color=colorp self.talla=tallap self.material=materialp def getDatos(self): return ("\nColor: "+self.color+"\ntalla: "+self.talla+"\nmaterial: "+self.material) camisava...
460ba5a60ab9a38e85340fc373790155e88dfa7e
TEC-2014092195/IC1802-introduccion-a-la-programacion
/Asignaciones/Recursividad, Listas y arboles/fibonacci.py
237
3.546875
4
def fib(num,anterior=0,sucesor=1,t=0): if num == 1: return t else: t=anterior+sucesor anterior=sucesor sucesor=t return fib(num-1,anterior,sucesor,t) print(fib(7))
a333f2008ca964927f8c31d1151d14881508a72e
TEC-2014092195/IC1802-introduccion-a-la-programacion
/Asignaciones/Matrices y Encriptador/Ejercicio_3_Divisibles_por_7.py
1,127
3.765625
4
##3. Escriba un programa que busque todos los numeros divisibles por 7 pero que no son multiplos de 5, ##entre un numero n y m, inclusives. Imprima los numeros obtenidos en lineas de 5 en 5, separados por coma cont="s" while cont=="s": try: n=int(input("Digite el primer número: ")) m=int(inpu...
9169eefa94ef52e8373a7ca4cf1f4aac3568553e
TEC-2014092195/IC1802-introduccion-a-la-programacion
/Asignaciones/Herencia/Test_Herencia.py
619
4
4
class Humano(): def hablar(self,nom): self.nom = nom print("Mi nobre es: "+ self.nom) class IngSis(Humano): def __init__(self,edad): self.edad=edad print("Mi edad es: "+self.edad) def programar(self,lenguaje): self.lenguaje=lenguaje ...