content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def hip(a, b, c):
if b < a > c and a ** 2 == b ** 2 + c ** 2: return True
elif a < b > c and b ** 2 == a ** 2 + c ** 2: return True
elif a < c > b and c ** 2 == a ** 2 + b ** 2: return True
else: return False
e = str(input()).split()
a = int(e[0])
b = int(e[1])
c = int(e[2])
if(a < b + c and b < a + c... | def hip(a, b, c):
if b < a > c and a ** 2 == b ** 2 + c ** 2:
return True
elif a < b > c and b ** 2 == a ** 2 + c ** 2:
return True
elif a < c > b and c ** 2 == a ** 2 + b ** 2:
return True
else:
return False
e = str(input()).split()
a = int(e[0])
b = int(e[1])
c = int(e[... |
#!/usr/bin/env python3
def left_join(phrases):
return ','.join(phrases).replace("right", "left")
if __name__ == '__main__':
print(left_join(["right", "right", "left", "left", "forward"]))
assert left_join(["right", "right", "left", "left", "forward"]) == "left,left,left,left,forward"
assert left_join(... | def left_join(phrases):
return ','.join(phrases).replace('right', 'left')
if __name__ == '__main__':
print(left_join(['right', 'right', 'left', 'left', 'forward']))
assert left_join(['right', 'right', 'left', 'left', 'forward']) == 'left,left,left,left,forward'
assert left_join(['alright outright', 'squ... |
DATABASE_NAME = "lzhaoDemoDB"
TABLE_NAME = "MarketPriceGTest"
HT_TTL_HOURS = 24
CT_TTL_DAYS = 7
ONE_GB_IN_BYTES = 1073741824
| database_name = 'lzhaoDemoDB'
table_name = 'MarketPriceGTest'
ht_ttl_hours = 24
ct_ttl_days = 7
one_gb_in_bytes = 1073741824 |
class Solution:
def recursion(self,idx,arr,n,maxx,size,k):
if idx == n:
return maxx * size
if (idx,size,maxx) in self.dp: return self.dp[(idx,size,maxx)]
ch1 = self.recursion(idx+1,arr,n,max(maxx,arr[idx]),size+1,k) if size < k else 0
ch2 = self.recursion(idx+1,arr,n,ar... | class Solution:
def recursion(self, idx, arr, n, maxx, size, k):
if idx == n:
return maxx * size
if (idx, size, maxx) in self.dp:
return self.dp[idx, size, maxx]
ch1 = self.recursion(idx + 1, arr, n, max(maxx, arr[idx]), size + 1, k) if size < k else 0
ch2 = ... |
class Action:
def do(self) -> None:
raise NotImplementedError
def undo(self) -> None:
raise NotImplementedError
def redo(self) -> None:
raise NotImplementedError
| class Action:
def do(self) -> None:
raise NotImplementedError
def undo(self) -> None:
raise NotImplementedError
def redo(self) -> None:
raise NotImplementedError |
#
# PySNMP MIB module INCOGNITO-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/INCOGNITO-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:42:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
#list example for insertion order and the dupicates
l1 = []
print(type(l1))
l1.append(1)
l1.append(2)
l1.append(3)
l1.append(4)
l1.append(1)
print(l1)
| l1 = []
print(type(l1))
l1.append(1)
l1.append(2)
l1.append(3)
l1.append(4)
l1.append(1)
print(l1) |
def maximum_subarray_sum(lst):
'''Finds the maximum sum of all subarrays in lst in O(n) time and O(1) additional space.
>>> maximum_subarray_sum([34, -50, 42, 14, -5, 86])
137
>>> maximum_subarray_sum([-5, -1, -8, -101])
0
'''
current_sum = 0
maximum_sum = 0
for value in lst:
... | def maximum_subarray_sum(lst):
"""Finds the maximum sum of all subarrays in lst in O(n) time and O(1) additional space.
>>> maximum_subarray_sum([34, -50, 42, 14, -5, 86])
137
>>> maximum_subarray_sum([-5, -1, -8, -101])
0
"""
current_sum = 0
maximum_sum = 0
for value in lst:
... |
# Alternative solution using compound conditional statement
in_class_test = int(input('Please enter your mark for the In Class Test: '))
exam_mark = int(input('Please input your mark for the exam: '))
coursework_mark = int(input('Please enter your mark for Component B: '))
# Calculating mark by adding the marks toget... | in_class_test = int(input('Please enter your mark for the In Class Test: '))
exam_mark = int(input('Please input your mark for the exam: '))
coursework_mark = int(input('Please enter your mark for Component B: '))
component_a_mark = in_class_test * 0.25 + exam_mark * 0.75
module_mark = (component_a_mark + coursework_ma... |
# Implementation of a singly linked list data structure
# By: Jacob Rockland
# node class for linked list
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
# implementation of singly linked list
class SinglyLinkedList(object):
# initializes linked list
def ... | class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class Singlylinkedlist(object):
def __init__(self, head=None, tail=None):
self.head = head
self.tail = tail
def __repr__(self):
return repr(self.array())
def array(self):
... |
def print_formatted(number):
width = len("{0:b}".format(number))
for num in range(1, number+1):
print("{0:{w}}\t{0:{w}o}\t{0:{w}X}\t{0:{w}b}".format(num, w=width))
if __name__ == '__main__':
n = int(input())
print_formatted(n) | def print_formatted(number):
width = len('{0:b}'.format(number))
for num in range(1, number + 1):
print('{0:{w}}\t{0:{w}o}\t{0:{w}X}\t{0:{w}b}'.format(num, w=width))
if __name__ == '__main__':
n = int(input())
print_formatted(n) |
#######################################################
# Author: Mwiza Simbeye #
# Institution: African Leadership University Rwanda #
# Program: Playing Card Sorting Algorithm #
#######################################################
cards = [9, 10, 'J', 'K', 'Q', 'Q', 4, ... | cards = [9, 10, 'J', 'K', 'Q', 'Q', 4, 5, 6, 7, 8, 'A', 2, 3]
converted_cards = []
for i in cards:
if i == 'A':
converted_cards.append(1)
elif i == 'J':
converted_cards.append(11)
elif i == 'K':
converted_cards.append(12)
elif i == 'Q':
converted_cards.append(13)
else... |
def DPLL(B, I):
if len(B) == 0:
return True, I
for i in B:
if len(i) == 0:
return False, []
x = B[0][0]
if x[0] != '!':
x = '!' + x
Bp = [[j for j in i if j != x] for i in B if not(x[1:] in i)]
Ip = [i for i in I]
Ip.append('Valor de ' + x[1:] + ': '... | def dpll(B, I):
if len(B) == 0:
return (True, I)
for i in B:
if len(i) == 0:
return (False, [])
x = B[0][0]
if x[0] != '!':
x = '!' + x
bp = [[j for j in i if j != x] for i in B if not x[1:] in i]
ip = [i for i in I]
Ip.append('Valor de ' + x[1:] + ': ' + ... |
#multiplicar a nota pelo peso, depois divide a soma das notas pela soma dos pesos
nota1=float(input())*2
nota2=float(input())*3
nota3=float(input())*5
media=float((nota1+nota2+nota3))/10
print("MEDIA =","%.1f"%media) | nota1 = float(input()) * 2
nota2 = float(input()) * 3
nota3 = float(input()) * 5
media = float(nota1 + nota2 + nota3) / 10
print('MEDIA =', '%.1f' % media) |
VALUES_CONSTANT = "values"
PREVIOUS_NODE_CONSTANT = "previous_vertex"
START_NODE = "A"
END_NODE = "F"
# GRAPH IS 1A
graph = {
"A": {
"B" : 5,
"C" : 2
},
"B": {
"E" : 4 ,
"D": 2 ,
},
"C" : {
"B" : 8,
"D" : 7
},
"E" : {
"F" : 3 ,
"D" : 6
},
"D" : {
"F" : ... | values_constant = 'values'
previous_node_constant = 'previous_vertex'
start_node = 'A'
end_node = 'F'
graph = {'A': {'B': 5, 'C': 2}, 'B': {'E': 4, 'D': 2}, 'C': {'B': 8, 'D': 7}, 'E': {'F': 3, 'D': 6}, 'D': {'F': 1}, 'F': {}}
def generate_score_table():
score_table = {}
queue = [START_NODE]
SCORE_TABLE[ST... |
# -*- coding: utf-8 -*-
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the MIT License.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the... | csv = 'perf_Us_3'
cfg_dict = {'aux_no_0': {'dataset': 'aux_no_0', 'p': 3, 'd': 1, 'q': 1, 'taus': [1533, 8], 'Rs': [5, 5], 'k': 15, 'tol': 0.001, 'testsize': 0.1, 'loop_time': 5, 'info': 'v2', 'Us_mode': 3, 'filename': csv}, 'aux_smooth': {'dataset': 'aux_smooth', 'p': 3, 'd': 1, 'q': 1, 'taus': [319, 8], 'Rs': [5, 5],... |
sal = float(input('Qual o seu salario? '))
if sal > 1250.00:
print('Com o aumento seu salario sera R${:.2f}'.format(sal + (sal / 100) * 10))
else:
print('Com o aumento seu salario sera R${:.2f}'.format(sal + (sal / 100) * 15)) | sal = float(input('Qual o seu salario? '))
if sal > 1250.0:
print('Com o aumento seu salario sera R${:.2f}'.format(sal + sal / 100 * 10))
else:
print('Com o aumento seu salario sera R${:.2f}'.format(sal + sal / 100 * 15)) |
class QuizQuestion:
def __init__(self, text, answer):
self.text = text
self.answer = answer
@property
def text(self):
return self.__text
@text.setter
def text(self, text):
self.__text = text
@property
def answer(self):
return self.__answer
... | class Quizquestion:
def __init__(self, text, answer):
self.text = text
self.answer = answer
@property
def text(self):
return self.__text
@text.setter
def text(self, text):
self.__text = text
@property
def answer(self):
return self.__answer
@an... |
class Model:
def __init__(self):
self._classes = {}
self._relations = {}
self._generalizations = {}
self._associationLinks = {}
def addClass(self, _class):
self._classes[_class.uid()] = _class
def classByUid(self, uid):
return self._classes[uid]... | class Model:
def __init__(self):
self._classes = {}
self._relations = {}
self._generalizations = {}
self._associationLinks = {}
def add_class(self, _class):
self._classes[_class.uid()] = _class
def class_by_uid(self, uid):
return self._classes[uid]
def... |
'''
08 - Finding ambiguous datetimes
At the end of lesson 2, we saw something anomalous in our bike trip duration data.
Let's see if we can identify what the problem might be.
The data is loaded as onebike_datetimes, and tz has already been imported from dateutil.
Instructions
- Loop over the trips in onebike_date... | """
08 - Finding ambiguous datetimes
At the end of lesson 2, we saw something anomalous in our bike trip duration data.
Let's see if we can identify what the problem might be.
The data is loaded as onebike_datetimes, and tz has already been imported from dateutil.
Instructions
- Loop over the trips in onebike_date... |
_base_ = [
'../_base_/models/faster_rcnn_r50_fpn.py',
'../_base_/datasets/openBrand_detection.py',
'../_base_/default_runtime.py'
]
data = dict(
samples_per_gpu=4,
workers_per_gpu=2,
)
# model settings
model = dict(
neck=[
dict(
type='FPN',
in_channels=[256, 512... | _base_ = ['../_base_/models/faster_rcnn_r50_fpn.py', '../_base_/datasets/openBrand_detection.py', '../_base_/default_runtime.py']
data = dict(samples_per_gpu=4, workers_per_gpu=2)
model = dict(neck=[dict(type='FPN', in_channels=[256, 512, 1024, 2048], out_channels=256, num_outs=5), dict(type='BFP', in_channels=256, num... |
'''
Problem statement: Given a binary tree, find if it is height balanced or not.
A tree is height balanced if difference between heights of left and right subtrees is not more than one for all nodes
of tree.
'''
class Node:
# Constructor to create a new Node
def __init__(self, data):
self.data = data
... | """
Problem statement: Given a binary tree, find if it is height balanced or not.
A tree is height balanced if difference between heights of left and right subtrees is not more than one for all nodes
of tree.
"""
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.... |
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
inas = [('ina219', '0x40', 'pp1050_s', 1.05, 0.010, 'rem', True),
('ina219', '0x41', 'pp1800_a', 1.80, 0.010, 'rem', True),
('ina219'... | inas = [('ina219', '0x40', 'pp1050_s', 1.05, 0.01, 'rem', True), ('ina219', '0x41', 'pp1800_a', 1.8, 0.01, 'rem', True), ('ina219', '0x42', 'pp1200_vddq', 1.2, 0.01, 'rem', True), ('ina219', '0x43', 'pp3300_a', 3.3, 0.01, 'rem', True), ('ina219', '0x44', 'ppvbat', 7.5, 0.01, 'rem', True), ('ina219', '0x47', 'ppvccgi', ... |
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//antlir/bzl:shape.bzl", "shape")
conf_t = shape.shape(
nameservers = shape.list(str),
search_domains = shape.list(str),
)
| load('//antlir/bzl:shape.bzl', 'shape')
conf_t = shape.shape(nameservers=shape.list(str), search_domains=shape.list(str)) |
# Sudoku problem solved using backtracking
def solve_sudoku(array):
is_empty_cell_found = False;
# Finding if there is any empty cell
for i in range(0, 9):
for j in range(0, 9):
if array[i][j] == 0:
row, col = i, j
is_empty_cell_found = True
... | def solve_sudoku(array):
is_empty_cell_found = False
for i in range(0, 9):
for j in range(0, 9):
if array[i][j] == 0:
(row, col) = (i, j)
is_empty_cell_found = True
break
if is_empty_cell_found:
break
if not is_empty_cel... |
#SetExample4.py ------difference between discard() & remove()
#from both remove() gives error if value not found
nums = {1,2,3,4}
#remove using discard()
nums.discard(5)
print("After discard(5) : ",nums)
#reove using remove()
try:
nums.remove(5)
print("After remove(5) : ",nums)
except KeyErr... | nums = {1, 2, 3, 4}
nums.discard(5)
print('After discard(5) : ', nums)
try:
nums.remove(5)
print('After remove(5) : ', nums)
except KeyError:
print('KeyError : Value not found') |
class Item:
def __init__(self, name, price, quantity):
self._name = name
self.set_price(price)
self.set_quantity(quantity)
def get_name(self):
return self._name
def get_price(self):
return self._price
def get_quantity(self):
return self._quantity
... | class Item:
def __init__(self, name, price, quantity):
self._name = name
self.set_price(price)
self.set_quantity(quantity)
def get_name(self):
return self._name
def get_price(self):
return self._price
def get_quantity(self):
return self._quantity
... |
class Solution:
def makeConnected(self, n: int, connections: List[List[int]]) -> int:
if len(connections) < n-1:
return -1
adjacency = [set() for _ in range(n)]
for x,y in connections:
adjacency[x].add(y)
adjacency[y].add(x)
components = 0... | class Solution:
def make_connected(self, n: int, connections: List[List[int]]) -> int:
if len(connections) < n - 1:
return -1
adjacency = [set() for _ in range(n)]
for (x, y) in connections:
adjacency[x].add(y)
adjacency[y].add(x)
components = 0
... |
class Solution:
def bitwiseComplement(self, N: int) -> int:
if N == 0: return 1
ans = 0
i = 0
while N:
r = N % 2
ans += 2 ** i * (1 - r)
i += 1
N //= 2
return ans
| class Solution:
def bitwise_complement(self, N: int) -> int:
if N == 0:
return 1
ans = 0
i = 0
while N:
r = N % 2
ans += 2 ** i * (1 - r)
i += 1
n //= 2
return ans |
a, b, c = input().split(' ')
d, e, f = input().split(' ')
g, h, i = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)
f = int(f)
g = int(g)
h = int(h)
i = int(i)
def resto(a, b, c):
return (a + b) % c
resultado_1 = resto(a, b, c)
resultado_2 = resto(d, e, f)
resultado_3 = resto(g, h, ... | (a, b, c) = input().split(' ')
(d, e, f) = input().split(' ')
(g, h, i) = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)
f = int(f)
g = int(g)
h = int(h)
i = int(i)
def resto(a, b, c):
return (a + b) % c
resultado_1 = resto(a, b, c)
resultado_2 = resto(d, e, f)
resultado_3 = resto(g, h, ... |
jogador = {}
time = []
lista = []
total = 0
while True:
jogador.clear()
jogador['Nome'] = input('Nome do jogador: ')
quantidade = int(input('Quantas partidas {} jogou ? '.format(jogador['Nome'])))
lista.clear()
for i in range(0, quantidade):
gol_quantidade = int(input('Quantos gols na partid... | jogador = {}
time = []
lista = []
total = 0
while True:
jogador.clear()
jogador['Nome'] = input('Nome do jogador: ')
quantidade = int(input('Quantas partidas {} jogou ? '.format(jogador['Nome'])))
lista.clear()
for i in range(0, quantidade):
gol_quantidade = int(input('Quantos gols na partid... |
def df_restructure_values(data, structure='list', destructive=False):
'''Takes in a dataframe, and restructures
the values so that the output dataframe consist
of columns where the value is coupled with the
column header.
data | DataFrame | a pandas dataframe
structure | str | 'list', 'str', '... | def df_restructure_values(data, structure='list', destructive=False):
"""Takes in a dataframe, and restructures
the values so that the output dataframe consist
of columns where the value is coupled with the
column header.
data | DataFrame | a pandas dataframe
structure | str | 'list', 'str', 't... |
T,R=int(input('Enter no. Test Cases: ')),[]
while(T>0):
P=[int(x) for x in input('Enter No. Cases,Sum: ').split()]
A=sorted([int(x) for x in input('Enter Numbers(A): ').split()][:P[0]])
B=sorted([int(x) for x in input('Enter Numbers(B): ').split()][:P[0]])
for i in range(P[0]):
if A[i]+B[-(i+1)]... | (t, r) = (int(input('Enter no. Test Cases: ')), [])
while T > 0:
p = [int(x) for x in input('Enter No. Cases,Sum: ').split()]
a = sorted([int(x) for x in input('Enter Numbers(A): ').split()][:P[0]])
b = sorted([int(x) for x in input('Enter Numbers(B): ').split()][:P[0]])
for i in range(P[0]):
if... |
class Solution:
def findMaximumXOR(self, nums: List[int]) -> int:
L = len(bin(max(nums))) - 2
nums = [[(num >> i) & 1 for i in range(L)][::-1] for num in nums]
maxXor, trie = 0, {}
for num in nums:
currentNode, xorNode, currentXor = trie, trie, 0
for bit in nu... | class Solution:
def find_maximum_xor(self, nums: List[int]) -> int:
l = len(bin(max(nums))) - 2
nums = [[num >> i & 1 for i in range(L)][::-1] for num in nums]
(max_xor, trie) = (0, {})
for num in nums:
(current_node, xor_node, current_xor) = (trie, trie, 0)
... |
'''
2969
6299
9629
'''
def prime(n):
if n <= 2:
return n == 2
elif n % 2 == 0:
return False
else: #vsa liha ostanejo
d = 3
while d ** 2 <= n:
if n % d == 0:
return False
d += 2
return True
for x in range(100... | """
2969
6299
9629
"""
def prime(n):
if n <= 2:
return n == 2
elif n % 2 == 0:
return False
else:
d = 3
while d ** 2 <= n:
if n % d == 0:
return False
d += 2
return True
for x in range(1000, 10000 - 2 * 3330):
if sorted(lis... |
class Rectangle:
pass
rect1 = Rectangle()
rect2 = Rectangle()
rect1.height = 30
rect1.width = 10
rect2.height = 5
rect2.width = 10
rect1.area = rect1.height * rect1.width
rect2.area = rect2.height * rect2.width
print(rect2.area)
| class Rectangle:
pass
rect1 = rectangle()
rect2 = rectangle()
rect1.height = 30
rect1.width = 10
rect2.height = 5
rect2.width = 10
rect1.area = rect1.height * rect1.width
rect2.area = rect2.height * rect2.width
print(rect2.area) |
#
# Font compiler
#
fonts = [ None ] * 64
current = -1
for l in open("font.txt").readlines():
print(l)
if l.strip() != "":
if l[0] == ':':
current = ord(l[1]) & 0x3F
fonts[current] = []
else:
l = l.strip().replace(".","0").replace("X","1")
assert len(l) == 3
fonts[current].append(int(l,2))
for i ... | fonts = [None] * 64
current = -1
for l in open('font.txt').readlines():
print(l)
if l.strip() != '':
if l[0] == ':':
current = ord(l[1]) & 63
fonts[current] = []
else:
l = l.strip().replace('.', '0').replace('X', '1')
assert len(l) == 3
... |
# Read a DNA Sequence
def readSequence():
sequence = open(raw_input('Enter sequence filename: '),'r')
sequence.readline()
sequence = sequence.read().replace('\n', '')
return sequence
def match(a, b):
if a == b:
return 1
else:
return -1
# Align two sequences using Smith-Waterman algorithm
def alignSequences(... | def read_sequence():
sequence = open(raw_input('Enter sequence filename: '), 'r')
sequence.readline()
sequence = sequence.read().replace('\n', '')
return sequence
def match(a, b):
if a == b:
return 1
else:
return -1
def align_sequences(s1, s2):
gap = -2
s1 = '-' + s1
... |
def flip(arr, i):
start = 0
while start < i:
temp = arr[start]
arr[start] = arr[i]
arr[i] = temp
start += 1
i -= 1
def findMax(arr, n):
mi = 0
for i in range(0,n):
if arr[i] > arr[mi]:
mi = i
return mi
def pancakeSort(arr, n):
curr_size = n
while curr_size > 1:
mi = findMax(arr, curr_size)
i... | def flip(arr, i):
start = 0
while start < i:
temp = arr[start]
arr[start] = arr[i]
arr[i] = temp
start += 1
i -= 1
def find_max(arr, n):
mi = 0
for i in range(0, n):
if arr[i] > arr[mi]:
mi = i
return mi
def pancake_sort(arr, n):
curr... |
n = int(input())
s = []
while n != 0:
n -= 1
name = input()
s.append(name)
r = input()
for i in range(len(s)):
if r in s[i]:
while r in s[i]:
s[i] = s[i].replace(r, "")
max_seq = ""
for i in range(len(s[0])):
ans = ""
for j in range(i, len(s[0])):
ans... | n = int(input())
s = []
while n != 0:
n -= 1
name = input()
s.append(name)
r = input()
for i in range(len(s)):
if r in s[i]:
while r in s[i]:
s[i] = s[i].replace(r, '')
max_seq = ''
for i in range(len(s[0])):
ans = ''
for j in range(i, len(s[0])):
ans += s[0][j]
... |
testArray = [1, 2, 3, 4, 5]
testString = 'this is the test string'
newString = testString + str(testArray)
print(newString) | test_array = [1, 2, 3, 4, 5]
test_string = 'this is the test string'
new_string = testString + str(testArray)
print(newString) |
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
class DepthInfo:
# The default depth that we travel before forcing a foreign key attribute
DEFAULT_MAX_DEPTH = 2
# The max depth set if the user specif... | class Depthinfo:
default_max_depth = 2
max_depth_limit = 32
def __init__(self, current_depth, max_depth, max_depth_exceeded):
self.current_depth = current_depth
self.max_depth = max_depth
self.max_depth_exceeded = max_depth_exceeded |
class Solution:
def isMatch(self, text, pattern):
if not pattern:
return not text
first_match = bool(text) and pattern[0] in {text[0], '.'}
if len(pattern) >= 2 and pattern[1] == '*':
return (self.isMatch(text, pattern[2:]) or
first_match and sel... | class Solution:
def is_match(self, text, pattern):
if not pattern:
return not text
first_match = bool(text) and pattern[0] in {text[0], '.'}
if len(pattern) >= 2 and pattern[1] == '*':
return self.isMatch(text, pattern[2:]) or (first_match and self.isMatch(text[1:], ... |
def format_sql(table, obj: dict) -> str:
cols = ','.join(obj.keys())
values = ','.join(obj.values())
sql = "insert into {table} ({cols}) values ({values})".format(table=table, cols=cols, values=values)
return
def format_sqls(table, objs: list) -> str:
obj = objs.__getitem__(0)
cols = ','.join(... | def format_sql(table, obj: dict) -> str:
cols = ','.join(obj.keys())
values = ','.join(obj.values())
sql = 'insert into {table} ({cols}) values ({values})'.format(table=table, cols=cols, values=values)
return
def format_sqls(table, objs: list) -> str:
obj = objs.__getitem__(0)
cols = ','.join(o... |
# Head ends here
def next_move(posr, posc, board):
p = 0
q = 0
dmin = 0
dmax = 0
position = 0
for i in range(5) :
count = 0
for j in range(5) :
if board[i][j] == "d" :
count += 1
if count == 1 :
dmax ... | def next_move(posr, posc, board):
p = 0
q = 0
dmin = 0
dmax = 0
position = 0
for i in range(5):
count = 0
for j in range(5):
if board[i][j] == 'd':
count += 1
if count == 1:
dmax = dmin = j
elif count... |
class Person:
def __init__(self, name):
self.name = name
# create the method greet here
def greet(self):
print(f"Hello, I am {self.name}!")
in_name = input()
p = Person(in_name)
p.greet()
| class Person:
def __init__(self, name):
self.name = name
def greet(self):
print(f'Hello, I am {self.name}!')
in_name = input()
p = person(in_name)
p.greet() |
load("@wix_oss_infra//:import_external.bzl", import_external = "safe_wix_scala_maven_import_external")
def dependencies():
import_external(
name = "org_xerial_snappy_snappy_java",
artifact = "org.xerial.snappy:snappy-java:1.1.7.1",
artifact_sha256 = "bb52854753feb1919f13099a53475a2a8eb65db... | load('@wix_oss_infra//:import_external.bzl', import_external='safe_wix_scala_maven_import_external')
def dependencies():
import_external(name='org_xerial_snappy_snappy_java', artifact='org.xerial.snappy:snappy-java:1.1.7.1', artifact_sha256='bb52854753feb1919f13099a53475a2a8eb65dbccd22839a9b9b2e1a2190b951', srcjar... |
'''from flask import render_template
from flask import Response
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return render_template('streaming2.html')
def generate(camera):
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpg\r\n\r\n' + frame ... | """from flask import render_template
from flask import Response
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return render_template('streaming2.html')
def generate(camera):
while True:
frame = camera.get_frame()
yield (b'--frame\r
'
b'Content-Type: image/jpg\r
\r
' + frame + b... |
class StreamQueue:
repeat = False
current = None
streams = []
def next(self):
if self.repeat and self.current is not None:
return self.current
self.current = None
if len(self.streams) > 0:
self.current = self.streams.pop(0)
return self.curre... | class Streamqueue:
repeat = False
current = None
streams = []
def next(self):
if self.repeat and self.current is not None:
return self.current
self.current = None
if len(self.streams) > 0:
self.current = self.streams.pop(0)
return self.current
... |
def Move():
global ArchiveIndex, gameData
playerShip.landedBefore = playerShip.landedOn
playerShip.landedOn = None
for Thing in PlanetContainer:
XDiff = playerShip.X - Thing.X
YDiff = playerShip.Y + Thing.Y
Distance = (XDiff ** 2 + YDiff ** 2) ** 0.5
if Distance > 40000:
... | def move():
global ArchiveIndex, gameData
playerShip.landedBefore = playerShip.landedOn
playerShip.landedOn = None
for thing in PlanetContainer:
x_diff = playerShip.X - Thing.X
y_diff = playerShip.Y + Thing.Y
distance = (XDiff ** 2 + YDiff ** 2) ** 0.5
if Distance > 40000... |
def names(l):
# list way
new = []
for i in l:
if not i in new:
new.append(i)
# set way
new = list(set(l))
print(new)
names(["Michele", "Robin", "Sara", "Michele"]) | def names(l):
new = []
for i in l:
if not i in new:
new.append(i)
new = list(set(l))
print(new)
names(['Michele', 'Robin', 'Sara', 'Michele']) |
mylist = [1, 2, 3]
# Imprime 1,2,3
for x in mylist:
print(x)
| mylist = [1, 2, 3]
for x in mylist:
print(x) |
#Print without newline or space
print("\n")
for j in range(10):
print("")
for i in range(10):
print(' @ ', end="")
print("\n") | print('\n')
for j in range(10):
print('')
for i in range(10):
print(' @ ', end='')
print('\n') |
class Entry:
def __init__(self, obj, line_number = 1):
self.obj = obj
self.line_number = line_number
def __repr__(self):
return "In {}, line {}".format(self.obj.name, self.line_number)
class CallStack:
def __init__(self, initial = None):
self.__stack = [] if not initial e... | class Entry:
def __init__(self, obj, line_number=1):
self.obj = obj
self.line_number = line_number
def __repr__(self):
return 'In {}, line {}'.format(self.obj.name, self.line_number)
class Callstack:
def __init__(self, initial=None):
self.__stack = [] if not initial else ... |
class BaseConfig():
API_PREFIX = '/api'
TESTING = False
DEBUG = False
SECRET_KEY = '@!s3cr3t'
AGENT_SOCK = 'cmdsrv__0'
class DevConfig(BaseConfig):
FLASK_ENV = 'development'
DEBUG = True
CELERY_BROKER = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
REDIS_UR... | class Baseconfig:
api_prefix = '/api'
testing = False
debug = False
secret_key = '@!s3cr3t'
agent_sock = 'cmdsrv__0'
class Devconfig(BaseConfig):
flask_env = 'development'
debug = True
celery_broker = 'redis://localhost:6379/0'
celery_result_backend = 'redis://localhost:6379/0'
... |
while True:
x,y=map(int,input().split())
if x==0 and y==0:
break
print(x+y)
| while True:
(x, y) = map(int, input().split())
if x == 0 and y == 0:
break
print(x + y) |
def encode(json, schema):
payload = schema.Main()
payload.github = json['github']
payload.patreon = json['patreon']
payload.open_collective = json['open_collective']
payload.ko_fi = json['ko_fi']
payload.tidelift = json['tidelift']
payload.community_bridge = json['community_bridge']
payl... | def encode(json, schema):
payload = schema.Main()
payload.github = json['github']
payload.patreon = json['patreon']
payload.open_collective = json['open_collective']
payload.ko_fi = json['ko_fi']
payload.tidelift = json['tidelift']
payload.community_bridge = json['community_bridge']
payl... |
#!/usr/bin/python3
OPENVSWITCH_SERVICES_EXPRS = [r"ovsdb-\S+",
r"ovs-vswitch\S+",
r"ovn\S+"]
OVS_PKGS = [r"libc-bin",
r"openvswitch-switch",
r"ovn",
]
OVS_DAEMONS = {"ovs-vswitchd":
{"logs": "var/log/openvswit... | openvswitch_services_exprs = ['ovsdb-\\S+', 'ovs-vswitch\\S+', 'ovn\\S+']
ovs_pkgs = ['libc-bin', 'openvswitch-switch', 'ovn']
ovs_daemons = {'ovs-vswitchd': {'logs': 'var/log/openvswitch/ovs-vswitchd.log'}, 'ovsdb-server': {'logs': 'var/log/openvswitch/ovsdb-server.log'}} |
#!/usr/bin/env python3
inputs = {}
reduced = {}
with open("input.txt") as f:
for line in f:
inp, to = map(lambda x: x.strip(), line.split("->"))
inputs[to] = inp.split(" ")
inputs["b"] = "956"
def reduce(name):
try:
return int(name)
except:
pass
try:
return int(... | inputs = {}
reduced = {}
with open('input.txt') as f:
for line in f:
(inp, to) = map(lambda x: x.strip(), line.split('->'))
inputs[to] = inp.split(' ')
inputs['b'] = '956'
def reduce(name):
try:
return int(name)
except:
pass
try:
return int(inputs[name])
exce... |
LCGDIR = '../lib/sunos5'
LIBDIR = '${LCGDIR}'
BF_PYTHON = '/usr/local'
BF_PYTHON_VERSION = '3.2'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}' #BF_PYTHON+'/lib/python'+BF_PYTHON_VERSION+'/c... | lcgdir = '../lib/sunos5'
libdir = '${LCGDIR}'
bf_python = '/usr/local'
bf_python_version = '3.2'
bf_python_inc = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
bf_python_binary = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
bf_python_lib = 'python${BF_PYTHON_VERSION}'
bf_python_linkflags = ['-Xlinker', '-export-dyn... |
t=input()
while(t>0):
s=raw_input()
str=s.split(' ')
b=int(str[0])
c=int(str[1])
d=int(str[2])
print (c-b)+(c-d)
t=t-1
| t = input()
while t > 0:
s = raw_input()
str = s.split(' ')
b = int(str[0])
c = int(str[1])
d = int(str[2])
print(c - b) + (c - d)
t = t - 1 |
__version__ = "0.1"
__requires__ = [
"apptools>=4.2.0",
"numpy>=1.6",
"traits>=4.4",
"enable>4.2",
"chaco>=4.4",
"fiona>=1.0.2",
"scimath>=4.1.2",
"shapely>=1.2.17",
"tables>=2.4.0",
"sdi",
]
| __version__ = '0.1'
__requires__ = ['apptools>=4.2.0', 'numpy>=1.6', 'traits>=4.4', 'enable>4.2', 'chaco>=4.4', 'fiona>=1.0.2', 'scimath>=4.1.2', 'shapely>=1.2.17', 'tables>=2.4.0', 'sdi'] |
# A plugin is supposed to define a setup function
# which returns the type that the plugin provides
#
# This plugin fails to do so
def useless():
print("Hello World")
| def useless():
print('Hello World') |
class Number:
def numSum(num):
count = []
for x in range(1, (num+1)):
count.append(x)
print(sum(count))
if __name__ == "__main__":
num = int(input("Enter A Number: "))
numSum(num)
| class Number:
def num_sum(num):
count = []
for x in range(1, num + 1):
count.append(x)
print(sum(count))
if __name__ == '__main__':
num = int(input('Enter A Number: '))
num_sum(num) |
logging.info(" *** Step 3: Build features *** ".format())
# %% ===========================================================================
# Feature - Pure Breed Boolean column
# =============================================================================
def pure_breed(row):
# print(row)
mixed_breed_keywords... | logging.info(' *** Step 3: Build features *** '.format())
def pure_breed(row):
mixed_breed_keywords = ['domestic', 'tabby', 'mixed']
if row['Breed1'] == 'Mixed Breed':
return False
elif row['Breed2'] == 'NA':
if any([word in row['Breed1'].lower() for word in mixed_breed_keywords]):
... |
aws_access_key_id=None
aws_secret_access_key=None
img_bucket_name=None
| aws_access_key_id = None
aws_secret_access_key = None
img_bucket_name = None |
def get_tickets(path):
with open(path, 'r') as fh:
yield fh.read().splitlines()
def get_new_range(_min, _max, value):
# print(_min, _max, value)
if value == 'F' or value == 'L':
mid = _min + (_max - _min) // 2
return (_min, mid)
if value == 'B' or value == 'R':
mid = _m... | def get_tickets(path):
with open(path, 'r') as fh:
yield fh.read().splitlines()
def get_new_range(_min, _max, value):
if value == 'F' or value == 'L':
mid = _min + (_max - _min) // 2
return (_min, mid)
if value == 'B' or value == 'R':
mid = _min + (_max - _min) // 2 + 1
... |
def cls_with_meta(mc, attrs):
class _x_(object):
__metaclass__ = mc
for k, v in attrs.items():
setattr(_x_, k, v)
return _x_
| def cls_with_meta(mc, attrs):
class _X_(object):
__metaclass__ = mc
for (k, v) in attrs.items():
setattr(_x_, k, v)
return _x_ |
num = int(input('Digite um valor para saber seu fatorial: '))
d = num
for c in range(num-1,1,-1):
num += (num * c) - num
print('Calculando {}! = {}.'.format(d, num)) | num = int(input('Digite um valor para saber seu fatorial: '))
d = num
for c in range(num - 1, 1, -1):
num += num * c - num
print('Calculando {}! = {}.'.format(d, num)) |
class Solution:
def partition(self, head: ListNode, x: int) -> ListNode:
head = ListNode(0, head)
p1, prev, p2 = head, head, head.next
while p2:
if p2.val < x:
if p1 == prev:
prev, p2 = p2, p2.next
else:
... | class Solution:
def partition(self, head: ListNode, x: int) -> ListNode:
head = list_node(0, head)
(p1, prev, p2) = (head, head, head.next)
while p2:
if p2.val < x:
if p1 == prev:
(prev, p2) = (p2, p2.next)
else:
... |
#
# PySNMP MIB module BLUECOAT-HOST-RESOURCES-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BLUECOAT-HOST-RESOURCES-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:39:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) ... |
t = {}
t["0"] = ["-113", "Marginal"]
t["1"] = ["-111", "Marginal"]
t["2"] = ["-109", "Marginal"]
t["3"] = ["-107", "Marginal"]
t["4"] = ["-105", "Marginal"]
t["5"] = ["-103", "Marginal"]
t["6"] = ["-101", "Marginal"]
t["7"] = ["-99", "Marginal"]
t["8"] = ["-97", "Marginal"]
t["9"] = ["-95", "Marginal"]
t["10"] = ["-93"... | t = {}
t['0'] = ['-113', 'Marginal']
t['1'] = ['-111', 'Marginal']
t['2'] = ['-109', 'Marginal']
t['3'] = ['-107', 'Marginal']
t['4'] = ['-105', 'Marginal']
t['5'] = ['-103', 'Marginal']
t['6'] = ['-101', 'Marginal']
t['7'] = ['-99', 'Marginal']
t['8'] = ['-97', 'Marginal']
t['9'] = ['-95', 'Marginal']
t['10'] = ['-93'... |
class Solution:
def longestWPI(self, hours: List[int]) -> int:
acc = 0
seen = {0 : -1}
mx_len = 0
for i, h in enumerate(hours):
if h > 8:
acc += 1
else:
acc -= 1
if acc > 0:
mx_len = i + 1
... | class Solution:
def longest_wpi(self, hours: List[int]) -> int:
acc = 0
seen = {0: -1}
mx_len = 0
for (i, h) in enumerate(hours):
if h > 8:
acc += 1
else:
acc -= 1
if acc > 0:
mx_len = i + 1
... |
#log in process
def login():
Username = input("Enter Username : ")
if Username == 'betterllama' or NewUsername:
Password = input("Enter Password : ")
else:
print("Username Incorrect")
if Password == 'omoshi' or NewPassword:
print("Welcome, " + Username)
else:
print("Password is incorrect")
#sign up + log... | def login():
username = input('Enter Username : ')
if Username == 'betterllama' or NewUsername:
password = input('Enter Password : ')
else:
print('Username Incorrect')
if Password == 'omoshi' or NewPassword:
print('Welcome, ' + Username)
else:
print('Password is incor... |
# -*- coding: utf8 -*-
def js_test():
pass | def js_test():
pass |
#!/usr/bin/env python
# -----------------------------------------------------------------------------
# This example will open a file and read it line by line, process each line,
# and write the processed line to standard out.
# -----------------------------------------------------------------------------
# Open a fil... | outfile = open('jenny.txt', 'w')
num = 867
num2 = 5309
txt = 'Jenny'
txt2 = 'Tommy Tutone'
list = ['Everclear', 'Foo Fighters', 'Green Day', 'Goo Goo Dolls']
outfile.write('%d-%d/%s was sung by %s\n' % (num, num2, txt, txt2))
outfile.write('and was covered by:\n')
for l in list:
outfile.write('%s\n' % l)
outfile.cl... |
class Solution:
def reverse(self, x: int) -> int:
if x == 0:
return 0
if x < -(2 ** 31) or x > (2 ** 31) - 1:
return 0
newNumber = 0
tempNumber = abs(x)
while tempNumber > 0:
newNumber = (newNumber * 10) + tempNumber % 10
te... | class Solution:
def reverse(self, x: int) -> int:
if x == 0:
return 0
if x < -2 ** 31 or x > 2 ** 31 - 1:
return 0
new_number = 0
temp_number = abs(x)
while tempNumber > 0:
new_number = newNumber * 10 + tempNumber % 10
temp_num... |
good = 0
good_2 = 0
with open("day2.txt") as f:
for line in f.readlines():
parts = line.strip().split()
print(parts)
cmin, cmax = [int(i) for i in parts[0].split('-')]
letter = parts[1][0]
pwd = parts[2]
print(cmin, cmax, letter, pwd)
count = pwd.count(letter... | good = 0
good_2 = 0
with open('day2.txt') as f:
for line in f.readlines():
parts = line.strip().split()
print(parts)
(cmin, cmax) = [int(i) for i in parts[0].split('-')]
letter = parts[1][0]
pwd = parts[2]
print(cmin, cmax, letter, pwd)
count = pwd.count(lette... |
description = 'PUMA multianalyzer device'
group = 'lowlevel'
includes = ['aliases']
level = False
devices = dict(
man = device('nicos_mlz.puma.devices.PumaMultiAnalyzer',
description = 'PUMA multi analyzer',
translations = ['ta1', 'ta2', 'ta3', 'ta4', 'ta5', 'ta6', 'ta7', 'ta8',
... | description = 'PUMA multianalyzer device'
group = 'lowlevel'
includes = ['aliases']
level = False
devices = dict(man=device('nicos_mlz.puma.devices.PumaMultiAnalyzer', description='PUMA multi analyzer', translations=['ta1', 'ta2', 'ta3', 'ta4', 'ta5', 'ta6', 'ta7', 'ta8', 'ta9', 'ta10', 'ta11'], rotations=['ra1', 'ra2'... |
class Solution:
def longestPalindrome(self, s: str) -> str:
if not s:
return None
result = ''
maxPal = 0
record = [[0] * len(s) for i in range(len(s))]
for j in range(len(s)):
for i in range(j+1):
record[i][j] = ((s[i] == s[j]) and (j-i... | class Solution:
def longest_palindrome(self, s: str) -> str:
if not s:
return None
result = ''
max_pal = 0
record = [[0] * len(s) for i in range(len(s))]
for j in range(len(s)):
for i in range(j + 1):
record[i][j] = s[i] == s[j] and (j... |
__author__ = 'Liu'
def quadrado_menores(n):
return [i ** 2 for i in range(1, n + 1) if i ** 2 <= n]
assert [1] == quadrado_menores(1)
assert [1, 4] == quadrado_menores(4)
assert [1, 4, 9] == quadrado_menores(9)
assert [1, 4, 9] == quadrado_menores(11)
def soma_quadrados(n):
if n > 0:
menores = quadrad... | __author__ = 'Liu'
def quadrado_menores(n):
return [i ** 2 for i in range(1, n + 1) if i ** 2 <= n]
assert [1] == quadrado_menores(1)
assert [1, 4] == quadrado_menores(4)
assert [1, 4, 9] == quadrado_menores(9)
assert [1, 4, 9] == quadrado_menores(11)
def soma_quadrados(n):
if n > 0:
menores = quadrad... |
a = 1
if a == 1:
print("ok")
else:
print("no")
py_builtins = 1
if py_builtins == 1:
print("ok")
else:
print("no")
for py_builtins in range(5):
a += py_builtins
print(a)
| a = 1
if a == 1:
print('ok')
else:
print('no')
py_builtins = 1
if py_builtins == 1:
print('ok')
else:
print('no')
for py_builtins in range(5):
a += py_builtins
print(a) |
flag = [""] * 36
flag[0] = chr(0x46)
flag[1] = chr(0x4c)
flag[2] = chr(0x41)
flag[3] = chr(0x47)
flag[4] = chr(0x7b)
flag[5] = chr(0x35)
flag[6] = chr(0x69)
flag[7] = chr(0x6d)
flag[8] = chr(0x70)
flag[9] = chr(0x31)
flag[10] = chr(0x65)
flag[11] = chr(0x5f)
flag[12] = chr(0x52)
flag[13] = chr(0x65)
flag[14] = chr(0x7... | flag = [''] * 36
flag[0] = chr(70)
flag[1] = chr(76)
flag[2] = chr(65)
flag[3] = chr(71)
flag[4] = chr(123)
flag[5] = chr(53)
flag[6] = chr(105)
flag[7] = chr(109)
flag[8] = chr(112)
flag[9] = chr(49)
flag[10] = chr(101)
flag[11] = chr(95)
flag[12] = chr(82)
flag[13] = chr(101)
flag[14] = chr(118)
flag[15] = chr(101)
f... |
uno= Board('/dev/cu.wchusbserial1420')
led= Led(13)
led.setColor([0.84, 0.34, 0.67])
ledController= ExdTextInputBox(target= led, value="period", size="sm")
APP.STACK.add_widget(ledController)
| uno = board('/dev/cu.wchusbserial1420')
led = led(13)
led.setColor([0.84, 0.34, 0.67])
led_controller = exd_text_input_box(target=led, value='period', size='sm')
APP.STACK.add_widget(ledController) |
a, b = map(int, input().split())
if a + b == 15:
print('+')
elif a*b == 15:
print('*')
else:
print('x')
| (a, b) = map(int, input().split())
if a + b == 15:
print('+')
elif a * b == 15:
print('*')
else:
print('x') |
class Solution:
def stoneGameV(self, stoneValue: List[int]) -> int:
n = len(stoneValue)
dp = [[0] * n for _ in range(n)]
mx = [[0] * n for _ in range(n)]
for i in range(n):
mx[i][i] = stoneValue[i]
for j in range(1, n):
mid = j
s = stoneVal... | class Solution:
def stone_game_v(self, stoneValue: List[int]) -> int:
n = len(stoneValue)
dp = [[0] * n for _ in range(n)]
mx = [[0] * n for _ in range(n)]
for i in range(n):
mx[i][i] = stoneValue[i]
for j in range(1, n):
mid = j
s = stone... |
# %% [404. Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/)
class Solution:
def sumOfLeftLeaves(self, root: TreeNode) -> int:
if not root:
return 0
r = self.sumOfLeftLeaves(root.right)
if (p := root.left) and not p.left and not p.right:
return ro... | class Solution:
def sum_of_left_leaves(self, root: TreeNode) -> int:
if not root:
return 0
r = self.sumOfLeftLeaves(root.right)
if (p := root.left) and (not p.left) and (not p.right):
return root.left.val + r
return self.sumOfLeftLeaves(root.left) + r |
class Solution:
def maximalRectangle(self, matrix: List[List[str]]) -> int:
if not matrix: return 0
row, col = len(matrix), len(matrix[0])
dp = [0] * col
ret = 0
for i in range(row):
for j in range(col):
if matrix[i][j] == '1':
... | class Solution:
def maximal_rectangle(self, matrix: List[List[str]]) -> int:
if not matrix:
return 0
(row, col) = (len(matrix), len(matrix[0]))
dp = [0] * col
ret = 0
for i in range(row):
for j in range(col):
if matrix[i][j] == '1':
... |
database_name = "Health_Service"
user_name = "postgres"
password = "zhangheng"
port = "5432"
| database_name = 'Health_Service'
user_name = 'postgres'
password = 'zhangheng'
port = '5432' |
#Exercise 3.2: Rewrite your pay program using try and except so
# that yourprogram handles non-numeric input gracefully by
# printing a messageand exiting the program. The following
# shows two executions of the program:
# Enter Hours: 20
# Enter Rate: nine
# Error, please enter numeric input
# Enter Hours: forty
... | hrs = input('Enter Hours: ')
try:
h = float(hrs)
rph = input('Enter Rate: ')
try:
r = float(rph)
if h <= 40:
pay = h * r
else:
overhours = h - 40
norm_pay = 40 * r
over_pay = overhours * r * 1.5
pay = norm_pay + over_pay
... |
_base_ = [
'../_base_/models/mask_rcnn_r50_fpn_icdar2021.py',
'../_base_/datasets/icdar2021_instance_isolated.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
# data = dict(
# samples_per_gpu=1,
# workers_per_gpu=2)
# optimizer = dict(type='SGD', lr=0.01, momentum=0.9, w... | _base_ = ['../_base_/models/mask_rcnn_r50_fpn_icdar2021.py', '../_base_/datasets/icdar2021_instance_isolated.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'] |
HASS_EVENT_RECEIVE = 'HASS_EVENT_RECEIVE' # hass.bus --> hauto.bus
HASS_STATE_CHANGED = 'HASS_STATE_CHANGE' # aka hass.EVENT_STATE_CHANGED
HASS_ENTITY_CREATE = 'HASS_ENTITY_CREATE' # hass entity is newly created
HASS_ENTITY_CHANGE = 'HASS_ENTITY_CHANGE' # hass entity's state changes
HASS_ENTITY_UPDATE = 'HASS_ENT... | hass_event_receive = 'HASS_EVENT_RECEIVE'
hass_state_changed = 'HASS_STATE_CHANGE'
hass_entity_create = 'HASS_ENTITY_CREATE'
hass_entity_change = 'HASS_ENTITY_CHANGE'
hass_entity_update = 'HASS_ENTITY_UPDATE'
hass_entity_remove = 'HASS_ENTITY_REMOVE' |
N, L = map(int, input().split())
amida = []
for _ in range(L+1):
tmp = list(input())
amida.append(tmp)
idx = amida[L].index('o')
for i in reversed(range(L)):
if idx != N*2-2 and amida[i][idx+1] == '-':
idx += 2
elif idx != 0 and amida[i][idx-1] == '-':
idx -= 2
print(idx//2+1)
| (n, l) = map(int, input().split())
amida = []
for _ in range(L + 1):
tmp = list(input())
amida.append(tmp)
idx = amida[L].index('o')
for i in reversed(range(L)):
if idx != N * 2 - 2 and amida[i][idx + 1] == '-':
idx += 2
elif idx != 0 and amida[i][idx - 1] == '-':
idx -= 2
print(idx // 2... |
# LSM6DSO 3D accelerometer and 3D gyroscope seneor micropython drive
# ver: 1.0
# License: MIT
# Author: shaoziyang (shaoziyang@micropython.org.cn)
# v1.0 2019.7
LSM6DSO_CTRL1_XL = const(0x10)
LSM6DSO_CTRL2_G = const(0x11)
LSM6DSO_CTRL3_C = const(0x12)
LSM6DSO_CTRL6_C = const(0x15)
LSM6DSO_CTRL8_XL = const(0x17)
LSM6D... | lsm6_dso_ctrl1_xl = const(16)
lsm6_dso_ctrl2_g = const(17)
lsm6_dso_ctrl3_c = const(18)
lsm6_dso_ctrl6_c = const(21)
lsm6_dso_ctrl8_xl = const(23)
lsm6_dso_status = const(30)
lsm6_dso_out_temp_l = const(32)
lsm6_dso_outx_l_g = const(34)
lsm6_dso_outy_l_g = const(36)
lsm6_dso_outz_l_g = const(38)
lsm6_dso_outx_l_a = con... |
class Solution:
def findPeakElement(self, nums: List[int]) -> int:
l=0
r=len(nums)-1
while l<r:
mid=l+(r-l)//2
if nums[mid]<nums[mid+1]:
l=mid+1
else:
r=mid
return l
| class Solution:
def find_peak_element(self, nums: List[int]) -> int:
l = 0
r = len(nums) - 1
while l < r:
mid = l + (r - l) // 2
if nums[mid] < nums[mid + 1]:
l = mid + 1
else:
r = mid
return l |
# Refers to `_RAND_INCREASING_TRANSFORMS` in pytorch-image-models
rand_increasing_policies = [
dict(type='AutoContrast'),
dict(type='Equalize'),
dict(type='Invert'),
dict(type='Rotate', magnitude_key='angle', magnitude_range=(0, 30)),
dict(type='Posterize', magnitude_key='bits', magnitude_range=(4, ... | rand_increasing_policies = [dict(type='AutoContrast'), dict(type='Equalize'), dict(type='Invert'), dict(type='Rotate', magnitude_key='angle', magnitude_range=(0, 30)), dict(type='Posterize', magnitude_key='bits', magnitude_range=(4, 0)), dict(type='Solarize', magnitude_key='thr', magnitude_range=(256, 0)), dict(type='S... |
def tickets(people):
twenty_fives = 0
fifties = 0
for p in people:
if p == 25:
twenty_fives += 1
if p == 50:
if twenty_fives == 0:
return 'NO'
twenty_fives -= 1
fifties += 1
if p == 100:
if fifties >= 1 and t... | def tickets(people):
twenty_fives = 0
fifties = 0
for p in people:
if p == 25:
twenty_fives += 1
if p == 50:
if twenty_fives == 0:
return 'NO'
twenty_fives -= 1
fifties += 1
if p == 100:
if fifties >= 1 and t... |
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
# Disable DYNAMICBASE for these tests because it implies/doesn't imply
# FIXED in certain cases so it complicates the test for FIXED.
{... | {'targets': [{'target_name': 'test_fixed_default_exe', 'type': 'executable', 'msvs_settings': {'VCLinkerTool': {'RandomizedBaseAddress': '1'}}, 'sources': ['hello.cc']}, {'target_name': 'test_fixed_default_dll', 'type': 'shared_library', 'msvs_settings': {'VCLinkerTool': {'RandomizedBaseAddress': '1'}}, 'sources': ['he... |
# Python program to Find Numbers divisible by Another number
def main():
x=int(input("Enter the number"))
y=int(input("Enter the limit value"))
print("The Numbers divisible by",x,"is")
for i in range(1,y+1):
if i%x==0:
print(i)
if __name__=='__main__':
main()
| def main():
x = int(input('Enter the number'))
y = int(input('Enter the limit value'))
print('The Numbers divisible by', x, 'is')
for i in range(1, y + 1):
if i % x == 0:
print(i)
if __name__ == '__main__':
main() |
class multi():
def insert(self,num):
for i in range(1, 11):
print(num, "X", i, "=", num * i)
d=multi()
d.insert(num=int(input('Enter the number')))
| class Multi:
def insert(self, num):
for i in range(1, 11):
print(num, 'X', i, '=', num * i)
d = multi()
d.insert(num=int(input('Enter the number'))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.