blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1bb7abfbcd9880fb10dda10b8f0e503ad2721f86
benbendaisy/CommunicationCodes
/python_module/examples/1557_Minimum_Number_of_Vertices_to_Reach_All_Nodes.py
1,301
3.859375
4
from typing import List class Solution: """ Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi. Find the smallest set of vertices from which all nodes in the graph are reac...
8d5842cc654a7d88038f7a7b49d8b93c60bb3138
benbendaisy/CommunicationCodes
/python_module/examples/309_Best_Time_to_Buy_and_Sell_Stock_with_Cooldown.py
2,449
3.953125
4
import math from functools import lru_cache from typing import List class Solution: """ You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell on...
8ef4b91f2a4387024e1c274cdf26493da1993454
benbendaisy/CommunicationCodes
/python_module/examples/342_Power_of_Four.py
843
3.90625
4
class Solution: """ Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. Example 1: Input: n = 16 Output: true Example 2: Input: n = 5 Ou...
2c10049803a19a86a6fead5935fc0f9ee44fd7aa
benbendaisy/CommunicationCodes
/python_module/examples/1011_Capacity_To_Ship_Packages_Within_D_Days.py
2,101
4.3125
4
from typing import List class Solution: """ A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). ...
44c454d1bb050794cd6643d9b9c238a9f28728be
benbendaisy/CommunicationCodes
/python_module/examples/find_all_sub_sequence_strings.py
1,743
3.71875
4
from typing import List class Solution: # Below is the implementation of the above approach def printSubsequence(self, input, output): # Base Case # if the input is empty print the output string if len(input) == 0: print(output, end=' ') return # outpu...
5129f03ab46da5fc4408285eb931dc0771ad12c7
benbendaisy/CommunicationCodes
/python_module/examples/reverse_only_letters.py
836
3.578125
4
class Solution: def reverseOnlyLetters(self, s: str) -> str: if not s: return s arr = [x for x in s if x.isalpha()] res = [] for ch in s: if ch.isalpha(): res.append(arr.pop()) else: res.append(ch) return ""....
e632b1a248442c7766e239f3081273c7f182d287
benbendaisy/CommunicationCodes
/python_module/examples/268_Missing_Number.py
1,654
4.0625
4
from typing import List class Solution: """ Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, ...
9d41f44f4a109d5b3d9fcf7d6b14da966f23f010
benbendaisy/CommunicationCodes
/python_module/examples/379_Design_Phone_Directory.py
2,122
3.9375
4
class PhoneDirectory: """ Design a phone directory that initially has maxNumbers empty slots that can store numbers. The directory should store numbers, check if a certain slot is empty or not, and empty a given slot. Implement the PhoneDirectory class: PhoneDirectory(int maxNumbers) Initi...
b7e1d824c070470ef02ac97495ee2951a390f944
benbendaisy/CommunicationCodes
/python_module/examples/219_Contains_Duplicate_II.py
927
3.71875
4
from collections import defaultdict from typing import List class Solution: """ Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. Example 1: Input: nums = [1,2,3,1], k = 3 ...
35d3ba89c3e1e4ef5bc2076840a56a1bfec3a1f0
benbendaisy/CommunicationCodes
/python_module/examples/802_Find_Eventual_Safe_States.py
1,985
4.09375
4
from typing import List class Solution: """ There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nodes adjacent to node i, meaning there is an edge from node i to each node in graph[i]....
8b2d09027e1fe0263e576636da84942342be7b89
benbendaisy/CommunicationCodes
/python_module/examples/418_Sentence_Screen_Fitting.py
2,196
4.34375
4
from functools import lru_cache from typing import List class Solution: """ Given a rows x cols screen and a sentence represented as a list of strings, return the number of times the given sentence can be fitted on the screen. The order of words in the sentence must remain unchanged, and a word c...
9ef6abdcf61de6d2fc3d6b60f1173216bb933f36
benbendaisy/CommunicationCodes
/python_module/examples/746_Min_Cost_Climbing_Stairs.py
1,779
4.28125
4
from functools import lru_cache from typing import List class Solution: """ You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with ind...
aee87f4b237eff306107a1d1e9f7761ac966e7ad
benbendaisy/CommunicationCodes
/python_module/examples/766_Toeplitz_Matrix.py
1,616
4.4375
4
from typing import List class Solution: """ Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Example 1: Input: matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2...
489aa1eb02904e1347c4422c4e870c66bd85479c
benbendaisy/CommunicationCodes
/python_module/examples/297_Serialize_and_Deserialize_Binary_Tree.py
5,738
4
4
# Definition for a binary tree node. import collections class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Codec1: """ Serialization is the process of converting a data structure or object into a sequence of bits so that it can...
293c91ce1c36eb096c1cbbc698d2fe2a0934d375
benbendaisy/CommunicationCodes
/python_module/examples/329_Longest_Increasing_Path_in_a_Matrix.py
818
3.65625
4
from functools import lru_cache from typing import List class Solution: def longestIncreasingPath(self, matrix: List[List[int]]) -> int: directions = {(0, -1), (0, 1), (1, 0), (-1, 0)} @lru_cache(None) def longestIncreasingPathes(x: int, y: int) -> int: longestPath = 1 ...
1b2fa348941dff331a3e4b2ab9b50e51acedd4bc
benbendaisy/CommunicationCodes
/python_module/examples/1926_Nearest_Exit_from_Entrance_in_Maze.py
3,195
4.15625
4
from collections import deque from typing import List class Solution: """ You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column...
7f2a49a97105a86de83186f0070d17af34a2207e
benbendaisy/CommunicationCodes
/python_module/examples/468_Validate_IP_Address.py
2,256
4.03125
4
import string class Solution: """ Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type. A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leadin...
8b1161446b6bcdd4d763487e1437a02d1a8e31f6
benbendaisy/CommunicationCodes
/python_module/examples/844_Backspace_String_Compare.py
906
3.65625
4
class Solution: def backspaceCompare1(self, s: str, t: str) -> bool: def normalizedString(str1: str) -> str: chars = list(str1) for i in range(1, len(str1)): if chars[i] == "#": r = i while r > 0 and chars[r] == "#": ...
b720d355e0a493a00eaf35ad9ceb4872f9881476
benbendaisy/CommunicationCodes
/python_module/examples/441_Arranging_Coins.py
891
4.09375
4
class Solution: """ You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the ith row has exactly i coins. The last row of the staircase may be incomplete. Given the integer n, return the number of complete rows of the staircase you will build. Exa...
a72bba3e569b736e68904f9c8bb8e6f2d5d95e76
benbendaisy/CommunicationCodes
/python_module/examples/744_Find_Smallest_Letter_Greater_Than_Target.py
1,305
4.15625
4
from typing import List class Solution: """ You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters. Return the smallest character in letters that is lexicographically greater than target. If such ...
1b49b915b38a4abd037165be199671bfe38a670d
benbendaisy/CommunicationCodes
/python_module/examples/540_Single_Element_in_a_Sorted_Array.py
1,091
3.921875
4
from typing import List class Solution: """ You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element that appears only once. Your solution must run in O(log n) time and...
a35fad7d804d64efe19bc152f07444eba4f29f86
benbendaisy/CommunicationCodes
/python_module/examples/605_Can_Place_Flowers.py
1,026
4.15625
4
from typing import List class Solution: """ You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer ...
0eb12d7503cd7d67a44c337037e72ff06d4304b9
benbendaisy/CommunicationCodes
/python_module/examples/345_Reverse_Vowels_of_a_String.py
1,397
3.9375
4
class Solution: """ Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once. Example 1: Input: s = "hello" Output: "holle" Example 2: ...
2bbfa36216a103bd20f772600da8f64dc324e5a3
benbendaisy/CommunicationCodes
/python_module/examples/91_Decode_Ways.py
2,543
4.28125
4
from functools import lru_cache class Solution: """ A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then mapped back in...
1795efb88e3649def6135ae842a3558f1570d3eb
benbendaisy/CommunicationCodes
/python_module/examples/1020_Number_of_Enclaves.py
1,485
3.90625
4
from typing import List class Solution: """ You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell. A move consists of walking from one land cell to another adjacent (4-directionally) land cell or walking off the boundary of the grid. Return...
7be6e60a8ac184785a3e6e76396aed2128b858f4
benbendaisy/CommunicationCodes
/python_module/examples/449_Serialize_and_Deserialize_BST.py
2,097
4
4
# Definition for a binary tree node. import collections from typing import Optional class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Codec: """ Serialization is converting a data structure or object into a sequence of bits so that it...
03401932ddfa98313456a497f49017a2d5ab3c17
benbendaisy/CommunicationCodes
/python_module/examples/989_Add_to_Array-Form_of_Integer.py
1,203
4.1875
4
from typing import List class Solution: """ The array-form of an integer num is an array representing its digits in left to right order. For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form of an integer, and an integer k, return the array-form of the intege...
cc55fb364e95f4bb1fbcedbbd50d9bac70bb5f31
benbendaisy/CommunicationCodes
/python_module/examples/20_Valid_Parentheses.py
1,098
4.0625
4
class Solution: """ Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. ...
06cf706ef84b1814d0bab1b41e82859360ff75cd
benbendaisy/CommunicationCodes
/python_module/examples/1721_Swapping_Nodes_in_a_Linked_List.py
964
4
4
# Definition for singly-linked list. from typing import Optional class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: """ You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the...
fbcbab4de80c2748f69d22f48b88cb9f0f787d64
benbendaisy/CommunicationCodes
/python_module/examples/547_Number_of_Provinces.py
1,220
4.25
4
from typing import List class Solution: """ There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c. A province is a group of directly or indirectly conne...
1ac2b5b5169b9921d493d42bcbe5534802ac73cc
benbendaisy/CommunicationCodes
/python_module/examples/415_Add_Strings.py
1,871
3.9375
4
class Solution: """ Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers dir...
595fdc008065e3dde312d09a2fa126c0a8df4d81
benbendaisy/CommunicationCodes
/python_module/examples/1857_Largest_Color_Value_in_a_Directed_Graph.py
3,348
4.09375
4
from collections import defaultdict from typing import List class Solution: """ There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1. You are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in t...
e24db7a6897f3b1612d07724dafb14608cf634e0
benbendaisy/CommunicationCodes
/python_module/examples/2095_Delete_the_Middle_Node_of_a_Linked_List.py
2,494
4.21875
4
# Definition for singly-linked list. from typing import Optional class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: """ You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. ...
79253743fc6560251f018c06e07755bf4c94c98e
benbendaisy/CommunicationCodes
/python_module/examples/403_Frog_Jump.py
1,630
4.625
5
from functools import lru_cache from typing import List class Solution: """ A frog is crossing a river. The river is divided into some number of 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' ...
0a4232458c7f702468f8aa5c7f596e6c3f550225
benbendaisy/CommunicationCodes
/python_module/examples/1383_Maximum_Performance_of_a_Team.py
2,238
3.859375
4
import heapq from typing import List class Solution: """ You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the ith engineer respectively. Cho...
24079269479f5822a656cd72f5e7183029806c0a
benbendaisy/CommunicationCodes
/python_module/examples/5_Longest_Palindromic_Substring.py
1,407
3.984375
4
class Solution: """ Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Constraints: 1 <...
896af2e7efc35c2878f33ffbe15c49616facc3c6
benbendaisy/CommunicationCodes
/python_module/examples/837_New_21_Game.py
1,798
3.796875
4
class Solution: """ Alice plays the following game, loosely based on the card game "21". Alice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number of points randomly from the range [1, maxPts], where maxPts is an integer. Each draw is indep...
f889f9bb952ad305c6018399bd6891e3732e471f
benbendaisy/CommunicationCodes
/python_module/examples/281_Zigzag_Iterator.py
735
3.578125
4
from typing import List class ZigzagIterator: def __init__(self, v1: List[int], v2: List[int]): self.arr = [] for vl1, vl2 in zip(v1, v2): self.arr.append(vl1) self.arr.append(vl2) if len(v1) > len(v2): self.arr.extend(v1[len(v2):len(v1)]) elif l...
6914e99d3c28cad71bde1d88ccaa3bb13c2910fc
benbendaisy/CommunicationCodes
/python_module/examples/51_N-Queens.py
1,685
4.1875
4
from typing import List class Solution: """ The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order. Each solu...
e403b4d8f3e67fcc613a4f0a289f05eb344eb924
benbendaisy/CommunicationCodes
/python_module/examples/462_Minimum_Moves_to_Equal_Array_Elements_II.py
1,827
3.953125
4
import random from typing import List class Solution: """ Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment or decrement an element of the array by 1. Test cases are designed so that the ans...
56b64e837f8b454939bec6abcf9c2d82f5619335
benbendaisy/CommunicationCodes
/python_module/examples/1351_Count_Negative_Numbers_in_a_Sorted_Matrix.py
774
4.15625
4
from typing import List class Solution: """ Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid. Example 1: Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]] Output: 8 Explanation: There ...
876876514cc24584828733da33a574b22fe55045
benbendaisy/CommunicationCodes
/python_module/examples/93_Restore_IP_Addresses.py
1,546
4.125
4
from typing import List class Solution: """ A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses, but "0.011.255.245", "192.168....
1dda95cd64044ef3393276337b13ed25023a2b00
benbendaisy/CommunicationCodes
/python_module/examples/2551_Put_Marbles_in_Bags.py
1,521
3.828125
4
from typing import List class Solution: """ You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k. Divide the marbles into the k bags according to the following rules: No bag is empty. If the ith marble...
2430e84bb54101352be80e634584e72157bf7aed
benbendaisy/CommunicationCodes
/python_module/examples/448_Find_All_Numbers_Disappeared_in_an_Array.py
844
4.09375
4
from typing import List class Solution: """ Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. Example 1: Input: nums = [4,3,2,7,8,2,3,1] Output: [5,6] Example 2: ...
0695528aa2f0f2154e80d55c7bd40832c10b5f30
benbendaisy/CommunicationCodes
/python_module/examples/218_The_Skyline_Problem.py
7,992
4
4
import heapq from typing import List # Define the disjoint-set structure. class UnionFind(): def __init__(self, N): self.root = list(range(N)) def find(self, x): if self.root[x] != x: self.root[x] = self.find(self.root[x]) return self.root[x] def union(self, x, y): ...
85db0ddab1f19bb9b14eadad269eb1aba49f11ab
benbendaisy/CommunicationCodes
/python_module/examples/804_Unique_Morse_Code_Words.py
2,191
4.25
4
import string from collections import Counter from typing import List class Solution: """ International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' maps to "-...", 'c' maps to "-.-.", and so o...
01306bbcf0539a047bcfa69168a0dbcae000d29d
benbendaisy/CommunicationCodes
/python_module/examples/242_Valid_Anagram.py
973
3.890625
4
from collections import Counter class Solution: """ Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. ...
1c510ff7f59764801f4d289ce97e39918aee9ab5
banshica/Python-Programs
/String-Concat.py
147
3.984375
4
# #python string concatenation # # First_name="Banshica" Middle_name="A" Last_name="Singh" print(First_name+" "+Middle_name+" "+Last_name)
35e709e32fbbdfaffef976cf3cf8ba60dc702320
dsc-vast/Algorithms
/Python/largest_of_3.py
315
3.984375
4
a=int(input("Enter 1st number: ")) b=int(input("Enter 2nd number: ")) c=int(input("Enter 3rd number: ")) def check(a,b,c): if (a>b): if(a>c): return a else: return c else: if(b>c): return b else: return c print(check(a,b,c))
84d6a12d75877557180a10a95f37a02b14245167
HarryBMorgan/Nuclear_Astrophysics_Programmes
/Nuclear_Physics/nuclear_radii.py
997
4.625
5
#Nuclear Radii #This programme estimates the radii of a nucleus based on the atomic number. #Making the calculation into a funtion in case I need to expand the programme. def nuclear_radii(A): return A**(1/3) if __name__ == "__main__": #Adding ability to calculate ratio of atomic radii for past paper exam ...
3fdcc97ea0cb0cb5333fc696e27e10d390403b54
abpwrs/thee-flying-chicken
/ml_scraping/src/NLTK/tutorial/nltk_stemmers.py
432
3.65625
4
from nltk.stem import PorterStemmer from nltk.tokenize import word_tokenize ps = PorterStemmer() example_words = ["python","pythoner","pythoning","pythoned","pythonly"] ''' for w in example_words: print(ps.stem(w)) ''' new_text = "It is very important to be pythonly while you are pythoning with python. All pytho...
2d44848118aee04725e45bdf48a797e1a5db8b7a
Mohsen-Kalantar/Day2AM
/testMysql.py
2,314
4.0625
4
''' show databases show tables use database-name create database database-name drop database database-name create table product (name varchar(20) primary key, price float, qty int) describe product drop table product # to delete the whole table insert into product values ('Prod1', 34.56, 23) select * from...
75c7cebfaf73921c97a5793653e044299354822e
wsheehan/project_euler
/1-25/python/problem2.py
460
3.796875
4
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. su...
dec1cf0a0e225dc77e9747ace523765e14f28d72
ceewick/introClasses
/udemy4PillarsOOP/moreClassesUdemy.py
686
3.8125
4
#class Employee(): # def employeeDetails(self): # self.name = 'Ben' # # @staticmethod # def welcomeMessage(): # print('Welcome to our organization!') ### Static method = method without using self # #employee = Employee() #employee.employeeDetails() #print(employee.name) #employee....
57ab2d3d61a2e6dd3fcd5fc84181cabfade8c243
AlexTan331/cuny-ttp-algo-summer2021
/xiaqianZhang/assignments/twopointers/lc1/lc1.py
1,892
4.03125
4
# Problem Statement # # Given an array of sorted numbers and a target sum, find a pair in the array whose sum is equal to the given target. # Write a function to return the indices of the two numbers (i.e. the pair) such that they add up to the given target. # input: sorted list that may including negative numbers, t...
012db9d58b460d338e8a0026defc09710e07237e
110922826/MITx-6.00.2x-Introduction-to-Computational-Thinking-and-Data-Science
/week5/ProblemSet4/ps4.py
4,915
3.53125
4
# 6.00.2x Problem Set 4 import numpy import random import pylab from ps3b import * # # PROBLEM 1 # def simulationDelayedTreatment(numTrials): """ Runs simulations and make histograms for problem 1. Runs numTrials simulations to show the relationship between delayed treatment and patient outco...
36a0aefc8a4a40997ae57e75232413d626c4bd97
ThomasAllanLamb/operatoralpha
/operation.py
10,241
4.0625
4
#the identity of a given n def identity (n): if n == 1: # addition return 0 elif n >= 2: return 1 computed = [[[]]] def store (m, n, u, r): #ensure the array has sufficient dimension while (len(computed) <= m): computed.append([[]]) while (len(computed[m]) <= n): computed[m].append([]) ...
e4fa29d63f9888c1219d719c9c232fec9d1af148
ZhiliWang/Spaceship
/spaceship_driver.py
5,269
4.03125
4
######################################################################## # Zhili Wang # # # # Note: Driver of the Spaceship game program # # * CH...
5c3dd3cfc40ae08ba4ab501e312f1eaec5e1ca7e
PSarapata/ShawBasic
/ex24.py
1,024
4.09375
4
print("More practice.") print('Let us use escape sequences \\ that insert:') print('\n new lines and \t tabs') poem = """ \t This beautiful world with its' strict logics cannot see the \n love calling nor the passion for the feeling and it needs explanation, \n\t\tyet there is none. """ print('-------------------') p...
da4f272d3f6a51b66eabe03c0da25bc505acc248
PSarapata/ShawBasic
/ex11.py
254
4
4
print("How old are you?", end=' ') age = input() print("How tall are you (centimeters)?", end=' ') height = input() print("What is your weight (kg)?", end=' ') weight = input() print("So, your age is {age}, you're {height} and you weigh {weight} kgs.")
f48810eff351be4434076297b50d82bca3cddcf9
liquidscience/Python_Scrapes
/yourstory.py
1,293
3.515625
4
#Author - Samaksh Yadav #Description - The following scraper scrapes rencent content available at YOURSTORY.COM #Version 1.0 from urllib2 import urlopen from bs4 import BeautifulSoup html = urlopen('http://yourstory.com/ys-stories/') bsObj1 = BeautifulSoup(html,"html.parser") resultset= bsObj1.findAll("a",attrs={...
87530ba86259f38eae42c1694fa7d9231cf6a7a1
p-alisson/IABusca
/teste_romania.py
1,763
3.53125
4
import os from busca import BFS, DFS, DFSV, IDS, DLS, UCS, GBFS, AS, BS from classes import Problema from mundos import map_romania, HSLD QTD_ITERACOES = 20 INICIO_MAP = "Oradea" OBJETIVO_MAP = "Bucharest" def menu(problema): print("1: BUSCA EM LARGURA:") print("2: BUSCA EM PROFUNDIDADE LIMITADA:") print...
2872ff33047f329c1c65a624787bfbf58d721312
legalgps/FSDI108_Cohort
/test2.py
686
4.15625
4
class Student: def __init__(self, name, age): # class constructor - the init method on Python self.name = name self.age = age def say_hello(self): print("Hi there! My name is " + self.name) print("***************Test2*********") student1 = Student("Chris Daming"...
392ee8cbf2c5dbf84c4c9dc040421b16b015288b
META-DREAMER/tactics
/gather.py
3,390
3.765625
4
def gather(transport, unit_list, value): """ Finds the maximum possible "value" of troops that can be loaded in to the remaining space of a transport. Input: transport - The transport unit to be loaded. unit_list - The list of units that can be loaded onto transport. You may assume tha...
f5940b04f50ce593614b6c0dd08e8a0018bddd77
EmilianStankov/HackBulgaria
/week0/problem 18 - is_increasing/solution.py
300
3.9375
4
def is_increasing(seq): is_increasing = False for element in seq: if len(seq) == 1: is_increasing = True break if seq.index(element) < len(seq) - 1: if element < seq[seq.index(element) + 1]: is_increasing = True else: is_increasing = False break return is_increasing
53e9074ceab349f227ae841c3255997998b1796e
EmilianStankov/HackBulgaria
/week0/bonus round 2 - magic string/solution.py
275
3.921875
4
def magic_string(s): count = 0 if (len(s) % 2) != 0: return "String is not of even length" else: for char in range(int(len(s) / 2)): if s[char] == '<': count += 1 for char in range(int(len(s) / 2), len(s)): if s[char] == '>': count += 1 return count
170c451e2aadde225d2bdf7bdc3938580f287ef0
EmilianStankov/HackBulgaria
/week0/problem 33 - magic_square/solution.py
766
3.703125
4
def magic_square(matrix): forward_main_diag = 0 backward_main_diag = 0 columns_sum = 0 rows_sum = 0 columns = [0] * int(len(matrix)) rows = [0] * len(matrix) is_magic_square = False for i in range(len(matrix)): forward_main_diag += matrix[i][i] backward_main_diag += matrix[len(matrix) - i - 1][i] for j i...
2d395a04fa6ad328bb7c80df804771fd25a64854
EmilianStankov/HackBulgaria
/week0/problem 34 - sudoku_solved/solution.py
887
3.765625
4
def sudoku_solved(sudoku): columns_sum = 0 rows_sum = 0 columns = [] * 9 rows = [0] * 9 is_solved = False subsquares = [0] * 9 needed = [[1, 2, 3, 4, 5, 6, 7, 8, 9]] * 9 sudoku_list = [] for i in range(9): sudoku_list += sudoku[i] for j in range(9): columns.append(sudoku[j][i]) for i in range(82): ...
8ae8fd7e767ac25bf40052328ed48185ed5bce52
DivyaReddyNaredla/python_classes
/Even and odd.py
217
4.3125
4
print ( " Check whether the number is odd or even by just entering a value in variable A .") a = int(input("Enter a: ")) if (a%2==0): print (a," Is even") else: print (a, "Is odd")
6ab15876cef37cc940a7f4105b35335f6deba01a
DivyaReddyNaredla/python_classes
/Bank_class.py
1,535
4.1875
4
class Bank_Account: def __init__ (self): self.balance=int(input("Enter the balance to add into your account: ")) def withdraw(self,withdrawamount): self.balance = self.balance-withdrawamount print("Available amount is : ",self.balance) def deposit(self,depositamount): ...
cf42512fd54d9cc4031131b82cceebe6c9bbe5a9
DivyaReddyNaredla/python_classes
/class_eg2.py
374
3.78125
4
from class11 import Mlti_Table n =int(input("Enter the table of number you want: ")) m = Mlti_Table() m.mltitable(n) from class11 import Triangle rows = int(input("Enter the no of rows to print: ")) t = Triangle() t.triangle(rows) from class11 import Example name = input("Enter name: ") age = int(input("E...
9d2376f38082450bb1d038eff2b4f84e1477424d
DivyaReddyNaredla/python_classes
/list input.py
646
4.03125
4
lst1 = [] lst2 = [] lst3 = [] length_lst1=int(input("Enter the length of lst: ")) print() for a in range(1,length_lst1+1): elements_lst=input("enter elements for list 1: ") lst1.append(elements_lst) print() for a in range(1,length_lst1+1): elements_lst=input("enter elements for list 2:...
03a99f271a5708758bc6f58db9cabbcb846070e8
DivyaReddyNaredla/python_classes
/ex.py
79
3.84375
4
p = ("1,2,3,4") #s = input("Enter q to display : ") #if p == 'q': print(p)
6cc604e50fe0cadf5ca2a45c1e90384feb047c2b
DivyaReddyNaredla/python_classes
/Exercise_perimeter_rectangle.py
233
4.03125
4
# area and perimeter of rectangle a = int(input(" Enter the length of rectangle : ")) b = int(input(" Enter the breadth of rectangle : ")) c= 2*(a+b) print("area of rectangle is",a*b) print("perimeter of rectangle is",c)
0e7ef4ef44bcfcfdf90f0c69c886ffa906512a3e
riokko/lesson2
/while_practice.py
1,445
3.71875
4
# 1. Напишите функцию ask_user(), которая с помощью input() спрашивает пользователя # “Как дела?”, пока он не ответит “Хорошо” # 2. Создайте словарь типа "вопрос": "ответ", например: {"Как дела": "Хорошо!", # "Что делаешь?": "Программирую"} и так далее # 3. Доработайте ask_user() так, чтобы когда пользователь в...
2d1ef868d9e16c125d971465ef17423d0345365b
dcfernandez1023/HangmanLearner
/Hangman_Learner.py
11,468
3.625
4
import random class Hangman_Learner: def __init__(self): #self.guesses = guesses self.alphabet = ["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"] self.vowels = ["a", "e", "i", "o", "u"] ...
127d3c3424308871b6157a51c552a70d1e397bc4
rathoddilip/BasicPythonPractice
/conditional_statement.py
310
3.984375
4
a = 100 b = 102 if a > b: print("the value of a is greater than b") elif a == b: print("a is equal to b") elif a != b: print("a is not equal to b") else: print("The value of a is less than b") # ----------------------------------------------------- # in keyword a = [32, 5, 3] print(30 in a)
5c160e6dcee51b332f06f6f60e1801e670f5a155
ozenerdem/HackerRank
/PYTHON/Easy/The Captain's Room.py
1,230
4.0625
4
""" Mr. Anant Asankhya is the manager at the INFINITE hotel. The hotel has an infinite amount of rooms. One fine day, a finite number of tourists come to stay at the hotel. The tourists consist of: → A Captain. → An unknown group of families consisting of K members per group where K ≠ 1. The Captain was given a separ...
36cee93b41b8557f2418943481f78fa5e1e88b40
ozenerdem/HackerRank
/PYTHON/Easy/If-Else.py
713
4.28125
4
""" Task Given an integer, n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird Sample Input 1 24 Sample Output 1 Not ...
fcc5398c4c9895609a29804555a6a015bbd985f8
ryan-berkowitz/python
/Python Exercises Folder/Python Syntax.py
145
3.828125
4
#Correct Syntax if 5 > 2: print("Five is greater than two!") #Incorrect Syntax (no indentation) #if 5 > 2: #print("Five is greater than 2!")
9fb8da71095cf80751b604a04a061fab69a49d42
hidekuma/algorithms
/codility/temp.py
342
3.515625
4
def solution(T): summer = [] winter = [] for n in range(1,len(T)): if T[0] < T[n]: summer.append(T[n]) else: winter.append(T[n]) winter.append(T[0]) print(summer) print(winter) print() return len(winter) solution([5,-2,3,8,6]) solution([-5,...
c8916610573b2709949bb0c44e96a2b9594a0f38
JieMEI1994/machine_learning_from_scratch
/deep learning/function/linear_function.py
318
3.625
4
import numpy as np class linear: def forward(self, X, W, b): Z = np.dot(X, W) + b return Z def backward(self, dZ, X, W, b, m): dW = (1.0 / m) * np.dot(X.T, dZ) db = (1.0 / m) * np.sum(dZ, axis=0, keepdims=True) dX = np.dot(dZ, W.T) return dX, dW, db
01058effa3e036046f825477606b261e1f698a04
sanupanji/python
/practice_w3resource/22_count_number_in_list.py
181
3.671875
4
# Write a Python program to count the number 4 in a given list def count_number(ls): return ls.count(4) print(count_number([1,432,23,5,346,54,4,3,4,4,4,4,4346475,5]))
c1fe4e21e1b8cc5b0e3e8c4e33f5f6b738b943b5
sanupanji/python
/function_exercises/function1.py
716
4.40625
4
# write a function that returns the lesser of two given numbers if both numbers are even # but returns the greater if one or both numbers are odd def greater(num1, num2): if num1 % 2 == 0 and num2 % 2 == 0: if num1 < num2: return num1 else: return num2 else: if...
1baae9e3bac6f5acbf85d79e74177f2b559fe79d
sanupanji/python
/function_exercises/function4.py
349
4.15625
4
# write a function that capitalizes the first nd fourth letters of a name # def capitalize(name): # return name.replace(name[0], name[0].upper(), 1).replace(name[3], name[3].upper(), 1) # or # return name[:3].title() + name[3:].title() # or return name[:3].capitalize() + name[3:].capitalize() pr...
065fc91fb12f6c76bda7f1d70c8d6b787050c098
sanupanji/python
/function_exercises/function9.py
527
4.09375
4
# given three integers between 1 and 11, if their sum is less then or equal # to 21, return their sum. if their sum exceeds 21 and there's an eleven, reduce the total sum by 10, finally, if the sum (even after adjustment)exceeds 21, return "BUST" # 5,6,7 --> 18 # 9,9,9 --> 'BUST' # 9,9,11 --> 19 (one of the number is...
7fd3fde695f88973085423885d90dcb432c67081
sanupanji/python
/practice_w3resource/10_int_as_str.py
322
4
4
''' Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn. Go to the editor Sample value of n is 5 Expected Result : 615 ''' def int_as_str(i): # return i+11*i+111*i return i+int(f"{i}{i}")+int(f"{i}{i}{i}") print(int_as_str(int(input("Enter an integer : "))))...
fc4979e2c0e10f7a20c1e2544cae1af8efc59138
sanupanji/python
/practice_w3resource/14_diff_date.py
320
3.96875
4
''' Write a Python program to calculate number of days between two dates. Sample dates : (2014, 7, 2), (2014, 7, 11) Expected output : 9 days ''' from datetime import date def diff_date(t1,t2): return abs(date(t1[0],t1[1],t1[2])- date(t2[0],t2[1],t2[2])) print(diff_date((2019,2,2),(2019,2,3)))
5b2d6fa5be93642b88953af66a1a4a302f82d202
sanupanji/python
/practice_w3resource/27_list_to_str.py
210
4.125
4
''' Write a Python program to concatenate all elements in a list into a string and return it. ''' def list_to_str(lst): return ' '.join(lst) print(list_to_str(["sanu","panji","name","my"]))
fc734eaef5fa4f131ba79753e1659157ee961127
sanupanji/python
/practice_w3resource/24_check_vowel.py
383
4.09375
4
''' Write a Python program to test whether a passed letter is a vowel or not ''' def vowel_check(ch): if len(ch) != 1: return "wrong input !!!" elif ['a','e','i','o','u'].count(ch.lower()) == 1: return "Entered charecter is vowel" return "Entered charecter is not vowel" ...
a51d14e29db65fc03786273f5d5de994d4f65cd0
The-Mysterous-Coder/Math-Adventure
/adventure.py
1,036
3.890625
4
answer = input("Would you like to play? (yes/no) ") if answer.lower().strip() == "yes": answer = input("\nYou were voted to get food for your tribe you are in a nuclear wasteland after WW3 where will you go first (left/right) \n\nif you would like to go left do the problem -4 x 2 to move left and do -20...
7ad2f6c20a3c92f67e14f98cc6c503833a6d4576
iamdiv/Grokking-Deep-Learning
/NN_single_input_multiple_output.py
477
3.578125
4
def el_mul(input,weight): output = [0,0,0] assert(len(output) == len(weight)) for i in range(len(weight)): output[i] = input*weight[i] return output def neural_network(input,weight): prediction = el_mul(input,weight) return prediction def main(): weight = [0.3,0.2,0.9...
04e2b1f96eec152a4bc0c39cd0d09865b79614af
fbr-engineering-sdn-bhd/hello-world
/Ch_5_Fantasy_Items.py
889
3.984375
4
itemInventory = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} def displayInventory(inventory): totalItems = 0 for item, quantity in inventory.items(): #calls the dictionary print(str(quantity)+ ' ' + item) #calls the quantity and then the nam totalItems += quantity # adds...
27f4b9df4e8045b8b7f1e24401205a5de1dc770c
effoT/codingbat-py
/String-3.py
18,896
4.0625
4
# these are problems at codingbat.com for java, testing them out on python ''' countYZ Given a string, count the number of words ending in 'y' or 'z' -- so the 'y' in "heavy" and the 'z' in "fez" count, but not the 'y' in "yellow" (not case sensitive). We'll say that a y or z is at the end of a word if there is not ...
f8bbe8387b86993ad41bcfe9ea1d5ec1ffc3f877
gyanchith28/Automating_the_boring_stuff
/chapter03/theCollatzSequence.py
275
4.125
4
def collatz(num): if num % 2 == 0: return num//2 else: return 3*num + 1 try: n = int(input()) while n!=1: n = collatz(n) print(n) except ValueError: print('ERROR : Enter an integer')
86334f33e7c8277b09b2b620b20947acdfe7decc
k-bigboss99/Python-AI
/basic knowledge/base/tuple.py
697
4.09375
4
# 建立元組 # tuple元組與list列表相似,不同為元組元素不可修改,且元組元素類型可不相同 tup1 = () tup1 = ('Taiwan', 'USA', 'JAPAN') tup2 = (1, 2, 3, 4, 5) tup3 = ("a", "b", "c", "d") print("tup1[0]:", tup1[0]) print("tup2[1:5]:", tup2[1:5]) # 連接元組 ## 元組中的元组值不允須修改,但可以對元組進行結合 tup1 = (12, 34, 56) tup2 = (78, 90) tup3 = tup1 + tup2 print(tup3) # 刪除元組 ## 元組中的...
4296d7b668714864edb0f5fb0475bb38a52726af
k-bigboss99/Python-AI
/basic knowledge/GUI/gui1.py
697
3.640625
4
import tkinter win = tkinter.Tk() # 建立Windows視窗物件 win.title("HelloWorld") # 設定視窗標題 win.geometry("200x200") label = tkinter.Label(win, text="hello, python") label.pack() # 將Label元件增加到視窗中顯示 button1 = tkinter.Button(win...
62cf6c8adf3cee2ef7deb35542236e3fda7348e2
ratmie/aoj
/ALDS1/ALDS1_1_A.py
332
3.71875
4
def main(): n = int(input()) a = list(map(int, input().split())) printlist(a) insertionSort(a, n) def insertionSort(a, n): for i in range(1,n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j + 1] = a[j] j -= 1 a[j+1] = v printlist(a) def printlist(a): values = map(str, a) print(' '.join(valu...
c39a8b55c26807167a4f1131a6827b2f3f1755cf
max64q/Python_Practice
/Question 15.py
326
4.0625
4
#Question 15 #Write a program that computes the value of a+aa+aaa+aaaa with a given digit #as the value of a. #Suppose the following input is supplied to the program: #9 #Then, the output should be: #11106 val = input('Enter number: ') val = int(val) out = val + 11 * val + 111 * val + 1111 * val prin...
20e5c8ee6c1da6ffef9a763b0209bcea888549dc
bbein/Classifiers
/Classifiers/Core.py
2,370
3.703125
4
""" Core functions for Classifiers that can be shared between multiple classifiers. """ def dot_product_vector_vector(vector_1, vector_2): """ Dot product between two vectors. Both vectors need to be of the same dimention # Parameters vector_1 : list-like, with a list of all vector dat...