content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Author: Kay Hartmann <kg.hartma@gmail.com>
def weight_filler(m):
classname = m.__class__.__name__
if classname.find('MultiConv') != -1:
for conv in m.convs:
conv.weight.data.normal_(0.0, 1.)
if conv.bias is not None:
conv.bias.data.fill_(0.)
elif classname... | def weight_filler(m):
classname = m.__class__.__name__
if classname.find('MultiConv') != -1:
for conv in m.convs:
conv.weight.data.normal_(0.0, 1.0)
if conv.bias is not None:
conv.bias.data.fill_(0.0)
elif classname.find('Conv') != -1 or classname.find('Linear... |
class Figura():
def __init__(self, figura):
self.__figura = figura
def area(self):
return self.__figura.area()
def perimetro(self):
return self.__figura.perimetro()
| class Figura:
def __init__(self, figura):
self.__figura = figura
def area(self):
return self.__figura.area()
def perimetro(self):
return self.__figura.perimetro() |
###
### NOTICE: this file did not exit in the original Dimorphite_DL release.
### The is newly created based on "sites_substructures.smarts" file
### - made a readable Python module from it. Andrey Frolov, 2020-09-15
### - added last column with acid-base classification. Andrey Frolov, 2020-09-11
### - added TATA sub... | data_txt = '\nTATA CC(=O)N1CN(CN(C1)C(C)=O)C(C)=O NaN NaN NaN base\n\n*Azide\t[N+0:1]=[N+:2]=[N+0:3]-[H]\t2\t4.65\t0.07071067811865513 acid\nNitro\t[C,c,N,n,O,o:1]-[NX3:2](=[O:3])-[O:4]-[H]\t3\t-1000.0\t0 acid\nAmidineGuanidine1\t[N:1]-[C:2](-[N:3])=[NX2:4]-[H:5]\t3\t12.025333333333334\t1.594104615076916... |
n=int(input("enter a number"))
if(n%5==0 or n%7==0):
print("divisible by 5 or 7")
else:
print("not divisible")
| n = int(input('enter a number'))
if n % 5 == 0 or n % 7 == 0:
print('divisible by 5 or 7')
else:
print('not divisible') |
#
# PySNMP MIB module HM2-DHCPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HM2-DHCPS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:18:34 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
#
# PySNMP MIB module HUAWEI-UNIMNG-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-UNIMNG-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:49:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_intersection, constraints_union, single_value_constraint) ... |
'''
NAME
Program that calculates the percentage of a list of amino acids.
VERSION
[1.0]
AUTHOR
Rodrigo Daniel Hernandez Barrera <<rodrigoh@lcg.unam.mx>>
DESCRIPTION
This program takes a sequence of amino acids from a protein and a list of amino acids, looks for these in the
sequen... | """
NAME
Program that calculates the percentage of a list of amino acids.
VERSION
[1.0]
AUTHOR
Rodrigo Daniel Hernandez Barrera <<rodrigoh@lcg.unam.mx>>
DESCRIPTION
This program takes a sequence of amino acids from a protein and a list of amino acids, looks for these in the
sequen... |
#Gary Cunningham. 27/03/19
#My program intends to convert the string inputted by removing every second word on the output.
#Adaptation from python tutorials, class content and w3schools.com interactive tutorials.
#Attempted this solution alongside the inputs from the learnings of previous solutions in this problem set.... | n = input('Please enter a sentence: ')
secondstring = n.split()
for words in secondstring:
print(' '.join(secondstring[::2]))
break |
distance = int(input('Inform the distance: '))
if distance <= 200:
price = distance * 0.5
else:
price = distance * 0.45
print('Your trip cost \033[1;33;44mR$ {:.2f}\033[m.'.format(price))
| distance = int(input('Inform the distance: '))
if distance <= 200:
price = distance * 0.5
else:
price = distance * 0.45
print('Your trip cost \x1b[1;33;44mR$ {:.2f}\x1b[m.'.format(price)) |
#!/usr/bin/env python
imagedir = parent + "/oiio-images"
command += oiiotool (imagedir+"/grid.tif --scanline -o grid.iff")
command += diff_command (imagedir+"/grid.tif", "grid.iff")
| imagedir = parent + '/oiio-images'
command += oiiotool(imagedir + '/grid.tif --scanline -o grid.iff')
command += diff_command(imagedir + '/grid.tif', 'grid.iff') |
class Sang:
def __init__(self, tittel, artist):
self._tittel = tittel
self._artist = artist
def spill(self):
print('\t Spiller av', self._tittel, 'av', self._artist)
def sjekkArtist(self, navn):
liste = navn.split()
for i in liste:
if i in self._artist:
... | class Sang:
def __init__(self, tittel, artist):
self._tittel = tittel
self._artist = artist
def spill(self):
print('\t Spiller av', self._tittel, 'av', self._artist)
def sjekk_artist(self, navn):
liste = navn.split()
for i in liste:
if i in self._artist... |
l = [6,2,5,5,4,5,6,3,7,6]
for _ in range(int(input())):
a,b = map(int,input().split())
ans = a + b
val = 0
for i in str(ans):
val += l[int(i)]
print(val) | l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for _ in range(int(input())):
(a, b) = map(int, input().split())
ans = a + b
val = 0
for i in str(ans):
val += l[int(i)]
print(val) |
def measure(bucket1, bucket2, goal, start_bucket):
if start_bucket == "one":
liter1 = bucket1
liter2 = 0
elif start_bucket == "two":
liter1 = 0
liter2 = bucket2
return bfs(bucket1, bucket2, liter1, liter2, goal, start_bucket)
def bfs(bucket1, bucket2, liter1, liter2, goal,... | def measure(bucket1, bucket2, goal, start_bucket):
if start_bucket == 'one':
liter1 = bucket1
liter2 = 0
elif start_bucket == 'two':
liter1 = 0
liter2 = bucket2
return bfs(bucket1, bucket2, liter1, liter2, goal, start_bucket)
def bfs(bucket1, bucket2, liter1, liter2, goal, s... |
class SymbolManager:
def __init__(self):
self.symbol_dic = {}
def add_symbol(self, symbol):
if symbol is None:
return
self.symbol_dic[symbol.symbol_code] = symbol
def find_symbol(self, symbol_code):
for symbol in self.symbol_dic.items():
if symbol[1... | class Symbolmanager:
def __init__(self):
self.symbol_dic = {}
def add_symbol(self, symbol):
if symbol is None:
return
self.symbol_dic[symbol.symbol_code] = symbol
def find_symbol(self, symbol_code):
for symbol in self.symbol_dic.items():
if symbol[1... |
# Constants for the Lines and Boxes game
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 450
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GRAY = (220, 220, 220)
FRAMES_PER_SECOND = 40
NROWS = 5
NCOLS = 5
NSQUARES = NROWS * NCOLS
SPACING = 43
NLINES = 60
EMPTY = 'empty'
HUMAN = 'human'
COMPUTER = 'computer'
STARTING_X = 72
STARTI... | window_width = 800
window_height = 450
white = (255, 255, 255)
black = (0, 0, 0)
gray = (220, 220, 220)
frames_per_second = 40
nrows = 5
ncols = 5
nsquares = NROWS * NCOLS
spacing = 43
nlines = 60
empty = 'empty'
human = 'human'
computer = 'computer'
starting_x = 72
starting_y = 48
box_size = 45
line_size = 13
box_and_... |
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def insert_node(root, value):
if root.data:
if value < root.data:
if root.left is None:
root.left = Node(value)
else:
insert_node(ro... | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def insert_node(root, value):
if root.data:
if value < root.data:
if root.left is None:
root.left = node(value)
else:
insert_node(ro... |
#
# PySNMP MIB module A3COM-SWITCHING-SYSTEMS-ROUTEPOLICY-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-SWITCHING-SYSTEMS-ROUTEPOLICY-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:08:29 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwan... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, value_range_constraint, constraints_union, single_value_constraint) ... |
#Programa para saber la nota
nota = int(input("Introduce tu nota: "))
if nota < 5:
print("Insuficiente: esfuerzate mas")
elif nota < 6:
print("Suficiente")
elif nota < 7:
print("Bien")
elif nota < 9:
print("Notable")
else:
print("Sobresaliente: eres un/a crack")
| nota = int(input('Introduce tu nota: '))
if nota < 5:
print('Insuficiente: esfuerzate mas')
elif nota < 6:
print('Suficiente')
elif nota < 7:
print('Bien')
elif nota < 9:
print('Notable')
else:
print('Sobresaliente: eres un/a crack') |
# Data Types
a = 5
print(a, "is of type", type(a))
a = 2.0
print(a, "is of type", type(a))
a = 1+2j
print(a, "is complex number?", isinstance(1+2j,complex)) | a = 5
print(a, 'is of type', type(a))
a = 2.0
print(a, 'is of type', type(a))
a = 1 + 2j
print(a, 'is complex number?', isinstance(1 + 2j, complex)) |
#! /usr/bin/python3
#Note: Binary to Decimal Calculator
#Author: Khondakar
choice = int(input("[1] Decimal to Binary conversion. " + "\n[2] Binary to Decimal conversion. \nEnter choice: "))
# print("1: Decimal to Binary")
# print("2: Binary to Decimal")
val = ""
if choice == 1:
numb = int(input("Enter your whole... | choice = int(input('[1] Decimal to Binary conversion. ' + '\n[2] Binary to Decimal conversion. \nEnter choice: '))
val = ''
if choice == 1:
numb = int(input('Enter your whole Decimal number (integer): '))
while numb > 1:
val = str(numb % 2) + val
numb = numb // 2
val = str(numb % 2) + val
... |
class doggy(object):
def __init__(self, name, age, color):
self.name = name
self.age = age
self.color = color
def myNameIs(self):
print ('%s, %s, %s' % (self.name, self.age, self.color))
def bark(self):
print ("Wang Wang !!")
wangcai = doggy("Wangcai Masa... | class Doggy(object):
def __init__(self, name, age, color):
self.name = name
self.age = age
self.color = color
def my_name_is(self):
print('%s, %s, %s' % (self.name, self.age, self.color))
def bark(self):
print('Wang Wang !!')
wangcai = doggy('Wangcai Masarchik', 17... |
# 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 |
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"?') |
#
# 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 |
'''
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 ... |
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.
""" |
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 ... |
# 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
... |
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... |
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 =... |
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)
... |
class EmptyRainfallError(ValueError):
pass
class EmptyWaterlevelError(ValueError):
pass
class NoMethodError(ValueError):
pass | class Emptyrainfallerror(ValueError):
pass
class Emptywaterlevelerror(ValueError):
pass
class Nomethoderror(ValueError):
pass |
# 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 |
#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) ... |
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... |
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() |
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 |
#
# 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) ... |
{
"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 ... |
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 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)] |
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'}}}} |
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 |
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... |
{
"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' |
#!/usr/bin/env python3
names = ['Alice', 'Bob', 'John']
for name in names:
print(name)
| names = ['Alice', 'Bob', 'John']
for name in names:
print(name) |
# pylint: disable=too-many-instance-attributes
# number of attributes is reasonable in this case
class Skills:
def __init__(self):
self.acrobatics = Skill()
self.animal_handling = Skill()
self.arcana = Skill()
self.athletics = Skill()
self.deception = Skill()
self.h... | class Skills:
def __init__(self):
self.acrobatics = skill()
self.animal_handling = skill()
self.arcana = skill()
self.athletics = skill()
self.deception = skill()
self.history = skill()
self.insight = skill()
self.intimidation = skill()
self.i... |
class TestResult:
def __init__(self, test_case) -> None:
self.__test_case = test_case
self.__failed = False
self.__reason = None
def record_failure(self, reason: str):
self.__reason = reason
self.__failed = True
def test_case(self) -> str:
return type(self._... | class Testresult:
def __init__(self, test_case) -> None:
self.__test_case = test_case
self.__failed = False
self.__reason = None
def record_failure(self, reason: str):
self.__reason = reason
self.__failed = True
def test_case(self) -> str:
return type(self.... |
#!/usr/bin/python
#-*-coding:utf-8-*-
'''This packge contains the UCT algorithem of the UAV searching.
The algorithem conform to the standard OperateInterface defined
in the PlatForm class.'''
__all__ = ['UCTControl', 'UCTSearchTree', 'UCTTreeNode']
| """This packge contains the UCT algorithem of the UAV searching.
The algorithem conform to the standard OperateInterface defined
in the PlatForm class."""
__all__ = ['UCTControl', 'UCTSearchTree', 'UCTTreeNode'] |
# --- Starting python tests ---
#Funct
def functione(x,y):
return x*y
# call
print(format(functione(2,3))) | def functione(x, y):
return x * y
print(format(functione(2, 3))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.