content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#-- powertools.vendorize
''' script to vendorize dependencies for a module
'''
#-------------------------------------------------------------------------------------------------#
#-------------------------------------------------------------------------------------------------#
| """ script to vendorize dependencies for a module
""" |
# -*- coding: utf-8 -*-
#auth table for developer and others
#search bar(using keywords)
#public,private projects
#group accesses for many groups
#this for the main categories..
db.define_table('category',
Field('name',requires=(IS_SLUG(),IS_LOWER(),IS_NOT_IN_DB(db,'category.name'))))
##this is for sub_category
d... | db.define_table('category', field('name', requires=(is_slug(), is_lower(), is_not_in_db(db, 'category.name'))))
db.define_table('subcategory', field('category', 'reference category', requires=is_in_db(db, 'category.id', '%(name)s')), field('title', requires=(is_slug(), is_lower(), is_not_in_db(db, 'subcategory.title'),... |
num = 1
num = 2
num2 = 3
| num = 1
num = 2
num2 = 3 |
PROJECT_URL = "https://github.com/sebiweise/Home-Assistant-Parcello/"
ISSUE_URL = "{}issues".format(PROJECT_URL)
DOMAIN = "parcello"
VERSION = "0.0.1"
ISSUE_URL = "https://github.com/sebiweise/Home-Assistant-Parcello/issues"
PLATFORM = "sensor"
API_BASEURL = "https://api-v4.parcello.org/v1/app"
# Configuration Proper... | project_url = 'https://github.com/sebiweise/Home-Assistant-Parcello/'
issue_url = '{}issues'.format(PROJECT_URL)
domain = 'parcello'
version = '0.0.1'
issue_url = 'https://github.com/sebiweise/Home-Assistant-Parcello/issues'
platform = 'sensor'
api_baseurl = 'https://api-v4.parcello.org/v1/app'
conf_scan_interval = 'sc... |
class DatabaseManipulator:
def __init__(self, conexao):
self.__conexao = conexao
self.__cursor = self.__conexao.cursor()
def getConexao(self):
return self.__conexao
def setConexao(self, conexao):
self.__conexao = conexao
def getCursor(self):
return self.__curso... | class Databasemanipulator:
def __init__(self, conexao):
self.__conexao = conexao
self.__cursor = self.__conexao.cursor()
def get_conexao(self):
return self.__conexao
def set_conexao(self, conexao):
self.__conexao = conexao
def get_cursor(self):
return self.__c... |
#
# Copyright 2017 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... | {'includes': ['../common.gypi'], 'variables': {'target_app_location_param': '<(PRODUCT_DIR)/demos'}, 'targets': [{'target_name': 'iondemohud_assets', 'type': 'static_library', 'includes': ['../dev/zipasset_generator.gypi'], 'dependencies': ['<(ion_dir)/port/port.gyp:ionport'], 'sources': ['res/iondemohud.iad']}, {'targ... |
N = int(input())
def get_impact(s: str):
strength = 1
impact = 0
for c in s:
if c == 'S':
impact += strength
else:
strength *= 2
return impact
for i in range(N):
d, p = input().split()
d = int(d)
sol = 0
if p.count('S') > d:
sol = ... | n = int(input())
def get_impact(s: str):
strength = 1
impact = 0
for c in s:
if c == 'S':
impact += strength
else:
strength *= 2
return impact
for i in range(N):
(d, p) = input().split()
d = int(d)
sol = 0
if p.count('S') > d:
sol = 'IMPOS... |
n = int(input())
if 0 <= n <= 100:
if n == 0:
print('E')
elif 1 <= n <= 35:
print('D')
elif 36 <= n <= 60:
print('C')
elif 61 <= n <= 85:
print('B')
elif 86 <= n <= 100:
print('A') | n = int(input())
if 0 <= n <= 100:
if n == 0:
print('E')
elif 1 <= n <= 35:
print('D')
elif 36 <= n <= 60:
print('C')
elif 61 <= n <= 85:
print('B')
elif 86 <= n <= 100:
print('A') |
def main():
n = int(input())
ans = list(map(int, input().split()))
m = int(input())
bms = list(map(int, input().split()))
gears = [bj/ai for bj in bms for ai in ans]
checked = list(filter(lambda gear : gear == int(gear), gears))
maximum = max(checked)
checked = list(filter(lambda gear ... | def main():
n = int(input())
ans = list(map(int, input().split()))
m = int(input())
bms = list(map(int, input().split()))
gears = [bj / ai for bj in bms for ai in ans]
checked = list(filter(lambda gear: gear == int(gear), gears))
maximum = max(checked)
checked = list(filter(lambda gear: ... |
class StaticSelf:
def __init__(self):
class C:
SELF = self
self.c = C()
assert self.c.SELF is self
| class Staticself:
def __init__(self):
class C:
self = self
self.c = c()
assert self.c.SELF is self |
# player names are used as id.
PLAYERS = ['Ronaldo', 'Zidan', 'Raul', 'Beckham', 'Figo', 'Carlos']
# default values for trueskill calculator
# I made this (50, 16.33)
# even though trueskill's originals are (25, 8.33)
# because it ranges 0-100, it's more intuitive and natural I think.
MEAN = 50
STDDEV = 16.3333
... | players = ['Ronaldo', 'Zidan', 'Raul', 'Beckham', 'Figo', 'Carlos']
mean = 50
stddev = 16.3333
graph_xmax = 100
graph_ymax = 0.07
color_red = [1, 0.6, 0.6, 1]
color_blue = [0.6, 0.6, 1, 1]
color_gray = [0.5, 0.5, 0.5, 1] |
power = {'BUSES': {'Area': 1.33155,
'Bus/Area': 1.33155,
'Bus/Gate Leakage': 0.00662954,
'Bus/Peak Dynamic': 0.0,
'Bus/Runtime Dynamic': 0.0,
'Bus/Subthreshold Leakage': 0.0691322,
'Bus/Subthreshold Leakage with power gating': 0.0259246,
'Gate... | power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres... |
## params ##
nNodes = 5
nTraders = 2000
nGenesis = 4
nAddresses = nTraders
nMaxConfTerms = 100
nMaxConfVertices = 35
tSimtime = 100 # sec
tPow = 0.00 # sec
tNodeNetwork = 0.2 # sec
tHttpRequest = 0.2 # sec
tUnitVal = 0.003 # sec
tUnitValVar = 10 ** -7 # sec
tConfCycle = 1.0 # sec
tBroad = 0.01 # sec
rTxRate = 50 #
r... | n_nodes = 5
n_traders = 2000
n_genesis = 4
n_addresses = nTraders
n_max_conf_terms = 100
n_max_conf_vertices = 35
t_simtime = 100
t_pow = 0.0
t_node_network = 0.2
t_http_request = 0.2
t_unit_val = 0.003
t_unit_val_var = 10 ** (-7)
t_conf_cycle = 1.0
t_broad = 0.01
r_tx_rate = 50
r_conf_th = 0.8
amounts = [500] * nTrade... |
class Person:
"This is a person class"
age = 10
def greet(self):
print("Hello")
# Output: 10
print(Person.age)
# Output: <function Person.greet>
print(Person.greet)
# Output: "This is a person class"
print(Person.__doc__)
| class Person:
"""This is a person class"""
age = 10
def greet(self):
print('Hello')
print(Person.age)
print(Person.greet)
print(Person.__doc__) |
positive_words = {
"a+",
"abound",
"abounds",
"abundance",
"abundant",
"accessable",
"accessible",
"acclaim",
"acclaimed",
"acclamation",
"accolade",
"accolades",
"accommodative",
"accomodative",
"accomplish",
"accomplished",
"accomplishment",
"acc... | positive_words = {'a+', 'abound', 'abounds', 'abundance', 'abundant', 'accessable', 'accessible', 'acclaim', 'acclaimed', 'acclamation', 'accolade', 'accolades', 'accommodative', 'accomodative', 'accomplish', 'accomplished', 'accomplishment', 'accomplishments', 'accurate', 'accurately', 'achievable', 'achievement', 'ac... |
class Device:
def __init__(self, name, ise_id, address, device_type):
self.name = name
self.ise_id = ise_id
self.address = address
self.device_type = device_type
def get_name(self):
return self.name
def get_ise_id(self):
return self.ise_id
def get_addre... | class Device:
def __init__(self, name, ise_id, address, device_type):
self.name = name
self.ise_id = ise_id
self.address = address
self.device_type = device_type
def get_name(self):
return self.name
def get_ise_id(self):
return self.ise_id
def get_addr... |
c.TemplateExporter.exclude_input = True
c.Exporter.preprocessors = ['literacy.Execute']
#c.Exporter.preprocessors = ['literacy.template.Execute'] | c.TemplateExporter.exclude_input = True
c.Exporter.preprocessors = ['literacy.Execute'] |
class Crc8:
def __init__(s):
s.crc=255
def hash(s,int_list):
for i in int_list:
s.addVal(i)
return s.crc
def addVal(s,n):
crc = s.crc
for bit in range(0,8):
if ( n ^ crc ) & 0x80:
crc = ( crc << 1 ) ^ 0x31
else:
... | class Crc8:
def __init__(s):
s.crc = 255
def hash(s, int_list):
for i in int_list:
s.addVal(i)
return s.crc
def add_val(s, n):
crc = s.crc
for bit in range(0, 8):
if (n ^ crc) & 128:
crc = crc << 1 ^ 49
else:
... |
class Service:
@staticmethod
def ulr_identification(user_data):
url = user_data["url"]
return url
@staticmethod
def location(user_data):
lat = user_data["lat"]
lon = user_data["lon"]
return lat, lon
| class Service:
@staticmethod
def ulr_identification(user_data):
url = user_data['url']
return url
@staticmethod
def location(user_data):
lat = user_data['lat']
lon = user_data['lon']
return (lat, lon) |
# Chapter05_01
# Python Function
# Python Function and lambda
# How to defeine Function
# def function_name(parameter):
# code
# Ex1
def first_func(w):
print('Hello, ', w)
word = 'Goodboy'
first_func(word)
# Ex2
def return_func(w1):
value = 'Hello, ' + str(w1)
return value
x = return_func('Goodb... | def first_func(w):
print('Hello, ', w)
word = 'Goodboy'
first_func(word)
def return_func(w1):
value = 'Hello, ' + str(w1)
return value
x = return_func('Goodboy2')
print(x)
def func_mul(x):
y1 = x * 10
y2 = x * 20
y3 = x * 30
return (y1, y2, y3)
(x, y, z) = func_mul(10)
print(x, y, z)
def ... |
class DistcoveryException(Exception):
def __init__(self, **kwargs):
super(DistcoveryException, self). \
__init__(self.template % kwargs)
class NoMoreAttempts(DistcoveryException):
template = 'Coudn\'t create unique name with %(length)d ' \
'digit%(length_suffix)s in %(limit)d... | class Distcoveryexception(Exception):
def __init__(self, **kwargs):
super(DistcoveryException, self).__init__(self.template % kwargs)
class Nomoreattempts(DistcoveryException):
template = "Coudn't create unique name with %(length)d digit%(length_suffix)s in %(limit)d attemt%(limit_suffix)s."
def ... |
__all__ = ["COMPRESSIONS"]
COMPRESSIONS = {
# gz
".gz": "gz",
".tgz": "gz",
# xz
".xz": "xz",
".txz": "xz",
# bz2
".bz2": "bz2",
".tbz": "bz2",
".tbz2": "bz2",
".tb2": "bz2",
# zst
".zst": "zst",
".tzst": "zst",
}
| __all__ = ['COMPRESSIONS']
compressions = {'.gz': 'gz', '.tgz': 'gz', '.xz': 'xz', '.txz': 'xz', '.bz2': 'bz2', '.tbz': 'bz2', '.tbz2': 'bz2', '.tb2': 'bz2', '.zst': 'zst', '.tzst': 'zst'} |
def count_1478(digits, output):
sum = 0
if len(digits) == 10 and len(output) == 4:
digit_sets = [set()] * 10
for digit in digits:
if len(digit) == 2:
digit_sets[1] = set(digit)
elif len(digit) == 3:
digit_sets[7] = set(digit)
el... | def count_1478(digits, output):
sum = 0
if len(digits) == 10 and len(output) == 4:
digit_sets = [set()] * 10
for digit in digits:
if len(digit) == 2:
digit_sets[1] = set(digit)
elif len(digit) == 3:
digit_sets[7] = set(digit)
el... |
#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pysnmp/license.html
#
# PySNMP MIB module SNMP-NOTIFICATION-MIB (http://snmplabs.com/pysnmp)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-NOTIFICATION-MIB
# Produced by pysmi-0.... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ... |
# Created by MechAviv
# Map ID :: 620100043
# Ballroom : Lobby
sm.curNodeEventEnd(True)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(True, True, False, False)
sm.sendDelay(3000)
sm.showEffect("Effect/DirectionNewPirate.img/newPirate/balloonMsg2/6", 2000, 130, 0, 10, -2, True, 0)
sm.sendDelay(1000)
sm.setSp... | sm.curNodeEventEnd(True)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(True, True, False, False)
sm.sendDelay(3000)
sm.showEffect('Effect/DirectionNewPirate.img/newPirate/balloonMsg2/6', 2000, 130, 0, 10, -2, True, 0)
sm.sendDelay(1000)
sm.setSpeakerID(9270088)
sm.removeEscapeButton()
sm.setPlayerAsSpeaker()
sm.... |
#
# PySNMP MIB module RUCKUS-SZ-EVENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RUCKUS-SZ-EVENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:59:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) ... |
# 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 tmpCount(sumN, l):
digit, i = 0, 0
while l:
... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def tmp_count(sumN, l):
(digit, i) = (0, 0)
while l:
v = l.val
l = l.next
... |
def f(c):
for i in [1, 2, 3]:
if c:
x = 0
break
else:
x = 1
return x #pass
| def f(c):
for i in [1, 2, 3]:
if c:
x = 0
break
else:
x = 1
return x |
__author__ = 'rolandh'
ENTITYATTRIBUTES = "urn:oasis:names:tc:SAML:metadata:attribute&EntityAttributes"
def entity_categories(md):
res = []
if "extensions" in md:
for elem in md["extensions"]["extension_elements"]:
if elem["__class__"] == ENTITYATTRIBUTES:
for attr in elem... | __author__ = 'rolandh'
entityattributes = 'urn:oasis:names:tc:SAML:metadata:attribute&EntityAttributes'
def entity_categories(md):
res = []
if 'extensions' in md:
for elem in md['extensions']['extension_elements']:
if elem['__class__'] == ENTITYATTRIBUTES:
for attr in elem['... |
#!usr/bin/python3
# Filename: break.py
while True: # Fakes R's repeat loop
s = (input('Enter something: '))
if s == 'quit': # Provide condition to end the loop
break
print('Length of the string is ', len(s))
print('Done') | while True:
s = input('Enter something: ')
if s == 'quit':
break
print('Length of the string is ', len(s))
print('Done') |
class Collection:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
ber_over_snr = Collection(
bits_per_slot=440,
slot_per_frame=1,
give_up_value=1e-6,
# How many bits to aim for at give_up_value
certainty=20,
# Stop early at x number of errors. Make sure to scale togethe... | class Collection:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
ber_over_snr = collection(bits_per_slot=440, slot_per_frame=1, give_up_value=1e-06, certainty=20, stop_at_errors=100000, snr_stop=100, snr_step=2.5, branches=5) |
class Solution:
# Max Sum LC (Accepted), O(m * n) time, O(m) space
def maximumWealth(self, accounts: List[List[int]]) -> int:
return max(sum(row) for row in accounts)
# Max Map Sum (Top Voted), O(m * n) time, O(m) space
def maximumWealth(self, accounts: List[List[int]]) -> int:
return m... | class Solution:
def maximum_wealth(self, accounts: List[List[int]]) -> int:
return max((sum(row) for row in accounts))
def maximum_wealth(self, accounts: List[List[int]]) -> int:
return max(map(sum, accounts)) |
GSTR_APPFOLDER = 1
GSTR_CONFOLDER = 2
GSTR_LANFOLDER = 3
GSTR_TEMFOLDER = 4
GSTR_CE_FILE = 5
GSTR_CONF_FILE = 6
GSTR_LOC_FILE = 7
GSTR_SSET_FILE = 8
GSTR_LOCX_FILE = 9
GSTR_CEX_FILE = 10
GSTR_CONFX_FILE = 11
GSTR_TZ_FILE = 12
GSTR_COUNTRY_FILE = 13
GSTR_TEXT_FILE = 14
GSTR_TIPS_FILE = 15
GSTR_HELP_FILE = 16
| gstr_appfolder = 1
gstr_confolder = 2
gstr_lanfolder = 3
gstr_temfolder = 4
gstr_ce_file = 5
gstr_conf_file = 6
gstr_loc_file = 7
gstr_sset_file = 8
gstr_locx_file = 9
gstr_cex_file = 10
gstr_confx_file = 11
gstr_tz_file = 12
gstr_country_file = 13
gstr_text_file = 14
gstr_tips_file = 15
gstr_help_file = 16 |
bind_to = 'localhost'
port = 8001
client_id = 'INSERT GOOGLE CLIENT ID'
| bind_to = 'localhost'
port = 8001
client_id = 'INSERT GOOGLE CLIENT ID' |
# like a version, touched for the very first time
version = '0.2.10'
# definitions for coin types / chains supported
# selected by sqc.cfg['cointype']
ADDR_CHAR = 0
ADDR_PREFIX = 1
P2SH_CHAR = 2
P2SH_PREFIX = 3
BECH_HRP = 4
BLKDAT_MAGIC = 5
BLKDAT_NEAR_SYNC = 6
BLK_REWARD = 7
HALF_BLKS = 8
coin_cfg = {
'bitcoin... | version = '0.2.10'
addr_char = 0
addr_prefix = 1
p2_sh_char = 2
p2_sh_prefix = 3
bech_hrp = 4
blkdat_magic = 5
blkdat_near_sync = 6
blk_reward = 7
half_blks = 8
coin_cfg = {'bitcoin': ['1', 0, '3', 5, 'bc', 3652501241, 500, 50 * 100000000.0, 210000], 'testnet': ['mn', 111, '2', 196, 'tb', 118034699, 8000, 50 * 10000000... |
#!/usr/bin/python3
# https://practice.geeksforgeeks.org/problems/pairs-of-prime-number/0
def getPrimes(n):
primes = [True]*(n+1)
primes[0] = False
primes[1] = False
i=2
while i*i<=n:
if primes[i]:
for j in range(2*i, n+1, i):
primes[j] = False
i+=1
... | def get_primes(n):
primes = [True] * (n + 1)
primes[0] = False
primes[1] = False
i = 2
while i * i <= n:
if primes[i]:
for j in range(2 * i, n + 1, i):
primes[j] = False
i += 1
return primes
def sol(n):
p = []
i = 2
while i <= n // 2:
... |
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> List[str]:
if not s or not wordDict or len(wordDict) == 0:
return []
return self.dfs(s, wordDict, {})
def dfs(self, s: str, wordDict: List[str], memo: dict[str, List[str]]) -> None:
if s in memo:
... | class Solution:
def word_break(self, s: str, wordDict: List[str]) -> List[str]:
if not s or not wordDict or len(wordDict) == 0:
return []
return self.dfs(s, wordDict, {})
def dfs(self, s: str, wordDict: List[str], memo: dict[str, List[str]]) -> None:
if s in memo:
... |
class Coordenada:
def __init__(self, x, y):
self.x = x
self.y = y
def distancia(self, otro_cordenada):
x_diff = (self.x - otro_cordenada.x)**2
y_diff = (self.y - otro_cordenada.y)**2
return (x_diff + y_diff)**0.5
if __name__ == '__main__':
coord1 = Coordenada(... | class Coordenada:
def __init__(self, x, y):
self.x = x
self.y = y
def distancia(self, otro_cordenada):
x_diff = (self.x - otro_cordenada.x) ** 2
y_diff = (self.y - otro_cordenada.y) ** 2
return (x_diff + y_diff) ** 0.5
if __name__ == '__main__':
coord1 = coordenada(... |
ENV = "BipedalWalker-v2"
LOAD = True
DISPLAY = True
DISCOUNT = 0.99
FRAME_SKIP = 4
EPSILON_START = 0.1
EPSILON_STOP = 0.05
EPSILON_STEPS = 25000
ACTOR_LEARNING_RATE = 1e-3
CRITIC_LEARNING_RATE = 1e-3
# Memory size
BUFFER_SIZE = 100000
BATCH_SIZE = 1024
# Number of episodes of game environment to train with
TRA... | env = 'BipedalWalker-v2'
load = True
display = True
discount = 0.99
frame_skip = 4
epsilon_start = 0.1
epsilon_stop = 0.05
epsilon_steps = 25000
actor_learning_rate = 0.001
critic_learning_rate = 0.001
buffer_size = 100000
batch_size = 1024
training_steps = 1500000
max_episode_steps = 125
training_freq = 4
update_targe... |
class MessageTooLong(Exception):
pass
class MissingAttributes(Exception):
def __init__(self, attrs):
msg = 'Required attribute(s) missing: {}'.format(attrs)
super().__init__(msg)
class MustBeBytes(Exception):
pass
class NoLineEnding(Exception):
pass
class StrayLineEnding(Exceptio... | class Messagetoolong(Exception):
pass
class Missingattributes(Exception):
def __init__(self, attrs):
msg = 'Required attribute(s) missing: {}'.format(attrs)
super().__init__(msg)
class Mustbebytes(Exception):
pass
class Nolineending(Exception):
pass
class Straylineending(Exception):... |
deg, dis = map(int, input().split())
dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
wps = [2, 15, 33, 54, 79, 107, 138, 171, 207, 244, 284, 326]
w = 0
for n in wps:
if int(dis/6 + 0.5) > n:
w += 1
dir = dirs[(deg * 10 + 1125) % 36000 // 2250] ... | (deg, dis) = map(int, input().split())
dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
wps = [2, 15, 33, 54, 79, 107, 138, 171, 207, 244, 284, 326]
w = 0
for n in wps:
if int(dis / 6 + 0.5) > n:
w += 1
dir = dirs[(deg * 10 + 1125) % 36000 // 2250] ... |
class Node:
def __init__(self, data) -> None:
self.data = data
self.next = None
class LinkedList:
def __init__(self) -> None:
self.head = None
def push(self, data):
New_node = Node(data)
New_node.next = self.head
self.head = New_node... | class Node:
def __init__(self, data) -> None:
self.data = data
self.next = None
class Linkedlist:
def __init__(self) -> None:
self.head = None
def push(self, data):
new_node = node(data)
New_node.next = self.head
self.head = New_node
def get_count(sel... |
class StakeHolderDetails:
def __init__(self, blockchain_id, staker, amount_staked, reward_amount, claimable_amount, refund_amount,
auto_renewal, block_no_created):
self.__blockchain_id = blockchain_id
self.__staker = staker
self.__amount_staked = amount_staked
self._... | class Stakeholderdetails:
def __init__(self, blockchain_id, staker, amount_staked, reward_amount, claimable_amount, refund_amount, auto_renewal, block_no_created):
self.__blockchain_id = blockchain_id
self.__staker = staker
self.__amount_staked = amount_staked
self.__reward_amount =... |
expected_output = {
'active_query': {
'periodicity_mins': 30,
'status': 'Enabled'
},
'mdns_gateway': 'Enabled',
'mdns_query_type': 'ALL',
'mdns_service_policy': 'default-mdns-service-policy',
'sdg_agent_ip': '10.1.1.2',
'service_instance_suffix': 'N... | expected_output = {'active_query': {'periodicity_mins': 30, 'status': 'Enabled'}, 'mdns_gateway': 'Enabled', 'mdns_query_type': 'ALL', 'mdns_service_policy': 'default-mdns-service-policy', 'sdg_agent_ip': '10.1.1.2', 'service_instance_suffix': 'Not-Configured', 'source_interface': 'Vlan4025', 'transport_type': 'IPv4', ... |
n=[]
t=[]
nome=""
while(nome!="fim"):
nome=input("Digite um nome: ")
if(nome!="fim"):
n.append(nome)
t.append(input("Digite o telefone: "))
tamanhoDaLista=len(n)
print(n)
print(t)
print(tamanhoDaLista)
print(n[-1]) #de tras pra frente | n = []
t = []
nome = ''
while nome != 'fim':
nome = input('Digite um nome: ')
if nome != 'fim':
n.append(nome)
t.append(input('Digite o telefone: '))
tamanho_da_lista = len(n)
print(n)
print(t)
print(tamanhoDaLista)
print(n[-1]) |
class Solution:
def isValid(self, pos):
if(pos[0] >= self.matrix_row or pos[1] >= self.matrix_col):
return False
return True
def get_all_path_to_goal(self, matrix, st):
self.matrix_row = len(matrix)
self.matrix_col = len(matrix[0])
self.matrix = matrix
... | class Solution:
def is_valid(self, pos):
if pos[0] >= self.matrix_row or pos[1] >= self.matrix_col:
return False
return True
def get_all_path_to_goal(self, matrix, st):
self.matrix_row = len(matrix)
self.matrix_col = len(matrix[0])
self.matrix = matrix
... |
class ListNode:
def __init__(self, val: int, prev_node=None, next_node=None):
self.val = val
self.prev_node = prev_node
if self.prev_node:
self.prev_node.next_node = self
self.next_node = next_node
if self.next_node:
self.next_node.prev_node = self
... | class Listnode:
def __init__(self, val: int, prev_node=None, next_node=None):
self.val = val
self.prev_node = prev_node
if self.prev_node:
self.prev_node.next_node = self
self.next_node = next_node
if self.next_node:
self.next_node.prev_node = self
... |
class VerificationModel(object):
def __init__(self, password, mail, code):
self.Password = password
self.Mail = mail
self.CodeUtilisateur = code
| class Verificationmodel(object):
def __init__(self, password, mail, code):
self.Password = password
self.Mail = mail
self.CodeUtilisateur = code |
#!/usr/bin/env python3.6
#Author: Vishwas K Singh
#Email: vishwasks32@gmail.com
# Program: A Simple module with some problematic test code
# Listing10.3
# hello3.py
def hello():
print('Hello, world!')
# A test:
hello()
| def hello():
print('Hello, world!')
hello() |
def extractAnonanemoneWordpressCom(item):
'''
Parser for 'anonanemone.wordpress.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
tagmap = [
('tmpw', 'The Man\'s Perfect Wife', ... | def extract_anonanemone_wordpress_com(item):
"""
Parser for 'anonanemone.wordpress.com'
"""
(vol, chp, frag, postfix) = extract_vol_chapter_fragment_postfix(item['title'])
if not (chp or vol) or 'preview' in item['title'].lower():
return None
tagmap = [('tmpw', "The Man's Perfect Wife", 'trans... |
def square(n):
print("Square of ",n,"is",(n*n))
def cude(n):
print("Cube of ",n,"is",(n*n*n))
cude(3)
square(4) | def square(n):
print('Square of ', n, 'is', n * n)
def cude(n):
print('Cube of ', n, 'is', n * n * n)
cude(3)
square(4) |
name_and_hp = '''SELECT name, hp
FROM charactercreator_character;'''
# More queries to go here below
| name_and_hp = 'SELECT name, hp \n FROM charactercreator_character;' |
dummy_papers = [
{
"abstract": "This is an abstract.",
"authors": ["Yi Zhu", "Shawn Newsam"],
"category": "cs.CV",
"comment": "WACV 2017 camera ready, minor updates about test time efficiency",
"img": "/static/thumbs/1612.07403v2.pdf.jpg",
"link": "http://arxiv.org/ab... | dummy_papers = [{'abstract': 'This is an abstract.', 'authors': ['Yi Zhu', 'Shawn Newsam'], 'category': 'cs.CV', 'comment': 'WACV 2017 camera ready, minor updates about test time efficiency', 'img': '/static/thumbs/1612.07403v2.pdf.jpg', 'link': 'http://arxiv.org/abs/1612.07403v2', 'originally_published_time': '12/22/2... |
#!/usr/bin/python3
count = 0
i = 2
while i < 100:
k = i/2
j = 2
while j <= k:
k = i % j
if k == 0:
count = count - 1
break
k = i/2
j = j + 1
count = count + 1
i = i + 1
print(count)
| count = 0
i = 2
while i < 100:
k = i / 2
j = 2
while j <= k:
k = i % j
if k == 0:
count = count - 1
break
k = i / 2
j = j + 1
count = count + 1
i = i + 1
print(count) |
class IAMUsers():
def __init__(self, iam):
self.client = iam
# User methods
def _users_marker_handler(self, marker=None):
if marker:
response = self.client.list_users(Marker=marker)
else:
response = self.client.list_users()
return response
def _... | class Iamusers:
def __init__(self, iam):
self.client = iam
def _users_marker_handler(self, marker=None):
if marker:
response = self.client.list_users(Marker=marker)
else:
response = self.client.list_users()
return response
def _attached_policies_mar... |
{
"targets":
[
{
"target_name": "SpatialHashing",
"sources": ["src/SpatialHashing/SpatialHashing.cc"]
}
]
}
| {'targets': [{'target_name': 'SpatialHashing', 'sources': ['src/SpatialHashing/SpatialHashing.cc']}]} |
def is_prime(n):
cnt=2
if n<=1 :
return 0
if n==2 or n==3:
return 1
if n%2==0 or n%3==0:
return 0
if n<9:
return 1
counter=5
while(counter*counter<=n):
if n%counter==0:
return 0
if n%(counter+2)==0:
return... | def is_prime(n):
cnt = 2
if n <= 1:
return 0
if n == 2 or n == 3:
return 1
if n % 2 == 0 or n % 3 == 0:
return 0
if n < 9:
return 1
counter = 5
while counter * counter <= n:
if n % counter == 0:
return 0
if n % (counter + 2) == 0:
... |
class Question:
def __init__(self, text, category):
self.__question_text = text
self.__question_category = category
@property
def question_text(self):
return self.__question_text
@question_text.setter
def question_text(self, value):
self.__question_text = value
... | class Question:
def __init__(self, text, category):
self.__question_text = text
self.__question_category = category
@property
def question_text(self):
return self.__question_text
@question_text.setter
def question_text(self, value):
self.__question_text = value
... |
class FailureSummary(object):
def __init__(self, protocol, ctx, failed_method, reason):
self.__protocol = protocol
self.is_success = False
self.is_failure = True
self.ctx = ctx
self.__failed_method = failed_method
self.__failure_reason = reason
def failed_on(self... | class Failuresummary(object):
def __init__(self, protocol, ctx, failed_method, reason):
self.__protocol = protocol
self.is_success = False
self.is_failure = True
self.ctx = ctx
self.__failed_method = failed_method
self.__failure_reason = reason
def failed_on(sel... |
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
triangle = []
for row_num in range(numRows):
row=[None for _ in range(row_num+1)]
row[0],row[-1]=1,1
for j in range(1,len(row)-1):
row[j]=triangle[r... | class Solution:
def generate(self, numRows: int) -> List[List[int]]:
triangle = []
for row_num in range(numRows):
row = [None for _ in range(row_num + 1)]
(row[0], row[-1]) = (1, 1)
for j in range(1, len(row) - 1):
row[j] = triangle[row_num - 1][j... |
print("Hello World!!")
print()
print('-----------------------')
print()
print(note := 'python supports break and continue')
print(note := 'Below loop will stop when i = 5')
for i in range(1, 11):
# we can do comparison like below
if i % 5 == 0:
print(note := 'we have found a multiple of 5')
print(i)
print(no... | print('Hello World!!')
print()
print('-----------------------')
print()
print((note := 'python supports break and continue'))
print((note := 'Below loop will stop when i = 5'))
for i in range(1, 11):
if i % 5 == 0:
print((note := 'we have found a multiple of 5'))
print(i)
print((note := 'we ... |
# -*- coding: utf-8 -*-
def info_path(owner_id):
return 'data/photos_{}.csv'.format(owner_id)
| def info_path(owner_id):
return 'data/photos_{}.csv'.format(owner_id) |
WORKING_DIR_PATH_FULL = '/Users/hitesh/Documents/workspace/JARVIS/'
SAVED_FILES_DIR_FULL_PATH = WORKING_DIR_PATH_FULL + 'saved_files/'
NER_DIR_FULL_PATH = SAVED_FILES_DIR_FULL_PATH + 'ner/'
NER_TRAINING_FILE_PATH_FULL = NER_DIR_FULL_PATH + 'NER_token_training.tsv'
NER_PROPERTY_FILE_PATH_FULL = NER_DIR_FULL_PATH + 'NE... | working_dir_path_full = '/Users/hitesh/Documents/workspace/JARVIS/'
saved_files_dir_full_path = WORKING_DIR_PATH_FULL + 'saved_files/'
ner_dir_full_path = SAVED_FILES_DIR_FULL_PATH + 'ner/'
ner_training_file_path_full = NER_DIR_FULL_PATH + 'NER_token_training.tsv'
ner_property_file_path_full = NER_DIR_FULL_PATH + 'NERP... |
#! /usr/bin/python3
param_list = [
{
'task': 'train',
'boosting_type': 'gbdt',
'objective': 'binary',
'metric': {'auc'},
'train_metric': True,
'num_leaves': 63,
'lambda_l1': 0,
'lambda_l2': 1,
# 'min_data_in_leaf': 100,
'min_child_weight': 50,
'learning_rate': 0.1,
'feat... | param_list = [{'task': 'train', 'boosting_type': 'gbdt', 'objective': 'binary', 'metric': {'auc'}, 'train_metric': True, 'num_leaves': 63, 'lambda_l1': 0, 'lambda_l2': 1, 'min_child_weight': 50, 'learning_rate': 0.1, 'feature_fraction': 0.6, 'bagging_fraction': 0.7, 'bagging_freq': 1, 'verbose': 1, 'num_iterations': 30... |
def prime_num(n,prime):
while(True):
for a in range(2,n):
if n%a==0:
n+=1
prime_num(n,prime);
else:
print(n)
prime.append(n)
if len(prime)==10:
break
n=2
prime=[]
prime_num(n,prime);
| def prime_num(n, prime):
while True:
for a in range(2, n):
if n % a == 0:
n += 1
prime_num(n, prime)
else:
print(n)
prime.append(n)
if len(prime) == 10:
break
n = 2
prime = []
prime_num(n, prime) |
expected_output = {
"svl_info": {
1: {
"link_status": "U",
"ports": "HundredGigE1/0/26",
"protocol_status": "R",
"svl": 1,
"switch": 1,
}
}
}
| expected_output = {'svl_info': {1: {'link_status': 'U', 'ports': 'HundredGigE1/0/26', 'protocol_status': 'R', 'svl': 1, 'switch': 1}}} |
#CvModName.py
modName = "BUG Mod"
displayName = "BUG Mod"
modVersion = "4.4 [Build 2220]"
civName = "BtS"
civVersion = "3.13-3.19"
def getName():
return modName
def getDisplayName():
return displayName
def getVersion():
return modVersion
def getNameAndVersion():
return modName + " " + modVe... | mod_name = 'BUG Mod'
display_name = 'BUG Mod'
mod_version = '4.4 [Build 2220]'
civ_name = 'BtS'
civ_version = '3.13-3.19'
def get_name():
return modName
def get_display_name():
return displayName
def get_version():
return modVersion
def get_name_and_version():
return modName + ' ' + modVersion
def ... |
#
# PySNMP MIB module CISCO-CCM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-CCM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:35:23 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_union, value_size_constraint, constraints_intersection) ... |
#!/usr/bin/env python
'''
Event class and enums for Mission Editor
Michael Day
June 2014
'''
#MissionEditorEvents come FROM the GUI (with a few exceptions where the Mission Editor Module sends a message to itself, e.g., MEE_TIME_TO_QUIT)
#MissionEditorGUIEvents go TO the GUI
#enum for MissionEditorEvent types
MEE_READ_... | """
Event class and enums for Mission Editor
Michael Day
June 2014
"""
mee_read_wps = 0
mee_write_wps = 1
mee_time_to_quit = 2
mee_get_wp_rad = 3
mee_get_loit_rad = 4
mee_get_wp_default_alt = 5
mee_write_wp_num = 6
mee_load_wp_file = 7
mee_save_wp_file = 8
mee_set_wp_rad = 9
mee_set_loit_rad = 10
mee_set_wp_default_alt... |
l = int(input("Enter number of lines: "))
for i in range (1, l+1):
for z in range(1, i + 1):
print(z, end = " ")
print() | l = int(input('Enter number of lines: '))
for i in range(1, l + 1):
for z in range(1, i + 1):
print(z, end=' ')
print() |
def simple_operations(a1: torch.Tensor, a2: torch.Tensor, a3: torch.Tensor):
# multiplication of tensor a1 with tensor a2 and then add it with tensor a3
answer = a1 @ a2 + a3
return answer
# add timing to airtable
atform.add_event('Coding Exercise 2.2 : Simple tensor operations-simple_operations')
# Computing ... | def simple_operations(a1: torch.Tensor, a2: torch.Tensor, a3: torch.Tensor):
answer = a1 @ a2 + a3
return answer
atform.add_event('Coding Exercise 2.2 : Simple tensor operations-simple_operations')
a1 = torch.tensor([[2, 4], [5, 7]])
a2 = torch.tensor([[1, 1], [2, 3]])
a3 = torch.tensor([[10, 10], [12, 1]])
a =... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flat
class BoostOption(object):
Normal_Boost = 0
Unlimited_Boost = 1
Slow_Recharge = 2
Rapid_Recharge = 3
No_Boost = 4
| class Boostoption(object):
normal__boost = 0
unlimited__boost = 1
slow__recharge = 2
rapid__recharge = 3
no__boost = 4 |
#
# PySNMP MIB module CISCOSB-TRAPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-TRAPS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:23:52 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) ... |
_base_ = [
'../../_base_/default_runtime.py',
'../../_base_/schedules/schedule_adam_600e.py',
'../../_base_/det_models/panet_r50_fpem_ffm.py',
'../../_base_/det_datasets/icdar2017.py',
'../../_base_/det_pipelines/panet_pipeline.py'
]
train_list = {{_base_.train_list}}
test_list = {{_base_.test_list... | _base_ = ['../../_base_/default_runtime.py', '../../_base_/schedules/schedule_adam_600e.py', '../../_base_/det_models/panet_r50_fpem_ffm.py', '../../_base_/det_datasets/icdar2017.py', '../../_base_/det_pipelines/panet_pipeline.py']
train_list = {{_base_.train_list}}
test_list = {{_base_.test_list}}
train_pipeline_icdar... |
#Write a program that prompts for a file name, then opens that file and reads through the file,
#and print the contents of the file in upper case.
#Use the file words.txt to produce the output below.
#You can download the sample data at http://www.py4e.com/code3/words.txt
# Use words.txt as the file name
fname = input... | fname = input('Enter file name: ')
fh = open(fname)
print('fh___', fh)
book = fh.read()
print('book___', book)
book_capital = book.upper()
book_capita_lrstrip = bookCAPITAL.rstrip()
print(bookCAPITALrstrip) |
class Player:
def __init__(self, name: str):
self.name = name
self.wins = 0
def add_win(self):
self.wins += 1
class Player_War(Player):
def __init__(self, name: str):
super().__init__(name)
self.card = None | class Player:
def __init__(self, name: str):
self.name = name
self.wins = 0
def add_win(self):
self.wins += 1
class Player_War(Player):
def __init__(self, name: str):
super().__init__(name)
self.card = None |
# The MIT License (MIT)
# Copyright (c) 2015 Yanzheng Li
# 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, copy, modify,... | const_str_slice = __call_cls_builtin(str, 'slice(')
const_str_comma = __call_cls_builtin(str, ', ')
const_str_close_paren = __call_cls_builtin(str, ')')
const_int_zero = __call_cls_builtin(int, 0)
class Slice(object):
def __init__(self, start, stop, step):
self.start = start
self.stop = stop
... |
car_lot = ["Ford", "Dodge", "Toyota", "Ford", "Toyota", "Chevrolet", "Ford"]
print(car_lot.count("Ford"))
| car_lot = ['Ford', 'Dodge', 'Toyota', 'Ford', 'Toyota', 'Chevrolet', 'Ford']
print(car_lot.count('Ford')) |
class Board():
WINNERS = [
set([(0, 0), (0, 1), (0, 2), (0, 3), (0, 4)]),
set([(1, 0), (1, 1), (1, 2), (1, 3), (1, 4)]),
set([(2, 0), (2, 1), (2, 2), (2, 3), (2, 4)]),
set([(3, 0), (3, 1), (3, 2), (3, 3), (3, 4)]),
set([(4, 0), (4, 1), (4, 2), (4, 3), (4, 4)]),
set([(... | class Board:
winners = [set([(0, 0), (0, 1), (0, 2), (0, 3), (0, 4)]), set([(1, 0), (1, 1), (1, 2), (1, 3), (1, 4)]), set([(2, 0), (2, 1), (2, 2), (2, 3), (2, 4)]), set([(3, 0), (3, 1), (3, 2), (3, 3), (3, 4)]), set([(4, 0), (4, 1), (4, 2), (4, 3), (4, 4)]), set([(0, 0), (1, 0), (2, 0), (3, 0), (4, 0)]), set([(0, 1... |
class Solution:
def nextGreaterElement(self, n: int) -> int:
num = list(str(n))
# Start from the right most digit and find the first
# digit that is smaller than the digit next to it
i = len(num)-1
while i-1 >= 0 and num[i] <= num[i-1]:
i -= 1
if... | class Solution:
def next_greater_element(self, n: int) -> int:
num = list(str(n))
i = len(num) - 1
while i - 1 >= 0 and num[i] <= num[i - 1]:
i -= 1
if i == 0:
return -1
smallest = i
while smallest + 1 < len(num) and num[smallest + 1] > num[i ... |
# Base class
class SchemaError(Exception):
pass
class SchemaBaseError(SchemaError):
pass
class SchemaAttributeError(SchemaError):
pass
# Don't catch these exceptions
class SchemaBaseUnknownAttribute(SchemaBaseError):
pass
class SchemaBaseLinkTypeNotSupported(SchemaBaseError):
pass
class Sc... | class Schemaerror(Exception):
pass
class Schemabaseerror(SchemaError):
pass
class Schemaattributeerror(SchemaError):
pass
class Schemabaseunknownattribute(SchemaBaseError):
pass
class Schemabaselinktypenotsupported(SchemaBaseError):
pass
class Schemabaseunknownobjecttype(SchemaBaseError):
p... |
class FoxProgression:
def theCount(self, seq):
if len(seq) == 1:
return -1
a, m = seq[1]-seq[0], seq[1]/float(seq[0])
af, mf = True, m == int(m)
c = sum((af, mf))
for i, j in zip(seq[1:], seq[2:]):
if af and j-i != a:
af = False
... | class Foxprogression:
def the_count(self, seq):
if len(seq) == 1:
return -1
(a, m) = (seq[1] - seq[0], seq[1] / float(seq[0]))
(af, mf) = (True, m == int(m))
c = sum((af, mf))
for (i, j) in zip(seq[1:], seq[2:]):
if af and j - i != a:
... |
#
# PySNMP MIB module ARUBA-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ARUBA-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:25:46 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... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, single_value_constraint, value_size_constraint) ... |
def YesNo(message=None):
if message:
print(message + ' [y/N]')
else:
print('[y/N]')
choice = input()
if choice != 'y' and choice != 'Y':
return False
return True
def YesNoTwice():
if YesNo():
return YesNo("Are you really really sure?")
return False
def YesNoTrice():
if YesNo():
i... | def yes_no(message=None):
if message:
print(message + ' [y/N]')
else:
print('[y/N]')
choice = input()
if choice != 'y' and choice != 'Y':
return False
return True
def yes_no_twice():
if yes_no():
return yes_no('Are you really really sure?')
return False
def ... |
for i in range(int(input())):
n=int(input())
a=[int(x) for x in input().split()]
m=int(input())
my=[]
pf,c=0,0
q=[]
for i in range(n):
z=a[i]
if z not in my:
if len(my)<m:
my.append(z)
else:
my[my.index(q.pop(0))]=z
... | for i in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
my = []
(pf, c) = (0, 0)
q = []
for i in range(n):
z = a[i]
if z not in my:
if len(my) < m:
my.append(z)
else:
my[my.i... |
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
for i in range(k-1):
nums.remove(max(nums))
return max(nums)
| class Solution:
def find_kth_largest(self, nums: List[int], k: int) -> int:
for i in range(k - 1):
nums.remove(max(nums))
return max(nums) |
# Garo9521
# https://codeforces.com/contest/1521/problem/B
# math
t = int(input())
for case in range(t):
n = int(input())
array = list(map(int, input().split()))
minpos = array.index(min(array))
print(n - 1)
for i in range(minpos):
print(i + 1, minpos + 1, array[minpos] + minpos - i, array[m... | t = int(input())
for case in range(t):
n = int(input())
array = list(map(int, input().split()))
minpos = array.index(min(array))
print(n - 1)
for i in range(minpos):
print(i + 1, minpos + 1, array[minpos] + minpos - i, array[minpos])
for i in range(minpos + 1, n):
print(minpos + ... |
class Encoder(tf.keras.layers.Layer):
def __init__(self, intermediate_dim):
super(Encoder, self).__init__()
self.hidden_layer = tf.keras.layers.Dense(
units=intermediate_dim,
activation=tf.nn.relu,
kernel_initializer='he_uniform'
)
self.output_layer = tf.keras.layers.Dense(
un... | class Encoder(tf.keras.layers.Layer):
def __init__(self, intermediate_dim):
super(Encoder, self).__init__()
self.hidden_layer = tf.keras.layers.Dense(units=intermediate_dim, activation=tf.nn.relu, kernel_initializer='he_uniform')
self.output_layer = tf.keras.layers.Dense(units=intermediate_... |
def main():
# input
S = input()
T = input()
U = input()
# compute
# output
print(U + T + S)
if __name__ == '__main__':
main()
| def main():
s = input()
t = input()
u = input()
print(U + T + S)
if __name__ == '__main__':
main() |
def chi_squared(k1, k2, xs, ys):
stats_x = [0 for _ in range(k1)]
stats_y = [0 for _ in range(k2)]
d = dict()
for x, y in zip(xs, ys):
if (x,y) in d:
d[(x, y)] += 1
else:
d[(x, y)] = 1
stats_x[x] += 1
stats_y[y] += 1
result = 0.
for ... | def chi_squared(k1, k2, xs, ys):
stats_x = [0 for _ in range(k1)]
stats_y = [0 for _ in range(k2)]
d = dict()
for (x, y) in zip(xs, ys):
if (x, y) in d:
d[x, y] += 1
else:
d[x, y] = 1
stats_x[x] += 1
stats_y[y] += 1
result = 0.0
for (x, y) ... |
class Solution:
def dfs(self, root):
if root is None:
return (float('inf'), float('-inf'), 0, 0) # min, max, largest, size
left, right = self.dfs(root.left), self.dfs(root.right)
new_min = min(root.val, left[0], right[0])
new_max = max(root.val, left[1], right[1])
... | class Solution:
def dfs(self, root):
if root is None:
return (float('inf'), float('-inf'), 0, 0)
(left, right) = (self.dfs(root.left), self.dfs(root.right))
new_min = min(root.val, left[0], right[0])
new_max = max(root.val, left[1], right[1])
new_largest = max(le... |
def count_substring(string, sub_string):
stringSequences = []
for i in range(len(string)):
stringSequences.append(string[i:i+len(sub_string)])
return stringSequences.count(sub_string)
| def count_substring(string, sub_string):
string_sequences = []
for i in range(len(string)):
stringSequences.append(string[i:i + len(sub_string)])
return stringSequences.count(sub_string) |
'''
Copyright 2019-2020 Secure Shed Project Dev Team
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 i... | """
Copyright 2019-2020 Secure Shed Project Dev Team
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 i... |
'''configuration variables for use throughout the global scope'''
session = None
# --------------- Static Variables ------------------
APPLICATION_ID = 'amzn1.echo-sdk-ams.app.1a291230-7f25-48ed-b8b7-747205d072db'
APPLICATION_NAME = 'The Cyberpunk Dictionary'
APPLICATION_INVOCATION_NAME = 'the cyberpunk dictionary'
APP... | """configuration variables for use throughout the global scope"""
session = None
application_id = 'amzn1.echo-sdk-ams.app.1a291230-7f25-48ed-b8b7-747205d072db'
application_name = 'The Cyberpunk Dictionary'
application_invocation_name = 'the cyberpunk dictionary'
application_version = '0.1'
application_endpoint = 'arn:a... |
#!/usr/bin/env python3
# Print Welcome Message
print('Hello, World')
| print('Hello, World') |
class Solution:
def dailyTemperatures(self, T: List[int]) -> List[int]:
stack = []
result = [0] * len(T)
for idx, t in enumerate(T):
while stack and T[stack[-1]] < t:
prev_idx = stack.pop()
result[prev_idx] = idx - prev_idx
stack.appe... | class Solution:
def daily_temperatures(self, T: List[int]) -> List[int]:
stack = []
result = [0] * len(T)
for (idx, t) in enumerate(T):
while stack and T[stack[-1]] < t:
prev_idx = stack.pop()
result[prev_idx] = idx - prev_idx
stack.ap... |
def how_many_visited_houses(instructions):
visited = {'0:0' : True}
x = 0
y = 0
# ^y
# |
# |
# --------+---------->x
#
#
for step in instructions:
if step == '>':
x += 1
elif step == '<':
x -= 1... | def how_many_visited_houses(instructions):
visited = {'0:0': True}
x = 0
y = 0
for step in instructions:
if step == '>':
x += 1
elif step == '<':
x -= 1
elif step == 'v':
y -= 1
elif step == '^':
y += 1
else:
... |
for _ in range(int(input())):
a=input()
n=len(a)
if n%2==0 and a[0:n//2]==a[n//2:n]:
print("YES")
else:
print("NO")
| for _ in range(int(input())):
a = input()
n = len(a)
if n % 2 == 0 and a[0:n // 2] == a[n // 2:n]:
print('YES')
else:
print('NO') |
config = {}
def process_logic_message(message):
type = message.get("type", None)
if type == "initialize":
return __initialize__()
if type == "enable":
return __enable__()
if type == "disable":
return __disable__()
else:
return wirehome.response_creator.not_supporte... | config = {}
def process_logic_message(message):
type = message.get('type', None)
if type == 'initialize':
return __initialize__()
if type == 'enable':
return __enable__()
if type == 'disable':
return __disable__()
else:
return wirehome.response_creator.not_supported(... |
class tooltips:
def __init__ (self, attr):
self.tips = dict()
self.ori_attr = attr
for i in attr:
self.tips[i] = True
if 'time_value' in self.tips:
self.tips['time_value'] = False
def set_attr(self, attr):
for i in self.tips:
self.tips[i] = False
for i in attr:
if i in self.tips:
self.... | class Tooltips:
def __init__(self, attr):
self.tips = dict()
self.ori_attr = attr
for i in attr:
self.tips[i] = True
if 'time_value' in self.tips:
self.tips['time_value'] = False
def set_attr(self, attr):
for i in self.tips:
self.tips... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.