content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
'''Soma Simples'''
A = int(input())
B = int(input())
def CalculaSomaSimples(a: int, b: int):
resultado = int(a+b)
return('SOMA = {}'.format(resultado))
print(CalculaSomaSimples(A,B))
| """Soma Simples"""
a = int(input())
b = int(input())
def calcula_soma_simples(a: int, b: int):
resultado = int(a + b)
return 'SOMA = {}'.format(resultado)
print(calcula_soma_simples(A, B)) |
pkgname = "libgpg-error"
pkgver = "1.43"
pkgrel = 0
build_style = "gnu_configure"
hostmakedepends = ["pkgconf"]
pkgdesc = "Library for error values used by GnuPG components"
maintainer = "q66 <q66@chimera-linux.org>"
license = "LGPL-2.1-or-later"
url = "https://www.gnupg.org"
source = f"{url}/ftp/gcrypt/{pkgname}/{pkgn... | pkgname = 'libgpg-error'
pkgver = '1.43'
pkgrel = 0
build_style = 'gnu_configure'
hostmakedepends = ['pkgconf']
pkgdesc = 'Library for error values used by GnuPG components'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'LGPL-2.1-or-later'
url = 'https://www.gnupg.org'
source = f'{url}/ftp/gcrypt/{pkgname}/{pkgn... |
class Person:
name = None
age = 0
gender = None
def __init__(self, n, a, g):
self.name = n
self.age = a
self.gender = g
def walk(self):
print('I am walking')
def eat(self):
print('I am eating :)')
def __str__(self): # string representation of the o... | class Person:
name = None
age = 0
gender = None
def __init__(self, n, a, g):
self.name = n
self.age = a
self.gender = g
def walk(self):
print('I am walking')
def eat(self):
print('I am eating :)')
def __str__(self):
return 'name: {}\tage: {... |
list=input().split()
re=[int(e) for e in input().split()]
new=[]
for i in re:
new.append(list[i])
for l in new:
print(l,end=" ")
| list = input().split()
re = [int(e) for e in input().split()]
new = []
for i in re:
new.append(list[i])
for l in new:
print(l, end=' ') |
shopping_list = []
def show_help():
print("Enter the items/amount for your shopping list")
print("Enter DONE once you have completed the list, Enter Help if you require assistance")
def add_to_list(item):
shopping_list.append(item)
print("Added! List has {} items.".format(len(shopping_list)))
def show_li... | shopping_list = []
def show_help():
print('Enter the items/amount for your shopping list')
print('Enter DONE once you have completed the list, Enter Help if you require assistance')
def add_to_list(item):
shopping_list.append(item)
print('Added! List has {} items.'.format(len(shopping_list)))
def sho... |
GET_HOSTS = [
{
'device_id': '00000000000000000000000000000000',
'cid': '11111111111111111111111111111111',
'agent_load_flags': '0',
'agent_local_time': '2021-12-08T15:16:24.360Z',
'agent_version': '6.30.14406.0',
'bios_manufacturer': 'Amazon EC2',
'bios_versi... | get_hosts = [{'device_id': '00000000000000000000000000000000', 'cid': '11111111111111111111111111111111', 'agent_load_flags': '0', 'agent_local_time': '2021-12-08T15:16:24.360Z', 'agent_version': '6.30.14406.0', 'bios_manufacturer': 'Amazon EC2', 'bios_version': '1.0', 'build_number': '11111', 'config_id_base': '111111... |
# *****************************************************************************
# Copyright (c) 2020, Intel Corporation All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of sou... | def knn_python(train, train_labels, test, k, classes_num, train_size, test_size, predictions, queue_neighbors_lst, votes_to_classes_lst, data_dim):
for i in range(test_size):
queue_neighbors = queue_neighbors_lst[i]
for j in range(k):
x1 = train[j]
x2 = test[i]
di... |
class WordWithTag:
word = ""
tag = ""
separator = ''
def __init__(self, separator):
self.separator = separator
| class Wordwithtag:
word = ''
tag = ''
separator = ''
def __init__(self, separator):
self.separator = separator |
class Solution:
def minOperations(self, n: int) -> int:
num_ops = 0
for i in range(0, n // 2, 1):
num_ops += n - (2 * i + 1)
return num_ops | class Solution:
def min_operations(self, n: int) -> int:
num_ops = 0
for i in range(0, n // 2, 1):
num_ops += n - (2 * i + 1)
return num_ops |
'''
Largest Continuous Sum Problem
Given an array of integers (positive and negative) find the largest continous sum
'''
def large_cont_sum(arr):
#if array is all positive we return the result as summ of all numbers
#the negative numbers int he array will cause us to need to begin checkin sequences
## Che... | """
Largest Continuous Sum Problem
Given an array of integers (positive and negative) find the largest continous sum
"""
def large_cont_sum(arr):
if len(arr) == 0:
return 0
max_sum = current_sum = arr[0]
for num in arr[1:]:
current_sum = max(current_sum + num, num)
max_sum = max(cur... |
data = (
's', # 0x00
't', # 0x01
'u', # 0x02
'v', # 0x03
'w', # 0x04
'x', # 0x05
'y', # 0x06
'z', # 0x07
'A', # 0x08
'B', # 0x09
'C', # 0x0a
'D', # 0x0b
'E', # 0x0c
'F', # 0x0d
'G', # 0x0e
'H', # 0x0f
'I', # 0x10
'J', # 0x11
'K', # 0x12
'L', # 0x13
'M', # 0... | data = ('s', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C... |
# MIT licensed
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
GEMS_URL = 'https://rubygems.org/api/v1/versions/%s.json'
async def get_version(name, conf, *, cache, **kwargs):
key = conf.get('gems', name)
data = await cache.get_json(GEMS_URL % key)
return data[0]['number']
| gems_url = 'https://rubygems.org/api/v1/versions/%s.json'
async def get_version(name, conf, *, cache, **kwargs):
key = conf.get('gems', name)
data = await cache.get_json(GEMS_URL % key)
return data[0]['number'] |
def msgme(*names):
for i in names:
print(i)
msgme("abc")
msgme("xyz",100)
msgme("apple","mango",1,2,3,7)
| def msgme(*names):
for i in names:
print(i)
msgme('abc')
msgme('xyz', 100)
msgme('apple', 'mango', 1, 2, 3, 7) |
class Dog:
species = 'caniche'
def __init__(self, name, age):
self.name = name
self.age = age
bambi = Dog("Bambi", 5)
mikey = Dog("Rufus", 6)
blacky = Dog("Fosca", 9)
coco = Dog("Coco", 13)
perla = Dog("Neska", 3)
print("{} is {} and {} is {}.". format(bambi.name, bambi.age, mikey.name, mike... | class Dog:
species = 'caniche'
def __init__(self, name, age):
self.name = name
self.age = age
bambi = dog('Bambi', 5)
mikey = dog('Rufus', 6)
blacky = dog('Fosca', 9)
coco = dog('Coco', 13)
perla = dog('Neska', 3)
print('{} is {} and {} is {}.'.format(bambi.name, bambi.age, mikey.name, mikey.ag... |
def getBuiltinTargs():
return {
"1": {
"name": "1",
"ptype": "maven2",
"patterns": [".*"],
"defincpat": ["**"],
"defexcpat": []
},
"2": {
"name": "2",
"ptype": "maven1",
"patterns": [".*"],
... | def get_builtin_targs():
return {'1': {'name': '1', 'ptype': 'maven2', 'patterns': ['.*'], 'defincpat': ['**'], 'defexcpat': []}, '2': {'name': '2', 'ptype': 'maven1', 'patterns': ['.*'], 'defincpat': ['**'], 'defexcpat': []}, '3': {'name': '3', 'ptype': 'maven2', 'patterns': ['(?!.*-sources.*).*'], 'defincpat': ['... |
EXT_STANDARD = 1
INT_STANDARD = 2
EXT_HQ = 3
INT_HQ = 4
EXT_HOUSE = 5
INT_HOUSE = 6
EXT_COGHQ = 7
INT_COGHQ = 8
EXT_KS = 9
INT_KS = 10
| ext_standard = 1
int_standard = 2
ext_hq = 3
int_hq = 4
ext_house = 5
int_house = 6
ext_coghq = 7
int_coghq = 8
ext_ks = 9
int_ks = 10 |
# Leo colorizer control file for dart mode.
# This file is in the public domain.
# Properties for dart mode.
properties = {
"commentEnd": "*/",
"commentStart": "/*",
"electricKeys": ":",
"indentCloseBrackets": "]}",
"indentNextLine": "\\s*(((if|while)\\s*\\(|else\\s*|else\\s+if\\s*\\(|for\\s*\\(.*\... | properties = {'commentEnd': '*/', 'commentStart': '/*', 'electricKeys': ':', 'indentCloseBrackets': ']}', 'indentNextLine': '\\s*(((if|while)\\s*\\(|else\\s*|else\\s+if\\s*\\(|for\\s*\\(.*\\))[^{;]*)', 'indentOpenBrackets': '{[', 'lineComment': '//', 'unalignedCloseBrackets': ')', 'unalignedOpenBrackets': '(', 'uninden... |
ACCOUNT_ID = "1234567890"
def parameter_arn(region, parameter_name):
if parameter_name[0] == "/":
parameter_name = parameter_name[1:]
return "arn:aws:ssm:{0}:{1}:parameter/{2}".format(
region, ACCOUNT_ID, parameter_name
)
| account_id = '1234567890'
def parameter_arn(region, parameter_name):
if parameter_name[0] == '/':
parameter_name = parameter_name[1:]
return 'arn:aws:ssm:{0}:{1}:parameter/{2}'.format(region, ACCOUNT_ID, parameter_name) |
#!/bin/python
# Enter your code here. Read input from STDIN. Print output to STDOUT
N = int(raw_input())
n= N
w = 'Weird'
nw = 'Not Weird'
if n % 2 == 1:
print(w)
elif n % 2 == 0 and (n>=2 and n<5):
print(nw)
elif n % 2 == 0 and (n>=6 and n<=20):
print(w)
elif n % 2 == 0 and (n>20):
print(nw)
| n = int(raw_input())
n = N
w = 'Weird'
nw = 'Not Weird'
if n % 2 == 1:
print(w)
elif n % 2 == 0 and (n >= 2 and n < 5):
print(nw)
elif n % 2 == 0 and (n >= 6 and n <= 20):
print(w)
elif n % 2 == 0 and n > 20:
print(nw) |
# Sage version information for Python scripts
# This file is auto-generated by the sage-update-version script, do not edit!
version = '9.3.rc0'
date = '2021-03-23'
banner = 'SageMath version 9.3.rc0, Release Date: 2021-03-23'
| version = '9.3.rc0'
date = '2021-03-23'
banner = 'SageMath version 9.3.rc0, Release Date: 2021-03-23' |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __str__(self):
return str(self.val)
def print_list(head: ListNode):
cur = head
while cur is not None:
print(cur.val, end=' ')
cur = cu... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __str__(self):
return str(self.val)
def print_list(head: ListNode):
cur = head
while cur is not None:
print(cur.val, end=' ')
cur = cur.next
if cur is not None:
... |
REDFIN_TABLE_SCHEMA = {
'SCHEMA': {
'SALE_TYPE': 'VARCHAR(50)',
'SOLD_DATE': 'DATE',
'PROPERTY_TYPE': 'VARCHAR(50)',
'ADDRESS': 'VARCHAR(100) NOT NULL',
'CITY': 'VARCHAR(50) NOT NULL',
'STATE': 'VARCHAR(50) NOT NULL',
'ZIPCODE': 'BIGINT',
'PRICE': 'BIG... | redfin_table_schema = {'SCHEMA': {'SALE_TYPE': 'VARCHAR(50)', 'SOLD_DATE': 'DATE', 'PROPERTY_TYPE': 'VARCHAR(50)', 'ADDRESS': 'VARCHAR(100) NOT NULL', 'CITY': 'VARCHAR(50) NOT NULL', 'STATE': 'VARCHAR(50) NOT NULL', 'ZIPCODE': 'BIGINT', 'PRICE': 'BIGINT', 'BEDS': 'BIGINT', 'BATHS': 'DOUBLE PRECISION', 'SQFT': 'BIGINT',... |
message = 'My name is ' 'Tom'
print(message)
| message = 'My name is Tom'
print(message) |
list1 = ["apple", "banana", "cherry"]
list2 = list1.copy()
print(list2)
list3 = list(list1)
print(list3)
list4 = list('T am a list')
print(list4)
# join 2 lists
list5 = list1 + list4
print(list5)
for x in list4:
list1.append(x)
print(list1)
list2.extend(list4)
print(list2)
# list constructor
list7 = list(("appl... | list1 = ['apple', 'banana', 'cherry']
list2 = list1.copy()
print(list2)
list3 = list(list1)
print(list3)
list4 = list('T am a list')
print(list4)
list5 = list1 + list4
print(list5)
for x in list4:
list1.append(x)
print(list1)
list2.extend(list4)
print(list2)
list7 = list(('apple', 'banana', 'cherry'))
print(list7)
... |
_MODELS = dict()
def register(fn):
global _MODELS
_MODELS[fn.__name__] = fn
return fn
def get_model(args=None):
if args.model is None:
return _MODELS
return _MODELS[args.model](args.num_classes)
| _models = dict()
def register(fn):
global _MODELS
_MODELS[fn.__name__] = fn
return fn
def get_model(args=None):
if args.model is None:
return _MODELS
return _MODELS[args.model](args.num_classes) |
#Lists Challenge 9: Basketball Roster Program
print("Welcome to the Basketball Roster Program")
#Get user input and define our roster
roster = []
player = input("\nWho is your point guard: ").title()
roster.append(player)
player = input("Who is your shooting guard: ").title()
roster.append(player)
player = input("Wh... | print('Welcome to the Basketball Roster Program')
roster = []
player = input('\nWho is your point guard: ').title()
roster.append(player)
player = input('Who is your shooting guard: ').title()
roster.append(player)
player = input('Who is your small forward: ').title()
roster.append(player)
player = input('Who is your p... |
# Helper merge sort function
def mergeSort(arr):
# Clone the array for the merge later
arrClone = arr.clone()
mergeSortAux(arr, arrClone, 0, len(arr) - 1)
# Actual merge sort
def mergeSortAux(arr, arrClone, low, high):
if low < high:
mid = (low + high) / 2
# Sort left
mergeSort... | def merge_sort(arr):
arr_clone = arr.clone()
merge_sort_aux(arr, arrClone, 0, len(arr) - 1)
def merge_sort_aux(arr, arrClone, low, high):
if low < high:
mid = (low + high) / 2
merge_sort_aux(arr, arrClone, low, mid)
merge_sort_aux(arr, arrClone, mid + 1, high)
merge(arr, arr... |
# You can comment by putting # in front of a text.
#First off we will start off with the humble while loop.
#Now notice the syntax: first we declare our variable,
#while condition is followed with a colon,
#in order to concenate a string with a number
#we must turn it into a string as well.
#Finally don't forget the i... | n = 0
while n <= 5:
print('While is now ' + str(n))
n = n + 1
for n in range(5):
print(n)
my_sum = 1
for i in range(1, 12, 1):
print('i is now ' + str(i))
if i == 11:
print('Oh snap we are now over 11!')
break
var_a = 200
var_b = 100
if type(varA) == str or type(varB) == str:
pri... |
class DailySchedule:
def __init__(self, day_number: int, day_off: bool = False):
self.day_number = day_number
self.day_off = day_off
self.lessons: list[tuple[str, str, str]] = [] | class Dailyschedule:
def __init__(self, day_number: int, day_off: bool=False):
self.day_number = day_number
self.day_off = day_off
self.lessons: list[tuple[str, str, str]] = [] |
class SpaceSequenceEditor:
display_channel = None
display_mode = None
draw_overexposed = None
grease_pencil = None
overlay_type = None
preview_channels = None
proxy_render_size = None
show_backdrop = None
show_frame_indicator = None
show_frames = None
show_grease_pencil = Non... | class Spacesequenceeditor:
display_channel = None
display_mode = None
draw_overexposed = None
grease_pencil = None
overlay_type = None
preview_channels = None
proxy_render_size = None
show_backdrop = None
show_frame_indicator = None
show_frames = None
show_grease_pencil = Non... |
# Write for loops that iterate over the elements of a list without the use of the range
# function for the following tasks.
# c. Counting how many elements in a list are negative.
list = [ -5, 10, 15, -20, -2, 0, -8, 94 ]
numNegativeElements = 0
for item in list:
if item < 0:
numNegativeElements += ... | list = [-5, 10, 15, -20, -2, 0, -8, 94]
num_negative_elements = 0
for item in list:
if item < 0:
num_negative_elements += 1
print('Number of negative elements:', numNegativeElements) |
# Letter Phone
# https://www.interviewbit.com/problems/letter-phone/
#
# Given a digit string, return all possible letter combinations that the number could represent.
#
# A mapping of digit to letters (just like on the telephone buttons) is given below.
#
# The digit 0 maps to 0 itself.
# The digit 1 maps to 1 itself.... | class Solution:
map = {'0': '0', '1': '1', '2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', '8': 'tuv', '9': 'wxyz'}
def _letter_combinations(self, i, A, sub):
if i == len(A) - 1:
return [sub + char for char in Solution.MAP[A[i]]]
res = list()
for cha... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def test_install_extension(lib):
lib.cmd('extension install hello')
lib.cmd('hello')
def test_install_extension_with_github_syntax(lib):
lib.cmd('extension install clk-project/hello')
lib.cmd('hello')
def test_update_extension(lib):
lib.cmd('exten... | def test_install_extension(lib):
lib.cmd('extension install hello')
lib.cmd('hello')
def test_install_extension_with_github_syntax(lib):
lib.cmd('extension install clk-project/hello')
lib.cmd('hello')
def test_update_extension(lib):
lib.cmd('extension install hello')
lib.cmd('extension update ... |
'''
ref: https://www.datacamp.com/community/tutorials/decorators-python
'''
def uppercase_decorator(function):
def wrapper():
func = function()
make_uppercase = func.upper()
return make_uppercase
return wrapper
def say_hi():
return 'hi there'
decorate = uppercase_decorator(say_h... | """
ref: https://www.datacamp.com/community/tutorials/decorators-python
"""
def uppercase_decorator(function):
def wrapper():
func = function()
make_uppercase = func.upper()
return make_uppercase
return wrapper
def say_hi():
return 'hi there'
decorate = uppercase_decorator(say_hi)... |
MAX_CHAR_GROUP_NAME = 30
MAX_CHAR_CONTEXT_NAME = 30
MAX_CHAR_DEVICE_NAME = 30
MAX_DEVICES = 10
MAX_GROUPS = 10
MAX_CONTEXTS = 10
MAX_ACTIONS = 10
MAX_TRIGGERS = 10
# in seconds
INTERVAL_PUB_GROUP_DATA = 120
INTERVAL_ONLINE = 60
STATE_NO_CONNECTION = 1
STATE_CONNECTED_INTERNET = 2
STATE_CONNECTED_NO_INTERNET = 3 | max_char_group_name = 30
max_char_context_name = 30
max_char_device_name = 30
max_devices = 10
max_groups = 10
max_contexts = 10
max_actions = 10
max_triggers = 10
interval_pub_group_data = 120
interval_online = 60
state_no_connection = 1
state_connected_internet = 2
state_connected_no_internet = 3 |
def login(client, username, password):
payload = dict(username=username, password=password)
return client.post('/login', data=payload, follow_redirects=True)
def logout(client):
return client.get('/logout', follow_redirects=True)
| def login(client, username, password):
payload = dict(username=username, password=password)
return client.post('/login', data=payload, follow_redirects=True)
def logout(client):
return client.get('/logout', follow_redirects=True) |
largest_number=None
smallest_number=None
while True:
order=input('Enter a number: ')
if order=='done':
break
try:
number=int(order)
except Exception as e:
print("Invalid Input")
continue
if largest_number is None:
largest_number=number
if smal... | largest_number = None
smallest_number = None
while True:
order = input('Enter a number: ')
if order == 'done':
break
try:
number = int(order)
except Exception as e:
print('Invalid Input')
continue
if largest_number is None:
largest_number = number
if small... |
# XXXXXXXXXXX
class Node:
def __init__(self, value, prev_item=None, next_item=None):
self.value = value
self.prev_item = prev_item
self.next_item = next_item
class Queue():
def __init__(self, max_size):
self.max_size = max_size
self.size = 0
self.head = None
... | class Node:
def __init__(self, value, prev_item=None, next_item=None):
self.value = value
self.prev_item = prev_item
self.next_item = next_item
class Queue:
def __init__(self, max_size):
self.max_size = max_size
self.size = 0
self.head = None
self.last ... |
#!/usr/bin/python3.6
# created by cicek on 12.10.2018 15:09
digits = "731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311... | digits = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729... |
user_schema = {
"type": "object",
"properties": {
"name": {"type": "string"}
},
"required": ["name"],
"additionalProperties": False
}
get_users_query_params_schema = {
"type": ["object", "null"],
"properties": {
"page": {"type": "string"}
},
"additionalProperties": F... | user_schema = {'type': 'object', 'properties': {'name': {'type': 'string'}}, 'required': ['name'], 'additionalProperties': False}
get_users_query_params_schema = {'type': ['object', 'null'], 'properties': {'page': {'type': 'string'}}, 'additionalProperties': False} |
#!/usr/bin/env python
class HostType:
GPCHECK_HOSTTYPE_UNDEFINED = 0
GPCHECK_HOSTTYPE_APPLIANCE = 1
GPCHECK_HOSTTYPE_GENERIC_LINUX = 2
def hosttype_str(type):
if type == HostType.GPCHECK_HOSTTYPE_APPLIANCE:
return "GPDB Appliance"
elif type == HostType.GPCHECK_HOSTTYPE_GENERIC_LINUX:
... | class Hosttype:
gpcheck_hosttype_undefined = 0
gpcheck_hosttype_appliance = 1
gpcheck_hosttype_generic_linux = 2
def hosttype_str(type):
if type == HostType.GPCHECK_HOSTTYPE_APPLIANCE:
return 'GPDB Appliance'
elif type == HostType.GPCHECK_HOSTTYPE_GENERIC_LINUX:
return 'Generic Linu... |
true = True
false = False
abi = [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"stateMutability": "payable",
"type": "fallback"
},
{
"inputs": [],
"name": "client_cancellation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs":... | true = True
false = False
abi = [{'inputs': [], 'stateMutability': 'nonpayable', 'type': 'constructor'}, {'stateMutability': 'payable', 'type': 'fallback'}, {'inputs': [], 'name': 'client_cancellation', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [], 'name': 'client_delete_random_ind... |
# Copyright 2020 The FedLearner Authors. All Rights Reserved.
#
# 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 applica... | _es_datetime_format = 'strict_date_optional_time'
raw_data_mappings = {'dynamic': True, 'dynamic_templates': [{'strings': {'match_mapping_type': 'string', 'mapping': {'type': 'keyword'}}}], 'properties': {'partition': {'type': 'short'}, 'application_id': {'ignore_above': 128, 'type': 'keyword'}, 'event_time': {'format'... |
my_list = list(range(1, 11))
print(my_list)
def maxInList(aList): # non-recursion method
max_number = aList[0]
for i in range(1, len(aList)):
if max_number < aList[i]:
max_number = aList[i]
return max_number
def minInList(aList): # non-recursion method
min_number =... | my_list = list(range(1, 11))
print(my_list)
def max_in_list(aList):
max_number = aList[0]
for i in range(1, len(aList)):
if max_number < aList[i]:
max_number = aList[i]
return max_number
def min_in_list(aList):
min_number = aList[0]
for i in range(1, len(aList)):
if min... |
#!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
MATRIX_MEM_GB_MULTIPLIER = 2 # TODO reduce this once we're confident about the actual memory bounds
NUM_MATRIX_ENTRIES_PER_MEM_GB = 50e6
# Empirical obs: with new CountMatrix setup, take ~ 50 bytes/bc
NUM_MATRIX_BARCODES_PER_MEM_G... | matrix_mem_gb_multiplier = 2
num_matrix_entries_per_mem_gb = 50000000.0
num_matrix_barcodes_per_mem_gb = 2000000
min_mem_gb = 3
min_mem_gb_nowhitelist = 64
gzip_suffix = '.gz'
lz4_suffix = '.lz4'
h5_compression_level = 1
h5_filetype_key = 'filetype'
h5_feature_ref_attr = 'features'
h5_bcs_attr = 'barcodes'
h5_matrix_da... |
# 8. Write a program that swaps the values of three variables x,y, and z, so that x gets the value
# of y, y gets the value of z, and z gets the value of x.
x, y, z = 5, 10, 15
x, y, z = y, z, x # The power of Python ;)
# print(x, y, z) : 10 15 5
| (x, y, z) = (5, 10, 15)
(x, y, z) = (y, z, x) |
vts = list()
vts.append(0)
vtx = list()
total = 0
def dfs(cur, visited:list):
global vtx, total
if cache[cur] != -1:
total += cache[cur]
return
if not vtx[cur]:
if cur == tg + 3:
total += 1
return
visited = visited.copy()
visited.append(cur)
... | vts = list()
vts.append(0)
vtx = list()
total = 0
def dfs(cur, visited: list):
global vtx, total
if cache[cur] != -1:
total += cache[cur]
return
if not vtx[cur]:
if cur == tg + 3:
total += 1
return
visited = visited.copy()
visited.append(cur)
for i in... |
#!/usr/bin/env prey
async def main():
await x("ls -a")
cd("..")
a = await x("ls")
await asyncio.sleep(2)
| async def main():
await x('ls -a')
cd('..')
a = await x('ls')
await asyncio.sleep(2) |
class Solution:
def halvesAreAlike(self, s: str) -> bool:
num_vowels=0
num_vowels1=0
split = -( ( -len(s) )//2 )
p1, p2 = s[:split], s[split:]
for char in p1:
if char in "aeiouAEIOU":
num_vowels = num_vowels+1
for char in p2:
... | class Solution:
def halves_are_alike(self, s: str) -> bool:
num_vowels = 0
num_vowels1 = 0
split = -(-len(s) // 2)
(p1, p2) = (s[:split], s[split:])
for char in p1:
if char in 'aeiouAEIOU':
num_vowels = num_vowels + 1
for char in p2:
... |
class BaseValidationError(ValueError):
pass
class LogInFileNotParsedError(BaseValidationError):
pass
| class Basevalidationerror(ValueError):
pass
class Loginfilenotparsederror(BaseValidationError):
pass |
# -*- coding: utf-8 -*-
class TransitionType(object):
def __init__(self, utc_offset, is_dst, abbrev):
self.utc_offset = utc_offset
self.is_dst = is_dst
self.abbrev = abbrev
def __repr__(self):
return '<TransitionType [{}, {}, {}]>'.format(
self.utc_offset,
... | class Transitiontype(object):
def __init__(self, utc_offset, is_dst, abbrev):
self.utc_offset = utc_offset
self.is_dst = is_dst
self.abbrev = abbrev
def __repr__(self):
return '<TransitionType [{}, {}, {}]>'.format(self.utc_offset, self.is_dst, self.abbrev) |
#!/usr/bin/env python
# coding: utf-8
# In given array find the duplicate odd number .
#
# Note: There is only one duplicate odd number
#
# <b> Ex [1,4,6,3,1] should return 1 </b>
# In[3]:
def dup_odd_num(num):
count=0
for i in range(len(num)):
if num[i] % 2 != 0:
count+=1
if c... | def dup_odd_num(num):
count = 0
for i in range(len(num)):
if num[i] % 2 != 0:
count += 1
if count > 1:
return num[i]
return False
print(dup_odd_num([1, 3, 2, 3]))
def dup_odd_num(num):
count = 0
dic = {}
for i in range(len(num)):
if num[i] % 2 != ... |
a = int(input())
b = int(input())
count = 0
x = 0
a1 = str(a)
b1 = str(b)
if len(a1) == len(b1):
for i in a1:
for j in b1[x::]:
if i != j:
count += 1
x += 1
break
print(count)
| a = int(input())
b = int(input())
count = 0
x = 0
a1 = str(a)
b1 = str(b)
if len(a1) == len(b1):
for i in a1:
for j in b1[x:]:
if i != j:
count += 1
x += 1
break
print(count) |
valores =[]
valores_quadrado =[]
for i in range(10):
valores.append(int(input("Digite um numero inteiro: ")))
for i in valores:
valores_quadrado.append(i**2)
print("Valores da lista ao quadrado: ",valores_quadrado)
print("Soma dos quadrados: ",sum(valores_quadrado)) | valores = []
valores_quadrado = []
for i in range(10):
valores.append(int(input('Digite um numero inteiro: ')))
for i in valores:
valores_quadrado.append(i ** 2)
print('Valores da lista ao quadrado: ', valores_quadrado)
print('Soma dos quadrados: ', sum(valores_quadrado)) |
def str_seems_like_json(txt):
for c in txt:
if c not in "\r\n\t ":
return c == '{'
return False
def bytes_seems_like_json(binary):
for b in binary:
if b not in [13, 10, 9, 32]:
return b == 123
return False
| def str_seems_like_json(txt):
for c in txt:
if c not in '\r\n\t ':
return c == '{'
return False
def bytes_seems_like_json(binary):
for b in binary:
if b not in [13, 10, 9, 32]:
return b == 123
return False |
DEFAULT_SESSION_DURATION = 43200 # 12 hours
SANDBOX_SESSION_DURATION = 60 * 60 # 1 hour
BASTION_PROFILE_ENV_NAME = 'FIGGY_AWS_PROFILE'
AWS_REGIONS = ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'af-south-1', 'ap-east-1', 'ap-east-2',
'ap-northeast-3', 'ap-northeast-2', 'ap-northeast-1', 'ap-so... | default_session_duration = 43200
sandbox_session_duration = 60 * 60
bastion_profile_env_name = 'FIGGY_AWS_PROFILE'
aws_regions = ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'af-south-1', 'ap-east-1', 'ap-east-2', 'ap-northeast-3', 'ap-northeast-2', 'ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'ca-cent... |
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# Sep 16, 2016 pmoyer Generated
class GetStationsRequest(object):
def __init__(self):
self.pluginName = Non... | class Getstationsrequest(object):
def __init__(self):
self.pluginName = None
def get_plugin_name(self):
return self.pluginName
def set_plugin_name(self, pluginName):
self.pluginName = pluginName |
def compute():
ans = sum(1 for i in range(10000) if is_lychrel(i))
return str(ans)
def is_lychrel(n):
for i in range(50):
n += int(str(n)[ : : -1])
if str(n) == str(n)[ : : -1]:
return False
return True
if __name__ == "__main__":
print(compute())
| def compute():
ans = sum((1 for i in range(10000) if is_lychrel(i)))
return str(ans)
def is_lychrel(n):
for i in range(50):
n += int(str(n)[::-1])
if str(n) == str(n)[::-1]:
return False
return True
if __name__ == '__main__':
print(compute()) |
# lecture 3.6, slide 2
# bisection search for square root
x = 12345
epsilon = 0.01
numGuesses = 0
low = 0.0
high = x
ans = (high + low)/2.0
while abs(ans**2 - x) >= epsilon:
print('low = ' + str(low) + ' high = ' + str(high) + ' ans = ' + str(ans))
numGuesses += 1
if ans**2 < x:
low = ans
else:... | x = 12345
epsilon = 0.01
num_guesses = 0
low = 0.0
high = x
ans = (high + low) / 2.0
while abs(ans ** 2 - x) >= epsilon:
print('low = ' + str(low) + ' high = ' + str(high) + ' ans = ' + str(ans))
num_guesses += 1
if ans ** 2 < x:
low = ans
else:
high = ans
ans = (high + low) / 2.0
pr... |
#!/usr/bin/env python3
# imports go here
#
# Free Coding session for 2015-03-02
# Written by Matt Warren
#
class SimpleClass:
def main(self):
return "HI"
def main2(self):
return "HELLO AGAIN"
if __name__ == '__main__':
sc = SimpleClass()
assert(sc.main.__name__ == 'main')
fn = g... | class Simpleclass:
def main(self):
return 'HI'
def main2(self):
return 'HELLO AGAIN'
if __name__ == '__main__':
sc = simple_class()
assert sc.main.__name__ == 'main'
fn = getattr(sc, 'main')
assert fn() == 'HI'
fn = getattr(sc, 'main', sc.main2)
assert fn() == 'HI'
... |
r =int(input("enter the row:"))
for i in range(1, r+1):
for j in range(1, i+1):
print("*", end = " ")
print("\n")
x = r
for j in range(1, r):
for i in range(1, x):
print("*", end = " ")
x = x - 1
print("\n")
| r = int(input('enter the row:'))
for i in range(1, r + 1):
for j in range(1, i + 1):
print('*', end=' ')
print('\n')
x = r
for j in range(1, r):
for i in range(1, x):
print('*', end=' ')
x = x - 1
print('\n') |
SERVIDOR_DESTINO = "BIGSQL"
YAML_SCOOP_IMPORT = "sqoop-import"
YAML_SCOOP_EXPORT = "sqoop-export"
YAML_BIGSQL_EXEC = "bigsql-import"
YAML_HDFS_IMPORT = "hdfs-import"
YAML_HDFS_EXPORT = "hdfs-export"
YAML_PYTHON_SCRIPT = "python-script"
YAML_ORIGEM = "origem"
YAML_DESTINO = "destino"
YAML_TABLE = "tabela"
YAML_QUERY =... | servidor_destino = 'BIGSQL'
yaml_scoop_import = 'sqoop-import'
yaml_scoop_export = 'sqoop-export'
yaml_bigsql_exec = 'bigsql-import'
yaml_hdfs_import = 'hdfs-import'
yaml_hdfs_export = 'hdfs-export'
yaml_python_script = 'python-script'
yaml_origem = 'origem'
yaml_destino = 'destino'
yaml_table = 'tabela'
yaml_query = '... |
{
# Ports for the left-side motors
"leftMotorPorts": [0, 1],
# Ports for the right-side motors
"rightMotorPorts": [2, 3],
# NOTE: Inversions of the slaves (i.e. any motor *after* the first on
# each side of the drive) are *with respect to their master*. This is
# different from the other po... | {'leftMotorPorts': [0, 1], 'rightMotorPorts': [2, 3], 'leftMotorsInverted': [False, False], 'rightMotorsInverted': [False, False], 'encoderPPR': 512, 'leftEncoderInverted': False, 'rightEncoderInverted': False, 'gearing': 1, 'wheelDiameter': 0.333, 'gyroType': 'None', 'gyroPort': ''} |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"generate": "00_numpy.ipynb",
"square_root_by_exhaustive": "01_python03.ipynb",
"square_root_by_binary_search": "01_python03.ipynb",
"square_root_by_newton": "01_python03.ipynb",
... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'generate': '00_numpy.ipynb', 'square_root_by_exhaustive': '01_python03.ipynb', 'square_root_by_binary_search': '01_python03.ipynb', 'square_root_by_newton': '01_python03.ipynb', 'search': '01_python03.ipynb', 'select_sort': '01_python03.ipynb'}
mod... |
answer1 = widget_inputs["radio1"]
answer2 = widget_inputs["radio2"]
answer3 = widget_inputs["radio3"]
answer4 = widget_inputs["radio4"]
is_correct = False
comments = []
def commentizer(new):
if new not in comments:
comments.append(new)
if answer1 == True:
is_correct = True
else:
is_correct = is_c... | answer1 = widget_inputs['radio1']
answer2 = widget_inputs['radio2']
answer3 = widget_inputs['radio3']
answer4 = widget_inputs['radio4']
is_correct = False
comments = []
def commentizer(new):
if new not in comments:
comments.append(new)
if answer1 == True:
is_correct = True
else:
is_correct = is_cor... |
digit = input('Enter number:')
name = input("Name:")
if not digit.i:
print("Input must be a digit")
exit(1)
print(int(digit) + 1)
| digit = input('Enter number:')
name = input('Name:')
if not digit.i:
print('Input must be a digit')
exit(1)
print(int(digit) + 1) |
num1 = 11
num2 = 222
num3 = 3333333
num3 = 333
num4 = 44444
| num1 = 11
num2 = 222
num3 = 3333333
num3 = 333
num4 = 44444 |
# mock data
OP_STATIC_ATTRS = {
"objectClass": ["top", "oxAuthClient"],
"oxAuthScope": [
"inum=F0C4,ou=scopes,o=gluu",
"inum=C4F5,ou=scopes,o=gluu",
],
"inum": "w124asdgggAGs",
}
ADD_OP_TEST_ARGS = {
"oxAuthLogoutSessionRequired": False,
"oxAuthTrustedClient": False,
"oxAut... | op_static_attrs = {'objectClass': ['top', 'oxAuthClient'], 'oxAuthScope': ['inum=F0C4,ou=scopes,o=gluu', 'inum=C4F5,ou=scopes,o=gluu'], 'inum': 'w124asdgggAGs'}
add_op_test_args = {'oxAuthLogoutSessionRequired': False, 'oxAuthTrustedClient': False, 'oxAuthResponseType': 'token', 'oxAuthTokenEndpointAuthMethod': 'client... |
#!/usr/bin/env python3
# Day 15: Non-overlapping Intervals
#
# Given a collection of intervals, find the minimum number of intervals you
# need to remove to make the rest of the intervals non-overlapping.
#
# Note:
# - You may assume the interval's end point is always bigger than its start
# point.
# - Intervals lik... | class Solution:
def erase_overlap_intervals(self, intervals: [[int]]) -> int:
if len(intervals) == 0:
return 0
start = lambda interval: interval[0]
end = lambda interval: interval[1]
intervals = sorted(intervals, key=end)
intervals_to_remove = 0
previous_... |
aux = 0
num = int(input("Ingrese un numero entero positivo: "))
if num>0:
for x in range(0,num+1):
aux = aux + x
print (aux) | aux = 0
num = int(input('Ingrese un numero entero positivo: '))
if num > 0:
for x in range(0, num + 1):
aux = aux + x
print(aux) |
start = [8,13,1,0,18,9]
last_said = None
history = {}
def say(num, turn_no):
print(f'turn {i}\tsay {num}')
for i in range(30000000):
if i < len(start):
num = start[i]
else:
# print(f'turn {i} last said {last_said} {history}')
if last_said in history:
# print('in')
... | start = [8, 13, 1, 0, 18, 9]
last_said = None
history = {}
def say(num, turn_no):
print(f'turn {i}\tsay {num}')
for i in range(30000000):
if i < len(start):
num = start[i]
elif last_said in history:
num = i - history[last_said] - 1
else:
num = 0
if last_said is not None:
... |
num1 = '100'
num2 = '200'
# 100200
print(num1 + num2)
# Casting - 300
num1 = int(num1)
num2 = int(num2)
print(num1 + num2) | num1 = '100'
num2 = '200'
print(num1 + num2)
num1 = int(num1)
num2 = int(num2)
print(num1 + num2) |
# ------- FUNCTION BASICS --------
def allotEmail(firstName, surname):
return firstName+'.'+surname+'@pythonabc.org'
name = input("Enter your name: ")
fName, sName = name.split()
compEmail = allotEmail(fName, sName)
print(compEmail)
def get_sum(*args):
sum = 0
for i in args:
sum += i
return... | def allot_email(firstName, surname):
return firstName + '.' + surname + '@pythonabc.org'
name = input('Enter your name: ')
(f_name, s_name) = name.split()
comp_email = allot_email(fName, sName)
print(compEmail)
def get_sum(*args):
sum = 0
for i in args:
sum += i
return sum
print('sum =', get_su... |
'''
An approximation of network latency in the Bitcoin network based on the
following paper: https://ieeexplore.ieee.org/document/6688704/.
From the green line in Fig 1, we can approximate the function as:
Network latency (sec) = 19/300 sec/KB * KB + 1 sec
If we assume a transaction is 500 bytes or 1/2 KB, we... | """
An approximation of network latency in the Bitcoin network based on the
following paper: https://ieeexplore.ieee.org/document/6688704/.
From the green line in Fig 1, we can approximate the function as:
Network latency (sec) = 19/300 sec/KB * KB + 1 sec
If we assume a transaction is 500 bytes or 1/2 KB, we... |
class Spam(object):
'''
The Spam object contains lots of spam
Args:
arg (str): The arg is used for ...
*args: The variable arguments are used for ...
**kwargs: The keyword arguments are used for ...
Attributes:
arg (str): This is where we store arg,
'''
def __... | class Spam(object):
"""
The Spam object contains lots of spam
Args:
arg (str): The arg is used for ...
*args: The variable arguments are used for ...
**kwargs: The keyword arguments are used for ...
Attributes:
arg (str): This is where we store arg,
"""
def __i... |
'''
Given an integer array nums, return the length of the longest strictly increasing subsequence.
A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].
... | """
Given an integer array nums, return the length of the longest strictly increasing subsequence.
A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].
... |
class Solution(object):
@staticmethod
def min_steps(candy, n, m):
min_step = float("inf")
def dfs(curr, i, j, num_candy, steps):
nonlocal min_step
if num_candy == m:
min_step = min(steps, min_step)
if steps > min_step:
return... | class Solution(object):
@staticmethod
def min_steps(candy, n, m):
min_step = float('inf')
def dfs(curr, i, j, num_candy, steps):
nonlocal min_step
if num_candy == m:
min_step = min(steps, min_step)
if steps > min_step:
return
... |
class Employee:
# Constructor untuk Employee
def __init__(self, first_name, last_name, monthly_salary):
self._first_name = first_name
self._last_name = last_name
self._monthly_salary = monthly_salary
if monthly_salary < 0:
self._monthly_salary = 0
# Getter dan setter first_name
@property
def... | class Employee:
def __init__(self, first_name, last_name, monthly_salary):
self._first_name = first_name
self._last_name = last_name
self._monthly_salary = monthly_salary
if monthly_salary < 0:
self._monthly_salary = 0
@property
def first_name(self):
ret... |
class Solution:
def minFallingPathSum(self, arr: List[List[int]]) -> int:
min1 = min2 = -1
for j in range(len(arr[0])):
if min1 == -1 or arr[0][j] < arr[0][min1]:
min2 = min1
min1 = j
elif min2 == -1 or arr[0][j] < arr[0][min2]:
... | class Solution:
def min_falling_path_sum(self, arr: List[List[int]]) -> int:
min1 = min2 = -1
for j in range(len(arr[0])):
if min1 == -1 or arr[0][j] < arr[0][min1]:
min2 = min1
min1 = j
elif min2 == -1 or arr[0][j] < arr[0][min2]:
... |
GENERAL_HELP = '''
Usage:
vt <command> [options]
Commands:
lists Get all lists
list Return items of a specific list
item Return a specific item
show Alias for item
done Mark an item done
complete Alias for done
undone Mark an item undone
unc... | general_help = '\nUsage:\n vt <command> [options]\n\nCommands:\n lists Get all lists\n list Return items of a specific list\n item Return a specific item\n show Alias for item\n done Mark an item done\n complete Alias for done\n undone Mark an item undon... |
# slicing lab
def swap(seq):
return seq[-1:]+seq[1:-1]+seq[:1]
assert swap('something') == 'gomethins'
assert swap(tuple(range(10))) == (9,1,2,3,4,5,6,7,8,0)
def rem(seq):
return seq[::2]
assert rem('a word') == 'awr'
def rem4(seq):
return seq[4:-4:2]
print(rem4( (1,2,3,4,5,6,7,8,9,10,11), ) )
def ... | def swap(seq):
return seq[-1:] + seq[1:-1] + seq[:1]
assert swap('something') == 'gomethins'
assert swap(tuple(range(10))) == (9, 1, 2, 3, 4, 5, 6, 7, 8, 0)
def rem(seq):
return seq[::2]
assert rem('a word') == 'awr'
def rem4(seq):
return seq[4:-4:2]
print(rem4((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)))
def r... |
def minkowski(a, b, p) :
summ = 0
n = len(a)
for i in range(n) :
summ += (b[i]-a[i])**p
summ = summ ** (1/p)
return summ
a = [0, 3, 4, 5]
b = [7, 6, 3, -1]
p=3
print(minkowski(a, b, p))
| def minkowski(a, b, p):
summ = 0
n = len(a)
for i in range(n):
summ += (b[i] - a[i]) ** p
summ = summ ** (1 / p)
return summ
a = [0, 3, 4, 5]
b = [7, 6, 3, -1]
p = 3
print(minkowski(a, b, p)) |
inp = input()
points = inp.split(" ")
for i in range(len(points)):
points[i] = int(points[i])
points.sort()
result = points[len(points) - 1] - points[0]
print(result) | inp = input()
points = inp.split(' ')
for i in range(len(points)):
points[i] = int(points[i])
points.sort()
result = points[len(points) - 1] - points[0]
print(result) |
# Created by MechAviv
# ID :: [4000013]
# Maple Road : Inside the Small Forest
sm.showFieldEffect("maplemap/enter/40000", 0) | sm.showFieldEffect('maplemap/enter/40000', 0) |
# Define time, time constant
t = np.arange(0, 10, .1)
tau = 0.5
# Compute alpha function
f = t * np.exp(-t/tau)
# Define u(t), v(t)
u_t = t
v_t = np.exp(-t/tau)
# Define du/dt, dv/dt
du_dt = 1
dv_dt = -1/tau * np.exp(-t/tau)
# Define full derivative
df_dt = u_t * dv_dt + v_t * du_dt
# Uncomment below to visualize... | t = np.arange(0, 10, 0.1)
tau = 0.5
f = t * np.exp(-t / tau)
u_t = t
v_t = np.exp(-t / tau)
du_dt = 1
dv_dt = -1 / tau * np.exp(-t / tau)
df_dt = u_t * dv_dt + v_t * du_dt
with plt.xkcd():
plot_alpha_func(t, f, df_dt) |
al = 0
ga = 0
di = 0
x = 0
while x != 4:
x = int(input())
if x == 1:
al = al + 1
if x == 2:
ga = ga + 1
if x == 3:
di = di + 1
print('MUITO OBRIGADO')
print('Alcool: {}'.format(al))
print('Gasolina: {}'.format(ga))
print('Diesel: {}'.format(di))
| al = 0
ga = 0
di = 0
x = 0
while x != 4:
x = int(input())
if x == 1:
al = al + 1
if x == 2:
ga = ga + 1
if x == 3:
di = di + 1
print('MUITO OBRIGADO')
print('Alcool: {}'.format(al))
print('Gasolina: {}'.format(ga))
print('Diesel: {}'.format(di)) |
# 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 countNodes(self, root: TreeNode) -> int:
maxDepth = self.findLeftMaxDepth(root)
if maxDe... | class Solution:
def count_nodes(self, root: TreeNode) -> int:
max_depth = self.findLeftMaxDepth(root)
if maxDepth <= 1:
return maxDepth
else:
cur_root = root
cur_depth = 1
total_num = 0
while True:
if curRoot.left =... |
'''
A library to speed up physics data analysis.
Contains functions for error analysis and calculations
for various physics mechanics values.
''' | """
A library to speed up physics data analysis.
Contains functions for error analysis and calculations
for various physics mechanics values.
""" |
# Creating variables dynamically.
# To be able to pass arguments to variable file, we must define
# and use "get_variables" in a similar manner as follows:
def get_variables(server_uri, start_port):
# Note that the order in which the libraries are listed here must match
# that in 'server.py'.
port ... | def get_variables(server_uri, start_port):
port = int(start_port)
target_uri = '%s:%d' % (server_uri, port)
port += 1
common_uri = '%s:%d' % (server_uri, port)
port += 1
security_uri = '%s:%d' % (server_uri, port)
return {'target_uri': target_uri, 'common_uri': common_uri, 'security_uri': se... |
class StageOutputs:
execute_outputs = {
# Outputs from public Cisco docs:
# https://www.cisco.com/c/en/us/td/docs/routers/asr1000/release/notes/asr1k_rn_rel_notes/asr1k_rn_sys_req.html
'copy running-config startup-config': '''\
PE1#copy running-config startup-config
... | class Stageoutputs:
execute_outputs = {'copy running-config startup-config': ' PE1#copy running-config startup-config\n Destination filename [startup-config]?\n %Error opening bootflash:running-config (Permission denied)\n ', 'show boot': ' starfleet-1#show boot\n ... |
class UnknownCommand(Exception):
pass
class ModuleNotFound(Exception):
pass
class VariableError(Exception):
pass
class ModuleError:
error = ""
def __init__(self, error):
self.error = error | class Unknowncommand(Exception):
pass
class Modulenotfound(Exception):
pass
class Variableerror(Exception):
pass
class Moduleerror:
error = ''
def __init__(self, error):
self.error = error |
class Node:
def __init__(self,tag,valid_bit = 1,next = None,previous = None):
self.tag = tag
self.valid_bit = valid_bit
self.next = next
self.previous = previous
def set_next_pointer(self,next):
self.next = next
def set_previous_pointer(self,previous):... | class Node:
def __init__(self, tag, valid_bit=1, next=None, previous=None):
self.tag = tag
self.valid_bit = valid_bit
self.next = next
self.previous = previous
def set_next_pointer(self, next):
self.next = next
def set_previous_pointer(self, previous):
self... |
# Do not hard code credentials
client = boto3.client(
's3',
# Hard coded strings as credentials, not recommended.
aws_access_key_id='AKIAIO5FODNN7EXAMPLE',
aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'
)
# adding another line
| client = boto3.client('s3', aws_access_key_id='AKIAIO5FODNN7EXAMPLE', aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE') |
#!/usr/bin/env python3
#
## @file
# checkout_humble.py
#
# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
NO_COMBO = 'A combination named: {} does not exist in the workspace manifest'
| no_combo = 'A combination named: {} does not exist in the workspace manifest' |
cuda_code = '''
extern "C" __global__ void my_kernel(float* input_domain, int input_domain_n, int* layer_sizes, int layer_number, float* full_weights,
float* full_biases, float* results_cuda, int max_layer_size, int* activations) {
// Calculate all the bounds, node by node, for each layer. 'new_layer_values' is ... | cuda_code = '\n\nextern "C" __global__ void my_kernel(float* input_domain, int input_domain_n, int* layer_sizes, int layer_number, float* full_weights, \n\t\t\tfloat* full_biases, float* results_cuda, int max_layer_size, int* activations) {\n\n\t// Calculate all the bounds, node by node, for each layer. \'new_layer_val... |
class Point:
def __init__(self, x, y):
self.x = float(x)
self.y = float(y)
def __str__(self):
return "(" + str(round(self.x, 1)) + ', ' + str(round(self.y, 1)) + ")"
class Triangle:
def __init__(self, points):
self.points = points
def get_centroid(self):
sum... | class Point:
def __init__(self, x, y):
self.x = float(x)
self.y = float(y)
def __str__(self):
return '(' + str(round(self.x, 1)) + ', ' + str(round(self.y, 1)) + ')'
class Triangle:
def __init__(self, points):
self.points = points
def get_centroid(self):
sum_... |
class TrackableObject:
def __init__(self, objectID, centroid_frame_timestamp, detection_class_id, centroid, boxoid, bbox_rw_coords):
# store the object ID, then initialize a list of centroids
# using the current centroid
self.objectID = objectID
# initialize instance variable, 'oids... | class Trackableobject:
def __init__(self, objectID, centroid_frame_timestamp, detection_class_id, centroid, boxoid, bbox_rw_coords):
self.objectID = objectID
self.oids = []
self.centroids = []
self.boxoids = []
self.bbox_rw_coords = []
self.detection_class_id = detec... |
#---------------------------------------
# Selection Sort
#---------------------------------------
def selection_sort(A):
for i in range (0, len(A) - 1):
minIndex = i
for j in range (i+1, len(A)):
if A[j] < A[minIndex]:
minIndex = j
if minIndex != i:
A[i], A[minIndex] = A[minIndex], A[i]
A = [5,... | def selection_sort(A):
for i in range(0, len(A) - 1):
min_index = i
for j in range(i + 1, len(A)):
if A[j] < A[minIndex]:
min_index = j
if minIndex != i:
(A[i], A[minIndex]) = (A[minIndex], A[i])
a = [5, 9, 1, 2, 4, 8, 6, 3, 7]
print(A)
selection_sort(... |
games = ["chess", "soccer", "tennis"]
foods = ["chicken", "milk", "fruits"]
favorites = games + foods
print(favorites)
| games = ['chess', 'soccer', 'tennis']
foods = ['chicken', 'milk', 'fruits']
favorites = games + foods
print(favorites) |
# Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
# For example,
# Given the following matrix:
# [
# [ 1, 2, 3 ],
# [ 4, 5, 6 ],
# [ 7, 8, 9 ]
# ]
# You should return [1,2,3,6,9,8,7,4,5].
class Solution:
# @param {integer[][]} matrix
# @return {i... | class Solution:
def spiral_order(self, matrix):
if not matrix or not matrix[0]:
return []
total = len(matrix) * len(matrix[0])
spiral = []
(l, r, u, d) = (-1, len(matrix[0]), 0, len(matrix))
(s, i, j) = (0, 0, 0)
for c in range(total):
spiral.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.