content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# I usually do not hard-code urls here,
# but there is not much need for complex configuration
BASEURL = 'https://simple-chat-asapp.herokuapp.com/'
login_button_text = 'Login'
sign_in_message = 'Sign in to Chat'
who_are_you = 'Who are you?'
who_are_you_talking_to = 'Who are you talking to?'
chatting_text = 'Chatting'... | baseurl = 'https://simple-chat-asapp.herokuapp.com/'
login_button_text = 'Login'
sign_in_message = 'Sign in to Chat'
who_are_you = 'Who are you?'
who_are_you_talking_to = 'Who are you talking to?'
chatting_text = 'Chatting'
chatting_with_text = "You're {0}, and you're chatting with {1}"
say_something_text = 'Say someth... |
# code to run in IPython shell to test whether clustering info in spikes struct array and in
# the neurons dict is consistent:
for nid in sorted(self.sort.neurons):
print(nid, (self.sort.neurons[nid].sids == np.where(self.sort.spikes['nid'] == nid)[0]).all())
| for nid in sorted(self.sort.neurons):
print(nid, (self.sort.neurons[nid].sids == np.where(self.sort.spikes['nid'] == nid)[0]).all()) |
def sum67(nums):
count = 0
blocked = False
for n in nums:
if n == 6:
blocked = True
continue
if n == 7 and blocked:
blocked = False
continue
if not blocked:
count += n
return count
| def sum67(nums):
count = 0
blocked = False
for n in nums:
if n == 6:
blocked = True
continue
if n == 7 and blocked:
blocked = False
continue
if not blocked:
count += n
return count |
# author : @akash kumar
# problem link:
# https://prepinsta.com/tcs-coding-question-1/
x,y,d,t=0,0,10,1
for n in range(int(input())):
if t==1:
x+=d
t=2
d+=10
elif t==2:
y+=d
t=3
d+=10
elif t==3:
x-=d
t=4
d+=10
elif t==4:
y-=d
t=5... | (x, y, d, t) = (0, 0, 10, 1)
for n in range(int(input())):
if t == 1:
x += d
t = 2
d += 10
elif t == 2:
y += d
t = 3
d += 10
elif t == 3:
x -= d
t = 4
d += 10
elif t == 4:
y -= d
t = 5
d += 10
else:
... |
#!/usr/bin/env python3
#encoding=utf-8
#--------------------------------------------
# Usage: python3 3-calltracer_descr-for-method.py
# Description: make descriptor class as decorator to decorate class method
#--------------------------------------------
class Tracer: # a decorator + descriptor
def __ini... | class Tracer:
def __init__(self, func):
print('in property descriptor __init__')
self.calls = 0
self.func = func
def __call__(self, *args, **kwargs):
print('in property descriptor __call__')
self.calls += 1
print('call %s to %s' % (self.calls, self.func.__name__... |
def bytes2int(data: bytes) -> int:
return int.from_bytes(data, byteorder="big", signed=True)
def int2bytes(x: int) -> bytes:
return int.to_bytes(x, length=4, byteorder="big", signed=True)
| def bytes2int(data: bytes) -> int:
return int.from_bytes(data, byteorder='big', signed=True)
def int2bytes(x: int) -> bytes:
return int.to_bytes(x, length=4, byteorder='big', signed=True) |
#!/usr/bin/python3.4
tableData = [['apples','oranges','cherries','bananas'],
['Alice','Bob','Carol','David'],
['dogs','cats','moose','goose']]
# Per the hint
colWidth = [0] * len(tableData)
# Who knew you had to transpose this list of lists
def matrixTranspose( matrix ):
if not matrix: ... | table_data = [['apples', 'oranges', 'cherries', 'bananas'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']]
col_width = [0] * len(tableData)
def matrix_transpose(matrix):
if not matrix:
return []
return [[row[i] for row in matrix] for i in range(len(matrix[0]))]
def print_table... |
folder_nm='end_to_end'
coref_path="/home/raj/"+folder_nm+"/output/coreferent_pairs/output2.txt"
chains_path="/home/raj/"+folder_nm+"/output/chains/chains.txt"
f1=open(chains_path,"w+")
def linear_search(obj, item, start=0):
for l in range(start, len(obj)):
if obj[l] == item:
return l
return... | folder_nm = 'end_to_end'
coref_path = '/home/raj/' + folder_nm + '/output/coreferent_pairs/output2.txt'
chains_path = '/home/raj/' + folder_nm + '/output/chains/chains.txt'
f1 = open(chains_path, 'w+')
def linear_search(obj, item, start=0):
for l in range(start, len(obj)):
if obj[l] == item:
re... |
SCOUTOATH = '''
On my honor, I will do my best
to do my duty to God and my country
to obey the Scout Law
to help other people at all times
to keep myself physically strong, mentally awake and morally straight.
'''
SCOUTLAW = '''
A scout is:
Trustworthy
Loyal
Helpful
Friendly
Courteous
Kind
... | scoutoath = '\nOn my honor, I will do my best\nto do my duty to God and my country\nto obey the Scout Law\nto help other people at all times\nto keep myself physically strong, mentally awake and morally straight.\n'
scoutlaw = '\nA scout is:\n Trustworthy\n Loyal\n Helpful\n Friendly\n Courteous\n Kin... |
# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREY = (140, 140, 140)
CYAN = (0, 255, 255)
DARK_CYAN = (0, 150, 150)
ORANGE = (255, 165, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
| black = (0, 0, 0)
white = (255, 255, 255)
grey = (140, 140, 140)
cyan = (0, 255, 255)
dark_cyan = (0, 150, 150)
orange = (255, 165, 0)
red = (255, 0, 0)
green = (0, 255, 0) |
data = (
'kka', # 0x00
'kk', # 0x01
'nu', # 0x02
'no', # 0x03
'ne', # 0x04
'nee', # 0x05
'ni', # 0x06
'na', # 0x07
'mu', # 0x08
'mo', # 0x09
'me', # 0x0a
'mee', # 0x0b
'mi', # 0x0c
'ma', # 0x0d
'yu', # 0x0e
'yo', # 0x0f
'ye', # 0x10
'yee', # 0x11
'yi', # 0x12
'ya... | data = ('kka', 'kk', 'nu', 'no', 'ne', 'nee', 'ni', 'na', 'mu', 'mo', 'me', 'mee', 'mi', 'ma', 'yu', 'yo', 'ye', 'yee', 'yi', 'ya', 'ju', 'ju', 'jo', 'je', 'jee', 'ji', 'ji', 'ja', 'jju', 'jjo', 'jje', 'jjee', 'jji', 'jja', 'lu', 'lo', 'le', 'lee', 'li', 'la', 'dlu', 'dlo', 'dle', 'dlee', 'dli', 'dla', 'lhu', 'lho', 'l... |
class SymbolTableItem:
def __init__(self, type, name, customId, value):
self.type = type
self.name = name
self.value = value
# if type == 'int' or type == 'bool':
# self.value = 0
# elif type == 'string':
# self.value = ' '
# else:
# ... | class Symboltableitem:
def __init__(self, type, name, customId, value):
self.type = type
self.name = name
self.value = value
self.id = 'id_{}'.format(customId)
def __str__(self):
return '{}, {}, {}, {}'.format(self.type, self.name, self.value, self.id) |
# Define the fileName as a variable
fileToWrite = 'outputFile.txt'
fileHandle = open(fileToWrite, 'w')
i = 0
while i < 10:
fileHandle.write("This is line Number " + str(i) + "\n")
i += 1
fileHandle.close()
| file_to_write = 'outputFile.txt'
file_handle = open(fileToWrite, 'w')
i = 0
while i < 10:
fileHandle.write('This is line Number ' + str(i) + '\n')
i += 1
fileHandle.close() |
a = source()
if True:
b = a + 3 * sanitizer2(y)
else:
b = sanitizer(a)
sink(b) | a = source()
if True:
b = a + 3 * sanitizer2(y)
else:
b = sanitizer(a)
sink(b) |
#
# This file contains the Python code from Program 10.10 of
# "Data Structures and Algorithms
# with Object-Oriented Design Patterns in Python"
# by Bruno R. Preiss.
#
# Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved.
#
# http://www.brpreiss.com/books/opus7/programs/pgm10_10.txt
#
class AVLTree(Bin... | class Avltree(BinarySearchTree):
def balance(self):
self.adjustHeight()
if self.balanceFactor > 1:
if self._left.balanceFactor > 0:
self.doLLRotation()
else:
self.doLRRotation()
elif self.balanceFactor < -1:
if self._right.... |
# Python program to print Even Numbers in given range
start, end = 4, 19
# iterating each number in list
for num in range(start, end + 1):
# checking condition
if num % 2 == 0:
print(num, end = " ")
| (start, end) = (4, 19)
for num in range(start, end + 1):
if num % 2 == 0:
print(num, end=' ') |
x = input()
y = input()
z = input()
flag = z % (1 + 1) == 0 and (1 < x and x < 123) or (1 > y and y > x and x > y and y < 123)
def identity(var):
return var
if x ^ y == 1 or (
x % 2 == 0 and (3 > x and x <= 3 and 3 <= y and y > z and z >= 5) or (
identity(-1) + hash('hello') < 10 + 120 and 10 +... | x = input()
y = input()
z = input()
flag = z % (1 + 1) == 0 and (1 < x and x < 123) or (1 > y and y > x and (x > y) and (y < 123))
def identity(var):
return var
if x ^ y == 1 or (x % 2 == 0 and (3 > x and x <= 3 and (3 <= y) and (y > z) and (z >= 5)) or (identity(-1) + hash('hello') < 10 + 120 and 10 + 120 < hash(... |
def main():
class student:
std = []
def __init__(self,name,id,cgpa):
self.name = name
self.id = id
self.cgpa = cgpa
def showId(self):
return self.id
def result(self):
if(self.cgpa > 8.5):
print(... | def main():
class Student:
std = []
def __init__(self, name, id, cgpa):
self.name = name
self.id = id
self.cgpa = cgpa
def show_id(self):
return self.id
def result(self):
if self.cgpa > 8.5:
print('Great ... |
def valid(a):
a = str(a)
num = set()
for char in a:
num.add(char)
return len(a) == len(num)
n = int(input())
n += 1
while True:
if valid(n):
print(n)
break
else:
n += 1
| def valid(a):
a = str(a)
num = set()
for char in a:
num.add(char)
return len(a) == len(num)
n = int(input())
n += 1
while True:
if valid(n):
print(n)
break
else:
n += 1 |
P, A, B = map(int, input().split())
if P >= A+B:
print(P)
elif B > P:
print(-1)
else:
print(A+B)
| (p, a, b) = map(int, input().split())
if P >= A + B:
print(P)
elif B > P:
print(-1)
else:
print(A + B) |
PASSWORD = "PASSW0RD2019"
TO = ["test@gmail.com",
"test2@gmail.com"]
FROM = "test@gmail.com"
| password = 'PASSW0RD2019'
to = ['test@gmail.com', 'test2@gmail.com']
from = 'test@gmail.com' |
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incor... | def edgeorder_order_show(client, name, resource_group_name, location):
return client.get_order_by_name(order_name=name, resource_group_name=resource_group_name, location=location)
def edgeorder_list_config(client, configuration_filters, skip_token=None, registered_features=None, location_placement_id=None, quota_i... |
class Config(object):
ORG_NAME = 'footprints'
ORG_DOMAIN = 'footprints.devel'
APP_NAME = 'Footprints'
APP_VERSION = '0.4.0'
| class Config(object):
org_name = 'footprints'
org_domain = 'footprints.devel'
app_name = 'Footprints'
app_version = '0.4.0' |
class Solution:
def minSubArrayLen(self, s: int, nums: List[int]) -> int:
left, sum, count = 0, 0, float('inf')
for right in range(len(nums)):
sum += nums[right]
while sum >= s:
count = min(count, right - left + 1)
sum -= ... | class Solution:
def min_sub_array_len(self, s: int, nums: List[int]) -> int:
(left, sum, count) = (0, 0, float('inf'))
for right in range(len(nums)):
sum += nums[right]
while sum >= s:
count = min(count, right - left + 1)
sum -= nums[left]
... |
def pisano(m):
prev,curr=0,1
for i in range(0,m*m):
prev,curr=curr,(prev+curr)%m
if prev==0 and curr == 1 :
return i+1
def fib(n,m):
seq=pisano(m)
n%=seq
if n<2:
return n
f=[0]*(n+1)
f[1]=1
for i in range(2,n+1):
f[i]=f[i-1]+f[i-2]
... | def pisano(m):
(prev, curr) = (0, 1)
for i in range(0, m * m):
(prev, curr) = (curr, (prev + curr) % m)
if prev == 0 and curr == 1:
return i + 1
def fib(n, m):
seq = pisano(m)
n %= seq
if n < 2:
return n
f = [0] * (n + 1)
f[1] = 1
for i in range(2, n ... |
#
# PySNMP MIB module TRAPEZE-NETWORKS-RF-BLACKLIST-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TRAPEZE-NETWORKS-RF-BLACKLIST-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:27:23 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using P... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, single_value_constraint, constraints_union, value_range_constraint) ... |
T = int(input())
for i in range(T):
try:
a, b = map(str, input().split())
print(int(int(a)//int(b)))
except Exception as e:
print("Error Code:", e)
| t = int(input())
for i in range(T):
try:
(a, b) = map(str, input().split())
print(int(int(a) // int(b)))
except Exception as e:
print('Error Code:', e) |
def sortNums(nums):
# constant space solution
i = 0
j = len(nums) - 1
index = 0
while index <= j:
if nums[index] == 1:
nums[index], nums[i] = nums[i], nums[index]
index += 1
i += 1
if nums[index] == 2:
index += 1
if nums[index] ... | def sort_nums(nums):
i = 0
j = len(nums) - 1
index = 0
while index <= j:
if nums[index] == 1:
(nums[index], nums[i]) = (nums[i], nums[index])
index += 1
i += 1
if nums[index] == 2:
index += 1
if nums[index] == 3:
(nums[i... |
#!/usr/bin/env python
def num_digits(k):
c = 0
while k > 0:
c += 1
k /= 10
return c
def is_kaprekar(k):
k2 = pow(k, 2)
p10ndk = pow(10, num_digits(k))
if k == (k2 // p10ndk) + (k2 % p10ndk):
return True
else:
return False
if __name__ == '__main__':
for ... | def num_digits(k):
c = 0
while k > 0:
c += 1
k /= 10
return c
def is_kaprekar(k):
k2 = pow(k, 2)
p10ndk = pow(10, num_digits(k))
if k == k2 // p10ndk + k2 % p10ndk:
return True
else:
return False
if __name__ == '__main__':
for k in range(1, 1001):
... |
def decorating_fun(func):
def wrapping_function():
print("this is wrapping function and get func start")
func()
print("func end")
return wrapping_function
@decorating_fun
def decorated_func():
print("i`m decoraed")
decorated_func() | def decorating_fun(func):
def wrapping_function():
print('this is wrapping function and get func start')
func()
print('func end')
return wrapping_function
@decorating_fun
def decorated_func():
print('i`m decoraed')
decorated_func() |
class CannotAssignValueFromParentCategory(Exception):
def __init__(self):
super().__init__("422 Cannot assign value from parent category")
| class Cannotassignvaluefromparentcategory(Exception):
def __init__(self):
super().__init__('422 Cannot assign value from parent category') |
# read file
f=open("funny.txt","r")
for line in f:
print(line)
f.close()
# readlines()
f=open("funny.txt","r")
lines = f.readlines()
print(lines)
# write file
f=open("love.txt","w")
f.write("I love python")
f.close()
# same file when you write i love javascript the previous line goes away
f=open("love.txt","w")
... | f = open('funny.txt', 'r')
for line in f:
print(line)
f.close()
f = open('funny.txt', 'r')
lines = f.readlines()
print(lines)
f = open('love.txt', 'w')
f.write('I love python')
f.close()
f = open('love.txt', 'w')
f.write('I love javascript')
f.close()
f = open('love.txt', 'a')
f.write('I love javascript')
f.close()... |
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_error_message(exc) -> str:
if hasattr(exc, 'message_dict'):
return exc.message_dict
error_msg = get_first_matching_attr(exc, '... | 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_error_message(exc) -> str:
if hasattr(exc, 'message_dict'):
return exc.message_dict
error_msg = get_first_matching_attr(exc, 'me... |
c = input().strip()
fr = input().split()
n = 0
for i in fr:
if c in i: n += 1
print('{:.1f}'.format(n*100/len(fr)))
| c = input().strip()
fr = input().split()
n = 0
for i in fr:
if c in i:
n += 1
print('{:.1f}'.format(n * 100 / len(fr))) |
# Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agree... | _base_ = ['../_base_/models/mask_rcnn_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
model = dict(rpn_head=dict(anchor_generator=dict(type='LegacyAnchorGenerator', center_offset=0.5), bbox_coder=dict(type='LegacyDeltaXYWHBBoxCoder'), loss_bbox=d... |
raw_data = [
b'\x1cT#01 61.01,\r\nT#03 88.07,90.78,90.17,29.48,14.41\r\n \r\n \xae$\xe2\x02\xe0D\x143P\x02\xe0',
b'T#01 56.92,\r\nT#03 88.10,90.62,90.42,29.68,14.39\r\n \r\n C \xfc',
b'T#01 63.51,\r\nT#03 87.98,90.36,90.15,29.30,14.41\r\n \r\n \x03\x82\x01\x80$\x9f\xd8\xbc\x0f\x08',
b'T#01 56.05,\r\nT#0... | raw_data = [b'\x1cT#01 61.01,\r\nT#03 88.07,90.78,90.17,29.48,14.41\r\n \r\n \xae$\xe2\x02\xe0D\x143P\x02\xe0', b'T#01 56.92,\r\nT#03 88.10,90.62,90.42,29.68,14.39\r\n \r\n C \xfc', b'T#01 63.51,\r\nT#03 87.98,90.36,90.15,29.30,14.41\r\n \r\n \x03\x82\x01\x80$\x9f\xd8\xbc\x0f\x08', b'T#01 56.05,\r\nT#03 87.99,90.66,90.... |
#
# @lc app=leetcode id=1299 lang=python3
#
# [1299] Replace Elements with Greatest Element on Right Side
#
# @lc code=start
class Solution:
def replaceElements(self, arr: List[int]) -> List[int]:
index = 0
result = []
for i,v in enumerate(arr):
if i+1 == len(arr):
... | class Solution:
def replace_elements(self, arr: List[int]) -> List[int]:
index = 0
result = []
for (i, v) in enumerate(arr):
if i + 1 == len(arr):
result.append(-1)
break
result.append(max(arr[i + 1:len(arr)]))
index = inde... |
def rotate(cur_direction, rotation_command):
# Assumes there are only R/L 90/180/270
invert_rl = {
"R": "L",
"L": "R",
}
if int(rotation_command[1:]) == 270:
rotation_command = f"{invert_rl[rotation_command[0]]}90"
elif int(rotation_command[1:]) == 180:
flip ... | def rotate(cur_direction, rotation_command):
invert_rl = {'R': 'L', 'L': 'R'}
if int(rotation_command[1:]) == 270:
rotation_command = f'{invert_rl[rotation_command[0]]}90'
elif int(rotation_command[1:]) == 180:
flip = {'N': 'S', 'E': 'W', 'S': 'N', 'W': 'E'}
return flip[cur_direction... |
# https://codeforces.com/problemsets/acmsguru/problem/99999/100
A, B = map(int, input().split())
print(A+B)
| (a, b) = map(int, input().split())
print(A + B) |
# Hand decompiled day 19 part 2
a,b,c,d,e,f = 1,0,0,0,0,0
c += 2
c *= c
c *= 209
b += 2
b *= 22
b += 7
c += b
if a == 1:
b = 27
b *= 28
b += 29
b *= 30
b *= 14
b *= 32
c += b
a = 0
for d in range(1, c+1):
if c % d == 0:
a += d
print(a) | (a, b, c, d, e, f) = (1, 0, 0, 0, 0, 0)
c += 2
c *= c
c *= 209
b += 2
b *= 22
b += 7
c += b
if a == 1:
b = 27
b *= 28
b += 29
b *= 30
b *= 14
b *= 32
c += b
a = 0
for d in range(1, c + 1):
if c % d == 0:
a += d
print(a) |
def go(o, a, b):
if o == '+':
return a + b
return a * b
def main():
a, o, b = int(input()), input(), int(input())
return go(o, a, b)
if __name__ == '__main__':
print(main())
| def go(o, a, b):
if o == '+':
return a + b
return a * b
def main():
(a, o, b) = (int(input()), input(), int(input()))
return go(o, a, b)
if __name__ == '__main__':
print(main()) |
#
# This file contains the Python code from Program 14.14 of
# "Data Structures and Algorithms
# with Object-Oriented Design Patterns in Python"
# by Bruno R. Preiss.
#
# Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved.
#
# http://www.brpreiss.com/books/opus7/programs/pgm14_14.txt
#
class SimpleRV(Ra... | class Simplerv(RandomVariable):
def get_next(self):
return RandomNumberGenerator.next |
def test_list(client, seeder, utils):
user_id, admin_unit_id = seeder.setup_base()
seeder.create_event(admin_unit_id)
url = utils.get_url("planing")
utils.get_ok(url)
url = utils.get_url("planing", keyword="name")
utils.get_ok(url)
| def test_list(client, seeder, utils):
(user_id, admin_unit_id) = seeder.setup_base()
seeder.create_event(admin_unit_id)
url = utils.get_url('planing')
utils.get_ok(url)
url = utils.get_url('planing', keyword='name')
utils.get_ok(url) |
class Solution:
def to_hex(self, num: int) -> str:
if num == 0:
return "0"
prefix, ans = "0123456789abcdef", ""
num = 2 ** 32 + num if num < 0 else num
while num:
item = num & 15 # num % 16
ans = prefix[item] + ans
num >>= 4 # num //=... | class Solution:
def to_hex(self, num: int) -> str:
if num == 0:
return '0'
(prefix, ans) = ('0123456789abcdef', '')
num = 2 ** 32 + num if num < 0 else num
while num:
item = num & 15
ans = prefix[item] + ans
num >>= 4
return an... |
def partTwo(instr: str) -> int:
# This is the parsing section
service_list = instr.strip().split("\n")[-1].split(",")
eqns = []
for i, svc in enumerate(service_list):
if svc == "x":
continue
svc = int(svc)
v = 0
if i != 0:
v = svc - i # This is ... | def part_two(instr: str) -> int:
service_list = instr.strip().split('\n')[-1].split(',')
eqns = []
for (i, svc) in enumerate(service_list):
if svc == 'x':
continue
svc = int(svc)
v = 0
if i != 0:
v = svc - i
eqns.append((v, svc))
n = 1
... |
'''
Motion Event Provider
=====================
Abstract class for the implemention of a
:class:`~kivy.input.motionevent.MotionEvent`
provider. The implementation must support the
:meth:`~MotionEventProvider.start`, :meth:`~MotionEventProvider.stop` and
:meth:`~MotionEventProvider.update` methods.
'''
__all__ = ('Mot... | """
Motion Event Provider
=====================
Abstract class for the implemention of a
:class:`~kivy.input.motionevent.MotionEvent`
provider. The implementation must support the
:meth:`~MotionEventProvider.start`, :meth:`~MotionEventProvider.stop` and
:meth:`~MotionEventProvider.update` methods.
"""
__all__ = ('Moti... |
class Model(object):
def __init__(self, xml):
self.raw_data = xml
def __str__(self):
return self.raw_data.toprettyxml( )
def _get_attribute(self, attr):
val = self.raw_data.getAttribute(attr)
if val == '':
return None
return val
def _get_eleme... | class Model(object):
def __init__(self, xml):
self.raw_data = xml
def __str__(self):
return self.raw_data.toprettyxml()
def _get_attribute(self, attr):
val = self.raw_data.getAttribute(attr)
if val == '':
return None
return val
def _get_element(sel... |
# cook your dish here
a=int(input())
b=int(input())
while(1):
if a%b==0:
print(a)
break
else:
a-=1
| a = int(input())
b = int(input())
while 1:
if a % b == 0:
print(a)
break
else:
a -= 1 |
# -*- coding: utf-8 -*-
AUCTIONS = {
'simple': 'openprocurement.auction.esco.auctions.simple',
'multilot': 'openprocurement.auction.esco.auctions.multilot',
}
| auctions = {'simple': 'openprocurement.auction.esco.auctions.simple', 'multilot': 'openprocurement.auction.esco.auctions.multilot'} |
# python3
def max_pairwise_product(numbers):
x = sorted(numbers)
n = len(numbers)
return x[n-1] * x[n-2]
if __name__ == '__main__':
input_n = int(input())
input_numbers = [int(x) for x in input().split()]
print(max_pairwise_product(input_numbers))
| def max_pairwise_product(numbers):
x = sorted(numbers)
n = len(numbers)
return x[n - 1] * x[n - 2]
if __name__ == '__main__':
input_n = int(input())
input_numbers = [int(x) for x in input().split()]
print(max_pairwise_product(input_numbers)) |
'''
Homework assignment for the 'Python is easy' course by Pirple.
Written by Ed Yablonsky.
It pprints the numbers from 1 to 100.
But for multiples of three print "Fizz" instead of the number and for the
multiples of five print "Buzz".
For numbers which are multiples of both three and five print "FizzBuzz".
It also a... | """
Homework assignment for the 'Python is easy' course by Pirple.
Written by Ed Yablonsky.
It pprints the numbers from 1 to 100.
But for multiples of three print "Fizz" instead of the number and for the
multiples of five print "Buzz".
For numbers which are multiples of both three and five print "FizzBuzz".
It also a... |
a=input()
print(a)
print(a)
print(a)
| a = input()
print(a)
print(a)
print(a) |
# Fancy-pants method for getting a where clause that groups adjacent image keys
# using "BETWEEN X AND Y" ... unfortunately this usually takes far more
# characters than using "ImageNumber IN (X,Y,Z...)" since we don't run into
# queries asking for consecutive image numbers very often (except when we do it
# deli... | def get_where_clause_for_images(keys, is_sorted=False):
"""
takes a list of keys and returns a (hopefully) short where clause that
includes those keys.
"""
def in_sequence(k1, k2):
if len(k1) > 1:
if k1[:-1] != k2[:-1]:
return False
return k1[-1] == k2[-1... |
g = int(input().strip())
for _ in range(g):
n = int(input().strip())
s = [int(x) for x in input().strip().split(' ')]
x = 0
for i in s:
x ^= i
if len(set(s))==1 and 1 in s:
#here x=0 or 1
if x:#odd no. of ones
print("Second")
else:#even no. of... | g = int(input().strip())
for _ in range(g):
n = int(input().strip())
s = [int(x) for x in input().strip().split(' ')]
x = 0
for i in s:
x ^= i
if len(set(s)) == 1 and 1 in s:
if x:
print('Second')
else:
print('First')
elif x:
print('First')... |
class A(object):
def do_this(self):
print('do_this() in A')
class B(A):
pass
class C(A):
def do_this(self):
print('do_this() in C')
class D(B, C):
pass
D_instance = D()
D_instance.do_this()
print(D.mro()) # Method resolution order | class A(object):
def do_this(self):
print('do_this() in A')
class B(A):
pass
class C(A):
def do_this(self):
print('do_this() in C')
class D(B, C):
pass
d_instance = d()
D_instance.do_this()
print(D.mro()) |
a, b = 0, 1
while b < 10:
print(b)
a, b = b, a + b
# 1
# 1
# 2
# 3
# 5
# 8
a, b = 0, 1
while b < 1000:
print(b, end='->')
a, b = b, a + b
# 1->1->2->3->5->8->13->21->34->55->89->144->233->377->610->987->%
| (a, b) = (0, 1)
while b < 10:
print(b)
(a, b) = (b, a + b)
(a, b) = (0, 1)
while b < 1000:
print(b, end='->')
(a, b) = (b, a + b) |
class AutoScaleSettingVO:
def __init__(self, mini_size=1, max_size=1, mem_exc=0, deploy_name = ""):
self.miniSize = mini_size
self.maxSize = max_size
self.memExc = mem_exc
self.deployName = deploy_name
self.operationResult = ""
| class Autoscalesettingvo:
def __init__(self, mini_size=1, max_size=1, mem_exc=0, deploy_name=''):
self.miniSize = mini_size
self.maxSize = max_size
self.memExc = mem_exc
self.deployName = deploy_name
self.operationResult = '' |
#
# PySNMP MIB module STN-ATM-VPN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/STN-ATM-VPN-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:03:27 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, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
class MenuItem:
# Definiskan method info
def info(self):
print('Tampilkan nama dan harga dari menu item')
menu_item1 = MenuItem()
menu_item1.name = 'Roti Lapis'
menu_item1.price = 5
# Panggil method info dari menu_item1
menu_item1.info()
menu_item2 = MenuItem()
menu_item2.name = 'Kue Coklat'
menu_i... | class Menuitem:
def info(self):
print('Tampilkan nama dan harga dari menu item')
menu_item1 = menu_item()
menu_item1.name = 'Roti Lapis'
menu_item1.price = 5
menu_item1.info()
menu_item2 = menu_item()
menu_item2.name = 'Kue Coklat'
menu_item2.price = 4
menu_item2.info() |
#!/user/bin/python
'''Number of Inversions
'''
| """Number of Inversions
""" |
class HideX(object):
# def x():
# def fget(self):
# return ~self.__x
# def fset(self, x):
# assert isinstance(x, int), 'x must be int'
# self.__x = ~x
# return locals()
# x = property(**x())
@property
def x(self):
return ~self.__x
@x.setter
def x(self, x):
assert isinstance(x, int), 'x must be... | class Hidex(object):
@property
def x(self):
return ~self.__x
@x.setter
def x(self, x):
assert isinstance(x, int), 'x must be int'
self.__x = ~x
o = hide_x()
o.x = 5
print(o.x)
print(o._HideX__x) |
#coding=utf-8
'''
Created on 2015-10-10
@author: Devuser
'''
class HomeTaskPath(object):
left_nav_template_path="home/home_left_nav.html"
sub_nav_template_path="task/home_task_leftsub_nav.html"
task_index_path="task/home_task_index.html"
class HomeProjectPath(object):
left_nav_template_path="home/ho... | """
Created on 2015-10-10
@author: Devuser
"""
class Hometaskpath(object):
left_nav_template_path = 'home/home_left_nav.html'
sub_nav_template_path = 'task/home_task_leftsub_nav.html'
task_index_path = 'task/home_task_index.html'
class Homeprojectpath(object):
left_nav_template_path = 'home/home_left... |
class Reccomandation:
def __init__(self, input_text):
self.text = input_text
def __get__(self, name ):
return self.name
| class Reccomandation:
def __init__(self, input_text):
self.text = input_text
def __get__(self, name):
return self.name |
num_classes = 81
# model settings
model = dict(
type='SOLOv2',
#pretrained='torchvision://resnet50', # The backbone weights will be overwritten when using load_from or resume_from.
# https://github.com/open-mmlab/mmdetection/issues/7817#issuecomment-1108503826
backbone=dict(
type='ResNet',
... | num_classes = 81
model = dict(type='SOLOv2', backbone=dict(type='ResNet', depth=50, in_channels=3, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, style='pytorch'), neck=dict(type='FPN', in_channels=[256, 512, 1024, 2048], out_channels=256, start_level=0, num_outs=5), bbox_head=dict(type='SOLOv2Head', num_cla... |
#!/usr/bin/env prey
async def main():
word = input("Give me a word: ")
await x(f"echo {word}")
| async def main():
word = input('Give me a word: ')
await x(f'echo {word}') |
class ToolConfig ():
def __init__ (self):
self.one = './data/onetwothree1.wav'
self.two = './data/onetwothree8.wav'
self.digits_path = './data/digits'
| class Toolconfig:
def __init__(self):
self.one = './data/onetwothree1.wav'
self.two = './data/onetwothree8.wav'
self.digits_path = './data/digits' |
#
# PySNMP MIB module SW-DES3x50-ACLMGMT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-DES3x50-ACLMGMT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:12:30 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) ... |
# Michael O'Regan 05/May/2019
# https://www.sanfoundry.com/python-program-implement-bucket-sort/
def bucketSort(alist):
largest = max(alist)
length = len(alist)
size = largest/length
buckets = [[] for _ in range(length)]
for i in range(length):
j = int(alist[i]/size)
if j != lengt... | def bucket_sort(alist):
largest = max(alist)
length = len(alist)
size = largest / length
buckets = [[] for _ in range(length)]
for i in range(length):
j = int(alist[i] / size)
if j != length:
buckets[j].append(alist[i])
else:
buckets[length - 1].append... |
divs = {}
def sm(x):
s = 0
for i in range(2,int(x**0.5)):
if x%i == 0:
s += i
s += x/i
if i*i == x:
s -= i
return s+1
for i in range(10001):
divs[i] = sm(i)
ans = 0
for i in range(10001):
for j in range(10001):
if divs[i] == j and divs[j] == i and i!=j:
ans += i
print(ans)
| divs = {}
def sm(x):
s = 0
for i in range(2, int(x ** 0.5)):
if x % i == 0:
s += i
s += x / i
if i * i == x:
s -= i
return s + 1
for i in range(10001):
divs[i] = sm(i)
ans = 0
for i in range(10001):
for j in range(10001):
if divs[i... |
#######################
# MaudeMiner Settings #
#######################
# Database settings
DATABASE_PATH = '/Users/tklovett/maude/'
DATABASE_NAME = 'maude'
# These setting control where the text files and zip files retrieved from the FDA website are stored
DATA_PATH = '/Users/tklovett/maude/data/'
ZIPS_PATH = DATA_P... | database_path = '/Users/tklovett/maude/'
database_name = 'maude'
data_path = '/Users/tklovett/maude/data/'
zips_path = DATA_PATH + 'zips/'
txts_path = DATA_PATH + 'txts/'
maude_data_origin = 'http://www.fda.gov/MedicalDevices/DeviceRegulationandGuidance/PostmarketRequirements/ReportingAdverseEvents/ucm127891.htm'
lines... |
# https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
# 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 sortedArrayToBST(self, nums:... | class Solution:
def sorted_array_to_bst(self, nums: List[int]) -> TreeNode:
return self.generateTree(nums, 0, len(nums) - 1)
def generate_tree(self, nums, left, right):
if left > right:
return None
mid = (left + right) // 2
cur_node = tree_node(nums[mid])
cu... |
class _LinearWithBias(Module):
__parameters__ = ["weight", "bias", ]
__buffers__ = []
weight : Tensor
bias : Tensor
training : bool
| class _Linearwithbias(Module):
__parameters__ = ['weight', 'bias']
__buffers__ = []
weight: Tensor
bias: Tensor
training: bool |
count = 0
current_group = set()
with open('in', 'r') as f:
for line in f.readlines():
l = line.strip()
if len(l) == 0:
# this is end of the last group
count += len(current_group)
current_group = set()
else:
# add answers to the current group
... | count = 0
current_group = set()
with open('in', 'r') as f:
for line in f.readlines():
l = line.strip()
if len(l) == 0:
count += len(current_group)
current_group = set()
else:
for chr in l:
current_group.add(chr)
count += len(current_group)
... |
stim_positions = {
"double": [
[(0.4584, 0.2575, 0.2038), (0.4612, 0.2690, -0.0283)], # 3d location
[(0.4601, 0.1549, 0.1937), (0.4614, 0.1660, -0.0358)],
],
"double_20070301": [
[(0.4538, 0.2740, 0.1994), (0.4565, 0.2939, -0.0531)], # top highy
[(0.4516, 0.1642, 0.1872), (... | stim_positions = {'double': [[(0.4584, 0.2575, 0.2038), (0.4612, 0.269, -0.0283)], [(0.4601, 0.1549, 0.1937), (0.4614, 0.166, -0.0358)]], 'double_20070301': [[(0.4538, 0.274, 0.1994), (0.4565, 0.2939, -0.0531)], [(0.4516, 0.1642, 0.1872), (0.4541, 0.1767, -0.0606)]], 'half': [[(0.4567, 0.2029, 0.1958), (0.4581, 0.2166,... |
class Node(object):
def __init__(self):
super().__init__()
self.__filename = ''
self.__children = []
self.__line_number = 0
self.__column_number = 0
def get_children(self) -> list:
return self.__children
def add_child(self, child: 'Node') -> None:
a... | class Node(object):
def __init__(self):
super().__init__()
self.__filename = ''
self.__children = []
self.__line_number = 0
self.__column_number = 0
def get_children(self) -> list:
return self.__children
def add_child(self, child: 'Node') -> None:
a... |
def binary_search(nums, target):
low = 0
high = len(nums) - 1
while low <= high:
mid = low + ((high - low) // 2)
if nums[mid] > target:
high = mid-1
elif nums[mid] < target:
low = mid+1
else:
return mid
return -1
if __name__ == "__mai... | def binary_search(nums, target):
low = 0
high = len(nums) - 1
while low <= high:
mid = low + (high - low) // 2
if nums[mid] > target:
high = mid - 1
elif nums[mid] < target:
low = mid + 1
else:
return mid
return -1
if __name__ == '__mai... |
#
# PySNMP MIB module ALVARION-USER-ACCOUNT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALVARION-USER-ACCOUNT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:06:37 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.... | (alvarion_mgmt_v2,) = mibBuilder.importSymbols('ALVARION-SMI', 'alvarionMgmtV2')
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range... |
class Solution:
def superPow(self, a: int, b: List[int]) -> int:
if (a % 1337 == 0):
return 0
return pow(a, reduce(lambda x, y: x * 10 + y, b), 1337) | class Solution:
def super_pow(self, a: int, b: List[int]) -> int:
if a % 1337 == 0:
return 0
return pow(a, reduce(lambda x, y: x * 10 + y, b), 1337) |
print("Hello, world!")
x = "Hello World"
print(x)
y = 42
print(y) | print('Hello, world!')
x = 'Hello World'
print(x)
y = 42
print(y) |
def StringToDict(s):
RES = dict()
for e in set(s):
RES[e] = 0
for e in s:
RES[e] += 1
return RES
| def string_to_dict(s):
res = dict()
for e in set(s):
RES[e] = 0
for e in s:
RES[e] += 1
return RES |
DO_RUN_BIAS_TEST=False
DEBUG = False
INPUT_CSV=False
ROOT_FOLDER="/home/jupyter/forms-ocr"
OUTPUT_FOLDER= ROOT_FOLDER + "/sample_images"
GEN_FOLDER = OUTPUT_FOLDER + "/img"
LOCALE = "en_GB"
DUMMY_GENERATOR=0
FIELD_DICT_3FIELDS= {'Name':(0,0),'Tax':(0,0),
'Address':(0,0)
}
FIELD_DICT_7FIELDS= {'N... | do_run_bias_test = False
debug = False
input_csv = False
root_folder = '/home/jupyter/forms-ocr'
output_folder = ROOT_FOLDER + '/sample_images'
gen_folder = OUTPUT_FOLDER + '/img'
locale = 'en_GB'
dummy_generator = 0
field_dict_3_fields = {'Name': (0, 0), 'Tax': (0, 0), 'Address': (0, 0)}
field_dict_7_fields = {'Name':... |
class Student:
studentLevel = 'first year computer science 2020/2021 session'
studentCounter = 0
def __init__(self, thename, thematricno, thesex, thehostelname , theage,thecsc102examscore):
self.name = thename
self.matricno = thematricno
self.sex = thesex
self.hostelname = t... | class Student:
student_level = 'first year computer science 2020/2021 session'
student_counter = 0
def __init__(self, thename, thematricno, thesex, thehostelname, theage, thecsc102examscore):
self.name = thename
self.matricno = thematricno
self.sex = thesex
self.hostelname =... |
# success values
# sql.h
SQL_INVALID_HANDLE = -2
SQL_ERROR = -1
SQL_SUCCESS = 0
SQL_SUCCESS_WITH_INFO = 1
SQL_STILL_EXECUTING = 2
SQL_NEED_DATA = 99
SQL_NO_DATA_FOUND = 100
sql_errors = [SQL_ERROR, SQL_INVALID_HANDLE]
# sqlext.h
SQL_FETCH_NEXT = 0x01
SQL_FETCH_FIRST = 0x02
SQL_FETCH_LAST ... | sql_invalid_handle = -2
sql_error = -1
sql_success = 0
sql_success_with_info = 1
sql_still_executing = 2
sql_need_data = 99
sql_no_data_found = 100
sql_errors = [SQL_ERROR, SQL_INVALID_HANDLE]
sql_fetch_next = 1
sql_fetch_first = 2
sql_fetch_last = 4
sql_fetch_prior = 8
sql_fetch_absolute = 16
sql_fetch_relative = 32
s... |
class Solution:
# @param A : list of integers
# @return an integer
def perfectPeak(self, A):
n = len(A)
left = [0] * n
right = [0] * n
left[0] = A[0]
right[n-1] = A[n-1]
for i in range(1, n) :
left[i] = max(left[i-1], A[i])
for i in rang... | class Solution:
def perfect_peak(self, A):
n = len(A)
left = [0] * n
right = [0] * n
left[0] = A[0]
right[n - 1] = A[n - 1]
for i in range(1, n):
left[i] = max(left[i - 1], A[i])
for i in range(n - 2, -1, -1):
right[i] = min(right[i + ... |
class Matrix:
def __init__(self, matrix_string: str):
# Split matrix_string into lines, split lines on whitespace and cast elements as integers.
self.matrix = [[int(j) for j in i.split()] for i in matrix_string.splitlines()]
def row(self, index: int) -> list[int]:
return self.matrix[ind... | class Matrix:
def __init__(self, matrix_string: str):
self.matrix = [[int(j) for j in i.split()] for i in matrix_string.splitlines()]
def row(self, index: int) -> list[int]:
return self.matrix[index - 1]
def column(self, index: int) -> list[int]:
return [i[index - 1] for i in self... |
Colors = {'snow': ('255', '250', '250'),
'ghostwhite': ('248', '248', '255'),
'GhostWhite': ('248', '248', '255'),
'whitesmoke': ('245', '245', '245'),
'WhiteSmoke': ('245', '245', '245'),
'gainsboro': ('220', '220', '220'),
'floralwhite': ('255', '250', '240'),
'FloralWhite': ('255', '250', '240'),
'oldlace': ('253', ... | colors = {'snow': ('255', '250', '250'), 'ghostwhite': ('248', '248', '255'), 'GhostWhite': ('248', '248', '255'), 'whitesmoke': ('245', '245', '245'), 'WhiteSmoke': ('245', '245', '245'), 'gainsboro': ('220', '220', '220'), 'floralwhite': ('255', '250', '240'), 'FloralWhite': ('255', '250', '240'), 'oldlace': ('253', ... |
class Student:
def __init__(self, id: str, name: str) -> None:
self.id = id
self.name = name
class Course:
def __init__(self, id: str, name: str, hours: int, grades = None) -> None:
self.id = id
self.name = name
self.hours = hours
self.grades = grades or {}
... | class Student:
def __init__(self, id: str, name: str) -> None:
self.id = id
self.name = name
class Course:
def __init__(self, id: str, name: str, hours: int, grades=None) -> None:
self.id = id
self.name = name
self.hours = hours
self.grades = grades or {}
... |
class WebServerDefinitions:
name = None
root = None
template = None
https = False
default_template = 'laravel'
def __init__(self, name, root, template=None, https=False):
self.name = name
self.root = root
self.https = https
if not template:
template ... | class Webserverdefinitions:
name = None
root = None
template = None
https = False
default_template = 'laravel'
def __init__(self, name, root, template=None, https=False):
self.name = name
self.root = root
self.https = https
if not template:
template =... |
class GraphReprBase(object):
@staticmethod
def read_from_file(input_file):
raise NotImplemented()
| class Graphreprbase(object):
@staticmethod
def read_from_file(input_file):
raise not_implemented() |
STATUS_MAP = {
'RECEIVED_UNREAD': b'0',
'RECEIVED_READ': b'1',
'STORED_UNSENT': b'2',
'STORED_SENT': b'3',
'ALL': b'4'
}
STATUS_MAP_R = {
b'0': 'RECEIVED_UNREAD',
b'1': 'RECEIVED_READ',
b'2': 'STORED_UNSENT',
b'3': 'STORED_SENT',
b'4': 'ALL'
}
DELETE_FLAG = {
'ALL_READ': b... | status_map = {'RECEIVED_UNREAD': b'0', 'RECEIVED_READ': b'1', 'STORED_UNSENT': b'2', 'STORED_SENT': b'3', 'ALL': b'4'}
status_map_r = {b'0': 'RECEIVED_UNREAD', b'1': 'RECEIVED_READ', b'2': 'STORED_UNSENT', b'3': 'STORED_SENT', b'4': 'ALL'}
delete_flag = {'ALL_READ': b'1', 'READ_AND_SENT': b'2', 'READ_AND_UNSENT': b'3',... |
def collatz(n, count):
if n == 1:
return count
else:
count = count + 1
if n % 2 == 0:
n = n /2
else:
n = 3 * n + 1
return collatz(n, count)
max_collatz = 1
iteration = 1
for i in range(1, 1000000):
count = 1
contesting = collatz(i, 1)
... | def collatz(n, count):
if n == 1:
return count
else:
count = count + 1
if n % 2 == 0:
n = n / 2
else:
n = 3 * n + 1
return collatz(n, count)
max_collatz = 1
iteration = 1
for i in range(1, 1000000):
count = 1
contesting = collatz(i, 1)
... |
#!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
# Functions allow variable-length argument lists
def main():
kitten('meow', 'grrr', 'purr')
# We treat it as a sequence, actually a tuple
def kitten(*args): # It's denoted as *args. args is the conventional name
if len(args): # If the length of ar... | def main():
kitten('meow', 'grrr', 'purr')
def kitten(*args):
if len(args):
for s in args:
print(s)
else:
print('Meow.')
if __name__ == '__main__':
main()
x = ('hiss', 'howl', 'roar', 'screech')
kitten(*x) |
for i in range(5):
for j in range(5):
if i==j:
print('#',end='')
else:
print("+",end='')
print("")
| for i in range(5):
for j in range(5):
if i == j:
print('#', end='')
else:
print('+', end='')
print('') |
DATA_URL = 'http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data'
DATA_COLUMNS = ['MPG', 'Cylinders', 'Displacement', 'Horsepower', 'Weight',
'Acceleration', 'Model Year', 'Origin']
NORMALIZE = False
TARGET_VARIABLE = 'MPG'
# FEATURES_TO_USE = [ 'Cylinders', 'Displacement', 'H... | data_url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data'
data_columns = ['MPG', 'Cylinders', 'Displacement', 'Horsepower', 'Weight', 'Acceleration', 'Model Year', 'Origin']
normalize = False
target_variable = 'MPG'
features_to_use = ['MPG', 'Horsepower', 'Displacement']
normalize_hor... |
# question : https://quera.ir/problemset/contest/8901
x_n = input().split(' ')
x = x_n[1]
n = int(x_n[0])
default_value = {
'L': 0,
'M': 0,
'R': 0,
}
movements = []
for one_input in range(n):
movements.append(input().split(' '))
default_value[x] = 1
for one_movement in movements:
temp = default_va... | x_n = input().split(' ')
x = x_n[1]
n = int(x_n[0])
default_value = {'L': 0, 'M': 0, 'R': 0}
movements = []
for one_input in range(n):
movements.append(input().split(' '))
default_value[x] = 1
for one_movement in movements:
temp = default_value.get(one_movement[0])
default_value[one_movement[0]] = default_v... |
#!/usr/bin/env python3
def get_vertices(wire):
x = y = steps = 0
vertices = [(x, y, 0)]
for edge in wire:
length = int(edge[1:])
steps += length
if edge[0] == "R":
x += length
if edge[0] == "L":
x -= length
if edge[0] == "U":
... | def get_vertices(wire):
x = y = steps = 0
vertices = [(x, y, 0)]
for edge in wire:
length = int(edge[1:])
steps += length
if edge[0] == 'R':
x += length
if edge[0] == 'L':
x -= length
if edge[0] == 'U':
y += length
if edge[0... |
dim=10.0
eta=0.5
steps=100 #must be integer (no decimal point)
rneighb=eta
| dim = 10.0
eta = 0.5
steps = 100
rneighb = eta |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: apemodefb
class EAnimCurvePropertyFb(object):
LclTranslation = 0
RotationOffset = 1
RotationPivot = 2
PreRotation = 3
PostRotation = 4
LclRotation = 5
ScalingOffset = 6
ScalingPivot = 7
LclScaling = 8... | class Eanimcurvepropertyfb(object):
lcl_translation = 0
rotation_offset = 1
rotation_pivot = 2
pre_rotation = 3
post_rotation = 4
lcl_rotation = 5
scaling_offset = 6
scaling_pivot = 7
lcl_scaling = 8
geometric_translation = 9
geometric_rotation = 10
geometric_scaling = 11 |
__author__ = 'tylin'
# from .bleu import Bleu
#
# __all__ = ['Bleu']
| __author__ = 'tylin' |
# General ES Constants
COUNT = 'count'
CREATE = 'create'
DOCS = 'docs'
FIELD = 'field'
FIELDS = 'fields'
HITS = 'hits'
ID = '_id'
INDEX = 'index'
INDEX_NAME = 'index_name'
ITEMS = 'items'
KILOMETERS = 'km'
MAPPING_DYNAMIC = 'dynamic'
MAPPING_MULTI_FIELD = 'multi_field'
MAPPING_NULL_VALUE = 'null_value'
MILES = 'mi'
OK ... | count = 'count'
create = 'create'
docs = 'docs'
field = 'field'
fields = 'fields'
hits = 'hits'
id = '_id'
index = 'index'
index_name = 'index_name'
items = 'items'
kilometers = 'km'
mapping_dynamic = 'dynamic'
mapping_multi_field = 'multi_field'
mapping_null_value = 'null_value'
miles = 'mi'
ok = 'ok'
properties = 'pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.