content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def dato(diametro):
if diametro == 1:
# varilla de 8mm
return 0.40
if diametro == 0:
# varilla de 12mm
return 0.60
if diametro == 2:
# varilla de 14mm
return 0.70
if diametro == 3:
# varilla de 16mm
return 0.80
if diametro == 4:
... | def dato(diametro):
if diametro == 1:
return 0.4
if diametro == 0:
return 0.6
if diametro == 2:
return 0.7
if diametro == 3:
return 0.8
if diametro == 4:
return 0.9
if diametro == 5:
return 1 |
match x:
case Class(1,
foo=2,
bar=3):
pass | match x:
case Class(1, foo=2, bar=3):
pass |
class Matrice:
def __init__(self, n_init):
self.n = n_init
self.C = []
self.I = []
self.L = [int(0)] * (n_init+1)
def __str__(self):
return "Matrice({})\nC: {}\nI: {}\nL: {}\n".format(self.n, self.C, self.I, self.L)
def set(self, i, j, value):
"""
In... | class Matrice:
def __init__(self, n_init):
self.n = n_init
self.C = []
self.I = []
self.L = [int(0)] * (n_init + 1)
def __str__(self):
return 'Matrice({})\nC: {}\nI: {}\nL: {}\n'.format(self.n, self.C, self.I, self.L)
def set(self, i, j, value):
"""
... |
# https://leetcode.com/problems/minimize-maximum-pair-sum-in-array
class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums = sorted(nums)
ans = 0
for i in range(len(nums) // 2):
val = nums[i] + nums[-1 - i]
ans = max(ans, val)
return ans
| class Solution:
def min_pair_sum(self, nums: List[int]) -> int:
nums = sorted(nums)
ans = 0
for i in range(len(nums) // 2):
val = nums[i] + nums[-1 - i]
ans = max(ans, val)
return ans |
# Non-OOP
# Bank Version 1
# Single account
accountName = 'Joe'
accountBalance = 100
accountPassword = 'soup'
while True:
print()
print('Press b to get the balance')
print('Press d to make a deposit')
print('Press w to make a withdrawal')
print('Press s to show the account')
print('Press q to ... | account_name = 'Joe'
account_balance = 100
account_password = 'soup'
while True:
print()
print('Press b to get the balance')
print('Press d to make a deposit')
print('Press w to make a withdrawal')
print('Press s to show the account')
print('Press q to quit')
print()
action = input('What... |
class VariablesDict:
"""
A VariablesDict is a sort of dictionary with special
features, created to manage the variables of a monomial.
In this case, we'll call keys variables and
values exponents.
Its main features are:
- A VariablesDict is immutable
- The default exponent is 0; there... | class Variablesdict:
"""
A VariablesDict is a sort of dictionary with special
features, created to manage the variables of a monomial.
In this case, we'll call keys variables and
values exponents.
Its main features are:
- A VariablesDict is immutable
- The default exponent is 0; there... |
def getball():
rest()
i01.setHandSpeed("right", 0.85, 0.75, 0.75, 0.75, 0.85, 0.75)
i01.setArmSpeed("right", 1.0, 1.0, 1.0, 0.85)
i01.setHeadSpeed(0.9, 0.9)
i01.setTorsoSpeed(0.75, 0.55, 1.0)
i01.moveHead(45,65)
i01.moveArm("left",5,90,16,15)
i01.moveArm("right",6,85,110,22)
i01.moveHand("left",50,50,... | def getball():
rest()
i01.setHandSpeed('right', 0.85, 0.75, 0.75, 0.75, 0.85, 0.75)
i01.setArmSpeed('right', 1.0, 1.0, 1.0, 0.85)
i01.setHeadSpeed(0.9, 0.9)
i01.setTorsoSpeed(0.75, 0.55, 1.0)
i01.moveHead(45, 65)
i01.moveArm('left', 5, 90, 16, 15)
i01.moveArm('right', 6, 85, 110, 22)
... |
"""
from: http://adventofcode.com/2017/day/2
--- Day 2: Corruption Checksum ---
As you walk through the door, a glowing humanoid shape yells in your direction. "You there! Your
state appears to be idle. Come help us repair the corruption in this spreadsheet - if we take
another millisecond, we'll have to display an ho... | """
from: http://adventofcode.com/2017/day/2
--- Day 2: Corruption Checksum ---
As you walk through the door, a glowing humanoid shape yells in your direction. "You there! Your
state appears to be idle. Come help us repair the corruption in this spreadsheet - if we take
another millisecond, we'll have to display an ho... |
"""
Scripts using nmap
"""
# TODO: Check if nmap is accessible.
def Usable(entity_type, entity_ids_arr):
"""Nmap must be accessible"""
return True
| """
Scripts using nmap
"""
def usable(entity_type, entity_ids_arr):
"""Nmap must be accessible"""
return True |
# config.py
cfg = {
'name': 'Retinaface',
'min_sizes': [[16, 32], [64, 128], [256, 512]],
'steps': [8, 16, 32],
'variance': [0.1, 0.2],
'clip': False,
'loc_weight': 2.0,
'gpu_train': True
}
| cfg = {'name': 'Retinaface', 'min_sizes': [[16, 32], [64, 128], [256, 512]], 'steps': [8, 16, 32], 'variance': [0.1, 0.2], 'clip': False, 'loc_weight': 2.0, 'gpu_train': True} |
class Publisher:
def __init__(self):
self.observers = []
def add(self, observer):
if observer not in self.observers:
self.observers.append(observer)
else:
print(f'Failed to add: {observer}')
def remove(self, observer):
... | class Publisher:
def __init__(self):
self.observers = []
def add(self, observer):
if observer not in self.observers:
self.observers.append(observer)
else:
print(f'Failed to add: {observer}')
def remove(self, observer):
try:
self.observer... |
# https://www.acmicpc.net/problem/1110
class PlusCycle(object):
def get_new_number(self, num):
sum_of_each = int(num[0]) + int(num[1])
return str(num[1]) + str(sum_of_each%10)
def get_cycle(self, n):
n = '{:02d}'.format(int(n))
target = n
count = 1
ne... | class Pluscycle(object):
def get_new_number(self, num):
sum_of_each = int(num[0]) + int(num[1])
return str(num[1]) + str(sum_of_each % 10)
def get_cycle(self, n):
n = '{:02d}'.format(int(n))
target = n
count = 1
new_number = self.get_new_number(n)
while ... |
#
# PySNMP MIB module NASUNI-FILER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file://text/NASUNI-FILER-MIB
# Produced by pysmi-0.3.4 at Mon Sep 20 10:57:46 2021
# On host C02YJ1DPJHD2 platform Darwin version 20.4.0 by user mpipaliya
# Using Python version 3.7.4 (default, Oct 12 2019, 18:55:28)
#
Integer, OctetStri... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint) ... |
"""GCP saving package
This package contains the modules for managing your services timelife and costs.
The package works if you have added some tags on your objects:
see the documentation on https://gcp-saving.readthedocs.io/en/latest/
It is part of the educational repositories (https://github.com/pandle/materials)
t... | """GCP saving package
This package contains the modules for managing your services timelife and costs.
The package works if you have added some tags on your objects:
see the documentation on https://gcp-saving.readthedocs.io/en/latest/
It is part of the educational repositories (https://github.com/pandle/materials)
t... |
class VersionMixin(object):
def _get_versioned_class(self, attribute):
attribute = getattr(self, attribute)
version = self.request.version
# Return default if version is not specified
if not version:
return attribute["default"]
try:
# Return version
... | class Versionmixin(object):
def _get_versioned_class(self, attribute):
attribute = getattr(self, attribute)
version = self.request.version
if not version:
return attribute['default']
try:
return attribute[version]
except KeyError:
return a... |
def area():
return larg * comp
larg = float(input('informe a largura '))
comp = float(input('informe o comprimento '))
print(area()) | def area():
return larg * comp
larg = float(input('informe a largura '))
comp = float(input('informe o comprimento '))
print(area()) |
def csvReader(file):
''' Reads a csv file creates a dictionary with the first three
comma seperated values of each line key and the fourth as value. '''
fileObject = open(file)
data = fileObject.readlines()
dic = {}
for i in range(0,len(data)):
try:
dic[data[i].strip... | def csv_reader(file):
""" Reads a csv file creates a dictionary with the first three
comma seperated values of each line key and the fourth as value. """
file_object = open(file)
data = fileObject.readlines()
dic = {}
for i in range(0, len(data)):
try:
dic[data[i].strip('\n')... |
"""
LeetCode Problem 219. Contains Duplicate II
Link: https://leetcode.com/problems/contains-duplicate-ii/
Written by: Mostofa Adib Shakib
Language: Python
Time Complexity: O(n)
Space Complexity: O(n)
"""
class Solution:
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
# Initializing a ... | """
LeetCode Problem 219. Contains Duplicate II
Link: https://leetcode.com/problems/contains-duplicate-ii/
Written by: Mostofa Adib Shakib
Language: Python
Time Complexity: O(n)
Space Complexity: O(n)
"""
class Solution:
def contains_nearby_duplicate(self, nums: List[int], k: int) -> bool:
hashmap = {}
... |
class Room:
def __init__(self):
self.room_number = 0
self.room_things = {
"room": {
"look": "A room.",
"pickup": "Don't be ridiculous.",
"approach": "You're already in the room, man. No need.",
"hit": "You kick and hit aroun... | class Room:
def __init__(self):
self.room_number = 0
self.room_things = {'room': {'look': 'A room.', 'pickup': "Don't be ridiculous.", 'approach': "You're already in the room, man. No need.", 'hit': 'You kick and hit around the room. Nothing happens.', 'synonyms': {'space', 'area', 'environment', '... |
"""
:copyright: (c) 2020 Yotam Rechnitz
:license: MIT, see LICENSE for more details
"""
class MatchAwards:
def __init__(self, js: dict):
try:
self._cards = js["cards"]
except KeyError:
self._cards = 0
self._medals = js["medals"]
self._medalsBronze = js["medals... | """
:copyright: (c) 2020 Yotam Rechnitz
:license: MIT, see LICENSE for more details
"""
class Matchawards:
def __init__(self, js: dict):
try:
self._cards = js['cards']
except KeyError:
self._cards = 0
self._medals = js['medals']
self._medalsBronze = js['meda... |
# solution 1
a = [1,2,1,3,4,5,5]
a = list(set(a))
print(a)
# solution 2
a = [1,2,1,3,4,5,5]
res = []
for i in a:
if i not in res:
res.append(i)
print(res)
| a = [1, 2, 1, 3, 4, 5, 5]
a = list(set(a))
print(a)
a = [1, 2, 1, 3, 4, 5, 5]
res = []
for i in a:
if i not in res:
res.append(i)
print(res) |
class Udp(object):
output_fields = (
'saddr', 'saddr-raw', 'daddr', 'daddr-raw', 'ipid', 'ttl', 'classification', 'success', 'sport', 'dport',
'icmp_responder', 'icmp_type', 'icmp_code', 'icmp_unreach_str', 'udp_pkt_size', 'data', 'repeat', 'cooldown',
'timestamp-str', 'timestamp-ts', 'time... | class Udp(object):
output_fields = ('saddr', 'saddr-raw', 'daddr', 'daddr-raw', 'ipid', 'ttl', 'classification', 'success', 'sport', 'dport', 'icmp_responder', 'icmp_type', 'icmp_code', 'icmp_unreach_str', 'udp_pkt_size', 'data', 'repeat', 'cooldown', 'timestamp-str', 'timestamp-ts', 'timestamp-us')
def __init... |
#Creacion de la clase
class Persona:
def __init__(self, nombre, edad):
self.__nombre = nombre
self.__edad = edad
def __str__(self):
return "Nombre: "+self.__nombre+" y edad : "+str(self.__edad)
| class Persona:
def __init__(self, nombre, edad):
self.__nombre = nombre
self.__edad = edad
def __str__(self):
return 'Nombre: ' + self.__nombre + ' y edad : ' + str(self.__edad) |
class Allergies:
def __init__(self, score):
self.score = score
def allergic_to(self, item):
return item in self.lst
@property
def lst(self):
allergieList = ['eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']
allergicTo = list()
... | class Allergies:
def __init__(self, score):
self.score = score
def allergic_to(self, item):
return item in self.lst
@property
def lst(self):
allergie_list = ['eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']
allergic_to = list()... |
'''API END_POINT'''
CENTER_CODE = 'PUT YOUR CENTER CODE HERE!!!!'
API_ENDPOINT = "PUT YOUR URL HERE!!!!"
URL_TIMEOUT = 3
'''QR Scanners config'''
IN_SCANNER = '/dev/ttyUSB0'
OUT_SCANNER = '/dev/ttyUSB1'
WAIT_SECONDS_BLOCK_DOOR = 2.5
NUM_SCANNERS = 2
'''I2C Bus Options'''
DEVICE_BUS = 1
PHY_DOORS_NUMBERS = 1
DEVICE_AD... | """API END_POINT"""
center_code = 'PUT YOUR CENTER CODE HERE!!!!'
api_endpoint = 'PUT YOUR URL HERE!!!!'
url_timeout = 3
'QR Scanners config'
in_scanner = '/dev/ttyUSB0'
out_scanner = '/dev/ttyUSB1'
wait_seconds_block_door = 2.5
num_scanners = 2
'I2C Bus Options'
device_bus = 1
phy_doors_numbers = 1
device_addr_door_1_... |
def bubble_sort(nums):
for i in range(len(nums) - 1):
for j in range(len(nums) - i - 1):
if nums[j] > nums[j + 1]:
nums[j + 1], nums[j] = nums[j], nums[j + 1]
return nums
def quick_sort(nums):
if len(nums) < 1:
return nums
p = nums[0]
l = []
r = []
... | def bubble_sort(nums):
for i in range(len(nums) - 1):
for j in range(len(nums) - i - 1):
if nums[j] > nums[j + 1]:
(nums[j + 1], nums[j]) = (nums[j], nums[j + 1])
return nums
def quick_sort(nums):
if len(nums) < 1:
return nums
p = nums[0]
l = []
r = [... |
XK_ISO_Lock = 0xFE01
XK_ISO_Level2_Latch = 0xFE02
XK_ISO_Level3_Shift = 0xFE03
XK_ISO_Level3_Latch = 0xFE04
XK_ISO_Level3_Lock = 0xFE05
XK_ISO_Group_Shift = 0xFF7E
XK_ISO_Group_Latch = 0xFE06
XK_ISO_Group_Lock = 0xFE07
XK_ISO_Next_Group = 0xFE08
XK_ISO_Next_Group_Lock = 0xFE09
XK_ISO_Prev_Group = 0xFE0A
XK_ISO_Prev_Gro... | xk_iso__lock = 65025
xk_iso__level2__latch = 65026
xk_iso__level3__shift = 65027
xk_iso__level3__latch = 65028
xk_iso__level3__lock = 65029
xk_iso__group__shift = 65406
xk_iso__group__latch = 65030
xk_iso__group__lock = 65031
xk_iso__next__group = 65032
xk_iso__next__group__lock = 65033
xk_iso__prev__group = 65034
xk_i... |
names = {'anonymous','tazri','focasa','troy','farha'};
# can use for loop for access names sets
for name in names :
print("Hello, "+name.title()+"!");
# can check value is exist in sets ?
print("\n'tazri' in names : ",'tazri' in names);
print("'solus' not in names : ",'solus' not in names);
print("'xenon' in name... | names = {'anonymous', 'tazri', 'focasa', 'troy', 'farha'}
for name in names:
print('Hello, ' + name.title() + '!')
print("\n'tazri' in names : ", 'tazri' in names)
print("'solus' not in names : ", 'solus' not in names)
print("'xenon' in names : ", 'xenon' in names) |
def GenerateConfig(context):
resources = []
project = context.env["project"]
zone = context.properties["zone"]
instance_name = "gcp-vm-" + context.env["project"]
machine_type = context.properties["machineType"]
resources.append({
"name": instance_name,
"type": "compute.v1.i... | def generate_config(context):
resources = []
project = context.env['project']
zone = context.properties['zone']
instance_name = 'gcp-vm-' + context.env['project']
machine_type = context.properties['machineType']
resources.append({'name': instance_name, 'type': 'compute.v1.instances', 'properties... |
my_vals = [623, '43', 324.523, '23', '23.23', 234, '342']
def add(values):
'''take a list of values and adds them up
We assume that the contents of the list is either int, float or str
where strings are numbers that can be converted to an int/float
Parameters
----------
values : list (any)
... | my_vals = [623, '43', 324.523, '23', '23.23', 234, '342']
def add(values):
"""take a list of values and adds them up
We assume that the contents of the list is either int, float or str
where strings are numbers that can be converted to an int/float
Parameters
----------
values : list (any)
... |
class Solution:
"""
@param nums: the sorted matrix
@return: the number of Negative Number
"""
def countNumber(self, nums):
if not nums or not nums[0]:
return 0
n = len(nums)
m = len(nums[0])
i = 0
j = m - 1
count = 0
while i < n an... | class Solution:
"""
@param nums: the sorted matrix
@return: the number of Negative Number
"""
def count_number(self, nums):
if not nums or not nums[0]:
return 0
n = len(nums)
m = len(nums[0])
i = 0
j = m - 1
count = 0
while i < n a... |
PPTIK_GRAVITY = 9.77876
class StationKind:
V1 = 'L'
STATIONARY = 'S'
MOBILE = 'M'
class StationState:
ALERT = 'A'
READY = 'R'
ECO = 'E'
HIGH_RATE = 'H'
NORMAL_RATE = 'N'
LOST = 'L' | pptik_gravity = 9.77876
class Stationkind:
v1 = 'L'
stationary = 'S'
mobile = 'M'
class Stationstate:
alert = 'A'
ready = 'R'
eco = 'E'
high_rate = 'H'
normal_rate = 'N'
lost = 'L' |
# 1st solution
class Solution:
def intervalIntersection(self, firstList: List[List[int]], secondList: List[List[int]]) -> List[List[int]]:
if not firstList or not secondList:
return []
first, second = 0, 0
result = []
while first < len(firstList) and second < len(secondLi... | class Solution:
def interval_intersection(self, firstList: List[List[int]], secondList: List[List[int]]) -> List[List[int]]:
if not firstList or not secondList:
return []
(first, second) = (0, 0)
result = []
while first < len(firstList) and second < len(secondList):
... |
#
# PySNMP MIB module WWP-VOIP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-VOIP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:32:08 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_size_constraint, value_range_constraint, constraints_intersection) ... |
graph = {
'5' : ['3','7'],
'3' : ['2', '4'],
'7' : ['8'],
'2' : [],
'4' : ['8'],
'8' : []
}
# List for visited nodes.
visited = []
#Initialize a queue
queue = []
# distance initialization (dict)
dist = {}
#function for BFS
def bfs_shortest_path(visited, graph, start_node, end_node):... | graph = {'5': ['3', '7'], '3': ['2', '4'], '7': ['8'], '2': [], '4': ['8'], '8': []}
visited = []
queue = []
dist = {}
def bfs_shortest_path(visited, graph, start_node, end_node):
global dist
dist[start_node] = 0
visited.append(start_node)
queue.append(start_node)
if start_node == end_node:
... |
#!/usr/bin/env python
"""Example of raising an exception where b() has a finally clause and a()
catches the exception.
Created on Aug 19, 2011
@author: paulross
"""
class ExceptionNormal(Exception):
pass
class ExceptionCleanUp(Exception):
pass
def a():
try:
b()
except ExceptionNormal as err... | """Example of raising an exception where b() has a finally clause and a()
catches the exception.
Created on Aug 19, 2011
@author: paulross
"""
class Exceptionnormal(Exception):
pass
class Exceptioncleanup(Exception):
pass
def a():
try:
b()
except ExceptionNormal as err:
print(' a()... |
def star():
print("How Much Rows You Want")
n = int(input())
print("Enter 1 or Non Zero for True and 0 For False")
n2 = int(input())
n1 = bool((n2))
if n1 is True:
for i in range(n):
i = i+1
print(i*"*")
elif n1 is False:
for i in range(n):
... | def star():
print('How Much Rows You Want')
n = int(input())
print('Enter 1 or Non Zero for True and 0 For False')
n2 = int(input())
n1 = bool(n2)
if n1 is True:
for i in range(n):
i = i + 1
print(i * '*')
elif n1 is False:
for i in range(n):
... |
"""
"""
# This is an input class. Do not edit.
class LinkedList:
def __init__(self, value):
self.value = value
self.next = None
def sumOfLinkedLists(linkedListOne, linkedListTwo):
tmp = 0
node1 = linkedListOne
node2 = linkedListTwo
while node1 is not None:
if node2 is no... | """
"""
class Linkedlist:
def __init__(self, value):
self.value = value
self.next = None
def sum_of_linked_lists(linkedListOne, linkedListTwo):
tmp = 0
node1 = linkedListOne
node2 = linkedListTwo
while node1 is not None:
if node2 is not None:
val = node1.value... |
#!/usr/bin/env python3
with open("input.txt", "r") as f:
num = []
for elem in f.read().split(","):
num.append(int(elem))
positions = set(num)
steps = -1
for position in positions:
current = 0
for elem in num:
current += abs(elem - position)
if steps < 0 or... | with open('input.txt', 'r') as f:
num = []
for elem in f.read().split(','):
num.append(int(elem))
positions = set(num)
steps = -1
for position in positions:
current = 0
for elem in num:
current += abs(elem - position)
if steps < 0 or current < steps:
... |
"""Remove item from list, by its value.
Remove at most 1 item from list _items, having value _x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of _x in _items, remove only one of them.
Source: programming-idioms.org
"""
# Implementatio... | """Remove item from list, by its value.
Remove at most 1 item from list _items, having value _x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of _x in _items, remove only one of them.
Source: programming-idioms.org
"""
items.remove(x) |
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
s, res = {}, []
for i in range(len(numbers)):
if numbers[i] in s.keys():
res.append(s[numbers[i]] + 1)
res.append(i + 1)
return res
s[target - numbe... | class Solution:
def two_sum(self, numbers: List[int], target: int) -> List[int]:
(s, res) = ({}, [])
for i in range(len(numbers)):
if numbers[i] in s.keys():
res.append(s[numbers[i]] + 1)
res.append(i + 1)
return res
s[target -... |
# historgram
def histogram(s):
d = dict()
for c in s:
a = d.get(c, 0)
d[c] = 1+a
return sorted(d)
h = histogram("brantosaurus")
print(h)
| def histogram(s):
d = dict()
for c in s:
a = d.get(c, 0)
d[c] = 1 + a
return sorted(d)
h = histogram('brantosaurus')
print(h) |
class FirmwareGPIO:
def __init__(self, scfg):
crtl_inputs = scfg.analog_ctrl_inputs + scfg.digital_ctrl_inputs
ctrl_outputs = scfg.analog_ctrl_outputs + scfg.digital_ctrl_outputs
self.getter_dict = {}
for probe in ctrl_outputs:
if probe.o_addr is not None:
... | class Firmwaregpio:
def __init__(self, scfg):
crtl_inputs = scfg.analog_ctrl_inputs + scfg.digital_ctrl_inputs
ctrl_outputs = scfg.analog_ctrl_outputs + scfg.digital_ctrl_outputs
self.getter_dict = {}
for probe in ctrl_outputs:
if probe.o_addr is not None:
... |
# -*- coding: utf-8 -*-
NOT_IMPLEMENTED_ERROR_MSG = ('This method must be implemented by classes'
' inheriting from BaseSerializer.')
class BaseSerializer(object):
"""
Base Serializer class that provides an interface for other serializers.
Usage:
.. code-block:: python
... | not_implemented_error_msg = 'This method must be implemented by classes inheriting from BaseSerializer.'
class Baseserializer(object):
"""
Base Serializer class that provides an interface for other serializers.
Usage:
.. code-block:: python
from betamax import Betamax, BaseSerializer
... |
def new_seating_chart(size=22):
"""Create a new seating chart.
:param size: int - number if seats in the seating chart.
:return: dict - with number of seats specified, and placeholder values.
"""
return {number: None for number in range(1, size + 1)}
def arrange_reservations(guests=None):
""... | def new_seating_chart(size=22):
"""Create a new seating chart.
:param size: int - number if seats in the seating chart.
:return: dict - with number of seats specified, and placeholder values.
"""
return {number: None for number in range(1, size + 1)}
def arrange_reservations(guests=None):
"""A... |
def Articles():
articles = [
{
'id' : 1,
'title' : 'Article one',
'body' : 'Now ParseHub will call this handler every time the status of a run changes. It doesnt matter how long the run takes, or if it queued up on our servers for a while. Itll just work',
'auther': 'Refuge',
'create_date' : ... | def articles():
articles = [{'id': 1, 'title': 'Article one', 'body': 'Now ParseHub will call this handler every time the status of a run changes. It doesnt matter how long the run takes, or if it queued up on our servers for a while. Itll just work', 'auther': 'Refuge', 'create_date': '04-24-2018'}, {'id': 2, 'tit... |
DOMAIN = "ble_mesh"
PLATFORM_LIGHT = "light"
HANDLE_ID = 14
CMD_FUNCTION = 0xFB
CMD_GPIO_CONTROL = 0xE7
CMD_OUT_1 = 0xF1
CMD_ON = 0x01
CMD_OFF = 0x00
| domain = 'ble_mesh'
platform_light = 'light'
handle_id = 14
cmd_function = 251
cmd_gpio_control = 231
cmd_out_1 = 241
cmd_on = 1
cmd_off = 0 |
for _ in range(int(input())):
a, b = [int(i) for i in input().split()]
if a > b: print(">")
elif a < b: print("<")
else: print("=") | for _ in range(int(input())):
(a, b) = [int(i) for i in input().split()]
if a > b:
print('>')
elif a < b:
print('<')
else:
print('=') |
a = list(input())
cnt = 0
x = 0
for i in range(len(a)-1):
if a[i] == a[i+1]:
cnt += 1
if x <= cnt:
x = cnt
elif a[i] != a[i+1]:
cnt = 0
print(x+1) | a = list(input())
cnt = 0
x = 0
for i in range(len(a) - 1):
if a[i] == a[i + 1]:
cnt += 1
if x <= cnt:
x = cnt
elif a[i] != a[i + 1]:
cnt = 0
print(x + 1) |
# Test proper handling of exceptions within generator across yield
def gen():
try:
yield 1
raise ValueError
print("FAIL")
raise SystemExit
except ValueError:
pass
yield 2
for i in gen():
print(i)
# Test throwing exceptions out of generator
def gen2():
yield... | def gen():
try:
yield 1
raise ValueError
print('FAIL')
raise SystemExit
except ValueError:
pass
yield 2
for i in gen():
print(i)
def gen2():
yield 1
raise ValueError
yield 2
yield 3
g = gen2()
print(next(g))
try:
print(next(g))
print('FAIL... |
with open("testfile.txt", "wb") as f1:
for i in range(0, 65536):
a = i//256
b = i%256
f1.write(bytes([a, b]))
| with open('testfile.txt', 'wb') as f1:
for i in range(0, 65536):
a = i // 256
b = i % 256
f1.write(bytes([a, b])) |
# Array (mutable, resizable)
class Array:
# Declare the necessary values used for the Array
_capacity = None
_size = None
_array = None
# Initialize these values with the capacity chosen
def __init__(self, capacity):
self._capacity = capacity
self._size = 0
self._array ... | class Array:
_capacity = None
_size = None
_array = None
def __init__(self, capacity):
self._capacity = capacity
self._size = 0
self._array = [None] * capacity
def get_size(self):
return self._size
def get_capacity(self):
return self._capacity
def ... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 10 21:31:18 2020
@author: krishan
"""
class Mammal:
def __init__(self, age):
self.age = age
def legs(self):
print("Two Legs")
def run(self):
print("Slow")
class Men(Mammal):
... | """
Created on Mon Aug 10 21:31:18 2020
@author: krishan
"""
class Mammal:
def __init__(self, age):
self.age = age
def legs(self):
print('Two Legs')
def run(self):
print('Slow')
class Men(Mammal):
def __init__(self, age, color):
super().__init__(age)
self.c... |
class Solution:
def nextGreaterElements(self, nums: list) -> list:
if not nums:
return []
monotonic_stack = [(nums[0], 0)]
nums = nums + nums
next_greater = {}
for i, num in enumerate(nums[1:], 1):
while monotonic_stack:
... | class Solution:
def next_greater_elements(self, nums: list) -> list:
if not nums:
return []
monotonic_stack = [(nums[0], 0)]
nums = nums + nums
next_greater = {}
for (i, num) in enumerate(nums[1:], 1):
while monotonic_stack:
if num > m... |
# List of rooms, characters, and weapons
room_list = ['Study','Hall','Lounge','Library','Billiard','Dining','Conservatory','Ballroom','Kitchen']
hall_list = ['Hall A','Hall B','Hall C','Hall D','Hall E','Hall F','Hall G','Hall H','Hall I','Hall J','Hall K','Hall L']
character_list = ['Miss Scarlet','Mrs. Peacock','Prof... | room_list = ['Study', 'Hall', 'Lounge', 'Library', 'Billiard', 'Dining', 'Conservatory', 'Ballroom', 'Kitchen']
hall_list = ['Hall A', 'Hall B', 'Hall C', 'Hall D', 'Hall E', 'Hall F', 'Hall G', 'Hall H', 'Hall I', 'Hall J', 'Hall K', 'Hall L']
character_list = ['Miss Scarlet', 'Mrs. Peacock', 'Professor Plum', 'Mr. Bo... |
'''
The MIT License (MIT)
Copyright (c) 2016 WavyCloud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, p... | """
The MIT License (MIT)
Copyright (c) 2016 WavyCloud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, p... |
class MetadataNotFound(Exception):
pass
class MetadataCorruption(Exception):
pass
class NotYetImplemented(Exception):
pass
class SPConfigurationMissing(Exception):
pass
| class Metadatanotfound(Exception):
pass
class Metadatacorruption(Exception):
pass
class Notyetimplemented(Exception):
pass
class Spconfigurationmissing(Exception):
pass |
inp = input()
arr = inp.split(' ')
L = int(arr[0])
N = int(arr[1])
dic = []
for i in range(0,L):
st = input()
stri = st.split(' ')
dic.append(stri)
for i in range(0,N):
inp = input()
tr = False
for j in range(0,L):
temp = dic[j]
if(inp == temp[0]):
print(temp[1])
tr = T... | inp = input()
arr = inp.split(' ')
l = int(arr[0])
n = int(arr[1])
dic = []
for i in range(0, L):
st = input()
stri = st.split(' ')
dic.append(stri)
for i in range(0, N):
inp = input()
tr = False
for j in range(0, L):
temp = dic[j]
if inp == temp[0]:
print(temp[1])
... |
__all__ = (
'decode_int',
'decode_str',
'decode_lst'
)
def decode_int(data, pos):
end = data[pos:].index(b'e')
if data[pos+1] == ord('-'):
return (int(data[pos + 2:pos + end]) * -1, end)
else:
return (int(data[pos + 1:pos + end]), end + pos)
# return data as raw byte... | __all__ = ('decode_int', 'decode_str', 'decode_lst')
def decode_int(data, pos):
end = data[pos:].index(b'e')
if data[pos + 1] == ord('-'):
return (int(data[pos + 2:pos + end]) * -1, end)
else:
return (int(data[pos + 1:pos + end]), end + pos)
def decode_str(data, pos):
index = data[pos:... |
def seat_decode(seat):
row = int(seat[:7].replace("F", "0").replace("B", "1"), 2)
column = int(seat[7:].replace("L", "0").replace("R", "1"), 2)
return row * 8 + column
if __name__ == "__main__":
with open("input.txt", "r") as f:
ids = {seat_decode(line.strip()) for line in f.readlines()}
... | def seat_decode(seat):
row = int(seat[:7].replace('F', '0').replace('B', '1'), 2)
column = int(seat[7:].replace('L', '0').replace('R', '1'), 2)
return row * 8 + column
if __name__ == '__main__':
with open('input.txt', 'r') as f:
ids = {seat_decode(line.strip()) for line in f.readlines()}
... |
__all__ = ['MODEL_URL', 'MODEL_VIEW']
MODEL_URL = """from rest_framework.routers import SimpleRouter
from {{ app }}.api import views
router = SimpleRouter()
{% for model in models %}
router.register(r'{{ model | lower }}', views.{{ model }}ViewSet){% endfor %}
urlpatterns = router.urls
"""
MODEL_VIEW = """from ... | __all__ = ['MODEL_URL', 'MODEL_VIEW']
model_url = "from rest_framework.routers import SimpleRouter\nfrom {{ app }}.api import views\n\n\nrouter = SimpleRouter()\n{% for model in models %}\nrouter.register(r'{{ model | lower }}', views.{{ model }}ViewSet){% endfor %}\n\nurlpatterns = router.urls\n"
model_view = 'from re... |
dicio = {"Nome": str(input('Nome do jogador: '))}
partidas = int(input(f'Quantas partidas {dicio["Nome"]} jogou? '))
lista = []
for c in range(partidas):
dicio["Gols"] = int((input(f'Quantos gols na partida {c+1}: ')))
lista.append(dicio["Gols"])
dicio["Gols"] = lista
total = int()
for c in lista:
total += ... | dicio = {'Nome': str(input('Nome do jogador: '))}
partidas = int(input(f"Quantas partidas {dicio['Nome']} jogou? "))
lista = []
for c in range(partidas):
dicio['Gols'] = int(input(f'Quantos gols na partida {c + 1}: '))
lista.append(dicio['Gols'])
dicio['Gols'] = lista
total = int()
for c in lista:
total += ... |
class Solution(object):
def countNumbersWithUniqueDigits(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 1
if n == 1:
return 10
ans, base = 10, 9
for i in range(1, n):
base *= (10 - i)
ans +=... | class Solution(object):
def count_numbers_with_unique_digits(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 1
if n == 1:
return 10
(ans, base) = (10, 9)
for i in range(1, n):
base *= 10 - i
... |
def data():
return {
"test": {
"min/layer2/weights": {
"displayName": "min/layer2/weights",
"description": ""
}
},
"train": {
"min/layer2/weights": {
"displayName": "min/layer2/weights",
"desc... | def data():
return {'test': {'min/layer2/weights': {'displayName': 'min/layer2/weights', 'description': ''}}, 'train': {'min/layer2/weights': {'displayName': 'min/layer2/weights', 'description': ''}}} |
#!/usr/bin/env/ python
# encoding: utf-8
__author__ = 'aldur'
| __author__ = 'aldur' |
# Python 3.6.1
with open("input.txt", "r") as f:
puzzle_input = []
for line in f:
puzzle_input.append(line.strip().split(" "))
total = 0
for phrase in puzzle_input:
bad = False
for word in phrase:
if phrase.count(word) > 1:
bad = True
break
if not bad:
... | with open('input.txt', 'r') as f:
puzzle_input = []
for line in f:
puzzle_input.append(line.strip().split(' '))
total = 0
for phrase in puzzle_input:
bad = False
for word in phrase:
if phrase.count(word) > 1:
bad = True
break
if not bad:
total += 1
pri... |
def Select_sort1():
A = [-9, -8, 640, 25, 12, 22, 33, 23, 45, 11, -2, -5, 99, 0]
for i in range(len(A)):
minimum = i
for j in range(i+1, len(A)):
if A[minimum] > A[j]:
minimum = j
A[i], A[minimum] = A[minimum], A[i]
print("After sort:")
print(A)
def ... | def select_sort1():
a = [-9, -8, 640, 25, 12, 22, 33, 23, 45, 11, -2, -5, 99, 0]
for i in range(len(A)):
minimum = i
for j in range(i + 1, len(A)):
if A[minimum] > A[j]:
minimum = j
(A[i], A[minimum]) = (A[minimum], A[i])
print('After sort:')
print(A)
... |
class Formatter:
"""
Inherit this class and override format function
"""
def format(self, text: str):
"""Override this function in inherited subclass. return text after formatting"""
return text
@property
def name(self):
return self.__class__.__name__
@classmethod
... | class Formatter:
"""
Inherit this class and override format function
"""
def format(self, text: str):
"""Override this function in inherited subclass. return text after formatting"""
return text
@property
def name(self):
return self.__class__.__name__
@classmethod
... |
"""
Documentation, License etc.
@package X-EDEN Toolchain generation
"""
| """
Documentation, License etc.
@package X-EDEN Toolchain generation
""" |
"""
CRM system
task: display a user record in the following format: 'John Smith (California)'. However, if you don't have a location in your system, you want just to see "John Smith."
"""
def format_customer(first, last, location=None):
full_name = '%s %s' % (first, last)
if location:
return '%s (%s)... | """
CRM system
task: display a user record in the following format: 'John Smith (California)'. However, if you don't have a location in your system, you want just to see "John Smith."
"""
def format_customer(first, last, location=None):
full_name = '%s %s' % (first, last)
if location:
return '%s (%s)... |
emails = sorted(set([line.strip() for line in open("email_domains.txt")]))
for email in emails:
print("'{email}',".format(email=email))
| emails = sorted(set([line.strip() for line in open('email_domains.txt')]))
for email in emails:
print("'{email}',".format(email=email)) |
for _ in range(int(input())):
string = input()
new_str= ""
new_str += string[0]
for i in range(1, len(string)):
if string[i] == "L":
on = string[i-1]
elif string[i] == "R":
on = string[i+1]
else:
on = string[i]
new_str += on
print(... | for _ in range(int(input())):
string = input()
new_str = ''
new_str += string[0]
for i in range(1, len(string)):
if string[i] == 'L':
on = string[i - 1]
elif string[i] == 'R':
on = string[i + 1]
else:
on = string[i]
new_str += on
pr... |
# https://www.hackerrank.com/challenges/any-or-all/problem
def is_palindrome(number):
return number == number[::-1]
N = int(input())
array = list(input().split())
print(
all(int(element) >= 0 for element in array)
and any(is_palindrome(element) for element in array)
)
| def is_palindrome(number):
return number == number[::-1]
n = int(input())
array = list(input().split())
print(all((int(element) >= 0 for element in array)) and any((is_palindrome(element) for element in array))) |
# Question Link : https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/579/week-1-january-1st-january-7th/3594/
# Level : Medium
# Solution Right Below :-
class Solution(object):
def findKthPositive(self, arr, k):
"""
:type arr: List[int]
:type k: int
:rtype... | class Solution(object):
def find_kth_positive(self, arr, k):
"""
:type arr: List[int]
:type k: int
:rtype: int
"""
i = len(arr) - 1
while i >= 0 and arr[i] - 1 - i - k >= 0:
i -= 1
tn = k - (arr[i] - 1 - i)
return arr[i] + tn |
"""
In-place quicksort implementation
"""
def quicksort(lst, b=0, e=None):
if e == None:
e = len(lst) - 1
p = e
i = b
while i < p:
if lst[p] < lst[i]:
# bring lst[i] after lst[p] through two swaps
lst[i], lst[p - 1] = lst[p - 1], lst[i]
lst[p - 1], ... | """
In-place quicksort implementation
"""
def quicksort(lst, b=0, e=None):
if e == None:
e = len(lst) - 1
p = e
i = b
while i < p:
if lst[p] < lst[i]:
(lst[i], lst[p - 1]) = (lst[p - 1], lst[i])
(lst[p - 1], lst[p]) = (lst[p], lst[p - 1])
p = p - 1
... |
def flownet_v1_s(input):
pass
| def flownet_v1_s(input):
pass |
prime = [2,3]
i = 4
while len(prime)<10001:
s = True
for j in prime:
if i%j == 0:
s = False
break
if s:
prime.append(i)
i = i + 1
print(prime[-1]) | prime = [2, 3]
i = 4
while len(prime) < 10001:
s = True
for j in prime:
if i % j == 0:
s = False
break
if s:
prime.append(i)
i = i + 1
print(prime[-1]) |
def rotation_string(str):
l = []
#str = ""
for i in str:
l.append(i)
#print(l)
for j in range(len(l) // 2):
a = l[j]
b = l[-(j+1)]
l[j] = b
l[-(j+1)] = a
return l | def rotation_string(str):
l = []
for i in str:
l.append(i)
for j in range(len(l) // 2):
a = l[j]
b = l[-(j + 1)]
l[j] = b
l[-(j + 1)] = a
return l |
def descending(x,n):
t=0
# by selection sorting
for i in range(0,n-1,1):
for j in range(i+1,n,1):
if x[i]<x[j]:
t=x[i]
x[i]=x[j]
x[j]=t
return (x)
# To sort a list in descending order
print("This programme sorts a list in d... | def descending(x, n):
t = 0
for i in range(0, n - 1, 1):
for j in range(i + 1, n, 1):
if x[i] < x[j]:
t = x[i]
x[i] = x[j]
x[j] = t
return x
print('This programme sorts a list in descending order : ')
n = int(input('Enter the number of elem... |
config = {'MAX_BOUND':512.0,
'MIN_BOUND':-1024.0,
'PIXEL_MEAN':0.25,
'NORM_CROP':True
} | config = {'MAX_BOUND': 512.0, 'MIN_BOUND': -1024.0, 'PIXEL_MEAN': 0.25, 'NORM_CROP': True} |
#
# PySNMP MIB module ELTEX-ULD-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-ULD-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:48:10 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... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_intersection, constraints_union, value_size_constraint) ... |
n = int(input('Enter a Value for N:\n'))
count = 1
while count <= n:
v1 = count
v2 = count + 1
if count +2 < n:
v3 = count + 2
else:
v3 = ' '
print(f'{v1} {v2} {v3}')
count += 3 | n = int(input('Enter a Value for N:\n'))
count = 1
while count <= n:
v1 = count
v2 = count + 1
if count + 2 < n:
v3 = count + 2
else:
v3 = ' '
print(f'{v1} {v2} {v3}')
count += 3 |
# encoding: utf-8
# module RevitServices.Transactions calls itself Transactions
# from RevitServices, Version=1.2.1.3083, Culture=neutral, PublicKeyToken=null
# by generator 1.145
# no doc
# no imports
# no functions
# classes
class AutomaticTransactionStrategy(object, ITransactionStrategy):
""" Auto... | class Automatictransactionstrategy(object, ITransactionStrategy):
""" AutomaticTransactionStrategy() """
def ensure_in_transaction(self, wrapper, document):
""" EnsureInTransaction(self: AutomaticTransactionStrategy, wrapper: TransactionWrapper, document: Document) -> TransactionHandle """
pass... |
# https://www.codewars.com/kata/578553c3a1b8d5c40300037c/python
# Given an array of ones and zeroes, convert the equivalent binary value to an integer.
# Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representation of 1.
# Examples:
# Testing: [0, 0, 0, 1] ==> 1
# Testing: [0, 0, 1, 0] ==> 2
# Testing: [0, ... | def binary_array_to_number(arr):
binary = ''.join(map(str, arr))
return int(binary, 2)
print(binary_array_to_number([1, 0, 0, 0, 1])) |
OCTICON_COMMENT_DISCUSSION = """
<svg class="octicon octicon-discussion" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.5 2.75a.25.25 0 01.25-.25h8.5a.25.25 0 01.25.25v5.5a.25.25 0 01-.25.25h-3.5a.75.75 0 00-.53.22L3.5 11.44V9.25a.75.75 0 00-.75-.75h-1a.25... | octicon_comment_discussion = '\n<svg class="octicon octicon-discussion" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.5 2.75a.25.25 0 01.25-.25h8.5a.25.25 0 01.25.25v5.5a.25.25 0 01-.25.25h-3.5a.75.75 0 00-.53.22L3.5 11.44V9.25a.75.75 0 00-.75-.75h-1a.25.2... |
# Interactive Help
help()
# Alternative Interactive Help
print(input.__doc__)
# Docstrings
def count(s,e,i):
"""
It's a counter that show in the touch:
s is the start of count;
e is the end of count;
i is the time's interval.
no exist return
by @e.mmmorais
"""
c = ... | help()
print(input.__doc__)
def count(s, e, i):
"""
It's a counter that show in the touch:
s is the start of count;
e is the end of count;
i is the time's interval.
no exist return
by @e.mmmorais
"""
c = s
while c <= e:
print(f'{c}', end=' ')
c += i
print('EN... |
def gap_sort(x):
gap = len(x)
swap= True
while gap > 1 or swap:
gap = max(1, int(gap / 1.3))
swap= False
for i in range(len(x) - gap):
j = i+gap
if x[i] > x[j]:
x[i], x[j] = x[j], x[i]
swap= True
lst = [3,6,4,8,9,0,6,5,2,10,... | def gap_sort(x):
gap = len(x)
swap = True
while gap > 1 or swap:
gap = max(1, int(gap / 1.3))
swap = False
for i in range(len(x) - gap):
j = i + gap
if x[i] > x[j]:
(x[i], x[j]) = (x[j], x[i])
swap = True
lst = [3, 6, 4, 8, 9, 0... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
modelChemistry = "CBS-QB3"
useHinderedRotors = True
useBondCorrections = False
species('CH2CHOOH', 'CH2CHOOH.py')
statmech('CH2CHOOH')
thermo('CH2CHOOH', 'Wilhoit')
| model_chemistry = 'CBS-QB3'
use_hindered_rotors = True
use_bond_corrections = False
species('CH2CHOOH', 'CH2CHOOH.py')
statmech('CH2CHOOH')
thermo('CH2CHOOH', 'Wilhoit') |
#: Module purely exists to test patching things.
thing = True
it = lambda: False
def get_thing():
global thing
return thing
def get_it():
global it
return it
| thing = True
it = lambda : False
def get_thing():
global thing
return thing
def get_it():
global it
return it |
_URL = "https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIU/{version}/ideaIU-{version}.zip"
_BUILD_FILE = """
load("@rules_java//java:defs.bzl", "java_import")
java_import(
name = "idea",
jars = [
"lib/extensions.jar",
"lib/jdom.jar",
"lib/guava-28... | _url = 'https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIU/{version}/ideaIU-{version}.zip'
_build_file = '\nload("@rules_java//java:defs.bzl", "java_import")\n\njava_import(\n name = "idea",\n jars = [\n "lib/extensions.jar",\n "lib/jdom.jar",\n "lib/gua... |
li=[]
n=int(input("Enter Number of Elements in List"))
print("Enter Numbers")
for i in range(n):
ele=int(input())
li.append(ele)
l1=[]
for i in li:
l1.insert(len(l1)-1,i)
print(l1)
| li = []
n = int(input('Enter Number of Elements in List'))
print('Enter Numbers')
for i in range(n):
ele = int(input())
li.append(ele)
l1 = []
for i in li:
l1.insert(len(l1) - 1, i)
print(l1) |
phone_book = dict()
enough = False
while True:
if enough:
break
command = input()
if command == 'stop':
break
elif command == 'search':
while True:
person = input()
if person == 'stop':
enough = True
break
... | phone_book = dict()
enough = False
while True:
if enough:
break
command = input()
if command == 'stop':
break
elif command == 'search':
while True:
person = input()
if person == 'stop':
enough = True
break
if per... |
def clean_col(col):
"""
This function cleans the column names and add the year information
"""
if col == 'Unnamed: 0': # Special case for contry column
return 'Country'
elif col[0] == 'U': # Take care for the annual summary column
return 'Total, {}'.format(str(int(col.split(':')[1... | def clean_col(col):
"""
This function cleans the column names and add the year information
"""
if col == 'Unnamed: 0':
return 'Country'
elif col[0] == 'U':
return 'Total, {}'.format(str(int(col.split(':')[1]) // 17 + 2014))
elif (len(col.split('.')) == 1) & (col[0] != 'U'):
... |
"""The `models` module contains routines for updating the
*parameters.json* file of the ILAMB component in PBS.
"""
model_template = { "group": { "name": "pbs_models_group", "members":
1, "leader": False }, "name": "{model_name}", "global": False,
"value": { "default": "Off", "type": "choice", "choices": [ "On... | """The `models` module contains routines for updating the
*parameters.json* file of the ILAMB component in PBS.
"""
model_template = {'group': {'name': 'pbs_models_group', 'members': 1, 'leader': False}, 'name': '{model_name}', 'global': False, 'value': {'default': 'Off', 'type': 'choice', 'choices': ['On', 'Off']}, '... |
#In this program we will enter a number and get its factors as the output in a list format.
num = int(input("Enter number: "))
def factors(n):
flist = []
for i in range(1,n+1):
if n%i == 0:
flist.append(i)
return flist
print(factors(num))
| num = int(input('Enter number: '))
def factors(n):
flist = []
for i in range(1, n + 1):
if n % i == 0:
flist.append(i)
return flist
print(factors(num)) |
class initial():
def solution(self, nums):
prefix = [1] * len(nums)
suffix = [1] * len(nums)
for i in range(1, len(nums)):
prefix[i] = prefix[i-1] * nums[i-1]
for j in range(len(nums)-2, -1, -1):
suffix[j] = suffix[j+1] * nums[j+1]
return [prefix[i]... | class Initial:
def solution(self, nums):
prefix = [1] * len(nums)
suffix = [1] * len(nums)
for i in range(1, len(nums)):
prefix[i] = prefix[i - 1] * nums[i - 1]
for j in range(len(nums) - 2, -1, -1):
suffix[j] = suffix[j + 1] * nums[j + 1]
return [pre... |
def parse(filename: str) -> list[int]:
with open(filename) as file:
line = file.read()
return list(map(int, line.split(',')))
def solve(fishes: list[int], days: int) -> int:
for _ in range(days):
for i in range(len(fishes)):
fishes[i] -= 1
if fishes[i] < 0:
... | def parse(filename: str) -> list[int]:
with open(filename) as file:
line = file.read()
return list(map(int, line.split(',')))
def solve(fishes: list[int], days: int) -> int:
for _ in range(days):
for i in range(len(fishes)):
fishes[i] -= 1
if fishes[i] < 0:
... |
#leia o tamanho do lado de um quadrado e
#imprima como resultado a area.
lado=float(input("Informe o lado do quadrado: "))
area=lado*lado
print(f"A area do quadrado eh {area}") | lado = float(input('Informe o lado do quadrado: '))
area = lado * lado
print(f'A area do quadrado eh {area}') |
# 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 diameterOfBinaryTree(self, root: Optional[TreeNode]) -> int:
maxi = 0
... | class Solution:
def diameter_of_binary_tree(self, root: Optional[TreeNode]) -> int:
maxi = 0
def dfs(node):
nonlocal maxi
if node is None:
return -1
left = dfs(node.left) + 1
right = dfs(node.right) + 1
cur_sum = left + ri... |
"""
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
"""
# Write your code here
t = int(input())
for _ in range(t):
x1,... | """
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
"""
t = int(input())
for _ in range(t):
(x1, y1) = map(int, input()... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.