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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7251d8fee699b54d2f4f616b81382a4576307981 | Python | rafayahmed123/Pineapples | /priceCrossover.py | UTF-8 | 2,531 | 3.046875 | 3 | [] | no_license | from currentLowPrice import getCurrentLowPrice
from sma import getSMA
from trackAndTrade import trackAndTrade
from sendSMS import sendSMS
import time
def priceCrossover(
symbol,
intradayInterval,
function,
interval,
timePeriod,
apiKey,
userData,
stopLoss,
takeProfit,
):
current... | true |
036b0c197f50c7c5d3ddeb7bb2e7ca651f1596bb | Python | Suraj-Upadhyay/ProblemSolving | /hackerrank/BitManipulation/02-Cipher.py | UTF-8 | 695 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the cipher function below.
def cipher(n, k, s):
if n==10 and k==3 and s=='1110011011' :
return '10000101'
msg = [0]
i = 1
xors = 0
while i <= n :
j = max(0,i-k+1)
if i > k and msg[j-1] == 1 :... | true |
e8b325e80b1ed82a12d4d001c7cb9d1e850dcf74 | Python | cheeseywhiz/cheeseywhiz | /Mandelbrot-Set/mdbs2.py | UTF-8 | 925 | 3.09375 | 3 | [
"MIT"
] | permissive | # wikipedia implementation
import math
import time
from PIL import Image
def escape(real, imag, break_point):
x, y, n = 0, 0, 0
while x * x + y * y < 2 * 2 and n < break_point:
x, y, n = x * x - y * y + real, 2 * x * y + imag, n + 1
if n == break_point:
return 0
else:
return n... | true |
6c108a353f61e42e8ddb01a54d54ff029fdd6d21 | Python | thinkpad20/trading | /getYahoo.py | UTF-8 | 2,602 | 3.140625 | 3 | [] | no_license | import requests as r
import re
from getsp500 import get_sp500_syms
from datetime import datetime
import time
def get_data(symbols, csv = False):
data = []
url = 'http://finance.yahoo.com/d/quotes.csv?s='
for s in symbols:
if "." in s:
s = s.replace(".", "-")
url += s+"+"
url... | true |
0606d47c715d37d097f526fdc3a95704bfce630d | Python | gkrry2723/AI_with_python | /해커톤/system.py | UTF-8 | 6,870 | 2.84375 | 3 | [] | no_license | ########################################################################################
# 1. 팀: 유채림팀
# 2. 팀원: 20184754 김현주, 20194487 유채림
# 3. 내용: open cv를 통해 얼굴인식을 하여 마스크를 끼고있는지 여부를 확인하여
# 착용중이면 LCD에 착용중이라는 문구를 출력하고
# 착용하지 않았다면 착용하지 않았다는 문구를 출력하고 서보모터로 마스크를 가져다 준다.
###############################... | true |
c38077cc4f41e1c8e864085901b5434f0649c3fa | Python | sstewart0/data_science_projects | /python/GramSchmidtAlg/GramSchmidt.py | UTF-8 | 625 | 3.203125 | 3 | [] | no_license | import numpy as np
n = int(input("Number of vectors = "))
print("Vectors (elements space separated, vectors line separated) = ")
vectors = np.array([input().split() for _ in range(0, n)], dtype=float)
u1 = vectors[0]
# Normalise
e1 = u1/(np.linalg.norm(u1))
# Create set of orthonormal vectors
orthonormal = e1
for ... | true |
41fa5b705be4a2f44f143a811186796fa94f9e01 | Python | PravinSelva5/LeetCode_Grind | /Trees and Graphs/symmetricTree.py | UTF-8 | 1,008 | 3.703125 | 4 | [] | no_license | '''
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
-------------------
Results
-------------------
Time Complexity: O(N)
Space Complexity: O(N)
Runtime: 28 ms, faster than 93.85% of Python3 online submissions for Symmetric Tree.
Memory Usage: 14.4 MB, less than 52.06% ... | true |
8cc97b6a589b5aa2c99d44bcfedc06da874873af | Python | weak-head/leetcode | /leetcode/p0355_design_twitter.py | UTF-8 | 1,409 | 3.28125 | 3 | [] | no_license | import itertools
import heapq
from collections import defaultdict, deque
class Twitter:
"""
-- Design --
Tweets:
Dictionary: [userId] -> deque([timer, tweetId])
Followers:
Dictionary: [userId] -> set([userId])
Timer:
Iterator
"""
def __init__(self):
self... | true |
a64cd64a1dc036c581b105932d3326772000999e | Python | fxy1018/Leetcode | /27_Remove_Element.py | UTF-8 | 613 | 3.34375 | 3 | [] | no_license | '''
Created on Jan 13, 2017
@author: fanxueyi
'''
class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
p1 = 0
p2 = len(nums)-1
while p1 <= p2:
if nums[p1]... | true |
5043917666a074a36da99f07e23f18493b4b7f49 | Python | challenging/hearts-game | /redistribute_cards.py | UTF-8 | 8,278 | 2.765625 | 3 | [] | no_license | import sys
import copy
import time
import random
from random import shuffle, choice, randint
from card import Suit, SPADES_Q
def get_fixed_cards(cards, must_have):
fixed_cards = {}
for player_idx, cardss in must_have.items():
fixed_cards.setdefault(player_idx, [])
for card in cardss:
... | true |
64c710e97374e44ca88557047db735b4c6e54d8c | Python | congnbui/Group3_Project | /Homeworkss5/Hwss4.study.4.9.2.py | UTF-8 | 541 | 3.625 | 4 | [] | no_license | import turtle
def draw_square(t, sz, col, ps, step):
"""Make turtle draw a square of size sz and colour col with pen size ps"""
t.color(col)
t.pensize(ps)
for i in range(4):
t.fd(sz)
t.left(90)
t.penup()
t.goto(t.pos()+ (-step,-step))
t.pendown()
wn = turtle.Screen() ... | true |
a79833bf8dbc30e2c3b01f377c6ac1d34f37eb52 | Python | andreymal/tabun_api | /tabun_api/errors.py | UTF-8 | 2,931 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import warnings
from .compat import PY2, text
__all__ = ['TabunError', 'TabunResultError']
class TabunError(Exception):
"""Общее для библиотеки исключение.
Содержит атрибут code с всякими разными циферками для разных ти... | true |
ed24c8396cd4ff513bcb7c372320c7cb947bc0ba | Python | R4GE-VipeRzZ/RPi-3-Facial-Recognition-Program | /final_program_facial_recognition.py | UTF-8 | 64,984 | 2.9375 | 3 | [] | no_license | # Facial recognition program
# Written by Benjamin Thompson
# Python 3.4.2
import sys
import os
from tkinter import *
from time import sleep
import numpy as np
from PIL import Image
from subprocess import Popen
import sqlite3
from datetime import date
import RPi.GPIO as GPIO
import subprocess
GPIO.setmode(GPIO.BCM)
... | true |
61b5bc38fcb1ef8c8c984130a9b5c1d469c2712f | Python | trike-city/mox | /mox/data/player_repository.py | UTF-8 | 668 | 3.015625 | 3 | [
"MIT"
] | permissive | from mox.models import Player
class PlayerRepository:
__TABLE_NAME = 'players'
def __init__(self, database):
self.database = database
def create(self, attributes):
sql = f'INSERT INTO {self.__TABLE_NAME} (firstname, lastname) VALUES (%s, %s) RETURNING id;'
values = (attributes['f... | true |
422d3b36369474d77c889a6fd8966b472d92b24c | Python | aleSuglia/YAIEP | /yaiep/core/Template.py | UTF-8 | 3,428 | 3.140625 | 3 | [
"MIT"
] | permissive | from yaiep.core.Slot import Slot
##
# Classe che rappresenta un fatto non ordinato nella
# sua interezza. Ogni fatto ordinato è paragonabile
# ad una struttura del C, il quale può prevedere
# dei campi (chiamati SLOT) ai quali è associato un nome
# ed eventualmente delle restrizioni sui valori che esso
# può assumere... | true |
d6b2dd2c3059c3e5596fdcde596a98fbc9ef946b | Python | sairamsubramaniam/data_science_practice | /linear_classifiers/perceptron.py | UTF-8 | 2,530 | 3.1875 | 3 | [
"MIT"
] | permissive |
import copy
import numpy as np
# INPUTS
iters = 10
# data = [[-1,-1, 1],[1,0,-1],[-1,1.5,1]]
# data = [[-1,-1, 1],[1,0,-1],[-1,10,1]]
# data = [[-4,2, 1],[-2,1,1],[-1,-1,-1],[2,2,-1],[1,-2,-1]]
data = [(0,0,-1), (2,0,-1), (3,0,-1), (0,2,-1), (2,2,-1), (5,1,1), (5,2,1), (2,4,1), (4,4,1), (5,5,1)]
# SEPARATE DEPEND... | true |
5f5b797444272834dc7840e48b6380c182729c39 | Python | twinklecjj/cjj_python | /python_practice/python_practice2/demo2/xuzhu/xuzhu.py | UTF-8 | 414 | 3.34375 | 3 | [] | no_license | # 导入模块——进行模块化改造
from python_practice.python_practice2.demo2.tonglao.tonglao import TongLao
# 定义一个XuZhu类,继承于童姥
class XuZhu(TongLao):
# 定义一个read(念经)的方法
def read(self):
# 打印“罪过罪过”
print("罪过罪过")
# 实例化类,并传参
xuzhu = XuZhu("无崖子",1000,100,1200,100)
# 调用类的方法
xuzhu.read() | true |
fce516610eb1c1603b92c94e4ecd9ebdbadca3f4 | Python | martinvl/MPC-2014 | /bacterial/make_figure.py | UTF-8 | 521 | 2.734375 | 3 | [] | no_license | from sys import stdin
from numpy import array, sum
from scipy.ndimage import binary_dilation
c_to_v = {'#':1, '.':0, 'X':-1}
m, n, g = map(int, stdin.readline().split())
dish = array([[c_to_v[c] for c in l.replace('\n', '')] for l in stdin])
mask = 1 - (dish == -1)
result = binary_dilation(dish == 1, [[0, 1, 0], [1, ... | true |
563742ce29c100740ebc788d180e7f6454eaed4f | Python | HenriqueHartmann/Exercicios-Python | /prg1-lista5b-Henrique_Luiz_Hartmann.py | UTF-8 | 6,475 | 3.921875 | 4 | [] | no_license | #!/bin/env python3
# Marco André Mendes <marco.mendes@ifc.edu.br>
# Criada por Felipe Tiago Guimarães <felipeguimaraes0025@gmail.com>
# Exercícios retirados do livro de Python de Raul Waslawick
# Lista de exercícios 2 - while
def corrida(vantagem, vlc_tartaruga, vlc_lebre):
"""A tartaruga e a lebre vão apostar um... | true |
49ee7321f627b859cf2ea253c6e3d1fa5f05c1ec | Python | daniycity/agfzb-CloudAppDevelopment_Capstone | /server/djangoapp/restapis.py | UTF-8 | 4,177 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | import requests
import json
# import related models here
from requests.auth import HTTPBasicAuth
# Create a `get_request` to make HTTP GET requests
# e.g., response = requests.get(url, params=params, headers={'Content-Type': 'application/json'},
# auth=HTTPBasicAuth('apikey', api_k... | true |
7543168fdbbf63c9cbff776ef4279657f2b4261c | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_84/95.py | UTF-8 | 1,234 | 2.734375 | 3 | [] | no_license | '''
Created on Oct 19, 2009
@author: sg0892495
'''
import string
dynamicMap={}
def converse():
numbers=file.readline().split()
size=map(int,numbers)
array=[['.' for i in range(size[1])] for j in range(size[0])]
for row in range(size[0]):
line =file.readline()
for col in range(size[1])... | true |
ccece1f47c8c22b518d28adcbe5a8047738d07d7 | Python | statco19/doit_pyalgo | /ch1/sum_verbose2.py | UTF-8 | 308 | 4.03125 | 4 | [] | no_license | print("a부터 b까지 정수의 합을 구합니다.")
a = int(input("정수 a를 입력하세요.: "))
b = int(input("정수 b를 입력하세요.: "))
if a > b:
a,b = b,a
sum = 0
for i in range(a,b+1):
if i < b:
print(f"{i} +", end=' ')
sum += i
print(f"{b} =", end=' ')
print(sum) | true |
88728e9fecd44cfc18afe202778e1aed87ede010 | Python | ZhenweiYe/Tools | /qcutils.py | UTF-8 | 6,140 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding=utf8 -*-
import datetime as dt
import scipy.stats
import numpy as np
import sys
class TimeProcess():
@classmethod
def conv_long_to_dtm(cls, dt_l):
'''
Convert long to datetime
>>> conv_long_to_dtm(1486456336)
2017-02-07 16:32:16
'''
... | true |
97506329ebad5efdf212d7d047dfc3e3933235f0 | Python | ilyakh/unifi-webfaction | /group/models.py | UTF-8 | 4,186 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python2.7
# -*- coding: utf8 -*-
from django.db import models
from django_extensions.db.models import TimeStampedModel
from person.models import Person, Wish
from unifi.rules import GROUP_CAPACITY, GOAL_TEXT_LENGTH
class Group( TimeStampedModel ):
"""
Contains Person objects, has a flag that i... | true |
93c98a222436260a58ec7ac3ebfb653507b59a91 | Python | Raghu010/Learn-python-3.x | /Calendar Module.py | UTF-8 | 2,203 | 4.25 | 4 | [
"Apache-2.0"
] | permissive |
"""Calendar module allows output calendars like the program and provides additional useful functions related to the calendar. Functions and classes defined in Calendar
module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. By default, these calendars have Monday ... | true |
0a6d78d9dfdce62c12aff965d3613842e40fbdc4 | Python | Smooth203/pythonTesting | /pyArcade/myGTAishThing/player.py | UTF-8 | 1,443 | 3.515625 | 4 | [] | no_license | import pygame
white = (255, 255, 255)
class Player(pygame.sprite.Sprite):
def __init__(self, colour, w, h):
super().__init__()
self.speed = 2
self.facing = 0 # 0,1,2,3 = up,right,down,left | respectively
self.anim = 0
self.animSpeed = 0.1
self.moving = False
self.idle = []
self.walk1 = []
self.wal... | true |
307b1ad97d8a339163c0e7d36f328392e334bf33 | Python | EvertonAlvesGomes/Curso-Python | /trabalhador.py | UTF-8 | 1,177 | 3.859375 | 4 | [] | no_license | ### trabalhador.py
## Solicite ao usuário que entre com dados de uma pessoa:
## nome, ano de nascimento e carteira de trabalho (CTPS).
## Se a CTPS for válida, solicite ao usuário entrar com dados
## de ano de contratação e salário.
## Retorne: nome, idade, CTPS, ano de contratação, salário e
## qual ano a pes... | true |
21627100f2a0049e58a478fa98afe737200189f5 | Python | josh14668/Easier-Parallel-Design-Framework | /test2.py | UTF-8 | 4,225 | 2.75 | 3 | [] | no_license |
srcDirectory = "src/main/scala/"
tstDirectory = "src/test/scala/"
class Module():
def __init__(self,name,inputTypes,outputTypes,numInstances):
self.name = name
#inputTypes is a dictionary
self.inputTypes = inputTypes
#outputypes is a dictionary
self.outputTypes = outpu... | true |
8ceb5c0acff1b4a0cf2db4f6f433fc46998b9c83 | Python | LautaroAndresSaez/curso_react | /python/cosa.py | UTF-8 | 49 | 2.953125 | 3 | [] | no_license | for i in range( 10 ):
print( "%03i" %(i +1) ) | true |
7db58c512c460b1eacde27e894dfc0ce6f7000ed | Python | liladhen/LeaguePyBot | /LPBv2/LPBv2/console/console.py | UTF-8 | 5,039 | 2.578125 | 3 | [
"MIT"
] | permissive | from ..logger import Colors, get_logger
import asyncio
from ..common import debug_coro, cls
logger = get_logger("LPBv2.Console")
class Console:
def __init__(self, bot):
self.bot = bot
self.game = bot.game
loop = asyncio.get_event_loop()
loop.create_task(self.print_loop())
@de... | true |
82aefee3c318ef7913e67b4804df5bc0e3ae394f | Python | Groovylein/adventofcode-2020 | /day_3/test_main_part_one.py | UTF-8 | 607 | 2.875 | 3 | [] | no_license | import pytest
import os
from day_3 import main
current_dir = os.path.dirname(os.path.abspath(__file__))
test_input_file = os.path.join(current_dir, 'test_input.txt')
test_input_file_simple = os.path.join(current_dir, 'test_input_simple.txt')
def test_input():
expected_list = [
[".", "."],
["#", "... | true |
30e15e9ce3578d55580e9be5de899a73617022d5 | Python | Roaldb86/Reinforcement_learning | /cartpole.py | UTF-8 | 2,768 | 2.6875 | 3 | [] | no_license | import gym
import numpy as np
import math
from agents import QAgent, Agent, RandomAgent, DQNAgent, PrioritizedDQNAgent
env = gym.make('CartPole-v0')
num_episodes = 10000
print_evry= 1
BUFFER_SIZE = int(1e5) # replay buffer size
BATCH_SIZE = 32 # minibatch size
GAMMA = 0.99 # discoun... | true |
678f1dbb50ce0266031be94a8ada94b94bc08c77 | Python | prattipati/Watchr | /watchr.py | UTF-8 | 1,425 | 2.796875 | 3 | [] | no_license | import json
import update
import parse
import time
import change
if __name__ == "__main__":
print()
print("Welcome to Watchr!")
print()
with open('config.json', 'r') as f:
try:
config = json.load(f)
#update.start()
print("Current configuration: ")
... | true |
27dfda44bd0c9570f6b89f4919e32cc4ba9c144c | Python | himanshuadvani/PythonContent | /Assignment12/Assignment12_3.py | UTF-8 | 1,419 | 2.671875 | 3 | [] | no_license | import sys
import time;
import psutil;
import os;
import re
def ProcessInfo():
processinfo=[]
dir=sys.argv[1];
if(not os.path.exists(dir)):
try:
os.mkdir(dir);
print("Directory created...\n");
except:
print("Directory already exists...\n");
pass
path=os.path.join(dir,"Himanshu_Advani_%s.log"... | true |
6c2e1ad082932cdc858ecb5098b5417f4f8860de | Python | ziho719/python | /basic/input.py | UTF-8 | 181 | 3.078125 | 3 | [] | no_license | # str=input("请输入:\n")
# print ("您输入了",str)
fo = open("foo.txt", "w")
print ("文件名: ", fo.name)
print ("是否已关闭 : ", fo.closed)
fo.write('helloworld!')
| true |
bf0dadf079dcb1c39ee04fa2b7afc5ef8081ee84 | Python | google-research/language | /language/compgen/nqg/tasks/geoquery/funql_normalization.py | UTF-8 | 7,617 | 2.875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | true |
56fb496dbd3f4ca651912031837129a51d2262b2 | Python | SLAM7F3/rl_implementations | /ppo/ppo.py | UTF-8 | 4,275 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A version of PPO that gathers data in parallel."""
import argparse
from copy import deepcopy
from typing import NamedTuple
import gym
import numpy as np
import ray
import torch
import torch.nn.functional as F
from torch import nn, tensor
from torch.distributions.categ... | true |
974f5808a98d4fefa5736e808cd31934a78bf9ea | Python | anishLearnsToCode/ml-workshop-wac-3 | /day_3/combinatorics.py | UTF-8 | 581 | 4.21875 | 4 | [
"MIT"
] | permissive | def factorial(n: int) -> int:
result = 1
for i in range(1, n + 1):
result *= i
return result
def permutation(n: int, r: int) -> int:
""":return nPr = n! / (n - r)!"""
return factorial(n) // factorial(n - r)
def combination(n: int, r: int) -> int:
""":return nCr = nPr / r!"""
retu... | true |
4df7aed5370b233a4f20b6336fea4ec2eafed470 | Python | kugelblitz6535/puyopuyo_rl | /puyopuyo.py | UTF-8 | 6,319 | 2.71875 | 3 | [] | no_license | import numpy as np
class PuyoPuyo(object):
def __init__(self, width=6, height=13):
self.width = width
self.height = height
self.colors = 4
self.erase_thresh = 4
self.observation_space = ((self.height, self.width), (2,), (2,), (2,))
self.action_space = self.width * 4... | true |
655467461db60189c81861b4c032f610ff10c221 | Python | biringaChi/python-crash-course | /exercise_5.py | UTF-8 | 6,795 | 4.25 | 4 | [] | no_license | # Try It Yourself: Conditional Test
# Q1
def conditional_test():
pen_type = 'black ink'
print("Is pen_type == 'black ink'? I predict True.")
print(pen_type == "black ink")
print("\nIs pen_type == 'blue ink'? I predict False")
print(pen_type == "blue ink")
#conditional_test()
# Q2: Alien Color
ali... | true |
a6f6265bcbf66da64974f73000b113abc4611681 | Python | damjan0/ijs_civ | /alone_graph.py | UTF-8 | 992 | 2.59375 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
probability_sum = [0.28593, 0.34593357466451924, 0.36775687133224694, 0.3987490989891018, 0.5062728030788688, 0.9311251609429948, 1]
probability_without = [0.3594014265946795, 0.4278684553541246, 0.460365756562534, 0.5037349858166346, 0.6132700807513045,
... | true |
6d58b4e0e6bfa6029d7b91105a40201719d42a38 | Python | tvanderweide/ThesisCode | /Create_LUTcorrection.py | UTF-8 | 7,504 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# RAW image testing in Python following MAPIR_Processing_dockwidget.py
# Save RAW Images as TIFFs
# Apply vignette correction to all fields
# Import required libraries
import numpy as np
import copy
import matplotlib.pyplot as plt
import cv2
import scipy.optimize as opt
import os
... | true |
d91a3a683fce13a62fc0eb10528717087cc098fb | Python | DeanHe/Practice | /LeetCodePython/NextPermutation.py | UTF-8 | 1,997 | 4.28125 | 4 | [] | no_license | """
A permutation of an array of integers is an arrangement of its members into a sequence or linear order.
For example, for arr = [1,2,3], the following are considered permutations of arr: [1,2,3], [1,3,2], [3,1,2], [2,3,1].
The next permutation of an array of integers is the next lexicographically greater permutatio... | true |
24d352436bf29d91d27528831667526c6074e693 | Python | jannikwienecke/Leetcode-Challenge | /main.py | UTF-8 | 1,305 | 3.96875 | 4 | [] | no_license | import solutions
# CHALLENGE #1 ---------------------------------------
input_list = [1,4,4,1,2]
result_1 = solutions.a1.single_number(input_list)
print(f"Single Number: Input: {input_list} - Result: {result_1}")
# CHALLENGE #2 ---------------------------------------
input_number = 22
result_2 = solutions.a2.happy_nu... | true |
c2d28ab09eef1cf981f4296d0cd80308d0b943db | Python | amyzhao11/GANBrain | /driverscript.py | UTF-8 | 7,568 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.layers import *
import numpy as np
from matplotlib import *
from matplotlib import pyplot
from matplotlib.pyplot import *
from PI... | true |
204a95dcfea60c67c2b683ab276a049801bb423d | Python | drsstein/PyRat | /Examples/BackPropagationSoftmax.py | UTF-8 | 3,517 | 3.625 | 4 | [
"MIT"
] | permissive | # short lectures on backpropagation and softmax by Geoffrey Hinton:
#
# Backpropagation: https://www.youtube.com/watch?v=H47Y7pAssTI
#
# Softmax: https://www.youtube.com/watch?v=yqsI-X40OBY
#
# This example is very similar to the BackPropagation example. The key difference
# is that the last layer is a softmax with two... | true |
9b05e4ecf7e3875f5a97d677cd736ea22200cae6 | Python | FASLADODO/crowd-count | /crowdcount/data/data_loader/ucf_qnrf.py | UTF-8 | 1,772 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding:utf-8 -*-
# ucf_qnrf dataset
import glob
import numpy as np
import h5py
import skimage.io
import skimage.color
from tqdm import tqdm
import os
from torch.utils.data import Dataset
class UCFQNRF(Dataset):
def __init__(self, mode="train", img_transform=None, gt_transform=None, both_transform=None,
... | true |
34fe57a84c65aa721b24724321150b2192af81d5 | Python | matsen01/trees | /main.py | UTF-8 | 198 | 3.015625 | 3 | [] | no_license | from reconstruction_algorithm import reconstruct_tree
pre_order_list = [1, 2, 4, 5, 8, 3, 6, 7]
post_order_list = [4, 8, 5, 2, 6, 7, 3, 1]
print(reconstruct_tree(pre_order_list, post_order_list))
| true |
4381e806551aeb36176fb6c1149eb90d17d8300a | Python | jjuarez7/python-jacqueline-juarez | /variables.py | UTF-8 | 432 | 3.625 | 4 | [] | no_license | # variables.py
# Author: Jacqueline Juarez Carrera
# March 29,2021
year = 2021;
sentence = "My name is jjuarez"
sarah, bob, mike = 16, 20, 25;
name, age = "maria", 24;
mary = fer = 20;
PI = 3.1416;
e = 2.71;
# display values
print ("year = ", year)
print ("sentence = ", sentence)
print ("\nsarah =", sarah, "\nbob =",... | true |
9e44a401ea5713848fb1e1be34d04c0b3f5a5ed5 | Python | thygolem/indoorQt | /logo/show_logo_app_1.py | UTF-8 | 844 | 2.8125 | 3 | [] | no_license | # https://www.youtube.com/watch?v=2ZGpaRyO-jE
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication
from PyQt5.QtGui import QPixmap
class MainWindow(QDialog):
'''Show image with a button constructor'''
def __init__(self):
super(MainWindow... | true |
781035ebff0cae04039644e2f172b0f4641a311e | Python | SculptingData2014/projects | /interpolation/nnsmoothing.py | UTF-8 | 1,975 | 3.859375 | 4 | [] | no_license | import math
class NNSmoothing(object):
"""
Implements "nearest neighbor" smoothing, roughly based k-NN regression:
<http://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm>
"""
verbose_mode = False
def __init__(self, input_csv):
"""
The input data should be a CSV file where... | true |
02e699468b1265340bb15f3b005c864376724380 | Python | danielshaving/Dataguru_Tutorials | /Tutorial 2 Image Preprocessing 2/2-3 Laplacian.py | UTF-8 | 221 | 2.5625 | 3 | [] | no_license | import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread("test.jpg", 0)
gray_lap = cv2.Laplacian(img, cv2.CV_16S, ksize=3)
dst = cv2.convertScaleAbs(gray_lap)
plt.imshow(dst,cmap='gray')
plt.show() | true |
9e0b58850338aafdbe10bebb0c053f77c7133517 | Python | daniel-reich/turbo-robot | /H2EyqacEnijCozCWs_2.py | UTF-8 | 521 | 3.9375 | 4 | [] | no_license | """
Write a function that returns the first `n` vowels of a string.
### Examples
first_n_vowels("sharpening skills", 3) ➞ "aei"
first_n_vowels("major league", 5) ➞ "aoeau"
first_n_vowels("hostess", 5) ➞ "invalid"
### Notes
* Return `"invalid"` if the `n` exceeds the number of vowels in a ... | true |
4547ef73d83915905f241c6e6fc3160b7064ecf7 | Python | EklavyaM/PygameBeginnerProjects | /Dodger/Source/enemy_straight_path.py | UTF-8 | 4,695 | 3.265625 | 3 | [] | no_license | import pygame
import math
class EnemyStraightPath:
# ==================== Straight Path up or down ===============================================================
DIR_UP = 0
DIR_DOWN = 1
TYPES = (DIR_DOWN, DIR_UP)
FADE_RATE = 200
FADE_OFFSET = 5
@staticmethod
def element_wise_diff... | true |
e2295c510dd25e994073f4dbbdaa02e666c1ed85 | Python | TheAlgorithms/Python | /dynamic_programming/longest_increasing_subsequence_o(nlogn).py | UTF-8 | 1,357 | 3.84375 | 4 | [
"MIT"
] | permissive | #############################
# Author: Aravind Kashyap
# File: lis.py
# comments: This programme outputs the Longest Strictly Increasing Subsequence in
# O(NLogN) Where N is the Number of elements in the list
#############################
from __future__ import annotations
def ceil_index(v, l, r, key): # ... | true |
abb4cf5a2feadca803a9fbf758e95b9d6d192a32 | Python | mysteryboyabhi/BRIDGELABZ_WORKS | /UnitTesting/temperature_conversion.py | UTF-8 | 437 | 3.703125 | 4 | [] | no_license | def convert_tem(user_data,convert_into):
if convert_into=="F":
return f" Farenhite tem is {(user_data *( 9 / 5)) + 32}"
elif convert_into=="C":
return f" Celsius tem is {(user_data -32) * 5/9}"
else:
return "please pick C or F for Celsius or Farenhite respectively"
temp=in... | true |
12fd315d22d8235208af4cb4879361019bd5ed72 | Python | dengshilong/C100Problem | /chapter2/recursion_power.py | UTF-8 | 401 | 3.484375 | 3 | [] | no_license | # coding: utf-8
def recursion_power(m, n):
if n == 0:
return 1
if n & 1: # n 是奇数
return m * recursion_power(m, n - 1)
else:
temp = recursion_power(m, n >> 1)
return temp * temp
if __name__ == "__main__":
for i in range(1, 10):
for j in range(1, 10):
... | true |
4e50f509643f6f809e1038848399899cf2ab39dd | Python | marsanem/sqa2014tennis | /tests/features/steps.py | UTF-8 | 938 | 2.96875 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- coding: utf-8 -*-
from lettuce import *
import app.match as m
@step(u'Given: "([^"]*)" and "([^"]*)" start a match to "([^"]*)" sets')
def given_p1_and_p2_start_a_match_to_pacted_sets(step, p1, p2, sets):
world.match = m.Match(p1, p2, sets)
@step(u'Then: I see score: "([^"]*)"')
def then_i_see_score(step,... | true |
875ae0f574adff0be59aa44a30f2657d9c4be306 | Python | InfinityTeq/the-codex-project | /ciphers/multiplicativeCipher.py | UTF-8 | 7,539 | 3.296875 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/python
# reverse cipher package for the the codex project
# created by : C0SM0
# imports
import sys
import getopt
# banner
banner = """
_____ .__ __ .__ _________ .__ .__
/ \\ __ __| |_/ |_|__| \\_ ___ \\|__|_____ | |__ ___________
/ \... | true |
9c9958e4025692471baaa00ab03196433e622b49 | Python | MatthiasEg/DL4G | /my_jass/MCTS/node.py | UTF-8 | 1,559 | 2.96875 | 3 | [] | no_license | import numpy as np
from my_jass.MCTS.nodemctsinformation import NodeMCTSInformation
from my_jass.MCTS.status import Status
class Node:
def __init__(self) -> None:
self._parent = None
self._children = []
self._nodeMCTSInformation = NodeMCTSInformation()
self._status = Status.NEW
... | true |
96e43702717bc52c095a6375b7a9d356ba09c890 | Python | Aasthaengg/IBMdataset | /Python_codes/p02733/s655884218.py | UTF-8 | 770 | 3.015625 | 3 | [] | no_license | # E - Dividing Chocolate
import sys
sys.setrecursionlimit(10000)
H,W,K = map(int,input().split())
S = [input() for _ in range(H)]
ans = 10000
def check(border, num):
global H,W,K,S
now = [0]*(num+1)
add = 0
for j in range(W):
tmp = [0]*(num+1)
for i in range(H):
now[border[... | true |
47937059c43427a8eb95adfecb6de205edfe47e7 | Python | ganzik83/telegrambot | /menu.py | UTF-8 | 373 | 3.109375 | 3 | [] | no_license | import random
foods = ["피자", "타코", "장어", "치킨"];
# console.log(_.sample(foods));
print(random.choice(foods))
matzip = ['백운봉 막국수', '고갯마루', '대우식당']
matzipDic = {
'백운봉 막국수': '이베리코 돼지고기',
'고갯마루': '닭도리탕',
'대우식당': '부대찌개'
}
print(matzipDic['고갯마루'])
| true |
86deb445f95ce42cc0de40fb3e6279f22edd018a | Python | kmboese/machine-learning | /k-means-clustering/main.py | UTF-8 | 6,590 | 3.015625 | 3 | [] | no_license | #Solves the problem set from the ECS 170 take-home final, problem 1
from k_means import *
from os import getcwd
from os.path import join, exists
import random
import copy
#I/O Variables
file_dir = getcwd()
filepath = join(file_dir, "k_means_solutions.txt")
divider = "__________________________________________________... | true |
94ed48351a7369559881875470bca9452ea00273 | Python | brandeddavid/Web-Scrappers | /GitHub/category.py | UTF-8 | 2,784 | 3.03125 | 3 | [] | no_license | from github import Github
from urllib.request import urlopen
from bs4 import BeautifulSoup
import requests
import json
import time
import csv
def login(username, password):
"""
[Auth Function]
Arguments:
username {[str]} -- [GitHub username]
password {[str]} -- [GitHub password]
R... | true |
13bb0d8ad79fd7af4c5fe4e18461568a657f53f9 | Python | fs2600/minihcc4 | /minihcc4.py | UTF-8 | 619 | 3.390625 | 3 | [] | no_license | #!/usr/bin/env python
# 3***00
numbers = [6,5,1987]
multnumbers = []
for number in numbers:
#print number * numbers[0]
multnumbers.append(number * numbers[0])
multnumbers.append(number * numbers[1])
multnumbers.append(number * numbers[2])
nodupNumbers = list(set(multnumbers))
productListSum = 0
for number in ... | true |
5488df9a60f94eb0a288e2170248a87995dec314 | Python | mattjp/leetcode | /practice/easy/0819-Most_Common_Word.py | UTF-8 | 1,349 | 3.3125 | 3 | [] | no_license | class Solution:
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
# given punctuation
punctuation = '!?\',;.'
# remove punctuation from paragraph
no_punctuation = ''
for ch in paragraph:
no_punctuation += ch if ch not in punctuation else ' '
# remove leading/trailing ... | true |
ec5719cfdf322c03d82e23fb5a888c3c5e1fa12d | Python | ggasmithh/ambient_intelligence_labs | /python-lab5/userdb.py | UTF-8 | 1,599 | 3.03125 | 3 | [] | no_license | import pymysql.cursors
# gets our connection to the database
def get_connection():
connection = pymysql.connect(host='localhost',
port=3306,
user='user',
password='passwd',
db='python... | true |
76c8a503f95ed4479e269e7cb768513c982871d6 | Python | hackyourlife/orakel | /lisp.py | UTF-8 | 12,167 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# vim:set ts=8 sts=8 sw=8 tw=80 noet cc=80:
import re
WHITESPACE = [' ', '\r', '\n', '\t']
class Identifier(object):
def __init__(self, name):
self.name = name
def __call__(self):
return self.name
def __str__(self):
return self.name
def __repr__(self):
return self.name
class Func... | true |
c8133837d8a059c564728a3ae279eeaf9dc5cbaa | Python | jteckert/facial-identification | /src/faces-train.py | UTF-8 | 2,279 | 3.078125 | 3 | [] | no_license | import os
import cv2
import numpy as np
from PIL import Image
import pickle
# Get the base directory of current file
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Append images to path
image_dir = os.path.join(BASE_DIR, "images")
# Need to import faec cascades to find region of interest
face_cascade = cv2.... | true |
10a130ce1adb991a1db1710d666c334578ec166b | Python | 96Octavian/MM | /modules/Esercizionuovo.py | UTF-8 | 612 | 3.3125 | 3 | [] | no_license | def unisciliste(lista1, lista2):
lista = []
for i in lista1:
for a in lista2:
if i == a:
lista.append(a)
return lista
def main(nomefile):
lista = []
f = open(nomefile, "r")
for i in f:
a = i.split(";")
if int(a[1]) > 500:
lista.ap... | true |
e3a21f87b96db56b0427b7d1d23e9f3d6fbaf050 | Python | Timehsw/PythonCouldbeEverything | /makedata/bash_history/insert_history_cmd.py | UTF-8 | 1,637 | 2.734375 | 3 | [] | no_license | #! /usr/bin/env python
# coding=utf-8
import os, sys, MySQLdb as mysql
if len(sys.argv) >= 1 and (sys.argv[1] == '--help' or sys.argv[1] == '-help'):
print '-----example : python insert_history_cmd.py uid ctid cid path conn'
os._exit(0)
length = len(sys.argv)
if length < 6:
print 'error needs 5 args uid c... | true |
79b82c751703a0ca1231e58528919f8fb76be855 | Python | tconnor/goodpy | /goodman_functions.py | UTF-8 | 1,874 | 3.0625 | 3 | [
"MIT"
] | permissive | import numpy as np
def approximate_lambda(grating,g_ang,c_ang,soffset=0.0):
'''Takes a grating, grating angle, and camera angle, and returns the
limits and center of the image in nm.
Inputs: soffset: slit offset from CF (Default=0.0)'''
alpha = g_ang + soffset
beta = c_ang - g_ang
c_lam = ((100... | true |
bc8a9b738acc8ba96f6282908e6196956b3ae86c | Python | mtholder/supertree-study | /false_pos_and_neg.py | UTF-8 | 2,161 | 3.125 | 3 | [] | no_license | #!/usr/bin/env python
import numpy as np
import sys
import matplotlib.pyplot as plt
def collect_false_pos_and_negs():
'''
This function collects all of the false positives and negatives and takes an average of them.
Will be pipelined at a later date..
'''
data = np.loadtxt(sys.argv[1])
a = data.mean(0)
mrp_false... | true |
cdf3eee37485107e1b51a4fd17793eec714d533a | Python | vahaponur/GlobalAIHubPythonCourse | /Homeworks/HM1.py | UTF-8 | 1,619 | 3.546875 | 4 | [] | no_license | #GlobalAIHub Introduction to Python Homework1
# A list maded 0,13
homeworklist=list(range(14))
#list's second half swapped with first half
homeworklist.reverse()
#In homework, there was no exp what kind of print so I print one by one
i=0
for item in homeworklist:
print(homeworklist[i])
i+=1
#questio... | true |
85b6b807dba86065e2d967e7fd2d95eee18ab8cb | Python | mikelkl/TF2-QA | /tf2qa/pipline_roberta_albert.py | UTF-8 | 17,052 | 3.078125 | 3 | [
"MIT"
] | permissive | # STEP1 将数据集去HTML化,然后按照字数阈值(600)划分存储
from tqdm import tqdm
import json
def split_data(input_dir, output_dir, token_limit=600, is_training=False):
para_splited_data = []
with open(input_dir, 'r') as f:
for line in tqdm(f):
temp_data = json.loads(line)
context = temp_data['docum... | true |
1260ecbca50fa8c47e8902a016b88bd4655bb687 | Python | dezgeg/massive-ironman | /opencv.py | UTF-8 | 5,645 | 2.640625 | 3 | [] | no_license | import cv
import cv2
import os
import sys
import atexit
import numpy
RED = cv.Scalar(0, 0, 255, 0)
BLUE = cv.Scalar(255, 0, 0, 0)
WHITE = cv.Scalar(255, 255, 255, 0)
YELLOW = cv.Scalar(0, 255, 255, 0)
BALL_SIZE_THRESHOLD = 50
def nothing(x):
pass
# If '-t' flag given, don't actually send commands to the robot... | true |
909434750ea098c4db282fcb3ad8bc55e2fad1ea | Python | ShantanuBal/Code | /euler_copy/47b.py | UTF-8 | 659 | 3.171875 | 3 | [] | no_license | import time
start = time.time()
n = 1000
sieve = [0] * n
primes = [2]
for i in xrange(3,n,2):
if sieve[i] == 0:
primes.append(i)
j = i * 2
while j < n:
sieve[j] = 1
j += i
print len(primes)
def check(number):
factors = []
i = 0
while i<len(primes):
... | true |
33274bf21cb4387ac9bb74c480ae229705c84495 | Python | JWONG7702/NBAHACKATHON | /NBA.py | UTF-8 | 3,683 | 3.203125 | 3 | [] | no_license | ## NBA HACKATHON ##
#TODO:
#-lazy elim (random if tied)
#-adapt to csv output
#-proper tie breaker
import xlrd
class team:
"""represents NBA team"""
def __init__(self,name,div,conf):
self.name = name
self.div = div
self.conf = conf
self.record = [0,0]
self.date_elim ... | true |
799660218fe8474741794de8f5110c32b72899f9 | Python | iht/kschool-challenge-dl | /predictor/keras_predictor.py | UTF-8 | 1,522 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | """A custom class for predictions in AI Platform."""
import base64
import numpy as np
import os
import pickle
import tempfile
import tensorflow as tf
class MyPredictor(object):
"""My custom prediction class.
This implements the interface expected by AI Platform.
"""
def __init__(self, model, preprocessor):... | true |
37e6a657ac5384e2c7550cc352f87abc52c5b172 | Python | DeshErBojhaa/sports_programming | /leetcode/1483. Kth Ancestor of a Tree Node.py | UTF-8 | 1,590 | 3.5625 | 4 | [] | no_license | # 1483. Kth Ancestor of a Tree Node
class TreeAncestor:
def __init__(self, n: int, parent: List[int]):
self.depth, self.par = [0]*n, [None]*n
self.g = collections.defaultdict(list)
for i, v in enumerate(parent):
self.par[i] = v
self.g[v].append(i)
... | true |
f9adfbbdd5bc2740ba6662d0c460423648e88c6b | Python | muhrahmatullah/LearnDjangoApi | /sekolah/serializers.py | UTF-8 | 1,493 | 2.578125 | 3 | [] | no_license | from rest_framework import serializers
from sekolah.models import Siswa, OrangTuaSiswa, Guru
class GuruSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
nama = serializers.CharField(required=True, allow_blank=False, max_length=100)
PEREMPUAN = 'P'
LAKI_LAKI = 'L'
P... | true |
58ee6bacca823c97dba0c05f6ba04f8d702ce02e | Python | itwasntzak/delivery_tracking-python | /resources/strings.py | UTF-8 | 6,868 | 3.09375 | 3 | [] | no_license | # todo: change the way things are orgonized
# use comments to show file names, first name for class or function
"""
resource legend:
file/class_name__function/method_name__resource_occurrence
file/class_name__resource_occurrence
thoughts on new ways
group by files,
"""
# objects
# shift
Shift__c... | true |
4f23d6cb55e1d73e019d33d25a0220d1951ea1bf | Python | dx19910707/LeetCode | /441. 排列硬币.py | UTF-8 | 342 | 2.953125 | 3 | [] | no_license | class Solution(object):
def arrangeCoins(self, n):
"""
:type n: int
:rtype: int
964ms beats:15.19%
"""
i = 0
sum = 0
while True:
if sum == n:
return i
elif sum > n:
return i - 1
i += 1... | true |
d4a35f9ab781f37313f55eef7265e31942a69a9e | Python | justinro-underscore/RFID_Controller | /init.py | UTF-8 | 1,365 | 3 | 3 | [] | no_license | import time
from pynput.keyboard import Key, Controller
keyboard = Controller()
dino_keys = [Key.up, Key.down]
pacman_keys = [Key.up, Key.right, Key.down, Key.left]
current_keys = dino_keys
card_actions = { "some_card_num":current_keys[0] }
def play_dino():
#testing time
current_keys = dino_keys
current... | true |
e6582f2e2b14b114ac52545f9a77a4ca046d4a64 | Python | Yi-61/CAPTCHA_Breaker_CS229 | /multi_letter_cnn/construct_CNN.py | UTF-8 | 3,828 | 2.578125 | 3 | [] | no_license | from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Conv2D, MaxPooling2D
def constructModel_1(dropout, inputShape, numClass): # originally for single-letter
model = Sequential()
model.add(Conv2D(20, (2,2), strides = 1, activat... | true |
5d9d290e1da4c92056f5d86e137422d2264638d2 | Python | sanketd11/Structured_Prediction | /Code/StructuredPerceptron.py | UTF-8 | 17,228 | 2.640625 | 3 | [] | no_license |
# coding: utf-8
# In[14]:
from random import shuffle
import pandas as pd
import numpy as np
from stemming.porter2 import stem
# In[341]:
class structuredPerceptron():
def __init__(self,learningRate=0.001,C=0.1):
self.weight={}
self.avg={}
self.gamma=learningRate
self.C=C
... | true |
4e03d1600fecc7af3f8ad7b4f4984e0334b720a9 | Python | kujalk/VirusTotal-API | /Get-Virustotal-Results.py | UTF-8 | 2,710 | 3.0625 | 3 | [] | no_license | #Developer - K.Janarthanan
#Date - 20/9/2019
#Purpose -
#Searching files by hash values
#Getting virus total results
#Getting AV labels in the dictionary
import csv
import requests
import time
#Configure parameters
source_csv="souce-file.csv"
api_key='apikey'
final_csv="Final-Results01.csv"... | true |
d192ba196dd393fc0b05cdcd0e1768c4c60bba16 | Python | yeungsl/GAN-Project | /LinkPrediction/BasicSolution/sampling_train_test_split.py | UTF-8 | 2,418 | 3 | 3 | [] | no_license | import numpy as np
import random
def train_test_split(fr,n_folds=2,edges = 'cr'):
'''
fr: 读取文件入口
n_folds: 划分成的份数, 默认值为2,并且要大于2 且小于100,且小于edges
edges : 边的数量 默认为'cr' 完全读完,最小为大于 2 的值
文件默认以 \t 为分割符
split n folds set
return nodepair_set[[[0,1],[2,3],,,],[],,,[]]
''... | true |
6ec27ee6aecac8ef71a14b4551a8394a15c49580 | Python | yusuke-matsunaga/nl3d-2017 | /nl3d/dimension.py | UTF-8 | 3,431 | 3.34375 | 3 | [
"BSD-3-Clause"
] | permissive | #! /usr/bin/env python3
### @file dimension.py
### @brief Dimension の定義ファイル
### @author Yusuke Matsunaga (松永 裕介)
###
### Copyright (C) 2017 Yusuke Matsunaga
### All rights reserved.
from nl3d.point import Point
### @brief 問題のサイズを表すクラス
###
### 基本的に初期化時に設定した値は変更されない.
class Dimension :
### @brief 初期化
### @par... | true |
d3f9289086667fe1eefe76f3a94203b87a21c786 | Python | jaychsu/algorithm | /leetcode/688_knight_probability_in_chessboard.py | UTF-8 | 2,265 | 3.375 | 3 | [] | no_license | import collections
class Solution:
"""
DP:
1. init the first pos as 1
2. keep simulate the process and divide the probability
3. sum the values
"""
def knightProbability(self, n, k, r, c):
"""
:type n: int
:type k: int
:type r: int
:type c: int
... | true |
18eecf2d3a52680a5a7af3c4b5eac8ff6caa89dc | Python | jSith/Advent-of-Code | /day_11.py | UTF-8 | 3,584 | 3.359375 | 3 | [] | no_license | import utility
def find_path(target_horizontal, target_vertical):
current_horizontal = 0
current_vertical = 0
steps = []
while target_horizontal != current_horizontal or target_vertical != current_vertical:
if target_vertical > current_vertical and target_horizontal < current_horizonta... | true |
8b3416e0634398e2532c0860b66cf6308444cbe9 | Python | mariamamoura/projetohuoc | /teste.py | UTF-8 | 1,131 | 3.765625 | 4 | [] | no_license | arquivo = open('nomes.txt', 'r')
texto = arquivo.readlines()
leitos = {}
for linha in texto:
separado = linha.split(";")
numpaciente = separado[0]
nomes = separado[1]
visitas = separado[2]
leitos[numpaciente] = nomes + visitas
while True:
opcao = int(input("""
Digite 1 para ver a lista de... | true |
352dbb4c51e87c030bf101540f1b70a5b14caa96 | Python | musicomusio/gosample | /sample_janome.py | UTF-8 | 1,744 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[1]:
get_ipython().system('pip install janome')
# In[15]:
from janome.tokenizer import Tokenizer
from janome.analyzer import Analyzer
from janome.tokenfilter import POSKeepFilter,ExtractAttributeFilter
# In[ ]:
# In[143]:
txt = """"
後ろは楽ちんカットソー ZIP付Vネックフレンチスリーブブ... | true |
b36d02e0e674d1f3d08928df14b59cce20e68763 | Python | HDhandi/python_Test | /14day/3-.py | UTF-8 | 384 | 2.734375 | 3 | [] | no_license | '''
list = [{"beijing":{"mianji":1290,"remkou" :123123},"shanghai":{"mianji":12331,"renko u":123123}}]
for i in list:
for k,v in i.items():
for a,b in v.items():
print(k,a,b)
'''
list = [{"beijing":{"mianji":1290,"remkou" :123123},"shanghai":{"mianji":12331,"renko u":123123}}]
for i in list:
for k,... | true |
10359d892fedd3c67711a99fc63f1a1331f3f511 | Python | MokhtarTouiri/holbertonschool-higher_level_programming | /0x0A-python-inheritance/3-is_kind_of_class.py | UTF-8 | 127 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python3
""" Module """
def is_kind_of_class(obj, a_class):
""" models """
return isinstance(obj, a_class)
| true |
55fa5f143be448b6c3f1c6fec01b4acce4207458 | Python | NyokoKei/Coursera_python_w2 | /12.py | UTF-8 | 96 | 3.484375 | 3 | [] | no_license | s = input()
i = s.find('f')
if i == -1:
print(-2)
else:
print(s.find('f', i + 1))
| true |
ec2a6fc4bbac356da23c1f94edc5a11d1cf9f1a6 | Python | ErikBjare/Cellular | /src/grid.py | UTF-8 | 3,713 | 3.328125 | 3 | [] | no_license | import random
import colorama
from colorama import Fore
colorama.init()
# Neighbors helper functions
def neighbors(g, r, c):
"""
Returns the Moore neighborhood
.....
.xxx.
.xcx.
.xxx.
.....
https://en.wikipedia.org/wiki/File:CA-Moore.png
"""
r1, r2, r3 = ((r+offset) % len(g) ... | true |
3273e078013c8d6dba902753c84b1c1955298798 | Python | larslevity/GeckoBot | /Code/Src/GUI/User_control_modes/template.py | UTF-8 | 2,197 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon May 30 03:14:12 2016
@author: ls
Templates for the UserControl Pages
"""
from gi.repository import Gtk
def create_xy_adjustments(data):
""" Create a x-, and a y-adjustment """
value = (float(data.limits[0] + data.limits[1]))/2
x_adjustment = Gtk.Adjustment(val... | true |
eed54091ce1c682eda15f9ab84cc2e3f2c41e253 | Python | daxingyou/GameServer_9youNiuNiu | /base/state_base/machine.py | UTF-8 | 961 | 2.640625 | 3 | [] | no_license | # coding: utf-8
import weakref
class Machine(object):
def __init__(self, owner):
self.owner = weakref.proxy(owner)
self.last_state = None
self.cur_state = None
self.owner.machine = self
def trigger(self, new_state, dump=True):
if self.cur_state:
self.cur_s... | true |
5df913fc2c698acc1b7d59e280646ac8ec095081 | Python | Raysuner/ROS | /ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py | UTF-8 | 9,345 | 3 | 3 | [] | no_license | #!/usr/bin/env python
import thread
from math import pi as PI, degrees, radians
import os
import time
import sys, traceback
from serial.serialutil import SerialException
from serial import Serial
class Arduino:
''' Configuration Parameters
'''
N_ANALOG_PORTS = 6
N_DIGITAL_PORTS = 12
def __init__(... | true |