content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def poscode2word(pos):
tag_des = {
'CC': 'Coordinating conjunction',
'CD': 'Cardinal number',
'DT': 'Determiner',
'EX': 'Existential',
'FW': 'Foreign word',
'IN': 'Preposition',
'JJ': 'Adjective',
'JJR': 'Adjective, comparative',
'JJS': 'Adject... | def poscode2word(pos):
tag_des = {'CC': 'Coordinating conjunction', 'CD': 'Cardinal number', 'DT': 'Determiner', 'EX': 'Existential', 'FW': 'Foreign word', 'IN': 'Preposition', 'JJ': 'Adjective', 'JJR': 'Adjective, comparative', 'JJS': 'Adjective, superlative', 'LS': 'List item maker', 'MD': 'Modal', 'NN': 'Noun, s... |
def part1(arr):
s = 0
for v in arr:
s += v // 3 - 2
return s
def part2(arr):
s = 0
for v in arr:
fuel = v // 3 - 2
s += fuel
while fuel > 0:
fuel = fuel // 3 - 2
if fuel > 0:
s += fuel
return s
def day1():
arr = [
... | def part1(arr):
s = 0
for v in arr:
s += v // 3 - 2
return s
def part2(arr):
s = 0
for v in arr:
fuel = v // 3 - 2
s += fuel
while fuel > 0:
fuel = fuel // 3 - 2
if fuel > 0:
s += fuel
return s
def day1():
arr = [80891... |
BASE_JSON_PATH = '/home/mdd36/tools350/tools350/assembler/base_jsn'
BASE_JSON_LOCAL = '/Users/matthew/Documents/SchoolWork/TA/ECE350/2019s/350_tools_mk2/tools350/assembler/base_jsn'
class InstructionType:
def __init__(self, types: dict):
self._instruction_types: dict = types
def get_by_type(self, ty... | base_json_path = '/home/mdd36/tools350/tools350/assembler/base_jsn'
base_json_local = '/Users/matthew/Documents/SchoolWork/TA/ECE350/2019s/350_tools_mk2/tools350/assembler/base_jsn'
class Instructiontype:
def __init__(self, types: dict):
self._instruction_types: dict = types
def get_by_type(self, typ... |
class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def inorder(root):
if root is None:
return ""
res = ""
res += inorder(root.left)
res += "{} ".format(root.data)
res += inorder(root.right)
return res
def all_subtree... | class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def inorder(root):
if root is None:
return ''
res = ''
res += inorder(root.left)
res += '{} '.format(root.data)
res += inorder(root.right)
return res
def all_subtree(r... |
for i in range(int(input())):
sum = 0
y, x = map(int, input().split())
n = max(x,y)
sum += (n-1) * (n-1)
if n%2!=0:
sum += x + (n-y)
else:
sum += y + (n-x)
print(sum)
| for i in range(int(input())):
sum = 0
(y, x) = map(int, input().split())
n = max(x, y)
sum += (n - 1) * (n - 1)
if n % 2 != 0:
sum += x + (n - y)
else:
sum += y + (n - x)
print(sum) |
class GetCashgramStatus:
end_point = "/payout/v1/getCashgramStatus"
req_type = "GET"
def __init__(self, *args, **kwargs):
self.cashgramId = kwargs["cashgramId"] | class Getcashgramstatus:
end_point = '/payout/v1/getCashgramStatus'
req_type = 'GET'
def __init__(self, *args, **kwargs):
self.cashgramId = kwargs['cashgramId'] |
description = 'Small Beam Limiter in Experimental Chamber 1'
group = 'optional'
devices = dict(
nbl_l = device('nicos.devices.generic.VirtualReferenceMotor',
description = 'Beam Limiter Left Blade',
lowlevel = True,
abslimits = (-250, 260),
unit = 'mm',
speed = 10,
... | description = 'Small Beam Limiter in Experimental Chamber 1'
group = 'optional'
devices = dict(nbl_l=device('nicos.devices.generic.VirtualReferenceMotor', description='Beam Limiter Left Blade', lowlevel=True, abslimits=(-250, 260), unit='mm', speed=10, refswitch='high'), nbl_r=device('nicos.devices.generic.VirtualRefer... |
async def test_admin_auth(client, admin, user):
res = await client.get('/admin', follow_redirect=False)
assert res.status_code == 307
# Login as an simple user
res = await client.post('/login', data={'email': user.email, 'password': 'pass'})
assert res.status_code == 200
res = await client.get... | async def test_admin_auth(client, admin, user):
res = await client.get('/admin', follow_redirect=False)
assert res.status_code == 307
res = await client.post('/login', data={'email': user.email, 'password': 'pass'})
assert res.status_code == 200
res = await client.get('/admin', follow_redirect=False... |
# https://edabit.com/challenge/Yj2Rew5XQYpu7Nosq
# Create a function that returns the number of frames shown in a given number of minutes for a certain FPS.
def frames(minutes: int, fps: int) -> int:
try:
total_frames = (minutes * 60) * fps
return total_frames
except TypeError as err:
... | def frames(minutes: int, fps: int) -> int:
try:
total_frames = minutes * 60 * fps
return total_frames
except TypeError as err:
print(f'Error: {err}')
print(frames(1, 1))
print(frames(10, 1))
print(frames(10, 25))
print(frames('a', 'b')) |
list_one = [1, 2, 3]
list_two = [4, 5, 6,7]
lst = [0, *list_one, *list_two]
print(lst)
country_lst_one = ['Finland', 'Sweden', 'Norway']
country_lst_two = ['Denmark', 'Iceland']
nordic_countries = [*country_lst_one, *country_lst_two]
print(nordic_countries)
| list_one = [1, 2, 3]
list_two = [4, 5, 6, 7]
lst = [0, *list_one, *list_two]
print(lst)
country_lst_one = ['Finland', 'Sweden', 'Norway']
country_lst_two = ['Denmark', 'Iceland']
nordic_countries = [*country_lst_one, *country_lst_two]
print(nordic_countries) |
# https://www.codechef.com/problems/DEVARRAY
n,Q=map(int,input().split())
max1,min1,a=-99999999999,99999999999,list(map(int,input().split()))
for z in range(n): min1,max1 = min(min1,a[z]),max(max1,a[z])
for z in range(Q): print("Yes") if(int(input()) in range(min1,max1+1)) else print("No") | (n, q) = map(int, input().split())
(max1, min1, a) = (-99999999999, 99999999999, list(map(int, input().split())))
for z in range(n):
(min1, max1) = (min(min1, a[z]), max(max1, a[z]))
for z in range(Q):
print('Yes') if int(input()) in range(min1, max1 + 1) else print('No') |
_base_ = [
'../_base_/default_runtime.py', '../_base_/datasets/coco_detection.py'
]
# model settings
model = dict(
type='CenterNet',
pretrained='torchvision://resnet18',
backbone=dict(
type='ResNet',
depth=18,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages... | _base_ = ['../_base_/default_runtime.py', '../_base_/datasets/coco_detection.py']
model = dict(type='CenterNet', pretrained='torchvision://resnet18', backbone=dict(type='ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=False, zero_init_... |
# Copyright (c) 2012 OpenStack, LLC.
#
# 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 wr... | extended_attributes_2_0 = {'networks': {'v2attrs:something': {'allow_post': False, 'allow_put': False, 'is_visible': True}, 'v2attrs:something_else': {'allow_post': True, 'allow_put': False, 'is_visible': False}}}
class V2Attributes(object):
def get_name(self):
return 'V2 Extended Attributes Example'
... |
# Python Program to subtract two numbers
# Store input numbers
num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
# Sub two numbers
sub = float(num1) - float(num2)
# Display the sub
print("The sub of {0} and {1} is {2}".format(num1, num2, sub))
| num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
sub = float(num1) - float(num2)
print('The sub of {0} and {1} is {2}'.format(num1, num2, sub)) |
BACKTEST_FLOW_OK = {
"nodeList": {
"1": {
"blockType": "DATA_BLOCK",
"blockId": 1,
"equity_name": {"options": ["AAPL"], "value": ""},
"data_type": {"options": ["intraday", "daily_adjusted"], "value": ""},
"interval": {"options": ["1min"], "value": ... | backtest_flow_ok = {'nodeList': {'1': {'blockType': 'DATA_BLOCK', 'blockId': 1, 'equity_name': {'options': ['AAPL'], 'value': ''}, 'data_type': {'options': ['intraday', 'daily_adjusted'], 'value': ''}, 'interval': {'options': ['1min'], 'value': ''}, 'outputsize': {'options': ['compact', 'full'], 'value': ''}, 'start_da... |
numbers = [14, 2,3,4,5,6,7,6,5,7,8,8,9,10,11,12,13,14,14]
numbers2 =[]
for number in numbers:
if number not in numbers2:
numbers2.append(number)
print(numbers2) | numbers = [14, 2, 3, 4, 5, 6, 7, 6, 5, 7, 8, 8, 9, 10, 11, 12, 13, 14, 14]
numbers2 = []
for number in numbers:
if number not in numbers2:
numbers2.append(number)
print(numbers2) |
class MyClass:
print('MyClass created')
# instansiate a class
my_var = MyClass()
print(type(my_var))
print(dir(my_var)) | class Myclass:
print('MyClass created')
my_var = my_class()
print(type(my_var))
print(dir(my_var)) |
class BTNode:
__slots__ = "value", "left", "right"
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def test_BTNode():
parent = BTNode(10)
left = BTNode(20)
right = BTNode(30)
parent.left = left
parent.right =... | class Btnode:
__slots__ = ('value', 'left', 'right')
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def test_bt_node():
parent = bt_node(10)
left = bt_node(20)
right = bt_node(30)
parent.left = left
parent.ri... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
DEBUG = True
USE_TZ = True
SECRET_KEY = "KEY"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
}
ROOT_URLCONF = "tests.urls"
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.messages",
"d... | debug = True
use_tz = True
secret_key = 'KEY'
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}
root_urlconf = 'tests.urls'
installed_apps = ['django.contrib.admin', 'django.contrib.messages', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.co... |
class Solution:
# @param prices, a list of integer
# @return an integer
def maxProfit(self, prices):
n = len(prices)
if n < 2:
return 0
min_price = prices[0]
res = 0
for i in xrange(1, n):
res = max(res, prices[i]-min_price)
min_pr... | class Solution:
def max_profit(self, prices):
n = len(prices)
if n < 2:
return 0
min_price = prices[0]
res = 0
for i in xrange(1, n):
res = max(res, prices[i] - min_price)
min_price = min(min_price, prices[i])
return res |
# Python 3: Simple output (with Unicode)
print("Hello, I'm Python!")
# Input, assignment
name = input('What is your name?\n')
print('Hi, %s.' % name)
| print("Hello, I'm Python!")
name = input('What is your name?\n')
print('Hi, %s.' % name) |
# Time complexity: O(n) where n is number of nodes in Tree
# Approach: Checking binary search tree conditions on each node recursively.
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right... | class Solution:
def is_valid_bst(self, root: Optional[TreeNode], l=-2 ** 31 - 1, r=2 ** 31) -> bool:
if not root:
return True
elif l < root.val and root.val < r:
return self.isValidBST(root.left, l, root.val) and self.isValidBST(root.right, root.val, r)
return False |
class Node():
def __init__(self):
self.children = {}
self.endofword = False
self.string = ""
class Trie():
def __init__(self):
self.root = Node()
def insert(self, word):
pointer = self.root
for char in word:
if char not in pointer.children:
... | class Node:
def __init__(self):
self.children = {}
self.endofword = False
self.string = ''
class Trie:
def __init__(self):
self.root = node()
def insert(self, word):
pointer = self.root
for char in word:
if char not in pointer.children:
... |
#-----------------------------------------------------------------------
# helper modules for argparse:
# - check if values are in a certain range, are positive, etc.
# - https://github.com/Sorbus/artichoke
#-----------------------------------------------------------------------
def check_range(value):
ivalue = in... | def check_range(value):
ivalue = int(value)
if ivalue < 1 or ivalue > 3200:
raise argparse.ArgumentTypeError('%s is not a valid positive int value' % value)
return ivalue
def check_positive(value):
ivalue = int(value)
if ivalue < 0:
raise argparse.ArgumentTypeError('%s is not a vali... |
#logaritmica
#No. de digitos de un numero
def digitos(i):
cont=0
if i == 0:
return '0'
while i > 0:
cont=cont+1
i = i//10
return cont
numeros=list(range(1,1000))
print(numeros)
ite=[]
for a in numeros:
ite.append(digitos(a))
print(digitos(a))
| def digitos(i):
cont = 0
if i == 0:
return '0'
while i > 0:
cont = cont + 1
i = i // 10
return cont
numeros = list(range(1, 1000))
print(numeros)
ite = []
for a in numeros:
ite.append(digitos(a))
print(digitos(a)) |
class FakeSerial:
def __init__( self, port=None, baudrate = 19200, timeout=1,
bytesize = 8, parity = 'N', stopbits = 1, xonxoff=0,
rtscts = 0):
print("Port is ", port)
self.halfduplex = True
self.name = port
self.port = port
self.ti... | class Fakeserial:
def __init__(self, port=None, baudrate=19200, timeout=1, bytesize=8, parity='N', stopbits=1, xonxoff=0, rtscts=0):
print('Port is ', port)
self.halfduplex = True
self.name = port
self.port = port
self.timeout = timeout
self.parity = parity
s... |
class CustomException(Exception):
def __init__(self, *args):
if args:
self.message = args[0]
else:
self.message = None
def get_str(self, class_name):
if self.message:
return '{0}, {1} '.format(self.message, class_name)
else:
return... | class Customexception(Exception):
def __init__(self, *args):
if args:
self.message = args[0]
else:
self.message = None
def get_str(self, class_name):
if self.message:
return '{0}, {1} '.format(self.message, class_name)
else:
retur... |
# Copyright 2014 Cloudera Inc.
#
# 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, so... | base_identifiers = ['add', 'aggregate', 'all', 'alter', 'and', 'api_version', 'as', 'asc', 'avro', 'between', 'bigint', 'binary', 'boolean', 'by', 'cached', 'case', 'cast', 'change', 'char', 'class', 'close_fn', 'column', 'columns', 'comment', 'compute', 'create', 'cross', 'data', 'database', 'databases', 'date', 'date... |
H = {0: [0], 1: [1, 2, 4, 8], 2: [3, 5, 6, 9, 10], 3: [7, 11]}
M = {0: [0], 1: [1, 2, 4, 8, 16, 32], 2: [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48],
3: [7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56],
4: [15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58], 5: ... | h = {0: [0], 1: [1, 2, 4, 8], 2: [3, 5, 6, 9, 10], 3: [7, 11]}
m = {0: [0], 1: [1, 2, 4, 8, 16, 32], 2: [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48], 3: [7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56], 4: [15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58], 5: [31, 47, 5... |
yusuke_power = {"Yusuke Urameshi": "Spirit Gun"}
hiei_power = {"Hiei": "Jagan Eye"}
powers = dict()
# Iteration
for dictionary in (yusuke_power, hiei_power):
for key, value in dictionary.items():
powers[key] = value
# Dictionary Comprehension
powers = {key: value for d in (yusuke_power, hiei_power) for key, v... | yusuke_power = {'Yusuke Urameshi': 'Spirit Gun'}
hiei_power = {'Hiei': 'Jagan Eye'}
powers = dict()
for dictionary in (yusuke_power, hiei_power):
for (key, value) in dictionary.items():
powers[key] = value
powers = {key: value for d in (yusuke_power, hiei_power) for (key, value) in d.items()}
powers = yusuk... |
SIMPLE_QUEUE = 'simple'
WORK_QUEUE = 'work_queue'
RABBITMQ_HOST = '0.0.0.0'
LOG_EXCHANGE = 'logs'
ROUTING_EXCHANGE = 'direct_exchange'
TOPIC_EXCHANGE = 'topic_exchange'
SEVERITIES = ['err', 'info', 'debug']
FACILITIES = ['kern', 'mail', 'user', 'local0']
| simple_queue = 'simple'
work_queue = 'work_queue'
rabbitmq_host = '0.0.0.0'
log_exchange = 'logs'
routing_exchange = 'direct_exchange'
topic_exchange = 'topic_exchange'
severities = ['err', 'info', 'debug']
facilities = ['kern', 'mail', 'user', 'local0'] |
# triple nested exceptions
passed = 1
def f():
try:
foo()
passed = 0
except:
print("except 1")
try:
bar()
passed = 0
except:
print("except 2")
try:
baz()
passed = 0
except:
... | passed = 1
def f():
try:
foo()
passed = 0
except:
print('except 1')
try:
bar()
passed = 0
except:
print('except 2')
try:
baz()
passed = 0
except:
print('except 3')... |
uctable = [ [ 194, 178 ],
[ 194, 179 ],
[ 194, 185 ],
[ 194, 188 ],
[ 194, 189 ],
[ 194, 190 ],
[ 224, 167, 180 ],
[ 224, 167, 181 ],
[ 224, 167, 182 ],
[ 224, 167, 183 ],
[ 224, 167, 184 ],
[ 224, 167, 185 ],
[ 224, 173, 178 ],
[ 224, 173, 179 ],
[ 224, 173, 180 ],
[ 224, 173, 181 ],
[ ... | uctable = [[194, 178], [194, 179], [194, 185], [194, 188], [194, 189], [194, 190], [224, 167, 180], [224, 167, 181], [224, 167, 182], [224, 167, 183], [224, 167, 184], [224, 167, 185], [224, 173, 178], [224, 173, 179], [224, 173, 180], [224, 173, 181], [224, 173, 182], [224, 173, 183], [224, 175, 176], [224, 175, 177],... |
#A
def greeting(x :str) -> str:
return "hello, "+ x
def main():
# input
s = input()
# compute
# output
print(greeting(s))
if __name__ == '__main__':
main()
| def greeting(x: str) -> str:
return 'hello, ' + x
def main():
s = input()
print(greeting(s))
if __name__ == '__main__':
main() |
def test_delete_first__group(app):
app.session.open_home_page()
app.session.login("admin", "secret")
app.group.delete_first_group()
app.session.logout()
| def test_delete_first__group(app):
app.session.open_home_page()
app.session.login('admin', 'secret')
app.group.delete_first_group()
app.session.logout() |
#####count freq of words in text file
word_count= dict()
with open(r'C:/Users/Jen/Downloads/resumes/PracticeCodeM/cantrbry/plrabn12.txt', 'r') as fi:
for line in fi:
words = line.split()
prepared_words = [w.lower() for w in words]
for w in prepared_words:
word_count[w] =... | word_count = dict()
with open('C:/Users/Jen/Downloads/resumes/PracticeCodeM/cantrbry/plrabn12.txt', 'r') as fi:
for line in fi:
words = line.split()
prepared_words = [w.lower() for w in words]
for w in prepared_words:
word_count[w] = 1 if w not in word_count else word_count[w] + ... |
# Copyright 2018 Oinam Romesh Meitei. All Rights Reserved.
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under th... | class Molog:
filname = ''
def __init__(self):
apple = 0
def set_name(self, string):
molog.filname = string
def initiate(self):
out = open(molog.filname, 'w')
out.write(' ******************\n')
out.write(' ***** MOLEPY *****\n')
... |
Dev = {
"db_server": "Dbsed4555",
"user": "<db_username>",
"passwd": "<password>",
"driver": "SQL Server",
"port": "1433"
}
Oracle = {
"db_server": "es20-scan01",
"port": "1521",
"user": "<db_username>",
"passwd": "<password>",
"service_name": "cmc1st01svc.uhc.com"
}
Sybase = {
... | dev = {'db_server': 'Dbsed4555', 'user': '<db_username>', 'passwd': '<password>', 'driver': 'SQL Server', 'port': '1433'}
oracle = {'db_server': 'es20-scan01', 'port': '1521', 'user': '<db_username>', 'passwd': '<password>', 'service_name': 'cmc1st01svc.uhc.com'}
sybase = {'db_server': 'DBSPS0181', 'user': '<db_usernam... |
message_id = {
b"\x00\x00": "init",
b"\x00\x01": "ping",
b"\x00\x02": "pong",
b"\x00\x03": "give nodes",
b"\x00\x04": "take nodes",
b"\x00\x05": "give next headers",
b"\x00\x06": "take the headers",
b"\x00\x07": "give blocks",
b"\x00\x08": "take the blocks",
b"\x00\x09": "give the txos",
b"\x00\x0a": "take the txos",
b... | message_id = {b'\x00\x00': 'init', b'\x00\x01': 'ping', b'\x00\x02': 'pong', b'\x00\x03': 'give nodes', b'\x00\x04': 'take nodes', b'\x00\x05': 'give next headers', b'\x00\x06': 'take the headers', b'\x00\x07': 'give blocks', b'\x00\x08': 'take the blocks', b'\x00\t': 'give the txos', b'\x00\n': 'take the txos', b'\x00... |
def accuracy(y_test, y):
cont = 0
for i in range(len(y)):
if y[i] == y_test[i]:
cont += 1
return cont / float(len(y))
def f_measure(y_test, y, beta=1):
tp = 0.0 # true pos
fp = 0.0 # false pos
tn = 0.0 # true neg
fn = 0.0 # false neg
for i in range(len(y)):
if y_test[i] == 1.0 and y[i] =... | def accuracy(y_test, y):
cont = 0
for i in range(len(y)):
if y[i] == y_test[i]:
cont += 1
return cont / float(len(y))
def f_measure(y_test, y, beta=1):
tp = 0.0
fp = 0.0
tn = 0.0
fn = 0.0
for i in range(len(y)):
if y_test[i] == 1.0 and y[i] == 1.0:
... |
name0_1_1_0_1_0_0 = None
name0_1_1_0_1_0_1 = None
name0_1_1_0_1_0_2 = None
name0_1_1_0_1_0_3 = None
name0_1_1_0_1_0_4 = None | name0_1_1_0_1_0_0 = None
name0_1_1_0_1_0_1 = None
name0_1_1_0_1_0_2 = None
name0_1_1_0_1_0_3 = None
name0_1_1_0_1_0_4 = None |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
# both does not exist
if not root.l... | class Solution:
def is_symmetric(self, root: Optional[TreeNode]) -> bool:
if not root.left and (not root.right):
return True
elif not root.left or not root.right:
return False
stack1 = [root.left]
output1 = [root.left.val]
stack2 = [root.right]
... |
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_dependencies():
go_repository(
name = "com_github_aws_aws_sdk_go",
importpath = "github.com/aws/aws-sdk-go",
sum = "h1:3+AsCrxxnhiUQEhWV+j3kEs7aBCIn2qkDjA+elpxYPU=",
version = "v1.33.13",
)
go_repository(
name... | load('@bazel_gazelle//:deps.bzl', 'go_repository')
def go_dependencies():
go_repository(name='com_github_aws_aws_sdk_go', importpath='github.com/aws/aws-sdk-go', sum='h1:3+AsCrxxnhiUQEhWV+j3kEs7aBCIn2qkDjA+elpxYPU=', version='v1.33.13')
go_repository(name='com_github_bazelbuild_remote_apis', importpath='github... |
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def source():
pass
def sinkA(x):
pass
def sinkB(x):
pass
def sinkC(x):
pass
def sinkD(x):
pass
def split(x):
... | def source():
pass
def sink_a(x):
pass
def sink_b(x):
pass
def sink_c(x):
pass
def sink_d(x):
pass
def split(x):
y = x._params
sink_b(y)
sink_c(y)
sink_d(y)
return x
def wrapper(x):
y = split(x)
sink_a(y)
def issue():
x = source()
wrapper(x)
def splitwrapp... |
#output comments variables input calculations output constants
def display_output():
print('hello')
def test_config():
return True
| def display_output():
print('hello')
def test_config():
return True |
n = int(input())
f = {}
while n > 1:
i = 2
while True:
if n % i == 0:
if i not in f:
f[i] = 0
f[i] += 1
n = n // i
break
i = i + 1
s = ""
for k, v in f.items():
s += "{}".format(k)
if v != 1:
s += "^{}".format(v)
... | n = int(input())
f = {}
while n > 1:
i = 2
while True:
if n % i == 0:
if i not in f:
f[i] = 0
f[i] += 1
n = n // i
break
i = i + 1
s = ''
for (k, v) in f.items():
s += '{}'.format(k)
if v != 1:
s += '^{}'.format(v)
... |
def divisors(x):
divisorList = []
for i in range(1, x+1):
if x%i == 0:
divisorList.append(i)
return divisorList
def main():
while True:
try:
x = int(input("Type a number please:"))
break
except ValueError:
pass
y = divisors(x)... | def divisors(x):
divisor_list = []
for i in range(1, x + 1):
if x % i == 0:
divisorList.append(i)
return divisorList
def main():
while True:
try:
x = int(input('Type a number please:'))
break
except ValueError:
pass
y = divisor... |
# Exercise 8.2
# You can call a method directly on the string, as well as on a variable
# of type string. So here I call count directly on 'banana', with the
# argument 'a' as the letter/substring to count.
print('banana'.count('a'))
# Exercise 8.3
def is_palindrome(s):
# The slice uses the entire string if the ... | print('banana'.count('a'))
def is_palindrome(s):
return s == s[::-1]
def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False
def any_lowercase2(s):
for c in s:
if 'c'.islower():
return 'True'
else:
r... |
'''
Created on 30 de nov de 2018
@author: filiped
'''
class Base:
def __init__(self):
self.s=""
self.p=0
self.fim="@"
self.pilha = ["z0"]
def le_palavra(self,palavra="@"):
self.p=0
self.s = palavra+"@"
def xp(self,c=""):
print(s... | """
Created on 30 de nov de 2018
@author: filiped
"""
class Base:
def __init__(self):
self.s = ''
self.p = 0
self.fim = '@'
self.pilha = ['z0']
def le_palavra(self, palavra='@'):
self.p = 0
self.s = palavra + '@'
def xp(self, c=''):
print(self.s[s... |
class ConsumptionTax:
def __init__(self, tax_rate):
self.tax_rate = tax_rate
def apply(self, price):
return int((price * self.tax_rate) / 100) + price | class Consumptiontax:
def __init__(self, tax_rate):
self.tax_rate = tax_rate
def apply(self, price):
return int(price * self.tax_rate / 100) + price |
# Nach einer Idee von Kevin Workman
# (https://happycoding.io/examples/p5js/images/image-palette)
WIDTH = 800
HEIGHT = 640
palette = ["#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"]
def setup():
global img
size(WIDTH, HEIGHT)
this.surface.setTitle("Image Palette")
img = loadImage("akt.jpg")
... | width = 800
height = 640
palette = ['#264653', '#2a9d8f', '#e9c46a', '#f4a261', '#e76f51']
def setup():
global img
size(WIDTH, HEIGHT)
this.surface.setTitle('Image Palette')
img = load_image('akt.jpg')
image(img, 0, 0)
no_loop()
def draw():
global y, img
for x in range(width / 2):
... |
def front_and_back_search(lst, item):
rear=0
front=len(lst)-1
u=None
if rear>front:
return False
else:
while rear<=front:
if item==lst[rear] or item==lst[front]:
u=''
return True
elif item!=lst[rear] and item!=lst[front]:
... | def front_and_back_search(lst, item):
rear = 0
front = len(lst) - 1
u = None
if rear > front:
return False
else:
while rear <= front:
if item == lst[rear] or item == lst[front]:
u = ''
return True
elif item != lst[rear] and item... |
# Darren Keenan 2018-02-27
# Exercise 4 - Project Euler 5
# What is the smallest number divisible by 1 to 20
def divisibleby1to20(n):
for i in range(1, 21):
if n % i != 0:
return False
return True
n = 1
while True:
if divisibleby1to20(n):
break
n += 1
print(n)
# The smallest ... | def divisibleby1to20(n):
for i in range(1, 21):
if n % i != 0:
return False
return True
n = 1
while True:
if divisibleby1to20(n):
break
n += 1
print(n) |
# Three number sum
def threeSumProblem(arr: list, target: int) :
arr.sort()
result = list()
for i in range(0, len(arr) - 2) :
left = i+1;right=len(arr)-1
while left < right :
curren_sum = arr[i] + arr[left] + arr[right]
if curren_sum == target :
... | def three_sum_problem(arr: list, target: int):
arr.sort()
result = list()
for i in range(0, len(arr) - 2):
left = i + 1
right = len(arr) - 1
while left < right:
curren_sum = arr[i] + arr[left] + arr[right]
if curren_sum == target:
result.append... |
class animal:
def eat(self):
print("eat")
class mammal(animal):
def walk(self):
print("walk")
class fish(animal):
def swim(self):
print("swim")
moka = mammal()
moka.eat()
moka.walk()
| class Animal:
def eat(self):
print('eat')
class Mammal(animal):
def walk(self):
print('walk')
class Fish(animal):
def swim(self):
print('swim')
moka = mammal()
moka.eat()
moka.walk() |
g1 = 1
def display():
global g1
g1 = 2
print(g1)
print("inside",id(g1))
display()
print(g1)
print("outside",id(g1))
| g1 = 1
def display():
global g1
g1 = 2
print(g1)
print('inside', id(g1))
display()
print(g1)
print('outside', id(g1)) |
showroom = set()
showroom.add('Chevrolet SS')
showroom.add('Mazda Miata')
showroom.add('GMC Yukon XL Denali')
showroom.add('Porsche Cayman')
# print(showroom)
# print (len(showroom))
showroom.update(['Jaguar F-Type', 'Ariel Atom 3'])
# print (showroom)
showroom.remove('GMC Yukon XL Denali')
# print (showroom)
junky... | showroom = set()
showroom.add('Chevrolet SS')
showroom.add('Mazda Miata')
showroom.add('GMC Yukon XL Denali')
showroom.add('Porsche Cayman')
showroom.update(['Jaguar F-Type', 'Ariel Atom 3'])
showroom.remove('GMC Yukon XL Denali')
junkyard = set()
junkyard.update(['Mazda Miata', 'Chevy Caprice', 'Isuzu Trooper', 'Satur... |
TARGET_COL = 'class'
ID_COL = 'id'
N_FOLD = 5
N_CLASS = 3
SEED = 42
| target_col = 'class'
id_col = 'id'
n_fold = 5
n_class = 3
seed = 42 |
#
# PySNMP MIB module ROHC-UNCOMPRESSED-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ROHC-UNCOMPRESSED-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:49:54 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, constraints_intersection, value_range_constraint, value_size_constraint) ... |
# 11.
print(list(range(1, 10)))
# 12.
print(list(range(100, 20, -5)))
| print(list(range(1, 10)))
print(list(range(100, 20, -5))) |
def A(m, n):
if m == 0:
return n + 1
if m > 0 and n == 0:
return A(m - 1, 1)
if m > 0 and n > 0:
return A(m - 1, A(m, n - 1))
def main() -> None:
print(A(2, 2))
if __name__ == "__main__":
main() | def a(m, n):
if m == 0:
return n + 1
if m > 0 and n == 0:
return a(m - 1, 1)
if m > 0 and n > 0:
return a(m - 1, a(m, n - 1))
def main() -> None:
print(a(2, 2))
if __name__ == '__main__':
main() |
# input -1
n = int(input('input nilai: '))
if n <= 0:
# Menentukan pengecualian & teks yang akan di tampilkan
raise ValueError('nilai n harus bilangan positif')
try:
n = int(input('input nilai: '))
if n <= 0:
# Menentukan pengecualian & teks yang akan di tampilkan
raise ValueError('nil... | n = int(input('input nilai: '))
if n <= 0:
raise value_error('nilai n harus bilangan positif')
try:
n = int(input('input nilai: '))
if n <= 0:
raise value_error('nilai n harus bilangan positif')
except ValueError as ve:
print(ve) |
#
# PySNMP MIB module CYCLONE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CYCLONE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:34:24 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_intersection, constraints_union, value_range_constraint) ... |
def tapcode_to_fingers(tapcode:int):
return '{0:05b}'.format(1)[::-1]
def mouse_data_msg(data: bytearray):
vx = int.from_bytes(data[1:3],"little", signed=True)
vy = int.from_bytes(data[3:5],"little", signed=True)
prox = data[9] == 1
return vx, vy, prox
def air_gesture_data_msg(data: bytearray):
return [data[0]]... | def tapcode_to_fingers(tapcode: int):
return '{0:05b}'.format(1)[::-1]
def mouse_data_msg(data: bytearray):
vx = int.from_bytes(data[1:3], 'little', signed=True)
vy = int.from_bytes(data[3:5], 'little', signed=True)
prox = data[9] == 1
return (vx, vy, prox)
def air_gesture_data_msg(data: bytearray... |
class DBConnector:
def save_graph(self, local_graph):
pass
def get_reader_endpoint(self):
pass
def get_writer_endpoint(self):
pass
def disconnect(self):
pass
| class Dbconnector:
def save_graph(self, local_graph):
pass
def get_reader_endpoint(self):
pass
def get_writer_endpoint(self):
pass
def disconnect(self):
pass |
#! python
# Problem # : 50A
# Created on : 2019-01-14 21:29:26
def Main():
m, n = map(int, input().split(' '))
val = m * n
cnt = int(val / 2)
print(cnt)
if __name__ == '__main__':
Main()
| def main():
(m, n) = map(int, input().split(' '))
val = m * n
cnt = int(val / 2)
print(cnt)
if __name__ == '__main__':
main() |
def organize_data(lines):
max_x = 0
max_y = 0
line_segments = []
# store all of the line segments
for line in lines:
points = line.split(" -> ")
point1 = points[0].split(",")
point2 = points[1].split(",")
x1 = int(point1[0].strip())
y1 = int(point1[1].strip()... | def organize_data(lines):
max_x = 0
max_y = 0
line_segments = []
for line in lines:
points = line.split(' -> ')
point1 = points[0].split(',')
point2 = points[1].split(',')
x1 = int(point1[0].strip())
y1 = int(point1[1].strip())
x2 = int(point2[0].strip())
... |
class Config:
def __init__(self, name:str=None, username:str=None, pin:int=2, email:str=None, password:str=None, set_password:bool=False, set_email_notify:bool=False):
self.name = name
self.username = username
self.pin = pin
self.email = email
self.password = password
... | class Config:
def __init__(self, name: str=None, username: str=None, pin: int=2, email: str=None, password: str=None, set_password: bool=False, set_email_notify: bool=False):
self.name = name
self.username = username
self.pin = pin
self.email = email
self.password = password... |
# https://leetcode.com/problems/longest-increasing-subsequence/
class Solution:
def lengthOfLIS(self, nums: list[int]) -> int:
# Patience sorting-like approach, but keeping track
# only of the topmost element at each stack.
stack_tops = [nums[0]]
for num in nums[1:]:
for... | class Solution:
def length_of_lis(self, nums: list[int]) -> int:
stack_tops = [nums[0]]
for num in nums[1:]:
for idx in range(len(stack_tops)):
if stack_tops[idx] >= num:
stack_tops[idx] = num
break
else:
... |
{
"targets": [{
"target_name": "binding",
"sources": ["binding.cc"],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"/opt/vc/include",
"/opt/vc/include/interface/vcos/pthreads",
"/opt/vc/include/interface/vmcs_host/linux"
],
... | {'targets': [{'target_name': 'binding', 'sources': ['binding.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")', '/opt/vc/include', '/opt/vc/include/interface/vcos/pthreads', '/opt/vc/include/interface/vmcs_host/linux'], 'libraries': ['-lbcm_host', '-L/opt/vc/lib']}]} |
RES_SPA_MASSAGE_PARLOR = [
"spa",
"table",
"shower",
"nuru",
"slide",
"therapy",
"therapist",
"bodyrub",
"sauna",
"gel",
"shiatsu",
"jacuzzi"
]
| res_spa_massage_parlor = ['spa', 'table', 'shower', 'nuru', 'slide', 'therapy', 'therapist', 'bodyrub', 'sauna', 'gel', 'shiatsu', 'jacuzzi'] |
'''function in python
'''
print('=== function in python ===')
def func_args(*args):
print('* function *args')
for x in args:
print(x)
def func_kwargs(**kwargs):
print('* function **kwargs')
print('kwargs[name]', kwargs['name'])
func_args('hainv', '23')
func_kwargs(name="Tobias", lname="Re... | """function in python
"""
print('=== function in python ===')
def func_args(*args):
print('* function *args')
for x in args:
print(x)
def func_kwargs(**kwargs):
print('* function **kwargs')
print('kwargs[name]', kwargs['name'])
func_args('hainv', '23')
func_kwargs(name='Tobias', lname='Refsnes... |
# config.py
class Config(object):
num_channels = 256
linear_size = 256
output_size = 4
max_epochs = 10
lr = 0.001
batch_size = 128
seq_len = 300 # 1014 in original paper
dropout_keep = 0.5 | class Config(object):
num_channels = 256
linear_size = 256
output_size = 4
max_epochs = 10
lr = 0.001
batch_size = 128
seq_len = 300
dropout_keep = 0.5 |
arr = input()
for i in range(0, len(arr), 7):
bits = arr[i:i + 7]
result = 0
n = 1
for b in bits[::-1]:
result += n * int(b)
n *= 2
print(result)
| arr = input()
for i in range(0, len(arr), 7):
bits = arr[i:i + 7]
result = 0
n = 1
for b in bits[::-1]:
result += n * int(b)
n *= 2
print(result) |
def test():
# Here we can either check objects created in the solution code, or the
# string value of the solution, available as __solution__. A helper for
# printing formatted messages is available as __msg__. See the testTemplate
# in the meta.json for details.
# If an assertion fails, the messag... | def test():
assert 'X' in __solution__, "Make sure you are using 'X' as a variable"
assert 'y' in __solution__, "Make sure you are using 'y' as a variable"
assert X.shape == (25, 8), 'The dimensions of X is incorrect. Are you selcting the correct columns?'
assert y.shape == (25,), 'The dimensions of y i... |
n = int(input('Enter number of lines:'))
for i in range(1, n +1):
for j in range(1, n+1):
if i == 1 or j == 1 or i == n or j == n:
print("*", end = ' ')
else:
print(' ', end = ' ')
print()
| n = int(input('Enter number of lines:'))
for i in range(1, n + 1):
for j in range(1, n + 1):
if i == 1 or j == 1 or i == n or (j == n):
print('*', end=' ')
else:
print(' ', end=' ')
print() |
#import sys
#file = sys.stdin
file = open( r".\data\listcomprehensions.txt" )
data = file.read().strip().split()
#x,y,z,n = input(), input(), input(), input()
x,y,z = map(eval, map(''.join, (zip(data[:3], ['+1']*3))))
n = int(data[3])
print(x,y,z,n)
coords = [[a,b,c] for a in range(x) for b in range(y) for c in range... | file = open('.\\data\\listcomprehensions.txt')
data = file.read().strip().split()
(x, y, z) = map(eval, map(''.join, zip(data[:3], ['+1'] * 3)))
n = int(data[3])
print(x, y, z, n)
coords = [[a, b, c] for a in range(x) for b in range(y) for c in range(z) if a + b + c != n]
print(coords) |
routes_in=(('/forca/(?P<a>.*)','/\g<a>'),)
default_application = 'ForCA' # ordinarily set in base routes.py
default_controller = 'default' # ordinarily set in app-specific routes.py
default_function = 'index' # ordinarily set in app-specific routes.py
routes_out=(('/(?P<a>.*)','/forca/\g<a>'),)
| routes_in = (('/forca/(?P<a>.*)', '/\\g<a>'),)
default_application = 'ForCA'
default_controller = 'default'
default_function = 'index'
routes_out = (('/(?P<a>.*)', '/forca/\\g<a>'),) |
N = int(input())
X = 0
W = 0
Y = 0
Z = 0
for i in range(N):
W = Z + 1
X = W + 1
Y = X + 1
Z = Y + 1
print('{} {} {} PUM'.format(W, X, Y))
| n = int(input())
x = 0
w = 0
y = 0
z = 0
for i in range(N):
w = Z + 1
x = W + 1
y = X + 1
z = Y + 1
print('{} {} {} PUM'.format(W, X, Y)) |
# pylint: disable=missing-function-docstring, missing-module-docstring/
# coding: utf-8
#$ header class Parallel(public, with, openmp)
#$ header method __init__(Parallel, str, str, str [:], str [:], str [:], str [:], str, str [:], str)
#$ header method __del__(Parallel)
#$ header method __enter__(Parallel)
#$ header m... | class Parallel(object):
def __init__(self, num_threads, if_test, private, firstprivate, shared, reduction, default, copyin, proc_bind):
self._num_threads = num_threads
self._if_test = if_test
self._private = private
self._firstprivate = firstprivate
self._shared = shared
... |
class MyMetaClass(type):
def __new__(cls, name, bases, ns):
ns['kw_created_by_metaclass'] = lambda self, arg: arg.upper()
return type.__new__(cls, name, bases, ns)
def method_in_metaclass(cls):
pass
class MetaClassLibrary(metaclass=MyMetaClass):
def greet(self, name):
re... | class Mymetaclass(type):
def __new__(cls, name, bases, ns):
ns['kw_created_by_metaclass'] = lambda self, arg: arg.upper()
return type.__new__(cls, name, bases, ns)
def method_in_metaclass(cls):
pass
class Metaclasslibrary(metaclass=MyMetaClass):
def greet(self, name):
ret... |
lower_camel_case = input()
snake_case = ""
for char in lower_camel_case:
if char.isupper():
snake_case += "_" + char.lower()
else:
snake_case += char
print(snake_case)
| lower_camel_case = input()
snake_case = ''
for char in lower_camel_case:
if char.isupper():
snake_case += '_' + char.lower()
else:
snake_case += char
print(snake_case) |
#wap to find the numbers which are divisible by 3
a=int(input('Enter starting range '))
b=int(input('Enter ending range '))
number=int(input('Enter the number whose multiples you want to find in the range '))
print('Numbers which are divisible')
for i in range(a,b+1):
if i%number==0:
print(i,end=' ') | a = int(input('Enter starting range '))
b = int(input('Enter ending range '))
number = int(input('Enter the number whose multiples you want to find in the range '))
print('Numbers which are divisible')
for i in range(a, b + 1):
if i % number == 0:
print(i, end=' ') |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
''' 92.22% // 75.79% '''
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
slow = fast = head
{(fast := fast.next) for _... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
""" 92.22% // 75.79% """
def remove_nth_from_end(self, head: ListNode, n: int) -> ListNode:
slow = fast = head
{(fast := fast.next) for _ in range(n)}
if fast is N... |
q = int(input())
for _ in range(q):
n, m = map(int, input().split())
d = n // m
a = [0] * 10
for i in range(10):
a[i] = (m + a[i - 1]) % 10
s = sum(a)
print((d // 10) * s + sum(a[: (d % 10)]))
| q = int(input())
for _ in range(q):
(n, m) = map(int, input().split())
d = n // m
a = [0] * 10
for i in range(10):
a[i] = (m + a[i - 1]) % 10
s = sum(a)
print(d // 10 * s + sum(a[:d % 10])) |
__author__ = 'shukkkur'
'''
https://codeforces.com/problemset/problem/110/A
'''
i = input()
n = i.count('4') + i.count('7')
s = str(n)
s = s.replace('4', '')
s = s.replace('7', '')
if s == '':
print('YES')
else:
print('NO')
| __author__ = 'shukkkur'
'\nhttps://codeforces.com/problemset/problem/110/A\n'
i = input()
n = i.count('4') + i.count('7')
s = str(n)
s = s.replace('4', '')
s = s.replace('7', '')
if s == '':
print('YES')
else:
print('NO') |
PYTHON_PLATFORM = "python"
SUPPORTED_PLATFORMS = ((PYTHON_PLATFORM, "Python"),)
LOG_LEVEL_DEBUG = "debug"
LOG_LEVEL_INFO = "info"
LOG_LEVEL_ERROR = "error"
LOG_LEVEL_FATAL = "fatal"
LOG_LEVEL_SAMPLE = "sample"
LOG_LEVEL_WARNING = "warning"
LOG_LEVELS = (
(LOG_LEVEL_DEBUG, "Debug"),
(LOG_LEVEL_INFO, "Info"),
... | python_platform = 'python'
supported_platforms = ((PYTHON_PLATFORM, 'Python'),)
log_level_debug = 'debug'
log_level_info = 'info'
log_level_error = 'error'
log_level_fatal = 'fatal'
log_level_sample = 'sample'
log_level_warning = 'warning'
log_levels = ((LOG_LEVEL_DEBUG, 'Debug'), (LOG_LEVEL_INFO, 'Info'), (LOG_LEVEL_E... |
# Largest palindrome product
DIGITS = 3
def solve():
return max(p for x in range(10**(DIGITS - 1), 10**DIGITS)
for y in range(x, 10**DIGITS)
if str(p := x * y) == str(p)[::-1])
if __name__ == "__main__":
print(solve())
| digits = 3
def solve():
return max((p for x in range(10 ** (DIGITS - 1), 10 ** DIGITS) for y in range(x, 10 ** DIGITS) if str((p := (x * y))) == str(p)[::-1]))
if __name__ == '__main__':
print(solve()) |
def find_longest_palindrome(string):
if is_palindrome(string):
return string
left = find_longest_palindrome(string[:-1])
right = find_longest_palindrome(string[1:])
middle = find_longest_palindrome(string[1:-1])
if len(left) >= len(right) and len(left) >= len(middle):
return left
... | def find_longest_palindrome(string):
if is_palindrome(string):
return string
left = find_longest_palindrome(string[:-1])
right = find_longest_palindrome(string[1:])
middle = find_longest_palindrome(string[1:-1])
if len(left) >= len(right) and len(left) >= len(middle):
return left
... |
class Solution:
def mySqrt(self, x: int) -> int:
if x < 0 or x>(2**31):
return False
ans = 0
for i in range(0, x+1):
if i**2<=x:
ans = i
else:
break
return ans
| class Solution:
def my_sqrt(self, x: int) -> int:
if x < 0 or x > 2 ** 31:
return False
ans = 0
for i in range(0, x + 1):
if i ** 2 <= x:
ans = i
else:
break
return ans |
# Copyright 2020 The Kythe 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 applicable law... | load('@bazel_skylib//lib:paths.bzl', 'paths')
load('@bazel_tools//tools/cpp:toolchain_utils.bzl', 'find_cpp_toolchain')
load('//kythe/go/indexer:testdata/go_indexer_test.bzl', 'go_verifier_test')
load('//tools/build_rules/verifier_test:verifier_test.bzl', 'KytheEntries')
def _rust_extract_impl(ctx):
cc_toolchain =... |
class Participant:
def __init__(self, pa_name, pa_has_somebody_to_gift=False):
self._name = pa_name
# I don't use this property in my algorithm :P
self._has_somebody_to_gift = pa_has_somebody_to_gift
@property
def name(self):
return self._name
@name.setter
def name... | class Participant:
def __init__(self, pa_name, pa_has_somebody_to_gift=False):
self._name = pa_name
self._has_somebody_to_gift = pa_has_somebody_to_gift
@property
def name(self):
return self._name
@name.setter
def name(self, pa_name):
self._name = pa_name
@pro... |
def trint(inthing):
try:
outhing = int(inthing)
except:
outhing = None
return outhing
def trfloat(inthing, scale):
try:
outhing = float(inthing) * scale
except:
outhing = None
return outhing
class IMMA:
def __init__(self): # Standard instance obj... | def trint(inthing):
try:
outhing = int(inthing)
except:
outhing = None
return outhing
def trfloat(inthing, scale):
try:
outhing = float(inthing) * scale
except:
outhing = None
return outhing
class Imma:
def __init__(self):
self.data = {}
def re... |
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
count = 1
i = 0
while i <len(nums)-1:
if nums[i]!=nums[i+1]:
count=1
else:
count+=1
if count==2:
i+=1
... | class Solution:
def remove_duplicates(self, nums: List[int]) -> int:
count = 1
i = 0
while i < len(nums) - 1:
if nums[i] != nums[i + 1]:
count = 1
else:
count += 1
if count == 2:
i += 1
... |
# START LAB EXERCISE 02
print('Lab Exercise 02 \n')
# SETUP
sandwich_string = 'chicken, bread, lettuce, onion, olives'
# END SETUP
# PROBLEM 1 (4 Points)
sandwich_replace = sandwich_string.replace('olives', 'tomato')
# PROBLEM 2 (4 Points)
# Don't have heavy_cream need to replace with milk
sandwich_list = sandwic... | print('Lab Exercise 02 \n')
sandwich_string = 'chicken, bread, lettuce, onion, olives'
sandwich_replace = sandwich_string.replace('olives', 'tomato')
sandwich_list = sandwich_replace.split(', ')
sandwich_list.pop(0)
sandwich_list.append('cheese')
last_item = sandwich_list[-1] |
compilers_ = {
"python": "cpython-head",
"c++": "gcc-head",
"cpp": "gcc-head",
"c": "gcc-head",
"c#": "mono-head",
"javascript": "nodejs-head",
"js": "nodejs-head",
"coffeescript": "coffeescript-head",
"cs": "coffeescript-head",
"java": "openjdk-head",
"haskell": "ghc-8.4.2",... | compilers_ = {'python': 'cpython-head', 'c++': 'gcc-head', 'cpp': 'gcc-head', 'c': 'gcc-head', 'c#': 'mono-head', 'javascript': 'nodejs-head', 'js': 'nodejs-head', 'coffeescript': 'coffeescript-head', 'cs': 'coffeescript-head', 'java': 'openjdk-head', 'haskell': 'ghc-8.4.2', 'bash': 'bash', 'cmake': 'cmake-head', 'crys... |
class News(object):
news_id: int
title: str
image: str
def __init__(self, news_id: int, title: str, image: str):
self.news_id = news_id
self.title = title
self.image = image
class NewsContent(object):
news_id: int
title: str
content: str
def __init__(self, new... | class News(object):
news_id: int
title: str
image: str
def __init__(self, news_id: int, title: str, image: str):
self.news_id = news_id
self.title = title
self.image = image
class Newscontent(object):
news_id: int
title: str
content: str
def __init__(self, news... |
numbers = input()
list_of_nums = numbers.split(',')
tuple_of_nums = tuple(list_of_nums)
print(list_of_nums)
print(tuple_of_nums) | numbers = input()
list_of_nums = numbers.split(',')
tuple_of_nums = tuple(list_of_nums)
print(list_of_nums)
print(tuple_of_nums) |
# Generated by h2py z /usr/include/sys/cdio.h
CDROM_LBA = 0x01
CDROM_MSF = 0x02
CDROM_DATA_TRACK = 0x04
CDROM_LEADOUT = 0xAA
CDROM_AUDIO_INVALID = 0x00
CDROM_AUDIO_PLAY = 0x11
CDROM_AUDIO_PAUSED = 0x12
CDROM_AUDIO_COMPLETED = 0x13
CDROM_AUDIO_ERROR = 0x14
CDROM_AUDIO_NO_STATUS = 0x15
CDROM_DA_NO_SUBCODE = 0x00
CDROM_DA... | cdrom_lba = 1
cdrom_msf = 2
cdrom_data_track = 4
cdrom_leadout = 170
cdrom_audio_invalid = 0
cdrom_audio_play = 17
cdrom_audio_paused = 18
cdrom_audio_completed = 19
cdrom_audio_error = 20
cdrom_audio_no_status = 21
cdrom_da_no_subcode = 0
cdrom_da_subq = 1
cdrom_da_all_subcode = 2
cdrom_da_subcode_only = 3
cdrom_xa_da... |
def can_build(platform):
return platform != "android"
def configure(env):
pass
| def can_build(platform):
return platform != 'android'
def configure(env):
pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.