content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def palin(n):
if str(n) == str(n)[::-1]:
return True
return False
N, M = map(int, input().split())
mid = (N+M) // 2
mid1 = (N+M) // 2
mid2 = (N+M) // 2
mids = {}
while True:
mid1 += 1
if palin(mid1):
break
while True:
mid2 -= 1
if palin(mid2):
break
if abs(mid - ... | def palin(n):
if str(n) == str(n)[::-1]:
return True
return False
(n, m) = map(int, input().split())
mid = (N + M) // 2
mid1 = (N + M) // 2
mid2 = (N + M) // 2
mids = {}
while True:
mid1 += 1
if palin(mid1):
break
while True:
mid2 -= 1
if palin(mid2):
break
if abs(mid - m... |
#from .test_cluster_det import test_cluster_det
#from .train_cluster_det import train_cluster_det
#from .debug_cluster_det import debug_cluster_det
#from .get_cluster_det import get_cluster_det
__factory__ = { }
def build_handler(phase, stage):
key_handler = '{}_{}'.format(phase, stage)
if key_handler not in... | __factory__ = {}
def build_handler(phase, stage):
key_handler = '{}_{}'.format(phase, stage)
if key_handler not in __factory__:
raise key_error('Unknown op:', key_handler)
return __factory__[key_handler] |
# -*- coding: utf-8 -*-
def test_hello_world():
text = 'Hello World'
assert text == 'Hello World'
| def test_hello_world():
text = 'Hello World'
assert text == 'Hello World' |
try:
1/0
except Exception as e:
print('e : ', e)
print(f"repr(e) : {repr(e)}")
| try:
1 / 0
except Exception as e:
print('e : ', e)
print(f'repr(e) : {repr(e)}') |
#!/usr/bin/env python3
print("Welcome to the Binary/Hexadecimal Converter Application")
# User input
max_value = int(input("\nCompute binary and hexadecimal values up to the following decimal number: "))
decimal = list(range(1, max_value+1))
binary = []
hexadecimal = []
for num in decimal:
binary.append(bin(num)... | print('Welcome to the Binary/Hexadecimal Converter Application')
max_value = int(input('\nCompute binary and hexadecimal values up to the following decimal number: '))
decimal = list(range(1, max_value + 1))
binary = []
hexadecimal = []
for num in decimal:
binary.append(bin(num))
hexadecimal.append(hex(num))
pr... |
s = 'GTCGAAGCCATTTCGCCGTGGGGTTGCGCGTGATTCTACCATCAGTTCTTTTTACGGTTCATTTAAACCGGTAATCCAGTAGCGTCAACAAATACTACTCTATGGTTGACTGGAGACGGAACGGGCCCATCGGACGTAATTATGTGGTCTTTGCACGAGCCGGCTGATACAAGCACATGCATCGTGACCACACCGACAAAGTTGTATCTTGGTTCCCGATTTATAACGTCTGCAGAATGAGCCTGTGTGACTATTGTAGTAGGTCCGAATGCCATGTCGGGGCTCCCACCTACGCTGCCTGGCGTCTTTTTGTGC... | s = 'GTCGAAGCCATTTCGCCGTGGGGTTGCGCGTGATTCTACCATCAGTTCTTTTTACGGTTCATTTAAACCGGTAATCCAGTAGCGTCAACAAATACTACTCTATGGTTGACTGGAGACGGAACGGGCCCATCGGACGTAATTATGTGGTCTTTGCACGAGCCGGCTGATACAAGCACATGCATCGTGACCACACCGACAAAGTTGTATCTTGGTTCCCGATTTATAACGTCTGCAGAATGAGCCTGTGTGACTATTGTAGTAGGTCCGAATGCCATGTCGGGGCTCCCACCTACGCTGCCTGGCGTCTTTTTGTGC... |
expected_output = {
"route-information": {
"route-table": [
{
"table-name": "inet.0",
"destination-count": "60",
"total-route-count": "66",
"active-route-count": "60",
"holddown-route-count": "1",
"hi... | expected_output = {'route-information': {'route-table': [{'table-name': 'inet.0', 'destination-count': '60', 'total-route-count': '66', 'active-route-count': '60', 'holddown-route-count': '1', 'hidden-route-count': '0', 'rt-entry': {'rt-destination': '10.169.196.254', 'rt-prefix-length': '32', 'rt-entry-count': '2', 'r... |
if __name__ == '__main__':
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
l = [fruit.upper() for fruit in fruits if "n" in fruit]
print(l)
s = {fruit.upper() for fruit in fruits if "n" in fruit}
print(s)
d = {fruit.upper() : len(fruit) for fruit in fruits if "n" in fruit}
print(d)... | if __name__ == '__main__':
fruits = ['apple', 'banana', 'cherry', 'kiwi', 'mango']
l = [fruit.upper() for fruit in fruits if 'n' in fruit]
print(l)
s = {fruit.upper() for fruit in fruits if 'n' in fruit}
print(s)
d = {fruit.upper(): len(fruit) for fruit in fruits if 'n' in fruit}
print(d)
... |
class BaseClass:
def __init__(self):
pass
@staticmethod
def say_hi():
print("hi")
class MyClassOne(BaseClass):
def __init__(self):
pass
class MyClassTwo(BaseClass, MyClassOne):
def __init__(self):
pass
| class Baseclass:
def __init__(self):
pass
@staticmethod
def say_hi():
print('hi')
class Myclassone(BaseClass):
def __init__(self):
pass
class Myclasstwo(BaseClass, MyClassOne):
def __init__(self):
pass |
class AndGate(BinaryGate):
def __init__(self,n):
super().__init__(n)
def performGateLogic(self):
a = self.getPinA()
b = self.getPinB()
if a==1 and b==1:
return 1
else:
return 0
| class Andgate(BinaryGate):
def __init__(self, n):
super().__init__(n)
def perform_gate_logic(self):
a = self.getPinA()
b = self.getPinB()
if a == 1 and b == 1:
return 1
else:
return 0 |
#
# Copyright (c) 2019, Infosys Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | ies_type = {'0': 'MME-UE-S1AP-ID', '1': 'HandoverType', '2': 'Cause', '3': 'SourceID', '4': 'TargetID', '8': 'ENB-UE-S1AP-ID', '12': 'E-RABSubjecttoDataForwardingList', '13': 'E-RABtoReleaselistHOCmd', '14': 'E-RABDataForwardingItem', '15': 'E-RABReleaseItemBearerRelComp', '16': 'E-RABToBeSetuplistBearerSUReq', '17': '... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def constant_aminoacid_code():
aa_dict = {
"R" : "ARG", "H" : "HIS", "K" : "LYS", "D" : "ASP", "E" : "GLU",
"S" : "SER", "T" : "THR", "N" : "ASN", "Q" : "GLN", "C" : "CYS",
"G" : "GLY", "P" : "PRO", "A" : "ALA", "V" : "VAL", "I" : "ILE",
... | def constant_aminoacid_code():
aa_dict = {'R': 'ARG', 'H': 'HIS', 'K': 'LYS', 'D': 'ASP', 'E': 'GLU', 'S': 'SER', 'T': 'THR', 'N': 'ASN', 'Q': 'GLN', 'C': 'CYS', 'G': 'GLY', 'P': 'PRO', 'A': 'ALA', 'V': 'VAL', 'I': 'ILE', 'L': 'LEU', 'M': 'MET', 'F': 'PHE', 'Y': 'TYR', 'W': 'TRP', '-': 'MAR'}
return aa_dict
de... |
def head(n):
print(f"Calling the function head({n})")
# Base Case
if(n == 0):
print("**** Base Case **** \n")
return
# Recursive Function Call
head(n-1)
# Operation
print(n)
# head(5): -1006
# RecursionError: maximum recursion depth exceeded while pickli... | def head(n):
print(f'Calling the function head({n})')
if n == 0:
print('**** Base Case **** \n')
return
head(n - 1)
print(n)
head(5) |
{
PDBConst.Name: "notetype",
PDBConst.Columns: [
{
PDBConst.Name: "ID",
PDBConst.Attributes: ["tinyint", "not null", "primary key"]
},
{
PDBConst.Name: "Type",
PDBConst.Attributes: ["varchar(128)", "not null"]
},
{
PDBConst.Name: "SID",
PDBCons... | {PDBConst.Name: 'notetype', PDBConst.Columns: [{PDBConst.Name: 'ID', PDBConst.Attributes: ['tinyint', 'not null', 'primary key']}, {PDBConst.Name: 'Type', PDBConst.Attributes: ['varchar(128)', 'not null']}, {PDBConst.Name: 'SID', PDBConst.Attributes: ['varchar(128)', 'not null']}], PDBConst.Initials: [{'Type': "'html'"... |
# -*- python -*-
{
'includes': [
'../../../build/common.gypi',
],
'target_defaults': {
'variables':{
'target_base': 'none',
},
'target_conditions': [
['target_base=="ripple_ledger_service"', {
'sources': [
'ripple_ledger_service.h',
'ripple_ledger_service.c'... | {'includes': ['../../../build/common.gypi'], 'target_defaults': {'variables': {'target_base': 'none'}, 'target_conditions': [['target_base=="ripple_ledger_service"', {'sources': ['ripple_ledger_service.h', 'ripple_ledger_service.c'], 'xcode_settings': {'WARNING_CFLAGS': ['-Wno-missing-field-initializers']}}]]}, 'condit... |
# 140000000
LILIN = 1201000
sm.setSpeakerID(LILIN)
if sm.sendAskAccept("Shall we continue with your Basic Training? Before accepting, please make sure you have properly equipped your sword and your skills and potions are readily accessible."):
sm.startQuest(parentID)
sm.removeEscapeButton()
sm.sendNext("A... | lilin = 1201000
sm.setSpeakerID(LILIN)
if sm.sendAskAccept('Shall we continue with your Basic Training? Before accepting, please make sure you have properly equipped your sword and your skills and potions are readily accessible.'):
sm.startQuest(parentID)
sm.removeEscapeButton()
sm.sendNext("Alright. This t... |
def basic_align(seq1, seq2):
score = 0
if len(seq1) == len(seq2):
for base1, base2 in zip(seq1, seq2):
if base1 == base2:
score += 1
else:
score -= 0
return score
def aa_extract(file):
aa_list = []
for line in file:
if line.s... | def basic_align(seq1, seq2):
score = 0
if len(seq1) == len(seq2):
for (base1, base2) in zip(seq1, seq2):
if base1 == base2:
score += 1
else:
score -= 0
return score
def aa_extract(file):
aa_list = []
for line in file:
if line.s... |
## after apply any leyer of the forward function in pytorch
iimg=input[:,:3,:,].cpu().data.numpy()
# print(img.shape)
img = np.squeeze(img)
# print(img.shape)
img=np.transpose(img,(1,2,0))
img = cv2.resize(img,(256,256))
cv2.imshow('out',img)
cv2.waitKey(0)
| iimg = input[:, :3, :].cpu().data.numpy()
img = np.squeeze(img)
img = np.transpose(img, (1, 2, 0))
img = cv2.resize(img, (256, 256))
cv2.imshow('out', img)
cv2.waitKey(0) |
b=int(input())
x_1=b
i=0
while True:
a=b//10+(b%10)
b=(b%10)*10+a%10
i+=1
x=b
if x==x_1:
break
print(i)
| b = int(input())
x_1 = b
i = 0
while True:
a = b // 10 + b % 10
b = b % 10 * 10 + a % 10
i += 1
x = b
if x == x_1:
break
print(i) |
class Stack:
def __init__ (self):
self.elements = []
def is_empty(self):
return self.elements == []
def push(self, item):
self.elements.append(item)
def pop(self):
return self.elements.pop()
def peek(self):
return self.elements[-1]
def size(self):
... | class Stack:
def __init__(self):
self.elements = []
def is_empty(self):
return self.elements == []
def push(self, item):
self.elements.append(item)
def pop(self):
return self.elements.pop()
def peek(self):
return self.elements[-1]
def size(self):
... |
n = int(input())
l = []
for i in range(1, n):
if (i < 3):
l.append(1)
else:
l.append(l[len(l) - 1] + l[len(l) -2])
print(i, ": ", l[i-1])
| n = int(input())
l = []
for i in range(1, n):
if i < 3:
l.append(1)
else:
l.append(l[len(l) - 1] + l[len(l) - 2])
print(i, ': ', l[i - 1]) |
python = Runtime.createAndStart("python","Python")
mouth = Runtime.createAndStart("Mouth","MouthControl")
arduino = mouth.getArduino()
arduino.connect('COM11')
jaw = mouth.getJaw()
jaw.detach()
jaw.attach(arduino,11)
mouth.setmouth(110,120)
mouth.autoAttach = False
speech = Runtime.createAndStart("Speech","AcapelaSpeec... | python = Runtime.createAndStart('python', 'Python')
mouth = Runtime.createAndStart('Mouth', 'MouthControl')
arduino = mouth.getArduino()
arduino.connect('COM11')
jaw = mouth.getJaw()
jaw.detach()
jaw.attach(arduino, 11)
mouth.setmouth(110, 120)
mouth.autoAttach = False
speech = Runtime.createAndStart('Speech', 'Acapela... |
# -*- coding: utf-8 -*-
if __name__ == '__main__':
s = input()
t = input()
mod_s = s
for i in range(len(s)):
mod_s = mod_s[1:] + mod_s[0]
if mod_s == t:
print('Yes')
exit()
print('No')
| if __name__ == '__main__':
s = input()
t = input()
mod_s = s
for i in range(len(s)):
mod_s = mod_s[1:] + mod_s[0]
if mod_s == t:
print('Yes')
exit()
print('No') |
def test_cep_match(correios):
matches = correios.match_cep(cep="28620000", cod="QC067757494BR")
assert matches
def test_cep_not_match_wrong_digit(correios):
matches = correios.match_cep(cep="28620000", cod="QC067757490BR")
assert not matches
def test_cep_not_match(correios):
matches = correios... | def test_cep_match(correios):
matches = correios.match_cep(cep='28620000', cod='QC067757494BR')
assert matches
def test_cep_not_match_wrong_digit(correios):
matches = correios.match_cep(cep='28620000', cod='QC067757490BR')
assert not matches
def test_cep_not_match(correios):
matches = correios.mat... |
# This problem was recently asked by Apple:
# You are given an array. Each element represents the price of a stock on that particular day.
# Calculate and return the maximum profit you can make from buying and selling that stock only once.
def buy_and_sell(arr):
# Fill this in.
maxP = -1
buy = 0
sell... | def buy_and_sell(arr):
max_p = -1
buy = 0
sell = 0
change = True
for i in range(0, len(arr) - 1):
sell = arr[i + 1]
if change:
buy = arr[i]
if sell < buy:
change = True
continue
else:
temp = sell - buy
if tem... |
#reference_number = 9
text = ' is a prime number '
print('................................')
#print('This are numbers which can be divided into ' + str(reference_number))
for i in range(1, 100):
first = i / i
second = i/1
# print('Residual value of dividing ' + str(i) + ' / ' + str(reference_number) + ' = '... | text = ' is a prime number '
print('................................')
for i in range(1, 100):
first = i / i
second = i / 1
if first == 1:
if second == i:
print(str(i) + text) |
def test_a():
x = "this"
assert "h" in x
def test_b():
x = "hello"
assert "h" in x
def test_c():
x = "world"
assert "w" in x | def test_a():
x = 'this'
assert 'h' in x
def test_b():
x = 'hello'
assert 'h' in x
def test_c():
x = 'world'
assert 'w' in x |
#
# PySNMP MIB module AIPPP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AIPPP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:00:42 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... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_union, value_size_constraint, constraints_intersection) ... |
#350111
#a3_p10.py
#Alexandru Sasu
#a.sasu@jacobs-university.de
def printframe(n, m, c):
for j in range(0,m):
print(c,end="")
print()
for i in range (1,n-1):
print(c,end="")
for j in range(1,m-1):
print(" ",end="")
print(c)
for j in range(0,m):
print(c,end="")
print()
n=int(input())
m=int(input())
c=i... | def printframe(n, m, c):
for j in range(0, m):
print(c, end='')
print()
for i in range(1, n - 1):
print(c, end='')
for j in range(1, m - 1):
print(' ', end='')
print(c)
for j in range(0, m):
print(c, end='')
print()
n = int(input())
m = int(input()... |
x = True
y=False
print(x,y)
num1=1
num2=2
resultado=num1<num2
print(resultado)
if(num1 < num2):
print("el valor num1 es menor que num2")
else:
print("el valor de num1 No es menor que num2") | x = True
y = False
print(x, y)
num1 = 1
num2 = 2
resultado = num1 < num2
print(resultado)
if num1 < num2:
print('el valor num1 es menor que num2')
else:
print('el valor de num1 No es menor que num2') |
class Solution:
def isMirrorImage(self, left, right):
if left is None and right is None:
return True
if left is None or right is None:
return False
if left.val != right.val:
return False
return self.isMirrorImage(left.left, right.right) a... | class Solution:
def is_mirror_image(self, left, right):
if left is None and right is None:
return True
if left is None or right is None:
return False
if left.val != right.val:
return False
return self.isMirrorImage(left.left, right.right) and self... |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
if not head or head.next == None:
return head
temp_dict = dict()
pre = head
... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def delete_duplicates(self, head: ListNode) -> ListNode:
if not head or head.next == None:
return head
temp_dict = dict()
pre = head
while pre:
if pre.v... |
def binary_search(data, value):
min = 0
max = len(data) - 1
while min <= max:
mid = (min + max) // 2
if data[mid] == value:
return mid
elif data[mid] < value:
min = mid + 1
else:
max = mid - 1
return -1
if __name__ == '__main__':
d... | def binary_search(data, value):
min = 0
max = len(data) - 1
while min <= max:
mid = (min + max) // 2
if data[mid] == value:
return mid
elif data[mid] < value:
min = mid + 1
else:
max = mid - 1
return -1
if __name__ == '__main__':
da... |
def jac_uniform(mesh, mask):
# create Jacobian
cv = mesh.get_control_volumes(cell_mask=mask)
cvc = mesh.get_control_volume_centroids(cell_mask=mask)
return 2 * (mesh.node_coords - cvc) * cv[:, None]
| def jac_uniform(mesh, mask):
cv = mesh.get_control_volumes(cell_mask=mask)
cvc = mesh.get_control_volume_centroids(cell_mask=mask)
return 2 * (mesh.node_coords - cvc) * cv[:, None] |
def pig_it(text):
l=text.split()
count=0
for i in l:
if i.isalpha():
tmp=list(i)
tmp.append(tmp[0])
tmp.pop(0)
tmp.extend(list('ay'))
l[count]=''.join(tmp)
count+=1
return ' '.join(l)
'''
def pig_it(text):
lst = text.split... | def pig_it(text):
l = text.split()
count = 0
for i in l:
if i.isalpha():
tmp = list(i)
tmp.append(tmp[0])
tmp.pop(0)
tmp.extend(list('ay'))
l[count] = ''.join(tmp)
count += 1
return ' '.join(l)
"\ndef pig_it(text):\n lst = te... |
{
"targets": [
{
"target_name": "glfw",
"sources": [
"src/native/glfw.cc",
"src/native/glad.c"
],
"include_dirs": [
"src/native/deps/include",
"<!@(pkg-config glfw3 --cflags-only-I | sed s/-I//g)"... | {'targets': [{'target_name': 'glfw', 'sources': ['src/native/glfw.cc', 'src/native/glad.c'], 'include_dirs': ['src/native/deps/include', '<!@(pkg-config glfw3 --cflags-only-I | sed s/-I//g)'], 'libraries': ['<!@(pkg-config --libs glfw3)'], 'library_dirs': ['/usr/local/lib']}, {'target_name': 'gles', 'sources': ['src/na... |
def foo():
return 'bar'
COMMAND = foo
| def foo():
return 'bar'
command = foo |
class HomeEventManager:
def __init__(self, model):
self._model = model
def handle_mouse_event(self, event):
for button in self.model.buttons:
if button.rect.collidepoint(event.pos):
return button
return None
@property
def model(self):
return... | class Homeeventmanager:
def __init__(self, model):
self._model = model
def handle_mouse_event(self, event):
for button in self.model.buttons:
if button.rect.collidepoint(event.pos):
return button
return None
@property
def model(self):
return... |
errors = {
"BadRequest": {"message": "Bad Request", "status": 400},
"Forbidden": {"message": "Forbidden", "status": 403},
"NotFound": {"message": "Resource Not Found", "status": 404},
"MethodNotAllowed": {"message": "Method Not allowed", "status": 405},
"Conflict": {
"message": "You can not ... | errors = {'BadRequest': {'message': 'Bad Request', 'status': 400}, 'Forbidden': {'message': 'Forbidden', 'status': 403}, 'NotFound': {'message': 'Resource Not Found', 'status': 404}, 'MethodNotAllowed': {'message': 'Method Not allowed', 'status': 405}, 'Conflict': {'message': 'You can not add a duplicate resource.', 's... |
class Node:
def __init__(self, data, depth):
children_count = int(data.pop(0))
metadata_count = int(data.pop(0))
self.children = []
self.metadata = []
self.depth = depth
for i in range(children_count):
self.children.append(Node(data, depth + 1))
... | class Node:
def __init__(self, data, depth):
children_count = int(data.pop(0))
metadata_count = int(data.pop(0))
self.children = []
self.metadata = []
self.depth = depth
for i in range(children_count):
self.children.append(node(data, depth + 1))
f... |
#WAP to print the grade
s1 = float(input("Enter marks for subject 1 :"))
s2 = float(input("Enter marks for subject 2 :"))
s3 = float(input("Enter marks for subject 3 :"))
s4 = float(input("Enter marks for subject 4 :"))
total = s1 + s2 + s3 + s4
avg = total / 4
print('Average marks:',avg)
if avg >= 90:
... | s1 = float(input('Enter marks for subject 1 :'))
s2 = float(input('Enter marks for subject 2 :'))
s3 = float(input('Enter marks for subject 3 :'))
s4 = float(input('Enter marks for subject 4 :'))
total = s1 + s2 + s3 + s4
avg = total / 4
print('Average marks:', avg)
if avg >= 90:
print('O')
elif avg >= 80:
prin... |
SAMPLEEXECUTION_TYPE_URI = "https://w3id.org/okn/o/sd#SampleExecution"
SAMPLEEXECUTION_TYPE_NAME = "SampleExecution"
GRID_TYPE_URI = "https://w3id.org/okn/o/sdm#Grid"
GRID_TYPE_NAME = "Grid"
DATASETSPECIFICATION_TYPE_URI = "https://w3id.org/okn/o/sd#DatasetSpecification"
DATASETSPECIFICATION_TYPE_NAME = "DatasetSpecifi... | sampleexecution_type_uri = 'https://w3id.org/okn/o/sd#SampleExecution'
sampleexecution_type_name = 'SampleExecution'
grid_type_uri = 'https://w3id.org/okn/o/sdm#Grid'
grid_type_name = 'Grid'
datasetspecification_type_uri = 'https://w3id.org/okn/o/sd#DatasetSpecification'
datasetspecification_type_name = 'DatasetSpecifi... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
total = 0
n = int(input(''))
size = list(map(int, input().split()))
m = int(input(''))
for i in range(m):
order = list(map(int, input().split()))
if order[0] in size:
total = total + order[1]
size.remove(order[0])
print(total)... | total = 0
n = int(input(''))
size = list(map(int, input().split()))
m = int(input(''))
for i in range(m):
order = list(map(int, input().split()))
if order[0] in size:
total = total + order[1]
size.remove(order[0])
print(total) |
def missingTwo(nums: [int]) -> [int]:
ret = 0
for i, num in enumerate(nums):
ret ^= (i + 1)
ret ^= num
ret ^= len(nums) + 1
ret ^= len(nums) + 2
mask = 1
while mask & ret == 0:
mask <<= 1
a, b = 0, 0
for i in range(1, len(nums) + 3):
if i & mask:
... | def missing_two(nums: [int]) -> [int]:
ret = 0
for (i, num) in enumerate(nums):
ret ^= i + 1
ret ^= num
ret ^= len(nums) + 1
ret ^= len(nums) + 2
mask = 1
while mask & ret == 0:
mask <<= 1
(a, b) = (0, 0)
for i in range(1, len(nums) + 3):
if i & mask:
... |
def diff_records(left, right):
'''
Given lists of [year, value] pairs, return list of [year, difference] pairs.
Fails if the inputs are not for exactly corresponding years.
'''
assert len(left) == len(right), \
'Inputs have different lengths.'
num_years = len(left)
results = []
... | def diff_records(left, right):
"""
Given lists of [year, value] pairs, return list of [year, difference] pairs.
Fails if the inputs are not for exactly corresponding years.
"""
assert len(left) == len(right), 'Inputs have different lengths.'
num_years = len(left)
results = []
for i in ra... |
#!/usr/bin/python3
# -*- encoding="UTF-8" -*-
#parameters
listR = [] #
listC = []
listL = []
listM = []
listE = []
listF = []
listG = []
listH = []
listD = []
listDCV = []
listSinV = []
listPulseV = []
listACV = []
listDCI = []
listSinI = []
listDCParam = []
listACParam = []
listTranParam = []
listPlotDC = []
list... | list_r = []
list_c = []
list_l = []
list_m = []
list_e = []
list_f = []
list_g = []
list_h = []
list_d = []
list_dcv = []
list_sin_v = []
list_pulse_v = []
list_acv = []
list_dci = []
list_sin_i = []
list_dc_param = []
list_ac_param = []
list_tran_param = []
list_plot_dc = []
list_plot_ac = []
list_plot_tran = []
op_ex... |
def math():
while True:
i_put = int(input())
if i_put == 0:
break
else:
for i in range(1, i_put+1):
for j in range(1, i_put+1):
print(i, end=' ')
j += 1
print()
if __name__ == '__main__':
m... | def math():
while True:
i_put = int(input())
if i_put == 0:
break
else:
for i in range(1, i_put + 1):
for j in range(1, i_put + 1):
print(i, end=' ')
j += 1
print()
if __name__ == '__main__':
... |
PLUGIN_NAME = 'plugin'
PACKAGE_NAME = 'mock-plugin'
PACKAGE_VERSION = '1.0'
def create_plugin_url(plugin_tar_name, file_server):
return '{0}/{1}'.format(file_server.url, plugin_tar_name)
def plugin_struct(file_server, source=None, args=None, name=PLUGIN_NAME,
executor=None, package_name=PACKAG... | plugin_name = 'plugin'
package_name = 'mock-plugin'
package_version = '1.0'
def create_plugin_url(plugin_tar_name, file_server):
return '{0}/{1}'.format(file_server.url, plugin_tar_name)
def plugin_struct(file_server, source=None, args=None, name=PLUGIN_NAME, executor=None, package_name=PACKAGE_NAME):
return ... |
# Title: Reverse Linked List II
# Link: https://leetcode.com/problems/reverse-linked-list-ii/
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Problem:
def reverse_between(self, head: ListNode, m: int, n: int) -> ListNode:
cur = head
... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Problem:
def reverse_between(self, head: ListNode, m: int, n: int) -> ListNode:
cur = head
part = None
n = n - m
(head_end, tail_head) = (None, None)
m -= 1
... |
class TestImporter:
domain_file = "test/data/domain-woz.xml"
dialogue_file = "test/data/woz-dialogue.xml"
domain_file2 = "test/data/example-domain-params.xml"
dialogue_file2 = "test/data/dialogue.xml"
# def test_importer(self):
# system = DialogueSystem(XMLDomainReader.extract_domain(self.d... | class Testimporter:
domain_file = 'test/data/domain-woz.xml'
dialogue_file = 'test/data/woz-dialogue.xml'
domain_file2 = 'test/data/example-domain-params.xml'
dialogue_file2 = 'test/data/dialogue.xml' |
def factorial(x):
if x <= 0:
return x+1
else:
return x * factorial(x-1)
result = []
while True:
try:
n = input().split()
a = int(n[0])
b = int(n[1])
result.append(factorial(a) + factorial(b))
except EOFError:
break
for i in range(0,len(result)):
print(r... | def factorial(x):
if x <= 0:
return x + 1
else:
return x * factorial(x - 1)
result = []
while True:
try:
n = input().split()
a = int(n[0])
b = int(n[1])
result.append(factorial(a) + factorial(b))
except EOFError:
break
for i in range(0, len(result)... |
# OUT OF PLACE retuns new different dictionary
def replace_dict_value(d, bad_val, good_val):
new_dict = {}
for key, value in d.items():
if bad_val == value:
new_dict[key] = good_val
else:
new_dict[key] = value
return new_dict
og_dict = {'a':5,'b':6,'c':5}
print(og_d... | def replace_dict_value(d, bad_val, good_val):
new_dict = {}
for (key, value) in d.items():
if bad_val == value:
new_dict[key] = good_val
else:
new_dict[key] = value
return new_dict
og_dict = {'a': 5, 'b': 6, 'c': 5}
print(og_dict)
fresh_dict = replace_dict_value(og_di... |
Dict = {1:'Amrik', 2: 'Abhi'}
print (Dict)
##call
print(Dict[1])
print(Dict.get(2)) | dict = {1: 'Amrik', 2: 'Abhi'}
print(Dict)
print(Dict[1])
print(Dict.get(2)) |
# Copyright (c) 2016-2017 Dustin Doloff
# Licensed under Apache License v2.0
load(
"@bazel_toolbox//labels:labels.bzl",
"executable_label",
)
load(
":internal.bzl",
"web_internal_generate_variables",
)
generate_variables = rule(
attrs = {
"config": attr.label(
mandatory = True,... | load('@bazel_toolbox//labels:labels.bzl', 'executable_label')
load(':internal.bzl', 'web_internal_generate_variables')
generate_variables = rule(attrs={'config': attr.label(mandatory=True, allow_single_file=True), 'out_js': attr.output(), 'out_css': attr.output(), 'out_scss': attr.output(), '_generate_variables_script'... |
#https://www.codechef.com/problems/CHEFEZQ
for _ in range(int(input())):
q,k=map(int,input().split())
l=list(map(int,input().split()))
rem=0
c=0
f=0
for i in range(q):
rem+=l[i]
if(rem-k<0):
f=1
break
c+=1
rem-=k
print(c+1) if f else p... | for _ in range(int(input())):
(q, k) = map(int, input().split())
l = list(map(int, input().split()))
rem = 0
c = 0
f = 0
for i in range(q):
rem += l[i]
if rem - k < 0:
f = 1
break
c += 1
rem -= k
print(c + 1) if f else print(int(sum(l) ... |
# python_version >= '3.8'
#: Okay
class C:
def __init__(self, a, /, b=None):
pass
#: N805:2:18
class C:
def __init__(this, a, /, b=None):
pass
| class C:
def __init__(self, a, /, b=None):
pass
class C:
def __init__(this, a, /, b=None):
pass |
# Write your solution here
def count_matching_elements(my_matrix: list, element: int):
count = 0
for row in my_matrix:
for item in row:
if item == element:
count += 1
return count
if __name__ == "__main__":
m = [[1, 2, 1], [0, 3, 4], [1, 0, 0]]
print(count_matchin... | def count_matching_elements(my_matrix: list, element: int):
count = 0
for row in my_matrix:
for item in row:
if item == element:
count += 1
return count
if __name__ == '__main__':
m = [[1, 2, 1], [0, 3, 4], [1, 0, 0]]
print(count_matching_elements(m, 1)) |
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [
{
"name": "newaccount",
"base": "",
"fields": [
{"name":"account", "type":"name"},
{"name":"pub_key", "type":"public_key"}
]
}
],
"actions": [{
... | {'version': 'eosio::abi/1.0', 'types': [], 'structs': [{'name': 'newaccount', 'base': '', 'fields': [{'name': 'account', 'type': 'name'}, {'name': 'pub_key', 'type': 'public_key'}]}], 'actions': [{'name': 'newaccount', 'type': 'newaccount', 'ricardian_contract': ''}], 'tables': [], 'ricardian_clauses': [], 'error_messa... |
iput = input('Multiphy number')
divi = input ('Multiply By?')
try:
put = int(iput)
di = int(divi)
ans = put * di
except:
print('Invalid Value')
quit()
print(ans)
| iput = input('Multiphy number')
divi = input('Multiply By?')
try:
put = int(iput)
di = int(divi)
ans = put * di
except:
print('Invalid Value')
quit()
print(ans) |
# Python3 program to find the
# max LRproduct[i] among all i
# Method to find the next greater
# value in left side
def nextGreaterInLeft(a):
left_index = [0] * len(a)
s = []
for i in range(len(a)):
# Checking if current
# element is greater than top
... | def next_greater_in_left(a):
left_index = [0] * len(a)
s = []
for i in range(len(a)):
while len(s) != 0 and a[i] >= a[s[-1]]:
s.pop()
if len(s) != 0:
left_index[i] = s[-1]
else:
left_index[i] = 0
s.append(i)
return left_index
def next_... |
CALENDAR_CACHE_TIME = 5*60 # seconds
CALENDAR_COLORS = ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854']
CALENDARS = [
{
'name': 'ATP Tennis 2018',
'color': CALENDAR_COLORS[0],
'url': '''https://p23-calendars.icloud.com/published/2/PMXFAiuTnEBHpFCFP8YdjnQt3zIkrpTgDwH58V9EWgy0_sZKiUMsrUl_DTyynnz5iCTEdu-h3ojPtsT... | calendar_cache_time = 5 * 60
calendar_colors = ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854']
calendars = [{'name': 'ATP Tennis 2018', 'color': CALENDAR_COLORS[0], 'url': 'https://p23-calendars.icloud.com/published/2/PMXFAiuTnEBHpFCFP8YdjnQt3zIkrpTgDwH58V9EWgy0_sZKiUMsrUl_DTyynnz5iCTEdu-h3ojPtsTwhzz59tWWK3zayh... |
#
# PySNMP MIB module ZYXEL-CFM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-CFM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:43:08 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... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) ... |
N,M=map(int,input().split())
if M == 1 or M == 2:
print("NEWBIE!")
elif M<=N:
print("OLDBIE!")
else:
print("TLE!") | (n, m) = map(int, input().split())
if M == 1 or M == 2:
print('NEWBIE!')
elif M <= N:
print('OLDBIE!')
else:
print('TLE!') |
class MetricObjective:
def __init__(self, task):
self.task = task
self.clear()
def clear(self):
self.total = 0
self.iter = 0
def step(self):
self.total = 0
self.iter += 1
def update(self, logits, targets, args, metadata={}):
self.total += args[... | class Metricobjective:
def __init__(self, task):
self.task = task
self.clear()
def clear(self):
self.total = 0
self.iter = 0
def step(self):
self.total = 0
self.iter += 1
def update(self, logits, targets, args, metadata={}):
self.total += args[... |
a = input("give numbers ")#1
while a.isdigit() != True:
a = input("give numbers ")#1
b = input("give numbers ")
while b == 0 or b.isdigit() != True:
b = input("give numbers ")
a = int(a)
b = int(b)
if str(a)[-1] in [0,2,4,6,8]:
print("even")
else:
print("odd")
print(int(a)/int(b))#2
x = 0#3
b = 0
whi... | a = input('give numbers ')
while a.isdigit() != True:
a = input('give numbers ')
b = input('give numbers ')
while b == 0 or b.isdigit() != True:
b = input('give numbers ')
a = int(a)
b = int(b)
if str(a)[-1] in [0, 2, 4, 6, 8]:
print('even')
else:
print('odd')
print(int(a) / int(b))
x = 0
b = 0
while x ... |
def setup():
size(500,500);
background(0);
smooth();
noLoop();
def draw():
strokeWeight(10);
stroke(200);
line(10, 10, 400, 400)
| def setup():
size(500, 500)
background(0)
smooth()
no_loop()
def draw():
stroke_weight(10)
stroke(200)
line(10, 10, 400, 400) |
def lower(o):
t = type(o)
if t == str:
return o.lower()
elif t in (list, tuple, set):
return t(lower(i) for i in o)
elif t == dict:
return dict((lower(k), lower(v)) for k, v in o.items())
raise TypeError('Unable to lower %s (%s)' % (o, repr(o)))
| def lower(o):
t = type(o)
if t == str:
return o.lower()
elif t in (list, tuple, set):
return t((lower(i) for i in o))
elif t == dict:
return dict(((lower(k), lower(v)) for (k, v) in o.items()))
raise type_error('Unable to lower %s (%s)' % (o, repr(o))) |
def extractAlbedo404BlogspotCom(item):
'''
Parser for 'albedo404.blogspot.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
tagmap = [
('PRC', 'PRC', 'translated'),
('Loiterou... | def extract_albedo404_blogspot_com(item):
"""
Parser for 'albedo404.blogspot.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 = [('PRC', 'PRC', 'translated'), ('Loiterous', 'Lo... |
class FeatureDataResponseDto:
def __init__(self,
value = None,
iterationCount = None,
featureKey = None,
sampleKey = None
):
self.value = value
self.iterationCount = iterationCount
self.featureKey = featureKey
self.sampleKey = sampleKey
class Feat... | class Featuredataresponsedto:
def __init__(self, value=None, iterationCount=None, featureKey=None, sampleKey=None):
self.value = value
self.iterationCount = iterationCount
self.featureKey = featureKey
self.sampleKey = sampleKey
class Featuredatarequestdto:
def __init__(self, f... |
#zero
if n == 0:
yield []
return
#modify
for ig in partitions(n-1):
yield [1] + ig
if ig and (len(ig) < 2 or ig[1] > ig[0]):
yield [ig[0] + 1] + ig[1:]
| if n == 0:
yield []
return
for ig in partitions(n - 1):
yield ([1] + ig)
if ig and (len(ig) < 2 or ig[1] > ig[0]):
yield ([ig[0] + 1] + ig[1:]) |
N = int(input())
for i in range(N):
S = input().split()
print(S)
# ......
for string in S:
if string.upper() == "THE":
count += 1
| n = int(input())
for i in range(N):
s = input().split()
print(S)
for string in S:
if string.upper() == 'THE':
count += 1 |
print("BMI Calculator\n")
weight = float(input("Input your weight (kg.) : "))
height = float(input("Input your height (cm.) : ")) / 100
bmi = weight / height ** 2
print("\nYour BMI = {:15,.2f}".format(bmi))
# print("\nYour BMI = {0:.2f}".format(float(input("Input your weight (kg.) : ")) / ((float(input("In... | print('BMI Calculator\n')
weight = float(input('Input your weight (kg.) : '))
height = float(input('Input your height (cm.) : ')) / 100
bmi = weight / height ** 2
print('\nYour BMI = {:15,.2f}'.format(bmi)) |
# O(N) Solution:
def leftIndex(n,arr,x):
for i in range(n):
if arr[i] == x:
return i
return -1
#______________________________________________________________________________________
# O(logN) Solution: Using Binary Search to find the first occurence of the element
def leftI... | def left_index(n, arr, x):
for i in range(n):
if arr[i] == x:
return i
return -1
def left_index(N, A, x):
lo = 0
hi = N - 1
mid = lo + (hi - lo) // 2
while lo <= hi:
mid = lo + (hi - lo) // 2
if A[mid] == x and mid == 0 or (A[mid] == x and A[mid - 1] < x):
... |
'''
Given an array of characters, compress it in-place.
The length after compression must always be smaller than or equal to the original array.
Every element of the array should be a character (not int) of length 1.
After you are done modifying the input array in-place, return the new length of the array.
Follow... | """
Given an array of characters, compress it in-place.
The length after compression must always be smaller than or equal to the original array.
Every element of the array should be a character (not int) of length 1.
After you are done modifying the input array in-place, return the new length of the array.
Follow... |
class Try(object):
@staticmethod
def print_hi():
print('hi')
| class Try(object):
@staticmethod
def print_hi():
print('hi') |
class Endpoint:
def __init__(self, ID, data_center_latency):
self.ID = ID
self.data_center_latency = data_center_latency
self.cache_server_connections = []
# def get_connection(self, cs):
# if(cs in self.cache_server_connections_hash.keys()):
# return self.cache_serv... | class Endpoint:
def __init__(self, ID, data_center_latency):
self.ID = ID
self.data_center_latency = data_center_latency
self.cache_server_connections = [] |
# 1038
code, quantity = input().split(" ")
code = int(code)
quantity = int(quantity)
if code == 1:
print("Total: R$ {0:.2f}".format(quantity * 4.00))
elif code == 2:
print("Total: R$ {0:.2f}".format(quantity * 4.50))
elif code == 3:
print("Total: R$ {0:.2f}".format(quantity * 5.00))
elif code == 4:
prin... | (code, quantity) = input().split(' ')
code = int(code)
quantity = int(quantity)
if code == 1:
print('Total: R$ {0:.2f}'.format(quantity * 4.0))
elif code == 2:
print('Total: R$ {0:.2f}'.format(quantity * 4.5))
elif code == 3:
print('Total: R$ {0:.2f}'.format(quantity * 5.0))
elif code == 4:
print('Total... |
expected_output = {
"route-information": {
"route-table": {
"active-route-count": "929",
"destination-count": "929",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
"rt-destination": "10.220.0.0... | expected_output = {'route-information': {'route-table': {'active-route-count': '929', 'destination-count': '929', 'hidden-route-count': '0', 'holddown-route-count': '0', 'rt': [{'rt-destination': '10.220.0.0/16', 'rt-entry': {'active-tag': '*', 'as-path': '(65151 65000) I', 'bgp-metric-flags': 'Nexthop Change', 'local-... |
# Modulo
for i in range(0, 101):
if i % 2 == 0:
print (str(i) + " is even")
else:
print (str(i) + " is odd")
print ("----------------------")
# Without modulo
for i in range (0,101):
num = int(i/2)
if (num * 2 == i):
print (str(i) + " is even")
else:
print (str(i) + " is odd")
| for i in range(0, 101):
if i % 2 == 0:
print(str(i) + ' is even')
else:
print(str(i) + ' is odd')
print('----------------------')
for i in range(0, 101):
num = int(i / 2)
if num * 2 == i:
print(str(i) + ' is even')
else:
print(str(i) + ' is odd') |
# csamiselo@github.com 15.10.2019
print("This is how i count my livestock")
print("Goats",12 + 30 + 60)
print("Cows", 13 + 15 + 10)
print ("Layers" ,1000 + 250 + 503 )
print ("Are the layers more than the goats")
print (12 + 30 + 60 < 1000 + 250 +503 )
| print('This is how i count my livestock')
print('Goats', 12 + 30 + 60)
print('Cows', 13 + 15 + 10)
print('Layers', 1000 + 250 + 503)
print('Are the layers more than the goats')
print(12 + 30 + 60 < 1000 + 250 + 503) |
class CeleryConfig:
# List of modules to import when the Celery worker starts.
imports = ('apps.tasks',)
## Broker settings.
broker_url = 'amqp://'
## Disable result backent and also ignore results.
task_ignore_result = True
| class Celeryconfig:
imports = ('apps.tasks',)
broker_url = 'amqp://'
task_ignore_result = True |
def if_pycaffe(if_true, if_false = []):
return select({
"@caffe_tools//:caffe_python_layer": if_true,
"//conditions:default": if_false
})
def caffe_pkg(label):
return select({
"//conditions:default": ["@caffe//" + label],
"@caffe_tools//:use_caffe_rcnn": ["@caffe_rcnn//" + label],
"... | def if_pycaffe(if_true, if_false=[]):
return select({'@caffe_tools//:caffe_python_layer': if_true, '//conditions:default': if_false})
def caffe_pkg(label):
return select({'//conditions:default': ['@caffe//' + label], '@caffe_tools//:use_caffe_rcnn': ['@caffe_rcnn//' + label], '@caffe_tools//:use_caffe_ssd': ['... |
frase = "Nos estamos procurando o rubi na floresta"
rubi = frase[24:29]
print (rubi) | frase = 'Nos estamos procurando o rubi na floresta'
rubi = frase[24:29]
print(rubi) |
def spiralTraverse(array):
num_elements = len(array) * len(array[0])
n = len(array)
m = len(array[0])
it = 0
result = []
while num_elements > 0:
# Up side
for j in range(it, m - it):
result.append(array[it][j])
num_elements -= 1
if num_elemen... | def spiral_traverse(array):
num_elements = len(array) * len(array[0])
n = len(array)
m = len(array[0])
it = 0
result = []
while num_elements > 0:
for j in range(it, m - it):
result.append(array[it][j])
num_elements -= 1
if num_elements == 0:
... |
{
PDBConst.Name: "paymentmode",
PDBConst.Columns: [
{
PDBConst.Name: "ID",
PDBConst.Attributes: ["tinyint", "not null", "primary key"]
},
{
PDBConst.Name: "Name",
PDBConst.Attributes: ["varchar(128)", "not null"]
},
{
PDBConst.Name: "SID",
PDBC... | {PDBConst.Name: 'paymentmode', PDBConst.Columns: [{PDBConst.Name: 'ID', PDBConst.Attributes: ['tinyint', 'not null', 'primary key']}, {PDBConst.Name: 'Name', PDBConst.Attributes: ['varchar(128)', 'not null']}, {PDBConst.Name: 'SID', PDBConst.Attributes: ['varchar(128)', 'not null']}], PDBConst.Initials: [{'Name': "'Cre... |
class Graph(object):
def __init__(self, graph_dict=None):
if graph_dict == None:
graph_dict = {}
self.__graph_dict = graph_dict
| class Graph(object):
def __init__(self, graph_dict=None):
if graph_dict == None:
graph_dict = {}
self.__graph_dict = graph_dict |
main = {
'General': {
'Prop': {
'Labels': 'rw',
'AlarmStatus': 'r-'
}
}
}
cfgm = {
'General': {
'Prop': {
'Blacklist': 'rw'
}
}
}
fm = {
'Status': {
'Prop': {
'AlarmStatus': 'r-'
},
'Cmd': (
... | main = {'General': {'Prop': {'Labels': 'rw', 'AlarmStatus': 'r-'}}}
cfgm = {'General': {'Prop': {'Blacklist': 'rw'}}}
fm = {'Status': {'Prop': {'AlarmStatus': 'r-'}, 'Cmd': ('Acknowledge',)}, 'Configuration': {'Prop': {'AlarmConfiguration': 'rw'}}, 'DuplicatedMac': {'Prop': {'DuplicatedMacAccessList': 'r-'}, 'Cmd': ('F... |
tiles = [
# Riker's Island - https://www.openstreetmap.org/relation/3955540
(10, 301, 384, 'Rikers Island'),
# SF County Jail - https://www.openstreetmap.org/way/103383866
(14, 2621, 6332, 'SF County Jail')
]
for z, x, y, name in tiles:
assert_has_feature(
z, x, y, 'pois',
{ 'kind':... | tiles = [(10, 301, 384, 'Rikers Island'), (14, 2621, 6332, 'SF County Jail')]
for (z, x, y, name) in tiles:
assert_has_feature(z, x, y, 'pois', {'kind': 'prison', 'name': name})
assert_has_feature(10, 301, 384, 'landuse', {'kind': 'prison'}) |
def median(x):
sorted_x = sorted(x)
midpoint = len(x) // 2
if len(x) % 2:
return sorted_x[midpoint]
else:
return (sorted_x[midpoint]+sorted_x[midpoint-1])/2
assert median([1]) == 1
assert median([1, 2]) == 1.5
assert median([1, 2, 3]) == 2
assert median([3,1,2]) == 2
assert medi... | def median(x):
sorted_x = sorted(x)
midpoint = len(x) // 2
if len(x) % 2:
return sorted_x[midpoint]
else:
return (sorted_x[midpoint] + sorted_x[midpoint - 1]) / 2
assert median([1]) == 1
assert median([1, 2]) == 1.5
assert median([1, 2, 3]) == 2
assert median([3, 1, 2]) == 2
assert media... |
#!/usr/bin/python3
#https://codeforces.com/contest/1426/problem/F
def f(s):
_,a,ab,abc = 1,0,0,0
for c in s:
if c=='a':
a += _
elif c=='b':
ab += a
elif c=='c':
abc += ab
else:
abc *= 3
abc += ab
ab *=... | def f(s):
(_, a, ab, abc) = (1, 0, 0, 0)
for c in s:
if c == 'a':
a += _
elif c == 'b':
ab += a
elif c == 'c':
abc += ab
else:
abc *= 3
abc += ab
ab *= 3
ab += a
a *= 3
a +... |
DEBUG = True
INSTAGRAM_CLIENT_ID = ''
INSTAGRAM_CLIENT_SECRET = ''
INSTAGRAM_CALLBACK = 'http://cameo.gala-isen.fr/api/instagram/hub'
MONGODB_NAME = 'cameo'
MONGODB_HOST = 'localhost'
MONGODB_PORT = 27017
REDIS_HOST = 'localhost'
REDIS_PORT = 6379 | debug = True
instagram_client_id = ''
instagram_client_secret = ''
instagram_callback = 'http://cameo.gala-isen.fr/api/instagram/hub'
mongodb_name = 'cameo'
mongodb_host = 'localhost'
mongodb_port = 27017
redis_host = 'localhost'
redis_port = 6379 |
npratio = 4
MAX_SENTENCE = 30
MAX_ALL = 50
MAX_SENT_LENGTH=30
MAX_SENTS=50 | npratio = 4
max_sentence = 30
max_all = 50
max_sent_length = 30
max_sents = 50 |
# Solution to day 1 of AOC 2015, Not Quite Lisp.
# https://adventofcode.com/2015/day/1
f = open('input.txt')
whole_text = f.read()
f.close()
floor = 0
steps = 0
basement_found = False
for each_char in whole_text:
if not basement_found:
steps += 1
if each_char == '(':
floor += 1
elif each... | f = open('input.txt')
whole_text = f.read()
f.close()
floor = 0
steps = 0
basement_found = False
for each_char in whole_text:
if not basement_found:
steps += 1
if each_char == '(':
floor += 1
elif each_char == ')':
floor -= 1
if floor == -1:
basement_found = True
print('P... |
ask = "time is time versus time"
count = 0
for t in ask:
if t == "t":
count += 1
print(count)
number = list(range(5, 20, 2))
print(number) | ask = 'time is time versus time'
count = 0
for t in ask:
if t == 't':
count += 1
print(count)
number = list(range(5, 20, 2))
print(number) |
class CSVEmployeeRepository:
def __init__(self, csv_intepreter):
self._anagraphic = csv_intepreter.employees()
def birthdayFor(self, month, day):
return self._anagraphic.bornOn(Birthday(month, day))
class Anagraphic:
def __init__(self, employees):
self._employees = employees
... | class Csvemployeerepository:
def __init__(self, csv_intepreter):
self._anagraphic = csv_intepreter.employees()
def birthday_for(self, month, day):
return self._anagraphic.bornOn(birthday(month, day))
class Anagraphic:
def __init__(self, employees):
self._employees = employees
... |
PACKAGE_NAME = 'cdeid'
SPACY_PRETRAINED_MODEL_LG = 'en_core_web_lg'
# SPACY_PRETRAINED_MODEL_SM = 'en_core_web_sm'
PROGRESS_STATUS = {
1: 'prepare data sets',
2: 'train spacy on balanced sets',
3: 'train stanza on balanced sets',
4: 'train flair on balanced sets',
5: 'train spacy on imbalanced sets'... | package_name = 'cdeid'
spacy_pretrained_model_lg = 'en_core_web_lg'
progress_status = {1: 'prepare data sets', 2: 'train spacy on balanced sets', 3: 'train stanza on balanced sets', 4: 'train flair on balanced sets', 5: 'train spacy on imbalanced sets', 6: 'train stanza on imbalanced sets', 7: 'train flair on imbalance... |
def handle(event, context):
file = open("dynamicdns/scripts/dynamic-dns-client", "r")
content = file.read()
file.close()
headers = {
"Content-Type": "text/plain"
}
body = content
response = {
"statusCode": 200,
"headers": headers,
"body": body
}
re... | def handle(event, context):
file = open('dynamicdns/scripts/dynamic-dns-client', 'r')
content = file.read()
file.close()
headers = {'Content-Type': 'text/plain'}
body = content
response = {'statusCode': 200, 'headers': headers, 'body': body}
return response |
class Bird():
def __init__(self) :
self.wings = True
self.fur = True
self.fly = True
def isFly(self) :
return self.fly
Parrot = Bird()
if Parrot.isFly() == "fly" :
print("Parrot must be can fly")
else :
print("Why Parrot can't fly ?")
###### Inheritance #####
cla... | class Bird:
def __init__(self):
self.wings = True
self.fur = True
self.fly = True
def is_fly(self):
return self.fly
parrot = bird()
if Parrot.isFly() == 'fly':
print('Parrot must be can fly')
else:
print("Why Parrot can't fly ?")
class Penguin(Bird):
def __init__(... |
class MapMatcher:
def __init__(self, rn, routing_weight='length'):
self.rn = rn
self.routing_weight = routing_weight
def match(self, traj):
pass
def match_to_path(self, traj):
pass
| class Mapmatcher:
def __init__(self, rn, routing_weight='length'):
self.rn = rn
self.routing_weight = routing_weight
def match(self, traj):
pass
def match_to_path(self, traj):
pass |
#-*- coding: utf-8 -*-
# ------ wuage.com testing team ---------
# __author__ : weijx.cpp@gmail.com
def split(word):
return [char for char in word]
def test_crypt2():
letter :str = u"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"
let = letter.split("," ,maxsplit=26)
# let = ["X", "Y"]
# print... | def split(word):
return [char for char in word]
def test_crypt2():
letter: str = u'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'
let = letter.split(',', maxsplit=26)
cypterdata: str = 'yriry gjb cnffjbeq ebggra'
cypterwords = cypterdata.split(' ')
for i in range(1, 26):
print('++... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.