content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
# (c)2010-2012 Chris Pressey, Cat's Eye Technologies.
# All rights reserved. Released under a BSD-style license (see LICENSE).
"""
Abstract Syntax Trees for the Unlikely programming language.
$Id: ast.py 318 2010-01-07 01:49:38Z cpressey $
"""
class ArtefactExistsError(Exception):
"""An... | """
Abstract Syntax Trees for the Unlikely programming language.
$Id: ast.py 318 2010-01-07 01:49:38Z cpressey $
"""
class Artefactexistserror(Exception):
"""An exception indicating that a proposed artefact (class, method,
property, ...) already exists.
"""
pass
class Artefactnotfounderror(Exception)... |
del_items(0x800A0FE4)
SetType(0x800A0FE4, "void VID_OpenModule__Fv()")
del_items(0x800A10A4)
SetType(0x800A10A4, "void InitScreens__Fv()")
del_items(0x800A1194)
SetType(0x800A1194, "void MEM_SetupMem__Fv()")
del_items(0x800A11C0)
SetType(0x800A11C0, "void SetupWorkRam__Fv()")
del_items(0x800A1250)
SetType(0x800A1250, "... | del_items(2148143076)
set_type(2148143076, 'void VID_OpenModule__Fv()')
del_items(2148143268)
set_type(2148143268, 'void InitScreens__Fv()')
del_items(2148143508)
set_type(2148143508, 'void MEM_SetupMem__Fv()')
del_items(2148143552)
set_type(2148143552, 'void SetupWorkRam__Fv()')
del_items(2148143696)
set_type(21481436... |
def arithmetic_arranger(problems, count_start=False):
line_1 = ""
line_2 = ""
line_3 = ""
line_4 = ""
for i, problem in enumerate(problems):
a, b, c = problem.split()
d = max(len(a), len(c))
if len(problems) > 5:
return "Error: Too many problems."
if le... | def arithmetic_arranger(problems, count_start=False):
line_1 = ''
line_2 = ''
line_3 = ''
line_4 = ''
for (i, problem) in enumerate(problems):
(a, b, c) = problem.split()
d = max(len(a), len(c))
if len(problems) > 5:
return 'Error: Too many problems.'
if l... |
# Copyright (c) 2019 The Bazel Utils Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
def runtime_library():
return [
"_WINDOWS",
"WIN32",
]
def winver():
return [
"_WIN32_WINNT=0x0A00",
"WIN... | def runtime_library():
return ['_WINDOWS', 'WIN32']
def winver():
return ['_WIN32_WINNT=0x0A00', 'WINVER=0x0A00']
def unicode():
return ['_UNICODE', 'UNICODE']
def lean_and_mean():
return ['WIN32_LEAN_AND_MEAN'] |
def arithmetic_arranger(problems, solution=False):
# Limit of 4 problems per call
if len(problems) > 5:
return "Error: Too many problems."
# Declaring list to organise problems
summa1 = []
summa2 = []
operator = []
# Organising problems in right list
for problem in problems:
... | def arithmetic_arranger(problems, solution=False):
if len(problems) > 5:
return 'Error: Too many problems.'
summa1 = []
summa2 = []
operator = []
for problem in problems:
prob_list = problem.split()
summa1.append(prob_list[0])
summa2.append(prob_list[2])
opera... |
"""
Azure concepts
"""
def Graphic_shape():
return "egg"
def Graphic_colorfill():
return "#CCCC33"
def Graphic_colorbg():
return "#CCCC33"
def Graphic_border():
return 0
def Graphic_is_rounded():
return True
| """
Azure concepts
"""
def graphic_shape():
return 'egg'
def graphic_colorfill():
return '#CCCC33'
def graphic_colorbg():
return '#CCCC33'
def graphic_border():
return 0
def graphic_is_rounded():
return True |
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
letters = [0 for i in range(256)]
for i in range(len(s)):
letters[ord(s[i])] += 1
for i in range(len(t)):
letters[ord(t[i])] -= 1
... | class Solution(object):
def is_anagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
letters = [0 for i in range(256)]
for i in range(len(s)):
letters[ord(s[i])] += 1
for i in range(len(t)):
letters[ord(t[i])] -= ... |
'''
PURPOSE
The function capital_indexes takes a single parameter, which is a string.
It returns a list of all the indexes in the string that have capital letters.
EXAMPLE
Calling capital_indexes("HeLlO") should return the list [0, 2, 4].
'''
def capital_indexes(input_str):
try:
input_str_len ... | """
PURPOSE
The function capital_indexes takes a single parameter, which is a string.
It returns a list of all the indexes in the string that have capital letters.
EXAMPLE
Calling capital_indexes("HeLlO") should return the list [0, 2, 4].
"""
def capital_indexes(input_str):
try:
input_str_len ... |
n,m = map(int, input().split())
arr = list(map(int, input().split()))
a = set(map(int, input().split()))
b = set(map(int,input().split()))
print(n,m)
print(arr)
print(a)
print(b)
c = 0
for i in arr:
if i in a:
c = c +1
if i in b:
c = c-1
print(c)
| (n, m) = map(int, input().split())
arr = list(map(int, input().split()))
a = set(map(int, input().split()))
b = set(map(int, input().split()))
print(n, m)
print(arr)
print(a)
print(b)
c = 0
for i in arr:
if i in a:
c = c + 1
if i in b:
c = c - 1
print(c) |
# Road to the Mine 1 (931060030) | Xenon 3rd Job
lackey = 2159397
gelimer = 2154009
goon = 9300643
sm.lockInGameUI(True)
sm.spawnNpc(lackey, 648, 28)
# TO DO: Figure out why the lackey doesn't move and just spazes in place (initial start x: 1188)
# sm.moveCamera(100, 738, ground)
# sm.sendDelay(1000)
# sm.moveCamer... | lackey = 2159397
gelimer = 2154009
goon = 9300643
sm.lockInGameUI(True)
sm.spawnNpc(lackey, 648, 28)
sm.removeEscapeButton()
sm.setSpeakerID(lackey)
sm.sendNext("Hey, what're you doing out here? And where did that other guy go? You don't look familiar...")
sm.setPlayerAsSpeaker()
sm.sendSay('I am a Black Wing.')
sm.set... |
PWR_MGMT_1 = 0x6b
ACCEL_CONFIG = 0x1C
ACCEL_XOUT_H = 0x3B
ACCEL_XOUT_L = 0x3C
ACCEL_YOUT_H = 0x3D
ACCEL_YOUT_L = 0x3E
ACCEL_ZOUT_H = 0x3F
ACCEL_ZOUT_L = 0x40
GYRO_CONFIG = 0x1B
GYRO_XOUT_H = 0x43
GYRO_XOUT_L = 0x44
GYRO_YOUT_H = 0x45
GYRO_YOUT_L = 0x46
GYRO_ZOUT_H = 0x47
GYRO_ZOUT_L = 0x48
TEMP_H = 0x41
TEMP_L = 0x4... | pwr_mgmt_1 = 107
accel_config = 28
accel_xout_h = 59
accel_xout_l = 60
accel_yout_h = 61
accel_yout_l = 62
accel_zout_h = 63
accel_zout_l = 64
gyro_config = 27
gyro_xout_h = 67
gyro_xout_l = 68
gyro_yout_h = 69
gyro_yout_l = 70
gyro_zout_h = 71
gyro_zout_l = 72
temp_h = 65
temp_l = 66 |
"""
__init__.py
Created by lmarvaud on 31/01/2019
"""
| """
__init__.py
Created by lmarvaud on 31/01/2019
""" |
###
### Week 2: Before Class
###
## Make a list of the words one two three o'clock four o'clock rock
words = ["one", "two", "three", "o'clock", "four", "o'clock", 'rock']
## Pick out the first word as a string
words[0]
## Pick out the first word as a list
words[0:1]
## Pick out the last word as a string
word... | words = ['one', 'two', 'three', "o'clock", 'four', "o'clock", 'rock']
words[0]
words[0:1]
words[-1]
len(words)
[len(w) for w in words]
words.count("o'clock")
print('No output for this') |
word1 = input("Enter a word: ")
word2 = input("Enter another word: ")
word1 = word1.lower()
word2 = word2.lower()
dic1 = {}
dic2 = {}
for elm in word1:
if elm in dic1.keys():
count = dic1[elm]
count += 1
dic1[elm] = count
else:
dic1[elm] = 1
for elm in word2:
if elm in di... | word1 = input('Enter a word: ')
word2 = input('Enter another word: ')
word1 = word1.lower()
word2 = word2.lower()
dic1 = {}
dic2 = {}
for elm in word1:
if elm in dic1.keys():
count = dic1[elm]
count += 1
dic1[elm] = count
else:
dic1[elm] = 1
for elm in word2:
if elm in dic2.k... |
S = input()
if S[-2:] == 'ai':
print(S[:-2] + 'AI')
else:
print(S + '-AI')
| s = input()
if S[-2:] == 'ai':
print(S[:-2] + 'AI')
else:
print(S + '-AI') |
def words(digit):
for i in digit:
num = int(i)
if num == 1:
print("One")
if num == 2:
print("Two")
if num == 3:
print("Three")
if num == 4:
print("Four")
if num == 5:
print("Five")
if num =... | def words(digit):
for i in digit:
num = int(i)
if num == 1:
print('One')
if num == 2:
print('Two')
if num == 3:
print('Three')
if num == 4:
print('Four')
if num == 5:
print('Five')
if num == 6:
... |
class Solution:
def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
n = len(numbers)
left, right = 0, n-1
while left < right:
if numbers[left]+numbers[right]==target: return [left+1, right... | class Solution:
def two_sum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
n = len(numbers)
(left, right) = (0, n - 1)
while left < right:
if numbers[left] + numbers[right] == target:
... |
test_data = """
939
7,13,x,x,59,x,31,19
""".strip()
data = """
1001612
19,x,x,x,x,x,x,x,x,41,x,x,x,37,x,x,x,x,x,821,x,x,x,x,x,x,x,x,x,x,x,x,13,x,x,x,17,x,x,x,x,x,x,x,x,x,x,x,29,x,463,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,23
""".strip()
def test_aoc13_p1t():
time, schedule = test_data.splitlines()
time ... | test_data = '\n939\n7,13,x,x,59,x,31,19\n'.strip()
data = '\n1001612\n19,x,x,x,x,x,x,x,x,41,x,x,x,37,x,x,x,x,x,821,x,x,x,x,x,x,x,x,x,x,x,x,13,x,x,x,17,x,x,x,x,x,x,x,x,x,x,x,29,x,463,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,23\n'.strip()
def test_aoc13_p1t():
(time, schedule) = test_data.splitlines()
time = ... |
class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
x = 0
y = 0
xx = len(matrix) - 1
yy = len(matrix[0]) - 1
rows = xx + 1
cols = yy + 1
w... | class Solution(object):
def search_matrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
x = 0
y = 0
xx = len(matrix) - 1
yy = len(matrix[0]) - 1
rows = xx + 1
cols = yy + 1
... |
# Sanitize a dependency so that it works correctly from code that includes
# QCraft as a submodule.
def clean_dep(dep):
return str(Label(dep))
| def clean_dep(dep):
return str(label(dep)) |
def unatrag(s):
if len(s)==0:
return s
else:
return unatrag(s[1:]) + s[0]
s=input("Unesite rijec: ")
print(unatrag(s))
| def unatrag(s):
if len(s) == 0:
return s
else:
return unatrag(s[1:]) + s[0]
s = input('Unesite rijec: ')
print(unatrag(s)) |
file_obj = open("squares.txt", "w") #Usar w de writing
for number in range (13):
square = number * number
file_obj.write(str(square))
file_obj.write('\n')
file_obj.close()
| file_obj = open('squares.txt', 'w')
for number in range(13):
square = number * number
file_obj.write(str(square))
file_obj.write('\n')
file_obj.close() |
# Exercise 4: Assume that we execute the following assignment statements:
# width = 17
# height = 12.0
# For each of the following expressions, write the value of the expression and the type (of the value of the expression).
# 1. width//2
# 2. width/2.0
# 3. height/3
# 4. 1 + 2 * 5
width = 17;
height = 12.0;
one = wi... | width = 17
height = 12.0
one = width // 2
two = width / 2.0
three = height / 3
four = 1 + 2 * 5
print(four, type(four)) |
altitude = int(input("Enter Altitude in ft:"))
if altitude<=1000:
print("Safe to land")
elif altitude< 5000:
print("Bring down to 1000")
else:
print("Turn Around and Try Again") | altitude = int(input('Enter Altitude in ft:'))
if altitude <= 1000:
print('Safe to land')
elif altitude < 5000:
print('Bring down to 1000')
else:
print('Turn Around and Try Again') |
# -*- coding: utf-8 -*-
def test_dummy(cmd, initproj, monkeypatch):
monkeypatch.delenv(str("TOXENV"), raising=False)
path = initproj(
'envreport_123',
filedefs={
'tox.ini': """
[tox]
envlist = a
[testenv]
deps=tox-envreport
... | def test_dummy(cmd, initproj, monkeypatch):
monkeypatch.delenv(str('TOXENV'), raising=False)
path = initproj('envreport_123', filedefs={'tox.ini': '\n [tox]\n envlist = a\n [testenv]\n deps=tox-envreport\n commands=echo "yehaaa"\n '})
assert path... |
# -*- coding: utf-8 -*-
'''
File name: code\comfortable_distance\sol_364.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #364 :: Comfortable distance
#
# For more information see:
# https://projecteuler.net/problem=364
# Problem Statemen... | """
File name: code\\comfortable_distance\\sol_364.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
"""
'\nThere are N seats in a row. N people come after each other to fill the seats according to the following rules:\nIf there is any seat whose adjacent seat(s) are not occupied ta... |
class Water():
regions = None
outline_points = None
def __init__(self):
self.regions = []
self.outline_points = [] | class Water:
regions = None
outline_points = None
def __init__(self):
self.regions = []
self.outline_points = [] |
1
"test"
"equality" == "equality"
1.5 * 10
int | 1
'test'
'equality' == 'equality'
1.5 * 10
int |
class Classe:
atributo_da_classe = 0
print(Classe.atributo_da_classe)
Classe.atributo_da_classe = 5
print(Classe.atributo_da_classe)
| class Classe:
atributo_da_classe = 0
print(Classe.atributo_da_classe)
Classe.atributo_da_classe = 5
print(Classe.atributo_da_classe) |
# 917. Reverse Only Letters
def reverseOnlyLetters(S):
def isLetter(c):
if (ord(c) >= 65 and ord(c) < 91) or (ord(c) >= 97 and ord(c) < 123):
return True
return False
A = list(S)
i, j = 0, len(A) - 1
while i < j:
if isLetter(A[i]) and isLetter(A[j]):
A[i]... | def reverse_only_letters(S):
def is_letter(c):
if ord(c) >= 65 and ord(c) < 91 or (ord(c) >= 97 and ord(c) < 123):
return True
return False
a = list(S)
(i, j) = (0, len(A) - 1)
while i < j:
if is_letter(A[i]) and is_letter(A[j]):
(A[i], A[j]) = (A[j], A[i... |
a=str(input('Enter string'))
if(a==a[::-1]):
print('palindrome')
else:
print('not a palindrome')
| a = str(input('Enter string'))
if a == a[::-1]:
print('palindrome')
else:
print('not a palindrome') |
#
# PySNMP MIB module CTRON-SSR-SMI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-SSR-SMI-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:15:44 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint) ... |
PROCESSOR_VERSION = "0.7.0"
# Entities
AREAS = "areas"
CAMERAS = "cameras"
ALL_AREAS = "ALL"
# Metrics
OCCUPANCY = "occupancy"
SOCIAL_DISTANCING = "social-distancing"
FACEMASK_USAGE = "facemask-usage"
IN_OUT = "in-out"
DWELL_TIME = "dwell-time"
| processor_version = '0.7.0'
areas = 'areas'
cameras = 'cameras'
all_areas = 'ALL'
occupancy = 'occupancy'
social_distancing = 'social-distancing'
facemask_usage = 'facemask-usage'
in_out = 'in-out'
dwell_time = 'dwell-time' |
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
if n == 1:
return 1
if n == 2:
return 2
a = 1
b = 2
for i in range(3, n + 1):
c = a + b
a = b
b = c
... | class Solution(object):
def climb_stairs(self, n):
"""
:type n: int
:rtype: int
"""
if n == 1:
return 1
if n == 2:
return 2
a = 1
b = 2
for i in range(3, n + 1):
c = a + b
a = b
b = c... |
'''
URL: https://leetcode.com/problems/delete-columns-to-make-sorted/
Difficulty: Easy
Description: Delete Columns to Make Sorted
We are given an array A of N lowercase letter strings, all of the same length.
Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those ... | """
URL: https://leetcode.com/problems/delete-columns-to-make-sorted/
Difficulty: Easy
Description: Delete Columns to Make Sorted
We are given an array A of N lowercase letter strings, all of the same length.
Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those ... |
ACTIVE_CLASS = 'active'
SELECTED_CLASS = 'selected'
class MenuItem:
def __init__(self, label, url, css_classes='', submenu=None):
self.label = label
self.url = url
self.css_classes = css_classes
self.submenu = submenu
def status_class(self, request):
css_class = ''
... | active_class = 'active'
selected_class = 'selected'
class Menuitem:
def __init__(self, label, url, css_classes='', submenu=None):
self.label = label
self.url = url
self.css_classes = css_classes
self.submenu = submenu
def status_class(self, request):
css_class = ''
... |
class Hyparams:
user_count= 192403
item_count= 63001
cate_count= 801
predict_batch_size = 120
predict_ads_num = 100
batch_size = 128
hidden_units = 64
train_batch_size = 32
test_batch_size = 512
predict_batch_size = 32
predict_users_num = 1000
predict_ads_num = 100
... | class Hyparams:
user_count = 192403
item_count = 63001
cate_count = 801
predict_batch_size = 120
predict_ads_num = 100
batch_size = 128
hidden_units = 64
train_batch_size = 32
test_batch_size = 512
predict_batch_size = 32
predict_users_num = 1000
predict_ads_num = 100
... |
'''
Created on 1.12.2016
@author: Darren
''''''
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra space.
For example,
Given the following binary tre... | """
Created on 1.12.2016
@author: Darren
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra space.
For example,
Given the following binary tree,
1
... |
def set_template(args):
# task category
args.task = 'VideoBDE'
# network parameters
args.n_feat = 32
# loss
args.loss = '1*L1+2*HEM'
# learning rata strategy
args.lr = 1e-4
args.lr_decay = 100
args.gamma = 0.1
# data parameters
args.data_train = 'SDR4K'
args.data_test... | def set_template(args):
args.task = 'VideoBDE'
args.n_feat = 32
args.loss = '1*L1+2*HEM'
args.lr = 0.0001
args.lr_decay = 100
args.gamma = 0.1
args.data_train = 'SDR4K'
args.data_test = 'SDR4K'
args.n_sequence = 3
args.n_frames_per_video = 100
args.rgb_range = 65535
args.... |
"""
Write a program by the following:
1. Define a function that accepts a string and prints every other word
2. Define a function that accepts a string and translates it into pig latin
3. If time, implement them into a main loop
""" | """
Write a program by the following:
1. Define a function that accepts a string and prints every other word
2. Define a function that accepts a string and translates it into pig latin
3. If time, implement them into a main loop
""" |
#
# PySNMP MIB module UNCDZ-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/UNCDZ-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:28:43 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')
(constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 23 17:49:24 2020
@author: ahmad
"""
x = [5, 9, 8, -8, 7, 8, 10]
#print(x[4])
#for i in range(0,len(x)):
# print(x[i])
# write a code to show the sum og the numbers in the Array
sum = 0
for i in range(0,len(x)):
sum += x[i]
print("array su... | """
Created on Sat May 23 17:49:24 2020
@author: ahmad
"""
x = [5, 9, 8, -8, 7, 8, 10]
sum = 0
for i in range(0, len(x)):
sum += x[i]
print('array sum = ' + str(sum))
max = x[0]
for i in range(1, len(x)):
if max < x[i]:
max = x[i]
print('array max = ' + str(max)) |
"""State: Abstract class that
defines the desired state of inventory in a target system"""
class State(object):
def __init__(self):
self.logger = None
self.verify_connectivity()
def verify_connectivity(self):
raise NotImplementedError
def set_logger(self):
raise NotImplem... | """State: Abstract class that
defines the desired state of inventory in a target system"""
class State(object):
def __init__(self):
self.logger = None
self.verify_connectivity()
def verify_connectivity(self):
raise NotImplementedError
def set_logger(self):
raise NotImplem... |
class BaseBuilding(object):
"""
boilder-plate class used to initiale the various building in
municipality
"""
def __init__(self, location=None, land_rate=500):
if not isinstance(location, str) and location is not None:
raise TypeError("Location should be of type str")
... | class Basebuilding(object):
"""
boilder-plate class used to initiale the various building in
municipality
"""
def __init__(self, location=None, land_rate=500):
if not isinstance(location, str) and location is not None:
raise type_error('Location should be of type str')
... |
"""adds Buffer functionality to Loader"""
class BufferMixin(object):
"""stuff"""
def __init__(self, *args, **kwargs):
"""initializes base data loader"""
super(BufferMixin, self).__init__(*args, **kwargs)
self._buffered_values = None
#set _buffered_values
self._reset_b... | """adds Buffer functionality to Loader"""
class Buffermixin(object):
"""stuff"""
def __init__(self, *args, **kwargs):
"""initializes base data loader"""
super(BufferMixin, self).__init__(*args, **kwargs)
self._buffered_values = None
self._reset_buffered_values()
def load_b... |
NB_GRADER_CONFIG_TEMPLATE = """
c = get_config()
c.CourseDirectory.root = '/home/{grader_name}/{course_id}'
c.CourseDirectory.course_id = '{course_id}'
"""
| nb_grader_config_template = "\nc = get_config()\n\nc.CourseDirectory.root = '/home/{grader_name}/{course_id}'\nc.CourseDirectory.course_id = '{course_id}'\n" |
class Settings:
def __init__(
self,
workdir: str,
outdir: str,
threads: int,
debug: bool):
self.workdir = workdir
self.outdir = outdir
self.threads = threads
self.debug = debug
class Logger:
def __i... | class Settings:
def __init__(self, workdir: str, outdir: str, threads: int, debug: bool):
self.workdir = workdir
self.outdir = outdir
self.threads = threads
self.debug = debug
class Logger:
def __init__(self, name: str):
self.name = name
def info(self, msg: str):
... |
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 15 01:40:25 2018
@author: kennedy
"""
#sample --> 'kennedy':'ify1', 'andy': 'best56', 'great': 'op3'
#create new user
system = {} #database system
option = ""
def newusers():
uname= input("Enter a username: ")
if uname in system:
print("User a... | """
Created on Mon Jan 15 01:40:25 2018
@author: kennedy
"""
system = {}
option = ''
def newusers():
uname = input('Enter a username: ')
if uname in system:
print('User already exit: Create new user')
else:
pw = input('Enter password: ')
system[uname] = pw
print('\nUser cre... |
"""Cached evaluation of integrals of monomials over the unit simplex.
"""
# Integrals of all monomial basis polynomials for the space P_r(R^n) over the n-dimensional unit simplex,
# given as a list.
monomial_integrals_unit_simplex_all_cache = {
# (n, r) = (1, 1)
(1, 1): [
1,
1 / 2
],
# ... | """Cached evaluation of integrals of monomials over the unit simplex.
"""
monomial_integrals_unit_simplex_all_cache = {(1, 1): [1, 1 / 2], (1, 2): [1, 1 / 2, 1 / 3], (1, 3): [1, 1 / 2, 1 / 3, 1 / 4], (1, 4): [1, 1 / 2, 1 / 3, 1 / 4, 1 / 5], (1, 5): [1, 1 / 2, 1 / 3, 1 / 4, 1 / 5, 1 / 6], (1, 6): [1, 1 / 2, 1 / 3, 1 / 4... |
#import base64
#
#data = "abc123!?$*&()'-=@~"
#
## Standard Base64 Encoding
#encodedBytes = base64.b64encode(data.encode("utf-8"))
#encodedStr = str(encodedBytes, "utf-8")
#
#print(encodedStr)
#
l = [x for x in range(10)]
for x in range(10):
l.pop(0)
print(l) | l = [x for x in range(10)]
for x in range(10):
l.pop(0)
print(l) |
load(":collection_results.bzl", "collection_results")
load(":collect_module_members.bzl", "collect_module_members")
load(":declarations.bzl", "declarations")
load(":errors.bzl", "errors")
load(":tokens.bzl", "tokens", rws = "reserved_words", tts = "token_types")
# MARK: - Attribute Collection
def _collect_attribute(p... | load(':collection_results.bzl', 'collection_results')
load(':collect_module_members.bzl', 'collect_module_members')
load(':declarations.bzl', 'declarations')
load(':errors.bzl', 'errors')
load(':tokens.bzl', 'tokens', rws='reserved_words', tts='token_types')
def _collect_attribute(parsed_tokens):
"""Collect a modu... |
f = open('input.txt')
adapters = []
for line in f:
adapters.append(int(line[:-1]))
adapters.sort()
adapters.append(adapters[-1] + 3)
differences = {}
previous = 0
for adapter in adapters:
current_difference = adapter - previous
if not current_difference in differences: differences[current_difference] = ... | f = open('input.txt')
adapters = []
for line in f:
adapters.append(int(line[:-1]))
adapters.sort()
adapters.append(adapters[-1] + 3)
differences = {}
previous = 0
for adapter in adapters:
current_difference = adapter - previous
if not current_difference in differences:
differences[current_difference... |
class Solution:
def peakIndexInMountainArray(self, A):
"""
:type A: List[int]
:rtype: int
"""
A_new = sorted(A)
return A.index(A_new[-1])
# # other solutions
# # 1.
# class Solution:
# def peakIndexInMountainArray(self, A):
# """
# :type A: List[... | class Solution:
def peak_index_in_mountain_array(self, A):
"""
:type A: List[int]
:rtype: int
"""
a_new = sorted(A)
return A.index(A_new[-1])
a = [0, 1, 0]
a = [0, 2, 1, 0]
sol = solution()
res = sol.peakIndexInMountainArray(A)
print(res) |
# LinkNode/Marker ID Table
# -1: Unassigned (Temporary)
# 0 ~ 50: Reserved for Joint ID
#
FRAME_ID = 'viz_frame'
| frame_id = 'viz_frame' |
"""
strategy_observer.py
Copyright 2015 Andres Riancho
This file is part of w3af, http://w3af.org/ .
w3af is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
w3af is distributed in the hop... | """
strategy_observer.py
Copyright 2015 Andres Riancho
This file is part of w3af, http://w3af.org/ .
w3af is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
w3af is distributed in the hop... |
VBA = \
r"""
Function ExecuteCmdSync(targetPath As String)
'Run a shell command, returning the output as a string'
' Using a hidden window, pipe the output of the command to the CLIP.EXE utility...
' Necessary because normal usage with oShell.Exec("cmd.exe /C " & sCmd) always pops a windows
Dim instr... | vba = '\n\nFunction ExecuteCmdSync(targetPath As String)\n \'Run a shell command, returning the output as a string\'\n \' Using a hidden window, pipe the output of the command to the CLIP.EXE utility...\n \' Necessary because normal usage with oShell.Exec("cmd.exe /C " & sCmd) always pops a windows\n Dim in... |
'''
Statement
Given a list of numbers, find and print the elements that appear in it only once. Such elements should be printed in the order in which they occur in the original list.
Example input
4 3 5 2 5 1 3 5
Example output
4 2 1
'''
arr = input().split()
for i in arr:
if arr.count(i) == 1:
print(i, ... | """
Statement
Given a list of numbers, find and print the elements that appear in it only once. Such elements should be printed in the order in which they occur in the original list.
Example input
4 3 5 2 5 1 3 5
Example output
4 2 1
"""
arr = input().split()
for i in arr:
if arr.count(i) == 1:
print(i, e... |
class Source:
pass
class URL(Source):
def __init__(self, url, method="GET", data=None):
self.url = url
self.method = method
self.data = data
def get_data(self, scraper):
return scraper.request(method=self.method, url=self.url, data=self.data).content
def __str__(self)... | class Source:
pass
class Url(Source):
def __init__(self, url, method='GET', data=None):
self.url = url
self.method = method
self.data = data
def get_data(self, scraper):
return scraper.request(method=self.method, url=self.url, data=self.data).content
def __str__(self)... |
fs = 44100.
dt = 1. / fs
def rawsco_to_ndf(rawsco):
clock, rate, nsamps, score = rawsco
if rate == 44100:
ar = True
else:
ar = False
max_i = score.shape[0]
samp = 0
t = 0.
# ('apu', ch, func, func_val, natoms, offset)
ndf = [
('clock', int(clock)),
('apu', 'ch', 'p1', 0, 0, 0),... | fs = 44100.0
dt = 1.0 / fs
def rawsco_to_ndf(rawsco):
(clock, rate, nsamps, score) = rawsco
if rate == 44100:
ar = True
else:
ar = False
max_i = score.shape[0]
samp = 0
t = 0.0
ndf = [('clock', int(clock)), ('apu', 'ch', 'p1', 0, 0, 0), ('apu', 'ch', 'p2', 0, 0, 0), ('apu', ... |
#Write a program to input a string and check if it is a palindrome or not.
#This solution is in python programing language
str = input("Enter the string: ")
if str == str[::-1]:
print("String is Palindrome")
else:
print("String is not Palindrome")
| str = input('Enter the string: ')
if str == str[::-1]:
print('String is Palindrome')
else:
print('String is not Palindrome') |
buddy= "extremely loyal and cute"
print(len(buddy))
print(buddy[0])
print(buddy[0:10])
print(buddy[0:])
print(buddy[:15])
print(buddy[:])
# len gives you the length or number of characters of the string.
# So (len(buddy)) when printed = 24 as even spaces are counted.
# [] these brackets help to dissect the components o... | buddy = 'extremely loyal and cute'
print(len(buddy))
print(buddy[0])
print(buddy[0:10])
print(buddy[0:])
print(buddy[:15])
print(buddy[:])
print(buddy[-1])
print(buddy[-2])
print(buddy[-5:2]) |
class Secret:
# Dajngo secret key
SECRET_KEY = ''
# Amazone S3
AWS_STORAGE_BUCKET_NAME = ''
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
| class Secret:
secret_key = ''
aws_storage_bucket_name = ''
aws_access_key_id = ''
aws_secret_access_key = '' |
"""
leetcode 232
Stack implementation Queue
"""
def __init__(self):
self.instack = []
self.outstack = []
def push(self, x: int) -> None:
self.instack.append(x)
def pop(self) -> int:
if not self.outstack:
while self.instack:
self.outstack.append(self.instack.pop())
return self.... | """
leetcode 232
Stack implementation Queue
"""
def __init__(self):
self.instack = []
self.outstack = []
def push(self, x: int) -> None:
self.instack.append(x)
def pop(self) -> int:
if not self.outstack:
while self.instack:
self.outstack.append(self.instack.pop())
return self.... |
class MessageHandler:
def __init__(self, name: str):
self.name = name
self.broker = None
def process_message(self, data: bytes):
pass
| class Messagehandler:
def __init__(self, name: str):
self.name = name
self.broker = None
def process_message(self, data: bytes):
pass |
self.description = "Sysupgrade with same version, different epochs"
sp = pmpkg("dummy", "2:2.0-1")
sp.files = ["bin/dummynew"]
self.addpkg2db("sync", sp)
lp = pmpkg("dummy", "1:2.0-1")
lp.files = ["bin/dummyold"]
self.addpkg2db("local", lp)
self.args = "-Su"
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_VERSIO... | self.description = 'Sysupgrade with same version, different epochs'
sp = pmpkg('dummy', '2:2.0-1')
sp.files = ['bin/dummynew']
self.addpkg2db('sync', sp)
lp = pmpkg('dummy', '1:2.0-1')
lp.files = ['bin/dummyold']
self.addpkg2db('local', lp)
self.args = '-Su'
self.addrule('PACMAN_RETCODE=0')
self.addrule('PKG_VERSION=du... |
def commonCharacterCount(s1, s2):
dic1 = {}
dic2 = {}
sums = 0
for letter in s1:
dic1[letter] = dic1.get(letter,0) + 1
for letter in s2:
dic2[letter] = dic2.get(letter,0) + 1
for letter in dic1:
if letter in dic2:
sums = sums + min(dic1[letter],dic2[letter])
... | def common_character_count(s1, s2):
dic1 = {}
dic2 = {}
sums = 0
for letter in s1:
dic1[letter] = dic1.get(letter, 0) + 1
for letter in s2:
dic2[letter] = dic2.get(letter, 0) + 1
for letter in dic1:
if letter in dic2:
sums = sums + min(dic1[letter], dic2[lette... |
class QuickReplyButton:
def __init__(self, title: str, payload: str):
if not isinstance(title, str):
raise TypeError("QuickReplyButton.title must be an instance of str")
if not isinstance(payload, str):
raise TypeError("QuickReplyButton.payload must be an instance of str")
... | class Quickreplybutton:
def __init__(self, title: str, payload: str):
if not isinstance(title, str):
raise type_error('QuickReplyButton.title must be an instance of str')
if not isinstance(payload, str):
raise type_error('QuickReplyButton.payload must be an instance of str')... |
class EnigmaException(Exception):
pass
class PlugboardException(EnigmaException):
pass
class ReflectorException(EnigmaException):
pass
class RotorException(EnigmaException):
pass
| class Enigmaexception(Exception):
pass
class Plugboardexception(EnigmaException):
pass
class Reflectorexception(EnigmaException):
pass
class Rotorexception(EnigmaException):
pass |
def checks_in_string(string, check_list):
for check in check_list:
if check in string:
return True
return False
| def checks_in_string(string, check_list):
for check in check_list:
if check in string:
return True
return False |
def find_strongest_eggs(*args):
eggs = args[0]
div = args[1]
res = []
strongest = []
is_strong = True
n = div
for _ in range(n):
res.append([])
for i in range(1):
if div == 1:
res.append(eggs)
break
else:
for j i... | def find_strongest_eggs(*args):
eggs = args[0]
div = args[1]
res = []
strongest = []
is_strong = True
n = div
for _ in range(n):
res.append([])
for i in range(1):
if div == 1:
res.append(eggs)
break
else:
for j in range(len(eggs... |
##PUT ALL INFO BETWEEN QUOTES BELOW AND RENAME THIS FILE TO 'creds.py'
#Twilio API Account info
ACCOUNT_SID = ""
AUTH_TOKEN = ""
# your cell phone number below (must begin with '+', example: "+15555555555")
TO_PHONE = ""
# your Twilio phone number below (must begin with '+', example: "+15555555555")
FROM_PHONE = ""
... | account_sid = ''
auth_token = ''
to_phone = ''
from_phone = ''
client_id = '' |
class ModeException(Exception):
def __init__(self, message: str):
super().__init__(message)
class SizeException(Exception):
def __init__(self, message: str):
super().__init__(message)
class PaddingException(Exception):
def __init__(self, message: str):
super().__init__(message)
... | class Modeexception(Exception):
def __init__(self, message: str):
super().__init__(message)
class Sizeexception(Exception):
def __init__(self, message: str):
super().__init__(message)
class Paddingexception(Exception):
def __init__(self, message: str):
super().__init__(message)
... |
#!/usr/bin/env python
""" Aluguel de carro
Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo
usuario, assim como a quantidade de dias pelos quais o carro foi alugado. Calcule o preco a pagar,
sabendo que o carro custa R$ 60,00 por dia e R$ 0,15 por km rodado.
"""
def pay(km, da... | """ Aluguel de carro
Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo
usuario, assim como a quantidade de dias pelos quais o carro foi alugado. Calcule o preco a pagar,
sabendo que o carro custa R$ 60,00 por dia e R$ 0,15 por km rodado.
"""
def pay(km, days):
return days * ... |
def function(a):
pass
function(10) | def function(a):
pass
function(10) |
class NullAttributeException(Exception):
"""Raised when the attribute which is not nullable is missing."""
pass
class ItemNotFoundException(Exception):
"""Raised when the item is not found"""
pass
class ConditionNotRecognizedException(Exception):
"""Raised when the condition is not found"""
... | class Nullattributeexception(Exception):
"""Raised when the attribute which is not nullable is missing."""
pass
class Itemnotfoundexception(Exception):
"""Raised when the item is not found"""
pass
class Conditionnotrecognizedexception(Exception):
"""Raised when the condition is not found"""
pa... |
class Base1:
def __init__(self, *args):
print("Base1.__init__",args)
class Clist1(Base1, list):
pass
class Ctuple1(Base1, tuple):
pass
a = Clist1()
print(len(a))
a = Clist1([1, 2, 3])
print(len(a))
a = Ctuple1()
print(len(a))
a = Ctuple1([1, 2, 3])
# TODO: Faults
#print(len(a))
print("---")
cl... | class Base1:
def __init__(self, *args):
print('Base1.__init__', args)
class Clist1(Base1, list):
pass
class Ctuple1(Base1, tuple):
pass
a = clist1()
print(len(a))
a = clist1([1, 2, 3])
print(len(a))
a = ctuple1()
print(len(a))
a = ctuple1([1, 2, 3])
print('---')
class Clist2(list, Base1):
pa... |
# 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
# distributed under the Li... | _credential_properties = {'blob': {'type': 'string'}, 'project_id': {'type': 'string'}, 'type': {'type': 'string'}, 'user_id': {'type': 'string'}}
credential_create = {'type': 'object', 'properties': _credential_properties, 'additionalProperties': True, 'oneOf': [{'title': 'ec2 credential requires project_id', 'require... |
def hash_function(s=b''):
a, b, c, d = 0xa0, 0xb1, 0x11, 0x4d
for byte in bytearray(s):
a ^= byte
b = b ^ a ^ 0x55
c = b ^ 0x94
d = c ^ byte ^ 0x74
return format(d << 24 | c << 16 | a << 8 | b, '08x')
| def hash_function(s=b''):
(a, b, c, d) = (160, 177, 17, 77)
for byte in bytearray(s):
a ^= byte
b = b ^ a ^ 85
c = b ^ 148
d = c ^ byte ^ 116
return format(d << 24 | c << 16 | a << 8 | b, '08x') |
# -*- coding: utf-8 -*-
"""
lswifi.constants
~~~~~~~~~~~~~~~~
define app constant values
"""
APNAMEACKFILE = "apnames.ack"
APNAMEJSONFILE = "apnames.json"
CIPHER_SUITE_DICT = {
0: "Use group cipher suite",
1: "WEP-40", # WEP
2: "TKIP", # WPA-Personal (TKIP is limited to 54 Mbps)
3: "Reserved",
... | """
lswifi.constants
~~~~~~~~~~~~~~~~
define app constant values
"""
apnameackfile = 'apnames.ack'
apnamejsonfile = 'apnames.json'
cipher_suite_dict = {0: 'Use group cipher suite', 1: 'WEP-40', 2: 'TKIP', 3: 'Reserved', 4: 'AES', 5: 'WEP-104', 6: 'BIP-CMAC-128', 7: 'Group addressed traffic not allowed', 8: 'GCMP-128',... |
#!/usr/bin/env python3
# coding: utf8
"""
constants.py
Date: 08-21-2019
Description: Defines the codes required for ansi code generation
"""
START = "\033["
END = "\033[0m"
COLOR_CODES = {
"k": "black",
"b": "blue",
"r": "red",
"g": "green",
"p": "purple",
"y": "yellow",
"c": "cyan",
... | """
constants.py
Date: 08-21-2019
Description: Defines the codes required for ansi code generation
"""
start = '\x1b['
end = '\x1b[0m'
color_codes = {'k': 'black', 'b': 'blue', 'r': 'red', 'g': 'green', 'p': 'purple', 'y': 'yellow', 'c': 'cyan', 'w': 'white', 'lg': 'light green', 'dg': 'dark gray', 'lr': 'light red', ... |
def buy_card(n: int, p: list):
d = [0]*(n+1)
for i in range(1, n+1):
for j in range(1, i+1):
d[i] = max(d[i], d[i-j] + p[j-1])
return d[n]
def test_buy_card():
assert buy_card(4, [1, 5, 6, 7]) == 10
assert buy_card(5, [10, 9, 8, 7, 6]) == 50
assert buy_card(10, [1, 1, 2, ... | def buy_card(n: int, p: list):
d = [0] * (n + 1)
for i in range(1, n + 1):
for j in range(1, i + 1):
d[i] = max(d[i], d[i - j] + p[j - 1])
return d[n]
def test_buy_card():
assert buy_card(4, [1, 5, 6, 7]) == 10
assert buy_card(5, [10, 9, 8, 7, 6]) == 50
assert buy_card(10, [... |
class Item:
item_id = 1
def __init__(self, name):
self.name = name
self.item_id = Item.item_id
Item.item_id += 1
tv = Item('LG 42')
computer = Item('Dell XPS')
print(tv.item_id)
print(computer.item_id)
# prints:
# 1
# 2 | class Item:
item_id = 1
def __init__(self, name):
self.name = name
self.item_id = Item.item_id
Item.item_id += 1
tv = item('LG 42')
computer = item('Dell XPS')
print(tv.item_id)
print(computer.item_id) |
#!/usr/bin/env python3
"""Remove vowels and whitespace from a string and put the vowels at the end.
Title:
Disemvoweler
Description:
Make a program that removes every vowel and whitespace found in a string.
It should output the resulting disemvoweled string
with the removed vowels concatenated to the end of it.
For e... | """Remove vowels and whitespace from a string and put the vowels at the end.
Title:
Disemvoweler
Description:
Make a program that removes every vowel and whitespace found in a string.
It should output the resulting disemvoweled string
with the removed vowels concatenated to the end of it.
For example 'Hello world' ou... |
# Dit is weer een encoder, dus gebruik instellinen die daarbij horen.
real_encoder = tf.keras.models.Sequential([
tf.keras.layers.Dense(784, activation=tf.nn.relu),
tf.keras.layers.Dense(128, activation=tf.nn.relu),
tf.keras.layers.Dense(2, activation=tf.nn.relu),
tf.keras.layers.Dense(128, activation=tf.nn.rel... | real_encoder = tf.keras.models.Sequential([tf.keras.layers.Dense(784, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(2, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(784, activation=tf.nn.relu)])
real_encoder.compile(lo... |
SLOTS = [
[
0,
5460,
["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"],
["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"],
],
[
9995,
9995,
["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"],
["172.17... | slots = [[0, 5460, ['172.17.0.2', 7000, 'cf0da23bbea0ac65fd93d272358b59cd7ce3af25'], ['172.17.0.2', 7003, 'ab35b1210fcae1010a463c65e1616b51d3d7a00b']], [9995, 9995, ['172.17.0.2', 7000, 'cf0da23bbea0ac65fd93d272358b59cd7ce3af25'], ['172.17.0.2', 7003, 'ab35b1210fcae1010a463c65e1616b51d3d7a00b']], [12182, 12182, ['172.1... |
def emulate_catchup(replica, ppSeqNo=100):
if replica.isMaster:
replica.caught_up_till_3pc((replica.viewNo, ppSeqNo))
else:
replica.catchup_clear_for_backup()
def emulate_select_primaries(replica):
replica.primaryName = 'SomeAnotherNode'
replica._setup_for_non_master_after_view_change(r... | def emulate_catchup(replica, ppSeqNo=100):
if replica.isMaster:
replica.caught_up_till_3pc((replica.viewNo, ppSeqNo))
else:
replica.catchup_clear_for_backup()
def emulate_select_primaries(replica):
replica.primaryName = 'SomeAnotherNode'
replica._setup_for_non_master_after_view_change(r... |
# this is the module which i will be
#calling and using again and again
def kolar():
print("I am a new module which will work i am call")
# this file save with same python path with new file name
| def kolar():
print('I am a new module which will work i am call') |
f = open('Log-A.strace')
lines = f.readlines()
term = ' read('
term2 = 'pipe'
term3 = 'tty'
def extract_name(line, start_delimiter, end_delimiter):
name_start = line.find(start_delimiter)
name_end = line.find(end_delimiter, name_start + 1)
name = line[name_start + 1 : name_end]
return name
names = [... | f = open('Log-A.strace')
lines = f.readlines()
term = ' read('
term2 = 'pipe'
term3 = 'tty'
def extract_name(line, start_delimiter, end_delimiter):
name_start = line.find(start_delimiter)
name_end = line.find(end_delimiter, name_start + 1)
name = line[name_start + 1:name_end]
return name
names = []
cou... |
TEMPLATE_SOURCE_TYPE = "TemplateSourceType"
# stairlight.yaml
STAIRLIGHT_CONFIG_FILE_PREFIX = "stairlight"
STAIRLIGHT_CONFIG_INCLUDE_SECTION = "Include"
STAIRLIGHT_CONFIG_EXCLUDE_SECTION = "Exclude"
STAIRLIGHT_CONFIG_SETTING_SECTION = "Settings"
DEFAULT_TABLE_PREFIX = "DefaultTablePrefix"
FILE_SYSTEM_PATH = "FileSyst... | template_source_type = 'TemplateSourceType'
stairlight_config_file_prefix = 'stairlight'
stairlight_config_include_section = 'Include'
stairlight_config_exclude_section = 'Exclude'
stairlight_config_setting_section = 'Settings'
default_table_prefix = 'DefaultTablePrefix'
file_system_path = 'FileSystemPath'
regex = 'Reg... |
#
# @lc app=leetcode id=696 lang=python3
#
# [696] Count Binary Substrings
#
# https://leetcode.com/problems/count-binary-substrings/description/
#
# algorithms
# Easy (61.31%)
# Total Accepted: 81.6K
# Total Submissions: 132.8K
# Testcase Example: '"00110011"'
#
# Give a binary string s, return the number of non-e... | class Solution:
def count_binary_substrings(self, s: str) -> int:
temp = []
current_length = 1
for i in range(1, len(s)):
if s[i] != s[i - 1]:
temp.append(current_length)
current_length = 1
else:
current_length += 1
... |
def reverse(s):
target = list(s)
for i in range(int(len(s) / 2)):
swap = target[i]
target[i] = target[len(s) - i - 1]
target[len(s) - i - 1] = swap
return ''.join(target)
if __name__ == '__main__':
s = 'abcdef'
print(reverse(s))
print(s[::-1])
| def reverse(s):
target = list(s)
for i in range(int(len(s) / 2)):
swap = target[i]
target[i] = target[len(s) - i - 1]
target[len(s) - i - 1] = swap
return ''.join(target)
if __name__ == '__main__':
s = 'abcdef'
print(reverse(s))
print(s[::-1]) |
# -*- coding: utf-8 -*-
def bubble_sort(arr):
""" Sorts the input array using the bubble sort method.
The idea is to raise each value to it's final position through successive
swaps.
Complexity: O(n^2) in time, O(n) in space (sorting is done in place)
Args:
arr: list of keys to sort
... | def bubble_sort(arr):
""" Sorts the input array using the bubble sort method.
The idea is to raise each value to it's final position through successive
swaps.
Complexity: O(n^2) in time, O(n) in space (sorting is done in place)
Args:
arr: list of keys to sort
Return:
list
... |
### Build String ###
class Solution1:
def backspaceCompare(self, S: str, T: str) -> bool:
def check(S):
S_new = []
for w in S:
if w != "#":
S_new.append(w)
elif len(S_new):
S_new.pop()
return... | class Solution1:
def backspace_compare(self, S: str, T: str) -> bool:
def check(S):
s_new = []
for w in S:
if w != '#':
S_new.append(w)
elif len(S_new):
S_new.pop()
return S_new
return check... |
class DiGraph:
def __init__(self):
self.nodes = dict()
self.edges = []
def copy(self):
H_ = __class__()
H_.add_edges_from(self.edges)
return H_
def __eq__(self, other):
return len(set(self.edges) ^ set(other.edges)) == 0
def __str__(self):
retu... | class Digraph:
def __init__(self):
self.nodes = dict()
self.edges = []
def copy(self):
h_ = __class__()
H_.add_edges_from(self.edges)
return H_
def __eq__(self, other):
return len(set(self.edges) ^ set(other.edges)) == 0
def __str__(self):
retu... |
'''
Problem 34
@author: Kevin Ji
'''
FACTORIALS = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
def factorial(number):
return FACTORIALS[number]
def is_curious_num(number):
temp_num = number
curious_sum = 0
while temp_num > 0:
curious_sum += factorial(temp_num % 10)
tem... | """
Problem 34
@author: Kevin Ji
"""
factorials = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
def factorial(number):
return FACTORIALS[number]
def is_curious_num(number):
temp_num = number
curious_sum = 0
while temp_num > 0:
curious_sum += factorial(temp_num % 10)
temp_nu... |
n= int(input("Digite o valor de n: "))
sub = n - 1
fat = n
while n != 0:
while sub != 1:
fat = fat * sub
sub = sub -1
print(fat)
| n = int(input('Digite o valor de n: '))
sub = n - 1
fat = n
while n != 0:
while sub != 1:
fat = fat * sub
sub = sub - 1
print(fat) |
class Neuron:
# TODO: Create abstraction of generic unsupervised neuron
pass
| class Neuron:
pass |
expected_output = {
'switch': {
"1": {
'system_temperature_state': 'ok',
}
}
}
| expected_output = {'switch': {'1': {'system_temperature_state': 'ok'}}} |
def addition(x: int, y: int) -> int:
"""Adds two integers together and returns the result."""
return x + y
if __name__ == '__main__':
a, b = 1, 2
result = addition(a, b)
print(result) | def addition(x: int, y: int) -> int:
"""Adds two integers together and returns the result."""
return x + y
if __name__ == '__main__':
(a, b) = (1, 2)
result = addition(a, b)
print(result) |
"""6.1.3 Circular Definition of Product ID
For each new defined Product ID (type /$defs/product_id_t) in items of relationships (/product_tree/relationships)
it must be tested that the product_id does not end up in a cirle.
The relevant path for this test is:
/product_tree/relationships[]/full_product_name/product... | """6.1.3 Circular Definition of Product ID
For each new defined Product ID (type /$defs/product_id_t) in items of relationships (/product_tree/relationships)
it must be tested that the product_id does not end up in a cirle.
The relevant path for this test is:
/product_tree/relationships[]/full_product_name/product... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.