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
56e978332bc89abfef96a4e87336b04f9e4dcdd9
alhursalman/shaziscool
/number_rounder.py
280
3.984375
4
print ("The -is my first number bigger than my second number confirmer-.") numa = float(input("First number:")) numb = float(input("Second number:")) if numa > numb: num1big= True else: num1big= False print ("Number 1 is bigger. (The previous sentence is", num1big,".)")
1a6a2321d51baf188ce43cdb0bfb20991fff9d75
ujuc/introcs-py
/introcs/stdlib/stdstats.py
1,108
3.765625
4
""" stdstats.py ``stdstats`` 모듈은 통계 분석과 그래픽 데이터 표시에 관련된 기능을 정의합니다. """ import math import introcs.stdlib.stddraw as stddraw def mean(a): return sum(a) / float(len(a)) def var(a): mu = mean(a) total = 0.0 for x in a: total += (x - mu) * (x - mu) return total / (float(len(a)) - 1.0) ...
35b773998d19b37ce486cb5d21ab801d33dc7369
ujuc/introcs-py
/introcs/ch1/exp_q/2/1_2_4.py
113
3.53125
4
from introcs.stdlib import stdio a = 2 b = 3 stdio.writeln(not (a < b) and not (a > b)) stdio.writeln(a == b)
d47c98841ac6501af8cc332af95dcd5de76adad8
NightKirie/NCKU_NLP_2018_industry3
/Packages/matplotlib-2.2.2/lib/mpl_examples/lines_bars_and_markers/line_demo_dash_control.py
687
3.90625
4
""" ======================================= A simple plot with a custom dashed line ======================================= A Line object's ``set_dashes`` method allows you to specify dashes with a series of on/off lengths (in points). """ import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 500...
5423a5a94d1e429f6605b6a19458020d7970064b
asawaged/ISQA3900
/scores.py
1,127
4
4
from statistics import mean def display_title(): print("The Test Scores program") print("Enter -999 to quit") def main(): display_title() grades = getScores() grade = mean(grades) abcGrade = getGrade(grade) print("\nScores: ",grades) print("Total: ",sum(grades)) print("N...
63beaf940424b5ea9b1bb0c2b187dc0697f8ac77
cbadami/CSC-842
/Project 3/imagepass.py
2,746
3.765625
4
#!c:/Program%Files/Python36 python.exe # Author: Charles Badami # Date: 6/21/19 # Program Name: Imagepass ''' Description/Purpose: This program is the first iteration of simple algorithm that uses an image to generate a pseudo-random, 16-character password, using base64 encoding. In order to retrieve a forgotten pass...
61155ea5ff49b5d96c34ba013d9cfa71ad55506f
emrehaskilic/tekrar
/introduction/lesson4/list.py
1,055
4
4
# birden fazla elemanla çalışacak sek tek tek değişken tanımlamak yerine dizi kullanıyorum # tanımlama şekli: sehirler = ["istanbul","edirne","konya","rize","ankara","eskisehir","adana","kayseri"] # not: bir dizinin eleman sayisi x ise index sayisi x-1'dir print(sehirler[-1]) # listenin son elemanını yazdırdı index...
c6c111771c9fd6aeb8e6fe3efcd88da70f82a83f
emrehaskilic/tekrar
/introduction/lesson2/hataYonetimi1.py
365
3.515625
4
# Hatalar 4 e ayrılır # 1) Programcı Hataları # 2) Program Kusurları # 3) İstisnai Hatalar # 4) Mantiksal Hatalar try: telefonNo = int(input("Lutfen telefon numaranizi girinizi: ")) print("Tebrikler") except ValueError: print("Value Error") except ZeroDivisionError: print("ZeroDivisionError") except: ...
08380b54f4275869782af21479526868db8a4bdc
puchake/market-teller
/src/data_handling/data_split.py
2,286
3.546875
4
import numpy as np import csv import datetime as dt def split_csv(in_file_path, out_dir_path): """ Splits csv data file into smaller pieces using ticker names. It saves split data as numpy arrays. :param in_file_path: path to csv file :param out_dir_path: path to output directory :return: - ...
0ac4c15f04bf3e49e1ca36ac3bb67e81ed9a0200
Rogersamacedo/calc
/calc.py
1,279
4.28125
4
def calculadora(): print("Qual operação deseja efetuar? : ") print( "Para soma digite 1") print( "Para subtração digite 2") print( "Para divisão digite 3") print( "Para mutiplicação digite 4") print( "Para potencia digite 5") print( "Para porcentagem digite 6") print( "Para raiz quadrada...
78f336a208eb77c5913068dcd4f25efaeb4337b8
HryChg/RaspberryPiProjects
/ButtonTrigger/buttonTrigger.py
799
3.96875
4
# followed here # https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/bread-board-setup-for-input-buttons from gpiozero import Button from signal import pause from os import system; print ('Program is starting ... ') button1 = Button(23) # define Button pin according to BCM Numbering butto...
d7a0eaf524bd36baf8ef17e6aab4147e32e61e9b
DeepuDevadas97/-t2021-2-1
/Problem-1.py
1,046
4.21875
4
class Calculator(): def __init__(self,a,b): self.a=a self.b=b def addition(self): return self.a+self.b def subtraction(self): return self.a-self.b def multiplication(self): return self.a*self.b def division(self): ...
d05ea6103a3aac5bdebdbb71a0772da74535668f
bis-bald/attempt2
/linked_list/linked_list_class.py
1,334
3.953125
4
import unittest class Node(object): def __init__(self,value): self.data = value self.nextNode = None class LinkedList(object): def __init__(self,headNode = None): self.head = headNode def append(self,value): if self.head == None: self.head = Node(value) current = self.head while current.nextNode != ...
a53dc52a5fdbd1d9b25d2282036f8fcaa4ad11f3
kelpasa/Code_Wars_Python
/6 кю/ASCII hex converter.py
467
3.890625
4
''' Write a module Converter that can take ASCII text and convert it to hexadecimal. The class should also be able to take hexadecimal and convert it to ASCII text. ''' class Converter(): @staticmethod def to_ascii(h): from re import findall as fin return ''.join([chr(i) for i in ([int(i,16) ...
22b5e71d891a902473213c464125bea0ca1526c6
kelpasa/Code_Wars_Python
/5 кю/RGB To Hex Conversion.py
971
4.21875
4
''' The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Valid decimal values for RGB are 0 - 255. Any values that fall out of that range must be rounded to the closest valid value. Note: Your answer should always be 6 characters ...
1120d72d9169880d35291eab5f2203fb3580bbf5
kelpasa/Code_Wars_Python
/6 кю/String array revisal.py
748
3.921875
4
''' In this Kata, you will be given an array of strings and your task is to remove all consecutive duplicate letters from each string in the array. For example: dup(["abracadabra","allottee","assessee"]) = ["abracadabra","alote","asese"]. dup(["kelless","keenness"]) = ["keles","kenes"]. Strings will be alphabet cha...
efe2f3dd96140dfb7ca59d5a5571e6c031491273
kelpasa/Code_Wars_Python
/5 кю/Scramblies.py
430
4.15625
4
''' Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false. Notes: Only lower case letters will be used (a-z). No punctuation or digits will be included. Performance needs to be considered ''' def scramble(s1,s2): fo...
dd779b32823d27f4e4ecb31e982778759dad57cf
kelpasa/Code_Wars_Python
/6 кю/Easy Balance Checking.py
2,566
3.625
4
''' You are given a (small) check book as a - sometimes - cluttered (by non-alphanumeric characters) string: "1000.00 125 Market 125.45 126 Hardware 34.95 127 Video 7.45 128 Book 14.32 129 Gasoline 16.10" The first line shows the original balance. Each other line (when not blank) gives information: check number, categ...
2310c8587f47159a18e46b16b7d93170bad5d580
kelpasa/Code_Wars_Python
/6 кю/Validate Credit Card Number.py
1,370
3.890625
4
''' In this Kata, you will implement the Luhn Algorithm, which is used to help validate credit card numbers. Given a positive integer of up to 16 digits, return true if it is a valid credit card number, and false if it is not. Here is the algorithm: ''' def validate(n): n = [int(i) for i in (str(n))] ...
51a9cfb41b9af82091397763aae42d4ec52c1238
kelpasa/Code_Wars_Python
/6 кю/Matrix Addition.py
493
3.9375
4
''' Write a function that accepts two square matrices (N x N two dimensional arrays), and return the sum of the two. Both matrices being passed into the function will be of size N x N (square), containing only integers. How to sum two matrices: Take each cell [n][m] from the first matrix, and add it with the same [n]...
4d26fc6d60a59ad20aec5456cf32bc6588018139
kelpasa/Code_Wars_Python
/6 кю/String transformer.py
489
4.40625
4
''' Given a string, return a new string that has transformed based on the input: Change case of every character, ie. lower case to upper case, upper case to lower case. Reverse the order of words from the input. Note: You will have to handle multiple spaces, and leading/trailing spaces. For example: "Example Input" ...
c2e41ebc3e43f69d7b06dbe2e466bd197a928999
kelpasa/Code_Wars_Python
/6 кю/Friendly Pairs I.py
993
3.953125
4
''' The Abundancy (A) of a number n is defined as: (sum of divisors of n) / n For example: A(8) = (1 + 2 + 4 + 8) / 8 = 15/8 A(25) = (1 + 5 + 25) / 25 = 31/25 Friendly Pairs are pairs of numbers (m, n), such that their abundancies are equal: A(n) = A(m). Write a function that returns "Friendly!" if the two given n...
992c2c8c60176bf725cb6c31f387573387fba8f9
kelpasa/Code_Wars_Python
/6 кю/Exercise in Summing.py
232
3.609375
4
''' https://www.codewars.com/kata/52cd0d600707d0abcd0003eb/train/python ''' def minimum_sum(values, n): return sum(sorted(values,reverse=False)[:n]) def maximum_sum(values, n): return sum(sorted(values,reverse=True)[:n])
973f5341eacdb3c14412e7a0034866dee3ea51d9
kelpasa/Code_Wars_Python
/6 кю/Throwing Darts.py
938
3.953125
4
''' You've just recently been hired to calculate scores for a Dart Board game! Scoring specifications: 0 points - radius above 10 5 points - radius between 5 and 10 inclusive 10 points - radius less than 5 If all radii are less than 5, award 100 BONUS POINTS! Write a function that accepts an array of radii (can be i...
a62713c957216d00edf4dbb925e5f561f94c4cf2
kelpasa/Code_Wars_Python
/6 кю/Sort sentence pseudo-alphabetically.py
1,238
4.3125
4
''' Given a standard english sentence passed in as a string, write a method that will return a sentence made up of the same words, but sorted by their first letter. However, the method of sorting has a twist to it: All words that begin with a lower case letter should be at the beginning of the sorted sentence, and sor...
f9af37f29903136d6d83087e3917487b8987e4c6
kelpasa/Code_Wars_Python
/4 кю/Strings Mix.py
2,069
4.03125
4
''' Given two strings s1 and s2, we want to visualize how different the two strings are. We will only take into account the lowercase letters (a to z). First let us count the frequency of each lowercase letters in s1 and s2. s1 = "A aaaa bb c" s2 = "& aaa bbb c d" s1 has 4 'a', 2 'b', 1 'c' s2 has 3 'a', 3 'b', 1 '...
4804ed7aa18e361bf99084a6d1f2390b18d8bb8a
kelpasa/Code_Wars_Python
/5 кю/Emirps.py
1,045
4.3125
4
''' If you reverse the word "emirp" you will have the word "prime". That idea is related with the purpose of this kata: we should select all the primes that when reversed are a different prime (so palindromic primes should be discarded). For example: 13, 17 are prime numbers and the reversed respectively are 31, 71 wh...
f8598608e15066552822cd58ae73c01bcf445028
kelpasa/Code_Wars_Python
/6 кю/Decipher this!.py
868
4
4
''' You are given a secret message you need to decipher. Here are the things you need to know to decipher it: For each word: the second and the last letter is switched (e.g. Hello becomes Holle) the first letter is replaced by its character code (e.g. H becomes 72) Note: there are no special characters used, only let...
4058cb8f075543bc2b78a15f129ec92fd395490a
kelpasa/Code_Wars_Python
/6 кю/Group in 10s.py
796
4.0625
4
''' Write a function groupIn10s which takes any number of arguments, and groups them into sets of 10s and sorts each group in ascending order. The return value should be an array of arrays, so that numbers between 0-9 inclusive are in position 0 and numbers 10-19 are in position 1, etc. Here's an example of the requi...
3f821ad7f3538a1066e56a6c8737932fcbda94b0
kelpasa/Code_Wars_Python
/6 кю/Parity bit - Error detecting code.py
1,118
4.21875
4
''' In telecomunications we use information coding to detect and prevent errors while sending data. A parity bit is a bit added to a string of binary code that indicates whether the number of 1-bits in the string is even or odd. Parity bits are used as the simplest form of error detecting code, and can detect a 1 bit ...
ab10772302efd8e44c5b0d5a157587cbeea7ce62
kelpasa/Code_Wars_Python
/6 кю/Multiplication table.py
424
4.15625
4
''' our task, is to create NxN multiplication table, of size provided in parameter. for example, when given size is 3: 1 2 3 2 4 6 3 6 9 for given example, the return value should be: [[1,2,3],[2,4,6],[3,6,9]] ''' def multiplicationTable(n): table = [] for num in range(1, n+ 1): row = [] for c...
9180bd22fb2a47c8276454dda65caa58fd5116ce
kelpasa/Code_Wars_Python
/6 кю/Matrix Trace.py
1,236
4.34375
4
''' Calculate the trace of a square matrix. A square matrix has n rows and n columns, where n is any integer > 0. The entries of the matrix can contain any number of integers. The function should return the calculated trace of the matrix, or nil/None if the array is empty or not square; you can otherwise assume the inp...
deb7b21d9a08444b3681c1fce4ce1f82e38a6192
kelpasa/Code_Wars_Python
/6 кю/Selective Array Reversing.py
893
4.46875
4
''' Given an array, return the reversed version of the array (a different kind of reverse though), you reverse portions of the array, you'll be given a length argument which represents the length of each portion you are to reverse. E.g selReverse([1,2,3,4,5,6], 2) //=> [2,1, 4,3, 6,5] if after reversing some portion...
2b6315a9c117156389761fb6d25ec1d375ed9d1b
kelpasa/Code_Wars_Python
/5 кю/Human Readable Time.py
690
4.15625
4
''' Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS) HH = hours, padded to 2 digits, range: 00 - 99 MM = minutes, padded to 2 digits, range: 00 - 59 SS = seconds, padded to 2 digits, range: 00 - 59 The maximum time never exceeds 359999 (...
f67afbb5da9f57dd033101e6b219a495e466b392
kelpasa/Code_Wars_Python
/6 кю/Duplicate Arguments.py
584
4.25
4
''' Complete the solution so that it returns true if it contains any duplicate argument values. Any number of arguments may be passed into the function. The array values passed in will only be strings or numbers. The only valid return values are true and false. Examples: solution(1, 2, 3) --> false solu...
43b73b103585e836ed8ae216ad0cae6e818c955b
vengadam2001/python
/classnotes.py
7,963
4.09375
4
''''#write a python programme to get a number if the number is <than 10 then add 5 n=int(input("enter a number")) if(n<10): n+=5 print(f"the num is{n}") else: print("the number is:",n)''' '''.................................................................................................................
9861a8caa697d165386a71ea3aaff17634f1bb7c
vengadam2001/python
/plural.py
1,167
3.71875
4
import re str1= input("enter a word") if re.search(r'[aeiou]y$',str1): str1 = re.findall('\w', str1) str1.append('s') elif re.search(r'y$',str1): str1 = re.findall('\w',str1) str1.pop() str1.append("ies") elif re.search(r'f$',str1): str1 = re.findall('\w',str1) str1.pop() str...
684e2a2c55063a62f7081174c647cf2d23efefa1
vengadam2001/python
/seris.py
185
3.8125
4
name= input("") for i in range(0,len(name)-1,1): if(name[i]>name[1+i]): flag=10 break if(flag==0): print("is the seris") else: print("not the seris")
4b10fd502309aa7dfa31b5dac2b342ff1544b19f
vengadam2001/python
/practice1.py
304
3.65625
4
class hello: def __init__(self,name,name1): self.__name=name self.name1=name1 def disp(self): print("from class",self.__name,self.name1) ob=hello("stv","madu") ob.disp() print("from ob",ob.name1) dict={x:x**2 for x in range(int(input())) if x<10} print(dict)
efe66b3d475df2d7b126535c03d20a4b63dc7c80
Bulgakoff/hello_git_31
/qwe.py
1,383
3.703125
4
import random def main(): min_number_of_range = 1 max_number_of_range = 50 puzzle_num = random.randint(min_number_of_range, max_number_of_range) game_guess(puzzle_num, min_number_of_range, max_number_of_range) def game_guess(p_n, minn, maxx): attempts = 0 print(p_n) guess_num = None ...
c0f030b499535de572c0f88c3632127876a131f3
danned/A-Star
/Node.py
1,464
3.53125
4
class Node(object): #predecessor = 0 #x = 0 #y = 0 #f = 0 #g = 0 map = 0 def __init__(self, pre, earning, stack,endNode, action, predictedAction, invested): global endPoint self.predecessor = pre #print type(pre) self.action = action self.stack = stac...
3092940d9f459bd50c769d6f5cf5da791dfdebed
Shubham-gupta007/Pattern-using-python
/Pattern/p13.py
272
3.96875
4
n = int(input("Enter the number: ")) num = str(int(5)) for i in range(n,0,-1): print ('%s' % ((num*i).ljust(n)) + '%s' % ((num*i).rjust(n))) num = str(int(i-1)) for i in range(1,n+1): print ('%s' % ((num*i).ljust(n)) + '%s' % ((num*i).rjust(n))) num = str(int(1)+i)
2e30ebd0bcd7e6418d36995643c8bd02cd728c8e
Shubham-gupta007/Pattern-using-python
/Pattern/p6.py
94
3.921875
4
n = int(input("enter the number:")) c = '*' for i in range(-1,n+1,2): print((c*i).ljust(n))
ffd4fbedc90c91cbd09c1572ed3df6e63949f3ff
tsh/edx_algs202x_graph_algorithms
/4-3_shortest_paths_exchanging_money_optimally_arbitrage.py
1,894
3.5625
4
#Uses python3 import sys from collections import deque def shortet_paths(adj, cost, s, distance, reachable, shortest): distance[s] = 0 reachable[s] = '' # Bellman-Ford for _ in range(len(adj) - 1): for vert in range(len(adj)): for npos in range(len(adj[vert])): nei...
ca4772c00ec1785d8dfc2c1498b27339b2fa61ad
arechesk/PythonHW
/Lesson 3/task4.py
465
3.5
4
import xml.etree.ElementTree as ET a = '<root><element1 /><element2 /><element3><element4 /></element3></root>' def foo(xml, level=-1, depth=[0]): root = ET.fromstring(xml) if len(list(root)) == 0: depth.append(level+1) return {'name':root.tag, 'children':[]}, max(depth) else: ret...
2b05526cb0411055143d33a24a01043fba2f9419
arechesk/PythonHW
/Lesson 7/task1.py
602
3.65625
4
from functools import wraps from time import time, sleep def average_time(func=None, *, n=2): if func is None: return lambda f: average_time(f, n=n) cache = [] @wraps(func) def inner(*args, **kwargs): start = time() result = func(*args, **kwargs) cache.append(time()-sta...
9d25f6ebdcbef1d2a0a57cfb0659412ac6730d0f
nkbkassas/snowflake
/lexer.py
4,392
3.59375
4
from lexeme import * class Lexer: def __init__(self,filename): self.tokens = [] self.filename = filename self.readFile = False self.currentCh = self.generateCh() self.saved = None self.linenum = 0 self.colnum = 0 #Generate characters one by one d...
b3f45a8d760e5425a7ca72d5da43e7dea647db5d
eligiuz/Curso_Python
/practicas_bucles.py
669
4.09375
4
#-- Utilizados con for y while #-- continue: Salta las instrucciones que se encuentren bajo y va ala siguiente vuelta del bucle #-- Sintaxis # for letra in "Python": # if letra=="h": # continue # print("Viendo la letra: " + letra) # #-- Uso de continue busca las letras de un texto -- # nombre="Pild...
2d40bf4dba925bf5a846e7fd859f390fe5046b07
eligiuz/Curso_Python
/practica_for.py
1,217
4.1875
4
# for i in ["primavera","verano","otoño","invierno"]: # print(i) #-- imprime en una linea con un espacio por pase de for # for i in ["Pildoras", "Informativas", 3]: # print("Hola",end=" ") #-- Revisa si se encuentra la @ en el email -- # contador=0 # miEmail=input("Introduce tu dirección de email: ") # for...
2dfb7054f018df2fcad749deb6c1a90d895c43e5
Justinandjohnson/Python
/tree.py
927
3.703125
4
import math from io import StringIO def show_tree(tree, total_width=60, fill=' '): """Pretty-print a tree. total_width depends on your input size""" output = StringIO() last_row = -1 for i, n in enumerate(tree): if i: row = int(math.floor(math.log(i+1, 2))) else: ...
e7d1dc715eb03a04c3063b00b164efe4b59abf34
Justinandjohnson/Python
/abc.py
700
3.515625
4
import heapq from collections import Counter def reorganizeString(S): ctr = Counter(S) heap = [(-value, key) for key, value in ctr.items()] heapq.heapify(heap) if (-heap[0][0]) * 2 > len(S) + 1: return "" ans = [] while len(heap) >= 2: nct1, char1 = heapq.heappop(heap) ...
6f1a4d0b030332efe3a14553900e3f13ef294fda
moh-amiri/contacts_django
/TutorialFiles/test.py
107
3.640625
4
list=[1,2,3,4,5] list.append(6) print(list) tuple=(1,2,3) dic={'key1':'A','key2':'B'} print(dic['key1'])
421b1232a36a6718cce0560efee1260a906f84fb
miguel-nascimento/coding-challenges-stuffs
/project-euler/004 - Largest palindrome product.py
375
4.1875
4
# Find the largest palindrome made from the product of two 3-digit numbers. # A palindromic number reads the same both ways def three_digits_palindome(): answer = max(i * j for i in range(100, 1000) for j in range(100, 1000) if str(i * j) == str(i * j)[:: -1]) ...
c3091271e3921026c03bcf19df2aa9a87866b9d8
pythonmentor/paul-henri-p5
/categories.py
406
3.734375
4
"""This file contains everything related to the categories""" from product import productlist """"Create an object Category with an id and a name as attributes""" class Category: def __init__(self, id, name): self.id = id self.name = name #get the names for the categories def get_name...
ff715e70c4127931a699851802fc999d816be325
IyappanSamiraj/black.pro
/Ps11f2.py
75
3.59375
4
n=int(input()) m=n-1 sum=0 for i in range(1,m+1): sum=sum+i print(sum)
d4b222d1bdf34f95f17fee76e61676c0d60bc5fb
jrkoval/python_class
/overloading.py
656
3.875
4
def add(a,b): return a + b #python supports dynamic typing print(add(20,30)) print(add(3.14,2.25)) print(add('perl', 'python')) #compiler does syntax and grammar check and translates to some other #every function in python is runtime polymorphic # this is called type overloading #Next length overloading #C++ has...
e66e63f944a253e5f2d72fcb5b7a7773279333bc
joanneting/python-practice
/compareInt.py
282
3.765625
4
print("請輸入三個整數") F= int(input("請輸入第一個整數 : ")) S= int(input("請輸入第二個整數 : ")) T= int(input("請輸入第三個整數 : ")) if F > S : F, S = S, F if F > T : F, T = T, F if S > T : S, T = T, S print(f'{F}<{S}<{T}')
b493e27cfa8cebe1564932b902a245ac8f699805
aggeor/CryptographyCourseProjects
/AffineDecryption.py
993
3.84375
4
#!/usr/bin/python import string alphabet = string.ascii_uppercase ciphertext = "Hflyy Lqtuw jel hfy Yxdyt-mqtuw stnyl hfy wmk, Wydyt jel hfy Noglj-xelnw qt hfyql fgxxw ej whety, Tqty jel Ielhgx Iyt neeiyn he nqy, Ety jel hfy Nglm Xeln et fqw nglm hflety Qt hfy Xgtn ej Ielnel ofyly hfy Wfgneow xqy. Ety Lqtu he ls...
c3428c43aabfec70798967a4b884a152822d662f
georggoetz/hackerrank-py
/Python/Regex and Parsing/hex_color_code.py
220
3.78125
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/hex-color-code import re for i in range(int(input())): m = re.findall(r'[^#]+(#(?:[A-f0-9]{3}){1,2})', input()) if m: print('\n'.join(m))
5b8e27ec4b77709a2a9a8a685859c89e21df7098
georggoetz/hackerrank-py
/Python/Sets/set_mutations.py
513
3.765625
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/py-set-mutations n = int(input()) a = set(map(int, input().split())) for _ in range(int(input())): op = input().split()[0] s = set(map(int, input().split())) if op == 'intersection_update': a.intersection_update(s) elif op == 'symm...
0b522233ef6c044190d2a0135a362598f4ec163b
georggoetz/hackerrank-py
/Algorithm/Implementation/taum_and_bday.py
400
3.671875
4
# http://www.hackerrank.com/challenges/taum-and-bday def taumBday(b, w, x, y, z): x = min(x, y + z) y = min(y, x + z) return b*x + w*y if __name__ == "__main__": t = int(input().strip()) for _ in range(t): b, w = map(int, input().strip().split(' ')) x, y, z = map(int, input().str...
c384368a0c87e4d37e54caedb54a8471d43a09a3
georggoetz/hackerrank-py
/Algorithm/Implementation/kangaroo.py
299
3.734375
4
# http://www.hackerrank.com/challenges/kangaroo def kangaroo(x1, v1, x2, v2): return 'NO' if v1 <= v2 or abs(x1-x2) % abs(v1-v2) != 0 else 'YES' x1, v1, x2, v2 = input().strip().split(' ') x1, v1, x2, v2 = [int(x1), int(v1), int(x2), int(v2)] result = kangaroo(x1, v1, x2, v2) print(result)
bfe2009573dba0c3855fbd8a4a8400474e9f1664
georggoetz/hackerrank-py
/Algorithm/Strings/strong_password.py
624
3.640625
4
# http://www.hackerrank.com/challenges/strong-password n = int(input()) pw = list(input()) specials = '!@#$%^&*()-+' has_digit = False has_lower_char = False has_upper_char = False has_special = False for c in pw: if c.isdigit(): has_digit = True elif c.isalpha() and c.islower(): has_lower_char...
7afd0c6d2f0df7cb933002f295962cbb8c5db612
georggoetz/hackerrank-py
/Algorithm/Strings/hackerrank_in_a_string.py
284
3.59375
4
# http://www.hackerrank.com/challenges/hackerrank-in-a-string q = int(input()) w = 'hackerrank' for _ in range(q): s = input() j = 0 for c in s: if j == len(w): break if c == w[j]: j += 1 print('YES' if j == len(w) else 'NO')
51d8d1e957a189e77167816d87890530f84d64d1
georggoetz/hackerrank-py
/Algorithm/Strings/camel_case.py
150
3.703125
4
# http://www.hackerrank.com/challenges/camelcase s = list(input().strip()) count = 1 for c in s: if c.isupper(): count += 1 print(count)
6a879dbcf0bf03f503a0a148076886b126043052
georggoetz/hackerrank-py
/Algorithm/Implementation/drawing_book.py
299
3.5625
4
# http://www.hackerrank.com/challenges/drawing-book def solve(n, p): if n % 2 == 0: n += 1 if p % 2 == 0: return min(p // 2, (n - p - 1) // 2) return min((p - 1) // 2, (n - p) // 2) n = int(input().strip()) p = int(input().strip()) result = solve(n, p) print(result)
db159e564d747ca44701258853e0ad7fa30756ef
georggoetz/hackerrank-py
/Python/Numpy/concatenate.py
286
3.59375
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/np-concatenate import numpy n, m, _ = map(int, input().split()) a = numpy.array([input().split() for _ in range(n)], int) b = numpy.array([input().split() for _ in range(m)], int) print(numpy.concatenate((a, b), axis=0))
2aaa6f457d11582b98da3d3bc218e69abb17ba5f
georggoetz/hackerrank-py
/Python/Strings/alphabet_rangoli.py
533
3.59375
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/alphabet-rangoli/problem def print_rangoli(size): if size <= 1: print('a') return n = 4*(size-1) + 1 a = [] for i in range(size-1, -1, -1): s = chr(ord('a') + i) for j in range(i+1, size): c = c...
248be7d4adbd1c6623db054a0350e5b7753c63ed
georggoetz/hackerrank-py
/Python/Collections/collections_deque.py
410
3.90625
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/py-collections-deque from collections import deque a = deque() for _ in range(int(input())): op = input().split() if (op[0] == 'append'): a.append(op[1]) elif (op[0] == 'appendleft'): a.appendleft(op[1]) elif (op[0] == 'pop...
28bee6f52db0f416dd797d93e66ce33e73b6f5c0
georggoetz/hackerrank-py
/Python/Strings/find_a_string.py
457
4.0625
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/find-a-string def count_substring(string, sub_string): start = num = 0 while start >= 0: pos = string.find(sub_string, start) if pos < 0: break num += 1 start = pos+1 return num if __name__ == '__...
391a6781a0b7e7a6388c737c52c86f1b512379d9
georggoetz/hackerrank-py
/Python/Regex and Parsing/re_start_end.py
263
3.65625
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/re-start-re-end import re s = input() k = input() p = re.compile('(?=(' + k + '))') if p.search(s): print(*[(m.start(1), m.end(1)-1) for m in p.finditer(s)], sep='\n') else: print((-1, -1))
3ce089735a37f4637807665b6ef3e2ca2ae61829
georggoetz/hackerrank-py
/Python/Introduction/division.py
262
3.546875
4
# http://www.hackerrank.com/contests/python-tutorial/challenges/python-division def solve(a, b): """ >>> solve(4, 3) 1 1.3333333333333333 """ print(a//b) print(a/b) if __name__ == '__main__': solve(int(input()), int(input()))
2d2e07e012825d709e5550b8d598d618cdb61ad3
ThinhHuynh17/Assignment-2
/Desktop/turtle/early feedback on intro to prog.py
745
3.890625
4
# RMIT University Vietnam # Course: COSC2429 Introduction to Programming # Semester: 2020B # Assignment: 1 # Author: Huynh Hung Thinh (3750559) # Created date: 18/07/2020 # Last modified date: 19/07/2020 # Define turtle and window: import turtle import math rua = turtle.Turtle() rua.shape("classic") rua.speed(20) ...
6d533e446c7e20c59f42bbf779ceb44f9907bcca
ThinhHuynh17/Assignment-2
/Desktop/turtle/Assigment Week 7 task 2.py
1,439
4.09375
4
# RMIT University Vietnam # Course: COSC2429 Introduction to Programming # Semester: 2020B # Assignment: 1 # Author: Huynh Hung Thinh (S3750559) # Created date: 16/08/2020 # Last modified date: 16/08/2020 import turtle import math numbers_input = list(map(float, input("Enter maximum 7 numbers only: ").split())) lis...
236679d32efd3a04c1e840933f6d6cf864e4c2c1
allanfreitas/python-para-zumbis
/TWP272_Vetor2.py
530
4.03125
4
''' Faça um programa que leia um vetor de dez números reais e mostre-os na ordem inversa ''' vetor = [] x = 0 while x < 10: add = float(input("Digite a posição %d: " %x)) x += 1 vetor.append(add) if x == 10: while x <= 10: x -= 1 if x < 0: break else: pri...
a08e4258499780666e6312cf549eb61e5ea76eb8
allanfreitas/python-para-zumbis
/TWP274_Media4notas.py
613
3.84375
4
''' Faça um programa que leia um vetor de 10 caracteres minúsculos, e diga quantas consoantes foram lidas. ''' caract=[] vogais=["a","e","i","o","u"] contvogal = 0 x = 1 while x <= 10: entrada = input("Caractere %d: " %x) x += 1 caract.append(entrada) if entrada in vogais: contvogal += 1 print ...
7b920239e036136b161b7c59df64ba47ee31187d
allanfreitas/python-para-zumbis
/Lista 2/questao04.py
572
4
4
n1=int(input('1º número: ')) n2=int(input('2º número: ')) n3=int(input('3º número: ')) if n1 > n2: if n1 > n3: print('O maior número é %d' %n1) else: print('O maior número é %d' %n3) elif n2 > n3: print('O maior número é %d' %n2) else: print('O maior número é %d' %n3) ''' Como Foi reso...
4103c1db15e40cf81239f76d0e904c09254ff29c
allanfreitas/python-para-zumbis
/Lista 3 Desafios/questao04.py
495
3.890625
4
''' Dado um número inteiro positivo, determine a sua decomposição em fatores primos calculando também a multiplicidade de cada fator. ''' n = int(input('Entre com o número: ')) divisores = [] d = 2 while n > 1: if n%d == 0: n = n/d divisores.append(d) else: d += 1 print ("Estes são o...
e963b612403311a49c37ee61c0a95f51c1e12b6e
allanfreitas/python-para-zumbis
/Lista 3 Desafios/questao02.py
2,749
3.859375
4
''' Indique como um troco deve ser dado utilizando-se um número mínimo de notas. Seu algoritmo deve ler o valor da conta a ser paga e o valor do pagamento efetuado desprezando os centavos. Suponha que as notas para troco sejam as de 50, 20, 10, 5, 2 e 1 reais, e que nenhuma delas esteja em falta no caixa. ''' '''Prim...
781f933c31978cb1d11fab33b22375caf9a7ceb3
allanfreitas/python-para-zumbis
/Lista 4/questao04.py
1,514
4
4
''' 4. Seja o statement sobre diversidade: “The Python Software Foundation and the global Python community welcome and encourage participation by everyone. Our community is based on mutual respect, tolerance, and encouragement, and we are working to help each other live up to these principles. We want our community to ...
ccb54ffe4c0f80352d10a1d05f62e0dfeea1fb62
allanfreitas/python-para-zumbis
/TWP210_Inteiros_ate_um_fim.py
119
3.8125
4
n_user=int(input('Entre com o número: ')) x = 0 while x <= n_user: if x % 2 == 0: print(x) x = x +1
c7bcf3d78220f0499473be5c38df3e64f2ed64fa
Jill1627/lc-notes
/KthLargestElementinArray.py
1,587
3.609375
4
# LC215 Kth largest Element in an Array """ Solution 1: time - O(NlogN) space O(1) sort first and find [k]""" class Solution(object): def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ nums = sorted(nums) return nums[len...
003241fd15b6ad7c5aa10e35a4f310ed6f517688
Jill1627/lc-notes
/mergeSortArray.py
755
3.875
4
""" Merge sort array """ def mergeSort(self, nums): if nums is None or len(nums) == 0: return nums return self.divideThenMerge(0, len(nums) - 1, nums) def divideThenMerge(self, start, end, nums): if start >= end: return list(nums[start]) mid = start + (end - start) / 2 left = self....
d322f50dcbc3ee8bef6c33a8218b2cb0db2f2570
Jill1627/lc-notes
/serialANDdeserialBT.py
1,658
3.75
4
""" LC. 297 Serialize and Deserialize Binary Tree Strategy: from tree to string, and from string to tree """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Code...
ffea9058418df133f7857d1b4c5e7122d0cf03df
Jill1627/lc-notes
/longestConsecutiveSequence.py
2,360
3.53125
4
"""LC128 Longest Consecutive Sequence - #array, #hashmap 2 solutions: use hashmap or hashset Solution 1: Idea: use a hashmap<unique num : max sequence length containing this num, if it's at boundary> Steps: 1. Initialize: maxLen, and hashmap 2. Loop each num in nums, only considers unique ones, skip num already in h...
51d58925c320d572d2367334ffb3b7ec98250f91
Jill1627/lc-notes
/moveZeroes.py
687
3.65625
4
# LC283 FB """ Two pointers Problem desc: move all zeroes to the left while maintaiing original order of non-zeroes Idea: use a variable to mark the left boundary of all zeroes loop through, enoucnter a non-zero: swap with boundary """ class Solution(object): def moveZeroes(self, nums): """ :type n...
a8fd2028ef7c978b0c5278d830a89ef28aa22eb5
Jill1627/lc-notes
/longestCommonPrefix.py
832
3.5
4
#LC14 class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if not strs or len(strs) == 0: return "" pre = strs[0] for i in range(len(strs)): while strs[i].find(pre) != 0: ...
3ac6e6e8f13030e0d72283035673efe0ac9cb7b8
Jill1627/lc-notes
/nextRightPointersTree.py
792
3.828125
4
""" LC116 """ # Definition for binary tree with next pointer. # class TreeLinkNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # self.next = None class Solution: # @param root, a tree link node # @return nothing def connect(self, root...
77cc2ae93f57660813b615936e2e540d6472fe94
Jill1627/lc-notes
/quickSort.py
205
3.765625
4
""" Quick Sort """ def quickSort(self, nums): toSort = list(nums) if nums is None or len(nums) == 0: return nums sortRange(0, len(nums), toSort) def sortRange(start, last, nums):
e08e7708001b65349f35dd3ad28c290781755c96
Jill1627/lc-notes
/maximalSquare.py
1,904
3.5625
4
""" LC 221 Maximal square Idea: DP function definition: dp[i][j] = max square side length ending at matrix[i][j] Steps: 1. initialize a 2d matrix dp[m + 1][n + 1], a variable maxLen max length of square side 2. loop, whenever encountering a '1', dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1, as the...
c69dfe77cb4343285570095edd99c5b0e630f913
Jill1627/lc-notes
/insertDeleteGetRandom.py
2,301
3.71875
4
""" LC 380 Insert delete getRandom Idea: use ArrayList and hashmap To guarantee O(1) operation, remove the last element all the time, swap if not Steps: 1. initialize the data structure with an ArrayList nums, and a HashMap indexMap, indexMap = [num : its index in nums], initially 2. insert operation, check if it's al...
36d4781dc9fe9f8e998b961cab74d3368f9921b1
Jill1627/lc-notes
/populateRightNextPointers.py
912
3.984375
4
""" LC.116 Populating Next Right Pointers in Each node Strategy: use two pointers: pre and curr pre - iterate all leftmost nodes of each level curr - iterate all nodes on a level """ # Definition for binary tree with next pointer. # class TreeLinkNode: # def __init__(self, x): # self.val = x # self...
0c240dc233f789d84b520990af063cb5b991a11b
Jill1627/lc-notes
/countAndSay.py
1,173
3.671875
4
""" 问题:输出第n位count and say sequence - 注意count and say sequence的生成方式 思路:递归,算法设计如何从n-1到n 1. 考虑n=0,1的特殊情况 2. 初始:res, count = 1, prev = self.countAndSay(n - 1),还有prevNum 3. 在loop中,考察当前i(curNum)与prevNum的关系,更新count 4. 如果当前位与前一位相等,只需要count++ 5. 如果当前位与前一位不等,更新答案,同时:reset count = 1,preNum = curNum 6. 最后一步,还要将prevNum加入答案 完成 """ c...
66f623ba589eaac2c61125b4dd9aa65c9dbf5712
Jill1627/lc-notes
/letterCombo.py
1,706
3.546875
4
""" 题目:LC17: 根据电话数字字符串,输出所有字母组合 思路:三个For循环,依次为,每一个数字,每一个数字相对应的字母,如果答案已有内容,每一个答案elem 1. 初始化chars list包含所有字母组,res记录答案 2. 循环每一个数字时:用num存储,temp暂存目前答案 3. 循环每一个字母时:看答案是否有内容,如无,直接加入temp 4. 如果已有内容,要循环每一个现有答案elem,逐个加入当前字母 5. 最终,将temp替换成答案 完成 """ """Later solution, easier to understand """ class Solution(object): def letter...
c78e8325f41d8ea62a94dafbd36654bc1a072532
Jill1627/lc-notes
/findTheCelebrity.py
891
3.515625
4
""" LC.277 Find the celebrity Strategy: two pass 1 pass: identify a celebrity candidate 2 pass: verify the celebrity candidate """ # The knows API is already defined for you. # @param a, person a # @param b, person b # @return a boolean, whether a knows b # def knows(a, b): class Solution(object): def findCelebri...
ec3b70ddcc2be1343cc1dc6abe03a24cd7cb77fd
mindcandyy/CP3-Yada-Klueabvichit
/Exercise8_Yada_K.py
452
3.828125
4
usernameInput = input("Username: ") passwordInput = input("Password: ") if usernameInput=="mind" and passwordInput=="1234": print("Welcome Mind") print("----Shop---") print("1.Water 5baht") print("2.Milk 10baht") userselected = int(input(">>")) quantity = int(input("quantity: ")) if...
67cb74c1d63c526850307c195396ceeee4525a3d
evelyn-pardo/actividad-de-clases
/def.py
376
3.78125
4
"""funcion sin retorno """ def vocales (frase): for car in frase: if car in ('a','e','i','o','u'): print (car) """llamada funcion """ oracion = input('ingrese oracion:') vocales(oracion.lower()) """llamada funcion """ def promedio (notas): summ=0 for n in no...
4aef3e9c439bc78c0de034650e260cf98b6b5ee3
evelyn-pardo/actividad-de-clases
/condicion.py
1,372
4.1875
4
class Condicion: def _init_(self,num1,num2): self.numero1=num1 self.numero2=num2 numero = self.numero1+self.numero2 self.numero3=numero def __init__(self,num1,num2): self.numero1=num1 self.numero2=num2 numer...
d3d1778fb92c9e1bd8c3626b0f5ce9680cc44230
brfulu/foo-lang-compiler
/src/test-samples/zad11.py
326
3.65625
4
def is_sorted(arr = []): result = False result = True i = 0 i = 1 while (i < len(arr)): if (arr[i] < arr[(i - 1)]): result = False i += 1 return result n = 0 n = int(input()) x = [] i = 0 i = 0 while (i < n): num = 0 num = int(input()) x.append(num) i += 1 result = False result = is_sorted(x) print(re...
a5df8cb2afb5efe94940a68cd09772b67958b42c
brfulu/foo-lang-compiler
/src/test-samples/zad6.py
300
3.578125
4
import math result = [] x = 0 x = int(input()) while (x >= 0): temp = 0 temp = int(math.sqrt(x)) if ((temp * temp) == x): result.append(x) x = int(input()) output = '' i = 0 i = 0 while (i < len(result)): output = (output + (str(result[i]) + ', ')) i += 1 print('Perfect squares:', output)