content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
CITIES_SIGSPATIAL = [
'Zagrzeb', 'Helsinki', 'Espoo', 'Tampere', 'Oulu',
'Lille', 'Nice', 'Toulouse', 'Nantes', 'Cologne',
'Aachen', 'Hamburg', 'Erfurt', 'Mannheim', 'Antwerp',
'Gent', 'Wieden', 'Karlsruhe', 'Ateny', 'Budapest',
'Wenecja', 'Florencja', 'Genoa', 'Turin', 'Palermo',
'Milan', 'O... | cities_sigspatial = ['Zagrzeb', 'Helsinki', 'Espoo', 'Tampere', 'Oulu', 'Lille', 'Nice', 'Toulouse', 'Nantes', 'Cologne', 'Aachen', 'Hamburg', 'Erfurt', 'Mannheim', 'Antwerp', 'Gent', 'Wieden', 'Karlsruhe', 'Ateny', 'Budapest', 'Wenecja', 'Florencja', 'Genoa', 'Turin', 'Palermo', 'Milan', 'Oslo', 'Szczecin', 'Lublin', ... |
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'targets': [
{
# GN version: //cc/ipc
'target_name': 'cc_ipc',
'type': '<(component)... | {'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'cc_ipc', 'type': '<(component)', 'dependencies': ['../../base/base.gyp:base', '../../cc/cc.gyp:cc', '../../gpu/gpu.gyp:gpu_ipc_common', '../../ipc/ipc.gyp:ipc', '../../skia/skia.gyp:skia', '../../ui/events/events.gyp:events_base', '../../ui/events/events.... |
APPEAL_LEVEL = (
('level 1', 'Level 1'),
('level 2', 'Level 2'),
('level 3', 'Level 3'),
('level 4', 'Level 4'),
)
APPEAL_SERVICE_CATEGORY = (
('practitioner services', 'Practitioner Services'),
('emergency room', 'Emergency Room'),
('acute inpatient hospital', 'Acute Inpatient Hospital'),
... | appeal_level = (('level 1', 'Level 1'), ('level 2', 'Level 2'), ('level 3', 'Level 3'), ('level 4', 'Level 4'))
appeal_service_category = (('practitioner services', 'Practitioner Services'), ('emergency room', 'Emergency Room'), ('acute inpatient hospital', 'Acute Inpatient Hospital'), ('office-based lab/x-ray', 'Offic... |
class CustomException(Exception):
def __init__(self, message="", data=None):
super(CustomException, self).__init__(self, message)
self.message = message
self.data = data
| class Customexception(Exception):
def __init__(self, message='', data=None):
super(CustomException, self).__init__(self, message)
self.message = message
self.data = data |
#encoding:utf-8
subreddit = 'terriblefacebookmemes'
t_channel = '@TerribleFacebookMemes'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| subreddit = 'terriblefacebookmemes'
t_channel = '@TerribleFacebookMemes'
def send_post(submission, r2t):
return r2t.send_simple(submission) |
# Given a string, find the length of the longest substring without repeating characters.
# Example 1:
# Input: "abcabcbbdd"
# Output: 3
# Explanation: The answer is "abc", with the length of 3.
def subString(str):
n = len(str)
# Start pos of final string , length of final string
start = 0
max_length... | def sub_string(str):
n = len(str)
start = 0
max_length = 0
visited_pos = {}
current_start = 0
current_length = 0
for i in range(0, n):
if str[i] not in visited_pos:
visited_pos[str[i]] = i
else:
if visited_pos[str[i]] >= current_start:
... |
#!/usr/bin/env python3
# encoding: utf-8
def error():
yield 1
raise Exception
def thing():
return error()
def main():
for x in thing(): # thing won't be in the traceback
pass
if __name__ == '__main__':
main()
| def error():
yield 1
raise Exception
def thing():
return error()
def main():
for x in thing():
pass
if __name__ == '__main__':
main() |
def solution():
T = int(input())
for t in range(1, T+1):
p = solve(t)
print('Case #%d: %d' % (t, p))
def isAllOne(i, n):
while n:
if n%i != 1:
return False
n //= i
return True
def solve(t):
n = int(input())
# (p^x-1)/(p-1) = n
# x>4, p<10^5
min... | def solution():
t = int(input())
for t in range(1, T + 1):
p = solve(t)
print('Case #%d: %d' % (t, p))
def is_all_one(i, n):
while n:
if n % i != 1:
return False
n //= i
return True
def solve(t):
n = int(input())
min_n = min(n, 10 ** 5)
for i in ... |
# Python - 3.6.0
def tail_swap(strings):
s1, s2 = strings
a, b = s1.split(':')
c, d = s2.split(':')
return [f'{a}:{d}', f'{c}:{b}']
| def tail_swap(strings):
(s1, s2) = strings
(a, b) = s1.split(':')
(c, d) = s2.split(':')
return [f'{a}:{d}', f'{c}:{b}'] |
cad = {}
apv = []
cad['nome'] = str(input('Nome do Jogador: '))
n = int(input(f'Quantas partidas {cad["nome"]} jogou? '))
for c in range (0,n):
apv.append(int(input(f'Quantos gols na partida {c+1}? ')))
cad['gols'] = apv[:]
cad['total'] = sum(apv)
print('-=-'*30)
for k, v in cad.items():
print(f'O campo {k} te... | cad = {}
apv = []
cad['nome'] = str(input('Nome do Jogador: '))
n = int(input(f"Quantas partidas {cad['nome']} jogou? "))
for c in range(0, n):
apv.append(int(input(f'Quantos gols na partida {c + 1}? ')))
cad['gols'] = apv[:]
cad['total'] = sum(apv)
print('-=-' * 30)
for (k, v) in cad.items():
print(f'O campo {... |
class TupleWithCallback(tuple):
def __new__(cls, *args, onDone=None):
t = tuple.__new__(cls, args)
if onDone is not None:
t.onDone = onDone
return t
| class Tuplewithcallback(tuple):
def __new__(cls, *args, onDone=None):
t = tuple.__new__(cls, args)
if onDone is not None:
t.onDone = onDone
return t |
WHITE, BLACK, NONE = "W", "B", " "
class Board:
def __init__(self, board):
self.board = [list(row) for row in board]
def territory(self, x, y):
if x < 0 or x >= len(self.board[0]) or y < 0 or y >= len(self.board):
raise ValueError(r".+")
if self.board[y][x] != NONE:
... | (white, black, none) = ('W', 'B', ' ')
class Board:
def __init__(self, board):
self.board = [list(row) for row in board]
def territory(self, x, y):
if x < 0 or x >= len(self.board[0]) or y < 0 or (y >= len(self.board)):
raise value_error('.+')
if self.board[y][x] != NONE:
... |
# Enter species name and filters
sp="Macaca_mulatta"
GQ_lim="60"
DP_min="0.5*mean_dp"
DP_max="2*mean_dp"
AB_max="0.7"
AB_min="0.3"
| sp = 'Macaca_mulatta'
gq_lim = '60'
dp_min = '0.5*mean_dp'
dp_max = '2*mean_dp'
ab_max = '0.7'
ab_min = '0.3' |
expected_chiral_data = [(True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... | expected_chiral_data = [(True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... |
def title(txt):
tam = len(txt)+4
print('-'*tam)
print(f' {txt}')
print('-'*tam)
while True:
title("SYSTEM HELPER PYHELP")
Helper = input("CAN I HELP YOU? TYPE A FUNCTION (FOR FINISH(END)): ")
if 'end' in Helper:
break
help(Helper)
title("THANKS! SEE YOU SOON!")
| def title(txt):
tam = len(txt) + 4
print('-' * tam)
print(f' {txt}')
print('-' * tam)
while True:
title('SYSTEM HELPER PYHELP')
helper = input('CAN I HELP YOU? TYPE A FUNCTION (FOR FINISH(END)): ')
if 'end' in Helper:
break
help(Helper)
title('THANKS! SEE YOU SOON!') |
def validate_input(msg, allowed):
i = ""
while i not in allowed:
i = input(msg)
return i
def format_choices(choices):
return " | ".join(choices)
| def validate_input(msg, allowed):
i = ''
while i not in allowed:
i = input(msg)
return i
def format_choices(choices):
return ' | '.join(choices) |
length = 5
width = 16.5
height = 12.5
volume = length * width * height
area = 2*length*width + 2*length*height + 2*width*height
print('volume =', volume)
print('area =', area)
| length = 5
width = 16.5
height = 12.5
volume = length * width * height
area = 2 * length * width + 2 * length * height + 2 * width * height
print('volume =', volume)
print('area =', area) |
#
# PySNMP MIB module EQLREPLPARTNER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EQLREPLPARTNER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:51:18 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')
(constraints_intersection, single_value_constraint, constraints_union, value_range_constraint, value_size_constraint) ... |
dictionary = {'A':'Alfa', 'B':'Bravo','C':'Charlie', 'D':'Delta', 'E':'Echo', 'F':'Foxtrot', 'G':'Golf', "H":"Hotel", 'I':'India', 'J':'Juliett', 'K':'Kilo', 'L':'Lima', 'M':'Mike', 'N':'November', 'O':'Oscar', 'P':'Papa', 'Q':'Quebec', 'R':'Romeo', 'S':'Sierra', 'T':'Tango', 'U':'Uniform', 'V':'Victor', 'W':'Whiskey',... | dictionary = {'A': 'Alfa', 'B': 'Bravo', 'C': 'Charlie', 'D': 'Delta', 'E': 'Echo', 'F': 'Foxtrot', 'G': 'Golf', 'H': 'Hotel', 'I': 'India', 'J': 'Juliett', 'K': 'Kilo', 'L': 'Lima', 'M': 'Mike', 'N': 'November', 'O': 'Oscar', 'P': 'Papa', 'Q': 'Quebec', 'R': 'Romeo', 'S': 'Sierra', 'T': 'Tango', 'U': 'Uniform', 'V': '... |
# Rewrite your pay computation with time-and-a-half for over-
# time and create a function called compute_pay which takes two parameters
# (hours and rate).
user_hours = input('Enter your hours worked: ')
user_hours = float(user_hours)
user_pay = input('Enter the rate per hour: ')
user_pay = float(user_pay)
def c... | user_hours = input('Enter your hours worked: ')
user_hours = float(user_hours)
user_pay = input('Enter the rate per hour: ')
user_pay = float(user_pay)
def compute_pay(hours, rate):
if user_hours > 40:
over_time = user_hours - 40
total_pay = over_time * (user_pay * 1.5) + 40 * user_pay
retu... |
'''write a function that shutters a word as if someone is struggling to read it. The first two letters are repeated twice with an ellipsis ... , and then the word is pronounced with a question mark?
Input Format
a string
Constraints
no
Output Format
xx... xx... ~~~~~~~?
Sample Input 0
incredible
Sample Output 0... | """write a function that shutters a word as if someone is struggling to read it. The first two letters are repeated twice with an ellipsis ... , and then the word is pronounced with a question mark?
Input Format
a string
Constraints
no
Output Format
xx... xx... ~~~~~~~?
Sample Input 0
incredible
Sample Output 0... |
class Solution:
def numSubmatrixSumTarget(self, matrix: List[List[int]], target: int) -> int:
m, n = len(matrix), len(matrix[0])
for row in matrix:
for i in range(n - 1):
row[i + 1] += row[i]
res = 0
for i in range(n):
for j in range(i, n):
... | class Solution:
def num_submatrix_sum_target(self, matrix: List[List[int]], target: int) -> int:
(m, n) = (len(matrix), len(matrix[0]))
for row in matrix:
for i in range(n - 1):
row[i + 1] += row[i]
res = 0
for i in range(n):
for j in range(i,... |
weth_abi = [
{
"constant": True,
"inputs": [],
"name": "name",
"outputs": [{"name": "tokenName", "type": "string"}],
"payable": False,
"stateMutability": "view",
"type": "function",
},
{
"constant": False,
"inputs": [
{"name... | weth_abi = [{'constant': True, 'inputs': [], 'name': 'name', 'outputs': [{'name': 'tokenName', 'type': 'string'}], 'payable': False, 'stateMutability': 'view', 'type': 'function'}, {'constant': False, 'inputs': [{'name': 'spender', 'type': 'address'}, {'name': 'value', 'type': 'uint256'}], 'name': 'approve', 'outputs':... |
class Person(object):
'''
Test class to show the functionality of model creation in the flask api.abs
It contains:
* first name = First name of a person
* last name = Last name of a person
'''
def __init__(self, first_name, last_name):
self.first_name - first_name
self.last =... | class Person(object):
"""
Test class to show the functionality of model creation in the flask api.abs
It contains:
* first name = First name of a person
* last name = Last name of a person
"""
def __init__(self, first_name, last_name):
self.first_name - first_name
self.last ... |
# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
short_version = '1.6.0'
version = '1.6.0'
full_version = '1.6.0'
git_revision = 'Unknown'
release = True
if not release:
version = full_version
| short_version = '1.6.0'
version = '1.6.0'
full_version = '1.6.0'
git_revision = 'Unknown'
release = True
if not release:
version = full_version |
class WrongPassword(Exception):
pass
class WrongEmail(Exception):
pass
class RequestedApproval(Exception):
pass
class UserBlocked(Exception):
pass
class DisabledInviting(Exception):
pass
class UnexpectedException(Exception):
pass
class NoDialogflowCredentialsFileFound(Exception):
... | class Wrongpassword(Exception):
pass
class Wrongemail(Exception):
pass
class Requestedapproval(Exception):
pass
class Userblocked(Exception):
pass
class Disabledinviting(Exception):
pass
class Unexpectedexception(Exception):
pass
class Nodialogflowcredentialsfilefound(Exception):
pass |
# temp = 19
# is_raining = False
# if temp > 15:
# print("take a hat")
# print("don't take a coat")
# else:
# print("don't take a hat")
# print("take a coat")
# if is_raining==True:
# print("take an umbrella")
# else:
# print("don't take an umbrella")
temp = int(input("\nwhat i... | temp = int(input('\nwhat is the tempreture ? '))
is_raining = input('\nis it raining ? ')
if temp > 15:
print('\ntake a hat')
print("don't take a coat")
else:
print("\ndon't take a hat")
print('take a coat')
if is_raining == 'yes':
print('take an umbrella')
else:
print("don't take an umbrella") |
# https://www.educative.io/courses/grokking-the-coding-interview/7XMlMEQPnnQ
def get_sum_between_ptr(sum_array, i, j):
if i == 0:
return sum_array[j]
else:
return sum_array[j] - sum_array[i - 1]
def get_smallest_subarray_size(size, ptr1, ptr2):
if size > (ptr2 - ptr1 + 1):
return... | def get_sum_between_ptr(sum_array, i, j):
if i == 0:
return sum_array[j]
else:
return sum_array[j] - sum_array[i - 1]
def get_smallest_subarray_size(size, ptr1, ptr2):
if size > ptr2 - ptr1 + 1:
return ptr2 - ptr1 + 1
else:
return size
def smallest_subarray_with_given_s... |
# Find the next greater and next smaller number with same number of set bits
# Ex. num = 6 bin = 110
def next_greater(num):
res = num
if num != 0:
# Find the right most 1 position
# Ex. right_one = 2 bin = 10
right_one = num & -num
# get the left pattern to merge
# Ex. ... | def next_greater(num):
res = num
if num != 0:
right_one = num & -num
left_pattern = num + right_one
right_pattern = (num ^ left_pattern) >> right_one + 1
res = left_pattern | right_pattern
return res
def next_smaller(num):
return ~next_greater(~num)
print(next_greater(6)... |
m = 1000000007
N, *c = map(int, open(0).read().split())
fac = [1] * (N + 1)
for i in range(N):
fac[i + 1] = fac[i] * (i + 1)
fac[i + 1] %= m
x = fac[N - 1] * (pow(10, N, m) - 1) * pow(9, -1, m) % m
frac = 0
denom = 1
for i in range(9):
if c[i] == 0:
continue
frac += c[i] * (i + 1) * x
fra... | m = 1000000007
(n, *c) = map(int, open(0).read().split())
fac = [1] * (N + 1)
for i in range(N):
fac[i + 1] = fac[i] * (i + 1)
fac[i + 1] %= m
x = fac[N - 1] * (pow(10, N, m) - 1) * pow(9, -1, m) % m
frac = 0
denom = 1
for i in range(9):
if c[i] == 0:
continue
frac += c[i] * (i + 1) * x
frac... |
# Copyright 2017, Ansible by Red Hat.
#
# 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 ... | version = '3.3.0'
cur_api_version = 'v2'
launch_type_choices = ['manual', 'relaunch', 'relaunch', 'callback', 'scheduled', 'dependency', 'workflow', 'sync', 'scm']
status_choices = ['new', 'pending', 'waiting', 'running', 'successful', 'failed', 'error', 'canceled']
inventory_source_choices = ['', 'file', 'scm', 'ec2',... |
#!/usr/bin/env python
# coding: utf-8
# In[1]:
bar=input()
bar = bar.replace('()','/')
raiser=0
ans=0
for i in bar:
if(i=='/'):
ans=ans+raiser
elif(i=='('):
raiser=raiser+1
else:
raiser=raiser-1
ans=ans+1
print(ans)
| bar = input()
bar = bar.replace('()', '/')
raiser = 0
ans = 0
for i in bar:
if i == '/':
ans = ans + raiser
elif i == '(':
raiser = raiser + 1
else:
raiser = raiser - 1
ans = ans + 1
print(ans) |
def extremize(y,level=0.1):
y[y<level]=0
y[y>=level]=1
return y
| def extremize(y, level=0.1):
y[y < level] = 0
y[y >= level] = 1
return y |
#!/usr/bin/env python3
COLLATZ_SIZE = 5000000 + 5
collatz = [0] * COLLATZ_SIZE
answers = [0] * COLLATZ_SIZE
for k in range(23):
collatz[2 ** k] = k
def calculate_collatz(N):
global collatz;
steps = 0
n = N
# Answers for n < N have been calculated already.
while (n >= N):
steps += 1
... | collatz_size = 5000000 + 5
collatz = [0] * COLLATZ_SIZE
answers = [0] * COLLATZ_SIZE
for k in range(23):
collatz[2 ** k] = k
def calculate_collatz(N):
global collatz
steps = 0
n = N
while n >= N:
steps += 1
n = n // 2 if n % 2 == 0 else 3 * n + 1
collatz[N] = collatz[n] + steps
... |
__author__ = 'Comma'
END = -1
MAIN_PANEL = 1
POST_START = 10
POST_SELECT_FIELD = 11
POST_FILL_VALUE = 12
POST_BEFORE_SUBMIT = 13
POST_SUBMIT = 14
UPDATE_START = 15
UPDATE_SELECT_TICKET = 16
UPDATE_SELECT_FIELD = 17
UPDATE_FILL_VALUE = 18
UPDATE_BEFORE_SUBMIT = 19
UPDATE_SUBMIT = 20
SEARCH_START = 21
SEARCH_SELECT_F... | __author__ = 'Comma'
end = -1
main_panel = 1
post_start = 10
post_select_field = 11
post_fill_value = 12
post_before_submit = 13
post_submit = 14
update_start = 15
update_select_ticket = 16
update_select_field = 17
update_fill_value = 18
update_before_submit = 19
update_submit = 20
search_start = 21
search_select_field... |
'''
Created on 1.12.2016
@author: Darren
'''
'''
Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.
You may assume each number in the sequence is unique.
Follow up:
Could you do it using only constant space complexity?
'''
| """
Created on 1.12.2016
@author: Darren
"""
'\nGiven an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.\n\nYou may assume each number in the sequence is unique.\n\nFollow up:\nCould you do it using only constant space complexity?\n' |
# flake8: noqa
# lambda function atau dikenal juga dengan anonymous function
# adalah function yang bisa menerima multiple arguments
# tapi hanya bisa melakukan 1 expression
# seperti contoh pada lambda luas_persegi dibawah
# hanya input s, dan satu expresi yaitu, s * s
luas_persegi = lambda s: s ** 2
print(luas_per... | luas_persegi = lambda s: s ** 2
print(luas_persegi(4))
luas_segitiga = lambda a, t: a * t / 2
print(luas_segitiga(2, 3))
infinite = lambda *input: sum(input)
print(infinite(1, 2, 3))
print(infinite(1, 2, 3, 4))
key_inf = lambda **kwargs: sum(kwargs.values())
print(key_inf(satu=1, dua=2, tiga=3))
print(key_inf(seven=7, ... |
load(
"//tensorflow:tensorflow.bzl",
"tf_binary_additional_srcs",
)
# Generate Java wrapper classes for all registered core operations and package
# them into a single source archive (.srcjar).
#
# For example:
# tf_java_op_gen_srcjar("gen_sources", ":gen_tool", "my.package")
#
# will create a genrule named "... | load('//tensorflow:tensorflow.bzl', 'tf_binary_additional_srcs')
def tf_java_op_gen_srcjar(name, gen_tool, base_package, api_def_srcs=[], out_dir='ops/', out_src_dir='src/main/java/', visibility=['//tensorflow/java:__pkg__']):
gen_cmds = ['rm -rf $(@D)']
srcs = api_def_srcs[:]
if not api_def_srcs:
... |
class Foo:
def __init__(self):
self.name = 'Foo name'
class Bar:
def __init__(self):
self.last_name = 'Bar name'
class DataAdapter:
def __init__(self, source, target):
self.source = type(source)
self.target = type(target)
def do(self, source, target=None):
... | class Foo:
def __init__(self):
self.name = 'Foo name'
class Bar:
def __init__(self):
self.last_name = 'Bar name'
class Dataadapter:
def __init__(self, source, target):
self.source = type(source)
self.target = type(target)
def do(self, source, target=None):
i... |
# for loop
for x in range(1, 20):
print(x)
# WHILE
age = 5
while age < 10:
print(age)
age += 1
| for x in range(1, 20):
print(x)
age = 5
while age < 10:
print(age)
age += 1 |
{ # pylint: disable=C8101,C8103
'name': 'Odoo Next - Eletronic documents',
'description': 'Enable Eletronic Documents',
'version': '14.0.1.0.0',
'category': 'Localization',
'author': 'Trustcode',
'license': 'OEEL-1',
'website': 'http://www.odoo-next.com,br',
'contributors': [
'D... | {'name': 'Odoo Next - Eletronic documents', 'description': 'Enable Eletronic Documents', 'version': '14.0.1.0.0', 'category': 'Localization', 'author': 'Trustcode', 'license': 'OEEL-1', 'website': 'http://www.odoo-next.com,br', 'contributors': ['Danimar Ribeiro <danimaribeiro@gmail.com>'], 'depends': ['l10n_br_account'... |
class Action:
def __init__(self, name, parameter, precondition, effects):
self.name = name
self.parameter = parameter
self.precondition = precondition
self.effects = effects
def update_params(self, param_type, param_mapping, p_objects):
self.parameter = param_type
... | class Action:
def __init__(self, name, parameter, precondition, effects):
self.name = name
self.parameter = parameter
self.precondition = precondition
self.effects = effects
def update_params(self, param_type, param_mapping, p_objects):
self.parameter = param_type
... |
INVALID_DATE = "Invalid date format provided. Please YYYY/MM/dd date format"
COIN_UNAVAILABLE = "Coin with given id does not exist"
COIN_ID_NOT_PROVIDED = "A coin_id must be provided"
QUERY_DATE_NOT_PROVIDED = "A query date must be provided"
CURRENCY_CODE_NOT_PROVIDED = "A currency code must be provided"
FUTURE_DATE_NO... | invalid_date = 'Invalid date format provided. Please YYYY/MM/dd date format'
coin_unavailable = 'Coin with given id does not exist'
coin_id_not_provided = 'A coin_id must be provided'
query_date_not_provided = 'A query date must be provided'
currency_code_not_provided = 'A currency code must be provided'
future_date_no... |
class Sources:
'''
Sources class that defines source objects
'''
def __init__(self,id,name,author,description,url,category,urlToImage,title):
'''
Function that initiates the sources class
'''
self.id = id
self.name = name
self.author = author
self.... | class Sources:
"""
Sources class that defines source objects
"""
def __init__(self, id, name, author, description, url, category, urlToImage, title):
"""
Function that initiates the sources class
"""
self.id = id
self.name = name
self.author = author
... |
n=int(input())
prices=input().split(" ")
temp_buy_date=0
buy_price=(1<<31)-1
buy_date=0
profit=0
for i in range(n) :
p=int(prices[i])
if p<buy_price :
buy_price=p
temp_buy_date=i+1
elif p-buy_price>profit :
buy_date=temp_buy_date
profit=p-buy_price
print(str(profit)+"\n"+str(buy_date))
| n = int(input())
prices = input().split(' ')
temp_buy_date = 0
buy_price = (1 << 31) - 1
buy_date = 0
profit = 0
for i in range(n):
p = int(prices[i])
if p < buy_price:
buy_price = p
temp_buy_date = i + 1
elif p - buy_price > profit:
buy_date = temp_buy_date
profit = p - buy_... |
tokens = [
('{', 'LKEY'),
('}', 'RKEY'),
('[', 'LBRACKETS'),
(']', 'RBRACKETS'),
('(', 'LPARENTHESES'),
(')', 'RPARENTHESES'),
('+', 'PLUS'),
('-', 'MINUS'),
('/', 'DIVISION'),
('%', 'MODULO'),
('~', 'NOT'),
('=', 'EQUALS'),
('<', 'LT'),
('>', 'GT'),
('<=', 'L... | tokens = [('{', 'LKEY'), ('}', 'RKEY'), ('[', 'LBRACKETS'), (']', 'RBRACKETS'), ('(', 'LPARENTHESES'), (')', 'RPARENTHESES'), ('+', 'PLUS'), ('-', 'MINUS'), ('/', 'DIVISION'), ('%', 'MODULO'), ('~', 'NOT'), ('=', 'EQUALS'), ('<', 'LT'), ('>', 'GT'), ('<=', 'LTE'), ('>=', 'GTE'), ('==', 'DOUBLEEQUAL'), ('&', 'AND'), ('|... |
# coding: utf-8
REDIS_URL = 'redis://redis:6379/0'
REDIS_CONF = {
'url': REDIS_URL,
'socket_timeout': 0.5,
}
WEBHOOK_TYPES = ['jira', 'jenkins']
LOG_DIR = '/var/log'
HOST = '120.78.197.57'
| redis_url = 'redis://redis:6379/0'
redis_conf = {'url': REDIS_URL, 'socket_timeout': 0.5}
webhook_types = ['jira', 'jenkins']
log_dir = '/var/log'
host = '120.78.197.57' |
class Point:
def __init__(self, value):
self.value = value
self.mark = False
def __str__(self):
return f"value: {self.value}, marked: {self.mark}"
def get_value(self):
return self.value
def get_mark(self):
return self.mark
def mark_point(self):
se... | class Point:
def __init__(self, value):
self.value = value
self.mark = False
def __str__(self):
return f'value: {self.value}, marked: {self.mark}'
def get_value(self):
return self.value
def get_mark(self):
return self.mark
def mark_point(self):
se... |
def _impl(ctx):
in_file = ctx.file.src
basename = ctx.attr.src.label.name
out_file = ctx.actions.declare_file("%s.gz" % basename)
cmd = "gzip --no-name -c '%s' > '%s'" % (in_file.path, out_file.path)
ctx.actions.run_shell(
outputs = [out_file],
inputs = [in_file],
command ... | def _impl(ctx):
in_file = ctx.file.src
basename = ctx.attr.src.label.name
out_file = ctx.actions.declare_file('%s.gz' % basename)
cmd = "gzip --no-name -c '%s' > '%s'" % (in_file.path, out_file.path)
ctx.actions.run_shell(outputs=[out_file], inputs=[in_file], command=cmd)
return [default_info(fi... |
# inserts "\t* " before each line in the selection
text = bg.components.fldDocument.getStringSelection()
unorderedList = ""
for i in text.splitlines(1):
unorderedList += "\t* " + i
bg.components.fldDocument.replaceSelection(unorderedList)
| text = bg.components.fldDocument.getStringSelection()
unordered_list = ''
for i in text.splitlines(1):
unordered_list += '\t* ' + i
bg.components.fldDocument.replaceSelection(unorderedList) |
class Solution:
def freqAlphabets(self, s: str) -> str:
chars = string.ascii_lowercase
m = dict(zip('123456789', chars[:9]))
m.update(dict(zip(['{}#'.format(val) for val in range(10, 27)], chars[9:])))
n = len(s)
ans = []
i = 0
while i < n:
if i + ... | class Solution:
def freq_alphabets(self, s: str) -> str:
chars = string.ascii_lowercase
m = dict(zip('123456789', chars[:9]))
m.update(dict(zip(['{}#'.format(val) for val in range(10, 27)], chars[9:])))
n = len(s)
ans = []
i = 0
while i < n:
if i ... |
# settings.py
def get_defaults():
return {
'aleph': {
'queue_topic': 'ALEPH-QUEUE',
'host': '127.0.0.1',
'port': 8080
},
'p2p': {
'port': 4025,
'http_port': 4024,
'host': '0.0.0.0',
'key': None,
'... | def get_defaults():
return {'aleph': {'queue_topic': 'ALEPH-QUEUE', 'host': '127.0.0.1', 'port': 8080}, 'p2p': {'port': 4025, 'http_port': 4024, 'host': '0.0.0.0', 'key': None, 'reconnect_delay': 60, 'clients': ['http'], 'peers': ['/ip4/51.159.57.71/tcp/4025/p2p/QmZkurbY2G2hWay59yiTgQNaQxHSNzKZFt2jbnwJhQcKgV', '/ip... |
class Console:
def __init__(self, text=None):
if text is None:
text = ""
self.text = "\n"
self.add(text)
def get(self):
return self.text
def add(self, maybe_text):
try:
self.text += " " + maybe_text + "\n"
except TypeError:
... | class Console:
def __init__(self, text=None):
if text is None:
text = ''
self.text = '\n'
self.add(text)
def get(self):
return self.text
def add(self, maybe_text):
try:
self.text += ' ' + maybe_text + '\n'
except TypeError:
... |
# Keywords
KW_START = 'KW_START'
KW_STOP = 'KW_STOP'
KW_VAR = 'KW_VAR'
KW_AS = 'KW_AS'
KW_INT = 'KW_INTEGER'
KW_FLOAT = 'KW_FLOATING'
KW_STRING = 'KW_STRING'
KW_BOOLEAN = 'KW_BOOLEAN'
KW_OUTPUT = 'KW_OUTPUT'
KW_INPUT = 'KW_INPUT'
KW_CHAR = 'KW_CHAR'
# LANGUAGE SPECIFICS
NEWLINE = 'NL' # Value is (#)
CONCATENATOR = '... | kw_start = 'KW_START'
kw_stop = 'KW_STOP'
kw_var = 'KW_VAR'
kw_as = 'KW_AS'
kw_int = 'KW_INTEGER'
kw_float = 'KW_FLOATING'
kw_string = 'KW_STRING'
kw_boolean = 'KW_BOOLEAN'
kw_output = 'KW_OUTPUT'
kw_input = 'KW_INPUT'
kw_char = 'KW_CHAR'
newline = 'NL'
concatenator = 'CON'
comment_init = 'COMI'
escape_open = 'ESCO'
es... |
class FinderError(Exception):
pass
class MultipleMatchesError(FinderError):
pass
class NoMatchesError(FinderError):
pass
class Finder(object):
def __init__(self, root, item_finder_factory):
self._root = root
self.item_finder_factory = item_finder_factory
def find(self, matcher... | class Findererror(Exception):
pass
class Multiplematcheserror(FinderError):
pass
class Nomatcheserror(FinderError):
pass
class Finder(object):
def __init__(self, root, item_finder_factory):
self._root = root
self.item_finder_factory = item_finder_factory
def find(self, matcher_s... |
tableau20 = [
'steelblue', # 0
'lightsteelblue', # 1
'darkorange', # 2
'peachpuff', # 3
'green', # 4
'lightgreen', # 5
'crimson', # 6
'lightcoral', # 7
'mediumpurple', # 8
'thistle', # 9
'saddlebrown', # 10
'rosybrown', # 11
'orchid', # 12
'lightpink'... | tableau20 = ['steelblue', 'lightsteelblue', 'darkorange', 'peachpuff', 'green', 'lightgreen', 'crimson', 'lightcoral', 'mediumpurple', 'thistle', 'saddlebrown', 'rosybrown', 'orchid', 'lightpink', 'gray', 'lightgray', 'olive', 'palegoldenrod', 'mediumturquoise', 'paleturquoise']
tableau10 = ['blue', 'darkorange', 'gree... |
#!/usr/bin/env python3
N = int(input())
P = [int(_) for _ in input().split()]
count = 0
flag = False
for i, v in enumerate(P):
ii = i + 1
if v == ii:
if flag:
flag = False
else:
count += 1
flag = True
elif flag:
flag = False
print(count)
| n = int(input())
p = [int(_) for _ in input().split()]
count = 0
flag = False
for (i, v) in enumerate(P):
ii = i + 1
if v == ii:
if flag:
flag = False
else:
count += 1
flag = True
elif flag:
flag = False
print(count) |
#!/usr/bin/env python
oracle_home = '/usr/local/ohs'
domain_name = 'base_domain'
domain_home = oracle_home + '/user_projects/domains/' + domain_name
node_manager_name = 'localmachine'
component_name = 'ohs1'
component_admin_listen_address = '127.0.0.1'
component_admin_listen_port = '9999'
component_listen_address = ''... | oracle_home = '/usr/local/ohs'
domain_name = 'base_domain'
domain_home = oracle_home + '/user_projects/domains/' + domain_name
node_manager_name = 'localmachine'
component_name = 'ohs1'
component_admin_listen_address = '127.0.0.1'
component_admin_listen_port = '9999'
component_listen_address = ''
component_listen_port ... |
# Copyright (c) 2020 Rocky Bernstein
def testtrue(self, lhs: str, n: int, rule, ast, tokens, first: int, last: int) -> bool:
# FIXME: make this work for all versions
if self.version != 3.7:
return False
if rule == ("testtrue", ("expr", "POP_JUMP_IF_TRUE")):
pjit = tokens[min(last - 1, n -... | def testtrue(self, lhs: str, n: int, rule, ast, tokens, first: int, last: int) -> bool:
if self.version != 3.7:
return False
if rule == ('testtrue', ('expr', 'POP_JUMP_IF_TRUE')):
pjit = tokens[min(last - 1, n - 2)]
if pjit == 'POP_JUMP_IF_TRUE_BACK':
assert_next = tokens[min... |
# -*- coding: utf-8 -*-
class Solution:
def reverseString(self, s):
return s[::-1]
if __name__ == '__main__':
solution = Solution()
assert 'olleh' == solution.reverseString('hello')
assert 'amanaP :lanac a ,nalp a ,nam A' == solution.\
reverseString('A man, a plan, a canal: Panama')... | class Solution:
def reverse_string(self, s):
return s[::-1]
if __name__ == '__main__':
solution = solution()
assert 'olleh' == solution.reverseString('hello')
assert 'amanaP :lanac a ,nalp a ,nam A' == solution.reverseString('A man, a plan, a canal: Panama') |
# taken from https://sashat.me/2017/01/11/list-of-20-simple-distinct-colors/
rainbow = [
(230, 25, 75),
(60, 180, 75),
(255, 225, 25),
(0, 130, 200),
(245, 130, 48),
(145, 30, 180),
(70, 240, 240),
(240, 50, 230),
(210, 245, 60),
(250, 190, 190),
(0, 128, 128),
(230, 190,... | rainbow = [(230, 25, 75), (60, 180, 75), (255, 225, 25), (0, 130, 200), (245, 130, 48), (145, 30, 180), (70, 240, 240), (240, 50, 230), (210, 245, 60), (250, 190, 190), (0, 128, 128), (230, 190, 255), (170, 110, 40), (255, 250, 200), (128, 0, 0), (170, 255, 195), (128, 128, 0), (255, 215, 180), (0, 0, 128), (128, 128, ... |
sample_rate = 44100
window_size = 2048 # 1024 # 2048
overlap = 672 # 256 # 672 # So that there are 320 frames in an audio clip
seq_len = 320 # 573 # 320
mel_bins = 64
labels = ['airport', 'bus', 'metro', 'metro_station', 'park', 'public_square',
'shopping_mall', 'street_pedestrian', 'street_traffic', 'tra... | sample_rate = 44100
window_size = 2048
overlap = 672
seq_len = 320
mel_bins = 64
labels = ['airport', 'bus', 'metro', 'metro_station', 'park', 'public_square', 'shopping_mall', 'street_pedestrian', 'street_traffic', 'tram']
lb_to_ix = {lb: ix for (ix, lb) in enumerate(labels)}
ix_to_lb = {ix: lb for (ix, lb) in enumera... |
# Algorithms for computer algebra, Geddes
# a, b in R, R es D.F.U.
# return gcd(a, b)
def primitive_euclidean(a, b, R):
c = R.primitive_part(a)
d = R.primitive_part(b)
while d != R.zero():
r = primitive_reminder(c, d, R)
c = d
d = R.primitive_part(r)
F = R.get_domain()
gamma... | def primitive_euclidean(a, b, R):
c = R.primitive_part(a)
d = R.primitive_part(b)
while d != R.zero():
r = primitive_reminder(c, d, R)
c = d
d = R.primitive_part(r)
f = R.get_domain()
gamma = F.gcd(R.cont(a), R.cont(b))
g = R.mul(gamma, c)
return g
def primitive_remi... |
a = float(input("Enter The Base : "))
b = float(input("Enter The Hight : "))
Area = 0.5 * a * b
print("Triangle Area is:",Area)
| a = float(input('Enter The Base : '))
b = float(input('Enter The Hight : '))
area = 0.5 * a * b
print('Triangle Area is:', Area) |
def test_publish(judge_command):
judge_command(
"publish foo bar", {"command": "publish", "channel": "foo", "message": "bar"}
)
def test_subscribe(judge_command):
judge_command("subscribe foo bar", {"command": "subscribe", "channel": "bar"})
def test_pubsub(judge_command):
judge_command(
... | def test_publish(judge_command):
judge_command('publish foo bar', {'command': 'publish', 'channel': 'foo', 'message': 'bar'})
def test_subscribe(judge_command):
judge_command('subscribe foo bar', {'command': 'subscribe', 'channel': 'bar'})
def test_pubsub(judge_command):
judge_command('PUBSUB NUMSUB foo b... |
def reverse_string(x):
# Reversing a string
output = ""
for c in x:
output = c + output
return output
print(reverse_string("hello"))
def reverse_string_2(x):
output = [None] * len(x)
idx = len(x)-1
for c in x:
output[idx] = c
idx -= 1
return ''.join(output)
pri... | def reverse_string(x):
output = ''
for c in x:
output = c + output
return output
print(reverse_string('hello'))
def reverse_string_2(x):
output = [None] * len(x)
idx = len(x) - 1
for c in x:
output[idx] = c
idx -= 1
return ''.join(output)
print(reverse_string_2('hell... |
class Integer:
def __init__(self, value):
self.value = value
@classmethod
def from_float(cls, value):
if isinstance(value, float):
return cls(int(value))
return 'value is not a float'
@classmethod
def from_roman(cls, value):
roman = {'I': 1, 'V': 5, 'X':... | class Integer:
def __init__(self, value):
self.value = value
@classmethod
def from_float(cls, value):
if isinstance(value, float):
return cls(int(value))
return 'value is not a float'
@classmethod
def from_roman(cls, value):
roman = {'I': 1, 'V': 5, 'X'... |
file = open("4_dna_sequences.txt")
all_lines = file.readlines()
for line in all_lines:
print("> " + line[:5] + '\n' + line[8:].replace('"', "").replace("-", "").upper())
file.close()
| file = open('4_dna_sequences.txt')
all_lines = file.readlines()
for line in all_lines:
print('> ' + line[:5] + '\n' + line[8:].replace('"', '').replace('-', '').upper())
file.close() |
N, M, A, B = map(int, input().split())
t = N
for i in range(M):
if t <= A:
t += B
c = int(input())
t -= c
if t < 0:
print(i + 1)
break
else:
print('complete')
| (n, m, a, b) = map(int, input().split())
t = N
for i in range(M):
if t <= A:
t += B
c = int(input())
t -= c
if t < 0:
print(i + 1)
break
else:
print('complete') |
def handle_num(num: str):
s = ''
for c in num:
if c != ' ':
s += c
if s[:1] == '0':
s = '0o'+s[1:]
return int(s, 8)
return int(s)
def handle_article(path_from, path_to):
with open(path_from, 'r') as f_in:
with open(path_to, 'w') as f_out:
for ... | def handle_num(num: str):
s = ''
for c in num:
if c != ' ':
s += c
if s[:1] == '0':
s = '0o' + s[1:]
return int(s, 8)
return int(s)
def handle_article(path_from, path_to):
with open(path_from, 'r') as f_in:
with open(path_to, 'w') as f_out:
fo... |
def search1(pat: str, txt: str):
M = len(pat)
N = len(txt)
for i in range(N - M + 1):
j = 0
while j < M:
if txt[i + j] == pat[j]: # index should be i + j for txt
j += 1
else:
break
if j == M:
return i
return N
... | def search1(pat: str, txt: str):
m = len(pat)
n = len(txt)
for i in range(N - M + 1):
j = 0
while j < M:
if txt[i + j] == pat[j]:
j += 1
else:
break
if j == M:
return i
return N
def search2(pat: str, txt: str):
... |
class PdfPageContainer:
def __init__(self):
self.triples = []
self.shapes = []
| class Pdfpagecontainer:
def __init__(self):
self.triples = []
self.shapes = [] |
def test_laptops_catalogue(browser, url):
browser.get(url + 'admin')
browser.find_element_by_css_selector("#container #header")
browser.find_element_by_css_selector("#container #content")
browser.find_element_by_css_selector("#container #footer")
browser.find_element_by_css_selector(".panel")
b... | def test_laptops_catalogue(browser, url):
browser.get(url + 'admin')
browser.find_element_by_css_selector('#container #header')
browser.find_element_by_css_selector('#container #content')
browser.find_element_by_css_selector('#container #footer')
browser.find_element_by_css_selector('.panel')
br... |
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8899
c.NotebookApp.token = ''
c.NotebookApp.password = ''
| c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8899
c.NotebookApp.token = ''
c.NotebookApp.password = '' |
def index():
images = db().select(db.image.ALL, orderby=db.image.title)
return dict(images=images)
@auth.requires_login()
def show():
image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
db.post.image_id.default = image.id
form = SQLFORM(db.post)
if form.process().accepted:
... | def index():
images = db().select(db.image.ALL, orderby=db.image.title)
return dict(images=images)
@auth.requires_login()
def show():
image = db.image(request.args(0, cast=int)) or redirect(url('index'))
db.post.image_id.default = image.id
form = sqlform(db.post)
if form.process().accepted:
... |
#!/usr/bin/env python3
# TODO refactor to move the following from globals to config/settings (if appropriate?)
SF_COUNTS = 1 # 1000 # scale factor for counts (e.g. instead of 4,00,000 -- scale to 400)
NUM_PTS = 20 # how much of a history of searched points to keep/observe
| sf_counts = 1
num_pts = 20 |
def count_positives_sum_negatives(arr):
positive = [i for i in arr if i>0]
negative = [i for i in arr if i<0]
# print(positive)
# print(negative)
# if arr:
# return [len(positive), sum(negative)]
# else:
# return []
return [len(positive), sum(negative)] if arr else [... | def count_positives_sum_negatives(arr):
positive = [i for i in arr if i > 0]
negative = [i for i in arr if i < 0]
return [len(positive), sum(negative)] if arr else []
print(count_positives_sum_negatives([]))
print(count_positives_sum_negatives([0, 2, 3, 0, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14])) |
class BaseSorter:
def __init__(self, name, filePath):
self.name = name
self.filePath = filePath
self.readFile()
def readFile(self):
with open(self.filePath, "r") as f:
self.data = [int(x.strip("\n")) for x in f.readlines()]
| class Basesorter:
def __init__(self, name, filePath):
self.name = name
self.filePath = filePath
self.readFile()
def read_file(self):
with open(self.filePath, 'r') as f:
self.data = [int(x.strip('\n')) for x in f.readlines()] |
terms = 11
result = list(map(lambda x: 2 ** x, range(terms)))
print("The total terms are:",terms)
for i in range(terms):
print("2 raised to power",i,"is",result[i]) | terms = 11
result = list(map(lambda x: 2 ** x, range(terms)))
print('The total terms are:', terms)
for i in range(terms):
print('2 raised to power', i, 'is', result[i]) |
in_name = 'input.txt'
out_name = 'commented_gc_program.txt'
with open(in_name, 'r') as f:
with open(out_name, 'w') as f_out:
for ipcount, line in enumerate(f.readlines()):
f_out.write(f'{ipcount:03}: {line}') | in_name = 'input.txt'
out_name = 'commented_gc_program.txt'
with open(in_name, 'r') as f:
with open(out_name, 'w') as f_out:
for (ipcount, line) in enumerate(f.readlines()):
f_out.write(f'{ipcount:03}: {line}') |
#Q1: What is the time complexity of
nums = [4, 78, 9, 84]
longitud = len(nums)
for i in range(longitud):
print(nums[longitud-i-1])
#Es de orden lineal O(n)
| nums = [4, 78, 9, 84]
longitud = len(nums)
for i in range(longitud):
print(nums[longitud - i - 1]) |
def lanche(*itens):
print(itens)
lanche('hot-dog')
lanche('calabresa','x-salada','x-burguer')
| def lanche(*itens):
print(itens)
lanche('hot-dog')
lanche('calabresa', 'x-salada', 'x-burguer') |
# Function "greet" examples call stack
def greet(name):
print('Hello, ' + name + '!')
greet2(name)
print('Getting ready to say bye...')
bye()
def greet2(name):
print('How are you, ' + name + '?')
def bye():
print('Ok, bye!')
if __name__ == '__main__':
greet(input('Input name: '))
| def greet(name):
print('Hello, ' + name + '!')
greet2(name)
print('Getting ready to say bye...')
bye()
def greet2(name):
print('How are you, ' + name + '?')
def bye():
print('Ok, bye!')
if __name__ == '__main__':
greet(input('Input name: ')) |
class MissingActiveToken(Exception):
def __init__(self, token=None, message="Missing Active Token") -> None:
self.token = token
self.message = message
super().__init__(self.message)
def __str__(self):
return f"{self.token} -> {self.message}"
| class Missingactivetoken(Exception):
def __init__(self, token=None, message='Missing Active Token') -> None:
self.token = token
self.message = message
super().__init__(self.message)
def __str__(self):
return f'{self.token} -> {self.message}' |
# Copyright 2017 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.
# This file is automatically generated by mkgrokdump and should not
# be modified manually.
# List of known V8 instance types.
INSTANCE_TYPES = {
0: "IN... | instance_types = {0: 'INTERNALIZED_STRING_TYPE', 2: 'EXTERNAL_INTERNALIZED_STRING_TYPE', 8: 'ONE_BYTE_INTERNALIZED_STRING_TYPE', 10: 'EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE', 18: 'EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE', 34: 'SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE', 42: 'SHORT_EXTERNAL_ONE_BYTE_INTER... |
def main():
e_pace = 8*60+15 ## easy pace in seconds
t_mile = 7*60+12 ## tempo in seconds
# I run 1 mile at Easy Pace + 3 Miles at tempo + 1 more at Easy Pace
total_min = (e_pace+3*t_mile+e_pace)/60 #Total in minutes
ini_hour_m = 6*60+52 ## departure time in minutes
return_hour_h = (total_mi... | def main():
e_pace = 8 * 60 + 15
t_mile = 7 * 60 + 12
total_min = (e_pace + 3 * t_mile + e_pace) / 60
ini_hour_m = 6 * 60 + 52
return_hour_h = (total_min + ini_hour_m) / 60
h = int(str(return_hour_h).split('.')[0])
m = int(float('0.' + str(return_hour_h).split('.')[1][0:2]) * 60)
print('... |
# my solution to kata found here:
# https://www.codewars.com/kata/numbers-in-strings
def solve(s):
prev = '0'
s2 = ''
for character in s:
if character.isalpha():
character = ' '
s2 += character
t = s2.split()
t2 = []
for string in t:
t2.append(int(string))
... | def solve(s):
prev = '0'
s2 = ''
for character in s:
if character.isalpha():
character = ' '
s2 += character
t = s2.split()
t2 = []
for string in t:
t2.append(int(string))
return max(t2) |
list=[1,2,3,4,5]
n=2
le=len(list)
list1=[0,0]
list2=[0,0,]
for i in range(0,n):
list1[i]=list[i]
#list.remove(list[i])
for j in range(n,le):
list2[j]=list[j]
print(list)
print(list2+list1)
| list = [1, 2, 3, 4, 5]
n = 2
le = len(list)
list1 = [0, 0]
list2 = [0, 0]
for i in range(0, n):
list1[i] = list[i]
for j in range(n, le):
list2[j] = list[j]
print(list)
print(list2 + list1) |
input()
A = [*map(int,input().split())]
B = [*map(int,input().split())]
for i in B:
for j in range(len(A)):
if i <= A[j]:
A[j] -= i
break
print(sum(A))
| input()
a = [*map(int, input().split())]
b = [*map(int, input().split())]
for i in B:
for j in range(len(A)):
if i <= A[j]:
A[j] -= i
break
print(sum(A)) |
# Link: https://leetcode.com/problems/search-insert-position/
# Time: O(LogN)
# Space: O(1)
def search_insert_position(nums, target):
start, end = 0, len(nums) - 1
while start <= end:
mid = (start + end) // 2
if nums[mid] == target:
return mid
elif nums[mid] < target:
... | def search_insert_position(nums, target):
(start, end) = (0, len(nums) - 1)
while start <= end:
mid = (start + end) // 2
if nums[mid] == target:
return mid
elif nums[mid] < target:
start = mid + 1
else:
end = mid - 1
return start
def main(... |
class Solution:
def wordPattern(self, pattern: str, s: str) -> bool:
words = s.split()
if len(words) != len(pattern):
return False
words_dic = {}
pattern_dic = {}
for i, v in enumerate(pattern):
if (v in words_dic) and words_dic[v] != words[i]:
... | class Solution:
def word_pattern(self, pattern: str, s: str) -> bool:
words = s.split()
if len(words) != len(pattern):
return False
words_dic = {}
pattern_dic = {}
for (i, v) in enumerate(pattern):
if v in words_dic and words_dic[v] != words[i]:
... |
TRUE = [
[[ 0.299, 0.587, 0.114 ],
[ 0, 0, 0 ],
[ 0, 0, 0 ]],
[[ 0, 0, 0 ],
[ 0, 0, 0 ],
[ 0.299, 0.587, 0.114 ]]
]
GRAY = [
[[ 0.299, 0.587, 0.114 ],
[ 0, 0, 0 ],
[ 0, 0, 0 ]],
[[ 0, 0, 0 ],
[ 0.299, 0.587, 0.114 ],
[ 0.299, 0.587, 0.1... | true = [[[0.299, 0.587, 0.114], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0.299, 0.587, 0.114]]]
gray = [[[0.299, 0.587, 0.114], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0.299, 0.587, 0.114], [0.299, 0.587, 0.114]]]
color = [[[1, 0, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 1, 0], [0, 0, 1]]]
half_color = [[[0.299, 0.... |
'''
PROBLEM STATEMENT:
Given a binary tree with its root node and two nodes, a and b, present in
the tree. The task is to find the lowest common ancestor of a and b.
The input is in preorder and -1 denotes a null value.
For example:
Input: 3 4 -1 6 -1 -1 5 1 -1 -1 -1
let a = 1, b = 6
The above input will have t... | """
PROBLEM STATEMENT:
Given a binary tree with its root node and two nodes, a and b, present in
the tree. The task is to find the lowest common ancestor of a and b.
The input is in preorder and -1 denotes a null value.
For example:
Input: 3 4 -1 6 -1 -1 5 1 -1 -1 -1
let a = 1, b = 6
The above input will have the follo... |
print("loading maths...")
def monotonically_increasing(num_list):
return all(x>=y for x, y in zip(num_list, num_list[1:]))
def monotonically_decreasing(num_list):
return all(x<=y for x, y in zip(num_list, num_list[1:]))
def slope(num_list):
return float(num_list[-1:] - num_list[0]) / len(num_list)
| print('loading maths...')
def monotonically_increasing(num_list):
return all((x >= y for (x, y) in zip(num_list, num_list[1:])))
def monotonically_decreasing(num_list):
return all((x <= y for (x, y) in zip(num_list, num_list[1:])))
def slope(num_list):
return float(num_list[-1:] - num_list[0]) / len(num_... |
a = int(input("Enter the first binary number: "))
b = int(input("Enter the second binary number: "))
e = '00000000000000000000000000000000'
A = str(bin(a))[2:]
B = str(bin(b))[2:]
print("A in binary: " + e[:-len(A)] + A)
print("B in binary: " + e[:-len(B)] + B)
c = a*b
print("Decimal multiplication will resul... | a = int(input('Enter the first binary number: '))
b = int(input('Enter the second binary number: '))
e = '00000000000000000000000000000000'
a = str(bin(a))[2:]
b = str(bin(b))[2:]
print('A in binary: ' + e[:-len(A)] + A)
print('B in binary: ' + e[:-len(B)] + B)
c = a * b
print('Decimal multiplication will result in: ' ... |
BOT_NAME = 'Recipeify-spider'
ROBOTSTXT_OBEY = True
DOWNLOAD_DELAY = 0.01
CONCURRENT_REQUESTS = 16
USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0'
LOG_FILE='Recipes/scraper/scrapy.log' | bot_name = 'Recipeify-spider'
robotstxt_obey = True
download_delay = 0.01
concurrent_requests = 16
user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0'
log_file = 'Recipes/scraper/scrapy.log' |
KEY_FORWARD = ord("t")
KEY_BACKWARD = ord("T")
KEY_BACK = ord("g")
KEY_DETAILS = ord("s")
KEY_TAB = 9
| key_forward = ord('t')
key_backward = ord('T')
key_back = ord('g')
key_details = ord('s')
key_tab = 9 |
s = {1, 2, 3, 4}
l = list(s)
l.sort()
print(l)
| s = {1, 2, 3, 4}
l = list(s)
l.sort()
print(l) |
class MapPointerConverter:
'''Handles converting virtual pointers to/from file pointers in maps.'''
class PageInfo:
def __init__(self, v_addr=0, f_addr=0, size=0):
self.v_addr = v_addr
self.f_addr = f_addr
self.size = size
self.v_addr_range = range(... | class Mappointerconverter:
"""Handles converting virtual pointers to/from file pointers in maps."""
class Pageinfo:
def __init__(self, v_addr=0, f_addr=0, size=0):
self.v_addr = v_addr
self.f_addr = f_addr
self.size = size
self.v_addr_range = range(self.... |
strings = open("input_5", "r").readlines()
def is_nice_1(s):
if not 3 <= sum(1 for c in s if c in "aeiou"):
return False
if not any(a == b for a, b in zip(s, s[1:])):
return False
if any(banned in s for banned in ["ab", "cd", "pq", "xy"]):
return False
return True
def is_nice... | strings = open('input_5', 'r').readlines()
def is_nice_1(s):
if not 3 <= sum((1 for c in s if c in 'aeiou')):
return False
if not any((a == b for (a, b) in zip(s, s[1:]))):
return False
if any((banned in s for banned in ['ab', 'cd', 'pq', 'xy'])):
return False
return True
def i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.