content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#
# @lc app=leetcode id=32 lang=python3
#
# [32] Longest Valid Parentheses
#
# @lc code=start
class Solution:
def longestValidParentheses(self, s):
if not s:
return 0
l = 0
r = len(s)
while s[r - 1] == '(' and r > 0:
r -= 1
while s[l] == ')' and l < r... | class Solution:
def longest_valid_parentheses(self, s):
if not s:
return 0
l = 0
r = len(s)
while s[r - 1] == '(' and r > 0:
r -= 1
while s[l] == ')' and l < r - 2:
l += 1
s = s[l:r]
if len(s) < 2:
return 0
... |
command = input()
compare_string_lower = {"coding", "dog", "cat", "movie"}
compare_string_upper = {"CODING", "DOG", "CAT", "MOVIE"}
coffee = 0
get_sleep = False
while not command == "END":
if command.isupper() and command in compare_string_upper:
coffee += 2
if command.islower() and command in compare_s... | command = input()
compare_string_lower = {'coding', 'dog', 'cat', 'movie'}
compare_string_upper = {'CODING', 'DOG', 'CAT', 'MOVIE'}
coffee = 0
get_sleep = False
while not command == 'END':
if command.isupper() and command in compare_string_upper:
coffee += 2
if command.islower() and command in compare_s... |
print('nice' in 'nice to meet you')
a=1000000
b=1000000
c=a+b
print(c)
| print('nice' in 'nice to meet you')
a = 1000000
b = 1000000
c = a + b
print(c) |
a = 1
b = 1
while 32 >= a:
print(a,-b)
b *= 2
a += 1
print("Year",b/365)
| a = 1
b = 1
while 32 >= a:
print(a, -b)
b *= 2
a += 1
print('Year', b / 365) |
# Please contact the author(s) of this library if you have any questions.
# Authors: Kai-Chieh Hsu ( kaichieh@princeton.edu )
class _scheduler(object):
def __init__(self, last_epoch=-1, verbose=False):
self.cnt = last_epoch
self.verbose = verbose
self.variable = None
self.step()
... | class _Scheduler(object):
def __init__(self, last_epoch=-1, verbose=False):
self.cnt = last_epoch
self.verbose = verbose
self.variable = None
self.step()
def step(self):
self.cnt += 1
value = self.get_value()
self.variable = value
def get_value(self... |
#!/usr/bin/env python3
inp = []
with open('03.txt') as fp:
for line in fp:
inp.append(line.strip())
def part1(arr):
acc = [0] * len(arr[0])
for x in arr:
for i in range(len(x)):
acc[i] += int(x[i])
gamma = list(map(lambda x: '1' if x >= len(arr)/2.0 else '0', acc))
eps... | inp = []
with open('03.txt') as fp:
for line in fp:
inp.append(line.strip())
def part1(arr):
acc = [0] * len(arr[0])
for x in arr:
for i in range(len(x)):
acc[i] += int(x[i])
gamma = list(map(lambda x: '1' if x >= len(arr) / 2.0 else '0', acc))
epsilon = list(map(lambda ... |
# ac
N = int(input())
A = list(map(int,input().split()))
mid = int(2**N/2)
left, right = A[:mid], A[mid:]
second = min(max(left), max(right))
print(A.index(second)+1) | n = int(input())
a = list(map(int, input().split()))
mid = int(2 ** N / 2)
(left, right) = (A[:mid], A[mid:])
second = min(max(left), max(right))
print(A.index(second) + 1) |
# eln:decorators
READERS = dict()
# Decorator for adding reader functions
def register_reader(function):
READERS[function.__name__] = function
return function
| readers = dict()
def register_reader(function):
READERS[function.__name__] = function
return function |
# -*- coding: utf-8 -*-
'''
File name: code\permuted_matrices\sol_559.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #559 :: Permuted Matrices
#
# For more information see:
# https://projecteuler.net/problem=559
# Problem Statement
'''... | """
File name: code\\permuted_matrices\\sol_559.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
"""
'\nAn ascent of a column j in a matrix occurs if the value of column j is smaller than the value of column j+1 in all rows.\n\nLet P(k, r, n) be the number of r x n matrices with th... |
def assert_valid_git_hub_url(edit_on_github_url: str, page_path: str):
# Do you like to include yet another organization? Thing twice :)
url_lower = edit_on_github_url.lower()
assert \
url_lower.startswith('https://github.com/JetBrains/'.lower()) \
or \
url_lower.startswith('https:... | def assert_valid_git_hub_url(edit_on_github_url: str, page_path: str):
url_lower = edit_on_github_url.lower()
assert url_lower.startswith('https://github.com/JetBrains/'.lower()) or url_lower.startswith('https://github.com/kotlin/'.lower()), 'Check `edit_on_github_url` for `' + page_path + '` to be either `JetB... |
class RigPacket:
def __init__(self, velocity=0, direction=0):
self.velocity = velocity
self.direction = direction
| class Rigpacket:
def __init__(self, velocity=0, direction=0):
self.velocity = velocity
self.direction = direction |
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_varying_index_float.tif test_varying_index_float")
command += tes... | command += testshade('-t 1 -g 256 256 -od uint8 -o Cout out_varying_index_float.tif test_varying_index_float')
command += testshade('-t 1 -g 256 256 -od uint8 -o Cout out_varying_index_int.tif test_varying_index_int')
command += testshade('-t 1 -g 256 256 -od uint8 -o Cout out_varying_index_string.tif test_varying_inde... |
NL_MATERIAL = {
"math": {
"title": "Didactiek van wiskundig denken",
"text": "Leermateriaal over wiskunde en didactiek op de universiteit.",
"url": "https://maken.wikiwijs.nl/91192/Wiskundedidactiek_en_ICT",
"files": [
[{
"mime_type": "application/x-zip",
... | nl_material = {'math': {'title': 'Didactiek van wiskundig denken', 'text': 'Leermateriaal over wiskunde en didactiek op de universiteit.', 'url': 'https://maken.wikiwijs.nl/91192/Wiskundedidactiek_en_ICT', 'files': [[{'mime_type': 'application/x-zip', 'url': 'https://maken.wikiwijs.nl/91192/Wiskundedidactiek_en_ICT', '... |
# Suppose the cover price of a book is $24.95, but bookstores get a 40% discount.
# Shipping costs $3 for the first copy and 75 cents for each additional copy.
# What is the total wholesale cost for 60 copies?
print(round((24.95 - (24.95 * (40 / 100))) * 60 + 3 + 0.75 * 59, 2))
| print(round((24.95 - 24.95 * (40 / 100)) * 60 + 3 + 0.75 * 59, 2)) |
'''
Global Variables
Variables that are created outside of a function (as in all of the examples above) are known as global variables.
Global variables can be used by everyone, both inside of functions and outside.
'''
#Example
#Create a variable outside of a function, and use it inside the function
x = "awesome"
... | """
Global Variables
Variables that are created outside of a function (as in all of the examples above) are known as global variables.
Global variables can be used by everyone, both inside of functions and outside.
"""
x = 'awesome'
def myfunction():
print('python is ' + x)
myfunction()
'\n\nIf you create a var... |
''' 5. b.
To get a string from a given string where
all occurrences of its first char have been
changed to '$', except the first char itself.
'''
word = input("Enter a long word: ") #arastratiosphecomyia
first_char = word[0] # set first character of our string to first_char variable
new_string = fi... | """ 5. b.
To get a string from a given string where
all occurrences of its first char have been
changed to '$', except the first char itself.
"""
word = input('Enter a long word: ')
first_char = word[0]
new_string = first_char
for pointer in word[1:]:
if pointer == first_char:
new_string += '$'
... |
points = [[0, 0]]
n = int(input())
for i in range(n):
x, y = map(int, input().split())
points.append([x, y])
distance_pairs = []
for i in range(n + 1):
for j in range(i, n + 1):
dx = points[i][0] - points[j][0]
dy = points[i][1] - points[j][1]
distance_pairs.append([dx ** 2 + dy ** 2, i, j])
distanc... | points = [[0, 0]]
n = int(input())
for i in range(n):
(x, y) = map(int, input().split())
points.append([x, y])
distance_pairs = []
for i in range(n + 1):
for j in range(i, n + 1):
dx = points[i][0] - points[j][0]
dy = points[i][1] - points[j][1]
distance_pairs.append([dx ** 2 + dy **... |
'''
NetworkX betweenness centrality on a social network
Betweenness centrality is a node importance metric that uses information about the shortest paths in a network. It is defined as the fraction of all possible shortest paths between any pair of nodes that pass through the node.
NetworkX provides the nx.betweennes... | """
NetworkX betweenness centrality on a social network
Betweenness centrality is a node importance metric that uses information about the shortest paths in a network. It is defined as the fraction of all possible shortest paths between any pair of nodes that pass through the node.
NetworkX provides the nx.betweennes... |
#Desafio MDC
def mdc(numeros):
pass
if __name__ == '__main__':
print(mdc([21, 7])) #7
print(mdc([125, 40])) #5
print(mdc([9, 564, 66, 3])) #3
print(mdc([55, 22])) #11
print(mdc([15, 150])) #15
print(mdc([7, 9])) #1 | def mdc(numeros):
pass
if __name__ == '__main__':
print(mdc([21, 7]))
print(mdc([125, 40]))
print(mdc([9, 564, 66, 3]))
print(mdc([55, 22]))
print(mdc([15, 150]))
print(mdc([7, 9])) |
N = int(input())
K = int(input())
print(K % N)
| n = int(input())
k = int(input())
print(K % N) |
'''Test file for file_path_operations.py.'''
master = FileMaster('/Users/person1/Pictures/house.png')
test.describe('Description Test Cases')
test.assert_equals(master.extension(), 'png')
test.assert_equals(master.filename(), 'house')
test.assert_equals(master.dirpath(), '/Users/person1/Pictures/') | """Test file for file_path_operations.py."""
master = file_master('/Users/person1/Pictures/house.png')
test.describe('Description Test Cases')
test.assert_equals(master.extension(), 'png')
test.assert_equals(master.filename(), 'house')
test.assert_equals(master.dirpath(), '/Users/person1/Pictures/') |
class Solution:
# @param {int[]} nums a set of distinct positive integers
# @return {int[]} the largest subset
def largestDivisibleSubset(self, nums):
# Write your code here
if not nums:
return 0
nums = sorted(nums)
# n = len(nums)
dp, prev =... | class Solution:
def largest_divisible_subset(self, nums):
if not nums:
return 0
nums = sorted(nums)
(dp, prev) = ({}, {})
for num in nums:
dp[num] = 1
prev[num] = -1
last_num = nums[0]
for num in nums:
for factor in sel... |
def complicated_logic(first, second):
print(f"You passed: {first}, {second}")
# return first + second * 12 - 4 * 12
number1 = 10
number2 = 3
result = complicated_logic(number1, number2)
print(result)
| def complicated_logic(first, second):
print(f'You passed: {first}, {second}')
number1 = 10
number2 = 3
result = complicated_logic(number1, number2)
print(result) |
class Solution:
def powerfulIntegers(self, x: int, y: int, bound: int) -> List[int]:
ans = set()
for i in range(bound):
if pow(x,i) > bound or (x==1 and i>0):
break
for j in range(bound):
if pow(y,j) > bound or (y==1 and j>0):
... | class Solution:
def powerful_integers(self, x: int, y: int, bound: int) -> List[int]:
ans = set()
for i in range(bound):
if pow(x, i) > bound or (x == 1 and i > 0):
break
for j in range(bound):
if pow(y, j) > bound or (y == 1 and j > 0):
... |
class Node():
def __init__(self, val):
self.val = val
self.right = None
self.left = None
def insert(root, val):
if root is None:
return Node(val)
elif val < root.val:
root.left = insert(root.left, val)
elif val > root.val:
root.right = insert(root.right,... | class Node:
def __init__(self, val):
self.val = val
self.right = None
self.left = None
def insert(root, val):
if root is None:
return node(val)
elif val < root.val:
root.left = insert(root.left, val)
elif val > root.val:
root.right = insert(root.right, v... |
input()
num = set(map(int,input().split()))
prime = set([i for i in range(3,max(num)+1,2)])
for i in range(3,max(num)+1,2):
if i in prime:
prime -= set([i for i in range(i*2,max(num)+1,i)])
prime.add(2)
print(len(num.intersection(prime))) | input()
num = set(map(int, input().split()))
prime = set([i for i in range(3, max(num) + 1, 2)])
for i in range(3, max(num) + 1, 2):
if i in prime:
prime -= set([i for i in range(i * 2, max(num) + 1, i)])
prime.add(2)
print(len(num.intersection(prime))) |
# draw a rectangle
# rect(x, y, width, height)
rect(20, 50, 100, 200)
rect(130, 50, 100, 200)
oval(240, 50, 100, 200)
oval(20, 250, 100, 100)
oval(130, 250, 100, 100)
rect(240, 250, 100, 100)
for x in range(20, 300, 50):
rect(x, 370, 40, 40)
for x in range(20, 300, 50):
if random() > 0.5:
rect(x,... | rect(20, 50, 100, 200)
rect(130, 50, 100, 200)
oval(240, 50, 100, 200)
oval(20, 250, 100, 100)
oval(130, 250, 100, 100)
rect(240, 250, 100, 100)
for x in range(20, 300, 50):
rect(x, 370, 40, 40)
for x in range(20, 300, 50):
if random() > 0.5:
rect(x, 420, 40, 40)
else:
oval(x, 420, 40, 40) |
scores = {
"John": 81.5,
"Fred": 100,
"Chad": 50,
"Wopper": 30,
"Katie": 73
}
def calc_grade(score):
if score >= 91:
return "Outstanding"
elif score >= 81:
return "Exceeds Expectations"
elif score >= 71:
return "Acceptable"
elif score >= 61:
return "... | scores = {'John': 81.5, 'Fred': 100, 'Chad': 50, 'Wopper': 30, 'Katie': 73}
def calc_grade(score):
if score >= 91:
return 'Outstanding'
elif score >= 81:
return 'Exceeds Expectations'
elif score >= 71:
return 'Acceptable'
elif score >= 61:
return 'Needs Improvement'
... |
#!/usr/bin/env python3
'''
Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words.
You should return an array of all the anagrams or an empty array if there are none.
'''
def anagrams(word, words):
analis = []
for item in words:
... | """
Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words.
You should return an array of all the anagrams or an empty array if there are none.
"""
def anagrams(word, words):
analis = []
for item in words:
if sorted(word) ==... |
YEAR_CHOICES = (
(1,'First'),
(2,'Second'),
(3,'Third'),
(4,'Fourth'),
(5,'Fifth'),
)
| year_choices = ((1, 'First'), (2, 'Second'), (3, 'Third'), (4, 'Fourth'), (5, 'Fifth')) |
# day 6...
# count distinct questions or whatever
# parse forms from input file. Split by group!
def parse_forms(file):
raw = file.read()
# Ths smushes each group's responses together, to better facilitate part 1.
# I'm sure I'll regret this in part 2.
# grouplist = ["".join(p.splitlines()) for p in r... | def parse_forms(file):
raw = file.read()
grouplist = [p.splitlines() for p in raw.split('\n\n')]
return grouplist
def main():
with open('input/day6.txt') as f:
group_list = parse_forms(f)
sumcounts1 = 0
sumcounts2 = 0
for group in group_list:
groupset = {c for c in ''.join(g... |
#
# PySNMP MIB module DOCS-RPHY-PTP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DOCS-RPHY-PTP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:53:44 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, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_union, constraints_intersection, value_size_constraint) ... |
# -*- coding: utf-8 -*-
# @Author: ZwEin
# @Date: 2016-07-08 13:48:24
# @Last Modified by: ZwEin
# @Last Modified time: 2016-07-08 13:48:34
def attr_func_state(attr_vals):
pass | def attr_func_state(attr_vals):
pass |
# Domains list
DOMAINS = [
{ 'url': 'https://ifmo.su', 'message': '@guryn' }
]
# Notifications link from https://t.me/wbhkbot
WEBHOOK = ''
| domains = [{'url': 'https://ifmo.su', 'message': '@guryn'}]
webhook = '' |
@state_trigger("sensor.power_meter != '9999'")
def load_optimizer(value=None):
pass
| @state_trigger("sensor.power_meter != '9999'")
def load_optimizer(value=None):
pass |
## Alphabet war
## 7 kyu
## https://www.codewars.com/kata/59377c53e66267c8f6000027
def alphabet_war(fight):
l = dict(zip('wpbs', range(4,0,-1)))
r = dict(zip('mqdz', range(4,0,-1)))
left, right = 0,0
for char in fight:
if char in l:
left += l[char]
elif char ... | def alphabet_war(fight):
l = dict(zip('wpbs', range(4, 0, -1)))
r = dict(zip('mqdz', range(4, 0, -1)))
(left, right) = (0, 0)
for char in fight:
if char in l:
left += l[char]
elif char in r:
right += r[char]
if left > right:
return 'Left side wins!'
... |
class Solution:
# Codes (Accepted), O(n) time and space
def replaceDigits(self, s: str) -> str:
li, n = [], len(s)
for i in range(0, n, 2):
if i+1 < n:
code = ord(s[i]) + int(s[i+1])
li += [s[i], chr(code)]
else:
li.append(s... | class Solution:
def replace_digits(self, s: str) -> str:
(li, n) = ([], len(s))
for i in range(0, n, 2):
if i + 1 < n:
code = ord(s[i]) + int(s[i + 1])
li += [s[i], chr(code)]
else:
li.append(s[i])
return ''.join(li)
... |
class SubmissionStatus(object):
SUBMITTED = -4
WAITING = -3
JUDGING = -2
WRONG_ANSWER = -1
ACCEPTED = 0
TIME_LIMIT_EXCEEDED = 1
IDLENESS_LIMIT_EXCEEDED = 2
MEMORY_LIMIT_EXCEEDED = 3
RUNTIME_ERROR = 4
SYSTEM_ERROR = 5
COMPILE_ERROR = 6
SCORED = 7
REJECTED = 10
JUDGE_ERROR = 11
PRETEST_PASSE... | class Submissionstatus(object):
submitted = -4
waiting = -3
judging = -2
wrong_answer = -1
accepted = 0
time_limit_exceeded = 1
idleness_limit_exceeded = 2
memory_limit_exceeded = 3
runtime_error = 4
system_error = 5
compile_error = 6
scored = 7
rejected = 10
judg... |
str1 = "Liu Kang "
str2 = "Johnny Cage "
str3 = "Scorpion "
str4 = "Sub-Zero "
str5 = "Sonya "
str6 = "Test yo might! "
print(str1 + str2 + str3 + str4 + str5 + str6)
print(str3 * 5)
print(str3 * (5 + 4))
print(str3 * 5 + "4")
today = "Tuesday"
# bool - in operator
print("day" in today)
print("scorpion" in today)
... | str1 = 'Liu Kang '
str2 = 'Johnny Cage '
str3 = 'Scorpion '
str4 = 'Sub-Zero '
str5 = 'Sonya '
str6 = 'Test yo might! '
print(str1 + str2 + str3 + str4 + str5 + str6)
print(str3 * 5)
print(str3 * (5 + 4))
print(str3 * 5 + '4')
today = 'Tuesday'
print('day' in today)
print('scorpion' in today) |
# pylint: disable=missing-docstring
def stupid_function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9): # [too-many-arguments]
return arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
| def stupid_function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9):
return (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) |
class DsapiParams:
def __init__(self, limit=1, bundles = [], role=None, tenant=None, format = 'json'):
self.limit = limit
self.bundles = bundles
self.role = role
self.tenant = tenant
self.format = format
def formatForRequest(self):
formattedString = '?'
n... | class Dsapiparams:
def __init__(self, limit=1, bundles=[], role=None, tenant=None, format='json'):
self.limit = limit
self.bundles = bundles
self.role = role
self.tenant = tenant
self.format = format
def format_for_request(self):
formatted_string = '?'
n... |
def decode_flag(value, alphabet):
# Construct inverse alphabet.
map_inv = [0]*len(alphabet)
for i in range(len(alphabet)):
map_inv[alphabet[i]] = i
# Apply.
result = bytearray()
for i in range(len(value)):
c = value[i]
if i % 2 == 1:
c -= 1
cc = map_... | def decode_flag(value, alphabet):
map_inv = [0] * len(alphabet)
for i in range(len(alphabet)):
map_inv[alphabet[i]] = i
result = bytearray()
for i in range(len(value)):
c = value[i]
if i % 2 == 1:
c -= 1
cc = map_inv[c]
result.append(cc)
return res... |
###
### Copyright (C) 2019-2022 Intel Corporation
###
### SPDX-License-Identifier: BSD-3-Clause
###
subsampling = {
"Y800" : ("YUV400", 8),
"I420" : ("YUV420", 8),
"NV12" : ("YUV420", 8),
"YV12" : ("YUV420", 8),
"P010" : ("YUV420", 10),
"P012" : ("YUV420", 12),
"I010" : ("YUV420", 10),
"422H" : ("Y... | subsampling = {'Y800': ('YUV400', 8), 'I420': ('YUV420', 8), 'NV12': ('YUV420', 8), 'YV12': ('YUV420', 8), 'P010': ('YUV420', 10), 'P012': ('YUV420', 12), 'I010': ('YUV420', 10), '422H': ('YUV422', 8), '422V': ('YUV422', 8), 'YUY2': ('YUV422', 8), 'Y210': ('YUV422', 10), 'Y212': ('YUV422', 12), '444P': ('YUV444', 8), '... |
class Matrix:
def __init__(self, matrix_string):
self.row_string = matrix_string.splitlines()
self.matrix = [[int(num) for num in row.split()] for row in self.row_string]
def row(self, index):
return self.matrix[index -1]
def column(self, index):
return [row[index -1] for r... | class Matrix:
def __init__(self, matrix_string):
self.row_string = matrix_string.splitlines()
self.matrix = [[int(num) for num in row.split()] for row in self.row_string]
def row(self, index):
return self.matrix[index - 1]
def column(self, index):
return [row[index - 1] fo... |
# Leo colorizer control file for velocity mode.
# This file is in the public domain.
# Properties for velocity mode.
properties = {
"commentEnd": "*#",
"commentStart": "#*",
"lineComment": "##",
}
# Attributes dict for velocity_main ruleset.
velocity_main_attributes_dict = {
"default": "nu... | properties = {'commentEnd': '*#', 'commentStart': '#*', 'lineComment': '##'}
velocity_main_attributes_dict = {'default': 'null', 'digit_re': '', 'escape': '', 'highlight_digits': 'true', 'ignore_case': 'true', 'no_word_sep': ''}
velocity_velocity_attributes_dict = {'default': 'null', 'digit_re': '', 'escape': '', 'high... |
num_waves = 4
num_eqn = 5
num_aux = 5
# Conserved quantities
sigma_11 = 0
sigma_22 = 1
sigma_12 = 2
u = 3
v = 4
# Auxiliary variables
density = 0
lamda = 1
mu = 2
cp = 3
cs = 4
| num_waves = 4
num_eqn = 5
num_aux = 5
sigma_11 = 0
sigma_22 = 1
sigma_12 = 2
u = 3
v = 4
density = 0
lamda = 1
mu = 2
cp = 3
cs = 4 |
# encoding:utf-8
class Word:
def __init__(self, id, form, label):
self.id = id
self.org_form = form
self.form = form.lower()
self.label = label
def __str__(self):
values = [str(self.id), self.org_form, self.label]
return '\t'.join(values)
class Sentence:
d... | class Word:
def __init__(self, id, form, label):
self.id = id
self.org_form = form
self.form = form.lower()
self.label = label
def __str__(self):
values = [str(self.id), self.org_form, self.label]
return '\t'.join(values)
class Sentence:
def __init__(self,... |
def rsum(any_list):
'''(list of int) -> int
REQ: Length of the list must be greater than 0
This function will add up all the integers in the given list of integers
>>>rsum([9,1000,-1000,57,78,0])
144
>>>rsum([1])
1
'''
# Base case for one element
if len(any_list) == 1:
# ... | def rsum(any_list):
"""(list of int) -> int
REQ: Length of the list must be greater than 0
This function will add up all the integers in the given list of integers
>>>rsum([9,1000,-1000,57,78,0])
144
>>>rsum([1])
1
"""
if len(any_list) == 1:
return any_list[0]
else:
... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This file is part of Androwarn.
#
# Copyright (C) 2012, 2019, Thomas Debize <tdebize at mail.com>
# All rights reserved.
#
# Androwarn is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
#... | media_recorder__audio_source = {0: 'DEFAULT', 1: 'MIC', 2: 'VOICE_UPLINK', 3: 'VOICE_DOWNLINK', 4: 'VOICE_CALL', 5: 'CAMCORDER', 6: 'VOICE_RECOGNITION', 7: 'VOICE_COMMUNICATION', 8: 'REMOTE_SUBMIX', 9: 'UNPROCESSED'}
media_recorder__video_source = {0: 'DEFAULT', 1: 'CAMERA', 2: 'SURFACE'}
package_manager__package_info ... |
# network size
ict_head_size = None
# checkpointing
ict_load = None
bert_load = None
# data
titles_data_path = None
query_in_block_prob = 0.1
use_one_sent_docs = False
# training
report_topk_accuracies = []
# faiss index
faiss_use_gpu = False
block_data_path = None
# indexer
indexer_batch_size = 128
indexer_log_i... | ict_head_size = None
ict_load = None
bert_load = None
titles_data_path = None
query_in_block_prob = 0.1
use_one_sent_docs = False
report_topk_accuracies = []
faiss_use_gpu = False
block_data_path = None
indexer_batch_size = 128
indexer_log_interval = 1000 |
#
# PySNMP MIB module TFTIF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TFTIF-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:16:16 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... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, value_size_constraint, single_value_constraint, value_range_constraint) ... |
def partition(lista: list[int], low: int, high: int) -> int:
i = low
pivot = lista[high]
for j in range(low, high):
if lista[j] <= pivot:
# swap
lista[i], lista[j] = lista[j], lista[i]
i += 1
lista[i], lista[high] = lista[high], lista[i]
return i
def f... | def partition(lista: list[int], low: int, high: int) -> int:
i = low
pivot = lista[high]
for j in range(low, high):
if lista[j] <= pivot:
(lista[i], lista[j]) = (lista[j], lista[i])
i += 1
(lista[i], lista[high]) = (lista[high], lista[i])
return i
def find_k(lista: l... |
DATA_FOLDER = './materialist/data'
TEST_FOLDER = './materialist/data/test'
TRAIN_FOLDER = './materialist/data/train'
VALIDATION_FOLDER = './materialist/data/validation'
TEST_FILE = './materialist/data/test.json'
TRAIN_FILE = './materialist/data/train.json'
VALIDATION_FILE = './materialist/data/validation.json'
TEST_... | data_folder = './materialist/data'
test_folder = './materialist/data/test'
train_folder = './materialist/data/train'
validation_folder = './materialist/data/validation'
test_file = './materialist/data/test.json'
train_file = './materialist/data/train.json'
validation_file = './materialist/data/validation.json'
test_pic... |
print(f'This is the python code file bar.py and my name currently is:{__name__}')
if __name__ == 'bar':
print(f'I was imported as a module.')
print(f'bar.py __file__ variable:{__file__}')
print('If the slashes in the file path lean to the right then I am __main__')
| print(f'This is the python code file bar.py and my name currently is:{__name__}')
if __name__ == 'bar':
print(f'I was imported as a module.')
print(f'bar.py __file__ variable:{__file__}')
print('If the slashes in the file path lean to the right then I am __main__') |
class View:
@staticmethod
def show_message(message):
print(message)
@staticmethod
def get_input():
return input()
| class View:
@staticmethod
def show_message(message):
print(message)
@staticmethod
def get_input():
return input() |
class Test:
def ptr(self):
print(self)
print(self.__class__)
class Test2:
def ptr(baidu):
print(baidu)
print(baidu.__class__)
class people:
name = ''
age = 0
__weight = 0
def __init__(self, n, a, w):
self.name = n
self.age = a
self.__w... | class Test:
def ptr(self):
print(self)
print(self.__class__)
class Test2:
def ptr(baidu):
print(baidu)
print(baidu.__class__)
class People:
name = ''
age = 0
__weight = 0
def __init__(self, n, a, w):
self.name = n
self.age = a
self.__w... |
class LambdaContext(object):
def __init__(
self,
request_id="request_id",
function_name="my-function",
function_version="v1.0",
):
self.aws_request_id = request_id
self.function_name = function_name
self.function_version = function_version
def get_rem... | class Lambdacontext(object):
def __init__(self, request_id='request_id', function_name='my-function', function_version='v1.0'):
self.aws_request_id = request_id
self.function_name = function_name
self.function_version = function_version
def get_remaining_time_in_millis(self):
r... |
for i in range(int(input())):
n,m,x,y = [int(j) for j in input().split()]
if((n-1)%x==0 and (m-1)%y==0):
print('Chefirnemo')
elif(n-2>=0 and m-2>=0):
if((n-2)%x==0 and (m-2)%y==0):
print('Chefirnemo')
else:
print('Pofik')
else:
print('Pofik')
| for i in range(int(input())):
(n, m, x, y) = [int(j) for j in input().split()]
if (n - 1) % x == 0 and (m - 1) % y == 0:
print('Chefirnemo')
elif n - 2 >= 0 and m - 2 >= 0:
if (n - 2) % x == 0 and (m - 2) % y == 0:
print('Chefirnemo')
else:
print('Pofik')
... |
###################################################
# header_common.py
# This file contains common declarations.
# DO NOT EDIT THIS FILE!
###################################################
server_event_preset_message = 0
server_event_play_sound = 1
server_event_scene_prop_p... | server_event_preset_message = 0
server_event_play_sound = 1
server_event_scene_prop_play_sound = 2
server_event_play_sound_at_position = 3
server_event_agent_equip_armor = 4
server_event_player_set_slot = 5
server_event_scene_prop_set_slot = 6
server_event_faction_set_slot = 7
server_event_troop_set_slot = 8
server_eve... |
## class <nombre_del_objeto>:
## def <metodo_del_objeto>(self):
# variable -> atributos
# funciones -> metodos
def hola():
print("hola a todos")
hola()
class Persona:
def __init__(self, nombre):
self.nombre = nombre
def hola(self):
print("Hola a todos, soy", self.nombre)
de... | def hola():
print('hola a todos')
hola()
class Persona:
def __init__(self, nombre):
self.nombre = nombre
def hola(self):
print('Hola a todos, soy', self.nombre)
def agregar_apellido(self, apellido):
self.apellido = apellido
def agregar_edad(self, edad):
self.edad... |
#
# PySNMP MIB module CISCO-IETF-SCTP-EXT-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-IETF-SCTP-EXT-CAPABILITY
# Produced by pysmi-0.3.4 at Wed May 1 12:01:04 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_size_constraint, constraints_union, value_range_constraint) ... |
def first_last(s1):
# [out of bound error] s2 = s1[0] + s1[1] + s1[4] + s1[5]
# [out of bound error] s2 = s1[0] + s1[1] + s1[-2] + s1[-1]
# [false result] s2 = s1[0:2] + s1[-2:-1]
s2 = s1[0:2] + s1[-2:]
# [out of bound error] s2 = s1[:2] + s1[-2]
return s2
print(first_last("spring"))
p... | def first_last(s1):
s2 = s1[0:2] + s1[-2:]
return s2
print(first_last('spring'))
print(first_last('hello'))
print(first_last('a'))
print(first_last('abc')) |
ref = [
"A00002",
"A00005",
"A10001",
"A10002",
"A10003",
"A10004",
"A10005",
"A10006",
"A10007",
"A10008",
"A10009",
"A10010",
"A10011",
"A10012",
"A10013",
"A10014",
"A10015",
"A10016",
"A10017",
"A10018",
"A10019",
"A10020",
... | ref = ['A00002', 'A00005', 'A10001', 'A10002', 'A10003', 'A10004', 'A10005', 'A10006', 'A10007', 'A10008', 'A10009', 'A10010', 'A10011', 'A10012', 'A10013', 'A10014', 'A10015', 'A10016', 'A10017', 'A10018', 'A10019', 'A10020', 'A10021', 'A10022', 'A10023', 'A10024', 'A10025', 'A10026', 'A10027', 'A10028', 'A10029', 'A1... |
ROBOT_POSITION_RESSOURCE = '/robotposition'
CUBE_POSITION_RESSOURCE = '/cubeposition'
PATH_RESSOURCE = '/path'
FLAG_RESSOURCE = '/flag' | robot_position_ressource = '/robotposition'
cube_position_ressource = '/cubeposition'
path_ressource = '/path'
flag_ressource = '/flag' |
server = "uri.pi"
port = 4711
# well World
home = Vec3(-66.9487,7.0,-39.5313)
| server = 'uri.pi'
port = 4711
home = vec3(-66.9487, 7.0, -39.5313) |
# file handling
# 1) without using with statement
file = open('t1.txt', 'w')
file.write('hello world !')
file.close()
# 2) without using with statement
file = open('t2.txt', 'w')
try:
file.write('hello world')
finally:
file.close()
# 3) using with statement
with open('t3.txt', 'w') as file:
file.write('h... | file = open('t1.txt', 'w')
file.write('hello world !')
file.close()
file = open('t2.txt', 'w')
try:
file.write('hello world')
finally:
file.close()
with open('t3.txt', 'w') as file:
file.write('hello world !') |
#Will add a fixed header and return a sendable string (we should add pickle support here at some point somehow), also encodes the message for you
def createMsg(data):
msg = data
msg = f'{len(msg):<10}' + msg
return msg.encode("utf-8")
#streams data from the 'target' socket with an initial buffersiz... | def create_msg(data):
msg = data
msg = f'{len(msg):<10}' + msg
return msg.encode('utf-8')
def stream_data(target, bufferSize):
data = target.recv(bufferSize)
msglen = int(data[:bufferSize].strip())
decoded_data = ''
while len(decoded_data) < msglen:
print(decoded_data)
decod... |
class Solution:
def maxNonOverlapping(self, nums: List[int], target: int) -> int:
last = {0:-1}
s = 0
dp = [0]*len(nums)
for i in range(len(nums)):
s += nums[i]
if s-target in last:
dp[i] = max(dp[i-1] if i-1>=0 else 0, 1+ (dp[last[s-target]] if last... | class Solution:
def max_non_overlapping(self, nums: List[int], target: int) -> int:
last = {0: -1}
s = 0
dp = [0] * len(nums)
for i in range(len(nums)):
s += nums[i]
if s - target in last:
dp[i] = max(dp[i - 1] if i - 1 >= 0 else 0, 1 + (dp[la... |
def ascii_cipher(message, key):
pfactor = max(
i for i in range(2, abs(key)+1)
if is_prime(i) and key%i==0
)*(-1 if key<0 else 1)
return ''.join(chr((ord(c)+pfactor)%128) for c in message)
def is_prime(n):
if n < 2: return False
return all(... | def ascii_cipher(message, key):
pfactor = max((i for i in range(2, abs(key) + 1) if is_prime(i) and key % i == 0)) * (-1 if key < 0 else 1)
return ''.join((chr((ord(c) + pfactor) % 128) for c in message))
def is_prime(n):
if n < 2:
return False
return all((n % i != 0 for i in range(2, round(pow... |
def add_two(a, b):
'''Adds two numbers together'''
return a + b
def multiply_two(a, b):
'''Multiplies two numbers together'''
return a * b
| def add_two(a, b):
"""Adds two numbers together"""
return a + b
def multiply_two(a, b):
"""Multiplies two numbers together"""
return a * b |
# # example string
# string = 'cat'
# width = 5
# print right justified string
# print(string.rjust(width))
# print(string.rjust(width))
# # example string
# string = 'cat'
# width = 5
# fillchar = '*'
# # print right justified string
# print(string.rjust(width, fillchar))
# # .centre function
# string = "Python ... | size = 5
a = list(map(chr, range(97, 122)))
m = a[size - 1::-1] + a[:size]
print(m) |
def test_use_provider(accounts, networks):
with networks.fantom.local.use_provider("test"):
account = accounts.test_accounts[0]
account.transfer(account, 100)
| def test_use_provider(accounts, networks):
with networks.fantom.local.use_provider('test'):
account = accounts.test_accounts[0]
account.transfer(account, 100) |
class Field(object):
def render(self, field):
raise NotImplementedError('Field.render needs to be defined')
class Attr(Field):
def __init__(self, attr, default=None, type=None):
self.attr = attr
self.default = default
if type is None:
self.type = lambda x: x
... | class Field(object):
def render(self, field):
raise not_implemented_error('Field.render needs to be defined')
class Attr(Field):
def __init__(self, attr, default=None, type=None):
self.attr = attr
self.default = default
if type is None:
self.type = lambda x: x
... |
def set_elements_sum(a, b):
c = []
for i in range(len(a)):
result = a[i] + b[i]
c.append(result)
return c
ll = [1, 2, 3, 4, 5]
ll2 = [3, 4, 5, 6, 7]
print(set_elements_sum(ll, ll2))
# [4, 6, 8, 10, 12]
| def set_elements_sum(a, b):
c = []
for i in range(len(a)):
result = a[i] + b[i]
c.append(result)
return c
ll = [1, 2, 3, 4, 5]
ll2 = [3, 4, 5, 6, 7]
print(set_elements_sum(ll, ll2)) |
# URI Online Judge 1133
X = int(input())
Y = int(input())
soma = 0
if Y < X:
X, Y = Y, X
for i in range(X,Y+1):
if i%13!=0:
soma += i
print(soma) | x = int(input())
y = int(input())
soma = 0
if Y < X:
(x, y) = (Y, X)
for i in range(X, Y + 1):
if i % 13 != 0:
soma += i
print(soma) |
salario = float(input())
if (salario >= 0 and salario <= 2000.00):
print('Isento')
elif (salario >= 2000.01 and salario <= 3000.00):
resto = salario - 2000
resul = resto * 0.08
print('R$ {:.2f}'.format(resul))
elif (salario >= 3000.01 and salario <= 4500.00):
resto = salario - 3000
resul = (res... | salario = float(input())
if salario >= 0 and salario <= 2000.0:
print('Isento')
elif salario >= 2000.01 and salario <= 3000.0:
resto = salario - 2000
resul = resto * 0.08
print('R$ {:.2f}'.format(resul))
elif salario >= 3000.01 and salario <= 4500.0:
resto = salario - 3000
resul = resto * 0.18 +... |
for i in range(int(input())):
a, b, c = map(int, input().split())
mi = min(a, b)
ma = max(a, b)
half_circle_people = (ma - mi)
full_circle_people = 2 * half_circle_people
if ma > half_circle_people * 2 or c > full_circle_people:
print(-1)
else:
print((c - half_circle_people... | for i in range(int(input())):
(a, b, c) = map(int, input().split())
mi = min(a, b)
ma = max(a, b)
half_circle_people = ma - mi
full_circle_people = 2 * half_circle_people
if ma > half_circle_people * 2 or c > full_circle_people:
print(-1)
else:
print((c - half_circle_people -... |
# model settings
model = dict(
type='Recognizer3DRPL',
backbone=dict(
type='ResNet3dSlowOnly',
depth=50,
pretrained='torchvision://resnet50',
lateral=False,
out_indices=(2, 3),
conv1_kernel=(1, 7, 7),
conv1_stride_t=1,
pool1_stride_t=1,
inf... | model = dict(type='Recognizer3DRPL', backbone=dict(type='ResNet3dSlowOnly', depth=50, pretrained='torchvision://resnet50', lateral=False, out_indices=(2, 3), conv1_kernel=(1, 7, 7), conv1_stride_t=1, pool1_stride_t=1, inflate=(0, 0, 1, 1), norm_eval=False), neck=dict(type='TPN', in_channels=(1024, 2048), out_channels=1... |
def make_divider():
return {"type": "divider"}
def make_markdown(text):
return {"type": "mrkdwn", "text": text }
def make_section(text):
return {"type":"section", "text": make_markdown(text)}
def make_context(*args):
return {"type":"context", "elements": [*args]}
def make_blocks(*args):
return [... | def make_divider():
return {'type': 'divider'}
def make_markdown(text):
return {'type': 'mrkdwn', 'text': text}
def make_section(text):
return {'type': 'section', 'text': make_markdown(text)}
def make_context(*args):
return {'type': 'context', 'elements': [*args]}
def make_blocks(*args):
return ... |
# generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/nvidia/linorobot_ws/src/imu_calib/include;/usr/local/include/eigen3".split(';') if "/home/nvidia/linorobot_ws/src/imu_calib/include;/usr/local/include/eigen3" != "" else []
PROJECT_CATKIN_DEPENDS... | catkin_package_prefix = ''
project_pkg_config_include_dirs = '/home/nvidia/linorobot_ws/src/imu_calib/include;/usr/local/include/eigen3'.split(';') if '/home/nvidia/linorobot_ws/src/imu_calib/include;/usr/local/include/eigen3' != '' else []
project_catkin_depends = 'cmake_modules;roscpp;sensor_msgs;lino_msgs'.replace('... |
numero = int(input("Entre com um numero inteiro e menor que 1000: "))
if numero > 1000:
print("Numero invalido")
else:
unidade = numero % 10
numero = (numero - unidade) / 10
dezena = int(numero % 10)
numero = (numero - dezena) / 10
centena = int(numero)
print(f"{centena} centena(s) , {dezena... | numero = int(input('Entre com um numero inteiro e menor que 1000: '))
if numero > 1000:
print('Numero invalido')
else:
unidade = numero % 10
numero = (numero - unidade) / 10
dezena = int(numero % 10)
numero = (numero - dezena) / 10
centena = int(numero)
print(f'{centena} centena(s) , {dezena... |
def str_to_bool(s):
if isinstance(s, bool): # do not convert if already a boolean
return s
else:
if s == 'True' \
or s == 'true' \
or s == '1' \
or s == 1 \
or s == True:
return True
elif s == 'False' \
... | def str_to_bool(s):
if isinstance(s, bool):
return s
elif s == 'True' or s == 'true' or s == '1' or (s == 1) or (s == True):
return True
elif s == 'False' or s == 'false' or s == '0' or (s == 0) or (s == False):
return False
return False |
class Solution:
def compareVersion(self, version1: str, version2: str) -> int:
ver1 = version1.split('.')
ver2 = version2.split('.')
def removeLeadingZeros(s):
while len(s) > 1 and s[0] == '0':
s = s[1:]
return s
ver1... | class Solution:
def compare_version(self, version1: str, version2: str) -> int:
ver1 = version1.split('.')
ver2 = version2.split('.')
def remove_leading_zeros(s):
while len(s) > 1 and s[0] == '0':
s = s[1:]
return s
ver1 = [remove_leading_zer... |
GUIDs = {
"ASROCK_ACPIS4_DXE_GUID": [69196166, 45078, 18382, 175, 197, 34, 105, 237, 212, 173, 100],
"ASROCK_USBRT_GUID": [82487969, 10657, 4567, 136, 56, 0, 80, 4, 115, 212, 235],
"ASROCK_RAID_SETUP_GUID": [152494882, 14144, 12750, 173, 98, 189, 23, 44, 236, 202, 54],
"ASROCK_RAID_LOADER_GUID": [16450... | gui_ds = {'ASROCK_ACPIS4_DXE_GUID': [69196166, 45078, 18382, 175, 197, 34, 105, 237, 212, 173, 100], 'ASROCK_USBRT_GUID': [82487969, 10657, 4567, 136, 56, 0, 80, 4, 115, 212, 235], 'ASROCK_RAID_SETUP_GUID': [152494882, 14144, 12750, 173, 98, 189, 23, 44, 236, 202, 54], 'ASROCK_RAID_LOADER_GUID': [164506669, 19843, 1759... |
'''
Python program to convert the distance (in feet) to inches,yards, and miles
'''
def distanceInInches (d_ft):
print("The distance in inches is %i inches." %(d_ft * 12))
def distanceInYard (d_ft):
print("The distance in yards is %.2f yards." %(d_ft / 3.0))
def distanceInMiles (d_ft):
print("The distanc... | """
Python program to convert the distance (in feet) to inches,yards, and miles
"""
def distance_in_inches(d_ft):
print('The distance in inches is %i inches.' % (d_ft * 12))
def distance_in_yard(d_ft):
print('The distance in yards is %.2f yards.' % (d_ft / 3.0))
def distance_in_miles(d_ft):
print('The di... |
def somme(liste_nombres):
pass
def moyenne(liste_nombres):
pass
| def somme(liste_nombres):
pass
def moyenne(liste_nombres):
pass |
class Solution:
def solve(self, genes):
ans = 0
seen = set()
genes = set(genes)
for gene in genes:
if gene in seen:
continue
ans += 1
dfs = [gene]
seen.add(gene)
while dfs:
cur = dfs.pop()
... | class Solution:
def solve(self, genes):
ans = 0
seen = set()
genes = set(genes)
for gene in genes:
if gene in seen:
continue
ans += 1
dfs = [gene]
seen.add(gene)
while dfs:
cur = dfs.pop()
... |
class Constants:
# DATA TYPES
GENERATE_EPR_IF_NONE = 'generate_epr_if_none'
AWAIT_ACK = 'await_ack'
SEQUENCE_NUMBER = 'sequence_number'
PAYLOAD = 'payload'
PAYLOAD_TYPE = 'payload_type'
SENDER = 'sender'
RECEIVER = 'receiver'
PROTOCOL = 'protocol'
KEY = 'key'
# WAIT TIME
... | class Constants:
generate_epr_if_none = 'generate_epr_if_none'
await_ack = 'await_ack'
sequence_number = 'sequence_number'
payload = 'payload'
payload_type = 'payload_type'
sender = 'sender'
receiver = 'receiver'
protocol = 'protocol'
key = 'key'
wait_time = 10
epr = 0
da... |
#--------------------------------------------------------------------#
# Help program.
# Created by: Jim - https://www.youtube.com/watch?v=XCgWYx-lGl8
# Changed by: Thiago Piovesan
#--------------------------------------------------------------------#
# When to use class methods and when to use static methods ?
#-----... | class Item:
@staticmethod
def is_integer():
"""
This should do something that has a relationship
with the class, but not something that must be unique
per instance!
"""
@classmethod
def instantiate_from_something(cls):
"""
This should also do som... |
FIPS_Reference = {
"AL":"01",
"AK":"02",
"AZ":"04",
"AR":"05",
"AS":"60",
"CA":"06",
"CO":"08",
"CT":"09",
"DE":"10",
"FL":"12",
"GA":"13",
"GU":"66",
"HI":"15",
"ID":"16",
"IL":"17",
"IN":"18... | fips__reference = {'AL': '01', 'AK': '02', 'AZ': '04', 'AR': '05', 'AS': '60', 'CA': '06', 'CO': '08', 'CT': '09', 'DE': '10', 'FL': '12', 'GA': '13', 'GU': '66', 'HI': '15', 'ID': '16', 'IL': '17', 'IN': '18', 'IA': '19', 'KS': '20', 'KY': '21', 'LA': '22', 'ME': '23', 'MD': '24', 'MA': '25', 'MI': '26', 'MN': '27', '... |
def check_full_text(fb_full_text, filter_full_text) -> bool:
if filter_full_text is None or fb_full_text == filter_full_text:
return True
return False
def check_contains(fb_contains, filter_contains) -> bool:
if filter_contains is None:
return True
intersection = list(fb_contains & fil... | def check_full_text(fb_full_text, filter_full_text) -> bool:
if filter_full_text is None or fb_full_text == filter_full_text:
return True
return False
def check_contains(fb_contains, filter_contains) -> bool:
if filter_contains is None:
return True
intersection = list(fb_contains & filt... |
class Solution:
def maxRotateFunction(self, nums: List[int]) -> int:
sums = sum(nums)
index = 0
res = 0
for ele in nums:
res += index*ele
index += 1
ans = res
for i in range(1,len(nums)):
res = res + sums - (len(nums))*nums[len(nums... | class Solution:
def max_rotate_function(self, nums: List[int]) -> int:
sums = sum(nums)
index = 0
res = 0
for ele in nums:
res += index * ele
index += 1
ans = res
for i in range(1, len(nums)):
res = res + sums - len(nums) * nums[le... |
def is_even(n):
return n % 2 == 0
def is_odd(n):
return not is_even(n)
lost_numbers = (4, 8, 15, 16, 23, 42)
| def is_even(n):
return n % 2 == 0
def is_odd(n):
return not is_even(n)
lost_numbers = (4, 8, 15, 16, 23, 42) |
# You are given two non-empty linked lists representing two non-negative integers.
# The digits are stored in reverse order and each of their nodes contain a single digit.
# Add the two numbers and return it as a linked list.
# You may assume the two numbers do not contain any leading zero, except the number 0 itself... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def add_two_numbers(self, l1, l2):
dummy = list_node(-1)
cur = dummy
t = 0
while l1 or l2 or t:
if l1:
t += l1.val
l... |
# Given two strings s and t, determine if they are isomorphic.
# Two strings s and t are isomorphic if the characters in s can be replaced to
# get t.
# All occurrences of a character must be replaced with another character while
# preserving the order of characters. No two characters may map to the same
# character,... | class Dictsetsolution:
def is_isomorphic(self, s: str, t: str) -> bool:
replacements = {}
mapped = set()
for (s_let, t_let) in zip(s, t):
if (replacement := replacements.get(s_let)):
if replacement != t_let:
return False
else:
... |
def mergeSort(elements):
if len(elements) == 0 or len(elements) == 1:
# BASE CASE
return elements
middle = len(elements) // 2
left = mergeSort(elements[:middle])
right = mergeSort(elements[middle:])
if left == [] or right == []:
return left or right
result = []
i, ... | def merge_sort(elements):
if len(elements) == 0 or len(elements) == 1:
return elements
middle = len(elements) // 2
left = merge_sort(elements[:middle])
right = merge_sort(elements[middle:])
if left == [] or right == []:
return left or right
result = []
(i, j) = (0, 0)
whi... |
__author__ = 'James Myatt'
__version__ = '0.0.2'
__all__ = [
'monitor', 'sensor', 'utils',
'time', 'w1therm'
]
| __author__ = 'James Myatt'
__version__ = '0.0.2'
__all__ = ['monitor', 'sensor', 'utils', 'time', 'w1therm'] |
class SocketAPIError(Exception):
pass
class InvalidRequestError(SocketAPIError):
pass
class InvalidURIError(InvalidRequestError):
pass
class NotFoundError(InvalidRequestError):
pass
| class Socketapierror(Exception):
pass
class Invalidrequesterror(SocketAPIError):
pass
class Invalidurierror(InvalidRequestError):
pass
class Notfounderror(InvalidRequestError):
pass |
# Prints out a string
print("Mary had a little lamb.")
# Prints out a formatted string
print("Its fleece was white as {}.".format('snow'))
# Prints out another string
print("and everywhere that Mary went.")
# Prints a period for ten times
print("." * 10) # what'd that do?
# Assign a letter to string variable
end1 = "... | print('Mary had a little lamb.')
print('Its fleece was white as {}.'.format('snow'))
print('and everywhere that Mary went.')
print('.' * 10)
end1 = 'C'
end2 = 'h'
end3 = 'e'
end4 = 'e'
end5 = 's'
end6 = 'e'
end7 = 'B'
end8 = 'u'
end9 = 'r'
end10 = 'g'
end11 = 'e'
end12 = 'r'
print(end1 + end2 + end3 + end4 + end5 + end... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class HookitConnectionError(Exception):
pass
__all__ = ['HookitConnectionError']
| class Hookitconnectionerror(Exception):
pass
__all__ = ['HookitConnectionError'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.