content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
"""
solution Adventofcode 2019 day 4 part 1.
https://adventofcode.com/2019/day/4
author: pca
"""
def valid_pw(pw_str: int) -> bool:
has_double = False
if len(pw_str) != 6:
return False
max_digit = 0
prev_digit = -1
for ch in pw_str:
cur_digit = int(ch)
# decreasing
... | """
solution Adventofcode 2019 day 4 part 1.
https://adventofcode.com/2019/day/4
author: pca
"""
def valid_pw(pw_str: int) -> bool:
has_double = False
if len(pw_str) != 6:
return False
max_digit = 0
prev_digit = -1
for ch in pw_str:
cur_digit = int(ch)
if cur_digit < max_d... |
#A function to show the list of trait with categorial data
def categorial_trait(dataframe):
numeric, categorial = classifying_column(dataframe)
print('Traits with categorial data : ','\n',categorial, '\n')
print('Total count : ' ,len(categorial) , 'Traits')
| def categorial_trait(dataframe):
(numeric, categorial) = classifying_column(dataframe)
print('Traits with categorial data : ', '\n', categorial, '\n')
print('Total count : ', len(categorial), 'Traits') |
ENDC = '\033[0m'
OKGREEN = '\033[92m'
def print_play_my_playlist(playlist_name, name_song, artist, total_time, prefix, bar, percent, suffix):
print("\033[F"*13)
print(
f'{playlist_name} | {name_song} | {artist} | {total_time[:7]}',
f'{prefix}|{OKGREEN}{bar}{ENDC}|{percent[:7]} {suffix}',
... | endc = '\x1b[0m'
okgreen = '\x1b[92m'
def print_play_my_playlist(playlist_name, name_song, artist, total_time, prefix, bar, percent, suffix):
print('\x1b[F' * 13)
print(f'{playlist_name} | {name_song} | {artist} | {total_time[:7]}', f'{prefix}|{OKGREEN}{bar}{ENDC}|{percent[:7]} {suffix}', f'', f'p : Pause', f'... |
"""
Constants
"""
MONGO_DOCKER_SERVICE = "db"
MONGO_HOST = "192.168.99.100"
MONGO_PORT = 27017
RABBIT_DOCKER_SERVICE = "rabbit"
RABBIT_HOST = "192.168.99.100"
RABBIT_PORT = 5672
| """
Constants
"""
mongo_docker_service = 'db'
mongo_host = '192.168.99.100'
mongo_port = 27017
rabbit_docker_service = 'rabbit'
rabbit_host = '192.168.99.100'
rabbit_port = 5672 |
"""
texto = [x for x in input("Input: ") if x in "{}[]()"]
if len(texto) % 2 != 0 or len(texto) == 0:
validacion = False
else:
validacion = True
i = 0
while 0 < len(texto) and validacion == "YES":
if texto[i] in "{[(":
i += 1
else:
if texto[i - 1] + tex... | """
texto = [x for x in input("Input: ") if x in "{}[]()"]
if len(texto) % 2 != 0 or len(texto) == 0:
validacion = False
else:
validacion = True
i = 0
while 0 < len(texto) and validacion == "YES":
if texto[i] in "{[(":
i += 1
else:
if texto[i - 1] + texto[i] in '{... |
# -*- coding: utf-8 -*-
"""
pyglobi.config
~~~~~~~~~~~~
Configuration used by pyglobi
:copyright: (c) 2019 by Chris Nicholas.
:license: MIT, see LICENSE for more details.
"""
# Base URL's
globi_neo_url = "https://neo4j.globalbioticinteractions.org/db/data/cypher"
eol_url = "https://eol.org/pages"
eol_geo_url = "htt... | """
pyglobi.config
~~~~~~~~~~~~
Configuration used by pyglobi
:copyright: (c) 2019 by Chris Nicholas.
:license: MIT, see LICENSE for more details.
"""
globi_neo_url = 'https://neo4j.globalbioticinteractions.org/db/data/cypher'
eol_url = 'https://eol.org/pages'
eol_geo_url = 'https://eol.org/data/map_data_dwca' |
class Stock():
def __init__(self,code,name,price):
self.code = code
self.name = name
self.price = price
def __str__(self):
return 'code{},name{},price{}'.format(self.code,self.name,self.price) | class Stock:
def __init__(self, code, name, price):
self.code = code
self.name = name
self.price = price
def __str__(self):
return 'code{},name{},price{}'.format(self.code, self.name, self.price) |
"""Convert a Decimal Number to a Binary Number."""
def decimal_to_binary(decimal: int) -> str:
rem , bin , c = 0 , 0 , 0
is_negative = '-' if decimal < 0 else ''
decimal = abs(decimal)
while decimal > 0:
rem = decimal % 2
bin += rem * pow(10 , c)
c += 1
decimal //= 2
... | """Convert a Decimal Number to a Binary Number."""
def decimal_to_binary(decimal: int) -> str:
(rem, bin, c) = (0, 0, 0)
is_negative = '-' if decimal < 0 else ''
decimal = abs(decimal)
while decimal > 0:
rem = decimal % 2
bin += rem * pow(10, c)
c += 1
decimal //= 2
... |
line = input().split()
a = int(line[0])
b = int(line[1])
hour = 0
total = a
burned = 0
while(total > 0):
total -= 1
burned += 1
if(burned % b == 0):
total += 1
hour += 1
print(str(hour))
| line = input().split()
a = int(line[0])
b = int(line[1])
hour = 0
total = a
burned = 0
while total > 0:
total -= 1
burned += 1
if burned % b == 0:
total += 1
hour += 1
print(str(hour)) |
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[List[int]]
:rtype: List[List[int]]
"""
length = len(intervals)
if length == 0 or not intervals[0]:
return intervals
intervals = sorted(intervals, key=lambda x: x[0])
... | class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[List[int]]
:rtype: List[List[int]]
"""
length = len(intervals)
if length == 0 or not intervals[0]:
return intervals
intervals = sorted(intervals, key=lambda x: x[0])
... |
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# -----------------------------------------------------... | class Export:
def __init__(self, export: dict):
self.id = export.get('id')
self.display_name = export.get('displayName')
self.enabled = export.get('enabled')
self.source = export.get('source')
self.filter = export.get('filter')
self.destinations = export.get('destina... |
# -*- coding: utf-8 -*-
"""
Resource module
"""
# pylint: disable=too-few-public-methods
class Resource:
"""
Used for representing Conjur resources
"""
def __init__(self, type_:type, name:str):
self.type = type_
self.name = name
def full_id(self):
"""
Method for bu... | """
Resource module
"""
class Resource:
"""
Used for representing Conjur resources
"""
def __init__(self, type_: type, name: str):
self.type = type_
self.name = name
def full_id(self):
"""
Method for building the full resource ID in the format 'user:someuser' for e... |
__package__ = 'tkgeom'
__title__ = 'tkgeom'
__description__ = '2D geometry module as an example for the TK workshop'
__copyright__ = '2019, Zs. Elter'
__version__ = '1.0.0'
| __package__ = 'tkgeom'
__title__ = 'tkgeom'
__description__ = '2D geometry module as an example for the TK workshop'
__copyright__ = '2019, Zs. Elter'
__version__ = '1.0.0' |
'''
Copyright (c) 2014, Aaron Westendorf All rights reserved.
https://github.com/agoragames/pluto/blob/master/LICENSE.txt
'''
| """
Copyright (c) 2014, Aaron Westendorf All rights reserved.
https://github.com/agoragames/pluto/blob/master/LICENSE.txt
""" |
def id(message):
# Define empty variables
fu_userid = False
rt_userid = False
rf_userid = False
gp_groupid = False
# the 'From User' data
fu_username = message.from_user.username
fu_userid = message.from_user.id
fu_fullname = message.from_user.first_name.encode("utf-8")
# check for 'Replied to' mess... | def id(message):
fu_userid = False
rt_userid = False
rf_userid = False
gp_groupid = False
fu_username = message.from_user.username
fu_userid = message.from_user.id
fu_fullname = message.from_user.first_name.encode('utf-8')
if message.reply_to_message:
rt_userid = message.reply_to... |
txt = "banana"
x = txt.ljust(20)
print(x, "is my favorite fruit.")
| txt = 'banana'
x = txt.ljust(20)
print(x, 'is my favorite fruit.') |
class Solution:
def count_l(self, a_list: list):
a, b = a_list
return a*a + b*b
def kClosest(self, points, K):
"""
:type points: List[List[int]]
:type K: int
:rtype: List[List[int]]
"""
m = list()
tmp = dict()
for point in point... | class Solution:
def count_l(self, a_list: list):
(a, b) = a_list
return a * a + b * b
def k_closest(self, points, K):
"""
:type points: List[List[int]]
:type K: int
:rtype: List[List[int]]
"""
m = list()
tmp = dict()
for point in ... |
pkgname = "gnome-menus"
pkgver = "3.36.0"
pkgrel = 0
build_style = "gnu_configure"
configure_args = ["--disable-static"]
make_cmd = "gmake"
hostmakedepends = [
"gmake", "pkgconf", "gobject-introspection", "glib-devel", "gettext-tiny"
]
makedepends = ["libglib-devel"]
pkgdesc = "GNOME menu definitions"
maintainer = ... | pkgname = 'gnome-menus'
pkgver = '3.36.0'
pkgrel = 0
build_style = 'gnu_configure'
configure_args = ['--disable-static']
make_cmd = 'gmake'
hostmakedepends = ['gmake', 'pkgconf', 'gobject-introspection', 'glib-devel', 'gettext-tiny']
makedepends = ['libglib-devel']
pkgdesc = 'GNOME menu definitions'
maintainer = 'q66 <... |
#!/usr/bin/env python3
class BaseError(Exception):
def __init__(self, message):
self.message = message
class LoggedOutError(BaseError):
def __init__(self):
super(LoggedOutError, self).__init__("User is currently not logged In")
# self.message = "User is currently not logged In"
cla... | class Baseerror(Exception):
def __init__(self, message):
self.message = message
class Loggedouterror(BaseError):
def __init__(self):
super(LoggedOutError, self).__init__('User is currently not logged In')
class Loginexpirederror(BaseError):
def __init__(self):
super(LoginExpired... |
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | """Config to train MobileNet."""
mobilenet_cfg = {'use_tpu': True, 'train_batch_size': 1024, 'train_steps': 8000000, 'eval_batch_size': 1024, 'iterations_per_loop': 100, 'num_cores': 8, 'eval_total_size': 0, 'train_steps_per_eval': 2000, 'min_eval_interval': 180, 'learning_rate': 0.165, 'depth_multiplier': 1.0, 'optimi... |
pkgname = "python-py"
pkgver = "1.11.0"
pkgrel = 0
build_style = "python_module"
hostmakedepends = ["python-setuptools_scm"]
checkdepends = ["python-pytest"]
depends = ["python"]
pkgdesc = "Python development support library"
maintainer = "q66 <q66@chimera-linux.org>"
license = "MIT"
url = "https://github.com/pytest-de... | pkgname = 'python-py'
pkgver = '1.11.0'
pkgrel = 0
build_style = 'python_module'
hostmakedepends = ['python-setuptools_scm']
checkdepends = ['python-pytest']
depends = ['python']
pkgdesc = 'Python development support library'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'MIT'
url = 'https://github.com/pytest-de... |
test_input = """35
20
15
25
47
40
62
55
65
95
102
117
150
182
127
219
299
277
309
576
"""
def find_number(numbers, preamble_size):
for number_index in range(preamble_size, len(numbers)):
number = numbers[number_index]
breaked = False
start = number_index - preamble_size
for first_... | test_input = '35\n20\n15\n25\n47\n40\n62\n55\n65\n95\n102\n117\n150\n182\n127\n219\n299\n277\n309\n576\n'
def find_number(numbers, preamble_size):
for number_index in range(preamble_size, len(numbers)):
number = numbers[number_index]
breaked = False
start = number_index - preamble_size
... |
n = int(input())
nums = list(map(int, input().strip().split()))
print(min(nums) * max(nums))
| n = int(input())
nums = list(map(int, input().strip().split()))
print(min(nums) * max(nums)) |
line = Line()
line.xValues = [2, 1, 3, 4, 0]
line.yValues = [2, 1, 3, 4, 0]
plot = Plot()
plot.add(line)
plot.save("unordered.png")
| line = line()
line.xValues = [2, 1, 3, 4, 0]
line.yValues = [2, 1, 3, 4, 0]
plot = plot()
plot.add(line)
plot.save('unordered.png') |
'''
Created on Oct 31, 2013/.>"
@author: rgeorgi
'''
class TextParser(object):
'''
classdocs
'''
def parse(self):
pass
def __init__(self):
'''
Constructor
'''
class ParserException(Exception):
pass | """
Created on Oct 31, 2013/.>"
@author: rgeorgi
"""
class Textparser(object):
"""
classdocs
"""
def parse(self):
pass
def __init__(self):
"""
Constructor
"""
class Parserexception(Exception):
pass |
# -*- coding: utf-8 -*-
"""
999. Available Captures for Rook
On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns.
These are given as characters 'R', '.', 'B', and 'p' respectively.
Uppercase characters represent white pieces, and lowercase characters repres... | """
999. Available Captures for Rook
On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns.
These are given as characters 'R', '.', 'B', and 'p' respectively.
Uppercase characters represent white pieces, and lowercase characters represent black pieces.
The r... |
class UIColors:
"color indices for UI (c64 original) palette"
white = 2
lightgrey = 16
medgrey = 13
darkgrey = 12
black = 1
yellow = 8
red = 3
brightred = 11
| class Uicolors:
"""color indices for UI (c64 original) palette"""
white = 2
lightgrey = 16
medgrey = 13
darkgrey = 12
black = 1
yellow = 8
red = 3
brightred = 11 |
# Time: O (N ^ 2) | Space: O(N)
def arrayOfProducts(array):
output = []
for i in range(len(array)):
product = 1
for j in range(len(array)):
if i != j:
product = product * array[j]
output.append(product)
return output
# Time: O(N) | Space: O(N)
def array... | def array_of_products(array):
output = []
for i in range(len(array)):
product = 1
for j in range(len(array)):
if i != j:
product = product * array[j]
output.append(product)
return output
def array_of_products_n(array):
left = [1 for i in range(len(arr... |
# -*- coding = utf-8 -*-
# @Time:2021/2/2821:58
# @Author:Linyu
# @Software:PyCharm
def response(flow):
print(flow.request.url)
print(flow.response.text) | def response(flow):
print(flow.request.url)
print(flow.response.text) |
# example of how to display octal and hexa values
a = 0o25
b = 0x1af
print('Value of a in decimal is ', a)
c = 19
print('19 in octal is %o and in hex is %x' % (c, c))
d = oct(c)
e = hex(c)
print('19 in octal is', d, ' and in hex is ', e)
| a = 21
b = 431
print('Value of a in decimal is ', a)
c = 19
print('19 in octal is %o and in hex is %x' % (c, c))
d = oct(c)
e = hex(c)
print('19 in octal is', d, ' and in hex is ', e) |
states_in_order_of_founding = ("Delaware", "Pennsylvania", "New Jersey", "Georgia")
# You use parentheses instead of square brackets.
print(states_in_order_of_founding)
second_state_founded = states_in_order_of_founding[1]
print("The second state founded was " + second_state_founded) | states_in_order_of_founding = ('Delaware', 'Pennsylvania', 'New Jersey', 'Georgia')
print(states_in_order_of_founding)
second_state_founded = states_in_order_of_founding[1]
print('The second state founded was ' + second_state_founded) |
#!/usr/bin/python
# -*- coding: utf-8 -*-
nitram_micro_mono_CP437 = [
0, 0, 0, 0, 0,
10, 0, 4, 17, 14,
10, 0, 0, 14, 17,
27, 31, 31, 14, 4,
0, 0, 0, 0, 0,
0, 4, 10, 4, 14,
4, 14, 14, 4, 14,
0, 14, 14, 14, 0,
0, 0, 0, 0, 0,
0, 4, 10, 4, 0,
0, 0, 0, 0, 0,
30, 28, 31, 21, 7... | nitram_micro_mono_cp437 = [0, 0, 0, 0, 0, 10, 0, 4, 17, 14, 10, 0, 0, 14, 17, 27, 31, 31, 14, 4, 0, 0, 0, 0, 0, 0, 4, 10, 4, 14, 4, 14, 14, 4, 14, 0, 14, 14, 14, 0, 0, 0, 0, 0, 0, 0, 4, 10, 4, 0, 0, 0, 0, 0, 0, 30, 28, 31, 21, 7, 5, 13, 31, 12, 4, 20, 22, 31, 6, 4, 15, 10, 10, 10, 5, 21, 14, 27, 14, 21, 4, 12, 28, 12, ... |
def is_same_string(string1, string2):
if len(string1) != len(string2):
return False
else:
for i in range(len(string1)):
if string1[i] != string2[i]:
return False
return True
def reverse_string(string):
gnirts = ''
for i in range(len(string)):... | def is_same_string(string1, string2):
if len(string1) != len(string2):
return False
else:
for i in range(len(string1)):
if string1[i] != string2[i]:
return False
return True
def reverse_string(string):
gnirts = ''
for i in range(len(string)):
gnir... |
class AccessKeyEventArgs(EventArgs):
""" Provides information for access keys events. """
IsMultiple=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets a value that indicates whether other elements are invoked by the key.
Get: IsMultiple(self: AccessKeyEventArgs) -> bool
"""
... | class Accesskeyeventargs(EventArgs):
""" Provides information for access keys events. """
is_multiple = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Gets a value that indicates whether other elements are invoked by the key.\n\n\n\nGet: IsMultiple(self: AccessKeyEventArgs) -> boo... |
class PretreatedQuery:
'''
DBpedia resultat
'''
def __init__(self, mentions_list, detected_ne):
'''
Constructor
'''
self.mentions_list=mentions_list
self.detected_ne=detected_ne
| class Pretreatedquery:
"""
DBpedia resultat
"""
def __init__(self, mentions_list, detected_ne):
"""
Constructor
"""
self.mentions_list = mentions_list
self.detected_ne = detected_ne |
def even_odd(*args):
if "even" in args:
return list(filter(lambda x: x % 2 == 0, [args[i] for i in range(len(args) - 1)]))
return list(filter(lambda x: x % 2 == 1, [args[i] for i in range(len(args) - 1)]))
# print(even_odd(1, 2, 3, 4, 5, 6, "even"))
# print(even_odd(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "od... | def even_odd(*args):
if 'even' in args:
return list(filter(lambda x: x % 2 == 0, [args[i] for i in range(len(args) - 1)]))
return list(filter(lambda x: x % 2 == 1, [args[i] for i in range(len(args) - 1)])) |
# swift_build_support/build_graph.py ----------------------------*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.tx... | def _get_po_ordered_nodes(root, invertedDepMap):
worklist = [root]
visited_nodes = set([])
po_ordered_nodes = []
while not len(worklist) == 0:
node = worklist[-1]
if node in visitedNodes:
worklist.pop()
continue
deps = invertedDepMap.get(node, set([]))
... |
pkgname = "python-sphinxcontrib-serializinghtml"
pkgver = "1.1.5"
pkgrel = 0
build_style = "python_module"
hostmakedepends = ["python-setuptools"]
checkdepends = ["python-sphinx"]
depends = ["python"]
pkgdesc = "Sphinx extension which outputs serialized HTML document"
maintainer = "q66 <q66@chimera-linux.org>"
license ... | pkgname = 'python-sphinxcontrib-serializinghtml'
pkgver = '1.1.5'
pkgrel = 0
build_style = 'python_module'
hostmakedepends = ['python-setuptools']
checkdepends = ['python-sphinx']
depends = ['python']
pkgdesc = 'Sphinx extension which outputs serialized HTML document'
maintainer = 'q66 <q66@chimera-linux.org>'
license ... |
"""
MIT License
Copyright (c) 2019 Michael Schmidt
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, publis... | """
MIT License
Copyright (c) 2019 Michael Schmidt
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, publis... |
class Solution:
def longestValidParentheses(self, s):
"""
:type s: str
:rtype: int
"""
stack = []
index_stack = []
if len(s) <= 1:
return 0
dp = [0] * len(s)
for i in range(len(s)):
if s[i] == '(':
dp[i] ... | class Solution:
def longest_valid_parentheses(self, s):
"""
:type s: str
:rtype: int
"""
stack = []
index_stack = []
if len(s) <= 1:
return 0
dp = [0] * len(s)
for i in range(len(s)):
if s[i] == '(':
dp[... |
lis = [1, 2, 3, 4, 2, 6, 7, 8, 9]
without_duplicates = []
ok = True
for i in range(0,len(lis)):
if lis[i] in without_duplicates:
ok = False
break
else:
without_duplicates.append(lis[i])
if ok:
print("There are no duplicates")
else:
print("Things are not ok") | lis = [1, 2, 3, 4, 2, 6, 7, 8, 9]
without_duplicates = []
ok = True
for i in range(0, len(lis)):
if lis[i] in without_duplicates:
ok = False
break
else:
without_duplicates.append(lis[i])
if ok:
print('There are no duplicates')
else:
print('Things are not ok') |
# model settings
model = dict(
type='CenterNet2',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
init_cfg=dict(... | model = dict(type='CenterNet2', backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50')), neck=dict(type='FPN', in_channels=[256, 5... |
""" Constants file for Auth0's seed project
"""
ACCESS_TOKEN_KEY = 'access_token'
API_ID = 'API_ID'
APP_JSON_KEY = 'application/json'
AUTH0_CLIENT_ID = 'uL61M0bVYCd72QwsrvGioOHotcRlqw35'
AUTH0_CLIENT_SECRET = '3dtMdBV5P4jtohyJCtwk0P0HBoOk_hv_oHYzEkYtHCOWjFR59MBBphTPIYf6tucz'
# AUTH0_CALLBACK_URL = 'http://127.0.0.1:500... | """ Constants file for Auth0's seed project
"""
access_token_key = 'access_token'
api_id = 'API_ID'
app_json_key = 'application/json'
auth0_client_id = 'uL61M0bVYCd72QwsrvGioOHotcRlqw35'
auth0_client_secret = '3dtMdBV5P4jtohyJCtwk0P0HBoOk_hv_oHYzEkYtHCOWjFR59MBBphTPIYf6tucz'
auth0_callback_url = 'https://sustainable-ro... |
# Copyright 2014 0xc0170
#
# 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, soft... | class Iardefinitions:
def get_mcu_definition(self, name):
""" If MCU found, returns its definition dic, error otherwise. """
try:
return self.mcu_def[name]
except KeyError:
raise runtime_error('Mcu was not recognized for IAR. Please check mcu_def dictionary.')
mc... |
aux = 0
num = int(input("Ingrese un numero entero positivo: "))
opc = int(input("1- Sumatoria, 2-Factorial: "))
if opc == 1:
for x in range(0,num+1):
aux = aux + x
print (aux)
elif opc == 2:
if num == 0:
print("1")
elif num > 0:
aux = 1
for x in range(1,num+1):
aux = aux*x
print (aux)
elif num < 0:
... | aux = 0
num = int(input('Ingrese un numero entero positivo: '))
opc = int(input('1- Sumatoria, 2-Factorial: '))
if opc == 1:
for x in range(0, num + 1):
aux = aux + x
print(aux)
elif opc == 2:
if num == 0:
print('1')
elif num > 0:
aux = 1
for x in range(1, num + 1):
... |
#Give a single command that computes the sum from Exercise R-1.6,relying
#on Python's comprehension syntax and the built-in sum function
n = int(input('please input an positive integer:'))
result = sum(i**2 for i in range(1,n) if i&1!=0)
print(result) | n = int(input('please input an positive integer:'))
result = sum((i ** 2 for i in range(1, n) if i & 1 != 0))
print(result) |
# coding=utf-8
"""
Exceptions for AVWX package
"""
class AVWXError(Exception):
"""Base AVWX exception"""
class AVWXRequestFailedError(AVWXError):
"""Raised when request failed"""
class StationNotFound(AVWXError):
"""
Raised when a ICAO station isn't found
"""
def __init__(self, icao: str)... | """
Exceptions for AVWX package
"""
class Avwxerror(Exception):
"""Base AVWX exception"""
class Avwxrequestfailederror(AVWXError):
"""Raised when request failed"""
class Stationnotfound(AVWXError):
"""
Raised when a ICAO station isn't found
"""
def __init__(self, icao: str) -> None:
... |
def twoSum(self, n: List[int], target: int) -> List[int]:
N = len(n)
l = 0
r = N-1
while l<r:
s = n[l] + n[r]
if s == target:
return [l+1,r+1]
elif s < target:
l += 1
else:
r -= 1
| def two_sum(self, n: List[int], target: int) -> List[int]:
n = len(n)
l = 0
r = N - 1
while l < r:
s = n[l] + n[r]
if s == target:
return [l + 1, r + 1]
elif s < target:
l += 1
else:
r -= 1 |
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
def __bytes2ul(b):
return int.from_bytes(b, byteorder='little', signed=False)
def mmh2(bstr, seed=0xc70f6907, signed=True)... | def __bytes2ul(b):
return int.from_bytes(b, byteorder='little', signed=False)
def mmh2(bstr, seed=3339675911, signed=True):
mask = 2 ** 64 - 1
size = len(bstr)
m = 14313749767032793493
r = 47
h = seed ^ size * m & MASK
end = size & 4294967288
for pos in range(0, end, 8):
k = __b... |
"""
author : Ali Emre SAVAS
Link : https://www.hackerrank.com/challenges/py-check-subset/problem
"""
if __name__ == "__main__":
for _ in range(int(input())):
numberOfA = int(input())
setA = set(map(int, input().split()))
numberOfA = int(input())
setB = set(map(int, input().sp... | """
author : Ali Emre SAVAS
Link : https://www.hackerrank.com/challenges/py-check-subset/problem
"""
if __name__ == '__main__':
for _ in range(int(input())):
number_of_a = int(input())
set_a = set(map(int, input().split()))
number_of_a = int(input())
set_b = set(map(int, inpu... |
def init(n,m):
state_initial = [n] + [1] * m
state_current = state_initial
state_final = [n] * (m + 1)
return state_initial, state_current, state_final
def valid_transition(currentState, tower_i, tower_j):
k = 0
t = 0
if tower_i == tower_j: # same tower not allowed
return False
... | def init(n, m):
state_initial = [n] + [1] * m
state_current = state_initial
state_final = [n] * (m + 1)
return (state_initial, state_current, state_final)
def valid_transition(currentState, tower_i, tower_j):
k = 0
t = 0
if tower_i == tower_j:
return False
for i in range(1, len(... |
class Vector:
'''Vector class modeling Vectors'''
def __init__(self,initialise_param):
'''constructor:-create list of num length'''
if isinstance(initialise_param,(Vector,list)):
self._coords=[i for i in initialise_param]
elif isinstance(initialise_param,(int)):
... | class Vector:
"""Vector class modeling Vectors"""
def __init__(self, initialise_param):
"""constructor:-create list of num length"""
if isinstance(initialise_param, (Vector, list)):
self._coords = [i for i in initialise_param]
elif isinstance(initialise_param, int):
... |
def createList():
fruitsList = ["apple", "banana", "cherry"]
print("Fruit List : ", fruitsList)
# Iterate the list of fruits
for i in fruitsList:
print("Value : ", i)
# Add to fruits list
fruitsList.append("kiwi")
fruitsList.append("Grape")
fruitsList.append("Orange")
... | def create_list():
fruits_list = ['apple', 'banana', 'cherry']
print('Fruit List : ', fruitsList)
for i in fruitsList:
print('Value : ', i)
fruitsList.append('kiwi')
fruitsList.append('Grape')
fruitsList.append('Orange')
print('After adding furits now list ...')
for fruit in frui... |
class SlopeGradient:
def __init__(self, rightSteps, downSteps):
self.rightSteps = rightSteps
self.downSteps = downSteps
| class Slopegradient:
def __init__(self, rightSteps, downSteps):
self.rightSteps = rightSteps
self.downSteps = downSteps |
S = input()
is_no = False
for s in S:
if S.count(s) != 2:
is_no = True
break
if is_no:
print("No")
else:
print("Yes")
| s = input()
is_no = False
for s in S:
if S.count(s) != 2:
is_no = True
break
if is_no:
print('No')
else:
print('Yes') |
class WeekSchedule():
def __init__(self, dates=[], codes=[]):
self.weeknum = 0
self.dates = dates
self.codes = codes | class Weekschedule:
def __init__(self, dates=[], codes=[]):
self.weeknum = 0
self.dates = dates
self.codes = codes |
a=10
print(type(a))
a='Python'
print(type(a))
a=False
print(type(a)) | a = 10
print(type(a))
a = 'Python'
print(type(a))
a = False
print(type(a)) |
''' Code for training and evaluating Self-Explaining Neural Networks.
Copyright (C) 2018 David Alvarez-Melis <dalvmel@mit.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of ... | """ Code for training and evaluating Self-Explaining Neural Networks.
Copyright (C) 2018 David Alvarez-Melis <dalvmel@mit.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of ... |
load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
def image_deps():
container_pull(
name = "python3.7",
digest = "sha256:57c7d7161fdaa79b61f107b8a480c50657d64dca37295d67db2f675abe38b45a",
registry = "index.docker.io",
repository = "library/python",
ta... | load('@io_bazel_rules_docker//container:container.bzl', 'container_pull')
def image_deps():
container_pull(name='python3.7', digest='sha256:57c7d7161fdaa79b61f107b8a480c50657d64dca37295d67db2f675abe38b45a', registry='index.docker.io', repository='library/python', tag='3.7.8') |
#!/usr/bin/python
ADMIN_SCHEMA_FOLDER = "admin/schemas/"
ADMIN_SCHEMA_CHAR_SEPARATOR = "_"
ADD_COIN_METHOD = "addcoin"
GET_COIN_METHOD = "getcoin"
REMOVE_COIN_METHOD = "removecoin"
UPDATE_COIN_METHOD = "updatecoin"
| admin_schema_folder = 'admin/schemas/'
admin_schema_char_separator = '_'
add_coin_method = 'addcoin'
get_coin_method = 'getcoin'
remove_coin_method = 'removecoin'
update_coin_method = 'updatecoin' |
class HandledEventArgs(EventArgs):
"""
Provides data for events that can be handled completely in an event handler.
HandledEventArgs()
HandledEventArgs(defaultHandledValue: bool)
"""
@staticmethod
def __new__(self,defaultHandledValue=None):
"""
__new__(cls: type)
__new__(cls: type,defa... | class Handledeventargs(EventArgs):
"""
Provides data for events that can be handled completely in an event handler.
HandledEventArgs()
HandledEventArgs(defaultHandledValue: bool)
"""
@staticmethod
def __new__(self, defaultHandledValue=None):
"""
__new__(cls: type)
__new__(cls: type,de... |
exp_name = 'glean_ffhq_16x'
scale = 16
# model settings
model = dict(
type='GLEAN',
generator=dict(
type='GLEANStyleGANv2',
in_size=64,
out_size=1024,
style_channels=512,
pretrained=dict(
ckpt_path='http://download.openmmlab.com/mmgen/stylegan2/'
... | exp_name = 'glean_ffhq_16x'
scale = 16
model = dict(type='GLEAN', generator=dict(type='GLEANStyleGANv2', in_size=64, out_size=1024, style_channels=512, pretrained=dict(ckpt_path='http://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth', prefix='genera... |
#1 Create countries dictionary
countries = __________________
#2 Print out the capital of egypt
print(__________________) | countries = __________________
print(__________________) |
# -*- coding:utf-8 -*-
__author__ = [
'wufang'
]
| __author__ = ['wufang'] |
"""Farmer classes.
:author: Someone
:email: someone@pnnl.gov
License: BSD 2-Clause, see LICENSE and DISCLAIMER files
"""
class FarmerOne:
"""This is the first Farmer agent.
:param age: Age of farmer
:type age: int
CLASS ATTRIBUTES:
:param AGE_M... | """Farmer classes.
:author: Someone
:email: someone@pnnl.gov
License: BSD 2-Clause, see LICENSE and DISCLAIMER files
"""
class Farmerone:
"""This is the first Farmer agent.
:param age: Age of farmer
:type age: int
CLASS ATTRIBUTES:
:param AGE_MI... |
# ------------------------------------------------------------------------------
# Access to the CodeHawk Binary Analyzer Analysis Results
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2016-2020 Kestrel Technology LLC
#
#... | """X86 CPU Register data."""
class Asmregisterbase(object):
def __init__(self, bd, index, tags, args):
self.bd = bd
self.index = index
self.tags = tags
self.args = args
def is_cpu_register(self):
return False
def is_segment_register(self):
return False
... |
"""hxlm.core.urn
Author: 2021, Emerson Rocha (Etica.AI) <rocha@ieee.org>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""
# __all__ = [
# 'get_entrypoint_type'
# ]
# from hxlm.core.io.util import ( # noqa
# get_entrypoint_type
# )
| """hxlm.core.urn
Author: 2021, Emerson Rocha (Etica.AI) <rocha@ieee.org>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
""" |
"""
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity
O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BANC".
Note:
If there is no such window in S that covers all characters in T, return the emtpy string "".
If there... | """
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity
O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BANC".
Note:
If there is no such window in S that covers all characters in T, return the emtpy string "".
If there are multipl... |
a = int(input())
b = int(input())
def rectangle_area(a, b):
return '{:.0f}'.format(a * b)
print(rectangle_area(a, b))
| a = int(input())
b = int(input())
def rectangle_area(a, b):
return '{:.0f}'.format(a * b)
print(rectangle_area(a, b)) |
# -*- coding: utf-8 -*-
"""
KM3NeT Data Definitions v2.0.0-9-gbae3720
https://git.km3net.de/common/km3net-dataformat
"""
# daqdatatypes
data = dict(
DAQSUPERFRAME=101,
DAQSUMMARYFRAME=201,
DAQTIMESLICE=1001,
DAQTIMESLICEL0=1002,
DAQTIMESLICEL1=1003,
DAQTIMESLICEL2=1004,
DAQTIMESLICESN=1005,... | """
KM3NeT Data Definitions v2.0.0-9-gbae3720
https://git.km3net.de/common/km3net-dataformat
"""
data = dict(DAQSUPERFRAME=101, DAQSUMMARYFRAME=201, DAQTIMESLICE=1001, DAQTIMESLICEL0=1002, DAQTIMESLICEL1=1003, DAQTIMESLICEL2=1004, DAQTIMESLICESN=1005, DAQSUMMARYSLICE=2001, DAQEVENT=10001) |
class Solution:
def minSteps(self, n: int) -> int:
res, m = 0, 2
while n > 1:
while n % m == 0:
res += m
n //= m
m += 1
return res | class Solution:
def min_steps(self, n: int) -> int:
(res, m) = (0, 2)
while n > 1:
while n % m == 0:
res += m
n //= m
m += 1
return res |
# Example, do not modify!
print(5 / 8)
# Put code below here
5 / 8
print( 7 + 10 )
# Just testing division
print(5 / 8)
# Addition works too.
print(7 + 10)
# Addition and subtraction
print(5 + 5)
print(5 - 5)
# Multiplication and division
print(3 * 5)
print(10 / 2)
# Exponentiation
print(4 ** 2)
# Modulo
print(... | print(5 / 8)
5 / 8
print(7 + 10)
print(5 / 8)
print(7 + 10)
print(5 + 5)
print(5 - 5)
print(3 * 5)
print(10 / 2)
print(4 ** 2)
print(18 % 7)
print(100 * 1.1 ** 7)
savings = 100
print(savings)
savings = 100
factor = 1.1
result = savings * factor ** 7
print(result)
desc = 'compound interest'
profitable = True
savings = 1... |
# -*- coding: utf-8 -*-
name = 'smsapi-client'
version = '2.3.0'
lib_info = '%s/%s' % (name, version) | name = 'smsapi-client'
version = '2.3.0'
lib_info = '%s/%s' % (name, version) |
f = open('day6.txt', 'r')
data = f.read()
groups = data.split('\n\n')
answer = 0
for group in groups:
people = group.split('\n')
group_set = set(people[0])
for person in people:
group_set = group_set & set(person)
answer += len(group_set)
print(answer)
| f = open('day6.txt', 'r')
data = f.read()
groups = data.split('\n\n')
answer = 0
for group in groups:
people = group.split('\n')
group_set = set(people[0])
for person in people:
group_set = group_set & set(person)
answer += len(group_set)
print(answer) |
#!/bin/python3
def day12(lines):
registers = {'a': 0, 'b': 0, 'c': 1, 'd': 0}
i = 0
k = 0
while i < len(lines):
if k > 0:
i += 1
k -= 1
continue
line = lines[i].strip('\n').split(' ')
print('[%d, %d, %d, %d], %s' % (registers['a'],
... | def day12(lines):
registers = {'a': 0, 'b': 0, 'c': 1, 'd': 0}
i = 0
k = 0
while i < len(lines):
if k > 0:
i += 1
k -= 1
continue
line = lines[i].strip('\n').split(' ')
print('[%d, %d, %d, %d], %s' % (registers['a'], registers['b'], registers['... |
"""Used to make pytest functions available globally"""
# Copyright (c) 2020 zfit
#
#
# def pytest_generate_tests(metafunc):
# if metafunc.config.option.all_jit_levels:
#
# # We're going to duplicate these tests by parametrizing them,
# # which requires that each test has a fixture to accept the pa... | """Used to make pytest functions available globally""" |
mutables_test_text_001 = '''
def function(
param,
):
pass
'''
mutables_test_text_002 = '''
def function(
param=0,
):
pass
'''
mutables_test_text_003 = '''
def function(
param={},
):
pass
'''
mutables_test_text_004 = '''
def function(
param=[],
):
pass
'''
mutables_test_text_005 = '''
def... | mutables_test_text_001 = '\ndef function(\n param,\n):\n pass\n'
mutables_test_text_002 = '\ndef function(\n param=0,\n):\n pass\n'
mutables_test_text_003 = '\ndef function(\n param={},\n):\n pass\n'
mutables_test_text_004 = '\ndef function(\n param=[],\n):\n pass\n'
mutables_test_text_005 = '\n... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Solution:
def merge(self, nums1, m: int, nums2, n: int) -> None:
"""
Do not return anything, modify nums1 in-place instead.
"""
for i in range(m):
nums1[-1-i] = nums1[m-1-i]
i = 0
j = 0
k = 0
... | class Solution:
def merge(self, nums1, m: int, nums2, n: int) -> None:
"""
Do not return anything, modify nums1 in-place instead.
"""
for i in range(m):
nums1[-1 - i] = nums1[m - 1 - i]
i = 0
j = 0
k = 0
while i < m and j < n:
... |
#
# PySNMP MIB module CISCO-ENTITY-FRU-CONTROL-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ENTITY-FRU-CONTROL-CAPABILITY
# Produced by pysmi-0.3.4 at Wed May 1 11:57:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Usi... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection) ... |
"""
Eventually we'll probably want to add some decent serialization support.
For now - this is a pass through. Patches accepted :)
"""
class Serializer(object):
def serialize(cls, obj):
return obj
def is_valid(self):
return True
| """
Eventually we'll probably want to add some decent serialization support.
For now - this is a pass through. Patches accepted :)
"""
class Serializer(object):
def serialize(cls, obj):
return obj
def is_valid(self):
return True |
name = "openimageio"
version = "2.0.0"
authors = [
"Larry Gritz"
]
description = \
"""
OpenImageIO is a library for reading and writing images, and a bunch of
related classes, utilities, and applications.
"""
private_build_requires = [
'cmake-3.2.2+',
"boost-1.55",
"gcc-4.8.2+",
... | name = 'openimageio'
version = '2.0.0'
authors = ['Larry Gritz']
description = '\n OpenImageIO is a library for reading and writing images, and a bunch of\n related classes, utilities, and applications.\n '
private_build_requires = ['cmake-3.2.2+', 'boost-1.55', 'gcc-4.8.2+', 'opencolorio-1.0.9', 'ilmbase-2.2'... |
"""
57 / 57 test cases passed.
Runtime: 104 ms
Memory Usage: 14.9 MB
"""
class Solution:
def largestTriangleArea(self, points: List[List[int]]) -> float:
def triangleArea(x1, y1, x2, y2, x3, y3):
return abs(x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2) / 2
return max(triangl... | """
57 / 57 test cases passed.
Runtime: 104 ms
Memory Usage: 14.9 MB
"""
class Solution:
def largest_triangle_area(self, points: List[List[int]]) -> float:
def triangle_area(x1, y1, x2, y2, x3, y3):
return abs(x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2) / 2
return max((... |
class User:
user_list = []
def __init__(self,f_name,l_name,password):
"""function that creates user object"""
self.f_name = f_name
self.l_name = l_name
self.password = password
def save_user(self):
"""function that saves users"""
User.user_list.append(self)
... | class User:
user_list = []
def __init__(self, f_name, l_name, password):
"""function that creates user object"""
self.f_name = f_name
self.l_name = l_name
self.password = password
def save_user(self):
"""function that saves users"""
User.user_list.append(sel... |
# validated: 2018-01-14 DV a68a0c3ebf0b libraries/driver/include/ctre/phoenix/MotorControl/Faults.h
__all__ = ['FaultsBase']
class FaultsBase:
fields = []
def __init__(self, bits = 0):
mask = 1
for field in self.fields:
setattr(self, field, bool(bits & mask))
mask <<... | __all__ = ['FaultsBase']
class Faultsbase:
fields = []
def __init__(self, bits=0):
mask = 1
for field in self.fields:
setattr(self, field, bool(bits & mask))
mask <<= 1
def to_bitfield(self):
retval = 0
mask = 1
for field in self.fields:
... |
# Databricks notebook source
HLRIOWYITKFDP
GOQFOEKSZNF
BQRYZYCEYRHRVDKCQSN
BELVHHTEWWKFYTNTWJIIYUQTBHUMOCJNDBBIPBOVCDIKTUPVXZRIUC
AUVGECGGHDZPJPMFEZWDFYYDXYGEMHXRHYXXGEMXTCZOPGPGSRCIQNPHCUONPPCBOWTFOZEYCXCQKKUNDSXSBAKSMWIPUKICUWX
HDCWKJXOZHPPXWBBPLIGLXMBATYPTDTCAACKEEWURDREVIIUPRJXDFNDLSHBZEBMWQOMYFWARMGERQAXVLFREGTYUX... | HLRIOWYITKFDP
GOQFOEKSZNF
BQRYZYCEYRHRVDKCQSN
BELVHHTEWWKFYTNTWJIIYUQTBHUMOCJNDBBIPBOVCDIKTUPVXZRIUC
AUVGECGGHDZPJPMFEZWDFYYDXYGEMHXRHYXXGEMXTCZOPGPGSRCIQNPHCUONPPCBOWTFOZEYCXCQKKUNDSXSBAKSMWIPUKICUWX
HDCWKJXOZHPPXWBBPLIGLXMBATYPTDTCAACKEEWURDREVIIUPRJXDFNDLSHBZEBMWQOMYFWARMGERQAXVLFREGTYUXPABORSDUP
XPSNALKIEEH
TNRJVKV... |
"""!
@brief Colors used by pyclustering library for visualization.
@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause
"""
class color:
"""!
@brief Consists titles of colors that are used by pyclustering for visualization.
"""
@staticmetho... | """!
@brief Colors used by pyclustering library for visualization.
@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause
"""
class Color:
"""!
@brief Consists titles of colors that are used by pyclustering for visualization.
"""
@staticmethod
def get_colo... |
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# Function to print the list
def printList(self):
node = self
output = ''
while node is not None:
output += str(node.val)
output += " "
node =... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
def print_list(self):
node = self
output = ''
while node is not None:
output += str(node.val)
output += ' '
node = node.next
print(output)
@stat... |
# My Script:
hrs=input('Enter Hours: ')
hrs=float(hrs)
rph=input('Enter your rate per hour: ')
rph=float(rph)
pay=hrs*rph
print('Pay:', pay)
| hrs = input('Enter Hours: ')
hrs = float(hrs)
rph = input('Enter your rate per hour: ')
rph = float(rph)
pay = hrs * rph
print('Pay:', pay) |
#!/usr/bin/python
def twosum(list, target):
for i in list:
for j in list:
if i != j and i + j == target:
return True
return False
with open('xmas.txt') as fh:
lines = fh.readlines()
nums = [int(l.strip()) for l in lines]
idx = 25
while(True):
last25 = nums[idx-25... | def twosum(list, target):
for i in list:
for j in list:
if i != j and i + j == target:
return True
return False
with open('xmas.txt') as fh:
lines = fh.readlines()
nums = [int(l.strip()) for l in lines]
idx = 25
while True:
last25 = nums[idx - 25:idx]
if twosum(la... |
class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
if len(nums) <= 2:
return max(nums)
dp = [0] * len(nums)
dp[0] = nums[0]
dp[1] = max... | class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
if len(nums) <= 2:
return max(nums)
dp = [0] * len(nums)
dp[0] = nums[0]
dp[1] = max(nums[0], nums[1])
... |
class Solution:
# Max to Min distance pair, O(n^2) time, O(1) space
def maxDistance(self, colors: List[int]) -> int:
for dist in range(len(colors)-1, 0, -1):
for i in range(len(colors)-dist):
if colors[i] != colors[i+dist]:
return dist
# Max dist from... | class Solution:
def max_distance(self, colors: List[int]) -> int:
for dist in range(len(colors) - 1, 0, -1):
for i in range(len(colors) - dist):
if colors[i] != colors[i + dist]:
return dist
def max_distance(self, A: List[int]) -> int:
(i, j) = (... |
#Functions
def userFunction(): #Putting Function
print("Hello, User :)")
print("Have a nice day!")
#Calling Function
userFunction()
| def user_function():
print('Hello, User :)')
print('Have a nice day!')
user_function() |
"""Define docstring substitutions.
Text to be replaced is specified as a key in the returned dictionary,
with the replacement text defined by the corresponding value.
Special docstring substitutions, as defined by a class's
`_docstring_special_substitutions` method, may be used in the
replacement text, and will be su... | """Define docstring substitutions.
Text to be replaced is specified as a key in the returned dictionary,
with the replacement text defined by the corresponding value.
Special docstring substitutions, as defined by a class's
`_docstring_special_substitutions` method, may be used in the
replacement text, and will be su... |
num_of_lines = int(input())
def cold_compress(cum, rs):
N = len(cum)
# exit
if (rs == ""):
output_string = ""
for s in cum:
output_string += str(s) + " "
return output_string
# iteration
if (N >= 2 and cum[N-1] == rs[0]):
cnt = cum[N-2]
cnt += 1
... | num_of_lines = int(input())
def cold_compress(cum, rs):
n = len(cum)
if rs == '':
output_string = ''
for s in cum:
output_string += str(s) + ' '
return output_string
if N >= 2 and cum[N - 1] == rs[0]:
cnt = cum[N - 2]
cnt += 1
cum[N - 2] = cnt
... |
# arr = [2, 3, -4, -9, -1, -7, 1, -5, -6]
arr = [0, 0, 0, 0]
def next_p(arr, l, x):
print("px0", x)
while x <= l - 1 and arr[x] < 0:
x += 1
print("px1", x)
print("px2", x)
return x
def next_n(arr, l, x):
print("nx0", x)
while x <= l - 1 and arr[x] >= 0:
x += 1
... | arr = [0, 0, 0, 0]
def next_p(arr, l, x):
print('px0', x)
while x <= l - 1 and arr[x] < 0:
x += 1
print('px1', x)
print('px2', x)
return x
def next_n(arr, l, x):
print('nx0', x)
while x <= l - 1 and arr[x] >= 0:
x += 1
print('nx1', x)
print('nx2', x)
ret... |
# -*- coding: utf-8 -*-
# OPENID URLS
URL_WELL_KNOWN = "realms/{realm-name}/.well-known/openid-configuration"
URL_TOKEN = "realms/{realm-name}/protocol/openid-connect/token"
URL_USERINFO = "realms/{realm-name}/protocol/openid-connect/userinfo"
URL_LOGOUT = "realms/{realm-name}/protocol/openid-connect/logout"
URL_CERTS... | url_well_known = 'realms/{realm-name}/.well-known/openid-configuration'
url_token = 'realms/{realm-name}/protocol/openid-connect/token'
url_userinfo = 'realms/{realm-name}/protocol/openid-connect/userinfo'
url_logout = 'realms/{realm-name}/protocol/openid-connect/logout'
url_certs = 'realms/{realm-name}/protocol/openid... |
#DEFAULT ARGS
print('Default Args : ')
def sample(a, b = 0, c = 1) :
print(a, b, c)
sample(10)
sample(10, 20)
sample(10, 20, 30)
#VARIABLE NUMBER OF ARGS
print('VARIABLE NUMBER OF ARGS : ')
def add(a, b, *t) :
s = a + b
for x in t :
s = s + x
return s
print(add(1, 2, 3, 4))
#KEY - WORD ARGS
print('KEY - WORD... | print('Default Args : ')
def sample(a, b=0, c=1):
print(a, b, c)
sample(10)
sample(10, 20)
sample(10, 20, 30)
print('VARIABLE NUMBER OF ARGS : ')
def add(a, b, *t):
s = a + b
for x in t:
s = s + x
return s
print(add(1, 2, 3, 4))
print('KEY - WORD ARGS : ')
def sample2(j, k, l):
print(j, k... |
string = 'b a '
newstring = string[-1::-1]
length = 0
print(newstring)
for i in range(0, len(newstring)):
if newstring[i] == ' ':
if i == 0:
continue
if newstring[i-1] == ' ':
continue
break
length += 1
print(length) | string = 'b a '
newstring = string[-1::-1]
length = 0
print(newstring)
for i in range(0, len(newstring)):
if newstring[i] == ' ':
if i == 0:
continue
if newstring[i - 1] == ' ':
continue
break
length += 1
print(length) |
NEPS_URL = 'https://neps.academy'
ENGLISH_BUTTON = '/html/body/div/div/div/div[2]/div/div/a/div[2]/div'
LOGIN_PAGE_BUTTON = '//*[@id="app"]/div/div/div/div[1]/div/header/div/div/div[3]/div/div/nav/ul/li[6]/button'
EMAIL_INPUT = '/html/body/div/div/div/div[3]/div/div/div/form/div[1]/div/div[1]/div/input'
PASSWORD_INPUT ... | neps_url = 'https://neps.academy'
english_button = '/html/body/div/div/div/div[2]/div/div/a/div[2]/div'
login_page_button = '//*[@id="app"]/div/div/div/div[1]/div/header/div/div/div[3]/div/div/nav/ul/li[6]/button'
email_input = '/html/body/div/div/div/div[3]/div/div/div/form/div[1]/div/div[1]/div/input'
password_input ... |
class Account:
"""Store login information(username and password)."""
def __init__(self, username='', password=''):
"""Store username and password."""
self.username = username
self.password = password
| class Account:
"""Store login information(username and password)."""
def __init__(self, username='', password=''):
"""Store username and password."""
self.username = username
self.password = password |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.