content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Given a non-negative integer x, compute and return the square root of x.
# Since the return type is an integer, the decimal digits are truncated,
# and only the integer part of the result is returned.
# Note: You are not allowed to use any built-in exponent function or operator,
# such as pow(x, 0.5) or x ** 0.5.
... | class Initialsolution:
def my_sqrt(self, x: int) -> int:
(start, end) = (0, x)
while start <= end:
mid = start + (end - start) // 2
square = mid * mid
if square > x:
end = mid - 1
elif square < x:
start = mid + 1
... |
def get_color(code):
# write your answer between #start and #end
#start
return ''
#end
print('Test 1')
print('Expected:Red')
result = get_color ('R')
print('Actual :' + result)
print()
print('Test 2')
print('Expected:Green')
result = get_color ('g')
print('Actual :' + result)
print()
print('Test... | def get_color(code):
return ''
print('Test 1')
print('Expected:Red')
result = get_color('R')
print('Actual :' + result)
print()
print('Test 2')
print('Expected:Green')
result = get_color('g')
print('Actual :' + result)
print()
print('Test 3')
print('Expected:Blue')
result = get_color('B')
print('Actual :' + resu... |
def game_to_genre(game_name):
genres_dict = {}
with open('genres_dict.txt', 'r') as file:
file.seek(0)
for line in file:
stripped_line = line.strip()
key, *value = stripped_line.split(', ')
genres_dict[key] = value
game_genre = None
lowered_ga... | def game_to_genre(game_name):
genres_dict = {}
with open('genres_dict.txt', 'r') as file:
file.seek(0)
for line in file:
stripped_line = line.strip()
(key, *value) = stripped_line.split(', ')
genres_dict[key] = value
game_genre = None
lowered_game_name... |
# Copyright (C) 2021 Clinton Garwood
# MIT Open Source Initiative Approved License
# hw_assignment_4_clinton.py
# CIS-135 Python
# Homework Assignment #4 - A Phone Sales Application
# Code Summary:
# A program that computes total charges for phones sold
# and displays the initial charge, the tax and the total
... | def sales_data_report(total_phones_price, total_sales_tax_collected, total_sales):
price_of_phone = 0.0
sales_tax = 0.0
tax_rate = 0.07
this_sale = 0.0
price_of_phone = float(input('\n\tPlease enter in the price of the phone: '))
sales_tax = price_of_phone * tax_rate
this_sale = price_of_pho... |
'''
Positioning and styling legends
Properties of the legend can be changed by using the legend member attribute of a Bokeh figure after the glyphs have been plotted.
In this exercise, you'll adjust the background color and legend location of the female literacy vs fertility plot from the previous exercise.
The figu... | """
Positioning and styling legends
Properties of the legend can be changed by using the legend member attribute of a Bokeh figure after the glyphs have been plotted.
In this exercise, you'll adjust the background color and legend location of the female literacy vs fertility plot from the previous exercise.
The figu... |
alphabet = "".join([chr(65 + r) for r in range(26)] * 2)
stringToEncrypt = input("please enter a message to encrypt")
stringToEncrypt = stringToEncrypt.upper()
shiftAmount = int(input("please enter a whole number from -25-25 to be your key"))
encryptedString = ""
for currentCharacter in stringToEncrypt:
position =... | alphabet = ''.join([chr(65 + r) for r in range(26)] * 2)
string_to_encrypt = input('please enter a message to encrypt')
string_to_encrypt = stringToEncrypt.upper()
shift_amount = int(input('please enter a whole number from -25-25 to be your key'))
encrypted_string = ''
for current_character in stringToEncrypt:
posi... |
fruit = input()
size_set = input()
ordered_sets = int(input())
price = 0.0
if size_set == "small":
price = 2.0
if fruit == "Watermelon":
price *= 56
elif fruit == "Mango":
price *= 36.66
elif fruit == "Pineapple":
price *= 42.10
elif fruit == "Raspberry":
price *= 20
... | fruit = input()
size_set = input()
ordered_sets = int(input())
price = 0.0
if size_set == 'small':
price = 2.0
if fruit == 'Watermelon':
price *= 56
elif fruit == 'Mango':
price *= 36.66
elif fruit == 'Pineapple':
price *= 42.1
elif fruit == 'Raspberry':
price *= 20
i... |
class Solution:
def largeGroupPositions(self, s: str) -> List[List[int]]:
indexes = []; start, end, n = 0, 0, len(s)
while start < n:
while end < n and s[start] == s[end]:
end += 1
if end-start > 2: indexes.append([start,end-1])
start = end
... | class Solution:
def large_group_positions(self, s: str) -> List[List[int]]:
indexes = []
(start, end, n) = (0, 0, len(s))
while start < n:
while end < n and s[start] == s[end]:
end += 1
if end - start > 2:
indexes.append([start, end - ... |
class Class(object):
def __enter__(self):
print('__enter__')
return self
def __exit__(self, exc_type, exc_val, exc_tb):
print('__exit__')
with Class() as c:
print(c)
#raise Exception
| class Class(object):
def __enter__(self):
print('__enter__')
return self
def __exit__(self, exc_type, exc_val, exc_tb):
print('__exit__')
with class() as c:
print(c) |
new_pod_repository(
name = "FBSDKCoreKit",
url = "https://github.com/facebook/facebook-ios-sdk/archive/v7.1.1.zip",
podspec_url = "Vendor/Podspecs/FBSDKCoreKit.podspec.json",
generate_header_map = 1
)
new_pod_repository(
name = "FBSDKLoginKit",
url = "https://github.com/facebook/facebook-ios-sdk/archive/v7.... | new_pod_repository(name='FBSDKCoreKit', url='https://github.com/facebook/facebook-ios-sdk/archive/v7.1.1.zip', podspec_url='Vendor/Podspecs/FBSDKCoreKit.podspec.json', generate_header_map=1)
new_pod_repository(name='FBSDKLoginKit', url='https://github.com/facebook/facebook-ios-sdk/archive/v7.1.1.zip', podspec_url='Vend... |
class Simplest():
pass
print(type(Simplest))
simp = Simplest()
print(type(simp))
print(type(simp) == Simplest)
| class Simplest:
pass
print(type(Simplest))
simp = simplest()
print(type(simp))
print(type(simp) == Simplest) |
print(''.join(['-' for x in range(70)]))
# Functions are objects
def my_func(x):
print("Functions are objects:", x, my_func.foo)
my_func.foo = 'foo'
print(dir(my_func))
print(''.join(['-' for x in range(70)]))
# Named and anonymous functions
my_lambda = lambda x: print("Lambda:", x, my_lambda.bar)
my_lambda.bar = 'b... | print(''.join(['-' for x in range(70)]))
def my_func(x):
print('Functions are objects:', x, my_func.foo)
my_func.foo = 'foo'
print(dir(my_func))
print(''.join(['-' for x in range(70)]))
my_lambda = lambda x: print('Lambda:', x, my_lambda.bar)
my_lambda.bar = 'bar'
my_lambda(42)
print(''.join(['-' for x in range(70... |
QUERY_ISSUE_RESPONSE = {
"expand": "names,schema",
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"fields": {
"aggregateprogress": {
"progress": 0,
"total": 0
... | query_issue_response = {'expand': 'names,schema', 'issues': [{'expand': 'operations,versionedRepresentations,editmeta,changelog,renderedFields', 'fields': {'aggregateprogress': {'progress': 0, 'total': 0}, 'aggregatetimeestimate': None, 'aggregatetimeoriginalestimate': None, 'aggregatetimespent': None, 'assignee': None... |
cod1, n1, v1 = input().split(' ')
cod1 = int(cod1)
n1 = int(n1)
v1 = float(v1)
cod2, n2, v2 = input().split(' ')
cod2 = int(cod2)
n2 = int(n2)
v2 = float(v2)
tot = n1 * v1 + n2 * v2
print(f'VALOR A PAGAR: R$ {tot:.2f}')
| (cod1, n1, v1) = input().split(' ')
cod1 = int(cod1)
n1 = int(n1)
v1 = float(v1)
(cod2, n2, v2) = input().split(' ')
cod2 = int(cod2)
n2 = int(n2)
v2 = float(v2)
tot = n1 * v1 + n2 * v2
print(f'VALOR A PAGAR: R$ {tot:.2f}') |
# Dictionary
phonebook = {}
print(phonebook)
phonebook = {
'Andy': '9957558',
'John': '64746484',
'Jenny': '22282'
}
print(phonebook['Andy'])
print(phonebook['John'])
print(phonebook['Jenny'])
print(dir(phonebook))
for phone in phonebook.values():
print(phone)
for phone in phonebook.keys():
print(phone)
... | phonebook = {}
print(phonebook)
phonebook = {'Andy': '9957558', 'John': '64746484', 'Jenny': '22282'}
print(phonebook['Andy'])
print(phonebook['John'])
print(phonebook['Jenny'])
print(dir(phonebook))
for phone in phonebook.values():
print(phone)
for phone in phonebook.keys():
print(phone)
for (key, value) in ph... |
def test_bearychat_badge_should_be_svg(test_client):
resp = test_client.get('/badge/bearychat.svg')
assert resp.status_code == 200
assert resp.content_type == 'image/svg+xml'
def test_bearychat_badge_should_contain_bearychat(test_client):
resp = test_client.get('/badge/bearychat.svg')
assert 'Bear... | def test_bearychat_badge_should_be_svg(test_client):
resp = test_client.get('/badge/bearychat.svg')
assert resp.status_code == 200
assert resp.content_type == 'image/svg+xml'
def test_bearychat_badge_should_contain_bearychat(test_client):
resp = test_client.get('/badge/bearychat.svg')
assert 'Beary... |
def get_first_matching_attr(obj, *attrs, default=None):
for attr in attrs:
if hasattr(obj, attr):
return getattr(obj, attr)
return default
| def get_first_matching_attr(obj, *attrs, default=None):
for attr in attrs:
if hasattr(obj, attr):
return getattr(obj, attr)
return default |
#
# PySNMP MIB module OG-SMI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OG-SMI-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:23:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, constraints_intersection, value_size_constraint, value_range_constraint) ... |
layer_adr_pt = QgsMapLayerRegistry.instance().mapLayersByName('adresse_pt_1')[0]
layer_adr_line = QgsMapLayerRegistry.instance().mapLayersByName('troncon_fusion')[0]
ids = []
for point in layer_adr_pt.getFeatures():
geom = point.geometry()
for rue in layer_adr_line.getFeatures():
geom_rue = rue.geome... | layer_adr_pt = QgsMapLayerRegistry.instance().mapLayersByName('adresse_pt_1')[0]
layer_adr_line = QgsMapLayerRegistry.instance().mapLayersByName('troncon_fusion')[0]
ids = []
for point in layer_adr_pt.getFeatures():
geom = point.geometry()
for rue in layer_adr_line.getFeatures():
geom_rue = rue.geometry... |
# parsetab.py
# This file is automatically generated. Do not edit.
# pylint: disable=W,C,R
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftPAR_ABREPAR_CIERRArightIGUALleftORleftANDleftNO_IGUALnonassocMAYORMENORMAYOR_IGUALMENOR_IGUALleftMASMENOSleftASTERISCODIVISIONMODULOleftPOTENCIArightNOTleftLLAVE_AB... | _tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftPAR_ABREPAR_CIERRArightIGUALleftORleftANDleftNO_IGUALnonassocMAYORMENORMAYOR_IGUALMENOR_IGUALleftMASMENOSleftASTERISCODIVISIONMODULOleftPOTENCIArightNOTleftLLAVE_ABRELLAVE_CIERRAADD ALL ALTER AND AS ASC ASTERISCO AVG BETWEEN BIGINT BOOLEAN BY CADENA CASE CAS... |
#!/usr/bin/env python
class Elf_parser:
"Extracts parts from ELF files"
def __init__(self, filename):
self.elf_file = filename
def get_text(self):
"Returns the text section of the ELF file as array"
pass
def get_data(self):
"Returns the data section of the ELF file as array"
pass
def hex_dump_text(s... | class Elf_Parser:
"""Extracts parts from ELF files"""
def __init__(self, filename):
self.elf_file = filename
def get_text(self):
"""Returns the text section of the ELF file as array"""
pass
def get_data(self):
"""Returns the data section of the ELF file as array"""
... |
def parse_binary(binary_string):
if not all(char in ('0', '1') for char in binary_string):
raise ValueError('invalid binary number')
return sum(int(digit) * (2 ** power) for power, digit in enumerate(reversed(binary_string)))
| def parse_binary(binary_string):
if not all((char in ('0', '1') for char in binary_string)):
raise value_error('invalid binary number')
return sum((int(digit) * 2 ** power for (power, digit) in enumerate(reversed(binary_string)))) |
def f(x):
if(x>4):
return f(x-1)+2*x
elif(x>1 and x<=4):
return f(x-2)*x + x
else:
return x
print(f(6))
| def f(x):
if x > 4:
return f(x - 1) + 2 * x
elif x > 1 and x <= 4:
return f(x - 2) * x + x
else:
return x
print(f(6)) |
def stars_decorator(f):
def wrapper(n):
print("*" * 50)
f(n)
print("*" * 50)
return wrapper
# let's decorate greet:
@stars_decorator
def greet(name):
print("Howdy {}!".format(name))
# and use it:
greet("Pesho") | def stars_decorator(f):
def wrapper(n):
print('*' * 50)
f(n)
print('*' * 50)
return wrapper
@stars_decorator
def greet(name):
print('Howdy {}!'.format(name))
greet('Pesho') |
tabby_cat="\tI'm tabbed in";
persian_cat="I'm split\non s line."
backslash_cat="i'm \\ a \\ cat"
fat_cat="I'll do a list:\t* Cat food \t* Fishies \t* Catnip\n\t* Grass"
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)
| tabby_cat = "\tI'm tabbed in"
persian_cat = "I'm split\non s line."
backslash_cat = "i'm \\ a \\ cat"
fat_cat = "I'll do a list:\t* Cat food \t* Fishies \t* Catnip\n\t* Grass"
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat) |
t= int(input("Enter the number of test cases\n"))
n=[]
stack=[]
for i in range(t):
n.append(input())
l=len(n[i])
stack.append([])
t=n[i][l-1]
stack[i].append(n[i][l-1])
for j in range(l-2,-1,-1):
if n[i][j]!=t:
stack[i].append(n[i][j])
t=n[i][j]
for i in stack:
... | t = int(input('Enter the number of test cases\n'))
n = []
stack = []
for i in range(t):
n.append(input())
l = len(n[i])
stack.append([])
t = n[i][l - 1]
stack[i].append(n[i][l - 1])
for j in range(l - 2, -1, -1):
if n[i][j] != t:
stack[i].append(n[i][j])
t = n[i][... |
def solution(a):
sm_num = min(a)
while not( all(x % sm_num == 0 for x in a)):
a = sorted(a)
lg_num = a[-1]
sm_num = a[0]
if lg_num % sm_num == 0:
a[-1] = sm_num
else:
a[-1] = lg_num % sm_num
return len(a) * sm_num | def solution(a):
sm_num = min(a)
while not all((x % sm_num == 0 for x in a)):
a = sorted(a)
lg_num = a[-1]
sm_num = a[0]
if lg_num % sm_num == 0:
a[-1] = sm_num
else:
a[-1] = lg_num % sm_num
return len(a) * sm_num |
class AnimeDLError(Exception):
pass
class URLError(AnimeDLError):
pass
class NotFoundError(AnimeDLError):
pass
| class Animedlerror(Exception):
pass
class Urlerror(AnimeDLError):
pass
class Notfounderror(AnimeDLError):
pass |
'''
Python program to format a specified string limiting the length of a string.
'''
str_num = "1234567890"
print("Original string:",str_num)
print('%.6s' % str_num)
print('%.9s' % str_num)
print('%.10s' % str_num)
| """
Python program to format a specified string limiting the length of a string.
"""
str_num = '1234567890'
print('Original string:', str_num)
print('%.6s' % str_num)
print('%.9s' % str_num)
print('%.10s' % str_num) |
# Copyright Notice:
# Copyright 2018 Dell, Inc. All rights reserved.
# License: BSD License. For full license text see link: https://github.com/RedDrum-Redfish-Project/RedDrum-Frontend/LICENSE.txt
class RdSystemsBackend():
# class for backend systems resource APIs
def __init__(self,rdr):
self.... | class Rdsystemsbackend:
def __init__(self, rdr):
self.version = 1
self.rdr = rdr
def update_resource_dbs(self, systemid, updateStaticProps=False, updateNonVols=True):
return (0, False)
def do_system_reset(self, systemid, resetType):
self.rdr.logMsg('DEBUG', '--------SIM BA... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
if not head or not head.next:
return head
newhead = head.next
pt... | class Solution:
def swap_pairs(self, head: ListNode) -> ListNode:
if not head or not head.next:
return head
newhead = head.next
ptr = head
prev = None
while ptr:
if ptr.next:
tmp = ptr.next.next
ptr.next.next = ptr
... |
class Rectangle:
# write your code here
def __init__(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
print('Rectangle(',x1,', ',y1,', ',x2,', ',y2,') created')
# Alternative Solutions
class Rectangle2:
def __init__(self, x1, y1, x2, y2): # class constructor
if x... | class Rectangle:
def __init__(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
print('Rectangle(', x1, ', ', y1, ', ', x2, ', ', y2, ') created')
class Rectangle2:
def __init__(self, x1, y1, x2, y2):
if x1 < x2 and y1 > y2:
... |
## Idiomatic dict comprehension
# No.1
def i1():
emails = {user.name: user.email for user in users if user.email}
# No.2
def i2():
dict_compr = {k: k**2 for k in range(10000)}
# No.3
def i3():
new_dict_comp = {n:n**2 for n in numbers if n%2 == 0}
# No.4
def i4():
dict1 = {'a': 1, 'b'... | def i1():
emails = {user.name: user.email for user in users if user.email}
def i2():
dict_compr = {k: k ** 2 for k in range(10000)}
def i3():
new_dict_comp = {n: n ** 2 for n in numbers if n % 2 == 0}
def i4():
dict1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6}
dict1_triple_cond = {k: v for... |
print("Hello World1")
a = 1
b = 2
c = a+b
print("c:",c) | print('Hello World1')
a = 1
b = 2
c = a + b
print('c:', c) |
'''
A simple documentation utility for python. It extracts the documentation from the `docstring` and generate `markdown` files from that.
This documentation is also generated using `code2doc`.
Module dependency graph:

Here are the list of all files and folders in this module:... | """
A simple documentation utility for python. It extracts the documentation from the `docstring` and generate `markdown` files from that.
This documentation is also generated using `code2doc`.
Module dependency graph:

Here are the list of all files and folders in this module:
""" |
#Author: OMKAR PATHAK
#This program checks whether the entered number is prime or not
def checkPrime(number):
'''This function checks for prime number'''
isPrime = False
if number == 2:
print(number, 'is a Prime Number')
if number > 1:
for i in range(2, number):
if number % ... | def check_prime(number):
"""This function checks for prime number"""
is_prime = False
if number == 2:
print(number, 'is a Prime Number')
if number > 1:
for i in range(2, number):
if number % i == 0:
print(number, 'is not a Prime Number')
is_pri... |
#
# PySNMP MIB module APPIAN-TIMESLOTS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APPIAN-TIMESLOTS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:24:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (ac_admin_status, ac_osap) = mibBuilder.importSymbols('APPIAN-SMI-MIB', 'AcAdminStatus', 'acOsap')
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constr... |
#
# PySNMP MIB module Unisphere-Data-ERX-Registry (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Unisphere-Data-ERX-Registry
# Produced by pysmi-0.3.4 at Wed May 1 15:31:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, single_value_constraint, constraints_union, value_range_constraint) ... |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\x11\x13C\xf3\x8a\xda\x0f\xf9op-\xf5B\xe1`\xb1'
_lr_action_items = {'BOX':([0,8,9,12,14,15,16,23,24,25,28,29,30,31,32,35,37,40,48,54,56,59,63,64,70,74,75,80,84,87,91,92,95,99,101,104,111,1... | _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\x11\x13Có\x8aÚ\x0fùop-õBá`±'
_lr_action_items = {'BOX': ([0, 8, 9, 12, 14, 15, 16, 23, 24, 25, 28, 29, 30, 31, 32, 35, 37, 40, 48, 54, 56, 59, 63, 64, 70, 74, 75, 80, 84, 87, 91, 92, 95, 99, 101, 104, 111, 112, 113, 114], [1, -14, -3, -7, 1, -8, -10, -11, -39, -... |
#!/usr/bin/env python3
END_MARK = None # any singleton could be used for this
FALLBACK = '0' # text to print when there are no matches
for _ in range(int(input())):
input() # don't need n
# Build the trie.
trie = {}
for word in input().split():
cur = trie
for ch in word:
... | end_mark = None
fallback = '0'
for _ in range(int(input())):
input()
trie = {}
for word in input().split():
cur = trie
for ch in word:
try:
cur = cur[ch]
except KeyError:
nxt = {}
cur[ch] = nxt
cur = nxt
... |
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
temp = []
result = 0
for i in s:
if i not in temp:
temp.append(i)
else:
result = max(result, len(temp))
temp = temp[temp.index(i)+1::]
te... | class Solution:
def length_of_longest_substring(self, s: str) -> int:
temp = []
result = 0
for i in s:
if i not in temp:
temp.append(i)
else:
result = max(result, len(temp))
temp = temp[temp.index(i) + 1:]
... |
followers_likes= {}
followers_comments= {}
while True:
line = input()
if line == 'Log out':
break
args = line.split(': ')
command= args[0]
username = args[1]
if command == 'New follower':
if username not in followers_likes and username not in followers_comments:
... | followers_likes = {}
followers_comments = {}
while True:
line = input()
if line == 'Log out':
break
args = line.split(': ')
command = args[0]
username = args[1]
if command == 'New follower':
if username not in followers_likes and username not in followers_comments:
fo... |
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DEPS = [
'core',
'recipe_engine/path',
'recipe_engine/properties',
]
def RunSteps(api):
api.core.setup()
def GenTests(api):
buildername = 'Bui... | deps = ['core', 'recipe_engine/path', 'recipe_engine/properties']
def run_steps(api):
api.core.setup()
def gen_tests(api):
buildername = 'Build-Win-Clang-x86_64-Release-Vulkan'
yield (api.test('test') + api.properties(buildername=buildername, repository='https://skia.googlesource.com/skia.git', revision='... |
a=int(input("Enter a Number"))
if (a%2==0):
print(a,"Entered Number is Divisible by 2")
if(a%5==0):
print(a,"Entered Number is Divisible by 5")
else:
print(a,"Entered Number is Not Divisible by 5")
else:
print(a,"Entered Number is Not Divisible by 2")
| a = int(input('Enter a Number'))
if a % 2 == 0:
print(a, 'Entered Number is Divisible by 2')
if a % 5 == 0:
print(a, 'Entered Number is Divisible by 5')
else:
print(a, 'Entered Number is Not Divisible by 5')
else:
print(a, 'Entered Number is Not Divisible by 2') |
s = map(ord, input())
r = 0
c = 0
a = ord('a')
z = ord('z')
for x in s:
if a <= x <= z:
x -= a
r += min(abs(x - c), 26 - abs(x - c))
c = x
else:
break
print(r)
| s = map(ord, input())
r = 0
c = 0
a = ord('a')
z = ord('z')
for x in s:
if a <= x <= z:
x -= a
r += min(abs(x - c), 26 - abs(x - c))
c = x
else:
break
print(r) |
# generated by scripts/build_keyboard_adjacency_graphs.py
ADJACENCY_GRAPHS = {
"qwerty": {"!": ["`~", None, None, "2@", "qQ", None], "\"": [";:", "[{", "]}", None, None, "/?"], "#": ["2@", None, None, "4$", "eE", "wW"], "$": ["3#", None, None, "5%", "rR", "eE"], "%": ["4$", None, None, "6^", "tT", "rR"], "&": ["6^"... | adjacency_graphs = {'qwerty': {'!': ['`~', None, None, '2@', 'qQ', None], '"': [';:', '[{', ']}', None, None, '/?'], '#': ['2@', None, None, '4$', 'eE', 'wW'], '$': ['3#', None, None, '5%', 'rR', 'eE'], '%': ['4$', None, None, '6^', 'tT', 'rR'], '&': ['6^', None, None, '8*', 'uU', 'yY'], "'": [';:', '[{', ']}', None, N... |
class Solution:
def __init__(self, rects):
self.rects, self.ranges, sm = rects, [], 0
for x1, y1, x2, y2 in rects:
sm += (x2 - x1 + 1) * (y2 - y1 + 1)
self.ranges.append(sm)
def pick(self):
x1, y1, x2, y2 = self.rects[bisect.bisect_left(self.ranges, random.randi... | class Solution:
def __init__(self, rects):
(self.rects, self.ranges, sm) = (rects, [], 0)
for (x1, y1, x2, y2) in rects:
sm += (x2 - x1 + 1) * (y2 - y1 + 1)
self.ranges.append(sm)
def pick(self):
(x1, y1, x2, y2) = self.rects[bisect.bisect_left(self.ranges, rand... |
class FoldrNode(object):
def __init__(self, depth, code):
'''
>>> node = FoldrNode(0,'aaa')
>>> node.add(FoldrNode(1,'bbb'))
>>> node.add(FoldrNode(2,'ccc'))
>>> node.depth
0
>>> node.code
'aaa'
>>> node.parent
'''
self.dept... | class Foldrnode(object):
def __init__(self, depth, code):
"""
>>> node = FoldrNode(0,'aaa')
>>> node.add(FoldrNode(1,'bbb'))
>>> node.add(FoldrNode(2,'ccc'))
>>> node.depth
0
>>> node.code
'aaa'
>>> node.parent
"""
self.dept... |
class Common(object):
def __init__(self):
pass
def start(self, f, title):
f.writelines("[TITLE]\n")
f.writelines(title)
f.writelines("\n")
f.writelines("\n")
def end(self, f):
f.writelines("[END]")
f.writelines("\n")
def export_tags(self, f):
... | class Common(object):
def __init__(self):
pass
def start(self, f, title):
f.writelines('[TITLE]\n')
f.writelines(title)
f.writelines('\n')
f.writelines('\n')
def end(self, f):
f.writelines('[END]')
f.writelines('\n')
def export_tags(self, f):
... |
# Flask settings
DEBUG = False
SQLALCHEMY_DATABASE_URI = "sqlite:///hortiradar.sqlite"
CSRF_ENABLED = True
# Flask-Babel
BABEL_DEFAULT_LOCALE = "nl"
# Flask-Mail settings
MAIL_USERNAME = "noreply@acba.labs.vu.nl"
MAIL_DEFAULT_SENDER = '"Hortiradar" <noreply@acba.labs.vu.nl>'
MAIL_SERVER = "localhost"
MAIL_PORT = 25
#... | debug = False
sqlalchemy_database_uri = 'sqlite:///hortiradar.sqlite'
csrf_enabled = True
babel_default_locale = 'nl'
mail_username = 'noreply@acba.labs.vu.nl'
mail_default_sender = '"Hortiradar" <noreply@acba.labs.vu.nl>'
mail_server = 'localhost'
mail_port = 25
user_app_name = 'Hortiradar'
user_enable_login_without_c... |
def bubble_sort(arr):
for i in range(len(arr)):
for j in range(0, len(arr) - i - 1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
array = [5, 3, 2, 4, 11, 9, 15, 7]
bubble_sort(array)
print(array) | def bubble_sort(arr):
for i in range(len(arr)):
for j in range(0, len(arr) - i - 1):
if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
array = [5, 3, 2, 4, 11, 9, 15, 7]
bubble_sort(array)
print(array) |
# Epiphany (25512) | Luminous 4th Job
if chr.getJob() == 2711:
sm.flipDialoguePlayerAsSpeaker()
sm.sendNext("(I feel the Light and Dark within me coming together, "
"merging into a new kind of energy!)")
sm.sendSay("(I've reached a new level of balance between the Light and Dark.)")
sm.jobAdvance(... | if chr.getJob() == 2711:
sm.flipDialoguePlayerAsSpeaker()
sm.sendNext('(I feel the Light and Dark within me coming together, merging into a new kind of energy!)')
sm.sendSay("(I've reached a new level of balance between the Light and Dark.)")
sm.jobAdvance(2712)
sm.startQuest(parentID)
sm.comple... |
'''
Graph as:
- Vertex/node - contains name "key", data "payload"
- Edge - connects 2 vertices, symbolizing relationship
- Weight - cost to traverse vertex
- G = (V,E) (V=vertex, E=edges)
ex.) V = {V0..V5}, E = {(V0, V1, 5), (V1, V2, 2) ...}
- Path - sequence of vertices connected by edges
- Cycle - path that start... | """
Graph as:
- Vertex/node - contains name "key", data "payload"
- Edge - connects 2 vertices, symbolizing relationship
- Weight - cost to traverse vertex
- G = (V,E) (V=vertex, E=edges)
ex.) V = {V0..V5}, E = {(V0, V1, 5), (V1, V2, 2) ...}
- Path - sequence of vertices connected by edges
- Cycle - path that start... |
class Solution:
def numSquares(self, n: int) -> int:
if n==1:
return n
dp=[(n+1) for i in range(n+1)]
sq=[i**2 for i in range(int(sqrt(n))+1)]
for i in range(len(dp)):
if i in sq:
dp[i]=1
else:
for j in sq:
... | class Solution:
def num_squares(self, n: int) -> int:
if n == 1:
return n
dp = [n + 1 for i in range(n + 1)]
sq = [i ** 2 for i in range(int(sqrt(n)) + 1)]
for i in range(len(dp)):
if i in sq:
dp[i] = 1
else:
for j ... |
# Your Nessus Scanner API Keys
ACCESS_KEY = "Your_Nessus_Access_Key"
SECRET_KEY = "Your_Nessus_SecretKey"
# Your URL for the API
API_URL = "https://nessus.yourInfo.com"
# The Port Number
API_PORT = "1234"
# Warnings Greater than or equal to the number you want
SEVERITY = '1' # Meaning we will see 1 and above
# Bef... | access_key = 'Your_Nessus_Access_Key'
secret_key = 'Your_Nessus_SecretKey'
api_url = 'https://nessus.yourInfo.com'
api_port = '1234'
severity = '1'
directory = False
email = False
email_address = 'Send_Emails_From_Here@site.com'
password = ''
delimiter = ':' |
def create_python_script(filename):
comments = "# Start of a new Python program"
with open("program.py","w") as f:
filesize = f.write(comments)
return(filesize)
print(create_python_script("program.py")) | def create_python_script(filename):
comments = '# Start of a new Python program'
with open('program.py', 'w') as f:
filesize = f.write(comments)
return filesize
print(create_python_script('program.py')) |
# The following RTTTL tunes were extracted from the following:
# https://github.com/onebeartoe/media-players/blob/master/pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/BuiltInSongs.java
# most of which originated from here:
# http://www.picaxe.com/RTTTL-Ringtones-for-Tune-Command/
#
SONGS = [
'Super M... | songs = ['Super Mario - Main Theme:d=4,o=5,b=125:a,8f.,16c,16d,16f,16p,f,16d,16c,16p,16f,16p,16f,16p,8c6,8a.,g,16c,a,8f.,16c,16d,16f,16p,f,16d,16c,16p,16f,16p,16a#,16a,16g,2f,16p,8a.,8f.,8c,8a.,f,16g#,16f,16c,16p,8g#.,2g,8a.,8f.,8c,8a.,f,16g#,16f,8c,2c6', 'Super Mario - Title Music:d=4,o=5,b=125:8d7,8d7,8d7,8d6,8d7,8d7... |
# config file name
RIGOR_YML = "rigor.yml"
# content-types
TEXT_HTML = "text/html"
TEXT_PLAIN = "text/plain"
APPLICATION_JSON = "application/json"
# headers
CONTENT_TYPE = "Content-Type"
| rigor_yml = 'rigor.yml'
text_html = 'text/html'
text_plain = 'text/plain'
application_json = 'application/json'
content_type = 'Content-Type' |
__char_num = [('a',0),('b',1),('c',2),('d',3),('e',4),('f',5),('g',6),('h',7),('i',8),('j',9),('k',10),('l',11),('m',12),('n',13),('o',14),('p',15),('q',16),('r',17),('s',18),('t',19),('u',20),('v',21),('w',22),('x',23),('y',24),('z',25)]
def char2num(char):
return next(filter(lambda x: x[0] == char.lower(), __... | __char_num = [('a', 0), ('b', 1), ('c', 2), ('d', 3), ('e', 4), ('f', 5), ('g', 6), ('h', 7), ('i', 8), ('j', 9), ('k', 10), ('l', 11), ('m', 12), ('n', 13), ('o', 14), ('p', 15), ('q', 16), ('r', 17), ('s', 18), ('t', 19), ('u', 20), ('v', 21), ('w', 22), ('x', 23), ('y', 24), ('z', 25)]
def char2num(char):
retur... |
class Solution:
def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:
def intersect(p_left, p_right, q_left, q_right):
return min(p_right, q_right) > max(p_left, q_left)
return (intersect(rec1[0], rec1[2], rec2[0], rec2[2]) and intersect(rec1[1], rec1[3], rec2[1], rec2[3]))
| class Solution:
def is_rectangle_overlap(self, rec1: List[int], rec2: List[int]) -> bool:
def intersect(p_left, p_right, q_left, q_right):
return min(p_right, q_right) > max(p_left, q_left)
return intersect(rec1[0], rec1[2], rec2[0], rec2[2]) and intersect(rec1[1], rec1[3], rec2[1], re... |
__all__ = [
"messenger",
"writer",
"processor",
"listener",
]
| __all__ = ['messenger', 'writer', 'processor', 'listener'] |
class Solution:
def hammingDistance(self, x: int, y: int) -> int:
if x < 0 or y < 0:
raise Exception("Negative Input(s)")
h_dist = 0
while x > 0 or y > 0:
if (x ^ y) & 1 == 1:
h_dist += 1
x >>= 1
y >>= 1
return h_dist
| class Solution:
def hamming_distance(self, x: int, y: int) -> int:
if x < 0 or y < 0:
raise exception('Negative Input(s)')
h_dist = 0
while x > 0 or y > 0:
if (x ^ y) & 1 == 1:
h_dist += 1
x >>= 1
y >>= 1
return h_dist |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def helper(self, l1, r1, l2, r2):
if l1 > r1: return None
mid = self.postorder[r2]
... | class Solution:
def helper(self, l1, r1, l2, r2):
if l1 > r1:
return None
mid = self.postorder[r2]
mid_idx = self.inorder.index(mid)
left_size = mid_idx - l1
return tree_node(mid, self.helper(l1, l1 + left_size - 1, l2, l2 + left_size - 1), self.helper(mid_idx + ... |
def mergeSort(alist):
if len(alist) > 1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
mergeSort(lefthalf)
mergeSort(righthalf)
i = 0; j = 0; k = 0
while i < len(lefthalf) and j < len(righthalf):
if lefthalf[i] < righthalf[j]... | def merge_sort(alist):
if len(alist) > 1:
mid = len(alist) // 2
lefthalf = alist[:mid]
righthalf = alist[mid:]
merge_sort(lefthalf)
merge_sort(righthalf)
i = 0
j = 0
k = 0
while i < len(lefthalf) and j < len(righthalf):
if lefthalf[... |
#AREA DO CIRCULO
r= float(input())
resultado= 3.14* r**2/10000
print("Area={:.4f}".format(resultado) )
| r = float(input())
resultado = 3.14 * r ** 2 / 10000
print('Area={:.4f}'.format(resultado)) |
#!/usr/bin/env python3
def has_dups(data):
for i in data:
if data.count(i) > 1:
return True
else:
return False
print(has_dups([1, 2, 3]))
print(has_dups([1,1,2,3])) | def has_dups(data):
for i in data:
if data.count(i) > 1:
return True
else:
return False
print(has_dups([1, 2, 3]))
print(has_dups([1, 1, 2, 3])) |
headers = {'User-Agent': 'Mozilla/5.0 Chrome/86.0.4240.75'}
# Enter the URL of the product page on flipkart
PRODUCT_URL = 'enter_url_here'
# Enter the threshhold price of the product
THRESHHOLD = 6969.0
# Enter your email address
MY_EMAIL = ''
# Enter your password (Check readme.md for steps to get app password)
MY_APP... | headers = {'User-Agent': 'Mozilla/5.0 Chrome/86.0.4240.75'}
product_url = 'enter_url_here'
threshhold = 6969.0
my_email = ''
my_app_password = ''
check_again = 60 * 30
receiver_email = '' |
# Key Arbitrary
def build_profile(first, last, **user_info):
profile = {}
profile['first'] = first
profile['last'] = last
for key, value in user_info.items():
profile[key] = value
return profile
user_profile0 = build_profile('albert', 'einstein', location = 'princeton', field = 'physics')
user_profile1 = build_... | def build_profile(first, last, **user_info):
profile = {}
profile['first'] = first
profile['last'] = last
for (key, value) in user_info.items():
profile[key] = value
return profile
user_profile0 = build_profile('albert', 'einstein', location='princeton', field='physics')
user_profile1 = buil... |
COMMIT="12c255d13729fb571e4964f4f0a97ddba4bbe0d2"
VERSION="1.1-53-g12c255d"
DICTCOMMIT="8f414ce140263ac8c378d4e7bc97c035ade85aa7"
DICTVERSION="0.2.0"
| commit = '12c255d13729fb571e4964f4f0a97ddba4bbe0d2'
version = '1.1-53-g12c255d'
dictcommit = '8f414ce140263ac8c378d4e7bc97c035ade85aa7'
dictversion = '0.2.0' |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isSameTree(self, p: 'TreeNode', q: 'TreeNode') -> 'bool':
def helper(p,q):
if not p and not q:
... | class Solution:
def is_same_tree(self, p: 'TreeNode', q: 'TreeNode') -> 'bool':
def helper(p, q):
if not p and (not q):
return True
if not p and q or (p and (not q)) or p.val != q.val:
return False
return helper(p.left, q.left) and helper... |
text_based = ["perspective_score", "identity_attack",
"sentiment",
"Please", "Please_start", "HASHEDGE",
"Indirect_(btw)",
"Hedges",
"Factuality", "Deference", "Gratitude", "Apologizing",
"1st_person_pl.", "1... | text_based = ['perspective_score', 'identity_attack', 'sentiment', 'Please', 'Please_start', 'HASHEDGE', 'Indirect_(btw)', 'Hedges', 'Factuality', 'Deference', 'Gratitude', 'Apologizing', '1st_person_pl.', '1st_person', '1st_person_start', '2nd_person', '2nd_person_start', 'Indirect_(greeting)', 'Direct_question', 'Dir... |
#Submitted by thr3sh0ld
#logic: Readable code
class Solution:
def largestDivisibleSubset(self, nums: List[int]) -> List[int]:
if len(nums) == 0 or len(nums) == 1:
return nums
nums.sort(reverse= False)
l = len(nums)
count = [1 for i in range(l)] #dp
prev = [-1 f... | class Solution:
def largest_divisible_subset(self, nums: List[int]) -> List[int]:
if len(nums) == 0 or len(nums) == 1:
return nums
nums.sort(reverse=False)
l = len(nums)
count = [1 for i in range(l)]
prev = [-1 for i in range(l)]
max_ind = 0
for i... |
int('0x7e0', 0)
# 2016
int('7e0', 16)
# 2016
hex(2016)
# '0x7e0' | int('0x7e0', 0)
int('7e0', 16)
hex(2016) |
#!/usr/bin/env python3.6.4
# encoding: utf-8
# @Time : 2018/6/24 14:40
# @Author : penghaibo
# @contact: xxxx@qq.com
# @Site :
# @File : config.py
# @Software: PyCharm
appkey = "d391709bada01c89be6dba753752bcd5"
host = "http://v.juhe.cn/historyWeather/" | appkey = 'd391709bada01c89be6dba753752bcd5'
host = 'http://v.juhe.cn/historyWeather/' |
#
# PySNMP MIB module A100-R1-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A100-R1-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 16:48:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_range_constraint, constraints_union, value_size_constraint) ... |
#
# PySNMP MIB module HPN-ICF-DOT11-LIC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-DOT11-LIC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:25:45 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, single_value_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
lista_alunos=[]
lista_notas=[]
n1=0
n2=1
n3=2
n4=3
for i in range(0,10,1):
lista_alunos.append(str(input('Digite seu nome:')))
for i in range(0,1,1):
lista_notas.append(float(input('Digite a primeira nota:')))
lista_notas.append(float(input('Digite a segunda nota:')))
lista_notas.append(... | lista_alunos = []
lista_notas = []
n1 = 0
n2 = 1
n3 = 2
n4 = 3
for i in range(0, 10, 1):
lista_alunos.append(str(input('Digite seu nome:')))
for i in range(0, 1, 1):
lista_notas.append(float(input('Digite a primeira nota:')))
lista_notas.append(float(input('Digite a segunda nota:')))
lis... |
def simple_generator():
for i in range(5):
yield i
def run_simple_generator():
for j in simple_generator():
print(f"For loop: {j}")
sg = simple_generator()
print(f"Next value: {next(sg)}")
print(f"Next value: {next(sg)}")
print(f"Next value: {next(sg)}")
my_gen = simple_... | def simple_generator():
for i in range(5):
yield i
def run_simple_generator():
for j in simple_generator():
print(f'For loop: {j}')
sg = simple_generator()
print(f'Next value: {next(sg)}')
print(f'Next value: {next(sg)}')
print(f'Next value: {next(sg)}')
my_gen = simple_gene... |
my_variable = 'hello'
my_list_variable = ['hello', 'hi', 'nice to meet you']
my_tuple_variable = ('hello', 'hi', 'nice to meet you') # we can not increase the size of a tuple, it's immutable
my_set_variable = {'hello', 'hi', 'nice to meet you'} # Unique and unordered
print(my_list_variable)
print(my_tuple_variable)
pr... | my_variable = 'hello'
my_list_variable = ['hello', 'hi', 'nice to meet you']
my_tuple_variable = ('hello', 'hi', 'nice to meet you')
my_set_variable = {'hello', 'hi', 'nice to meet you'}
print(my_list_variable)
print(my_tuple_variable)
print(my_set_variable)
my_short_tuple_variable = ('hello',)
another_short_tuple_vari... |
# -*- coding: utf-8 -*-
DEFAULT_SETTINGS_MODULE = True
APP_B_FOO = "foo"
| default_settings_module = True
app_b_foo = 'foo' |
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'use_system_sqlite%': 0,
},
'target_defaults': {
'defines': [
'SQLITE_CORE',
'SQLITE_ENABLE_BROKEN_FTS3',
... | {'variables': {'use_system_sqlite%': 0}, 'target_defaults': {'defines': ['SQLITE_CORE', 'SQLITE_ENABLE_BROKEN_FTS3', 'DSQLITE_ENABLE_FTS3_PARENTHESIS', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_FTS4', 'SQLITE_ENABLE_MEMORY_MANAGEMENT', 'SQLITE_SECURE_DELETE', 'SQLITE_SEPARATE_CACHE_POOLS', 'THREADSAFE', '_HAS_EXCEPTIONS=0']... |
seriffont = {"Width": 6, "Height": 8, "Start": 32, "End": 127, "Data": bytearray([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, #0x00,
0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, #0x00,
0x03, 0x00, 0x03, 0x00, 0x00, 0x00, #0x00,
0x12, 0x3F, 0x12, 0x3F, 0x12, 0x00, #0x00,
0x26, 0x7F, 0x32, 0x00, 0x00, 0x00, #0x00,
0x13, 0x0... | seriffont = {'Width': 6, 'Height': 8, 'Start': 32, 'End': 127, 'Data': bytearray([0, 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 0, 18, 63, 18, 63, 18, 0, 38, 127, 50, 0, 0, 0, 19, 11, 52, 50, 0, 0, 26, 37, 26, 40, 0, 0, 3, 0, 0, 0, 0, 0, 126, 129, 0, 0, 0, 0, 129, 126, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 8, 28, 8, 0, 0... |
London_walk = ox.graph_from_place('London, UK', network_type='walk')
London_walk_simple=nx.Graph(London_walk)
street_bus=London_walk_simple.copy()
street_bus.add_nodes_from(BN.nodes(data=True))
street_bus.add_edges_from(BN.edges(data=True))
# create tree
street_nodes=[]
for node,data in London_walk_simple.nodes(data=... | london_walk = ox.graph_from_place('London, UK', network_type='walk')
london_walk_simple = nx.Graph(London_walk)
street_bus = London_walk_simple.copy()
street_bus.add_nodes_from(BN.nodes(data=True))
street_bus.add_edges_from(BN.edges(data=True))
street_nodes = []
for (node, data) in London_walk_simple.nodes(data=True):
... |
# 18 > = Adult
# 5-17 = Child
# >0 - 5 = Infant
your_age = int(input("Enter you age : "))
if your_age >= 18 :
print("ADULT")
elif your_age > 5 :
print("CHILD")
else :
print("INFANT")
| your_age = int(input('Enter you age : '))
if your_age >= 18:
print('ADULT')
elif your_age > 5:
print('CHILD')
else:
print('INFANT') |
class Solution:
def solve(self, matrix):
dp = [[[None,0,0,0] for x in range(len(matrix[0])+1)] for y in range(len(matrix)+1)]
ans = 0
for y in range(len(matrix)):
for x in range(len(matrix[0])):
coeff0 = 1 if matrix[y][x] == dp[y-1][x][0] == dp[y][x-1][0] == dp[y-1][x-... | class Solution:
def solve(self, matrix):
dp = [[[None, 0, 0, 0] for x in range(len(matrix[0]) + 1)] for y in range(len(matrix) + 1)]
ans = 0
for y in range(len(matrix)):
for x in range(len(matrix[0])):
coeff0 = 1 if matrix[y][x] == dp[y - 1][x][0] == dp[y][x - 1]... |
class Solution:
def bitwiseComplement(self, N: int) -> int:
if N == 0:
return 1
tmp = []
while N:
t = N % 2
N //= 2
tmp.append(1-t)
ans = 0
for k in range(len(tmp)-1, -1, -1):
ans += tmp[k] * 2**k
return ans
... | class Solution:
def bitwise_complement(self, N: int) -> int:
if N == 0:
return 1
tmp = []
while N:
t = N % 2
n //= 2
tmp.append(1 - t)
ans = 0
for k in range(len(tmp) - 1, -1, -1):
ans += tmp[k] * 2 ** k
ret... |
#
# PySNMP MIB module ACMEPACKET-ENVMON-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ACMEPACKET-ENVMON-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:13:15 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (acmepacket_mgmt,) = mibBuilder.importSymbols('ACMEPACKET-SMI', 'acmepacketMgmt')
(ap_redundancy_state, ap_hardware_module_family, ap_phy_port_type, ap_presence) = mibBuilder.importSymbols('ACMEPACKET-TC', 'ApRedundancyState', 'ApHardwareModuleFamily', 'ApPhyPortType', 'ApPresence')
(object_identifier, integer, octet_s... |
#
# PySNMP MIB module M2000-V1 (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/M2000-V1
# Produced by pysmi-0.3.4 at Mon Apr 29 19:59:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:1... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ... |
Experiment(description='More kernels but no RQ',
data_dir='../data/tsdl/',
max_depth=8,
random_order=False,
k=1,
debug=False,
local_computation=False,
n_rand=9,
sd=4,
max_jobs=400,
verbose=False,
... | experiment(description='More kernels but no RQ', data_dir='../data/tsdl/', max_depth=8, random_order=False, k=1, debug=False, local_computation=False, n_rand=9, sd=4, max_jobs=400, verbose=False, make_predictions=False, skip_complete=True, results_dir='../results/2013-08-14-no-rq/', iters=500, base_kernels='IBM,IBMLin,... |
class Solution:
def deleteDuplicates(self, head):
if head:
p = head.next
while p and p.val == head.val:
p = p.next
head.next = self.deleteDuplicates(p)
return head
| class Solution:
def delete_duplicates(self, head):
if head:
p = head.next
while p and p.val == head.val:
p = p.next
head.next = self.deleteDuplicates(p)
return head |
# getting these names wrong on the mocks will result in always passing tests
# instead of calling methods on the mock, call these (where typos will fail)
def assert_called_once_with(mock, *args, **kwargs):
mock.assert_called_once_with(*args, **kwargs)
def assert_called_with(mock, *args, **kwargs):
mock.ass... | def assert_called_once_with(mock, *args, **kwargs):
mock.assert_called_once_with(*args, **kwargs)
def assert_called_with(mock, *args, **kwargs):
mock.assert_called_with(*args, **kwargs)
def assert_has_calls(mock, *args, **kwargs):
mock.assert_has_calls(*args, **kwargs) |
#
# PySNMP MIB module CTRON-SSR-HARDWARE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-SSR-HARDWARE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:31:24 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')
(value_size_constraint, value_range_constraint, constraints_intersection, single_value_constraint, constraints_union) ... |
# Area and perimeter of a rectangle in the plane
# A rectangle is given by the coordinates of two of its opposite angles (x1, y1) - (x2, y2).
# Calculate its area and perimeter . The input is read from the console. The numbers x1, y1, x2 and y2 are given one per line.
# The output is displayed on the console and must c... | x1 = float(input())
y1 = float(input())
x2 = float(input())
y2 = float(input())
side_1 = abs(x2 - x1)
side_2 = abs(y2 - y1)
area = side_1 * side_2
perimeter = 2 * (side_1 + side_2)
print(area)
print(perimeter) |
#
# PySNMP MIB module CPQSTSYS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CPQSTSYS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:27:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint, constraints_union) ... |
def encoded_from_base10(number, base, digit_map):
'''
This function returns a string encoding in the "base" for the the "number" using the "digit_map"
Conditions that this function must satisfy:
- 2 <= base <= 36 else raise ValueError
- invalid base ValueError must have relevant information
- di... | def encoded_from_base10(number, base, digit_map):
"""
This function returns a string encoding in the "base" for the the "number" using the "digit_map"
Conditions that this function must satisfy:
- 2 <= base <= 36 else raise ValueError
- invalid base ValueError must have relevant information
- di... |
#config.py
#Enable Flask"s debugging features. should be False in production
DEBUG = True | debug = True |
# Problem Statement: https://www.hackerrank.com/challenges/ginorts/problem
S = ''.join(sorted(input(), key=lambda x: (not x.islower(),
not x.isupper(),
not x in '13579',
x)))
print(S) | s = ''.join(sorted(input(), key=lambda x: (not x.islower(), not x.isupper(), not x in '13579', x)))
print(S) |
class InitCommands(object):
COPY = 'copy'
CREATE = 'create'
DELETE = 'delete'
@classmethod
def is_copy(cls, command):
return command == cls.COPY
@classmethod
def is_create(cls, command):
return command == cls.CREATE
@classmethod
def is_delete(cls, command):
... | class Initcommands(object):
copy = 'copy'
create = 'create'
delete = 'delete'
@classmethod
def is_copy(cls, command):
return command == cls.COPY
@classmethod
def is_create(cls, command):
return command == cls.CREATE
@classmethod
def is_delete(cls, command):
... |
hm_epoch = 5 # Number of epoch in training
lag_range = 1 # Lag range
lag_epoch_num = 1 # Number of epoch while finding lag
learning_rate = 0.001 # Default learning rate
| hm_epoch = 5
lag_range = 1
lag_epoch_num = 1
learning_rate = 0.001 |
#
# PySNMP MIB module NOKIA-HWM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NOKIA-HWM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:23:29 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... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, constraints_intersection, single_value_constraint, value_range_constraint) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.