content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# we are given a 2d matrix of 0s and 1s where 0 represents water and 1 represents land.
# any chunk of land disconnected from the borders(edges) of matrix is considered an island.
# The task is to remove all the islands from the matrix.
# Example
# [1, 0, 0, 0, 0, 0] [1, 0, 0, 0, 0, 0]
# [0, 1, 0, 1, 1, 1] [0, 0, 0,... | def is_valid(row, col, matrix):
return row >= 0 and row < len(matrix) and (col >= 0) and (col < len(matrix[0]))
def scan(matrix, row, col, res):
if not is_valid(row, col, matrix):
return
if matrix[row][col] == 0:
return
if res[row][col] == 1:
return
res[row][col] = 1
sca... |
class Solution:
def isValid(self, s):
if not s: # empty string is valid
return True
stack = []
for ch in s:
if ch == '(' or ch == '[' or ch == '{': # push opening brackets onto stack
stack.append(ch)
elif not stack: # if stack is empty then cannot pop needed closing bracket
return False # st... | class Solution:
def is_valid(self, s):
if not s:
return True
stack = []
for ch in s:
if ch == '(' or ch == '[' or ch == '{':
stack.append(ch)
elif not stack:
return False
else:
x = stack.pop()
... |
class DenseNetConfig(object):
# number of groups for group normalization
numGroups = 8
compressionRate = .5
growthRate = 32
# number of conv blocks
numBlocks = [6, 12, 24, 16]
| class Densenetconfig(object):
num_groups = 8
compression_rate = 0.5
growth_rate = 32
num_blocks = [6, 12, 24, 16] |
class WeAre():
fl = False
_count = 0
def __init__(self):
WeAre.fl = True
WeAre._count += 1
WeAre.fl = False
@property
def count(self):
return WeAre._count
@count.setter
def count(self, value):
if WeAre.fl:
print("SAS")
WeA... | class Weare:
fl = False
_count = 0
def __init__(self):
WeAre.fl = True
WeAre._count += 1
WeAre.fl = False
@property
def count(self):
return WeAre._count
@count.setter
def count(self, value):
if WeAre.fl:
print('SAS')
WeAre._c... |
def prestamo(informacion: dict)-> dict:
id_prestamo = informacion['id_prestamo']
casado = informacion['casado']
dependientes = informacion['dependientes']
educacion = informacion['educacion']
independiente = informacion['independiente']
ingreso_deudor = informacion['ingreso_deudor']
ic... | def prestamo(informacion: dict) -> dict:
id_prestamo = informacion['id_prestamo']
casado = informacion['casado']
dependientes = informacion['dependientes']
educacion = informacion['educacion']
independiente = informacion['independiente']
ingreso_deudor = informacion['ingreso_deudor']
ic = in... |
MAJOR = 0
MINOR = 5
MICRO = 2
__version__ = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
| major = 0
minor = 5
micro = 2
__version__ = '%d.%d.%d' % (MAJOR, MINOR, MICRO) |
if __name__ == '__main__':
with open('input', 'r') as file:
outputs = []
for line in file.readlines():
vals = line.split('|')
outputs.extend(vals[1].split())
print(len([x for x in outputs if len(x) in [2, 3, 4, 7]]))
| if __name__ == '__main__':
with open('input', 'r') as file:
outputs = []
for line in file.readlines():
vals = line.split('|')
outputs.extend(vals[1].split())
print(len([x for x in outputs if len(x) in [2, 3, 4, 7]])) |
def get_credentials_from_vault(path):
# TODO
pass
| def get_credentials_from_vault(path):
pass |
def pangram(s):
a = "abcdefghijklmnopqrstuvwxyz"
for i in a:
if i not in s.lower():
return False
return True
pan_Str = input("Enter the String : ")
if(pangram(pan_Str) == True):
print("Pangram Exists")
else:
print("Pangram Not Exists")
| def pangram(s):
a = 'abcdefghijklmnopqrstuvwxyz'
for i in a:
if i not in s.lower():
return False
return True
pan__str = input('Enter the String : ')
if pangram(pan_Str) == True:
print('Pangram Exists')
else:
print('Pangram Not Exists') |
class Solution:
def XXX(self, digits: List[int]) -> List[int]:
s = digits[::-1]
i = 0
if s[0]+1 < 10:
s[0] += 1
else:
while s[i]+1 >= 10:
s[i] = 0
i += 1
if i != len(s):
s[i] += 1
... | class Solution:
def xxx(self, digits: List[int]) -> List[int]:
s = digits[::-1]
i = 0
if s[0] + 1 < 10:
s[0] += 1
else:
while s[i] + 1 >= 10:
s[i] = 0
i += 1
if i != len(s):
s[i] += 1
... |
print(min(1, 2, 3, 4, 0, 2, 1))
print(max([1, 4, 9, 2, 5, 6, 8]))
print(abs(-99))
print(abs(42))
print(sum([1, 2, 3, 4, 5])) | print(min(1, 2, 3, 4, 0, 2, 1))
print(max([1, 4, 9, 2, 5, 6, 8]))
print(abs(-99))
print(abs(42))
print(sum([1, 2, 3, 4, 5])) |
def Setup(Settings,DefaultModel):
# set1-test_of_models_against_datasets/osm299.py
Settings["experiment_name"] = "set1_Img_model_versus_datasets_299px"
Settings["graph_histories"] = ['together'] #['all','together',[],[1,0],[0,0,0],[]]
# 5556x_minlen30_640px 5556x_minlen20_640px 5556x_reslen20_299px 5... | def setup(Settings, DefaultModel):
Settings['experiment_name'] = 'set1_Img_model_versus_datasets_299px'
Settings['graph_histories'] = ['together']
n = 0
Settings['models'][n]['dataset_name'] = '5556x_reslen30_299px'
Settings['models'][n]['dump_file_override'] = 'SegmentsData_marked_R100_4Tables.dump... |
xs = (
x and
x
for x in range(10)
if
x and
x
)
| xs = (x and x for x in range(10) if x and x) |
Scale.default = "chromatic"
Root.default = 2
Clock.bpm = 120
drp = [0, 7, 12, 17, 21, 26]
std = [0, 5, 10, 15, 19, 24]
p1 >> play(
"<Vs>< n >",
sample = 2,
).every(5, "stutter", 2, dur=3)
p2 >> play(
"{ ppP[pP][Pp]}",
sample = PRand(5),
rate = PRand([0.5, 1, 2]),
)
a1 >> karp(
oct = PRand(... | Scale.default = 'chromatic'
Root.default = 2
Clock.bpm = 120
drp = [0, 7, 12, 17, 21, 26]
std = [0, 5, 10, 15, 19, 24]
p1 >> play('<Vs>< n >', sample=2).every(5, 'stutter', 2, dur=3)
p2 >> play('{ ppP[pP][Pp]}', sample=p_rand(5), rate=p_rand([0.5, 1, 2]))
a1 >> karp(oct=p_rand([4, 5, 6]), dur=1 / 4, hpf=linvar([1000,... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
aws_default_parameters.py
This module holds default parameters and/or objects to be used by the AWS ATS.
"""
# Defaults to use when accessing services on the main AWS SysLink instance.
DEFAULT_AWS_SYSLINK_ACCESS_DATA = {
'name': 'systemlink-jenkins.aws.natinst.com'... | """
aws_default_parameters.py
This module holds default parameters and/or objects to be used by the AWS ATS.
"""
default_aws_syslink_access_data = {'name': 'systemlink-jenkins.aws.natinst.com', 'username': 'ni-systemlink-dev', 'password': 'Kn1ghtR!der'}
default_security_group_ids = ['sg-02b4b7b6eefa0aea1', 'sg-0d0107d... |
def solveMeFirst(a, b):
return a + b
print(solveMeFirst(1, 2))
| def solve_me_first(a, b):
return a + b
print(solve_me_first(1, 2)) |
"""
https://leetcode.com/problems/univalued-binary-tree/
A binary tree is univalued if every node in the tree has the same value.
Return true if and only if the given tree is univalued.
Example 1:
Input: [1,1,1,1,1,null,1]
Output: true
Example 2:
Input: [2,2,2,5,2]
Output: false
Note:
The number of nodes in ... | """
https://leetcode.com/problems/univalued-binary-tree/
A binary tree is univalued if every node in the tree has the same value.
Return true if and only if the given tree is univalued.
Example 1:
Input: [1,1,1,1,1,null,1]
Output: true
Example 2:
Input: [2,2,2,5,2]
Output: false
Note:
The number of nodes in ... |
# -*- coding: utf-8 -*-
# @Author: David Hanson
# @Date: 2021-01-30 23:30:31
# @Last Modified by: David Hanson
# @Last Modified time: 2021-01-31 13:41:39
counter = 0
def inception():
global counter
print(counter)
if counter > 3:
return "done!"
counter += 1
return inception()
inception(... | counter = 0
def inception():
global counter
print(counter)
if counter > 3:
return 'done!'
counter += 1
return inception()
inception() |
class Vehicle():
def __init__(self, wheels, max_weight, max_volume):
self.wheels = wheels
self.speed = 0
self._packages = []
self.max_weight = max_weight
self.max_volume = max_volume
def accelerate(self, amount):
self.speed += amount
def add_packages(self, packages):
if not isinstan... | class Vehicle:
def __init__(self, wheels, max_weight, max_volume):
self.wheels = wheels
self.speed = 0
self._packages = []
self.max_weight = max_weight
self.max_volume = max_volume
def accelerate(self, amount):
self.speed += amount
def add_packages(self, pa... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def neues_konto(inhaber, kontonummer, kontostand,
max_tagesumsatz=1500):
return {
"Inhaber" : inhaber,
"Kontonummer" : kontonummer,
"Kontostand" : kontostand,
"MaxTagesumsatz" : max_tagesumsatz,
"UmsatzHeute" : 0
... | def neues_konto(inhaber, kontonummer, kontostand, max_tagesumsatz=1500):
return {'Inhaber': inhaber, 'Kontonummer': kontonummer, 'Kontostand': kontostand, 'MaxTagesumsatz': max_tagesumsatz, 'UmsatzHeute': 0}
def geldtransfer(quelle, ziel, betrag):
if betrag < 0 or quelle['UmsatzHeute'] + betrag > quelle['MaxTa... |
class Citizen:
"""A not-so-simple example Class"""
def __init__(self, first_name, last_name):
self.first_name = str(first_name)
self.last_name= str(last_name)
def full_name(self):
return self.first_name + ' ' + self.last_name
greeting = 'For the glory of Python!'
x = Citizen(... | class Citizen:
"""A not-so-simple example Class"""
def __init__(self, first_name, last_name):
self.first_name = str(first_name)
self.last_name = str(last_name)
def full_name(self):
return self.first_name + ' ' + self.last_name
greeting = 'For the glory of Python!'
x = citizen('... |
class InvalidFileNameError(Exception):
"""Occurs when an invalid file name is provided."""
def __init__(self, name):
self.name = name
| class Invalidfilenameerror(Exception):
"""Occurs when an invalid file name is provided."""
def __init__(self, name):
self.name = name |
def first_recurring(data):
seen = []
for index in data:
if index not in seen:
seen.append(index)
else:
return index
return "All unique characters."
data = [1, 2, 3, 3, 2, 1, 3]
print("first_recurring():", first_recurring(data))
| def first_recurring(data):
seen = []
for index in data:
if index not in seen:
seen.append(index)
else:
return index
return 'All unique characters.'
data = [1, 2, 3, 3, 2, 1, 3]
print('first_recurring():', first_recurring(data)) |
class Matrix:
def __init__(self, matrix_string):
self.matrix = [[int(a) for a in line.split()] for line in matrix_string.splitlines()]
def row(self, row):
return (self.matrix.copy())[row-1]
def column(self, col):
#return [self.matrix[k][col-1] for k in enumerate(len(self.matrix))]
... | class Matrix:
def __init__(self, matrix_string):
self.matrix = [[int(a) for a in line.split()] for line in matrix_string.splitlines()]
def row(self, row):
return self.matrix.copy()[row - 1]
def column(self, col):
return [k[col - 1] for k in self.matrix]
end = matrix('9 8 7\n5 3 2\... |
number = input()
def get_sums(number):
return [sum(list(map(int, filter(lambda x: int(x) % 2 == 0, number)))),
sum([int(x) for x in number if int(x) % 2 == 1])]
result = get_sums(number)
print(f"Odd sum = {result[1]}, Even sum = {result[0]}") | number = input()
def get_sums(number):
return [sum(list(map(int, filter(lambda x: int(x) % 2 == 0, number)))), sum([int(x) for x in number if int(x) % 2 == 1])]
result = get_sums(number)
print(f'Odd sum = {result[1]}, Even sum = {result[0]}') |
"""
Package version.
"""
__version__ = '1.0.2'
| """
Package version.
"""
__version__ = '1.0.2' |
#!/usr/bin/python3
Rectangle = __import__('6-rectangle').Rectangle
my_rectangle_1 = Rectangle(2, 4)
my_rectangle_2 = Rectangle(2, 4)
print("{:d} instances of Rectangle".format(Rectangle.number_of_instances))
del my_rectangle_1
print("{:d} instances of Rectangle".format(Rectangle.number_of_instances))
del my_rectangle_... | rectangle = __import__('6-rectangle').Rectangle
my_rectangle_1 = rectangle(2, 4)
my_rectangle_2 = rectangle(2, 4)
print('{:d} instances of Rectangle'.format(Rectangle.number_of_instances))
del my_rectangle_1
print('{:d} instances of Rectangle'.format(Rectangle.number_of_instances))
del my_rectangle_2
print('{:d} instan... |
def export_users(users, workbook, mimic_upload=False):
data_prefix = 'data: ' if mimic_upload else 'd.'
user_keys = ('user_id', 'username', 'is_active', 'name', 'groups')
user_rows = []
fields = set()
for user in users:
user_row = {}
for key in user_keys:
if key == 'usern... | def export_users(users, workbook, mimic_upload=False):
data_prefix = 'data: ' if mimic_upload else 'd.'
user_keys = ('user_id', 'username', 'is_active', 'name', 'groups')
user_rows = []
fields = set()
for user in users:
user_row = {}
for key in user_keys:
if key == 'usern... |
'''[Question 10952] '''
# import sys
# while True:
# try:
# a, b = map(int, sys.stdin.readline().split())
# print(a+b)
# except:
# break
''' Fail [Question 1110] '''
# import sys
# copy = n = int(sys.stdin.readline())
# count = 0
# while True:
# a = copy//10
# b = copy%10
# ... | """[Question 10952] """
' Fail [Question 1110] '
' [Question 2562] '
' [Question 2577] '
' [Question 3052] '
result_1 = []
for _ in range(10):
n = int(input())
n = n % 42
result_1.append(n)
result_2 = set(result_1)
print(len(result_2)) |
def get_input():
numbers_dict = {}
command = str(input())
while command != "Search":
try:
number = int(input())
except ValueError:
print('The variable number must be an integer')
command = str(input())
continue
numbers_dict[command] = n... | def get_input():
numbers_dict = {}
command = str(input())
while command != 'Search':
try:
number = int(input())
except ValueError:
print('The variable number must be an integer')
command = str(input())
continue
numbers_dict[command] = n... |
class Solution:
"""
@param A: An integer array
@param k: A positive integer (k <= length(A))
@param target: An integer
@return: An integer
"""
def kSum(self, A, k, target):
pass
| class Solution:
"""
@param A: An integer array
@param k: A positive integer (k <= length(A))
@param target: An integer
@return: An integer
"""
def k_sum(self, A, k, target):
pass |
def max_sub_array(nums, max_sum=None, current_sum=0, current_index=0):
""" Returns the max subarray of the given list of numbers.
Returns 0 if nums is None or an empty list.
Time Complexity: O(n)
Space Complexity: O(1)
"""
if nums == None:
return 0
if len(nums) == 0... | def max_sub_array(nums, max_sum=None, current_sum=0, current_index=0):
""" Returns the max subarray of the given list of numbers.
Returns 0 if nums is None or an empty list.
Time Complexity: O(n)
Space Complexity: O(1)
"""
if nums == None:
return 0
if len(nums) == 0:
... |
"""Collection of utilities"""
def with_metaclass(meta, *bases):
"""Create a base class with a metaclass.
Code taken from six (https://pypi.python.org/pypi/six).
"""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replace... | """Collection of utilities"""
def with_metaclass(meta, *bases):
"""Create a base class with a metaclass.
Code taken from six (https://pypi.python.org/pypi/six).
"""
class Metaclass(meta):
def __new__(cls, name, _, doc):
return meta(name, bases, doc)
return type.__new__(metacl... |
class DictValidator:
def __init__(self):
directives = [seg.strip().replace("\n", "").strip() for seg in self.__doc__.split("@")]
v_name = "__SPEC_%s" % (self.__class__.__name__.upper())
globals().update({
v_name: self,
})
self.directives = directives
self... | class Dictvalidator:
def __init__(self):
directives = [seg.strip().replace('\n', '').strip() for seg in self.__doc__.split('@')]
v_name = '__SPEC_%s' % self.__class__.__name__.upper()
globals().update({v_name: self})
self.directives = directives
self.allow_extra_params = Fal... |
#!/usr/bin/python
def web_socket_do_extra_handshake(request):
request.ws_protocol = 'foobar'
def web_socket_transfer_data(request):
pass | def web_socket_do_extra_handshake(request):
request.ws_protocol = 'foobar'
def web_socket_transfer_data(request):
pass |
"""
Helpers.
"""
def _clean_readme(content):
"""
Clean instructions such as ``.. only:: html``.
:param content: content of an rst file
:return: cleaned content
"""
lines = content.split("\n")
indent = None
less = None
rows = []
for i, line in enumerate(lines):
sline = l... | """
Helpers.
"""
def _clean_readme(content):
"""
Clean instructions such as ``.. only:: html``.
:param content: content of an rst file
:return: cleaned content
"""
lines = content.split('\n')
indent = None
less = None
rows = []
for (i, line) in enumerate(lines):
sline = ... |
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def sortedArrayToBST(self, nums):
"""
:type nums: List[int]
:rtype: TreeNode... | class Treenode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def sorted_array_to_bst(self, nums):
"""
:type nums: List[int]
:rtype: TreeNode
"""
length = len... |
#
# This file contains constants and methods for configurations in the
# TinkerSpaceCommand server.
#
CONFIG_NAME_EXTERNAL_ID = "externalId"
CONFIG_NAME_NAME = "name"
CONFIG_NAME_DESCRIPTION = "description"
CONFIG_NAME_MEASUREMENT_TYPE = "measurementType"
CONFIG_NAME_MEASUREMENT_UNIT = "measurementUnit"
CONFIG_N... | config_name_external_id = 'externalId'
config_name_name = 'name'
config_name_description = 'description'
config_name_measurement_type = 'measurementType'
config_name_measurement_unit = 'measurementUnit'
config_name_sensor_id = 'sensorId'
config_name_sensed_id = 'sensedId'
config_name_channel_ids = 'channelIds'
config_v... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def pseudoPalindromicPaths (self, root: TreeNode) -> int:
counter = [0] * 10
self.cnt = 0
... | class Solution:
def pseudo_palindromic_paths(self, root: TreeNode) -> int:
counter = [0] * 10
self.cnt = 0
def dfs(node, counter):
if node is not None:
counter[node.val] += 1
if node.left is None and node.right is None:
if sum... |
__version__ = "0.3.3"
def version():
return __version__
| __version__ = '0.3.3'
def version():
return __version__ |
"""
Aim: From a list of integers, check and return a set of integers whose sum
will be equal to the target value K.
"""
# Main Recursive function to find the desired Subset Sum
def Subset_Sum(li, target, ans=[]):
# Base Cases
if target == 0 and ans != []:
return ans
elif li == []:
... | """
Aim: From a list of integers, check and return a set of integers whose sum
will be equal to the target value K.
"""
def subset__sum(li, target, ans=[]):
if target == 0 and ans != []:
return ans
elif li == []:
return False
temp = subset__sum(li[1:], target, ans)
if temp:
... |
registry = {}
def access(key):
return registry[key]
| registry = {}
def access(key):
return registry[key] |
#!/usr/bin/env python
# encoding: utf-8
"""Group Polls 2
# Polls
"""
class d:
"""Group Question 2
## Choice [/questions/{question_id}/choices/{choice_id}]
+ Parameters
+ question_id: 1 (required, number) - ID of the Question in form of an integer
+ choice_id: 1 (required, number) - ID of ... | """Group Polls 2
# Polls
"""
class D:
"""Group Question 2
## Choice [/questions/{question_id}/choices/{choice_id}]
+ Parameters
+ question_id: 1 (required, number) - ID of the Question in form of an integer
+ choice_id: 1 (required, number) - ID of the Choice in form of an integer
###... |
# https://en.bitcoin.it/wiki/Secp256k1
_p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
_n = 115792089237316195423570985008687907852837564279074904382605163141518161494337
_a = 0
_b = 7
_gx = int("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", 16)
_gy = int("483ada... | _p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
_n = 115792089237316195423570985008687907852837564279074904382605163141518161494337
_a = 0
_b = 7
_gx = int('79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', 16)
_gy = int('483ada7726a3c4655da4fbfc0e1108a8fd17b448a6855... |
# Print the result of 9 / 2
print(9 / 2)
# Print the result of 7 * 5
print(7 * 5)
# Print the remainder of 5 divided by 2 using %
print(5 % 2) | print(9 / 2)
print(7 * 5)
print(5 % 2) |
# print the tuples for the conflict_table inputs
def print_lines(l):
for e in l:
l2 = l[:]
l2.remove(e)
for f in l2:
l3 = l2[:]
l3.remove(f)
for g in l3:
l4 = l3[:]
l4.remove(g)
for h in l4:
... | def print_lines(l):
for e in l:
l2 = l[:]
l2.remove(e)
for f in l2:
l3 = l2[:]
l3.remove(f)
for g in l3:
l4 = l3[:]
l4.remove(g)
for h in l4:
print((e, f, g, h))
print_lines(['g0', 'g1', '... |
# COLORS
BLACK = (0, 0, 0) # Black
WHITE = (255, 255, 255) # White
YELLOW = (255, 255, 0) # Yellow
RED = (255, 0, 0)
# SCREEN
WIDTH, HEIGHT = (1000, 800) # Screen dims
SCREEN_DIMS = (WIDTH, HEIGHT)
CENTER = (WIDTH // 2, HEIGHT // 2)
# GAME OPTIONS
FPS = 60
PLAYER_SPEED = 1.01
PLAYER_COORD = [
(CENTER[0] - 10, C... | black = (0, 0, 0)
white = (255, 255, 255)
yellow = (255, 255, 0)
red = (255, 0, 0)
(width, height) = (1000, 800)
screen_dims = (WIDTH, HEIGHT)
center = (WIDTH // 2, HEIGHT // 2)
fps = 60
player_speed = 1.01
player_coord = [(CENTER[0] - 10, CENTER[1]), (CENTER[0] + 10, CENTER[1]), (CENTER[0], CENTER[1] - 25)]
player_sen... |
class Pomodorer:
"""Clase que representa la interfaz de comunicacion de un sistema pomodoro"""
def __init__(self, event_system):
self._report = [[]]
self.event_system = event_system
def run_pomodoro(self):
pass
def get_report(self):
agg = []
for series i... | class Pomodorer:
"""Clase que representa la interfaz de comunicacion de un sistema pomodoro"""
def __init__(self, event_system):
self._report = [[]]
self.event_system = event_system
def run_pomodoro(self):
pass
def get_report(self):
agg = []
for series in self.... |
def hexal_to_decimal(s):
""" s in form 0X< hexal digits>
returns int in decimal"""
s = s[2:]
s = s[::-1]
s = list(s)
for i, e in enumerate(s):
if s[i] == "A": s[i] = "10"
if s[i] == "B": s[i] = "11"
if s[i] == "C": s[i] = "12"
if s[i] == "D": s[i] = "13"
if s[i] == "E": s[i] = "14"
if s[i] == "F": s[i... | def hexal_to_decimal(s):
""" s in form 0X< hexal digits>
returns int in decimal"""
s = s[2:]
s = s[::-1]
s = list(s)
for (i, e) in enumerate(s):
if s[i] == 'A':
s[i] = '10'
if s[i] == 'B':
s[i] = '11'
if s[i] == 'C':
s[i] = '12'
if... |
bole=True
n=0
while n<=30:
n=n+1
print(f'ola turma{n}')
break
print('passou') | bole = True
n = 0
while n <= 30:
n = n + 1
print(f'ola turma{n}')
break
print('passou') |
#from cryptomath import *
#import Cryptoalphabet as ca
#alpha = ca.Cryptoalphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
def affine_encode(plaintext, a, b):
process = ""
cipherFinal = ""
modulusValue = len(alphabet)
#removes punctuation from plaintext
for s in plaintext:
if s!= '.' and s!= ',' and s!= ' ' and s!= '!' an... | def affine_encode(plaintext, a, b):
process = ''
cipher_final = ''
modulus_value = len(alphabet)
for s in plaintext:
if s != '.' and s != ',' and (s != ' ') and (s != '!') and (s != '?') and (s != "'"):
process += s
process = process.upper()
for letter in process:
ind... |
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
results = dict()
def solution(N):
# write your code in Python 3.6
# 1000000
if N in results:
return results[N]
else:
result = f_series(N)
results[N] = result
return result
def f... | results = dict()
def solution(N):
if N in results:
return results[N]
else:
result = f_series(N)
results[N] = result
return result
def f_series(n):
if n < 2:
return n
elif n in results:
return results[n]
else:
result = (f_series(n - 1) + f_ser... |
def isgore(a,b):
nbr1=int(a+b)
nbr2=int(b+a)
return nbr1>=nbr2
def largest_number(a):
res = ""
while len(a)!=0:
mx=0
for x in a:
if isgore(str(x),str(mx)):
mx=x
res+=str(mx)
a.remove(mx)
return res
n = int(input())
a = list(map(int,... | def isgore(a, b):
nbr1 = int(a + b)
nbr2 = int(b + a)
return nbr1 >= nbr2
def largest_number(a):
res = ''
while len(a) != 0:
mx = 0
for x in a:
if isgore(str(x), str(mx)):
mx = x
res += str(mx)
a.remove(mx)
return res
n = int(input())
... |
class Converter(object):
"""Base class for all converters."""
def convert_state(self, s, info=None):
"""Convert state to be consumable by the neural network.
Base implementation returns original state.
Parameters
----------
s : obj
State as it is received... | class Converter(object):
"""Base class for all converters."""
def convert_state(self, s, info=None):
"""Convert state to be consumable by the neural network.
Base implementation returns original state.
Parameters
----------
s : obj
State as it is received f... |
weight=1
a = _State('hh', 'naziv')
def run():
@_spawn(_name='haha')
def _():
#with _while(1):
_label('a')
_goto('a')
_label('b')
p1=nazadp.picked()
p2=napredp.picked()
sleep(0.1)
@_do
def _():
# print('drzi ', hex(p1.val), hex(p2.val))
print('drzi ', p1.val, p2.val)
_goto('b')
for i in ran... | weight = 1
a = __state('hh', 'naziv')
def run():
@_spawn(_name='haha')
def _():
_label('a')
_goto('a')
_label('b')
p1 = nazadp.picked()
p2 = napredp.picked()
sleep(0.1)
@_do
def _():
print('drzi ', p1.val, p2.val)
_goto('b')
... |
name = 'Abid'
age = 25
salary = 15.5 # Earning in Ks
print(name, age, salary)
print(' My name is ' + name + ' and my age is ' + str(age) + ' and I earn ' + str(salary) + 'K per month')
| name = 'Abid'
age = 25
salary = 15.5
print(name, age, salary)
print(' My name is ' + name + ' and my age is ' + str(age) + ' and I earn ' + str(salary) + 'K per month') |
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
lista = list()
espacios = 0
print(bcolors.BOLD, "Programa que calcula la longitud de un ... | class Bcolors:
header = '\x1b[95m'
okblue = '\x1b[94m'
okcyan = '\x1b[96m'
okgreen = '\x1b[92m'
warning = '\x1b[93m'
fail = '\x1b[91m'
endc = '\x1b[0m'
bold = '\x1b[1m'
underline = '\x1b[4m'
lista = list()
espacios = 0
print(bcolors.BOLD, 'Programa que calcula la longitud de un texto... |
def create_rooted_spanning_tree(G, root):
def s_rec(root, S):
for node in G[root]:
if node in S:
if root not in S[node]:
S.setdefault(root, {})[node] = 'red'
S[node][root] = 'red'
else:
S.setdefault(root, {})[nod... | def create_rooted_spanning_tree(G, root):
def s_rec(root, S):
for node in G[root]:
if node in S:
if root not in S[node]:
S.setdefault(root, {})[node] = 'red'
S[node][root] = 'red'
else:
S.setdefault(root, {})[no... |
# -*- coding: utf-8 -*-
def test1():
print("test1")
def test2():
print("test2") | def test1():
print('test1')
def test2():
print('test2') |
# This is an AWESOME LIBRARY.
# You can use its AWESOME CLASSES to do Great Things.
# The author however DOESN'T allow you to CHANGE the source code and taint it with Pyro decorators!
class WeirdReturnType(object):
def __init__(self, value):
self.value = value
class AwesomeClass(object):
def method(... | class Weirdreturntype(object):
def __init__(self, value):
self.value = value
class Awesomeclass(object):
def method(self, arg):
print('Awesome object is called with: ', arg)
return 'awesome'
def private(self):
print('This should be a private method...')
return 'bo... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 3 17:27:00 2019
@author: war-machince
"""
docker_path = './'
NFS_path_AoA = docker_path
NFS_path = docker_path
save_NFS = docker_path | """
Created on Wed Jul 3 17:27:00 2019
@author: war-machince
"""
docker_path = './'
nfs_path__ao_a = docker_path
nfs_path = docker_path
save_nfs = docker_path |
class Song:
def __init__(self, name, lenght, single):
self.name = name
self.lenght = lenght
self.single = single
def get_info(self):
return f"{self.name} - {self.lenght}" | class Song:
def __init__(self, name, lenght, single):
self.name = name
self.lenght = lenght
self.single = single
def get_info(self):
return f'{self.name} - {self.lenght}' |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
*****************************************
Author: zhlinh
Email: zhlinhng@gmail.com
Version: 0.0.1
Created Time: 2016-03-06
Last_modify: 2016-03-06
******************************************
'''
'''
Given preorder and inorder traversal of a ... | """
*****************************************
Author: zhlinh
Email: zhlinhng@gmail.com
Version: 0.0.1
Created Time: 2016-03-06
Last_modify: 2016-03-06
******************************************
"""
'\nGiven preorder and inorder traversal of a tree,\nconstruct the binary tree.\n\nNote:\nYou ... |
class BaseEngine(object):
database = ''
def __init__(self, databaseName="epubdb"):
self.databaseName = databaseName
self.databasePath = "databases/" + databaseName
self.open()
pass
def open(self):
'''
Opens the database for reading
'''
p... | class Baseengine(object):
database = ''
def __init__(self, databaseName='epubdb'):
self.databaseName = databaseName
self.databasePath = 'databases/' + databaseName
self.open()
pass
def open(self):
"""
Opens the database for reading
"""
pass
... |
a, b, c = [int(x) for x in input().split()]
if a >= b >= c:
print(c, b, a, sep='\n')
elif a >= c >= b:
print(b, c, a, sep='\n')
elif b >= a >= c:
print(c, a, b, sep='\n')
elif b >= c >= a:
print(a, c, b, sep='\n')
elif c >= a >= b:
print(b, a, c, sep='\n')
elif c >= b >= a:
print(a, b, c, sep='... | (a, b, c) = [int(x) for x in input().split()]
if a >= b >= c:
print(c, b, a, sep='\n')
elif a >= c >= b:
print(b, c, a, sep='\n')
elif b >= a >= c:
print(c, a, b, sep='\n')
elif b >= c >= a:
print(a, c, b, sep='\n')
elif c >= a >= b:
print(b, a, c, sep='\n')
elif c >= b >= a:
print(a, b, c, sep=... |
class ListNode:
def __init__(self, x):
self.x = x
self.val = x
self.next = None
class PointNode:
def __init__(self, x, y):
self.x = x
self.y = y
# Definition for singly-linked list with a random pointer.
class RandomListNode:
def __init__(self, x):
self.labe... | class Listnode:
def __init__(self, x):
self.x = x
self.val = x
self.next = None
class Pointnode:
def __init__(self, x, y):
self.x = x
self.y = y
class Randomlistnode:
def __init__(self, x):
self.label = x
self.next = None
self.random = Non... |
"""
These classes are used to represent the objects drawn on a drawing layer.
**Note**
These calsses should be kept picklable to be sent over a Pipe
Not to be confused with classes in Detection.* . In addition to coordinates
thse also store color, alpha and other displaying parameters
"""
class Line(object):
d... | """
These classes are used to represent the objects drawn on a drawing layer.
**Note**
These calsses should be kept picklable to be sent over a Pipe
Not to be confused with classes in Detection.* . In addition to coordinates
thse also store color, alpha and other displaying parameters
"""
class Line(object):
d... |
class OTMSConfig(object):
MYSQL_DATABASE_USER = 'root'
MYSQL_DATABASE_PASSWORD = ''
MYSQL_DATABASE_DB = 'otms'
MYSQL_DATABASE_PORT = '3308'
MYSQL_DATABASE_HOST = 'localhost' | class Otmsconfig(object):
mysql_database_user = 'root'
mysql_database_password = ''
mysql_database_db = 'otms'
mysql_database_port = '3308'
mysql_database_host = 'localhost' |
#
# Simple Image
#
# Copyright 2017, Adam Edwards
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | class Simpleimage:
def __init__(self, width, height, is_sparse=False, default_color=0):
self.__width = width
self.__height = height
self.__sparse_size = 0
self.__default_color = default_color
self.__is_sparse = is_sparse
self.__sparse_map = {}
self.__image_da... |
class Scene(object):
"""
Base class for all Scene objects
Contains the base functionalities and the functions that all derived classes need to implement
"""
def __init__(self):
self.build_graph = False # Indicates if a graph for shortest path has been built
self.floor_body_ids = []... | class Scene(object):
"""
Base class for all Scene objects
Contains the base functionalities and the functions that all derived classes need to implement
"""
def __init__(self):
self.build_graph = False
self.floor_body_ids = []
def load(self):
"""
Load the scene ... |
'''
Created on 09.03.2019
@author: Nicco
'''
class act_base(object):
'''
providing all the methods to connect to the simulator, and plan
'''
def __init__(self, params):
'''
Constructor
'''
| """
Created on 09.03.2019
@author: Nicco
"""
class Act_Base(object):
"""
providing all the methods to connect to the simulator, and plan
"""
def __init__(self, params):
"""
Constructor
""" |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold(s):
maxvalue = 0
i = 1
for i in range(s - 1):
j = 1
for j in range(s):
k = s ... | def f_gold(s):
maxvalue = 0
i = 1
for i in range(s - 1):
j = 1
for j in range(s):
k = s - i - j
maxvalue = max(maxvalue, i * j * k)
return maxvalue
if __name__ == '__main__':
param = [(67,), (48,), (59,), (22,), (14,), (66,), (1,), (75,), (58,), (78,)]
n_s... |
# DROP TABLES
songplay_table_drop = "DROP TABLE IF EXISTS songplays"
user_table_drop = "DROP TABLE IF EXISTS users"
song_table_drop = "DROP TABLE IF EXISTS songs"
artist_table_drop = "DROP TABLE IF EXISTS artsts"
time_table_drop = "DROP TABLE IF EXISTS time"
# CREATE TABLES one facts table and four dimensions tables ... | songplay_table_drop = 'DROP TABLE IF EXISTS songplays'
user_table_drop = 'DROP TABLE IF EXISTS users'
song_table_drop = 'DROP TABLE IF EXISTS songs'
artist_table_drop = 'DROP TABLE IF EXISTS artsts'
time_table_drop = 'DROP TABLE IF EXISTS time'
songplay_table_create = 'CREATE TABLE IF NOT EXISTS songplays (\n songpl... |
msg = "\nU cannot do it with the zero under there!!!"
def mean(num_list):
if len(num_list)== 0:
raise Exception(msg)
else:
return sum(num_list)/len(num_list)
def mean2(num_list):
try:
return sum(num_list)/len(num_list)
except ZeroDivisionError as detail:
raise ZeroDivisionError(detail.__str__() + msg)
e... | msg = '\nU cannot do it with the zero under there!!!'
def mean(num_list):
if len(num_list) == 0:
raise exception(msg)
else:
return sum(num_list) / len(num_list)
def mean2(num_list):
try:
return sum(num_list) / len(num_list)
except ZeroDivisionError as detail:
raise zero... |
# where output is the value per line
# loop through the values
# print the value of the letter plus the next letter for n number of times
# n = a number (1-10) that represents how many characters are in a line
# once you have printed n number of times, '\n'
output = ''
#for value in range(65, 91, 1):
for i in range... | output = ''
for i in range(5):
for j in range(i + 1):
print('* ', end='')
print('\n') |
""" Task
Given an integer, n, perform the following conditional actions:
If is odd, print Weird
If is even and in the inclusive 2 range 5 of to , print Not Weird
If is even and in the inclusive 6 range of 20 to , print Weird
If is even and greater than 20, print Not Weird """
n = int(input("Write a number: "))... | """ Task
Given an integer, n, perform the following conditional actions:
If is odd, print Weird
If is even and in the inclusive 2 range 5 of to , print Not Weird
If is even and in the inclusive 6 range of 20 to , print Weird
If is even and greater than 20, print Not Weird """
n = int(input('Write a number: '))
i... |
#!/usr/bin/env python3
N, T = list(map(int, input().strip().split(' ')))
width = list(map(int, input().strip().split(' ')))
for _ in range(T):
i, j = list(map(int, input().strip().split(' ')))
print(min(width[i:j + 1]))
| (n, t) = list(map(int, input().strip().split(' ')))
width = list(map(int, input().strip().split(' ')))
for _ in range(T):
(i, j) = list(map(int, input().strip().split(' ')))
print(min(width[i:j + 1])) |
# Task
# Apply your knowledge of the .add() operation to help your friend Rupal.
# Rupal has a huge collection of country stamps. She decided to count the
# total number of distinct country stamps in her collection. She asked for
# your help. You pick the stamps one by one from a stack of N country stamps.
# Find the t... | n = int(input())
countries = set()
for i in range(N):
countries.add(input())
print(len(countries)) |
class Window(object):
def __init__(self, win_id, name, geom=None, d_num=None):
self.win_id = win_id
self.name = name
self.geom = geom
self.children = []
self.desktop_number = d_num
return
def __repr__(self):
"""
An inheritable string representatio... | class Window(object):
def __init__(self, win_id, name, geom=None, d_num=None):
self.win_id = win_id
self.name = name
self.geom = geom
self.children = []
self.desktop_number = d_num
return
def __repr__(self):
"""
An inheritable string representati... |
def add_numbers(x, y):
""" add two numbers and return the result"""
return x + y
def subtract_numbers(x, y):
if x > y:
return x - y
elif x < y:
return y - x
else:
return 0
| def add_numbers(x, y):
""" add two numbers and return the result"""
return x + y
def subtract_numbers(x, y):
if x > y:
return x - y
elif x < y:
return y - x
else:
return 0 |
# solution by erine_y, py3
bijectiveNumeration = lambda n, d: d[n//100]+"%03d"%~(~-n%99)
"""
You need to label a set of indices; ideally something a little more human friendly than just a number.
What was decided was to use a character, or set of characters, hyphenated with a two digit number.
Example
For n = 134 a... | bijective_numeration = lambda n, d: d[n // 100] + '%03d' % ~(~-n % 99)
'\nYou need to label a set of indices; ideally something a little more human friendly than just a number.\n\nWhat was decided was to use a character, or set of characters, hyphenated with a two digit number.\n\nExample\nFor n = 134 and domain = ["MO... |
def get_profile(name: str, age: int, *args, **kwargs):
if len(list(args)) > 5:
raise ValueError
if not isinstance(age, int):
raise ValueError
profile = dict(name=name, age=age,)
if args:
profile.update(sports=sorted(list(args)))
if kwargs:
profile.update(awards=kwarg... | def get_profile(name: str, age: int, *args, **kwargs):
if len(list(args)) > 5:
raise ValueError
if not isinstance(age, int):
raise ValueError
profile = dict(name=name, age=age)
if args:
profile.update(sports=sorted(list(args)))
if kwargs:
profile.update(awards=kwargs)... |
class Klasse:
def __init__(self, wert):
self.attribut = wert
def print_attribut(self):
print(self.attribut)
def main():
a = Klasse(3)
b = Klasse(12)
a.attribut = -a.attribut
b.print_attribut()
| class Klasse:
def __init__(self, wert):
self.attribut = wert
def print_attribut(self):
print(self.attribut)
def main():
a = klasse(3)
b = klasse(12)
a.attribut = -a.attribut
b.print_attribut() |
# Time: O(nlogn)
# Space: O(1)
class Interval(object):
def __init__(self, s=0, e=0):
self.start = s
self.end = e
def __repr__(self):
return "[{}, {}]".format(self.start, self.end)
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Inter... | class Interval(object):
def __init__(self, s=0, e=0):
self.start = s
self.end = e
def __repr__(self):
return '[{}, {}]'.format(self.start, self.end)
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interv... |
def uninstall(distro, purge=False):
packages = [
'ceph',
'ceph-mds',
'ceph-common',
'ceph-fs-common',
'radosgw',
]
extra_remove_flags = []
if purge:
extra_remove_flags.append('--purge')
distro.packager.remove(
packages,
extra_remove... | def uninstall(distro, purge=False):
packages = ['ceph', 'ceph-mds', 'ceph-common', 'ceph-fs-common', 'radosgw']
extra_remove_flags = []
if purge:
extra_remove_flags.append('--purge')
distro.packager.remove(packages, extra_remove_flags=extra_remove_flags) |
class Solution:
def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:
sentence = sentence.split()
k = len(searchWord)
for i, word in enumerate(sentence):
if word[:k] == searchWord:
return i+1
return -1
| class Solution:
def is_prefix_of_word(self, sentence: str, searchWord: str) -> int:
sentence = sentence.split()
k = len(searchWord)
for (i, word) in enumerate(sentence):
if word[:k] == searchWord:
return i + 1
return -1 |
class GenderParity:
"""
Gender parity metric from https://github.com/decompositional-semantics-initiative/DNC.
"""
def __init__(self):
self.same_preds = 0.0
self.diff_preds = 0.0
def get_metric(self, reset=False):
if self.same_preds + self.diff_preds == 0:
retur... | class Genderparity:
"""
Gender parity metric from https://github.com/decompositional-semantics-initiative/DNC.
"""
def __init__(self):
self.same_preds = 0.0
self.diff_preds = 0.0
def get_metric(self, reset=False):
if self.same_preds + self.diff_preds == 0:
retur... |
#
# PySNMP MIB module WLSX-WLAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WLSX-WLAN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:36:48 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (wlsx_enterprise_mib_modules,) = mibBuilder.importSymbols('ARUBA-MIB', 'wlsxEnterpriseMibModules')
(aruba_vlan_valid_range, aruba_rogue_ap_type, aruba_ap_status, aruba_access_point_mode, aruba_monitor_mode, aruba_antenna_setting, aruba_enet1_mode, aruba_phy_type, aruba_ht_mode, aruba_voip_protocol_type, aruba_mesh_role... |
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 5 21:40:27 2019
@author: Abhishek Mukherjee
"""
#Size of set A ~~~ M
M=list(map(int, input()))
#list A
listA=list(map(int, input().split()))
#Size of set B ~~~ N
N=list(map(int, input()))
#list B
listB=list(map(int, input().split()))
#Set A
setA=... | """
Created on Fri Jul 5 21:40:27 2019
@author: Abhishek Mukherjee
"""
m = list(map(int, input()))
list_a = list(map(int, input().split()))
n = list(map(int, input()))
list_b = list(map(int, input().split()))
set_a = set()
set_b = set()
for i in range(M[0]):
setA.add(listA[i])
for i in range(N[0]):
setB.add(l... |
class Salsa:
def __init__(self,r=20):
assert r >= 0
self._r = r # number of rounds
self._mask = 0xffffffff # 32-bit mask
def __call__(self,key=[0]*32,nonce=[0]*8,block_counter=[0]*8):
assert len(key) == 32
assert len(nonce) == 8
assert len(block_counter) == 8
# init state
k ... | class Salsa:
def __init__(self, r=20):
assert r >= 0
self._r = r
self._mask = 4294967295
def __call__(self, key=[0] * 32, nonce=[0] * 8, block_counter=[0] * 8):
assert len(key) == 32
assert len(nonce) == 8
assert len(block_counter) == 8
k = [self._little... |
def parentheses_balance_stack_check(expression):
open_list, close_list, stack = ['[', '{', '('], [']', '}', ')'], []
for i in expression:
if i in open_list:
stack.append(i)
elif i in close_list:
pos = close_list.index(i)
if len(stack) > 0 and open_list[pos] == stack[len(stack) - 1]:
... | def parentheses_balance_stack_check(expression):
(open_list, close_list, stack) = (['[', '{', '('], [']', '}', ')'], [])
for i in expression:
if i in open_list:
stack.append(i)
elif i in close_list:
pos = close_list.index(i)
if len(stack) > 0 and open_list[pos... |
# -*- coding: utf-8 -*-
#%% configs
VOCdatasetConfig= {
'rootDir': "D:\GitHubRepos\ML_learning\VOC2007",
'imageFolder': "JPEGImages",
'imageExtension': ".jpg",
'annotationFolder': "Annotations",
'annotationExtension': ".xml",
'trainCasesPath': "ImageSets\Segmentation\\train.txt",
'valCase... | vo_cdataset_config = {'rootDir': 'D:\\GitHubRepos\\ML_learning\\VOC2007', 'imageFolder': 'JPEGImages', 'imageExtension': '.jpg', 'annotationFolder': 'Annotations', 'annotationExtension': '.xml', 'trainCasesPath': 'ImageSets\\Segmentation\\train.txt', 'valCasesPath': 'ImageSets\\Segmentation\\val.txt', 'textFileFolder':... |
def get_sunday_count():
sunday_count = 0
for i in range(1901, 2000):
for j in range(1, 12):
for k in range(1, get_number_of_days(j, i)):
if j == 2000:
c = 20
else:
c = 19
f = k + ((13 * j - 1) / 5) + ((i ... | def get_sunday_count():
sunday_count = 0
for i in range(1901, 2000):
for j in range(1, 12):
for k in range(1, get_number_of_days(j, i)):
if j == 2000:
c = 20
else:
c = 19
f = k + (13 * j - 1) / 5 + (i - 1... |
"""
0068. Text Justification
Hard
Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when n... | """
0068. Text Justification
Hard
Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when n... |
#
# PySNMP MIB module PCUBE-SE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PCUBE-SE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:11:29 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint, constraints_union) ... |
# coding=utf-8
"""
This package provides a session authentication for TheTVDB.
"""
| """
This package provides a session authentication for TheTVDB.
""" |
MODEL_FOLDER_NAME = 'models'
FASTTEXT_MODEL_NAME = 'fasttext.magnitude'
GLOVE_MODEL_NAME = 'glove.magnitude'
WORD2VEC_MODEL_NAME = 'word2vec.magnitude'
ELMO_MODEL_NAME = 'elmo.magnitude'
BERT_MODEL_NAME = ''
UNIVERSAL_SENTENCE_ENCODER_MODEL_NAME = 'https://tfhub.dev/google/universal-sentence-encoder/1'
DB_STORAGE_TYPE ... | model_folder_name = 'models'
fasttext_model_name = 'fasttext.magnitude'
glove_model_name = 'glove.magnitude'
word2_vec_model_name = 'word2vec.magnitude'
elmo_model_name = 'elmo.magnitude'
bert_model_name = ''
universal_sentence_encoder_model_name = 'https://tfhub.dev/google/universal-sentence-encoder/1'
db_storage_type... |
def CHECK(UNI, PWI, usernameArray, PasswordArray):
for UN in usernameArray:
if UN == UNI:
for PW in PasswordArray:
if PW == PWI:
if usernameArray.index(UNI) == PasswordArray.index(PWI):
return True
def login(correctMessage,... | def check(UNI, PWI, usernameArray, PasswordArray):
for un in usernameArray:
if UN == UNI:
for pw in PasswordArray:
if PW == PWI:
if usernameArray.index(UNI) == PasswordArray.index(PWI):
return True
def login(correctMessage, inCorrectMe... |
m = [
'common',
'leap'
]
y = 2024
# outside in
if y%4 ==0:
if y%100 ==0:
if y%400 ==0:
y=1
else:
y=0
else:
y=1
else:
y=0
print(m[y])
# inside out
y=2024
if y%400==0:
y=1
elif y%100==0:
y=0
elif y%4==0:
y=1
else:
y=0
print(m[y])... | m = ['common', 'leap']
y = 2024
if y % 4 == 0:
if y % 100 == 0:
if y % 400 == 0:
y = 1
else:
y = 0
else:
y = 1
else:
y = 0
print(m[y])
y = 2024
if y % 400 == 0:
y = 1
elif y % 100 == 0:
y = 0
elif y % 4 == 0:
y = 1
else:
y = 0
print(m[y])
y = 2... |
def create_markdown_content(
input_file: str,
import_list: list[str],
global_import_table: dict[str,str],
mermaid_diagrams: list[str],
debug_dump: str,
) -> str:
debug_block = create_markdown_debug_dump_block(debug_content=debug_dump)
import_block = turn_out_the_import_list(
import_... | def create_markdown_content(input_file: str, import_list: list[str], global_import_table: dict[str, str], mermaid_diagrams: list[str], debug_dump: str) -> str:
debug_block = create_markdown_debug_dump_block(debug_content=debug_dump)
import_block = turn_out_the_import_list(import_list=import_list, global_import_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.