content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Tetapkan 'Bob' ke variable name
name = "Bob"
# Cetak nilai dari variable name
print(name)
# Tetapkan 7 ke variable number
number = 7
# Cetak nilai dari variable number
print(number) | name = 'Bob'
print(name)
number = 7
print(number) |
# 1.1: Is Unique
# Runtime: O(n) - Space: O(n)
def is_unique(string: str) -> bool:
counts = set()
for s in string:
if s in counts:
return False
counts.add(s)
return True
# Runtime: O(n log n + n) - Space: O(1)
def is_unique_without_additional_data_structures(string: str) ->... | def is_unique(string: str) -> bool:
counts = set()
for s in string:
if s in counts:
return False
counts.add(s)
return True
def is_unique_without_additional_data_structures(string: str) -> bool:
string.sort()
prev = ''
for curr in string:
if curr == prev:
... |
def Ising_input():
nrows = 20 # number of rows of spins (even number)
ncols = 20 # number of columns of spins (even number)
npass = 60000 # number of passes for each temperature
nequil = 40000 # number of equilibration steps for ea... | def ising_input():
nrows = 20
ncols = 20
npass = 60000
nequil = 40000
high_temp = 4.0
low_temp = 0.92
temp_interval = 0.005
config_type = 1
return (nrows, ncols, npass, nequil, high_temp, low_temp, temp_interval, ConfigType) |
def solve(a, b, c):
if a == b == c:
return 0
if a == b:
return 2 * (abs(b - c) - 2) if (abs(b - c) - 2) > 0 else 0
if b == c:
return 2 * (abs(a - b) - 2) if (abs(a - b) - 2) > 0 else 0
if a == c:
return 2 * (abs(c - b) - 2) if (abs(c - b) - 2) > 0 else 0
min_, mid_, ... | def solve(a, b, c):
if a == b == c:
return 0
if a == b:
return 2 * (abs(b - c) - 2) if abs(b - c) - 2 > 0 else 0
if b == c:
return 2 * (abs(a - b) - 2) if abs(a - b) - 2 > 0 else 0
if a == c:
return 2 * (abs(c - b) - 2) if abs(c - b) - 2 > 0 else 0
(min_, mid_, max_) ... |
class Model:
@staticmethod
def get_waiting_time_secs() -> int:
return 5
@staticmethod
def get_waiting_time() -> list:
return [1, 30] | class Model:
@staticmethod
def get_waiting_time_secs() -> int:
return 5
@staticmethod
def get_waiting_time() -> list:
return [1, 30] |
#AUTOR; Eduardo Rico Sotomayor. GitHub: Eduardo-rico. www.ricosotomayor.com
def Simpson(f, a, b, n):
if n % 2 != 0:
return 'El numero de intervalos tiene que ser par'
h = float((b-a))/n
suma1 = 0
for i in range(1, int(n/2)+1):
suma1 = suma1 + f(a + (2*i -1)*h)
suma2 = 0
for j in... | def simpson(f, a, b, n):
if n % 2 != 0:
return 'El numero de intervalos tiene que ser par'
h = float(b - a) / n
suma1 = 0
for i in range(1, int(n / 2) + 1):
suma1 = suma1 + f(a + (2 * i - 1) * h)
suma2 = 0
for j in range(1, int(n / 2)):
suma2 = suma2 + f(a + 2 * j * h)
... |
def setup_parser(common_parser, subparsers):
parser = subparsers.add_parser("discover", parents=[common_parser])
parser.add_argument(
"-i",
"--genotype_dir",
help="Input directory."
"Is an output directory of gramtools `genotype` command.",
dest="geno_dir",
type=... | def setup_parser(common_parser, subparsers):
parser = subparsers.add_parser('discover', parents=[common_parser])
parser.add_argument('-i', '--genotype_dir', help='Input directory.Is an output directory of gramtools `genotype` command.', dest='geno_dir', type=str, required=True)
parser.add_argument('-o', '--... |
class solution(object):
def lengthOfLongestSubstring(self, s):
sz = len(s)
if sz <= 1:
return sz
ml = 0
mml = ml
reg = dict()
for c in s:
if c in reg:
ml = 1
print ('-' + str(ml))
... | class Solution(object):
def length_of_longest_substring(self, s):
sz = len(s)
if sz <= 1:
return sz
ml = 0
mml = ml
reg = dict()
for c in s:
if c in reg:
ml = 1
print('-' + str(ml))
else:
... |
# ----------------------------------------------------------------------------
# CLASSES: nightly
#
# Test Case: kulllite.py
#
# Tests: mesh - 2D, 3D unstructured
# plots - Pseudocolor, mesh, boundary, subset
#
# Defect ID: '6251, '6326, '7043
#
# Programmer: Hank Childs
# Date: ... | required_database_plugin('KullLite')
open_database(data_path('KullLite_test_data/tagtest_xy_3.pdb'))
add_plot('Mesh', 'mesh')
draw_plots()
test('kulllite_01')
delete_all_plots()
open_database(data_path('KullLite_test_data/tagtest_rz_1_0.pdb'))
add_plot('FilledBoundary', 'Material(mesh)')
add_plot('Mesh', 'mesh_tags/edg... |
'''
NUMBERS
- Integers
- Booleans
- Reals
- Complex numbers
- Fractions and decimals
Numbers are immutable objects
INTEGERS
It doesn't matter how big the number you want to store - as long as it can fir in your computer's memory, Python will take care of it.
'''
a = 12
b = 3
a + b
b - a
a // b
a / b
a * b
b ** a
2 ... | """
NUMBERS
- Integers
- Booleans
- Reals
- Complex numbers
- Fractions and decimals
Numbers are immutable objects
INTEGERS
It doesn't matter how big the number you want to store - as long as it can fir in your computer's memory, Python will take care of it.
"""
a = 12
b = 3
a + b
b - a
a // b
a / b
a * b
b ** a
2 **... |
#!/usr/bin/python
class Order(object):
def __init__(self, tick, order_list):
self.next_order = None
self.prev_order = None
self.tick = tick
self.order_list = order_list
def next_order(self):
return self.next_order
def prev_order(self):
return self.prev_orde... | class Order(object):
def __init__(self, tick, order_list):
self.next_order = None
self.prev_order = None
self.tick = tick
self.order_list = order_list
def next_order(self):
return self.next_order
def prev_order(self):
return self.prev_order
def update_... |
# opp7
# property decorator
# property decorator allows us to give our class attributes getter,setter and a deleter functionality.
class Employee:
def __init__(self,first,last,pay):
self.first=first
self.last=last
self.pay=pay
self.email=first+last+"@gmail.com"
def fullname(self... | class Employee:
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + last + '@gmail.com'
def fullname(self):
return f'{self.first} {self.last}'
emp_1 = employee('ahammad', 'shawki', 10000)
print(emp_1.first)
print... |
# -*- coding: utf-8 -*-
db.define_table('container',
Field('barcode','string',length=100,notnull=True,unique=True,requires=[IS_NOT_EMPTY(),IS_LENGTH(18)]),
auth.signature, format='%(barcode)s')
db.define_table('impreso',
Field('record','text'),
Field('ba... | db.define_table('container', field('barcode', 'string', length=100, notnull=True, unique=True, requires=[is_not_empty(), is_length(18)]), auth.signature, format='%(barcode)s')
db.define_table('impreso', field('record', 'text'), field('barcode', 'string', length=100, notnull=True, unique=True), field('segment', 'string'... |
default_app_config = 'adminfilters.apps.Config'
NAME = 'django-adminfilters'
VERSION = __version__ = '2.0.1'
__author__ = 'sax'
| default_app_config = 'adminfilters.apps.Config'
name = 'django-adminfilters'
version = __version__ = '2.0.1'
__author__ = 'sax' |
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0
swagger_template = {
"swagger": "",
"openapi": "3.0.0",
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat... | swagger_template = {'swagger': '', 'openapi': '3.0.0', 'components': {'securitySchemes': {'BearerAuth': {'type': 'http', 'scheme': 'bearer', 'bearerFormat': 'JWT'}}}, 'definitions': {'User': {'type': 'object', 'properties': {'username': {'type': 'string'}, 'first_name': {'type': 'string'}, 'last_name': {'type': 'string... |
_base_ = [
'../_base_/models/deeplabv3_unet_s5-d16.py',
'../_base_/datasets/Car_0505.py', '../_base_/default_runtime.py',
'../_base_/schedules/schedule_40k.py'
]
model = dict(test_cfg=dict(crop_size=(160, 160), stride=(85, 85)))
evaluation = dict(metric='mDice')
| _base_ = ['../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/Car_0505.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py']
model = dict(test_cfg=dict(crop_size=(160, 160), stride=(85, 85)))
evaluation = dict(metric='mDice') |
def wrapper(*args, **kwargs):
print('hello from wrapper')
def check(func):
return wrapper
| def wrapper(*args, **kwargs):
print('hello from wrapper')
def check(func):
return wrapper |
## Local ems economic dispatch computing format
# Diesel generator set
IG = 0
PG = 1
RG = 2
#Utility grid set
IUG = 3
PUG = 4
RUG = 5
# Bi-directional convertor set
PBIC_AC2DC = 6
PBIC_DC2AC = 7
# Energy storage system set
PESS_C = 8
PESS_DC = 9
RESS = 10
EESS = 11
# Neighboring set
PMG = 12
# Emergency shedding/curtai... | ig = 0
pg = 1
rg = 2
iug = 3
pug = 4
rug = 5
pbic_ac2_dc = 6
pbic_dc2_ac = 7
pess_c = 8
pess_dc = 9
ress = 10
eess = 11
pmg = 12
ipv = 13
iwp = 14
il_ac = 15
il_uac = 16
il_dc = 17
il_udc = 18
nx = 19 |
class Resp(object):
def __init__(self):
'''
Resp Parameters
'''
self.code=None
self.desc=None
def getCode(self):
return self.code
def setCode(self, code):
self.code = code
def getDesc(self):
return self.desc
def setDesc(self, d... | class Resp(object):
def __init__(self):
"""
Resp Parameters
"""
self.code = None
self.desc = None
def get_code(self):
return self.code
def set_code(self, code):
self.code = code
def get_desc(self):
return self.desc
def set_desc(sel... |
n1: int; n2: int; n3: int; menor: int
n1 = int(input("Primeiro valor: "))
n2 = int(input("Segundo valor: "))
n3 = int(input("Terceiro valor: "))
if n1 < n2 and n1 < n3:
menor = n1
elif n2 < n3:
menor = n2
else:
menor = n3
print(f"MENOR = {menor}") | n1: int
n2: int
n3: int
menor: int
n1 = int(input('Primeiro valor: '))
n2 = int(input('Segundo valor: '))
n3 = int(input('Terceiro valor: '))
if n1 < n2 and n1 < n3:
menor = n1
elif n2 < n3:
menor = n2
else:
menor = n3
print(f'MENOR = {menor}') |
#Jumping through array
#Advent of Code 2017 Day 5
file = open('input5.txt','r')
input = file.read()
file.close()
#print (input)
instructions = [int(n) for n in input.split() ]
#instructions = [0,3,0,1,-3]
index = 0
jumps = 0
escaped = False
while escaped == False:
toJump = instructions[index]
if( toJ... | file = open('input5.txt', 'r')
input = file.read()
file.close()
instructions = [int(n) for n in input.split()]
index = 0
jumps = 0
escaped = False
while escaped == False:
to_jump = instructions[index]
if toJump >= 3:
instructions[index] -= 1
else:
instructions[index] += 1
index += toJump... |
Variable([
dict(name="Right", ui="EditText"),
dict(name="Left", ui="EditText"),
], globals())
lista = list(Left)
listb = list(Right)
output = []
for x in lista:
for y in listb:
output.append(x)
output.append(y)
output.append("\n")
print(*output, sep="") | variable([dict(name='Right', ui='EditText'), dict(name='Left', ui='EditText')], globals())
lista = list(Left)
listb = list(Right)
output = []
for x in lista:
for y in listb:
output.append(x)
output.append(y)
output.append('\n')
print(*output, sep='') |
class Slice:
def __init__(self, name, ratio,
connected_users, user_share, delay_tolerance, qos_class,
bandwidth_guaranteed, bandwidth_max, init_capacity,
usage_pattern):
self.name = name
self.connected_users = connected_users
self.user_share... | class Slice:
def __init__(self, name, ratio, connected_users, user_share, delay_tolerance, qos_class, bandwidth_guaranteed, bandwidth_max, init_capacity, usage_pattern):
self.name = name
self.connected_users = connected_users
self.user_share = user_share
self.delay_tolerance = delay... |
def is_nice(word):
has_double = False
vowel_count = word[0] in "aeiou"
for i in range(1, len(word)):
if word[i] == word[i-1]:
has_double = True
if word[i] in "aeiou":
vowel_count += 1
if (word[i-1] + word[i]) in ["ab", "cd", "pq", "xy"]:
return Fal... | def is_nice(word):
has_double = False
vowel_count = word[0] in 'aeiou'
for i in range(1, len(word)):
if word[i] == word[i - 1]:
has_double = True
if word[i] in 'aeiou':
vowel_count += 1
if word[i - 1] + word[i] in ['ab', 'cd', 'pq', 'xy']:
return F... |
default_sanitizers = {
"human_bool": lambda x: x.lower() in ["yes", "y", "si", "true"],
"integer": lambda x: int(x),
"float": lambda x: float(x),
"strip": lambda x: " ".join(x.strip().split())
}
| default_sanitizers = {'human_bool': lambda x: x.lower() in ['yes', 'y', 'si', 'true'], 'integer': lambda x: int(x), 'float': lambda x: float(x), 'strip': lambda x: ' '.join(x.strip().split())} |
# Courtesy of sdickreuter/python-andor
ERROR_CODES = {
20001: ["DRV_ERROR_CODES", "None"],
20002: ["DRV_SUCCESS", "None"],
20003: ["DRV_VXNOTINSTALLED", "None"],
20004: ["DRV_ERROR_SCAN", "None"],
20005: ["DRV_ERROR_CHECK_SUM", "None"],
20006: ["DRV_ERROR_FILELOAD", "None"],
20007: ["DRV_ERR... | error_codes = {20001: ['DRV_ERROR_CODES', 'None'], 20002: ['DRV_SUCCESS', 'None'], 20003: ['DRV_VXNOTINSTALLED', 'None'], 20004: ['DRV_ERROR_SCAN', 'None'], 20005: ['DRV_ERROR_CHECK_SUM', 'None'], 20006: ['DRV_ERROR_FILELOAD', 'None'], 20007: ['DRV_ERROR_VXD_INIT', 'None'], 20008: ['DRV_ERROR_VXD_INIT', 'None'], 20009:... |
P, k=map(int, input().split())
chk=[False]*1000001
prime=[]
for i in range(2, k):
if chk[i]==False:
prime.append(i)
t=i+i
while t<=1000000:
chk[t]=True
t+=i
for p in prime:
if p>k: break
if P%p==0:
print('BAD', p)
exit(0)
print('GOOD') | (p, k) = map(int, input().split())
chk = [False] * 1000001
prime = []
for i in range(2, k):
if chk[i] == False:
prime.append(i)
t = i + i
while t <= 1000000:
chk[t] = True
t += i
for p in prime:
if p > k:
break
if P % p == 0:
print('BAD', p)
... |
############################# EVORhA Link #################################
# Link: http://bioinformatics.intec.ugent.be/kmarchal/EVORhA/
ref = 'reference genome file'
bam_file = 'input sorted bam file'
command = 'java -jar /media/saidi/SAID1/bio_exp/Project15_For_Min_Xin/software/EVORhA/evorha/evorha.jar ... | ref = 'reference genome file'
bam_file = 'input sorted bam file'
command = 'java -jar /media/saidi/SAID1/bio_exp/Project15_For_Min_Xin/software/EVORhA/evorha/evorha.jar completeAnalysis %s %s' % (ref, bam_file) |
# see also: https://github.com/soong-construction/dirt-rally-time-recorder/blob/master/resources/setup-dr2.sql
# max_rpm, idle_rpm, max_gears, car_name
car_data = [
# Crosskarts
[1598.547119140625, 161.26841735839844, 6.0, 'Speedcar Xtrem'],
# RX Super 1600S
[994.8377075195312, 188.49555969238281, 6.0,... | car_data = [[1598.547119140625, 161.26841735839844, 6.0, 'Speedcar Xtrem'], [994.8377075195312, 188.4955596923828, 6.0, 'Volkswagen Polo S1600'], [968.6577758789062, 198.96754455566406, 6.0, 'Renault Clio RS S1600'], [994.8377075195312, 198.96754455566406, 6.0, 'Opel Corsa Super 1600'], [890.1179809570312, 167.55160522... |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Editor Variables #
# Developer: Carbon #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
textColor = '#FFFFFF'
cursorColor = '#FFFFFF'
backgroundColor = '... | text_color = '#FFFFFF'
cursor_color = '#FFFFFF'
background_color = '#2D3132'
cmnt_color = '#BACBE7'
key_word_color = '#5FD66B'
built_in_color = '#F29020'
string_color = '#1E69EB'
button_color = '#1aff66'
tab_size = 40 |
test_input = open('data/gigaword/Giga/input.txt')
test_target = open('data/gigaword/Giga/task1_ref0.txt')
test_input_cleaned = open('data/gigaword/train/input_cleaned.txt', 'w')
test_target_cleaned = open('data/gigaword/train/task1_ref0_cleaned.txt', 'w')
for source, target in zip(test_input.readlines(), test_target.... | test_input = open('data/gigaword/Giga/input.txt')
test_target = open('data/gigaword/Giga/task1_ref0.txt')
test_input_cleaned = open('data/gigaword/train/input_cleaned.txt', 'w')
test_target_cleaned = open('data/gigaword/train/task1_ref0_cleaned.txt', 'w')
for (source, target) in zip(test_input.readlines(), test_target.... |
values = {
"namespace": "metrics",
"metricsServer": {
"image": "gcr.io/google_containers/metrics-server-amd64",
"version": "v0.2.1",
"pullPolicy": "IfNotPresent",
"cpuRequestMilliCores": 40,
"memRequestMB": 40,
"cpuLimitMilliCores": 80,
"memLimitMB": 200
... | values = {'namespace': 'metrics', 'metricsServer': {'image': 'gcr.io/google_containers/metrics-server-amd64', 'version': 'v0.2.1', 'pullPolicy': 'IfNotPresent', 'cpuRequestMilliCores': 40, 'memRequestMB': 40, 'cpuLimitMilliCores': 80, 'memLimitMB': 200}, 'kubeStateMetrics': {'image': 'quay.io/coreos/kube-state-metrics'... |
#
# PySNMP MIB module HUAWEI-MSDP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-MSDP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:35:29 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
print("Hello, world")
name = input('what is your name?: ')
print('hello, %s' % name)
| print('Hello, world')
name = input('what is your name?: ')
print('hello, %s' % name) |
class Spam:
__egg = 7
def print_egg(self):
print(self.__egg)
s = Spam()
s.print_egg()
print(s._Spam__egg)
print(s.__egg)
| class Spam:
__egg = 7
def print_egg(self):
print(self.__egg)
s = spam()
s.print_egg()
print(s._Spam__egg)
print(s.__egg) |
#
# PySNMP MIB module NMS-IPAcl (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-IPAcl
# Produced by pysmi-0.3.4 at Mon Apr 29 20:12:29 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... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, constraints_intersection, value_size_constraint) ... |
# =======================================================================================================
# Global constants and variables related to Training sheet headings
# =======================================================================================================
# ====================================... | contact_number = 'membership_number'
forenames = 'forenames'
surname = 'surname'
preferred = 'preferred'
email = 'email'
role = 'role'
role_start_date = 'role_start_date'
role_status = 'role_status'
review_date = 'review_date'
wood_badge_date = 'wood_badge_date'
country = 'country'
region = 'region'
county = 'county'
c... |
def solution(X, A):
# write your code in Python 3.6
positions = dict.fromkeys(range(1,X+1), 0)
covered_positions = 0
additional_time = 0
waiting_for_missing_leaf = False
for time, position in enumerate(A):
if position <= X:
positions[position] += 1
if positions[po... | def solution(X, A):
positions = dict.fromkeys(range(1, X + 1), 0)
covered_positions = 0
additional_time = 0
waiting_for_missing_leaf = False
for (time, position) in enumerate(A):
if position <= X:
positions[position] += 1
if positions[position] == 1:
c... |
arr=[10, 4, 3, 50, 23, 90]
n=len(arr)
#largest three elements in array
def func1(arr,n):
first,second,third=-1,-1,-1
for i in range(n):
if arr[i]>first:
third=second
second=first
first=arr[i]
elif arr[i]>second:
third=second
... | arr = [10, 4, 3, 50, 23, 90]
n = len(arr)
def func1(arr, n):
(first, second, third) = (-1, -1, -1)
for i in range(n):
if arr[i] > first:
third = second
second = first
first = arr[i]
elif arr[i] > second:
third = second
second = arr[i]
... |
class Solution:
def sortArray(self, nums: List[int]) -> List[int]:
def quicksort(A, low, high):
if low >= high: return
p = partition(A, low, high)
quicksort(A, low, p-1)
quicksort(A, p+1, high)
def partition(A, low, high):
mid =... | class Solution:
def sort_array(self, nums: List[int]) -> List[int]:
def quicksort(A, low, high):
if low >= high:
return
p = partition(A, low, high)
quicksort(A, low, p - 1)
quicksort(A, p + 1, high)
def partition(A, low, high):
... |
TRAIN_POWER_CONSUMPTION=50 # watt
TRAIN_SPEED=6000# samples/sec
class Mecs:
db=[]
def add_new_mec(self,id,worker):
new_mec=Mec(id,worker)
self.db.append(new_mec)
def get_all_mec_ids(self):
mylist=[]
for mec in self.db:
mylist.append(mec.id)
return mylis... | train_power_consumption = 50
train_speed = 6000
class Mecs:
db = []
def add_new_mec(self, id, worker):
new_mec = mec(id, worker)
self.db.append(new_mec)
def get_all_mec_ids(self):
mylist = []
for mec in self.db:
mylist.append(mec.id)
return mylist
... |
def copy_and_reverse(old_file, new_file):
with open(old_file, "r") as old_f:
text = old_f.read()
with open(new_file, "w") as new_f:
new_f.write(text[::-1])
copy_and_reverse('story.txt', 'story_reversed.txt') | def copy_and_reverse(old_file, new_file):
with open(old_file, 'r') as old_f:
text = old_f.read()
with open(new_file, 'w') as new_f:
new_f.write(text[::-1])
copy_and_reverse('story.txt', 'story_reversed.txt') |
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int:
if not nums:
return 0
if len(nums) == 1:
return 1
i, res = 0, 1
for j in range(1, len(nums)):
if nums[j] <= nums[j-1]:
res = max(res, j-i)
i = j
... | class Solution:
def find_length_of_lcis(self, nums: List[int]) -> int:
if not nums:
return 0
if len(nums) == 1:
return 1
(i, res) = (0, 1)
for j in range(1, len(nums)):
if nums[j] <= nums[j - 1]:
res = max(res, j - i)
... |
nums = [1,3,4,5,177,123,16743556,132,675]
print(min(nums))
print(max(nums))
print(sum(nums))
result = 0;
for num in nums:
result = result + num; # result += num
print(result) | nums = [1, 3, 4, 5, 177, 123, 16743556, 132, 675]
print(min(nums))
print(max(nums))
print(sum(nums))
result = 0
for num in nums:
result = result + num
print(result) |
class Solution:
def restoreString(self, s: str, indices: List[int]) -> str:
table = {i : c for c, i in zip(s, indices)}
return ''.join([table[i] for i in range(len(s))])
| class Solution:
def restore_string(self, s: str, indices: List[int]) -> str:
table = {i: c for (c, i) in zip(s, indices)}
return ''.join([table[i] for i in range(len(s))]) |
class Toilet():
def __init__(self):
# pre-double-underscore means private in python
# only accessible within the class
self.__sex = "male"
# Protected method
def _Print(self):
print(self.__sex)
wc = Toilet()
# print(wc.__sex)
wc._Print()
print(dir(wc))
shit = [1,2,5,3,2,324,234,23,3]
roundShit = ('as... | class Toilet:
def __init__(self):
self.__sex = 'male'
def __print(self):
print(self.__sex)
wc = toilet()
wc._Print()
print(dir(wc))
shit = [1, 2, 5, 3, 2, 324, 234, 23, 3]
round_shit = ('asdfasdg', 234, 2348)
(a, *_, b) = shit
print(a, b)
(a, *_, c) = roundShit
print(a, c) |
def first_non_repeating_letter(s: str) -> str:
if s:
non_repeating = [i for i in s if s.lower().count(i.lower()) == 1]
return non_repeating[0] if len(non_repeating) >= 1 else ''
return ''
| def first_non_repeating_letter(s: str) -> str:
if s:
non_repeating = [i for i in s if s.lower().count(i.lower()) == 1]
return non_repeating[0] if len(non_repeating) >= 1 else ''
return '' |
def change(m):
coins = [0]*(m+1)
coins[0] = 0
for i in range(1,m+1):
if i < 3:
coins[i] = i
elif i < 5:
coins[i] = 1
else:
coins[i] = min(coins[i-3],coins[i-1],coins[i-4])+1
return coins[m]
if __name__ =='__main__':
print(change(3... | def change(m):
coins = [0] * (m + 1)
coins[0] = 0
for i in range(1, m + 1):
if i < 3:
coins[i] = i
elif i < 5:
coins[i] = 1
else:
coins[i] = min(coins[i - 3], coins[i - 1], coins[i - 4]) + 1
return coins[m]
if __name__ == '__main__':
print(... |
a = 1
c = 3
b = 10
| a = 1
c = 3
b = 10 |
class PedidoDAO():
def __init__(self):
self._pedido_list = []
def pedir(self,pedido):
valor1 = pedido.get_valor()
valor2 = pedido.get_quantidade()
pedido.set_valor_total(int(valor1) * int(valor2))
self._pedido_list.append(pedido)
def listar(self):
... | class Pedidodao:
def __init__(self):
self._pedido_list = []
def pedir(self, pedido):
valor1 = pedido.get_valor()
valor2 = pedido.get_quantidade()
pedido.set_valor_total(int(valor1) * int(valor2))
self._pedido_list.append(pedido)
def listar(self):
return sel... |
class Sentence:
def __init__(self, sentence, alwaysTrue=False):
self.sentence = sentence
self.alwaysTrue = alwaysTrue
def __repr__(self):
return self.stringify()
def __str__(self):
return self.stringify()
def __eq__(self, other):
n = self.size()
if n != other.size():
return False
for i in rang... | class Sentence:
def __init__(self, sentence, alwaysTrue=False):
self.sentence = sentence
self.alwaysTrue = alwaysTrue
def __repr__(self):
return self.stringify()
def __str__(self):
return self.stringify()
def __eq__(self, other):
n = self.size()
if n !... |
# args
def SumOfNumbers(a, b):
print('result: ', a+b)
SumOfNumbers(3,4)
def SumOfNumbers2(*args): # * it is notation to tell that its tuple in aggregation
print('Args: ', args)
print('type(args): ', type(args))
result = 0
for item in args:
result += item
print('result: ',... | def sum_of_numbers(a, b):
print('result: ', a + b)
sum_of_numbers(3, 4)
def sum_of_numbers2(*args):
print('Args: ', args)
print('type(args): ', type(args))
result = 0
for item in args:
result += item
print('result: ', result)
sum_of_numbers2(1, 2)
sum_of_numbers2(1, 2, 3, 4, 5) |
#
# Write `max`
#
def max(L):
max=-1000000
for l in L:# return the maximum value in L
if l>max:
max=l
return max
def test():
L = [1, 2, 3, 4]
assert 4 == max(L)
L = [3, 6, 10, 9, 3]
assert 10 == max(L)
test() | def max(L):
max = -1000000
for l in L:
if l > max:
max = l
return max
def test():
l = [1, 2, 3, 4]
assert 4 == max(L)
l = [3, 6, 10, 9, 3]
assert 10 == max(L)
test() |
red_hose = 8.5 * 60
combined = 5.25 * 60
# how much would red hose do in 5.25 hours
red_hose_partial = combined / red_hose * 100
print('Red Hose Partial: ' + str(red_hose_partial) + '%')
blue_hose_contribution = 100 - red_hose_partial
print('Blue Hose Contribution: ' + str(blue_hose_contribution))
print('--')
# How ... | red_hose = 8.5 * 60
combined = 5.25 * 60
red_hose_partial = combined / red_hose * 100
print('Red Hose Partial: ' + str(red_hose_partial) + '%')
blue_hose_contribution = 100 - red_hose_partial
print('Blue Hose Contribution: ' + str(blue_hose_contribution))
print('--')
blue_hose_per_minute = blue_hose_contribution / comb... |
UP = 0
DOWN = UP + 1
LEFT = DOWN + 1
RIGHT = LEFT + 1
NO_OP = RIGHT + 1
ACTIONS = [UP, DOWN, LEFT, RIGHT, NO_OP]
QUIT = NO_OP + 1 # Meta-action
LIST_CONTROLS = QUIT + 1 # Meta-action
ACTION_NAMES = ["ACCELERATE", "BREAK", "LEFT", "RIGHT", "CRUISE"]
| up = 0
down = UP + 1
left = DOWN + 1
right = LEFT + 1
no_op = RIGHT + 1
actions = [UP, DOWN, LEFT, RIGHT, NO_OP]
quit = NO_OP + 1
list_controls = QUIT + 1
action_names = ['ACCELERATE', 'BREAK', 'LEFT', 'RIGHT', 'CRUISE'] |
#
# PySNMP MIB module BLUECOAT-SG-FAILOVER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BLUECOAT-SG-FAILOVER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:22:38 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, constraints_intersection, value_size_constraint, single_value_constraint) ... |
# solution A
class Solution:
def sortByBits(self, arr):
res = []
d = {}
for i in arr:
t = str(bin(i))
n = t.count('1')
if n not in d:
d[n] = []
d[n].append(i)
for i in sorted(d):
res += sorted(d[i])
r... | class Solution:
def sort_by_bits(self, arr):
res = []
d = {}
for i in arr:
t = str(bin(i))
n = t.count('1')
if n not in d:
d[n] = []
d[n].append(i)
for i in sorted(d):
res += sorted(d[i])
return res
... |
#
# PySNMP MIB module CTRON-DHCP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-DHCP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:29:48 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... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
def get_greeting():
return "hello world"
if __name__ == "__main__":
greeting = get_greeting()
print(greeting)
| def get_greeting():
return 'hello world'
if __name__ == '__main__':
greeting = get_greeting()
print(greeting) |
n=int(input())
a=list(map(int,input().split()))
b=[]
che=[]
che1=[]
for i in range(10000000):
che.append(0)
che1.append(0)
for i in range(n-1,-1,-1):
b.append(a[i])
for i in range(n):
if(che1[a[i]]==0):
che1[a[i]]=i
che[a[i]]=i
che1[a[0]]=0
#print("che",che)
#print("che1",che1)
ans=-1
n1=n
f... | n = int(input())
a = list(map(int, input().split()))
b = []
che = []
che1 = []
for i in range(10000000):
che.append(0)
che1.append(0)
for i in range(n - 1, -1, -1):
b.append(a[i])
for i in range(n):
if che1[a[i]] == 0:
che1[a[i]] = i
che[a[i]] = i
che1[a[0]] = 0
ans = -1
n1 = n
for i in rang... |
def remove_duplicate(a):
b=[]
for i in a:
if i not in b:
b.append(i)
return b
a=[2,4,3,2,5,6,3,5,4,8,1,3]
print(remove_duplicate(a))
| def remove_duplicate(a):
b = []
for i in a:
if i not in b:
b.append(i)
return b
a = [2, 4, 3, 2, 5, 6, 3, 5, 4, 8, 1, 3]
print(remove_duplicate(a)) |
n = int(input())
factors = []
while n % 2 == 0:
factors.append(2)
n //= 2
temp = 3
while n != 1 and temp <= n:
if n % temp == 0:
factors.append(temp)
n//=temp
else:
temp+=2
# Since if we encounter any composite odd numbers i,e, temp = 9 their factors have already been ... | n = int(input())
factors = []
while n % 2 == 0:
factors.append(2)
n //= 2
temp = 3
while n != 1 and temp <= n:
if n % temp == 0:
factors.append(temp)
n //= temp
else:
temp += 2
for i in range(len(factors)):
print(factors[i], end=' ') |
# https://leetcode.com/problems/stone-game-vi
class Solution:
def stoneGameVI(self, aliceValues: List[int], bobValues: List[int]) -> int:
alice, bob = 0, 0
arr = [[a + b, a, b] for a, b in zip(aliceValues, bobValues)]
arr = sorted(arr, reverse=True)
for i, item in enumerate(arr):
... | class Solution:
def stone_game_vi(self, aliceValues: List[int], bobValues: List[int]) -> int:
(alice, bob) = (0, 0)
arr = [[a + b, a, b] for (a, b) in zip(aliceValues, bobValues)]
arr = sorted(arr, reverse=True)
for (i, item) in enumerate(arr):
if i % 2 == 0:
... |
config = {}
train_config = {}
train_config['csv_root'] = '../data/train_model_1/train_model_1.csv'
train_config['batch_size'] = 48
config['train_config'] = train_config
net = {}
net['num_classes'] = 4
config['net'] = net
optim = {}
optim["lr"] = 1e-3
optim["momentum"] = 0.9
optim["weight_decay"] = 5e-4... | config = {}
train_config = {}
train_config['csv_root'] = '../data/train_model_1/train_model_1.csv'
train_config['batch_size'] = 48
config['train_config'] = train_config
net = {}
net['num_classes'] = 4
config['net'] = net
optim = {}
optim['lr'] = 0.001
optim['momentum'] = 0.9
optim['weight_decay'] = 0.0005
optim['nester... |
# coding: utf-8
class pid:
def __init__(self):
self.P_value=0.0
self.I_value=0.0
self.D_value=0.0
self.kp=0.05
self.ki=0.002
self.kd=0.002
self.Derivator=0
self.Integrator=0
self.Integrator_Max=500
self.Integrator_Min=-500
sel... | class Pid:
def __init__(self):
self.P_value = 0.0
self.I_value = 0.0
self.D_value = 0.0
self.kp = 0.05
self.ki = 0.002
self.kd = 0.002
self.Derivator = 0
self.Integrator = 0
self.Integrator_Max = 500
self.Integrator_Min = -500
... |
# read sentence
words = [x for x in input().split()]
reply = 'yes'
for w in words:
k = sum(map(lambda x: w==x,words))
if k > 1:
reply = 'no'
print(reply)
| words = [x for x in input().split()]
reply = 'yes'
for w in words:
k = sum(map(lambda x: w == x, words))
if k > 1:
reply = 'no'
print(reply) |
# Problem: https://docs.google.com/document/d/1mEX7fdbHTi7NmEZo7IceaxA64NmuDUZaDUBjBRcWXAk/edit?usp=sharing
a,b =[int(i) for i in input().split()]
print(['Not amicable','Amicable'][sum([i for i in range(1,a//2+1)if a%i==0])==b and sum([i for i in range(1,b//2+1)if b%i==0])==a])
| (a, b) = [int(i) for i in input().split()]
print(['Not amicable', 'Amicable'][sum([i for i in range(1, a // 2 + 1) if a % i == 0]) == b and sum([i for i in range(1, b // 2 + 1) if b % i == 0]) == a]) |
class Foo:
pass
def to_list(x):
return [x]
| class Foo:
pass
def to_list(x):
return [x] |
# This file contains any station functions. These are functions relating to the clicked stations and hover stations.
# This file is used by the plotting file.
# These are the colours and colour order of the clicked stations
colours = [
"red",
"darkviolet",
"limegreen",
"darkorange",
"deeppink",
... | colours = ['red', 'darkviolet', 'limegreen', 'darkorange', 'deeppink', 'darkred', 'darkgreen']
class Station:
def __init__(self, type, lat, lon, name, date, colour):
self.type = type
self.lat = lat
self.lon = lon
self.name = name
self.date = date
self.colour = colou... |
# ''Secondstring''
# Ask user to input a sentance and return every second letter in reverse order
# Author: Conor McCaffrey
sentance = input('Please write a sentance') # asking user for sentance to carry out operation on
reversed_Sentence = sentance[::-1] # reversing the input
second_Letter = reversed_Sentence[::2] # ... | sentance = input('Please write a sentance')
reversed__sentence = sentance[::-1]
second__letter = reversed_Sentence[::2]
print(second_Letter) |
# dependencies_slicer.py
def slice(target, chunk_size):
sliced = []
start = 0
end = len(target)
done = False
while not done and end - start != 0:
if end - start < chunk_size:
sliced.append(target[start:end])
done = True
else:
cutpoint = start + c... | def slice(target, chunk_size):
sliced = []
start = 0
end = len(target)
done = False
while not done and end - start != 0:
if end - start < chunk_size:
sliced.append(target[start:end])
done = True
else:
cutpoint = start + chunk_size
slice... |
batch_size = 10
save_summary_steps = 50
num_epochs = 160
pre_trained = 'experiments/yolov2_pretrained/model.ckpt-197655'
# network parameter
network_params = {
"lr" : 0.0001
}
# For multiple scale training
change_steps = 50
training_scale = [608]
# For yolov2 loss
object_scale = 5
no_object_scale = 1
class_scal... | batch_size = 10
save_summary_steps = 50
num_epochs = 160
pre_trained = 'experiments/yolov2_pretrained/model.ckpt-197655'
network_params = {'lr': 0.0001}
change_steps = 50
training_scale = [608]
object_scale = 5
no_object_scale = 1
class_scale = 1
coordinates_scale = 1
classes_mapping = {'person': 0, 'bicycle': 1, 'car'... |
class Moves():
def __init__(self):
self.moves = []
def add_move(self, move):
self.moves.append(move)
| class Moves:
def __init__(self):
self.moves = []
def add_move(self, move):
self.moves.append(move) |
# Sorted list
cards = [108, 56, 44, 21, 19, 15, 14, 12, 11, 11, 11, 9, 9, 7, 4, 3]
target = 11
# Linear search, time complexity (O)N, space complexity (O)
def findtarget(cards, target):
index = len(cards)//2
while index < len(cards) and index >= 0:
num = cards[index]
if num > target:
... | cards = [108, 56, 44, 21, 19, 15, 14, 12, 11, 11, 11, 9, 9, 7, 4, 3]
target = 11
def findtarget(cards, target):
index = len(cards) // 2
while index < len(cards) and index >= 0:
num = cards[index]
if num > target:
index += 1
elif num < target:
index -= 1
e... |
input_number = int(input())
numbers = []
filtered = []
for i in range(1, input_number + 1):
new_number = int(input())
numbers.append(new_number)
command = input()
for number in numbers:
if command == "even":
if number % 2 == 0:
filtered.append(number)
elif command == "odd":
... | input_number = int(input())
numbers = []
filtered = []
for i in range(1, input_number + 1):
new_number = int(input())
numbers.append(new_number)
command = input()
for number in numbers:
if command == 'even':
if number % 2 == 0:
filtered.append(number)
elif command == 'odd':
i... |
with open('input.txt') as input_file:
aim = 0
h_pos = 0
depth = 0
for line in input_file:
amount = int(line.rstrip()[-1]) # Assume it's always a single-digit integer
if line[0] == 'f':
h_pos += amount
depth += aim * amount
elif line[0] == 'd':
... | with open('input.txt') as input_file:
aim = 0
h_pos = 0
depth = 0
for line in input_file:
amount = int(line.rstrip()[-1])
if line[0] == 'f':
h_pos += amount
depth += aim * amount
elif line[0] == 'd':
aim += amount
elif line[0] == 'u':
... |
def is_palin_perm(input_str):
input_str = input_str.replace(" ", "")
input_str = input_str.lower()
d = dict()
for i in input_str:
if i in d:
d[i] += 1
else:
d[i] = 1
odd_count = 0
for k, v in d.items():
if v % 2 != 0 and odd_count == 0:
... | def is_palin_perm(input_str):
input_str = input_str.replace(' ', '')
input_str = input_str.lower()
d = dict()
for i in input_str:
if i in d:
d[i] += 1
else:
d[i] = 1
odd_count = 0
for (k, v) in d.items():
if v % 2 != 0 and odd_count == 0:
... |
#!/usr/bin/env python3
def diagonal_traverse(matrix):
m, n = len(matrix), len(matrix[0])
diag = [[] for _ in range(m + n - 1)]
for c in range(n):
for r in range(m):
diag[r+c].append(matrix[r][c])
return diag
matrix = [input().split() for _ in range(int(input()))]
result = diagona... | def diagonal_traverse(matrix):
(m, n) = (len(matrix), len(matrix[0]))
diag = [[] for _ in range(m + n - 1)]
for c in range(n):
for r in range(m):
diag[r + c].append(matrix[r][c])
return diag
matrix = [input().split() for _ in range(int(input()))]
result = diagonal_traverse(matrix)
pr... |
class GameText:
def __init__(self):
self.intro_text = [
' The Mars Orbiter experienced an error during Orbit insertion.',
' Use thrusters to correct to a circular mapping orbit without',
' running out of fuel or burning up in the atmosphere.'
]
self.instruct_t... | class Gametext:
def __init__(self):
self.intro_text = [' The Mars Orbiter experienced an error during Orbit insertion.', ' Use thrusters to correct to a circular mapping orbit without', ' running out of fuel or burning up in the atmosphere.']
self.instruct_text0 = ['Orbital altitude must be within ... |
citation_check = [
(
'Edbali (2018) stated something.',
'Edbali, T. (2018) "The test" Journal of Testing, 15(4): 261-278.',
{
'authors': ['Edbali'],
'year': '2018',
'result': True,
'in_text': True,
'in_text_separated': False,
... | citation_check = [('Edbali (2018) stated something.', 'Edbali, T. (2018) "The test" Journal of Testing, 15(4): 261-278.', {'authors': ['Edbali'], 'year': '2018', 'result': True, 'in_text': True, 'in_text_separated': False, 'parenthetical': False}), ('The cat is brown (Edbali 2018).', 'Edbali, T. (2018) "The test" Journ... |
TELLO_IP = "192.168.10.1"
TELLO_COMMAND_PORT = 8889
TELLO_STATE_PORT = 8890
TELLO_CAMERA_PORT = 11111
| tello_ip = '192.168.10.1'
tello_command_port = 8889
tello_state_port = 8890
tello_camera_port = 11111 |
# Function(Decorators([Name('foo')]), 'f', ['a', 'b'], [], 0, None, Stmt([Pass()]))
@foo
def f(a, b):
pass
@accepts(int, (int,float))
@returns((int,float))
def func0(arg1, arg2):
return arg1 * arg2
## Stmt([Function(Decorators([CallFunc(Getattr(Getattr(Name('mod1'), 'mod2'), 'accepts'), [Name('int'), Tuple([... | @foo
def f(a, b):
pass
@accepts(int, (int, float))
@returns((int, float))
def func0(arg1, arg2):
return arg1 * arg2
@mod1.mod2.accepts(int, (int, float))
@mod1.mod2.returns((int, float))
def func(arg1, arg2):
return arg1 * arg2 |
x, y, a, b = map(int, input().split())
ans = []
for i in range(a, x + 1):
for j in range(b, y + 1):
if i > j:
ans.append((i, j))
print(len(ans))
[print(x[0], x[1]) for x in ans]
| (x, y, a, b) = map(int, input().split())
ans = []
for i in range(a, x + 1):
for j in range(b, y + 1):
if i > j:
ans.append((i, j))
print(len(ans))
[print(x[0], x[1]) for x in ans] |
def getTotalX(a, b):
#
# Write your code here.
#
ausgabe = 0
for q in range(max(a), min(b) +1):
if all(q % arr == 0 for arr in a) and all(brr % q == 0 for brr in b):
ausgabe += 1
return ausgabe
| def get_total_x(a, b):
ausgabe = 0
for q in range(max(a), min(b) + 1):
if all((q % arr == 0 for arr in a)) and all((brr % q == 0 for brr in b)):
ausgabe += 1
return ausgabe |
# Input
date, month, year = [int(e) for e in input().split()]
delivery_type = input()
# find day in month
# apr, jun, sep, nov
day = 30
# jan, mar, may, jul, aug, oct, dec
if month in [1,3,5,7,8,10,12]:
day = 31
# feb
elif month == 2:
# christian era
ce_year = year - 543
if (ce_year%400 == 0) or (ce_yea... | (date, month, year) = [int(e) for e in input().split()]
delivery_type = input()
day = 30
if month in [1, 3, 5, 7, 8, 10, 12]:
day = 31
elif month == 2:
ce_year = year - 543
if ce_year % 400 == 0 or (ce_year % 4 == 0 and ce_year % 100 != 0):
day = 29
else:
day = 28
valid = True
if year < ... |
class Fields:
domain = 'domain'
value = 'value'
@staticmethod
def keys() -> list:
return list(
filter(lambda x: not x.startswith('_'), Fields.__dict__)
)
@staticmethod
def values() -> list:
return [Fields.__dict__[k] for k in Fields.keys()]
| class Fields:
domain = 'domain'
value = 'value'
@staticmethod
def keys() -> list:
return list(filter(lambda x: not x.startswith('_'), Fields.__dict__))
@staticmethod
def values() -> list:
return [Fields.__dict__[k] for k in Fields.keys()] |
my_list = []
N = int(input())
# insert i e: Insert integer at position .
# print: Print the list.
# remove e: Delete the first occurrence of integer .
# append e: Insert integer at the end of the list.
# sort: Sort the list.
# pop: Pop the last element from the list.
# reverse: Reverse the list.
for i in r... | my_list = []
n = int(input())
for i in range(N):
line = input().split()
command = line[0]
if command == 'insert':
index = int(line[1])
element = int(line[2])
my_list.insert(index, element)
elif command == 'print':
print(my_list)
elif command == 'remove':
eleme... |
i = 0
while True:
print('Hello World')
i += 1
if (i >= 10):
break | i = 0
while True:
print('Hello World')
i += 1
if i >= 10:
break |
# ler varios numeros,
# mostrar a media, maior e menor numero e perguntar
# se o usuario deve continuar
maior = menor = num1 = int(input('digite um numero'))
cont = 1
media = 0
n = input('deseja continuar? (S/N) ')
while n in ('Sssim'):
num1 = int(input('digite um numero'))
cont += 1
media += num1
n = i... | maior = menor = num1 = int(input('digite um numero'))
cont = 1
media = 0
n = input('deseja continuar? (S/N) ')
while n in 'Sssim':
num1 = int(input('digite um numero'))
cont += 1
media += num1
n = input('deseja continuar(S/N) ?')
if num1 <= menor:
menor = num1
elif num1 >= maior:
... |
def suma(a, b):
int(a)
int(b)
return a + b
while True:
try:
x = int(input("ingrese un numero A: "))
y = int(input("ingrese un numero B: "))
break
except ValueError:
print("No fue valido, ingrese de nuevo.")
print(suma(x, y)) | def suma(a, b):
int(a)
int(b)
return a + b
while True:
try:
x = int(input('ingrese un numero A: '))
y = int(input('ingrese un numero B: '))
break
except ValueError:
print('No fue valido, ingrese de nuevo.')
print(suma(x, y)) |
#!/usr/bin/env python3
print("=======================")
print("Even Numbers in range 1:20")
for x in range(2, 21, 2):
print(x)
print("=======================")
print("Odd Numbers in range 1:20")
for x in range(1, 21, 2):
print(x)
print("=======================")
print("Numbers that dividable by 4 and 6 in ra... | print('=======================')
print('Even Numbers in range 1:20')
for x in range(2, 21, 2):
print(x)
print('=======================')
print('Odd Numbers in range 1:20')
for x in range(1, 21, 2):
print(x)
print('=======================')
print('Numbers that dividable by 4 and 6 in range 1:100')
for x in range... |
def dfs(node,G):
if not G[node]:
print(node)
return
else:
for n in G[node]:
dfs(n,G)
print(node)
return
g = {'root':['a','b','c'],
'a':['d','e'],
'b':['f','g'],
'c':['h'],
'd':['i'],
'e':['j'],
'f':[],'g':[]... | def dfs(node, G):
if not G[node]:
print(node)
return
else:
for n in G[node]:
dfs(n, G)
print(node)
return
g = {'root': ['a', 'b', 'c'], 'a': ['d', 'e'], 'b': ['f', 'g'], 'c': ['h'], 'd': ['i'], 'e': ['j'], 'f': [], 'g': [], 'h': [], 'i': [], 'j': []}
print(dfs... |
# Data
dataset = 'en-ru_TEDtalks'
type = 'test'
year = 'tst2012'
prefix = 'IWSLT14.TED.' + year + '.ru-en'
src = 'en'
tgt = 'ru'
# Open files
src_file = open('../datasets/' + dataset + '/' + type + '/' + prefix + '.' + src + '.xml')
tgt_file = open('../datasets/' + dataset + '/' + type + '/' + prefix + '.' + tgt + '.x... | dataset = 'en-ru_TEDtalks'
type = 'test'
year = 'tst2012'
prefix = 'IWSLT14.TED.' + year + '.ru-en'
src = 'en'
tgt = 'ru'
src_file = open('../datasets/' + dataset + '/' + type + '/' + prefix + '.' + src + '.xml')
tgt_file = open('../datasets/' + dataset + '/' + type + '/' + prefix + '.' + tgt + '.xml')
src_sen_lists = ... |
# import xml.etree.cElementTree as ET
# root = ET.Element("root")
# doc = ET.SubElement(root, "doc")
# ET.SubElement(doc, "field1", name="blah").text = "some value1"
# ET.SubElement(doc, "field2", name="asdfasd").text = "some vlaue2"
# tree = ET.ElementTree(root)
# print(tree)
# tree.write("/home/bootcamp/src/pure_s... | print('%s - %s' % ('aa', 'bb')) |
#!/bin/python3
class Car:
def __init__(self, max_speed: int, speed_notation: str):
self.max_speed = max_speed
self.speed_notation = speed_notation
def __str__(self):
return f'Car with the maximum speed of {self.max_speed}' \
f' {self.speed_notation}'
class Boat:
def ... | class Car:
def __init__(self, max_speed: int, speed_notation: str):
self.max_speed = max_speed
self.speed_notation = speed_notation
def __str__(self):
return f'Car with the maximum speed of {self.max_speed} {self.speed_notation}'
class Boat:
def __init__(self, max_speed: int):
... |
story = {
"title": "Invisible Planets",
"author": "Hao Jingfang",
"published": 2013
}
story["words"] = 6359
story["title"] = "Folding Beijing"
story["translator"] = "Ken Liu"
del story['published']
print(story)
classrooms = {
"B48": 14
}
classrooms["B48"] = 15
del classrooms['B48']
def count(list):
... | story = {'title': 'Invisible Planets', 'author': 'Hao Jingfang', 'published': 2013}
story['words'] = 6359
story['title'] = 'Folding Beijing'
story['translator'] = 'Ken Liu'
del story['published']
print(story)
classrooms = {'B48': 14}
classrooms['B48'] = 15
del classrooms['B48']
def count(list):
dictionary = {list[... |
_base_ = [
'../_base_/models/faster_rcnn_r50_fpn.py',
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
checkpoint = 'https://download.pytorch.org/models/resnet50-11ad3fa6.pth'
model = dict(
backbone=dict(init_cfg=dict(type='Pretrained', chec... | _base_ = ['../_base_/models/faster_rcnn_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
checkpoint = 'https://download.pytorch.org/models/resnet50-11ad3fa6.pth'
model = dict(backbone=dict(init_cfg=dict(type='Pretrained', checkpoint=checkpoint)))... |
description = 'setup for the right status monitor'
group = 'special'
# location: Office R.Georgii, right
_column1 = Column(
Block('Heater long-term', [
BlockRow(
Field(plot='TPower', dev='t/heaterpower', width=40, height=30,
plotwindow=24*3600),
),
],
... | description = 'setup for the right status monitor'
group = 'special'
_column1 = column(block('Heater long-term', [block_row(field(plot='TPower', dev='t/heaterpower', width=40, height=30, plotwindow=24 * 3600))], setups='htf01'), block('Heater short-term', [block_row(field(plot='TPower2', dev='t/heaterpower', width=40, ... |
false=False
true=True
player={
"format_version": "1.16.0",
"minecraft:entity": {
"description": {
"identifier": "minecraft:player",
"is_spawnable": false,
"is_summonable": false,
"is_experimental": false,
"scripts": {
"animate": [
"health",
"health",
"spectator",
"adventure"
... | false = False
true = True
player = {'format_version': '1.16.0', 'minecraft:entity': {'description': {'identifier': 'minecraft:player', 'is_spawnable': false, 'is_summonable': false, 'is_experimental': false, 'scripts': {'animate': ['health', 'health', 'spectator', 'adventure']}, 'animations': {'health': 'controller.ani... |
#!/bin/env python
class DoublyLinkedList(object):
def __init__(self):
self.data = [[0, 'sentinel', 0]]
self.empties = []
def __iter__(self):
index = 0
while index != self.data[0][0]:
index = self.data[index][2]
value = self.data[index][1]
yi... | class Doublylinkedlist(object):
def __init__(self):
self.data = [[0, 'sentinel', 0]]
self.empties = []
def __iter__(self):
index = 0
while index != self.data[0][0]:
index = self.data[index][2]
value = self.data[index][1]
yield (index, value)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.