content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
seat_ids = []
def binary_partition(start, end, identifier, lower_id, upper_id):
if start == end:
return start
half_range = int((end - start + 1) / 2)
if identifier[0] == lower_id:
new_start = start
new_end = end - half_range
elif identifier[0] == upper_id:
new_start =... | seat_ids = []
def binary_partition(start, end, identifier, lower_id, upper_id):
if start == end:
return start
half_range = int((end - start + 1) / 2)
if identifier[0] == lower_id:
new_start = start
new_end = end - half_range
elif identifier[0] == upper_id:
new_start = st... |
def skyhook_calculator(upper_vel,delta_vel):
Cmax = 4000
Cmin = 300
epsilon = 0.0001
alpha = 0.5
sat_limit = 800
if upper_vel * delta_vel >= 0:
C = (alpha * Cmax * upper_vel + (1 - alpha) * Cmax * upper_vel)/(delta_vel + epsilon)
C = min(C,Cmax)
u = C * del... | def skyhook_calculator(upper_vel, delta_vel):
cmax = 4000
cmin = 300
epsilon = 0.0001
alpha = 0.5
sat_limit = 800
if upper_vel * delta_vel >= 0:
c = (alpha * Cmax * upper_vel + (1 - alpha) * Cmax * upper_vel) / (delta_vel + epsilon)
c = min(C, Cmax)
u = C * delta_vel
... |
def printmove(fr,to):
print("Moved from " + str(fr)+" to "+str(to))
def TowerOfHanoi(n,fr,to,spare):
if n==1:
printmove(fr,to)
else:
TowerOfHanoi(n-1,fr,spare,to)
TowerOfHanoi(1,fr,to,spare)
TowerOfHanoi(n-1,spare,to,fr)
TowerOfHanoi(int(input("Enter the number of rings in the source peg\n")),'A','B','C') | def printmove(fr, to):
print('Moved from ' + str(fr) + ' to ' + str(to))
def tower_of_hanoi(n, fr, to, spare):
if n == 1:
printmove(fr, to)
else:
tower_of_hanoi(n - 1, fr, spare, to)
tower_of_hanoi(1, fr, to, spare)
tower_of_hanoi(n - 1, spare, to, fr)
tower_of_hanoi(int(inp... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
n = input()
a = set(raw_input().strip().split(" "))
m = input()
b = set(raw_input().strip().split(" "))
print(len(a.intersection(b)))
| n = input()
a = set(raw_input().strip().split(' '))
m = input()
b = set(raw_input().strip().split(' '))
print(len(a.intersection(b))) |
"""
day6b - https://adventofcode.com/2020/day/6
* Part 2
Example: 6
Identify the questions to which everyone answered "yes"!
3520
"""
def load_data():
answers = {}
answer_id = 1
answers[1] = []
datafile = 'input-day6'
with open(datafile, 'r') as input:
for line in input:
cle... | """
day6b - https://adventofcode.com/2020/day/6
* Part 2
Example: 6
Identify the questions to which everyone answered "yes"!
3520
"""
def load_data():
answers = {}
answer_id = 1
answers[1] = []
datafile = 'input-day6'
with open(datafile, 'r') as input:
for line in input:
cle... |
# how to copy a list
months = ['jan', 'feb', 'march', 'apr', 'may']
months_copy = months[:]
print(months_copy)
print(months) | months = ['jan', 'feb', 'march', 'apr', 'may']
months_copy = months[:]
print(months_copy)
print(months) |
data = (
'nzup', # 0x00
'nzurx', # 0x01
'nzur', # 0x02
'nzyt', # 0x03
'nzyx', # 0x04
'nzy', # 0x05
'nzyp', # 0x06
'nzyrx', # 0x07
'nzyr', # 0x08
'sit', # 0x09
'six', # 0x0a
'si', # 0x0b
'sip', # 0x0c
'siex', # 0x0d
'sie', # 0x0e
'siep', # 0x0f
'sat', # 0x10
'sax', #... | data = ('nzup', 'nzurx', 'nzur', 'nzyt', 'nzyx', 'nzy', 'nzyp', 'nzyrx', 'nzyr', 'sit', 'six', 'si', 'sip', 'siex', 'sie', 'siep', 'sat', 'sax', 'sa', 'sap', 'suox', 'suo', 'suop', 'sot', 'sox', 'so', 'sop', 'sex', 'se', 'sep', 'sut', 'sux', 'su', 'sup', 'surx', 'sur', 'syt', 'syx', 'sy', 'syp', 'syrx', 'syr', 'ssit', ... |
'''
import requests
import copy
host = "http://172.30.1.8"
uri = "/changeuser.ghp"
org_headers = {
"User-Agent": "Mozilla/4.0",
"Host": host.split("://")[1],
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "en-us",
"Accept-Encoding": "gzip, deflate",... | """
import requests
import copy
host = "http://172.30.1.8"
uri = "/changeuser.ghp"
org_headers = {
"User-Agent": "Mozilla/4.0",
"Host": host.split("://")[1],
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "en-us",
"Accept-Encoding": "gzip, deflate",... |
def create_matrix(rows):
matrix = [[int(x) for x in input().split()] for _ in range(rows)]
return matrix
def valid_cell(row, col, size):
return 0 <= row < size and 0 <= col < size
def print_matrix(matrix):
[print(' '.join([str(x) for x in row])) for row in matrix] # did this for the sake of using c... | def create_matrix(rows):
matrix = [[int(x) for x in input().split()] for _ in range(rows)]
return matrix
def valid_cell(row, col, size):
return 0 <= row < size and 0 <= col < size
def print_matrix(matrix):
[print(' '.join([str(x) for x in row])) for row in matrix]
rows = int(input())
matrix = create_m... |
#Leia uma temperatura em graus Celsius e apresente-a convertida em Kelvin.
# A formula da conversao eh: K=C+273.15,
# sendo K a temperatura em Kelvin e c a temperatura em celsius.
C=float(input("Informe a temperatura em Celsius: "))
K=C+273.15
print(f"A temperatura em Kelvin eh {round(K,1)}") | c = float(input('Informe a temperatura em Celsius: '))
k = C + 273.15
print(f'A temperatura em Kelvin eh {round(K, 1)}') |
def operate(operator, *args):
result = 1
for x in args:
if operator == "+":
return sum(args)
elif operator == "*":
result *= x
elif operator == "/":
result /= x
return result
print(operate("+", 1, 2, 3))
print(operate("*", 3, 4))
print(operate("/"... | def operate(operator, *args):
result = 1
for x in args:
if operator == '+':
return sum(args)
elif operator == '*':
result *= x
elif operator == '/':
result /= x
return result
print(operate('+', 1, 2, 3))
print(operate('*', 3, 4))
print(operate('/',... |
class MonoBasicPackage (GitHubTarballPackage):
def __init__(self):
GitHubTarballPackage.__init__(self, 'mono', 'mono-basic', '4.8', 'e31cb702937a0adcc853250a0989c5f43565f9b8',
configure='./configure --prefix="%{staged_profile}"')
def install(self):
self.s... | class Monobasicpackage(GitHubTarballPackage):
def __init__(self):
GitHubTarballPackage.__init__(self, 'mono', 'mono-basic', '4.8', 'e31cb702937a0adcc853250a0989c5f43565f9b8', configure='./configure --prefix="%{staged_profile}"')
def install(self):
self.sh('./configure --prefix="%{staged_prefix... |
# We start our program by informing the user that this program is for a calculator.
print("Welcome to the calculator program!")
# Our program will run until the user chooses to exit, so we define a variable to
# hold the text that a user must enter to exit the program. Since we intend that
# this variable be constant ... | print('Welcome to the calculator program!')
exit_user_input_option = 'EXIT'
print('Enter ' + EXIT_USER_INPUT_OPTION + ' after a calculation to end program.')
user_input_after_calculation = ''
while EXIT_USER_INPUT_OPTION != user_input_after_calculation:
first_number = int(input('Enter first number: '))
second_n... |
# Copyright 2020 Keren Ye, University of Pittsburgh
#
# 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... | class Groundingtuple(object):
entity_proposal_id = None
entity_proposal_box = None
entity_proposal_score = None
entity_proposal_feature = None
class Detectiontuple(object):
valid_detections = None
nmsed_proposal_id = None
nmsed_boxes = None
nmsed_scores = None
nmsed_classes = None
... |
##################################################
##
## Auto generate the simple WAT unit tests for
## wrap, trunc, extend, convert, demote, promote
## and reinterpret operators.
##
##################################################
tyi32 = "i32";
tyi64 = "i64";
tyf32 = "f32";
tyf64 = "f64";
tests =... | tyi32 = 'i32'
tyi64 = 'i64'
tyf32 = 'f32'
tyf64 = 'f64'
tests = ['i32_wrap_i64 ', 'i32_trunc_f32_s ', 'i32_trunc_f32_u ', 'i32_trunc_f64_s ', 'i32_trunc_f64_u ', 'i64_extend_i32_s ', 'i64_extend_i32_u ', 'i64_trunc_f32_s ', 'i64_trunc_f32_u ', 'i64_trunc_f64_s ', 'i64_trunc_f64_u ', 'f... |
# -*- coding: utf-8 -*-
# !/bin/env python
__all__ = ['Driver']
"""
This script defines objects representing the drivers
"""
class Driver(object):
"""
Represent a Driver. 3 properties are mandatory: starting time, starting and ending nodes.
For continuous solution, a traffic weight can be specified: be... | __all__ = ['Driver']
'\nThis script defines objects representing the drivers\n'
class Driver(object):
"""
Represent a Driver. 3 properties are mandatory: starting time, starting and ending nodes.
For continuous solution, a traffic weight can be specified: between 0 and 1
"""
def __init__(self, sta... |
# M0_C5 - Mean, Median
def mean(scores):
# Write your code here
return "not implemented"
def median(scores):
# Write your code here
return "not implemented"
if __name__ == '__main__':
scores = input("Input list of test scores, space-separated: ")
scores_list = [int(i) for i in scores.split()]... | def mean(scores):
return 'not implemented'
def median(scores):
return 'not implemented'
if __name__ == '__main__':
scores = input('Input list of test scores, space-separated: ')
scores_list = [int(i) for i in scores.split()]
mean = mean(scores_list)
median = median(scores_list)
print(f'Mean... |
entradas = int(input())
def cesar_cifra(frase, deslocamento):
frase_codificada = ""
for letra in frase:
ascii_value = ord(letra)-deslocamento
if ascii_value < 65:
ascii_value = 91 - (65-ascii_value)
frase_codificada += chr(ascii_value)
return frase_codificada
for i in... | entradas = int(input())
def cesar_cifra(frase, deslocamento):
frase_codificada = ''
for letra in frase:
ascii_value = ord(letra) - deslocamento
if ascii_value < 65:
ascii_value = 91 - (65 - ascii_value)
frase_codificada += chr(ascii_value)
return frase_codificada
for i i... |
all_cells = input().split("#")
water = int(input())
effort = 0
fire = 0
cells_value = []
total_fire = 0
for cell in all_cells:
current_cell = cell.split(" = ")
type_of_fire = current_cell[0]
cell_value = int(current_cell[1])
if type_of_fire == "High":
if not 81 <= cell_value <= 125:... | all_cells = input().split('#')
water = int(input())
effort = 0
fire = 0
cells_value = []
total_fire = 0
for cell in all_cells:
current_cell = cell.split(' = ')
type_of_fire = current_cell[0]
cell_value = int(current_cell[1])
if type_of_fire == 'High':
if not 81 <= cell_value <= 125:
... |
""" Contains Template class """
class Template(object):
'''
Represents a Template and all its data
'''
def __init__(self):
self.name = None
self.keyval = []
self.context = None
def __repr__(self):
return "{}".format(self.keyval)
| """ Contains Template class """
class Template(object):
"""
Represents a Template and all its data
"""
def __init__(self):
self.name = None
self.keyval = []
self.context = None
def __repr__(self):
return '{}'.format(self.keyval) |
class NextcloudRequestException(Exception):
def __init__(self, request=None, message=None):
self.request = request
message = message or f"Error {request.status_code}: {request.get_error_message()}"
super().__init__(message)
class NextcloudDoesNotExist(NextcloudRequest... | class Nextcloudrequestexception(Exception):
def __init__(self, request=None, message=None):
self.request = request
message = message or f'Error {request.status_code}: {request.get_error_message()}'
super().__init__(message)
class Nextclouddoesnotexist(NextcloudRequestException):
pass
... |
def generate_game_stats(sheets):
games = 0
wins = [0, 0, 0] #Re, Contra, Tie
for sheet in sheets:
for row_int in range(1, len(sheet)):
row = sheet[row_int]
# print(row)
if len(row) == 5:
games += 1
if int(row[4]) >= 1:
... | def generate_game_stats(sheets):
games = 0
wins = [0, 0, 0]
for sheet in sheets:
for row_int in range(1, len(sheet)):
row = sheet[row_int]
if len(row) == 5:
games += 1
if int(row[4]) >= 1:
wins[0] += 1
elif i... |
rf_commands = {
'light/off': '2600500000012b9312131337131312131213131213121338133713131238133713131238133713131312133714371337143713121312131214371312131214111411143713371436140005610001294813000d050000000000000000',
'aircon/off': '2600d6007f3d110e112c110f112c110e112c110f112c110e112c110f112c112c110e112c110f112c112c11... | rf_commands = {'light/off': '2600500000012b9312131337131312131213131213121338133713131238133713131238133713131312133714371337143713121312131214371312131214111411143713371436140005610001294813000d050000000000000000', 'aircon/off': '2600d6007f3d110e112c110f112c110e112c110f112c110e112c110f112c112c110e112c110f112c112c112c1... |
#L01EX06
topo = int(input())
carta = int(input())
if (topo % 13) == (carta % 13) or carta % 13 == 11:
print("True")
elif (-12 <= (topo - carta)) and ((topo - carta) <= 12):
print("True")
else:
print("False")
| topo = int(input())
carta = int(input())
if topo % 13 == carta % 13 or carta % 13 == 11:
print('True')
elif -12 <= topo - carta and topo - carta <= 12:
print('True')
else:
print('False') |
testcases = int(input())
for _ in range(0, testcases):
pc, pr = list(map(int, input().split()))
nnm_of_9_pc = pc if pc % 9 == 0 else pc + 9 - (pc % 9)
nnm_of_9_pr = pr if pr % 9 == 0 else pr + 9 - (pr % 9)
digits_pc = nnm_of_9_pc // 9
digits_pr = nnm_of_9_pr // 9
who_wins = '1' if digits_pc... | testcases = int(input())
for _ in range(0, testcases):
(pc, pr) = list(map(int, input().split()))
nnm_of_9_pc = pc if pc % 9 == 0 else pc + 9 - pc % 9
nnm_of_9_pr = pr if pr % 9 == 0 else pr + 9 - pr % 9
digits_pc = nnm_of_9_pc // 9
digits_pr = nnm_of_9_pr // 9
who_wins = '1' if digits_pc >= dig... |
FACTORY_IGNORE_FIELDS = ['id', 'created', 'modified', 'archived']
FACTORY_INTEGER_FIELDS = [
'BigIntegerField',
'IntegerField',
'PositiveIntegerField',
'PositiveSmallIntegerField',
'SmallIntegerField',
]
FACTORY_FLOAT_FIELDS = [
'FloatField',
'MoneyField',
]
FACTORY_TEXT_FIELDS = [
'Text... | factory_ignore_fields = ['id', 'created', 'modified', 'archived']
factory_integer_fields = ['BigIntegerField', 'IntegerField', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'SmallIntegerField']
factory_float_fields = ['FloatField', 'MoneyField']
factory_text_fields = ['TextField']
class Factorymeta(object):
... |
elements = {
'login_page': {
'input_email': '//*[@id="ap_email"]',
'btn_continue': '//*[@id="continue"]',
'input_password': '//*[@id="ap_password"]',
'btn_login': '//*[@id="signInSubmit"]'
},
'header_confirm': '/html/body/div[1]/header/div/div[1]/div[3]/div/a[1]/div/span',
... | elements = {'login_page': {'input_email': '//*[@id="ap_email"]', 'btn_continue': '//*[@id="continue"]', 'input_password': '//*[@id="ap_password"]', 'btn_login': '//*[@id="signInSubmit"]'}, 'header_confirm': '/html/body/div[1]/header/div/div[1]/div[3]/div/a[1]/div/span', 'bnt_buy_one_click': '/html/body/div[1]/div[2]/di... |
"""
Implement the following operations of a queue using stacks.
push(x) -- Push element x to the back of queue.
pop() -- Removes the element from in front of queue.
peek() -- Get the front element.
empty() -- Return whether the queue is empty.
Notes:
You must use only standard operations of a stack... | """
Implement the following operations of a queue using stacks.
push(x) -- Push element x to the back of queue.
pop() -- Removes the element from in front of queue.
peek() -- Get the front element.
empty() -- Return whether the queue is empty.
Notes:
You must use only standard operations of a stack... |
valor_real = float(input("\033[1;30mDigite o valor na carteira?\033[m \033[1;32mR$\033[m"))
dolares = valor_real / 3.27
print("\033[1;37mO valor\033[m \033[1;32mR$: {0:.2f} reais\033[m \033[1;37mpode comprar\033[m \033[1;32mUSD$: {1:.2f} dolares\033[m \033[1;37m!\033[m".format(valor_real, dolares))
| valor_real = float(input('\x1b[1;30mDigite o valor na carteira?\x1b[m \x1b[1;32mR$\x1b[m'))
dolares = valor_real / 3.27
print('\x1b[1;37mO valor\x1b[m \x1b[1;32mR$: {0:.2f} reais\x1b[m \x1b[1;37mpode comprar\x1b[m \x1b[1;32mUSD$: {1:.2f} dolares\x1b[m \x1b[1;37m!\x1b[m'.format(valor_real, dolares)) |
# Problem 026 - Reciprocal cycles
"""
Note: This task could be solved faster by looping over a list of all
cyclic prime numbers. But then cycle_length would be easier to write
"""
def generate_decimal_iterator(denominator):
numerator = 10
while numerator != 0:
yield numerator // denominator
n... | """
Note: This task could be solved faster by looping over a list of all
cyclic prime numbers. But then cycle_length would be easier to write
"""
def generate_decimal_iterator(denominator):
numerator = 10
while numerator != 0:
yield (numerator // denominator)
numerator = numerator % denominator... |
class Node:
def __init__(self,val=None,nxt=None,prev=None):
self.val = val
self.nxt = nxt
self.prev = prev
class LL:
def __init__(self):
self.head = Node()
self.tail = Node()
self.head.nxt = self.tail
self.tail.prev = self.head
def find(s... | class Node:
def __init__(self, val=None, nxt=None, prev=None):
self.val = val
self.nxt = nxt
self.prev = prev
class Ll:
def __init__(self):
self.head = node()
self.tail = node()
self.head.nxt = self.tail
self.tail.prev = self.head
def find(self, va... |
class Solution:
def findUnsortedSubarray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
sorted_nums = sorted(nums)
start = 0
end = len(nums) - 1
while start <= end and nums[start] == sorted_nums[start]:
start += 1
while e... | class Solution:
def find_unsorted_subarray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
sorted_nums = sorted(nums)
start = 0
end = len(nums) - 1
while start <= end and nums[start] == sorted_nums[start]:
start += 1
while e... |
# Letter Combinations of a Phone Number
# ttungl@gmail.com
class Solution(object):
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
# sol 1
d = {'2': 'abc', '3':'def', '4':'ghi', '5':'jkl', '6': 'mno', '7':'pqrs', '8':'tuv', '... | class Solution(object):
def letter_combinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
d = {'2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', '8': 'tuv', '9': 'wxyz'}
if len(digits) == 0:
return []
return... |
p1 = 0.49
p2 = 0.38
p3 = 0.1
p4 = 0.03
p = p1 * p1 + p1 * p2 + p1 * p3 + p1 * p4 + p2 * p2 + p2 * p4 + p3 * p3 + p3 * p4 + p4 * p4
print(p)
print(10 * 0.2 * 0.8 ** 9) | p1 = 0.49
p2 = 0.38
p3 = 0.1
p4 = 0.03
p = p1 * p1 + p1 * p2 + p1 * p3 + p1 * p4 + p2 * p2 + p2 * p4 + p3 * p3 + p3 * p4 + p4 * p4
print(p)
print(10 * 0.2 * 0.8 ** 9) |
class Developer:
DUNDY = 321730481903370240
ADM = 600443374587346989
TEMPLAR = 108281077319077888
GHOSTRIDER = 846009958062358548
| class Developer:
dundy = 321730481903370240
adm = 600443374587346989
templar = 108281077319077888
ghostrider = 846009958062358548 |
def computeParameterValue(sources):
mapping = {}
for idx, source in enumerate(sources):
for kv in source:
k, v = kv.split(":")
mapping[k] = v
results = []
for key in mapping:
results.append(mapping[key])
return results
| def compute_parameter_value(sources):
mapping = {}
for (idx, source) in enumerate(sources):
for kv in source:
(k, v) = kv.split(':')
mapping[k] = v
results = []
for key in mapping:
results.append(mapping[key])
return results |
#coding=utf-8
'''
Created on 2014-1-5
@author: zhangtiande
'''
| """
Created on 2014-1-5
@author: zhangtiande
""" |
for _ in range(int(input())):
n = int(input())
temp = list(map(int, input().split()))
c = 0
for i in range(n-1):
temp2 = list(map(int, input().split()))
if c==0:
for j in range(n-1):
if temp[j]==1 and (temp[j+1]==1 or temp2[j]==1):
c=1
... | for _ in range(int(input())):
n = int(input())
temp = list(map(int, input().split()))
c = 0
for i in range(n - 1):
temp2 = list(map(int, input().split()))
if c == 0:
for j in range(n - 1):
if temp[j] == 1 and (temp[j + 1] == 1 or temp2[j] == 1):
... |
class OperatingSystemNotSupported(Exception):
def __init__(self, operating_system: str) -> None:
self._operating_system = operating_system
message = f"operating system not supported - {operating_system}"
super().__init__(message)
@property
def operating_system(self) -> str:
... | class Operatingsystemnotsupported(Exception):
def __init__(self, operating_system: str) -> None:
self._operating_system = operating_system
message = f'operating system not supported - {operating_system}'
super().__init__(message)
@property
def operating_system(self) -> str:
... |
"""restructuredtext (rst) documentation support
"""
__import__("pkg_resources").declare_namespace(__name__)
__version__ = "1.8.1"
| """restructuredtext (rst) documentation support
"""
__import__('pkg_resources').declare_namespace(__name__)
__version__ = '1.8.1' |
money = int(input())
cake = money * 0.2
drinks = cake - 0.45 * cake
animator = 1/3 * money
price = money + cake + drinks + animator
print (price) | money = int(input())
cake = money * 0.2
drinks = cake - 0.45 * cake
animator = 1 / 3 * money
price = money + cake + drinks + animator
print(price) |
class Solution:
def closeStrings(self, word1: str, word2: str) -> bool:
if len(word1)!=len(word2):
return False
show1=[0]*26
show2=[0]*26
for i in range(len(word1)):
show1[ord(word1[i])-ord('a')]+=1
show2[ord(word2[i])-ord('a')]+=1
... | class Solution:
def close_strings(self, word1: str, word2: str) -> bool:
if len(word1) != len(word2):
return False
show1 = [0] * 26
show2 = [0] * 26
for i in range(len(word1)):
show1[ord(word1[i]) - ord('a')] += 1
show2[ord(word2[i]) - ord('a')] +... |
"""
File: largest_digit.py
Name:
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""
def main():
print(find_largest_digit(12345)) # 5
print(find_la... | """
File: largest_digit.py
Name:
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""
def main():
print(find_largest_digit(12345))
print(find_largest_... |
# file grafo.py
class Grafo:
def __init__(self, es_dirigido = False, vertices_init = []):
self.vertices = {}
for v in vertices_init:
self.vertices[v] = {}
self.es_dirigido = es_dirigido
def __contains__(self, v):
return v in self.vertices
def __len__(self):
return len(self.vertices)
def __iter__(sel... | class Grafo:
def __init__(self, es_dirigido=False, vertices_init=[]):
self.vertices = {}
for v in vertices_init:
self.vertices[v] = {}
self.es_dirigido = es_dirigido
def __contains__(self, v):
return v in self.vertices
def __len__(self):
return len(self... |
#
# PySNMP MIB module NBS-SIGCOND-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-SIGCOND-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:17:38 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, single_value_constraint, value_range_constraint, constraints_intersection) ... |
"""
Write a program that takes two strings
from the user and checks if they represent
a valid user name.
Valid users and passwords:
apple => red
lettuce => green
lemon => yellow
orange => orange
When valid credentials are entered print:
Welcome Master
And when invalid credentials are entered print... | """
Write a program that takes two strings
from the user and checks if they represent
a valid user name.
Valid users and passwords:
apple => red
lettuce => green
lemon => yellow
orange => orange
When valid credentials are entered print:
Welcome Master
And when invalid credentials are entered print... |
def dayOfProgrammer(year):
s=0
if 1700 <= year <= 1917:
if year % 4==0:
for i in range(1, 9):
if i % 2 == 0:
s += 30
else:
s += 31
print(256 - s, ".09", ".", year, sep='')
else:
for i in r... | def day_of_programmer(year):
s = 0
if 1700 <= year <= 1917:
if year % 4 == 0:
for i in range(1, 9):
if i % 2 == 0:
s += 30
else:
s += 31
print(256 - s, '.09', '.', year, sep='')
else:
for ... |
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
res = [[0] * n for _ in range(n)]
xi,yi,dx,dy = 0,0,1,0
for i in range(1,n*n+1):
res[yi][xi]=i
if not 0 <= yi+dy < n or not 0 <= xi+dx < n or res[yi+dy][xi+dx]:
dy,dx = dx,-dy
... | class Solution:
def generate_matrix(self, n: int) -> List[List[int]]:
res = [[0] * n for _ in range(n)]
(xi, yi, dx, dy) = (0, 0, 1, 0)
for i in range(1, n * n + 1):
res[yi][xi] = i
if not 0 <= yi + dy < n or not 0 <= xi + dx < n or res[yi + dy][xi + dx]:
... |
# Merge Two Sorted Lists
#
# Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing
# together the nodes of the first two lists.
#
# Example:
#
# Input: 1->2->4, 1->3->4
# Output: 1->1->2->3->4->4
# Definition for singly-linked list.
class ListNode:
def __init__(s... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def merge_two_lists(self, l1, l2):
if None in (l1, l2):
return l1 or l2
elif l1.val < l2.val:
l1.next = self.mergeTwoLists(l1.next, l2)
ret... |
#bitwise or operator
a=24
b=10
print(bin(a))
print(bin(b))
print(a|b)
| a = 24
b = 10
print(bin(a))
print(bin(b))
print(a | b) |
#CNN Config File
batchsize = 3
numberOfGenres = 4
learningRate = 0.001
numberOfSteps = 10000
dropoutProbability = 0.5
| batchsize = 3
number_of_genres = 4
learning_rate = 0.001
number_of_steps = 10000
dropout_probability = 0.5 |
'''
09 - Subsetting lists of lists
You saw before that a Python list can contain practically anything; even other lists! To subset
lists of lists, you can use the same technique as before: square brackets. Try out the commands
in the following code sample in the IPython Shell:
x = [["a", "b", "c"],
["d", "e", "f... | """
09 - Subsetting lists of lists
You saw before that a Python list can contain practically anything; even other lists! To subset
lists of lists, you can use the same technique as before: square brackets. Try out the commands
in the following code sample in the IPython Shell:
x = [["a", "b", "c"],
["d", "e", "f... |
class DjangoeventsError(Exception):
pass
class AlreadyExists(DjangoeventsError):
pass
| class Djangoeventserror(Exception):
pass
class Alreadyexists(DjangoeventsError):
pass |
# Remove a exclamation mark from the end of string. For a beginner kata, you can assume
# that the input data is always a string, no need to verify it.
# Examples
# remove("Hi!") === "Hi"
# remove("Hi!!!") === "Hi!!"
# remove("!Hi") === "!Hi"
# remove("!Hi!") === "!Hi"
# remove("Hi! Hi!") === "Hi! Hi"
# rem... | def remove(s):
return s[:-1] if s.endswith('!') else s
def test_remove():
assert remove('Hi!') == 'Hi'
assert remove('Hi!!!') == 'Hi!!'
assert remove('!Hi') == '!Hi'
assert remove('!Hi!') == '!Hi'
assert remove('Hi! Hi!') == 'Hi! Hi'
assert remove('Hi') == 'Hi' |
class Solution:
def maxPower(self, s: str) -> int:
best_answer = 1
current_answer = 1
last_char = None
for char in s:
if last_char == char:
current_answer += 1
else:
if current_answer > best_answer:
best_answ... | class Solution:
def max_power(self, s: str) -> int:
best_answer = 1
current_answer = 1
last_char = None
for char in s:
if last_char == char:
current_answer += 1
else:
if current_answer > best_answer:
best_an... |
class Reporter():
def __init__(self, checker):
pass
def doReport(self):
pass
def appendMsg(self):
pass
def export(self):
pass
| class Reporter:
def __init__(self, checker):
pass
def do_report(self):
pass
def append_msg(self):
pass
def export(self):
pass |
def evenNumbersGenerator(x):
while True:
x += 1
yield x
# yield 1
# yield 2
# yield 3
# yield 4
# yield 5
# yield 6
# yield 7
gen=evenNumbersGenerator(5)
print( next(gen) )
print( next(gen) )
print( next(gen) )
print( next(gen) )
| def even_numbers_generator(x):
while True:
x += 1
yield x
gen = even_numbers_generator(5)
print(next(gen))
print(next(gen))
print(next(gen))
print(next(gen)) |
class Optimizer:
def __init__(self, parameters):
pass
def step(self, **kwargs):
raise NotImplementedError
| class Optimizer:
def __init__(self, parameters):
pass
def step(self, **kwargs):
raise NotImplementedError |
# Copyright 2018 Kai Groner
#
# 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 i... | class Ns:
"""Nesting namespace.
>>> ns = NS({ 'foo.bar': 1, 'duck.duck.goose': 101 })
>>> ns.foo
<NS: 'foo'>
>>> ns.foo.bar
1
>>> ns.duck.duck
<NS: 'duck.duck'>
>>> ns.duck.duck.goose
101
>>> ns['foo.quux'] = 2
>>> ns.foo.quux
2
"""
def __init__(self, seq=No... |
spike = {
'kind': 'bulldog',
'owner': 'tom',
}
garfield = {
'kind': 'cat',
'owner': 'mark',
}
tom = {
'kind': 'cat',
'owner': 'will',
}
pets = [spike, garfield, tom]
for pet in pets:
print(pet)
| spike = {'kind': 'bulldog', 'owner': 'tom'}
garfield = {'kind': 'cat', 'owner': 'mark'}
tom = {'kind': 'cat', 'owner': 'will'}
pets = [spike, garfield, tom]
for pet in pets:
print(pet) |
# MenuTitle: Print master models
# -*- coding: utf-8 -*-
__doc__ = """
Prints a tab with all Kern On models for each master.
"""
for i, master in enumerate(Font.masters):
if master.userData["KernOnIsInterpolated"]:
continue
negativeModels = []
zeroModels = []
positiveModels = []
for model in master.userData[... | __doc__ = '\nPrints a tab with all Kern On models for each master.\n'
for (i, master) in enumerate(Font.masters):
if master.userData['KernOnIsInterpolated']:
continue
negative_models = []
zero_models = []
positive_models = []
for model in master.userData['KernOnModels']:
lglyph = Fon... |
#
# PySNMP MIB module CISCO-FABRIC-MCAST-APPL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FABRIC-MCAST-APPL-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:40:35 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint, constraints_union) ... |
class Stack():
def __init__(self):
self.arr = []
self.length = 0
def __str__(self):
return str(self.__dict__)
def push(self, data):
self.arr.append(data)
self.length += 1
def peek(self):
return self.arr[self.length - 1]
def pop(self):
popped_item = self.arr[self.length - 1]
del self.arr[self.le... | class Stack:
def __init__(self):
self.arr = []
self.length = 0
def __str__(self):
return str(self.__dict__)
def push(self, data):
self.arr.append(data)
self.length += 1
def peek(self):
return self.arr[self.length - 1]
def pop(self):
popped... |
"""
Some module
-----------
Just a dummy module with some class definition
"""
class MyClass(object):
"""Some class
With some description"""
def do_something(self):
"""Do something"""
pass
#: Any instance attribute
some_attr = None
#: Any other instance attribute
some_... | """
Some module
-----------
Just a dummy module with some class definition
"""
class Myclass(object):
"""Some class
With some description"""
def do_something(self):
"""Do something"""
pass
some_attr = None
some_other_attr = None
large_data = 'Whatever' |
class TrafficLightClassifier(object):
def __init__(self):
PATH_TO_MODEL = 'frozen_inference_graph.pb'
self.detection_graph = tf.Graph()
with self.detection_graph.as_default():
od_graph_def = tf.GraphDef()
# Works up to here.
with tf.gfile.GFile(PATH_TO_MOD... | class Trafficlightclassifier(object):
def __init__(self):
path_to_model = 'frozen_inference_graph.pb'
self.detection_graph = tf.Graph()
with self.detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_MODEL, 'rb') as fid:
... |
a = 1
b = 2
d = 4
c = 3
e = 6
e = 5
f = 7
g = 8
| a = 1
b = 2
d = 4
c = 3
e = 6
e = 5
f = 7
g = 8 |
t = int(input().strip())
for a0 in range(t):
b,w = input().strip().split(' ')
b,w = [int(b),int(w)]
x,y,z = input().strip().split(' ')
x,y,z = [int(x),int(y),int(z)]
cost = b*x + w*y
x_cost = b*(y+z) + w*y
y_cost = b*x + w*(x+z)
new_cost = min(cost, x_cost, y_cost)
print (new... | t = int(input().strip())
for a0 in range(t):
(b, w) = input().strip().split(' ')
(b, w) = [int(b), int(w)]
(x, y, z) = input().strip().split(' ')
(x, y, z) = [int(x), int(y), int(z)]
cost = b * x + w * y
x_cost = b * (y + z) + w * y
y_cost = b * x + w * (x + z)
new_cost = min(cost, x_cos... |
sum1 = 0
sum2 = 0
for i in range (1, 101, 1):
sum1 = sum1 + (i**2)
sum2 = sum2 + i
sum2 = sum2**2
answer = sum2-sum1
print(answer)
| sum1 = 0
sum2 = 0
for i in range(1, 101, 1):
sum1 = sum1 + i ** 2
sum2 = sum2 + i
sum2 = sum2 ** 2
answer = sum2 - sum1
print(answer) |
# day 10 challenge 1
# read input
ratings = []
with open('input.txt', 'r') as file:
for line in file:
ratings.append(int(line))
ratings.sort()
ratings.append(ratings[-1] + 3)
ratings.insert(0, 0)
one_ct = 0
thr_ct = 0
for ind, jlt in enumerate(ratings):
if ind < (len(ratings) - 1):
if (rati... | ratings = []
with open('input.txt', 'r') as file:
for line in file:
ratings.append(int(line))
ratings.sort()
ratings.append(ratings[-1] + 3)
ratings.insert(0, 0)
one_ct = 0
thr_ct = 0
for (ind, jlt) in enumerate(ratings):
if ind < len(ratings) - 1:
if ratings[ind + 1] - jlt == 1:
one... |
#!/usr/bin/env python3
n = int(input())
i = 0
while i < n:
if i == 0:
print(n * "*")
elif 0 < i < n - 1:
print("*" + ((n - 2) * " ") + "*")
elif i == n - 1:
print(n * "*")
i = i + 1
| n = int(input())
i = 0
while i < n:
if i == 0:
print(n * '*')
elif 0 < i < n - 1:
print('*' + (n - 2) * ' ' + '*')
elif i == n - 1:
print(n * '*')
i = i + 1 |
# Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:
# Only one letter can be changed at a time.
# Each transformed word must exist in the word list. Note that beginWord is not a transformed word.
# For exampl... | class Solution(object):
def ladder_length(self, beginWord, endWord, wordList):
"""
O(NL)
:type beginWord: str
:type endWord: str
:type wordList: List[str]
:rtype: int
"""
if not beginWord or not endWord or (not wordList):
return 0
... |
#
# PySNMP MIB module WWP-LEOS-FLOW-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-LEOS-FLOW-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:37:57 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint, constraints_union) ... |
# generated from catkin/cmake/template/cfg-extras.context.py.in
DEVELSPACE = 'FALSE' == 'TRUE'
INSTALLSPACE = 'TRUE' == 'TRUE'
CATKIN_DEVEL_PREFIX = '/root/ros_catkin_ws/devel_isolated/roslisp'
CATKIN_GLOBAL_BIN_DESTINATION = 'bin'
CATKIN_GLOBAL_ETC_DESTINATION = 'etc'
CATKIN_GLOBAL_INCLUDE_DESTINATION = 'include'
CA... | develspace = 'FALSE' == 'TRUE'
installspace = 'TRUE' == 'TRUE'
catkin_devel_prefix = '/root/ros_catkin_ws/devel_isolated/roslisp'
catkin_global_bin_destination = 'bin'
catkin_global_etc_destination = 'etc'
catkin_global_include_destination = 'include'
catkin_global_lib_destination = 'lib'
catkin_global_libexec_destinat... |
# Definition for a binary tree node. https://leetcode.com/problems/find-mode-in-binary-search-tree/submissions/
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def findMode(self, root: TreeNode) -> Lis... | class Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def find_mode(self, root: TreeNode) -> List[int]:
"""
Intuition - most common elems
Approach:
Extra Space:
... |
a,b=1,0
for i in range(int(input())):
x,y,z=list(map(int,input().split()))
a=a*y//x
if z:
b=1-b
print(b,a) | (a, b) = (1, 0)
for i in range(int(input())):
(x, y, z) = list(map(int, input().split()))
a = a * y // x
if z:
b = 1 - b
print(b, a) |
# https://www.hackerrank.com/challenges/merge-the-tools/problem
def merge_the_tools(s, n):
# your code goes here
for part in zip(*[iter(s)] * n):
d = dict()
print(''.join([d.setdefault(c, c) for c in part if c not in d]))
if __name__ == '__main__':
string, k = input(), int(input())
m... | def merge_the_tools(s, n):
for part in zip(*[iter(s)] * n):
d = dict()
print(''.join([d.setdefault(c, c) for c in part if c not in d]))
if __name__ == '__main__':
(string, k) = (input(), int(input()))
merge_the_tools(string, k) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class PodiumApplication():
def __init__(self, app_id, app_secret, podium_url=None):
self.app_id = app_id
self.app_secret = app_secret
self.podium_url = 'https://podium.live' if podium_url is None else podium_url
| class Podiumapplication:
def __init__(self, app_id, app_secret, podium_url=None):
self.app_id = app_id
self.app_secret = app_secret
self.podium_url = 'https://podium.live' if podium_url is None else podium_url |
class DigAdd:
def addDigits(self, num: int) -> int:
if not num:
return 0
else:
mod = (num - 1) % 9
x = mod + 1
return x
print(DigAdd().addDigits(12))
print(DigAdd().addDigits(12836374))
print(DigAdd().addDigits(9))
print(DigAdd().addDigits(8))
| class Digadd:
def add_digits(self, num: int) -> int:
if not num:
return 0
else:
mod = (num - 1) % 9
x = mod + 1
return x
print(dig_add().addDigits(12))
print(dig_add().addDigits(12836374))
print(dig_add().addDigits(9))
print(dig_add().addDigits(8)) |
"""Constants needed for the operation of the program."""
WHEEL_DIAMETER = 0.03
AXIS_LENGTH = 0.14
RPS_PER_PERCENTAGE = 0.083
PIXELS_PER_METER = 100
VALUE_PER_ALPHA = 1024.0 / 255.0
SENSORS = [
(-0.03, 0.01),
(-0.02, 0.02),
(-0.01, 0.03),
(0.03, 0.01),
(0.02, 0.02),
(0.01, 0.03)
]
| """Constants needed for the operation of the program."""
wheel_diameter = 0.03
axis_length = 0.14
rps_per_percentage = 0.083
pixels_per_meter = 100
value_per_alpha = 1024.0 / 255.0
sensors = [(-0.03, 0.01), (-0.02, 0.02), (-0.01, 0.03), (0.03, 0.01), (0.02, 0.02), (0.01, 0.03)] |
# 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:
# O(n) time | O(n) space - where n is the number of the nodes in this binary tree
def maxDepth(self, roo... | class Solution:
def max_depth(self, root: Optional[TreeNode]) -> int:
stack = [[root, 1]]
ans = 0
while stack:
(node, depth) = stack.pop()
if node:
ans = max(ans, depth)
stack.append([node.right, depth + 1])
stack.appen... |
def send_email(name: str, address: str, subject: str, body: str):
print(f"Sending email to {name} ({address})")
print("==========")
print(f"Subject: {subject}\n")
print(body)
| def send_email(name: str, address: str, subject: str, body: str):
print(f'Sending email to {name} ({address})')
print('==========')
print(f'Subject: {subject}\n')
print(body) |
with open('input') as f:
in_data = [line.rstrip() for line in f]
j=0
w=len(in_data[0])
tree_count=0
for i in range(1, len(in_data)):
line = in_data[i]
j=(j+3)%w
if line[j] == '#':
tree_count+=1
print(tree_count)
| with open('input') as f:
in_data = [line.rstrip() for line in f]
j = 0
w = len(in_data[0])
tree_count = 0
for i in range(1, len(in_data)):
line = in_data[i]
j = (j + 3) % w
if line[j] == '#':
tree_count += 1
print(tree_count) |
# =======================
# From the pyECC package
# =======================
#
# Predefined Elliptic Curves
# for use in signing and key exchange
#
"""
Predefined elliptic curves for use in signing and key exchange.
This Module implements FIPS approved standard curves P-192, P-224, P-256,
P-384 and P-521 along with... | """
Predefined elliptic curves for use in signing and key exchange.
This Module implements FIPS approved standard curves P-192, P-224, P-256,
P-384 and P-521 along with two weak non-standard curves of field size 128
and 160 bits.
The weak curves cannot be used for signing but provide a faster way to
obfuscate non-crit... |
# -*- coding: utf-8 -*-
"""
118. Pascal's Triangle
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
"""
class Solution:
def generate(self, numRows):
if numRows == 0:
retur... | """
118. Pascal's Triangle
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
"""
class Solution:
def generate(self, numRows):
if numRows == 0:
return []
elif numRow... |
def isPalindrome(word):
word = word.lower()
if word == word[::-1]:
return True
else:
return False
print(isPalindrome("DDnKnDD"))
| def is_palindrome(word):
word = word.lower()
if word == word[::-1]:
return True
else:
return False
print(is_palindrome('DDnKnDD')) |
for i in range(1, 1001):
print(1001 - i, end="\t")
if i % 5 == 0:
print("")
| for i in range(1, 1001):
print(1001 - i, end='\t')
if i % 5 == 0:
print('') |
with open('day002.txt', 'r') as fd:
inp = fd.read()
rows = inp.split('\n')
def move(p, d):
x, y = p
if d == 'U': p = (x, max(y - 1, 0))
if d == 'D': p = (x, min(y + 1, 2))
if d == 'R': p = (min(x + 1, 2), y)
if d == 'L': p = (max(x - 1, 0), y)
return p
def key(p):
return p[0] + p[1] * 3 +... | with open('day002.txt', 'r') as fd:
inp = fd.read()
rows = inp.split('\n')
def move(p, d):
(x, y) = p
if d == 'U':
p = (x, max(y - 1, 0))
if d == 'D':
p = (x, min(y + 1, 2))
if d == 'R':
p = (min(x + 1, 2), y)
if d == 'L':
p = (max(x - 1, 0), y)
return p
def... |
jvar = 0
def return_something():
return "Hi world"
def change_jvar():
jvar = 18
print(jvar)
def print_jvar():
print(jvar)
print("Called on import! Oops!")
| jvar = 0
def return_something():
return 'Hi world'
def change_jvar():
jvar = 18
print(jvar)
def print_jvar():
print(jvar)
print('Called on import! Oops!') |
# empty class for creating constants
class Constant:
pass
# constants for metrical feet
FOOT = Constant()
FOOT.DACTYL = "Dactyl"
FOOT.SPONDEE = "Spondee"
FOOT.FINAL = "Final"
APPROACH = Constant()
APPROACH.STUDENT = "version_student"
APPROACH.NATIVE_SPEAKER = "version_native_speaker"
APPROACH.FALLBACK = "versio... | class Constant:
pass
foot = constant()
FOOT.DACTYL = 'Dactyl'
FOOT.SPONDEE = 'Spondee'
FOOT.FINAL = 'Final'
approach = constant()
APPROACH.STUDENT = 'version_student'
APPROACH.NATIVE_SPEAKER = 'version_native_speaker'
APPROACH.FALLBACK = 'version_fallback'
syl = constant()
SYL.UNKNOWN = 0
SYL.SHORT = 1
SYL.LONG = 2... |
class Agencia:
def __init__(self,nombre,direccion,email):
self.nombre = nombre
self.direccion = direccion
self.email = email
def getNombre(self):
return self.nombre
def getDireccion(self):
return self.direccion
def getEmail(self):
return self.email
d... | class Agencia:
def __init__(self, nombre, direccion, email):
self.nombre = nombre
self.direccion = direccion
self.email = email
def get_nombre(self):
return self.nombre
def get_direccion(self):
return self.direccion
def get_email(self):
return self.ema... |
"""The is an attempt at creating a bowl class
to solve Exercise 2-1 in the Think Bayes book"""
class Bowl(object):
"""A bowl object that keeps track of our cookies"""
def __init__(self, bowl_name, v_cookies, c_cookies):
"""Constructor"""
self.bowl_name = bowl_name
self.v_cookies = floa... | """The is an attempt at creating a bowl class
to solve Exercise 2-1 in the Think Bayes book"""
class Bowl(object):
"""A bowl object that keeps track of our cookies"""
def __init__(self, bowl_name, v_cookies, c_cookies):
"""Constructor"""
self.bowl_name = bowl_name
self.v_cookies = floa... |
# Advent of Code 2017
# Day 9, Part 2
# @geekygirlsarah
# Files to run through
# input.txt being the input the puzzle provides
inputFile = "input.txt"
# inputFile = "testinput.txt"
# Process file
with open(inputFile) as f:
while True:
contents = f.readline(-1)
if not contents:
# print... | input_file = 'input.txt'
with open(inputFile) as f:
while True:
contents = f.readline(-1)
if not contents:
break
state = 'start'
group_level = 0
group_sum = 0
char_pos = -1
garbage_count = 0
while True:
char_pos += 1
... |
#
# PySNMP MIB module Juniper-DVMRP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-DVMRP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:02:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, single_value_constraint, constraints_intersection, value_range_constraint) ... |
# -*- coding: utf-8 -*-
"""
Configuration file.
"""
# enables the debug mode of the client
# True: Exceptions will be raised
# False: Exceptions will be catched and logged
debug_mode = True
# parameter for database connection
database_connection = {
'user': 'root',
'passwd': 'Se!Ne#Ta45',
'host': 'local... | """
Configuration file.
"""
debug_mode = True
database_connection = {'user': 'root', 'passwd': 'Se!Ne#Ta45', 'host': 'localhost', 'db': 'domainSearch', 'charset': 'utf8'}
rating_request_server = {'host': '', 'port': 8010}
queued_domain_request_server = {'host': '', 'port': 8020}
task_notification_server = {'host': '', ... |
# single_leading_underscore.py
print("""
Single leading underscore: _var
-------------------------------
1. When applied to variable and method names, it has a meaning by convention only.
2. Intended as a hint to the programmer that it is used for internal purposes, but not enforced by Python.
3. Does not affect the ... | print('\nSingle leading underscore: _var\n-------------------------------\n1. When applied to variable and method names, it has a meaning by convention only.\n2. Intended as a hint to the programmer that it is used for internal purposes, but not enforced by Python.\n3. Does not affect the behaviour of the program.\n')
... |
# Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.
# Example
# For s = "abacabad", the output should be
# first_not_repeating_character(s) = 'c'.
# There are 2 non-repeating characters in the string... | def first_not_repeating_character(s):
chars = {}
non_repeat = []
for char in s:
if char in chars:
chars[char] += 1
else:
chars[char] = 1
non_repeat.append(char)
for char in non_repeat:
if chars[char] == 1:
return char
return '_' |
"""
generateProductImages.py
50 products --> 50 images
10 images per category
Categories:
1. Books
2. Electronics
3. Clothing
4. Games
5. Groceries
"""
def getProductImage(category, idx):
bookImages = ["https://tinyurl.com/bdew8ewr",
"https://tinyurl.com/ycktxfjs",
"https://tiny... | """
generateProductImages.py
50 products --> 50 images
10 images per category
Categories:
1. Books
2. Electronics
3. Clothing
4. Games
5. Groceries
"""
def get_product_image(category, idx):
book_images = ['https://tinyurl.com/bdew8ewr', 'https://tinyurl.com/ycktxfjs', 'https://tinyurl.com/4... |
skill = input()
while True:
command = input()
if command == 'For Azeroth' or command is None:
break
if command == 'GladiatorStance':
skill = skill.upper()
print(skill)
elif command == 'DefensiveStance':
skill = skill.lower()
print(skill)
elif comman... | skill = input()
while True:
command = input()
if command == 'For Azeroth' or command is None:
break
if command == 'GladiatorStance':
skill = skill.upper()
print(skill)
elif command == 'DefensiveStance':
skill = skill.lower()
print(skill)
elif command.split(' '... |
# Copyright (c) 2020 Club Raiders Project
# https://github.com/HausReport/ClubRaiders
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Faction constants
#
GOVERNMENT = 'government'
MINOR_FACTION_ID = 'minor_faction_id'
MINOR_FACTION_PRESENCES = 'minor_faction_presences'
NEIGHBOR_COUNT = 'neighbor_count'
HAS_ANARCHY... | government = 'government'
minor_faction_id = 'minor_faction_id'
minor_faction_presences = 'minor_faction_presences'
neighbor_count = 'neighbor_count'
has_anarchy = 'hasAnarchy'
id = 'id'
neighbors = 'neighbors'
power_state = 'power_state'
has_docking = 'has_docking'
system_id = 'system_id'
pad_size = 'max_landing_pad_s... |
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 27 02:01:38 2020
@author: peng
"""
# nothing new
A = [1]
B = [2]
C = [3] | """
Created on Fri Nov 27 02:01:38 2020
@author: peng
"""
a = [1]
b = [2]
c = [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.