content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Twitter():
Consumer_Key = ''
Consumer_Secret = ''
Access_Token = ''
Access_Token_Secret = ''
CONNECTION_STRING = "sqlite:///Twitter.db"
LANG = ["en"]
| class Twitter:
consumer__key = ''
consumer__secret = ''
access__token = ''
access__token__secret = ''
connection_string = 'sqlite:///Twitter.db'
lang = ['en'] |
feature_types = {
# features with continuous numeric values
"continuous": [
"number_diagnoses",
"time_in_hospital",
"number_inpatient",
"number_emergency",
"num_procedures",
"num_medications",
"num_lab_procedures"],
# features which describe buckets o... | feature_types = {'continuous': ['number_diagnoses', 'time_in_hospital', 'number_inpatient', 'number_emergency', 'num_procedures', 'num_medications', 'num_lab_procedures'], 'range': ['age', 'weight'], 'categorical': ['diabetesMed', 'chlorpropamide', 'repaglinide', 'medical_specialty', 'rosiglitazone', 'miglitol', 'glipi... |
while True:
try:
input()
alice = set(input().split())
beatriz = set(input().split())
repeticoes = [1 for carta in alice if carta in beatriz]
print(min([len(alice), len(beatriz)]) - len(repeticoes))
except EOFError:
break
| while True:
try:
input()
alice = set(input().split())
beatriz = set(input().split())
repeticoes = [1 for carta in alice if carta in beatriz]
print(min([len(alice), len(beatriz)]) - len(repeticoes))
except EOFError:
break |
def square(a):
return(a*a)
# a=int(input("enter the number"))
# square(a)
s=[2,3,4,5,6,7,8,9,10]
print(list(map(square,s)))
| def square(a):
return a * a
s = [2, 3, 4, 5, 6, 7, 8, 9, 10]
print(list(map(square, s))) |
features = [
"mtarg1",
"mtarg2",
"mtarg3",
"roll",
"pitch",
"LACCX",
"LACCY",
"LACCZ",
"GYROX",
"GYROY",
"SC1I",
"SC2I",
"SC3I",
"BT1I",
"BT2I",
"vout",
"iout",
"cpuUsage",
]
fault_features = ["fault", "fault_type", "fault_value", "fault_duration"... | features = ['mtarg1', 'mtarg2', 'mtarg3', 'roll', 'pitch', 'LACCX', 'LACCY', 'LACCZ', 'GYROX', 'GYROY', 'SC1I', 'SC2I', 'SC3I', 'BT1I', 'BT2I', 'vout', 'iout', 'cpuUsage']
fault_features = ['fault', 'fault_type', 'fault_value', 'fault_duration'] |
maxsimal = 0
while True:
a = int(input("Masukan bilangan = "))
if maxsimal < a:
maxsimal = a
if a == 0:
break
print("Bilangan Terbesarnya Adalah = ", maxsimal)
| maxsimal = 0
while True:
a = int(input('Masukan bilangan = '))
if maxsimal < a:
maxsimal = a
if a == 0:
break
print('Bilangan Terbesarnya Adalah = ', maxsimal) |
class Holding(object):
def __init__(self, name, symbol, sector, market_val_percent, market_value, number_of_shares):
self.name = name
self.symbol = symbol
self.sector = sector
self.market_val_percent = market_val_percent
self.market_value = market_value
self.number_... | class Holding(object):
def __init__(self, name, symbol, sector, market_val_percent, market_value, number_of_shares):
self.name = name
self.symbol = symbol
self.sector = sector
self.market_val_percent = market_val_percent
self.market_value = market_value
self.number_o... |
# rps data for the rock-paper-scissors portion of the red-green game
# to be imported by rg.cgi
# this file represents the "host throw" for each numbered round
rps_data = {
0: "rock",
1: "rock",
2: "scissors",
3: "paper",
4: "paper",
5: "scissors",
6: "rock",
7: "scissors",
8: "pape... | rps_data = {0: 'rock', 1: 'rock', 2: 'scissors', 3: 'paper', 4: 'paper', 5: 'scissors', 6: 'rock', 7: 'scissors', 8: 'paper', 9: 'paper', 10: 'scissors', 11: 'rock', 12: 'paper', 13: 'paper', 14: 'rock', 15: 'scissors', 16: 'scissors', 17: 'scissors', 18: 'rock', 19: 'scissors', 20: 'paper', 21: 'rock', 22: 'paper', 23... |
user_info = {}
while True:
print("\n\t\t\tUnits:metric")
name = str(input("Enter your name: "))
height = float(input("Input your height in meters(For instance:1.89): "))
weight = float(input("Input your weight in kilogram(For instance:69): "))
age = int(input("Input your age: "))
sex = str(input... | user_info = {}
while True:
print('\n\t\t\tUnits:metric')
name = str(input('Enter your name: '))
height = float(input('Input your height in meters(For instance:1.89): '))
weight = float(input('Input your weight in kilogram(For instance:69): '))
age = int(input('Input your age: '))
sex = str(input... |
#!/usr/bin/env python
#-*- coding: utf-8 -*-
def getHeaders(fileName):
headers = []
headerList = ['User-Agent','Cookie']
with open(fileName, 'r') as fp:
for line in fp.readlines():
name, value = line.split(':', 1)
if name in headerList:
headers.append((name.st... | def get_headers(fileName):
headers = []
header_list = ['User-Agent', 'Cookie']
with open(fileName, 'r') as fp:
for line in fp.readlines():
(name, value) = line.split(':', 1)
if name in headerList:
headers.append((name.strip(), value.strip()))
return header... |
class ComponentsAssembly:
def __init__(self, broker, strategy, datafeed, sizer, metrics_collection, *args):
self._components = [broker, strategy, datafeed, sizer, metrics_collection, *args]
def __iter__(self):
self.index = 0
return self
def __next__(self):
if self.index ... | class Componentsassembly:
def __init__(self, broker, strategy, datafeed, sizer, metrics_collection, *args):
self._components = [broker, strategy, datafeed, sizer, metrics_collection, *args]
def __iter__(self):
self.index = 0
return self
def __next__(self):
if self.index < ... |
# Lecture 3.6, slide 2
# Defines the value to take the square root of, epsilon, and the number of guesses.
x = 9
epsilon = 0.01
numGuesses = 0
# Here, 0 < x < 1, then the low is x and the high is 1 - the sqrt(x) > x if 0 < x < 1.
# If x > 1, then the low is 0 and the high is x - the sqrt(x) < x if x > 1.
if (x >= 0 a... | x = 9
epsilon = 0.01
num_guesses = 0
if x >= 0 and x < 1:
low = x
high = 1.0
elif x >= 1:
low = 0.0
high = x
ans = (low + high) / 2.0
while abs(ans ** 2 - x) >= epsilon:
print('low = ' + str(low) + ' ; high = ' + str(high) + ' ; ans = ' + str(ans))
num_guesses += 1
if ans ** 2 < x:
l... |
# ctx.addClock("csi_rx_i.dphy_clk", 96)
# ctx.addClock("video_clk", 24)
# ctx.addClock("uart_i.sys_clk_i", 12)
ctx.addClock("EXTERNAL_CLK", 12)
# ctx.addClock("clk", 25)
| ctx.addClock('EXTERNAL_CLK', 12) |
class Solution:
def soupServings(self, N: int) -> float:
def dfs(a: int, b: int) -> float:
if a <= 0 and b <= 0:
return 0.5
if a <= 0:
return 1.0
if b <= 0:
return 0.0
if memo[a][b] > 0:
return memo[a][b]
memo[a][b] = 0.25 * (dfs(a - 4, b) +
... | class Solution:
def soup_servings(self, N: int) -> float:
def dfs(a: int, b: int) -> float:
if a <= 0 and b <= 0:
return 0.5
if a <= 0:
return 1.0
if b <= 0:
return 0.0
if memo[a][b] > 0:
return... |
# First we define a variable "to_find" which contains the alphabet to be checked for in the file
# fo is the file which is to be read.
to_find="e"
fo = open('E:/file1.txt' ,'r+')
count=0
for line in fo:
for word in line.split():
if word.find(to_find)!=-1:
count=count+1
print(... | to_find = 'e'
fo = open('E:/file1.txt', 'r+')
count = 0
for line in fo:
for word in line.split():
if word.find(to_find) != -1:
count = count + 1
print(count) |
DELIVERY_TYPES = (
(1, "Vaginal Birth"), # Execise care when changing...
(2, "Caesarian")
)
| delivery_types = ((1, 'Vaginal Birth'), (2, 'Caesarian')) |
class Solution:
def makeGood(self, s: str) -> str:
i = 0
string = list(s)
while i < len(string) - 1:
a = string[i]
b = string[i + 1]
if a.lower() == b.lower() and a != b:
string.pop(i)
string.pop(i)
i = 0
... | class Solution:
def make_good(self, s: str) -> str:
i = 0
string = list(s)
while i < len(string) - 1:
a = string[i]
b = string[i + 1]
if a.lower() == b.lower() and a != b:
string.pop(i)
string.pop(i)
i = 0
... |
l,j,k=[list(input()) for i in range(3)]
l.extend(j)
for i in l:
if i not in k :
k.append(i)
break
k.remove(i)
print('YES' if k==[] else 'NO')
| (l, j, k) = [list(input()) for i in range(3)]
l.extend(j)
for i in l:
if i not in k:
k.append(i)
break
k.remove(i)
print('YES' if k == [] else 'NO') |
#
# PySNMP MIB module CXQLLC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXQLLC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:33:22 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:... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, value_size_constraint, constraints_intersection) ... |
RGB2HEX = 1
RGB2HSV = 2
RGB2HSL = 3
HEX2RGB = 4
HSV2RGB = 5
OPCV_RGB2HSV = 100
OPCV_HSV2RGB = 101 | rgb2_hex = 1
rgb2_hsv = 2
rgb2_hsl = 3
hex2_rgb = 4
hsv2_rgb = 5
opcv_rgb2_hsv = 100
opcv_hsv2_rgb = 101 |
class ImageGroupsComponent:
def __init__(self, key=None, imageGroup=None):
self.key = 'imagegroups'
self.current = None
self.animationList = {}
self.alpha = 255
self.hue = None
self.playing = True
if key is not None and imageGroup is not None:
sel... | class Imagegroupscomponent:
def __init__(self, key=None, imageGroup=None):
self.key = 'imagegroups'
self.current = None
self.animationList = {}
self.alpha = 255
self.hue = None
self.playing = True
if key is not None and imageGroup is not None:
sel... |
class Tag(object):
def __init__(self, tag_name : str, type_ = None):
self.__tag_name = tag_name
self.__type : str = type_ if type_ is not None else ""
@property
def type(self) -> str:
return self.__type
@property
def name(self) -> str:
return self.__tag_name... | class Tag(object):
def __init__(self, tag_name: str, type_=None):
self.__tag_name = tag_name
self.__type: str = type_ if type_ is not None else ''
@property
def type(self) -> str:
return self.__type
@property
def name(self) -> str:
return self.__tag_name
def _... |
#First go
print("Hello, World!")
message = "Hello, World!"
print(message)
#-------> print "Hello World!" is Python 2 syntax, use print("Hello World!") for Python 3
| print('Hello, World!')
message = 'Hello, World!'
print(message) |
# https://leetcode.com/problems/minimum-depth-of-binary-tree
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def minDepth(self, root):
if not root:
return 0
... | class Solution:
def min_depth(self, root):
if not root:
return 0
ans = set()
def helper(node, depth):
if not node.left and (not node.right):
ans.add(depth)
return
if node.right:
helper(node.right, depth + 1... |
EXCHANGE_CFFEX = 0
EXCHANGE_SHFE = 1
EXCHANGE_DCE = 2
EXCHANGE_SSEOPT = 3
EXCHANGE_CZCE = 4
EXCHANGE_SZSE = 5
EXCHANGE_SSE = 6
EXCHANGE_UNKNOWN = 7
| exchange_cffex = 0
exchange_shfe = 1
exchange_dce = 2
exchange_sseopt = 3
exchange_czce = 4
exchange_szse = 5
exchange_sse = 6
exchange_unknown = 7 |
numerator = int(input("Enter a numerator: "))
denominator = int(input("Enter denominator: "))
while denominator == 0:
print("Denominator cannot be 0")
denominator = int(input("Enter denominator: "))
if int(numerator / denominator) * denominator == numerator:
print("Divides evenly!")
else:
... | numerator = int(input('Enter a numerator: '))
denominator = int(input('Enter denominator: '))
while denominator == 0:
print('Denominator cannot be 0')
denominator = int(input('Enter denominator: '))
if int(numerator / denominator) * denominator == numerator:
print('Divides evenly!')
else:
print("Doesn't... |
class Solution:
#Function to find sum of weights of edges of the Minimum Spanning Tree.
def spanningTree(self, V, adj):
#code here
##findpar with rank compression
def findpar(x):
if parent[x]==x:
return x
else:
parent[x]=findpa... | class Solution:
def spanning_tree(self, V, adj):
def findpar(x):
if parent[x] == x:
return x
else:
parent[x] = findpar(parent[x])
return parent[x]
def union(x, y):
lp_x = findpar(x)
lp_y = findpar(y)
... |
class Pegawai:
def __init__(self, nama, email, gaji):
self.__namaPegawai = nama
self.__emailPegawai = email
self.__gajiPegawai = gaji
# decoration ini digunakan untuk mengakses property
# nama pegawai agar dapat diakses tanpa menggunakan
# intance.namaPegawai() melainkan instan... | class Pegawai:
def __init__(self, nama, email, gaji):
self.__namaPegawai = nama
self.__emailPegawai = email
self.__gajiPegawai = gaji
@property
def nama_pegawai(self):
return self.__namaPegawai
@namaPegawai.setter
def nama_pegawai(self, nama):
self.__namaPe... |
snippet_normalize (cr, width, height)
cr.set_line_width (0.12)
cr.set_line_cap (cairo.LINE_CAP_BUTT) #/* default */
cr.move_to (0.25, 0.2); cr.line_to (0.25, 0.8)
cr.stroke ()
cr.set_line_cap (cairo.LINE_CAP_ROUND)
cr.move_to (0.5, 0.2); cr.line_to (0.5, 0.8)
cr.stroke ()
cr.set_line_cap (cairo.LINE_CAP_SQUARE)
cr.m... | snippet_normalize(cr, width, height)
cr.set_line_width(0.12)
cr.set_line_cap(cairo.LINE_CAP_BUTT)
cr.move_to(0.25, 0.2)
cr.line_to(0.25, 0.8)
cr.stroke()
cr.set_line_cap(cairo.LINE_CAP_ROUND)
cr.move_to(0.5, 0.2)
cr.line_to(0.5, 0.8)
cr.stroke()
cr.set_line_cap(cairo.LINE_CAP_SQUARE)
cr.move_to(0.75, 0.2)
cr.line_to(0.... |
class DiscreteEnvWrapper:
def __init__(self, env):
self.__env = env
def reset(self):
return self.__env.reset()
def step(self, action):
next_state, reward, done, info = self.__env.step(action)
return next_state, reward, done, info
def render(self):
self.__env.re... | class Discreteenvwrapper:
def __init__(self, env):
self.__env = env
def reset(self):
return self.__env.reset()
def step(self, action):
(next_state, reward, done, info) = self.__env.step(action)
return (next_state, reward, done, info)
def render(self):
self.__e... |
def mse(x, target):
n = max(x.numel(), target.numel())
return (x - target).pow(2).sum() / n
def snr(x, target):
noise = (x - target).pow(2).sum()
signal = target.pow(2).sum()
SNR = 10 * (signal / noise).log10_()
return SNR
| def mse(x, target):
n = max(x.numel(), target.numel())
return (x - target).pow(2).sum() / n
def snr(x, target):
noise = (x - target).pow(2).sum()
signal = target.pow(2).sum()
snr = 10 * (signal / noise).log10_()
return SNR |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def bstFromPreorder(self, preorder: List[int]) -> TreeNode:
size = len(preorder)
root = TreeNode(preorder[0])
s = ... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def bst_from_preorder(self, preorder: List[int]) -> TreeNode:
size = len(preorder)
root = tree_node(preorder[0])
s = []
s.append(root)
i = 1
... |
def get_account(account_id: int):
return {
'account_id': 1,
'email': 'noreply@gerenciagram.com',
'first_name': 'Gerenciagram'
}
| def get_account(account_id: int):
return {'account_id': 1, 'email': 'noreply@gerenciagram.com', 'first_name': 'Gerenciagram'} |
__author__ = 'Michael Andrew michael@hazardmedia.co.nz'
class SoundModel(object):
sound = None
path = ""
delay = 0
delay_min = 0
delay_max = 0
def __init__(self, sound, path, delay=0, delay_min=0, delay_max=0):
self.sound = sound
self.path = path
self.delay = delay
... | __author__ = 'Michael Andrew michael@hazardmedia.co.nz'
class Soundmodel(object):
sound = None
path = ''
delay = 0
delay_min = 0
delay_max = 0
def __init__(self, sound, path, delay=0, delay_min=0, delay_max=0):
self.sound = sound
self.path = path
self.delay = delay
... |
max_strlen=[]
max_strindex=[]
for i in range(1,11):
file_name="sample."+str(i)
with open(file_name,"rb") as f:
offsets=[]
len_of_file=[]
for strand in f.readlines():
offsets.append(sum(len_of_file))
len_of_file.append(len(strand))
max_strlen.appe... | max_strlen = []
max_strindex = []
for i in range(1, 11):
file_name = 'sample.' + str(i)
with open(file_name, 'rb') as f:
offsets = []
len_of_file = []
for strand in f.readlines():
offsets.append(sum(len_of_file))
len_of_file.append(len(strand))
max_strlen.... |
tokens = ('IMPLY', 'LPAREN', 'RPAREN', 'PREDICATENAME', 'PREDICATEVAR')
precedence = (
('left', 'IMPLY'),
('left', '|', '&'),
('right', '~'),
)
t_ignore = ' \t'
t_IMPLY = r'=>'
t_RPAREN = r'\)'
t_LPAREN = r'\('
literals = ['|', ',', '&', '~']
def t_PREDICATENAME(t):
r'[A-Z][a-zA-Z0-9_]*'... | tokens = ('IMPLY', 'LPAREN', 'RPAREN', 'PREDICATENAME', 'PREDICATEVAR')
precedence = (('left', 'IMPLY'), ('left', '|', '&'), ('right', '~'))
t_ignore = ' \t'
t_imply = '=>'
t_rparen = '\\)'
t_lparen = '\\('
literals = ['|', ',', '&', '~']
def t_predicatename(t):
"""[A-Z][a-zA-Z0-9_]*"""
t.value = str(t.value)
... |
for i in range(int(input())):
n = int(input())
a = [0 for j in range(32)]
for j in range(n):
s = input()
p = 0
if('a' in s):
p|=1
if('e' in s):
p|=2
if('i' in s):
p|=4
if('o' in s):
p|=8
if('u' in s):
... | for i in range(int(input())):
n = int(input())
a = [0 for j in range(32)]
for j in range(n):
s = input()
p = 0
if 'a' in s:
p |= 1
if 'e' in s:
p |= 2
if 'i' in s:
p |= 4
if 'o' in s:
p |= 8
if 'u' in s:
... |
begin_unit
comment|'# Copyright 2013 OpenStack Foundation'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'# not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'# a copy of the License at'
... | begin_unit
comment | '# Copyright 2013 OpenStack Foundation'
nl | '\n'
comment | '#'
nl | '\n'
comment | '# Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl | '\n'
comment | '# not use this file except in compliance with the License. You may obtain'
nl | '\n'
comment | '# a copy o... |
## https://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/
## Restrictions with multiple metaclasses
# class Meta1(type):
# pass
# class Meta2(type):
# pass
# class Base1(metaclass=Meta1):
# pass
# class Base2(metaclass=Meta2):
# pass
# class Foobar(Base1, Base2):
# pass
# class Meta(type)... | class Base1(metaclass=Meta):
pass
class Base2(metaclass=SubMeta):
pass
class Foobar(Base1, Base2):
pass
type(Foobar) |
STRING_FILTER = 'string'
CHOICE_FILTER = 'choice'
BOOLEAN_FILTER = 'boolean'
RADIO_FILTER = 'radio'
HALF_WIDTH_FILTER = 'half_width'
FULL_WIDTH_FILTER = 'full_width'
VALID_FILTERS = (
STRING_FILTER,
CHOICE_FILTER,
BOOLEAN_FILTER,
RADIO_FILTER,
)
VALID_FILTER_WIDTHS = (
HALF_WIDTH_FILTER,
FULL... | string_filter = 'string'
choice_filter = 'choice'
boolean_filter = 'boolean'
radio_filter = 'radio'
half_width_filter = 'half_width'
full_width_filter = 'full_width'
valid_filters = (STRING_FILTER, CHOICE_FILTER, BOOLEAN_FILTER, RADIO_FILTER)
valid_filter_widths = (HALF_WIDTH_FILTER, FULL_WIDTH_FILTER)
sort_param = 'so... |
class Passenger():
def __init__(self, weight, floor, destination, time):
self.weight = weight
self.floor = floor
self.destination = destination
self.elevator = None
self.created_at = time
def enter(self, elevator):
'''
Input: the elevator that the passen... | class Passenger:
def __init__(self, weight, floor, destination, time):
self.weight = weight
self.floor = floor
self.destination = destination
self.elevator = None
self.created_at = time
def enter(self, elevator):
"""
Input: the elevator that the passenge... |
# ============================================================
# Title: Keep Talking and Nobody Explodes Solver: Who's on First?
# Author: Ryan J. Slater
# Date: 4/4/2019
# ============================================================
def solveSimonSays(textList, # List of strings [displayText, topLeft, topRight, m... | def solve_simon_says(textList, bombSpecs):
if textList[0] in ['ur']:
return get_responses_from_word(textList[1])
elif textList[0] in ['first', 'okay', 'c']:
return get_responses_from_word(textList[2])
elif textList[0] in ['yes', 'nothing', 'led', 'they are']:
return get_responses_fro... |
#coding:utf-8
#pulic
BASE_DIR = "/home/dengerqiang/Documents/WORK/"
VQA_BASE = BASE_DIR + 'VQA/'
DATA10 = VQA_BASE + "data1.0/"
DATA20 = VQA_BASE + "data2.0/"
IMAGE_DIR = VQA_BASE + "images/"
GLOVE_DIR = BASE_DIR + 'glove/'
NLTK_DIR = BASE_DIR + "nltk_data"
#private
WORK_DIR = BASE_DIR+ "VQA/DenseCoAttention/"
GLOVE_... | base_dir = '/home/dengerqiang/Documents/WORK/'
vqa_base = BASE_DIR + 'VQA/'
data10 = VQA_BASE + 'data1.0/'
data20 = VQA_BASE + 'data2.0/'
image_dir = VQA_BASE + 'images/'
glove_dir = BASE_DIR + 'glove/'
nltk_dir = BASE_DIR + 'nltk_data'
work_dir = BASE_DIR + 'VQA/DenseCoAttention/'
glove_file = 'glove.6B.100d.pt'
rnn_d... |
def toMinutesArray(times: str):
res = [0, 0]
startEnd = times.split()
hourMin = startEnd[0].split(':')
res[0] = int(hourMin[0]) * 60 + int(hourMin[1])
hourMin = startEnd[1].split(':')
res[1] = int(hourMin[0]) * 60 + int(hourMin[1])
return res
MAX_MINS = 1500
N = int(input())
table = [0] *... | def to_minutes_array(times: str):
res = [0, 0]
start_end = times.split()
hour_min = startEnd[0].split(':')
res[0] = int(hourMin[0]) * 60 + int(hourMin[1])
hour_min = startEnd[1].split(':')
res[1] = int(hourMin[0]) * 60 + int(hourMin[1])
return res
max_mins = 1500
n = int(input())
table = [0]... |
# For the central discovery server
LOG_FILE = 'discovered.pkl'
DISCOVERY_PORT = 4444
MESSAGING_PORT = 8192
PROMPT_FILE = 'prompt'
SHARED_FOLDER = 'shared'
DOWNLOAD_FOLDER = 'download'
CHUNK_SIZE = 1000000 | log_file = 'discovered.pkl'
discovery_port = 4444
messaging_port = 8192
prompt_file = 'prompt'
shared_folder = 'shared'
download_folder = 'download'
chunk_size = 1000000 |
class FindImage:
def __init__(self, image_repo):
self.image_repo = image_repo
def by_ayah_id(self, ayah_id):
return self.image_repo.find_by_ayah_id(ayah_id) | class Findimage:
def __init__(self, image_repo):
self.image_repo = image_repo
def by_ayah_id(self, ayah_id):
return self.image_repo.find_by_ayah_id(ayah_id) |
# To review... adding up the lengths of strings in a list
# e.g. totalLength(["UCSB","Apple","Pie"]) should be: 12
# because len("UCSB")=4, len("Apple")=5, and len("Pie")=3, and 4+5+3 = 12
def totalLength(listOfStrings):
" add up length of all the strings "
# for now, ignore errors.. assume they are all of ... | def total_length(listOfStrings):
""" add up length of all the strings """
count = 0
for string in listOfStrings:
count = count + len(string)
return count
def test_total_length_1():
assert total_length(['UCSB', 'Apple', 'Pie']) == 12
def test_total_length_2():
assert total_length([]) ==... |
T = int(input(''))
X = 0
Y = 0
for i in range(T):
B = int(input(''))
A1, D1, L1 = map(int, input().split())
A2, D2, L2 = map(int, input().split())
X = (A1 + D1) / 2
if L1 % 2 == 0:
X = X + L1
Y = (A2 + D2) / 2
if L2 % 2 == 0:
Y = Y + L1
if X == Y:
print('Empate')
... | t = int(input(''))
x = 0
y = 0
for i in range(T):
b = int(input(''))
(a1, d1, l1) = map(int, input().split())
(a2, d2, l2) = map(int, input().split())
x = (A1 + D1) / 2
if L1 % 2 == 0:
x = X + L1
y = (A2 + D2) / 2
if L2 % 2 == 0:
y = Y + L1
if X == Y:
print('Empat... |
class Solution:
def XXX(self, n: int) -> str:
ans = '1#'
for i in range(1, n):
t, cnt = '', 1
for j in range(1, len(ans)):
if ans[j] == ans[j - 1]:
cnt += 1
else:
t += (str(cnt) + ans[j - 1])
... | class Solution:
def xxx(self, n: int) -> str:
ans = '1#'
for i in range(1, n):
(t, cnt) = ('', 1)
for j in range(1, len(ans)):
if ans[j] == ans[j - 1]:
cnt += 1
else:
t += str(cnt) + ans[j - 1]
... |
# This kata was seen in programming competitions with a wide range of variations. A strict bouncy array of numbers, of
# length three or longer, is an array that each term (neither the first nor the last element) is strictly higher or lower
# than its neighbours.
# For example, the array:
# arr = [7,9,6,10,5,11,10,12,... | def longest_bouncy_list(arr):
bounce = ''
count = 0
value = []
depths = [[] for i in range(4)]
if arr[1:] == arr[:-1]:
return [arr[0]]
if arr[0] < arr[1]:
bounce = 'low'
elif arr[0] > arr[1]:
bounce = 'high'
for (x, y) in zip(arr[:], arr[1:]):
current_dept... |
DEFAULTS = {
'label': "{win[title]}",
'label_alt': "[class_name='{win[class_name]}' exe='{win[process][name]}' hwnd={win[hwnd]}]",
'label_no_window': None,
'max_length': None,
'max_length_ellipsis': '...',
'monitor_exclusive': True,
'ignore_windows': {
'classes': [],
'process... | defaults = {'label': '{win[title]}', 'label_alt': "[class_name='{win[class_name]}' exe='{win[process][name]}' hwnd={win[hwnd]}]", 'label_no_window': None, 'max_length': None, 'max_length_ellipsis': '...', 'monitor_exclusive': True, 'ignore_windows': {'classes': [], 'processes': [], 'titles': []}, 'callbacks': {'on_left... |
#!python3
class Error(Exception):
pass
class IncompatibleArgumentError(Error):
pass
class DataShapeError(Error):
pass | class Error(Exception):
pass
class Incompatibleargumenterror(Error):
pass
class Datashapeerror(Error):
pass |
x = 9
def f(x):
return x
| x = 9
def f(x):
return x |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def findTilt(self, root: TreeNode) -> int:
tilt = [0]
def dfs(node):
if node is... | class Solution:
def find_tilt(self, root: TreeNode) -> int:
tilt = [0]
def dfs(node):
if node is None:
return 0
left = dfs(node.left)
right = dfs(node.right)
tilt[0] += abs(left - right)
return left + right + node.val
... |
def test_filtering_sequential_blocks_with_bounded_range(
w3,
emitter,
Emitter,
wait_for_transaction):
builder = emitter.events.LogNoArguments.build_filter()
builder.fromBlock = "latest"
initial_block_number = w3.eth.block_number
builder.toBlock = initial_block_number ... | def test_filtering_sequential_blocks_with_bounded_range(w3, emitter, Emitter, wait_for_transaction):
builder = emitter.events.LogNoArguments.build_filter()
builder.fromBlock = 'latest'
initial_block_number = w3.eth.block_number
builder.toBlock = initial_block_number + 100
filter_ = builder.deploy(w3... |
num_acc=int(input())
accounts={}
for i in range(num_acc):
p,b = input().split()
accounts[p] = int(b)
#print (accounts)
num_t=int(input())
trans=[]
for i in range(num_t):
pf,pt,c,t = input().split()
trans.append((int(t),pf,pt,int(c)))
trans = sorted(trans)
for i in trans:
accounts[i[1]]-=i[3]
accounts[i[2]]+=i[3]... | num_acc = int(input())
accounts = {}
for i in range(num_acc):
(p, b) = input().split()
accounts[p] = int(b)
num_t = int(input())
trans = []
for i in range(num_t):
(pf, pt, c, t) = input().split()
trans.append((int(t), pf, pt, int(c)))
trans = sorted(trans)
for i in trans:
accounts[i[1]] -= i[3]
... |
count = 1
def show_title(msg):
global count
print('\n')
print('#' * 30)
print(count, '.', msg)
print('#' * 30)
count += 1
| count = 1
def show_title(msg):
global count
print('\n')
print('#' * 30)
print(count, '.', msg)
print('#' * 30)
count += 1 |
# result = 5/3
# if result:
data = ['asdf', '123', 'Aa']
names = ['asdf', '123', 'Aa']
# builtin functions that operate on sequences
# zip
# max
# min
# sum
sum([1, 2, 3])
# generator expressions
print(sum(len(x) for x in data))
# all
# any
print(all(len(x) > 2 for x in data))
print(any(len(... | data = ['asdf', '123', 'Aa']
names = ['asdf', '123', 'Aa']
sum([1, 2, 3])
print(sum((len(x) for x in data)))
print(all((len(x) > 2 for x in data)))
print(any((len(x) > 2 for x in data)))
for x in reversed(data):
pass
get_len = lambda x: len(x)
def get_length(x):
return len(x)
def get_second_item(x):
retur... |
__copyright__ = "2015 Cisco Systems, Inc."
# Define your areas here. you can add or remove area in areas_container
areas_container = [
{
"areaId": "area1",
"areaName": "Area Name 1",
"dimension": {
"length": 100,
"offsetX": 0,
"offsetY": 0,
"u... | __copyright__ = '2015 Cisco Systems, Inc.'
areas_container = [{'areaId': 'area1', 'areaName': 'Area Name 1', 'dimension': {'length': 100, 'offsetX': 0, 'offsetY': 0, 'unit': 'FEET', 'width': 100}, 'floorRefId': '723402329507758200'}, {'areaId': 'area2', 'areaName': 'Area Name 2', 'dimension': {'length': 500, 'offsetX':... |
Errors = {
400: "BAD_REQUEST_BODY",
401: "UNAUTHORIZED",
403: "ACCESS_DENIED",
404: "NotFoundError",
406: "NotAcceptableError",
409: "ConflictError",
415: "UnsupportedMediaTypeError",
422: "UnprocessableEntityError",
429: "TooManyRequestsError",
... | errors = {400: 'BAD_REQUEST_BODY', 401: 'UNAUTHORIZED', 403: 'ACCESS_DENIED', 404: 'NotFoundError', 406: 'NotAcceptableError', 409: 'ConflictError', 415: 'UnsupportedMediaTypeError', 422: 'UnprocessableEntityError', 429: 'TooManyRequestsError', 500: 'API_CONFIGURATION_ERROR', 502: 'BadGatewayError', 503: 'ServiceUnavai... |
response = {"username": "username", "password": "pass"}
db = list()
def add_user(user_obj):
password = response.get("password")
if len(password) < 5:
return "Password is shorter than 5 characters."
else:
db.append(user_obj)
return "User has been added."
print(add_user(response))
... | response = {'username': 'username', 'password': 'pass'}
db = list()
def add_user(user_obj):
password = response.get('password')
if len(password) < 5:
return 'Password is shorter than 5 characters.'
else:
db.append(user_obj)
return 'User has been added.'
print(add_user(response))
pri... |
#errorcodes.py
#version 2.0.6
errorList = ["no error",
"error code 1",
"mrBayes.py: Could not open quartets file",
"mrBayes.py: Could not interpret quartets file",
"mrBayes.py: Could not open translate file",
"mrBayes.py: Could not interpret translate fi... | error_list = ['no error', 'error code 1', 'mrBayes.py: Could not open quartets file', 'mrBayes.py: Could not interpret quartets file', 'mrBayes.py: Could not open translate file', 'mrBayes.py: Could not interpret translate file', 'mrBayes.py: Could not interpret condor job name', 'mrBayes.py: Could not find tarfile', '... |
size_matrix = int(input())
matrix = []
pls = []
for i in range(size_matrix):
matrix.append([x for x in input()])
for row in range(size_matrix):
for col in range(size_matrix):
if matrix[row][col] == 'B':
pls.append((row, col))
count_food = 0
for row in range(size_matrix):
for col in r... | size_matrix = int(input())
matrix = []
pls = []
for i in range(size_matrix):
matrix.append([x for x in input()])
for row in range(size_matrix):
for col in range(size_matrix):
if matrix[row][col] == 'B':
pls.append((row, col))
count_food = 0
for row in range(size_matrix):
for col in range... |
+ utility('transmissionMgmt',50)
+ requiresFunction('transmissionMgmt','transmissionF')
+ utility('transmissionF',100)
+ requiresFunction('transmissionF','opcF')
+ implements('opcF','opc',0)
+ consumesData('transmissionMgmt','engineerWorkstation','statusRestData',False,0,True,1,True,0.5)
#Allocation/Deployments
+isTyp... | +utility('transmissionMgmt', 50)
+requires_function('transmissionMgmt', 'transmissionF')
+utility('transmissionF', 100)
+requires_function('transmissionF', 'opcF')
+implements('opcF', 'opc', 0)
+consumes_data('transmissionMgmt', 'engineerWorkstation', 'statusRestData', False, 0, True, 1, True, 0.5)
+is_type('opc', 'ser... |
class AsyncSerialPy3Mixin:
async def read_exactly(self, n):
data = bytearray()
while len(data) < n:
remaining = n - len(data)
data += await self.read(remaining)
return data
async def write_exactly(self, data):
while data:
res = await self.writ... | class Asyncserialpy3Mixin:
async def read_exactly(self, n):
data = bytearray()
while len(data) < n:
remaining = n - len(data)
data += await self.read(remaining)
return data
async def write_exactly(self, data):
while data:
res = await self.wri... |
def test_clear_group(app):
while 0 != app.group.count_groups():
app.group.delete_first_group()
else:
print("Group list is already empty")
| def test_clear_group(app):
while 0 != app.group.count_groups():
app.group.delete_first_group()
else:
print('Group list is already empty') |
def attritems(class_):
def _getitem(self, key):
return getattr(self, key)
setattr(class_, '__getitem__', _getitem)
if getattr(class_, '__setitem__', None):
delattr(class_, '__setitem__')
if getattr(class_, '__delitem__', None):
delattr(class_, '__delitem__')
return class_... | def attritems(class_):
def _getitem(self, key):
return getattr(self, key)
setattr(class_, '__getitem__', _getitem)
if getattr(class_, '__setitem__', None):
delattr(class_, '__setitem__')
if getattr(class_, '__delitem__', None):
delattr(class_, '__delitem__')
return class_
@... |
BINGO_BOARD_LENGTH = 5
class BingoField:
def __init__(self, number):
self.number = number
self.marked = False
class BingoBoard:
def __init__(self, numbers: list):
self.board = [[], [], [], [], []]
self.already_won = False
for row_idx, _ in enumerate(numbers):
... | bingo_board_length = 5
class Bingofield:
def __init__(self, number):
self.number = number
self.marked = False
class Bingoboard:
def __init__(self, numbers: list):
self.board = [[], [], [], [], []]
self.already_won = False
for (row_idx, _) in enumerate(numbers):
... |
x=input('first number?')
y=input('second number?')
outcome=int(x)*int(y)
print (outcome)
| x = input('first number?')
y = input('second number?')
outcome = int(x) * int(y)
print(outcome) |
# -*- coding: utf-8 -*-
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# ... | """
ui_utils.py
Some UI utility functions
"""
class Gui:
@classmethod
def draw_icon_button(cls, enabled, layout, iconName, operator, frame=True):
col = layout.column()
col.enabled = enabled
bt = col.operator(operator, text='', icon=iconName, emboss=frame)
@clas... |
'''
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.
Implement KthLargest class:
KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.
int add(int val) Appends the i... | """
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.
Implement KthLargest class:
KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.
int add(int val) Appends the i... |
# Challenge 9 : Write a function named same_values() that takes two lists of numbers of equal size as parameters.
# The function should return a list of the indices where the values were equal in lst1 and lst2.
# Date : Sun 07 Jun 2020 09:28:38 AM IST
def same_values(lst1, lst2):
newList = []
... | def same_values(lst1, lst2):
new_list = []
for i in range(len(lst1)):
if lst1[i] == lst2[i]:
newList.append(i)
return newList
print(same_values([5, 1, -10, 3, 3], [5, 10, -10, 3, 5])) |
def info(a):
a = raw_input("type your height here: ")
return a
| def info(a):
a = raw_input('type your height here: ')
return a |
def strategy(history, memory):
if memory is None:
memory = (0, 0)
defections = memory[0]
count = memory[1]
choice = 1
if count > 0:
if count < defections:
choice = 0
count += 1
elif count == defections:
count += 1
elif count > defections:
count = 0
elif history.shape[1] >= 1 an... | def strategy(history, memory):
if memory is None:
memory = (0, 0)
defections = memory[0]
count = memory[1]
choice = 1
if count > 0:
if count < defections:
choice = 0
count += 1
elif count == defections:
count += 1
elif count > defec... |
def get_2(digits, one, seven, four):
for digit in digits:
if len(digit - one - seven - four) == 2:
return digit
assert False, f"2 cannot be calculated from {digits=} using {one=}, {seven=} and {four=}"
def get_3(digits, two):
for digit in digits:
if len(digit - two) == 1:
... | def get_2(digits, one, seven, four):
for digit in digits:
if len(digit - one - seven - four) == 2:
return digit
assert False, f'2 cannot be calculated from digits={digits!r} using one={one!r}, seven={seven!r} and four={four!r}'
def get_3(digits, two):
for digit in digits:
if len... |
# Firstly, get the flatfile from the user.
def getFile():
file_path = input("Input the path to the flat file: ")
try:
keypath = open(file_path, "r")
return keypath
except:
print("No file found there.")
# Secondly, iterate through the file and update a state dictionary containing str... | def get_file():
file_path = input('Input the path to the flat file: ')
try:
keypath = open(file_path, 'r')
return keypath
except:
print('No file found there.')
def analyze_file(file):
state_dict = {'string_state': '', 'grid_state': [0, 0]}
nav_grid = [['A', 'B', 'C', 'D', 'E... |
#
# @lc app=leetcode id=83 lang=python3
#
# [83] Remove Duplicates from Sorted List
#
# https://leetcode.com/problems/remove-duplicates-from-sorted-list/description/
#
# algorithms
# Easy (41.95%)
# Likes: 774
# Dislikes: 82
# Total Accepted: 333.1K
# Total Submissions: 779.9K
# Testcase Example: '[... | class Solution:
def delete_duplicates(self, head: ListNode) -> ListNode:
if not head:
return head
(p, q) = (head, head.next)
while q:
if p.val == q.val:
p.next = q.next
q = q.next
else:
p = p.next
re... |
def high_and_low(numbers):
numbers = list((max(map(int,numbers.split())),min(map(int,numbers.split()))))
return ' '.join(map(str,numbers))
def high_and_lowB(numbers):
nn = [int(s) for s in numbers.split(" ")]
return "%i %i" % (max(nn),min(nn)) | def high_and_low(numbers):
numbers = list((max(map(int, numbers.split())), min(map(int, numbers.split()))))
return ' '.join(map(str, numbers))
def high_and_low_b(numbers):
nn = [int(s) for s in numbers.split(' ')]
return '%i %i' % (max(nn), min(nn)) |
grid = [['.', '.', '.', '.', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['O', 'O', 'O', 'O', 'O', '.'],
['.', 'O', 'O', 'O', 'O', 'O'],
['O', 'O', 'O', 'O', 'O', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
... | grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 'O', '.'], ['.', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]
def grid_output(grid):
... |
t = int(input())
for i in range(t):
b,c=map(int,input().split())
ans = (2*b-c-1)//2
print(2*ans)
| t = int(input())
for i in range(t):
(b, c) = map(int, input().split())
ans = (2 * b - c - 1) // 2
print(2 * ans) |
def moveZeroes(nums):
lastNonZero = 0
for i in range(len(nums)):
if nums[i] != 0:
nums[lastNonZero], nums[i] = nums[i], nums[lastNonZero]
lastNonZero += 1
nums = [0, 1, 0, 3, 12]
moveZeroes(nums)
print(nums) # [1, 3, 12, 0, 0]
nums = [4, 2, 4, 0, 0, 3, 0, 5, 1, 0]
moveZeroes(nu... | def move_zeroes(nums):
last_non_zero = 0
for i in range(len(nums)):
if nums[i] != 0:
(nums[lastNonZero], nums[i]) = (nums[i], nums[lastNonZero])
last_non_zero += 1
nums = [0, 1, 0, 3, 12]
move_zeroes(nums)
print(nums)
nums = [4, 2, 4, 0, 0, 3, 0, 5, 1, 0]
move_zeroes(nums)
print(... |
def move(n, a, b, c):
if n == 1:
print(str(a) + " " + str(c))
else:
move(n - 1, a, c, b)
print(str(a) + " " + str(c))
move(n - 1, b, a, c)
def Num11729():
n = int(input())
print(2 ** n -1)
move(n, 1, 2, 3)
Num11729()
| def move(n, a, b, c):
if n == 1:
print(str(a) + ' ' + str(c))
else:
move(n - 1, a, c, b)
print(str(a) + ' ' + str(c))
move(n - 1, b, a, c)
def num11729():
n = int(input())
print(2 ** n - 1)
move(n, 1, 2, 3)
num11729() |
def get_synset(path='../data/imagenet_synset_words.txt'):
with open(path, 'r') as f:
# Strip off the first word (until space, maxsplit=1), then synset is remainder
return [ line.strip().split(' ', 1)[1] for line in f]
| def get_synset(path='../data/imagenet_synset_words.txt'):
with open(path, 'r') as f:
return [line.strip().split(' ', 1)[1] for line in f] |
class Deque:
def __init__(self):
self.deque =[]
def addFront(self,element):
self.deque.append(element)
print("After adding from front the deque value is : ", self.deque)
def addRear(self,element):
self.deque.insert(0,element)
print("After adding from end t... | class Deque:
def __init__(self):
self.deque = []
def add_front(self, element):
self.deque.append(element)
print('After adding from front the deque value is : ', self.deque)
def add_rear(self, element):
self.deque.insert(0, element)
print('After adding from end the ... |
things = [
'An old Box',
'Ancient Knife',
'Oppenheimer Blue Diamond',
'1962 Ferrari 250 GTO Berlinetta',
'Hindoostan Antique Map 1826',
'Rare 19th C. Mughal Indian ZANGHAL Axe with Strong',
'1850 $5 Baldwin Gold Half Eagle UNCIRCULATED',
'Chevrolet Corvette 1963'
]
| things = ['An old Box', 'Ancient Knife', 'Oppenheimer Blue Diamond', '1962 Ferrari 250 GTO Berlinetta', 'Hindoostan Antique Map 1826', 'Rare 19th C. Mughal Indian ZANGHAL Axe with Strong', '1850 $5 Baldwin Gold Half Eagle UNCIRCULATED', 'Chevrolet Corvette 1963'] |
x,y=0,0
for i in range(5):
b=input("").split()
for j in range(5):
if(b[j]=='1'):
x=i+1
y=j+1
x=x-3;
y=y-3;
if(x<0):
x=-x
if(y<0):
y=-y
print(x+y)
a=[[],[],[]]
b=len(a[1])//2
a[b][b],a[i][j]=a[i][j],a[b][b]
a=tan(3.33) | (x, y) = (0, 0)
for i in range(5):
b = input('').split()
for j in range(5):
if b[j] == '1':
x = i + 1
y = j + 1
x = x - 3
y = y - 3
if x < 0:
x = -x
if y < 0:
y = -y
print(x + y)
a = [[], [], []]
b = len(a[1]) // 2
(a[b][b], a[i][j]) = (a[i][j], a[b][b])
a = tan(3.33) |
class Salary:
def __init__(self, pay):
self._pay = pay
def get_total(self):
return (self._pay * 12) // 4.9545
class SalarySenior:
def __init__(self, pay):
self._pay = pay
def get_total(self):
return (self._pay * 24) // 4.9545
class Employee:
def __init__(self, p... | class Salary:
def __init__(self, pay):
self._pay = pay
def get_total(self):
return self._pay * 12 // 4.9545
class Salarysenior:
def __init__(self, pay):
self._pay = pay
def get_total(self):
return self._pay * 24 // 4.9545
class Employee:
def __init__(self, pay,... |
changes = {'.': 0, ',': 1, '+': 2, '-': 3, '>':4, '<': 5, '[': 6, ']': 7}
def convert(code):
current = 0
x = ""
for i in code:
dest = changes.get(i)
if dest is None:
continue
diff = (dest - current) % 8
x += "+" * diff + "!"
current = dest
print(cu... | changes = {'.': 0, ',': 1, '+': 2, '-': 3, '>': 4, '<': 5, '[': 6, ']': 7}
def convert(code):
current = 0
x = ''
for i in code:
dest = changes.get(i)
if dest is None:
continue
diff = (dest - current) % 8
x += '+' * diff + '!'
current = dest
print(... |
{'application':{'type':'Application',
'name':'webgrabber',
'backgrounds': [
{'type':'Background',
'name':'bgGrabber',
'title':'webgrabber PythonCard Application',
'size':(540, 172),
'statusBar':1,
'menubar': {'type':'MenuBar',
'menus': [
... | {'application': {'type': 'Application', 'name': 'webgrabber', 'backgrounds': [{'type': 'Background', 'name': 'bgGrabber', 'title': 'webgrabber PythonCard Application', 'size': (540, 172), 'statusBar': 1, 'menubar': {'type': 'MenuBar', 'menus': [{'type': 'Menu', 'name': 'menuFile', 'label': '&File', 'items': [{'type': '... |
# ------------------------------------------------------------------------------------
# Tutorial: The replace method replaces a specified string with another specified string.
# ------------------------------------------------------------------------------------
# Example 1.
# Replace all occurences of "dog" with "ca... | dog_txt = "I always wanted a dog! My dog is awsome :) My dog's name is Taco"
cat_txt = dog_txt.replace('dog', 'cat')
print('\nExample 1. - Replace all occurences of "dog" with "cat"')
print(f'Old String: {dog_txt}')
print(f'New String: {cat_txt}')
dog_txt = "I always wanted a dog! My dog is awsome :) My dog's name is T... |
is_day = False
lights_on = not is_day
print("Daytime?")
print(is_day)
print("Lights on?")
print(lights_on) | is_day = False
lights_on = not is_day
print('Daytime?')
print(is_day)
print('Lights on?')
print(lights_on) |
def insertionSort(arr):
output = arr[:]
#go through each element
for index in range(1, len(output)):
#grab current element
current = output[index]
#get last index of sorted output
j = index
#shift up all sorted elements that are greater than current one
whi... | def insertion_sort(arr):
output = arr[:]
for index in range(1, len(output)):
current = output[index]
j = index
while j > 0 and output[j - 1] > current:
output[j] = output[j - 1]
j = j - 1
output[j] = current
return output |
SCHEMA_URL = "https://raw.githubusercontent.com/vz-risk/veris/master/verisc-merged.json"
VARIETY_AMT_ENUMS = ['asset.assets', 'attribute.confidentiality.data', 'impact.loss']
VARIETY_AMT = ['variety', 'amount']
ASSETMAP = {'S ' : 'Server', 'N ' : 'Network', 'U ' : 'User Dev', 'M ' : 'Media',
'P ' : 'Person'... | schema_url = 'https://raw.githubusercontent.com/vz-risk/veris/master/verisc-merged.json'
variety_amt_enums = ['asset.assets', 'attribute.confidentiality.data', 'impact.loss']
variety_amt = ['variety', 'amount']
assetmap = {'S ': 'Server', 'N ': 'Network', 'U ': 'User Dev', 'M ': 'Media', 'P ': 'Person', 'T ': 'Kiosk/Te... |
N = int(input())
ans = min(9, N) + max(0, min(999, N) - 99) + max(0, min(99999, N) - 9999)
print(ans)
| n = int(input())
ans = min(9, N) + max(0, min(999, N) - 99) + max(0, min(99999, N) - 9999)
print(ans) |
'''
done
'''
def Jumlah(a, b):
return a + b
print(Jumlah(2, 8)) | """
done
"""
def jumlah(a, b):
return a + b
print(jumlah(2, 8)) |
greetings = ["hello", "world", "Jenn"]
for greeting in greetings:
print(f"{greeting}, World")
def add_number(x, y):
return x + y
add_number(1, 2)
things_to_do = ["pickup meds", "shower", "change bandage", "python", "brush Baby and pack dogs", "Whole Foods", "Jocelyn"] | greetings = ['hello', 'world', 'Jenn']
for greeting in greetings:
print(f'{greeting}, World')
def add_number(x, y):
return x + y
add_number(1, 2)
things_to_do = ['pickup meds', 'shower', 'change bandage', 'python', 'brush Baby and pack dogs', 'Whole Foods', 'Jocelyn'] |
class Solution:
#Function to convert a binary tree into its mirror tree.
def mirror(self,root):
# Code here
if(root == None):
return
else:
self.mirror(root.left)
self.mirror(root.right)
root.left, root.right = root.right, root.... | class Solution:
def mirror(self, root):
if root == None:
return
else:
self.mirror(root.left)
self.mirror(root.right)
(root.left, root.right) = (root.right, root.left) |
## robot_servant.py
## This code implements a search space model for a robot
## that can move around a house and pick up and put down
## objects.
## The function calls provided for a general search algorithm are:
## robot_print_problem_info()
## robot_initial_state
## robot_possible_actions(state)
## robot_successor... | print('Loading robot_servant.py')
robot_goal = 'undefined'
def robot_initialise_1():
global permanent_facts, initial_state, ROBOT_GOAL
permanent_facts = robot_permanent_facts_1
initial_state = robot_initial_state_1
robot_goal = robot_goal_1
robot_permanent_facts_1 = [('connected', 'kitchen', 'garage', ... |
# [Root Abyss] The World Girl
MYSTERIOUS_GIRL = 1064001 # npc Id
sm.removeEscapeButton()
sm.lockInGameUI(True)
sm.setPlayerAsSpeaker()
sm.sendNext("If you're really the World Tree, can't you just like... magic yourself outta here?")
sm.setSpeakerID(MYSTERIOUS_GIRL)
sm.sendNext("No! Those bad people did this to me!")
... | mysterious_girl = 1064001
sm.removeEscapeButton()
sm.lockInGameUI(True)
sm.setPlayerAsSpeaker()
sm.sendNext("If you're really the World Tree, can't you just like... magic yourself outta here?")
sm.setSpeakerID(MYSTERIOUS_GIRL)
sm.sendNext('No! Those bad people did this to me!')
sm.setPlayerAsSpeaker()
sm.sendNext('Oh, ... |
#!usr/bin/python
# -*- coding:utf8 -*-
class MyException(Exception):
pass
try:
raise MyException('my exception')
# exception MyException as e:
except Exception as e:
print(e) | class Myexception(Exception):
pass
try:
raise my_exception('my exception')
except Exception as e:
print(e) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.