content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Solution:
def hIndex(self, citations: List[int]) -> int:
size = len(citations)
if len(citations) == 0 or citations == [0]:
return 0
# citations.sort()
for i in range(size):
if citations[i] >= size - i:
return size - i
return 0
| class Solution:
def h_index(self, citations: List[int]) -> int:
size = len(citations)
if len(citations) == 0 or citations == [0]:
return 0
for i in range(size):
if citations[i] >= size - i:
return size - i
return 0 |
# The generators both work on the same principle. To create its next value, a generator will take the previous value it produced, multiply it by a factor (generator A uses 16807; generator B uses 48271), and then keep the remainder of dividing that resulting product by 2147483647. That final remainder is the value it p... | (val_a, val_b) = (16807, 48271)
mod = 2147483647
num = 40000000
def generator(factor, val, M=1):
while True:
factor = factor * val % mod
if factor % M == 0:
yield (factor & 65535)
(a, b) = (input().split(' ').pop(), input().split(' ').pop())
(a, b) = (int(A), int(B))
(gen_a, gen_b) = (g... |
class Coords:
def __init__(self, x, y):
self.x = x
self.y = y
def __setattr__(self, attr, value):
if isinstance(value, int):
object.__setattr__(self, attr, value)
else:
raise ValueError("Coords should be ints")
| class Coords:
def __init__(self, x, y):
self.x = x
self.y = y
def __setattr__(self, attr, value):
if isinstance(value, int):
object.__setattr__(self, attr, value)
else:
raise value_error('Coords should be ints') |
START = 'START'
RUNNING = 'RUNNING'
WON = 'WON'
LOST ='LOST'
PAUSE ='PAUSE' | start = 'START'
running = 'RUNNING'
won = 'WON'
lost = 'LOST'
pause = 'PAUSE' |
# ======================================================================
#
# Brad T. Aagaard, U.S. Geological Survey
#
# ======================================================================
"""Top-level cartopy-extra-tiles module.
"""
__all__ = [
"cached_tiler",
"esri_tiles",
"stamen_tiles",
"scale_b... | """Top-level cartopy-extra-tiles module.
"""
__all__ = ['cached_tiler', 'esri_tiles', 'stamen_tiles', 'scale_bar'] |
class WorkflowJobRunningError(ValueError):
"""
Operation was prevented by a job running in the job queue
"""
| class Workflowjobrunningerror(ValueError):
"""
Operation was prevented by a job running in the job queue
""" |
model = "stages"
eval_occlusion = True
results_folder = "../../resources/results"
dataset_folder = "../../resources/datasets/linemod_occlusion"
mesh_folder = "../../resources/object_models"
weights_file = "../../resources/weights/linemod_occlusion_stages/model.ckpt-0"
| model = 'stages'
eval_occlusion = True
results_folder = '../../resources/results'
dataset_folder = '../../resources/datasets/linemod_occlusion'
mesh_folder = '../../resources/object_models'
weights_file = '../../resources/weights/linemod_occlusion_stages/model.ckpt-0' |
def avarage(numbers):
if not numbers:
return None
return sum(numbers)/len(numbers)
if __name__ == "__main__":
numbers = [1, 2, 3, 4, 5]
print(avarage(numbers))
| def avarage(numbers):
if not numbers:
return None
return sum(numbers) / len(numbers)
if __name__ == '__main__':
numbers = [1, 2, 3, 4, 5]
print(avarage(numbers)) |
class LinkedList:
def __init__(self, head, tail):
assert isinstance(tail, LinkedList) or isinstance(tail, Nil), TypeError(
'tail should either be a LinkedList or a Nil')
self._head, self._tail = head, tail
@property
def head(self):
return self._head
@property
d... | class Linkedlist:
def __init__(self, head, tail):
assert isinstance(tail, LinkedList) or isinstance(tail, Nil), type_error('tail should either be a LinkedList or a Nil')
(self._head, self._tail) = (head, tail)
@property
def head(self):
return self._head
@property
def tail(... |
"""
ID: tony_hu1
PROG: wormhole
LANG: PYTHON3
"""
def solve(x,y,next_on_right,N,partner):
total = 0
for i in range(1,N+1):
if partner[i] == 0:
break
if i == N:
if (cycle_exists(next_on_right,N,partner)):
return 1
else:
return 0
for j in r... | """
ID: tony_hu1
PROG: wormhole
LANG: PYTHON3
"""
def solve(x, y, next_on_right, N, partner):
total = 0
for i in range(1, N + 1):
if partner[i] == 0:
break
if i == N:
if cycle_exists(next_on_right, N, partner):
return 1
else:
return 0
for j in... |
# -*- coding: utf-8 -*-
# Author: Aris Tritas
# License: BSD 3-clause
class FeedbackGraph:
"""
A feedback graph shares the result of a loss function between nodes
(experts) according to dependence relations represented by the edges
between nodes. At each timestep, results are propagated to the observa... | class Feedbackgraph:
"""
A feedback graph shares the result of a loss function between nodes
(experts) according to dependence relations represented by the edges
between nodes. At each timestep, results are propagated to the observation
system defined by each expert.
"""
def __init__(self, ... |
def getMyNumber():
for i in range(1,1001):
#First Test: Does the number have 2 more digits?
if(len(str(i))>2):
#Second Test: Is it a prime?
factors=0
for j in range(1,i+1):
if(i%j==0):
factors+=1
if(factors==2):
... | def get_my_number():
for i in range(1, 1001):
if len(str(i)) > 2:
factors = 0
for j in range(1, i + 1):
if i % j == 0:
factors += 1
if factors == 2:
if str(i).find('1') == -1 and str(i).find('7') == -1:
... |
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
# O(M) time | O(1) space
# M is the number of cells in the matrix.
n = len(matrix)
for i in range(n // 2):
for j in r... | class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
n = len(matrix)
for i in range(n // 2):
for j in range(i, n - 1 - i):
self.elementsRotate(matrix, i, j)
def ele... |
favorite_fruit = "blueberry"
counter = 0
for character in favorite_fruit:
if character == "b":
counter = counter + 1
print(counter)
#2
def letter_check(word, letter):
for character in word:
if character == letter:
return True
return False | favorite_fruit = 'blueberry'
counter = 0
for character in favorite_fruit:
if character == 'b':
counter = counter + 1
print(counter)
def letter_check(word, letter):
for character in word:
if character == letter:
return True
return False |
# -*- coding: utf-8 -*-
'''
File name: code\twentytwo_foolish_primes\sol_239.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #239 :: Twenty-two Foolish Primes
#
# For more information see:
# https://projecteuler.net/problem=239
# Problem... | """
File name: code wentytwo_foolish_primes\\sol_239.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
"""
'\nA set of disks numbered 1 through 100 are placed in a line in random order.\n\nWhat is the probability that we have a partial derangement such that exactly 22 prime number d... |
class Node:
def __init__(self, data):
self.data = data
self.neighbors = []
self.visited = False
class Graph:
def __init__(self, grid, n, m):
self.nodes=dict()
for i in range(n):
for j in range(m):
if grid[i][j]==1:
current ... | class Node:
def __init__(self, data):
self.data = data
self.neighbors = []
self.visited = False
class Graph:
def __init__(self, grid, n, m):
self.nodes = dict()
for i in range(n):
for j in range(m):
if grid[i][j] == 1:
cu... |
bags = {}
def get_bag_definition(_line):
components = _line.split(' contain ')
return components[0].replace(' bags', '')
def get_contain_definition(_line):
components = _line.split(' contain ')
return components[1].replace(' bags', '').replace(' bag', '')
def get_gold_amount(_contain):
num = _... | bags = {}
def get_bag_definition(_line):
components = _line.split(' contain ')
return components[0].replace(' bags', '')
def get_contain_definition(_line):
components = _line.split(' contain ')
return components[1].replace(' bags', '').replace(' bag', '')
def get_gold_amount(_contain):
num = _con... |
#
# PySNMP MIB module XEDIA-POLICY-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XEDIA-POLICY-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:36:31 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, constraints_intersection, value_range_constraint, single_value_constraint) ... |
# colors
cl_black = (0, 0, 0)
cl_white = (255, 255, 255)
cl_red = (255, 0, 0)
cl_green = (0, 255, 0)
cl_blue = (0, 0, 255)
cl_off_black = (30, 30, 30)
size = SC_WIDTH, SC_HEIGHT = 1024, 640
FPS = 120
PADDLE_SPEED = 300 / FPS
| cl_black = (0, 0, 0)
cl_white = (255, 255, 255)
cl_red = (255, 0, 0)
cl_green = (0, 255, 0)
cl_blue = (0, 0, 255)
cl_off_black = (30, 30, 30)
size = (sc_width, sc_height) = (1024, 640)
fps = 120
paddle_speed = 300 / FPS |
print(str.format_map.__doc__)
print(vars.__doc__)
"""
https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p15_interpolating_variables_in_strings.html
""" | print(str.format_map.__doc__)
print(vars.__doc__)
'\n\n https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p15_interpolating_variables_in_strings.html\n' |
test = {
'name': 'Question 5',
'points': 4,
'suites': [
{
'cases': [
{
'answer': 'While score0 and score1 are both less than goal',
'choices': [
'While score0 and score1 are both less than goal',
'While at least one of score0 or score1 is less than goa... | test = {'name': 'Question 5', 'points': 4, 'suites': [{'cases': [{'answer': 'While score0 and score1 are both less than goal', 'choices': ['While score0 and score1 are both less than goal', 'While at least one of score0 or score1 is less than goal', 'While score0 is less than goal', 'While score1 is less than goal'], '... |
TOKENS = [
'NUMBER',
'PLUS',
'MINUS',
'MUL',
'DIV',
'OPEN_PARENS',
'CLOSE_PARENS',
'LSHIFT',
'RSHIFT',
'GT',
'LT'
] | tokens = ['NUMBER', 'PLUS', 'MINUS', 'MUL', 'DIV', 'OPEN_PARENS', 'CLOSE_PARENS', 'LSHIFT', 'RSHIFT', 'GT', 'LT'] |
# Source: Class and Instance Variables
# https://docs.python.org/2/tutorial/classes.html#class-and-instance-variables
'''
In the absence of any other superclasses that you specifically want to inherit from, the superclass should always be object,
which is the root of all classes in Python.
object is technically the ro... | """
In the absence of any other superclasses that you specifically want to inherit from, the superclass should always be object,
which is the root of all classes in Python.
object is technically the root of "new-style" classes in Python.
But, if you don't explicitly use the word object when creating classes, then Pytho... |
# Desired capabilities example file for Selenoid Grid
#
# The same result can be achieved on the command-line. Eg:
# --cap-string='{"selenoid:options": {"enableVNC": true}}'
capabilities = {
"acceptSslCerts": True,
"acceptInsecureCerts": True,
"screenResolution": "1920x1080x24",
"selenoid:options":... | capabilities = {'acceptSslCerts': True, 'acceptInsecureCerts': True, 'screenResolution': '1920x1080x24', 'selenoid:options': {'enableVNC': True, 'enableVideo': False}} |
# -*- coding: utf-8 -*-
"""
__author__ = "Ashiquzzaman Khan"
__desc__ = "Main Exe file to Run"
""" | """
__author__ = "Ashiquzzaman Khan"
__desc__ = "Main Exe file to Run"
""" |
CAKE = 45 * (1 - 0.125)
GOFRETTA = 5.80 * (1 - 0.125)
PANCAKE = 3.20 * (1 - 0.125)
campaign_days = int(input('Campaign days:'))
number_of_bakers = int(input('Number of bakers'))
number_of_cakes = int(input('Number of cakes'))
number_of_gofrettas = int(input('Number of gofrettas'))
number_of_pancakes = int(inpu... | cake = 45 * (1 - 0.125)
gofretta = 5.8 * (1 - 0.125)
pancake = 3.2 * (1 - 0.125)
campaign_days = int(input('Campaign days:'))
number_of_bakers = int(input('Number of bakers'))
number_of_cakes = int(input('Number of cakes'))
number_of_gofrettas = int(input('Number of gofrettas'))
number_of_pancakes = int(input('Number o... |
for _ in range(int(input())):
n=int(input())
lis=list(map(int,input().split()))
x=lis.count(1)
y=lis.count(2)
if(x%2!=0):
print("NO")
else:
if(y%2==0):
print("YES")
elif(x>=2):
print("YES")
else:
print("NO")
| for _ in range(int(input())):
n = int(input())
lis = list(map(int, input().split()))
x = lis.count(1)
y = lis.count(2)
if x % 2 != 0:
print('NO')
elif y % 2 == 0:
print('YES')
elif x >= 2:
print('YES')
else:
print('NO') |
#
# PySNMP MIB module ZHONE-COM-IP-FTP-CLIENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHONE-COM-IP-FTP-CLIENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:47:05 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, single_value_constraint, constraints_union, value_size_constraint) ... |
#!/usr/bin/python
# -*- coding:UTF-8 -*-
colors = ['black', 'white']
sizes = ['S', 'M', 'L']
if __name__ == '__main__':
for tshirt in ('%s %s' % (c, s) for c in colors for s in sizes):
print(tshirt)
| colors = ['black', 'white']
sizes = ['S', 'M', 'L']
if __name__ == '__main__':
for tshirt in ('%s %s' % (c, s) for c in colors for s in sizes):
print(tshirt) |
apiAttachAvailable = u'\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0418\u041f\u041f'
apiAttachNotAvailable = u'\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d'
apiAttachPendingAuthorization = u'\u041e\u0436\u... | api_attach_available = u'Возможно соединение через ИПП'
api_attach_not_available = u'Невозможен'
api_attach_pending_authorization = u'Ожидание авторизации'
api_attach_refused = u'Отказ'
api_attach_success = u'Удалось!'
api_attach_unknown = u'Неизвестно'
bud_deleted_friend = u'Удален из списка друзей'
bud_friend = u'Дру... |
def get_lines(input):
return [x.strip() for x in input.split("\n") if x.strip() != '']
PUZZLE_INPUT = get_lines(
"""
...#..#.
#..#...#
.....###
##....##
......##
........
.#......
##...#..
"""
)
EXAMPLE_INPUT = get_lines(
"""
.#.
..#
###
"""
)
TOTAL_CYCLES = 6
def is_active(cub... | def get_lines(input):
return [x.strip() for x in input.split('\n') if x.strip() != '']
puzzle_input = get_lines('\n\n ...#..#.\n #..#...#\n .....###\n ##....##\n ......##\n ........\n .#......\n ##...#..\n\n ')
example_input = get_lines('\n\n .#.\n ..#\n ###\n\n ')
total_cycles = 6
def is_active(cube)... |
def get_data():
return [
{
"label": "Documents",
"items": [
{
"type": "doctype",
"name": "eBay Order"
},
{
"type": "doctype",
"name": "eBay Sync Log"
... | def get_data():
return [{'label': 'Documents', 'items': [{'type': 'doctype', 'name': 'eBay Order'}, {'type': 'doctype', 'name': 'eBay Sync Log'}, {'type': 'doctype', 'name': 'Item Group eBay'}]}, {'label': 'Setup', 'items': [{'type': 'doctype', 'name': 'eBay Manager', 'onboard': 1}, {'type': 'doctype', 'name': 'eBa... |
class PhotoAlbum:
def __init__(self, pages):
self.pages = int(pages)
self.photos = [[] for _ in range(pages)]
self.page_capacity = 4
self.page_index = 0
@classmethod
def from_photos_count(cls, photos_count):
pages = int(photos_count) // 4
return cls(pages)
... | class Photoalbum:
def __init__(self, pages):
self.pages = int(pages)
self.photos = [[] for _ in range(pages)]
self.page_capacity = 4
self.page_index = 0
@classmethod
def from_photos_count(cls, photos_count):
pages = int(photos_count) // 4
return cls(pages)
... |
class myclass:
variable = 'blah'
myobjectx = myclass()
print(myobjectx.variable)
| class Myclass:
variable = 'blah'
myobjectx = myclass()
print(myobjectx.variable) |
class Grammar(object):
"""Grammar may represent any formal grammar.
"""
commutative_ops = ['+', '*', 'and', 'or']
def __init__(self, rules = None):
if rules is None:
rules = {}
self.rules = rules
def add_rule(self, rule):
assert(type(rule) == GrammarRule)
... | class Grammar(object):
"""Grammar may represent any formal grammar.
"""
commutative_ops = ['+', '*', 'and', 'or']
def __init__(self, rules=None):
if rules is None:
rules = {}
self.rules = rules
def add_rule(self, rule):
assert type(rule) == GrammarRule
s... |
'''
A leap year calculator:
every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
'''
def is_leap_year(year):
four = year % 4
hundred = year % 100
fourHundred = year % 400
if fourHundred == 0:
return Tr... | """
A leap year calculator:
every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
"""
def is_leap_year(year):
four = year % 4
hundred = year % 100
four_hundred = year % 400
if fourHundred == 0:
return Tru... |
'''
You can run all the examples below using:
pytest --doctest-modules -v exercises.py
'''
def combine_two_bytes(b1, b2):
'''
Combine two bytes into a word:
>>> hex(combine_two_bytes(0xff, 0x12))
'0xff12'
>>> hex(combine_two_bytes(0, 0x32))
'0x32'
'''
return 0
def split_ip_a... | """
You can run all the examples below using:
pytest --doctest-modules -v exercises.py
"""
def combine_two_bytes(b1, b2):
"""
Combine two bytes into a word:
>>> hex(combine_two_bytes(0xff, 0x12))
'0xff12'
>>> hex(combine_two_bytes(0, 0x32))
'0x32'
"""
return 0
def split_ip_addre... |
def Main(a, b, c, d):
"""
:param a:
:param b:
:param c:
:param d:
:return:
"""
return a + b - c * d
| def main(a, b, c, d):
"""
:param a:
:param b:
:param c:
:param d:
:return:
"""
return a + b - c * d |
""" write a in-elif-else chain that determines a person's
stage of life. Set a value for the variable age """
age = int(input('What\'s your age:\n'))
if age < 2:
print('baby')
elif age == 2 or age < 4:
print('toddler')
elif age == 4 or age < 13:
print('kid')
elif age == 13 or age < 20:
print('teenager... | """ write a in-elif-else chain that determines a person's
stage of life. Set a value for the variable age """
age = int(input("What's your age:\n"))
if age < 2:
print('baby')
elif age == 2 or age < 4:
print('toddler')
elif age == 4 or age < 13:
print('kid')
elif age == 13 or age < 20:
print('teenager')
... |
def findSingle(arr):
res = arr[0]
for i in arr[1::]:
res = res^arr[i]
return res
arr = [7, 3, 5, 4, 5, 3, 4]
print(findSingle(arr)) | def find_single(arr):
res = arr[0]
for i in arr[1:]:
res = res ^ arr[i]
return res
arr = [7, 3, 5, 4, 5, 3, 4]
print(find_single(arr)) |
N = int(input())
string = list(input())
final = list(input())
counter = 0
first_index = 0
last_index = 0
for x in range(N-1):
if string[x] != final[x] and x > first_index:
last_index = x
if string[x+1] != final[x+1]:
continue
else:
for y in range(first... | n = int(input())
string = list(input())
final = list(input())
counter = 0
first_index = 0
last_index = 0
for x in range(N - 1):
if string[x] != final[x] and x > first_index:
last_index = x
if string[x + 1] != final[x + 1]:
continue
else:
for y in range(first_index, la... |
class Range:
""" A range of parameter values
that can be passed to :class:`Control`.
Arguments:
vmin (float, optional):
Minimum value for this parameter (default 0).
vmax (float, optional):
Maximum value for this parameter (default 1).
vdef (float, optional)... | class Range:
""" A range of parameter values
that can be passed to :class:`Control`.
Arguments:
vmin (float, optional):
Minimum value for this parameter (default 0).
vmax (float, optional):
Maximum value for this parameter (default 1).
vdef (float, optional):... |
'''
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).
Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor,
and you can either start from the step with index 0, or the step with index 1.
'''
class Solution:
... | """
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).
Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor,
and you can either start from the step with index 0, or the step with index 1.
"""
class Solution:
... |
"""Constants for the Strava Home Assistant integration."""
DOMAIN = "ha_strava"
# OAuth Specs
AUTH_CALLBACK_PATH = "/auth/external/callback"
OAUTH2_AUTHORIZE = "https://www.strava.com/oauth/authorize"
OAUTH2_TOKEN = "https://www.strava.com/oauth/token"
# Camera Config
CONF_PHOTOS = "conf_photos"
CONF_PHOTOS_ENTITY =... | """Constants for the Strava Home Assistant integration."""
domain = 'ha_strava'
auth_callback_path = '/auth/external/callback'
oauth2_authorize = 'https://www.strava.com/oauth/authorize'
oauth2_token = 'https://www.strava.com/oauth/token'
conf_photos = 'conf_photos'
conf_photos_entity = 'strava_cam'
config_img_size = 5... |
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 21 01:37:26 2020
@author: abcdk
"""
sweet = "cookies"
savory = "pickles"
num = 100
print (num, savory, "and", num, sweet)
print("I choose the", sweet.upper())
| """
Created on Tue Apr 21 01:37:26 2020
@author: abcdk
"""
sweet = 'cookies'
savory = 'pickles'
num = 100
print(num, savory, 'and', num, sweet)
print('I choose the', sweet.upper()) |
def replace_elements_with_greatest_on_right(arr):
for i in range(len(arr) - 1):
arr[i] = max(arr[i + 1:])
arr[-1] = -1
return arr | def replace_elements_with_greatest_on_right(arr):
for i in range(len(arr) - 1):
arr[i] = max(arr[i + 1:])
arr[-1] = -1
return arr |
# Write a function that returns the boolean True if the given number is zero, the string "positive" if the number is greater than zero or the string "negative" if it's smaller than zero.
def equilbrium(x):
# if x > 0:
# return "positive"
# elif x < 0:
# return "negative"
# else:
# return True
return "posit... | def equilbrium(x):
return 'positive' if x > 0 else 'negative' if x < 0 else True |
#!/usr/bin/env python3
n = 10
largest = int(input())
i = 0
while i < n - 1:
v = int(input())
if largest < v:
largest = v
i = i + 1
print(largest)
| n = 10
largest = int(input())
i = 0
while i < n - 1:
v = int(input())
if largest < v:
largest = v
i = i + 1
print(largest) |
N, S, D = [int(n) for n in input().split()]
ans = 'No'
for i in range(N):
x, y = [int(n) for n in input().split()]
if x >= S or y <= D:
continue
else:
ans = 'Yes'
print(ans) | (n, s, d) = [int(n) for n in input().split()]
ans = 'No'
for i in range(N):
(x, y) = [int(n) for n in input().split()]
if x >= S or y <= D:
continue
else:
ans = 'Yes'
print(ans) |
"""
Radix Sort
Time Complexity: O(nk + n).
n is the size of input list and k is the digit length of the number.
"""
def radix_sort(arr, simulation=False):
position = 1
max_number = max(arr)
iteration = 0
if simulation:
print("iteration", iteration, ":", *arr)
while position <= max_number... | """
Radix Sort
Time Complexity: O(nk + n).
n is the size of input list and k is the digit length of the number.
"""
def radix_sort(arr, simulation=False):
position = 1
max_number = max(arr)
iteration = 0
if simulation:
print('iteration', iteration, ':', *arr)
while position <= max_number:
... |
class MeboError(Exception):
pass
class MeboCommandError(MeboError):
pass
class MeboRequestError(MeboError):
pass
class MeboConnectionError(MeboError):
pass
class MeboConfigurationError(MeboError):
pass
class MeboDiscoveryError(MeboError):
pass
| class Meboerror(Exception):
pass
class Mebocommanderror(MeboError):
pass
class Meborequesterror(MeboError):
pass
class Meboconnectionerror(MeboError):
pass
class Meboconfigurationerror(MeboError):
pass
class Mebodiscoveryerror(MeboError):
pass |
n=int(input(""))
arr=[]
def countx(list):
x,y=0,0
for i in range(0,len(list)-1,2):
if(list[i]==1):
x+=1
for i in range(1,len(list),2):
if(list[i]==1):
y+=1
return [x,y]
for i in range(n):
b=int(input(""))
c=input("").split()
for i in range(len(c)):
c[i]=int(c[i])
arr.append(c)
... | n = int(input(''))
arr = []
def countx(list):
(x, y) = (0, 0)
for i in range(0, len(list) - 1, 2):
if list[i] == 1:
x += 1
for i in range(1, len(list), 2):
if list[i] == 1:
y += 1
return [x, y]
for i in range(n):
b = int(input(''))
c = input('').split()
... |
class Generic(Exception):
def __init__(self, message: str):
self.message = message
self.data = {}
def add_details(self, message: str):
"""Add details to the error message.
Keyword arguments:
message -- details to be concatenated
Return value:
returns se... | class Generic(Exception):
def __init__(self, message: str):
self.message = message
self.data = {}
def add_details(self, message: str):
"""Add details to the error message.
Keyword arguments:
message -- details to be concatenated
Return value:
returns s... |
class Animal:
def __init__(self,nombre,duracion_de_vida,peso,ecosistema):
self.nombre= nombre
self.duracion_de_vida = duracion_de_vida
self.peso = peso
self.ecosistema = ecosistema
print("Creamos un animal")
def describe(self):
print("Soy un animal del t... | class Animal:
def __init__(self, nombre, duracion_de_vida, peso, ecosistema):
self.nombre = nombre
self.duracion_de_vida = duracion_de_vida
self.peso = peso
self.ecosistema = ecosistema
print('Creamos un animal')
def describe(self):
print('Soy un animal del tipo... |
def square_root(n):
k_squared = 0
i = 0
while k_squared <= n:
i += 1
k_squared += 2 * i - 1
k = i-1
return k
print(square_root(16))
| def square_root(n):
k_squared = 0
i = 0
while k_squared <= n:
i += 1
k_squared += 2 * i - 1
k = i - 1
return k
print(square_root(16)) |
"""
__version__.py
~~~~~~~~~~~~~~
Information about the current version of the synthrunner package.
"""
__title__ = 'synthrunner'
__description__ = 'synthrunner - SynthRunner'
__version__ = '0.8.0'
__author__ = 'Sarvi Shanmugham'
__author_email__ = 'sarvi@yahoo.com'
__license__ = 'MIT License'
__url__ = 'https://gith... | """
__version__.py
~~~~~~~~~~~~~~
Information about the current version of the synthrunner package.
"""
__title__ = 'synthrunner'
__description__ = 'synthrunner - SynthRunner'
__version__ = '0.8.0'
__author__ = 'Sarvi Shanmugham'
__author_email__ = 'sarvi@yahoo.com'
__license__ = 'MIT License'
__url__ = 'https://githu... |
def remove_dups(L1,L2):
for e in L1:
if e in L2:
L1.remove(e)
L1=[1,2,3,4]
L2=[1,2,5,6]
remove_dups(L1,L2)
print(L1)
print(L2)
| def remove_dups(L1, L2):
for e in L1:
if e in L2:
L1.remove(e)
l1 = [1, 2, 3, 4]
l2 = [1, 2, 5, 6]
remove_dups(L1, L2)
print(L1)
print(L2) |
# -*- coding: utf-8 -*-
def response_message(msg):
data = {
'message': msg
}
return data | def response_message(msg):
data = {'message': msg}
return data |
# libnatacalc.py
class Calculator:
def __init__(self, d, h, m, s):
self.distance = float(d)
self.hours = float(h)
self.minutes = float(m)
self.seconds = float(s)
self.kmsh = 0.0
self.t100m = 0.0
self.t1000m = 0.0
@staticmethod
def cnvt_to_seconds(h, m, s):
return s + (m * 60) + (h * 3600)
@stat... | class Calculator:
def __init__(self, d, h, m, s):
self.distance = float(d)
self.hours = float(h)
self.minutes = float(m)
self.seconds = float(s)
self.kmsh = 0.0
self.t100m = 0.0
self.t1000m = 0.0
@staticmethod
def cnvt_to_seconds(h, m, s):
re... |
names = "Julian Bob PyBites Dante Martin Rodolfo".split()
countries = "Australia Spain Global Argentina USA Mexico".split()
def enumerate_names_countries():
"""Outputs:
1. Julian Australia
2. Bob Spain
3. PyBites Global
4. Dante Argentina
5. Martin ... | names = 'Julian Bob PyBites Dante Martin Rodolfo'.split()
countries = 'Australia Spain Global Argentina USA Mexico'.split()
def enumerate_names_countries():
"""Outputs:
1. Julian Australia
2. Bob Spain
3. PyBites Global
4. Dante Argentina
5. Martin USA
... |
'''
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
'''
for b in range(5):
for a in range(5):
print("*",end=" ")
print()
| """
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
"""
for b in range(5):
for a in range(5):
print('*', end=' ')
print() |
# coding: utf-8
# In[18]:
# https://leetcode.com/problems/longest-substring-without-repeating-characters/description/
# Status:
# Percentile:
# Author: Shreyas Padhye
# Approach:
def lengthOfLongestSubstring(s):
"""
:type s: str
:rtype: int
"""
if len(s) == 0:
return 0
maxVal = 1... | def length_of_longest_substring(s):
"""
:type s: str
:rtype: int
"""
if len(s) == 0:
return 0
max_val = 1
for i in range(0, len(s) - 1):
check_str = s[i + 1:]
if s[i] in checkStr:
cur_val = checkStr.index(s[i]) + 1
if curVal > maxVal:
... |
#!/usr/bin/env python3
terms = set()
for a in range(2, 101):
for b in range(2, 101):
terms.add(a**b)
print(len(terms))
| terms = set()
for a in range(2, 101):
for b in range(2, 101):
terms.add(a ** b)
print(len(terms)) |
marks = int(input("Input Your Marks In Programming: "))
def your_grade(grade):
print(f"You Got: {grade}")
# if marks >= 80:
# your_grade("A+")
# elif 80 >= marks >= 70:
# your_grade('A')
# elif 70 > marks >= 60:
# your_grade("A-")
# elif marks >= 33:
# your_grade('Passed')
# else:
# your_gra... | marks = int(input('Input Your Marks In Programming: '))
def your_grade(grade):
print(f'You Got: {grade}')
if marks > 80 or marks < 10:
print('You are GOOD Or BAD')
if marks > 80:
print('You Are GOOD')
else:
print('You Are BAD')
else:
print('You are OK !!')
print('Finished') |
class TrainStates:
def __init__(self):
self.EXECUTING = False
self.MOTOR_RUNNING = False
self.MOTOR_WAITING = False
self.MOTOR_SPEED = 0
self.CRANE_LOADED = False
self.CRANE_LOADING = False
self.COMMUNICATION_RUNNING = False
self.SIGNALER_RUNNIN... | class Trainstates:
def __init__(self):
self.EXECUTING = False
self.MOTOR_RUNNING = False
self.MOTOR_WAITING = False
self.MOTOR_SPEED = 0
self.CRANE_LOADED = False
self.CRANE_LOADING = False
self.COMMUNICATION_RUNNING = False
self.SIGNALER_RUNNING = Fa... |
eve = lambda x: x & 1 == 0
def f(x):
division = 1
ret = 0
while division * division < x:
if x % division == 0:
if eve(division):
ret += 1
if eve(x // division):
ret += 1
division += 1
if division * division == x and eve(division):
... | eve = lambda x: x & 1 == 0
def f(x):
division = 1
ret = 0
while division * division < x:
if x % division == 0:
if eve(division):
ret += 1
if eve(x // division):
ret += 1
division += 1
if division * division == x and eve(division):
... |
class Config:
def __init__(self):
self.db_config = 'DRIVER={FreeTDS};SERVER=SDAQWGDWM4;DATABASE=GWCC_ProdCopy;UID=ClaimAnalyticsETLUser;PWD=jU' \
'&ruwrUde4aSpAt;TDS_Version=8.0;Port=1433 '
self.input_folder = 'data/Production/Output'
self.output_folder = 'dat... | class Config:
def __init__(self):
self.db_config = 'DRIVER={FreeTDS};SERVER=SDAQWGDWM4;DATABASE=GWCC_ProdCopy;UID=ClaimAnalyticsETLUser;PWD=jU&ruwrUde4aSpAt;TDS_Version=8.0;Port=1433 '
self.input_folder = 'data/Production/Output'
self.output_folder = 'data/Production/Input'
self.LDA... |
"""
A simple/basic graph structure designed to help group together annuli.
:Copyright: Smithsonian Astrophysical Observatory (2018)
:Author: Douglas Burke (dburke@cfa.harvard.edu)
"""
__all__ = ("SimpleGraph", )
class SimpleGraph:
"""A graph where links are bi-directional
The identifiers must be hashable (... | """
A simple/basic graph structure designed to help group together annuli.
:Copyright: Smithsonian Astrophysical Observatory (2018)
:Author: Douglas Burke (dburke@cfa.harvard.edu)
"""
__all__ = ('SimpleGraph',)
class Simplegraph:
"""A graph where links are bi-directional
The identifiers must be hashable (as ... |
abbreviations = {
'ARI':'Arizona Cardinals','ATL':'Atlanta Falcons','BAL':'Baltimore Ravens',
'BUF':'Buffalo Bills','CAR':'Carolina Panthers','CHI':'Chicago Bears',
'CIN':'Cincinnati Bengals','CLE':'Cleveland Browns','DAL':'Dallas Cowboys',
'DEN':'Denver Broncos','DET':'Detroit Lions','GB' :'Green B... | abbreviations = {'ARI': 'Arizona Cardinals', 'ATL': 'Atlanta Falcons', 'BAL': 'Baltimore Ravens', 'BUF': 'Buffalo Bills', 'CAR': 'Carolina Panthers', 'CHI': 'Chicago Bears', 'CIN': 'Cincinnati Bengals', 'CLE': 'Cleveland Browns', 'DAL': 'Dallas Cowboys', 'DEN': 'Denver Broncos', 'DET': 'Detroit Lions', 'GB': 'Green Bay... |
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
def add_n_ext(attrs):
return {}
| def add_n_ext(attrs):
return {} |
price = [10,20,30]
sum = 0
for i in price:
sum = sum + i
print(f"total price in shop is : {sum}")
| price = [10, 20, 30]
sum = 0
for i in price:
sum = sum + i
print(f'total price in shop is : {sum}') |
#!/usr/bin/env python3
"""
https://www.reddit.com/r/dailyprogrammer/comments/6jr76h/20170627_challenge_321_easy_talking_clock/
Given a 5-character input of the format HH:MM, convert the 24-hour timestamp
into natural language.
"""
def timeFormatNatural(timestamp):
output = ["It's"]
# get components
milHo... | """
https://www.reddit.com/r/dailyprogrammer/comments/6jr76h/20170627_challenge_321_easy_talking_clock/
Given a 5-character input of the format HH:MM, convert the 24-hour timestamp
into natural language.
"""
def time_format_natural(timestamp):
output = ["It's"]
mil_hour = int(timestamp[:2])
mil_min = int(... |
class addTwoNum:
def __init__(self, l1, l2):
self.l1 = l1
self.l2 = l2
self.l3 = []
self.carry = 0
self.sum = 0
self.sum_list = []
def addTwoNum(self):
while self.l1 or self.l2:
if self.l1:
self.sum = self.l1.val + self.carry
... | class Addtwonum:
def __init__(self, l1, l2):
self.l1 = l1
self.l2 = l2
self.l3 = []
self.carry = 0
self.sum = 0
self.sum_list = []
def add_two_num(self):
while self.l1 or self.l2:
if self.l1:
self.sum = self.l1.val + self.carr... |
class Label(object):
def __init__(self):
self.label = LabelGenerator.get_next()
def __str__(self):
return self.label
def __eq__(self, other):
return self.label == other.label
class LabelGenerator(object):
_next_label = 0
@classmethod
def get_next(cls):
next_l... | class Label(object):
def __init__(self):
self.label = LabelGenerator.get_next()
def __str__(self):
return self.label
def __eq__(self, other):
return self.label == other.label
class Labelgenerator(object):
_next_label = 0
@classmethod
def get_next(cls):
next_l... |
def validPalindrome(string):
left, right = 0, len(string) - 1
while left < right:
if string[left] != string[right]:
return isPalindrome(string, left + 1, right) or \
isPalindrome(string, left, right - 1)
left += 1
right -= 1
return True
def isPalindrom... | def valid_palindrome(string):
(left, right) = (0, len(string) - 1)
while left < right:
if string[left] != string[right]:
return is_palindrome(string, left + 1, right) or is_palindrome(string, left, right - 1)
left += 1
right -= 1
return True
def is_palindrome(string, lef... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Main text area
font = "Consolas"
fontsize = 10
# Message area
messagefont = "Consolas"
messagefontsize = 9
debug = True
| font = 'Consolas'
fontsize = 10
messagefont = 'Consolas'
messagefontsize = 9
debug = True |
number = 23
guess = int(input('Enter an integer : '))
if guess == number:
print('Congratulations, bingo!') # New block starts here
print('(but you do not win any prizes!)') # New block ends here
elif guess < number:
print('No, it is a litter higher than that')
# you can do whatever you want in a ... | number = 23
guess = int(input('Enter an integer : '))
if guess == number:
print('Congratulations, bingo!')
print('(but you do not win any prizes!)')
elif guess < number:
print('No, it is a litter higher than that')
else:
print('No, it is a letter lower than that')
print('Done') |
#
# PySNMP MIB module CISCOSB-TUNNEL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-TUNNEL-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:07:58 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint, constraints_union) ... |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def invertTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
# If th... | class Solution(object):
def invert_tree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if root == None:
return None
if root.left == None and root.right == None:
return root
temp = root.left
root.left = root.right
... |
a = input("Type something")
print("The class of what you type is", type (a) )
print("Has only spaces?", a.isspace())
print("Is it a number?", a.isnumeric())
print("Is it alphabetic?",a.isalpha()) | a = input('Type something')
print('The class of what you type is', type(a))
print('Has only spaces?', a.isspace())
print('Is it a number?', a.isnumeric())
print('Is it alphabetic?', a.isalpha()) |
# if statements
# if statements are used to test for particular conditions and respond appropriately.
# Conditional test
"""
equals: x == 42
not equals: x != 42
greater than: x > 42
greater than or equal to: x >= 42
less than: x < 42
less than or equal to: x <= 42
"""
# conditional checks in the list
bikes = ['trek... | """
equals: x == 42
not equals: x != 42
greater than: x > 42
greater than or equal to: x >= 42
less than: x < 42
less than or equal to: x <= 42
"""
bikes = ['trek', 'mob', 'spoof', 'delta']
'trek' in bikes
'surely' not in bikes
age = int(input('Please enter your age: '))
if age >= 18:
print('You can vote.')
if age... |
# -*- python -*-
#
# $Id: generators.py,v 1.1 2010-02-19 18:41:28 wirawan Exp $
#
# Created: 20100218
# Wirawan Purwanto
#
"""
Various generators
"""
def all_combinations(seq):
"""Generates stream of tuples containing all possible
combinations of items (where order matters).
This is useful e.g. for generating... | """
Various generators
"""
def all_combinations(seq):
"""Generates stream of tuples containing all possible
combinations of items (where order matters).
This is useful e.g. for generating all possible indices for a multidimensional
array.
Example:
>>> for i in all_combinations((xrange(4), xrange(3))):... |
input = """
1 2 0 0
1 3 0 0
1 4 0 0
1 5 0 0
1 6 0 0
1 7 0 0
1 8 0 0
1 9 0 0
1 10 0 0
1 11 0 0
1 12 0 0
1 13 0 0
1 14 0 0
1 15 0 0
1 16 0 0
1 17 0 0
1 18 0 0
1 19 0 0
1 20 0 0
1 21 0 0
1 22 0 0
1 23 0 0
1 24 0 0
1 25 0 0
1 26 0 0
1 27 0 0
1 28 0 0
1 29 0 0
1 30 0 0
1 31 0 0
1 32 0 0
1 33 1 1 34
1 35 1 1 36
1 37 1 0 33
1... | input = '\n1 2 0 0\n1 3 0 0\n1 4 0 0\n1 5 0 0\n1 6 0 0\n1 7 0 0\n1 8 0 0\n1 9 0 0\n1 10 0 0\n1 11 0 0\n1 12 0 0\n1 13 0 0\n1 14 0 0\n1 15 0 0\n1 16 0 0\n1 17 0 0\n1 18 0 0\n1 19 0 0\n1 20 0 0\n1 21 0 0\n1 22 0 0\n1 23 0 0\n1 24 0 0\n1 25 0 0\n1 26 0 0\n1 27 0 0\n1 28 0 0\n1 29 0 0\n1 30 0 0\n1 31 0 0\n1 32 0 0\n1 33 1 ... |
# Function dependencies, for example:
# package>=version
google-cloud-bigquery
pydub
google-cloud-storage
google-cloud-speech
| google - cloud - bigquery
pydub
google - cloud - storage
google - cloud - speech |
error_whitelist = ['ModuleNotFoundError: No module named']
other_error_count = 0
module_not_found_count = 0
module_not_found_list = []
num_of_notebooks = 10000
filter_out_count = 0
executable_count = 0
non_executable_count = 0
for i in range(1, num_of_notebooks+1):
file_name = str(i)+'.txt'
# Dump txt file to... | error_whitelist = ['ModuleNotFoundError: No module named']
other_error_count = 0
module_not_found_count = 0
module_not_found_list = []
num_of_notebooks = 10000
filter_out_count = 0
executable_count = 0
non_executable_count = 0
for i in range(1, num_of_notebooks + 1):
file_name = str(i) + '.txt'
f = open(file_na... |
expected_output = {
"CUST123-PIN-T5/0/0.20": {
"service_policy": {
"input": {
"policy_name": {
"CUST123-PIN-T5/0/0.20": {
"class_map": {
"class-default": {
"match_evaluation": ... | expected_output = {'CUST123-PIN-T5/0/0.20': {'service_policy': {'input': {'policy_name': {'CUST123-PIN-T5/0/0.20': {'class_map': {'class-default': {'match_evaluation': 'match-any', 'packets': 21211, 'bytes': 1442291, 'rate': {'interval': 30, 'offered_rate_bps': 0, 'drop_rate_bps': 0}, 'match': ['any'], 'police': {'conf... |
def get_repository_id(repository_info, api_root, repository_name=None):
"""Get the repository ID from the server.
This will compare the paths returned by the SCM client
with those on the server, and return the id of the first
match.
"""
detected_paths = repository_info.path
if not isinstan... | def get_repository_id(repository_info, api_root, repository_name=None):
"""Get the repository ID from the server.
This will compare the paths returned by the SCM client
with those on the server, and return the id of the first
match.
"""
detected_paths = repository_info.path
if not isinstanc... |
def pre_delete_interface(sender, instance, using, **kwargs):
instance.a_records.all().delete()
instance.aaaa_records.all().delete()
instance.cname_records.all().delete()
instance.ptr_records.all().delete()
instance.firewall_layer2.all().delete()
instance.firewall_layer3.all().delete()
instan... | def pre_delete_interface(sender, instance, using, **kwargs):
instance.a_records.all().delete()
instance.aaaa_records.all().delete()
instance.cname_records.all().delete()
instance.ptr_records.all().delete()
instance.firewall_layer2.all().delete()
instance.firewall_layer3.all().delete()
instan... |
"""An API for managing Vumi Go opt outs."""
__version__ = "0.1.2"
__all__ = []
| """An API for managing Vumi Go opt outs."""
__version__ = '0.1.2'
__all__ = [] |
# You are given the root node of a binary search tree(BST) and a value to insert into the tree.Return
# the root node of the BST after the insertion.It is guaranteed that the new value does not exist in the
# original BST.
# Notice that there may exist multiple valid ways
# for the insertion, as long as the tree remain... | class Solution:
def insert_into_bst(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]:
if not root:
return tree_node(val)
self.cont = True
self.helper(root, val)
return root
def helper(self, node, val):
if not self.cont:
return
... |
def part1():
positions = {int(i.split("#")[1][0]): int(i.split("position ")[1][:-1]) for i in open("input.txt").read().split("\n")[:-1]}
possiblePositions = {int(i.split("#")[1][0]): int(i.replace("positions;","has").split("has ")[1]) for i in open("input.txt").read().split("\n")}
time = 0
while True:
... | def part1():
positions = {int(i.split('#')[1][0]): int(i.split('position ')[1][:-1]) for i in open('input.txt').read().split('\n')[:-1]}
possible_positions = {int(i.split('#')[1][0]): int(i.replace('positions;', 'has').split('has ')[1]) for i in open('input.txt').read().split('\n')}
time = 0
while True:... |
#!/usr/bin/env python
# -*- coding: latin-1 -*-
#
def check_calls(self, calls, values):
self.assertEqual(len(calls), len(values))
r = {}
for call in calls:
name = call[0][0]
value = call[0][1]
r[name] = value
for name, value in values:
self.assertEqual(r.pop(name), va... | def check_calls(self, calls, values):
self.assertEqual(len(calls), len(values))
r = {}
for call in calls:
name = call[0][0]
value = call[0][1]
r[name] = value
for (name, value) in values:
self.assertEqual(r.pop(name), value)
self.assertEqual(len(r), 0) |
# _*_ encoding: utf-8 _*_
class SQD(object):
__elements = []
__length = 0
@property
def first(self):
if not self.is_empty():
return self.elements[0]
return None
@property
def last(self):
if not self.is_empty():
return self.elements[-1]
... | class Sqd(object):
__elements = []
__length = 0
@property
def first(self):
if not self.is_empty():
return self.elements[0]
return None
@property
def last(self):
if not self.is_empty():
return self.elements[-1]
return None
@property
... |
# MIT LICENSE Copyright (c) 2018 David Longnecker
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, ... | class Node(object):
pass
class Module(Node):
def __init__(self):
self.status_1 = 0
self.status_2 = 0
self.status_3 = 0
self.status_4 = 0
self.methodc = 0
self.methods = []
self.objectc = 0
self.objects = []
self.stringc = 0
self.s... |
T = int(input())
def match(A, B):
i = j = 1
while True:
if i > len(A):
return True
if j > len(B):
return False
if A[i - 1] == B[j - 1]:
i += 1
j += 1
elif i == 1:
j += 1
else:
i = 1
def solve(s):
... | t = int(input())
def match(A, B):
i = j = 1
while True:
if i > len(A):
return True
if j > len(B):
return False
if A[i - 1] == B[j - 1]:
i += 1
j += 1
elif i == 1:
j += 1
else:
i = 1
def solve(s):
... |
mock_get_instance_metadata = """
{
"ami-manifest-path": "(unknown)",
"instance-action": "none",
"ami-launch-index": "0",
"instance-type": "t2.small",
"local-ipv4": "123.45.67.89",
"services": {
"domain": "amazonaws.com",
"partition": "aws"
},
"placement": {
"avail... | mock_get_instance_metadata = '\n{\n "ami-manifest-path": "(unknown)",\n "instance-action": "none",\n "ami-launch-index": "0",\n "instance-type": "t2.small",\n "local-ipv4": "123.45.67.89",\n "services": {\n "domain": "amazonaws.com",\n "partition": "aws"\n },\n "placement": {\n ... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = "Robin 'r0w' Weiland"
__credits__ = ["Robin Weiland", ]
__copyright__ = "Copyright 2019, Robin Weiland"
__date__ = "2019-06-17"
__version__ = "0.0.1"
__license__ = "MIT"
__all__ = ['check_star_imports']
__doc__ = """compares globals() before and after the import... | __author__ = "Robin 'r0w' Weiland"
__credits__ = ['Robin Weiland']
__copyright__ = 'Copyright 2019, Robin Weiland'
__date__ = '2019-06-17'
__version__ = '0.0.1'
__license__ = 'MIT'
__all__ = ['check_star_imports']
__doc__ = 'compares globals() before and after the import; used as a contextmanager\nbasic example:\n\n>>>... |
x =int(input('digite a largura: '))
y= int(input('digite a altura: '))
#x=10
#y=3
x1=x
y1=y
while y>=1:
while x>0:
print("#",end="")
x=x-1
print()
y=y-1
x=x1
| x = int(input('digite a largura: '))
y = int(input('digite a altura: '))
x1 = x
y1 = y
while y >= 1:
while x > 0:
print('#', end='')
x = x - 1
print()
y = y - 1
x = x1 |
# Complete the mergeLists function below.
#
# For your reference:
#
# SinglyLinkedListNode:
# int data
# SinglyLinkedListNode next
#
#
def mergeLists(head1, head2):
li3 = SinglyLinkedList()
while(head1 or head2):
if(head1 and head2):
if(head1.data<=head2.data):
li3.i... | def merge_lists(head1, head2):
li3 = singly_linked_list()
while head1 or head2:
if head1 and head2:
if head1.data <= head2.data:
li3.insert_node(head1.data)
head1 = head1.next
else:
li3.insert_node(head2.data)
head2 ... |
"""
@no 8
@name String to Integer
"""
class Solution:
def myAtoi(self, str):
"""
:type str: str
:rtype: int
"""
l = []
p = []
tmp_str = ''
start = False
for c in str:
if start:
tmp_str += c
if not start ... | """
@no 8
@name String to Integer
"""
class Solution:
def my_atoi(self, str):
"""
:type str: str
:rtype: int
"""
l = []
p = []
tmp_str = ''
start = False
for c in str:
if start:
tmp_str += c
if not star... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.