content stringlengths 7 1.05M |
|---|
class AccountInfo(object):
_LABELS = ('section',
'organization',
'account-group-code',
'account-code',
'account-group-name',
'account-name',
'amount')
def __init__(self):
self.section = None
self.organizat... |
class WitEmulator(object):
def __init__(self):
self.name='wit'
def normalise_request_json(self,data):
_data = {}
_data["text"]=data['q'][0]
return _data
def normalise_response_json(self,data):
print('plain response {0}'.format(data))
return [
{
... |
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def bgcd(a, b):
if b == 0:
return a
if a == 0:
return b
if a & 1:
if b & 1:
return bgcd((a - b) >> 1, b)
else:
return bgcd(a, b >> 1)
else:
if b & 1:
retu... |
# Copyright 2013-2021 Aerospike, 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
#
# Unless required by applicable law or agreed to in writ... |
'''
Doc Header
'''
def test_this1():
assert 1 == 1, "This should never fail"
|
name = 'stackdandelion'
aliases = ['stackdandelions', 'fixdandelionstacking']
fix_dandelion_stacking_fixed = False
async def run(message):
'Fixes dandelion stacking.'
global fix_dandelion_stacking_fixed
if not fix_dandelion_stacking_fixed:
await message.send('Dandelion stacking has been fixed.')
else:
await ... |
# Solution for the problem "Constructing a Number"
# https://www.hackerrank.com/contests/hourrank-25/challenges/constructing-a-number/problem
# Number of test cases
t = int(input())
for x in range(t):
# Number of items. We are not actually using this in our approach
n = int(input())
# We are replacing all... |
name_score = 0
def cal_name_score(n, list_a):
global name_score
name_s = 0
for i in list_a[n]:
name_s += ord(i.lower()) - 96
name_score += name_s * (n+1)
return name_score
if __name__ == '__main__':
with open('p022_names.txt') as f:
name_list = f.readlines()
clear_list = ... |
'''https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/
http://www.youtube.com/watch?v=Ttezuzs39nk
http://courses.csail.mit.edu/6.006/spring11/lectures/lec15.pdf
Algorithm
Following are the detailed steps.
Input: Graph and a source vertex src
Output: Shortest distance to all vertices from src.
If there is a n... |
# Nested For Loop
# User input for number of rows
rows = int(input("Enter the rows:"))
# Outer loop will print number of rows
for i in range(0, rows+1):
# Inner loop will print number of Astrisk
for j in range(i):
print("*",end = '')
print()
# Program to print number pyramid
rows = int(inp... |
# ==============================================
# Hacking : décoder le code romain
# Objectifs:
# - utilisation des boucles
# - utilisation des tests
# ==============================================
#
clef = 0
lettres = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
#lettres = "abcdefghijklmnopqr... |
select_guilds = """select * from servers where discord_id = %s"""
insert_guild = """ INSERT INTO public.servers(
discord_id, discord_name)
VALUES (%s, %s);
"""
select_users = """ select * from public.users where server_id = (select id from public.servers where discord_id = %s) and user_id =... |
class Automovel:
cor = ""
marca = ""
qtdegasolina = 45
def __init__(self, c, m):
self.cor = c
self.marca = m
def abastecerCarro(qtdeLitros):
qtdegasolina = qtdegasolina + qtdeLitros
uno = Automovel("Verde","Fiat")
print(uno)
hondafit = Automovel("Preta", "Honda")
prin... |
class Solution:
def decodeString(self, s: str) -> str:
def dfs(s, i):
res, multi = "", 0
while i < len(s):
if '0' <= s[i] <= '9':
multi = multi * 10 + int(s[i])
elif s[i] == '[':
i, tmp = dfs(s, i + 1)
... |
# cores no terminal
print('\033[0;30;41mteste\033[m')
print('\033[4;33;44mteste\033[m')
print('\033[0;35;43mteste\033[m')
print('\033[0;30;42mteste\033[m')
print('\033[0;30;0mteste\033[m')
print('\033[7;30mteste\033[m')
a = 3
b = 5
print('Os valores são \033[32m{}\033[m e \033[34m{}\033[m!!!'.format(a , b))
nome = '... |
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/test_nbdev_define_in_subfolder/01 define in multiple_nbs 1.ipynb (unless otherwise specified).
__all__ = ['defined_in_multiple_nbs', 'defined_in_multiple_nbs']
# Cell
def defined_in_multiple_nbs():
print("This function was defined on notebook 01")
# Cell
def defi... |
#!/usr/bin/env python
def part_one() -> None:
buffer = [0]
idx = 0
for i in range(1, 2018):
idx = step(buffer, idx)
buffer.insert(idx + 1, i)
idx += 1
print('Part 1: ', buffer[buffer.index(2017) + 1])
def step(buffer: list, start: int) -> int:
steps = 359
return (step... |
data = {
"endpoint": {
"uri": "/reg",
"method": "POST"
},
# kwargs for `requests` to send HTTP request
"kwargs": {
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"data": {
"theme": "每逢佳节你更圆"
}
}
}
|
#page contains functions that locates data about things on the webpage
#add locators
def body_element_locator(browser):
return browser.find_element_by_tag_name('body')
def get_tweets(browser):
return browser.find_elements_by_class_name('tweet-text') |
class WorkflowException(Exception):
pass
class UnsupportedRequirement(WorkflowException):
pass
|
# zop = Zen of python
zop = '''Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality be... |
"""
# PROBLEM 2
Even Fibonacci numbers
Problem 2
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four millio... |
img_width = 48
img_height = 48
img_depth = 1
batch_size = 32
epochs = 500
|
# -*- coding: utf-8 -*-
class PasswordError(Exception):
"""symmetric encrypt wrong password error.
"""
class SignatureError(Exception):
"""asymmetric encrypt wrong signature error.
"""
|
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
occur = {}
count = 0
for i in a:
if i in occur:
count += occur[i] * 2
occur[i] += 1
else:
occur[i] = 1
print(count) |
"""
round
"""
print(round(233.33333))
print(round(233.33333, 2))
print(round(233.33333, -2))
|
class Solution:
def sumOddLengthSubarrays(self, arr: List[int]) -> int:
n = len(arr)
res = 0
for i in range(n):
# i 的左边有i个元素,右边有n-i-1个元素
lo = (i+1)//2
ro = (n-i)//2
le = (i//2)+1
re = (n-i-1)//2 + 1
res += (lo*ro + le*re... |
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
_ER... |
"""
types:
'.' = water
'#' = island
'1' or other number = number square
rules:
squares are connected up,down,right,and left
island sqaure can only have one numbered square
numbered squre can contain itself + island square(s) ex) '2' means itself + 1 island
My thought process:
check 2x2 block of water ex) [i+1][j],[i]... |
img_norm_cfg = dict(
mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5], to_rgb=False)
crop_size = (288, 960)
# KITTI config
kitti_train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', sparse=True),
dict(
type='ColorJitter',
asymmetric_prob=0.0,
bri... |
# utils.py
""" Odds and ends that might be useful in other files."""
# custom exception for a failing regex
class NoGpuError(Exception):
""" No GPU string was found in the file name!
This error is raised when a run is done without GPUs (meaning it uses only CPUs for
Tensorflow predictions, which is, in t... |
maxdepth = 0
def depth(elem, level):
global maxdepth
# your code goes her
# print(elem," :::")
# print(level," [[[]]]")
if (level == maxdepth):
maxdepth += 1
# print(elem)
for child in elem:
# print(child)
depth(child, level + 1)
|
class InvalidKeyType(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
class KeyValueStoreDumpException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs) |
# This file is automatically generated during the generation of setup.py
# Copyright 2020, Caer
author = 'Jason Dsouza <jasmcaus@gmail.com>'
version = '1.7.8'
full_version = '1.7.8'
release = True
contributors = ['Jason Dsouza <jasmcaus@gmail.com>']
|
"""Create Phone Number Kata from Codewars."""
def phone(x):
"""Create the phone number."""
if len(x) < 10:
raise ValueError('List needs to contain 10 numbers')
elif len(x) > 10:
raise ValueError('List needs to contain 10 numbers')
first = x[0:3]
second = x[3:6]
third = x[6:]
... |
# Variables and Functions
# Variable names
names = "Python"
job_title = "Software Engineer"
populated_countries_list = []
# Nonmangling names
_books = {} # variable name to define private
__dict = [] # prevent name mangling with python in-build lib
"""You should use one underscore(_) as a prefix for the internal var... |
# My solution
def merge_lists(a, b):
res = []
a_cur = 0
b_cur = 0
a_min = a[a_cur]
b_min = b[b_cur]
a_done = False
b_done = False
for i in range(len(a) + len(b)):
if (a_min <= b_min or b_done) and (a_cur < len(a)):
res.append(a_min)
a_cur += 1
if (a_cur < len(a)):
a_min = a... |
YOLO = dict()
# Datasets Parameter
YOLO['classes'] = ["aeroplane", "bicycle", "bird", "boat", "bottle"]
YOLO['datasets_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/'
YOLO['anno_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/jinnan_round1_train.json'
YOLO['val_path'] = '/home/... |
'''
Manages the ingestion rollback
File: rollback.py
Contains:
Singleton - metaclass for the Singleton pattern implementation
Rollback - a class storing and executing rollback commands
@author: livia
'''
class Singleton(type):
'''Metaclass to create Singleton classes
_instances - s... |
# coding=utf8
# Entrada
num = int (input("Informe um número inteiro: "))
# Processamento
if num >= 0:
a = num
print("Valor positivo: {0}".format(a))
else:
b = num
print("Valor negativo: {0}".format(b)) |
b = {}
n = int(input())
for i in range(n):
a = int(input())
if a in b:
b[a+2000]= b[a] #костылечек для того чтобы ключик не повторялся
print(b[a])
continue
else:
b[a] = f(a)
print(b[a])
|
"""
Crie um programa que tenha uma tupla com várias palavras (não usar acentos). Depois disso, você deve mostrar, para cada
palavra, quais são as suas vogais.
"""
palavras = ('Palmeiras', 'Flamengo', 'Internacional', 'Gremio', 'Sao Paulo', 'Atletico-MG', 'Atletico-PR', 'Cruzeiro',
'Botafogo', 'Santos', 'Bahia... |
#!/usr/bin/env python3
file_contents = open('in.idf').read().upper()
if 'HVACTEMPLATE' in file_contents:
open('expanded.idf', 'w').write('HI')
open('BasementGHTIn.idf', 'w').write('HI')
open('GHTIn.idf', 'w').write('HI')
open('EPObjects.TXT', 'w').write('HI')
open('RunINPUT.TXT', 'w').write('HI')
... |
BID_VALUE = 'BID_VALUE'
PASS = "PASS"
MIN_BID_VALUE = "MIN_BID_VALUE"
FIRST_ROUND_HONORS_MIN= "FIRST_ROUND_HONORS_MIN"
SECOND_ROUND_HONORS_MIN="SECOND_ROUND_HONORS_MIN"
TRUMP_CARD_ABBREVIATION= "CARD_ABBREVIATION"
|
def quick_sort(ARRAY):
ARRAY_LENGTH = len(ARRAY)
if( ARRAY_LENGTH <= 1):
return ARRAY
else:
PIVOT = ARRAY[0]
GREATER = [ element for element in ARRAY[1:] if element > PIVOT ]
LESSER = [ element for element in ARRAY[1:] if element <= PIVOT ]
return quick_sort(LESSER) +... |
# Python - 3.6.0
def is_triangle_number(number):
if type(number) != int:
return False
n, d = 0, 1
while n < number:
n += d
d += 1
return (number == n) or (number == 0)
|
#!/usr/bin/env python3
class Module:
def __init__(self, name, method, options):
self.name = name
self.run = method
self.hasoptions = options
def processD(self, data, options):
return self.run(data, options)
def process(self, data):
return self.run(data)
def ge... |
"""
This is my first attempt at fibbonaci from memory.
I used cursors similar to how we work with linked lists.
"""
def fib_iterative(n):
prevprev = 0
prev = 1
curr = 0
# base cases
if n == 0:
return 0
if n == 1:
return 0
if n == 2:
return 1
# algorithm
fo... |
def find_matches(s):
s = s + s[0]
m = []
for i in range(0, len(s) - 1):
if s[i] == s[i+1]:
m.append(int(s[i]))
return m
def captcha(s):
return sum(find_matches(s))
if __name__ == '__main__':
s = "428122498997587283996116951397957933569136949848379417125362532269869461185743... |
PRED_DIR = './../../../predictions'
#
# TEST
#
# MultiRC
# Test Predictions
MULTIRC_TEST_BB_S1 = 'multirc_bert_blackbox_predictions_test.jsonl'
MULTIRC_TEST_BB_S2 = 'multirc_bert_blackbox_seed2_predictions_test.jsonl'
MULTIRC_TEST_BB_S3 = 'multirc_bert_blackbox_seed3_predictions_test.jsonl'
MULTIRC_TEST_BB_S4 = 'multi... |
def main():
word = input()
print(''.join([word[0] if ord('A') <= ord(word[0]) <= ord(
'Z') else chr(ord(word[0]) - (ord('a') - ord('A')))] + list(word[1:])))
main()
|
class Solution:
def isBalanced(self, root: Optional[TreeNode]) -> bool:
if not root:
return True
def maxDepth(root: Optional[TreeNode]) -> int:
if not root:
return 0
leftHeight = maxDepth(root.left)
if leftHeight == -1:
return -1
rightHeight = maxDepth(root.righ... |
def render_lines(lines_count):
s = "abcdefghijklmnopqrstuvwxyz"
yield from ("%d: %s" % (i + 1, s) for i in range(lines_count))
def render_text(lines_count):
return "\n".join(render_lines(lines_count))
#######################################################################################################... |
class FileLogger:
def __init__(self, file_path):
self.file_path = file_path
def log(self, data):
string = ' '.join(["%s=%s" % (key, value) for key, value in data.items()])
string += '\r\n'
self.write(string)
# TODO: make write function async <<<
def write(self, s... |
salt_email = "1e698bd5135c4e0321b40c8842bb0f8b9217ffdd3ca1e56d5b9ac5abbbb3136c"
d = {}
with open('imdb-1.csv', 'r') as f:
for line in f.readlines():
sp = line.split(',')
movie = sp[1]
date = sp[2].strip()
rating = sp[3].strip()
if date + "," + rating in d:
d[date + "," + rating].append(movi... |
class CoffeeMachine:
def __init__(self, water=0, milk=0, coffee=0, cups=0, money=0):
self.water = water
self.milk = milk
self.coffee = coffee
self.cups = cups
self.money = money
@classmethod
def coffee_params(cls, param):
dict_param = {"1": (250, 0, 16, 1, 4)... |
#pergunte o nome. mostre o nome com as letras M e m, quantas letras tem tirando os espaços e quantas letras tem o primeiro nome.
nome = str(input('Digite no nome Completo: '))
print(nome.upper())
print(nome.lower())
print(len(nome.strip()) - nome.count(" "))
primeiroNome = nome.split()
nome1 = primeiroNome[0]
print(len... |
#list creation
l1=list()
for i in range(5):
l1.append(input("enter name:"))
print(l1)
|
# Zadanie 2
# - analogiczne do zadania 1
# - pobrać dni tygodnia z pliku tekstowego
# - jeżeli długość nazwy jest parzysta, wypisać ciąg liczb zaczynający się od długości tej nazwy aż do zera włącznie
# - wypisać znak z nazwy który znajduje się na pozycji [długość napisu % 5]
f = open("03_zadanie2_dane.txt", "r")
for... |
class Number:
def __init__(self, num) -> None:
self.num = num
def __iter__(self):
return self
def __next__(self):
if self.num < 10:
x = self.num
self.num += 1
return x
else: raise StopIteration
my_number = Number(5)
my_number_iterator = iter(my_number)
for n in my_numb... |
"""
@version: 2.0
@author: Chao Chen
@contact: cchao@didiglobal.com
"""
|
{
'targets': [
{
'target_name': 'memwatch',
'include_dirs': [
],
'variables': {
'node_ver': '<!(node --version | sed -e "s/^v\([0-9]*\\.[0-9]*\).*$/\\1/")'
},
'sources': [
'src/heapdiff.cc',
'src/init.cc',
'src/memwatch.cc',
'src/util.cc'... |
# -*- coding: utf-8 -*-
# Copyright (2017) Hewlett Packard Enterprise Development LP
#
# 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... |
UA = ["Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
"Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Wind... |
#http://shell-storm.org/shellcode/files/shellcode-165.php
#I can use it ..
"""
00000000 EB2B jmp short 0x2d
00000002 5E pop esi
00000003 31C0 xor eax,eax
00000005 88460B mov [esi+0xb],al
00000008 884629 mov [esi+0x29],al
0000000B 50 ... |
'''
30 个人在一条船上,超载,需要 15 人下船。
于是人们排成一队,排队的位置即为他们的编号。
报数,从 1 开始,数到 9 的人下船。
如此循环,直到船上仅剩 15 人为止,问都有哪些编号的人下船了呢?'''
people = dict() # 创建字典,用于标记
for i in range(1, 31):
people[i] = 'in'
print(people)
check = 0 # 塞选下船人的编号
m = 1 # 控制整体循环
o = 0 # 记录下船人数
while m <= 31:
if m == 31:
m = 1
elif o == 15:... |
def display(board_state):
n = board_state.shape[0]
print(" ", end="")
for y in range(n):
print(chr(ord('a') + y),"", end="")
print("")
print(" ", end="")
for _ in range(n):
print ("-", end="-")
print("--")
for x in range(n):
print(x, "|",end="") # print the... |
first_name = "Feng"
last_name = "Li"
####################################################
# Repetitions of string
full_name = first_name * 3
print(full_name, "binggo", sep='|')
|
#!/usr/bin/env python
"""Docstring"""
__author__ = "Petar Stoyanov"
def main():
"""Docstring"""
if __name__ == '__main__':
main()
|
x = int(input())
a = int(input())
b = int(input())
t = x - a
k = 0
while t - b * k >= 0:
k += 1
print(t - b * (k - 1))
|
# pylint: disable=all
class MockResponse:
def __init__(self, status_code, json_data):
self.json_data = json_data
self.status_code = status_code
def json(self):
return self.json_data
GOOD_MANIFEST = MockResponse(
200,
{
"@context": "http://iiif.io/api/presentation/2/c... |
# Filenames
input_configuation_filename = "config.ini"
data_file_directory = "data"
log_file_directory = data_file_directory
status_file_directory = data_file_directory
log_file_name = "log"
database_file_name = 'cryptoData.db'
status_file_name = 'status.ini'
appNameDirectory = 'CMCLogger'
# Configuration file section... |
n, m = map(int, input().split())
l = []
for i in range(n):
line = input().split()
for x in line:
l.append(x)
s = set(l)
ans = [x for x in s if l.count(x) == n]
print(len(ans))
for x in sorted(ans):
print(x) |
PRACTICE = False
with open("test.txt" if PRACTICE else "input.txt", "r") as f:
content = f.read().strip()
grid = [list(row) for row in content.split("\n")]
height = len(grid)
width = len(grid[0])
move_num = 0
while True:
move_occurred = False
for i, row in enumerate(grid):
to_move_east = set()
... |
def test_hello_world():
message = "Hello, world!"
assert message == "Hello, world!"
|
# -*- coding: utf-8 -*-
'''
Implementa uma pilha com listas.
Esconde detalhes de implementação fornecendo
uma interface mais simples, ou mais padronizada.
'''
class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def ... |
# URI Online Judge 3209
N = int(input())
for n in range(N):
entrada = [int(i) for i in input().split()]
K = entrada[0]
O = entrada[1:]
saida = sum(O) - len(O) + 1
print(saida) |
def menorpos(numeros):
cont = menor = pos = 0
for c, i in enumerate(numeros):
cont = cont + 1
if cont == 1:
menor = i
pos = c
else:
if i < menor:
menor = i
pos = c
return pos
v = [3, 5, 1, 30, 50, 100]
print(menorp... |
def load(h):
return ({'bit': 0, 'on': 0, 'title': 'bit0_off'},
{'bit': 0, 'on': 1, 'title': 'bit0_on'},
{'bit': 1, 'on': 0, 'title': 'bit1_off'},
{'bit': 1, 'on': 1, 'title': 'bit1_on'},
{'bit': 2, 'on': 0, 'title': 'bit2_off'},
{'bit': 2, 'on': 1, 'title'... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def get_number(head):
number = 0
while head:
numb... |
# To input 10 random numbers & find how many of them are even and odd
print("============You have to enter 10 random numbers===================")
even = 0
odd = 0
for i in range(1,11):
num = int(input("Enter the number: "))
if(num%2==0):
even = even + 1
else:
... |
def CheckingNeededVars(list_vars):
#for var in list_vars:
# if var is None:
# print 'Variable Needed'
pass
|
"""Top-level package for gitown."""
__author__ = """Milind Shakya"""
__email__ = 'sh.milind@gmail.com'
__version__ = '0.1.0'
|
#!/usr/bin/env python
# coding: utf-8
# # Introduction to Python Statements
# Let's create a simple statement that says:
# "If a is greater than b, assign 2 to a and 4 to b"
#
# if a>b:
# a = 2
# b = 4
# ## Indentation
# Note how Python is so heavily driven by code indentation and whitespac... |
# -*- coding: utf-8 -*-
class HelperSet(object):
def __init__(self, helpers=None):
helpers = helpers or []
self.__helpers = {}
self.__command = None
if isinstance(helpers, (list, tuple)):
for helper in helpers:
self.set(helper, None)
else:
... |
db_dir = 'financial_db'
db_tables = [ '''security ( ticker TEXT PRIMARY KEY,
company INT,
exchange INT,
currency TEXT
)''',
'''exchange ( acronym TEXT PRIMARY KEY,
n... |
# -*- coding: utf-8 -*-
"""Top-level package for Pretty upper."""
__author__ = """Nick Mavrakis"""
__email__ = 'mavrakis.n@gmail.com'
__version__ = '0.3.1'
|
nums = int(input("Enter range :"))
def getfectnum(nums):
for i in range(1, nums+1):
sumdiv = 0
for a in findalldivs(i):
sumdiv = a + sumdiv
if sumdiv == i:
print(i)
def findalldivs(num):
ls = list()
for x in range(1,num):
if num % x ... |
schedule1B = [
["Crucero","07:20","08:20","09:30","10:30","11:40","12:50","14:00","16:15","17:15","18:20","19:30"],
["Centro","07:30","08:30","09:40","10:40","11:50","13:00","14:10","16:25","17:25","18:30","19:40"],
["Esc Yrigoyen","","","","","12:00","","","","17:30","",""],
["Esc Padre Viera","07:40",... |
def merge_sort(nums):
if len(nums) <= 1:
return nums
mid = (0 + len(nums)) // 2
left = merge_sort(nums[:mid])
right = merge_sort(nums[mid:])
return merge_iterative(left, right)
def merge_iterative(nums1, nums2):
if nums1 == []:
return nums2
if nums2 == []:
re... |
# Exercise 065 - Largest and Smallest Values
"""Create a program that reads several integers from the keyboard. At the end of execution,
show the average of all values and what was the highest and lowest values read.
The program should ask the user whether or not he wants to continue typing values."""
flag = False
co... |
"""
Paint House
https://leetcode.com/problems/paint-house/
There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.
The... |
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# Full license terms provided in LICENSE.md file.
CHECKPOINT_DIR = 'data/checkpoints/'
FROZEN_GRAPHS_DIR = 'data/frozen_graphs/'
UFF_DIR = 'data/uff/'
NETS = {
'vgg_16': {
'num_classes': 1000,
'input_name': 'input',
'output_na... |
'''
Created on 27 Oct 2018
@author: vahanoi
'''
class Player:
'''
classdocs
'''
# TODO: create object Player with all details
def __init__(self, name, emailaddress):
'''
Constructor
'''
age=0
return(None)
|
# DUAS TUPLAS
a= (2,5,4)
b=(5,8,1,2)
c= a+b #Ele vai mostrar primeiro a Tupla A e depois a Tupla B. Não irá somar ninguem, logo a ordem dos fatores importa.
print(c)
print(len(c)) #Irá mostrar o tamanho, ou seja, quantos elementos eu tenho em c
print(c.count(5)) #Mostra quantas vezes está aparecendo o numero 5 dentro... |
class Zillion:
def __init__(self,digits):
self.digits = digits
self.List = []
self.toList()
def toList(self):
badBoolean=False #Kludge
if len(self.digits) == 0 :
raise RuntimeError #Cannot make a list of nothing
for n in range (0,len(self.digits)):
if self.digits... |
#Programa de senha
cont = soma = entrada = 0
while entrada != 999:
entrada = int(input('Entre com a senha: '))
if entrada != 999:
cont += 1
soma += entrada
print('Senha Válida!')
print(f'Números de tentativas: {cont}')
print(f'A soma entre os valores informados: {soma}') |
MAX_NUMBER_ONE_CLASS = 2
MAX_WIDTH = 200
CPU_CORE = 8
RANSAC_THRESHOLD = 5.0 |
def getarea(XYZ):
# prism is A,B,C
# X=A+B Y=B+C Z=A+C
X,Y,Z = XYZ
#A=2(wl+hl+hw)
A = ((X+Z)-Y)/2
B = ((X+Y)-Z)/2
C = ((Y+Z)-X)/2
return 2*(A*B+C*B+C*A)
if __name__ == "__main__":
for tc in xrange(int(raw_input())):
print("%.2f" % round(getarea(map(float,raw_input().spli... |
"""
Flatten List from nested list
__author__ = Pavan Maradia
__version__ = v1.0
"""
class ListFlatten(object):
"""
Flat Nested list in single list
"""
def __init__(self):
"""
Initialize class object
"""
self.resp_list = list()
self.response = dict()
def ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.