blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f2659fedef1da65c985f5a9b19e66fc418c068ba
joseraz/Data-Structure-and-Algorithms
/14 Code - Hard Problems/Greedy algorithm.py
691
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 5 15:42:19 2019 @author: jose """ class Item(object): def __init__(self, n, v, w): self.name = n self.value = v self.weight = w def getName(self): return self.name def getValue(self): return self.value ...
d41459487f33aa9a9708ce1f756f0c2ca95b38f5
Tektalk4kidsOfficial/Code-On-cards
/main.py
934
3.96875
4
import random import sys responses = ["Move forward 2 ", "Move Forward 1", "Move back 1", "Move backward 2", "U-turn", "Turn Right", "Turn Left", "Down and right", "Any direction","Down and left"] answer = random.choice(responses) print(answer) answer = random.choice(responses) print(answer) answer = rando...
4d72004164993e0d14d72b7c2a65d56eb775721f
ContextLab/hypertools
/examples/analyze.py
887
3.96875
4
# -*- coding: utf-8 -*- """ ============================= Analyze data and then plot ============================= This example demonstrates how to use the `analyze` function to process data prior to plotting. The data is a list of numpy arrays representing multi-voxel activity patterns (columns) over time (rows). Fi...
c0da1633ffdb0f88ac05ec2c85ad580364578919
Fennay/python-study
/study/sorted.py
570
3.515625
4
#!/usr/bin/env python3 # _*_ coding:utf-8 _*_ from collections import Iterable L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] M = [] def by_name(t): return t[1] ss = sorted(L, key=by_name, reverse=True) print(ss) def calc_sum(*args): ax = 0 for n in args: ax = ax + n retur...
08f77a244a5b0d6bbac0365db5c73a0948d92291
wang264/JiuZhangLintcode
/AlgorithmAdvance/L7/require/405_submatrix-sum.py
1,790
3.90625
4
# 405. Submatrix Sum # 中文English # Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return the # coordinate of the left-up and right-down number. # # If there are multiple answers, you can return any of them. # # Example # Example 1: # # Input: # [ # [1, 5, 7], # [3, 7, -...
c47df2c714af2d65a5ae7db63bb3f0f7cedf76ea
mritter-xcc/big-questions
/04-Add-database/scripts/createDB.py
421
3.78125
4
import sqlite3 # db name variable DB = 'meaning-life.db' # connect to db - create if not exist con = sqlite3.connect(DB) # create cursor to interact with db cur = con.cursor() # create db table cur.execute(""" CREATE TABLE comments (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, title TEXT...
2be4430c0383f036462d8fa0e6d4515f835a3f41
ShellySrivastava/Machine-Learning
/ML_CW1/assgn_1_part_2/1_logistic_regression/gradient_descent.py
2,170
4.21875
4
from calculate_hypothesis import * from compute_cost import * from plot_cost import * def gradient_descent(X, y, theta, alpha, iterations): """ :param X : 2D array of our dataset :param y : 1D array of the groundtruth labels of the dataset :param theta : 1D arra...
752a7284ae570c9f74cbb8f7c34280325747ac5e
NJ-zero/LeetCode_Answer
/list/missingnumber.py
743
3.65625
4
# coding=utf-8 # Time: 2019-09-30-09:50 # Author: dongshichao ''' 给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数。 示例 1: 输入: [3,0,1] 输出: 2 示例 2: 输入: [9,6,4,2,3,5,7,0,1] 输出: 8 解题思路: 从数学的角度,0-n,确定会缺失一个数字 将数组求和,和0-n求和,差额就是少的数字 ''' class Solution(object): def missingNumber(self, nums): """ ...
d8dba460d2cc183c103b2ffe8c96ae5ca813e0e9
ielecer/Python-3
/passwordDetection.py
275
3.734375
4
#Password Detection (The world's simplest) #Written by Anupam #For the book: Automating The Internet with Python password = input("Enter your password: ") if len(password) > 8: print("That is one strong password") else: print("May god have mercy on your account")
85dd832180a68a07459894cf7779368ec6115d3a
darigas/BFDjango_2018
/Week_1/CodingBat/String-2/double_char.py
119
3.71875
4
def double_char(str): result = "" for item in range(len(str)): result += str[item] + str[item] return result
bfb1a80d78b28b2adedaf8780dfc1dea71bd78ed
er-vikramsnehi/python_programming
/python-programming-workshop/set/create_modify_search_del_dictionary.py
448
3.9375
4
mydictionary = { } mydictionary["salary"] = 1000000 mydictionary["age"] = 45 print(mydictionary) dictone = {"name":"Aprameya","salary":1000000} print(dictone) newdict = dict([("Cat",5),("Dogs",3)]) print(newdict) dictone["age"] = 16 print(dictone) dictone["age"] = 15 print(dictone) if "age" in dictone: print(...
161a48a2cb494d149dde4ba1953a3045d62230aa
fjdurlop/TallerArduinoPython2020-1
/Tkinter/Tkinter/gui6.py
865
3.796875
4
# ENTRY #Entrada de texto from tkinter import * raiz = Tk() ent = Entry(raiz) # entrada de texto boton = Button(raiz, text='Mandar') # Variables de tkinter var = StringVar() # variable de tipo string ent.config(textvariable=var) # asociamos variable con ent ''' Variables de control Las variables de control son...
6395349908c105f09811b795d6bd0d4b8389b022
lion963/SoftUni-Python-Fundamentals-
/Exercise Functions/Smallest of Three Numbers.py
265
3.734375
4
def min_num(a=int(input()), b=int(input()), c=int(input())): small=None small=min(a,b,c) print(small) min_num() # def min_num(a=int(input()), b=int(input()), c=int(input())): # small=None # small=min(a,b,c) # return small # print(min_num())
24dc477337e6e12e547cc5a94a84987f66788eda
Kontowicz/Daily-Interview-Pro
/solutions/day_96.py
300
3.75
4
import math def is_palindrome(n): num = [] while n != 0: num.append(n%10) n = n // 10 return num == num[::-1] assert is_palindrome(1234321) == True print(is_palindrome(1234321)) assert is_palindrome(1234322) == False print(is_palindrome(1234322)) print('Test pass.')
3e35852ffc793a0889f4f71311d5af294a525b7d
Educorreia932/FEUP-FPRO
/PE/PE2/exactly.py
1,370
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 23 16:20:22 2018 @author: exame """ def exactly(s): counter = 0 interrogation = 0 index = 0 result = () numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] numbers_list = [] for character in s: if c...
04418419fd3bf64be3c9b5908abb156d9a90d211
acnolan/Data-vis-7-ways
/imputeMPG.py
962
3.890625
4
# This python script imputes the 2 missing MPG values # We know both of them are 8 cylinder Ford cars # So we will perform the imputation by finding all of the 8 Cylinder Fords and taking their average MPG values. # Since it's only two values I am just calculating the average and then printing the output, I will manual...
171b35341056bc5503bf816a5923788df8559e66
annamichalovova/Python
/easy_unpack/Easy unpact.py
136
3.6875
4
def easy_unpack(elements: tuple) -> tuple: return elements[0],elements[2],elements[-2] print(easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)))
be5125b7a93bad21bb8a126ba67b5bf07d0d2a91
yuzhoul1991/leetcode
/785.is-graph-bipartite.python3.py
1,132
3.640625
4
class Solution: def isBipartite(self, graph): """ :type graph: List[List[int]] :rtype: bool """ # construct graph and start with black color and all neibors with it should be # red color, keep labeling, if we found a neighbor with the same color as self # it i...
7bd5c81913bce05a511fe5e68ed11ca641987735
neamedina73/Ejercicios_de_Python
/5. Constructor de pandas DataFrame_lista_tabla_periodica.py
582
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 1 15:49:22 2021 @author: Alejandro AJ """ import pandas as pd elementos = { 'Número atómico':[1,6,47,88], 'Masa atómica':[1.088,12.011,107.87,226], 'Familia':['No metal','No metal','Metal','Metal'] } tabla_Periódica = pd.DataFrame(elementos)...
12dd0e6c8302f7a09e60b886c189c278874e1bc9
abay-90/NISprogramming
/Module 3/Class Lecture & Practise programming/ReadingWithTellAndSeek.py
635
4.09375
4
# The file is opened using the readable mode my_file = open("Textfile.txt", "r") # Display all the contents of the file print(my_file.read()) print("Position {}".format(my_file())) print("Resetting postion to 50") my_file.seek(20) print("Position {}".format(my_file.tell())) print() # Display all the contents of the fi...
984469c33fd33b7cfe3d770163580c075506b408
zolcsika71/JBA_Python
/Rock-Paper-Scissors/Problems/Decimal places/main.py
132
3.5625
4
number = float(input()) decimal_places = int(input()) print(f'{number:.{decimal_places}f}') # print(round(number, decimal_places))
39b0a33f4eac15b14b6566438e3ba144ec33363c
1715974253/learned-codes
/23列表循环遍历.py
140
3.71875
4
list1 = ['Tom', '斯塔克', '托尼', '刘亦菲'] i = 0 while i < len(list1): print(list1[i]) i += 1 for j in list1: print(j)
7b7f71d85ea482f5d9f7fb67687634926c24a54f
novayo/LeetCode
/0366_Find_Leaves_of_Binary_Tree/try_2.py
620
3.671875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def findLeaves(self, root: Optional[TreeNode]) -> List[List[int]]: layers = collections.defaultdict(...
0ca3717f6522074ed07a00848af3fe29f7296e1e
siddharth456/Python_Scripts_1
/mysql-connector.py
501
3.875
4
# Python can be used in database applications # One of the popular databases around is mysql # Python needs a mysql driver to access the databases in mysql import mysql.connector # Creating a connection object mycon = mysql.connector.connect(host="localhost",user="root",password="compaq@123") # Creating a cursor ...
0038551dde549eb0fc36cd13ae448e0e796d890c
kshitiz2001/Python-Projects
/language.py
149
3.765625
4
from langdetect import detect text = input("Enter any text in any language: ") print("language of this text is : ", detect(text)) # by kshitiz
48c3ee1ebe3766367d52b2f04e4d61893d69b006
RamuSannanagari/python_practice_files
/Inheitence/Inheritence2.py
479
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 2 10:39:04 2018 @author: abhi """ class Parent: P_V=1000 def parent_m(self): print("parent_m = ",self.P_V) self.child_m() def child_m(self): print("child_m in parent = ",self.C_V) class Child(Parent): ...
f63b673b5115013d2ca73ba95275c7aa9957f338
almirgon/LabP1
/Unidade-7/ajeita.py
504
3.671875
4
#coding: utf-8 #Crispiniano #Unidade 7: Ajeita Lista de Números Inteiros def ajeita_lista(dados): while True: condicao = False for i in range(len(dados)-1): if dados[i] < dados[i+1]: dados[i], dados[i+1] = dados[i+1], dados[i] condicao = True if not condicao: break for x in range(len(dados)-1,...
e145898955acc74a21d2e3faf7a231ee58319bc6
Fover21/notebook
/Python笔记/Wzy01/03.py
1,920
4.1875
4
#首先安利一下:字符串是不可变的对象,所以任何操作对原字符串是不改变的。 python2默认编码为ASCII python3默认编码为uft-8 python2的 str == bytes 而python3的str是Unicode bytes为str编码后的二进制类型 1.编码 1)最早的计算机编码是ASSCII 128个码位 2**7 在此基础上加了一位 2**8 8位,1个字节(Byte) 2)Gbk 国标码 16位。 2个字节(双字节字符) 3)unicode 万国码 32位,4个字节 4)utf-8: 英文 8 位 1个字节 欧洲文字 16位 2个字节 中文 ...
29e731b78696a6a03589f5f36669963481f6629a
keving3ng/Coding-Challenges
/FirstRecurringCharacter.py
438
3.78125
4
'''First Recurring Character Jan 17 2018 https://www.reddit.com/r/dailyprogrammer/comments/7cnqtw/20171113_challenge_340_easy_first_recurring/ Example Input: ABCDEBC -> B IKEUNFUVFV -> U PXLJOUDJVZGQHLBHGXIW -> J *l1J?)yn%R[}9~1"=k7]9;0[$ -> 1 ''' chars = [] i = 0 cChar = str() string = input ("Input th...
f2cb3a4beea5bc4db97e3264d505576707b704e3
EmersonBraun/python-excercices
/cursoemvideo/ex022.py
534
4.21875
4
# Crie um programa que leia o nome completo de uma pessoa e mostre: # – O nome com todas as letras maiúsculas e minúsculas; # – Quantas letras ao todo (sem considerar espaços); # – Quantas letras tem o primeiro nome. nome = str(input('Digite seu nome completo: ')).strip() print('Em maiúsculas: {}'.format(nome.upper()))...
9a73f3cb946a5299910afe3593cededa0eaeecb1
theodoro/logica-prog-com-python
/logica/06-listas/cEmv-aula-18.py
766
3.921875
4
pessoa = [['Sumara',36],['Bruno',34]] print(pessoa[0][0]) teste = list() teste.append(34) teste.append('Bruno') galera = list() galera.append(teste[:]) teste[0] = 'Sumara' teste[1] = 36 galera.append(teste[:]) print(galera) galera2 = [['João',19], ['Ana', 33], ['Joaquim', 14], ['Pietra', 1]] print(galera2) print(...
ad5ad8ad3dc8ff56afea93111612073ca6d1df94
L200184137/praktikumAlgopro
/8.2.py
403
3.921875
4
def konversi_suhu(): x = int(input('pilih konversi :')) if ( x == 1): f = int (input('masukkan suhu celcius :')) c = 32+9.0/5*f print(c) if (x==2): a = int (input ('masukkan suhu farenheit :')) b = (a - 32)*5.0/9 print (b) print ('konversi suhu') pr...
2eb2eee16e18048b444d6f741e2600aa7ed7ed68
L111235/Python-code
/嵩天python3/字典键值反转输出.py
251
3.71875
4
#d={"a": 1, "b": 2} d=eval(input()) #输入一个字典数据,input()函数返回值实际为为一个字符串 try: d1={} for i in d: #print(i) #value=d[i] d1[d[i]]=i print(d1) except: print('输入错误')
66ace7bf809984b57b1d435093cf9bac7e298a07
scohen40/wallbreakers_projects
/Leetcode/week_4/p0039_combination_sum.py
694
3.609375
4
from typing import List class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: self.valid = [] def backtrack(path, index, csum): if csum == target: self.valid.append(path) return for i, n in enumera...
8fbd3820575971ce7b77f71d5adbdbabb597ac7c
ShyZhou/LeetCode-Python
/301.py
1,388
3.765625
4
# Remove Invalid Parentheses # Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. # Note: The input string may contain letters other than the parentheses ( and ). # Example 1: # Input: "()())()" # Output: ["()()()", "(())()"] # Example 2: # Input: ...
4407531d5821b2aa27ba9450fb111cf7eb27c440
akhilgoel0007/Chess_Game_Simulation
/Functions/Bishop.py
2,160
3.59375
4
from Functions.BasicFunc import * def MoveBishop(ChessPiece, NewSquare, AllPieces, Board): """ Both Bishop's Cannot Collide at one Position, Both are of Different Colors..""" for Bishop in AllPieces[ChessPiece]: X_BishopSquare = int(Bishop['CurrentSquare'][1])-1 # Integer Coordinate Y_BishopSquare = int(RowToN...
364a607c24b4b4ad87d0609a3500c7f289ccf319
ngocdung03/codecademy-machine-learning
/4-breast_cancer_classifier.py
1,469
3.75
4
import codecademylib3_seaborn # Importing breast cancer data from sklearn.datasets import load_breast_cancer breast_cancer_data = load_breast_cancer() print(breast_cancer_data.data[0]) #breast_cancer_data.data to see the data print(breast_cancer_data.feature_names) print(breast_cancer_data.target) print(breast_cance...
f208c268fb48ff085e07a546beb3e6f155c88e17
saurabhchris1/Algorithm-Pratice-Questions-LeetCode
/Reverse_Words_in_a_String II.py
1,032
4.125
4
# Given an input string , reverse the string word by word. # # Example: # # Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] # Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"] # Note: # # A word is defined as a sequence of non-space characters. # The input string does not conta...
32e39678f754e8f633480fac24743119c3b5bba2
yihutu/Python
/week1/day1/格式化输出.py
560
3.90625
4
#conding:utf-8 #_author:贡金敏 #date:2018/9/18 name = input("Name:") age = int(input("age:")) ##输出数字 job = input("job:") salary = input("salary:") if salary.isdigit(): #判断salary变量长得像不像数字,比如200d,‘200’ salary = int(salary) # else: # print() # exit("must input digit") ##退出程序 #%d只能输入数字 msg = ''' -------info of...
efbf3f69711662d56233d1318fbb026186b13f53
akshaypatil3207/beginer-problems
/finding unique rows from given rows.py
633
3.90625
4
#Take m ie rows in class and n ie columns in class #form M by n matrix #enter 1 for boy and 0 for girl as per sitting arrangement #print no of unique rows ignore same arrangement rows arr=[] out=[] m=int(input("enter no of rows:- ")) n=int(input("enter no of columns:- ")) for i in range(m): arr.append(list(inpu...
cee010873a34a2727efcdbb1d0249666ee1cf572
kakru/puzzles
/leetcode/929_unique_email_addresses.py
781
3.859375
4
#/usr/bin/env python3 import unittest class Solution: def numUniqueEmails(self, emails): """ :type emails: List[str] :rtype: int """ mails = set() for m in emails: user, domain = m.split('@') if '+' in user: user = user.split('...
d2ac1c0b62ed3b812052adc724c54db25fba0f67
AdamZhouSE/pythonHomework
/Code/CodeRecords/2577/58547/308603.py
552
3.765625
4
def my_hash(string): total = 0 total += len(string) * ord(string[0]) * 142857 i = 0 mul = 37 while i < len(string): total += mul * ord(string[i]) i += 1 mul += 7 return total def func(): string = input() string += input() string += input() v = my_hash(s...
bf7a019d1fe8eaac4a5faf7cf2a72934d067ad8b
bobk48/unixthetextbook3
/ch16/panedwindow_widget.py
375
4.03125
4
from Tkinter import * def panedwindow(): m1 = PanedWindow() m1.pack(fill=BOTH, expand=1) left = Label(m1, text="PanedWindow left") m1.add(left) m2 = PanedWindow(m1, orient=VERTICAL) m1.add(m2) top = Label(m2, text="PanedWindow top") m2.add(top) bottom = Label(m2, text="PanedWindow bo...
70ff6b3b91b229cacaec1f92d6edc40b511db045
jsverch/practice
/leet690.py
700
3.84375
4
from typing import List # Definition for Employee. class Employee: def __init__(self, id: int, importance: int, subordinates: List[int]): self.id = id self.importance = importance self.subordinates = subordinates class Solution: def getImportance(self, employees: List['Employee'], ei...
507d0176b4612b75f04cef29161be11dc33778d0
twshutech/foobarChallenge-L3
/whatIsSolution.py
1,089
3.59375
4
addNeg = lambda a,b:a-b addPos = lambda a,b:a+b def solution(m): # All maps' path length. shortest_path(m, len(m[0]), len(m)) def shortest_path(m, w, h): # Dict with steps as key, neibhors as properties. breadcrumbs = dict({1: {(0,0)}}) print 'breadcrumbs:',breadcrumbs,'breadcrumbs',breadcrumbs.keys() # D...
cfd48e282703b110be553a4e40474301191663c2
bjemcnally/Udacity-DAND-Notes
/DAND_Lesson2.py
8,852
4.3125
4
# print function ''' include parentheses! ''' print('waddup') # Arithmetic Operators ''' +, -, *, / exponentiation ** modulo %, returns remainder (and only the remainder) after you divide first number by the second 9 / 2 would give 1 integer division // rounds answer DOWN to an integer ...
a6682bb1f4b9d7fb965c55cb60cd59f44424e4b9
hanrick2000/algorithm-6
/03 - Binary Search/E14firstPosition.py
607
3.890625
4
class Solution: """ @param nums: The integer array. @param target: Target to find. @return: The first position of target. Position starts from 0. """ def binarySearch(self, nums, target): # write your code here left, right = 0, len(nums) while left + 1 < right: ...
0da6dbd43f537d3bdfa6d80bcebaf51a1f72cd15
HSJung93/-Python-algorithm_interview
/31-counter-topKth.py
291
3.859375
4
""" nums = [1, 1, 1, 2, 2, 3, 3, 4] k = 3 [1, 2, 3] """ from collections import Counter nums = [1, 1, 1, 2, 2, 3, 3, 4] k = 3 counter = Counter(nums) print(counter.most_common()) print(counter.most_common()[k]) print(counter.most_common(k)) print(list(zip(*counter.most_common(k)))[0])
90bddd2feb4349b7e1d0d5eb5f3446555c996def
deniztim/Data_Mining_and_Machine_Learning
/Main Python codes/DataMunging.py
2,697
4.25
4
# -*- coding: utf-8 -*- """ Created on Sat May 19 23:56:37 2018 @author: Deniz Timartas """ #First things first, everything actually starts here, we have a dataframe and we dont yet know what it has inside it. #So here we will show some data mining techniques to understand the data and here on we will decide how to us...
a77f34c6b43f86dac628de861dcd1a6352383554
Xiaoctw/LeetCode1_python
/树/从先序遍历还原二叉树_1028.py
1,002
3.53125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def recoverFromPreorder(self, S: str) -> TreeNode: stack=[] i=0 while i<len(S): cnt = 0 while i < ...
b2d22d329980926b8c9d4bd4fbf4e7d17aa607ef
lel352/PythonAulas
/PythonExercicios/Desafio017.py
495
3.8125
4
from math import hypot print('=========Desafio 017========') catetoOposto = float(input('Cateto oposto: ')) catetoAdjacente = float(input('Cateto adjacente: ')) hipotenusa = hypot(catetoOposto, catetoAdjacente) print('Hipotenusa de {} e {} é {:.2f}'.format(catetoOposto, catetoAdjacente, hipotenusa)) ''' OU hipo...
f7023e4be0fe383095d537d90620d8278af08255
tomegathericon/scripts
/sum.py
428
3.734375
4
#!/bin/bash/env python # Starters import sys import time import optparse print 'Hello, this will be a normal script to add two numbers either passed as arguements or requested from you during run time' #time.sleep(1) if len(sys.argv) > 1 : a = int(sys.argv[1]) b = int(sys.argv[2]) else : a = int(raw...
d3886c85a45f90f6802745a09e6e8b885df17bd1
Aasthaengg/IBMdataset
/Python_codes/p02406/s998707055.py
227
3.65625
4
n = int(raw_input()) print "", for i in range(1, n+1): if i % 3 == 0: print "%d" % i, else: z = i while 1: if z % 10 == 3: print "%d" % i, break z /= 10 if z == 0: break
7f71bafb32e608882525cf3d24ef49bf91517d28
iamrajshah/python_assignments
/madam_assignments/class_power.py
325
3.984375
4
class customPowerOfN: def __init__(self, number, power): self.number = number self.power = power def findpower(self): return self.number**self.power number = int(input('Enter the number:')) power = int(input('Enter the power:')) custom = customPowerOfN(number, power) print(custom.findpow...
f53f3b5394e3144c33cd57188dafc35549f7446f
serdardoruk/Bloomberg-Common-DS-Algo-Python-Solutions
/RemoveInvalidParentheses.py
1,498
3.90625
4
''' https://leetcode.com/problems/remove-invalid-parentheses/ Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters other than the parentheses ( and ). Example 1: Input: "()())()" Output: ["()()()", "(())()"]...
9eb73aad756fb101797721a33fa4d7822d644581
fabiomartinezmerino/python_tests
/codewars6_1.py
181
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat May 5 16:59:30 2018 @author: Alicia """ def reverse_seq(n): return list(range(n,0,-1)) print(reverse_seq(8))
d1f0d2720f33932fbbe66f427d988dcfe30ee4b3
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4370/codes/1884_1639.py
243
3.5625
4
from numpy import * t= array(eval(input("digite o valor das turmas"))) j=0 for i in range(size(t)): if(t[i]%2==0): j=j+1 print(j) v=zeros(j,dtype=int) g=0 b=0 for i in range (size(t)): if(t[i]%2==0): v[g]=v[g]+b g=g+1 b=b+1 print(v)
fa55bd2d425e0a379d70d0e0031fdd46dd762833
sqiprasanna/coding-questions
/DynamicProgramming/coin_change.py
1,707
4.0625
4
""" url : https://practice.geeksforgeeks.org/problems/coin-change/0 Given a value N, find the number of ways to make change for N cents, if we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins. The order of coins doesn’t matter. For example, for N = 4 and S = {1,2,3}, there are four solutions: {1,1,1...
45c12355463ac2a5e9ec1abbaa6aa61209041c8f
mwijaya3/Training
/CSTraining/CodingSchool/Bootcamp - Intuition/hashlp.py
1,951
3.9375
4
class Entry(dict): """ Definition for an Entry in the Hash Table (Dictionary) """ def __init__(self, key, value): """ Constructor key = the key value value = the value for this node next = the next entry """ super().__init__(key=key, value=value, next=None) def compare(self, key): """ Comparato...
47f203e02ceadcb7b9def5c838b85ed50fda6f5f
gerwinboschloo/DevNet
/circle.py
93
3.65625
4
from math import pi def area_of_circle(r): return pi*(r**2) print(area_of_circle(10))
ad6f4c5c5171864eb9959eb96bf68ab5fbe0b6c4
averycordle/csce204
/exercises/apr20/replace_stars.py
259
3.921875
4
def replace_stars(): global word answer = "" for letter in word: if letter == "*": answer+="." else: answer+=letter word = answer word = "a*b*c*d*e" replace_stars() print(word)
e09b2ec77fdcadc6983e4b6f705a047a9e0a0307
jsaysay/simple-FTP
/FTPser.py
6,499
3.578125
4
#Jonathan Saysay #Server code # import socket import sys import os import commands listenPort = int(sys.argv[1]) # Create a welcome socket for control connection. welcomeSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to the port welcomeSock.bind(('', listenPort)) # Start listening on th...
eec189a6e3552ce3442e5170f70232a8011db4e9
LShun/cs50-psets
/2019/pset7/similarities/helpers.py
1,396
3.5625
4
from nltk.tokenize import sent_tokenize def lines(a, b): """Return lines in both a and b""" match = set() # when reach a newline character # split the strings setA = set(a.split('\n')) setB = set(b.split('\n')) # test it with another string for line in setA: if line in se...
674a7986a16ec070a3386d9165f3176f7293dce1
AndrewMiranda/holbertonschool-machine_learning-1
/reinforcement_learning/0x00-q_learning/2-epsilon_greedy.py
868
3.765625
4
#!/usr/bin/env python3 """File that contains the function epsilon_greedy""" import numpy as np import gym.envs.toy_text.frozen_lake as frozen_lake def epsilon_greedy(Q, state, epsilon): """ Function that uses epsilon-greedy to determine the next action Args: Q is a numpy.ndarray containing the q-tab...
b1b07c4a15e70790a1872e7d580448691fffa2c0
simonhuang/LeetCode
/python_solutions/bst_max_path_sum.py
1,276
3.703125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def maxPathSum(self, root): """ :type root: TreeNode :rtype: int """ if root is N...
156aa1f1b2cc10339402d353f9791205b06e570f
berkaydasgil/LeetCode
/count-of-matches-in-tournament/count-of-matches-in-tournament.py
676
3.578125
4
class Solution: def numberOfMatches(self, n: int) -> int: result = 0 def backtrack(n,result): if n == 0: # print('returned') return result if n % 2 == 0 : # print('even') n = n/2 resul...
57a6e59816be829e9e6d4cf17a67906e6ccf12ed
AlphaProgramador-Edutech/edutech-pr
/Somador_interativo.py
314
4.03125
4
Numero1_str = input("Digite um número: ") Numero2_str = input("Digite o número que você gostaria que fosse acrescentado ao número dito: ") Numero1 = int(Numero1_str) Numero2 = int(Numero2_str) numeroResultante = (Numero1 + Numero2) print("A soma dos números que você digitou é", numeroResultante)
7477b1a5ad5aa2df3d7b407de88f7dc383553ef0
ParulProgrammingHub/assignment-1-Bunnyyash
/Q12.py
136
3.765625
4
n=input("enter the no. to perform operation ""n+nn+nnn"" :") a=n*11 b=n*111 s=n+a+b print "Answere to the following operation :",s
16401f0939081517eb5812a620963bf0a29b71ff
Jungeol/algorithm
/leetcode/easy/1221_split_a_string_in_balanced_strings/hsh2438.py
722
3.671875
4
""" https://leetcode.com/problems/split-a-string-in-balanced-strings/ Runtime: 28 ms, faster than 67.64% of Python3 online submissions for Split a String in Balanced Strings. Memory Usage: 13.8 MB, less than 100.00% of Python3 online submissions for Split a String in Balanced Strings. """ class Solution: def bala...
7bd8d543aa6e46d58c1e524ce636f9aba72c27e6
dineshfox/learnpython
/bankAccount/trycatch.py
752
4.125
4
##while True: ## ## print ("Enter any number?") ## number = int(input()) ## ## if number =='q': ## break ## elif number !='q': ## print(number) ## ## else: ## print("enter something") def checkType(prompt): while True: try: value=float(input(prompt)...
96071bd6c69a7ed1e5fc2584f180d73bfefe9625
MegIvanova/PythonTesting
/PythonTests/TestingPython/PythonLab1Exercise11.py
304
3.6875
4
''' Created on Sep 8, 2015 @author: Meglena ''' #Python Program to Print all factorials Numbers in an Interval 0 to 20 def main(): f = 1 n = 0 for a in range (0,20): n += 1 f = f * n print(n,"! = ",f) main() # prints all factorials from 1 to 20
5289d23ceddb3b96327b0b3dff2230013405917d
xibaochat/crescendo_projects
/10days_stats/4day/1.py
797
3.90625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT def factorial(n): if n == 0: return 1 return n * factorial(n-1) def binomial_calculation(n): f = factorial(m) / (factorial(m - n) * factorial(n)) return f def calculate_possibility(f, m, n): return f * (p**n) * ((1 - p)*...
d60a229a041d8aac66662cdcb651fb9f67c3fa31
shuoshuoge/system-development
/stuent-grade.py
2,539
4.28125
4
class Student: ''' Student(学号、姓名、性别、专业) ''' def __init__(self, id, name, gender, major): self.id = id self.name = name self.gender = gender self.major = major self.stuCourseGrade = dict() self.getCredit = 0 def addCourseGrade(self, cou...
fc884e1df5110034aff7f2893ea4b629518d77f0
Ayoya22/Learning-Python-HardWay
/ex3-number_maths.py
253
4.34375
4
print("This is a mathematics operation", 5 + 3 / 2 - 4 * 6 % 5) print('Is 5 greater than 2?', 5>2) print("-7 is greater than 5", -7 > 5 ) print("8 is less than or equal to -10?", 8 <= -10) #Simple program to show how python handles mathematical symbols.
be8e012d2d16de7d3e0bf102d5702789bf9ff3a3
hyc121110/LeetCodeProblems
/String/wordBreak.py
1,603
4
4
''' Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Note: -The same word in the dictionary may be reused multiple times in the segmentation. -You may assume the dictionary does no...
a7e9d36fec3ebd2c97f9a4e7dfca8da0d79f9509
timothyfranklinpowers/ciss441
/a2.populate.sqlite.PowersTimothy.py
2,382
3.578125
4
import json import csv import sqlite3 import sys dbfile = 'flavors_of_cacao.db' #the database file conn = sqlite3.connect(dbfile) #connect to the database def main(): create_table() #create the table open_file() #open file print('Got it!')#confirmation conn.close() #close the connection sys.exit(1)...
ec0ff18ac0d8e6202b0efbe5ae33052dc059524f
smbehura/Pong
/run_pong.py
5,255
3.84375
4
''' Used to run and test Pong ''' import pygame from example_menu import main as menu from example_menu import alt_main as instructions from example_menu import nalt_main as options import time from board_class import Board pygame.init() window_size = [500, 500] # width, height screen = pygame.display.set_mode(windo...
658844c53687bcc993f9af465d534b1f6a40efa5
powermano/pycharmtest
/leetcode/generateParenthesis.py
894
3.546875
4
class Solution(object): def generateParenthesis(self, n): def generate(p, left, right, parens=[]): if left: generate(p + '(', left - 1, right) if right > left: generate(p + ')', left, right - 1) if not right: parens += p, return parens retu...
dde9c69797d2273e4796c542aa46ea280f672522
Satyavrath/pythonBasics
/stringLength.py
410
4.0625
4
def string_length(name): count = 0 for string in name: count += 1 return count print(string_length("Hello")) def test_stringLength(): assert string_length("Hello") == 5 assert string_length("myName") == 6 print("The string works fine") test_stringLength() # last letter of str...
4b41d52dfde3200beddba5cf5d52f9d8ca42cb60
Maan17/python
/Lambda/map()filter()reduce().py
321
3.546875
4
#filter() with lambda li=[5,7,22,97,54,62,77,23,73,61] final_list=list(filter(lambda x:(x%2!=0),li)) print(final_list) #map() with lambda final_list=list(map(lambda x:x*2,li)) print(final_list) #lambda() to get sum of a list from functools import reduce li=[5,8,10,20,50,100] sum=reduce((lambda x,y:x+y),li) print(sum)...
e856c339cddfce18b1484bf3ea7aa860c88f71fd
yujinee/scimat2
/science/RotationalMotion/simplerelations/simplerelations.py
2,936
3.84375
4
import random # A girl sitting on a merry go round, moving in counter clockwise through an arc length of s m. If the angular diplacement is r rad, how far she is from the center of merry go round ? # If the wheel of radius r m has a angular velocity of w rad/s, what is the velocity of the point at the circumference of...
3780d8293d9ace18020363154098a08d7f4d3362
banana-galaxy/Discord_challenges
/encrypt_decrypt.py
2,569
4.1875
4
# very simple encrypting logic where when you encrypt something like a string, it takes every character in the string takes the places where it appears in the string and puts all that information # together in another string def encrypt(text): # initiating and setting some variables text = str(text) text ...
bf7fa73bf5818682f99e683596c52916abc4ca9a
gavendanoc-learning/terminal
/flows/money.py
400
3.625
4
def piggyBank(): count = 0 history = [] def moneyCounter(amount): nonlocal count # for inmtable variables count += amount history.append(amount) return (count, history) return moneyCounter myPiggyBank = piggyBank() print("total : ", myPiggyBank(10)) print("total : ", m...
1a4c1b3275d7a84677003bf28ccee551633989fd
nzsnapshot/car_game_pygame
/car.py
1,931
3.875
4
import pygame class Car(): """A class to manage the car.""" def __init__(self, ai_game): """Initialize the car and set its starting position.""" self.screen = ai_game.screen self.settings = ai_game.settings self.screen_rect = ai_game.screen.get_rect() # Load the car...
fce00ef4b8a79e91a392a6509f9d4298eadaf934
shadiqurrahaman/python_DS
/tree/level_order_bottom_up.py
1,549
3.96875
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None class Tree: def print_tree(self,node): if node is None: return self.print_tree(node.left) print(node.data) self.print_tree(node.right) def levelOrder...
e9def8e6e5bb452c5d56a9e887b02963d1c62619
Smoow/MIT-UNICAMP-IPL-2021
/set1/problemas/p1_3.py
195
3.546875
4
dividend = 31 divisor = 5 tmp = divisor rest = 0 counter = 0 while (tmp < dividend): tmp += divisor counter += 1 rest = dividend - (divisor * counter) out = (counter, rest) print(out)
38589327cc90d25c6c82b31fb8081a4d1a5011e4
juliano60/scripts_exo
/ch3/exo2.py
150
3.84375
4
#!/usr/bin/env python3 ## calculate the sum of a list of numbers from 1 to 1000 numbers = range(1,1001) print("Total is: {}".format(sum(numbers)))
23dff04d0b822f7baabdbd6349bf11d4f4e223c4
Luckyaxah/leetcode-python
/二叉树_折纸问题.py
712
4.0625
4
# 给定一个二叉树,返回它的中序遍历。 # 规则:若树为空,则空操作返回,否则从根节点开始(注意不是先访问根节点)中序遍历根节点的左子树,最后访问根节点 # 最后中序遍历右子树 # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def printAllFolds(N): printProcess(1,N,True) # down == True 凹, down == Fa...
742bcbea94c99c058085d3d0fde9ab465a144cd8
mattmaniak/initial_rpg
/src/characters.py
1,650
3.765625
4
from random import randint class __Character(): """A sketch of the all game characters.""" def __init__(self, name, hp, attack, armor, speed): self.name = name self.attack = attack self.armor = armor self.speed = speed self.hp = hp self.__prng_spread = 1 d...
ee8418ec927e244df1019eb7e450d6fce80b4823
wellqin/USTC
/DataStructure/二叉树/二叉树遍历/postOrder.py
2,147
4
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: postOrder Description : Author : wellqin date: 2020/1/31 Change Activity: 2020/1/31 ------------------------------------------------- """ # 构建了层序遍历: [0, 1, 2, 3, 4, 5, 6]的二叉树 class Node(object): ...
3b8ec8f55619e64bd23b260e77fb42119de1099f
ankitk2109/HackerRank
/Data Structures/Day4/leftRotation.py
701
3.828125
4
#Problem Statement: https://www.hackerrank.com/challenges/array-left-rotation/problem #!/bin/python3 import math import os import random import re import sys def leftRotate(n,d,arr): temp = 0 #To store the first element which would be removed in each iteration for i in range(d): #Running loop 'd' times ...
8f1e6599be4a5ec6b3a71e0d40470c50803c0e7a
youjiahe/python
/python2/day2/partial_func.py
200
3.53125
4
#!/usr/bin/env python3 from functools import partial # def add(a,b,c,d,e): # return a+b+c+d+e # print(add(10,20,30,40,50)) # newadd=partial(add,10,20,30,40) # print(newadd(99)) # print(newadd(12))
8831cfbdf63c4f8f4745fd8bc71d9458c24e109e
ansonwhho/orbital-chaos
/Revolver.py
9,144
4.4375
4
''' ' R E V O L V E R ' 28/03/2021 Alba Spahiu, Joel Beckles, Anson Ho This is a 3D Gravity simulator: an interactive game, in which the user can create multiple dots at the click of the mouse -> the more the mouse is kept clicked the more the mass. Each dot interacts with each other. There is an initial dot ...
0f090f590e5798f801bad75ebfeea81bc23b3e49
HyoHee/Python_month01_all-code
/day11/ecercise06.py
723
4.34375
4
""" 创建子类:狗(跑),鸟类(飞) 创建父类:动物(吃) 体会子类复用父类方法 体会 isinstance 、issubclass 与 type 的作用. """ class Animal: def eat(self): print("吃") class Dog(Animal): def run(self): print("跑") self.eat() class Brid(Animal): def fly(self): print("飞") d01 = Dog() ...
59ddaae6995f350ea479d199a4fc21dec0a0bebc
ireeX/LeetCode_Python
/Solution/21_Merge_Two_Sorted_Lists.py
1,295
4.15625
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class LinkedList: def __init__(self, head:ListNode): self.head = head def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: if l1 == None and l2 == None:...
1763a56f62053d8c93011f471699426cf3a1bde0
fmaindl/MIT-CS-PS0
/answers.py
1,621
4
4
import numpy import matplotlib initialization=input("Greetings! Let's play a game. I want you to give me two numbers," "and I will tell you how much the first number raised to the power of," "the second number is. I will also tell you what the log in base 2 of," ...
7a560114b10bf262385c633f27574853f702a58d
zhaochuanshen/leetcode
/Remove_Linked_List_Elements.py
829
3.890625
4
''' Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6 Return: 1 --> 2 --> 3 --> 4 --> 5 Credits: Special thanks to @mithmatt for adding this problem and creating all test cases. ''' # Definition for singly-linked list. # class ListNo...
562e422693d44784282e90184d8789f595298b5d
prettYPies/LR_1
/5.py
390
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 4 22:08:19 2017 @author: joe27 """ i = 0 inText = input("Ваш текст: ") splitText = inText.split() print("Итоговая строка: ") while i < len(splitText): s = splitText[i] if s[0].isupper() == True: splitText[i] = splitText[i].upper() print(splitText[i],...
3ba8ba62a9ba43c77b3ae23e8266536b29d25966
choiwon7/MSE_Python
/ex300.py
646
3.5625
4
per = ["10.31", "", "8.00"] for i in per: #per을 i에 대입한다. try: # 실행코드 print(float(i)) #----->per에 ""가 있어서 실수로 변환이 안되어 오류가 발생할것임. except: #예외가 발생할경우 print(0) #0으로 표현해라 else: #예외가 발생하지않으면 print("clean data") #clean data를 실행해라 finally: ...
bbc8393f8f7b35039319123bace3bac1a20a66da
XingXing2019/LeetCode
/LinkedList/LeetCode 61 - RotateList/RotateList_Python/main.py
1,084
3.828125
4
# Definition for singly-linked list. from typing import List class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def rotateRight(head: ListNode, k: int) -> ListNode: if head is None: return head def getLen(head: Li...