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 |
|---|---|---|---|---|---|---|---|---|---|---|
701267d548a05b3832f06779fc07cb0b3ccd53f0 | crystal1509/Project | /numberguessinggame.py | UTF-8 | 2,415 | 4.03125 | 4 | [] | no_license | #!!NUMBER GUESSING GAME!!!
#CREATED BY GANGA SINGH
import random
while(1):
again=input("DO YOU WANT TO PLAY(enter y/n):")
if again=="y" or again=="Y":
print("\t\t!!WELCOME TO THE NUMBER GUESSING GAME!! :)")
... | true |
22c046e263835028d5923d68f9331ef58ca5cc78 | SandervWickeren/Heuristics_Amstelhaege | /Functions/alg_simannealing_switch.py | UTF-8 | 4,055 | 3.171875 | 3 | [] | no_license | """
Uitleg:
In dit algoritme worden twee willekeurige huizen
gepakt en de coordinaten van deze huizen worden
verwisseld zo mogelijk. Hierbij wordt geled op het
feit dat de huizen niet hetzelfde zijn en dat er
niet met water wordt verwisseld. Er geldt dat wanneer
de score verbetert, de map wordt aangenomen en wanneer
... | true |
2ed13494bb84a9deaf35d41584db60fe185bc002 | shekoelnawawy/Ohio_13 | /URET/uret/transformers/BloodGlucose/string_transformer.py | UTF-8 | 9,755 | 3.078125 | 3 | [
"MIT"
] | permissive | from uret.transformers import Transformer
import numpy as np
import random
class StringTransformer(Transformer):
name = "StringTransformer"
# Two attributes used by simulated annealing to track transformer properties
transform_initial = True # If True, then inputs to transform() should be based on the i... | true |
8c16026f8d0eb9e0b494bd8bf03c764834fe3ad6 | darid/ResearchWork | /LSTM/PrepareData.py | UTF-8 | 1,913 | 2.515625 | 3 | [] | no_license | import os
import re
import numpy as np
work_dir = "/home/darid/ResearchWork/DataCollection/Data/"
# num = 0
# for cur_file in os.listdir(work_dir):
# print cur_file
# num = num + 1
# print num
def importData(filename):
im_lable = []
lable_dic = {'grasp\n':np.array([0,0,0,0,0,0,0,0]),
... | true |
7bdc8570ff2d899ba822b0c8572167cd5ea19307 | H33525/Print-0-to-49-Digits | /Print Zero to 49 digits.py | UTF-8 | 33 | 3.015625 | 3 | [] | no_license | i=0
while i<50:
print(i)
i=i+1 | true |
7c2152b41c33a2a4f5ae6d2d11bc5849d1b2b573 | loedata/FORMATION-DATA_SCIENTIST-OPENCLASSROOM | /CODE/OC-COURS-6-NETTOYER_JEU_DONNEES/analyse/python_analysis.py | UTF-8 | 9,428 | 3 | 3 | [] | no_license |
# coding: utf-8
# In[3]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
data = pd.read_csv("operations_enrichies.csv", parse_dates=[0])
# # Représenter une variable sous forme de graphique
# In[4]:
data['categ'].value_counts(normalize=True).plot(kind='bar')
plt.show()
# In[5]:
data... | true |
db540ab07c327be4a8283539051479543351e04f | glassalle/HiplexGC | /Hiplex.py | UTF-8 | 7,631 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 25 10:53:16 2018
@author: glassalle
Analyse globale d'un fichier de genotypage selon Hiplex
input : fichier fasta de reference avec les snps candiadts
Fichier en sortie de sequenceur demultiplexé
output : Fichier pileup par individu... | true |
4735df1b92c370089e22848306d8684005a8ea3f | grkimcfa/DigitalEquity_MobileVers | /mobileVers/application/backend.py | UTF-8 | 3,455 | 2.5625 | 3 | [] | no_license | # Andrew backend code for address check
# 2/23/2021 TODO:
# Streamline logic for going through CSV file - priority: medium
# Using USPS-API, incorporate returned address to clients' view via drop-down bar - priority: high
import csv
from usps import USPSApi, Address
import json
import re
#Andrew backend code for Twili... | true |
c8268c265cac8b221026b0477af7085ebe419856 | GoogleCloudPlatform/professional-services | /tools/airflow-v1-to-v2-migration/airflow_migration/migration.py | UTF-8 | 13,322 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | import csv
import glob
from pathlib import Path
import re
from prettytable import PrettyTable
def clean_input(arg):
return arg.strip().replace('\n', '')
def parse_import_statement(import_statement):
pattern = r'^(?:from\s+([\w.]+)\s+)?import\s+(?:\(([^)]+)\)|([\w., ]+))$'
match = re.search(pattern, imp... | true |
a8a6e0d081452307ebc28a7746aa39af08544293 | delaven007/2-advance | /IO-网络编程/1-文件读写-shell命令-struct模块-文件偏移量-文件描述符/my_seek.py | UTF-8 | 347 | 3.484375 | 3 | [] | no_license | """
文件偏移
"""
# r,w 文件偏移量在开头
# a 文件偏移量在结尾
f= open("text.txt","wb+")
f.write(b"hell,oasdhdsff\n")
f.flush()
# f.close()
# print(f.tell()) #打印当前文件偏移量
f.seek(-7,1) #以开头为基准向后移动0字节
f.seek(3,0)
# f= open("text.txt","r+")
data=f.read()
print(data) | true |
44c78836c4bc1fc53acd13a1b1323459fb412892 | Dandelionym/HappyFarm | /Tools/Schedule.py | UTF-8 | 1,309 | 2.65625 | 3 | [] | no_license | import Places.MapExchange as pm
def Table():
print("\033[5;31m")
print(" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓")
print(" 1 地图 2 帮助 3 存档 0 退出")
print(" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")
... | true |
c8af78ba92618f87b4b97057868bc0c26100eacb | jemme07/pipeline-configs | /flamingo/registration.py | UTF-8 | 9,536 | 2.796875 | 3 | [] | no_license | """
Registration of extra quantities for velociraptor catalogues (i.e. quantities
derived from the catalogue's internal properties).
This file calculates:
+ sSFR (30, 100 kpc) (specific_sfr_gas_{x}_kpc)
This is the specific star formation rate of gas within those apertures.
Only calculated for galax... | true |
93602e708024799c9aecfba6c81f293b0ccf0478 | google/benchmark | /bindings/python/google_benchmark/example.py | UTF-8 | 3,858 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2020 Google Inc. All rights reserved.
#
# 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 applicable law or a... | true |
120772524fa90c29332b321b241b88393034fa76 | ravi-kumar12/DynamicAlgorithm | /Unbounded Knapsack(Recursion+Memonisation).py | UTF-8 | 3,082 | 3.578125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 15:18:51 2020
Definition: Given types of items of different values and volumes, find the most
valuable set of items that fit in a knapsack of fixed volume. The number of
items of each type is unbounded. This is an NP-hard combinatorial optimization
problem
Ti... | true |
710fc49886dbd2ff191ff1d3c0fbd2bdbc45ee61 | fhirschmann/Flask-FlatPages-Pandoc | /tests.py | UTF-8 | 1,466 | 2.640625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import unittest
import os
from shutil import rmtree
from tempfile import mkdtemp
from codecs import open
from flask import Flask
from flask_flatpages import FlatPages
from flask_flatpages_pandoc import FlatPagesPandoc
class TestFlatPagesPandoc(unittest.TestCase):
def setUp(self):
... | true |
39f74fe52780113d9b3abc815477d717d62196ec | mishraabhinav4/Python4DataScience | /TextMining/Text_Preprocessing.py | UTF-8 | 9,285 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 13 04:41:02 2018
@author: amishra_v
"""
import pandas as pd
import numpy as np
from nltk.data import load
import re
import csv
import nltk
from multiprocessing import cpu_count,Pool
from nltk import word_tokenize,ngrams
import itertools
from nltk.corpus import stopwords
f... | true |
4422e7878241cc78e5f3447e81d13786b695c3e2 | samuelanthrayose/python_text_manipulation | /learning/examples/generate_array/generateArray.py | UTF-8 | 360 | 3.65625 | 4 | [] | no_license | # Take htwo digits as inputs
print "Enter any two digits"
row = int(raw_input("> "))
col = int(raw_input("> "))
elements = []
print "\nThe %d X %d 2-D array generated is:" % (row, col)
# To generate a 2-D array of size (row X col)
for i in range(row):
for j in range(col):
elements.append(j*i)
print e... | true |
9c5c4fe4f20788f9fdd9ef79dc5f1720adeee469 | talianzakowski/neos | /write.py | UTF-8 | 3,840 | 3.53125 | 4 | [] | no_license | """Write a stream of close approaches to CSV or to JSON.
This module exports two functions: `write_to_csv` and `write_to_json`, each of
which accept an `results` stream of close approaches and a path to which to
write the data.
These functions are invoked by the main module with the output of the `limit`
function and... | true |
bf0bd326c18e1edaf8156b7fd2b480706b816266 | GaganpreetKaurKalsi/LeetCodeChallenge-August | /Day4-PowerOfFour/Solution.py | UTF-8 | 245 | 2.8125 | 3 | [] | no_license | # Runtime: 28 ms
# Memory Usage: 12.7 MB
class Solution(object):
def isPowerOfFour(self, num):
n = 4
if num==1 : return True
while n<=num:
if n==num : return True
n = n*4
return False
| true |
543e312cd447e82ab225f822bca587179b50b1fb | jiluhu/dirtysalt.github.io | /codes/contest/leetcode/binary-tree-longest-consecutive-sequence.py | UTF-8 | 1,165 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env python
# coding:utf-8
# Copyright (C) dirlt
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
cl... | true |
40d3a6aa00c4fcbeb75b92f110ef31f56f96426d | msbelal/Project-Euler | /hash-1.py | UTF-8 | 344 | 2.890625 | 3 | [] | no_license | def hash(i, c) :
return ((int(i) * 37) + c) & 0xFFFFFFFF
def hashR(low, high) :
hashC = 0
for i in range(low, high) :
hashC = hash(hashC, i)
return hashC
d = {}
x = 0
for i in range(1, 1000*1000) :
if i % 1000 == 0 :
print ".",
x = hash(x, i)
if x in d.keys() :
print "Seen %08x: %d %d" % (x, d[x], i)
b... | true |
7471d0dfc7da539a06d7846f5e9d50254562c5fa | jee14k/Linear-Algebra | /Lab/jeevan.py | UTF-8 | 238 | 3.765625 | 4 | [] | no_license |
# coding: utf-8
# In[5]:
def funct1(a,b):
print("Value of a: ",a)
print("Value of b: ",b)
# In[6]:
funct1(5,3)
# In[11]:
def funct2(c,d):
e=c*d
print("The product of is ",e)
# In[12]:
funct2(5,2)
# In[ ]:
| true |
8edf88ffa60397ece79c508d1dac02ac0a416701 | avranju/iotedge-k8s | /edge-bootstrap/python/edgectl/deployment/commandfactory.py | UTF-8 | 3,238 | 2.765625 | 3 | [
"MIT"
] | permissive | """ Implementation of the factory class to instantiate Edge deployment commands """
import logging as log
from edgectl.config import EdgeConstants as EC
from edgectl.deployment.commandbase import EdgeLoginCommand
from edgectl.deployment.commandbase import EdgeRestartCommand
from edgectl.deployment.commandbase import Ed... | true |
8b54b1b834e3b619a1e58da9affa87a7e4a2d861 | bijou/bijou-server | /bijou/server/errors/config_file_not_found.py | UTF-8 | 423 | 2.796875 | 3 | [
"MIT"
] | permissive | import errno
import os
class ConfigFileNotFoundError(FileNotFoundError):
"""
The optionally supplied configuration file was not found
"""
def __init__(self, file):
super(errno.ENOENT, os.strerror(errno.ENOENT), file)
class ConfigFileNotFoundWarning(Warning):
"""
The default configura... | true |
31e079a29152ad1646d0f2ea30fb35735b00fe21 | syo0e/Algorithm | /python/baekjoon/11047.py | UTF-8 | 191 | 2.734375 | 3 | [] | no_license | import sys
N,K = map(int,input().split())
arr = []
for _ in range(N):
arr.append(int(input()))
ans = 0
idx = -1
while K!=0:
ans+=K//arr[idx]
K=K%arr[idx]
idx-=1
print(ans) | true |
dc2ec0f94207d34bbcec48947a333583a6386748 | cankutergen/hackerrank | /Triple_Sum.py | UTF-8 | 434 | 3.171875 | 3 | [] | no_license | def triplets(a, b, c):
set_a = set(a)
set_b = set(b)
set_c = set(c)
arr = []
for i in set_a:
for j in set_b:
sub_arr = []
if i <= j:
sub_arr.append(i)
sub_arr.append(j)
arr.append(sub_arr)
count = 0
for k i... | true |
f91d6f5053c7cd9c5b5a3a08752cbb322c8067e3 | icyflame/auv-visualizer-pyqt | /listen_multiple_dynamic.py | UTF-8 | 2,359 | 2.6875 | 3 | [] | no_license | # Dynamic listener
# All the topics will have a single push button associated with them.
# When the push button is pressed, that topic will be shown. When the push button
# is pressed again then the topic will be hidden.
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
import sys
from PyQt4 impo... | true |
46cfe7902fa27209033345876adfc2f84830aedb | scls19fr/openphysic | /python/oreilly/cours_python/solutions/exercice_7_15.py | ISO-8859-1 | 520 | 3.796875 | 4 | [] | no_license | #! /usr/bin/env python
# -*- coding: Latin-1 -*-
def volBoite(x1 =-1, x2 =-1, x3 =-1):
"Volume d'une bote paralllipipdique"
if x1 == -1 :
return x1 # aucun argument n'a t fourni
elif x2 == -1 :
return x1**3 # un seul argument -> bote cubique
elif x3 == -1 :
retu... | true |
f0cd422425bd6f05458644b326b58475e325c808 | inholland-compolab/specto_imaging | /percentage_calculator.py | UTF-8 | 420 | 3.4375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from PIL import Image
#Generate a random image 640x150 with many colours but no black or white
img = Image.open('GOZONE.png')
pixels = img.getdata()
go = len(list(filter(lambda i: i >= 200, pixels)))
total = len(list(filter(lambda i: i >= 0, pixels)))
percentage = (go/total)*100
pr... | true |
87d60e847eb7f1528247ea9cb0d8060178451e69 | pySART/objutils | /objutils/tests/testDwarfExpressions.py | UTF-8 | 5,528 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = "0.1.0"
__copyright__ = """
pyObjUtils - Object file library for Python.
(C) 2010-2016 by Christoph Schueler <github.com/Christoph2,
cpu12.gems@googlemail.com>
All Rights Reserved
This program is free so... | true |
60eed5b724f0b4881fac70d1fea793e5531c208c | daniel-reich/ubiquitous-fiesta | /Sf7iS6JhA7nadm6CR_7.py | UTF-8 | 200 | 2.734375 | 3 | [] | no_license |
def divisibility_rule(n):
seq = [1, 10, 9, 12, 3, 4]
A=[]
while n not in A:
A.append(n)
B=[int(x) for x in str(n)][::-1]
n=sum(B[i]*seq[i%6] for i in range(len(B)))
return A[-1]
| true |
6544b8c09e21b6004a1480ff3c5556ccef165906 | nienkelegemaate/rosemary.py | /pancakes.py | UTF-8 | 915 | 3.375 | 3 | [] | no_license | from kitchen import Rosemary
from kitchen.utensils import Pan, Plate, Bowl
from kitchen.ingredients import Flour, Egg, Milk, Butter, Salt
#grab the bowl
bowl = Bowl.use(name='batter')
#add the ingredients (250 grams of flour, salt, 2 eggs, and 500 mL milk) to a bowl and mix
for i in range(2):
egg = Egg.take()
... | true |
517999c7eea1b6fe64084751abec6899532e36f0 | dikopylov/Coursera.ML | /Week 1/Pandas.Programming_Assignment/4.py | UTF-8 | 292 | 3.203125 | 3 | [] | no_license | import pandas
data = pandas.read_csv('titanic.csv', index_col='PassengerId')
data_average = round(data.Age.mean(), 2)
data_median = round(data.Age.median())
print(data_average)
print(data_median)
file = open("4.txt", "w")
file.write(str(data_average) + " " + str(data_median))
file.close() | true |
dd372b030d4fb4b9d32cf4da6d2075b44c93625c | akif88/py-workspace | /AI/tensorflow_gpu_env/tf_board.py | UTF-8 | 1,768 | 2.90625 | 3 | [] | no_license | import tensorflow as tf
import random
graph = tf.Graph()
with graph.as_default():
# Input placeholders
a = tf.placeholder(tf.float32, name="a")
b = tf.placeholder(tf.float32, name="b")
# Perform +, -, *, and / operations
plus = tf.add(a, b, name="a_plus_b")
minus = tf.subtract(a, b, name=... | true |
cb01d8542c935ce9a30bcd5f3df2d3653aa3914b | thecraftman/python-from-scratch | /create_amount.py | UTF-8 | 216 | 3.71875 | 4 | [] | no_license | class simple():
def __init__(self,value):
self.value = value
def add_to_value(self,amount):
self.value = self.value + amount
print("We just added {} to your value".format(amount))
| true |
a911abcaac3d43ee3587a56ed087dc1f0f9620fe | HongguLiu/AutoEncoder_Pytorch | /train_mnist.py | UTF-8 | 1,610 | 2.609375 | 3 | [] | no_license | import torch
import torchvision
from networks.autoencoders import AutoEncoder_mnist
import pdb
input_dim = 28*28
hidden_dim = 3
num_epoches = 100
batch_size = 128
train_data = torchvision.datasets.MNIST(root="../Non-local_pytorch/mnist", train=True, transform=torchvision.transforms.ToTensor())
test_data = torchvision... | true |
a94cef8bf37520b5b667ec72acf0db5002bc562e | Harshithaiiitn/MAZE-SOLVING | /move_person_down.py | UTF-8 | 2,384 | 2.765625 | 3 | [] | no_license | def test_move_person_down():
assert move_person_down('b',[['F', 'X', 'F', 'F', 'F', 'X'],
['g1', 'F', 'F', 'F', 'F', 'e'],
['F', 'b', 'F', 'F', 'F', 'F'],
['X', 'F', 'g2', 'F', 'F', 'X'],
['F', 'X', 'F', 'F', 'F', 'F... | true |
47aee6b82667420131cdf7c6880fbdda1a69b264 | toyaji/pythonstudy | /OpenCV/Histogram.py | UTF-8 | 425 | 2.546875 | 3 | [] | no_license | from os.path import expanduser
import cv2
import numpy as np
from matplotlib import pyplot as plt
image = cv2.imread(expanduser(r'~\pictures\maxresdefault.jpg'))
hist = cv2.calcHist([image], [0], None, [256], [0,256])
plt.hist(image.ravel(), 256, [0,256])
plt.show()
color = ('b', 'g', 'r')
for i, c in enumerate(col... | true |
7c056f6c80a098220e36a7a8f0b2e3e4c33a04cc | marioacc/dataStructuresAndAlgorithmsRanceD.Necaise | /structures/linearmap.py | UTF-8 | 1,557 | 3.6875 | 4 | [] | no_license | class Map:
def __init__(self):
self._entryList= List()
def __len__(self):
return len(self._entryList)
def __contains__ (self, key):
ndx = self._findPosition(key)
return ndx is not None
def add(self, key, value):
ndx = self._findPosition(key)
if ndx is n... | true |
b8d7a9ed42eb981c3a4989b7c32b5608f31e9542 | uuuno/doodle | /atcoder/beginner/011/b.py | UTF-8 | 136 | 3.296875 | 3 | [] | no_license | # -*- coding:utf-8 -*-
s = list(input())
s[0] = s[0].upper()
for i, str in enumerate(s[1:]):
s[i+1] = str.lower()
print(''.join(s))
| true |
e23119b2206a41f22e2f52ed4f42b008c33eb2f6 | jwc0906/Genetic-Algorithm | /genetic_search_algorithm.py | UTF-8 | 2,638 | 2.703125 | 3 | [] | no_license | # 최적의 sequence
import numpy as np
#np.array([])
def sampling_tf(true_p, num):
f_t=np.array([False, True])
idx= np.random.choice(2, num, p= [1-true_p, true_p])
idx_ft=f_t[idx]
return idx_ft
# y_hat, input of model, output of model 의 데이터타입은 모두 numpy array (float)
def gen_search(model, y_hat, x_len, ep... | true |
4c874d0bab17a69f7e3f02a255e1b832d76f94e8 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_34/546.py | UTF-8 | 811 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python
import re
f = open('A-large.in','r')
lines2 = []
lines = f.xreadlines()
for line in lines:
line = line.splitlines()[0]
line = line.replace('(','[')
line = line.replace(')',']')
lines2.append(line)
del lines
firstLine = lines2[0]
l1 = firstLine.split(" ")
len1 = int(l... | true |
41fb6959e1a0fb5c4b5469ac87f8745db978d569 | Hildayutami/tentara | /tugas3.py | UTF-8 | 5,338 | 3.140625 | 3 | [] | no_license | class dataOperasi:
def __init__(self, operasi, sulit):
self.operasi = operasi
self.sulit = sulit
def __str__(self):
return ("operasi "+self.operasi+self.sulit)
class dataTentara:
def __init__(self, nama, umur, kekuatan):
self.nama = nama
self.umur... | true |
ab0e80e4e79e7358177af08f8d72c7dbd9843e3a | michaelChen07/studyPython | /cn/homework/week4/checkPassword.py | UTF-8 | 741 | 4 | 4 | [] | no_license | #encoding=utf-8
#检测密码强度
#c1 : 长度>=8 c2: 包含数字和字母 c3: 其他可见的特殊字符
# 强:满足c1,c2,c3 中: 只满足任一2个条件 弱:只满足任一1个或0个条件
import string
def checkPassword(s):
c1=c2=c3=0
if len(s) >= 8:#判断密码长度
c1=1
for i in s:
if i.isalnum():#判断密码是否包含数字和字母
c2=1
if i in string.punctuation:#判断密码是否包含其他可见的特... | true |
7aa8914ab66fe26fc960e0a4c718980d7fd8f589 | odnaks/Pandas | /sber/check_inn.py | UTF-8 | 3,179 | 2.515625 | 3 | [] | no_license | import pandas as pd
import numpy as np
result = pd.DataFrame(columns=['Файл', 'ИНН'])
xls = pd.ExcelFile("perech.xlsx")
sheet_to_df_map = {}
k = 0
flag = 0
for sheet_name in xls.sheet_names:
if (flag == 0):
data_ref = xls.parse(sheet_name)
col_inn = data_ref['ИНН']
list_inn = col_inn.tolis... | true |
3e08dec8a0e3aa7317edc6c106d3495486dbc051 | ksayee/programming_assignments | /python/CodingExercises/CountSingleValuedSubTreesBinaryTree.py | UTF-8 | 4,962 | 4.40625 | 4 | [] | no_license | '''
Find Count of Single Valued Subtrees
Given a binary tree, write a program to count the number of Single Valued Subtrees. A Single Valued Subtree is one in which all the nodes have same value. Expected time complexity is O(n).
Example:
Input: root of below tree
5
/ \
1 5
... | true |
5e603c800893f0b685fc5baadd9ff1f52bf5d997 | gowthamkuntumalla/Codes_for_Gas_Dynamics | /ME673_assgn2_code.py | UTF-8 | 1,868 | 3.265625 | 3 | [] | no_license | #!/usr/bin/python
'''
Python code for Numerical assignment 2, ME 678
Written by Gowtham Kuntumalla, 140100091
Fanno flow analysis.
Both subsonic and supersonic inlet conditions are considered.
M, P, T are the required properties
'''
import matplotlib.pyplot as plt
import numpy as np
import math
from scipy.optim... | true |
4ddccb7700415d904737a9f2b71cc046d15c0c9c | dreamway/pytorch-retinanet | /data/query_file_exists.py | UTF-8 | 637 | 2.875 | 3 | [] | no_license | import os
import shutil
root_dir = '/home/jingwenlai/data/voc/VOCdevkit/VOC2012/JPEGImages'
def query_file(filename):
filename = os.path.join(root_dir,filename)
if os.path.exists(filename):
return True
return False
def load_and_query(filename):
val_file = open(filename,'r')
for line in... | true |
cd6cceca1a5235050094b3664966ae0d20ea118b | MrHamdulay/csc3-capstone | /examples/data/Assignment_2/lkxant002/question2.py | UTF-8 | 2,349 | 3.53125 | 4 | [] | no_license | #Assignment 2
#Question 2
#LKXANT002
print("Welcome to the 30 Second Rule Expert")
print("------------------------------------")
print("Answer the following questions by selecting from among the options.")
yes="yes"
no="no"
ans1=input("Did anyone see you? (yes/no)\n")
if ans1==yes:
ans2=input("Was i... | true |
b5634667a661983f94b3673bba042bb8d3b1a162 | yanyuechuixue/PTAInference | /code/sampling/runCPNest.py | UTF-8 | 1,652 | 2.546875 | 3 | [] | no_license | import numpy as np
import cpnest.model
import hModelCircular
# ranges on the priors
def priorBounds():
logno = [-20.0,3.0]
beta = [-2.0,7.0]
gamma = [0.2,5.0]
alpha = [-3.0,3.0]
delta = [-1.0,2.0]
priors = [logno,beta,gamma,alpha,delta]
return priors
class NANOGravResult(cpnest.m... | true |
db98c3b46ad5c2cec1bb73c6dbb0e55a1ed674b5 | img14/Programs_Public | /ClassPrograms/PerceptronLearning/p5.py | UTF-8 | 5,230 | 3.140625 | 3 | [] | no_license | '''
Test majority accuracy with decision tree
'''
import csv
import math
import random
import numpy
from numpy import *
def majority(lis):
s = 0
for i in lis:
s += int(i)
if s > len(lis)/2:
return 1
else:
return 0
csvfile = open('data1.csv', 'w')
writer = csv.writer(csvfile)
row = ["Label", "B1", "B2", "B3"... | true |
ae33a6814d89e7f0ffff78971bad7a8a1d2e69c8 | Luskinnn28/Sete-Exerc-cios-de-fixa-o | /Exercício 1.py | UTF-8 | 553 | 4.53125 | 5 | [] | no_license | #1) Faça um programa que insira um valor em reais, e faça ele converter o valor para dólar,mostrando quantos
# dólares podem ser comprados com aquela quantia. (Valor para ser usado do dólar no exercício: 5.30)
print('RESOLUÇÃO DA 1')
ValorEscolhido = float(input("Digite o valor que você quer converter para dolar"))
... | true |
b7c41158bfd96825b78eced3c734442564f01e90 | wengzhenqi/python | /tcp_serv.py | UTF-8 | 1,050 | 2.828125 | 3 | [] | no_license | import socket
host = '' # 表示0.0.0.0
port = 12345
addr = (host, port)
s = socket.socket() # 默认创建TCP套接字
# 程序执行结束后,操作系统默认会保留套接字1分钟,在1分钟内无法再次使用相同的套接字
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # 取消1分钟限制
s.bind(addr) # 绑定地址到套接字
s.listen(1) # 启动监听过程 netstat -tlnp | grep :12345
while True:
try:
... | true |
1d429b2e0b48021574dd38bbb07bc104191646b1 | flaviobarros/Stopwatch | /stopwatch.py | UTF-8 | 1,945 | 3.84375 | 4 | [] | no_license | # template for "Stopwatch: The Game"
# import modules
import simplegui
import random
# Global state
time = 0
score = 0
attempts = 0
# define helper function format that converts time
# in tenths of seconds into formatted string A:BC.D
def format(time):
"""Format state string."""
global state
minutos = ti... | true |
37d1516f1c5402fe4ec7bec88bead9ff8a13cd66 | andysitu/algo-problems | /leetcode/200/137_single_number_2_iterative_sum_nonconstantspace.py | UTF-8 | 288 | 2.78125 | 3 | [] | no_license | class Solution:
def singleNumber(self, nums: List[int]) -> int:
s = 0
nset = set()
for n in nums:
s += n
if n not in nset:
nset.add(n)
for n in nset:
s -= (n*3)
return -(s//2) | true |
4f896ed51678f1e7ffa79f9c77de93676ccfc8bc | kotsky/programming-exercises | /String/String Rotation.py | UTF-8 | 973 | 4.28125 | 4 | [] | no_license | ''' Check, if 2nd string is rotated based on 1st string
string1 = 'waterbottle'
string2 = 'erbottlewat'
print(stringRotation(string1, string2)) # => True
The idea:
1. Check if string2 contains preffix of string1.
2. For each such prefix, check other letters in
the same order as origin.
'''
# O(s1 * (s... | true |
e999554daf0d50c37916a382ab4858b3d7ac9205 | splasky/jit-construct | /python/interpreter.py | UTF-8 | 2,602 | 3.03125 | 3 | [
"MIT",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | #! /usr/bin/python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
# Last modified: 2017-08-27 22:38:10
import sys
class Brainf_VirtualMachine(object):
ByteCode = {'>', '<', '+', '-', '.', ',', '[', ']'}
def __init__(self):
self.__instructions = {
'>': self.__advance,
'<': self.__dev... | true |
2d6bb3d2225fa4ff9bb63d120cdc7958ca640824 | IL-Collection/BangalASR | /bnasr/utils.py | UTF-8 | 3,543 | 3.375 | 3 | [
"MIT"
] | permissive | '''Contain utility code used in both training and inferance time'''
import tensorflow as tf
class VectorizeChar:
def __init__(self, unique_chars, max_len=50):
'''Initialize vectorize char object
Args:
unique_chars: list of unique charaster used
max_len: int, maximum lengt... | true |
504fc5f1de7000112e674cd4824bb12b71ce9bd3 | ghanas/senior-design | /Scripts/DataScripts/getInterestPoint.py | UTF-8 | 2,426 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python
import os
import sys
import csv
import argparse
import math
#Argparse ActionClass check extension
def CheckExt(choices):
class Act(argparse.Action):
def __call__(self,parser,namespace,fname,option_string=None):
ext = os.path.splitext(fname)[1][1:]
if ext not in ch... | true |
d3816b1f1ce22bd08657eedf4c72c790d56384c6 | kamit17/Python | /Practice Python/Graph.py | UTF-8 | 294 | 3.359375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 20 13:20:57 2018
@author: Maverick
"""
#importing the required module
import matplotlib.pyplot as plt
# x axis values
x = [1,2,3]
y = [2,4,1]
plt.plot(x,y)
plt.xlabel('x-axis')
plt.ylabel('y-axis')
plt.title ('My first graph!')
plt.show() | true |
70aa4e0ae6a02687a54c05f5cf9cd7d8b334db62 | SaadAhmad123/myCodeRepo | /python/knapSackGreedyAlgo.py | UTF-8 | 1,306 | 3.78125 | 4 | [
"Apache-2.0"
] | permissive | '''
The greedy algorithm follows the algorithm:
while knapsack is not full
add the "best" possible element to it.
To use the implementation below the list should be
a list of objects with following functions.
- getValue() -----> this function will be maximized for all the elements in the list
... | true |
0b87c2faa042d2faea17cada66b5fc14d4e82b16 | IvanWoo/coding-interview-questions | /puzzles/longest_consecutive_sequence.py | UTF-8 | 1,800 | 3.609375 | 4 | [] | no_license | # https://leetcode.com/problems/longest-consecutive-sequence/
"""
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Follow up: Could you implement the O(n) solution?
Example 1:
Input: nums = [100,4,200,1,3,2]
Output: 4
Explanation: The longest consecutive elemen... | true |
202daf4993027359d2a5e320f1a0d5fdc7b3481f | skirdapa/StepikPythonEducation | /Programming on Python [Base Course]/3 week/Dataset Qiuz/students_list.py | UTF-8 | 2,626 | 3.84375 | 4 | [] | no_license | """
Имеется файл с данными по успеваемости абитуриентов.
Он представляет из себя набор строк, где в каждой строке записана следующая информация:
Фамилия;Оценка_по_математике;Оценка_по_физике;Оценка_по_русскому_языку
Поля внутри строки разделены точкой с запятой, оценки — целые числа.
Напишите программу, которая счит... | true |
8aa1033ee861f5970e0cd575f44e8fe32eea3161 | chrisjluc/Coding-challenges | /practice/quora/upvotes.py | UTF-8 | 2,477 | 3.21875 | 3 | [] | no_license | # Christopher Luc
# https://www.quora.com/challenges
def solve(N, K, A):
next_non_increasing = [0] * N
next_non_decreasing = [0] * N
for i in range(1, N):
if A[i] > A[i - 1]:
next_non_decreasing[i] = i
if A[i] < A[i - 1]:
next_non_increasing[i] = i
a = N
b... | true |
f65b70e2b113284fe629fb559c930025c39360f1 | atulkumar-mittal/cp | /codeforces/ladder1/chat_room_hello.py | UTF-8 | 1,145 | 3.53125 | 4 | [] | no_license | # s1 = input()
# s2 = 'helpo'
# i = 0
# j = 0
# while i < len(s1) and j < 5:
# if s1[i] == s2[j]:
# while s1[i+1] == s2[j]:
# i += 1
# j += 1
# else:
# j = 0
# i += 1
# if j == 5:
# print('YES')
# else:
# print('NO')
#
def freq_method(s1):
s2 = 'hello'
s1... | true |
cbc023ef323bb515a4664660cbfd13f582bbdde6 | giraycan/NetScanner | /Man-in-the-middle.py | UTF-8 | 825 | 2.8125 | 3 | [] | no_license | import scapy.all as scapy
import optparse
def get_input():
parser=optparse.OptionParser()
parser.add_option("-r","--radar",dest="scanner_ip",help="input scanner ip example:10.0.2.0/24")
(user_input,arguments) = parser.parse_args()
if not user_input.scanner_ip:
print("Enter IP Address")
retur... | true |
91c294213615496068d74b023ad28a0b57046022 | cy-2224/AI_first_contact | /Deep Learning Course in NetEase/Deep Learning/Fifth Class/Week1/mainwork2.py | UTF-8 | 2,400 | 2.65625 | 3 | [] | no_license | import numpy as np
from utils import *
import random
from di import *
data = open('dinos.txt', 'r').read()
data= data.lower()
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
# print('There are %d total characters and %d unique characters in your data.' % (data_size, vocab_size))
char_to_ix = { c... | true |
e3fd9c6e27f5edbf2c69d5c09270867f66c9ca89 | BaoAdrian/interview-prep | /data-structures/binary-heap/binary_heap.py | UTF-8 | 2,872 | 4.3125 | 4 | [] | no_license | """
BinaryHeap: Implementation of the Binary Heap represented
by a list of nodes given the maintainence of a complete
binary tree.
O(logn) insertion and removal
"""
class BinaryHeap:
def __init__(self):
self.heap_list = [0]
self.size = 0
def insert(self, node):
"""
insert: In... | true |
73f4cc72f969905f1cbe26a3e65a71eca74392a6 | emmalieb/SALSA | /salsa/DataQuery.py | UTF-8 | 1,416 | 2.984375 | 3 | [] | no_license | """
Author: Emma Lieb
"""
'''Function to create a URL that queries the solar data from a given dataset on LISRD
Parameters:
wavelengthLow, wavelengthHigh - wavelength range given by user to limit results, if they did not specify a solar dataset name it is used to find the dataset name
timeLow, timeHigh - ti... | true |
9d4fb8e8f34a57ebafe5de6375c059651d871644 | Smeilz/BlockfolioTerminal | /blockfolio.py | UTF-8 | 4,810 | 2.8125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import json
import requests
from prettytable import PrettyTable
class BlockFolio(object):
API_TOKEN = "INSERT TOKEN HERE"
API_URL = "https://api-v0.blockfolio.com"
USER_AGENT = {'User-Agent':'okhttp/3.6.0'}
PORTFOLIO = None
COINFOLIO ... | true |
c3aa76f010040a9b1ae3f56dfbfa93986fa1fb81 | tezy/mogu_embedding | /tests/data_disp.py | UTF-8 | 1,527 | 2.90625 | 3 | [] | no_license | import os
import numpy as np
import matplotlib.pyplot as plt
data_dir = '/home/tze'
file = 'attr_key_counts.txt'
def attr_key_freq():
attr_freq_list = []
with open(os.path.join(data_dir, file), 'r') as f:
for line in f:
attr, freq = line.strip().split(':')
attr_freq_list.appe... | true |
0955db9518ec401750ba1736b1819361d8b9aa98 | mhinojosa24/core_data_structures | /strings.py | UTF-8 | 3,276 | 4.1875 | 4 | [] | no_license | from helper import find_pattern
def contains(text, pattern):
"""Return a boolean indicating whether pattern occurs in text."""
assert isinstance(text, str), 'text is not a string: {}'.format(text)
assert isinstance(pattern, str), 'pattern is not a string: {}'.format(text)
# time complexity: O(n) => goe... | true |
432177677e0f1fcd882cf464da0bfe7ebc8b1f2c | yanxurui/keepcoding | /python/algorithm/leetcode/72.py | UTF-8 | 1,050 | 3.515625 | 4 | [] | no_license | class Solution(object):
def minDistance(self, word1, word2):
"""
:type word1: str
:type word2: str
:rtype: int
"""
m = len(word1)
n = len(word2)
table = [[0 for j in range(n+1)] for i in range(m+1)]
for i in range(m+1):
table[i][0] ... | true |
33a183ff496b40e5937a417c9b0ed51a8d43cabe | gentlman2006/SCADA-Profinet_Network-Attack-1 | /MITM_Lib/parse_config.py | UTF-8 | 6,193 | 2.578125 | 3 | [] | no_license | __author__ = 'Nicholas Rodofile'
from portScan import *
import xml.etree.ElementTree as ET
file = 'mitm_conf.xml'
tree = ET.parse(file)
root = tree.getroot()
from xml.dom import minidom
def format_xml(elem):
"""Return a pretty-printed XML string for the Element.
http://pymotw.com/2/xml/etree/ElementTree/... | true |
eb2dced80f989a9c922683ca149b9734d85d59ed | Hopw06/Python | /Python_Deep_Dive/Part 2/2.Sequences/7.In-PlaceConcatenationAndRepetition.py | UTF-8 | 856 | 4.15625 | 4 | [] | no_license | ## In-Place Concatenation ##
l1 = [1, 2, 3, 4]
l2 = [5, 6]
print(id(l1), l1)
print(id(l2), l2)
l1 = l1 + l2
print(id(l1), l1) # new object
l1 = [1, 2, 3, 4]
l2 = [5, 6]
print(id(l1), l1)
print(id(l2), l2)
l1 += l2
print(id(l1), l1) # same object
# It work with other iterables as well:
l1 = [... | true |
b79a7797ef14e6d6f89c489889cb50c17d74b463 | vlampos/fludetector-flask | /tests/models_test.py | UTF-8 | 3,018 | 2.609375 | 3 | [] | no_license | from flask import Flask
from fludetector.models import GoogleLog, Model, ModelScore, db
from sqlalchemy.exc import IntegrityError
import unittest
import datetime
class ModelsTest(unittest.TestCase):
@staticmethod
def create_app():
app = Flask(__name__)
app.config['TESTING'] = True
app... | true |
d64ec8d7e4241864751b1fe98792ff9189bd870b | vrushti-mody/Leetcode-Solutions | /All_Paths_From_Source_To_Targetpy | UTF-8 | 953 | 3.828125 | 4 | [] | no_license | # Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order.
# The graph is given as follows: the nodes are 0, 1, ..., graph.length - 1. graph[i] is a list of all nodes j for which the edge (i, j) exists.
class Solution(object):
def __init__(... | true |
fe07cec8871253ac5b7d088372810b3d6c6adf9f | efrei-paris-sud/n-printer | /src/start.py | UTF-8 | 1,832 | 2.6875 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
from Adafruit_Thermal import *
import RPi.GPIO as GPIO
import subprocess, time, Image, socket
printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5)
buttonPin1 = 12
ledPin1 = 6
ledPin4 = 26
#initialisation
GPIO.setm... | true |
6aa703ea5fa183747c53a427ad79c2819e6af803 | angelranjel/SI206_Final_Project | /GeniusAPI.py | UTF-8 | 8,520 | 2.78125 | 3 | [] | no_license | #
# Project Partners: Hamza Asad, William Luna, Angel Ranjel
# Student ID's: 45662901, 74953405, 44945284
# UMich Email: asadh@umich.edu, lunawill@umich.edu, aranjel@umich.edu
import sys
import spotipy
import spotipy.util as util
import requests
import unittest
import sqlite3
import json
import... | true |
78a2db0be788b2e6dc2866aabfae085c0f1a60b8 | henrysky/milkyway_plot | /mw_plot/__init__.py | UTF-8 | 1,318 | 2.671875 | 3 | [
"MIT"
] | permissive | try:
import bokeh
_BOKEH_LOADED = True
except ImportError:
_BOKEH_LOADED = False
else:
from mw_plot.mw_plot_bokeh import *
from mw_plot.mw_plot_matplotlib import *
from pkg_resources import get_distribution
from astropy.coordinates import SkyCoord, ICRS
import astropy.units as u
import numpy as np
ver... | true |
42c763cc8d8a58283444238847b0459458e55225 | kevinl120/maliciousfilterproxy | /history.py | UTF-8 | 2,845 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Analyzes Chrome history and populates MongoDB
"""
import ai
import os
import sqlite3
from pymongo import MongoClient
from shutil import copyfile
print("machine learning...")
vectorizer, lgs = ai.TL()
def populateMongoDB():
""" Top level function to be called by... | true |
31b9552487eb75c64d032f8b449e5a612ba803c3 | betodealmeida/shillelagh | /src/shillelagh/functions.py | UTF-8 | 1,817 | 2.640625 | 3 | [
"MIT"
] | permissive | """
Custom functions available to the SQL backend.
"""
import json
import sys
import time
from typing import Any, Dict, List, Type
from shillelagh.adapters.base import Adapter
from shillelagh.lib import find_adapter
if sys.version_info < (3, 10):
from importlib_metadata import distribution
else:
from importli... | true |
8287bdbbba3e53e20643daf926d6c898531a63e5 | tsaoman/Exercise | /Python/wordbrain.py | UTF-8 | 388 | 3.3125 | 3 | [] | no_license | import enchant
dic = enchant.Dict("en_US")
alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
#n = 10 #int(raw_input("Enter length of word: "))
words = []
first = 'b'
for i in alphabets:
for j in alphabets:
if dic... | true |
213498b62d6fecc6398cad9242897c8664e75708 | 0x0400/LeetCode | /p7.py | UTF-8 | 472 | 3.03125 | 3 | [] | no_license | # https://leetcode.com/problems/reverse-integer/#/description
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
negative = -1 if x < 0 else 1
x = abs(x)
rst = 0
while True:
x, remainder = divmod(x, 10)
... | true |
8f6eaa56b480ddb36d6d8afd6baf4d4538e5ea89 | unmateo/7506-TP | /src/tp1/lab/caracteristicas_inmueble.py | UTF-8 | 16,541 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# ## Campos involucrados
#
# - tipodepropiedad
# - antiguedad
# - habitaciones
# - banos
# - metroscubiertos
# - metrostotales
#
# ## Hipótesis
#
# - En las zonas urbanas debería haber mayor cantidad de apartamentos que cualquier otro tipo de propiedad
# - Si consideramos cara... | true |
31681c38e16b39ba467d4e0368d4391b95d205b5 | Gennki/Machine-Learning-Practice | /test/Mongo.py | UTF-8 | 4,415 | 3.1875 | 3 | [] | no_license | import pymongo
# 创建数据库,如果数据库已经存在的话,则不会再被创建,collection(集群)同样如此
myClient = pymongo.MongoClient("mongodb://localhost:27017/")
db = myClient["test"] # 创建数据库,当创建collection并插入数据后才会真正创建
col = db['table1'] # 创建当创建collection并插入数据后才会真正创建,当插入数据后才会真正创建
# # =============================================插入一条数据====================... | true |
6846770074b3bc4e8a34a49d8a4bb04ca8d5c6c7 | slehar/fourierinteractive | /TestProgs/TestFileDialog.py | UTF-8 | 553 | 2.890625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
TestFileDialog.py
From http://stackoverflow.com/questions/17435360/matplotlib-figures-not-working-after-tkinter-file-dialog
Created on Wed Sep 28 08:20:23 2016
@author: slehar
"""
import Tkinter, tkFileDialog
import pylab
root = Tkinter.Tk()
print 'root = %r'%root
root.withdraw()
file_p... | true |
84a357aaa525716cef0eed6366fc901438100390 | jiggum/c-compiler | /visitor/write_visitor.py | UTF-8 | 5,900 | 2.84375 | 3 | [] | no_license | class WriteVisitor:
def __init__(self, dead_code_elimination=False):
self.s = ''
self._indent = 0
self.dead_code_elimination = dead_code_elimination
def __str__(self):
return self.s
def indent(self):
self._indent += 1
def unindent(self):
self._indent -= 1
def get_indent_str(self):
... | true |
98e6fe4c6db0c6237982720df9bbd8648d3ba002 | JuliansPolymathExplorations/Minimalistic-Eventbright-JSON-API | /src/event_data.py | UTF-8 | 3,384 | 3.421875 | 3 | [
"MIT"
] | permissive | # Last revised 7/21/19
# Class "EventData", providing an object to manage the data about the Events
# MIT License
# Copyright (c) 2019 Julian A. West
import json
class EventData:
"""
Object to manage the data about the Events.
Note: except for import from a JSON text file, this class deals with P... | true |
658a671842109b34b1482ea5e1ae703c48cbc224 | zpoint/Reading-Exercises-Notes | /high_peformance_python/matrix & iterator/numpy_diffusion.py | UTF-8 | 714 | 3.09375 | 3 | [] | no_license | import numpy as np
import time
np.roll([1,2,3,4], 1) #array([4,1,2,3])
np.roll([[1,2,3],[4,5,6]], 1, axis = 1) #array([[3, 1, 2], [6, 4, 5]])
grid_shape = (1024, 1024)
def laplacian(grid):
return np.roll(grid, +1, 0) + np.roll(grid, -1, 0) + np.roll(grid, +1, 1) + np.roll(grid, -1, 1) -4 * grid
def evolve(grid, ... | true |
fb64a3dd9e113b46d52e293399fd70abd467d48d | wjdrmrgns/DRILL | /07-1/move_point.py | UTF-8 | 1,235 | 2.96875 | 3 | [] | no_license | from pico2d import *
from random import randint
KPU_WIDTH, KPU_HEIGHT = 1280, 1024
def handle_events():
global running
global x, y
events = get_events()
for event in events:
if event.type == SDL_QUIT:
running = False
elif event.type == SDL_MOUSEMOTION:
x, y = e... | true |
a0669731e36b4afb648f67245a9945d17d8e09fc | kimgahoo/flask-pybo | /pybo/views/main_views.py | UTF-8 | 1,118 | 2.984375 | 3 | [] | no_license | from flask import Blueprint, url_for ## render_template 화면구성인데, url_for를 쓰면서 삭제하네????
from werkzeug.utils import redirect ## werkzeug 대체 뭐하는놈?
bp = Blueprint('main', __name__, url_prefix='/')
# (블루프린트 객체의)이름, 모듈명, url프리픽스 값을 전달해야함
# main은 , > 함수명으로 url을 찾아주는 > url_for 함수에서 사용예정
# ulr_prefix 는 접두어 ur... | true |
50d6205d9fdc92ee6c6f0021a433f4a9350a00aa | patrocinio/rediswork | /test_redis_driver.py | UTF-8 | 5,808 | 2.96875 | 3 | [] | no_license | """
testdriver.py is a collection of functions in order to test the
behavior of Redis, deployed in an HA environment inside a Docker
Datacenter Cluster.
"""
__author__ = "Chris King"
__email__ = "chris.king@kilncode.com"
__owner__ = "MetLife"
# Global Imports
import redis
from fabric.api import *
import unittest
im... | true |
1705447cdf8a86c3e14037e194857686d2c3acbe | galileo15640215/atcoder | /abc009b.py | UTF-8 | 92 | 2.84375 | 3 | [] | no_license | n = int(input())
A = sorted(set([int(input()) for _ in range(n)]), reverse=True)
print(A[1]) | true |
f06d17247e7019b058ca450709e00c69bae7f8d1 | CreativeCodingLab/DarkSkyVis | /python/vtkTest.py | UTF-8 | 5,105 | 2.671875 | 3 | [] | no_license | import vtk
import time
import numpy as np
import sdfpy as sdf
class SDFLoader(object):
"""docstring for SDFLoader"""
def __init__(self, filename, isCoMoving=False):
super(SDFLoader, self).__init__()
self.filename = filename
self.isCoMoving = isCoMoving
self.initSDF()
def in... | true |
76e56ec041f3b49135642828d767ca13ac54f923 | fiercool/TheLonelyDiscordBot | /commands/dog.py | UTF-8 | 1,008 | 2.765625 | 3 | [] | no_license | from commands.base_command import BaseCommand
import requests
import discord
class Dog(BaseCommand):
def __init__(self):
description = "gets a random dog from some bad api that has bad dogs"
params = None
super().__init__(description, params)
async def handle(self, params, message, cli... | true |
4a17791a082d919d4ae8b70267a23c229cb4a250 | kentkwu/dotfiles.py | /dotfiles.py | UTF-8 | 7,930 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env python
import argparse
import os
import shutil
import errno
import sys
def copy(dotfile, home_dir, backups_dir):
"""Copies the dotfile to the the dotfiles_backup directory"""
print 'Copying {} from home directory to {}'.format(dotfile, backups_dir)
try:
shutil.copy2('{}/.{}'.format(h... | true |
95e297571ee1027a218cb69ce32b6615fbb2c093 | saarikabhasi/Data-Structure-and-Algorithms-in-python | /string-processing/spreadsheet-encoding.py | UTF-8 | 261 | 3.453125 | 3 | [] | no_license | def spreadsheet_encoding_column(col_name):
n = len(col_name)
i = 0
res = 0
while i<n:
ord_num = ord(col_name[i])-ord('A') + 1
res += ord_num*(26**((n-1)-i))
i = i+1
return res
print(spreadsheet_encoding_column("A")) | true |
be59b8c9c746909ec27c6db0450d47e383655d73 | troymaclure/SystemSolver | /console/matrixanim.py | UTF-8 | 3,747 | 2.890625 | 3 | [] | no_license | import fcntl
import time
import random
import struct
import sys
import termios
import string
import os
from colorama import init
init(strip=not sys.stdout.isatty()) # strip colors if stdout is redirected
from termcolor import cprint
from pyfiglet import figlet_format
class message(str):
def __new__(cls, text, sp... | true |
40e612dd915b7acea042b83e0879b7c4f62f852b | shreetiranjit/LabWork | /Lab4/list/one.py | UTF-8 | 177 | 3.5625 | 4 | [] | no_license | '''
Write a Python program to sum all the items in a list
'''
def items(list):
sum = 0
for i in list:
sum += i
print(sum)
return sum
items([1,2,3,3,6])
| true |