content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def binPack(i, array, target, dp):
if (i == len(array)):
return(0)
if (i not in dp):
dp[i] = {}
if (target not in dp[i]):
best = binPack(i + 1, array, target, dp)
if (target - array[i] >= 0):
aux = binPack(i + 1, array, target - array[i], dp) + array[i]
... | def bin_pack(i, array, target, dp):
if i == len(array):
return 0
if i not in dp:
dp[i] = {}
if target not in dp[i]:
best = bin_pack(i + 1, array, target, dp)
if target - array[i] >= 0:
aux = bin_pack(i + 1, array, target - array[i], dp) + array[i]
if a... |
"""
Datos de entrada
capital-->c-->int
Datos de salida
ganancia-->g-->float
"""
#Entradas
c=int(input("Ingrese la cantidad de dinero invertida: "))
#Caja negra
g=(c*0.2)/100
#Salidas
print("Su ganancia mensual es de: ", g) | """
Datos de entrada
capital-->c-->int
Datos de salida
ganancia-->g-->float
"""
c = int(input('Ingrese la cantidad de dinero invertida: '))
g = c * 0.2 / 100
print('Su ganancia mensual es de: ', g) |
"""
0923. 3Sum With Multiplicity
Medium
Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.
As the answer can be very large, return it modulo 109 + 7.
Example 1:
Input: arr = [1,1,2,2,3,3,4,4,5,5], target = 8
Output: ... | """
0923. 3Sum With Multiplicity
Medium
Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.
As the answer can be very large, return it modulo 109 + 7.
Example 1:
Input: arr = [1,1,2,2,3,3,4,4,5,5], target = 8
Output: ... |
if __name__ == '__main__':
Str1 = '14:59~15:20'
StrList = Str1.split('~')
print(StrList)
print(StrList[0])
print(StrList[1])
| if __name__ == '__main__':
str1 = '14:59~15:20'
str_list = Str1.split('~')
print(StrList)
print(StrList[0])
print(StrList[1]) |
# Copyright (C) 2011 MetaBrainz Foundation
# Distributed under the MIT license, see the LICENSE file for details.
__version__ = "0.1.0"
| __version__ = '0.1.0' |
#App
HOST = '0.0.0.0'
PORT = 6000
DEBUG = False
#AWS
BUCKET = 'fastermlpipeline'
ACCESS_KEY = 'sorry_itsasecret'
SECRET_KEY = 'sure_itsasecret'
#Extract Data
URL_DATA = 'http://api:5000/credits'
#Preprocessors
NUMERICAL_FEATURES = ['age', 'job', 'credit_amount' ,'duration']
CATEGORICAL_FEATURES = ['sex', 'housing... | host = '0.0.0.0'
port = 6000
debug = False
bucket = 'fastermlpipeline'
access_key = 'sorry_itsasecret'
secret_key = 'sure_itsasecret'
url_data = 'http://api:5000/credits'
numerical_features = ['age', 'job', 'credit_amount', 'duration']
categorical_features = ['sex', 'housing', 'saving_accounts', 'checking_account', 'pu... |
""" Return nth element from last node
input: A -> B -> C -> D
output: B
"""
class Node:
""" Node class contains everything related to Linked List node """
def __init__(self, data):
""" initializing single node with data """
self.data = data
self.next = None
class LinkedList:
... | """ Return nth element from last node
input: A -> B -> C -> D
output: B
"""
class Node:
""" Node class contains everything related to Linked List node """
def __init__(self, data):
""" initializing single node with data """
self.data = data
self.next = None
class Linkedlist:
... |
lookup_table = {
"TRI_FACILITY_NPDES": {
"ASGN_NPDES_IND": "Indicates that the associated NPDES_NUM represents the principal NPDES permit number as assigned to the facility by TRI from Form R or Form A submissions. Values: 1 = 'Yes', 0 = 'No'.",
"TRI_FACILITY_ID": "The unique number assigned to each facilit... | lookup_table = {'TRI_FACILITY_NPDES': {'ASGN_NPDES_IND': "Indicates that the associated NPDES_NUM represents the principal NPDES permit number as assigned to the facility by TRI from Form R or Form A submissions. Values: 1 = 'Yes', 0 = 'No'.", 'TRI_FACILITY_ID': 'The unique number assigned to each facility for purpose... |
#Write a function that takes a two-dimensional list (list of lists) of numbers as argument and returns a list
#which includes the sum of each row. You can assume that the number of columns in each row is the same.
def sum_of_two_lists_row(list2d):
final_list = []
for list_numbers in list2d:
sum_list = 0
for nu... | def sum_of_two_lists_row(list2d):
final_list = []
for list_numbers in list2d:
sum_list = 0
for number in list_numbers:
sum_list += number
final_list.append(sum_list)
return final_list
print(sum_of_two_lists([[1, 2], [3, 4]])) |
"""
Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A.
We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j.
These lists A and B may contain duplicates. If there are multi... | """
Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A.
We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j.
These lists A and B may contain duplicates. If there are multi... |
# coding=utf-8
# Copyright 2022 The Google Research 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 applicab... | """Gives the interface of the rans coder."""
class Bitstream:
"""Bitstream object that manages encoding/decoding."""
def __init__(self, scale_bits):
self.scale_bits = scale_bits
def encode_cat(self, x, probs):
raise NotImplementedError
def decode_cat(self, probs):
raise NotIm... |
def count_words(input_str):
return len(input_str.split())
print(count_words('this is a string'))
demo_str = 'hellow world'
print(count_words(demo_str))
def find_min(num_list):
min_item = num_list[0]
for num in num_list:
if type(num) is not str:
if min_item>... | def count_words(input_str):
return len(input_str.split())
print(count_words('this is a string'))
demo_str = 'hellow world'
print(count_words(demo_str))
def find_min(num_list):
min_item = num_list[0]
for num in num_list:
if type(num) is not str:
if min_item >= num:
min_it... |
class Solution(object):
def pourWater(self, heights, V, K):
"""
:type heights: List[int]
:type V: int
:type K: int
:rtype: List[int]
"""
for i in range(V):
t = K
#left peak [0: k]
for left ... | class Solution(object):
def pour_water(self, heights, V, K):
"""
:type heights: List[int]
:type V: int
:type K: int
:rtype: List[int]
"""
for i in range(V):
t = K
for left in range(K - 1, -1, -1):
if heights[left] < hei... |
class InvalidInputError(Exception):
"""
This will be raised when one tries to input a type thats not in its
list of types that can be used.
"""
def __init__(self, message):
self.message = message
def __str__(self):
return self.message | class Invalidinputerror(Exception):
"""
This will be raised when one tries to input a type thats not in its
list of types that can be used.
"""
def __init__(self, message):
self.message = message
def __str__(self):
return self.message |
"""
nydus.db.backends.base
~~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2011 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""
__all__ = ('BaseConnection',)
class BasePipeline(object):
"""
Base Pipeline class.
This basically is absolutely useless, and just provides a sample
API for ... | """
nydus.db.backends.base
~~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2011 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""
__all__ = ('BaseConnection',)
class Basepipeline(object):
"""
Base Pipeline class.
This basically is absolutely useless, and just provides a sample
API for de... |
def find_minimum_number_of_moves(rows, cols, start_row, start_col, end_row, end_col):
# row_low = start_row if start_row < end_row else end_row
# row_high = start_row if start_row > end_row else end_row
# col_low = start_col if start_col < end_col else end_col
# col_high = start_col if start_col > end_c... | def find_minimum_number_of_moves(rows, cols, start_row, start_col, end_row, end_col):
deltas = [(-2, -1), (-2, +1), (+2, -1), (+2, +1), (-1, -2), (-1, +2), (+1, -2), (+1, +2)]
def get_all_valid_moves(y0, x0):
valid_positions = []
for (x, y) in deltas:
x_candidate = x0 + x
... |
#
# subtag.py
# =========
#
# Python-3 module for loading and parsing the Language Subtag Registry
# from IANA.
#
# A current copy of the registry can be downloaded from IANA at the
# following address:
#
# https://www.iana.org/assignments/
# language-subtag-registry/language-subtag-registry
#
# The format of this ... | class Subtagerror(Exception):
def __str__(self):
return 'Unknown subtag parsing error!'
class Badcontinueline(SubtagError):
def __init__(self, line=None):
self.m_line = line
def __str__(self):
if self.m_line is not None:
return 'Subtag data line ' + str(self.m_line) +... |
for _ in range(int(input())):
p,n=input(),int(input())
x=input()[1:-1].split(',')
pos,rpos,mode=0,n-1,0
error=False
for i in p:
if i=='R': mode=(mode+1)%2
else:
if pos>rpos:
print('error')
error=True
break
if mode==0: pos+=1
else: rpos-=1
if error: continue
print(end='[')
if mode==0:
... | for _ in range(int(input())):
(p, n) = (input(), int(input()))
x = input()[1:-1].split(',')
(pos, rpos, mode) = (0, n - 1, 0)
error = False
for i in p:
if i == 'R':
mode = (mode + 1) % 2
else:
if pos > rpos:
print('error')
error... |
# -*- coding: utf-8 -*-
# @Author: davidhansonc
# @Date: 2021-01-19 10:22:34
# @Last Modified by: davidhansonc
# @Last Modified time: 2021-01-19 10:56:52
my_string = 'abcde fgh'
def reverse_string(string):
rev_str = ''
for i in range(len(string)-1, -1, -1):
rev_str += string[i]
return rev_str
... | my_string = 'abcde fgh'
def reverse_string(string):
rev_str = ''
for i in range(len(string) - 1, -1, -1):
rev_str += string[i]
return rev_str
def reverse_string2(string):
return string[::-1]
print(reverse_string(my_string))
print(reverse_string2(my_string)) |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
d = 1
current = head.next
middle = head
while current:
d +=... | class Solution:
def middle_node(self, head: ListNode) -> ListNode:
d = 1
current = head.next
middle = head
while current:
d += 1
if d % 2 == 0:
middle = middle.next
current = current.next
return middle |
name = 'Sina'
last = 'Bakhshandeh'
age = 29
nationality = 'Iran'
a = 'I am Sina Bakhshandeh 29 years old, from iran.'
# print(a)
# print('I am', name, last, age ,'years old, from ', nationality)
b = 'I am {} {} {} years old, from {}.'
print( b.format(name, last, age, nationality) ) | name = 'Sina'
last = 'Bakhshandeh'
age = 29
nationality = 'Iran'
a = 'I am Sina Bakhshandeh 29 years old, from iran.'
b = 'I am {} {} {} years old, from {}.'
print(b.format(name, last, age, nationality)) |
#!usr/bin/python3
with open('01/input.txt', 'r') as file:
increases = 0
previous = file.readline()
for line in file.readlines():
delta = int(line) - int(previous)
if delta > 0:
increases += 1
previous = line
print(increases) | with open('01/input.txt', 'r') as file:
increases = 0
previous = file.readline()
for line in file.readlines():
delta = int(line) - int(previous)
if delta > 0:
increases += 1
previous = line
print(increases) |
"""
RHGamestation manager API
Well in fact it's not really an API, this is mostly JSON views for some
special jobs like executing some command scripts.
""" | """
RHGamestation manager API
Well in fact it's not really an API, this is mostly JSON views for some
special jobs like executing some command scripts.
""" |
# Basics
5 == 5 # True
5 == 4 # False
5 != 4 # True
5 > 3 # True
3 < 5 # True
5 >= 3 # True
5 >= 5 # True
[1, 2, 4] > [1, 2, 3] # True
1 < 2 and 5 > 4 # True
(1 < 2) and (5 > 4) # True
1 > 2 or 5 > 4 # True
#Chainging
x = 4
x > 3 and x < 5 # True
3 < x < 5 # True
# isinstance
isinstance("Will", str) # True
isinstance... | 5 == 5
5 == 4
5 != 4
5 > 3
3 < 5
5 >= 3
5 >= 5
[1, 2, 4] > [1, 2, 3]
1 < 2 and 5 > 4
1 < 2 and 5 > 4
1 > 2 or 5 > 4
x = 4
x > 3 and x < 5
3 < x < 5
isinstance('Will', str)
isinstance('Will', int)
isinstance(4.0, float)
a = True
b = True
a is b
x = [1, 2, 3]
y = [1, 2, 3]
x is y
x = [1, 2, 3]
3 in x
5 in x
x = [1, 2, 3]... |
#!/usr/bin/python
# -*- coding: utf8
"""
Keywords reserved in any SQL standard
From http://www.postgresql.org/docs/9.4/static/sql-keywords-appendix.html
"""
sql_reserved_words = [
'ABS',
'ABSOLUTE',
'ACTION',
'ADD',
'ALL',
'ALLOCATE',
'ALTER',
'ANALYSE',
'ANALYZE',
'AND',
'ANY',
'ARE',
'ARRAY',
'ARRAY_AG... | """
Keywords reserved in any SQL standard
From http://www.postgresql.org/docs/9.4/static/sql-keywords-appendix.html
"""
sql_reserved_words = ['ABS', 'ABSOLUTE', 'ACTION', 'ADD', 'ALL', 'ALLOCATE', 'ALTER', 'ANALYSE', 'ANALYZE', 'AND', 'ANY', 'ARE', 'ARRAY', 'ARRAY_AGG', 'ARRAY_MAX_CARDINALITY', 'AS', 'ASC', 'ASENSITIV... |
# Region
# VPC
# Private Subnet
# Public Subnet
# Security Group
# Availability Zone
# AWS Step Functions Workflow
# Elastic Beanstalk container
# Auto Scaling Group
# Server contents
# EC2 instance contents
# Spot Fleet
groups = {
'AWS::AccountId': {'level': 0},
'AWS::Region': {'level': 1},
'AWS::IAM:... | groups = {'AWS::AccountId': {'level': 0}, 'AWS::Region': {'level': 1}, 'AWS::IAM::': {'level': 2}, 'AWS::EC2::VPC': {'level': 3}, 'AvailabilityZone': {'level': 4}, 'AWS::EC2::SecurityGroup': {'level': 4}, 'AWS::EC2::Subnet': {'level': 5}, 'Default': {'level': 6}}
blacklist_resource_types = ['AWS::SSM::Parameter', 'AWS:... |
f = open('latin_text', 'w')
for i in xrange(5000):
text = "Lorem ipsum dolor sit amet, est malis molestiae no,\nrebum" \
"mediocrem vituperatoribus qui et. Quando intellegam ne mea," \
" utroque\n voluptua sensibus nam te. In duo accusam accusamus," \
" mea ad iriure detracto\nsigni... | f = open('latin_text', 'w')
for i in xrange(5000):
text = 'Lorem ipsum dolor sit amet, est malis molestiae no,\nrebummediocrem vituperatoribus qui et. Quando intellegam ne mea, utroque\n voluptua sensibus nam te. In duo accusam accusamus, mea ad iriure detracto\nsigniferumque. Veri complectitur concludaturque te se... |
'''
Created on Dec 5, 2012
@author: arnaud
'''
"""
from UniShared_python.website.models import UserProfile
from django.contrib.auth.models import User
from django.test.testcases import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from social_auth.db.django... | """
Created on Dec 5, 2012
@author: arnaud
"""
'\nfrom UniShared_python.website.models import UserProfile\nfrom django.contrib.auth.models import User\nfrom django.test.testcases import LiveServerTestCase\nfrom selenium import webdriver\nfrom selenium.webdriver.support.wait import WebDriverWait\nfrom social_auth.db.dj... |
def multi_inverse(b, n):
r1 = n
r2 = b
t1 = 0
t2 = 1
while(r1 > 0):
q = int(r1/r2)
r = r1 - q * r2
r1 = r2
r2 = r
t = t1 - q * t2
t1 = t2
t2 = t
if(r1 == 1):
inv_t = t1
break
return inv_t
| def multi_inverse(b, n):
r1 = n
r2 = b
t1 = 0
t2 = 1
while r1 > 0:
q = int(r1 / r2)
r = r1 - q * r2
r1 = r2
r2 = r
t = t1 - q * t2
t1 = t2
t2 = t
if r1 == 1:
inv_t = t1
break
return inv_t |
#Data : 2018-10-15
#Author : Fengyuan Zhang (Franklin)
#Email : franklinzhang@foxmail.com
class ModelDataHandler:
def __init__(self, context):
self.mContext = context
self.mExecutionPath = ''
self.mZipExecutionPath = ''
self.mExecutionName = ''
self.mSavePath = ''
... | class Modeldatahandler:
def __init__(self, context):
self.mContext = context
self.mExecutionPath = ''
self.mZipExecutionPath = ''
self.mExecutionName = ''
self.mSavePath = ''
self.mSaveName = ''
self.mReturnFileFullName = ''
def connect_data_mapping_meth... |
"""Path counting solutions."""
def count_path_recursive(m, n):
"""Count number of paths with the recursive method."""
def traverse(m, n, location=[1, 1]):
# return 0 if past edge
if location[0] > m or location[1] > n:
return 0
# return 1 if at end position
if locati... | """Path counting solutions."""
def count_path_recursive(m, n):
"""Count number of paths with the recursive method."""
def traverse(m, n, location=[1, 1]):
if location[0] > m or location[1] > n:
return 0
if location == [m, n]:
return 1
return traverse(m, n, [loca... |
class Solution:
def trap(self, height: List[int]) -> int:
if len(height) < 3:
return 0
max_left = [0] * len(height)
max_right = [0] * len(height)
for i in range(1, len(height)):
max_left[i] = max(height[i - 1], max_left[i - 1])
for i in ra... | class Solution:
def trap(self, height: List[int]) -> int:
if len(height) < 3:
return 0
max_left = [0] * len(height)
max_right = [0] * len(height)
for i in range(1, len(height)):
max_left[i] = max(height[i - 1], max_left[i - 1])
for i in range(len(heig... |
__version__ = "0.2.2"
__license__ = "MIT License"
__website__ = "https://code.exrny.com/opensource/vulcan-builder/"
__download_url__ = ('https://github.com/exrny/vulcan-builder/archive/'
'{}.tar.gz'.format(__version__))
| __version__ = '0.2.2'
__license__ = 'MIT License'
__website__ = 'https://code.exrny.com/opensource/vulcan-builder/'
__download_url__ = 'https://github.com/exrny/vulcan-builder/archive/{}.tar.gz'.format(__version__) |
"""
radish
~~~~~~
The root from red to green. BDD tooling for Python.
:copyright: (c) 2019 by Timo Furrer <tuxtimo@gmail.com>
:license: MIT, see LICENSE for more details.
"""
class Tag:
"""Represents a single Gherkin Tag"""
def __init__(self, name: str, path: str, line: int) -> None:
self.name = na... | """
radish
~~~~~~
The root from red to green. BDD tooling for Python.
:copyright: (c) 2019 by Timo Furrer <tuxtimo@gmail.com>
:license: MIT, see LICENSE for more details.
"""
class Tag:
"""Represents a single Gherkin Tag"""
def __init__(self, name: str, path: str, line: int) -> None:
self.name = nam... |
'''
Created on Mar 27, 2015
@author: maxz
'''
def lim(x, perc=.1):
r = x.max() - x.min()
return x.min()-perc*r, x.max()+perc*r
| """
Created on Mar 27, 2015
@author: maxz
"""
def lim(x, perc=0.1):
r = x.max() - x.min()
return (x.min() - perc * r, x.max() + perc * r) |
def most_frequent(data: list) -> str:
"""
determines the most frequently occurring string in the sequence.
"""
# your code here
return max(data, key=lambda x: data.count(x))
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testin... | def most_frequent(data: list) -> str:
"""
determines the most frequently occurring string in the sequence.
"""
return max(data, key=lambda x: data.count(x))
if __name__ == '__main__':
print('Example:')
print(most_frequent(['a', 'b', 'c', 'a', 'b', 'a']))
assert most_frequent(['a', 'b', '... |
def filter_positive_even_numbers(numbers):
"""Receives a list of numbers, and returns a filtered list of only the
numbers that are both positive and even (divisible by 2), try to use a
list comprehension."""
positive_even_numbers = [x for x in numbers if x > 0 and not x % 2]
return positive_... | def filter_positive_even_numbers(numbers):
"""Receives a list of numbers, and returns a filtered list of only the
numbers that are both positive and even (divisible by 2), try to use a
list comprehension."""
positive_even_numbers = [x for x in numbers if x > 0 and (not x % 2)]
return positive_... |
# Copyright 2019 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# Benchmark adapted from https://github.com/d5/tengobench/
doc="fib tail call recursion test"
def fib(n, a, b):
if n == 0:
return a
elif n ... | doc = 'fib tail call recursion test'
def fib(n, a, b):
if n == 0:
return a
elif n == 1:
return b
return fib(n - 1, b, a + b)
fib(35, 0, 1)
doc = 'finished' |
# Given a collection of distinct integers, return all possible permutations.
# Example:
# Input: [1,2,3]
# Output:
# [
# [1,2,3],
# [1,3,2],
# [2,1,3],
# [2,3,1],
# [3,1,2],
# [3,2,1]
# ]
class Solution:
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]... | class Solution:
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
res = []
self.helper(res, [], nums)
return res
def helper(self, res, cur, nums):
if len(cur) == len(nums):
res.append(cur + [])
... |
class ParsingError(Exception):
pass
| class Parsingerror(Exception):
pass |
__all__ = [
"ConsulError",
"ConflictError",
"NotFound",
"SupportDisabled",
"TransactionError",
"UnauthorizedError"
]
class ConsulError(Exception):
"""Consul base error
Attributes:
value (Object): object of the error
meta (Meta): meta of the error
"""
def __init... | __all__ = ['ConsulError', 'ConflictError', 'NotFound', 'SupportDisabled', 'TransactionError', 'UnauthorizedError']
class Consulerror(Exception):
"""Consul base error
Attributes:
value (Object): object of the error
meta (Meta): meta of the error
"""
def __init__(self, msg, *, meta=None... |
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_test")
# `dir` is path from WORKSPACE root.
def steep_check(name, bin, srcs, deps, dir = ".", rubyopt = []):
ruby_test(
name = name,
srcs = srcs,
deps = deps,
main = bin,
args = [
"check",
"--steepfile={}/Steepfile".format(dir),
... | load('@bazelruby_rules_ruby//ruby:defs.bzl', 'ruby_test')
def steep_check(name, bin, srcs, deps, dir='.', rubyopt=[]):
ruby_test(name=name, srcs=srcs, deps=deps, main=bin, args=['check', '--steepfile={}/Steepfile'.format(dir), '--steep-command={}/{}'.format(dir, name)], rubyopt=rubyopt) |
######################################################################
#
# File: b2sdk/transfer/inbound/file_metadata.py
#
# Copyright 2020 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
class FileMe... | class Filemetadata(object):
"""
Hold information about a file which is being downloaded.
"""
unverified_checksum_prefix = 'unverified:'
__slots__ = ('file_id', 'file_name', 'content_type', 'content_length', 'content_sha1', 'content_sha1_verified', 'file_info')
def __init__(self, file_id, file_n... |
class Location:
pass
class DecimalLocation:
pass
class GridLocation:
pass
| class Location:
pass
class Decimallocation:
pass
class Gridlocation:
pass |
# -*- coding: utf-8 -*-
"""Exceptions.
"""
class TinderException(Exception):
"""
"""
pass
class TinderAuthenticationException(TinderException):
"""
"""
pass
class TinderConnectionException(TinderException):
"""
"""
pass
| """Exceptions.
"""
class Tinderexception(Exception):
"""
"""
pass
class Tinderauthenticationexception(TinderException):
"""
"""
pass
class Tinderconnectionexception(TinderException):
"""
"""
pass |
def make_complex1(*args):
x, y = args
return dict(**locals())
def make_complex2(x, y):
return {'x': x, 'y': y}
print(make_complex1(5, 6))
print(make_complex2(5, 6))
| def make_complex1(*args):
(x, y) = args
return dict(**locals())
def make_complex2(x, y):
return {'x': x, 'y': y}
print(make_complex1(5, 6))
print(make_complex2(5, 6)) |
# -*- coding: utf-8 -*-
"""
fbone.modules.frontend
~~~~~~~~~~~~~~~~~~~~~~~~
frontend management commands
"""
| """
fbone.modules.frontend
~~~~~~~~~~~~~~~~~~~~~~~~
frontend management commands
""" |
"""
* @author: Shashank Jain
* @date: 25/12/2018
"""
a=input("Enter the string to count no. of vowels?")
b=list(a.replace(" ","").lower())
c=['a','e','i','o','u']
count=0
for i in b:
for j in c:
if (j==i):
count=count+1
print(count)
| """
* @author: Shashank Jain
* @date: 25/12/2018
"""
a = input('Enter the string to count no. of vowels?')
b = list(a.replace(' ', '').lower())
c = ['a', 'e', 'i', 'o', 'u']
count = 0
for i in b:
for j in c:
if j == i:
count = count + 1
print(count) |
# -*- coding: utf-8 -*-
"""
Student Do: Trading Log.
This script demonstrates how to perform basic analysis of trading profits/losses
over the course of a month (20 business days).
"""
# @TODO: Initialize the metric variables
# @TODO: Initialize lists to hold profitable and unprofitable day profits/losses
# L... | """
Student Do: Trading Log.
This script demonstrates how to perform basic analysis of trading profits/losses
over the course of a month (20 business days).
"""
trading_pnl = [-224, 352, 252, 354, -544, -650, 56, 123, -43, 254, 325, -123, 47, 321, 123, 133, -151, 613, 232, -311] |
"""
This file defines the structure of the JSON
responses expected by the Searcher module.
They are generated using the JSON Schema Tool,
available here https://jsonschema.net/
"""
# pylint: skip-file
SEARCH_RESULT_SCHEMA = {
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": ... | """
This file defines the structure of the JSON
responses expected by the Searcher module.
They are generated using the JSON Schema Tool,
available here https://jsonschema.net/
"""
search_result_schema = {'definitions': {}, '$schema': 'http://json-schema.org/draft-07/schema#', '$id': 'http://example.com/root.json', 't... |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def addOneRow(self, root, v, d):
"""
:type root: TreeNode
:type v: int
:type d: int
... | class Solution(object):
def add_one_row(self, root, v, d):
"""
:type root: TreeNode
:type v: int
:type d: int
:rtype: TreeNode
"""
if d == 1:
temp = tree_node(v)
temp.left = root
return temp
self.helper(root, v, d)
... |
if __name__ == '__main__':
def uninit_switch(*args):
raise TypeError("executed a case stmt outside switch's context")
class switch:
@property
def default(self):
if self.finished:
raise SyntaxError("multiple 'default' cases were provided")
self.fi... | if __name__ == '__main__':
def uninit_switch(*args):
raise type_error("executed a case stmt outside switch's context")
class Switch:
@property
def default(self):
if self.finished:
raise syntax_error("multiple 'default' cases were provided")
self... |
stamina = 6
alive=False
def report(stamina):
if stamina > 8:
print ("The alien is strong! It resists your pathetic attack!")
elif stamina > 5:
print ("With a loud grunt, the alien stands firm.")
elif stamina > 3:
print ("Your attack seems to be having an effect! The alien stu... | stamina = 6
alive = False
def report(stamina):
if stamina > 8:
print('The alien is strong! It resists your pathetic attack!')
elif stamina > 5:
print('With a loud grunt, the alien stands firm.')
elif stamina > 3:
print('Your attack seems to be having an effect! The alien stumbles!')... |
class EpisodeQuality:
def __init__(self, title: str, url: str):
self.title = title
self.url = url
| class Episodequality:
def __init__(self, title: str, url: str):
self.title = title
self.url = url |
#
# PySNMP MIB module APSLB-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APSLB-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:24:22 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... | (acmepacket_mgmt,) = mibBuilder.importSymbols('ACMEPACKET-SMI', 'acmepacketMgmt')
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraint... |
num="""\
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40... | num = '75\n95 64\n17 47 82\n18 35 87 10\n20 04 82 47 65\n19 01 23 75 03 34\n88 02 77 73 07 63 67\n99 65 04 28 06 16 70 92\n41 41 26 56 83 40 80 70 33\n41 48 72 33 47 32 37 16 94 29\n53 71 44 65 25 43 91 52 97 51 14\n70 11 33 28 77 73 17 78 39 68 17 57\n91 71 52 38 17 14 91 43 58 50 27 29 48\n63 66 04 68 89 53 67 30 73 ... |
#i'm an idiot, this algoritm is fucking useless, the FB and LR notation is literally binary notation.
def ticketCheck(line):
rowMin = 0
rowMax = 127
colMin = 0
colMax = 7
for i in range (7):
if line[i] == 'F':
rowMax = rowMin + abs(int((rowMax - rowMin)/2))
else: rowMin ... | def ticket_check(line):
row_min = 0
row_max = 127
col_min = 0
col_max = 7
for i in range(7):
if line[i] == 'F':
row_max = rowMin + abs(int((rowMax - rowMin) / 2))
else:
row_min = rowMax - abs(int((rowMax - rowMin) / 2))
for i in range(3):
if line[7... |
list = [50,100,150,200,250,300]
mininumber = list[0]
for x in list:
if mininumber > x:
mininumber = x
print("mininumber is ",mininumber)
| list = [50, 100, 150, 200, 250, 300]
mininumber = list[0]
for x in list:
if mininumber > x:
mininumber = x
print('mininumber is ', mininumber) |
# File: config.py
# Author: Qian Ge <geqian1001@gmail.com>
# directory of pre-trained vgg parameters
vgg_dir = '../../data/pretrain/vgg/vgg19.npy'
# directory of training data
data_dir = '../../data/dataset/256_ObjectCategories/'
# directory of testing data
test_data_dir = '../data/'
# directory of infe... | vgg_dir = '../../data/pretrain/vgg/vgg19.npy'
data_dir = '../../data/dataset/256_ObjectCategories/'
test_data_dir = '../data/'
infer_data_dir = '../data/'
infer_dir = '../../data/tmp/'
summary_dir = '../../data/tmp/'
checkpoint_dir = '../../data/tmp/'
model_dir = '../../data/tmp/'
result_dir = '../../data/tmp/' |
# Solution 1
# O(n^2) time | O(n) space
def longestIncreasingSubsequence(array):
if len(array) <= 1:
return array
sequences = [None for _ in range(len(array))]
lengths = [1 for _ in range(len(array))]
maxLenIdx = 0
for i in range(len(array)):
curNum = array[i]
for j in ra... | def longest_increasing_subsequence(array):
if len(array) <= 1:
return array
sequences = [None for _ in range(len(array))]
lengths = [1 for _ in range(len(array))]
max_len_idx = 0
for i in range(len(array)):
cur_num = array[i]
for j in range(i):
other_num = array[j... |
class Auth:
class general:
token = None # Token for general authentication
class live:
result = None # JSON result of the Live Auth request;
class Me(object):
def __init__(self):
self.id = None
self.username = None
self.auth = Auth
cl... | class Auth:
class General:
token = None
class Live:
result = None
class Me(object):
def __init__(self):
self.id = None
self.username = None
self.auth = Auth
class Http_Request:
class Login:
uri = 'https://social.triller.co/v1.5/user/auth'
hea... |
# MIT License
#
# Copyright (c) 2020 Evgeny Medvedev, evge.medvedev@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# ... | class Attesterslashing(object):
def __init__(self):
self.attestation_1_attesting_indices = []
self.attestation_1_slot = None
self.attestation_1_index = None
self.attestation_1_beacon_block_root = None
self.attestation_1_source_epoch = None
self.attestation_1_source_r... |
"""
pyrtf-ng Errors and Exceptions
"""
class RTFError(Exception):
pass
class ParseError(RTFError):
"""
Unable to parse the RTF data.
"""
| """
pyrtf-ng Errors and Exceptions
"""
class Rtferror(Exception):
pass
class Parseerror(RTFError):
"""
Unable to parse the RTF data.
""" |
def pytrades():
pass
def DiffEvol():
pass
def PyPolyChord():
pass
def PolyChord():
pass
def celerite():
pass
def ttvfast():
pass
def george():
pass
def batman():
pass
def dynesty():
pass
## absurd workaround to fix the lack of celerite in the system
def Celerite_QuasiPeriodi... | def pytrades():
pass
def diff_evol():
pass
def py_poly_chord():
pass
def poly_chord():
pass
def celerite():
pass
def ttvfast():
pass
def george():
pass
def batman():
pass
def dynesty():
pass
def celerite__quasi_periodic_activity():
pass
class Dummy_One:
def __init_... |
NO_ROLE_CODE = ''
TRUSTEE_CODE = '0'
STEWARD_CODE = '2'
TGB_CODE = '100'
TRUST_ANCHOR_CODE = '101'
| no_role_code = ''
trustee_code = '0'
steward_code = '2'
tgb_code = '100'
trust_anchor_code = '101' |
class PartialCumulativeClass:
'''
the concept:
'''
def __init__(self, conf, shared):
self.conf = conf
self.shared = shared
self.sharedAnalysis = None
# define data source / destination
# define data source / destination
self.dataSourceFilePath = ''
... | class Partialcumulativeclass:
"""
the concept:
"""
def __init__(self, conf, shared):
self.conf = conf
self.shared = shared
self.sharedAnalysis = None
self.dataSourceFilePath = ''
self.dataSourceFileName = ''
self.saveAnomaliesFilePath = self.conf.transac... |
'''
You are given an integer array nums sorted in non-decreasing order.
Build and return an integer array result with the same length as
nums such that result[i] is equal to the summation of absolute
differences between nums[i] and all the other elements in the
array.
In other words, result[i] is equal to sum(|num... | """
You are given an integer array nums sorted in non-decreasing order.
Build and return an integer array result with the same length as
nums such that result[i] is equal to the summation of absolute
differences between nums[i] and all the other elements in the
array.
In other words, result[i] is equal to sum(|num... |
#Servo test
e1 = Entry(root)
e1.grid(row=0, column=1)
def cal():
global dc
deg = abs(float(deg1))
dc = 0.056*deg + 2.5
p.ChangeDutyCycle(dc)
print(deg, dc) | e1 = entry(root)
e1.grid(row=0, column=1)
def cal():
global dc
deg = abs(float(deg1))
dc = 0.056 * deg + 2.5
p.ChangeDutyCycle(dc)
print(deg, dc) |
# Weight converter
weight = float(input("Weight?"))
unit = input("(L)bs or (K)g?")
if unit.upper() == "K":
print(weight*2.2)
elif unit.upper() == "L":
print(weight*0.45)
else:
print("Error, please verify your input") | weight = float(input('Weight?'))
unit = input('(L)bs or (K)g?')
if unit.upper() == 'K':
print(weight * 2.2)
elif unit.upper() == 'L':
print(weight * 0.45)
else:
print('Error, please verify your input') |
def stair_ways(n):
ways = [0] * n
ways[0] = 1
if n > 1:
ways[1] = 1
if n > 2:
ways[2] = 1
for p in range(0, n):
if p + 1 < n:
ways[p+1] += ways[p]
if p + 2 < n:
ways[p+2] += ways[p]
if p + 3 < n:
... | def stair_ways(n):
ways = [0] * n
ways[0] = 1
if n > 1:
ways[1] = 1
if n > 2:
ways[2] = 1
for p in range(0, n):
if p + 1 < n:
ways[p + 1] += ways[p]
if p + 2 < n:
ways[p + 2] += ways[p]
if p + 3 < n:
ways[p + 3] += ways[p]
... |
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 28 00:08:24 2017
@author: soumi
"""
## scale canvas pixels to android screen pixel
class SketchDipCalculator:
def __init__(self, width, height):
self.mHeightPx=height
self.mWidthPx = width
## default screen size consid... | """
Created on Tue Nov 28 00:08:24 2017
@author: soumi
"""
class Sketchdipcalculator:
def __init__(self, width, height):
self.mHeightPx = height
self.mWidthPx = width
standard_screen_width_dpi = 410
standard_screen_height_dpi = 730
self.mWidthDpr = self.mWidthPx / standard... |
#!/usr/bin/env python
a = 0
b = 1
while b < 100:
print(b)
a,b = b,a+b
| a = 0
b = 1
while b < 100:
print(b)
(a, b) = (b, a + b) |
"""
``pysiml`` is a python library for similarity measures
"""
__version__ = '0.1.0'
| """
``pysiml`` is a python library for similarity measures
"""
__version__ = '0.1.0' |
class state:
def __init__(self, name, population, area, capital):
self.name = name
self.population = population
self.area = area
self.capital = capital
def calc_density(self):
return self.area/self.population
state_1 = state('guj', 50000000, 40000000, 'gandhinagar')
sta... | class State:
def __init__(self, name, population, area, capital):
self.name = name
self.population = population
self.area = area
self.capital = capital
def calc_density(self):
return self.area / self.population
state_1 = state('guj', 50000000, 40000000, 'gandhinagar')
s... |
puffRstring = '''
impute_zeros <- function(x, y, bw){
k <- ksmooth(x=x, y=y, bandwidth=bw)
y[y == 0] <- k$y[y == 0]
return(y)
}
mednorm <- function(x){x/median(x)}
mednorm.ksmooth <-function(x,y,bw){mednorm(ksmooth(x=x,y=y,bandwidth = bw)$y)}
mednorm.ksmooth.norm <-function(x,y,bw,norm.y){mednorm.ksmooth(... | puff_rstring = '\nimpute_zeros <- function(x, y, bw){\n k <- ksmooth(x=x, y=y, bandwidth=bw)\n y[y == 0] <- k$y[y == 0]\n return(y)\n}\nmednorm <- function(x){x/median(x)}\nmednorm.ksmooth <-function(x,y,bw){mednorm(ksmooth(x=x,y=y,bandwidth = bw)$y)}\nmednorm.ksmooth.norm <-function(x,y,bw,norm.y){mednorm.ksm... |
# -----------------
# User Instructions
#
# In this problem, you will generalize the bridge problem
# by writing a function bridge_problem3, that makes a call
# to lowest_cost_search.
def bridge_problem3(here):
"""Find the fastest (least elapsed time) path to
the goal in the bridge problem."""
# your co... | def bridge_problem3(here):
"""Find the fastest (least elapsed time) path to
the goal in the bridge problem."""
start = (frozenset(here) | frozenset(['light']), frozenset())
def is_goal(state):
(state_here, _) = state
return state_here == frozenset() or here == set(['light'])
return... |
#
# PySNMP MIB module Unisphere-Data-IP-PROFILE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Unisphere-Data-IP-PROFILE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:31:34 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ve... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, value_size_constraint, single_value_constraint, value_range_constraint) ... |
def checkInline(s):
i = 0
while True:
try:
if s[i] == '$':
return i
except IndexError:
return -1
i += 1
def checkOutline(s):
return s == "<p class='md-math-block'>$"
def main():
f = open("./output.txt", "w")
while True:
s = ... | def check_inline(s):
i = 0
while True:
try:
if s[i] == '$':
return i
except IndexError:
return -1
i += 1
def check_outline(s):
return s == "<p class='md-math-block'>$"
def main():
f = open('./output.txt', 'w')
while True:
s = ... |
## Read input as specified in the question.
## Print output as specified in the question.
N = int(input())
for i in range(1, N+1):
for j in range(0, i):
x = i - 1
if x == 0:
print("1", end='')
else:
if x == j or j == 0:
print(x, end = '')
e... | n = int(input())
for i in range(1, N + 1):
for j in range(0, i):
x = i - 1
if x == 0:
print('1', end='')
elif x == j or j == 0:
print(x, end='')
else:
print(0, end='')
print() |
def solution(n):
if str(n ** (1/2))[-2] == '.': return int(((n **(1/2))+1) ** 2)
else: return -1
print(solution(121))
print(solution(3)) | def solution(n):
if str(n ** (1 / 2))[-2] == '.':
return int((n ** (1 / 2) + 1) ** 2)
else:
return -1
print(solution(121))
print(solution(3)) |
# Find the thirteen adjacent digits in the 1000-digit number that have the
# greatest product. What is the value of this product?
# Problem taken from https://projecteuler.net/problem=8
number = "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545... | number = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729... |
OPTIONAL_FIELDS = [
'tags', 'consumes', 'produces', 'schemes', 'security',
'deprecated', 'operationId', 'externalDocs'
]
OPTIONAL_OAS3_FIELDS = [
'components', 'servers'
]
| optional_fields = ['tags', 'consumes', 'produces', 'schemes', 'security', 'deprecated', 'operationId', 'externalDocs']
optional_oas3_fields = ['components', 'servers'] |
rows=6
for num in range(rows):
for i in range(num):
print(num, end=" ")
print()
'''
Step for num in range(6):
step1:num=0
for i in range(0): 0,0
--------------------- skip
step2:num=1
for i in range(1): 0,1
1
step3:num=2
for i in ra... | rows = 6
for num in range(rows):
for i in range(num):
print(num, end=' ')
print()
'\nStep for num in range(6):\n step1:num=0\n for i in range(0): 0,0\n --------------------- skip\n step2:num=1\n for i in range(1): 0,1\n 1\n step3:num=2\n for i... |
class NotImplementedException(Exception):
pass
class GeolocationBackend(object):
def __init__(self, ip):
self._ip = ip
self._continent = None
self._country = None
self._geo_data = None
self._raw_data = None
def geolocate(self):
raise NotImplementedException(... | class Notimplementedexception(Exception):
pass
class Geolocationbackend(object):
def __init__(self, ip):
self._ip = ip
self._continent = None
self._country = None
self._geo_data = None
self._raw_data = None
def geolocate(self):
raise not_implemented_excepti... |
class Solution:
def missingNumber(self, arr: List[int]) -> int:
x=int(((len(arr)+1)/2)*(arr[0]+arr[-1]))
return x-sum(arr)
| class Solution:
def missing_number(self, arr: List[int]) -> int:
x = int((len(arr) + 1) / 2 * (arr[0] + arr[-1]))
return x - sum(arr) |
def deep_merge_dicts(dict1, dict2):
output = {}
# adds keys from `dict1` if they do not exist in `dict2` and vice-versa
intersection = {**dict2, **dict1}
for k_intersect, v_intersect in intersection.items():
if k_intersect not in dict1:
v_dict2 = dict2[k_intersect]
outp... | def deep_merge_dicts(dict1, dict2):
output = {}
intersection = {**dict2, **dict1}
for (k_intersect, v_intersect) in intersection.items():
if k_intersect not in dict1:
v_dict2 = dict2[k_intersect]
output[k_intersect] = v_dict2
elif k_intersect not in dict2:
... |
def sayHello(name):
'''say hello to given name'''
print(f'Hello, {name}')
| def say_hello(name):
"""say hello to given name"""
print(f'Hello, {name}') |
# Prepare the data
piedpiper=np.array([4.57, 4.55, 5.47, 4.67, 5.41, 5.55, 5.53, 5.63, 3.86, 3.97, 5.44, 3.93, 5.31, 5.17, 4.39, 4.28, 5.25])
endframe = np.array([4.27, 3.93, 4.01, 4.07, 3.87, 4. , 4. , 3.72, 4.16, 4.1 , 3.9 , 3.97, 4.08, 3.96, 3.96, 3.77, 4.09])
# Assumption check
check_normality(piedpiper)
check_nor... | piedpiper = np.array([4.57, 4.55, 5.47, 4.67, 5.41, 5.55, 5.53, 5.63, 3.86, 3.97, 5.44, 3.93, 5.31, 5.17, 4.39, 4.28, 5.25])
endframe = np.array([4.27, 3.93, 4.01, 4.07, 3.87, 4.0, 4.0, 3.72, 4.16, 4.1, 3.9, 3.97, 4.08, 3.96, 3.96, 3.77, 4.09])
check_normality(piedpiper)
check_normality(endframe)
(test, pvalue) = stats... |
"""
segmentation.py
SCTE35 Segmentation Descriptor tables.
"""
"""
Table 20 from page 58 of
https://www.scte.org/SCTEDocs/Standards/ANSI_SCTE%2035%202019r1.pdf
"""
table20 = {
0x00: "Restrict Group 0",
0x01: "Restrict Group 1",
0x02: "Restrict Group 2",
0x03: "No Restrictions",
}
"""
table 22 from pa... | """
segmentation.py
SCTE35 Segmentation Descriptor tables.
"""
'\nTable 20 from page 58 of\nhttps://www.scte.org/SCTEDocs/Standards/ANSI_SCTE%2035%202019r1.pdf\n'
table20 = {0: 'Restrict Group 0', 1: 'Restrict Group 1', 2: 'Restrict Group 2', 3: 'No Restrictions'}
'\ntable 22 from page 62 of\nhttps://www.scte.org/SCTE... |
pkgname = "pcre"
pkgver = "8.45"
pkgrel = 0
build_style = "gnu_configure"
configure_args = [
"--with-pic",
"--enable-utf8",
"--enable-unicode-properties",
"--enable-pcretest-libedit",
"--enable-pcregrep-libz",
"--enable-pcregrep-libbz2",
"--enable-newline-is-anycrlf",
"--enable-jit",
... | pkgname = 'pcre'
pkgver = '8.45'
pkgrel = 0
build_style = 'gnu_configure'
configure_args = ['--with-pic', '--enable-utf8', '--enable-unicode-properties', '--enable-pcretest-libedit', '--enable-pcregrep-libz', '--enable-pcregrep-libbz2', '--enable-newline-is-anycrlf', '--enable-jit', '--enable-static', '--disable-stack-... |
"""@package gensolver_dumper
Abstract class for dumpers.
"""
class GenSolverDumper:
def __init__(self, output_file):
""" Abstract class for creating dumper objects.
:param str output_file: Path to the file to store output, if output_file == '' then will not output to file.
"""
se... | """@package gensolver_dumper
Abstract class for dumpers.
"""
class Gensolverdumper:
def __init__(self, output_file):
""" Abstract class for creating dumper objects.
:param str output_file: Path to the file to store output, if output_file == '' then will not output to file.
"""
sel... |
def m2f_e(s, st):
return [[st.index(ch), st.insert(0, st.pop(st.index(ch)))][0] for ch in s]
def m2f_d(sq, st):
return ''.join([st[i], st.insert(0, st.pop(i))][0] for i in sq)
ST = list('abcdefghijklmnopqrstuvwxyz')
for s in ['broood', 'bananaaa', 'hiphophiphop']:
encode = m2f_e(s, ST[::])
print('%14r... | def m2f_e(s, st):
return [[st.index(ch), st.insert(0, st.pop(st.index(ch)))][0] for ch in s]
def m2f_d(sq, st):
return ''.join(([st[i], st.insert(0, st.pop(i))][0] for i in sq))
st = list('abcdefghijklmnopqrstuvwxyz')
for s in ['broood', 'bananaaa', 'hiphophiphop']:
encode = m2f_e(s, ST[:])
print('%14r... |
def get_pyenv_root():
return "/usr/local/pyenv"
def get_user():
return "root"
def get_group():
return "root"
def get_rc_file():
return "/etc/profile.d/pyenv.sh"
def get_python_test_case():
return "3.9.0", True
def get_venv_test_case():
return "neovim", True
| def get_pyenv_root():
return '/usr/local/pyenv'
def get_user():
return 'root'
def get_group():
return 'root'
def get_rc_file():
return '/etc/profile.d/pyenv.sh'
def get_python_test_case():
return ('3.9.0', True)
def get_venv_test_case():
return ('neovim', True) |
# https://www.hackerrank.com/challenges/30-testing/forum/comments/138775
print("5")
print("5 3\n-1 90 999 100 0")
print("4 2\n0 -1 2 1")
print("3 3\n-1 0 1")
print("6 1\n-1 0 1 -1 2 3")
print("7 3\n-1 0 1 2 3 4 5")
| print('5')
print('5 3\n-1 90 999 100 0')
print('4 2\n0 -1 2 1')
print('3 3\n-1 0 1')
print('6 1\n-1 0 1 -1 2 3')
print('7 3\n-1 0 1 2 3 4 5') |
def inorde_tree_walk(self, vertice = None):
if(self.raiz == None): #arvore vazia
return
if(verice == None): #Por padrao comeca pela raiz
vertice = self.raiz
if(vertice.left != None): #Decomposicao
self.inorde_tree_walk(vertice = vertice.left)
print(vertice)
if(ver... | def inorde_tree_walk(self, vertice=None):
if self.raiz == None:
return
if verice == None:
vertice = self.raiz
if vertice.left != None:
self.inorde_tree_walk(vertice=vertice.left)
print(vertice)
if vertice.right != None:
self.inorde_tree_walk(vertice=vertice.right) |
#
# PySNMP MIB module HM2-DHCPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HM2-DHCPS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:31:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint) ... |
class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def insert(root, value):
"""
For a binary search tree
"""
if root is None:
return Node(value)
node = root
parent = None
new = Node(value)
while True:
parent = node
if value < parent.d... | class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def insert(root, value):
"""
For a binary search tree
"""
if root is None:
return node(value)
node = root
parent = None
new = node(value)
while True:
parent... |
table_pkeys_map = {
"account": [
"account_id"
],
"account_assignd_cert": [
"account_id",
"x509_cert_id",
"x509_key_usg"
],
"account_auth_log": [
"account_id",
"account_auth_ts",
"auth_resource",
"account_auth_seq"
],
"account_co... | table_pkeys_map = {'account': ['account_id'], 'account_assignd_cert': ['account_id', 'x509_cert_id', 'x509_key_usg'], 'account_auth_log': ['account_id', 'account_auth_ts', 'auth_resource', 'account_auth_seq'], 'account_coll_type_relation': ['account_collection_type', 'account_collection_relation'], 'account_collection'... |
""" Largest element in the array. """
class Solution:
""" Naive Solution.
Time complexity: O(n^2)
"""
def largestElementInArray(self, arr):
i = 0
while i <len(arr):
j =i+1
while j< len(arr):
if arr[i] > arr[j]:
arr[i], arr[... | """ Largest element in the array. """
class Solution:
""" Naive Solution.
Time complexity: O(n^2)
"""
def largest_element_in_array(self, arr):
i = 0
while i < len(arr):
j = i + 1
while j < len(arr):
if arr[i] > arr[j]:
(ar... |
# LANGUAGE: Python
# AUTHOR: randy
# GITHUB: https://github.com/randy1369
print('Hello, python!') | print('Hello, python!') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.