blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b56d7644d444a7e7cbb27fe8d6b673debf915e24
vegetablebird6/Algorithm_Homework
/maze.py
4,237
3.546875
4
import copy import turtle import random rows = 5 cols = 5 # 行和列 num_rows = rows * 2 + 1 num_cols = cols * 2 + 1 # 初始化迷宫(0是路,1是墙) def init(): i, j = 0, 0 status = [[[False for _ in range(4)] for _ in range(cols)] for _ in range(rows)] visited = [[False for _ in range(cols)] for _ in range(rows)] sta...
8d4a8c329d089ffb830b594ceba17f23175ec406
preetising/if_else
/leap-year.py
224
4.125
4
year=int(input("enter the year")) if year%4==0: if year%100==0: if year%400==0: print("it is leap year") else: print("it is century leap year") else: print("it is century year") else: print("it is leap year")
b18da02a43b9fbd71e552aad83f258818fac1148
ceacar/albert_practice
/exercise2.py
1,250
4.1875
4
#fill lthe function named character_classifier which will accepts a sentence and calculate the number of letters and digits. #example input: #hello world! 123 #example output: #LETTERS 10 #DIGITS 3 def character_classifier(s): d=l=0 for c in s: if c.isdigit(): d=d+1 elif...
50eeaaf8add1705bf4262f49655d4fc64bb20333
Huzo/AVL_Tree
/avl_tree.py
7,806
3.921875
4
class Node(object): # our node for the tree def __init__(self, value): self.value = value self.right = None self.left = None self.parent = None self.height = 1 self.rh = 0 self.lh = 0 self.rh_minus_lh = self.rh - self.lh class Tree(object): # ...
b0b228e4add3c363caa2db66abd444284a6d15e6
NathiyaM/PYTHON
/HackerRankSolutions/HashTable.py
1,180
3.703125
4
class HashTable: def __init__(self,size): self.size = size self.slots = [None]*self.size self.data = [None]*self.size def put(self,key,data): hashvalue = self.hashfunction(key,self.size) if self.slots[hashvalue] == None: self.slots[hashvalue] = key ...
482d92e1f376201241d5c191d0853da54a0944e9
RealAbsurdity/CP_PHCR
/01_digitalio_DigitalOut/03_basic_PWM.py
526
3.640625
4
# import modules import time import board import pulseio # make a led object with pulseio.PWMOut on pin board.A1 led = pulseio.PWMOut(board.A1, duty_cycle=0) """ pulseio.PWMOut creates a PWMOut object with the name led you can set the duty_cycle with the property led.duty_cycle led.duty_cycle accepts a 16-bit integ...
f59b299d928afc183c64d5545d90892b0c719d69
mmmaaaggg/RefUtils
/src/fh_tools/language_test/DesignPatternTest/strategy_pattern_test.py
920
3.734375
4
# -*- coding: utf-8 -*- """ 参见流畅的python P281 策略模式 Created on 2017/9/29 @author: MG """ from abc import ABC, abstractmethod class Promotion(ABC): # 策略:抽象基类 @abstractmethod def discount(self, order): """ 折扣""" class FidelityPromo(Promotion): # 第一个具体策略 """为积分为1000或以上的顾客提供5%折扣""" ...
9c337d8cd65ee9f2aea763f443099cb63c4f9673
mogreen2063/momega
/resume_decode.py
518
3.875
4
import binascii import sys def decode(str): temp_string = binascii.unhexlify(str) temp_string = temp_string.decode("utf-8") return temp_string def encode(str): temp_string = "" for c in str: temp_string += "{:x}".format(ord(c)) return temp_string def main(): ...
2fd4f5b5710ee8e01b1cc2a31c4f2f221b1ae8d0
Eurus-Holmes/LCED
/Perfect Squares.py
411
3.625
4
class Solution(object): def numSquares(self, n): """ :type n: int :rtype: int """ while n%4 == 0: n /= 4 if n%8 == 7: return 4 a = 0 while a*a <= n: b = int(math.sqrt(n - a*a)) if a*a + b*b == n: ...
f4f7bdd7a0bc12f0d4b89438eff46fae3c28f459
syurskyi/Python_Topics
/115_testing/examples/Github/_Level_1/unittestexamples-master(1)/unittestexamples-master/test_phonebook.py
2,381
3.71875
4
import unittest from phonebook import PhoneBook # Test runner: >python3 -m unittest -v # Test Suite class PhoneBookTest(unittest.TestCase): # Test fixture def setUp(self): self.phonebook = PhoneBook() # Test fixture # Tear down resources that were initialized in setUp def tearDown(self): ...
6b6bf01052dd6ad5d74839dda8ed98ecfab4bc7e
TobiahRex/computerScience
/algorithms/cracking-coding-interview/python/cciLinkedListLoop.py
1,422
3.96875
4
''' Cyclic Detection A linked list is said to contain a cycle if any node is visited more than once while traversing the list. Complete the function provided in the editor below. It has one parameter: a pointer to a Node object named that points to the head of a linked list. Your func...
b33572ea8e0d84e12f2e37c38390c5db54f760c6
oamam/atcoder
/abc/65/A.py
183
3.625
4
def main(): X, A, B = map(int, input().split()) if A >= B: print('delicious') elif A + X >= B: print('safe') else: print('dangerous') main()
010caccf6823750993e3b8ed8fb5d96ce468cdb4
aKrishnan0817/ScheduleApp
/helper.py
781
3.75
4
from datetime import datetime from dictionary import * def time(): dayOfWeek = int(datetime.today().weekday()) daysLst = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'] dayOfWeek = daysLst[dayOfWeek] ct = datetime.now().hour*60+datetime.now().minute period = 1 #find the...
bd8d1d8e28628cb8f5fe4720febd382d807d7115
MaxwellVale/CS01
/lab5/lab5_ab.py
6,639
4.5
4
# Maxwell Vale # CS01 Section 1a # Assignment 5 import math # Part A: Exercises # Ex A.1 class Point(): ''' Class Point A class representing a point in three-dimensional Euclidean space (x, y, z). Methods distanceTo ''' def __init__(self, x, y, z): ''' Initializing a Poin...
644e43279273fe2c40b0db2722e3f7bf0f1b6b65
rafi80/UdacityIntroToComputerScience
/lesson4/speed_fraction.py
669
3.875
4
# Write a procedure, speed_fraction, which takes as its inputs the result of # a traceroute (in ms) and distance (in km) between two points. It should # return the speed the data travels as a decimal fraction of the speed of # light. speed_of_light = 300000. # km per second def speed_fraction(trace_route_time, physi...
1cc5b320c716725fd13b83232271d8a0c3d124f2
brookslybrand/CS303E
/Random/practice.py
696
3.671875
4
def main(): ''' # init num num = 0; num_largest = 0; num_s_largest = 0; # keep prompting for num until num == -1 while(num != -1): num = int(input("Enter a number (-1 to cancel): ")) if(num > num_largest): num_s_largest = num_largest num_largest = num print(num_s_largest, "is the...
11b03ef79df3fafc15cb83c9bd1be9a0292d6101
ilovecoffeeeee/python
/dayoffCalender/dayoff.py
661
3.734375
4
holiday = {'lee': ['0707', '0718', '0815'], 'kim': [ '0815', '1211', '1215', '1225'], 'park': ['0322', '0718', '0815', '1225']} def day_off(person_date): people = [] dates = [] for person, date in person_date.items(): people.append(person) dates = dates + date date_person = {} ...
284ac9bfbf2e3ba05dfb09a7d96af42879270d6e
Rudra-Patil/Programming-Exercises
/HackerRank/Python/Regex and Parsing/Group(), Groups() & Groupdict()/solution.py
110
3.5
4
import re line = input() match = re.search(r'([a-zA-Z0-9])\1+', line) print(match.group(1) if match else -1)
15d3c3510b96b00dfe1f19b1c41234882f5d9404
aidancmatthews99/cp1404practicals
/prac_01/shop_calculator.py
497
3.890625
4
number_items = int(input("Number of items: ")) total = 0.00 item_price = 0.00 while number_items <= 0: number_items = int(input("Invalid number of items! \nNumber of items: ")) for i in range(0, number_items): item_price = int(input("Price of item: ")) while item_price < 0: item_price = int(input...
cd7ece94de6a18be48389a939724486a62d1a0f5
taiga4112/pDESy
/pDESy/model/organization.py
980
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from .base_organization import BaseOrganization from .base_team import BaseTeam from typing import List class Organization(BaseOrganization): """Organization Organization class for expressing organization in target project. This class is implemented from Base...
0b85d3edf498f56fdf00482b67270a8f27479bb6
zjuzpz/Algorithms
/LowestCommonAncestorOfABinarySearchTree.py
2,189
3.625
4
""" 235. Lowest Common Ancestor of a Binary Search Tree Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w ...
de5b462856e486013b87fe32c0f0f2dcc8f3e87f
Minaksh1012/dictionary
/que7 unique no.py
689
3.84375
4
# [ # {"first":"1"}, # {"second": "2"}, # {"third": "1"}, # {"four": "5"}, # {"five":"5"}, # {"six":"9"}, # {"seven":"7"} # ] # Output :- # [2', '7', '9', '5', '1'] list1=[ {"first":"1"}, {"second": "2"}, {"third": "1"}, {"four": "5"}, {"five":"5"}, {"six":"9...
4a436864856819e3ec08e6eb8f40dbaa31562258
paulosuchoj/tic-tac-py
/tic_tac_toe.py
6,852
4.25
4
import random player_choice = '' computer_choice = '' game_won = False def start_game(): global player_choice, computer_choice print('Welcome to Tic-Tac-Toe!') while True: try: player_choice = input('Do you want to be O or X?\n') except ValueError: print('''Sorry...
ddc78d5d3776f38a06754bea024cb3841b8a5e87
souza-joao/cursoemvideo-python3
/016.py
114
3.75
4
n = float(input('Mostre um número real qualquer: ')) print('A porção inteira de {} é {}. '.format(n, int(n)))
8e584482d93b14e844a7a8c9526c1823a484a160
Runsheng/rosalind
/IPRB.py
1,178
3.59375
4
#!/usr/bin/env python ''' Rosalind ID: IPRB Problem Title: Introduction to Mendelian Inheritance URL: http://rosalind.info/problems/iprb/ 2016/04/07, runsheng ''' def dom_prob(k,m,n): """ 3 positive integers k, m, and n, representing a population containing k+m+nk+m+n organisms :param k: k individuals are...
b68a2a5a225fb0c40a7d4e468ce9bb32a48363c8
anjanayraina/Record-Filter-System
/simulation.py
5,192
4.0625
4
# Name - Anjanay Raina # Roll No - 2020494 import a2d as a import json ''' - This is the skeleton code, wherein you have to write the logic for each of the functions defined below. - DO NOT modify/delete the given functions. - DO NOT import any python libraries. You may only import a2.py. - Make sure ...
ebebfeb43ac3a3d202bc8c0d0a6e82bbb88195d8
LazyerIJ/Algorithm
/Problem/BakJoon/bj_2839.py
232
3.8125
4
weight = int(input()) temp=True num5 = weight//5 left5 = weight%5 while num5>=0: if left5%3 ==0: print(num5+left5//3,end='') temp=False break num5 -=1 left5 += 5 if temp: print(-1,end='')
7d358b503f03be0d3cef6f11f447ee8ad533cab9
VaVoose/ProgrammingLanguage
/testMain.py
1,938
3.96875
4
""" testMain.py _ Dominic Ferrante - Brian Rexroth - Drew Battison Python Lexer Class Dr. Al-Haj ECCS 4411 - Programming Languages Main file for testing the lexer and associated functions Requirements: 1. Read an input file and output all tokens a. Input file name is given as an ar...
b97b9f15d2cd927f796daa10ebcab9c0655c3186
KnightUA/PythonLabs
/Lab2/Level3.py
853
4.09375
4
from math import sqrt def string_to_number_list(input): is_correct_data = True items = input.split(",") for j in range(len(items)): try: items[j] = int(items[j]) except (ValueError, NameError): is_correct_data = False break if not is_correct_data: ...
ee96a7dfea3fc10d5e54b8847eec5a48d43a6e67
jlpalardy/Exercism
/matrix/matrix.py
794
3.703125
4
class Matrix: def __init__(self, matrix_string): self.matrix2D = [[int(x) for x in row.split()] for row in matrix_string.split('\n')] #The following checks to make sure that the rows are all the same #length- if they're not, that indicates that there are some column #lengths that are different than others (...
4c54e72a6913c6e551ca4ad65fbfc602b1a90abb
infigenie/pygsp
/pygsp/filters/gabor.py
3,450
3.65625
4
# -*- coding: utf-8 -*- from pygsp import utils from . import Filter # prevent circular import in Python < 3.5 class Gabor(Filter): r"""Design a filter bank with a kernel centered at each frequency. Design a filter bank from translated versions of a mother filter. The mother filter is translated to eac...
51f3cc9fd2c4a05c0f1d465197a49d2e2a5bc4e2
madeibao/PythonAlgorithm
/PartC/Py冤家数字的解法.py
728
3.734375
4
# 所谓冤家数字,指的就是由仅仅由两个数字组合称的数字,按照从小到大的顺序进行排列。 例如 2与4组成的冤家数字。 [2, 4, 22, 24, 42, 44, 222, 224, 242, 244, 422, 424, 442, 444, 2222, 2224, 2242, 2244, 2422, 2424, 2442, 2444, 4222, 4224, 4242, 4244, 4422, 4424, 4442, 4444] import itertools import functools print("请输入两个数字") a, b = map(int, input().split(",")) str2 = s...
bde22ca20bf1b0becfd02ddd320928136db1b510
dasherinuk/classwork
/2020-11-21_control/agrigate.py
215
3.59375
4
# 1 2 3 4 5 6 7 8 9 # 1 3 6 10 15 21 28 36 45 array=[int(k) for k in input("Enter your elements:").split()] len_array=len(array) for i in range(1,len_array): array[i]=array[i-1] + array[i] print(array)
126134d226676245c30fb06e8b124f3a82f70911
jan-pfr/dive-into-pyhton3
/sba06.py
1,431
3.78125
4
import math V = lambda a , b , c : a * b * c * (1 / 3) #Berechnung des Volumens der Pyramide mit einer Lamda-Funktion def funcdo( l, b, h): #Definition einer Funktion zum Berechnen der Diagonalen und...
510281f929445df64911cc6eb8bb4c43a42b1402
jazib-mahmood-attainu/Ambedkar_Batch
/W6D2_Recursion/rec.py
108
3.6875
4
def add(a,b): if a>=100: return c = a+b print(c) add(a+1,b) return c add(2,3)
f338e3a8ec7bad9cf0753c2d007dd9e72d197828
JungHyeonKim1/TIL
/algorithm/2월 3주차/부분집합.py
474
3.71875
4
# bit = [0,0,0,0] # # for i in range(2): # bit[0] = i # for j in range(2): # bit[1] = j # for k in range(2): # bit[2] = k # for l in range(2): # bit[3] = l # print(*bit) arr = [1, 2, 3] n = len(arr) for i in range(1<<n): # 2^n 0 ~ 7 ...
ba6bf71353a6ffbf2260911966ad3856d68b6083
canjieChen/LeetCode_for_fun
/lemonade-change.py
2,516
3.671875
4
# coding=utf-8 """ 在柠檬水摊上,每一杯柠檬水的售价为 5 美元。 顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯。 每位顾客只买一杯柠檬水,然后向你付 5 美元、10 美元或 20 美元。你必须给每个顾客正确找零,也就是说净交易是每位顾客向你支付 5 美元。 注意,一开始你手头没有任何零钱。 如果你能给每位顾客正确找零,返回 true ,否则返回 false 。 示例 1: 输入:[5,5,5,10,20] 输出:true 解释: 前 3 位顾客那里,我们按顺序收取 3 张 5 美元的钞票。 第 4 位顾客那里,我们收取一张 10 美元的钞票,并返还 5 美元。 第 5 位顾...
527fef44938434b5f866c81c609892a2089641d8
nagam-mk/GitHUBPractice
/src/fun_tes.py
85
3.6875
4
x=[9,8,2] y=x.remove(2) z=print(1,end=' ') if y or z: print(1) else: print(2)
ba551db1ceaac0f17f4154f8e71a0690c387e4ce
mahmoud-taya/OWS-Mastering_python_course
/Files/125.Advanced_lessons_timing_your_code_with_timeit.py
1,246
3.8125
4
# ------------------------------------------------------ # -- Advanced lessons => timing your code with timeit -- # ------------------------------------------------------ # - timeit - Get execution time of code by running 1M time and give you minimal time # - - It used for performance by testing all functional...
8d6c4213711bc70081c36e33d33a3967ec0eede4
orian71/exercism-exercises
/Python/pangram.py
856
3.90625
4
def is_pangram(sentence): lowercase = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] uppercase = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', ...
92b2773631eb99264903535f0fb518ae61af5213
MatthewWolff/Scraps
/Personal/missing_no.py
2,794
3.734375
4
import math from random import random def to_binary(array): new_array = [] for num in array: new_array.append(Binary(num)) return new_array def make_array(n): array = range(n) array.append(n) return array def remove_number(array): num = select_num(len(array)) removed = arra...
b382e13b4aec07e7fd6717fe45274ad64f0e7d80
georgekaplan59/notebooks
/draw/team.py
870
3.8125
4
class Team: """ Team representation storing club information regarding: - short name - association/country to which the club belongs - group in the previous stage of the Champions League """ def __init__(self, name, country, group): # Constructor self.name = name ...
e64dca0a3d3e6732ee0be1ea0a4fd09c4d91a6ae
pulinghao/LeetCode_Python
/字符串/KMP算法.py
1,273
3.609375
4
#!/usr/bin/env python # _*_coding:utf-8 _*_ """ @Time :2020/8/29 11:40 下午 @Author :pulinghao@baidu.com @File :KMP算法.py.py @Description : """ class Solution: def getNext(self, T): """ 构造next数组 :param T: :return: """ i = 0 j = -1 next_val = [...
c01a1ee37498a74a418576e8ba3d032766e64439
govex/python-lessons-for-gov
/section_10_(dictionaries)/dict_values.py
702
4.59375
5
# If you're new to dictionaries, you might want to start with dict_access.py # We create a dictionary. contacts = { 'Shannon': '202-555-1234', 'Amy': '410-515-3000', 'Jen': '301-600-5555', 'Julie': '202-333-9876' } # We can use the dictionary method .values() to give us a list of all of the values in...
bf0858887f73e01c14446030a272ca8c7ddbd56c
pedromaresteves/flask-web
/projects/unittests/test_roman_numbers.py
5,669
3.5625
4
import unittest from projects.roman import convert_to_roman # IMPORTANT: # All test functions must start with test_ # unittest Assertion Methods: https://docs.python.org/3/library/unittest.html#assert-methods class GuessNumber(unittest.TestCase): @classmethod def setUpClass(cls): # Use setUpClass to r...
a9cefd68ff74910d198188fcadba1feb37726b40
choroba/perlweeklychallenge-club
/challenge-208/sgreen/python/ch-1.py
1,312
4.125
4
#!/usr/bin/env python3 import re import sys def find_index_in_list(array, word): '''Find the index of a word in a list''' for i, w in enumerate(array): if w == word: return i # This word does not appear in the list return None def main(first_list, second_list): # Turn the w...
77632ab16f2295b2fd5c5bc2b3ce701677bbd140
ilkera/EPI
/LinkedList/InterweaveLinkedList/InterweaveLinkedList.py
2,627
3.75
4
# Problem: Interweave linked list # Input: A->B->C->D->E Output: A->E->B->D->C # Node definition class Node: def __init__(self, value, next = None): self.value = value self.next = next # Functions class ListUtils: def interweave(self, list): left, right = self.divideList(list) ...
6ffd089f678eeeebf8d0d8c0f42cc050fa7aab10
Rojinaprajapati/python-today
/loops.py
882
4.1875
4
for i in range(10): print(i) string="hello world" for i in range(0,len(string),2): print(string[i]) j=11 while(j<=10): print(j) j=j+1 set1={1,2,3,4,5,6} set2={2,3,4,5,6,7,8} print (set1) print (set2) set1=set1.union(set2) set1 def function(): return [1,2,3,4] print(function()) #lambda argu...
4926ff9346073e37cd78d1d5a4bceb928724ee23
vishnubalaji1998/guvi2
/sqrt.py
67
3.859375
4
x=int(input("enter no : ")) y=x**(0.5) print("square root : " ,y)
b9258f169c35b0a6f08991bf6e40bcead79cb676
KonstantinSukhorukov/Python
/HW4_Task_5.py
676
4
4
# Реализовать формирование списка, используя функцию range() и возможности генератора. # В список должны войти четные числа от 100 до 1000 (включая границы). # Необходимо получить результат вычисления произведения всех элементов списка. # Подсказка: использовать функцию reduce(). from functools import reduce def umno...
1f0fad5678244a2617f1ef596b9ab8ba596bbf80
todaatsushi/python-data-structures-and-algorithms
/structures/tree.py
2,156
4
4
""" Python implementation of a tree structure - similar to heap. """ class Node: def __init__(self, data, level, left=None, right=None): self.level = level self.data = data self.left = left self.right = right def __repr__(self): return str( { ...
fa651a8e77d4730941b680b6ec3194999fecb390
developyoun/AlgorithmSolve
/solved/20540.py
215
3.65625
4
string = input() result = '' result += 'E' if string[0] == 'I' else 'I' result += 'S' if string[1] == 'N' else 'N' result += 'T' if string[2] == 'F' else 'F' result += 'J' if string[3] == 'P' else 'P' print(result)
6e30c72061f622d5f9b7d6a365f7dd11cc5b491a
alemor10/Resturant-Menu-
/menu.py
2,185
3.515625
4
from tkinter import * class Application(Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.pack() self.create_widgets() #with that, we want to then run init_window, which doesn't yet exist self.init_window() def init_w...
a7175c26c27772dc3b58f4917ca4f63e950ade81
schnell18/play-python
/intro/number.py
1,102
4
4
#!/usr/bin/env python def main(): n = get_number() meow(n) x = get_int("What's x? ") print(f"x is {x}") # try: # x = int(input("What is x? ")) # except ValueError: # print("x is not an integer") # else: # print(f"x is {x}") # while True: # try: # ...
ace706cf9f6a3eaca1b143650ffcf5732a6e393a
sci-c0/exercism-learning
/python/phone-number/phone_number.py
3,189
3.984375
4
""" Clean up user-entered phone numbers so that they can be sent SMS messages. The North American Numbering Plan (NANP) is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda. All NANP-countries share the same international country code: 1. NANP numbers are t...
3ef513ed8c8b49c2f81a7ffe91c911576194b2d6
python20180319howmework/homework
/zhangzhen/20180326(2)/text7.py
253
3.59375
4
#7.请删除字典中的键'k5',如果不存在键'k5',则输出"对不起!不存在你要删除的元素" dic = {} num = 0 for key in dic.keys(): num += 1 if num >= 5: dic.pop(k5) else: print("对不起,不存在你要删除的元素")
e66a053e98fa54a0be39e9503c10533f2237f0f8
henryfw/algo
/interviewbit/python/arrays-rotate2d.py
636
3.78125
4
class Solution: # @param A : list of list of integers # @return the same list modified def rotate(self, A): #B = [ [0 for i in range(len(A))] for j in range(len(A[0])) ] for i in range(len(A)): for j in range(len(A[0])): tmp = A[j][len(A)-1-i] A[j]...
32b3975b93debb8cff4b25beaf85c3b5e4ed660d
winan305/Algorithm-with-Python3
/BOJ2789.py
139
3.84375
4
# https://www.acmicpc.net/problem/2789 str = input() for c in str : if c in "CAMBRIDGE": str = str.replace(c, "") print(str)
ba42e80102784a23f4196ebb147c82b267fe41bd
JulyKikuAkita/PythonPrac
/cs15211/GeneralizedAbbreviation.py
5,337
3.625
4
__source__ = 'https://leetcode.com/problems/generalized-abbreviation/' # https://github.com/kamyu104/LeetCode/blob/master/Python/generalized-abbreviation.py # Time: O(n * 2^n) # Space: O(n) # # Description: Leetcode # 320. Generalized Abbreviation # # Write a function to generate the generalized abbreviations of a wor...
c3cd3fa4f3a25e3e21b393fe46110b6b5eb4a114
Ozoniuss/Graphs
/better_menu.py
3,791
3.875
4
from Graph import Graph, readGrahFromFile, writeGraphToFile, randomGraph, randomGraph2, accessibleFromVertex, lowestLenghtPathBetweenVerticesBacwardsBFS, dijkstraAlgorithm import re class Ui: def __init__(self): self.__graph = Graph(0) self.__options = {'algorithm backwards bfs <x, y>':self._...
11d9264c903a47edb7468b4ed0af92bb71c6b7af
gmidha/python-examples
/subclass_predatory_creditcard.py
917
4.40625
4
#!/usr/bin/env python3 # This program demonstrates the usage of Inheritance in python. We are going to extend the functionality of CreditCard class present in class_creditcard.py from class_creditcard import CreditCard class PredatoryCreditCard(CreditCard): def __init__(self, customer, bank, acnt, limit, apr): ...
79223cf5af2f19f000758b5dfa7595a459cac3e9
KierstenPage/Intro-to-Programming-and-Problem-Solving
/Homework/hw2/kep394_hw2_q5.py
941
4.15625
4
johnDays = float(input("Please enter the number of days John has worked: ")) johnHours = float(input("Please enter the number of hours John has worked: ")) johnMinutes = float(input("Please enter the number of minutes John has worked: ")) billDays = float(input("Please enter the number of days Bill has worked: ")) bill...
2ee49116e2eecbdc7b3820ccdafc45817f7d0178
Flaeros/leetcode
/src/subsets/subsets_duplicates_90.py
736
3.890625
4
from typing import List class Solution: def subsetsWithDup(self, nums): nums.sort() subsets = [] self.subsetsWithDupRec(nums, subsets, [], 0) return subsets def subsetsWithDupRec(self, nums, subsets, subset, index): subsets.append(subset.copy()) for i in range...
384b22c078f5bbbe457f29a05c2c9fbab79fa7e8
nacoaks/pyCourse
/ejemplos/ejemplo1_0010.py
306
4.09375
4
# Esto es un comentario del programador print(4+2*3) print(4+(2*3)) # la solución aquí también es 10 print((4+2)*3) # la solución ahora es 18 print("La raiz cuadrada de 16 es", 16**.5) '''Esto es un comentario que se escribe en varias líneas''' print("La raiz cuadrada de 16 es", 16**.5)
b5ba40682406cf40c07d6fc3ba76a8bd7273aed1
aman0997/scripts2
/python Scripts programs/script.py
244
3.953125
4
# Define the string string = 'Python Bash Java Python PHP PERL' # Define the search string search = 'Python' # Store the count value count = string.count(search) # Print the formatted output print("%s appears %d times" % (search, count))
00dd3a9672a4b036bbb3990682503be0836bd31c
nxwcharlene/PBL-3210
/connect_database_gerg.py
885
3.515625
4
# connecting to mysql database to the python code, from a remote computer import mysql.connector import pandas as pd db_connection = mysql.connector.connect(user='root', password='Gregory2',host='localhost', port='3306', database='pbl3210 db') #macrotabl= pd.read_sql_query("SELECT...
42f643352523fe5491a556971bf5ac9cdca0b488
Daniel-Ortiz1210/adivina_el_numero
/adivina_el_numero.py
549
3.9375
4
import random def run(): print('BIENVENIDO AL JUEGO ADIVINA EL NÚMERO') numero_aleatorio = random.randint(1, 100) numero_usuario = int(input('Ingresa un numero del 1-100: ')) while True: if numero_usuario > numero_aleatorio: print('Ingresa un numero menor!') elif numero_usuar...
58cdfbaa99d75935bdd7e85afd4c6ebf85f94373
ankitsharma6652/HackerrankPractice
/Python/03. Strings/011. Capitalize!.py
157
3.921875
4
# Problem: https://www.hackerrank.com/challenges/capitalize/problem # Score: 20 st = input() print(' '.join(word.capitalize() for word in st.split(' ')))
4c87c71ef0f4005d6a1c748f42bacc81ab6c81ff
oOo0oOo/chords
/chords.py
15,137
3.5
4
######################################################### # # Music Helper Functions # Oliver Dressler, 2013 # ######################################################### import random import math # Get all the music theory (parameters) from theory import * def quick_song(chord_list, pause = True): '''Song is a li...
52e9ad219ba40ad70f974924e46b283200b85f19
xros/temp_convert
/temp_convert.py
1,838
4.34375
4
""" This is a small program to convert temperature degrees between different types. Created by Songhua Liu """ def all_to_kelvin(x,y): a = ["","","","","","","",""] # declare an empty list a[0] = x # kelvin to kelvin a[1] = x + 273.15 # celsius to kelvin a[2] = ( x + 459.67...
f8aa695aa9656a9494f0e387e2428d264424664c
HJ23/Algorithms-for-interview-
/UniqueMorseCodeWords/find.py
293
3.625
4
morse=[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."] def find(words): ss=set() for word in words: ss.add("".join(map(lambda x:morse[ord(x)-ord('a')],word))) return len(ss)
62324f1fb66aba83501ad6f59d162837437bfbdf
prateekstark/training-binary-neural-network
/baseline/pmf/models/LeNet300.py
1,148
3.578125
4
""" model: LeNet-300-100-10 """ import torch import torch.nn as nn class LeNet300(nn.Module): """deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (dataset_size, input_dim) Returns: y: a tensor of shape (dataset_size, output_dim), with...
4bd4fa2f4aaeb0ebcc8fc5c14452f9d492ef2360
abhishekmsharma/leetcode-solutions-python
/500_keyboard_row.py
438
4.03125
4
class Solution: def findWords(self,words): s1 = set("QWERTYUIOP") s2 = set("ASDFGHJKL") s3 = set("ZXCVBNM") result = [] for word in words: if set(word.upper()).issubset(s1) or set(word.upper()).issubset(s2) or set(word.upper()).issubset(s3): result...
cba92ecc76487ade366f204d6a16d2e705fb28a7
nehapokharel/Beeflux_Test
/Question17.py
1,176
3.53125
4
class CreditCard: def make_payment(self,amount): self.amount = amount print(self.amount) def get_customer(self,customer): self.customer = customer print(self.customer) def get_bank(self,bank): self.bank= bank print(self.bank) def get_account(self,customer,bank,balance_limit): self.customer = cu...
0ffdc455c6dfbe8695f8c173b7065e83be04d477
niki4/algorithms
/sort/insertion_sort.py
1,255
3.84375
4
import random import timeit # Runtime complexity: O(1) best case [insert in sorted list], O(n**2) worst case def insertion_sort(items): for idx in range(1, len(items)): # considering items[0] already sorted current_value = items[idx] pos = idx while pos > 0 and items[pos-1] > current_value...
6bef96f68d06bbd05ac8ee1cdf7a79e824b3e00a
appleface2050/algorithms
/interview/fibonacci.py
256
3.84375
4
def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) def fib2(n): a, b = 0, 1 for i in range(n): a, b = b, a+b return a if __name__ == '__main__': print fib(3)
6cc48912d421ba356f214ce4886fdb603668fc6c
stupidchen/leetcode
/src/leetcode/P884.py
632
3.734375
4
class Solution(object): def uncommonFromSentences(self, A, B): a = {} b = {} for word in B.split(' '): b[word] = b.setdefault(word, 0) + 1 for word in A.split(' '): a[word] = a.setdefault(word, 0) + 1 ret = [] for word in a.keys(): ...
7c11807940984649eec688f505f0108d1c58dab4
AryusG/US-States-Game
/main.py
1,216
3.65625
4
import pandas as pd import turtle as t screen = t.Screen() screen.title("U.S States Game") image = "blank_states_img.gif" screen.addshape(image) t.shape(image) data = pd.read_csv("50_states.csv") correct_answers = [] while len(correct_answers) < 50: answer_state = screen.textinput(title=f'{len(correct_answers)}...
cd54568b2dbf4f90b8a3c0bbeab380ff3d167c35
Menturan/aoc2017
/calendar/dec_04.py
2,252
4.09375
4
from christmas_tree import tree from util.read_file import read_file_to_string def part1(passphrase: str): """ A valid passphrase must contain no duplicate words :return no of valid passphrases: """ list_of_passphrases = passphrase.splitlines(keepends=False) no_of_valid_phrases = 0 for phrase ...
dd8c9c393e85a981c1db511ff2526e8c7be9dfa0
sucramaJ/SpotifyApp
/MakePlaylist.py
2,475
3.609375
4
import spotipy from spotipy.oauth2 import SpotifyOAuth import json def getIndex(name, lst): return lst.index(name) #Create the playlist def createPlaylist(username, spotifyObject): playlistName = input('Enter a playlist name: ') playlist_descr = input('Enter a playlist description: ') spotifyObject.u...
f4465a19ea8adc809c1b370f58712ff871a96f11
pythonfrankcc/python_fundamentals
/deckOfCards_oop.py
2,050
4
4
#oop and debugging import pdb import random #inheriting from object #establishing the starting point of the debugger but cannot be used in situations with classe only runs after #classes are called #pdb.set_trace() class Card(object): def __init__(self,suit,val): #creating methods of the Card class self.suit=suit ...
20a655970f24bebcc8d10179b66feac87202e1f3
rjamesdunlop/Secret-Hitler
/HitlerRole.py
724
3.984375
4
class Role(object): """ Parent role. Inherited by three subclasses: Liberal, Fascist, Hitler. """ def __init__(self): self.party_membership = "" self.role = "" def __repr__(self): return self.role.title() class Liberal(Role): def __init__(self): super(Liberal, ...
a8ce705f6a3d7a0a397a2d9843545bc8d011166e
jiahui-qin/python_learn
/lintcode/fibonacci.py
303
3.90625
4
def fibonacci(n): # write your code here #从低向上 lll = [] if n == 1: return 0 if n == 2: return 1 for i in range(n): lll.append(0) lll[1] = 1 for i in range(2,n): lll[i] = lll[i-1]+lll[i-2] return lll[n-1] print(fibonacci(7))
4834198651c1030369be221897db35595fa2c037
avedun/fall-21
/for list overlap.py
1,137
4.375
4
#Take two lists, say for example these two: # a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] # b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] #and write a program that returns a list that contains only the elements that are # common between the lists (without duplicates). Make sure your program works on # two lists of...
02807e30c5c8fd74fd35daba846d9624541eed35
dimitri4d/Software-for-Legacy-Systems
/Russian_peasant_multiplication/src/pythonIter.py
554
4
4
# # Dimitri Frederick # Cis3190 A4 # # python # itterative russian peasant Multiplication # # def peasantMult(m,n): p = 0 while(m >= 1): # m is even, double n, halve m, no addition to sum if ((m > 1) and ((m % 2)==0 )): n *= 2 m //= 2 # m is odd, add n addition to sum, double n, halve m, if ((m > 1) a...
0268483c9dcc13d87ebbfc29230f6925f59aa575
s10018/100pon_knock
/No3/ex24.py
550
4.0625
4
# -*- coding: utf-8 -*- import sys import string alphabet = string.ascii_letters + string.digits for line in sys.stdin: line = line.rstrip('\n').decode('utf-8') for word in line.split(' '): if len(word) == 0: print word continue w, symbols = word[-1], [] while l...
74dcf7b23563a325757089b2711077c2f299ac27
wwitzel3/samples
/snippets/wnp.py
814
4.15625
4
"""Why Not Pangram? Examine a String, determine if it contains every letter in the US-ASCII alphabet. This will ignore case and non US-ASCII characters. >>> getMissingLetters('A quick brown fox jumps over the lazy dog') '' >>> getMissingLetters('A slow yellow fox crawls under the proactive dog') 'bjkmqz' >>> getMissin...
b695111cffa7c1387a12b98a1921fd5f3ad70d41
samadabbagh/sama-mft
/mft-eight-section/def practice.py
425
4.03125
4
def factorial(t): """ computes factorial .blaah blaah :param t: an integer number :return: factorial """ res = 1 while t: res = res * t t -= 1 return res def combination(m, n): val_1 = factorial(m) val_2 = factorial(n) val_3 = factorial(m -...
d530a99eada6a16a96b92abf65b90591a0eba61c
CinS12/piia_v3
/View/V_ViewPage.py
4,923
3.5
4
import tkinter as tk from tkinter import ttk from pubsub import pub from View.V_Page import Page FONT_BENVINGUDA = ("Verdana", 12) FONT_TITOL = ("Verdana", 10) FONT_MSG = ("Verdana", 8) class ViewPage(Page): def __init__(self, parent, lang): self.container = parent self.lang = lang self.p...
ff0a74003400f19e741bb7ad24895e5771ce6527
sai-kumar-peddireddy/PythonLearnigTrack
/Strings/SplitigString.py
477
4.21875
4
""" Mon Jul 16 06:13:33 IST 2018 source :https://www.tutorialspoint.com/python3/string_split.htm The split() method returns a list of all the words in the string, using str as the separator (splits on all whitespace if left unspecified), optionally limiting the number of splits to num """ text = "cat|dog|elephant|zoo|m...
938ae92305ea62e3b2e0101c7257052b2e75d378
hamzayn/My_HackerRank_Solutions
/String_validators.py
441
4.09375
4
def check_validity(string): isalnum = isal = isdigit = islow = isupper = False for x in string: if x.isalnum(): isalnum = True if x.isalpha(): isal = True if x.isdigit(): isdigit = True if x.islower(): islow = True if x.isupper(): isupper = True return isalnum, isal,...
71e015fb422e5c507610ca514b0232faf7d6621a
gannonp/CSE
/__pycache__/Object Assignment - Gannon Peebles.py
3,661
3.71875
4
class Playstation4(object): def __init__(self, number_of_games, internet, money): self.controller = True self.disk = True self.power = True self.hdmi = True self.number_of_games = number_of_games self.headset = True self.internet = internet self.wallet...
0520cb3fd5ab4875700afdb270b63b1f92011ac4
frombegin/gnote-server
/gnote-server/utils.py
1,982
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import random import string from functools import partial # ------------------------------------------------------------------------------ def randomString(length=10, allowedChars=string.ascii_letters): """randomString(int, [str]) -> str 返回指定长度的随机字符串, 字符串由 allow...
7acb0fbc578d41dd382e523cae7a0be882b1cbb8
fbergamini/valemobi
/testeBack/manipular_db1.py
1,092
3.859375
4
# -*- coding: utf-8 -*- #Código feito em Python 2.7.1 #Este código utiliza um banco de dados SQLite3 para manipulação de dados #Foram utilizados comandos SQL para calcular a média e ordenar os clientes import sqlite3 #Inicia a conexão com o banco de dados conexao = sqlite3.connect('loja.db') cursor = conexao.cursor()...
2fe4e7863d559c1521a41780a02391debaf06986
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/palindrome-products/9d36d1d83a1c40f0870894c1b12f46b8.py
679
3.546875
4
def is_palyndrome(n): s = str(n) return s == s[::-1] def smallest_palindrome(min_factor = 0, max_factor = None): for v1 in xrange(min_factor, max_factor): for v2 in xrange(v1, max_factor): m = v1*v2 if is_palyndrome(m): return (m, [v1, v2]) def largest_pal...
d0653149578703707af936e50f5b7736b3bd03a9
CodyTeague/dps
/dps.py
1,296
3.859375
4
class Node: def __init__(self,name,children=[]): self.color = 'white' self.children = children self.discover_time = -1 self.final_time = -1 self.name = name def __str__(self): return self.name + " " + str(self.discover_time) + "/" + str(self.final_time) #def bre...
5cd0467e658bd1cb45fb0a375727a40265f530ee
WagonsWest/Leetcode
/recursion/lc509_fibonacci.py
356
3.5625
4
class Solution(object): def fib(self, n): """ :type n: int :rtype: int """ if n==0: return 0 if n==1 or n==2: return 1 prev = 1 curr = 1 for i in range(n-2): sum = prev + curr prev = curr ...
cc309dfc2eb107fe158231c01c7e850eb2c35370
outtrip-kpsv/brainskills
/3/3.1/3.1.e.py
88
3.890625
4
def reverse_num(num): return int(str(num)[::-1]) print(reverse_num(int(input())))
9354efb4d1cdd3b0f9dc3218b4fc93c2ba645dde
Urvashi-91/Urvashi_Git_Repo
/Interview/Stripe/triangle.py
1,181
3.8125
4
// https://www.codewars.com/kata/56606694ec01347ce800001b/solutions/javascript // Implement a method that accepts 3 integer values a, b, c. The method should return true if a triangle can be built with the sides of given length and false in any other case. // (In this case, all triangles must have surface greater tha...
ce9f101d403bf657c43cf8051e2ce62c6f21d5be
maryammouse/cs101
/u03ps03q03.py
3,817
3.984375
4
# Numbers in lists by SeanMc from forums # define a procedure that takes in a string of numbers from 1-9 and # outputs a list with the following parameters: # Every number in the string should be inserted into the list. # If a number x in the string is less than or equal # to the proceeding number y, the number x shoul...