blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7bf0a2fed15165bc88ca2edb8f2896fd1b31c4ac
kamyar/abzar
/abzar/singleton.py
526
3.765625
4
class Singleton: """ Singleton Superclass Usage: class MyClass(Singleton): ... Retrieved from: https://stackoverflow.com/a/11517201/1329429 """ def __new__(cls, *args, **kwargs): cls._instance = cls.__dict__.get("_instance") if cls._instance is not None: ...
e1918691e6bf84e57caae6c1768569e3a715dd39
venkatsvpr/Problems_Solved
/LC_Best_Time_to_Buy_and_Sell_Stock.py
1,482
3.78125
4
""" run through the numbers.. store the min_number and max_profit. update the max_profit in the process. What remains at the end is the max_profit. """ class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ if not prices: ...
dba2ee6e8865d49a110ba6152ac50a9d3cb52ad9
venkatsvpr/Problems_Solved
/LC_Minimum_time_Difference.py
1,577
3.953125
4
""" 539. Minimum Time Difference Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list. Example 1: Input: timePoints = ["23:59","00:00"] Output: 1 Example 2: Input: timePoints = ["00:00","23:59","00:00"] Output: 0 Constraints...
a4a6d87ae1bb601a4e19ae3fb749d0985d1d9f4c
venkatsvpr/Problems_Solved
/LC_Paint_House.py
813
3.9375
4
""" There are three colors. The cost of picking a color for nth house .. Is cost of picking a color to nth house and the min cost of picking other two colors for n-1 th house. We will choose the minimum value from the different colors for any particular house. """ class Solution: def minCost(self, costs): ...
30d65e22be34d3225c3edebad4d30abd01290e03
venkatsvpr/Problems_Solved
/LC_Reverse_Words_in_a_String_3.py
1,105
3.84375
4
""" 557. Reverse Words in a String III Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Note: In the string, each word is separated ...
296e12b8436d85ffbf45d972741d8ce882ef4a39
venkatsvpr/Problems_Solved
/LC_Find_Anagram_Mappings.py
1,188
4.125
4
""" 760. Find Anagram Mappings Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j. These lists A and B may contain ...
53838a621b60730767655f844a9e039de9f2406a
venkatsvpr/Problems_Solved
/LC_Find_The_Duplicate_Number.py
1,426
4.125
4
""" 287. Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3...
a08dfb0f7f673f5ac3b354aae835c0074461c8cc
venkatsvpr/Problems_Solved
/LC_Robot_Room_Cleaner.py
4,444
3.734375
4
""" 489. Robot Room Cleaner You are controlling a robot that is located somewhere in a room. The room is modeled as an m x n binary grid where 0 represents a wall and 1 represents an empty slot. The robot starts at an unknown location in the room that is guaranteed to be empty, and you do not have access to the grid,...
73145b0cd4db3609b73fc26d69cba89d44644b30
venkatsvpr/Problems_Solved
/LC_MoveZeros.py
980
3.765625
4
""" Linearly search the nums and store the position of the zero Swap the position when we find a non-zero number. """ class Solution: def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ if not nums: ...
580d335a95141313969e3baa7eb5b90d1b81f2db
venkatsvpr/Problems_Solved
/LC_Minimum_Window_Substring.py
3,383
3.953125
4
""" 76. Minimum Window Substring Hard 10060 530 Add to List Share Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "". The testc...
1df401e3876f9baf13a356d0d7fcdc94998239d2
venkatsvpr/Problems_Solved
/LC_Evaluate_Division.py
3,351
3.984375
4
""" 399. Evaluate Division Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0. Example: Given a / b = 2.0, b / c = 3.0. queries are: a / c = ...
4df0a26bba8def771fd4f90a6c9060ce13f656b4
venkatsvpr/Problems_Solved
/2296_Design_a_Text_Editor.py
5,048
3.875
4
""" 2296. Design a Text Editor Design a text editor with a cursor that can do the following: Add text to where the cursor is. Delete text from where the cursor is (simulating the backspace key). Move the cursor either left or right. When deleting text, only characters to the left of the cursor will be deleted. The cu...
e2ce51f6d73eb69beba76cfdab15d40af6fcef5d
venkatsvpr/Problems_Solved
/LC_N_Array_Tree_Level_Order_Traversal.py
1,088
4.0625
4
""" 429. N-ary Tree Level Order Traversal Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree: We should return its level order traversal: [ [1], [3,2,4], [5,6] ] Note: The depth of the tree i...
8ac4f44a4f02ef381c641a642fa5aeaea099d6ba
venkatsvpr/Problems_Solved
/LC_Divide_Chocolate.py
2,073
4.09375
4
""" 1231. Divide Chocolate You have one chocolate bar that consists of some chunks. Each chunk has its own sweetness given by the array sweetness. You want to share the chocolate with your k friends so you start cutting the chocolate bar into k + 1 pieces using k cuts, each piece consists of some consecutive chunks....
8fc7fa3c6f02f37c86e4a20b924e21559a876110
venkatsvpr/Problems_Solved
/LC_Reorder_List.py
2,092
3.859375
4
""" 143. Reorder List Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes itself may be changed. Example 1: Given 1->2->3->4, reorder it to 1->4->2->3. Example 2: Given 1->2->3->4->5, reorder it to 1->5->2->4->3. """ ...
bc2d26a2b29f77873174123bb93e4e2ff5c9973e
venkatsvpr/Problems_Solved
/606_Construct_String_from_Binary_Tree.py
1,582
4.0625
4
""" 606. Construct String from Binary Tree Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it. Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and th...
729c072fa7f5406df4523d24ceaf74b3932c8e7b
venkatsvpr/Problems_Solved
/LC_Partition_Array_into_Disjoint_Intervals.py
1,871
4.0625
4
""" 915. Partition Array into Disjoint Intervals Given an array A, partition it into two (contiguous) subarrays left and right so that: Every element in left is less than or equal to every element in right. left and right are non-empty. left has the smallest possible size. Return the length of left after such a parti...
ff5bc2b8c1dfe6cfd68ae8d135a56b8bfe7e957b
venkatsvpr/Problems_Solved
/LC_Letter_Combination_of_a_Phone_Number2.py
843
3.71875
4
# Letter Combination of a Phone Number # https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/ # Iterative Solution class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ Ans =[] ...
2163f2121fbbc45862eac8f2a23380a1b14d5cae
venkatsvpr/Problems_Solved
/LC_Coin_Change_2.py
1,660
3.796875
4
""" 518. Coin Change 2 You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return 0. You ma...
3eb3b8dac245ad373540f155ce6df87bcd88d77e
venkatsvpr/Problems_Solved
/LC_Product_of_Array_Except_Self_Const_space.py
1,257
3.875
4
""" 238. Product of Array Except Self ================================== Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Example: Input: [1,2,3,4] Output: [24,12,8,6] Note: Please solve it without division...
c999e78872e94db1f380a5c2c32522746fc350f0
venkatsvpr/Problems_Solved
/Largest_Sum_of_Non_Adjacent_Numbers.py
637
4.375
4
""" This problem was asked by Airbnb. Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5. """ # Function to return ...
8ddfb130bd4d93de2601e185566880c84c152086
venkatsvpr/Problems_Solved
/LC_Replace_All_?_To_Avoid_Consecutive_Repeating_Characters.py
2,629
3.828125
4
""" 1576. Replace All ?'s to Avoid Consecutive Repeating Characters Given a string s containing only lower case English letters and the '?' character, convert all the '?' characters into lower case letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' ...
9a4a1fd3191df1a9c6778dcea9cb7add9dcad95b
venkatsvpr/Problems_Solved
/LC_Isomorphic_String.py
483
3.84375
4
""" Isomorphic String Find len(s) == len(t) == len(set(zip(s,t))) If this is true. Return True else Return False """ class Solution: def isIsomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ if ((len(s) ==0) and (len(t)==0)): return True...
743791aad06c2d009f35a8c16f8a204999fe455d
venkatsvpr/Problems_Solved
/LC_Serialize_and_Deserialize_Binary_Search_Tree.py
2,448
3.84375
4
""" 449. Serialize and Deserialize BST Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an alg...
d19e1d966c74b79fb2861bbeddac012ce44abf15
venkatsvpr/Problems_Solved
/LC_Target_Sum.py
2,466
4.125
4
""" 494. Target Sum You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers. For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and conca...
1c53a9032e676dcb4a5d1b815b9e46528c96d42d
venkatsvpr/Problems_Solved
/LC_Longest_Mountain_Array.py
1,531
4.125
4
""" Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array...
8166d297975960e78306aa59ece94be838f4b09c
venkatsvpr/Problems_Solved
/LC_Special_Positions_in_a_Matrix.py
1,773
3.90625
4
""" 1582. Special Positions in a Binary Matrix Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat. A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed). Example 1: Inpu...
71567969846f431a4e04050fc793672a00a2d4cd
venkatsvpr/Problems_Solved
/LC_Two_Sum_IV_Tree.py
1,280
3.640625
4
""" 653. Two Sum IV - Input is a BST Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: 5 / \ 3 6 / \ \ 2 4 7 Target = 9 Output: True Example 2: Input: 5 / \ 3 6 / \ ...
0429168bd715d699e4bf6005f55da921b64074d3
venkatsvpr/Problems_Solved
/267_Palindrome_Permutation_2.py
1,383
3.53125
4
class Solution: def generatePalindromes(self, s: str) -> List[str]: count = collections.Counter(s) oddCount = 0 for c in range(ord('a'), ord('z')+1): ch = chr(c) if count[ch] % 2 != 0: oddCount += 1 # If we have more than one odd poin...
74feec8d7dab0835d03d2820253a3fe06fb203d0
venkatsvpr/Problems_Solved
/LC_Frog_Jump.py
3,074
4.09375
4
""" 403. Frog Jump A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of stones' positions (in units) in sorted ascending order, determine if the frog is able to cross the ri...
28e5b1af503d6d1e1ba5c3206d775f93752c2e4e
venkatsvpr/Problems_Solved
/LC_Step_by_Step_Directions_For_Binary_Tree_Node_To_Another.py
3,622
4.25
4
""" 2096. Step-By-Step Directions From a Binary Tree Node to Another You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of...
513c003a435949284dab2d6b256e3b2645a623e4
venkatsvpr/Problems_Solved
/LC_Employee_Importance.py
2,411
4.4375
4
""" 690. Employee Importance You are given a data structure of employee information, which includes the employee's unique id, his importance value and his 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, r...
8ecaeba7f21f73e58ceb27fd31bc26c262ace990
venkatsvpr/Problems_Solved
/LC_Construct_Binary_Tree_from_inorder_And_preorder.py
1,333
3.984375
4
""" 105. Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3,15,20,7] Return the following binary tree: 3 ...
d20dcd07147875b7088c7eafe73e04920c115552
venkatsvpr/Problems_Solved
/LC_Count_Primes.py
608
4.0625
4
""" 204. Count Primes Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. """ class Solution(object): def countPrimes(self, n): """ :type n: int :rtype: int "...
ee0c4723c84ab72fdb97031cd56e5f0c214621c3
venkatsvpr/Problems_Solved
/LC_Find_median_From_data_stream.py
3,671
3.90625
4
""" 295. Find Median from Data Stream The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. For example, for arr = [2,3,4], the median is 3. For example, for arr = [2,3], the median is (2 + 3) / 2 = 2.5...
c71e85eaefc2c3cd33a8956cc0f187dde01fafb6
venkatsvpr/Problems_Solved
/LC_Moving_Average_from_Data_Stream.py
1,139
3.921875
4
""" Moving Average from Data Stream https://leetcode.com/problems/moving-average-from-data-stream/ Approach: 1) Create a Queue for the size 2) Enqueue and dequeue 3) Keep track of the sum of elements queue 4) When we pop - we have to update the sum and return """ class MovingAverage: queue_sum = 0; queue = []...
3d085e984876753299b9161b029a9f24ad1fa610
venkatsvpr/Problems_Solved
/LC_Longer_Contiguous_Segments_of_Ones_than_Zeros.py
1,991
4.09375
4
""" 1869. Longer Contiguous Segments of Ones than Zeros Given a binary string s, return true if the longest contiguous segment of 1s is strictly longer than the longest contiguous segment of 0s in s. Return false otherwise. For example, in s = "110100010" the longest contiguous segment of 1s has length 2, and the lo...
332a300c7fc310323c6514d722538b3a5ff8228f
venkatsvpr/Problems_Solved
/Longest_Common_Subsequence.py
2,253
4
4
""" 1143. Longest Common Subsequence Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relati...
066aa51c8adea057fd2a4f419a49cd9fc732b1c5
venkatsvpr/Problems_Solved
/1366_Rank_teams_by_votes.py
2,401
4.28125
4
""" In a special ranking system, each voter gives a rank from highest to lowest to all teams participated in the competition. The ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they ti...
3c1b00c95906daac6afde2944d459c08727cc8ff
venkatsvpr/Problems_Solved
/LC_Minimum_Number_of_Arrows_To_Burst_Ballons.py
1,902
3.921875
4
""" 452. Minimum Number of Arrows to Burst Balloons There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of start and end of t...
d7095359113a4813e735b3a1eeef921055295a6b
venkatsvpr/Problems_Solved
/LC_Graph_Valid_Tree.py
1,619
3.96875
4
""" 261. Graph Valid Tree You have a graph of n nodes labeled from 0 to n - 1. You are given an integer n and a list of edges where edges[i] = [ai, bi] indicates that there is an undirected edge between nodes ai and bi in the graph. Return true if the edges of the given graph make up a valid tree, and false otherwis...
10c307d324ea44956ca0de154eda21a6bb4fa5e0
venkatsvpr/Problems_Solved
/LC_Intersection_of_Two_Arrays_II.py
352
3.703125
4
""" Create counter for nums1,nums2 Find the overlap and elements """ class Solution: def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ a = collections.Counter(nums1) b = collections.Counter(nums2) ...
1e1a3a0868280e3f2e1773455596dc7f9fa57cee
venkatsvpr/Problems_Solved
/LC_Maximal_Rectangle.py
1,842
3.765625
4
""" 85. Maximal Rectangle Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 6 Explanation: The maximal rectangl...
c1bcb7efb2cdcabf1d963ade48293792f5f03597
venkatsvpr/Problems_Solved
/LC_Permutation_in_a_String.py
1,600
3.671875
4
""" 567. Permutation in String Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string. Example 1: Input:s1 = "ab" s2 = "eidbaooo" Output:True Explanation: s2 contains one permutation...
c8d57ebf94491909e8f58e8708cfe7992471aa9b
whoisme123/python-note
/局部变量实验.py
2,247
3.609375
4
''' def spam(): egg = 23 ban() print(egg) def ban(): ham = 11 egg = 33 spam() ''' ''' def spam(): egg = 'spam local ' print(egg) def bacon(): egg = 'bacon local' print(egg) spam() print(egg) egg = 'zzz' bacon() print(egg) ''' ''' def spam(): global eggs eggs = 's...
567dad2db52c6b40ee9f0fc49d6327d9251de8ca
caiti326/python-challenge
/PyPoll/main.py
2,604
4
4
#Import and read csv file, import pandas and statistics import os import csv vote_csv = "/Users/caitlindonovan/Desktop/ColumbiaBootcamp/Homework/python-challenge/PyPoll/Resources/election_data.csv" export_file = "/Users/caitlindonovan/Desktop/ColumbiaBootcamp/Homework/python-challenge/PyPoll/PyPoll.txt" import pandas a...
8863011ed9b2a33fbe3de156a47d1aa83c66ecba
dilbwagsingh/Business-profit-prediction
/main.py
2,100
3.96875
4
import matplotlib.pyplot as plt; import numpy as np; from gradientDescent import gradientDescent; from setParams import setParams; from costFunction import costFunction; from checkGradientDescent import plotCost_vs_iter; from plotData import plotData; # open data file print("Opening Data file..."); path = "./data_...
c1a4a96caf8fc44e40642a5c11c1cb2fca97a040
MCKasman/leetcode
/strings/first_unique_character.py
626
3.796875
4
class Solution(object): def firstUniqChar(self, s): """ :type s: str :rtype: int Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1. Algorithm 1. Create a Hash Map and count the frequency of the charact...
b52d1f1870f3f8c50313cd7b49b1055b8d194a4b
MCKasman/leetcode
/linked_lists/remove_nth_node_from_end_of_list.py
1,069
4.0625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode ...
d14d92c14c5505d1c1c7bb5e6aaf9f4a1ca45163
ryansb/validator.py
/validator/__init__.py
9,985
3.953125
4
""" validator.py A library for validating that dictionary values fit inside of certain sets of parameters. Author: Samuel Lucidi <slucidi@newstex.com> """ def In(collection): """ Use to specify that the value of the key being validated must exist within the collection passed to this validato...
68770c1256bff903a2578f6edf66e89a7109a2db
pythagaurang/data-science-learning
/neural-networks/first-neural-network/neural_networks.py
1,499
4.46875
4
from sklearn.metrics import mean_squared_error import numpy as np import matplotlib.pyplot as plt # a relu activation function returns # 0 for negative numbers and the # number itself for positive function def relu(input): return max(0,input) # this is the main function for # neural network it a simple single #...
d5600c91385690aa323e81628adc39297aed8dd8
2021202025/Programming
/Basics.py
375
3.9375
4
from random import shuffle def jumble(word): anagram = list(word) shuffle(anagram) return ''.join(anagram) words = ['Shelby GT350R', 'BMW E36 M3', 'Nissan Skyline R34 GTR'] anagrams = [] '''for word in words: anagrams.append(jumble(word)) print(anagrams) ''' #map(function, data) print(list(map(jumble,...
472157a5c6ed20aeaf0b79a7961db0fe0bd4da1c
2021202025/Programming
/Binary_search.py
586
3.9375
4
n = int(input()) numbers = [] for i in range(n): a = int(input()) numbers.append(a) print(numbers) x = sorted(numbers) print(x) first = 0 middle = 0 last = n flag = 0 search = int(input("Enter the element to be searched: ")) for i in range(len(numbers)): middle = (first + last)// 2 if(search == nu...
a12f4fde512b58fe0e76218232ae41a1b0915abb
2021202025/Programming
/Bubble Sort.py
328
4.03125
4
bubble = [] n = int(input('Enter the number of elements ')) for i in range(n): a = int(input()) bubble.append(a) print(bubble) for i in range(n): for j in range(n-1): if(bubble[j]>bubble[j+1]): temp = bubble[j+1] bubble[j+1] = bubble[j] bubble[j] = temp print(...
7cf2602ae991d3bcb36e2ecd3352bc433ae62be0
AsherPop/Lots-of-py-seriously-
/Poppleton.CardDealingEngineV1.py
2,551
4.28125
4
""" Card Dealing Engine Questions from previous class: 1. How do you represent each card? 2. A card displays three pieces of data...which ones do you need? Which is the only piece of data that is IMPLIED by another piece? 3. How do you organize the deck, player "hands", and a discard "pile"? 4. How do you re...
a2209490f5c2d115e7c396815c091fd5ef7b85e8
CamilaTermine/programitas
/Python/Parte1/11-07-2021/ejercicio2.py
203
3.96875
4
numero = int(input("ingrese un numero: ")); mensaje = ""; for i in range(1, numero+1): for i2 in range(1, i+1): mensaje = mensaje + str(i2); mensaje = mensaje + "\n" print(mensaje);
d9376fe8353fd1529ef29150af49dfb695ffd199
CamilaTermine/programitas
/Python/Parte1/11-07-2021/ejercicio3.py
208
3.96875
4
numero = int(input("ingrese un numero: ")); mensaje = ""; for i in range(numero, 0, -1): for i2 in range(i, 0, -1): mensaje = mensaje + str(i2); mensaje = mensaje + "\n"; print(mensaje);
cfa3e118a522ff668c98ab35cf4231b486c0ecc3
CamilaTermine/programitas
/Python/Parte1/14-07-2021/letrasDistintas.py
550
3.625
4
palabra = input("ingrese una palabra: "); largo = len(palabra); cantA = 0; cantE = 0; cantI = 0; cantO = 0; cantU = 0; for i in range(0, largo): if palabra[i] == "a": cantA = cantA+1 if palabra[i] == "e": cantE = cantE+1 if palabra[i] == "i": cantI = cantI+1 if palabra[i] == "o...
bedc5798e83dd089239f1b06f394dda89cba02c1
CamilaTermine/programitas
/Python/Parte2/5-08-2021/arreglosRandom.py
429
3.921875
4
#guardar en una lista n numeros randoms #mostrar la lista y el promedio import random arreglo = []; cantNum = int(input("indique la cantidad de numeros que quiere en su arreglo: ")); suma = 0; promedio = 0; for i in range (0, cantNum): numero = random.randint(0, 10); arreglo.append(numero); suma = suma + n...
0bf2220a4db7af3e2c649c1a9940e1e01ef5df7e
CamilaTermine/programitas
/Python/Parte2/5-08-2021/ordenarListaOrdenada.py
760
3.609375
4
listaPar = [1, 3, 4, 5, 9]; listaImpar = [2, 4, 6, 7, 10]; listaOrdenada = []; indicePar = 0; indiceImpar = 0; numeroParcial = 0; maschikito = 0; while len(listaOrdenada) != len(listaPar + listaImpar): if indicePar == len(listaPar): listaOrdenada.append(listaImpar[indiceImpar]); indiceImpar = ind...
2a1a0e2547e22101c1f64d81cb8c5448466d8e25
CamilaTermine/programitas
/Python/Parte1/27-07-2021/adivinar.py
615
3.609375
4
numSecreto = "1892"; numRandom = ""; vidas = 10; signo = ""; while vidas > 0 and numRandom != numSecreto: numRandom = input("ingrese un numero: "); signo = ""; for i in range (0, 4): if numSecreto[i] == numRandom[i]: signo = signo + "+"; elif numRandom[i] in (numSecreto[0], num...
7e6ea598d48777358fa4c1353a8b7381f5d918c0
Erik-A-Smith/demo-python3-command-pattern
/Classes/Card.py
535
3.53125
4
from enum import Enum # Main card class class Card: def __init__(self,suit,face, value): self.suit = suit self.face = face self.value = value def __str__(self): compiledString = "---- Card ----\n" compiledString += "|Suit: {} \n".format(self.suit) compiledSt...
a8ce12e4f757e1d493e3c91f46b270e75090b60d
dfabela/age-calculator
/age-calc-1.py
484
4.125
4
#birthyearguesser and age calculator x = int(input('How old are you?(in numbers, not words): ')) name= input('And what is your name?:') equat = x + 5 print ("In five years" , name , ", you'll be, ", equat) birth_year=input('So, would you like to know your birth year? if so, says "yes". if not say "no".(case sensetive)'...
f8e32f226a8f5fd864e55dc0aa3844955d36ef33
waws520waws/the-god-of-algorithms
/汉诺塔.py
1,067
4.03125
4
# 汉诺塔的问题 # 解决步骤实际上是: """ 将A上圆盘通过B放置在C的上面 1.首先先将A上的n-1个圆盘经过C放到B上 2.在将A上最大的圆盘移动的C上 3.将B上的n-1个圆盘经过A放置在C上,完成由A--->C的最终的移动 """ def hannuota(n, a, b, c): if n > 0: hannuota(n - 1, a, c, b) print("please move %s to %s" % (a, c)) hannuota(n - 1, b, a, c) hannuota(1, "a", "b", "c") """ please mov...
040fb1a6b59e049f4f29c7d4889141f0c6dadf4c
waws520waws/the-god-of-algorithms
/排序方法/选择排序差版.py
465
3.875
4
def select_sort(li): li_new = [] for i in range(len(li)): min_li = min(li) li_new.append(min_li) li.remove(min_li) return li_new """ 存在着两个大的缺点: 1.新创建了一个list的大小和原始数据一边大小,若原始数据2G,那新创建的也会是2G,怕内存吃不消 2.时间复杂度远远大于O(n),因为min和remove都不是O(1)的基本操做。 """ a = [7,3,1,3,2,4,2,5,6] print(select_sor...
8f4e2ffc9f4c734c67f043a486667144a7562e9a
waws520waws/the-god-of-algorithms
/排序方法/python堆排序.py
249
3.84375
4
# 使用python自带的函数heapq完成堆排序 import heapq import random li = list(range(100)) random.shuffle(li) print(li) heapq.heapify(li) # 建堆(小根堆) print(li) n = len(li) for i in range(n): print(heapq.heappop(li),end=",")
8f720cba055fea1dcabd7cccefcfdbcbf0d8d8c4
waws520waws/the-god-of-algorithms
/数据结构/链表/头插法创建链表.py
432
4
4
# 头插法创建链表 class Node(object): def __init__(self, item): self.item = item self.next = None def create_linklist(li): head = Node(li[0]) for element in li[1:]: node = Node(element) node.next = head head = node return head def print_linklist(lk): while lk: ...
27c3f7a048e34e0105258d12256984129c64474b
hellospiral/Alarm-Clock-App
/alarm.py
3,235
3.859375
4
import tkinter as tk import time from tkinter import* class App(): def __init__(self): # Function to inform user that alarm has been set def alarmSet(): global alarmTime global message message = messageEntry.get() tk.messagebox.show...
7bbf9fbf4d2c62545a75f4d1b659a9ff6928a526
Tayacan/AD-examples-python
/fib.py
894
3.84375
4
# -*- coding: utf-8 -*- # Bottom-up fibonacci # Laver en liste af alle fibonacci-tal fra # 0 til n, og returnerer så det nte. def fib(n): if n < 2: return n prev,curr = 0,1 new = -1 for i in range (2,n+1): new = prev + curr prev = curr curr = new return new # memoized fibo...
a07a26e76b0f914df8e17cc7f487e9ea3638cef6
zhrmrz/cesar
/cesar.py
615
3.578125
4
class Solution: def cesar(self,str1,str2): if len(str1)!=len(str2): return value=ord(str2[0])-ord(str1[0]) for i in range(len(str1)): if ((ord(str2[i])>64 and ord(str2[i])<91) or (ord(str2[i])>96 and ord(str2[i])<123)) and ((ord(str1[i])>64 and ord(str1[i])<91) or (or...
04d071771071afef88d874ab9e61ce03b956a62c
Honest-red/Home_task
/task4.py
364
3.875
4
#ДЗ 4. Перевернуть число a = int(input('введите целов трехзначное число:')) a1 = a%10 #print('первое числло ', a1) a11 = (a%100)//10 #print('второе число ', a11) a111 = (a%1000)//100 #print('третье число', a111) b=(a1*100)+(a11*10)+(a111) print('итоговое число ', b)
23dd58877bc3ae5f626508c1d48b3d553a6978a0
buisang123/buiducsang-fundamentals-c4e18
/session 3/Homework/con_cuu.py
511
3.828125
4
menu = [5,7,300,300,24,50,75] print("hello,my name is Hiep and there are my ship size: ") print( *menu,sep=', ' ) print('now my biggest shep has size ',max(menu)," let's shear it ") n = max(menu) while True: print('after shearing, here is my lock ') for i in range(len(menu)): if menu[i] == n: ...
5d21078a17538bdf56891467a75030da0c7e9080
buisang123/buiducsang-fundamentals-c4e18
/session 5/homework/count_bacterias.py
212
3.984375
4
n = int(input("how many bacterias are there? ")) m = int(input("how much time in minutes will we wait? ")) dem = m/2 while dem != 0: n *= 2 dem -= 1 print("after",m,"minutes, we would have",n,"bacterias")
d0202c4d1edf34c7d9c2b594f2940f246d2d1cd6
buisang123/buiducsang-fundamentals-c4e18
/session 5/homework/dictory.py
338
3.78125
4
prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } stock = { "apple": 0, "banana": 6, "orange": 32, "pear": 15 } tong = 0 for k,v in stock.items(): print() print(k) print("stock:",stock[k]) print("price:",prices[k]) zero = stock[k]*prices[k] print('=',zero) tong += zero print...
6fdcbb366004250c085e980ddd6e3bb5c803c3b6
buisang123/buiducsang-fundamentals-c4e18
/ssision 2/ve_hinh _sao.py
483
4.0625
4
# for i in range(3): # print("******") # for i in range(5): # print("#"*5) # print("hello", end=" ") # print("world") # for i in range(3): # for j in range(5): # print("*",end="") # print() # for i in range(6): # for j in range(i): # print("*",end="") # print() for i in ra...
b0c955c8324c8d4a17ade86a89cb1b5e282d9c36
junweitan1999/csci1100
/homework/hw2/hw2_part2.py
1,357
4.53125
5
# this is the function def time_to_seconds(hour,minute,second): time = hour*3600+minute*60+second return time def calculate_years(a,b,c): years = (a-b)/c return years # the main body current_day_length = time_to_seconds(23,56,4) print("The current length of a day is {0} seconds.".forma...
592186c160279f6148ee171039a2d12eb04a1edd
junweitan1999/csci1100
/homework/hw1/hw1_part3.py
995
4.0625
4
word = input("Word => ") print(word) columns = int(input("#columns => ")) print(columns) rows = int(input("#rows => ")) print(rows) print("Your word is:",word+"\n") print("(a)") print(("*** "*columns + "\n")*rows) print("(b)") print(("*** "*columns +"\n")*int(((rows-1)/2))+"*** "*int(((columns-1)/2))+...
d214ae1de551ad145aafc2887d0fae2c9e15d6aa
Martin576/Pacman
/TD TKinter.py
3,271
3.609375
4
import sys import random # Import du module tkinter import tkinter # Creation d'une classe qui herite de la classe tkinter.Tk class MaFenetreGraphique(tkinter.Tk): def __init__(self,largeur=400,hauteur=400, parent = None): tkinter.Tk.__init__(self, parent) #texte label self.monLabel = tkinter.Label(self...
2877ea29b8712b7c0b570fa6f291e822aee72379
Shreyas062796/experience_nyc
/backend/maps/geo.py
1,299
3.515625
4
import googlemaps import sys import json geoencodingkey = "AIzaSyDcnc92jRlww69hL1IA_CXHyh7xo-D9VeI" def addressToGeo(addressStr): gmap = googlemaps.Client(key = geoencodingkey) loc = gmap.geocode(addressStr) # FOR NOW JUST RETURN THE FIRST OPTION FOUND location = loc[0] returnLoc = dict() returnLoc['place_i...
bbc36c5ce171f4803211ab3fca3ead83308e1564
PaulLundgren/Project-Run
/GameFiles/Background.py
1,894
3.671875
4
import pygame import os import sys class Background(): """The background for our game.""" def __init__(self, screen_width, screen_height): #'Lib','GameFiles', for the installer self.image = pygame.image.load(os.path.join(os.path.dirname(sys.executable), 'Lib', 'GameFiles', 'Images', 'backgroun...
1aa2ee749a36397072fa31d0d61b3f10b1a7ccd7
monikarychter/assigments
/rewrite_multiply.py
125
3.640625
4
def multiply(x,y): result = 0 for i in range(y): result += x print(result) multiply(4,6)
b6b824c49a5265e4b575b125cc845447928c866c
isulim/ProsteZadanka
/Zadania1/proste_zadanko_6.py
639
3.65625
4
def count_character(text, letter): if isinstance(letter, str) and len(letter) == 1: if isinstance(text, str): licznik = 0 for character in text.upper(): if character == letter.upper(): licznik += 1 return licznik else: ...
2f35501d860ebcb37a5bdd2d2eebf4a4ccfcfd04
isulim/ProsteZadanka
/Zadania1/proste_zadanko_9.py
398
3.703125
4
from random import randint def domino(count): if isinstance(count, int) and count > 0: lista = [] a, b = 0, 0 for i in range(count): a = randint(0, 6) b = randint(0, 6) lista.append(str(a) + '-' + str(b)) return lista else: return "...
1b5f2774603387fda8acd7d0a65e859863a536d0
Negahead/nlp
/logistic_cost.py
1,330
3.734375
4
import numpy as np class LogisticRegressionGD: """ logistic regression is a model for classification, not regression logistic is a classification model that is very easy to implement but performs very well on linearly separable classes.It is one of the most widely used algorithms for classificatio...
0eff6c2979c193dc385e7579eed86a1385307294
RaviMohan/loaddataframe
/dataset-gen.py
2,707
4.09375
4
import random import string # write row of n random integers into a file def generate_integers_only_data_set_row(f,separator,n,a,b): #assumed f is an open file handle. closing left to caller #f = open(fname,'w') #write n-1 ints followed by commas for i in range (1,n): #the comma should be rep...
244e5e4a4778e2f4d95a1d8fff7b01504f3ada7a
LEEBONGHAK/Python_like_Python
/part6. Itertools and collections 모듈/6.7_가장_많이_등장하는_알파벳_찾기-Counter.py
506
3.609375
4
''' 표준 입력으로 문자열, mystr이 주어진다. mystr에서 가장 많이 등장하는 알파벳만을 사전 순으로 출력하는 코드를 작성 input output 'aab' 'a' 'dfdefdgf' 'df' 'bbaa' 'ab' ''' import collections my_str = input().strip() confirm = collections.Counter(my_str) print(confirm) print("\n") maximum = max(confirm.values()) result = filter(lambda x: x[1] =...
5beeddef40eac015742c8243b072d10ce8826c99
LEEBONGHAK/Python_like_Python
/part3.Str 다루기/3.2_문자열_정렬하기_ljust_center_rjust.py
357
3.5625
4
# 문자열 정렬하기 ''' '가나다라 ' # 좌측 정렬 ' 가나다라' # 우측 정렬 ' 가나다라 ' # 가운데 정렬 ''' s, n = input().strip().split(' ') n = int(n) right_sort = s.ljust(n) print(right_sort) center_sort = s.center(n) print(center_sort) left_sort = s.rjust(n) print(left_sort)
56eb9a0c992ad3b16522806c9b9290e6ed892a0a
LEEBONGHAK/Python_like_Python
/part7.기타/7.3_flag_or_for-else.py
610
3.828125
4
''' 자연수 5개가 주어지며, 1. 숫자를 차례로 곱해 나온 수가 제곱수1가 되면 found를 출력하고 2. 모든 수를 곱해도 제곱수가 나오지 않았다면 not found를 출력 예시 1 예시 2 입력 입력 2 5 4 1 2 2 5 3 1 1 출력 출력 found not found ''' from math import sqrt check = 1 for i in ...
47dae3417439cf4fd0cb8eddc2856607e8cc8079
diablo0316/algorithmstudy
/MyArray2.py
1,171
3.671875
4
class MyArray2: def __init__(self, capacity): self.array = [None] * capacity self.size = 0 def insert_v2(self, index, element): # 判断下标是否超出范围 if index < 0 or index > self.size: raise Exception("超出数组实际元素范围!") # 如果实际元素达到数组容量上限,数组扩容 if self.size >= len(se...
e9b457069e0fdddcfbdea93d751df4df436c5487
TianYuWang1996/mystuff
/ex44b.py
349
3.984375
4
## 一个显式覆盖的例子 class Parent(object): def override(self): print("PARENT override()") class Child(Parent): def override(self): print("CHILD override()")##定义了一个与父类相同的方法函数 ##对父类的方法进行了覆盖 dad = Parent() son = Child() dad.override() son.override()
1c19d6e09913c235567011f9024961ab6214371e
TianYuWang1996/mystuff
/ex43_2.py
6,725
3.65625
4
from sys import exit from random import randint class Scene(object): def enter(self): print("This scene is not yet configured. " "Subclass it and implement enter().") exit(1) class Engine(object): def __init__(self, scene_map): self.scene_map = scene_map ...
49fe30601847cf0de4d62c34f3fa7fa084f99cf2
chatchad/Machine-Learning
/Linear Regression/linear_reg.py
1,034
3.609375
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt import os os.chdir(r'g:\\Programs\\python\\Machine Learning\\Linear Regression') datas = pd.read_csv('example.csv') print(datas.shape) datas.head() X = datas[datas.columns[0]].values Y = datas[datas.columns[1]].values print(X) print(Y) mean_x = ...
761f0ff6afcab479b696794a3b969968f566414c
MrMicrowaveOven/nqueens_python
/lib/board.py
3,815
3.78125
4
from space import Space class Board: def __init__(self, size, prefill = []): self.size = size spaces = [0] * size for i in range(size): row = [] for j in range(size): row.append(Space()) spaces[i] = row self.spaces = spaces ...
3d1dcd5a05419f53627e4e1e50f5282c8b036c3c
hanjiyou/LearnPython
/SublimeProject/LearnFromRunoob/Day5_Error.py
857
3.65625
4
# -*- coding: utf-8 -*- # @Author: Marte # @Date: 2019-03-15 17:24:31 # @Last Modified by: Marte # @Last Modified time: 2019-03-18 19:50:14 def this_fails(): x=1/0 try: this_fails() except ZeroDivisionError as err: print("Handling run-time error:",err) #raise#抛出异常 else: print('执行else') finally:#定义了无论在任何情况下都会执...
62af994fcee9bdba6802c8b52348f4bd4fceb1b4
rogeriosouzax/jogos
/forca.py
1,322
3.875
4
from random import randrange def jogar(): print('********************************') print('***Bem vindo ao jogo da forca***') print('********************************') with open("frutas", mode="r") as fruta: frutas = fruta.read().split("\n") index = randrange(0, len(frutas)) palavra...
a3f11933f9bced2f3c41769aee59a8f84b8423ec
viktorstaikov/hearthstone-deck-classifier
/hearthstone-deck-classifier/Classifiers/kNN.py
2,479
3.515625
4
from heapq import heappush class KNearestDecks(object): """ Finds the decks that are most similar to a set of cards. """ MAX_CARDS_IN_DECK = 30 def __init__(self): self.decks = {} self.card_count = {} def update_deck(self, deck_entry): """ Adds a card to its corresponding de...
9658e090be81c2824ba0f453b00dd4bb616fa00a
thiagarajan-tutoring/introduction-to-image-filtering-starter
/visualization/output_image.py
591
3.765625
4
import matplotlib.pyplot as plt import numpy as np def save_image(image, output_fp): """Saves `image` to file at location `output_fp`. Args: image (np.ndarray): a NumPy array corresponding to the image output_fp (str): a file path to save the image at Hint: When saving the image,...
90d433aa77a7a3c6fcb22a9e513d4c439d271aad
khoapulga/Python-basic
/String.py
2,134
4.09375
4
#Chuoi string = "this is a man" string2 = " who met me yesterday" string3= string+"\n"+string2 print(string3) string4 = string2 * 3 print(string4) #kiem tra chuoi trong chuoi string5 = string2 in string print(string5) #lay ki tu trong chuoi chuoi = string[2] print(chuoi) #lay ki tu cuoi trong chuoi chuoi2 = string[len(...
c9f129adc21b7a054513ef85ce5ae3c2bc76dec3
robpalbrah/RedditDailyProgrammer
/easy/dp_229_easy.py
521
3.6875
4
""" [2015-08-24] Challenge #229 [Easy] The Dottie Number https://tinyurl.com/dp-229-easy """ # Status: Done import math def foxed_cox(number): """Finds a fixed point of cosine""" cos_number = math.cos(number) print(cos_number) difference = math.fabs((number - cos_number) / number) if dif...
4875ab08f9ed02f89c552e44075891c84b573b24
robpalbrah/RedditDailyProgrammer
/easy/dp_220_easy.py
2,444
4
4
""" [2015-06-22] Challenge #220 [Easy] Mangling sentences https://tinyurl.com/rDP-220-Easy """ # Status: Done import string def mangle_word(word): """Takes a single word and arranges it's letters in alphabetical order. Leaves numbers and punctuation in place. Capital letters retain their positions. Retu...