content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class SubrectangleQueries:
def __init__(self, rectangle: List[List[int]]):
self.rec = rectangle
self.newRec = []
def updateSubrectangle(self, row1: int, col1: int, row2: int, col2: int, newValue: int) -> None:
self.newRec.append((row1, col1, row2, col2, newValue))
def get... | class Subrectanglequeries:
def __init__(self, rectangle: List[List[int]]):
self.rec = rectangle
self.newRec = []
def update_subrectangle(self, row1: int, col1: int, row2: int, col2: int, newValue: int) -> None:
self.newRec.append((row1, col1, row2, col2, newValue))
def get_value(s... |
# model
model = Model()
i0 = Input("op_shape", "TENSOR_INT32", "{4}")
weights = Parameter("ker", "TENSOR_FLOAT32", "{1, 3, 3, 1}", [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0])
i1 = Input("in", "TENSOR_FLOAT32", "{1, 4, 4, 1}" )
pad = Int32Scalar("pad_same", 1)
s_x = Int32Scalar("stride_x", 1)
s_y = Int32Scalar("strid... | model = model()
i0 = input('op_shape', 'TENSOR_INT32', '{4}')
weights = parameter('ker', 'TENSOR_FLOAT32', '{1, 3, 3, 1}', [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0])
i1 = input('in', 'TENSOR_FLOAT32', '{1, 4, 4, 1}')
pad = int32_scalar('pad_same', 1)
s_x = int32_scalar('stride_x', 1)
s_y = int32_scalar('stride_y', ... |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 13:28:17 2020
@author: Robinson Montes
Carlos Murcia
"""
| """
Created on Tue Jun 30 13:28:17 2020
@author: Robinson Montes
Carlos Murcia
""" |
{
"targets": [
{
"target_name": "cityhash",
"include_dirs": ["cityhash/"],
"sources": [
"binding.cc",
"cityhash/city.cc"
]
}
]
}
| {'targets': [{'target_name': 'cityhash', 'include_dirs': ['cityhash/'], 'sources': ['binding.cc', 'cityhash/city.cc']}]} |
# def positive_or_negative(value):
# if value > 0:
# return "Positive!"
# elif value < 0:
# return "Negative!"
# else:
# return "It's zero!"
# number = int(input("Wprowadz liczbe: "))
# print(positive_or_negative(number))
def calculator(operation, a, b):
if operation == "add":
... | def calculator(operation, a, b):
if operation == 'add':
return a + b
elif operation == 'subtract':
return a - b
elif operation == 'multiple':
return a * b
elif operation == 'divide':
return a / b
else:
print('There is no such an operation!')
operacja = str(inp... |
pkgname = "eventlog"
pkgver = "0.2.13"
pkgrel = 0
_commit = "a5c19163ba131f79452c6dfe4e31c2b4ce4be741"
build_style = "gnu_configure"
hostmakedepends = ["pkgconf", "automake", "libtool"]
pkgdesc = "API to format and send structured log messages"
maintainer = "q66 <q66@chimera-linux.org>"
license = "BSD-3-Clause"
url = "... | pkgname = 'eventlog'
pkgver = '0.2.13'
pkgrel = 0
_commit = 'a5c19163ba131f79452c6dfe4e31c2b4ce4be741'
build_style = 'gnu_configure'
hostmakedepends = ['pkgconf', 'automake', 'libtool']
pkgdesc = 'API to format and send structured log messages'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'BSD-3-Clause'
url = '... |
"""Echoes everything you say.
Usage:
/echo
/echo Hi!
Type 'cancel' to stop echoing.
"""
def handle_update(bot, update, update_queue, **kwargs):
"""Echo messages that user sends.
This is the main function that modulehander calls.
Args:
bot (telegram.Bot): Telegram bot itself
update ... | """Echoes everything you say.
Usage:
/echo
/echo Hi!
Type 'cancel' to stop echoing.
"""
def handle_update(bot, update, update_queue, **kwargs):
"""Echo messages that user sends.
This is the main function that modulehander calls.
Args:
bot (telegram.Bot): Telegram bot itself
update (... |
#
# PySNMP MIB module CISCO-COMPRESSION-SERVICE-ADAPTER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-COMPRESSION-SERVICE-ADAPTER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:36:21 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
#... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, value_range_constraint, single_value_constraint, constraints_intersection) ... |
user_input = '5,4,25,18,22,9'
user_numbers = user_input.split(',')
user_numbers_as_int = []
for number in user_numbers:
user_numbers_as_int.append(int(number))
print(user_numbers_as_int)
print([number for number in user_numbers])
print([number*2 for number in user_numbers])
print([int(number) for number in use... | user_input = '5,4,25,18,22,9'
user_numbers = user_input.split(',')
user_numbers_as_int = []
for number in user_numbers:
user_numbers_as_int.append(int(number))
print(user_numbers_as_int)
print([number for number in user_numbers])
print([number * 2 for number in user_numbers])
print([int(number) for number in user_n... |
line = "Please have a nice day"
# This takes a parameter, what prefix we're looking for.
line_new = line.startswith('Please')
print(line_new)
#Does it start with a lowercase p?
# And then we get back a False because,
# no, it doesn't start with a lowercase p
line_new = line.startswith('p')
print(line_new)
| line = 'Please have a nice day'
line_new = line.startswith('Please')
print(line_new)
line_new = line.startswith('p')
print(line_new) |
a=[1,2]
for i,s in enumerate(a):
print(i,"index contains",s)
| a = [1, 2]
for (i, s) in enumerate(a):
print(i, 'index contains', s) |
def gen_help(bot_name):
return'''
Hello!
I am a telegram bot that generates duckduckgo links from tg directly.
I am an inline bot, you can access it via @{bot_name}.
If you have any questions feel free to leave issue at http://github.com/cleac/tgsearchbot
'''.format(bot_name=bot_name)
| def gen_help(bot_name):
return '\nHello!\n\nI am a telegram bot that generates duckduckgo links from tg directly.\nI am an inline bot, you can access it via @{bot_name}.\n\nIf you have any questions feel free to leave issue at http://github.com/cleac/tgsearchbot\n '.format(bot_name=bot_name) |
#class Solution:
# def checkPowersOfThree(self, n: int) -> bool:
#def checkPowersOfThree(n):
# def divisible_by_3(k):
# return k % 3 == 0
# #if 1 <= n <= 2:
# if n == 2:
# return False
# if divisible_by_3(n):
# return checkPowersOfThree(n//3)
# else:
# n = n - 1
# ... | qualified = {1, 3, 4, 9}
def check_powers_of_three(n):
if n in qualified:
return True
remainder = n % 3
if remainder == 2:
return False
else:
reduced = (n - remainder) // 3
if check_powers_of_three(reduced):
qualified.add(reduced)
return True
... |
n = int(input('Enter A Number:'))
count = 1
for i in range(count, 11, 1):
print (f'{n} * {count} = {n*count}')
count +=1 | n = int(input('Enter A Number:'))
count = 1
for i in range(count, 11, 1):
print(f'{n} * {count} = {n * count}')
count += 1 |
# Sum of the diagonals of a spiral square diagonal
# OPTIMAL (<0.1s)
#
# APPROACH:
# Generate the numbers in the spiral with a simple algorithm until
# the desdired side is obtained,
SQUARE_SIDE = 1001
DUMMY_SQUARE_SIDE = 5
DUMMY_RESULT = 101
def generate_numbers(limit):
current = 1
internal_square = 1
steps = ... | square_side = 1001
dummy_square_side = 5
dummy_result = 101
def generate_numbers(limit):
current = 1
internal_square = 1
steps = 0
while internal_square <= limit:
yield current
if current == internal_square ** 2:
internal_square += 2
steps += 2
current +=... |
def get_data(query):
"""[summary] make variable of chart.graphs.drawgraph.Graph().CustomDraw(kwargs) from querydict. The querydict from index.html
Args:
query ([type]): [description] querydict like <QueryDict: {'csrfmiddlewaretoken': ['2aboKu6bYhaa5OiUS5cWLytPpUpEMFLLqsYlZAE3MWervMwfoQ3HP9RlRcjEl9U... | def get_data(query):
"""[summary] make variable of chart.graphs.drawgraph.Graph().CustomDraw(kwargs) from querydict. The querydict from index.html
Args:
query ([type]): [description] querydict like <QueryDict: {'csrfmiddlewaretoken': ['2aboKu6bYhaa5OiUS5cWLytPpUpEMFLLqsYlZAE3MWervMwfoQ3HP9RlRcjEl9Uj'],... |
PI = 3.14
SALES_TAX = 6
if __name__ == '__main__':
print('Constant file directly executed')
else:
print('Constant file is imported') | pi = 3.14
sales_tax = 6
if __name__ == '__main__':
print('Constant file directly executed')
else:
print('Constant file is imported') |
# ------------------------------------------------------------------------
# Copyright 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/li... | class Configuration:
"""Compiler-specific configuration abstract base class"""
def __init__(self, context):
"""
Initialize the Configuration object
Arguments:
context -- the scons configure context
"""
if type(self) is Configuration:
raise type_error... |
{
'targets': [
{
'target_name': 'electron-dragdrop-win',
'include_dirs': [
'<!(node -e "require(\'nan\')")',
],
'defines': [ 'UNICODE', '_UNICODE'],
'sources': [
],
'conditions': [
['OS=="win"', {
'sources': [
"src/addon.cpp",
... | {'targets': [{'target_name': 'electron-dragdrop-win', 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'defines': ['UNICODE', '_UNICODE'], 'sources': [], 'conditions': [['OS=="win"', {'sources': ['src/addon.cpp', 'src/Worker.cpp', 'src/v8utils.cpp', 'src/ole/DataObject.cpp', 'src/ole/DropSource.cpp', 'src/ole/EnumFo... |
def format_reader_port_message(message, reader_port, error):
return f'{message} with {reader_port}. Error: {error}'
def format_reader_message(message, vendor_id, product_id, serial_number):
return f'{message} with ' \
f'vendor_id={vendor_id}, ' \
f'product_id={product_id} and ' \
... | def format_reader_port_message(message, reader_port, error):
return f'{message} with {reader_port}. Error: {error}'
def format_reader_message(message, vendor_id, product_id, serial_number):
return f'{message} with vendor_id={vendor_id}, product_id={product_id} and serial_number={serial_number}'
class Readerno... |
word="boy"
print(word)
reverse=[]
l=list(word)
for i in l:
reverse=[i]+reverse
reverse="".join(reverse)
print(reverse)
l=[1,2,3,4]
print(l)
r=[]
for i in l:
r=[i]+r
print(r) | word = 'boy'
print(word)
reverse = []
l = list(word)
for i in l:
reverse = [i] + reverse
reverse = ''.join(reverse)
print(reverse)
l = [1, 2, 3, 4]
print(l)
r = []
for i in l:
r = [i] + r
print(r) |
path = '08-File-Handling-Lab-Resources/File Reader/numbers.txt'
file = open(path, 'r')
num_sum = 0
for num in file:
num_sum += int(num)
print(num) # read
print(num_sum)
print(file.read()) # .read(n) n = number
| path = '08-File-Handling-Lab-Resources/File Reader/numbers.txt'
file = open(path, 'r')
num_sum = 0
for num in file:
num_sum += int(num)
print(num)
print(num_sum)
print(file.read()) |
class BindingTypes:
JSFunction = 1
JSObject = 2
class Binding(object):
def __init__(self, type, src, dest):
self.type = type
self.src = src
self.dest = dest
| class Bindingtypes:
js_function = 1
js_object = 2
class Binding(object):
def __init__(self, type, src, dest):
self.type = type
self.src = src
self.dest = dest |
def faculty_evaluation_result(nev, rar, som, oft, voft, alw):
''' Write code to calculate faculty evaluation rating according to asssignment instructions
:param nev: Never
:param rar: Rarely
:param som: Sometimes
:param oft: Often
:param voft: Very Often
:param alw: Always
:ret... | def faculty_evaluation_result(nev, rar, som, oft, voft, alw):
""" Write code to calculate faculty evaluation rating according to asssignment instructions
:param nev: Never
:param rar: Rarely
:param som: Sometimes
:param oft: Often
:param voft: Very Often
:param alw: Always
:return: rati... |
HTTP_HOST = ''
HTTP_PORT = 8080
FLASKY_MAIL_SUBJECT_PREFIX = "(Info)"
FLASKY_MAIL_SENDER = 'ycs_ctbu_2010@126.com'
FLASKY_ADMIN = 'ycs_ctbu_2010@126.com'
SECRET_KEY = "\x02|\x86.\\\xea\xba\x89\xa3\xfc\r%s\x9e\x06\x9d\x01\x9c\x84\xa1b+uC"
LOG = "/var/flasky"
# WSGI Settings
WSGI_LOG = 'default'
# Flask-... | http_host = ''
http_port = 8080
flasky_mail_subject_prefix = '(Info)'
flasky_mail_sender = 'ycs_ctbu_2010@126.com'
flasky_admin = 'ycs_ctbu_2010@126.com'
secret_key = '\x02|\x86.\\êº\x89£ü\r%s\x9e\x06\x9d\x01\x9c\x84¡b+uC'
log = '/var/flasky'
wsgi_log = 'default'
log_level = 'debug'
log_filename = 'logs/error.log'
log_... |
class Action:
def __init__(self, fun, id=None):
self._fun = fun
self._id = id
def fun(self):
return self._fun
def id(self):
return self._id
| class Action:
def __init__(self, fun, id=None):
self._fun = fun
self._id = id
def fun(self):
return self._fun
def id(self):
return self._id |
def encode(plaintext, key):
"""Encodes plaintext
Encode the message by shifting each character by the offset
of a character in the key.
"""
ciphertext = ""
i, j = 0, 0 # key, plaintext indices
# strip all non-alpha characters from key
key2 = ""
for x in key: key2 += x if x.isalp... | def encode(plaintext, key):
"""Encodes plaintext
Encode the message by shifting each character by the offset
of a character in the key.
"""
ciphertext = ''
(i, j) = (0, 0)
key2 = ''
for x in key:
key2 += x if x.isalpha() else ''
for x in plaintext:
if 97 <= ord(x) <= ... |
class dotIFC2X3_Product_t(object):
# no doc
Description = None
IFC2X3_OwnerHistory = None
Name = None
ObjectType = None
| class Dotifc2X3_Product_T(object):
description = None
ifc2_x3__owner_history = None
name = None
object_type = None |
'''
###############################################
# ####################################### #
#### ######## Simple Calculator ########## ####
# ####################################### #
###############################################
## ##
###########... | """
###############################################
# ####################################### #
#### ######## Simple Calculator ########## ####
# ####################################### #
###############################################
## ##
###########... |
def handle_error_response(resp):
codes = {
-1: FactomAPIError,
-32008: BlockNotFound,
-32009: MissingChainHead,
-32010: ReceiptCreationError,
-32011: RepeatedCommit,
-32600: InvalidRequest,
-32601: MethodNotFound,
-32602: InvalidParams,
-32603:... | def handle_error_response(resp):
codes = {-1: FactomAPIError, -32008: BlockNotFound, -32009: MissingChainHead, -32010: ReceiptCreationError, -32011: RepeatedCommit, -32600: InvalidRequest, -32601: MethodNotFound, -32602: InvalidParams, -32603: InternalError, -32700: ParseError}
error = resp.json().get('error', ... |
# Encapsulate the pairs of int multiples to related string monikers
class MultipleMoniker:
mul = 0
mon = ""
def __init__(self, multiple, moniker) -> None:
self.mul = multiple
self.mon = moniker
# Define object to contain methods
class FizzBuzz:
# Define the int to start counting at
... | class Multiplemoniker:
mul = 0
mon = ''
def __init__(self, multiple, moniker) -> None:
self.mul = multiple
self.mon = moniker
class Fizzbuzz:
start = 1
maxi = 0
mm_pair = [multiple_moniker(3, 'Fizz'), multiple_moniker(5, 'Buzz')]
array = []
def __init__(self, max_int, ... |
"""
Load and Display an OBJ Shape.
The loadShape() command is used to read simple SVG (Scalable Vector Graphics)
files and OBJ (Object) files into a Processing sketch. This example loads an
OBJ file of a rocket and displays it to the screen.
"""
ry = 0
def setup():
size(640, 360, P3D)
global rocket
ro... | """
Load and Display an OBJ Shape.
The loadShape() command is used to read simple SVG (Scalable Vector Graphics)
files and OBJ (Object) files into a Processing sketch. This example loads an
OBJ file of a rocket and displays it to the screen.
"""
ry = 0
def setup():
size(640, 360, P3D)
global rocket
rock... |
class ContentType:
"""AI Model content types."""
MODEL_PUBLISHING = 'application/vnd.iris.ai.model-publishing+json'
MODEL_TRAINING = 'application/vnd.iris.ai.model-training+json'
| class Contenttype:
"""AI Model content types."""
model_publishing = 'application/vnd.iris.ai.model-publishing+json'
model_training = 'application/vnd.iris.ai.model-training+json' |
#
# 1265. Print Immutable Linked List in Reverse
#
# Q: https://leetcode.com/problems/print-immutable-linked-list-in-reverse/
# A: https://leetcode.com/problems/print-immutable-linked-list-in-reverse/discuss/436558/Javascript-Python3-C%2B%2B-1-Liners
#
class Solution:
def printLinkedListInReverse(self, head: 'Immu... | class Solution:
def print_linked_list_in_reverse(self, head: 'ImmutableListNode') -> None:
if head:
self.printLinkedListInReverse(head.getNext())
head.printValue() |
class Grid:
def __init__(self, grid: [[int]]):
self.grid = grid
self.flashes = 0
self.ticks = 0
self.height = len(grid)
self.width = len(grid[0])
self.flashed_cells: [str] = []
def tick(self):
self.ticks += 1
i = 0
for row in self.grid:... | class Grid:
def __init__(self, grid: [[int]]):
self.grid = grid
self.flashes = 0
self.ticks = 0
self.height = len(grid)
self.width = len(grid[0])
self.flashed_cells: [str] = []
def tick(self):
self.ticks += 1
i = 0
for row in self.grid:
... |
#%%
text=open('new.txt', 'r+')
text.write('Hello file')
for i in range(0, 11):
text.write(str(i))
print(text.seek(2))
#%%
#file operations Read & Write
text=open('sampletxt.txt', 'r')
text= text.read()
print(text)
text=text.split(' ')
print(text)
| text = open('new.txt', 'r+')
text.write('Hello file')
for i in range(0, 11):
text.write(str(i))
print(text.seek(2))
text = open('sampletxt.txt', 'r')
text = text.read()
print(text)
text = text.split(' ')
print(text) |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"load_audio": "00_core.ipynb",
"AudioMono": "00_core.ipynb",
"duration": "00_core.ipynb",
"SpecImage": "00_core.ipynb",
"ArrayAudioBase": "00_core.ipynb",
"ArraySp... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'load_audio': '00_core.ipynb', 'AudioMono': '00_core.ipynb', 'duration': '00_core.ipynb', 'SpecImage': '00_core.ipynb', 'ArrayAudioBase': '00_core.ipynb', 'ArraySpecBase': '00_core.ipynb', 'ArrayMaskBase': '00_core.ipynb', 'TensorAudio': '00_core.ip... |
class ObjAlreadyExist(Exception):
"""Is used when is created multiple objects of same RestApi class."""
def __init__(self, cls=None, message=None):
if not (cls and message):
message = "RestApi object was created twice."
elif not message:
message = "{} object was created t... | class Objalreadyexist(Exception):
"""Is used when is created multiple objects of same RestApi class."""
def __init__(self, cls=None, message=None):
if not (cls and message):
message = 'RestApi object was created twice.'
elif not message:
message = '{} object was created ... |
"""
focal_point
===========
The *focal_point* extension allows you to drag a marker on image thumbnails
while editing, thus specifying the most relevant portion of the image. You can
then use these coordinates in templates for image cropping.
- To install it, add the extension module to your ``INSTALLED_APPS`` sett... | """
focal_point
===========
The *focal_point* extension allows you to drag a marker on image thumbnails
while editing, thus specifying the most relevant portion of the image. You can
then use these coordinates in templates for image cropping.
- To install it, add the extension module to your ``INSTALLED_APPS`` sett... |
version = "1.0"
version_maj = 1
version_min = 0
| version = '1.0'
version_maj = 1
version_min = 0 |
r = range(5) # Counts from 0 to 4
for i in r:
print(i)
r = range(1,6) # Counts from 1 to 5
for i in r:
print(i)
# Step Value
r = range(1,15,3) # Counts from 1 to 15 with a gap of '3', thereby, counting till '13' only as 16 is not in the... | r = range(5)
for i in r:
print(i)
r = range(1, 6)
for i in r:
print(i)
r = range(1, 15, 3)
for i in r:
print(i) |
# --- Day 3: Toboggan Trajectory ---
line_list = [line.rstrip("\n") for line in open("input.txt")]
def slopecheck(hori, vert):
pos = 0
found = 0
i = 0
for line in line_list:
if i % vert == 0:
if line[pos % len(line)] == "#":
found += 1
pos += hori
i += 1
return found
a = slopecheck(1, 1)
b = slope... | line_list = [line.rstrip('\n') for line in open('input.txt')]
def slopecheck(hori, vert):
pos = 0
found = 0
i = 0
for line in line_list:
if i % vert == 0:
if line[pos % len(line)] == '#':
found += 1
pos += hori
i += 1
return found
a = slopeche... |
# kgen_extra.py
kgen_file_header = \
"""
! KGEN-generated Fortran source file
!
! Filename : %s
! Generated at: %s
! KGEN version: %s
"""
kgen_subprograms = \
"""FUNCTION kgen_get_newunit() RESULT(new_unit)
INTEGER, PARAMETER :: UNIT_MIN=100, UNIT_MAX=1000000
LOGICAL :: is_opened
INTEGER :: nunit, new_un... | kgen_file_header = '\n! KGEN-generated Fortran source file\n!\n! Filename : %s\n! Generated at: %s\n! KGEN version: %s\n\n'
kgen_subprograms = 'FUNCTION kgen_get_newunit() RESULT(new_unit)\n INTEGER, PARAMETER :: UNIT_MIN=100, UNIT_MAX=1000000\n LOGICAL :: is_opened\n INTEGER :: nunit, new_unit, counter\n\n ... |
def sum(*n):
total=0
for n1 in n:
total=total+n1
print("the sum=",total)
sum()
sum(10)
sum(10,20)
sum(10,20,30,40) | def sum(*n):
total = 0
for n1 in n:
total = total + n1
print('the sum=', total)
sum()
sum(10)
sum(10, 20)
sum(10, 20, 30, 40) |
"""
Django configurations for the project.
These configurations include:
* settings: Project-wide settings, which may be customized per environment.
* urls: Routes URLs to views (i.e., Python functions).
* wsgi: The default Web Server Gateway Interface.
""" | """
Django configurations for the project.
These configurations include:
* settings: Project-wide settings, which may be customized per environment.
* urls: Routes URLs to views (i.e., Python functions).
* wsgi: The default Web Server Gateway Interface.
""" |
name = 'late_binding'
version = "1.0"
@late()
def tools():
return ["util"]
def commands():
env.PATH.append("{root}/bin")
| name = 'late_binding'
version = '1.0'
@late()
def tools():
return ['util']
def commands():
env.PATH.append('{root}/bin') |
# functions
# i.e., len() where the () designate a function
# functions that are related to str
course = "python programming"
# here we have a kind of function called a "method" which
# comes after a str and designated by a "."
# in Py all everything is an object
# and objects have "functions"
# and "functions" have ... | course = 'python programming'
print(course.upper())
print(course)
print(course.capitalize())
print(course.istitle())
print(course.title())
upper_course = course.upper()
print(upper_course)
lower_course = upper_course.lower()
print(lower_course)
unstriped_course = ' The unstriped Python Course'
print(unstriped_course)... |
#!/usr/bin/python
"""
Fizz Buzz in python 3
P Campbell
February 2018
"""
for i in range(1,101):
if i % 3 == 0 or i % 5 == 0 :
if i % 3 == 0:
msg = "Fizz"
if i % 5 == 0:
msg += "Buzz"
print (msg)
msg = ""
else:
print (i)
| """
Fizz Buzz in python 3
P Campbell
February 2018
"""
for i in range(1, 101):
if i % 3 == 0 or i % 5 == 0:
if i % 3 == 0:
msg = 'Fizz'
if i % 5 == 0:
msg += 'Buzz'
print(msg)
msg = ''
else:
print(i) |
class DirectoryObjectSecurity(ObjectSecurity):
""" Provides the ability to control access to directory objects without direct manipulation of Access Control Lists (ACLs). """
def AccessRuleFactory(self,identityReference,accessMask,isInherited,inheritanceFlags,propagationFlags,type,objectType=None,inheritedObjectTyp... | class Directoryobjectsecurity(ObjectSecurity):
""" Provides the ability to control access to directory objects without direct manipulation of Access Control Lists (ACLs). """
def access_rule_factory(self, identityReference, accessMask, isInherited, inheritanceFlags, propagationFlags, type, objectType=None, inh... |
#this is to make change from dollar bills
change=float(input("Enter an amount to make change for :"))
print("Your change is..")
print(int(change//20), "twenties")
change=change % 20
print(int(change//10), "tens")
change=change % 10
print(int(change//5), "fives")
change=change % 5
print(int(change//1), "ones")
change=ch... | change = float(input('Enter an amount to make change for :'))
print('Your change is..')
print(int(change // 20), 'twenties')
change = change % 20
print(int(change // 10), 'tens')
change = change % 10
print(int(change // 5), 'fives')
change = change % 5
print(int(change // 1), 'ones')
change = change % 1
print(int(chang... |
def calc_fuel(mass):
fuel = int(mass / 3) - 2
return fuel
with open("input.txt") as infile:
fuel_sum = 0
for line in infile:
mass = int(line.strip())
fuel = calc_fuel(mass)
fuel_sum += fuel
print(fuel_sum)
| def calc_fuel(mass):
fuel = int(mass / 3) - 2
return fuel
with open('input.txt') as infile:
fuel_sum = 0
for line in infile:
mass = int(line.strip())
fuel = calc_fuel(mass)
fuel_sum += fuel
print(fuel_sum) |
def main() -> None:
a, b, c = map(int, input().split())
d = [a, b, c]
d.sort()
print("Yes" if d[1] == b else "No")
if __name__ == "__main__":
main()
| def main() -> None:
(a, b, c) = map(int, input().split())
d = [a, b, c]
d.sort()
print('Yes' if d[1] == b else 'No')
if __name__ == '__main__':
main() |
def sums(target):
ans = 0
sumlist=[]
count = 1
for num in range(target):
sumlist.append(count)
count = count + 1
ans = sum(sumlist)
print(ans)
#print(sumlist)
target = int(input(""))
sums(target)
| def sums(target):
ans = 0
sumlist = []
count = 1
for num in range(target):
sumlist.append(count)
count = count + 1
ans = sum(sumlist)
print(ans)
target = int(input(''))
sums(target) |
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# 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 applicab... | class Barcodeerrorcorrection(object):
"""
Const Class
These constants identify the type of Error Correction for a Bar Code.
The Error Correction for a Bar code is a measure that helps a Bar code to recover, if it is destroyed.
Level L (Low) 7% of codewords can be restored. Level M (Medium... |
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_core.ipynb (unless otherwise specified).
__all__ = ['print_hello']
# Cell
def print_hello(to):
"Print hello to the user"
return f"Hello, {to}!" | __all__ = ['print_hello']
def print_hello(to):
"""Print hello to the user"""
return f'Hello, {to}!' |
## @ingroup methods-mission-segments
# expand_state.py
#
# Created: Jul 2014, SUAVE Team
# Modified: Jan 2016, E. Botero
# ----------------------------------------------------------------------
# Expand State
# ----------------------------------------------------------------------
## @ingroup methods-mission-segme... | def expand_state(segment):
"""Makes all vectors in the state the same size.
Assumptions:
N/A
Source:
N/A
Inputs:
state.numerics.number_control_points [Unitless]
Outputs:
N/A
Properties Used:
N/A
"""
n_points = segment.state.numerics.number_control_points
seg... |
'''
Created on Aug 4, 2012
@author: vinnie
'''
class Rotor(object):
def __init__(self, symbols, permutation):
'''
'''
self.states = []
self.inverse_states = []
self.n_symbols = len(symbols)
for i in range(self.n_symbols):
self.states.append({sy... | """
Created on Aug 4, 2012
@author: vinnie
"""
class Rotor(object):
def __init__(self, symbols, permutation):
"""
"""
self.states = []
self.inverse_states = []
self.n_symbols = len(symbols)
for i in range(self.n_symbols):
self.states.append({sy... |
class BasePexelError(Exception):
pass
class EndpointNotExists(BasePexelError):
def __init__(self, end_point, _enum) -> None:
options = _enum.__members__.keys()
self.message = f'Endpoint "{end_point}" not exists. Valid endpoints: {", ".join(options)}'
super().__init__(self.message)
c... | class Basepexelerror(Exception):
pass
class Endpointnotexists(BasePexelError):
def __init__(self, end_point, _enum) -> None:
options = _enum.__members__.keys()
self.message = f'''Endpoint "{end_point}" not exists. Valid endpoints: {', '.join(options)}'''
super().__init__(self.message)
... |
"""Containers for DL CONTROL file MC move type descriptions
Moves are part of the DL CONTROL file input. Each type of
move gets a class here.
The classification of the available Move types is as follows:
Move
MCMove
AtomMove
MoleculeMove
... [others, some of which are untested in regression tests]
Vo... | """Containers for DL CONTROL file MC move type descriptions
Moves are part of the DL CONTROL file input. Each type of
move gets a class here.
The classification of the available Move types is as follows:
Move
MCMove
AtomMove
MoleculeMove
... [others, some of which are untested in regression tests]
Vo... |
#https://www.acmicpc.net/problem/1712
a, b, b2 = map(int, input().split())
if b >= b2:
print(-1)
else:
bx = b2 - b
count = a // bx + 1
print(count) | (a, b, b2) = map(int, input().split())
if b >= b2:
print(-1)
else:
bx = b2 - b
count = a // bx + 1
print(count) |
grade_1 = [9.5,8.5,6.45,21]
grade_1_sum = sum(grade_1)
print(grade_1_sum)
grade_1_len = len(grade_1)
print(grade_1_len)
grade_avg = grade_1_sum/grade_1_len
print(grade_avg)
# create Function
def mean(myList):
the_mean = sum(myList) / len(myList)
return the_mean
print(mean([10,1,1,10]))
def mean_1(value)... | grade_1 = [9.5, 8.5, 6.45, 21]
grade_1_sum = sum(grade_1)
print(grade_1_sum)
grade_1_len = len(grade_1)
print(grade_1_len)
grade_avg = grade_1_sum / grade_1_len
print(grade_avg)
def mean(myList):
the_mean = sum(myList) / len(myList)
return the_mean
print(mean([10, 1, 1, 10]))
def mean_1(value):
if type(va... |
if 0:
pass
if 1:
pass
else:
pass
if 2:
pass
elif 3:
pass
if 4:
pass
elif 5:
pass
else:
1
| if 0:
pass
if 1:
pass
else:
pass
if 2:
pass
elif 3:
pass
if 4:
pass
elif 5:
pass
else:
1 |
print("Halo")
print("This is my program in vscode ")
name = input("what your name : ")
if name == "Hero":
print("Wow your name {} ? , my name is Hero too, nice to meet you ! ".format(name))
else:
print("Halo {} , nice to meet you friend".format(name))
age = input("how old are you : ")
if age == "21":
... | print('Halo')
print('This is my program in vscode ')
name = input('what your name : ')
if name == 'Hero':
print('Wow your name {} ? , my name is Hero too, nice to meet you ! '.format(name))
else:
print('Halo {} , nice to meet you friend'.format(name))
age = input('how old are you : ')
if age == '21':
print(... |
def foo(numbers, path, index, cur_val, target):
if index == len(numbers):
return cur_val, path
# No point in continuation
if cur_val > target:
return -1, ""
sol_1 = foo(numbers, path+"1", index+1, cur_val+numbers[index], target)
# Found the solution. Do not continue.
if sol_1[0] == target:
... | def foo(numbers, path, index, cur_val, target):
if index == len(numbers):
return (cur_val, path)
if cur_val > target:
return (-1, '')
sol_1 = foo(numbers, path + '1', index + 1, cur_val + numbers[index], target)
if sol_1[0] == target:
return sol_1
sol_2 = foo(numbers, path + ... |
# general_sync_utils
# similar to music_sync_utils but more general
class NameEqualityMixin():
def __eq__(self, other):
if isinstance(other, str):
return self.name == other
return self.name == other.name
def __ne__(self, other):
return not self.__eq__(other)
def __ha... | class Nameequalitymixin:
def __eq__(self, other):
if isinstance(other, str):
return self.name == other
return self.name == other.name
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash(self.name)
class Folder(NameEqualityMix... |
LABEL_TRASH = -1
LABEL_NOISE = -2
LABEL_ALIEN = -9
LABEL_UNCLASSIFIED = -10
LABEL_NO_WAVEFORM = -11
to_name = { -1: 'Trash',
-2 : 'Noise',
-9: 'Alien',
-10: 'Unclassified',
-11: 'No waveforms',
}
| label_trash = -1
label_noise = -2
label_alien = -9
label_unclassified = -10
label_no_waveform = -11
to_name = {-1: 'Trash', -2: 'Noise', -9: 'Alien', -10: 'Unclassified', -11: 'No waveforms'} |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( a , b , c ) :
if ( a + b <= c ) or ( a + c <= b ) or ( b + c <= a ) :
return False
else :
r... | def f_gold(a, b, c):
if a + b <= c or a + c <= b or b + c <= a:
return False
else:
return True
if __name__ == '__main__':
param = [(29, 19, 52), (83, 34, 49), (48, 14, 65), (59, 12, 94), (56, 39, 22), (68, 85, 9), (63, 36, 41), (95, 34, 37), (2, 90, 27), (11, 16, 1)]
n_success = 0
fo... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
rd,rm,ry=map(int,input().split())
ed,em,ey=map(int,input().split())
if ry<ey:
print("0")
elif ry<=ey:
if rm<=em:
if rd<=ed:
print("0")
else:
print(15*(rd-ed))
else:
print(500*(rm-em))
else:
... | (rd, rm, ry) = map(int, input().split())
(ed, em, ey) = map(int, input().split())
if ry < ey:
print('0')
elif ry <= ey:
if rm <= em:
if rd <= ed:
print('0')
else:
print(15 * (rd - ed))
else:
print(500 * (rm - em))
else:
print(10000) |
# card.py
# Implements the Card object.
class Card:
"""
A Card of any type.
"""
def __init__(self, title, desc, color, holder, is_equip, use):
self.title = title
self.desc = desc
self.color = color
self.holder = holder
self.is_equipment = is_equip
self.... | class Card:
"""
A Card of any type.
"""
def __init__(self, title, desc, color, holder, is_equip, use):
self.title = title
self.desc = desc
self.color = color
self.holder = holder
self.is_equipment = is_equip
self.use = use
def dump(self):
ret... |
n1 = float(input('Informe a primeira nota do Aluno: '))
n2 = float(input('informe a segunda nota: '))
m = (n1 + n2) / 2
print('Sua media foi de {}'.format(m))
| n1 = float(input('Informe a primeira nota do Aluno: '))
n2 = float(input('informe a segunda nota: '))
m = (n1 + n2) / 2
print('Sua media foi de {}'.format(m)) |
class BaseAnalyzer(object):
def __init__(self, base_node):
self.base_node = base_node
def analyze(self):
raise NotImplementedError() | class Baseanalyzer(object):
def __init__(self, base_node):
self.base_node = base_node
def analyze(self):
raise not_implemented_error() |
class Solution:
def minPathSum(self, grid: List[List[int]]) -> int:
m, n = len(grid), len(grid[0])
dp = grid[0][:]
for i in range(1, n):
dp[i] += dp[i-1]
for i in range(1, m):
for j in range(n):
if j > 0:
dp[j] = grid[i][j] ... | class Solution:
def min_path_sum(self, grid: List[List[int]]) -> int:
(m, n) = (len(grid), len(grid[0]))
dp = grid[0][:]
for i in range(1, n):
dp[i] += dp[i - 1]
for i in range(1, m):
for j in range(n):
if j > 0:
dp[j] = gr... |
"""simd float32vec"""
def get_data():
return [1.9, 1.8, 1.7, 0.6, 0.99,0.88,0.77,0.66]
def main():
## the translator knows this is a float32vec because there are more than 4 elements
x = y = z = w = 22/7
a = numpy.array( [1.1, 1.2, 1.3, 0.4, x,y,z,w], dtype=numpy.float32 )
## in this case the translator is not s... | """simd float32vec"""
def get_data():
return [1.9, 1.8, 1.7, 0.6, 0.99, 0.88, 0.77, 0.66]
def main():
x = y = z = w = 22 / 7
a = numpy.array([1.1, 1.2, 1.3, 0.4, x, y, z, w], dtype=numpy.float32)
u = get_data()
b = numpy.array(u, dtype=numpy.float32)
c = a + b
print(c)
test_error(c[0] ... |
def repetition(a,b):
count=0;
for i in range(len(a)):
if(a[i]==b):
count=count+1
return count
| def repetition(a, b):
count = 0
for i in range(len(a)):
if a[i] == b:
count = count + 1
return count |
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
buf = 0
for xi, yi in zip(x, y):
if xi == yi:
buf += 1
else:
if buf > count:
count = buf
buf = 0
if buf > count:
count = buf
if count >= 3:
print('Yes')... | n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
(x, y) = [list(i) for i in zip(*xy)]
count = 0
buf = 0
for (xi, yi) in zip(x, y):
if xi == yi:
buf += 1
else:
if buf > count:
count = buf
buf = 0
if buf > count:
count = buf
if count >= 3:
print('Yes'... |
"""
Definitions of fixtures used in acceptance mixed tests.
"""
__author__ = "Michal Stanisz"
__copyright__ = "Copyright (C) 2017 ACK CYFRONET AGH"
__license__ = "This software is released under the MIT license cited in " \
"LICENSE.txt"
pytest_plugins = "tests.gui.gui_conf"
| """
Definitions of fixtures used in acceptance mixed tests.
"""
__author__ = 'Michal Stanisz'
__copyright__ = 'Copyright (C) 2017 ACK CYFRONET AGH'
__license__ = 'This software is released under the MIT license cited in LICENSE.txt'
pytest_plugins = 'tests.gui.gui_conf' |
"""
Represents tests defined in the draft_kings.output.schema module.
Most tests center around serializing / deserializing output objects using the marshmallow library
"""
| """
Represents tests defined in the draft_kings.output.schema module.
Most tests center around serializing / deserializing output objects using the marshmallow library
""" |
#
# PySNMP MIB module Sentry4-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Sentry4-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:14:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) ... |
DEBUG = True
ALLOWED_HOSTS = ['*']
SECRET_KEY = 'secret'
SOCIAL_AUTH_TWITTER_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
SOCIAL_AUTH_TWITTER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
SOCIAL_AUTH_ORCID_KEY = ''
SOCIAL_AUTH_ORCID_SECRET = ''
| debug = True
allowed_hosts = ['*']
secret_key = 'secret'
social_auth_twitter_key = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
social_auth_twitter_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
social_auth_orcid_key = ''
social_auth_orcid_secret = '' |
# reverse generator
def reverse(data):
current = len(data)
while current >= 1:
current -= 1
yield data[current]
for c in reverse("string"):
print(c)
for i in reverse([1, 2, 3]):
print(i)
# reverse iterator
class Reverse(object):
def __init__(self, data):
self.data = d... | def reverse(data):
current = len(data)
while current >= 1:
current -= 1
yield data[current]
for c in reverse('string'):
print(c)
for i in reverse([1, 2, 3]):
print(i)
class Reverse(object):
def __init__(self, data):
self.data = data
self.index = len(data)
def _... |
### Model data
class catboost_model(object):
float_features_index = [
0, 1, 2, 4, 5, 6, 8, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 24, 27, 28, 31, 33, 35, 37, 38, 39, 46, 47, 48,
]
float_feature_count = 50
cat_feature_count = 0
binary_feature_count = 29
tree_count = 40
float_feature... | class Catboost_Model(object):
float_features_index = [0, 1, 2, 4, 5, 6, 8, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 24, 27, 28, 31, 33, 35, 37, 38, 39, 46, 47, 48]
float_feature_count = 50
cat_feature_count = 0
binary_feature_count = 29
tree_count = 40
float_feature_borders = [[0.000758085982, 0.... |
# Based on: https://articles.leetcode.com/longest-palindromic-substring-part-ii/
def _process(s):
alt_chars = ['$', '#']
for char in s:
alt_chars.extend([char, '#'])
alt_chars += ['@']
return alt_chars
def _run_manacher(alt_chars):
palin_table = [0] * len(alt_chars)
center, right... | def _process(s):
alt_chars = ['$', '#']
for char in s:
alt_chars.extend([char, '#'])
alt_chars += ['@']
return alt_chars
def _run_manacher(alt_chars):
palin_table = [0] * len(alt_chars)
(center, right) = (0, 0)
for i in range(len(alt_chars) - 1):
opposite = center * 2 - i
... |
def get_majority_element(a, left, right):
a.sort()
if left == right:
return -1
if left + 1 == right:
return a[left]
#write your code here
mid = left + (right-left)//2
k=0
for i in range(len(a)):
if a[i]==a[mid]: k+=1
if k > right/2 : return k
return -1
n =... | def get_majority_element(a, left, right):
a.sort()
if left == right:
return -1
if left + 1 == right:
return a[left]
mid = left + (right - left) // 2
k = 0
for i in range(len(a)):
if a[i] == a[mid]:
k += 1
if k > right / 2:
return k
return -1
n ... |
def main():
points = []
with open("input.txt") as input_file:
for wire in input_file:
wire = [(x[0], int(x[1:])) for x in wire.split(",")]
x, y = 0, 0
cost = 0
points_local = [(x, y, cost)]
for direction, value in wire:
if di... | def main():
points = []
with open('input.txt') as input_file:
for wire in input_file:
wire = [(x[0], int(x[1:])) for x in wire.split(',')]
(x, y) = (0, 0)
cost = 0
points_local = [(x, y, cost)]
for (direction, value) in wire:
if... |
class APIException(Exception):
def __init__(self, message):
super().__init__(message)
self.message = message
class UserException(Exception):
def __init__(self, message):
super().__init__(message)
self.message = message | class Apiexception(Exception):
def __init__(self, message):
super().__init__(message)
self.message = message
class Userexception(Exception):
def __init__(self, message):
super().__init__(message)
self.message = message |
class MyClass(object):
def set_val(self,val):
self.val = val
def get_val(self):
return self.val
a = MyClass()
b = MyClass()
a.set_val(10)
b.set_val(100)
print(a.get_val())
print(b.get_val()) | class Myclass(object):
def set_val(self, val):
self.val = val
def get_val(self):
return self.val
a = my_class()
b = my_class()
a.set_val(10)
b.set_val(100)
print(a.get_val())
print(b.get_val()) |
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/security-key-spaces/problem
# Difficulty: Easy
# Max Score: 10
# Language: Python
# ========================
# Solution
# ========================
num = (input())
e = int(input())
p... | num = input()
e = int(input())
print(''.join([str((int(i) + e) % 10) for i in num])) |
def reverse(S, start, stop):
"""Reverse elements in emplicit slice S[start:stop]."""
if start < stop - 1:
S[start], S[stop-1] = S[stop - 1], S[start]
reverse(S, start+1, stop - 1)
def reverse_iterative(S):
"""Reverse elements in S using tail recursion"""
start,stop = 0,len... | def reverse(S, start, stop):
"""Reverse elements in emplicit slice S[start:stop]."""
if start < stop - 1:
(S[start], S[stop - 1]) = (S[stop - 1], S[start])
reverse(S, start + 1, stop - 1)
def reverse_iterative(S):
"""Reverse elements in S using tail recursion"""
(start, stop) = (0, len(... |
def palindrome_num():
num = int(input("Enter a number:"))
temp = num
rev = 0
while(num>0):
dig = num%10
rev = rev*10+dig
num = num//10
if(temp == rev):
print("The number is palindrome!")
else:
print("Not a palindrome!")
palindrome_num() | def palindrome_num():
num = int(input('Enter a number:'))
temp = num
rev = 0
while num > 0:
dig = num % 10
rev = rev * 10 + dig
num = num // 10
if temp == rev:
print('The number is palindrome!')
else:
print('Not a palindrome!')
palindrome_num() |
# Not necessary. Just wanted to separate program from credentials
def apikey():
return 'apikey'
def stomp_username():
return 'stomp user'
def stomp_password():
return 'stomp pass'
| def apikey():
return 'apikey'
def stomp_username():
return 'stomp user'
def stomp_password():
return 'stomp pass' |
"""
https://leetcode.com/problems/add-strings/
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
Note:
The length of both num1 and num2 is < 5100.
Both num1 and num2 contains only digits 0-9.
Both num1 and num2 does not contain any leading zero.
You must not use any... | """
https://leetcode.com/problems/add-strings/
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
Note:
The length of both num1 and num2 is < 5100.
Both num1 and num2 contains only digits 0-9.
Both num1 and num2 does not contain any leading zero.
You must not use any... |
# Lists always stay in the same order, so you can get
# information out very easily. List indexes act very similar
# to string indexs
intList = [1, 2, 3, 4, 5]
# Get the first item
print(intList[0])
# Get the last item
print(intList[-1])
# Alternatively:
print(intList[len(intList) - 1])
# Get the 2nd to 4th items
... | int_list = [1, 2, 3, 4, 5]
print(intList[0])
print(intList[-1])
print(intList[len(intList) - 1])
print(intList[1:5])
print(intList.index(2)) |
cars = 100
space_in_car = 4
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_car
average_passengers_per_car = passengers / cars_driven
print("Cars: ", cars)
print(drivers)
print(cars_not_driven)
print(carpool_capacity)
print(passengers)
print... | cars = 100
space_in_car = 4
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_car
average_passengers_per_car = passengers / cars_driven
print('Cars: ', cars)
print(drivers)
print(cars_not_driven)
print(carpool_capacity)
print(passengers)
print(... |
class Config(object):
# Measuration Parameters
TOTAL_TICKS = 80
PRECISION = 1
INITIAL_TIMESTAMP = 1
# Acceleration Parameters
MINIMIZE_CHECKING = True
GENERATE_STATE = False
LOGGING_NETWORK = False
# SPEC Parameters
SLOTS_PER_EPOCH = 8
# System Parameters
NUM_VALIDATO... | class Config(object):
total_ticks = 80
precision = 1
initial_timestamp = 1
minimize_checking = True
generate_state = False
logging_network = False
slots_per_epoch = 8
num_validators = 8
latency = 1.5 / PRECISION
reliability = 1.0
num_peers = 10
shard_num_peers = 5
tar... |
_base_ = [
'../_base_/models/mask_rcnn_se_r50_fpn.py',
'../_base_/datasets/coco_instance.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
pretrained='checkpoints/se_resnext101_64x4d-f9926f93.pth',
backbone=dict(block='SEResNeXtBottleneck', layers=[3, 4, 23, 3... | _base_ = ['../_base_/models/mask_rcnn_se_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
model = dict(pretrained='checkpoints/se_resnext101_64x4d-f9926f93.pth', backbone=dict(block='SEResNeXtBottleneck', layers=[3, 4, 23, 3], groups=64)) |
class Solution:
def reverseVowels(self, s: str) -> str:
vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
s = list(s)
left = 0
right = len(s) - 1
while left < right:
if s[left] not in vowels:
left += 1
elif s[right] not in vow... | class Solution:
def reverse_vowels(self, s: str) -> str:
vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
s = list(s)
left = 0
right = len(s) - 1
while left < right:
if s[left] not in vowels:
left += 1
elif s[right] not in v... |
#!/usr/bin/env python3
# https://sites.google.com/site/ev3python/learn_ev3_python/using-sensors/sensor-modes
speedReading=0
# Color Sensor Readings
# COL-REFLECT COL-AMBIENT COL-COLOR RGB-RAW
colorSensor_mode_default = "COL-COLOR"
colorSensor_mode_lt = colorSensor_mode_default
colorSensor_mode_rt = colorSensor_mo... | speed_reading = 0
color_sensor_mode_default = 'COL-COLOR'
color_sensor_mode_lt = colorSensor_mode_default
color_sensor_mode_rt = colorSensor_mode_default
color_sensor_reflect_lt = 0
color_sensor_reflect_rt = 0
color_sensor_color_lt = 0
color_sensor_color_rt = 0
color_sensor_rawred_lt = 0
color_sensor_rawgreen_lt = 0
co... |
"""Message types to register."""
PROTOCOL_URI = "https://didcomm.org/issue-credential/1.1"
PROTOCOL_PACKAGE = "aries_cloudagent.protocols.issue_credential.v1_1"
CREDENTIAL_ISSUE = f"{PROTOCOL_URI}/issue-credential"
CREDENTIAL_REQUEST = f"{PROTOCOL_URI}/request-credential"
MESSAGE_TYPES = {
CREDENTIAL_ISSUE: (f"{... | """Message types to register."""
protocol_uri = 'https://didcomm.org/issue-credential/1.1'
protocol_package = 'aries_cloudagent.protocols.issue_credential.v1_1'
credential_issue = f'{PROTOCOL_URI}/issue-credential'
credential_request = f'{PROTOCOL_URI}/request-credential'
message_types = {CREDENTIAL_ISSUE: f'{PROTOCOL_... |
class Player:
def getTime(self):
pass
def playWavFile(self, file):
pass
def wavWasPlayed(self):
pass
def resetWav(self):
pass | class Player:
def get_time(self):
pass
def play_wav_file(self, file):
pass
def wav_was_played(self):
pass
def reset_wav(self):
pass |
def countSetBits(num):
binary = bin(num)
setBits = [ones for ones in binary[2:] if ones == '1']
return len(setBits)
if __name__ == "__main__":
n = int(input())
for i in range(n+1):
print(countSetBits(i), end =' ')
| def count_set_bits(num):
binary = bin(num)
set_bits = [ones for ones in binary[2:] if ones == '1']
return len(setBits)
if __name__ == '__main__':
n = int(input())
for i in range(n + 1):
print(count_set_bits(i), end=' ') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.