content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | def capital_checker(dicti):
correct_ans = {'New York': 'Albany', 'California': 'Sacramento', 'New Mexico': 'Santa Fe', 'Florida': 'Tallahassee', 'Michigan': 'Lansing'}
return_dict = {}
for (keys, values) in dicti.items():
if values.lower() != correct_ans[keys].lower():
return_dict[keys] ... |
TEST_OCF_ACCOUNTS = (
'sanjay', # an old, sorried account with kerberos princ
'alec', # an old, sorried account with no kerberos princ
'guser', # an account specifically made for testing
'nonexist', # this account does not exist
)
TESTER_CALNET_UIDS = (
872544, # daradib
1034192, # ckueh... | test_ocf_accounts = ('sanjay', 'alec', 'guser', 'nonexist')
tester_calnet_uids = (872544, 1034192, 869331, 1031366, 1099131, 1101587, 1511731, 1623751, 1619256)
test_group_accounts = ((91740, 'The Testing Group'), (46187, 'Open Computing Facility'), (46692, 'Awesome Group of Awesome'), (92029, 'eXperimental Computing F... |
class NotFoundError(Exception):
def __init__(self, url):
super().__init__(url)
self.type = "notfound"
class NoTitleError(Exception):
def __init__(self, url):
super().__init__(url)
self.type = "notitle"
class ErrorPageError(Exception):
def __init__(self, url):
supe... | class Notfounderror(Exception):
def __init__(self, url):
super().__init__(url)
self.type = 'notfound'
class Notitleerror(Exception):
def __init__(self, url):
super().__init__(url)
self.type = 'notitle'
class Errorpageerror(Exception):
def __init__(self, url):
sup... |
init_info = input().split(" ")
sapce_width = int(init_info[0])
space_length = int(init_info[1])
space_gun = int(init_info[2])
gun_x = []
gun_y = []
for each_input in range(space_gun):
init_gun = input().split()
gun_x.append(int(init_gun[0]))
gun_y.append(int(init_gun[1]))
new_width = sapce_width -... | init_info = input().split(' ')
sapce_width = int(init_info[0])
space_length = int(init_info[1])
space_gun = int(init_info[2])
gun_x = []
gun_y = []
for each_input in range(space_gun):
init_gun = input().split()
gun_x.append(int(init_gun[0]))
gun_y.append(int(init_gun[1]))
new_width = sapce_width - len(set(g... |
# Create a calculator function
# The function should accept three parameters:
# first_number: a numeric value for the math operation
# second_number: a numeric value for the math operation
# operation: the word 'add' or 'subtract'
# the function should return the result of the two numbers added or subtracted
# based on... | def calcutate(first, second, operation):
if operation.lower() == 'add':
result = first + second
elif operation.lower() == 'substract':
result = first - second
else:
result = 'Operation, not supported'
return result
first = float(input('Enter first number: '))
second = float(input... |
'''
We can pass multiple arguments to the .order_by() method to order by multiple columns. In fact, we can also sort in ascending or descending order for each individual column. Each column in the .order_by() method is fully sorted from left to right. This means that the first column is completely sorted, and then with... | """
We can pass multiple arguments to the .order_by() method to order by multiple columns. In fact, we can also sort in ascending or descending order for each individual column. Each column in the .order_by() method is fully sorted from left to right. This means that the first column is completely sorted, and then with... |
#!/usr/bin/env python3
####################################################################################
# #
# Program purpose: Finds the difference between the largest and the smallest #
# integer which a... | def read_data(mess: str):
valid = False
data = 0
while not valid:
try:
temp_data = list(input(mess).strip())
if len(temp_data) != 8:
raise value_error('Number must be 8-digit long')
else:
for x in range(len(temp_data)):
... |
class AuthenticationError(Exception):
pass
class MarketClosedError(Exception):
pass
class MarketEmptyError(Exception):
pass
| class Authenticationerror(Exception):
pass
class Marketclosederror(Exception):
pass
class Marketemptyerror(Exception):
pass |
# coding=utf-8
# @Time : 2021/3/26 10:34
# @Auto : zzf-jeff
class GlobalSetting():
label_path = './coco.names'
model_path = './weights/yolov5x-simpler.engine'
# model_path = './weights/yolov5s.pt'
output_path = './output'
img_path = './test_imgs'
conf_thresh = 0.3
iou... | class Globalsetting:
label_path = './coco.names'
model_path = './weights/yolov5x-simpler.engine'
output_path = './output'
img_path = './test_imgs'
conf_thresh = 0.3
iou_thresh = 0.45
anchors = [[[10, 13], [16, 30], [33, 23]], [[30, 61], [62, 45], [59, 119]], [[116, 90], [156, 198], [373, 326... |
def test_trading_fee(position):
entry_price = 100000000000000000000 # 100
current_price = 150000000000000000000 # 150
notional = 10000000000000000000 # 10
debt = 2000000000000000000 # 2
liquidated = False
trading_fee_rate = 750000000000000
oi = int((notional / entry_price) * 10000000000... | def test_trading_fee(position):
entry_price = 100000000000000000000
current_price = 150000000000000000000
notional = 10000000000000000000
debt = 2000000000000000000
liquidated = False
trading_fee_rate = 750000000000000
oi = int(notional / entry_price * 1000000000000000000)
fraction = 100... |
# 9th Solutions
#--------------------------
n = int(input())
d = {}
for i in range(n):
x = input().split()
d[x[0]] = x[1]
while True:
try:
name = input()
if name in d:
print(name, '=', d[name], sep='')
else:
print('Not found')
except:
break
| n = int(input())
d = {}
for i in range(n):
x = input().split()
d[x[0]] = x[1]
while True:
try:
name = input()
if name in d:
print(name, '=', d[name], sep='')
else:
print('Not found')
except:
break |
def define_targets(rules):
rules.cc_test(
name = "test",
srcs = ["impl/CUDATest.cpp"],
deps = [
"@com_google_googletest//:gtest_main",
"//c10/cuda",
],
target_compatible_with = rules.requires_cuda_enabled(),
)
| def define_targets(rules):
rules.cc_test(name='test', srcs=['impl/CUDATest.cpp'], deps=['@com_google_googletest//:gtest_main', '//c10/cuda'], target_compatible_with=rules.requires_cuda_enabled()) |
def vogal(c):
if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'A' or c == 'E' or c == 'I' or c == 'O' or c == 'U':
return True
else:
return False | def vogal(c):
if c == 'a' or c == 'e' or c == 'i' or (c == 'o') or (c == 'u') or (c == 'A') or (c == 'E') or (c == 'I') or (c == 'O') or (c == 'U'):
return True
else:
return False |
# Copyright 2021 Variscite LTD
# SPDX-License-Identifier: BSD-3-Clause
__version__ = "1.0.0"
| __version__ = '1.0.0' |
# dfs
def walk_parents(vertex):
return sum(
(walk_parents(parent) for parent in vertex.parents),
[]
) + [vertex]
def walk_children(vertex):
return sum(
(walk_children(child) for child in vertex.children),
[]
) + [vertex]
| def walk_parents(vertex):
return sum((walk_parents(parent) for parent in vertex.parents), []) + [vertex]
def walk_children(vertex):
return sum((walk_children(child) for child in vertex.children), []) + [vertex] |
# list1 = [i for i in range(5, 16)]
# print(list1)
# list1 = [i for i in range(0, 11)]
# for i in range(11):
# if i > 0:
# print(list1[i-1] * list1[i])
# list1 = [i * j for i in range(1, 10) for j in range(1, 10)]
# print(list1)
str1 = str(input())
strArray = list(str1)
newList = []
for i in strArray:
... | str1 = str(input())
str_array = list(str1)
new_list = []
for i in strArray:
if i > 'e':
del i
else:
newList.append(i)
print(*newList) |
# Flask settings
DEBUG = False
# Flask-restplus settings
RESTPLUS_MASK_SWAGGER = False
SWAGGER_UI_DOC_EXPANSION = 'none'
# Application settings
# API metadata
API_TITLE = 'MAX Image Colorizer'
API_DESC = 'Adds color to black and white images.'
API_VERSION = '1.1.0'
ERR_MSG = 'Invalid file type/extension. Please pro... | debug = False
restplus_mask_swagger = False
swagger_ui_doc_expansion = 'none'
api_title = 'MAX Image Colorizer'
api_desc = 'Adds color to black and white images.'
api_version = '1.1.0'
err_msg = 'Invalid file type/extension. Please provide a valid image (supported formats: JPEG, PNG).'
model_name = API_TITLE
model_id =... |
minx = 20
maxx = 30
miny = -10
maxy = -5
minx = 25
maxx = 67
miny = -260
maxy = -200
def simulate(vx, vy):
x = 0
y = 0
highest = 0
while y > miny:
x += vx
y += vy
if vx > 0:
vx -= 1
elif vx < 0:
vx += 1
vy -= 1
if vy == 0:
... | minx = 20
maxx = 30
miny = -10
maxy = -5
minx = 25
maxx = 67
miny = -260
maxy = -200
def simulate(vx, vy):
x = 0
y = 0
highest = 0
while y > miny:
x += vx
y += vy
if vx > 0:
vx -= 1
elif vx < 0:
vx += 1
vy -= 1
if vy == 0:
... |
def file_to_list(filename):
lines = []
fin = open(filename, "rt", encoding="utf-8")
lines = fin.readlines()
fin.close()
return lines
def print_table(lines):
template = {
"1": "+" + "-" * 11 + "+" + "-" * 11 + "+" + "-" * 8 + "+",
"2": "| {:<10.9}| {:<10.9}| {:<7.6}|",
}
... | def file_to_list(filename):
lines = []
fin = open(filename, 'rt', encoding='utf-8')
lines = fin.readlines()
fin.close()
return lines
def print_table(lines):
template = {'1': '+' + '-' * 11 + '+' + '-' * 11 + '+' + '-' * 8 + '+', '2': '| {:<10.9}| {:<10.9}| {:<7.6}|'}
print(template['1'])
... |
a = int(input())
b = int(input())
c = int(input())
a_odd = a % 2
b_odd = b % 2
c_odd = c % 2
a_even = not (a % 2)
b_even = not (b % 2)
c_even = not (c % 2)
if (a_odd or b_odd or c_odd) and (a_even or b_even or c_even):
print("YES")
else:
print("NO")
| a = int(input())
b = int(input())
c = int(input())
a_odd = a % 2
b_odd = b % 2
c_odd = c % 2
a_even = not a % 2
b_even = not b % 2
c_even = not c % 2
if (a_odd or b_odd or c_odd) and (a_even or b_even or c_even):
print('YES')
else:
print('NO') |
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def closestValue(self, root: TreeNode, target: float) -> int:
if root == None:
return float('inf')
diff = target - root.val
if diff > 0:
... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def closest_value(self, root: TreeNode, target: float) -> int:
if root == None:
return float('inf')
diff = target - root.val
if diff > 0:
... |
command = '/opt/django/smegurus-django/env/bin/gunicorn'
pythonpath = '/opt/django/smegurus-django/smegurus'
bind = '127.0.0.1:8001'
workers = 3
| command = '/opt/django/smegurus-django/env/bin/gunicorn'
pythonpath = '/opt/django/smegurus-django/smegurus'
bind = '127.0.0.1:8001'
workers = 3 |
language_compiler_param = \
{
"java": "-encoding UTF-8 -d -cp ."
}
| language_compiler_param = {'java': '-encoding UTF-8 -d -cp .'} |
aTuple = ("Orange", [10, 20, 30], (5, 15, 25))
print(aTuple[1][1])
| a_tuple = ('Orange', [10, 20, 30], (5, 15, 25))
print(aTuple[1][1]) |
__all__ = [
"sorter",
"ioputter",
"handler",
"timer",
"simple",
"process",
"HarnessChartProcessing",
"KomaxTaskProcessing",
"KomaxCore",
"HarnessProcessing"
] | __all__ = ['sorter', 'ioputter', 'handler', 'timer', 'simple', 'process', 'HarnessChartProcessing', 'KomaxTaskProcessing', 'KomaxCore', 'HarnessProcessing'] |
_base_ = "base.py"
fold = 1
percent = 1
data = dict(
samples_per_gpu=1,
workers_per_gpu=1,
train=dict(
ann_file="data/coco/annotations/semi_supervised/instances_train2017.${fold}@${percent}.json",
img_prefix="data/coco/train2017/",
),
)
work_dir = "work_dirs/${cfg_name}/${percent}/${fold... | _base_ = 'base.py'
fold = 1
percent = 1
data = dict(samples_per_gpu=1, workers_per_gpu=1, train=dict(ann_file='data/coco/annotations/semi_supervised/instances_train2017.${fold}@${percent}.json', img_prefix='data/coco/train2017/'))
work_dir = 'work_dirs/${cfg_name}/${percent}/${fold}'
log_config = dict(interval=50, hook... |
class GumballMonitor:
def __init__(self, machine):
self.machine = machine
def report(self):
try:
print(f'Gumball Machine: {self.machine.get_location()}')
print(f'Current inventory: {self.machine.get_count()} gumballs')
except Exception as e:
print(e)
| class Gumballmonitor:
def __init__(self, machine):
self.machine = machine
def report(self):
try:
print(f'Gumball Machine: {self.machine.get_location()}')
print(f'Current inventory: {self.machine.get_count()} gumballs')
except Exception as e:
print(e) |
################### Error URLs #####################
# For imageGen.py
not_enough_info = 'http://i.imgur.com/2BZk32a.jpg'
improperly_formatted_tag = 'http://i.imgur.com/HvFX82m.jpg'
# For memeAPI.py
meme_not_supported = 'http://i.imgur.com/6VoMZqm.jpg'
couldnt_create_meme = 'http://i.imgur.com/bkW1HEV.jpg'
too_many_li... | not_enough_info = 'http://i.imgur.com/2BZk32a.jpg'
improperly_formatted_tag = 'http://i.imgur.com/HvFX82m.jpg'
meme_not_supported = 'http://i.imgur.com/6VoMZqm.jpg'
couldnt_create_meme = 'http://i.imgur.com/bkW1HEV.jpg'
too_many_lines = 'http://i.imgur.com/fGkrbGe.jpg'
too_few_lines = 'http://i.imgur.com/aLYiN7V.jpg'
n... |
#
# PySNMP MIB module CENTILLION-FILTERS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CENTILLION-FILTERS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:47:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint) ... |
def ask_user_for_weeknum():
weeknum = 0
while weeknum not in range(1,23):
try:
weeknum = int(input('Please enter the number of the week that we\'re in:'))
if weeknum in range(1,23):
break
else:
print('You did not enter a valid week number')
#weeknum = int(input('... | def ask_user_for_weeknum():
weeknum = 0
while weeknum not in range(1, 23):
try:
weeknum = int(input("Please enter the number of the week that we're in:"))
if weeknum in range(1, 23):
break
else:
print('You did not enter a valid week num... |
message = input()
new_message = ''
index = 0
current_text = ''
multiplier = ''
while index < len(message):
if message[index].isdigit():
multiplier += message[index]
if index+1 < len(message):
if message[index+1].isdigit():
multiplier += message[index+1]
... | message = input()
new_message = ''
index = 0
current_text = ''
multiplier = ''
while index < len(message):
if message[index].isdigit():
multiplier += message[index]
if index + 1 < len(message):
if message[index + 1].isdigit():
multiplier += message[index + 1]
... |
load("//:import_external.bzl", import_external = "safe_wix_scala_maven_import_external")
def dependencies():
import_external(
name = "org_mongodb_mongodb_driver_reactivestreams",
artifact = "org.mongodb:mongodb-driver-reactivestreams:1.11.0",
jar_sha256 = "ae3d5eb3c51a0c286f43fe7ab0c52e3e0b385766f... | load('//:import_external.bzl', import_external='safe_wix_scala_maven_import_external')
def dependencies():
import_external(name='org_mongodb_mongodb_driver_reactivestreams', artifact='org.mongodb:mongodb-driver-reactivestreams:1.11.0', jar_sha256='ae3d5eb3c51a0c286f43fe7ab0c52e3e0b385766f1b4dd82e06df1e617770764', ... |
def delete_date_symbols(date,dateFormat):
if(dateFormat == 'YYYY-MM-DD HH:MM:SS'):
year = date[0:4]
month = date[5:7]
day = date[8:10]
hours = date[11:13]
minutes = date[14:16]
seconds = date[17:19]
formattedDate=year+month+day+hours+minutes+seconds
re... | def delete_date_symbols(date, dateFormat):
if dateFormat == 'YYYY-MM-DD HH:MM:SS':
year = date[0:4]
month = date[5:7]
day = date[8:10]
hours = date[11:13]
minutes = date[14:16]
seconds = date[17:19]
formatted_date = year + month + day + hours + minutes + secon... |
class Solution:
def countAndSay(self, n: int) -> str:
if n == 1:
return "1"
prev = "1"
for i in range(1, n):
res = ""
val = prev[0]
count = 1
for i in range(1, len(prev)):
if prev[i] == val:
count... | class Solution:
def count_and_say(self, n: int) -> str:
if n == 1:
return '1'
prev = '1'
for i in range(1, n):
res = ''
val = prev[0]
count = 1
for i in range(1, len(prev)):
if prev[i] == val:
co... |
#
# @lc app=leetcode id=771 lang=python3
#
# [771] Jewels and Stones
#
# @lc code=start
class Solution:
def numJewelsInStones(self, J: str, S: str) -> int:
jewels = set(J)
number_jewels = 0
for char in S:
if char in jewels:
number_jewels += 1
return num... | class Solution:
def num_jewels_in_stones(self, J: str, S: str) -> int:
jewels = set(J)
number_jewels = 0
for char in S:
if char in jewels:
number_jewels += 1
return number_jewels |
#Odd numbers
for number in range(1,21,2):
print(number)
| for number in range(1, 21, 2):
print(number) |
# Copyright (C) 2019 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | def _noop_override(**kwargs):
pass
perfetto_config = struct(root='//', deps=struct(build_config=['//:build_config_hdr'], zlib=['@perfetto_dep_zlib//:zlib'], jsoncpp=['@perfetto_dep_jsoncpp//:jsoncpp'], linenoise=['@perfetto_dep_linenoise//:linenoise'], sqlite=['@perfetto_dep_sqlite//:sqlite'], sqlite_ext_percentile... |
load("@npm//@bazel/typescript:index.bzl", "ts_library")
def ng_ts_library(**kwargs):
ts_library(
compiler = "//libraries/angular-tools:tsc_wrapped_with_angular",
supports_workers = True,
use_angular_plugin = True,
**kwargs
)
| load('@npm//@bazel/typescript:index.bzl', 'ts_library')
def ng_ts_library(**kwargs):
ts_library(compiler='//libraries/angular-tools:tsc_wrapped_with_angular', supports_workers=True, use_angular_plugin=True, **kwargs) |
def comb(n, k):
if n - k < k:
k = n - k
if k == 0:
return 1
a = 1
b = 1
for i in range(k):
a *= n - i
b *= i + 1
return a // b
N, P = map(int, input().split())
A = list(map(int, input().split()))
odds = sum(a % 2 for a in A)
evens = len(A) - odds
print(sum(com... | def comb(n, k):
if n - k < k:
k = n - k
if k == 0:
return 1
a = 1
b = 1
for i in range(k):
a *= n - i
b *= i + 1
return a // b
(n, p) = map(int, input().split())
a = list(map(int, input().split()))
odds = sum((a % 2 for a in A))
evens = len(A) - odds
print(sum((co... |
class Solution:
def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]:
if k == 0: return []
win = sorted(nums[:k])
ans = []
for i in range(k, len(nums) + 1):
median = (win[k // 2] + win[(k - 1) // 2]) / 2.0
ans.append(median)
if i =... | class Solution:
def median_sliding_window(self, nums: List[int], k: int) -> List[float]:
if k == 0:
return []
win = sorted(nums[:k])
ans = []
for i in range(k, len(nums) + 1):
median = (win[k // 2] + win[(k - 1) // 2]) / 2.0
ans.append(median)
... |
# https://codeforces.com/problemset/problem/230/A
s, n = [int(x) for x in input().split()]
dragons = []
new_dragons = []
for _ in range(n):
x, y = [int(x) for x in input().split()]
dragons.append([x, y])
dragons.sort()
for row in range(n - 1):
current_row = dragons[row]
next_row = dragons[row + 1]
... | (s, n) = [int(x) for x in input().split()]
dragons = []
new_dragons = []
for _ in range(n):
(x, y) = [int(x) for x in input().split()]
dragons.append([x, y])
dragons.sort()
for row in range(n - 1):
current_row = dragons[row]
next_row = dragons[row + 1]
if current_row[0] == next_row[0]:
if cu... |
#
# PySNMP MIB module NMS-EPON-ONU-RESET (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-EPON-ONU-RESET
# Produced by pysmi-0.3.4 at Mon Apr 29 20:12:13 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ... |
def centuryFromYear(year):
remainer = year % 100
if remainer == 0:
return year/100
else:
return int(year/100)+1
| def century_from_year(year):
remainer = year % 100
if remainer == 0:
return year / 100
else:
return int(year / 100) + 1 |
#Christine Logan
#9/10/2017
#CS 3240
#Lab 3: Pre-lab
#hello.py
def greeting(msg):
print(msg)
def salutation(msg):
print(msg)
if __name__ == "__main__":
greeting("hello")
salutation("goodbye")
| def greeting(msg):
print(msg)
def salutation(msg):
print(msg)
if __name__ == '__main__':
greeting('hello')
salutation('goodbye') |
# TODO: to be deleted
class FieldMock:
def __init__(self):
self.find = lambda _: FieldMock()
self.skip = lambda _: FieldMock()
self.limit = lambda _: FieldMock()
class BeaconMock:
def __init__(self):
self.datasets = FieldMock()
class DBMock:
def __init__(self):
self... | class Fieldmock:
def __init__(self):
self.find = lambda _: field_mock()
self.skip = lambda _: field_mock()
self.limit = lambda _: field_mock()
class Beaconmock:
def __init__(self):
self.datasets = field_mock()
class Dbmock:
def __init__(self):
self.beacon = beaco... |
class SecurityKeyError(Exception):
def __init__(self, message):
super().__init__(message)
class ListenError(Exception):
def __init__(self, message):
super().__init__(message)
class ChildError(Exception):
def __init__(self, message):
super().__init__(message)
| class Securitykeyerror(Exception):
def __init__(self, message):
super().__init__(message)
class Listenerror(Exception):
def __init__(self, message):
super().__init__(message)
class Childerror(Exception):
def __init__(self, message):
super().__init__(message) |
def main():
single_digit = 36
teens = 70
second_digit = 46
hundred = 7
nd = 3
thousand = 11
a = single_digit * (10 * 19)
a += second_digit * 10 * 10
a += teens * 10
a += hundred * 900
a += nd * 891
a += thousand
print(a)
main()
| def main():
single_digit = 36
teens = 70
second_digit = 46
hundred = 7
nd = 3
thousand = 11
a = single_digit * (10 * 19)
a += second_digit * 10 * 10
a += teens * 10
a += hundred * 900
a += nd * 891
a += thousand
print(a)
main() |
class CreditCard:
def __init__(self, cc_number, expiration, security_code):
self.cc_number = cc_number
self.expiration = expiration
self.security_code = security_code
class Charge:
def __init__(self, success, error=''):
self.success = success
self.error = error
| class Creditcard:
def __init__(self, cc_number, expiration, security_code):
self.cc_number = cc_number
self.expiration = expiration
self.security_code = security_code
class Charge:
def __init__(self, success, error=''):
self.success = success
self.error = error |
{
'targets': [
{
'target_name': 'xxhash',
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7',
},
'msvs_settings': {
... | {'targets': [{'target_name': 'xxhash', 'cflags!': ['-fno-exceptions'], 'cflags_cc!': ['-fno-exceptions'], 'xcode_settings': {'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.7'}, 'msvs_settings': {'VCCLCompilerTool': {'ExceptionHandling': 1}}, 'sources': ['lib/binding/x... |
class Solution:
def canCross(self, stones):
memo, stones, target = {}, set(stones), stones[-1]
def dfs(unit, last):
if unit == target: return True
if (unit, last) not in memo:
memo[(unit, last)] = any(dfs(unit + move, move) for move in (last - 1, last, last +... | class Solution:
def can_cross(self, stones):
(memo, stones, target) = ({}, set(stones), stones[-1])
def dfs(unit, last):
if unit == target:
return True
if (unit, last) not in memo:
memo[unit, last] = any((dfs(unit + move, move) for move in (l... |
path2file = sys.argv[1]
file = open(path2file, 'r')
while True:
line = file.readline()
if not line:
break
stroka = unicode(line, 'utf-8')
type('f', KeyModifier.CTRL)
sleep(1)
paste(stroka)
sleep(1)
type(Key.ENTER)
sleep(1)
break
exit(0)
| path2file = sys.argv[1]
file = open(path2file, 'r')
while True:
line = file.readline()
if not line:
break
stroka = unicode(line, 'utf-8')
type('f', KeyModifier.CTRL)
sleep(1)
paste(stroka)
sleep(1)
type(Key.ENTER)
sleep(1)
break
exit(0) |
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
longestSubstring = 0
start = -1
end = 0
characterSet = set()
stringLength = len(s)
while start < stringLength and end < stringLength:
currentChar = s[end]
if currentChar in char... | class Solution:
def length_of_longest_substring(self, s: str) -> int:
longest_substring = 0
start = -1
end = 0
character_set = set()
string_length = len(s)
while start < stringLength and end < stringLength:
current_char = s[end]
if currentChar... |
def Swap(a,b):
temp = a
a=b
b=temp
lst = [a,b]
return lst | def swap(a, b):
temp = a
a = b
b = temp
lst = [a, b]
return lst |
# 5
# 5 3
# 1 5 2 6 1
# 1 6
# 6
# 3 2
# 1 2 3
# 4 3
# 3 1 2 3
# 10 3
# 1 2 3 4 5 6 7 8 9 10
i = int(input())
l = []
for j in range(i):
k = list(map(int,(input().split(' '))))
il = list(map(int,input().split(' ')))
if k[1] in il and len(il)==1:
l.append('yes')
elif k[1] in il[1:] and len(il) %... | i = int(input())
l = []
for j in range(i):
k = list(map(int, input().split(' ')))
il = list(map(int, input().split(' ')))
if k[1] in il and len(il) == 1:
l.append('yes')
elif k[1] in il[1:] and len(il) % 2 == 1:
l.append('yes')
elif k[1] in il[1:-1] and len(il) % 2 == 0:
l.ap... |
class Solution:
def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
now = points[0]
ans = 0
for point in points[1:]:
ans += max(abs(now[0] - point[0]), abs(now[1] - point[1]))
now = point
return ans
| class Solution:
def min_time_to_visit_all_points(self, points: List[List[int]]) -> int:
now = points[0]
ans = 0
for point in points[1:]:
ans += max(abs(now[0] - point[0]), abs(now[1] - point[1]))
now = point
return ans |
# Write a Python class which has two methods get_String and print_String....
# get_String accept a string from the user and print_String print the string in upper case.
class IOString():
def __init__(self):
self.str1 = ""
def get_String(self):
self.str1 = input()
def print_String(self):
... | class Iostring:
def __init__(self):
self.str1 = ''
def get__string(self):
self.str1 = input()
def print__string(self):
print(self.str1.upper())
str1 = io_string()
str1.get_String()
str1.print_String() |
#####################
### Base classes. ###
#####################
class room:
repr = "room"
m_description = "You are in a simple room."
def __init__(self, contents=[]):
self.contents = contents
def __str__(self):
s = ""
for object in self.contents:
... | class Room:
repr = 'room'
m_description = 'You are in a simple room.'
def __init__(self, contents=[]):
self.contents = contents
def __str__(self):
s = ''
for object in self.contents:
s += ' ' + str(object)
return self.m_description + s
def __repr__(self... |
# Source
# ======
# https://www.hackerrank.com/contests/projecteuler/challenges/euler008
#
# Problem
# =======
# Find the greatest product of K consecutive digits in the N digit number.
#
# Input Format
# ============
# First line contains T that denotes the number of test cases.
# First line of each test case will co... | def product(num_subset):
p = 1
for i in num_subset:
p *= i
return p
t = int(input().strip())
for _ in range(t):
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
num = input().strip()
p = []
for i in range(n - k):
num_subset = [int(x) for x in list(num[i:k + i... |
# __version__ is for deploying with seed.
# VERSION is to keep the rest of the app DRY.
__version__ = '0.1.18'
VERSION = __version__
| __version__ = '0.1.18'
version = __version__ |
class Vehicle(object):
def __init__(self, vehicle_id, company, location):
self.vehicle_id = vehicle_id
self.company = company
self.location = location
# def __str__(self):
# return str( P["id":+str(self.id) + " company: " + str(self.company)+
# str(self.location)+ " loca... | class Vehicle(object):
def __init__(self, vehicle_id, company, location):
self.vehicle_id = vehicle_id
self.company = company
self.location = location |
'''
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?
'''
def largest_prime_factor(n):
f = 2
while f**2 <= n:
while n % f == 0:
n //= f
f += 1
return max(f-1, n)
print(largest_prime_factor(600851475143)) | """
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?
"""
def largest_prime_factor(n):
f = 2
while f ** 2 <= n:
while n % f == 0:
n //= f
f += 1
return max(f - 1, n)
print(largest_prime_factor(600851475143)) |
def selectionSort(alist):
for fillslot in range (len(alist)-1, 0, -1):
positionofMax = 0;
for location in range(1,fillslot+1):
if alist[location] > alist[positionofMax]:
positionofMax = location
temp = alist[fillslot]
alist[fillslot] = alist[positionofMax]
alist[positionofMax] = temp
a = [54,26,93,1... | def selection_sort(alist):
for fillslot in range(len(alist) - 1, 0, -1):
positionof_max = 0
for location in range(1, fillslot + 1):
if alist[location] > alist[positionofMax]:
positionof_max = location
temp = alist[fillslot]
alist[fillslot] = alist[position... |
#!/usr/bin/env python
a = 1000000000
for i in xrange(1000000):
a += 1e-6
a -= 1000000000
print(a)
| a = 1000000000
for i in xrange(1000000):
a += 1e-06
a -= 1000000000
print(a) |
class EnviadorDeSpam():
def __init__(self, sessao, enviador):
self.sessao = sessao
self.enviador = enviador
def enviar_emails(self, remetente, assunto, corpo):
for usuario in self.sessao.listar():
self.enviador.enviar(
remetente,
usuario.email... | class Enviadordespam:
def __init__(self, sessao, enviador):
self.sessao = sessao
self.enviador = enviador
def enviar_emails(self, remetente, assunto, corpo):
for usuario in self.sessao.listar():
self.enviador.enviar(remetente, usuario.email, assunto, corpo) |
class DDAE_Hyperparams:
drop_rate = 0.5
n_units = 1024
activation = 'lrelu'
final_act = 'linear'
f_bin = 257
class CBHG_Hyperparams:
#### Modules ####
drop_rate = 0.0
normalization_mode = 'layer_norm'
activation = 'lrelu'
final_act = 'linear'
f_bin = 257
##... | class Ddae_Hyperparams:
drop_rate = 0.5
n_units = 1024
activation = 'lrelu'
final_act = 'linear'
f_bin = 257
class Cbhg_Hyperparams:
drop_rate = 0.0
normalization_mode = 'layer_norm'
activation = 'lrelu'
final_act = 'linear'
f_bin = 257
banks_filter = 64
n_banks = 8
... |
SIZE_BOARD = 10
# Tipo de navios na forma "tipo": tamanho
TYPES_OF_SHIPS = {
"1": 5,
"2": 4,
"3": 3,
"4": 2
} | size_board = 10
types_of_ships = {'1': 5, '2': 4, '3': 3, '4': 2} |
x = input("input a letter : ")
if x == "a" or x == "i" or x == "u" or x == "e" or x == "o":
print("This is a vowel!")
elif x == "y":
print("Sometimes y is a vowel and sometimes y is a consonant")
else:
print("This is a consonant!")
| x = input('input a letter : ')
if x == 'a' or x == 'i' or x == 'u' or (x == 'e') or (x == 'o'):
print('This is a vowel!')
elif x == 'y':
print('Sometimes y is a vowel and sometimes y is a consonant')
else:
print('This is a consonant!') |
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
max_count = 0
count = 0
for i in nums:
if i == 1:
count += 1
else:
count = 0
max_count = max(max_count, count)
return max_count
| class Solution:
def find_max_consecutive_ones(self, nums: List[int]) -> int:
max_count = 0
count = 0
for i in nums:
if i == 1:
count += 1
else:
count = 0
max_count = max(max_count, count)
return max_count |
# This file declares all the constants for used in this app
MAIN_URL = 'https://api.github.com/repos/'
ONE_DAY = 1
| main_url = 'https://api.github.com/repos/'
one_day = 1 |
# The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
# def guess(num: int) -> int:
class Solution:
def guessNumber(self, n: int) -> int:
l, h = 1, n
while l <= h:
m = l + (h - l) // 2
... | class Solution:
def guess_number(self, n: int) -> int:
(l, h) = (1, n)
while l <= h:
m = l + (h - l) // 2
if guess(m) < 0:
h = m - 1
elif guess(m) > 0:
l = m + 1
else:
return m
return -1 |
def make_shirt(text, size = 'large'):
print('You can buy a ' + size + ' size t-shirt with written ' + text + ' written on it.')
make_shirt(text = 'yepa')
| def make_shirt(text, size='large'):
print('You can buy a ' + size + ' size t-shirt with written ' + text + ' written on it.')
make_shirt(text='yepa') |
###########################################################
# This module is used to centralise messages
# used by the self service bot.
#
###########################################################
class ErrorMessages:
BOT_ABORT_ERROR = "Aborting Self Service Bot"
BOT_INIT_ERROR = "ERROR reported during init... | class Errormessages:
bot_abort_error = 'Aborting Self Service Bot'
bot_init_error = 'ERROR reported during initialisation of SelfServiceBot'
dynamodb_scan_error = 'ERROR reported by DynamoDB'
general_error = 'The bot encountered an error.'
missing_param_error = 'Required parameter not provided'
... |
class Solution:
def maxChunksToSorted(self, arr):
intervals = {}
for i in range(len(arr)):
if i < arr[i]:
minVal, maxVal = i, arr[i]
else:
minVal, maxVal = arr[i], i
if minVal in intervals:
if maxVal > intervals[ min... | class Solution:
def max_chunks_to_sorted(self, arr):
intervals = {}
for i in range(len(arr)):
if i < arr[i]:
(min_val, max_val) = (i, arr[i])
else:
(min_val, max_val) = (arr[i], i)
if minVal in intervals:
if maxVal ... |
def bubble_sort(alist):
for i in range(len(alist)-1, 0, -1):
for j in range(i):
if alist[j] > alist[j+1]:
temp = alist[j]
alist[j] = alist[j+1]
alist[j+1] = temp
return alist
list_to_sort = [147, -16, 18, 91, 44, 1, 8, 54, 31, 18]
bubble_so... | def bubble_sort(alist):
for i in range(len(alist) - 1, 0, -1):
for j in range(i):
if alist[j] > alist[j + 1]:
temp = alist[j]
alist[j] = alist[j + 1]
alist[j + 1] = temp
return alist
list_to_sort = [147, -16, 18, 91, 44, 1, 8, 54, 31, 18]
bubbl... |
class MenuItem():
def __init__(self, itemID, itemName, itemPrice):
self.itemID = itemID
self.itemName = itemName
self.itemPrice = itemPrice
self.itemMods = list()
def getItemID(self):
return self.itemID
def setItemID(self, itemID):
self.itemID = s... | class Menuitem:
def __init__(self, itemID, itemName, itemPrice):
self.itemID = itemID
self.itemName = itemName
self.itemPrice = itemPrice
self.itemMods = list()
def get_item_id(self):
return self.itemID
def set_item_id(self, itemID):
self.itemID = self.item... |
def find_highest_number(numbers):
highest_number = 0
for num in numbers:
if num > highest_number:
highest_number = num
return highest_number
| def find_highest_number(numbers):
highest_number = 0
for num in numbers:
if num > highest_number:
highest_number = num
return highest_number |
# [17CE023] Bhishm Daslaniya
'''
Algorithm!
--> Build a list of tuples such that the string "aaabbc" can be squashed down to [("a", 3), ("b", 2), ("c", 1)]
--> Add to answer all combinations of substrings from these tuples which would represent palindromes which have all same letters
--> traverse this list to specific... | """
Algorithm!
--> Build a list of tuples such that the string "aaabbc" can be squashed down to [("a", 3), ("b", 2), ("c", 1)]
--> Add to answer all combinations of substrings from these tuples which would represent palindromes which have all same letters
--> traverse this list to specifically find the second case ment... |
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
config_type='sweetberry'
revs = [5]
inas = [
('sweetberry', '0x40:3', 'pp975_io', 7.7, 0.100, 'j2', True), # R111
('sweetberry', '0x40:1'... | config_type = 'sweetberry'
revs = [5]
inas = [('sweetberry', '0x40:3', 'pp975_io', 7.7, 0.1, 'j2', True), ('sweetberry', '0x40:1', 'pp850_prim_core', 7.7, 0.1, 'j2', True), ('sweetberry', '0x40:2', 'pp3300_dsw', 3.3, 0.01, 'j2', True), ('sweetberry', '0x40:0', 'pp3300_a', 7.7, 0.01, 'j2', True), ('sweetberry', '0x41:3'... |
# fastq handling
class fastqIter:
" A simple file iterator that returns 4 lines for fast fastq iteration. "
def __init__(self, handle):
self.inf = handle
def __iter__(self):
return self
def next(self):
lines = {'id': self.inf.readline().strip(),
'seq': self.i... | class Fastqiter:
""" A simple file iterator that returns 4 lines for fast fastq iteration. """
def __init__(self, handle):
self.inf = handle
def __iter__(self):
return self
def next(self):
lines = {'id': self.inf.readline().strip(), 'seq': self.inf.readline().strip(), '+': sel... |
vowels = ['a' , 'o' , 'u' , 'e' , 'i' , 'A' , 'O' , 'U' , 'E' , 'I']
string = input()
result = [s for s in string if s not in vowels]
print(''.join(result)) | vowels = ['a', 'o', 'u', 'e', 'i', 'A', 'O', 'U', 'E', 'I']
string = input()
result = [s for s in string if s not in vowels]
print(''.join(result)) |
# Given a binary string (ASCII encoded), write a function that returns the equivalent decoded text.
# Every eight bits in the binary string represents one character on the ASCII table.
# Examples:
# csBinaryToASCII("011011000110000101101101011000100110010001100001") -> "lambda"
# 01101100 -> 108 -> "l"
# 01100001 ->... | def cs_binary_to_ascii(binary):
binary_letters = []
letters = ''
if binary == '':
return ''
for index in range(0, len(binary), 8):
binary_letters.append(binary[index:index + 8])
print(binary_letters)
for string in binary_letters:
binary_int = v = chr(int(string, 2))
... |
# 5/1/2020
# Elliott Gorman
# ITSW 1359
# VINES - STACK ABSTRACT DATA TYPE
class Stack():
def __init__(self):
self.stack = []
#set stack size to -1 so when first object is pushed
# its reference is correct at 0
self.size = -1
def push(self, object):
sel... | class Stack:
def __init__(self):
self.stack = []
self.size = -1
def push(self, object):
self.stack.append(object)
self.size += 1
def pop(self):
if self.isEmpty():
raise empty_stack_exception('The Stack is already Empty.')
else:
remov... |
# Motor
MOTOR_LEFT_FORWARD = 20
MOTOR_LEFT_BACK = 21
MOTOR_RIGHT_FORWARD = 19
MOTOR_RIGHT_BACK = 26
MOTOR_LEFT_PWM = 16
MOTOR_RIGHT_PWM = 13
# Track Sensors
TRACK_LEFT_1 = 3
TRACK_LEFT_2 = 5
TRACK_RIGHT_1 = 4
TRACK_RIGHT_2 = 18
# Button
BUTTON = 8
BUZZER = 8
# Servos
FAN = 2
SEARCHLIGHT_SERVO = 23
CAMERA_SERVO_H = 1... | motor_left_forward = 20
motor_left_back = 21
motor_right_forward = 19
motor_right_back = 26
motor_left_pwm = 16
motor_right_pwm = 13
track_left_1 = 3
track_left_2 = 5
track_right_1 = 4
track_right_2 = 18
button = 8
buzzer = 8
fan = 2
searchlight_servo = 23
camera_servo_h = 11
camera_servo_v = 9
led_r = 22
led_g = 27
le... |
# Selection Sort
# Time Complexity: O(n^2)
# A Implementation of a Selection Sort Algorithm Through a Function.
def selection_sort(nums):
# This value of i corresponds to each value that will be sorted.
for i in range(len(nums)):
# We assume that the first item of the unsorted numbers is the smallest... | def selection_sort(nums):
for i in range(len(nums)):
lowest_value_index = i
for j in range(i + 1, len(nums)):
if nums[j] < nums[lowest_value_index]:
lowest_value_index = j
(nums[i], nums[lowest_value_index]) = (nums[lowest_value_index], nums[i])
random_list_of_num... |
# Solution to problem 7 #
#Student: Niamh O'Leary#
#ID: G00376339#
#Date: 10/03/2019#
#Write a program that takes a positive floating point number as input and outputs an approximation of its square root#
#Note: for the problem please use number 14.5.
num = 14.5
num_sqrt = num ** 0.5 #calulates the... | num = 14.5
num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f' % (num, num_sqrt)) |
class Categories:
def __init__(self, category_name, money_allocated, index_inside_list):
self.category_name = category_name
self.money_allocated = money_allocated
self.index_inside_list = index_inside_list
| class Categories:
def __init__(self, category_name, money_allocated, index_inside_list):
self.category_name = category_name
self.money_allocated = money_allocated
self.index_inside_list = index_inside_list |
class Solution:
def fib(self, N: int) -> int:
self.seen = {}
self.seen[0] = 0
self.seen[1] = 1
return self.dfs(N)
def dfs(self, n):
if n in self.seen:
return self.seen[n]
self.seen[n] = self.dfs(n - 1) + self.dfs(n - 2)
return self.se... | class Solution:
def fib(self, N: int) -> int:
self.seen = {}
self.seen[0] = 0
self.seen[1] = 1
return self.dfs(N)
def dfs(self, n):
if n in self.seen:
return self.seen[n]
self.seen[n] = self.dfs(n - 1) + self.dfs(n - 2)
return self.seen[n] |
# Program to find whether given input string has balanced brackets or not
def isBalanced(s):
a=[]
for i in range(len(s)):
if s[i]=='{' or s[i]=='[' or s[i]=='(':
a.append(s[i])
if s[i]=='}':
if len(a)==0:
return "NO"
else:
... | def is_balanced(s):
a = []
for i in range(len(s)):
if s[i] == '{' or s[i] == '[' or s[i] == '(':
a.append(s[i])
if s[i] == '}':
if len(a) == 0:
return 'NO'
elif a[-1] == '{':
a.pop()
else:
break
... |
#Requests stress Pod resources for a given period of time to simulate load
#deploymentLabel is the Deployment that the request is beings sent to
#cpuCost is the number of threads that the request will use on a pod
#execTime is how long the request will use those resource for before completing
class Request:
def __ini... | class Request:
def __init__(self, INFOLIST):
self.label = INFOLIST[0]
self.deploymentLabel = INFOLIST[1]
self.execTime = int(INFOLIST[2]) |
# Constants and functions for Marsaglia bits ingestion
# constants
FILE_BASE = '/media/alxfed/toca/bits.'
FILE_NUMBER_MIN = 1
FILE_NUMBER_MAX = 60
# pseudo-constants
FILE_EXTENSION = [str(i).zfill(2) for i in range(FILE_NUMBER_MIN, FILE_NUMBER_MAX + 1)]
# starts with 0 element and ends with 59, that's why the dance i... | file_base = '/media/alxfed/toca/bits.'
file_number_min = 1
file_number_max = 60
file_extension = [str(i).zfill(2) for i in range(FILE_NUMBER_MIN, FILE_NUMBER_MAX + 1)]
def file_name(n=1):
if n in range(FILE_NUMBER_MIN, FILE_NUMBER_MAX + 1):
return FILE_BASE + FILE_EXTENSION[n - 1]
else:
raise v... |
def organise(records):
# { user: {shop -> {day -> counter}}}
res = {}
for person, shop, day in records:
if person and shop and (0 < day < 8):
if person not in res:
res[person] = {}
if shop not in res[person]:
res[person][shop] = {}
... | def organise(records):
res = {}
for (person, shop, day) in records:
if person and shop and (0 < day < 8):
if person not in res:
res[person] = {}
if shop not in res[person]:
res[person][shop] = {}
if day not in res[person][shop]:
... |
'''
Convenience wrappers to make using the conf system as easy and seamless as possible
'''
def integrate(hub, imports, override=None, cli=None, roots=None, home_root=None, loader='json'):
'''
Load the conf sub and run the integrate sequence.
'''
hub.pop.sub.add('pop.mods.conf')
hub.conf.integrate... | """
Convenience wrappers to make using the conf system as easy and seamless as possible
"""
def integrate(hub, imports, override=None, cli=None, roots=None, home_root=None, loader='json'):
"""
Load the conf sub and run the integrate sequence.
"""
hub.pop.sub.add('pop.mods.conf')
hub.conf.integrate.... |
#!/usr/bin/env python
# create pipeline
#
reader = vtk.vtkDataSetReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/RectGrid2.vtk")
reader.Update()
# here to force exact extent
elev = vtk.vtkElevationFilter()
elev.SetInputConnection(reader.GetOutputPort())
elev.Update()
outline = vtk.vtkRectilinea... | reader = vtk.vtkDataSetReader()
reader.SetFileName('' + str(VTK_DATA_ROOT) + '/Data/RectGrid2.vtk')
reader.Update()
elev = vtk.vtkElevationFilter()
elev.SetInputConnection(reader.GetOutputPort())
elev.Update()
outline = vtk.vtkRectilinearGridOutlineFilter()
outline.SetInputData(elev.GetRectilinearGridOutput())
outline_... |
# Find the 10001st prime using the Sieve of Eratosthenes
def sieve(n):
sieve = [True] * (n + 1)
sieve[0] = sieve[1] = False
for i in range(2, (n + 1)):
if sieve[i]:
for j in range(i*i, (n + 1), i):
sieve[j] = False
return sieve
prime_sieve = sieve(400000);
primes =... | def sieve(n):
sieve = [True] * (n + 1)
sieve[0] = sieve[1] = False
for i in range(2, n + 1):
if sieve[i]:
for j in range(i * i, n + 1, i):
sieve[j] = False
return sieve
prime_sieve = sieve(400000)
primes = []
for (idx, val) in enumerate(prime_sieve):
if val:
... |
class Node:
# Constructor to initialize the node object
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
# Function to initialize head
def __init__(self):
self.head = None
# Function to insert a new node at the beginning
de... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def push(self, new_data):
new_node = node(new_data)
new_node.next = self.head
self.head = new_node
def print_list(self):
... |
def bubble(alist):
for first in range(len(alist)-1,0,-1):
for sec in range(first):
if alist[sec] > alist[sec+1]:
tmp = alist[sec+1]
alist[sec+1] = alist[sec]
alist[sec] = tmp
def test_bubble():
alist = [1,7,2,5,9,12,5]
bubble(alist)
as... | def bubble(alist):
for first in range(len(alist) - 1, 0, -1):
for sec in range(first):
if alist[sec] > alist[sec + 1]:
tmp = alist[sec + 1]
alist[sec + 1] = alist[sec]
alist[sec] = tmp
def test_bubble():
alist = [1, 7, 2, 5, 9, 12, 5]
bubb... |
#
# PySNMP MIB module TPLINK-ETHERNETOAM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPLINK-ETHERNETOAM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:17:08 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) ... |
class ParticleInstanceModifier:
axis = None
object = None
particle_system_index = None
position = None
random_position = None
show_alive = None
show_dead = None
show_unborn = None
use_children = None
use_normal = None
use_path = None
use_preserve_shape = None
use_size... | class Particleinstancemodifier:
axis = None
object = None
particle_system_index = None
position = None
random_position = None
show_alive = None
show_dead = None
show_unborn = None
use_children = None
use_normal = None
use_path = None
use_preserve_shape = None
use_size... |
def FlagsForFile(filename, **kwargs):
return {
'flags': ['-x', 'c++', '-std=c++14', '-Wall', '-Wextra', '-Werror'
,'-I','C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/include'
,'-I','C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.2612... | def flags_for_file(filename, **kwargs):
return {'flags': ['-x', 'c++', '-std=c++14', '-Wall', '-Wextra', '-Werror', '-I', 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/include', '-I', 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/... |
n = int(input('Digite um valor para calcular seu fatorial: '))
f = 1
print(f'Calculando {n}! = ', end =' ')
for i in range(1, n+1):
print(f'{n}', end = ' ')
print(' x ' if n > 1 else ' = ', end = ' ')
f *= i
n -= 1
print(f) | n = int(input('Digite um valor para calcular seu fatorial: '))
f = 1
print(f'Calculando {n}! = ', end=' ')
for i in range(1, n + 1):
print(f'{n}', end=' ')
print(' x ' if n > 1 else ' = ', end=' ')
f *= i
n -= 1
print(f) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.