blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
07248cf4efe83dd6fdc53da0c9d9f932ebda7310
ocardozera/Algoritmos-1
/ex3.py
413
3.9375
4
# Construa um programa que recebe três valores, A, B e C. Em seguida, apresente na tela somente o maior deles. a = int(input("Olá, digite um número: ")) b = int(input("Digite outro número: ")) c = int(input("Digite mais outro número: ")) if(a>b and a>c): print(a, "é o maior valor") elif(b>a and b>c): ...
324bdc0af227b0df2935977643aaf79ce194be81
Ades-Angel/CS-As-Level
/Grades and Grades Bar Chart.py
298
3.96875
4
#Grades and Grades chart grades = [] numberOfGrades = int(input('How many grades do you want to enter? ')) for i in range(numberOfGrades): grade = input('Enter a grade: ') grades.append(grade) for grade in grades: bar_chart = int(grade) * 'i' print(bar_chart, grade)
e57827ce24ec0647fcfb13fb199916d7e9811330
crypton480/assorted_data_sci
/basic_classification_keras.py
1,388
3.75
4
#https://www.tensorflow.org/tutorials/keras/basic_classification import tensorflow as tf from tensorflow import keras import numpy as np fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() print("Data Downloaded") train_images = train_ima...
d1a2bc4e0793188664a9e6a9f69ae4021c528a56
asharifisadr/Image-Processing
/HW0_9733044/Q3/HM0-Q3.py
740
3.5625
4
#!/usr/bin/env python # coding: utf-8 # In[23]: import numpy as np from matplotlib import pyplot as plt def mapping(arr): arr=(((arr-arr.min())/(arr.max()-arr.min()))*255) # mapping operation arr = arr.astype('uint8') # changing data type to int return arr rnd = np.random.uniform(-3.2, 9.3, size=(50, ...
e06014466181848464daf9e5b47b9bcb0b8b4136
yao-charlie/SortingAlgorithms
/nlognSort.py
2,068
4.0625
4
def quickSort(unsorted_list): if len(unsorted_list) <= 1: return unsorted_list pivot_index = 0 pivot_value = unsorted_list[pivot_index] # for compared in range(1, len(unsorted_list)): # if unsorted_list[compared] < pivot_value: # unsorted_list.insert(0, unsorted_list.pop(co...
c4bf9469a66b7d969b349a4b774494aca8f780fe
ehallenborg/hackerrank
/DaysofCodeChallenges/10daysofStatistics/day0/weighted-mean.py
289
3.625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) rate = [int(x) for x in input().split()] weight = [int(x) for x in input().split()] summing = 0 for i in range(len(rate)): summing += (rate[i] * weight[i]) print(round(1.0*summing/sum(weight), 1))
cf6a4f384801da34174899ef9400c10296d6e9ab
darroyo97/python
/Jan15/LectureNotes/list_methods.py
682
4.0625
4
# List Insert as specific location numbers = [13, 342, 3, 44, 5] # print(numbers) # numbers.insert(3, 6) # new_num_list = numbers[0:2] # numbers.insert(3, new_num_list) # print(numbers) # List pop removes an item form the end of lost # numbers.pop() # List index returns index of the item in the list # print(number...
516047b7119b09aeac60713632e07355de79b7a9
LucasGVallejos/Master-en-MachineLearning-y-RedesNeuronales
/01-PrincipiosYFundamentosDePython/POO/14.04-ObjetosEmbebidos.py
1,110
3.796875
4
class Fabrica: autos = [] def __init__(self, nombre): self.nombre = nombre self.cantidadArticulos = 0 print("Se creo la Fabrica: ", self.nombre) def __del__(self): print("Se elimino la Fabrica: ", self.nombre) def __str__(self): return "La fabrica {} gener...
cb43a1f39ca9a03b183ebc0de4deb27cd23db209
marinkoellen/python_tasks_repo
/Week4/variables_user_input.py
1,040
4.15625
4
# #Q1 first_number = input("Please enter first input number") first_number= float(first_number) second_number = input("Please enter second input number") second_number = float(second_number) sum_of_inputs = int(first_number) + int(second_number) print(f"The sum of your inputs is {sum_of_inputs}") # #Q2 first_number =...
cb84e75d92901ce56e4212831cf08c83f3222b09
jiluhu/dirtysalt.github.io
/codes/contest/leetcode/longest-continuous-increasing-subsequence.py
567
3.5625
4
#!/usr/bin/env python # coding:utf-8 # Copyright (C) dirlt class Solution: def findLengthOfLCIS(self, nums): """ :type nums: List[int] :rtype: int """ n = len(nums) ans = 0 j = 0 for i in range(1, n): if nums[i] <= nums[i - 1]: ...
e29d793619dd7d4b5921f94ebbc4fd850099b503
Anandhukrishnan201/an2211
/flow control/looping/sepration.py
157
4.125
4
num=int(input("enter the number:")) i=1 even=0 odd=0 while(i<=num): if i%2==0: even+=i else: odd+=i i+=1 print(even) print(odd)
ff0aecd2fdf7d95031f7e8dd5d6a9b5ca2737321
edsonbonfim/Solution-URI-Online-Judge
/1134 - Tipo de Combustível.py
321
3.5
4
alcool = 0 gasolina = 0 diesel = 0 while True: n = int(input()) if n == 4: break elif n == 1: alcool += 1 elif n == 2: gasolina += 1 elif n == 3: diesel += 1 print("MUITO OBRIGADO") print("Alcool: {0}\nGasolina: {1}\nDiesel: {2}".format(alcool, gasolina, diesel)...
9848498e5e6664041dee72b53c93bdfd9f659087
cromod/Collision
/display.py
2,826
4.09375
4
import Tkinter as tk import solver def _create_circle(self, x, y, r, **kwargs): """Create a circle x the abscissa of centre y the ordinate of centre r the radius of circle **kwargs optional arguments return the drawing of a circle """ return self.create_oval(x-r, y-r, x+r, y+r,...
28ff72c095fa0e33570991c38c8a39f69e92c29e
NakayamaYutaro/PartOfSpeechOrder
/WriteToTxt.py
199
3.515625
4
import sys class write_to_txt: def insert_text(self,text_name,text_content): path_w = text_name with open(path_w,mode='a') as f: f.write(text_content+"\n")
7c9816285575f88d80eee89bbacc1fb5a287a03c
DanJamRod/mis3640
/session08/rotate_word.py
912
3.8125
4
def letter_cypher(letter, n): """ Ceaser cypher moving letter down the alphabet by n places """ if ord("a") <= ord(letter) <= ord("z"): return (ord(letter) + n - ord("a")) % 26 + ord("a") elif ord("A") <= ord(letter) <= ord("Z"): return (ord(letter) + n - ord("A")) % 26 + ord("A") el...
1c94ca7ac1bc026b9a302bfcd47f4b2112bb317e
prashantkaulwar/Python-Practice
/python/Class/A4/Assignment4_1.py
204
3.921875
4
def testfunc(num): return lambda num : num * num def main(): number = int(input("Please Enter Number: ")) n = testfunc(number) print("Squre Number: ",n(number)) if __name__ == "__main__": main()
96745e04e5009b795e2dfc738d21e114f5fea698
xero7689/xStockSystem
/crawler/utils.py
1,190
3.71875
4
import sys import os import datetime today = datetime.datetime.today() cur_year = today.year cur_month = today.month cur_day = today.day def year_generator(start_year=2010, end_year=cur_year): dates = [] for y in range(start_year, end_year+1): year = str(y) for m in range(1, 12+1): ...
c27349ec5aaa6eb68617a0e7c4d284a7830e832b
maci2233/Competitive_programming
/CodeForces/B/519_2.py
513
3.625
4
def create_dict(nums): d = {} for num in nums: if num in d: d[num] += 1 else: d[num] = 1 return d input() d1 = create_dict([int(i) for i in input().split()]) d2 = create_dict([int(i) for i in input().split()]) d3 = create_dict([int(i) for i in input().split()]) for k...
be3cd7bbf08091715dd31d638516e8ebe6798eeb
ihuei801/leetcode
/MyLeetCode/python/Longest Common Prefix.py
584
3.75
4
### # Vertical Scan # Time Complexity: O(n) # Space Complexity: O(1) ### class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if not strs: return "" end = 0 for i in xrange(len(strs[0])): ...
4df45376c073557a8652616e4699e81c9c256f73
Gauravs-2k/CodeForce
/Hulk.py
376
3.640625
4
hate = 'I hate' love = 'I love' output = '' layer = int(input()) for i in range(1, layer + 1): if i % 2 == 1: if i < layer: output += hate + ' that ' else: output += hate + ' it' else: if i < layer: output += love + ' that ' el...
fdff312743dcaa2b8ebd9348b30d487575eded88
lipegomes/python-django-udemy-studies
/Lessons/Section-02/lesson_0033.py
643
4.125
4
# 33. For in - Estrutura de repetição em Python # Função range(start=0, stop, setp=1) print("----****----") text = "Python" new_str = "" for letter in text: if letter == "t": new_str += letter.upper() elif letter == "h": new_str += letter.upper() else: new_str += letter print(f"...
cd1cb81857b9ac5f40257db90cf2c7882649d0cf
mustafahavan/.vscode
/Sqlite.py
682
3.609375
4
# import sqlite3 as sql # db = sql.connect(r"D:\muratHANCI\iedb.db") # cursor = db.cursor() # cursor.execute("SELECT * FROM V_HESAP") def SozlukGetir(tabloid): import sqlite3 as sql db = sql.connect(r"D:\muratHANCI\iedb.db") cursor = db.cursor() cursor.execute("SELECT sozluk_id,sozluk_adi FROM HSP_SOZL...
0e8bffd68a301c3ad6797bc23bdbab667d110c97
svmeehan/FuelEfficiencyCalc
/airport.py
1,587
3.78125
4
import csv import Currency class Airport: #CONSTRUCTOR def __init__(self, airportID, airportName, cityName, country, code, icaoCode, lat, long, alt, timeOffset, DST, timeZone, CurrencyAtlas): self.airportID = airportID self.airportName = airportName self.cityName = cityName self.country = country self.code...
9f9254b2f919ad367775f1760bb75f858e896919
OhadVal/Monty-Hall
/monty_hall_problem.py
11,806
4.03125
4
from tkinter import * import tkinter.messagebox import random import os # defining the game class class MontyHallGame: def __init__(self): self.window = Tk() # initializing the gui window self.window.title("Monty Hall Game") # setting the title for the window self.doorColor = ...
e0fe0d38e2e9362ba7b68926403231a3d713e7db
bhavyakh/decrypto
/decrypto/cipher/ascii_shift.py
841
3.71875
4
class AsciiShift: # Protected: def _decrypt(message, key=None): ans = "" # traverse message for i in range(len(message)): char = message[i] # Adds key -> % 255 ans += chr((ord(char) + key) % 255) return ans # Public: @classmethod ...
ae657c78a6ead891100c576278280ca2a911fc02
jedzej/tietopythontraining-basic
/students/olszewski_bartosz/lesson_01_python_basics/sum_of_digits.py
134
3.609375
4
a = int(input('give a number ')) s = a // 100 a = a - s * 100 d = a // 10 a = a - d * 10 j = a // 1 print('sum of digits', d + s + j)
0a79956b47b76fd7165991a4aaf9dba8e6c37e36
Vides99/FP_TareasClases_00368019
/Tareas/phyton/suma/sumaVariosNumeros.py
375
3.96875
4
cantidadNumeros = 0 numerosSumatoria = 0 resultado = 0 print("en este programa haremos la suma de la cantidad de numeros que tu quieras") cantidadNumeros = int(input("Cuantos numeros deseas sumar?")) for i in range(1,cantidadNumeros + 1): numerosSumatoria = int(input("ingresa el valor")) resultado = resultado +...
c2accf9ca71a7001d155c3c7bd0f1300fe8b4d58
woorud/Algorithm
/boj/1668 트로피 진열.py
321
4
4
def ascending(array): now = array[0] res = 1 for i in range(1, len(array)): if now<array[i]: res += 1 now = array[i] return res n = int(input()) array = [] for i in range(n): array.append(int(input())) print(ascending(array)) array.reverse() print(ascending(array)...
58ea5c961dcbf3eab1a5b45b3ce612c8fc57dd68
wilsonvetdev/micro-credential-cuny
/week-four/magic8.py
821
4.0625
4
import random name = input("What's your name? ") question = input("What would you like to ask? ") ball_answer = "" random_number = random.randint(1, 9) # print(random_number) if random_number == 1: ball_answer = "Yes - definitely." elif random_number == 2: ball_answer = "It is decidedly so." elif random_numbe...
85fd3e536a3943a1ccf6c36d02f576304e788940
songszw/python
/python小栗子/t121.py
278
3.609375
4
def showSuShu(num): count = num//2 while count>1: if num % count == 0: print('%d的最大公约数是%d'%(num,count)) break else: print('%d是素数'% num) anum = int(input('请输入一个数字:')) showSuShu(anum)
7abaed213cdc7af8ed01d1b29d2e030216c8415e
hellstrikes13/sudipython
/string_even_odd.py
310
3.53125
4
t = int(raw_input('no of testcases: ')) lst = [] lst2 = [] for i in range(t): s = raw_input('enter a string: ') for i in range(len(s)): if i % 2 == 0: lst.append(s[i]) else: lst2.append(s[i]) print ''.join(lst),''.join(lst2) lst[:] = [] lst2[:] = []
7afbd7d2dc1e809a4700615c43ef09151746bda7
Koozzi/Algorithms
/SAMSUNG/BOJ/20061_모노미노도미노2_20210422.py
3,839
3.640625
4
def stack_block(t, x, y): if t == 1: # 파란색 부분 blue_y = 9 for j in range(5, 10): if board[x][j] == 1: blue_y = j - 1 break board[x][blue_y] = 1 # 초록색 부분 green_x = 9 for i in range(5, 10): if board[i][y] =...
6979d0f090e789616a7cc2e88089a0f54411dfde
niyatim23/search-algorithms
/homework3.py
10,530
3.53125
4
# ('../resource/asnlib/public/input1.txt') from collections import deque import heapq def read_input(path): input_data = open(path, 'r') algorithm = input_data.readline() grid_size = list(map(int, input_data.readline().split())) landing_site = list(map(int, input_data.readline().split())) max_elev...
1a47b7bc9536cfa7e7b31e27e9e318a13394e699
feecoding/Python
/Classes/Program 1.py
310
3.53125
4
##created by feecoding class enployer: pass t=list() for i in range(5): t.append(enployer()) print("Enter the name: ") t[i].nom=(input()) t[i].prenom=(input()) t[i].salair=(int(input())) p=0 for i in range(1,5): if(t[p].salair<t[i].salair): p=i print(t[p].nom,t[p].prenom)
0b7678c7356666e240234b3e0529b048930195f0
amaravindmenon/tcpportscanner
/tcpscan.py
1,960
3.875
4
#TCP Port Scanner. This help to find all the open port in a given IP #address from socket import * from sys import * import re import threading regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( ...
d06ed0a907b85ec345b81c4546fcc47f70965bd1
scottkerstetter/dungeon_crawl
/dungeon.py
14,240
3.515625
4
#import libs from sys import exit # script and version info script = "dungeon.py" version = "1.0.0" author = "S Kerstetter" created = "2020-12-05" last_modified = "2020-12-06" # Define player and monster stats hp = 10 attack = 1 # THE MEAT def boss_room(player_name, player_hp, player_attack): monster_dead = Fals...
abc4106344f04db9913e3a7b4dc66cac709b20ff
AleksandrBud/Python
/Lesson3/easy.py
1,594
4.25
4
# Постарайтесь использовать то, что мы прошли на уроке при решении этого ДЗ, # вспомните про zip(), map(), lambda, посмотрите где лучше с ними, а где они излишни! # Задание - 1 # Создайте функцию, принимающую на вход Имя, возраст и город проживания человека # Функция должна возвращать строку вида "Василий, 21 год(а),...
c48b89a1341bee13811b31ac85b6fedb653f5739
AleByron/AleByron-The-Python-Workbook-second-edition
/Chap-1/ex25.py
199
3.765625
4
s = int(input('Insert a period in seconds:')) m = s//60 h = m//60 d = h//24 s = s - (m*60) m = m - (h*60) h = h - (d*24) print("The period in second is", "%d:%02d:%02d:%02d." % (d, h, m, s))
cd43b2093b42842da52c2c469ddf0c70806ac613
AnkithaBH/Python
/Basics/Fibonacci.py
260
4.15625
4
"""The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it.""" a=0 b=1 print(a) print(b) for i in range(1,10+1): c=a+b print(c) a=b b=c
ece88a43b7eb860cbe4d7a15c03813ac0870fbdd
siddhant68/Cool_Coding_Questions
/n_queens_2.py
860
3.65625
4
count = 0 def n_queens(n, matrix, row): global count if row == n: print(matrix) count += 1 return for i in range(n): if is_safe(row, i, matrix): matrix[row][i] = 1 n_queens(n, matrix, row+1) matrix[row][i] = 0 def is_safe(row, col, matrix...
413b0227fd667ca3326984414caaaa3d0bdaeda2
ChannithAm/PY-programming
/algorithm/3-interpolation-search.py
840
3.71875
4
def interpolation_search(alist, x): n = len(alist) low = 0 high = n - 1 while((alist[high] != alist[low]) and (x >= alist[low]) and (x <= alist[high])): mid = low + ((x - alist[low]) * (high - low) // (alist[high] - alist[low])) print("low = {}, high = {}, mid = {}".format(low, high, mi...
201af89e0b217ef843780c0b648770816ff75516
GonzaloFerradas/my_files_py
/FOR.py
1,118
4
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: numeros = [1,2,3,5,6,7,8,9,10] inidice = 0 while (indice < len(numeros)): print(numeros[indice]) inidice +=1 # In[2]: for i in numeros: print(i) # In[1]: indice = 0 numeros = [0,1,2,3,4,5,6,7,8,9,10] for numero in numeros: numeros[indice] *= 10...
f85d517e25d20801a2083d48f3eda99f6188d22b
fernandosavio/estudos-phyton
/python-brasil-wiki/1.EstruturaSequencial/exercicio_02.py
553
4.3125
4
#!/usr/bin/env python """ Faça um Programa que peça um número e então mostre a mensagem "O número informado foi [número]." """ if __name__ == "__main__": numero = None while not numero: try: numero = float(input("Informe um número: ")) if numero.is_integer(): n...
86a0d95fd10565edbc8411f6f98069b395ee320a
kashyapa/interview-prep
/revise-daily/arjuna-vishwamitra-abhimanyu/educative/4-dynamic-programming/fibonacci/1_calculate_fibonacci.py
638
3.984375
4
def calculate_fibonacci(n): if n < 2: return calculate_fibonacci(n-1) + calculate_fibonacci(n-2) def calculate_fibonacci_memo(n): memo = [-1 for _ in range(n+1)] return calculate_fibonacci_memo(memo, n) def calculate_fibonacci_recur(memo, n): if n < 2: return n if memo[n] >= 0: ...
cf0f674bae5ae37096fc635ebd84726027c815ea
IsolatedRain/code_wars
/completed/Rectangle Cipher Puzzle.py
502
3.53125
4
def cipher(phrase: str): n = len(phrase) a = 'this will probably not be fun' b = "tiks zjop twrggfrf uwz kl pcx" res = [] t = [] for i in range(n): if a[i] == " ": res.append(" ") t.append(" ") continue res.append((ord(b[i]) - ord(a[i]), i)) ...
40c44e944757ba88a81a2f4ce5e92533448d22e9
techiemilin/PythonPractice
/IfElseCondition.py
1,329
4.15625
4
''' Created on Apr. 4, 2019 @author: milinpatel ''' # Example 1 ( we can put condition) a = 16 if a > 15: print("condition satisfied") else: print("condition is NOT satisfied") print("******************") # Example 2 ( we can put True or False) if True: print("condition satisfied") else: print("c...
745246db47ad2549111992f447622e7449722c73
RPMeyer/intro-to-python
/Intro to Python/Homework/CSC110_2_Ch08/hw_08_ex_07.py
706
4.125
4
# HW:7,8,10 # #Write a function that reverses its string argument, and satisfies these tests: # test(reverse("happy") == "yppah") # test(reverse("Python") == "nohtyP") # test(reverse("") == "") # test(reverse("a") == "a") import sys def test(did_pass): ''' print result of a test ''' linenum = sys._getframe(1)....
638717bbf896d1f42e28495568523aab16740490
wentaoxu415/tictactoe_ai
/play.py
1,259
3.921875
4
def main(): print("Welcome to Tic Tac Toe") board = Board() board.print_board() while not board.is_full(): winner = board.check_winner() if winner is not False: print("Winner is {}".format(winner)) break if board.is_full(): print("Tie Game") class Board(object): def __init__(self): self.positi...
8a3a324ef9ce97af4817b612d8f3dc97c7454fb9
KevinKnott/Coding-Review
/Month 01/Week 02/Day 02/b.py
1,969
3.875
4
# 203. Remove Linked List Elements: https://leetcode.com/problems/remove-linked-list-elements/ # Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head. # Do the following: # simply check if node.next.val == val # if it does skip ov...
bbc958ef0f60cbe9045e97cea12241683b396ddd
SoliDeoGloria31/study
/AID12 day01-16/day12/exercise/circle.py
494
4.0625
4
# 面积 = 圆周率 * 半径**2 # 半径 = math.sqrt(面积/圆周率) # 练习: # 1. 输入一个圆的半径,打印出这个圆的面积 import math # 导入math模块 r = float(input("请输入圆的半径: ")) area = math.pi * r ** 2 print("半径为:", r, '的圆的面积是:', area) # 2. 输入一个圆的面积,打印出这个圆的半径 area2 = float(input("请输入圆的面积: ")) r2 = math.sqrt(area2 / math.pi) print('面积为: ', area2, '的圆的半径是:', r2) ...
17c7af073ae2a970b9f12d42464d880ea252499b
green-fox-academy/wenjing-liu
/week-05/day-03/power.py
415
4.1875
4
''' # Power Given base and n that are both 1 or more, compute recursively (no loops) the value of base to the n power, so powerN(3, 2) is 9 (3 squared). ''' base, power_num = [int(x) for x in input('Please input base and power (press enter to end):\n').split()] def power(base, power_num): if power_num == 1: r...
b3aabde2d9dfcf9ab55d56aa8a5f387f3d9f8b44
vishalbedi/Kata
/python/LongestPalindromicSubstring/main.py
709
3.734375
4
def longetst_Palindrome(input: str)-> str: if len(input) <= 1: return input longest_string = "" for i in range(len(input) + 1): len_odd = palendrome_length(input, i,i) len_even = palendrome_length(input, i, i+1) len_palindrome = max(len_odd, len_even) if len_palindr...
8d086e23a2a56668fd7cb0ac516ad111242f9d85
Aasthaengg/IBMdataset
/Python_codes/p03080/s978984970.py
254
3.59375
4
def main(): N = int(input()) s = input() count = 0 for c in s: if c == "R": count += 1 else: count -= 1 if count > 0: return "Yes" return "No" if __name__ == '__main__': print(main())
59c1d9d8048d6783071f1f367de6a773036be396
joramwessels/nlp
/Part A/posgram.py
3,517
3.5
4
#! /usr/bin/python import sys # internal 'line start' and 'line end' representation. LS = "START/START" LE = "STOP/STOP" def main(): tr, wt = viterbiMatrices(sys.argv[1], 2, line_ends=["./.", "======================================"], word_ends=[' ', '\n'], tag_del='/') print([(key, val) for key, val in list(t...
ab901d3ddbf46efddbf9598ee3d5206ac4f7db12
Luolingwei/LeetCode
/BreadthFirstSearch/Q1210_Minimum Moves to Reach Target with Rotations.py
2,937
3.6875
4
# 思路: bfs, 一共四种情况,往右,往下,顺时针转,逆时针转 # 这里用set作为bfs,方便查找target,每迭代一轮,判断target in bfs,O(1)时间,不需要每个进行对比. 同时,bfs用set可以去除每一轮中的重复位置 class Solution: def minimumMoves(self, grid): bfs, dist, n = {(0, 0, 0, 1)}, 0, len(grid) visited, target= {(0,0,0,1)},(n - 1, n - 2, n - 1, n - 1) # down, right, coun...
2c34ee79cb70a8df6583feea4fd77c8e01f1b56a
Sparkliang/DataStructure
/list_sort.py
1,251
3.90625
4
# Data Structure-Ch3 Linear List # Sequenced List Sort && Single Linked List Sort # Liang # 2019/4/4 # By Moving Elements def list_sort(lst): for i in range(1, len(lst)): x = lst[i] j = i while j > 0 and lst[j-1] > x: lst[j] = lst[j-1] j -= 1 lst...
188245bbf848dc2bf1b42ee43165992a3e83cf98
Omar-V2/intelligent-collision-avoidance
/src/game/create_map.py
474
3.703125
4
from src.game.obstacle import Rectangle, Circle def create_map(): """ Returns an array of randomly placed and sized obstacles (shapes) that will serve as map/obstacle course for the agents to traverse through wihtou any collisions. """ obstacles = [] # make sure id (last argument of obstacl...
37a66d994b6e2665e13225c72ee059a7bec0aba7
rohanprateek/pythonprograms
/HighestValueinWindow.py
1,004
3.671875
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 12 11:31:19 2021 @author: rohan """ class Solution: # @param A : tuple of integers # @param B : integer # @return a list of integers def slidingMaximum(self, A, B): if B > len(A): return [max(A)] from collections impo...
1d9f49fe7e5c1ab46f8779ad2e8e03cee41df042
ShreekantSaurabh/Play-with-Python
/Tkinter/1_t1.py
1,355
4.65625
5
from tkinter import * root = Tk() #To create blank window with minimize, maximize and Close #theLabel = Label(root, text = 'This is too easy') #Created a label #theLabel.pack() #pack() is used To display on the screen topFrame = Frame(root) #Dividing the screen in top and bottom frame topFrame.pack() ...
ea9d1c59423f670fd77df4a47b6f216b5297662d
gabriellaec/desoft-analise-exercicios
/backup/user_006/ch27_2020_03_19_18_43_46_801561.py
191
3.796875
4
tem_duvidas= True while tem_duvidas: resposta_do_aluno = input("Voce tem duvida?") if resposta_do_aluno!="nao": print("Pratique mais") else:tem_duvidas=False
d96dfb487cadf1b2043f775145cad381590c06d2
TadejVarl/Basic_Track1
/week_2/Exercise 2.14.7.py
210
4.03125
4
time_now_1 = input('What is the time now?') time_now = int(time_now_1) hours_to_wait_1 = input('How long to wait for the alarm? :') hours_to_wait = int(hours_to_wait_1) print((hours_to_wait % 24) + time_now)
c1708def40e95295835d6bef8bc1caab08c9d70e
anila-a/CEN-206-Data-Structures
/lab03/ex4.py
465
4.375
4
''' Program: ex4.py Author: Anila Hoxha Last date modified: 03/10/2020 Write a short Python function that takes a positive integer n and returns the sum of the squares of all the positive integers smaller than n. ''' def sum_of_squares(n): sum = 0 while (n > 0): sum += n ** 2 # Add square ...
679ddb83c6ca7989a38620042c93d7a9130b717d
Jackthebighead/recruiment-2022
/algo_probs/jzoffer/jz28.py
3,284
3.8125
4
# 题意:对称二叉树问题。请实现一个函数,用来判断一棵二叉树是不是对称的。如果一棵二叉树和它的镜像一样,那么它是对称的。 # 题解1:非递归做法,用两个辅助栈,配合dfs。一个栈记录左子树,一个记录右子树。入栈顺序不同来实现每次弹出比较镜像对象。 # 题解1改良:用collection.deque的双端队列来完成。 # 题解2: 递归做法。判断左子树右子树。要分两个phase来讨论:若都不存在则true,若只有一个存在则false,若都存在则进入下一个phase # 若存在且两者val相同则递归 左的左,右的右 and 递归 左的右,右的左。若不相同则false。 # Definition for a binary tree no...
ac732309f3774469b4baf381dfabaef75c0d7c16
asellis/Practice
/MySQL/example.py
8,956
4.25
4
# An example of using MySQL with Python # Creating a school data base with information about students, classes, etc. # Using XAMPP for the database and pymysql as the python connection library import pymysql # MySQL code for creating tables using XAMPP """ CREATE TABLE students(id INTEGER PRIMARY KEY AUTO_INCRE...
6f406d1fb00ba0c51f6bf667b675f1649e4b9e37
djsaint03/python-examples
/server.py
4,397
3.828125
4
from flask import Flask, render_template, request, jsonify, make_response import csv import json import sqlite3 import data.statements as sql_statement import data.students as students_dictionary app = Flask(__name__) def create_table(): connection = sqlite3.connect('training.db') mycursor = connection.curso...
b25adabd624a1e3490f456f49ce05d53e7460b06
Abhishek2271/ClusterDataWithKmeans
/Clustering/StopWordsFilter.py
2,864
3.890625
4
# import statements import nltk import re import sys sys.path.insert(1, 'Clustering') import Tokenizer import pandas as pd """ <Created Date> Nov 9, 2018 </CreatedDate> <About> Use NLTK to get a stop words filter for tokens. The stop word list is a default one provided by nltk with nothing added ...
b3714ca4bdcb06b1533d22b35400c24770334820
CodeHemP/CAREER-TRACK-Data-Scientist-with-Python
/02_Intermediate Python/4-loops/02_basic-while-loop.py
1,041
4.3125
4
''' 02 - Basic while loop Below you can find the example from the video where the error variable, initially equal to 50.0, is divided by 4 and printed out on every run: error = 50.0 while error > 1 : error = error / 4 print(error) This example will come in handy, because it's time to build a while loop yourse...
c6e7a33869f654d910173785a852e79b2dfc4141
irobbwu/Python-3.7-Study-Note
/basic Grammar/21. 文件:一个任务.py
12,233
4.15625
4
# 10.12 作业 # 集合:在我的世界你就是唯一 # 课堂作业:将小甲鱼和客服的话分开 r = open('/Users/yasmine/Documents/学习/python/files/record.txt') def new_file(): boy_name = 'boy_' + str(count) + '.txt' boy_txt = open(boy_name, 'w') boy_txt.writelines(boy) girl_name = 'girl_' + str(count) + '.txt' girl_txt = open(girl_name, ...
583fd0f202e65b4c4554f9d0985b505b54953dba
aniaskudlarska/148-work
/148 A1/starter_code/distance_map.py
852
3.921875
4
"""Assignment 1 - Distance map (Task 1) This module contains the class DistanceMap, which is used to store and lookup distances between cities. This class does not read distances from the map file. All reading from files is done in module experiment. Your task is to design and implement this class. Do not import an...
e8d10b55c843a2cc152b51dfb60cbcb654db9823
NoisyPunk/IntensivePython
/src/day_1/01 hours_salary.py
157
3.84375
4
hour_cost = int(input('Hourcost >> ')) day_quantity = int(input('Days >> ')) total = (hour_cost * 8) * day_quantity ndfl = total * 0.87 print(total, ndfl)
af54b54f923cee6ebe11674e1c2ac3a7b6c75ec7
FlareJia/-Python
/f2.py
3,893
3.828125
4
#如果要让内部属性不被外部访问,可以把属性的名称前加上两个下划线__,在Python中,实例的变量名如果以__开头,就变成了一个私有变量(private),只有内部可以访问,外部不能访问,所以,我们把Student类改一改: #-*- coding: utf-8 -*- class Student(object): def __init__(self, name, score): self.__name = name self.__score = score def print_score(self): print('%s: %s' % (self...
3f038a1861c8d00873558513bb7852f8cb0ba22e
chenbaoshun/AutomationTesting
/AutoInerface_project/Day01_pythonBasic/09-dict04.py
423
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @File : 09-dict04.py # @Author : CHIN # @Time : 2020-12-20 22:51 ''' 数据类型的转换 ''' str1 = '9.6' str_list = str1.split('.') print(str_list) list_str = '.'.join(str_list) print(list_str) dict1 = {'name':'coco','age':18} dict_list = dict1.items() # dict_list = li...
b98a74a8f8e22ab559773dc159b5c0baed597346
INYEONGKIM/programming-fundamentals
/week4/practice4_3.py
280
3.765625
4
def insert(n,ss): left = [] while ss != []: if n <= ss[0]: return left+[n]+ss else: ss, left = ss[1:], left+[ss[0]] return left+[n]+ss # print(insert(1,[2,4,5,7,8])) # print(insert(6,[2,4,5,7,8])) # print(insert(9,[2,4,5,7,8]))
212463e8116e5ced585ae2dd8bdec6179cc7f6f2
francisaddae/PYTHON
/joinedList.py
453
3.859375
4
def joinedList(n): x = [ i for i in range(1,n+1)] a = [ i for i in range(1,n+1)] a.reverse() return x + a def removePunctuation(s): s = list(s) for i in range(len(s)): if not(ord(s[i]) in range(65,91)) and not((ord(s[i]) in range(97,123))): s[i] = ' ' else: continue return ''....
cc7f05efb94d049525c445f6195b54e918b352e5
timadjordan/3.14-thon
/lattice.py
365
3.578125
4
# Tim Jordan # 9/16/14 # This program creates a sodium chloride lattice using vpython import visual as vi total=0 twototal=total+1 for i in range(3): twototal+=1 for j in range(3): twototal+=1 for k in range(3): total+=1 if total%2==0: coloring = vi.color.blue else: coloring = vi.color.red vi...
5f0dcd02e0fe68abf61da0bf968552677ad0d111
bala4rtraining/python_programming
/python-programming-workshop/OOPython/30.args.py
200
3.703125
4
def multiply(*args): z = 1 for num in args: z = z + num print(z) print(args) multiply(4, 5) multiply(10, 9) multiply(2, 3, 4) multiply(3, 5, 10, 6) multiply(3, 5, 10, 6, 10)
c1c8d0a99f9123ec4c1db3bd938960090363d79b
ElizabethBeck/Class-Labs
/BeckLab06.py
1,238
3.765625
4
import random # Initialize array myArray = [] a = 0 b = 1 size = 50 j = 0 n =1000 # Populate array with size = 25 random integers in the range 0 - 1 #and repeat for n times while (j < n): for k in range(size): randNum = random.randint(a,b) myArray.insert(k, randNum) j = j + 1 # Display array...
8491b8af495ce810ae29e9e12e0e11825d3399da
jagfirerwalker/HackerRank
/kangaroo_jump.py
1,426
3.96875
4
#!/bin/python3 import sys ''' def kangaroo(x1, v1, x2, v2): k1 = x1 k2 = x2 for i in range(1000): k1 += v1 k2 += v2 if k1 == k2: return True return False ''' def kangaroo(x1, v1, x2, v2): x, y = sorted([[x1, v1], [x2, v2]], key=lambda el: el[0]) ...
47f9de9f6ab59cb06eedd515b0d301911fbbe2c1
ubuntunux/WorkSpace
/Codes/RectArea/RectArea.py
600
3.765625
4
''' Python으로 작성했습니다. 면적에 해당하는 좌표를 리스트에 집어넣고 중복되는 영역은 무시하고 리스트 원소의 갯수를 센다. ''' def getArea(rects): pointList = set() for rect in rects: for x in range(rect[0], rect[2]): for y in range(rect[1], rect[3] pointList.add((x,y)) return len(pointList) rects=[] print("Input rectangle 4 ...
b9758e7a8d665e11cb0211a9f484a6cbafc590cb
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/chnjea007/question1.py
456
4
4
# A8Q1 def isPalindrome(s, index): if len(s) == 1: return True if (index >(len(s)//2)-1): return True else: if s[index] == s[len(s) - 1 - index]: return isPalindrome(s, index+1) else: return False text = input("Enter a string:\n")...
f21993350f70f78af69771b104b2ed211d2f24a4
jerrytamchiho/Jerry3DRepo
/read_pickle.py
631
3.578125
4
import pickle import argparse def parse_args(): parser = argparse.ArgumentParser(description='Read pickle file.') parser.add_argument('--file_path', help='path to pickle file', required=False, default='/media/jerry/HDD/NMini/infos_val.pkl') args = parser.parse_args() dict_args = vars(args) for k ...
6511c3514317661fb15379ed5a7c4f91a67027cd
navjordj/BioSim_G10_Eirik_Jorgen
/biosim/animals/animal.py
9,500
3.71875
4
__author__ = 'Eirik Høyheim, Jørgen Navjord' __email__ = 'eirihoyh@nmbu.no, navjordj@gmail.com' from math import exp from typing import Union, Dict, Tuple import numpy as np class Animal: """Documentation for Animal superclass implemented using the specifications in PEAP requirements """ params: dic...
443f8e534efdcf7beef6e37c532eed5cf60a4cd7
festus14/Facebook-Mentorship-SWE
/LinkedLists/PalindromeLL-O(1).py
1,207
4.375
4
""" Examples For Singly Linked List: - [1,2,1] => True - [1,2,3], 1 => False - [1,1] , 1 => True - [1] => True Steps 1. Get the middle of the linked list. 2. Reverse right half of the list. 3. Compare left half of the list with its reversed right half. 4. Time complexity i...
39af62215324dff6ac4df88ef886a12d1fb4adfe
nyhu/PyThonSnake
/src/collider.py
1,840
3.734375
4
""" ... """ from src import snake, food from pygame import font class Collider(object): """docstring for ClassName""" def __init__(self, size_max): self.decimal_pi = "3@14159265359" self.max = size_max self.snake = snake.Snake(self) self.food = food.Food(self) # Food.spa...
e27d8befe7082dac3d84db02516fed9650d0ccaf
chaunceysun82/leetcode-questions
/Chauncey_code/92_reversed_linked_list_II.py
845
3.921875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode: if left == right or head.next is None: return head ...
f878cc29140450a009f4b225df749c2088275096
Aluriak/PokemonPhylogeny
/common/pokemon.py
2,701
3.78125
4
# -*- coding: utf-8 -*- ######################### # POKEMON # ######################### ######################### # IMPORTS # ######################### ######################### # PRE-DECLARATIONS # ######################### ######################### # CLASS # #...
ac19113cce45ef824ca509e019e6da23414b822b
Tareikie/CSSI19
/Day7/mystory.py
548
3.59375
4
adjective1 = raw_input("Enter an adjective:\n") adjective2 = raw_input("Enter a second adjective:\n") noun = raw_input("Enter an noun:\n") verb1 = raw_input("Enter an verb:\n") verb2 = raw_input("Enter a second verb:\n") story = """Jack be nimble, Jack be quick Jack jump over the candlestick Jack be {0}, {1} be cool J...
511b43f80a63e424aa9403ac3a9d21529eca3082
Vanderson10/Codigos-Python-UFCG
/4simulado/tabelaquadrados/Chavesegura/chavesegura.py
1,009
4.125
4
#analisar se a chave é segura #se não tiver mais que cinco vogais na chave #não tem tre caracteres consecultivos iguais #quando detectar que a chave não é segura é para o programa parar e avisar ao usuario #criar um while e analisar se tem tres letras igual em sequencia #analisar se tem mais que cinco vogais, analis...
7d159dbc91901a6d9302c3f347bc79c7ed96e672
Leorfk/Exercicios-Python
/Cev_exercicios/ex0014.py
146
3.875
4
c = float(input('Digite a temperatura em ºC: ')) f = ((9*c)/5)+32 print('A temperatura de {:.2f}ºC em Fahrenheit é {:.2f}ºF'.format(c, f))
3d992b041cdc5482faf8fea65edab54cb2f873c9
shivamgupta08/Face-Detection-Recognition
/face_detection.py
2,000
3.546875
4
## Face Detection using OpenCV and HaarCascades ## Haarcascade Classifier is already trained on a lot of facial data ############# Once done detecting -> PRESS 'q' to BREAK THE LOOP ################# import cv2 ##1 Capturing the device from which we want to read our video stream, 0 is for default webcam cap = cv2.V...
757cf5ff2d28de22c725b773a5d176469af07627
Goour/python-cookbook-demo
/chapter-02/_textwrap.py
533
3.890625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # author : haymai """ 你有一些长字符串,想以指定的列宽将它们重新格式化。 """ import textwrap if __name__ == '__main__': s = "Look into my eyes, look into my eyes, the eyes, the eyes, \ the eyes, not around the eyes, don't look around the eyes, \ look into my eyes, you're under." prin...
4067408ebcb9dff6cb9bdbd3fcf4bc9751179354
knight-furry/Python-programming
/D_pattern.py
356
3.984375
4
x = int(input("Enter no of rows : ")) k=1 l=1 for row in range(1,x+1): for col in range(1,x+1): if (col==2 and (row < x and row > 1)) or (col== x and row > 1 and row < x) : print("*",end="") elif (row == 1 and col == k): print("*",end="") k=k+2 elif (row == x and col == l): print("*",end="") l=l+2...
ff2ccf5438312eac07c6e203a2044813992bc9e7
xiaoyuer14/PycharmProjects
/IAQI/aqi_v4.0.py
1,526
3.609375
4
""" 功能:AQI计算 日期:24/01/2019 版本: 4.0 os模块 提供与系统、目录操作相关的功能,不受平台限制 os.remove() 删除文件 os.makedirs() 删除多层目录 os.rmdir() 删除单级目录 os.rename() 重命名文件 os.path.isfile() 判断是否为文件 os.path.isdir() 判断是否为目录 os.path.join() 连接目录,如path1 连接 path2 为 path1...
7d503ce25090483653abb608b891c9b4b9a47c3a
wendy0802/WendySecondPro
/CalculatorTest/Test_Calculator.py
1,475
3.765625
4
# encoding=utf-8 class Calculator(): def add(self, a, b): return a + b def minus(self, a, b): return a - b def mul(self, a, b): return a * b def div(self, a, b): try: return a / b except: return "Dividend can not be zero" calc = Calcu...
30933ecdab34d12c3476a3fd4ab38f14e23aa605
vikas-t/practice-problems
/full-problems/specialKeyboard.py
972
3.53125
4
#!/usr/bin/python3 # https://practice.geeksforgeeks.org/problems/special-keyboard/0 def sol(n): """ b is the break point after which only one ctrl+c and ctrl+v will happen and the remaining will be all ctrl+v therefore it starts at the end from n-3 Now, say if b is the break point then n-b is left...
7ac6ed55ac507ca204a424667b2556db05cdb93e
Abhishek-IOT/Data_Structures
/DATA_STRUCTURES/Heap/MergeksortedList.py
1,198
3.984375
4
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def addNode(self,data): newNode=Node(data) if self.head is None: self.head=newNode return last=self.head...
6e21790655e501d75c02f71d285956daa9636d82
dnipser/algorithms-stanford
/course1/week3/quick_sort.py
2,594
3.625
4
from enum import Enum from misc.file_utils import read_input_dataset from misc.sort_utils import copy, swap, is_sorted class PivotType(Enum): FIRST = 1 LAST = 2 MEDIAN = 3 class Counter: def __init__(self, n=0): self.total = n def __call__(self, x=0): self.total += x def qui...
ab824618e8b5da9f6ba60f42592852a5ef8623de
szykol/zadania-python
/zadania/1.4/smartphone.py
955
3.890625
4
class Smartphone: def __init__(self, manufacturer, model, price): self.__manufacturer = manufacturer self.__model = model self.__price = price @property def manufacturer(self): return self.__manufacturer @manufacturer.setter def manufacturer(self, manufacturer): ...
adc3c2d5b0c51dfd55dd1063b81a8026c84fb4b6
priyamshah112/Basic_Python
/python/python/miniproject-1/STUDENTRECORD.py
11,684
3.96875
4
"""PROGRAM TO KEEP TRACK RECORD OF A ENGINEERING STUDENT's GRADES,ATTENDANCE,EXPOSURE COURSE,PROCTOR,EXTRA ACTIVITIES etc""" print(" \t \t ~ APPLICATION FOR ENGINEERING STUDENT RECORD ~") print("*"*80) def combo(): print(" \t \t ~ ENGINEERING Student Record ~ ") print(" 1] CREATE Student RECORD \n 2] READ Stu...
315a572d4a7a5df51972b0c3f34f1a8ad2f72347
heedy/heedy
/api/python/heedy/base.py
16,972
3.53125
4
import json from urllib.parse import urljoin # Used for the synchronous session import requests import socket from urllib3.connection import HTTPConnection from urllib3.connectionpool import HTTPConnectionPool from requests.adapters import HTTPAdapter # Used for the asynchronous session import aiohttp import urllib...