content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
factor = int(input())
count = int(input())
list = []
counter = factor
for _ in range(count):
list.append(counter)
counter += factor
print(list) | factor = int(input())
count = int(input())
list = []
counter = factor
for _ in range(count):
list.append(counter)
counter += factor
print(list) |
# 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 isSameTree(self, p: _TreeNode, q: _TreeNode) -> bool:
# If both are none, the nodes are the same.
... | class _Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def is_same_tree(self, p: _TreeNode, q: _TreeNode) -> bool:
if p is None and q is None:
return True
if p is None or q is No... |
# Based on https://github.com/zricethezav/gitleaks/blob/6f5ad9dc0b385c872f652324188ce91da7157c7c/test_data/test_repos/test_dir_1/server.test2.py
# Do not hard code credentials
client = boto3.client(
's3',
# Hard coded strings as credentials, not recommended.
aws_access_key_id='AKIAIO5FODNN7EXAMPLE',
aws... | client = boto3.client('s3', aws_access_key_id='AKIAIO5FODNN7EXAMPLE', aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE') |
def find_range_values(curr_range):
return list(map(int, curr_range.split(",")))
def find_set(curr_range):
start_value, end_value = find_range_values(curr_range)
curr_set = set(range(start_value, end_value + 1))
return curr_set
def find_longest_intersection(n):
longest_intersection = set()
... | def find_range_values(curr_range):
return list(map(int, curr_range.split(',')))
def find_set(curr_range):
(start_value, end_value) = find_range_values(curr_range)
curr_set = set(range(start_value, end_value + 1))
return curr_set
def find_longest_intersection(n):
longest_intersection = set()
fo... |
CKAN_ROOT = "https://data.wprdc.org/"
API_PATH = "api/3/action/"
SQL_SEARCH_ENDPOINT = "datastore_search_sql"
API_URL = CKAN_ROOT + API_PATH + SQL_SEARCH_ENDPOINT
| ckan_root = 'https://data.wprdc.org/'
api_path = 'api/3/action/'
sql_search_endpoint = 'datastore_search_sql'
api_url = CKAN_ROOT + API_PATH + SQL_SEARCH_ENDPOINT |
# variables 3
a = "abc"
print("a:", a, type(a))
a = 3
print("a:", a, type(a))
| a = 'abc'
print('a:', a, type(a))
a = 3
print('a:', a, type(a)) |
def put_languages(self, root):
if hasattr(self, "languages") and self.languages:
lang_string = ",".join(["/".join(x) for x in self.languages])
root.attrib["languages"] = lang_string
def put_address(self, root):
if self.address:
if isinstance(self.address, str):
root.attrib... | def put_languages(self, root):
if hasattr(self, 'languages') and self.languages:
lang_string = ','.join(['/'.join(x) for x in self.languages])
root.attrib['languages'] = lang_string
def put_address(self, root):
if self.address:
if isinstance(self.address, str):
root.attrib['... |
# n = nums.length
# time = 0(n)
# space = O(1)
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
ret = max(nums)
sub_sum = 0
for num in nums:
sub_sum = max(0, sub_sum) + num
ret = max(ret, sub_sum)
return ret
| class Solution:
def max_sub_array(self, nums: List[int]) -> int:
ret = max(nums)
sub_sum = 0
for num in nums:
sub_sum = max(0, sub_sum) + num
ret = max(ret, sub_sum)
return ret |
class Heroes3(object):
def __init__(self):
super(Heroes3, self).__init__()
self._army_size = {
"Few" : (1, 4),
"Several" : (5, 9),
"Pack" : (10, 19),
"Lots" : (20, 49),
"Horde" : (50, 100),
"Throng" : (100, 249),
"Sw... | class Heroes3(object):
def __init__(self):
super(Heroes3, self).__init__()
self._army_size = {'Few': (1, 4), 'Several': (5, 9), 'Pack': (10, 19), 'Lots': (20, 49), 'Horde': (50, 100), 'Throng': (100, 249), 'Swarm': (250, 499), 'Zounds': (500, 999), 'Legion': (1000, float('inf'))}
def get_all(s... |
count = int(input())
for i in range(count):
k = int(input())
n = int(input())
people = [j for j in range(1,n+1)]
for x in range (k):
for v in range(n-1):
people[v+1] += people[v]
print(people[-1])
| count = int(input())
for i in range(count):
k = int(input())
n = int(input())
people = [j for j in range(1, n + 1)]
for x in range(k):
for v in range(n - 1):
people[v + 1] += people[v]
print(people[-1]) |
def goTo(logic, x, y):
hero.moveXY(x, y)
hero.say(logic)
hero.moveXY(26, 16);
a = hero.findNearestFriend().getSecretA()
b = hero.findNearestFriend().getSecretB()
c = hero.findNearestFriend().getSecretC()
goTo(a and b or c, 25, 26)
goTo((a or b) and c, 26, 32)
goTo((a or c) and (b or c), 35, 32)
go... | def go_to(logic, x, y):
hero.moveXY(x, y)
hero.say(logic)
hero.moveXY(26, 16)
a = hero.findNearestFriend().getSecretA()
b = hero.findNearestFriend().getSecretB()
c = hero.findNearestFriend().getSecretC()
go_to(a and b or c, 25, 26)
go_to((a or b) and c, 26, 32)
go_to((a or c) and (b or c), 35, 32)
go_to(a and b... |
def print_array(array):
for i in array:
print(i, end=" ")
print("")
def bubble_sort(array):
for i in range(len(array)):
swapped = False
for j in range(0, len(array)-i-1):
if array[j] >= array[j+1]:
tmp = array[j+1]
array[j+1] = array[j]
... | def print_array(array):
for i in array:
print(i, end=' ')
print('')
def bubble_sort(array):
for i in range(len(array)):
swapped = False
for j in range(0, len(array) - i - 1):
if array[j] >= array[j + 1]:
tmp = array[j + 1]
array[j + 1] = a... |
class Solution:
def findAnagrams(self, s: str, p: str) -> List[int]:
size_s = len(s)
size_p = len(p)
counter1 = collections.defaultdict(int)
counter2 = collections.defaultdict(int)
ans = []
for c in p:
counter2[c] += 1
for c in s[:size_p-1]... | class Solution:
def find_anagrams(self, s: str, p: str) -> List[int]:
size_s = len(s)
size_p = len(p)
counter1 = collections.defaultdict(int)
counter2 = collections.defaultdict(int)
ans = []
for c in p:
counter2[c] += 1
for c in s[:size_p - 1]:
... |
'''
Created on Oct 3, 2015
@author: bcy-3
'''
| """
Created on Oct 3, 2015
@author: bcy-3
""" |
app_name = "pusta2"
prefix_url = "pusta2"
static_files = {
'js': {
'pusta2/js/': ['main.js', ]
},
'css': {
'pusta2/css/': ['main.css', ]
},
'html': {
'pusta2/html/': ['index.html', ]
}
}
permissions = {
"edit": "Editing actualy nothing.",
"sample1": "sample1longve... | app_name = 'pusta2'
prefix_url = 'pusta2'
static_files = {'js': {'pusta2/js/': ['main.js']}, 'css': {'pusta2/css/': ['main.css']}, 'html': {'pusta2/html/': ['index.html']}}
permissions = {'edit': 'Editing actualy nothing.', 'sample1': 'sample1longversion'} |
input = open('input.txt', 'r').read().split("\n")
preamble_length = 25
invalid = 0
for i in range(preamble_length, len(input)):
current = int(input[i])
found = False
for j in range(i - preamble_length, i):
for k in range (j + 1, i):
sum = int(input[j]) + int(input[k])
if sum == current:
found = True
i... | input = open('input.txt', 'r').read().split('\n')
preamble_length = 25
invalid = 0
for i in range(preamble_length, len(input)):
current = int(input[i])
found = False
for j in range(i - preamble_length, i):
for k in range(j + 1, i):
sum = int(input[j]) + int(input[k])
if sum =... |
x,y = map(float, input().split())
if (x == y == 0):
print("Origem")
elif (y == 0):
print("Eixo X")
elif (x == 0):
print("Eixo Y")
elif (x > 0) and (y > 0):
print("Q1")
elif (x < 0) and (y > 0):
print("Q2")
elif (x < 0) and (y < 0):
print("Q3")
elif (x > 0) and (y < 0):
print("Q4")
| (x, y) = map(float, input().split())
if x == y == 0:
print('Origem')
elif y == 0:
print('Eixo X')
elif x == 0:
print('Eixo Y')
elif x > 0 and y > 0:
print('Q1')
elif x < 0 and y > 0:
print('Q2')
elif x < 0 and y < 0:
print('Q3')
elif x > 0 and y < 0:
print('Q4') |
class Point(object):
def __init__(self, x, y):
self._x = x
self._y = y
def get_x(self):
return self._x
def set_x(self, x):
self._x = x
def get_y(self):
return self._y
def set_y(self, y):
self._y = y
def euclidean_distance(a, b):
ax = a.get_... | class Point(object):
def __init__(self, x, y):
self._x = x
self._y = y
def get_x(self):
return self._x
def set_x(self, x):
self._x = x
def get_y(self):
return self._y
def set_y(self, y):
self._y = y
def euclidean_distance(a, b):
ax = a.get_x(... |
print("Height: ", end='')
while True:
height = input()
# check if int
try:
height = int(height)
except ValueError:
print("Retry: ", end='')
continue
# check if suitable value
if height >= 0 and height <= 23:
break
else:
print("Height: ", end='')
# ... | print('Height: ', end='')
while True:
height = input()
try:
height = int(height)
except ValueError:
print('Retry: ', end='')
continue
if height >= 0 and height <= 23:
break
else:
print('Height: ', end='')
for i in range(height):
hashes = '#' * (i + 1)
... |
# In Search for the Lost Memory [Explorer Pirate + Jett] (3527)
recoveredMemory = 7081
kyrin = 1090000
sm.setSpeakerID(kyrin)
sm.sendNext("A stable position, with a calm demanor-- but I can tell you're hiding your explosive attacking abilities-- "
"you've become quite an impressive pirate, #h #. It's been a while.")... | recovered_memory = 7081
kyrin = 1090000
sm.setSpeakerID(kyrin)
sm.sendNext("A stable position, with a calm demanor-- but I can tell you're hiding your explosive attacking abilities-- you've become quite an impressive pirate, #h #. It's been a while.")
sm.sendSay("You used to be a kid that was scared of water-- and look... |
class Powerup:
def __init__(self, coord):
self.coord = coord
def use(self, player):
raise NotImplementedError
def ascii(self):
return "P"
| class Powerup:
def __init__(self, coord):
self.coord = coord
def use(self, player):
raise NotImplementedError
def ascii(self):
return 'P' |
languages = {
"c": "c",
"cpp": "cpp",
"cc": "cpp",
"cs": "csharp",
"java": "java",
"py": "python",
"rb": "ruby"
}
| languages = {'c': 'c', 'cpp': 'cpp', 'cc': 'cpp', 'cs': 'csharp', 'java': 'java', 'py': 'python', 'rb': 'ruby'} |
#Arquivo que contem os parametros do jogo
quantidade_jogadores = 2 #quantidade de Jogadores
jogadores = [] #array que contem os jogadores(na ordem de jogo)
tamanho_tabuleiro = 40 #tamanho do array do tabuleiro (sempre multiplo de 4 para o tabuleiro ficar quadrado)
quantidade_dados = 2 #quantos dados serao usados
quant... | quantidade_jogadores = 2
jogadores = []
tamanho_tabuleiro = 40
quantidade_dados = 2
quantidade_reves = int(tamanho_tabuleiro / 5)
dinheiro_inicial = 10000000
jogadas_default = 1
pos_vai_para_cadeia = int(tamanho_tabuleiro / 4)
pos__cadeia = int(pos_vai_para_cadeia * 3)
contrucoes = {'1': 'Nada', '2': 'Casa', '3': 'Hote... |
s = 'azcbobobegghakl'
num = 0
for i in range(0, len(s) - 2):
if s[i] + s[i + 1] + s[i + 2] == 'bob':
num += 1
print('Number of times bob occurs is: ' + str(num)) | s = 'azcbobobegghakl'
num = 0
for i in range(0, len(s) - 2):
if s[i] + s[i + 1] + s[i + 2] == 'bob':
num += 1
print('Number of times bob occurs is: ' + str(num)) |
# --- Day 14: Docking Data ---
# As your ferry approaches the sea port, the captain asks for your help again. The computer system that runs this port isn't compatible with the docking program on the ferry, so the docking parameters aren't being correctly initialized in the docking program's memory.
# After a brief ins... | def file_input():
f = open(inputFile, 'r')
with open(inputFile) as f:
read_data = f.read().split('\n')
f.close()
return read_data
def split_data(data):
data_line = []
max_size = 0
global mem
for line in data:
new_line = line.split(' = ')
if newLine[0] != 'mask':
... |
#!/usr/bin/env python3
class DNSMasq_DHCP_Generic_Switchable:
def __init__(self, name, value):
self.name = name
self.value = value
def __str__(self):
if self.value is None:
return self.name
elif self.value is not None:
return self.name + "=" + self.valu... | class Dnsmasq_Dhcp_Generic_Switchable:
def __init__(self, name, value):
self.name = name
self.value = value
def __str__(self):
if self.value is None:
return self.name
elif self.value is not None:
return self.name + '=' + self.value
class Dnsmasq_Dhcp_Op... |
df4 = pandas.read_csv('supermarkets-commas.txt')
df4
df5 = pandas.read_csv('supermarkets-semi-colons.txt',sep=';')
df5
| df4 = pandas.read_csv('supermarkets-commas.txt')
df4
df5 = pandas.read_csv('supermarkets-semi-colons.txt', sep=';')
df5 |
class DummyScheduler(object):
def __init__(self, optimizer):
pass
def step(self):
pass | class Dummyscheduler(object):
def __init__(self, optimizer):
pass
def step(self):
pass |
a = [int(x) for x in input().split()]
aset = set()
for i in range(5):
for j in range(i+1, 5):
for k in range(j+1, 5):
aset.add(a[i] + a[j] + a[k])
print(sorted(aset, reverse=True)[2])
| a = [int(x) for x in input().split()]
aset = set()
for i in range(5):
for j in range(i + 1, 5):
for k in range(j + 1, 5):
aset.add(a[i] + a[j] + a[k])
print(sorted(aset, reverse=True)[2]) |
# Configuration file for interface "rpc". This interface is
# used in conjunction with RPC resource for cage-to-cage RPC calls.
#
# If location discovery at runtime is used (which is recommended),
# then all the cages that wish to share the same RPC "namespace" need
# identical broadcast ports, broadcast addresses that... | config = dict(protocol='rpc', random_port=-63000, max_connections=100, broadcast_address=('0.0.0.0/255.255.255.255', 12480), ssl_ciphers=None, ssl_protocol=None, flock_id='DEFAULT', marshaling_methods=('msgpack', 'pickle'), max_packet_size=1048576)
__all__ = ['get', 'copy']
get = lambda key, default=None: pmnc.config.g... |
EXAMPLE_TWEETS = [
"Trump for President!!! #MAGA",
"Trump is the best ever!",
"RT @someuser: Trump is, by far, the best POTUS in history. \n\nBonus: He^s friggin^ awesome!\n\nTrump gave Pelosi and the Dems the ultimate\u2026 ",
"If Clinton is elected, I'm moving to Canada",
"Trump is doing a great ... | example_tweets = ['Trump for President!!! #MAGA', 'Trump is the best ever!', 'RT @someuser: Trump is, by far, the best POTUS in history. \n\nBonus: He^s friggin^ awesome!\n\nTrump gave Pelosi and the Dems the ultimate… ', "If Clinton is elected, I'm moving to Canada", 'Trump is doing a great job so far. Keep it up man.... |
test_item = {
"stac_version": "1.0.0",
"stac_extensions": [],
"type": "Feature",
"id": "20201211_223832_CS2",
"bbox": [
172.91173669923782,
1.3438851951615003,
172.95469614953714,
1.3690476620161975
],
"geometry": {
"type": "Polygon",
"coordina... | test_item = {'stac_version': '1.0.0', 'stac_extensions': [], 'type': 'Feature', 'id': '20201211_223832_CS2', 'bbox': [172.91173669923782, 1.3438851951615003, 172.95469614953714, 1.3690476620161975], 'geometry': {'type': 'Polygon', 'coordinates': [[[172.91173669923782, 1.3438851951615003], [172.95469614953714, 1.3438851... |
# output: ok
assert([x for x in ()] == [])
assert([x for x in range(0, 3)] == [0, 1, 2])
assert([(x, y) for x in range(0, 2) for y in range(2, 4)] ==
[(0, 2), (0, 3), (1, 2), (1, 3)])
assert([x for x in range(0, 3) if x >= 1] == [1, 2])
def inc(x):
return x + 1
assert([inc(y) for y in (1, 2, 3)] == [2, 3, ... | assert [x for x in ()] == []
assert [x for x in range(0, 3)] == [0, 1, 2]
assert [(x, y) for x in range(0, 2) for y in range(2, 4)] == [(0, 2), (0, 3), (1, 2), (1, 3)]
assert [x for x in range(0, 3) if x >= 1] == [1, 2]
def inc(x):
return x + 1
assert [inc(y) for y in (1, 2, 3)] == [2, 3, 4]
a = 1
assert [a for y ... |
#
# PySNMP MIB module ASCEND-MIBVDSLNET-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBVDSLNET-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:28:54 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')
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union... |
def __init__(self):
self.meetings = []
def book(self, start: int, end: int) -> bool:
for s, e in self.meetings:
if s < end and start < e:
return False
self.meetings.append([start, end])
return True | def __init__(self):
self.meetings = []
def book(self, start: int, end: int) -> bool:
for (s, e) in self.meetings:
if s < end and start < e:
return False
self.meetings.append([start, end])
return True |
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
#
# The number of elements initialized in nums1 and nums2 are m and n respectively.
# You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.
# Source - https://leetcod... | class Solution:
def merge(self, nums1, m: int, nums2, n: int):
i = m - 1
j = n - 1
k = m + n - 1
while i >= 0 and j >= 0:
if nums1[i] > nums2[j]:
nums1[k] = nums1[i]
i -= 1
else:
nums1[k] = nums2[j]
... |
# Example of mutual recursion with even/odd.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# This code is in the public domain.
def is_even(n):
if n == 0:
return True
else:
return is_odd(n - 1)
def is_odd(n):
if n == 0:
return False
else:
return is_even(n - 1)
de... | def is_even(n):
if n == 0:
return True
else:
return is_odd(n - 1)
def is_odd(n):
if n == 0:
return False
else:
return is_even(n - 1)
def is_even_thunked(n):
if n == 0:
return True
else:
return lambda : is_odd_thunked(n - 1)
def is_odd_thunked(n)... |
X = {}
print(5 in X)
print(X[4])
print(X[5])
| x = {}
print(5 in X)
print(X[4])
print(X[5]) |
# -*- coding: utf-8 -*-
# Author: Tonio Teran <tonio@stateoftheart.ai>
# Copyright: Stateoftheart AI PBC 2021.
'''NEAR AI's library wrapper.
Dataset information taken from:
'''
SOURCE_METADATA = {
'name': 'nearai',
'original_name': 'NEAR Program Synthesis',
'url': 'https://github.com/nearai/program_synthe... | """NEAR AI's library wrapper.
Dataset information taken from:
"""
source_metadata = {'name': 'nearai', 'original_name': 'NEAR Program Synthesis', 'url': 'https://github.com/nearai/program_synthesis'}
datasets = {'Program Synthesis': ['AlgoLisp', 'Karel', 'NAPS']}
def load_dataset(name: str) -> dict:
return {'name... |
#!/usr/bin/python
inp = input(">> ")
print(inp)
count = 0
while True:
print("hi")
count += 1
if count == 3:
break | inp = input('>> ')
print(inp)
count = 0
while True:
print('hi')
count += 1
if count == 3:
break |
#VERSION: 1.0
INFO = {"example":("test","This is an example mod")}
RLTS = {"cls":(),"funcs":("echo"),"vars":()}
def test(cmd):
echo(0,cmd)
| info = {'example': ('test', 'This is an example mod')}
rlts = {'cls': (), 'funcs': 'echo', 'vars': ()}
def test(cmd):
echo(0, cmd) |
#so sai quando escrever sair
nome = str(input("Escreva nome :(sair para terminar)"))
while nome != "sair":
nome = str(input("Escreva nome: (sair para terminar)"))
| nome = str(input('Escreva nome :(sair para terminar)'))
while nome != 'sair':
nome = str(input('Escreva nome: (sair para terminar)')) |
def heap_sort(l: list):
# flag is init
def sort(num: int, node: int, flag: bool):
# print(str(node) +' '+str(num))
if num == len(l) - 1:
return
if node < 0:
l[0], l[-(num) - 1] = l[-(num) - 1], l[0] #swap topest
num += 1
node = 0
if... | def heap_sort(l: list):
def sort(num: int, node: int, flag: bool):
if num == len(l) - 1:
return
if node < 0:
(l[0], l[-num - 1]) = (l[-num - 1], l[0])
num += 1
node = 0
if node * 2 + 1 < len(l) - num:
if l[node] < l[node * 2 + 1]:
... |
# directories where to look for duplicates
dir_list = [
r"C:\Users\Gamer\Documents\Projekte\azzap\azzap-docker-dev\data\html\pub\media\catalog\product",
r"C:\Users\Gamer\Documents\Projekte\azzap\azzap-docker-dev\data\html\pub\media\import\multishopifystoremageconnect",
r"C:\Users\Gamer\Documents\Projekte\a... | dir_list = ['C:\\Users\\Gamer\\Documents\\Projekte\\azzap\\azzap-docker-dev\\data\\html\\pub\\media\\catalog\\product', 'C:\\Users\\Gamer\\Documents\\Projekte\\azzap\\azzap-docker-dev\\data\\html\\pub\\media\\import\\multishopifystoremageconnect', 'C:\\Users\\Gamer\\Documents\\Projekte\\azzap\\azzap-docker-dev\\data\\h... |
print("NFC West W L T")
print("-----------------------")
print("Seattle 13 3 0")
print("San Francisco 12 4 0")
print("Arizona 10 6 0")
print("St. Louis 7 9 0\n")
print("NFC North W L T")
print("-----------------------")
print("Green Bay 8 7 1")
print("Chicago ... | print('NFC West W L T')
print('-----------------------')
print('Seattle 13 3 0')
print('San Francisco 12 4 0')
print('Arizona 10 6 0')
print('St. Louis 7 9 0\n')
print('NFC North W L T')
print('-----------------------')
print('Green Bay 8 7 1')
print('Chicago ... |
pallet_color = [
(231, 234, 238), # 010 White
(252, 166, 0), # 020Golden yellow
(232, 167, 0), # 019 Signal yellow
(254, 198, 0), # 021 Yellow
(242, 203, 0), # 022 Light yellow
(241, 225, 14), # 025 Brimstone yellow
(116, 2, 16), # 312 Burgundy
(145, 8, 20), # 030 Dark red
(1... | pallet_color = [(231, 234, 238), (252, 166, 0), (232, 167, 0), (254, 198, 0), (242, 203, 0), (241, 225, 14), (116, 2, 16), (145, 8, 20), (175, 0, 11), (199, 12, 0), (211, 48, 0), (221, 68, 0), (236, 102, 0), (255, 109, 0), (65, 40, 114), (93, 43, 104), (120, 95, 162), (186, 148, 188), (195, 40, 106), (239, 135, 184), (... |
# All metrics are treated as gauge as the counter instrument don't provide a set
# method and for performance, it's always good to avoid calculation when ever it's possible.
# Using the inc() method require the diff to be calculated!
metrics = [
## Custom metrics
("up", "the status of the node (1=running, ... | metrics = [('up', 'the status of the node (1=running, 0=down, -1=connection issue, -2=node error)'), ('peers_count', 'how many peers the node is seeing'), ('sigs_count', 'how many nodes are currently validating'), ('header_nextValidators_count', 'how many nodes are in the validators set for the next epoch'), ('header_n... |
def test_slash_request_forbidden(client):
assert client.get("/").status_code == 404
def test_api_root_request_forbidden(client):
assert client.get("/api").status_code == 404
assert client.get("/api/").status_code == 404
def test_auth_root_request_forbidden(client):
assert client.get("/auth").status_... | def test_slash_request_forbidden(client):
assert client.get('/').status_code == 404
def test_api_root_request_forbidden(client):
assert client.get('/api').status_code == 404
assert client.get('/api/').status_code == 404
def test_auth_root_request_forbidden(client):
assert client.get('/auth').status_co... |
a, b, c = map(int, input().split())
if (a == b and a != c) or (a ==c and a != b) or (b == c and b != a):
print("Yes")
else:
print("No")
| (a, b, c) = map(int, input().split())
if a == b and a != c or (a == c and a != b) or (b == c and b != a):
print('Yes')
else:
print('No') |
#Check for the existence of file
no_of_items=0
try:
f=open("./TODO (CLI-VER)/todolist.txt")
p=0
for i in f.readlines():#Counting the number of items if the file exists already
p+=1
no_of_items=p-2
except:
f=open("./TODO (CLI-VER)/todolist.txt",'w')
f.write("_________TODO LIST__________\... | no_of_items = 0
try:
f = open('./TODO (CLI-VER)/todolist.txt')
p = 0
for i in f.readlines():
p += 1
no_of_items = p - 2
except:
f = open('./TODO (CLI-VER)/todolist.txt', 'w')
f.write('_________TODO LIST__________\n')
f.write(' TIME WORK')
finally:
f.close()
p... |
class Solution:
def minFlips(self, target: str) -> int:
nflips = 0
for ison in map(lambda x : x == '1', target):
if ((not ison) and nflips % 2 == 1) or (ison and nflips % 2 == 0):
nflips += 1
return nflips
| class Solution:
def min_flips(self, target: str) -> int:
nflips = 0
for ison in map(lambda x: x == '1', target):
if not ison and nflips % 2 == 1 or (ison and nflips % 2 == 0):
nflips += 1
return nflips |
class Solution:
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
for i in matrix:
for j in i:
if j==target:return True
return False | class Solution:
def search_matrix(self, matrix: List[List[int]], target: int) -> bool:
for i in matrix:
for j in i:
if j == target:
return True
return False |
class FermiDataGetter(object):
def __init__(self) -> None:
raise NotImplementedError()
| class Fermidatagetter(object):
def __init__(self) -> None:
raise not_implemented_error() |
# -*- coding: utf-8 -*-
'''
>>> from pycm import *
>>> import os
>>> import json
>>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]
>>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]
>>> cm = ConfusionMatrix(y_actu, y_pred)
>>> cm
pycm.ConfusionMatrix(classes: [0, 1, 2])
>>> len(cm)
3
>>> print(cm)
Predict 0 ... | """
>>> from pycm import *
>>> import os
>>> import json
>>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]
>>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]
>>> cm = ConfusionMatrix(y_actu, y_pred)
>>> cm
pycm.ConfusionMatrix(classes: [0, 1, 2])
>>> len(cm)
3
>>> print(cm)
Predict 0 1 2
Actual
0 ... |
#encoding:utf-8
subreddit = 'talesfromtechsupport'
t_channel = '@r_talesfromtechsupport'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| subreddit = 'talesfromtechsupport'
t_channel = '@r_talesfromtechsupport'
def send_post(submission, r2t):
return r2t.send_simple(submission) |
def factors(n):
factorlist=[]
for i in range(1,n+1):
if n%i==0:
factorlist=factorlist+[i]
return(factorlist)
def isprime(n):
return(factors(n)==[1,n])
def sumprimes(l):
sum=0
for i in range(0,len(l)):
if isprime(l[i]):
sum=s... | def factors(n):
factorlist = []
for i in range(1, n + 1):
if n % i == 0:
factorlist = factorlist + [i]
return factorlist
def isprime(n):
return factors(n) == [1, n]
def sumprimes(l):
sum = 0
for i in range(0, len(l)):
if isprime(l[i]):
sum = sum + l[i]
... |
def swap(array,i,j): #this simply swaps the values
array[i],array[j]=array[j],array[i]
'''HeapifyMax function, our root node is at index i. We will first assume that
the value at index 'i' is the largest. Then we will find index of left and right child.
Then we will check if left and right child exist or not.Now... | def swap(array, i, j):
(array[i], array[j]) = (array[j], array[i])
'HeapifyMax function, our root node is at index i. We will first assume that \nthe value at index \'i\' is the largest. Then we will find index of left and right child.\nThen we will check if left and right child exist or not.Now, we will compare ou... |
# https://app.codesignal.com/arcade/intro/level-5/g6dc9KJyxmFjB98dL
def areEquallyStrong(your_left, your_right, friends_left, friends_right):
# Two arms are equally strong if the heaviest weights they each are
# able to lift are equal. Two people are equally strong if their
# strongest arms are equally stro... | def are_equally_strong(your_left, your_right, friends_left, friends_right):
my_max = max(your_left, your_right)
my_min = min(your_left, your_right)
fr_max = max(friends_left, friends_right)
fr_min = min(friends_left, friends_right)
return my_max == fr_max and my_min == fr_min |
# Source : https://leetcode.com/problems/4sum/
# Author : YipingPan
# Date : 2020-08-16
#####################################################################################################
#
# Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums
# such that a + b + c ... | class Solution:
def four_sum(self, nums: List[int], target: int) -> List[List[int]]:
dic = collections.defaultdict(list)
for i in range(len(nums)):
for j in range(len(nums)):
if i < j:
dic[nums[i] + nums[j]].append([i, j])
res = set()
... |
dict_rhythms = {
"E(2,3)" : "A common Afro-Cuban drum pattern when started on the second onset as in [101]. For example, it is the conga rhythm of the (6/8)-time Swing Tumbao. It is common in Latin American music, as for example in the Cueca, and the coros de clave. It is common in Arabic music, as for example in the... | dict_rhythms = {'E(2,3)': 'A common Afro-Cuban drum pattern when started on the second onset as in [101]. For example, it is the conga rhythm of the (6/8)-time Swing Tumbao. It is common in Latin American music, as for example in the Cueca, and the coros de clave. It is common in Arabic music, as for example in the Al ... |
def fun(a, b):
return 1
fun(1, 2)
| def fun(a, b):
return 1
fun(1, 2) |
# Create a program to check if an integer is a perfect square.
# 4, 9, 25 any ideas? Use Square Root
# input
num = int(input('Enter a value: '))
# processing & output
if (num ** 0.5) % 1 != 0:
print(num, 'is not a perfect square.')
else:
print(num, 'is a perfect square.') | num = int(input('Enter a value: '))
if num ** 0.5 % 1 != 0:
print(num, 'is not a perfect square.')
else:
print(num, 'is a perfect square.') |
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
# Copyright 2018 The AnPyLar Team. All Rights Reserved.
# Use of this source code is governed by an MIT-style license that
# can be found in the LICENSE file at http://anpyla... | styles_css = '\n/* Master Styles */\nh1 {\n color: #369;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 250%;\n}\nh2, h3 {\n color: #444;\n font-family: Arial, Helvetica, sans-serif;\n font-weight: lighter;\n}\nbody {\n margin: 2em;\n}\nbody, input[text], button {\n color: #888;\n font-family: Cambr... |
def Insertion_Sort(lst):
l = len(lst)
for i in range(1,l):
temp = lst[i]
j = i-1
while j>=0:
if temp[0]<lst[j][0]:
lst[j+1] = lst[j]
lst[j] = temp
j = j-1
return lst
lst = []
lst = ['Tininha', 'Dudinha','Carlinhos','Marquinhos','Joaozinho','Bruninha','Fernandinha','Rafinha','Pedrinho','Aninh... | def insertion__sort(lst):
l = len(lst)
for i in range(1, l):
temp = lst[i]
j = i - 1
while j >= 0:
if temp[0] < lst[j][0]:
lst[j + 1] = lst[j]
lst[j] = temp
j = j - 1
return lst
lst = []
lst = ['Tininha', 'Dudinha', 'Carlinhos',... |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = 'D\xccZ\x0b=\xf2\xd6\x89\x1e\xeb\xa3n\xa2z\xd6n'
_lr_action_items = {'PEEK':([179,250,251,256,296,303,325,346,351,358,361,372,374,375,376,378,381,382,],[244,244,-98,-82,-81,-88,-97,-95,-89,... | _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = 'DÌZ\x0b=òÖ\x89\x1eë£n¢zÖn'
_lr_action_items = {'PEEK': ([179, 250, 251, 256, 296, 303, 325, 346, 351, 358, 361, 372, 374, 375, 376, 378, 381, 382], [244, 244, -98, -82, -81, -88, -97, -95, -89, -94, -99, -90, -92, -100, -101, -93, -91, -96]), 'TRANS': ([0, 1, 2, ... |
def hoopCount(n):
if n > 9:
return "Great, now move on to tricks"
else:
return "Keep at it until you get it" | def hoop_count(n):
if n > 9:
return 'Great, now move on to tricks'
else:
return 'Keep at it until you get it' |
#
# PySNMP MIB module Dell-LAN-TRAP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Dell-LAN-TRAP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:56:05 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, single_value_constraint, value_range_constraint, value_size_constraint) ... |
class DummyClass:
dummy_var = 'original'
def __init__(self, init_param=0):
pass
def __call__(self, call_param=0):
return 'not_mocked_call'
def some_method(self):
# def some_method(self, some_method_param):
return 'not_mocked_some_method'
def some_other_method(self, so... | class Dummyclass:
dummy_var = 'original'
def __init__(self, init_param=0):
pass
def __call__(self, call_param=0):
return 'not_mocked_call'
def some_method(self):
return 'not_mocked_some_method'
def some_other_method(self, some_other_method_param):
return 'not_mock... |
H, W, A, B = map(int, input().split())
board = [[0] * W for _ in range(H)]
for i in range(B):
for j in range(A):
board[i][j] = 1
for i in range(B, H):
for j in range(A, W):
board[i][j] = 1
assert all(sum(row) in [A, W-A] for row in board)
assert all(sum(board[i][j] for i in range(H)) in [B, H-B... | (h, w, a, b) = map(int, input().split())
board = [[0] * W for _ in range(H)]
for i in range(B):
for j in range(A):
board[i][j] = 1
for i in range(B, H):
for j in range(A, W):
board[i][j] = 1
assert all((sum(row) in [A, W - A] for row in board))
assert all((sum((board[i][j] for i in range(H))) in... |
def genSubsets(L):
'''
L: list
Returns: all subsets of L
'''
# base case
if len(L) == 0:
return [[]]
# recursive block
# all the subsets of smaller + all the subsets of smaller combined with extra = all subsets of L
extra = L[0:1]
smaller = genSubsets(L[1:])
combine ... | def gen_subsets(L):
"""
L: list
Returns: all subsets of L
"""
if len(L) == 0:
return [[]]
extra = L[0:1]
smaller = gen_subsets(L[1:])
combine = []
for i in smaller:
combine.append(extra + i)
return smaller + combine |
class Solution(object):
def isUgly(self, num):
if not num:
return False
for factor in (2, 3, 5):
while num % factor == 0:
num /= factor
return num == 1
| class Solution(object):
def is_ugly(self, num):
if not num:
return False
for factor in (2, 3, 5):
while num % factor == 0:
num /= factor
return num == 1 |
# Please change this appropriately
TRAIN_DATA = "../input/train.csv"
TEST_DATA = "../input/test.csv"
HTML_DATA = "../input/html_data.csv"
CLEAN_TRAIN_DATA = "../input2/train_v2.csv"
CLEAN_TEST_DATA = "../input2/test_v2.csv"
TRAIN_TEXT_MODEL_PATH = "../input2/train_text_preds.csv"
TEST_TEXT_MODEL_PATH = "../input2/tes... | train_data = '../input/train.csv'
test_data = '../input/test.csv'
html_data = '../input/html_data.csv'
clean_train_data = '../input2/train_v2.csv'
clean_test_data = '../input2/test_v2.csv'
train_text_model_path = '../input2/train_text_preds.csv'
test_text_model_path = '../input2/test_text_preds.csv'
submission_path = '... |
_day_bands = ['n2_lbh'
, 'n2_vk'
, 'n2_1pg'
, 'n2_2pg'
, 'n2p_1ng'
, 'n2p_mnl'
, 'no_bands'
]
_night_bands = ['o2_nglow','o2_atm']
_bands = _day_bands + _night_bands
_band_cmd = {'n2_lbh':'syn_lbh'
, 'n2_vk':'syn_vk'
, 'n2_1pg':'sy... | _day_bands = ['n2_lbh', 'n2_vk', 'n2_1pg', 'n2_2pg', 'n2p_1ng', 'n2p_mnl', 'no_bands']
_night_bands = ['o2_nglow', 'o2_atm']
_bands = _day_bands + _night_bands
_band_cmd = {'n2_lbh': 'syn_lbh', 'n2_vk': 'syn_vk', 'n2_1pg': 'syn_1pg', 'n2_2pg': 'syn_2pg', 'n2p_1ng': 'syn_1ng', 'n2p_mnl': 'syn_mnl', 'no_bands': 'syn_no',... |
# Aaron Donnelly
# This program will count the number of re-occurences of the letter 'e' in a txt file selected by the user.
f= open(input("Insert a .txt filename "), "r")
x= f.read().count('e')
print("There are",x, "e's in this text")
| f = open(input('Insert a .txt filename '), 'r')
x = f.read().count('e')
print('There are', x, "e's in this text") |
#
# PySNMP MIB module WWP-COMMUNITY-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-COMMUNITY-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:30:41 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection) ... |
class Solution:
def XXX(self, nums: List[int]) -> List[List[int]]:
return [[n] + sub for i, n in enumerate(nums) for sub in self.XXX(nums[:i] + nums[i+1:])] or [nums]
| class Solution:
def xxx(self, nums: List[int]) -> List[List[int]]:
return [[n] + sub for (i, n) in enumerate(nums) for sub in self.XXX(nums[:i] + nums[i + 1:])] or [nums] |
'''
Created on Nov 6, 2013
@author: agreen
This module is used by the cubing_tests module as a data store.
'''
enabled = True
class DAR:
xfibre_pos = False
yfibre_pos = False
| """
Created on Nov 6, 2013
@author: agreen
This module is used by the cubing_tests module as a data store.
"""
enabled = True
class Dar:
xfibre_pos = False
yfibre_pos = False |
class Field(object):
def __init__(self, name=None, default=None, data_type=None):
self.name = name
self.default = default
self.required = self.default is None
self.type = data_type
def build(self):
result = {key: value for key, value in self.__dict__.items() if value is... | class Field(object):
def __init__(self, name=None, default=None, data_type=None):
self.name = name
self.default = default
self.required = self.default is None
self.type = data_type
def build(self):
result = {key: value for (key, value) in self.__dict__.items() if value ... |
COLORS = dict([
('CLEANUP', '\033[94m'),
('CREATE', '\033[92m'),
('INSTALL', '\033[92m'),
('SKIP', '\033[93m'),
('FAIL', '\033[31m'),
('DEFAULT', '\033[39m'),
('UNDEFINED', '\033[37m'),
('STATUS', '\033[36m')
])
def typed_message(message, message_type=None):
color = COLORS.setdefaul... | colors = dict([('CLEANUP', '\x1b[94m'), ('CREATE', '\x1b[92m'), ('INSTALL', '\x1b[92m'), ('SKIP', '\x1b[93m'), ('FAIL', '\x1b[31m'), ('DEFAULT', '\x1b[39m'), ('UNDEFINED', '\x1b[37m'), ('STATUS', '\x1b[36m')])
def typed_message(message, message_type=None):
color = COLORS.setdefault(message_type, COLORS['UNDEFINED'... |
class Solution:
def reverse(self, x: int) -> int:
rev = 0
y = abs(x)
while y:
rev = rev*10 + y % 10
y //= 10
sign = -1 if x < 0 else 1
if(rev > 0x7fffffff):
return 0
return sign * rev
| class Solution:
def reverse(self, x: int) -> int:
rev = 0
y = abs(x)
while y:
rev = rev * 10 + y % 10
y //= 10
sign = -1 if x < 0 else 1
if rev > 2147483647:
return 0
return sign * rev |
# device present global variables
DS3231_Present = False
BMP280_Present = False
AM2315_Present = False
ADS1015_Present = False
ADS1115_Present = False
| ds3231__present = False
bmp280__present = False
am2315__present = False
ads1015__present = False
ads1115__present = False |
ObjectId = int
class Object:
def __init__(self, id_):
self.id: ObjectId = id_
self.count = 1
self.neighbors = {self}
@property
def neighbor_count(self):
return sum([neighbor.count for neighbor in self.neighbors])
def __repr__(self):
return f'{self.id}_'
| object_id = int
class Object:
def __init__(self, id_):
self.id: ObjectId = id_
self.count = 1
self.neighbors = {self}
@property
def neighbor_count(self):
return sum([neighbor.count for neighbor in self.neighbors])
def __repr__(self):
return f'{self.id}_' |
# Linear search algorithm
# @ra1ski
def linear_search(item, _list):
index = None
for idx, val in enumerate(_list):
if val == item:
index = idx
break
return index
if __name__ == '__main__':
_list = ['chrome', 'firefox', 'opera', 'ie', 'netscape']
item = input('Ty... | def linear_search(item, _list):
index = None
for (idx, val) in enumerate(_list):
if val == item:
index = idx
break
return index
if __name__ == '__main__':
_list = ['chrome', 'firefox', 'opera', 'ie', 'netscape']
item = input('Type browser name:')
found_index = lin... |
city = input("Enter the name of the city: ")
sales = float(input("Enter the percentage of sales: "))
commission = 0
if 0 <= sales <= 500:
if city == "Sofia":
commission = 0.05
elif city == "Varna":
commission == 0.045
elif city == "Plovdiv":
commission == 0.055
elif 500 < sales <= 1... | city = input('Enter the name of the city: ')
sales = float(input('Enter the percentage of sales: '))
commission = 0
if 0 <= sales <= 500:
if city == 'Sofia':
commission = 0.05
elif city == 'Varna':
commission == 0.045
elif city == 'Plovdiv':
commission == 0.055
elif 500 < sales <= 10... |
def get_dotted_mask_split(ip_address_mask_cidr):
p = int(ip_address_mask_cidr)
ip_address_mask_dotted_split = []
for i in range(4):
if p >= 0:
if p - 8 >= 0:
ip_address_mask_dotted_split.append('255')
p -= 8
else:
b... | def get_dotted_mask_split(ip_address_mask_cidr):
p = int(ip_address_mask_cidr)
ip_address_mask_dotted_split = []
for i in range(4):
if p >= 0:
if p - 8 >= 0:
ip_address_mask_dotted_split.append('255')
p -= 8
else:
byte = 256 - p... |
#!/usr/bin/python
class Node:
def __init__(self, value):
self.left = None
self.right = None
self.value = value
class Tree:
def __init__(self):
self.root = None
@property
def root_node(self):
return self.root
def add(self, value):
if self.root is ... | class Node:
def __init__(self, value):
self.left = None
self.right = None
self.value = value
class Tree:
def __init__(self):
self.root = None
@property
def root_node(self):
return self.root
def add(self, value):
if self.root is None:
s... |
#Conor O'Riordan
# Write a program that asks the user to input any positive integer and outputs the successive values of the following calculation.
# At each step calculate the next value by taking the current value and
# if it is even, divide it by two, but if it is odd, multiply it by three and add one.
# Have the pr... | pos_int = int(input('Please enter a positive integer:'))
while pos_int > 1:
if pos_int % 2 == 0:
print(round(pos_int), 'is even so divide by two. This gives:', round(pos_int / 2))
pos_int = pos_int / 2
else:
print(round(pos_int), 'is odd so multiply by three and add one. This gives:', ro... |
#!/usr/bin/python3
# https://practice.geeksforgeeks.org/problems/odd-even-level-difference/1
def getLevelDiff(root):
h = {0: 0, 1: 0}
level = 0
populateDiff(root, level, h)
return h[0]-h[1]
def populateDiff(root, level, h):
if root == None:
return
l = level%2
h[l] += root.... | def get_level_diff(root):
h = {0: 0, 1: 0}
level = 0
populate_diff(root, level, h)
return h[0] - h[1]
def populate_diff(root, level, h):
if root == None:
return
l = level % 2
h[l] += root.data
populate_diff(root.left, level + 1, h)
populate_diff(root.right, level + 1, h) |
#
# PySNMP MIB module Vsm-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Vsm-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:35: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, 09:23:15)... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_size_constraint, constraints_union, value_range_constraint) ... |
'''1. Write a Python program to compute the greatest common divisor (GCD) of two positive integers.'''
def lcm(x, y):
if x > y:
z = x
else:
z = y
while(True):
if((z % x == 0) and (z % y == 0)):
lcm = z
break
z += 1
return lcm
print(lcm(4, 6))
pr... | """1. Write a Python program to compute the greatest common divisor (GCD) of two positive integers."""
def lcm(x, y):
if x > y:
z = x
else:
z = y
while True:
if z % x == 0 and z % y == 0:
lcm = z
break
z += 1
return lcm
print(lcm(4, 6))
print(lcm(... |
for t in range(int(input())):
n = int(input())
L = list(map(int,input().split()))
L.sort()
d = dict()
for i in L:
d[i] = 1
cnt = 0
for i in range(n):
for j in range(i+1,n):
try:
if d[L[i] - (L[j]-L[i])] == 1:
cnt+=1
... | for t in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
L.sort()
d = dict()
for i in L:
d[i] = 1
cnt = 0
for i in range(n):
for j in range(i + 1, n):
try:
if d[L[i] - (L[j] - L[i])] == 1:
cnt += 1
... |
'''
Remove Smallest
'''
t = int(input())
for ll in range(t):
n = int(input())
integers = set(map(int, input().split(' ')))
integers = list(integers)
integers.sort()
for i in range(1,len(integers)):
if abs(integers[i]-integers[i-1]) > 1:
print('NO')
break
else:
... | """
Remove Smallest
"""
t = int(input())
for ll in range(t):
n = int(input())
integers = set(map(int, input().split(' ')))
integers = list(integers)
integers.sort()
for i in range(1, len(integers)):
if abs(integers[i] - integers[i - 1]) > 1:
print('NO')
break
els... |
{
"targets": [
{
"target_name": "test_constructor",
"sources": [ "test_constructor.c" ]
},
{
"target_name": "test_constructor_name",
"sources": [ "test_constructor_name.c" ]
}
]
}
| {'targets': [{'target_name': 'test_constructor', 'sources': ['test_constructor.c']}, {'target_name': 'test_constructor_name', 'sources': ['test_constructor_name.c']}]} |
class Logger:
def __init__(self, filepath):
self.filepath = filepath
def write(self, msg):
with open(self.filepath, "a") as logfile:
logfile.write("{}\n".format(msg))
| class Logger:
def __init__(self, filepath):
self.filepath = filepath
def write(self, msg):
with open(self.filepath, 'a') as logfile:
logfile.write('{}\n'.format(msg)) |
'''
contains functions that convenient math stuff, usually involving operations that are not
defined in normal mathematics but could be useful
@author: Klint
'''
# matrix stuff, collapse matrix in interesting ways
def collapse_matrix_cols(matrix: [list])-> list:
'''flatten a matrix by m by n into a array of size... | """
contains functions that convenient math stuff, usually involving operations that are not
defined in normal mathematics but could be useful
@author: Klint
"""
def collapse_matrix_cols(matrix: [list]) -> list:
"""flatten a matrix by m by n into a array of size m by adding columns together
ie
| a_00 ... |
def write (name, stream):
stream.write("#include <unico.h>\n")
stream.write("#include <stddef.h>\n")
stream.write("extern int %s (size_t, size_t, unicos*);\n" % name)
| def write(name, stream):
stream.write('#include <unico.h>\n')
stream.write('#include <stddef.h>\n')
stream.write('extern int %s (size_t, size_t, unicos*);\n' % name) |
#! /usr/bin/env python3
# coding: utf-8
# Thanks to imbadatreading, should have through about LCM
def add_step_size(buses):
buses_with_step = list()
for num in range(len(buses)):
if buses[num] != 'x':
buses_with_step.append((int(buses[num]), num))
return buses_with_step
def find_aweso... | def add_step_size(buses):
buses_with_step = list()
for num in range(len(buses)):
if buses[num] != 'x':
buses_with_step.append((int(buses[num]), num))
return buses_with_step
def find_awesome_timestamp(buses):
current_time = 0
lcm = 1
for order_bus in range(len(buses) - 1):
... |
#!/usr/bin/env python3
f = open("input.txt", "r").read().splitlines()
REGISTERS_MAP = {"w": 0, "x": 1, "y": 2, "z": 3}
def checker(number):
num_str = str(number)
if "0" in num_str:
return False
if len(num_str) != 14:
return False
# Registers are in form [w,x,y,z]
counter = 0
... | f = open('input.txt', 'r').read().splitlines()
registers_map = {'w': 0, 'x': 1, 'y': 2, 'z': 3}
def checker(number):
num_str = str(number)
if '0' in num_str:
return False
if len(num_str) != 14:
return False
counter = 0
registers = [0] * 4
for line in f:
instr_arr = line.... |
# bunch of color constants
class Color:
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
BLUE = (0, 128, 255)
GREEN = (0, 153, 0)
YELLOW = (255, 255, 0)
BROWN = (204, 102, 0)
PINK = (255, 102, 178)
PURPLE = (153, 51, 255)
GREY = (128, 128, 128)
colors = {
... | class Color:
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
blue = (0, 128, 255)
green = (0, 153, 0)
yellow = (255, 255, 0)
brown = (204, 102, 0)
pink = (255, 102, 178)
purple = (153, 51, 255)
grey = (128, 128, 128)
colors = {1: WHITE, 2: YELLOW, 3: RED, 4: BLUE,... |
VERSION = "0.2"
if __name__ == '__main__':
print(VERSION)
| version = '0.2'
if __name__ == '__main__':
print(VERSION) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.