content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
if request.isInit:
lastVal = 0
elif request.isRead:
request.value = lastVal
elif request.isWrite:
lastVal = request.value
| if request.isInit:
last_val = 0
elif request.isRead:
request.value = lastVal
elif request.isWrite:
last_val = request.value |
'''input
4 2 3
1 4 2 3
2 3 2 3
3 1 10
3 3 4
3 3 4
1 3 3
3
3
'''
# -*- coding: utf-8 -*-
# SoundHound Inc. Programming Contest 2018 Spring
# Problem B
if __name__ == '__main__':
n, l, r = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(len(a)):
if a[i] < l:
... | """input
4 2 3
1 4 2 3
2 3 2 3
3 1 10
3 3 4
3 3 4
1 3 3
3
3
"""
if __name__ == '__main__':
(n, l, r) = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(len(a)):
if a[i] < l:
a[i] = l
if a[i] > r:
a[i] = r
print(' '.join(map(str... |
def cycle_fn(epoch, cycle_length=15, const_epochs=3, start=0.0, stop=1.0):
cur_epoch = epoch % cycle_length
grow_length = (cycle_length - const_epochs)
growing = cur_epoch < grow_length
rate = (stop - start)
if growing:
t = cur_epoch / float(grow_length)
return rate * t + start
... | def cycle_fn(epoch, cycle_length=15, const_epochs=3, start=0.0, stop=1.0):
cur_epoch = epoch % cycle_length
grow_length = cycle_length - const_epochs
growing = cur_epoch < grow_length
rate = stop - start
if growing:
t = cur_epoch / float(grow_length)
return rate * t + start
else:... |
x = 0
while x < 100:
print(x)
x += 1
| x = 0
while x < 100:
print(x)
x += 1 |
# -*- coding: utf-8 -*-
"""
module mixin - mixes classes to augment an existing class or creat a new one
http://c2.com/cgi/wiki?MixinsForPython
"""
def mixIn (base, addition):
"""
Mixes in place, i.e. the base class is modified.
Tags the class with a list of names of mixed members.
@param base : the base clas... | """
module mixin - mixes classes to augment an existing class or creat a new one
http://c2.com/cgi/wiki?MixinsForPython
"""
def mix_in(base, addition):
"""
Mixes in place, i.e. the base class is modified.
Tags the class with a list of names of mixed members.
@param base : the base class
@param addition :... |
firstName = 'John'
lastName = 'Smith'
#message = first + ' [' + last + '] is a coder'
message = f'{firstName} [{lastName}] is a coder.'
print(message) | first_name = 'John'
last_name = 'Smith'
message = f'{firstName} [{lastName}] is a coder.'
print(message) |
"""
Used to "iterate", or do something repeatedly, over an iterable.
The loop's body is run a predefined number of times.
"""
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
""" Creating Lists """
capitalized_cities = []
for city in cities:
capitalized_cities.append(city.title())
print(c... | """
Used to "iterate", or do something repeatedly, over an iterable.
The loop's body is run a predefined number of times.
"""
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
' Creating Lists '
capitalized_cities = []
for city in cities:
capitalized_cities.append(city.title())
print(capitalize... |
#list comprehension with if statement
numbers = list(range(1,11))
print(f" List of the numbers : {numbers}")
print(" 1st example ")
#by simple method
even_num = []
for i in numbers:
if i % 2 == 0:
even_num.append(i)
print(f"even number by list simple: {even_num} " )
#by list comprehension
even_num2 = [i ... | numbers = list(range(1, 11))
print(f' List of the numbers : {numbers}')
print(' 1st example ')
even_num = []
for i in numbers:
if i % 2 == 0:
even_num.append(i)
print(f'even number by list simple: {even_num} ')
even_num2 = [i for i in numbers if i % 2 == 0]
print(f'even number by list comprehension: {even_... |
dict = {}
uid =[]
name = []
age = []
n = int(input("Plz Enter Number of User U Want to Add: "))
i =0
while(i<n):
print()
print("Enter User ",i+1," Details")
uid.append(int(input("Enter User ID : ")))
name.append(input("Enter User Name : "))
age.append(int(input("Enter Your Age : ")))
... | dict = {}
uid = []
name = []
age = []
n = int(input('Plz Enter Number of User U Want to Add: '))
i = 0
while i < n:
print()
print('Enter User ', i + 1, ' Details')
uid.append(int(input('Enter User ID : ')))
name.append(input('Enter User Name : '))
age.append(int(input('Enter Your Age : ')))
i = ... |
CASSANDRA_VERSION = "3.11.11"
CASSANDRA_DEB_VERSION = CASSANDRA_VERSION + "_all"
DNSMASQ_VERSION = "2.80-1"
DNSMASQ_DEB_VERSION = DNSMASQ_VERSION + "+deb10u1"
ELASTICSEARCH_VERSION = "7.3.1"
ENVOY_VERSION = "1.15.5"
ERLANG_VERSION = "22.3.4.9-1"
ERLANG_DEB_VERSION = ERLANG_VERSION + ""
GERRIT_VERSION = "3.4.0"
GR... | cassandra_version = '3.11.11'
cassandra_deb_version = CASSANDRA_VERSION + '_all'
dnsmasq_version = '2.80-1'
dnsmasq_deb_version = DNSMASQ_VERSION + '+deb10u1'
elasticsearch_version = '7.3.1'
envoy_version = '1.15.5'
erlang_version = '22.3.4.9-1'
erlang_deb_version = ERLANG_VERSION + ''
gerrit_version = '3.4.0'
grafana_... |
DEFAULT_TRAINING_PARAMS = {
'max_depth': [5, 10, 15],
'minbucket': [1, 5, 10],
'hyperplanes': False,
}
| default_training_params = {'max_depth': [5, 10, 15], 'minbucket': [1, 5, 10], 'hyperplanes': False} |
def bubbleSort(arr):
for n in range(len(arr)-1,0,-1):
for k in range(n):
print(f" n {n} - k {k}")
if arr[k] > arr[k+1]:
temp = arr[k]
arr[k] = arr[k+1]
arr[k+1] = temp
return arr
print(bubbleSort([2,6,1,5,9,... | def bubble_sort(arr):
for n in range(len(arr) - 1, 0, -1):
for k in range(n):
print(f' n {n} - k {k}')
if arr[k] > arr[k + 1]:
temp = arr[k]
arr[k] = arr[k + 1]
arr[k + 1] = temp
return arr
print(bubble_sort([2, 6, 1, 5, 9, 4, 3])) |
S = input()
if ('N' in S) ^ ('S' in S) or ('W' in S) ^ ('E' in S):
print('No')
else:
print('Yes')
| s = input()
if ('N' in S) ^ ('S' in S) or ('W' in S) ^ ('E' in S):
print('No')
else:
print('Yes') |
long_string = lambda str: len(str) > 12
print(long_string("short"))
print(long_string("photosynthesis"))
| long_string = lambda str: len(str) > 12
print(long_string('short'))
print(long_string('photosynthesis')) |
"""
Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.
The k... | """
Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.
The k... |
word = input()
reverse_word = ''
for i in range(len(word) - 1, -1 , -1):
reverse_word += word[i]
print(reverse_word) | word = input()
reverse_word = ''
for i in range(len(word) - 1, -1, -1):
reverse_word += word[i]
print(reverse_word) |
__all__ = ['make_simple_coil', 'set_parameter', 'make_motion_component', 'get_parameter']
def make_simple_coil(doc, problem_id, array_values):
""" function to make a simple coil with 'ArrayOfValues' and 'ProblemID',
returns path to the coil
"""
coil = doc.makeSimpleCoil(problem_id, array_values)
r... | __all__ = ['make_simple_coil', 'set_parameter', 'make_motion_component', 'get_parameter']
def make_simple_coil(doc, problem_id, array_values):
""" function to make a simple coil with 'ArrayOfValues' and 'ProblemID',
returns path to the coil
"""
coil = doc.makeSimpleCoil(problem_id, array_values)
re... |
x = input()
while len(x)>0:
# print(x[:3] , x[3:])
if x[:3]=="144":
x = x[3:]
# print(x)
elif x[:2]=="14":
# print("2")
x = x[2:]
elif x[:1]=="1":
# print("3")
x = x[1:]
else:
print("NO")
break
else:
print("YES") | x = input()
while len(x) > 0:
if x[:3] == '144':
x = x[3:]
elif x[:2] == '14':
x = x[2:]
elif x[:1] == '1':
x = x[1:]
else:
print('NO')
break
else:
print('YES') |
while True:
n = int(input('Digite um valor: '))
r = str(input('Quer continuar? [S/N] '))
if r in 'Nn':
break
| while True:
n = int(input('Digite um valor: '))
r = str(input('Quer continuar? [S/N] '))
if r in 'Nn':
break |
number = int(input())
hours = int(input())
salary = float(input())
print("NUMBER =", number)
print("SALARY = U$ %.2f" % (hours * salary)) | number = int(input())
hours = int(input())
salary = float(input())
print('NUMBER =', number)
print('SALARY = U$ %.2f' % (hours * salary)) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
# 1st solution
# O(n) time | O(n) space
def countNodes(self, root: Optional[TreeNode]) -> int:
... | class Solution:
def count_nodes(self, root: Optional[TreeNode]) -> int:
if not root:
return 0
level = 0
stack = [root]
while stack:
count = 0
new_stack = []
for node in stack:
if node.left:
newStack.... |
print('H\'ello')
print(int('8') + 5)
print(8,5)
'''print('Hi',5)
print(3/4)'''
ex=print('Hey')
(x,y)=7,9
print(x,y)
add=5+9
sub=9-7
print(add/sub) | print("H'ello")
print(int('8') + 5)
print(8, 5)
"print('Hi',5)\nprint(3/4)"
ex = print('Hey')
(x, y) = (7, 9)
print(x, y)
add = 5 + 9
sub = 9 - 7
print(add / sub) |
# SCENARIO: Calculator - Do an addition
# GIVEN a running calculator app
type(Key.WIN + "calculator" + Key.ENTER)
wait("screen-home.png")
# AND '5' is displayed
click("button-5.png")
wait("1471901563200.png")
# WHEN I click on '+', '1', '='
click("1471902303880.png")
click("button-1.png")
click("button-equal.... | type(Key.WIN + 'calculator' + Key.ENTER)
wait('screen-home.png')
click('button-5.png')
wait('1471901563200.png')
click('1471902303880.png')
click('button-1.png')
click('button-equal.png')
wait('1471902151627.png') |
def calculate_score(set_of_tags_1, set_of_tags_2):
"""
:param set_of_tags_1: collection of unique strings
:param set_of_tags_2: same as above
:return: score based on hashcode scoring
"""
one_and_two = len(set_of_tags_1.intersection(set_of_tags_2))
one_not_two = len(set_of_tags_1.difference(s... | def calculate_score(set_of_tags_1, set_of_tags_2):
"""
:param set_of_tags_1: collection of unique strings
:param set_of_tags_2: same as above
:return: score based on hashcode scoring
"""
one_and_two = len(set_of_tags_1.intersection(set_of_tags_2))
one_not_two = len(set_of_tags_1.difference(s... |
"""
Configuration of 'memos' Flask app.
Edit to fit development or deployment environment.
"""
### Flask settings for ix
PORT=6291 # The port I run Flask on
SERVER_NAME = "ix.cs.uoregon.edu:{}".format(PORT)
DEBUG = False
### Flask settings for local machine
PORT=5000 # The port I run Flask on
DEBUG = Tru... | """
Configuration of 'memos' Flask app.
Edit to fit development or deployment environment.
"""
port = 6291
server_name = 'ix.cs.uoregon.edu:{}'.format(PORT)
debug = False
port = 5000
debug = True
mongo_port = 27017
mongo_pw = 'iremember'
mongo_user = 'memoproj'
mongo_url = 'mongodb://{}:{}@localhost:{}/memos'.format(M... |
class Solution(object):
def romanToInt(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) == 0:
return 0
else:
ref = {
"I" : 1,
"V" : 5,
"X" : 10,
"L" : 50,
"C" :... | class Solution(object):
def roman_to_int(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) == 0:
return 0
else:
ref = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
sum = ref[s[-1]]
for i in range(... |
def cc(M):
m, n = len(M), len(M[0])
ly, lx = [], []
for j in range(1, m):
for i in range(n):
if M[j][i] != M[j-1][i]:
ly.append(j)
break
for i in range(1, n):
for j in range(m):
if M[j][i] != M[j][i-1]:
lx.append(i)
... | def cc(M):
(m, n) = (len(M), len(M[0]))
(ly, lx) = ([], [])
for j in range(1, m):
for i in range(n):
if M[j][i] != M[j - 1][i]:
ly.append(j)
break
for i in range(1, n):
for j in range(m):
if M[j][i] != M[j][i - 1]:
l... |
"""
You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest
palindrome you can find by performing this transformation.
Example 1:
Input: s = 'aacecaaa', Output: 'aaacecaaa'
Example 2:
Input: s = 'abcd', Output: 'dcbabcd'
"""
"""
Seeing as we can only add l... | """
You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest
palindrome you can find by performing this transformation.
Example 1:
Input: s = 'aacecaaa', Output: 'aaacecaaa'
Example 2:
Input: s = 'abcd', Output: 'dcbabcd'
"""
'\nSeeing as we can only add let... |
# 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 th... | """
Script for generating a ROM contain un aligned 512 bit data words.
"""
bytes_in_bus_word = 64
misalignments = [(5, 4), (11, 63), (6, 0), (2, 30), (4, 0), (3, 55), (3, 0)]
misaligned_bus_words = []
aligned_bus_words = []
alignment_rom_values = []
alignment_rom_values2 = []
current_nibble = 0
for misalignment in misa... |
# TODO: include seccomp
# plat/nonplat files are only found on Android N (>8.0) as part of the Treble project
# Treble Reference: https://source.android.com/security/selinux/images/SELinux_Treble.pdf
SEPOLICY_FILES = [
'sepolicy',
'precompiled_sepolicy', # Treble devices (if it has been compiled)
... | sepolicy_files = ['sepolicy', 'precompiled_sepolicy', 'selinux_version', 'genfs_contexts', 'file_contexts', 'file_contexts.bin', 'plat_file_contexts', 'nonplat_file_contexts', 'vendor_file_contexts', 'seapp_contexts', 'plat_seapp_contexts', 'nonplat_seapp_contexts', 'vendor_seapp_contexts', 'property_contexts', 'plat_p... |
load(":pkg_config.bzl", "pkg_config_repository")
def add_repositories():
pkg_config_repository(
name = "glfw3",
spec = "glfw3",
includes = [
"GLFW/*.h",
],
)
pkg_config_repository(
name = "glew",
spec = "glew",
includes = [
"GL... | load(':pkg_config.bzl', 'pkg_config_repository')
def add_repositories():
pkg_config_repository(name='glfw3', spec='glfw3', includes=['GLFW/*.h'])
pkg_config_repository(name='glew', spec='glew', includes=['GL/glew.h'])
pkg_config_repository(name='libpng', spec='libpng', includes=['png.h', 'pngconf.h', 'pngl... |
ARTICLE_URL = 's/{slug}/'
ARTICLE_SAVE_AS = 's/{slug}/index.html'
DIRECT_TEMPLATES = (('index', 'tags', 'categories','archives', 'submit', 'search', '404'))
PAGE_URL = 'content/pages/{slug}.html'
PAGE_SAVE_AS = '{slug}.html'
PLUGIN_PATH = 'pelican-plugins'
PLUGINS = ['tipue_search']
RECENT_ARTICLES_COUNT = 5 ... | article_url = 's/{slug}/'
article_save_as = 's/{slug}/index.html'
direct_templates = ('index', 'tags', 'categories', 'archives', 'submit', 'search', '404')
page_url = 'content/pages/{slug}.html'
page_save_as = '{slug}.html'
plugin_path = 'pelican-plugins'
plugins = ['tipue_search']
recent_articles_count = 5
sitename = ... |
"""
39. Combination Sum
Medium
Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order.
The same number may be chosen from candidates an unlimited number of ... | """
39. Combination Sum
Medium
Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order.
The same number may be chosen from candidates an unlimited number of ... |
print("Lyrics of the Song 99 Bottles of Beer")
bottlecount = int(99)
confirm = int (1)
i = bottlecount
while(i>1):
print(f"{bottlecount} bottles of beer on the wall, {bottlecount} bottles of beer. \n")
bottlecount=bottlecount-1
i-=1
print(f"Take one down and pass it around, {bottlecount} bottles of beer... | print('Lyrics of the Song 99 Bottles of Beer')
bottlecount = int(99)
confirm = int(1)
i = bottlecount
while i > 1:
print(f'{bottlecount} bottles of beer on the wall, {bottlecount} bottles of beer. \n')
bottlecount = bottlecount - 1
i -= 1
print(f'Take one down and pass it around, {bottlecount} bottles o... |
#!/usr/bin/env python3
grid = [['x', 'x', 1, 'x', 'x'],
['x', 2, 3, 4, 'x'],
[ 5, 6, 7, 8, 9],
['x', 'A', 'B', 'C', 'x'],
['x', 'x', 'D', 'x', 'x']]
XMAX = len(grid[0]) - 1
YMAX = len(grid) - 1
x, y = 0, 2
nums = []
with open('input.txt') as f:
for line in f:
... | grid = [['x', 'x', 1, 'x', 'x'], ['x', 2, 3, 4, 'x'], [5, 6, 7, 8, 9], ['x', 'A', 'B', 'C', 'x'], ['x', 'x', 'D', 'x', 'x']]
xmax = len(grid[0]) - 1
ymax = len(grid) - 1
(x, y) = (0, 2)
nums = []
with open('input.txt') as f:
for line in f:
line = line.strip()
for direction in line:
nextx... |
#!/usr/bin/env python
"""
Tests for the `edx_course_team_api` models module.
"""
| """
Tests for the `edx_course_team_api` models module.
""" |
MAX_SEED=99999999
UNK="_UNK"
WORD_START="<w>"
WORD_END="</w>"
START_TAG=0
END_TAG=1
| max_seed = 99999999
unk = '_UNK'
word_start = '<w>'
word_end = '</w>'
start_tag = 0
end_tag = 1 |
#!/usr/bin/env python3
"""
ZOOM POLL VIEWER v1.0
RESPONSE CLASS
"""
class Response:
def __init__(self, student, session, poll):
self._student = student
self._session = session
self._poll = poll
self._answers = {}
# Structure of _answers = { <question_A> : [<choice_1>, ... | """
ZOOM POLL VIEWER v1.0
RESPONSE CLASS
"""
class Response:
def __init__(self, student, session, poll):
self._student = student
self._session = session
self._poll = poll
self._answers = {}
self._grade = None
def get_student(self):
return self._student
d... |
map = { '0': '0', '1': '1', '2': '2', '3': '3',
'4': '4', '5': '5', '6': '6', '7': '7',
'8': '8', '9': '9', 'a': 'd', 'b': 'e',
'c': 'f', 'd': 'a', 'e': 'b', 'f': 'c'}
input = ['4ab56415e91e6d5172ee79d9810e30be5da8af18',
'c19a3ca5251db76b221048ca0a445fc39ba576a0',
'fdb2c9cd514... | map = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', 'a': 'd', 'b': 'e', 'c': 'f', 'd': 'a', 'e': 'b', 'f': 'c'}
input = ['4ab56415e91e6d5172ee79d9810e30be5da8af18', 'c19a3ca5251db76b221048ca0a445fc39ba576a0', 'fdb2c9cd51459c2cc38c92af472f3275f8a6b393', '6d586747083... |
'''Basic calculator operations using python
Command Line Interface and Menu are in progress'''
print(" modules | CALCULATOR | INFO | ")
def arCalc():
''' printing Menu for Showning the available operations'''
print("PYTHON CALCULATOR 2.0 \n 1.Addition \n 2.Subtraction \n 3.Multiplication \n 4.Division")
... | """Basic calculator operations using python
Command Line Interface and Menu are in progress"""
print(' modules | CALCULATOR | INFO | ')
def ar_calc():
""" printing Menu for Showning the available operations"""
print('PYTHON CALCULATOR 2.0 \n 1.Addition \n 2.Subtraction \n 3.Multiplication \n 4.Division')
... |
'''
What is Matplotlib?
Matplotlib is a low level graph plotting library in python that serves as a visualization utility.
Matplotlib was created by John D. Hunter.
Matplotlib is open source and we can use it freely.
Matplotlib is mostly written in python, a few segments are written in C, Objective-C and Javascript ... | """
What is Matplotlib?
Matplotlib is a low level graph plotting library in python that serves as a visualization utility.
Matplotlib was created by John D. Hunter.
Matplotlib is open source and we can use it freely.
Matplotlib is mostly written in python, a few segments are written in C, Objective-C and Javascript ... |
load("@rules_python//python/pip_install:pip_repository.bzl", "whl_library")
all_requirements = ["@rules_pycross_pypi_deps_build//:pkg", "@rules_pycross_pypi_deps_dacite//:pkg", "@rules_pycross_pypi_deps_installer//:pkg", "@rules_pycross_pypi_deps_packaging//:pkg", "@rules_pycross_pypi_deps_pep517//:pkg", "@rules_pycro... | load('@rules_python//python/pip_install:pip_repository.bzl', 'whl_library')
all_requirements = ['@rules_pycross_pypi_deps_build//:pkg', '@rules_pycross_pypi_deps_dacite//:pkg', '@rules_pycross_pypi_deps_installer//:pkg', '@rules_pycross_pypi_deps_packaging//:pkg', '@rules_pycross_pypi_deps_pep517//:pkg', '@rules_pycros... |
def print_game(game):
print(' {} {} {} '.format('0', '1', '2'))
print('0 {} | {} | {} '.format(game[0][0], game[0][1], game[0][2]))
print(' --- --- --- --- ')
print('1 {} | {} | {} '.format(game[1][0], game[1][1], game[1][2]))
print(' --- --- --- --- ')
print('2 {} | {} | ... | def print_game(game):
print(' {} {} {} '.format('0', '1', '2'))
print('0 {} | {} | {} '.format(game[0][0], game[0][1], game[0][2]))
print(' --- --- --- --- ')
print('1 {} | {} | {} '.format(game[1][0], game[1][1], game[1][2]))
print(' --- --- --- --- ')
print('2 {} | {} | ... |
def selection_sort(lst):
for i in range(len(lst)-1):
smallestIndex = i
for j in range(i+1, len(lst)):
if lst[j] < lst[smallestIndex]:
smallestIndex = j
if smallestIndex != i:
lst[i], lst[smallestIndex] = lst[smallestIndex], lst[i]
return lst
list_1 = [4, 7, 1, 9, 2]
print(se... | def selection_sort(lst):
for i in range(len(lst) - 1):
smallest_index = i
for j in range(i + 1, len(lst)):
if lst[j] < lst[smallestIndex]:
smallest_index = j
if smallestIndex != i:
(lst[i], lst[smallestIndex]) = (lst[smallestIndex], lst[i])
return ... |
class MenuHelper:
def __init__(self, app):
self.app = app
def check_menu_items(self):
driver = self.app.driver
driver.find_element_by_partial_link_text('Dashboard').click()
driver.find_element_by_partial_link_text('Feedback').click()
driver.find_element_by_partial_link_t... | class Menuhelper:
def __init__(self, app):
self.app = app
def check_menu_items(self):
driver = self.app.driver
driver.find_element_by_partial_link_text('Dashboard').click()
driver.find_element_by_partial_link_text('Feedback').click()
driver.find_element_by_partial_link_... |
class RandomizedCollection:
"""
dict[val] = index of val in list v
when do removing, get any one index of the val to be deleted in v,
and denote it as idx, then swap it with the last val in v (if with
a different index), change index to idx and then pop it out
"""
def __init__(self):
self.v = []
... | class Randomizedcollection:
"""
dict[val] = index of val in list v
when do removing, get any one index of the val to be deleted in v,
and denote it as idx, then swap it with the last val in v (if with
a different index), change index to idx and then pop it out
"""
def __init__(self):
self.v... |
class TonLiteClientException(Exception):
pass
| class Tonliteclientexception(Exception):
pass |
"""Module for handling the different draw options for nodes. Used when creating a .dot file respresentation of the pipeline."""
_DEFAULT_DRAW_OPTIONS = {'shape': 'box', 'style': 'filled'}
_DEFAULT_AQP_OPTIONS = {'fillcolor': '#ffffff'}
_DEFAULT_VISQOL_OPTIONS = {'fillcolor': '#F0E442B3'}
_DEFAULT_PESQ_OPTIONS = {'fill... | """Module for handling the different draw options for nodes. Used when creating a .dot file respresentation of the pipeline."""
_default_draw_options = {'shape': 'box', 'style': 'filled'}
_default_aqp_options = {'fillcolor': '#ffffff'}
_default_visqol_options = {'fillcolor': '#F0E442B3'}
_default_pesq_options = {'fillc... |
class TelepatResponse:
def __init__(self, response):
self.status = response.status_code
self.json_data = response.json()
self.content = self.json_data["content"] if "content" in self.json_data else None
self.message = self.json_data["message"] if "message" in self.json_data else ""
... | class Telepatresponse:
def __init__(self, response):
self.status = response.status_code
self.json_data = response.json()
self.content = self.json_data['content'] if 'content' in self.json_data else None
self.message = self.json_data['message'] if 'message' in self.json_data else ''
... |
__author__ = 'Seqian Wang'
# A class for each scan session
class ScanSession:
def __init__(self, study, rid, scan_type, scan_date, scan_time,
s_identifier, i_identifier, download_folder, raw_folder, file_type, moved=0):
self.study = study
self.rid = rid
self.scan_type = s... | __author__ = 'Seqian Wang'
class Scansession:
def __init__(self, study, rid, scan_type, scan_date, scan_time, s_identifier, i_identifier, download_folder, raw_folder, file_type, moved=0):
self.study = study
self.rid = rid
self.scan_type = scan_type
self.scan_date = scan_date
... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
*****************************************
Author: zhlinh
Email: zhlinhng@gmail.com
Version: 0.0.1
Created Time: 2016-02-29
Last_modify: 2016-02-29
******************************************
'''
'''
Given a set of distinct integers, nums, re... | """
*****************************************
Author: zhlinh
Email: zhlinhng@gmail.com
Version: 0.0.1
Created Time: 2016-02-29
Last_modify: 2016-02-29
******************************************
"""
'\nGiven a set of distinct integers, nums, return all possible subsets.\n\nNote:\nElements in... |
def continuity(x):
yes = []
m = 0
d = 1
a = int(x ** (1 / 2))
yes.append(a)
while a != 2 * int(((x) ** (1 / 2))):
m = d * a - m
d = (x - m**2) / d
a = int(((x ** (1 / 2)) + m) / d)
yes.append(a)
return yes
def solutions(x):
if x in squares:
retur... | def continuity(x):
yes = []
m = 0
d = 1
a = int(x ** (1 / 2))
yes.append(a)
while a != 2 * int(x ** (1 / 2)):
m = d * a - m
d = (x - m ** 2) / d
a = int((x ** (1 / 2) + m) / d)
yes.append(a)
return yes
def solutions(x):
if x in squares:
return [0,... |
cases = [
('Push is observable here so no actions are enabled in the initial state',
'pmt -n 10 -s 1 Stack Observables'),
('Accepts Push(3) but not Pop(3) because here Push is observable, Pop controllable',
'pmt -n 10 -s 1 Stack Observables Scenarios'),
('Accepts both Push(3) and Pop(3) because ... | cases = [('Push is observable here so no actions are enabled in the initial state', 'pmt -n 10 -s 1 Stack Observables'), ('Accepts Push(3) but not Pop(3) because here Push is observable, Pop controllable', 'pmt -n 10 -s 1 Stack Observables Scenarios'), ('Accepts both Push(3) and Pop(3) because here both are observable,... |
def unit_convert(value, initial_unit, convert_to_unit):
units = {"cm": 0.01, "m": 1}
result = value*(units[initial_unit]/units[convert_to_unit])
string = f"{result}{convert_to_unit}"
print(string)
return string
def run_script(TEST=False):
while True:
try:
user_input = input(... | def unit_convert(value, initial_unit, convert_to_unit):
units = {'cm': 0.01, 'm': 1}
result = value * (units[initial_unit] / units[convert_to_unit])
string = f'{result}{convert_to_unit}'
print(string)
return string
def run_script(TEST=False):
while True:
try:
user_input = in... |
gitignore = [
"None",
"Actionscript.gitignore",
"Ada.gitignore",
"Agda.gitignore",
"Android.gitignore",
"AppEngine.gitignore",
"AppceleratorTitanium.gitignore",
"ArchLinuxPackages.gitignore",
"Autotools.gitignore",
"C++.gitignore",
"C.gitignore",
"CFWheels.gitignore",
"CMake.gitignore",
"CUDA.gitignore",
"CakePHP.gitig... | gitignore = ['None', 'Actionscript.gitignore', 'Ada.gitignore', 'Agda.gitignore', 'Android.gitignore', 'AppEngine.gitignore', 'AppceleratorTitanium.gitignore', 'ArchLinuxPackages.gitignore', 'Autotools.gitignore', 'C++.gitignore', 'C.gitignore', 'CFWheels.gitignore', 'CMake.gitignore', 'CUDA.gitignore', 'CakePHP.gitign... |
{
"targets": [
{
"target_name":"binding",
"sources":["png.c","jpeg.c","gif.c","imagesize.c","binding.c"],
'dependencies':['./binding.gyp:libhttp','./binding.gyp:libpng','./binding.gyp:libjpeg'],
},
{
"target_name":"libhttp",
"type":'static_library',
"sources":["http.c"]
},
{
"target_name"... | {'targets': [{'target_name': 'binding', 'sources': ['png.c', 'jpeg.c', 'gif.c', 'imagesize.c', 'binding.c'], 'dependencies': ['./binding.gyp:libhttp', './binding.gyp:libpng', './binding.gyp:libjpeg']}, {'target_name': 'libhttp', 'type': 'static_library', 'sources': ['http.c']}, {'target_name': 'libjpeg', 'type': 'stati... |
names = ['Bob', 'John', 'Steve', 'Dave']
# print(len(names))
# names += ['Robert']
# print(names)
# print(names[:3])
# print('Bob' in names)
# names.remove('Bob')
# names.remove('John')
# print(names)
# names.append('Don')
# print(names)
# names.extend(['Bob', 'John'])
# print(names)
# print(names)
# names[1] = 'Don'
#... | names = ['Bob', 'John', 'Steve', 'Dave']
namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']
namelist.append('pb122')
if 'pb122' in namelist:
print('Now I know pb122!')
namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']
namelist.extend('theelous3')
if input('Enter your name: ') in namelist:
print('... |
def duplicate(arr):
tortoise = arr[0]
hare = arr[0]
while True:
tortoise = arr[tortoise]
hare = arr[arr[hare]]
if tortoise == hare:
break
ptr1 = arr[0]
ptr2 = tortoise
while ptr1 != ptr2:
ptr1 = arr[ptr1]
ptr2 = arr[ptr2]
return ptr1
a... | def duplicate(arr):
tortoise = arr[0]
hare = arr[0]
while True:
tortoise = arr[tortoise]
hare = arr[arr[hare]]
if tortoise == hare:
break
ptr1 = arr[0]
ptr2 = tortoise
while ptr1 != ptr2:
ptr1 = arr[ptr1]
ptr2 = arr[ptr2]
return ptr1
arr = ... |
process_queue = []
total_wtime = 0
total_tat=0
ct = 0
n = int(input('Enter the total no of processes: '))
for i in range(n):
at = 0
bt = 0
process_queue.append([])#append a list object to the list
process_queue[i].append(int(input('Enter p_id: ')))
#at = int(input('Enter p_arrival: '))
process_q... | process_queue = []
total_wtime = 0
total_tat = 0
ct = 0
n = int(input('Enter the total no of processes: '))
for i in range(n):
at = 0
bt = 0
process_queue.append([])
process_queue[i].append(int(input('Enter p_id: ')))
process_queue[i].append(0)
bt = int(input('Enter p_bust: '))
process_queue... |
#
# PySNMP MIB module HUAWEI-LINE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-LINE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:46:05 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) ... |
#simple DB API testcase
class TestSimpleDBAPI(object):
def test_regular_selection(self, duckdb_cursor):
duckdb_cursor.execute('SELECT * FROM integers')
result = duckdb_cursor.fetchall()
assert result == [(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (None,)], "Incorrect resul... | class Testsimpledbapi(object):
def test_regular_selection(self, duckdb_cursor):
duckdb_cursor.execute('SELECT * FROM integers')
result = duckdb_cursor.fetchall()
assert result == [(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (None,)], 'Incorrect result returned' |
def enforce(*types):
def decorator(f):
def new_func(*args, **kwargs):
new_args = []
for (a, t) in zip(args, types):
new_args.append(t(a))
return f(*new_args, **kwargs)
return new_func
return decorator
@enforce(str, int)
def repeat_msg(msg,... | def enforce(*types):
def decorator(f):
def new_func(*args, **kwargs):
new_args = []
for (a, t) in zip(args, types):
new_args.append(t(a))
return f(*new_args, **kwargs)
return new_func
return decorator
@enforce(str, int)
def repeat_msg(msg, t... |
S = raw_input()
N = input()
for i in range(N):
Wi = raw_input()
c = 0
for x in Wi:
if x in S:
c+=1
else:
print("No")
break
if c == len(Wi):
print("Yes")
| s = raw_input()
n = input()
for i in range(N):
wi = raw_input()
c = 0
for x in Wi:
if x in S:
c += 1
else:
print('No')
break
if c == len(Wi):
print('Yes') |
TEXT_STYLE_INPUTS = (
'EmailInput',
'NumberInput',
'PasswordInput',
'TextInput',
'Textarea',
'URLInput',
)
| text_style_inputs = ('EmailInput', 'NumberInput', 'PasswordInput', 'TextInput', 'Textarea', 'URLInput') |
print ("Hello Python!")
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = "John" # A string
print (counter)
print (miles)
print (name)
print ()
# two examples of assignment which could cause confusion.
a=1
b=2
# in this case b is assigned a+b where a is the ... | print('Hello Python!')
counter = 100
miles = 1000.0
name = 'John'
print(counter)
print(miles)
print(name)
print()
a = 1
b = 2
(a, b) = (b, a + b)
print(a)
print(b)
print()
a = 1
b = 2
a = b
b = a + b
print(a)
print(b) |
zabbixapiurl = 'your zabbix url'
zabbixapilogin = 'your zabbix login'
zabbixapipasswd = 'your zabbix passwd'
ecopowerstart = '20:00:00'
ecopowerfinish = '09:00:00'
bridgepasswd = 'PyZabbixHuePasswd'
flickingperiod = 600
runinterval = 60
| zabbixapiurl = 'your zabbix url'
zabbixapilogin = 'your zabbix login'
zabbixapipasswd = 'your zabbix passwd'
ecopowerstart = '20:00:00'
ecopowerfinish = '09:00:00'
bridgepasswd = 'PyZabbixHuePasswd'
flickingperiod = 600
runinterval = 60 |
class Solution:
def letterCombinations(self, digits: str) -> List[str]:
d = {
2:"abc",
3:"def",
4:"ghi",
5:"jkl",
6:"mno",
7:"pqrs",
8:"tuv",
9:"wxyz"
}
if digits == "":
retu... | class Solution:
def letter_combinations(self, digits: str) -> List[str]:
d = {2: 'abc', 3: 'def', 4: 'ghi', 5: 'jkl', 6: 'mno', 7: 'pqrs', 8: 'tuv', 9: 'wxyz'}
if digits == '':
return []
ans = []
current = []
n = len(digits)
i = 0
def f(i):
... |
expected_output = {
'vrf': {
'default': {
'peer': {
'192.168.229.3': {
'connect_source_address': '192.168.100.1',
'elapsed_time': '00:00:09',
'nsr': {
'oper_downs': 0,
's... | expected_output = {'vrf': {'default': {'peer': {'192.168.229.3': {'connect_source_address': '192.168.100.1', 'elapsed_time': '00:00:09', 'nsr': {'oper_downs': 0, 'state': 'StopRead', 'up_down_time': '1d02h'}, 'password': 'None', 'peer_as': 65109, 'peer_name': '?', 'reset': '999', 'sa_filter': {'in': {'(S,G)': {'filter'... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reorderList(self, head) -> None:
"""
Do not return anything, modify head in-place instead.
"""
if head is None or... | class Solution:
def reorder_list(self, head) -> None:
"""
Do not return anything, modify head in-place instead.
"""
if head is None or head.next is None:
return head
memo = []
while head is not None:
memo.append(head)
head = head.n... |
up_alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
class Columnar:
def col_encrypt(plaintext, key):
plaintext = plaintext.replace(" ", "")
cipher = ""
num_key = []
key_index = []
table = []
row = []
for i in key.upper():
num_key.append(up_alpha.index(i))
... | up_alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
class Columnar:
def col_encrypt(plaintext, key):
plaintext = plaintext.replace(' ', '')
cipher = ''
num_key = []
key_index = []
table = []
row = []
for i in key.upper():
num_key.append(up_alpha.index(i))
... |
"""Initialization file for library."""
# pylint: disable=C0114
__version__ = "0.1.1"
| """Initialization file for library."""
__version__ = '0.1.1' |
def get_mwa_eor_freq(ch):
if ch > 704:
print('Maximum frequency channel is 704')
else:
return 138.915 + 0.08 * ch
| def get_mwa_eor_freq(ch):
if ch > 704:
print('Maximum frequency channel is 704')
else:
return 138.915 + 0.08 * ch |
#!/usr/bin/python3
def f(l1,l2):
n,m = len(l1),len(l1[0])
d = sum([l1[i][j]!=l2[i][j] for i in range(n) for j in range(m)])
if d*2 > n*m:
for i in range(n):
for j in range(m):
l1[i][j] = 'X' if l1[i][j]=='.' else '.'
return [''.join(l) for l in l1]
n,m = list(map... | def f(l1, l2):
(n, m) = (len(l1), len(l1[0]))
d = sum([l1[i][j] != l2[i][j] for i in range(n) for j in range(m)])
if d * 2 > n * m:
for i in range(n):
for j in range(m):
l1[i][j] = 'X' if l1[i][j] == '.' else '.'
return [''.join(l) for l in l1]
(n, m) = list(map(int, ... |
# Open doors and collect treasures.
peasant = hero.findByType("peasant")[0]
goldKey = peasant.findByType("gold-key")[0]
silverKey = peasant.findByType("silver-key")[0]
bronzeKey = peasant.findByType("bronze-key")[0]
# Command the peasant to pick up the gold and silver keys.
hero.command(peasant, "pickUpItem... | peasant = hero.findByType('peasant')[0]
gold_key = peasant.findByType('gold-key')[0]
silver_key = peasant.findByType('silver-key')[0]
bronze_key = peasant.findByType('bronze-key')[0]
hero.command(peasant, 'pickUpItem', goldKey)
hero.command(peasant, 'pickUpItem', silverKey)
hero.command(peasant, 'dropItem', {'x': 40, '... |
class Base:
"""The base object for all top-level client objects.
Parameters
----------
domain : one of rubicon.domain.*
The top-level object's domain instance.
config : rubicon.client.Config, optional
The config, which injects the repository to use.
"""
def __init__(self, d... | class Base:
"""The base object for all top-level client objects.
Parameters
----------
domain : one of rubicon.domain.*
The top-level object's domain instance.
config : rubicon.client.Config, optional
The config, which injects the repository to use.
"""
def __init__(self, d... |
"""Widget framework
"""
__all__ = \
[
'animators',
'assembly_view',
'axial_plot',
'colormaps.py',
'core_axial_view',
'core_view',
'core_view_plot',
'data_analysis_view',
'detector_multi_view',
'image_ops',
'intrapin_edits_assembly_view',
'intrapin_edits_plot',
'leg... | """Widget framework
"""
__all__ = ['animators', 'assembly_view', 'axial_plot', 'colormaps.py', 'core_axial_view', 'core_view', 'core_view_plot', 'data_analysis_view', 'detector_multi_view', 'image_ops', 'intrapin_edits_assembly_view', 'intrapin_edits_plot', 'legend3', 'plot_widget', 'raster_widget', 'subpin_len_plot', ... |
# using break to stop looping
is_learning = True
while is_learning:
print("I'm still learning")
break
# using other statement to stop looping
hungry = True
while hungry:
print("let's go eat")
hungry = False
'''
value that not 'false'
or you input other value except 'false' is equal to true
in this case, y... | is_learning = True
while is_learning:
print("I'm still learning")
break
hungry = True
while hungry:
print("let's go eat")
hungry = False
'\nvalue that not \'false\'\nor you input other value except \'false\' is equal to true\nin this case, you input \'yes\' or \'no\' to get always loop\n\nthirsty = True... |
class Keyboard:
def __init__(self):
self.keys = []
def add_key(self, key):
self.keys.append(key)
def get_key(self, index):
return [key for key in self.keys if key.index == index][0]
if __name__ == '__main__':
exit()
| class Keyboard:
def __init__(self):
self.keys = []
def add_key(self, key):
self.keys.append(key)
def get_key(self, index):
return [key for key in self.keys if key.index == index][0]
if __name__ == '__main__':
exit() |
# Write a Python function to find the maximum and minimum numbers from a sequence of numbers
List = [2, 4, 6, 41, 8, 10, 5]
max = 0
for i in List:
if i > max:
max = i
print(max) | list = [2, 4, 6, 41, 8, 10, 5]
max = 0
for i in List:
if i > max:
max = i
print(max) |
class Solution:
def judgeSquareSum(self, c):
"""
:type c: int
:rtype: bool
"""
right = int(c ** 0.5)
left = 0
while left <= right:
s = left * left + right * right
if s == c:
return True
elif s < c:
... | class Solution:
def judge_square_sum(self, c):
"""
:type c: int
:rtype: bool
"""
right = int(c ** 0.5)
left = 0
while left <= right:
s = left * left + right * right
if s == c:
return True
elif s < c:
... |
"""
entrada
capital-->float-->cap
salida
ganacia-->float-->g
intereses-->float-->i
"""
#entrada
cap=int(input("Digite capital invertido:"))
#cajanegra
i=cap*0.02
g=cap+i
#salidas
print("Ganancia despues de un mes:"+str(g))
| """
entrada
capital-->float-->cap
salida
ganacia-->float-->g
intereses-->float-->i
"""
cap = int(input('Digite capital invertido:'))
i = cap * 0.02
g = cap + i
print('Ganancia despues de un mes:' + str(g)) |
class StreetParking:
def freeParks(self, street):
c, l = 0, len(street)
for i in xrange(l):
if (
street[i] == "-"
and "B" not in street[i + 1 : i + 3]
and "S" not in street[max(i - 1, 0) : i + 2]
):
c += 1
... | class Streetparking:
def free_parks(self, street):
(c, l) = (0, len(street))
for i in xrange(l):
if street[i] == '-' and 'B' not in street[i + 1:i + 3] and ('S' not in street[max(i - 1, 0):i + 2]):
c += 1
return c |
# 1st brute-force solution
class Solution:
def maxProduct(self, nums: List[int]) -> int:
largest = nums[0]
for i in range(len(nums)):
curProduct = 1
for j in range(i, len(nums)):
curProduct *= nums[j]
largest = max(largest, curProduct)
... | class Solution:
def max_product(self, nums: List[int]) -> int:
largest = nums[0]
for i in range(len(nums)):
cur_product = 1
for j in range(i, len(nums)):
cur_product *= nums[j]
largest = max(largest, curProduct)
return largest
class S... |
# ls0 = "3, 4, 1, 5" # Lengths.
# # ls0 = "197, 97, 204, 108, 1, 29, 5, 71, 0, 50, 2, 255, 248, 78, 254, 63"
# ls1 = list(map(int, [c[:-1] if c[-1] == ',' else c for c in ls0.split()]))
# upper_bound = 5
# # upper_bound = 256
# xs = range(upper_bound)
# skip_size = 0
# pos = 0
# size = len(xs)
# assert a... | s = '3, 4, 1, 5'
s = '197, 97, 204, 108, 1, 29, 5, 71, 0, 50, 2, 255, 248, 78, 254, 63'
ls = list(map(lambda c: int(c) if c[-1] != ',' else int(c[:-1]), s.split()))
upper_bound = 5
upper_bound = 256
assert all((l <= upper_bound and l >= 0 for l in ls))
iota = 0
sigma = 0
xs = list(range(upper_bound))
zeta = len(xs)
for... |
'''
Project Euler Problem 18
Created: 2012-06-18
Author: William McDonald
'''
'''
IDEA:
For a given row, store the maximum sum to get to each element in that row by
using the maximum sums for the row above it.
e.g.
08
01 02
01 05 04
==>
09 10
01 04 05
==>
10 15 14
Now simp... | """
Project Euler Problem 18
Created: 2012-06-18
Author: William McDonald
"""
'\nIDEA:\nFor a given row, store the maximum sum to get to each element in that row by\nusing the maximum sums for the row above it.\n\ne.g.\n 08\n 01 02\n 01 05 04\n==>\n 09 10\n 01 04 05\n==>\n 10 15 14\n\nNow simply take t... |
def is_divisible_by_seven(x):
if x % 7 == 0:
return True
return False
def is_not_multiple_of_five(x):
while x > 0:
x -= 5
if x == 0:
return False
return True
result = [x for x in range(2000, 3201) if is_divisible_by_seven(x) and is_not_multiple_of_five(x)]
print(result)
| def is_divisible_by_seven(x):
if x % 7 == 0:
return True
return False
def is_not_multiple_of_five(x):
while x > 0:
x -= 5
if x == 0:
return False
return True
result = [x for x in range(2000, 3201) if is_divisible_by_seven(x) and is_not_multiple_of_five(x)]
print(result) |
#
# PySNMP MIB module CAT2600-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CAT2600-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:29:39 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, 0... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint, constraints_union) ... |
# ------------------------------
# 351. Android Unlock Patterns
#
# Description:
# https://leetcode.com/problems/android-unlock-patterns/description/
#
# Version: 1.0
# 11/11/17 by Jianfa
# ------------------------------
class Solution(object):
def numberOfPatterns(self, m, n):
"""
:type m: int
... | class Solution(object):
def number_of_patterns(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
res = 0
candidate = [i for i in range(1, 10)]
neighbour = {1: [2, 4, 5, 6, 8], 2: [1, 3, 4, 5, 6, 7, 9], 3: [2, 4, 5, 6, 8], 4: [1, 2, 3, 5, 7, 8... |
class Solution(object):
def canJump(self, nums):
cur, last = 0, 0
for i in nums:
last, cur = max(last, cur + i), cur + 1
if cur > last:
break
return True if cur == len(nums) else False
| class Solution(object):
def can_jump(self, nums):
(cur, last) = (0, 0)
for i in nums:
(last, cur) = (max(last, cur + i), cur + 1)
if cur > last:
break
return True if cur == len(nums) else False |
class Kite(object):
def __init__(self):
self.code = "kite"
def foo(self):
print("bar!")
| class Kite(object):
def __init__(self):
self.code = 'kite'
def foo(self):
print('bar!') |
def combinations(A):
"""
Just as an exercise to think about all combinations...
Powerset: all subsets of A, including empty set. Grab the first value in A,
then find all combinations for the remaining elements. The result is those
combinations plus those combinations prefixed with A[0].
"""
... | def combinations(A):
"""
Just as an exercise to think about all combinations...
Powerset: all subsets of A, including empty set. Grab the first value in A,
then find all combinations for the remaining elements. The result is those
combinations plus those combinations prefixed with A[0].
"""
... |
#
# PySNMP MIB module HPN-ICF-EPON-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-EPON-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:26:17 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ... |
# cribbing from matplotlib's approach
# by default DeprecationWarnings are ignored. Define our own class to make sure they are seen
__all__ = ["mpl_interactions_DeprecationWarning"]
class mpl_interactions_DeprecationWarning(DeprecationWarning):
"""A class for issuing deprecation warnings for mpl-interactions use... | __all__ = ['mpl_interactions_DeprecationWarning']
class Mpl_Interactions_Deprecationwarning(DeprecationWarning):
"""A class for issuing deprecation warnings for mpl-interactions users.""" |
class RepositoryNotFoundError(Exception):
pass
class MissingFilesError(Exception):
pass
| class Repositorynotfounderror(Exception):
pass
class Missingfileserror(Exception):
pass |
#LAB X
#Due Date: 04/07/2019, 11:59PM
########################################
#
# Name:
# Collaboration Statement:
#
########################################
# use the code for max heap
class MaxHeapPriorityQueue:
def __init__(self):
self.heap=[]
... | class Maxheappriorityqueue:
def __init__(self):
self.heap = []
self.size = 0
def __len__(self):
return len(self.heap)
def parent(self, index):
if index == 0 or index > len(self.heap) - 1:
return None
else:
return index - 1 >> 1
def left... |
"""
Datos de entrada
monto de la compra-->m-->float
nombre del cliente-->n-->str
Datos de salida
nombre del cliente-->n-->str
monto de la compra-->m-->float
monto a pagar-->mp-->float
descuento-->d-->float
"""
n=str(input("Ingrese el nombre del cliente "))
m=float(input("Digite el monto de la compra "))
if(m<=50000):... | """
Datos de entrada
monto de la compra-->m-->float
nombre del cliente-->n-->str
Datos de salida
nombre del cliente-->n-->str
monto de la compra-->m-->float
monto a pagar-->mp-->float
descuento-->d-->float
"""
n = str(input('Ingrese el nombre del cliente '))
m = float(input('Digite el monto de la compra '))
if m <= 500... |
"""
Module for processing and saving data
for processing in the API.
"""
selected = None
class Selection:
def __init__(self, objtype: str, data):
self.type = objtype
self.data = data | """
Module for processing and saving data
for processing in the API.
"""
selected = None
class Selection:
def __init__(self, objtype: str, data):
self.type = objtype
self.data = data |
"""Utils for handling biological data"""
genomeBuild2genMapSfx = { 'hg17': 'b35', 'hg18': 'b36', 'hg19': 'b37' }
| """Utils for handling biological data"""
genome_build2gen_map_sfx = {'hg17': 'b35', 'hg18': 'b36', 'hg19': 'b37'} |
#INCOMPLETE
to_sort = [230, 6, 3, 234565, 9, 13000]
def ins_sort():
for i in range(0, len(to_sort)):
j=i
for j in range(1, j+1):
if to_sort[j+1]<to_sort[j]:
val=to_sort[j+1]
to_sort[j+1]=to_sort[j]
to_sort[j]=val
print(to_sort) | to_sort = [230, 6, 3, 234565, 9, 13000]
def ins_sort():
for i in range(0, len(to_sort)):
j = i
for j in range(1, j + 1):
if to_sort[j + 1] < to_sort[j]:
val = to_sort[j + 1]
to_sort[j + 1] = to_sort[j]
to_sort[j] = val
print(to_sort) |
# *******************************************************************************************
# *******************************************************************************************
#
# Name : gencpu.py
# Purpose : Generate the CPU core (not B) in C
# Date : 27th August 2019
# Author : Paul Robson (paul@r... | def get_mnemonic(opcode):
m = ['ldr', 'str', 'add', 'sub', 'and', 'xor', 'ror', 'skb'][opcode >> 4]
m = m + ('f' if opcode & 8 != 0 else '')
m = m + ' ra,'
if opcode & 4 != 0:
m = m + '#nnn'
else:
m = m + ['rb', '(rb)', '-(rb)', '(rb)+'][opcode & 3]
return m
def effective_addres... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.