blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
cadc12e86d89626fc3a9d980cf5cfd3dd3f13a2d | lipovetsky/FSND-Movie-Website | /entertainment.py | 2,884 | 3.921875 | 4 | import fresh_tomatoes
import movie
# Here, we import the two other .py files/modules:
# movie and fresh_tomatoes. Movie is where we have created
# the appropriate classes. We can create a new instance of
# a class by defining a variable as movie.Movie.
# Movie with the upper-case is the class, and movie with
# the low... |
0d2fe8b04315543526cf5cbc6732111df9426d60 | j2woong1/algo-itzy | /BOJ/stack/10828-스택/10828-스택-yoonbaek.py | 924 | 3.609375 | 4 | # solved by YoonBaek
import sys
class Stack:
'''
stack class 정의
'''
item = []
# stack 클래스 메서드 구성
def push(self, x):
self.item.append(x)
def pop(self):
if self.empty() :
return -1
return self.item.pop()
def size(self):
return len(self.item)
... |
3137839febf3aa5425741b9ff714eba8a3bcbac8 | j2woong1/algo-itzy | /SWEA/implementation/1974-스도쿠_검증/1974-스도쿠_검증-jiwoong.py | 1,405 | 3.75 | 4 | """
# 스도쿠 검증
입력으로 9 X 9 크기의 스도쿠 퍼즐의 숫자들이 주어졌을 때,
겹치는 숫자가 없을 경우, 1을 정답으로 출력하고 그렇지 않을 경우 0 을 출력
첫 줄에 총 테스트 케이스의 개수 T
다음 줄부터 각 테스트 케이스
테스트 케이스는 9 x 9 크기의 퍼즐의 데이터
테스트 케이스 t에 대한 결과는 “#t”을 찍고, 한 칸 띄고, 정답을 출력
"""
def sudoku_check():
# 스도쿠 판 2중 리스트로 생성
sudoku_lst = []
for number in range(9):
sudoku_num ... |
39398001b2cf01f00411703c91c1b51a2cc1992f | j2woong1/algo-itzy | /SWEA/implementation/1974-스도쿠_검증/1974-스도쿠_검증-yoonbaek.py | 860 | 3.609375 | 4 | # solved by YoonBaek
def get_puzzle():
puzzle = [list(map(int, input().split())) for _ in range(9)]
return puzzle
def check(puzzle_part):
return criterion == set(puzzle_part)
def check_game(puzzle):
# 1: row
for row in range(9):
if not check(puzzle[row]):
return 0
# 2: c... |
e3bacf2ab3e33cfaf8a5325c5d2f2bb700333e00 | j2woong1/algo-itzy | /BOJ/dp/01003-피보나치함수/01003-피보나치함수-yeonju.py | 672 | 3.578125 | 4 | zero = [1,0,1] # fibo(0)일 때, fibo(1), fibo(2)일 때 0과 1의 개수
one = [0,1,1]
def fibo(n):
length = len(zero)
if n >= length:
for i in range(length, n+1):
zero.append(zero[i-1] + zero[i-2])
one.append(one[i-1]+ one[i-2])
print(f'{zero[n]} {one[n]}')
T = int(input()) ... |
97f2d1df792366e343658fc76dd3a1c04315b181 | estysdesu/exercism | /python/pangram/pangram.py | 190 | 3.984375 | 4 | def is_pangram(phrase: str) -> bool:
"""Determines if all 26 letters of the alphabet are present in a sentence/phrase."""
return len(set(filter(str.isalpha, phrase.upper()))) == 26
|
f3acff92e5cc4e2174cb59c554175aa11aafdaae | Yihan-Dai/Leetcode-Python | /longestPalindromeSubstring/solution01.py | 1,079 | 3.8125 | 4 | '''
Given a string S, find the longest palindromic substring in S.
You may assume that the maximum length of S is 1000,
and there exists one unique longest palindromic substring.
'''
class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
... |
2016a3dbd46dc91165319c8bfc332e018a7adc48 | Yihan-Dai/Leetcode-Python | /3SumClosest/solution.py | 1,589 | 3.875 | 4 | '''
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
For example, given array S = {-1 2 1 -4}, and target = 1.
The sum that is closest to the ta... |
f81fc15ec271d1b5a73863d5caa93fec8def696c | Yihan-Dai/Leetcode-Python | /IntegerToRoman/Solution.py | 2,299 | 4.15625 | 4 | '''Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.'''
'''Note:
Roman numeric system
Roman numerals, as used today, are based on seven symbols:[1]
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
Numbers are formed by combining symbols and adding the valu... |
394ce471e9e0ffd1a936734409139a9e5e9aeea4 | rkc007/RTT_Client_Server | /stats.py | 513 | 3.921875 | 4 | import numpy
def mean(x):
"""Find the mean of an iterable of numbers."""
n = len(x)
return sum(x) / n if n is not 0 else None
def std(x):
"""Find the standard deviation of an iterable of numbers."""
m = mean(x)
n = len(x)
dev = (i - m for i in x)
dev2 = (i ** 2 for i in dev)
ret... |
37f8eb3fda6cfba5956f362a9fd4012a61ce00bb | objchris/LeetCodePearl | /其他/134.Gas Station/134_GasStation.py | 1,763 | 3.578125 | 4 | from typing import List
class Solution:
def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int:
result = -1
if len(gas) == 1:
return 0 if gas[0] >= cost[0] else -1
count = 0
i = 0
while count < len(gas) :
current = i
tank = ... |
669af9915ebdd14b35d0e2a0e0573c6032fe0930 | objchris/LeetCodePearl | /数据结构/二叉树/94.Binary Tree Inorder Traversal/94_BinaryTreeInorderTraversal.py | 1,079 | 3.984375 | 4 | from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution_Recursive:
def inorderTraversal(self, root: TreeNode) -> List[int]:
r = []
if root is None or root.val is None:
return r
if ... |
942e663d7dbb3c6e3cca7b1e16143f767e7f8059 | apoorvkhurasia/texpredict | /feature_extraction.py | 7,852 | 3.640625 | 4 | """
This module provides methods to extract features from images of symbols and
associate labels categorizing that symbol with the extracted features.
"""
import os
from dataclasses import dataclass
from typing import Generator, List, Tuple
import numpy as np
from PIL.Image import BILINEAR, Image
from pdf2image import... |
887019e4f648ee422e4f4c662fc34260f22623ed | yuseon27/KDT_AI | /W1_Python_Algorithm/[Day1] Linked_List.py | 2,398 | 3.8125 | 4 | class Node:
def __init__(self, item):
self.data = item
self.next = None
class LinkedList:
def __init__(self):
self.nodeCount = 0
self.head = None
self.tail = None
def getAt(self, pos):
if pos < 1 or pos > self.nodeCount:
return None
... |
02a01d3a87193688d8075b75b7b904edaf4d47b4 | shawnhusky/Python-Palindrome-Check | /main.py | 131 | 4.21875 | 4 | s = input('Enter value')
reverse = s[::-1]
if s == reverse:
print('yes its palindrome')
else:
print('no not palindrome')
|
2bce03187fa25bece1673e0e3a77b3a3ec886a5a | zwjtech/java-ee | /python/src/main/java/com/changwen/python/base/sequence02.py | 9,492 | 3.984375 | 4 | #!/usr/bin/python
# coding=utf-8
from string import maketrans
# 序列(sequence)
# python 包含6种内建的序列,有列表、元组、字符串、Unicode字符串、buffer对象和xrange对象。其中第一个元素为1,最后一个为-1
# ---------------通用序列操作------
# 通用操作包括:索引(indexing)、分片(slicing)、加(adding)、乘和检查某个元素是否属于序列的成员(成员资格)、计算序列长度、找出最大元素和最小元素的内建函数
def test_sequence_common():
# 1.索引:序列... |
53c3c02c19b42e85618c14d1bdd4fbb3f6abfcfd | glowing713/boostcamp-algo-study | /BFS_DFS/0201/jaeha_target_number_BFS.py | 380 | 3.5 | 4 | from collections import deque
def solution(numbers, target):
answer = 0
que = deque([(0,0)])
while que:
value , idx = que.popleft()
if idx == len(numbers):
if value == target:
answer+=1
else:
que.append((value+numbers[idx], idx+1))
... |
f0ec98be60eb4a44e887f1b681cd00541172b4c3 | messierspheroid/instruction | /D19 - Instances, State and Higher Order functions/main.py | 726 | 4.21875 | 4 | from turtle import Turtle, Screen
tim = Turtle()
screen = Screen()
# function that is being used as an input
def move_forwards():
tim.forward(10)
screen.listen()
screen.onkey(key="space", fun=move_forwards)
screen.exitonclick()
# # higher order functions
# def add(n1, n2):
# return n1 + n2
#
# def subtra... |
87d46784696aacb689b509b3ed22952dfbf1f383 | priyo97/Visualization-of-algorithms | /puzzle problem/puzzle.py | 3,472 | 3.5 | 4 | import pygame
import time
from astar import Astar
def drawBoard(n,a,display):
f = pygame.font.Font(None,100)
for i in range(n):
for j in range(n):
s = f.render(str(a[n*i+j]),True,(0,0,0),(255,255,255))
r = s.get_rect()
r.center = (j*pixels+pixels//2),(i*pixels+pixels//2)
if a[n*i... |
f1bfdb72d362780ab655df334c2e9049543eff9e | Lynzs/project | /addresslist.py | 2,183 | 3.6875 | 4 | import cProfile as p
import os
class Item:
def __init__(self,name,age,gender):
self.name=name
self.age=age
self.gender=gender
def menu():
print("")
print("1.insert an item ")
print("2.delete an item")
print("3.Modify an item")
print("4.Display all item")
print("5.Sor... |
cacf50d0e4b8e0cf968ea86effb6da3f6cbb9779 | hollyfeldl/pybyexample | /interfaces.py | 1,249 | 4.28125 | 4 | # interfaces example
# let's use inheritance and duck-typing
# Python also has abstract base classes which are closer to GO
# interfaces but usage in Python is rarer
import math
class geometry:
def __init__(self):
pass
def measure(self):
print(self)
print(self.area())
print(s... |
a9ae87d72b2efb61e1b2ffded5ed6e1703d557fa | hollyfeldl/pybyexample | /structs.py | 713 | 4.34375 | 4 | # the structs example
# in Python let us use classes
class person:
def __init__(self, name=None, age=0):
self.name = name
self.age = age
def __repr__(self):
# make the representation look like Go structs
return ('{{{0} {1}}}'.format(repr(self.name), repr(self.age)))
def main():... |
5bdfede597ae5d493333179ed2b2b9610631d788 | hollyfeldl/pybyexample | /array.py | 699 | 4.03125 | 4 | # example for arrays
import numpy as np
def main():
# create an empty list of 5 positions
a = [None] * 5
print("emp:", a)
a[4] = 100
print("set:", a)
print("get:", a[4])
print("len:", len(a))
# init a list with values
b = [1, 2, 3, 4 ,5]
print("dcl:", b)
# use lists f... |
91c870a5fa5292c543cc02cab2625d42faef8be3 | hollyfeldl/pybyexample | /switch.py | 847 | 3.890625 | 4 | # switch example
import calendar
from datetime import datetime
def caseFunc(x):
return{
1 : "one",
2 : "two",
3 : "three"
}.get(x, "undefined") # undefined is the default
def main():
# Python does not have a case/switch structure
# first replacement for switch -- dictionary ... |
57ce0cfd3b05ad54bee4dcbdb84e5659313cb4ea | AdamHussain786/Mathematical-generators-for-kids-in-python | /Measurement/measurement.py | 862 | 3.84375 | 4 | import random
import math
import csv
csv_file = open('measurement.csv', 'w+')
csv_writer = csv.writer(csv_file)
def housePlan():
for i in range(100):
x = random.randint(1 , 10)
y = random.randint(1, 10)
z = random.randint(y , 20)
areas = ['hall', 'living-room', 'kitchen... |
7ff1ed28b0de2d333cbbaeab84c38e6c1496c8fd | AdamHussain786/Mathematical-generators-for-kids-in-python | /Addition, Subtraction, multiplication, division/division.py | 686 | 3.6875 | 4 | import random
import math
import csv
fruits = ['apples', 'pears', 'raspberries', 'guavas', 'cherries']
csv_file = open('division.csv', 'a')
csv_writer = csv.writer(csv_file)
def divisionQuestions(iterations):
for i in range(iterations):
x = random.randint(0 , 4)
y = random.rand... |
b038a4625f507b3f147003226d52583dfad6b943 | ali-almousa/CS50-AI-Project1-knights | /puzzle.py | 5,193 | 3.546875 | 4 | from logic import *
AKnight = Symbol("A is a Knight")
AKnave = Symbol("A is a Knave")
BKnight = Symbol("B is a Knight")
BKnave = Symbol("B is a Knave")
CKnight = Symbol("C is a Knight")
CKnave = Symbol("C is a Knave")
################################################################################################... |
d15b2c76110b886bbc5821c6d402c02485c6f307 | dpswps12/min2 | /4.py | 157 | 3.671875 | 4 | score = int(input("점수 : "))
deg = {10:'A', 9:'A', 8:'B', 7:'C', 6:'D', 5:'F',4:'F', 3:'F', 2:'F', 1:'F',0:'F'}
s = score // 10
print(score, ':', deg[s])
|
ba5eb30dc451e2e23c771e2c2f1b976f0031b942 | DamianKumar7/TicTacToe | /TicTacToe(OOPS) Python/models/Player.py | 455 | 3.765625 | 4 |
class Player:
def __init__(self, name, game_piece):
self.name = name
self.game_piece = game_piece
def get_game_piece(self):
return self.game_piece
def get_player_name(self):
return self.name
def get_position_from_console(self):
print("{} Ent... |
d12aadcc74ed1c16b7d3c0a829b64091899aad98 | AnnaKostrikova/hello-world | /main.py | 275 | 4.25 | 4 | ######################
# Name: Anna Kostrikova
# Coding 02
# converting celsius to fahrenheit
######################
celsius=18.123
RATIO=9.0/5.0
Fahrenheit=RATIO*celsius+32
print('{:.1f}'.format(celsius),'degrees Celsius is equal to','{:.1f}'.format(Fahrenheit),'degrees Fahrenheit') |
79cf3a2219d82923d5da77f949c6410de5c9bc28 | JocelynYH/Python-Data-Analysis-Class | /Assignment 1/Jocelyn+Huang+HW+1+STAT+3250.py | 4,794 | 3.734375 | 4 |
# coding: utf-8
# In[73]:
##
## File: assignment01.py (STAT 3250)
## Topic: Assignment 1
## Name: Jocelyn Huang
## Section time: 3:30 - 4:45
## Grading Group: 3
#### Assignment 1, Part A
##
## For the questions in this part, use the following
## lists as needed:
mylist01 = [2,5,4,9,1... |
4987b2a388bc4f28777352fbd4534d8b2517793a | JocelynYH/Python-Data-Analysis-Class | /Assignment 3/assignment03.py | 2,677 | 4.3125 | 4 | ##
## File: assignment03.py (STAT 3250)
## Topic: Assignment 3
##
#### Assignment 3, Part A
##
## The problems in Part A should be done without the use of
## loops. They can be done with NumPy functions.
## The different questions in this part use the array
## defined below.
import numpy as np # Load NumPy
arr1 = ... |
f31dbb0c8ae72516d7fd46d147e0e243af39e238 | JocelynYH/Python-Data-Analysis-Class | /Assignment 8/HW+8+Stat+3250+Jocelyn+Huang.py | 10,870 | 3.703125 | 4 |
# coding: utf-8
# In[529]:
##
## File: assignment08.py (STAT 3250)
## Topic: Assignment 8
##
## The focus of this assignment is dates. Not the fruit, but the time
## and date that data is put into a file.
## 1. The questions below require the data frame 'reviews.txt' that
## is described in the README_assign08... |
a988d1d2fa25da836de7c4446e7fc3fa928ef117 | BozinovskiDaniel/Leetcode | /easy/validPalindrome.py | 592 | 3.796875 | 4 | class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s = s.lower()
stringArr = []
for letter in s:
if letter.isalnum():
stringArr.append(letter)
newS = ''.join(stringArr)
rev = newS[... |
0123124c7fa5c10a4b302cb40933a3fce5384555 | BozinovskiDaniel/Leetcode | /medium/binaryTreeInorderTraversal.py | 727 | 3.828125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: L... |
f09603999d5ff876ac0c28d7d0af3bfef8d403ba | xuyi11111/leetcode | /035.py | 557 | 3.828125 | 4 | #-----coding:utf-8------
'''
@project:leetcode
@author:yixu
@file:035.py
@ide:PyCharm
@create_time:2019/7/6 16:08
'''
class Solution:
def searchInsert(self, nums, target) :
left=0
right=len(nums)-1
while left<=right:
mid=(left+right)//2
if nums[mid]==target:
... |
709a2a8f238892e83dc0fd1edf7b364cb26fde2c | aparnapr121/python_practice | /test2.py | 703 | 3.734375 | 4 | def compareFriends(frndsList):
# Write your code here
res = []
f_len = len(frndsList) - 1
i = 0
j = 0
l1 = []
res = []
for x in frndsList:
l1.append(x.split(","))
l1.sort(key=lambda x: (x[0], x[1]))
print(l1)
for x in l1:
print(x)
flag = 1
for... |
c29da5ab6c6f60fdf3ca4a931ccb21fe4f48bba1 | aparnapr121/python_practice | /binary_tree.py | 2,461 | 3.953125 | 4 | class BSTNode(object):
def __init__(self, parent, k):
self.key = k
self.parent = parent
self.left = None
self.right = None
def insert(self, node):
"""
insert a node into the subtree rooted at this node
"""
if node is None:
return
... |
f91189bd499b28dff7654c7427d7e8ae05d4cc33 | aparnapr121/python_practice | /closures.py | 397 | 4.03125 | 4 | def outer():
x = 10
def inner():
return x+10
return inner
inner_f = outer()
print(inner_f())
print(inner_f.__closure__)
print(outer.__closure__)
# no reference to enclosing scope inn inner func's body here
def outer():
x = 10
def inner():
return 10
return inner
inner_f = out... |
a1719c524ce8995b464896a63582cee099cd202b | emirhanmtl/RandomPasswordGenerator | /Password Generator.py | 784 | 4.03125 | 4 | import random
while True:
print("Hello, Welcome to Password Generator 3000!")
length = int(input("\nEnter the length of password: "))
name = str(input("\nWhat is your password for:"))
chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!'^+%&/()=?_->£#$½{[]}\|"
password = ""
... |
26e0547b1674e0278841daaf47f0eb3d8dc0039a | exodusmulaggusi/python | /TIQM.py | 4,960 | 3.828125 | 4 | import time
#method one
#ANSWER=input('type your answer:')
#if ANSWER==ans4:
# print('correct')
#else:
# print('wrong')
starttime=time.ctime().split()[3]
print('you have started the test at', starttime)
s1s="according to the world book of records the highes I.Q score is 228\n which was scored by MARILYN VOS SAVANT ... |
ab29df9c0c8d3a246f797dfbd25b4d7029b4a036 | cji03/LeetCode-Practise | /Python/Longest Consecutive Sequence.py | 1,281 | 3.734375 | 4 | # Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
#
# For example,
# Given [100, 4, 200, 1, 3, 2],
# The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
#
# Your algorithm should run in O(n) complexity.
# 用了hashset, 取出一个数,抛掉,然后+1 —1看是否存在... |
47796c390d81ef5b42543bb5a48cd78dfa1f2eb8 | cji03/LeetCode-Practise | /Python/1. Container With Most Water.py | 865 | 3.71875 | 4 | # Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).
# n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).
# Find two lines, which together with x-axis forms a container, such that the container contains the most water.
# Note: Yo... |
5c2f176288e96e0977c925eaf452e9eef0fc2892 | cji03/LeetCode-Practise | /Python/1. Remove Element.py | 766 | 4.03125 | 4 | # Do not allocate extra space for another array, you must do this in place with constant memory.
# The order of elements can be changed. It doesn't matter what you leave beyond the new length.
# Example:
# Given input array nums = [3,2,2,3], val = 3
# Your function should return length = 2, with the first two element... |
33621a677bba0250f47b6abf73cc25eaf1bfa36d | njgupta23/Coding-Challenges | /reimanns-sum.py | 715 | 4.375 | 4 | # Reimann's Sum
# Background: A Reimann's sum is an approximation of an integral.
# The sum is calculated by dividing the area under the curve into rectangles,
# calculating the area of each rectangle, and adding all these areas together.
# Write a function that returns a function which computes the Reimann's sum
# o... |
bce3b0847ac9aa49fd078d9199cc1acfb06c36a1 | njgupta23/Coding-Challenges | /without-str.py | 763 | 3.984375 | 4 | # Without String
# Given two strings, base and remove, return a version of the base string where all
# instances of the remove string have been removed.
# You may assume that the remove string is length 1 or more.
# Remove only non-overlapping instances, so with "xxx" removing "xx" leaves "x".
# withoutString("H... |
ae1c0355090e64ce6c01c0992275e68650ba4994 | njgupta23/Coding-Challenges | /find-equil.py | 787 | 3.9375 | 4 | # Given a list of unordered integers,
# find the equilibrium point where the sum of all ints to the left
# equals the sum of all ints to the right.
# Notes:
# - Return the index of the last element in the first half of the list
# - If there is no exact equilibrium point, return the closest
# >>> nums = [5, 3... |
f3264e9e116471c8e6b437e4b1ccb44d86266a4e | mattsfowler/Dataset-Visualisation-Dissertation | /R/Visualisations/convertheaderfile.py | 851 | 3.5625 | 4 | import sys
if __name__ == "__main__":
file_path = "CommunityData.txt"
output_path = "CommunityHeader.txt"
header_file = None
try:
header_file = open(file_path, "r")
except:
print("ERROR: could not open file to read")
sys.exit(1)
output_file = None
try:
ou... |
5ca3eb0effe1164ea414dc51db2fe3dac9fa4847 | louis627/Projects | /creat_an_art_marketplace.py | 2,389 | 3.703125 | 4 | class Art:
def __init__(self, artist, title, medium, year, owner):
self.artist = artist
self.title = title
self.medium = medium
self.year = year
self.owner = owner
def __repr__(self):
return """{artist_name}. "{name_of_art}". {year}, {medium}. {owner}, {location}.""".format(artist_name = se... |
809b750fc541d069da15b15dd6e35f45d6b7b4b2 | altmshfkgudtjr/Problem-Solving | /Summer_Winter Coding 2019/멀쩡한사각형.py | 172 | 3.59375 | 4 | def gcd(x, y):
while y:
x, y = y, x % y
return x
def solution(w, h):
value = gcd(w, h)
pattern = (w / value) + (h / value) - 1
return int(w * h - pattern * value)
|
9bae6bbc2036e9f5de25abc3f11d2846cb4adf3d | altmshfkgudtjr/Problem-Solving | /월간 코드 챌린지 시즌2/올바른 괄호 문자열.py | 624 | 3.828125 | 4 | def stackChecker(s):
stack = []
for c in s:
if c == '(' or c == '{' or c == '[':
stack.append(c)
else:
if len(stack) == 0:
return False
tmp = stack.pop()
if (tmp == '(' and c == ')') or\
(tmp == '{' and c == '}') or\
(tmp == '[' and c == ']'):
pass
else:
stack.append(tmp)
st... |
0a6955945c62653f993e4acec76eccacfdc4b846 | altmshfkgudtjr/Problem-Solving | /KAKAO Winter Intership 2019/크레인인형뽑기.py | 617 | 3.5625 | 4 | def solution(board, moves):
answer = 0
stack = []
for move in moves:
move -= 1
catch = None
for row in board:
if row[move] == 0:
continue
catch = row[move]
row[move] = 0
break
if catch != None:
if len(stack) != 0 and stack[len(stack)-1] == catch:
stack.pop()
answer+=... |
f2a5d054fecf5cf8f85d3242ffa0c0486ba435ba | Dominik-Robert/csv-merge | /mergecsv.py | 1,439 | 3.71875 | 4 | import argparse
import csv
parser = argparse.ArgumentParser(description='Merges two CSV files')
parser.add_argument("-i", "--inputFile", action="append", type=str, required=True, help="Path of the InputFile")
parser.add_argument("-m", "--match", action="append", type=int, required=True, help="The index of the CSV File... |
77bf1ec2b691b56499ada369e574044f786685a7 | elonoraartango/Practicals | /prac_02/file_A.py | 276 | 4.03125 | 4 |
infile=open('name.txt','r') #name of file that name has been previously saved to
name = infile.read() #'name'(variable) is found and read
print("Your name is:", name) #asking user for input / data is being taken from file on previous input
infile.close() #closes the file
|
f98cd118c92dd921bb0642a1476c0d6be884129a | agvish/Python | /Image_Process.py | 8,040 | 4.09375 | 4 | """This script will convert pdf pages to images.
The images will undergo some processing to improve its quality.
Following processing techniques are implemented:
1: Binarizing Image
2: Scaling Image
3: De-skewing Image
4: Denoising Image via erosion - dilation method
5: Eroding Image
6: Dilating Image
7: Denoising Ima... |
b134fb2b68ad1bf3e9bcb2509df0d12cbabf356c | srinu1009/Demo_Project | /Table.py | 107 | 3.859375 | 4 | num = int(input("Enter the table number : "))
for i in range(21):
print(f" {num} * {i} = {num * i} ")
|
5d8d37d88d3e5a2ef202375481bd50249eb4f58e | gitmaster1337/brainfuck-lvl1 | /brainfuck_games/engine.py | 1,483 | 3.6875 | 4 | """Brainfuck Games game engine."""
import prompt
from brainfuck_games import cli, settings
def run_game(game_descr, ask_question):
"""Run a specific Brainfuck Game.
Args:
game_descr:
Game description string
ask_question:
Function returning question and correct
... |
80a0d83d7de33caeefadd264b20a8eb8a10513f0 | AnthonyAltieri/discord-gateway | /discord_gateway/environment.py | 875 | 3.546875 | 4 | import os
from enum import Enum
class Environment(str, Enum):
DEVELOPMENT = "DEVELOPMENT"
STAGING = "STAGING"
PRODUCTION = "PRODUCTION"
def get_environment() -> Environment:
"""Get the current environment"""
raw = os.environ.get("ENVIRONMENT", Environment.DEVELOPMENT.value)
normalized = raw.... |
8242ca3855b915c4f2b14399afd9153265d81748 | darlose04/Python-Scripts | /reverseString.py | 228 | 4.65625 | 5 | # Reverse a String
# Enter a string and the program will reverse it and print it out.
def reverse_string():
word = str(input('Enter a string: '))
word_reverse = word[::-1]
print(word_reverse)
reverse_string()
|
57f05f9f07717074258dcdc8c62506f2bab9e0a0 | darlose04/Python-Scripts | /reverseInteger.py | 268 | 3.84375 | 4 | def reverse(x):
intString = str(x)
lstString = list(intString)
if lstString[0] == '-':
lstString.pop(0)
return int('-' + ''.join(lstString[::-1]))
else:
return int(''.join(lstString[::-1]))
print(reverse(-10235))
|
cab98a22d244732ca63a7ab7c537ed2d4d59c306 | darlose04/Python-Scripts | /MIT_Python/Week1/wk1pset1p1.py | 342 | 3.921875 | 4 | # Write a program that counts the number of vowels in a string
s = 'azcbobobegghakl'
count_a = s.lower().count('a')
count_e = s.lower().count('e')
count_i = s.lower().count('i')
count_o = s.lower().count('o')
count_u = s.lower().count('u')
total = count_a + count_e + count_i + count_o + count_u
print('Number of vowel... |
c006a0e2733a45216f61abadb5b0623ad44aa741 | darlose04/Python-Scripts | /MIT_Python/Week2/week2p1.py | 1,304 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Problem 1 - Paying Debt off in a Year
Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month.
"""
'''def cc_balance(bal,r,mo):
Returns the remaining balance on a cred... |
4fabfde471f0ae74465e3d497b5c9b3179f60712 | suyashgoyan/Python-Projects- | /HiLo_Game.py | 1,223 | 4.09375 | 4 | low = 1
high = 1000
print("Please think of a number between {} and {}".format(low,high))
input("Press ENTER to start ")
guesses = 1
while low != high: # We used True because the computer don't the exact answer
guess = low + (high - low) // 2 #Binary Search Form... |
c5a495b311a719f208b50220f73d90ee6e1f91f0 | jeevanvenkataramana/Coding-Challenges | /Convert Date Format/Date_format_conversion.py | 691 | 4.3125 | 4 | ''' Convert a date in the format 9-sep-2015 to yyyy/mm/dd --> 2015/09/09'''
def convert(dates):
month = {'jan':'01','feb':'02','mar':'03' ,'apr':'04' ,'may':'05' ,'jun':'06' ,'jul':'07' ,'aug':'08' ,'sep':'09' ,'oct':'10' ,'nov':'11' ,'dec':'12'}
results=list()
temp_str="/"
for i in dates:
date... |
44fab9102dd4a5b35a5af978d8e42ee04b7793fb | muppidathic/pytho | /find year is leap year or not.py | 221 | 3.953125 | 4 |
x=int(input("a="))
if(x%4==0):
print(" year is leap year")
else:
print(" year is not leap year")
x=int(input("a="))
if(x%4==0):
print(" year is leap year")
else:
print(" year is not leap year")
|
b7329c4970f7de26039993421af8ac0ac801327b | muppidathic/pytho | /print the sorted array.py | 171 | 4.21875 | 4 | list=[]
num=int(input("how many numbers:"))
for i in range(num):
num=int(input("enter a number:"))
list.append(num)
print("the sorted array is",sorted(list))
|
fc5eaea7f9e03d8d98be43ef756f45f385e79a03 | Ryan-Walsh-6/ICS3U-Unit6-04-Python | /2d_array.py | 1,839 | 4.5 | 4 | #!/usr/bin/env python3
# created by: Ryan Walsh
# created on: January 2021
# this program generate a 2-D array and finds average of all numbers in array
import random
def average_of_numbers(passed_in_2d_list):
# this function adds up and calculates the average all the elements
# in a 2D array
total = 0... |
4079ad91acb7d4fce917952c1263bd68acd27ff6 | aballester29/dotfiles | /config_files/bin/invertcsv | 1,166 | 4.0625 | 4 | #!/usr/bin/env python3
# Author:
# Sergio Quijano Rey
# sergiquijano@gmail.com
# Version:
# v1.0 03/10/2018 - First functionally version
# Description:
# Reverses a whole csv table
# I am using it for "Evo Banco" .xls file, which cannot be reversed properly by date
import os
import sys
if __name__ == "__m... |
e9addfb0fe221d05c5dbeda702d086d7384da04c | Tanya1901/my_pyton | /future_ball.py | 1,157 | 3.609375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[11]:
import random
a = str(input("Введите свой общий вопрос или break: "))
if a != "break":
with open("Desktop/шар.txt") as file:
rd = file.readlines()
rd_r = random.choice(rd)
print(rd_r.strip())
a = str(input("Введите свой общий вопро... |
30c7e328a6ad49f021717514a6b1894c27f0bd3f | Tanya1901/my_pyton | /_uncle.py | 341 | 3.90625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
a='Мой дядя самых честных правил, Когда не в шутку занемог, Он уважать себя заставил И лучше выдумать не мог'
# In[2]:
print(' '.join(x for x in a.split(' ') if not x.startswith('м')))
# In[ ]:
|
68a7d787d88aa2f3433a7dcfea3a1df11140dd3c | Tanya1901/my_pyton | /my_calc.py | 817 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
try:
x = float(input("Введите первое число: "))
y = float(input("Введите второе число: "))
o = input("Введите операцию: ")
if o in ('+','-','*','/'):
if o == '+':
print (x+y)
elif o == '-':
print (x-y)
elif... |
83f7e7fe1d843335a4d6e77f08567132282f3828 | zendoth/Python | /Rotate Array.py | 627 | 4.125 | 4 | """
@author Zendoth
Website https://github.com/zendoth/Python
Date Thu Jan 2 20:03:36 2020
"""
#Question's website https://practice.geeksforgeeks.org/problems/rotate-array-by-n-elements/0
#Task Given an unsorted array arr[] of size N, rotate it by D elements (clockwise)
def rotate(x,d):
for i in range(... |
52148f6422c0f19939e603ac08b5601d2c72ecee | myshuradima/amis | /km-83/Mishura_Dmitro/workshop3/homework/homework_20.11.2018.py | 2,453 | 3.796875 | 4 | """
Тут написати умову до завдання
"""
def market_list(sn, arr=[], n=0):
"""
Рекурсивна функція, яка повертає список всіх магазинів
:param sn:
:param arr:
:param n:
:return:
"""
key = list(sn.keys())
if (n == len(key)):
print(set(arr))
return
else:
arr = a... |
0031c073467addbcb5adc444f6b486ab12170d75 | Samyak-Surti/FireCellularAutomata | /1DCA_Example/ca1dview.py | 1,415 | 3.625 | 4 | class CA1Dview(object):
"""
Provides a UI for a CA1D object.
Can be replaced by any class providing the same methods.
"""
def __init__(self, off_color, on_color):
"""
These cryptic attributes use ANSI terminal codes to print a space
in either the off colour or the on colou... |
5d20c3ea3650c6ee3d5dd24347d46f73fb54cf6b | VNSubhash/Subhash | /second.py | 126 | 3.96875 | 4 | #subhashvecham999@gmail.com
a=int(input())
if((a>0)&(a%2==0)):
print('Even')
elif((a>0)&a%2!=0):
print('Odd')
else:
print('Invalid')
|
f09acc9930dca77cca28e40ba984a6f7c6872aba | FrozenSky7124/Project_Python | /Demo/Demo00_Practice/ThinkPython_C08_0.py | 521 | 3.890625 | 4 | """
This module contains a code example related to
Think Python, 2nd Edition
by Allen Downey
http://thinkpython2.com
Copyright 2015 Allen Downey
License: http://creativecommons.org/licenses/by/4.0/
"""
def is_reverse(word1, word2):
if len(word1) != len(word2):
return False
i = 0
j = len(word2) -... |
4d6a3421925b8524cf0c7ba4e10e92ee5768127a | Josehpequeno/Projeto-PMC | /interface1.py | 2,562 | 3.75 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 17:12:40 2019
@author: hicaro
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 17:10:23 2019
@author: hicaro
"""
from functools import partial
from tkinter import *
def bt_click():
if(str(ed1.get()).isnumeric() ... |
d22364604c00aee3c71c9346cc4bc693a580c9a8 | PerlaLunaD/csv-py | /csv-rw/read.py | 1,534 | 4.21875 | 4 | import csv
# 'with' se usa para crear un contexto de manejo del archivo.
# Sin usarlo, tendriamos que administrar el abrir y cerrar de el archivo nosotros mismos
# Aqui estamos abriendo el archivo, y pasando la 'r' para 'read' y asignandolo a la variable 'csv_file'
with open('spreadsheet-01.csv', 'r') as csv_file:
... |
93eda82ff19005ac9ee45d362ed36760010c1028 | marmagk/Programming_with_python_2122 | /part1_Basics/i_for_loops.py | 1,937 | 4.34375 | 4 | # encoding: utf-8
##################################################
# This script shows an example of comparison operators.
# First, it shows examples of - for - loops.
# These loops serve to repeat operations for a defined number of times.
#
##################################################
#
######################... |
96cec69f706a2aafd142032056894833515bbafe | marmagk/Programming_with_python_2122 | /Part2-DataTypes/b_pseudo.py | 326 | 4.34375 | 4 | # declaring an empty list
# declaring a list with some numbers
# checking the data type of list
# creating a list with different data types
# using len() to count the items in a list
# indexing and slicing list
# merging lists
# reassigning a specific item
# adding an item to the list
# reversing the order of th... |
ad27b0e9620e1d95e99327d98f77264566a1418b | Lorenzo-Cel/Introduciton-to-CIS | /First Assignment - Golf Improvment.py | 1,806 | 4.09375 | 4 | #program 1 September 09, 2020 Lorenzo Celiento
#Second version
#Introduction messages
print("this program is going to calculate the golfer’s handicap")
print()
print("________________________________________________________")
print()
#inizialization of variables start ************
Par = 0
S... |
778af83c7950713b6263d746a78cb91980528d75 | VladyslavHnatchenko/async-p | /algorithms/quadratic_time.py | 448 | 4 | 4 | """ O(n²) -> Quadratic Time
for x in data:
for y in data:
print(x, y)
"""
def bubble_sort(data):
swapped = True
while swapped:
swapped = False
for i in range(len(data) - 1):
if data[i] > data[i + 1]:
data[i], data[i+1] = data[i+1], data[i]
... |
e9871b8eaec26d84afbed4012831cf8c4e52856e | VladyslavHnatchenko/async-p | /worker.py | 1,115 | 3.640625 | 4 | # ThreadPoolExecutor VERSION
from concurrent.futures import ThreadPoolExecutor
from time import sleep
def return_after_5_secs(message):
sleep(5)
return message
pool = ThreadPoolExecutor(3)
future = pool.submit(return_after_5_secs, "hello")
print(future.done())
sleep(5)
print(future.done())
print(future.res... |
022b22d7dfd8c45dcb84f24eef73f6f6483ba56c | gauravprasad/coding-challenge-hackerrank | /src/main/python/com/gprasad/hackerrank/py/python/collections/CollectionsDeque.py | 325 | 3.671875 | 4 | from collections import deque
n = int(input())
dq = deque()
for _ in range(n):
op, *val = input().split()
if op == 'append':
dq.append(int(val[0]))
elif op == 'pop':
dq.pop()
elif op == 'popleft':
dq.popleft()
elif op == 'appendleft':
dq.appendleft(int(val[0]))
print... |
2e675731e9c3deccb345a5b67b367639db6454d6 | ahmedamin1700/python_challenges | /birthday_cake_candles.py | 699 | 4.21875 | 4 | # HackerRank Challenge.
# Ahmed Amin 18 / 10 / 2020.
# You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year
# of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are
# tallest.
def birthday_cake_candles... |
3df6f3e3741f8155cdcb970db06c778ddbff8709 | ahmedamin1700/python_challenges | /mini_max_sum.py | 649 | 4.09375 | 4 | # HackerRank Challenge.
# Ahmed Amin 18 / 10 / 2020.
# Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of
# the five integers. Then print the respective minimum and maximum values as a single line of two space-separated
# long integers.
def mini_max_sum... |
05c693ec1285c9493dc514a03ba0fec086c44f2a | kaushal-gupta/opencv-programs | /Drawing.py | 640 | 3.75 | 4 | import numpy as np
import cv2
# Create a black image
img = np.zeros((512,512,3), np.uint8)
# Draw a diagonal blue line with thickness of 5 px
cv2.line(img,(0,0),(511,511),(255,0,0),5)
#Drawing Rectangle
cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)
#Drwaing circle using center coordinates and the ra... |
2c6530ad6690d88dde443c4f8fda347a21afcd45 | IvAnastasia/News-lexical-analysis | /среднее количество предложений.py | 836 | 3.53125 | 4 | import re
# среднее количество предложений в текстах
def mean_sentence_number(text):
sentences = re.split(r'[.?!]|$', text)
return len(sentences)
rus_sum = 0
indep_sum = 0
for n in range(1, 17):
with open('rusnew' + str(n) + '.txt', encoding = 'utf-8') as file:
text = file.read()
... |
dc7b3da14d70e209f45ba6be0c4c5ea590b7c53f | Gerj17/FamilyTree | /core/FamilyTree.py | 2,583 | 4 | 4 | import core.Human as Person
import copy
class FamilyTree:
""" Creates persons in the using the Human class.
Stores their ID in the self.__tree dictionary, the ID is the key and the value is the instance of
the person class, all all interactions between individuals take place in
the person class """
... |
731c0420dc1bd2737d1db5555d6feaf736430797 | gingeleski/keyword-captain | /src/Cell.py | 1,852 | 4 | 4 | from enum import Enum
class Cell(object):
letters = ''
value = -1
is_used = False
multiplier = None
# coordinates on board
x = -1
y = -1
def __init__(self):
self.letters = ''
self.value = -1
self.is_used = False
self.x = -1
self.y = -1
s... |
7b6ee273fb9ee42e3df932d3043cc930359883c4 | lyicecream1012/mycode | /b.py | 528 | 3.515625 | 4 | #!/usr/bin/env python
# yanghui
def print_yanghui(n):
if n <= 0:
return null
listyang = []
for i in range(1,n+1):
listyang.append(['1'] * i)
if n > 2:
for i in range(2, n):
for j in range(1, i):
listyang[i][j] = str(int(listyang[i-1][j-1]) + int(list... |
c16aeed36aa5d2586bac03acad66fe11bf42561b | uimarshall/DataStructure-and-Algorithm_Trees_And_Graphs | /Problemset5tree(e).py | 3,312 | 4.1875 | 4 | #-------------------------------------------------------------------------------
# Name: Using the buildHeap method, write a sorting function that can sort a list in
# O(nlogn) time.
# Purpose:Education
#
# Author: mmk and marshal
#
# Created: 11/09/2018
# Copyright: (c) mmk 2018
# Licence: <glori... |
95802d01ec41ef16801504ad43683eaf8357f475 | gustavogneto/app-comerciais-kivy | /aula71.py | 129 | 3.671875 | 4 | lista = "TE AMO ALINE"
print(lista[::])
print(lista[:6:])
print(lista[len(lista)-5::])
print(lista[::-1])
print(len(lista)-5)
|
4538366d5aa8962148b222f2a9d3de778403231b | gustavogneto/app-comerciais-kivy | /POO/retangle.py | 222 | 3.53125 | 4 | # coding: utf-8
class Retangle:
# constructor
def __init__(self):
self.a = 0
self.l = 0
def area(self):
return self.a * self.l
r1 = Retangle()
r1.l = 10
r1.a = 5
print(r1.area())
|
b12c98be49b4de7162f09ef83410f86123977396 | zoek917/Zoe-Ko | /Zoe Ko Final "Pathetic Quiz" .py | 1,247 | 3.90625 | 4 |
print('Quiz:How pathetic are you? Instructions: you will get a set of questions and at the end however manypoints you have out of five is how else you are to truly pathetic. 5 is 100% pathetic')
#1st question
print('1st question')
print('How old are you?')
points = 0
age = int(input())
if age > 0 and age <= 1... |
92fc439087c0f8937ba940c2a4d0598c82f7ced4 | uscwang54/challenge-project | /currencies.py | 1,112 | 3.75 | 4 | class Ccy:
exchange_rate = {"USD": 1, "GBP": 0.8, "EUR": 0.9, "JPY": 106.54, "CAD": 1.39}
def __init__(self, amount, unit="EUR"):
self.amount = amount
self.unit = unit
def __str__(self):
return f"{self.amount:.2f} {self.unit}"
def __add__(self, other):
if type(other) ... |
efae5411e8a98c45d5a3ddbd741c965305cbcd7d | ArevikArestakyan/Homework-N3 | /Task 3-5.py | 153 | 3.984375 | 4 | a = int(input("a ="))
b = int(input("b ="))
c = int(input("c ="))
if a + b == c or a + c == b or c + b == a:
print("Yes")
else:
print("No") |
a89027ec34196eba0c9c542d5c0d59a989f13913 | jpignata/adventofcode | /2015/10/solve.py | 560 | 3.53125 | 4 | from collections import deque
def look_and_say(numbers, times):
numbers = deque(numbers)
output = []
while numbers:
number = numbers.popleft()
count = 1
while numbers and number == numbers[0]:
numbers.popleft()
count += 1
output.append(f"{count}{n... |
eb9dfeac3b8118461928083139d898c00df8e8f0 | jpignata/adventofcode | /2016/03/solve.py | 350 | 3.875 | 4 | import sys
import numpy as np
def count(triangles):
return sum(1 for a, b, c in triangles if a + b > c and a + c > b and b + c > a)
triangles = np.loadtxt(sys.stdin.readlines())
transposed = triangles.transpose().flatten()
transposed.shape = int(len(transposed) / 3), 3
print("Part 1:", count(triangles))
print(... |
5e8f1135a88e8e41957feb7518935d0504fa1f9e | jpignata/adventofcode | /2017/06/solve.py | 522 | 3.625 | 4 | from itertools import count
banks = [2, 8, 8, 5, 4, 2, 3, 1, 5, 5, 1, 2, 15, 13, 5, 14]
first = 0
second = 0
seen = []
for i in count(1):
idx = banks.index(max(banks))
size = banks[idx]
banks[idx] = 0
for j in range(idx + 1, idx + size + 1):
banks[j % len(banks)] += 1
if seen.count(str(b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.