content stringlengths 7 1.05M |
|---|
def main():
# input
H, W = map(int, input().split())
Ass = [[*map(int, input().split())] for _ in range(H)]
# compute
ansss = []
for i in range(H):
ansss.append([sum(Ass[i])] * W)
for j in range(W):
tmp_sum = 0
for i in range(H):
tmp_sum += Ass[i][j]
... |
class MonsterClassificationAgent:
def __init__(self):
#If you want to do any initial processing, add it here.
self.default_monster_attributes = {
'size': ['tiny', 'small', 'medium', 'large', 'huge'],
'color': ['black', 'white', 'brown', 'gray', 'red', 'yellow', 'blue', 'gree... |
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 17:40:33 2020
This time, write a procedure, called biggest, which returns the key
corresponding to the entry with the largest number of values associated with it.
If there is more than one such entry, return any one of the matching keys.
@author: MarcoSilva
"""
ani... |
with open('inputs/input11.txt') as fin:
raw = fin.read()
def parse(raw):
x = tuple(x for x in raw.split('\n'))
return x
a = parse(raw)
def part_1(data):
test = data[:]
test2 = []
while test != test2:
test = data[:]
for i, x in enumerate(data):
for a, b in enumera... |
#Exercício Python 008: Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros.
number = float(input('Enter the number in meters:'))
#Quilômetros
km = number/1000
#Hectometros
hm = number/100
#Decametro
dam = number/10
#Decímetro
dm = number * 10
#Centímetro
cm = number * 100
#... |
#############################################
### web face setting
#############################################
pretrain_model_path = 'E:/git/project/facenet/model/20180402-114759'
train_mode = 'TRAIN'
classify_mode = 'CLASSIFY'
profile_data_root_path = 'E:/temp/flask-upload-test/'
image_upload_path = 'E:/temp... |
str1 = "abcdefghijklmnopqrstuvwxyz"
# 1. Create a slice that produces "qpo"
print(str1[16:13:-1])
# 2. Slice the string to produce "edcba"
print(str1[4::-1])
# 3. Slice the string to produce the last 8 characters, in reverse order
print(str1[:-9:-1])
print(str1[-4:])
print(str1[-1:])
print(str1[:1])
print(str1[0... |
class AddInCommandBinding(object):
"""
This object represents a binding between a Revit command and one or more handlers which
override the behavior of the command in Revit.
"""
RevitCommandId = property(
lambda self: object(), lambda self, v: None, lambda self: None
)
"""The Rev... |
class Settings():
# APP SETTINGS
# ///////////////////////////////////////////////////////////////
ENABLE_CUSTOM_TITLE_BAR = True
MENU_WIDTH = 240
LEFT_BOX_WIDTH = 240
RIGHT_BOX_WIDTH = 240
TIME_ANIMATION = 500
# BTNS LEFT AND RIGHT BOX COLORS
BTN_LEFT_BOX_COLOR = "background-color:... |
num = int(input('Informe um número: '))
c = num - 1
conta = num
print('Calculando %i!: ' % num, end='')
while c >= 1:
print('%i' % c, end='')
print(' x ' if c > 1 else ' = ', end='')
conta *= c
c -= 1
print(conta, end=' ')
print('\033[1;31mFim')
|
"""
Bubble Sort
It is a comparison-based algorithm in which each pair of adjacent elements is compared and the elements are swapped if they are not in order.
"""
def bubblesort(list):
# Swap the elements to arrange in order
for iter_num in range(len(list)-1,0,-1):
for idx in range(iter_num):
... |
expected_output = {
'instance': {
'test': {
'vrf': {
'default': {
'interfaces': {
'Ethernet1/1.115': {
'adjacencies': {
'R2_xr': {
... |
skip_list = [
{'scheme': 'kyber1024', 'implementation': 'm3', 'estmemory': 12288},
{'scheme': 'kyber512', 'implementation': 'm3', 'estmemory': 7168},
{'scheme': 'kyber768', 'implementation': 'm3', 'estmemory': 9216},
{'scheme': 'saber', 'implementation': 'm3', 'estmemory': 22528},
{'scheme': 'sikep4... |
class RougeDatasetResults(object):
""" Class for storing the results of the ROUGE evaluation for multiple texts.
"""
def __init__(self):
self.runs = 0
self.successes = 0
self.timeouts = 0
self.errors = 0
self.output = None
def add_success(self):
self.r... |
def add(a, b):
c = a + b
return c
c = add(1, 2)
print(c)
def subtraction(a, b):
return a - b
print(subtraction(b=5, a=10))
def division(a, b=1):
return a / b
print(division(5))
print(division(10, 5))
def print_a(a, *b):
print(a, b)
print_a(1, 2, 3, 4, 5, 6)
... |
def problem_14():
"Which starting number, under one million, produces the longest [Collatz sequence] chain?"
longest_length = 0
longest_start = 0
# For each number between 1 and one million...
for i in range(1, 1000000):
# Take a copy of each number
n = i
# Set the length o... |
class SuperElasticHardeningModifications:
"""The SuperElasticHardeningModifications object specifies the variation of the
transformation stress levels of a material model.
Notes
-----
This object can be accessed by:
.. code-block:: python
import material
mdb.model... |
#!/usr/bin/env python
# encoding: utf-8
def run(whatweb, pluginname):
whatweb.recog_from_content(pluginname, "/WorldClient.dll?View=Main")
|
def update_fields_widget(form, fields, css_class):
for field in fields:
form.fields[field].widget.attrs.update({'class': css_class})
|
# 雑種
optionWindow = None
selectedLangValue = None
root = None
menubar = None
# タブ機能用の変数
tframes = None
fnames = None
notebook = None
frame_hover_now = False
font = 'Courier'
text_size = 10
# 設定データを保存する用のもの
# 毎度毎度,ファイルから読み取るのはバカだと思ってしまう癖ありんす
settings_temp_language = None
# 初期値(pythonってfinal宣言あるんかな...)
DEFAULT_WIDTH =... |
dicionario = dict()
dicionario['nome'] = str(input('Nome: '))
dicionario['media'] = float(input(f'Média de {dicionario["nome"]}: '))
if dicionario['media'] >= 7:
dicionario['situação'] = 'Aprovado'
elif 7 > dicionario['media'] >= 5:
dicionario['situação'] = 'Recuperação'
else:
dicionario['situação'] = 'Repr... |
"""
Code for computing collected components.
"""
class Component:
"""
Holder for a connected component.
"""
def __init__(self, item):
self.id = item
self.items = {item}
def connected_components(f, g):
"""
Compute connected components of undirected edges (f[i], g[i]).
For... |
#!/usr/bin/env python
"""
This is where I put working code that I no longer use, but that might be useful in the future.
"""
async def ask_moves_questions(num_questions, channel, guesser):
msg = await channel.send("Here is your quiz")
for question_number in range(num_questions):
record_channel_activity... |
"""http://stackoverflow.com/a/23173968/287297"""
################################################################################
def parse_newick(path):
"""Parse a newick-formated text file and return a "Tree" object."""
pass |
# A base Class for the various kinds of 2d-rules used to update the playing field
class BaseRule:
def __init__(self, rule_str="", mode=None, num_states=0):
self.rule_str = rule_str
self.mode = mode
self.num_states = num_states
def apply(self, curr_state: int, num_neighbors: int) -> i... |
def toplama(x, y):
return x + y
def cikarma(x, y):
return x - y
def carpma(x, y):
return x * y
def bolme(x, y):
return x / y
while True:
print("Yapmak İstediğiniz İşlemi Seçiniz!")
print("1) Toplama")
print("2) Çıkarma")
print("3) Çarpma")
print("4) Bölme")
print("5) Çık... |
def resizeApp(app, dx, dy):
switchApp(app)
corner = find(Pattern("1273159241516.png").targetOffset(3,14))
dragDrop(corner, corner.getCenter().offset(dx, dy))
resizeApp("Safari", 50, 50)
# exists("1273159241516.png")
# click(Pattern("1273159241516.png").targetOffset(3,14).similar(0.7).firstN(2))
# with Region(10,100... |
# 41. 和为S的连续正数序列
# 题目描述
# 小明很喜欢数学,有一天他在做数学作业时,要求计算出9到16的和,他马上就写出了正确答案是100。
# 但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。没多久,
# 他就得到另一组连续正数和为100的序列:18,19,20,21,22。现在把问题交给你,你能不能也很快的
# 找出所有和为S的连续正数序列? Good Luck!
# 输出描述:
# 输出所有和为S的连续正数序列。序列内按照从小至大的顺序,序列间按照开始数字从小到大的顺序
# -*- coding:utf-8 -*-
class Solution:
def FindCo... |
a = input("Immetti il coefficiente a ")
b = input("Immetti il coefficiente b ")
c = input("Immetti il coefficiente c ")
print ("Data l'equazione algebrica " + str(a) +
"*X^2+" + str(b) + "*X+" + str(c) + "=0 ")
delta = b * b - 4 * a * c
if delta >= 0:
rad_delta = delta**0.5
x1 = -(b - rad_delta) / (2 * ... |
'''
PROBLEM STATEMENT:
Given an array of integers of size n, where n denotes number of books and each element of an array denotes the number of pages in the ith book, also given another integer
denoting number of students. The task is to allocate books to the given number of students so that maximum number of pag... |
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"flag_group",
"flag_set",
"tool_path",
)
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
# This file has been written based off the variable definitions in the following
# files:
# - https://github.c... |
"""
python_gtk_kiosk module entry point.
"""
__author__ = 'KuraLabs S.R.L'
__email__ = 'info@kuralabs.io'
__version__ = '0.1.0'
|
'''
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
Follow up:
Coud you solve it without converting the integer to a string?
TODO
'''
class Solution:
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
... |
sum_ = 0
for n in range(1, 1000):
if n % 3 == 0 or n % 5 == 0:
print(n, end=", ")
sum_ += n
print("sum =", sum_) |
'''
Print the following pattern for the given N number of rows.
Pattern for N = 4
1234
123
12
1
'''
rows=int(input())
n=rows
for i in range(rows):
value=1
for j in range(n,0,-1):
print(value,end="")
value=value+1
n=n-1
print()
|
"""------------------------------------------------------------------------
#3 totalQuantity() function calculates the total quantity of orders.
------------------------------------------------------------------------"""
def totalQuantity(TEMP):
total = float(0)
for i in range(len(TEMP)):
to... |
# URL: https://www.geeksforgeeks.org/python-list/
myList = []
print("Intial List : ")
print(myList)
# Addition of Elements in the list
myList.append(1)
myList.append(2)
myList.append(4)
print("\nList after addition of three elements : ")
print(myList)
# Adding elements to the list using Iterator
for i in range(1, 4)... |
n = int(input())
for i in range(0, n):
line = input()
total = 0
k = int(line.split()[0])
for j in range(0, k):
o = int(line.split()[j+1])
total += o
total -= k - 1
print(total)
|
#
# Solution to Project Euler Problem 8
# by Lucas Chen
#
# Answer: 23514624000
#
DIGITS = 13
NUM = "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445... |
# SPDX-License-Identifier: MIT
# Copyright (C) 2018-present iced project and contributors
# ⚠️This file was generated by GENERATOR!🦹♂️
# pylint: disable=invalid-name
# pylint: disable=line-too-long
# pylint: disable=too-many-lines
"""
Mnemonic condition code selector (eg. ``JNP`` / ``JPO``)
"""
NP: int = 0
"""
``... |
units = 'nm'
vdw ={
"H" : 0.11000,
"He" : 0.14000,
"Li" : 0.18200,
"Be" : 0.15300,
"B" : 0.19200,
"C" : 0.17000,
"N" : 0.15500,
"O" : 0.15200,
"F" : 0.14700,
"Ne" : 0.15400,
"Na" : 0.22700,
"Mg" : 0.17300,
"Al" : 0.18400,
"Si" : 0.21000,
"P" : 0.18000,
"S" : 0.18000,
"Cl" : 0.17500,
"Ar" : 0.18800,
... |
s1=str(input())
s2=str(input())
n=len(s1)
m=len(s2)
a=[0]*n
b=[0]*m
for i in range(0,n-2):
if s1[i]=='1':
a[i]=a[i]+1
a[i+1]+=a[i]
a[i+2]+=a[i];
if(s1[n-2]=='1'):
a[n-2]+=1
if(s1[n-1]=='1'):
a[n-1]+=1
for i in range(0,m-2):
if s2[i]=='1':
++b[i];
b[i+1]+=b[i]
b[i+2]+=b[i]... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-05-25 13:16
# @Author : minp
# @contact : king101125s@gmail.com
# @Site :
# @File : __init__.py.py
# @Software: PyCharm
"""
信息来源1:http://funhacks.net/explore-python/Class/slots.html
信息来源2:https://eastlakeside.gitbooks.io/interpy-zh/content/slots_m... |
def new_queue():
return []
def enqueue(a, element):
a.append(element);
def dequeue(a):
if (len(a)):
return a.pop(0)
def is_empty(a):
return True if len(a) == 0 else False |
#
# PySNMP MIB module GAMATRONIC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GAMATRONIC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:04:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... |
# Generated with generatedevices.py
class Device:
def __init__(self, **kwargs):
for key in kwargs:
setattr(self, key, kwargs[key])
devices = [
Device(devid="at90can128", name="AT90CAN128", signature=0x978103f, flash_size=0x20000, flash_pagesize=0x100, reg_dwdr=None, reg_spmcsr=0x37),
D... |
# pylint: disable=C0112,C0103,R0903,C0116,C0114,R0201
def read_int():
return int(input())
def read_int_array():
return [int(ss) for ss in input().split()]
def complete_sequence(xs, a, b, c, d, total_len):
"""
FB Hacker Cup-style for long lists
"""
for x in xs:
yield x
p, q = xs[-2... |
"""
Copyright 2016 Deepgram
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 writing, software
distri... |
#Embedded file name: ACEStream\Core\dispersy\encoding.pyo
def _a_encode_int(value, mapping):
value = str(value).encode('UTF-8')
return (str(len(value)).encode('UTF-8'), 'i', value)
def _a_encode_float(value, mapping):
value = str(value).encode('UTF-8')
return (str(len(value)).encode('UTF-8'), 'f', v... |
n = int(input())
value = 0
max_value = 0
max_quality = 0
max_weight = 0
max_time = 0
for x in range(n):
weight = int(input())
time_needed = int(input())
quality = int(input())
value = (weight / time_needed) ** quality
if value > max_value:
max_value = value
max_quality = quality
... |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def findBottomLeftValue(self, root: TreeNode) -> int:
stack = [root]
res = stack[0].val
while stack:
newstack =... |
night = 20
transport = 1.60
museum = 6
number_of_people = int(input())
number_of_nights = int(input())
number_of_cards = int(input())
number_of_tickets = int(input())
all_nights = night * number_of_nights
all_cards = transport * number_of_cards
all_museum = museum * number_of_tickets
total_per_person = all_nights + ... |
into = [13,56,34,58,52,93,35,24]
print(into)
print("\sorted is =",
sorted(into))
print("\maximum is = ",
max(into))
print("\minimum is =",
min(into))
print("\length is = ",
len(into))
|
"""Constants for frigate."""
# Base component constants
NAME = "Frigate"
DOMAIN = "frigate"
FRIGATE_VERSION_ERROR_CUTOFF = "0.8.4"
FRIGATE_RELEASES_URL = "https://github.com/blakeblackshear/frigate/releases"
FRIGATE_RELEASE_TAG_URL = f"{FRIGATE_RELEASES_URL}/tag"
# Icons
ICON_CAR = "mdi:shield-car"
ICON_CAT = "mdi:cat... |
# https://www.codechef.com/problems/CHOPRT
for T in range(int(input())):
a,b = map(int,input().split())
if(a>b): print(">")
if(a<b): print("<")
if(a==b): print("=") |
###############################################################################
# Function: Sequence1Frames_set_timeslider
#
# Purpose:
# This is a callback function for sequence 1's IterateCallbackAndSaveFrames
# function. This function sets the time and updates the time slider so
# it has the right time value.
... |
def printb(block):
print(bstr(block))
def bstr(block):
strs = []
types = ['res', 'com', 'ind']
for t in types:
bldg_strs = []
bldgs = list(block['buildings'][t].values())
bldgs = sorted(bldgs, key=lambda b: b['weight'])
for build in bldgs:
s = f" {build[... |
n = int(input("INSIRA O NUMERO DE TERMOS DA PA: "))
pt = int(input("INSIRA O 1° TERMO DA PA: "))
r = int(input("INSIRA A RAZÃO DA PA: "))
print("*"*40)
print("OS TERMOS DA PA SÃO")
calc = pt + ( n - 1 )*r
for i in range(pt, calc+r, r):
print(f'{i}',end='->')
soma = n * (pt + calc) // 2
print()
print(">A SOMA DOS TE... |
class MapSum(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.d = {}
def insert(self, key, val):
"""
:type key: str
:type val: int
:rtype: None
"""
self.d[key] = val
def sum(self, prefix):
... |
#/usr/bin/env python
'''
Classical algorithm
Hanoi Towel
'''
# No Import needed.
# No Global Variable.
# No Class definition.
def Hanoi( a , b , c , n ):
'''
a -- position for the plate need to move
b -- destination for the plate need to reach
c -- assistant plate
n -- count of p... |
NAME_FILE = "name.mp3"
TMP_DATA_DIR = "data/engagement"
TMP_RAW_NAME_FILE = f"{TMP_DATA_DIR}/raw-name.wav"
TMP_NAME_FILE = f"{TMP_DATA_DIR}/{NAME_FILE}"
FACES_DATA_DIR = "data/faces"
ENCODINGS_FILE_PATH = "data/encodings.pickle"
TRAINER_PROCESSED_FILE_PATH = "data/faces_processed.txt"
|
#!/usr/bin/env python3
txt = "w1{1wq87g_9654g"
flag = ""
for i in range(len(txt)):
if i % 2 == 0:
flag += chr(ord(txt[i])-5)
else:
flag += chr(ord(txt[i])+2)
print("picoCTF{%s}"%flag) |
# Write your code here
test = int(input())
while test > 0 :
n = input()
count = 0
l = ['a','e','i','o','u','A','E','I','O','U']
for i in n :
if i in l :
count += 1
print(count)
test -= 1
|
def condition_check(string: str, condition: str) -> bool:
condition = chop_redundant_bracket(condition.strip()).strip()
level_dict = get_level_dict(condition)
if level_dict == {}:
return has_sub_string(string, condition)
else:
min_level = min(level_dict.keys())
min_level_dict = l... |
def find_largest(n: int, L: list) -> list:
"""Return the n largest values in L in order from smallest to largest.
>>> L= [3, 4, 7, -1, 2, 5]
>>> find_largest(3, L)
[4, 5, 7]
"""
copy=sorted(L)
return copy[-n:] |
for i in range (10,20):#imprime do ao 19, pois sao 10 numeros
print(i)
for i in range (10,20,2):#agora com numero 2 determino o salto de numeros
print(i) |
# if elif else gibi koşulları destekleyen mantıksal operatörler vardır
# bunlar and or ve not dır
# and operatörü tüm koşul gerçekleşiyor yani tümü doğru ise kod bloğunu çalıştırır
# içlerinden biri yanlış ise komple yanlış olarak algılanır
hasHighİncome = False
hasGoodCredit = True
if hasHighİncome and hasGoodCredi... |
def make_collector(cls, methodname):
storage = []
method = getattr(cls, methodname)
method = getattr(method, "__func__", method)
def collect(self, ctx):
storage.append(ctx)
return method(self, ctx)
class Collector(cls):
pass
collect.__name__ = methodname
Collector... |
class Solution:
def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:
if obstacleGrid[0][0] == 1:
return 0
else:
obstacleGrid[0][0] = 1
numberOfRows = len(obstacleGrid)
numberOfColumns = len(obstacleGrid[0])
for col in range(1, numb... |
#
# PySNMP MIB module TRANGOP5830S-RU-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TRANGOP5830S-RU-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:27:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... |
test = { 'name': 'q2_1_2',
'points': 1,
'suites': [ { 'cases': [ { 'code': '>>> # Make sure you can use any two movies;\n'
'>>> correct_dis = 0.000541242;\n'
'>>> dis = distance_two_features("clerks.", "the a... |
# TC:O(N^N)
def queens_helper(n, row, col, asc_des, desc_des, possibilities):
curr_row = len(possibilities)
for curr_col in range(n):
if col[curr_col] and row[curr_row] and asc_des[curr_col+curr_row] and desc_des[curr_row-curr_col]:
row[curr_row] = False
col[curr_col] = False
... |
SITE_NAME='Bitsbox'
SQLALCHEMY_TRACK_MODIFICATIONS=False
DEBUG=False
USER_CREATION_ALLOWED=False
GOOGLE_CLIENT_ID='YOUR_CLIENT_ID.apps.googleusercontent.com'
|
"""Custom exceptions."""
class SlugError(Exception):
"""Slug error."""
|
option_spec = {
"OIDCProvider": {
"REQUIRE_CONSENT": {
"type": "boolean",
"default": True,
"envvars": ("KOLIBRI_OIDC_PROVIDER_REQUEST_CONSENT",),
}
}
}
|
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
s_dict = {}
t_dict = {}
if len(s) != len(t):
return False
for idx in range(len(s)):
s_char = s[idx]
t_char = t[idx]
if s_char not in s_dict:
... |
base_dir = os.path.split(os.path.dirname(__file__))[0]
data_dir = os.path.join(
base_dir,
"data",
)
resource_dir = os.path.join(
base_dir,
"resources",
)
|
# -*- coding: utf-8 -*-
#
#
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General infor... |
def pydemic():
"""
Patch the streamlit module
"""
|
VALIDATION_EXCEPTION_MESSAGE = "Validation error has occurred : {0}"
WRONG_ID_FORMAT_MESSAGE = "Wrong {0} id format : {1}"
OBJECT_ALREADY_PROCESSING_MESSAGE = "object {0} is already processing. request cannot be completed."
# validation error messages
INVALID_SECRET_CONFIG_MESSAGE = "got an invalid secret config"
IN... |
stop_codon = ["UAA", "UAG", "UGA"]
amino_acid = ["Ala", "Arg", "Asn", "Asp", "Cys", "Glu", "Gln", "Gly", "His", "Ile", "Leu", "Lys",
"Met", "Phe", "Pro", "Ser", "Thr", "Trp", "Tyr", "Val"]
codon_U = ["UUU", "UUC", "UUA", "UUG",
"UCU", "UCC", "UCA", "UCG",
"UAU", "UAC", "UAA", "U... |
#Crie um programa que pergunte quanto dinheiro uma pesssoa tem na carteira, e mostre quantros dólares ela pode .
#considere US1,00 = R$ 5,65
r = float(input('Me diga quanto voce tem na carteira, em Reais, e eu digo quantos dólares você pode comprar: R$'))
d = r / 5.65
print('Estando 1 dólar a 5,65 reais, você poderá co... |
class Node(object):
def __init__(self, val, parent=None):
self.val = val
self.leftChild = None
self.rightChild = None
self.parent = parent
def getLeftChild(self):
return self.leftChild
def getRightChild(self):
return self.rightChild
def getParent(self)... |
def isMAC48Address(inputString):
str_split = inputString.split("-")
count = 0
if len(inputString) != 17:
return False
if len(str_split) != 6:
return False
for i in range(0, 6):
if str_split[i] == "":
return False
if re.search("[a-zG-Z]", str_split[i]):
... |
"""
Consider an array arr of distinct numbers sorted in increasing order.
Given that this array has been rotated (clockwise) k number of times. Given such an array, find the value of k.
"""
def find_rotations(arr: list):
min_val = arr[0]
n = len(arr)
min_index = -1
for i in range(0, n):
if mi... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 27 11:06:10 2021
@author: q
Goal : Study Dynamic Programming Concepts for CGA Exam
Study Case : Fibonacci Numbers
- Binary Recursion
- Top-Down with Memoization
- Bottom-Up with Tabualtion
"""
def fiboRecursive(n):
... |
'''
给定一个非负整数数组 A, A 中一半整数是奇数,一半整数是偶数。
对数组进行排序,以便当 A[i] 为奇数时,i 也是奇数;当 A[i] 为偶数时, i 也是偶数。
你可以返回任何满足上述条件的数组作为答案。
示例:
输入:[4,2,5,7]
输出:[4,5,2,7]
解释:[4,7,2,5],[2,5,4,7],[2,7,4,5] 也会被接受。
提示:
2 <= A.length <= 20000
A.length % 2 == 0
0 <= A[i] <= 1000
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/sort-array-by... |
class Account:
def __init__(self, client):
self._client = client
def get_balance(self):
return self._client.get(self._client.host(), "/account/get-balance")
def topup(self, params=None, **kwargs):
return self._client.post(self._client.host(), "/account/top-up", params or kwargs)
... |
#!/usr/bin/env python
# vim: set tabstop=4 shiftwidth=4 textwidth=79 cc=72,79:
"""
Original Author: Owain Jones [github.com/erinaceous] [odj@aber.ac.uk]
"""
__all__ = [
'data',
'fuzzy',
'utils',
'cmeans'
]
|
# Base architecture
alexnet = {}
alexnet['conv1'] = [64,3,11,11]
alexnet['conv2'] = [192,64,5,5]
alexnet['conv3'] = [384,192,3,3]
alexnet['conv4'] = [256,384,3,3]
alexnet['conv5'] = [256,256,3,3]
alexnet['fc'] = [100,256]
vgg8 = {}
vgg8['conv1'] = [64,3,3,3]
vgg8['conv2'] = [128,64,3,3]
vgg8['conv3'] = [256,128,3,... |
strN = input("Please enter a number:")
N = int(strN)
#N = 10
total = 0
for current in range(N+1):
if current % 2 == 1:
total = total + current
print("summation 1..",N," for odd numbers is",total)
|
#!/usr/bin/env python3
d = ['Sunny', 'Cloudy', 'Rainy']
N = input()
i = d.index(N)
print(d[(i + 1) % 3])
|
version = '2.4.0'
author = 'maximilionus'
# Variables below was deprecated in 2.2.0
# and will be removed in 3.0.0 release
__version__ = version
__author__ = author
|
"""Manager service."""
class Manager:
"""Encapsulation of manager service."""
def __init__(self) -> None:
self._instance: bool = True
|
#!/usr/bin/env python3
"""Infoset-NG maintenance module.
Miscellaneous functions
"""
def print_ok(message):
"""Install python module using pip3.
Args:
module: module to install
Returns:
None
"""
# Print message
print('OK - {}'.format(message))
|
class bank:
def __init__(self,d,w):
self.deposit = d
self.withdrawl = w
def amount(self):
if self.withdrawl<=self.deposit:
print("remaining balance: %d " %(self.deposit - self.withdrawl))
else:
print("insufficient balance:")
d = int(input("... |
class Config:
framesPerExample = 512
exampleLength = 120
batch_size = 98 |
__author__ = 'sarangis'
class ModulePass:
def __init__(self):
pass
def run_on_module(self, node):
raise NotImplementedError("Derived passes class should implement run_on_module")
class FunctionPass:
def __init__(self):
pass
def run_on_function(self, node):
raise NotIm... |
github_config = {
"base_url": "",
"org": "",
"access_token": ""
} |
"""Online Stock Span"""
class StockSpanner:
"""https://leetcode.com/problems/online-stock-span/"""
def __init__(self):
# monotone decreasing stack
self.min_stack = []
def next(self, price: int) -> int:
weight = 1
while self.min_stack and self.min_stack[-1][0] <= price:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.