content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
'''Functions for calculating weighted aggregates of PV system data.'''
def aggregation_insol(energy_normalized, insolation, frequency='D'):
'''
Insolation weighted aggregation
Parameters
----------
energy_normalized : pd.Series
Normalized energy time series
insolation : pd.Series
... | """Functions for calculating weighted aggregates of PV system data."""
def aggregation_insol(energy_normalized, insolation, frequency='D'):
"""
Insolation weighted aggregation
Parameters
----------
energy_normalized : pd.Series
Normalized energy time series
insolation : pd.Series
... |
def perfect_number(num):
result = []
count = 1
for divisor in range(1, num):
if num % count == 0:
result.append(count)
count += 1
else:
count += 1
if not sum(result) == num:
print("It's not so perfect.")
else:
print("We have a perfe... | def perfect_number(num):
result = []
count = 1
for divisor in range(1, num):
if num % count == 0:
result.append(count)
count += 1
else:
count += 1
if not sum(result) == num:
print("It's not so perfect.")
else:
print('We have a perfe... |
class CommonConfig:
CMAKE_BINS = ['cmake', 'cmake3']
VEHICLE_TYPES = ['car', 'pedestrian', 'bicycle', 'transit']
| class Commonconfig:
cmake_bins = ['cmake', 'cmake3']
vehicle_types = ['car', 'pedestrian', 'bicycle', 'transit'] |
WTF_CSRF_ENABLED = True
SECRET_KEY = 'you-will-never-guess'
# MONGO_DBNAME = ''
# MONGO_URI = ''
| wtf_csrf_enabled = True
secret_key = 'you-will-never-guess' |
class SceneBase:
def __init__(self, screen=None):
self.next = self
self.screen = screen
def ProcessInput(self, events, pressed_keys):
print("Did not override this in the child class")
def Update(self, deltatime):
print("Did not override this in the child class")
... | class Scenebase:
def __init__(self, screen=None):
self.next = self
self.screen = screen
def process_input(self, events, pressed_keys):
print('Did not override this in the child class')
def update(self, deltatime):
print('Did not override this in the child class')
def ... |
# Medium
# https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/submissions/
# TC: O(N)
# SC: O(N)
# 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 =... | class Solution:
def build_tree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
def solve(l, h):
nonlocal i
if l > h:
return None
node = tree_node(preorder[i])
i += 1
if l == h:
return node
i... |
def lettercount():
word = input('Type any string: ').lower()
Finder=input ('Write the alphabet you want the count for? ').lower()
#Alphabet counter
count = 0
for letter in word:
if letter == Finder:
count = count + 1
print('Total number of','"',Finder,'"','count= ', count... | def lettercount():
word = input('Type any string: ').lower()
finder = input('Write the alphabet you want the count for? ').lower()
count = 0
for letter in word:
if letter == Finder:
count = count + 1
print('Total number of', '"', Finder, '"', 'count= ', count)
tot = 0
... |
print(1+True)
print(1+False)
print(True+False)
#
# print(type(123))
# print(type("hello"))
# print(type(b"hello"))
#
# # a=3 if 2>1 else 5
#
# s="hello"
# s=str()
#
# l=[1,23,4]
# l2=list([1,2,34,6])
print("---".join(["hello","world"]))
def f():
print(123)
| print(1 + True)
print(1 + False)
print(True + False)
print('---'.join(['hello', 'world']))
def f():
print(123) |
t = int(input())
for i in range(t):
b = int(input())
e = str(input()).split()
a1 = int(e[0])
d1 = int(e[1])
l1 = int(e[2])
e = str(input()).split()
a2 = int(e[0])
d2 = int(e[1])
l2 = int(e[2])
d = (a1 + d1) / 2
g = (a2 + d2) / 2
d = d + b if (l1 % 2 == 0) else d
g = g... | t = int(input())
for i in range(t):
b = int(input())
e = str(input()).split()
a1 = int(e[0])
d1 = int(e[1])
l1 = int(e[2])
e = str(input()).split()
a2 = int(e[0])
d2 = int(e[1])
l2 = int(e[2])
d = (a1 + d1) / 2
g = (a2 + d2) / 2
d = d + b if l1 % 2 == 0 else d
g = g +... |
# Write a Python program to check if a given positive integer is a power of two
def ispower2(num):
count = 0
for x in range(1000):
if 2**x == num:
count += 1
return count > 0
print(ispower2(32))
print(ispower2(50))
print(ispower2(25)) | def ispower2(num):
count = 0
for x in range(1000):
if 2 ** x == num:
count += 1
return count > 0
print(ispower2(32))
print(ispower2(50))
print(ispower2(25)) |
'''
https://leetcode.com/explore/challenge/card/september-leetcoding-challenge/556/week-3-september-15th-september-21st/3464
'''
class Solution:
def maxProfit(self, prices: List[int]) -> int:
n=len(prices)
if n==0 or n==1: return 0
profit=0
minNum=prices[0]
for i in range(1,n... | """
https://leetcode.com/explore/challenge/card/september-leetcoding-challenge/556/week-3-september-15th-september-21st/3464
"""
class Solution:
def max_profit(self, prices: List[int]) -> int:
n = len(prices)
if n == 0 or n == 1:
return 0
profit = 0
min_num = prices[0]
... |
# What is 7 power 4
print(7**4)
# Print a list
aString = 'Hi there Sam!'
aList = list(aString.split())
print(aList)
# Return domain address
email = 'samuel.dufresne@mindgeek.com'
after_at = False
domain = ''
print(len(email))
for index in range(0, len(email)):
if after_at:
domain += email[index]
if email[index] =... | print(7 ** 4)
a_string = 'Hi there Sam!'
a_list = list(aString.split())
print(aList)
email = 'samuel.dufresne@mindgeek.com'
after_at = False
domain = ''
print(len(email))
for index in range(0, len(email)):
if after_at:
domain += email[index]
if email[index] == '@':
after_at = True
print(domain)
... |
# http://www.codewars.com/kata/55d24f55d7dd296eb9000030/
def summation(num):
return sum(xrange(num + 1))
| def summation(num):
return sum(xrange(num + 1)) |
# Q1 a program to find grestest no among four no enterd by user.
'''
a = int(input("Enter no 1 "))
b = int(input("Enter no 2 "))
c = int(input("Enter no 3 "))
d = int(input("Enter no 4 "))
'''
'''
if (a>b and a>c and a>d):
print(a ,"a is greater")
elif(b>a and b>c and b>d):
print(b , "b is greater")
elif(c>... | """
a = int(input("Enter no 1 "))
b = int(input("Enter no 2 "))
c = int(input("Enter no 3 "))
d = int(input("Enter no 4 "))
"""
'\nif (a>b and a>c and a>d):\n print(a ,"a is greater")\nelif(b>a and b>c and b>d):\n print(b , "b is greater") \nelif(c>a and c>b and c>d):\n print(c ,"c is greater")\nelse:\n ... |
def findDecision(obj): #obj[0]: Passanger, obj[1]: Weather, obj[2]: Time, obj[3]: Coupon, obj[4]: Coupon_validity, obj[5]: Gender, obj[6]: Age, obj[7]: Maritalstatus, obj[8]: Children, obj[9]: Education, obj[10]: Occupation, obj[11]: Income, obj[12]: Bar, obj[13]: Coffeehouse, obj[14]: Restaurantlessthan20, obj[15]: Re... | def find_decision(obj):
if obj[10] > 4:
if obj[12] <= 0.0:
if obj[13] > 0.0:
if obj[14] <= 2.0:
return 'True'
elif obj[14] > 2.0:
return 'False'
else:
return 'False'
elif obj[1... |
#
# PySNMP MIB module F10-FPSTATS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/F10-FPSTATS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:57:19 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, value_size_constraint, constraints_union, single_value_constraint) ... |
a = 2;
b = 5;
c = 4;
| a = 2
b = 5
c = 4 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT
_DATA_ROOT = 'Datasets/'
datasets = {"RIMEScharH32W16": _DATA_ROOT+'RIMES/h32char16to17/tr',
"RIMEScharH32": _DATA_ROOT+'RIMES/h32/tr',
"RIMEScharH32te": _DATA_ROOT+'RIMES/h32/te',
"R... | _data_root = 'Datasets/'
datasets = {'RIMEScharH32W16': _DATA_ROOT + 'RIMES/h32char16to17/tr', 'RIMEScharH32': _DATA_ROOT + 'RIMES/h32/tr', 'RIMEScharH32te': _DATA_ROOT + 'RIMES/h32/te', 'RIMEScharH32val': _DATA_ROOT + 'RIMES/h32/val', 'IAMcharH32W16rmPunct': _DATA_ROOT + 'IAM/words/h32char16to17/tr_removePunc', 'IAMch... |
# Solution
def max_sum_subarray(arr):
max_sum = arr[0]
current_sum = arr[0]
for num in arr[1:]:
current_sum = max(current_sum + num, num)
max_sum = max(current_sum, max_sum)
return max_sum | def max_sum_subarray(arr):
max_sum = arr[0]
current_sum = arr[0]
for num in arr[1:]:
current_sum = max(current_sum + num, num)
max_sum = max(current_sum, max_sum)
return max_sum |
'''
Define a class with a generator which can iterate the numbers, which
are divisible by 7, between a given range 0 and n.
https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt#L545
'''
### WITH A GENERATOR
def divisible_by_seven(max_value):... | """
Define a class with a generator which can iterate the numbers, which
are divisible by 7, between a given range 0 and n.
https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt#L545
"""
def divisible_by_seven(max_value):
current_value = 1
... |
#python
#-------------------------------------------------------------------------------
# Name:pp_poly_collapse
# Version: 1.0
# Purpose: This script is designed to collapse the selected polys without affecting
#the surrounding geometry.
#
# Author: William Vaughan, pushingpoints.com
#
# Created: 01/21/2014
... | lx.eval('tool.set poly.bevel on')
lx.eval('tool.reset poly.bevel')
lx.eval('tool.doApply')
lx.eval('tool.set poly.bevel off')
lx.eval('poly.collapse') |
# Small script with replaces the doc directory for gdscript-doc-maker
n = "ReferenceCollectorCLI.gd"
f = open(n, "r")
s = f.read().replace(
"var directories := [\"res://\"]",
"var directories := [\"res://addons/mongo-driver-godot/wrapper\"]")
f.close()
f = open(n, "w")
f.write(s)
f.close()
| n = 'ReferenceCollectorCLI.gd'
f = open(n, 'r')
s = f.read().replace('var directories := ["res://"]', 'var directories := ["res://addons/mongo-driver-godot/wrapper"]')
f.close()
f = open(n, 'w')
f.write(s)
f.close() |
#author SANKALP SAXENA
# Enter your code here. Read input from STDIN. Print output to STDOUT
m = int(input())
m = input().split(" ")
n = int(input())
n = input().split(" ")
m = set(m).intersection(set(n))
print(len(m))
| m = int(input())
m = input().split(' ')
n = int(input())
n = input().split(' ')
m = set(m).intersection(set(n))
print(len(m)) |
#
# PySNMP MIB module ONEACCESS-UPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ONEACCESS-UPS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:25:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
# Constants for movement algorithm
l = 0.7 # distance to wheels
r = 1 # wheel radius
# Constants
# Units here are in metres and radians using our standard coordinate frame
WINDOW_CORNERS = (-4.0, -2.5, 4.0, 2.5) # The region we will fill with obstacles
UNITS_RADIUS = 0.14
# A starting pose of robot
x_start... | l = 0.7
r = 1
window_corners = (-4.0, -2.5, 4.0, 2.5)
units_radius = 0.14
x_start_left = -4.0 + UNITS_RADIUS
y_start_left = -2.5 + UNITS_RADIUS
x_start_right = 3.9 - UNITS_RADIUS
y_start_right = -2.5 + UNITS_RADIUS
theta_start = 0
window_width = 800
window_height = 500
u0 = WINDOW_WIDTH / 2
v0 = WINDOW_HEIGHT / 2
clas... |
#
# PySNMP MIB module ASCEND-MIBLOG-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBLOG-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:11:42 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration')
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_const... |
class Solution:
def compareVersion(self, version1: str, version2: str) -> int:
v1 = list(map(int, version1.split('.')))
v2 = list(map(int, version2.split('.')))
v1Len = len(v1)
v2Len = len(v2)
if v1Len > v2Len:
v2 += [0] * (v1Len - v2Len)
else:
... | class Solution:
def compare_version(self, version1: str, version2: str) -> int:
v1 = list(map(int, version1.split('.')))
v2 = list(map(int, version2.split('.')))
v1_len = len(v1)
v2_len = len(v2)
if v1Len > v2Len:
v2 += [0] * (v1Len - v2Len)
else:
... |
#creamos una clas
class FiguraGeometrica:
def __init__(self, ancho, alto):
self.ancho = ancho
self.alto = alto
| class Figurageometrica:
def __init__(self, ancho, alto):
self.ancho = ancho
self.alto = alto |
#load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
#load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace")
load("@rules_pyo3_repo//cargo:crates.bzl", "rules_pyo3_fetch_remote_crates")
#load("@//cargo:crates.bzl", "raze_fetch_re... | load('@io_bazel_rules_rust//rust:repositories.bzl', 'rust_repositories')
load('@rules_pyo3_repo//cargo:crates.bzl', 'rules_pyo3_fetch_remote_crates')
load('@orjson_repo//cargo:crates.bzl', 'raze_fetch_remote_crates')
load('@rules_python//python:pip.bzl', 'pip_install')
load('@toolchains//:toolchains_deps.bzl', toolchai... |
class Response(object):
STATUS_OK = "ok"
STATUS_FAIL = "fail"
status = None
message = None
fullResponse = None
def setStatus(self, status):
self.status = status
def getStatus(self):
return self.status
def setMessage(self, message):
self.message = message
... | class Response(object):
status_ok = 'ok'
status_fail = 'fail'
status = None
message = None
full_response = None
def set_status(self, status):
self.status = status
def get_status(self):
return self.status
def set_message(self, message):
self.message = message
... |
_na = 'name'
_tp = 'type'
_opt = 'optional'
_nu = 'nullable'
_cp = 'is_compound'
_srl = 'compound_serializer'
_sch = 'compound_schema'
_spbtps = (int, float, bool, str)
_empt = (None, "", (), [], {})
| _na = 'name'
_tp = 'type'
_opt = 'optional'
_nu = 'nullable'
_cp = 'is_compound'
_srl = 'compound_serializer'
_sch = 'compound_schema'
_spbtps = (int, float, bool, str)
_empt = (None, '', (), [], {}) |
class Operator:
pass
class Number:
pass
class MemLocLiteral:
pass
class Register:
pass
class Literal:
pass
class Directive:
pass
class EOF:
pass
class GroupStart:
pass
class GroupEnd:
pass
class Comma:
pass
class Dot:
pass
class Star:
pass
class Sl... | class Operator:
pass
class Number:
pass
class Memlocliteral:
pass
class Register:
pass
class Literal:
pass
class Directive:
pass
class Eof:
pass
class Groupstart:
pass
class Groupend:
pass
class Comma:
pass
class Dot:
pass
class Star:
pass
class Slash:
pas... |
def AlgOptions(alphaLevelOptAlg, Alg, epsStop):
if Alg == 'MMA':
alphaLevelOptAlg.setOption('GEPS', epsStop)
alphaLevelOptAlg.setOption('DABOBJ', epsStop)
alphaLevelOptAlg.setOption('DELOBJ', epsStop)
alphaLevelOptAlg.setOption('ITRM', 1)
alphaLevelOptAlg.setOption('MAXIT', 3... | def alg_options(alphaLevelOptAlg, Alg, epsStop):
if Alg == 'MMA':
alphaLevelOptAlg.setOption('GEPS', epsStop)
alphaLevelOptAlg.setOption('DABOBJ', epsStop)
alphaLevelOptAlg.setOption('DELOBJ', epsStop)
alphaLevelOptAlg.setOption('ITRM', 1)
alphaLevelOptAlg.setOption('MAXIT', ... |
'''
At some n, generating the list of solutions is going to take such a long time that it will be more worth to use the doubly
linked list data structure to optimize the city generation
'''
class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
# Create the... | """
At some n, generating the list of solutions is going to take such a long time that it will be more worth to use the doubly
linked list data structure to optimize the city generation
"""
class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
class Doub... |
with open('input.txt', 'r') as f:
a = f.read()
# split the input file on blank lines ('\n\n') to return passport data
forms = a.split('\n\n')
#defining a function to create a set containing unique characters from a string
def unique_count(form_string):
unique_set = set()
for i in form_string:
uni... | with open('input.txt', 'r') as f:
a = f.read()
forms = a.split('\n\n')
def unique_count(form_string):
unique_set = set()
for i in form_string:
unique_set.add(i)
return unique_set
def yes_count(unique_set):
if '\n' in unique_set:
count = len(unique_set) - 1
else:
count =... |
#(Row, Col) - ErrorType: Message
ERROR_FORMAT = "(%d, %d) - %s: %s"
# Error Types
COMPILER_ERR = 'CompilerError'
LEXICOGRAPHIC_ERR = 'LexicographicError'
SYNTACTIC_ERR = 'SyntacticError'
NAME_ERR = 'NameError'
TYPE_ERR = 'TypeError'
ATTRIBUTE_ERR = 'AttributeError'
SEMANTIC_ERR = 'SemanticError'
# Semantic Messages
W... | error_format = '(%d, %d) - %s: %s'
compiler_err = 'CompilerError'
lexicographic_err = 'LexicographicError'
syntactic_err = 'SyntacticError'
name_err = 'NameError'
type_err = 'TypeError'
attribute_err = 'AttributeError'
semantic_err = 'SemanticError'
wrong_signature = 'Method "%s" already defined in "%s" with a differen... |
def get_feed_items(api):
results = api.feed_timeline()
items = [item for item in results.get('feed_items', [])
if item.get('media_or_ad')]
for item in items:
# print(item['media_or_ad']['code'])
print(item['media_or_ad']['user']['username'])
def get_userid(api, username):... | def get_feed_items(api):
results = api.feed_timeline()
items = [item for item in results.get('feed_items', []) if item.get('media_or_ad')]
for item in items:
print(item['media_or_ad']['user']['username'])
def get_userid(api, username):
user_info = api.username_info(username)
id = user_info[... |
#
# PySNMP MIB module EdgeSwitch-DOT1X-AUTHENTICATION-SERVER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EdgeSwitch-DOT1X-AUTHENTICATION-SERVER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:56:12 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user ... | (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) ... |
temp = float(input("Enter the temperature in Fahrenheit: "))
celsius = (temp - 32) * 5/9
print(f"{temp} in fahrenheit is {celsius} in celsius!") | temp = float(input('Enter the temperature in Fahrenheit: '))
celsius = (temp - 32) * 5 / 9
print(f'{temp} in fahrenheit is {celsius} in celsius!') |
words = input('')
a = input('')
b = input('')
c = input('')
d = input('')
print(words[int(a):(int(b) + 1)] + ' ' + words[int(c):(int(d) + 1)])
| words = input('')
a = input('')
b = input('')
c = input('')
d = input('')
print(words[int(a):int(b) + 1] + ' ' + words[int(c):int(d) + 1]) |
def pack_function():
def func1(*args, **kwargs):
# *args is tuple
# **kwargs is key-value dict
print(f'args: {args}')
print(f'kwargs: {kwargs}', end='\n\n')
# *args
print('func1(1,2,3)')
func1(1,2,3)
# **kwargs case1
print('func1(a=1, b=2)')
func1(a=1, b=2)
... | def pack_function():
def func1(*args, **kwargs):
print(f'args: {args}')
print(f'kwargs: {kwargs}', end='\n\n')
print('func1(1,2,3)')
func1(1, 2, 3)
print('func1(a=1, b=2)')
func1(a=1, b=2)
dic = dict()
dic['a'] = 1
dic['b'] = 2
print('func1(dic)')
func1(dic)
... |
email = input("EMAIL: ")
user, at, domain = email.partition("@")
check1 = domain == "gmail.com"
check2 = user.replace(".", "").replace("_", "").isalnum()
if check1 and check2:
print("valid")
else:
print("invalid")
#
| email = input('EMAIL: ')
(user, at, domain) = email.partition('@')
check1 = domain == 'gmail.com'
check2 = user.replace('.', '').replace('_', '').isalnum()
if check1 and check2:
print('valid')
else:
print('invalid') |
class a:
def sum(self):
self.a=int(input('enter a : '))
self.b=int(input('enter b : '))
result=self.a+self.b
print('sum ',result)
obj=a()
#simple class
#obj.sum()
class b(a):
def mul(self):
self.a=int(input('enter a : '))
self.b=int(input('enter b : ... | class A:
def sum(self):
self.a = int(input('enter a : '))
self.b = int(input('enter b : '))
result = self.a + self.b
print('sum ', result)
obj = a()
class B(a):
def mul(self):
self.a = int(input('enter a : '))
self.b = int(input('enter b : '))
result = ... |
def hi(name):
print("Hi, ", name)
hi('Trayan')
| def hi(name):
print('Hi, ', name)
hi('Trayan') |
fname = input('Enter a filename: ')
try:
fhand = open(fname, 'r')
except:
print('Invalid filename:', fname)
quit()
emails = dict()
for line in fhand:
words = line.split()
if len(words) >= 2 and words[0] == 'From':
emails[words[1]] = emails.get(words[1], 0) + 1
print(emails)
largest = No... | fname = input('Enter a filename: ')
try:
fhand = open(fname, 'r')
except:
print('Invalid filename:', fname)
quit()
emails = dict()
for line in fhand:
words = line.split()
if len(words) >= 2 and words[0] == 'From':
emails[words[1]] = emails.get(words[1], 0) + 1
print(emails)
largest = None
fo... |
class APIException(Exception):
'''General unexpected response'''
pass
class InvalidAppId(APIException):
'''Invalid key, HTTP 401'''
pass | class Apiexception(Exception):
"""General unexpected response"""
pass
class Invalidappid(APIException):
"""Invalid key, HTTP 401"""
pass |
def map_letter(c):
return "_" + c.lower() if c.isupper() else c
def to_underscore(s):
return str.lstrip("".join(map_letter(c) for c in str(s)), "_")
| def map_letter(c):
return '_' + c.lower() if c.isupper() else c
def to_underscore(s):
return str.lstrip(''.join((map_letter(c) for c in str(s))), '_') |
class AccountInfo(object):
def __init__(
self,
funds: dict,
open_orders: int,
transaction_count: int,
server_time: int,
rights: dict,
):
self.funds = funds
self.open_orders = open_orders
self.transaction_count = tran... | class Accountinfo(object):
def __init__(self, funds: dict, open_orders: int, transaction_count: int, server_time: int, rights: dict):
self.funds = funds
self.open_orders = open_orders
self.transaction_count = transaction_count
self.server_time = server_time
self.info_rights ... |
EXP_DIR = "EXPERIMENTS"
EXP_NAME = "EXPERIMENT"
DATA_DIR = "DATA"
CKPTS_DIR = "ckpts"
EXPDATA_DIR = "data"
RESULTS_DIR = "results"
CONFIG_DIR = "config"
LOGS_DIR = "logs"
TRAINING = "training"
VALIDATION = "validation"
TEST = "test"
LEARNING_MODES = [TRAINING, VALIDATION, TEST]
RAW_DIR = "raw"
PROCESSED_DIR = "proces... | exp_dir = 'EXPERIMENTS'
exp_name = 'EXPERIMENT'
data_dir = 'DATA'
ckpts_dir = 'ckpts'
expdata_dir = 'data'
results_dir = 'results'
config_dir = 'config'
logs_dir = 'logs'
training = 'training'
validation = 'validation'
test = 'test'
learning_modes = [TRAINING, VALIDATION, TEST]
raw_dir = 'raw'
processed_dir = 'processe... |
# Naive-Brute Force Approach -----> Time Complexity = O(n^2) Quadratic
def twoSum1(nums, target):
# Input validation
if len(nums) < 2:
return 'Not enough elements.'
# Double Foor Loop
for i in range(0, len(nums-1)):
for j in range(1, len(nums)-1):
if (nums[i] + nums[j] == target):
ret... | def two_sum1(nums, target):
if len(nums) < 2:
return 'Not enough elements.'
for i in range(0, len(nums - 1)):
for j in range(1, len(nums) - 1):
if nums[i] + nums[j] == target:
return [i, j]
def two_sum(nums, target):
if len(nums) < 2:
return 'Not enough e... |
# Predicitions and labels are 2D array/list containing the predictions/labels for each entry
# as an example:
# predictions with k = 3 : [[1,200,300], [5, 10, 20], [3,5,10], ...]
# labels : [[1,2], [5,10,20,30,40,50], [3,5,100], ...]
def metric_calculation(predictions, labels):
sum_recall_1 = 0
sum_recall... | def metric_calculation(predictions, labels):
sum_recall_1 = 0
sum_recall_2 = 0
sum_recall_3 = 0
sum_precision_1 = 0
sum_precision_2 = 0
sum_precision_3 = 0
num_test_data = len(predictions)
for i in range(len(predictions)):
correct_prediction = 0
actual_label = labels[i]
... |
def quickSort(_list):
if not isinstance(_list, list):
raise TypeError
quickSortRunner(_list, 0, len(_list)-1)
return _list
# Quicksort sets up the initial state of the sort
# quicksort runner will recursively come up with the split point
# after the initial reun through
def quickSortRunner(_list... | def quick_sort(_list):
if not isinstance(_list, list):
raise TypeError
quick_sort_runner(_list, 0, len(_list) - 1)
return _list
def quick_sort_runner(_list, first, last):
if first < last:
splitpoint = find_splitpnt(_list, first, last)
quick_sort_runner(_list, first, splitpoint -... |
# Created by MechAviv
# Map ID :: 402000615
# Refuge Outskirts : Beyond the Refuge
if "1" not in sm.getQuestEx(34915, "e1"):
sm.setMapTaggedObjectVisible("core0", False, 0, 0)
sm.setMapTaggedObjectVisible("core1", False, 0, 0)
sm.changeBGM("Bgm28.img/helisiumWarcry", 0, 0)
OBJECT_3 = sm.sendNpcControlle... | if '1' not in sm.getQuestEx(34915, 'e1'):
sm.setMapTaggedObjectVisible('core0', False, 0, 0)
sm.setMapTaggedObjectVisible('core1', False, 0, 0)
sm.changeBGM('Bgm28.img/helisiumWarcry', 0, 0)
object_3 = sm.sendNpcController(3001509, 500, 90)
sm.showNpcSpecialActionByObjectId(OBJECT_3, 'summon', 0)
... |
cont = 0
acomulador = 0
n = 0
n = int(input('Digite um numero '))
while n != 999:
cont += 1
acomulador += n
n = int(input('Digite um numero '))
print('Quantidade: {}\nSoma: {}'. format(cont, acomulador)) | cont = 0
acomulador = 0
n = 0
n = int(input('Digite um numero '))
while n != 999:
cont += 1
acomulador += n
n = int(input('Digite um numero '))
print('Quantidade: {}\nSoma: {}'.format(cont, acomulador)) |
num ,k = 1000000000 , 9
for i in range(int(k)):
if num%10 == 0 :
num = num // 10
print("if " ,num)
else :
num -=1
print("else " ,num)
print(num)
| (num, k) = (1000000000, 9)
for i in range(int(k)):
if num % 10 == 0:
num = num // 10
print('if ', num)
else:
num -= 1
print('else ', num)
print(num) |
def main():
a_factor = 16807
b_factor = 48271
divider = 2147483647
a = int(input().split()[4])
b = int(input().split()[4])
judge_count = 0
for _ in range(40000000):
a = (a * a_factor) % divider
b = (b * b_factor) % divider
a_bin = '{0:b}'.format(a).zfill(1... | def main():
a_factor = 16807
b_factor = 48271
divider = 2147483647
a = int(input().split()[4])
b = int(input().split()[4])
judge_count = 0
for _ in range(40000000):
a = a * a_factor % divider
b = b * b_factor % divider
a_bin = '{0:b}'.format(a).zfill(16)
b_bin... |
# -*- coding: utf-8 -*-
def calc_minimum_travels(east_stations):
cant_stations = len(east_stations)
paralelas_arriba = set()
paralelas_abajo = set()
rectas = set()
for west_station in range(cant_stations - 1):
e_station_1 = east_stations[west_station]
e_station_2 = east_stations[we... | def calc_minimum_travels(east_stations):
cant_stations = len(east_stations)
paralelas_arriba = set()
paralelas_abajo = set()
rectas = set()
for west_station in range(cant_stations - 1):
e_station_1 = east_stations[west_station]
e_station_2 = east_stations[west_station + 1]
if... |
# Simple Encryption, used to encrypt and decrypt the user names with the password as a key.
def generate_key(string):
key = []
for char in list(string):
key.append(ord(char))
return key
def encrypt_char(key, char):
en_char = ord(char)
for x in key:
en_char = en_char + x
return chr(en_char)
def encrypt_li... | def generate_key(string):
key = []
for char in list(string):
key.append(ord(char))
return key
def encrypt_char(key, char):
en_char = ord(char)
for x in key:
en_char = en_char + x
return chr(en_char)
def encrypt_line(key, line):
en_line = ''
for char in list(line):
... |
class Solution:
def numDecodings(self, s: str) -> int:
n = len(s)
# dp[i] := # of ways to decode s[i..n)
dp = [0] * n + [1]
def isValid(a: chr, b=None) -> bool:
if b:
return a == '1' or a == '2' and b < '7'
return a != '0'
if isValid(s[-1]):
dp[n - 1] = 1
for i in ... | class Solution:
def num_decodings(self, s: str) -> int:
n = len(s)
dp = [0] * n + [1]
def is_valid(a: chr, b=None) -> bool:
if b:
return a == '1' or (a == '2' and b < '7')
return a != '0'
if is_valid(s[-1]):
dp[n - 1] = 1
... |
#!/usr/bin/env python
def load_pins():
ret = {}
with open("DIMM-DDR4-288pins.txt", "rt") as f:
for l in f.readlines():
line = l.replace('\n', '')
#print(line)
idx, pin_name = line.split(' ')
assert(int(idx) not in ret)
ret[int(idx)] = pin_name... | def load_pins():
ret = {}
with open('DIMM-DDR4-288pins.txt', 'rt') as f:
for l in f.readlines():
line = l.replace('\n', '')
(idx, pin_name) = line.split(' ')
assert int(idx) not in ret
ret[int(idx)] = pin_name
return ret
def list_pins(pins):
for p... |
class Solution:
def maximum_69(self, num):
x = str(num)
if "6" in x:
x = x.replace("6", "9", 1)
return int(x) | class Solution:
def maximum_69(self, num):
x = str(num)
if '6' in x:
x = x.replace('6', '9', 1)
return int(x) |
# The Josephus Problem
def odd(n):
return (n % 2) == 1
def even(n):
return (n % 2) == 0
def josephus(n):
assert n > 0
if (n == 1): return 1
if (even(n)): return 2*josephus(n/2) - 1
return 2*josephus(n/2) + 1
def round_up_power2(n):
assert n >= 0
return 1 << n.bit_length()
# Logic le... | def odd(n):
return n % 2 == 1
def even(n):
return n % 2 == 0
def josephus(n):
assert n > 0
if n == 1:
return 1
if even(n):
return 2 * josephus(n / 2) - 1
return 2 * josephus(n / 2) + 1
def round_up_power2(n):
assert n >= 0
return 1 << n.bit_length()
def better_josephu... |
User.objects.create_user(email='instructor01@bogus.com', password='boguspwd')
User.objects.create_user(email='instructor02@bogus.com', password='boguspwd')
User.objects.create_user(email='instructor03@bogus.com', password='boguspwd')
User.objects.create_user(email='student01@bogus.com', password='boguspwd')
User.object... | User.objects.create_user(email='instructor01@bogus.com', password='boguspwd')
User.objects.create_user(email='instructor02@bogus.com', password='boguspwd')
User.objects.create_user(email='instructor03@bogus.com', password='boguspwd')
User.objects.create_user(email='student01@bogus.com', password='boguspwd')
User.object... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"get_arxiv_pdf_url": "00_core.ipynb",
"download_file": "00_core.ipynb",
"is_url": "00_core.ipynb",
"TargetType": "00_core.ipynb",
"Target": "00_core.ipynb",
"Messa... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'get_arxiv_pdf_url': '00_core.ipynb', 'download_file': '00_core.ipynb', 'is_url': '00_core.ipynb', 'TargetType': '00_core.ipynb', 'Target': '00_core.ipynb', 'MessageEncoded': '01_mail.ipynb', 'SCOPES': '01_mail.ipynb', 'Emailer': '01_mail.ipynb', 's... |
##@package forecast
#@author Sebastien MATHIEU
## Skeleton of a forecast.
# This forecast takes as state the last measurement.
class Forecast(object):
# Constructor
# @param x0 Initial state.
def __init__(self, x0=[0]):
self.initialize(x0)
# Initialize the forecast.
# @param x0 ... | class Forecast(object):
def __init__(self, x0=[0]):
self.initialize(x0)
def initialize(self, x0=[0]):
self.x = x0
def measure(self, x):
self.x = x |
#
# PySNMP MIB module EATON-OIDS (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EATON-OIDS
# Produced by pysmi-0.3.4 at Mon Apr 29 18:44:22 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:... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection) ... |
my_test_dict = {
"_id": {
"oid": "5fc8ec"
},
"mainId": "1e5a84e4",
"thisDate": {
"date": "2020-12-03T13:46:57Z"
},
"details": [
{
"detlName": "Detail_Name_1",
"dtlId": "fc9631b2-aed3",
"dblValue1": 0.925,
"intValue1": 715,
"customJSON": {
"accelAvg": 0.0,
... | my_test_dict = {'_id': {'oid': '5fc8ec'}, 'mainId': '1e5a84e4', 'thisDate': {'date': '2020-12-03T13:46:57Z'}, 'details': [{'detlName': 'Detail_Name_1', 'dtlId': 'fc9631b2-aed3', 'dblValue1': 0.925, 'intValue1': 715, 'customJSON': {'accelAvg': 0.0, 'accelMax': 0.0, 'max': [200.0, 40.0], 'gmInf': [{'bX': 30.297, 'bY': 53... |
#print nilai
nilai_Putu_Erik_Cahyadi = 85
print('Nilai anda adalah', nilai_Putu_Erik_Cahyadi)
if nilai_Putu_Erik_Cahyadi >= 75:
print('selamat anda lulus!! Erikc kun')
else :
print('Maaf anda tidak lulus erick kun :)')
| nilai__putu__erik__cahyadi = 85
print('Nilai anda adalah', nilai_Putu_Erik_Cahyadi)
if nilai_Putu_Erik_Cahyadi >= 75:
print('selamat anda lulus!! Erikc kun')
else:
print('Maaf anda tidak lulus erick kun :)') |
SOURCES = {"san jose mercury news (california)":"san jose mercury news",
"new york times blogs (the 6th floor)":"new york times",
"new york times blogs (artsbeat)":"new york times",
"new york times blogs (t magazine)":"new york times",
"new york times blogs (goal)":"new york times",
"new york times blogs... | sources = {'san jose mercury news (california)': 'san jose mercury news', 'new york times blogs (the 6th floor)': 'new york times', 'new york times blogs (artsbeat)': 'new york times', 'new york times blogs (t magazine)': 'new york times', 'new york times blogs (goal)': 'new york times', 'new york times blogs (economix... |
global N
N = 4
def printSolution(board):
for i in range(N):
for j in range(N):
print (board[i][j], end = " ")
print()
def isSafe(board, row, col):
for i in range(col):
if board[row][i] == 1:
return False
for i, j in zip(range(row, -1, -1), range(col, -1, -1)):
if board[i][j] =... | global N
n = 4
def print_solution(board):
for i in range(N):
for j in range(N):
print(board[i][j], end=' ')
print()
def is_safe(board, row, col):
for i in range(col):
if board[row][i] == 1:
return False
for (i, j) in zip(range(row, -1, -1), range(col, -1, -1... |
#!/usr/bin/env python
java_home = os.environ['JAVA_HOME']
oracle_home = os.environ['MW_HOME']
admin_server_listen_address = os.environ['ADMIN_SERVER_LISTEN_ADDRESS']
admin_server_listen_port = os.environ['ADMIN_SERVER_LISTEN_PORT']
admin_username = os.environ['ADMIN_USERNAME']
admin_password = os.environ['ADMIN_PASSW... | java_home = os.environ['JAVA_HOME']
oracle_home = os.environ['MW_HOME']
admin_server_listen_address = os.environ['ADMIN_SERVER_LISTEN_ADDRESS']
admin_server_listen_port = os.environ['ADMIN_SERVER_LISTEN_PORT']
admin_username = os.environ['ADMIN_USERNAME']
admin_password = os.environ['ADMIN_PASSWORD']
managed_server_nam... |
for _ in range(int(input())):
a,b,c=map(int,input().split())
d1=b-a
d2=c-b
| for _ in range(int(input())):
(a, b, c) = map(int, input().split())
d1 = b - a
d2 = c - b |
#!/usr/bin/env python3
# CHECKED
def f(x, y):
return -0.25 * (y - Ta)
h = 0.4
ti = 1
# tf = 1 + 2*h
Ti = 23
Ta = 45
for i in range(2):
print(ti, Ti)
deltax = h
deltay = f(ti, Ti) * deltax
ti = ti + deltax
Ti = Ti + deltay
print(ti, Ti)
| def f(x, y):
return -0.25 * (y - Ta)
h = 0.4
ti = 1
ti = 23
ta = 45
for i in range(2):
print(ti, Ti)
deltax = h
deltay = f(ti, Ti) * deltax
ti = ti + deltax
ti = Ti + deltay
print(ti, Ti) |
# Euler Problem 1
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we
# get 3, 5, 6 and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
def solve(upper_bound=999):
all_numbers = range(1, upper_bound + 1)
matching_numbers = [x for x in ... | def solve(upper_bound=999):
all_numbers = range(1, upper_bound + 1)
matching_numbers = [x for x in all_numbers if x % 5 == 0 or x % 3 == 0]
return sum(matching_numbers)
if __name__ == '__main__':
print(solve()) |
# start with def func_name(args)
# Every year that is evenly divisble by 4
# except Every year that is evenly divisible by 100
# unless that year is also envenly divislbe by 400
def is_leap_year(year):
if year < 0:
return False
if year % 4 == 0:
if year % 100 == 0:
if year % 40... | def is_leap_year(year):
if year < 0:
return False
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
return False
return True
return False |
def prime(n):
flag=True
for i in range(2,n):
if (n%i==0):
flag=False
break
return flag
def Goldbach(n):
l=[]
for i in range(2,n):
for j in range(i,n):
if (i+j==n) and (prime(i) and prime(j)):
l.append((i,j))
return l
n=int(... | def prime(n):
flag = True
for i in range(2, n):
if n % i == 0:
flag = False
break
return flag
def goldbach(n):
l = []
for i in range(2, n):
for j in range(i, n):
if i + j == n and (prime(i) and prime(j)):
l.append((i, j))
retur... |
class Solution:
def maxProfit(self, prices: List[int]) -> int:
if not prices:
return 0
n = len(prices)
dp = [[0] * n for _ in range(3)]
for i in range(1, 3):
best_hold = -prices[0]
for j in range(1, n):
dp[i][j] = max(dp[i][j - 1], ... | class Solution:
def max_profit(self, prices: List[int]) -> int:
if not prices:
return 0
n = len(prices)
dp = [[0] * n for _ in range(3)]
for i in range(1, 3):
best_hold = -prices[0]
for j in range(1, n):
dp[i][j] = max(dp[i][j - 1]... |
if 2 > 3:
print('mior')
else:
print('menor')
| if 2 > 3:
print('mior')
else:
print('menor') |
# NOTE: This function was copied from
# https://github.com/andymccurdy/redis-py/blob/master/redis/utils.py#L29
def str_if_bytes(value):
return (
value.decode('utf-8', errors='replace')
if isinstance(value, bytes)
else value
)
# NOTE: This function was copied from
# https://github.com/a... | def str_if_bytes(value):
return value.decode('utf-8', errors='replace') if isinstance(value, bytes) else value
def parse_info(response):
"""Parse the result of Redis's INFO command into a Python dict"""
info = {}
response = str_if_bytes(response)
def get_value(value):
if ',' not in value o... |
def generate(list_of_elements, string):
if len(list_of_elements) == 0:
print(string);
else:
for num, elem in enumerate(list_of_elements):
tmp_list = list_of_elements.copy();
del tmp_list[num];
generate(tmp_list, string + str(elem))
list_of_elements = [1,2,3,4]
generate(list_of_elements, ""); | def generate(list_of_elements, string):
if len(list_of_elements) == 0:
print(string)
else:
for (num, elem) in enumerate(list_of_elements):
tmp_list = list_of_elements.copy()
del tmp_list[num]
generate(tmp_list, string + str(elem))
list_of_elements = [1, 2, 3, ... |
# Initialize sum
sum = 0
# Add 0.01, 0.02, ..., 0.99, 1 to sum
i = 0.01
while i <= 1.0:
sum += i
i = i + 0.01
# Display result
print("The sum is", sum) | sum = 0
i = 0.01
while i <= 1.0:
sum += i
i = i + 0.01
print('The sum is', sum) |
# lc686.py
# LeetCode 686. Repeated String Match `E`
# acc | 96% | 37'
# A~0g25
class Solution:
def repeatedStringMatch(self, A: str, B: str) -> int:
if set(A) < set(B):
return -1
n = ceil(len(B)/len(A))
for k in (n, n+1):
if B in A*k:
return k
... | class Solution:
def repeated_string_match(self, A: str, B: str) -> int:
if set(A) < set(B):
return -1
n = ceil(len(B) / len(A))
for k in (n, n + 1):
if B in A * k:
return k
return -1 |
panel_name = "tutkain.tap_panel"
def create_panel(window):
panel = window.find_output_panel(panel_name)
if panel is None:
panel = window.create_output_panel(panel_name)
panel.settings().set("line_numbers", False)
panel.settings().set("gutter", False)
panel.settings().set("is_w... | panel_name = 'tutkain.tap_panel'
def create_panel(window):
panel = window.find_output_panel(panel_name)
if panel is None:
panel = window.create_output_panel(panel_name)
panel.settings().set('line_numbers', False)
panel.settings().set('gutter', False)
panel.settings().set('is_wid... |
# Copyright (c) 2018, Vanessa Sochat All rights reserved.
# See the LICENSE in the main repository at:
# https://www.github.com/openschemas/openschemas-python
__version__ = "0.0.14"
AUTHOR = 'Vanessa Sochat'
AUTHOR_EMAIL = 'vsochat@stanford.edu'
NAME = 'openschemas'
PACKAGE_URL = "https://www.github.com/openschemas... | __version__ = '0.0.14'
author = 'Vanessa Sochat'
author_email = 'vsochat@stanford.edu'
name = 'openschemas'
package_url = 'https://www.github.com/openschemas/openschemas-python'
keywords = 'openschemas, markdown, schemaorg, rdf'
description = 'openschemas python helper functions for schemaorg schemas'
license = 'LICENS... |
class Wave:
freq = 0
amp = 0
phase = 0
def __init__(self, freq, amp, phase):
self.freq = freq
self.amp = amp
self.phase = phase
def getWaves():
w = []
w.append(Wave(52, 135.19819405635224, -1.0207892479734177))
w.append(Wave(51, 54.79526886568049, -1.304787207074190... | class Wave:
freq = 0
amp = 0
phase = 0
def __init__(self, freq, amp, phase):
self.freq = freq
self.amp = amp
self.phase = phase
def get_waves():
w = []
w.append(wave(52, 135.19819405635224, -1.0207892479734177))
w.append(wave(51, 54.79526886568049, -1.30478720707419... |
DEBUG = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test.db',
}
}
USE_TZ = False
SITE_ID = 1
STATIC_URL = '/static/'
SECRET_KEY = 'NOT_SO_SECRET'
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
... | debug = True
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.db'}}
use_tz = False
site_id = 1
static_url = '/static/'
secret_key = 'NOT_SO_SECRET'
installed_apps = ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.mes... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 - hongzhi.wang <hongzhi.wang@moji.com>
'''
Author: hongzhi.wang
Create Date: 2019-09-04
Modify Date: 2019-09-04
'''
class BowlingGame:
def __init__(self):
self._score = 0
self.pins = [0] * 21
self.current_pin_index = 0
... | """
Author: hongzhi.wang
Create Date: 2019-09-04
Modify Date: 2019-09-04
"""
class Bowlinggame:
def __init__(self):
self._score = 0
self.pins = [0] * 21
self.current_pin_index = 0
def roll(self, pin):
self.pins[self.current_pin_index] = pin
self.current_pin_index += 1
... |
uctable = [ [ 36 ],
[ 194, 162 ],
[ 194, 163 ],
[ 194, 164 ],
[ 194, 165 ],
[ 214, 143 ],
[ 216, 139 ],
[ 224, 167, 178 ],
[ 224, 167, 179 ],
[ 224, 167, 187 ],
[ 224, 171, 177 ],
[ 224, 175, 185 ],
[ 224, 184, 191 ],
[ 225, 159, 155 ],
[ 226, 130, 160 ],
[ 226, 130, 161 ],
[ 226, 130, 1... | uctable = [[36], [194, 162], [194, 163], [194, 164], [194, 165], [214, 143], [216, 139], [224, 167, 178], [224, 167, 179], [224, 167, 187], [224, 171, 177], [224, 175, 185], [224, 184, 191], [225, 159, 155], [226, 130, 160], [226, 130, 161], [226, 130, 162], [226, 130, 163], [226, 130, 164], [226, 130, 165], [226, 130,... |
class countdown_iterator:
def __init__(self, count):
self.count = count
self.start = count
def __iter__(self):
return self
def __next__(self):
index = self.start
if self.start < 0:
raise StopIteration
self.start -= 1
return index
#test ... | class Countdown_Iterator:
def __init__(self, count):
self.count = count
self.start = count
def __iter__(self):
return self
def __next__(self):
index = self.start
if self.start < 0:
raise StopIteration
self.start -= 1
return index
iterato... |
#!/usr/bin/env python3
#This program will write:
#hello world!
print("Hello World!") | print('Hello World!') |
class Array:
name = None
value = None
item_definition = None
_type = 'array'
_format = ''
def __init__(self, name, item_definition, value=None):
self.name = name
self.value = value
self.item_definition = item_definition
| class Array:
name = None
value = None
item_definition = None
_type = 'array'
_format = ''
def __init__(self, name, item_definition, value=None):
self.name = name
self.value = value
self.item_definition = item_definition |
files = {
"libsigsegv2_2.12-2_amd64.deb": "78d1be36433355530c2e55ac8a24c41cbbdd8f5a3c943e614c8761113a72cb8d",
"m4_1.4.18-2_amd64.deb": "37076cc03a19863eb6c4ec2afb3e79328c19fdc506176bfe8ffcada6d0f7d099",
}
| files = {'libsigsegv2_2.12-2_amd64.deb': '78d1be36433355530c2e55ac8a24c41cbbdd8f5a3c943e614c8761113a72cb8d', 'm4_1.4.18-2_amd64.deb': '37076cc03a19863eb6c4ec2afb3e79328c19fdc506176bfe8ffcada6d0f7d099'} |
{
"targets": [{
"target_name": "iohook",
"win_delay_load_hook": "true",
"type": "loadable_module",
"sources": [
"src/iohook.cc",
"src/iohook.h"
],
"dependencies": [
"./uiohook.gyp:uiohook"
],
"cflags": [
"-std=c99"
],
"link_settings": {
"libraries": [
"-Wl,-rpath,@executable_p... | {'targets': [{'target_name': 'iohook', 'win_delay_load_hook': 'true', 'type': 'loadable_module', 'sources': ['src/iohook.cc', 'src/iohook.h'], 'dependencies': ['./uiohook.gyp:uiohook'], 'cflags': ['-std=c99'], 'link_settings': {'libraries': ['-Wl,-rpath,@executable_path/.', '-Wl,-rpath,@loader_path/.', '-Wl,-rpath,<!(p... |
def mock_df():
area = pd.Series({0: 423967, 1: 695662, 2: 141297, 3: 170312, 4: 149995})
population = pd.Series(
{0: 38332521, 1: 26448193, 2: 19651127, 3: 19552860, 4: 12882135})
population = population.astype(float)
states = ['California', 'Texas', 'New York', 'Florida', 'Illinois']
df = ... | def mock_df():
area = pd.Series({0: 423967, 1: 695662, 2: 141297, 3: 170312, 4: 149995})
population = pd.Series({0: 38332521, 1: 26448193, 2: 19651127, 3: 19552860, 4: 12882135})
population = population.astype(float)
states = ['California', 'Texas', 'New York', 'Florida', 'Illinois']
df = pd.DataFra... |
__package__ = "tests.django"
DEBUG = True
SECRET_KEY = "fake-key"
INSTALLED_APPS = [
"graphene_django",
]
GRAPHENE_PROTECTOR_DEPTH_LIMIT = 2
GRAPHENE_PROTECTOR_SELECTIONS_LIMIT = 50
DATABASES = {
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}
}
GRAPHENE = {"SCHEMA": "tests.django.schema... | __package__ = 'tests.django'
debug = True
secret_key = 'fake-key'
installed_apps = ['graphene_django']
graphene_protector_depth_limit = 2
graphene_protector_selections_limit = 50
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}
graphene = {'SCHEMA': 'tests.django.schema.schema'} |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
POST = 'post'
CATEGORY = 'category'
GROUP = 'group'
USER = 'user'
TOPIC = 'topic'
| post = 'post'
category = 'category'
group = 'group'
user = 'user'
topic = 'topic' |
def test_cases(index):
return testCases[index]
critical = "Critical"
major = "Major"
moderate = "Moderate"
low = "Low"
testCases = {
0: [critical, 'When user goes to Canonizer main page, page should be loaded Properly'],
1: [critical, 'In Home page, when user click "Register" button, User should see Use... | def test_cases(index):
return testCases[index]
critical = 'Critical'
major = 'Major'
moderate = 'Moderate'
low = 'Low'
test_cases = {0: [critical, 'When user goes to Canonizer main page, page should be loaded Properly'], 1: [critical, 'In Home page, when user click "Register" button, User should see User Registrati... |
fibo=[0,1]
p=0
s=1
for i in range(60):
t=s+p
fibo.append(t)
p=s
s=t
T= int(input())
for i in range(T):
N=int(input())
print('Fib(%d) = %d' %(N, fibo[N])) | fibo = [0, 1]
p = 0
s = 1
for i in range(60):
t = s + p
fibo.append(t)
p = s
s = t
t = int(input())
for i in range(T):
n = int(input())
print('Fib(%d) = %d' % (N, fibo[N])) |
#String concat in loop
def y(seq):
y_accum = ''
for s in seq:
y_accum += s
def z(seq):
z_accum = ''
for s in seq:
z_accum = z_accum + s
| def y(seq):
y_accum = ''
for s in seq:
y_accum += s
def z(seq):
z_accum = ''
for s in seq:
z_accum = z_accum + s |
'''
This is an object to represent a bundle of stats that a champion may possess.
offensive stats:
Attack Damage (ad)
Ability Power (ap)
Attack Speed (as)
Critical Strike Chance (cs)
Critical Strike Damage (csd)
Ability Haste (ah)
Armour Penetration (arp)
Magic Penetrat... | """
This is an object to represent a bundle of stats that a champion may possess.
offensive stats:
Attack Damage (ad)
Ability Power (ap)
Attack Speed (as)
Critical Strike Chance (cs)
Critical Strike Damage (csd)
Ability Haste (ah)
Armour Penetration (arp)
Magic Penetrat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.