content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#
# Copyright (c) 2020, Hyve Design Solutions Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | __all__ = ['cmds', 'intf', 'mesg', 'util']
__version__ = 1.2 |
class Database:
database = None
def __init__(self):
self.content = "User Data"
@staticmethod
def getInstance():
if not Database.database:
print("New database instance created")
Database.database = Database()
return Database.database
def describe(self):
print("The databa... | class Database:
database = None
def __init__(self):
self.content = 'User Data'
@staticmethod
def get_instance():
if not Database.database:
print('New database instance created')
Database.database = database()
return Database.database
def describe(se... |
class OsptException(Exception):
msg = ''
def __init__(self, message, **kwargs):
_msg = message if message else self.msg
super(Exception, self).__init__(_msg.format(**kwargs))
class ConnectionError(OsptException):
pass
class TimeoutError(OsptException):
pass
class N... | class Osptexception(Exception):
msg = ''
def __init__(self, message, **kwargs):
_msg = message if message else self.msg
super(Exception, self).__init__(_msg.format(**kwargs))
class Connectionerror(OsptException):
pass
class Timeouterror(OsptException):
pass
class Notenoughresourcesto... |
"""The smtp component."""
DOMAIN = "smtp"
PLATFORMS = ["notify"]
| """The smtp component."""
domain = 'smtp'
platforms = ['notify'] |
TEST_NETLIST = r"""
** Library name: gsclib045
** Cell name: INVX1_3
** View name: schematic
.subckt INVX1_3 A Y VDD VSS
*.PININFO VSS:I VDD:I A:I Y:O
** Above line required by Conformal LEC - DO NOT DELETE
mp0 Y A VDD VDD g45p1svt L=45e-9 W=250e-9 AD=54.6e-15 AS=54.6e-15 PD=1.06e-6 PS=1.06e-6 NRD=358.974e-3 NRS=358.... | test_netlist = '\n** Library name: gsclib045\n** Cell name: INVX1_3\n** View name: schematic\n.subckt INVX1_3 A Y VDD VSS\n*.PININFO VSS:I VDD:I A:I Y:O\n** Above line required by Conformal LEC - DO NOT DELETE\n\nmp0 Y A VDD VDD g45p1svt L=45e-9 W=250e-9 AD=54.6e-15 AS=54.6e-15 PD=1.06e-6 PS=1.06e-6 NRD=358.974e-3 NRS... |
def byte_to_hex(bytebuffer):
return "".join(("%02x" % a) for a in bytebuffer)
# CASSSANDRA TYPES
class TxInputOutput(object):
def __init__(self, address, value):
self.address = address[0]
self.value = value
class Value(object):
def __init__(self, satoshi, eur, usd):
self.satosh... | def byte_to_hex(bytebuffer):
return ''.join(('%02x' % a for a in bytebuffer))
class Txinputoutput(object):
def __init__(self, address, value):
self.address = address[0]
self.value = value
class Value(object):
def __init__(self, satoshi, eur, usd):
self.satoshi = satoshi
s... |
def all_binary(k):
if k == 0:
return []
if k == 1:
return ["0", "1"]
return [f"0{x}" for x in all_binary(k - 1)] + [f"1{x}" for x in all_binary(k - 1)]
def all_k_in_str(str, k):
kmersFound = {}
for kmer in all_binary(k):
kmersFound[kmer] = False
n_kmers_found = 0
n... | def all_binary(k):
if k == 0:
return []
if k == 1:
return ['0', '1']
return [f'0{x}' for x in all_binary(k - 1)] + [f'1{x}' for x in all_binary(k - 1)]
def all_k_in_str(str, k):
kmers_found = {}
for kmer in all_binary(k):
kmersFound[kmer] = False
n_kmers_found = 0
n_... |
FreeSerifItalic18pt7bBitmaps = [
0x01, 0xC0, 0xF0, 0x3C, 0x0F, 0x03, 0x81, 0xE0, 0x70, 0x1C, 0x06, 0x01,
0x80, 0xC0, 0x30, 0x0C, 0x02, 0x01, 0x80, 0x40, 0x10, 0x00, 0x00, 0x01,
0x80, 0xF0, 0x3C, 0x06, 0x00, 0x38, 0x77, 0x8F, 0x78, 0xF7, 0x0E, 0x60,
0xE6, 0x0C, 0xC1, 0x8C, 0x18, 0x81, 0x00, 0x00, 0x60, 0... | free_serif_italic18pt7b_bitmaps = [1, 192, 240, 60, 15, 3, 129, 224, 112, 28, 6, 1, 128, 192, 48, 12, 2, 1, 128, 64, 16, 0, 0, 1, 128, 240, 60, 6, 0, 56, 119, 143, 120, 247, 14, 96, 230, 12, 193, 140, 24, 129, 0, 0, 96, 192, 12, 56, 3, 134, 0, 96, 192, 12, 56, 3, 6, 0, 96, 192, 255, 255, 31, 255, 224, 97, 192, 28, 48, ... |
#!/usr/bin/env python3
_, k, *l = map(int, open(0).read().split())
for a,b in sorted(zip(*[iter(l)]*2)):
k -= b
if k < 1:print(a);exit() | (_, k, *l) = map(int, open(0).read().split())
for (a, b) in sorted(zip(*[iter(l)] * 2)):
k -= b
if k < 1:
print(a)
exit() |
class player_class:
number = 0
name = ""
HP = 10
live = True
raceWeapon = ""
comp = False
real_player_list = []
def addRealPlayers():
n = 0
real_player_list.append(player_class())
print("Enter the first player's name:")
real_player_list[n].name = input()
real_p... | class Player_Class:
number = 0
name = ''
hp = 10
live = True
race_weapon = ''
comp = False
real_player_list = []
def add_real_players():
n = 0
real_player_list.append(player_class())
print("Enter the first player's name:")
real_player_list[n].name = input()
real_player_list[... |
f = open('dftdemo.hex', 'r')
lines = f.read().split('\n')
fout = open('mem-dft.hex', 'w')
step = 2
for line in lines:
for i in range(len(line), 0, -step):
fout.write(line[i-step:i])
fout.write('\n')
| f = open('dftdemo.hex', 'r')
lines = f.read().split('\n')
fout = open('mem-dft.hex', 'w')
step = 2
for line in lines:
for i in range(len(line), 0, -step):
fout.write(line[i - step:i])
fout.write('\n') |
expected_output = {
'test': {
'loopback Test': {
'status': True
}
}
}
| expected_output = {'test': {'loopback Test': {'status': True}}} |
name = input('What is your first name? ')
print(
'Your name is as long or longer the the avarage first name'
) if len(name) >= 6 else print(
'Your name is shorter than the avarage first name'
)
message = (
'The first letter in your name is among the five most common'
if name[0].lower() in ['a', 'j', '... | name = input('What is your first name? ')
print('Your name is as long or longer the the avarage first name') if len(name) >= 6 else print('Your name is shorter than the avarage first name')
message = 'The first letter in your name is among the five most common' if name[0].lower() in ['a', 'j', 'm', 'e', 'l'] else 'The ... |
AWS_API_KEY = None
AWS_SECRET_KEY = None
AWS_KEY_FILE = None
LOCAL_AWS_KEY_FILE = None
#AMI SETTINGS
# AMI IDs are available on http://cloud.ubuntu.com/ami/
# Ubuntu 12.04 EBS Backed Instances
AMI_ID_BY_REGION = {
'ap-northeast-1' : 'ami-d71a9ad6',
'ap-southeast-1' : 'ami-6686ca34',
'ap-southeast-2' : 'ami... | aws_api_key = None
aws_secret_key = None
aws_key_file = None
local_aws_key_file = None
ami_id_by_region = {'ap-northeast-1': 'ami-d71a9ad6', 'ap-southeast-1': 'ami-6686ca34', 'ap-southeast-2': 'ami-4a38a970', 'eu-west-1': 'ami-1ef5ff6a', 'sa-east-1': 'ami-c371aade', 'us-east-1': 'ami-1ebb2077', 'us-west-1': 'ami-b0c3ee... |
# 169. Majority Element
# Given an array of size n, find the majority element. The majority element is the element that appears more than n/2 times.
# You may assume that the array is non-empty and the majority element always exist in the array.
# DIVIDE AND CONQUER [NOT THE BEST WAY TO SOLVE IT]
class Solution:
... | class Solution:
def majority_element(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
return self.helper(nums, 0, len(nums) - 1)
def helper(self, nums, left, right):
if left == right:
return nums[left]
mid = left + (right - left) // 2
... |
class SearcherConfig():
AND = 'AND'
OR = 'OR'
| class Searcherconfig:
and = 'AND'
or = 'OR' |
# Exercise on selection sort - Level 1
def find_next_min(num_list, start_index):
# Remove pass and write the logic to find the minimum element in a sub-list and return the index of the identified element in the num_list.
# start_index indicates the start index of the sub-list
min_index = 0
for i in ra... | def find_next_min(num_list, start_index):
min_index = 0
for i in range(len(num_list)):
if i >= start_index:
if num_list[i] < num_list[start_index]:
min_index = i
return min_index
min_index = start_index
return min_index
num_list = [10, 2, 100, 67, 1]
s... |
#!/usr/bin/python
delayIntervals = [0, 40, 80, 160]
lossIntervals = [0, 5, 10]
tcpTestLocation = '../../tcp-clock-station/tcp-clock-station'
udpTestLocation = '../../udp-clock-station/udp-clock-station'
rrtcpTestLocation = '../../rrtcp-clock-station/rrtcp-clock-station'
| delay_intervals = [0, 40, 80, 160]
loss_intervals = [0, 5, 10]
tcp_test_location = '../../tcp-clock-station/tcp-clock-station'
udp_test_location = '../../udp-clock-station/udp-clock-station'
rrtcp_test_location = '../../rrtcp-clock-station/rrtcp-clock-station' |
transitions = {' ': {' ': 2877,
'?': 24468,
'a': 68563,
'b': 24641,
'c': 21074,
'd': 16954,
'e': 11615,
'f': 21199,
'g': 9600,
'h': 49177,
'i': 29498,
'j': 1618,
'k': 3983,
'l': 13015,
'm': 19254,
'n': 14619,
... | transitions = {' ': {' ': 2877, '?': 24468, 'a': 68563, 'b': 24641, 'c': 21074, 'd': 16954, 'e': 11615, 'f': 21199, 'g': 9600, 'h': 49177, 'i': 29498, 'j': 1618, 'k': 3983, 'l': 13015, 'm': 19254, 'n': 14619, 'o': 33619, 'p': 18734, 'q': 1410, 'r': 15070, 's': 40402, 't': 86410, 'u': 5537, 'v': 3914, 'w': 39279, 'x': 4... |
# -*- coding: utf-8 -*-
# Module/mypkg/mod3.py
class MyClass():
def func3(self):
print("./mypkg/mod3.py")
print("func3")
| class Myclass:
def func3(self):
print('./mypkg/mod3.py')
print('func3') |
# Question
# WAP to find a reverse of the four-digit number
# Code
# I ask the user for the number
num=int(input('Enter a number: '))
# I initialize the value to null ; rev is just another variable I took for reverse
rev=0
# we can do the task by using a while loop
while (num>0): # 'num' should not be reversed o... | num = int(input('Enter a number: '))
rev = 0
while num > 0:
digit = num % 10
rev = rev * 10 + digit
num = num // 10
print(f'Reverse number is {rev}') |
'''
Problem description:
Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a
multiplication table sized according to the given dimensions. **The return value of the function
must be an array, and the numbers must be Fixnums, NOT strings.
Example:
multiplication_table(3,... | """
Problem description:
Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a
multiplication table sized according to the given dimensions. **The return value of the function
must be an array, and the numbers must be Fixnums, NOT strings.
Example:
multiplication_table(3,... |
class Person:
"""Represents a generic Person."""
def __init__(self, first, last, weight, height):
self.first_name = first
self.last_name = last
self.weight_in_lbs = weight
self.height_in_inches = height
p1 = Person('Tom', 'Smith', 80, 185)
p2 = Person('Fred', 'Smith', 80, 185)
p... | class Person:
"""Represents a generic Person."""
def __init__(self, first, last, weight, height):
self.first_name = first
self.last_name = last
self.weight_in_lbs = weight
self.height_in_inches = height
p1 = person('Tom', 'Smith', 80, 185)
p2 = person('Fred', 'Smith', 80, 185)
p... |
# DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml.
class PassThroughClientService:
def __init__(self, http_client):
self._http_client = http_client
def set_zrobotsecret_header(self, val):
"""" Set header ZrobotSecret to '<val>'"""
self._http_client.set_hea... | class Passthroughclientservice:
def __init__(self, http_client):
self._http_client = http_client
def set_zrobotsecret_header(self, val):
"""" Set header ZrobotSecret to '<val>'"""
self._http_client.set_header('Zrobot', val)
return self._http_client.set_header('ZrobotSecret', va... |
# simple function calling
def our_method(a, b):
if a > b:
a = a + 1
a = a + 2
a = a + 3
a = a + 3
a = a + 3
a = a + 3
a = a + 3
return a
else:
b = b + 1
b = b + 2
b = b + 3
return b
x = our_method(2, 3)
print(x... | def our_method(a, b):
if a > b:
a = a + 1
a = a + 2
a = a + 3
a = a + 3
a = a + 3
a = a + 3
a = a + 3
return a
else:
b = b + 1
b = b + 2
b = b + 3
return b
x = our_method(2, 3)
print(x)
def our_method1(c, d):
if... |
# https://www.codewars.com/kata/50654ddff44f800200000004
def multiply(a, b):
return a * b
| def multiply(a, b):
return a * b |
__version__ = "0.0.1"
# from .fe import *
# from .metric import *
# from .oos import *
# # from .scripts import *
# from .utils import *
test_var = 1
test_dict = {'a': 1, 'b': 2}
test_list = [1,2,3] | __version__ = '0.0.1'
test_var = 1
test_dict = {'a': 1, 'b': 2}
test_list = [1, 2, 3] |
"""
Class with all params of BackEnd.MemoryBound.MioThrottle class
and their subclasses
@author: Alvaro Saiz (UC)
@date: Jul 2021
@version: 1.0
"""
class MemoryMioThrottleParameters:
C_MEMORY_MIO_THROTTLE_NAME : str = "BACK-END.MEMORY-BOUND.MIO-THROTTLE"
C_MEMORY_MIO_THROT... | """
Class with all params of BackEnd.MemoryBound.MioThrottle class
and their subclasses
@author: Alvaro Saiz (UC)
@date: Jul 2021
@version: 1.0
"""
class Memorymiothrottleparameters:
c_memory_mio_throttle_name: str = 'BACK-END.MEMORY-BOUND.MIO-THROTTLE'
c_memory_mio_throttle_description: str = 'Coll... |
# Set ranks of words in list (starting at 0)
def setRanks(wordList):
for x in range(len(wordList)):
wordList[x].setRank(x)
# Set ranks and initialize modify and notModify characteristics
# Modifies the words themselves (no copy created)
def readyWordList(wordList):
setRanks(wordList)
for x in wordList:
x.initia... | def set_ranks(wordList):
for x in range(len(wordList)):
wordList[x].setRank(x)
def ready_word_list(wordList):
set_ranks(wordList)
for x in wordList:
x.initializeModify()
x.initializeNotModify()
def extract_ids(wcList):
ids = []
for word in wcList:
ids.append(word._i... |
"""
Problem : Add Two Numbers (https://leetcode.com/problems/add-two-numbers/description/)
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
"""Solution Class"""
def addTwoNumbers(self, l1, l2):
""... | """
Problem : Add Two Numbers (https://leetcode.com/problems/add-two-numbers/description/)
"""
class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
"""Solution Class"""
def add_two_numbers(self, l1, l2):
"""
:type l1: ListNode
... |
def symmetric_difference(a, b):
return sorted(set(a ^ b), key=int)
if __name__ == '__main__':
_,a = input(), set(input().split())
_,b = input(), set(input().split())
print('\n'.join(symmetric_difference(a, b)))
| def symmetric_difference(a, b):
return sorted(set(a ^ b), key=int)
if __name__ == '__main__':
(_, a) = (input(), set(input().split()))
(_, b) = (input(), set(input().split()))
print('\n'.join(symmetric_difference(a, b))) |
def make_bold(function):
def wrapper(*args):
return f"<b>{function(*args)}</b>"
return wrapper
def make_italic(function):
def wrapper(*args):
return f"<i>{function(*args)}</i>"
return wrapper
def make_underline(function):
def wrapper(*args):
return f"<u>{function(*args)}<... | def make_bold(function):
def wrapper(*args):
return f'<b>{function(*args)}</b>'
return wrapper
def make_italic(function):
def wrapper(*args):
return f'<i>{function(*args)}</i>'
return wrapper
def make_underline(function):
def wrapper(*args):
return f'<u>{function(*args)}... |
def test_passed():
assert True
def test_read_params(config, param):
assert config.get(param) == 2
def test_do_nothing():
pass
| def test_passed():
assert True
def test_read_params(config, param):
assert config.get(param) == 2
def test_do_nothing():
pass |
def print_list(head):
temp=head
while temp:
print (temp.data)
temp=temp.next
def reverse_even_nodes(head):
odd=head
even=None
while odd:
if odd.next:
temp=odd.next
odd.next=odd.next.next
temp.next=even
even=temp
odd=odd.next
odd=head
curr=head
print("this is odd l... | def print_list(head):
temp = head
while temp:
print(temp.data)
temp = temp.next
def reverse_even_nodes(head):
odd = head
even = None
while odd:
if odd.next:
temp = odd.next
odd.next = odd.next.next
temp.next = even
even = temp
... |
hparam_grids={
'rf':{
'n_estimators':[120,300,500,800,1200],
'max_depth':[15,25,30,None],
'min_samples_split':[2,5,10,15,100],
'min_samples_leaf':[2,4,5,10],
'max_features':[None, 0.5]
},
'xgb':{
'eta':[0.01, 0.015, 0.025, 0.05, 0.1],
'gamma':[0.05, 0.... | hparam_grids = {'rf': {'n_estimators': [120, 300, 500, 800, 1200], 'max_depth': [15, 25, 30, None], 'min_samples_split': [2, 5, 10, 15, 100], 'min_samples_leaf': [2, 4, 5, 10], 'max_features': [None, 0.5]}, 'xgb': {'eta': [0.01, 0.015, 0.025, 0.05, 0.1], 'gamma': [0.05, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0], 'max_depth': [3, 5... |
"""
Given a positive integer N and a precision factor P,
it produces an output
with a maximum error P from the actual square root of N.
Example:
Given N = 5 and P = 0.001, can produce output x such that
2.235 < x < 2.237. Actual square root of 5 being 2.236.
"""
def square_root(n, epsilon=0.001):
"""Return squar... | """
Given a positive integer N and a precision factor P,
it produces an output
with a maximum error P from the actual square root of N.
Example:
Given N = 5 and P = 0.001, can produce output x such that
2.235 < x < 2.237. Actual square root of 5 being 2.236.
"""
def square_root(n, epsilon=0.001):
"""Return square... |
data = open("data-14006B000", "r").read()
a = []
index = 0
for _ in range(266504):
index = data.find("dup(", index) + 4
a.append(int(data[index]))
print(a)
| data = open('data-14006B000', 'r').read()
a = []
index = 0
for _ in range(266504):
index = data.find('dup(', index) + 4
a.append(int(data[index]))
print(a) |
COMMONSENSE_MAPPING = {'Antonym': 'antonym',
'AtLocation': 'at location',
'CapableOf': 'capable of',
'Causes': 'causes',
'CausesDesire': 'causes desire',
'CreatedBy': 'created by',
'DefinedAs': 'defined as',
'DerivedFrom': 'derived from',
'Desires': 'desires',
'DistinctFrom': 'destinct from',
'Enta... | commonsense_mapping = {'Antonym': 'antonym', 'AtLocation': 'at location', 'CapableOf': 'capable of', 'Causes': 'causes', 'CausesDesire': 'causes desire', 'CreatedBy': 'created by', 'DefinedAs': 'defined as', 'DerivedFrom': 'derived from', 'Desires': 'desires', 'DistinctFrom': 'destinct from', 'Entails': 'entails', 'Ety... |
class BasePlanet:
def __init__(self, name, description):
self.name = name
self.description = description
self.port = None
def get_info(self):
return f'*{self.name}*\n' \
f'{self.description}'
def start(self, message):
self.port.start(message)
def... | class Baseplanet:
def __init__(self, name, description):
self.name = name
self.description = description
self.port = None
def get_info(self):
return f'*{self.name}*\n{self.description}'
def start(self, message):
self.port.start(message)
def __str__(self):
... |
def calcularMitadHorizontal(size = int(), division = int(), position = int(), message = str()):
if position < 1:
return -1
if division < 2:
return -1
if size <= division:
return -1
return int(((size / division)*position)/int(2) - len(message))
| def calcular_mitad_horizontal(size=int(), division=int(), position=int(), message=str()):
if position < 1:
return -1
if division < 2:
return -1
if size <= division:
return -1
return int(size / division * position / int(2) - len(message)) |
class Person:
def sleep(self):
return "sleeping..."
class Employee:
def get_fired(self):
return "fired..."
class Teacher(Person, Employee):
def teach(self):
return "teaching..."
gosho = Teacher()
print(Teacher.__mro__)
print(gosho.sleep())
print(gosho.get_fired())
print(gosho.t... | class Person:
def sleep(self):
return 'sleeping...'
class Employee:
def get_fired(self):
return 'fired...'
class Teacher(Person, Employee):
def teach(self):
return 'teaching...'
gosho = teacher()
print(Teacher.__mro__)
print(gosho.sleep())
print(gosho.get_fired())
print(gosho.te... |
def generate_signer_resources(gendoc):
gendoc.add_comments("""
The signer watches all release tags and signs those that have the correct metadata and images are reachable (according
to an `oc adm release info --verify` invocation). Signatures a test that the specified release image was built within the
CI infrast... | def generate_signer_resources(gendoc):
gendoc.add_comments('\nThe signer watches all release tags and signs those that have the correct metadata and images are reachable (according\nto an `oc adm release info --verify` invocation). Signatures a test that the specified release image was built within the\nCI infrastr... |
number1 = int(input("Enter number 1: "))
number2 = int(input("Enter number 2: "))
def multiplication(number1, number2):
return number1 * number2
print(multiplication(number1, number2)) | number1 = int(input('Enter number 1: '))
number2 = int(input('Enter number 2: '))
def multiplication(number1, number2):
return number1 * number2
print(multiplication(number1, number2)) |
'''
Write a Python program to perform an action if a condition is true.
Given a variable name, if the value is 1, display the string "First day of a Month!" and do nothing if the value is not equal.
'''
var_word = int(input("Enter a number between 0-9: "))
if var_word == 1:
print("First day of a month!")
| """
Write a Python program to perform an action if a condition is true.
Given a variable name, if the value is 1, display the string "First day of a Month!" and do nothing if the value is not equal.
"""
var_word = int(input('Enter a number between 0-9: '))
if var_word == 1:
print('First day of a month!') |
# class constructor takes an array of integers as a parameter and saves it to the __elements instance variable.
class Difference:
def __init__(self, a):
self.__elements = a
def computeDifference(self):
maxDiff = 0
# computeDifference method that finds the maximum absolute difference betwee... | class Difference:
def __init__(self, a):
self.__elements = a
def compute_difference(self):
max_diff = 0
for i in range(len(self.__elements)):
for j in range(len(self.__elements)):
absolute = abs(self.__elements[i] - self.__elements[j])
if abs... |
# coding: utf-8
RESOURCE_MAPPING = {
'list_spreadsheets': {
'resource': '/spreadsheets/private/full',
'docs': 'https://developers.google.com/google-apps/spreadsheets/worksheets'
'#retrieve_a_list_of_spreadsheets'
},
'manage_worksheets': {
'resource': '/worksheets/{ke... | resource_mapping = {'list_spreadsheets': {'resource': '/spreadsheets/private/full', 'docs': 'https://developers.google.com/google-apps/spreadsheets/worksheets#retrieve_a_list_of_spreadsheets'}, 'manage_worksheets': {'resource': '/worksheets/{key}/private/full', 'docs': 'https://developers.google.com/google-apps/spreads... |
def majorityElement(self, nums: List[int]) -> int:
'''
tracker = {}
for num in nums:
if num not in tracker:
tracker[num] = 1
else:
tracker[num] += 1
return max(tracker, key=tracker.get)
'''
# Much nicer
num = sorted(nums)
r... | def majority_element(self, nums: List[int]) -> int:
"""
tracker = {}
for num in nums:
if num not in tracker:
tracker[num] = 1
else:
tracker[num] += 1
return max(tracker, key=tracker.get)
"""
num = sorted(nums)
return num[len(num) // 2... |
a, b = input().split()
if int(a) > int(b):
print(b * int(a))
else:
print(a * int(b)) | (a, b) = input().split()
if int(a) > int(b):
print(b * int(a))
else:
print(a * int(b)) |
n=int(input())
arr = []
for i in range(n):
arr.append(int(input()))
k=None
c=0
temp=[]
for i in range(n):
temp.append(abs(arr[0]-arr[i]))
k=max(temp)
if k<2:
k=2
for i in range(n):
c+=abs(k-arr[i])
k+=1
print(c)
| n = int(input())
arr = []
for i in range(n):
arr.append(int(input()))
k = None
c = 0
temp = []
for i in range(n):
temp.append(abs(arr[0] - arr[i]))
k = max(temp)
if k < 2:
k = 2
for i in range(n):
c += abs(k - arr[i])
k += 1
print(c) |
class ActException(Exception):
def __init__(self, message):
super(ActException, self).__init__(message)
self.message = message
class ActLoginError(ActException):
def __init__(self, msg):
super(ActLoginError, self).__init__('Actifio Login Exception: %s' % msg)
self.msg = msg
class ActConnectError(... | class Actexception(Exception):
def __init__(self, message):
super(ActException, self).__init__(message)
self.message = message
class Actloginerror(ActException):
def __init__(self, msg):
super(ActLoginError, self).__init__('Actifio Login Exception: %s' % msg)
self.msg = msg
c... |
#a
"""
for each pair of items in the usorted list:
if the pair is out of order :
swap them
"""
#b
#The end of the unsorted list
"""end = len(lst) - 1
#Keep going until the last item of the list is reached
while end != 0 :
for each pair of items in the usorted list:
if the pair is out of order :
... | """
for each pair of items in the usorted list:
if the pair is out of order :
swap them
"""
'end = len(lst) - 1\n\n#Keep going until the last item of the list is reached\nwhile end != 0 :\n for each pair of items in the usorted list:\n if the pair is out of order :\n swap them\n end = end -1... |
a = "WWW"
b = 'WWW'
lrc = "I've let you down"
# lrc2 = 'I've let you down'
print(lrc);
# \t
# \n
sen = "Jack: \"You jump I jump\""
sen2 = 'Jack: "You jump I jump"'
print(sen);
print(sen2);
| a = 'WWW'
b = 'WWW'
lrc = "I've let you down"
print(lrc)
sen = 'Jack: "You jump I jump"'
sen2 = 'Jack: "You jump I jump"'
print(sen)
print(sen2) |
class NotDefined:
pass
def has_descent_attrs(obj, *args):
i = obj
for attr_name in args:
if not hasattr(i, attr_name):
return False
i = getattr(i, attr_name)
return True
def get_descent_attrs(obj, *args, **kwargs):
default = kwargs.pop('default', NotDefined)
i = o... | class Notdefined:
pass
def has_descent_attrs(obj, *args):
i = obj
for attr_name in args:
if not hasattr(i, attr_name):
return False
i = getattr(i, attr_name)
return True
def get_descent_attrs(obj, *args, **kwargs):
default = kwargs.pop('default', NotDefined)
i = obj... |
#%%
"""
- Flip Equivalent Binary Trees
- https://leetcode.com/problems/flip-equivalent-binary-trees/
- Medium
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.
A binary tree X is flip equivalent to a binary tree Y if and only if we can make X ... | """
- Flip Equivalent Binary Trees
- https://leetcode.com/problems/flip-equivalent-binary-trees/
- Medium
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.
A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equa... |
"""
Meta-information about pe.
"""
__version__ = '0.3.2'
# Note: most of this file's contents has moved to setup.cfg
| """
Meta-information about pe.
"""
__version__ = '0.3.2' |
# Here go your api methods.
def get_products():
if request.vars['query'] is None:
product_list = db().select(db.r_products.ALL)
return response.json(dict(product_list=product_list))
else:
product_list = db(db.r_products.f_name.like(request.vars['query'] + '%') ).select()
return response.json(dict(product... | def get_products():
if request.vars['query'] is None:
product_list = db().select(db.r_products.ALL)
return response.json(dict(product_list=product_list))
else:
product_list = db(db.r_products.f_name.like(request.vars['query'] + '%')).select()
return response.json(dict(product_lis... |
class Emp:
def __init__(self, emp_id=0, name="", age=0, gender="", place="", salary=0, previous_company="", joining_date=""):
self._emp_id = emp_id
self._name = name
self._age = age
self._gender = gender
self._place = place
self._salary = salary
self._previo... | class Emp:
def __init__(self, emp_id=0, name='', age=0, gender='', place='', salary=0, previous_company='', joining_date=''):
self._emp_id = emp_id
self._name = name
self._age = age
self._gender = gender
self._place = place
self._salary = salary
self._previou... |
def test_foo():
assert False
def test_bar():
assert False
| def test_foo():
assert False
def test_bar():
assert False |
with open("input", "r") as f:
count = 0
for line in f:
string = line.split(': ')[1]
fst = line.split(': ')[0]
letter = fst[-1]
fst = fst[:-1]
a = int(fst.split('-')[0])
a -= 1
b = int(fst.split('-')[1])
b -= 1
count += bool(string[a] == letter) != bool(string[b] == letter)
pri... | with open('input', 'r') as f:
count = 0
for line in f:
string = line.split(': ')[1]
fst = line.split(': ')[0]
letter = fst[-1]
fst = fst[:-1]
a = int(fst.split('-')[0])
a -= 1
b = int(fst.split('-')[1])
b -= 1
count += bool(string[a] == let... |
sol = ""
for i in range (1,1000000):
sol = sol+str(i)
if len(sol) > 1000000:
break
ans = 1
for i in range(6):
ans = ans*int(sol[10**i-1])
print(ans) | sol = ''
for i in range(1, 1000000):
sol = sol + str(i)
if len(sol) > 1000000:
break
ans = 1
for i in range(6):
ans = ans * int(sol[10 ** i - 1])
print(ans) |
side = 1080
frames = 120
speed = 4000
def lsPts(inc):
steps = 1 + inc
size = 2
tr = 106.5
points = []
for i in range(steps):
t = i / 21 * pi
x = (size * t) * cos(t)
y = (size * t) * sin(t) - (tr/2)
points.append((x, y))
for i in range(-steps, 0):
t = i / ... | side = 1080
frames = 120
speed = 4000
def ls_pts(inc):
steps = 1 + inc
size = 2
tr = 106.5
points = []
for i in range(steps):
t = i / 21 * pi
x = size * t * cos(t)
y = size * t * sin(t) - tr / 2
points.append((x, y))
for i in range(-steps, 0):
t = i / 21 ... |
def do_stuff():
print('stuff')
def do_other_stuff():
print('other stuff')
def branching(some_condition):
if some_condition is True:
do_stuff()
do_other_stuff()
| def do_stuff():
print('stuff')
def do_other_stuff():
print('other stuff')
def branching(some_condition):
if some_condition is True:
do_stuff()
do_other_stuff() |
def react(text):
stack = []
for letter in text:
if not stack:
stack.append(letter)
else:
l = stack[-1]
if letter != l and l.lower() == letter.lower():
stack.pop()
else:
stack.append(letter)
return len(stack)
d... | def react(text):
stack = []
for letter in text:
if not stack:
stack.append(letter)
else:
l = stack[-1]
if letter != l and l.lower() == letter.lower():
stack.pop()
else:
stack.append(letter)
return len(stack)
def... |
class Node:
def __init__(self, data=None):
self.val = data
self.right = None
self.left = None
class BST:
def __init__(self, data=None):
self.tree = None if data is None else Node(data)
def isEmpty(self):
if self.tree == None:
return True
else:
... | class Node:
def __init__(self, data=None):
self.val = data
self.right = None
self.left = None
class Bst:
def __init__(self, data=None):
self.tree = None if data is None else node(data)
def is_empty(self):
if self.tree == None:
return True
else:... |
# Define a function searching for the longest word
def get_longest_word(words):
longest_word = ''
for word in words:
if len(word) > len(longest_word):
longest_word = word
return longest_word
wlist = [
['Python', 'creativity', 'universe'],
['interview', 'study', 'job', 'univers... | def get_longest_word(words):
longest_word = ''
for word in words:
if len(word) > len(longest_word):
longest_word = word
return longest_word
wlist = [['Python', 'creativity', 'universe'], ['interview', 'study', 'job', 'university', 'lecture'], ['task', 'objective', 'aim', 'subject', 'prog... |
class Loop(object):
"""
Repeatedly run and reschedule an action.
"""
def __init__(self, clock, action):
"""
Args:
clock: a clock function that returns a non-decreasing time.
action: the action to run.
reschedule: a function that reschedules this action. It m... | class Loop(object):
"""
Repeatedly run and reschedule an action.
"""
def __init__(self, clock, action):
"""
Args:
clock: a clock function that returns a non-decreasing time.
action: the action to run.
reschedule: a function that reschedules this action. It ... |
def create_tags_list(*tags):
tags_list = list(set(tags))
tags_list.sort()
return tags_list
| def create_tags_list(*tags):
tags_list = list(set(tags))
tags_list.sort()
return tags_list |
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def isPalindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
# Quick return
if not head or... | class Solution(object):
def is_palindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
if not head or not head.next:
return True
slow = head
fast = head
count = 0
while fast and fast.next:
slow = slow.next
... |
# cc71 meanMedianMode https://repl.it/student/submissions/1871422
'''
Write a function that, given a list of numbers, calculates the
mean, median, and mode of those numbers. Return a dictionary with
properties for the mean, median and mode.
For example:
mmm_dict = meanMedianMode([1,2,3,4,5,6,7,8,9,10,10])
print(mmm_di... | """
Write a function that, given a list of numbers, calculates the
mean, median, and mode of those numbers. Return a dictionary with
properties for the mean, median and mode.
For example:
mmm_dict = meanMedianMode([1,2,3,4,5,6,7,8,9,10,10])
print(mmm_dict) should print:
{'mean': 5.909090909090909, 'median': 6, 'mode':... |
"""translation tables are useful for mapping character changes (translations)"""
trans_table1 = "A Tesx Sxring".maketrans({"x": "t"})
trans_table2 = "A Tesx Sxring".maketrans("x", "t")
print(trans_table1)
print(trans_table2)
trans1 = "A Tesx Sxring".translate(trans_table1)
trans2 = "A Tesx Sxring".translate(trans_ta... | """translation tables are useful for mapping character changes (translations)"""
trans_table1 = 'A Tesx Sxring'.maketrans({'x': 't'})
trans_table2 = 'A Tesx Sxring'.maketrans('x', 't')
print(trans_table1)
print(trans_table2)
trans1 = 'A Tesx Sxring'.translate(trans_table1)
trans2 = 'A Tesx Sxring'.translate(trans_table... |
class Vector:
def __init__(self, x, y):
self.x = x
self.y = y
def add(self, other):
return Vector(self.x + other.x , self.y + other.y)
def sub(self, other):
return Vector(self.x - other.x, self.y - other.y)
def mag2(self):
return self.x ** 2 + self.y ** 2
... | class Vector:
def __init__(self, x, y):
self.x = x
self.y = y
def add(self, other):
return vector(self.x + other.x, self.y + other.y)
def sub(self, other):
return vector(self.x - other.x, self.y - other.y)
def mag2(self):
return self.x ** 2 + self.y ** 2
... |
# Copyright 2016 F5 Networks 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 writi... | def setup_test(request, mgmt_root, name):
def teardown():
if dns1.exists(name=name):
dns1.delete()
request.addfinalizer(teardown)
dc1 = mgmt_root.tm.net.dns_resolvers
dr1 = dc1.dns_resolver
dns1 = dr1.create(name=name)
return (dc1, dns1)
class Testdnsresolver(object):
... |
#3
for row in range(8):
for col in range(6):
if (row==0) or (row==1 and col==4) or (row==2 and col==3)or (row==3 and col==2)or (row==4 and col==3)or (row==5 and col==4) or row==6:
print("*",end=" ")
else:
print(" ",end=" ")
print()
| for row in range(8):
for col in range(6):
if row == 0 or (row == 1 and col == 4) or (row == 2 and col == 3) or (row == 3 and col == 2) or (row == 4 and col == 3) or (row == 5 and col == 4) or (row == 6):
print('*', end=' ')
else:
print(' ', end=' ')
print() |
def main():
info('Waiting for minibone access')
wait('JanMiniboneFlag', 0)
info('Minibone released')
wait('MinibonePumpTimeFlag', 0)
acquire('FelixMiniboneFlag', clear=True)
info('minibone acquired')
| def main():
info('Waiting for minibone access')
wait('JanMiniboneFlag', 0)
info('Minibone released')
wait('MinibonePumpTimeFlag', 0)
acquire('FelixMiniboneFlag', clear=True)
info('minibone acquired') |
def findFirstAndLast(arr, n, x) :
first = -1
last = -1
for i in range(0, n) :
if (x != arr[i]) :
continue
if (first == -1) :
first = i
last = i
if (first != -1) :
print( "First Occurrence = ", first,
" \nLast Occurrence = ", last)
else :
print("Not Found")
arr = [1, 2, 2, 2, 2, 3, 4, 7, ... | def find_first_and_last(arr, n, x):
first = -1
last = -1
for i in range(0, n):
if x != arr[i]:
continue
if first == -1:
first = i
last = i
if first != -1:
print('First Occurrence = ', first, ' \nLast Occurrence = ', last)
else:
print('N... |
#Config File for declaring and initializing global variables
data_glance_exit_flag = False
current_temp = 0
current_humidity = 0
current_soil = 0
current_float = 0
current_fan = 0
pumped = False
currently_lighting = False
| data_glance_exit_flag = False
current_temp = 0
current_humidity = 0
current_soil = 0
current_float = 0
current_fan = 0
pumped = False
currently_lighting = False |
team_names = ['Pittsburgh Steelers', 'Baltimore Ravens', 'NE Patriots', 'Miami Dolphins',
'Indianapolis Colts', 'Jacksonville Jaguars', 'Denver Broncos', 'KC Chiefs',
'Green Bay Packers', 'Chicago Bears', 'Dallas Cowboys', 'Philadelphia Eagles',
'New Orleans Saints', 'Atlanta... | team_names = ['Pittsburgh Steelers', 'Baltimore Ravens', 'NE Patriots', 'Miami Dolphins', 'Indianapolis Colts', 'Jacksonville Jaguars', 'Denver Broncos', 'KC Chiefs', 'Green Bay Packers', 'Chicago Bears', 'Dallas Cowboys', 'Philadelphia Eagles', 'New Orleans Saints', 'Atlanta Falcons', 'Seattle Seahawks', 'LA Rams'] |
# Time: O(31)
# Space: O(1)
# 1318 weekly contest 171 1/11/2020
# Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make a OR b == c. (bitwise OR operation).
# Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representa... | class Solution(object):
def min_flips(self, a, b, c):
"""
:type a: int
:type b: int
:type c: int
:rtype: int
"""
def number_of_1_bits(n):
result = 0
while n:
n &= n - 1
result += 1
return re... |
class Solution:
# @param n, an integer
# @return an integer
def climbStairs(self, n):
table = {}
table[1] = 1
table[2] = 2
for i in range(1, n+1):
if i not in table:
table[i] = table[i-1] + table[i-2]
return table[n]
s = 3
solution = Solu... | class Solution:
def climb_stairs(self, n):
table = {}
table[1] = 1
table[2] = 2
for i in range(1, n + 1):
if i not in table:
table[i] = table[i - 1] + table[i - 2]
return table[n]
s = 3
solution = solution()
print(solution.climbStairs(s)) |
#!/usr/bin/env python
"""
_FwkJobReport_
FwkJobReport unit test
"""
__all__ = []
| """
_FwkJobReport_
FwkJobReport unit test
"""
__all__ = [] |
##f = []
##
##def factorial(n):
## result = n
## for i in range(1, n):
## if(i in f):
## result = i * f[f.index(i)]
## else:
## result = i * result
## f.append(result)
## print(result)
##
##factorial(3)
##factorial(4)
##n = int(input())
##arr = [1] * (n + 1)
##f... | n = int(input())
f = []
result = 1
for i in range(1, n + 1):
result = i * result
f.append(result)
print(result) |
class Solution:
def __init__(self):
self.RED = 0
self.BLUE = 1
self.GREEN = 2
def minCost(self, costs: List[List[int]]) -> int:
if len(costs) == 0:
return 0
for idx in range(1, len(costs)):
prev_min_costs = costs[idx - 1]
... | class Solution:
def __init__(self):
self.RED = 0
self.BLUE = 1
self.GREEN = 2
def min_cost(self, costs: List[List[int]]) -> int:
if len(costs) == 0:
return 0
for idx in range(1, len(costs)):
prev_min_costs = costs[idx - 1]
costs[idx][... |
class Node:
def __init__(self, data=None, prev=None, next=None):
self.data = data
self.prev = prev
self.next = next
class DoublyLinkedList:
def __init__(self):
self.head = None
def insert_at_begining(self, data):
node = Node(data=data)
if self.head is None:... | class Node:
def __init__(self, data=None, prev=None, next=None):
self.data = data
self.prev = prev
self.next = next
class Doublylinkedlist:
def __init__(self):
self.head = None
def insert_at_begining(self, data):
node = node(data=data)
if self.head is None... |
with open("top10000words.txt", 'r') as f:
allwords = f.readlines()
fiveletterwords = []
for word in allwords:
if len(list(word)) == 6:
fiveletterwords.append(word.lower())
with open('5lettertop10k.txt', 'w') as g:
g.writelines(fiveletterwords) | with open('top10000words.txt', 'r') as f:
allwords = f.readlines()
fiveletterwords = []
for word in allwords:
if len(list(word)) == 6:
fiveletterwords.append(word.lower())
with open('5lettertop10k.txt', 'w') as g:
g.writelines(fiveletterwords) |
#
# @lc app=leetcode.cn id=151 lang=python3
#
# [151] reverse-words-in-a-string
#
None
# @lc code=end | None |
# ------------------------------
# 277. Find the Celebrity
#
# Description:
# Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there
# may exist one celebrity. The definition of a celebrity is that all the other n - 1 people
# know him/her but he/she does not know any of them.
#
# ... | class Solution(object):
def find_celebrity(self, n):
"""
:type n: int
:rtype: int
"""
candidate = 0
for i in range(1, n):
if knows(candidate, i):
candidate = i
for i in range(n):
if i != candidate and (not knows(i, cand... |
# calc the spawn in a factorial way would be nice in erlang or elixir...
def count_fishes(input, days):
vals = list(map(int, input.split(',')))
# Only need to calc for each unique
unique_ages = list(set(vals))
result = 0
for unique_age in unique_ages:
spawn = _calc_spawn([unique_age], d... | def count_fishes(input, days):
vals = list(map(int, input.split(',')))
unique_ages = list(set(vals))
result = 0
for unique_age in unique_ages:
spawn = _calc_spawn([unique_age], days)
result += spawn * vals.count(unique_age)
return result
def _calc_spawn(fishes, days_left):
if da... |
def format(discrepancies, margins = None):
if discrepancies == {}:
return "No Discrepancies Found"
inequal_messages = ""
missing_physical_message = ""
missing_digital_message = ""
valid_discrepancies = 0
for item, entry in discrepancies.items():
valid_discrepancies += 1
if entry["digital"] == None:
if en... | def format(discrepancies, margins=None):
if discrepancies == {}:
return 'No Discrepancies Found'
inequal_messages = ''
missing_physical_message = ''
missing_digital_message = ''
valid_discrepancies = 0
for (item, entry) in discrepancies.items():
valid_discrepancies += 1
i... |
'''
Simple hello world python modules.
'''
__name__ = "greetworld"
__version__ = 0.4
__author__ = 'Rajendra Kumar R Yadav'
__doc__ = '''
A simple Greet World module in Python
'''
| """
Simple hello world python modules.
"""
__name__ = 'greetworld'
__version__ = 0.4
__author__ = 'Rajendra Kumar R Yadav'
__doc__ = '\nA simple Greet World module in Python\n' |
class LRUCache(object):
def __init__(self, size):
self.size = size
self.cache = {}
self.priorities = []
def adjust(self, key):
item_index = self.priorities.index(key)
self.priorities[:] = self.priorities[:item_index] + self.priorities[item_index+1:]
self.priorit... | class Lrucache(object):
def __init__(self, size):
self.size = size
self.cache = {}
self.priorities = []
def adjust(self, key):
item_index = self.priorities.index(key)
self.priorities[:] = self.priorities[:item_index] + self.priorities[item_index + 1:]
self.prior... |
def rounded_box_fn_icon(node):
return {
"shape": "box",
"style": "rounded",
}
def rounded_box_metric_icon(node):
return {
"shape": "box",
"style": "rounded",
}
def square_box_database_icon(node):
return {
"shape": "box",
}
def square_box_json_icon(no... | def rounded_box_fn_icon(node):
return {'shape': 'box', 'style': 'rounded'}
def rounded_box_metric_icon(node):
return {'shape': 'box', 'style': 'rounded'}
def square_box_database_icon(node):
return {'shape': 'box'}
def square_box_json_icon(node):
return {'shape': 'box'}
def square_box_highlight(node)... |
#
# Simple Hello World Program
#
print("Hello Python")
print('Hello World') | print('Hello Python')
print('Hello World') |
class Solution:
def findShortestSubArray(self, nums: List[int]) -> int:
max_cnt = 0
for num in set(nums):
cur_cnt = nums.count(num)
if cur_cnt > max_cnt:
max_cnt=cur_cnt
max_num = [num]
elif cur_cnt == max_cnt:
max_n... | class Solution:
def find_shortest_sub_array(self, nums: List[int]) -> int:
max_cnt = 0
for num in set(nums):
cur_cnt = nums.count(num)
if cur_cnt > max_cnt:
max_cnt = cur_cnt
max_num = [num]
elif cur_cnt == max_cnt:
... |
expected_output = {
"primary_load_time_percent":0,
"secondary_load_time_percent":0,
"one_minute_load_percent":1,
"five_minute_load_percent":1,
"ntp_time":"14:48:32.688 UTC Tue Mar 22 2022",
"smart_licensing_status":{
"export_authorization_key":{
"features_authorized":... | expected_output = {'primary_load_time_percent': 0, 'secondary_load_time_percent': 0, 'one_minute_load_percent': 1, 'five_minute_load_percent': 1, 'ntp_time': '14:48:32.688 UTC Tue Mar 22 2022', 'smart_licensing_status': {'export_authorization_key': {'features_authorized': 'none'}, 'utility': {'status': 'DISABLED'}, 'sm... |
# coding: utf-8
#
atx_agent_version = "" # set from command line
| atx_agent_version = '' |
#!/usr/bin/python
#coding=utf-8
'''
@author: sheng
@contact: sinotradition@gmail.com
@copyright: License according to the project license.
'''
__all__ = ['wu3', 'wei4', 'yin2', 'shen1', 'hai4', 'you3', 'xu1', 'mao3', 'chen2', 'zi3', 'si4', 'chou3'] | """
@author: sheng
@contact: sinotradition@gmail.com
@copyright: License according to the project license.
"""
__all__ = ['wu3', 'wei4', 'yin2', 'shen1', 'hai4', 'you3', 'xu1', 'mao3', 'chen2', 'zi3', 'si4', 'chou3'] |
def CheckPossibility(num):
digits = [int(d) for d in str(num)]
lastDigit = 0
hasConsecutive = False
for i in digits:
if(lastDigit > i):
return False
if(lastDigit == i):
hasConsecutive = True
lastDigit = i
else:
if(hasConsecutive == F... | def check_possibility(num):
digits = [int(d) for d in str(num)]
last_digit = 0
has_consecutive = False
for i in digits:
if lastDigit > i:
return False
if lastDigit == i:
has_consecutive = True
last_digit = i
else:
if hasConsecutive == False:
... |
def spotRsiExceed(current_rsi):
if current_rsi > 70:
# The market may be overbought, it may become bearish
return -1
elif current_rsi < 30:
# the market may be ouversold, it may become bullish
return 1
return 0
| def spot_rsi_exceed(current_rsi):
if current_rsi > 70:
return -1
elif current_rsi < 30:
return 1
return 0 |
class InsertError(RuntimeError):
def __init__(self, operation, cause):
self.operation = operation
self.cause = cause
| class Inserterror(RuntimeError):
def __init__(self, operation, cause):
self.operation = operation
self.cause = cause |
with open('input.txt', 'r') as f:
s = f.readline()
n,m = [int(x) for x in s.split()]
out = []
if n > m:
while n + m:
if n:
out.append("B")
n -= 1
if m:
out.append("G")
m -= 1
else:
while n + m:
... | with open('input.txt', 'r') as f:
s = f.readline()
(n, m) = [int(x) for x in s.split()]
out = []
if n > m:
while n + m:
if n:
out.append('B')
n -= 1
if m:
out.append('G')
m -= 1
else:
while n + m:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.