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 |
|---|---|---|---|---|---|---|
3802938003565f54718487b5f6865d2c709123bd | jakehoare/leetcode | /python_1_to_1000/926_Flip_String_to_Monotone_Increasing.py | 1,176 | 3.859375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/flip-string-to-monotone-increasing/
# A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0),
# followed by some number of '1's (also possibly 0.)
# We are given a string S of '0's and '1's, and we may... |
ae00b5a28d57f57c71ccae7cdc9ccc822ca24e35 | jakehoare/leetcode | /python_1_to_1000/347_Top_K_Frequent_Elements.py | 952 | 3.75 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/top-k-frequent-elements/
# Given a non-empty array of integers, return the k most frequent elements.
# Count the frequency of each element. Bucket sort the elements by frequency since the highest frequency cannot be
# more than the length of num... |
775c777d9166f841c1f7ab43026c6b6a3a0cf5b0 | jakehoare/leetcode | /python_1001_to_2000/1002_Find_Common_Characters.py | 1,212 | 3.78125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/find-common-characters/
# Given an array A of strings made only from lowercase letters, return a list of all characters that show up in
# all strings within the list (including duplicates).
# For example, if a character occurs 3 times in all stri... |
86a94afac60fda2b8ae9da2e70bde1488d62d24f | jakehoare/leetcode | /python_1_to_1000/808_Soup_Servings.py | 2,355 | 3.65625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/soup-servings/
# There are two types of soup: type A and type B. Initially we have N ml of each type of soup.
# There are four kinds of operations:
# Serve 100 ml of soup A and 0 ml of soup B
# Serve 75 ml of soup A and 25 ml of soup B
# Serve 50... |
9d8ae760d33b5759e0aed7ff94d545e2b36d665e | jakehoare/leetcode | /python_1_to_1000/286_Walls_and_Gates.py | 1,661 | 3.90625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/walls-and-gates/
# You are given a m x n 2D grid initialized with these three possible values.
# -1 - A wall or an obstacle.
# 0 - A gate.
# INF - Infinity means an empty room. We use the value 2**31 - 1 = 2147483647 to represent INF.
# Fil... |
d414b158e9dc6d1f0f3ffff14a9ab860ce00d1c2 | jakehoare/leetcode | /python_1_to_1000/637_Average_of_Levels_in_Binary_Tree.py | 1,165 | 3.703125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/average-of-levels-in-binary-tree/
# Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.
# Breadth first search. Maintain a queue of nodes in the current level.
# Time - O(n)
# Space - O(n)
... |
b6ddcc8efa1b04548012c0288258dc74d08305af | jakehoare/leetcode | /python_1_to_1000/972_Equal_Rational_Numbers.py | 1,889 | 3.796875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/equal-rational-numbers/
# Given two strings S and T, each of which represents a non-negative rational number,
# return True if and only if they represent the same number.
# The strings may use parentheses to denote the repeating part of the ratio... |
53f7b2aae35fd780b43080a87f4a066b06659a0d | jakehoare/leetcode | /python_1_to_1000/807_Max_Increase_to_Keep_City_Skyline.py | 1,674 | 3.890625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/max-increase-to-keep-city-skyline/
# In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there.
# We are allowed to increase the height of any number of buildings, by any amount (the amounts can be dif... |
1d901c8eb087e1cd9de6607a24997b57865cdaf5 | jakehoare/leetcode | /python_1_to_1000/416_Partition_Equal_Subset_Sum.py | 2,061 | 3.59375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/partition-equal-subset-sum/
# Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets
# such that the sum of elements in both subsets is equal.
# Dynamic programming. Maintain array of whi... |
5d1c1bd40803b7c61ff2ab19e9baaec9ace9a7ba | jakehoare/leetcode | /python_1_to_1000/767_Reorganize_String.py | 2,077 | 3.8125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/reorganize-string/
# Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other
# are not the same. If possible, output any possible result. If not possible, return the empty string.
# Create ... |
005fddbe88c0024f2de5c0bef62ee93100f3e51d | jakehoare/leetcode | /python_1_to_1000/827_Making_A_Large_Island.py | 1,906 | 3.796875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/making-a-large-island/
# In a 2D grid of 0s and 1s, we change at most one 0 to a 1.
# After, what is the size of the largest island? (An island is a 4-directionally connected group of 1s).
# For each cell of the grid, find the area of its island... |
240770b9e35d39bd84f2f19781018062a6a13b70 | jakehoare/leetcode | /python_1001_to_2000/1165_Single-Row_Keyboard.py | 1,201 | 3.84375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/single-row-keyboard/
# There is a special keyboard with all keys in a single row.
# Given a string keyboard of length 26 indicating the layout of the keyboard (indexed from 0 to 25),
# initially your finger is at index 0.
# To type a character, y... |
15f48dab447702057082211cabe326f5231199e1 | jakehoare/leetcode | /python_1_to_1000/527_Word_Abbreviation.py | 2,483 | 3.65625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/word-abbreviation/
# Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word
# following rules below.
# Begin with the first character and then the number of characters abbreviated, which... |
9c9fc4e5a6c2c49c8e00f77d76594f708f05b539 | jakehoare/leetcode | /python_1_to_1000/902_Numbers_At_Most_N_Given_Digit_Set.py | 1,765 | 3.78125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/numbers-at-most-n-given-digit-set/
# We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}.
# Note that '0' is not included.
# Now, we write numbers using these digits, using each digit as many times as we ... |
dfe11b6c0346492737e49907667a3109281f18bc | jakehoare/leetcode | /python_1001_to_2000/1240_Tiling_a_Rectangle_with_the_Fewest_Squares.py | 1,604 | 3.90625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/
# Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile the rectangle.
# State consists of the height of each column already tiled.
# Given a state, find the lowes... |
9165497d9960d76d23f8b38dd7eac2d8345d65c6 | jakehoare/leetcode | /python_1_to_1000/190_Reverse_Bits.py | 1,141 | 3.71875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/reverse-bits/
# Reverse bits of a given 32 bits unsigned integer.
# For example, given input 43261596 (represented in binary as 00000010100101000001111010011100),
# return 964176192 (represented in binary as 00111001011110000010100101000000).
# ... |
f22ed404e71743bb35560b2e29e9daeb48de8c2d | jakehoare/leetcode | /python_1_to_1000/221_Maximal_Square.py | 1,305 | 3.8125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/maximal-square/
# Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
# For each cell find the largest square with that cell at the bottom right by dynamic programming.
# If cell == ... |
c95cbdf32c6118e1dd63dfe8fac4cdb292900807 | jakehoare/leetcode | /python_1_to_1000/075_Sort_Colors.py | 1,061 | 3.859375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/sort-colors/
# Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent,
# with the colors in the order red, white and blue.
# Here, we will use the integers 0, 1, and 2 to represent the c... |
655ee29a245b886bb179b459791af52602ed3a51 | jakehoare/leetcode | /python_1_to_1000/815_Bus_Routes.py | 2,421 | 3.640625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/bus-routes/
# We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever.
# For example if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in the
# sequence 1->5->7->1->5->7->1->... f... |
8f2678dd9556ae486368f25e78eb7cdab7a38219 | jakehoare/leetcode | /python_1001_to_2000/1221_Split_a_String_in_Balanced_Strings.py | 786 | 3.734375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/split-a-string-in-balanced-strings/
# Balanced strings are those who have equal quantity of 'L' and 'R' characters.
# Given a balanced string s split it in the maximum amount of balanced strings.
# Return the maximum amount of splitted balanced s... |
e564225896350b4e264016aed2b8902c6d6c9b10 | jakehoare/leetcode | /python_1_to_1000/717_1-bit_and_2-bit_Characters.py | 856 | 3.75 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/1-bit-and-2-bit-characters/
# We have two special characters. The first character can be represented by one bit 0.
# The second character can be represented by two bits (10 or 11).
# Now given a string represented by several bits. Return whether ... |
34e42528789cc3c7b668330a6f8360aa4b4a8cc3 | jakehoare/leetcode | /python_1_to_1000/509_Fibonacci_Number.py | 673 | 3.921875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/fibonacci-number/
# The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number
# is the sum of the two preceding ones, starting from 0 and 1. That is,
# F(0) = 0, F(1) = 1
# F(N) = F(N - 1) ... |
115eeddd4650b206befb5acb51479e060fc46812 | jakehoare/leetcode | /python_1001_to_2000/1229_Meeting_Scheduler.py | 1,859 | 3.796875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/meeting-scheduler/
# Given the availability time slots arrays slots1 and slots2 of two people and a meeting duration duration,
# return the earliest time slot that works for both of them and is of duration duration.
# If there is no common time s... |
d99ba9b14064c017b23927ed27addbbac2fcb0ad | jakehoare/leetcode | /python_1_to_1000/732_My_Calendar_III.py | 2,252 | 3.671875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/my-calendar-iii/
# Implement a MyCalendarThree class to store your events. A new event can always be added.
# Your class will have one method, book(int start, int end). Formally, this represents a booking on the half open
# interval [start, end),... |
dd77de46b2bf23d0d23501c526d854dd1cf54979 | jakehoare/leetcode | /python_1_to_1000/923_3Sum_With_Multiplicity.py | 2,154 | 3.5625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/3sum-with-multiplicity/
# Given an integer array A, and an integer target, return the number of tuples i, j, k such that i < j < k
# and A[i] + A[j] + A[k] == target.
# As the answer can be very large, return it modulo 10^9 + 7.
# Count the fre... |
617af9b0de81a5f65f96374dfa7f5ffc02abdb8e | jakehoare/leetcode | /python_1_to_1000/069_Sqrt(x).py | 686 | 3.859375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/sqrtx/
# Implement int sqrt(int x).
# Compute and return the square root of x.
# Newton method. Initial guess of x. Iteratively update guess to be average of previous guess and x // guess.
# Since guess is too high, x // guess is too low.
# Term... |
85c4ba76b35aaeaef8c0a5b8e2a17cc17f4c279f | jakehoare/leetcode | /python_1_to_1000/284_Peeking_Iterator.py | 1,234 | 4.125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/peeking-iterator/
# Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that
# supports the peek() operation -- i.e. returns the element that will be returned by the next call to next().
#... |
439dccacf525e813772d6ee2a02480c4dc92dfeb | jakehoare/leetcode | /python_1_to_1000/035_Search_Insert_Position.py | 1,046 | 3.90625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/search-insert-position/
# Given a sorted array and a target value, return the index if the target is found.
# If not, return the index where it would be if it were inserted in order.
# You may assume no duplicates in the array.
# Iterative binar... |
ed27bdf61dac576d670f4baf67099f9879921340 | jakehoare/leetcode | /python_1_to_1000/472_Concatenated_Words.py | 1,365 | 4.09375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/concatenated-words/
# Given a list of words (without duplicates), please write a program that returns all concatenated words in the given
# list of words. A concatenated word is defined as a string that is comprised entirely of at least two short... |
571d8ed83c7d05b191049325fab820c68d431ce1 | jakehoare/leetcode | /python_1_to_1000/239_Sliding_Window_Maximum.py | 1,459 | 3.71875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/sliding-window-maximum/
# Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the
# very right. You can only see the k numbers in the window. Each time the sliding window moves right by one ... |
bbe3bfbeac20116cecb0b9736753ec1a8a1b216a | jakehoare/leetcode | /python_1_to_1000/885_Spiral_Matrix_III.py | 2,281 | 4.3125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/spiral-matrix-iii/
# On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east.
# Here, the north-west corner of the grid is at the first row and column, and the south-east corner of the
# grid is at the last row and col... |
336ba132e5f7bce831920a848b3dd538127e603f | jakehoare/leetcode | /python_1_to_1000/763_Partition_Labels.py | 1,204 | 3.703125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/partition-labels/
# A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that
# each letter appears in at most one part, and return a list of integers representing the size of these parts.
... |
162770f6f64c24f9076d88f885bda0dff06d8769 | jakehoare/leetcode | /python_1001_to_2000/1059_All_Paths_from_Source_Lead_to_Destination.py | 2,037 | 3.9375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/all-paths-from-source-lead-to-destination/
# Given the edges of a directed graph, and two nodes source and destination of this graph,
# determine whether or not all paths starting from source eventually end at destination, that is:
# At least one... |
cd61f74fa4f898ba95369b19044ca2e9d38be58c | jakehoare/leetcode | /python_1_to_1000/044_Wildcard_Matching.py | 1,725 | 3.890625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/wildcard-matching/
# Implement wildcard pattern matching with support for '?' and '*'.
# '?' Matches any single character.
# '*' Matches any sequence of characters (including the empty sequence).
# The matching should cover the entire input strin... |
28f539977dd7b501818c49dedecdcdcd96092c44 | jakehoare/leetcode | /python_1_to_1000/645_Set_Mismatch.py | 1,237 | 3.703125 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/set-mismatch/
# The set S originally contains numbers from 1 to n. But unfortunately, one of the numbers in the set got duplicated
# to another number in the set, which results in repetition of one number and loss of another number.
# Given an ar... |
99e187e28aaf4b20aba3cf7e5bb71ccf94b36837 | jakehoare/leetcode | /python_1_to_1000/073_Set_Matrix_Zeroes.py | 1,489 | 3.90625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/set-matrix-zeroes/
# Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
# Record whether first row and forst col contains zero. Then use first for and first col to flag whether body of
# matrix contain... |
f6a8cb9d2992fd028dfc7948b598ab0abe63cbf2 | jakehoare/leetcode | /python_1_to_1000/409_Longest_Palindrome.py | 1,008 | 3.90625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/longest-palindrome/
# Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that
# can be built with those letters. This is case sensitive, for example "Aa" is not considered a palindrome here... |
f28838f29cdddbb3306f8b6a6e50e015dc24ade9 | jakehoare/leetcode | /python_1_to_1000/734_Sentence_Similarity.py | 1,915 | 3.984375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/sentence-similarity/
# Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs,
# determine if two sentences are similar.
# For example, "great acting skills" and "fine drama talent" ar... |
110873776d780d3721fb96c42be11fc03c25c1df | jakehoare/leetcode | /python_1_to_1000/806_Number_of_Lines_To_Write_String.py | 1,401 | 3.875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/number-of-lines-to-write-string/
# We are to write the letters of a given string S, from left to right into lines.
# Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units,
# it is wri... |
80b51e5f5c055166fad48745e0d067554be867c3 | jakehoare/leetcode | /python_1_to_1000/186_Reverse_Words_in_a_String_II.py | 1,416 | 3.9375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/reverse-words-in-a-string-ii/
# Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.
# The input string does not contain leading or trailing spaces and the words are always separated by ... |
691d7c02155de751d9cb24ccdd38efbfec9bad6e | jakehoare/leetcode | /python_1_to_1000/024_Swap_Nodes_in_Pairs.py | 999 | 3.9375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/swap-nodes-in-pairs/
# Given a linked list, swap every two adjacent nodes and return its head.
# E.g. given 1->2->3->4, you should return the list as 2->1->4->3.
# Your algorithm should use only constant space. You may not modify the values in th... |
cabfe68c434ddc297b113bdedecbf32c21175e40 | jakehoare/leetcode | /python_1_to_1000/082_Remove_Duplicates_from_Sorted_List_II.py | 1,355 | 3.765625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
# Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
# If node is duplicated, move past all nodes of same value. Else add node t... |
061d10d7825407f9b5e185e326e6d385044459d5 | jakehoare/leetcode | /python_1001_to_2000/1197_Minimum_Knight_Moves.py | 2,124 | 3.921875 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/minimum-knight-moves/
# In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0].
# A knight has 8 possible moves it can make.
# Each move is two squares in a cardinal direction, then one square ... |
18c3091a5c779b0531e9eb0709e473480a9b03f7 | jakehoare/leetcode | /python_1_to_1000/496_Next_Greater_Element_I.py | 1,565 | 3.609375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/next-greater-element-i/
# You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2.
# Find all the next greater numbers for nums1's elements in the corresponding places of nums2.
# The Next Greater ... |
27e9363a8bf3bb6dc20054910df9e4f1564a6044 | MaximLiul/Daily_dependence_of_kauia_dataset_ | /activity_periods_of_the_day.py | 5,476 | 3.5 | 4 | import pandas as pd
import math
import numpy as np
df = pd.read_csv('kauia_dataset_excluded_extras.csv')
def activity_periods_of_the_day(data_frame, column_for_analysis, date_column, quantity_column,
transaction_column, number_of_intervals, product_or_user = 'user', list_of_excluded_h... |
6e0cbb5edd783cb46de1c8a595a3545816298de2 | JnsFerreira/lmpthw | /challenge_8/cut.py | 614 | 3.5 | 4 | from argparse import ArgumentParser
from cutpy import Cut
def parse_args():
parser = ArgumentParser(description="")
parser.add_argument(
"input", type=str, nargs=1, help="A text input")
parser.add_argument(
"-d", "--delimiter", type=str, default=' ', help="Type of delimiter")
parser... |
8f99dcd4f119f37af4f27a7589b6e4da7e58de43 | ra1nfoll/summer-practice | /1 день 2B.py.py | 787 | 3.921875 | 4 | import datetime
def printTimeStamp(name):
print('Автор програми: ' + name)
print('Час компіляції: ' + str(datetime.datetime.now()))
num = int(input("Введіть магнітуду:"))
if (0<num<2.0):
print("Мікро")
if (2.0<=num<3.0):
print("Дуже слабкий")
if (3.0<=num<4.0):
print("Слабкий")
if (4.0<=num<5... |
c00215ef84646d1a9d6b378eebaf34807bc66ad7 | ra1nfoll/summer-practice | /1День.А.5.цельсии.py | 671 | 3.8125 | 4 | import datetime
def printTimeStamp(name):
print('Автор програми: ' + name)
print('Час компіляції: ' + str(datetime.datetime.now()))
print('Перевод из температури в Цельсіях, в Кельвіни та Фаренгейти')
a = input('Введіть температуру в Цельсіях:')
bor = 9 / 5
t = 32
K = float(a) - 273.15... |
1ba8e5b555ccfb3ccf840c3875998e94cdcc7767 | fredlqin/gentrification | /old_files/helpful.py | 5,594 | 3.84375 | 4 |
import requests
import string
import json
from collections import *
"""
Examples to run for problem 1:
Web scraping, the basic command (Thanks, Prof. Medero!)
"""
def google_api(Sources, Dests):
""" Inputs: Sources is a list of starting places
Dests is a list of ending places
This funct... |
d8fb56977104d6fd7f5c8df34133ba6797736cb8 | corri-golden/tandem-trivia | /tandem_trivia.py | 2,763 | 3.96875 | 4 | import json
import random
welcome = input("Welcome to the Tandem Trivia. Would like to play press [y/n]?")
if welcome == "n":
print ("Aw... I understand next time.")
if welcome == "y":
with open('tandem.json') as json_file:
jsondata = json.load(json_file)
score = 0
i = 1
# loop... |
70b880f078b7083beecf0a1a1c8dc6ed410dca95 | BhagyashreeKarale/web-scraping | /movies.py | 1,148 | 3.5 | 4 | import requests
from bs4 import BeautifulSoup
response=requests.get("https://www.imdb.com/india/top-rated-indian-movies/?ref_=nv_mv_250_in")
soup=BeautifulSoup(response.text,"html.parser")
title1=soup.title
#task1:all 250 movies details
def scrape_top_list():
main_div=soup.find("div",{"class":"lister"})
tbody=m... |
47f6b8d0fc9f6145d73c26221697367446019b88 | imarnav/Tic-Tac-Toe | /oxgame.py | 2,478 | 3.671875 | 4 | # import sys
# sys.stdin=open('input.in','r')
# sys.stdout=open('output.out','w')
pos=['-','-','-',
'-','-','-',
'-','-','-']
Name_1=str(input())
Name_2=str(input())
class board():
def display():
print(pos[0]+'|'+pos[1]+'|'+pos[2])
print(pos[3]+'|'+pos[4]+'|'+pos[5])
print(pos[6]+'|'+pos[7]+'|'+pos[... |
eba4eac9b3b2c5ac9b7155e4631015e1667c56d4 | Vkunduru/Go_Analytics_Software | /PycharmProjects/Go_Analytics_Software/MiniMaxTreeTest.py | 297 | 3.5625 | 4 | from MonteCarlo import MonteCarloNode
def print_Tree(root):
root.printNode()
for i in range(root.next_moves.length):
print_Tree(root.next_moves[i])
print ")"
root = MonteCarloNode()
root.node_level = 0
root.move = 0
child1 = root.add_next_move(p_move=1)
print_Tree(root)
|
d3fa2a48bd30f8a5dd3242969288ddb657b7d8b6 | gmcsykes/Programming | /hello_world_extended.py | 285 | 3.875 | 4 | #! /usr/bin/python
phrase = "Nearly Test"
print ("hello world")
print ("testing 1,2,3")
print (phrase.upper().isupper())
print (len(phrase))
print (phrase[3])
print (phrase.index("Test"))
print (phrase.replace("Test","Rubish"))
print ("really long test")
print (phrase.index("rly"))
Pr |
576a002b13d054a0b484786ce83a020031b382fd | JAY-YANG1/python3 | /ex03.py | 525 | 3.765625 | 4 | # 이름, 국어, 영어, 수학을 입력받아
# 총점, 평균, 학점을 출력하는 프로그램
name = input('이름 : ')
kor = int(input('국어 : '))
eng = int(input('영어 : '))
mat = int(input('수학 : '))
tot = kor + eng + mat
avg = tot / 3
grd = '수' if (avg >= 90) else \
'우' if (avg >= 80) else \
'미' if (avg >= 70) else \
'양' if (avg >= 60) else '가'
print(f'이름 :... |
4225470b8d82843c5ab7a79cbe7c70eb87c72371 | clairevalva/mcrn_multi_DA | /multiscale_1.0/compartmental_model/build_population.py | 1,309 | 4.03125 | 4 | '''
Methods for multiscale program
'''
import numpy as np
#######################################################################################################################
'''Methods for generating initial data'''
##################################################################################################... |
8af9fa471236000c71f7a22a4b4a69c59a4bff83 | Huic-Yang/Data_Structure_and_Algorithm_in_Python | /Chapter 1/C_1_28.py | 224 | 3.859375 | 4 | from math import sqrt
def euclidean_norm(v):
return sqrt(sum((x * x for x in v)))
vectors = [
[1, 1, 1, 1],
[1, 1, 1],
[1, 1],
[1]
]
if __name__ == "__main__":
for v in vectors:
print(euclidean_norm(v))
|
b01194dfc1c4cba5ecbdea6b97aaf3366e72c80a | Huic-Yang/Data_Structure_and_Algorithm_in_Python | /Chapter 1/R_1_3.py | 536 | 3.859375 | 4 | def minmax(data):
try:
mi = ma = data[0]
for e in data:
if e < mi:
mi = e
if ma < e:
ma = e
return mi, ma
except IndexError:
print("should not be an empty sequence!")
return None, None
except TypeError:
print("elements in data must be comparable with each other"... |
e9be4b70f91f85c2deed3a16283ed3de7871a295 | Davin-Rousseau/ICS3U-Assignment-4-Python | /question_12.py | 861 | 4.15625 | 4 | #!/usr/bin/env python3
# Created by: Davin Rousseau
# Created on October 2019
# This program asks user to enter classes held and attended
# and tells them if they can write an exam or not
def main():
# This function calculates if student can write exam
# input
number = input("Enter number of classes hel... |
6641466adb3ad7ec5d7c19691f3598a91465d092 | fantian669/web | /python/painting.py | 1,273 | 4.5 | 4 | # 转载于 http://www.kidscoderepo.com/python.html
#"Recursive Star"
# in Python you have to pay attention to the indentions as they are regrouping blocks of code!
import turtle
def star(turtle, n,r):
# draw a star with n branches of length d
for k in range(0,n):
turtle.pendown()
turtle.forward(r)
... |
1460b604a769a7b6c3fed028205ffba39b45c654 | neelybd/Character_Remover | /BN_Char_Remover.py | 4,815 | 3.984375 | 4 | import pandas as pd
from tkinter import Tk
from tkinter.filedialog import askopenfilename, asksaveasfilename
def main():
print("Program: Char Remover")
print("Release: 0.1.1")
print("Date: 2019-03-26")
print("Author: Brian Neely")
print()
print()
print("This program reads a csv file and wi... |
3fd8774e74da1a46395362fdce76f000d1d5c4d0 | cwtliu/inuktitut-mt | /Bible_Prep_Scripts/inuktitut_cleaning.py | 842 | 3.6875 | 4 | #!/usr/bin/python
# -*- coding: utf-8
# Cleans off the front verse number and removes spaces at the beginning and end of verse
# For ASCII Encoding/Decoding of Inuktitut Syllabary
import io
import codecs
import unicodedata
import sys
import re
reload(sys)
sys.setdefaultencoding('utf8')
inputname = 'input name'
outp... |
1f235674e05afd1ea28c5567b68297375eda458d | pranavv999/DNA-Identifier | /dna.py | 2,558 | 4.0625 | 4 | import re
import csv
from sys import argv
# when we run the program in terminal with two arguments it will produce the list containing three fields name of python file,
# name of csv file, and name of txt file and we provide wrong input code will not execute
if len(argv) == 3:
csv_name = argv[1]
txt_file = argv[... |
ec903cb7d48d662143b03c62468623d97a0a9ceb | YandanYang/DL4CV_TUM | /exercise_1/dl4cv/classifiers/softmax.py | 3,235 | 3.890625 | 4 | import numpy as np
from random import shuffle
def softmax_loss_naive(W, X, y, reg):
"""
Softmax loss function, naive implementation (with loops)
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
Inputs:
- W: A numpy array of shape (D, C) containing wei... |
6e70688fc3b19f13791d04f5c346ec4a8930dd08 | Hwayongg/example_matplotlib | /practice.py | 421 | 3.5 | 4 | import random
import math
degree=0
i = 0
y1 = []
y2 = []
y3 = []
x = []
while degree < 180:
x.append(degree)
degree += 1
y1.append(math.sin(math.radians(degree))**2)
y2.append(math.cos(math.radians(degree))**2)
y3.append(math.sin(math.radians(degree))**2 + math.cos(math.radians(degree))**2)
... |
12f43f763479a25e9b33ee1016689e5e53f37fc9 | GottaGoGitHub/RubriksCubeSolver | /CubeMesh.py | 2,701 | 4 | 4 | from tkinter import *
from tkinter.font import Font
from Cube import *
def rectangle(canvas, x1, x2, y1, y2):
"""
Wrapper function to create a canvas rectangle object.
"""
rect = canvas.create_rectangle(x1, x2, y1, y2)
return rect
def grid3x3(canvas, origin_x, origin_y):
"""
... |
be0b1af484b9ccf62062f587f97c3bad4cabdfe2 | Harshsharma798/Limiting-check-algorithm | /list_creator.py | 591 | 4.0625 | 4 | from math import floor,sqrt
def create_list(breakpoint):
# flag for primality
prime = True
# 2 is a prime number so its already added
prime_list = [2]
for i in range(3,(breakpoint+1),2):
for j in range(3,(floor(sqrt(i))+1)):
# checks for every number before the squareroot... |
40f41c248aadd54117c2bb089a8876d1e49378d0 | Sulay35/speed-math | /speedmathscript.py | 1,079 | 3.609375 | 4 | from math import *
from random import *
from time import *
def S(t):
T=0.6
A=14*exp(1/T)
return A*exp(-t/T)+1
def play():
score=0
t0=monotonic()
level=1
add_max=5
calculs=0
while 1:
if calculs%5==0:
print("* NIVEAU ",int(calculs/5),"*")
print("________")
add_max+... |
52a9153c6bc1ef736b9f7daa3d3eee5fd666b5f2 | paulalarrechart/algoritmos_2021-paula | /ejercicios.py | 2,715 | 3.921875 | 4 | #sacar los objetos de la mochila de a uno a la vez hasta encontrar un sable de luz o que no
#queden más objetos en la mochila;
#b. determinar si la mochila contiene un sable de luz y cuantos objetos fueron necesarios sa-
#car para encontrarlo;
#c. Utilizar un vector para representar la mochila.
mochila_jedi = ['lap... |
cf7f1b3fc1b173a850b677de0f8842eee150a7fd | mlevesquedion/java---sql | /convert.py | 232 | 3.90625 | 4 | def convert(from_filename, to_filename, convert_func):
with open(from_filename) as from_file, open(to_filename, 'w') as to_file:
converted = convert_func(from_file.readlines())
to_file.write(converted)
print(converted) |
8f2199c8eb460a8a08c3c3431624befa301b0d14 | saiso12/python-ds | /stack/balance-paran.py | 882 | 3.90625 | 4 | from stack import Stack
def is_paren_balanced(paran_string):
s = Stack()
index = 0
is_balanced = True
while index < len(paran_string) and is_balanced:
paran = paran_string[index]
if paran in "({[":
s.push(paran)
else:
if s.is_empty():
i... |
695c70f84f685c25e2da00f8f975e9f7f50cf80d | PriyankaPriya29/Python-Programs | /eligible.py | 232 | 3.703125 | 4 | n=int(input('Enter your percentage:'))
m=int(input('Enter your arrears:'))
if (n>60 and m == 0):
print ('student eligible')
elif (n<60 and m>0):
print ('student not eligible')
else:
print('Rejected')
|
591a8634b561956700ecec65b77bc7dea9d2e152 | PriyankaPriya29/Python-Programs | /pattern1.py | 618 | 3.953125 | 4 | n=int(input('Enter a number:-'))
for i in range(1,n+1):
for j in range(1,n+1):
print('*',end=" ")
print()
n=int(input('Enter a number:-'))
for i in range(1,n+1):
for j in range(1,i+1):
print('*',end=" ")
print()
n=int(input('Enter a number:-'))
for i in range(1,n+1):
for ... |
41ee29588e2acf92c286fbb27ccef60f89203eb1 | howardh0214/Algorithms-Homework | /HW10/shortest.py | 2,960 | 3.5625 | 4 | def shortestDist(graph):
V = 11
dist = graph
for k in range(V):
for i in range(V):
for j in range(V):
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
line_1 = [0, min(dist[0][1], dist[0][2], dist[0][3])]
if min(dist[0][1], dist[0][2], dist[0][3]... |
78b0ce48ff78ed55f9e4db38feda81da949fe104 | howardh0214/Algorithms-Homework | /HW7/ternary.py | 313 | 3.984375 | 4 | def ternary(n):
convertString = "0123456789ABCDE"
if n < 3:
return convertString[n]
else:
return ternary(n//3) + convertString[n%3]
if __name__ == '__main__':
while True:
x = int(input())
if x >= 0:
print(ternary(x))
else:
break |
cb333d9b47cb5f6b91a952b2941a0862b741036a | howardh0214/Algorithms-Homework | /HW7/crypt.py | 252 | 3.515625 | 4 | def crypt(x, y):
while True:
return (round(y ** (1 / x)))
if __name__ == '__main__':
n_tests = int(input())
for _ in range(n_tests):
m , n = list(map(int, input().split(' ')))
print(crypt(m, n)) |
03d1dcf49c0598cef3ca335f4ecfe2abb6879f0f | howardh0214/Algorithms-Homework | /HW6/huffman.py | 883 | 3.59375 | 4 | import heapq
def encode(frequency):
heap = [[weight, [symbol, '']] for symbol, weight in frequency.items()]
heapq.heapify(heap)
while len(heap) > 1:
lo = heapq.heappop(heap)
hi = heapq.heappop(heap)
for pair in lo[1:]:
pair[1] = '0' + pair[1]
for pair in hi[1:]:
... |
de7ca2a9765bfd0e9ac653faea8fa6c7319ea77d | nuttanon211211/PY | /cyc.py | 1,407 | 3.796875 | 4 | from collections import defaultdict
class Graph():
def __init__(self,vertices):
self.graph = defaultdict(list)
self.V = vertices
def addEdge(self,u,v):
self.graph[u].append(v)
def isCyclicUtil(self,v,visited,recStack):
visited[v] = True
recStack[v] = True
for... |
621c78e9fb40f7748754d1f1afebff53c3207229 | nuttanon211211/PY | /money.py | 631 | 3.515625 | 4 | import sys
keyboard = sys.stdin
def currencyAnalysis():
numOfCurrency = int(keyboard.readline())
currencyData = []
for i in range(numOfCurrency):
currencyData.append([float(e) for e in keyboard.readline().split()])
for i in range(numOfCurrency):
for j in range(numOfCurrency):
for k in range(numOfCurrency):... |
013d047c44a323e6516693d193d5fa9bb0a68f02 | Danilo282/python-port | /Leitores/cilindro.py | 217 | 3.90625 | 4 | alt = int(input('Digite a altura do cilindro: '))
raio = int(input('Digite o raio do cilindro: '))
vol = (3.141592 * raio ** 2) * alt
print('O volume do cilindro é: ')
print('------------------------')
print(vol)
|
d40426c18b41af34ca9e3541a5fcb56c02acd695 | Danilo282/python-port | /Conversores/real_dolar.py | 204 | 3.875 | 4 | real = float(input('Digite o valor em reais: R$ '))
dolar = real / 5.23
print('O valor convertido para dolar é de : ')
print('--------------------------------------')
print('US$: {:.2f}'.format(dolar))
|
6c6a6a8b0cdb63eb1b08d618979005df7e74db14 | Danilo282/python-port | /Conversores/celsius_fahrenheit.py | 77 | 3.609375 | 4 | c = int(input('Digite a temperatura em Celsius: '))
f = c * 1.8 + 32
print(f) |
99c47346a0def4d6b8f7c7482b97d1c88dbe0adc | Danilo282/python-port | /Listas/variaveis.py | 285 | 3.734375 | 4 | numeros = [1, 2, 3, 4, 5]
print(numeros)
cores = ['verde', 'amarelo', 'azul', 'branco']
print(cores[0])
print(cores[1])
print(cores[2])
print(cores[3])
print('------------------')
print('----Cores Inverso--------')
print(cores[-1])
print(cores[-2])
print(cores[-3])
print(cores[-4]) |
d8992351836f0fd82d66e8363181d6f93e0aace1 | Danilo282/python-port | /Leitores_for_while/range.py | 307 | 4.03125 | 4 | """
nome = "Danilo Silva"
lista = (1, 3, 5, 7, 9)
numero = range(1, 10)
for letra in nome:
print(nome)
for numero in lista:
print(numero)
for numero in range(1, 10):
print(numero)
for a, o in enumerate(nome):
print(nome[4])
"""
nome = 'Danilo Silva'
for letra in enumerate(nome):
print(letra) |
705533b6527c1cbcbe1dfa1c1d97bfc324e447a9 | Danilo282/python-port | /Conversores/inteiros_soma.py | 162 | 3.8125 | 4 | n1 = int(input('Digite um numero: '))
n2 = int(input('Digite o segundo numero: '))
n3 = int(input('Digite o terceiro numero: '))
soma = n1 + n2 + n3
print(soma)
|
9a34e98f9104d893f8c959266391d4d90782c3cd | Danilo282/python-port | /Leitores/altura_degrau.py | 211 | 3.5625 | 4 | ad = float(input('Digite a altura do degrau: '))
audc = float(input('Digite a altura que deseja alcançar: '))
qtd_degraus = audc / ad
print('A quantidade de degraus necessarios são: {} '.format(qtd_degraus)) |
daa08cb4ad99abeb4cd8b112b84749c3c0a28292 | Danilo282/python-port | /Leitores/salario_imposto.py | 140 | 3.609375 | 4 | sb = float(input('Digite o Salario:R$ '))
s1 = sb * 1.05
s2 = sb * 0.07
sr = s1 - s2
print('O salario a receber é de R${:.2f}'.format(sr)) |
a4075d5f77149b3e232a44b947f9ec9ae9bda672 | KFOAS/automate-the-boring-stuff | /resize_add_logo/resize_add_logo.py | 3,184 | 3.734375 | 4 | #! /usr/bin/env python3
# resize_add_logo.py - resizes images to standard square size and adds logo
from pathlib import Path
from PIL import Image
def resize_and_add_logos(path, logo_path, scaling_factor):
"""
Gathers all image files at path's location, resizes the images and
adds a logo (as long as the... |
be86b1f1ebaa584ed88fe48ceb4c11b1b1d75d09 | KFOAS/automate-the-boring-stuff | /prettified_stopwatch/stopwatch.py | 3,435 | 4.34375 | 4 | #! /usr/bin/env python3
# stopwatch.py - a simple stopwatch program
import time
import pyperclip
def print_instructions():
"""
Prints instructions for using the stopwatch
"""
input("Press ENTER to begin."
"\nAfterwards, press ENTER to 'click' the stopwatch."
"\nPress Ctrl + C to ... |
1940f8577b025affa17c0e7f3c3931b1cfe69c0d | KFOAS/automate-the-boring-stuff | /play_2048/play_2048.py | 1,767 | 3.5625 | 4 | #! /usr/bin/env python3
# play_2048.py - simple blind bot that plays 2048 online
import random
from itertools import cycle
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def play_2048(random_input=False):
"""
This function launches and plays a game of 2048 with either seqenti... |
29f0dded2b2b061bd3792dbeefa614a8aaa5a076 | KFOAS/automate-the-boring-stuff | /find_files_by_size/find_files_by_size.py | 1,412 | 4.25 | 4 | #! /usr/bin/env python3
# find_files_by_size.py - finds files along a specified path larger than
# a specified threshold in size
import os
def find_large_files(path, threshold):
"""
Finds all files whose size is greater than or equal to threshold and
prints their absolute path and size to the conso... |
97d5c91a9d5ddcf80b38977e3e2f18272b47211d | KFOAS/automate-the-boring-stuff | /character_picture_grid/character_picture_grid.py | 1,226 | 3.953125 | 4 | #! /usr/bin/env python3
# character_picture_grid.py - takes a nested list input, rotates and formats the data
def rotate_grid(grid):
"""
Rotates the input 90 degrees clockwise
:param list grid: input with nested lists to format
"""
return list(zip(*grid[::-1]))
def format_grid(grid):
"""
... |
b953bf97069660b8308b79780da61e00e41aac96 | KFOAS/automate-the-boring-stuff | /spreadsheet_to_text/spreadsheet_to_text.py | 1,065 | 3.921875 | 4 | #! /usr/bin/env python3
# spreadsheet_to_text.py - converts spreadsheet (.XLSX) to text (.TXT)
import os
from os.path import join, abspath
import openpyxl
def spreadsheet_to_text(filename):
"""
Writes column data in worksheet to text files. The filenames are
in the first row of each column. Each subsequ... |
593b38eed8f1cceda1e0ee92a00544c8892cc18c | samsonosiomwan/resource-security | /auth.py | 296 | 3.796875 | 4 | from db import database
def authenticate(email, password):
'''This function authenticate user, it returns user object if user exist and false otherwise'''
for user in database:
if user['email'] == email and user['password'] == password:
return user
return False
|
3b17da4171b2d00877200cfacf72d48b68d2c2cd | godscreator/GeneticAlgorithms | /Genetic/MultiObjectiveAlgorithms.py | 9,223 | 3.90625 | 4 | import math
import random
from abc import ABC, abstractmethod
from typing import List
class Gene(ABC):
"""
Gene is template to make a genotype of the solution.
"""
@classmethod
@abstractmethod
def create_random(cls) -> 'Gene':
"""
Create a gene with random data.
:retu... |
b9fe35846746cb99e9155e39ea2cb23bd31f7b06 | AmmarShaqeel/LPTH-12-09-2013 | /ex15.py | 644 | 3.875 | 4 | # normal usage of sys and import to get script and file name
from sys import argv
sript, filename = argv
# new stuff, opening file (creating a file object) then assigning it to a variable
txt = open(filename)
# printing name of file
print "Here's your file %r:" % filename
# printing contents of file with "read" comm... |
e8c0b9300ff68aea60e83ec46e513039d312d535 | AmmarShaqeel/LPTH-12-09-2013 | /ex43.py | 5,300 | 3.8125 | 4 | from sys import exit
from random import randint
class Scene(object):
def enter(self):
print "This scene is not yet configured"
exit(1)
class Engine(object):
def __init__(self, scene_map):
# print "Engine __init__ has scene_map", scene_map
self.scene_map = scene_map
def play(self):
... |
333a82d65bd6dee34b905450adac9f1dfc84086f | venkateshtanniru/Data-Mining | /Lab6/Lab6.py | 1,184 | 3.765625 | 4 |
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
age=[17.5,22,29.5,44.5,64.5,80]
deaths=[38,36,24,20,18,28]
plt.plot(age,deaths,"b.")
plt.xlabel("age")
plt.ylabel("Number of deaths")
plt.show()
mean_age = np.mean(age)
mean_deaths = np.mean(deaths)
def least_squares(age,mean_age,deaths,mean_deat... |
fe17b03aca45cb37de6f5f1587b16857fa8298f2 | jhong16/NLP-TOS-Summarization | /model2/utils.py | 267 | 3.796875 | 4 | import string
str_translator = str.maketrans('', '', string.punctuation + '”' + '“' + '’' + '´')
def removePunc(word):
return word.translate(str_translator)
def checkHasCapital(word):
for letter in word:
if letter.isupper():
return True
return False |
1b6d6d4a9fc4c1aa3be7f9cea43c10171e76130f | HarrisonBacordo/MegaProject | /Text/Palindrome Checker.py | 498 | 4.34375 | 4 | string_to_reverse = input("Welcome to the palindrome checker! Type in any length of string, and I'll"
" check if it's a palindrome\n")
reverse = []
is_palindrome = True
for i in range(len(string_to_reverse), 0, -1):
reverse.extend(string_to_reverse[i-1])
for i in range(len(string_to_rever... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.