content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
__all__ = [
'commands_ip_route',
'commands_iptables_forwarding',
'is_ipv6',
]
CMD_IP = '/sbin/ip'
CMD_IPTABLESv4 = '/sbin/iptables'
CMD_IPTABLESv6 = '/sbin/ip6tables'
def is_ipv6(ip_addr):
return (':' in ip_addr)
def commands_ip_route(device_na... | __all__ = ['commands_ip_route', 'commands_iptables_forwarding', 'is_ipv6']
cmd_ip = '/sbin/ip'
cmd_iptable_sv4 = '/sbin/iptables'
cmd_iptable_sv6 = '/sbin/ip6tables'
def is_ipv6(ip_addr):
return ':' in ip_addr
def commands_ip_route(device_name, ip, *, start=None, stop=None):
assert bool(start) ^ bool(stop)
... |
LMS_LEVELS = {
"programme_preliminaries": 1,
"programming_paradigms": 1,
"html_essentials": 1,
"css_essentials": 1,
"user_centric_frontend_development": 1,
"comparative_programming_languages_essentials": 2,
"javascript_essentials": 2,
"interactive_frontend_development": 2,
"python_es... | lms_levels = {'programme_preliminaries': 1, 'programming_paradigms': 1, 'html_essentials': 1, 'css_essentials': 1, 'user_centric_frontend_development': 1, 'comparative_programming_languages_essentials': 2, 'javascript_essentials': 2, 'interactive_frontend_development': 2, 'python_essentials': 3, 'practical_python': 3, ... |
def main():
n, k, l, c, d, p, nl, np = list(map(int, input().split()))
total_drink = k*l
total_limes = c*d
total_salt = p
print(int(min(int(total_drink/nl), total_limes, int(total_salt/np))/n))
if __name__=='__main__':
main()
| def main():
(n, k, l, c, d, p, nl, np) = list(map(int, input().split()))
total_drink = k * l
total_limes = c * d
total_salt = p
print(int(min(int(total_drink / nl), total_limes, int(total_salt / np)) / n))
if __name__ == '__main__':
main() |
# contains the processing code for the ticketer.
class Processor(object):
def __init__(self):
pass
def say(self, message):
return message + "\n"
| class Processor(object):
def __init__(self):
pass
def say(self, message):
return message + '\n' |
EMAIL_SERVER = None
PORT = None
SENDER_EMAIL = None
PASSWORD = None
RECIEVER_EMAIL = None | email_server = None
port = None
sender_email = None
password = None
reciever_email = None |
# Python - 3.6.0
Test.describe('Basic tests')
Test.assert_equals(volume(7, 3), 153)
Test.assert_equals(volume(56, 30), 98520)
Test.assert_equals(volume(0, 10), 0)
Test.assert_equals(volume(10, 0), 0)
Test.assert_equals(volume(0, 0), 0)
| Test.describe('Basic tests')
Test.assert_equals(volume(7, 3), 153)
Test.assert_equals(volume(56, 30), 98520)
Test.assert_equals(volume(0, 10), 0)
Test.assert_equals(volume(10, 0), 0)
Test.assert_equals(volume(0, 0), 0) |
# OpenWeatherMap API Key
weather_api_key = "Put Key Here"
# Google API Key
g_key = "Put key here"
| weather_api_key = 'Put Key Here'
g_key = 'Put key here' |
BASE_URL = 'http://api.fantasy.nfl.com/v1/players/stats?statType={}&season={}&format=json{}'
STAT_URL = 'http://api.fantasy.nfl.com/v1/game/stats?format=json'
USEFUL_DATA = ('name', 'position', 'stats', 'teamAbbr')
ALL_WEEKS = [x for x in range(1,18)]
ONE_HOUR = 3600
VALID_POSITIONS = (
'QB',
'RB',
'WR... | base_url = 'http://api.fantasy.nfl.com/v1/players/stats?statType={}&season={}&format=json{}'
stat_url = 'http://api.fantasy.nfl.com/v1/game/stats?format=json'
useful_data = ('name', 'position', 'stats', 'teamAbbr')
all_weeks = [x for x in range(1, 18)]
one_hour = 3600
valid_positions = ('QB', 'RB', 'WR', 'TE', 'DEF')
o... |
class InterfaceMeta(type):
def __new__(cls, name, bases, attrs):
if "salad" not in attrs:
attrs["salad"] = "salad"
return super().__new__(cls, name, bases, attrs)
class Interface(metaclass=InterfaceMeta):
def __init__(self, potato):
self.potato = potato
def test_meta():... | class Interfacemeta(type):
def __new__(cls, name, bases, attrs):
if 'salad' not in attrs:
attrs['salad'] = 'salad'
return super().__new__(cls, name, bases, attrs)
class Interface(metaclass=InterfaceMeta):
def __init__(self, potato):
self.potato = potato
def test_meta():
... |
# The variable number is just reference to the object 1001
number = 1001
print(id(number))
print(id(1001))
a1 = 2
print('a1: ', id(a1))
a2 = a1 + 1
print('a2: ', id(a2))
print('three: ', id(3))
b1 = 2
print('b1: ', id(b1))
print('Two: ', id(2))
# All bellow assignments to the 'something' variable is a valid code
so... | number = 1001
print(id(number))
print(id(1001))
a1 = 2
print('a1: ', id(a1))
a2 = a1 + 1
print('a2: ', id(a2))
print('three: ', id(3))
b1 = 2
print('b1: ', id(b1))
print('Two: ', id(2))
something = 12
something = 'Python'
something = ['a', 2, True]
def hello():
print('Hello World')
something = hello
something()
pr... |
# description: global
# date: 2020/6/7 19:15
# author: objcat
# version: 1.0
tool = None | tool = None |
def validate_post(post):
try:
anno_l1 = post['Layer1'].split(' ')
anno_l2 = post['Layer2'].split(' ')
text = post['text']
except KeyError:
return False, 4
if len(anno_l1) != len(anno_l2):
return False, 0
elif '[removed]' in text:
return False, 3
elif... | def validate_post(post):
try:
anno_l1 = post['Layer1'].split(' ')
anno_l2 = post['Layer2'].split(' ')
text = post['text']
except KeyError:
return (False, 4)
if len(anno_l1) != len(anno_l2):
return (False, 0)
elif '[removed]' in text:
return (False, 3)
... |
def get_kwarg(self, name, **kwargs):
return kwargs[name] if name in kwargs else ''
def get_arg(self, name, *args):
return args[0] if len(args) > 0 else '' | def get_kwarg(self, name, **kwargs):
return kwargs[name] if name in kwargs else ''
def get_arg(self, name, *args):
return args[0] if len(args) > 0 else '' |
class Solution:
def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
dic = [0]*101
for n in nums:
dic[n] += 1
return [sum(dic[0:n]) for n in nums]
| class Solution:
def smaller_numbers_than_current(self, nums: List[int]) -> List[int]:
dic = [0] * 101
for n in nums:
dic[n] += 1
return [sum(dic[0:n]) for n in nums] |
class Employee:
name = "Tom Cruise"
def function(self):
print("This is a message inside the class.")
employeeTom = Employee()
employeeJerry = Employee()
employeeJerry.name = "Jerry"
print(employeeTom.name)
print(employeeJerry.name)
print(employeeJerry.function())
| class Employee:
name = 'Tom Cruise'
def function(self):
print('This is a message inside the class.')
employee_tom = employee()
employee_jerry = employee()
employeeJerry.name = 'Jerry'
print(employeeTom.name)
print(employeeJerry.name)
print(employeeJerry.function()) |
#declare X Data points
testDataX = [1, 2, 3, 4, 5, 6, 7]
lengthX = len(testDataX)
n = lengthX
############## ############## ##############
#declare Y Data points
testDataY = [1.5, 3.8, 6.7, 9.0, 11.2, 13.6, 16.0]
lengthY = len(testDataY)
############## ############## ##############
#find the Variance, or square... | test_data_x = [1, 2, 3, 4, 5, 6, 7]
length_x = len(testDataX)
n = lengthX
test_data_y = [1.5, 3.8, 6.7, 9.0, 11.2, 13.6, 16.0]
length_y = len(testDataY)
mean_y = 0.0
for i in range(lengthY):
mean_y += testDataY[i]
mean_y /= lengthY
s_ey = 0.0
for i in range(lengthY):
s_ey += (testDataY[i] - meanY) ** 2.0
print(... |
# time related parameters
no_intervals = 144
no_periods = 48
no_intervals_periods = int(no_intervals / no_periods)
# household related parameters
# new_households = True
new_households = False
no_households = 100
no_tasks_min = 5
max_demand_multiplier = no_tasks_min
care_f_max = 10
care_f_weight = 1
# pricing related... | no_intervals = 144
no_periods = 48
no_intervals_periods = int(no_intervals / no_periods)
new_households = False
no_households = 100
no_tasks_min = 5
max_demand_multiplier = no_tasks_min
care_f_max = 10
care_f_weight = 1
pricing_table_weight = 1
cost_function_type = 'piece-wise'
zero_digit = 2
var_selection = 'smallest'... |
# -*- coding: utf8 -*-
"Files-related convertors"
| """Files-related convertors""" |
################################################
class BasePlantNonUDP(BasePlant):
def init(self):
pass
def stop(self):
pass
def enable(self):
pass
def last_data_ts_arrival(self):
# there's no delay when receiving feedback using the NonUDP classes,
... | class Baseplantnonudp(BasePlant):
def init(self):
pass
def stop(self):
pass
def enable(self):
pass
def last_data_ts_arrival(self):
return time.time()
def disable(self):
pass
def enable_watchdog(self, timeout_ms):
pass
class Armassistplantnon... |
catlog = [
"New",
"Macros",
"Manager",
"-",
"Install",
"Contribute",
"update_plg",
"-",
"temporal_plg",
"StackReg",
"Games",
"screencap_plg",
]
| catlog = ['New', 'Macros', 'Manager', '-', 'Install', 'Contribute', 'update_plg', '-', 'temporal_plg', 'StackReg', 'Games', 'screencap_plg'] |
class A:
def speak(self):
return "hello"
def speak_patch(self):
return "world"
A.speak = speak_patch
some_class = A()
print('some_class.speak():', some_class.speak())
some_class2 = A()
print('some_class2.speak():', some_class2.speak())
| class A:
def speak(self):
return 'hello'
def speak_patch(self):
return 'world'
A.speak = speak_patch
some_class = a()
print('some_class.speak():', some_class.speak())
some_class2 = a()
print('some_class2.speak():', some_class2.speak()) |
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
_end = '_end_'
def make_trie(words):
root = dict()
for word in words:
current_dict = root
for letter in word:
current_dict = current_dict.setdefault(letter, {})
current_dict[_end] = _e... | _end = '_end_'
def make_trie(words):
root = dict()
for word in words:
current_dict = root
for letter in word:
current_dict = current_dict.setdefault(letter, {})
current_dict[_end] = _end
return root
def get_endings(di, prefix=''):
res = []
for c in di:
i... |
def copy_not_empty_attrs(src, dst):
if src is not None and dst is not None:
for attribute in src.__dict__:
value = getattr(src, attribute)
if value:
setattr(dst, attribute, value)
class NoneDict(dict):
def __init__(self, args, **kwargs):
self.update(args... | def copy_not_empty_attrs(src, dst):
if src is not None and dst is not None:
for attribute in src.__dict__:
value = getattr(src, attribute)
if value:
setattr(dst, attribute, value)
class Nonedict(dict):
def __init__(self, args, **kwargs):
self.update(args... |
def make_arr(data):
t = {}
for ov in data:
if t.get(ov['resource']) is None:
t[ov['resource']] = {}
t[ov['resource']][ov['other_input']] = ov['value']
return t
| def make_arr(data):
t = {}
for ov in data:
if t.get(ov['resource']) is None:
t[ov['resource']] = {}
t[ov['resource']][ov['other_input']] = ov['value']
return t |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ============================================================================
# fap4malware - File analyzation program to detect malware
# Malware definition list
# Copyright (C) 2018 by Ralf Kilian
# Distributed under the MIT License (https://opensource.org/licenses/MIT... | deflist = {'6eb9f90ae2cfe10f0364729298351eb2afba298a6c8b36b47483785b78a87c4e': "Test file included with 'fap4malware'", '275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f': 'EICAR test signature', '2546dcffc5ad854d4ddc64fbf056871cd5a00f2471cb7a5bfd4ac23b6e9eedad': 'EICAR test signature (zipped)', 'e11050... |
def createMatrix(rowCount, colCount):
mat = []
for i in range(rowCount):
rowList = []
for j in range(colCount):
rowList.append(0)
mat.append(rowList)
return mat
with open('input.txt') as file:
input = (file.readline()).split(" ")
n = int(input[0])
... | def create_matrix(rowCount, colCount):
mat = []
for i in range(rowCount):
row_list = []
for j in range(colCount):
rowList.append(0)
mat.append(rowList)
return mat
with open('input.txt') as file:
input = file.readline().split(' ')
n = int(input[0])
k = int(inpu... |
# Source: https://github.com/sventhijssen/pgmtocnf
# Authors: Sven Thijssen and Gillis Hermans
class Literal():
def __init__(self, name, positive=True):
super(Literal, self).__init__()
self.atom = name
self.positive = positive
def __str__(self):
if self.positive:
re... | class Literal:
def __init__(self, name, positive=True):
super(Literal, self).__init__()
self.atom = name
self.positive = positive
def __str__(self):
if self.positive:
return str(self.atom)
elif self.atom == 'False':
return str(self.atom)
... |
# x = 101
#
# # print no of digits in a number
# print(len(str(x)))
#
#
# def end_zeros(num: int) -> int:
# # your code here
# # return str(num).count('0')
# return len(str(num)) - len(str(num).rstrip('0'))
#
#
# if __name__ == '__main__':
# print("Example:")
# print(end_zeros(0))
#
# # These "a... | def correct_sentence(text: str) -> str:
text = text[0].upper() + text[1:]
if text[len(text) - 1] != '.':
return text[0:] + '.'
return text[0:]
if __name__ == '__main__':
print('Example:')
print(correct_sentence('greetings, friends'))
assert correct_sentence('greetings, friends') == 'Gree... |
myStr = "Hello World"
#print(dir(myStr))
print(myStr.upper())
print(myStr.swapcase())
print(myStr.replace("Hello", "Goodbye"))
print(myStr.count("l"))
print(myStr.startswith("he"))
print(myStr.split(" "))
print(len(myStr))
print(myStr.find("e"))
print(myStr.index("e"))
print(myStr.isnumeric())
print(myStr.isalpha())... | my_str = 'Hello World'
print(myStr.upper())
print(myStr.swapcase())
print(myStr.replace('Hello', 'Goodbye'))
print(myStr.count('l'))
print(myStr.startswith('he'))
print(myStr.split(' '))
print(len(myStr))
print(myStr.find('e'))
print(myStr.index('e'))
print(myStr.isnumeric())
print(myStr.isalpha())
print(myStr[4])
prin... |
expected_output = {
"boot_loader_version": "Not applicable",
"build": "4567",
"chassis_serial_number": "None",
"commit_pending": "false",
"configuration_template": "CLItemplate_srp_vedge",
"controller_compatibility": "20.3",
"cpu_allocation": {"control": 1, "data": 3, "total": 4},
"cpu_r... | expected_output = {'boot_loader_version': 'Not applicable', 'build': '4567', 'chassis_serial_number': 'None', 'commit_pending': 'false', 'configuration_template': 'CLItemplate_srp_vedge', 'controller_compatibility': '20.3', 'cpu_allocation': {'control': 1, 'data': 3, 'total': 4}, 'cpu_reported_reboot': 'Not Applicable'... |
#
# PySNMP MIB module NET-SNMP-EXAMPLES-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NET-SNMP-EXAMPLES-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:18:07 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_union, value_size_constraint, constraints_intersection) ... |
class Led:
def __init__(self, devpath, brightness):
self.devpath = devpath
self.brightness = brightness
def __del__(self):
self.set_brightness(0)
def set_brightness(self, brightness):
f = open(self.devpath, "w")
f.write("%d\n" % brightness)
f.close();
self.brightness = brightness
| class Led:
def __init__(self, devpath, brightness):
self.devpath = devpath
self.brightness = brightness
def __del__(self):
self.set_brightness(0)
def set_brightness(self, brightness):
f = open(self.devpath, 'w')
f.write('%d\n' % brightness)
f.close()
... |
#!/usr/bin/env python3
def transform(s1, s2):
first_list = map(int, s1.split())
second_list = map(int, s2.split())
zipped = list(zip(first_list, second_list))
final_list = [a * b for a, b in zipped]
return final_list
def main():
s1 = "1 51 12 4"
s2 = "4 6 99 2"
print(transfor... | def transform(s1, s2):
first_list = map(int, s1.split())
second_list = map(int, s2.split())
zipped = list(zip(first_list, second_list))
final_list = [a * b for (a, b) in zipped]
return final_list
def main():
s1 = '1 51 12 4'
s2 = '4 6 99 2'
print(transform(s1, s2))
if __name__ == '__mai... |
def gradingStudents(calificaciones):
for i in range(len(calificaciones)):
if calificaciones[i] > 40:
redondeo = int(calificaciones[i] / 5 + 1)
if redondeo * 5 - calificaciones[i] < 3:
calificaciones[i] = redondeo * 5
print(calificaciones)
continuar = False
while ... | def grading_students(calificaciones):
for i in range(len(calificaciones)):
if calificaciones[i] > 40:
redondeo = int(calificaciones[i] / 5 + 1)
if redondeo * 5 - calificaciones[i] < 3:
calificaciones[i] = redondeo * 5
print(calificaciones)
continuar = False
while ... |
'''
Author: your name
Date: 2021-01-27 08:45:44
LastEditTime: 2021-02-08 12:02:54
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: /mmdetection/configs/_base_/default_runtime.py
'''
checkpoint_config = dict(interval=1)
# yapf:disable
log_config = dict(
interval=50,
hooks=[
... | """
Author: your name
Date: 2021-01-27 08:45:44
LastEditTime: 2021-02-08 12:02:54
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: /mmdetection/configs/_base_/default_runtime.py
"""
checkpoint_config = dict(interval=1)
log_config = dict(interval=50, hooks=[dict(type='TextLoggerHook')])
d... |
print("hello Dodger fans")
print("I know you haven't won a world series in a while")
print("but the rest of the NL West fans don't care")
print("Go Brewers!")
print("Even though you beat the Rockies")
| print('hello Dodger fans')
print("I know you haven't won a world series in a while")
print("but the rest of the NL West fans don't care")
print('Go Brewers!')
print('Even though you beat the Rockies') |
## Example #1
print("\n\n")
print("*" * 80)
print("Example #1")
print("*" * 80)
up = True
down = True
if up:
print("Going Up!")
elif down:
print("Going Down!")
elif up and down:
print("Going No Where!!!")
else:
print("Error!")
## Example #2
# print("\n\n")
# print("*" * 80)
# print("Example #2... | print('\n\n')
print('*' * 80)
print('Example #1')
print('*' * 80)
up = True
down = True
if up:
print('Going Up!')
elif down:
print('Going Down!')
elif up and down:
print('Going No Where!!!')
else:
print('Error!') |
class Solution:
def fib(self, N: int) -> int:
if N==0:
return 0
if N==1:
return 1
dp=[0]*N
dp[0]=1
dp[1]=1
for i in range(2,N):
dp[i]=dp[i-1]+dp[i-2]
return dp[N-1]
| class Solution:
def fib(self, N: int) -> int:
if N == 0:
return 0
if N == 1:
return 1
dp = [0] * N
dp[0] = 1
dp[1] = 1
for i in range(2, N):
dp[i] = dp[i - 1] + dp[i - 2]
return dp[N - 1] |
w=int(input())
if w>2:
if w%2==0:
print("YES")
else:
print("NO")
else:
print("NO")
| w = int(input())
if w > 2:
if w % 2 == 0:
print('YES')
else:
print('NO')
else:
print('NO') |
#
# PySNMP MIB module ODSLANBlazer7000-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ODSLANBlazer7000-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:32:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint) ... |
#W.A.P TO CHECK WHETHER THE NO. IS ARMSTRONG NO.
x=int(input('Enter a no.'))
sum=0
t=x
while(t!=0):
sum=sum+(int(t%10))**3
t=t/10
if(sum==x):
print('It is an armstrong no.')
else:
print('It is not an armstrong no.') | x = int(input('Enter a no.'))
sum = 0
t = x
while t != 0:
sum = sum + int(t % 10) ** 3
t = t / 10
if sum == x:
print('It is an armstrong no.')
else:
print('It is not an armstrong no.') |
# coding: utf8
FILENAME_TYPE = {'full': '_T1w_space-MNI152NLin2009cSym_res-1x1x1_T1w',
'cropped': '_T1w_space-MNI152NLin2009cSym_desc-Crop_res-1x1x1_T1w',
'skull_stripped': '_space-Ixi549Space_desc-skullstripped_T1w'}
| filename_type = {'full': '_T1w_space-MNI152NLin2009cSym_res-1x1x1_T1w', 'cropped': '_T1w_space-MNI152NLin2009cSym_desc-Crop_res-1x1x1_T1w', 'skull_stripped': '_space-Ixi549Space_desc-skullstripped_T1w'} |
T = [3614090360, 3905402710, 606105819, 3250441966,
4118548399, 1200080426, 2821735955, 4249261313,
1770035416, 2336552879, 4294925233, 2304563134,
1804603682, 4254626195, 2792965006, 1236535329,
4129170786, 3225465664, 643717713, 3921069994,
3593408605, 38016083, 3634488961, 38894294... | t = [3614090360, 3905402710, 606105819, 3250441966, 4118548399, 1200080426, 2821735955, 4249261313, 1770035416, 2336552879, 4294925233, 2304563134, 1804603682, 4254626195, 2792965006, 1236535329, 4129170786, 3225465664, 643717713, 3921069994, 3593408605, 38016083, 3634488961, 3889429448, 568446438, 3275163606, 41076033... |
def driver():
list = []
age1 = input("Enter the first number:")
age2 = input("Enter the second number:")
def swap(num1, num2):
if age1 > age2:
list.append(age2)
list.append(age1)
if age1 < age2:
list.append(age1)
list.append(age2)
swap(age1,age2)
print("the swapped result (fr... | def driver():
list = []
age1 = input('Enter the first number:')
age2 = input('Enter the second number:')
def swap(num1, num2):
if age1 > age2:
list.append(age2)
list.append(age1)
if age1 < age2:
list.append(age1)
list.append(age2)
swap... |
db_config = {
# 'host': 'localhost',
# 'port': 1337,
# 'unix_socket': '/var/lib/mysql/mysql.sock',
'user': 'root',
# 'passwd': 'password,
'db': 'logs_db'
}
| db_config = {'user': 'root', 'db': 'logs_db'} |
make_numbers = {'American Motors': 1,
'Jeep/Kaiser-Jeep/Willys Jeep': 2,
'AM General': 3,
'Chrysler': 6,
'Dodge': 7,
'Imperial': 8,
'Plymouth': 9,
'Eagle': 10,
'Ford': 12,
... | make_numbers = {'American Motors': 1, 'Jeep/Kaiser-Jeep/Willys Jeep': 2, 'AM General': 3, 'Chrysler': 6, 'Dodge': 7, 'Imperial': 8, 'Plymouth': 9, 'Eagle': 10, 'Ford': 12, 'Lincoln': 13, 'Mercury': 14, 'Buick/Opel': 18, 'Cadillac': 19, 'Chevrolet': 20, 'Oldsmobile': 21, 'Pontiac': 22, 'GMC': 23, 'Saturn': 24, 'Grumman'... |
def twoNumberSum(array, targetSum):
# Write your code here.
dic = {}
for i in range(len(array)):
if targetSum - array[i] in dic:
return [array[i], targetSum - array[i]]
else:
dic[array[i]] = i
return [] | def two_number_sum(array, targetSum):
dic = {}
for i in range(len(array)):
if targetSum - array[i] in dic:
return [array[i], targetSum - array[i]]
else:
dic[array[i]] = i
return [] |
# Calcular todos em:
# KM HM DAM M DM CM MM
var = float(input("Digite um valor: "))
print("O valor em decimetro fica {}".format(var * 10)) #DM
print("O valor em centimetros fica {}".format(var * 100)) #CM
print("O valor e milimetros fica {}".format(var * 1000)) #MM
print("O valor em metros fica {}".format(var * 10... | var = float(input('Digite um valor: '))
print('O valor em decimetro fica {}'.format(var * 10))
print('O valor em centimetros fica {}'.format(var * 100))
print('O valor e milimetros fica {}'.format(var * 1000))
print('O valor em metros fica {}'.format(var * 10000))
print('O valor em decametro fica {}'.format(var / 10))
... |
def slices(num_string,slice_size):
if slice_size>len(num_string):
raise ValueError
list_of_slices = []
for i in range(len(num_string)-slice_size+1):
temp_answer = []
for j in range(slice_size):
temp_answer.append(int(num_string[i+j]))
list_of_slices.append(temp_answer)
return list_of_slices
def l... | def slices(num_string, slice_size):
if slice_size > len(num_string):
raise ValueError
list_of_slices = []
for i in range(len(num_string) - slice_size + 1):
temp_answer = []
for j in range(slice_size):
temp_answer.append(int(num_string[i + j]))
list_of_slices.appen... |
global LAYER_UNKNOWN
LAYER_UNKNOWN = 'unknown'
class Design(object):
def __init__(self, layers, smells) -> None:
self.layers = layers
self.smells = smells
super().__init__()
| global LAYER_UNKNOWN
layer_unknown = 'unknown'
class Design(object):
def __init__(self, layers, smells) -> None:
self.layers = layers
self.smells = smells
super().__init__() |
class RecentCounter:
def __init__(self):
self.slide_window = deque()
def ping(self, t: int) -> int:
self.slide_window.append(t)
# invalidate the outdated pings
while self.slide_window:
if self.slide_window[0] < t - 3000:
self.slide_window.po... | class Recentcounter:
def __init__(self):
self.slide_window = deque()
def ping(self, t: int) -> int:
self.slide_window.append(t)
while self.slide_window:
if self.slide_window[0] < t - 3000:
self.slide_window.popleft()
else:
break
... |
# --------------
# Code starts here
class_1=['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio']
class_2=['Hilary Mason','Carla Gentry','Corinna Cortes']
new_class=class_1+class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove("Carla Gentry")
print(new_class)
# Cod... | class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1 + class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_class)
courses = {'Math': 65, 'English... |
widget = WidgetDefault()
widget.border = "None"
widget.background = "None"
commonDefaults["RadialMenuWidget"] = widget
def generateRadialMenuWidget(file, screen, menu, parentName):
name = menu.getName()
file.write(" %s = leRadialMenuWidget_New();" % (name))
generateBaseWidget(file, screen, menu)
... | widget = widget_default()
widget.border = 'None'
widget.background = 'None'
commonDefaults['RadialMenuWidget'] = widget
def generate_radial_menu_widget(file, screen, menu, parentName):
name = menu.getName()
file.write(' %s = leRadialMenuWidget_New();' % name)
generate_base_widget(file, screen, menu)
... |
def find_divisor(numbers):
for index, number in enumerate(numbers):
print("len", len(numbers[index + 1:]))
for divider in reversed(numbers[index + 1:]):
if number % divider == 0:
print("found {} and {}. Rest: {}".format(
number, divider, number % divid... | def find_divisor(numbers):
for (index, number) in enumerate(numbers):
print('len', len(numbers[index + 1:]))
for divider in reversed(numbers[index + 1:]):
if number % divider == 0:
print('found {} and {}. Rest: {}'.format(number, divider, number % divider))
... |
class University:
def __init__(self, name, country, world_rank):
self.name = name
self.country = country
self.world_rank = world_rank | class University:
def __init__(self, name, country, world_rank):
self.name = name
self.country = country
self.world_rank = world_rank |
#!/usr/bin/env python
class Solution:
def copyRandomList(self, head: 'Node') -> 'Node':
curr = head
while curr:
node = Node(curr.val, curr.next, None)
curr.next, curr = node, curr.next
curr = head
while curr:
copy = curr.next
copy.ran... | class Solution:
def copy_random_list(self, head: 'Node') -> 'Node':
curr = head
while curr:
node = node(curr.val, curr.next, None)
(curr.next, curr) = (node, curr.next)
curr = head
while curr:
copy = curr.next
copy.random = curr.random... |
KEY_PRESS = 0
MOUSE_DOWN = 1
MOUSE_UP = 2
MOUSE_DOUBLE_CLICK = 3
MOUSE_MOVE = 5
SCROLL_DOWN = 6
SCROLL_UP = 7
SCROLL_STEP = 1
CTRL = 'ctrl'
SHIFT = 'shift'
ALT = 'alt'
MODIFIER_KEYS = (CTRL, SHIFT, ALT,)
MODIFIER_KEYS_PRESS_DELAY = .4
EVENTS_DELAY = .05
LEFT = "left"
MIDDLE = "middle"
RIGHT = "right"
HIGH_QUALIT... | key_press = 0
mouse_down = 1
mouse_up = 2
mouse_double_click = 3
mouse_move = 5
scroll_down = 6
scroll_up = 7
scroll_step = 1
ctrl = 'ctrl'
shift = 'shift'
alt = 'alt'
modifier_keys = (CTRL, SHIFT, ALT)
modifier_keys_press_delay = 0.4
events_delay = 0.05
left = 'left'
middle = 'middle'
right = 'right'
high_quality = 75... |
#Celsius to Fahrenheit conversion
#F = C *9/5 +32
F= 0
print("Give the Number of Celcius: ")
c=float(input())
print("The result is: ")
F=c*9/5+32
print(F)
| f = 0
print('Give the Number of Celcius: ')
c = float(input())
print('The result is: ')
f = c * 9 / 5 + 32
print(F) |
#Software By AwesomeWithRex
def read_file(filename):
with open(filename) as f:
filename = f.readlines()
return filename
def get_template():
template = ''
with open('template.html', 'r') as f:
template = f.readlines()
return template
def put_in_body(file, template):
... | def read_file(filename):
with open(filename) as f:
filename = f.readlines()
return filename
def get_template():
template = ''
with open('template.html', 'r') as f:
template = f.readlines()
return template
def put_in_body(file, template):
count = 0
body_tag = 0
for i in ... |
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def print_list(self):
cur_node=self.head
while cur_node:
print(cur_node.data)
cur_node = cur_node.next
def ap... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def print_list(self):
cur_node = self.head
while cur_node:
print(cur_node.data)
cur_node = cur_node.next
def... |
class Solution:
def angleClock(self, hour: int, minutes: int) -> float:
hdeg = ((hour*30) + (minutes*0.5))%360
mdeg = (minutes * 6)
angle = abs(hdeg-mdeg)
return min(angle, 360-angle)
| class Solution:
def angle_clock(self, hour: int, minutes: int) -> float:
hdeg = (hour * 30 + minutes * 0.5) % 360
mdeg = minutes * 6
angle = abs(hdeg - mdeg)
return min(angle, 360 - angle) |
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
},
'targets': [
{
# Protobuf comp... | {'variables': {'chromium_code': 1, 'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out'}, 'targets': [{'target_name': 'sync_proto', 'type': 'none', 'sources': ['sync.proto', 'encryption.proto', 'app_specifics.proto', 'autofill_specifics.proto', 'bookmark_specifics.proto', 'extension_specifics.proto', 'nigori_speci... |
#!/usr/bin/env python
# encoding: utf-8
def run(whatweb, pluginname):
whatweb.recog_from_file(pluginname, "sysImages/css/PagesCSS.css", "foosun")
whatweb.recog_from_file(pluginname, "Tags.html", "Foosun")
| def run(whatweb, pluginname):
whatweb.recog_from_file(pluginname, 'sysImages/css/PagesCSS.css', 'foosun')
whatweb.recog_from_file(pluginname, 'Tags.html', 'Foosun') |
# reading withdrawal amount and account balance
x,y=map(float,input().split())
# this will check if account balance is less than the withdrawal amount or
# withdrawal amount is multiple of 5 and print the current account balance
if(x+0.5>=y or x%5!=0 or y<=0):
# printing the result upto two decimals
print("%.2f"%... | (x, y) = map(float, input().split())
if x + 0.5 >= y or x % 5 != 0 or y <= 0:
print('%.2f' % y)
else:
y = y - x - 0.5
print('%.2f' % y) |
#--------------------------------------
# Open and Parse BF File
#--------------------------------------
fileName = input("Enter name of Brainf*** file here: ")
file = open(fileName, "r")
programCode = []
validCommands = [">", "<", "+", "-", ".", ",", "[", "]"]
for x in file:
for y in x:
if y in validComm... | file_name = input('Enter name of Brainf*** file here: ')
file = open(fileName, 'r')
program_code = []
valid_commands = ['>', '<', '+', '-', '.', ',', '[', ']']
for x in file:
for y in x:
if y in validCommands:
programCode.append(y)
file.close()
bracket_positions = []
loop_index = 0
open_index = ... |
_registered_input_modules_types = {}
def register(name, class_type):
if name in _registered_input_modules_types:
raise RuntimeError("Dublicate input module name: " + name)
_registered_input_modules_types[name] = class_type
def load_modules(agent, input_link_config):
input_modules = []
# get in... | _registered_input_modules_types = {}
def register(name, class_type):
if name in _registered_input_modules_types:
raise runtime_error('Dublicate input module name: ' + name)
_registered_input_modules_types[name] = class_type
def load_modules(agent, input_link_config):
input_modules = []
if not ... |
def find_missing(array):
return [x for x in range(array[0], array[-1] + 1) if x not in array]
lst = [2, 4, 1, 7, 10]
print(find_missing(lst)) | def find_missing(array):
return [x for x in range(array[0], array[-1] + 1) if x not in array]
lst = [2, 4, 1, 7, 10]
print(find_missing(lst)) |
S1 = "Hello Python"
print(S1) # Prints complete string
print(S1[0]) # Prints first character of the string
print(S1[2:5]) # Prints character starting from 3rd t 5th
print(S1[2:]) # Prints string starting from 3rd character
print(S1 * 2) # Prints string two times
print(S1 + "Thanks") # Prints concatenated string
| s1 = 'Hello Python'
print(S1)
print(S1[0])
print(S1[2:5])
print(S1[2:])
print(S1 * 2)
print(S1 + 'Thanks') |
def onSpawn():
while True:
pet.moveXY(48, 8)
pet.moveXY(12, 8)
pet.on("spawn", onSpawn)
while True:
hero.say("Run!!!")
hero.say("Faster!")
| def on_spawn():
while True:
pet.moveXY(48, 8)
pet.moveXY(12, 8)
pet.on('spawn', onSpawn)
while True:
hero.say('Run!!!')
hero.say('Faster!') |
# TO print Fibonacci Series upto n numbers and replace all prime numbers and multiples of 5 by 0
# Checking for prime numbers
def isprime(numb):
if numb == 2:
return True
elif numb == 3:
return True
else :
for i in range(2, numb // 2 + 1):
if (numb % i) == 0:
... | def isprime(numb):
if numb == 2:
return True
elif numb == 3:
return True
else:
for i in range(2, numb // 2 + 1):
if numb % i == 0:
return False
else:
return True
def fibonacci_series(n):
flag = 0
(a, b) = (1, 1)
if ... |
class Solution:
def reorderLogFiles(self, logs: List[str]) -> List[str]:
def corder(log):
identifier, detail = log.split(None, 1)
return (0, detail, identifier) if detail[0].isalpha() else (1,)
return sorted(logs, key=corder)
| class Solution:
def reorder_log_files(self, logs: List[str]) -> List[str]:
def corder(log):
(identifier, detail) = log.split(None, 1)
return (0, detail, identifier) if detail[0].isalpha() else (1,)
return sorted(logs, key=corder) |
# initiate empty list to hold user input and sum value of zero
user_list = []
list_sum = 0
# seek user input for ten numbers
for i in range(10):
userInput = input("Enter any 2-digit number: ")
# check to see if number is even and if yes, add to list_sum
# print incorrect value warning when ValueError ex... | user_list = []
list_sum = 0
for i in range(10):
user_input = input('Enter any 2-digit number: ')
try:
number = int(userInput)
user_list.append(number)
if number % 2 == 0:
list_sum += number
except ValueError:
print("Incorrect value. That's not an int!")
print('use... |
load("@io_bazel_rules_docker//container:pull.bzl", "container_pull")
def containers():
container_pull(
name = "alpine_linux_amd64",
registry = "index.docker.io",
repository = "library/alpine",
tag = "3.14.2",
)
| load('@io_bazel_rules_docker//container:pull.bzl', 'container_pull')
def containers():
container_pull(name='alpine_linux_amd64', registry='index.docker.io', repository='library/alpine', tag='3.14.2') |
BUILD_STATE = (
('triggered', 'Triggered'),
('building', 'Building'),
('finished', 'Finished'),
)
BUILD_TYPES = (
('html', 'HTML'),
('pdf', 'PDF'),
('epub', 'Epub'),
('man', 'Manpage'),
)
| build_state = (('triggered', 'Triggered'), ('building', 'Building'), ('finished', 'Finished'))
build_types = (('html', 'HTML'), ('pdf', 'PDF'), ('epub', 'Epub'), ('man', 'Manpage')) |
class Solution:
def getDecimalValue(self, head: ListNode) -> int:
return self.getDecimalValueHelper(head)[0]
def getDecimalValueHelper(self, head: ListNode) -> int:
if head is None:
return (0, 0)
total, exp = self.getDecimalValueHelper(head.next)
currbit = head.val
... | class Solution:
def get_decimal_value(self, head: ListNode) -> int:
return self.getDecimalValueHelper(head)[0]
def get_decimal_value_helper(self, head: ListNode) -> int:
if head is None:
return (0, 0)
(total, exp) = self.getDecimalValueHelper(head.next)
currbit = he... |
# Copyright (C) 2009 Duncan McGreggor <duncan@canonical.com>
# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
# Copyright (C) 2012 New Dream Network, LLC (DreamHost)
# Licenced under the txaws licence available at /LICENSE in the txaws source.
__all__ = ["REGION_US", "REGION_EU", "EC2_US_EAST", "EC2_US_... | __all__ = ['REGION_US', 'REGION_EU', 'EC2_US_EAST', 'EC2_US_WEST', 'EC2_ASIA_PACIFIC', 'EC2_EU_WEST', 'EC2_SOUTH_AMERICA_EAST', 'EC2_ALL_REGIONS']
region_us = 'US'
region_eu = 'EU'
ec2_endpoint_us = 'https://us-east-1.ec2.amazonaws.com/'
ec2_endpoint_eu = 'https://eu-west-1.ec2.amazonaws.com/'
sqs_endpoint_us = 'https:... |
n = int(input())
for i in range(0, n):
line = input()
b, p = line.split()
b = int(b)
p = float(p)
calc = (60 * b) / p
var = 60 / p
min = calc - var
max = calc + var
print(min, calc, max) | n = int(input())
for i in range(0, n):
line = input()
(b, p) = line.split()
b = int(b)
p = float(p)
calc = 60 * b / p
var = 60 / p
min = calc - var
max = calc + var
print(min, calc, max) |
a = int(input('First number'))
b = int(input('Second number'))
if a>b:
print(a)
else:
print(b)
| a = int(input('First number'))
b = int(input('Second number'))
if a > b:
print(a)
else:
print(b) |
# Copyright (c) Microsoft Corporation.
#
# 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 agreed to in wri... | async def test_should_clear_cookies(context, page, server):
await page.goto(server.EMPTY_PAGE)
await context.addCookies([{'url': server.EMPTY_PAGE, 'name': 'cookie1', 'value': '1'}])
assert await page.evaluate('document.cookie') == 'cookie1=1'
await context.clearCookies()
assert await context.cookie... |
# pylint: disable=C0111
__all__ = ["test_dataset",
"test_label_smoother",
"test_noam_optimizer",
"test_tokenizer",
"test_transformer",
"test_transformer_data_batching",
"test_transformer_dataset",
"test_transformer_positional_encoder",
... | __all__ = ['test_dataset', 'test_label_smoother', 'test_noam_optimizer', 'test_tokenizer', 'test_transformer', 'test_transformer_data_batching', 'test_transformer_dataset', 'test_transformer_positional_encoder', 'test_vocabulary', 'test_word2vec', 'test_data', 'test_cnn'] |
distancia1: float; distancia2: float; distancia3: float; maiorD: float
print("Digite as tres distancias: ")
distancia1 = float(input())
distancia2 = float(input())
distancia3 = float(input())
if distancia1 > distancia2 and distancia1 > distancia3:
maiorD = distancia1
elif distancia2 > distancia3:
maiorD = dis... | distancia1: float
distancia2: float
distancia3: float
maior_d: float
print('Digite as tres distancias: ')
distancia1 = float(input())
distancia2 = float(input())
distancia3 = float(input())
if distancia1 > distancia2 and distancia1 > distancia3:
maior_d = distancia1
elif distancia2 > distancia3:
maior_d = dista... |
#
# PySNMP MIB module ALTIGA-GLOBAL-REG (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALTIGA-GLOBAL-REG
# Produced by pysmi-0.3.4 at Wed May 1 11:21:16 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, value_range_constraint, constraints_intersection) ... |
# Since any modulus should lay between 0 and 101, we can record all
# possible modulus at any given point in the calculation. The possible
# set of values of next step can be calculated using the previous set.
# Since there's guaranteed to be an answer, we will eventually make
# modulus 0 possible. We then backtrack to... | n = int(input())
a = list(map(int, input().split()))
op = ['*'] * (N - 1)
possible = [[None] * 101 for i in range(N)]
possible[0][A[0]] = True
end = N - 1
for i in range(N - 1):
if possible[i][0]:
end = i
break
for x in range(101):
if possible[i][x]:
possible[i + 1][(x + A[i ... |
# File: koodous_consts.py
#
# Copyright (c) 2018-2021 Splunk Inc.
#
# 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 app... | phantom_err_code_unavailable = 'Error code unavailable'
phantom_err_msg_unavailable = 'Unknown error occurred. Please check the asset configuration and|or action parameters.'
vault_err_invalid_vault_id = 'Invalid Vault ID'
vault_err_file_not_found = 'Vault file could not be found with supplied Vault ID'
koodous_base_ur... |
def print_two(*args):
arg1, arg2 =args
print(f"arg1 : {arg1},arg2 : {arg2}")
def print_two_again(arg1,arg2):
print(f"arg1:{arg1},arg2:{arg2}")
def print_one(arg1):
print(f"arg1:{arg1}")
def print_none():
print("I got nothing")
print_two("Zed","Shaw")
print_two_again("Zed","Shaw")
print_one("First!")... | def print_two(*args):
(arg1, arg2) = args
print(f'arg1 : {arg1},arg2 : {arg2}')
def print_two_again(arg1, arg2):
print(f'arg1:{arg1},arg2:{arg2}')
def print_one(arg1):
print(f'arg1:{arg1}')
def print_none():
print('I got nothing')
print_two('Zed', 'Shaw')
print_two_again('Zed', 'Shaw')
print_one(... |
'''
Provide transmission-daemon RPC credentials
'''
rpc_ip = ''
rpc_port = ''
rpc_username = ''
rpc_password = ''
| """
Provide transmission-daemon RPC credentials
"""
rpc_ip = ''
rpc_port = ''
rpc_username = ''
rpc_password = '' |
''' Kattis - secretchamber
Without much execution time pressure along with nodes being characters, we opt to use python with a
dict of dicts as our adjacency matrix. This is basically just floyd warshall transitive closure.
Time: O(V^3), Mem: O(V^2)
'''
n, q = input().split()
n = int(n)
q = int(q)
edges = []
node_nam... | """ Kattis - secretchamber
Without much execution time pressure along with nodes being characters, we opt to use python with a
dict of dicts as our adjacency matrix. This is basically just floyd warshall transitive closure.
Time: O(V^3), Mem: O(V^2)
"""
(n, q) = input().split()
n = int(n)
q = int(q)
edges = []
node_na... |
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
maria = Person("Maria Popova", 25)
print(hasattr(maria,"name"))
print(hasattr(maria,"surname"))
print(getattr(maria, "age"))
setattr(maria, "surname", "Popova")
print(getattr(maria, "surname"))
| class Person:
def __init__(self, name, age):
self.name = name
self.age = age
maria = person('Maria Popova', 25)
print(hasattr(maria, 'name'))
print(hasattr(maria, 'surname'))
print(getattr(maria, 'age'))
setattr(maria, 'surname', 'Popova')
print(getattr(maria, 'surname')) |
def spiral(steps):
dx = 1
dy = 0
dd = 1
x = 0
y = 0
d = 0
for _ in range(steps - 1):
x += dx
y += dy
d += 1
if d == dd:
d = 0
tmp = dx
dx = -dy
dy = tmp
if dy == 0:
dd += 1
yie... | def spiral(steps):
dx = 1
dy = 0
dd = 1
x = 0
y = 0
d = 0
for _ in range(steps - 1):
x += dx
y += dy
d += 1
if d == dd:
d = 0
tmp = dx
dx = -dy
dy = tmp
if dy == 0:
dd += 1
yie... |
with open('do-plecaka.txt', 'r') as f:
dane = []
# getting and cleaning data
for line in f:
dane.append([int(x) for x in line.split()])
# printing
for x in dane:
print(x) | with open('do-plecaka.txt', 'r') as f:
dane = []
for line in f:
dane.append([int(x) for x in line.split()])
for x in dane:
print(x) |
# measurements in inches
ball_radius = 3
goal_top = 50
goal_width = 58
goal_half = 29
angle_threshold = .1
class L_params(object):
horizontal_offset = 14.5
vertical_offset = 18.5
min_y = ball_radius - vertical_offset+3 # in robot coords
max_y = goal_top - vertical_offset
min_x = -14.5
max_x = 14.0
l1 = 11
l... | ball_radius = 3
goal_top = 50
goal_width = 58
goal_half = 29
angle_threshold = 0.1
class L_Params(object):
horizontal_offset = 14.5
vertical_offset = 18.5
min_y = ball_radius - vertical_offset + 3
max_y = goal_top - vertical_offset
min_x = -14.5
max_x = 14.0
l1 = 11
l2 = 11
shoulder... |
class Solution:
def numDecodings(self, s: str) -> int:
if s[0] == '0' or '00' in s:
return 0
for idx, _ in enumerate(s):
if idx == 0:
pre, cur = 1, 1
else:
tmp = cur
if _ != '0':
if s[idx - 1] == ... | class Solution:
def num_decodings(self, s: str) -> int:
if s[0] == '0' or '00' in s:
return 0
for (idx, _) in enumerate(s):
if idx == 0:
(pre, cur) = (1, 1)
else:
tmp = cur
if _ != '0':
if s[idx ... |
def find_skew_value(text):
length_of_text = len(text)
skew_value = 0
skew_value_list = []
for i in range(0, length_of_text):
if text[i] == 'C':
skew_value = skew_value - 1
elif text[i] == 'G':
skew_value = skew_value + 1
skew_value_list.append(skew_v... | def find_skew_value(text):
length_of_text = len(text)
skew_value = 0
skew_value_list = []
for i in range(0, length_of_text):
if text[i] == 'C':
skew_value = skew_value - 1
elif text[i] == 'G':
skew_value = skew_value + 1
skew_value_list.append(skew_value)
... |
#!/usr/bin/env python3
etape = 1
compteur = 0
n = 0
while True:
print(f"{etape:4d} : {n:5d} { -2+(etape)*(etape+2):6d} ; ", end="")
for _ in range(3 + etape):
n += 1
print(n, end=" ")
compteur += 1
if compteur == 500000:
print(n)
exit()
print()... | etape = 1
compteur = 0
n = 0
while True:
print(f'{etape:4d} : {n:5d} {-2 + etape * (etape + 2):6d} ; ', end='')
for _ in range(3 + etape):
n += 1
print(n, end=' ')
compteur += 1
if compteur == 500000:
print(n)
exit()
print()
n += etape
etape... |
class EPIconst:
class FeatureName:
pseknc = "pseknc"
cksnap = "cksnap"
dpcp = "dpcp"
eiip = "eiip"
kmer = "kmer"
tpcp = "tpcp"
all = sorted([pseknc, cksnap, dpcp, eiip, kmer, tpcp])
class CellName:
K562 = "K562"
NHEK = "NHEK"
IMR90... | class Epiconst:
class Featurename:
pseknc = 'pseknc'
cksnap = 'cksnap'
dpcp = 'dpcp'
eiip = 'eiip'
kmer = 'kmer'
tpcp = 'tpcp'
all = sorted([pseknc, cksnap, dpcp, eiip, kmer, tpcp])
class Cellname:
k562 = 'K562'
nhek = 'NHEK'
imr9... |
# Functions can encapsulate functionality you want to reuse:
def even_odd(x):
if x % 2 == 0:
print("even")
else:
print("odd")
# reused
even_odd(2)
even_odd(4)
even_odd(7)
even_odd(22)
even_odd(8)
# output should be >>> even, even, odd, even, even
| def even_odd(x):
if x % 2 == 0:
print('even')
else:
print('odd')
even_odd(2)
even_odd(4)
even_odd(7)
even_odd(22)
even_odd(8) |
class Sensors:
def __init__(self, **kwargs):
self.sensor_data_dictionary = kwargs
def update(self, **kwargs):
self.sensor_data_dictionary = kwargs
def get_value(self, key):
return (self.sensor_data_dictionary.get(key))
| class Sensors:
def __init__(self, **kwargs):
self.sensor_data_dictionary = kwargs
def update(self, **kwargs):
self.sensor_data_dictionary = kwargs
def get_value(self, key):
return self.sensor_data_dictionary.get(key) |
# https://www.google.com/webhp?sourceid=chrome-
# instant&ion=1&espv=2&ie=UTF-8#q=dp%20coin%20change
def coin_change_recur(coins,n,change_sum):
# If sum is 0 there exists a solution with no coins
if change_sum == 0:
return 1
# if sum is less then 0 no solution exists
if change_sum < 0:
... | def coin_change_recur(coins, n, change_sum):
if change_sum == 0:
return 1
if change_sum < 0:
return 0
if n <= 0 and change_sum > 0:
return 0
return coin_change_recur(coins, n - 1, change_sum) + coin_change_recur(coins, n, change_sum - coins[n - 1])
memo_dict = {}
def coin_change... |
def calc_fuel(mass: int):
return max(mass // 3 - 2, 0)
def calc_fuel_rec(mass: int):
fuel = calc_fuel(mass)
if fuel == 0:
return fuel
else:
return fuel + calc_fuel_rec(fuel)
| def calc_fuel(mass: int):
return max(mass // 3 - 2, 0)
def calc_fuel_rec(mass: int):
fuel = calc_fuel(mass)
if fuel == 0:
return fuel
else:
return fuel + calc_fuel_rec(fuel) |
class Cls:
x = "a"
d = {"a": "ab"}
cl = Cls()
cl.x = "b"
d[cl.x]
| class Cls:
x = 'a'
d = {'a': 'ab'}
cl = cls()
cl.x = 'b'
d[cl.x] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.