blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
71e0109b6823aa22bbf7f53710b0030ee62d9855 | HyeJoonKim/Algorithm | /Greedy/boj_2839_설탕배달x.py | 220 | 3.609375 | 4 | N = int(input())
cnt = 0
while (N >= 3):
if (N % 5 == 0):
cnt = cnt + (N // 5)
N = 0
break
else:
cnt += 1
N = N - 3
if (N==0):
print(cnt)
else:
print(-1)
|
db3a601528687ad58c191144ed29d056a9a7e0ae | HyeJoonKim/Algorithm | /재귀/2020KAKAO_BLIND_RECRUITMENT_괄호변환x.py | 933 | 3.8125 | 4 | def check(string):
left = 0 # (
right = 0 # )
for i in string:
if left < right:
return 0
if i == '(':
left += 1
else:
right += 1
return 1
def UV(string): # u,v 리턴
left = 0
right = 0
u = ''
for i in string:
if... |
9b3c3c42c26aaf990a97c327be99dab6f95fa90c | AnastasiaSig/Task_6 | /task_6.3.py | 5,657 | 3.6875 | 4 | class Student:
def __init__(self, name, surname, gender='male'):
self.name = name
self.surname = surname
self.gender = gender
self.finished_courses = []
self.courses_in_progress = []
self.grades = {}
self.mean = 0
def add_courses(self, course_name):
... |
cc0a1ead1ffefea7d0c6360e6017e3de455958f1 | Frontman01/pihat | /hat_random_pixel.py | 678 | 3.71875 | 4 | #! /usr/bin/env python
# displays one letter at a time with random colors
from sense_hat import SenseHat
import time
import random
sense = SenseHat()
#assign a random integer between 0 and 255 to a variable named r
r = random.randint (0,255)
print("The random Red number is"), r, ("this time")
g = random.randint (0,255... |
cc157edc908e4cb99ada1f2f4b880fa939d635cb | alojea/PythonDataStructures | /Tuples.py | 1,105 | 4.5 | 4 | #!/usr/bin/python
import isCharacterInsideTuple
import convertTupleIntoList
import addValueInsideTuple
alphabetTuple = ('a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')
stringTuple = ""
for valueTuple in alphabetTuple:
stringTuple = ... |
c82373ca17d775c2f680f2d50ae9d5b161315618 | RustyNails8/Letters2Words | /MakeWords4mLists.py | 2,049 | 3.859375 | 4 | #! <python3.10>
# Sumit Das
from textblob import Word
import sys
try:
# Useage of script
# python MakeWords4mLists.py boko 4
# python MakeWords4mLists <jumbled word/letters> <number of letters>
# Stoarge original jumbled word in myWORD
myWORD=sys.argv[1]
# Break myWORD into a list of letters
# r n c a t o o
... |
1140d2d3a3f929378933d10e73dfcfc0db0d36e0 | aussio/Journey-to-Dev | /fizzbuzz.py | 920 | 3.953125 | 4 |
def test_fizz_buzz():
print('If this test is successful, it will return True all three times.')
print fizz_buzz(15) == "1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n11\nfizz\n13\n14\nfizzbuzz\n"
print fizz_buzz(18) == "1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n11\nfizz\n13\n14\nfizzbuzz\n16\n17\nfizz\n"... |
1101a81949a2a7270ad8bfc884f33789184b4878 | manne05/Konzepte | /Dictonary/dictonary01.py | 693 | 4.09375 | 4 | # Mit Mengen arbeiten - ein set speichert Variablen gleichen Datentyps
# Deklaration mit geschweiften Klammern {}
# Beispiel 1:
numSet = {1, 2, 3, 4, 5}
print('numSet = ', numSet)
# Initialisieren einer leeren Menge
emptySet = set()
print('leere Menge: ', emptySet)
#Hinzufügen von Werten zu einer Menge
emptySet.add(1... |
7a1d7af1698554f9103001316ae2220cf2a36308 | Nakiiii/exercise | /Book/Chapter 1/pig_latin_practice.py | 752 | 3.875 | 4 | """translate a word into pig latin """
CONSONANT = ['a','e','i','o','u']
def main():
"""main"""
normal_word = input("Which word would you like to translate?\n")
splitter = normal_word.split(' ')
while True:
if len(splitter) > 1:
normal_word = input("Please enter only one ... |
3dda3b0b83b4e8735e5eb83d4eb2eea90d61eecb | nishantvyas/python | /scrape_meta.py | 2,089 | 3.578125 | 4 | """
Scrape meta information title, description, keywords for a given url
"""
import re
import requests
import urllib.request
from bs4 import BeautifulSoup
class scrape_meta:
"""
Class with methods and attributes to scarape meta information for a given url
"""
def __init__(self, url):
"""
... |
e5ed9fc02cc72c08c406da675159dcb3798bbf11 | nishantvyas/python | /Gender.py | 740 | 4.09375 | 4 | """
Define a class Person and its two child classes: Male and Female.
All classes have a method "getGender" which can print "Male" for Male class and "Female" for Female class.
"""
class person():
"""
Base class
"""
gender = "Unknown"
def getGender(self):
return self.gender
class male(pe... |
c50d0f924ae516d9d6bab320cb1bb71cfc35d7a6 | nishantvyas/python | /unique_sorted.py | 1,603 | 4.15625 | 4 | """
Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
Suppose the following input is supplied to the program:
hello world and practice makes perfect and hello world again
Then, the output should be:
a... |
e7c48982c6a8017df64420b888746e1bf8c1cfab | nishantvyas/python | /mysql_db.py | 1,879 | 3.59375 | 4 | """
Simple Program to test MySQL insert and select
"""
import pymysql.cursors
from configparser import ConfigParser
def read_db_config(filename='config.ini', section='mysql'):
""" Read database configuration file and return a dictionary object
:param filename: name of the configuration file
:param sectio... |
b4a1b6a56741e60eb6307f3b08eff4eacb64f413 | nishantvyas/python | /simple_texteditor.py | 3,649 | 3.9375 | 4 | """
Text Editor - Notepad style application that can open, edit, and save text documents.
"""
from pathlib import Path
import os
def readInLine(fileObj):
"""
:param fileObj:
:return:
"""
file_in_buffer = []
with open(fileObj) as f:
for line in f:
file_in_buffer.append(l... |
85ecb77f4910ff7b77c1da1d529fe61a0d7d594d | fanalyticsports/Brewers | /Blackjack/Blackjack_Random_Card.py | 197 | 3.5 | 4 | ## Random Card Generator
import random
rank = random.choice( (('A','2','3','4','5','6','7','8','9','T','J','Q','K')*4) )
suit = random.choice( ('c','d','h','s') )
card = rank + suit
print(card)
|
955c55efe16b106f0659c26ea94aeeefcf37e179 | IanChen6/python-learning | /untitled1/datetimemodule/acquiretime.py | 498 | 3.75 | 4 | # import time
# a=time.time()
# for i in range(10):
# n=i+1
# time.sleep(1)
# b=time.time()
# l=b-a
# print(l)
from datetime import datetime#导入datetime模块中的datetime类
now=datetime.now()
print(now)
print(type(now))
dt=datetime(2018,2,21,23,30,59)
print(dt)
t=dt.timestamp()
print(t)#timestap是一个浮点数,如果有小数位表示毫秒
t1=12... |
18e80b39656539bf27339879860d1718d47ca0d4 | IanChen6/python-learning | /untitled1/collect_tion/deque1.py | 185 | 3.671875 | 4 | from collections import deque
#deque始终双向列表,适用于队列和栈
q=deque(['1','23',3,'ad'])
q.append('w')
q.appendleft('id')
print(q)
q.popleft()
print(q)
q.pop()
print(q) |
d6825d3eaa9a67d508ec4f016c3cb4af38f9f05b | IanChen6/python-learning | /untitled1/practice/bubleSort.py | 327 | 3.734375 | 4 | def bubble_sort1(l):
print(l)
for i in range(len(l)-1,0,-1):
for j in range(i):
if l[j]>l[j+1]:
l[j],l[j+1]=l[j+1],l[j]
print(l)
list=[23,1234,2,15,24,100,25,4]
bubble_sort1(list)
# L=[23,1234,2,15,24,100,25,4]
# for n in L:
# print(n)
# for x in [5,2,9]:
# p... |
d7eb842aed854de8a990af447b34fd1305d40865 | IanChen6/python-learning | /untitled1/practice/Screen_property.py | 788 | 3.703125 | 4 | class Screen(object):
@property
def width(self):
return self.__width
@property
def height(self):
return self.__height
@width.setter
def width(self,value):
if not isinstance(value,int):
raise ValueError("width must be an integer")
self.__width=value
... |
e4bf99b038abe3e1ba02953ab3c41935fb5b982c | IanChen6/python-learning | /untitled1/practice/OOP.py | 650 | 3.96875 | 4 | class Student(object):#括号内的object表示Student类从Object类中继承(object类是超类)
def __init__(self,name,score):#_init_函数用于初始化对象的属性
self.name = name#self为对象自身的引用,给对象增加name和score属性
self.score = score
def print_score(self):#和普通的函数不同,在类中定义的函数的第一个参数一定是实例对象self本身
print('%s: %s'%(self.name,self.score))
# bar... |
bebcd72b799a2192e56004caf9eb55e4903c9f82 | qh96/leetcode | /solutions/720.longest-word-in-dictionary/longest-word-in-dictionary.py | 374 | 3.671875 | 4 | class Solution:
def longestWord(self, words):
"""
:type words: List[str]
:rtype: str
"""
s = set(words)
ans = []
for i in words:
a = itertools.accumulate(list(i))
if all(j in s for j in a):
ans.append(i)
ans.sort... |
435100bf99fc11be89c3fd1e44330b908af61b76 | qh96/leetcode | /solutions/098.validate-binary-search-tree/validate-binary-search-tree.py | 586 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isValidBST(self, root):
"""
:type root: TreeNode
:rtype: bool
"""
l = []
def preOrder... |
c0fe665fb14e644bb2f435f42a37cbd4500acdf7 | qh96/leetcode | /solutions/143.reorder-list/reorder-list.py | 1,884 | 3.921875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reorderList(self, head):
"""
:type head: ListNode
:rtype: void Do not return anything, modify head in-place instead.
"""
... |
589f077eb0b0080801f5dc3e7b4da8e3a4d1bf35 | applicationsbypaul/Module7 | /fun_with_collections/basic_list.py | 837 | 4.46875 | 4 | """
Program: basic_list.py
Author: Paul Ford
Last date modified: 06/21/2020
Purpose: uses inner functions to be able to
get a list of numbers from a user
"""
def make_list():
"""
creates a list and checks for valid data.
:return: returns a list of 3 integers
"""
a_list = []
for index ... |
726acce695d62e6d438f2abd93b1685daab8f95a | applicationsbypaul/Module7 | /Module8/more_fun_with_collections/dict_membership.py | 502 | 4.15625 | 4 | """
Program: dict_membership.py
Author: Paul Ford
Last date modified: 06/22/2020
Purpose: using dictionaries for the first time
"""
def in_dict(dictionary, data):
"""
accept a set and return a boolean value
stating if the element is in the dictionary
:param dictionary: The given dictionary to search
... |
092b00d36e90e830f501bb2702c9280139fdd23e | applicationsbypaul/Module7 | /Module11/class_definitions/bicycle.py | 966 | 3.703125 | 4 | from Module11.class_definitions.rider import Rider
class Bicycle(Rider):
def __init__(self):
self.ride = 'Human powered, not enclosed, 2 wheels'
self.rider = '1 or 2 if tandem'
def rider(self):
return self.ride
def ride(self):
return self.rider
class Motorcycle(Rider):... |
d38c77a4b3c2b8448226fa481fc79e177048fa65 | applicationsbypaul/Module7 | /Module10/class_definitions/student.py | 2,597 | 4.25 | 4 | from datetime import datetime
class Student:
"""Student class"""
def __init__(self, lname, fname, major, startdate, gpa=''):
"""
constructor to create a student
:param lname: last name
:param fname: first name
:param major: Major of student
:param gpa: students... |
8510a11490351504b7bf1707f5ba14318fae7240 | applicationsbypaul/Module7 | /Module8/more_fun_with_collections/dictionary_update.py | 1,563 | 4.28125 | 4 | """
Program: dictionary_update.py
Author: Paul Ford
Last date modified: 06/22/2020
Purpose: using dictionaries to gather
store and recall info
"""
def get_test_scores():
"""
Gathers test scores for a user and stores them
into a dictionary.
:return: scores_dict a dictionary of scores
"""
... |
92bc5430ef862add59eff1b67665abd2a3e2fd09 | applicationsbypaul/Module7 | /Module8/test/test_assign_average.py | 713 | 3.515625 | 4 | import unittest
from Module8.more_fun_with_collections.assign_average import switch_average
class MyTestCase(unittest.TestCase):
def test_switch_average_A(self):
self.assertEqual(switch_average('A'), 'a')
def test_switch_average_B(self):
self.assertEqual(switch_average('B'), 'b')
def te... |
0e33395aca1884d5dd3ff9e7e672bc4bb950d457 | ugurdonmez/algorithm | /python/heap.py | 1,679 | 3.9375 | 4 | class Heap:
def __init__(self):
self.array = []
self.size = 0
def heapify(self,pos): #create a heap out of given array of elements
l = 2 * pos
r = 2 * pos + 1
largest = pos
if l < self.size and self.array[l] > self.array[largest]:
largest = l
... |
83323a76154b6ca50a563cfd323fc533846a611c | idealisms/adventofcode2018 | /07/part1.py | 1,106 | 3.71875 | 4 | # This took me forever to finish because I didn't realize that
# the lexical sort was across all nodes, not just children of
# current node.
# Letter to array of letters
tree = {}
reverse = {}
for line in open('input').read().split('\n'):
arr = line.split(' ')
children = tree.setdefault(arr[1], [])
children.appe... |
89c4c15f7b925818ff859d8f440b60adb64cc89b | migekun/LabOposiciones | /src/main/java/es/navas/oposiciones/datosEstaticos/matrices/Reto5_sieteymedia.py | 8,367 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 14 15:10:45 2019
@author: Saúl Lázaro
"""
import random
import os
import itertools
from ficheros import FICHEROSOLUCION#variables con los datos de los ficheros
'''Clase Carta'''
class Carta:
palo = ''#Or(oros), Es(espadas),Co(Copas),Ba(bastos)
numer... |
0ccfd30f00a68ee9ff515616f68d386cad02889e | srishtik2310/birthday-wisher | /main.py | 1,513 | 3.75 | 4 | #add birthday details in birthdays.csv
#it has example data. Do fill it with your own details
#to automate the running of the code everyday use https://www.pythonanywhere.com
#add main.py and birthdays.csv in files section and create a new directory with the name letter templates and
# add the three letter text files i... |
bd88ed035bdf5f8354ac78a838e8f8219f6c5722 | TSM-Hackers/speemo | /sentiment_toolkit/embedding.py | 1,733 | 3.5 | 4 | """Functions for word embedding"""
import torchtext
import torch
"""
Load the GLOVE model as in https://nlp.stanford.edu/projects/glove/
The returned GloVe object includes attributes:
stoi : string-to-index returns a dictionary of words to indexes
itos : index-to-string returns an array of words by index
... |
0bb1d6143dcb02b3b431cf26fa2c067c82e0efda | soumendrak/basic_blockchain | /src/server.py | 2,727 | 3.5625 | 4 | """
Blockchain server to keep track of the transactions
Author: Soumendra Kumar Sahoo
Date: 30 sep 2017
"""
from flask import Flask, request
import datetime as dt
import json
import main
import pdb
from block import Block
from config_reader import hostname, port
from internal_rules import proof_of_work
node = Flask(... |
8de7aba17305088c6d97e87379fe5ec40166344c | dongyi1996/penmon | /src/penmon/eto.py | 29,470 | 3.859375 | 4 | """
Penman-Monteith Equation implementation in Python.
Full implementation of Penman-Monteith ETo equation based on UAN-FAO
[Irrigation and Drainage Paper 56](http://www.fao.org/3/X0490E/x0490e00.htm)
Penman-Monteith equation is used to calculate reference crop evapotranspiration (ETo)
for a given location u... |
794527edec92b7116cd371bd2aa32c3b8f3353fa | PikeyG25/Python-class | /Critter.py | 1,512 | 4.09375 | 4 | #Parker Gowans
#1/19
import time
import pickle
class Critter(object):
"""A Virtual Pet"""
def __init__(self, name, hunger, boredom):
print("A new critter has been born")
self.__name = name
self.__hunger = hunger
self.__boredom = boredom
@property
def name(self):
... |
1ea4a6c647008cc1ca139857137291c335914941 | PikeyG25/Python-class | /indexing.py | 242 | 3.796875 | 4 | import random
name = input("Enter your name")
print(name[-4])
length =len(name)
print(length)
index_pos = random.randrange(0,length)
if index_pos<= length:
char = name[index_pos]
print(char)
else:
print("thats out of the range")
|
97d812a9b932e9ae3d7db1726be2089627985347 | PikeyG25/Python-class | /forloops.py | 658 | 4.15625 | 4 | ##word=input("Enter a word")
##print("\nHere's each letter in your word:")
##for letter in word:
## print(letter)
## print(len(word))
##message = input("Enter a message: ")
##new_message = ""
##VOWELS = "aeiouy"
##
##for letter in message:
## if letter.lower() not in VOWELS:
## new_message+=letter
## ... |
72390ec7722bbba6dc2154b6afd6b02a9779152c | NurRahmawatiSubuh/Tugas4 | /reversefile.py | 1,133 | 3.84375 | 4 | class Empty(Exception):
pass
class ArrayStack:
def _init_(self):
self.data = []
def len(self):
return len(self.data)
def is_empty(self):
return len(self.data) == 0
def push(self, e):
self.data.append(e)
def top(self):
if self.is_empty... |
54f82d1235d130ade1f427c369570e7d51174c12 | theisolatedisland/refactor-code-and-career | /bad_naming.py | 208 | 3.671875 | 4 | def bad_name_examples(my_string, increment, value1, term):
for i in range(0, value1):
while value1 >= increment:
my_string += term
value1 -= increment
return my_string
|
5b62414ce6aff1465d51efed53180a7255d6540c | sinhars/Data-Structures-And-Algorithms | /Course1/Week2/7_fibonacci_partial_sum.py | 1,713 | 3.765625 | 4 | # Uses python3
import sys
def fibonacci_partial_sum_naive(m, n):
sum = 0
current = 0
next = 1
for i in range(n + 1):
if i >= m:
sum += current
current, next = next, current + next
return sum % 10
def fibonacci_partial_sum_fast(m, n):
curr_last_digit = 0
next_la... |
2ef1792a1ca55238f3c9ef96b0f4840d028805f8 | Reetishchand/Leetcode-Problems | /00604_DesignCompressedStringIterator_Easy.py | 2,435 | 3.984375 | 4 | '''Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string.
Implement the StringIterator class:
next() Returns the next charac... |
a8aec37db92f7e89af19e681cef885e6d5ceda3c | Reetishchand/Leetcode-Problems | /00236_LowestCommonAncestorofaBinaryTree_Medium.py | 1,703 | 3.953125 | 4 | '''Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself)... |
6700dca221f6a0923ef9b5dbbf1ec56ab69b0671 | Reetishchand/Leetcode-Problems | /00328_OddEvenLinkedList_Medium.py | 1,368 | 4.21875 | 4 | '''Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.
Example 1:
Input: 1->2->3->4->5->N... |
56bb70f89a3b2e9fa203c1ee8d4f6f47ec71daf8 | Reetishchand/Leetcode-Problems | /00922_SortArrayByParityII_Easy.py | 924 | 4.125 | 4 | '''Given an array of integers nums, half of the integers in nums are odd, and the other half are even.
Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even.
Return any answer array that satisfies this condition.
Example 1:
Input: nums = [4,2,5,7]
Output: [4,5,2,7]
Explanat... |
85875486d9866d10d5cfbbf0364cee1719a2696a | Reetishchand/Leetcode-Problems | /00844_BackspaceStringCompare_Easy.py | 1,123 | 4.03125 | 4 | '''Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
Example 1:
Input: S = "ab#c", T = "ad#c"
Output: true
Explanation: Both S and T become "ac".
Example 2:
Input: S = "... |
15752f7526ec8ffeb90f57fdf1196f011c4a3d00 | Reetishchand/Leetcode-Problems | /00252_MeetingRooms_Easy.py | 1,365 | 3.640625 | 4 | '''Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.
Example 1:
Input: intervals = [[0,30],[5,10],[15,20]]
Output: false
Example 2:
Input: intervals = [[7,10],[2,4]]
Output: true
Constraints:
0 <= intervals.length <= 104
intervals[i].lengt... |
5231912489a4f9b6686e4ffab24f4d4bc13f3a46 | Reetishchand/Leetcode-Problems | /00165_CompareVersionNumbers_Medium.py | 2,374 | 4.1875 | 4 | '''Given two version numbers, version1 and version2, compare them.
Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revisions are 0-indexed from left to right, with the leftmost revision ... |
8937e4cc7b216ba837dcbf3a326b2a75fb325cd0 | Reetishchand/Leetcode-Problems | /00690_EmployeeImportance_Easy.py | 1,800 | 4.1875 | 4 | '''You are given a data structure of employee information, which includes the employee's unique id, their importance value and their direct subordinates' id.
For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. They have importance value 15, 10 and 5, respectively. Then emplo... |
f4612c3c05633cb4b936a06adeec15b5b6207e7a | Reetishchand/Leetcode-Problems | /00507_PerfectNumber_Easy.py | 1,124 | 3.671875 | 4 | '''A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly.
Given an integer n, return true if n is a perfect number, otherwise return false.
Example 1:
Input: num = 28
Output: true
Explanat... |
c0a23174b8c9d3021942781c960a21d2ad0699b5 | Reetishchand/Leetcode-Problems | /02402_Searcha2DMatrixII_Medium.py | 1,388 | 4.25 | 4 | '''Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties:
Integers in each row are sorted in ascending from left to right.
Integers in each column are sorted in ascending from top to bottom.
Example 1:
Input: matrix = [[1,4,7,11,15],[2,5,8,12... |
a1deab558fc18c14f21f543653ca6bbbc5324e88 | Reetishchand/Leetcode-Problems | /01133_LargestUniqueNumber_Easy.py | 796 | 3.84375 | 4 | '''Given an array of integers A, return the largest integer that only occurs once.
If no integer occurs once, return -1.
Example 1:
Input: [5,7,3,9,4,9,8,3,1]
Output: 8
Explanation:
The maximum integer in the array is 9 but it is repeated. The number 8 occurs only once, so it's the answer.
Example 2:
Input: [9,9,8,8... |
99202f99cbf5b47e4f294c8e0da826f993ac5d3b | Reetishchand/Leetcode-Problems | /00537_ComplexNumberMultiplication_Medium.py | 1,240 | 4.15625 | 4 | '''Given two strings representing two complex numbers.
You need to return a string representing their multiplication. Note i2 = -1 according to the definition.
Example 1:
Input: "1+1i", "1+1i"
Output: "0+2i"
Explanation: (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i.
Example 2:
In... |
3f48f3661d0b116e24d9caf23001ba8cb3b683b0 | Reetishchand/Leetcode-Problems | /00771_JewelsandStones_Easy.py | 989 | 4.0625 | 4 | '''You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels.
Letters are case sensitive, so "a" is considered a different type of stone... |
816f660892a68fd9054345747495b700f25f36d2 | Reetishchand/Leetcode-Problems | /00053_MaximumSubarray_Easy.py | 1,311 | 3.8125 | 4 | '''Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Example 2:
Input: nums = [1]
Output: 1
Example 3:
Input: nums = [0]
Ou... |
68198c760cdb09b8e882088013830389b0b4d19d | Reetishchand/Leetcode-Problems | /00346_MovingAveragefromDataStream_Easy.py | 1,289 | 4.3125 | 4 | '''Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
Implement the MovingAverage class:
MovingAverage(int size) Initializes the object with the size of the window size.
double next(int val) Returns the moving average of the last size values of the stream.
... |
fc1a32478203cdad96f6fecc7efed0a1aa094c14 | Reetishchand/Leetcode-Problems | /00011_ContainerWithMostWater_Medium.py | 1,146 | 3.90625 | 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 the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
Notic... |
a907e8ce42a9fdbe6635de5f6805ba923a8ebb48 | qianer0216/DPL5211Tri2110 | /Lab 2.5.py | 347 | 3.859375 | 4 | #Student ID: 1201200678
#Student Name: Law Qian Er
LI=0.15
print("Natural Mineral Water Dispenser")
print("---------------------------------")
litres=int(input("Enter amount of litres: "))
print("\nPrice per litres = RM{:.2f}".format(LI))
print("Number of liters = ",litres)
total=litres*LI
print("... |
8817ad61e89edc342fc2efd1d86b4ef2d09a648e | clementearraez/sensors | /Código/dueno.py | 1,520 | 3.75 | 4 | import random
import string
def randomString(stringLength):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
def envio_clave(cloud):
clave = randomString(5)
mensaje_instruccion = "Bienvenido al programa de se... |
203627e74cee01831a7f80da474083e7d34d70ce | rojasarmando/PracticandoPython | /Año Bisiesto/main.py | 846 | 3.625 | 4 | from Validate import *
from Menu import *
#inicializar variable
opc = "z"
menu = Menu()
valida = Validate()
while opc != 'x':
opc = menu.get().lower()
print "\n\n\n\n"
if opc == "a" or opc == "b" or opc == "c":
intervalo = menu.getIntervalo()
for i in xrange(intervalo['inicio'] , intervalo['fin'] +1 )... |
d815c1aa9a0bd4203ce0bfd29ee035f4e33a1b70 | SoumenNath/Python-Search-Sort | /SearchAndSort.py | 11,640 | 3.5625 | 4 | """
Soumen Nath
ICS4U
SoumenNath_SearchAndSort.py
Description: This program will create a character in the game for the user and allow them to use 4 different search algorithms. The program will also display all the characters that are stored in the file.
"""
#import following modules
import os; import random; i... |
de9db5083ca9f25e1db0ed43de6eeb293b227282 | amohapatra123/openCvTutorial | /Chapter2.py | 924 | 3.90625 | 4 | # Learn important functions to be used
import cv2
import numpy as np
img = cv2.imread("Resources/Anshuman.png");
# converting into grayscale
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY);
cv2.imshow("Grayscale Image", imgGray);
cv2.waitKey(0);
# making the image blur
# the kernel number should be always odd number... |
c67665fb81c5a9dd1fb9f7d961fe2f8af6f5b759 | smhblk04/Applied-Cryptography | /HW_04/ecdsa.py | 9,236 | 4.25 | 4 | #-----------------------------------------------------------------------
#Semih Balki
#Python IDE: Visual Studio Code
#Operating system: MacOS
#-----------------------------------------------------------------------
#GLOBAL VARIABLES
# PROPERTIES OF THE ELLIPTIC CURVE
m = 29#Number set
a = -1
b ... |
650c6fd6c5d85407816888dd3e9a008ef3595fd0 | mytrickz/CP3-Nattapong-Ampaiphan | /Lecture54_Nattapong_A.py | 882 | 3.78125 | 4 | def login():
usernameInput = input("Username : ")
passwordInput = input("Password : ")
if usernameInput == "admin" and passwordInput == "1234":
showManu()
else:
return False
def showManu():
print("---iNex Shop---")
print("1. Vat Calculator")
print("2. Price Calculator")
m... |
68f0b89631b89d1098932cd021cf579348d71004 | jaipal24/DataStructures | /Linked List/Detect_Loop_in_LinkedList.py | 1,388 | 4.25 | 4 | # Given a linked list, check if the linked list has loop or not.
#node class
class Node:
def __init__(self, data):
self.data = data
self.next = None
# linked list class
class LinkedList:
def __init__(self):
self.head = None
def push(self, data):
new_node = ... |
9d37c445b24698c71621cadd7f3b2a295b759138 | muralweirdo/Data-Structures-assignments | /a04.py | 3,632 | 3.84375 | 4 | class Node:
def __init__(self,val = None):
self.val = val
self.next = None
class Ring:
def __init__(self):
self.head = None
def __str__(self):
fin = "["
temp = self.head
while temp is not None:
fin = fin + str(temp.val) + ", "
... |
e418c2ecdc2542711e5687cfca88973934b4e4c7 | Gourav123098/all2 | /hangman.py | 1,142 | 4.0625 | 4 | import random
from words import words
import string
def get_vallid_word(wordss):
word = random.choice(wordss)
while '_' in word or ' ' in word:
word = random.choice(wordss)
return word.upper()
def hangman():
word = get_vallid_word(words)
# word = random.choice(words).upper()... |
5473e78e7a3f4d37b730f04e985f4ef182593986 | tschijnmo/evolpac | /evolpac/duel/__init__.py | 2,388 | 3.6875 | 4 | """Duelling between PAC-mites."""
import functools
import itertools
import numpy as np
from .duel import battle
from .tournament import run_tournament as _run_tournament
def run_duel(gene1, gene2):
"""Perform duel between the two given genes.
The score for them will be returned according to the course web... |
4e2c6c7c65b798fddd16eacff0fb71ca2a1310b9 | kaczmarekmichal/nauka_pythona | /new.py | 205 | 3.609375 | 4 | a = "ala ma kota"
a="ala "+"ma " + "kota"
print (len(a))
print (a)
x ="python"
print (x[-4])
print('{0}{1}{2}'.format('a','b','c'))
z="ala"
x="%s ma kota"%z
print(x)
for x in "nic":
print (x)
|
87f6078f3f99bd3c33f617e2b7b33143fed70369 | BonnieBo/Python | /第二章/2.18.py | 412 | 4.125 | 4 | # 计算时间
import time
currentTime = time.time()
print(currentTime)
totalSeconds = int(currentTime)
currentSeconds = totalSeconds % 60
totalMinutes = totalSeconds // 60
currentMinute = totalMinutes % 60
totalHours = totalMinutes // 60
currentHours = totalHours % 24
print("Current time is", currentHours, ":", currentMi... |
c0df9e7e2e54328372dc4eb1d938d14a2d01015e | BonnieBo/Python | /第二章/2.10.py | 171 | 3.859375 | 4 | # 计算跑道长度
v, a = eval(input("Enter speed and acceleration: "))
length = v * v / (a*2)
print("The minimum runway length for this airplane is", length, "meters") |
eaca691cde47e23c41a8ab58ad0137c2281385af | DietrichHorscht/sales_taxes | /sales_taxes.py | 1,863 | 3.59375 | 4 | #!/usr/bin/env python3
import re
import sys
from math import ceil
from typing import Tuple
TAX_FREE = ['book', 'chocolate', 'pill']
LINE_RGX = re.compile(r"^(\d+) (.*) at (\d+\.\d{2})$")
def main(argv):
if len(argv) != 2:
raise AttributeError("no basket file defined!")
with open(argv[1], "r", encodi... |
570c7e0cecea9b436ddde17ddca00b877a05d761 | Psingh12354/GeeksPy | /SymmetricalPalindrome.py | 430 | 4 | 4 | string='khokho'
if string==string[::-1]:
print("Palindrome Yes")
else:
print("Palindrome No")
n = len(string)
flag = 0
if n%2:
mid_val = n//2 +1
else:
mid_val = n//2
start1=0
start2=mid_val
while start1 < mid_val and start2 < n:
if string[start1]==string[start2]:
start1+=1
... |
6b04286aacf020cc1a77a98e11aa7b61483e203a | Psingh12354/GeeksPy | /StringReplace.py | 62 | 3.59375 | 4 | string="HelloWorld"
char='e'
print(string.replace("e",""))
|
a1e717a321ed838ba2ab8efd2fb0bef4836f96e6 | Psingh12354/GeeksPy | /BinaryString.py | 191 | 4.09375 | 4 | n='01'
string = "001021010001010"
for char in string:
if char not in n:
print("Not a Binary String")
break
else:
print("Binary String")
break
|
7e00498100cb3d34dced83a1b57338d0461c11ed | Psingh12354/GeeksPy | /FilterMapreduce.py | 306 | 3.9375 | 4 | #Filter
def is_even(n):
if n%2==0:
return True
nums=[1,2,3,4,5,6,7,8,9]
evens = list(filter(is_even,nums))
print(evens)
#or
evens = list(filter(lambda n: n%2==0,nums))
print(evens)
#Map change every value
print(list(map(lambda x : x+2,evens)))
#Reduce
print(reduce(lambda a,b : a+b,evens))
|
5d8d431167b0b82eee228f40f7e060fea18c8101 | Psingh12354/GeeksPy | /CubeOfNnaturalNumber.py | 101 | 4 | 4 | n=int(input("Enter the number : "))
count=0
for i in range(1,n+1):
count+=i**3
print(count)
|
3e859b1ade44f33218d19158bcf9a2dc46226d55 | Psingh12354/GeeksPy | /StringLenght.py | 99 | 3.765625 | 4 | string = "geeks"
print(len(string))
counter=0
for i in string:
counter+=1
print(counter)
|
4d8a277ce2c33627e45cd0da050ada7ba48d9941 | zhonghe0615/python-mini-program | /Redfin_OA/show_open_food_trucks.py | 3,783 | 3.625 | 4 | #!/usr/bin/env python
# Make sure to install requests before running:
# > pip install requests
# Documentation for the requests library can be found here: http://docs.python-requests.org/en/master/
import requests
import json
from datetime import datetime
import pytz
#Class as container of food truck's Name / Address... |
ac5b0b43111426b1ed2940afd5b4e1827b2bdc71 | 03lafaye/pal-nix | /scripts/pycrypto.py | 2,150 | 3.828125 | 4 | #!/usr/bin/env python
from Crypto.Cipher import AES
import base64
import os
import sys
# the block size for the cipher object; must be 16, 24, or 32 for AES
BLOCK_SIZE = 32
# the character used for padding--with a block cipher such as AES, the value
# you encrypt must be a multiple of BLOCK_SIZE in length. This cha... |
ed0c851ae75b82e26415d25eee6e8c1c287c1391 | YouChowMein/Python | /小甲鱼零基础入门学习Python(全87集)/009了不起的分支和循环3/example1.py | 263 | 3.640625 | 4 | bingo='YCM大帅哥'
answer=input('请输入YCM最想听的一句话:')
while True:
if answer==bingo:
break
answer=input('抱歉,错了,请重新输入(答案正确才能推出游戏):')
print('哎哟不错哦')
print('你可真是小天才')
|
094cfb42aa2edec6e85df295521e8a0e7bfe7e36 | YouChowMein/Python | /小甲鱼零基础入门学习Python(全87集)/008了不起的分支和循环2/method3.py | 220 | 3.796875 | 4 | score=int(input('请输入一个分数:'))
if 100>=score>=90:
print('A')
elif 90>score>=80: #else if
print('B')
elif 80>score>=60:
print('C')
elif 60>score>=0:
print('D')
else:
print('输入错误!')
|
f333fa873040ad8be6da8fd744895d6ba386e0ce | Avangarde2225/Assignment3 | /get_list.py | 245 | 3.640625 | 4 | def main():
scores = []
value = input("Enter a value: ")
while value:
scores.append(value)
value =input("Enter a value: ")
print("Here's the list: ")
print(scores)
if __name__ == "__main__":
main() |
8afc0af95f1183ec4ec87a5ccd93183a82bec9f4 | Avangarde2225/Assignment3 | /blue_screen.py | 767 | 3.953125 | 4 | """
File: bluescreen.py
----------------
Not part of the assignment. This was a lecture demo!
This is a fun algorithm to implement. It is not in the
assignment, but feel free to implement it as an extension.
Put the smaller foreground picture into the background.
Do not include any pixels that are sufficiently blue.
""... |
56d2eae81c0d900e0f26e5e4c5714e0dc1f8139c | shreyashPramod/C97p | /guessingGame.py | 292 | 4.09375 | 4 | game=("Number Guessing Game")
print(game)
Guess=("Guess the Number between 1 to 9")
print(Guess)
number=int(input("enter your number"))
print(number)
if(number>9):
print("You Lose!!")
print("The Number is,9")
elif(number>1):
print("Congratulation You Won!!")
|
6f5e036fbe860c0b5336f87313b9dc60bc7beceb | gilesdrinkall/briw | /source/briwv1.py | 3,191 | 3.640625 | 4 | import os
os.system("clear")
people = []
people_file = open("persistence/people.txt", "r")
people_lines = people_file.readlines()
for peep in people_lines:
people.append(peep.rstrip("\n"))
people_file.close()
drink = []
drink_file = open("persistence/drinks.txt", "r")
drink_lines = drink_file.readlines()
for be... |
d6b81d71a51bccc4b4a95f3ade6b8081437f1309 | Neurotrophin/CPSC230ParlettPelleriti | /InClass/Class16.py | 667 | 3.625 | 4 | # SYNTAX
## define
def funct_name(arg1,arg2):
b = "DO things" + arg1 + arg2
return b + "."
## call
c = "8"
c = int(c)
output = funct_name("hello", "no")
print(output)
#----------------------------------
def boringfn(n):
n += 1
print("In functions", n)
return n
print("hello")
k = 9
k = bor... |
d30a05522c031e1a0c92560961337b26a2ff2642 | Neurotrophin/CPSC230ParlettPelleriti | /InClass/Class26.py | 1,092 | 3.625 | 4 | #Build a Tamagotchi class
class Tamagotchi():
#init
def __init__(self, name, color):
self.name = name
self.color = color
self.love = 50
self.hunger = 10
self.thirst = 10
self.tired = 0
self.sleepy = False
print("Hi! I'm your new Tamagotchi friend! ... |
a351aa1095cf4026c71fa9afbd11b218fe4e379d | Neurotrophin/CPSC230ParlettPelleriti | /InClass/Final_Review.py | 3,524 | 3.875 | 4 | #classes------------------------------------------------------
class wizard:
def __init__(self,name,specialpower):
self.myclass = "wizard"
self.name = name
self.sp = specialpower
self.hp = 100
print("---------------------------------------------")
print("Welcome " + s... |
afc6614926bdd5821040bafc93fabc6f5d0c659a | emicalvacho/All-algorithms-and-data-structures-AEDI | /pilas/pila_predef.py | 495 | 3.65625 | 4 | class PilaPredefinida(object):
def __init__(self):
self.items = []
def apilar(self,x):
self.items.append(x)
def desapilar(self):
try:
return self.items.pop()
except ValueError:
print("La pila está vacía")
def es_vacia(self):
return self.items==[]
def elementoCima(self):
retur... |
83920bc4e32b0dbc42187f9ce0fd8ce8e840a15f | emicalvacho/All-algorithms-and-data-structures-AEDI | /arboles/binary_tree.py | 2,433 | 4.125 | 4 | #TAD de Árbol Binario
class BinaryTree(object):
"""Clase del Binary Tree"""
def __init__(self, data):
"""Constructor del BT: Creo un nodo con el valor que
se instancia e inicializo tanto los dos hijos con None."""
self.key = data
self.leftChild = None
self.rightChild = None
def insertLeft(self, ... |
b60ea1611675a1c1e9509e27d7de95ac31e39f1b | ghensto/python | /MaxHeap.py | 1,007 | 3.640625 | 4 | def Parent(i):
return(i//2)
def Left(i):
return 2 * i
def Right(i):
return 2 * i + 1
def maximum(A):
return A[0]
def extract_maximum(A):
if len(A) < 0:
return ("Heap underflow")
max = A[0]
A[0] = A[len(A) -1]
del A[len(A) -1]
heapify(A,0)
return max
def increase_key... |
980e953005d9fd542114f611242dd674dd41630d | jamiepg1/WebCrawler | /CheckRobots.py | 1,461 | 3.765625 | 4 | import urllib2
import RobotExclusionRulesParser
import DeleteLastSlash
"""Check the url by Robots protocol
If this url is not aloowed to crawl
This is a naive method: check robots.txt for every url
if robots.txt do not allowed crewl, return error code -1
or not return orient url
"""
def toSiteUrl (h... |
c25210f20aa374a9be8cdf0ce0f456e75ed9f48b | philgeun/TapiocaPearlo | /tools/utils/time/__init__.py | 500 | 3.578125 | 4 | from datetime import datetime
import math
def to_datetime(timestamp, timezone=0):
"""Convert timestamp into datetime."""
# change timestamp type if type is string
if type(timestamp) is str or type(timestamp) is bytes:
timestamp = int(timestamp)
if type(timestamp) is int:
if timestam... |
530b7dddd1595bf0b4a4728af0ac6073a1de9d36 | MartinPetkov/AdventOfCode | /2021/day19-beacon-scanner/part1.py | 2,902 | 3.75 | 4 | # Run as:
# python3 part1.py [input|sample]
# I couldn't really figure this one out :(
import math
import sys
class Point:
def __init__(self, coord):
self.x = coord[0] if len(coord) > 0 else 0
self.y = coord[1] if len(coord) > 1 else 0
self.z = coord[2] if len(coord) > 2 else 0
def to_point(str_poin... |
8601c65e92ee6ed3dda60275a02c8b8fc488fb5d | MartinPetkov/AdventOfCode | /2018/day2/part1.py | 728 | 3.953125 | 4 | #!/usr/bin/env python
import argparse
def check_letters(s, num_letters):
for l in set(s):
if s.count(l) == num_letters:
return True
return False
def part1(input):
two_letters = 0
three_letters = 0
for box_id in input:
if check_letters(box_id, 2):
two_letters += 1
if check_letter... |
b2134377a690d727798aacd9a94583ba9d40ad40 | MartinPetkov/AdventOfCode | /2018/day1/part2.py | 669 | 3.734375 | 4 | #!/usr/bin/env python
class CircularBuffer:
"""
Class for a simple circular buffer.
"""
def __init__(self, buffer, idx=0):
self.buffer = buffer
self.idx = idx
self.mod = len(buffer)
def __iter__(self):
return self
def __next__(self):
val = self.buffer[self.idx]
self.idx = (self.... |
b0c06650a15e3c08c3c149d7df9f26abb25fb29f | MartinPetkov/AdventOfCode | /2021/day3-binary-diagnostic/part2.py | 1,610 | 3.65625 | 4 | # Run as:
# python3 part1.py [input|sample]
import sys
from functools import reduce
# Filter the set of numbers based on the frequency of bits in the given
# position and the mode ('oxygen' or 'co2').
def filter_numbers(numbers, position, mode='oxygen'):
def collect(collector, elem):
if elem[position] == '0':
... |
15c551bece5a2c0eaaa4cc35ec2e0bcc7ea615fb | Farazi-Ahmed/python | /problem-solved-10.py | 255 | 3.90625 | 4 | # Question 10 : Draw the flowchart for the following:
# 1) Ask the user to enter the name of his favorite car.
# 2) Display the name of the user’s favorite car 4 times.
car = input("Favorite car: ")
print(car)
print(car)
print(car)
print(car) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.