content stringlengths 7 1.05M |
|---|
lines = open('input','r').readlines()
size_linea = 12
unos = [0,0,0,0,0,0,0,0,0,0,0,0]
for line in lines:
for i in range(size_linea):
if (line[i] == '1'):
unos[i] += 1
media = len(lines)/2
gamma = 0
epsilon = 0
for i in range(size_linea):
if (unos[i] > media):
gamma += 2**(size_... |
# Using flag
prompt = "\nTell me your name, and I will reprint your name: "
prompt += "\nEnter 'quit' to end the program."
active = True
while active:
message = input(prompt)
if message == 'quit':
active = False
else:
print(message) |
# coding=utf-8
#
# @lc app=leetcode id=1122 lang=python
#
# [1122] Relative Sort Array
#
# https://leetcode.com/problems/relative-sort-array/description/
#
# algorithms
# Easy (66.81%)
# Likes: 147
# Dislikes: 12
# Total Accepted: 14.6K
# Total Submissions: 21.9K
# Testcase Example: '[2,3,1,3,2,4,6,7,9,2,19]\n[2... |
print('Numeros pares!!!')
print('=-=' * 15)
for c in range(2, 52, 2):
print(c)
print('=-=' * 15)
print('ACABOU.')
|
class medicamento:
def __init__(self, id, nombre, precio, descripcion, cantidad, rol):
self.id = id
self.nombre = nombre
self.precio = precio
self.descripcion = descripcion
self.cantidad = cantidad
self.rol = rol
def actualizar_datos(self, id, nombre, preci... |
def test_it(binbb, groups_cfg):
for account, accgrp_cfg in groups_cfg.items():
bbcmd = ["groups", "--account", account]
res = binbb.sysexec(*bbcmd)
# very simple test of group names and member names being seen in output
for group_name, members in accgrp_cfg.items():
asser... |
def pattern_eighten(steps):
''' Pattern eighteen
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3
9 8 7 6 5 4
9 8 7 6 5
9 8 7 6
9 8 7
9 8
9
'''
get_range = [str(i) for i in range(1, steps + 1)][::-1]
for i in range... |
#!/usr/bin/env python3
class Album:
""" Class representing an album """
def __init__(self, title):
self.title = str(title)
self.tracks = []
self.coverFile = None
def add(self, track):
self.tracks.append(track)
|
"""
5565 : 영수증
URL : https://www.acmicpc.net/problem/5565
Input :
9850
1050
800
420
380
600
820
2400
1800
980
Output :
600
"""
total_price = int(input())
prices = []
for _ in range(9):
prices.append(int(input())... |
"""
Prácticas de Redes de comunicaciones 2
Autores:
Miguel Arconada Manteca
Mario García Pascual
"""
DS_ADDR = ('vega.ii.uam.es', 8000)
BUFSIZE = 1048576
UDP_SLEEP = 0.05
LISTEN_TIMEOUT = 0.1
LISTEN_SLEEP = 0.1
CONNECT_TIMEOUT = 5
REPLY_TIMEOUT = 5
CONTROL_TIMEOUT = 0.1
CONTROL_SLEEP = 0.1
|
# -*- coding: utf-8 -*-
title = "Edwin's photos"
source = 'pictures'
theme = 'galleria'
author = 'Edwin Steele'
# ----------------
# Image processing (ignored if use_orig = True)
# ----------------
img_size = (1600, 1200)
show_map = True
keep_orig = True
# If True, EXIF data from the original image is copied to the... |
# -*- coding: utf-8 -*-
"""
abide.registry
~~~~~~~~~~~~~~
"""
class PropertyDoesNotExist(AttributeError):
pass
class AbidePropertyRegistry():
"""
Contains the properties that have been registered for persistence.
When a Class is created, the
"""
def __init__(self, *args, **kwargs):... |
# puck_properties_consts.py
#
# ~~~~~~~~~~~~
#
# pyHand Constants File
#
# ~~~~~~~~~~~~
#
# ------------------------------------------------------------------
# Authors : Chloe Eghtebas,
# Brendan Ritter,
# Pravina Samaratunga,
# Jason Schwartz
#
# Last change: 08.08.2013
#
#... |
#
# @lc app=leetcode id=680 lang=python3
#
# [680] Valid Palindrome II
#
# https://leetcode.com/problems/valid-palindrome-ii/description/
#
# algorithms
# Easy (37.22%)
# Total Accepted: 275.1K
# Total Submissions: 737.9K
# Testcase Example: '"aba"'
#
# Given a string s, return true if the s can be palindrome after... |
'''
Module contains basic functions
'''
def number_to_power(number, power):
'''
:param number: number to be taken
:param power:
:return: number to power
>>> number_to_power(3, 2)
9
>>> number_to_power(2, 3)
8
'''
return number**power
def number_addition(... |
def mask_out(sentence, banned, substitutes):
# write your answer between #start and #end
#start
return ''
#end
print('Test 1')
print('Expected:abcd#')
print('Actual :' + mask_out('abcde', 'e', '#'))
print()
print('Test 2')
print('Expected:#$solute')
print('Actual :' + mask_out('absolute', 'ab', '#$... |
def linear_search_recursive(arr, value, start, end):
if start >= end: return -1
if arr[start] == value:
return start
if arr[end] == value: return end
else:
return linear_search_recursive(arr, value, start+1, end-1)
test_list = [1,3,9,11,15,19,29]
print(linear_search_recursive(tes... |
'''
Joe Walter
difficulty: 5%
run time: 0:20
answer: 40730
***
034 Digit Factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
***
O... |
class Config:
"""
:ivar endpoint: url path for docs
:ivar filename: openapi spec file name
:ivar openapi_version: openapi spec version
:ivar title: document title
:ivar version: service version
:ivar ui: ui theme, choose 'redoc' or 'swagger'
:ivar mode: mode for route. **normal** include... |
config = {
"bootstrap_servers": 'localhost:9092',
"async_produce": False,
"models": [
{
"module_name": "image_classification.predict",
"class_name": "ModelPredictor",
}
]
} |
# -*- coding: utf-8 -*-
"""As the name suggests, this file contains (almost?) all the constants we need:
- The tablenames and their web urls
- The county sets
- Column names for all the tables
"""
url_prefix = 'http://www.cdss.ca.gov/inforesources/'
table_url_map = {
'tbl_cf296': url_prefix + 'Resear... |
'''
Have the function SimpleMode(arr) take the array of numbers stored in arr and return the number that appears most frequently (the mode).
For example: if arr contains [10, 4, 5, 2, 4] the output should be 4. If there is more than one mode return the one
that appeared in the array first (ie. [5, 10, 10, 6, 5] sh... |
class Solution:
"""
@param nums: A list of integers
@param k: An integer
@return: The median of the element inside the window at each moving
"""
def medianSlidingWindow(self, nums, k):
# write your code here
pass
|
class Pipe(object):
def __init__(self, *args):
self.functions = args
self.state = {'error': '', 'result': None}
def __call__(self, value):
if not value:
raise "Not any value for running"
self.state['result'] = self.data_pipe(value)
return self.state
def ... |
#code
class Node :
def __init__(self,data):
self.data = data
self.next = None
class LinkedList :
def __init__(self):
self.head = None
def Push(self,new_data):
if(self.head== None):
self.head = Node(new_data)
else:
new_node = Node(new_data)
... |
NONE = 0
HALT = 1 << 0
FAULT = 1 << 1
BREAK = 1 << 2
|
"""
check if 2 strings are anagrams
"""
def anagrams(string1, string2):
if sorted(string1) == sorted(string2):
return True
else:
return False
|
# Pascal's Triangle
# @author unobatbayar
# Input website link and download to a directory
# @author unobatbayar just for comments not whole code this time
# @program 10
# date 27-10-2018
print("Welcome to Pascal's Triangle!" + "\n")
row = int(input('Please input a row number to which you want to see the triangle ... |
class StorageDriverError(Exception):
pass
class ObjectDoesNotExistError(StorageDriverError):
def __init__(self, driver, bucket, object_name):
super().__init__(
f"Bucket {bucket} does not contain {object_name} (driver={driver})"
)
class AssetsManagerError(Exception):
pass
cl... |
class Solution:
def maximizeSweetness(self, sweetness: List[int], K: int) -> int:
low, high = 1, sum(sweetness) // (K + 1)
while low < high:
mid = (low + high + 1) // 2
count = curr = 0
for s in sweetness:
curr += s
if curr >= mid:
... |
"""
good explanation from discussion
my solution is like this: using two pointers, one of them one step at a time.
Another pointer each take two steps. Suppose the first meet at step k,the length of the Cycle is r. so..2k-k=nr,k=nr
Now, the distance between the start node of list and the start node of c... |
taggable_resources = [
# API Gateway
"aws_api_gateway_stage",
# ACM
"aws_acm_certificate",
"aws_acmpca_certificate_authority",
# CloudFront
"aws_cloudfront_distribution",
# CloudTrail
"aws_cloudtrail",
# AppSync
"aws_appsync_graphql_api",
# Backup
"aws_backup_plan",
... |
print('\033[31m-=' * 22)
print('\033[37;1manalisador de lados para formar um triangulo\033[m ')
print('\033[31m-=\033[m' * 22)
a = float(input('primeira reta: '))
b = float(input('segunda reta: '))
c = float(input('terceira reta: '))
if a < b + c and b < a + c and c < a + b:
print('\033[32mpod-se formar triangulo c... |
CREATE_VENV__CMD = b'UkVNIE5lY2Vzc2FyeSBGaWxlczoNClJFTSAtIHByZV9zZXR1cF9zY3JpcHRzLnR4dA0KUkVNIC0gcmVxdWlyZWRfcGVyc29uYWxfcGFja2FnZXMudHh0DQpSRU0gLSByZXF1aXJlZF9taXNjLnR4dA0KUkVNIC0gcmVxdWlyZWRfUXQudHh0DQpSRU0gLSByZXF1aXJlZF9mcm9tX2dpdGh1Yi50eHQNClJFTSAtIHJlcXVpcmVkX3Rlc3QudHh0DQpSRU0gLSByZXF1aXJlZF9kZXYudHh0DQpSRU0gLSB... |
n1 = int(input ('Digite a nota1: '))
n2 = int(input ('Digite a nota2: '))
t = (n1 + n2) / 2
#m = t / 2
print ('A média é {}'.format(t))
|
veiculos = ['Fusca', 'Palio', 'UNO', 'Ferrari', 'HB20']
consumo_carros = []
for i in range(5):
print("Veiculo n°", i + 1, "\nNome: ", veiculos[i])
km_litro = float(input("Km por litro: "))
consumo_carros.append(km_litro)
print("\nRelatório final: ")
for i in range(5):
print(i+1, " - ", veiculo... |
"""
SOURCE: TODO; link github code snippet
"""
class meta:
length = 0
# def __init__(self):
# print self.process("schmidt")
def isSlavoGermanic(self, str):
for each in ["W", "K", "CZ", "WITZ"]:
if (each in str):
return 1;
return 0;
def isVowel(self, wo... |
# Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. Pergunte o valor da casa, o salário do comprador e em quantos anos ele vai pagar. A prestação mensal não pode exceder 30% do salário ou então o empréstimo será negado.
casa = float(input('Valor da casa: '))
salario = float(input('Salár... |
n = int(input())
def sum_input():
_sum = 0
for i in range(n):
_sum += int(input())
return _sum
left_sum = sum_input()
right_sum = sum_input()
if left_sum == right_sum:
print("Yes, sum =", left_sum)
else:
print("No, diff =", abs(left_sum - right_sum)) |
class Monitor(object):
"""
发送文件打印器
"""
def __init__(self, *parameter_list):
"""
TODO
"""
pass
def monitor(self, ditc_info):
"""
iter:可迭代字典
"""
for k, v in ditc_info.items():
if k == "DATA":
print("{:10}: {}... |
#!/usr/bin/env python3 -tt
def doHTML(sd):
header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n <head>\n <p><font size=\"3\"><strong>Description</strong... |
a = int(input())
while(a):
counti = 0
counte = 0
b = input()
for i in b:
if(i=='1'):
counti+=1
elif(i=='2'):
counte+=1
elif(i=='0'):
counte+=1
counti+=1
if(counti>counte):
print("INDIA")
elif(counte>counti):
... |
text = input('Enter the text:\n')
if ('make a lot of money' in text):
spam = True
elif ('buy now' in text):
spam = True
elif ('watch this' in text):
spam = True
elif ('click this' in text):
spam = True
elif ('subscribe this' in text):
spam = True
else:
spam = False
if (spam):
... |
a=input()
b=int(len(a))
for i in range(b):
print(a[i])
|
"""
@author: karthikrao
Test the Polish Expression for its Balloting and Normalized properties.
"""
def test_ballot(exp, index):
"""
Parameters
----------
exp : list
Polish Expression to be tested for its balloting property.
index : int
End point of the Polish Expression to be t... |
print("{:=^60}".format(' Super Progressão Aritmetíca v3.0 '))
termo = int(input('Primeiro Termo: '))
razão = int(input('Razão da PA: '))
#termo = primeiro
n = 1
mais = 1
total = 0
mais = 10
while mais != 0:
total += mais
while n <= total:
print(termo, end=' - ')
termo += razão
n += 1
... |
def second_largest(mylist):
largest = None
second_largest = None
for num in mylist:
if largest is None:
largest = num
elif num > largest:
second_largest = largest
largest = num
elif second_largest is None:
second_largest = num
elif num > second_largest:
second_largest = num
return second_la... |
# ===========
# BoE
# ===========
class HP_IMDB_BOE:
batch_size = 64
learning_rate = 1e-3
learning_rate_dpsgd = 1e-3
patience = 5
tgt_class = 1
sequence_length = 512
class HP_DBPedia_BOE:
batch_size = 256
learning_rate = 1e-3
learning_rate_dpsgd = 1e-3
patience = 2
tgt_cla... |
def get_azure_config(provider_config):
config_dict = {}
azure_storage_type = provider_config.get("azure_cloud_storage", {}).get("azure.storage.type")
if azure_storage_type:
config_dict["AZURE_STORAGE_TYPE"] = azure_storage_type
azure_storage_account = provider_config.get("azure_cloud_storage",... |
"""
Blog app for the CDH website.
Similar to the built-in grappelli blog, but allows multiple authors
(other than the current user) to be associated with a post.
"""
default_app_config = "cdhweb.blog.apps.BlogConfig"
|
backslashes_test_text_001 = '''
string = 'string'
'''
backslashes_test_text_002 = '''
string = 'string_start \\
string end'
'''
backslashes_test_text_003 = '''
if arg_one is not None \\
and arg_two is None:
pass
'''
backslashes_test_text_004 = '''
string = \'\'\'
text \\\\
text
\'\'\'
'''
|
# 1
def front_two_back_two(input_string):
return '' if len(input_string) < 2 else input_string[:2] + input_string[-2:]
# 2
def kelvin_to_celsius(k):
return k - 273.15
# 2
def kelvin_to_fahrenheit(k):
return kelvin_to_celsius(k) * 9.0 / 5.0 + 32.0
# 4
def min_max_sum(input_list):
return [min(input_... |
class Data:
def __init__(self, dia, mes, ano):
self.dia = dia
self.mes = mes
self.ano = ano
print(self)
@classmethod
def de_string(cls, data_string):
dia, mes, ano = map(int, data_string.split('-'))
data = cls(dia, mes, ano)
return data
@staticmethod
def is_date_valid(data_string):
dia, mes, an... |
# Задача 6
# # Найти сумму цифр числа.
number=1029384756
sum=0
while number>0:
sum+=number%10
number=number//10
print(sum) |
# author: Fei Gao
#
# Evaluate Reverse Polish Notation
#
# Evaluate the value of an arithmetic expression in Reverse Polish Notation.
# Valid operators are +, -, *, /. Each operand may be an integer or another expression.
# Some examples:
# ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9
# ["4", "13", "5", "/", "+"] ->... |
ROUTE_MIDDLEWARE = {
'test': 'app.http.middleware.MiddlewareTest.MiddlewareTest',
'middleware.test': [
'app.http.middleware.MiddlewareTest.MiddlewareTest',
'app.http.middleware.AddAttributeMiddleware.AddAttributeMiddleware'
]
}
|
'''首先获取当前目录下所有文件,然后做如下处理:
01 文件名去重复
02 选出文件大于10m的
03 获取到文件的md5值,然后利用这个md5值对文件名进行重命名(其中md5代表一个文件属性)
04 打印出最后的符合条件的所有文件名'''
# import os,hashlib
# class get_file():
# def __init__(self,path):
# self.path=path
# """path 通过传入制定路径,获取路径下的所有文件名字返回一个1维列表"""
# self.file_name=[]
# ... |
"""
* how to use:
to be used you must declare how many parity bits (sizePari)
you want to include in the message.
it is desired (for test purposes) to select a bit to be set
as an error. This serves to check whether the code is working correctly.
Lastly,... |
# file creation
myfile1 = open("truncate.txt", "w")
# writing data to the file
myfile1.write("Python is a user-friendly language for beginners")
# file truncating to 30 bytes
myfile1.truncate(30)
# file is getting closed
myfile1.close()
# file reading and displaying the text
myfile2 = open("truncate.tx... |
"""Load dependencies needed to compile the protobuf library as a 3rd-party consumer."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def protobuf_deps():
"""Loads common dependencies needed to compile the protobuf library."""
if not native.existing_rule("zlib"):
http_archive(
... |
# Copyright 2013 - Mirantis, Inc.
# Copyright 2015 - StackStorm, Inc.
#
# 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
#
# Unl... |
class Solution:
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
if numRows == 0:
return []
ret = [[1]]
for i in range(1, numRows):
tmp = []
for j in range(i + 1):
if j == 0:
... |
# open( filePath , mode )
# filePath:路径 可以绝对路径和相对路径
# mode: w 可写 r 可读 a 追加 r 读取数据
f = open('file/test.txt', 'w')
# write( 内容 )
f.write('hello world\n')
# close() 文件的进程关闭 不然会一直存在内存
f.close()
# mode: a 追加数据
fa = open('file/test.txt', 'a')
fa.write('i am append data\n' * 5)
fa.close()
# read() 读取文件类容
fr = open('f... |
class NamingUtils(object):
'''
Utilities related to object naming
'''
@classmethod
def createUniqueMnemonic(cls, mnem, unitMap):
""" If mnemonic exists in dict appends a _x where x is an int """
result = mnem
if mnem in unitMap:
suffix = 1
while (mn... |
a = {'C', 'C++', 'Java'}
b = {'C++', 'Java', 'Python'}
c = {'java', 'Python', 'C', 'pascal'}
# who known all three subject
u = a.union(b).union(c)
print("Union", u)
# find subject known to A and not to B
i = a.intersection(b)
print("Intersection", i)
diff1 = a.difference(b)
print(a, b, "C-F", diff1)
#find a subjec... |
nk = input().split()
n = int(nk[0])
k = int(nk[1])
r = int(input())
c = int(input())
o = []
z=0
for _ in range(k):
o.append(list(map(int, input().rstrip().split())))
l=[]
p=[]
a=[]
for i in range(n):
l=l+[0]
for i in range(n):
l[i]=[0]*n
l[r-1][c-1]=1
for i in range(len(o)):
l[o[i][0]-... |
name = "generators"
"""
The generators module
"""
|
def eig(a):
# TODO(beam2d): Implement it
raise NotImplementedError
def eigh(a, UPLO='L'):
# TODO(beam2d): Implement it
raise NotImplementedError
def eigvals(a):
# TODO(beam2d): Implement it
raise NotImplementedError
def eigvalsh(a, UPLO='L'):
# TODO(beam2d): Implement it
raise NotI... |
# ex1116 Dividindo x por y
n = int(input())
for c in range(1, n + 1):
x, y = map(float, input().split())
if x > y and y != 0:
divisao = x / y
print('{:.1f}'.format(divisao))
elif x > y and y == 0:
print('divisao impossivel')
if x < y and y != 0:
divisao = x / y
p... |
# Description: Class, Instances, Constructor, Self in Python
"""
### Note
* Class
- A template for creating objects.
- All objects created using the same class will have the same characteristics.
* Object
- An instance of a class.
* Instantiate
- Create an instance of a class.
* Method
- A function... |
# https://leetcode.com/problems/valid-perfect-square
class Solution:
def isPerfectSquare(self, num):
if num == 1:
return True
l, r = 1, num
while l <= r:
mid = (l + r) // 2
if mid ** 2 == num:
return True
elif mid ** 2 < num:
... |
'''
Color Pallette
'''
# Generic Stuff
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
# Pane Colors
PANE1 = (236, 236, 236)
PANE2 = (255, 255, 255)
PANE3 = (236, 236, 236)
# Player Color
PLAYER_COLOR = BLACK
# Reds
RED_POMEGRANATE = (242, 38, 19)
RED_THUNDERBIRD = (217, 30, 24)
RED_FLAMINGO = (239, 72, 54... |
lista = list()
vezesInput = 0
while vezesInput < 6:
valor = float(input())
if valor > 0:
lista.append(valor)
vezesInput += 1
print(f'{len(lista)} valores positivos') |
class Node(object):
def __init__(self, symbol, offset, token=None):
self.symbol = symbol
self.offset = offset
self.token = token
self.children = []
self.parent = None
def append(self, node):
if node.symbol is None or node.symbol.drop:
return
... |
# -*- coding: utf-8 -*-
# This file is generated from NI Switch Executive API metadata version 19.1.0d1
enums = {
'ExpandAction': {
'values': [
{
'documentation': {
'description': 'Expand to routes'
},
'name': 'NISE_VAL_EXPAND_T... |
"""Utility functions."""
def generate_query_string(query_params):
"""Generate a query string given kwargs dictionary."""
query_frags = [
str(key) + "=" + str(value) for key, value in query_params.items()
]
query_str = "&".join(query_frags)
return query_str
|
defterolepta = int(input('Δώσε τον αριθμό των δευτερολέπτων: '))
if defterolepta < 60:
print('Δευτερόλεπτα: ', float(defterolepta), sep='')
elif defterolepta >= 60 and defterolepta < 3600:
lepta = (defterolepta // 60) % 60
defterolepta = defterolepta % 60
print('Λεπτά: ', float(lepta), '\nΔευτερόλ... |
# Click trackpad of first controller by "C" key
alvr.buttons[0][alvr.Id("trackpad_click")] = keyboard.getKeyDown(Key.C)
alvr.buttons[0][alvr.Id("trackpad_touch")] = keyboard.getKeyDown(Key.C)
# Move trackpad position by arrow keys
if keyboard.getKeyDown(Key.LeftArrow):
alvr.trackpad[0][0] = -1.0
alvr.trackpad[0][1... |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def flatten(root: TreeNode) -> None:
"""
Do not return anything, modify root in-place instead.
"""
if not root:
... |
"""
In Python, there are three different numeric types. These are "int",
"float" and "complex".
Documentation - https://www.w3schools.com/python/python_numbers.asp
Below we will look at all three different types.
"""
"""
"int", or integer, is a whole number, positive or negative, without decimals
and has an unlimite... |
class Solution:
def checkInclusion(self, s1: str, s2: str) -> bool:
'''
T: O(n2 * n1 log n1); can be reduced to O(n2 * n1) by using char counter
S: O(n1); can be reduced to O(26) = O(1) by using character counting array
'''
n1, n2 = len(s1), len(s2)
s1 = sorted(s1)
... |
#!/usr/bin/env python3
# MIT License
# Copyright (c) 2020 pixelbubble
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, ... |
# MYSQL_CONFIG = {
# 'host': '10.70.14.244',
# 'port': 33044,
# 'user': 'view',
# 'password': '!@View123',
# 'database': 'yjyg'
# }
MYSQL_CONFIG = {
'host': '127.0.0.1',
'port': 33004,
'user': 'root',
'password': 'q1w2e3r4',
'database': 'yjyg'
} |
"""iCE entities."""
#
# Base entity class
#
class Entity(object):
"""Generic entity.
:type id: str
:type created: datetime.datetime
:type update: datetime.datetime
:type etag: str
"""
def __init__(self, **kwargs):
# MongoDB stuff
self.id = kwargs.get('_id', None)
... |
AUX={
"す,_":"せ:し:す:する:すれ:せよ",
"ず,_":"ざら:ずし:ず:ざる:ざれ:ざれ",
"なり,_":"なら:なり:なり:なる:なれ:なれ",
"不,v,副詞,否定,無界":"ざら:ずし:ず:ざる:ざれ:ざれ",
"且,v,副詞,時相,将来":"んとせ:んとし:んとす:んとする:んとすれ:んとせよ",
"也,p,助詞,句末,*":"なら:なり:なり:なる:なれ:なれ",
"也,p,助詞,提示,*":"なら:なり:なり:なる:なれ:なれ",
"儀,v,助動詞,必要,*":"べから:べく:べし:べき:べけれ:べけれ",
"勿,v,副詞,否定,禁止":"なから:なく:なかれ:なき... |
def cheapest_flour(input1,output1):
a=[]
b=[]
with open(input1,"r") as input_file:
number1=0
for i in input_file.readlines():
a.append(i.split())
b.append(int(a[number1][0])/int(a[number1][1]))
number1+=1
b=sorted(b,reverse=True)
with... |
"""
Cross-validation sampling
-------------------------
This module contains the functions used to crete a a cross validation
division for the data.
TODO
----
Create a class structure to create samplings
Create a class which is able to create a cv object
"""
class Categorical_Sampler:
def __init__(self, point... |
__author__ = "Dimi Balaouras"
__copyright__ = "Copyright 2016, Stek.io"
__license__ = "Apache License 2.0, see LICENSE for more details."
# Do not modify the following
__default_feature_name__ = "DO_NOT_MODIFY"
class AppContext(object):
"""
App Context based on Service Locator Pattern
"""
def __init... |
# config.py
SEED = 42
EXTENSION = ".png"
IMAGE_H = 28
IMAGE_W = 28
CHANNELS = 3
BATCH_SIZE = 30
EPOCHS = 400
LEARNING_RATE = 0.001
CIRCLES = "../input/shapes/circles/"
SQUARES = "../input/shapes/squares/"
TRIANGLES = "../input/shapes/triangles/"
INPUT_FOLD = "../input/"
OUTPUT_FOLD = "../output/"
TRAIN_DATA = "../i... |
# In one of the Chinese provinces, it was decided to build a series of machines to protect the
# population against the coronavirus. The province can be visualized as an array of values 1 and 0,
# which arr[i] = 1 means that in city [i] it is possible to build a machine and value 0 that it can't.
# There is also a numb... |
m = 5
n = 0.000001
# rule-id: use-float-numbers
assert(1.0000 == 1.000000)
# rule-id: use-float-numbers
assert(1.0000 == m)
# rule-id: use-float-numbers
assert(m == 1.0000)
# rule-id: use-float-numbers
assert(m == n)
|
while True:
password = input("Password")
print(password)
if password == "stop":
break
print("the while loop has stopped") |
# wczytanie slow i szyfrow
with open('../dane/sz.txt') as f:
cyphers = []
for word in f.readlines():
cyphers.append(word[:-1])
with open('../dane/klucze2.txt') as f:
keys = []
for word in f.readlines():
keys.append(word[:-1])
# zbior odszyfrowanych slow
words = []
# przejscie po slowac... |
def graph_pred_vs_actual(actual,pred,data_type):
plt.scatter(actual,pred,alpha=.3)
plt.plot(np.linspace(int(min(pred)),int(max(pred)),int(max(pred))),
np.linspace(int(min(pred)),int(max(pred)),int(max(pred))))
plt.title('Actual vs Pred ({} Data)'.format(data_type))
plt.xlabel('Actual')
... |
# https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list
# Python
"""
Insert Node at the end of a linked list
head pointer input could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
s... |
#
# PySNMP MIB module DC-OPT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DC-OPT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:21:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... |
# Вам дано положительное целое число.
# Определите сколько цифр оно имеет.
number = 1233334444555666
str_number = str(number)
print(len(str_number)) |
#
# PySNMP MIB module DGS-6600-STP-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DGS-6600-STP-EXT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:45:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... |
def arithmetic_arranger(problems,calc = False):
if 5 < len(problems):
return "Error: Too many problems."
sOperand1 = sOperand2 = sDashes = sResults = ""
separator = " "
for i in range(len(problems)):
words = problems[i].split()
if(not (words[1] == "+" or words[1] =="-")):
return "E... |
#
# PySNMP MIB module MITEL-ERN (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MITEL-ERN
# Produced by pysmi-0.3.4 at Wed May 1 14:13:10 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.