content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class APIError(Exception):
"""Error raised for non-200 API return codes
Args:
status_code(int): HTTP status code returned by the API
message(str): Potential error message returned by the API
Attributes:
status_code(int): HTTP status code returned by the API
message(str)... | class Apierror(Exception):
"""Error raised for non-200 API return codes
Args:
status_code(int): HTTP status code returned by the API
message(str): Potential error message returned by the API
Attributes:
status_code(int): HTTP status code returned by the API
message(str)... |
size=int(input("enter size="))
numbers=[]
for i in range(1,size+1):
a=int(input("enter a="))
numbers.append(a)
count=numbers.count(4)
print(numbers)
print("numbers of 4s in list=",count)
| size = int(input('enter size='))
numbers = []
for i in range(1, size + 1):
a = int(input('enter a='))
numbers.append(a)
count = numbers.count(4)
print(numbers)
print('numbers of 4s in list=', count) |
"""Constants for the Kuler Sky integration."""
DOMAIN = "kulersky"
DATA_ADDRESSES = "addresses"
DATA_DISCOVERY_SUBSCRIPTION = "discovery_subscription"
| """Constants for the Kuler Sky integration."""
domain = 'kulersky'
data_addresses = 'addresses'
data_discovery_subscription = 'discovery_subscription' |
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
# Author: illuz <iilluzen[at]gmail.com>
# File: AC_mod_1.py
# Create Date: 2015-08-17 00:44:30
# Usage: AC_mod_1.py
# Descripton:
class Solution:
# @param {integer} num
# @return {integer}
def addDigits(self, num):
return num % 9... | class Solution:
def add_digits(self, num):
return num % 9 or (num and 9) |
"""
Set of Nagios probes for testing LFC grid service.
Contains the following Nagios probe:
LFC-probe.
- The probes can run in active and/or passives modes (in Nagios sense).
Publication of passive test results from inside of probes can be done
via Nagios command file or NSCA.
- On worker nodes Nagios is used as ... | """
Set of Nagios probes for testing LFC grid service.
Contains the following Nagios probe:
LFC-probe.
- The probes can run in active and/or passives modes (in Nagios sense).
Publication of passive test results from inside of probes can be done
via Nagios command file or NSCA.
- On worker nodes Nagios is used as ... |
class Obj:
def __init__(self, filename, swapyz=True, flipy=True):
"""Loads a Wavefront OBJ file. """
self.vertices = []
self.normals = []
self.texcoords = []
self.faces = []
self.plain_vertecies = []
self.plain_normals = []
self.plain_texcoords = []
... | class Obj:
def __init__(self, filename, swapyz=True, flipy=True):
"""Loads a Wavefront OBJ file. """
self.vertices = []
self.normals = []
self.texcoords = []
self.faces = []
self.plain_vertecies = []
self.plain_normals = []
self.plain_texcoords = []
... |
# An object that will hold the type of current input with its respective value
class Token:
# type_ -> a type of token (from the list in constants)
# value -> the actual value
# pos_start -> Position of start of token (optional)
# pos_end -> Position of end of token (optional)
def __init__(self, typ... | class Token:
def __init__(self, type_, value=None, pos_start=None, pos_end=None):
self.type = type_
self.value = value
if pos_start:
self.pos_start = pos_start.copy()
self.pos_end = pos_start.copy()
self.pos_end.advance()
if pos_end:
s... |
class Student:
# class initialization method
def __init__(self, name, birthday, courses):
# class public attributes
self.full_name = name
self.first_name = name.split(' ')[0]
self.birthday = birthday
self.courses = courses
self.attendance = []
# class public ... | class Student:
def __init__(self, name, birthday, courses):
self.full_name = name
self.first_name = name.split(' ')[0]
self.birthday = birthday
self.courses = courses
self.attendance = []
def is_colleague(self, other):
course_intersection = self.courses.intersec... |
class Schedule():
r"""Base class for all schedules.
Your schedules should also subclass this class.
"""
def __init__(self):
pass
def reset(self):
r"""Resets the schedule."""
raise NotImplementedError
def update(self):
r"""Updates the schedule."""
ra... | class Schedule:
"""Base class for all schedules.
Your schedules should also subclass this class.
"""
def __init__(self):
pass
def reset(self):
"""Resets the schedule."""
raise NotImplementedError
def update(self):
"""Updates the schedule."""
raise ... |
PV = int(input('Primeiro valor:'))
SV = int(input('Segundo valor:'))
TV = int(input('Terceiro valor:'))
menor = PV
if SV < PV and SV < TV:
menor = SV
if TV < PV and TV < SV:
menor = TV
maior = PV
if SV > PV and SV > TV:
maior = SV
if TV > PV and TV > SV:
maior = TV
print(f'O menor valor digitado foi {m... | pv = int(input('Primeiro valor:'))
sv = int(input('Segundo valor:'))
tv = int(input('Terceiro valor:'))
menor = PV
if SV < PV and SV < TV:
menor = SV
if TV < PV and TV < SV:
menor = TV
maior = PV
if SV > PV and SV > TV:
maior = SV
if TV > PV and TV > SV:
maior = TV
print(f'O menor valor digitado foi {me... |
a=int(input("Enter a number "))
while(a>0):
print(a)
a=a-1
| a = int(input('Enter a number '))
while a > 0:
print(a)
a = a - 1 |
conf_file = open("./online_exam_bot.config","r")
lines = conf_file.readlines()
data = []
conf = {}
i = 0
for line in lines:
if i <= 10:
extracted = line.split("'")
data.append(extracted)
if i != 5:
conf[data[i][1]] = data[i][3]
else:
pass
i += 1
| conf_file = open('./online_exam_bot.config', 'r')
lines = conf_file.readlines()
data = []
conf = {}
i = 0
for line in lines:
if i <= 10:
extracted = line.split("'")
data.append(extracted)
if i != 5:
conf[data[i][1]] = data[i][3]
else:
pass
i += 1 |
def CloseGump(serial: int):
"""
Close a specified gump serial
:param serial: An entity serial such as 0xf00ff00f.
"""
pass
def ConfirmPrompt(str9: str, bool4: bool):
"""
Displays an ingame prompt with the specified message, returns True if Okay was pressed, False if not.
:param str9: ... | def close_gump(serial: int):
"""
Close a specified gump serial
:param serial: An entity serial such as 0xf00ff00f.
"""
pass
def confirm_prompt(str9: str, bool4: bool):
"""
Displays an ingame prompt with the specified message, returns True if Okay was pressed, False if not.
:param str9:... |
def encryptRailFence(text, key):
rail = [['\n' for i in range(len(text))]
for j in range(key)]
dir_down = False
row, col = 0, 0
for i in range(len(text)):
if (row == 0) or (row == key - 1):
dir_down = not dir_down
rail[row][col] = text[i]
c... | def encrypt_rail_fence(text, key):
rail = [['\n' for i in range(len(text))] for j in range(key)]
dir_down = False
(row, col) = (0, 0)
for i in range(len(text)):
if row == 0 or row == key - 1:
dir_down = not dir_down
rail[row][col] = text[i]
col += 1
if dir_dow... |
def func():
print("Hello")
def func2():
print("world")
l = [1,2,3,func, lambda x: x+1]
print(l)
print(l[3]())
print(l[4](2))
l2 = [func, func2]
for i in l2:
i() | def func():
print('Hello')
def func2():
print('world')
l = [1, 2, 3, func, lambda x: x + 1]
print(l)
print(l[3]())
print(l[4](2))
l2 = [func, func2]
for i in l2:
i() |
# see http://python4astronomers.github.com/contest/bounce.html
figure(1)
clf()
axis([-10, 10, -10, 10])
# Define properties of the "bouncing balls"
n = 10
pos = (20 * random_sample(n*2) - 10).reshape(n, 2)
vel = (0.3 * normal(size=n*2)).reshape(n, 2)
sizes = 100 * random_sample(n) + 100
# Colors where each row is (Re... | figure(1)
clf()
axis([-10, 10, -10, 10])
n = 10
pos = (20 * random_sample(n * 2) - 10).reshape(n, 2)
vel = (0.3 * normal(size=n * 2)).reshape(n, 2)
sizes = 100 * random_sample(n) + 100
colors = random_sample([n, 4])
circles = scatter(pos[:, 0], pos[:, 1], marker='o', s=sizes, c=colors)
grav = -0.1 * ones(20).reshape(n,... |
# Employee class
class Employee:
"""A sample employee class"""
raise_amt = 1.05
def __init__(self, first, last, pay):
"""Initialize employee class"""
self.first = first
self.last = last
self.pay = pay
#@property
def email(self):
"""Return employee emai... | class Employee:
"""A sample employee class"""
raise_amt = 1.05
def __init__(self, first, last, pay):
"""Initialize employee class"""
self.first = first
self.last = last
self.pay = pay
def email(self):
"""Return employee email address"""
return '{}.{}@com... |
#
# PySNMP MIB module TIARA-NETWORKS-CONFIG-MGMT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIARA-NETWORKS-CONFIG-MGMT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:16:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, constraints_intersection, single_value_constraint, value_range_constraint) ... |
# -*- coding: utf-8 -*-
# 16/12/15
# create by: snower
FORMATER = "watoee.formaters.formater.Formater"
SERIALIZE = "watoee.serializes.jsonserialize.JsonSerialize" | formater = 'watoee.formaters.formater.Formater'
serialize = 'watoee.serializes.jsonserialize.JsonSerialize' |
"""
Good morning! Here's your coding interview problem for today.
This problem was asked by Uber.
Given a binary tree and an integer k, return whether there exists a root-to-leaf path that sums up to k.
For example, given k = 18 and the following binary tree:
8
/ \
4 13
/ \ \
2 6 19
Return True s... | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Uber.
Given a binary tree and an integer k, return whether there exists a root-to-leaf path that sums up to k.
For example, given k = 18 and the following binary tree:
8
/ 4 13
/ \\ 2 6 19
Return True sinc... |
def deci_func_logger(_func=None, *, name: str = 'abstract_decorator'):
"""
This decorator is used to wrap our functions with logs.
It will log every enter and exit of the functon with the equivalent parameters as extras.
It will also log exceptions that raises in the function.
It will also log the e... | def deci_func_logger(_func=None, *, name: str='abstract_decorator'):
"""
This decorator is used to wrap our functions with logs.
It will log every enter and exit of the functon with the equivalent parameters as extras.
It will also log exceptions that raises in the function.
It will also log the exc... |
#-----------------------------------------------------------------------------
# Copyright (c) 2005-2017, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this s... | def pre_safe_import_module(api):
api.add_runtime_module(api.module_name) |
#Get the number at a specified row and column in Pascal's triangle
def getNumber(row, column):
if (column == 0) or (row == 0) or (column == row):
return 1
else:
return getNumber(row - 1, column - 1) + getNumber(row - 1, column)
if __name__ == "__main__":
row = int(input())
col = int(i... | def get_number(row, column):
if column == 0 or row == 0 or column == row:
return 1
else:
return get_number(row - 1, column - 1) + get_number(row - 1, column)
if __name__ == '__main__':
row = int(input())
col = int(input())
print(get_number(row, col)) |
class Today:
def __init__(self, cases, deaths, recoveries):
self.cases = cases
self.deaths = deaths
self.recoveries = recoveries
class PerMillion:
def __init__(self, cases, deaths, tests, active, recoveries, critical):
self.cases = cases
self.deaths = deaths
sel... | class Today:
def __init__(self, cases, deaths, recoveries):
self.cases = cases
self.deaths = deaths
self.recoveries = recoveries
class Permillion:
def __init__(self, cases, deaths, tests, active, recoveries, critical):
self.cases = cases
self.deaths = deaths
se... |
CHARMAP = [bytes([x]) for x in b'BCDFGHJKMPQRTVWXY2346789']
def b24encode(data):
enc = b''
for c in data:
enc += CHARMAP[c >> 4]
enc += CHARMAP[-(c & 0x0f) - 1]
return enc
def b24decode(data):
dec = b''
hi = -1
for c in data:
if hi < 0:
hi = CH... | charmap = [bytes([x]) for x in b'BCDFGHJKMPQRTVWXY2346789']
def b24encode(data):
enc = b''
for c in data:
enc += CHARMAP[c >> 4]
enc += CHARMAP[-(c & 15) - 1]
return enc
def b24decode(data):
dec = b''
hi = -1
for c in data:
if hi < 0:
hi = CHARMAP.index(byte... |
amd = [
{
"Codename": "Tahiti",
"IDs": [
{ "Vendor": "0x1002", "Device": "0x6780" },
{ "Vendor": "0x1002", "Device": "0x6784" },
{ "Vendor": "0x1002", "Device": "0x6788" },
{ "Vendor": "0x1002", "Device": "0x678a" },
{ "Vendor": "0x1002", "Device": "0x6790" },
{ "Vendor": "... | amd = [{'Codename': 'Tahiti', 'IDs': [{'Vendor': '0x1002', 'Device': '0x6780'}, {'Vendor': '0x1002', 'Device': '0x6784'}, {'Vendor': '0x1002', 'Device': '0x6788'}, {'Vendor': '0x1002', 'Device': '0x678a'}, {'Vendor': '0x1002', 'Device': '0x6790'}, {'Vendor': '0x1002', 'Device': '0x6791'}, {'Vendor': '0x1002', 'Device':... |
# %%
#######################################
def scapypayload_joinall(packet_list: scapy.plist.PacketList):
allpayloads_onestring = b''.join([ p.load for p in packet_list if p.haslayer(Raw) ])
return allpayloads_onestring
| def scapypayload_joinall(packet_list: scapy.plist.PacketList):
allpayloads_onestring = b''.join([p.load for p in packet_list if p.haslayer(Raw)])
return allpayloads_onestring |
class tile:
def __init__(self) -> None:
self.owner = None
self.population = None
class board:
def __init__(self,size) -> None:
self.size = size
class game:
def __init__(self,players) -> None:
self.players = players
self.playercount = len(players)
def newGame(se... | class Tile:
def __init__(self) -> None:
self.owner = None
self.population = None
class Board:
def __init__(self, size) -> None:
self.size = size
class Game:
def __init__(self, players) -> None:
self.players = players
self.playercount = len(players)
def new_g... |
arr1 = [-12, 11, -13, -5, 6, -7, 5, -3, -6]
arr2 = [1, 2, -4, -5, 2, -7, 3, 2, -6, -8, -9, 3, 2, 1]
def moveNegativeInt(arr):
for i in arr:
if i < 0:
temp = i
arr.remove(i)
arr.insert(0, temp)
return arr
print(moveNegativeInt(arr1))
print(moveNegativeInt(arr2))
| arr1 = [-12, 11, -13, -5, 6, -7, 5, -3, -6]
arr2 = [1, 2, -4, -5, 2, -7, 3, 2, -6, -8, -9, 3, 2, 1]
def move_negative_int(arr):
for i in arr:
if i < 0:
temp = i
arr.remove(i)
arr.insert(0, temp)
return arr
print(move_negative_int(arr1))
print(move_negative_int(arr2)) |
s = input()
l = len(s)
r = 'AWH'
# just repeat Os bc valid, ignore other rules
print(r + 'O' * l)
| s = input()
l = len(s)
r = 'AWH'
print(r + 'O' * l) |
WOQL_CONCAT_JSON = {
"@type": "Concatenate",
"list": {"@type" : "DataValue",
"list" : [
{"@type": "DataValue", "variable": "Duration"},
{
"@type": "DataValue",
"data": {"@type": "xsd:string", "@value": " yo "},
... | woql_concat_json = {'@type': 'Concatenate', 'list': {'@type': 'DataValue', 'list': [{'@type': 'DataValue', 'variable': 'Duration'}, {'@type': 'DataValue', 'data': {'@type': 'xsd:string', '@value': ' yo '}}, {'@type': 'DataValue', 'variable': 'Duration_Cast'}]}, 'result': {'@type': 'DataValue', 'variable': 'x'}} |
class GeneralizationSet:
name = ""
id = ""
attributes = []
def __init__(self, name, gs_id, attributes):
self.name = name
self.id = gs_id
self.attributes = attributes
def __str__(self):
return f'id:{self.id} name: {self.name} attributes: {self.attributes}'
| class Generalizationset:
name = ''
id = ''
attributes = []
def __init__(self, name, gs_id, attributes):
self.name = name
self.id = gs_id
self.attributes = attributes
def __str__(self):
return f'id:{self.id} name: {self.name} attributes: {self.attributes}' |
"""igcommit - The main module
Copyright (c) 2021 InnoGames GmbH
Portions Copyright (c) 2021 Emre Hasegeli
"""
VERSION = (3, 1)
| """igcommit - The main module
Copyright (c) 2021 InnoGames GmbH
Portions Copyright (c) 2021 Emre Hasegeli
"""
version = (3, 1) |
#
# @lc app=leetcode id=32 lang=python3
#
# [32] Longest Valid Parentheses
#
# @lc code=start
class Solution:
def longestValidParentheses(self, s: str) -> int:
max_length = 0
left_count = right_count = 0
for i in range(len(s)): # left to right scan
if s[i] == '(':
... | class Solution:
def longest_valid_parentheses(self, s: str) -> int:
max_length = 0
left_count = right_count = 0
for i in range(len(s)):
if s[i] == '(':
left_count += 1
elif s[i] == ')':
right_count += 1
if left_count == rig... |
# 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 sumNumbers(self, root: TreeNode) -> int:
if root == None:
return 0
else:
... | class Solution:
def sum_numbers(self, root: TreeNode) -> int:
if root == None:
return 0
else:
return sum([int(i) for i in self.travelTree(root)])
def travel_tree(self, root):
if root.left == None and root.right == None:
return [str(root.val)]
... |
###########################################################################
#
# Copyright 2017 Google 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
#
# https://www.apache.org/... | dcm__field__lookup = {'Video_Unmutes': 'INTEGER', 'Zip_Postal_Code': 'INTEGER', 'Path_Length': 'INTEGER', 'Billable_Impressions': 'FLOAT', 'Active_View_Of_Completed_Impressions_Audible_And_Visible': 'FLOAT', 'Measurable_Impressions_For_Audio': 'INTEGER', 'Average_Interaction_Time': 'FLOAT', 'Invalid_Impressions': 'FLOA... |
# Problem 1: Two Sum
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
# Given an array of integers, return indices of the two numbers such that they add up to a specific target.
# You ... | class Solution(object):
def two_sum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
total = 0
for x in range(0, len(nums)):
total = 0
for y in range(0, len(nums)):
if x != y:
... |
a = 1.123456
b = 10
c = -30
d = 34
e = 123.456
f = 19892122
# form 0
s = "b=%i" % b
print(s)
# form 1
s = "b,c,d=%i+%i+%i" % (b,c,d)
print(s)
# form 2
s = "b=%(b)i and c=%(c)i and d=%(d)i" % { 'b':b,'c':c,'d':d }
print(s)
# width,flags
s = "e=%020i e=%+i e=%20i e=%-20i (e=%- 20i)" % (e,e,e,e,e)
print(s)
| a = 1.123456
b = 10
c = -30
d = 34
e = 123.456
f = 19892122
s = 'b=%i' % b
print(s)
s = 'b,c,d=%i+%i+%i' % (b, c, d)
print(s)
s = 'b=%(b)i and c=%(c)i and d=%(d)i' % {'b': b, 'c': c, 'd': d}
print(s)
s = 'e=%020i e=%+i e=%20i e=%-20i (e=%- 20i)' % (e, e, e, e, e)
print(s) |
registry = []
def register(cls, bench_type=None, bench_params=None):
registry.append((cls, bench_type, bench_params))
return cls
| registry = []
def register(cls, bench_type=None, bench_params=None):
registry.append((cls, bench_type, bench_params))
return cls |
__author__ = "Bilal El Uneis and Jieshu Wang"
__since__ = "Nov 2018"
__email__ = "bilaleluneis@gmail.com"
"""
Meta Classes are the blue print for classes just like classes are blue print for types instantiated from them.
they allow to set class capabilities.
bellow is example:
Meta Class To prevent inheritance of Clas... | __author__ = 'Bilal El Uneis and Jieshu Wang'
__since__ = 'Nov 2018'
__email__ = 'bilaleluneis@gmail.com'
'\nMeta Classes are the blue print for classes just like classes are blue print for types instantiated from them.\nthey allow to set class capabilities.\nbellow is example:\nMeta Class To prevent inheritance of Cla... |
#
# PySNMP MIB module ASCEND-MIBUDS3NET-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBUDS3NET-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:12:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration')
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union,... |
vermelho = '\033[31m'
verde = '\033[32m'
azul = '\033[34m'
#-----------------------------
ciano = '\033[36m'
magenta = '\033[35m'
amarelo = '\033[33m'
preto = '\033[30m'
branco = '\033[37m'
#-----------------------------
original = '\033[0;0m'
negrito = '\033[1m'
reverso = '\033[2m'
#-----------------------------
fu... | vermelho = '\x1b[31m'
verde = '\x1b[32m'
azul = '\x1b[34m'
ciano = '\x1b[36m'
magenta = '\x1b[35m'
amarelo = '\x1b[33m'
preto = '\x1b[30m'
branco = '\x1b[37m'
original = '\x1b[0;0m'
negrito = '\x1b[1m'
reverso = '\x1b[2m'
fundo_preto = '\x1b[40m'
fundo_vermelho = '\x1b[41m'
fundo_verde = '\x1b[42m'
fundo_amarelo = '\x1... |
class AppCredentials(object):
def __init__(self, client_id, client_secret, redirect_uri):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
| class Appcredentials(object):
def __init__(self, client_id, client_secret, redirect_uri):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri |
s=str(input())
n1,n2=[int(e) for e in input().split()]
count=0
count2=1
for i in range(n1):
print(s[i],end="")
for i in range(n2-n1+1):
print(s[n2-count],end="")
count+=1
for i in range(len(s)-n2-1):
print(s[n2+count2],end="")
count2+=1
| s = str(input())
(n1, n2) = [int(e) for e in input().split()]
count = 0
count2 = 1
for i in range(n1):
print(s[i], end='')
for i in range(n2 - n1 + 1):
print(s[n2 - count], end='')
count += 1
for i in range(len(s) - n2 - 1):
print(s[n2 + count2], end='')
count2 += 1 |
# 28. Implement strStr()
class Solution(object):
# brute-force 1
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
lh , ln = len(haystack), len(needle)
if ln == 0: return 0
for i in range(lh - ln + 1):
... | class Solution(object):
def str_str(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
(lh, ln) = (len(haystack), len(needle))
if ln == 0:
return 0
for i in range(lh - ln + 1):
j = 0
... |
#
# PySNMP MIB module DLGHWINF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DLGHWINF-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:47:46 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,... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_intersection, single_value_constraint, constraints_union) ... |
class Pricing(object):
def __init__(self, location, event):
self.location = location
self.event = event
def setlocation(self, location):
self.location = location
def getprice(self):
return self.location.getprice()
def getquantity(self):
return self.location.getqua... | class Pricing(object):
def __init__(self, location, event):
self.location = location
self.event = event
def setlocation(self, location):
self.location = location
def getprice(self):
return self.location.getprice()
def getquantity(self):
return self.location.ge... |
class Solution(object):
def sub_two(self, a, b):
if a is None or b is None:
raise TypeError('a or b cannot be None')
result = a ^ b
borrow = (~a & b) << 1
if borrow != 0:
return self.sub_two(result, borrow)
return result | class Solution(object):
def sub_two(self, a, b):
if a is None or b is None:
raise type_error('a or b cannot be None')
result = a ^ b
borrow = (~a & b) << 1
if borrow != 0:
return self.sub_two(result, borrow)
return result |
class Plan():
"""
This is a class for the plans.
"""
def __init__(self, name, price, limit):
"""
The constructor for the Subscription class.
Parameters:
name (str): The plan name.
price (int): The plan price.
limit (int): Allowed nuber of websi... | class Plan:
"""
This is a class for the plans.
"""
def __init__(self, name, price, limit):
"""
The constructor for the Subscription class.
Parameters:
name (str): The plan name.
price (int): The plan price.
limit (int): Allowed nuber of website... |
# write a function that accepts a name as input and
# prints out "Hello {name}!"
def greeting(name):
print("Hello " + name + "!")
greeting("Alfred") | def greeting(name):
print('Hello ' + name + '!')
greeting('Alfred') |
class MetaGetter:
def __init__(self, context):
self.__context = context
def render_width_px(self):
original_width = self.__context.scene.render.resolution_x
return int(original_width * self.__render_size_fraction())
def render_height_px(self):
original_height = self.__context.scene.render.resolution_y
r... | class Metagetter:
def __init__(self, context):
self.__context = context
def render_width_px(self):
original_width = self.__context.scene.render.resolution_x
return int(original_width * self.__render_size_fraction())
def render_height_px(self):
original_height = self.__cont... |
# 024 - Write a Python program to test whether a passed letter is a vowel or not.
def vowelLetter(pLetter):
return pLetter.upper() in 'AEIOU'
print(vowelLetter('A'))
print(vowelLetter('B')) | def vowel_letter(pLetter):
return pLetter.upper() in 'AEIOU'
print(vowel_letter('A'))
print(vowel_letter('B')) |
class IntervalStats:
def __init__(self) -> None:
self.interval_duration = 0.0
self.rtt_ratio = 0.0
self.marked_lost_bytes = 0
self.loss_rate = 0
self.actual_sending_rate_mbps = 0
self.ack_rate_mbps = 0
self.avg_rtt = 0.0
self.rtt_dev = 0.0
sel... | class Intervalstats:
def __init__(self) -> None:
self.interval_duration = 0.0
self.rtt_ratio = 0.0
self.marked_lost_bytes = 0
self.loss_rate = 0
self.actual_sending_rate_mbps = 0
self.ack_rate_mbps = 0
self.avg_rtt = 0.0
self.rtt_dev = 0.0
sel... |
# Python3 Total Ways to arrange coins {1, 3, 5} to Sum Upto N
# Using Recursion
def Arrangement(N):
if N < 0:
return 0
if N == 0:
return 1
return Arrangement(N-1) + Arrangement(N-3) + Arrangement(N-5)
# Using DP
dp = [None for _ in range(10001)]
def Arrangement_DP(n):
if n < 0:
return 0
if n == 0:
retur... | def arrangement(N):
if N < 0:
return 0
if N == 0:
return 1
return arrangement(N - 1) + arrangement(N - 3) + arrangement(N - 5)
dp = [None for _ in range(10001)]
def arrangement_dp(n):
if n < 0:
return 0
if n == 0:
return 1
if dp[n]:
return dp[n]
dp[n]... |
def ex2():
rs = np.random.RandomState(112)
x=np.linspace(0,10,11)
y=np.linspace(0,10,11)
X,Y = np.meshgrid(x,y)
X=X.flatten()
Y=Y.flatten()
weights=np.random.random(len(X))
plt.hist2d(X,Y,weights=weights); #The semicolon here avoids that Jupyter shows the resulting arrays
| def ex2():
rs = np.random.RandomState(112)
x = np.linspace(0, 10, 11)
y = np.linspace(0, 10, 11)
(x, y) = np.meshgrid(x, y)
x = X.flatten()
y = Y.flatten()
weights = np.random.random(len(X))
plt.hist2d(X, Y, weights=weights) |
"""Module with util funcs for testing."""
def assert_raises(exception, func, *args, **kwargs) -> None:
"""Check whether calling func(*args, **kwargs) raises exeption.
Parameters
----------
exception : Exception
Exception type.
func : callable
Method to be run.
"""
try:... | """Module with util funcs for testing."""
def assert_raises(exception, func, *args, **kwargs) -> None:
"""Check whether calling func(*args, **kwargs) raises exeption.
Parameters
----------
exception : Exception
Exception type.
func : callable
Method to be run.
"""
try:
... |
def change_data(x):
if x < 0 or x >255:
return None
elif 200 <= x <=255:
return int(round((x - 200) * 3 / 11.0 + 85, 0))
elif 0 <= x <=130:
return int(round(x * 6 / 13.0, 0))
else:
return int(round((x - 131) * 23 / 68.0 + 61, 0))
if __name__ == '__main__':
print('-1... | def change_data(x):
if x < 0 or x > 255:
return None
elif 200 <= x <= 255:
return int(round((x - 200) * 3 / 11.0 + 85, 0))
elif 0 <= x <= 130:
return int(round(x * 6 / 13.0, 0))
else:
return int(round((x - 131) * 23 / 68.0 + 61, 0))
if __name__ == '__main__':
print('-... |
n, x = map(int, input().split())
s = str(input())
for e in s:
if e == "o":
x += 1
else:
x -= 1
if x < 0:
x = 0
print(x)
| (n, x) = map(int, input().split())
s = str(input())
for e in s:
if e == 'o':
x += 1
else:
x -= 1
if x < 0:
x = 0
print(x) |
cont = soma = 0
while True:
nota = float(input())
if nota < 0 or nota > 10:
print('nota invalida')
else:
soma += nota
cont += 1
if cont == 2:
break
print('media = {}'.format(soma / cont)) | cont = soma = 0
while True:
nota = float(input())
if nota < 0 or nota > 10:
print('nota invalida')
else:
soma += nota
cont += 1
if cont == 2:
break
print('media = {}'.format(soma / cont)) |
template = """
/****************************************************************************
* ${name}.sv
****************************************************************************/
module ${name}(
${ports}
);
${wires}
${port_wire_assignments}
${interconnects}
endmodule
"""
| template = '\n/****************************************************************************\n * ${name}.sv\n ****************************************************************************/\nmodule ${name}(\n${ports}\n);\n\n${wires}\n\n${port_wire_assignments}\n\n${interconnects}\n\nendmodule\n' |
src = Split('''
awss.c
enrollee.c
sha256.c
zconfig_utils.c
zconfig_ieee80211.c
wifimgr.c
ywss_utils.c
zconfig_ut_test.c
registrar.c
zconfig_protocol.c
zconfig_vendor_common.c
''')
component = aos_component('ywss', src)
component.add_macros('DEBUG')
... | src = split('\n awss.c \n enrollee.c \n sha256.c \n zconfig_utils.c \n zconfig_ieee80211.c \n wifimgr.c \n ywss_utils.c\n zconfig_ut_test.c \n registrar.c \n zconfig_protocol.c \n zconfig_vendor_common.c\n')
component = aos_component('ywss', src)
component.add_macros('DEBUG')
component.... |
class Settings:
base_url = "https://compass.scouts.org.uk"
date_format = "%d %B %Y" # dd Month YYYY
org_number = 10000001
total_requests = 0
wcf_json_endpoint = "/JSon.svc" # Windows communication foundation JSON service endpoint
web_service_path = base_url + wcf_json_endpoint
| class Settings:
base_url = 'https://compass.scouts.org.uk'
date_format = '%d %B %Y'
org_number = 10000001
total_requests = 0
wcf_json_endpoint = '/JSon.svc'
web_service_path = base_url + wcf_json_endpoint |
def say_hello():
return "hello"
| def say_hello():
return 'hello' |
def searchRange(nums, target):
start, end = -1, -1
lo, hi = 0, len(nums)-1
while lo <= hi:
mid = (lo+hi)//2
if nums[mid] == target and (mid == 0 or nums[mid-1] != target):
start = mid
break
elif nums[mid] < target:
lo = mid+1
... | def search_range(nums, target):
(start, end) = (-1, -1)
(lo, hi) = (0, len(nums) - 1)
while lo <= hi:
mid = (lo + hi) // 2
if nums[mid] == target and (mid == 0 or nums[mid - 1] != target):
start = mid
break
elif nums[mid] < target:
lo = mid + 1
... |
start,end=input().split()
edges=[("ab",1),("ac",1),("be",3),("cd",1),("de",1),("df",2),("eg",1),("fg",1),("ba",1),("ca",1),("eb",3),("dc",1),("ed",1),("fd",2),("ge",1),("gf",1)]
paths=[(start,0)]
while True:
new_paths=paths
for (path,T) in paths:
for (edge,t) in edges:
if path[-1]==edge[0] a... | (start, end) = input().split()
edges = [('ab', 1), ('ac', 1), ('be', 3), ('cd', 1), ('de', 1), ('df', 2), ('eg', 1), ('fg', 1), ('ba', 1), ('ca', 1), ('eb', 3), ('dc', 1), ('ed', 1), ('fd', 2), ('ge', 1), ('gf', 1)]
paths = [(start, 0)]
while True:
new_paths = paths
for (path, t) in paths:
for (edge, t)... |
# OpenWeatherMap API Key
weather_api_key = "972fc242a771ca44611f48d634a9e967"
# Google API Key
g_key = "AIzaSyCWD-Z7WINc53d-5orJ46Zg3qVZN1UK0ho"
| weather_api_key = '972fc242a771ca44611f48d634a9e967'
g_key = 'AIzaSyCWD-Z7WINc53d-5orJ46Zg3qVZN1UK0ho' |
class ListNode:
def __init__(self,x):
self.val = x
self.next = None
class Solution:
def hasCycle(self,head):
# type head: ListNode
# rtype: bool
fast, slow = head, head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def has_cycle(self, head):
(fast, slow) = (head, head)
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
ret... |
class Solution:
# @param A, a list of integer
# @return an integer
def singleNumber(self, A):
num = A[0]
for number in A[ 1 : ]:
num = num ^ number
return num | class Solution:
def single_number(self, A):
num = A[0]
for number in A[1:]:
num = num ^ number
return num |
def count_3_in_time(n):
# 00:00:00 ~ n:59:59
count = 0
for hrs in range(0, n + 1):
for min in range(0, 60):
for sec in range(0, 60):
if -1 != str(hrs).find('3') or -1 != str(min).find('3') or -1 != str(sec).find('3'):
count += 1
return count
de... | def count_3_in_time(n):
count = 0
for hrs in range(0, n + 1):
for min in range(0, 60):
for sec in range(0, 60):
if -1 != str(hrs).find('3') or -1 != str(min).find('3') or -1 != str(sec).find('3'):
count += 1
return count
def main():
n = int(input(... |
# Given a binary tree, return all root-to-leaf paths.
# Note: A leaf is a node with no children.
# Example:
# Input:
# 1
# / \
# 2 3
# \
# 5
# Output: ["1->2->5", "1->3"]
# Explanation: All root-to-leaf paths are: 1->2->5, 1->3
# Definition for a binary tree node.
# class TreeNode(object):
# def... | class Solution(object):
def binary_tree_paths(self, root):
"""
:type root: TreeNode
:rtype: List[str]
"""
if not root:
return []
(res, stack) = ([], [(root, '')])
while stack:
(node, ans) = stack.pop()
if not node.left and ... |
def last_index(pattern):
wave_list = pattern.wave_list
number_of_elements = len(wave_list)
return number_of_elements
| def last_index(pattern):
wave_list = pattern.wave_list
number_of_elements = len(wave_list)
return number_of_elements |
def code(st, syntax = ""): return f"```{syntax}\n{st}```"
def md(st): return code(st, "md")
def diff(st): return code(st, "diff")
| def code(st, syntax=''):
return f'```{syntax}\n{st}```'
def md(st):
return code(st, 'md')
def diff(st):
return code(st, 'diff') |
class AuthStatusError(Exception):
""" Auth status error
"""
pass
| class Authstatuserror(Exception):
""" Auth status error
"""
pass |
def IDW(Z, b):
"""
Inverse distance weighted interpolation.
Input
Z: a list of lists where each element list contains
four values: X, Y, Value, and Distance to target
point. Z can also be a NumPy 2-D array.
b: power of distance
Output
Estimated value at the target l... | def idw(Z, b):
"""
Inverse distance weighted interpolation.
Input
Z: a list of lists where each element list contains
four values: X, Y, Value, and Distance to target
point. Z can also be a NumPy 2-D array.
b: power of distance
Output
Estimated value at the target l... |
"""
Query
=====
This is the query package.
"""
| """
Query
=====
This is the query package.
""" |
def maxSum(a, b, k, n):
a.sort()
b.sort()
i = 0
j = n - 1
while i < k:
if (a[i] < b[j]):
a[i], b[j] = b[j], a[i]
else:
break
i += 1
j -= 1
sum = 0
for i in range (n):
sum += a[i]
return(sum)
... | def max_sum(a, b, k, n):
a.sort()
b.sort()
i = 0
j = n - 1
while i < k:
if a[i] < b[j]:
(a[i], b[j]) = (b[j], a[i])
else:
break
i += 1
j -= 1
sum = 0
for i in range(n):
sum += a[i]
return sum
tc = int(input())
for i in range... |
def fib(n):
first=0
second=1
overall=0
if n==0:
return 0
elif n==1:
return 1
else:
for i in range(1,n):
overall=second+first
first=second
second=overall
return overall
def productFib(num):
n=1
append_array=[]
while T... | def fib(n):
first = 0
second = 1
overall = 0
if n == 0:
return 0
elif n == 1:
return 1
else:
for i in range(1, n):
overall = second + first
first = second
second = overall
return overall
def product_fib(num):
n = 1
appe... |
number = 600851475143
def isPrime(n):
for i in range(2, n):
if n % i == 0 and i != n:
return False
return True
def LargestPrimeFactor(n):
_n, lpf = n, 0
for i in range(2, n):
if isPrime(i) and n % i == 0:
_n, lpf = _n/i, i
print(i, end=', ')
... | number = 600851475143
def is_prime(n):
for i in range(2, n):
if n % i == 0 and i != n:
return False
return True
def largest_prime_factor(n):
(_n, lpf) = (n, 0)
for i in range(2, n):
if is_prime(i) and n % i == 0:
(_n, lpf) = (_n / i, i)
print(i, end=... |
"""
This file provides all error codes for the program.
"""
ERR_OK = 0
WARN_OK = 0
ERR_MISSING_ARGUMENT = 100
ERR_MISMATCHED_FORMAT = 101
ERR_MISMATCHED_PLATFORM = 102
ERR_UNKNOWN_PLATFORM = 103
ERR_MISMATCHED_ARGUMENT = 104
ERR_UNKNOWN_ARGUMENT = 105
WARN_IMPLICIT_FORMAT = 200
WARN_MODULE_NOT_FOUND = 201
WARN_MOD_... | """
This file provides all error codes for the program.
"""
err_ok = 0
warn_ok = 0
err_missing_argument = 100
err_mismatched_format = 101
err_mismatched_platform = 102
err_unknown_platform = 103
err_mismatched_argument = 104
err_unknown_argument = 105
warn_implicit_format = 200
warn_module_not_found = 201
warn_mod_no... |
# Title : TODO
# Objective : TODO
# Created by: Wenzurk
# Created on: 2018/2/5
# for value in range(1,5):
# print(value)
# for value in range(1,6):
# print(value)
numbers = list(range(1,6))
print(numbers) | numbers = list(range(1, 6))
print(numbers) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : Jinyuan Sun
# @Time : 2022/3/31 6:17 PM
# @File : aa_index.py
# @annotation : define properties of amino acids
ALPHABET = "QWERTYIPASDFGHKLCVNM"
hydrophobic_index = {
'R': -0.9,
'K': -0.889,
'D': -0.767,
'E': -0.696,
'N': -0.... | alphabet = 'QWERTYIPASDFGHKLCVNM'
hydrophobic_index = {'R': -0.9, 'K': -0.889, 'D': -0.767, 'E': -0.696, 'N': -0.674, 'Q': -0.464, 'S': -0.364, 'G': -0.342, 'H': -0.271, 'T': -0.199, 'A': -0.171, 'P': 0.055, 'Y': 0.188, 'V': 0.331, 'M': 0.337, 'C': 0.508, 'L': 0.596, 'F': 0.646, 'I': 0.652, 'W': 0.9}
volume_index = {'G... |
class DefaultTokenizer:
def __init__(self, prefixes, suffixes, infixes, exceptions):
self.prefixes = prefixes
self.suffixes = suffixes
self.infixes = infixes
self.exceptions = exceptions
def __call__(self, text: str):
return text.split(" ")
| class Defaulttokenizer:
def __init__(self, prefixes, suffixes, infixes, exceptions):
self.prefixes = prefixes
self.suffixes = suffixes
self.infixes = infixes
self.exceptions = exceptions
def __call__(self, text: str):
return text.split(' ') |
for i in range(1, 21):
if i % 3 == 0:
print("Fizz")
else:
print(i)
| for i in range(1, 21):
if i % 3 == 0:
print('Fizz')
else:
print(i) |
cutoff = 20
decision_cutoff = .25
model_path = 'ml/overwatch_messages.model'
vectorizer_path = 'ml/overwatch_messages.vectorizer'
| cutoff = 20
decision_cutoff = 0.25
model_path = 'ml/overwatch_messages.model'
vectorizer_path = 'ml/overwatch_messages.vectorizer' |
#!/usr/bin/env python
# __author__ = "Ronie Martinez"
# __copyright__ = "Copyright 2019-2020, Ronie Martinez"
# __credits__ = ["Ronie Martinez"]
# __maintainer__ = "Ronie Martinez"
# __email__ = "ronmarti18@gmail.com"
def calculate_amortization_amount(principal, interest_rate, period):
"""
Calculates Amortiza... | def calculate_amortization_amount(principal, interest_rate, period):
"""
Calculates Amortization Amount per period
:param principal: Principal amount
:param interest_rate: Interest rate per period
:param period: Total number of periods
:return: Amortization amount per period
"""
x = (1 ... |
def clean_xml_indentation(element, level=0, spaces_per_level=2):
"""
copy and paste from http://effbot.org/zone/elementent-lib.htm#prettyprint
it basically walks your tree and adds spaces and newlines so the tree is
printed in a nice way
"""
i = "\n" + level*spaces_per_level*" "
if len(ele... | def clean_xml_indentation(element, level=0, spaces_per_level=2):
"""
copy and paste from http://effbot.org/zone/elementent-lib.htm#prettyprint
it basically walks your tree and adds spaces and newlines so the tree is
printed in a nice way
"""
i = '\n' + level * spaces_per_level * ' '
if len(e... |
# -*- coding: utf-8 -*-
"""Top-level package for dsn_3000."""
__author__ = """Shannon-li"""
__email__ = 'lishengchen@mingvale.com'
__version__ = '0.1.0'
| """Top-level package for dsn_3000."""
__author__ = 'Shannon-li'
__email__ = 'lishengchen@mingvale.com'
__version__ = '0.1.0' |
#
# PySNMP MIB module Juniper-SUBSCRIBER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-SUBSCRIBER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:01:13 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, constraints_union, value_range_constraint) ... |
#input
# 69 237 245 22 97 105 68 243 232 209 177 72 161 199 237 218 206 122 209 100 79 226 195 202 160 238 106 99 118 57 68 68 53 65 240 230 160 99 208 64 118 210 232 244 119 178 69 224 146 87 104 237 232 204 227 75 65 162 90 75 64 133 75 225 238 160 204 54 14 196 121 78 72 240 89 237 145 108 244 179 102 54 32 160 53 8... | def decode(seq):
if len(seq) == 8:
seq = '0b' + seq[1:]
char = chr(int(seq, 2))
return char
encoded_sequence = [int(x) for x in input().split()]
for c in encoded_sequence:
binc = bin(c)[2:]
num_of_bits = binc.count('1')
if num_of_bits % 2 == 0:
decoded_character = decode(binc)
... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
# root and current node
cur = ro... | class Solution:
def merge_two_lists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
cur = root = list_node(0)
while list1 and list2:
if list1.val <= list2.val:
item = list1.val
list1 = list1.next
elif list1.v... |
def proc(command, message):
return {
"data": {
"text": "Your command was not recognised. Type 'help' to read the list of all available commands."
},
"response_required": True
}
| def proc(command, message):
return {'data': {'text': "Your command was not recognised. Type 'help' to read the list of all available commands."}, 'response_required': True} |
A, B, C = input().split()
A = int(A)
B = int(B)
C = int(C)
if(A < B and A < C and B < C):
a = C
b = B
c = A
elif(A < B and A < C and C < B):
a = B
b = C
c = A
elif(B < A and B < C and A < C):
a = C
b = A
c = B
elif(B < A and B < C and C < A):
a = A
b = C
c = B
e... | (a, b, c) = input().split()
a = int(A)
b = int(B)
c = int(C)
if A < B and A < C and (B < C):
a = C
b = B
c = A
elif A < B and A < C and (C < B):
a = B
b = C
c = A
elif B < A and B < C and (A < C):
a = C
b = A
c = B
elif B < A and B < C and (C < A):
a = A
b = C
c = B
elif ... |
"""Ordered List impelementation."""
class Node(object):
"""Node class."""
def __init__(self, initdata=None):
"""Initialization."""
self.data = initdata
self.next = None
def getData(self):
"""Get node's data."""
return self.data
def setData(self, data):
... | """Ordered List impelementation."""
class Node(object):
"""Node class."""
def __init__(self, initdata=None):
"""Initialization."""
self.data = initdata
self.next = None
def get_data(self):
"""Get node's data."""
return self.data
def set_data(self, data):
... |
for _ in range(int(input())):
s = input()
f,l,r = 0,0,0
for i in range(len(s) - 1):
if(s[i] == s[i + 1]):
f = 1
l = i
break
for i in range(len(s) - 1,0,-1):
if(s[i] == s[i - 1]):
# print(i)
f = 1
r = i
break
if s[0] == s[len(s) - 1]: f = 1
if f == 0:print('yes')
elif(len(s) % 2 != 0): pr... | for _ in range(int(input())):
s = input()
(f, l, r) = (0, 0, 0)
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
f = 1
l = i
break
for i in range(len(s) - 1, 0, -1):
if s[i] == s[i - 1]:
f = 1
r = i
break
if s[0]... |
""" tells the bot to join the [params] channel """
class Command:
owner_command = True
def run(self):
self.response = f"attempting to join {self.params}"
self.raw_send = "JOIN " + self.params
| """ tells the bot to join the [params] channel """
class Command:
owner_command = True
def run(self):
self.response = f'attempting to join {self.params}'
self.raw_send = 'JOIN ' + self.params |
def solution(n, delivery):
answer = ''
ans_list = []
for i in range(n):
ans_list.append('?')
for de in delivery:
if(de[2] == 1):
ans_list[de[0] -1] = 'O'
ans_list[de[1] -1] = 'O'
for de in delivery:
if(de[2] == 0):
if(ans_list[de[0] -1 ] =... | def solution(n, delivery):
answer = ''
ans_list = []
for i in range(n):
ans_list.append('?')
for de in delivery:
if de[2] == 1:
ans_list[de[0] - 1] = 'O'
ans_list[de[1] - 1] = 'O'
for de in delivery:
if de[2] == 0:
if ans_list[de[0] - 1] ==... |
# def summation(num):
# pos = 0
# while (num > 0):
# pos += num
# print(pos)
# num -= 1
# print(num)
# return pos
# # Code here
def summation(num):
pos = 0
for num in range(1,num + 1):
pos += num
print(num)
return p... | def summation(num):
pos = 0
for num in range(1, num + 1):
pos += num
print(num)
return pos
num = int(input('Write number = '))
print(summation(num)) |
def somar(a=0,b=0,c=0):
s=a+b+c
return s
def main():
#print(somar(3,4,5))
r1 = somar(3,4,5)
r2 = somar(1,7)
r3 = somar(4)
print('RESULTADOS: ',r1,r2,r3)
main()
| def somar(a=0, b=0, c=0):
s = a + b + c
return s
def main():
r1 = somar(3, 4, 5)
r2 = somar(1, 7)
r3 = somar(4)
print('RESULTADOS: ', r1, r2, r3)
main() |
def tf_io_copts():
return (
[
"-std=c++11",
"-DNDEBUG",
] +
select({
"@bazel_tools//src/conditions:darwin": [],
"//conditions:default": ["-pthread"]
})
)
| def tf_io_copts():
return ['-std=c++11', '-DNDEBUG'] + select({'@bazel_tools//src/conditions:darwin': [], '//conditions:default': ['-pthread']}) |
def nb_post_fix(rtl_log_f,rtl_log,nb_log):
''' Replaces non-blocking load results in rd of trace log.
Sees time/CycleCnt at which non-block load is written back to gpr,
checks from that time/CycleCnt backwards, where this gpr was written in trace log,
replaces the result in rd (also load) at that instru... | def nb_post_fix(rtl_log_f, rtl_log, nb_log):
""" Replaces non-blocking load results in rd of trace log.
Sees time/CycleCnt at which non-block load is written back to gpr,
checks from that time/CycleCnt backwards, where this gpr was written in trace log,
replaces the result in rd (also load) at that inst... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.