content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
t = int(input())
while(t!=0):
count=0
n=int(input())
if n==1:
print('no')
else:
for i in range(2,n//2):
if(n%i == 0):
count+=1
if(count>=1):
print('no')
else:
print('yes')
t-=1
| t = int(input())
while t != 0:
count = 0
n = int(input())
if n == 1:
print('no')
else:
for i in range(2, n // 2):
if n % i == 0:
count += 1
if count >= 1:
print('no')
else:
print('yes')
t -= 1 |
class OrderDamageConfirmation:
def __init__(self, content):
self.system_seat_ids = content['systemSeatIds']
self.msg_id = content['msgId']
self.game_state_id = content['gameStateId']
self.result = content['orderDamageConfirmation']['result']
self.order_damage_type = content['... | class Orderdamageconfirmation:
def __init__(self, content):
self.system_seat_ids = content['systemSeatIds']
self.msg_id = content['msgId']
self.game_state_id = content['gameStateId']
self.result = content['orderDamageConfirmation']['result']
self.order_damage_type = content[... |
def test():
# if an assertion fails, the message will be displayed
# --> must have the output in a comment
assert "Mean: 5.0" in __solution__, "Did you record the correct program output as a comment?"
# --> must have the correct arithmetic mean
assert mean == 5.0, "Are you calculating the arithmetic... | def test():
assert 'Mean: 5.0' in __solution__, 'Did you record the correct program output as a comment?'
assert mean == 5.0, 'Are you calculating the arithmetic mean?'
assert 'TODO' not in __solution__, 'Did you remove the TODO marker when finished?'
__msg__.good('Well done!') |
MASTER_NAME = 'localhost:9090'
MASTER_AUTH = ('admin', 'password')
TEST_MONITOR_SVC_URLS = dict(
base='http://{0}/nitestmonitor',
base_sans_protocol='{0}://{1}/nitestmonitor',
can_write='/v2/can-write',
query_results='/v1/query-results',
query_results_skip_take='/v1/query-results?skip={0}... | master_name = 'localhost:9090'
master_auth = ('admin', 'password')
test_monitor_svc_urls = dict(base='http://{0}/nitestmonitor', base_sans_protocol='{0}://{1}/nitestmonitor', can_write='/v2/can-write', query_results='/v1/query-results', query_results_skip_take='/v1/query-results?skip={0}&take={1}', create_results='/v2/... |
extensions = ["sphinx-favicon"]
master_doc = "index"
exclude_patterns = ["_build"]
html_theme = "basic"
html_static_path = ["gfx"]
favicons = [
{
"sizes": "32x32",
"static-file": "square.svg",
},
{
"sizes": "128x128",
"static-file": "nested/triangle.svg",
},
]
| extensions = ['sphinx-favicon']
master_doc = 'index'
exclude_patterns = ['_build']
html_theme = 'basic'
html_static_path = ['gfx']
favicons = [{'sizes': '32x32', 'static-file': 'square.svg'}, {'sizes': '128x128', 'static-file': 'nested/triangle.svg'}] |
acceptall = [
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n",
"Accept-Encoding: gzip, deflate\r\n",
"Accept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n",
"Accept: text/html, application... | acceptall = ['Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n', 'Accept-Encoding: gzip, deflate\r\n', 'Accept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n', 'Accept: text/html, application/xhtml+xml, appli... |
# region headers
# escript-template v20190605 / stephane.bourdeaud@nutanix.com
# * author: Geluykens, Andy <Andy.Geluykens@pfizer.com>
# * version: 2019/06/05
# task_name: RubrikGetSlaDomainId
# description: This script gets the id of the specified Rubrik SLA domain.
# endregion
# region capture Cal... | username = '@@{rubrik.username}@@'
username_secret = '@@{rubrik.secret}@@'
api_server = '@@{rubrik_ip}@@'
sla_domain = '@@{sla_domain}@@'
api_server_port = '443'
api_server_endpoint = '/api/v1/sla_domain?name={}'.format(sla_domain)
url = 'https://{}:{}{}'.format(api_server, api_server_port, api_server_endpoint)
method ... |
class Animal:
def __init__(self, name): # Constructor of the class
self.name = name
def speak(self): # Abstract method, defined by convention only
raise NotImplementedError("Subclass must implement abstract method")
class Dog(Animal):
def speak(self):
return self.n... | class Animal:
def __init__(self, name):
self.name = name
def speak(self):
raise not_implemented_error('Subclass must implement abstract method')
class Dog(Animal):
def speak(self):
return self.name + ' says Woof!'
class Cat(Animal):
def speak(self):
return self.name... |
'''
You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the Kth attribute and print the final resulting table. Follow the example given below for better understanding.
image
Note that K is indexed fro... | """
You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the Kth attribute and print the final resulting table. Follow the example given below for better understanding.
image
Note that K is indexed from 0 t... |
# Copyright 2019 BlueCat Networks. All rights reserved.
# -*- coding: utf-8 -*-
type = 'ui'
sub_pages = [
{
'name' : 'cmdb_routers_page',
'title' : u'CMDB Routers',
'endpoint' : 'cmdb_routers/cmdb_routers_endpoint',
'description' : u'cmdb_routers'
},
]
| type = 'ui'
sub_pages = [{'name': 'cmdb_routers_page', 'title': u'CMDB Routers', 'endpoint': 'cmdb_routers/cmdb_routers_endpoint', 'description': u'cmdb_routers'}] |
__title__ = "mathy_core"
__version__ = "0.8.4"
__summary__ = "Computer Algebra System for working with math expressions"
__uri__ = "https://mathy.ai"
__author__ = "Justin DuJardin"
__email__ = "justin@dujardinconsulting.com"
__license__ = "All rights reserved"
| __title__ = 'mathy_core'
__version__ = '0.8.4'
__summary__ = 'Computer Algebra System for working with math expressions'
__uri__ = 'https://mathy.ai'
__author__ = 'Justin DuJardin'
__email__ = 'justin@dujardinconsulting.com'
__license__ = 'All rights reserved' |
class ContactHelper:
def __init__(self, app):
self.app = app
def open_contacts_page(self):
wd = self.app.wd
if not (wd.current_url.endswith("/group.php") and len (wd.find_elements_by_name("new"))) > 0:
wd.find_element_by_link_text("home").click()
def create(self, conta... | class Contacthelper:
def __init__(self, app):
self.app = app
def open_contacts_page(self):
wd = self.app.wd
if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new'))) > 0:
wd.find_element_by_link_text('home').click()
def create(self, contac... |
# some sample
PROJECT_NAME = "My Application"
APPLICATION_SENTENCE = "Hello Django"
# add apps into project read after settings.py
# append application into lists
# INSTALLED_APPS.append('my_application')
# MIDDLEWARE.append('my_application.middleware.MyApplicationMiddleware')
# add an application
INSTALLED_APPS.appe... | project_name = 'My Application'
application_sentence = 'Hello Django'
INSTALLED_APPS.append('myapplication.apps.MyapplicationConfig') |
__all__=["declare_reproducible"]
def declare_reproducible(SEED = 123):
'''
https://github.com/NVIDIA/framework-determinism/blob/master/pytorch.md
'''
# or whatever you choose
try :
random.seed(SEED) # if you're using random
except :
pass
try :
np.random.seed(SEED)... | __all__ = ['declare_reproducible']
def declare_reproducible(SEED=123):
"""
https://github.com/NVIDIA/framework-determinism/blob/master/pytorch.md
"""
try:
random.seed(SEED)
except:
pass
try:
np.random.seed(SEED)
except:
pass
try:
torch.manual_seed... |
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
}
SECRET_KEY = 'supersecret'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'nonr... | databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}
secret_key = 'supersecret'
installed_apps = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'nonrelated_inlines.tests.testapp']
root_urlconf = 'nonrelat... |
class Solution:
def buildTree(self, preorder, inorder):
if not inorder:
return None
root_val = preorder[0]
index = inorder.index(root_val)
left_tree = self.buildTree(preorder[1:index + 1], inorder[:index])
right_tree = self.buildTree(preorder[index + 1:... | class Solution:
def build_tree(self, preorder, inorder):
if not inorder:
return None
root_val = preorder[0]
index = inorder.index(root_val)
left_tree = self.buildTree(preorder[1:index + 1], inorder[:index])
right_tree = self.buildTree(preorder[index + 1:], inorde... |
num1 = int(input())
num2 = int(input())
print(f'X = {num1 + num2}')
| num1 = int(input())
num2 = int(input())
print(f'X = {num1 + num2}') |
def PeptideMasses(PeptideMassesSummaryFileName, PeptidesListFileLocation):
# 'amino acid', monoisotopic residue mass, average residue mass
AAResidueMassData = {'A':('Ala', 71.037114, 71.0779),
'C':('Cys', 103.009185, 103.1429),
'D':('Asp', 115.026943, 115.0874),
'... | def peptide_masses(PeptideMassesSummaryFileName, PeptidesListFileLocation):
aa_residue_mass_data = {'A': ('Ala', 71.037114, 71.0779), 'C': ('Cys', 103.009185, 103.1429), 'D': ('Asp', 115.026943, 115.0874), 'E': ('Glu', 129.042593, 129.114), 'F': ('Phe', 147.068414, 147.1739), 'G': ('Gly', 57.021464, 57.0513), 'H': ... |
# Multiplying strings and accessing characters within them
# You can print a string multiple times by... multiplying it!
print("-" * 10)
# Since strings are basically a list, you can also access characters
# or ranges of characters by indexing into them
name = "Phil Hinton"
print(f"Name: {name}")
# First characte... | print('-' * 10)
name = 'Phil Hinton'
print(f'Name: {name}')
print(name[0]) |
# TWITTER
ACCESS_KEY = (" ")
ACCESS_SECRET = (" ")
CONSUMER_KEY = (" ")
CONSUMER_SECRET = (" ")
BEARER_TOKEN = (" ")
# TELEGRAM
API_KEY = (" ")
BOT_CHAT_ID = (" ")
# DISCORD
APPLICATION_ID = (" ")
PUBLIC_KEY = (" ")
CLIENT_ID = (" ")
CLIENT_SECRET = (" ")
TOKEN = (" ")
invite_url = (" ")
# tweets baixados
tweets = [... | access_key = ' '
access_secret = ' '
consumer_key = ' '
consumer_secret = ' '
bearer_token = ' '
api_key = ' '
bot_chat_id = ' '
application_id = ' '
public_key = ' '
client_id = ' '
client_secret = ' '
token = ' '
invite_url = ' '
tweets = []
number = 0 |
SESSION_EXPIRED = "Session expired. Please log in again."
NETWORK_ERROR_MESSAGE = (
"Network error. Please check your connection and try again."
)
AUTH_SERVER_ERROR = (
"A problem occured while trying to authenticate with divio.com. "
"Please try again later"
)
SERVER_ERROR = (
"A problem occured while ... | session_expired = 'Session expired. Please log in again.'
network_error_message = 'Network error. Please check your connection and try again.'
auth_server_error = 'A problem occured while trying to authenticate with divio.com. Please try again later'
server_error = 'A problem occured while trying to communicate with di... |
class FileType:
CSV = 'csv'
XLSX = 'xlsx'
JSON = 'json'
XML = 'xml' | class Filetype:
csv = 'csv'
xlsx = 'xlsx'
json = 'json'
xml = 'xml' |
# encoding: UTF-8
def remove_chinese(str):
s = ""
for w in str:
if w >= u'\u4e00' and w <= u'\u9fa5':
continue
s += w
return s
def remove_non_numerical(s):
f = ''
for i in range(len(s)):
try:
f = float(s[:i+1])
except:
return f
... | def remove_chinese(str):
s = ''
for w in str:
if w >= u'一' and w <= u'龥':
continue
s += w
return s
def remove_non_numerical(s):
f = ''
for i in range(len(s)):
try:
f = float(s[:i + 1])
except:
return f
return str(f) |
# Link: https://leetcode.com/problems/search-in-rotated-sorted-array/
# Time: O(LogN)
# Space: O(1)
# As the given array is rotated sorted, binary search cannot be applied directly.
def search(nums, target):
start, end = 0, len(nums) - 1
while start <= end:
mid = (start + end) // 2
if targ... | def search(nums, target):
(start, end) = (0, len(nums) - 1)
while start <= end:
mid = (start + end) // 2
if target == nums[mid]:
return mid
if nums[start] <= nums[mid]:
if nums[start] <= target < nums[mid]:
end = mid - 1
else:
... |
class Sequence:
transcription_table = {'A':'U', 'T':'A', 'C':'G' , 'G':'C'}
enz_dict = {'EcoRI':'GAATTC', 'EcoRV':'GATATC'}
def __init__(self, seqstring):
self.seqstring = seqstring.upper()
def restriction(self, enz):
try:
enz_target = Sequence.enz_dict[enz]
retur... | class Sequence:
transcription_table = {'A': 'U', 'T': 'A', 'C': 'G', 'G': 'C'}
enz_dict = {'EcoRI': 'GAATTC', 'EcoRV': 'GATATC'}
def __init__(self, seqstring):
self.seqstring = seqstring.upper()
def restriction(self, enz):
try:
enz_target = Sequence.enz_dict[enz]
... |
class Messages:
USERS_1 = 'Username already exists.'
USERS_2 = 'Email already exists.'
USERS_3 = 'Password and Confirm Password must be same.'
USERS_4 = 'Username or Password is incorrect.'
USERS_5 = 'Your email address is not verified.'
TOKENS_1 = 'Token does not exist.'
TOKENS_2 = 'User d... | class Messages:
users_1 = 'Username already exists.'
users_2 = 'Email already exists.'
users_3 = 'Password and Confirm Password must be same.'
users_4 = 'Username or Password is incorrect.'
users_5 = 'Your email address is not verified.'
tokens_1 = 'Token does not exist.'
tokens_2 = 'User do... |
class PageEffectiveImageMixin(object):
def get_effective_image(self):
if self.image:
return self.image
page = self.get_main_language_page()
if page.specific.image:
return page.specific.get_effective_image()
return ''
| class Pageeffectiveimagemixin(object):
def get_effective_image(self):
if self.image:
return self.image
page = self.get_main_language_page()
if page.specific.image:
return page.specific.get_effective_image()
return '' |
# /home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser_tables.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '`\xa3O\x17\xd6C\xd4E2\xb5\xf60wIM\xd9'
_lr_action_items = {'TAKING_TOK':([142,161,187,216,],[-66,188,-66,240,]),'L... | _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '`£O\x17ÖCÔE2µö0wIMÙ'
_lr_action_items = {'TAKING_TOK': ([142, 161, 187, 216], [-66, 188, -66, 240]), 'LP_TOK': ([18, 32, 43, 65, 73, 85, 88, 95, 111, 112, 124, 125, 128, 132, 144, 150, 158, 162, 165, 170, 171, 179, 180, 181, 182, 183, 184, 185, 189, 192, 193, 196... |
# The next lines will make the Pixel Turtle and its heading invisible
# and will clear the screen for light show
hidePixel()
hideHeading()
clear()
# Those are the colors for the light show
colors = [white, red, yellow, green, cyan, blue, purple, white]
# First we move to the top left corner
moveTo(0, 0)
# For each c... | hide_pixel()
hide_heading()
clear()
colors = [white, red, yellow, green, cyan, blue, purple, white]
move_to(0, 0)
for color in colors:
set_color(color)
backward(7)
move(1, 0)
forward(7)
move(1, 0)
move_to(8, 4)
set_color(green)
show_pixel()
show_heading() |
# Write a Python program to multiply two numbers entered by the user and display their product
# for more info on this quiz, go to this url: http://www.programmr.com/multiply-two-numbers-1
def multiply_number():
print("Please enter two numbers")
user_inputs = []
result = 1
for i in range(2):
... | def multiply_number():
print('Please enter two numbers')
user_inputs = []
result = 1
for i in range(2):
user_input = int(input('Enter a number: '))
user_inputs.append(user_input)
for i in user_inputs:
result = i * result
return result
print(multiply_number()) |
personal_details = ('Sanjar', 22, 'India')
print(personal_details)
name, _, country = personal_details
print(name, country)
| personal_details = ('Sanjar', 22, 'India')
print(personal_details)
(name, _, country) = personal_details
print(name, country) |
print ("how old are you?.",)
age=raw_input()
print("How tall are you?.",)
height=raw_input()
print("How much do you weight?.",)
weight=raw_input()
print("So you're %r old,%r tall and %r heavy."%(age,height,weight))
| print('how old are you?.')
age = raw_input()
print('How tall are you?.')
height = raw_input()
print('How much do you weight?.')
weight = raw_input()
print("So you're %r old,%r tall and %r heavy." % (age, height, weight)) |
x = list(input().lower())
y = list(input().lower())
for i,j in zip(x,y):
if i>j:
print("1")
break
elif i<j:
print("-1")
break
else:
print("0") | x = list(input().lower())
y = list(input().lower())
for (i, j) in zip(x, y):
if i > j:
print('1')
break
elif i < j:
print('-1')
break
else:
print('0') |
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
(train_images, train_labels), (test_images, test_la... | fashion_mnist = tf.keras.datasets.fashion_mnist
((train_images, train_labels), (test_images, test_labels)) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
((train_images, train_labels), (test_images, test_labels)) = fas... |
marksheet = []
scores = []
n = int(input())
for i in range(n):
name = input()
score = float(input())
marksheet += [[name, score]]
scores += [score]
li = sorted(set(scores))[1]
for n, s in marksheet:
if s == li:
print(n)
| marksheet = []
scores = []
n = int(input())
for i in range(n):
name = input()
score = float(input())
marksheet += [[name, score]]
scores += [score]
li = sorted(set(scores))[1]
for (n, s) in marksheet:
if s == li:
print(n) |
# -*- coding: utf-8 -*-
def main():
n = int(input())
ans = set()
for i in range(n):
ai, bi = map(int, input().split())
if ai > bi:
ans.add((bi, ai))
else:
ans.add((ai, bi))
print(len(ans))
if __name__ == '__main__':
main()
| def main():
n = int(input())
ans = set()
for i in range(n):
(ai, bi) = map(int, input().split())
if ai > bi:
ans.add((bi, ai))
else:
ans.add((ai, bi))
print(len(ans))
if __name__ == '__main__':
main() |
# vim: set ts=4 sw=4 et fileencoding=utf-8:
'''Vim encoding mappings to Sublime Text'''
ENCODING_MAP = {
'latin1': 'Western (Windows 1252)',
'koi8-r': 'Cyrillic (KOI8-R)',
'koi8-u': 'Cyrillic (KOI8-U)',
'macroman': 'Western (Mac Roman)',
'iso-8859-1': 'Western (ISO 8859-1)',
... | """Vim encoding mappings to Sublime Text"""
encoding_map = {'latin1': 'Western (Windows 1252)', 'koi8-r': 'Cyrillic (KOI8-R)', 'koi8-u': 'Cyrillic (KOI8-U)', 'macroman': 'Western (Mac Roman)', 'iso-8859-1': 'Western (ISO 8859-1)', 'iso-8859-2': 'Central European (ISO 8859-2)', 'iso-8859-3': 'Western (ISO 8859-3)', 'iso... |
#
# PySNMP MIB module NNCEXTPVC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NNCEXTPVC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:13:11 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ... |
# The isBadVersion API is already defined for you.
# def isBadVersion(version: int) -> int:
class Solution:
def firstBadVersion(self, n: int) -> int:
start, end = 1, n
while start < end:
mid = start + (end - start) // 2
check = isBadVersion(mid)
if check... | class Solution:
def first_bad_version(self, n: int) -> int:
(start, end) = (1, n)
while start < end:
mid = start + (end - start) // 2
check = is_bad_version(mid)
if check:
end = mid
else:
start = mid + 1
return ... |
current_petrol = 0
current_position = 0
n = int(input().strip())
for i in range(n):
petrol, distance = map(int, input().strip().split(' '))
current_petrol += petrol
if (current_petrol > distance):
current_petrol -= distance
else:
current_petrol = 0
current_position = i
print(curr... | current_petrol = 0
current_position = 0
n = int(input().strip())
for i in range(n):
(petrol, distance) = map(int, input().strip().split(' '))
current_petrol += petrol
if current_petrol > distance:
current_petrol -= distance
else:
current_petrol = 0
current_position = i
print(curr... |
APPNAME = 'assembly'
APPAUTHOR = 'kbase'
URL = 'http://kbase.us/services/assembly'
AUTH_SERVICE = 'KBase'
OAUTH_EXP_DAYS = 14
OAUTH_FILENAME = 'globus_oauth.prop'
| appname = 'assembly'
appauthor = 'kbase'
url = 'http://kbase.us/services/assembly'
auth_service = 'KBase'
oauth_exp_days = 14
oauth_filename = 'globus_oauth.prop' |
PACKAGE = "python-ptrace"
VERSION = "0.9"
WEBSITE = "http://python-ptrace.readthedocs.org/"
LICENSE = "GNU GPL v2"
| package = 'python-ptrace'
version = '0.9'
website = 'http://python-ptrace.readthedocs.org/'
license = 'GNU GPL v2' |
def findmax(items):
if len(items) == 0:
return None
m = items[0]
i = 1
while i < len(items):
if m < items[i]:
m = items[i]
i = i + 1
return m
| def findmax(items):
if len(items) == 0:
return None
m = items[0]
i = 1
while i < len(items):
if m < items[i]:
m = items[i]
i = i + 1
return m |
#!/usr/bin/python
patch_size = [25, 31, 35]
scale_factor = [1.15, 1.2, 1.3]
num_levels = [4, 8, 10]
max_dist = [35, 40, 45, 50]
fp_runscript = open("/home/kivan/source/cv-stereo/scripts/egomotion_kitti_eval/run_validation_orb2.sh", 'w')
fp_runscript.write("#!/bin/bash\n\n")
cnt = 0
for i in range(len(patch_size)):
... | patch_size = [25, 31, 35]
scale_factor = [1.15, 1.2, 1.3]
num_levels = [4, 8, 10]
max_dist = [35, 40, 45, 50]
fp_runscript = open('/home/kivan/source/cv-stereo/scripts/egomotion_kitti_eval/run_validation_orb2.sh', 'w')
fp_runscript.write('#!/bin/bash\n\n')
cnt = 0
for i in range(len(patch_size)):
for j in range(len... |
class Queue:
def __init__(self, size):
if size <= 0:
raise "Size must be 1 or greater."
self.start = 0
self.end = 0
self.count = 0
self.size = size
self.items = [None] * size
def enqueue(self, data):
if self.count >= self.size:
r... | class Queue:
def __init__(self, size):
if size <= 0:
raise 'Size must be 1 or greater.'
self.start = 0
self.end = 0
self.count = 0
self.size = size
self.items = [None] * size
def enqueue(self, data):
if self.count >= self.size:
ra... |
# -----------------------------------------------------------------------------
# Staff Assistance Flow
# -----------------------------------------------------------------------------
staff_assistance_customer_email_inputtext = "xpath=//*[@id='emailInput']"
staff_assistance_company_input ... | staff_assistance_customer_email_inputtext = "xpath=//*[@id='emailInput']"
staff_assistance_company_input = "//*[@id='customerInput']"
staff_assistance_company_dropdown = "xpath=//*[@id='customerInput']/div/div[2]/div"
staff_assistance_company_select_button = "xpath=//button[contains(text(),'Done')]"
staff_assistance_co... |
# Python Program To Copy An Image Into Another Files
'''
Function Name : Copy An Image Into Another Files
Function Date : 24 Sep 2020
Function Author : Prasad Dangare
Input : --
Output : --
'''
# Open The File In Binary Modes
f1 = open('new.jpg.png', 'rb')
f2 = open('new... | """
Function Name : Copy An Image Into Another Files
Function Date : 24 Sep 2020
Function Author : Prasad Dangare
Input : --
Output : --
"""
f1 = open('new.jpg.png', 'rb')
f2 = open('neww.jpg.jpg', 'wb')
bytes = f1.read()
f2.write(bytes)
f1.close()
f2.close() |
# Oefening: Vraag de geboortedatum van de gebruiker en zeg de leeftijd.
huidig_jaar = 2017
huidige_maand = 10
huidige_dag = 24
jaar = int(input("In welk jaar ben je geboren? "))
maand = int(input("En in welke maand? (getal) "))
# De dag moeten we pas weten als de geboortemaand deze maand is!
# Je kan het hier nat... | huidig_jaar = 2017
huidige_maand = 10
huidige_dag = 24
jaar = int(input('In welk jaar ben je geboren? '))
maand = int(input('En in welke maand? (getal) '))
leeftijd = huidig_jaar - jaar
if maand > huidige_maand:
leeftijd -= 1
elif maand == huidige_maand:
dag = int(input('En welke dag? (getal) '))
if dag > h... |
# Problem for Prof Charnesky's mid term review sheet at:
# https://canvas.umd.umich.edu/courses/522665/pages/midterm-practice?module_item_id=9243802
# 1 Classes and Unit Test question
# Given the following UML, write the class
# Pizza
# toppings : []
# slices : int
# base_cost : float
# price_per_topping : int
# get_to... | class Pizza:
def __init__(self, toppings, slices, base_cost=2.5, price_per_topping=1):
self._toppings = toppings
self._slices = slices
self._base_cost = base_cost
self._price_per_topping = price_per_topping
def get_total_price(self):
return (self._base_cost + self._pric... |
class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def insert(self, value):
if self.value:
if value < self.value:
if self.left:
self.left.insert(value)
else:
... | class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def insert(self, value):
if self.value:
if value < self.value:
if self.left:
self.left.insert(value)
else:
... |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | acr_resource_provider = 'Microsoft.ContainerRegistry'
acr_resource_type = ACR_RESOURCE_PROVIDER + '/registries'
storage_resource_type = 'Microsoft.Storage/storageAccounts'
webhook_resource_type = ACR_RESOURCE_TYPE + '/webhooks'
webhook_api_version = '2017-06-01-preview'
managed_registry_api_version = '2017-06-01-previe... |
total = 0
for num in range(101):
total = total + num
print (total)
| total = 0
for num in range(101):
total = total + num
print(total) |
def totalFruit(self, tree):
count = {}
i = res = 0
for j, v in enumerate(tree):
count[v] = count.get(v, 0) + 1
while len(count) > 2:
count[tree[i]] -= 1
if count[tree[i]] == 0: del count[tree[i]]
i += 1
res = max(res, j - i + 1)
return res
| def total_fruit(self, tree):
count = {}
i = res = 0
for (j, v) in enumerate(tree):
count[v] = count.get(v, 0) + 1
while len(count) > 2:
count[tree[i]] -= 1
if count[tree[i]] == 0:
del count[tree[i]]
i += 1
res = max(res, j - i + 1)
... |
a, b = input().split()
st = ''
num_a = int(a)
num_b = int(b)
if num_a % 2 == 0 :
answer = -num_a
st += str(-num_a)
else :
answer = num_a
st += str(num_a)
if a == b :
if int(a) % 2 == 0 :
print("-", a, "=-", a, sep='')
else :
print(a, "=+", a, sep='')
exit()
while ... | (a, b) = input().split()
st = ''
num_a = int(a)
num_b = int(b)
if num_a % 2 == 0:
answer = -num_a
st += str(-num_a)
else:
answer = num_a
st += str(num_a)
if a == b:
if int(a) % 2 == 0:
print('-', a, '=-', a, sep='')
else:
print(a, '=+', a, sep='')
exit()
while num_a != num_b:... |
result =1
i=1
while i<=100:
result=result*i
i=i+1
pass
print("the factorial is {}".format(result)) | result = 1
i = 1
while i <= 100:
result = result * i
i = i + 1
pass
print('the factorial is {}'.format(result)) |
class TOS(QTextEdit):
tos_signal = pyqtSignal()
error_signal = pyqtSignal(object)
class Plugin(TrustedCoinPlugin):
def __init__(self, parent, config, name):
super().__init__(parent, config, name)
@hook
def on_new_window(self, window):
wallet = window.wallet
if not isinstance(wallet, self.wallet_class):
re... | class Tos(QTextEdit):
tos_signal = pyqt_signal()
error_signal = pyqt_signal(object)
class Plugin(TrustedCoinPlugin):
def __init__(self, parent, config, name):
super().__init__(parent, config, name)
@hook
def on_new_window(self, window):
wallet = window.wallet
if not isinst... |
#
# PySNMP MIB module ZHONE-PHY-SONET-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHONE-PHY-SONET-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:47:49 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (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, constraints_intersection, single_value_constraint) ... |
### SATISFACTORY RESPONSE
## Not found code
OK = 200
OK_NOCONTENT = 204
### CLIENT ERROR
## Not found code
NOT_FOUND = 404
UNAUTHORIZED = 401
### SERVER ERROR
## Internal server error
INTERNAL_ERROR = 500
| ok = 200
ok_nocontent = 204
not_found = 404
unauthorized = 401
internal_error = 500 |
# DESCRIPTION
# Return the root node of a binary search tree that matches the given preorder traversal.
# It's guaranteed that for the given test cases there is always possible to find a
# binary search tree with the given requirements.
# EXAMPLE
# Input: [8,5,1,7,10,12]
# Output: [8,5,10,1,7,null,12]
# Definition f... | class Solution:
def bst_from_preorder(self, preorder: List[int]) -> TreeNode:
"""
Time: O(N), Must iterate over every element of the list
Space: O(N), max space needed for recursive stack
"""
self.index = 0
return self.bst_build(preorder, float('inf'))
def bst_b... |
def find_floor(brackets: str) -> int:
return sum(1 if c == '(' else -1 for c in brackets)
def find_basement_entry(brackets: str) -> int:
return [n + 1 for n in range(len(brackets)) if find_floor(brackets[:n + 1]) == -1][0]
if __name__ == '__main__':
with open('input') as f:
bracket_text = f.read... | def find_floor(brackets: str) -> int:
return sum((1 if c == '(' else -1 for c in brackets))
def find_basement_entry(brackets: str) -> int:
return [n + 1 for n in range(len(brackets)) if find_floor(brackets[:n + 1]) == -1][0]
if __name__ == '__main__':
with open('input') as f:
bracket_text = f.read(... |
result = [
None,
6,
['a', 'b', 'c', {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}],
{'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}},
{'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}},
['a', 'b', 'c', {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}],
None,
6
]
def is_equal(a, b, message... | result = [None, 6, ['a', 'b', 'c', {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}], {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}, {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}, ['a', 'b', 'c', {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}], None, 6]
def is_equal(a, b, message):
comparable_a = [a[0], a[1], ... |
p1, p2 = map(int, input().split())
m = (p1 + p2) / 2
if m >= 7:
print(f'{m} - Aprovado', end='')
elif m < 5:
print(f'{m} - Reprovado', end='')
else:
print(f'{m} - De Recuperacao', end='')
| (p1, p2) = map(int, input().split())
m = (p1 + p2) / 2
if m >= 7:
print(f'{m} - Aprovado', end='')
elif m < 5:
print(f'{m} - Reprovado', end='')
else:
print(f'{m} - De Recuperacao', end='') |
#
# PySNMP MIB module RADIUS-ACCOUNTING-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADIUS-ACCOUNTING-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:44:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, value_size_constraint, constraints_intersection) ... |
#Prints the number in matrix form
def print_numbers(number):
for i in range(1,number+1):
for j in range(1, number+1):
print(i,end=" ")
print()
number=int(input("please enter a number: "))
if number%2==0:
print_numbers(number+1)
else:
print_numbers(number-1)
| def print_numbers(number):
for i in range(1, number + 1):
for j in range(1, number + 1):
print(i, end=' ')
print()
number = int(input('please enter a number: '))
if number % 2 == 0:
print_numbers(number + 1)
else:
print_numbers(number - 1) |
def bar_spec(data):
return {
"config": {
"view": {"continuousWidth": 400, "continuousHeight": 300},
"mark": {"opacity": 0.75}
},
"layer": [
{
"mark": {"type": "bar", "color": "red"},
"encoding": {
"x": {... | def bar_spec(data):
return {'config': {'view': {'continuousWidth': 400, 'continuousHeight': 300}, 'mark': {'opacity': 0.75}}, 'layer': [{'mark': {'type': 'bar', 'color': 'red'}, 'encoding': {'x': {'type': 'nominal', 'field': 'subject'}, 'y': {'type': 'quantitative', 'field': 'percentage of input passed filter'}}}, ... |
#!/usr/bin/env python
#
# Copyright (C) 2017 ShadowMan
#
class FatalError(Exception):
pass
class FrameHeaderParseError(Exception):
pass
class ConnectClosed(Exception):
pass
class RequestError(Exception):
pass
class LoggerWarning(RuntimeWarning):
pass
class DeamonError(Exception):
pass... | class Fatalerror(Exception):
pass
class Frameheaderparseerror(Exception):
pass
class Connectclosed(Exception):
pass
class Requesterror(Exception):
pass
class Loggerwarning(RuntimeWarning):
pass
class Deamonerror(Exception):
pass
class Senddatapackerror(Exception):
pass
class Invalidre... |
#!/usr/bin/env python
#coding: utf-8
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# @return a ListNode
def addTwoNumbers(self, l1, l2):
h = ch = ListNode(-1)
n1, n2, c = l1, l2, 0
... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def add_two_numbers(self, l1, l2):
h = ch = list_node(-1)
(n1, n2, c) = (l1, l2, 0)
while n1 or n2:
a = n1.val if n1 else 0
b = n2.val if n2 else 0
... |
def is_uppercase(letter: str):
return True if 65 <= ord(letter) <= 90 else False
def is_lowercase(letter: str):
return True if 97 <= ord(letter) <= 122 else False
def check_same_case(first: str, second: str) -> bool:
if is_uppercase(first) and is_uppercase(second):
return True
if is_lowerca... | def is_uppercase(letter: str):
return True if 65 <= ord(letter) <= 90 else False
def is_lowercase(letter: str):
return True if 97 <= ord(letter) <= 122 else False
def check_same_case(first: str, second: str) -> bool:
if is_uppercase(first) and is_uppercase(second):
return True
if is_lowercase(... |
n=int(input("enter a number"))
m=int(input("enter a number"))
if n%m==0:
print(n,"is dividible by",m)
else:
print(n,"is not divisible by",m)
if n%2==0:
print(n,"is even")
else:
print(n,"is odd")
| n = int(input('enter a number'))
m = int(input('enter a number'))
if n % m == 0:
print(n, 'is dividible by', m)
else:
print(n, 'is not divisible by', m)
if n % 2 == 0:
print(n, 'is even')
else:
print(n, 'is odd') |
MAX = 'x'
MIN = 'o'
def get_player(s):
return MAX if len([1 for i in s if i == ' ']) % 2 == 1 else MIN
def next_player(p):
return MAX if p == MIN else MIN
def get_actions(s):
return [i for i in range(9) if s[i] == ' ']
def result(s, a):
player = get_player(s)
s2 = list(s)
s2[a] = player
... | max = 'x'
min = 'o'
def get_player(s):
return MAX if len([1 for i in s if i == ' ']) % 2 == 1 else MIN
def next_player(p):
return MAX if p == MIN else MIN
def get_actions(s):
return [i for i in range(9) if s[i] == ' ']
def result(s, a):
player = get_player(s)
s2 = list(s)
s2[a] = player
... |
# What are the factors of 18?
# factor: an integer which when multiplied with another integer, results in the product 18.
# Hence when 18 is divided by this number, the dividend is an integer and there are no remainders.
num = 18
for i in range(1, num+1):
if num % i == 0:
print(i, end=' ')
| num = 18
for i in range(1, num + 1):
if num % i == 0:
print(i, end=' ') |
def main():
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().strip().split()))
if n == 1:
print(arr[0])
else:
n += 1
arr.append(1001)
left, right = 0, 1
res = ''
while left <= right and ... | def main():
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().strip().split()))
if n == 1:
print(arr[0])
else:
n += 1
arr.append(1001)
(left, right) = (0, 1)
res = ''
while left <= right ... |
#########################################################################################
# IMPORTANT: This file should be copied to setting.py and then completed before use #
#########################################################################################
# Rocky Version
VERSION = '0.3.5'
# Path to js... | version = '0.3.5'
hosts = 'file.json'
ports_path = 'path/ports/'
router_name_servers = ['8.8.8.8', '1.1.1.1']
rocky_rsa = ''
robot_rsa = ''
administrator_encryp_pass = ''
api_user_pass = ''
radius_server_address = ''
radius_server_secret = ''
device_config_path = 'path/repo/'
map_access_list = [{'source_address': '', '... |
###########################################################
# #
# Solving factorial problem with recursive function #
# #
###########################################################
def factorial(n):
... | def factorial(n):
if n == 2:
return 2
return n * factorial(n - 1)
print(factorial(int(input()))) |
#
# University of Luxembourg
# Laboratory of Algorithmics, Cryptology and Security (LACS)
#
# FigureOfMerit (FOM)
#
# Copyright (C) 2015 University of Luxembourg
#
# Written in 2015 by Daniel Dinu <dumitru-daniel.dinu@uni.lu>
#
# This file is part of FigureOfMerit.
#
# This program is free software; you can redistribut... | __author__ = 'daniel.dinu' |
__all__ = (
'ESputnikException',
'InvalidAuthDataError',
'IncorrectDataError'
)
class ESputnikException(AttributeError):
pass
class InvalidAuthDataError(ESputnikException):
def __init__(self, code, message):
self.code = code
self.message = message
class IncorrectDataError(Inval... | __all__ = ('ESputnikException', 'InvalidAuthDataError', 'IncorrectDataError')
class Esputnikexception(AttributeError):
pass
class Invalidauthdataerror(ESputnikException):
def __init__(self, code, message):
self.code = code
self.message = message
class Incorrectdataerror(InvalidAuthDataError)... |
class TextFieldFsm:
def __init__(self, title, position, need_hide=False, initial_text=""):
self.title = title
self.position = position
self.need_hide = need_hide
self.initial_text = initial_text
| class Textfieldfsm:
def __init__(self, title, position, need_hide=False, initial_text=''):
self.title = title
self.position = position
self.need_hide = need_hide
self.initial_text = initial_text |
BINDIR = '/usr/local/Cellar/python3/3.6.2_1/Frameworks/Python.framework/Versions/3.6/bin'
DATADIR = '/usr/local/Cellar/python3/3.6.2_1/Frameworks/Python.framework/Versions/3.6/share'
DATAROOTDIR = '/usr/local/Cellar/python3/3.6.2_1/Frameworks/Python.framework/Versions/3.6/share'
DESTDIR ... | bindir = '/usr/local/Cellar/python3/3.6.2_1/Frameworks/Python.framework/Versions/3.6/bin'
datadir = '/usr/local/Cellar/python3/3.6.2_1/Frameworks/Python.framework/Versions/3.6/share'
datarootdir = '/usr/local/Cellar/python3/3.6.2_1/Frameworks/Python.framework/Versions/3.6/share'
destdir = '/'
docdir = '/usr/local/Cella... |
wanted_profit = float(input())
is_wanted_profit_gained = False
total_amount = 0
cocktail = input()
while cocktail != 'Party!':
number_of_cocktails = int(input())
cocktail_price = len(cocktail)
order_price = cocktail_price * number_of_cocktails
if order_price % 2 != 0:
order_price = order_price ... | wanted_profit = float(input())
is_wanted_profit_gained = False
total_amount = 0
cocktail = input()
while cocktail != 'Party!':
number_of_cocktails = int(input())
cocktail_price = len(cocktail)
order_price = cocktail_price * number_of_cocktails
if order_price % 2 != 0:
order_price = order_price -... |
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "core_library", "core_nunit3_test", "core_resource")
COMMON_DEFINES = [
"NETSTANDARD2_0",
"NETCOREAPP2_0",
"SERIALIZATION",
"ASYNC",
#"PLATFORM_DETECTION",
"PARALLEL",
"TASK_PARALLEL_LIBRARY_API",
]
core_library(
name = "nunit.framework.d... | load('@io_bazel_rules_dotnet//dotnet:defs.bzl', 'core_library', 'core_nunit3_test', 'core_resource')
common_defines = ['NETSTANDARD2_0', 'NETCOREAPP2_0', 'SERIALIZATION', 'ASYNC', 'PARALLEL', 'TASK_PARALLEL_LIBRARY_API']
core_library(name='nunit.framework.dll', srcs=glob(['src/NUnitFramework/framework/**/*.cs']) + ['sr... |
def solution(l):
parsed = [e.split(".") for e in l]
toSort = [map(int, e) for e in parsed]
sortedINTs = sorted(toSort)
sortedJoined = [('.'.join(str(ee) for ee in e)) for e in sortedINTs]
return sortedJoined | def solution(l):
parsed = [e.split('.') for e in l]
to_sort = [map(int, e) for e in parsed]
sorted_in_ts = sorted(toSort)
sorted_joined = ['.'.join((str(ee) for ee in e)) for e in sortedINTs]
return sortedJoined |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
print("************************************************************************")
print("* WELCOME TO ZEROMCMP (OpenSource MultiCloud Management Platform) *")
print("**************************************************************... | if __name__ == '__main__':
print('************************************************************************')
print('* WELCOME TO ZEROMCMP (OpenSource MultiCloud Management Platform) *')
print('************************************************************************') |
class Settings:
def __init__(self):
self.screen_width = 900
self.screen_height = 700
self.bg_color = (230, 230, 230)
self.ship_speed_factor = 1
# bullet
self.bullet_speed_factor = 1
self.bullet_width = 4
self.bullet_height = 4
self.bullet_color... | class Settings:
def __init__(self):
self.screen_width = 900
self.screen_height = 700
self.bg_color = (230, 230, 230)
self.ship_speed_factor = 1
self.bullet_speed_factor = 1
self.bullet_width = 4
self.bullet_height = 4
self.bullet_color = (60, 60, 60)
... |
def main() -> None:
S = input()
print("Yes" if "AC" in [S[i:i+2] for i in range(len(S)-1)] else "No")
if __name__ == '__main__':
main()
| def main() -> None:
s = input()
print('Yes' if 'AC' in [S[i:i + 2] for i in range(len(S) - 1)] else 'No')
if __name__ == '__main__':
main() |
i= 1
while i<=3:
print("Guess:", i)
i=i+1
print("sorry you failed") | i = 1
while i <= 3:
print('Guess:', i)
i = i + 1
print('sorry you failed') |
src = Split('''
aos/soc_impl.c
hal/uart.c
hal/flash.c
main.c
''')
deps = Split('''
kernel/rhino
platform/arch/arm/armv7m
platform/mcu/wm_w600/
kernel/vcall
kernel/init
''')
global_macro = Split('''
STDIO_UART=0
CONFIG_NO_TCPIP
... | src = split('\n aos/soc_impl.c\n hal/uart.c\n hal/flash.c \n\tmain.c\n')
deps = split('\n kernel/rhino\n platform/arch/arm/armv7m\n platform/mcu/wm_w600/\n kernel/vcall\n kernel/init\n')
global_macro = split('\n STDIO_UART=0 \n CONFIG_NO_TCPIP\n ... |
# Test helper functions and classes
class ParameterPassLevel:
FLAG = 0
INI_KEY = 1
MARKER = 2
def _assert_result_outcomes(
result, passed=0, skipped=0, failed=0, error=0, dynamic_rerun=0
):
outcomes = result.parseoutcomes()
_check_outcome_field(outcomes, "passed", passed)
_check_outcome_... | class Parameterpasslevel:
flag = 0
ini_key = 1
marker = 2
def _assert_result_outcomes(result, passed=0, skipped=0, failed=0, error=0, dynamic_rerun=0):
outcomes = result.parseoutcomes()
_check_outcome_field(outcomes, 'passed', passed)
_check_outcome_field(outcomes, 'skipped', skipped)
_chec... |
# O(1) time | O(1) space
def validIPAddresses(string):
ipAddressesFound = []
for i in range(1, min(len(string), 4)): # from index 0 - 4
currentIPAddressParts = ["","","",""]
currentIPAddressParts[0] = string[:i] # before the first period
if not isValidPart(currentIPAddressParts[0]):
continue
for j... | def valid_ip_addresses(string):
ip_addresses_found = []
for i in range(1, min(len(string), 4)):
current_ip_address_parts = ['', '', '', '']
currentIPAddressParts[0] = string[:i]
if not is_valid_part(currentIPAddressParts[0]):
continue
for j in range(i + 1, i + min(len... |
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
# TODO: 'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
# django-oauth-toolkit >= 1.0.0
# 'rest_framework_social_oauth2.authentication.SocialAuthenticati... | rest_framework = {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',), 'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',), 'DEFAULT_PARSER_CLASSES': ('rest_framework.parsers.JSONParser', 'rest_framework.parsers.FormParser', 'rest_framework.parsers.MultiPa... |
def is_merge(s, part1, part2):
all_chars = len(s) == len(part1) + len(part2)
if not all_chars:
return False
d = {}
for i, c in enumerate(s):
d[c] = i
indices1, indices2 = [d[c] for c in part1], [d[c] for c in part2]
part1_good = indices1 == sorted(indices1)
part2_good = indic... | def is_merge(s, part1, part2):
all_chars = len(s) == len(part1) + len(part2)
if not all_chars:
return False
d = {}
for (i, c) in enumerate(s):
d[c] = i
(indices1, indices2) = ([d[c] for c in part1], [d[c] for c in part2])
part1_good = indices1 == sorted(indices1)
part2_good =... |
def Duplicate_Charaters(Test_String):
Duplicates = []
for char in Test_String:
if Test_String.count(char) > 1 and char not in Duplicates:
Duplicates.append(char)
return Duplicates
Test_String = input("Enter a String: ")
print(*(Duplicate_Charaters(Test_String)))
| def duplicate__charaters(Test_String):
duplicates = []
for char in Test_String:
if Test_String.count(char) > 1 and char not in Duplicates:
Duplicates.append(char)
return Duplicates
test__string = input('Enter a String: ')
print(*duplicate__charaters(Test_String)) |
#!python3
def main():
with open('21.txt', 'r') as f, open('21_out.txt', 'w') as f_out:
lines = f.readlines()
# Part 1
answer = 0
print(answer)
print(answer, file=f_out)
# Part 2
print(answer)
print(answer, file=f_out)
if __name__ == '__main__':
... | def main():
with open('21.txt', 'r') as f, open('21_out.txt', 'w') as f_out:
lines = f.readlines()
answer = 0
print(answer)
print(answer, file=f_out)
print(answer)
print(answer, file=f_out)
if __name__ == '__main__':
main() |
class HashState:
def __init__(self, player, cards, leading, upper, lower, tricks):
self.current_player = player
self.cards = cards
self.upper_bound = upper
self.lower_bound = lower
self.leading_suite = leading
self.tricks_left = tricks
def get_current_player(... | class Hashstate:
def __init__(self, player, cards, leading, upper, lower, tricks):
self.current_player = player
self.cards = cards
self.upper_bound = upper
self.lower_bound = lower
self.leading_suite = leading
self.tricks_left = tricks
def get_current_player(sel... |
# -*- coding: utf-8 -*-
# License: See LICENSE file.
required_states = ['position']
required_matrices = ['cellular_binary_grass']
def run(name, world, matrices, states, extra_life=10):
y,x = states['position']
#if matrices['cellular_binary_grass'][int(y),int(x)]:
# Eat the cell under the agent's position... | required_states = ['position']
required_matrices = ['cellular_binary_grass']
def run(name, world, matrices, states, extra_life=10):
(y, x) = states['position']
matrices['cellular_binary_grass'][int(y), int(x)] = False |
class Config:
def __init__(self, classified_types: [str]):
self.classified_types = classified_types
| class Config:
def __init__(self, classified_types: [str]):
self.classified_types = classified_types |
nterms = int(input("Stevilo cifr? "))
n1, n2 = 0, 1
count = 0
if nterms <= 0:
print("Vnesi pozitivno stevilo: ")
elif nterms == 1:
print("Sekvenca do ",nterms,": ")
print(n1)
else:
print("Sekvenca:")
while count < nterms:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
coun... | nterms = int(input('Stevilo cifr? '))
(n1, n2) = (0, 1)
count = 0
if nterms <= 0:
print('Vnesi pozitivno stevilo: ')
elif nterms == 1:
print('Sekvenca do ', nterms, ': ')
print(n1)
else:
print('Sekvenca:')
while count < nterms:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth... |
issues=[
dict(name='Habit',number=5,season='Winter 2012',
description='commit to a change, experience it, and record'),
dict(name='Interview', number=4, season='Autumn 2011',
description="this is your opportunity to inhabit another's mind"),
dict(name= 'Digital Presence', number= 3, season= ... | issues = [dict(name='Habit', number=5, season='Winter 2012', description='commit to a change, experience it, and record'), dict(name='Interview', number=4, season='Autumn 2011', description="this is your opportunity to inhabit another's mind"), dict(name='Digital Presence', number=3, season='Summer 2011', description='... |
num = 1
factors = list()
while num <= 100:
if (num % 10) == 0:
factors.append(num)
num = num + 1
print("Factors :",factors)
| num = 1
factors = list()
while num <= 100:
if num % 10 == 0:
factors.append(num)
num = num + 1
print('Factors :', factors) |
dict(
source=["/home/yzhang3151/project/NMT/experiments/nmt/binarized_text.diag.shuf.h5"],
target=["/home/yzhang3151/project/NMT/experiments/nmt/binarized_text.drug.shuf.h5"],
indx_word="/home/yzhang3151/project/NMT/experiments/nmt/ivocab.diag.pkl",
indx_word_target="/home/yzhang3151/project/NMT/experiments/nmt/ivocab.... | dict(source=['/home/yzhang3151/project/NMT/experiments/nmt/binarized_text.diag.shuf.h5'], target=['/home/yzhang3151/project/NMT/experiments/nmt/binarized_text.drug.shuf.h5'], indx_word='/home/yzhang3151/project/NMT/experiments/nmt/ivocab.diag.pkl', indx_word_target='/home/yzhang3151/project/NMT/experiments/nmt/ivocab.d... |
#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
# Basic list exercises
# Fill in the code for the functions below. main() is already set ... | def match_ends(words):
return len([word for word in words if len(word) >= 2 and word[0] == word[-1]])
def front_x(words):
strings_with_x = sorted([word for word in words if word[0] == 'x'])
other_strings = sorted([word for word in words if word[0] != 'x'])
return strings_with_x + other_strings
def sor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.