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
37e2bd3cbbcf23950579ca220ef8f487ce94f03c
Slowika/AI_Ethics
/ft_experiments.py
1,915
3.703125
4
from utilities import * DEFAULT_FILTER_PARAMS = { "filter": "quantile", "threshold": 0.01 } def run_projection_experiment(words, embeddings, word1, word2, filter_params=DEFAULT_FILTER_PARAMS): """ A function for calculating distances and projections between two words in the embedded space. :param...
3a4b6c64075b96c1566276a7056ca86010186986
rajithakari333/rajithakari
/strcmp.py
146
3.796875
4
str1=input().split() if(len(str1[0])>len(str1[1])): print(str1[0]) elif(len(str1[0])==len(str1[1])): print(str1[1]) else: print(str1[0])
80606851234ce8412342ca085259f61c0f989073
rajithakari333/rajithakari
/maximum.py
223
3.890625
4
def largest(arr,n): max=arr[0] for i in range(1,n): if arr[i]>max: max=arr[i] return max n = int(input()) arr = input() l = list(map(int,arr.split(' '))) n=len(l) ans=largest(l,n) print(ans)
bae515dfed1325c4a9260c6ac501d53b57364c64
hend0472/sadness_script
/sadness.py
5,385
3.53125
4
import time import tkinter from tkinter import * import datetime as dt import tkinter.messagebox monthly_wage = 0 days_field = 0 days_normal = 0 hours_normal = 0 fixed_expenses = 0 hourly = 0 minutely = 0 secondly = 0 real_secondly = 0 s = "0:00" hour, minute = s.split(':') hour = 0 minute = 0 def retrieve_input(): ...
4ac182f86ebcf77f442bdf343dadeef34b65f162
moon-j-h/python-study-1st
/sql/02_sql_hw.py
708
3.8125
4
import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() c.execute("INSERT INTO inventory VALUES('Ford', 'Focus', 10)") c.execute("INSERT INTO inventory VALUES('Honda', 'Civic', 11)") c.execute("INSERT INTO inventory VALUES('Ford', 'Ranger', 12)") c.execute("INSERT INT...
4e0730d471146edd5bb196ff536c023e67eb5453
akash123456-hub/hello.py
/vns2.py
836
4.15625
4
''' thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"] print(thislist[-4:-1]) ''' ''' class Dog: # Class Variable animal = 'dog' # The init method or constructor def __init__(self, breed, color): # Instance Variable self.breed = bre...
39084936f046b1637f21f6b4ffcf43ff2d6772fb
akash123456-hub/hello.py
/vns.py
197
4.09375
4
#thistuple = ("apple", "banana", "cherry", "apple", "cherry") #print(thistuple) mytuple = ("apple", "banana", "cherry") myit = iter(mytuple) print(next(myit)) print(next(myit)) print(next(myit))
6d7316d1cfaec8205b21061ecd276d07a974237d
akash123456-hub/hello.py
/factorial03.py
255
4.0625
4
def factorial_iter(n): product = 1 for i in range(n): product = product*(i+1) return product def factorail_recursive(n): if n ==1 or n==0: return 1 return n*factorial_recursive(n-1) f = factorial_recursive(0) print(f)
d8dd4313bd50188f028e40120d7b9dc41dacea4d
akash123456-hub/hello.py
/problem02.py
414
3.640625
4
class Calculator: def __init__(self,num): self.number = num def square(self): print(f"The value of {self.number}square is{self.number**2}") def SqaureRoot(self): print(f"The value of {self.number}sqaure root is{self.number**0.5}") def cube(self): print(f"The value of...
13bf2cf48d9aea5486656c5bb6784d98fadfebbf
akash123456-hub/hello.py
/Country.py
871
3.640625
4
class India(): def capital(self): print("New Delhi is the capital of india") def language(self): print("Hindi is the most widely spoken language of india") def type(self): print("India is a developing country") class USA(): def capital(self): print("Washington is the capi...
54ade87c563db585b2f3651fbf1403b4f1c458b1
akash123456-hub/hello.py
/company03.py
144
3.5
4
class Number: def sum(self): return self.a + self.b + self.c num = Number() num.a = 12 num.b = 34 num.c = 67 s = num.sum() print(s)
06ec8cf1459d3e9d3e25fb27aa4f390f86734bd7
akash123456-hub/hello.py
/fruits.py
118
3.609375
4
fruits = ['Banana','Watermelon','Grapes','Mangoes'] i = 0 while i<len(fruits): print(fruits[i]) i = i + 1
0dd6ab92f4fe4ed712d6b38d19d03f23a84e6d9d
akash123456-hub/hello.py
/Parents.py
377
3.875
4
class Mother: mothername = "" def mother(self): print(self.mothername) class Father: fathername = "" def father(self): print(self.fathername) class Son(Mother,Father): def parents(self): print("Father:",self.fathername) print("Mother:",self.mothername) s1 = Son() s1.f...
6131ef86b87a824d4fa564b646b180ae109b4264
ApkaevIS/Laboratornie
/21.py
156
3.703125
4
x = float(input('x: ')) y= int(input('y: ')) eps = 0.0001 count = 0 while abs(y-x) > eps: y=(y+x/y)/2 count= count +1 if count==10: print(y) exit(1)
286e966846095295095c4bfcc1ec34af216363f1
Eduard-z/SeleniumwithPython
/UnitTest_Framework_methods.py
1,015
3.671875
4
import unittest def set_up_module(): # will be executed before executing any class or any method presented in the test-case print("setUpModule") def tear_down_module(): # will be executed after completing everything presented in the python module print("tearDownModule") class AppTesting(unittest.TestCas...
abaa9a0392c8d9b76f1d6382750db79d97a0ab79
kots14/a-patterns
/src/python/HollowTrianglePattern.py
600
4
4
#created by ymchandaliya #function to make hollow triangle def HollowTrianglePattern(n): for i in range(n-1): for j in range(i+1): if(j==0 or j==i): print('*', end = " ") #prints '*' only to the edge of the triangle else: print(' ', end = " ") ...
3186b45c5f7db5c7b048df4a360ea198b60cd69a
TheRealTimCameron/cp1404Practicals
/prac_08/unreliable_car_test.py
437
3.578125
4
from prac_08.unreliable_car import UnreliableCar good_car = UnreliableCar("good car", 100, 90) unreliable_car = UnreliableCar("unreliable car", 100, 9) for i in range(1, 12): print("Attempting to drive {}km:".format(i)) print("{:12} drove {:2}km".format(good_car.name, good_car.drive(i))) print("{:12} drov...
2106f83a2dccafddfeebc846f551368f85ab756a
clementeqp/Python_Clemen
/40-Tkinter_Label.py
513
3.765625
4
from tkinter import * root =Tk() miFrame=Frame(root, width=500, height=450) miFrame.pack() # creamos un label y luego empaquetamos, adapta el # contenedor padre al tamaño del texto o usamos place(x=int, y=int) miLabel1=Label(miFrame,text="Hola que tal estas .....",fg="red", font=("Arial", 20)) #miLabel1...
9421a2ef16ebab41bc62af119d3a39013ae06099
clementeqp/Python_Clemen
/09-In_Not.py
383
4.3125
4
# con una lista trabajadores=["Laura", "Manolo", "Jorge", "Teresa"] if "Manolo" in trabajadores: print("Manolo esta en la lista") else: print("Manolo no esta en la lista") # con un string trabajadores2="Laura", "Manolo", "Jorge", "Teresa" if "Manolo" not in trabajadores2: print("Man...
105d485fe77dd7be45bd150184378708c2fc33ac
clementeqp/Python_Clemen
/02-listas.py
845
3.890625
4
# nombreLista=[entero, "elem2", elem3.......] Diferente tipo from typing import ChainMap trabajadores=["Ana", "Maria", "Antonio","Clemen"] print(trabajadores) #tamaño lista print(len(trabajadores)) #invertir lista trabajadores.reverse() print(trabajadores) #añadir elementos trabajadores.append(5...
57a58138224f6ff1506922cf48877b15473ba84f
clementeqp/Python_Clemen
/16-Bucle_Diccionarios.py
338
4.0625
4
capitales={"China":"Pekín", "India":"Nueva Delhi", "Indonesia":"Yakarta", "Japón":"Tokyo"} for c in capitales: valor=capitales[c] print((c + " ").ljust(25,"-"),valor) # imprimimos el diccionario print(capitales.items()) # con for for c,v in capitales.items(): print((c + " ").ljust(...
83305542c8218101457e109e1d526331cc34e117
clementeqp/Python_Clemen
/41-Tkinter_Entry_Label.py
1,305
3.765625
4
from tkinter import * raiz=Tk() miFrame=Frame(raiz, width=1000, height=550) miFrame.pack() # creamos una entrada de texto en miFrame cuadroTexto=Entry(miFrame) #cuadroTexto.place(x=50, y=50) # lo hacemos con grid cuadroTexto.grid(row=0, column=1) # etiqueta nombreLabel=Label(miFrame, text="Nombre: "...
1cfd08df97ae7e4228ec082f096432bb2beee189
Brokenshire/codewars-projects
/Python/six_kyu/in_array.py
1,066
4.28125
4
# Python solution for 'Which are in?' codewars question. # Level: 6 kyu # Tags: REFACTORING, ARRAYS, SEARCH, ALGORITHMS, LISTS, DATA STRUCTURES, and STRINGS. # Author: Jack Brokenshire # Date: 11/06/2020 import unittest from re import search def in_array(array1, array2): """ Finds which words within array1 a...
8661ec95819888190ac3159f42ffc3ebcd5b0423
Brokenshire/codewars-projects
/Python/seven_kyu/maskify.py
1,140
3.578125
4
# Python solution for "Credit Card Mask" codewars question. # Level: 7 kyu # Tags: Algorithms, Utilities, and Strings. # Author: Jack Brokenshire # Date: 23/03/2020 import unittest def mask(cc): """ Function mask, which changes all but the last four characters into '#'. :param cc: a string value. :re...
850ef1bc3215064426abed63def8de9a52fd8cc4
Brokenshire/codewars-projects
/Python/six_kyu/likes.py
1,552
4.375
4
# Python solution for 'Who likes it?' codewars question. # Level: 6 kyu # Tags: Fundamentals, Formatting, Algorithms, and Strings. # Author: Jack Brokenshire # Date: 19/02/2020 import unittest def likes(names): """ You probably know the "like" system from Facebook and other pages. People can "like" blog post...
12bc40dff0e1cc2211ec5f4bc77d7aa08e1b881b
Brokenshire/codewars-projects
/Python/seven_kyu/nb_year.py
1,016
4.03125
4
# Python solution for 'Growth of a Population' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS. # Author: Jack Brokenshire # Date: 23/05/2020 import unittest def nb_year(p0, percent, aug, p): """ Finds the amount of years required for the population to reach a desired amount. :param p0: integer of...
a6c9f153e08a44a65cd9cd314229b7b18a7a60f6
Brokenshire/codewars-projects
/Python/seven_kyu/find.py
636
4.53125
5
# Python solution for 'Sum of all the multiples of 3 or 5' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS. # Author: Jack Brokenshire # Date: 18/05/2020 import unittest def find(n): """ Finds the sum of all multiples of 3 and 5 of an integer. :param n: an integer value. :return: the sum of al...
f66d99f8800f29f0da719a02ca7df5666637ff11
Brokenshire/codewars-projects
/Python/seven_kyu/square_digits.py
891
4.4375
4
# Python solution for 'Simple Pig Latin' codewars question. # Level: 7 kyu # Tags: Fundamentals, Mathematics, Algorithms, and Numbers # Author: Jack Brokenshire # Date: 11/02/2020 import unittest def square_digits(num): """ Welcome. In this kata, you are asked to square every digit of a number. For examp...
19937ad4042fe640d47bc40486434f0a2fd86c3e
Brokenshire/codewars-projects
/Python/four_kyu/permutations.py
962
4.1875
4
# Python solution for 'Permutations' codewars question. # Level: 4 kyu # Tags: ALGORITHMS, PERMUTATIONS, and STRINGS. # Author: Jack Brokenshire # Date: 13/05/2020 import unittest import itertools def permutations(string): """ Create all permutations of an input string and remove duplicates, if present. This...
e48a8a7273db7f74a15710e01769a58535e3fdcd
Brokenshire/codewars-projects
/Python/seven_kyu/in_asc_order.py
1,046
4.125
4
# Python solution for "Are the numbers in order?" codewars question. # Level: 7 kyu # Tags: ALGORITHMS, FUNDAMENTALS, MATHEMATICS, NUMBERS, CONTROL FLOW, BASIC LANGUAGE FEATURES, and OPTIMIZATION. # Author: Jack Brokenshire # Date: 06/04/2020 import unittest def in_asc_order(arr): """ Determines if the given...
51e7bad81151e1c9bd352e3fef3b2969faae88a8
Brokenshire/codewars-projects
/Python/seven_kyu/max_diff.py
997
4.0625
4
# Python solution for 'max diff - easy' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS, MATHEMATICS, ALGORITHMS, NUMBERS, COLLECTIONS, LISTS, DATA STRUCTURES, AND ARRAYS. # Author: Jack Brokenshire # Date: 16/07/2020 import unittest def max_diff(lst): """ Finds the difference beteween the largest and...
cf815b0af79820535c15167786267ec93245cfc2
Brokenshire/codewars-projects
/Python/six_kyu/count_smileys.py
1,811
4.21875
4
# Python solution for 'Count the smiley faces!' codewars question. # Level: 6 kyu # Tags: Fundamentals, Regular Expressions, Declarative Programming, Advanced Language Features, and Strings. # Author: Jack Brokenshire # Date: 06/02/2020 import unittest def count_smileys(arr): """ Given an array (arr) as an a...
6ab627974a887abeefed0d56b6ac03cc75475092
Brokenshire/codewars-projects
/Python/seven_kyu/sum_all.py
716
3.921875
4
# Python solution for 'Gauß needs help! (Sums of a lot of numbers)' codewars question. # Level: 7 kyu # Tags: Fundamentals, Mathematics, Algorithms, Numbers, Performance, and Integers. # Author: Jack Brokenshire # Date: 05/02/2020 import unittest def f(n): """ Function finds the sum from 1 to 'n'. :param...
a5746557d0b41917a459998bc393246117f4ba40
Brokenshire/codewars-projects
/Python/eight_kyu/reversed_string.py
725
4.15625
4
# Python solution for 'Reversed Strings' codewars question. # Level: 8 kyu # Tags: FUNDAMENTALS and STRINGS. # Author: Jack Brokenshire # Date: 27/06/2020 import unittest def solution(string): """ Complete the solution so that it reverses the string passed into it. :param string: a string value. :ret...
ffa315450ca504e52aa8d42b1a66e75bc8273040
Brokenshire/codewars-projects
/Python/seven_kyu/reverse_letter.py
880
4.25
4
# Python solution for 'Simple Fun #176: Reverse Letter' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS. # Author: Jack Brokenshire # Date: 03/05/2020 import unittest def reverse_letter(string): """ Given a string str, reverse it omitting all non-alphabetic characters. :param string: a string valu...
3187a208fd79756ce2f348354e0439249a5d786a
Brokenshire/codewars-projects
/Python/six_kyu/find_missing_number.py
991
4.21875
4
# Python solution for 'Number Zoo Patrol' codewars question. # Level: 6 kyu # Tags: ALGORITHMS, PERFORMANCE, MATHEMATICS, and NUMBERS. # Author: Jack Brokenshire # Date: 09/05/2020 import unittest def find_missing_number(numbers): """ akes a shuffled list of unique numbers from 1 to n with one element missin...
2227299998c5819a79b6ad295b37d46e55ad626f
Brokenshire/codewars-projects
/Python/seven_kyu/odd_or_even.py
972
4.46875
4
# Python solution for 'Odd or Even?' codewars question. # Level: 7 kyu # Tags: Fundamentals, Arithmetic, Mathematics, Algorithms, Numbers, and Arrays. # Author: Jack Brokenshire # Date: 15/02/2020 import unittest def odd_or_even(arr): """ Given a list of numbers, determine whether the sum of its elements is ...
a77599b1b182804ef47d14662e3e4a6f8640af86
Brokenshire/codewars-projects
/Python/seven_kyu/get_count.py
806
4.1875
4
# Python solution for 'Vowel Count' codewars question. # Level: 7 kyu # Tags: Fundamentals, Strings, and Utilities # Author: Jack Brokenshire # Date: 09/02/2020 import unittest def get_count(inputStr): """ Return the number (count) of vowels in the given string. We will consider a, e, i, o, and u as vowe...
bca58d3cfb38f49d0c0a227539eb638498ae5e31
Brokenshire/codewars-projects
/Python/seven_kyu/convert_my_dollars.py
2,708
4.3125
4
# Python solution for "Currency Conversion" codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS, MATHEMATICS, ALGORITHMS, NUMBERS, and ALGEBRA. # Author: Jack Brokenshire # Date: 05/04/2020 import unittest CONVERSION_RATES = { "Argentinian Peso": 10, "Armenian Dram": 478, "Bangladeshi Taka": 1010010, "Cro...
4c1ef91c4464eb933dfeb493523e27d408a89b30
Brokenshire/codewars-projects
/Python/seven_kyu/even_chars.py
1,045
4.5
4
# Python solution for 'Return a string's even characters.' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS, STRING, AND SARRAYS. # Author: Jack Brokenshire # Date: 16/08/2020 import unittest def even_chars(st): """ Finds all the even characters in a string. :param st: string value. :return: a ...
e9f2949472cd7fc90b3bae516e2afe2d6d1fc920
Brokenshire/codewars-projects
/Python/seven_kyu/sort_numbers.py
582
4.03125
4
# Python solution for 'Sort Numbers' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS. # Author: Jack Brokenshire # Date: 06/06/2020 import unittest def sort_numbers(nums): """ Sorts an array of numbers. :param nums: array of integers. :return: sorted array. """ if nums: return ...
1790d87e28600368578483b8c0511619df107563
Brokenshire/codewars-projects
/Python/seven_kyu/get_middle.py
1,284
4.15625
4
# Python solution for 'Get the Middle Character' codewars question. # Level: 7 kyu # Tags: Fundamentals, and Strings # Author: Jack Brokenshire # Date: 10/02/2020 import unittest def get_middle(s): """ You are going to be given a word. Your job is to return the middle character of the word. If the word's len...
35d959494dc98cd3d0dcce40d8ff91e835d6e573
Brokenshire/codewars-projects
/Python/seven_kyu/greet.py
716
3.71875
4
# Python solution for 'Greet Me' codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS and STRINGS. # Author: Jack Brokenshire # Date: 20/05/2020 import unittest def greet(name): """ Greets a person with their name capitalized. :param name: a string. :return: greets that name, capitalized and ends w...
65dcd2a0dfdbec01e569d71f32396b6eaaa813b4
Brokenshire/codewars-projects
/Python/seven_kyu/longest.py
838
3.875
4
# Python solution for Two to One codewars question. # Level: 7 kyu # Tags: Fundamentals # Author: Jack Brokenshire # Date: 24/01/2020 from collections import OrderedDict import unittest def longest(s1, s2): """ Returns a new sorted string, the longest possible, containing distinct letters.""" word = "".join(...
594ad29599b3dd0c697d48edf9fd42c561c97ebd
Brokenshire/codewars-projects
/Python/six_kyu/roman_numerals_decoder.py
1,264
3.984375
4
# Python solution for 'Roman Numerals Decoder' codewars question. # Level: 6 kyu # Tags: ALGORITHMS, PARSING, and STRINGS. # Author: Jack Brokenshire # Date: 21/05/2020 import unittest def roman_numerals_decoder(roman): """ Takes a Roman numeral as its argument and returns its value as a numeric decimal inte...
28465cb79ba68b2a2e21040272f483ef46dd9948
Brokenshire/codewars-projects
/Python/seven_kyu/stray.py
801
4
4
# Python solution for "Find the stray number" codewars question. # Level: 7 kyu # Tags: FUNDAMENTALS, NUMBERS, and ALGORITHMS. # Author: Jack Brokenshire # Date: 10/04/2020 import unittest def stray(arr): """ You are given an odd-length array of integers, in which all of them are the same, except for one sin...
204d75a486784b74f705a51a2edc7f5989d5b554
Brokenshire/codewars-projects
/Python/five_kyu/sum_pairs.py
1,845
4.1875
4
# Python solution for "Sum of Pairs" codewars question. # Level: 5 kyu # Tags: FUNDAMENTALS, PARSING, ALGORITHMS, STRINGS, MEMOIZATION, DESIGN PATTERNS, and DESIGN PRINCIPLES. # Author: Jack Brokenshire # Date: 08/04/2020 import unittest def sum_pairs(ints, s): """ Finds the first pairs to equal the integer ...
0f702ff15d1d5b9145082f6402c50e7a282d49a8
Brokenshire/codewars-projects
/Python/eight_kyu/make_negative.py
714
4.21875
4
# Python solution for 'Return Negative' codewars question. # Level: 8 kyu # Tags: FUNDAMENTALS and NUMBERS. # Author: Jack Brokenshire # Date: 11/04/2020 import unittest def make_negative(number): """ Make a given number negative. :param number: an integer value. :return: the integer as a negative nu...
8ce90fd19cf8df52af008dac2f8c61ad9054b3fb
Brokenshire/codewars-projects
/Python/five_kyu/pig_it.py
880
4.21875
4
# Python solution for 'Square Every Digit' codewars question. # Level: 5 kyu # Tags: Algorithms # Author: Jack Brokenshire # Date: 11/02/2020 import unittest def pig_it(text): """ Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched....
5696eedb1fce1317b7e599a1a3d82c11ed318297
Brokenshire/codewars-projects
/Python/eight_kyu/bool_to_word.py
767
4.1875
4
# Python solution for 'Convert boolean values to strings 'Yes' or 'No'.' codewars question. # Level: 8 kyu # Tags: FUNDAMENTALS, BOOLEAN, and SBEST PRACTICES. # Author: Jack Brokenshire # Date: 01/05/2020 import unittest def bool_to_word(boolean): """ Complete the method that takes a boolean value and return...
cfa7febef65c5683971080f1119d2734c91dc229
thekuldeep07/SDE-SHEET
/majority element.py
745
4.15625
4
# Question :- find the majority element i.e which appear more than n//2 times # method1:- using two nested loops # o(n2) # method2:- using hashmap # O(n) # mrthod 3 :- using moore voting algorithm def findMajority(nums): maj_index=0 count=0 for i in range(len(nums)): if nums[i]== nums[maj_index...
36700216634d00bdf95f5d824c9834a1932150ee
thekuldeep07/SDE-SHEET
/Fibonacci.py
302
3.734375
4
from typing import List def nFibonacci(n,dp:List): if n<=1: return n if dp[n]!=-1: return dp[n] dp[n]=nFibonacci(n-1,dp)+nFibonacci(n-2,dp) return dp[n] if __name__=="__main__": n=int(input()) dp=[-1 for i in range(n+1)] print(nFibonacci(n,dp))
673089b2c7433e449e827e8b1b73b0292f30aaf8
thekuldeep07/SDE-SHEET
/LongestCommonSubsequence.py
523
3.5625
4
def lcs(s1,s2,i,j,memo): if i>=len(s1) or j>=len(s2): return 0 if memo[i][j]!=-1: return memo[i][j] if s1[i]==s2[j]: return 1+lcs(s1,s2,i+1,j+1,memo) else: left=lcs(s1,s2,i+1,j,memo) right=lcs(s1,s2,i,j+1,memo) memo[i][j]=max(left,right) ...
3c4dbe98f70abf7ce35901c5b7552d69b348a3f6
thekuldeep07/SDE-SHEET
/no of subarray having sum k.py
1,003
3.796875
4
# Given an unsorted array of integers, find the number of subarrays having sum exactly equal to a given number k. # Examples: # Input : arr[] = {10, 2, -2, -20, 10}, # k = -10 # Output : 3 # Subarrays: arr[0...3], arr[1...4], arr[3..4] # have sum exactly equal to -10. # Naive Solution – # A simple solutio...
1ba2ef0ed9a5b0c1ef8b13ab37ff3648ed2e0034
thekuldeep07/SDE-SHEET
/lomgestSubstringwithoutRepeating Charachters.py
3,692
4.21875
4
# Length of the longest substring without repeating characters # Difficulty Level : Medium # Given a string str, find the length of the longest substring without repeating characters. # For “ABDEFGABEF”, the longest substring are “BDEFGA” and “DEFGAB”, with length 6. # For “BBBB” the longest substring is “B”, with ...
8f1a747a43e0aa8d165d1ba48164994ecaf43a79
yterradas/advent-of-code
/2020/day02.py
968
3.609375
4
import sys, functools def parse(line): parts = line.split() ranges = [int(i) for i in parts[0].split('-')] return ranges[0], ranges[1], parts[1].strip(':'), parts[2] def part1(filename): with open(filename) as f: lines = [l.rstrip('\n') for l in f.readlines()] validpass = 0 for line in lines: ...
b00470529276f93413b5c0291648ba30c190b674
nasim-aust/AUST-CSE-4.1-Artificial-Intelligence
/offline 5/offline5.py
6,334
3.75
4
import sys import copy import math import random rook_count = 3 class Board: def __init__(self, board_size, goal): self.board_size = board_size self.goal = goal self.fitness = 0 self.queens = [] self.queens_index = {} for i in range(self.board_size-rook_count): ...
1751dbe199063c0feb24559b512bb03c7825e7f6
jxlxt/leetcode
/Python/HashTable/isHappy.py
628
3.5
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/12/18 5:54 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: isHappy.py # @Software: PyCharm class Solution: def isHappy(self, n): """ :type n: int :rtype: bool ...
a3487f7328049b1f46234d8973fc3a4a36f11239
jxlxt/leetcode
/Python/248.Strobogrammatic_NumberIII.py
1,369
3.671875
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 11/23/18 7:21 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: 248.Strobogrammatic_NumberIII.py # @Software: PyCharm class Solution: def strobogrammaticInRange(self, low, high): """ ...
6bd5ee5875020f6e31d755645e1cc1c2b894d9c6
jxlxt/leetcode
/Python/backpackIII.py
412
3.59375
4
class Solution: """ @param A: an integer array @param V: an integer array @param m: An integer @return: an array """ def backPackIII(self, A, V, m): # write your code here f = [0 for _ in range(m+1)] for (a, v) in zip(A, V): for j in range(a, m+1): ...
32216fe924ec85bebff656869a05c16d122f4290
jxlxt/leetcode
/Python/HashTable/groupStrings.py
1,072
3.5
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/12/18 6:07 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: groupStrings.py # @Software: PyCharm class Solution: def groupStrings(self, strings): """ :type strings: List[str]...
fccc9270abb1b3b47169699d4283037401efc205
jxlxt/leetcode
/Python/9.palindrome_number.py
272
3.5
4
class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0: return False res, tmp = 0, x while tmp: res = res * 10 + tmp % 10 tmp //= 10 return res == x
4ac6e3d15e22fab7609eaaf2d69e7817c2878a95
jxlxt/leetcode
/Python/test.py
2,117
3.625
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/17/18 4:28 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: test.py # @Software: PyCharm # class Solution: # def longestPalindrome(self, s): # """ # :type s: str # :...
69d9c4a74d95e2940026f64dc9570e2e9a0d5ea4
jxlxt/leetcode
/Python/plot_parabola.py
4,318
3.671875
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 12/27/18 6:24 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: plot_parabola.py # @Software: PyCharm import math import numpy as np import matplotlib.pyplot as plt class Parabola: def plot_dot(s...
2cd6324ab0ccdd64aa11dd14d85d79028c2a9451
jxlxt/leetcode
/Python/37.sudoku.solver.py
1,521
3.8125
4
class Solution: def solveSudoku(self, board): """ :type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead. """ def solve_partial_sudoku(i, j): # row by row, col by col if i == len(board): i = 0 ...
f92ba16a4ee861651d0eddcdb35b11f64b7dec97
jxlxt/leetcode
/Python/QueueStack/evalRPN.py
940
3.59375
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/2/18 9:03 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: evalRPN.py # @Software: PyCharm class Solution: def evalRPN(self, tokens): """ :type tokens: List[str] :rty...
912b108e055f11f9e0a02b43052ae47d4b37b3ec
jxlxt/leetcode
/Python/156.binary_tree_upside_down.py
678
3.875
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 upsideDownBinaryTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ ...
7a3f175b6d94f14dd54b3662ec4637789d4e4420
jxlxt/leetcode
/Python/N-aryTree/postorder.py
722
3.5
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/8/18 9:54 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: postorder.py # @Software: PyCharm """ # Definition for a Node. class Node(object): def __init__(self, val, children): self.va...
3a04d9ea89711400361c76a3b3f9f323da38249b
jxlxt/leetcode
/Python/HashTable/twoSumIII.py
1,089
4.0625
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/12/18 6:14 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: twoSumIII.py # @Software: PyCharm class TwoSum: def __init__(self): """ Initialize your data structure here. ...
c2ae016934a2a2b59de50aee0d3c75216b7fa8eb
jxlxt/leetcode
/Python/BinarySearch/split_array_largest_sum.py
999
3.578125
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 9/28/18 10:57 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: autocomplete_System.py # @Software: PyCharm class Solution: def splitArray(self, nums, m): """ :type nums: List[int...
afda460ff4379d52d62ae45cd8e4cc29d7bce96c
jxlxt/leetcode
/Python/79.word_search.py
1,267
3.828125
4
class Solution: def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool """ # corner case if not board: return True if not word: return False row, col = len(board), len(board[0]) for i in range(row): ...
9a46e83add0a32fe4adffb2049526b64ea661426
jxlxt/leetcode
/Python/Trie/MapSum.py
1,310
3.640625
4
#! /Users/xiaotongli/anaconda3/bin/python # -*- coding: utf-8 -*- # @Time : 10/3/18 8:28 PM # @Author : Xiaotong Li # @School : University of California, Santa Cruz # @FileName: MapSum.py # @Software: PyCharm class TrieNode(): """ implement a Trie data structure """ def __init__(self, count = 0): ...
eba3bf66b03ed86f58753aa6805e7505ff9502cd
jxlxt/leetcode
/Python/44.Wildcard_Matching.py
1,242
3.6875
4
class Solution: def isMatch(self, source, pattern): """ :type s: str :type p: str :rtype: bool """ # memoery search return self.isMatch_helper(source, 0, pattern, 0, {}) def isMatch_helper(self, source, i, pattern, j, memo): # determine wh...
d85fc53158e06d73441712a6401b59bf3dd3ebf8
VicSanNun/DeterminantePython
/main.py
2,944
4.1875
4
#@author: Victor Nunes #Estudante de Fsica e Engenharia #Calcular Determinante de Matrizes bsicas #v.1.0 - 13/05/2018 00:20 #Definindo Funes para Calcular o Determinante #Ordem 2 def ordem_2(a11, a12, a21, a22): det = ((a11*a22)-(a21*a12)) return det #Ordem 3 def ordem_3(a11, a12, a13, a21, a22, a23, a31, a32,...
b1d3f6edbe21e683f6e8596c56ad8a8b0a288ded
Zizo001/Random-Password-Generator
/RandomPasswordGenerator.py
1,798
4.34375
4
""" Author: Zeyad E Description: random password generator that uses characters, numbers, and symbols Last Modified: 6/9/2021 """ import random import string import pyperclip #external library used to copy/paste to clipboard def randomPassword(length): characters = string.ascii_letters + string.dig...
c497d53ab66e4279e077ecafc1d5e72e5fba3c0d
M-vdBerg/ProjectEuler
/problem007.py
472
3.875
4
# Problem 7 / 10001st prime # # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # # What is the 10 001st prime number? import math def is_prime(z): for i in range(2, math.sqrt(z).__int__() + 1): if z % i == 0: return False return True ...
54bab2af89fe1cb539ebafc3777a39971492d69b
stoltzmaniac/data_munger
/basics.py
1,293
4.40625
4
def mean(data: list) -> float: """ Calculates the arithmetic mean of a list of numeric values :param data: list of numeric values :return: float """ data_mean = sum(data) / len(data) return data_mean def variance(data: list) -> float: """ Calculates the variance of a list of numeri...
7c77ac0dd2f34ec393c3e7918594e2e344193d3b
Yida-Ding/ICSP2021-Labclass
/Lab_3/knowledge.py
689
4
4
#while/for loop i=1 while i<=3: print("i=",i) i=i+1 print("Done") for i in range(1,4): print("i=",i) print("Done") #global/local variable a=5 def sum_with_b(x): b=3 print(x+b) sum_with_b(a) print(b) def sums(L): result=[] for i in L: for j in L: if i...
43d29f23b038a959ba25465023429bf6e0f0d9cd
Yida-Ding/ICSP2021-Labclass
/key_lw/lab8_task2.py
830
3.640625
4
import time def multiply(a,b): s=[0]*5 a=str(a) b=str(b) if(len(a)>0 and len(b)>0): if(len(a)==1 and len(b)==1): return int(a)*int(b) else: a1=a[0:len(a)//2] a2=a[(len(a)//2):len(a)] b1=b[0:len(b)//2] b2=b[len(b)//2:len(b)] ...
8b58008f538e84ce0e91dd30df5d880a6f6db811
Yida-Ding/ICSP2021-Labclass
/key_lw/lab2 task6.py
166
3.5625
4
a=int(input()) b=int(input()) if(a<b): c=a a=b b=c if(a>0 and b>0): for i in range(a,a*b*5): if(i%a==0 and i%b==0): print(i)
77d76994a88c0706d33ade350fe6cfe594b022ad
Yida-Ding/ICSP2021-Labclass
/key_lw/lab5_task3.py
548
3.671875
4
class Event: def __init__(self,name,date,time,location): self.name=name self.time=time self.date=date self.location=location class calender: def __init__(self): self.li=[] def NewEvent(self,a): self.li.append(a) def FindEvent(self,b): for i in rang...
42781e2c0f9fb1afdb4019ffc2a19f67662c9c0b
Yida-Ding/ICSP2021-Labclass
/Lab_4/HW_4.py
1,159
3.90625
4
#Task1 def hanoi(n,x,y,z): if n==1: print("Move disk from",x,"to",z) else: hanoi(n-1,x,z,y) print(x,y,z) hanoi(1,x,y,z) hanoi(n-1,y,x,z) hanoi(2,'a','b','c') #(1) #change: line7 -> hanoi(1,x,y,z) #(2) #add: line6/7/8 -> print(x,y,z) #(3) #add: line6/8 -> return #print(h...
efd9f719c7a839af2fcfe0546f489397d2ddb638
Yida-Ding/ICSP2021-Labclass
/key_lw/lab6 task5.py
253
3.8125
4
def f(x): return 3*x**2+x-2 def di(a,b): if(b-a<0.001): print("(",a,",",b,")") else: c=(a+b)/2 if(f(c)==0): print(c) elif(f(a)*f(c)<0): di(a,c) else: di(c,b) di(0,1)
23270e0f2811b5a711c8a224885fe33aa90eb480
Yida-Ding/ICSP2021-Labclass
/key_lw/Heap.py
1,266
3.6875
4
import random class Max_Heap: def __init__(self): self.ht=[] self.size=0 def sinkdown(self,i): if(i*2>self.size): return 0 elif(i*2==self.size): if(self.ht[i]<self.ht[i*2]): self.ht[i],self.ht[i*2]=self.ht[i*2],self.ht[i] else: ...
6a63426188de8e01a5343853d37c312a353eb231
Yida-Ding/ICSP2021-Labclass
/key_lw/task8.py
363
3.75
4
a=float(input("a=")) b=float(input("b=")) c=float(input("c=")) if(a!=0 and (b**2-(4*a*c))>0): print("x=",((-1)*b+(b**2-(4*a*c))**(1/2))/(2*a)) print("or x=",((-1)*b-(b**2-(4*a*c))**(1/2))/(2*a)) elif(a!=0 and (b**2-(4*a*c))==0): print("x=",((-1)*b+(b**2-(4*a*c))**(1/2))/(2*a)) elif(a==0): print("x=",(-1...
0588afa573a8d90bf4584c19e6dd95302de1fcfa
lelanlan/00P_Buoi3
/python_buoi3.py
2,404
4.03125
4
#Thay đổi các thuộc tính account_number, account_name, balance trong class BankAccount thành thuộc tính ẩn, và triển khai thêm các phương thức: #get_account_number() ##get_balance() #set_balance() - balance phải lớn hơn hoặc bằng 0 #Thay đổi các phương thức display(), withdraw() và deposit() sử dụng các phương thức get...
1e6a8390e1f0a466215fc06cf22a927cb2035d1f
tristanbower/Harvard_Cs50
/pset6/pset6/cash/cash.py
440
3.640625
4
from cs50 import get_float change = get_float('How much will you be paying\n'); coin = 0 while(change<0): change = get_float('How much will you be paing\n') if(change == 0): print('0\n') cent = round(change*100) while(cent>= 25): cent = cent - 25 coin += 1 while(cent>= 10): cent = cent -10 coin...
47355faeb3b11b5eed30d09453b463dd564ce36c
carlocamurri/NeuralNetworksKarpathyTutorial
/neural_network_practice.py
2,065
4.40625
4
# Simplified version of multiplication gate to return the output or the gradient of the input variables def multiply_gate(a, b, dx=1, backwards_pass=False): if not backwards_pass: return a * b else: da = b * dx db = a * dx return da, db def add_gate(a, b, dx=1, backwards_pass=F...
0676e98b993097962e0014a31daabedc5c1939f5
rsinger86/software-testing-udacity
/lessons/luhns_algorithm.py
1,351
4.34375
4
# concise definition of the Luhn checksum: # # "For a card with an even number of digits, double every odd numbered # digit and subtract 9 if the product is greater than 9. Add up all # the even digits as well as the doubled-odd digits, and the result # must be a multiple of 10 or it's not a valid card. If the card ...
d352dac38955032029f33d4f2a664c4080c27bcd
ma-xbo/k8s-sample-applications
/python-hello-world/app.py
134
3.59375
4
from datetime import datetime dateTimeObj = datetime.now() print("Hello World, it is: " , dateTimeObj.strftime("%m/%d/%Y, %H:%M:%S"))
8bb98a6e86f29dd70cc261baaa53c11bda52e974
Alex-andre3/Kakuro---L3
/src/model/cell.py
628
3.78125
4
class Cell: # value < 0 means the cell is black # value = 0 means the cell is empty and must be filled # if value > 0, sumDown and sumRight will be ignored def __init__(self, value, sumDown=0, sumRight=0): self.value = value self.sumDown = sumDown self.sumRight = sumRight ...
fc3b3aa8d83a501bcece3244ed6f41eb0717d708
publiccoding/os_deploy
/Python/Project_multiple/components/mywork.py
391
3.703125
4
import math for i in range(10) : print(i) drinks = { 'martini': {'vodka', 'vermouth'}, 'black russian': {'vodka', 'kahlua'}, 'white russian': {'cream', 'kahlua', 'vodka'}, 'manhattan': {'rye', 'vermouth', 'bitters'}, 'screwdriver': {'orange juice', 'vodka'} } for n, c i...
8d88b04b8b209cef6d829741349cfd5585824859
publiccoding/os_deploy
/Python/Project_multiple/patch multiple models/test_larger.py
1,643
3.890625
4
import sys import os import mylib '''print(sys.platform) print(2 ** 100) x='Spam!' print(x * 8) def Hello(): print("this is my mesage") Hello() def Hello(Greetings): print(Greetings) Hello("thimmarayan") Name = input("Tell your name") print("Hello", Name) anum = float(input("Type your nu...
10927770b8889a23872c25cc42f47d82e33dc743
sisiflorensia/udacity-ipnd
/P3 - Guess The Words - Game.py
5,373
4.34375
4
# The paragraphs with blanks and their corresponding answers: paragraph_easy = "A ___1___ starts with a ___2___ character (#) that is not part of a string literal, and ___3___ at the end of the physical line. A ___4___ signifies the end of the logical line unless the implicit line joining rules are invoked. They are...
69b8cab0a572367fa692308a94befa83c76d93a0
tomokoji/ce888assignment
/src/sub/feature_importance.py
2,471
3.609375
4
""" =========================================================================== f e a t u r e _ i m p o r t a n c e . p y --------------------------------------------------------------------------- This code analyses feature importance based on a Decision Tree classifier. Author : Tomoko Ayakaw...
32469b54faa54f4b0f595ac6760e51c065ee119e
ipecanand/wms
/tools/dbconnect.py
3,317
3.515625
4
#import pymssql import pymysql import configparser class Dbconnect(): """ This class is used to connect to databases and run queries. """ def __init__(self): pass def dbfile(self): d = {} database_file = open("E:\\robotframework\pwms\\token.txt", "r") for line in da...
c539c3a368f1e6e1be1cea1de2da1df48ee4cbd9
Camu5/Scienc3_Calculat0rs
/CALCULADORA DE CONJUNTOS.py
5,856
3.9375
4
#Coded by Camu5 import sys def menu0(): print("Escoge una Operación Para Realizar: ") print("1) UNIÓN *U*") print("2) INTERSECCIÓN *∩*") print("3) COMPLEMENTO *x'*") print("4) DIFERENCIA *()-()*") print("5) DIFERENCIA SIMÉTRICA *Δ*") print() def pregunta(): print() print("¿Deseas calcular algo ...
15054803c30ba692946895d90db8d16ac202c84b
Jefferson-Oliveira1/python
/03_ receber_dados_client.py
1,143
4.34375
4
""" Receber Dados Do Client input() -> Todo Dado Recebido Via Input e do tipo String Em Python Stinng e Tudo que Estiver entre: - Aspas Simples - Aspas Duplas: - Aspas Simples Triplas: - Aspas Duplas Triplas: Exemplos: - aspas Simples -> 'Anjolina Jolie' - aspas duplas -> "Anjolina Jolie" - aspas Simples tiplas -> '...
9d6e83cb10bca31436fd3a1dc0d7941b29a205eb
Saikat2019/Python3-oop
/5magic_dunder.py
1,116
4.25
4
#magic methods - emulate some built-in methods in python #implement operator overloding #dunder means double'_' -- __add__() it's a dunder method #you can change some special methods , like for __add__ #we define add in our way ... in line 32 class Employee: num_of_emps = 0 raise_amount = 1.04 def __init__(self, f...
629e55eff269185b1f3b82ae80b682ad999f2d68
hdhcy/pytorch_learning
/basic/1.py
270
3.78125
4
''' Author: hdhcy Email: 982768496@qq.com date: 2019/8/13 18:04 ''' def res(age): for a in range(1,age): for b in range(1,2*age-a): c=2*age-a-b if a*b*c==2450: return age,a,b,c for i in range(48,52): print(res(i))