blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
9032e486507221dd3052d0cdddf4c9e03b9bc203 | nathanshammah/OpenSurfaceSim | /oopsc/graph/graph_3D.py | UTF-8 | 10,764 | 2.78125 | 3 | [] | no_license | '''
2020 Mark Shui Hu, QuTech
www.github.com/watermarkhu/oop_surface_code
_____________________________________________
We define the unit cell, which contains two qubits, a star operator and plaquette operator.
| |
- Star - Q_0 - also top (T) qubit
| |
- Q_1 - Plaq - also down (D) q... | true |
95787b576285f610289219563c8bc19307698e4b | rockniu/Python101 | /lambda_exp.py | UTF-8 | 382 | 3.59375 | 4 | [] | no_license | print (range(10))
s6=set(range(10))
f=lambda x:x*2;
print (map(f,s6))
print (map(lambda x:x*3, s6))
s5=s6.copy();
def fun1(x):
return x**2
def fun2(x):
return x%2==0
def fun3(x,y):
return x+y
print ("map...")
s6=map(fun1, s5)
print (s6);print(type(s6))
print ("filter")
s7=filter(fun2, s6)
print (s7)
pri... | true |
76ac35cd1a30fe4564ba495e62660ef667926cf0 | ihsan3975/Demy_5 | /no_2.py | UTF-8 | 350 | 3.109375 | 3 | [] | no_license | import re
regex_user = '^(?=.*^[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]{5,9}$'
username = input("input username:")
print(bool(re.search(regex_user, username)))
regex_pass = '^(?=(?:.*[a-z]))(?=.*[$=_]{1})(?=.*[A-Z]{1})(?=.*[0-9]{1})(?=.*[$=_])[a-zA-Z0-9$=_$=_]{8,}$'
password = input("input password:")
print(bool(re.se... | true |
0e67fee76aa9b28f00402b95918a0f9ae6ce818a | Supriyapandhre/Test-Repository | /PythonSelenium/PytestFramework/test_paramitize_function.py | UTF-8 | 1,122 | 2.875 | 3 | [] | no_license | from selenium import webdriver
from time import sleep
import pytest
@pytest.mark.parametrize("num1, num2, sum", [(2, 3, 5), (30, 50, 80), (40, 40, 90)])
def test_addition(num1, num2, sum):
assert num1+num2 == sum
driver = webdriver.Chrome(executable_path="C:\\drivers\\chromedriver_win32\\chromedriver.exe")
driv... | true |
e1d3e9217add2478964b2a78c0d1c9546a0be33e | Mch233/Mch | /work/Clustering by fast search and find of density peaks/change.py | UTF-8 | 867 | 2.84375 | 3 | [] | no_license | from numpy import *
import numpy as np
import matplotlib.pyplot as plt
import math
from sklearn.datasets import make_gaussian_quantiles
#########################################打开文件###############################################
filein = input('输入原始数据文件\n')
f = loadtxt(filein)
N = len(f)
############################... | true |
6e7c1f40a533efafef34b20b861b5547fab19432 | juliandunne1234/pands-problems-2020gmit | /topic03/lab03.04-random.py | UTF-8 | 149 | 3.71875 | 4 | [
"MIT"
] | permissive | # Program that prints out random
# numbers between 1 and 10
import random
number = random.randint(1,12)
print ("Here is a random number", number)
| true |
0d885c684061825f0c657a9d4a98e416cfa41200 | Graey/pythoncharmers | /complexconversion.py | UTF-8 | 761 | 4.0625 | 4 | [
"MIT"
] | permissive | import math
print("Enter your input format:")
print("1. a+ib")
print("2. r*e^(i*theta)")
print("3. rCis(theta)")
choice=int(input())
print("Enter number:")
if choice==1:
print("Enter a:")
a=float(input())
print("Enter b:")
b=float(input())
r=math.sqrt(a*a+b*b)
theta=math.ata... | true |
3d2f1495bfeb30b8e959d53dff71b7ffa70d54c6 | jithinp040/Python-Beginner | /Print-evenno-btwn-range.py | UTF-8 | 124 | 3.28125 | 3 | [] | no_license | i,j=map(int,input().split())
op=[]
for integer in range(i+1,j):
if(integer%2==0):
op.append(integer)
print(*op)
| true |
2d95a35564a797c5938c5166d6171c33f89f8c34 | lzmaths/leetcode | /leetcode_366_paindrome_pairs.py | UTF-8 | 1,128 | 3.265625 | 3 | [
"MIT"
] | permissive | import sys, collections
class Solution(object):
def palindromePairs(self, words):
"""
:type words: List[str]
:rtype: List[List[int]]
"""
ans = []
dic = {word: idx for idx, word in enumerate(words)}
for idx, word in enumerate(words):
rword = word[:... | true |
f516a2398c262e1527742546307f8032e58f5700 | claraduboisr/FinalProjectArt | /circle.py | UTF-8 | 2,370 | 3.515625 | 4 | [] | no_license | import tkinter as tk
import turtle
from tkinter import *
from tkinter import messagebox
def center_window(w=300, h=200):
# get screen width and height
ws = root1.winfo_screenwidth()
hs = root1.winfo_screenheight()
# calculate position x, y
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root1.geometr... | true |
f9edb8b9414edbc6a2680c91aa9734cc905d8f78 | ehudkr/gandi | /MetricsG.py | UTF-8 | 2,333 | 2.734375 | 3 | [] | no_license | from scipy.stats import entropy, ks_2samp, kstest, anderson
import numpy as np
EPSILON = 10e-10
# ############################################### #
# ##### Distribution Metrics for Testing G: ##### #
# ############################################### #
def calc_Dkl(true_samples, generated_samples, bin_num=100):
... | true |
b717fe0997b5b893ad1d91709ae1a62670e0072b | ghleokim/codeTestProblems | /baekjoon/14891.py | UTF-8 | 2,462 | 3.5 | 4 | [] | no_license | # 20190814_백준_14891.py
# https://www.acmicpc.net/problem/14891
"""
총 8개의 톱니를 가진 톱니바퀴 4개
각 톱니의 방향 리스트: 현재 12시방향에 있는 톱니의 인덱스 = [g1, g2, g3, g4]
시계방향 회전: g - 1,
반시계방향 회전: g + 1
3시방향: (g + 2) % 8
9시방향: (g + 6) % 8
"""
"""
gear = [15,16,17,18,19,25,26,27,28,29]
# n번째 톱니바퀴(i=n-1)부터 1번째 톱니바퀴(i=0)까지
# 아래가 더 빠르다.
i = 6
for... | true |
ba628aa21ec35320254162bb2069501a1d9bd1d1 | zanalkamar/alloons | /src/models/excel/excel.py | UTF-8 | 1,748 | 2.8125 | 3 | [] | no_license |
# print('Your total sale as of today is : {}'.format(total_sale))
import csv
from src.models.sales.sales import Sales
from src.common.database import Database
Database.initialize()
def convert_str_float(string):
try:
return float(string)
except ValueError:
return None
with open('/Users/zam... | true |
576d57ef13ec022b2f83da6e34c6f6bcb6e2978b | cchestnut91/projects | /sudoku.py | UTF-8 | 13,228 | 3.34375 | 3 | [] | no_license | import math
def main():
#prompt user for puzzle
print "Please enter a 4x4 sudoku, using 0 for empty spaces"
#collect the puzzle
values = raw_input()
#values = "7 2 9 0 5 0 0 0 4 0 8 0 7 9 0 0 2 0 0 0 1 0 2 0 7 9 0 0 0 2 0 0 5 0 0 0 8 0 7 0 0 2 4 3 5 0 4 5 0 0 8 9 0 2 2 0 4 5 0 0 6 0 0 0 0 0 0 0 0 2 0 9 0 0 8 0 0 ... | true |
aeef00e50de87143dfdbe9ca37f5172c90f055f3 | Stealthmate/atcoder | /abc/abc015/b.py | UTF-8 | 137 | 2.75 | 3 | [] | no_license | import math
n = int(input())
bugs = list(filter(lambda x: x > 0, map(int, input().split(" "))))
print(math.ceil(sum(bugs) / len(bugs)))
| true |
8c0418be4e73d0d3bd637dc23fac45dbf56d13f0 | nova17621370317/nova | /get_weekno.py | UTF-8 | 740 | 3.453125 | 3 | [] | no_license | # _*_ coding: utf-8 _*_
from Tkinter import *
import time
def get_week():
listbox.delete(0,END)
week_num = u'今天' + '(' + time.strftime('%Y%m%d') + ')' + u'是第' + time.strftime('%W') + u'周'
listbox.insert(END,week_num)
root = Tk() # 实例一个窗口对象
root.title("第几周") #窗口的标题
#root.geometry('300x300+500+100') #设置窗... | true |
a2503f71acedfed1e111c068d5086547abd499d9 | WonderPro/Engineering-Practical-Experiments | /Semester 6/SPCC/Code optimization - Algebraic simplification/main.py | UTF-8 | 1,184 | 3.859375 | 4 | [
"Unlicense"
] | permissive | '''
author: Virag Dosani (@repl.it/@VTech1699)
'''
import sympy
from sympy import *
def readData(f):
with open(f) as f:
data = []
da = f.read().split("\n")
for line in da:
data.append(line.split("="))
return data
def algebraicSimplify(data):
x,y,z = symbols... | true |
db8522f0a4054935ead0c453e7415b6b0447f4f7 | Pseud0n1nja/VentureHub | /helpers_DL.py | UTF-8 | 13,670 | 2.53125 | 3 | [] | no_license | import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
import pickle
import time
import os
import matplotlib.pylab as pylab
from matplotlib.ticker import MaxNLocator
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # ... | true |
6a713238775aa86a1565ff05b67df06bc9cc0ff0 | Ayrton1931/SIAF--Division-Funcioanal-CIENCIA-y-Tecnolog-a | /siaf_inn_local_gob.py | UTF-8 | 23,079 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 12 09:32:00 2020
@author: Shadow
"""
import time
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC # av... | true |
fee56c71db273aaff336b46a2ede1c185c7f3dc5 | mconigliaro/project_euler | /tests/test_pascal.py | UTF-8 | 602 | 3.0625 | 3 | [] | no_license | import pytest
from project_euler.pascal import pascals_triangle
@pytest.fixture
def known_pascals_triangle():
return [
[1],
[1, 1],
[1, 2, 1],
[1, 3, 3, 1],
[1, 4, 6, 4, 1],
[1, 5, 10, 10, 5, 1],
[1, 6, 15, 20, 15, 6, 1],
[1, 7, 21, 35, 35, 21, 7, 1]... | true |
4f1ec7fa420e9aae25383b429708da70e5f67222 | rishuatgithub/weather-data-analysis | /job/weather_job.py | UTF-8 | 777 | 2.53125 | 3 | [] | no_license | from conf import spark, logging
from transformation import weather_ingest, weather_transform
if __name__ == '__main__':
WEATHER_INPUT_PATH = '../data/input/*.csv'
WEATHER_INGEST_OUTPUT_PATH = '../data/output/weather_parquet'
WEATHER_TRANSFORM_OUTPUT_PATH = '../data/output/weather_calculate_temperature'
... | true |
077214546d194a0838e9c5534a014310b48f689a | libinjungle/LeetCode_Python | /dp/132_palindrome_partitioning_II.py | UTF-8 | 2,366 | 3.6875 | 4 | [] | no_license | class Solution(object):
def minCut(self, s):
"""
dp[i] is the min cut of previous i number of chars.
initialize dp[len(s)] with each element to be its index minus 1.
dp[i] = min(dp[j]+1, dp[i]) for j < i and j~i-1 is palindrome.
time: O(n3)
:type s: str
:rtype: int
"""
if not len(... | true |
7de39e003ff9e8d2b393fad2ea6a2ae610da5558 | corentinalcoy/orm | /src/masonite/orm/blueprint/Blueprint.py | UTF-8 | 24,036 | 2.90625 | 3 | [
"MIT"
] | permissive | class Column:
"""Used for creating or modifying columns.
"""
def __init__(
self,
column_type,
column_name,
table=None,
length=None,
nullable=False,
action="add",
default=None,
):
self.column_type = column_type
self.column_n... | true |
38fe712d5a42fc6dd746f104e0de491ccae545ee | tomviner/tdd-dojo | /prepared-kata-roman-numerals/test_roman.py | UTF-8 | 1,613 | 2.75 | 3 | [] | no_license | import pytest
from roman import *
from acceptance_test_values import ACCEPTANCE_TEST_PACK
TEST_PAIRS_1 = (
(1, 'I'),
(5, 'V'),
(10, 'X'),
(50, 'L'),
)
TEST_PAIRS_2 = TEST_PAIRS_1 + (
)
TEST_PAIRS_3 = TEST_PAIRS_2 + (
(6, 'VI'),
(11, 'XI'),
(16, 'XVI'),
(51, 'LI'),
(55, 'LV'),
(... | true |
0640da96b226a5d05bac4281eb9893ccf09139a4 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2561/60870/278251.py | UTF-8 | 844 | 2.546875 | 3 | [] | no_license | num_test = int(input())
info_list = []
mat1_list = []
mat2_list = []
for i in range(num_test):
info = input().split()
info = [int(x) for x in info]
num_line = info[0]
mat1 = []
mat2 = []
for j in range(num_line):
array = input().split()
array = [int(x) for x in array]
for... | true |
3d6cf233943d21cee813b90f253609496aab4498 | phanirajl/stock-analysis-engine | /analysis_engine/iex/fetch_api.py | UTF-8 | 11,499 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | """
Fetch API calls wrapping pyEX
Supported environment variables:
::
# verbose logging in this module
export DEBUG_FETCH=1
"""
import pyEX.stocks as pyex_stocks
import analysis_engine.iex.consts as iex_consts
import analysis_engine.iex.utils as fetch_utils
import analysis_engine.dataset_scrub_utils as scr... | true |
b04a05596981ad27aea994d7658ec2bd7700ccb7 | lucky777-dev/Q3 | /DON3/execute.py | UTF-8 | 1,577 | 3.09375 | 3 | [] | no_license | #!/usr/bin/python3
#coding:utf-8
import sqlite3
import os
td = input("File name to execute?: ")
if not os.path.exists(os.getcwd() + f"/data.db"):
print(f"error: can't find file 'data.db'!")
exit(0)
with open(td, 'r') as file:
data = file.readlines()
if len(data) == 0:
print(f"error: 'data.db' file ... | true |
22be9bb8710f79bcd078b4d9f339d556b63dffbb | bmoretz/Daily-Coding-Problem | /py/algo_scratch.py | UTF-8 | 4,593 | 3.625 | 4 | [
"MIT"
] | permissive | '''
In this assignment you will implement one or more algorithms for the traveling salesman problem, such as the dynamic programming
algorithm covered in the video lectures. Here is a data file describing a TSP instance.
tsp.txt
The first line indicates the number of cities. Each city is a point in the plane, and eac... | true |
96e261b891b33b7ccfc330f2706b5ece895356ec | Phantom139/wrf-gaea-run | /scripts/Wait.py | UTF-8 | 1,904 | 3 | 3 | [] | no_license | #!/usr/bin/python
# Wait.py
# Robert C Fritzen - Dpt. Geographic & Atmospheric Sciences
#
# Contains methods used to hold the process until specific conditions are met
import datetime
import time
import sys
import os
import subprocess
import Tools
#TimeExpiredException: Custom exception that is thrown when the Wait()... | true |
d0392bfbcfe106ad0c01c2fa6cee82f28db79315 | amacd31/phildb | /examples/hrs/hrs_data/list_hrs.py | UTF-8 | 140 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | import json
x = json.load(open("site_config.json"))
for station in x["stations"]["features"]:
print(station["properties"]["AWRC_ID"])
| true |
c1bd335b7a723f6e630eb9fe8b54cd668c80417f | Reactive-Capital/huobi_Python | /huobi/model/etp/creation_quota.py | UTF-8 | 1,292 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | from huobi.utils.json_parser import fill_obj
class CreationQuota:
"""
Creation quota of ETP
:member
maxCreationValue: Maximum creation value per request.
minCreationValue: Minimal creation value per request.
dailyCreationValue: Maximum creation value per day.
creation... | true |
25b4884c8bacdeea2bfcd4616dec76b38518e4e4 | bnajafi/Scientific_Python_Assignments_POLIMI_EETBS | /Assignment 5 - Numpy - Deadline Oct 24 2017/Assignment 5 Fabio Gardella/Assignment 5_step2_Gardella.py | UTF-8 | 1,651 | 2.78125 | 3 | [] | no_license | import numpy as np
# DEFINING
material_names = np.array (["Wood_Bevel_Lapped_Siding","Wood_Fiberboard_Sheeting","Glass_Fiber_Insulation","Wood_Stud","Gypsum_Wallboard","Outside_Surface_Winter","Inside_Surface"])
material_resistances = np.array([0.14,0.23,2.45,0.63,0.079,0.03,0.12])
layers_in_series = np.array (["Wo... | true |
ef1888386b94148207a617a3daa6c3f49b0683b6 | smeenai/llvm-project | /mlir/test/python/ir/builtin_types.py | UTF-8 | 24,543 | 2.640625 | 3 | [
"LLVM-exception",
"Apache-2.0",
"NCSA"
] | permissive | # RUN: %PYTHON %s | FileCheck %s
import gc
from mlir.ir import *
from mlir.dialects import arith, tensor, func, memref
def run(f):
print("\nTEST:", f.__name__)
f()
gc.collect()
assert Context._get_live_count() == 0
return f
# CHECK-LABEL: TEST: testParsePrint
@run
def testParsePrint():
ctx ... | true |
c6e3a9e58ab5966ddda8ece7d850ef3baf3e28d7 | Aasthaengg/IBMdataset | /Python_codes/p03837/s455623948.py | UTF-8 | 652 | 2.96875 | 3 | [] | no_license | N,M=map(int,input().split())
def warshall_floyd(d):
#d[i][j]: iからjへの最短距離
for k in range(size_v):
for i in range(size_v):
for j in range(size_v):
d[i][j]=min(d[i][j],d[i][k]+d[k][j])
return d
abclist=[]
for i in range(M):
a,b,c=map(int,input().split())
abclist.append((a,b,c))
#print(graph)
... | true |
4aac5821e846e9841f6c93d7071a9c0c85f3e29b | HenriqueCSJ/Python-Lessons | /Dictionaries/dictionaries3.py | UTF-8 | 447 | 3.546875 | 4 | [] | no_license | fruit = {"orange": "a sweet, orange, citrus fruit",
"apple": "good for making soda",
"lemmon": "a sour, yellow, citrus fruit",
"grape": "a small, sweet fruit",
"lime": "a sour, green, citrus fruit"}
print(fruit)
print(fruit.items())
f_tuple = tuple(fruit.items())
print(f_tuple)
fo... | true |
13e93712ad7b0667fbd6fe78d0f0e955387be621 | ZohanKPI/Lab1 | /third_task.py | UTF-8 | 901 | 3.484375 | 3 | [] | no_license | def EBNF_SyntaxChecker(string):
if not string:
return False, None
elif string.isdigit():
return True, int(string)
flag = True
subtract = False
operationResult = 0
for i in range(0, len(string), 2):
if not string[i].isdigit():
flag = False
break
... | true |
c447f91fdcc44299bdfaa9c49d8634d958b36b63 | AmineBarrak/commit-entropy | /tests/parser/test_git_log_parser.py | UTF-8 | 2,997 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# coding=utf-8
import unittest
from commit_entropy.parser.git_log_parser import GitLogParser
from datetime import datetime, timezone, timedelta
class GitLogParserTest(unittest.TestCase):
def setUp(self):
self.commit_line_without_commit_keyword = '9093ace390c4e44910774ebddef403689435... | true |
6f7f5f8fe28e01c58dd9359a1ec37e9e5d7fe0f0 | Glasgow2015/team-3 | /protocol.py | UTF-8 | 4,580 | 2.65625 | 3 | [] | no_license | import time
import datetime
def harvest_from_twilio(input):
elements = input.split('|')
return {
"harvest_date": elements[0].strip(),
"quantity": int(elements[1].strip()),
"beekeeper_clothing": elements[2].strip().lower() == "yes",
"assistant_clothing": elements[3].strip().lower... | true |
cba30077d4f7d0f1fd0838e2b51e3e0752749a2e | Lazydog8000/python_script | /year_add_one.py | UTF-8 | 711 | 2.71875 | 3 | [] | no_license | import re
fp = open("C:/Users/wcl/ecmwf_data_download_copy.py","r+")
line_all = fp.readlines()
#print(type(line_all[7]))
year_old = re.findall(r'\d{4}',line_all[7])
#print(year_old)
year_num = int(year_old[1]) + 1
#print(year_num)
year = year_num
#print(year)
line_all_seven_new = line_all[7].replace(y... | true |
cd47299be93fde5abaf6958af9dc4d5434c19679 | tomi77/python-t77-date | /tests/timedelta_to_seconds_test.py | UTF-8 | 1,267 | 3.421875 | 3 | [
"MIT"
] | permissive | import unittest
from datetime import timedelta
from t77_date import timedelta_to_seconds
class TimedeltaToSecondsTestCase(unittest.TestCase):
def test_not_timedelta(self):
"""timedelta_to_seconds throw TypeError when val is not datetime.timedelta"""
val = 'not timedelta object'
with self.... | true |
d2f189fc60221106df99ac98d08489bca85d7c2a | JBarrada/7seg | /code/NEW/debug/driver_debug.py | UTF-8 | 1,463 | 2.640625 | 3 | [] | no_license | from debug_graphics import *
import threading
import time
import color_tools
a_rect, b_rect, c_rect, d_rect, e_rect, f_rect, g_rect, dprect = [None]*8
rects = None
win = None
seg_pos = [4, 5, 7, 1, 2, 3, 6, 0]
def push(segments):
global rects, seg_pos
for i in range(8):
r, g, b = segments[i]
... | true |
b806d40237707ed2b0d1e1a791663ca844b6acec | LeonLenclos/a-quoi-bon-te-suivre | /script.py | UTF-8 | 6,397 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env python3
# Oulala c'est pas très beau tout ça.
#
# Faudra que je prenne le temps de revoir un peu ce code.
#
# ('< _ '
import pyglet
from math import *
import random
import os, sys
window = pyglet.window.Window(600 ,600)
coords = 300, 200
class Face():
"""docstring for Face"""
def __init__... | true |
fd93d9209d6aa3816db8f24047c98096b911ff90 | progress0407/python-nadongbin-codingtest | /ndb/lec01_grammer/03_conditional_loop.py | UTF-8 | 2,026 | 3.734375 | 4 | [] | no_license | # 가이드라인에서는 4개의 공백 문자가 들여쓰기의 표준이라 정의
# 4번 space VS tab : 2진영
# 범위가 작은 구간부터 해야 모든 상황을 나누어 처리 가능
score = 95
if score >= 95:
print('학점 A+')
elif score >= 90:
print('학점 A')
else:
print('학점 B~F')
# and or not
if (True or False) and (not False):
print("True")
# in, not in
# 리스트, 튜플, 문자열, 딕셔너리
if 'a' not i... | true |
62ded4f20971e0a4647a2abf593848f61a7f2511 | Infinitehj/LDA-classification | /lda.py | UTF-8 | 6,204 | 2.8125 | 3 | [] | no_license | import os
import jieba
import random
import numpy
def read_document(doc_num,stop_words,dic):
doc = []
for m in range(doc_num):
doc.append([])
path = os.getcwd() + "\\data\\1"+str(m)+".txt"
f = open(path)
try:
ftext = f.read()
finally:
f.close()
... | true |
53e54bb876ead296f3c0731f762944b6bd596a82 | slashbreak/Project-Euler | /euler36.py | UTF-8 | 222 | 3.234375 | 3 | [] | no_license | #!/usr/bin/python
sum = 0
for i in range(1,1000000):
b2 = bin(i)[2:]
b2rev = b2[::-1]
b10 = str(i)
b10rev = b10[::-1]
if b2 == b2rev and b10 == b10rev:
sum += i
print(str(i))
print(sum)
| true |
d24b5f58e7de08a1bf4cbd26e20e982e1553340a | Chenhuaqi6/python_base | /练习专用/day16/code/seek.py | UTF-8 | 514 | 4.0625 | 4 | [] | no_license | # seek.py
# 此示例示意用seek 来改动文件的读写位置
f = open('data.txt', 'rb')
b = f.read(3)
print("您读取的是:", b)
print("当前的读写位置是:", f.tell())
# 以下读写第5至第10个字节的b'abcde'
# f.seek(5, 0) # 从文件头开始向后移动5个字节
# f.seek(2, 1) # 从当前位置向后移动2个字节
f.seek(-15, 2) # 从文件尾向向前移动15个字节
print("当前的读写位置是: ", f.tell())
b = f.read(5)
print("读取的内容是:", b)
f.cl... | true |
4089cefcd1ed1a4b4ed649b3f17b0d17a30bf994 | velllum/parse_arshin_mongodb | /parseDataArshin.py | UTF-8 | 3,037 | 2.578125 | 3 | [] | no_license | import env
import os
import requests
from pymongo import MongoClient
class ParseArshin:
_PAGE_NUMBER = 1
_PAGE_SIZE = 1000
# _MONGO_CONNECTION = f"mongodb+srv://{os.getenv('MONGO_LOGIN')}:{os.getenv('MONGO_PASS')}@cluster0.fs8kg.mongodb.net/{os.getenv('MONGO_DB')}?retryWrites=true&w=majority"
_MONGO... | true |
72e2915ac1cdfbdf2e26aa42bb6dac411e022d19 | jongjunpark/TIL | /Public/problem/D1/2047.신문헤드라인.py | UTF-8 | 29 | 2.640625 | 3 | [] | no_license | a = input().upper()
print(a)
| true |
0c4395c3f2fb0a595ba3cd548813dc7d95db1f30 | Aasthaengg/IBMdataset | /Python_codes/p04030/s554025536.py | UTF-8 | 187 | 3.0625 | 3 | [] | no_license | s1 = str(input())
s = []
for i in s1:
if i == '0' or i == '1':
s.append(i)
else:
if 1 <= len(s):
s.pop(len(s)-1)
w = ""
for h in s:
w += h
print(w) | true |
a87b921bf98ec01ea3e54358e6acb92afed9c2b6 | grodrigues3/InterviewPrep | /Leetcode/containsDuplicate.py | UTF-8 | 284 | 2.890625 | 3 | [] | no_license | class Solution:
# @param {integer[]} nums
# @return {boolean}
def containsDuplicate(self, nums):
e = {}
for thing in nums:
if thing in e:
return True
else:
e[thing] = 1
return False
| true |
6370a6fcda045641eb85d1cd3bec13e8547c98a0 | vselosi/adalin | /functionally_chek_login_pswd.py | UTF-8 | 817 | 3.046875 | 3 | [] | no_license | import pwd
passwd_db = pwd.getpwall()
def erroruser():
erroruser = []
global passwd_db
try:
for entry in passwd_db:
username = entry[0]
if len(username) < 7:
erroruser.append(username)
except:
print 'Error while executing erroruser function!'
... | true |
031c6c0384a9d7ec2cf8c0fcbd789826ada2b57e | Kaiutin/Lakauma | /scrapers/scrapers/spiders/crawlersAndDrivers/ovv_webdriver.py | UTF-8 | 1,945 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @author: Samuel Uusi-Makela
# @version:
#
# Webdriver meant to automate searching of the information of available
# apartments in Jyväskylä from ovv.com website.
#
#
# Requires seleniumHQ, we should all have pip installed so
# installation is as simple as "[sudo] pip install selenium" (or ... | true |
d680ce0861694829bf1b11a7ae3d48e4fcdd6f09 | ChrisFugl/Reasoning-From-Memory | /evaluation/types/evaluation_result.py | UTF-8 | 1,205 | 3.265625 | 3 | [] | no_license | """Contains definition of an evaluation results."""
class EvaluationResult:
"""Definition of an evaluation result."""
def __init__(self, name, test_results):
"""
Create a new evaluation result.
:type name: str
:type test_results: list of evaluation.types.test_result.TestResult... | true |
24bea3df464978c3181a5c79f1768dc16f1efd57 | sheelabhadra/LeetCode-Python | /868_Transpose_Matrix.py | UTF-8 | 444 | 3.9375 | 4 | [] | no_license | # Given a matrix A, return the transpose of A.
## SOLUTION: List comprehension - Visit each column and convert the elements in them into rows.
class Solution(object):
def transpose(self, A):
"""
:type A: List[List[int]]
:rtype: List[List[int]]
"""
if A == [[]]:
... | true |
885464dc246c3d0b2d635fbcb3e934efef71e6ce | Bradysm/daily_coding_problems | /largestThreeNumProduct.py | UTF-8 | 5,130 | 4.15625 | 4 | [
"MIT"
] | permissive | # Hi, here's your problem today. This problem was recently asked by Microsoft:
#You are given an array of integers. Return the largest product that can be made by multiplying any 3 integers in the array.
#Example:
#[-4, -4, 2, 8] should return 128 as the largest product can be made by multiplying -4 * -4 * 8 = 128.
... | true |
326169ba6f3e89d350ace65b4b1b6dbbf7bb3294 | rafaelperazzo/programacao-web | /moodledata/vpl_data/11/usersdata/143/4559/submittedfiles/jogo.py | UTF-8 | 609 | 3.453125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import division
import math
cv = input(' Numero de vitórias do Cormengo: ')
ce = input(' Numero de empates do Cormengo: ')
cs = input(' Saldo de gols do Cormengo: ')
fv = input(' Numero de vitórias do Flaminthians: ')
fe = input(' Numero de empates do Flaminthians: ')
fs = input(... | true |
09a3f7099c67482b270b97fbdcd499730fbc3c71 | yeseongcho/- | /프로그래밍1/emma.py | UTF-8 | 825 | 3.359375 | 3 | [] | no_license |
f = open("./words.txt", "r")
word_dict = {}
for word in f :
wrd = word.strip()
if 5 <= len(wrd) <= 10 :
word_dict[wrd] = 0
f.close()
file = open("./emma.txt", "r")
#
for line in file :
if line.startswith("*END*THE") :
break
# 가정 : line을 읽는 것이 위에 것의 바통을 받아서 이어진다.
for line in file :
wo... | true |
a4c087ad46aa2930f7d4c571db4fb348456dc726 | chenguanghuang/store | /day12/danyuanceshi.py | UTF-8 | 1,252 | 3.515625 | 4 | [] | no_license | '''
单元测试:
1、使用unittest单元组件
1.1继承TestCase测试用例
1.2测试用例方法命名必须是testxxxx
1.3使用assertEqual()来断言
'''
from Calc import Calc
import unittest
class TestCalc(unittest.TestCase):
def testAdd(self):
#1.准备数据
a = 6
b = 5
c = 11
... | true |
878ea687dd51a540185ca8ea55b314df4f14e53e | Hellofafar/Leetcode | /Medium/221.py | UTF-8 | 1,505 | 3.828125 | 4 | [] | no_license | # ------------------------------
# 221. Maximal Square
#
# Description:
# Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
# Example:
# Input:
# 1 0 1 0 0
# 1 0 1 1 1
# 1 1 1 1 1
# 1 0 0 1 0
# Output: 4
#
# Version: 1.0
# 09/12/18 by Jianfa
# --------... | true |
98a2b2701b902d69dff4399fca136e0cc1a7ff37 | libyal/libyal | /data/source/tests/pyyal_test_type/read_buffer_file_object-end.py | UTF-8 | 457 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive |
with open(test_source, "rb") as file_object:
${library_name_suffix}_${type_name}.open_file_object(file_object)
${type_size_name} = ${library_name_suffix}_${type_name}.get_${type_size_name}()
# Test normal read.
data = ${library_name_suffix}_${type_name}.read_buffer(size=4096)
self.... | true |
d08d79705375c2320893b761537892d2dcb9beee | KsenijaS/pytorch | /benchmarks/instruction_counts/definitions/standard.py | UTF-8 | 6,660 | 2.703125 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"BSL-1.0",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | """Default set of benchmarks.
Parser notes:
`parse_stmts`:
- Width for the left (Python) column MUST be 40 characters.
- The column separator is " | ", not "|". Whitespace matters.
`GroupedVariants`:
- `Setup` and `Global_Setup` (case insensitive) are reserved keywords
to pop... | true |
d72fb12186be24617f8cd9b6163a3efb1573bc51 | ALopezMoreno/Reparametrisation | /Scripts/complex_multiplicator.py | UTF-8 | 4,813 | 3.265625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 13 15:54:09 2020
@author: andre
"""
#A program to calculate the algebra of the PMNS formalism
#This will be useful for grouping up powers at the end
def find_all(a_str, sub):
start = 0
while True:
start = a_str.find(sub, start)
if start == -1: re... | true |
81c829b335518b678be8fe0dff45c7fa54324eb8 | oscarkey/safe-exploration | /safe_exploration/ssm_gpy/gp_models_utils_casadi.py | UTF-8 | 8,208 | 2.8125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 25 14:54:53 2017
@author: tkoller
TODO: Untested (But reused)!!
TODO: Undocumented!
"""
import numpy as np
from casadi import mtimes, exp, sum2, repmat, Function, sqrt, vertcat, horzcat, SX
from casadi import reshape as cas_reshape
def _k_rbf(x, y=None, variance=1., ... | true |
bcdd90432e18fcd180ce31a45e68631f60968def | heysion/python-demo | /python-obj/python_self.py | UTF-8 | 272 | 3.453125 | 3 | [
"MIT"
] | permissive |
class ClassA:
def __init__(self):
self.name = "abc"
self.age = 123
def start(self):
get_self(handler = self)
def get_self(handler):
print handler.name
print handler.age
if __name__ == "__main__":
a = ClassA()
a.start()
| true |
75f273693e36463a0fd256bdcd94692d3767a183 | gzucolotto/PrimeNumbersPlotting | /StatisticCollector.py | UTF-8 | 1,674 | 2.75 | 3 | [] | no_license | import time
import matplotlib.pyplot as plt
import math
counter = {}
times = {}
lables = {}
stored_series = {}
stored_times = {}
stored_labels = {}
def method_decorator(method):
'''
Decorator to getter method invocations and execution times.
'''
def wrapper(*args, **kwargs):
key = method
if counter.__contain... | true |
e63dded6434c5dc9f2c2b3249622d9aa767d3510 | simonmonk/raspirobotboard2 | /python/examples/test.py | UTF-8 | 2,539 | 3.15625 | 3 | [
"MIT"
] | permissive | #Python 2
import rrb2 as rrb
import time
#import ex_8x8_pixels
rr = rrb.RRB2(revision=2)
def confirm(question):
answer = raw_input(question)
def test_leds():
rr.set_led1(0)
rr.set_led2(0)
confirm("Are LED1 and LED2 both OFF?")
rr.set_led1(1)
rr.set_led2(0)
confirm("Is LED1 ON and LE... | true |
2dc9182bd77fdc0336755d6f2d4d4b324d3df40a | anaisafonseca/POO | /python/retangulo.py | UTF-8 | 196 | 3.59375 | 4 | [] | no_license | print("i'm lonely now")
class Retangulo():
def area(self,a=0,b=0):
area = b*a
print(area)
rec = Retangulo() #Retangulo rec = new Retangulo()
rec.area()
rec.area(5,4) | true |
de7c37ca468deec9fdfd0056cce0b2f8d719649a | komendantyan/digits | /utils.py | UTF-8 | 3,386 | 2.609375 | 3 | [] | no_license | from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
import sklearn.datasets
import sklearn.preprocessing
import sklearn.cross_validation
import tensorflow as tf
__all__ = []
def register(func):
__all__.append(func.func_name)
return func
@register
def imgshow(img, target=''... | true |
072eaf1315fd0e27527d6b1b4e25b15fb4cde88c | danielmansueto/Programming2-Daniel | /Notes/recursion.py | UTF-8 | 2,944 | 4.25 | 4 | [] | no_license | # recursion (functions calling themselves)
# functions can call functions
def f():
print("f")
g()
def g():
print("g")
f()
# function calling itself
def f():
print("F")
f()
#f()
# we can control the recursion depth
def controlled(level, end_level):
print("Recursion level:", level)
if lev... | true |
09f49cb6a35e6ae2775966b1ea39cb543e4b103c | Feinasia/yzu_python | /lesson05/DefDemo06.py | UTF-8 | 340 | 4.15625 | 4 | [] | no_license | def add(x):
return x + 1
def sub(x):
return x - 1
def operate(func, x): # 函式拿來當參數
return func(x)
x = 10
x = operate(sub, x) # 函式拿來當參數
print(x)
y = 10
y = operate(add, y) # 函式拿來當參數
print(y)
z = [add, sub] #函式陣列
for i in z:
y = 10
y = operate(i, y)
print(y)
| true |
caec89f73a62b85b958fa4017326f0c5b8bfe27d | umiswing/NiuTrans.NMT | /tools/GetVocab.py | UTF-8 | 1,085 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | '''
Convert a bpe vocabulary to a NiuTrans.NMT vocab
Usage: python3 GetVocab.py -src [bpe_vocab] -tgt [niutrans_nmt_vocab]
'''
import sys
import argparse
parser = argparse.ArgumentParser(description='prepare parallel data for nmt training')
parser.add_argument('-raw', help='Path of the BPE vocabulary', type=str, defa... | true |
367aac19dbbe21d4ea1c56b57ac81a572b41bc31 | MayankMaheshwar/data_structures_and_algorithms | /sorting_algos/mergesort/test_mergesort.py | UTF-8 | 796 | 3.640625 | 4 | [] | no_license | from .mergesort import mergesort
import pytest
def test_merge_sort_method_exist():
"""Test merge sort method exist"""
assert mergesort
def test_merge_sort_is_successful():
"""Test merge sort is successful"""
actual = [34, 19, 42, -9, 2018, 0, 2005, 77, 2099]
expected = [-9, 0, 19, 34, 42, 77, 20... | true |
a56b2cf6b0e9ae0b4182c78ecdc72f52cc8e083d | kleimkuhler/snippets | /Python/dijkstras.py | UTF-8 | 1,056 | 3.140625 | 3 | [] | no_license | from PriorityQueue import PriorityQueue
from utils import *
name = 'dijkstras'
def dijkstra(pq, adjlist, weights):
"Dijkstra's algorithm to find the shortest distance of each node from 1."
while pq.Q:
u = pq.delete()
for v in adjlist[u]:
if pq.dist[v] > pq.dist[u] + weights[(u, v)]... | true |
034ebd235bb35e7db1b891979f9a153eb3b1b170 | wnoadiarwb/cellular-automata-map-generator | /Scaler.py | UTF-8 | 721 | 2.734375 | 3 | [] | no_license | import numpy as N
from numpy import int32, uint8, uint
class Scaler():
def __init__(self, array, scale):
self.inArray = array
self.scale = scale
self.inW = len(array)
self.inH = len(array[0])
self.outArray = N.zeros((self.inW*scale, self.inH*scale, 3), int32)
def transf... | true |
56da693ec2e6ff598fc88213144d6b34cf07c39c | Jiwno/pydub-audio-conditioner | /wav_conditioner.py | UTF-8 | 2,879 | 2.96875 | 3 | [] | no_license | import os
import sys
import argparse
from pydub import AudioSegment
DIR = "./"
SAMPLERATE = 24000
BITRATE = 16
SEC = 5000
EXTENSION = "wav"
#AudioSegment.converter = 'path/to/ffmpeg.exe'
def get_arguments():
parser = argparse.ArgumentParser(description='Wav file conditioner for training dataset')
parser.add_a... | true |
e1de90efd7b4fdfd435d64776f4d9fee853722cc | lorand-tatar/AdventOfCode | /src/main/python/year2021/Day14.py | UTF-8 | 2,959 | 2.921875 | 3 | [] | no_license | file_path = 'inputs/day14.txt'
base_material = ""
rules = {}
with open(file_path, 'r') as file:
read_rules = False
for line in file:
if not read_rules:
if line.rstrip() == "":
read_rules = True
else:
base_material = line.rstrip()
else:
... | true |
33e2dfb6bfec672ab4d3e57c7cb4cd0f5c877b0e | Sniper970119/leetCode | /L0101~L0150/L0138.py | UTF-8 | 1,063 | 2.984375 | 3 | [] | no_license | # -*- coding:utf-8 -*-
"""
┏┛ ┻━━━━━┛ ┻┓
┃ ┃
┃ ━ ┃
┃ ┳┛ ┗┳ ┃
┃ ┃
┃ ┻ ┃
┃ ┃
┗━┓ ┏━━━┛
┃ ┃ 神兽保佑
┃ ┃ 代码无BUG!
┃ ┗━━━━━━━━━┓
┃ ┣┓
┃ ┏┛
┗━┓ ┓ ┏━━━┳ ┓ ┏━┛
┃ ┫... | true |
9a4b6eba6e062170c0012a2e8e55e4cee7e1e420 | viralsir/flaskblog | /users/routes.py | UTF-8 | 1,566 | 2.71875 | 3 | [] | no_license | from flask import Blueprint,render_template,flash,redirect,url_for
from users.form import RegisterForm,LoginForm
from main import bcrypt,db
from users.model import User
from flask_login import login_user,logout_user,current_user
user=Blueprint('user',__name__)
@user.route("/register",methods=['GET','POST'])
def regi... | true |
19c28054ffd1c482510dfcdec4d46ec3a7b6b608 | blueset/comp30024-2019-part-b | /ᐖ⵿/greedy_player.py | UTF-8 | 927 | 3.0625 | 3 | [] | no_license | from .board import Board, DESTINATIONS
from .typing import Coordinate
from .utilities import exit_distance
class Player:
def __init__(self, color):
self.color = color
self.board = Board()
def action(self):
dests = DESTINATIONS[self.color]
best_dist = float("inf")
best... | true |
062142edf13679ae2d9ad70ec4e0861e47e1278e | JonnyMe/bq-paella-splashimg-tools | /paella_splashimg_tools.py | UTF-8 | 5,769 | 2.59375 | 3 | [] | no_license | #!/usr/bin/python3.6
import os,sys,getopt
from PIL import Image
FILEHEADER_LENGTH = 128
BQ_AQUARIS_X5_SCREEN_W = 720
BQ_AQUARIS_X5_SCREEN_H = 1280
IMAGE_STARTS = 1
IMAGE_ENDS = 2
OFFSET_SPLASH = 512
SPLASH_MAX_SIZE = 31224
OFFSET_BOOTLOADER = 31744
BOOTLOADER_MAX_SIZE = 65016
SPLASHIMG_SIZE = 96768
def is_paddin... | true |
de5a96c8614eb5a3cfa89aa838da810d834131d1 | master-fufu/Adidas-Stock-Check | /StockWindow.py | UTF-8 | 1,577 | 2.84375 | 3 | [] | no_license | import AdidasStock
from Tkinter import *
import tkMessageBox
class StockWindow:
def __init__(self):
self.master = Tk()
self.master.wm_title("pslifeisgood - Adidas Stock Checker")
self.master.minsize(width=500, height=275)
self.master.maxsize(width=500, height=275)
self.v = ... | true |
0a7f718ffbe1081b03d090b83d1c7a3a2371ee14 | Unviray/ES21 | /es21/filters.py | UTF-8 | 3,854 | 2.75 | 3 | [] | no_license | """
es21.filters
============
Include all filters of preachers.
"""
from flask import current_app as app
from tinydb import Query
from .database import get_db
from ._type import _int
q = Query()
class Filter(object):
def __init__(self, preachers):
self.preachers = preachers
self.filters = dic... | true |
9a60ec124e5842ce429589b32eb02d0f88e62796 | DataRozhlas/upadek-stran-plus | /analyza.py | UTF-8 | 2,562 | 2.703125 | 3 | [] | no_license | #%%
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
# %%
data_volby = pd.read_excel("./data/parlgov.xlsx", sheet_name="election")
data_party = pd.read_excel("./data/parlgov.xlsx", sheet_name="party")
#%%
# %%
data = data_volby.merge(data_party[['par... | true |
caaf59d09e0cb6f1585ccc575a421c91d8470df9 | Deaseyy/algorithm | /DP问题/斐波那契数列.py | UTF-8 | 796 | 4.4375 | 4 | [] | no_license | """
递推公式:f(n) = f(n-1) + f(n-2)
1 2 3 4 5 6 7 ...
0 1 1 2 3 5 8 ...
递归算法的时间复杂度怎么计算?就是用子问题个数乘以解决一个子问题需要的时间。
1.首先计算子问题个数,即递归树中节点的总数。显然二叉树节点总数为指数级别,所以子问题个数为 O(2^n)。
2.然后计算解决一个子问题的时间,在本算法中,没有循环,只有 f(n - 1) + f(n - 2) 一个加法操作,时间为 O(1)。
所以,这个算法的时间复杂度为二者相乘,即 O(2^n),指数级别,爆炸。
"""
def fib(n: int):
if n == 0 or n == 1: r... | true |
445018165eacf63498abc0648f43d194289d0dc2 | Javiebear/localhack | /Local_Hack.py | UTF-8 | 3,829 | 3.21875 | 3 | [] | no_license | #####################################################
# Program: Panda and Rocky
# Date: December 2, 2017
# Description: Panda flying, avoiding death
# Authors: Cindy Wang, Javier Chung, Raymond Li
#####################################################
import pygame
pygame.init()
import random
WIDTH = 625
HEIGHT= 450
g... | true |
9922917e290b2122ee248ac68b95553234be4c60 | JingkaiTang/github-play | /different_government/find_eye_beneath_man.py | UTF-8 | 234 | 3 | 3 | [] | no_license |
#! /usr/bin/env python
def have_long_hand_after_number(str_arg):
seem_other_man(str_arg)
print('able_way')
def seem_other_man(str_arg):
print(str_arg)
if __name__ == '__main__':
have_long_hand_after_number('hand')
| true |
6aa152c09d8be6867a7b74cd78541b351ae0803e | theryanclausen/Algorithms | /rock_paper_scissors/rps.py | UTF-8 | 563 | 3.390625 | 3 | [] | no_license | #!/usr/bin/python
import sys
rps = [['rock'], ['paper'], ['scissors']]
def rps_appender(l):
return [[*l, rps[0][0]], [*l, rps[1][0]], [*l, rps[2][0]]]
def rock_paper_scissors(n):
result = [[]]
while n > 0:
length = len(result)
temp = []
for x in result:
temp.extend(rps_appender(x))
n = n... | true |
1933952e41e9a5a9890e03b4f7671dbe15bd1c3a | r15h1/opencv | /A-FaceDetection/03FaceRecognizer.py | UTF-8 | 3,821 | 2.796875 | 3 | [] | no_license | import sys, cv2, os
import numpy as np
def get_images_and_labels(path):
# Append all the absolute image paths in a list image_paths
# We will not read the image with the .sad extension in the training set
# Rather, we will use them to test our accuracy of the training
image_paths = [os.path.join(path, ... | true |
bc14f2a23666d2298105c9c13a6161e83a6921b1 | nguyenhotoanthuap97/face_recognition | /facerec_cnn/facerec_cnn_test_model.py | UTF-8 | 3,698 | 2.546875 | 3 | [] | no_license | from imutils.video import VideoStream
from imutils import face_utils
from imutils.face_utils import FaceAligner
import imutils
import time
import cv2
import dlib
import sys
import numpy as np
import json
# Saving and loading model and weights
from keras.models import model_from_json
from keras.models import load_model... | true |
c400117c00ed9e883e1c57ccf66c204e8f97dfe8 | westqzy/leetcodes | /120.三角形最小路径和.py | UTF-8 | 1,132 | 3.25 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=120 lang=python3
#
# [120] 三角形最小路径和
#
# @lc code=start
import copy
class Solution:
def minimumTotal(self, triangle: List[List[int]]) -> int:
n = len(triangle)
dp = [[0] * n for _ in range(n)]
dp[0][0] = triangle[0][0]
for i in range(1, n):
dp... | true |
f9911b69b5eabf071515296af4d8366e1a36ed65 | jeremyfirst22/Small_Helices | /tinker/small_helix_EXE/paper_figs/plot_hist.py | UTF-8 | 1,331 | 2.546875 | 3 | [] | no_license | ##Need to change if:
## naming convention changes
## sampling windows change
import numpy as np
import matplotlib.pyplot as plt
import os.path
from matplotlib import rc_file
molecule='Ac-AAEAAAAXAAAAEAAY-NH2'
mutant = molecule[5] + molecule[10] + molecule[15]
data = np.genfromtxt('../wham/EXE.output.count')... | true |
d3600385cb8cb26a76e89acb357e608a9534771e | Aasthaengg/IBMdataset | /Python_codes/p02239/s129507381.py | UTF-8 | 605 | 3.140625 | 3 | [] | no_license | import queue
from collections import namedtuple
T = namedtuple("T", "u d")
n = int(input())
path = dict()
ans = [-1] * (n + 1)
for i in range(n):
a = [int(x) for x in input().split()]
a.reverse()
u, k = a.pop(), a.pop()
path[u] = set()
for j in range(k):
path[u].add(a.pop())
def bfs(s):... | true |
97354d60addd3abd4ca329af22696e182150991c | ShawnDong98/Algorithm-Book | /leetcode/python/121.py | UTF-8 | 508 | 3.65625 | 4 | [] | no_license | from typing import List
class Solution:
"""
dp[i] 表示前 i 天的最大利润,因为我们始终要使利润最大化,则:
dp[i] = max(dp[i-1], prices[i]-minprice)
"""
def maxProfit(self, prices: List[int]) -> int:
n = len(prices)
if n == 0: return 0
dp = [0] * n
minprice = prices[0]
for i in r... | true |
4efd776811d0d9d29460238f067eb1f4c1986917 | a8ksh4/junk | /Python/examples/EXAMPLES/generator_function.py | UTF-8 | 381 | 3.5 | 4 | [] | no_license | #!/usr/bin/env python
def main():
mary = trimmed('../DATA/mary.txt')
for line in mary:
print line # \n is already trimmed, so no double-spacing
def trimmed(file_name):
'''Generator that yields lines trimmed of the trailing \n '''
with open(file_name) as FILE:
for line in FILE:
... | true |
41bf163df6954218cad3fffa080cc9e35fd9b50c | jakubbujny/smoggler | /lib/sensor.py | UTF-8 | 5,041 | 2.5625 | 3 | [
"MIT"
] | permissive | import datetime
import json
import logging
import queue
import random
import threading
import time
from abc import ABC, abstractmethod
from lib.logger import logger
from lib.sds011 import SDS011
class Measurement:
def toJSON(self):
return json.dumps(self, default=lambda o: o.__dict__,
... | true |
93bcfc3d6564f5c6a8fc1cf90a69e3a633c6ba6d | DenisMalofeyev/p2p-chat | /db.py | UTF-8 | 1,663 | 2.78125 | 3 | [
"MIT"
] | permissive | from pymongo import MongoClient
# Includes database operations
class DB:
# db initializations
def __init__(self):
self.client = MongoClient('mongodb://localhost:27017/')
self.db = self.client['p2p-chat']
# checks if an account with the username exists
def is_account_exist(self, user... | true |
b4f56e4bdcf19c9ebb95d40dba4c981f4832589c | Hrishikesh-3459/leetCode | /prob_238.py | UTF-8 | 462 | 2.640625 | 3 | [] | no_license | import math
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
l = [0] * len(nums)
r = [0] * len(nums)
l[0] = 1
r[-1] = 1
ans = [0] * len(nums)
for i in range(1, len(nums)):
l[i] = nums[i-1] * l[i-1]
for i in reversed(range(... | true |
a425f7955d73d302b96311c156eaf0c1dd07f534 | runnerxin/MVMN | /model.py | UTF-8 | 13,505 | 2.53125 | 3 | [] | no_license | # =============================================
# @File : base_matrix.py
# @Software : PyCharm
# @Time : 2019/7/1 21:13
# =============================================
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import math
import pickle
import torch
from torch import nn
from... | true |
8ac94485d6b9d8dc270dcce3e6aaa9ff8aeaba43 | KATO-Hiro/AtCoder | /ABC/abc151-abc200/abc187/d/main.py | UTF-8 | 420 | 3 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # -*- coding: utf-8 -*-
def main():
import sys
input = sys.stdin.readline
n = int(input())
diff = 0
ab = list()
for i in range(n):
ai, bi = map(int, input().split())
ab.append(2 * ai + bi)
diff -= ai
ab = sorted(ab, reverse=True)
ans = 0
while diff <= ... | true |
af9ed73cfa26005d4c04fc1ae12af100507c7608 | QiliangFan/pyemail | /main.py | UTF-8 | 718 | 2.625 | 3 | [] | no_license |
from imap_tools import MailBox
import os
import re
student_id = ""
email_auth = ""
def remove_char(name: str):
return re.sub(r"[,。()/: !]", "_", name)
with MailBox('imap.mail.nankai.edu.cn').login(f'{student_id}@mail.nankai.edu.cn', f'{email_auth}', 'INBOX') as mailbox:
for message in mailbox.fetch(charset=... | true |