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
b4140e40ffe4ca4da77c3549db94e5b156d85ed1
AlirezaTeimoori/Assignment_3b
/pizza_price_calculator.py
2,264
4.0625
4
#Created by: Alireza Teimoori #Created on: 6 Oct 2017 #Created for: ICS3UR-1 #Lesson: Asssignment 3b # This program calculates pizza price # user is allowed to choose from 2 size # of pizzas and 1 to 4 toppings # app calculates sub total, HST, Final Total import ui ### Variables and Constants pizza_size = None ...
6073062969ef14f41dcad4e40440fc09395f8690
ermeksnow/geekbrains-python-homework
/example4-06.py
769
3.59375
4
#задача 6.1 def int_1(i): from itertools import count list_one = [] print('число начала списка',i) for x in count(i): if x > 10: break else: list_one.append(x) print(list_one) int_1(6) #задача 6.2 def int_2(repeat): from itertools import cycle lisi_i...
6b73359237accf47bfed47a7e42c90e828da44af
skinan/Competative-Programming-Problems-Solutions-Using-Python
/141A.py
570
4
4
# CodeForces # 141A - Amusing Joke def main(): s1 = input() # First String. s2 = input() # Second String. s3 = input() # Third String. z = [] for i in s1: z.append(ord(i)) # Make a list with ASCII code of each character of string. for i in s2: z.append(ord(i)) # Append to ...
eddf351952407920d8f57caf5bcebc1092a95e3c
Piyush-Ranjan-Mishra/python
/Machine Learning & AI/randomForrest.py
1,234
3.8125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd # Next, download the iris dataset from its weblink as follows − path = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data" # assign column names to the dataset headernames = ['sepal-length', 'sepal-width', 'petal-length', ...
9f82c6f05b1c96c177c2da4294f991b6b945d5c7
Piyush-Ranjan-Mishra/python
/Machine Learning & AI/logisticRegression.py
690
3.625
4
Import sklearn from sklearn import datasets from sklearn import linear_model from sklearn import metrics from sklearn.model_selection import train_test_split # load dataset digits = datasets.load_digits() # the feature matrix(X) and response vector(y) X = digits.data y = digits.target X_train, X_test, y_train, y_tes...
98b52e2171f3e4c8eb0da9df7e4e7130aa78169e
Gisset/Python-Essential
/Ejercicio 2 28-06-2021.py
274
3.703125
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 28 18:31:37 2021 @author: Gissela """ contar=input("Ingrese el # al que debo contar") contar=int(contar) contador=1 while True: print(contador) contador+=1 if contador>contar: break
3603a3f0cb0129699c8d158756cebde3a860fa1c
obrunet/green_garden
/various_tests/test_config.py
2,713
3.515625
4
import configparser import os.path import requests from requests.exceptions import HTTPError CONFIG_FILE = 'config.ini' GITHUB_BASE_URL = 'https://github.com/' def get_user_infos(): """Ask user for his/her username, name of the repo, and password""" username = input('Enter your GitHub username: ') repo ...
3ad5b60af0b9b5b922b220daf75fb8ed95f85909
pythondevelope/input
/input.py
294
3.671875
4
x = input("Your Name : ") print("Welcome",x) x = input("Years : ") print("Your Years Is",x) x = input("Do you like program? 0-10 :") print("Thanks for rating") print("Your Rating is",x) x = input("End? : ") print("Your answer is",x) print("© 2018") print("Thanks For Using my python app.")
f796dc8a77915b9bb581228ff929d80ac9198bab
RuiqingQiu/InterviewQuestions
/ZeroMatrix.py
746
4.09375
4
# 1.8 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0 def ZeroMatrix(matrix, M, N): row_zero = [] column_zero = [] for i in range(0, M): for j in range(0, N): if matrix[i][j] == 0: row_zero.append(j) ...
6ce4266cb2b1aca3b353b7c7a2de472418baad02
alex-coupe/battleships
/src/board.py
636
3.65625
4
class Board: ROWS = ['A','B','C','D','E','F','G','H'] COLS = ['1','2','3','4','5','6','7','8'] board = list() def init_board(self): for x in self.COLS: position = 0 for _y in range(8): self.board.append(self.ROWS[position] + x) position+=1 ...
735e48d42709bde3c0c662b1476feecd78976f6e
codejunkiekenya/andelabootcamp17
/max_min.py
225
3.78125
4
def max_min(): old_list = [] for num in old_list: new_list = [] min_value = min(old_list) max_value = max(old_list) new_list = new_list.append(min_value) new_list = new_list.append(max_value) return new_list
3d3f2208767ceb12d67aeeba29fe84adf605a6ee
marthaluka/Python4Bioinformatics2019
/Scripts/lec07_ex03.py
322
4.03125
4
#!/usr/bin/python import sys def validSequence(infile): valid = ['A','C','T','G'] isValid=True for letter in infile: if letter not in valid: isValid = False print("This DNA file contains non-convetional bases") return isValid infile = sys.argv[1] validSequence(infil...
63c6381dc1c727e69ba1d2d858d50ffa5c14ed92
kateleecheng/Python-for-Everybody-Specialization
/1_Getting Started with Python/Week_7_Class.py
381
3.78125
4
#Week_7_Class.py n=5 while n>0: print(n) n=n-1 print('Blastoff') print(n) while True: line=input('>') if line == 'done': break print(line) print('Done!') while True: line=input('> ') if line[0] == '#': continue #back to while loop if line =='done': ...
8f98cdccca903730bcc7bea751d011e854b6bfae
kateleecheng/Python-for-Everybody-Specialization
/2_Python Data Structures/Week_1_Class2.py
1,119
3.8125
4
#Week_1_Class2.py a='Hello' b=a+'There' print(b) #no space c=a+' '+'There' print(c) #have space fruit='banana' 'n'in fruit 'm'in fruit 'nan'in fruit if 'a' in fruit: print('Found it') greet='Hello Bob' zap=greet.lower() #a lowercase copy wont change the original print(zap) print(greet) print...
d11903a89fb0387d128b95424184ea7c9748ab22
kateleecheng/Python-for-Everybody-Specialization
/1_Getting Started with Python/Week_6_Asm.py
306
3.671875
4
#Week_6_Asm.py hrs=input('Enter Hours:') rate=input('Enter Rate:') f_hrs=float(hrs) f_rate=float(rate) def computepay(f_hrs,f_rate): if f_hrs>40: Pay=40*f_rate+(f_hrs-40)*f_rate*1.5 else: Pay=f_hrs*f_rate return Pay p=computepay(f_hrs,f_rate) print("Pay", p)
8d8b1094ecc52d64728c656aea268e70968616ad
kateleecheng/Python-for-Everybody-Specialization
/2_Python Data Structures/Week_5_Class3.py
678
4
4
#Week_5_Class3.py counts=dict() print('Enter a line of the text') line=input('') words=line.split() #split into list of words print('Words:', words) print('Counting...') for word in words: counts[word]=counts.get(word,0)+1 print('Counts',counts) counts={'chuck':1, 'fred':42,'jan':100} for key i...
c5eae2e88f6e8e9173e11e533822cdcadff1ce17
w50103/python
/demo/mydef.py
1,019
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf8 -*- import math def myfunction(param1, param2): print("param1 is %s, param2 is %s" %(param1,param2)) return 'nb'; def my_abs( n): if not isinstance(n, (float,int)): raise TypeError("bad opend type") if n >=0: return n else: retur...
437b78f280905868807dcad17e3f04bfdb4b7ce1
w50103/python
/demo/if.py
385
3.84375
4
#!/bin/usr/env python3 # -*- coding: utf-8 -*- weight = float(input("体重(KG): ")) height = float(input("身高(M): ")) res = weight/(height * height) if res > 38: mes = "太重了" elif res > 25: mes = "还好" elif res > 18: mes = "管肚子" else: mes = '不错' print('身高: %s ,\n体重: %s ,\nBMI: %s, 测算结果是: %s\n' % (height, ...
657084794be0f8aaa92b09c0c79d4d301db245e8
esbullington/cct
/cct/wifi.py
3,102
3.5
4
import time import network # the class starts a WiFi access point class AccessPoint: """ Initialize a new WiFi access point Notes: Make sure that the password is not too short. Otherwise, an OSError may occur while staring the access point. """ def __init__(self, access_point_ssid, acc...
5c7188d2152ef27af0f67a29a65970031a4fabb2
EchoSlam/data_structure
/chr03.py
6,907
3.703125
4
# -*- coding:utf-8 -*- # !/usr/bin/python """ @author:yyx @version: 1.0 @file: chr03.py @time: 2019/4/30 16:20 """ class ListNode: def __init__(self, data=None, pred=None, succ=None): self.data = data self.pred = pred # 前 self.succ = succ # 后 class List: def __init__(self): ...
cac134a11deff81aac536108a181b2c44ca60471
EchoSlam/data_structure
/chr05.py
8,931
3.640625
4
# -*- coding:utf-8 -*- # !/usr/bin/python """ @author:yyx @version: 1.0 @file: chr05.py @time: 2019/5/30 15:30 """ from chr04 import Stack, Queue class BinNode: def __init__(self, data=None, parent=None, lc=None, rc=None, height=0, color='R'): self.data = data self.parent = parent self...
2239f466399276fa8976e0512fb4a956918fa661
BRamamohan/python-notes
/python_practice/swap1.py
709
3.5625
4
#!/usr/bin/python list1, list2 = [123, 'xyz'], [456, 'abc'] ''' print cmp(list1, list2) print cmp(list2, list1) list3 = list2 + [786]; print cmp(list2, list3) print (list1) print (list2) list3 = list2 + list1; print (len(list3)) print (max(list3)) print (min(list3)) c=1,2,3 print (list(c)) list1.extend(list2) print (li...
4be76caa3f17cfb1385ec756d3187de5a9fc9bc7
yaronlev9/Nand2Tetris-projects
/Jack-compiler/SymbolTable.py
1,263
3.640625
4
class SymbolTable: """ Symbol table for classes/subroutines """ def __init__(self, class_table=None): """ Ctor _class_table: a list of all the symbol in the class _symbols: a list of all the symbols in the subroutine _counters: the counters of the diffe...
27e5aa42643b7502884b3d46fe79354acf3e1d1c
tt-n-walters/saturday-advanced-python
/functional_programming/artist_labels_functional.py
1,307
3.75
4
import csv import operator from functools import reduce def open_file(filename): return open(filename, "r") def create_tsv_reader(file): return csv.reader(file, dialect="excel-tab") def replace_hyphens(string): if string == "-": return "2020" else: return string # return "2020"...
d949a6cc812e77ab66ae356915dfc0ba2b0c866b
sane-nature/Basics
/nth_prime.py
352
3.734375
4
count=0 x=1 n=5 def prime(x): c=0 for i in range (1,x+1): if x%i==0: c=c+1 if c==2: return 1 else: return 0 while count<=n: count=count+prime(x) if count==n: break x=x+1 print(count) print("The",n,"th prime number is", x...
9563b2aeffb31ec541ac52870b7cb3e041662861
gavinbarrett/Star_Solver
/src/reader.py
870
3.6875
4
import os import sys class Reader: def __init__(self, f): self.fileObj = self.open_file(f) self.maze = self.read(self.fileObj) #print(self.maze) def valid(self, c): ''' Return true if character is valid ''' if c == '0' or c == '1': return True el...
bcb33f9ec9c08c28536d999a23a16632afd2da84
Bearsintours/CS50
/PSET6/crack.py
773
3.875
4
# import import crypt import sys # prompt user for hashed password if len(sys.argv) != 2: print("Please enter valid password") exit(code=1) # store hashed password hashed = sys.argv[1] # create string with every letters of the alphabet lowercase and uppercase letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl...
df619117f7e0c33580fee5d1fe489f990419243d
YonatanEizenberg/Catan_Project
/client/Road.py
2,215
3.890625
4
import pygame class Road(pygame.sprite.Sprite): # class for the Roads of the game def __init__(self, p1, p2): # initialises the Road Object pygame.sprite.Sprite.__init__(self) x1, y1 = p1.location x2, y2 = p2.location location = ((x1 + x2) / 2, (y1 + y2) / 2)...
f0edf436e1ca4e445f1b975f97c8a0348740b224
Alekhyo/InfyTQ-Assignment
/Assignment 4: Mandatory - Level 2.py
2,604
4
4
#DSA-Assgn-4 # The Indian Cricket Board has decided to send its best players to ICC World Cup. They have chosen the best 11 players for the match. # The players should be sent in for the batting based on their experience, i.e. the priority would be given to the player who has got the highest experience. # At the las...
69b8d384aa8dfe0b29e69e63ad7531e53faeef9d
catalindoja/Doja_Castro_Aqueducte_Prac2
/aqueducte_greedy_iterative.py
1,776
3.703125
4
#!/usr/bin/env python3 '''Practica Aqueducte 1. David Castro i Catalin Doja''' # encoding: utf-8 from __future__ import print_function import aux_functions def greedy_iterative(data_x, data_y, data_header): '''Algorisme iteratiu que implementa greedy''' total = 0 cost_mes_baix = 0 index_cost_baix = 0 ...
9f84598c8ac6b52a6fbc29741fc3a40d32732897
dmpark135/OOP-phrase-hunter-game
/phrase.py
632
3.6875
4
class Phrase: def __init__(self, phrase): self.phrase = phrase.lower() def display(self, guesses): for letter in self.phrase: if letter in guesses: print(f"{letter} ", end = "") else: print('_', end= "") de...
80977b223bc9a3e2f5b13b49d1c8af84add23b89
af1-tech/Python-equation
/Ecuatii_ro.py
6,233
4.09375
4
print("Ecuatii si inecuatii ver 1.0") import math loop1 = 10 optiune1 = 10 def ecgr1(): a = 0 b = 0 c = 0 x = 0 z = 1 while z != 0: a = float(input("Introduceti pe a: ")) if a == 0: print("Valoarea lui a trebuie sa fie diferita de zero!") e...
0bca93ef94e7f35e959941e7dbb8e7dd6d2129e6
pablomartinez/dailyprogrammer
/353/easy/closest_string.py
317
3.546875
4
def distance(s1, s2): d = 0 for c1, c2 in zip(s1, s2): if c1 != c2: d += 1 return d def closest(items): distances = list() for item in items: distances.append([item, sum([distance(item, i) for i in items])]) c = min(distances, key=lambda d: d[1]) return c[0]
86405915fec857d56f34a713028b8a2638f88b2b
JulianPL/Non-Rectangular_Convolution
/nrconv/primes.py
1,781
3.96875
4
#!/usr/bin/python3 """A module to create suitable primes for the NTT. """ from typing import List import sympy def create_power_of_two(number: int) -> int: """Creates the smallest power of two which is at least number.""" power = 1 while power < number: power = power * 2 return power def c...
581ada565596befba44b95249a95a7c145f6385e
KristianMariyanov/PythonPlayground
/hack-bulgaria-course/python01/week1/n_dice_more.py
577
4
4
from random import randint as rand def roll_dice(): print('Please enter number of dice sides:') n = int(input()) sum = 0 print('Your first number is:') first_number = rand(1, n) sum += first_number print(first_number) print('Your second number is:') second_number = rand(1, n) s...
326530c9ad4e37337ff0dc50f80a9084cb132cae
KristianMariyanov/PythonPlayground
/softuni-course/Lecture01/draw_chess_desk.py
469
3.703125
4
import turtle side = 20 turtle.speed('fastest') size = int(input()) for row in range(size): for col in range(size): if (col % 2 == 1 and row % 2 == 0) or (col % 2 == 0 and row % 2 == 1): turtle.begin_fill() for _ in range(4): turtle.forward(side) turtle.left(9...
563976bc89231207545cadbea2b9ccf053d7c903
MyHackInfo/My-Project
/Talk_To_Me.py
325
3.796875
4
#Hey i am narsi and you print('Hey i am narsi ') you=input('And you :') print('\nNice to meet you {0}'.format(you)) age=int(input('How old are you?: ')) print('\nyou born in {0} its good'.format((2018-age))) city=input('Where are you form ') print('\nohh {0} i love it '.format(city)) a=input('\nok bye ') print('ok bye ...
fe7e07d50bce5bfd98da40c4dd667a4a5280ffea
greenmoon55/robotics
/test2.py
2,078
3.53125
4
# % matplotlib inline import scipy import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import spline from math import * def get_point(x, y, theta, steering, distance): length = 20. turn = tan(steering) * distance / length radius = distance / turn cx = x - (sin(theta) * radius) ...
d202ee1b2a40990f05daa809841df5bab91c8c9e
sharatss/python
/techgig_practice/age.py
1,547
4.15625
4
""" Decide yourself with conditional statement (100 Marks) This challenge will help you in clearing your fundamentals with if-else conditionals which are the basic part of all programming languages. Task: For this challenge, you need to read a integer value(default name - age) from stdin, store it in a variable and...
d2b5c0a27b01ac2f63d6495436d9816453bd6241
sharatss/python
/python_basics/decorators.py
247
3.546875
4
def my_decorator(func): def func_wrapper(x): print("If this is called, then the function is decorated") res = func(x) print(res) return func_wrapper @my_decorator def next_number(x): return x+1 next_number(1)
a9786b118e8755d0b94e2318f514f27d7eeaa263
sharatss/python
/techgig_practice/special_numbers.py
1,070
4.125
4
""" Count special numbers between boundaries (100 Marks) This challenge will help you in getting familiarity with functions which will be helpful when you will solve further problems on Techgig. Task: For this challenge, you are given a range and you need to find how many prime numbers lying between the given range....
d571802de24c04e1e42fcb455f9daf3645703383
sharatss/python
/python_basics/iterator.py
166
3.890625
4
cities = ["Berlin", "Vienna", "Zurich"] iterator_obj = iter(cities) print(iterator_obj) print(next(iterator_obj)) print(next(iterator_obj)) print(next(iterator_obj))
7aeeb6b21cfb8a8f208af19d3eaf098be947d230
dandani-cs/dotnetfdnchallenge
/codingchallenge2.py
1,494
3.875
4
# YOUTUBE LIVE CODING SESSION VID: https://youtu.be/D7w6_i5QwRY class Student: def __init__(self): self.first_name = None self.last_name = None self.scores = [] def get_ave(self): return sum(self.scores) / test_amt def translate_grade(numeric_grade): if numeric_grade >= 90...
43dfc72f955053bd2ffb7e44a0b0d2e32776c24f
alyhhbrd/CTI110-
/P2T1_SalesPrediction_AaliyahHubbard.py
327
3.671875
4
# Programming Exercise 2 - Sales Prediction # 02162019 # CTI-110 P2T1 - Sales Prediction # Aaliyah Hubbard # # get projected total sales: total_sales = float(input('Enter the projected total sales: ')) # calculate profit as 23% of total: profit = total_sales * 0.23 # display profit: print('The profit is $', format(p...
e6c0effb856be274dabe3f6fc6913cf9a5d1440b
alyhhbrd/CTI110-
/P3HW1_ColorMixer_HubbardAaliyah.py
1,225
4.3125
4
# CTI-110 # P3HW1 - Color Mixer # Aaliyah Hubbard # 03032019 # # Prompt user to input two of three primary colors; output as error code if input color is not primary # Determine which secondary color is produced of two input colors # Display secondary color produced as output # promt user for input print('LET`S MIX ...
3df487f269f633fcc9dcc27046ace41fc0c67209
HenryCWong/MoDataNotebooks
/nobelPrize/untitled1.py
580
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 19 12:35:55 2019 @author: cywon """ #given a pool of numbers create an 11 digit ID def numOfIds(pool): if len(pool) < 11: return(0) possible = int(len(pool)/11) #round down number of possible based on characters numOfEights = findNumOfEights(pool) ...
f2217abfe2d3051b8a38ec70597b86c68dcbb4bd
skinnyporkbun/cs114
/greeting.py
494
4.0625
4
# Ask user to input name and age from time import sleep print("Hey stranger... Whats your name?") sleep( 2 ) name = input("What is it? Tell me...hehe...:") sleep( 1 ) #Ask user to input age print("And how old are you?") sleep( 1 ) age = int(input("Tell me, Tell me, I won't hurt you...")) print("So you're called " ...
b3be7d3a37103efc4b90ec491a65a6e196199a91
skinnyporkbun/cs114
/hello_list.py
795
4.0625
4
from time import sleep print ("Hello world") sleep( 2 ) print ("How are you feeling today from 1 to 10? 1 being bad and 10 being good.") feeling = input("Tell me here: ") # if feeling == "1" or "2" or "3" or "4" or "5" or "6" or "7" or "8" or "9" or "10": if feeling == "skip": print("Oh, okay. I won't ask you...
e310fbcbbeda57e3ad8e0575fc54d3e7038b9cf8
s5046838/python
/test_ladder.py
1,741
4
4
import unittest # module for testing purposes import word_ladder as wordladder # imports word_ladder.py files as wordladder class testWord(unittest.TestCase): #creates a unittest class to initiate unit testing of functions def test_file(self,file): # Tests whether the dictionary.txt file works result = ...
92e0b5ade5b8f114237827037f7e4afe0ca9f85c
zhuyuecai/CtCI-6th-Edition-Python
/Chapter1/4_Palindrome Permutation/PalindromePermutation.py
1,916
3.984375
4
# O(N) import unittest """ def pal_perm(phrase): '''function checks if a string is a permutation of a palindrome or not''' table = [0 for _ in range(ord('z') - ord('a') + 1)] countodd = 0 for c in phrase: x = char_number(c) if x != -1: table[x] += 1 if table[x] %...
12c967001835fea6570908ee030e60b02f70bbe2
QIBET/News
/app/models.py
628
3.734375
4
class Article: ''' class used to create instances of Articles objects ''' def __init__(self,id,author,title,description,urlToImage,publishedAt,url): self.id = id self.author = author self.title = title self.description = description self.image = urlToImage ...
df088fb37c67578d8327ad3fd90b2eebfaba85dd
dk4267/CS490
/Lesson1Question3.py
1,151
4.25
4
#I accidentally made this much more difficult than it had to be inputString = input('Please enter a string') #get input outputString = '' #string to add chars for output index = 0 #keeps track of where we are in the string isPython = False #keeps track of whether we're in the middle of the word 'python' for ch...
83cb74255b2448b7ae873aeb9cc3de3ba0e376b8
sujineel/opensource
/fib.py
156
3.8125
4
#!/usr/bin/python2.7 f=[] f.append(0) f.append(1) f.append(1) n=input("Please number!") for i in range(3, n+1): f.append(f[i-1]+f[i-2]) print(f[n])
8444b3f7acd22ad7e0bdee4ce910e8c982b2e00b
piotroramus/PJN
/lab2/metrics.py
2,575
3.515625
4
def levenshtein_distance(s1, s2): n, m = len(s1), len(s2) if n == 0: return m if m == 0: return n matrix = [[0 for _ in xrange(n + 1)] for _ in xrange(m + 1)] for i in xrange(m + 1): matrix[i][0] = i for i in xrange(n + 1): matrix[0][i] = i for i, c1 in enume...
e08ea56443f08fb4a90650b4dec896d23406dc19
danielforero19/ejemplos-de-bucles-anidados
/ejemplo 1.py
81
3.53125
4
for x in range(12): for y in range(3): print("x vale", x,"y vale", y)
90134f566a29c2dc47658224c55090064fc61a32
appsjit/testament
/Miscellaneous/AlgTool/wk2fractional_knapsack.py
883
3.921875
4
# Uses python3 import sys class knapsack(): def __init__(self,pRatio,pTagId): self.ratio = pRatio self.tagId = pTagId def get_optimal_value(capacity, weights, values,n): value = 0. for x in range(0,n): print(x) print(weights.__getitem__(x)) ##print(wt) # write y...
342b6b8449d061f9cde986a9d64c10ca48148732
appsjit/testament
/LeetCode/educative/StQ_Ch3_RevKinQ.py
734
4.03125
4
from myStack import myStack from myQueue import myQueue def reverseK(queue,k): # Write your code here mstack = myStack() cnt = 0 while cnt < k: mstack.push(queue.dequeue()) cnt += 1 while not mstack.isEmpty(): queue.enqueue(mstack.pop()) totSize = len(queue.queueList) print(totSize) for...
dae84ac89abab12d06b0b22264a995764a72d110
appsjit/testament
/LeetCode/educative/LinkedList_Ch06_Loop.py
399
3.703125
4
#Access HeadNode => list.getHead() #Check if list is empty => list.isEmpty() #Node class { int data ; Node nextElement;} def detectLoop(list): # Write your code here cnode = list.getHead() visitedNodes = [] while cnode.nextElement != None: print(cnode.data) cnode = cnode.nextElement if ( cnode in ...
37289bf83605e88e888b447c06f9b99827dcf227
appsjit/testament
/LeetCode/soljit/s063_UniquePath2.py
1,422
3.546875
4
class Solution: def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int: r = len(obstacleGrid) c = len(obstacleGrid[0]) # If the starting cell has an obstacle, then simply return as there would be # no paths to the destination. if obstacleGrid[0][0] == 1: ...
51e9f480efe28c6db2e708995e944674b63eaabb
appsjit/testament
/LeetCode/soljit/s023_MergeKSortedLists.py
2,432
3.84375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: def mergeTwoLists(l1: ListNode, l2: ListNode) -> ListNode: if l1 == None: ...
5eae40a6a77aa2e27d7492d7e5cfac3ba5a27979
appsjit/testament
/LeetCode/soljit/s020_validParenthesis.py
661
3.6875
4
class Solution: def isValid(self, s): if len(s) % 2 != 0: return False stack = [] match = set([('(', ')'), ('[', ']'), ('{', '}')]) for c in s: if c in ('(', '[', '{'): stack.append(c) if c in (')', ']', '}'): if l...
67b81266248d8fb5394b5ffbd7a950a2ae38f5b2
appsjit/testament
/LeetCode/soljit/s208_TrieAddSearchSW.py
2,080
4.125
4
class TrieNode: def __init__(self, value=None): self.value = value self.next = {} self.end = False class Trie: def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def insert(self, word: str) -> None: """ ...
f5fa5c732290e75bc783f0ffb6414abe81beed07
appsjit/testament
/LeetCode/soljit/s002_AddingNumbers.py
2,415
3.796875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getNm(l): x="" childNode = l while childNode.next != None: x = str(childNode.val)+x # print(childNode.val) ...
7606e3ab011a884ecadbd3db10920b506991da66
appsjit/testament
/LeetCode/soljit/s394_decodeString.py
1,826
3.609375
4
class Solution: def decodeString(self, s: str) -> str: ans = "" def peek_stack(stack): if stack: return stack[-1] # this will get the last element of stack else: return None stack = [] k = '' for idx, x in enumerate(s...
f1fc4cee503b73c157276cf2528fcb0493e15c86
appsjit/testament
/LeetCode/soljit/s094_BST_Inorder.py
1,109
3.8125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from queue import LifoQueue class Solution: def inorderTraversal(self, root: TreeNode) -> List[int]: result = [] # def helper(pn...
c76de6d1f45c00a5f5f5f6b5f0478b74507dc753
darlingtonbesa/SSR-GBS-pipeline
/extract_alleles.py
2,797
3.65625
4
# It uses a codominant matrix as an input containing alleles defined according to length. Then it sepeartes the sequences from each allele in a seperated file per sample. # Usage: python extract_alleles.py codominat_matrix.txt(tab-delimited text) Directory_containing_sequence_per_marker_annd_per_sample(fasta or fastq) ...
ab7c467b47bb356cec6496a4873fb4a52670d9e8
Hashah1/Leetcode-Practice
/medium/221. Maximal Square.py
790
3.59375
4
class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: """ Time Complexity: O(row*col), row = len(matrix), col = len(matrix[0]) Space Complexity: O(row * col), row = len(matrix), col = len(matrix[0]) """ dp = [[0 for i in range(len(matrix[0]))] for j in rang...
6b36039673eba232521cd9777b2caed9538cf08d
Hashah1/Leetcode-Practice
/medium/230. Kth Smallest Element in a BST.py
649
3.65625
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 kthSmallest(self, root: TreeNode, k: int) -> int: """ Brute force: Inorder traversal, re...
38ebd923872af70b5fdf33c03d10cf53d288dc70
Hashah1/Leetcode-Practice
/easy/BT_cousins.py
1,932
3.953125
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 isCousins(self, root, x, y): """ :type root: TreeNode :type x: int :type y: int ...
6de9cbd5e764ff8fd45291bbe82ded9f025287b2
Hashah1/Leetcode-Practice
/medium/637. Average of Levels in Binary Tree.py
939
3.796875
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 from collections import deque class Solution: def averageOfLevels(self, root: TreeNode) -> List[float]: """ ...
84455b0473913ce9734e7c4b62f4b604a1c3e82c
Hashah1/Leetcode-Practice
/medium/inorder_traversal.py
1,257
3.984375
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): traversal_list = [] def inorderTraversal(self, root): """ :type root: TreeNode :rtype: List[...
b20fb77c38e50c5a3b1a047e3cd5af74eb364b1a
Hashah1/Leetcode-Practice
/easy/design_hashmap.py
1,719
4.09375
4
class MyHashMap(object): def __init__(self): """ Initialize your data structure here. """ # Use two arrays, which will always have the same # length and will have a one-one relationship self.hashmap = [] def put(self, key, value): """ va...
a326d24bb276b5310d0a4f74ba822ccb8aa5205c
Hashah1/Leetcode-Practice
/easy/max subarray.py
661
3.6875
4
def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ # Set initial sums to the first element previous_max = current_max = nums[0] # Iterate through everything after first number # Compare the current num and the # previous sum of...
1e5f673a2ebd9bd87525fb51591a8e6d31360f21
Hashah1/Leetcode-Practice
/easy/intersection_2_lists.py
1,748
3.625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ # Approach: ...
5100ba7cac697fb4bb69e10609557a2e29cf8b06
Hashah1/Leetcode-Practice
/easy/is_symmetric.py
998
4.03125
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 isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ r_a = r_b ...
3d19120e68c4aad4bc1406bff2bc75baca2f023b
Hashah1/Leetcode-Practice
/medium/48. Rotate Image.py
734
3.953125
4
class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ def reverse(lst): l = 0 r = len(lst) - 1 while l < r: lst[l], lst[r] = lst[r], lst[l] ...
1772cc776ab52f857090e0d91949512e23ec0de0
Hashah1/Leetcode-Practice
/medium/LCA_binarytree.py
1,354
3.84375
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 __init__(self): self.path = [] def lowestCommonAncestor(self, root, p, q): """ :type roo...
91382fa88ad4ed185fe2d6b635b3f321c22d2297
Hashah1/Leetcode-Practice
/medium/654. Maximum Binary Tree.py
1,309
3.578125
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 constructMaximumBinaryTree(self, nums: List[int]) -> TreeNode: """ Thought Process: ...
ff02b770288584cac77790cda21a5ece164fe1c7
Hashah1/Leetcode-Practice
/easy/Climbin stairs.py
1,050
3.8125
4
class Solution(object): def climbStairs(self, n): """ RECURSIVE :type n: int :rtype: int """ # Cache with stairs:numways relationship cache = {} def helper(n): # Base case 1 if n in cache: return cache[n] # B...
3d72b16a663cdd2f59f293615dbe063462f877dd
forat19-meet/meet2017y1lab3
/helloWorld.py
2,137
4.375
4
>>> print("hello world") hello world >>> print('hello world') hello world >>> print("hello gilad") hello gilad >>> # print("Hello World!") >>> print("Γειά σου Κόσμε") Γειά σου Κόσμε >>> print("Olá Mundo") Olá Mundo >>> print("Ahoj světe") Ahoj světe >>> print("안녕 세상") 안녕 세상 >>> print("你好,世界") 你好,世界 >>> print("नमस्ते दु...
2142a60c7a8db734a6d41468d3ae3c45ce7c14d1
jordanCain-zz/Java-Optimisation-Atom-Plugin
/debugUtil.py
1,412
3.625
4
import inspect class Trace(): def __init__(self, debug): self.debugLevel = debug if debug >= 1: print ("Initialising User Trace") userFile = open('UserTrace.txt', 'w+') self.userFile = userFile self.userFile.write("User Trace \n") if debug >= ...
6be025375f60e36c59bb84f3a12f90d28e6df505
yjlee0209/kite
/Python/module_basic/test_module.py
537
3.96875
4
# 변수 PI = 3.14 # 함수 : 사용자의 데이터 입력 값을 반환하는 기능 def number_input(): result = input('숫자를 입력해주세요 >>> ') return float(result) # 함수 : 원의 둘레를 구하고 값을 반환하는 기능 def get_circumference(radius): return 2*PI*radius # 함수 : 원의 면적을 구해서 반환하는 기능 def get_circle_area(radius): return PI*radius*radius if __name__ == '__nam...
5db6b90a933778253e1c023dce68643d026d367b
voitenko-lex/leetcode
/Python3/06-zigzag-conversion/zigzag-conversion.py
2,703
4.28125
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conv...
52c86bc850235388c689c5fad29accb4f1c9537d
voitenko-lex/leetcode
/Python3/TreeNode.py
4,690
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ## Kth Smallest Element in a BST Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Example 1: Input: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \ 2 Output: 1 Example 2: Input: root = [5,3,6,2,4,null...
28b61ff27c9b29b985fe9c584447b3391367e569
voitenko-lex/leetcode
/Python3/05-longest-palindromic-substring/longest-palindromic-substring.py
2,865
4.09375
4
""" Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" """ import unittest class Solution: def longestPalindrome(self, s: str) -> s...
e47ec00b96e1851b21d61daa57a2f498fc88a41a
voitenko-lex/leetcode
/Python3/30-day-leetcoding-challenge/week-4/Subarray Sum Equals K.py
2,522
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ## Find the Town Judge In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: - The town judge trusts nobody. - Everybody (except for the town judge) trusts the...
ed39fed3c0d69d077cbbf00350885c7205b00ae6
voitenko-lex/leetcode
/Python3/02-add-two-numbers/add-two-numbers.py
2,693
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest def ToReverseListNode(source: str): nextv = None for i in source: node = ListNode(i) node.next = nextv nextv = node return nextv # Definition for singly-linked list. class ListNode: def __init__(self, ...
dcb2f37d5210d29312bff7ce6a9d38e17e4d209e
adamhammes/advent-of-code
/aoc_2020/day12.py
3,133
3.5
4
import dataclasses import enum from lib import Point, get_input class TurnDirection(enum.Enum): Clockwise = enum.auto() CounterClockwise = enum.auto() class Orientation(enum.IntEnum): North = 0 East = 1 South = 2 West = 3 def as_coords(self) -> Point: # fmt: off return ...
781681dc75e3bfa3068f0ff02b464bbc160f47ea
adamhammes/advent-of-code
/aoc_2022/day02.py
1,564
3.5
4
from collections.abc import Iterable import enum import lib class Option(str, enum.Enum): Rock = "X" Paper = "Y" Scissors = "Z" beats = { Option.Rock: Option.Scissors, Option.Paper: Option.Rock, Option.Scissors: Option.Paper, } loses = {b: a for a, b in beats.items()} def parse_input(raw...
a7ed10e9782bb1d07f03ac85384d23770d9a1be2
adamhammes/advent-of-code
/aoc_2020/day03.py
1,173
3.703125
4
import typing as t import lib TEST_INPUT_1 = """ ..##....... #...#...#.. .#....#..#. ..#.#...#.# .#...##..#. ..#.##..... .#.#.#....# .#........# #.##...#... #...##....# .#..#...#.# """.strip() class Point(t.NamedTuple): x: float y: float def get_input() -> t.Tuple[int, t.Dict[Point, bool]]: with open(...
2cac80f5684db963e7c759375ca254aa0808e33e
adamhammes/advent-of-code
/aoc_2018/day01.py
1,057
3.578125
4
import itertools import unittest tests1 = [ ([1, -2, 3, 1], 3), ([1, 1, 1], 3), ([1, 1, -2], 0), ([-1, -2, -3], -6), ] tests2 = [([1, -1, 2], 2)] def get_input(): with open("inputs/day1.txt") as f: return map(int, f.readlines()) def compute_frequency_drift(numbers): return sum(numb...
98fabd6301a588815cd22364d109f81faec6a343
adamhammes/advent-of-code
/aoc_2022/day05.py
1,778
3.796875
4
import re from typing import NamedTuple import lib EXAMPLE_1 = """ [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 """ Board = list[list[str]] class Instruction(NamedTuple): quantity: int from_position: int to_position: int ...
66ec6c800587d4dda3ee1ec81442ac0ac9206525
adamhammes/advent-of-code
/aoc_2021/p3d.py
1,334
3.671875
4
import typing class P(typing.NamedTuple): x: int y: int z: int def rotations(self, n: int) -> "P": x, y, z = self rots = [ # positive z up (-x, -y, +z), (-y, +x, +z), (+x, +y, +z), (+y, -x, +z), # negative z up ...
64e5c5bf7520e5efdd2ab7cc1bfc2c94b231dfff
adamhammes/advent-of-code
/aoc_2021/day02.py
1,219
3.890625
4
from lib import get_input from lib import Point from typing import NamedTuple class Movement(NamedTuple): direction: str magnitude: int def as_point(self) -> Point: return {"forward": Point(1, 0), "down": Point(0, 1), "up": Point(0, -1)}[ self.direction ].times(self.magnitude)...
94c76f1469491425967b64e08d9795a3f46a71d5
adamhammes/advent-of-code
/aoc_2021/day04.py
1,877
3.53125
4
from typing import NamedTuple, Optional, Tuple import lib Calls = list[int] class BingoBoard(NamedTuple): squares: list[list[Optional[int]]] @staticmethod def from_str(raw: str) -> "BingoBoard": squares = [[int(c) for c in line.split()] for line in raw.strip().splitlines()] return Bingo...
6303d1c3706e99b0bbd18d019cd124323d4d90e4
adamabad/WilkesUniversity
/cs125/projects/weights.py
1,289
4.25
4
# File: weights.py # Date: October 26, 2017 # Author: Adam Abad # Purpose: To evaluate pumpkin weights and average their total def info(): print() print("Program to calculate the average of a") print("group of pumpkin weights.") print("You will be asked to enter the number of") print("pumpkins...
9d2cf5ad9820012e8b04b74c424fa27b034184e3
adamabad/WilkesUniversity
/cs125/projects/histo.py
2,544
4.09375
4
#File: histo.py #Date: December 7, 2017 #Author: Adam Abad #Purpose: To construct a histogram for data in a file from math import * def intro(): print() print("Program to print a histogram of scores.") print("It also produces the high, low, and average score") print("along with the standard deviation...
201d52619b0eea154785427223844d3d9e48c5e7
regynald/Project-Euler-Solutions
/Python/euler/bruh.py
831
3.640625
4
# def run(): # def circular_prime(n, primes): # if not primes[n]: # return False # elif n < 10 and primes[n]: # return True # number = map(int, str(n)) # rotator = deque(number) # for i in range(len(number)): # num = int(''.join(map(str, ro...
c7d12d4ff7ce104c97eb20b3b9b4b222647fd09e
regynald/Project-Euler-Solutions
/Python/euler/library.py
1,820
3.84375
4
import math # Returns true if n is a palindrome def is_palindrome(n): if isinstance(n, str): return n == n[::-1] else: return is_palindrome(str(n)) # return true if n is prime def is_prime(n): if n <= 1: return False elif n == 2: return True elif n % 2 == 0: ...
2f362e378804ba491b518e056ab5df68cf175e70
regynald/Project-Euler-Solutions
/Python/014.py
1,174
3.765625
4
""" Project Euler Problem 14 ======================== The following iterative sequence is defined for the set of positive integers: n->n/2 (n is even) n->3n+1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13->40->20->10->5->16->8->4->2->1 It can be seen ...