content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
XM_OFF = 649.900675
YM_OFF = -25400.296854
ZM_OFF = 15786.311942
MM_00 = 0.990902
MM_01 = 0.006561
MM_02 = 0.006433
MM_10 = 0.006561
MM_11 = 0.978122
MM_12 = 0.006076
MM_20 = 0.006433
MM_21 = 0.006076
MM_22 = 0.914589
XA_OFF = 0.141424
YA_OFF = 0.380157
ZA_OFF = -0.192037
AC_00 = 100.154822
AC_01 = 0.327... | xm_off = 649.900675
ym_off = -25400.296854
zm_off = 15786.311942
mm_00 = 0.990902
mm_01 = 0.006561
mm_02 = 0.006433
mm_10 = 0.006561
mm_11 = 0.978122
mm_12 = 0.006076
mm_20 = 0.006433
mm_21 = 0.006076
mm_22 = 0.914589
xa_off = 0.141424
ya_off = 0.380157
za_off = -0.192037
ac_00 = 100.154822
ac_01 = 0.327635
ac_02 = -0.... |
# The mathematical modulo is used to calculate the remainder of the
# integer division. As an example, 102%25 is 2.
# Write a function that takes two values as parameters and returns
# the calculation of a modulo from the two values.
def mathematical_modulo(a, b):
''' divide a by b, return the remainder '''
re... | def mathematical_modulo(a, b):
""" divide a by b, return the remainder """
return a % b
print('Divide 100 by 25, remainder is: ', mathematical_modulo(100, 25))
print('Divide 102 by 25, remainder is: ', mathematical_modulo(102, 25)) |
class CohereError(Exception):
def __init__(
self,
message=None,
http_status=None,
headers=None,
) -> None:
super(CohereError, self).__init__(message)
self.message = message
self.http_status = http_status
self.headers = headers or {}
def __str... | class Cohereerror(Exception):
def __init__(self, message=None, http_status=None, headers=None) -> None:
super(CohereError, self).__init__(message)
self.message = message
self.http_status = http_status
self.headers = headers or {}
def __str__(self) -> str:
msg = self.mes... |
#
# PySNMP MIB module WWP-LEOS-PORT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-LEOS-PORT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:38:09 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_intersection, value_range_constraint, constraints_union, single_value_constraint, value_size_constraint) ... |
budget = int(input())
season = input()
fisherman = int(input())
rent_price = 0
if season == "Spring":
rent_price = 3000
elif season == "Summer" or season == "Autumn":
rent_price = 4200
elif season == "Winter":
rent_price = 2600
if fisherman <= 6:
rent_price = rent_price - (rent_price * 0.1)
elif 7 <= ... | budget = int(input())
season = input()
fisherman = int(input())
rent_price = 0
if season == 'Spring':
rent_price = 3000
elif season == 'Summer' or season == 'Autumn':
rent_price = 4200
elif season == 'Winter':
rent_price = 2600
if fisherman <= 6:
rent_price = rent_price - rent_price * 0.1
elif 7 <= fish... |
def pascal_triangle(n):
if n == 0:
return [1]
else:
row = [1]
line_behind = pascal_triangle(n - 1)
for r in range(len(line_behind) - 1):
row.append(line_behind[r] + line_behind[r + 1])
row += [1]
return row
print(pascal_triangle(4))
| def pascal_triangle(n):
if n == 0:
return [1]
else:
row = [1]
line_behind = pascal_triangle(n - 1)
for r in range(len(line_behind) - 1):
row.append(line_behind[r] + line_behind[r + 1])
row += [1]
return row
print(pascal_triangle(4)) |
class YesError(Exception):
pass
class YesUserCanceledError(YesError):
pass
class YesUnknownIssuerError(YesError):
pass
class YesAccountSelectionRequested(YesError):
redirect_uri: str
class YesOAuthError(YesError):
oauth_error: str
oauth_error_description: str
| class Yeserror(Exception):
pass
class Yesusercancelederror(YesError):
pass
class Yesunknownissuererror(YesError):
pass
class Yesaccountselectionrequested(YesError):
redirect_uri: str
class Yesoautherror(YesError):
oauth_error: str
oauth_error_description: str |
class Packtry(object):
@staticmethod
def print():
print('print')
| class Packtry(object):
@staticmethod
def print():
print('print') |
class Constants:
APPLICATION_TITLE = "Welcome to Kafka Local Setup Tool"
APPLICATION_WINDOW_TITLE = "Kafka Application Tool"
START_BUTTON = "Start"
STOP_BUTTON = "Stop"
CHOOSE_FOLDER = "Choose Folder"
SELECT_FOLDER = "Select the folder"
ZOOKEEPER_START_SERVER_PATH = "bin/zookeeper-server-sta... | class Constants:
application_title = 'Welcome to Kafka Local Setup Tool'
application_window_title = 'Kafka Application Tool'
start_button = 'Start'
stop_button = 'Stop'
choose_folder = 'Choose Folder'
select_folder = 'Select the folder'
zookeeper_start_server_path = 'bin/zookeeper-server-sta... |
class User():
def __init__(self, Name, LastName, ID, Mail, Phone):
self.Name = Name
self.LastName = LastName
self.ID = ID
self.Mail = Mail
self.Phone = Phone
def Describe_U(self):
s = "\nName: " + self.Name + " "+self.LastName + "\nID: "+self.ID
... | class User:
def __init__(self, Name, LastName, ID, Mail, Phone):
self.Name = Name
self.LastName = LastName
self.ID = ID
self.Mail = Mail
self.Phone = Phone
def describe_u(self):
s = '\nName: ' + self.Name + ' ' + self.LastName + '\nID: ' + self.ID
s += '... |
with open("data_100.vrt", "rb") as f_in:
with open("data_broken_header.vrt", "wb") as f_out:
f_out.write(f_in.read(2))
with open("data_missing_fields.vrt", "wb") as f_out:
f_out.write(f_in.read(4))
with open("data_broken_fields.vrt", "wb") as f_out:
f_out.write(f_in.read(6))
with... | with open('data_100.vrt', 'rb') as f_in:
with open('data_broken_header.vrt', 'wb') as f_out:
f_out.write(f_in.read(2))
with open('data_missing_fields.vrt', 'wb') as f_out:
f_out.write(f_in.read(4))
with open('data_broken_fields.vrt', 'wb') as f_out:
f_out.write(f_in.read(6))
with... |
n = int(input())
arr = [int(x) for x in input().split()]
if all(item < 0 for item in arr):
print(0)
else:
mx = 0
su = 0
for item in arr:
su += item
if su < 0:
su = 0
if su > mx:
mx = su
print(mx)
| n = int(input())
arr = [int(x) for x in input().split()]
if all((item < 0 for item in arr)):
print(0)
else:
mx = 0
su = 0
for item in arr:
su += item
if su < 0:
su = 0
if su > mx:
mx = su
print(mx) |
def flatten_list(mylist,index=0,newlist=[]):
if(index==len(mylist)):
return newlist
if(type(mylist[index])== list):
newlist.extend(flatten_list(mylist[index],0,[]))
else:
newlist.append(mylist[index])
return flatten_list(mylist,index+1,newlist)
mylist=[1,2,[3,4],[5,[6,7,... | def flatten_list(mylist, index=0, newlist=[]):
if index == len(mylist):
return newlist
if type(mylist[index]) == list:
newlist.extend(flatten_list(mylist[index], 0, []))
else:
newlist.append(mylist[index])
return flatten_list(mylist, index + 1, newlist)
mylist = [1, 2, [3, 4], [5... |
class Service(object):
'''Basic service interface.
If you want your own service, you should respect this interface
so that your service can be used by the looper.
'''
def __init__(self, cfg, comp, outdir):
'''
cfg: framework.config.Service object containing whatever parameters
... | class Service(object):
"""Basic service interface.
If you want your own service, you should respect this interface
so that your service can be used by the looper.
"""
def __init__(self, cfg, comp, outdir):
"""
cfg: framework.config.Service object containing whatever parameters
... |
def shorten_string(string : str, max_length : int):
shortened_name = string
if len(string) > max_length:
shortened_name = string[0:max_length] + '...'
return shortened_name | def shorten_string(string: str, max_length: int):
shortened_name = string
if len(string) > max_length:
shortened_name = string[0:max_length] + '...'
return shortened_name |
#!/usr/bin/env python3
#
# Prints to stdout very fast.
#
# Optimal time:
# time ./stress.py >/dev/null
# Actual time:
# time ./stress.py
for i in range(1000000):
print('\033[31;1m', i, '\033[0m')
| for i in range(1000000):
print('\x1b[31;1m', i, '\x1b[0m') |
GstreamerPackage ('gstreamer', 'gst-plugins-bad', '0.10.23', configure_flags = [
' --disable-gtk-doc',
' --with-plugins=quicktime',
' --disable-apexsink',
' --disable-bz2',
' --disable-metadata',
' --disable-oss4',
' --disable-theoradec'
])
| gstreamer_package('gstreamer', 'gst-plugins-bad', '0.10.23', configure_flags=[' --disable-gtk-doc', ' --with-plugins=quicktime', ' --disable-apexsink', ' --disable-bz2', ' --disable-metadata', ' --disable-oss4', ' --disable-theoradec']) |
n = int(input())
list_names = []
for i in range(n):
name = input()
list_names.append(name)
print(list_names) | n = int(input())
list_names = []
for i in range(n):
name = input()
list_names.append(name)
print(list_names) |
def mergeSort(myArray):
# print to show splitting
print("Splitting ",myArray)
# if array is greater than 1 then:
if len(myArray) > 1:
# mid, leftside, and right side of array stored as variables
mid = len(myArray)//2
lefthalf = myArray[:mid]
righthalf = myArray[m... | def merge_sort(myArray):
print('Splitting ', myArray)
if len(myArray) > 1:
mid = len(myArray) // 2
lefthalf = myArray[:mid]
righthalf = myArray[mid:]
merge_sort(lefthalf)
merge_sort(righthalf)
i = 0
j = 0
k = 0
while i < len(lefthalf) and j... |
#!/usr/bin/env python3
class Flower():
color = 'unknown'
rose = Flower()
rose.color = "red"
violet = Flower()
violet.color = "blue"
this_pun_is_for_you = "The honey is sweet and so are you"
print("Roses are {},".format(rose.color))
print("violets are {},".format(violet.color))
print(this_pun_is_for_you)
| class Flower:
color = 'unknown'
rose = flower()
rose.color = 'red'
violet = flower()
violet.color = 'blue'
this_pun_is_for_you = 'The honey is sweet and so are you'
print('Roses are {},'.format(rose.color))
print('violets are {},'.format(violet.color))
print(this_pun_is_for_you) |
def query(start, end):
if start < end:
print('M {} {}'.format(start, end), flush=True)
else:
print('M {} {}'.format(end, start), flush=True)
def swap(pos1, pos2):
if pos1 < pos2:
print('S {} {}'.format(pos1, pos2), flush=True)
else:
print('S {} {}'.format(pos2, pos1), fl... | def query(start, end):
if start < end:
print('M {} {}'.format(start, end), flush=True)
else:
print('M {} {}'.format(end, start), flush=True)
def swap(pos1, pos2):
if pos1 < pos2:
print('S {} {}'.format(pos1, pos2), flush=True)
else:
print('S {} {}'.format(pos2, pos1), fl... |
# -*- mode: python -*-
DOCUMENTATION = '''
---
module: group_by
short_description: Create Ansible groups based on facts
description:
- Use facts to create ad-hoc groups that can be used later in a playbook.
version_added: "0.9"
options:
key:
description:
- The variables whose values will be used as groups
... | documentation = '\n---\nmodule: group_by\nshort_description: Create Ansible groups based on facts\ndescription:\n - Use facts to create ad-hoc groups that can be used later in a playbook.\nversion_added: "0.9"\noptions:\n key:\n description:\n - The variables whose values will be used as groups\n required: t... |
#class that represents a resource
class Resource:
def __init__(self,name,id):
self.name = name
self.ID = id
self.aliases = [name]
#list of all the events this resource is involved in
#reflects when the resource worked on which object
#list of Event objects
s... | class Resource:
def __init__(self, name, id):
self.name = name
self.ID = id
self.aliases = [name]
self.events = []
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_id(self):
return self.ID
def add_ali... |
class Book():
def __init__(self, name) -> None:
self._name = name
def get_name(self):
return self._name
class BookShelf():
def __init__(self) -> None:
self._books: list[Book] = []
def append(self, book: Book):
self._books.append(book)
def get_book_at(self, index)... | class Book:
def __init__(self, name) -> None:
self._name = name
def get_name(self):
return self._name
class Bookshelf:
def __init__(self) -> None:
self._books: list[Book] = []
def append(self, book: Book):
self._books.append(book)
def get_book_at(self, index):
... |
# -*- coding: utf-8 -*-
def main():
s = input()
k = int(input())
count = 0
for si in s:
if si == '1':
count += 1
else:
break
if s[0] != '1':
print(s[0])
else:
if k <= count:
print(1)
else:
print(s[count])... | def main():
s = input()
k = int(input())
count = 0
for si in s:
if si == '1':
count += 1
else:
break
if s[0] != '1':
print(s[0])
elif k <= count:
print(1)
else:
print(s[count])
if __name__ == '__main__':
main() |
values = input("please fill value: ")
previous = []
result = []
def isAEIOU(value):
# value = str(value)
if value.upper() == 'A':
return True
elif value.upper() == 'E':
return True
elif value.upper() == 'I':
return True
elif value.upper() == 'O':
return True
e... | values = input('please fill value: ')
previous = []
result = []
def is_aeiou(value):
if value.upper() == 'A':
return True
elif value.upper() == 'E':
return True
elif value.upper() == 'I':
return True
elif value.upper() == 'O':
return True
elif value.upper() == 'U':
... |
__author__ = 'Shane'
class ClassToPass:
def __init__(self, int1=int(), int2=int()):
self.int1 = int1
self.int2 = int2
def gimmeTheSum(self, a, b) -> int:
return a + b | __author__ = 'Shane'
class Classtopass:
def __init__(self, int1=int(), int2=int()):
self.int1 = int1
self.int2 = int2
def gimme_the_sum(self, a, b) -> int:
return a + b |
N = input()
N = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
c = int(N[i]) + carry
n = int(N[i - 1])
if c < 5 or (c == 5 and n < 5):
result += c
carry = 0
else:
result += 10 - c
carry = 1
result += carry
print(result)
| n = input()
n = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
c = int(N[i]) + carry
n = int(N[i - 1])
if c < 5 or (c == 5 and n < 5):
result += c
carry = 0
else:
result += 10 - c
carry = 1
result += carry
print(result) |
class Demo:
def __init__(self, name):
self.name = name
print("Started!")
def hello(self):
print("Hey " + self.name + "!")
def goodbye(self):
print("Good-bye " + self.name + "!")
m = Demo("Alexa")
m.hello()
m.goodbye()
| class Demo:
def __init__(self, name):
self.name = name
print('Started!')
def hello(self):
print('Hey ' + self.name + '!')
def goodbye(self):
print('Good-bye ' + self.name + '!')
m = demo('Alexa')
m.hello()
m.goodbye() |
assert set([1,2]) == set([1,2])
assert not set([1,2,3]) == set([1,2])
assert set([1,2,3]) >= set([1,2])
assert set([1,2]) >= set([1,2])
assert not set([1,3]) >= set([1,2])
assert set([1,2,3]).issuperset(set([1,2]))
assert set([1,2]).issuperset(set([1,2]))
assert not set([1,3]).issuperset(set([1,2]))
assert set([1,2,... | assert set([1, 2]) == set([1, 2])
assert not set([1, 2, 3]) == set([1, 2])
assert set([1, 2, 3]) >= set([1, 2])
assert set([1, 2]) >= set([1, 2])
assert not set([1, 3]) >= set([1, 2])
assert set([1, 2, 3]).issuperset(set([1, 2]))
assert set([1, 2]).issuperset(set([1, 2]))
assert not set([1, 3]).issuperset(set([1, 2]))
... |
def makeGood(s: str) -> str:
stack = []
for i in range(len(s)):
if stack and ((s[i].isupper() and stack[-1] == s[i].lower()) or
(s[i].islower() and stack[-1] == s[i].upper())):
stack.pop()
else:
stack.append(s[i])
return ''.join(stack) | def make_good(s: str) -> str:
stack = []
for i in range(len(s)):
if stack and (s[i].isupper() and stack[-1] == s[i].lower() or (s[i].islower() and stack[-1] == s[i].upper())):
stack.pop()
else:
stack.append(s[i])
return ''.join(stack) |
#Given a binary tree, return all root-to-leaf paths.
# dfs+stack, bfs+queue, dfs recursively
class Solution:
def binaryTreePaths1(self, root):
if not root:
return []
res, stack = [], [(root, "")]
while stack:
node, ls = stack.pop()
if not node.left and no... | class Solution:
def binary_tree_paths1(self, root):
if not root:
return []
(res, stack) = ([], [(root, '')])
while stack:
(node, ls) = stack.pop()
if not node.left and (not node.right):
res.append(ls + str(node.val))
if node.ri... |
class Solution:
def diagonalSum(self, mat: List[List[int]]) -> int:
sum = 0
n = len(mat)
for i in range(n):
sum += mat[i][i]
if i != n - 1 - i:
sum += mat[i][n - 1 - i]
return sum
| class Solution:
def diagonal_sum(self, mat: List[List[int]]) -> int:
sum = 0
n = len(mat)
for i in range(n):
sum += mat[i][i]
if i != n - 1 - i:
sum += mat[i][n - 1 - i]
return sum |
def courses_list(user=None):
user = auth.user if not user else db(db.users.id==user).select().first()
if user.type_==1:
courses = db(db.registered_courses.professor==user.id).select(db.registered_courses.course_id)
courses = map(lambda x: x.course_id, courses)
else:
courses = db(db.student_registrations.... | def courses_list(user=None):
user = auth.user if not user else db(db.users.id == user).select().first()
if user.type_ == 1:
courses = db(db.registered_courses.professor == user.id).select(db.registered_courses.course_id)
courses = map(lambda x: x.course_id, courses)
else:
courses = d... |
def check_inners(rule):
if target in rules[rule]:
return 1
for bag in rules[rule]:
if check_inners(bag):
return 1
return 0
def part1():
count = 0
for rule in rules:
#print(rule)
if rule == target:
next
else:
count += check_... | def check_inners(rule):
if target in rules[rule]:
return 1
for bag in rules[rule]:
if check_inners(bag):
return 1
return 0
def part1():
count = 0
for rule in rules:
if rule == target:
next
else:
count += check_inners(rule)
prin... |
#practice using data structures and several algorithms
#compiled all classes into one
class Node:
def __init__(self, data):
self.data = data
self.next = None
class BinaryNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
self.val = data
class... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Binarynode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
self.val = data
class Graphnode:
def __init__(self, data, adj=[], visited=0):
s... |
# list(map(int, input().split()))
# int(input())
def main(X, Y):
cand = Y // 4
for i in range(cand, -1, -1):
if i * 4 + (X - i) * 2 == Y:
print('Yes')
exit()
else:
print('No')
if __name__ == '__main__':
X, Y = list(map(int, input().split()))
main(X, Y)
| def main(X, Y):
cand = Y // 4
for i in range(cand, -1, -1):
if i * 4 + (X - i) * 2 == Y:
print('Yes')
exit()
else:
print('No')
if __name__ == '__main__':
(x, y) = list(map(int, input().split()))
main(X, Y) |
class Solution:
def peakIndexInMountainArray(self, arr: List[int]) -> int:
count = 0
for i in range(len(arr)-1):
if arr[i] < arr[i+1]:
count += 1
return count
| class Solution:
def peak_index_in_mountain_array(self, arr: List[int]) -> int:
count = 0
for i in range(len(arr) - 1):
if arr[i] < arr[i + 1]:
count += 1
return count |
def mutate_kernel_size(kernel):
return None
def mutate_stride(stride):
return None
def mutate_padding(padding):
return None
def mutate_filter(filter):
return None | def mutate_kernel_size(kernel):
return None
def mutate_stride(stride):
return None
def mutate_padding(padding):
return None
def mutate_filter(filter):
return None |
# Check a number for prime....
a = int(input("Enter Number: "))
c = 0
for i in range(1, a+1):
if a % i == 0:
c += 1
if c == 2:
print("Prime")
else:
print("Not Prime")
| a = int(input('Enter Number: '))
c = 0
for i in range(1, a + 1):
if a % i == 0:
c += 1
if c == 2:
print('Prime')
else:
print('Not Prime') |
def readint(msg):
ok = False
value = 0
while True:
n1 = str(input(msg))
if n1.isnumeric():
value = int(n1)
ok = True
else:
print('\033[0;31mError! Please enter a valid number. \033[m')
if ok:
break
return value
n = readint... | def readint(msg):
ok = False
value = 0
while True:
n1 = str(input(msg))
if n1.isnumeric():
value = int(n1)
ok = True
else:
print('\x1b[0;31mError! Please enter a valid number. \x1b[m')
if ok:
break
return value
n = readint('... |
# https://leetcode.com/problems/keys-and-rooms/
class Solution:
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
return self.dfs(rooms, 0, set())
def dfs(self, rooms: List[List[int]], node: int, visited: set[int]) -> bool:
if node in visited:
return False
vis... | class Solution:
def can_visit_all_rooms(self, rooms: List[List[int]]) -> bool:
return self.dfs(rooms, 0, set())
def dfs(self, rooms: List[List[int]], node: int, visited: set[int]) -> bool:
if node in visited:
return False
visited.add(node)
if len(visited) == len(roo... |
c = float(input())
n = int(input())
t=0
for each in range(n):
h,w = list(map(float, input().split()))
t+= h*w*c
print("{:.8f}".format(t))
| c = float(input())
n = int(input())
t = 0
for each in range(n):
(h, w) = list(map(float, input().split()))
t += h * w * c
print('{:.8f}'.format(t)) |
class Dsu:
def __init__(self, n, ranked):
self.parents = [i for i in range(n)]
self.ranked = ranked
self.ranks = [0 for i in range(n)]
self.messages = [0 for i in range(n)]
self.read = [0 for i in range(n)]
def find(self, v):
if v == self.parents[v]:
... | class Dsu:
def __init__(self, n, ranked):
self.parents = [i for i in range(n)]
self.ranked = ranked
self.ranks = [0 for i in range(n)]
self.messages = [0 for i in range(n)]
self.read = [0 for i in range(n)]
def find(self, v):
if v == self.parents[v]:
... |
'''
A simple exercie sript to find out total pay by multiplying hours worked with
rate per hour.
'''
hr1 = input('Enter Hours: ')
rate1 = input('Enter Rate: ')
# made failure proof so if user inputs values other than number it won't crash
# and through an error. so the program will just quit with following warning
# ... | """
A simple exercie sript to find out total pay by multiplying hours worked with
rate per hour.
"""
hr1 = input('Enter Hours: ')
rate1 = input('Enter Rate: ')
try:
hrs = float(hr1)
rate = float(rate1)
except:
print('Failure: Enter Integers Only')
quit()
pay = float(hrs * rate)
print('Pay:', pay) |
spark = SparkSession \
.builder \
.appName("exercise_eighteen") \
.getOrCreate()
(df.select("id", "first_name", "last_name", "gender", "country", "birthdate", "salary")
.filter(df["country"] == "United States")
.orderBy(df["gender"].asc(), df["salary"].asc())
.show())
df.select("id", "first_name", "las... | spark = SparkSession.builder.appName('exercise_eighteen').getOrCreate()
df.select('id', 'first_name', 'last_name', 'gender', 'country', 'birthdate', 'salary').filter(df['country'] == 'United States').orderBy(df['gender'].asc(), df['salary'].asc()).show()
df.select('id', 'first_name', 'last_name', 'gender', 'country', '... |
#personaldetails
print("NAME: Jaskeerat Singh \nE-MAIL: jsing322@uwo.ca \nSLACK USERNAME: @jass \nBIOSTACK: Genomics \nTwitter Handle: @jsin")
def hamming_distance(a,b):
count=0
for i in range(len(a)):
if a[i] != b[i]:
count +=1
return count
print(hamming_distance('@jass','@jsin'))
| print('NAME: Jaskeerat Singh \nE-MAIL: jsing322@uwo.ca \nSLACK USERNAME: @jass \nBIOSTACK: Genomics \nTwitter Handle: @jsin')
def hamming_distance(a, b):
count = 0
for i in range(len(a)):
if a[i] != b[i]:
count += 1
return count
print(hamming_distance('@jass', '@jsin')) |
class Interface(object):
def __init__(self, name, idx, addrwidth, datawidth, lite=False):
self.name = name
self.idx = idx
self.datawidth = datawidth
self.addrwidth = addrwidth
self.lite = lite
def __repr__(self):
ret = []
ret.append('(')
ret.appen... | class Interface(object):
def __init__(self, name, idx, addrwidth, datawidth, lite=False):
self.name = name
self.idx = idx
self.datawidth = datawidth
self.addrwidth = addrwidth
self.lite = lite
def __repr__(self):
ret = []
ret.append('(')
ret.appe... |
{
'includes': [
'deps/common.gypi',
],
'variables': {
'gtest%': 0,
'gtest_static_libs%': [],
'glfw%': 0,
'glfw_static_libs%': [],
'mason_platform': 'osx',
},
'targets': [
{ 'target_name': 'geojsonvt',
'product_name': 'geojsonvt',
'type': 'static_library',
'standal... | {'includes': ['deps/common.gypi'], 'variables': {'gtest%': 0, 'gtest_static_libs%': [], 'glfw%': 0, 'glfw_static_libs%': [], 'mason_platform': 'osx'}, 'targets': [{'target_name': 'geojsonvt', 'product_name': 'geojsonvt', 'type': 'static_library', 'standalone_static_library': 1, 'include_dirs': ['include'], 'sources': [... |
print(True)
print(False)
print("True")
print("False")
print(5 == 1)
print(5 != 1)
print("Ham" == "Ham")
print("ham " == "ham")
print(5 == 5.0)
print(5 < 1)
print(5 >= 5)
print(5 < 8 <= 7) | print(True)
print(False)
print('True')
print('False')
print(5 == 1)
print(5 != 1)
print('Ham' == 'Ham')
print('ham ' == 'ham')
print(5 == 5.0)
print(5 < 1)
print(5 >= 5)
print(5 < 8 <= 7) |
class Animal:
def __init__(self, leg_count=4): # Constructor, initializes the new obj
# Print("constructor called!")
self.leg_count = leg_count
self.likes_food = True
def get_leg_count(self): # getter
return self.leg_count
def set_leg_count(self, leg_count): # setter
... | class Animal:
def __init__(self, leg_count=4):
self.leg_count = leg_count
self.likes_food = True
def get_leg_count(self):
return self.leg_count
def set_leg_count(self, leg_count):
self.leg_count = leg_count
cat = animal()
dog = animal()
centipede = animal(100)
rabbits = [a... |
a = float(input())
b = float(input())
peso_nota_a = 3.5
peso_nota_b = 7.5
media = (a * peso_nota_a + b * peso_nota_b) / (peso_nota_a + peso_nota_b)
print(f"MEDIA = {media:.5f}")
| a = float(input())
b = float(input())
peso_nota_a = 3.5
peso_nota_b = 7.5
media = (a * peso_nota_a + b * peso_nota_b) / (peso_nota_a + peso_nota_b)
print(f'MEDIA = {media:.5f}') |
class Node(object):
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __str__(self):
return str(self.data)
class AVL_Tree(object):
def height(self,root):
if not root:
return -1
else:
hl = self.hei... | class Node(object):
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __str__(self):
return str(self.data)
class Avl_Tree(object):
def height(self, root):
if not root:
return -1
else:
hl = self.height... |
# enter the Chocolate Rooom
ownername = "Daw Hla"
playerlives = 2
chocolate = 2
print("Welcome to the Chocolate Room. I am the owner of this sweet shop, my name is " + ownername)
print("You must answer this question.")
# add an input statement to ask the question on the next line and store the response in a variable c... | ownername = 'Daw Hla'
playerlives = 2
chocolate = 2
print('Welcome to the Chocolate Room. I am the owner of this sweet shop, my name is ' + ownername)
print('You must answer this question.')
print('Which of the following could be used as a good password')
print("1. Your pet's name. 2. Password123 3. A random collection... |
'''
https://leetcode.com/contest/weekly-contest-150/problems/as-far-from-land-as-possible/
'''
diffs = [(1, 0), (0, 1), (-1, 0), (0, -1)]
class Cell:
def __init__(self, x, y, dist=0):
self.dist = dist
self.x, self.y = x, y
class Solver:
def __init__(self, grid):
self.g = grid
s... | """
https://leetcode.com/contest/weekly-contest-150/problems/as-far-from-land-as-possible/
"""
diffs = [(1, 0), (0, 1), (-1, 0), (0, -1)]
class Cell:
def __init__(self, x, y, dist=0):
self.dist = dist
(self.x, self.y) = (x, y)
class Solver:
def __init__(self, grid):
self.g = grid
... |
f=str(input('Digite uma frase: ')).strip().upper()
print('Tem {} A na frase.'.format(f.count('A')))
print('O primeiro A esta em {} letra.'.format(f.find('A')+1))
print('O ultimo A esta em {} letra.'.format(f.rfind('A')+1))
| f = str(input('Digite uma frase: ')).strip().upper()
print('Tem {} A na frase.'.format(f.count('A')))
print('O primeiro A esta em {} letra.'.format(f.find('A') + 1))
print('O ultimo A esta em {} letra.'.format(f.rfind('A') + 1)) |
def start_room():
return "room1"
| def start_room():
return 'room1' |
node = S(input, "application/json")
childNode = node.prop("orderDetails")
property = childNode.prop("article")
value = property.stringValue()
| node = s(input, 'application/json')
child_node = node.prop('orderDetails')
property = childNode.prop('article')
value = property.stringValue() |
bit_list = [19, 17, 16, 18, 26, 24, 22, 21, 23, 25]
value = 5808
for bit in bit_list:
new_value = value + 2 ** bit
print(value, new_value-1)
value = new_value
| bit_list = [19, 17, 16, 18, 26, 24, 22, 21, 23, 25]
value = 5808
for bit in bit_list:
new_value = value + 2 ** bit
print(value, new_value - 1)
value = new_value |
class Solution:
# @return a string
def minWindow(self, S, T):
s = S
t = T
d = {}
td = {}
for c in t:
td[c] = td.get(c, 0) + 1
left = 0
right = 0
lefts = []
rights = []
for i, c in enumerate(s):
if c in td:
... | class Solution:
def min_window(self, S, T):
s = S
t = T
d = {}
td = {}
for c in t:
td[c] = td.get(c, 0) + 1
left = 0
right = 0
lefts = []
rights = []
for (i, c) in enumerate(s):
if c in td:
d[c] ... |
class Solution:
def canJump(self, nums: List[int]) -> bool:
if not nums or len(nums) == 0:
return False
target = len(nums) - 1
for i in range(len(nums) - 1, -1, -1):
if (nums[i] + i >= target):
target = i
return targe... | class Solution:
def can_jump(self, nums: List[int]) -> bool:
if not nums or len(nums) == 0:
return False
target = len(nums) - 1
for i in range(len(nums) - 1, -1, -1):
if nums[i] + i >= target:
target = i
return target == 0 |
print ("How old are you?"),
age = input()
print ("How tall are you?"),
height = input()
print ("How much do you weigh?"),
weight = input()
print ("So you are %r old, %r tall and %r heavy!"%(age,weight,height) )
| (print('How old are you?'),)
age = input()
(print('How tall are you?'),)
height = input()
(print('How much do you weigh?'),)
weight = input()
print('So you are %r old, %r tall and %r heavy!' % (age, weight, height)) |
a=int(input("enter number:"))
b=int(input("enter number:"))
c=int(input("enter number:"))
d=int(input("enter number:"))
total=a+b+c+d
average=total/4
print("total=",total)
print("average=",average)
| a = int(input('enter number:'))
b = int(input('enter number:'))
c = int(input('enter number:'))
d = int(input('enter number:'))
total = a + b + c + d
average = total / 4
print('total=', total)
print('average=', average) |
# test decorators
def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
# plain decorator
@dec
def f():
pass
# decorator with arg
@dec_arg('dec_arg')
def g():
pass
# decorator of class
@dec
class A:
pass
print("PASS") | def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f: f
@dec
def f():
pass
@dec_arg('dec_arg')
def g():
pass
@dec
class A:
pass
print('PASS') |
def read_E_matrix():
# # physical distance
# E = [[1, 1, 0, 0, 1, 1],
# [1, 1, 1, 1, 1, 0],
# [0, 1, 1, 1, 0, 0],
# [0, 1, 1, 1, 0, 0],
# [1, 1, 0, 0, 1, 0],
# [1, 0, 0, 0, 0, 1]
# ]
# fully connected
# E = [[1, 1, 1, 1, 1, 1],
# [1, 1, 1, 1... | def read_e_matrix():
e = [[1, 0, 1, 0, 1, 1], [0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1]]
return E
def graph_random(i):
if i == 6:
e = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 1], [0, 1, ... |
# color mixer
print("Red, blue, and yellow are primary colors.")
print()
# ask user to choose two primary colors to mix
color1 = input("Enter the primary color 1 (red,blue, or yellow): ")
color2 = input("Enter the primary color 2 (red,blue, or yellow): ")
if color1 == "red" and color2 == "blue":
print("The seco... | print('Red, blue, and yellow are primary colors.')
print()
color1 = input('Enter the primary color 1 (red,blue, or yellow): ')
color2 = input('Enter the primary color 2 (red,blue, or yellow): ')
if color1 == 'red' and color2 == 'blue':
print('The secondary color is purple.')
elif color1 == 'blue' and color2 == 'red... |
# Non-MacOS users can change it to Chrome/Firefox.
BROWSER = "Chrome" # can be Chrome/Safari/Firefox
MATCH_URL = "http://www.espncricinfo.com/series/8039/commentary/1144506/afghanistan-vs-england-24th-match-icc-cricket-world-cup-2019"
MESSAGE_BOX_CLASS_NAME = "_3u328"
SEND_BUTTON_CLASS_NAME = "_3M-N-"
# Match start ti... | browser = 'Chrome'
match_url = 'http://www.espncricinfo.com/series/8039/commentary/1144506/afghanistan-vs-england-24th-match-icc-cricket-world-cup-2019'
message_box_class_name = '_3u328'
send_button_class_name = '_3M-N-'
match_start_hours = 13
match_start_minutes = 30
match_end_hours = 23
match_end_minutes = 0
script_l... |
# REST API server related constants
USERNAME = "asdfg"
PASSWORD = "asdfg"
HOST = "http://127.0.0.1:8000"
AUTH_URL: str = f"{HOST}/auth/"
LOCATIONS_URL: str = f"{HOST}/api/locations/"
PANIC_URL: str = f"{HOST}/api/panic/"
# Format constants
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
PRECISION = 6
# Job scheduling cons... | username = 'asdfg'
password = 'asdfg'
host = 'http://127.0.0.1:8000'
auth_url: str = f'{HOST}/auth/'
locations_url: str = f'{HOST}/api/locations/'
panic_url: str = f'{HOST}/api/panic/'
datetime_format = '%Y-%m-%dT%H:%M:%S.%fZ'
precision = 6
time_panic = 1
time_no_panic = 5
time_check_panic = 3
log_file = 'gps_tracker.l... |
LOCK = False
RELEASE = True
VERSION = "19.99.0"
VERSION_AGAIN = "19.99.0"
STRICT_VERSION = "19.99.0"
UNRELATED_STRING = "apple"
| lock = False
release = True
version = '19.99.0'
version_again = '19.99.0'
strict_version = '19.99.0'
unrelated_string = 'apple' |
def dec_to_bin(dec):
bin_num = ''
while dec > 0:
bin_num = str(dec % 2) + bin_num
dec //= 2
return bin_num
if __name__ == "__main__":
dec_num = int(input())
print(dec_to_bin(dec_num))
| def dec_to_bin(dec):
bin_num = ''
while dec > 0:
bin_num = str(dec % 2) + bin_num
dec //= 2
return bin_num
if __name__ == '__main__':
dec_num = int(input())
print(dec_to_bin(dec_num)) |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# author: ouyangshaokun
# date:
print(44444444444)
print("fsfasfaa")
print(22222222)
print("fsfasfa")
print(123214)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(42342) | print(44444444444)
print('fsfasfaa')
print(22222222)
print('fsfasfa')
print(123214)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(42342) |
def add_elem(lst,ele):
lst.append(ele)
my_lst=[1,2,3]
print(my_lst)
add_elem(my_lst,5)
print(my_lst)
| def add_elem(lst, ele):
lst.append(ele)
my_lst = [1, 2, 3]
print(my_lst)
add_elem(my_lst, 5)
print(my_lst) |
print("Welcome to the GPA calculator")
print("Please enter all your letter grades, one per line.")
print("Enter a blank line to designate the end.")
# map from letter grade to point value
points = {
'A+': 4.0,
'A': 3.8,
'A-': 3.67,
'B+': 3.33,
'B': 3.0,
'B-': 2.67,
'C+': 2.33,
'C': 2.0,... | print('Welcome to the GPA calculator')
print('Please enter all your letter grades, one per line.')
print('Enter a blank line to designate the end.')
points = {'A+': 4.0, 'A': 3.8, 'A-': 3.67, 'B+': 3.33, 'B': 3.0, 'B-': 2.67, 'C+': 2.33, 'C': 2.0, 'C-': 1.67, 'D': 1.0, 'F': 0.0}
num_courses = 0
total_points = 0
done = ... |
class Logger(object):
def log(self, str):
print("Log: {}".format(str))
def error(self, str):
print("Error: {}".format(str))
def message(self, str):
print("Message: {}".format(str))
| class Logger(object):
def log(self, str):
print('Log: {}'.format(str))
def error(self, str):
print('Error: {}'.format(str))
def message(self, str):
print('Message: {}'.format(str)) |
FAIL_ON_ANY = 'any'
FAIL_ON_NEW = 'new'
# Identifies that a comment came from Lintly. This is used to aid in automatically
# deleting old PR comments/reviews. This is valid Markdown that is hidden from
# users in GitHub and GitLab.
LINTLY_IDENTIFIER = '<!-- Automatically posted by Lintly -->'
| fail_on_any = 'any'
fail_on_new = 'new'
lintly_identifier = '<!-- Automatically posted by Lintly -->' |
#
# PySNMP MIB module ADSL-LINE-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADSL-LINE-EXT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:13:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (adsl_line_conf_profile_entry, adsl_atur_perf_data_entry, adsl_line_alarm_conf_profile_entry, adsl_line_entry, adsl_atur_interval_entry, adsl_atuc_perf_data_entry, adsl_atuc_interval_entry, adsl_mib) = mibBuilder.importSymbols('ADSL-LINE-MIB', 'adslLineConfProfileEntry', 'adslAturPerfDataEntry', 'adslLineAlarmConfProfi... |
errors_find = {
'ServerError': {
'response': "Some thing went wrong. Please try after some time.",
'status': 500,
},
'BadRequest': {
'response': "Request must be valid",
'status': 400
},
}
#Code to store error types based on status code. | errors_find = {'ServerError': {'response': 'Some thing went wrong. Please try after some time.', 'status': 500}, 'BadRequest': {'response': 'Request must be valid', 'status': 400}} |
# fml_parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'bofx eofx newline tab interpolant lce rce string\n\tstart \t: \tbofx\n\t\t\t|\tstart eofx\n\t\t\t|\tstart code\n\t\n\tcode \t: \tnewline \n\t\n\tcode \t: \ttab\n\t\n\tcode \t: \tstring\n\t... | _tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'bofx eofx newline tab interpolant lce rce string\n\tstart \t: \tbofx\n\t\t\t|\tstart eofx\n\t\t\t|\tstart code\n\t\n\tcode \t: \tnewline \n\t\n\tcode \t: \ttab\n\t\n\tcode \t: \tstring\n\t\n\tcode \t: \tlce\n\t\n\tcode \t: \trce\n\t\n\tcode \t: \tinterpolant\n\t... |
RAW_SUBTOMOGRAMS = "volumes/raw"
LABELED_SUBTOMOGRAMS = "volumes/labels/"
PREDICTED_SEGMENTATION_SUBTOMOGRAMS = "volumes/predictions/"
CLUSTERING_LABELS = "volumes/cluster_labels/"
HDF_INTERNAL_PATH = "MDF/images/0/image"
| raw_subtomograms = 'volumes/raw'
labeled_subtomograms = 'volumes/labels/'
predicted_segmentation_subtomograms = 'volumes/predictions/'
clustering_labels = 'volumes/cluster_labels/'
hdf_internal_path = 'MDF/images/0/image' |
fp=open("list-11\\readme.txt","r")
sentence=fp.read()
words=sentence.split()
d = dict()
for c in words:
if c not in d:
d[c] = 1
else:
d[c] += 1
#dictionary values
a=d.values()
b=max(a)
for i in d:
if(d[i]==b):
print("frequent word:",i,";","count:",b) | fp = open('list-11\\readme.txt', 'r')
sentence = fp.read()
words = sentence.split()
d = dict()
for c in words:
if c not in d:
d[c] = 1
else:
d[c] += 1
a = d.values()
b = max(a)
for i in d:
if d[i] == b:
print('frequent word:', i, ';', 'count:', b) |
class fracao(object):
def __init__(self, num, den):
self.num = num
self.den = den
def somar_fracao(self, b):
f = fracao(self.num*b.den + b.num*self.den, self.den*b.den)
#f.num =
#f.den =
fracao.simplificar_fracao(f)
return f
def su... | class Fracao(object):
def __init__(self, num, den):
self.num = num
self.den = den
def somar_fracao(self, b):
f = fracao(self.num * b.den + b.num * self.den, self.den * b.den)
fracao.simplificar_fracao(f)
return f
def subtrair_fracao(self, b):
pass
def ... |
#!/usr/bin/python3
def inherits_from(obj, a_class):
if isinstance(obj, a_class) and type(obj) is not a_class:
return True
else:
return False
| def inherits_from(obj, a_class):
if isinstance(obj, a_class) and type(obj) is not a_class:
return True
else:
return False |
#
# A Rangoli Generator
#
# Author: Jeremy Pedersen
# Date: 2019-02-18
# License: "the unlicense" (Google it)
#
# Define letters for use in rangoli
alphabet = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split()
# Read in rangoli size
size = int(input("Set size of rangoli: "))
# Calculate maximum linewidth ... | alphabet = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split()
size = int(input('Set size of rangoli: '))
max_width = size * 2 - 1 + (size - 1) * 2
for i in list(range(size - 1, 0, -1)) + list(range(0, size)):
left = alphabet[1 + i:size]
left.reverse()
right = alphabet[0 + i:size]
center = '-'... |
calls = 0
def call():
global calls
calls += 1
def reset():
global calls
calls = 0
| calls = 0
def call():
global calls
calls += 1
def reset():
global calls
calls = 0 |
def iterPower(base,exp):
ans=1
while exp>0:
ans=ans*base
exp-=1
return ans
| def iter_power(base, exp):
ans = 1
while exp > 0:
ans = ans * base
exp -= 1
return ans |
#Environment related constants
ENV_PRODUCTION = 'PRODUCTION'
#Staging is used for testing by replicating the same production remote env
ENV_STAGING = 'STAGING'
#Development local env
ENV_DEVELOPMENT = 'DEV'
#Automated tests local env
ENV_TESTING = 'TEST'
ENVIRONMENT_CHOICES = [
ENV_PRODUCTION,
ENV_STAGING,
... | env_production = 'PRODUCTION'
env_staging = 'STAGING'
env_development = 'DEV'
env_testing = 'TEST'
environment_choices = [ENV_PRODUCTION, ENV_STAGING, ENV_DEVELOPMENT, ENV_TESTING]
page_size = 20
email_regexp = "^[a-zA-Z0-9'._-]+@[a-zA-Z0-9._-]+.[a-zA-Z]{2,6}$"
oauth2_scopes = 'https://www.googleapis.com/auth/userinfo.... |
name = input("Please enter your name:")
age = int(input("Please enter your age:"))
if type(name) == str:
if type(age) == int:
print(f"{name} you are {age} years old and you will be 100 after {100 - age} years")
else:
print("Please enter a valid number")
else:
print("please enter your name")... | name = input('Please enter your name:')
age = int(input('Please enter your age:'))
if type(name) == str:
if type(age) == int:
print(f'{name} you are {age} years old and you will be 100 after {100 - age} years')
else:
print('Please enter a valid number')
else:
print('please enter your name') |
seq = [0, 1]
def create_sequence(n):
global seq
if n == 0:
return []
elif n == 1:
return [0]
else:
seq = [0, 1]
for i in range(2, n):
seq.append(seq[-1] + seq[-2])
return seq
def locate(x):
if x in seq:
return f"The number - {x} is at in... | seq = [0, 1]
def create_sequence(n):
global seq
if n == 0:
return []
elif n == 1:
return [0]
else:
seq = [0, 1]
for i in range(2, n):
seq.append(seq[-1] + seq[-2])
return seq
def locate(x):
if x in seq:
return f'The number - {x} is at ind... |
d1 = dict()
print(d1) # DI1
print(type(d1))
d2 = dict({1:'a',2:'b',3:'c'})
print(d2) # DI2
d3 = dict([(1,"python"),(2,"is"),(3,"awesome")])
print(d3) # DI3
d4 = dict(((1,"python"),(2,"is"),(3,"awesome")))
print(d4) # DI4
d5 = dict({(1,"python"),(2,"is"),(3,"awesome")})
print(d5) # DI5
d6 = dict({[1,"python"],[2,"... | d1 = dict()
print(d1)
print(type(d1))
d2 = dict({1: 'a', 2: 'b', 3: 'c'})
print(d2)
d3 = dict([(1, 'python'), (2, 'is'), (3, 'awesome')])
print(d3)
d4 = dict(((1, 'python'), (2, 'is'), (3, 'awesome')))
print(d4)
d5 = dict({(1, 'python'), (2, 'is'), (3, 'awesome')})
print(d5)
d6 = dict({[1, 'python'], [2, 'is'], [3, 'aw... |
def parse_array(tokenstream):
_ = tokenstream.pop_next()
assert _ == "["
result = []
while True:
token = tokenstream.pop_next()
if token == "]": break
result.append(token)
return result
def parse_varfunction(tokenstream, identifier, scene):
identifier_type = tokenstream.pop_next()[1:-1]
params... | def parse_array(tokenstream):
_ = tokenstream.pop_next()
assert _ == '['
result = []
while True:
token = tokenstream.pop_next()
if token == ']':
break
result.append(token)
return result
def parse_varfunction(tokenstream, identifier, scene):
identifier_type = ... |
class Solution:
def lengthoflongestsubstring(self, s):
sls = len(set(s))
slen = len(s)
if slen < 1:
return 0
else:
max_len = 1
for i in range(slen):
for j in range(i+max_len+1, i+sls+1):
curr = s[i:j]
curr_l... | class Solution:
def lengthoflongestsubstring(self, s):
sls = len(set(s))
slen = len(s)
if slen < 1:
return 0
else:
max_len = 1
for i in range(slen):
for j in range(i + max_len + 1, i + sls + 1):
curr = s[i:j]
... |
print("Input: ",end="")
str = input()
def rev(str):
str = str.split(" ")
stack = []
for i in str:
stack.append(i)
while len(stack) > 0:
print(stack[-1], end = " ")
del stack[-1]
print("Output: ",end="")
rev(str)
| print('Input: ', end='')
str = input()
def rev(str):
str = str.split(' ')
stack = []
for i in str:
stack.append(i)
while len(stack) > 0:
print(stack[-1], end=' ')
del stack[-1]
print('Output: ', end='')
rev(str) |
def compare_reverse_number(A, B):
rev_A, rev_B = '', ''
for i in range(len(A) - 1, -1, -1):
rev_A += A[i]
for j in range(len(B) - 1, -1, -1):
rev_B += B[j]
if rev_A > rev_B:
return rev_A
else:
return rev_B
def main():
A, B = input().split()
answer = compare_r... | def compare_reverse_number(A, B):
(rev_a, rev_b) = ('', '')
for i in range(len(A) - 1, -1, -1):
rev_a += A[i]
for j in range(len(B) - 1, -1, -1):
rev_b += B[j]
if rev_A > rev_B:
return rev_A
else:
return rev_B
def main():
(a, b) = input().split()
answer = com... |
TASK = "task"
TASK_INSTANCE = "task_instance"
X = "X"
Y = "Y"
MAHOZ = "MAHOZ"
XY = f"{X}/{Y}"
| task = 'task'
task_instance = 'task_instance'
x = 'X'
y = 'Y'
mahoz = 'MAHOZ'
xy = f'{X}/{Y}' |
#
# PySNMP MIB module RDN-CABLE-SPECTRUM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RDN-CABLE-SPECTRUM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:54:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
t=int(input(""))
for i in range(0,t):
a,b=tuple(map(int,input("").split(" ")))
d=abs(a-b)
print((int(d/10))if(d%10==0)else(int((d+9)/10))) | t = int(input(''))
for i in range(0, t):
(a, b) = tuple(map(int, input('').split(' ')))
d = abs(a - b)
print(int(d / 10) if d % 10 == 0 else int((d + 9) / 10)) |
def repeat(n):
def decorator(func):
def wrapper(*args, **kwargs):
for _ in range(n):
func(*args, **kwargs)
return wrapper
return decorator
@repeat(4)
def say_hi():
print("Hello")
say_hi() | def repeat(n):
def decorator(func):
def wrapper(*args, **kwargs):
for _ in range(n):
func(*args, **kwargs)
return wrapper
return decorator
@repeat(4)
def say_hi():
print('Hello')
say_hi() |
if __name__ == "__main__":
my_tuple = (1, 2, 3)
print('my_tuple:', my_tuple)
a, b, c = my_tuple
print('a', a)
print('b', b)
print('c', c)
print('my_tuple[0]:', my_tuple[0])
print('my_tuple[1]:', my_tuple[1])
print('my_tuple[1:3]:', my_tuple[1:3])
# my_tuple[0] = 1 # error , tup... | if __name__ == '__main__':
my_tuple = (1, 2, 3)
print('my_tuple:', my_tuple)
(a, b, c) = my_tuple
print('a', a)
print('b', b)
print('c', c)
print('my_tuple[0]:', my_tuple[0])
print('my_tuple[1]:', my_tuple[1])
print('my_tuple[1:3]:', my_tuple[1:3]) |
#Bitonic sequence Dynamic programming
# Java code https://github.com/mission-peace/interview/blob/master/src/com/interview/dynamic/BitonicSequence.java
def bitonic_sequence( input ):
lis = [1]*len(input)
lds = [1]*len(input)
for i in range(1, len(input)):
for j in range(0, i):
if input[... | def bitonic_sequence(input):
lis = [1] * len(input)
lds = [1] * len(input)
for i in range(1, len(input)):
for j in range(0, i):
if input[i] > input[j]:
lis[i] = max(lis[i], lis[j] + 1)
for i in range(len(input) - 2, -1, -1):
for j in range(len(input) - 1, i, -... |
class API_Slack_Dialog():
def __init__(self):
self.title = ""
self.callback_id = ""
self.submit_label = "Submit"
self.state = "#3AA3E3"
self.elements = []
self.notify_on_cancel = True
# def add_button(self, name, text, value... | class Api_Slack_Dialog:
def __init__(self):
self.title = ''
self.callback_id = ''
self.submit_label = 'Submit'
self.state = '#3AA3E3'
self.elements = []
self.notify_on_cancel = True
def add_element_text(self, label, name, value=None, optional=False, hint=None, p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.