blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
52f3999f1065af63d7942742b5313d82829ce2b3
GaganDureja/Algorithm-practice
/Balancing scale.py
262
3.515625
4
#Link: https://edabit.com/challenge/xPmfKHShmuKL5Qf9u def scale_tip(lst): left = sum(lst[:lst.index('I')]) right = sum(lst[lst.index('I')+1:]) return 'balanced' if left==right else 'left' if left>right else 'right' print(scale_tip([0, 0, "I", 1, 1]))
bd5772753947ecc410181a53ba174f28563aea27
GaganDureja/Algorithm-practice
/merge_sort.py
264
3.9375
4
# This problem was asked by Google. # Given k sorted singly linked lists, write a function to merge all the lists into one sorted singly linked list. def sort_merge(lst): return sorted(sum(lst,[])) lst = [[1,5,8],[0,2,6]] print(sort_merge(lst))
af0b61fb0ec5eed544bd7d47e2e6ddd5c43604e3
GaganDureja/Algorithm-practice
/climbing competition.py
554
3.703125
4
#Link: https://edabit.com/challenge/Q7oecYfjkq7tHwPoA def climb(stamina, obstacles): count = 0 x = 1 while True: try: prev = obstacles[x-1] now = obstacles[x] except IndexError: return count if prev==now: count+=1 x+=1 elif prev>now and stamina>=int((prev-now)+0.999): stamina-=int((p...
7d3e7f1c6ae4cc055b7fd0c4abcc2bdf0df5082f
GaganDureja/Algorithm-practice
/Big sorting.py
289
3.828125
4
#Link: https://www.hackerrank.com/challenges/big-sorting/problem n = int(input().strip()) unsorted = [] unsorted_i = 0 for unsorted_i in range(n): unsorted_t = str(input().strip()) unsorted.append(unsorted_t) unsorted.sort(key= lambda x:(len(x),x)) for i in unsorted: print(i)
13f403466c54ae0edd72fa95a867cc7d234ae206
GaganDureja/Algorithm-practice
/budget items.py
347
3.578125
4
Link: https://edabit.com/challenge/9ZAk3EEoQ9YPGGYhA def items_purchase(store, wallet): lst = [] for x in store: price = int((store[x][1:]).replace(',','')) if price<= int(wallet[1:]): lst.append(x) return lst if lst else 'Nothing' print(items_purchase({"Water": "$1", "Bread": "$3", "TV": "$1,000","Fert...
25f7bd2da375d36fce8e9febbc03651943a8c4d2
GaganDureja/Algorithm-practice
/Amateur Hour.py
636
3.734375
4
#Link: https://edabit.com/challenge/6BXmvwJ5SGjby3x9Z def convet24(txt): if txt[-2:]=='AM' and txt[:2]=='12': return 0 elif txt[-2:]=='PM' and txt[:2]!='12': return int(txt.split(':')[0])+12 else: return int(txt.split(':')[0]) def hours_passed(time1, time2): return 'no time passed' if time1==time2 e...
ac42e69bac982862edcbed8567653688ee07f186
GaganDureja/Algorithm-practice
/Vending Machine.py
1,686
4.25
4
# Link: https://edabit.com/challenge/dKLJ4uvssAJwRDtCo # Your task is to create a function that simulates a vending machine. # Given an amount of money (in cents ¢ to make it simpler) and a product_number, #the vending machine should output the correct product name and give back the correct amount of change. # The...
bdd4c91465121a0b9d6692f2ace3a71e37ac9e24
GaganDureja/Algorithm-practice
/bin_consecutive.py
395
3.75
4
# This problem was asked by Stripe. # Given an integer n, return the length of the longest consecutive run of # 1s in its binary representation. # For example, given 156, you should return 3. def bin_consecutive(n): lst = [] count = 0 for x in bin(n): if x=='1': count+=1 else: lst.append(co...
211c1129fbe5965c1e1c8c8981231c68bcb43421
tangjiaxing669/magedu_worker
/work_3.py
170
3.890625
4
#!/usr/bin/env python rep_list = [1, 3, 2, 4, 3, 2, 5, 5, 7] list_temp = [] for i in rep_list: if i not in list_temp: list_temp.append(i) print(list_temp)
935ccb971b74f78ee14b5d0079f46c2f2ba00e28
xinbingzhe/Tianchidata_taobaorec
/count_term_match.py
168
3.515625
4
def count_term_match(test_term,match_term): count = 0 for tt in test_term: if tt!='': count = count + match_term.count(tt) return count
6a18a4213fe1f83c4e110bc0cbda1b4aa85f53dd
Andrej300/tdd_fizzbuzz
/src/fizzbuzz.py
288
3.84375
4
def fizzbuzz(number): if number == 3: return "fizz" elif number == 5: return "buzz" elif number == 15: return "fizzbuzz" elif number == 4: return "4" elif number % 15 == 0: return "fizzbuzz" # THE FUNCTION CREATED SUCCESFULLY
d69edfd1a15a4ac77d29c0392dd1ea8db3d55352
Tallequalle/Code_wars
/Perimeter.py
415
3.984375
4
#The function perimeter has for parameter n where n + 1 is the number of squares (they are numbered from 0 to n) and returns the total perimeter of all the squares. def fib(n): if n == 0: return 0 elif n in (1,2): return 1 else: return fib(n - 1) + fib(n - 2) def perimeter(n): ...
cfc8a7e2d9bd3de03f4a654826838aacdec32586
Tallequalle/Code_wars
/Task23.py
771
3.859375
4
#In mathematics, a Diophantine equation is a polynomial equation, usually with two or more unknowns, such that only the integer solutions are sought or studied. #In this kata we want to find all integers x, y (x >= 0, y >= 0) solutions of a diophantine equation of the form: #x2 - 4 * y2 = n #(where the unknowns are x...
47f8c6b8f6c8b01f0bc66d998fdd4c039bf91572
Tallequalle/Code_wars
/Task15.py
728
4.125
4
#A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant). #Given a string, detect whether or not it is a pangram. Return True if it i...
f07319d009817401342e4c7691d90c2a1c5121bd
Tallequalle/Code_wars
/Task9.py
301
3.59375
4
def order(sentence): # code here dict = {} lst = [] for i in sentence.split(): for j in range(len(sentence.split()) + 1): if str(j) in i: dict[j] = i for i in range(1,len(sentence.split()) + 1): lst.append(dict[i]) return ' '.join(lst) order("is2 Thi1s T4est 3a")
bc0f1c5b564e30b27364dd3dce13b62e493affa2
Deepdesh/data-prework
/snail-and-well.py
5,845
4.3125
4
#!/usr/bin/env python # coding: utf-8 # <img src="https://bit.ly/2VnXWr2" width="100" align="left"> # # The Snail and the Well # # A snail falls at the bottom of a 125 cm well. Each day the snail rises 30 cm. But at night, while sleeping, slides 20 cm because the walls are wet. How many days does it take for the sna...
d4732957153731bb76ae6d2881fb68ce5c52441c
Serendipity0618/python-practice
/zero_number_end2.py
351
4.03125
4
def factorial(n) : product = 1 while n > 0: product = product * n n = n - 1 return product n = input("Please input x:") product = factorial(int(n)) print(product) str = list(str(product)) #print(str) i = -1 counter = 0 while int(str[i]) == 0: counter = counter + 1 ...
a739fe164438f5caf866c2aa2a580e76cabb01cd
gciotto/learning-python
/part6/exercise3/mylistsub.py
1,584
3.625
4
from exercise2.listwrapper import Mylist class MylistSub (Mylist): number_of_calls = 0 def __init__ (self, data = []): MylistSub.number_of_calls += 1 Mylist.__init__(self, data) def __add__ (self, other): MylistSub.number_of_calls += 1 if type (ot...
4cff39203e317f4b8081b0f30b32a7d357a75db1
gciotto/learning-python
/part6/exercise2/listwrapper.py
1,022
3.859375
4
class Mylist(): def __init__ (self, data = []): self.data = [] for item in data: self.data.append(item) def __add__ (self, other): if type (other) == Mylist : return Mylist(self.data + other.data) return Mylis...
091718f2cf95ce96ff8d3aa2704068d25e650121
wsargeant/aoc2020
/day_1.py
1,383
4.34375
4
def read_integers(filename): """ Returns list of numbers from file containing list of numbers separated by new lines """ infile = open(filename, "r") number_list = [] while True: num = infile.readline() if len(num) == 0: break if "\n" in num: num = num...
0e5c146079914aa6bab5f783d98c0dc0bcdeb6f5
hungdoan888/algo_expert
/rightSiblingTree.py
1,770
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 13 17:43:39 2021 @author: hungd """ # This is the class of the input root. Do not edit it. class BinaryTree: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def insert(self,...
4a39a20896255a548630d1b25d2811a034788e4f
hungdoan888/algo_expert
/reverseWordsInString.py
534
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 2 20:32:31 2021 @author: hungd """ def reverseWordsInString(string): # Write your code here. newString = "" prevI = len(string) hasSpaces = False for i in reversed(range(len(string))): if string[i] == " ": newString += string[i:pr...
60222725d3f34393d03e644196e94bb59250a24d
hungdoan888/algo_expert
/ThreeNumberSum2.py
633
4.03125
4
def threeNumberSum(array, targetSum): threeNumberList = list() array.sort() for i in range(len(array) - 2): low = i + 1 high = len(array) - 1 while low < high: if array[i] + array[low] + array[high] == targetSum: threeNumberList.append([array[i], array[lo...
446a02bb4cb33ebf28bb3d527d89b4ce476eb7cc
hungdoan888/algo_expert
/diskStacking.py
1,156
3.796875
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 16 10:58:33 2020 @author: hungd """ def diskStacking(disks): # Write your code here. disks.sort(key=lambda disk:disk[2]) heights = [[0, []] for _ in range(len(disks))] for i in range(len(disks)): maxHeight = disks[i][2] maxHeightJ = None ...
32b1a830efb26d7a935de27dd6940c96823a73aa
hungdoan888/algo_expert
/removeIslands.py
1,345
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 26 16:50:44 2020 @author: hungd """ def removeIslands(matrix): # Write your code here. visited = [[0 for j in range(len(matrix[0]))] for i in range(len(matrix))] i = 0 for j in range(len(matrix[0])): matrixTraverse(matrix, visited, i, j) ...
f4497789caa2482b7590e11a57107076154d497b
hungdoan888/algo_expert
/sudoku.py
4,958
4.0625
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 2 21:05:15 2021 @author: hungd """ def solveSudoku(board): # Write your code here. board_truth = [list(x) for x in board] i = 0 while i < 9: j = 0 while j < 9: if board_truth[i][j] != 0: j += 1 ...
efd35c7698960a4088f61397ee23fde3defb21ee
hungdoan888/algo_expert
/suffixTrieConstruction.py
1,209
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 24 13:23:31 2020 @author: hungd """ # Do not edit the class below except for the # populateSuffixTrieFrom and contains methods. # Feel free to add new properties and methods # to the class. class SuffixTrie: def __init__(self, string): self.root = {} ...
ae60f245873fbd99e43f2abfa82f4c5dc1075066
hungdoan888/algo_expert
/matchingCalendars.py
3,253
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 7 20:43:15 2021 @author: hungd """ def calendarMatching(calendar1, dailyBounds1, calendar2, dailyBounds2, meetingDuration): # Write your code here. calendar1 = putDailyBoundsinCalendar(dailyBounds1, calendar1) calendar2 = putDailyBoundsinCalendar(dailyBounds...
cdbb3a25cc828a42d79c7a60eadda96c4523024a
hungdoan888/algo_expert
/continuousMedian.py
5,256
3.75
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 24 19:23:04 2020 @author: hungd """ #%% Max Heap Class class MaxHeap: def __init__(self, array): # Do not edit the line below. self.heap = array self.heap = self.buildHeap() def buildHeap(self): array = self.heap # Write ...
40b5bb8e27346b778a7c396ca92c28d16e3d57ef
hungdoan888/algo_expert
/cycleInGraph.py
870
3.9375
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 21 20:41:01 2021 @author: hungd """ def cycleInGraph(edges): # Write your code here. visited = {} for i in range(len(edges)): containsCycle = cycleInGraphHelper(i, edges, visited, {}) if containsCycle: return True return F...
f07b0f5817a383e1ce6166b0c315579983e7d120
patrick330602/stochastic-mab
/prog1_random_selection.py
3,010
4.09375
4
# This is the first program to simulate the multi-arm bandit # Let say we only use RANDOM POLICY: each round, just randomly pick an arm # Each arm has outcome 0 or 1, with probability 1 being the winning probability (Bernoulli distribution) # Created by John C.S. Lui Date: April 10, 2020 import numpy as np from ...
370fc45b3df47accb59bb98ae9b11a56f9bd5511
willxie/action-conditional-video-prediction-with-motion-equivariance-regularizer
/scripts/format_image_file_names.py
773
3.65625
4
import sys import os def is_int(s): try: int(s) return True except ValueError: return False def main(): """ Put enough prepending 0 padding according to the README """ if len(sys.argv) != 2: print("Usage: target_dir") exit() root_dir = os.getcwd() targe...
6ce809c0589f2e3993d4b3c5d495805d0400545e
SurajKB11/Python_Tkinter_Module_1
/new1.py
579
3.578125
4
from Tkinter import * from PIL import ImageTk,Image root=Tk() root.title("Hello World") root.iconbitmap("@/home/suraj/Desktop/INTERNSHIP/index.xbm") def open(): global image top=Toplevel() image=ImageTk.PhotoImage(Image.open("/home/suraj/Desktop/INTERNSHIP/index.jpeg")) l=Label(top,image=image) l....
ed32d42d353918892d9fcecc947baec861be76d7
phani111/Pythonex1
/inheritance.py
647
3.890625
4
class Parent(): def __init__(self,last_name,eye_color): print("parent construcot called") self.last_name = last_name self.eye_color = eye_color def show_info(self): print("Last Name - "+self.last_name) print("Eye Color - "+self.eye_color) class Child(Parent): def ...
08e800c3cdcbfaa6f37a0aa98863a39d8260242c
AsiakN/flexi-Learn
/sets.py
1,880
4.34375
4
# A set is an unordered collection with no duplicates # Basic use of sets include membership testing and eliminating duplicates in lists # Sets can also implement mathematical operations like union, intersection etc # You can create a set using set() or curly braces. You can only create an empty set using the set(...
7db7e72cd3e60a357f3acbffea2f833fd3c8dc2a
Fasermaler/Quick-Q
/vision/price_calculator.py
2,413
3.71875
4
''' This class calculates the total price of the drinks Author: Fasermaler March 2019 ''' class price_calculator: # initialize with the price list def __init__(self, price_list): self.set_price_list(price_list) self.drinks_list = [] self.total_price = 0.0 self.old_ids = None # subroutine to set the pri...
fa2d68d2cf5d4602e62a783ece922fad17e2df04
parulsethi86/project-test
/test2.py
197
3.890625
4
import sys as s x = int(s.argv[1]) y = int(s.argv[2]) z = int(s.argv[3]) if x>y: if x>z: print("x is largest") elif y>z: print("y is largest") else: print("z is largest")
ec1ae83ac468971c4984f71912cb9d4404b846cb
ChrisLeeSlacker/Gauss
/Without Timer.py
867
3.96875
4
""" Gauss: 50 pairs of numbers that added up to 100: 1 + 99, 2 + 98, 3 + 97, and so on, until 49 + 51. Since 50 × 100 is 5,000, when you add that middle 50, the sum of all the numbers from 0 to 100 is 5,050. """ while True: total = 0 try: num = int(input('Type in the number you want to add up to: ')) ...
a23f46def2ea89c2a9eaf5b73a02341033cadcce
safakeskin/ITU-UndergraduateCourses
/AI-BLG435E/Homeworks/hw1/Classes/PrioQueue.py
792
3.796875
4
from Classes import Queue class PrioQueue(Queue.Queue): def __init__( self, prio_queue=[], heuristic=None ): Queue.Queue.__init__(self, prio_queue) if heuristic is None: self.sorter = None else: self.sorter = heuristic def enqueue(self, elem): ...
38139c531a162b657b27d7ca21721cbe265663b7
Barleyfield/Language_Practice
/Python/Others/Pr181210/Code09_12(asterisk_single).py
427
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 11 00:06:35 2018 @author: Isaac *para 매개변수의 개수를 지정하지 않고 전달 """ def para_func(*para) : result = 0 for num in para : result += num return result hap = 0 hap = para_func(10,20) print("매개변수 10, 20 합 : %d" % hap) hap = para_func(10,20,30,40,50,...
86f6e5557848284320743778855e04492df6e5d1
Barleyfield/Language_Practice
/Python/Others/Pr181210/Code08_03(Parentheses).py
323
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 10 21:23:10 2018 @author: Isaac Parentheses 문자열 앞뒤로 괄호 붙이기 """ ss = input("입력 : ") print("출력 : ", end='') if (ss.startswith('(') == False) : print("(", end="") print(ss, end="") if (ss.endswith(')') == False) : print(")", end="")
328d2837ac6d8df632e83f83bdbe70096a1bfa12
Barleyfield/Language_Practice
/Python/Others/Pr180920/Code05_10.py
238
3.71875
4
import random numbers = [] for num in range(0,10) : numbers.append(random.randrange(0,10)) print("생성된 리스트 : ", numbers) for i in range(0,10) : if i not in numbers : print(i,"는 리스트에 없어요.")
8a2ef0964755bab3aa0728c14bf8441fbd0b9971
Barleyfield/Language_Practice
/Python/Others/Pr181121/Code09_13(lotto).py
579
3.703125
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 21 20:01:05 2018 @author: Isaac Lotto """ import random def getNumber() : return random.randrange(1,46) # 전역 변수 선언 부분 lotto = [] num = 0 if __name__ == "__main__" : print("로또 추첨 시작~\n") while(True) : num = getNumber() if (lotto.count...
31d0bfabe282edfeb9837de43863c3930877e298
Barleyfield/Language_Practice
/Python/Others/Pr181021/Code07_05.py
780
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 21 01:35:07 2018 @author: Isaac """ myList = [30,10,20] print("현재 리스트 : %s" % myList) myList.append(40) print("append(40) 후의 리스트 : %s" % myList) print("pop()으로 추출한 값 : %s " % myList.pop()) print("pop() 후의 리스트 : %s" % myList) myList.sort() print("sort() 후의 리스트 : %s" % ...
37c1747fe02916114e8c544739b816f9de7b00a1
Barleyfield/Language_Practice
/Python/Others/Pr181121/Code09_Lambda_map.py
714
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 21 20:23:14 2018 @author: Isaac Lambda와 map을 알아보자 """ myList = [1,2,3,4,5] add10 = lambda num : num + 10 myList = list(map(add10, myList)) print(map(add10,myList)) # map 함수를 직접적으로 출력하면 덧셈은 수행되지만 그 결과가 저장된 장소를 출력. # 예 : <map object...
b57a35c5d3b1a40c9b79cbbec7c7fa8045e76dc6
Barleyfield/Language_Practice
/Python/Others/etc/a2.py
95
3.578125
4
a=int(input("첫 번째 값? ")) b=int(input("두 번째 값? ")) c = int(a) + int(b) print(c)
fe14c4912950ed8ca6bbb77eabc57ce776a1a095
Barleyfield/Language_Practice
/Python/Others/Pr181121/HW09_Substring.py
1,089
4.15625
4
# -*- coding: utf-8 -*- """ 142694 윤이삭 Substring 함수 만들기 <실행예> Enter the first string: asdf Enter the second string: vfrtgasdfnhy asdf is a substring of vfrtgasdfnhy Enter the first string: 깊은바다 Enter the second string: 파란하늘은 깊은바다와 같다 깊은바다 is a substring of 파란하늘은 깊은바다와 같다 """ def Substring(subst,st) : if(st.find...
35659b0510b851aecb0bdfa04419244b7711ca03
Barleyfield/Language_Practice
/Python/Others/Pr181211/Count_to_1_Recursive.py
290
3.96875
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 11 01:06:21 2018 @author: Isaac Count to 1 - Recursive 1까지 세는 재귀함수 """ def count(num) : if (num >= 1) : print(num, end=' ') count(num - 1) else : print() return count(10) count(20)
797022e9f7bb3655f643fbbd9cbb8266100c1fe8
KaranPhadnisNaik/leetcode
/0009.PalindromeNumber.py
870
3.625
4
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ # no palindrome if negative # no palindrome if more than 32 bit int if x >= 2**31-1 or x<0: return False # number wont have leading zeros so cant end in ze...
58c9c0e25a17fbbcfa00813c4824e33373daf78b
KaranPhadnisNaik/leetcode
/0101.SymetricTree.py
849
3.984375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ #empty ...
a70af6521851155c91bf0bddf720cc3fad1d1814
jongman/theyearlyprophet
/code/sieve.py
189
3.890625
4
#!/usr/bin/python def sieve(n=2): yield n for next in sieve(n+1): if next % n > 0: yield next for _, prime in zip(range(100), sieve()): print prime, print
1b2fac0ed9821ebbea90e8f3492fec2cf057a9c8
jgibbons94/cse251-course
/week14/assignment/assignment.py
15,164
3.8125
4
""" Course: CSE 251 Lesson Week: 14 File: assignment.py Author: Jesse Gibbons Purpose: Assignment 13 - Family Search Instructions: Depth First Search https://www.youtube.com/watch?v=9RHO6jU--GU Breadth First Search https://www.youtube.com/watch?v=86g8jAQug04 Describe how to sped up part 1 Organize families with l...
330e62b9b6ff037ff06d0e9a1dc6aa3a930095f0
Alfred-Mountfield/CodingChallenges
/scripts/buy_and_sell_stocks.py
881
4.15625
4
""" Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. """ def ma...
076395d0095a59681c423b8cdde74a077c237c73
lkloh/unittest_mocking_example
/decorators/decorator_and_function_have_args.py
303
3.578125
4
def decorator(lower, upper): def outer_wrapper(func): def inner_wrapper(func_arg): print('before') val = func(func_arg) assert lower <= val assert val <= upper print('after') return inner_wrapper return outer_wrapper @decorator(1, 100) def func(arg): return arg * 7 func(8)
fe226864772bca16c89cd1cbc61c5ac8de8ace0d
sansrit/Python_DataScience-AI
/Python_for_dataScience&AI/5.Numpy_2d.py
1,055
3.578125
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 8 19:31:58 2020 @author: Sansrit """ import numpy as np import matplotlib.pyplot as plt a = [[11, 12, 13], [21, 22, 23], [31, 32, 33]] #converting the list into numpy array A = np.array(a) print(A) print(A.ndim) #shows dimension print(A.shape...
30c27943793dba87e387e4b28b80ec84bd39c436
jshk1205/pythonPractice
/3058.py
252
3.5625
4
for _ in range(0, int(input())): num_list = list(map(int, input().split())) even_list = [] for i in range(0, len(num_list)): if num_list[i] % 2 ==0: even_list.append(num_list[i]) print(sum(even_list), min(even_list))
31e62b29dfd8817625758e5dc23696a681c7be11
jshk1205/pythonPractice
/2751.py
124
3.65625
4
n = int(input()) num=[] for i in range(0, n): lis = int(input()) num.append(lis) for j in sorted(num): print(j)
b740b3d5aa623c3f4ef7bea2d8fbc31f81f70661
jshk1205/pythonPractice
/4458.py
248
3.9375
4
for _ in range(0, int(input())): text = list(str(input())) first = text.pop(0) if first.isupper() == False: first=first.upper() print(first ,end='') for i in range(0, len(text)): print(text[i],end='') print()
f19c4d80aba45cc4d3f4234b775a793bb7dd31b2
jshk1205/pythonPractice
/5063.py
255
3.625
4
n = int(input()) for i in range(0, n): r, e, c = list(map(int, input().split())) price = e - c if r < price: print('advertise') elif r == price: print('does not matter') elif r > price: print('do not advertise')
677ede23da8af655dab170eb2a9e436ba8cf39c8
jshk1205/pythonPractice
/2747.py
122
3.828125
4
n = int(input()) num1, num2 = 0, 1 for i in range(0,n): next = num1 + num2 num1 = num2 num2 = next print(num1)
d894aee10b45799712ec60aaaa27b765eb87cf52
jshk1205/pythonPractice
/2693.py
131
3.609375
4
t = int(input()) for _ in range(0, t): numA_list = list(map(int,input().split())) numA_list.sort() print(numA_list[-3])
330485bc5d73e332debe14d8eef82040810f48b3
beckitrue/python-kali
/cameras.py
3,549
3.75
4
# We want to map the camera MAC to IP using data collected from Wireshark # Wireshark filter is: ip.dst == 255.255.255.255 and udp.port == 8848 # Port 8848 UDP is used by MESSOA IP cameras as a heartbeat. Every few # seconds they send a small comma separated string: # $MessoaIPCamera,ipaddress,subnetmask,macaddress...
a82299e881d28c5b3672509104f7e1398288876c
KatsuhiroMorishita/machine_leaning_samples
/keras_Image_classification/fine_tuning/image_preprocessing.py
25,692
3.5
4
# purpose: 画像の前処理用モジュール # main()では、画像の読み込みと保存を行います。 # author: Katsuhiro MORISHITA 森下功啓 # created: 2018-08-20 # lisence: MIT. If you use this program in your study, you should write shaji in your paper. from matplotlib import pylab as plt from PIL import Image from skimage.transform import rotate # scipyのrotateは推奨されてい...
491df162a8c8cf2c69dfcee689fa4c9da7f642fb
kasthuri28/Python
/python.py
130
3.984375
4
n=int(input()) if(n>0) : print("The number is +ve") elif(n==0) : print("The number is 0") else : print("The number is -ve")
42271e653dc0e194900989799e3279979fd20a90
andramarkov/StockScrape
/main.py
5,378
3.640625
4
# getData function returns stock symbol, current price, and and current date in a list. from scrape import getData # scr function scrapes the database for information about purchased stocks from scrape import scr # Current version gets declared as a global var up here version = 1.0 # This will act as the main file tha...
ab869dd38e2a573cbbd30bbc74732d7258c6a86b
keith-fischer/gurucv
/face1/face_detect.py
748
3.71875
4
# import the necessary packages import cv2 # load our image and convert it to grayscale image = cv2.imread("orientation_example.jpg") gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # load the face detector and detect faces in the image detector = cv2.CascadeClassifier("haarcascade_frontalface_default.xml") rects = de...
ea76a11674e184f49ced584222a74685d2c1cda5
mariamiah/Event-Life
/reception/reception.py
913
4.0625
4
# Read ordinary file and append names to a list ordinary = open("ordinary.txt", "r") ordinary_list = [line.rstrip() for line in ordinary.readlines()] # Read VIP file and append names to the vip_list vip = open("vip.txt", "r") vip_list = [line.rstrip() for line in vip.readlines()] # Request user to enter their name s...
2df6ff13c5c936dc180433eb12825b5b9115e5e6
nullbit01/Cracking-Python-Bootcamp
/coding projects/game_of_conditions.py
9,477
4.1875
4
########################################################### # A Game of Conditions: Text Based Fantasy Game in Python # -------------------------------------------------------- # This is the text based adventure game. # It works by asking the gender of the user, # asking them additional questions, and then modifying th...
d197d685ffe9965de5d52f0e98499c1df83b28dd
nullbit01/Cracking-Python-Bootcamp
/01_numbers_in_python.py
3,638
4.375
4
########################################### # Code from python # Features python variables, numbers, and # builtin data types # # # By Doug Purcell # http://www.purcellconsult.com # ############################################ ############################### # creating variables in python ############################...
a0358832b918a12cb565c33d2aec314da3755c37
eaphilli/Geocoding_Suite
/Business_Names_to_Lat_Lng/BusinessNamestoLatLng.py
2,239
3.609375
4
"""Python script that converts Business names to lat,lng coordinates using google places API @author Shyam Thiagarajan @requires output.txt is empty empty last line in companies.txt @inputs Business names from companies.txt @outputs lat and lng to output.txt API KEY CHOICES: AIzaSyCFfJiEeUo_nX...
5b023960a27d8b0a1247a06fc3b54cb5935e9056
aasalaza/Project_1
/ballistic.py
3,783
4.28125
4
''' The first part of the program sets the initial parameters for an object thrown at some angle above the horizont, including the air resistance dragging effect. Then, it solves the differential equation m(dV/dT)=mg-cV, describing the motion ( the numerical solution). The second part computes the analytical solution a...
d55b17b8c7c508e486c24d9822f23672b2a7afae
Sagar-16/Python-programs
/0-1 knapsack.py
673
3.796875
4
#python program for 0-1 knapsack using recursion weights=[1,3,6,7,10] # weights array for items values=[2,4,7,9,12] # values array for items n=5 #number of items w=10 #bags weight def knapsack(weights,values,w,n): if n==0 or w ==0: #base case return 0 if weights[n-1]<=w:...
250d6f88944cafcbbe870b2d05813c7bf6c68d0e
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Alphabets/Lower_Case_alphabets/c.py
909
4.09375
4
def for_c(): """ Lower case Alphabet letter 'c' pattern using Python for loop""" for row in range(4): for col in range(4): if col==0 and row%3!=0 or col>0 and row%3==0: print('*', end = ' ') else: ...
dc2da5e06755ee1ef83d933b77b4ed1ffa1c6d71
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Symbols/Equilateral_Triangle.py
479
4.125
4
def for_equilateral_triangle(): """Shape of 'Equilateral Triangle' using Python for loop""" for row in range(12): if row%2!=0: print(' '*(12-row), '* '*row) def while_equilateral_triangle(): """Shape of 'Equilateral Triangle' using Python while l...
97179eb2d9dcaf051c37211d40937166869a0c83
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Alphabets/Upper_Case_alphabets/D.py
970
4.21875
4
# using for loop def for_D(): """ Upper case Alphabet letter 'D' pattern using Python for loop""" for row in range(6): for col in range(5): if col==0 or row in (0,5) and col<4 or col==4 and row>0 and row<5: print('*', end ...
ae17927ae7d2911b505dca233df10577c39efd6e
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Alphabets/Lower_Case_alphabets/z.py
869
4.125
4
def for_z(): """ Lower case Alphabet letter 'z' pattern using Python for loop""" for row in range(4): for col in range(4): if row==0 or row==3 or row+col==3: print('*', end = ' ') else: ...
e77e9c67faf6319143afd737cee920a98496cce0
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Symbols/Reverse_triangle.py
444
4.375
4
def for_reverse_triange(): """Shape of 'Reverse Triangle' using Python for loop """ for row in range(6,0,-1): print(' '*(6-row), '* '*row) def while_reverse_triange(): """Shape of 'Reverse Triangle' using Python while loop """ row = 6 ...
35e9d5de6afa12398a59af95f454097f3231d4ad
SaikumarS2611/Python-3.9.0
/Packages/Patterns_Packages/Symbols/Rectangle.py
926
4.34375
4
def for_rectangle(): """Shape of 'Rectangle' using Python for loop """ for row in range(6): for col in range(8): if row==0 or col==0 or row==5 or col==7: print('*', end = ' ') else: ...
c465caaccdd28b99ba3cada1325ee3899e4e7542
Konstantce/ToySTARK
/relations/ARP.py
3,332
3.71875
4
from algebra.polynomials import * from utils.utils import * import itertools class ARP: def __init__(self, instance, size, witness = None): """Instance format: The instance x is a tuple (Fq, d, C) where: * Fq is a finite field of size q. * d is an integer representing a bound on th...
bee56f7245f12089b0b9758c39688decddf364cc
jmcculloch796/robotplanner
/ExampleProblems/Large Grid/main.py
3,281
3.890625
4
""" F29AI - Artificial Intelligence and Intelligent Agents Coursework - Part I - A* Search Big Grid with 3 robots. An example program to show our '10x10 grid with 3 robots' example. Ronan Smith & Jamie McCulloch Last edited: 10.11.2016 """ from implementation import * from nodes import * from...
b964aa87cc49f22ba948c6e270ebc7736e6329c6
conorbradley7/MPT
/MPT 3/Combinations.py
231
3.703125
4
''' combinations n = number of numbers in set k = number of numbers per combination n/k = number of combinations find the number of outputs given a n value and a k value where k <= n ''' def combos():
214cc05b6e51051522abc9a9be28cf21130d47c0
conorbradley7/MPT
/MPT 1 & 2/Labs/Lab04/investMoney.py
975
4
4
#import modules import math def investMoney(): ''' Pyton program to invest money over some years. Inputs: amount, nrYears Output: amount, profit and cummulated amount for each year How to do it: repeat for each year calculate profit and cummulated amount print them ...
a484f8294c03e56e67adbe8480b530f3b6dcc6a4
conorbradley7/MPT
/MPT 3/Self Descriptive.py
673
3.65625
4
''' input: numbers EG: 1, 2, 3 output: selfDescribe number: 11 12 13 -> 1 one 1 two and 1 three ''' def group(lst): acc = [] for c in lst: if acc != [] and c == acc[-1][0]: acc[-1] += c else: acc.append(c) return acc word = input('...
a8eb547555c78fef3925cb7b43b9f73f541a745f
conorbradley7/MPT
/Other Programs/Calculator.py
3,235
4.0625
4
#Pythagoras================================================================================================================================================================================= import math def pythagorasHyp(): adj = int(input('Adjacent:')) opp = int(input('Opposite')) hyp = math.sqrt(adj*...
e6088db9c546542b5bba0f26e67a222ed11e5878
3070owner/pingpong
/test.py
4,437
3.5
4
#범위설정 잘못함 import pygame import sys import random import time COLOR = {"BLACK":(0,0,0),"WHITE":(255,255,255),"RED":(255,0,0),"GREEN":(0,255,0)} SCREEN_WIDTH = 800 SCREEN_HEIGHT = 800 #How 2 use: COLOR["BLACK"] class Ball: def __init__(self, x_speed_ball, y_speed_ball, pos_ball = [400,400]): self....
d0a6cb2b084d953f976a981259ebcc06a801ee09
s4nktum/infa_2021
/lec_02/multiangle.py
346
3.6875
4
import turtle as trt import numpy as np trt.shape('turtle') n = 3 x = 50 def angle(n, x): a = 360 / n for i in range(1,n+1): trt.left(a) trt.forward(x) trt.penup() trt.right(a/2) trt.forward(200**0.5) trt.left(a/2 + 5) trt.pendown() for i in range(1,11): angle(n,x) ...
48ed4732c564bf5f3d88aa263f727615cc8107b8
claraqqqq/l_e_e_t
/78_subsets.py
662
3.75
4
# Subsets # Given a set of distinct integers, S, return all possible subsets. # Note: # Elements in a subset must be in non-descending order. # The solution set must not contain duplicate subsets. # For example, # If S = [1,2,3], a solution is: # [ # [3], # [1], # [2], # [1,2,3], # [1,3], # [2,3], # [1,2]...
3646422ea8a820273f0a09a10890d06da6bff19b
claraqqqq/l_e_e_t
/11_container_with_most_water.py
766
3.859375
4
# Container With Most Water # 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 con...
043941cdd77c0fbef0e2aed141fd19339ebbe3ef
claraqqqq/l_e_e_t
/36_valid_sudoku.py
1,569
3.9375
4
# Valid Sudoku # Determine if a Sudoku is valid, according to: Sudoku Puzzles # - The Rules. # The Sudoku board could be partially filled, where empty # cells are filled with the character '.'. # A partially filled sudoku which is valid. # Note: # A valid Sudoku board (partially filled) is not necessarily # solvabl...
b7cf0ad56f664cab16423ec3baeaea62603d29bb
claraqqqq/l_e_e_t
/102_binary_tree_level_order_traversal.py
1,178
4.21875
4
# Binary Tree Level Order Traversal # Given a binary tree, return the level order traversal of its # nodes' values. (ie, from left to right, level by level). # For example: # Given binary tree {3,9,20,#,#,15,7}, # 3 # / \ # 9 20 # / \ # 15 7 # return its level order traversal as: # [ # [3], # [...
400c8ae876e334744176a1f747912b777083d904
claraqqqq/l_e_e_t
/135_candy.py
869
3.578125
4
# Candy # There are N children standing in a line. # Each child is assigned a rating value. # You are giving candies to these children subjected to the following requirements: # # Each child must have at least one candy. # Children with a higher rating get more candies than their neighbors. # # What is the m...
cdd09dafb35bc0077d004e332ab48436810224a7
claraqqqq/l_e_e_t
/150_evaluate_reverse_polish_notation.py
1,079
4.28125
4
# Evaluate Reverse Polish Notation # Evaluate the value of an arithmetic expression in Reverse Polish Notation. # Valid operators are +, -, *, /. Each operand may be an integer or another expression. # Some examples: # # ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 # ["4", "13", "5", "/", "+"] -> (4 + (13 / 5))...
12afa69cd0323b3daca516c39e732f713a8cd9fc
claraqqqq/l_e_e_t
/59_spiral_matrix_II.py
1,178
3.984375
4
# Spiral Matrix II # Given an integer n, generate a square matrix filled with # elements from 1 to n2 in spiral order. # For example, # Given n = 3, # You should return the following matrix: # [ # [ 1, 2, 3 ], # [ 8, 9, 4 ], # [ 7, 6, 5 ] # ] class Solution: # @return a list of lists of integer def genera...
18ff611887dc3fa77e4c812014158a3859427171
OranGeNaL/labs
/8_semestr/rezak/Lab5/progs/BWT.py
533
3.75
4
def BWT(text): assert "|" not in text text = text + "|" table = [text[i:] + text[:i] for i in range(len(text))] # print("Перебор") # for i in table: # print(i) # print("Отсортированные") table = sorted(table) # for i in table: # print(i) last_column = [row[-...
8a8b0c0a06c2c307defdbea728683c64b5802ca2
KailashGanesh/Sudoku-solver
/sudoku-GUI.py
7,164
3.6875
4
import pygame, sys from sudokuSolver import * import copy def isBoardSloved(board): ''' parm: (sudoku board array) return: True if no 0 present in board, False if 0 present ''' for i in range(len(board)): if 0 in board[i]: return False elif i == 8: return Tru...
c63823a2c9c773b6964cdd20cae2862826cc5f40
mamengjuan/beibei
/zuoye/timo.py
975
3.921875
4
""" 一个回合制游戏,有两个英雄,分别以两个类进行定义。分别是timo和police。每个英雄都有 hp 属性和 power属性,hp 代表血量,power 代表攻击力 每个英雄都有一个 fight 方法: my_hp = hp - enemy_power enemy_final_hp = enemy_hp - my_power 两个 hp 进行对比,血量剩余多的人获胜 每个英雄都一个speak_lines方法 调用speak_lines方法,不同的角色会打印(讲出)不同的台词 timo : 提莫队长正在待命 police: 见识一下法律的子弹 """ from zuoye.hero import Hero class T...
f248af63a79a8f960c7139d6f301b1294bf3f99e
StevenHowlett/pracs
/prac3/broken_score.py
450
3.90625
4
""" CP1404/CP5632 - Practical Broken program to determine score status """ def main(): score = float(input("Enter score: ")) if score < 0 or score > 100: print("Invalid score") else: text = text_for_scores(score) print (text) def text_for_scores(score): if score >= 90: ...
045ad42fadd7542f7932345050395615896b6543
StevenHowlett/pracs
/prac5/hex_colours.py
468
4.375
4
COLOUR_TO_HEX = {'aliceblue': '#fof8ff', 'antiquewhite': '#faebd7', 'aquamarine': '#7fffd4', 'azure': '#f0ffff', 'beige': '#f5f5dc', 'bisque': 'ffe4c4', 'black': '#000000', 'blue': '#0000ff', 'blueviolet': '8a2be2'} colour = input("Enter colour: ").lower() while colour != "": if colour in COLOUR_T...
b6a02861984e2eb65b763b35b0ee43aa4fffbada
felixtomlinson/Udacity
/Log Analysis Project/Logs_Analysis_Project.py
3,435
3.890625
4
#!/usr/bin/env python import psycopg2 DBNAME = "news" def connect(database_name): """Connect to the PostgreSQL database. Returns a database connection.""" try: db = psycopg2.connect("dbname={}".format(database_name)) c = db.cursor() return db, c except psycopg2.Error as e: ...
93bd0eeac2c81ab4af6c1e336eb0ac0a46825b7e
petersheck/SimplePython
/Variables.py
634
4.03125
4
fruit = 'apple' fruit = "apple" frint = 'orange' sentence = 'She said, "This is a great tasting apple!"' sentence = "That's a great tasting apple!" a = 'apple'[0] e = 'apple'[4] fruit = "apple" first_character = fruit[0] fruit_len = len(fruit) print(fruit_len) print(len(fruit)) fruit = "Apple" print(fruit.lower()) prin...