blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
16f4e7634512172920920fe1ac38a179ae20e9dc
Jarhmander/gamegenie
/gamegenie.py
5,642
3.546875
4
#!/usr/bin/python2 """Module to encode/decode Game Genie codes. The algorithm used to decode was taken from info available at http://tuxnes.sourceforge.net/gamegenie.html See file LICENSE for license information. """ # Mapping and reverse mapping of Game Genie letters to nibbles code2letter = [ 'A', 'P',...
3105109a28d387b60432b5fe13cf336f3e72821a
michael-grace/advent-of-code-2020
/day06.py
999
3.59375
4
# Ensure you add a newline at the end your input file from typing import List, Set question_groups: List[List[str]] = [] group_numbers: List[int] = [] with open("data/6") as f: temp: List[str] = [] num_in_group: int = 0 for l in f: if l != "\n": for x in l[:-1]: temp.a...
b9e54ceb13ae27c2289baf4c7f3c118b16717ae8
soft9000/ZipDB
/ZipNotes/ZipBase.py
4,914
3.875
4
#!/usr/bin/env python3 from zipfile import ZipFile import os import sys sys.path.insert(1, os.path.join(sys.path[0], '../..')) class ZipArchiveBase(): ''' Once a file has been written to a zip archive, the enarchived file is no longer updatable. To update any file in an archive, that archive...
566ff9db1680e613ef013e6918d274b1382c2934
codethat-vivek/NPTEL-Programming-Data-Structures-And-Algorithms-Using-Python-2021
/week2/RotateList.py
646
4.28125
4
# Third Problem: ''' A list rotation consists of taking the first element and moving it to the end. For instance, if we rotate the list [1,2,3,4,5], we get [2,3,4,5,1]. If we rotate it again, we get [3,4,5,1,2]. Write a Python function rotatelist(l,k) that takes a list l and a positive integer k and returns the list l...
dd656afd2673c0d81d665db755cc5ccb48d406a9
mdekudugu/nlp-ashesi
/Ashesi Support Chatbot/CapstoneFinalProduct/custom_actions/action_affirmative_negative.py
666
3.796875
4
import random from time import sleep class ActionAffirmitiveNegative(): def __init__(self): self.action = "action_affirmative_negative" def makeAffirmativeNegative(self, intent): positive_response = ["I'm Impressed", "Thanks you find it useful", "Glad to hear that", "Great it did help"] negative_response = ["...
e3213188386fcab7d9f99e7062eb2699d52979d6
suptidas/competitive-programming
/learning/Bitwise_operator(2).py
161
3.703125
4
#An efficient solution is to use bitwise leftshift operator. We know 1 << n means 2 raised to power n. # compute x * (2^n) x = 2 n = 4 multiply=x*n print(x<<n)
0b707ef4af8965918d48cc798f916e406f7c943f
morzen/Greenwhich1
/COMP1753/week11/L09 Files/06File_lineCount.py
937
3.75
4
import os def readlines(filename): """Return contents of text file as a list of lines.""" with open(filename) as file: return file.readlines() def index_and_count_lines(dirname, root_path_length): filenames = os.listdir(dirname) for filename in filenames: path = dirname + "\\" + file...
7585ea2f9315f9c6d998cf124527778bbb17a7b9
morzen/Greenwhich1
/COMP1753/week6/L04 Functions/04Calculator_outputBetter.py
659
4.0625
4
def output(parameter1, parameter2): parameter1_str = str(parameter1) parameter2_str = str(parameter2) print(parameter1_str + parameter2_str) number1_str = input(" First number: ") number1 = int(number1_str) number2_str = input("Second number: ") number2 = int(number2_str) operation = input("Operation [+...
99c377b0c7085e7172fc34fd82bc1898e0d2b3ab
morzen/Greenwhich1
/COMP1753/week10/L08 Strings/02Formatting_justification.py
545
4
4
print("Justified decimals") print("|" + format(123.456789, "8.2f") + "|") print("|" + format(123, "8.2f") + "|") print("|" + format(123.456789, "<8.2f") + "|") print("|" + format(123, "<8.2f") + "|") print() print("Justified integers") print("|" + format(123, "8") + "|") print("|" + format(123, "<8") + "|") print() pri...
c4e7313dd7ea194c6a94dc786eb986b69b010745
morzen/Greenwhich1
/COMP1753/week3/my code/triangle.py
136
3.703125
4
from turtle import * i=0 def line_and_angle(x,y) : forward(x) left(y) while i<3: line_and_angle(100,120) i=i+1
c1e45315a36a73c74389e0a5e9e994bad70e4ece
morzen/Greenwhich1
/COMP1753/week10/L08 Strings/11String_chaining.py
388
3.671875
4
response = input("Are you generally happy with COMP1753? ") # with chaining if response.strip().lower().startswith("yes"): print("Good! Your response is '" + response + "'") # without chaining response = response.strip() response = response.lower() if response.startswith("yes"): print("Good! Your response is ...
7addd194339d9409be8ec733c35cbe79e0c1171f
morzen/Greenwhich1
/COMP1753/week9/L07 Lists/12Randoms_localFunctions.py
949
3.609375
4
from random import randint def print_list(items, header=None): if header != None: print(header) for item in items: print(str(item)) print() def get_min_v1(items): items.sort() return items[0] def get_min_v2(items): smallest = items[0] for item in items[1:]: if i...
35006c7cae16453ff82b8936e70b1e63cb3d4a85
morzen/Greenwhich1
/COMP1753/week12/L10 GUIs/08GUI_focus.py
475
3.515625
4
from tkinter import * window = Tk() window.geometry("350x200") window.title("COMP1753 GUI") input_txt = Entry(window, width=10) input_txt.focus() input_txt.grid(column=0, row=0) def clicked(): res = "Hello " + input_txt.get() output.set(res) btn = Button(window, text="Click Me", command=clicked) btn.grid...
1ff1fadb88d860e4d2b97c5c38668bcc880c607c
morzen/Greenwhich1
/COMP1753/week7/L05 Debugging/02Calculator_ifElifElse.py
1,241
4.40625
4
# this program asks the user for 2 numbers and an operation +, -, *, / # it applies the operation to the numbers and outputs the result def input_and_convert(prompt, conversion_fn): """ this function prompts the user for some input then it converts the input to whatever data-type the programmer ha...
2802f5d52bbd64374c37693ac1b21a764c9fc43a
morzen/Greenwhich1
/COMP1753/week4/L02 Variables/03HelloNameWelcome.py
154
3.765625
4
name = input("What is your name? ") course = "COMP1753" print("Hello " + name + " - welcome to " + course) print() input("Press return to continue ...")
4bb208f78003b0eaa9e32887929bc79342bd9168
morzen/Greenwhich1
/COMP1753/week11/L09 Files/10Browser.py
267
3.53125
4
import urllib.request #url = "https://www.gre.ac.uk/" url = input("Enter an URL for a file: ").strip() infile = urllib.request.urlopen(url) content = infile.read().decode() # Read the content as string print(content) print() input("Press return to continue ...")
8a7fc33dc1794e5e4c811eb901709c2c1b39a1a7
morzen/Greenwhich1
/COMP1753/week4/L02 Variables/07HelloLuckyYear.py
304
3.9375
4
from random import randint name = input("what is your name ?: ") year = input("what is your year of birth?: ") minimum = int(year) maximum = int(year)+70 lucky = randint(minimum, maximum) lucky = str(lucky) print() print("hello " + name + " your lucky number is " + lucky) input("press enter to end")
fc6d050bd28928483a191ef1e17e335c1ec7b22b
morzen/Greenwhich1
/COMP1753/week8/L06 Loops/10LineNumbers_break.py
201
4.09375
4
n_lines = int(input("How many lines? ")) for counter in range(1, n_lines+1): if counter == 3: break print("This is line " + str(counter)) print() input("Press return to continue ...")
905b694d1ffc3d27ca964eca00b32888896e96ea
Shorokhov-A/repo-algorithms_python
/lesson_1/task_1_8.py
287
3.84375
4
year = int(input('Введите год: ')) if year % 4 == 0: if year % 100 == 0 and year % 400 != 0: print(f"Год {year} невисокосный") else: print(f"Год {year} високосный") else: print(f"Год {year} невисокосный")
a1957ecd08b7ece42b19b735cacd5969ad58d2d6
Shorokhov-A/repo-algorithms_python
/lesson_3/task_3_8.py
2,668
3.765625
4
matrix_5x4 = [] print('Укажите по 3 элемента каждой строки матрицы 5х4 целыми числами.\n' 'Последний элемент каждой строки будет заполняться автоматически значениями ' 'суммы трех указанных элементов этой строки.') for i in range(5): print(f'Строка №{i + 1}:') matrix_str = [] for j in range(3): ...
66d4eeb9f9660a9290d03b126d144e2ceaff24ec
Shorokhov-A/repo-algorithms_python
/lesson_3/task_3_4.py
732
3.515625
4
from random import randint list_1 = [randint(1, 5) for _ in range(20)] print(list_1) max_count = 0 max_count_els = [] for idx in range(len(list_1)): count = list_1.count(list_1[idx]) if count > max_count: max_count = count max_count_els.clear() max_count_els.append(list_1[idx]) eli...
985e66edfa4cfd1089475b7e78c3b451e090ad9a
Shorokhov-A/repo-algorithms_python
/lesson_6/task_3_4_6.py
4,954
3.8125
4
# Определить, какое число в массиве встречается чаще всего. from random import randint from sys import getsizeof list_1 = [randint(1, 5) for _ in range(20)] print(list_1) max_count = 0 max_count_els = [] for idx in range(len(list_1)): count = list_1.count(list_1[idx]) if count > max_count: max_count =...
51233640dabe69e4606ecd9ebdabac22d1908bfd
Shorokhov-A/repo-algorithms_python
/lesson_2/task_1_6.py
1,529
3.921875
4
# В программе генерируется случайное целое число от 0 до 100. Пользователь должен его # отгадать не более чем за 10 попыток. После каждой неудачной попытки должно сообщаться # больше или меньше введенное пользователем число, чем то, что загадано. Если за 10 # попыток число не отгадано, то вывести загаданное число. from...
6723c36e9559556640bb3da3b046a4070ea142cf
CameronLonsdale/crypto_experiments
/RSA_CRT_attack/crt_attack.py
3,467
3.546875
4
#!/usr/bin/env python3 from Crypto.PublicKey import RSA from decimal import Decimal, getcontext # function that implements Extended euclidean # algorithm def extended_euclidean(a, b): if a == 0: return (b, 0, 1) else: g, y, x = extended_euclidean(b % a, a) return (g, x - (b // a) * y,...
1986d8bf8fb4aa4b742efe61e473a72965436493
JieDaWangDev/Python-01-100days
/day04/lotteryticket.py
789
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ****************************** # @File : lotteryticket.py # @Author : Ge丶 # @Time : 2020/4/11 20:35 # @software : PyCharm # ****************************** from random import sample, randint def select_balls(): red_balls = [x for x in r...
20b5ee7935148fbff2a339ef440bfa2fe8c09bcc
JieDaWangDev/Python-01-100days
/day06/salary_system.py
1,779
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ****************************** # @File : salary_system.py # @Author : Ge丶 # @Time : 2020/4/12 20:03 # @software : PyCharm # ****************************** from abc import abstractmethod, ABCMeta # 通过abc模块的ABCMeta元类和abstractmethod包装器来达到抽象类 ...
7b0ab3a5901f9263f716e0e4b7c4635c84799e51
gbramley/PythonRangeDrillFinal
/Pythonrangedrill.py
117
3.625
4
for i in range(4): print (i) for i in range(3,-1,-1): print (i) for i in range(8,0,-2): print(i)
c2e8208d3f33abd0ba15b7e1a51a13c54a0b2135
SerenaPaley/WordUp
/venv/lib/python3.8/WordUp.py
1,231
4.28125
4
# Serena Paley # March, 2021 from getpass import getpass def main(): print('Welcome to Word Up') secret_word = getpass('Enter the secret word') current_list = ["_"] * len(secret_word) letter_bank = [] guess = "" while "_" in current_list: print_board(current_list) get_letter(...
fff1a953b9f3ef821a71daabd8266ee7f22535e2
IrisLiQinyi/mis3690
/Session 6/if-demo.py
1,664
4.09375
4
# age = input('please enter your age: ') # if int(age) > 6: # print('teenager') # elif age > 18: #else if can have as many as we want # print ('adult') # else: # print('kid') # x = 6 # y = 4 # if x == y: # print('x and y are euqual') # else: # if x < y: # print ('x is less than y') # el...
640ef5788a718e619ffb2776f1705a92bb611de7
IrisLiQinyi/mis3690
/word.py
2,531
3.890625
4
# counter = 0 # for line in fin: # word = line.strip() # counter += 1 # print(counter) # def read_long_words(): # """ # prints only the words with more than 20 characters # """ # for line in fin: # word = line.strip() # if len(word) > 20: # print (word) ...
86f0b87b8e1aa0178656a4d418774926376a23d0
cindy3124/python
/testerhome_pratice/pytest_practice/pytest_bubble.py
376
4.15625
4
#! /usr/bin/env python # coding=utf-8 import random def bubble_sort(nums): for i in range(len(nums)-1): for j in range(len(nums)-i-1): if nums[j] > nums[j+1]: nums[j], nums[j+1] = nums[j+1], nums[j] print(nums) return random.choice([nums, None, 10]) if __name__ == '_...
b8b430ab548f7f1ee89588b8aba3a0211aad7d6c
Tuukka-B/protocol-programming
/other_assignments/M2296_assignment03.5_client.py
4,861
4.53125
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 10 16:29:51 2019 @author: tuukka Assignment: Write a client and a server program that can be used to send files to the server. You have to come up with a simple protocol (you don’t have to document the protocol, but you can) whic...
8a719ebf2471443b778789b13fe409c6ede17eeb
luelvira/Matrix
/Matrix.py
8,267
3.640625
4
#!/usr/bin/python3 # -*- encoding UTF-8 -*- """ @author Lucas Elvira Martín @size september 2018 @version 2.1 """ from functools import reduce class Matrix: """Clase matriz. Sirve para definir las propiedades de un matrix y manipularla con cierta facilidad""" def __init__(self, col = 1, row=1, val = 0, diagonal=Fa...
fb6893517f0b7ded7acb58fd6dbe15662075ebed
Miguel-Caringal/CCC-Solution-Bank
/CCC-2010/s1.py
912
3.6875
4
numcomp = int(input()) maxsum = 0 maxsumname = "" secondsum = 0 secondsumname = "" testarr = [] for _ in range(0,numcomp,1): string = str(input()) name,ram,cpu,disk = string.split(" ") ram = int(ram) cpu = int(cpu) disk = int(disk) sum = ram*2+cpu*3+disk if sum > maxsum: testarr = ...
36e7cd8cc96264f50e49f9cd2b778fc642434312
GaryZhang15/a_byte_of_python
/002_var.py
227
4.15625
4
print('\n******Start Line******\n') i =5 print(i) i = i + 1 print(i) s = '''This is a multi-line string. This is the second line.''' print(s) a = 'hello'; print(a) b = \ 5 print(b) print('\n*******End Line*******\n')
b4a4b5a5681d88c82e86fde80ce5d0683a3da0a1
AdamHillingerSzekely/PythonExamples
/twotimestable.py
152
3.8125
4
T= 0 while T<=100: print("Print", T, "Times table.") A=0 while A<=10: print(T, "x", A, "=", (A*T)) A+=1 T+=1 print("__________________")
2b11b3d81beb69818e673ce70588d0ad9c440f21
AdamHillingerSzekely/PythonExamples
/eesforstars.py
227
3.703125
4
FileRead=open("data.txt", "r") FileWrite= open("data2.txt", "w") for line in FileRead: for letter in line: if letter=="e" or letter=="E": print("*", end="", file=FileWrite) else: print(letter, end="", file=FileWrite)
b0b0e230d33dcab6e31f796574a574e3ca27bfd5
AdamHillingerSzekely/PythonExamples
/change2.py
516
4.03125
4
bill= int(input("what is the bill? ")) paid= int(input("what was paid? ")) change= paid-bill if change>=50: print(int(change/50), '50 pound notes') change= change%50 if change>=20: print(int(change/20), '20 pound notes') change= change%20 if change>=10: print(int(change/10), '10 pound notes') change= change%10 if...
08e0fba604efc7c7922daefd05beb27ae720f462
ashdank/PracticePython
/dog_walking.py
1,322
4
4
class Dog: # Class attribute species = 'mammal' # Initializer / Instance attributes def __init__(self, name, age): self.name = name self.age = age # Instance method def description(self): return self.name, self.age # Instance method def speak(self, sound): ...
aed3693956b8b787ffc6b8a3821b808e5892f0a5
ashdank/PracticePython
/reverseletters.py
87
4.03125
4
s = raw_input("Enter a word: ") str = "" for i in s: str = i + str print (str)
ee09fd35aec20d9b6cd829e1d2ab72b84c979913
xiaoxin12/pythonlearn
/learnign/9-11-9.15/first.py
349
3.65625
4
print(' sqq is a good boy') # 输出时间下一秒 timeStr = input() timeList = timeStr.split(':') hour = int(timeList[0]) min = int(timeList[1]) sec = int(timeList[2]) sec += 1 if sec == 60: min +=1 sec = 0 if min ==60: hour +=1 min = 0 if hour ==24: hour = 0 print('%d: %d:%d' % (h...
f3ae08b7e3ed42215176b43dda0332d96636e23b
xiaoxin12/pythonlearn
/learnign/4-18-4.20/猜数字.py
914
3.640625
4
# -*- coding: utf-8 -*- import math import random random.random() number = math.ceil( random.random()*20 ) def gucessfun(num): global number print(num) print(number) if num > number: print('大了大了,再小点') if num < number: print('小了小了,再大点') count = 0 nums = 0 #while count < 3: # cou...
a09f9fe6aa0663cf8143ca71d01553918d6d35a1
Sana-mohd/fileQuestions
/S_s_4.py
298
4.34375
4
#Write a Python function that takes a list of strings as an argument and displays the strings which # starts with “S” or “s”. Also write a program to invoke this function. def s_S(list): for i in list: if i[0]=="S" or i[0]=="s": print(i) s_S(["sana","ali","Sara"])
253ce94494055fd089f3826c3740b3ea5d95c43a
shankarapailoor/elina-octagon
/compareConstraints.py
1,064
3.546875
4
import sys def addConstraints(file): constraints = [] with open(file, 'rb') as f: inConstraint = False constraint = None for line in f: if not inConstraint: if "PRINTING" in str(line.strip()): inConstraint = True constr...
48349455195a918bcc971129da021a96a8220f52
AngeloLiwanag/Party_Class
/queues.py
760
3.78125
4
class Node: def __init__(self,val): self.val = val self.next = None class Queues: def __init__(self): self.head = None self.tail = None def enque(self, val): new_node = node(val) if (self.head and self.tail == None): self.head = new_node ...
0ad3c7e6dda7c7deab28251680f5a99b5d0dbaaa
abayirli/CellularAutomata
/rules.py
1,540
3.5
4
#CA rules degined by numbers import numpy as np def rule_1(row): """Cell i becomes (or stays) black if one or more of the triad [i-1, i, i+1] is black; otherwise it stays (or becomes) white""" new_row = np.zeros(row.shape[0]) for i, cel in enumerate(row): if(row[i-1] + row[i] + row[(i+1) % len(row)] >= 1): ...
41a2110a54d616bfed0d062ba3d2719727175146
itsjustaksh/SYSC3010-AkshRavishankar
/Lab 3/lab3-JSON-demo.py
1,744
4.03125
4
from urllib.request import * from urllib.parse import * import json import sqlite3 # The URL that is formatted: http://api.openweathermap.org/data/2.5/weather?APPID=a808bbf30202728efca23e099a4eecc7&units=imperial&q=ottawa # As of October 2015, you need an API key. # I have registered under my Carleton email. apiKe...
d9430fbbcfc44711fc384e09b0be5e6b680688ad
Nishi-1910/Python-assignment-1
/greater.py
66
3.53125
4
lis=[1,2,4,10,45,8] lis.sort() print("largest no. is",lis[-1])
2d0bdf035301f9623b0094d8acfda0b5be25999c
jgoodacre93/pnwgen
/pnwgen.py
3,296
3.59375
4
#!/usr/bin/env python3 # phone number wordlist generator version 0.2.7 # https://github.com/toxydose # https://awake.pro/ import sys import logging from doc import * if '-v' in sys.argv: print('Phone number Wordlist Generator v.' + VERSION) exit() elif '-h' in sys.argv: print(HELP) exit() logging.ba...
7849a9c3043f20a49cd8e7fd7b5426aa82cdc1f1
adamtlee/python_playground
/datatype_tuple_example.py
326
3.828125
4
demo_tuple_drinks = ("coffee", "tea", "water") demo_tuple_foods = ("bread", "steak", "fish") print("The contents in the tuple: ", demo_tuple_drinks) print("The length of the tuple: ", len(demo_tuple_drinks)) print("The Tuple types: ", type(demo_tuple_drinks)) nested_tuple = tuple((demo_tuple_drinks)) print(nested_tu...
5898fd67e1add864fdf2ded31fb6173d8b995c1f
kaldixey/datasci_assignment1
/src/analyseCSV/table.py
6,610
3.5625
4
''' ARCL0160 Assessment 1 2018 @author: CTRL0 ''' ''' IMPORTS: os and csv imported to manipulate the filepath and read the csv file math imported to sum the values of self.size and self.population ''' import os, csv import math class Table(object): ''' This class reads in a csv file and c...
634ac9b61b5de328cd7f9f88d8d66308f1526f36
chrischapman82/AI_WatchYourBackGame
/PartA.py
12,868
3.796875
4
from queue import * import heapq # sample input #a = "X - - - - - - X - - - - - - - - - - - - - 0 0 - - - - - @ 0 - - - - - - - - - - - - - - - 0 - - - - - - @ - @ @ X - - - - - - X" # BOARD SYMBOLS EMPTY = "-" CORNER = "X" WHITE_PIECE = "O" BLACK_PIECE = "@" # PART NAME MOVES = "Moves" MASSACRE = "Massacre" # DIRE...
43cdb6b4bf6da4f4655df3c743030651a19c8150
harmansehmbi/Project10
/practice10k.py
276
3.515625
4
# Class and Object Relationship class CA: num = 101 def __init__(self): self.a = 102 def show(self): print("num is: ", self.num) print("num is: ", CA.num) # Property of class can be accessed by class Vl cRef = CA() cRef.show()
cc787277d8c89b914c9761b8613a1dd2b776b1cd
frankhart2018/BRNS-WEB-PYTHON
/decorators.py
353
3.65625
4
import time def timeit(func): # This function shows the execution time of # the function object passed def wrap_func(*args, **kwargs): t1 = time.time() result = func(*args, **kwargs) t2 = time.time() print(f'Function {func.__name__!r} executed in {(t2-t1):.4f}s') r...
29865162bf29577e34b94334c406b25dc87b6ffc
shpal2000/todo
/todo-app/crud.py
1,436
3.703125
4
import sqlite3 def create_tables(db_file): conn = sqlite3.connect(db_file) c = conn.cursor() c.execute (''' DROP TABLE IF EXISTS user''') c.execute (''' CREATE TABLE user (user_name text PRIMARY KEY, user_pass text NOT NULL, ful...
ea03341745c69eca422fded2e8a5d9c615619336
dev-schueppchen/programmier-aufgaben
/aufgaben-leicht/aufgabe02/loesungen/python/python.py
732
3.84375
4
# Lösung ohne Zusatzaufgaben import random zahl = random.randint(1, 101) versuche = 10 eingabe = -1 print("Die Zahl befindet sich zwischen einschließlich 1 und 100.") print("Du hast nun 10 Versuche, die Zahl zu raten.") while(versuche > 0): print("Verbleibende Versuche: " + str(versuche)) eingabe = int(inpu...
c24c3d90b8e596e642a035143cbacf030f161f1e
19JamesLeggett/jamesleggett-python
/Unit2Alab/Unit2Alab.py
226
3.5625
4
print(5+4) print(4.5+ 5) num1 =input() num2= input() print(int(num1)+int(num2)) i=100 j=200 x=300 y=100 print((i == j) or (i == x)) print((i<j) and (i>=y)) print((i!=j) and (i != x)) print((i<j) and (i<x) and (i<y))
2f800478018deccabc35c30e0aeed820df4918b2
19JamesLeggett/jamesleggett-python
/turtleProject/turtleProject.py
853
3.625
4
import turtle as j def main () : #t.hideturtle() #t.speed(0) j.setup(width=800 , height=800) j.title("Turtle Project - turtleIntro") j.bgcolor("#1de047") line () square () circle () triangle () j.exitonclick () def line () : j.pencolor('green') moveT(50 , 0) j.left(...
6e9d50cdfa78c5a3c74cd7abe06120cc26cb5c86
NikilMunireddy/SIH2019
/FitArgoApi/API/GPSLocation/in_range.py
769
3.671875
4
from math import radians, cos, sin, asin, sqrt def haversine(lon1, lat1, lon2, lat2): lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) dlon = lon2 - lon1 dlat = lat2 - lat1 a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2 c = 2 * asin(sqrt(a)) r = 6371 # Radius of e...
7af83213bffd6fc83e83ae42a0d61f8978aea915
allank47/UT-CSI
/Week 6/yl6.2 - Õunamahla tegemine.py
255
3.5
4
#ALLAN KERME // 10.12.2020 #ÕUNAMAHLA TEGEMINE trikk = float(input("Sisestage õunte kogus kilogrammides: ")) def mahlapakkide_arv(trikk): return round(trikk * 0.4/3) mahlapakkide_arv(trikk) print(float(mahlapakkide_arv(trikk))) #Added to GitHub on 13th of March, 2021
a43994f169d6c256d23e8d429f78e4c2011ade20
kategomezny/IS211_Assignment10
/query_pets.py
993
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- """Connects and query the data""" import sqlite3 as lite con = lite.connect('pets.db') while True: person_ID= raw_input("Please enter your ID number or enter -1 to exit:") if person_ID == '-1': print 'Exiting Database Query.' raise Sy...
766fa02257a17a6310c3fd47b3ac28585a7f040f
moh833/encryption-algorithms
/Classical Cyphers/play_fair.py
1,884
3.640625
4
def get_matrix(key): '''takes a key and returns matrix: a 5x5 matrix of letters locations: a dictionary with letters as keys and (row, column) as value ''' letters = 'abcdefghijklmnopqrstuvwxyz' matrix_text = key + letters matrix_text = matrix_text.lower() matrix_text = matrix_text.repla...
5cf79f3a364e3b48edeaf6534807bcf60948cf11
ndmichael/Python-CalculatorSwitch
/calculator_switch.py
3,698
4.03125
4
class Calculator: def __init__(self, choice, num1, num2): self.choice = choice self.num1 = num1 self.num2 = num2 self.__total = None # this method controls the user decisions and inputs to calculate def switcher(self): choice_dict = { '1': 'add', ...
1087032a2f1fde416bc8dc2bc7f578b68aa185a1
ksubin96/-_-
/5주차.py
3,129
3.78125
4
import operator def menu() : print('1. 데이터 추가''\n' '2. 데이터 검색''\n' '3. 데이터 삭제''\n' '4. 데이터 정렬''\n' '5. 데이터 출력''\n' '0. 종료''\n') key = int(input("메뉴를 선택하세요 : ")) return key def addinfo() : global info global std part = input(("학과를 입력하세요 : "...
9a7672604d6b7c1732a61a86e891b486ca8cfab1
jorge11696/3.-CRUD-PYTHON
/4.-decorators.py
819
3.703125
4
PASSWORD = '12345' def password_required(func): def wrapper(): password = input('Cual es tu contraseña?') if password == PASSWORD: return func() else: print('La contraseña es incorrecta') return wrapper @password_required #decorador def needs_passwors(): ...
7d5b653828b1735bbbaace0aab311d88b940faa5
wjddn803/Assignment_JungwooLim
/Assignment3.py
7,194
4.34375
4
# coding: utf-8 # ## 1 # In this exercise you will create a program that computes the average of a collection # of values entered by the user. The user will enter 0 as a sentinel value to indicate # that no further values will be provided. Your program should display an appropriate # error message if the first value...
0006826b855b68787fdbc3ce56dde88d63876fc1
ingolfurorri/HR-assignments
/numbers.py
777
3.84375
4
#Find all numbers i so that 9 < i < 100 so that the sum of individual numbers sqared equals the number it self for i in range(10, 100): #Isolate the first and second part of the number, and sum it up in a special variable. num1 = i // 10 num2 = i % 10 num_sum = num1 + num2 if(num_sum**2 == i...
14c7fabc5353e7784170a565481c11eaea89bf4a
gavanderlinden/PythonForNonDeveloper
/examples/3_the_kitchen_shift_class.py
3,109
4.09375
4
import random import datetime # define the class_____________________________________________________________ class KitchenDutyPlanner(object): def __init__(self): self.date = datetime.datetime(2017, 4, 1) self.end_date = datetime.datetime(2017, 5, 1) self.day = datetime.timedelta(day...
b59ba8b0e2ec0d39b92a04031580bb5703a11246
Andrewlearning/Leetcoding
/leetcode/BackTracking(DFS)/77. 组合.py
772
3.734375
4
""" 给定两个整数 n 和 k,返回 1 ... n 中所有可能的 k 个数的组合。 示例: 输入:n = 4, k = 2 输出: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] """ class Solution(object): def combine(self, n, k): """ :type n: int :type k: int :rtype: List[List[int]] """ if n < 1: return ...
48e424fd2925ae3a00d4c1f344f8ce22e461f341
Andrewlearning/Leetcoding
/leetcode/DFS/394m. 字符串解码(DFS).py
1,796
3.90625
4
""" 给定一个经过编码的字符串,返回它解码后的字符串。 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次。注意 k 保证为正整数。 你可以认为输入字符串总是有效的;输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的。 **这个规则很重要: 此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数 k ,例如不会出现像 3a 或 2[4] 的输入。   示例 1: 输入:s = "3[a]2[bc]" 输出:"aaabcbc" """ class Solution(object): def decodeString(self,...
a1aad6060c386d3bd1b8659107c4eb291ee4252c
Andrewlearning/Leetcoding
/leetcode/BFS/古城 - BFS/127. 最短单词转换I(双向BFS).py
2,478
3.84375
4
""" 一个单词每次只能变一个字母,然后到达另一个单词,最后希望能到达endword 输入: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"] 输出: 5 解释: 一个最短转换序列是 "hit" -> "hot" -> "dot" -> "dog" -> "cog", 返回它的长度 5。 """ class Solution(object): def ladderLength(self, beginWord, endWord, wordList): """ ...
da1c5463a576cf600dcbeac10e399a1cc11dc947
Andrewlearning/Leetcoding
/leetcode/String/468. 验证IP地址.py
1,677
3.5
4
class Solution(object): def validIPAddress(self, IP): """ :type IP: str :rtype: str """ if not IP: return "Neither" if IP.count(":") == 7: return self.valid_IPv6(IP) elif IP.count(".") == 3: return self.valid_IPv4(IP) ...
7df2fac43c8c7087189c3d08b6a4bec4971190e9
Andrewlearning/Leetcoding
/leetcode/Tree/437. 路径总和III(给定值).py
1,555
4
4
""" 给定一个二叉树,它的每个结点都存放着一个整数值。 找出路径和等于给定数值的路径总数。 路径不需要从根节点开始,也不需要在叶子节点结束,但是路径方向必须是向下的(只能从父节点到子节点)。 二叉树不超过1000个节点,且节点数值范围是 [-1000000,1000000] 的整数。 示例: root = [10,5,-3,3,2,null,11,3,-2,null,1], sum = 8 10 / \ 5 -3 / \ \ 3 2 11 / \ \ 3 -2 1 返回 3。和等于 8 的路径有: 1. 5 -> 3 2. 5 -> 2 -...
16fea5a2cdc6d28cfde063cf6ccaf3ea3a63ddd0
Andrewlearning/Leetcoding
/leetcode/Tree/古城-信息的传递/549. 二叉树最长的连续序列II(自下而上,多个同类型数据).py
2,468
3.796875
4
""" 给定一个二叉树,你需要找出二叉树中最长的连续序列路径的长度。 请注意,该路径可以是递增的或者是递减。例如,[1,2,3,4] 和 [4,3,2,1] 都被认为是合法的,而路径 [1,2,4,3] 则不合法。另一方面,路径可以是 子-父-子 顺序,并不一定是 父-子 顺序。 示例 2: 输入: 2 / \ 1 3 输出: 3 解释: 最长的连续路径是 [1, 2, 3] 或者 [3, 2, 1]。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(se...
a32ad588efb25dad5d64dcf2a29be6e697d5cfdd
Andrewlearning/Leetcoding
/leetcode/String/434m. 字符串中的单词数.py
976
4.25
4
""" 统计字符串中的单词个数,这里的单词指的是连续的不是空格的字符。 请注意,你可以假定字符串里不包括任何不可打印的字符。 示例: 输入: "Hello, my name is John" 输出: 5 解释: 这里的单词是指连续的不是空格的字符,所以 "Hello," 算作 1 个单词。 """ class Solution(object): def countSegments(self, s): """ :type s: str :rtype: int """ if not s and len(s) == 0: ...
12a973a1466a4281b8210edb3229f1a5e5e1e009
Andrewlearning/Leetcoding
/剑指offer/面试题40. 最小的k个数(最大堆).py
1,118
3.671875
4
import heapq class Solution(object): def getLeastNumbers(self, arr, k): """ :type arr: List[int] :type k: int :rtype: List[int] """ if not arr or k == 0: return [] heap = [] for num in arr: if len(heap) < k: h...
1c5d7daf14016c5b8e136af932b2642f128b5165
Andrewlearning/Leetcoding
/leetcode/String/基础/转换类(进制,字母)/168. 10进制转26进制.py
826
3.859375
4
""" Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: Input: "A" Output: 1 Example 2: Input: "AB" Output: 28 """ class Solution(object): def convertToTitle(sel...
4f6504269c4abed560badb1016b9bd4cdcd7b2c2
Andrewlearning/Leetcoding
/剑指offer/37.两个链表的第一个公共结点.py
1,766
3.671875
4
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if not headA or not headB: return None ...
38be1b9bb17bc0b9c15a4a6cdba063ed22119e3e
Andrewlearning/Leetcoding
/leetcode/BitOperation/717. 最后一个字符是不是1比特(从后往前).py
998
3.78125
4
""" 有两种特殊字符。第一种字符可以用一比特0来表示。第二种字符可以用两比特(10 或 11)来表示。 现给一个由若干比特组成的字符串。问最后一个字符是否必定为一个一比特字符。给定的字符串总是由0结束。 """ class Solution(object): def isOneBitCharacter(self, bits): """ :type bits: List[int] :rtype: bool """ res = bits.pop(-1) # 奇数情况 0 1110 假如说最后0前面有奇数个连续的1,那么...
84a4ce33ab050bed93f3e83400a5b744b73cad2f
Andrewlearning/Leetcoding
/leetcode/DP/背包问题/1049. 最后一块石头的重量II(01背包).py
2,334
3.53125
4
""" 有一堆石头,每块石头的重量都是正整数。 每一回合,从中选出任意两块石头,然后将它们一起粉碎。假设石头的重量分别为x 和y,且x <= y。那么粉碎的可能结果如下: 如果x == y,那么两块石头都会被完全粉碎; 如果x != y,那么重量为x的石头将会完全粉碎,而重量为y的石头新重量为y-x。 最后,最多只会剩下一块石头。返回此石头最小的可能重量。如果没有石头剩下,就返回 0。 """ class Solution(object): def lastStoneWeightII(self, stones): """ :type stones: List[int] :...
e5d27eae52ce47ebd7e3ce78e487ae6000c06ca4
Andrewlearning/Leetcoding
/算法基础课/5. 动态规划/线性dp/AcWing 899. 编辑距离(线性dp).py
1,980
3.609375
4
""" 对于每次询问,请你求出给定的n个字符串中有多少个字符串可以在上限操作次数内经过操作变成询问给出的字符串。 每个对字符串进行的单个字符的插入、删除或替换算作一次操作。 输入格式 第一行包含两个整数n和m。 接下来n行,每行包含一个字符串,表示给定的字符串。 再接下来m行,每行包含一个字符串和一个整数,表示一次询问。 字符串中只包含小写字母,且长度均不超过10。 输入样例: 3 2 abc acd bcd ab 1 acbd 2 输出样例: 1 3 """ def minDistance(word1, word2): if not word1 and not word2: return 0 m =...
dc6396bc9cd7774a281cf33fce4ad02aaee30c82
Andrewlearning/Leetcoding
/leetcode/Math/397m 整数替换(递归).py
706
3.84375
4
""" 给定一个正整数 n,你可以做如下操作: 1. 如果 n 是偶数,则用 n / 2替换 n。 2. 如果 n 是奇数,则可以用 n + 1或n - 1替换 n。 n 变为 1 所需的最小替换次数是多少? 示例 1: 输入: 8 输出: 3 解释: 8 -> 4 -> 2 -> 1 """ class Solution(object): def integerReplacement(self, n): """ :type n: int :rtype: int """ # base case 已经到1了,不需要再变动 ...
e40f1da2fc37ddc85f7dd982eb96b8a5a34ff207
Andrewlearning/Leetcoding
/leetcode/DFS/417m. 太平洋大西洋水流问题(两边dfs求交集).py
1,761
3.546875
4
""" 给定一个 m x n 的非负整数矩阵来表示一片大陆上各个单元格的高度。“太平洋”处于大陆的左边界和上边界,而“大西洋”处于大陆的右边界和下边界。 规定水流只能按照上、下、左、右四个方向流动,且只能从高到低或者在同等高度上流动。 请找出那些水流既可以流动到“太平洋”,又能流动到“大西洋”的陆地单元的坐标。 """ class Solution(object): def pacificAtlantic(self, matrix): """ :type matrix: List[List[int]] :rtype: List[List[int]] """...
c8a78a61fdccfb1eaade9b0e5d2408ced2e2835a
Andrewlearning/Leetcoding
/剑指offer/57.链表中环的入口结点.py
1,220
3.6875
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def EntryNodeOfLoop(self, pHead): slow = pHead quick = pHead while quick and quick.next: quick = quick.next.next slow = slow.next if quick == slow:...
fa9865e06131b5bde1ad368c6d480b4ee5395859
Andrewlearning/Leetcoding
/leetcode/Array/169. 求超过一半的数字(无序,摩尔投票).py
1,125
3.765625
4
""" 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数大于⌊ n/2 ⌋的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 """ class Solution(object): def majorityElement1(self, nums): """ :type nums: List[int] :rtype: int """ if nums is None and len(nums) == 0: return 0 res = nums[0] ...
e08008341ca5c8913d5f3e0b7e91f8c92bfc3291
Andrewlearning/Leetcoding
/leetcode/BinarySearch/LCP 12. 小张刷题计划(二分分组最小).py
2,190
3.640625
4
""" 给定一个数组,将其划分成 M 份,使得每份元素之和最大值最小,每份可以任意减去其中一个元素。 输入:time = [1,2,3,3], m = 2 输出:3 解释:第一天小张完成前三题,其中第三题找小杨帮忙;第二天完成第四题,并且找小杨帮忙。这样做题时间最多的一天花费了 3 的时间,并且这个值是最小的。 示例 2: 输入:time = [999,999,999], m = 4 输出:0 解释:在前三天中,小张每天求助小杨一次,这样他可以在三天内完成所有的题目并不花任何时间。 """ import sys class Solution(object): def minTime(self, times, m): ...
73c9a0d470bdffba8de8b63988f7c8f8e8a365d4
Andrewlearning/Leetcoding
/leetcode/Tree/古城-树的遍历/103. 二叉树的锯齿形层序遍历.py
1,064
3.78125
4
""" 给你二叉树的根节点 root ,返回其节点值的 锯齿形层序遍历。 (即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行) """ class Solution(object): def zigzagLevelOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ if not root: return [] res = [] queue = [root] wh...
04aec907ae510991686ec9e8876b0404e1b69717
Andrewlearning/Leetcoding
/leetcode/Math/基础/8. String to Integer (atoi).py
1,778
3.9375
4
""" 这个题目说的是,给你一个字符串,你要把它转成一个 int 类型的数字。这个字符串里可能会包含空格,字母或是其它字符。 一个可以有效地转成数字的字符串包含以下特点: 1. 可以有前导空格或前导 0,但不能有其它前导字符 2. 可能会有一个加号或减号表示正负,也可能没有,连续的多个加号或减号则视为不合法 3. 紧接着是一段连续的数字,如果没有数字则示为不合法 4. 数字后的其它字符都可以忽略 5. 如果数字大于 int 的最大值或小于 int 的最小值,返回相应的极值即可 6. 字符串如果不能合法地转为整数,则返回 0 """ class Solution(object): def myAtoi(self, str):...
eefdfe54d8c2c3978bcdd3bd14d90ef4ff6d069e
Andrewlearning/Leetcoding
/leetcode/Math/246. 中心对称数I.py
878
3.953125
4
""" 中心对称数是指一个数字在旋转了 180 度之后看起来依旧相同的数字(或者上下颠倒地看)。 请写一个函数来判断该数字是否是中心对称数,其输入将会以一个字符串的形式来表达数字。 示例 1: 输入: "69" 输出: true """ class Solution(object): def isStrobogrammatic(self, num): """ :type num: str :rtype: bool """ res = "" for char in num: if char in ...
ed28b398a00b09708cd6cadebe4ce5342d16466b
Andrewlearning/Leetcoding
/leetcode/Random/478m. 在圆内随机生成点(拒绝采样).py
1,711
4.25
4
""" 给定圆的半径和圆心的 x、y 坐标,写一个在圆中产生均匀随机点的函数 randPoint 。 说明: 输入值和输出值都将是浮点数。 圆的半径和圆心的 x、y 坐标将作为参数传递给类的构造函数。 圆周上的点也认为是在圆中。 randPoint 返回一个包含随机点的x坐标和y坐标的大小为2的数组。 示例 1: 输入: ["Solution","randPoint","randPoint","randPoint"] [[1,0,0],[],[],[]] 输出: [null,[-0.72939,-0.65505],[-0.78502,-0.28626],[-0.83119,-0.19803]] """ import rando...
bb3f374f97f432e51ce8f677c1b191017ace415d
Andrewlearning/Leetcoding
/leetcode/Hashmap/266. 回文排列(抵消法).py
857
3.5
4
class Solution(object): def canPermutePalindrome(self, s): """ :type s: str :rtype: bool """ # 由于字符串中出现的字符的 ASCII 码在 0 到 127 之间,因此我们可以枚举所有的字符 hashmap = [0] * 128 count = 0 for char in s: hashmap[ord(char) - ord("A")] += 1 # 当...
acb6d4063bce9aacaf89517aca8d5c7ddac9d888
Andrewlearning/Leetcoding
/leetcode/Queue/365. 水壶问题.py
2,496
3.546875
4
class Solution(object): def canMeasureWater(self, x, y, z): """ :type x: int :type y: int :type z: int :rtype: bool """ stack = [(0, 0)] self.seen = set() while stack: remain_x, remain_y = stack.pop() if remain_x == z ...
9b2e0cb73d043c3ff344567e6f43b06846d81b20
Andrewlearning/Leetcoding
/leetcode/DP/多维状态DP问题/309. 最佳买卖股票时机含冷冻期.py
1,868
3.5625
4
""" 给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。​ 设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票): 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。 示例: 输入: [1,2,3,0,2] 输出: 3 解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出] """ class Solution(object): def maxProfit(self, prices): """ :type prices: List[i...
e7ba890d619554bbc5031203eeee5155cfaf4e7a
Andrewlearning/Leetcoding
/leetcode/Array/244m. 最短单词距离II(有重复,hashmap+双指针).py
1,445
3.921875
4
""" 请设计一个类,使该类的构造函数能够接收一个单词列表。然后再实现一个方法,该方法能够分别接收两个单词 word1 和 word2,并返回列表中这两个单词之间的最短距离。您的方法将被以不同的参数调用 多次。 示例: 假设 words = ["practice", "makes", "perfect", "coding", "makes"] 输入: word1 = “coding”, word2 = “practice” 输出: 3 输入: word1 = "makes", word2 = "coding" 输出: 1 注意: 你可以假设 word1 不等于 word2, 并且 word1 和 word2 都在列表里。 ""...
b1461c71782ba37ffd3189dd9941a98260409f01
Andrewlearning/Leetcoding
/leetcode/Math/372. Super Pow(做加法).py
1,748
3.859375
4
""" 你的任务是计算 ab 对 1337 取模,a 是一个正整数,b 是一个非常大的正整数且会以数组形式给出。 示例 1: 输入: a = 2, b = [3] 输出: 8 示例 2: 输入: a = 2, b = [1,0] 输出: 1024 """ class Solution: def Add(self, num1, num2): while num2 != 0: temp = num1 ^ num2 num2 = (num1 & num2) << 1 num1 = temp return num1 ...
f086b14cc8ddd30cf31479e27e740431d84243a3
Andrewlearning/Leetcoding
/leetcode/String/Palindrome(回文)/680. 删除一个字符形成回文串.py
959
3.65625
4
""" 给定一个非空字符串 s,最多删除一个字符。判断是否能成为回文字符串。 示例 1: 输入: "acba" 输出: True ab (1) cd (c) ba """ class Solution(object): def validPalindrome(self, s): """ :type s: str :rtype: bool """ l = 0 r = len(s) - 1 while l < r: if s[l] != s[r]: # 在 ...
bb4949677622a5c90170350cf032ab99e3d3a8ca
Andrewlearning/Leetcoding
/leetcode/Array/区间(扫描线,堆)/56. 区间合并.py
1,559
3.9375
4
""" 给出一个区间的集合,请合并所有重叠的区间。 示例 1: 输入: [[1,3],[2,6],[8,10],[15,18]] 输出: [[1,6],[8,10],[15,18]] 解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6] """ class Solution(object): def merge(self, intervals): """ :type intervals: List[List[int]] :rtype: List[List[int]] """ if not intervals or len(...
34cf89a651eeb1294f0f0ad79ed607bee4f8d389
Andrewlearning/Leetcoding
/leetcode/Tree/968m. 监控二叉树(分配,贪心).py
1,886
3.953125
4
""" 给定一个二叉树,我们在树的节点上安装摄像头。 节点上的每个摄影头都可以监视其父对象、自身及其直接子对象。 计算监控树的所有节点所需的最小摄像头数量。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def minCameraCover(self, root): ...
5bfda894800a87be20bdc2844e69d3a4d0a6f0cd
Andrewlearning/Leetcoding
/leetcode/String/基础/28. Implement strStr().py
1,814
3.921875
4
""" Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "hello", needle = "ll" Output: 2 """ class Solution(object): def strStr(self, haystack, needle): """ :type haystack: str :type needle: str :rtype...
571652ae840eb882bc873321cdcbd87711fdeaa0
Andrewlearning/Leetcoding
/leetcode/BFS/841. 钥匙和房间(BFS).py
1,132
3.515625
4
""" 输入: [[1],[2],[3],[]] 输出: true 解释: 我们从 0 号房间开始,拿到钥匙 1。 之后我们去 1 号房间,拿到钥匙 2。 然后我们去 2 号房间,拿到钥匙 3。 最后我们去了 3 号房间。 由于我们能够进入每个房间,我们返回 true。 示例 2: 输入:[[1,3],[3,0,1],[2],[0]] 输出:false 解释:我们不能进入 2 号房间。 """ class Solution(object): def canVisitAllRooms(self, rooms): """ :type rooms: List[List[int]] ...