content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
with open ('2gram_output_birkbeck.txt') as f:
with open ('../data/birkbeck_correct.txt') as g:
corrects = []
i = 0
for line in g:
corrects.append(line.strip())
for line in f:
try:
A = line.split(' potential diatance_word:(')
... | with open('2gram_output_birkbeck.txt') as f:
with open('../data/birkbeck_correct.txt') as g:
corrects = []
i = 0
for line in g:
corrects.append(line.strip())
for line in f:
try:
a = line.split(' potential diatance_word:(')
mis... |
def set_session_user_profile(request, profile=None):
user_profile = {
'use_pop_article': True,
'theme': '',
'is_authenticated': request.user.is_authenticated
}
if profile:
user_profile['use_pop_article'] = profile.use_pop_article
user_profile['theme'] = profile.theme
... | def set_session_user_profile(request, profile=None):
user_profile = {'use_pop_article': True, 'theme': '', 'is_authenticated': request.user.is_authenticated}
if profile:
user_profile['use_pop_article'] = profile.use_pop_article
user_profile['theme'] = profile.theme
request.session['user_prof... |
class Solution(object):
def readBinaryWatch(self, num):
"""
:type num: int
:rtype: List[str]
"""
ans=[]
for i in range(2**10):
if(bin(i).count('1')==num):
minute = i & 0b0000111111
hour = i>>6
if h... | class Solution(object):
def read_binary_watch(self, num):
"""
:type num: int
:rtype: List[str]
"""
ans = []
for i in range(2 ** 10):
if bin(i).count('1') == num:
minute = i & 63
hour = i >> 6
if hour < 12... |
def squared(n):
return n * n
def cubed(n):
return n * n * n
def raise_power(n, power):
total = 1
for t in range (power) :
total = total * n
return total
def is_divisible(n, t):
return n % t == 0
def is_even(n):
return n % 2 == 0
def is_odd(n):
return n % 2 != 0
p... | def squared(n):
return n * n
def cubed(n):
return n * n * n
def raise_power(n, power):
total = 1
for t in range(power):
total = total * n
return total
def is_divisible(n, t):
return n % t == 0
def is_even(n):
return n % 2 == 0
def is_odd(n):
return n % 2 != 0
print(list(map(... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def buildTree(self, inorder, postorder):
"""
:type inorder: List[int]
:type postorder: List[int]
:rtype: ... | class Solution:
def build_tree(self, inorder, postorder):
"""
:type inorder: List[int]
:type postorder: List[int]
:rtype: TreeNode
"""
if not postorder:
return None
node = postorder.pop()
root = tree_node(node)
index = inorder.inde... |
# -*- coding: utf-8 -*-
"""
Top-level package for {{ cookiecutter.municipality }}
CDP instance backend.
"""
__author__ = "{{ cookiecutter.maintainer_full_name }}"
__version__ = "1.0.0"
def get_module_version() -> str:
return __version__
| """
Top-level package for {{ cookiecutter.municipality }}
CDP instance backend.
"""
__author__ = '{{ cookiecutter.maintainer_full_name }}'
__version__ = '1.0.0'
def get_module_version() -> str:
return __version__ |
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@berty_go//:repositories.bzl", "berty_go_repositories")
def berty_bridge_repositories():
# utils
maybe(... | load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe')
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
load('@berty_go//:repositories.bzl', 'berty_go_repositories')
def berty_bridge_repositories():
maybe(git_reposito... |
LOCATION_TERMS = ['city', 'sub_region', 'region', 'country']
def get_geographical_granularity(data):
"""Returns the index of the lowest granularity level available in data."""
for index, term in enumerate(LOCATION_TERMS):
if term in data.columns:
return index
def check_column_and_get_ind... | location_terms = ['city', 'sub_region', 'region', 'country']
def get_geographical_granularity(data):
"""Returns the index of the lowest granularity level available in data."""
for (index, term) in enumerate(LOCATION_TERMS):
if term in data.columns:
return index
def check_column_and_get_ind... |
def score(name=tom,score=0):
print(name," scored ", score )
| def score(name=tom, score=0):
print(name, ' scored ', score) |
# estos es un cometario en python
#decalro una variable
x = 5
# imprime variable
print ("x =",x)
#operaciones aritmeticas
print ("x - 5 = ",x - 5)
print ("x + 5 = ",x + 5)
print ("x * 5 = ",x * 5)
print ("x % 5 = ",x % 5)
print ("x / 5 = ",x /5)
print ("x // 5 = ",x //5)
print ("x ** 5 = ",x **5) | x = 5
print('x =', x)
print('x - 5 = ', x - 5)
print('x + 5 = ', x + 5)
print('x * 5 = ', x * 5)
print('x % 5 = ', x % 5)
print('x / 5 = ', x / 5)
print('x // 5 = ', x // 5)
print('x ** 5 = ', x ** 5) |
class PushwooshException(Exception):
pass
class PushwooshCommandException(PushwooshException):
pass
class PushwooshNotificationException(PushwooshException):
pass
class PushwooshFilterException(PushwooshException):
pass
class PushwooshFilterInvalidOperatorException(PushwooshFilterException):
... | class Pushwooshexception(Exception):
pass
class Pushwooshcommandexception(PushwooshException):
pass
class Pushwooshnotificationexception(PushwooshException):
pass
class Pushwooshfilterexception(PushwooshException):
pass
class Pushwooshfilterinvalidoperatorexception(PushwooshFilterException):
pas... |
"""
The deal with super is that you can easily call
a function of a parent or a sister class that you have inherited, without
necessarily calling the classes then their functions
an example
"""
class Parent:
def __init__(self, i):
print(i)
class Sister:
def __init__(self):
print("asda")
cla... | """
The deal with super is that you can easily call
a function of a parent or a sister class that you have inherited, without
necessarily calling the classes then their functions
an example
"""
class Parent:
def __init__(self, i):
print(i)
class Sister:
def __init__(self):
print('asda')
cl... |
#
# PySNMP MIB module CISCO-ENTITY-SENSOR-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ENTITY-SENSOR-CAPABILITY
# Produced by pysmi-0.3.4 at Mon Apr 29 17:39:53 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, constraints_intersection, single_value_constraint, value_size_constraint) ... |
"""
Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all equal.
Example 1:
Input: nums = [4, 3, 2, 3, 5, 2, 1], k = 4
Output: True
Explanation: It's possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with e... | """
Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all equal.
Example 1:
Input: nums = [4, 3, 2, 3, 5, 2, 1], k = 4
Output: True
Explanation: It's possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with e... |
# -*- coding: utf-8 -*-
__author__ = 'Alfredo Cobo'
__email__ = 'ajscobo@gmail.com'
__version__ = '0.1.0' | __author__ = 'Alfredo Cobo'
__email__ = 'ajscobo@gmail.com'
__version__ = '0.1.0' |
in_file = 'report_suis.tsv'
biovar_list = ['bv01', 'bv02', 'bv03', 'bv04', 'bv05']
for biovar in biovar_list:
if biovar == 'bv04':
t=1
bv = biovar[-1]
preID = 0
pos = 0
pcrID = 0
anyID = 0
justPCR = 0
false_pos = 0
false_neg = 0
with open(in_file, 'r') as f:
for... | in_file = 'report_suis.tsv'
biovar_list = ['bv01', 'bv02', 'bv03', 'bv04', 'bv05']
for biovar in biovar_list:
if biovar == 'bv04':
t = 1
bv = biovar[-1]
pre_id = 0
pos = 0
pcr_id = 0
any_id = 0
just_pcr = 0
false_pos = 0
false_neg = 0
with open(in_file, 'r') as f:
... |
# 18. Write a Python program to calculate the sum of three given numbers, if the values are equal then return three times of their sum.
# Question:
# Input:
# Output:
# Solution: https://www.w3resource.com/python-exercises/python-basic-exercise-18.php
# Ideas:
"""
1.
"""
# Steps:
"""
"""
# Notes:
"""
"""
# C... | """
1.
"""
' \n'
'\n'
def sum_three_times(a, b, c):
if a == b == c:
return (a + b + c) * 3
else:
return a + b + c
print(sum_three_times(1, 2, 3))
print(sum_three_times(6, 6, 6))
' \n' |
# Create a class called Triangle with 3 instances variables that represents 3 angles of triangle. Its __init__() method should take self, angle1, angle2, and angle3 as
# arguments. Make sure to set these appropriately in the body of the __init__() method. Create a method named check_angles(self). It should return True ... | class Triangle:
def _init_(self, angle1, angle2, angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3
def check_angles(self):
if self.angle1 + self.angle2 + self.angle3 == 180:
return True
else:
return False |
fields_masks = {
'background': "sheets/data/rowData/values/effectiveFormat/backgroundColor",
'value': "sheets/data/rowData/values/formattedValue",
'note': "sheets/data/rowData/values/note",
'font_color': "sheets/data/rowData/values/effectiveFormat/textFormat/foregroundColor"
}
| fields_masks = {'background': 'sheets/data/rowData/values/effectiveFormat/backgroundColor', 'value': 'sheets/data/rowData/values/formattedValue', 'note': 'sheets/data/rowData/values/note', 'font_color': 'sheets/data/rowData/values/effectiveFormat/textFormat/foregroundColor'} |
def tuple_to_string(tuple):
string = ''
for i in range(0, len(tuple)):
num = tuple[i]
char = chr(num)
string += str(char)
return string | def tuple_to_string(tuple):
string = ''
for i in range(0, len(tuple)):
num = tuple[i]
char = chr(num)
string += str(char)
return string |
# -*- coding: utf-8 -*-
"""
resultsExport.py
A small command-line tool to calculate mileage statistics for a personally-owned vehicle.
Handles results export to Python objects, ready for use in a Jinja HTML template.
""" | """
resultsExport.py
A small command-line tool to calculate mileage statistics for a personally-owned vehicle.
Handles results export to Python objects, ready for use in a Jinja HTML template.
""" |
# formatting colors
reset = "\033[0m"
red = "\033[0;31m"
green = "\033[0;32m"
yellow = "\033[0;33m"
blue = "\033[0;34m"
purple = "\033[0;35m"
BRed = "\033[1;31m"
BYellow = "\033[1;33m"
BBlue = "\033[1;34m"
BPurple = "\033[1;35m"
On_Black = "\033[40m"
BIRed = "\033[1;91m"
BIYellow = "\033[1;93m"
BIBlue = "... | reset = '\x1b[0m'
red = '\x1b[0;31m'
green = '\x1b[0;32m'
yellow = '\x1b[0;33m'
blue = '\x1b[0;34m'
purple = '\x1b[0;35m'
b_red = '\x1b[1;31m'
b_yellow = '\x1b[1;33m'
b_blue = '\x1b[1;34m'
b_purple = '\x1b[1;35m'
on__black = '\x1b[40m'
bi_red = '\x1b[1;91m'
bi_yellow = '\x1b[1;93m'
bi_blue = '\x1b[1;94m'
bi_purple = '\... |
def count(sequence, item):
amount = 0
for x in sequence:
if x == item:
amount += 1
return amount
| def count(sequence, item):
amount = 0
for x in sequence:
if x == item:
amount += 1
return amount |
'''
Write a Python program to get the sum of a non-negative integer.
'''
class Solution:
def __init__(self, num):
self.num = num
def sum_digits(self, x):
if x == 1:
return int(str(self.num)[-1])
else:
return int(str(self.num)[-x]) + self.sum_digits(x-1)
def s... | """
Write a Python program to get the sum of a non-negative integer.
"""
class Solution:
def __init__(self, num):
self.num = num
def sum_digits(self, x):
if x == 1:
return int(str(self.num)[-1])
else:
return int(str(self.num)[-x]) + self.sum_digits(x - 1)
def ... |
'#La nomenclatura utilizada es INSTANCIA_ESQUEMA_PWD'
FISCO_USER = 'FISCAR'
FISCO_FISCAR_PWD = 'FISCAR'
'#String de conexion '
FISCO_CONNECTION_STRING = '10.30.205.127/fisco'
| """#La nomenclatura utilizada es INSTANCIA_ESQUEMA_PWD"""
fisco_user = 'FISCAR'
fisco_fiscar_pwd = 'FISCAR'
'#String de conexion '
fisco_connection_string = '10.30.205.127/fisco' |
def hamming_distance(string1, string2):
assert len(string1) == len(string2)
distance = 0
for i in range(len(string1)):
if string1[i] != string2[i]:
distance += 1
return distance
'''def results(string1, string2):
print(hamming_distance(string1, string2))
results('CGTGAGATAGCATATGGTAAATGTTCCGCAATCGCTACCGCC... | def hamming_distance(string1, string2):
assert len(string1) == len(string2)
distance = 0
for i in range(len(string1)):
if string1[i] != string2[i]:
distance += 1
return distance
"def results(string1, string2):\n\tprint(hamming_distance(string1, string2))\n\nresults('CGTGAGATAGCATATGG... |
# -*- coding: utf-8 -*-
__author__ = 'Hamish Downer'
__email__ = 'hamish@aptivate.org'
__version__ = '0.1.0'
| __author__ = 'Hamish Downer'
__email__ = 'hamish@aptivate.org'
__version__ = '0.1.0' |
class SparkPostException(Exception):
pass
class SparkPostAPIException(SparkPostException):
"Handle 4xx and 5xx errors from the SparkPost API"
def __init__(self, response, *args, **kwargs):
# noinspection PyBroadException
try:
errors = response.json()['errors']
error... | class Sparkpostexception(Exception):
pass
class Sparkpostapiexception(SparkPostException):
"""Handle 4xx and 5xx errors from the SparkPost API"""
def __init__(self, response, *args, **kwargs):
try:
errors = response.json()['errors']
error_template = '{message} Code: {code} ... |
{
"targets": [
{
"target_name": "switch_bindings",
"sources": [
"src/switch_bindings.cpp",
"src/log-utils/logging.c",
"src/log-utils/log_core.c",
"src/common-utils/common_utils.c",
"src/shm_core/shm_dup.c",
"src/shm_core/shm_data.c",
"src/shm_core/shm_mutex.c... | {'targets': [{'target_name': 'switch_bindings', 'sources': ['src/switch_bindings.cpp', 'src/log-utils/logging.c', 'src/log-utils/log_core.c', 'src/common-utils/common_utils.c', 'src/shm_core/shm_dup.c', 'src/shm_core/shm_data.c', 'src/shm_core/shm_mutex.c', 'src/shm_core/shm_datatypes.c', 'src/shm_core/shm_apr.c', 'src... |
def main():
n = int(input())
for a in range(1, 10):
b = n / a
if 1 <= b and b <= 9 and b % 1 == 0:
print('Yes')
exit()
print('No')
if __name__ == '__main__':
main()
| def main():
n = int(input())
for a in range(1, 10):
b = n / a
if 1 <= b and b <= 9 and (b % 1 == 0):
print('Yes')
exit()
print('No')
if __name__ == '__main__':
main() |
x = int(input("Enter number"))
for i in range(x):
a = list(str(i))
sum1 = 0
for j in range(len(a)):
b = int(a[j])**len(a)
sum1 = sum1 + b
if i == sum1:
print (i,"amstrong")
| x = int(input('Enter number'))
for i in range(x):
a = list(str(i))
sum1 = 0
for j in range(len(a)):
b = int(a[j]) ** len(a)
sum1 = sum1 + b
if i == sum1:
print(i, 'amstrong') |
x = int(input("Please enter the first digit"))
y = int(input("Please enter the second digit"))
output_list = []
while len(output_list) < x - 1:
for i in range(0, x):
list_2d = []
output_list.append(list_2d)
for j in range(0 ,y):
number = i * j
output_list[i].append... | x = int(input('Please enter the first digit'))
y = int(input('Please enter the second digit'))
output_list = []
while len(output_list) < x - 1:
for i in range(0, x):
list_2d = []
output_list.append(list_2d)
for j in range(0, y):
number = i * j
output_list[i].append(nu... |
# -*- Python -*-
# Copyright 2021 The Verible Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | """
Rule to generate json-serializable simple structs
"""
def jcxxgen(name, src, out, namespace=''):
"""Generate C/C++ language source from a jcxxgen schema file.
Args:
name: Name of the rule, producing a cc-library with the same name.
src: The schema yaml input file.
out: Name of the gene... |
class Player():
def __init__(self, name):
self.name = name
self.force = 0.0
def set_force(self, force):
self.force = force
| class Player:
def __init__(self, name):
self.name = name
self.force = 0.0
def set_force(self, force):
self.force = force |
def combine_nonblank_lines(content: list[str], sep: str = " ") -> list[str]:
content = [item.strip() for item in content]
i, new_content, clean_content = 0, "", []
while i < len(content):
if content[i] == "":
clean_content.append(new_content.strip())
new_content = ""
... | def combine_nonblank_lines(content: list[str], sep: str=' ') -> list[str]:
content = [item.strip() for item in content]
(i, new_content, clean_content) = (0, '', [])
while i < len(content):
if content[i] == '':
clean_content.append(new_content.strip())
new_content = ''
... |
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 3 07:32:06 2018
@author: James Jiang
"""
all_lines = [line.rstrip('\n') for line in open('Data.txt')]
all_triples = [line.split('x') for line in all_lines]
all_triples_int = []
for triple in all_triples:
all_triples_int.append([int(num) for num in triple])
total = ... | """
Created on Wed Jan 3 07:32:06 2018
@author: James Jiang
"""
all_lines = [line.rstrip('\n') for line in open('Data.txt')]
all_triples = [line.split('x') for line in all_lines]
all_triples_int = []
for triple in all_triples:
all_triples_int.append([int(num) for num in triple])
total = 0
for triple in all_triple... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 25 14:05:46 2020
@author: jwiesner
"""
| """
Created on Tue Feb 25 14:05:46 2020
@author: jwiesner
""" |
def phoneCall(min1, min2_10, min11, s):
minutes = 0
rate = min1
while s > 0:
minutes += 1
if minutes == 2:
rate = min2_10
elif minutes > 10:
rate = min11
s -= rate
if s < 0:
minutes -= 1
return minutes
| def phone_call(min1, min2_10, min11, s):
minutes = 0
rate = min1
while s > 0:
minutes += 1
if minutes == 2:
rate = min2_10
elif minutes > 10:
rate = min11
s -= rate
if s < 0:
minutes -= 1
return minutes |
print('hello\tworld')
print('hello\nworld')
print( len('hello world'))
print('hello world'[0])
my_letter_list = ['a','a','b','b','c']
print(my_letter_list)
print( set(my_letter_list))
my_unique_letters = set(my_letter_list)
print(my_unique_letters)
print( len(my_unique_letters))
print( 'd' in my_unique_letters... | print('hello\tworld')
print('hello\nworld')
print(len('hello world'))
print('hello world'[0])
my_letter_list = ['a', 'a', 'b', 'b', 'c']
print(my_letter_list)
print(set(my_letter_list))
my_unique_letters = set(my_letter_list)
print(my_unique_letters)
print(len(my_unique_letters))
print('d' in my_unique_letters) |
# -*- coding: utf-8 -*-
def get_height_magnet(self):
"""get the height of the hole magnets
Parameters
----------
self : HoleM53
A HoleM53 object
Returns
-------
Hmag: float
height of the 2 Magnets [m]
"""
# magnet_0 and magnet_1 have the same height
Hmag = s... | def get_height_magnet(self):
"""get the height of the hole magnets
Parameters
----------
self : HoleM53
A HoleM53 object
Returns
-------
Hmag: float
height of the 2 Magnets [m]
"""
hmag = self.H2
return Hmag |
"""Message type identifiers for Trust Pings."""
SPEC_URI = (
"https://github.com/hyperledger/aries-rfcs/tree/"
"527849ec3aa2a8fd47a7bb6c57f918ff8bcb5e8c/features/0048-trust-ping"
)
PROTOCOL_URI = "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0"
PING = f"{PROTOCOL_URI}/ping"
PING_RESPONSE = f"{PROTOCOL_URI... | """Message type identifiers for Trust Pings."""
spec_uri = 'https://github.com/hyperledger/aries-rfcs/tree/527849ec3aa2a8fd47a7bb6c57f918ff8bcb5e8c/features/0048-trust-ping'
protocol_uri = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0'
ping = f'{PROTOCOL_URI}/ping'
ping_response = f'{PROTOCOL_URI}/ping_response'
... |
"""
Constants used by the packageinstaller module
Copyright (C) 2017-2022 Intel Corporation
SPDX-License-Identifier: Apache-2.0
"""
# Configuration command/response channel
REMEDIATION_CONTAINER_CMD_CHANNEL = 'remediation/container'
REMEDIATION_IMAGE_CMD_CHANNEL = 'remediation/image'
EVENTS_CHANNEL = ... | """
Constants used by the packageinstaller module
Copyright (C) 2017-2022 Intel Corporation
SPDX-License-Identifier: Apache-2.0
"""
remediation_container_cmd_channel = 'remediation/container'
remediation_image_cmd_channel = 'remediation/image'
events_channel = 'manageability/event'
configuration_update... |
# The value to indicate NO LIMIT parameter
NO_LIMIT = -1
# PER_CPU_SHARES has been set to 1024 because CPU shares' quota
# is commonly used in cloud frameworks like Kubernetes[1],
# AWS[2] and Mesos[3] in a similar way. They spawn containers with
# --cpu-shares option values scaled by PER_CPU_SHARES.
PER_CPU_SHARES =... | no_limit = -1
per_cpu_shares = 1024
subsys_memory = 'memory'
subsys_cpuset = 'cpuset'
subsys_cpu = 'cpu'
subsys_cpuacct = 'cpuacct'
subsys_pids = 'pids'
cgroup_type_v2 = 'cgroup2'
cgroup_type_v1 = 'cgroup' |
n = int(input())
total = 0
line = map(int, input().split())
for _ in line:
if _ < 0:
total += -_
print(total)
| n = int(input())
total = 0
line = map(int, input().split())
for _ in line:
if _ < 0:
total += -_
print(total) |
#common variables!
def set_loop(lp):
global loop #not to use local variable
loop=lp
def set_nm(nm):
global noisymode
noisymode=nm
def get_loop():
return loop
def get_nm(): return noisymode
loop=[]
noisymode=False | def set_loop(lp):
global loop
loop = lp
def set_nm(nm):
global noisymode
noisymode = nm
def get_loop():
return loop
def get_nm():
return noisymode
loop = []
noisymode = False |
def maior():
for c in range(10):
num = int(input())
if c == 0:
maior = primeiro = num
if num > maior:
maior = num
print(maior)
if maior % primeiro == 0:
print(primeiro)
maior()
| def maior():
for c in range(10):
num = int(input())
if c == 0:
maior = primeiro = num
if num > maior:
maior = num
print(maior)
if maior % primeiro == 0:
print(primeiro)
maior() |
# coding: utf-8
# 2021/3/17 @ tongshiwei
def etl(*args, **kwargs) -> ...: # pragma: no cover
"""
extract - transform - load
"""
pass
def train(*args, **kwargs) -> ...: # pragma: no cover
pass
def evaluate(*args, **kwargs) -> ...: # pragma: no cover
pass
class CDM(object):
def __in... | def etl(*args, **kwargs) -> ...:
"""
extract - transform - load
"""
pass
def train(*args, **kwargs) -> ...:
pass
def evaluate(*args, **kwargs) -> ...:
pass
class Cdm(object):
def __init__(self, *args, **kwargs) -> ...:
pass
def train(self, *args, **kwargs) -> ...:
ra... |
AwayPlayerFoulClockStart=0
AwayLastPlayerFoul=''
HomePlayerFoulClockStart=0
HomeLastPlayerFoul=''
| away_player_foul_clock_start = 0
away_last_player_foul = ''
home_player_foul_clock_start = 0
home_last_player_foul = '' |
# -*- coding: utf-8 -*-
# Copyright (c) 2008-2016 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
"""Functions to generate files readab... | """Functions to generate files readable with Georg Sander's vcg
(Visualization of Compiler Graphs).
You can download vcg at http://rw4.cs.uni-sb.de/~sander/html/gshome.html
Note that vcg exists as a debian package.
See vcg's documentation for explanation about the different values that
maybe used for the functions pa... |
class Solution:
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
length = 0
current = ""
i = 0
j = 0
while i < len(s) and j < len(s):
if s[j] in curren... | class Solution:
def length_of_longest_substring(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
length = 0
current = ''
i = 0
j = 0
while i < len(s) and j < len(s):
if s[j] in current:
... |
#Global
PARENT_DIR = "PARENT_DIR"
#Logging
LOG_FILE = "LOG_FILE"
SAVE_DIR = "SAVE_DIR"
TENSORBOARD_LOG_DIR = "TENSORBOARD_LOG_DIR"
#Preprocessing Dataset
DATASET_PATH = "DATASET_PATH"
#DeepSense Parameters
##Dataset Parameters
BATCH_SIZE = "BATCH_SIZE"
HISTORY_LENGTH = "HISTORY_LENGTH"
HORIZON = "HORIZON"
MEMORY_SIZ... | parent_dir = 'PARENT_DIR'
log_file = 'LOG_FILE'
save_dir = 'SAVE_DIR'
tensorboard_log_dir = 'TENSORBOARD_LOG_DIR'
dataset_path = 'DATASET_PATH'
batch_size = 'BATCH_SIZE'
history_length = 'HISTORY_LENGTH'
horizon = 'HORIZON'
memory_size = 'MEMORY_SIZE'
num_actions = 'NUM_ACTIONS'
num_channels = 'NUM_CHANNELS'
split_size... |
# https://www.codechef.com/problems/TWOSTR
for T in range(int(input())):
a,b,s=input(),input(),0
for i in range(len(a)):
if(a[i]==b[i] or a[i]=="?" or b[i]=="?"): s+=1
print("Yes") if(s==len(a)) else print("No") | for t in range(int(input())):
(a, b, s) = (input(), input(), 0)
for i in range(len(a)):
if a[i] == b[i] or a[i] == '?' or b[i] == '?':
s += 1
print('Yes') if s == len(a) else print('No') |
w2vSize = 100
feature_dim = 100
max_len=21
debug = False
poolSize=32
topicNum = 100
fresh = True
| w2v_size = 100
feature_dim = 100
max_len = 21
debug = False
pool_size = 32
topic_num = 100
fresh = True |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
"""
class Solution:
def getlen(self,node):
count = 0
while node is not None:
count+=1
node = node.next
return count
def g... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
'\nclass Solution:\n def getlen(self,node):\n count = 0\n while node is not None:\n count+=1\n node = node.next\n return count\n def getsumlist(self,node1,node2,m):... |
E = [[ 0, 1, 0, 0, 0, 0],
[E21, 0, 0, E24, E25, 0],
[ 0, 0, 0, 1, 0, 0],
[ 0, 0, E43, 0, 0, -1],
[ 0, 0, 0, 0, 0, 1],
[E61, 0, 0, E64, E65, 0]]
| e = [[0, 1, 0, 0, 0, 0], [E21, 0, 0, E24, E25, 0], [0, 0, 0, 1, 0, 0], [0, 0, E43, 0, 0, -1], [0, 0, 0, 0, 0, 1], [E61, 0, 0, E64, E65, 0]] |
class ComponentMeta(type):
"""Metaclass that builds a Component class.
This class transforms the _properties class property into a __slots__
property on the class before it is created, which suppresses the normal
creation of the __dict__ property and the memory overhead that brings.
"""
def __n... | class Componentmeta(type):
"""Metaclass that builds a Component class.
This class transforms the _properties class property into a __slots__
property on the class before it is created, which suppresses the normal
creation of the __dict__ property and the memory overhead that brings.
"""
def __... |
"""Utility functions for processing connection tables and related data."""
def clean_atom(atom_line):
"""Removes reaction-specific properties (e.g. atom-atom mapping) from the
atom_line and returns the updated line."""
return atom_line[:60] + ' 0 0 0'
def clean_bond(bond_line):
"""Removes r... | """Utility functions for processing connection tables and related data."""
def clean_atom(atom_line):
"""Removes reaction-specific properties (e.g. atom-atom mapping) from the
atom_line and returns the updated line."""
return atom_line[:60] + ' 0 0 0'
def clean_bond(bond_line):
"""Removes reaction cent... |
#Represents the entire memory bank of the TB-3 (64 patterns in total)
class TB3Bank:
BANK_SIZE = 64
def __init__(self,patterns=None):
if(patterns != None):
self.patterns = patterns
else:
self.patterns = []
def get_patterns(self):
return self.patterns
def get_pattern(self,index):
return self.patt... | class Tb3Bank:
bank_size = 64
def __init__(self, patterns=None):
if patterns != None:
self.patterns = patterns
else:
self.patterns = []
def get_patterns(self):
return self.patterns
def get_pattern(self, index):
return self.patterns[index]
d... |
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Li... | success = {'name': 'SUCCESS', 'ordinal': '0', 'color': 'BLUE', 'complete': True}
unstable = {'name': 'UNSTABLE', 'ordinal': '1', 'color': 'YELLOW', 'complete': True}
failure = {'name': 'FAILURE', 'ordinal': '2', 'color': 'RED', 'complete': True}
notbuild = {'name': 'NOT_BUILD', 'ordinal': '3', 'color': 'NOTBUILD', 'com... |
# Time: O(nlogn)
# Space: O(n)
class Solution(object):
def intersectionSizeTwo(self, intervals):
"""
:type intervals: List[List[int]]
:rtype: int
"""
intervals.sort(key = lambda s_e: (s_e[0], -s_e[1]))
cnts = [2] * len(intervals)
result = 0
while int... | class Solution(object):
def intersection_size_two(self, intervals):
"""
:type intervals: List[List[int]]
:rtype: int
"""
intervals.sort(key=lambda s_e: (s_e[0], -s_e[1]))
cnts = [2] * len(intervals)
result = 0
while intervals:
((start, _),... |
#!/usr/bin/env python
#######################################
# Installation module for mana-toolkit
#######################################
# AUTHOR OF MODULE NAME
AUTHOR="jklaz"
# DESCRIPTION OF THE MODULE
DESCRIPTION="This module will install/update the mana-toolkit"
# INSTALL TYPE GIT, SVN, FILE DOWNLOAD
# OPTIO... | author = 'jklaz'
description = 'This module will install/update the mana-toolkit'
install_type = 'GIT'
repository_location = 'https://github.com/sensepost/mana'
install_location = 'mana'
debian = 'libnl-dev,isc-dhcp-server,tinyproxy,libssl-dev,apache2,macchanger,python-dnspython,python-pcapy,dsniff,stunnel4,python-scap... |
class Holding_Registers:
Winch_ID, \
DIP_Switch_Status, \
Soft_Reset, \
Max_Velocity, \
Max_Acceleration, \
Encoder_Radius, \
Target_Setpoint, \
Target_Setpoint_Offset, \
Kp_velocity, \
Ki_velocity, \
Kd_velocity, \
Max_Encoder_Feedrate, \
Kp_position, \
Ki_position, \
Kd_position, \
Kp, \
Ki, \
Kd, \... | class Holding_Registers:
(winch_id, dip__switch__status, soft__reset, max__velocity, max__acceleration, encoder__radius, target__setpoint, target__setpoint__offset, kp_velocity, ki_velocity, kd_velocity, max__encoder__feedrate, kp_position, ki_position, kd_position, kp, ki, kd, pid__setpoint, target_x, target_y, ta... |
first_term = int(input('Insert the first term of an arithmetic progression: '))
reason = int(input('Insert the reason of the arithmetic progression: '))
for c in range (1, 11):
if reason == 0:
print(first_term)
elif reason > 0:
c = first_term + (c - 1)*reason
print(c)
else:
c... | first_term = int(input('Insert the first term of an arithmetic progression: '))
reason = int(input('Insert the reason of the arithmetic progression: '))
for c in range(1, 11):
if reason == 0:
print(first_term)
elif reason > 0:
c = first_term + (c - 1) * reason
print(c)
else:
... |
self = [1]*11000
for i in range(1,10):
self[2*i-1] = 0
for j in range(10,100):
self[j+int(str(j)[0])+int(str(j)[1])-1] = 0
for k in range(100,1000):
self[k+int(str(k)[0])+int(str(k)[1])+int(str(k)[2])-1] = 0
for m in range(1000,10000):
self[m+int(str(m)[0])+int(str(m)[1])+int(str(m)[2])+int(str(m)[3])... | self = [1] * 11000
for i in range(1, 10):
self[2 * i - 1] = 0
for j in range(10, 100):
self[j + int(str(j)[0]) + int(str(j)[1]) - 1] = 0
for k in range(100, 1000):
self[k + int(str(k)[0]) + int(str(k)[1]) + int(str(k)[2]) - 1] = 0
for m in range(1000, 10000):
self[m + int(str(m)[0]) + int(str(m)[1]) + i... |
APP_KEY = 'your APP_KEY'
APP_SECRET = 'your APP_SECRET'
OAUTH_TOKEN = 'your OAUTH_TOKEN'
OAUTH_TOKEN_SECRET = 'your OAUTH_TOKEN_SECRET'
ROUTE = 'your ROUTE'
| app_key = 'your APP_KEY'
app_secret = 'your APP_SECRET'
oauth_token = 'your OAUTH_TOKEN'
oauth_token_secret = 'your OAUTH_TOKEN_SECRET'
route = 'your ROUTE' |
__about__ = """Merge Sorted Linked List only single traverse allowed."""
class Node:
def __init__(self,value):
self.data = value
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.current = None
def push(self,value):
push_node = Node(value... | __about__ = 'Merge Sorted Linked List only single traverse allowed.'
class Node:
def __init__(self, value):
self.data = value
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
self.current = None
def push(self, value):
push_node = node(value... |
def main():
s = input("Please enter your sentence: ")
words = s.split()
wordCount = len(words)
print ("Your word and letter counts are:", wordCount)
main() | def main():
s = input('Please enter your sentence: ')
words = s.split()
word_count = len(words)
print('Your word and letter counts are:', wordCount)
main() |
"""
Model-Based Configuration
=========================
This app allows other apps to easily define a configuration model
that can be hooked into the admin site to allow configuration management
with auditing.
Installation
------------
Add ``config_models`` to your ``INSTALLED_APPS`` list.
Usage
-----
Create a sub... | """
Model-Based Configuration
=========================
This app allows other apps to easily define a configuration model
that can be hooked into the admin site to allow configuration management
with auditing.
Installation
------------
Add ``config_models`` to your ``INSTALLED_APPS`` list.
Usage
-----
Create a sub... |
#!/usr/bin/env python3
def calculate():
L = 100000
rads = [0] + [1] * L
for i in range(2, len(rads)):
if rads[i] == 1:
for j in range(i, len(rads), i):
rads[j] *= i
data = sorted((rad, i) for(i, rad) in enumerate(rads))
return str(data[10000][1])
if __name__ =... | def calculate():
l = 100000
rads = [0] + [1] * L
for i in range(2, len(rads)):
if rads[i] == 1:
for j in range(i, len(rads), i):
rads[j] *= i
data = sorted(((rad, i) for (i, rad) in enumerate(rads)))
return str(data[10000][1])
if __name__ == '__main__':
print(... |
temperatures = []
with open('lab_05.txt') as infile:
for row in infile:
temperatures.append(float(row.strip()))
min_tem = min(temperatures)
max_tem = max(temperatures)
avr_tem = sum(temperatures)/len(temperatures)
temperatures.sort()
median = temperatures[len(temperatures)//2]
unique = len(set(temperature... | temperatures = []
with open('lab_05.txt') as infile:
for row in infile:
temperatures.append(float(row.strip()))
min_tem = min(temperatures)
max_tem = max(temperatures)
avr_tem = sum(temperatures) / len(temperatures)
temperatures.sort()
median = temperatures[len(temperatures) // 2]
unique = len(set(temperatu... |
class KeyGesture(InputGesture):
"""
Defines a keyboard combination that can be used to invoke a command.
KeyGesture(key: Key)
KeyGesture(key: Key,modifiers: ModifierKeys)
KeyGesture(key: Key,modifiers: ModifierKeys,displayString: str)
"""
def GetDisplayStringForCulture(self,culture):
"""
GetD... | class Keygesture(InputGesture):
"""
Defines a keyboard combination that can be used to invoke a command.
KeyGesture(key: Key)
KeyGesture(key: Key,modifiers: ModifierKeys)
KeyGesture(key: Key,modifiers: ModifierKeys,displayString: str)
"""
def get_display_string_for_culture(self, culture):
""... |
s = 0
for c in range(0, 4):
n = int(input('Digite um numero:'))
s += n
print('O somatorio de todos os valores foi {}'.format(s)) | s = 0
for c in range(0, 4):
n = int(input('Digite um numero:'))
s += n
print('O somatorio de todos os valores foi {}'.format(s)) |
def dict_to_str(src_dict):
dst_str = ""
for key in src_dict.keys():
dst_str += " %s: %.4f " %(key, src_dict[key])
return dst_str
class Storage(dict):
"""
A Storage object is like a dictionary except `obj.foo` can be used inadition to `obj['foo']`
ref: https://blog.csdn.net/a20082214608... | def dict_to_str(src_dict):
dst_str = ''
for key in src_dict.keys():
dst_str += ' %s: %.4f ' % (key, src_dict[key])
return dst_str
class Storage(dict):
"""
A Storage object is like a dictionary except `obj.foo` can be used inadition to `obj['foo']`
ref: https://blog.csdn.net/a20082214608... |
# string di python bisa menggunakan
# petik satu dan petik dua
# contoh
# "Hello World" sama dengan 'hello world'
# 'hello world' sama dengan "hello world"
kata_pertama = "warung"
# bisa juga menggunakan multi string
# bisa menggunakan 3 tanda petik dua atau satu
kata_saya = """indonesia adalah negara yang indah
ber... | kata_pertama = 'warung'
kata_saya = 'indonesia adalah negara yang indah\nberada di bawah garis khatulistiwa\naku cinta indonesia\n'
print(kata_saya)
print(kata_pertama.upper())
print(kata_pertama.lower())
print(kata_pertama[0])
print(len(kata_pertama))
print('indonesia' in kata_saya) |
faces = fetch_olivetti_faces()
# set up the figure
fig = plt.figure(figsize=(6, 6)) # figure size in inches
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
# plot the faces:
for i in range(64):
ax = fig.add_subplot(8, 8, i + 1, xticks=[], yticks=[])
ax.imshow(faces.images[i], ... | faces = fetch_olivetti_faces()
fig = plt.figure(figsize=(6, 6))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(64):
ax = fig.add_subplot(8, 8, i + 1, xticks=[], yticks=[])
ax.imshow(faces.images[i], cmap=plt.cm.bone, interpolation='nearest') |
class Solution:
def findLucky(self, arr: List[int]) -> int:
x=[i for i in arr if arr.count(i)==i]
if not x:
return -1
else:
return max(x)
| class Solution:
def find_lucky(self, arr: List[int]) -> int:
x = [i for i in arr if arr.count(i) == i]
if not x:
return -1
else:
return max(x) |
VERSION = (0, 2, 1)
"""Application version number tuple."""
VERSION_STR = '.'.join(map(str, VERSION))
"""Application version number string."""
default_app_config = 'sitetables.apps.SitetablesConfig' | version = (0, 2, 1)
'Application version number tuple.'
version_str = '.'.join(map(str, VERSION))
'Application version number string.'
default_app_config = 'sitetables.apps.SitetablesConfig' |
i = input("Enter a number: ")
d = '0369'
if i[-1] in d:
print('Last digit is divisible by 3.')
else:
print('Last digit is not divisible by 3.')
| i = input('Enter a number: ')
d = '0369'
if i[-1] in d:
print('Last digit is divisible by 3.')
else:
print('Last digit is not divisible by 3.') |
"""
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word
in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
Example:
Given s = "Hello World",
return 5 as l... | """
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word
in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
Example:
Given s = "Hello World",
return 5 as l... |
# Get the config object
c = get_config()
# Inline figures when using Matplotlib
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.ip = '*'
c.NotebookApp.allow_remote_access = True
# Do not open a browser window by default when using notebooks
c.NotebookApp.open_browser = False
# INSECURE: No token. Always use jupyter over s... | c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.ip = '*'
c.NotebookApp.allow_remote_access = True
c.NotebookApp.open_browser = False
c.NotebookApp.token = ''
c.NotebookApp.notebook_dir = '/git'
c.NotebookApp.allow_root = True |
Import('env')
global_env = DefaultEnvironment()
global_env.Append(
CPPDEFINES=[
"MSGPACK_ENDIAN_LITTLE_BYTE",
]
)
| import('env')
global_env = default_environment()
global_env.Append(CPPDEFINES=['MSGPACK_ENDIAN_LITTLE_BYTE']) |
def get_label_lower(opts):
if hasattr(opts, 'label_lower'):
return opts.label_lower
model_label = opts.model_name
app_label = opts.app_label
return "{app_label}.{model_label}".format(app_label=app_label,
model_label=model_label)
| def get_label_lower(opts):
if hasattr(opts, 'label_lower'):
return opts.label_lower
model_label = opts.model_name
app_label = opts.app_label
return '{app_label}.{model_label}'.format(app_label=app_label, model_label=model_label) |
# list the uses of all certificates
res = client.get_certificates_uses()
print(res)
if type(res) == pypureclient.responses.ValidResponse:
print(list(res.items))
# list the uses of certificates named "ad-cert-1" and "posix-cert"
res = client.get_certificates_uses(names=['ad-cert-1', 'posix-cert'])
print(res)
if type... | res = client.get_certificates_uses()
print(res)
if type(res) == pypureclient.responses.ValidResponse:
print(list(res.items))
res = client.get_certificates_uses(names=['ad-cert-1', 'posix-cert'])
print(res)
if type(res) == pypureclient.responses.ValidResponse:
print(list(res.items)) |
def allLongestStrings(inputArray):
'''
Given an array of strings, return another array containing all of its longest strings.
'''
resultArray = []
currentMax = len(inputArray[0])
for i in range(len(inputArray) ):
currentLen = len(inputArray[i])
if currentLen... | def all_longest_strings(inputArray):
"""
Given an array of strings, return another array containing all of its longest strings.
"""
result_array = []
current_max = len(inputArray[0])
for i in range(len(inputArray)):
current_len = len(inputArray[i])
if currentLen > currentMax:
... |
n , m = map(int, input().split())
array = list(map(int, input().split()))
A = list(set(map(int, input().split())))
B = list(set(map(int, input().split())))
happiness = 0
for i in range(n):
for j in range(m):
if array[i] == A[j]:
happiness += 1
elif array[i]... | (n, m) = map(int, input().split())
array = list(map(int, input().split()))
a = list(set(map(int, input().split())))
b = list(set(map(int, input().split())))
happiness = 0
for i in range(n):
for j in range(m):
if array[i] == A[j]:
happiness += 1
elif array[i] == B[j]:
happines... |
def relativeSorting(A1,A2):
common_elements = set(A1).intersection(set(A2))
extra = set(A1).difference(set(A2))
out = []
for i in A2:
s = [i] * A1.count(i)
out.extend(s)
extra_out = []
for j in extra:
u = [j] * A1.count(j)
extra_out.extend(u)
out = out + sorte... | def relative_sorting(A1, A2):
common_elements = set(A1).intersection(set(A2))
extra = set(A1).difference(set(A2))
out = []
for i in A2:
s = [i] * A1.count(i)
out.extend(s)
extra_out = []
for j in extra:
u = [j] * A1.count(j)
extra_out.extend(u)
out = out + sor... |
#!/usr/bin/env python3.8
# Copyright 2021 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
def f():
print('lib.f')
def truthy():
return True
def falsy():
return False
| def f():
print('lib.f')
def truthy():
return True
def falsy():
return False |
n=int(input())
a=list(map(int,input().split()))
jump=0
i=0
while i<=n:
if i+2<n and a[i+2]==0:
jump+=1
i+=2
elif i+1<n and a[i+1]==0:
jump+=1
i+=1
else:
i+=1
print(jump) | n = int(input())
a = list(map(int, input().split()))
jump = 0
i = 0
while i <= n:
if i + 2 < n and a[i + 2] == 0:
jump += 1
i += 2
elif i + 1 < n and a[i + 1] == 0:
jump += 1
i += 1
else:
i += 1
print(jump) |
"""
AvaTax Software Development Kit for Python.
Copyright 2019 Avalara, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unles... | """
AvaTax Software Development Kit for Python.
Copyright 2019 Avalara, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unles... |
class config(object):
rank_norm = 0
run_list = str.split("zh2en_w2vv_attention w2vv_attention")
nr_of_runs = len(run_list)
#weights = [1.0/nr_of_runs] * nr_of_runs
weights = [0.73, 0.27]
| class Config(object):
rank_norm = 0
run_list = str.split('zh2en_w2vv_attention w2vv_attention')
nr_of_runs = len(run_list)
weights = [0.73, 0.27] |
# pylint: disable=line-too-long
# SPDX-FileCopyrightText: Copyright (c) 2021 ajs256
#
# SPDX-License-Identifier: MIT
"""
`seriallcd`
================================================================================
CircuitPython helper library for Parallax's serial LCDs
* Author(s): ajs256
Implementation Notes
-----... | """
`seriallcd`
================================================================================
CircuitPython helper library for Parallax's serial LCDs
* Author(s): ajs256
Implementation Notes
--------------------
**Hardware:**
* `16x2 Parallax Serial LCD <https://www.parallax.com/product/parallax-2-x-16-serial-... |
def duplicate_number(arr):
"""
:param - array containing numbers in the range [0, len(arr) - 2]
return - the number that is duplicate in the arr
"""
current_sum = 0
expected_sum = 0
for num in arr:
current_sum += num
for i in range(len(arr) - 1):
expected_su... | def duplicate_number(arr):
"""
:param - array containing numbers in the range [0, len(arr) - 2]
return - the number that is duplicate in the arr
"""
current_sum = 0
expected_sum = 0
for num in arr:
current_sum += num
for i in range(len(arr) - 1):
expected_sum += i
ret... |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( n ) :
if ( n == 0 ) :
return "0" ;
bin = "" ;
while ( n > 0 ) :
if ( n & 1 == 0 ) :
... | def f_gold(n):
if n == 0:
return '0'
bin = ''
while n > 0:
if n & 1 == 0:
bin = '0' + bin
else:
bin = '1' + bin
n = n >> 1
return bin
if __name__ == '__main__':
param = [(35,), (17,), (8,), (99,), (57,), (39,), (99,), (14,), (22,), (7,)]
n_... |
class Clip:
def __init__(self, start_time: float, end_time: float):
self.start_time: float = start_time
self.end_time: float = end_time
@property
def length_in_seconds(self) -> float:
return self.end_time - self.start_time
| class Clip:
def __init__(self, start_time: float, end_time: float):
self.start_time: float = start_time
self.end_time: float = end_time
@property
def length_in_seconds(self) -> float:
return self.end_time - self.start_time |
# LISTAS INTERNAS - ISINSTANCE
minhaLista = [[1, "a", 2], [3, 4, "b"], ["c", 5, "d"]]
letras = []
numeros = []
for listaInterna in minhaLista:
for elementos in listaInterna:
if (isinstance(elementos, str)):
letras.append(elementos)
else:
numeros.append(elemento... | minha_lista = [[1, 'a', 2], [3, 4, 'b'], ['c', 5, 'd']]
letras = []
numeros = []
for lista_interna in minhaLista:
for elementos in listaInterna:
if isinstance(elementos, str):
letras.append(elementos)
else:
numeros.append(elementos)
print(letras)
print(numeros) |
slackInfo = {
"url": "https://hooks.slack.com/services/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",
"username": "leaderboard-bot",
}
hackerrankInfo = {
"url": "https://www.hackerrank.com/rest/contests/wissen-coding-challenge-2021/leaderboard",
} | slack_info = {'url': 'https://hooks.slack.com/services/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', 'username': 'leaderboard-bot'}
hackerrank_info = {'url': 'https://www.hackerrank.com/rest/contests/wissen-coding-challenge-2021/leaderboard'} |
class AdditionExpression:
def __init__(self, left, right):
self.right = right
self.left = left
def print(self, buffer):
buffer.append('(')
self.left.print(buffer)
buffer.append('+')
self.right.print(buffer)
buffer.append(')')
def eval(self):
... | class Additionexpression:
def __init__(self, left, right):
self.right = right
self.left = left
def print(self, buffer):
buffer.append('(')
self.left.print(buffer)
buffer.append('+')
self.right.print(buffer)
buffer.append(')')
def eval(self):
... |
'''
3. Swap string variable values
fname = "rahul"
lname = "dravid"
Swap the value of variable with fname & fname with lname
Output:: print(fname) # dravid
print(lname) # rahul
'''
fname = "rahul"
lname = "dravid"
#fname.swap(lname)
#lname.swap(fname)
fname="dravid"
lname="rahul"
print(fname)
print(... | """
3. Swap string variable values
fname = "rahul"
lname = "dravid"
Swap the value of variable with fname & fname with lname
Output:: print(fname) # dravid
print(lname) # rahul
"""
fname = 'rahul'
lname = 'dravid'
fname = 'dravid'
lname = 'rahul'
print(fname)
print(lname)
print('-------------------------------------... |
{
'includes': [
'../common.gypi',
'../config.gypi',
],
'targets': [
{
'target_name': 'linuxapp',
'product_name': 'mapbox-gl',
'type': 'executable',
'sources': [
'./main.cpp',
'../common/settings_json.cpp',
'../common/settings_json.hpp',
'../commo... | {'includes': ['../common.gypi', '../config.gypi'], 'targets': [{'target_name': 'linuxapp', 'product_name': 'mapbox-gl', 'type': 'executable', 'sources': ['./main.cpp', '../common/settings_json.cpp', '../common/settings_json.hpp', '../common/platform_default.cpp', '../common/glfw_view.hpp', '../common/glfw_view.cpp', '.... |
#Source : https://leetcode.com/problems/linked-list-cycle/
#Author : Yuan Wang
#Date : 2018-08-01
'''
**********************************************************************************
*Given a linked list, determine if it has a cycle in it.
*
*Follow up:
*Can you solve it without using extra space?
****************... | """
**********************************************************************************
*Given a linked list, determine if it has a cycle in it.
*
*Follow up:
*Can you solve it without using extra space?
**********************************************************************************/
"""
def has_cycle(self, head):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.