content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# DFLOW LIBRARY:
# dflow utilities module
# with new range function
# and dictenumerate
def range(_from, _to, step=1):
out = []
aux = _from
while aux < _to:
out.append(aux)
aux += step
return out
def dictenumerate(d):
return {k: v for v, k in enumerate(d)}
def prod(x):
res = ... | def range(_from, _to, step=1):
out = []
aux = _from
while aux < _to:
out.append(aux)
aux += step
return out
def dictenumerate(d):
return {k: v for (v, k) in enumerate(d)}
def prod(x):
res = 1
for x in x:
res *= X
return res |
class TFException(Exception):
pass
class TFAPIUnavailable(Exception):
pass
class TFLogParsingException(Exception):
def __init__(self, type):
self.type = type | class Tfexception(Exception):
pass
class Tfapiunavailable(Exception):
pass
class Tflogparsingexception(Exception):
def __init__(self, type):
self.type = type |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isSubtree(self, s, t, match=False):
"""
:type s: TreeNode
:type t: TreeNode
:rtype: bool
"""
#... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def is_subtree(self, s, t, match=False):
"""
:type s: TreeNode
:type t: TreeNode
:rtype: bool
"""
if not s and (not t):
re... |
"""
Some models such as
A model with high precision
"""
class Model_Regression():
def __init__(self):
self.name = 'a_good_model'
def predict(self,x):
y = x*2
return y
if __name__ == '__main__':
model = Model_Regression()
print(model.predict(1)) | """
Some models such as
A model with high precision
"""
class Model_Regression:
def __init__(self):
self.name = 'a_good_model'
def predict(self, x):
y = x * 2
return y
if __name__ == '__main__':
model = model__regression()
print(model.predict(1)) |
print("Hello Aline and Basti!")
print("What's up?")
# We need escaping: \" cancels its meaning.
print("Are you \"Monty\"?")
# Alternatively you can use ':
print('Are you "Monty"?')
# But you will need escaping for the last:
print("Can't you just pretend you were \"Monty\"?")
# or
print('Can\'t you just pretend you w... | print('Hello Aline and Basti!')
print("What's up?")
print('Are you "Monty"?')
print('Are you "Monty"?')
print('Can\'t you just pretend you were "Monty"?')
print('Can\'t you just pretend you were "Monty"?') |
class Action:
"""A thing that is done.
The responsibility of action is to do something that is important in the game. Thus, it has one
method, execute(), which should be overridden by derived classes.
"""
def execute(self, cast, script, callback):
"""Executes something that is importan... | class Action:
"""A thing that is done.
The responsibility of action is to do something that is important in the game. Thus, it has one
method, execute(), which should be overridden by derived classes.
"""
def execute(self, cast, script, callback):
"""Executes something that is importan... |
"""
The core Becca code
This package contains all the learning algorithms and heuristics
implemented together in a functional learning agent. Most users
won't need to modify anything in this package. Only core developers,
those who want to experiment with and improve the underlying
learning algorithms and their implem... | """
The core Becca code
This package contains all the learning algorithms and heuristics
implemented together in a functional learning agent. Most users
won't need to modify anything in this package. Only core developers,
those who want to experiment with and improve the underlying
learning algorithms and their implem... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 1 10:42:25 2017
@author: wuyiming
"""
SR = 16000
H = 512
FFT_SIZE = 1024
BATCH_SIZE = 64
PATCH_LENGTH = 128
PATH_FFT = "/media/wuyiming/TOSHIBA EXT/UNetFFT/"
| """
Created on Wed Nov 1 10:42:25 2017
@author: wuyiming
"""
sr = 16000
h = 512
fft_size = 1024
batch_size = 64
patch_length = 128
path_fft = '/media/wuyiming/TOSHIBA EXT/UNetFFT/' |
#
# PySNMP MIB module MIB-INTEL-IP (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MIB-INTEL-IP
# Produced by pysmi-0.3.4 at Wed May 1 14:12:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ... |
#!/usr/bin/env python
while True:
pass
| while True:
pass |
"""Mock turtle module.
"""
def goto(x, y):
pass
def up():
pass
def down():
pass
def color(name):
pass
def begin_fill():
pass
def end_fill():
pass
def forward(steps):
pass
def left(degrees):
pass
| """Mock turtle module.
"""
def goto(x, y):
pass
def up():
pass
def down():
pass
def color(name):
pass
def begin_fill():
pass
def end_fill():
pass
def forward(steps):
pass
def left(degrees):
pass |
'''
Get various integer numbers. In the end, show the average between all values and the lowest and the highest.
Asks the user if they want to continue or not.
'''
number = int(input('Choose a number: '))
again = input('Do you want to continue? [S/N]').strip().upper()
total = 1
minimum = maximum = number
while... | """
Get various integer numbers. In the end, show the average between all values and the lowest and the highest.
Asks the user if they want to continue or not.
"""
number = int(input('Choose a number: '))
again = input('Do you want to continue? [S/N]').strip().upper()
total = 1
minimum = maximum = number
while ... |
# -*- coding:utf-8 -*-
"""
"""
class Delegate:
daily_forge = 0.
gift = property(
lambda obj: obj.share*obj.daily_forge/(obj.vote+obj.cumul-obj.exclude),
None, None,
""
)
@staticmethod
def configure(blocktime=8, delegates=51, reward=2):
assert isinstance(blocktime, int)
assert isinstance(delegates, i... | """
"""
class Delegate:
daily_forge = 0.0
gift = property(lambda obj: obj.share * obj.daily_forge / (obj.vote + obj.cumul - obj.exclude), None, None, '')
@staticmethod
def configure(blocktime=8, delegates=51, reward=2):
assert isinstance(blocktime, int)
assert isinstance(delegates, int... |
print(3 * 3 == 6)
print(50 % 5 == 0)
Name = "Sam"
print(Name == "SaM")
fruits = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
for fruit in fruits:
if fruit == "apple":
print("Apple is present")
elif "cherry" in fruit:
print("Cherry is also present") | print(3 * 3 == 6)
print(50 % 5 == 0)
name = 'Sam'
print(Name == 'SaM')
fruits = ['apple', 'banana', 'cherry', 'orange', 'kiwi', 'melon', 'mango']
for fruit in fruits:
if fruit == 'apple':
print('Apple is present')
elif 'cherry' in fruit:
print('Cherry is also present') |
#!/usr/bin/python3
'''
helloworld.py
Simple Hello world program. This is considered to be the
first program that anyone would write when learing a new language.
Author: Rich Lynch
Created for merit badge college.
Released to the public under the MIT license.
'''
print ("Hello Wo... | """
helloworld.py
Simple Hello world program. This is considered to be the
first program that anyone would write when learing a new language.
Author: Rich Lynch
Created for merit badge college.
Released to the public under the MIT license.
"""
print('Hello World') |
# -*- coding: utf-8 -*-
'''
Configuration of Capsul and external software operated through capsul.
'''
| """
Configuration of Capsul and external software operated through capsul.
""" |
version = "0.9.8"
_default_base_dir = "./archive"
class Options:
"""Holds Archiver options."""
def __init__(self, base_dir, use_ssl=False, silent=False, verbose=False, delay=2, thread_check_delay=90, dl_threads_per_site=5, dl_thread_wait=1, skip_thumbs=False, thumbs_only=False, skip_js=False, skip_css=False, follow_c... | version = '0.9.8'
_default_base_dir = './archive'
class Options:
"""Holds Archiver options."""
def __init__(self, base_dir, use_ssl=False, silent=False, verbose=False, delay=2, thread_check_delay=90, dl_threads_per_site=5, dl_thread_wait=1, skip_thumbs=False, thumbs_only=False, skip_js=False, skip_css=False, ... |
class StepsLoss:
def __init__(self, loss):
self.steps = None
self.loss = loss
def set_steps(self, steps):
self.steps = steps
def __call__(self, y_pred, y_true):
if self.steps is not None:
y_pred = y_pred[:, :, : self.steps]
y_true = y_true[:, :, : se... | class Stepsloss:
def __init__(self, loss):
self.steps = None
self.loss = loss
def set_steps(self, steps):
self.steps = steps
def __call__(self, y_pred, y_true):
if self.steps is not None:
y_pred = y_pred[:, :, :self.steps]
y_true = y_true[:, :, :sel... |
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
# O(n) time | O(n) space
lst = []
startRow, endRow = 0, len(matrix) - 1
startColumn, endColumn = 0, len(matrix[0]) - 1
place = (0, 0)
while startRow <= endRow and startColumn <= endColumn:
... | class Solution:
def spiral_order(self, matrix: List[List[int]]) -> List[int]:
lst = []
(start_row, end_row) = (0, len(matrix) - 1)
(start_column, end_column) = (0, len(matrix[0]) - 1)
place = (0, 0)
while startRow <= endRow and startColumn <= endColumn:
if place ... |
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 20 14:15:56 2018
@author: Chris
"""
path = r'C:\Users\Chris\Desktop\Machine Learning Raw Data\air-quality-madrid\stations.csv'
stations = pd.read_csv(path)
stations.head()
geometry = [Point(xy) for xy in zip(stations['lon'], stations['lat'])]
crs = {'init': 'epsg:4326'}... | """
Created on Sat Oct 20 14:15:56 2018
@author: Chris
"""
path = 'C:\\Users\\Chris\\Desktop\\Machine Learning Raw Data\\air-quality-madrid\\stations.csv'
stations = pd.read_csv(path)
stations.head()
geometry = [point(xy) for xy in zip(stations['lon'], stations['lat'])]
crs = {'init': 'epsg:4326'}
geo_df_stations = gp... |
# network image size
IMAGE_WIDTH = 128
IMAGE_HEIGHT = 64
# license number construction
DOWNSAMPLE_FACTOR = 2 ** 2 # <= pool size ** number of pool layers
MAX_TEXT_LEN = 10
| image_width = 128
image_height = 64
downsample_factor = 2 ** 2
max_text_len = 10 |
#!/usr/bin/python
def readFile(fileName):
paramsFile = open(fileName)
paramFileLines = paramsFile.readlines()
return paramFileLines
#number of expected molecular lines
def getExpectedLineNum(fileName):
lines = readFile(fileName)
print(lines[0])
return lines[0]
#frequency ranges of all expected... | def read_file(fileName):
params_file = open(fileName)
param_file_lines = paramsFile.readlines()
return paramFileLines
def get_expected_line_num(fileName):
lines = read_file(fileName)
print(lines[0])
return lines[0]
def get_expected_lines(fileName):
result = []
lines = read_file(fileNam... |
#!/usr/bin/env python3
# https://abc051.contest.atcoder.jp/tasks/abc051_d
INF = 10 ** 9
n, m = map(int, input().split())
a = [[INF] * n for _ in range(n)]
e = [None] * m
for i in range(n): a[i][i] = 0
for i in range(m):
u, v, w = map(int, input().split())
u -= 1
v -= 1
e[i] = (u, v, w)
a[u][v] = w
... | inf = 10 ** 9
(n, m) = map(int, input().split())
a = [[INF] * n for _ in range(n)]
e = [None] * m
for i in range(n):
a[i][i] = 0
for i in range(m):
(u, v, w) = map(int, input().split())
u -= 1
v -= 1
e[i] = (u, v, w)
a[u][v] = w
a[v][u] = w
for k in range(n):
for i in range(n):
f... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class ListNode:
def __init__(self, x, n):
self.val = x
self.next = n
class Solution:
def mergeTwoLists(self, l1, l2):
pre = tmp = None
cur = l1
... | class Listnode:
def __init__(self, x, n):
self.val = x
self.next = n
class Solution:
def merge_two_lists(self, l1, l2):
pre = tmp = None
cur = l1
while cur and cur.next:
if cur.val > l2.val:
tmp = cur
cur = l2
... |
class AsupDestination(basestring):
"""
smtp|http|noteto|retransmit
Possible values:
<ul>
<li> "smtp" ,
<li> "http" ,
<li> "noteto" ,
<li> "retransmit"
</ul>
"""
@staticmethod
def get_api_name():
return "asup-destination"
| class Asupdestination(basestring):
"""
smtp|http|noteto|retransmit
Possible values:
<ul>
<li> "smtp" ,
<li> "http" ,
<li> "noteto" ,
<li> "retransmit"
</ul>
"""
@staticmethod
def get_api_name():
return 'asup-destination' |
def parseRaspFile(filepath):
headerpassed = False
data = {
'motor name':None,
'motor diameter':None,
'motor length':None,
'motor delay': None,
'propellant weight': None,
'total weight': None,
'manufacturer': None,
'thrust data': {'time':[],'thrust... | def parse_rasp_file(filepath):
headerpassed = False
data = {'motor name': None, 'motor diameter': None, 'motor length': None, 'motor delay': None, 'propellant weight': None, 'total weight': None, 'manufacturer': None, 'thrust data': {'time': [], 'thrust': []}}
with open(filepath) as enginefile:
whil... |
"""
Author: Kagaya john
Tutorial 9 : Dictionaries
"""
"""
Python Dictionaries
Dictionary
A dictionary is a collection which is unordered, changeable and indexed.
In Python dictionaries are written with curly brackets, and they have keys and values.
Example
Using the len() method to return the number of items:"""... | """
Author: Kagaya john
Tutorial 9 : Dictionaries
"""
'\nPython Dictionaries\nDictionary\nA dictionary is a collection which is unordered, changeable and indexed.\n In Python dictionaries are written with curly brackets, and they have keys and values.\n\nExample\nUsing the len() method to return the number of items:... |
class Solution:
def maxSumDivThree(self, nums: List[int]) -> int:
ones = []
twos = []
ans = 0
for num in nums:
ans += num
if num % 3 == 1:
ones.append(num)
elif num % 3 == 2:
twos.append(num)
if ans % 3 == 0:... | class Solution:
def max_sum_div_three(self, nums: List[int]) -> int:
ones = []
twos = []
ans = 0
for num in nums:
ans += num
if num % 3 == 1:
ones.append(num)
elif num % 3 == 2:
twos.append(num)
if ans % 3 =... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Problem 031
The Minion Game
Source : https://www.hackerrank.com/challenges/the-minion-game/problem
"""
def is_vowel(c):
return c in ("A","E","I","O","U")
def minion_game(word):
p1, p2 = 0, 0
nb = len(word)
for i in range(nb):
if is_vowel(word... | """Problem 031
The Minion Game
Source : https://www.hackerrank.com/challenges/the-minion-game/problem
"""
def is_vowel(c):
return c in ('A', 'E', 'I', 'O', 'U')
def minion_game(word):
(p1, p2) = (0, 0)
nb = len(word)
for i in range(nb):
if is_vowel(word[i]):
p2 += nb - i
... |
def evaluate_shard(out_csv_name, pw_ji, labels_x, labels_y, d = 0.00, d_step = 0.005, d_max=1.0):
h.save_to_csv(data_rows=[[
"Distance Threshhold",
"True Positives",
"False Positives",
"True Negative",
"False Negative",
"Num True Same",
"Num True Dif... | def evaluate_shard(out_csv_name, pw_ji, labels_x, labels_y, d=0.0, d_step=0.005, d_max=1.0):
h.save_to_csv(data_rows=[['Distance Threshhold', 'True Positives', 'False Positives', 'True Negative', 'False Negative', 'Num True Same', 'Num True Diff']], outfile_name=out_csv_name, mode='w')
n_labels = len(labels_x)
... |
__query_all = {
# DO NOT CHANGE THE FIRST KEY VALUE, IT HAS TO BE FIRST.
'question_select_all_desc_by_date':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time DESC',
'question_select_all_asc_by_date':
'SELECT id, submission_ti... | __query_all = {'question_select_all_desc_by_date': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time DESC', 'question_select_all_asc_by_date': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_... |
class EmptyRainfallError(ValueError):
pass
class EmptyWaterlevelError(ValueError):
pass
class NoMethodError(ValueError):
pass | class Emptyrainfallerror(ValueError):
pass
class Emptywaterlevelerror(ValueError):
pass
class Nomethoderror(ValueError):
pass |
"""
TOTAL BUTTON COUNT: 26 Buttons
GROUP NAMES: Enumerates each of the groups of buttons on controller.
BUTTON NAMES: Enumerates each of the names for each button on the controller.
GROUP SIZES: Dictionary containing the total number of buttons in each group.
BUTTON GROUPS: Dictionary where keys are group names an... | """
TOTAL BUTTON COUNT: 26 Buttons
GROUP NAMES: Enumerates each of the groups of buttons on controller.
BUTTON NAMES: Enumerates each of the names for each button on the controller.
GROUP SIZES: Dictionary containing the total number of buttons in each group.
BUTTON GROUPS: Dictionary where keys are group names an... |
# O(n^2) time | O(1) Space
# def twoNumberSum(array, targetSum):
# for i in range(len(array)):
# firstNum = array[i]
# for j in range(i+1, array[j]):
# secondNum = array[j]
# if firstNum + secondNum == targetSum:
# return [firstNum,secondNum]
# return []
... | def two_number_sum(array, targetSum):
array.sort()
left = 0
right = len(array) - 1
while left < right:
current_sum = array[left] + array[right]
if currentSum == targetSum:
return [array[left], array[right]]
elif currentSum < targetSum:
left += 1
el... |
class Solution:
def isStrobogrammatic(self, num: str) -> bool:
# create a hash table for 180 degree rotation mapping
helper = {'0':'0','1':'1','6':'9','8':'8','9':'6'}
# flip the given string
num2 = ''
n = len(num)
i = n - 1
while i >= 0:
... | class Solution:
def is_strobogrammatic(self, num: str) -> bool:
helper = {'0': '0', '1': '1', '6': '9', '8': '8', '9': '6'}
num2 = ''
n = len(num)
i = n - 1
while i >= 0:
if num[i] in helper:
num2 += helper[num[i]]
else:
... |
## floating point
class Number(Primitive):
def __init__(self, V, prec=4):
Primitive.__init__(self, float(V))
## precision: digits after decimal `.`
self.prec = prec
| class Number(Primitive):
def __init__(self, V, prec=4):
Primitive.__init__(self, float(V))
self.prec = prec |
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 8 19:30:21 2018
@author: lenovo
"""
def Bsearch(A, key):
length = len(A)
if length == 0:
return -1
A.sort()
left = 0
right = length - 1
while left <= right:
mid = int((left + right) / 2)
if key == A[mid]:
retur... | """
Created on Wed Aug 8 19:30:21 2018
@author: lenovo
"""
def bsearch(A, key):
length = len(A)
if length == 0:
return -1
A.sort()
left = 0
right = length - 1
while left <= right:
mid = int((left + right) / 2)
if key == A[mid]:
return mid
elif key <... |
#media sources
dataurl_src = "'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAAAA'"
throttler = "'../resources/range-request.php?rate=100000&fileloc=";
mp4_src = throttler + "preload.mp4&nocache=' + Math.random()";
ogg_src = throttler + "preload.ogv&nocache=' + Math.random()";
webm... | dataurl_src = "'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAAAA'"
throttler = "'../resources/range-request.php?rate=100000&fileloc="
mp4_src = throttler + "preload.mp4&nocache=' + Math.random()"
ogg_src = throttler + "preload.ogv&nocache=' + Math.random()"
webm_src = throttler + "... |
class SecureList(object):
def __init__(self, lst):
self.lst = list(lst)
def __getitem__(self, item):
return self.lst.pop(item)
def __len__(self):
return len(self.lst)
def __repr__(self):
tmp, self.lst = self.lst, []
return repr(tmp)
def __str__(self):
... | class Securelist(object):
def __init__(self, lst):
self.lst = list(lst)
def __getitem__(self, item):
return self.lst.pop(item)
def __len__(self):
return len(self.lst)
def __repr__(self):
(tmp, self.lst) = (self.lst, [])
return repr(tmp)
def __str__(self):... |
first_card = input().strip().upper()
second_card = input().strip().upper()
third_card = input().strip().upper()
total_point = 0
if first_card == 'A':
total_point += 1
elif first_card in 'JQK':
total_point += 10
else:
total_point += int(first_card)
if second_card == 'A':
total_point += 1
elif second... | first_card = input().strip().upper()
second_card = input().strip().upper()
third_card = input().strip().upper()
total_point = 0
if first_card == 'A':
total_point += 1
elif first_card in 'JQK':
total_point += 10
else:
total_point += int(first_card)
if second_card == 'A':
total_point += 1
elif second_card... |
class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class List:
def __init__(self):
self.head = None
self.tail = None
self.this = None
def add_to_tail(self, val):
new_node = Node(val)
if self.empty():
self... | class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class List:
def __init__(self):
self.head = None
self.tail = None
self.this = None
def add_to_tail(self, val):
new_node = node(val)
if self.empty():
self... |
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'targets': [
{
# GN version: //ui/events/keycodes:xkb
'target_name': 'keycodes_xkb',
... | {'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'keycodes_xkb', 'type': 'static_library', 'dependencies': ['<(DEPTH)/base/base.gyp:base', '<(DEPTH)/ui/events/events.gyp:dom_keycode_converter'], 'sources': ['keyboard_code_conversion_xkb.cc', 'keyboard_code_conversion_xkb.h', 'scoped_xkb.h', 'xkb_keysym.h... |
# from typing import Any
class SensorCache(object):
# instance = None
soil_moisture: float = 0
temperature: float = 0
humidity: float = 0
# def __init__(self):
# if SensorCache.instance:
# return
# self.soil_moisture: float = 0
# self.temperature: int = 0
#... | class Sensorcache(object):
soil_moisture: float = 0
temperature: float = 0
humidity: float = 0 |
#
# PySNMP MIB module NMS-ERPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-ERPS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:22:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (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_intersection, constraints_union) ... |
"""
1. The larger the time-step $\Delta t$ the more the estimate $p_1$ deviates
from the exact $p(t_1)$.
2. There is a linear relationship between $\Delta t$ and $e_1$: double the time-step double the error.
3. Make more shorter time-steps
""" | """
1. The larger the time-step $\\Delta t$ the more the estimate $p_1$ deviates
from the exact $p(t_1)$.
2. There is a linear relationship between $\\Delta t$ and $e_1$: double the time-step double the error.
3. Make more shorter time-steps
""" |
def quote_info(text):
return f"<blockquote class=info>{text}</blockquote>"
def quote_warning(text):
return f"<blockquote class=warning>{text}</blockquote>"
def quote_danger(text):
return f"<blockquote class=danger>{text}</blockquote>"
def code(text):
return f"<code>{text}</code>"
def html_link(l... | def quote_info(text):
return f'<blockquote class=info>{text}</blockquote>'
def quote_warning(text):
return f'<blockquote class=warning>{text}</blockquote>'
def quote_danger(text):
return f'<blockquote class=danger>{text}</blockquote>'
def code(text):
return f'<code>{text}</code>'
def html_link(link_... |
#!/usr/bin/env python
# encoding: utf-8
class postag(object):
# ref: http://universaldependencies.org/u/pos/index.html
# Open class words
ADJ = "ADJ"
ADV = "ADV"
INTJ = "INTJ"
NOUN = "NOUN"
PROPN = "PROPN"
VERB = "VERB"
# Closed class words
ADP = "ADP"
AUX ="AUX"
CCON... | class Postag(object):
adj = 'ADJ'
adv = 'ADV'
intj = 'INTJ'
noun = 'NOUN'
propn = 'PROPN'
verb = 'VERB'
adp = 'ADP'
aux = 'AUX'
cconj = 'CCONJ'
det = 'DET'
num = 'NUM'
part = 'PART'
pron = 'PRON'
sconj = 'SCONJ'
punct = 'PUNCT'
sym = 'SYM'
x = 'X'
cla... |
print("-----------\nOmzetten van lengte-eenheden - Kilometers naar miles.\n")
while True:
print ("Geef de kilometers in die naar miles moeten omgezet.\nGebruik alleen getallen!")
km = str(input("Kilometers: "))
try:
km = float(km.replace(",", ".")) # replace comma with dot, if user entered a co... | print('-----------\nOmzetten van lengte-eenheden - Kilometers naar miles.\n')
while True:
print('Geef de kilometers in die naar miles moeten omgezet.\nGebruik alleen getallen!')
km = str(input('Kilometers: '))
try:
km = float(km.replace(',', '.'))
miles = round(km * 0.621371, 2)
prin... |
#!/usr/bin/env python3
"""
implementation of recursive hilbert enumeration
"""
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def up(point):
point.y += 1
def down(point):
point.y -= 1
def left(point):
point.x -= 1
def right(point):
point.x += 1
def hilber... | """
implementation of recursive hilbert enumeration
"""
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def up(point):
point.y += 1
def down(point):
point.y -= 1
def left(point):
point.x -= 1
def right(point):
point.x += 1
def hilbert(n, point=point(), up=up, ... |
class Pair(object):
def __init__(self, individual1, individual2):
self.ind1 = individual1
self.ind2 = individual2
| class Pair(object):
def __init__(self, individual1, individual2):
self.ind1 = individual1
self.ind2 = individual2 |
class atom(object):
def __init__(self,atno,x,y,z):
self.atno = atno
self.position = (x,y,z)
# this is constructor
def symbol(self): # a class method
return atno__to__Symbol[atno]
def __repr__(self): # a class method
return '%d %10.4f %10.4f %10.4f%'
(... | class Atom(object):
def __init__(self, atno, x, y, z):
self.atno = atno
self.position = (x, y, z)
def symbol(self):
return atno__to__Symbol[atno]
def __repr__(self):
return '%d %10.4f %10.4f %10.4f%'
(self.atno, self.position[0], self.position[1], self.position[2]) |
class Data:
def __init__(self, startingArray):
self.dict = {
"Category" : 0,
"Month" : 1,
"Day" : 2,
"RepeatType" : 3,
"Time" : 4,
}
self.list = ["Category","Month", "Day", "RepeatMonth", "Time"]
... | class Data:
def __init__(self, startingArray):
self.dict = {'Category': 0, 'Month': 1, 'Day': 2, 'RepeatType': 3, 'Time': 4}
self.list = ['Category', 'Month', 'Day', 'RepeatMonth', 'Time']
self.data = startingArray
def set_data(self, array):
self.data = array
def get_data(... |
class Solution:
def findJudge(self, n: int, trust: List[List[int]]) -> int:
if not trust and n == 1:
return 1
Trust = defaultdict(list)
Trusted = defaultdict(list)
for a, b in trust:
Trust[a].append(b)
Trusted[b].append(a)
for i, t in Trust... | class Solution:
def find_judge(self, n: int, trust: List[List[int]]) -> int:
if not trust and n == 1:
return 1
trust = defaultdict(list)
trusted = defaultdict(list)
for (a, b) in trust:
Trust[a].append(b)
Trusted[b].append(a)
for (i, t) in... |
HOST = "irc.twitch.tv"
PORT = 6667
NICK = "simpleaibot"
PASS = "oauth:tldegtq435nf1dgdps8ik9opfw9pin"
CHAN = "simpleaibot"
OWNER = ["sinstr_syko", "aloeblinka"]
| host = 'irc.twitch.tv'
port = 6667
nick = 'simpleaibot'
pass = 'oauth:tldegtq435nf1dgdps8ik9opfw9pin'
chan = 'simpleaibot'
owner = ['sinstr_syko', 'aloeblinka'] |
N,K=map(int,input().split())
L=[1]*(N+1)
for j in range(2,N+1):
if L[j]: key=j
for i in range(key,N+1,key):
if L[i]:
L[i]=0
K-=1
if K==0:
print(i)
exit() | (n, k) = map(int, input().split())
l = [1] * (N + 1)
for j in range(2, N + 1):
if L[j]:
key = j
for i in range(key, N + 1, key):
if L[i]:
L[i] = 0
k -= 1
if K == 0:
print(i)
exit() |
"""lists"""
#import json
class Lists:
"""lists"""
def __init__(self, twitter):
self.twitter = twitter
def list(self, params):
"""Hello"""
pass
def members(self, params):
"""Hello"""
pass
def memberships(self, params):
"""Hello"""
pass
def ... | """lists"""
class Lists:
"""lists"""
def __init__(self, twitter):
self.twitter = twitter
def list(self, params):
"""Hello"""
pass
def members(self, params):
"""Hello"""
pass
def memberships(self, params):
"""Hello"""
pass
def ownershi... |
def fact(n = 5):
if n < 2:
return 1
else:
return n * fact(n-1)
num = input("Enter a number to get its factorial: ")
if num == 'None' or num == '' or num == ' ':
print("Factorial of default value is: ",fact())
else:
print("Factorial of number is: ",fact(int(num)))
| def fact(n=5):
if n < 2:
return 1
else:
return n * fact(n - 1)
num = input('Enter a number to get its factorial: ')
if num == 'None' or num == '' or num == ' ':
print('Factorial of default value is: ', fact())
else:
print('Factorial of number is: ', fact(int(num))) |
SUCCESS_GENERAL = 2000
SUCCESS_USER_REGISTERED = 2001
SUCCESS_USER_LOGGED_IN = 2002
ERROR_USER_ALREADY_REGISTERED = 4000
ERROR_USER_LOGIN = 4001
ERROR_LOGIN_FAILED_SYSTEM_ERROR = 4002 | success_general = 2000
success_user_registered = 2001
success_user_logged_in = 2002
error_user_already_registered = 4000
error_user_login = 4001
error_login_failed_system_error = 4002 |
"""
Ludolph: Monitoring Jabber Bot
Version: 1.0.1
Homepage: https://github.com/erigones/Ludolph
Copyright (C) 2012-2017 Erigones, s. r. o.
See the LICENSE file for copying permission.
"""
__version__ = '1.0.1'
__author__ = 'Erigones, s. r. o.'
__copyright__ = 'Copyright 2012-2017, Erigones, s. r. o.'
| """
Ludolph: Monitoring Jabber Bot
Version: 1.0.1
Homepage: https://github.com/erigones/Ludolph
Copyright (C) 2012-2017 Erigones, s. r. o.
See the LICENSE file for copying permission.
"""
__version__ = '1.0.1'
__author__ = 'Erigones, s. r. o.'
__copyright__ = 'Copyright 2012-2017, Erigones, s. r. o.' |
#
# PySNMP MIB module AVICI-SMI (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AVICI-SMI
# Produced by pysmi-0.3.4 at Wed May 1 11:32:28 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, value_range_constraint, constraints_intersection) ... |
# Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | ga_account_id = ''
ga_property_id = ''
ga_dataset_id = ''
bqml_predict_query = '\n '
enable_bq_logging = False
enable_sendgrid_email_reporting = False
gcp_project_id = ''
bq_dataset_name = ''
bq_table_name = ''
sendgrid_api_key = ''
to_email = ''
from_email = 'workflow@example.com'
subject = 'FAILED... |
{
"uidPageJourney": {
W3Const.w3PropType: W3Const.w3TypePanel,
W3Const.w3PropSubUI: [
"uidJourneyTab"
]
},
"uidJourneyTab": {
W3Const.w3PropType: W3Const.w3TypeTab,
W3Const.w3PropSubUI: [
["uidJourneyTabJourneyLabel", "uidJourneyTabJourneyPanel... | {'uidPageJourney': {W3Const.w3PropType: W3Const.w3TypePanel, W3Const.w3PropSubUI: ['uidJourneyTab']}, 'uidJourneyTab': {W3Const.w3PropType: W3Const.w3TypeTab, W3Const.w3PropSubUI: [['uidJourneyTabJourneyLabel', 'uidJourneyTabJourneyPanel'], ['uidJourneyTabMapLabel', 'uidJourneyTabMapPanel']], W3Const.w3PropCSS: {'borde... |
def custom_send(socket):
socket.send("message from mod.myfunc()")
def custom_recv(socket):
socket.recv()
def custom_measure(q):
return q.measure()
| def custom_send(socket):
socket.send('message from mod.myfunc()')
def custom_recv(socket):
socket.recv()
def custom_measure(q):
return q.measure() |
#This one is straight out the standard library.
def _default_mime_types():
types_map = {
'.cdf' : 'application/x-cdf',
'.cdf' : 'application/x-netcdf',
'.xls' : 'application/excel',
'.xls' : 'application/vnd.ms-excel',
}
| def _default_mime_types():
types_map = {'.cdf': 'application/x-cdf', '.cdf': 'application/x-netcdf', '.xls': 'application/excel', '.xls': 'application/vnd.ms-excel'} |
s = input()
ret = 0
for i in range(len(s)//2):
if s[i] != s[-(i+1)]:
ret += 1
print(ret)
| s = input()
ret = 0
for i in range(len(s) // 2):
if s[i] != s[-(i + 1)]:
ret += 1
print(ret) |
SBOX = (
(0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76),
(0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0),
(0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15),
(... | sbox = ((99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118), (202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192), (183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21), (4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117), (9, 131... |
poem = '''There was a young lady named Bright,
Whose speed was far faster than light;
She started one day In a relative way, And
returned on the previous night.'''
print(poem)
try:
fout = open('relativety', 'xt')
fout.write(poem)
fout.close()
except FileExistsError:
print('relativety already exists! ... | poem = 'There was a young lady named Bright,\nWhose speed was far faster than light;\nShe started one day In a relative way, And\nreturned on the previous night.'
print(poem)
try:
fout = open('relativety', 'xt')
fout.write(poem)
fout.close()
except FileExistsError:
print('relativety already exists! That... |
try:
with open("input.txt", "r") as fileContent:
timers = [int(number) for number in fileContent.readline().split(",")]
frequencies = [0] * 9
for timer in timers:
frequencies[timer] = timers.count(timer)
except FileNotFoundError:
print("[!] The input file was not found. The p... | try:
with open('input.txt', 'r') as file_content:
timers = [int(number) for number in fileContent.readline().split(',')]
frequencies = [0] * 9
for timer in timers:
frequencies[timer] = timers.count(timer)
except FileNotFoundError:
print('[!] The input file was not found. The ... |
ADMINS = (
('Admin', 'admin@tvoy_style.com'),
)
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = 'dezigner20@gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'dezigner20@gmail.com'
EMAIL_HOST_PASSWORD = 'SSDD24869317SSDD**'
SERVER_EMAIL = DEFAULT_FR... | admins = (('Admin', 'admin@tvoy_style.com'),)
email_backend = 'django.core.mail.backends.smtp.EmailBackend'
default_from_email = 'dezigner20@gmail.com'
email_use_tls = True
email_host = 'smtp.gmail.com'
email_host_user = 'dezigner20@gmail.com'
email_host_password = 'SSDD24869317SSDD**'
server_email = DEFAULT_FROM_EMAIL... |
class Solution:
# @param {integer[]} nums
# @return {integer[]}
def productExceptSelf(self, nums):
before = []
after = []
product = 1
for num in nums:
before.append(product)
product = product * num
product = 1
for num in reversed(nums):... | class Solution:
def product_except_self(self, nums):
before = []
after = []
product = 1
for num in nums:
before.append(product)
product = product * num
product = 1
for num in reversed(nums):
after.append(product)
produc... |
def f(a):
global n
if n == 0 and a == 0:
return True
if n == a%10:
return True
if n == a//10:
return True
H1,M1=list(map(int,input().split()))
H2,M2=list(map(int,input().split()))
n=int(input())
S=0
while H1 != H2 or M1 != M2:
if f(H1) or f(M1):
S+=1
... | def f(a):
global n
if n == 0 and a == 0:
return True
if n == a % 10:
return True
if n == a // 10:
return True
(h1, m1) = list(map(int, input().split()))
(h2, m2) = list(map(int, input().split()))
n = int(input())
s = 0
while H1 != H2 or M1 != M2:
if f(H1) or f(M1):
s ... |
def add(x, y):
""" Add two number """
return x+y
def subtract(x,y):
return abs(x-y)
| def add(x, y):
""" Add two number """
return x + y
def subtract(x, y):
return abs(x - y) |
LOCATION_REPLACE = {
'USA': 'United States',
'KSA': 'Kingdom of Saudi Arabia',
'CA': 'Canada',
}
| location_replace = {'USA': 'United States', 'KSA': 'Kingdom of Saudi Arabia', 'CA': 'Canada'} |
def count(index):
print(index)
if index < 2:
count(index + 1)
count(0)
| def count(index):
print(index)
if index < 2:
count(index + 1)
count(0) |
def elbow_method(data, clusterer, max_k):
"""Elbow method function.
Takes dataset, "Reason" clusterer class and returns the optimum number of
clusters in range of 1 to max_k.
Args:
data (pandas.DataFrame or list of dict): Data to cluster.
clusterer (class): "Reason" clusterer.
... | def elbow_method(data, clusterer, max_k):
"""Elbow method function.
Takes dataset, "Reason" clusterer class and returns the optimum number of
clusters in range of 1 to max_k.
Args:
data (pandas.DataFrame or list of dict): Data to cluster.
clusterer (class): "Reason" clusterer.
... |
def main():
def square(n):
return n * n
if __name__ == '__main__':
main()
| def main():
def square(n):
return n * n
if __name__ == '__main__':
main() |
class Response:
def __init__(self, content, private=False, file=False):
self.content = content
self.private = private
self.file = file | class Response:
def __init__(self, content, private=False, file=False):
self.content = content
self.private = private
self.file = file |
def knapsackLight(value1, weight1, value2, weight2, maxW):
if weight1 + weight2 <= maxW:
return value1 + value2
if weight1 <= maxW and (weight2 > maxW or value1 >= value2):
return value1
if weight2 <= maxW and (weight1 > maxW or value2 >= value1):
return value2
return 0
| def knapsack_light(value1, weight1, value2, weight2, maxW):
if weight1 + weight2 <= maxW:
return value1 + value2
if weight1 <= maxW and (weight2 > maxW or value1 >= value2):
return value1
if weight2 <= maxW and (weight1 > maxW or value2 >= value1):
return value2
return 0 |
#
# PySNMP MIB module A3COM0074-SMA-VLAN-SUPPORT (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM0074-SMA-VLAN-SUPPORT
# Produced by pysmi-0.3.4 at Wed May 1 11:09:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (sma_vlan_support,) = mibBuilder.importSymbols('A3COM0004-GENERIC', 'smaVlanSupport')
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value... |
def countConstruct(target, word_bank, memo = None):
'''
input: target- String
word_bank- array of Strings
output: number of ways that the target can be constructed by
concatenating elements fo the word_bank array.
'''
if memo is None:
memo = {}
if target in memo:
return memo[target]
if target ==... | def count_construct(target, word_bank, memo=None):
"""
input: target- String
word_bank- array of Strings
output: number of ways that the target can be constructed by
concatenating elements fo the word_bank array.
"""
if memo is None:
memo = {}
if target in memo:
return memo[targe... |
# scenario of runs for MC covering 2012 with three eras, as proposed by ECAL/H2g for 2013 re-digi campaign
# for reference see: https://indico.cern.ch/conferenceDisplay.py?confId=243497
runProbabilityDistribution=[(194533,5.3),(200519,7.0),(206859,7.3)]
| run_probability_distribution = [(194533, 5.3), (200519, 7.0), (206859, 7.3)] |
__author__ = 'roeiherz'
"""
Given two straight line segments (represents as a start point and end point), compute the point of intersection, if any.
"""
class Line:
def __init__(self, point1, point2):
self.point1 = point1
self.point2 = point2
self.m = self.slope()
self.n = self.ge... | __author__ = 'roeiherz'
'\nGiven two straight line segments (represents as a start point and end point), compute the point of intersection, if any.\n'
class Line:
def __init__(self, point1, point2):
self.point1 = point1
self.point2 = point2
self.m = self.slope()
self.n = self.get_n... |
def sortStack(stack):
if len(stack) == 0:
return stack
top = stack.pop()
sortStack(stack)
insertInSortedOrder(stack, top)
return stack
def insertInSortedOrder(stack, value):
if len(stack) == 0 or stack[-1] <= value:
stack.append(value)
return
top = stack.pop()
... | def sort_stack(stack):
if len(stack) == 0:
return stack
top = stack.pop()
sort_stack(stack)
insert_in_sorted_order(stack, top)
return stack
def insert_in_sorted_order(stack, value):
if len(stack) == 0 or stack[-1] <= value:
stack.append(value)
return
top = stack.pop(... |
def safe_strftime(d, format_str='%Y-%m-%d %H:%M:%S') -> str:
try:
return d.strftime(format_str)
except Exception:
return ''
| def safe_strftime(d, format_str='%Y-%m-%d %H:%M:%S') -> str:
try:
return d.strftime(format_str)
except Exception:
return '' |
# WebSite Name
WebSiteName = 'Articles Journal'
######################################################################################
# Pages
__HOST = 'http://127.0.0.1:8000'
#############
# Register
SignUP = __HOST + '/Register/SignUP'
SignUP_Template = 'Register/SignUP.html'
Login = __HOST + '/Register/Login'
L... | web_site_name = 'Articles Journal'
__host = 'http://127.0.0.1:8000'
sign_up = __HOST + '/Register/SignUP'
sign_up__template = 'Register/SignUP.html'
login = __HOST + '/Register/Login'
login__template = 'Register/Login.html'
articles = __HOST
articles__template = 'Articles/Articles.html'
make_article = __HOST + '/Articl... |
def compute_opt(exact_filename, preprocessing_filename):
datasets = set() # Dataset names
exact_solution_lookup = {} # Maps dataset names to OPT
with open(exact_filename, 'r') as infile:
# Discard header
infile.readline()
for line in infile.readlines():
line = line.split... | def compute_opt(exact_filename, preprocessing_filename):
datasets = set()
exact_solution_lookup = {}
with open(exact_filename, 'r') as infile:
infile.readline()
for line in infile.readlines():
line = line.split(',')
if line[1] == 'ilp':
datasets.add(li... |
brd = {
'name': ('StickIt! MPU-9150 V1'),
'port': {
'pmod': {
'default' : {
'scl': 'd1',
'clkin': 'd2',
'sda': 'd3',
'int': 'd5',
'fsync': 'd7'
}
},
'wing': {
... | brd = {'name': 'StickIt! MPU-9150 V1', 'port': {'pmod': {'default': {'scl': 'd1', 'clkin': 'd2', 'sda': 'd3', 'int': 'd5', 'fsync': 'd7'}}, 'wing': {'default': {'scl': 'd0', 'clkin': 'd3', 'sda': 'd2', 'int': 'd5', 'fsync': 'd7'}}}} |
def for_K():
""" Upper case Alphabet letter 'K' pattern using Python Python for loop"""
for row in range(6):
for col in range(4):
if col==0 or row+col==3 or row-col==2:
print('*', end = ' ')
else:
... | def for_k():
""" Upper case Alphabet letter 'K' pattern using Python Python for loop"""
for row in range(6):
for col in range(4):
if col == 0 or row + col == 3 or row - col == 2:
print('*', end=' ')
else:
print(' ', end=' ')
print()
def wh... |
class BlockTerminationNotice(Exception):
pass
class IncorrectLocationException(Exception):
pass
class SootMethodNotLoadedException(Exception):
pass
class SootFieldNotLoadedException(Exception):
pass
| class Blockterminationnotice(Exception):
pass
class Incorrectlocationexception(Exception):
pass
class Sootmethodnotloadedexception(Exception):
pass
class Sootfieldnotloadedexception(Exception):
pass |
# description: various useful helpers
class DataKeys(object):
"""standard names for features
and transformations of features
"""
# core data keys
FEATURES = "features"
LABELS = "labels"
PROBABILITIES = "probs"
LOGITS = "logits"
LOGITS_NORM = "{}.norm".format(LOGITS)
ORIG_SEQ ... | class Datakeys(object):
"""standard names for features
and transformations of features
"""
features = 'features'
labels = 'labels'
probabilities = 'probs'
logits = 'logits'
logits_norm = '{}.norm'.format(LOGITS)
orig_seq = 'sequence'
seq_metadata = 'example_metadata'
logits_m... |
class Corner(object):
def __init__(self, row, column, lines):
self.row = row
self.column = column
self.lines = lines
self.done = False
for line in self.lines:
line.add_corner(self)
self.line_number = None
def check_values(self):
if self.done:... | class Corner(object):
def __init__(self, row, column, lines):
self.row = row
self.column = column
self.lines = lines
self.done = False
for line in self.lines:
line.add_corner(self)
self.line_number = None
def check_values(self):
if self.done:... |
#Table used for the example 2split.py
#################################################################################################
source_path = "/home/user/Scrivania/Ducks/"# Where the images are
output_path = "/home/user/Scrivania/Ducks/"# Where the two directory with the cutted images will be stored
RIGHT_CUT_... | source_path = '/home/user/Scrivania/Ducks/'
output_path = '/home/user/Scrivania/Ducks/'
right_cut_dir_name = 'right_duck'
left_cut_dir_name = 'left_duck'
left_prefix = 'left_quacky'
right_prefix = 'right_quacky' |
def logic(value, a, b):
if value:
return a
return b
hero.moveXY(20, 24);
a = hero.findNearestFriend().getSecretA()
b = hero.findNearestFriend().getSecretB()
c = hero.findNearestFriend().getSecretC()
hero.moveXY(30, logic(a and b and c, 33, 15))
hero.moveXY(logic(a or b or c, 20, 40), 24)
hero.moveXY(3... | def logic(value, a, b):
if value:
return a
return b
hero.moveXY(20, 24)
a = hero.findNearestFriend().getSecretA()
b = hero.findNearestFriend().getSecretB()
c = hero.findNearestFriend().getSecretC()
hero.moveXY(30, logic(a and b and c, 33, 15))
hero.moveXY(logic(a or b or c, 20, 40), 24)
hero.moveXY(30, ... |
def a(mem):
seen = set()
tup = tuple(mem)
count = 0
while tup not in seen:
seen.add(tup)
index = 0
max = 0
for i in range(len(mem)):
n = mem[i]
if(n > max):
max = n
index = i
mem[index] = 0
index += 1
while(max > 0):
... | def a(mem):
seen = set()
tup = tuple(mem)
count = 0
while tup not in seen:
seen.add(tup)
index = 0
max = 0
for i in range(len(mem)):
n = mem[i]
if n > max:
max = n
index = i
mem[index] = 0
index += 1
... |
def mergeSort(l):
if len(l) > 1:
mid = len(l) // 2
L = l[:mid]
R = l[mid:]
mergeSort(L)
mergeSort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] < R[j]:
l[k] = L[i]
i += 1
else:
... | def merge_sort(l):
if len(l) > 1:
mid = len(l) // 2
l = l[:mid]
r = l[mid:]
merge_sort(L)
merge_sort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] < R[j]:
l[k] = L[i]
i += 1
else:
... |
class Solution:
def minAbbreviation(self, target: str, dictionary: List[str]) -> str:
m = len(target)
def getMask(word: str) -> int:
# mask[i] = 0 := target[i] == word[i]
# mask[i] = 1 := target[i] != word[i]
# e.g. target = "apple"
# word = "blade"
# mask = 11110... | class Solution:
def min_abbreviation(self, target: str, dictionary: List[str]) -> str:
m = len(target)
def get_mask(word: str) -> int:
mask = 0
for (i, c) in enumerate(word):
if c != target[i]:
mask |= 1 << m - 1 - i
return ma... |
#! python3
# __author__ = "YangJiaHao"
# date: 2018/2/8
class Solution:
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if len(digits) <= 0:
return []
keys = [[''], [''], ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ... | class Solution:
def letter_combinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if len(digits) <= 0:
return []
keys = [[''], [''], ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n', 'o'], ['p', 'q', 'r', 's']... |
{
"targets": [
{
"target_name": "example",
"sources": [ "example.cxx", "example_wrap.cxx" ]
}
]
} | {'targets': [{'target_name': 'example', 'sources': ['example.cxx', 'example_wrap.cxx']}]} |
# Event: LCCS Python Fundamental Skills Workshop
# Date: Dec 2018
# Author: Joe English, PDST
# eMail: computerscience@pdst.ie
# Solution to programming exercises 6.1 Q2
# Purpose: A program to find the GCD of any two positive integers
# Determines if one number is a factor of the other
def isFactor(a1, a2):... | def is_factor(a1, a2):
if a2 % a1 == 0:
return True
else:
return False
def get_factors(n):
factors = []
for i in range(1, n + 1):
if is_factor(i, n):
factors.append(i)
return factors
def gcd(l1, l2):
set1 = set(l1)
set2 = set(l2)
common_factors = set... |
assert format(5, "b") == "101"
try:
format(2, 3)
except TypeError:
pass
else:
assert False, "TypeError not raised when format is called with a number"
| assert format(5, 'b') == '101'
try:
format(2, 3)
except TypeError:
pass
else:
assert False, 'TypeError not raised when format is called with a number' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.