blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
ad6f9f99e1fa329d1790ea6273ad69882829be46 | Python | areamluersen/simulacao-discreta | /src/lavacar/numeros_aleatorios/main.py | UTF-8 | 1,111 | 2.640625 | 3 | [] | no_license | from entrada import selecaoMetodoDoUsuario, selecaoDeValoresDoUsuario, converteValoresDeEntrada, \
converteSelecaoMetodoDoUsuario, selecaoDeQuantidade, converteSelecaoDeQuantidade
from numeros_randomicos import gerarNumerosRandomicos
if __name__ == '__main__':
metodoDeEntrada = selecaoMetodoDoUsuario()
met... | true |
22e8ff0aa1bf7aafa8e2d863aad24c7ef874d16e | Python | ikale1234/42Work | /pygame1/Game/game1a.py | UTF-8 | 6,328 | 2.8125 | 3 | [] | no_license | import pygame
import random
pygame.init()
clock = pygame.time.Clock()
win = pygame.display.set_mode((500,480))
pygame.display.set_caption("jump")
walkRight = [pygame.image.load('R1.png'), pygame.image.load('R2.png'), pygame.image.load('R3.png'), pygame.image.load('R4.png'), pygame.image.load('R5.png'), pygame.image.loa... | true |
2524f5ce0dd56ffe5b0140a187166e485a22e6dd | Python | mishrakeshav/Competitive-Programming | /Code Forces/Problem Set/B/keyboard.py | UTF-8 | 1,060 | 2.921875 | 3 | [
"MIT"
] | permissive |
if __name__ == '__main__':
n, m, x = map(int, input().split())
keyboard = []
for i in range(n):
keyboard.append(input())
q = int(input())
text = input()
shift_keys = []
cost = dict()
for i in range(n):
for j in range(m):
if keyboard[i][j] == 'S':
... | true |
711e8b0de95dba6c5c0e33f2f2d5c0eac7af8b88 | Python | suvam1997/I-stand-with-you-using-Emojis-to-study-Solidarity-in-Crisis-Events | /Project/sentimentAnalysis.py | UTF-8 | 17,840 | 2.765625 | 3 | [] | no_license |
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
#time for execution
import timeit
start_time = timeit.default_timer()
from nltk.corpus import sentiwordnet as swn
import random
from sklearn import svm
import nltk
import re
from emoji import UNICODE_EMOJI
from nltk.stem.snowball import SnowballStemmer
import o... | true |
71884c9fc4ee836af4589d5cfe6e87777cfe9321 | Python | sranyjstrannik/codeforces | /codeforces386/A.py | UTF-8 | 140 | 3.421875 | 3 | [] | no_license | a = int(input())
b = int(input())
c = int(input())
for i in range(a,-1,-1):
if 2*i <= b and 4*i <= c:
print(7*i)
break
| true |
dedb56d6b874283066589a5e8468a845df49d165 | Python | Bubbleskye/2019summer | /leetcode/删除回文子数组.py | UTF-8 | 1,097 | 3.171875 | 3 | [] | no_license | def minimumMoves(arr):
# 回文子数组即是连续的一段
# dp[i][j]删除arr[i:j+1]这一段所需要进行的操作次数
# if arr[i]==arr[j]: dp[i][j]=dp[i+1][j-1]
# 如果头尾相同的话,这两个字符不用单独算一次删除,这两个字符只要跟着中间的随便哪个组合一起删掉就可以
# else: dp[i][j]=min(dp[i][k]+dp[k+1][j])
# 如果头尾不相同的话,分两段逐个找最小
dp = [[float("inf") for _ in range(len(arr))] for _ in range... | true |
a7db77bcfcd1270d7fab048d9d860c1a7fef594f | Python | abir-taheer/speed-a-la-mode | /methods/v1_abir.py | UTF-8 | 1,549 | 4.53125 | 5 | [] | no_license | def mode(nums: list) -> list:
"""
Return the most occurring item in a list
:param nums: A numerical list
:return: The item that appears the most in the list
>>> list_mode([1, 2, 3, 1])
[1]
>>> list_mode([-1, -4, 9, 2, -4, 9, -4])
[-4]
>>> list_mode(["hello", 0, 2, 3, 2... | true |
b1785e22fea9c3ed82b527d5b771a78b61583f5a | Python | Sohyo/IDS_2017 | /Assignment4/script_21.py | UTF-8 | 1,039 | 2.828125 | 3 | [] | no_license | import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
path = "/Users/danielmlow/Dropbox/lct/data_science/assignment4/lastfm-dataset-1K/"
df = pd.read_csv(path+'last_fm_user_band.csv')
df = df.iloc[:,1:]
pd.set_option('display.float_format', lambda x: '%.4f' % x)
uniq = df.il... | true |
58ad8d3929ef9177a48681f21451f21bdc472dc4 | Python | ineedacookie/SimpleEncodingExercise | /EncodeDecode.py | UTF-8 | 6,225 | 2.859375 | 3 | [] | no_license | import numpy as np
import random
class OTPInvalidInputError(Exception):
def __init__(self, provided_obj):
super().__init__('OneTimePad require an array of ints. You provided {}: {}'.format(type(provided_obj), provided_obj))
plainTextMessage = "WE ARE DISCOVERED. FLEE AT ONCE"
compositeKey = "1422555515"... | true |
7added06b54850be5f57ac7af8fb8ce1eb6ab37c | Python | baobaobaobaobao/mypaper | /jarden_center/main_code/divid/NET.py | UTF-8 | 6,551 | 2.90625 | 3 | [] | no_license | import networkx as nx
import random
from Girvan_Newman import GN #引用模块中的函数
#读取文件中边关系,然后成为一个成熟的图
def ContractDict(dir,G):
with open(dir, 'r') as f:
for line in f:
line1=line.strip().split(",")
# print (line1)
G.add_edge(int(float(line1[0])),int(float(line1[1])))
# p... | true |
44d890b71390252fe0e11576770615005d0d2de9 | Python | atjones90/Jones_DSC510 | /IMHOF_DSC510/hello.py | UTF-8 | 570 | 3.953125 | 4 | [] | no_license | # Taylor Imhof
# Bellevue University | DSC 510
# Date Created: 6.7.2021
# Last Update: 6.10.2021
# Change Log:
# 6.8.2021 -- Added functionality to accept user's name from console and display short greeting
# 6.10.2021 -- Updated documentation to reflect changes
# hello.py
# this program first displays the ... | true |
02dbe6225a2edac584e5c7eeefe1aa3f12417a08 | Python | gitter-badger/dbcollection | /dbcollection/tests/datasets/__test_check_urls.py | UTF-8 | 2,094 | 3.109375 | 3 | [
"MIT"
] | permissive | """
Test dataset's urls download status.
"""
import pytest
import signal
import requests
from dbcollection.core.api import fetch_list_datasets
TIMEOUT_SECONDS = 3
def get_list_urls_dataset():
available_datasets = fetch_list_datasets()
dataset_urls = []
for name in available_datasets:
url_list ... | true |
699c2b83108a072ac70fd68cc47e4bd4c036ecb5 | Python | ashwin21rao/Sudoku-Solver | /gui.py | UTF-8 | 7,157 | 2.984375 | 3 | [] | no_license | import pygame
import numpy as np
pygame.init()
clock = pygame.time.Clock()
font_large = pygame.font.Font("extras/OpenSans-Bold.ttf", 25)
font_small = pygame.font.Font("extras/OpenSans-Bold.ttf", 20)
screen_width = 600
screen_height = 600
side_length = 405
margin = (screen_width - side_length) / 2
screen = pygame.displ... | true |
62024bd9b021f59e359647ebfa0c29473d6d91c4 | Python | Gholtes/Keras-Deep-Dream | /deepDream.py | UTF-8 | 5,143 | 2.828125 | 3 | [
"MIT"
] | permissive | from keras.applications import VGG16
from keras.applications.vgg16 import preprocess_input
from keras.layers import Input
from keras import backend as K
import numpy as np
from PIL import Image
import scipy
'''
Deep dream application based on VGG16 classifier, pretrained on imagenet dataset
Written by Grant Holtes, De... | true |
b6f1a4c5d3d300a0f6d6417d9947deb08143de4a | Python | k0psutin/ohtu-2021 | /viikko3/nhl-reader/src/index.py | UTF-8 | 398 | 2.71875 | 3 | [] | no_license | from player_stats import PlayerStats
from player_reader import PlayerReader
def main():
url = "https://nhlstatisticsforohtu.herokuapp.com/players"
reader = PlayerReader(url)
stats = PlayerStats(reader)
players = stats.top_scorer_by_nationality("FIN")
print("Suomalaiset pelaajat:")
for pla... | true |
00bb349abfc734fc9123aeb4227f36c4dacae498 | Python | GreatStephen/MyLeetcodeSolutions | /Sum of Subarray Minimums/one stack.py | UTF-8 | 701 | 3.078125 | 3 | [] | no_license | class Solution:
def sumSubarrayMins(self, A: List[int]) -> int:
# 只需要一个Stack,就能找到左右山峰
# stack[i-1]是stac[i]左手边的第一个更小数字的下标
# 当前数字大于stack[-1],压栈。当前数字小于stack[-1],则左山峰下标是stack[-2],右山峰下标是当前i
deq = collections.deque()
A = [0] + A + [0]
ans, MOD = 0, 10**9+7
for i,n i... | true |
e7c23031085f797d07e7dcc623b1c56358d23f83 | Python | tkoz0/problems-online-judge | /vol_006/p621.py | UTF-8 | 248 | 3.125 | 3 | [] | no_license |
n = int(input())
for z in range(n):
e = input()
if e == '1' or e == '4' or e == '78': print('+')
elif e[-2:] == '35': print('-')
elif e[0] == '9' and e[-1] == '4': print('*')
elif e[:3] == '190': print('?')
else: assert 0
| true |
c3b7182962ceb666b76b404169f5186ec03b25f1 | Python | bholaa72429/Higher-Lower | /07_HL_statement_generator.py | UTF-8 | 725 | 3.953125 | 4 | [] | no_license | # HL component 7 - Statement Generator
def h1_statement(statement, char):
print()
print(char*len(statement))
print(statement)
print(char*len(statement))
print
# Main routine
too_low = h1_statement("^^ Too low, try a higher number. | "
"Guesses Left: 3 ^^", "^")
print()
too... | true |
26bcbca39eade156c22983821ee9dfdcba4d5022 | Python | HarryRicardo1989/airQuality | /carrega_display.py | UTF-8 | 1,032 | 2.828125 | 3 | [] | no_license | from lcd_12c import LCD
class CarregaDisplay:
def __init__(self, i2c_bus=0, address=0x00, mode=LCD.MODE4BITS, lines=LCD.LINES2, dots=LCD.DOTS5X8, numLinhas=2):
self.display = LCD(i2c_bus, address, mode, lines, dots, numLinhas)
def display_line_0(self, string):
self.display.writeLine(str(stri... | true |
1681f69dd865865f89235db74f1ae006457a75c9 | Python | FiddeEliasson/Pibot-helpfulai | /exts/ArkhamPlayer.py | UTF-8 | 17,270 | 2.671875 | 3 | [] | no_license | # ArkhamPlayer extension for Discord
### PREAMBLE ##################################################################
import copy
import re
import discord
import requests
import random
from discord.ext import commands
from unidecode import unidecode
class ArkhamPlayer(commands.Cog):
"""Arkham Horror Pl... | true |
d65f9d0e0acf04c4c94a890d6bb9d7017c2f2bf5 | Python | Vluuks/AdventOfCode19 | /day2.py | UTF-8 | 2,307 | 3.75 | 4 | [] | no_license | from copy import deepcopy
def parse_intlist(ints):
i = 0
# iter over in steps of 4
while True:
opcode = ints[i]
if opcode == 99:
print("termination 99")
break
print('opcode ' + str(opcode))
val1 = ints[ints[i+1]]
val2 = ints[ints[i+2]]
print(val1, val2)
print("ind... | true |
2dd1dcfd5f616f702edc430220567553906d92f6 | Python | yzw0917/mypython3 | /bs4_理解/lianxi01.py | UTF-8 | 735 | 3.046875 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
# 配置请求头
headers={
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
}
# 网站诗词内容下载
url='http://www.shicimingju.com/book/hongloumeng/54.html'
#获取标题正文页数据
gethtml = requests.... | true |
a39e476077d37813e2ce0bceb8e50447982c1d0e | Python | prabhupanda/LeapFinance-Internship-Tasks | /collegedunia_script.py | UTF-8 | 4,864 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 12 12:56:01 2021
@author: prabh
Script to Scape collegedunia.com US college-wise data
"""
import numpy as np
import pandas as pd
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#get list of all college names
df=pd... | true |
8129a644b468e92088c0997202840979dc2ee42a | Python | AnesuChinoda/rosebotics2 | /src/capstone_2_runs_on_robot.py | UTF-8 | 1,326 | 3.265625 | 3 | [] | no_license | """
Mini-application: Buttons on a Tkinter GUI tell the robot to:
- Go forward at the speed given in an entry box.
Also: responds to Beacon button-presses by beeping, speaking.
This module runs on the ROBOT.
It uses MQTT to RECEIVE information from a program running on the LAPTOP.
Authors: David Mutchler, his co... | true |
935788c507724d8e14f6bf2e24b70cff741f8ffe | Python | GustavHenning/DeepLearning18 | /lab4/inits.py | UTF-8 | 397 | 2.84375 | 3 | [
"MIT"
] | permissive | import sys
import numpy as np
class Initializer:
def from_shape(self, shape):
print("Initializer is an interface.")
sys.exit(1)
pass
class Zeros(Initializer):
def from_shape(self, shape):
return np.zeros(shape, dtype=float)
class Xavier(Initializer):
def from_shape(self, ... | true |
b8a9a5243fb19d0e1dc51a918a1e828733ec36b8 | Python | rgliuca/OpenCV | /opencv_hello_world.py | UTF-8 | 411 | 2.75 | 3 | [] | no_license | import cv2
image = cv2.imread("images\\trex.png")
print("width: %d pixels" % image.shape[1])
print("height: %d pixels" % image.shape[0])
print("channels: %d" % image.shape[2])
cv2.imshow("Trex Image", image)
for r in range(image.shape[0]):
image[r,150]=(0,0,0)
cv2.imshow("Trex with line image", image)
... | true |
327a8e70819e2acfa73b2a715c7540de3eecc70d | Python | flareno/ExtraPy | /Scalogram.py | UTF-8 | 5,118 | 2.625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 22 10:04:18 2019
@author: Sam Garcia (adapted by Federica Lareno Faccini)
"""
import numpy as np
import scipy.signal
from scipy import fftpack
def generate_wavelet_fourier(len_wavelet, f_start, f_stop, delta_freq,
sampling_rate, f0, normalisatio... | true |
782a51ea78bf90a34ea65197f0e740ae05ee650c | Python | memuunkie/HBProject_research_library_app | /seed.py | UTF-8 | 2,265 | 2.8125 | 3 | [] | no_license | from sqlalchemy import func
from model import Book, User, TypeUser
from model import connect_to_db, db
from server import app
from datetime import datetime
from csv import reader
from datetime import datetime
import json
def load_books():
"""Create library of books"""
Book.query.delete()
seed_data = re... | true |
1b43b7b31506323bbda99e3dd17f4de628e39305 | Python | ishwarjindal/Think-Python | /FuncAsArg.py | UTF-8 | 245 | 2.765625 | 3 | [] | no_license | # script to test passing function as argument
def print_spam(arg1):
print(arg1)
def do_twice(f, arg1):
f(arg1)
f(arg1)
def do_four(f, arg1):
do_twice(f, arg1)
do_twice(f, arg1)
do_four(print_spam,"Py for Python")
| true |
0232d45c10ac50d974432e0ed64b50d53ea8ca79 | Python | santhosh-duraipandiyan/corona-hotel | /view.py | UTF-8 | 496 | 3.15625 | 3 | [] | no_license | import json
from pprint import pprint
def viewData():
data = json.load(open('data.json'))
print("##########################################")
for item in data:
if data[item]["name"] == "dummy":
return
print("\nName: ",data[item]["name"])
print("Email: ",data[item]["email"])
print("Address: "... | true |
e16cda56f96e2edca51b53f27a073747622ee628 | Python | alexamar0714/Proglab-6 | /bbcon2.py | UTF-8 | 3,565 | 2.5625 | 3 | [] | no_license | import time
class BBCON():
behaviours = []
active_behaviours = []
sensobs = []
motobs = []
arbitrator = None
def __init__(self):
pass
def set_arb(self,arb):
self.arbitrator = arb
def add_behaviour(self, behaviour):
self.behaviours.a... | true |
5302e76b90629c30d3ec355d8f91aba9d32d13ec | Python | jleakakos-cyrus/euler | /python/problem15.py | UTF-8 | 369 | 4.125 | 4 | [] | no_license | # Problem 15
# How many routes are there through a 20x20 grid?
def factorial(number):
mult = 1
for x in range(1, number + 1):
mult *= x
return mult
def binomialCoefficient(m, n):
return factorial(m)/(factorial(n) * factorial(m - n))
def problem15(x, y):
return binomialCoefficient(x + y, y)
if ... | true |
2c075a7369d8d30392abcbf09c3ca4022a4c20c1 | Python | joeryan/100pythondays2019 | /004/program.py | UTF-8 | 1,332 | 4.125 | 4 | [
"MIT"
] | permissive | import characters
import random
def print_header():
print("---------------------")
print(" Wizard game")
print("---------------------\n")
def game_loop():
creatures = [
characters.Creature('bat', 1, 2),
characters.Creature('tiger', 4, 6),
characters.Creature('beholder', 12, 8),
characte... | true |
26624611c183882e819f2aa972a7ab49d852638f | Python | NUSTARS/2020-Data-Comm | /React-App/api/parsePacket.py | UTF-8 | 2,739 | 2.90625 | 3 | [] | no_license | from struct import unpack, Struct
from struct import error as structerror
# import struct
from binascii import crc32
import time
import datetime
# import sys
"""
PACKET FORMAT
Byte #
1: Protocol version
2: Flags
3-4: Payload size
5-6: Sequence number
7-10: CRC-32 checksum
11-?: Variable length... | true |
ee2b2276c2d16558963277217aae3815b4c02f0c | Python | Hugo-Oh/study_DataStructure | /인프런/섹션 4/10. 역수열/AA2.py | UTF-8 | 294 | 2.96875 | 3 | [] | no_license | import sys
sys.stdin = open("input.txt", "rt")
N = int(input())
arr =list(map(int, input().split()))
tot = 0
for i in sorted(arr)[::-1]:
cnt = 0
for j in arr:
if j > i:
cnt += 1
elif j == i:
print(cnt, end = " ")
break
print(cnt) | true |
467f1d4ab50bcaa749573268603c50c16a31c6b2 | Python | johnmnemonik/aiorest-ws | /aiorest_ws/test/utils.py | UTF-8 | 4,260 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- coding: utf-8 -*-
"""
Django-like settings functions and classes, which help to modify basic
configuration on the fly, while tests performed.
"""
from functools import wraps
from unittest import TestCase
from aiorest_ws.conf import settings, UserSettingsHolder
__all__ = ('override_settings', )
class BaseConte... | true |
b72d46fce5466f7fe4f2355f85ccd6b04bc2e603 | Python | Aasthaengg/IBMdataset | /Python_codes/p02831/s339451730.py | UTF-8 | 827 | 2.796875 | 3 | [] | no_license | import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools
import heapq
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def int_inputs(num_of_input):
ins = ... | true |
46aa8d6935b9d5bb703827123d07a201e11d535b | Python | scout719/adventOfCode | /2022/adventOfCode_10.py | UTF-8 | 2,901 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# pylint: disable=import-error
# pylint: disable=unused-import
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import
# pylint: disable=wrong-import-position
# pylint: disable=consider-using-enumerate
import functools
import math
import os
from os.path import join
import sys
... | true |
e9e0f1bcf703ae5c4ff882814e677398c9b52b09 | Python | WenhaoChen0907/Python_Demo | /01_hellopython/hn_41_类方法.py | UTF-8 | 442 | 3.515625 | 4 | [] | no_license | class Tool(object):
# 定义类属性
count = 0
# 定义类方法
@classmethod
def show_tool_count(cls):
print("工具对象的个数是 %d" % cls.count)
def __init__(self, name):
# 这是实例属性
self.name = name
# 利用类属性记录创建了多少个实例
Tool.count += 1
futou = Tool("斧头")
dingpa = Tool("钉耙")
# 调用类... | true |
7932f004858dcc5e3d2122e8f387e6ff15bdedd6 | Python | jovalle/advent-of-code | /2019/day/2/program_alarm.py | UTF-8 | 1,547 | 3.09375 | 3 | [] | no_license | # Day 2: 1202 Program Alarm
# https://adventofcode.com/2019/day/2
import os
import sys
def execute_intcode(intcode_set):
"""Run through sequence of opcodes and parameters as per Intcode program specs"""
position = 0 # keep track of logical position
index = 0 # keep track of literal position
# it... | true |
3ba1c3b75d3b50c60a9002096aa008301e68686e | Python | myanhon/ISCRIPT | /src/Week_4/zomertijd.py | UTF-8 | 1,040 | 3.234375 | 3 | [] | no_license | import datetime
# Mike Yan
# s1098641
from datetime import date, timedelta
def klok(datum):
dag = datetime.datetime.strptime(datum, '%d/%m/%Y')
dag = datetime.datetime.date(dag)
jaar = dag.year
if dag == zomerTijd(jaar):
return "omschakeling van wintertijd naar zomertijd"
if dag == winter... | true |
7cd945c5094cbf00185d7691bb875c632fff0806 | Python | VinFigSan/tccOpenCV | /main.py | UTF-8 | 2,691 | 2.765625 | 3 | [] | no_license | import cv2
import numpy as np
face_cascade = cv2.CascadeClassifier('classifier/haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('classifier/haarcascade_eye.xml')
cap = cv2.VideoCapture(0)
while True:
_, frame = cap.read()
gray_face = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
face_fr... | true |
e4d709f14cbd28e73e5c87e21d4503311475b8e0 | Python | GustavTheUseless/Iris-Flask-App | /Iris-Flask-App/app/app.py | UTF-8 | 984 | 2.875 | 3 | [
"MIT"
] | permissive | import numpy as np
from flask import Flask, request, render_template, redirect
import pickle
# define Flask app
app = Flask(__name__)
# load machine learning model
model = pickle.load(open("../iris-model.pkl", "rb"))
# define initial route and returns the index.html page
# aswell as sets the parameter 'flower_name' eq... | true |
e5aa9676edb9fb843c1c9b296c3734970eb4d0ca | Python | 0RootLoL0/DownloadYandexMusic | /venv/lib/python3.7/site-packages/yandex_music/supplement/video_supplement.py | UTF-8 | 3,793 | 2.8125 | 3 | [] | no_license | from typing import TYPE_CHECKING, Optional, List
from yandex_music import YandexMusicObject
if TYPE_CHECKING:
from yandex_music import Client
class VideoSupplement(YandexMusicObject):
"""Класс, представляющий видеоклипы.
Attributes:
cover (:obj:`str`): URL на обложку видео.
title (:obj:... | true |
831a3b13362c6dcd0ad86f25aa03cb49809e688f | Python | eth-csem/data | /Codes/plot_rays.py | UTF-8 | 5,341 | 2.703125 | 3 | [] | no_license | import glob
import time
import yaml
import numpy as np
import matplotlib.pyplot as plt
import auxiliary as aux
import cartopy.crs as ccrs
import cartopy.feature as cfeature
plt.rcParams["font.family"] = "serif"
plt.rcParams.update({'font.size': 70})
plt.subplots(1, figsize=(25,12))
start=time.time()
#===============... | true |
7c0537d09d097400b5ee47f2d1eff59eb1b8ff84 | Python | wbeyda/python-interview-questions | /CodeSignal/Daily Challenges/sameElementsNaive.py | UTF-8 | 414 | 4.125 | 4 | [
"MIT"
] | permissive | '''
Find the number of elements that are contained in both of the given arrays.
Example
For a = [1, 2, 3] and b = [3, 4, 5], the output should be
sameElementsNaive(a, b) = 1.
'''
def sameElementsNaive(a, b):
c = 0
for i in a:
if i in b:
c += 1
return c
if __name__ == "main":
a = [1... | true |
11e65ac5d67d9c9a902dafd2e6e44a580d6c0ca6 | Python | qwe764840446/py-L | /_text_file/Done/10_1.2.py | UTF-8 | 1,207 | 3.640625 | 4 | [] | no_license | # -*- coding:utf-8 -*-
"""
@author: jim
"""
import os
#编写代码将当前工作目录修改为“C:\”并验证,最后将当前工作目录恢复为原来的目录
'''保存当前工作路径'''
oldpwd=os.getcwd()
'''修改成c盘'''
os.chdir('C:\\')
print('前工作路径',os.getcwd())
'''恢复原来路径'''
os.chdir(oldpwd)
print('前工作路径',os.getcwd(),'\n\n\n**************************')
#编写程序,用户输入一个目录和一个文件名,搜索该目录机器子目录中... | true |
7678e4390ad6385c34aefa8b82c223de1ec321a4 | Python | Ramen-Shaman/Reco-PC-Server | /venv/Lib/site-packages/mss/tests/test_cls_image.py | UTF-8 | 487 | 2.9375 | 3 | [
"MIT"
] | permissive | """
This is part of the MSS Python's module.
Source: https://github.com/BoboTiG/python-mss
"""
class SimpleScreenShot:
def __init__(self, data, monitor, **kwargs):
self.raw = bytes(data)
self.monitor = monitor
def test_custom_cls_image(sct):
sct.cls_image = SimpleScreenShot
mon1 = sct.mo... | true |
f9f4117e0c29324343d1500c6e1c41dad746e71a | Python | Esaych/neopixel-server | /server.py | UTF-8 | 3,927 | 2.703125 | 3 | [] | no_license | from flask import Flask
from threading import Thread
import queue
import control, weather, logging
# import time
# from timeloop import Timeloop
# from datetime import timedelta
# tl = Timeloop()
app = Flask(__name__)
run_weather = False
weather_thread = None
run_music = False
music_thread = None
@app.route('/rgb/<r... | true |
d2d31a6af97b990086adb0810b4d98fde2f809b5 | Python | JosiahMg/leetcode | /python/278. First Bad Version.py | UTF-8 | 1,980 | 4 | 4 | [] | no_license | """
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have n versions [1, 2, ..., n] an... | true |
b65a4b620f8205eb275331a261fcbfb06ab5cda7 | Python | iyuanfang0105/mistywind_ml | /ImageStyle/feedward/utils.py | UTF-8 | 2,363 | 2.640625 | 3 | [] | no_license | import os
import sys
import numpy as np
import cv2
import errno
import functools
import tensorflow as tf
def check_image(img, path):
if img is None:
raise OSError(errno.ENOENT, "No such file", path)
def preprocess(img):
imgpre = np.copy(img)
# bgr to rgb
imgpre = imgpre[..., ::-1]
# shap... | true |
c6883622b8eab7b5b28e0941d13ca2ea6e2a1b90 | Python | zhr1201/Algorithms | /Knapsack/Knapsack/Knapsack/knapsack.py | UTF-8 | 804 | 3.046875 | 3 | [] | no_license | import sys
sys.setrecursionlimit(2 ** 20)
value = []
weight = []
C = {}
def compute_C(i, x):
key = str(i) + ',' + str(x)
if(i == 0):
return 0
if(key in C):
return C[key]
else:
if(x < weight[i - 1]):
C[key] = compute_C(i - 1, x)
return C... | true |
9d5857c80eaff3587414cb735ddf6d3f8dba33ac | Python | tv5am/Naive-Bayes-Classifier | /NBAdaBoost.py | UTF-8 | 18,793 | 2.515625 | 3 | [] | no_license | import sys
import time
import random
import math
#print 'Number of arguments:', len(sys.argv), 'arguments.'
#print 'Argument List:', str(sys.argv)
train_file = sys.argv[1]
test_file = sys.argv[2]
# print("train_file = " + train_file)
# print("test_file = " + test_file)
#test_file = "dataset/poker.test"
#train_file =... | true |
bf9c8bb223f852852efbdd2ea6b3161ed4e60fb5 | Python | Josh-Park/hacking_ciphers | /detect_english/detect_english.py | UTF-8 | 2,396 | 4.0625 | 4 | [] | no_license | """
Importing and using module:
import detect_english
detect_english.is_english(string) #Returns True or False
Note: There must be a 'words_dictionary.json' file in the root directory with one word on each line
This can be downloaded from https://github.com/dwyl/english-words
"""
import json
import time
time_start ... | true |
784b64906b603d12322c3ed4571d350ee4f3182c | Python | awheels/pycharm-edu-topic1 | /lesson2/task3/tests.py | UTF-8 | 504 | 2.953125 | 3 | [] | no_license | from test_helper import run_common_tests, failed, passed, get_file_output
if __name__ == '__main__':
run_common_tests()
answer1 = 'I am 5\'10" tall'
answer2 = 'Mr. Wheeler\t5\'10"'
answer3 = 'Greg Smith\t6\'2"'
answer4 = 'Emily Irk\t5\'5"'
print(get_file_output())
if (get_file_output() == ... | true |
22e34f1cd1a31cc12edceaf98bd7d5d16ee51db1 | Python | hayden-blair/squares | /group_no_overlap.py | UTF-8 | 2,281 | 2.71875 | 3 | [] | no_license | import pandas as pd
import numpy as np
def group_no_overlap(square, DEV_MODE=False):
num_in_group = pd.DataFrame()
#square_num = int(np.sqrt(len(square)))
square_num = int(np.sqrt(len(square)))
#square['numbers'] = np.arange(int(square_num**2))
num_in_group['num'] = np.zeros(len(square)... | true |
0c3ef0be8001eda616a967e523261df0637402ad | Python | john-marinton/Python_automation | /PDF-automate/combined_pdf.py | UTF-8 | 528 | 2.75 | 3 | [] | no_license | import PyPDF2
read1=open('meetingminutes1.pdf','rb')
read2=open('meetingminutes2.pdf','rb')
reader1=PyPDF2.PdfFileReader(read1)
reader2=PyPDF2.PdfFileReader(read2)
writer=PyPDF2.PdfFileWriter()
for file1 in range(reader1.numPages):
page=reader1.getPage(file1)
writer.addPage(page)
for file2... | true |
59268b7f0f8727719c94fe161a47eb7a209b7974 | Python | omni360/finite-elements | /poisson/2d/verify.py | UTF-8 | 2,166 | 2.90625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | #!/usr/bin/env python
from scipy.sparse.linalg import spsolve
import pylab as plt
import numpy as np
import FEM, create_mesh, plot_mesh
import poisson_optimized as poisson
import time
def set_bc_nodes_square(pts):
"""Sets up B.C. nodes in the [-1,1]x[-1,1] square case."""
n_nodes = pts.shape[0]
bc_nodes =... | true |
f8ee280c0a037177511782d8392b7f1a0f3d3fd4 | Python | vaceslav/cuda | /statistics.py | UTF-8 | 191 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
import pandas as pd
df = pd.read_csv("./statistics.txt", sep="|")
size = df["total_data_file_size"].sum() / 1024.0 / 1024 / 1024.0
print(f"Total size: {size} GB")
| true |
85599d56db41e16e0c02898f3423f86f0388343b | Python | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_4_neat/16_0_4_mattiaf_d.py | UTF-8 | 279 | 3 | 3 | [] | no_license | def solve(k, c, s):
if k == 1:
return 1
if c == 1:
if s < k:
return "IMPOSSIBLE"
return ' '.join([str(i) for i in range(1, k+1)])
t = int(input())
for cc in range(t):
k, c, s = [int(x) for x in input().split()]
print("Case #{}: {}".format(cc+1, solve(k, c, s)))
| true |
2ce6523c0946a4e0a14a3dc5cfa63b4afdad5dc5 | Python | yuwendong/user_portrait | /user_portrait/group/mid2weibolink.py | UTF-8 | 727 | 3.046875 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
import os
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
def base62_encode(num, alphabet=ALPHABET):
if (num == 0):
return alphabet[0]
arr = []
base = len(alphabet)
while num:
rem = num % base
num = num // base
arr.ap... | true |
daf4438f42104229bb754f6232ec11f9f27526a2 | Python | bshwave/se-challenge | /expenses/tests/unit/expenses/test_helpers.py | UTF-8 | 1,554 | 2.796875 | 3 | [] | no_license | from __future__ import absolute_import, unicode_literals
from StringIO import StringIO
from mock import Mock
from nose.tools import assert_raises
from expenses.expenses.helpers import (
BadCSVFile,
save_csv_file,
_make_expense_from_line
)
def test_save_csv_file():
mocked_db_session = Mock()
fil... | true |
ffd7f9598f63d44fc196c541a5d2f516533b9176 | Python | sujal100/IITH-BTECH-Courses | /6th-Sem/CS5500 Reinforcement Learning/RL assignment 2/tictactoe.py | UTF-8 | 10,133 | 3 | 3 | [] | no_license | import copy
import numpy as np
import pickle
import sys
import tkinter as tk
class Player(object):
def __init__(self, mark):
self.mark = mark
def opponent_mark(self):
if self.mark == 'X':
return 'O'
else:
return 'X'
class HumanPlayer(Player):
pa... | true |
6fee62ab215d954f3b55571f41e4ef6d5502cec7 | Python | kanbaochun/Python | /TensorFlow/tf-3/backword.py | UTF-8 | 1,745 | 2.59375 | 3 | [] | no_license | import tensorflow as tf
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
import numpy as np
import generateds
import forward
import matplotlib.pyplot as plt
STEPS = 40000
BATCH_SIZE = 30
LEARNING_RATE_BASE = 0.001
LEARNING_RATE_DECAY = 0.999
REGULARIZER = 0.01
def backward():
#训练集占位
x = tf.placeholder(tf.float32... | true |
f7bb3daa125b8991f9d448ae24f721705775d6bc | Python | rhgrant10/ProjectEuler | /problem_015.py | UTF-8 | 472 | 3.703125 | 4 | [] | no_license | """Problem 15
Lattice paths
=============
Starting in the top left corner of a 2×2 grid, and only being able to move to
the right and down, there are exactly 6 routes to the bottom right corner.
rrdd
rdrd
rddr
drrd
drdr
ddrr
How many such routes are there through a 20×20 grid?
"""
from math... | true |
e0f5200406b5640e4e42ed4103614d2b3c9e3a94 | Python | mangostory85/MangoServer | /st01.Python기초/py02프로그래밍기초/py11문자열/py11_03.문자열은수정불가.py | UTF-8 | 313 | 3.390625 | 3 | [] | no_license | # 문자열은 수정할 수 없다.
# 새롭게 메모리가 할당된다는 의미
str1 = "abc"
print("str1 주소값 출력", id(str1))
print()
str2 = str1
print("str2 주소값 출력", id(str2))
print()
str1 = "efg"
print("str1 주소값 출력", id(str1))
print("str2 주소값 출력", id(str2))
print() | true |
caffec3329bab34101161ce058abb9d46a7db716 | Python | bitounu/Nauka-Pythona | /przyklady/przyklady/listing_11-2.py | WINDOWS-1250 | 458 | 3.234375 | 3 | [
"Unlicense"
] | permissive | # Listing_11-2.py
# Copyright Warren & Carter Sande, 2013
# Released under MIT license http://www.opensource.org/licenses/mit-license.php
# Version $version ----------------------------
# Zmienna ptla zagniedona
ileLinii = int(raw_input ('W ilu liniach maj by wywietlone gwiazdki? '))
ileGwiazdek = int(raw_input ('... | true |
81d2d1db6268b19b920e9222c1fe90888158899c | Python | theodao/nanodegree-algorithm-datastructures | /Chapter3/problem_algorithm/math_sqrt.py | UTF-8 | 270 | 3.34375 | 3 | [] | no_license | def mySqrt(self, x):
start = 0
end = x
while start <= end:
mid = start + (end - start) / 2
if mid * mid <= x and x < (mid + 1) * (mid + 1):
return mid
if mid * mid > x:
end = mid
if mid * mid < x:
start = mid + 1 | true |
9a5b9db8171cf4e253ec2a3905783ab9cb44cfc4 | Python | jpverkamp/dotfiles | /bin/enumerate | UTF-8 | 120 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python3
import fileinput
for i, line in enumerate(fileinput.input(), 1):
print(i, line.rstrip('\n'))
| true |
7700ff929baa6fa8b5642c80f7bb447d86315545 | Python | wimbuhTri/Kelas-Python_TRE-2021 | /P3/soal3.py | UTF-8 | 135 | 3 | 3 | [] | no_license | angka = "123 4567 8982"
print(angka[0])
print(angka[-1])
print(angka[4:7])
print(angka)
print(angka[:4])
print([angka])
print(angka(0)) | true |
9eb259481d0003d7b9d9d15e498196ac996413ee | Python | nixonpjoshua/Math127 | /Project_1/NJ_test.py | UTF-8 | 461 | 3.03125 | 3 | [] | no_license | # Group 6: UPGMA Algorithm using Jukes Cantor Distance
# Authors: Josh Nixon
# Alex Pearson
# Bidit Acharya
# Tracy Lou
import numpy as np
from neighbor_joining import *
"""
Makes Q matrix that decides what will be joined
Args:
M: symetric matrix
Returns:
Q matrix
"""
a = np.array([[ 0... | true |
2e4ae175e408f062f823c93f25983d0cee10f263 | Python | HongsenHe/algo2018 | /1428_leftmost_column_with_at_least_a_one.py | UTF-8 | 1,437 | 3.640625 | 4 | [] | no_license | # """
# This is BinaryMatrix's API interface.
# You should not implement it, or speculate about its implementation
# """
#class BinaryMatrix(object):
# def get(self, row: int, col: int) -> int:
# def dimensions(self) -> list[]:
class Solution:
def leftMostColumnWithOne(self, binaryMatrix: 'BinaryMatrix') -> ... | true |
034a9cd31370c5a6438b2cd749316c9cf00e8624 | Python | koelling/limix | /python/demo/gp_regression_demo.py | UTF-8 | 2,895 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # Copyright(c) 2014, The LIMIX developers (Christoph Lippert, Paolo Francesco Casale, Oliver Stegle)
# All rights reserved.
#
# LIMIX is provided under a 2-clause BSD license.
# See license.txt for the complete license.
import sys
sys.path.append('./../../build_mac/src/interfaces/python')
import limix
import scipy as... | true |
4bb251b12f3c19292e966a0dcdd4a339be7e903f | Python | egushinnosuke/collatz-py | /collatz.py | UTF-8 | 535 | 4.15625 | 4 | [] | no_license | # coding:utf-8
def collatz(number):
if number % 2 == 0: #偶数の場合
return number / 2
else: #奇数の場合
return 3 * number + 1
print('整数を入力してください')
input_number = input()
while True:
try:
input_number = int(input_number)
if input_number == 1:
break
else:
input_number = collatz(input_nu... | true |
ba57bfc163deae6345540f976612f5ac8fc5e432 | Python | Nepherius/Mangopie | /core/aochat/extended_message.py | UTF-8 | 309 | 2.5625 | 3 | [] | no_license | class ExtendedMessage:
def __init__(self, category_id, instance_id, template, params):
self.category_id = category_id
self.instance_id = instance_id
self.template = template
self.params = params
def get_message(self):
return self.template % tuple(self.params)
| true |
0a11586a127f173bbb5eb22783695e5452c09872 | Python | i026e/python_ecg_graph | /tests/test_parameters.py | UTF-8 | 10,159 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 24 09:50:30 2016
@author: pavel
"""
import sys
sys.path.insert(0, '../')
import parameter_types
import unittest
class TestParameterManager(unittest.TestCase):
def test_pm(self):
pm = parameter_types.ParameterManager()
param1 = ... | true |
da803b958a4395bfde84bfa0414221455797a472 | Python | ramanmishra/Code-Chef-Solutions | /Beginner/Tanu_And_Head_Bob.py | UTF-8 | 211 | 3.359375 | 3 | [] | no_license | t = int(input())
for i in range(t):
length = input()
n = input()
if 'I' in n:
print("INDIAN")
elif n.count('N') == len(n):
print("NOT SURE")
else:
print("NOT INDIAN") | true |
f6008a41a4753d49f6de16d17b32cc854d93e151 | Python | ZJgithubZJ/Python | /monitor/监控报警/mail_accessory.py | UTF-8 | 1,316 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env python3
#!-*- encoding=utf-8 -*-
#Auther:ZJ
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
class Sendmail:
def __init__(self):
self.sender = 'zhangjian@xnhd.com'
self.receiver = 'zhangjian@xnhd.com'
#创建实例
self.... | true |
ff7bec80ee1800b4b366e78134dbb67b3fe2b0aa | Python | tnferreira/PID_Car | /.ipynb_checkpoints/test-checkpoint.py | UTF-8 | 598 | 2.890625 | 3 | [] | no_license | from datetime import datetime
from matplotlib import pyplot
from matplotlib.animation import FuncAnimation
from random import randrange
import time
x_data, y_data = [], []
pyplot.ion()
figure = pyplot.figure()
line, = pyplot.plot_date(x_data, y_data, '-')
def update(frame):
x_data.append(datetime.now())
y_dat... | true |
fcdb9b060f938ddb6d3336e9eca8d3d9760d5b51 | Python | nextdesusu/Learn-Python | /py_files/noizes/noizes.py | UTF-8 | 952 | 3.265625 | 3 | [] | no_license | import random
import math
mapsize = 5
def print_chart(*src):
print(src)
def noise(freq):
phase = random.uniform(0, 2*math.pi)
return [math.sin(2*math.pi * freq*x/mapsize + phase)
for x in range(mapsize)]
def weighted_sum(amplitudes, noises):
output = [0.0] * mapsize... | true |
89c02f0be58f787caaf2d693b0ccfdcbd5f168ef | Python | SwimmingLee/ProblemSolving | /(Pyton)ProblemSolving/ProblemSovling/그래프/다익스트라/[BOJ_20183]골목 대장 호석 - 효율성2.py | UTF-8 | 1,070 | 2.546875 | 3 | [] | no_license | import sys
import heapq
r = open("/mnt/c/Users/swimm/Desktop/test/large_16.in", mode='rt')
input = r.readline
N, M, start_city, end_city, wallet = list(map(int, input().split()))
edges = [[] for _ in range(N+1)]
for _ in range(M):
u, v, c = list(map(int, input().split()))
edges[u].append([v, c])
edges[v]... | true |
764677d3356fa854e876ed56c56ccd69c9ebe278 | Python | pritysonisingh/Tic-Tac-Toe | /Tic Tac Toe.py | UTF-8 | 3,945 | 4.46875 | 4 | [] | no_license | # TIC TAC TOE
import random
# Function to display the tic tac toe board
def display_board(board):
print(' | |')
print(board[7]+' | '+board[8]+' | '+board[9])
print(' | |')
print('---------------')
print(' | |')
print(board[4]+' | '+board[5]+' | '+board[6])
print(' | |')
pri... | true |
c05874d2b8251416daf568da28f49a8c9007da08 | Python | rajatg98/ChatVIT | /code/code_timetable_data.py | UTF-8 | 5,369 | 2.921875 | 3 | [] | no_license |
# Weekday abbreviations
WEEK=["MON","TUE","WED","THU","FRI","SAT","SUN"]
from dataload_init import *
import csv
import datetime
from collections import defaultdict as dd
abbr={
"nlp":"Natural Language Processing",
"biodb":"Biological Database","bio":"Biological Database","biology":"Biologica... | true |
39fb6bc60f0a6d7b7e2252688bec6e894640a7e2 | Python | codeAligned/codingChallenges | /codewars/cipher.py | UTF-8 | 589 | 3.5625 | 4 | [] | no_license | # Source: http://www.codewars.com/kata/546937989c0b6ab3c5000183/train/python
def encryptor(key, message):
def shift(c, key):
if c == c.upper():
return ((ord(c) + key - ord('A')) % 26) + ord('A')
elif c == c.lower():
return ((ord(c) + key - ord('a')) % 26) + ord('a')
resu... | true |
d63a3d8235069d2b6d528dbb2e5807082462aa80 | Python | darcatron/BottersOfTheGalaxy | /src/main.py | UTF-8 | 22,936 | 2.75 | 3 | [] | no_license | import random
import sys
import math
import copy
### CONSTANTS
INSULTS = ["come at me", "who's your daddy", "is this LoL", "cash me outside", "2 + 2 don't know what it is!", "yawn",
"dis some disrespect"]
# TODO: use this at the end (not sure how we know when the end is....maybe when tower or hero is at a l... | true |
ec855677f8be794168bce84d3cc9088c23463345 | Python | vrvelasco/Python-Programming | /[Week 16] December 2/multiplication.py | UTF-8 | 424 | 4.4375 | 4 | [] | no_license | # Victor Velasco (Multiplication) 12/2/19
def main():
num1 = 0
num2 = 0
while num1 <= 0:
num1 = int(input('Enter a positive number: '))
while num2 <= 0:
num2 = int(input('Enter another positive number: '))
print(num1, 'times', num2, 'is', multiply(num1, num2))
def multiply(x, y)... | true |
4473ff9cb5b16783c1cf4cb0e83235aa5a3223b1 | Python | lucienimmink/scanner.py | /scanner/_utils.py | UTF-8 | 1,322 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf8 -*-
class Time:
def ums(i, ignoreZero=True):
i = float(i)
hours = int(i / 3600)
rest = i % 3600
minutes = int(rest / 60)
seconds = int(rest % 60)
if hours < 10:
hours = "0" + str(hours)
if minutes < 10:
... | true |
b1ced03ce86e5f55a347a32f8dec4ae7524d86e4 | Python | jasonfigueroa/PythonSnippets | /strings/strings.py | UTF-8 | 1,579 | 4.75 | 5 | [] | no_license | # in this file I'll be practicing strings and a few basic ways to use or
# manipulate strings.
# string variable for our name, you can enclose the string with single quotes or
# double quotes, I'll use singles so I don't have to use the shift key
name = 'Jason'
# string variable for a number as a string, using double... | true |
f7d9e8097a55f82c7ce3e3cb52335a93e8a91d57 | Python | unsortedtosorted/DynamicProgramming | /Unbounded Knapsack/rodcutting.py | UTF-8 | 900 | 3.25 | 3 | [] | no_license | """
Given a rod of length ‘n’, we are asked to cut the rod and sell t
he pieces in a way that will maximize the profit.
We are also given the price of every piece of length ‘i’ where ‘1 <= i <= n’.
Example:
Lengths: [1, 2, 3, 4, 5]
Prices: [2, 6, 7, 10, 13]
Rod Length: 5
dp(i) = max (i+dp(l-i)) for i in range(0,n)
... | true |
b7ab9e6fdf234152418e22d69a72f9505c631a7b | Python | simonhoo/python-study | /s002/slicing.py | UTF-8 | 735 | 3.71875 | 4 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python
# -*- coding:utf-8 -*-
def t_slicing_str():
s = 'http://www.cottsoft.com'
print s[7:]
def t_slicing_arry():
ar = [1,2,3,4,5,6,7,8,9,0]
print ar[4:]
print ar[4:-2]
print ar[-2:]
print ar[:7]
def t_slicing_input():
s = raw_input("请输入字符串:")
n1 = input("请输入要截取的开始下标:"... | true |
6141ce19a90680508f097dff816cce12fc7cee90 | Python | cser2016/HttpUdp | /hello_server.py | UTF-8 | 416 | 3.046875 | 3 | [] | no_license | from flask import Flask, request
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def hello():
name = 'World'
if request.method == 'POST':
name = request.form.get('name', 'World')
return '''
<h1>Hello {name}!</h1>
<form method="post">
<input type="text" name="name">
<button type="subm... | true |
8f0fd363ddce4fd1d4779274a6fa64b5d3fb27dc | Python | pratikhrohane/IoT_NodeMCU | /lab_06.py | UTF-8 | 1,209 | 2.90625 | 3 | [] | no_license | """
Watching Start Wars Episodes on NodeMCU
>>Connect NodeMCU Internet
>>Download Asciimation
>>Display
NodeMCU connect to Internet
~ESP8266 WiFi based Chip with UART interfaace
~802.11b/g/n Protocal
~Integrated TCP/IP stact
~ON-chip SRAM
SSID -> Name for Wireless Network
IP -> Software level id for n... | true |
c88664c1ec85127719486e2ffe0e0c22f5068a60 | Python | zillow/ctds | /tests/test_cursor___iter__.py | UTF-8 | 2,858 | 2.53125 | 3 | [
"MIT"
] | permissive | import warnings
from .base import TestExternalDatabase
class TestCursorNext(TestExternalDatabase):
'''Unit tests related to the Cursor.__iter__() member.
'''
def test_next(self):
with self.connect() as connection:
with connection.cursor() as cursor:
cursor.execute(
... | true |
19a1242bfc081145b1698dba06cebb62df94e3d2 | Python | eduardoroboto/math-matrix | /main.py | UTF-8 | 1,464 | 2.953125 | 3 | [
"BSD-3-Clause"
] | permissive | from matrix import Matrix
# class test
if __name__ == '__main__':
#a = Matrix(4,4,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])
#a = Matrix(3,4,[-1,1,-2,-20,5,2,1,21,2,5,4,33])
#a = Matrix(2,5,[2,1,1,1,1,2,1,1,1,3])
#a = Matrix(3,4,[1,-1,2,2,2,1,-1,1,-2,-5,3,3])
# a = Matrix(2,2,[1,2,3,4])
#b = Ma... | true |
81f6c48e8ee21a4ad87dd0448399e29650ad582e | Python | rodrigoSolano/pokedex | /entities/pokemonTypes/GrassPokemon.py | UTF-8 | 765 | 2.75 | 3 | [] | no_license | from entities.DecoratorPokemon import DecoratorPokemon
from entities.pokemonTypes.config import type_strengths
from entities.pokemonTypes.config import type_weaknesses
class GrassPokemon(DecoratorPokemon):
strengths = type_strengths['grass']
weaknesses = type_weaknesses['grass']
typeName = "Grass"
... | true |
d085d10b2b3f3d3740b2d818e04d2550ba45f429 | Python | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_2/gosip/pancakes.py | UTF-8 | 423 | 3.21875 | 3 | [] | no_license | def main():
f = open("B-large.in", "r")
t = int(f.readline())
for i in range(t):
r = count(f.readline().strip())
print("Case #" + str(i+1) + ": " + str(r))
def count(arg):
cnt = 0
last = arg[0]
for c in arg:
if last == '-' and c == '+':
last = '+'
cnt += 1
elif last == '+' and c == '-':
last = '... | true |
0f70268fc15e4562a0a60af33534d0e7108cb8d5 | Python | AChen24562/Python-QCC | /Week-9-Functions/Part-2/hw2-test.py | UTF-8 | 256 | 3.734375 | 4 | [] | no_license | from random import randint
def isInRange(x):
return x in range(-100, 100)
def main():
for x in range(10):
n = randint(-500, 500)
if isInRange(n):
print(f"{n} ok")
else:
print(f"{n} no ")
main()
| true |
a39faa04f973de1335aa6f0c8e4a4d373da6614c | Python | a-jumani/coding-problems | /Binary Search/1/lowest_index.py | UTF-8 | 1,243 | 3.921875 | 4 | [
"MIT"
] | permissive | def lowest_index(arr, target):
""" Finds the lowest index of target in arr. If target in arr, returns lowest
index i such that arr[i] == target, else returns index i where it should be
inserted while keeping arr sorted.
Args:
arr array to search target in
target value
Returns:
... | true |
07d4d03be15891bbd1ce4e648dcbf4fd23b3cbc5 | Python | YolandePretorius/159372-Assignment-4 | /Assignment 4/aipython/cspExamples.py | UTF-8 | 7,731 | 3.359375 | 3 | [] | no_license | # cspExamples.py - Example CSPs
# AIFCA Python3 code Version 0.9.1 Documentation at http://aipython.org
# Artificial Intelligence: Foundations of Computational Agents
# http://artint.info
# Copyright David L Poole and Alan K Mackworth 2017-2020.
# This work is licensed under a Creative Commons
# Attribution-NonCommerc... | true |
d86539aa8d02235a4cec35ebd3238225e4a43a4e | Python | liliahache/kattis | /calculatingdartscores.py | UTF-8 | 557 | 2.890625 | 3 | [] | no_license | import sys
from itertools import product, combinations_with_replacement, chain
n = int(next(sys.stdin))
c = list(product(range(1, 20+1),range(1, 3+1)))
scores = dict()
for p in list(combinations_with_replacement(c, 1)) + list(combinations_with_replacement(c, 2)) + list(combinations_with_replacement(c, 3)):
s = s... | true |