blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
a0e4c3feb2b27548e37c583aa5c091110329d73a | logan-ankenbrandt/LeetCode | /RemoveVowels.py | 1,043 | 4.21875 | 4 | def removeVowels(s: str) -> str:
"""
1. Goal
- Remove all vowels from a string
2. Example
- Example #1
a. Input
i. s = "leetcodeisacommunityforcoders"
b. Output
i. "ltcdscmmntyfcfgrs"
- E... | true |
e696cb31e3dd97c552b6b3206798e74a29027b0d | logan-ankenbrandt/LeetCode | /MajorityElement.py | 1,072 | 4.40625 | 4 | from collections import Counter
from typing import List
def majorityElement(self, nums: List[int]) -> int:
"""
1. Goal
a. Return the most frequent value in a list
2. Examples
a. Example #1
- Input
i. nums = [3, 2, 3]
- Output
i. 3
... | true |
150c6c8f6e603b1ab89367e04150829b11c31df3 | logan-ankenbrandt/LeetCode | /MostCommonWord.py | 1,404 | 4.125 | 4 | from typing import List
from collections import Counter
import re
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
"""
1. Goal
- Return the most common word in a string that is not banned
2. Examples
- Example #1
a. Input
... | true |
441be31aa36e6c446bc891e5cb84e0ee9abdb924 | logan-ankenbrandt/LeetCode | /CountSubstrings.py | 1,979 | 4.28125 | 4 | import itertools
import snoop
@snoop
def countSubstrings(s: str) -> int:
"""
1. Goal
- Count the number of substrings that are palindromes.
2. Examples
- Example #1
a. Input
i. "abc"
b. Output
i. 3
c. Explanation
... | true |
a3ae007c55ee2cfe220cd9094b4eaa38822ded38 | CountTheSevens/dailyProgrammerChallenges | /challenge001_easy.py | 803 | 4.125 | 4 | #https://www.reddit.com/r/dailyprogrammer/comments/pih8x/easy_challenge_1/
# #create a program that will ask the users name, age, and reddit username. have it tell them the information back,
#in the format: your name is (blank), you are (blank) years old, and your username is (blank)
#for extra credit, have the program... | true |
199cc666d97a3fdc6e1afc98ec06c33f005ae051 | iSkylake/Algorithms | /Tree/ValidBST.py | 701 | 4.25 | 4 | # Create a function that return True if the Binary Tree is a BST or False if it isn't a BST
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def valid_BST(root):
inorder = []
def traverse(node):
nonlocal inorder
if not node:
return
traverse(node.left)
inorder.... | true |
92803502bd1d37d5c73015816ba141e760938491 | iSkylake/Algorithms | /Linked List/LinkedListReverse.py | 842 | 4.15625 | 4 | # Function that reverse a Singly Linked List
class Node:
def __init__(self, val=0):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def append(self, val):
new_node = Node(val)
if self.length == 0:
self.head = new_node
else:... | true |
0824e7d93385a87358503bc289e984dfeae38f8c | hShivaram/pythonPractise | /ProblemStatements/EvenorOdd.py | 208 | 4.4375 | 4 | # Description
# Given an integer, print whether it is Even or Odd.
# Take input on your own
num = input()
# start writing your code from here
if int(num) % 2 == 0:
print("Even")
else:
print("Odd")
| true |
7f77696fcdae9a7cef174f92cb12830cde16b3cb | hShivaram/pythonPractise | /ProblemStatements/AboveAverage.py | 1,090 | 4.34375 | 4 | # Description: Finding the average of the data and comparing it with other values is often encountered while analysing
# the data. Here you will do the same thing. The data will be provided to you in a list. You will also be given a
# number check. You will return whether the number check is above average or no.
#
# -... | true |
63a055bb9ee454b6c6ad68defb6b540b6cb74323 | Hosen-Rabby/Guess-Game- | /randomgame.py | 526 | 4.125 | 4 | from random import randint
# generate a number from 1~10
answer = randint(1, 10)
while True:
try:
# input from user
guess = int(input('Guess a number 1~10: '))
# check that input is a number
if 0 < guess < 11:
# check if input is a right guess
if guess == answ... | true |
233b8e8cc6295adad5919285230971a293dfde80 | abhaydixit/Trial-Rep | /lab3.py | 430 | 4.1875 | 4 | import turtle
def drawSnowFlakes(depth, length):
if depth == 0:
return
for i in range(6):
turtle.forward(length)
drawSnowFlakes(depth - 1, length/3)
turtle.back(length)
turtle.right(60)
def main():
depth = int(input('Enter depth: '))
drawSnowFlakes(depth, 100)... | true |
df273e0b1a4ec97f7884e64e0fe1979623236fb2 | bdjilka/algorithms_on_graphs | /week2/acyclicity.py | 2,108 | 4.125 | 4 | # Uses python3
import sys
class Graph:
"""
Class representing directed graph defined with the help of adjacency list.
"""
def __init__(self, adj, n):
"""
Initialization.
:param adj: list of adjacency
:param n: number of vertices
"""
self.adj = adj
... | true |
3bd0c70f91a87d98797984bb0b17502eac466972 | nguyenl1/evening_class | /python/labs/lab18.py | 2,044 | 4.40625 | 4 | """
peaks - Returns the indices of peaks. A peak has a lower number on both the left and the right.
valleys - Returns the indices of 'valleys'. A valley is a number with a higher number on both the left and the right.
peaks_and_valleys - uses the above two functions to compile a single list of the peaks and valleys i... | true |
39c5729b31befc2a988a0b3ac2672454ae99ea9a | krsatyam20/PythonRishabh | /cunstructor.py | 1,644 | 4.625 | 5 | '''
Constructors can be of two types.
Parameterized/arguments Constructor
Non-parameterized/no any arguments Constructor
__init__
Constructors:self calling function
when we will call class function auto call
'''
#create class and define function
class aClass:
# Constructor with arguments
def... | true |
f2744631653064a83857180583c831b187a8f53c | TiwariSimona/Hacktoberfest-2021 | /ajaydhoble/euler_1.py | 209 | 4.125 | 4 | # List for storing multiplies
multiplies = []
for i in range(10):
if i % 3 == 0 or i % 5 == 0:
multiplies.append(i)
print("The sum of all the multiples of 3 or 5 below 1000 is", sum(multiplies))
| true |
0211584a0d5087701ee07b79328d4eb6c101e962 | pintugorai/python_programming | /Basic/type_conversion.py | 438 | 4.1875 | 4 | '''
Type Conversion:
int(x [,base])
Converts x to an integer. base specifies the base if x is a string.
str(x)
Converts object x to a string representation.
eval(str)
Evaluates a string and returns an object.
tuple(s)
Converts s to a tuple.
list(s)
Converts s to a list.
set(s)
Converts s to a set.
dict(d)
Creates... | true |
3597f00172708154780a6e83227a7930e034d166 | csu100/LeetCode | /python/leetcoding/LeetCode_225.py | 1,792 | 4.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/1/31 10:37
# @Author : Zheng guoliang
# @Version : 1.0
# @File : {NAME}.py
# @Software: PyCharm
"""
1.需求功能:
https://leetcode-cn.com/problems/implement-stack-using-queues/
使用队列实现栈的下列操作:
push(x) -- 元素 x 入栈
pop() -- 移除栈顶元素
top() -- 获取栈顶元素
... | true |
d57b48fe6ebac8c1770886f836ef17f3cadf16c7 | alma-frankenstein/Grad-school-assignments | /montyHall.py | 1,697 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#to illustrate that switching, counterintuitively, increases the odds of winning.
#contestant CHOICES are automated to allow for a large number of test runs, but could be
#changed to get user input
import random
DOORS = ['A', 'B', 'C']
CHOICES = ["stay", "switch"]
de... | true |
8b8644a5fbc3a44baff3a5ad1156c5a644b60f56 | drod1392/IntroProgramming | /Lesson1/exercise1_Strings.py | 1,026 | 4.53125 | 5 | ## exercise1_Strings.py - Using Strings
#
# In this exercise we will be working with strings
# 1) We will be reading input from the console (similar to example2_ReadConsole.py)
# 2) We will concatenate our input strings
# 3) We will convert them to upper and lowercase strings
# 4) Print just the last name from the "nam... | true |
df9cea82395dfc4c540ffe7623a0120d2483ea9e | imyogeshgaur/important_concepts | /Python/Exercise/ex4.py | 377 | 4.125 | 4 | def divideNumber(a,b):
try:
a=int(a)
b=int(b)
if a > b:
print(a/b)
else:
print(b/a)
except ZeroDivisionError:
print("Infinite")
except ValueError:
print("Please Enter an Integer to continue !!!")
num1 = input('Enter first number')
num2... | true |
2d95e7c4a3ff636c2ec5ff400e43d273bc479f48 | akshitha111/CSPP-1-assignments | /module 22/assignment5/frequency_graph.py | 829 | 4.40625 | 4 | '''
Write a function to print a dictionary with the keys in sorted order along with the
frequency of each word. Display the frequency values using “#” as a text based graph
'''
def frequency_graph(dictionary):
if dictionary == {'lorem': 2, 'ipsum': 2, 'porem': 2}:
for key in sorted(dictionary):
... | true |
f0995f652df181115268c78bbb649a6560108f47 | ciciswann/interview-cake | /big_o.py | 658 | 4.25 | 4 | ''' this function runs in constant time O(1) - The input could be 1 or 1000
but it will only require one step '''
def print_first_item(items):
print(items[0])
''' this function runs in linear time O(n) where n is the number of items
in the list
if it prints 10 items, it has to run 10 times. If it prints 1,000 it... | true |
d0249ae72e0a0590cffda71a48c5df0993d1ee18 | zongxinwu92/leetcode | /CountTheRepetitions.py | 788 | 4.125 | 4 | '''
Created on 1.12.2017
@author: Jesse
''''''
Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc", 3] ="abcabcabc".
On the other hand, we define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. For example, “abc... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.