content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class FlaskRequest(object):
"""
A Request class to connect the Piwik API to Flask
"""
def __init__(self, request):
"""
:param request: Flask request object.
:type request: flask.Request
:rtype: None
"""
self.request = request
@property
def META(s... | class Flaskrequest(object):
"""
A Request class to connect the Piwik API to Flask
"""
def __init__(self, request):
"""
:param request: Flask request object.
:type request: flask.Request
:rtype: None
"""
self.request = request
@property
def meta(s... |
# Sal's Shipping
# Eleni A.
weight = 41.5
GS_FLAT = 20
GSP_FLAT = 125
# Basic Scale Shipping
def basic_shipping(weight):
if weight <= 2:
cost = weight * 1.50
elif weight <= 6:
cost = weight * 3
elif weight <=10:
cost = weight * 4
else:
cost = weight * 4.75
return cost
# Ground Shipping
def ... | weight = 41.5
gs_flat = 20
gsp_flat = 125
def basic_shipping(weight):
if weight <= 2:
cost = weight * 1.5
elif weight <= 6:
cost = weight * 3
elif weight <= 10:
cost = weight * 4
else:
cost = weight * 4.75
return cost
def ground_shipping(weight):
cost = basic_sh... |
"""
Product of Array Except Self
Given an integer array nums, return an array answer such that answer[i] is equal to the product of
all the elements of nums except nums[i].
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
You must write an algorithm that runs in O(n) time and w... | """
Product of Array Except Self
Given an integer array nums, return an array answer such that answer[i] is equal to the product of
all the elements of nums except nums[i].
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
You must write an algorithm that runs in O(n) time and w... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: 2017, Dag Wieers (@dagwieers) <dag@wieers.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by... | ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
documentation = "\n---\nmodule: win_defrag\nversion_added: '2.4'\nshort_description: Consolidate fragmented files on local volumes\ndescription:\n- Locates and consolidates fragmented files on local volumes to improve sys... |
def open_dev( ):
''' Opens the red light LEDR device
:return: 1 on success, else 0
'''
def set(data):
''' Sets the red light LEDR device
:param data: the integer data to write to LEDR. If data = 0 all lights will be
turned off. If data = 0b1111111111 all lights will be turned on
:retu... | def open_dev():
""" Opens the red light LEDR device
:return: 1 on success, else 0
"""
def set(data):
""" Sets the red light LEDR device
:param data: the integer data to write to LEDR. If data = 0 all lights will be
turned off. If data = 0b1111111111 all lights will be turned on
:retu... |
del_items(0x801234F4)
SetType(0x801234F4, "void GameOnlyTestRoutine__Fv()")
del_items(0x801234FC)
SetType(0x801234FC, "int vecleny__Fii(int a, int b)")
del_items(0x80123520)
SetType(0x80123520, "int veclenx__Fii(int a, int b)")
del_items(0x8012354C)
SetType(0x8012354C, "void GetDamageAmt__FiPiT1(int i, int *mind, int *... | del_items(2148676852)
set_type(2148676852, 'void GameOnlyTestRoutine__Fv()')
del_items(2148676860)
set_type(2148676860, 'int vecleny__Fii(int a, int b)')
del_items(2148676896)
set_type(2148676896, 'int veclenx__Fii(int a, int b)')
del_items(2148676940)
set_type(2148676940, 'void GetDamageAmt__FiPiT1(int i, int *mind, i... |
def simple(arry, target):
# simple search
arry = [i for i in range(20)]
for i in arry:
print("%d steps" % i)
if i == target:
print("Found %d" % i)
break
def binary_search(arry, target):
# binary search
l = 0 # left pointer
r = len(arry) - 1 # right poi... | def simple(arry, target):
arry = [i for i in range(20)]
for i in arry:
print('%d steps' % i)
if i == target:
print('Found %d' % i)
break
def binary_search(arry, target):
l = 0
r = len(arry) - 1
step = 0
while l <= r:
step += 1
mid = l + (r... |
FreeMono9pt7bBitmaps = [
0xAA, 0xA8, 0x0C, 0xED, 0x24, 0x92, 0x48, 0x24, 0x48, 0x91, 0x2F, 0xE4,
0x89, 0x7F, 0x28, 0x51, 0x22, 0x40, 0x08, 0x3E, 0x62, 0x40, 0x30, 0x0E,
0x01, 0x81, 0xC3, 0xBE, 0x08, 0x08, 0x71, 0x12, 0x23, 0x80, 0x23, 0xB8,
0x0E, 0x22, 0x44, 0x70, 0x38, 0x81, 0x02, 0x06, 0x1A, 0x65, 0x4... | free_mono9pt7b_bitmaps = [170, 168, 12, 237, 36, 146, 72, 36, 72, 145, 47, 228, 137, 127, 40, 81, 34, 64, 8, 62, 98, 64, 48, 14, 1, 129, 195, 190, 8, 8, 113, 18, 35, 128, 35, 184, 14, 34, 68, 112, 56, 129, 2, 6, 26, 101, 70, 200, 236, 233, 36, 90, 170, 169, 64, 169, 85, 90, 128, 16, 34, 75, 227, 5, 17, 0, 16, 32, 71, 2... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Current source: https://github.com/open-security/vulnpwn/
##
class FrameworkException(Exception):
pass
class OptionValidationError(FrameworkException):
pass
| class Frameworkexception(Exception):
pass
class Optionvalidationerror(FrameworkException):
pass |
def load(h):
return ({'abbr': 'none', 'code': 0, 'title': 'not set'},
{'abbr': 96,
'code': 96,
'title': 'HIRLAM data',
'units': 'non-standard, deprecated'},
{'abbr': 98,
'code': 98,
'title': 'previously used to tag SMHI data th... | def load(h):
return ({'abbr': 'none', 'code': 0, 'title': 'not set'}, {'abbr': 96, 'code': 96, 'title': 'HIRLAM data', 'units': 'non-standard, deprecated'}, {'abbr': 98, 'code': 98, 'title': 'previously used to tag SMHI data that is ECMWF compliant', 'units': 'deprecated'}) |
# Daniel Mc Callion
# Computing the primes
# My list of primes
p = []
# Loop through all of the numbers we're
# checking for primality
for i in range (2,10000):
# Assume that i is a prime
is_prime = True
# Look through all values j from 2 up
# to but not including i
# for j in range(2,i):
for... | p = []
for i in range(2, 10000):
is_prime = True
for j in p:
if i % j == 0:
is_prime = False
break
if is_prime:
p.append(i)
print(p) |
# Section 1: Comments and Print
# A single line comment in python is indicated by a # at the beginning
''' This
is
a
multiline
comment '''
# A print function prints the code to the console, useful to learn and to debug
print('This is a print') # a comment can also be added after a funcion declaration or variable dec... | """ This
is
a
multiline
comment """
print('This is a print')
print('you can print multiple things separated by a comma', 'like this and python will add a space in between')
var_1 = 5
var_2 = 'a'
var_3 = 1.0
print('Hello World!')
print('Hello', 'World!')
print('Hello', end=' ')
print('World!')
print('var_1', var_1)
p... |
# -*- coding: utf-8 -*-
"""Top-level package for Music Downloader Telegram Bot."""
__author__ = """@Bots_Ki_Duniya"""
__reportbugs__ = "@Mr_Ninjas_Bot"
__version__ = "0.13.7"
| """Top-level package for Music Downloader Telegram Bot."""
__author__ = '@Bots_Ki_Duniya'
__reportbugs__ = '@Mr_Ninjas_Bot'
__version__ = '0.13.7' |
inputstr="SecondMostFrequentCharacterInTheString"
safe=inputstr
countar=[]
count=0
for i in inputstr:
if(i!='#'):
countar.append(inputstr.count(i))
print(i,inputstr.count(i),end=", ")
inputstr=inputstr.replace(i,'#')
else:
continue
firstmax=max(countar)
countar.remove... | inputstr = 'SecondMostFrequentCharacterInTheString'
safe = inputstr
countar = []
count = 0
for i in inputstr:
if i != '#':
countar.append(inputstr.count(i))
print(i, inputstr.count(i), end=', ')
inputstr = inputstr.replace(i, '#')
else:
continue
firstmax = max(countar)
countar.re... |
class Solution:
def reverseBetween(self, head: ListNode,
left: int, right: int) -> ListNode:
# Base case scenario
if left == right:
return head
node = ptr = ListNode() # Dummy node before actual linked list
node.next = head
# First traver... | class Solution:
def reverse_between(self, head: ListNode, left: int, right: int) -> ListNode:
if left == right:
return head
node = ptr = list_node()
node.next = head
for _ in range(1, left):
ptr = ptr.next
current_node = ptr.next
while left < ... |
codigo_set = set()
codido_set_saiu = set()
s = input()
codigos = input().split(' ')
for codigo in codigos:
codigo_set.add(codigo)
i = input()
saidas = input().split(' ')
A = 0
I = 0
R = 0
for saida in saidas:
if saida in codigo_set:
if saida in codido_set_saiu:
R += 1
else:
A += 1... | codigo_set = set()
codido_set_saiu = set()
s = input()
codigos = input().split(' ')
for codigo in codigos:
codigo_set.add(codigo)
i = input()
saidas = input().split(' ')
a = 0
i = 0
r = 0
for saida in saidas:
if saida in codigo_set:
if saida in codido_set_saiu:
r += 1
else:
... |
"""
This is a Utility to parse a file.
"""
def parse_file(input_file = ""):
try:
with open(input_file , 'r') as file:
lines = [line.rstrip() for line in file]
return lines
except :
return None
| """
This is a Utility to parse a file.
"""
def parse_file(input_file=''):
try:
with open(input_file, 'r') as file:
lines = [line.rstrip() for line in file]
return lines
except:
return None |
# Configuration file for the Sphinx documentation builder.
project = 'pathlib2'
copyright = '2012-2014 Antoine Pitrou and contributors; 2014-2021, Matthias C. M. Troffaes and contributors'
author = 'Matthias C. M. Troffaes'
# The full version, including alpha/beta/rc tags
with open("../VERSION", "r") as version_file:... | project = 'pathlib2'
copyright = '2012-2014 Antoine Pitrou and contributors; 2014-2021, Matthias C. M. Troffaes and contributors'
author = 'Matthias C. M. Troffaes'
with open('../VERSION', 'r') as version_file:
release = version_file.read().strip()
extensions = []
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Sto... |
#
# PySNMP MIB module Dell-vlan-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Dell-vlan-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:43:15 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... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, single_value_constraint, value_range_constraint, constraints_union) ... |
_base_ = [
'../_base_/models/mask_rcnn_r50_fpn.py',
'../_base_/datasets/coco_instance.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
rpn_head=dict(
anchor_generator=dict(type='LegacyAnchorGenerator', center_offset=0.5),
bbox_coder=dict... | _base_ = ['../_base_/models/mask_rcnn_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
model = dict(rpn_head=dict(anchor_generator=dict(type='LegacyAnchorGenerator', center_offset=0.5), bbox_coder=dict(type='LegacyDeltaXYWHBBoxCoder'), loss_bbox=d... |
# TODO: Finish exception implementation, with single exception used to manage hiding error details from user in UI
class GigantumException(Exception):
"""Any Exception arising from inside the Labbook class will be cast as a LabbookException.
This is to avoid having "except Exception" clauses in the client cod... | class Gigantumexception(Exception):
"""Any Exception arising from inside the Labbook class will be cast as a LabbookException.
This is to avoid having "except Exception" clauses in the client code, and to avoid
having to be aware of every sub-library that is used by the Labbook and the exceptions that thos... |
"""
cmd.do('set ellipsoid_color, ${1:color};')
cmd.do('${0}')
"""
cmd.do('set ellipsoid_color, color;')
# Description: Set ellipsoid color.
# Source: placeHolder
| """
cmd.do('set ellipsoid_color, ${1:color};')
cmd.do('${0}')
"""
cmd.do('set ellipsoid_color, color;') |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: illuz <iilluzen[at]gmail.com>
# File: AC_stack_dict_n.py
# Create Date: 2015-03-04 19:47:43
# Usage: AC_stack_dict_n.py
# Descripton:
class Solution:
# @return a boolean
def isValid(self, s):
mp = {')': '(', ']': '[', '}': '{'}
... | class Solution:
def is_valid(self, s):
mp = {')': '(', ']': '[', '}': '{'}
stk = []
for ch in s:
if ch in '([{':
stk.append(ch)
elif not stk or mp[ch] != stk.pop():
return False
return not stk |
class Button(object):
"""Button object, used for creating button messages"""
def __init__(self, type=None, title="", payload=""):
# Type: request param key
valid_types = {
'web_url': 'url',
'postback': 'payload'
}
assert type in valid_types, "Type %s i... | class Button(object):
"""Button object, used for creating button messages"""
def __init__(self, type=None, title='', payload=''):
valid_types = {'web_url': 'url', 'postback': 'payload'}
assert type in valid_types, 'Type %s is not a Button type' % (type,)
self.title = title
self.... |
"""
Equation:
x^3 - 2400x^2 - 3x + 2 = 0
x = [0, ]
"""
def bisection(lb, ub, e, iter):
lv = lb**3-2400*(lb**2)-3*lb+2
uv = ub**3-2400*(ub**2)-3*ub+2
if lv*uv > 0:
print("No root found")
return
prev_mid = (lb+ub)/2
f_lb = lb**3-2400*(lb**2)-3*lb+2
f_mid = prev_mid**... | """
Equation:
x^3 - 2400x^2 - 3x + 2 = 0
x = [0, ]
"""
def bisection(lb, ub, e, iter):
lv = lb ** 3 - 2400 * lb ** 2 - 3 * lb + 2
uv = ub ** 3 - 2400 * ub ** 2 - 3 * ub + 2
if lv * uv > 0:
print('No root found')
return
prev_mid = (lb + ub) / 2
f_lb = lb ** 3 - 2400 * lb ** 2 - 3... |
f = open('sample-input.txt')
o = open('sample-output.txt', 'w')
t = int(f.readline().strip())
for i in xrange(1, t + 1):
o.write("Case #{}: ".format(i))
n = int(f.readline().strip())
x = [int(j) for j in f.readline().strip().split()]
y = [int(j) for j in f.readline().strip().split()]
o.write("\n")
| f = open('sample-input.txt')
o = open('sample-output.txt', 'w')
t = int(f.readline().strip())
for i in xrange(1, t + 1):
o.write('Case #{}: '.format(i))
n = int(f.readline().strip())
x = [int(j) for j in f.readline().strip().split()]
y = [int(j) for j in f.readline().strip().split()]
o.write('\n') |
"""Undocumented Module"""
__all__ = []
## from DirectObject import *
## from pandac.PandaModules import *
##
## class PandaObject(DirectObject):
## """
## This is the class that all Panda/Show classes should inherit from
## """
## pass
| """Undocumented Module"""
__all__ = [] |
class Users:
def __init__(self, id, name, surname, password, email, changepass, read_comment, read_like):
self.id = id
self.name = name
self.surname = surname
self.password = password
self.email = email
self.changepass = changepass
self.read_comment = read_co... | class Users:
def __init__(self, id, name, surname, password, email, changepass, read_comment, read_like):
self.id = id
self.name = name
self.surname = surname
self.password = password
self.email = email
self.changepass = changepass
self.read_comment = read_co... |
M = int(input())
m1 = set(map(int, input().split()))
N = int(input())
n1 = set(map(int, input().split()))
output = list(m1.union(n1).difference(m1.intersection(n1)))
output.sort()
for i in output:
print(i)
| m = int(input())
m1 = set(map(int, input().split()))
n = int(input())
n1 = set(map(int, input().split()))
output = list(m1.union(n1).difference(m1.intersection(n1)))
output.sort()
for i in output:
print(i) |
"""
Version of drf_editable
"""
__version__ = '0.0.1'
| """
Version of drf_editable
"""
__version__ = '0.0.1' |
"""A series of modules containing dictionaries that can be used in run.py"""
def test_person_set_1():
person1 = {
"name": "Steven",
"age": 12,
"likes": "action",
"availability": 3
}
person2 = {
"name": "Jane",
"age": 23,
"likes": "roma... | """A series of modules containing dictionaries that can be used in run.py"""
def test_person_set_1():
person1 = {'name': 'Steven', 'age': 12, 'likes': 'action', 'availability': 3}
person2 = {'name': 'Jane', 'age': 23, 'likes': 'romance', 'availability': 2}
person3 = {'name': 'Alice', 'age': 18, 'likes': 'r... |
class ALonelyClass:
'''
A multiline class docstring.
'''
def AnEquallyLonelyMethod(self):
'''
A multiline method docstring'''
pass
def one_function():
'''This is a docstring with a single line of text.'''
pass
def shockingly_the_quotes_are_normalized():
'''This is... | class Alonelyclass:
"""
A multiline class docstring.
"""
def an_equally_lonely_method(self):
"""
A multiline method docstring"""
pass
def one_function():
"""This is a docstring with a single line of text."""
pass
def shockingly_the_quotes_are_normalized():
"""This ... |
## UVSError handling guidelines:
# 1- don't use OOP exceptions, NEVER NEVER NEVER use inheritance in exceptions
# i dont like exception X that inherits from Y and 2mrw is a G then suddenly catches an F blah blah
# doing the above makes it harder not easier to figure out what the hell happened.
# ju... | class Uvserror(Exception):
pass |
"""
Module: 'cmath' on micropython-maixpy-0.6.2-66
"""
# MCU: {'ver': '0.6.2-66', 'build': '66', 'sysname': 'MaixPy', 'platform': 'MaixPy', 'version': '0.6.2', 'release': '0.6.2', 'port': 'MaixPy', 'family': 'micropython', 'name': 'micropython', 'machine': 'Sipeed_M1 with kendryte-k210', 'nodename': 'MaixPy'}
# Stubber... | """
Module: 'cmath' on micropython-maixpy-0.6.2-66
"""
def cos():
pass
e = 2.718282
def exp():
pass
def log():
pass
def log10():
pass
def phase():
pass
pi = 3.141593
def polar():
pass
def rect():
pass
def sin():
pass
def sqrt():
pass |
def SumOfTwoNums(array , target):
"""
Get THe Sum of Two Numbers from an array to match the required target
"""
#sort the array
array.sort()
NumSums = []
left = 0
right = len(array)-1
while left < right:
currSum = array[left] + array[right]
# print(left , right , c... | def sum_of_two_nums(array, target):
"""
Get THe Sum of Two Numbers from an array to match the required target
"""
array.sort()
num_sums = []
left = 0
right = len(array) - 1
while left < right:
curr_sum = array[left] + array[right]
if currSum == target:
NumSums... |
# This is an input class. Do not edit.
class LinkedList:
def __init__(self, value):
self.value = value
self.next = None
def reverseLinkedList(head):
# The trick of the problem is that we need to use three pointers, not two (which is the common pattern).
# the first and third pointer act as a ... | class Linkedlist:
def __init__(self, value):
self.value = value
self.next = None
def reverse_linked_list(head):
(p1, p2) = (None, head)
while p2 is not None:
p3 = p2.next
p2.next = p1
p1 = p2
p2 = p3
return p1 |
# cycle.py
def cycle(iterable):
index = 0
length = len(iterable)
while True:
for index in range(length):
yield index
endless = cycle(range(0, 10))
for item in endless:
print(item)
| def cycle(iterable):
index = 0
length = len(iterable)
while True:
for index in range(length):
yield index
endless = cycle(range(0, 10))
for item in endless:
print(item) |
# Copyright 2021 The Bazel Authors. All rights reserved.
#
# 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... | """Defines create_rule and create_dep macros"""
def create_rule(impl, attrs={}, deps=[], fragments=[], remove_attrs=[], **kwargs):
"""Creates a rule composed from dependencies.
Args:
impl: The implementation function of the rule, taking as parameters the
rule ctx followed by the executable... |
def oddTuples(aTup):
'''
aTup: a tuple
returns: tuple, every other element of aTup.
'''
# using tuple slicing method
return aTup[0: :2]
| def odd_tuples(aTup):
"""
aTup: a tuple
returns: tuple, every other element of aTup.
"""
return aTup[0::2] |
mylang='fr'
family = 'wikipedia'
usernames['wikipedia']['fr']=u'Arktest'
console_encoding = 'utf-8'
| mylang = 'fr'
family = 'wikipedia'
usernames['wikipedia']['fr'] = u'Arktest'
console_encoding = 'utf-8' |
#!/usr/bin/python3
"""Square class creation
"""
class Square:
"""Bypass attributes or methods declaration
"""
pass
| """Square class creation
"""
class Square:
"""Bypass attributes or methods declaration
"""
pass |
'''
@author: Pranshu Aggarwal
@problem: https://hack.codingblocks.com/app/practice/1/285/problem
Algorithm to Generate(arr, n):
for row:=0 to n step by 1,
for col:=0 to row + 1 step by 1,
Set arr[row][col] = 1 if column is 0 or equals row
Set arr[row][col] = (Sum of Diagonally Pre... | """
@author: Pranshu Aggarwal
@problem: https://hack.codingblocks.com/app/practice/1/285/problem
Algorithm to Generate(arr, n):
for row:=0 to n step by 1,
for col:=0 to row + 1 step by 1,
Set arr[row][col] = 1 if column is 0 or equals row
Set arr[row][col] = (Sum of Diagonally Pre... |
#!/usr/bin/env python3
# https://codeforces.com/problemset/problem/1332/A
def f(l):
a,c = l
p = 1
r = 0
while a>0 or c>0:
r += p*((c%3-a%3)%3)
p *= 3
c = c//3
a = a//3
return r
l = list(map(int,input().split()))
print(f(l))
| def f(l):
(a, c) = l
p = 1
r = 0
while a > 0 or c > 0:
r += p * ((c % 3 - a % 3) % 3)
p *= 3
c = c // 3
a = a // 3
return r
l = list(map(int, input().split()))
print(f(l)) |
a = 0
b = 1
n = int(input())
for i in range(n):
print(a,end=",")
print(b,end=",")
a = a+b
b = b+a
print("\b")
| a = 0
b = 1
n = int(input())
for i in range(n):
print(a, end=',')
print(b, end=',')
a = a + b
b = b + a
print('\x08') |
DATASET_REGISTRY = {}
def register_dataset(name: str):
def register_dataset_func(func):
DATASET_REGISTRY[name] = func()
return register_dataset_func
| dataset_registry = {}
def register_dataset(name: str):
def register_dataset_func(func):
DATASET_REGISTRY[name] = func()
return register_dataset_func |
token = "bot_token"
admins = [admin_id]
api_id = 2040
api_hash = "b18441a1ff607e10a989891a5462e627"
| token = 'bot_token'
admins = [admin_id]
api_id = 2040
api_hash = 'b18441a1ff607e10a989891a5462e627' |
a = [3, 4, 5, 6]
b = ['a', 'b', 'c', 'd']
def zipper(a,b):
newZip = []
if len (a) == len(b):
for i in range(len(a)):
newZip.append([a[i], b[i]])
print (newZip)
if len(a)!= len(b):
print("lists do not match")
zipper(a,b)
| a = [3, 4, 5, 6]
b = ['a', 'b', 'c', 'd']
def zipper(a, b):
new_zip = []
if len(a) == len(b):
for i in range(len(a)):
newZip.append([a[i], b[i]])
print(newZip)
if len(a) != len(b):
print('lists do not match')
zipper(a, b) |
c = get_config()
c.TerminalInteractiveShell.confirm_exit = False
c.TerminalInteractiveShell.editing_mode = 'vi'
| c = get_config()
c.TerminalInteractiveShell.confirm_exit = False
c.TerminalInteractiveShell.editing_mode = 'vi' |
class Player:
def __init__(self, socket, name, color, board):
self.name = name
self.board = board
self.socket = socket
self.lastMove = []
self.isTurn = False
#self.color = color
self.color = 'w'
async def init(self):
await self.board.addPlayer(se... | class Player:
def __init__(self, socket, name, color, board):
self.name = name
self.board = board
self.socket = socket
self.lastMove = []
self.isTurn = False
self.color = 'w'
async def init(self):
await self.board.addPlayer(self)
def __str__(self):
... |
# visit: https://imgur.com/a/oemBqyv
count = 0
total = 0
# Handle any exceptions using try/except
try:
def main():
# Initialize variables
count = 0
total = 0
# Opens the Section1.txt file.
infile = open("Section1.txt", "r")
# Reads the numbers in the file into a li... | count = 0
total = 0
try:
def main():
count = 0
total = 0
infile = open('Section1.txt', 'r')
num = infile.readlines()
for num in infile:
number = float(num)
total = total + number
count = count + 1
average = total / count
... |
# V0
# V1
# https://www.jiuzhang.com/solution/fair-candy-swap/#tag-highlight-lang-python
class Solution:
"""
@param A: an array
@param B: an array
@return: an integer array
"""
def fairCandySwap(self, A, B):
# Write your code here.
ans = []
sumA = sum(A)
sumB =... | class Solution:
"""
@param A: an array
@param B: an array
@return: an integer array
"""
def fair_candy_swap(self, A, B):
ans = []
sum_a = sum(A)
sum_b = sum(B)
A.sort()
B.sort()
tmp = sumA - (sumA + sumB) / 2
i = 0
j = 0
wh... |
# PROBLEM LINK:- https://leetcode.com/problems/height-checker/
class Solution:
def heightChecker(self, heights: List[int]) -> int:
n = len(heights)
expected = heights.copy()
expected.sort()
c = 0
for i in range(0,n):
if heights[i] != expected[i]:
... | class Solution:
def height_checker(self, heights: List[int]) -> int:
n = len(heights)
expected = heights.copy()
expected.sort()
c = 0
for i in range(0, n):
if heights[i] != expected[i]:
c += 1
return c |
m = float(input('Informe os metros: '))
print(f'{m} metros equivale a: \n{m*0.001}km\n{m*0.01}hm\n{m*0.1:.1f}dam\n{m*10:.0f}dm\n{m*100:.0f}cm\n{m*1000:.0f}mm')
#km, hm, dam, m, dm, cm, mm | m = float(input('Informe os metros: '))
print(f'{m} metros equivale a: \n{m * 0.001}km\n{m * 0.01}hm\n{m * 0.1:.1f}dam\n{m * 10:.0f}dm\n{m * 100:.0f}cm\n{m * 1000:.0f}mm') |
__title__ = "feedler"
__description__ = "A dead simple parser"
__version__ = "0.0.2"
__author__ = "Victor Natschke"
__author_email__ = "vnatschke@gmail.com"
__license__ = "MIT"
__copyright__ = "Copyright 2020 Victor Natschke"
| __title__ = 'feedler'
__description__ = 'A dead simple parser'
__version__ = '0.0.2'
__author__ = 'Victor Natschke'
__author_email__ = 'vnatschke@gmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 Victor Natschke' |
class Solution:
def InsertInterval(self, Interval, newInterval):
nums,mid = list(), 0
int_len = len(Interval)
for s,e in Interval:
if s < newInterval[0]:
nums.append([s,e])
mid += 1
else:
break
if not nums or n... | class Solution:
def insert_interval(self, Interval, newInterval):
(nums, mid) = (list(), 0)
int_len = len(Interval)
for (s, e) in Interval:
if s < newInterval[0]:
nums.append([s, e])
mid += 1
else:
break
if not ... |
deployment = """
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {cfg[name_version]}-{cfg[name]}
namespace: {cfg[metadata][namespace]}
spec:
replicas: {cfg[replicas]}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: {... | deployment = '\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: {cfg[name_version]}-{cfg[name]}\n namespace: {cfg[metadata][namespace]}\nspec:\n replicas: {cfg[replicas]}\n strategy:\n type: RollingUpdate\n rollingUpdate:\n maxSurge: 1\n maxUnavailable: 1\n selector:\n matchLabels:... |
# Peter Thornton, 04 Mar 18
# Exercise 5
# Please complete the following exercise this week.
# Write a Python script that reads the Iris data set in and prints the four numerical values on each row in a nice format.
# That is, on the screen should be printed the petal length, petal width, sepal length and sepal widt... | with open('iris.data.csv') as t:
for line in t:
print(line.split(',')[0], line.split(',')[1], line.split(',')[2], line.split(',')[3]) |
EPSILON = "epsilon"
K = "k"
MAX_VALUE = "max_value"
MIN_VALUE = "min_value"
ATTRIBUTE = "attribute"
NAME = "name"
SENSITIVITY_TYPE = "sensitivity_type"
ATTRIBUTE_TYPE = "attribute_type"
# window size is used in the disclosure risk calculation
# it indicates the % of the num of records in the dataset
WINDOW_SIZE = 1
# b... | epsilon = 'epsilon'
k = 'k'
max_value = 'max_value'
min_value = 'min_value'
attribute = 'attribute'
name = 'name'
sensitivity_type = 'sensitivity_type'
attribute_type = 'attribute_type'
window_size = 1
border_margin = 1.5 |
pdrop = 0.1
tau = 0.1
lengthscale = 0.01
N = 364
print(lengthscale ** 2 * (1 - pdrop) / (2. * N * tau)) | pdrop = 0.1
tau = 0.1
lengthscale = 0.01
n = 364
print(lengthscale ** 2 * (1 - pdrop) / (2.0 * N * tau)) |
class Delegator():
""" Class implementing Delegator pattern in childrens, who enable to
automaticaly use functions and methods from _delegate_subsystems, so
reduces boilerplate code
!!! be aware that Delegator can't delegate methods from childrens
which implements Delegator
"""
def __init__... | class Delegator:
""" Class implementing Delegator pattern in childrens, who enable to
automaticaly use functions and methods from _delegate_subsystems, so
reduces boilerplate code
!!! be aware that Delegator can't delegate methods from childrens
which implements Delegator
"""
def __init__(s... |
a = 1
b = 1
a = 1
b = 1
| a = 1
b = 1
a = 1
b = 1 |
"""
Crafting.py
Inspired by: Craft3.pdf by John Arras
http://web.archive.org/web/20080211222642/http://www.cs.umd.edu/~jra/craft3.pdf
Intention: Implement a crafting system which can act as a suitable base for a procedurally-generated
society.
"""
# Crafting is the act of producing an object from resources by use o... | """
Crafting.py
Inspired by: Craft3.pdf by John Arras
http://web.archive.org/web/20080211222642/http://www.cs.umd.edu/~jra/craft3.pdf
Intention: Implement a crafting system which can act as a suitable base for a procedurally-generated
society.
"""
class Craft:
def __init__(self):
self.time = 1
s... |
class FrankiException(Exception):
pass
class FrankiInvalidFormatException(Exception):
pass
class FrankiFileNotFound(Exception):
pass
class FrankiInvalidFileFormat(Exception):
pass
__all__ = ("FrankiInvalidFormatException", "FrankiFileNotFound",
"FrankiInvalidFileFormat", "FrankiExcept... | class Frankiexception(Exception):
pass
class Frankiinvalidformatexception(Exception):
pass
class Frankifilenotfound(Exception):
pass
class Frankiinvalidfileformat(Exception):
pass
__all__ = ('FrankiInvalidFormatException', 'FrankiFileNotFound', 'FrankiInvalidFileFormat', 'FrankiException') |
T = int(input())
for i in range(T):
m, n, a, b = map(int, input().split())
count = 0
for num in range(m, n + 1):
if num % a == 0 or num % b == 0:
count += 1
print(count)
| t = int(input())
for i in range(T):
(m, n, a, b) = map(int, input().split())
count = 0
for num in range(m, n + 1):
if num % a == 0 or num % b == 0:
count += 1
print(count) |
"""
Author: Darian T. Yang
Date of Creation: September 13th, 2021
Description:
"""
# Welcome to the WE-dap module!
| """
Author: Darian T. Yang
Date of Creation: September 13th, 2021
Description:
""" |
# This problem was asked by Airbnb.
#
# Given a list of integers, write a function that returns the largest sum of non-adjacent numbers.
# Numbers can be 0 or negative.
# For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10,
# since we pick 5 and 5.
# Follow-up: Can yo... | input_1 = [2, 4, 6, 2, 5]
input_2 = [5, 1, 1, 5]
input_3 = [2, 14, 6, 2, 15]
input_4 = [2, 5, 11, 8, 3]
input_5 = [90, 15, 10, 30, 100]
input_6 = [29, 51, 8, 10, 43, 28]
def largest_sum_adj(arr):
result = 0
size = len(arr)
if size > 2:
arr[2] += arr[0]
result = arr[2]
for i in range... |
def status(bot, update, webcontrol):
chat_id = update.message.chat_id
code, text = webcontrol.execute('detection', 'status')
if code == 200:
bot.sendMessage(chat_id=chat_id, text=text)
else:
bot.sendMessage(chat_id=chat_id, text="Try it later")
| def status(bot, update, webcontrol):
chat_id = update.message.chat_id
(code, text) = webcontrol.execute('detection', 'status')
if code == 200:
bot.sendMessage(chat_id=chat_id, text=text)
else:
bot.sendMessage(chat_id=chat_id, text='Try it later') |
eg = [
'forward 5',
'down 5',
'forward 8',
'up 3',
'down 8',
'forward 2',
]
def load(file):
with open(file) as f:
data = f.readlines()
return data
def steps(lines, pos_char, neg_char):
directions = [ln.split(' ') for ln in lines if ln[0] in [pos_char, neg_char]]
st... | eg = ['forward 5', 'down 5', 'forward 8', 'up 3', 'down 8', 'forward 2']
def load(file):
with open(file) as f:
data = f.readlines()
return data
def steps(lines, pos_char, neg_char):
directions = [ln.split(' ') for ln in lines if ln[0] in [pos_char, neg_char]]
steps = [int(ln[1]) * (1 if ln... |
def test():
print("test successful...")
def update():
print("Updating DSA")
if __name__=='__main__':
pass | def test():
print('test successful...')
def update():
print('Updating DSA')
if __name__ == '__main__':
pass |
"""Sort an array by anagram."""
def sort_by_anagram(array):
n = len(array)
if n <= 2:
return array
i = 0
while i < n-2:
for j in range(i+1, n):
if is_anagram(array[i], array[j]):
i += 1
array[i], array[j] = array[j], array[i]
i +=... | """Sort an array by anagram."""
def sort_by_anagram(array):
n = len(array)
if n <= 2:
return array
i = 0
while i < n - 2:
for j in range(i + 1, n):
if is_anagram(array[i], array[j]):
i += 1
(array[i], array[j]) = (array[j], array[i])
i... |
class Component:
def __init__(self, fail_ratio, repair_ratio, state):
self.fail_ratio = fail_ratio
self.repair_ratio = repair_ratio
self.state = state | class Component:
def __init__(self, fail_ratio, repair_ratio, state):
self.fail_ratio = fail_ratio
self.repair_ratio = repair_ratio
self.state = state |
def parse():
with open("input16") as f:
n = [int(x) for x in f.read()]
return n
n = parse()
for _ in range(100):
result = []
for i in range(1, len(n) + 1):
digit = 0
start = i - 1
add = 1
while start < len(n):
end = min(start + i, len(n))
... | def parse():
with open('input16') as f:
n = [int(x) for x in f.read()]
return n
n = parse()
for _ in range(100):
result = []
for i in range(1, len(n) + 1):
digit = 0
start = i - 1
add = 1
while start < len(n):
end = min(start + i, len(n))
d... |
def exec_procedure(session, proc_name, params):
sql_params = ",".join(["@{0}={1}".format(name, value) for name, value in params.items()])
sql_string = """
DECLARE @return_value int;
EXEC @return_value = [dbo].[{proc_name}] {params};
SELECT 'Return Value' = @return_value;
"""... | def exec_procedure(session, proc_name, params):
sql_params = ','.join(['@{0}={1}'.format(name, value) for (name, value) in params.items()])
sql_string = "\n DECLARE @return_value int;\n EXEC @return_value = [dbo].[{proc_name}] {params};\n SELECT 'Return Value' = @return_value;\n ".for... |
"""
Computer vision Utils
=====================
Standard utils module storing common to the package classes, functions, constants, and other objects.
"""
| """
Computer vision Utils
=====================
Standard utils module storing common to the package classes, functions, constants, and other objects.
""" |
expected_output = {
'slot':{
2:{
'port_group':{
1:{
'port':{
'Hu2/0/25':{
'mode':'inactive'
},
'Hu2/0/26':{
'mode':'inactive'
... | expected_output = {'slot': {2: {'port_group': {1: {'port': {'Hu2/0/25': {'mode': 'inactive'}, 'Hu2/0/26': {'mode': 'inactive'}, 'Fou2/0/27': {'mode': '400G'}, 'Hu2/0/28': {'mode': 'inactive'}}}, 2: {'port': {'Hu2/0/29': {'mode': 'inactive'}, 'Hu2/0/30': {'mode': 'inactive'}, 'Fou2/0/31': {'mode': '400G'}, 'Hu2/0/32': {... |
"""
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
You can guarantee that input is non-negative.
Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case.
"""
def count_bit... | """
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
You can guarantee that input is non-negative.
Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case.
"""
def count_bit... |
#!/usr/bin/env python
# coding: utf-8
# # *section 2: Basic Data Type*
#
# ### writer : Faranak Alikhah 1954128
# ### 4. Lists :
#
# In[ ]:
if __name__ == '__main__':
N = int(input())
my_list=[]
for i in range(N):
A=input().split();
if A[0]=="sort":
my_list.sort()... | if __name__ == '__main__':
n = int(input())
my_list = []
for i in range(N):
a = input().split()
if A[0] == 'sort':
my_list.sort()
elif A[0] == 'insert':
my_list.insert(int(A[1]), int(A[2]))
elif A[0] == 'remove':
my_list.remove(int(A[1]))
... |
class Solution:
def hasZeroSumSubarray(self, nums: List[int]) -> bool:
vis = set()
x = 0
for n in nums :
x+=n
if x==0 or x in vis :
return 1
vis.add(x)
return 0
| class Solution:
def has_zero_sum_subarray(self, nums: List[int]) -> bool:
vis = set()
x = 0
for n in nums:
x += n
if x == 0 or x in vis:
return 1
vis.add(x)
return 0 |
# -*- coding: utf-8 -*-
# File defines a single function, a set cookie that takes a configuration
# Use only if the app cannot be imported, otherwise use .cookies
def set_cookie(config, response, key, val):
response.set_cookie(key, val,
secure = config['COOKIES_SECURE'],
... | def set_cookie(config, response, key, val):
response.set_cookie(key, val, secure=config['COOKIES_SECURE'], httponly=config['COOKIES_HTTPONLY'], samesite=config['COOKIES_SAMESITE']) |
class Solution:
def minSwaps(self, data: List[int]) -> int:
k = data.count(1)
ones = 0 # ones in window
maxOnes = 0 # max ones in window
for i, num in enumerate(data):
if i >= k and data[i - k]:
ones -= 1
if num:
ones += 1
maxOnes = max(maxOnes, ones)
return k... | class Solution:
def min_swaps(self, data: List[int]) -> int:
k = data.count(1)
ones = 0
max_ones = 0
for (i, num) in enumerate(data):
if i >= k and data[i - k]:
ones -= 1
if num:
ones += 1
max_ones = max(maxOnes, on... |
class DNSimpleException(Exception):
def __init__(self, message=None, errors=None):
self.message = message
self.errors = errors
| class Dnsimpleexception(Exception):
def __init__(self, message=None, errors=None):
self.message = message
self.errors = errors |
polygon = [
[2000, 1333],
[2000, 300],
[500, 900],
[0, 1333],
[2000, 1333]
]
'''
polygon = [
[0, 0],
[0, 600],
[900, 600],
[1800, 0],
[0, 0]
]
''' | polygon = [[2000, 1333], [2000, 300], [500, 900], [0, 1333], [2000, 1333]]
'\npolygon = [\n\t[0, 0],\n\t[0, 600],\n\t[900, 600],\n\t[1800, 0],\n\t[0, 0]\n]\n' |
class A:
def __init__(self):
self._x = 5
class B(A):
def display(self):
print(self._x)
def main():
obj = B()
obj.display()
main() | class A:
def __init__(self):
self._x = 5
class B(A):
def display(self):
print(self._x)
def main():
obj = b()
obj.display()
main() |
"""
Ideas:
1. The widest container (using first and last line) is a good candidate, because of its width. Its water level is the height of the smaller one of first and last line.
2. All other containers are less wide and thus would need a higher water level in order to hold more water.
3. The smaller one of first and ... | """
Ideas:
1. The widest container (using first and last line) is a good candidate, because of its width. Its water level is the height of the smaller one of first and last line.
2. All other containers are less wide and thus would need a higher water level in order to hold more water.
3. The smaller one of first and ... |
arr = []
for x in range(100):
arr.append([])
arr[x] = [0 for i in range(100)]
n = int(input())
ans=0
for x in range(n):
a, b, c, d = map(int, input().split())
ans=ans+(c-a+1)*(d-b+1)
print(ans) | arr = []
for x in range(100):
arr.append([])
arr[x] = [0 for i in range(100)]
n = int(input())
ans = 0
for x in range(n):
(a, b, c, d) = map(int, input().split())
ans = ans + (c - a + 1) * (d - b + 1)
print(ans) |
alp = "abcdefghijklmnopqrstuvwxyz"
res = ""
while True:
s = __import__('sys').stdin.readline().strip()
if s == "#":
break
x, y, z = s.split()
t = ""
for i in range(len(x)):
dif = (ord(y[i]) - ord(x[i]) + 26) % 26
t += alp[(ord(z[i]) - ord('a') + dif) % 26]
res += s + " " ... | alp = 'abcdefghijklmnopqrstuvwxyz'
res = ''
while True:
s = __import__('sys').stdin.readline().strip()
if s == '#':
break
(x, y, z) = s.split()
t = ''
for i in range(len(x)):
dif = (ord(y[i]) - ord(x[i]) + 26) % 26
t += alp[(ord(z[i]) - ord('a') + dif) % 26]
res += s + ' ... |
class Day10:
ILLEGAL_CHAR_TO_POINTS = {
")": 3,
"]": 57,
"}": 1197,
">": 25137,
}
def __init__(self, input="src/input/day10.txt"):
self.INPUT = input
def read_input(self):
input = []
with open(self.INPUT, "r") as fp:
lines = fp.readl... | class Day10:
illegal_char_to_points = {')': 3, ']': 57, '}': 1197, '>': 25137}
def __init__(self, input='src/input/day10.txt'):
self.INPUT = input
def read_input(self):
input = []
with open(self.INPUT, 'r') as fp:
lines = fp.readlines()
input = [line.strip()... |
def ways(n, m):
grid = [[None]*m]*n
for i in range(m):
grid[n-1][i] = 1
for i in range(n):
grid[i][m-1] = 1
for i in range(n-2,-1,-1):
for j in range(m-2,-1,-1):
grid[i][j] = grid[i][j+1] + grid[i+1][j]
return grid[0][0]
if __name__ == "__main__":
t = int(input("Number of times you want to run thi... | def ways(n, m):
grid = [[None] * m] * n
for i in range(m):
grid[n - 1][i] = 1
for i in range(n):
grid[i][m - 1] = 1
for i in range(n - 2, -1, -1):
for j in range(m - 2, -1, -1):
grid[i][j] = grid[i][j + 1] + grid[i + 1][j]
return grid[0][0]
if __name__ == '__main_... |
message = input().split()
def asci_change(message):
numbers = [num for num in i if num.isdigit()]
numbers_in_chr = chr(int(''.join(numbers)))
letters = [letter for letter in i if not letter.isdigit()]
letters_split = ''.join(letters)
final_word = numbers_in_chr + str(letters_split)
return fina... | message = input().split()
def asci_change(message):
numbers = [num for num in i if num.isdigit()]
numbers_in_chr = chr(int(''.join(numbers)))
letters = [letter for letter in i if not letter.isdigit()]
letters_split = ''.join(letters)
final_word = numbers_in_chr + str(letters_split)
return final... |
star_wars = [125, 1977]
raiders = [115, 1981]
mean_girls = [97, 2004]
def distance(movie1, movie2):
length_difference = (movie1[0] - movie2[0]) ** 2
year_difference = (movie1[1] - movie2[1]) ** 2
distance = (length_difference + year_difference) ** 0.5
return distance
print(distance(star_wars, raiders))
print(... | star_wars = [125, 1977]
raiders = [115, 1981]
mean_girls = [97, 2004]
def distance(movie1, movie2):
length_difference = (movie1[0] - movie2[0]) ** 2
year_difference = (movie1[1] - movie2[1]) ** 2
distance = (length_difference + year_difference) ** 0.5
return distance
print(distance(star_wars, raiders))... |
def get_distribution_steps(distribution):
i = 0
distributed_loaves = 0
while i < len(distribution):
if distribution[i] % 2 == 0:
i += 1
continue
next_item_index = i + 1
if next_item_index == len(distribution):
return -1
... | def get_distribution_steps(distribution):
i = 0
distributed_loaves = 0
while i < len(distribution):
if distribution[i] % 2 == 0:
i += 1
continue
next_item_index = i + 1
if next_item_index == len(distribution):
return -1
distribution[next_it... |
class File:
def __init__(
self,
name: str,
display_str: str,
short_status: str,
has_staged_change: bool,
has_unstaged_change: bool,
tracked: bool,
deleted: bool,
added: bool,
has_merged_conflicts: bool,
has_inline_merged_conflic... | class File:
def __init__(self, name: str, display_str: str, short_status: str, has_staged_change: bool, has_unstaged_change: bool, tracked: bool, deleted: bool, added: bool, has_merged_conflicts: bool, has_inline_merged_conflicts: bool) -> None:
self.name = name
self.display_str = display_str
... |
with open('input') as f:
instructions = []
for line in f:
op, arg = line.split()
instructions.append((op, int(arg)))
# Part 1
executed = [False] * len(instructions)
accumulator = 0
i = 0
while i < len(instructions):
if executed[i]: break
executed[i] = True
op, n = instructions[i]
... | with open('input') as f:
instructions = []
for line in f:
(op, arg) = line.split()
instructions.append((op, int(arg)))
executed = [False] * len(instructions)
accumulator = 0
i = 0
while i < len(instructions):
if executed[i]:
break
executed[i] = True
(op, n) = instructions[i]
... |
# encoding: utf-8
SECRET_KEY = 'a unique and long key'
TITLE = 'Riki'
HISTORY_SHOW_MAX = 30
PIC_BASE = '/static/content/'
CONTENT_DIR = '///D:\\School\\Riki\\content'
USER_DIR = '///D:\\School\\Riki\\user'
NUMBER_OF_HISTORY = 5
PRIVATE = False
| secret_key = 'a unique and long key'
title = 'Riki'
history_show_max = 30
pic_base = '/static/content/'
content_dir = '///D:\\School\\Riki\\content'
user_dir = '///D:\\School\\Riki\\user'
number_of_history = 5
private = False |
###############################################################
# LeetCode Problem Number : 622
# Difficulty Level : Medium
# URL : https://leetcode.com/problems/design-circular-queue/
###############################################################
class CircularQueue:
def __init__(self, size):
"""initializ... | class Circularqueue:
def __init__(self, size):
"""initialize your data structure here"""
self.max_size = size
' set head and tail pointer to -1 '
self.head = -1
self.tail = -1
' initialize internal array '
self.data = [[] for _ in range(size)]
def is_emp... |
"""
STIX 2.0 open vocabularies and enums
"""
ATTACK_MOTIVATION_ACCIDENTAL = "accidental"
ATTACK_MOTIVATION_COERCION = "coercion"
ATTACK_MOTIVATION_DOMINANCE = "dominance"
ATTACK_MOTIVATION_IDEOLOGY = "ideology"
ATTACK_MOTIVATION_NOTORIETY = "notoriety"
ATTACK_MOTIVATION_ORGANIZATIONAL_GAIN = "organizational-gain"
ATTA... | """
STIX 2.0 open vocabularies and enums
"""
attack_motivation_accidental = 'accidental'
attack_motivation_coercion = 'coercion'
attack_motivation_dominance = 'dominance'
attack_motivation_ideology = 'ideology'
attack_motivation_notoriety = 'notoriety'
attack_motivation_organizational_gain = 'organizational-gain'
attac... |
#!/usr/bin/env python
OUTPUT_FILENAME = "output"
TOTAL_OF_FILES = 2
if __name__ == "__main__":
# make an array of files of size 100
results = []
for i in range(1, TOTAL_OF_FILES+1):
a = open("./{}{}.txt".format(OUTPUT_FILENAME, i), 'r')
text = a.read()
a.close()
text = text... | output_filename = 'output'
total_of_files = 2
if __name__ == '__main__':
results = []
for i in range(1, TOTAL_OF_FILES + 1):
a = open('./{}{}.txt'.format(OUTPUT_FILENAME, i), 'r')
text = a.read()
a.close()
text = text.split('\n')
results.append(text[1:-2])
text = 'Ori... |
def func(word):
word = word.split(", ")
dic = {"Magic":[],"Normal":[]}
for elm in word:
decide = ""
first = elm[0]
first = int(first)
sum1 = 0
for sval in elm[1::]:
sum1 += int(sval)
if first == sum1:
decide = "Magic"
e... | def func(word):
word = word.split(', ')
dic = {'Magic': [], 'Normal': []}
for elm in word:
decide = ''
first = elm[0]
first = int(first)
sum1 = 0
for sval in elm[1:]:
sum1 += int(sval)
if first == sum1:
decide = 'Magic'
else:
... |
def contador(i,f,p):
"""
Faz a contagem e mostra na tela
:param i: inicio da contagem
:param f: fim da contagem
:param p: passo da contagem
:return: sem retorno
"""
c=i
while c<=f:
print(f'{c} ', end='')
c +=p
print('FIMMM')
contador(2,10,2)
help(contador)
| def contador(i, f, p):
"""
Faz a contagem e mostra na tela
:param i: inicio da contagem
:param f: fim da contagem
:param p: passo da contagem
:return: sem retorno
"""
c = i
while c <= f:
print(f'{c} ', end='')
c += p
print('FIMMM')
contador(2, 10, 2)
help(contad... |
class Node:
def __init__(self, data):
self.data = data # Assign the data here
self.next = None # Set next to None by default.
class LinkedList:
def __init__(self):
self.head = None
# Display the list. Linked list traversal.
def display(self):
temp = self.head
d... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def display(self):
temp = self.head
display = ''
while temp:
display += str(temp.data) + ' -> '
temp = te... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.