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 |
|---|---|---|---|---|---|---|
b5e51529e0c68b4c5d3879f9c034ce8540fadeab | itCatface/idea_python | /py_pure/src/catface/introduction/07_oo_senior/2_property.py | 1,692 | 3.890625 | 4 | # -@property[既能检查参数,又可以用类似属性这样简单的方式来访问类的变量]
# 常规getter&setter
class Student(object):
def __init__(self):
pass
def set_score(self, score):
if not isinstance(score, int):
raise ValueError('score must be an integer')
if score < 0 or score > 100:
raise ValueError(... |
d2feee5ec35d4bf4575cf61a98bf6d62ef9fb771 | itCatface/idea_python | /py_pure/src/catface/introduction/01_base/5_for.py | 1,222 | 3.765625 | 4 | # -循环
def test_for():
# for
nums = (1, 2, 3, 4, 5)
sum = 0
for x in nums:
sum += x
print(sum) # 15
for i, v in enumerate(nums):
print('第%d个位置的值为%d' % (i, v)) # 第0个位置的值为1\n第1个位置的值为2...
# range
nums = list(range(10)) # range(x): 生成一个整数序列 | list(range(x)): 通过list()将整数序列转... |
262604114db21368103f6c8e670fa17d1b640bed | dante092/Caesar-Cypher | /kassuro.py | 5,718 | 4.3125 | 4 |
#!/usr/bin/python3
def encrypt(string, rotate):
"""
Encrypt given input string with the caeser cypher.
args:
string (str): string to encrypt.
rotate (int): number by whiche the characters are rotated.
returns:
str: encrypted version of the input string.
raises... |
db18e85eb77c5d672ef397b4f21560e92a7ef5ad | johan-eriksson/advent-of-code-2019 | /src/day7.py | 5,242 | 3.5625 | 4 | import itertools
import math
class Computer():
def __init__(self, phase):
self.OPCODES = {
1: self.ADD,
2: self.MUL,
3: self.WRITE,
4: self.READ,
5: self.JNZ,
6: self.JEZ,
7: self.LT,
8: self.EQ,
99: self.EXIT
}
self.input = []
self.input.append(phase)
self.phase = phase
self.la... |
80643111235604455d6372e409fa248db684da97 | s56roy/python_codes | /python_prac/calculator.py | 1,136 | 4.125 | 4 | a = input('Enter the First Number:')
b = input('Enter the Second Number:')
# The entered value 10 is a string, not a number. To convert this into a number we can use int() or float() functions.
sum = float(a)+float(b)
print(sum)
print('The sum of {0} and {1} is {2}'.format(a, b, sum))
print('This is output to the ... |
b55313c576269b2fe93fc708e12bf74966886521 | MColosso/Wesleyan.-Machine-Learning-for-Data-Analysis | /Week 4. Running a k-means Cluster Analysis.py | 7,015 | 3.6875 | 4 | #
# Created on Mon Jan 18 19:51:29 2016
#
# @author: jrose01
# Adapted by: mcolosso
#
from pandas import Series, DataFrame
import pandas as pd
import numpy as np
import matplotlib.pylab as plt
from sklearn.cross_validation import train_test_split
from sklearn import preprocessing
from sklearn.cluster import KMeans
pl... |
e890b55a98130e34004f3ad15e02b8993aadf55b | eudaimonious/LPTHW | /ex4.py | 1,485 | 4 | 4 | cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
print "There are", cars, "cars available."
print "There are only", drivers, "drivers available."
pri... |
1aaec58e360a3897542886686250694e7971b308 | yesiamjulie/pyAlgorithm | /AlgoTest/Passing_bridge.py | 617 | 3.53125 | 4 | def solution(bridge_length, weight, truck_weights):
answer =0
waiting = truck_weights
length_truck = len(truck_weights)
passed = []
passing = []
on_bridge = []
while len(passed) != length_truck:
for i in range(len(passing)):
passing[i] += - 1
if passing and pass... |
145a53662de78fc1e68618010034705f73b44d62 | yesiamjulie/pyAlgorithm | /AlgoTest/SumOfTwoN.py | 518 | 3.59375 | 4 | """
서로 다른 자연수들로 이루어진 배열 arr와 숫자 n이 입력으로 주어집니다.
만약 배열 arr에 있는 서로 다른 2개의 자연수를 합하여 숫자 n을 만드는 것이 가능하면 true를, 불가능하면 false를 반환하는 함수를 작성하세요.
"""
def solution(arr, n):
answer = False
length = len(arr)
for i in range(length - 1):
for j in range(i + 1, length):
if arr[i] + arr[j] == n:
... |
d1a4bffe153eaaffde01f1bc0f07bb9fe8646941 | gurralaharika21/toy-problems | /LRU-oops/Lru_cache.py | 1,290 | 3.5625 | 4 | import collections
# import OrderedDict
class LRUCache:
# dict = {}
def __init__(self,capacity :int):
self.capacity = capacity
self.cache = collections.OrderedDict()
def put(self,key:int,value:int):
try:
self.cache.pop(key)
except KeyError:
if len(se... |
3a0af90aa6b19e7c73245e6724db18fb050aef7d | JinhuaShen/Python-Learning | /CalcCount.py | 1,038 | 3.640625 | 4 | import csv
import re
import sqlite3
def genInfos(file):
csvfile = open(file, 'r')
reader = csv.reader(csvfile)
seeds = []
for seed in reader:
seeds.append(seed)
csvfile.close()
return seeds
def showInfos(infos):
result = open("result.txt", 'w')
... |
15b45688390a72bdb74852f76cee51101ef1193e | ykcai/Python_ML | /homework/week11_homework.py | 679 | 3.890625 | 4 | # Machine Learning Class Week 11 Homework
# 1. An isogram is a word that has no repeating letters, consecutive or nonconsecutive. Create a function that takes a string and returns either True or False depending on whether or not it's an "isogram".
# Examples
# is_isogram("Algorism") ➞ True
# is_isogram("PasSword") ➞ F... |
69f49e0d03340dbbe2a4cdf5d489d884d2fe5b53 | ykcai/Python_ML | /homework/week8_homework.py | 599 | 3.890625 | 4 | # Machine Learning Class Week 8 Homework
import numpy as np
# 1. Create an array of 10 zeros
# 2. Create an array of 10 ones
# 3. Create an array of 10 fives
# 4. Create an array of the integers from 10 to 50
# 5. Create an array of all the even integers from 10 to 50
# 6. Create a 3x3 matrix with values ranging... |
9060d68c59660d4ee334ee824eda15cc49519de9 | ykcai/Python_ML | /homework/week5_homework_answers.py | 2,683 | 4.34375 | 4 | # Machine Learning Class Week 5 Homework Answers
# 1.
def count_primes(num):
'''
COUNT PRIMES: Write a function that returns the number of prime numbers that exist up to and including a given number
count_primes(100) --> 25
By convention, 0 and 1 are not prime.
'''
# Write your code here
#... |
0629cc2ce905a9bcb6d02fdf4114394d8e9ab6dc | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/coinimport.py | 599 | 3.8125 | 4 | # This program imports the ocin module and creates an instance of the Coin Class
# needs to be the file name or file path if in a different directory
import coin
def main():
# create an object from the ocin class
# needs the filename.module
my_coin = coin.Coin()
# Display the side of the coin... |
e25a8fc38ef3e98e5dc34aae30fbbea316e709c2 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/LoopsPractice/3.py | 1,029 | 4.21875 | 4 | # 3. Budget Analysis
# Write a program that asks the user to enter the amount that he or she has budgeted for amonth.
# A loop should then prompt the user to enter each of his or her expenses for the month, and keep a running total.
# When the loop finishes, the program should display theamount that the user is ov... |
2b1cf90a6ed89d0f5162114a103397c0f2a211e8 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/More advance things/iter.py | 612 | 4.25 | 4 | # Python iterators
# mylist = [1, 2, 3, 4]
# for item in mylist:
# print(item)
# def traverse(iterable):
# it = iter(iterable)
# while True:
# try:
# item = next(it)
# print(item)
# except: StopIteration:
# break
l1 = [1, 2, 3]
it ... |
b62ba48d92de96b49332b094f8b34a5f5af4a6cb | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/More advance things/map.py | 607 | 4.375 | 4 | # The map() function
# Takes in at least 2 args. Can apply a function to every item in a list/iterable quickly
def square(x):
return x*x
numbers = [1, 2, 3, 4, 5]
squarelist = map(square, numbers)
print(next(squarelist))
print(next(squarelist))
print(next(squarelist))
print(next(squarelist))
print(nex... |
8abfe167d6fa9e524df27f0adce9f777f4e2df58 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/LoopsPractice/5.py | 1,278 | 4.5625 | 5 | # 5. Average Rainfall
# Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years.
# The program should first ask for the number of years. The outer loop will iterate once for each year.
# The inner loop will iterate twelve times, once for each month. Each ite... |
60f890e1dfb13d2bf8071374024ef673509c58b2 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/Practice/Inheritance Exercises - 1.py | 1,870 | 4.59375 | 5 | """
1. Employee and ProductionWorker Classes
Write an Employee class that keeps data attributes for the following pieces of information:
• Employee name
• Employee number
Next, write a class named ProductionWorker that is a subclass of the Employee class. The
ProductionWorker class sho... |
d5b0d5d155c1733eb1a9fa27a7dbf11902673537 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/FunctionExercise/4.py | 1,166 | 4.1875 | 4 | # 4. Automobile Costs
# Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile:
# loan payment, insurance, gas, oil, tires, andmaintenance.
# The program should then display the total monthly cost of these expenses,and the total annual... |
e51cbe700da1b5305ce7dfe9c1748ad3b2369690 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/Dictionaries and Sets/Sets/notes.py | 2,742 | 4.59375 | 5 | # Sets
# A set contains a collection of unique values and works like a mathematical set
# 1 All the elements in a set must be unique. No two elements can have the same value
# 2 Sets are unordered, which means that the elements are not stored in any particular order
# 3 The elements that are stored in a set can be ... |
0ce57fc5296a09864fb1e75080a20c684bceef98 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/car_truck_suv_demo.py | 1,521 | 4.1875 | 4 | # This program creates a Car object, a truck object, and an SUV object
import vehicles
import pprint
def main():
# Create a Car object
car = vehicles.Car('Bugatti', 'Veyron', 0, 3000000, 2)
# Create a truck object
truck = vehicles.Truck('Dodge', 'Power Wagon', 0, 57000, '4WD')
# Create... |
8a747dfb6d959c1e4774543b9dd4fa42eeda228a | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Tkinter/tkinter_intro.py | 1,459 | 3.890625 | 4 | '''
GUI - a graphical user interface allows the user to interact with the operating system and other programs using
graphical elements such as icons, buttons, and dialog boxes.
In python you can use the tkinter module to create simple GUI programs
There are other GUI modules available but tkinter comes with ... |
d2e06b65113045bf009e371c53cc73750f8184a7 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/Recursion/Practice/7.py | 1,181 | 4.21875 | 4 | """
7. Recursive Power Method
Design a function that uses recursion to raise a number to a power. The function should
accept two arguments: the number to be raised and the exponent. Assume that the exponent is a
nonnegative integer.
"""
# define main
def main():
# Establish vars
int1 = int... |
fafa7582c917c253c46b4e773ebe8ea1c0e84af7 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/vehicles.py | 3,642 | 4.4375 | 4 | # The Automobile class holds general data about an auto in inventory
class Automobile:
# the __init__ method accepts arguments for the make, model, mileage, and price. It initializes the data attributes with these values.
def __init__(self, make, model, mileage, price):
self.__make = make
... |
f149ee1bf7a78720f53a8688d83d226cb00dc5eb | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Practice/Cars.py | 2,383 | 4.8125 | 5 | """
2. Car Class
Write a class named Car that has the following data attributes:
• __year_model (for the car’s year model)
• __make (for the make of the car)
• __speed (for the car’s current speed)
The Car class should have an __init__ method that accept the car’s year model ... |
eaa53c820d135506b1252749ab50b320d11d53b5 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Practice/5 - RetailItem.py | 1,427 | 4.625 | 5 | """
5. RetailItem Class
Write a class named RetailItem that holds data about an item in a retail store. The class
should store the following data in attributes: item description, units in inventory, and price.
Once you have written the class, write a program that creates three RetailItem objects
and stores the fol... |
b046b95c144bbe51ac2c77b5363814b8b5d2b5cc | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/LoopsPractice/6.py | 503 | 4.46875 | 4 | # 6. Celsius to Fahrenheit Table
# Write a program that displays a table of the Celsius temperatures 0 through 20 and theirFahrenheit equivalents.
# The formula for converting a temperature from Celsius toFahrenheit is
# F = (9/5)C + 32 where F is the Fahrenheit temperature and C is the Celsius temperature.
# You... |
6da08424b01dfcfcebb93cbeff93e76e72c53ea9 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/Unit Testing and Multithreading/MultiThreading/Multithreadingclassdemo1/multithreading5.py | 950 | 3.625 | 4 | # For editing further without losing multithreading og file
'''
Prove that these are actually coming in as they are completed
Lets pass in a range of seconds
Start 5 second thread first
'''
import concurrent.futures
import time
start = time.perf_counter()
def do_something(seconds):
print(f'Sle... |
9e6bdd3adc3e850240f3c9a94dd766ecdd4abe97 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/FileExercises/9.py | 1,013 | 4.28125 | 4 | # 9. Exception Handing
# Modify the program that you wrote for Exercise 6 so it handles the following exceptions:
# • It should handle any IOError exceptions that are raised when the file is opened and datais read from it.
# Define counter
count = 0
# Define total
total = 0
try:
# Display first 5 line... |
c7576a385b6019af0393ec97ebdd0cf3c5aee69e | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/Algorithms and Data Structures/collections_lecture.py | 2,840 | 3.8125 | 4 | '''
collection - a group of 0 or more items that can be treated as a conceptual unit. Things like strings, lists, tuples, dictionaries
Other types of collections include stacks, queues, priority queues, binary search trees, heaps, graphs, and bags
************** Collection Types **************... |
f1639f9b273a097c08d8e3d6236acf50befd9a99 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/regex/Practice/1.py | 285 | 3.75 | 4 | """
1. Recognize the following strings: “bat”, “bit”, “but”, “hat”,
“hit”, or “hut”.
"""
import re
string = '''
bat bit but hat hit hut
'''
pattern = re.compile(r'[a-z]{2}t')
matches = pattern.finditer(string)
for match in matches:
print(match)
|
2118efbe7e15e295f6ceea7b4a4c26696b22edb1 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/Unit Testing and Multithreading/MultiThreading/Multithreadingclassdemo1/multithreading.py | 1,434 | 4.15625 | 4 | '''
RUnning things concurrently is known as multithreading
Running things in parallel is known as multiprocessing
I/O bound tasks - Waiting for input and output to be completed
reading and writing from file system, network
operations.
These all benefit... |
5c78846587a1485c8a39a77ef8f4ec10dfe0f2bb | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Test Stuff/First Test/study/knowledge_lists_and_tuples.py | 3,523 | 4.15625 | 4 | """
Multiple Choice
1. This term refers to an individual item in a list.
a. element
b. bin
c. cubby hole
d. slot
2. This is a number that identifies an item in a list.
a. element
b. index
c. bookmark
d. identifier
3. This is the... |
f1923bf1fc1a3ab94a7f5d32c929cd6914fc7605 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Test Stuff/First Test/shapes1.py | 2,305 | 4.25 | 4 | class GeometricObject:
def __init__(self, color = "green", filled = True):
self.color = color
self.filled = filled
def getColor(self):
return self.color
def setColor(self, color):
self.color = color
def isFilled(self):
... |
cd2b8237503c74dfc7864dd4ec64d7f334c9ecb0 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Practice/8 - trivia.py | 2,521 | 4.4375 | 4 | """
8. Trivia Game
In this programming exercise you will create a simple trivia game for two players. The program will
work like this:
• Starting with player 1, each player gets a turn at answering 5 trivia questions. (There
should be a total of 10 questions.) When a question is displayed,... |
2ae55026f82e336bd28809f87822da12d2a8f0a6 | Hackman9912/PythonCourse | /NetworkStuff/09_NetworkingExtended/Practice/04 Modules/04-5.py | 679 | 4.03125 | 4 | '''
### Working With modules ( sys, os, subprocess, argparse, etc....)
5. Create a script that will accept a single integer as a positional argument, and will print a hash symbol that amount of times.
'''
import os
import sys
import time
import subprocess
import argparse
def get_arguments():
parser = argparse.Ar... |
1658b421c637ec8ab3524446baccd8f30da4470c | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/Lists/tuples.py | 394 | 4.25 | 4 | # tuples are like an immutable list
my_tuple = (1, 2, 3, 4, 5)
print(my_tuple)
# printing items in a tuple
names = ('Holly', 'Warren', 'Ashley')
for n in names:
print(n)
for i in range(len(names)):
print (names[i])
# Convert between a list and a tuple
listA = [2, 4, 5, 1, 6]
type(... |
8b72f14467bc40821bc0fb0c7c2ad9f05be58cd0 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/Practice/Inheritance Exercises - 3.py | 2,460 | 4.46875 | 4 | """
3. Person and Customer Classes
Write a class named Person with data attributes for a person’s name, address, and
telephone number. Next, write a class named Customer that is a subclass of the
Person class. The Customer class should have a data attribute for a customer
number and a Boolean da... |
ab93e5065c94a86f8ed6c812a3292100925a1bb5 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/IfElsePractice/5.py | 1,575 | 4.4375 | 4 | # 5. Color Mixer
# The colors red, blue, and yellow are known as the primary colors because they cannot be
# made by mixing other colors. When you mix two primary colors, you get a secondary color,
# as shown here:
# When you mix red and blue, you get purple.
# When you mix red and yellow, you get orange.
# When ... |
5a57c7b45ccb3df1adb3ebad30f2a4d2defba1d7 | stephaniecheng1124/CIS-01 | /InClassB.py | 941 | 3.984375 | 4 | # Stephanie Cheng
# CIS 41B Spring 2019
# In-class assignment B
# Problem B1
#
# This program writes a script to perform various basic math and string operations.
def string_count():
name = raw_input("Please enter your name: ")
print(name.upper())
print(len(name))
print(name[3])
name2 = nam... |
d2d9ad0905e398f8509b6ad6e70f59ee578f0adc | stephaniecheng1124/CIS-01 | /InClassC.py | 871 | 3.6875 | 4 | # Stephanie Cheng
# CIS 41B Spring 2019
# In-class assignment C
# Problem C1
#
#List Script
from copy import deepcopy
def list_script():
list1 = [2, 4.1, 'Hello']
list2 = list1
list3 = deepcopy(list1)
print("list1 == list2: " + str(list1==list2))
print("list1 == list3: " + str(list1==list3)... |
1821805f1bd83a8add850ac70f9ad17bf5a27431 | shaamimahmed/MITx---6.00.1x | /BFS.py | 700 | 3.859375 | 4 | class node():
def __init__(self,value,left,right):
self.value = value
self.left = left
self.right = right
def __str__(self):
return self.value
def __repr__(self):
return 'Node {}'.format(self.value)
def main():
g = node("G", None, None)
h = node("H", None, None)
i = node("... |
1b2a7905075802782b7f57df0b08520ee13aaea4 | shaamimahmed/MITx---6.00.1x | /recursion.py | 730 | 3.828125 | 4 | def iterPower(base, exp):
'''
base: int or float.
exp: int >= 0
returns: int or float, base^exp
'''
total= base
if exp == 0:
total = 1
for n in range(1, exp):
total *= base
return total
def recurPower(base, exp):
'''
base: int or float.
exp: int >= 0
... |
890f3be1a967335d2aa8f3c4d31a5c5d33626428 | Kediel/DataScienceFromScratch | /chapter5.py | 1,230 | 3.53125 | 4 | # Statistics
from collections import defaultdict, Counter
num_friends = [100,49,41,40,25,21,21,19,19,18,18,16,15,15,15,15,14,14,13,13,13,13,12,12,11,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,6... |
47332606f558cc9927e5f1d415dde6ce2ddfbf6d | smpss97058/c109156217 | /4-2D座標判斷及計算離原點距離.py | 860 | 3.84375 | 4 | x=int(input("X軸座標:"))
y=int(input("Y軸座標:"))
a=0
if x>0:
if y>0:
a=x**2+y**2
print("該點位於第一象限,離原點距離為根號"+str(a))
elif y<0:
a=x**2+y**2
print("該點位於第四象限,離原點距離為根號"+str(a))
else:
a=x**2+y**2
print("該點位於X軸上,離原點距離為根號"+str(a))
if x<0:
if y>0:
a=x**2+y**2
... |
77acd1d223437c765fa54b6c2148332653bbe731 | smpss97058/c109156217 | /32新公倍數.py | 252 | 3.71875 | 4 | n=int(input("輸入一整數:"))
while n<11 or 1000<n:
n=int(input("輸入一整數(11<=n<=1000):"))
if n%2==0 and n%11==0:
if n%5!=0 and n%7!=0:
print(str(n)+"為新公倍數?:Yes")
else:
print(str(n)+"為新公倍數?:No") |
fcf81e26402c78334170997fe6b6f4f98807d47e | elizamakkt1218/CSVFileCombination | /main.py | 4,241 | 4.03125 | 4 | import tkinter as tk
from tkinter.filedialog import askdirectory
import csv
import os
import utilities
absolute_file_paths = []
def get_file_path():
"""
Prompts user to select the folder for Combining CSV files
:parameter: None
:return: The relative paths of all files contained in the folder
:ex... |
dc1bbcc31eb28b89d15dac95bf107b5627667593 | JianyanLiang/SkyDrive | /Server/查看当前用户.py | 149 | 3.609375 | 4 | import sqlite3
conn = sqlite3.connect('Users.db')
cur = conn.cursor()
sql = 'select * from users'
cur.execute(sql)
print(cur.fetchall())
a = input()
|
d63f59488d65ba81d647da41c15424a0901d18b4 | DimitrisMaskalidis/Python-2.7-Project-Temperature-Research | /Project #004 Temperature Research.py | 1,071 | 4.15625 | 4 | av=0; max=0; cold=0; count=0; pl=0; pres=0
city=raw_input("Write city name: ")
while city!="END":
count+=1
temper=input("Write the temperature of the day: ")
maxTemp=temper
minTemp=temper
for i in range(29):
av+=temper
if temper<5:
pl+=1
if temper>maxTe... |
bafeb62820714891cf4f2082f45487e8d3db63a0 | treylitefm/euler | /misc-algos/tictactoe.py | 1,605 | 3.65625 | 4 | #arr = [['x','x','x'],['o','o','x'],['x','o','o']]
#rr = [['x','o','x'],['o','o','o'],['x','o','o']]
#arr = [['x','o','x'],['o','x','o'],['x','o','x']]
#arr = [['a','o','x'],['b','x','o'],['c','o','x']]
arr = [['a','b','g'],['d','g','f'],['g','h','i']]
def print_grid(grid):
for row in grid:
print row
def... |
7592ee5998b54cc6e7b4f7773c45e960d0b1e80c | viniciuskurt/LetsCode-PracticalProjects | /2-AdvancedStructures/Inserindo_Novo_Valor_Lista.py | 313 | 3.53125 | 4 | # podemos inserir novos valores através do METODO INSERT
cidades = ['São Paulo', 'Brasilia', 'Curitiba', 'Avaré', 'Florianópolis']
print(cidades)
cidades.insert(0, 'Osasco')
print(cidades)
# Inserido vários valores
cidades.insert(1, 'Bogotá');
print(cidades)
cidades.insert(4, 'Manaus')
print(cidades)
|
0e878016fadab1f137f3dd61c37197ecafa4511e | viniciuskurt/LetsCode-PracticalProjects | /2-AdvancedStructures/Listas_com_While.py | 438 | 4.09375 | 4 | # Uma forma inteligente de trabalhar é combinar Listas com Whiles
numeros = [1, 2, 3, 4, 5] #Criando e atribuindo valores a lista
indice = 0 #definindo contador no índice 0
while indice < 5: #Definindo repetição do laço enquanto menor que 5
print(numeros[indice]) #Exibe p... |
4d1e19c830d0f41e51c4837a8792b8a054ee6655 | viniciuskurt/LetsCode-PracticalProjects | /1-PythonBasics/aula04_Operadores.py | 1,578 | 4.40625 | 4 | '''
OPERADORES ARITMETICOS
Fazem operações aritméticas simples:
'''
print('OPERADORES ARITMÉTICOS:\n')
print('+ soma')
print('- subtração')
print('* multiplicacao')
print('/ divisão')
print('// divisão inteira') #não arredonda o resultado da divisão, apenas ignora a parte decimal
print('** potenciação')
print('% resto... |
298f3dd303082910f64b333d378934a1184f2694 | viniciuskurt/LetsCode-PracticalProjects | /1-PythonBasics/Laco_Rep_Loop_Infinito.py | 534 | 4.09375 | 4 | """
Laço de repetição com loop infinito e utilizando break
NÃO É RECOMENDADO UTILIZAR ESSA FORMA.
"""
contador = 0
# while contador < 10:
while True: # criando loop infinito
if contador < 10: # se a condição passar da condição, é executado tudo de novo
contador = contador + 1
if contador == 1:
... |
e2f5debc42e10a689eeb1836901ce285481da9ce | viniciuskurt/LetsCode-PracticalProjects | /1-PythonBasics/Validacao_Entrada.py | 207 | 3.984375 | 4 | # Exemplo básico de validação de senha de acesso
texto = input("Digite a sua entrada: ")
while texto != 'LetsCode':
texto = input("Senha inválida. Tente novamente\n")
print('Acesso permitido') |
5a008394476ccf00e21f8de67622c2c683f933fc | maxicraftone/informatics | /shortest_path.py | 13,569 | 4.15625 | 4 | #!/usr/bin/python
import math
import time
import sys
class Node:
def __init__(self, name: str) -> None:
"""
Node class. Just holds the name of the node
:param name: Name/ Title of the node (only for representation)
"""
self.name = name
# Set string representation of no... |
8faa0216ee950c7fbfd1dec6cb28a47d9c5aff7f | DCTyxx/opencv_study | /class25_分水岭算法.py | 2,272 | 3.53125 | 4 | #分水岭变换
#基于距离变换
#分水岭的变换 输入图像->灰度化(消除噪声)->二值化->距离变换->寻找种子->生成Marker->分水岭变换->输出图像->end
import cv2 as cv
import numpy as np
def watershed_demo():
print(src.shape)
blurred = cv.pyrMeanShiftFiltering(src,10,100)#边缘保留滤波
gray = cv.cvtColor(src,cv.COLOR_BGR2GRAY)
ret,binary = cv.threshold(gray,0,255,cv.THRE... |
9bf5a15c654b19ab6457ad83a3d0a763bb301892 | wangyunge/algorithmpractice | /eet/Restore_IP_Addresses.py | 1,293 | 3.90625 | 4 | '''
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["255.255.11.135", "255.255.111.35"]. (Order does not matter)
Subscribe to see which companies asked this question
Show Tags
'''
class Solution(object):
def res... |
e8116a0ec63ed32ab24c42650a5e9c51789b5cd8 | wangyunge/algorithmpractice | /int/389_Valid_Sudoku.py | 858 | 3.890625 | 4 | '''
Determine whether a Sudoku is valid.
The Sudoku board could be partially filled, where empty cells are filled with the character ..
Notice
A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated.
Have you met this question in a real interview? Yes
Clarifi... |
79db945c27a3797a29b9de46201352fa9e4f0a1b | wangyunge/algorithmpractice | /int/110_Minimum_Path_Sum.py | 888 | 3.859375 | 4 | '''
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Notice
You can only move either down or right at any point in time.
Have you met this question in a real interview? Yes
'''
class Solution:
"""
@param gri... |
352bf4ce999b1f9d03c6b96f79e8cdbb2f7230bf | wangyunge/algorithmpractice | /int/98_Sorted_List.py | 1,324 | 3.953125 | 4 | '''
Sort a linked list in O(n log n) time using constant space complexity.
Have you met this question in a real interview? Yes
Example
Given 1->3->2->null, sort it to 1->2->3->null.
'''
"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next... |
1bd27fbaa4aa4a3017d24929b4698cf48c3c1dbb | wangyunge/algorithmpractice | /int/82_Single_Number.py | 476 | 3.65625 | 4 | '''
Given 2*n + 1 numbers, every numbers occurs twice except one, find it.
Have you met this question in a real interview? Yes
Example
Given [1,2,2,1,3,4,3], return 4
'''
class Solution:
"""
@param A : an integer array
@return : a integer
"""
def singleNumber(self, A):
res = 0
for ... |
6e34a6e1dcf7b985b56e0b928a27b284d0c96c99 | wangyunge/algorithmpractice | /eet/Best_Time_to_Buy_and_Sell_Stock_IV.py | 1,809 | 4.0625 | 4 | '''
Say you have an array for which the i-th element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most k transactions.
Note:
You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
Example 1:
Inpu... |
ea76677bfc6bfc1c602ddd530ccc593258bd27c0 | wangyunge/algorithmpractice | /eet/01_Matrix.py | 526 | 4 | 4 | """
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.
The distance between two adjacent cells is 1.
Example 1:
Input:
[[0,0,0],
[0,1,0],
[0,0,0]]
Output:
[[0,0,0],
[0,1,0],
[0,0,0]]
Example 2:
Input:
[[0,0,0],
[0,1,0],
[1,1,1]]
Output:
[[0,0,0],
[0,1,0],
[1,2,1]]
""... |
431e4b3687f6e41381331f315f13108fc029d396 | wangyunge/algorithmpractice | /eet/Check_Completeness_of_a_Binary_Tree.py | 1,354 | 4.21875 | 4 | """
Given the root of a binary tree, determine if it is a complete binary tree.
In a complete binary tree, every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.
Example 1:
Input:... |
d9cdb986d5d7d796156e0ef1cc51c21cd096f9b7 | wangyunge/algorithmpractice | /eet/Longest_Increasing_Path_in_a_Matrix.py | 3,306 | 4.125 | 4 | """
Given an integer matrix, find the length of the longest increasing path.
From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).
Example 1:
Input: nums =
[
[9,9,4],
[6,6,8],
[2,1,1]
]
O... |
597bdffceea740761f6280470d81b9deaf73f400 | wangyunge/algorithmpractice | /int/517_Ugly_Number.py | 926 | 4.125 | 4 | '''
Write a program to check whether a given number is an ugly number`.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7.
Notice
Note that 1 is typically treated as an ugly number.
Have you met this ... |
6ae3a55543601626d59949db457edce81a02b2b9 | wangyunge/algorithmpractice | /eet/Add_Two_Numbers_II.py | 1,225 | 4.03125 | 4 | """
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Fo... |
53b1b4043d4949f1aec2b18d909993cc049772e8 | wangyunge/algorithmpractice | /cn/572.py | 978 | 3.890625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def isSubtree(self, s, t):
"""
:type s: TreeNode
:type t: TreeNode
... |
2e3a39178816c77f9f212cb1629a8f17950da152 | wangyunge/algorithmpractice | /int/171_Anagrams.py | 692 | 4.34375 | 4 | '''
Given an array of strings, return all groups of strings that are anagrams.
Notice
All inputs will be in lower-case
Have you met this question in a real interview? Yes
Example
Given ["lint", "intl", "inlt", "code"], return ["lint", "inlt", "intl"].
Given ["ab", "ba", "cd", "dc", "e"], return ["ab", "ba", "cd", ... |
f99cf09f6bdb40dd270f2a7845f6aa530f614795 | wangyunge/algorithmpractice | /eet/Find_K_Pairs_with_Smallest_Sums.py | 1,749 | 3.875 | 4 | """
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.
Define a pair (u,v) which consists of one element from the first array and one element from the second array.
Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums.
Example 1:
Input: nums1 = [1,7,11], nums2... |
cbc345e64aaa1883a5626e834e998addae622309 | wangyunge/algorithmpractice | /int/488_Happpy_Number.py | 979 | 3.78125 | 4 | '''
Write an algorithm to determine if a number is happy.
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle ... |
14e00c017aa35b3d0901ec3b9f83bf5d51c345be | wangyunge/algorithmpractice | /cn/234.py | 653 | 3.671875 | 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 isPalindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
stack = []
cu... |
1f4cd6fa5f100f5fec1f7ebcadf8eb99dbf09fe6 | wangyunge/algorithmpractice | /eet/Counting_Bits.py | 1,765 | 3.765625 | 4 | """
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.
Example 1:
Input: 2
Output: [0,1,1]
Example 2:
Input: 5
Output: [0,1,1,2,1,2]
Follow up:
It is very easy to come up with a solution with r... |
c730b160e62fd19ed56a4dbd8740dceed38583c2 | wangyunge/algorithmpractice | /eet/Android_Unlock_Patterns.py | 1,583 | 4 | 4 | """
我们都知道安卓有个手势解锁的界面,是一个 3 x 3 的点所绘制出来的网格。用户可以设置一个 “解锁模式” ,通过连接特定序列中的点,形成一系列彼此连接的线段,每个线段的端点都是序列中两个连续的点。如果满足以下两个条件,则 k 点序列是有效的解锁模式:
解锁模式中的所有点 互不相同 。
假如模式中两个连续点的线段需要经过其他点,那么要经过的点必须事先出现在序列中(已经经过),不能跨过任何还未被经过的点。
以下是一些有效和无效解锁模式的示例:
无效手势:[4,1,3,6] ,连接点 1 和点 3 时经过了未被连接过的 2 号点。
无效手势:[4,1,9,2] ,连接点 1 和点 9 时经过了未被连接过的 5 ... |
1ae166cb04757e11a8ca03fe3c83cbd2e3c602f1 | wangyunge/algorithmpractice | /int/106_Convert_Sorted_List_to_Balanced_BST.py | 1,193 | 3.890625 | 4 | '''
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
Have you met this question in a real interview? Yes
Example
2
1->2->3 => / \
1 3
'''
"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=No... |
3e5582033c67af1213ba003cff4b3095dabb15b5 | wangyunge/algorithmpractice | /eet/Lowest_Common_Ancestor_of_a_Binary_Tree.py | 2,220 | 4.0625 | 4 | """
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itse... |
854d5d19c39b60ed8b67150778a4bb015918c88b | wangyunge/algorithmpractice | /eet/Nth_Digit.py | 852 | 3.9375 | 4 | """
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
Note:
n is positive and will fit within the range of a 32-bit signed integer (n < 231).
Example 1:
Input:
3
Output:
3
Example 2:
Input:
11
Output:
0
Explanation:
The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9... |
e39cd00b68b6eff21de3d1b8364de609b687a309 | wangyunge/algorithmpractice | /int/392_House_Robber.py | 1,002 | 3.625 | 4 | '''
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken int... |
e3ee7499abf955e0662927b7341e93fa81843620 | wangyunge/algorithmpractice | /eet/Arithmetic_Slices.py | 960 | 4.15625 | 4 | """
An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithmetic sequences.
Given an integer array nums, return the number of arithmetic subarrays of nums.
A ... |
6c899e296237b144ba623fbbab473202cd0410ca | wangyunge/algorithmpractice | /eet/Insertion_Sorted_List.py | 887 | 3.9375 | 4 | '''
Sort a linked list using insertion sort.
'''
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def insertionSortList(self, head):
"""
:type head: ListNode
:rtype: ListNode... |
36039a9ac17ee24da100aebe9dd7b00cd17ab7f3 | wangyunge/algorithmpractice | /eet/Palindrome_Partitioning_II.py | 1,029 | 3.859375 | 4 | """
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
Example 1:
Input: s = "aab"
Output: 1
Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut.
Example 2:
Input: s = "a"
Output... |
9735ec4ad9479d0b9fe83a05b0f7a597d2b0ddd7 | wangyunge/algorithmpractice | /int/408_Add_Binary.py | 1,126 | 3.671875 | 4 | '''
Given two binary strings, return their sum (also a binary string).
Have you met this question in a real interview? Yes
Example
a = 11
b = 1
Return 100
'''
class Solution:
# @param {string} a a number
# @param {string} b a number
# @return {string} the result
def addBinary(self, a, b):
lo... |
9495b0f644bec8ff8727429271b3b4ffd1f11bbc | wangyunge/algorithmpractice | /int/426_Restore_IP_Address.py | 1,307 | 3.875 | 4 | '''
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
Have you met this question in a real interview? Yes
Example
Given "25525511135", return
[
"255.255.11.135",
"255.255.111.35"
]
Order does not matter.
'''
class Solution:
# @param {string} s the IP st... |
6eb1182dc9674ff9514f860b80c6eacaa3b54487 | wangyunge/algorithmpractice | /eet/Recover_Binary_Search_Tree.py | 3,165 | 3.8125 | 4 | '''
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?
Subscribe to see which companies asked this question
Show Tags
'''
# Definition for a binar... |
3859966faca648ffe0b7e83166049c07676ba93b | wangyunge/algorithmpractice | /eet/Maximum_Units_on_a_Truck.py | 2,304 | 4.125 | 4 | """
You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:
numberOfBoxesi is the number of boxes of type i.
numberOfUnitsPerBoxi is the number of units in each box of the type i.
You are also given an integer truckSize... |
fd3f8f5c834978e65253411de28c9177994120f9 | wangyunge/algorithmpractice | /int/186_Max_Points_on_a_Line.py | 1,782 | 3.609375 | 4 | '''
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
Example
Given 4 points: (1,2), (3,6), (0,0), (1,3).
The maximum number is 3.
'''
# Definition for a point.
# class Point:
# def __init__(self, a=0, b=0):
# self.x = a
# self.y = b
class Solutio... |
76c084094d90c838b553d1e58b78252f55852e3d | wangyunge/algorithmpractice | /eet/Contiguous_Array.py | 893 | 4.0625 | 4 | """
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.
Example 1:
Input: [0,1]
Output: 2
Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.
Example 2:
Input: [0,1,0]
Output: 2
Explanation: [0, 1] (or [1, 0]) is a longest contiguous s... |
181bd6428a741980af6e7ce9d2947b88a579cc8e | wangyunge/algorithmpractice | /eet/Pairs_of_Songs_With_Total_Durations_Divisible_by_60.py | 1,133 | 3.8125 | 4 | """
You are given a list of songs where the ith song has a duration of time[i] seconds.
Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.
Example 1:
Input: time = [30,20... |
e8f4d5ca11f339e1fa8c13b85ae55e7de66c0bcd | wangyunge/algorithmpractice | /int/73_Construct_Binary_Tree_from_Preorder_and_Inorder_Travesal.py | 1,895 | 3.921875 | 4 | '''
Given preorder and inorder traversal of a tree, construct the binary tree.
Notice
You may assume that duplicates do not exist in the tree.
Have you met this question in a real interview? Yes
Example
Given in-order [1,2,3] and pre-order [2,1,3], return a tree:
2
/ \
1 3
'''
"""
Definition of TreeNode:
clas... |
d620071842e6003015b2a9f34c72b85a64e00a04 | wangyunge/algorithmpractice | /eet/Multiply_Strings.py | 1,183 | 4.125 | 4 | """
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:
Input: num1... |
b956afb98967e9ca2fb6c320bcd360691e20b9f0 | wangyunge/algorithmpractice | /cn/29.py | 558 | 3.546875 | 4 | class Solution(object):
def divide(self, dividend, divisor):
"""
:type dividend: int
:type divisor: int
:rtype: int
"""
sign = 1 if dividend * divisor > 0 else -1
divisor = abs(divisor)
dividend = abs(dividend)
def _sub(res):
x = di... |
bdfc9caa3090f7727fd227548a83aaf19bf66c14 | wangyunge/algorithmpractice | /eet/Unique_Binary_Search_Tree_II.py | 1,269 | 4.25 | 4 | '''
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2
/ / ... |
9eba4c97143250a68995688a62b41145ab39485f | wangyunge/algorithmpractice | /int/165_Merge_Two_Sorted_Lists.py | 944 | 4.125 | 4 | '''
Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order.
Have you met this question in a real interview? Yes
Example
Given 1->3->8->11->15->null, 2->null , return 1->2->3->8->11->1... |
1ed697d41f7a62305a2bb7d82c3e945e47ac65b4 | wangyunge/algorithmpractice | /int/167_Add_Two_Numbers.py | 894 | 3.859375 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param l1: the first list
# @param l2: the second list
# @return: the sum list of l1 and l2
def addLists(self, l1, l2):
# write your code here
... |
a1e44328e89eccd44eccdf0f5bcad629ac9c4688 | wangyunge/algorithmpractice | /cn/445.py | 1,087 | 3.640625 | 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 addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"... |
8bbc714ce6bbf0420e2d320b0f9bccef01187ae8 | wangyunge/algorithmpractice | /eet/First_Unique_Character_in_a_String.py | 771 | 3.859375 | 4 | """
Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.
Examples:
s = "leetcode"
return 0.
s = "loveleetcode"
return 2.
Note: You may assume the string contains only lowercase English letters.
"""
class Solution(object):
def firstUniqChar(self,... |
c09cd743358e384ed520289eb8c09dab719ca8b3 | wangyunge/algorithmpractice | /int/101_Remove_Duplicates_from_Sorted_Array.py | 543 | 3.859375 | 4 | '''
Follow up for "Remove Duplicates":
What if duplicates are allowed at most twice?
For example,
Given sorted array A = [1,1,1,2,2,3],
Your function should return length = 5, and A is now [1,1,2,2,3].
'''
class Solution:
"""
@param A: a list of integers
@return an integer
"""
def removeDuplicates... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.