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 |
|---|---|---|---|---|---|---|
645d57de577822c067df2341ae3d313e3473fca9 | JiYou/LaGouAlgo | /09.BinarySearch/T1562.py | 519 | 3.5 | 4 | # -*- coding: utf-8 -*-
# 测试平台: https://nanti.jisuanke.com/t/T1562
def upperBound(A, target):
l = 0
r = len(A) if A else 0
while l < r:
m = l + ((r-l)>>1)
if (A[m] <= target):
l = m + 1
else:
r = m
return l
s = raw_input().split()
n = int(s[0])
m = int(... |
7d94d453b01e3f6ed01771570dc53e1fff114e45 | JiYou/LaGouAlgo | /09.BinarySearch/34.在排序数组中查找元素的第一个和最后一个位置.py | 2,047 | 3.859375 | 4 | #
# @lc app=leetcode.cn id=34 lang=python
#
# [34] 在排序数组中查找元素的第一个和最后一个位置
#
# https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/description/
#
# algorithms
# Medium (42.17%)
# Likes: 826
# Dislikes: 0
# Total Accepted: 203.3K
# Total Submissions: 482.1K
# Testcase Example: '... |
41c559efa7f6afe5ca8d41e26b6c33a5e098ff74 | JiYou/LaGouAlgo | /02.Queue/01.3.TreeNext.py | 1,604 | 3.625 | 4 | """
测试链接 https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node-ii/submissions/
# Definition for a Node.
class Node(object):
def __init__(self, val=0, left=None, right=None, next=None):
self.val = val
self.left = left
self.right = right
self.next = next
"""
clas... |
5ec2d7975079e026a4351d4b93421cba61685079 | JiYou/LaGouAlgo | /08.Sort/75.颜色分类.mergesort.py | 2,061 | 3.71875 | 4 | #
# @lc app=leetcode.cn id=75 lang=python
#
# [75] 颜色分类
#
# https://leetcode-cn.com/problems/sort-colors/description/
#
# algorithms
# Medium (57.26%)
# Likes: 761
# Dislikes: 0
# Total Accepted: 166.8K
# Total Submissions: 291.4K
# Testcase Example: '[2,0,2,1,1,0]'
#
# 给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜... |
a960279f46ce06106debcd700ccadae084dd8ece | JiYou/LaGouAlgo | /09.BinarySearch/33.搜索旋转排序数组.py | 1,664 | 3.609375 | 4 | #
# @lc app=leetcode.cn id=33 lang=python
#
# [33] 搜索旋转排序数组
#
# https://leetcode-cn.com/problems/search-in-rotated-sorted-array/description/
#
# algorithms
# Medium (40.44%)
# Likes: 1176
# Dislikes: 0
# Total Accepted: 219K
# Total Submissions: 541.4K
# Testcase Example: '[4,5,6,7,0,1,2]\n0'
#
# 升序排列的整数数组 nums ... |
90c0261d7018a42a3a1bda82b4dfeb97a8992c09 | benponce123/Text-Processor | /PartA.py | 2,242 | 3.875 | 4 | # CS 121
# Assignment 1 - Text Processing Functions
# Part A
# Benjamin Ponce 85348479
import sys
import re
# Opens and reads the file line by line
# Yield is used so that the entire text is not stored in memory
# Yields line to perform actions on it and after resumes on the next line
# O(n) - runs in ... |
18462eb6d35f481b9b9046359461830eb2e83e15 | pedrusphantom/encryption-algorithms | /Python/affinecyher.py | 1,724 | 3.65625 | 4 | #01-10-2020
#16:59
#Autor: Pedro Sequeira
import sys
import os
from fractions import gcd
table = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def main():
print("Welcome to Affine Cipher Hub!")
opt = input("Do you want to encrypt... |
278bb0099cdc7ce05ce6fccbfd4da592f55fd0ab | toshiNie/leetcode | /SortColors.py | 682 | 3.765625 | 4 | class Solution:
def sortColors(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
begin = 0
end = len(nums) - 1
size = 0
n = 0
while n <= end:
if nums[n] == 2:
... |
8ea7cedaf589cc29c083ee9414b1ed43d9362d51 | bit2data/PandaSQL | /data/cities.py | 1,161 | 3.96875 | 4 | import sqlite3
# making lots of assumptions
# only TEXT and INTEGER
# more than 1 line
# no escping of ,
def can_be_int(s):
try:
int(s)
return True
except ValueError:
return False
def sql_datatype_from_str(s):
if can_be_int(s):
return 'INTEGER'
return 'TEXT'
# String String St... |
99a8ebc12e3ce5d54c0fc87d6aaeb22b7fc83249 | zhoulouzhu/python | /python scripts/py_jichu/jichu.py | 259 | 3.765625 | 4 | '''x,y=6,5
smll=x if x<y else y
print(smll)
assert x>y'''
fariy='gouyang',"方哥",'狗蛋',"努力"
for i in fariy:
#print(i,end=" ")
print(i,len(i))
print(range(5))
print(list(range(5)))
for i in range(2,10,2):
print(i,end=" ")
print(type(i)) |
ea3845255de3c60675ef42d23768d31582a06d8f | zbc123a/ml_andrew_ng | /week2/machine-learning-ex1/ex1_py.py | 7,838 | 3.859375 | 4 | #%%
import numpy as np
# Identity Matrix
def warmUpExercise():
A =np.eye(5)
return A
# %%
#load data
import numpy as np
wdir = 'C:\\Users\\Beichen\\Desktop\\ML_NG\\week2\\machine-learning-ex1\\ex1\\ex1data1.txt'
data = np.loadtxt(wdir, delimiter = ',')
X,y = data[:,0], data[:,1]
print(X,y)
# %%
#plot data
d... |
a2f9a66e4d4a7eb987f16d81267143e0f8708c01 | smithwebhacker/smith_jterm_googleappengine | /nh_local_reviews/unit_test.py | 3,535 | 3.5 | 4 | from selenium import webdriver
import unittest
class MainPageTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
self.browser.get('http://nh-local-reviews-agente.appspot.com/')
def tearDown(self):
self.browser.close()
def testHeaderContent(self):
... |
bbf1266293004b41b0370dab56bbf59416b9a689 | evandadure/polychess_henaff | /minMax.py | 3,647 | 4 | 4 | import chess
import chess.polyglot
import evaluation as ev
def minMax(board, depth):
"""
[DEPRECIATED - SEE THE FUNCTION "minMaxAlphaBeta"]
Function that calculates the best move to play, considering that the opponent will use the same algorithm
and will also play the best theorical move, recur... |
3a0e496d2e910e46404d494bd1e74a36641dbd5c | evandadure/polychess_henaff | /python_chess/examples/polyglot_tree.py | 1,091 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Print a polyglot opening book in tree form."""
import chess
import chess.polyglot
import argparse
def print_tree(args, visited, level=0):
if level >= args.depth:
return
zobrist_hash = chess.polyglot.zobrist_hash(args.board)
if zobrist_hash in vis... |
850b46381fe4d9f6c5da04d2564758136c470cda | rios0021/pythonWeek9 | /rios0021Library.py | 12,640 | 3.71875 | 4 | # Function to calculate Area of a circle
# Inputs: radius(float)
# Outputs: area(float)
def calculateAreaOfCircle(radius):
from math import pi
area = pi * (radius**2)
return area
# Function to compute MPG for a car.
# Inputs: miles driven (float), gallons used(float)
# Output: MilesPerGalon(floa... |
6d5beb4061a63c8dddb63168261b8b6537f0db69 | drewpearce/AoC2018 | /15/day_15.py | 5,703 | 3.578125 | 4 | import heapq
class Unit(object):
def __init__(self, pos, unit_type):
self.pos = pos
self.hp = 200
self.alive = True
self.type = unit_type
self.turns = 0
if self.type == 'G':
self.enemy_type = 'E'
else:
self.enemy_type = 'G'
def a... |
af9074d7f8d67eb9cc0cefd480ec12e06bc38e52 | SkylarKelty/AI | /src/actors/Human.py | 2,348 | 3.640625 | 4 | import random
from src.util import namegen
from Bot import Bot
#
# A simple human
#
class Human(Bot):
#
# Init
#
def __init__(self):
self.hunger = 0
self.tiredness = 0
self.gender = random.choice(["F", "M"])
self.pregnant = False
self.movingToFood = False
Bot.__init__(self, namegen.human(self.gender... |
2a34ed0e85588e26a732b9240b46730f979e7e4d | LouisLinY/learning-Python | /Algorithms And Structure/Stack/Stack.py | 3,474 | 3.796875 | 4 | #! /usr/bin/env python3
# -*- coding: UTF-8 -*-
# Version: 0.1
# Author: Louis Lin <louislin15@yahoo.com>
# License: Copyright(c) 2019 Louis.Lin
# Summary:
# Date: 2020/2/29 15:40
class Stack():
def __init__(self):
self._items = []
def isEmpty(self):
return self._items == []
def push(self,... |
74bf6dbfcf307b07d3c40294dd404f64ec27e18a | mhrous/algorithm | /Junior_Training_Sheet_template_V6.3/CF_A/Keyboard.py | 261 | 3.640625 | 4 | direction = input()
message = input()
Keyboard="qwertyuiopasdfghjkl;zxcvbnm,./"
for char in message:
index = Keyboard.index(char)
if direction == "L":
index += 1
else:
index -= 1
print(Keyboard[index], end = "")
|
c4710fb88f031e1dbc456d5de69b7304e193fe5f | srinivasskc/API_Test_Automation_Python | /Bookings_API/GetBookingsByID.py | 1,192 | 3.984375 | 4 | # To make a request to the server and Get Response from Server
import requests
import json
import jsonpath
# API URL
url = "https://restful-booker.herokuapp.com/booking/11"
# Sending GET Request
# When we sent the request, we would get the response.
# We can store the response in response variable/object
response = ... |
e1f48502f2a00af71ddc4c4c92850b6a3ce61322 | besteekmen/Saarland | /NODE/ex01/ex01_P2.py | 1,536 | 3.828125 | 4 | import numpy as np # package for numerical linear algebra
import matplotlib.pyplot as plt # package for plotting and visualization
from math import pi; # import pi
################################################################################
### Problem 2 ################################... |
5f01af54158ded33c8adb5930d0f7df7300bc2a7 | apurvmishra99/classicalCSProblems | /smallProblems/fibonacci/fibonacciLoop.py | 274 | 3.75 | 4 | def fibo_iter(n: int) -> int:
if n == 0:
return n
last: int = 0
next: int = 1
for _ in range(1,n):
last, next = next, last + next # tuple unpacking
return next
if __name__ == "__main__":
print(fibo_iter(5))
print(fibo_iter(100)) |
3d28ba0e055cc3ae7b16d5a5519eb50d3eedeac5 | Boot-Camp-Coding-Test/Programmers | /day7(주말용)/problem1/[최중훈] 약수의 개수와 덧셈.py | 268 | 3.515625 | 4 | def solution(left, right):
answer = 0
for i in range(left, right+1):
divisors_lst = [j for j in range(1, i+1) if i % j == 0]
if len(divisors_lst) % 2 == 0:
answer += i
else:
answer -= i
return answer
|
4d533f64f9e763f026dd2f41487dec71df42e5de | Boot-Camp-Coding-Test/Programmers | /day6(주말용)/problem4/[정소진] 정수 제곱근 판별.py | 145 | 3.71875 | 4 | import math
def solution(n):
sqrt_n = math.sqrt(n)
if int(sqrt_n) == sqrt_n:
return (sqrt_n + 1)**2
return -1
|
88299ce5a74fc111660b6be593e078c246d9422c | Boot-Camp-Coding-Test/Programmers | /day14/problem1/[김유민]행렬의_곱셈.py | 467 | 3.65625 | 4 | def solution(arr1, arr2):
answer = [[] for i in range(len(arr1))]
new_arr2= [[] for i in range(len(arr2[0]))]
for row in arr2:
for i in range(len(arr2[0])) :
new_arr2[i].append(row[i])
print(new_arr2)
for i1, row1 in enumerate(arr1) :
for row2 in new_arr2 :
... |
d129e7357625304b8c000788d7e461f680e510bf | Boot-Camp-Coding-Test/Programmers | /day10(주말용)/푸라블럼3/[소요섭]비밀지도.py | 730 | 3.671875 | 4 | def get_binary(intnum, pn):
n = 1
rems = []
while intnum or n < pn+1:
intnum, rem = divmod(intnum,2)
rems.append(rem)
intnum = intnum
n +=1
rems.reverse()
return rems
def solution(n, arr1, arr2):
answer = []
for a1, a2 in zip(arr1, arr2):
pw = str()... |
e30cb66c85352becc4e8d7e6f6e161a78d4cc7e3 | Boot-Camp-Coding-Test/Programmers | /day3/problem3/[노태윤](3차도전 + 간소화)키패드누르기.py | 8,505 | 3.578125 | 4 | # 테스트 11 / 13~20 실패
import numpy as np
def find_length(a,b) :
dx = abs(b[0]-a[0])
dy = abs(b[1]-a[1])
return (dx**2 + dy**2) / 2
def solution(numbers,hand) :
answer=''
phone_list = []
a,b,c = 1,2,3
for i in range(3) :
phone_list.append([10,a,b,c])
a+=3
b+=3
... |
306df112e6af62ce73e55a5f19b71ae5b97f67d2 | Boot-Camp-Coding-Test/Programmers | /day10(주말용)/푸라블럼3/[최보혜]비밀지도.py | 566 | 3.59375 | 4 | def solution(n, arr1, arr2): #비트연산자를 쓰면 더 짧아질 수 있다
a,b = [[0 for _ in range(n)] for _ in range(n)], [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
num1, num2 = format(arr1[i],'b'), format(arr2[i],'b')
l1, l2 = list(map(int, str(num1))), list(map(int, str(num2)))
a[i][n-len(... |
d0fae41137cc6dcd768dcc8285d09a933adc3a49 | Boot-Camp-Coding-Test/Programmers | /day4/problem4/[김유민]2016년.py | 394 | 3.515625 | 4 | def solution(a, b):
months = {m: 30 if (m%2==0) else 31 for m in range(1, 8)}
months.update({m: 31 if (m%2==0) else 30 for m in range(8, 13)})
months[2] = 29
days_list = ['FRI', 'SAT', 'SUN', 'MON', 'TUE', 'WED', 'THU']
num_days = 0
for i in range(1, a) :
num_days += months[i]
... |
9ded79510d9312996af52ef77468616fcf5971ed | Boot-Camp-Coding-Test/Programmers | /day11/problem3/[이재형] 콜라츠추측.py | 274 | 3.625 | 4 | def solution(a):
answer = 0
while a != 1:
if a % 2 == 0 :
a = a/2
answer = answer + 1
else :
a = a * 3 + 1
answer = answer + 1
if answer > 500 :
return -1
else :
return answer
|
b3cfe6c8bcec4ec1005202eda706723db91609fd | Boot-Camp-Coding-Test/Programmers | /day18/problem1/[노태윤]N개의 최소공배수.py | 544 | 3.59375 | 4 | def gcd(a,b) : # 최대공약수 알고리즘
if a == 0 :
return b
else :
return gcd(b%a,a)
def lcm(a,b) : # 최소공배수 알고리즘
return a * b // gcd(a,b)
def solution(arr):
while arr :
first,second = arr.pop(0),arr.pop(0) # arr 앞에 두개 element의 최소공배수를 구하고 앞 자리에 다시 insert 한 뒤에 계속 업데이트 하기
lcms = lc... |
989c42d707d7bdaa0c8fede2bd6d3d55fd29a9f0 | Boot-Camp-Coding-Test/Programmers | /day18/problem1/[최중훈] N개의 최소공배수.py | 295 | 3.625 | 4 | def gcd(n, m):
if n < m:
n, m = m, n
while n % m != 0:
n, m = m, n%m
return m
def lcm(n ,m):
return int(n * m / gcd(n, m))
def solution(arr):
arr = sorted(arr)
for i in range(len(arr)-1):
arr[i+1] = lcm(arr[i], arr[i+1])
return arr[-1]
|
fa21820f02b6a0278da246ec27c9e7b7cd047b5f | Boot-Camp-Coding-Test/Programmers | /day3/problem1/[김유민]k번째수.py | 215 | 3.53125 | 4 | def solution(array, commands):
answer = []
for command in commands :
temp_arr = array[command[0]-1:command[1]]
temp_arr.sort()
answer.append(temp_arr[command[2]-1])
return answer
|
35aebf9937f1bfe4e2b2b8c20d48b4d3c44d6a25 | somchanda/loan_calculation | /main.py | 2,117 | 3.734375 | 4 |
from tabulate import tabulate
from datetime import datetime, timedelta
import calendar
loan = input('Enter loan ($): ')
rate = input('Enter interest rate(%): ')
duration = input('Enter duration(monthly): ')
# dateReceive = input('Enter date receive (dd-mm-YYYY): ')
# dateReceive = datetime.strptime(dateReceive, '%d-%m... |
6568f1f785fe86a522cd3884f198c1cf94921fd0 | vivi-and-tea/blackjack-start | /main.py | 4,326 | 3.75 | 4 | from art import logo
# print(logo)
import random
def restart_game():
player_cards.clear()
cpu_cards.clear()
player_cards.append(random.choice(cards))
cpu_cards.append(random.choice(cards))
hit_me()
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
player_cards = []
cpu_cards = []
def hit_me():
playe... |
aa8bde4fa697b8dfbf6dafae40cbc9f57645561c | gwangqq/python_exercise | /boolean.py | 304 | 3.640625 | 4 | # from copy import copy
# a = [1, 2, 3]
# b = copy(a)
# a[1] = 4
# print(id(a))
# print(id(b))
(a, b) = ("hello", "hi")
print(a)
print(b)
a, b = ("hello", "hi")
print(a)
print(b)
(a,b ) = ("hello", "hi")
print(a)
print(b)
c = 3
d = 5
c,d = d,c
# tmp = c #3
# c = d #5
# d = tmp #3
print(c)
print(d) |
ddb7136ee52a4bedc3fadfd47f29426b1b7e8576 | anahidzandi/pacman | /world.py | 10,964 | 3.53125 | 4 | import pygame
import map
import player as pl
import ghost
import time
import random
class Maze:
"""Create a functional maze"""
def __init__(self, map, square_size, BG_COLOR):
self.square_size = square_size
self.BG_COLOR = BG_COLOR
self.make_maze_rects(map)
def make_maze_rects(sel... |
0a1c8843bdb901ced9951f32ad87bccab0c4e5cd | Marin-Tony/Calculator | /Basic.py | 1,593 | 4.15625 | 4 |
def oprtn(a, b):
print("1.Addition")
print("2.Subtraction")
print("3.Division")
print("4.Multiplication")
#print("5.Percentage")
print("5.Remainder")
print("Choose the Number specified before each operation to be performed:")
oper_selectd = input(" ")
if oper_selectd == "1... |
7d0dbdd2c6bef2f48c39c2feca1104a95f3ae9f6 | davidtazy/kata_sudoku_solver | /test_sudoku_solver.py | 4,188 | 3.609375 | 4 | import unittest
from sudoku_solver import SudokuSolver, create_zero_grid, create_solved_grid, create_real_world_grid,create_hard_sudoku
class TestSudokuSolver(unittest.TestCase):
def test_all_positions_and_numbers_are_possible_on_zero_grid(self):
grid = create_zero_grid()
solver = SudokuSolver(g... |
893ba620cd134c78e14022d5ec4fbe7a912a5218 | e-harsley/mass_rover_coding_challenge | /test_rover.py | 3,021 | 4.25 | 4 | import unittest
# import unittest. The unittest module provides a rich set of tools for constructing and running tests.
from main import Rover
# import Rover from main file. The methods in the rover class would be tested.
class TestRoverMethods(unittest.TestCase):
def setUp(self):
"""
This is ... |
b8bb1c1d57479d4a80509aa94b86dd101f075e8d | breaksoul/python | /多线程.py | 3,344 | 3.796875 | 4 | import threading
import time
def run(n):
print('task',n)
time.sleep(1)
print('2s')
time.sleep(1)
print('1s')
time.sleep(1)
print('0s')
time.sleep(1)
if __name__=='__main__':
t1=threading.Thread(target=run,args=('t1',))#target是放入线程的函数,args是函数总需要传递的参数,以元祖的形式传入
t2=threading.Thread(... |
547ead9fa1756107b65097c598bf308bb12bb590 | WilliamScarbro/cooperation | /cooperation/market.py | 9,554 | 3.78125 | 4 | import random
class market:
resource_names = {"Wheat","Pork","Wood"}
def __init__(self, resources, people):
self.people=people
self.resources=resources
def set_initial_prices(self):
for name in self.resources:
self.resources[name].price=int(10*person.min_require[nam... |
930a6ba3da2b15f5c31af8a20e6e3632983abef3 | Twinotters/MyFirstCode | /SecretRobot.py | 1,152 | 3.796875 | 4 | command = ''
user_name = input('Enter name: ')
secret_number = 64
tries = 0
tries_limit = 8
print(f'Welcome {user_name}, i am "SecretRobot64". Nice to meet you.')
while True:
command = input('>').lower()
if command == 'hello':
print('How are you today?')
command = input('>').lower()
... |
fa832306c0e8f87f28cb3edcd2655860b7c8e8bc | GreenLightCleanup/GreenLightCleanup.github.io | /w4lab2.py | 277 | 3.890625 | 4 | day = "saturday"
print(len(day))
print(day[3])
name = "Bryce"
print(len(name))
print(name[0] + " " + name[len(name) -1])
if len(name) > 20:
print(name + " is longer than 20")
elif len(name) == 4:
print(name + " is equal to 20")
else:
print(name + " is shorter than 20")
|
bbc7d9744dedfcb8c544b04c4ba2ad96835e9b87 | FernandoSka/Programing-works | /algorithms/fact.py | 231 | 4.09375 | 4 | def factorial(numero):
if numero<2:
return(numero)
return(numero*factorial(numero-1))
print(factorial(3))
"""
def funcion(num,cont):
cont -= 1
if cont>=1:
num *= cont
funcion(num,cont)
else:
print(num)
funcion(5,5)
""" |
9c8e76b0cf1f5177a17859dfeee810907798eb2c | FernandoSka/Programing-works | /algorithms/countingv1.py | 196 | 3.828125 | 4 | """Counting Vowels."""
text = input("dame un texto plz\n")
counter = 0
for pos in range(0,len(text)):
if text[pos:pos+3] == "bob":
counter += 1
print('hay', counter, ' bobs en:', text) |
b17b4a6dbbef692f631e6849d2d31ab8f1c39da6 | FernandoSka/Programing-works | /python/Extra poo/menu.py | 3,094 | 3.859375 | 4 | from clases import Reporte
reporte = Reporte()
while True:
print("\n\nMenu")
print("Teclee una opcion")
print("1) Inventario")
print("2) Compras")
print("3) Reportes y Graficas")
print("4) Salir")
opc = 0
try:
opc = int(input("- "))
except Exception:
opc = 0... |
9d0872f342787d92be6a93e1f3d8afeda907b702 | FernandoSka/Programing-works | /discretas/karnaught.py | 3,305 | 3.625 | 4 | print("mapas de Karnaugh")
p = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
q = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]
r = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
s = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
pq = ["00", "01", "10", "11"]
rs = ["00", "01", "10", "11"]
pqrs = []
count = []
... |
22c04d4835001a9a7160a5be71e2395427a0f8b6 | FernandoSka/Programing-works | /algorithms/forc.py | 398 | 4.21875 | 4 |
arreglo = ["elemento1", 1, 2, 3, "hola", 1.8]
for element in range(0, len(arreglo)):
print(arreglo[element])
break
for element in arreglo:
print(element)
break
for element in range(0, len(arreglo)):
print(element)
break
#1. mostrar elementos de la matriz
matriz = [["hola ", 5, 8], ["mundo", ... |
98631dc2e4f47c21866ffb998996542cf24c090e | K-Mahfoudh/Sign-Language-Translator | /visualization/visualize.py | 1,854 | 4.0625 | 4 | import matplotlib.pyplot as plt
from data import get_class_name
def visualize_num(train_loss, train_accuracy, valid_loss, valid_accuracy):
"""
A function to visualize loss and accuracy during training (for both training and validation).
:param train_loss: a list containing training loss of all epochs
... |
9ca4f40c2b05a7da51e640000c6a37ca88bf91a8 | suvratjain18/CAP930Autum | /23AugPractical.py | 1,078 | 4.59375 | 5 | # What Is Sets
#collection of well defined things or elements
#or
# Unorderd collection of distinct hashable elements
#In First Create a set
s={1,2,3}
print(s)
print(type(s))
t={'M','K','R'}
print(t)
print(type(t))
# How you can declare Empty Set using below here
# empty_set=set()
# it will convert list to string belo... |
63d4b9684e3297f7dd01bc2df12f4a9508c6150e | MariaTTK/Algorithms | /Stocks.py | 1,175 | 3.828125 | 4 | __author__ = 'Maria'
# data
import numpy as np
import time
# stock_prices_yesterday = np.array([10,9,8,7,6,5])
stock_prices_yesterday = np.random.randint(1000, size=1)
stock_prices_yesterday = list(stock_prices_yesterday)
# print(stock_prices_yesterday)
# function
def get_max_profit(stock_prices_yesterday):
# ma... |
d730cef5da384b113f7edc3180f2ae7b9658d29d | dan-singh/project-euler | /11/grid.py | 2,375 | 3.5 | 4 | """
Grid class.
"""
class Grid:
"""
Grid object with methods to get neighbor values.
"""
def __init__(self, height, width, export_grid=None):
if export_grid:
self._grid = [[col for col in row] for row in export_grid]
# empty grid.
else:
self._grid = [[[]... |
369332e505d73d219c7f693bf273c043ce98299b | LysanderGG/AdventOfCode2016 | /day21.py | 3,862 | 3.65625 | 4 | import sys
#operation: (command, x, y)
operations = []
with open("day21.txt",'r') as f:
for line in f:
if line.startswith("swap position"):
cmd = "swap position"
x = int(line[len("swap position ")])
y = int(line[len("swap position X with position ")])
elif line.s... |
ad343f24332f0a700268d041d8e3fbb5e0116910 | LysanderGG/AdventOfCode2016 | /day06.py | 835 | 3.828125 | 4 | import collections
def read_input(filepath):
with open(filepath) as f:
return [line.strip() for line in f]
def count_letters(filepath):
words = read_input(filepath)
size = len(words[0])
counters = [collections.Counter() for _ in range(size)]
for word in words:
for idx, char in en... |
756fef5982b910d933824f807a6fe98c130fc0c8 | Botang13/belajar-python | /30. Return Value/return_value.py | 567 | 3.953125 | 4 | # Belajar Method Return Value
# Ada 2 Jenis Method yaitu
# Method Procedure hanya mengeksekusi kode program saja
# Method Function yang mengembalikan nilai
# Return untuk mengembalikan hasil kode program dari method
def jumlahkan(*list_angka):
total = 0
for angka in list_angka:
total = total + angka
... |
49f52dadc38f31d499240713726c0636e1322a84 | Botang13/belajar-python | /09. Input Number/input_number.py | 433 | 3.8125 | 4 | #Belajar Input Number
#Input dibaca Tipe Data String sehingga hasil keluaran 55
print("Angka Pertama : ")
a = input()
print("Angka Kedua : ")
b = input()
hasil = a + b
print (f"{a} + {b} = {hasil}")
#Konversikan Tipe Data ke Integer seperti dibawah ini
#Akan error jika dimasukkan data selain angka
print("Angka Pert... |
df05a678064c9d5a76ad95807fa5a4a7398096d1 | Botang13/belajar-python | /13. If/if.py | 384 | 3.5625 | 4 | #Belajar IF-Statement
#Jika suatu kondisi terjadi/terpenuhi, kita ingin melakukan apa
#if kondisi:
#mau melakukan apa ?
#melakukan hal lain
#dan seterusnya
#semua harus diawali karakter tab
#perbandingan menggunakan boolean
orang = 100
zombie = 100
if orang < zombie:
print("KABUR, DUNIA MAU KIAMAT")... |
a9064934aae70261f3f0cd60250d254daac8e3f8 | Botang13/belajar-python | /26. Method/method.py | 308 | 3.75 | 4 | # Belajar Membuat Method / Function
# Tempat menyimpan kode blok dimana akan dieksekusi jika dipanggil
nama = []
def print_nama():
print("==================")
for data in nama:
print(data)
nama.append("Mas")
print_nama()
nama.append("Her")
print_nama()
nama.append("Botang")
print_nama() |
e5d8ba0df2dbfefe7056c51cefa2fbcfc7757307 | zeeenjaaa/ProjectEulerExercisesPython | /4/4.py | 1,528 | 3.84375 | 4 | '''Задача 4
Наибольшее произведение-палиндром
Число-палиндром с обеих сторон (справа налево и слева направо) читается одинаково. Самое большое число-палиндром, полученное умножением двух двузначных чисел – 9009 = 91 × 99.
Найдите самый большой палиндром, полученный умножением двух трехзначных чисел.'''
listAnswers = ... |
5b4408dead4f3e07b0620f6c927c3409910f1559 | AnatoliKosarev/Python-beginner-course--Teclado- | /AsynchronousPython/threadsPython.py | 985 | 3.984375 | 4 | import time
from threading import Thread
def ask_user():
start_time = time.time()
name = input("Enter your name: ")
greet = f"Hello, {name}"
print(greet)
print(f"ask_user: {time.time() - start_time}")
def complex_calculation():
start_time = time.time()
print("Starting calculating...")
... |
661fe7a34a439278c3830a9b13f4b5f6b8d0521e | AnatoliKosarev/Python-beginner-course--Teclado- | /filesPython/fileImports/user_interactions/myfile.py | 1,138 | 4.21875 | 4 | print(__name__)
"""
The file that we run always has a __name__ variable with a value of "__main__". That is simply how Python tells us that we ran that file.
Running code only in script mode
Sometimes we want to include some code in a file, but we only want that code to run if we executed that file directly—and not i... |
cf3c642d9b2747669fcd2814bc5ef42ccc742303 | AnatoliKosarev/Python-beginner-course--Teclado- | /AsynchronousPython/asyncAwait.py | 621 | 4 | 4 | from collections import deque
from types import coroutine
friends = deque(('john', 'james', 'cliff', 'kirk', 'paul'))
@coroutine
def friend_upper():
while friends:
friend = friends.popleft().upper()
greeting = yield
print(f'{greeting} {friend}')
async def greet(g):
print("Starting")... |
b0410a2b46b734f18da31834065151d53cd37a41 | AnatoliKosarev/Python-beginner-course--Teclado- | /advancedPythonDevelopment/itertoolsCombinatoricIterators.py | 2,369 | 4.84375 | 5 | # permutations
"""
permutations is concerned with finding all of the possible orderings for a given collection of items. For example,
if we have the string "ABC", permutations will find all of the ways we can reorder the letters in this string, so that each order is unique.
"""
from itertools import permutations
p_1 =... |
cda9d69009f9846ad202a73821a95a31b7a0a404 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonFundamentals/enumerateInLoop.py | 1,488 | 4.375 | 4 | friends = ["Rolf", "John", "Anna"]
for counter, friend in enumerate(friends, start=1):
print(counter, friend)
# 1 Rolf
# 2 John
# 3 Anna
friends = ["Rolf", "John", "Anna"]
friends_dict = dict(enumerate(friends))
print(friends_dict) # {0: 'Rolf', 1: 'John', 2: 'Anna'}
# если не переводить в другой тип (dict, list,... |
cee5b75663a65161505fe4e9b113c055a0ece817 | AnatoliKosarev/Python-beginner-course--Teclado- | /filesPython/files_project/csvProject/csvProject.py | 3,694 | 4.0625 | 4 | with open("iris.csv", "r") as iris_file:
"""
Since the data is displayed on separate lines, we know one very important thing. Every line ends with a newline
character to mark the line break. We can therefore split our data based on the "\\n" character, giving us each line
as a list.
iris_data = ir... |
4dad400b2d1a3e8a4472698aa434dd7ceb23cea9 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonFundamentals/listJoin.py | 1,254 | 4.0625 | 4 | message = "My friends are {friends}"
list1 = ["john", "paul", "george", "ringo"]
print(message.format(friends=list1))
comma_separated = ", ".join(list1)
print(message.format(friends=comma_separated))
print(message.format(friends=", ".join(list1)))
numbers = [1, 2, 3, 4]
str_numbers = []
for number in numbers:
str_... |
3814a7116033ae2935d0ef09c8d7fae42f29c027 | AnatoliKosarev/Python-beginner-course--Teclado- | /advancedPythonDevelopment/namedTuple.py | 524 | 4.1875 | 4 | from collections import namedtuple
Student = namedtuple("Student", ["name", "age", "faculty"])
names = ["John", "Steve", "Mary"]
ages = [19, 20, 18]
faculties = ["Politics", "Economics", "Engineering"]
students = [
Student(*student_data)
for student_data in zip(names, ages, faculties)
]
print(students)
old... |
9ec610e2a5cf98ee93b5cc2c1c7a479c4ed8b410 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonTextBook/exercises/files/exTenFour.py | 369 | 3.859375 | 4 | def greet_guest():
name = input("Enter name or 'q' to exit: ")
while name != "q":
if name:
greeting = f"Welcome, {name}!"
print(greeting)
with open("guest_book.txt", "a") as f:
f.write(f"{greeting}\n")
name = input("Enter name or 'q' to exit: "... |
bb7ba363b2297d7d57b85e3c9b2cd9ce71147235 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonFundamentals/zipFunction.py | 2,299 | 4.65625 | 5 | """
Much like range, zip is lazy, which means it only calculates the next value when we request it.
We therefore can't print it directly, but we can convert it to something like a list if we want to see the output
"""
from itertools import zip_longest
student_ids = (112343, 134555, 113826, 124888)
names = ("mary", "Ri... |
36c9c7f2a4f0f955a46fd85c4116897bfbf61143 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonFundamentals/input.py | 239 | 4.15625 | 4 | my_name = "Bob"
your_name = input("Enter your name: ") # always returns string
print(f"Hello, {your_name}. My name is {my_name}")
print()
age = int(input("enter your age: "))
months = age * 12
print(f"you have lived for {months} months") |
1296a3a9e33e8e4d5f94a04ded57d834033d1970 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonTextBook/exercises/classes/exNineThirteen.py | 950 | 3.640625 | 4 | from random import randint
class Dice:
def __init__(self, sides=6):
self.sides = sides
def roll_dice(self):
print(randint(1, self.sides))
if __name__ == "__main__":
dice = Dice()
dice.roll_dice()
dice.roll_dice()
dice.roll_dice()
dice.roll_dice()
dice.roll_dice()
... |
0422da106ef0fb9b7e226007c4836aaf20985bc8 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonTextBook/exercises/dictionary/ex-6.7.py | 548 | 4.21875 | 4 | person1 = {
'name': 'John',
'lastname': 'Lennon',
'age': '33',
'city': 'Liverpool'
}
person2 = {
'name': 'James',
'lastname': 'Hetfield',
'age': '45',
'city': 'San Francisco'
}
person3 = {
'name': 'Fat',
'lastname': 'Mike',
'age': '19',
'city': 'Los Angeles'
}
people =... |
b012c287ee491ed19617ebc9ec1b5d82b89e3d10 | AnatoliKosarev/Python-beginner-course--Teclado- | /pythonFundamentals/listComprehension.py | 2,079 | 4.53125 | 5 | # can be used with lists, tuples, sets, dictionaries
numbers = [0, 1, 2, 3, 4]
doubled_numbers1 = []
for number in numbers:
doubled_numbers1.append(number * 2)
print(doubled_numbers1)
# same can be done with list comprehension which is much shorter
doubled_numbers2 = [number2 * 2 for number2 in numbers]
print(dou... |
65b98bcc0138a1d0325c31ac238154ce4c61345f | Amitgm/normal-python-progs | /supernims.py | 4,669 | 4.1875 | 4 | # this is for a computer Vs computer using random number generator
class supernim:
player='max' # initialized a player
player1points=0
player2points=0
counter=1
import random
import check;
# we are taking a list
list1 =[6,8];
print("the current list1 is",list1) # the current list
print("the curren... |
e3087b4f55f5ced23f8714e691611b9a5a5850b7 | chayan0424/ML-projects-under-Summer-internship | /ANN-deeplearning/Artificial Neural Networks.py | 3,899 | 3.75 | 4 | # ANN
# Part 1-Data Preprocessing
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing Dataset
dataset=pd.read_csv("Churn_Modelling.csv")
X= dataset.iloc[:,3:13].values
y=dataset.iloc[:,13].values
# Encoding Categorical Data
from sklearn.preproc... |
2e799b823ac9094652c5a2ab21e14d704e2a4f9c | kaci65/alx-higher_level_programming | /0x04-python-more_data_structures/0-square_matrix_simple.py | 197 | 3.6875 | 4 | #!/usr/bin/python3
def square_matrix_simple(matrix=[]):
new_square_matrix = []
for i in matrix:
new_square_matrix.append(list(map(lambda x: x * x, i)))
return new_square_matrix
|
530fbb32d43f45697dc30467a213278c3cd436ce | kaci65/alx-higher_level_programming | /0x11-python-network_1/3-error_code.py | 573 | 3.5625 | 4 | #!/usr/bin/python3
"""
takes in URL, sends request to URL & displays body of response (decoded
in utf-8)
manage urllib.error.HTTPError exceptions and print: Error code
followed by the HTTP status code
"""
import urllib.request
import urllib.parse
import urllib.error
from sys import argv
if __name__ == "__main__":
... |
cbcfc49caa4190e0027f7c46a4b1d23aaaf782ba | kaci65/alx-higher_level_programming | /0x0B-python-input_output/7-add_item.py | 557 | 3.890625 | 4 | #!/usr/bin/python3
"""script that adds all arguments to a Python list, and
then save them to a file
"""
from sys import argv
load_from_json_file = __import__('6-load_from_json_file').load_from_json_file
save_to_json_file = __import__('5-save_to_json_file').save_to_json_file
filename = "add_item.json"
with open(filena... |
de358089351c4cf78202bfb5dd7b00d26a1bb9a4 | kaci65/alx-higher_level_programming | /0x0C-python-almost_a_circle/models/rectangle.py | 2,370 | 3.96875 | 4 | #!/usr/bin/python3
"""module for class Rectangle"""
from models.base import Base
class Rectangle(Base):
"""class Rectangle inherits from Base"""
def __init__(self, width, height, x=0, y=0, id=None):
"""class constructor"""
super().__init__(id)
self.width = width
self.height = h... |
a157e07fe297e233a690d7ef9db017b5aabd8519 | changzj97/abc | /实战15.py | 428 | 3.828125 | 4 | print('欢迎使用10086自助查询系统')
print('输入1,查询您当前余额')
print('输入2,查询您当前剩余流量')
print('输入3,查询您当前剩余通话分钟数')
number=int(input('请输入:'))
if number==1:
print('您当前剩余余额为%d元'%(number * 13))
elif number==2:
print('您当前剩余流量为%dG'%number**2)
elif number==3:
print('您当前的剩余通话为%d分钟'%number**4)
|
c17b48b84258b6b0190a4b6fc8abb7b4164b9f90 | changzj97/abc | /62.py | 716 | 3.671875 | 4 | print('定制自己的手机套餐:')
a = {1:'0分钟',2:'50分钟',3:'100分钟',4:'300分钟',5:'不限量'}
b = {1:'0M',2:'500M',3:'1G',4:'5G',5:'不限量'}
c = {1:'0条',2:'50条',3:'100条'}
print('A.请设置通话时长:')
for k,v in a.items():
print(k,v)
a1 = int(input('输入选择的通话时间编号:'))
print('')
print('B.请设置流量:')
for k1,v1 in b.items():
print(k1,v1)
b1 =int(input('输入... |
4b07a02182e053b7fedb76fa7ea03188bcdd791f | changzj97/abc | /65.py | 1,505 | 3.546875 | 4 | a =int(input('请输入月份(例如:5):'))
b =int(input('请输入日期(例如:17):'))
if a == 1 and b in range(20,32) or a == 2 and b in range(1,19):
print('%d月%d日星座为:水瓶座'%(a,b))
elif a == 2 and b in range(19,32) or a == 3 and b in range(1,21):
print('%d月%d日星座为:双鱼座'%(a,b))
elif a == 3 and b in range(21,32) or a == 4 and b in range(1,2... |
3077c9696028be4335af5894aaf695d3daf3475c | changzj97/abc | /31.py | 97 | 3.671875 | 4 | num = 50
sum = 0
while num <= 100:
if num%2 == 1:
sum +=num
num +=1
print(sum)
|
fc2781e14c0eb577fe874cb98abc518d10bbd84d | changzj97/abc | /实战19.py | 304 | 3.796875 | 4 | height =int(input('请输入身高:'))
money = int(input('请输入身价:'))
face = int(input('请输入颜值分:'))
if height>=180 and money>1000000 and face>99:
print('高富帅')
elif money>1000000 and face>99:
print('帅')
elif height<=160 and money<100 and face<60:
print('矮穷矬')
|
716cab1c4b9634b5976743c8921d0fc62d80c29a | danielwiet/codecademy_python2_practice | /rgbhex.py | 1,573 | 4 | 4 | '''
RGB converter to hexadecimal
you got this
'''
from time import sleep
def rgb_hex():
invalid_msg = 'Ya dummy, that\'s not right'
red = int(raw_input('Please enter a red value: \n'))
if red > 255 or red < 0:
print(invalid_msg)
return
green = int(raw_input('Please enter a green value \n'))
if green ... |
32f3133f2d261dc6439afbec624987aa5b10a2a6 | MASaraji/Bank-3992 | /GUI.py | 831 | 3.53125 | 4 | # this module should define an api for main.py. classes and their methods
# must be able to do any need of the gui. in this project any toplevel class
# must be named like: 'CustomerTop" also any frame class must be named like:
# 'CustomerTransferView' or 'CustomerCreateAccountView' 'Top' classes must
# be defined in t... |
0db544ac38b5229c28839e00b6efe24bc625817b | bkoz/flexray | /code/02-canvas.py | 1,159 | 3.65625 | 4 | from Point import Point
from Vector import *
from Canvas import *
class Projectile:
def __init__(self, position, velocity):
self.position = position
self.velocity = velocity
class Environment:
def __init__(self, gravity, wind):
self.gravity = gravity
self.wind = wind
def tick(... |
26e53da5ae46cb8a9a2cd457f574d6657011db16 | magmaforever/python-training | /py-exercise/move_files_over_x_days.py | 1,253 | 3.703125 | 4 | # 把超过指定天数的文件移动的确定目录里
import argparse
import os
import shutil
import time
usage = 'python move_files_over_x_days.py -src [SRC] -dst [DST] -days [DAYS]'
description = 'Move files from src to dst if they are older than a certain number of days. Default is 240 days'
args_parser = argparse.ArgumentParser(usage=usage, des... |
af12948c9b1f6161862ae5079d03bf8d3595e44e | jsdiuf/leetcode | /src/Powerful Integers.py | 1,611 | 4.1875 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2019/1/6 12:06
Given two non-negative integers x and y, an integer is powerful
if it is equal to x^i + y^j for some integers i >= 0 and j >= 0.
Return a list of all powerful integers that have value less than or equal to bound.
You may re... |
d9d76f8ae9a033f929362a34f05f48adca19d9a0 | jsdiuf/leetcode | /src/House Robber.py | 1,614 | 3.890625 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-9-11 11:09
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 c... |
7d747766b7bc708d35e521644ff7982ce4ad0ccf | jsdiuf/leetcode | /src/N-Repeated Element in Size 2N Array.py | 766 | 3.765625 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018/12/23 10:33
In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times.
Return the element repeated N times.
Example 1:
Input: [1,2,3,3]
Output: 3
Example 2:
Input: [2,1,2,5,3,2]... |
8aa9ae47dc9edf9d36dc9c94bce543e7252310cd | jsdiuf/leetcode | /src/Minimum Increment to Make Array Unique.py | 1,688 | 4 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-11-26 9:36
Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1.
Return the least number of moves to make every value in A unique.
Example 1:
Input: [1,2,2]
Output: 1
Explanation: After 1 m... |
c167226fbfec1a0ecbf43cfcda87b6e51317e656 | jsdiuf/leetcode | /src/N-ary Tree Preorder Traversal.py | 835 | 4.15625 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-10-23 9:19
Given an n-ary tree, return the preorder traversal of its nodes' values.
For example, given a 3-ary tree:
Return its preorder traversal as: [1,3,5,6,2,4].
Note:
Recursive solution is trivial, could you do it iteratively?... |
0a337394ee3f20e36f5ed406364b22c10013ae63 | jsdiuf/leetcode | /src/Validate Stack Sequences.py | 1,677 | 3.84375 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-11-27 9:50
Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack.
Example 1:
Input: pushed = [1,2... |
07ffccd427b293a280f116ef438a733c1cd50541 | jsdiuf/leetcode | /src/findRestaurant.py | 969 | 3.671875 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-8-15 9:10
"""
class Solution(object):
def findRestaurant(self, list1, list2):
"""
:type list1: List[str]
:type list2: List[str]
:rtype: List[str]
"""
dic = {val: idx for idx, val in... |
2465ec8529895622152a1ef802415acd5b5f0512 | jsdiuf/leetcode | /src/removeElements.py | 1,159 | 3.796875 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-8-15 15:16
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def removeElements(self, head, val):
"""
:type head: L... |
60ffccc351e957b7f29c729b1988a4549866bb8f | jsdiuf/leetcode | /src/RLEIterator.py | 1,080 | 3.703125 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-9-9 9:44
"""
class RLEIterator:
def __init__(self, A):
"""
:type A: List[int]
"""
self.arr=A
def next(self, n):
"""
:type n: int
:rtype: int
"""
if not... |
e2e34e289942fc54ee8a5ff44efc447c22b17cac | jsdiuf/leetcode | /src/Swap Nodes in Pairs.py | 1,033 | 3.84375 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-8-4 18:05
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swapPairs(self, head):
"""
:type head: ListNode
... |
7271c8fc486ac39ecfd5353becad4736228857f5 | jsdiuf/leetcode | /src/singleNumber.py | 662 | 3.515625 | 4 | """
@version: python3.5
@author: jsdiuf
@contact: weichun713@foxmail.com
@time: 2018-8-14 0:16
"""
class Solution:
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
a = set()
for e in nums:
if e in a:
a.remove(e)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.