content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class InfiniteLineup:
def __init__(self, players):
self.players = players
def lineup(self):
lineup_max = len(self.players)
idx = 0
while True:
if idx < lineup_max:
yield self.players[idx]
else:
idx = 0
... | class Infinitelineup:
def __init__(self, players):
self.players = players
def lineup(self):
lineup_max = len(self.players)
idx = 0
while True:
if idx < lineup_max:
yield self.players[idx]
else:
idx = 0
yiel... |
class StoreObject:
def _log_template(self, token):
return f"<{token.server.upper()} {token.method}: {' '.join([str(token.params[k]) for k in token.params])}>"
async def get(self, token, *args, **kwargs):
raise NotImplementedError
async def set(self, token, response, *args, **kwargs):
... | class Storeobject:
def _log_template(self, token):
return f"<{token.server.upper()} {token.method}: {' '.join([str(token.params[k]) for k in token.params])}>"
async def get(self, token, *args, **kwargs):
raise NotImplementedError
async def set(self, token, response, *args, **kwargs):
... |
a = 10
b = 22
while b - a > 4:
c = b - (2 * a)
if c > 0:
d = c + 1
else:
d = c + 5
a = a + 3
b = b - 2
| a = 10
b = 22
while b - a > 4:
c = b - 2 * a
if c > 0:
d = c + 1
else:
d = c + 5
a = a + 3
b = b - 2 |
# HEAD
# Destructing or Multiple Assignment Operators
# DESCRIPTION
# Describe incorrect usage of
# multiple assignation which throws error
# RESOURCES
#
# The number of items in the destructuring
# have to be the same as variables used for assignation
cat = ['fat', 'orange', 'loud']
# Will give an err... | cat = ['fat', 'orange', 'loud']
(size, color, disposition, name) = cat |
pkg_dnf = {
'bind-utils': {},
'bzip2': {},
'coreutils': {},
'curl': {},
'diffutils': {},
'file': {},
'gcc': {},
'gcc-c++': {},
'git': {},
'grep': {},
'gzip': {},
'hexedit': {},
'hostname': {},
'iotop': {},
'iputils': {},
'less': {},
'lsof': {},
'ly... | pkg_dnf = {'bind-utils': {}, 'bzip2': {}, 'coreutils': {}, 'curl': {}, 'diffutils': {}, 'file': {}, 'gcc': {}, 'gcc-c++': {}, 'git': {}, 'grep': {}, 'gzip': {}, 'hexedit': {}, 'hostname': {}, 'iotop': {}, 'iputils': {}, 'less': {}, 'lsof': {}, 'lynx': {}, 'man-db': {}, 'mlocate': {}, 'ncdu': {}, 'net-tools': {}, 'nmap'... |
# A - Set Lot Charge, Piece Price, Added Lead Time variables
lot_charge = var('Lot Charge', 0, 'Lot charge for outside_service service', currency)
piece_price = var('Piece Price', 0, 'Price per unit for the outside_service service', currency)
added_lead_time = var('Added Lead Time', 0, 'Days of added lead time for outs... | lot_charge = var('Lot Charge', 0, 'Lot charge for outside_service service', currency)
piece_price = var('Piece Price', 0, 'Price per unit for the outside_service service', currency)
added_lead_time = var('Added Lead Time', 0, 'Days of added lead time for outside_service service', number)
extended_price = part.qty * pie... |
#
# PySNMP MIB module ZHONE-GEN-VOICESTAT (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHONE-GEN-VOICESTAT
# Produced by pysmi-0.3.4 at Wed May 1 15:47:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) ... |
'''https://practice.geeksforgeeks.org/problems/common-elements1132/1
Common elements
Easy Accuracy: 38.69% Submissions: 81306 Points: 2
Given three arrays sorted in increasing order. Find the elements that are common in all three arrays.
Note: can you take care of the duplicates without using any additional Data Struc... | """https://practice.geeksforgeeks.org/problems/common-elements1132/1
Common elements
Easy Accuracy: 38.69% Submissions: 81306 Points: 2
Given three arrays sorted in increasing order. Find the elements that are common in all three arrays.
Note: can you take care of the duplicates without using any additional Data Struc... |
# the follow code is for key handover
KEY_ACCEPTED = 1
KEY_NOT_ACCEPTED = 0
KEY_DESTINATION = 0
KEY_ESTATE = 1
KEY_ILOCK = 2
KEY_OTHER = 3
# the follow code is for note
NOTE_USED = 1
NOTE_DISCARDED = 0
NOTE_TYPE_HOME = 0
NOTE_TYPE_OFFER = 1
NOTE_TYPE_USER = 2
# the follow code is for Utility
UTILITY_USED = 1
UTILI... | key_accepted = 1
key_not_accepted = 0
key_destination = 0
key_estate = 1
key_ilock = 2
key_other = 3
note_used = 1
note_discarded = 0
note_type_home = 0
note_type_offer = 1
note_type_user = 2
utility_used = 1
utility_discarded = 0
is_active_used = 1
is_active_discarded = 0
offer_ready_message = 0
offer_finished_message... |
def mergeSort(lst):
pass
print(mergeSort([2,3,4,5,15,19,26,27,36,38,44,46,47,48,50] )) | def merge_sort(lst):
pass
print(merge_sort([2, 3, 4, 5, 15, 19, 26, 27, 36, 38, 44, 46, 47, 48, 50])) |
def attach_label_operation(label_id: 'Long' = None,
campaign_id: 'Long' = None,
ad_id: 'Long' = None,
ad_group_id: 'Long' = None,
criterion_id: 'Long' = None,
customer_id: 'Long' = None,
operator: 'String' = 'ADD',
... | def attach_label_operation(label_id: 'Long'=None, campaign_id: 'Long'=None, ad_id: 'Long'=None, ad_group_id: 'Long'=None, criterion_id: 'Long'=None, customer_id: 'Long'=None, operator: 'String'='ADD', **kwargs):
operation = {'operator': operator.upper(), 'operand': {'labelId': label_id}}
if customer_id:
... |
# Source : https://leetcode.com/problems/shortest-palindrome/
# Author : henrytine
# Date : 2020-07-23
#####################################################################################################
#
# Given a string s, you are allowed to convert it to a palindrome by adding characters in front of
# it. Fin... | class Solution:
def shortest_palindrome(self, s: str) -> str:
r = s[::-1]
for i in range(len(s) + 1):
if s.startswith(r[i:]):
return r[:i] + s |
def update_parameters(parameters, gradients, lr, batch_size, a):
parameters["Wax"] = parameters["Wax"] - (lr/batch_size) * gradients["dWax"]
parameters["Waa"] = parameters["Waa"] - (lr / batch_size) * gradients["dWaa"]
parameters["ba"] = parameters["ba"] - (lr / batch_size) * gradients["dba"]
if a == ... | def update_parameters(parameters, gradients, lr, batch_size, a):
parameters['Wax'] = parameters['Wax'] - lr / batch_size * gradients['dWax']
parameters['Waa'] = parameters['Waa'] - lr / batch_size * gradients['dWaa']
parameters['ba'] = parameters['ba'] - lr / batch_size * gradients['dba']
if a == 'd':
... |
#!/usr/bin/python3
s='ODITSZAPC'
p='ba9876420'
for comb in range(0, 2**9):
x = comb
i = 0
c = ''
v = 0
while x != 0:
f = x % 2
if f == 1:
c += s[i]
v += 1<<int(p[i], 16)
i += 1
x = int(x/2)
if c == '':
continue
print('Z%s = 0x%... | s = 'ODITSZAPC'
p = 'ba9876420'
for comb in range(0, 2 ** 9):
x = comb
i = 0
c = ''
v = 0
while x != 0:
f = x % 2
if f == 1:
c += s[i]
v += 1 << int(p[i], 16)
i += 1
x = int(x / 2)
if c == '':
continue
print('Z%s = 0x%x' % (c, v... |
MAX_INT8 = 1 << 7 - 1
MIN_INT8 = -1 << 7
MAX_INT16 = 1 << 15 - 1
MIN_INT16 = -1 << 15
MAX_INT32 = 1 << 31 - 1
MIN_INT32 = -1 << 31
MAX_INT64 = 1 << 63 - 1
MIN_INT64 = -1 << 63
MAX_UINT8 = 1 << 8 - 1
MAX_UINT16 = 1 << 16 - 1
MAX_UINT32 = 1 << 32 - 1
MAX_UINT64 = 1 << 64 - 1
| max_int8 = 1 << 7 - 1
min_int8 = -1 << 7
max_int16 = 1 << 15 - 1
min_int16 = -1 << 15
max_int32 = 1 << 31 - 1
min_int32 = -1 << 31
max_int64 = 1 << 63 - 1
min_int64 = -1 << 63
max_uint8 = 1 << 8 - 1
max_uint16 = 1 << 16 - 1
max_uint32 = 1 << 32 - 1
max_uint64 = 1 << 64 - 1 |
# board
# display board
# play game
# handle turn
# check win
# check rows
# check coumns
# check diagonals
# check tie
# flip player
#--------Global Variables------
#Game board
board = ["-","-","-",
"-","-","-",
"-","-","-",]
#if game is still going
game_still_going = True
#Who won? or tie?
win... | board = ['-', '-', '-', '-', '-', '-', '-', '-', '-']
game_still_going = True
winner = None
current_player = 'X'
def display_board():
print(board[0] + ' | ' + board[1] + ' | ' + board[2])
print(board[3] + ' | ' + board[4] + ' | ' + board[5])
print(board[6] + ' | ' + board[7] + ' | ' + board[8])
def play_g... |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(self, l1, l2):
p1=l1
p2=l2
count=0
while p1 and p2:
count+=p1.val
count+=p2.val
... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def add_two_numbers(self, l1, l2):
p1 = l1
p2 = l2
count = 0
while p1 and p2:
count += p1.val
count += p2.val
p1.val = coun... |
height = 6
num = 1
for i in range(height,-height-1,-1):
for j in range(1,abs(i)+1):
print(end=" ")
if(i >= 0) :
num = 1
else:
num = abs(i) + 1;
for j in range(height,abs(i)+1,-1):
print(num,end=" ")
num += 1
print()
# ... | height = 6
num = 1
for i in range(height, -height - 1, -1):
for j in range(1, abs(i) + 1):
print(end=' ')
if i >= 0:
num = 1
else:
num = abs(i) + 1
for j in range(height, abs(i) + 1, -1):
print(num, end=' ')
num += 1
print() |
f1 = 1
f2 = 2
not_a_flag = 3
print("step: 1")
print("stat_1: 0.5")
print("stat_2: 0.6")
print("step: 2")
print("stat_1: 0.7")
print("stat_2: 0.8")
| f1 = 1
f2 = 2
not_a_flag = 3
print('step: 1')
print('stat_1: 0.5')
print('stat_2: 0.6')
print('step: 2')
print('stat_1: 0.7')
print('stat_2: 0.8') |
load("@obazl_rules_ocaml//ocaml:providers.bzl", "OpamConfig", "BuildConfig")
opam_pkg = {
"async": ["v0.12.0"],
"bignum": ["v0.12.0"], # WARNING: depends on zarith which depends on libgmp-dev on local system
"bin_prot": ["v0.12.0"],
"core": ["v0.12.1"],
"core_kernel": ["v0.12.3"],
"digestif": [... | load('@obazl_rules_ocaml//ocaml:providers.bzl', 'OpamConfig', 'BuildConfig')
opam_pkg = {'async': ['v0.12.0'], 'bignum': ['v0.12.0'], 'bin_prot': ['v0.12.0'], 'core': ['v0.12.1'], 'core_kernel': ['v0.12.3'], 'digestif': ['0.9.0'], 'fieldslib': ['v0.12.0'], 'num': ['1.1'], 'ppx_assert': ['v0.12.0', ['ppx_assert.runtime-... |
keyFinancialIncomeStatement = [
# Valuation Measures
"Revenue",
"Total Revenue",
"Cost of Revenue",
]
| key_financial_income_statement = ['Revenue', 'Total Revenue', 'Cost of Revenue'] |
def wordInTarget(word, target):
'''
Can a 'word', be made using letters from 'target'.
'''
targetlist = list(target)
i = 0
while i < len(word):
letter = word[i]
if letter in targetlist:
targetlist.remove(letter)
i += 1
else:
... | def word_in_target(word, target):
"""
Can a 'word', be made using letters from 'target'.
"""
targetlist = list(target)
i = 0
while i < len(word):
letter = word[i]
if letter in targetlist:
targetlist.remove(letter)
i += 1
else:
return Fa... |
N = int(input())
first_word = input()
W = [input() for _ in range(N - 1)]
last = first_word[-1]
word_set = set([first_word])
for w in W:
if w[0] != last or w in word_set:
print("No")
break
word_set.add(w)
last = w[-1]
else:
print("Yes")
| n = int(input())
first_word = input()
w = [input() for _ in range(N - 1)]
last = first_word[-1]
word_set = set([first_word])
for w in W:
if w[0] != last or w in word_set:
print('No')
break
word_set.add(w)
last = w[-1]
else:
print('Yes') |
''' este grupo de numeros tiene un bucle, digamos que hacemos el algoritmo para "x" numero
la sucesion comenzara con (2, 2x, 2, ... , 2, 2x, 2, ...) donde ... es un bucle
entonces cuando 2x aparezca por segunda vez cortamos alli la sucesion y sacamos
el maximo '''
def algoritmo(a):
lista = []
i = 0
cont = 0
xam = ... | """ este grupo de numeros tiene un bucle, digamos que hacemos el algoritmo para "x" numero
la sucesion comenzara con (2, 2x, 2, ... , 2, 2x, 2, ...) donde ... es un bucle
entonces cuando 2x aparezca por segunda vez cortamos alli la sucesion y sacamos
el maximo """
def algoritmo(a):
lista = []
i = 0
cont = ... |
'''> Greater that - True if left operand is greater than the right x > y
< Less that - True if left operand is less than the right x < y
== Equal to - True if both operands are equal x == y
!= Not equal to - True if operands are not equal x != y
>= Greater than or equal to - True if left operand is greater than or equa... | """> Greater that - True if left operand is greater than the right x > y
< Less that - True if left operand is less than the right x < y
== Equal to - True if both operands are equal x == y
!= Not equal to - True if operands are not equal x != y
>= Greater than or equal to - True if left operand is greater than or equa... |
expected_output = {
"vrf": {
"default": {
"address_family": {
"ipv4": {
"instance": {
"65109": {
"areas": {
"0.0.0.8": {
"database": {
... | expected_output = {'vrf': {'default': {'address_family': {'ipv4': {'instance': {'65109': {'areas': {'0.0.0.8': {'database': {'lsa_types': {1: {'lsa_type': 1, 'lsas': {'192.168.165.220': {'adv_router': '192.168.165.220', 'lsa_id': '192.168.165.220', 'ospfv2': {'header': {'adv_router': '192.168.165.220', 'age': 113, 'che... |
{
"variables": {
"major_version": "<!(node -pe 'v=process.versions.node.split(\".\"); v[0];')",
"minor_version": "<!(node -pe 'v=process.versions.node.split(\".\"); v[1];')",
"micro_version": "<!(node -pe 'v=process.versions.node.split(\".\"); v[2];')"
},
"targets": [
{
... | {'variables': {'major_version': '<!(node -pe \'v=process.versions.node.split("."); v[0];\')', 'minor_version': '<!(node -pe \'v=process.versions.node.split("."); v[1];\')', 'micro_version': '<!(node -pe \'v=process.versions.node.split("."); v[2];\')'}, 'targets': [{'target_name': 'poppler', 'sources': ['src/poppler.cc'... |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def levelOrder(self, root: TreeNode):
if not root:
return []
parents = [root]
res = []
while parents:
... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def level_order(self, root: TreeNode):
if not root:
return []
parents = [root]
res = []
while parents:
cur_values = []
... |
def get_stats(data, country_list=None):
country_list = list(country_list)
country_list_slugs = []
country_list_codes = []
error_lst = []
cases = []
new_cases = []
deaths = []
new_deaths = []
recovered = []
new_recovered = []
names = []
codes = []
stats = []
... | def get_stats(data, country_list=None):
country_list = list(country_list)
country_list_slugs = []
country_list_codes = []
error_lst = []
cases = []
new_cases = []
deaths = []
new_deaths = []
recovered = []
new_recovered = []
names = []
codes = []
stats = []
if not... |
class Platform:
def set_nonblocking(self, read_fd):
raise NotImplementedError(
"Non-blocking capture not impelemented on this platform"
)
def apply_workarounds(self):
pass
| class Platform:
def set_nonblocking(self, read_fd):
raise not_implemented_error('Non-blocking capture not impelemented on this platform')
def apply_workarounds(self):
pass |
#request
class DmRequest(object):
__slots__ = ['gatewayobj']
def __init__(self, gatewayobj):
self.gatewayobj = gatewayobj
def DMchannel(self, channel_id):
self.gatewayobj.send({'op':self.gatewayobj.OPCODE.DM_UPDATE,'d':{'channel_id':channel_id}}) | class Dmrequest(object):
__slots__ = ['gatewayobj']
def __init__(self, gatewayobj):
self.gatewayobj = gatewayobj
def d_mchannel(self, channel_id):
self.gatewayobj.send({'op': self.gatewayobj.OPCODE.DM_UPDATE, 'd': {'channel_id': channel_id}}) |
numbers = []
# Going up first (1st digit cannot be 0)
for digit1 in range(1, 10):
for digit2 in range(0, 10):
for digit3 in range(0, 10):
if digit2 > digit1 and digit3 < digit2:
numbers.append(str(digit1) + str(digit2) + str(digit3))
# Going down first
for digit1 in range(1, 10... | numbers = []
for digit1 in range(1, 10):
for digit2 in range(0, 10):
for digit3 in range(0, 10):
if digit2 > digit1 and digit3 < digit2:
numbers.append(str(digit1) + str(digit2) + str(digit3))
for digit1 in range(1, 10):
for digit2 in range(0, 10):
for digit3 in range... |
def MeasureTime( v, t ):
sT = time.process_time( )
leer_matriz(v, t)
triangulo_superior(v, t)
eT = time.process_time( )
return float( eT - sT )
def leer_matriz(v, t):
for i in range (t):
for j in range (t):
print ("Escriba el elemento %u de la columna %u: ", j+1, i+1)
v[i][j] = input()
for... | def measure_time(v, t):
s_t = time.process_time()
leer_matriz(v, t)
triangulo_superior(v, t)
e_t = time.process_time()
return float(eT - sT)
def leer_matriz(v, t):
for i in range(t):
for j in range(t):
print('Escriba el elemento %u de la columna %u: ', j + 1, i + 1)
... |
a = 'In this letter I make some remarks on a general principle relevant to enciphering in general and my machine.'
b = 'If qualified opinions incline to believe in the exponential conjecture, then I think we cannot afford not to make use of it.'
c = 'The most direct computation would be for the enemy to try all 2^r pos... | a = 'In this letter I make some remarks on a general principle relevant to enciphering in general and my machine.'
b = 'If qualified opinions incline to believe in the exponential conjecture, then I think we cannot afford not to make use of it.'
c = 'The most direct computation would be for the enemy to try all 2^r pos... |
weight=1
def run():
r.absrot(90)
r.absrot(0)
r.absrot(-90)
r.absrot(90)
| weight = 1
def run():
r.absrot(90)
r.absrot(0)
r.absrot(-90)
r.absrot(90) |
__author__ = 'Aaron Yang'
__email__ = 'byang971@usc.edu'
__date__ = '8/14/2020 6:00 PM'
class Solution:
def __init__(self):
self.data = ['1', '11', '21', '1211', '111221']
def read(self, string):
pre = string[0]
count = 1
res = []
for val in string[1:]:
if... | __author__ = 'Aaron Yang'
__email__ = 'byang971@usc.edu'
__date__ = '8/14/2020 6:00 PM'
class Solution:
def __init__(self):
self.data = ['1', '11', '21', '1211', '111221']
def read(self, string):
pre = string[0]
count = 1
res = []
for val in string[1:]:
if ... |
# Sorting
## Sorting with keys
airports = [
('MROC', 'San Jose, CR'),
('KLAS', 'Las Vegas, USA'),
('EDDM', 'Munich, DE'),
('LSZH', 'Zurich, CH'),
('VNLK', 'Lukla, NEP')
]
sorted_airports = dict(sorted(airports, key=lambda x:x[0]))
print(sorted_airports) | airports = [('MROC', 'San Jose, CR'), ('KLAS', 'Las Vegas, USA'), ('EDDM', 'Munich, DE'), ('LSZH', 'Zurich, CH'), ('VNLK', 'Lukla, NEP')]
sorted_airports = dict(sorted(airports, key=lambda x: x[0]))
print(sorted_airports) |
# Create Trend Filter to remove linear, annual, and semi-annual trend
fl_tf = skdiscovery.data_structure.table.filters.TrendFilter('TrendFilter', [])
# Create stage container for the trend filter
sc_tf = StageContainer(fl_tf)
| fl_tf = skdiscovery.data_structure.table.filters.TrendFilter('TrendFilter', [])
sc_tf = stage_container(fl_tf) |
# encode categorical protocol name to number
def encode_protocol(text):
# put frequent cases to the front
if 'tcp' in text:
return 6
elif 'udp' in text:
return 17
elif 'icmp' in text:
return 1
elif 'hopopt' in text:
return 0
elif 'igmp' in text:
return 2
elif 'ggp' in text:
return ... | def encode_protocol(text):
if 'tcp' in text:
return 6
elif 'udp' in text:
return 17
elif 'icmp' in text:
return 1
elif 'hopopt' in text:
return 0
elif 'igmp' in text:
return 2
elif 'ggp' in text:
return 3
elif 'ipv4' in text:
return 4
... |
class WebServer:
def __init__():
pass
| class Webserver:
def __init__():
pass |
class super:
name =""
age =""
def set_user(self,a,b):
self.name = a
self.age = b
def show(self):
print(str(self.name))
print(str(self.age))
class sub(super):
def pp(self):
print("Python")
obj1 = sub()
obj1.set_user("AungMoe... | class Super:
name = ''
age = ''
def set_user(self, a, b):
self.name = a
self.age = b
def show(self):
print(str(self.name))
print(str(self.age))
class Sub(super):
def pp(self):
print('Python')
obj1 = sub()
obj1.set_user('AungMoeKyaw', '22')
obj1.show()
obj1... |
# Python3 code to find the element that occur only once
INT_SIZE = 32
def getSingle(arr, n) :
result = 0
for i in range(0, INT_SIZE) :
sm = 0
x = (1 << i)
for j in range(0, n) :
if (arr[j] & x) :
sm = sm + 1
if ((sm % 3)!= 0) :
result = result | x
return result
arr = [12, 1, 12, 3, 1... | int_size = 32
def get_single(arr, n):
result = 0
for i in range(0, INT_SIZE):
sm = 0
x = 1 << i
for j in range(0, n):
if arr[j] & x:
sm = sm + 1
if sm % 3 != 0:
result = result | x
return result
arr = [12, 1, 12, 3, 12, 1, 1, 2, 3, 2, ... |
#!/usr/bin/env python
__version__ = "3.0.0"
version = __version__
| __version__ = '3.0.0'
version = __version__ |
def closest_intersections(first_wire, second_wire):
least_no_of_steps = None
shortest_mh_distance = None
steps_taken_first = 0
point_a_first = (0, 0)
for instr_first in first_wire:
point_b_first, steps_to_b_first = next_point(point_a_first, instr_first)
steps_taken_second = 0
... | def closest_intersections(first_wire, second_wire):
least_no_of_steps = None
shortest_mh_distance = None
steps_taken_first = 0
point_a_first = (0, 0)
for instr_first in first_wire:
(point_b_first, steps_to_b_first) = next_point(point_a_first, instr_first)
steps_taken_second = 0
... |
_COURSIER_CLI_VERSION = "2.12"
_COURSIER_VERSION = "1.1.0-M9"
COURSIER_CLI_SHA256 = "8e7333506bb0db2a262d747873a434a476570dd09b30b61bcbac95aff18a8a9b"
COURSIER_CLI_MAVEN_PATH = "io/get-coursier/coursier-cli_{COURSIER_CLI_VERSION}/{COURSIER_VERSION}/coursier-cli_{COURSIER_CLI_VERSION}-{COURSIER_VERSION}-standalone.jar".... | _coursier_cli_version = '2.12'
_coursier_version = '1.1.0-M9'
coursier_cli_sha256 = '8e7333506bb0db2a262d747873a434a476570dd09b30b61bcbac95aff18a8a9b'
coursier_cli_maven_path = 'io/get-coursier/coursier-cli_{COURSIER_CLI_VERSION}/{COURSIER_VERSION}/coursier-cli_{COURSIER_CLI_VERSION}-{COURSIER_VERSION}-standalone.jar'.... |
userinput = ""
print("Before User input ", userinput)
userinput = input("EnterSomething :")
print("After User input ", userinput)
| userinput = ''
print('Before User input ', userinput)
userinput = input('EnterSomething :')
print('After User input ', userinput) |
'''
WRITTEN BY Ramon Rossi
PURPOSE
The prime number is position one is 2. The prime number in position
two is 3. The prime number is position three is 5. This function is_prime()
finds the prime number at any position. It accepts an integer as an argument
which is the position of the prime number t... | """
WRITTEN BY Ramon Rossi
PURPOSE
The prime number is position one is 2. The prime number in position
two is 3. The prime number is position three is 5. This function is_prime()
finds the prime number at any position. It accepts an integer as an argument
which is the position of the prime number t... |
# -*- coding: utf-8 -*-
# @Author: Anderson
# @Date: 2018-10-05 01:44:18
# @Last Modified by: Anderson
# @Last Modified time: 2018-11-26 11:20:20
def anagrams(strs):
word_dict = {}
for word in strs:
sorted_word = ''.join(sorted(word))
if sorted_word not in word_dict:
word_dict[... | def anagrams(strs):
word_dict = {}
for word in strs:
sorted_word = ''.join(sorted(word))
if sorted_word not in word_dict:
word_dict[sorted_word] = [word]
else:
word_dict[sorted_word].append(word)
count = 0
for item in word_dict:
if len(word_dict[it... |
name = input("Enter your name: ")
print("Your name is", name, ".")
age = int(input("Enter your age: "))
if age > 18:
print(name, "is", age, "years old.")
height = float(input("Enter your Height(cm):"))
if height > 0:
print("That's a positive size!")
weight = float(input("Enter your Weigh... | name = input('Enter your name: ')
print('Your name is', name, '.')
age = int(input('Enter your age: '))
if age > 18:
print(name, 'is', age, 'years old.')
height = float(input('Enter your Height(cm):'))
if height > 0:
print("That's a positive size!")
weight = float(input('Enter your Weight(kg):'))
if weight > 0:... |
t=int(input())
for i in range(t):
n=int(input())
dp=[0 for i in range(n+1)]
dp[0]=1
dp[1]=1
for i in range(2,n+1):
for j in range(0,i):
dp[i]+=dp[j]*dp[i-j-1]
print(dp[n]) | t = int(input())
for i in range(t):
n = int(input())
dp = [0 for i in range(n + 1)]
dp[0] = 1
dp[1] = 1
for i in range(2, n + 1):
for j in range(0, i):
dp[i] += dp[j] * dp[i - j - 1]
print(dp[n]) |
# You have a red lottery ticket showing ints a, b, and c, each of which is 0, 1, or 2.
# If they are all the value 2, the result is 10.
# Otherwise if they are all the same, the result is 5.
# Otherwise so long as both b and c are different from a, the result is 1.
# Otherwise the result is 0.
# Write a function t... | def find_ticket_value(a, b, c):
try:
if a == 2 and b == 2 and (c == 2):
return 10
elif a == b and b == c and (a == c):
return 5
elif b != a and c != a:
return 1
else:
return 0
except TypeError:
return 'wrong Data Type!'
if _... |
# 1 Write a Python function, which gets 2 numbers, and return True if the second number is first number divider, otherwise False.
def divider(a, b):
if b % a == 0:
return True
else:
return False
# 2 Write a Python function, which gets a number, and return True if that number is palindrome, oth... | def divider(a, b):
if b % a == 0:
return True
else:
return False
def palindrome(s):
s = str(s)
if s == s[::-1]:
return True
else:
return False
def prime(x):
if x <= 1:
return False
for i in range(2, x):
if x % i == 0:
return False... |
def get_fibonacci_huge(n):
if n <= 1:
return n
previous = 0
current =1
sum = 1
for __ in range(2,n+1):
previous,current = current, previous+current
sum = sum+(current*current)
# print(sum, ' ', current*current)
return sum%10
if __name__ == '__main__':
n ... | def get_fibonacci_huge(n):
if n <= 1:
return n
previous = 0
current = 1
sum = 1
for __ in range(2, n + 1):
(previous, current) = (current, previous + current)
sum = sum + current * current
return sum % 10
if __name__ == '__main__':
n = int(input())
print(get_fibon... |
class Particle(object):
def __init__(self, sprite):
self.gravity = PVector(0, 0.1)
self.lifespan = 255
self.velocity = PVector()
partSize = random(10, 60)
self.part = createShape()
self.part.beginShape(QUAD)
self.part.noStroke()
self.part.texture(spri... | class Particle(object):
def __init__(self, sprite):
self.gravity = p_vector(0, 0.1)
self.lifespan = 255
self.velocity = p_vector()
part_size = random(10, 60)
self.part = create_shape()
self.part.beginShape(QUAD)
self.part.noStroke()
self.part.texture(... |
#
# PySNMP MIB module ZYXEL-OAM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-OAM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:51:06 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, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ... |
def intro(task):
title = f" ** {task} ** "
print ("\n")
print ("*" * len(title))
print (title)
print ("*" * len(title))
print ("\n")
intro("School")
class Person:
def __init__(self, firstname, lastname, age, phone, email=None):
self.firstname = firstname
self.lastname = las... | def intro(task):
title = f' ** {task} ** '
print('\n')
print('*' * len(title))
print(title)
print('*' * len(title))
print('\n')
intro('School')
class Person:
def __init__(self, firstname, lastname, age, phone, email=None):
self.firstname = firstname
self.lastname = lastname... |
def foo(y):
x=y
return x
bar = foo(7)
| def foo(y):
x = y
return x
bar = foo(7) |
class Solution:
def countPrimes(self, n: int) -> int:
primes = []
for i in range(2, n):
for prime in primes:
if i % prime == 0: break
else:
primes.append(i)
return len(primes)
| class Solution:
def count_primes(self, n: int) -> int:
primes = []
for i in range(2, n):
for prime in primes:
if i % prime == 0:
break
else:
primes.append(i)
return len(primes) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Used to simulate an enum with unique values
class Enumeration(set):
def __getattr__(self, name):
if name in self:
return name
raise AttributeError
def __setattr__(self, name, value):
raise RuntimeError("Cannot override values"... | class Enumeration(set):
def __getattr__(self, name):
if name in self:
return name
raise AttributeError
def __setattr__(self, name, value):
raise runtime_error('Cannot override values')
def __delattr__(self, name):
raise runtime_error('Cannot delete values') |
def fib(n, c={0:1, 1:1}):
if n not in c:
x = n // 2
c[n] = fib(x-1) * fib(n-x-1) + fib(x) * fib(n - x)
return c[n]
fib(10000000) # calculating it takes a few seconds, printing it takes eons
| def fib(n, c={0: 1, 1: 1}):
if n not in c:
x = n // 2
c[n] = fib(x - 1) * fib(n - x - 1) + fib(x) * fib(n - x)
return c[n]
fib(10000000) |
def build_and(left, right):
return {'type':'and','left':left,'right':right}
def build_or(left,right):
return {'type':'or','left':left,'right':right}
def build_atom(atom):
return {'type':'atom','atom':atom}
def equal(p0,p1):
if p0['type'] == p1['type']:
if p1['type'] == 'atom':
ret... | def build_and(left, right):
return {'type': 'and', 'left': left, 'right': right}
def build_or(left, right):
return {'type': 'or', 'left': left, 'right': right}
def build_atom(atom):
return {'type': 'atom', 'atom': atom}
def equal(p0, p1):
if p0['type'] == p1['type']:
if p1['type'] == 'atom':
... |
self.con_win_size = 9
self.halfwin = con_win_size // 2
def load_data(self):
for i in range(self.n_file):
self.log("n." + str(i+1))
inp = np.load(os.path.join(self.data_path, os.listdir(self.data_path)[i]))
full_x = np.pad(inp["imgs"], [(self.halfwin,self.halfwin), (0,0)], mode='constant'... | self.con_win_size = 9
self.halfwin = con_win_size // 2
def load_data(self):
for i in range(self.n_file):
self.log('n.' + str(i + 1))
inp = np.load(os.path.join(self.data_path, os.listdir(self.data_path)[i]))
full_x = np.pad(inp['imgs'], [(self.halfwin, self.halfwin), (0, 0)], mode='constant... |
class TTRssException(Exception):
pass
class TTRssArgumentException(TTRssException):
pass
class TTRssConfigurationException(TTRssException):
pass
| class Ttrssexception(Exception):
pass
class Ttrssargumentexception(TTRssException):
pass
class Ttrssconfigurationexception(TTRssException):
pass |
lista = ('carro','moto','trator','caminhao','coracao','ovo',
'mao','paralelepipedo','borboleta','onibus','Brasil','papai')
for i in lista:
print(f'\nA palavra {i}, possui as vogais: ',end='')
for j in i:
if j.lower() in 'aeiou':
print(j, end=' ') | lista = ('carro', 'moto', 'trator', 'caminhao', 'coracao', 'ovo', 'mao', 'paralelepipedo', 'borboleta', 'onibus', 'Brasil', 'papai')
for i in lista:
print(f'\nA palavra {i}, possui as vogais: ', end='')
for j in i:
if j.lower() in 'aeiou':
print(j, end=' ') |
def find(n,m,index,cursor):
if index == m:
print(" ".join(map(str,foundlist)))
return
else:
for i in range(cursor,n+1):
if findnum[i] == True:
continue
else:
findnum[i] = True
foundlist[index] = cursor = i
find(n,m,index+1,cursor)
findnum[i] = False
... | def find(n, m, index, cursor):
if index == m:
print(' '.join(map(str, foundlist)))
return
else:
for i in range(cursor, n + 1):
if findnum[i] == True:
continue
else:
findnum[i] = True
foundlist[index] = cursor = i
... |
ONES = {0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'}
TEENS = {11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
TENS = {0: '', 1: 'ten', 2: 'twenty', 3: 'thirty', 4: 'for... | ones = {0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'}
teens = {11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
tens = {0: '', 1: 'ten', 2: 'twenty', 3: 'thirty', 4: 'for... |
class Solution:
def numDupDigitsAtMostN(self, N: int) -> int:
list_n = list(map(int, str(N + 1)))
res = 0
len_n = len(list_n)
for i in range(1, len_n):
res += 9 * self.get_cnt(9, i - 1)
s = set()
for i, x in enumerate(list_n):
for y in range(... | class Solution:
def num_dup_digits_at_most_n(self, N: int) -> int:
list_n = list(map(int, str(N + 1)))
res = 0
len_n = len(list_n)
for i in range(1, len_n):
res += 9 * self.get_cnt(9, i - 1)
s = set()
for (i, x) in enumerate(list_n):
for y in ... |
#
# PySNMP MIB module HPN-ICF-COMMON-SYSTEM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-COMMON-SYSTEM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:37:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ... |
## Recursion with memoization
# Time: O(n^3)
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
@lru_cache
def recur( s, word_dict, start ):
if start == len(s):
return True
for end in range( start+1, len(s)+1 ):
if s[star... | class Solution:
def word_break(self, s: str, wordDict: List[str]) -> bool:
@lru_cache
def recur(s, word_dict, start):
if start == len(s):
return True
for end in range(start + 1, len(s) + 1):
if s[start:end] in word_dict and recur(s, word_dict... |
expected_output = {
"active_translations": {"dynamic": 0, "extended": 0, "static": 0, "total": 0},
"cef_punted_pkts": 0,
"cef_translated_pkts": 0,
"dynamic_mappings": {
"inside_source": {
"id": {
1: {
"access_list": "test-robot",
... | expected_output = {'active_translations': {'dynamic': 0, 'extended': 0, 'static': 0, 'total': 0}, 'cef_punted_pkts': 0, 'cef_translated_pkts': 0, 'dynamic_mappings': {'inside_source': {'id': {1: {'access_list': 'test-robot', 'match': 'access-list test-robot pool test-robot', 'pool': {'test-robot': {'allocated': 0, 'all... |
# Copyright (C) 2021 Clinton Garwood
# MIT Open Source Initiative Approved License
# while_true_clinton.py
# CIS-135 Python
# Assignment #9
# # # Lab 9
# Get while_yes and enter Loop
# Initial Value received from input is a string value
# print("While Looping Exercises")
#while_yes = input("Yes or No? Input ... | while_false = False
while while_false != True:
print('While False loop will exit if True (#1) is entered')
t_f = int(input('Enter 1 for True, or 2 for False '))
if t_f == 1:
while_false = True
else:
print('')
print('Exited While False Loop Successfully') |
engine.run_script('init-touchcursor')
# https://github.com/autokey/autokey/issues/127
# Can't simulate multimedia keys #127
# xmodmap -pk | grep XF86AudioRaiseVolume
# 123 0x1008ff13 (XF86AudioRaiseVolume) 0x0000 (NoSymbol) 0x1008ff13 (XF86AudioRaiseVolume)
# keyboard.send_keys("<code123>")
# ... | engine.run_script('init-touchcursor')
system.exec_command('pactl -- set-sink-volume 0 +5%', getOutput=False) |
class Solution:
def twoSum(self, nums: list[int], target: int) -> list[int]:
l = len(nums)
data = {}
for i in range(l):
xa = nums[i]
if xa in data:
return [data[xa], i]
xb = target - xa
data[xb] = i
return []
de... | class Solution:
def two_sum(self, nums: list[int], target: int) -> list[int]:
l = len(nums)
data = {}
for i in range(l):
xa = nums[i]
if xa in data:
return [data[xa], i]
xb = target - xa
data[xb] = i
return []
def ... |
envs = [
'dm.acrobot.swingup',
'dm.cheetah.run',
'dm.finger.turn_hard',
'dm.walker.run',
'dm.quadruped.run',
'dm.quadruped.walk',
'dm.hopper.hop',
]
times = [
1e6, 1e6, 1e6, 1e6, 2e6, 2e6, 1e6
]
sigma = 0.001
f_dims = [1024, 512, 256, 128, 64]
lr = '1e-4'
count = 0
for i, env in enume... | envs = ['dm.acrobot.swingup', 'dm.cheetah.run', 'dm.finger.turn_hard', 'dm.walker.run', 'dm.quadruped.run', 'dm.quadruped.walk', 'dm.hopper.hop']
times = [1000000.0, 1000000.0, 1000000.0, 1000000.0, 2000000.0, 2000000.0, 1000000.0]
sigma = 0.001
f_dims = [1024, 512, 256, 128, 64]
lr = '1e-4'
count = 0
for (i, env) in e... |
def foo():
return "foo 1"
def bar():
return "bar 1"
if __name__ == "__main__":
print(foo())
print(bar()) | def foo():
return 'foo 1'
def bar():
return 'bar 1'
if __name__ == '__main__':
print(foo())
print(bar()) |
def find_node_in_list(name, l):
for i in l:
if i.name == name:
return i
return False
def remove_bag(string):
string = string.replace('bags', '') if 'bags' in string else string
string = string.replace('bag', '') if 'bag' in string else string
return string.strip()
class Link... | def find_node_in_list(name, l):
for i in l:
if i.name == name:
return i
return False
def remove_bag(string):
string = string.replace('bags', '') if 'bags' in string else string
string = string.replace('bag', '') if 'bag' in string else string
return string.strip()
class Linkedl... |
n = int(input())
ans = 0
for a in range(10 ** 5):
if a ** 2 <= n:
ans = a
else:
break
print(ans) | n = int(input())
ans = 0
for a in range(10 ** 5):
if a ** 2 <= n:
ans = a
else:
break
print(ans) |
dict = {
'apples': 7,
'oranges': 12,
'grapes': 5
}
# to get an item from a dictionary
apples = dict.get('apples') # option 1
apples1 = dict['apples'] # option 2
print(apples1)
# add items to the dict
dict['banana'] = 4
print(dict)
# remove items from the dict
dict.popitem() # removes last item fro... | dict = {'apples': 7, 'oranges': 12, 'grapes': 5}
apples = dict.get('apples')
apples1 = dict['apples']
print(apples1)
dict['banana'] = 4
print(dict)
dict.popitem()
print(dict)
dict.pop('oranges')
print(dict) |
A, B = map(int, input().split())
while A != 0 and B != 0:
X = set(map(int, input().split()))
Y = set(map(int, input().split()))
print(min(len(X-Y), len(Y-X)))
A, B = map(int, input().split())
| (a, b) = map(int, input().split())
while A != 0 and B != 0:
x = set(map(int, input().split()))
y = set(map(int, input().split()))
print(min(len(X - Y), len(Y - X)))
(a, b) = map(int, input().split()) |
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'array_data_model',
'dependencies': [
'../../compiled_resources2.gyp:cr',
'../compiled_resou... | {'targets': [{'target_name': 'array_data_model', 'dependencies': ['../../compiled_resources2.gyp:cr', '../compiled_resources2.gyp:event_target'], 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'autocomplete_list', 'dependencies': ['list', 'list_single_selection_model',... |
########################################
# QUESTION
########################################
# Create a function (or write a script in Shell) that takes an integer as an argument
# and returns "Even" for even numbers or "Odd" for odd numbers.
###################################
# SOLUTION
############################... | def even_or_odd(number):
if number % 2 == 0:
return 'Even'
else:
return 'Odd' |
# -*- coding: utf-8 -*-
VERSION_MAJOR = '0'
VERSION_MINOR = '1'
VERSION_PATCH = '1'
VERSION_DEV = 'dev'
def version():
dev = ''
if VERSION_DEV:
dev = '-' + VERSION_DEV
return VERSION_MAJOR + '.' + VERSION_MINOR + '.' + VERSION_PATCH + dev
| version_major = '0'
version_minor = '1'
version_patch = '1'
version_dev = 'dev'
def version():
dev = ''
if VERSION_DEV:
dev = '-' + VERSION_DEV
return VERSION_MAJOR + '.' + VERSION_MINOR + '.' + VERSION_PATCH + dev |
# coding: utf-8
default_app_config = 'modernrpc.apps.ModernRpcConfig'
__version__ = '0.11.1'
| default_app_config = 'modernrpc.apps.ModernRpcConfig'
__version__ = '0.11.1' |
x = 0
if x < 2 :
print('small')
elif x < 10 :
print('Medium')
else :
print('LARGE')
print('All done')
| x = 0
if x < 2:
print('small')
elif x < 10:
print('Medium')
else:
print('LARGE')
print('All done') |
CONTENT_OPERATIONS_RESOURCES_NAMESPACE = \
'bclearer_boson_1_1_source.resources.content_universes'
ADJUSTMENT_OPERATIONS_RESOURCES_NAMESPACE = \
'bclearer_boson_1_1_source.resources.adjustment_universes'
| content_operations_resources_namespace = 'bclearer_boson_1_1_source.resources.content_universes'
adjustment_operations_resources_namespace = 'bclearer_boson_1_1_source.resources.adjustment_universes' |
# More About the print Function (Title)
# Reading
# Suppressing the Print Function's Ending Newline
print('one')
print('two')
print('three')
# To print space instead of newline character (new line of output)
print('one', end=' ')
print('two', end=' ')
print('three')
# To print nothing at the end of its output
print... | print('one')
print('two')
print('three')
print('one', end=' ')
print('two', end=' ')
print('three')
print('one', end='')
print('two', end='')
print('three', end='')
print('One', 'Two', 'Three')
print('One', 'Two', 'Three', sep='')
print('One', 'Two', 'Three', sep='*')
print('One', 'Two', 'Three', sep='~~~')
print('One/... |
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
PYTHON_VERSION_COMPATIBILITY = "PY2+3"
DEPS = [
'provenance',
'recipe_engine/path',
]
def RunSteps(api):
api.provenance.generate(
'projects/PROJ... | python_version_compatibility = 'PY2+3'
deps = ['provenance', 'recipe_engine/path']
def run_steps(api):
api.provenance.generate('projects/PROJECT/locations/global/keyRings/KEYRING/cryptoKeys/KEY', api.path['start_dir'].join('input.json'), api.path['cleanup'].join('output.attestation'))
api.provenance.generate('... |
#
# PySNMP MIB module BASIS-GENERIC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BASIS-GENERIC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:34:35 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ... |
class MinStack(object):
def __init__(self):
self.stack = []
def push(self, x):
self.stack.append((x, min(self.getMin(), x)))
def pop(self):
self.stack.pop()
def top(self):
return self.stack[-1][0]
def getMin(self):
return self.stack[-1][1] if self.stack e... | class Minstack(object):
def __init__(self):
self.stack = []
def push(self, x):
self.stack.append((x, min(self.getMin(), x)))
def pop(self):
self.stack.pop()
def top(self):
return self.stack[-1][0]
def get_min(self):
return self.stack[-1][1] if self.stack ... |
# Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution:
# @param intervals, a list of Intervals
# @param newInterval, a Interval
# @return a list of Interval
def insert(self, intervals, newInterval):
re... | class Solution:
def insert(self, intervals, newInterval):
res = []
if len(intervals) == 0:
res.append(newInterval)
return res
intervals.append(newInterval)
intervals.sort(key=lambda x: x.start)
res.append(intervals[0])
for i in range(1, len(in... |
class dotIFC2X3_Application_t(object):
# no doc
ApplicationFullName=None
ApplicationIdentifier=None
Version=None
| class Dotifc2X3_Application_T(object):
application_full_name = None
application_identifier = None
version = None |
class LaunchAPIException(Exception):
def __init__(self, message, status_code):
super(Exception, self).__init__(message)
self.status_code = status_code
class ClientException(LaunchAPIException):
pass
| class Launchapiexception(Exception):
def __init__(self, message, status_code):
super(Exception, self).__init__(message)
self.status_code = status_code
class Clientexception(LaunchAPIException):
pass |
def main():
OnFwd(OUT_AB, 80)
TextOut(0, LCD_LINE1, 20)
Wait(2000)
| def main():
on_fwd(OUT_AB, 80)
text_out(0, LCD_LINE1, 20)
wait(2000) |
FreeMonoOblique9pt7bBitmaps = [
0x11, 0x22, 0x24, 0x40, 0x00, 0xC0, 0xDE, 0xE5, 0x29, 0x00, 0x09, 0x05,
0x02, 0x82, 0x47, 0xF8, 0xA0, 0x51, 0xFE, 0x28, 0x14, 0x0A, 0x09, 0x00,
0x08, 0x1D, 0x23, 0x40, 0x70, 0x1C, 0x02, 0x82, 0x84, 0x78, 0x20, 0x20,
0x1C, 0x11, 0x08, 0x83, 0x80, 0x18, 0x71, 0xC0, 0x1C, 0x... | free_mono_oblique9pt7b_bitmaps = [17, 34, 36, 64, 0, 192, 222, 229, 41, 0, 9, 5, 2, 130, 71, 248, 160, 81, 254, 40, 20, 10, 9, 0, 8, 29, 35, 64, 112, 28, 2, 130, 132, 120, 32, 32, 28, 17, 8, 131, 128, 24, 113, 192, 28, 17, 8, 131, 128, 30, 96, 129, 3, 10, 101, 70, 136, 232, 250, 128, 18, 36, 72, 136, 136, 136, 128, 1, ... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of easy-drf.
# https://github.com/talp101/easy-drf.git
# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2015, Tal Peretz <13@1500.co.il>
__version__ = '0.1.2' # NOQA
| __version__ = '0.1.2' |
class Solution:
# @param dictionary: a list of strings
# @return: a list of strings
def longestWords(self, dictionary):
def word_len_list(dictionary):
wd_list =[]
for word in dictionary:
wd_list.append(len(word))
return max(wd_list)
def fi... | class Solution:
def longest_words(self, dictionary):
def word_len_list(dictionary):
wd_list = []
for word in dictionary:
wd_list.append(len(word))
return max(wd_list)
def find_word(dictionary):
result = []
for word in dic... |
@jit(nopython=True)
def pressure_poisson(p, b, l2_target):
I, J = b.shape
iter_diff = l2_target + 1
n = 0
while iter_diff > l2_target and n <= 500:
pn = p.copy()
for i in range(1, I - 1):
for j in range(1, J - 1):
p[i, j] = (.25 * (pn[i, j + 1] +
... | @jit(nopython=True)
def pressure_poisson(p, b, l2_target):
(i, j) = b.shape
iter_diff = l2_target + 1
n = 0
while iter_diff > l2_target and n <= 500:
pn = p.copy()
for i in range(1, I - 1):
for j in range(1, J - 1):
p[i, j] = 0.25 * (pn[i, j + 1] + pn[i, j - 1... |
def findAllDuplicates(nums):
d = dict()
for i in nums:
d[i] = d.get(i, 0) + 1
dup = list()
print(d)
for i in d:
if d[i] == 2:
dup.append(i)
return dup
nums = [4, 3, 2, 7, 8, 2, 3, 1]
dup = findAllDuplicates(nums)
print(dup) | def find_all_duplicates(nums):
d = dict()
for i in nums:
d[i] = d.get(i, 0) + 1
dup = list()
print(d)
for i in d:
if d[i] == 2:
dup.append(i)
return dup
nums = [4, 3, 2, 7, 8, 2, 3, 1]
dup = find_all_duplicates(nums)
print(dup) |
##sq=lambda x:x**2
##res=sq(5)
##print("square is:",res)
##
##
##
##add=lambda x,y,z:x+y+z
##
##
##print("sum is:",add(2,3,4))
##
##l=[1,2,3,4,5]
##li=list(map(lambda x:x**3,l))
##print(li)
t=(1,2,3,4,5)
def sum(x):
return x+10
a=list(map(sum,t))
print(a)
| t = (1, 2, 3, 4, 5)
def sum(x):
return x + 10
a = list(map(sum, t))
print(a) |
# Title : TODO
# Objective : TODO
# Created by: Wenzurk
# Created on: 2018/2/3
transportation = ['bicycle', 'motorcycle', 'car', 'airplane']
message = 'I would like to own a '
print(message + transportation[0] + ".")
print(message + transportation[1] + ".")
print(message + transportation[2] + ".")
print(message + ... | transportation = ['bicycle', 'motorcycle', 'car', 'airplane']
message = 'I would like to own a '
print(message + transportation[0] + '.')
print(message + transportation[1] + '.')
print(message + transportation[2] + '.')
print(message + transportation[3] + '.') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.