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 |
|---|---|---|---|---|---|---|
4506ae03ec569f5a51e170d2942f8d74893f6629 | 2648226350/Python_learn | /pych-ten/10_6to10_10.py | 703 | 3.828125 | 4 | #10-6&&10-7
print("Give me two number, and I'll plus them.")
while True:
num_one = input("First num: ")
if num_one == 'q':
break
num_two = input("Second num: ")
if num_two == 'q':
break
else:
try:
summary = int(num_one) + int(num_two)
except ValueError:
... |
269f89eeefe703fa2be01b331e9811b8506ade2f | 2648226350/Python_learn | /pych-ten/pych-test/isYourBirthdayroNot.py | 431 | 3.890625 | 4 | filename = 'file\pi_digits_million.txt'
with open(filename) as file:
lines = file.readlines()
pi_string = ''
for line in lines:
pi_string += line.strip()
birthday = input("Please input your bithday in the form of 'mmddyy': ")
if birthday in pi_string:
print("Your birthday appears in the first hundred millio... |
19a308b87ea463cb6dde4767b06f5356caf5c954 | 2648226350/Python_learn | /pych-four/4_1to4_2.py | 489 | 3.953125 | 4 | #4-1
pizzas = ["new york style","chicago style","california style","pan pizza"]
for pizza in pizzas:
print(pizza.title().ljust(20),end = "")
print()
comment = "I like "
for pizza in pizzas:
print(comment+pizza.title()+".")
summary = "I really love pizza!"
print(summary)
#4-2
animals = ["lion","dog","cat","tigge... |
1fb2d7ac1bffe76e5c31c6bf23a2d22c9e612cda | 2648226350/Python_learn | /pych-eleven/pych-test/test.survey.py | 691 | 3.671875 | 4 | import unittest
from survey import AnonymousSurvey
class TestAnonymouSurvey(unittest.TestCase):
def setUp(self):
question = "What language did you first learn to speak?"
self.my_survey = AnonymousSurvey(question)
self.responses = ['English','Chinese','Franch']
def test_store_single_respo... |
65d52329fb4f8fc79768b6b3d2b4bd9f32e285cf | KingPegasus/HackerRank | /Problem Solving/Algorithms/Beautiful Triplets.py | 876 | 3.875 | 4 | #https://www.hackerrank.com/challenges/beautiful-triplets/problem
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the beautifulTriplets function below.
def beautifulTriplets(d, arr):
countTriplets = 0
for i,a in enumerate(arr):
temp = 0
baseValu... |
e477036a7b8648a8e771149b927dedd3624f1705 | KingPegasus/HackerRank | /Python/Easy/Nested Lists.py | 620 | 3.734375 | 4 | #https://www.hackerrank.com/challenges/nested-list/problem
if __name__ == '__main__':
Students=[]
for _ in range(int(input())):
name = input()
score = float(input())
student = [name,score]
Students.append(student);
min_score=100
sec_min= 100
for [a,b] in S... |
d748964e5affb9298d40cd97187798adf2f56a32 | aiazm496/PythonCompetitive | /codeforces_112A.py | 136 | 3.859375 | 4 | s1 = input()
s2 = input()
if(s1.lower()< s2.lower()):
print("-1")
elif(s1.lower()> s2.lower()):
print("1")
else:
print("0") |
f7d6ca3a583d86f65216908c73e3d4049a263946 | iseriki/hometask | /hometask.py | 1,491 | 3.5625 | 4 | names = ['Ann', 'Bob', 'Suzan', 'Radonir', 'Fill', 'Sam', 'Al']
ages = [12, 33, 56, 87, 4, 18, 21]
text_a = "Special cases aren't special enough to break the rules."
text_b = "In the face of ambiguity, refuse the temptation to guess."
# Задание:
# 1. Посчитать количество элементов в списке names
len(names)
# 2. Пос... |
0c10e5484ab79e16816ad868e64643bf13856ce0 | techacking/conecta | /venv/Lib/site-packages/djangobower/shortcuts.py | 767 | 3.796875 | 4 | import os, sys
def is_executable(path):
"""Check file is executable"""
if sys.platform == 'win32':
executable = os.access(path, os.X_OK) or path.lower().endswith(".cmd")
return os.path.isfile(path) and executable
return os.path.isfile(path) and os.access(path, os.X_OK)
def which(program)... |
5cb4f9094254dd1c87fddb21e32b812e9a30cc84 | rita-bot/Rita-DrawPy-2021 | /Client/MainMenu.py | 1,914 | 3.765625 | 4 | from tkinter import *
from tkinter.messagebox import showinfo
import LoginPage
import RegisterPage
class MainMenu(object):
def __init__(self, client):
self.client = client
self.root = Tk()
self.root.eval('tk::PlaceWindow . center')
self.root.title('DrawPy')
self.login_b... |
b1275e7bc1efb9ac444224b24e9bf43de4591237 | datasciencewizards/datasciencetricks | /codetricks/visualizations/scatter_plot.py | 294 | 3.765625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
#load sample data
df = pd.read_csv("advertising_data.csv")
#data to scatter
x = df['TV']
y = df['sales']
#plotting data
plt.scatter(x, y)
plt.title('Scatter Plot')
plt.xlabel("Money spent on TV Ads ($)")
plt.ylabel("Sales ($)")
plt.show()
|
7e3f62377f5768ef7482b39f715c06663de3d12b | usc-ee250-spring2020/GrovePi-EE250 | /ee250/archive/lab10/vigenere.py | 1,769 | 4.09375 | 4 | def encrypt(phrase, key):
assert isinstance(phrase, str) and isinstance(key, str)
key = key.lower()
phrase = phrase.lower()
new_phrase = ''
key_idx = 0
# increment through the characters of the phrase
for i in range(len(phrase)):
# if it is a letter of the alphabet encode it
if phrase[i].isalpha():
# con... |
a1d81122b91e07e1078a3b9e4405e3da03884315 | usc-ee250-spring2020/GrovePi-EE250 | /ee250/lab06/mailboxTools.py | 4,131 | 3.546875 | 4 | from pprint import pprint
import json
import requests
class mailboxClient():
def __init__(self, username, serv_addr, serv_password):
"""
Summary: Class that manages the HTTP interactions with a mailboxServer
Args:
username (string): Username that will identify the client for c... |
50a378e2d85d0ed677db5406146bad11e5262d3f | RonquilloAeon/street-game | /__main__.py | 3,292 | 3.609375 | 4 | """
workon game
Resources:
https://opengameart.org/content/isometric-city
https://kenney.nl/assets/road-textures
Info:
https://stackoverflow.com/questions/40443430/displaying-an-image-using-a-class-on-pygame
"""
import pygame
from pygame.locals import *
class Road(pygame.sprite.Sprite):
def __init__(self, fp, d... |
24f61da509a732682c0aa7c3db9cbd95c5b1d9ec | frozenjava/TidePod-Pi | /app/sensors/sensor.py | 975 | 3.515625 | 4 | from typing import Optional, TypeVar, Generic
import abc
TConfig = TypeVar('TConfig')
class Sensor(Generic[TConfig]):
def __init__(self, name: str, config: Optional[TConfig]):
"""
@param name: The name of this sesnor. Must be unique to all sensors
@param config: The config object fo... |
4fd15d3e74cb6ea719d26bf9f30704f5f7c7de7b | mfcust/sorting | /sorting.py | 2,274 | 4.53125 | 5 | # 1) Run the code in the markdown and write a comment about what happens.
# 2) Try to print(sorted(my_list2)) and print(my_list2.sort()). Is there a difference? What do you observe?
my_list2 = [1,4,10,9,8,300,20,21,21,46,52]
# 3) Let's say you wanted to sort your list but in reverse order. To do this, you ... |
5b9dff75a516f758e8e8aef83cf89794176b488b | Mukilavan/LinkedList | /prblm.py | 880 | 4.21875 | 4 | #Write a Python program to find the size of a singly linked list.
class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class linkedList:
def __init__(self):
self.head = None
def insert_beg(self, data):
node = Node(data, self.head)
... |
bc337a87619e570d1de3187f40c831289e9b3705 | jemmyperez28/TestPython | /pregunta8.py | 394 | 3.78125 | 4 | """Hacer un programa que genere un array y que imprima los numeros que no son iguales"""
import random
array_lenght = random.randint(50,100)
lista = []
x=1
while x <= array_lenght:
numero_alea = random.randint(1,30)
lista.append(numero_alea)
x = x + 1
print("Array Generado : \n" + str(lista))
#unicos
un... |
775c96a0cd0dd33dd111f11f7e46c3632fefbe23 | krish9191/basic_games | /tic_tac_toe/tictactoe_manager.py | 1,100 | 3.828125 | 4 | def create_square_matrix(number):
return [[8 for i in range(number)] for j in range(number)]
def matrix_transpose(arr):
arr_t = [[8 for i in range(len(arr))] for j in range(len(arr[0]))]
for i in range(len(arr)):
for j in range(len(arr[0])):
arr_t[j][i] = arr[i][j]
return arr_t
d... |
03f18acd29d365363c9d1ef2b16976a8ec1b2fad | aidanwilliams09/Travelling-Salesman | /tours.py | 811 | 3.796875 | 4 | from random import seed, random
from math import sqrt
# create num_cities random coordinates
def generate_cities(num_cities):
seed()
return [(random(), random()) for _ in range(num_cities)]
# create number instances and call generate_cities
def generate_instances(number=100, num_cities=7):
return [generat... |
20a02bc142f78cb71a52df056fb25406df53a11c | RobertoFeu/na_utilis | /21_june_ex3.py | 795 | 3.703125 | 4 | import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# 1. Function to compute ECDF
def ecdf(data):
"""Compute x, y values for an empirical distribution function."""
x = np.sort(data)
y = np.arange(1, len(data)+1) / len(data)
return x, y
# 2. Load in the data sets
xa_high = np.loa... |
fd92b77b3fa14090b5d2e18b6cdf7884e566dfc9 | sandhyakopparla/python | /practice all/collections_topic/count.py | 182 | 4.03125 | 4 | from collections import Counter
a=[1,2,2,3,4,32,9,2,3,5,5,1]
count=Counter(a)
print(list(count.elements())) #it will print the output in an ordered format like 1,1,2,2,2
print(count) |
0c27d658aa51bf00e502d09344cb771b0029069d | sandhyakopparla/python | /exam_task/3rd_week/question1.py | 644 | 3.71875 | 4 | import threading,logging
# mylist=[1,2,3,4,5,56,7,8,56,67,89,90]
def even(getlist):
even_no=list(filter(lambda x:(x%2==0),mylist))
print("even numbers in the list is:",even_no)
def odd(getlist):
odd_no=list(filter(lambda x:(x%2==1),mylist))
print("odd number in the list is",odd_no)
mylist=[... |
c080403bb323d98a4165491fe04168069f8bad97 | Acooper00/Revision-Notes | /Revision.py | 33,470 | 3.5 | 4 | #! /usr/bin/python3
""" Files must be structured with sections starting with '~' and tabs denoting the sub-level of the section. Each new section (including the title) must be a tab more than the section it is contained in. The first section should be indented by one tab. """
Subject_Files = {"English_Literature":"EN... |
655f533cabc444d5e0166b1398e762e7574fd6de | itoulou/Noughts-and-Crosses | /XandO.py | 2,834 | 4.03125 | 4 | def display_board(board):
print(board[7] + '|' + board[8] + '|' + board[9])
print("______")
print("")
print(board[4] + '|' + board[5] + '|' + board[6])
print("______")
print("")
print(board[1] + '|' + board[2] + '|' + board[3])
def check_win(board, marker):
if board[7] == board[8] == bo... |
6da93542a02ae983ed180784310ea3eeaa2985dc | Paradox-1337/less3 | /les3_4.py | 1,344 | 4.21875 | 4 | # Решение1
# x = int(input("Введите чило для возведения в степень: "))
# y = int(input("Введите отрицательное чило, для возведения числа X в эту степень: "))
# if y <= 0:
# x_y = x**y
# print(x_y)
# else:
# print("Введите отрицательное число! ")
# Решение 2
# def my_func():
# x = float((... |
aab1efc075a5bf9eb58f64ed4f1e42795b1d60c6 | paulberinde/fruitvliegen | /intersections_functions.py | 1,590 | 3.984375 | 4 | def calcMisplacement(self):
self.misplaced = []
'''
This code creates an array of numbers which are based on the difference between
the current index of the element and the place it should end up (in other words, how
many places it's removed from its final place).
... |
c623673fa3ddf18850b525a290d3f7afb2c81aa0 | GuilhermeAmado/alien_invasion | /bullet.py | 1,133 | 3.875 | 4 | import pygame
from pygame.sprite import Sprite
class Bullet(Sprite):
"""Classe para gerenciar as balas atiradas pela nave"""
def __init__(self, ai_game):
"""Cria um objeto de projétil de bala na posição atual da nave"""
super().__init__()
self.screen = ai_game.screen
self.sett... |
170a8282c3634945e708cca8b50de856accbb719 | chasorleo/ProjectEuler | /ep19.py | 911 | 3.703125 | 4 | from time import time
start_time = time()
ordin = 365
orlist = [0, 3, 3, 6, 8, 11, 13, 16, 19, 21, 24, 26]
leap = 366
leaplist = [0, 3, 4, 7, 9, 12, 14, 17, 20, 22, 25, 27]
day = 0
firstday = 1 # what day is the first day of the year
lastday = 0
for i in range(1901, 2001):
oldfirstday = firstday
ml = []
if... |
e02750dca90b02ef3fcc59ec7b519188aa3859c0 | Daniel-Chow-YC/eng-48-api-http-basics | /json_and_post_code_api.py | 673 | 3.8125 | 4 | import json
car_data = {"name": "Vauxhaul Adam", "engine": "Diesel"} # This is a dictionary
car_json_string = json.dumps(car_data) # creates a string that looks like a dictionary
# print(car_json_string)
# print(type(car_json_string))
# Creating a Json from a dictionary (encoding)
# json.dump(obj, file) --> file.js... |
913c6388da36112fa5a33871b99bab539dc1e356 | Nishinomiya0foa/Old-Boys | /2_Threading_MySql_html/day38/06_JoinableQueue.py | 1,663 | 3.515625 | 4 | """JoinableQueue:
---- 相比于Queue,每一次get了值,需提交一次回执(q.task_done())
q.join() # 阻塞 知道一个队列中的所有数据,全部被处理完毕
在消费者:
1.每次获取一个数据
2.处理这个数据
3.发送一个标识: 成功处理数据
生产者:
1.每次生产一个数据
2.将这个数据放入队列
3.在队列中刻上一个记号
4.全部生产完毕, 发出join()信号; 等待之前刻上的记号都被消费者处理完,join()阻塞结束
"""
import random
import time
from mult... |
12728e56bcac10df07c317028832f22903612504 | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day33/03_socketserver.py | 634 | 3.53125 | 4 | """socketserver:同时与多个客户端通信"""
# 基本读懂源码
# import socketserver
# class MyServer(socketserver.BaseRequestHandler): # 必须继承这个类
# def handle(self): # 必须重写handle方法
# print(self.request.recv(1024)) # self.request 相当于 socket中的conn,即 conn,addr = skt.accept()中的conn
# self.request.send(b'123')
# ... |
c6d266697a2f60b1570f77ab46c8d0b666fc3479 | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day11/01_last_homework.py | 13,480 | 4.1875 | 4 | """
1,继续整理函数相关知识点,写博客。
"""
"""
2,写函数,接收n个数字,求这些参数数字的和。(动态传参)
"""
# def get_sum(*args):
# sum = 0
# for i in args:
# sum += i
# return sum
# print(get_sum(1,3,2,5,6,0,-1))
"""
3,读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么?
a=10
b=20
def test5(a,b):
print(a,b)
c = test5(b,a)
pri... |
efbccaec661d3ae5406d5f2f0813a29dee7f2398 | Nishinomiya0foa/Old-Boys | /2_Threading_MySql_html/day40_thread/03_ThreadingPrinciple.py | 1,543 | 3.6875 | 4 | """线程 ---- cpu调度的最小单位
概念:
1. 轻型实体: 线程中的实体基本上不拥有系统资源,只需能保证独立运行的资源
包括程序,数据和TCB。 线程是动态概念,它的动态特性由线程控制块TCB描述。
2. 可并发
进程和线程的区别:
1.地址空间和其他资源(文件、代码),在进程间相互独立;同一进程的各线程间共享。
4.在多线程操作系统中,进程不是一个可执行的实体。
Cpython 解释器的特性. Jpython解释器则没有
全局解释器锁 GIL ---- 为了数据安全,同一时刻只能有一个线程访问cpu,降低了cpu效率
锁的是线程... |
3522711987fbec1e014e069cbbe1593f8e6c1b3e | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day19_module/04_os.py | 1,083 | 3.6875 | 4 | """ os模块 ---- 与操作系统交互的一个接口
和路径相关的操作都在os模块
"""
import os
# print(os.getcwd()) # 返回当前执行文件所在目录
# os.chdir('F:\Old Boys') # 改变当前脚本的工作目录
# os.makedirs(path) # 创建目录,可相对路径也可绝对路径
# os.removedirs(path) # 递归删除路径,为空则删除,并返回到上级,空就再删
# os.mkdir(path) # 创建单级目录
# os.rmdir(path) # 删除单级子目录
# os.listdir(path) # 打印path目录下,所有文件、... |
f10be4d04fea97886db620447999632fc3c706da | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day24_3features/4_multi_Inheritance.py | 1,402 | 4.53125 | 5 | """多继承
平时尽量不用! 应使用单继承
"""
# class A:
# def func(self):
# print('A')
#
# class B:
# def func(self):
# print('B')
#
# class C:
# def func(self):
# print('C')
#
# class D(A, B, C):
# pass
# # def func(self):
# # print('D')
#
# d = D()
# d.func() # 如果D()中有 func方法,则调用其... |
ba204273f3f156a0d7dac5ccefc8d0ce2face9c3 | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day22 OO/01_ObjectO_OO.py | 2,064 | 4.0625 | 4 | """OO:面向对象 ---- 适合复杂的程序
优点:易于扩展
缺点:可控性差
类:抽象
对象、实例:具体存在。 先有类,再有对象
类可以规范对象
"""
# 基本结构
class Person: # Person类名:操作属性,查看属性 ---- 类名
country = 'China' # 创造类中全局属性,类属性,即静态属性,静态属性无法在外部更改;所有实例对象都拥有这个属性
def __init__(self, *args): # 调用这个类时,会自动调用__init__()方法;self是一个必须传递的参数 ---- 初始化方法
... |
2a4a6cd2cbea2a14aa5d88008f9681031f289fd9 | Nishinomiya0foa/Old-Boys | /practice/picture_doodle.py | 920 | 3.90625 | 4 | """
做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),
使用 Python 如何生成 200 个激活码(或者优惠券)?
"""
# 16位, 大小写英文+数字, 每4位用 - 分离
# ascii 97-122 65-90
# 0-9
import random
def getcode(n):
with open('200codes.txt', 'w', encoding='utf-8') as f1:
for num in range(n):
lis = []
f... |
4e2b5db82f6bb4b1ac52b51637c375735b279dfc | Nishinomiya0foa/Old-Boys | /2_Threading_MySql_html/day42_Coroutine_IO/04_IO_Multiplexing/server.py | 578 | 3.53125 | 4 | """多用复用io 模型"""
import select
import socket
skt_s = socket.socket()
ip_port = ('', 8091)
skt_s.setblocking(False)
skt_s.bind(ip_port)
skt_s.listen(1)
read_lst = [skt_s]
while True:
r_list, w_list, x_list = select.select(read_lst,[],[])
for i in r_list:
if i is skt_s:
conn, addr = i.accep... |
81660e3c5bf7183dee2d45b575db34be7f8e0477 | Nishinomiya0foa/Old-Boys | /2_Threading_MySql_html/day37/07_daemon.py | 803 | 3.640625 | 4 | """
守护进程: 是子进程转换成的
---- 守护进程会随着主进程的代码执行结束而结束*; 即即使有其他的子进程还活着,守护进程也会结束.
p.daemon = True 设置为守护进程
p.name # 进程名
terminate() # 关闭子进程; 不会立即生效,操作系统会有一个极短的响应时间.
is_alive() # 返回进程是否存活
"""
import time
import random
from multiprocessing import Process
class TryDaemon(Process):
def run(self):
while True:
... |
0715eeb5328b5950ab3046d1a851048c1f15fa56 | Nishinomiya0foa/Old-Boys | /homework/ftp_homework/core/client.py | 2,481 | 3.640625 | 4 | """
1.输入username 和pwd 上传至server
2,登录成功:接收菜单 下载 / 上传?
1.下载:接收下载目录,选择文件,本地创建空文件,逐行接收文件,进行写入
2.上传:选择上传的文件,逐行传输
3.登录失败,程序终止运行
"""
import socket
import os
import json
from homework.ftp_homework.conf import conf
def connect():
skt = socket.socket()
skt.connect(conf.ip_port)
username = input('usernam... |
b648efd53c0a567602677b9af6a48d9ae20cc783 | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day26/02_Encapsulation.py | 498 | 3.78125 | 4 | """封装
私有属性和方法不被子类继承
"""
# 例子
class Room:
def __init__(self, owner, length, width):
self.owner = owner
self.__length = length
self.__width = width
def get_area(self):
return self.__length * self.__width # 内部调用私有属性
# chen = Room('陈文波', 12, 8)
# print(chen.get_area())
# 用到私有概念的场... |
48e05ac69a0d05e16662cf785f4c0a0853317a54 | Nishinomiya0foa/Old-Boys | /2_Threading_MySql_html/day42_MySql_base/2_MySql_Statement.py | 2,617 | 3.5 | 4 | """MySql语句规则
数据库
创建数据库
create database <name> default charset utf8;
删除数据库
drop database <name>;
数据表
新建数据表
create table <table name>(
列名1 类型 null/not null default <值> ,
*是否允许为空 默认值
列名2 类型 auto_increment primary key
... |
9e5ffc966fce92807345e48707d5e85cc38cc978 | Nishinomiya0foa/Old-Boys | /1_base_OO_net/day10/02 function nest.py | 5,431 | 3.5625 | 4 | # _*_ coding:utf-8 _*_
__author__ = 'brian'
__date__ = '2019/3/2 0002 22:37'
"""函数嵌套和作用域链"""
"""
函数嵌套调用:
def func1():
pass
def func2():
func1()
func2()
第一类对象: ----函数属于此类
1.可在运行时创建
2.可作为函数的参数或返回值
3.可作为变量的实体
函数可以嵌套定义
def outer():
def inner():
pass
内部函数... |
913b2ecdd15d9dbfedb82cb3bd843c4f75fe6e04 | sarthakforwet/Hash_Code_2k20 | /Hash_Code/hash_code.py | 985 | 3.609375 | 4 | # first line - Max number pizza slices , Number of different types of pizzas
# Second Line - N integers # slices in each type of pizza
from itertools import combinations
a,b = map(int,input().rstrip().split(" "))
type_pizza = list(map(int,input().rstrip().split(" ")))
tests = []
for i in range(1,b+1):
tests.append... |
44d85b024fcc7a6720ebec73b301754dbcbe57b1 | dmarx/GameOfLife | /game_of_life.py | 1,685 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Conway's Game of Life
Created on Mon Dec 01 13:36:30 2014
@author: davidmarx
"""
import numpy as np
import matplotlib.pyplot as plt
def gen_neighbors(pos, board_shape):
"""
Given a set of input coordinates, get the coordinates of all neighboring
tiles.
"""
ix2 = np.a... |
51edfa631fe0360cb2f5eae1d8507a0458ec9126 | AbdulGaniy/ASSIGNMENT1 | /question 3.py | 487 | 3.890625 | 4 | import random
for x in range(1):
number = random.randint(1,201)
guess_number = input("Now guess a number:")
val = int(guess_number)
if (number - val > 10 and number - val > 0) or (val - number > 10 and val - number > 0):
print(number)
print("try again, you are far away")
elif(val- number < 10 and va... |
45b1a020be6cefbf437415987ca4e668fcd5a8aa | kaizen-soze/texas-holdem-poker | /python/objects/deck.py | 1,210 | 3.640625 | 4 | import random
from collections import deque
from python.objects.card import Card
class Deck:
'A representation of a deck of cards'
def __init__(self):
self.__createCards()
pass
def burn(self):
self.deck.popleft()
def nextCard(self):
return self.deck.popleft()
de... |
36e736bd22196fe9e3aa3d3b4dc2c297d0bf4912 | kaizen-soze/texas-holdem-poker | /python/objects/card.py | 1,487 | 3.765625 | 4 | class Card:
'A representation of a playing card'
def __init__(self, value, suit):
self.value = value
self.suit = suit
self.suitEmoji = self.__fetchEmoji(suit)
self.score = self.__calculateScore()
# Calculate the score of a card
def __calculateScore(self):
score ... |
7b06e2402f71f016aef61f2896f3e0dc0485b210 | NorthcoteHS/10MCOD-Dimitrios-SYRBOPOULOS | /modules/u3_organisationAndReources/naming/commentMe.py | 417 | 3.640625 | 4 | """
Prog: commentMe.py
Name: Dimitrios Syrbopoulos
Date: 18/04/18
Desc: a calculator that determis the perimeter of a circle
"""
#print welcome message
print('Welcome to the Circle Calculator!')
#make user input radius
r = input('Enter a radius: ')
r = int(r)
#calculate area and print it
area = 3.14 * r * r
print('The ... |
adaea2c6294d090df73e14ee089fe015ad486979 | Dritzii/applying-promo | /applyingpromo.py | 2,268 | 4.0625 | 4 | """
How to apply promotion to a person if they are under a certain age.
Author: John Pham
"""
class shopping():
def __init__(self,Fname,Lname,Age,Family=None):
self.firstname = Fname
self.lastname = Lname
self.age = Age
print("Hello {} it is time to add you onto our system :)".form... |
50042e3c7051ee2be4a19e9d4f858a22a7be88f7 | clarkjoypesco/pythoncapitalname | /capitalname.py | 332 | 4.25 | 4 | # Write Python code that prints out Clark Joy (with a capital C and J),
# given the definition of z below.
z = 'xclarkjoy'
name1 = z[1:6]
name1 = name1.upper()
name1 = name1.title()
name2 = z[-3:]
name2 = name2.upper()
name2 = name2.title()
print name1 + ' ' + name2
s = "any string"
print s[:3] + s[3:]
print s... |
57cbc070897683320ad67a8710488dac46392fbf | r-hata/atcoder | /welcome-to-atcoder.py | 783 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
問題文
高橋君はデータの加工が行いたいです。
整数 a , b , cと、文字列 sが与えられます。
整数 a + b + cと、文字列 sを並べて表示しなさい。
入力
入力は以下の形式で与えられる。
a
b c
s
1行目は、整数 a (1 <= a <= 1,000) が与えられる。
2行目は、整数 b, c (1 <= b, c <= 1,000) が与えられる。
3行目は、文字列 s が与えられる。この文字列の長さは 1文字以上 100文字以下である。
出力
a + b + cと sを空白区切りで 1行に出力せよ。
"""... |
ee8a14b46db017786571c81da934f06a614b3553 | Jamsheeda-K/J3L | /notebooks/lutz/supermarket_start.py | 1,724 | 4.3125 | 4 | """
Start with this to implement the supermarket simulator.
"""
import numpy as np
import pandas as pd
class Customer:
'''a single customer that can move from one state to another'''
def __init__(self, id, initial_state):
self.id = id
self.state = initial_state
def __repr__(self):
... |
7c61f608b0278498c5bac3c8c2833d827754f124 | lynnxlmiao/Coursera | /Python for Everybody/Using Database with Python/Assignments/Counting Organizations/emaildb.py | 2,686 | 4.5 | 4 | """PROBLEM DESCRIPTION:
COUNTING ORGANIZATIONS
This application will read the mailbox data (mbox.txt) count up the number email
messages per organization (i.e. domain name of the email address) using a database
with the following schema to maintain the counts:
CREATE TABLE Counts (org TEXT, count INTEGER)
When you have... |
9415684dc35e4d73694ef14abe732a7ba32bf301 | lenatester100/AlvinAileyDancers | /Helloworld.py | 806 | 4.1875 | 4 | print ("Hello_World")
print ("I am sleepy")
'''
Go to sleep
print ("sleep")
Test1=float(input("Please Input the score for Test 1..."))
Test2=float(input("Please Input the score for Test 2..."))
Test3=float(input("Please Input the score for Test 3..."))
average=(Test1+Test2+Test3)/3
print ("The Average of... |
6811d964c37c5463aeb4153ac78875868a66e7a1 | guiwoda/untref-edd-tp1 | /ConversorUnidades.py | 678 | 3.515625 | 4 | import math
class ConversorUnidades():
@staticmethod
def distancia_legible(distancia):
"""Convierte una distancia en metros a una distancia legible."""
if 1000 > distancia:
return '%s m' % distancia
return '%s km' % round(distancia / 1000, 1)
@staticmethod
def tie... |
911c39365e412d174d91064e110ff729303ede1c | ldp72/polynoms | /polynomial.py | 3,599 | 3.59375 | 4 | import copy
class Polynomial:
def __init__(self, coefficients):
self.__coefficients = copy.copy(coefficients)
while self.__coefficients and self.__coefficients[0] == 0:
self.__coefficients.pop(0)
self.__degree = len(self.__coefficients) - 1
def __str__(self):
strin... |
eea09e9c0463a0a8dae191ff234c26f4c544748e | holamtruong/Learning_Geospatial_Analysis_with_Python | /read_and_write_zip_file.py | 761 | 3.515625 | 4 | import zipfile
def zipfile_name():
zip = open("sample_data/hancock.zip", "rb")
zipShape = zipfile.ZipFile(zip)
shpName, shxName, dbfName = zipShape.namelist()
shpFile = open(shpName, "wb")
shxFile = open(shxName, "wb")
dbfFile = open(dbfName, "wb")
shpFile.write(zipShape.read(shpName))
... |
b719b552170b8128a75a5121ac7578aa51a3e691 | Krishan27/assignment | /Task1.py | 1,466 | 4.375 | 4 | # 1. Create three variables in a single a line and assign different
# values to them and make sure their data types are different. Like one is
# int, another one is float and the last one is a string.
a=10
b=10.14
c="Krishan"
print(type(a))
print(type(b))
print(type(c))
# 2. Create a variable of value type comple... |
d90aef9fce23fc0abc8e7cf46921d822ebb56146 | sioufia/crossword_dm1 | /model.py | 3,517 | 3.546875 | 4 | from parsing import *
from sources.constraint_programming import constraint_programming
import time
def getListOfCellsInASequence(sequence):
"""Take a sequence and returns its cells under the format of variable"""
L = []
if sequence[0][0] == sequence[1][0]: #For a row
a = sequence[1][1] - sequence... |
ccde22affe7f01bff4b8d72e6d759c066b096230 | INTO-CPS-Association/mono-camera-robot-tracking | /Code/Models/SquareModels.py | 1,744 | 3.53125 | 4 | class RobotSquare:
def __init__(self, square, distance = None, angle = None, id = None):
self._square = square
self._angle = angle
self._distance = distance
self._id = id
self._corners = None
self._center = None
self._setup(square)
def _setup(self, square... |
ca641e876124cbc2e8c7ec15a99d98cbe45485b5 | matteobart/my-feed | /tfeed.py | 3,786 | 3.53125 | 4 | import config
import twitter
# Variables that contains the user credentials to access Twitter API
ACCESS_TOKEN = config.t_a_t
ACCESS_SECRET = config.t_a_s
CONSUMER_KEY = config.t_c_k
CONSUMER_SECRET = config.t_c_s
api = twitter.Api(access_token_key=ACCESS_TOKEN, access_token_secret=ACCESS_SECRET, consumer_key=CON... |
86e699a8169d75f3177eaeb1fb64b2cc1c80c53d | dtekluva/class9_code | /dice.py | 639 | 3.5625 | 4 | import random
def getrand():
return random.randint(1,6)
def throw():
die_one = getrand()
die_two = getrand()
return die_one,die_two
def gen_dice(arg):
list1, list2 = [arg[0],0], [arg[1],0]
if arg[0] > 3:
list1 = [3, arg[0] - 3]
if arg[1] > 3:
list2 = [3, arg[1] - 3... |
c31f87afb10962f5f9a0ea1bbdef51359d8b9f0c | dtekluva/class9_code | /Python-class-codes-master/Hang Man.py | 4,620 | 3.625 | 4 | import string
import random
print(" ;; ")
print(" | | ")
print(" ______________________________________|_|___")
print(" /____________________________________________\ ")
print(" /______________... |
ad87aace5baeb10090da1f7898b89297cdc262e3 | dtekluva/class9_code | /Python-class-codes-master/name age acc .py | 540 | 3.96875 | 4 | print("=========My Second PYTHON CODE==========")
print()
name = input("please enter your name: ")
age = int(input("please enter your age: "))
acc_bal = int(input("please enter account balance: "))
born=2017-age
max_bal = 1000
if acc_bal > max_bal:
print("At age ",age,", ",acc_bal,"naira is over the max allowed o... |
bc72cd2a3c2a12dd0894b1552b18b23cf6f245e5 | dtekluva/class9_code | /program.py | 1,309 | 3.90625 | 4 |
_list = []
structured_list = []
# users = "Ada, Ukbabi, ukpabi1, 3pm", "uche, ukanam, uchman, 3pm", "inyang, KPongette, inyanga50, 8am"
while True:
action = (input('Do you want to add name(A) or search name(S)')).lower()
if action == "a":
x = input("enter details with comma spaces : ")
_li... |
b1e46afcc92f87b3db3efe9cd9e0c53461ba49ba | dtekluva/class9_code | /Python-class-codes-master/delete.py | 2,048 | 3.859375 | 4 | ##def list_printer(listn):
## i=0
## if type(listn) is list:
## print()
## print("PRINTING LIST !!!!")
## print()
## for item in listn:
## print(i+1," : ",item)
## print()
## i+=1
## if type(listn) is dict:
## print()
## print("PRINTING... |
acd26a2c350e4f3893553f6db77e7eaf8a285f75 | VayerMaking/elsys2020-2021 | /rs/29092020/zad3.py | 169 | 3.703125 | 4 | def list_dict(listche):
my_dict = {}
my_dict = dict((i, listche.count(i)) for i in listche)
return my_dict
print(list_dict(["lama", "baba", "kon", "kon"]))
|
712f8daec6b47612f6a10906ccbba78ca365f48a | superwenqistyle/2-2018python | /05daay/训练/父类方法.py | 662 | 3.625 | 4 | class Father(object):
instance=8
def __new__(cls):
print("要返回了...")
return object.__new__(cls)
print("第一次返回")
return super().__new__(cls)
print("第二次返回")
def __init__(self):
self.skills=6
print("father的方法")
def __str__(self):
return "我会的技能有%d种"%self.skills
def __del__(self):
print("del功能要执行了....."... |
04441fea9b26e0273623a60cba55e7c45fd6d954 | superwenqistyle/2-2018python | /13day/创建元类.py | 218 | 3.609375 | 4 | class Bar(object):
def info(self):
print("Tom是什么")
def show(self):
print("the life is short ,wo need python")
Dog=type("Dog",(Bar,),{"name":"Tom","show":show})
dog=Dog()
print(dog.name)
dog.info()
dog.show()
|
1e8fdd7ac13bab76d8c1cb7f2469442a1405eda7 | superwenqistyle/2-2018python | /02day/int.py | 511 | 3.734375 | 4 | class boy():
def __init__(self,age,height):
self.game=[]
self.age=age
self.height=height
game=input("输入要玩的游戏:")
#self.game=[game]
self.game.append(game)
def study(self,test):
print("学习:%s"%test)
def sing(self,test):
print("唱歌:%s"%test)
def introduce(self):
print("年龄:%d\t身高:%d\t"%(self.age,self.hei... |
a51b43d3e53afd3df345cd74ed5f5b86e33e75fd | superwenqistyle/2-2018python | /12day/魔法方法.py | 257 | 3.703125 | 4 | class Dog():
def __init__(self,name):
self.name=name
def __str__(self):
return self.name
def __del__(self):
print("删除实例......")
dog1=Dog("阿财")
dog2=Dog("阿旺")
print(dog1)
print(dog2)
del dog1
print("*"*10)
del dog2
print("hahfahfa")
|
7c26e247edf7b433239294d5ede65388d26c1af4 | superwenqistyle/2-2018python | /训练/重写.py | 255 | 3.71875 | 4 | class Father(object):
def __init__(self):
print("Father的方法")
class Son(Father):
def __init__(self):
super().__init__()
Father.__init__(self)
print("*"*10)
object.__init__(self) #系统没有作出反应
print("*"*10)
xiaoming=Son()
|
953ed2c94e19a170fbe076f10339ff79ccda32f7 | chaithanyabanu/python_prog | /holiday.py | 460 | 4.21875 | 4 | from datetime import date
from datetime import datetime
def holiday(day):
if day%6==0 or day%5==0:
print("hii this is weekend you can enjoy holiday")
else:
print("come to the office immediately")
date_to_check_holiday=input("enter the date required to check")
day=int(input("enter the day"))
month=int(input("en... |
91572a07bf2cbe5716b5328c0d4afc34c5f375f8 | prince5609/Coding_Bat_problems | /make_bricks.py | 1,151 | 4.5 | 4 | """ QUESTION =
We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each)
and big bricks (5 inches each). Return True if it is possible to make the goal by choosing from the given bricks.
make_bricks(3, 1, 8) → True
make_bricks(3, 1, 9) → False
make_bricks(3, 2, 10) → True... |
1080e5a37eef774ebe6131a43ad761d41ecb68bb | GloriaAnholt/pydata-book | /ch02-babynames.py | 2,897 | 3.734375 | 4 | # Python for Data Analysis: Ch 02 US Baby Names 1880-2010
# 4/20/2016
# @totallygloria
"""
This code snippet comes from Ch 02 of Python for Data Analysis by Wes McKinney
(O'Reilly: Sebastopol, CA, 2014). See page 28 on for more information.
"""
import pandas as pd
import numpy as np
names1880 = pd.read_csv('ch02/nam... |
3c09271fc78291a07d6cca5e40b8add7e37f1837 | jonathanreveille/project3_OC | /macgyver/views/macgyver.py | 1,761 | 3.875 | 4 | #! /usr/bin/env python3
# coding : utf-8
""" This class represents the hero in graphics and
we control his directions according to moves"""
import pygame as pg
from config.settings import HERO, SPRITE_WIDTH, SPRITE_HEIGHT
from macgyver.models.mouvement import right, left, up, down
class MacGyver(pg.sprite.Sprite):
... |
c9761feeb5e2dcd4ea4a3251eeba4caa2745b304 | RNabel/InterviewPreparation | /Python/CTCI/QueueFromStacks.py | 1,019 | 3.953125 | 4 | class MyQueue(object):
def __init__(self):
self.first = []
self.second = []
self.first_out_of_date = False
self.second_out_of_date = False
def peek(self):
if self.first_out_of_date:
self.first = self.second[::-1]
self.first_out_of_date = False
... |
079684631ae3e00c61fb7f6c54d5864c5b17ada1 | RNabel/InterviewPreparation | /Python/ConnectedCellInGrid/ConnectedCellInGridProblem.py | 1,821 | 3.609375 | 4 | import sys
def parse_grid(string):
string = string.strip()
lines = string.split('\n')
rows = int(lines[0])
columns = int(lines[1])
grid = []
for line in lines[2:]:
grid.append([int(x) for x in line.split(' ')])
return grid
def floodfill(grid, x, y, max_row, max_col):
total ... |
d0f16fa8e543ce3fb92bcc73fc550378ba8ec318 | powderblock/powderblog | /python_files/md_to_HTML.py | 5,011 | 3.546875 | 4 | # Used for string.replace()
import string
import sys
import re
def markdown_to_HTML(filename):
# Take input from the user:
with open(filename, 'r') as content_file:
md = content_file.read()
# Have we found bold or italic characters yet?
bold = False
italics = False
# No. That's why the... |
53c7e504cde7e7d374cf3ff65291901962e7e22d | larsonmp/zsh-working-environment | /lib/python/util/shell.py | 1,137 | 3.65625 | 4 | import os
import pprint
import sys
def calculate(operation):
"""Perform basic arithmetic operations."""
print eval(str(operation))
def print_email():
"""Prints my (Micah's) e-mail address. This function is preserved solely for its obnoxiousness."""
print '@'.join(['.'.join([w[::-1] for w in p.split('... |
3208d795ade855b5dbbe9b381c437266c93131b9 | he44/Practice | /leetcode/2020_07_challenge/0710_flatten_multilevel_doubly_linked_list.py | 568 | 3.625 | 4 | from typing import *
class Solution:
def flatten(self, head: 'Node') -> 'Node':
if not head:
return None
stack = [head]
prev = None
while stack:
cur = stack.pop()
if prev:
prev.next = cur
cur.prev = prev
# r... |
35dbbd4fbe62a3b8f36ee8af5f68bc5d515670af | he44/Practice | /leetcode/2020_05_challenge/0524_bst_from_preorder.py | 799 | 3.90625 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def bstFromPreorder(self, preorder: List[int]) -> TreeNode:
root = TreeNode(preorder[0])
stack = [roo... |
72aa13bdac0add53d93b7792608ce4a8a0b52a60 | he44/Practice | /leetcode/2020_07_challenge/0729_best_time_to_buy_and_sell_stock_with_cooldown.py | 553 | 3.5625 | 4 | from typing import *
class Solution:
def maxProfit(self, prices: List[int]) -> int:
held = float('-inf')
sold = float('-inf')
reset = 0
for price in prices:
pre_sold = sold
sold = held + price
held = max(held, reset - price) #either nothing, or b... |
8d3c4469a22ab15c85cdbfb37af3634a7bca33f1 | he44/Practice | /aoc_2019/1/1_p1.py | 274 | 3.8125 | 4 | input_file = 'input.txt'
with open(input_file, 'r') as fp:
lines = fp.readlines()
total_fuel = 0
for line in lines:
mass = int(line)
fuel = int(mass / 3) - 2
print(mass, fuel)
total_fuel += fuel
print('Sum of the fuel requirements is %d'%total_fuel)
|
d4bfebac411b7dd14287628c199135e30471da10 | he44/Practice | /aoc_2019/24/test.py | 848 | 3.75 | 4 |
def sum_col(grid, c):
total = 0
for r in range(5):
total += grid[r][c]
return total
def sum_row(grid, r):
total = 0
for c in range(5):
total += grid[r][c]
return total
# Sum up the number of bugs in one grid
def sum_grid(grid):
sum_g = 0
for row in grid:
sum_... |
d02bfce245b8e22feff5d44cbb009fc232ab8620 | he44/Practice | /leetcode/2020_08_challenge/0801_detect_capital.py | 660 | 3.59375 | 4 | from typing import *
class Solution:
def detectCapitalUse(self, word: str) -> bool:
def case(char):
return ord('A') <= ord(char) <= ord('Z')
# except for the first char, all remaining should be same
first = case(word[0])
seen = None
for char in word[1:]:
... |
5e6834a78a8a80a2649038a15be649e18ec35e91 | he44/Practice | /leetcode/2020_08_challenge/0802_design_hashset.py | 1,046 | 3.828125 | 4 | from typing import *
class MyHashSet:
def __init__(self):
"""
Initialize your data structure here.
"""
self.base = 7919 # 1000th prime number from wikipedia
self.list = [[] for x in range(self.base)]
def add(self, key: int) -> None:
if self.contains(key):
... |
b54193899e93af4e098ffc30b1b33b3348d055de | he44/Practice | /leetcode/47.py | 1,061 | 3.734375 | 4 | """
47. Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
E.g.
input: [1, 1, 2]
output:
[1, 1, 2]
[1, 2, 1]
[2, 1, 1]
With code from 46, output:
[[1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 1, 1], [1, 1, 2], [1, 2, 1]]
Q: What does it mean by "unique" perm... |
1eee74086fc156321be9e68781fc456704014a6d | he44/Practice | /leetcode/20_0516_contest/5414.py | 1,194 | 3.578125 | 4 | from typing import *
class Solution:
# won't pass the time limit
def peopleIndexes(self, favoriteCompanies: List[List[str]]) -> List[int]:
# True if cl2 is subset of cl2
def subset(cl1, cl2):
for item in cl1:
if item not in cl2:
return False
... |
1c3e8a13eb6d138ee5a258b4e9b1d6fab679324f | he44/Practice | /leetcode/20_0516_contest/5413.py | 550 | 3.640625 | 4 | class Solution:
def arrangeWords(self, text: str) -> str:
words = text.lower().split(' ')
keys = []
for i in range(len(words)):
keys.append((len(words[i]), i))
sl, sw = zip(*(sorted(zip(keys, words))))
sw = list(sw)
sw[0] = sw[0][0].upper() + sw[0][1:]
... |
2b41cd87e58ecc83c6282f4477b905162205182b | he44/Practice | /leetcode/2020_08_challenge/0814_longest_palindrome.py | 446 | 3.625 | 4 | from typing import *
class Solution:
def longestPalindrome(self, s: str) -> int:
seen = set()
for char in s:
if char in seen:
seen.remove(char)
else:
seen.add(char)
return len(s) - max((len(seen) - 1), 0)
cases = [... |
690e148f0458973434dd39a1a7ef16a9a4aac544 | he44/Practice | /leetcode/20_0808_contest/1.py | 703 | 3.515625 | 4 | from typing import *
class Solution:
def makeGood(self, s: str) -> str:
list_s = [char for char in s]
good_string = False
while not good_string:
good_string = True
n = len(list_s)
for i in range(n-1):
if list_s[i] != list_s[i+1] and list_s... |
94af91b678c0c6bd086e296b682bdad529741575 | he44/Practice | /aoc_2020/21/p1.py | 2,677 | 3.828125 | 4 | def main():
in_fname = "i1_eg.txt"
in_fname = "i1.txt"
lines = open(in_fname).read().strip().split('\n')
ingreds, allers = grab_all(lines)
print(ingreds)
print(allers)
ingred_to_aller = {key:[val for val in allers] for key in ingreds}
print(ingred_to_aller)
# for each food... |
5b0150487d8b55faeac6b7d5958cab3190bd8fdd | he44/Practice | /leetcode/929.py | 1,161 | 3.671875 | 4 | from typing import *
class Solution:
def numUniqueEmails(self, emails: List[str]) -> int:
def simplifyEmails(email):
# find the @
at_loc = email.find('@')
# find the + in the first part
plus_loc = email.find('+')
# find the useful parts
... |
0c05f5242afff28ef0f16a8091d6852b4ae1fa6b | he44/Practice | /leetcode/2020_09_challenge/0908_moving_average_from_data_stream.py | 882 | 3.953125 | 4 | from typing import *
class MovingAverage:
def __init__(self, size: int):
"""
Initialize your data structure here.
"""
self.nums = []
self.ma = 0
self.count = size
def next(self, val: int) -> float:
# not enough vals
if len(self.nums) ... |
c20f9d32546d182020264ae70409fd843ee49f17 | he44/Practice | /leetcode/2020_08_challenge/0828_implement_rand10_using_rand7.py | 1,038 | 3.5 | 4 | from typing import *
# The rand7() API is already defined for you.
# def rand7():
# @return a random integer in the range 1 to 7
class Solution:
def rand7(self):
import random
return random.randint(1,7)
def rand10(self):
"""
:rtype: int
"""
rmo = 41
wh... |
1d6b5244ae0a3eaab84c7bc2dbb966eb82fe7bf7 | he44/Practice | /leetcode/12.py | 950 | 3.640625 | 4 | """
Integer to Roman
"""
class Solution:
def intToRoman(self, num: int) -> str:
units = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
unit_to_sym = {
1: "I",
4: "IV",
5: "V",
9: "IX",
10: "X",
40: "XL",
50: ... |
bbb649a876e8c755567494e8bf68b9477c0bb65c | he44/Practice | /leetcode/2020_06_challenge/0625_find_the_duplicate_number.py | 705 | 3.859375 | 4 | from typing import *
"""
This is O(n) extra space?
"""
"""
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
seen = {}
for num in nums:
if num in seen:
return num
seen[num] = 1
"""
"""
Try using Linked List
"""
class Solution:
def findDupl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.