content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding:utf-8 -*-
WENCAI_LOGIN_URL = {
"scrape_transaction": 'http://www.iwencai.com/traceback/strategy/transaction',
"scrape_report": 'http://www.iwencai.com/traceback/strategy/submit',
'strategy': 'http://www.iwencai.com/traceback/strategy/submit',
"search": "http://www.iwencai.com/data-robot/e... | wencai_login_url = {'scrape_transaction': 'http://www.iwencai.com/traceback/strategy/transaction', 'scrape_report': 'http://www.iwencai.com/traceback/strategy/submit', 'strategy': 'http://www.iwencai.com/traceback/strategy/submit', 'search': 'http://www.iwencai.com/data-robot/extract-new', 'recommend_strategy': 'http:/... |
class ConfigAttributeDataTypes:
data_types = {
0: 'None',
1: 'Base64',
2: 'Boolean',
3: 'CaseExactString',
4: 'CaseIgnoreList',
5: 'CaseIgnoreString, String',
6: 'Counter',
7: 'DistinguishedName',
8: 'EMailAddress',
9: 'FaxNum... | class Configattributedatatypes:
data_types = {0: 'None', 1: 'Base64', 2: 'Boolean', 3: 'CaseExactString', 4: 'CaseIgnoreList', 5: 'CaseIgnoreString, String', 6: 'Counter', 7: 'DistinguishedName', 8: 'EMailAddress', 9: 'FaxNumber', 10: 'Hold', 11: 'Integer', 12: 'Interval', 13: 'IPNetworkAddress', 14: 'NetworkAddres... |
# Python code to demonstrate the working of
# "+" and "*"
# initializing list 1
lis = [1, 2, 3]
# initializing list 2
lis1 = [4, 5, 6]
# using "+" to concatenate lists
lis2= lis + lis1
# priting concatenated lists
print ("list after concatenation is : ", end="")
for i in range(0,len(lis2)):
print (lis2[i... | lis = [1, 2, 3]
lis1 = [4, 5, 6]
lis2 = lis + lis1
print('list after concatenation is : ', end='')
for i in range(0, len(lis2)):
print(lis2[i], end=' ')
print('\r')
lis3 = lis * 3
print('list after combining is : ', end='')
for i in range(0, len(lis3)):
print(lis3[i], end=' ') |
"""Kata: Get nth even number - Return the nth even number.
#1 Best Practices Solution by tedmiston, tachyonlabs, OQth, and others.
def nth_even(n):
return n * 2 - 2
"""
def nth_even(n):
"""Function I wrote that returns the nth even number."""
return (n * 2) - 2
| """Kata: Get nth even number - Return the nth even number.
#1 Best Practices Solution by tedmiston, tachyonlabs, OQth, and others.
def nth_even(n):
return n * 2 - 2
"""
def nth_even(n):
"""Function I wrote that returns the nth even number."""
return n * 2 - 2 |
# -*- coding: utf-8 -*-
stuff = ['hello', 'hi', 'how are you doing', 'im fine', 'how about you']
length_of_stuff = len(stuff)
index = 0
while index < length_of_stuff:
print(stuff[index])
index += 1
| stuff = ['hello', 'hi', 'how are you doing', 'im fine', 'how about you']
length_of_stuff = len(stuff)
index = 0
while index < length_of_stuff:
print(stuff[index])
index += 1 |
# Returns list of a specific attribute in yaml file. Attribute could be aliases/filter/category/id.
def icon_list(p_list, *pos):
if pos:
return [p_list[i][pos[0]] for i in range(len(p_list)) if (p_list[i][pos[0]] is not None)]
else:
return [p_list[i][2] for i in range(len(p_list))]
# Displays l... | def icon_list(p_list, *pos):
if pos:
return [p_list[i][pos[0]] for i in range(len(p_list)) if p_list[i][pos[0]] is not None]
else:
return [p_list[i][2] for i in range(len(p_list))]
def icon_output(l):
print('Icon(s) matched this criteria :')
for i in l:
print(i)
def give_id_uni... |
for x in range(10):
pass
for x in range(5):
a += x
b += 2
if False:
break
else:
continue
else:
c = 3
for index, val in enumerate(range(5)):
val *= 2
| for x in range(10):
pass
for x in range(5):
a += x
b += 2
if False:
break
else:
continue
else:
c = 3
for (index, val) in enumerate(range(5)):
val *= 2 |
# Que 20 Leap Year
print ("Leap Year Has 366 Days...")
print ('The Year Perfectly Divisible by 4 is A Leap Year')
z=0
for i in range(2010,2101,1):
if i%4==0:
z=z+1
if z<=10:
print(i,end=" ")
else:
z=1
print()
print(i,end=" ")
| print('Leap Year Has 366 Days...')
print('The Year Perfectly Divisible by 4 is A Leap Year')
z = 0
for i in range(2010, 2101, 1):
if i % 4 == 0:
z = z + 1
if z <= 10:
print(i, end=' ')
else:
z = 1
print()
print(i, end=' ') |
def get_ns_declare(fd):
while True:
line = fd.readline()
if line.strip().startswith('(ns'):
return line
def get_ns(filename):
with open(filename, 'r') as infile:
ns_declare = get_ns_declare(infile)
splited = ns_declare.split()
ns = splited[-1]
if ns.... | def get_ns_declare(fd):
while True:
line = fd.readline()
if line.strip().startswith('(ns'):
return line
def get_ns(filename):
with open(filename, 'r') as infile:
ns_declare = get_ns_declare(infile)
splited = ns_declare.split()
ns = splited[-1]
if ns.e... |
num1 = int(input())
num2 = int(input())
if num1 > num2:
print(num1-num2)
else:
print(num1+num2) | num1 = int(input())
num2 = int(input())
if num1 > num2:
print(num1 - num2)
else:
print(num1 + num2) |
def gp(a,r,n):
for i in range(n):
temp = a*pow(r,i)
print(temp,end=" ")
a = int(input())
r = int(input())
n = int(input())
gp(a,r,n)
| def gp(a, r, n):
for i in range(n):
temp = a * pow(r, i)
print(temp, end=' ')
a = int(input())
r = int(input())
n = int(input())
gp(a, r, n) |
class BatchReferenceSampler:
def __init__(
self, dataset, batch_size, label_sampler, annotation_sampler, point_sampler
):
self._dataset = dataset
self._batch_size = batch_size
self._label_sampler = label_sampler
self._annotation_sampler = annotation_sampler
self.... | class Batchreferencesampler:
def __init__(self, dataset, batch_size, label_sampler, annotation_sampler, point_sampler):
self._dataset = dataset
self._batch_size = batch_size
self._label_sampler = label_sampler
self._annotation_sampler = annotation_sampler
self._point_sampler... |
name = 'pybk8500'
version = '1.2.0'
description = 'BK-8500-Electronic-Load python library'
url = 'https://github.com/justengel/pybk8500'
author = 'Justin Engel'
author_email = 'jtengel08@gmail.com'
| name = 'pybk8500'
version = '1.2.0'
description = 'BK-8500-Electronic-Load python library'
url = 'https://github.com/justengel/pybk8500'
author = 'Justin Engel'
author_email = 'jtengel08@gmail.com' |
"""Base classes."""
class BaseEstimator:
"""Base class for all estimators."""
def __init__(self):
self._parameters = {}
self._residuals = None
self._fitted = False
self._t = None
self._y = None
self._y_predict = None
@property
def parameters(self):
... | """Base classes."""
class Baseestimator:
"""Base class for all estimators."""
def __init__(self):
self._parameters = {}
self._residuals = None
self._fitted = False
self._t = None
self._y = None
self._y_predict = None
@property
def parameters(self):
... |
"""
https://www.ssa.gov/oact/babynames/decades/names2010s.html
"""
first_names_male = """
noah liam jacob william mason ethan michael alexander james elijah benjamin daniel aiden logan jayden
matthew lucas david jackson joseph anthony samuel joshua gabriel andrew john christopher olive dylan carter
isaac luke henry o... | """
https://www.ssa.gov/oact/babynames/decades/names2010s.html
"""
first_names_male = '\nnoah liam jacob william mason ethan michael alexander james elijah benjamin daniel aiden logan jayden\nmatthew lucas david jackson joseph anthony samuel joshua gabriel andrew john christopher olive dylan carter\nisaac luke henry ow... |
# 1.11
# Replace list elements
#Replacing list elements is pretty easy. Simply subset the list and assign new values to the subset. You can select single elements or you can change entire list slices at once.
#Use the IPython Shell to experiment with the commands below. Can you tell what's happening and why?
#x = ["a... | areas = ['hallway', 11.25, 'kitchen', 18.0, 'living room', 20.0, 'bedroom', 10.75, 'bathroom', 9.5]
areas[-1] = 10.5
areas[4] = 'chill zone' |
class Solution:
def fullJustify(self, words: List[str], maxWidth: int) -> List[str]:
ans = []
todo = []
todo_size = 0
def combine(todo, todo_size):
spaces = maxWidth - todo_size
if len(todo) == 1:
return todo[0] + " " * spaces
b... | class Solution:
def full_justify(self, words: List[str], maxWidth: int) -> List[str]:
ans = []
todo = []
todo_size = 0
def combine(todo, todo_size):
spaces = maxWidth - todo_size
if len(todo) == 1:
return todo[0] + ' ' * spaces
ba... |
# Python - 3.6.0
BASIC_TESTS = (
(('45', '1'), '1451'),
(('13', '200'), '1320013'),
(('Soon', 'Me'), 'MeSoonMe'),
(('U', 'False'), 'UFalseU')
)
test.describe('Basic Tests')
for pair, result in BASIC_TESTS:
test.it("'{}', '{}'".format(*pair))
test.assert_equals(solution(*pair), result)
| basic_tests = ((('45', '1'), '1451'), (('13', '200'), '1320013'), (('Soon', 'Me'), 'MeSoonMe'), (('U', 'False'), 'UFalseU'))
test.describe('Basic Tests')
for (pair, result) in BASIC_TESTS:
test.it("'{}', '{}'".format(*pair))
test.assert_equals(solution(*pair), result) |
class Solution(object):
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
m = [[1]*i for i in range(1 , numRows + 1 )]
for i in range(numRows):
for j in range(1 , len(m[i]) - 1):
m[i... | class Solution(object):
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
m = [[1] * i for i in range(1, numRows + 1)]
for i in range(numRows):
for j in range(1, len(m[i]) - 1):
m[i][j] = m[i - 1][j - 1] + m[i... |
#list_intro.py
#What is a list?
# A collection of items in a particular order.
# Ex: The alphabet, digits 0-9, names of family
# Typically we will plural nouns for list names
star_treks = ['TOS', 'TNG', 'Voyager', 'DS9']
#print(star_treks)
#Accessing Elements
#Because lists are ordered, each element has an ind... | star_treks = ['TOS', 'TNG', 'Voyager', 'DS9']
print(star_treks[0].title())
print(star_treks[-1])
print(star_treks[-3])
message = f'The first star trek I watched was {star_treks[0].title()}.'
print(message) |
"""
@author: magician
@file: annotation_attribute.py
@date: 2020/8/4
"""
class Field(object):
"""
Field
"""
def __init__(self, name):
self.name = name
self.internal_name = '_' + name
def __get__(self, instance, instance_type):
if instance is None:
return s... | """
@author: magician
@file: annotation_attribute.py
@date: 2020/8/4
"""
class Field(object):
"""
Field
"""
def __init__(self, name):
self.name = name
self.internal_name = '_' + name
def __get__(self, instance, instance_type):
if instance is None:
return se... |
"""Top-level package for RocketPy."""
__author__ = """Mohammed Raihaan Usman"""
__email__ = 'raihaan.usman@gmail.com'
__version__ = '0.1.1' | """Top-level package for RocketPy."""
__author__ = 'Mohammed Raihaan Usman'
__email__ = 'raihaan.usman@gmail.com'
__version__ = '0.1.1' |
# link: https://leetcode.com/problems/add-and-search-word-data-structure-design/
class TrieNode(object):
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word=False
class WordDictionary(object):
def __init__(self):
"""
Initialize your data structure... | class Trienode(object):
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word = False
class Worddictionary(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.root = trie_node()
def add_word(self, wor... |
width = const(10)
height = const(16)
data = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, # Character 0x00 (0)
0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,... | width = const(10)
height = const(16)
data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 54, 0, 54, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... |
def merge_the_tools(string, n):
out = [list(string)[k:k+n] for k in range(0,len(list(string)),n)]
for x in out:
print(''.join(sorted(set(x), key=x.index)))
| def merge_the_tools(string, n):
out = [list(string)[k:k + n] for k in range(0, len(list(string)), n)]
for x in out:
print(''.join(sorted(set(x), key=x.index))) |
def calculate_determinant(matrix):
if len(matrix) is 1:
return matrix[0][0]
elif len(matrix) is 2:
return (matrix[0][0] * matrix[1][1]) - (matrix[1][0] * matrix[0][1])
total = float()
for i in range(0, len(matrix)):
cofactor = (-1 ^ i) * matrix[0][i]
minor = [ ]
for y in range(1, len(matrix)):
sub = ... | def calculate_determinant(matrix):
if len(matrix) is 1:
return matrix[0][0]
elif len(matrix) is 2:
return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]
total = float()
for i in range(0, len(matrix)):
cofactor = (-1 ^ i) * matrix[0][i]
minor = []
for y ... |
# -*- coding: UTF-8 -*-
FIXTURE_WEBVTT = """WEBVTT
00:14.848 --> 00:17.350
MAN:
When we think
of E equals m c-squared,
00:17.350 --> 00:18.752
we have this vision of Einstein
00:18.752 --> 00:20.887
as an old, wrinkly man
with white hair.
00:20.887 --> 00:26.760
MAN 2:
E equals m c-squared is
not about an old Eins... | fixture_webvtt = "WEBVTT\n\n00:14.848 --> 00:17.350\nMAN:\nWhen we think\nof E equals m c-squared,\n\n00:17.350 --> 00:18.752\nwe have this vision of Einstein\n\n00:18.752 --> 00:20.887\nas an old, wrinkly man\nwith white hair.\n\n00:20.887 --> 00:26.760\nMAN 2:\nE equals m c-squared is\nnot about an old Einstein.\n\n0... |
PARAM_TOKEN = '%s'
class DbContext(object):
"""
"""
def __init__(self, connection, param_token=PARAM_TOKEN):
self.param_token = param_token
self.connection = connection
self.cursor = connection.cursor()
mod = self.cursor.connection.__class__.__module__.split('.', 1)[0]
... | param_token = '%s'
class Dbcontext(object):
"""
"""
def __init__(self, connection, param_token=PARAM_TOKEN):
self.param_token = param_token
self.connection = connection
self.cursor = connection.cursor()
mod = self.cursor.connection.__class__.__module__.split('.', 1)[0]
... |
class BitmapScalingMode(Enum,IComparable,IFormattable,IConvertible):
"""
Specifies which algorithm is used to scale bitmap images.
enum BitmapScalingMode,values: Fant (2),HighQuality (2),Linear (1),LowQuality (1),NearestNeighbor (3),Unspecified (0)
"""
def __eq__(self,*args):
""" x.__eq__(y) <==> x==y... | class Bitmapscalingmode(Enum, IComparable, IFormattable, IConvertible):
"""
Specifies which algorithm is used to scale bitmap images.
enum BitmapScalingMode,values: Fant (2),HighQuality (2),Linear (1),LowQuality (1),NearestNeighbor (3),Unspecified (0)
"""
def __eq__(self, *args):
""" x.__eq__(y)... |
if __name__ == '__main__':
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def __init__(self):
... | if __name__ == '__main__':
class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def __init__(self):
self.head = None
... |
#! /usr/bin/env python3
description = '''
Roman numerals
Problem 89
The rules for writing Roman numerals allow for many ways of writing each number (see About Roman Numerals...). However, there is always a "best" way of writing a particular number.
For example, the following represent all of the legitimate ways of wr... | description = '\nRoman numerals\nProblem 89\nThe rules for writing Roman numerals allow for many ways of writing each number (see About Roman Numerals...). However, there is always a "best" way of writing a particular number.\n\nFor example, the following represent all of the legitimate ways of writing the number sixte... |
# Finding the longest increasing subsequence in an array
# [3, 4, -1, 0, 6, 2, 3] -> [-1, 0, 2, 3]
# [2, 5, 1, 8, 3] -> [2, 5, 8]
def finding_longest_subsequence(arr):
if not arr:
return 0
longest_subsequence = 1
longest_arr = [arr[0]]
max_observed = float('-inf')
for idx in ran... | def finding_longest_subsequence(arr):
if not arr:
return 0
longest_subsequence = 1
longest_arr = [arr[0]]
max_observed = float('-inf')
for idx in range(1, len(arr)):
ele = arr[idx]
while True:
if longest_arr and longest_arr[-1] > ele:
longest_arr.p... |
class OpenPoseSkeleton(object):
def __init__(self):
self.root = 'MidHip'
self.keypoint2index = {
'Nose': 0,
'Neck': 1,
'RShoulder': 2,
'RElbow': 3,
'RWrist': 4,
'LShoulder': 5,
'LElbow': 6,
'LWrist': 7,
... | class Openposeskeleton(object):
def __init__(self):
self.root = 'MidHip'
self.keypoint2index = {'Nose': 0, 'Neck': 1, 'RShoulder': 2, 'RElbow': 3, 'RWrist': 4, 'LShoulder': 5, 'LElbow': 6, 'LWrist': 7, 'MidHip': 8, 'RHip': 9, 'RKnee': 10, 'RAnkle': 11, 'LHip': 12, 'LKnee': 13, 'LAnkle': 14, 'REye':... |
class CountingSort:
def __init__(self,a):
self.a = a
def result(self):
maxSize = max(self.a)
presence = [0 for x in range(maxSize+1)]
for element in self.a:
presence[element] += 1
for i in range(1,len(presence)):
presence[i] = presence[i] + presen... | class Countingsort:
def __init__(self, a):
self.a = a
def result(self):
max_size = max(self.a)
presence = [0 for x in range(maxSize + 1)]
for element in self.a:
presence[element] += 1
for i in range(1, len(presence)):
presence[i] = presence[i] + ... |
class BlockcertValidationError(Exception):
pass
class InvalidUrlError(Exception):
pass
| class Blockcertvalidationerror(Exception):
pass
class Invalidurlerror(Exception):
pass |
##
##Namelog.py
##
##
##uses list to load name
##
playerName = "???"
def nameWrite():
text_file = open("name.txt", "w+")
print('Girl: What was your name?')
ins = input()
if ins == "":
ins = "Hazel"
print('I couldnt be bothered to put a name so call me Hazel')
text_f... | player_name = '???'
def name_write():
text_file = open('name.txt', 'w+')
print('Girl: What was your name?')
ins = input()
if ins == '':
ins = 'Hazel'
print('I couldnt be bothered to put a name so call me Hazel')
text_file.write(ins)
text_file.close()
def name_read():
text_f... |
# Scrapy settings for Newengland project
#
# For simplicity, this file contains only the most important settings by
# default. All the other settings are documented here:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
#
BOT_NAME = 'Newengland'
SPIDER_MODULES = ['Newengland.spiders']
NEWSPIDER_MODULE = '... | bot_name = 'Newengland'
spider_modules = ['Newengland.spiders']
newspider_module = 'Newengland.spiders' |
'''
this file contains all the functions that contribute in the making of tic tac toe
__________ about the game __________
1-the grid shape :
1 | 2 | 3
-----------
4 | 5 | 6
-----------
7 | 8 | 9
2-how to play the game :
the player... | """
this file contains all the functions that contribute in the making of tic tac toe
__________ about the game __________
1-the grid shape :
1 | 2 | 3
-----------
4 | 5 | 6
-----------
7 | 8 | 9
2-how to play the game :
the player... |
# -*- coding: utf8 -*-
class Clients:
"""
Get clients information.
"""
def __init__(self, burp_version=1, conf=None):
"""
:param burp_version: version of burp backend to work with 1/2
:param conf: burp_ui configuration to use.
"""
self.version = burp_version... | class Clients:
"""
Get clients information.
"""
def __init__(self, burp_version=1, conf=None):
"""
:param burp_version: version of burp backend to work with 1/2
:param conf: burp_ui configuration to use.
"""
self.version = burp_version
self.buiconf = co... |
"""
Link: https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc8/00000000002d82e6
Language: Python
Written by: Mostofa Adib Shakib
Time complexity: O(n)
Space Complexity: O(1)
"""
T = int(input())
for x in range(1, T + 1):
N = int(input())
Q = [int(s) for s in input().split(" ")]
... | """
Link: https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc8/00000000002d82e6
Language: Python
Written by: Mostofa Adib Shakib
Time complexity: O(n)
Space Complexity: O(1)
"""
t = int(input())
for x in range(1, T + 1):
n = int(input())
q = [int(s) for s in input().split(' ')]
y = 0
... |
#
# @lc app=leetcode id=401 lang=python3
#
# [401] Binary Watch
#
# @lc code=start
class Solution:
def readBinaryWatch(self, num: int) -> List[str]:
if num > 10:
return []
times = []
for h in range(12): # 4 LEDs represent the hours (0-11)
for m in range(60): # 6... | class Solution:
def read_binary_watch(self, num: int) -> List[str]:
if num > 10:
return []
times = []
for h in range(12):
for m in range(60):
if (bin(h) + bin(m)).count('1') == num:
hour_str = str(h)
minute_str ... |
#!/usr/bin/python
dict = {'Name': 'Ruben', 'Age': 50, 'City': 'Amsterdam'}
print("dict['Name']: ", dict['Name'])
print("dict['Age']: ", dict['Age'])
# Access the data using a key, from the dictionary
print("dict['Ruben']: ", dict['Ruben'])
# Access the data using a key (which is non-existent), from the dictionary, w... | dict = {'Name': 'Ruben', 'Age': 50, 'City': 'Amsterdam'}
print("dict['Name']: ", dict['Name'])
print("dict['Age']: ", dict['Age'])
print("dict['Ruben']: ", dict['Ruben'])
print(dict['Dept'])
dict['Age'] = 52
dict['Company'] = 'XYZ'
dict
del dict['Name']
dict
dict.clear()
dict
del dict
'\nDictionary values can be any py... |
def prepare_knapsack(items, capacity):
'''
"capacity" is a numeric value representing a max weight.
this capacity will be modified as items are added.
---
"storage" is a list (usually a set) of item tuples.
the tuples inside store an item's name, value, and weight.
this variable represents all possible items ava... | def prepare_knapsack(items, capacity):
"""
"capacity" is a numeric value representing a max weight.
this capacity will be modified as items are added.
---
"storage" is a list (usually a set) of item tuples.
the tuples inside store an item's name, value, and weight.
this variable represents all possible items ... |
class Error(object):
def __init__(self, msg: str = "") -> None:
super().__init__()
self._msg = msg
def __str__(self) -> str:
return self._msg
def __repr__(self) -> str:
return self._msg
def __eq__(self, o: object) -> bool:
return self._msg == o.__repr__
de... | class Error(object):
def __init__(self, msg: str='') -> None:
super().__init__()
self._msg = msg
def __str__(self) -> str:
return self._msg
def __repr__(self) -> str:
return self._msg
def __eq__(self, o: object) -> bool:
return self._msg == o.__repr__
def... |
def lcs(x,y,m,n):
if m==0 or n==0:
return 0;
elif x[m-1]==y[n-1]:
return 1+lcs(x,y,m-1,n-1);
else:
return max(lcs(x,y,m,n-1),lcs(x,y,m-1,n));
x="AGGTAB"
y="GXTXAYB"
print("length of lcs is",lcs(x,y,len(x),len(y)));
| def lcs(x, y, m, n):
if m == 0 or n == 0:
return 0
elif x[m - 1] == y[n - 1]:
return 1 + lcs(x, y, m - 1, n - 1)
else:
return max(lcs(x, y, m, n - 1), lcs(x, y, m - 1, n))
x = 'AGGTAB'
y = 'GXTXAYB'
print('length of lcs is', lcs(x, y, len(x), len(y))) |
#! /usr/bin/env python
__author__ = "yatbear <sapphirejyt@gmail.com>"
__date__ = "$Dec 21, 2015"
# Map the infrequent words (count < 5) to a common symbol _RARE_
def remap():
# Read original training data
trainset = [line.strip().split() for line in open('gene.train', 'r').readlines()]
rare_candidates = d... | __author__ = 'yatbear <sapphirejyt@gmail.com>'
__date__ = '$Dec 21, 2015'
def remap():
trainset = [line.strip().split() for line in open('gene.train', 'r').readlines()]
rare_candidates = dict()
for sample in trainset:
if len(sample) == 0:
continue
word = sample[0]
if wor... |
# Sylvia Dee <sylvia_dee@brown.edu>
# PRYSM
# PSM for Lacustrine Sedimentary Archives
# SENSOR MODEL: GDGT-based measurements, e.g. TEX86, MBT5e
# Function 'gdgt_sensor'
# Modified 03/8/2016 <sylvia_dee@brown.edu>
#====================================================================
def gdgt_sensor(LST,MAAT,beta=(1/50)... | def gdgt_sensor(LST, MAAT, beta=1 / 50, model='TEX86-loomis'):
"""
SENSOR SUB-MODEL for GDGT proxy data
INPUTS:
LST: LAKE SURFACE TEMPERATURE (C)
MAAT: MEAN ANNUAL AIR TEMPERATURE (C)
beta: User-Specified transfer fucntion of LST to TEX/GDGT
model: Published calibrations for GDGTs. Options:
... |
class Bruxo:
def bruxeis(self):
print('The dead are coming back to life')
class Genio:
def genieis(self):
print('Los muertos vuelven a la vida')
class Deus:
def deuseis(self):
print('De doden komen weer tot leven')
seres = [Bruxo(), Genio(), Deus()]
for ser in seres:
if is... | class Bruxo:
def bruxeis(self):
print('The dead are coming back to life')
class Genio:
def genieis(self):
print('Los muertos vuelven a la vida')
class Deus:
def deuseis(self):
print('De doden komen weer tot leven')
seres = [bruxo(), genio(), deus()]
for ser in seres:
if isin... |
ERROR = {
'INPUT': {
'code': 20001,
'message': 'invalid request data',
'data': 'invalid request data',
},
'REGISTER': {
'code': 20002,
'data': '',
'message': 'failed to register user'
},
'USER_NOT_FOUND': {
'code': 20003,
'data': '',
... | error = {'INPUT': {'code': 20001, 'message': 'invalid request data', 'data': 'invalid request data'}, 'REGISTER': {'code': 20002, 'data': '', 'message': 'failed to register user'}, 'USER_NOT_FOUND': {'code': 20003, 'data': '', 'message': 'invalid username'}, 'INVALID_PASSWORD': {'code': 20004, 'data': '', 'message': 'i... |
class NoDataFileException(Exception):
def __init__(self, message="No data file", errors=[]):
super().__init__(message, errors)
pass
| class Nodatafileexception(Exception):
def __init__(self, message='No data file', errors=[]):
super().__init__(message, errors)
pass |
age = 17
print("You are " + str(age))
if age >= 21: # Is the age equal to or over 21?
print("You can drink!")
if age >= 18: # Is the age equal to or over 18?
print("You are an adult!")
if age >= 16: # Is the age equal to or over 16?
print("You can drive!")
if age < 16: # Is the age ... | age = 17
print('You are ' + str(age))
if age >= 21:
print('You can drink!')
if age >= 18:
print('You are an adult!')
if age >= 16:
print('You can drive!')
if age < 16:
print("You can't do anything!") |
'''
Models simple up/down counter that maintains a single count
Methods:
get_count()
incrememt()
decrement()
set()
reset()
'to_string'
'''
## Start your class with the keyword 'class' and the name of the class:
class Counter:
#---------------------------------------------------------------------------- ... | """
Models simple up/down counter that maintains a single count
Methods:
get_count()
incrememt()
decrement()
set()
reset()
'to_string'
"""
class Counter:
def __init__(self):
self.__count = 0
def get_count(self):
return self.__count
def increment(self):
self.__count +=... |
def foo():
global x
x="juanito"
print(f"El valor de x es {x}")
x=5
print(x)
foo()
print(x)
| def foo():
global x
x = 'juanito'
print(f'El valor de x es {x}')
x = 5
print(x)
foo()
print(x) |
def make_data_tensor(self, train=True):
if train:
folders = self.metatrain_character_folders
# number of tasks, not number of meta-iterations. (divide by metabatch size to measure)
num_total_batches = 200000
else:
folders = self.metaval_character_folders
num_total_batches... | def make_data_tensor(self, train=True):
if train:
folders = self.metatrain_character_folders
num_total_batches = 200000
else:
folders = self.metaval_character_folders
num_total_batches = 600
print('Generating filenames')
all_filenames = []
for _ in range(num_total_bat... |
class Mother:
def __init__(self):
self.eye_color = "brown"
self.hair_color = "dark brown"
self.hair_type = "curly"
class Father:
def __init__(self):
self.eye_color = "blue"
self.hair_color = "blond"
self.hair_type = "straight"
class Child(Mother,... | class Mother:
def __init__(self):
self.eye_color = 'brown'
self.hair_color = 'dark brown'
self.hair_type = 'curly'
class Father:
def __init__(self):
self.eye_color = 'blue'
self.hair_color = 'blond'
self.hair_type = 'straight'
class Child(Mother, Father):
... |
"""Utility class for holding multi-channel colour data.
"""
class Colour:
def __init__(self, r, g, b, name=""):
"""Creates a Colour object for holding data on the red, green,
and blue colour channels.
:param r: the red component of the colour, expressed as a number
between 0 and 2... | """Utility class for holding multi-channel colour data.
"""
class Colour:
def __init__(self, r, g, b, name=''):
"""Creates a Colour object for holding data on the red, green,
and blue colour channels.
:param r: the red component of the colour, expressed as a number
between 0 and 2... |
hparams = {
'batch_size': 32,
'epochs': 8,
'lr': 0.0001,
'name': 'mind_news',
'loss': 'cross_entropy_loss',
'optimizer': 'adam',
'version': 'v3',
'description': 'NRMS lr=5e-4, with weight_decay',
'pretrained_model': './data/utils/embedding.npy',
'model': {
'dct_size': 'au... | hparams = {'batch_size': 32, 'epochs': 8, 'lr': 0.0001, 'name': 'mind_news', 'loss': 'cross_entropy_loss', 'optimizer': 'adam', 'version': 'v3', 'description': 'NRMS lr=5e-4, with weight_decay', 'pretrained_model': './data/utils/embedding.npy', 'model': {'dct_size': 'auto', 'nhead': 20, 'embed_size': 300, 'encoder_size... |
class Sprite:
# Getter Functions
def getCurrentFramePath(cls): pass
def getCurrentFrameDelay(cls): pass
def getCurrentPos(cls): pass
# Interface for main to call
def init(cls, xcoord: int, ycoord: int): pass
def update(cls): pass
# Interface to set sprite properties
class Sprit... | class Sprite:
def get_current_frame_path(cls):
pass
def get_current_frame_delay(cls):
pass
def get_current_pos(cls):
pass
def init(cls, xcoord: int, ycoord: int):
pass
def update(cls):
pass
class Spriteproperties:
pass
def on_left_click(... |
with open("input1.txt","r") as f:
data = f.readlines()
data[0] = data[0].split(',')
data[1] = data[1].split(',')
# Might need to change w if too big
w = 22000
h = w
# 2000x2000 Wirespace
wireSpace = [[0 for x in range(w)] for y in range(h)]
centerX = w//2
centerY = h//2
currentPosX = centerX
currentPosY = center... | with open('input1.txt', 'r') as f:
data = f.readlines()
data[0] = data[0].split(',')
data[1] = data[1].split(',')
w = 22000
h = w
wire_space = [[0 for x in range(w)] for y in range(h)]
center_x = w // 2
center_y = h // 2
current_pos_x = centerX
current_pos_y = centerY
for command in data[0]:
(opcode, parameter)... |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def countNodes(self, root):
"""
:type root: TreeNode
:rtype: int
"""
# First get... | class Solution(object):
def count_nodes(self, root):
"""
:type root: TreeNode
:rtype: int
"""
depth = 0
node = root
while node:
depth += 1
node = node.left
if depth <= 1:
return depth
self.leaves = 0
... |
html_theme = 'classic'
exclude_patterns = ['_build']
latex_documents = [
('index', 'SphinxTests.tex', 'Testing maxlistdepth=10',
'Georg Brandl', 'howto'),
]
latex_elements = {
'maxlistdepth': '10',
}
| html_theme = 'classic'
exclude_patterns = ['_build']
latex_documents = [('index', 'SphinxTests.tex', 'Testing maxlistdepth=10', 'Georg Brandl', 'howto')]
latex_elements = {'maxlistdepth': '10'} |
# Simple Python3 program to find
# n'th node from end
class Node:
def __init__(self, new_data):
self.data = new_data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
# createNode and and make linked list
def push(self, new_data):
new_node = Node(new_data)
new_node.next ... | class Node:
def __init__(self, new_data):
self.data = new_data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def push(self, new_data):
new_node = node(new_data)
new_node.next = self.head
self.head = new_node
def print_nth_fro... |
NEED = 40 # mm
def rain_amount(rain_amount: int) -> str:
give = NEED - rain_amount
if give > 0:
return f"You need to give your plant {give}mm of water"
else:
return "Your plant has had more than enough water for today!" | need = 40
def rain_amount(rain_amount: int) -> str:
give = NEED - rain_amount
if give > 0:
return f'You need to give your plant {give}mm of water'
else:
return 'Your plant has had more than enough water for today!' |
# Time: O(n^3 / k)
# Space: O(n^2)
class Solution(object):
def mergeStones(self, stones, K):
"""
:type stones: List[int]
:type K: int
:rtype: int
"""
if (len(stones)-1) % (K-1):
return -1
prefix = [0]
for x in stones:
prefix.a... | class Solution(object):
def merge_stones(self, stones, K):
"""
:type stones: List[int]
:type K: int
:rtype: int
"""
if (len(stones) - 1) % (K - 1):
return -1
prefix = [0]
for x in stones:
prefix.append(prefix[-1] + x)
d... |
class Solution:
def reverse(self, x: int) -> int:
if x%10==x:
return x
elif x>0:
x = int (str(x).rstrip('0')[::-1])
return x if x <= ((1<<31)-1) else 0
elif x<0:
x = -int (str(abs(x)).rstrip('0')[::-1])
return x if x >= -(1<<31) els... | class Solution:
def reverse(self, x: int) -> int:
if x % 10 == x:
return x
elif x > 0:
x = int(str(x).rstrip('0')[::-1])
return x if x <= (1 << 31) - 1 else 0
elif x < 0:
x = -int(str(abs(x)).rstrip('0')[::-1])
return x if x >= -(1... |
def simple_mean(x, y):
"""Function that takes 2 numerical arguments and returns their mean.
"""
mean = (x + y) / 2
return mean
def advanced_mean(values):
"""Function that takes a list of numbers and returns the mean of all
the numbers in the list.
"""
total = 0
for v in values:
... | def simple_mean(x, y):
"""Function that takes 2 numerical arguments and returns their mean.
"""
mean = (x + y) / 2
return mean
def advanced_mean(values):
"""Function that takes a list of numbers and returns the mean of all
the numbers in the list.
"""
total = 0
for v in values:
... |
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def getIntersectionNode(self, headA, headB):
"""
:type head1, head1: ListNode
:rtype: ListNode
"""
lA=0
... | class Solution(object):
def get_intersection_node(self, headA, headB):
"""
:type head1, head1: ListNode
:rtype: ListNode
"""
l_a = 0
l_b = 0
t_a = headA
t_b = headB
while tA != None:
l_a += 1
t_a = tA.next
while... |
# Solution 1
# O(n^2) time / O(1) space
def twoNumberSum(array, targetSum):
for i in range(len(array) - 1):
firstNum = array[i]
for j in range(i + 1, len(array)):
secondNum = array[j]
if firstNum + secondNum == targetSum:
return [firstNum, secondNum]
ret... | def two_number_sum(array, targetSum):
for i in range(len(array) - 1):
first_num = array[i]
for j in range(i + 1, len(array)):
second_num = array[j]
if firstNum + secondNum == targetSum:
return [firstNum, secondNum]
return []
def two_number_sum(array, targ... |
'''
Merge sort
time complexity: O(nlogn)
space complexity: O(logn) + O(n) = O(n)
'''
# merge two sorted array
def merge(arr1, arr2):
merge_arr = []
idx1, idx2 = 0, 0
while idx1 < len(arr1) and idx2 < len(arr2):
if arr1[idx1] < arr2[idx2]:
merge_arr.append(arr1[idx1])
idx1 =... | """
Merge sort
time complexity: O(nlogn)
space complexity: O(logn) + O(n) = O(n)
"""
def merge(arr1, arr2):
merge_arr = []
(idx1, idx2) = (0, 0)
while idx1 < len(arr1) and idx2 < len(arr2):
if arr1[idx1] < arr2[idx2]:
merge_arr.append(arr1[idx1])
idx1 = idx1 + 1
else... |
# coding: utf-8
AUTHOR = 'R-Koubou'
VERSION = '0.7.0'
URL = 'https://github.com/r-koubou/XLS2ExpressionMap'
VERSION_0_6 = 0x006000
VERSION_0_7 = 0x007000
VERSION_NUMBER = VERSION_0_7
if __name__ == '__main__':
print( VERSION )
| author = 'R-Koubou'
version = '0.7.0'
url = 'https://github.com/r-koubou/XLS2ExpressionMap'
version_0_6 = 24576
version_0_7 = 28672
version_number = VERSION_0_7
if __name__ == '__main__':
print(VERSION) |
"""Top-level package for gist."""
__author__ = """Ammar Najjar"""
__email__ = 'najjarammar@protonmail.com'
__version__ = '0.1.0'
| """Top-level package for gist."""
__author__ = 'Ammar Najjar'
__email__ = 'najjarammar@protonmail.com'
__version__ = '0.1.0' |
expected_output = {
"route-information": {
"route-table": [
{
"active-route-count": "13",
"destination-count": "13",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
... | expected_output = {'route-information': {'route-table': [{'active-route-count': '13', 'destination-count': '13', 'hidden-route-count': '0', 'holddown-route-count': '0', 'rt': [{'rt-announced-count': '1', 'rt-destination': '10.55.0.1/32', 'rt-entry': {'active-tag': '*', 'age': {'#text': '13'}, 'announce-bits': '2', 'ann... |
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
k = 2
if len(nums) == 0:
return 0
m = 1
count = 1
for i in range(1, len(nums)):
if nums[i] == nums[i - 1]:
... | class Solution(object):
def remove_duplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
k = 2
if len(nums) == 0:
return 0
m = 1
count = 1
for i in range(1, len(nums)):
if nums[i] == nums[i - 1]:
... |
class Solution:
def partition(self, s: str) -> List[List[str]]:
ans = []
self.helper(s, 0, [], ans)
return ans
def helper(self, s, idx, partition, ans):
if idx == len(s):
ans.append(partition[:])
else:
for end in range(idx + 1, len(s) + 1)... | class Solution:
def partition(self, s: str) -> List[List[str]]:
ans = []
self.helper(s, 0, [], ans)
return ans
def helper(self, s, idx, partition, ans):
if idx == len(s):
ans.append(partition[:])
else:
for end in range(idx + 1, len(s) + 1):
... |
class KafkaTimeoutError(Exception):
"""
Error raised when the poll from Kafka returns nothing and therefore there is nothing to read.
"""
pass # pylint:disable=unnecessary-pass
| class Kafkatimeouterror(Exception):
"""
Error raised when the poll from Kafka returns nothing and therefore there is nothing to read.
"""
pass |
# page 100 // homework 2021-01-07
# TASK 1: fix bug
#
total = 0
number = 1 # bugfix: define the 'number' varible to a value that meets the condition of the loop below
# nbb: the proposed solution of the book to duplicate functional code is a no go for pre-initializing variables (duplicate code -> increase of... | total = 0
number = 1
while number != 0:
number = input('enter a number: ')
number = int(number)
total = total + number
print(total) |
class RepeaterBounds(object, IDisposable):
"""
Represents bounds of the array of repeating references in 0,1,or 2 dimensions.
(See Autodesk.Revit.DB.RepeatingReferenceSource).
"""
def AdjustForCyclicalBounds(self, coordinates):
"""
AdjustForCyclicalBounds(self: RepeaterBounds,coordina... | class Repeaterbounds(object, IDisposable):
"""
Represents bounds of the array of repeating references in 0,1,or 2 dimensions.
(See Autodesk.Revit.DB.RepeatingReferenceSource).
"""
def adjust_for_cyclical_bounds(self, coordinates):
"""
AdjustForCyclicalBounds(self: RepeaterBounds,coordinates: R... |
# Copyright 2021 The Cross-Media Measurement Authors
#
# 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 ... | """World Federation of Advertisers (WFA) GitHub repo macros."""
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
_release_url_template = 'https://github.com/world-federation-of-advertisers/{repo}/archive/refs/tags/v{version}.tar.gz'
_commit_url_template = 'https://github.com/world-federation-of-adve... |
a = True
b = False
print(a is b)
print(a is not b)
| a = True
b = False
print(a is b)
print(a is not b) |
expected_output = {
"interfaces": {
"Ethernet1/3": {
"neighbors": {
"fe80::f816:3eff:feff:9f9b": {
"homeagent_flag": 0,
"is_router": True,
"addr_flag": 0,
"ip": "fe80::f816:3eff:feff:9f9b",
... | expected_output = {'interfaces': {'Ethernet1/3': {'neighbors': {'fe80::f816:3eff:feff:9f9b': {'homeagent_flag': 0, 'is_router': True, 'addr_flag': 0, 'ip': 'fe80::f816:3eff:feff:9f9b', 'lifetime': 1800, 'current_hop_limit': 64, 'retransmission_time': 0, 'last_update': '2.8', 'mtu': 1500, 'preference': 'medium', 'other_... |
words=[
'redcoat',
'railing',
'waist',
'pinnacle',
'bribery',
'abjure',
'Swiss',
'chancel',
'groveler',
'chaser',
'curlew',
'markedly',
'admirer',
'coarse',
'slough',
'debrief',
'saltwater',
'spotty',
'photon',
'nephew',
'swath',
'elder',
'overnight',
'charm',
'rations',
'shrivel',
'quibbler',
'British',
'secretary',
'... | words = ['redcoat', 'railing', 'waist', 'pinnacle', 'bribery', 'abjure', 'Swiss', 'chancel', 'groveler', 'chaser', 'curlew', 'markedly', 'admirer', 'coarse', 'slough', 'debrief', 'saltwater', 'spotty', 'photon', 'nephew', 'swath', 'elder', 'overnight', 'charm', 'rations', 'shrivel', 'quibbler', 'British', 'secretary', ... |
#Class to calculate the LastPriceWindow and LastPriceTotal
class CUtilsSpread:
def GetLastPriceWindow(self, data_object, list_index, time_window_index):
while data_object.m_DatetimeList[list_index] <= data_object.m_strTimeWindowList[time_window_index]:
list_index += 1
if li... | class Cutilsspread:
def get_last_price_window(self, data_object, list_index, time_window_index):
while data_object.m_DatetimeList[list_index] <= data_object.m_strTimeWindowList[time_window_index]:
list_index += 1
if list_index >= len(data_object.m_fPriceList):
break
... |
'''
Author: tusikalanse
Date: 2021-07-13 20:13:20
LastEditTime: 2021-07-13 20:30:51
LastEditors: tusikalanse
Description:
'''
lis = [0, 2]
for i in range(1, 34):
lis.extend([1, 2 * i, 1])
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def gao(n):
numerator, denominator = lis[n], 1
for i in ra... | """
Author: tusikalanse
Date: 2021-07-13 20:13:20
LastEditTime: 2021-07-13 20:30:51
LastEditors: tusikalanse
Description:
"""
lis = [0, 2]
for i in range(1, 34):
lis.extend([1, 2 * i, 1])
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def gao(n):
(numerator, denominator) = (lis[n], 1)
for i in ... |
#pylint:disable=E0001
'''
We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
If the product of these four fractions is given in its lowest commo... | """
We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
If the product of these four fractions is given in its lowest common terms, find the valu... |
# encoding: utf-8
# module cv2.text
# from /home/davtoh/anaconda3/envs/rrtools/lib/python3.5/site-packages/cv2.cpython-35m-x86_64-linux-gnu.so
# by generator 1.144
# no doc
# no imports
# Variables with simple values
ERFILTER_NM_IHSGrad = 1
ERFILTER_NM_IHSGRAD = 1
ERFILTER_NM_RGBLGRAD = 0
ERFILTER_NM_RGBLGrad = 0
ER... | erfilter_nm_ihs_grad = 1
erfilter_nm_ihsgrad = 1
erfilter_nm_rgblgrad = 0
erfilter_nm_rgbl_grad = 0
ergrouping_orientation_any = 1
ergrouping_orientation_horiz = 0
ocr_decoder_viterbi = 0
ocr_level_textline = 1
ocr_level_word = 0
__loader__ = None
__spec__ = None
def compute_nm_channels(_src, _channels=None, _mode=Non... |
class ScoringMatrix(object):
"""
Defines a scoring-matrix between Kanji
"""
def get(self, **kwargs):
raise NotImplementedError
| class Scoringmatrix(object):
"""
Defines a scoring-matrix between Kanji
"""
def get(self, **kwargs):
raise NotImplementedError |
# Plot statistics
# Mean global flow completion time vs. utilization pFabric
lambdasdata = [4000, 6000, 10000, 15000, 22500, 37000, 60000]
lambdasweb = [3600, 5200, 7000, 8900, 11100, 14150, 19000]
row = 0
for x in lambdasweb:
file = "../temp_save/albert/pFabric/web_search_workload/"+str(x)+"/SPPIFO8_pFabric/analy... | lambdasdata = [4000, 6000, 10000, 15000, 22500, 37000, 60000]
lambdasweb = [3600, 5200, 7000, 8900, 11100, 14150, 19000]
row = 0
for x in lambdasweb:
file = '../temp_save/albert/pFabric/web_search_workload/' + str(x) + '/SPPIFO8_pFabric/analysis/flow_completion.statistics'
r = open(file, 'r')
lines = r.read... |
# .................................................................................................................
level_dict["love"] = {
"scheme": "red_scheme",
"size": (13,13,13),
"intro": "love",
"help":... | level_dict['love'] = {'scheme': 'red_scheme', 'size': (13, 13, 13), 'intro': 'love', 'help': ('$scale(1.5)mission:\nget to the exit!',), 'player': {'position': (0, 1, -4), 'orientation': rot0}, 'exits': [{'name': 'peace', 'active': 1, 'position': (0, 0, 4)}], 'create': '\nheart = [[0,0], [ 1,1], [ 2,1], [ 3,0], [ 3,-1]... |
# -*- coding: utf-8 -*-
"""Release data for the PyOOMUSH project."""
# Name of the package for release purposes.
name = 'PyOOMUSH'
version = '0.1'
description = "A Python Object-Oriented MUSH server."
long_description = \
"""
PyOOMUSH provides collaboratitive creation of a fully programmable
virtual world both usin... | """Release data for the PyOOMUSH project."""
name = 'PyOOMUSH'
version = '0.1'
description = 'A Python Object-Oriented MUSH server.'
long_description = '\nPyOOMUSH provides collaboratitive creation of a fully programmable\nvirtual world both using Python as the scripting language and using\nPython as the host.\n\nMain ... |
# Do not edit the class below except for the buildHeap,
# siftDown, siftUp, peek, remove, and insert methods.
# Feel free to add new properties and methods to the class.
class MinHeap:
def __init__(self, array):
# Do not edit the line below.
self.heap = self.buildHeap(array)
def buildHeap(se... | class Minheap:
def __init__(self, array):
self.heap = self.buildHeap(array)
def build_heap(self, array):
first_parent_idx = (len(array) - 2) // 2
for curr_idx in reversed(range(firstParentIdx + 1)):
self.siftDown(currIdx, len(array) - 1, array)
return array
def... |
class Button:
def __init__(self, x, y, w, h, text, callback):
self.pos = x, y
self.size = w, h
self.text = text
self.callback = callback
self.bg_colour = [0, 0, 0]
self.text_colour = [255, 255, 255]
self.pushed_colour = [155, 155, 155]
self.pushed = F... | class Button:
def __init__(self, x, y, w, h, text, callback):
self.pos = (x, y)
self.size = (w, h)
self.text = text
self.callback = callback
self.bg_colour = [0, 0, 0]
self.text_colour = [255, 255, 255]
self.pushed_colour = [155, 155, 155]
self.pushed... |
class Trie:
def __init__(self) -> None:
self.root = {}
self.endOfWord = ' '
def insert(self, word: str) -> None:
node = self.root
for char in word:
node = node.setdefault(char, {})
node[self.endOfWord] = self.endOfWord
def search(self, word: str) -> bool... | class Trie:
def __init__(self) -> None:
self.root = {}
self.endOfWord = ' '
def insert(self, word: str) -> None:
node = self.root
for char in word:
node = node.setdefault(char, {})
node[self.endOfWord] = self.endOfWord
def search(self, word: str) -> boo... |
# library to handle stuff about your ship
##########################
# necessary imports go here
##########################
##################################
# Inaugural frigate class - Atron
##################################
# a ship needs to have certain stats
# it needs a pilot (usually the player) it needs a ... | class Atron:
def __init__(self, hp, location):
self.hp = hp
self.cargo = []
self.location = location
self.score = 0
self.killmarks = 0
def structure_rep(self):
rep_amt = 100 - self.hp
self.hp += rep_amt
def add_cargo(self, items):
self.cargo... |
#
# PySNMP MIB module Juniper-ERX-Registry (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-ERX-Registry
# Produced by pysmi-0.3.4 at Wed May 1 14:02:31 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, value_range_constraint, constraints_intersection, single_value_constraint) ... |
# Part 1
def parsephrase(phrase):
sp = phrase.lower().split()
checked = []
for p in sp:
if p in checked:
return(False)
else:
checked += [p]
return(True)
def phrases(lines):
x = 0
for l in lines.split("\n"):
pp = parsephrase(l.lower())
if p... | def parsephrase(phrase):
sp = phrase.lower().split()
checked = []
for p in sp:
if p in checked:
return False
else:
checked += [p]
return True
def phrases(lines):
x = 0
for l in lines.split('\n'):
pp = parsephrase(l.lower())
if pp:
... |
__title__ = 'trylogging'
#__package_name__ = 'not-a-package'
__version__ = '0.0.1'
__description__ = "Just an example of using the Python logging module to remind me about using it."
__email__ = "notNeededForThisExample@null.net"
__author__ = 'Matt McCright'
__github__ = 'https://github.com/mccright/PPythonLoggingExamp... | __title__ = 'trylogging'
__version__ = '0.0.1'
__description__ = 'Just an example of using the Python logging module to remind me about using it.'
__email__ = 'notNeededForThisExample@null.net'
__author__ = 'Matt McCright'
__github__ = 'https://github.com/mccright/PPythonLoggingExamples'
__license__ = 'MIT'
__copyright... |
#!/usr/bin/python
#protexam_output.py
'''
Output functions for ProtExAM.
'''
| """
Output functions for ProtExAM.
""" |
# function to find double factorial of given number.
'''
Double factorial of a non-negative integer n,
is the product of all the integers from 1 to n that have the same parity (odd or even) as n.
It is also called as semifactorial of a number and is denoted by !!.
For example,
9!! = 9*7*5*3*1 = 945.
Note that--> 0!... | """
Double factorial of a non-negative integer n,
is the product of all the integers from 1 to n that have the same parity (odd or even) as n.
It is also called as semifactorial of a number and is denoted by !!.
For example,
9!! = 9*7*5*3*1 = 945.
Note that--> 0!! = 1.
"""
def double_factorial(input_num):
"""
... |
n, k = map(int, input().split())
s = str(input())
sl = []
c = 1
if (s[0] == "1"):
sl.append(0)
for i in range(n):
if (i != 0):
if (s[i] == s[i-1]):
c += 1
else:
sl.append(c)
c = 1
sl.append(c)
ruisekiwa = [0]
sums = []
ans = 0
w = 2*k+1
if (w > len(sl)):
... | (n, k) = map(int, input().split())
s = str(input())
sl = []
c = 1
if s[0] == '1':
sl.append(0)
for i in range(n):
if i != 0:
if s[i] == s[i - 1]:
c += 1
else:
sl.append(c)
c = 1
sl.append(c)
ruisekiwa = [0]
sums = []
ans = 0
w = 2 * k + 1
if w > len(sl):
p... |
#
# libjingle
# Copyright 2012 Google Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following d... | {'includes': ['build/common.gypi'], 'targets': [{'target_name': 'relayserver', 'type': 'executable', 'dependencies': ['libjingle.gyp:libjingle', 'libjingle.gyp:libjingle_p2p'], 'sources': ['examples/relayserver/relayserver_main.cc']}, {'target_name': 'stunserver', 'type': 'executable', 'dependencies': ['libjingle.gyp:l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.