content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
dtypes = {
'float32': 'float',
'float64': 'double',
'complex64': 'complex_float',
'complex128': 'complex_double'
}
""" Possible dptypes for spaces and c equivalents """
compatible_dtypes = { # name: (tuple of compatible dtypes)
'float32': ('float32', 'complex64'),
'float64': ('float64', 'compl... | dtypes = {'float32': 'float', 'float64': 'double', 'complex64': 'complex_float', 'complex128': 'complex_double'}
' Possible dptypes for spaces and c equivalents '
compatible_dtypes = {'float32': ('float32', 'complex64'), 'float64': ('float64', 'complex128'), 'complex64': ('complex64',), 'complex128': ('complex128',)}
'... |
# M0_C4 - Peak Volumes
def get_peak_volumes(volumes):
# Write your code here
return "not implemented"
#### DO NOT TOUCH CODE BELOW THIS LINE ####
if __name__ == '__main__':
"""This code is for manual testing and is provided for your convenience."""
test_volumes = input("Input space-separated list of v... | def get_peak_volumes(volumes):
return 'not implemented'
if __name__ == '__main__':
'This code is for manual testing and is provided for your convenience.'
test_volumes = input('Input space-separated list of volumes: ')
converted = [int(a) for a in test_volumes.split()]
print(get_peak_volumes(convert... |
#Algorithm Case Study
def naive(a,b):
x=a; y=b
z =0
while(x > 0):
z = z+y
x = x-1
return z
def testnaive():
i=0
while(i < 10):
j=0
while(j < 10):
print(i,j)
print(naive(i,j))
j += 1
i += 1
... | def naive(a, b):
x = a
y = b
z = 0
while x > 0:
z = z + y
x = x - 1
return z
def testnaive():
i = 0
while i < 10:
j = 0
while j < 10:
print(i, j)
print(naive(i, j))
j += 1
i += 1
if __name__ == '__main__':
testn... |
"""
Entradas
dia-->int
mes-->int
Salidas
singno zodiacal-->float
"""
dia = int (input ('Digite el numero de dia: '))
mes = int (input ("Digite el numero de mes: "))
if (dia>=21 and mes==3) or (dia<=20 and mes==4):
print ('Aries')
if (dia>=24 and mes==9) or (dia<=23 and mes==10):
print ('Libra')
if (dia>=21 and... | """
Entradas
dia-->int
mes-->int
Salidas
singno zodiacal-->float
"""
dia = int(input('Digite el numero de dia: '))
mes = int(input('Digite el numero de mes: '))
if dia >= 21 and mes == 3 or (dia <= 20 and mes == 4):
print('Aries')
if dia >= 24 and mes == 9 or (dia <= 23 and mes == 10):
print('Libra')
if dia >= ... |
capacity = int(input())
income = 0
command = input()
while command != "Movie time!":
group_count = int(command)
if group_count > capacity:
print("The cinema is full.")
print(f"Cinema income - {income} lv.")
exit()
capacity -= group_count
group_tax = group_count * 5
if gro... | capacity = int(input())
income = 0
command = input()
while command != 'Movie time!':
group_count = int(command)
if group_count > capacity:
print('The cinema is full.')
print(f'Cinema income - {income} lv.')
exit()
capacity -= group_count
group_tax = group_count * 5
if group_c... |
#pretty print method
def indent(elem, level=0):
i = "\n" + level*" "
j = "\n" + (level-1)*" "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
elem.tail = i
for subelem in elem:
... | def indent(elem, level=0):
i = '\n' + level * ' '
j = '\n' + (level - 1) * ' '
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + ' '
if not elem.tail or not elem.tail.strip():
elem.tail = i
for subelem in elem:
indent(sube... |
# -*- coding: utf-8 -*-
# This work is licensed under the MIT License.
# To view a copy of this license, visit https://www.gnu.org/licenses/
# Written by Taher Abbasi
# Email: abbasi.taher@gmail.com
class WrongSide(Exception):
pass | class Wrongside(Exception):
pass |
skywater_metal1 = {"layer": 68, "datatype": 20 }
skywater_metal2 = {"layer": 69, "datatype": 20 }
skywater_metal3 = {"layer": 70, "datatype": 20 }
skywater_metal4 = {"layer": 71, "datatype": 20 }
skywater_metal5 = {"layer": 72, "datatype": 20 }
| skywater_metal1 = {'layer': 68, 'datatype': 20}
skywater_metal2 = {'layer': 69, 'datatype': 20}
skywater_metal3 = {'layer': 70, 'datatype': 20}
skywater_metal4 = {'layer': 71, 'datatype': 20}
skywater_metal5 = {'layer': 72, 'datatype': 20} |
rc = 0
def setup():
size(600, 600)
smooth()
background(0)
font = loadFont("Gadugi-Bold-48.vlw")
textFont(font, 48)
def draw():
global rc
translate(width/2, height/2)
pushMatrix()
rotate(rc)
fill(255)
text("Black", mouseX - width/4, mouseY - height/4)
popMa... | rc = 0
def setup():
size(600, 600)
smooth()
background(0)
font = load_font('Gadugi-Bold-48.vlw')
text_font(font, 48)
def draw():
global rc
translate(width / 2, height / 2)
push_matrix()
rotate(rc)
fill(255)
text('Black', mouseX - width / 4, mouseY - height / 4)
pop_matr... |
"""
Hamming Numbers
URL: https://www.codewars.com/kata/526d84b98f428f14a60008da/python
A Hamming number is a positive integer of the form 2^i, 3^j, 5^k,
for some non-negative integers i, j, and k.
Write a function that computes the nth smallest Hamming number.
Specifically:
The first smallest Hamming number is 1... | """
Hamming Numbers
URL: https://www.codewars.com/kata/526d84b98f428f14a60008da/python
A Hamming number is a positive integer of the form 2^i, 3^j, 5^k,
for some non-negative integers i, j, and k.
Write a function that computes the nth smallest Hamming number.
Specifically:
The first smallest Hamming number is 1... |
class MessagesSerializer:
fields = ['id', 'topic', 'payload', 'attributes', 'bulk']
def serialize(self, messages):
return [self._serialize_fields(message) for message in messages]
def _serialize_fields(self, message):
return {field: getattr(message, field, None) for field in self.fields}
| class Messagesserializer:
fields = ['id', 'topic', 'payload', 'attributes', 'bulk']
def serialize(self, messages):
return [self._serialize_fields(message) for message in messages]
def _serialize_fields(self, message):
return {field: getattr(message, field, None) for field in self.fields} |
# -*- coding: utf-8 -*-
# @Author: Anderson
# @Date: 2018-09-01 22:04:38
# @Last Modified by: Anderson
# @Last Modified time: 2018-09-14 15:55:53
class DS(object):
def __init__(self, N):
self.__id = list(range(0, N))
def is_connected(self, parent, child):
pid = ord(parent) - ord('A')
... | class Ds(object):
def __init__(self, N):
self.__id = list(range(0, N))
def is_connected(self, parent, child):
pid = ord(parent) - ord('A')
cid = ord(child) - ord('A')
connected = False
generation_count = 0
while not connected:
generation_count += 1
... |
#
# PySNMP MIB module Juniper-IPV6-PROFILE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-IPV6-PROFILE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:03:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ... |
r'''
Copyright 2015 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to i... | """
Copyright 2015 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in... |
print("My name is Jessica Bonnie Ayomide")
print("JJJJJJJJJJJJJ BBBBBBBBBB A")
print(" J B B A A")
print(" J B B A A")
print(" J B B A A")
print(" J B B A A")
print(" J BB... | print('My name is Jessica Bonnie Ayomide')
print('JJJJJJJJJJJJJ BBBBBBBBBB A')
print(' J B B A A')
print(' J B B A A')
print(' J B B A A')
print(' J B B A A')
print(' J BBBBBBBB... |
#!/usr/bin/env python3
def main():
arr = []
fname = sys.argv[1]
with open(fname, 'r') as f:
for line in f:
arr.append(int(line.rstrip('\r\n')))
quicksort(arr, start=0, end=len(arr)-1)
print('Sorted list is: ', arr)
return
def quicksort(arr, start, end):
if end - start <... | def main():
arr = []
fname = sys.argv[1]
with open(fname, 'r') as f:
for line in f:
arr.append(int(line.rstrip('\r\n')))
quicksort(arr, start=0, end=len(arr) - 1)
print('Sorted list is: ', arr)
return
def quicksort(arr, start, end):
if end - start < 1:
return 0
... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"test_eq": "00_core.ipynb",
"listify": "00_core.ipynb",
"test_in": "00_core.ipynb",
"test_err": "00_core.ipynb",
"configure_logging": "00_core.ipynb",
"setup_dataf... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'test_eq': '00_core.ipynb', 'listify': '00_core.ipynb', 'test_in': '00_core.ipynb', 'test_err': '00_core.ipynb', 'configure_logging': '00_core.ipynb', 'setup_dataframe_copy_logging': '00_core.ipynb', 'n_total_series': '00_core.ipynb', 'n_days_total'... |
# -*- coding: utf-8 -*-
"""@package Methods.Machine.SlotWind.comp_surface_wind
Slot Winding Computation of surface (Numerical) method
@date Created on Wed Jul 25 14:22:33 2018
@copyright (C) 2014-2015 EOMYS ENGINEERING.
@author pierre_b
"""
def comp_surface_wind(self):
"""Compute the Slot winding surface (by nume... | """@package Methods.Machine.SlotWind.comp_surface_wind
Slot Winding Computation of surface (Numerical) method
@date Created on Wed Jul 25 14:22:33 2018
@copyright (C) 2014-2015 EOMYS ENGINEERING.
@author pierre_b
"""
def comp_surface_wind(self):
"""Compute the Slot winding surface (by numerical computation).
C... |
# code
'''python'''
class Solution(object):
def lengthOfLastWord(self, s):
self.s=s
string = self.s.strip().split(' ')[-1]
return len(string)
| """python"""
class Solution(object):
def length_of_last_word(self, s):
self.s = s
string = self.s.strip().split(' ')[-1]
return len(string) |
def clean_sentence(output, data_loader):
start_word = data_loader.dataset.vocab.start_word
end_word = data_loader.dataset.vocab.end_word
unk_word = data_loader.dataset.vocab.unk_word
words = []
for i in range(len(output)):
word_idx = output[i]
word = data_loader.dataset.vocab.idx2wo... | def clean_sentence(output, data_loader):
start_word = data_loader.dataset.vocab.start_word
end_word = data_loader.dataset.vocab.end_word
unk_word = data_loader.dataset.vocab.unk_word
words = []
for i in range(len(output)):
word_idx = output[i]
word = data_loader.dataset.vocab.idx2wor... |
#
# PySNMP MIB module TPLINK-SSH-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPLINK-SSH-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:25:53 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_union, constraints_intersection, single_value_constraint) ... |
REGULAR_MARGIN_REQUIREMENT = 0.25
LEVERAGED_MARGIN_REQUIREMENT = 0.75
def max_margin(leveraged_value, regular_value, percentage_of_leveraged_drop,
percentage_of_regular_drop, current_loan):
leveraged_value_after_drop = leveraged_value * (1 - percentage_of_leveraged_drop)
regular_value_after_dro... | regular_margin_requirement = 0.25
leveraged_margin_requirement = 0.75
def max_margin(leveraged_value, regular_value, percentage_of_leveraged_drop, percentage_of_regular_drop, current_loan):
leveraged_value_after_drop = leveraged_value * (1 - percentage_of_leveraged_drop)
regular_value_after_drop = regular_valu... |
class Solution:
def __init__(self):
pass
# o(mn)
def print_lcs(self, str1, str2):
m = len(str1)
n = len(str2)
if n == 0 or m == 0:
return 0
# declare an two dimension array store calculated dp value of lcs(str1[i]
R = [[None] * (n + 1) for i in xr... | class Solution:
def __init__(self):
pass
def print_lcs(self, str1, str2):
m = len(str1)
n = len(str2)
if n == 0 or m == 0:
return 0
r = [[None] * (n + 1) for i in xrange(m + 1)]
for i in range(m + 1):
for j in range(n + 1):
... |
lines = None
with open('day07/input.txt') as f:
lines = f.readlines()
line = lines[0]
arr = list(map(lambda s: int(s), line.split(",")))
cost = []
prev = 0
q = 0
for i in range(2000):
cost.append(prev + q)
prev = prev + q
q += 1
min = 99999999999999
for pos in range(1500):
sum = 0
for x in ar... | lines = None
with open('day07/input.txt') as f:
lines = f.readlines()
line = lines[0]
arr = list(map(lambda s: int(s), line.split(',')))
cost = []
prev = 0
q = 0
for i in range(2000):
cost.append(prev + q)
prev = prev + q
q += 1
min = 99999999999999
for pos in range(1500):
sum = 0
for x in arr:
... |
target = "xilinx"
action = "synthesis"
syn_device = "xc7k325t"
syn_grade = "-2"
syn_package = "ffg900"
syn_top = "cm0_busy_wait_top"
syn_project = "cm0_busy_wait_top"
syn_tool = "vivado"
modules = {
"local" : [ "../../../top/kc705_busy_wait/verilog" ],
}
| target = 'xilinx'
action = 'synthesis'
syn_device = 'xc7k325t'
syn_grade = '-2'
syn_package = 'ffg900'
syn_top = 'cm0_busy_wait_top'
syn_project = 'cm0_busy_wait_top'
syn_tool = 'vivado'
modules = {'local': ['../../../top/kc705_busy_wait/verilog']} |
class DataObject:
def __init__(self, read_data=True):
if read_data:
self._run_methods('read')
self._run_methods('parse')
def _run_methods(self, method_type):
for method in [m for m in dir(self) if m.startswith('_{}_'.format(method_type))]:
getattr(self, me... | class Dataobject:
def __init__(self, read_data=True):
if read_data:
self._run_methods('read')
self._run_methods('parse')
def _run_methods(self, method_type):
for method in [m for m in dir(self) if m.startswith('_{}_'.format(method_type))]:
getattr(self, meth... |
def sumUpNumbers(inputString):
numbers = []
curr = ""
for i in inputString:
try:
x = int(i)
curr += i
except:
if curr != "":
numbers.append(curr)
curr = ""
if curr != "":
numbers.append(curr)
return sum([in... | def sum_up_numbers(inputString):
numbers = []
curr = ''
for i in inputString:
try:
x = int(i)
curr += i
except:
if curr != '':
numbers.append(curr)
curr = ''
if curr != '':
numbers.append(curr)
return sum([in... |
#!/usr/bin/python3
def recsum(n): return n if n<=1 else n+recsum(n-1)
n = int(input("Enter your number\t"))
if n < 0:
print("Enter a positive number")
else:
print("The sum is",recsum(n)) | def recsum(n):
return n if n <= 1 else n + recsum(n - 1)
n = int(input('Enter your number\t'))
if n < 0:
print('Enter a positive number')
else:
print('The sum is', recsum(n)) |
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
d = {}
left = -1
right = 0
max = 0
if len(s) < 2:
return len(s)
while right < len(s)-1:
d[s[right]] = right
... | class Solution(object):
def length_of_longest_substring(self, s):
"""
:type s: str
:rtype: int
"""
d = {}
left = -1
right = 0
max = 0
if len(s) < 2:
return len(s)
while right < len(s) - 1:
d[s[right]] = right
... |
# -*- coding: utf-8 -*-
"""
@Datetime: 2019/1/2
@Author: Zhang Yafei
"""
| """
@Datetime: 2019/1/2
@Author: Zhang Yafei
""" |
raio = float(input())
pi = 3.14159
VOLUME = (4 / 3) * pi * (raio**3)
print("VOLUME = {:.3f}".format(VOLUME))
| raio = float(input())
pi = 3.14159
volume = 4 / 3 * pi * raio ** 3
print('VOLUME = {:.3f}'.format(VOLUME)) |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: proto
class AuthMethod(object):
ANONYMOUS = 0
COOKIE = 1
TLS = 2
TICKET = 3
CRA = 4
SCRAM = 5
CRYPTOSIGN = 6
| class Authmethod(object):
anonymous = 0
cookie = 1
tls = 2
ticket = 3
cra = 4
scram = 5
cryptosign = 6 |
# Copyright 2015 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.
class BaseError(Exception):
"""Base error for all test runner errors."""
def __init__(self, message, is_infra_error=False):
super(BaseError, self).... | class Baseerror(Exception):
"""Base error for all test runner errors."""
def __init__(self, message, is_infra_error=False):
super(BaseError, self).__init__(message)
self._is_infra_error = is_infra_error
def __eq__(self, other):
return self.message == other.message and self.is_infra... |
def for_e():
for row in range(6):
for col in range(4):
if row==2 or row==1 and col%3!=0 or row==4 and col>0 or col==0 and row==3:
print("*",end=" ")
else:
print(" ",end=" ")
print()
def while_e():
row=0
while row<6:
... | def for_e():
for row in range(6):
for col in range(4):
if row == 2 or (row == 1 and col % 3 != 0) or (row == 4 and col > 0) or (col == 0 and row == 3):
print('*', end=' ')
else:
print(' ', end=' ')
print()
def while_e():
row = 0
while ... |
"""
Copyright 2017 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... | """
Copyright 2017 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... |
def selection_sort(elements):
for i in range(len(elements) - 1):
min_index = i
for j in range(i + 1, len(elements)):
if elements[min_index] > elements[j]:
min_index = j
elements[i], elements[min_index] = elements[min_index], elements[i]
return elements
ele =... | def selection_sort(elements):
for i in range(len(elements) - 1):
min_index = i
for j in range(i + 1, len(elements)):
if elements[min_index] > elements[j]:
min_index = j
(elements[i], elements[min_index]) = (elements[min_index], elements[i])
return elements
ele... |
tab = 1
while tab <= 10:
print("Tabuada do", tab, ":", end="\t")
i = 1
while i <= 10:
print(tab*i, end = "\t")
i = i + 1
print()
tab = tab + 1 | tab = 1
while tab <= 10:
print('Tabuada do', tab, ':', end='\t')
i = 1
while i <= 10:
print(tab * i, end='\t')
i = i + 1
print()
tab = tab + 1 |
load("@bazel_skylib//lib:shell.bzl", "shell")
def kubebuilder_manifests(name, srcs, config_root, **kwargs):
native.genrule(
name = name,
srcs = srcs,
outs = [name + ".yaml"],
cmd = """
tmp=$$(mktemp --directory)
cp -aL "%s/." "$$tmp"
$(location @io_k8s_sigs_kustomize_kustomize_v4//:... | load('@bazel_skylib//lib:shell.bzl', 'shell')
def kubebuilder_manifests(name, srcs, config_root, **kwargs):
native.genrule(name=name, srcs=srcs, outs=[name + '.yaml'], cmd='\ntmp=$$(mktemp --directory)\ncp -aL "%s/." "$$tmp"\n$(location @io_k8s_sigs_kustomize_kustomize_v4//:v4) build "$$tmp/default" > $@\nrm -r "$... |
def chk_p5m(n):
if n%5==0: return 0
elif n==1: return n
for i in range(2,n):
if n%i==0:
return n
return 0
def fab(n):
f=[0,1]
return [chk_p5m((f:=[f[-1],f[-1]+f[-2]])[0]) for i in range(n)]
#i know it's little confusing most won't understand... but tried to do somethin... | def chk_p5m(n):
if n % 5 == 0:
return 0
elif n == 1:
return n
for i in range(2, n):
if n % i == 0:
return n
return 0
def fab(n):
f = [0, 1]
return [chk_p5m((f := [f[-1], f[-1] + f[-2]])[0]) for i in range(n)]
print(*fab(int(input()))) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Environment Base Class
__author__: Conor Heins, Alexander Tschantz, Brennan Klein
"""
class Env(object):
def reset(self, state=None):
raise NotImplementedError
def step(self, action):
raise NotImplementedError
def render(self):
... | """ Environment Base Class
__author__: Conor Heins, Alexander Tschantz, Brennan Klein
"""
class Env(object):
def reset(self, state=None):
raise NotImplementedError
def step(self, action):
raise NotImplementedError
def render(self):
pass
def sample_action(self):
pas... |
class Solution:
def largestValsFromLabels(self, values, labels, num_wanted, use_limit):
zipped = list(zip(values, labels))
_dict = {x: 0 for x in set(labels)}
ans = 0
for v, l in reversed(sorted(zipped)):
if num_wanted == 0:
return ans
if _dic... | class Solution:
def largest_vals_from_labels(self, values, labels, num_wanted, use_limit):
zipped = list(zip(values, labels))
_dict = {x: 0 for x in set(labels)}
ans = 0
for (v, l) in reversed(sorted(zipped)):
if num_wanted == 0:
return ans
if... |
"""
Package contains:
Database Class
Decoder Class
Cleaner Class
MyHTMLParser Class
""" | """
Package contains:
Database Class
Decoder Class
Cleaner Class
MyHTMLParser Class
""" |
class Human():
sum = 0
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
print(self.name)
def do_homework(self):
print('parent method') | class Human:
sum = 0
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
print(self.name)
def do_homework(self):
print('parent method') |
d = {
"no": "yes"
}
class CustomError:
def __init__(self, fun):
self.fun = fun
def __call__(self, *args, **kwargs):
try:
return self.fun(*args, **kwargs)
except Exception as e:
print(e)
raise Exception(d.get(str(e)))
@CustomError
def a():
... | d = {'no': 'yes'}
class Customerror:
def __init__(self, fun):
self.fun = fun
def __call__(self, *args, **kwargs):
try:
return self.fun(*args, **kwargs)
except Exception as e:
print(e)
raise exception(d.get(str(e)))
@CustomError
def a():
raise e... |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Documentation',
'category': 'Website',
'summary': 'Forum, Documentation',
'description': """
Documentation based on question and pertinent answers of Forum
""",
'depends': [
... | {'name': 'Documentation', 'category': 'Website', 'summary': 'Forum, Documentation', 'description': '\nDocumentation based on question and pertinent answers of Forum\n ', 'depends': ['website_forum'], 'data': ['data/doc_data.xml', 'security/ir.model.access.csv', 'views/doc.xml', 'views/website_doc.xml'], 'demo': ... |
# Databricks notebook source
# MAGIC %md
# MAGIC <img src="https://github.com/billkellett/flight-school-resources/blob/master/images/databricks icon.png?raw=true" width=100/>
# MAGIC <img src="/files/flight/Megacorp.png?raw=true" width=200/>
# MAGIC # Democratizing MegaCorp's Data
# MAGIC
# MAGIC ## MegaCorp's current... | dbutils.widgets.text('team_name', "Enter your team's name")
team_name = dbutils.widgets.get('team_name')
setup_responses = dbutils.notebook.run('./includes/flight_school_assignment_1_setup', 0, {'team_name': team_name}).split()
local_data_path = setup_responses[0]
dbfs_data_path = setup_responses[1]
database_name = set... |
# binary search
def binary(srchlist,srch):
"""list needs to be in ascending order to search for element"""
first = 0
last = len(srchlist)-1
while first <= last:
mid = (first + last)/2
if srch > srchlist[mid]:
first = mid+1
elif srch < srchlist[mid]:
last = mid-1
else:
return mid
return -1
| def binary(srchlist, srch):
"""list needs to be in ascending order to search for element"""
first = 0
last = len(srchlist) - 1
while first <= last:
mid = (first + last) / 2
if srch > srchlist[mid]:
first = mid + 1
elif srch < srchlist[mid]:
last = mid - 1
... |
#Longest Collatz Sequence
#Solving for Project Euler.Net Problem 14.
#Given n -> n/2 (n is even)
# n -> 3n + 1 (n is odd)
#
#Which starting number, under one million, produces the longest chain?
#
#By Alex Murshak
def collatz(n):
count = 0
while n>1:
if n%2==0:
n= n/2
else: ... | def collatz(n):
count = 0
while n > 1:
if n % 2 == 0:
n = n / 2
else:
n = 3 * n + 1
count += 1
return count
c_large = 0
i_large = 0
for i in range(1, 1000000, 1):
c = collatz(i)
if C > C_large:
c_large = C
i_large = i
print(I_large) |
class Solution:
def romanToInt(self, s: str) -> int:
translations = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
"C": 100,
"D": 500,
"M": 1000
}
number = 0
s = s.replace("IV", "IIII").replace("IX", "V... | class Solution:
def roman_to_int(self, s: str) -> int:
translations = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
number = 0
s = s.replace('IV', 'IIII').replace('IX', 'VIIII')
s = s.replace('XL', 'XXXX').replace('XC', 'LXXXX')
s = s.replace('CD', 'CCCC'... |
budget = float(input())
price_1kg_flour = float(input())
colored_eggs = 0
price_1pack_eggs = price_1kg_flour * 0.75
price_250ml_milk = (price_1kg_flour + (price_1kg_flour * 0.25)) / 4
price_1_bread = price_1pack_eggs + price_1kg_flour + price_250ml_milk
count_breads = int(budget // price_1_bread)
for current_bread... | budget = float(input())
price_1kg_flour = float(input())
colored_eggs = 0
price_1pack_eggs = price_1kg_flour * 0.75
price_250ml_milk = (price_1kg_flour + price_1kg_flour * 0.25) / 4
price_1_bread = price_1pack_eggs + price_1kg_flour + price_250ml_milk
count_breads = int(budget // price_1_bread)
for current_bread in ran... |
def min_value(gameState):
""" Return the game state utility if the game is over,
otherwise return the minimum value over all legal successors
# HINT: Assume that the utility is ALWAYS calculated for
player 1, NOT for the "active" player
"""
# TODO: finish this function!
if gam... | def min_value(gameState):
""" Return the game state utility if the game is over,
otherwise return the minimum value over all legal successors
# HINT: Assume that the utility is ALWAYS calculated for
player 1, NOT for the "active" player
"""
if gameState.terminal_test():
retu... |
#!/usr/bin/env python3
"""
Exercise 20: Word Count
Mimic the Un*x "wc" command to count lines, words, and characters.
"""
def wc(filename):
lines = 0
words = 0
characters = 0
distinct_words = set()
with open(filename) as f:
for line in f:
lines += 1
wor... | """
Exercise 20: Word Count
Mimic the Un*x "wc" command to count lines, words, and characters.
"""
def wc(filename):
lines = 0
words = 0
characters = 0
distinct_words = set()
with open(filename) as f:
for line in f:
lines += 1
words += len(line.split())
... |
# O(n) time | O(h) space - where n is the number of nodes in the Binary Tree
# and h is the height of the Binary Tree
def nodeDepths(root, depth = 0):
if root is None:
return 0
return depth + nodeDepths(root.left, depth + 1) + nodeDepths(root.right, depth + 1)
# This is the class of the input binary tree.
clas... | def node_depths(root, depth=0):
if root is None:
return 0
return depth + node_depths(root.left, depth + 1) + node_depths(root.right, depth + 1)
class Binarytree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None |
class KeySpline(Freezable,ISealable,IFormattable):
"""
This class is used by a spline key frame to define animation progress.
KeySpline(controlPoint1: Point,controlPoint2: Point)
KeySpline()
KeySpline(x1: float,y1: float,x2: float,y2: float)
"""
def CloneCore(self,*args):
"""
CloneCore(se... | class Keyspline(Freezable, ISealable, IFormattable):
"""
This class is used by a spline key frame to define animation progress.
KeySpline(controlPoint1: Point,controlPoint2: Point)
KeySpline()
KeySpline(x1: float,y1: float,x2: float,y2: float)
"""
def clone_core(self, *args):
"""
CloneCore... |
# Lesson 1 - Hello world and entry points
#
# All languages have an "entry point"
# An entry point is where the program begins execution
# "Main" is a common keyword used to specify the entry point
#
# Common C style entry points:
# int main()
# {
# return 0;
# }
# or
# void main()
# {
# }
# Hello World is a common ... | def hello_world():
print('Hello World')
if __name__ == '__main__':
hello_world() |
PASSWD = '12345'
def password_required(func):
def wrapper():
password = input('Cual es el passwd ? ')
if password == PASSWD:
return func()
else:
print('error')
return wrapper
def p_decorate(func):
def func_wrapper(name):
return "<p>{0}</p>".format(fu... | passwd = '12345'
def password_required(func):
def wrapper():
password = input('Cual es el passwd ? ')
if password == PASSWD:
return func()
else:
print('error')
return wrapper
def p_decorate(func):
def func_wrapper(name):
return '<p>{0}</p>'.format... |
def euclid(n, m):
if n > m:
r = m
m = n
n = r
r = m % n
while r != 0:
m = n
n = r
r = m % n
return n
| def euclid(n, m):
if n > m:
r = m
m = n
n = r
r = m % n
while r != 0:
m = n
n = r
r = m % n
return n |
"""Loads the gflags library"""
# Sanitize a dependency so that it works correctly from code that includes
# Apollo as a submodule.
def clean_dep(dep):
return str(Label(dep))
def repo():
# gflags
native.new_local_repository(
name = "com_github_gflags_gflags",
build_file = clean_dep("//third... | """Loads the gflags library"""
def clean_dep(dep):
return str(label(dep))
def repo():
native.new_local_repository(name='com_github_gflags_gflags', build_file=clean_dep('//third_party/gflags:gflags.BUILD'), path='/usr/local/include/gflags') |
def bisection_search(arr: list, n: int) -> bool:
mid = len(arr) // 2
if len(arr) < 2:
if arr[mid] == n:
return True
else:
return False
else:
if arr[mid] == n:
return True
else:
return bisection_search(arr[:mid], n) if arr[mid] >... | def bisection_search(arr: list, n: int) -> bool:
mid = len(arr) // 2
if len(arr) < 2:
if arr[mid] == n:
return True
else:
return False
elif arr[mid] == n:
return True
else:
return bisection_search(arr[:mid], n) if arr[mid] > n else bisection_search... |
l1 = int(input('Digite o lado 1 '))
l2 = int(input('Digite o lado 2 '))
l3 = int(input('Digite o lado 3 '))
if l1+l2>l3 and l1+l3>l2 and l2+l3>l1:
print(f'O triangulo PODE ser formado')
else:
print(f'O triangulo NAO PODE ser formado') | l1 = int(input('Digite o lado 1 '))
l2 = int(input('Digite o lado 2 '))
l3 = int(input('Digite o lado 3 '))
if l1 + l2 > l3 and l1 + l3 > l2 and (l2 + l3 > l1):
print(f'O triangulo PODE ser formado')
else:
print(f'O triangulo NAO PODE ser formado') |
'''
02 - Creating two-factor
Let's continue looking at the student_data dataset of students
in secondary school. Here, we want to answer the following question:
does a student's first semester grade ("G1") tend to correlate with
their final grade ("G3")?
There are many aspects of a student's life that could ... | """
02 - Creating two-factor
Let's continue looking at the student_data dataset of students
in secondary school. Here, we want to answer the following question:
does a student's first semester grade ("G1") tend to correlate with
their final grade ("G3")?
There are many aspects of a student's life that could ... |
def f(i):
return i + 2
def g(i):
return i > 1000
def applyF_filterG(L, f, g):
"""
Assumes L is a list of integers
Assume functions f and g are defined for you.
f takes in an integer, applies a function, returns another integer
g takes in an integer, applies a Boolean function... | def f(i):
return i + 2
def g(i):
return i > 1000
def apply_f_filter_g(L, f, g):
"""
Assumes L is a list of integers
Assume functions f and g are defined for you.
f takes in an integer, applies a function, returns another integer
g takes in an integer, applies a Boolean function,
... |
#
# PySNMP MIB module CISCO-VOICE-DNIS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-VOICE-DNIS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:03:03 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, single_value_constraint, value_size_constraint, value_range_constraint) ... |
"""
oops
"""
print(0, 1 == 1, 0)
| """
oops
"""
print(0, 1 == 1, 0) |
# acronymsBuilder.py
# A program to build acronyms from a phrase
# by Tung Nguyen
def main():
# declare program function:
print("This program builds acronyms.")
print()
# prompt user to input the sentence:
sentence = input("Enter a phrase: ")
# split the sentence into a list that con... | def main():
print('This program builds acronyms.')
print()
sentence = input('Enter a phrase: ')
list_word = sentence.split()
acronym = ''
for x in listWord:
acronym += x[0].upper()
print('The acronym is ' + acronym)
main() |
# x y x y
#r1 = [[0, 0], [5, 5]]
r1 = [[-5, -5], [-2, -2]]
r2 = [[7, 1], [1, 8]]
r3 = [[-1.2, 4], [3.7, 1.1]]
def rect_intersection_area(r1, r2, r3):
area = 0
r1_p1, r1_p2 = r1
r2_p1, r2_p2 = r2
r3_p1, r3_p2 = r3
right_x_p = 0
left_x_p = 0
top_y_p ... | r1 = [[-5, -5], [-2, -2]]
r2 = [[7, 1], [1, 8]]
r3 = [[-1.2, 4], [3.7, 1.1]]
def rect_intersection_area(r1, r2, r3):
area = 0
(r1_p1, r1_p2) = r1
(r2_p1, r2_p2) = r2
(r3_p1, r3_p2) = r3
right_x_p = 0
left_x_p = 0
top_y_p = 0
bottom_y_p = 0
left_x_p = max(min(r2_p1[0], r2_p2[0]), min... |
# https://atcoder.jp/contests/abs/tasks/practice_1
def resolve():
a = int(input())
b, c = list(map(int, input().split()))
d = input()
print("{} {}".format(a + b + c, d))
| def resolve():
a = int(input())
(b, c) = list(map(int, input().split()))
d = input()
print('{} {}'.format(a + b + c, d)) |
class IpConfiguration:
options: object
def __init__(self, options):
self.options = options
| class Ipconfiguration:
options: object
def __init__(self, options):
self.options = options |
#!/usr/bin/env python3
# Compares two lexicon files providing several stats
# @author Cristian TG
# @since 2021/04/15
# Please change the value of these variables:
LEXICON_1 = 'lexicon1.txt'
LEXICON_2 = 'lexicon2.txt'
SHOW_DETAILS = True
DISAMBIGUATION_SYMBOL = '#'
#################################################... | lexicon_1 = 'lexicon1.txt'
lexicon_2 = 'lexicon2.txt'
show_details = True
disambiguation_symbol = '#'
def get_lexicon(lexicon, path):
with open(path) as lexi:
for line in lexi:
aux = line.split('\t')
lexicon[aux[0]] = aux[1].replace('\n', '').split(' ')
return lexicon
def get_w... |
def three_word(a, b, c):
title = a
if title == '\"\"':
title = "\'\'"
else:
title = "\'{0}\'".format(title)
tag = b
if tag == '\"\"':
tag = "\'\'"
else:
tag = "\'{0}\'".format(tag)
description = c
if description == '\"\"':
description = "\'\'"
... | def three_word(a, b, c):
title = a
if title == '""':
title = "''"
else:
title = "'{0}'".format(title)
tag = b
if tag == '""':
tag = "''"
else:
tag = "'{0}'".format(tag)
description = c
if description == '""':
description = "''"
else:
de... |
# [Skill] Cygnus Constellation (20899)
echo = 10001005
cygnusConstellation = 1142597
cygnus = 1101000
if sm.canHold(cygnusConstellation):
sm.setSpeakerID(cygnus)
sm.sendNext("You have exceeded all our expectations. Please take this as a symbol of your heroism.\r\n"
"#s" + str(echo) + "# #q" + str(echo) +... | echo = 10001005
cygnus_constellation = 1142597
cygnus = 1101000
if sm.canHold(cygnusConstellation):
sm.setSpeakerID(cygnus)
sm.sendNext('You have exceeded all our expectations. Please take this as a symbol of your heroism.\r\n#s' + str(echo) + '# #q' + str(echo) + '#\r\n#i' + str(cygnusConstellation) + '# #z' +... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
ans = str(int(self.combine(l1)) + int(self.combine(l2)))
return self... | class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
ans = str(int(self.combine(l1)) + int(self.combine(l2)))
return self.separate(ans, len(ans) - 1)
def combine(self, lst):
if lst.next:
return self.combine(lst.next) + str(lst.val)
else... |
def http_exception(response):
raise HTTPException(response)
class HTTPException(Exception):
def __init__(self, response):
self._response = response
def __str__(self):
return self._response.message
@property
def is_redirect(self):
return self._response.is_redirect
@p... | def http_exception(response):
raise http_exception(response)
class Httpexception(Exception):
def __init__(self, response):
self._response = response
def __str__(self):
return self._response.message
@property
def is_redirect(self):
return self._response.is_redirect
@p... |
coins = [
100,
50,
25,
5,
1
]
total = 0
change = 130
for i in range(len(coins)):
numCoins = change // coins[i]
change -= numCoins * coins[i]
total += numCoins
print(total)
'''
numCoins = 75 // 100 = 0
change = change - 0 * 100
change = change
''' | coins = [100, 50, 25, 5, 1]
total = 0
change = 130
for i in range(len(coins)):
num_coins = change // coins[i]
change -= numCoins * coins[i]
total += numCoins
print(total)
'\nnumCoins = 75 // 100 = 0\nchange = change - 0 * 100\nchange = change \n' |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
DELIMITER = "\r\n"
def encode(*args):
"Pack a series of arguments into a value Redis command"
result = []
result.append("*")
result.append(str(len(args)))
result.append(DELIMITER)
for arg in args:
result.append("$")
result.append(st... | delimiter = '\r\n'
def encode(*args):
"""Pack a series of arguments into a value Redis command"""
result = []
result.append('*')
result.append(str(len(args)))
result.append(DELIMITER)
for arg in args:
result.append('$')
result.append(str(len(arg)))
result.append(DELIMITE... |
#print hello with arguments
def hello(name):
print('hello ' + name)
hello('bob')
hello('alice')
| def hello(name):
print('hello ' + name)
hello('bob')
hello('alice') |
n = int(input())
gerais = [e for e in input().split()]
m = int(input())
proib = [e for e in input().split()]
q = int(input())
arr = [e for e in input().split()]
for i in range(q):
key = arr[i]
esq = 0
dir = m-1
achou = False
while esq <= dir:
meio = (esq + dir) // 2
if proi... | n = int(input())
gerais = [e for e in input().split()]
m = int(input())
proib = [e for e in input().split()]
q = int(input())
arr = [e for e in input().split()]
for i in range(q):
key = arr[i]
esq = 0
dir = m - 1
achou = False
while esq <= dir:
meio = (esq + dir) // 2
if proib[meio] ... |
n = int(input())
calculadora = 1
for i in range(n):
valor, operacao = input().split()
valor = int(valor)
if(operacao == '/'):
calculadora = calculadora / valor
else:
calculadora = calculadora * valor
print("{0:.0f}".format(calculadora)) | n = int(input())
calculadora = 1
for i in range(n):
(valor, operacao) = input().split()
valor = int(valor)
if operacao == '/':
calculadora = calculadora / valor
else:
calculadora = calculadora * valor
print('{0:.0f}'.format(calculadora)) |
BEHIND_PROXY = True
SWAGGER_BASEPATH = ""
DEFAULT_DATABASE = "dev"
DATABASES = ["test"]
ENV = "development"
DEBUG = True
| behind_proxy = True
swagger_basepath = ''
default_database = 'dev'
databases = ['test']
env = 'development'
debug = True |
class Solution:
def findMaxValueOfEquation(self, points: List[List[int]], k: int) -> int:
ans = -math.inf
maxHeap = [] # (y - x, x)
for x, y in points:
while maxHeap and x + maxHeap[0][1] > k:
heapq.heappop(maxHeap)
if maxHeap:
ans = max(ans, x + y - maxHeap[0][0])
heap... | class Solution:
def find_max_value_of_equation(self, points: List[List[int]], k: int) -> int:
ans = -math.inf
max_heap = []
for (x, y) in points:
while maxHeap and x + maxHeap[0][1] > k:
heapq.heappop(maxHeap)
if maxHeap:
ans = max(ans... |
class Feature:
def __init__(self, value, string, infix_string, size=0, fitness=1, original_variable=False):
self.value = value
self.fitness = fitness
self.string = string
self.infix_string = infix_string
self.size = size
self.original_variable = original_variable
... | class Feature:
def __init__(self, value, string, infix_string, size=0, fitness=1, original_variable=False):
self.value = value
self.fitness = fitness
self.string = string
self.infix_string = infix_string
self.size = size
self.original_variable = original_variable
... |
def my_range(n):
i = 0
while i <= n:
yield i
i += 1
yield 'there are no values left'
gen = my_range(4)
for i in range(7):
print(next(gen))
| def my_range(n):
i = 0
while i <= n:
yield i
i += 1
yield 'there are no values left'
gen = my_range(4)
for i in range(7):
print(next(gen)) |
"""
pattern_stringHEAD_stringTAIL_list( "brianxxxcvbpythonvvvvvvvvvgghhbrianpppfgpython","brian","python") returns ["xxxcvb","pppfg"]
pattern_stringHEAD_stringTAIL_list( "susanvenezuelastronggghhsusancanadastrong","susan","strong") returns ["venezuela","canada"]
pattern_stringHEAD_stringTAIL_list( "boatxvmotorvvvmotorv... | """
pattern_stringHEAD_stringTAIL_list( "brianxxxcvbpythonvvvvvvvvvgghhbrianpppfgpython","brian","python") returns ["xxxcvb","pppfg"]
pattern_stringHEAD_stringTAIL_list( "susanvenezuelastronggghhsusancanadastrong","susan","strong") returns ["venezuela","canada"]
pattern_stringHEAD_stringTAIL_list( "boatxvmotorvvvmotorv... |
def merge_values(original: dict, new_values: dict):
"""
if a value in a dictionary is also
a dictionary we want to keep the old
information inside it
"""
for key, value in new_values.items():
if isinstance(value, dict):
original[key] = merge_values(original.get(key, dict()), value)
else:
origi... | def merge_values(original: dict, new_values: dict):
"""
if a value in a dictionary is also
a dictionary we want to keep the old
information inside it
"""
for (key, value) in new_values.items():
if isinstance(value, dict):
original[key] = merge_values(original.get(key, dict()), value)
... |
# Advent of code Year 2021 Day 02 solution
# Author = Anmol Gupta
# Date = December 2021
input = list()
with open("input.txt", "r") as input_file:
input = input_file.readlines()
def get_command(line):
splitInput = line.strip().split()
return (splitInput[0], int(splitInput[1]))
input_commands = [get_com... | input = list()
with open('input.txt', 'r') as input_file:
input = input_file.readlines()
def get_command(line):
split_input = line.strip().split()
return (splitInput[0], int(splitInput[1]))
input_commands = [get_command(line) for line in input]
horizontal_position = 0
depth = 0
for (action, magnitude) in i... |
class nullcontext:
""" A replacement for `contextlib.nullcontext` for python versions before 3.7
"""
def __enter__(self):
pass
def __exit__(self, exc_type, exc_val, exc_tb):
pass
| class Nullcontext:
""" A replacement for `contextlib.nullcontext` for python versions before 3.7
"""
def __enter__(self):
pass
def __exit__(self, exc_type, exc_val, exc_tb):
pass |
{
'targets':
[
{
'target_name': 'node_libtiepie',
'sources':
[
'src/libtiepie.cc'
],
'include_dirs':
[
'<!(node -e "require(\'nan\')")'
],
'conditions':
[
[
'OS=="linux"',
{
'libraries': ['-ltiepie']
... | {'targets': [{'target_name': 'node_libtiepie', 'sources': ['src/libtiepie.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'conditions': [['OS=="linux"', {'libraries': ['-ltiepie']}], ['OS=="win"', {'sources': ['src/libtiepieloader.cc'], 'defines': ['LIBTIEPIE_DYNAMIC'], 'include_dirs': ['<(module_root_dir)/de... |
def typist(s):
cur=res=0
for i in s:
next_val=int(i.isupper())
res+=1+int(next_val!=cur)
cur=next_val
return res | def typist(s):
cur = res = 0
for i in s:
next_val = int(i.isupper())
res += 1 + int(next_val != cur)
cur = next_val
return res |
class ScopeCache(object):
def __init__(self, name: str):
"""
:param name: human-readable name
:param scoped_components: components managed by this scope
"""
self.name = name
def handles_component(self, component: type) -> bool:
raise NotImplementedError
def... | class Scopecache(object):
def __init__(self, name: str):
"""
:param name: human-readable name
:param scoped_components: components managed by this scope
"""
self.name = name
def handles_component(self, component: type) -> bool:
raise NotImplementedError
def... |
n=int(input())
for i in range(n):
a,b,c=[int(x) for x in input().split()]
sum=a+b+c
if sum==180:
print("YES")
else:
print("NO") | n = int(input())
for i in range(n):
(a, b, c) = [int(x) for x in input().split()]
sum = a + b + c
if sum == 180:
print('YES')
else:
print('NO') |
beta = 9.
gamma = 0.6
logLX = beta + gamma * logLUV
scatter = 0.4 # 0.35
# LX: monochromatic at 2 keV
# LUV: monochromatic at 2500 AA | beta = 9.0
gamma = 0.6
log_lx = beta + gamma * logLUV
scatter = 0.4 |
class Solution:
def isValid(self, s):
if s == '':
return True
sList = list(s)
stack = []
for chr in sList:
if len(stack) == 0:
stack.append(chr)
else:
stack.pop() if (chr == ')' and stack[-1] == '(') or (chr == ']' a... | class Solution:
def is_valid(self, s):
if s == '':
return True
s_list = list(s)
stack = []
for chr in sList:
if len(stack) == 0:
stack.append(chr)
else:
stack.pop() if chr == ')' and stack[-1] == '(' or (chr == ']' ... |
#! /usr/bin/env python
"""
A singleton pattern implemented in python. Adapted from ActiveState Code
Recipe 52558: The Singleton Pattern implemented with Python
http://code.activestate.com/recipes/52558/
"""
class Singleton(object):
"""
A python singleton
"""
class SingletonImplementation:
... | """
A singleton pattern implemented in python. Adapted from ActiveState Code
Recipe 52558: The Singleton Pattern implemented with Python
http://code.activestate.com/recipes/52558/
"""
class Singleton(object):
"""
A python singleton
"""
class Singletonimplementation:
"""
Implementation ... |
class SecretKey:
"""A wrapper class for representing secret key.
Typical format of secret key data would be [p1. p2, p3...] where pi represents
polynomials for each coefficient modulus.
Elements of each polynomails is taken from {-1, 0, 1} represented in their respective
modulus.
Attributes:
... | class Secretkey:
"""A wrapper class for representing secret key.
Typical format of secret key data would be [p1. p2, p3...] where pi represents
polynomials for each coefficient modulus.
Elements of each polynomails is taken from {-1, 0, 1} represented in their respective
modulus.
Attributes:
... |
# For loops are used ot iterate over all elements of an iterable
# They use use the 'for variable in iterable' syntax
for i in range(0, 3):
# x is defined in the for loop and usable in this body of the for loop
print(i) # prints 0, 1, 2 each on a new line
for i in [10, "Hello", "World"]:
# We call this it... | for i in range(0, 3):
print(i)
for i in [10, 'Hello', 'World']:
print(i) |
#!/usr/bin/env python
#-*- coding: utf-8 -*-
class Fitness:
def __init__(self, criterion, *args, **kwargs):
"""
Simplest single criterion fitness object.
:param criterion: Generic container to store the fitness criterion;.
:type criterion: object
"""
self.criterion ... | class Fitness:
def __init__(self, criterion, *args, **kwargs):
"""
Simplest single criterion fitness object.
:param criterion: Generic container to store the fitness criterion;.
:type criterion: object
"""
self.criterion = criterion
def __gt__(self, other):
... |
weight = float(input("Please enter weight in kilograms: "))
height = float(input("Please enter height in meters: "))
bmi = weight/(height * height)
print("BMI is: ",bmi) | weight = float(input('Please enter weight in kilograms: '))
height = float(input('Please enter height in meters: '))
bmi = weight / (height * height)
print('BMI is: ', bmi) |
"""
A package in which functionality specific to MAGIC H2020 project can be found
The rest of the source code should not depend on MAGIC, being base on "plain"
MuSIASEM and of course its evolution inside MAGIC project.
""" | """
A package in which functionality specific to MAGIC H2020 project can be found
The rest of the source code should not depend on MAGIC, being base on "plain"
MuSIASEM and of course its evolution inside MAGIC project.
""" |
_base_ = ['./pipelines/rand_aug.py']
# dataset settings
dataset_type = 'ImageNet'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='RandomResizedCrop',
size=224,
backend='pil... | _base_ = ['./pipelines/rand_aug.py']
dataset_type = 'ImageNet'
img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [dict(type='LoadImageFromFile'), dict(type='RandomResizedCrop', size=224, backend='pillow', interpolation='bicubic'), dict(type='RandomFlip', flip... |
RELEVANT_EXTENSIONS = [
"java",
"c",
"cpp",
"h",
"py",
"js",
"xml",
"go",
"rb",
"php",
"sh",
"scale",
"lua",
"m",
"pl",
"ts",
"swift",
"sql",
"groovy",
"erl",
"swf",
"vue",
"bat",
"s",
"ejs",
"yaml",
"yml",
"... | relevant_extensions = ['java', 'c', 'cpp', 'h', 'py', 'js', 'xml', 'go', 'rb', 'php', 'sh', 'scale', 'lua', 'm', 'pl', 'ts', 'swift', 'sql', 'groovy', 'erl', 'swf', 'vue', 'bat', 's', 'ejs', 'yaml', 'yml', 'jar']
allowed_sites = ['for.testing.purposes', 'lists.apache.org', 'just.an.example.site', 'one.more.example.site... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.