blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
747d582cd3bae72054eeae14f8dc682bb6b18496
vinayaka-2000/python_fileextension_
/radius_of_the_circle.py
134
4.21875
4
pi = 3.142 rad = float(input("INPUT THE RADIUS OF THE CIRCLE")) area = pi * rad**2 print("area of the circle is : "+ str(area))
c57a993f890040da6eb041ad1b25591cd958e024
zacharyarney/advent-of-code
/2019/python-solutions/day_2.py
697
3.5
4
def intcode_reader(input, noun=12, verb=2): arr = input.copy() arr[1] = noun arr[2] = verb for i in range(0, len(arr), 4): opcode = arr[i] arg_1 = arr[arr[i+1]] arg_2 = arr[arr[i+2]] if arr[i] == 1: arr[arr[i+3]] = arg_1 + arg_2 elif arr[i] == 2: ...
8903b21e2bacff2e9bcb28d135d384186eb51902
BellaShah/DataStructureProjects
/Queen.py
2,433
3.78125
4
class EightQueens (object): # Initialize the board def __init__ (self, n = 8): self.board = [] self.n = n self.numSolutions = 0 # Populate chess board with '*' before adding queens for i in range (self.n): row = [] for j in range (self.n): row.append ('*') ...
b8e8310c63f017af9df4856fa309a9e7a79c3aa6
KamilPrzybysz/python
/18.03.18/zad12/zad12.py
148
3.96875
4
s='abcaaabcaaabc' print('a)'+str(s.replace('ab','d'))) print('b)'+str(s.replace('ca','ff'))) print('c)'+str(s.upper())) print('d)'+str(s.lower()))
7563b6d1bbfe1f4bad829d482b19971a4bf0275e
erisaran/cosc150
/Lab 11/powers.py
1,062
4.1875
4
def print_powers(n, high): power = 1 while power <= high: print n**power, power += 1 def x(high): i = 1 while i <= high: power = 1 while power <= high: print i**power, power += 1 i += 1 print "" def is_prime(n): ...
8e57b65138f18ce049a4e488da6b8f214ebec7aa
thomas-rohde/Classes-Python
/exercises/exe31 - 40/exe032.py
181
3.640625
4
s = float(input('Qual o salário do funcionário? R$')) if s>1250: s0 = s * 1.10 else: s0 = s * 1.15 print('O seu salário era R${:.2f}, e agora é R${:.2f}'.format(s, s0))
2829e3b5d2654cb2347443d36f52d4db5e5f293a
HUAN99UAN/TestPython
/daily_programming/stringFormat.py
387
3.59375
4
def stringFormat(A, n, arg): while "%s" in A and len(arg) > 0: A = A.replace("%s", arg.pop(0), 1)# ython replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串), # 如果指定第三个参数max,则替换不超过 max 次。 return A + ''.join(arg) print(stringFormat("A%sC%sE",7,['B','D','F']))
fc4aae6e8e0ad3972b8636df9b543eb83f05c081
zhaoly12/dataStructAlgorithmPythonVer
/stack.py
3,113
3.953125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 15 16:44:47 2020 @author: 86156 """ from seqList import seqList from linkedList import linkedList class Stack(seqList): ''' stack is a special kind of linear list we can only add element in a stack from the top and can only delete element from the top al...
ed3917e7ed1015587e1477f682067a877dd045f8
nathanthomashoang/blackjackgame
/blackjack.py
8,356
3.984375
4
'''global variables''' import random suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Jack','Queen','King','Ace') values = {'Two':2,'Three':3,'Four':4,'Five':5,'Six':6,'Seven':7,'Eight':8,'Nine':9,'Ten':10,'Jack':10,\ 'Queen':10,...
83046dc27bf8e0f1c042123e3f88c9f6b2f99a1c
NurFaizin/SDP
/Decorators/decorator1.py
247
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def outer(some_func): def inner(): print "before some_func" ret = some_func() return ret + 1 return inner def foo(): return 1 decorated = outer(foo) decorated()
c1a8d628e40254594a64478beadeb3539d0624b5
MohammadForouhesh/DataStructure_Python
/Stack_and_Queues/ArrayStack.py
1,496
3.765625
4
from Array import DynamicArray class ArrayStack: """ LIFO stack implementation using self-written DynamicArray based on c-types array as underlying storage. """ def __init__(self): self._contents = DynamicArray.DynamicArray() def __len__(self) -> int: """ :return: the len...
c78cd78aad4ac1f0889cd31d61bc16a03bdb63c0
NithinNitz12/ProgrammingLab-Python
/Programs/strings.py
6,244
4.375
4
#Python Notes str = "It is easy to learn python" print("Swapcase:",str.swapcase()) print("Capitalize:",str.capitalize()) print("Title:",str.title()) print("Replace:",str.replace("is","was")) print("*****") str2 = "How easy is python to learn, Java is not so easy, c not at all easy to code" print(str2.replace("is","w...
c0e4b865ee6b3374d76ffebc3b790d4d68514f46
GeorgianBadita/LeetCode
/easy/TwoSum.py
484
3.609375
4
# https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/546/ from typing import List class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: sum_dict = {} for i in range(len(nums)): if target - nums[i] in sum_dict and sum_dic...
7416176fa61807fb318c864783a9ef3e8a16bdfc
SardulDhyani/MCA3_lab_practicals
/MCA3A/Bhartendu_Pant_20711020_MCA3A/Q1.py
150
3.53125
4
a=4 b=6 #summation print(a+b) #substraction print(a-b) #Multiplication print(a*b) #Division print(a/b) #Exponent print(2**3) #floor print(b//a)
10dcfd0b45add42274d3ffc03109b4b1ac1d1a19
ashish010598/Regularity-check-of-a-language
/defLang.py
3,466
4
4
class Char: '''Class which defines any character in the string of a language inclusive of its power, whether or not the power is a constant or a variable, etc''' def __init__(self, base, exp, isVar, rangeOfVar = None): self.base = base self.exp = exp self.isVar = isVar # self.rangeOfVar = rangeOfVar def __...
618e2c559f456a45f1c51ebfd68bf20fb7cb029f
KritiShahi/30-Days-of-Python
/Day 10.py
1,910
4.625
5
"""1) Below is a tuple describing an album: ( "The Dark Side of the Moon", "Pink Floyd", 1973, ( "Speak to Me", "Breathe", "On the Run", "Time", "The Great Gig in the Sky", "Money", "Us and Them", "Any Colour You Like", "Brain Damage", "Eclipse" ) ) Inside t...
514c4bc87c58bf712ebe80a20a7eafe0984d78e6
pandapranav2k20/Python-Programs
/Lab 5/ENGR102_504_23_iii.py
1,934
4.125
4
# By submitting this assignment, I agree to the following: # "Aggies do not lie, cheat, or steal, or tolerate those who do." # "I have not given or received any unauthorized aid on this assignment." # # Names: Damon Tran # Benson Nguyen # Matt Knauth # Pranav Veerubh...
d9427801e00b3b0c88bf041916b516dd90a05397
AxelOrdonez98/Universidad_Proyectos_All
/Archivos_Python/Practicas/Practica_8_2.py
518
3.796875
4
estaturas= [] promedio = 0 menor = 0 mayor = 0 for x in range(5): valor = float(input("Ingrese estatura " + str(x+1) + ": ")) estaturas.append(valor) for x in range(5): promedio += estaturas[x] promedio = promedio / 5 for x in range(5): if estaturas[x] < promedio: menor = menor + 1 else: ...
e12048380ddadc7813ac6f5c19bd25a5e7f5d3b9
wangyuan1024/python
/unit5/homework/homework11.py
496
3.953125
4
# -*- coding: UTF-8 -*- ########################################################################## # File Name: homework11.py # Author: Wang Yuan # mail: 853283581@qq.com # Created Time: 2019年08月05日 星期一 17时21分25秒 ######################################################################### #!/usr/bin/env python # coding=ut...
2643fc25d27d93089d5fe9f7cccf8f07fff98bfb
hrivera7777/Jobs
/estructuras_de_datos/clase 23-05-2019/Pila.py
547
4.1875
4
# program 3.1 programa_3_01.py # implementacion de un pila en python # asumiendo que el tope está al final de la lista class Pila: def __init__(self): self.items = []# esto es una lista def estaVacia(self): return self.items == [] def incluir(self, item): self.items.append(item)# ...
83aeb8f31d94003abd6db8aedbf0ea1cba87543c
mlawan/lpthw
/ex33/ex33.py
456
3.75
4
i = 0 x = 1 a = 0 b = 0 numbers = [] users = [] while i <= 6 and not x > 8: #print(f"At the top i is {i}") #print(f"At the top x is {x}") numbers.append(i) users.append(x) i = i + 1 x = x + 2 a = a + 1 b = b + 1 print(f"{a}. Numbers row{a}:{numbers}") print(f" Users row{a}:{us...
113f83554a248c7909f3039d3bab32e0111f0cff
Gaming32/Python-AlgoAnim
/algoanim/sorts/bubble.py
451
3.6875
4
from algoanim.array import Array from algoanim.sort import Sort class BubbleSort(Sort): name = 'Bubble Sort' def run(self, array: Array) -> None: for i in range(len(array), 0, -1): sorted = True for j in range(1, i): if array[j - 1] > array[j]: ...
250aa61a3890c9de1a2758e36c324d5f386ac658
mkozel92/algos_py
/data_structures/linear_probed_hash_table.py
1,403
3.875
4
from typing import Any class LinearProbedHashTable(object): """Simple hash table with linear probing""" def __init__(self, size:int = 100): """ initialize with lists for keys and values of given size :param size: size of table """ self.keys = [None] * size self....
753bcaf056c38f841af2710d7b737d13695f6a3b
ChandrakalaBara/PythonBasics
/basicAssignments/assignment11.py
277
4.21875
4
# Write a program which accepts a sequence of comma-separated numbers from console and # generate a list and a tuple which contains every number. str = input('Enter comma seperated numbers').split(',') print(type(str)) print(str) tpl = tuple(str) print(type(tpl)) print(tpl)
9cdbef8d76941ae8ea10650f126146e27875a652
alexfear/crappycode
/palindrom.py
892
3.578125
4
import math isPalindrom = 0 isPrime = 0 def main(): j = m1 = m2 = max = 0 erat=[] for i in range(10001, 99999, 2): if isPrime(i): erat.append(i) j+=1 for i1 in range(0, j): for i2 in range(i1, j): p = erat[i1] * erat[i2] if isPalindrome(p) and p > max: max = p m1 = er...
8c95ab0ddc5878864319afb165ea9e921f7ad85a
abusamrah2005/Python
/Week-10/Day-64.py
424
3.734375
4
# Python Week-10 Day-64 # Python Try-Except try: print(x) except NameError as err: print ("name 'x' is not defined") print("----") try: print("Welcome To My Code") except NameError as err: print("Something went wrong") else: print("Complete no errors") print("----") try: print(y) except Nam...
0e944a20f2d1d21e440edb516347e69718aad026
derick-droid/pythonbasics
/loops[lst].py
1,700
4.625
5
# looping over a list of an item magicians = ["alice", "nana", "caroh"] for magician in magicians: print(f"{magician.title()} you did a good work") print("I cannot wait to see your next trick \n") # exercise # 4-1. Pizzas: Think of at least three kinds of your favorite pizza. Store these # pizza names in a l...
31d5e14e28750c5c5b74fb3337532c69cab55883
feliperfdev/100daysofcode-1
/Introdução ao Python/week6/day38/propriedades_POO.py
5,218
4.125
4
''' POO - Propriedades Em linguagens de programação como o Java, ao declararmos atributos privados nas classes, costumamos criar métodos públicos para manipulação desses atributos. Esses métodos são chamados de 'getters' e 'setters'. Os getters retornam o valor do atributo e os setters alteram o valor do mesmo. ''' p...
d1fd9c0eb3419d14efc2d6ea85e8e9e59960c5cc
syurskyi/Algorithms_and_Data_Structure
/Python for Data Structures Algorithms/template/13 Stacks Queues and Deques/Stacks, Queues, and Deques Interview Problems/SOLUTIONS/Balanced Parentheses Check - SOLUTION.py
2,891
4.0625
4
# # Balanced Parentheses Check - SOLUTION # # Problem Statement # # Given a string of opening and closing parentheses, check whether its balanced. We have 3 types of parentheses: # # round brackets: (), square brackets: [], and curly brackets: {}. Assume that the string doesnt contain any other # # character than these...
a7123a74bb59f8fc006abe5444112cafb7f45101
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/ryxshr002/question2.py
654
3.859375
4
"""Shriya Roy 8 May 2014 counting program""" def pair(n,i): if len(n)==0:#checks if length is 0 return print("Number of pairs:",i) if len(n)==1:#checks if length is 1 return print("Number of pairs:",i) else: if n[0]==n[1]:#checks if the first two are i...
29255977c6f2067cfc9275a1dacf9564f0ae9805
artificialfintelligence/letter-boxed-game-solver
/src/word.py
275
3.6875
4
from typing import NamedTuple, Set class Word(NamedTuple): text: str unique_letters: Set[str] num_unique_letters: int @staticmethod def create(text: str): unique_letters = set(text) return Word(text, unique_letters, len(unique_letters))
7813529a051b6cf9256a2ab26dcf5bd3762bae9d
Kanishk9/OpenSourceLabs
/Lab3/open1.py
138
3.640625
4
str1 = "Hello World" frequency = {} for i in str1: if i in frequency: frequency[i] += 1 else: frequency[i] = 1 print (frequency)
f93bec1f86741577030f6556eb9d5935f24f5eb1
qiannn/leetcode
/Binary Tree Postorder Traversal/Binary Tree Postorder Traversal.py
595
3.890625
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def postorderTraversal(self, root): list = [] self.traversal(root, list) return list def traversal(self, root, list): if root == None: return self.traversal(root.left, list) ...
95909e1b94d0e460981515f5ece9ae983ccd2a91
Crafty-Star/Anish-Sarkar-Graphic-Studio
/Python Starfield Assignment/ScalingLineStarfield.py
2,246
3.96875
4
from tkinter import * import math, time, random def convertRGBToHex(r,g,b): return "#{0:02x}{1:02x}{2:02x}".format(r,g,b) # Define the behavior of a line segment class Line: def __init__(self, canvas, x, y, dx, dy, color = "yellow"): self.canvas = canvas # The center of the line, so you can s...
80f45d8284bbc67dc219c85c6fd68fa93ce75af2
jcohen66/python-sorting
/recursion/towers_of_hanoi.py
413
3.75
4
def towers_of_hanoi(n, source, dest, aux): print(f"n {n} source {source} dest {dest} aux {aux}") if n == 1: print(f"Move disk 1 from source {source} to destination {dest}") return towers_of_hanoi(n-1, source, aux, dest) print(f"Move disk {n} from source {source} to destination {dest}") ...
ec4777248a57910bba407212cdd202e1b65d2adb
tssutha/Learnpy
/test.py
1,160
3.5
4
import math import time l = list() def reverse(ls): #l = list() print ls l.append(ls[len(ls)-1]) print l if(len(ls)>1): reverse(ls[:-1]) else: return l; ls = [1,2,3] def reverse2(ls): if len(ls)>1: return reverse2(ls[1:]).append(ls[0]) else: return ls #print reverse2(ls) ls = [2, [5,False,[7,False...
f89da34f751c98fc63617e23f88d28ef11aac458
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/8 Problems on bits and masking/12_OFF_SpecifiedBit/Demo.py
420
3.6875
4
''' Write a program which accept one number and position from user and off that bit. Return modified number IP: 1840 (11100110000) iPos = 5 OP: 1824 (11100100000) ''' def OffBit(no,pos): mask = ~(1 << (pos - 1)); return (no & mask); def main(): no = int(input("Enter number: ")); pos = int(input("Enter...
8e9f883f532052194319a0a01dd59468602d12ea
1914866205/python
/pythontest/day04-18-151-04.py
110
3.546875
4
def multi(*num): result=1 for i in num: result*=i return result print(multi(1,2,3,4,5))
4e09e60c9b598b2e6ca1a45f14af3c80c656298d
Halal375657/Graph-Theory
/PrimsMST.py
1,619
3.984375
4
# # Prim's Algorithm # Book:- Introduction to Algorithms # O(E log V) # from heapq import heappush, heappop, heapify class Graph: def __init__(self, n): self.n = n self.graph = [{} for _ in range(n)] def addEdges(self, u, v, w): self.graph[u][v] = w # As undirected. ...
4a710ffeeaeb8bedfd140d78fab583133701aeef
ithangarajan/HackerRank
/Grading Students
436
3.59375
4
#!/bin/python3 import sys def solve(grades): answer=[] for x in grades: if x > 37: if x%5 == 3: x=x+2 if x%5 == 4: x=x+1 answer.append(x) return answer n = int(input().strip()) grades = [] grades_i = 0 for grades_i in range(n): g...
8086a7615c470e5c7131dc76e81c05f7fa4008c9
simpleman19/patterns_project
/walker.py
1,151
3.84375
4
from random import choice import pickle class Walker: """ Generates random walks """ def __init__(self, num_points=5000): """ Initialize attributes for a walk """ self.num_points = num_points self.x_values = [0] self.y_values = [0] def fill_walk(self): """ Calcula...
8485cdfb5d873234977a828369a817b6a55fd883
alperkarasuer/Project-Euler
/Q10.py
361
4
4
def isPrime(n): if (n <= 1): return False if (n <= 3): return True if (n % 2 == 0 or n % 3 == 0): return False i = 5 while (i * i <= n): if (n % i == 0 or n % (i + 2) == 0): return False i = i + 6 return True primes = [x for x in range(1,int(...
f6dbc52885bf60408c175a019a6e82d82a683292
mikej803/digitalcrafts-2021
/week2notes/oppLab.py
3,953
3.921875
4
# # # # DIRs # # # chris = { # # # "firstName": "Chris", # # # "lastName": "Owens", # # # "greeting": greeting # # # } # # # matt = { # # # "firstName": "Matt", # # # "lastName": "Fisher", # # # "greeting": greeting # # # } # # # print(chris["firstName"], chris["lastName"]) # # # chris...
8e0c4ec65d65c3d28be6facf64fe8820a5075700
snehask7/AI-Lab
/A5-Polygon/Polygons.py
7,171
3.515625
4
import random import math import itertools import heapdict import heapq from collections import deque class Polygon: def __init__(self, vertices): self.vertices = vertices def check_inside(self, x, y): equation_values = [] direction=0 for i in range(len(self.vertices)): ...
b564cc1af09eb0c618da6652b6b1be38521d3c0d
gauravmalaviya143/loop
/nestedwhileloop.py
146
3.9375
4
i = 1 while i<=3: print("hello", end="") j = 1 while j<=2: print("gaurav", end="") j+=1 i+=1 print()
52bf3af5514b7e7dad54e8f44163764fcd798148
1642195610/backup_data
/data_zgd/python进阶/10.20/test.py
1,676
3.75
4
from typing import List from randomList import randomList def sort(nums: List[int]) -> List[int]: # 冒泡排序法 if len(nums) <= 1: return nums for i in range(len(nums) - 1): f = 1 for j in range(len(nums) - 1 - i): if nums[j] > nums[j + 1]: nums[j], nums[j + 1] \...
a24401cd68510151aafcaed9f4bb03b1fb393572
lordgrenville/project_euler
/prob_9.py
500
3.625
4
import time start = time.time() squares = [] triplets = [] i = 1 while i**2 < 1000000: squares.append(i**2) i += 1 for a in squares: for b in squares: for c in squares: if a + b == c: triplets.append(tuple([a, b, c])) for a in triplets: if sum([i**0.5 for i in a]) ...
cd85fd0ccd1bc652e615e9c00990ab5b4ab2b47c
prasertcbs/python_tutorial
/src/area.py
313
3.84375
4
def rectangle(w, h): # dynamic typing # code block area = w * h return area def triangle(w, h): # area = .5 * w * h return .5 * w * h # main entry point w = int(input("width = ")) # string '5' "5" h = int(input("height = ")) # "3" # print(rectangle(w, h)) print(triangle(w,h))
ba8dfd448cba8be6215e9649262225c334540c7c
poding/poding.github.io
/01_python/chapter12/ex12_03.py
1,157
3.546875
4
# 랜덤 모듈 import random for i in range(5): print(random.randint(1, 10)) # 1~10까지 정수 for i in range(5): print(random.randrange(1, 10)) # 1~9까지 정수 for i in range(5): print(random.uniform(1, 10)) # 1~10까지 실수 # 시퀀스에서 랜덤한 요소 선택 두가지 예제 food = ["짜장면", "짬뽕", "탕수육", "군만두"] print(random.choice(food)) i = random...
755837253137d808215f206c3fc8e815670739a3
marcyheld/SI507
/lab-11-assignment-marcyheld/sample6.py
1,820
3.546875
4
# Change Frame seconds and make movements smoothly #required import pygame pygame.init() #create a surface gameDisplay = pygame.display.set_mode((800,600)) #initialize with a tuple #lets add a title, aka "caption" pygame.display.set_caption("Frame per seconds") pygame.display.update() #only updates portion specifi...
d97e33eb8e9f23a26fd317eb7e196716613baec9
kirti167/FOOD-RECIPE-APP-in-python-using-tkinter-
/chilipotato.py
2,329
3.65625
4
import tkinter as tk from tkinter import * from PIL import ImageTk, Image root=tk.Toplevel() root.geometry("1400x700+0+0") root.config(bg='white') canvas = Canvas(root, width =500, height=500) canvas.place(x=0,y=0,relheight=1,relwidth=1) img = ImageTk.PhotoImage(file="chili1.jpg") canvas.create_image(1400,37,anchor=NW...
17dd496940fea0f52b43219da94fe13099c16b16
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_200/3418.py
1,209
3.796875
4
def checkTidy(numLst): lastDigit = 0 for digit in numLst: if digit < lastDigit: return False lastDigit = digit return True def makeList(num): numStr = str(num) numLst = [] for digit in numStr: numLst.append(int(digit)) return numLst def ...
853c4784126c5e253c7a6897fad66a02d75b998d
bobkey/python_learn
/untitled.py
280
3.671875
4
import os def get_file_names(path_name): print path_name file_names = os.listdir(path_name) for name in file_names: if os.path.isdir(name): get_file_names(os.path.abspath(name)) else: print name get_file_names(os.getcwd())
471df938b153c94d08d054c75ee55c6eced4208e
ReCir0/UCU_Programming
/Lab3/series.py
289
3.890625
4
num_check = int(input()) a = 1 b = 2 for i in range(num_check): if i == 0: print(a, "/", b, sep = "", end = "") elif i % 2 != 0: print(" - ", a, "/", b, sep = "", end = "") else: print(" + ", a, "/", b, sep = "", end = "") a += 2 b += 2 print()
f44548304bbc86ccf40883534a901210f933c6f4
Ayushrestha05/HackerRank-Python
/Triangle_Quest_2.py
216
3.859375
4
## You are given a positive integer N. ## Your task is to print a palindromic triangle of size N if __name__ == "__main__": for i in range(1, int(input()) + 1): print(int(10 ** i / 9) * int(10 ** i / 9))
590935d4f552690e09fb61e25da08a4c57befcf9
Woosiq92/Pythonworkspace
/5_list.py
1,124
4.15625
4
#리스트 subway1 = 10 subway2 = 20 subway3 = 30 subway = [10, 20, 30] print(subway) subway = ["유재석", "조세호", "박명수"] print(subway) #조세호가 몇번 째 칸에 타고 있는가? print(subway.index("조세호")) # 하하씨가 다음 정류장에 탐 subway.append("하하") # 항상 맨뒤에 삽입 print(subway) # 정형돈씨를 유재석과 조세호 사이에 태워봄 subway.insert(1, "정형돈") print(subway) # 지하철...
f4358439104ee24ff38e044d19ce1159e2fec608
aj3x/PythonPawnAI
/AlphaBeta.py
3,353
3.625
4
import PWND import MiniMax DEPTH_LIMIT = 5 PAWN_VALUE = 20 THREAT_VALUE = 5 transpositionTable = dict() def alphabeta(node): MiniMax.argMax() MiniMax.argMin() def alphaMini(node,depth = 0,end = False): """ :param node: a Game object responding to the following methods: str(): return a unique ...
32e6a41777d482af04e300856b5a0a7373adba35
hcxie20/Algorithm
/033_search_rotated_sorted_array.py
834
3.59375
4
# [4, 5, 6, 7, 0, 1, 2, 3] # nums[mid] 与target 是否在同一侧(递增数列) # 是则用target比 # 否则用inf, -inf比 # [4, 5, 6, 7, 0, 1, 2, 3], mid = 3, # target = 5, 同一侧, num = 7 # target = 0, 不同侧,num = -inf class Solution: def search(self, nums, target): l = 0 r = len(nums) - 1 while l <= r: mid = (l ...
804b26ef93087df59af4aab0a3cfe0f7a747057e
rec/dedupe
/old/old/file_length.py
965
3.6875
4
import collections import os import sys def count_filename_lengths(*roots): counter = collections.Counter() for root in roots: root = os.path.abspath(os.path.expanduser(root)) for dirpath, _, filenames in os.walk(root): for f in filenames: filename = os.path.join(di...
f20e6e580800eb466a1d2607d5eb8a22c89dc7e8
joshmreesjones/algorithms
/book-problems/clrs/2/2.1-2.py
449
4.0625
4
# 2.1-2 # Rewrite the INSERTION-SORT procedure to sort into nonincreasing instead of nondecreasing order. def insertion_sort_descending(array): for j in range(0, len(array)): data = array[j] i = j - 1 while i >= 0 and data > array[i]: array[i + 1] = array[i] i -= 1 ...
2f3cca57b8047a14d6786c3b3c88640e05833c98
MatheusFidelisPE/ProgramasPython
/exercicioscursoemvideo/ex004.py
380
4.09375
4
analise=input('Digite algo para caracteliza-lo:') espaco=analise.isspace() print('A string é composta só por espaço--->', espaco) decimal=analise.isdecimal() print('A string é um decimal--->',decimal) maiusculas=analise.isupper() print('A string esta em maiuscula--->', maiusculas) capitalizada=analise.istitle() print(...
c47b8d567c062d1499d482615835f736455241f4
Arjune-Ram-Kumar-M-Github/FreeCodeCamp.org-Dynamic-Programming--Algorithmic-Problems-Coding-Challenges-Python-Solutions
/Dyanamic_Recursion_Bestsum.py
751
3.65625
4
# Time Complexity - O(m*n) # Space Complexity - O(m) def bestSum(targetNumber,numbers,memo={}): if targetNumber in memo: return memo[targetNumber] if targetNumber == 0: return [] if targetNumber < 0: return None shortestCombination = None for i in numbers: rema...
0e2972971cf99869562af6632f79f59fc6e05cf1
DSM9606/Martin.Rocks.Paper.Excercise
/game.py
2,549
4.21875
4
# game.py import random import os import dotenv dotenv.load_dotenv() PLAYER_NAME = os.getenv("PLAYER_NAME") print(" ") print(" ") print(" ") print(" ") print("Player ", PLAYER_NAME," WELCOME TO Rock, Paper, Scissors, Shoot!") print(" ") print(" ") print(" ") print(" ") user_choice = input("Please choose one o...
34aac1c327b05e1889f0acfd76b03dc8db17774c
hyeon21-p/python
/Pycharm/HelloPycharm/sequence.py
533
3.875
4
string = "Hello World" list = ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'] tuple = ('H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd') print(string[0]) print(list[0]) print(tuple[0]) print(string[0:5]) print(list[0:5]) print(tuple[0:5]) for i in string: print(i) string1 = "Hello World" string2 = "...
2d8c21dde3f4673450e59847d5e20231a5013005
cannium/leetcode
/valid-palindrome.py
445
3.796875
4
class Solution: # @param s, a string # @return a boolean def isPalindrome(self, s): s = ''.join([l if l.isalpha() or l.isdigit() else '' for l in s.lower()]) for i in range(0, (len(s)+1)/2): if s[i] != s[len(s)-1-i]: return False return True t1 = Solutio...
a767a6b151d5318b77815e3616c517a5c57baba0
ysandeep999/fads-nltk-villy-2014
/fads 2104/test.py
329
3.734375
4
def achr(sents): x = "" for word in sents: x = x + "".join(word[-1]) return x.lower() def main(): txt = ["RANDOM", "ACESS", "MEMORY"] outp = achr(txt).lower() print(outp)...
e61e9280dc9ad6e8bb9c161e2b0d0a768404e0c1
mjgutierrezo/MCOC-Nivelaci-n-
/23082019/001224.py
575
3.765625
4
# -*- coding: utf-8 -*- """ Ejercicio propuesto """ from numpy import * #001224 given_list = [7, 5, 4, 4, 3, 1, -2, -3, -5, -7] #se quiere obtener la suma de sólo los números negativos de la lista total = 0 i = 0 while i < len(given_list): #primera condición: que el índice pertenezca a la lista ...
01eaa7031e0725f595519adf6ea4d592f67b690e
gtang31/algorithms
/tree/heap.py
3,548
4.1875
4
""" Implementation of min/max heap from a List. A heap is essentially a binary tree where the root node is either the min/max value in the tree. Heaps are usually used for priority queues where access to min/max is O(1) """ __author__ = 'Gary Tang' class Heap(): def __init__(self, from_list, type='min'): ...
79ccf1726b75dd59bfc9d1b088266136f92b7718
Bit4z/python
/new_python/abc.py
156
3.84375
4
def fun(a,b): return a+b n=int(input("enter the first value=")) m=int(input("enter the second value=")) c=fun(n,m) print("the sum of value=",c)
e8059bbb5394ec7ed9fec0bd5e37d414e1121d4f
chenshanghao/LeetCode_learning
/Problem_314/learning_solution.py
1,123
3.875
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ from collections import deque from collections import defaultdict class Solution: """ @param root: the root of tree @return: the vertical order traversal """ ...
4efacd1075e46c954a54a79cff2ba17ca92aed26
jclavelli89/The-Tech-Academy-Course-Work
/Python/sorting_algorithms.py
9,119
3.953125
4
# Bubblesort ''' def bubblesort(alist): for passnum in range(len(alist) -1, 0, -1): for i in range(passnum): if alist[i] > alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp alist = [67, 45, 2, 13, 1, 998] bubblesort(alist) print(...
b8252a68dcee907495057b7aa601f4925efd75dd
NoTyOuRDevil/phone-number-detail
/phonenum.py
843
3.90625
4
import phonenumbers from phonenumbers import carrier, geocoder, timezone mobileNo = input("Enter your number: ") print(''' AVAILABEL COUNTRIES FOR THIS APPLICATION INDIA, AMERICA, SRI LANKA ''') cn = input("Enter your country name: ") country_name = cn.upper() if country_name == "INDIA": mobil...
004b22a73911c8045f7df5d3a548b2162b88b0bd
petiatodorova/PythonFundamentals
/exam_preparation/task_2.py
1,528
3.671875
4
first_list = list(map(int, input().split())) command = input() results = [] while not command == "END": nums = first_list commands_line = command.split() if len(commands_line) == 3 and commands_line[0] == "multiply": # OK if not commands_line[1].isdigit(): new = [] n...
835915e21e79f5c923b4eb97780f4f3b605e7729
JonCanales/PyGame-Car-App
/border.py
4,183
3.75
4
#Here in this file we are able to create a border that if crossed the game will crash. #Also holding down the left and right keys will keep on moving instead of just pressing it once at a time like the display.py program. import pygame import time import random pygame.font.init() pygame.init() #Here we created our con...
15fb5b8e2b792bdef30e541372a2eeef84bfb19b
SharonGoldi/graph-algorithms
/Graph.py
3,259
3.640625
4
from collections import defaultdict # a general class for a directed graph class Graph: def __init__(self, num_of_vertex): self.V = num_of_vertex self.graph = defaultdict(list) self.weights = defaultdict(list) self.positive_w = True # add edge into the graph def add_edge(...
8c08c2e75da73309653061f89531a34c2b225ade
Eduardo-Goulart/SistemasOperacionais_TempoReal
/Threads/Threads.py
1,461
3.65625
4
from threading import Thread, Lock import time import sys class Trehdis ( Thread ): def __init__(self, id, func, rep = 1 ): Thread.__init__(self) self.mutex = Lock() self.rep = rep self.id = id self.f = func def run (self): num_cycles = self....
711b47daf5f8754aeb709bb9803307a7f946c87f
candyer/leetcode
/May LeetCoding Challenge/04_findComplement.py
1,126
3.640625
4
# https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3319/ # Given a positive integer, output its complement number. # The complement strategy is to flip the bits of its binary representation. # Example 1: # Input: 5 # Output: 2 # Explanation: The binary representation ...
fc234eeb4f0be781b39e6d126bbaf96a08914b44
metallic-tiger/StudenPython
/2.像界面tkinter学习/控件/1.windown窗口.py
757
3.8125
4
#!/usr/bin/python3 # -*- coding: UTF-8 -*- #1.引入Tk模块 import tkinter #建立窗口类 windown=tkinter.Tk() windown.title('显示在窗口上的标题') windown.geometry('600x400')#窗口的长和宽 windown.attributes('-alpha',0.9)#设置窗口透明度为50% 似乎无效 def command(): windown.quit()#退出消息循环 按钮=tkinter.Button(windown,text="按钮上显示的文字:退出",c...
384bc953ac14ed476e7a1fe552583462bb883e5f
ricardoquesada/aiamsori
/gamelib/waypointing.py
6,088
3.5
4
""" Waypointing doing: un poco de test heuristicos para debugear. considerando mejorar algunas cosas, hay partes bastante brute force """ ##FLOYD'S ALGORITHM (int **m, int size) ##{ ## int i,j,k; ## for ( k = 0; k < size; k++ ) ## for ( i = 0; i < size; i++ ) ## for ( j = 0; j < size; j++ ) #...
df758878ad57a52d3decf4e39ca4ba08a427e229
krishnayash-T/Hacker-Rank
/Hacker Rank Solutions/Python/if-else.py
294
3.8125
4
if __name__ == '__main__': n = int(raw_input()) my_str="Weird" my_str2="Not Weird" if n%2==0: if 2<=n<=5: print(my_str2) if 6<=n<=20: print(my_str) if n>20: print(my_str2) else: print(my_str)
9a709b41c614f2b36cc4a628777eeaf16d96c365
campoloj/SoftwareDevelopment2016
/14/dealer/traitcard.py
5,038
3.640625
4
from globals import * class TraitCard(object): """ Represents a TraitCard of the Evolution game """ def __init__(self, trait, food_points=False): """ Craates a TraitCard :param trait: String representing the name of the TraitCard :param food_points: Integer representing...
642909f7dc7cb10cf8b457f94a2ad85c1e67efc3
ummelen22/sudoku_solver
/src/solve_sudoku.py
2,989
3.96875
4
""" Solver for sudoku puzzels """ SUDOKU = [ [1, 0, 0, 0, 0, 0, 0, 0, 6], # . y [0, 0, 6, 0, 2, 0, 7, 0, 0], # .------------------> [7, 8, 9, 4, 5, 0, 1, 0, 3], # | [0, 0, 0, 8, 0, 7, 0, 0, 4], # | [0, 0, 0, 0, 3, 0, 0, 0, 0], # | [0, 9, 0, 0, 0, 4, 2, 0, 1], # x| [3, 1, 2, 9,...
de499f4cb5c36d322c899ac2765fd4b4a2952ee1
mapleinsss/python-basic
/chapter4-流程控制/demo04-断言.py
310
4.25
4
''' 断言如果为 True 继续执行,否则抛出 AssertionError 其实等于 if 条件为 False: 抛出 AssertionError 错误 ''' s_age = input('请输入年龄:') age = int(s_age) assert 20 < age < 80 print('年龄在20到80之间') # 输入不在区间的数, AssertionError assert 20 < age < 80
b86dc033a4dab1dece11da3da88d5abcde1c5322
gaurav-singh-au16/Online-Judges
/Leet_Code_problems/1313.decompress_run_length.py
1,261
4.09375
4
""" 1313. Decompress Run-Length Encoded List Easy 357 690 Add to List Share We are given a list nums of integers representing a list compressed with run-length encoding. Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0). For each such pair, there are freq elements with v...
913d93e2704c13b200ae984eab6f468f3706444e
scott75219/Python-Test
/problem.py
4,602
4.15625
4
# Python Test # You are given a matrix with m rows and n columns of cells, each of which # contains either 1 or 0. Two cells are said to be connected if they are # adjacent to each other horizontally, vertically, or diagonally. The connected # and filled (i.e. cells that contain a 1) cells form a region. There may be...
2f10b1b8449d25bf6186a791d1de189a0a5af377
juffalow/advent-of-code
/2021/1/second_solution.py
354
3.5
4
import sys currentTriplet = [] increasesCount = 0 for line in sys.stdin: if len(currentTriplet) < 3: currentTriplet.append(int(line)) continue first = currentTriplet.pop(0) if sum(currentTriplet) + int(line) > sum(currentTriplet) + first: increasesCount += 1 currentTriplet.append(...
84b4c9f854c576fc1d0f42031922e0a1aa8cbb7f
andreplacet/reinforcement-python-tasks-functions
/exe11.py
189
3.765625
4
# Exercicio 11 from random import shuffle def embaralha(nome): a = list(nome) shuffle(a) a = ''.join(a) print(a.lower()) nome = input('Digite algo: ') embaralha(nome)
c670053a345fdc66c6c47f599f371fd1142018c7
openturns/openturns.github.io
/openturns/master/_downloads/ba246a25b1216656698aa5118fef31ef/plot_kolmogorov_distribution.py
5,619
4.03125
4
""" The Kolmogorov-Smirnov distribution =================================== """ # %% # %% # In this example, we draw the Kolmogorov-Smirnov distribution for a sample size 10. We want to test the hypothesis that this sample has the `Uniform(0,1)` distribution. The K.S. distribution is first plot in the case where the ...
c86f7526ea58a0d3469781a9cecf2e3d4585bb2d
dreamroshan/Python-1
/1.Arrays/07.Longest_Peak.py
2,022
4.15625
4
''' LONGEST PEAK PROBLEM STATEMENT: Write a function that takes array of integers and returns the length of the longest peak in the array. A peak is defined as adjacent integers in the array that are strictly increasing until they reach a tip(the highest value in the peak) at which point they become strictly...
4264beb57a2d6d23edd036bc7dfeb389333d862d
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/web-dev-notes-resource-site/2-content/ciriculumn/week-17/python/my-intro-BG/2/Module11WritingFiles.py
302
3.734375
4
fileName = "demo.txt" WRITE = "w" APPEND = "a" data = input("Please enter file info") file = open(fileName, mode=WRITE) file.write(data) file.close() # file = open(fileName, mode = WRITE) # file.write('Susan, 29\n') # file.write('Christopher, 31') # file.close() print("File written successfully")
e4027bbc8947faba24aab7180e3de4f643d524f9
Impact-coder/hackerrank-problem-solving-solution
/Apple and Orange.py
1,335
4.09375
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'countApplesAndOranges' function below. # # The function accepts following parameters: # 1. INTEGER s # 2. INTEGER t # 3. INTEGER a # 4. INTEGER b # 5. INTEGER_ARRAY apples # 6. INTEGER_ARRAY oranges # ...
bdf8b347fc5946c94aecd5a5386423dd6110275d
Katsura47/Euler
/problem_21(amicable).py
596
3.734375
4
def prime(num): i = 2 total = 0 while num/2 > i > 1: if num%i == 0: return False i += 1 return True def sum_of_divisors(num): i = 1 total = 0 while i <= num / 2: if num%i == 0: total += i i += 1 return total def amicable(num): ...
37a693255016fa276cbaa05a04e27054fa528fd0
Thyrvald/SimplePasswordDatabase
/encrypting.py
2,585
3.921875
4
def encrypt(string_to_encrypt): encrypted_string = '' encrypting_table = create_encrypting_table() string_with_code_word = create_string_with_code_word(string_to_encrypt) for i in range(len(string_to_encrypt)): for encrypted_alphabet in encrypting_table: if encrypted_alphabet[0] == s...
2fdd514c907469add9b232232d3a5865ba7bbe22
NixonThuo/ParcticeRepo
/rough_copy.py
382
3.75
4
def sum_large(numbers): if len(numbers) > 1: numbers.sort() new_list = [] new_list.append(numbers[0] + numbers[-1]) numbers.pop(0) numbers.pop(-1) return new_list.append(sum_large(numbers)) else: return new_list print sum_large([1, 2, 5, 9, 7, 6]) """ n...
38432e4efd68ff6732061eb132040382bfce0d5c
tlambrou/Data-Structures
/source/sort.py
4,267
4.0625
4
#!python from binarysearchtree import BinarySearchTree, TreeMap def bubble_sort(array): # O(n^2-n) in_order = False # O(1) while in_order is False: # O(n) in_order = True # O(1) for i in range(0, len(array) - 1): # O(n) if array[i] > array[i + 1]: # O(1) array...
fc3eb7d06f934c1f93b19db73581d846182079c5
jamalzkhan/idapi
/IDAPICoursework02.py
10,316
3.546875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Coursework in Python from IDAPICourseworkLibrary import * from numpy import * import pydot # # Coursework 1 begins here # # Function to compute the prior distribution of the variable root from the data set def Prior(theData, root, noStates): prior = zeros((noStates...
b35c4a4c0565ae4d21de1dc3c0506c09352eb649
koyasu221b/lintcode
/rotated_sorted_array/recover-rotated-sorted-array/solution.py
618
3.625
4
class Solution: """ @param nums: The rotated sorted array @return: nothing """ def recoverRotatedSortedArray(self, nums): # write your code here for index in range(len(nums)-1): if nums[index] > nums[index+1]: self.reverse(nums, 0, index) s...
b0482f8a47e4be852c00b6aa4aac206536ecb65d
shauravmahmud/100DaysOfCode
/Day 016 Object Orientated Programming/main.py
2,832
4.25
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
6d533411183326e3ee2e610f4bebf43d3a51bb6a
Don-George-Thayyil/algorithms
/set_adt.py
835
3.84375
4
class SetADT: def __init__(self): self._set = list() def __length__(self): return len(self._set) def __contain__(self,value): return value in self._set def add(self,element): if element not in self._set: self._set.append(element) else: ...
f7dc60055181b6c97dd393f2785e241fa6947a55
AlexNilbak/Task_6
/Task_6.py
1,454
3.859375
4
try: file = open("data.txt", "r") except: print("Cannot open file\n") exit() def Read_int(filename): f=0 z=0 x='0' while (x!=' ') and (x!=''): x=filename.read(1) if (x==' ' or x=='') and (f!=0): return z if (x=='') and (f==0): ...