blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c011e1b8df16b585541da258947fc252644f6f2f
surajkawadkar/vita
/PYTHON/day4.py
1,189
3.734375
4
# for i in range(1,6,1): # print('*'*i) # for i in range(5,0,-1): # print('*'*i) # mirror pattern # for i in range(1,6,1): # print(' '*(6-i),'x'*i) # # pyramid # for i in range(1,6,1): # print(' '*(6-i),' x'*i) # for i in range(5,0,-2): # print(' '*(6-i),' x'*i) # word pyramid # name='suraj' # for ...
90de4969ae7759459a35dc7626ce314d4bed24ea
TheDotson/petting_zoo
/attractions/herpetarium.py
481
3.75
4
from .attraction import Attraction from movements import Slithering class Herpetarium(Attraction): def __init__(self, name, description): super().__init__(name, description) def add_animal_type_check(self, animal): if isinstance(animal, Slithering): self.animals.append(animal) print(f"{animal}...
8cddc0b38f1c0598d2e4c586539bc70b38c988b1
Suraj21/Machine-Learning
/Regression/Simple Linear Regression/Company_Data_Simple_Linear_Regression_Model.py
1,368
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 30 09:21:55 2019 @author: suraj """ import numpy as np import matplotlib.pyplot as plt import pandas as pd import seaborn as sb companies = pd.read_csv("D:\GitRepository\Machine-Learning\Regression\Simple Linear Regression\Company_Data.csv") X = companies.iloc[:,:-1].va...
a2a4a37f34211a4553a7a90b568b12d425b1f32f
parrul04/Employee-Registration-Form
/utilites/readData.py
383
3.9375
4
import csv def getCsvData(filename): # CREATE EMPTY LIST TO STORE DATA rows = [] # open the csv file filedata = open(filename, "r") # reader to itrate through lines in csv file reader = csv.reader(filedata) # skip the header next(reader) # add rows from reader to list ...
4f1548eeec37205d9d2af54612e4f163908e8f3d
ErikHajikyan/LoanHelp
/LoanHelp.py
7,286
3.59375
4
import datetime class User: def __init__(self,name,surname,id): self.name = name self.surname = surname self.id = id self.next = None self.head = None self.loans = [] def userActions(self): ask = raw_input("Please choose an option from below: " ...
ec101c5f910a62241b6489b673a3bb39f999a23b
MatsudaYoshio/study
/AutomateTheBoringStuff/detect_strong_password.py
341
3.640625
4
import re def is_strong(password): regex = re.compile(r'^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?\d)[a-zA-Z\d]{8,}') return re.match(regex, password) def main(): password = "lisdfDDh9fg" if is_strong(password): print("This is strong!!") else: print("This is weak!!") if __name__ == '...
64eb621895a0f9e7fd344817da576c989ab5d250
imperio-wxm/learning-python
/learning-python/learning_except/except_test.py
1,164
4.0625
4
#!/usr/bin/env python # -*- UTF-8 -*- __author__ = 'wxmimperio' try: x = input("Enter the first number: ") y = input("Enter the second number: ") print x / y except ZeroDivisionError, e: print "ZeroDivisionError " + e.message except NameError, e: print "Name Error " + e.message else: print "No ...
4cd616eea46d8676145a31c9256d9805ec91cce7
FerrerasRP/PythonUSP
/S3ex7.py
321
3.9375
4
import math x1 = int(input("Digite ponto 1 coordenada x:")) y1 = int(input("Digite ponto 1 coordenada y:")) x2 = int(input("Digite ponto 2 coordenada x:")) y2 = int(input("Digite ponto 2 coordenada y:")) distancia = math.sqrt((x2-x1)**2+(y2-y1)**2) if distancia >= 10: print("longe") else: print("perto") ...
d8e66ef173937b3faf7b2fb60559ea7a4a3716d3
FerrerasRP/PythonUSP
/jogo_nim_v3.py
1,358
3.921875
4
def computador_escolhe_jogada(n, m): multiplo = m + 1 jogada = 1 while True: if (n - jogada) % multiplo == 0: print ("Computador retirou: "+str(jogada)) return jogada jogada += 1 def usuario_escolhe_jogada(n, m): while True: valor = int(input("\nInforme...
0659a69d4cb86b986cacdf54a13c2b50cc0479e5
FerrerasRP/PythonUSP
/while.py
61
4
4
i = 1 while i < 3: print("iteração") i = i + 1
0dbaa8632d7f399c3cd6e1fed9f7859c2b6b9ef2
FerrerasRP/PythonUSP
/S6ex4.py
308
3.890625
4
l = int(input("digite a largura:")) a = int(input("digite a altura:")) il = 1 ia = 1 while ia <= a: while il <= l: if ia == a or ia == 1 or il == 1 or il == l: print("#",end="") else: print(" ",end="") il = il + 1 print("") ia = ia + 1 il = 1
4a5ea58436bf29615dd59d3bc8f90c3f0c381405
jamesr1775/CTCI
/python_solutions/ArraysStrings/Urlify/Urlify.py
628
3.671875
4
import sys def Urlify(string, trueLength): numSpaces = 0 string = list(string) for i in range(0, trueLength): if string[i] == " ": numSpaces += 1 index = trueLength + numSpaces*2 for i in range(trueLength-1, -1, -1): if string[i] == " ": string[index - 1] = "...
361936c64b9051658a386f9bb6b7c81267a464c9
jamesr1775/CTCI
/python_solutions/ArraysStrings/IsUnique/IsUnique.py
416
3.78125
4
import sys def IsUnique(input_str): char_dict_count = {} for c in input_str: if c in char_dict_count: print("Not All Unique Chars Detected") return False else: char_dict_count[c] = True print("All Unique Chars Detected") return True def main(): p...
e092588e0397db6522d8dc84efb91ce61cd42fb8
ShahzainAhmed/NumbersDivisbleInRange
/NumbersDivisibleInRange.py
318
4.0625
4
# Taking input of lower range from the user. lower=int(input("Enter lower range limit: ")) # Taking input of upper range from the user. upper=int(input("Enter upper range limit: ")) n=int(input("Enter the number to be divided by: ")) # Using for loop. for i in range(lower,upper+1): if(i%n==0): print(i)
3b98ff889c2f5b7effb759170a19208eba18cd1e
jlattu/simplecatalog
/catapp/catalog.py
7,134
3.96875
4
import sqlite3 import os db = None # This variable is used for database connection later project_path = os.path.dirname(os.path.abspath(__file__)) def open_database_connection(self, testing: bool = "false"): """Open database connection and attach it to db variable. Also creates table for shirts if it does...
6c070c5cbfb8cb0ba1d55a29db374e4a3f0ab018
Panic-Point/AOC2020
/Day10/AdapterArray.py
3,442
3.546875
4
import time from typing import List start = time.time() TEST1 = """16 10 15 5 1 11 7 19 6 12 4""" TEST2 = """28 33 18 42 31 14 46 20 48 47 24 23 49 45 19 38 39 11 1 32 25 35 8 17 7 9 4 2 34 10 3""" with open("Day10.txt", 'r') as file: data = file.read() TEST1_INPUT = [int(x) for x in TEST1.rstrip('\n').strip(...
5f8b291234e65f2b89c439166f17a617d0b870fd
Panic-Point/AOC2020
/Day02/PasswordPhilosophy.py
1,202
3.5
4
from dataclasses import dataclass import time from collections import Counter from typing import Tuple start = time.time() TEST = """1-3 a: abcde 1-3 b: cdefg 2-9 c: ccccccccc""" with open("Day02.txt", 'r') as file: data = file.read() @dataclass class Password: lo: int hi: int char: str passwo...
0cab9c31ccb2a907c2c09b53f43bc8789aabd723
appbanana/DataMining
/chapter06-使用朴素贝叶斯进行社会媒体挖掘/02-朴素贝叶斯对文本进行分类.py
6,056
3.5625
4
import numpy as np """ 参考文章:https://zhuanlan.zhihu.com/p/50287183 """ def load_data_set(): """ :return: 将评论分离个单个的单词 """ cm1 = "my dog has flea problems help please" cm2 = "maybe not take him to dog park stupid" cm3 = "my dalmation is so cute I love him" cm4 = "stop posting stupid wort...
8f6da1118acf7343632fcd3975ce9057176b3ce8
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter08/currency_converter.py
2,129
3.609375
4
#!/usr/bin/env python import urllib2 import json from string import Template import sys URL_TEMLATE = Template('http://api.fixer.io/latest?base=${from_curr}&symbols=${to_curr}') def get_rates(from_curr, to_currs): """ Get the conversion rates for a set of currencies. @param from_curr The starting curr...
fb9e32a01cb2353becb2b43b1c2395c0a69c2a28
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter06/pwm_output.py
980
3.796875
4
#!/usr/bin/env python import RPi.GPIO as GPIO from time import sleep def do_fade(pwm, start, end, step=2): """ Do a fade from a value to another. @param pwm PWM object @param start Staring value @param end Final value @param step Value change step """ # Make step negative for a down...
d97d9bc08451ec4869d418713cb21aa6490fdc1f
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter06/basic_input.py
564
3.640625
4
#!/usr/bin/env python import RPi.GPIO as GPIO from time import sleep # Use GPIO numbering GPIO.setmode(GPIO.BCM) # GPIO with switch attached switch_gpio = 17 # Set the GPIO up as an input will pullup resistor GPIO.setup(switch_gpio, GPIO.IN, pull_up_down=GPIO.PUD_UP) try: while(True): # Read the status...
08f70a3a954a03f0604176b8067d39f125cb2554
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter02/ControlFlow_Continue.py
142
3.671875
4
#!/usr/bin/env python for i in range(10): print "Starting #%d" % (i) if i % 2 == 1: continue print "Finishing #%d" % (i)
3836f56bdca0e9b0695c3940545ad55ea4f207df
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter06/basic_output.py
390
3.5625
4
#!/usr/bin/env python import RPi.GPIO as GPIO from time import sleep # Use GPIO numbering GPIO.setmode(GPIO.BCM) # GPIO with LED attached led_gpio = 4 # Set the GPIO up as an output GPIO.setup(led_gpio, GPIO.OUT) # Toggle the state of the output 10 times for _ in range(10): GPIO.output(led_gpio, not GPIO.input...
4a73ed65343cebcd3625b4bccc8fcb89a3e42cf5
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter03/File_Objects.py
544
3.75
4
#!/usr/bin/env python import os.path # The path to a file to write to filename = os.path.expanduser("~/SampleFile.txt") # Some text to write text = "The quick, brown fox jumps, over the, lazy dog" # Write some data to the file with open(filename, "a") as f: lines = [l + "\n" for l in text.split(",")] f.writ...
ebaa34bebbfcbaff66568f3804426296f7199e22
DanNixon/GettingStartedWithPythonAndRaspberryPi
/Chapter05/calcpy_with_cli/calcpy/calculator/Operation.py
542
3.921875
4
class Operation(object): _operation = None def __init__(self, name): if name not in ["add", "subtract", "multiply", "divide"]: raise ValueError("%s is not a valid operation" % (name)) self._operation = name def evaluate(self, a, b): if self._operation == "add": ...
6f14c5c457176e9fd79c870bade395ef4e50ae48
mzy97/leetcode_practice
/twosum.py
447
3.515625
4
""" 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] https://leetcode-cn.com/problems/two-sum """ class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: hashtable = dict() for i, num in enumerate(nums): if target - num in hasht...
7bc6c66a2d3ad36fc60cc87e2fed6ebd7af5afd7
khan2810/Hacktoberfest-Python
/shell_sort.py
342
3.671875
4
def shell_sort(arr): gap = len(arr)//2 while gap>0: for i in range(gap, len(arr)): anchor = arr[i] j = i while j>=gap and arr[j-gap]>anchor: arr[j] = arr[j-gap] j -= gap arr[j] = anchor gap = gap//2 if __name__ == "__main__": elements = [21, 38, 29, 17, 4, 25, 11, 32, 9] shell_sort(eleme...
3da3dea780804739789ca283a3e6002c54bbad1d
waspyfaeleith/darts_scorer_OO_python
/viewer.py
2,431
3.5
4
from throw import Throw import os import pdb class Viewer(object): def print_scoreboard(self, game): os.system("clear") print "\t %s Sets %s" %(game.player1.sets_won, game.player2.sets_won) print "\t %s Legs %s" %(game.player1.legs_won, game.player2.legs_won) print "\t\t%s" %(game.start_sco...
5369e23e2788589965ca2001dc34fbc486fb7f29
danielveazey/zombiedice
/zombiedice.py
3,837
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from random import randint, shuffle class Die(object): def __init__(self, color, sides): self.color = color self.sides = sides def roll(self): return self.sides[randint(0,5)] class Player(object): def __init__(self, name, score): ...
0c12deb1343cabd8ac9afdfd0cc3629913cfb72b
lucasbene86/Controle-de-estoque
/manipulando_db/manipulacao.py
6,367
3.78125
4
import sqlite3 from prettytable import PrettyTable # Essa função converte a tebela do banco de dados para visualização def visualizar_estoque(): # Conectenando ao banco de dados banco = sqlite3.connect('D:/Python/Estoque/Banco.db') cursor = banco.cursor() cursor.execute('SELECT * FROM produtos') ...
394d630cb3be220f13b3c28d41a2b93a93917c94
RAJU009F/my-work
/PYHTON/InheritanceTest.py
587
4.28125
4
#!usr/bin/python """ Example for Inheritance""" class Clock(object): def __init__(self, hours=0, minutes=0, seconds=0): self.__hours = hours self.__minutes = minutes self.__seconds = seconds def set(self, hours, minutes, seconds): self.__hours = hours self.__minutes = minutes self.__seconds = seconds ...
a86098636bd259031e13e14525d4307b3b2ef4bf
RAJU009F/my-work
/GFG/LinkedList/ReverseGroupwise.py
2,097
3.875
4
# // # import java.io.*; # // # import java.lang.*; # // # import java.util.*; #!/usr/bin/python -O # include <stdio.h> # include <stdlib.h> # include <string.h> # include<stdbool.h> # include<limits.h> # // #include<iostream> # // #include<algorithm> # // #include<string> # // #include<vector> # //using namespa...
29be92e8379bf37505c2f46a34f1c9bab91095ef
Mihir2604/Tkinker
/TkinkerButton.py
219
3.78125
4
from tkinter import * root=Tk() def funct(): mylabel=Label(root,text="I Clicked Button") mylabel.pack() button=Button(root,text="Mihir",bg="black",fg="green",command=funct) button.pack() root.mainloop()
66f48e961890f9b3713d33999e7961a72d9d3d66
wilc0n/hacker-rank
/python/nested_lists.py
638
3.859375
4
''' Testing. ''' def main(): ''' Main function ''' students_scores = [] for _ in range(int(input())): name = input() score = float(input()) row = [name, score] students_scores.append(row) students_scores.sort(key=lambda x: float(x[1])) lowest_score = students_scores[0...
51f6c37c67219a16f277c920aa353ef7e0a0896a
ribird/Calculator
/calc.pyw
3,704
3.5
4
import tkinter def clear(): global result entry.delete(0, len(entry.get())) result = '' def backspace(): global result entry.delete(0, len(entry.get())) result = result[0: len(result) - 1] entry.insert(len(entry.get()), result) def eq(): global result entry.delet...
8c774c2034fbc5bcacbeb38fbbe6ce48e963599b
vanillakernel/Connect4Bot
/connect4_OO.py
10,514
4.125
4
#!/bin/python import random import math from itertools import groupby import copy ############################################################################### # The player will contain anything that makes decisions or takes actions. # #########################################################################...
5ade5c07948dac1f470c9152698890b284a29485
XzzXzzX/py_study
/myClass/TimeUtil.py
684
3.578125
4
# -*- coding: utf-8 -*- #!/usr/bin/env python class TimeUtil(object): def __init__(self): pass def secondsToStr(self, seconds): """ 秒数转str xx小时xx分xx秒 """ t_m = 0 t_h = 0 if (seconds >= 60): t_m = int(seconds / 60) if (t_m >= 60): ...
bbea04ab07827c547d723f7388f0f274d09dde35
rheehot/hccho2FirstGitProject
/plot_Test.py
13,443
3.84375
4
# coding: utf-8 import matplotlib.pyplot as plt from PIL import Image import numpy as np # Simple data to display in various forms <---- 원하는 함수의 그래프를 그래볼 수 있다. x = np.linspace(0, 2 * np.pi, 400) y1 = np.sin(x ** 2) y2= np.cos(x ** 2) plt.plot(x,y1) ##################################################### # scatter x_t...
b0188bfd70a44f2b344d2908353037d75eb8f4cf
pry-muniz/Teste-git
/Exercicio3.py
311
4.09375
4
import random numeros = [] quantidade_numeros = int(input('Digite a quantidade de numero que deseja: ')) while len(numeros) < quantidade_numeros: numeros.append(random.randrange(0,50)) print(numeros) print('O maior valor dessa lista é: ', max(numeros)) print('O menor valor dessa lista é: ', min(numeros))
d335f4469d4215741e7a7e077f6dc4d0d18badcf
YuanZheCSYZ/algorithm
/datastructure/tree/minimum_absolute_difference_in_bst.py
1,133
3.75
4
# 530 https://leetcode.com/problems/minimum-absolute-difference-in-bst/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): """ Runtime: 44...
58507ae516575a51a303ef4a4049db926c8aa1b1
YuanZheCSYZ/algorithm
/search/dfs/path_sum.py
1,879
3.875
4
# 112 https://leetcode.com/problems/path-sum/submissions/ # 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: """ Runtime: 44 ms, faster than 65.05% of Pyt...
e2a1f7565159507e8184acc638bb2d1f32094b5f
YuanZheCSYZ/algorithm
/datastructure/list/implement_strstr.py
992
3.5625
4
# 28 https://leetcode.com/problems/implement-strstr/submissions/ class Solution: """ Runtime: 28 ms, faster than 94.46% of Python3 online submissions for Implement strStr(). Memory Usage: 14.4 MB, less than 61.75% of Python3 online submissions for Implement strStr(). """ def strStr(self, haystack: ...
12343960abe6fb1a2a9abeda550e7aa4afa35cf5
YuanZheCSYZ/algorithm
/datastructure/tree/base/N-ary Tree Preorder Traversal.py
542
3.609375
4
# https://leetcode.com/problems/n-ary-tree-preorder-traversal """ # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution: def preorder(self, root: 'Node') -> List[int]: if not root: retur...
069a0999e809405426c3c88fd900f8eae070fe15
YuanZheCSYZ/algorithm
/datastructure/tree/second_minimum_node_in_a_binary_tree.py
1,871
3.84375
4
# 671 https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/ # 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: """ Runtime: 16 ms, faster th...
51cf0756d77db65bffe2845b3b1efc4adb1c859f
YuanZheCSYZ/algorithm
/datastructure/list/47 Permutations II.py
1,754
3.53125
4
# https://leetcode.com/problems/permutations-ii/ class Solution: """ Runtime: 215 ms, faster than 22.68% of Python3 online submissions for Permutations II. Memory Usage: 19.6 MB, less than 5.03% of Python3 online submissions for Permutations II. """ def permuteUnique(self, nums: List[int]) -> List[...
f27537fd6d03a954ae7125f87cd23516c772f82a
redcrownlp/RC-OpenNlp
/Topic Identification System/PreProcessing Stage/Similarity.py
689
3.828125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # author: Mohammad Modallal <m.modallal@redcrow.co> from difflib import SequenceMatcher def similar(str1, str2): ''' Description: Find The similarity between two strings (Str1 and Str2) Input: 1)str1 - First string ...
e56187cabc1026d21cc7e5e93bb9450f2fceb490
MarsRoboters/HackerRank-Python-Solutions
/Find the Runner-Up Score!/Find_The_Runner_Up_Score.py
348
3.671875
4
if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) arr = list(arr) sorted_list = sorted(arr) n = len(sorted_list) maxi = sorted_list[n-1] for i in range(n - 1, -1, -1): if sorted_list[i] < maxi: second_maxi = sorted_list[i] b...
dacc5e525085c2e2e258459f6f42a832aad7db13
smithevan/python_test
/lottery_pick.py
456
3.515625
4
from random import randint lottery_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] picked_numbers = [] while len(picked_numbers) < 6: for number in lottery_numbers: iterator = randint(1, len(lottery_numbers)) if number == iterator: ...
047c739925766b18b04cac07658a4d0ae760c0f3
KoushikSahu/project-euler
/src/46.py
872
3.71875
4
import math, statistics, collections from typing import List """ Author: Koushik Sahu Created: 23 August 2021 Mon 10:23:06 """ nxm = int(1e7+5) def sieve() -> List[bool]: global nxm primes = [True]*nxm primes[0] = primes[1] = False for i in range(2, int(math.sqrt(nxm))): if primes[i]...
97e1fe1cde32aadbc0432d62115182a34fe09e7c
brian-rieder/bpr-hacks
/lightsout.py
3,194
3.875
4
#!/usr/bin/env python3 import random dimension = 5 def start_game(dimension): print('''############################################################################################## ################################## Welcome to LightsOut! ##################################### # ...
7e63581cb283cb763b0581b730e3e77f691033c9
foremanz/CAHighwayModel
/CarHW3.py
18,806
3.515625
4
#Created by UC Denver MCM Team 2017 import numpy as np import sys import math import random import time from collections import deque import queue import numpy as np #Car class object used for storing each vehicle information class Car(): #Initialize Car with Speed (MPH) and Lane number) def __init__(self, sp...
44996f37daa266b7e49fc81a41ead76175abed6f
afaideen/pythonschool
/Basics/Variables/1.py
605
4.15625
4
def main(): message1= input("Enter your first message ") message2= input("Enter your second message ") print("Your first message was {0} ".format(message1)) print("Your second message was {0} ".format(message2)) # Exercise 2 Basics # Write a program to input two whole numbers, # add them togeth...
f2fff1a0e2672ec313be1a9e4285300a3951b594
KomalBharadva/Dublin-bike-utilization-analysis
/Pearson's_correlation_code/PythonCode.py
959
3.625
4
import pandas as pd print("Your code and datasets should be in the same directory") fileinput1 = str(input("Enter the name of CSV file for Bikes and Rain: \n")) MR_rain = pd.read_csv(fileinput1, header=None) MR_rain.columns = ['StandName', 'Rain','UtilizedBikes Count'] # To calculate Pearson's Correlation coefficient f...
c376b7671886bb2ac6b8c08bb6bd13641f09d9e0
fengsq9408/py_01
/Hello_fengsq.py
323
4.03125
4
# 你好 风声起 """ Python是一种解释型、面向对象、动态数据类型的高级程序设计语言 Python由吉多·范罗苏姆于1989年底发明,第一个公开发行版发行于1991年 """ temp = input("Please enter;") print(temp) print(type(temp)) # 强制转换 temp = int(temp) print(type(temp))
5380c6cd4d698dcdf454c4dc7aafbc027b137d6d
Naincy47/Array-1
/diagonalArray.py
997
3.625
4
# Time Complexity : Brute Force: O(m*n) # Space Complexity : Brute Force: O(n) # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : Logic class Solution(object): def findDiagonalOrder(self, matrix): """ :type matrix: List[List[int]] :rtype: List[int...
2a42408d07a3333a4180b3b3dc2090c97bf4268e
Ollivanders/Network-Analysis
/Code/pa_graph.py
4,067
3.765625
4
########################################################################## # # # Filename: brilliance.py # # Author: htdv92 # # Date created: ...
70964e4f452ea8137609abf8d8de76670c6688f9
himelbikon/BA_Rewriter
/BA_Rewriter.py
927
3.53125
4
import random sentences = 'আমি অসময়, অবেলায়: কিভাবে অধিবেশন ছেড়ে চলে যাই। আমি বেহুশ। অধিবেশন' def converter(string): a = ['অকাল', 'অসময়', 'অবেলায়', 'অদিন', 'কুদিন', 'দুঃসময়'] b = ['অচেতন', 'অজ্ঞান', 'আসাড়', 'জ্ঞানশূন্য', 'জ্ঞানহীন', 'বেহুশ'] c = ['অধিবেশন', 'সভা', 'সমিতি', 'সমাবেশ', 'মিটিং'] extra = ['।', ...
e629ca3a609588cce9a3a45d3cb6359d0aaf64a5
rupakdasatos/python_practice
/matlabplot_rd1.py
195
3.640625
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0,5,11) y = x ** 2 plt.xlabel('X Label') plt.ylabel('Y Label') plt.title('Title') plt.plot(x,y,'r--') plt.show()
ec9b61cde3087cf0cfde444c0278cfc7c35dd978
auriferos/scripts-misc
/python_netstuff/check_rand_url.py
2,842
3.546875
4
#!/usr/bin/python import httplib import httplib2 import random import argparse import sys import re # regex to grab domain but not path: # [._\-a-zA-Z0-9]*\.[a-zA-Z]+ from BeautifulSoup import BeautifulSoup, SoupStrainer def split_path(url): if 'https:' in url: url=url.replace('https://','') url...
856da1613a77040aa063824cab5190559455a6d5
jalexvig/algos_datastructures
/data_structures/linked_list.py
4,673
3.6875
4
""" Lists implemented using singly/doubly linked nodes. Summary: Supports deleting at an index and inserting at an index. Characteristics: * n number elements Index: Worst Time: O(n) Search: Worst Time: O(n) Append left: Worst Time: O(1) Append right: Worst T...
74e5a092ce641331fb7360efd90a8e7fa31078e8
jalexvig/algos_datastructures
/data_structures/hash_map.py
3,197
3.90625
4
""" Map backed with hashing. Summary: 1. Closed hash: if there is something in the bucket deterministically figure out a new hash. 2. Open hash: use linked lists in the bucket (means need pointer lookup and may leave hash table). Need to resize as hash table fills up since a full hash table can lead to l...
de71e7b8b80f5446349838a33c2ca98886085c6e
jalexvig/algos_datastructures
/graphs/bellman_ford.py
1,829
3.984375
4
""" Find shortest distances to all nodes in graph from a source node. Summary: Start with distance to source as 0. Once for every other vertex: update **all** distances using the weights from the graph. This ensures that all paths are accounted for since making one hop per iteration means can fully traverse a...
ca20b045f1afac9861735114c3d98713ca15fab5
ARuhala/PythonProjects
/ViolentPythonCookBook/SSHBOTNET/BotnetWithBotArray.py
2,699
3.703125
4
''' This file is part of examples shown in a book "Violent Python Cookbook for Hackers, Forensic Analysts, Penetration Testers and Security Engineers" Most of the code is copied as is, or with minor changes to make naming easier to understand and some comments may have been added where i explain to myself how everythin...
c1150b039fd03044afc42eb898c52ebbb9886dd8
MuaazBin/data-mining-assignment-4
/k_nearest_neighbors.py
5,143
3.640625
4
""" This module uses k nearest neighbors model to classify iris flower dataset. Evaluate model's performance according to accuracy and F1 Score """ # ------------------------- Homework 4: Using and Evaluating a K Nearest Neighbors Model -------------------------- # # Full problem description can be found in problem_de...
805f78a378fe4af67500626bd732521e0100b255
GBMontecillo/test-repo
/test.py
199
3.78125
4
# -*- coding: utf-8 -*- """ Created on Fri Aug 2 11:36:57 2019 @author: arriba """ for num in range(6): for i in range(num): print('*', end='') print('\n') print('Hello World')
5aadf0748647639566441497330b1cf72f80f4c3
iaevan/Pybook1-solutions
/page 96.py
1,291
3.828125
4
#i used the given data which is slightly different than original data in wikipedia #inserting data bd_division_info = {} bd_division_info["Barisal"] = {"district" : 6, "upazila" : 39, "union" : 333 } bd_division_info["Chittagong"] = {"district" : 11, "upazila" : 97, "union" : 336 } bd_division_info["Dhaka"] = {"...
0b370f30f5fc6f2a2e3c9f60a446eded68a34595
abstract-object/tidbits
/connectfour.py
3,040
3.828125
4
def check(board, player): won = "" for row in range(1, 7): for col in range(7): if board[row][col] == player: if row < 4: if board[row + 1][col] == player: if board[row + 2][col] == player: if board [row + 3][col] == player: won = player ...
cf39c22fb1d089f5035b7da25b62914c1a9c1404
HrithikMittal/Hacktoberfest2k19
/Profiles/linked_listagain.py
369
3.546875
4
# Node class class Node: # Function to initialize the node object def __init__(self, data): self.data = data self.next = None # Linked List class class LinkedList: # Function to initialize the Linked # List object ...
448155816cdb699d2e1ab3c17af6ad8c54ce4f61
Tsalyk/HW
/telegram_bot/password_gen.py
884
3.71875
4
from random import randint, choice, sample from string import (ascii_letters, ascii_lowercase, digits, punctuation, ascii_uppercase) def password_gen(password_type: int) -> str: password = "" tmp = ascii_letters + digits if password_type == 1: while len(password) != 8: ...
0ec60d834890e61c97d54419d90b699c0124e22c
Tsalyk/HW
/HW4/practice.py
349
3.796875
4
string = 'Lorem, Ipsum, is, simply, dummy, text, of, the, printing, industry.' new_string = string.replace(",", "") print(new_string) print(string.rfind("s")) print(string.count("i") + string.count("I")) print(new_string[new_string.find("si"):new_string.find(" of")]) print(3 * new_string[:len(new_string)//2-1] + new_s...
003dd81ded36a99da442188eae2f202e010d9d4d
Tsalyk/HW
/HW6/file_practice.py
2,275
4.28125
4
""" Выполните все пункты. * можно описывать вложенные with open(), если это необходимо. * работа в основном с одним файлом, поэтому имя можно присвоить переменной """ f = "file_practice.txt" # 1. # Создайте файл file_practice.txt # Запишите в него строку 'Starting practice with files' # Файл должен заканч...
8e85d5118d2c70717f29c835859dde29445e7a42
bjemison96/AdventureGame
/adventure_game.py
2,843
3.765625
4
import sys import time #initializing the player and the players stats for the game class Player: def __init__(self, name, health, experience, turns_tkn): self.name = name self.health = health self.experience = experience self.turns_tkn = turns_tkn #method to return amount of turns ...
83ce02e7d1d8baed496f95f759de5fc6376e3cfa
BreadFeet/FITCHA_project
/frame/vo.py
953
3.53125
4
# Value Object class CustVO: def __init__(self, id, pwd, name, age, height, weight, size): self.__id = id self.__pwd = pwd self.__name = name self.__age = age self.__weight = weight self.__height = height self.__size = size def getId(self): retur...
05bb287d2049781df774103bc63ec2f237943d8f
mattprice09/IT327
/asg1/LL1.py
2,930
3.671875
4
##### ### # Author: Matt Price # Ilstu ID: 830083370 # Copyright: Matt Price # # HOWTO: # You can run the program using the command line by typing `python /path/to/LL1.py -e "100-((2*(5-3))-2)+3"`. ### ##### import argparse import re # Get expression from user via CLI parser = argparse.ArgumentParser(description='Ar...
c23f066ed4f4f46bdbd19429455ac526daf40cfa
jorgeromv/TC1028
/Batleship_A01252195_A01254247.py
1,656
3.859375
4
# %% #--------------------------------TABLERO--------------------------- from random import randint tablero =[] for x in range(5): tablero.append(["O"] * 5) #-------------- Numero de O en las filas ---------- def imprimir_tablero(tablero): for fila in tablero: print( " ".join(fila)) #------------- ...
f00dbf3879e0a237bed44271ad460489294938d3
varnitsaini/python-dynamic-programming
/KnapsackProblem.py
1,388
3.84375
4
""" Implementing 0-1 knapsack problem Two ways of representation has been depicted here """ """ Naive recursive approach Time complexity : 2^n This approach has exponential time complexity as each subproblem has to be evaluated twice. Although time complexity can be reduced if we use memoisation for evaluate each recu...
2df933a0686658662826341e60307a0127d2014d
user10x/DataStrucutes
/RegexPractice.py
707
3.59375
4
__author__ = 'nichawla' # # ''' meta characters . ^ $ * + ? { } [ ] \ | ( ) # For example, [abc] will match any of the characters a, b, or c # If you wanted to match only lowercase letters, your RE would be [a-z]. # Metacharacters are not active inside classes. For example, [akm$] will match any of the characters 'a',...
f9fd8316dc8141cd6f205033eb70c27e6c2b0d7b
user10x/DataStrucutes
/plaindrome.py
485
3.84375
4
def is_Palindrome(input): counter_start = 0 counter_end = len(input)-1 for element in input: print counter_start, counter_end if counter_start == counter_end : return True if input[counter_start] != input[counter_end]: return False counter_start = cou...
4610ca45539c79656a3ee6629999cbbb334875cb
douglaslaiber/desafio-python-codenation
/main.py
2,496
3.828125
4
# -*- coding: utf-8 -*- import collections import csv # Todas as perguntas são referentes ao arquivo `data.csv` # Você ** não ** pode utilizar o pandas e nem o numpy para este desafio. with open('data.csv') as csv_file: csv_reader = csv.reader(csv_file) csv_header = next(csv_reader) csv_dataset = list(cs...
443874fa9456e6474c72c05eb58dca8507b2edcc
sazzad-hosain/full-stake_pythone_assignment
/class_work-3.py
118
4.0625
4
# 3. Print first 10 natural numbers using while loop. i=1 n=10 while i<=n: print(i) i=i+1 print("End")
cba1238739bf585c5d51917ef71dd036787a8a4e
AP-MI-2021/lab-3-SergiuNeag
/main.py
5,887
4.09375
4
def read_list(): lista = [] lista_str = input("Citeste numere separate de spatiu ") lista_str_split = lista_str.split(' ') for num_str in lista_str_split: lista.append(int(num_str)) return lista def print_menu(): print(' ') print("1. Citire date: ") print("2. Determinare cea ma...
b1f1a16d8872132e0a98013483450e48196b941e
AriyandaP/GitPushPull
/013-03-06.py
4,656
3.71875
4
''' RABU - 03 Juni 2020 ''' import math import random # class namakelas (): # def __init__(self,parameter1,parameter2): # isi yang akan dimasukkan # def metode1 (self,parameter1,parameter2): # mirip fungsi # def metode2 (self,parameter1,parameter2): # mirip fungsi # class classker...
42c10e1c44eecd24f867af9bd8ece00c748e441c
AriyandaP/GitPushPull
/002.py
2,372
3.984375
4
# usia_andi=40 # usia_budi=20 # # * perkalian # # / pembagian # # % sisa pembagian # # // pembagian pembulatan kebawah # # print(math.fabs([pembuat absolut])) # # print(math.pow(angka,pangkat)) # # print(math.sqrt(angka,akar)) # #soal # #8^5 # #pembulatan 9.9 # #-9.5 x 7 # #sisa pembagian 100/70 # import math # an...
29cca5bcc01dd506f9c99dbad8878c913533fac8
AriyandaP/GitPushPull
/pr05.py
8,193
3.765625
4
''' SENIN/SELASA - 18/19 Mei 2020 PR05 - MUHAMAD ARIYANDA PUTRA ''' import math import random angka=[] pilihfungsi=['SORT', 'MEAN', 'MEDIAN', 'MODE', 'VARIANCE', 'STDEV', 'SKEWNESS', 'KURTOSIS', 'LIHAT LIST'] pilihlist=['LIST BIASA','LIST TANPA DUPLIKAT'] n=0 pilih=0 bawah=0 atas=0 stop = False pilih1='' pilih2='' x=[...
5ff90229851e5320137f3931d13f04382d354f2e
AriyandaP/GitPushPull
/fizzbuzz.py
494
3.875
4
number=1 ### RULES INPUT ### fizzbuzz=int(input('Play fizzbuzz until what number : ')) fizz=int(input('fizz for multiply of : ')) buzz=int(input('buzz for multiply of : ')) ### FIZZBUZZ ### while number<=fizzbuzz: if((number%fizz==0) and (number%buzz==0)): print('fizzbuzz') elif((number%fizz==0) and...
979b53f47d0797d9cc3c21b8c8c7d4fd21039c83
joelcarlson/ipython-notebooks
/KMeans_Implementation/kmeans/kmeans.py
4,805
3.921875
4
import numpy as np import random import hashlib def euclidean_dist(vec, arr): ''' returns np array of euclidean distances each row is the distance between the vector and the respective row in the array ''' if not vec.shape[0] == arr.shape[1]: raise ValueError('Vector and array must hav...
d8f9dfc5dc122232df76a9e46c714a5c0b3433d6
naveeneaswar/python-programming
/beginner level/set1(j).py
164
3.5625
4
arr = [] sum=0 n=int(raw_input()) k=int(raw_input()) for i in range(n): a=int(raw_input()) arr.append(a) for i in range(k): sum=sum + arr[i] print(sum)
dc923f3617c58ec07a7c82b0ccd40c933bceb92f
mallimuondu/school-library
/school-librari.py
2,605
4.1875
4
print("hello ") a = { "malli" : "Malli2010!", "nesh" : "1234", "sharon": "sharon2008" } complete = False user = {"malli" : "Malli2010", "nesh" : "1234" } while not complete: username = input("Username: ") password = input("Password: ") if username == user and password == password: continue eli...
829eeb9ac79a3bcd02252468466b96ba440a9ddf
Nickas47/magistr
/lines.py
906
3.734375
4
# Testing skills in game programming from tkinter import * root = Tk() root.title("Python game testing") root.resizable(0, 0) root.wm_attributes("-topmost", 1) canvas = Canvas(root, width=500, height=400, bd=0, highlightthickness=0) canvas.pack() root.update() class Ball: def __init__(self, canvas...
9e9cfbb3f6931949f18bac9ff7c69b2e31387b27
daandouwe/chart-parser
/grammar/add-space.py
868
3.546875
4
#!/usr/bin/env python import sys import re def add_space(s): """Add space between brackets.""" pattern = r'(?P<nt>.{1})\(' # any `(` preceded by something (i.e. not at start). sub = r'\g<nt> (' # put a space beween that something and the bracket. return re.sub(pattern, sub, s) def main(path): ...
f1e94b9f9f1e010d6d5110e507ff10b2dab8a197
HarrisonConeboy/Arrow-Rule-Mastery
/honoursPython.py
9,640
3.640625
4
class Node: def __init__(self, parents, node, children): self.node = node if isinstance(parents, set): self.parents = parents else: self.parents = set() self.parents.add(parents) if isinstance(children, set): self.children ...
cb51fdf4778bfd1c04159056533df6f76e320010
adamintech/awesome-python-projects
/RockPaperScissorsDictionary.py
1,634
3.75
4
import time import random def RockPaperScissors(): print("Welcome to the Arena!") user_name = input("Brave one, what is your name? ") print(f'{user_name.title()} is a strong name, I look forward to watching your battles!') opponent_weapon = ['rock','paper','scissors'] beats = {'scissors':'...
7138dd7975158896b8bebf083af16388ec6f7918
dragon15098/homework123
/Quốc núi - buổi 4/bai5.py
2,341
3.828125
4
def in_map(x, y, screen_width, screen_height): if x < 0 or y < 0 or x > screen_width - 1 or y > screen_height - 1: return False return True def move(x, y, dx, dy): return [x + dx, y + dy] def check_position(px, py, bx, by, choice): if(bx == px): if(by - py == 1) and (choice == 'S'): ...
3f21b1a17adbe15e6afe2a228f83d297efcfe9fa
dragon15098/homework123
/Quốc núi - buổi 3/4.9.7.py
111
3.578125
4
def sum_to(n): sums = 0 for i in range(n+1): sums = sums + i return sums print(sum_to(10))
d290cc03605815a4ed1ce46647532a346c0dafce
jahns/projecteuler
/prob5to25/problem5.py
239
3.703125
4
# We need all the unique factors less than or equal to 20 factors = [16, 9, 5, 7, 11, 13, 17, 19] product = 1 # for each factor multiply the previous product by the new factor for factor in factors: product *= factor print(product)
2c94e954bb82b16f83955cc2e390eb67c8efce56
stephendwillson/ProjectEuler
/python_solutions/problem_4.py
656
3.796875
4
def main(): palindromes = [] for i in range(1, 1000): for j in range(1, 1000): prod = i * j if str(prod) == str(prod)[::-1]: palindromes.append(prod) return max(palindromes) def description(): desc = """ https://projecteuler.net/problem=4 A palindr...
c8506399010d0b8d1ae397902686b3a7ef4bae12
stephendwillson/ProjectEuler
/python_solutions/problem_5.py
717
3.8125
4
import euler_lib def main(): # The smallest positive number that is evenly divisible by all of the # numbers from 1 to 20 is the least common multiple of those numbers. n = 20 lcm = 1 for i in range(2, n + 1): lcm = euler_lib.get_least_common_multiple(lcm, i) return lcm def descri...
a111ae4c8bb0300c38ac7ed26029e3d1c3e026d9
stephendwillson/ProjectEuler
/python_solutions/problem_1.py
524
4.03125
4
def main(): total = 0 for i in range(1, 1000): if i % 5 == 0 or i % 3 == 0: total += i return total def description(): desc = """ https://projecteuler.net/problem=1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these...
f579c4bea47900db4962a71ce69ddb00621047a0
stephendwillson/ProjectEuler
/python_solutions/problem_21.py
1,133
3.75
4
import euler_lib def main(): n = 10000 amicables = [] for a in range(1, n): a_sum = sum(euler_lib.get_proper_factors(a)) # only add pair once [220, 284] not [220, 284, 284, 220] b = a_sum if a > b: continue b_sum = sum(euler_lib.get_proper_factors(b...
41534dbe0b58136af21e85ab2922eac3b1eb1fa0
npv2k1/CTDLvaGT
/ZCode/Python/DSA06019.py
522
3.65625
4
import sys def get_ints(): return list(map(int, sys.stdin.readline().strip().split())) def cin(): return int(input()) def sort_dict_by_value(d, reverse=False): return dict(sorted(d.items(), key=lambda x: x[1], reverse=reverse)) t = cin() for i in range(t): n = cin() a = get_ints() b = sorted(set...