content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
someone = input("Enter a famous name: ").strip().title()
place = input("Enter a place: ").strip().lower()
weekday = ""
while weekday not in ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]:
weekday = input("Enter a weekday: ").strip().lower()
adjective = input("Enter an adjective: ")... | someone = input('Enter a famous name: ').strip().title()
place = input('Enter a place: ').strip().lower()
weekday = ''
while weekday not in ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']:
weekday = input('Enter a weekday: ').strip().lower()
adjective = input('Enter an adjective: ').s... |
# Question: https://projecteuler.net/problem=73
# F(n) -> length of Farey Sequence (https://mathworld.wolfram.com/FareySequence.html)
N = 12000
# https://en.wikipedia.org/wiki/Farey_sequence#Next_term
# From 0/1 to end_n/end_d
def farey_sequence_length(end_n, end_d, n):
a, b, c, d = 0, 1, 1, n
ans = 1
w... | n = 12000
def farey_sequence_length(end_n, end_d, n):
(a, b, c, d) = (0, 1, 1, n)
ans = 1
while not (a == end_n and b == end_d):
x = (n + b) // d
(a, b, c, d) = (c, d, x * c - a, x * d - b)
ans = ans + 1
return ans
print(farey_sequence_length(1, 2, 12000) - farey_sequence_length... |
#
# PySNMP MIB module RDN-CMTS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RDN-CMTS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:46:17 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,... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, constraints_intersection, single_value_constraint, value_range_constraint) ... |
# Nokia messages
nokia_update = [
(
"openconfig-interfaces:interfaces/interface[name=1/1/c1/2]",
{
"config": {
"name": "1/1/c1/2",
"enabled": True,
"type": "ethernetCsmacd",
"description": "Test Interface @ pygnmi"
... | nokia_update = [('openconfig-interfaces:interfaces/interface[name=1/1/c1/2]', {'config': {'name': '1/1/c1/2', 'enabled': True, 'type': 'ethernetCsmacd', 'description': 'Test Interface @ pygnmi'}, 'subinterfaces': {'subinterface': [{'index': 0, 'config': {'index': 0, 'enabled': True}, 'ipv4': {'addresses': {'address': [... |
c = 1
while True:
n = int(input())
if n == -1: break
print('Experiment {}: {} full cycle(s)'.format(c, n // 2))
c += 1
| c = 1
while True:
n = int(input())
if n == -1:
break
print('Experiment {}: {} full cycle(s)'.format(c, n // 2))
c += 1 |
# Write a function that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
# SIMPLER APPROACH: 1 is the min answer we return. Iterate through the list and if we we see the val of min then increment min.
# O(n)t | O(1)s
def smallestPositiveInteger(A):
... | def smallest_positive_integer(A):
A.sort()
min = 1
for val in A:
if val == min:
min += 1
return min |
for i in range(0,10):
for j in range(10, -1, -1): # we count backwards to -1 so we include 0
if(i == j):
print("i == j, so we break")
break
else:
print("i = %d, j= %d" % (i, j))
| for i in range(0, 10):
for j in range(10, -1, -1):
if i == j:
print('i == j, so we break')
break
else:
print('i = %d, j= %d' % (i, j)) |
temp = 0
respuesta = ''
def escribirArchivo(var):
archivo = open('temp.dat', 'a')
archivo.write(var+"\n")
def cerrarArchivo():
archivo = open('temp.dat', 'a')
archivo.close()
b = True
try:
while b == True:
temp = input(" Ingresa tu temperatura: ")
if(float(temp) > 37.5):
... | temp = 0
respuesta = ''
def escribir_archivo(var):
archivo = open('temp.dat', 'a')
archivo.write(var + '\n')
def cerrar_archivo():
archivo = open('temp.dat', 'a')
archivo.close()
b = True
try:
while b == True:
temp = input(' Ingresa tu temperatura: ')
if float(temp) > 37.5:
... |
name = "TensorFlow"
description = None
args_and_kwargs = (
(("--run-eagerly",), {
"help":"Running tensorflow in eager mode may be required for high memory models.",
"action":'store_true',
"default":False,
}),
(("--disable-gpu",), {
"help":"Disable GPU for high memory mode... | name = 'TensorFlow'
description = None
args_and_kwargs = ((('--run-eagerly',), {'help': 'Running tensorflow in eager mode may be required for high memory models.', 'action': 'store_true', 'default': False}), (('--disable-gpu',), {'help': 'Disable GPU for high memory models.', 'action': 'store_true', 'default': False}),... |
#encoding:utf-8
subreddit = 'behindthegifs'
t_channel = '@r_behindthegifs'
def send_post(submission, r2t):
return r2t.send_simple(submission,
min_upvotes_limit=100,
text=False,
gif=False,
img=False,
album=True,
other=False
) | subreddit = 'behindthegifs'
t_channel = '@r_behindthegifs'
def send_post(submission, r2t):
return r2t.send_simple(submission, min_upvotes_limit=100, text=False, gif=False, img=False, album=True, other=False) |
class DPDSettingsObject(object):
DPD_API_USERNAME = None
DPD_API_PASSWORD = None
DPD_API_FID = None
DPD_API_SANDBOX_USERNAME = None
DPD_API_SANDBOX_PASSWORD = None
DPD_API_SANDBOX_FID = None
| class Dpdsettingsobject(object):
dpd_api_username = None
dpd_api_password = None
dpd_api_fid = None
dpd_api_sandbox_username = None
dpd_api_sandbox_password = None
dpd_api_sandbox_fid = None |
class recipe_defs:
def __init__(self):
self.tags = ["Vegetarian",
"Vegan",
"Burger",
"Baby",
"High protein",
"Gluten free",
"Meat",
"Fish",
"Cold",
... | class Recipe_Defs:
def __init__(self):
self.tags = ['Vegetarian', 'Vegan', 'Burger', 'Baby', 'High protein', 'Gluten free', 'Meat', 'Fish', 'Cold', 'Hot', 'Take away']
self.types = ['Breakfast', 'Main', 'Dessert', 'Fika', 'Starter', 'Juice', 'Smoothie', 'Soup']
class Ingredient_Def:
def __ini... |
# scored.py
# Repeatedly read test scores (from 0 to 100), until the user
# enter -1 to finish. The input part of the program will ensure
# that the numbers are in the correct range.
# For each score, report the corresponding grade:
# 90-100 = A, 80-89 = B, 70-79 = C, 60-69 = D, < 60 = F
# When you have all the scores,... | def display_grade(score):
if score >= 90:
print('Congratulations! That is an A.')
elif score >= 80:
print('Good job. That is a B.')
elif score >= 70:
print('You are passing with a C.')
elif score >= 60:
print('Please study more. You have a D.')
else:
print('So... |
def is_possible(m, n, times):
re = 0
for t in times:
re += m // t
if re >= n:
return True
return False
def solution(n, times):
answer = 0
times.sort()
l=0; r=1_000_000_000_000_000; m=0
while l <= r:
m = (l+r)//2
if is_possible(m, n, times):
... | def is_possible(m, n, times):
re = 0
for t in times:
re += m // t
if re >= n:
return True
return False
def solution(n, times):
answer = 0
times.sort()
l = 0
r = 1000000000000000
m = 0
while l <= r:
m = (l + r) // 2
if is_possible(m, n, tim... |
list1=[1,2,6,12]
iteration=0
print ("iteration", iteration, list1)
for i in range(len(list1)):
for j in range(len(list1)-1-i):
iteration=iteration+1
if list1[j]> list1[j+1]:
temp=list1[j]
list1[j] = list1[j+1]
list1[j+1]=temp # Swap!
print ("iteration", ... | list1 = [1, 2, 6, 12]
iteration = 0
print('iteration', iteration, list1)
for i in range(len(list1)):
for j in range(len(list1) - 1 - i):
iteration = iteration + 1
if list1[j] > list1[j + 1]:
temp = list1[j]
list1[j] = list1[j + 1]
list1[j + 1] = temp
print... |
class TrackGroupStyle:
def __init__(self, distance=5, internal_offset=2, x_multiplier=1.05, show_label=True,
label_fontsize=16, label_fontweight="normal",
label_fontstyle='normal',
label_hor_aln='right', label_vert_aln='center',
label_y_shift=0,... | class Trackgroupstyle:
def __init__(self, distance=5, internal_offset=2, x_multiplier=1.05, show_label=True, label_fontsize=16, label_fontweight='normal', label_fontstyle='normal', label_hor_aln='right', label_vert_aln='center', label_y_shift=0, label_x_shift=-15):
self.distance = distance
self.int... |
def new_if(predicate, then, otherwise):
if predicate:
then
else:
otherwise
def p(x):
new_if(x > 5, print(x), p(x+1))
p(1) # what happens here? | def new_if(predicate, then, otherwise):
if predicate:
then
else:
otherwise
def p(x):
new_if(x > 5, print(x), p(x + 1))
p(1) |
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
#################
# List indexing #
#################
# Classical position indexing
i = 0
while i < len(a):
print(a[i])
i += 1
# Negative indices
print(a[-1])
print(a[-2])
print(a[-3])
################
# List slicing #
################
# Elements between indices 3 and 7
p... | a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 0
while i < len(a):
print(a[i])
i += 1
print(a[-1])
print(a[-2])
print(a[-3])
print(a[3:7])
print(a[5:])
print(a[:8])
l = [x * x for x in range(1, 10)]
print(l)
l = [x * x for x in range(1, 10) if x * x % 2 == 0]
print(l)
l = [x for x in a if x > 2 and x < 7]
print(l)
l = zip... |
#
# PySNMP MIB module Juniper-HTTP-Profile-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-HTTP-Profile-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:02:54 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ... |
# create_trusted_globals_dict takes in a module name [module_name], a trusted values dictionary [trusted_values_dict],
# and a boolean [first_time].
# Called by run_test
def create_trusted_globals_dict(self):
# If module is being run for the first time, a trusted_values_dict entry doesn't exist; return an empt... | def create_trusted_globals_dict(self):
if self.first_time:
return {}
else:
return self.trusted_values_dict[self.trusted_values_dict_name] |
class Truckloads:
def numTrucks(self, numCrates, loadSize):
if numCrates <= loadSize:
return 1
return self.numTrucks(numCrates/2, loadSize) + self.numTrucks((numCrates+1)/2, loadSize)
| class Truckloads:
def num_trucks(self, numCrates, loadSize):
if numCrates <= loadSize:
return 1
return self.numTrucks(numCrates / 2, loadSize) + self.numTrucks((numCrates + 1) / 2, loadSize) |
#!/usr/bin/env python3
def proc(x):
print(x)
x = proc("testing 1, 2, 3...")
print("below is x: ")
print(x)
print("above is x: ")
| def proc(x):
print(x)
x = proc('testing 1, 2, 3...')
print('below is x: ')
print(x)
print('above is x: ') |
GET_POWER_FLOW_REALTIME_DATA = {
'timestamp': {
'value': '2019-01-10T23:33:12+01:00'
},
'status': {
'Code': 0,
'Reason': '',
'UserMessage': ''
},
'energy_day': {
'value': 0,
'unit': 'Wh'
},
'energy_total': {
'value': 26213502,
'... | get_power_flow_realtime_data = {'timestamp': {'value': '2019-01-10T23:33:12+01:00'}, 'status': {'Code': 0, 'Reason': '', 'UserMessage': ''}, 'energy_day': {'value': 0, 'unit': 'Wh'}, 'energy_total': {'value': 26213502, 'unit': 'Wh'}, 'energy_year': {'value': 12400.100586, 'unit': 'Wh'}, 'meter_location': {'value': 'loa... |
#
# PySNMP MIB module Wellfleet-CONSOLE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-CONSOLE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:39:44 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, value_range_constraint, constraints_intersection) ... |
##Q1
def sumOfDigits(String):
sumNumber=0
for i in range(0,len(String)):
if String[i].isdigit():
sumNumber=sumNumber+int(String[i])
return sumNumber
##Q2
def smallerThanN(intList,integer):
newList=[]
for intInList in intList:
if intInList<integer:
newList.... | def sum_of_digits(String):
sum_number = 0
for i in range(0, len(String)):
if String[i].isdigit():
sum_number = sumNumber + int(String[i])
return sumNumber
def smaller_than_n(intList, integer):
new_list = []
for int_in_list in intList:
if intInList < integer:
... |
'''
Calculating Function
'''
n = int(input())
result = 0
if n % 2 == 0:
result = n // 2
else:
result = n // 2 - n
print(result) | """
Calculating Function
"""
n = int(input())
result = 0
if n % 2 == 0:
result = n // 2
else:
result = n // 2 - n
print(result) |
Motivations = [ # Acolyte
'I ran away from home at an early age and found refuge in a temple.',
'My family gave me to a temple, since they were unable or unwilling to care for me.',
'I grew up in a household with strong religious convictions. Entering the service of one or more gods seemed natural.',
'An impassioned se... | motivations = ['I ran away from home at an early age and found refuge in a temple.', 'My family gave me to a temple, since they were unable or unwilling to care for me.', 'I grew up in a household with strong religious convictions. Entering the service of one or more gods seemed natural.', 'An impassioned sermon struck... |
# coding: utf8
# Copyright 2017 Vincent Jacques <vincent@vincent-jacques.net>
project = "sphinxcontrib-ocaml"
author = '<a href="http://vincent-jacques.net/">Vincent Jacques</a>'
copyright = ('2017 {} <script>var jacquev6_ribbon_github="{}"</script>'.format(author, project) +
'<script src="https://jacque... | project = 'sphinxcontrib-ocaml'
author = '<a href="http://vincent-jacques.net/">Vincent Jacques</a>'
copyright = '2017 {} <script>var jacquev6_ribbon_github="{}"</script>'.format(author, project) + '<script src="https://jacquev6.github.io/ribbon.js"></script>'
version = '0.3.0'
release = version
master_doc = 'index'
ex... |
def add(x, *args):
total = x
for i in args:
total += i
print(f'{x=} + {args=} = {total}')
add(1, 2, 3)
add(1, 2)
add(1, 2, 3, 4, 5, 6, 7)
add(1)
| def add(x, *args):
total = x
for i in args:
total += i
print(f'x={x!r} + args={args!r} = {total}')
add(1, 2, 3)
add(1, 2)
add(1, 2, 3, 4, 5, 6, 7)
add(1) |
class orphan_external_exception(Exception):
def __init__(self, args=None):
if args:
self.args = (args,)
else:
self.args = ("Wow I have been imported",)
self.external_demo_attr = "Now imported"
| class Orphan_External_Exception(Exception):
def __init__(self, args=None):
if args:
self.args = (args,)
else:
self.args = ('Wow I have been imported',)
self.external_demo_attr = 'Now imported' |
__title__ = 'imgur-cli'
__author__ = 'Usman Ehtesham Gul'
__email__ = 'uehtesham90@gmail.com'
__license__ = 'MIT'
__version__ = '0.0.1'
__url__ = 'https://github.com/ueg1990/imgur-cli.git'
| __title__ = 'imgur-cli'
__author__ = 'Usman Ehtesham Gul'
__email__ = 'uehtesham90@gmail.com'
__license__ = 'MIT'
__version__ = '0.0.1'
__url__ = 'https://github.com/ueg1990/imgur-cli.git' |
class Solution:
# @param candidates, a list of integers
# @param target, integer
# @return a list of lists of integers
def combinationSum(self, candidates, target):
self.results = []
candidates.sort()
self.combination(candidates, target, 0, [])
return self.results
... | class Solution:
def combination_sum(self, candidates, target):
self.results = []
candidates.sort()
self.combination(candidates, target, 0, [])
return self.results
def combination(self, candidates, target, start, result):
if target == 0:
self.results.append(r... |
a = True
b = False
print('AND Logic:')
print('a and a =', a and a)
print('a and b =', a and b)
print('b and b =', b and b)
print('b and a =', b and a)
print('\nOR Logic:')
print('a or a =', a or a)
print('a or b =', a or b)
print('b or b =', b or b)
print('\nNOT Logic:')
print('a =' , a , '\tnot a =' , not a )
print... | a = True
b = False
print('AND Logic:')
print('a and a =', a and a)
print('a and b =', a and b)
print('b and b =', b and b)
print('b and a =', b and a)
print('\nOR Logic:')
print('a or a =', a or a)
print('a or b =', a or b)
print('b or b =', b or b)
print('\nNOT Logic:')
print('a =', a, '\tnot a =', not a)
print('b =',... |
'''https://leetcode.com/problems/non-overlapping-intervals/
435. Non-overlapping Intervals
Medium
2867
79
Add to List
Share
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Exam... | """https://leetcode.com/problems/non-overlapping-intervals/
435. Non-overlapping Intervals
Medium
2867
79
Add to List
Share
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Exam... |
# LANGUAGE: Python 3
# AUTHOR: Luiz Devitte
# GitHub: https://github.com/LuizDevitte
def greetings(name):
print('\n')
print('Hello, World!')
print('And Hello, {}!'.format(name))
print('\n')
return 0
def main():
name = input('Hey, who are you? ')
greetings(name)
if __name__=='__main__':
... | def greetings(name):
print('\n')
print('Hello, World!')
print('And Hello, {}!'.format(name))
print('\n')
return 0
def main():
name = input('Hey, who are you? ')
greetings(name)
if __name__ == '__main__':
main() |
#!/usr/bin/env python
MAX_LOG_LENGTH = 1000
MESSAGE_MAX_LENGTH = 2000
class ScriptLogger:
def __init__(self, db):
self.db = db
def save(self, user_name, path, logs):
# Don't save empty logs
if len(logs) == 0:
return
# If logs are longer than the ... | max_log_length = 1000
message_max_length = 2000
class Scriptlogger:
def __init__(self, db):
self.db = db
def save(self, user_name, path, logs):
if len(logs) == 0:
return
if len(logs) > MAX_LOG_LENGTH:
logs = logs[-MAX_LOG_LENGTH:]
all_messages = self.tr... |
#
# PySNMP MIB module Fore-DSX1-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Fore-DSX1-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:03:21 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... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint) ... |
class BattleEventsListener:
def on_battle_begins(self):
pass
def on_battle_ends(self):
pass
def on_reflected_attack(self, attack_obj):
pass
def on_unit_damaged(self, attack_obj):
pass
def on_unit_killed(self, attack_obj):
pass
def on_s... | class Battleeventslistener:
def on_battle_begins(self):
pass
def on_battle_ends(self):
pass
def on_reflected_attack(self, attack_obj):
pass
def on_unit_damaged(self, attack_obj):
pass
def on_unit_killed(self, attack_obj):
pass
def on_squad_killed(sel... |
# -*- coding: utf-8 -*-
class GameConfig:
# Frame dimensions
width = 30
height = 15
# Start the game at this speed
initial_speed = 3.0
# For every point scored, increase game speed by this amount
speed_increase_factor = 0.15
# Maximum game speed.
max_speed = 30
# Enforce co... | class Gameconfig:
width = 30
height = 15
initial_speed = 3.0
speed_increase_factor = 0.15
max_speed = 30
solid_walls = True
initial_food_count = 1
max_food_count = 5
food_increase_interval = 10 |
print("%s" % 1.0)
print("%r" % 1.0)
print("%d" % 1.0)
print("%i" % 1.0)
print("%u" % 1.0)
# these 3 have different behaviour in Python 3.x versions
# uPy raises a TypeError, following Python 3.5 (earlier versions don't)
#print("%x" % 18.0)
#print("%o" % 18.0)
#print("%X" % 18.0)
print("%e" % 1.23456)
print("%E" % 1.... | print('%s' % 1.0)
print('%r' % 1.0)
print('%d' % 1.0)
print('%i' % 1.0)
print('%u' % 1.0)
print('%e' % 1.23456)
print('%E' % 1.23456)
print('%f' % 1.23456)
print('%F' % 1.23456)
print('%g' % 1.23456)
print('%G' % 1.23456)
print('%06e' % float('inf'))
print('%06e' % float('-inf'))
print('%06e' % float('nan'))
print('%02... |
N,K=map(int,input().split())
S=[int(input()) for i in range(N)]
length=left=0
mul=1
if 0 in S:
length=N
else:
for right in range(N):
mul*=S[right]
if mul<=K:
length=max(length,right-left+1)
else:
mul//=S[left]
left+=1
print(length) | (n, k) = map(int, input().split())
s = [int(input()) for i in range(N)]
length = left = 0
mul = 1
if 0 in S:
length = N
else:
for right in range(N):
mul *= S[right]
if mul <= K:
length = max(length, right - left + 1)
else:
mul //= S[left]
left += 1
pri... |
class SERPException(Exception):
pass
class ItemNotFoundException(SERPException):
pass
| class Serpexception(Exception):
pass
class Itemnotfoundexception(SERPException):
pass |
#! /usr/bin/python3
def parts(arr):
arr.append(0)
arr.append(max(arr)+3)
arr.sort()
_type1 = 0
_type2 = 0
for _x in range(0, len(arr)-1):
_difference = arr[_x+1] - arr[_x]
if _difference == 1:
_type1 += 1
elif _difference == 3:
_type2 += 1
_... | def parts(arr):
arr.append(0)
arr.append(max(arr) + 3)
arr.sort()
_type1 = 0
_type2 = 0
for _x in range(0, len(arr) - 1):
_difference = arr[_x + 1] - arr[_x]
if _difference == 1:
_type1 += 1
elif _difference == 3:
_type2 += 1
_dict = {}
de... |
# Debug flag
DEBUG = False
# Menu tuple IDX return
IDX_STOCK = 0
IDX_DATE_RANGE = 1
IDX_PERCENT_TRAINED = 2 | debug = False
idx_stock = 0
idx_date_range = 1
idx_percent_trained = 2 |
def deep_reverse(arr):
if len(arr) == 0:
return []
last_el = arr[-1]
rem_list = deep_reverse(arr[:-1]) # remaining list
if type(last_el) is list:
last_el = deep_reverse(last_el)
rem_list.insert(0, last_el)
return rem_list
def test_function(test_case):
arr = test_case[... | def deep_reverse(arr):
if len(arr) == 0:
return []
last_el = arr[-1]
rem_list = deep_reverse(arr[:-1])
if type(last_el) is list:
last_el = deep_reverse(last_el)
rem_list.insert(0, last_el)
return rem_list
def test_function(test_case):
arr = test_case[0]
solution = test_c... |
# problem link: https://leetcode.com/problems/combination-sum-iii/
class Solution:
def combinationSum3(self, k: int, n: int) -> List[List[int]]:
end_num = 10 # candidates numbers are btw 0 - 9
def dfs(cur_list, cur_size, next_num):
if cur_size == k and sum(cur_list) == n:
... | class Solution:
def combination_sum3(self, k: int, n: int) -> List[List[int]]:
end_num = 10
def dfs(cur_list, cur_size, next_num):
if cur_size == k and sum(cur_list) == n:
res.append(cur_list)
return
if cur_size > k or sum(cur_list) > n:
... |
def insertion_sort(arr):
for k in range(1, len(arr)):
key = arr[k]
j = k
while j > 0 and arr[j-1] > arr[j]:
arr[j], arr[j-1] = arr[j-1], arr[j]
j = j - 1
my_list = [24, 81, 13, 57, 16]
insertion_sort(my_list)
print(my_list) | def insertion_sort(arr):
for k in range(1, len(arr)):
key = arr[k]
j = k
while j > 0 and arr[j - 1] > arr[j]:
(arr[j], arr[j - 1]) = (arr[j - 1], arr[j])
j = j - 1
my_list = [24, 81, 13, 57, 16]
insertion_sort(my_list)
print(my_list) |
#
# PySNMP MIB module ELTEX-MES-VLAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-MES-VLAN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:02:10 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, single_value_constraint, value_range_constraint, constraints_union) ... |
L, R = int(input()), int(input())
max_xor = 0
for i in range(L, R+1):
for j in range(i+1, R+1):
if i^j > max_xor:
max_xor = i^j
print(max_xor)
| (l, r) = (int(input()), int(input()))
max_xor = 0
for i in range(L, R + 1):
for j in range(i + 1, R + 1):
if i ^ j > max_xor:
max_xor = i ^ j
print(max_xor) |
f = open("file_name.txt", "w") # open file for writing
f.write("Some text with out new line ")
f.write("Some text.\nSome text.\nSome text.")
f.close() # always close the file
# "D:\\myfiles\file_name.txt" - backslash symbol (\) is for path in windows
# "/myfiles/file_name.txt" - slash symbol (/) is for path in ... | f = open('file_name.txt', 'w')
f.write('Some text with out new line ')
f.write('Some text.\nSome text.\nSome text.')
f.close()
f = open('file_name.txt', 'r')
print(f.read())
f.close()
f = open('file_name', 'w')
f.write('line to file')
f.close()
f = open('file_name', 'r')
f.read()
f.close()
f = open('file_name', 'r')
f.... |
class ActivitiesHelper:
'''
Given a pressure data timeseries, calculate a step count
'''
def calculate_step_count(self, dataframe, low_threshold = 0, high_threshold = 4):
p_avg = dataframe.mean(axis=1)
p_diff = p_avg.diff()
status = 0
step_count = 0
for p_diff_t ... | class Activitieshelper:
"""
Given a pressure data timeseries, calculate a step count
"""
def calculate_step_count(self, dataframe, low_threshold=0, high_threshold=4):
p_avg = dataframe.mean(axis=1)
p_diff = p_avg.diff()
status = 0
step_count = 0
for p_diff_t in p... |
class SemiFinder:
def __init__(self):
self.f = ""
self.counter = 0
#Path is inputted from AIPController
#Returns semicolon counter
def sendFile(self, path):
self.f = open(path)
for line in self.f:
try:
self.counter += self.get_all_semis(line... | class Semifinder:
def __init__(self):
self.f = ''
self.counter = 0
def send_file(self, path):
self.f = open(path)
for line in self.f:
try:
self.counter += self.get_all_semis(line)
except:
continue
c = self.counter
... |
#operate string of imgdata ,get the new string after ','
def cutstr(sStr1,sStr2):
nPos = sStr1.index(sStr2)
return sStr1[(nPos+1):]
if __name__ == '__main__':
print (cutstr('qwe,qw123123e2134123',','))
| def cutstr(sStr1, sStr2):
n_pos = sStr1.index(sStr2)
return sStr1[nPos + 1:]
if __name__ == '__main__':
print(cutstr('qwe,qw123123e2134123', ',')) |
class Node:
def __init__(self,data,freq):
self.left=None
self.right=None
self.data=data
self.freq=freq
root=Node("x",5)
root.left=Node("x",2)
root.right=Node("A",3)
root.left.left=Node("B",1)
root.left.right=Node("C",1)
s="1001011" #encoded data
ans=""
root2=roo... | class Node:
def __init__(self, data, freq):
self.left = None
self.right = None
self.data = data
self.freq = freq
root = node('x', 5)
root.left = node('x', 2)
root.right = node('A', 3)
root.left.left = node('B', 1)
root.left.right = node('C', 1)
s = '1001011'
ans = ''
root2 = root
fo... |
# Q6. Write a programs to print the following pattern :
''' a)A
A B
A B C
A B C D
A B C D E
b)1
1 2
1 2 3
1 2 3 4
c) 4 3 2 1
3 2 1
2 1
1 '''
| """ a)A
A B
A B C
A B C D
A B C D E
b)1
1 2
1 2 3
1 2 3 4
c) 4 3 2 1
3 2 1
2 1
1 """ |
data = (
'Shou ', # 0x00
'Yi ', # 0x01
'Zhi ', # 0x02
'Gu ', # 0x03
'Chu ', # 0x04
'Jiang ', # 0x05
'Feng ', # 0x06
'Bei ', # 0x07
'Cay ', # 0x08
'Bian ', # 0x09
'Sui ', # 0x0a
'Qun ', # 0x0b
'Ling ', # 0x0c
'Fu ', # 0x0d
'Zuo ', # 0x0e
'Xia ', # 0x0f
'Xiong ', # 0x10
... | data = ('Shou ', 'Yi ', 'Zhi ', 'Gu ', 'Chu ', 'Jiang ', 'Feng ', 'Bei ', 'Cay ', 'Bian ', 'Sui ', 'Qun ', 'Ling ', 'Fu ', 'Zuo ', 'Xia ', 'Xiong ', '[?] ', 'Nao ', 'Xia ', 'Kui ', 'Xi ', 'Wai ', 'Yuan ', 'Mao ', 'Su ', 'Duo ', 'Duo ', 'Ye ', 'Qing ', 'Uys ', 'Gou ', 'Gou ', 'Qi ', 'Meng ', 'Meng ', 'Yin ', 'Huo ', 'Ch... |
def Even_Length(Test_string):
return "\n".join([words for words in Test_string.split() if len(words) % 2 == 0])
Test_string = input("Enter a String: ")
print(f"Output: {Even_Length(Test_string)}") | def even__length(Test_string):
return '\n'.join([words for words in Test_string.split() if len(words) % 2 == 0])
test_string = input('Enter a String: ')
print(f'Output: {even__length(Test_string)}') |
batch_size = 32
stages = 4
epochs = 32
learning_rate = 0.00005
| batch_size = 32
stages = 4
epochs = 32
learning_rate = 5e-05 |
class InvalidSignError(Exception):
pass
class PositionTakenError(Exception):
pass
class ColumnIsFullError(Exception):
pass | class Invalidsignerror(Exception):
pass
class Positiontakenerror(Exception):
pass
class Columnisfullerror(Exception):
pass |
def adjust_travellers_number(travellers_input_val, num, subtract_btn, add_btn):
while travellers_input_val > num:
subtract_btn.click()
travellers_input_val -= 1
while travellers_input_val < num:
add_btn.click()
travellers_input_val += 1
def set_travellers_number(driver, num, fo... | def adjust_travellers_number(travellers_input_val, num, subtract_btn, add_btn):
while travellers_input_val > num:
subtract_btn.click()
travellers_input_val -= 1
while travellers_input_val < num:
add_btn.click()
travellers_input_val += 1
def set_travellers_number(driver, num, for... |
data_format = {
"Inputs": {
"input2":
{
"ColumnNames": ["temperature", "humidity"],
"Values": [ [ "value", "value" ], ]
}, },
"GlobalParameters": {
}
}
sensor_value = { "ColumnNames": ["currentTime... | data_format = {'Inputs': {'input2': {'ColumnNames': ['temperature', 'humidity'], 'Values': [['value', 'value']]}}, 'GlobalParameters': {}}
sensor_value = {'ColumnNames': ['currentTime', 'indoorTemp', 'indoorHumid', 'indoorIllum', 'outdoorIllum'], 'Values': [['value', 'value', 'value', 'value', 'value']]}
user_input = {... |
class VegaScatterPlot(object):
def __init__(self, width: int, height: int):
self._width = width
self._height = height
def build(self):
# TODO error log here
print("illegal")
assert 0
| class Vegascatterplot(object):
def __init__(self, width: int, height: int):
self._width = width
self._height = height
def build(self):
print('illegal')
assert 0 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Astounding Horror 1930s
chart = ["only", "absent-mindedly", "absolutely", "afterward", "ahead", "alike", "alongside", "always", "around", "asleep", "audibly", "away", "backward", "barely", "blankly", "blind", "blindly", "bravely", "brilliantly", "brokenly", "calmly", "clo... | chart = (['only', 'absent-mindedly', 'absolutely', 'afterward', 'ahead', 'alike', 'alongside', 'always', 'around', 'asleep', 'audibly', 'away', 'backward', 'barely', 'blankly', 'blind', 'blindly', 'bravely', 'brilliantly', 'brokenly', 'calmly', 'close', 'composedly', 'contemptuously', 'curiously', 'decidedly', 'definit... |
#Program 4
#Write a user defined function to accept two strings and concatenate them
#Name:Vikhyat
#Class:12
#Date of Execution:15.06.2021
def FuncConcat(x,y):
print(x+y)
print("Enter 2 strings to see them concatenated:")
l=(input("Enter String 1:"))
u=(input("Enter String 2:"))
FuncConcat(l,u)
'''O... | def func_concat(x, y):
print(x + y)
print('Enter 2 strings to see them concatenated:')
l = input('Enter String 1:')
u = input('Enter String 2:')
func_concat(l, u)
'Output for Program 4\n\nEnter 2 strings to see them concatenated:\nEnter String 1:I love\nEnter String 2:Computers\nI loveComputers\n\n' |
def nocache(app):
@app.after_request
def add_header(resp):
resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
resp.headers['Pragma'] = 'no-cache'
resp.headers['Expires'] = '0'
resp.headers['Cache-Control'] = 'public, max-age=0'
return resp
| def nocache(app):
@app.after_request
def add_header(resp):
resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
resp.headers['Pragma'] = 'no-cache'
resp.headers['Expires'] = '0'
resp.headers['Cache-Control'] = 'public, max-age=0'
return resp |
KEY = 'key'
DESCRIPTION = 'description'
TAGS = 'tags'
XTRA_ATTRS = 'xtra_attrs'
SEARCH_TERMS = 'search_terms'
def list_search_terms(key):
'''Given a stat key, returns a list of search terms.'''
terms = []
if KEY in key:
terms += key[KEY].lower().split('.')
terms.append(key[KEY].lower())
... | key = 'key'
description = 'description'
tags = 'tags'
xtra_attrs = 'xtra_attrs'
search_terms = 'search_terms'
def list_search_terms(key):
"""Given a stat key, returns a list of search terms."""
terms = []
if KEY in key:
terms += key[KEY].lower().split('.')
terms.append(key[KEY].lower())
... |
#
# PySNMP MIB module ADTRAN-AOS-DNS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADTRAN-AOS-DNS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:13:59 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (ad_gen_aos_conformance, ad_gen_aos_applications) = mibBuilder.importSymbols('ADTRAN-AOS', 'adGenAOSConformance', 'adGenAOSApplications')
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATI... |
def spec(packet, config, transmitted_packet):
if packet.device == config['wan device']:
assert transmitted_packet.device == config['lan device']
else:
assert transmitted_packet.device == config['wan device']
# assert transmitted_packet.data[:96] == packet.data[:96] # ignore MACs for now
| def spec(packet, config, transmitted_packet):
if packet.device == config['wan device']:
assert transmitted_packet.device == config['lan device']
else:
assert transmitted_packet.device == config['wan device'] |
class HashTable:
def __init__(self, sz, stp):
self.size = sz
self.step = stp
self.slots = [None] * self.size
def hash_fun(self, value):
result = 0
for pos in range(len(value)):
sym = value[pos]
result += ord(sym) * pos
return result % self... | class Hashtable:
def __init__(self, sz, stp):
self.size = sz
self.step = stp
self.slots = [None] * self.size
def hash_fun(self, value):
result = 0
for pos in range(len(value)):
sym = value[pos]
result += ord(sym) * pos
return result % sel... |
n=int(input())
for i in range(n):
s,k=input().split()
k=int(k)
s=s.replace('-','1').replace('+','0')
s=int(s,2)
ans=0
x=int('1'*k,2)
while s:
ss=len(bin(s))-2
if ss-k < 0:
ans="IMPOSSIBLE"
break
s^=x<<(ss-k)
ans+=1
print("Case #%d: %s"%(i+1,str(ans))) | n = int(input())
for i in range(n):
(s, k) = input().split()
k = int(k)
s = s.replace('-', '1').replace('+', '0')
s = int(s, 2)
ans = 0
x = int('1' * k, 2)
while s:
ss = len(bin(s)) - 2
if ss - k < 0:
ans = 'IMPOSSIBLE'
break
s ^= x << ss - k
... |
# Python - 3.6.0
Test.describe('Basic Tests')
Test.assert_equals(twice_as_old(36, 7), 22)
Test.assert_equals(twice_as_old(55, 30), 5)
Test.assert_equals(twice_as_old(42, 21), 0)
Test.assert_equals(twice_as_old(22, 1), 20)
Test.assert_equals(twice_as_old(29 ,0), 29)
| Test.describe('Basic Tests')
Test.assert_equals(twice_as_old(36, 7), 22)
Test.assert_equals(twice_as_old(55, 30), 5)
Test.assert_equals(twice_as_old(42, 21), 0)
Test.assert_equals(twice_as_old(22, 1), 20)
Test.assert_equals(twice_as_old(29, 0), 29) |
x = [1, 2, 3] # Create the first list
y = [4, 5, 6] # Create the second list
t = (x, y) # Create the tuple from the lists
print(t) # Print the tuple
print(type(t)) # Display the type 'tuple'
print(t[0]) # Display the first list
print(t[0][1]) # Display the second element of the first list
a, b = t # Assi... | x = [1, 2, 3]
y = [4, 5, 6]
t = (x, y)
print(t)
print(type(t))
print(t[0])
print(t[0][1])
(a, b) = t
print(a)
print(b)
a[0] = 'sorry'
print(a)
print(x)
c = ('Hello!',)
print(type(c)) |
#!/usr/bin/env python3
#this progam will write Hello World!
print("Hello World!") | print('Hello World!') |
# 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 isValidBST(self, root: TreeNode) -> bool:
nodes = []
self._isValidBST(root, nodes)
... | class Solution:
def is_valid_bst(self, root: TreeNode) -> bool:
nodes = []
self._isValidBST(root, nodes)
return sorted(nodes) == nodes and len(nodes) == len(set(nodes))
def _is_valid_bst(self, root, nodes):
if root:
self._isValidBST(root.left, nodes)
nod... |
# Write a Python program to remove the first item from a specified list.
color = ["Red", "Black", "Green", "White", "Orange"]
print("Original Color: ", color)
del color[0]
print("After removing the first color: ", color)
print()
| color = ['Red', 'Black', 'Green', 'White', 'Orange']
print('Original Color: ', color)
del color[0]
print('After removing the first color: ', color)
print() |
#
# PySNMP MIB module CISCO-LWAPP-DOT11-CLIENT-CCX-REPORTS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-DOT11-CLIENT-CCX-REPORTS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:05:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davw... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) ... |
def neighbor(neighbor_list,peer_state, **kwargs):
if peer_state in neighbor_list:
return 1
else:
return 0
| def neighbor(neighbor_list, peer_state, **kwargs):
if peer_state in neighbor_list:
return 1
else:
return 0 |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def findTilt(self, root: TreeNode) -> int:
if root is None:
return 0
# post order tree walk traversal
... | class Solution:
def find_tilt(self, root: TreeNode) -> int:
if root is None:
return 0
sum = 0
def post_order_traver(node):
nonlocal sum
if node.left is None and node.right is None:
return node.val
left_sum = 0 if node.left is ... |
# Tree Node
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
class Solution:
# The given root is the root of the Binary Tree
# Return the root of the generated BST
def binaryTreeToBST_Util(self, root):
if root is None:
... | class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
class Solution:
def binary_tree_to_bst__util(self, root):
if root is None:
return
self.binaryTreeToBST_Util(root.left)
self.values.append(root.data)
self... |
#Defining function for Linear Search
def Linear_Search(input_list, key):
flag = 0
#Iterating each item in the list and comparing it with the key searching for
for i in range(len(input_list)):
if(input_list[i] == key):
#If key matches with any of the list items
flag = 1
... | def linear__search(input_list, key):
flag = 0
for i in range(len(input_list)):
if input_list[i] == key:
flag = 1
print('\nKey is found in the position: {}'.format(i))
if flag == 0:
print('\nKey not found')
input_list = [11, 12, 13, 14, 15, 16, 17, 18, 19]
print('List ... |
class Token():
def __init__(self, classe, lexema, tipo):
self.classe = classe
self.lexema = lexema
self.tipo = tipo
def __repr__(self) -> str:
return 'classe: ' + self.classe + ', lexema: ' + self.lexema + ', tipo: ' + self.tipo
| class Token:
def __init__(self, classe, lexema, tipo):
self.classe = classe
self.lexema = lexema
self.tipo = tipo
def __repr__(self) -> str:
return 'classe: ' + self.classe + ', lexema: ' + self.lexema + ', tipo: ' + self.tipo |
def program():
intProgram = [
1,12,2,3,1,1,2,3,1,3,
4,3,1,5,0,3,2,1,10,19,
1,6,19,23,1,10,23,27,2,27,
13,31,1,31,6,35,2,6,35,39,
1,39,5,43,1,6,43,47,2,6,
47,51,1,51,5,55,2,55,9,59,
1,6,59,63,1,9,63,67,1,67,
10,71,2,9,71,75,1,6,75,79,
1,5,79,83,2,83,10,87,1,87,
5,91,1,91,9,95,1,6,95,99,
... | def program():
int_program = [1, 12, 2, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 1, 10, 19, 1, 6, 19, 23, 1, 10, 23, 27, 2, 27, 13, 31, 1, 31, 6, 35, 2, 6, 35, 39, 1, 39, 5, 43, 1, 6, 43, 47, 2, 6, 47, 51, 1, 51, 5, 55, 2, 55, 9, 59, 1, 6, 59, 63, 1, 9, 63, 67, 1, 67, 10, 71, 2, 9, 71, 75, 1, 6, 75, 79, 1, 5, 79, ... |
class Solution:
def minSubArrayLen(self, s: int, nums: List[int]) -> int:
ans = float('inf')
left = 0
sum_ = 0
for right, num in enumerate(nums):
sum_ += num
while left <= right and sum_ >= s:
ans = min(ans, right - left + 1)
... | class Solution:
def min_sub_array_len(self, s: int, nums: List[int]) -> int:
ans = float('inf')
left = 0
sum_ = 0
for (right, num) in enumerate(nums):
sum_ += num
while left <= right and sum_ >= s:
ans = min(ans, right - left + 1)
... |
class Solution:
def res(self, a, b):
count = 0
for i in range(1, len(a)):
if a[i] != a[0] and b[i] != a[0]:
return -1
elif a[i] != a[0]:
a[i] = b[i]
count += 1
return count
def minDominoRotations(self, A: list, B: ... | class Solution:
def res(self, a, b):
count = 0
for i in range(1, len(a)):
if a[i] != a[0] and b[i] != a[0]:
return -1
elif a[i] != a[0]:
a[i] = b[i]
count += 1
return count
def min_domino_rotations(self, A: list, B... |
# STP2019 - FALL
# Observable
class Publisher(object):
subscribers = set()
def register(self, user):
self.subscribers.add(user)
def unregister(self, user):
self.subscribers.discard(user)
def send_notifications(self, message):
for user in self.subscribers:
user.up... | class Publisher(object):
subscribers = set()
def register(self, user):
self.subscribers.add(user)
def unregister(self, user):
self.subscribers.discard(user)
def send_notifications(self, message):
for user in self.subscribers:
user.update(message)
class Subscriber(... |
def lee_entero():
while True:
entrada = raw_input("Escribe un numero entero: ")
try:
entrada = int(entrada)
return entrada
except ValueError:
print ("La entrada es incorrecta: escribe un numero entero") | def lee_entero():
while True:
entrada = raw_input('Escribe un numero entero: ')
try:
entrada = int(entrada)
return entrada
except ValueError:
print('La entrada es incorrecta: escribe un numero entero') |
'''
The __init__.py file makes Python treat directories containing it as modules.
Furthermore, this is the first file to be loaded in a module, so you can use
it to execute code that you want to run each time a module is loaded, or
specify the submodules to be exported.
''' | """
The __init__.py file makes Python treat directories containing it as modules.
Furthermore, this is the first file to be loaded in a module, so you can use
it to execute code that you want to run each time a module is loaded, or
specify the submodules to be exported.
""" |
class Exponentiation:
@staticmethod
def exponentiation(base, exponent):
return base ** exponent | class Exponentiation:
@staticmethod
def exponentiation(base, exponent):
return base ** exponent |
class Board:
def __init__(self, id) -> None:
self.id = id
self.parts = [] #note will be array of arrays [part object, qty used per board]
self.flag = False #True if stock issue
def AddPart(self, part, qty):
self.parts.append([part, qty])
def IsMatch(self, testid)... | class Board:
def __init__(self, id) -> None:
self.id = id
self.parts = []
self.flag = False
def add_part(self, part, qty):
self.parts.append([part, qty])
def is_match(self, testid):
if self.id == testid:
return True
else:
return Fals... |
# hw01_05
print('3 + 4 =', end=' ')
print(3 + 4)
'''
3 + 4 = 7
'''
| print('3 + 4 =', end=' ')
print(3 + 4)
'\n\n3 + 4 = 7\n\n' |
f = open('text1.txt')
v = open('text2.txt')
list1 = []
list2 = []
result = []
for line in f:
list1.append(line)
for line in v:
list2.append(line)
for i in range(len(list1)):
if list1[i] != list2[i]:
a = str(list1[i]) + '!=' + str(list2[i])
result.append(a)
print(result)
| f = open('text1.txt')
v = open('text2.txt')
list1 = []
list2 = []
result = []
for line in f:
list1.append(line)
for line in v:
list2.append(line)
for i in range(len(list1)):
if list1[i] != list2[i]:
a = str(list1[i]) + '!=' + str(list2[i])
result.append(a)
print(result) |
a = input("digite um numero em binario: ")
for n in (len(a)):
if n==1:
x=1
b=x*len(a)
print(b)
| a = input('digite um numero em binario: ')
for n in len(a):
if n == 1:
x = 1
b = x * len(a)
print(b) |
def find(arr,n,x):
start=0
end=n-1
result=-1
res=-1
mid=start+(end-start)//2
while start<end:
if arr[mid]==x:
result=mid
end=mid-1
elif arr[mid]>x:
end=mid-1
else:
start=mid+1
while start<end:
if arr[mi... | def find(arr, n, x):
start = 0
end = n - 1
result = -1
res = -1
mid = start + (end - start) // 2
while start < end:
if arr[mid] == x:
result = mid
end = mid - 1
elif arr[mid] > x:
end = mid - 1
else:
start = mid + 1
whil... |
class Solution:
def minCostClimbingStairs(self, cost: List[int]) -> int:
min_cost = {
0: 0,
1: 0,
}
n = len(cost)
for i in range(2, n+1):
min_cost[i] = min(min_cost[i-1] + cost[i-1], min_cost[i-2] + cost[i-2])
return min_cost[n]
| class Solution:
def min_cost_climbing_stairs(self, cost: List[int]) -> int:
min_cost = {0: 0, 1: 0}
n = len(cost)
for i in range(2, n + 1):
min_cost[i] = min(min_cost[i - 1] + cost[i - 1], min_cost[i - 2] + cost[i - 2])
return min_cost[n] |
CONFIG = {
'api_key': 'to be filled out',
'api_key_secret': 'to be filled out',
'access_token': 'to be filled out',
'access_token_secret': 'to be filled out',
'images_base_folder': 'to be filled out',
'images_backlog_folder': 'to be filled out',
'telegram_token': 'to be filled out',
'... | config = {'api_key': 'to be filled out', 'api_key_secret': 'to be filled out', 'access_token': 'to be filled out', 'access_token_secret': 'to be filled out', 'images_base_folder': 'to be filled out', 'images_backlog_folder': 'to be filled out', 'telegram_token': 'to be filled out', 'admin_chat_id': 0, 'user_chat_id': 0... |
def final_multipy(num: int) -> int:
if num < 10:
return num
n = 1
for i in str(num):
n *= int(i)
return final_multipy(n)
def final_multipy2(num: int) -> int:
return num if num < 10 else final_multipy2(reduce(lambda x, y: x*y, [int(i) for i in str(num)]))
| def final_multipy(num: int) -> int:
if num < 10:
return num
n = 1
for i in str(num):
n *= int(i)
return final_multipy(n)
def final_multipy2(num: int) -> int:
return num if num < 10 else final_multipy2(reduce(lambda x, y: x * y, [int(i) for i in str(num)])) |
# Copyright (c) Project Jupyter.
# Distributed under the terms of the Modified BSD License.
version_info = (0, 9, 0)
__version__ = ".".join(map(str, version_info))
| version_info = (0, 9, 0)
__version__ = '.'.join(map(str, version_info)) |
def incorrectPasscodeAttempts(passcode, attempts):
cnt = 0
for att in attempts:
if att == passcode:
cnt = 0
else:
cnt += 1
if cnt >= 10:
return True
return False | def incorrect_passcode_attempts(passcode, attempts):
cnt = 0
for att in attempts:
if att == passcode:
cnt = 0
else:
cnt += 1
if cnt >= 10:
return True
return False |
options = [
"USD",
"EUR",
"JPY",
"GBP",
"AUD",
"CAD",
"CHF",
"CNY",
"HKD",
"NZD",
"SEK",
"KRW",
"SGD",
"NOK",
"MXN",
"INR",
"RUB",
"ZAR",
"TRY",
"BRL",
]
opt2=[
"USD",
"EUR",
"JPY",
"GBP",
"A... | options = ['USD', 'EUR', 'JPY', 'GBP', 'AUD', 'CAD', 'CHF', 'CNY', 'HKD', 'NZD', 'SEK', 'KRW', 'SGD', 'NOK', 'MXN', 'INR', 'RUB', 'ZAR', 'TRY', 'BRL']
opt2 = ['USD', 'EUR', 'JPY', 'GBP', 'AUD', 'CAD', 'CHF', 'CNY', 'HKD', 'NZD', 'SEK', 'KRW', 'SGD', 'NOK', 'MXN', 'INR', 'RUB', 'ZAR', 'TRY', 'BRL'] |
# noinspection PyShadowingBuiltins,PyUnusedLocal
def compute(x, y):
if all(0 <= n <= 100 for n in (x, y)):
return x + y
else:
raise ValueError('Please provide two integer numbers')
| def compute(x, y):
if all((0 <= n <= 100 for n in (x, y))):
return x + y
else:
raise value_error('Please provide two integer numbers') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.