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
94b99fcc4d6f4adcd9776aeb6b8b351c0aa893e1
huangqiank/Algorithm
/laiclass/recursion/p.py
1,415
3.890625
4
def fib(n): nums = [0, 1] if n < 2: return nums[n] for i in range(2, n): nums[i] = nums[i - 1] + nums[i - 2] return nums[i] def reversed(node): if node is None or node.next is None: return node end = reversed(node.next) node.next.next = node node.next = None ...
b5eda4b03a6aa71e319b6c54ac8c6a82d07db0a3
huangqiank/Algorithm
/leetcode/two_Pointer/circular_array_loop.py
3,635
3.984375
4
##You are given a circular array nums of positive and negative integers. ##If a number k at an index is positive, then move forward k steps. Conversely, ##if it's negative (-k), move backward k steps. ##Since the array is circular, you may assume that the last element's next element is the first element, ##and the firs...
317f0783b9e840b41f9d422896475d5d76949889
huangqiank/Algorithm
/leetcode/tree/binary_tree_level_order_traversal2.py
1,205
4.15625
4
##Given a binary tree, return the bottom-up level order traversal of its nodes' values. # (ie, from left to right, level by level from leaf to root). ##For example: ##Given binary tree [3,9,20,null,null,15,7], ## 3 ## / \ ## 9 20 ## / \ ## 15 7 ##return its bottom-up level order traversal as: ##[ ## [1...
0532a1c3032f4b1112aeba1a3a253e09c811a80a
huangqiank/Algorithm
/laiclass/tree/p.py
1,163
3.765625
4
class Treenode: def __init__(self,x): self.value=x self.left = None self.right = None def find_path(node,k): sum = 0 path=[] return find_path_help(node,k,path,sum) def find_path_help(node,k,path,sum): if node is None: return False sum+=node.value if sum == ...
29bc3e6b2f64ff22d50c8669523808e03d479e50
huangqiank/Algorithm
/laiclass/recursion2/ddd.py
415
3.890625
4
''' Created on Sep 28, 2017 @author: qiankunhuang ''' def dfs(graph, start_vertex, visited_path): if visited_path is None: visited_path = [] for vertex in graph[start_vertex]: if vertex not in visited_path: visited_path.append(vertex) dfs(graph, vertex, visited_path) ...
d75d306cf0a272918233c47853e3a5e531c8f6fb
huangqiank/Algorithm
/leetcode/other/convert.py
1,143
3.8125
4
# 6. Z 字形变换 # 将一个给定字符串 s 根据给定的行数 numRows ,以从上往下、从左到右进行 Z 字形排列。 # 比如输入字符串为 "PAYPALISHIRING" 行数为 3 时,排列如下: # P A H N # A P L S I I G # Y I R # 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"PAHNAPLSIIGYIR"。 # 请你实现这个将字符串进行指定行数变换的函数: # string convert(string s, int numRows); # 示例 1: # 输入:s = "PAYPALISHIRING", numRows = 3 # 输出:"...
d202985f45ab4a06bc4c4665c90942c86bb0564a
huangqiank/Algorithm
/laiclass/linkedlist/POLAN.py
1,104
3.53125
4
''' Created on Sep 10, 2017 @author: qiankunhuang ''' import operator class Node: def __init__(self, x): self.value = x self.next = None class Stack(object): def __init__(self): self.size = 0 self.head = None def push(self, value): node = Node(value) if...
0e94d5bcff932e0c6330f98167bf184f14d92b4d
huangqiank/Algorithm
/leetcode/sliding_window/get_equal_substrings_within_budget.py
1,650
3.96875
4
##You are given two strings s and t of the same length. # #You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, ## the absolute difference between the ASCII values of the characters. ##You are also given an integer maxCost. ##Return the maximum length of a subs...
cddf333fd2f39e08f788febb4a8829bc452098a1
huangqiank/Algorithm
/leetcode/two_Pointer/2sum.py
989
3.71875
4
##Given an array of integers, ##return indices of the two numbers ##such that they add up to a specific target. ##You may assume that each input would have exactly one solution, ##and you may not use the same element twice. ##Example: ##Given nums = [2, 7, 11, 15], target = 9, ##Because nums[0] + nums[1] = 2 + 7 = ...
a853eb57d3de1ea3340e7a5dd3852a1f45f1d657
huangqiank/Algorithm
/leetcode/recursion/generate_trees.py
1,329
3.90625
4
# 给定一个整数 n,生成所有由 1 ... n 为节点所组成的 二叉搜索树 。 # 示例: # 输入:3 # 输出: # [ #   [1,null,3,2], #   [3,2,null,1], #   [3,1,null,null,2], #   [2,1,3], #   [1,null,2,null,3] # ] # 解释: # 以上的输出对应以下 5 种不同结构的二叉搜索树: # 1 3 3 2 1 # \ / / / \ \ # 3 2 1 1 3 2 # / / ...
14273ceb764322ffc9f3132bcf51ed1f23a76280
huangqiank/Algorithm
/laiclass/tree/print_same_level.py
848
3.875
4
class Treenode: def __init__(self, x): self.left = None self.right = None self.val = x def print_same_level(node): res = [] queue = [node] while queue: n = len(queue) this_level = [] while n > 0: n -= 1 node = queue.pop(0) ...
a9cf18e9d712c8fa2cf5446294cb5787192ed4b2
huangqiank/Algorithm
/leetcode/DFS/clone_graph.py
1,934
3.796875
4
##Given a reference of a node in a connected undirected graph, # return a deep copy (clone) of the graph. # Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors. # Example: # Input: # {"$id":"1","neighbors":[{"$id":"2","neighbors":[{"$ref":"1"}, # {"$id":"3","neighbors":[{"$ref":"2"},{"$...
fa7e93577b90d32d532cb012ccc90a8dccc72f4d
huangqiank/Algorithm
/laiclass/tree/countUnivalSubtrees.py
1,729
3.75
4
#250. 统计同值子树 #给定一个二叉树,统计该二叉树数值相同的子树个数。 #同值子树是指该子树的所有节点都拥有相同的数值。 #示例: #输入: root = [5,1,5,5,5,null,5] # 5 # / \ # 1 5 # / \ \ # 5 5 5 #输出: 4 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # ...
2e8dc29c25c09f1418cc75460bc9163494a8574d
huangqiank/Algorithm
/leetcode/dp/a.py
725
3.703125
4
# 给定一个正整数、负整数和 0 组成的 N × M 矩阵,编写代码找出元素总和最大的子矩阵。 # 返回一个数组 [r1, c1, r2, c2],其中 r1, c1 分别代表子矩阵左上角的行号和列号, # r2, c2 分别代表右下角的行号和列号。若有多个满足条件的子矩阵,返回任意一个均可。 # 输入:[ #   [-1,0], #   [0,-1] # ] # 输出:[0,1,0,1] # 解释:输入中标粗的元素即为输出所表示的矩阵 class Solution: def getMaxMatrix(self, matrix: List[List[int]]) -> List[int]: dp[[a...
2565789016dfc2e68f26229e9bd43d264c31cccc
huangqiank/Algorithm
/leetcode/two_Pointer/getIntersectionNode.py
1,225
3.859375
4
#160. 相交链表 ##编写一个程序,找到两个单链表相交的起始节点。 #如下面的两个链表: #在节点 c1 开始相交。 #示例 1: #输入:intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3 #输出:Reference of the node with value = 8 #输入解释:相交节点的值为 8 (注意,如果两个链表相交则不能为 0)。从各自的表头开始算起,链表 A 为 [4,1,8,4,5],链表 B 为 [5,0,1,8,4,5]。在 A 中,相交节点前有 2 个节点;在 B 中,相交节点前有 3 个节点...
debd2e4d31660576bf3b0ae62f9483f1d6367e11
huangqiank/Algorithm
/leetcode/other/convertitle.py
700
3.609375
4
##168. Excel表列名称 #给定一个正整数,返回它在 Excel 表中相对应的列名称。 #例如, # 1 -> A # 2 -> B # 3 -> C # ... # 26 -> Z # 27 -> AA # 28 -> AB # ... #示例 1: #输入: 1 #输出: "A" ##只需要注意1 - A而不是0 - A ##①让除数减一,那么余数自然就少一,原来余 1 的变成余 0,以此类推(详细见下表)。 #核心代码 `let remain = (n - 1) % 26;` class Solution123411: def convertToTitle(sel...
bb3f160ece699f954c2e93b0a3538e5fc187e95c
huangqiank/Algorithm
/leetcode/p.py
45,118
3.875
4
##Given an array of n positive integers and a positive integer s, ## find the minimal length of a contiguous subarray of which the sum ≥ s. # If there isn't one, return 0 instead def minSubArrayLen(s, nums): l = 0 r = 0 res = float("inf") for j in range(len(nums)): r += nums[j] while r...
e3b23843c6531f69939db92d0f0eaa164b21adae
huangqiank/Algorithm
/laiclass/hashmap/char_remove.py
216
3.59375
4
''' Created on Oct 1, 2017 @author: qiankunhuang ''' def remove(A): lst=[] for fast in A: if fast not in ["u","n"]: lst.append(fast) return "".join(lst) A="aunsdad" print(remove(A))
240cdac8236949ef4fb396b9b739a0e17aebced3
Hyeongseock/EulerProject
/Problem018.py
2,451
3.578125
4
''' Maximum path sum I Problem 18 ''' ''' By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below: 75 95 64 17 47 82 18 ...
f07911a813545ba8213b8500356406cd1a3fb8af
Hyeongseock/EulerProject
/Problem004.py
1,832
4.15625
4
''' Largest palindrome product Problem 4 ''' ''' English version A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' #Make empty list to add number number_lis...
08337729b9b67a3514ff9d6ebc4b1b152ab2aae6
lanjingjing1992/1505A_python_workspace
/day02/Test.py
2,218
3.59375
4
#coding=utf-8 # for i in range(1,10,1): # for j in range(1,i+1,1): # t=i*j # print '%s*%s=%s'%(i,j,t), # if j==i: # print '%s*%s=%s'%(i,j,t) # # def f(month):#参数代表月份 # if month==1: # return 1 # elif month==2: # return 1 # else: # return f(month...
22fe4599cea41ea7fdbab36693ca83d546bf6c75
ujjwalgandhi/sms18
/SMS_18/algo.py
1,081
3.578125
4
import time, random import threading class Stock: ''' Class for Stock object. Variable description: name: Name of Stock p0: Initial Price of Stock pf: Final price of Stock total_time: The time duration for which the event runs price: Current Price of the Stock fraction: To divide th...
47419370894a780c92c8cab02c4ed6b3f903f8f5
patorseing/10_Day_of_Statistics
/Day_1_Standard_Deviation/Solution_py/Solution.py
596
4
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'stdDev' function below. # # The function accepts INTEGER_ARRAY arr as parameter. # def mean(arr): return sum(arr) / len(arr) def EachMean(x, u): return (x-u) ** 2 def stdDev(arr): # Print your answers to 1 decimal pla...
0b3d512f8fe3fa810b21e446ff514979568ffffd
Wuwqhnsya/Dictator
/Dictator_service/Auto_logger.py
2,739
3.5625
4
""" @Author :Furqan Khan @Email :furqankhan08@gmail.com @Date :12/30/2016 Objective : The purpose of this file /module /Class is to take data from various other classes /methods and log it into a file for debugging and execution flow information. This class makes use of generic python logging module which serves a...
2243ba8e52b1a0ab73d871b6bd746d4a3ff21c40
C-Codes/structures
/python/test_stack.py
643
3.5625
4
from stack import Stack #from timing import timerfunc # @timerfunc def test_stack(N): print("Testing stack") s = Stack() print("Check if empty") print(s.empty()) print(f"Pushing {N} values") [s.push(i) for i in range(N)] print("") print("Peeking top value") print(s.peek()) pri...
88021e789e0602fff3527af5edd82e2db4e5376c
omolea/BYUI_CS101
/week_02/team_activity.py
2,155
4.15625
4
""" Jacob Padgett W02 Team Activity: Bro Brian Wilson """ First_name = input("What is you first name: ") Last_name = input("What is you last name: ") Email_Address = input("What is you email: ") Phone_Number = input("What is you number: ") Job_Title = input("What is you job: ") ID_Number = input("What is you id: ") H...
c9fc538595a40eed8dba6ddf12dadc8e88d67874
omolea/BYUI_CS101
/week_04/Meal_Price_Calculator.py
1,009
3.875
4
""" Jacob Padgett W04 Meal Price Calculator Bro Brian Wilson """ def childs_meal_price(): x = input("\nThe price of a child's meal: $") return x def adults_meal_price(): x = input("The price of an adult's meal: $") return x def num_children(): x = input("The number of children: ") return x...
fdf5d4e83a5184cd9cc451a74dbe252281f2d8d2
omolea/BYUI_CS101
/week_01/favorite_color.py
236
3.890625
4
def get_favorite_color(): """ Asks a user for favorite color Returns the input """ favorite_color = input("What is your fovorit color? ") print(favorite_color) # Calls the above function get_favorite_color()
4e514fe2af93cc540c4565172025ba9ac67b4d01
osohq/oso
/languages/python/oso/polar/expression.py
964
3.59375
4
from typing import Any class Expression: def __init__(self, operator, args): self.operator = operator self.args = args def __repr__(self) -> str: return f"Expression({self.operator}, {self.args})" def __str__(self) -> str: return f"Expression({self.operator}, {self.args})...
471d52a23c9114730253c1ad6a80cd3ba5d68bcb
Bob-Xtc/awesome_python
/Advanced/mro.py
3,971
3.953125
4
''' 1、Classical mro(python version < 2.2): Classical mro use a kind of simple method:DFS from left to right Take [diamond inheritance](菱形继承) as an example,The search order is [D, B, A, C, A], The result that keep the first item of the duplicate class is [D, B, A, C]. But we use the method of "show(...
613f95100dc1e818249fdda8ad84adc694001f2c
jdavis211512/CS421_project2
/project 2/project2.py
4,457
3.71875
4
import pandas as pd import matplotlib.pyplot as plot import numpy import math # C:\Users\jdavi\PycharmProjects\CS421_project2\project 2 # C:\Users\Hunter\OneDrive - Ball State University\Classes\Fall 2020\CS 421\CS421_project2\project 2\GOOGL.csv def readCSV(filepath): choice = input("What company are you wanting...
3b2db3580147895d9d1b7a71b644812c8a775ef0
alexisalt/curso_pensamiento_computacional
/caja_negra.py
1,576
3.8125
4
#Se empleara POO con clases en este codigo. import unittest #Modulo de Python que nos permite generar pruebas. def suma(num_1, num_2): return num_1 + num_2 #Es un placeholder que se emplea en Python para dejar vacio. #La forma en que nos permite realizar pruebas es con una clase que definimos de la s...
029fb3d02ca753d046ce00a6156f7ff75e8c0210
alexisalt/curso_pensamiento_computacional
/listas.py
1,503
4.4375
4
my_list = [1, 2, 3] print(my_list[0]) print(my_list[1:]) #Veremos ahora los metodos de las listas y sus side-effects my_list.append(4) print(my_list) #NO EXISTIO una reasignacion, simplemente la modificamos a la lista #agreganndole el numero 4 al final. #modificar ahora una de las posiciones my_list[0] = 'a' #A d...
7f3262257f916feedf74d057b326a9f990a2a185
shoel-uddin/Digital-Crafts-Classes
/programming101/exercises/loops-bonus.py
444
3.859375
4
username = input("Username:\n") counter = 0 while username != "Shoel": username = input("Please use correct username") counter += 1 if counter > 2: print ("Try again next time!") exit() password = input ("Password:\n") counter = 0 while password != "Yes": password = input("Try again") ...
6b696f052459bf2c88cd9a019db0fa4c68f5940e
shoel-uddin/Digital-Crafts-Classes
/programming101/strings.py
809
4.09375
4
my_string = "look a string" 'Look a string using single quotes' print message= "Hello World" print (message) name = "Shoel" combined = f"I want to say {message} to {name}." # f string print(combined) thing = "awesome" # new = "hey this is %s, keep going." % thing print("hey this is %s, keep going %s" % (thing, name...
c3f197930c850ca43bc7c7339d1ab7482ea218bc
shoel-uddin/Digital-Crafts-Classes
/programming102/exercises/list_exercises.py
1,555
4.375
4
#Exercise 1 # Create a program that has a list of at least 3 of your favorite # foods in order and assign that list to a variable named "favorite_foods". # print out the value of your favorite food by accessing by it's index. # print out the last item on the list as well. favorite_foods = ["Pizza", "Pasta", "Byriani"...
fbcdd3d7e66aa5ee32104c7888ab15dc7e9e1beb
shoel-uddin/Digital-Crafts-Classes
/programming102/class.py
374
4.09375
4
class Person: def __init__(self, name, age, height="normal"): print(self) print("you created a person.") self.name = name self.age = age self.height = height sho = Person("Sho", 30) anna = Person("Anna", 29, "Short") print(sho.name) print(f"Hello {sho.name}, you are {sho....
d652382b0e657735b15fc377cf8c087d32759c6a
shoel-uddin/Digital-Crafts-Classes
/programming102/exercises/key-value-pairs_exercise.py
718
4.3125
4
#1 movie = { "name":"Star Wars", "episode":4, "year":"1977" } print (movie) #2 person = { "first_name": "Sho", "last_name": "Uddin", "age": 30, "hair_color": "Black" } for key in person: print (person[key]) print (f"Hello {person['first_name']} {person['last_name']}. Since you ...
4ed944b169bf0052fbfbca5b379287a47b41f21e
texanerinbayern/OK2Wake
/time.py
2,214
3.765625
4
#!/usr/bin/env python def loop(): while True: currentYear = datetime.datetime.now().year currentMonth = datetime.datetime.now().month currentDay = datetime.datetime.now().day currentHour = datetime.datetime.now().hour currentMinute = datetime.datetime.now().minute day_date = datetime.date(currentYear, ...
1ad30a8485e10cda39bab5c197be602d35c5a674
aquablue1/dns_comb
/src/Visual/timePlot.py
6,244
3.8125
4
""" " The purpose of this class is to draw the time series plot according to the given input file " There are three major steps in order to do the visualization: " First, load the json file. " Second, decide the object and time period that will show in the figure " Third, set all the suitable parameters and show the gr...
afbe5b04d4a9db61f2d78d16d73a2b412e1c91e4
pawel2706111/wizualizacja-danych
/wd_cw04/cw_wd04_zadanie_8.py
965
3.640625
4
# zadanie 8 # Do klasy z wybranego poprzedniego zadania dołącz funkcję niszczenia obiektu. class robaczek: def __init__(self, x, y, krok): self.x = x self.y = y self.krok = krok def __del__(self): print('obiekt spadł z rowerka XD') def idz_w_gore(self, ile_krokow): ...
3c81ed453655abda44fcf2980d9ea44a125f2f12
pawel2706111/wizualizacja-danych
/wd_cw06/wd_cw06_zadanie_9.py
374
3.734375
4
# zadanie 9 # Wykorzystaj poznane na zajęciach funkcje biblioteki Numpyi stwórz # macierz 5x5, która będzie zawierała kolejne wartości ciągu Fibonacciego. import numpy as np macierz = np.empty((5, 5), dtype='int') a = 0 b = 1 for i in range(0, 5, 1): for j in range(0, 5, 1): macierz[i, j] = b ...
abd08f56fe63d32ff7f82df24ff327795c4ff321
pawel2706111/wizualizacja-danych
/wd_cw07/wd_cw07_zadanie_11.py
792
3.703125
4
# zadanie 11 # Wygeneruj macierz płaską (wektor) i przekształć ją na macierz 3x4. # Wygeneruj w ten sposób jeszcze kombinacje 4x3 i 2x6. # Spłaszcz każdą z nich i wyświetl wyniki. Czy są identyczne? import numpy as np a = np.arange(12) print('płaski wektor:') print(a) print('macierz 3x4:') print(a.reshape(3,...
ced7dab16e72d551fdd5b0067e2cfdbf34a23ee3
andrewhw/LWT-coding-group
/python/03-variables-and-scope/ballons-and-handles
3,954
4.625
5
#!/usr/bin/env python # This says that we want to be able to use the tools in the "copy" # library (we will use this to make a "deep copy", near the bottom # of the example) import copy # This will show some data stored in different variables, and # I hope will demonstrate one of the common issues people have, ...
a19f52eaf65614332254a8ec0861c13df99dbb03
MaxwellBo/CSSE1001_Assignments
/Statistics Summariser/main.py
5,682
3.796875
4
#!/usr/bin/env python3 ################################################################### # # CSSE1001/7030 - Assignment 1 # # Student Username: s4392687 # # Student Name: Maxwell Bo # ################################################################### ##################################### # Support given below...
a40d78ade0d4580d2bbb6c4a555fc77cf31162f4
maintain0404/algorithm_quizes
/baekjoon/baekjoon_10815.py
901
3.515625
4
import sys from functools import reduce, lru_cache read = sys.stdin.readline def search(list_, num): idx_start = 0 idx_end = len(list_) - 1 while idx_start <= idx_end: idx = (idx_end + idx_start) // 2 # print(f'{idx_start}, {idx}, {idx_end}') if list_[idx] == num: retu...
47d096a969ccc37455925dd7c8e570640b98be6e
Eccie-K/pycharm-projects
/dictionary.py
308
4.03125
4
dictionary = {"name": "essy", "age": 18, "town": "nairobi" } print(dictionary) print(dictionary["town"]) print(dictionary["age"]) print(dictionary["name"]) x = dictionary["town"] y = dictionary.get("town") new_dictionary = dictionary.copy() print(new_dictionary)
28c51e037e37d5567b59afb6abb3cbdf40f9e64b
Eccie-K/pycharm-projects
/looping.py
445
4.28125
4
#looping - repeating a task a number of times # types of loops: For loop and while loop # modcom.co.ke/datascience counter = 1 # beginning of the loop while counter <= 10: # you can count from any value print("hello", counter) counter = counter +1 # incrementing z = 9 while z >= -9: print("you", z) ...
deb60878e985ea2f31f2c57fd7f035db19cfbd5f
Eccie-K/pycharm-projects
/leap year.py
330
4.25
4
# checking whether a year is leap or not year = int(input("enter the year in numbers:")) if year % 4 != 0: print("this is not a leap year") elif year % 4 == 0 and year % 100 == 0 and year % 400 == 0: print("it is a leap year") elif year % 4 == 0 and year % 100 != 0: print("leap year") else: print("l...
626cd0515032904d46c32ae196065f169a9a30ab
manunirmal/manunirmal
/app.py
1,420
3.515625
4
#!/usr/bin/python3 """ This code is used as an example """ from functools import wraps from flask import Flask, request, jsonify app = Flask(__name__) def check_card(card_name): """ This function validates credit card transactions """ wraps(card_name) def validation(*args, **kwar...
7bafa1bc5842b9ed9da340d33bdaf3992b1b2434
aarora8/single_file_scripts
/process_text.py
2,391
3.546875
4
#!/usr/bin/env python import re UNK = '<UNK>' def case_normalize(w): if w.startswith('~'): return w.upper() else: return w.lower() def process_transcript(transcript): global WORDLIST # https://www.programiz.com/python-programming/regex # [] for set of characters you with to match ...
a3cd0090c8982c76c949f321420464a92af8d9bd
pksebben/kingscup
/kingscupmain/deck/__init__.py
2,161
3.65625
4
""" Deck class - to be used for any card game. This current version does not incorporate Ace Low rules. Key for reading the card values: card = [facevalue, suit] Suits 1 = Spade 2 = Club 3 = Heart 4 = Diamond 5 = Joker Face Values 1 = 2 2 = 3 3 = 4 4 = 5 5 = 6 6 = 7 7 = 8 8 = 9 9 = 10 10 = Jack 11 = Queen 12 = King...
dc7bd4c3fca11767acc90289473e8d9e30b7b891
pg633/cngs
/script/py/a.py
3,116
3.78125
4
import heapq from collections import defaultdict import collections import itertools # itertools.combinations(points, 3) 返回某个列表的全排列 class Solution(object): def largestTriangleArea(self, points): def area(p, q, r): return .5 * abs(p[0] * q[1] + q[0] * r[1] + r[0] * p[1] - ...
f86893b8507fd0e8f188ffb868958215a5e78ac1
groversid/holbertonschool-python-camp2
/0x02-python_if_else_loops_functions/2-print_alphabet.py~
89
3.796875
4
#!/usr/bin/python3 for i in range(97,123): print("{}".format(chr(letter),end=''))
d3f35c88d6aab16cbba3464b07db2dbc2575849d
paulaaraujo11/MiniSiga_emPython
/Disciplinas.py
3,771
3.84375
4
#CRUD das disciplina #importa funcoes que serao usadas no codigo from Funcoes import * #lista vazia onde sera add os dados em memoria disc_lista = [] #abre arquivo a ser usado DisciplinaA = open("Disciplinas.txt", "w") def pede_nome_disciplina(): return (input("Nome da Disciplina: ")) def novaDisciplina(): ...
ad10455b1ef59ddaf0dd3072afb1c5d28bca5dee
miguel-conde/py_nlp
/word_embed.py
3,022
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 18 21:31:46 2021 WORD EMBEDDINGS WITH THE EMBEDDING LAYER @author: migue """ # # 6.6 - Loading the IMDB data for use with an Embedding layer # from keras.datasets import imdb from keras import preprocessing # Number of words to consider as features max_features = 10000 ...
869baa47314690b570ebaa1740b31249eff86f91
prostopasta/python3-practice-with-mipt.ru
/Lesson 03/contest - week 1/G.py
331
3.921875
4
def multiply(s, op): return s * op string = input() operand = int(input()) if operand > 0: print(multiply(string, operand)) elif operand == 0: print(string) else: sub = string[:int(len(string)/abs(operand))] if multiply(sub, abs(operand)) == string: print(sub) else: print('NO ...
5f81a891c08f488ebfd0bb4741ff2c89d445b6c6
3salles/numerical-methods
/real-zero/bisssection.py
1,518
3.875
4
import math def calcule_min_iterations(initial_interval, final_interval, precision): """ This function estimates the minimum number of iterations. Returns: number (minimum iterations required) """ estimate = (math.log10(final_interval - initial_interval) - math.log(precision)/math.log10(2)) result = int...
d76061a5f3a63b8f89dbc06968777a6e753efbc6
IriskaKhrushch/PythonCore
/Classwork/Classwork6/Classwork6.py
3,120
4.09375
4
def choise(): """Перевірка числа на парність""" print('Привіт! Введи ціле число:') try: number = int(input()) except ValueError: print('Схоже Ви ввели не цифру...') else: if number % 2 == 0: print(f'Число {number} - парне!') else: print(f'Число...
670f6fb8b2cdc57d9f46743a66c3ae8fb9e9e0f1
IriskaKhrushch/PythonCore
/Homework1/HW1_Task 2.py
162
3.78125
4
f=input("What is you name?: ") print("Hello: ",f) g=input("How old are you?: ") print("You age is: ",g) i=input("Where do you live?: ") print("You live in: ",i)
4a6cc9dbc7057dfcfe1d340c0bfdaf719cae328b
tjwldnjss13/ADS-PNU
/Challenge/HashTable.py
702
3.84375
4
class Node: def __init__(self, key): self.key = key self.next = None class HashTable: def __init__(self, size): self.size = size self.table = [None] * self.size def hash_function(self, data): return data % self.size def insert(self, data, value): key ...
8c4fbb93ba3e95e2c5f7655720657bc9a6aa3683
SierraPSEC/WeeAdventure
/TMval1.py
419
3.578125
4
# google: python read file line by line # http://cmdlinetips.com/2011/08/three-ways-to-read-a-text-file-line-by-line-in-python/ ## Open the file with read only permit #f = open('TM20160310') f = open('CE_WeeAdventure01.txt') ## Read the first line line = f.readline() ## If the file is not empty keep reading line one...
ae73c80895594a8de3404eef785095d4cd652b77
qulianjie/hangman
/正则表达式.py
712
3.859375
4
import re text = """ Giraffes have aroused the curiosity of __PLURAL_NOUN__ since earliest times. The giraffe is the tallest of all living __PLURAL_NOUN__, but scientists are unable to explain how it got its long __PART_OF_THE_BODY__. The giraffe's tremendous height, which might reach __NUMBER_...
5ea4f6e79cee4a1bd5583781f94f6aef69da905a
samarthjj/Competitive-Coding-4
/Palindrome Linked List.py
1,360
4.0625
4
# Time Complexity : O(n), where n is the length of the list. # Space Complexity : O(1) # Did this code successfully run on Leetcode : yes # Any problem you faced while coding this : no # Your code here along with comments explaining your approach class Solution(object): # This problem is solved by traversing to th...
3253038670a631e8e3fc40c2f072fb78eadc3b67
frankiebee/chess
/re.py
1,355
3.765625
4
class test(object): def __init__(self): self.red = raw_input('test') def plus(self): def __init__(self): red test = test() print test.plus.red() def move(self, m): pace = m - self.king if pace == 0: return False line = [] if pace % 7 == 0: pace = 7 elif pace % 8 == 0: pace = 8 ...
7f083225bebf072dc3412a8acc30b6ba2b269433
mbot64/Rock-paper-scissors
/rock-paper-scissors/rockpaperscissors.py
4,089
4.15625
4
import random import tkinter as tk import tkinter from random import randint window = tkinter.Tk() #window.geometry("400*300") window.title("RPS") user = "" winner = "" Wins = "" #NOTE: A function that determines whether the user wins or not # Passes the user's choice (based on what button they click)...
79a253b114f1ea6283895746a9ec38acebc37f5f
djjohnsongeek/achieve
/cypher.py
2,277
3.890625
4
KEY_TEXT = "rkjfawtphxuoievokbanzmycaksjdgoql" def toupper(char: str): """ converts letter to upper case if neccesary """ if len(char) != 1: return None num = ord(char) if num >= 65 and num <= 90: return char elif num >= 97 and num <= 122: return chr(num - 32) els...
e560993500f2e938e997cf0bf10423754f21cf6e
pitriche/dslr
/old_python/V1.0/MetaData.py
1,346
3.84375
4
import math class MetaData : 'v1.1 of MetaData, a class to describe a single feature' 'included in DataClass as a dict' # constructor, takes data and calculate the metadata, or init to 0 # values contain all the metadata in a dict for easier display def __init__(self, data = 0): self.values = { "count" : 0,...
b2024573e2d2b8af362c6a8370100ed4641413ad
ShikoSuu/2021psp2
/ex/day03/d03_01.py
626
3.875
4
# d03_00.py from turtle import * import math def come(x,y): """ 座標(x,y)を向いて,その方向に距離を一割だけ縮める """ (xx,yy) = position() val_tan = (yy-y)/(xx-x) theta = math.atan(val_tan) head = heading() new_head = theta*180/math.pi - head walk = math.sqrt((xx-x)**2 + (yy-y)**2)/10 left(new_...
58420b29cb1897142585ace3e1502dc320c9f38d
ShikoSuu/2021psp2
/ex/day04/newton1.py
118
3.8125
4
#%% newton1.py x = 3 for n in range(10): epsilon = (x**2-3)/(2*x) x = x - epsilon print(n+1,':',x)
822ee3cdf019e47a5f212975b2b78c91a5c5533d
ShikoSuu/2021psp2
/2020psp1/ex06/b601.py
2,015
3.578125
4
# python の対話モードで実験すると楽です。 # コマンドプロンプト上でpythonとだけタイプし起動 # >>> というプロンプトが表示されているときはpythonの対話モード # 終了するには quit() コマンドを発行。 # プログラミング概論を受講していて 比較演算子と論理演算子を使えることを前提としています。 # 0~99999 の整数からランダムに一つ生成して変数 x に代入 import random x=random.randint(0,99999) # 問(i) x が 2 桁以下の数ならTrue、3 桁以上の数なら False と評価する式を求めてください print(x) print('この文...
d1bbfae6e3467c8557852939faf5cdd1daa1f2ca
Robock/problem_solving
/interview_code_14.py
1,127
4.125
4
#Given a non-finite stream of characters, output an "A" if the characters "xxx" are found in exactly that sequence. #If the characters "xyx" are found instead, output a "B". #Do not re-process characters so as to output both an “A” and a “B” when processing the same input. For example: #1. The following input xx...
669974e2c5321ca2cf58cf268f44d64cd7170f9d
LG4ML/DataGroupForQS
/ProjektDoku/aggDataUpdated.py
4,100
3.546875
4
import pandas as pd import matplotlib.pyplot as plt T_AGG = 60 speedPath = 'Data/WindSpeedData/csv_final2.csv' anglePath = 'Data/windAngleData/csv_final.csv' pressurePath = 'Data/PressureData/pressure2.csv' #Reading in data as well as converting String-Objects into Datetimes def readInData(speedPath, angle...
c9606248b5f5e346a83ab9c750f1b3836062000a
rodcordeiro/shares
/scripts/py/condicional_if.py
142
3.90625
4
# -*- coding: utf-8 -*- x=1 y=10 if x == y: print("X é igual a y") elif x > y: print("X é maior que y") else: print("Y é maior que X")
ef02434465a6d6da8ebcec85cbc10711f6660760
wyxvincent/turtle_lesson
/poligon.py
413
4.1875
4
import turtle t = turtle.Pen() def polygon(side, length): if side < 2: print("2条边不足以构成多边形") else: angle = 180 - (side - 2) * 180 / side for i in range(side): t.forward(length) t.left(angle) turtle.done() side = int(input("请输入多边形的边数:")) length = int(input("请输...
d0fca09d8c192e9d6aee5eb6fdd321d010ab31fb
yurikong/Artificial_Intelligence
/Assignment 2/n-queens/hill_climb.py
1,717
3.59375
4
from board import Board from heuristic import h import numpy as np class Hill_Climb: def __init__(self): self.no_steps = 0 if __name__ == '__main__': brd = Board(5) brd.set_queens() print("Initial board:") print(np.matrix(brd.map)) target = brd.n_queen * (brd.n_queen - 1) // 2 q...
3ad81a415b00c95db59eec15680b4da6ec544101
JanusTan/AlgorithmQIUZHAO
/Week_03/subsets.py
490
3.625
4
# 78. 子集 # 时间复杂度O(2^n)要生成所有子集, 空间复杂度O(2^n),递归的函数会调用栈空间 class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: res = [] n = len(nums) def helper(i, temp): res.append(temp) for j in range(i, n): helper(j+1, temp+[nums[j]]) # 注意[1,2,3]+[...
de071555e31bf0e584fc5b691803ed0f1f2af493
JanusTan/AlgorithmQIUZHAO
/Week_01/merge-two-sorted-lists.py
777
3.875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next # 时间复杂度O(n), 空间O(n) class Solution: # 头指针本身就是下标, 下面和归并排序的递归很像 def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: dummy = ListNode(val=0) ...
31aa59f07ef05b8526e63a32abffba163d42ed98
JanusTan/AlgorithmQIUZHAO
/Week_03/powx-n.py
817
3.75
4
# 50. Pow(x, n) # 时间复杂度:O(logn),即为递归的层数。 # 空间复杂度:O(logn),即为递归的层数。这是由于递归的函数调用会使用栈空间 class Solution: def myPow(self, x: float, n: int) -> float: def quickMul(n): # terminator if n==0: return 1.0 # prepare data, conquer subproblems y = quickMul(...
e5478f50c3f20f12283591fcbfc252daf13a962a
JanusTan/AlgorithmQIUZHAO
/Week_05/22. 括号生成.py
637
3.671875
4
class Solution: def generateParenthesis(self, n: int) -> List[str]: def add_parentthesis(left, right, s, result): # terminator if left+right >= 2*n: result.append(s) return # current level and drill down这里有剪枝的思想 if left<n: ...
5d2c3d632e0b79df6f51a0eeda2dea63905c2009
JanusTan/AlgorithmQIUZHAO
/Week_04/best-time-to-buy-and-sell-stock-with-transaction-fee.py
389
3.671875
4
# 714. 买卖股票的最佳时机含手续费 class Solution: def maxProfit(self, prices: List[int], fee: int) -> int: # 只交一次手续费,即买入的时候减去股钱和手续费 dp_0 = 0 dp_1 = - float('inf') for price in prices: dp_0 = max(dp_0, dp_1 + price) dp_1 = max(dp_1, dp_0 - fee - price) return dp_0
be8811e99f309b5eef111c19922ab525cd539c47
JanusTan/AlgorithmQIUZHAO
/Week_02/n-ary-tree-level-order-traversal.py
801
3.53125
4
# 429. N叉树的层序遍历 # 时间复杂度O(n), 空间O(n) """ # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution: def levelOrder(self, root: 'Node') -> List[List[int]]: if not root: return from co...
2eaff0c354fc1205e0c13b8cf074919c53787f33
tamtruongk01/foodGenerator
/main/mainGUI.py
496
3.796875
4
import tkinter as tk import foodGenerator window = tk.Tk() def clicked(): secondWindow = tk.Tk() text = tk.Text(secondWindow, bg="light blue", height = 10, font="Helvetica") text.insert(tk.INSERT, foodGenerator.foodGenerator()) text.pack() mainScreen = tk.Canvas(window, bg="bisque2", height=320, width...
10abc6a69c9c2dc948868895a66925ca6c799f7e
caasig1/CSC209
/week6/3n1.py
617
3.96875
4
def my3n1(n): count = 0 max = n while n > 1: count += 1 if n % 2 == 0: n //= 2 else: n = n * 3 + 1 if n > max: max = n return count, max maxcount = maxmax = 0 for i in range(1,20): count1,max1 = my3n1(i) if count1 > ma...
a28350d12dfc8cecca4ae2fde10f797985f7e941
skeitel/Artificial-Intelligence-Image-Recognition
/img_multi_object_recognition_openCV.py
1,207
3.640625
4
#Object detection in image using open CV #We use a street view image where we detect where red traffic lights are located import cv2 import numpy as np #Opening main street view image containing target images img = cv2.imread("street_traffic_signs.jpg") gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) ##...
959b1822518795b2316225900d047b8b932a06f2
pw0n3d/learn-python
/randomNum.py
798
3.84375
4
import random print("\t\t***Игра угадай число***") print("У тебя есть 5 попыток \nПопытайся угадать секретное.\nУдачи!") attemps = 0 secretNum = random.randint(0 , 10) while True: magician = int(input("Введите секретное число:")) attemps = attemps + 1 if attemps == 5: print("Ты проиграл\nУ тебя...
c959865b5dcb98a542fd4b7287c5c78b22ce1d1d
BananaH/ml
/ML/hw/data_processing.py
4,672
3.59375
4
class Stock: def __init__(self,name,date, opening,closing,highest,lowest,volume,adj_close,up): self.name = name; self.date = date; self.opening = opening; self.closing = closing; self.highest = highest; self. lowest = lowest; self.volume = volume; self.adj_close = adj_close; self.up = up; def set_u...
673c89a6c1a8af01c757d0469e74829a623e1dc1
ianpushee/RKCraft
/tools/commandbook.py
5,904
3.640625
4
#! /usr/bin/env python3 # Produces a Minecraft "Command Book", a book with text that # executes commands when clicked. # If run as a script, accepts a file with lines in the form: # # "Link text" /command... # # # For more complicated books, like special data file formats or # fancier text, make a separate file that ...
224eb82bb3960c13846039e33df88414b8a0091a
ahmedemad9/Python
/Py4es/1 First/wage.py
251
3.90625
4
#!/usr/bin/python3 hrs=input("Enter Hours:") rate = input("Enter rate:") if float(hrs)<=40 : wage=float(hrs)*float(rate) elif float(hrs)>40 : wage=(1.5*(float(hrs)-40)+float(hrs))*float(rate) print(wage)
6be4ddb8b6aa610e56bd421816bc0a6f71c4ae82
GKT-07/BouncingBallGame-Pygame
/arg.py
227
3.796875
4
# def name(a, b, c, d): # print(a, b, c, d) # name("gaurav", "prateek", "ankit", "satyam") def name(*args) : for item in args : print(item) list = ["gaurav", "prateek", "ankit", "satyam", "piyush"] name(*list)
24a6c099f183e2f5ca2b7676e5bd277c2b1be92c
djmailhot/Geography-Quiz
/GeographyQuiz.py
1,606
3.53125
4
class QuestionInfo: def __init__(self, qID, question, image): self.qID = qID self.question = question self.image = image class QuizMain: # Returns the ID of the current question def __currID(self): return self.qDatabase[self.currDatabaseIndex] # Retrieve the information for the current question. # Re...
4c320f93fb87dad3651bf32df315eb6aa1646729
hubugui/duplicate-cell
/duplicate.py
3,326
3.578125
4
#!/usr/bin/env python import os import getopt import sys import xlrd usage_msg = """\ USAGE: duplicate [-f excel file list] [-d excel directory] [-c column range] [-p print row when greater than duplicate count] -h print this help message and exit Examples: duplicate -f "a.xls b.xls c.xls" -c 1,4 -p 1 p...
5c69c5fbd745c124255cae5cf5856026b0b6e989
ashwin-pajankar/Python-Bootcamp
/Section15/04Dict.py
612
4.15625
4
dict1 = {"brand": "Intel", "model": "8008", "year": 1972} print(dict1) print(dict1["brand"]) print(dict1.get("model")) dict1["brand"] = "AMD" dict1["model"] = "Ryzen" dict1["year"] = 2017 print(dict1) for x in dict1: print(x) for x in dict1: print(dict1[x]) for x in dict1.values(): ...
8d9a30979402bcc51c960f4f8443eeaf69b681b3
ashwin-pajankar/Python-Bootcamp
/Section11/03mutualevenodd.py
244
3.78125
4
def isEven(x): if x == 0: return True else: return isOdd(x-1) def isOdd(x): if x == 0: return False else: return isEven(x-1) print(isEven(3)) print(isOdd(3)) print(isEven(10)) print(isOdd(10))
c7b7a3f789e1481bdd819b815820bebefddb6582
ashwin-pajankar/Python-Bootcamp
/Section09/08fact.py
225
4.3125
4
num = int(input("Please enter an integer: ")) fact = 1 if num == 0: print("Factorial of 0 is 1.") else: for i in range (1, num+1): fact = fact * i print("The factorial of {0} is {1}.".format(num, fact))
0e2a825bd9e62b23a09f554522177ed4bce81cff
dorinzaharia/project-Euler
/sum_square_difference.py
456
3.8125
4
import time def main(): start = time.time() n = 100 #sum of the squares of first n number s= (n * (n+1) * (2 * n + 1)) /6 sum_of_squares = (n*(n + 1)*(2*n + 1))/6 #sum of first n numbers s= n * ( n + 1) / 2 square_of_sum = pow(n*(n + 1)/2, 2) print("Difference: " + str(square_of_sum - ...
1b532a0d00f01ae09aa9974c63943d5bc90492c7
ppsirg/py-numbers-to-string-challenge
/index.py
938
3.75
4
from number_constants import number_constants def number_to_string(input): if input < 21: return number_constants[input] else: #dividir el número en sus partes (10) 143 # 1*100 + 1*40 + 3 finished = False numbers = [] while not finished: module = inp...
3f47b82659c8e4ed59fb9a07c87c60aa7725f64b
andrew962/Python
/practicando2/App/Practica#2.py
321
4.0625
4
def vocal(letra): if letra== 'a'or letra=='A'or letra== 'e'or letra=='E'or letra=='I' or letra== 'i'\ or letra=='O' or letra== 'o'or letra== 'u'or letra=='U': print("Es una vocal") else: print("No es vocal") if __name__ == "__main__": ob=input("Dijite una letra: ") vocal(ob)...
77713c02ce33a2a3beb58bc69586dc7a7de3b5f1
andrew962/Python
/practicando2/App/Practicando#3.py
320
3.859375
4
def numero(a,b,c): if a>b and a>c: print(str(a)+" Es mayor") elif b>c: print(str(b)+" Es mayor") else: print(str(c)+" Es mayor") if __name__ == "__main__": z=int(input("primer numero: ")) x=int(input("segundo numero: ")) c=int(input("tercero numero: ")) numero(z,x,c)
a0ae93985cd9be68582a8ee42d27c4a59fb454b3
eljoelee/python_Data_Structure
/search&sort/selection_sort_easy.py
493
3.71875
4
def find_min_idx(a): n = len(a) min_idx = 0 for i in range(1, n): if a[i] < a[min_idx]: min_idx = i return min_idx def sel_sort(a): result = [] # 새 리스트를 만들어 정렬된 값 저장 while a: # 주어진 리스트에 값이 남아 있는 동안 계속 min_idx = find_min_idx(a) value = a.pop(min_idx) r...