content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
mys1 = {1,2,3,4}
mys2 = {1,2,3,4,5,6}
print(mys2.issuperset(mys1)) # ISUP1
mys3 = {'a','b','c','d'}
mys4 = {'d','w','f','g'}
mys5 = {'a','b', 'c', 'd','v','w','x','z'}
print(mys3.issuperset(mys4)) # ISUP2
print(mys4.issuperset(mys5)) # ISUP3
print(mys5.issuperset(mys3)) # ISUP4 | mys1 = {1, 2, 3, 4}
mys2 = {1, 2, 3, 4, 5, 6}
print(mys2.issuperset(mys1))
mys3 = {'a', 'b', 'c', 'd'}
mys4 = {'d', 'w', 'f', 'g'}
mys5 = {'a', 'b', 'c', 'd', 'v', 'w', 'x', 'z'}
print(mys3.issuperset(mys4))
print(mys4.issuperset(mys5))
print(mys5.issuperset(mys3)) |
fa=open('MGI_HGNC_homologene.rpt')
L={}
fa.readline()
for line in fa:
seq=line.rstrip().split('\t')
try:
l= abs(float(seq[11])-float(seq[12]))
L[seq[1]]=l
except Exception as e:
pass
fi=open('GSE109125_Gene_count_table.csv.uniq')
fo=open('GSE109125_Gene_count_table.csv.uniq.rpk','w... | fa = open('MGI_HGNC_homologene.rpt')
l = {}
fa.readline()
for line in fa:
seq = line.rstrip().split('\t')
try:
l = abs(float(seq[11]) - float(seq[12]))
L[seq[1]] = l
except Exception as e:
pass
fi = open('GSE109125_Gene_count_table.csv.uniq')
fo = open('GSE109125_Gene_count_table.csv... |
#
# @lc app=leetcode id=215 lang=python3
#
# [215] Kth Largest Element in an Array
#
# https://leetcode.com/problems/kth-largest-element-in-an-array/description/
#
# algorithms
# Medium (59.69%)
# Likes: 6114
# Dislikes: 378
# Total Accepted: 944.8K
# Total Submissions: 1.6M
# Testcase Example: '[3,2,1,5,6,4]\n2... | class Solution:
def find_kth_largest(self, nums: List[int], k: int) -> int:
nums.sort()
return nums[-k] |
blog_list = [
{"date": "Dec 2018",
"title": "Starcraft II A.I. Bot",
"content": "Industria is a mixture of role-based A.I. with an deep learning decision process enhancement. While most of it's actions are scripted, it decides about an army composition.",
"keywords": ['starcraft-ii','bot','artificia... | blog_list = [{'date': 'Dec 2018', 'title': 'Starcraft II A.I. Bot', 'content': "Industria is a mixture of role-based A.I. with an deep learning decision process enhancement. While most of it's actions are scripted, it decides about an army composition.", 'keywords': ['starcraft-ii', 'bot', 'artificial-intelligence', 'q... |
def reduceBlue(picture, amount):
for pixel in getPixels(picture):
newBlue = getBlue(pixel) * amount
setBlue(pixel, newBlue)
repaint(picture)
def swapRedBlue(picture):
for pixel in getPixels(picture):
swapBlue = getRed(pixel)
swapRed = getBlue(pixel)
setR... | def reduce_blue(picture, amount):
for pixel in get_pixels(picture):
new_blue = get_blue(pixel) * amount
set_blue(pixel, newBlue)
repaint(picture)
def swap_red_blue(picture):
for pixel in get_pixels(picture):
swap_blue = get_red(pixel)
swap_red = get_blue(pixel)
set_r... |
n, _ = input().split()
n = int(n)
l = [[] for i in range(n)]
while True:
try:
a, b = input().split()
a = int(a)
b = int(b)
l[a].append(b)
except Exception as e:
break
for r in range(len(l)):
for i in l[r]:
print(r+1, i+1)
| (n, _) = input().split()
n = int(n)
l = [[] for i in range(n)]
while True:
try:
(a, b) = input().split()
a = int(a)
b = int(b)
l[a].append(b)
except Exception as e:
break
for r in range(len(l)):
for i in l[r]:
print(r + 1, i + 1) |
#!/usr/bin/python3
update_dictionary = __import__('7-update_dictionary').update_dictionary
print_sorted_dictionary = __import__('6-print_sorted_dictionary').print_sorted_dictionary
a_dictionary = { 'language': "C", 'number': 89, 'track': "Low level" }
new_dict = update_dictionary(a_dictionary, 'language', "Python")
pr... | update_dictionary = __import__('7-update_dictionary').update_dictionary
print_sorted_dictionary = __import__('6-print_sorted_dictionary').print_sorted_dictionary
a_dictionary = {'language': 'C', 'number': 89, 'track': 'Low level'}
new_dict = update_dictionary(a_dictionary, 'language', 'Python')
print_sorted_dictionary(... |
pumpvalues = [119.480003,119.699997,119.830002,119.900002,119.949997,119.980003,119.989998,120.0,120.0,120.0,120.0,120.010002,120.010002,120.010002,120.010002,120.010002,120.010002,120.010002,120.010002,120.0,119.989998,119.949997,119.900002,119.800003,119.629997,119.360001,118.949997,118.389999,117.68,116.889999,116.... | pumpvalues = [119.480003, 119.699997, 119.830002, 119.900002, 119.949997, 119.980003, 119.989998, 120.0, 120.0, 120.0, 120.0, 120.010002, 120.010002, 120.010002, 120.010002, 120.010002, 120.010002, 120.010002, 120.010002, 120.0, 119.989998, 119.949997, 119.900002, 119.800003, 119.629997, 119.360001, 118.949997, 118.389... |
config = {
# Fallback default used when a terminal width cannot be inferred.
"display.fallback_width": 88,
# Human-friendly line width for paragraphs.
"display.text_width": 88,
}
| config = {'display.fallback_width': 88, 'display.text_width': 88} |
rooms = {
1 : { 'name' : '1. room', 'description': 'first room', 'completed': False},
2 : { 'name' : '2. room', 'description': 'second room', 'completed': False},
3 : { 'name' : '3. room', 'description': 'third room', 'completed': False}
} | rooms = {1: {'name': '1. room', 'description': 'first room', 'completed': False}, 2: {'name': '2. room', 'description': 'second room', 'completed': False}, 3: {'name': '3. room', 'description': 'third room', 'completed': False}} |
class Error(Exception):
pass
class ConcreateError(Error):
pass
| class Error(Exception):
pass
class Concreateerror(Error):
pass |
#
# PySNMP MIB module CADANT-HW-MEAS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CADANT-HW-MEAS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:28:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, single_value_constraint, constraints_intersection, value_range_constraint) ... |
# -*- coding: UTF-8 -*-
# @yasinkuyu
# TODO
class analyze():
def position():
return 1
@staticmethod
def direction(ticker):
# Todo: Analyze, best price position
hight = float(ticker['hight'])
low = float(ticker['low'])
return False
| class Analyze:
def position():
return 1
@staticmethod
def direction(ticker):
hight = float(ticker['hight'])
low = float(ticker['low'])
return False |
"""
ID: MRNA
Title: Inferring mRNA from Protein
URL: http://rosalind.info/problems/mrna/
"""
# RNA codon table
rna_codon_dict = {
"F": ["UUU", "UUC"],
"L": ["UUA", "UUG", "CUU", "CUC", "CUA", "CUG"],
"S": ["UCU", "UCC", "UCA", "UCG", "AGU", "AGC"],
"Y": ["UAU", "UAC"],
"C": ["UGU", "UGC"],
"W":... | """
ID: MRNA
Title: Inferring mRNA from Protein
URL: http://rosalind.info/problems/mrna/
"""
rna_codon_dict = {'F': ['UUU', 'UUC'], 'L': ['UUA', 'UUG', 'CUU', 'CUC', 'CUA', 'CUG'], 'S': ['UCU', 'UCC', 'UCA', 'UCG', 'AGU', 'AGC'], 'Y': ['UAU', 'UAC'], 'C': ['UGU', 'UGC'], 'W': ['UGG'], 'P': ['CCU', 'CCC', 'CCA', 'CCG'],... |
li = ["entrance"]
sc = ["food", "others", "descry"]
current = li[len(li) - 1]
size = len(li)
while True:
print(current)
choice = input("enter choice")
if choice == "b" and size == 1:
print("LAsT ScReEN")
elif choice == "b" and size > 1:
print(f"your were in {current}")
last = li... | li = ['entrance']
sc = ['food', 'others', 'descry']
current = li[len(li) - 1]
size = len(li)
while True:
print(current)
choice = input('enter choice')
if choice == 'b' and size == 1:
print('LAsT ScReEN')
elif choice == 'b' and size > 1:
print(f'your were in {current}')
last = li[... |
#Placeholder class for player
class Player(object):
def __init__(self):
self.maxHp = 250
self.hp = self.maxHp
self.maxArk = 1000
self.ark = maxArk | class Player(object):
def __init__(self):
self.maxHp = 250
self.hp = self.maxHp
self.maxArk = 1000
self.ark = maxArk |
track_width = 1.4476123429435463
track_original = [(-7.328797578811646, 0.7067412286996826), (-7.174184083938599, 0.9988523125648499),
(-7.014955043792725, 1.2884796857833862), (-6.852129220962524, 1.5760955214500427),
(-6.69096302986145, 1.8646469712257385), (-6.549050569534302, 2.1... | track_width = 1.4476123429435463
track_original = [(-7.328797578811646, 0.7067412286996826), (-7.174184083938599, 0.9988523125648499), (-7.014955043792725, 1.2884796857833862), (-6.852129220962524, 1.5760955214500427), (-6.69096302986145, 1.8646469712257385), (-6.549050569534302, 2.133627951145172), (-6.420227527618408... |
_base_ = [
'../../../_base_/datasets/two_branch/few_shot_voc.py',
'../../../_base_/schedules/schedule.py', '../../mpsr_r101_fpn.py',
'../../../_base_/default_runtime.py'
]
# classes splits are predefined in FewShotVOCDataset
# FewShotVOCDefaultDataset predefine ann_cfg for model reproducibility.
data = dict... | _base_ = ['../../../_base_/datasets/two_branch/few_shot_voc.py', '../../../_base_/schedules/schedule.py', '../../mpsr_r101_fpn.py', '../../../_base_/default_runtime.py']
data = dict(train=dict(dataset=dict(type='FewShotVOCDefaultDataset', ann_cfg=[dict(method='MPSR', setting='SPLIT1_1SHOT')], num_novel_shots=1, num_bas... |
# -*- coding: utf-8 -*-
DESC = "trtc-2019-07-22"
INFO = {
"DescribeRealtimeQuality": {
"params": [
{
"name": "StartTime",
"desc": "Query start time in the format of local UNIX timestamp, such as 1588031999s, which is a point in time in the last 24 hours."
},
{
"name": "En... | desc = 'trtc-2019-07-22'
info = {'DescribeRealtimeQuality': {'params': [{'name': 'StartTime', 'desc': 'Query start time in the format of local UNIX timestamp, such as 1588031999s, which is a point in time in the last 24 hours.'}, {'name': 'EndTime', 'desc': 'Query end time in the format of local UNIX timestamp, such as... |
"""DSM 6 SYNO.API.Info data with surveillance surppot."""
DSM_6_API_INFO = {
"data": {
"SYNO.API.Auth": {"maxVersion": 6, "minVersion": 1, "path": "auth.cgi"},
"SYNO.API.Encryption": {
"maxVersion": 1,
"minVersion": 1,
"path": "encryption.cgi",
},
... | """DSM 6 SYNO.API.Info data with surveillance surppot."""
dsm_6_api_info = {'data': {'SYNO.API.Auth': {'maxVersion': 6, 'minVersion': 1, 'path': 'auth.cgi'}, 'SYNO.API.Encryption': {'maxVersion': 1, 'minVersion': 1, 'path': 'encryption.cgi'}, 'SYNO.API.Info': {'maxVersion': 1, 'minVersion': 1, 'path': 'query.cgi'}, 'SY... |
class Paras:
COURSE_LABEL_SIZE = None
FINE_2_COURSE = None
IX_a = None
IX_t = None
IX_s = None
IX_a_out = None
IX_p_out = None
@staticmethod
def init():
print("Paras.init started...")
Paras.COURSE_LABEL_SIZE = 6
Paras.FINE_2_COURSE = {}
... | class Paras:
course_label_size = None
fine_2_course = None
ix_a = None
ix_t = None
ix_s = None
ix_a_out = None
ix_p_out = None
@staticmethod
def init():
print('Paras.init started...')
Paras.COURSE_LABEL_SIZE = 6
Paras.FINE_2_COURSE = {}
Paras.FINE_2_C... |
def find_slowest_time(messages):
simulated_communication_times = {message.sender: message.body['simulated_time'] for message in messages}
slowest_client = max(simulated_communication_times, key=simulated_communication_times.get)
simulated_time = simulated_communication_times[
slowest_client] # simu... | def find_slowest_time(messages):
simulated_communication_times = {message.sender: message.body['simulated_time'] for message in messages}
slowest_client = max(simulated_communication_times, key=simulated_communication_times.get)
simulated_time = simulated_communication_times[slowest_client]
return simul... |
'''
Excited States software: qFit 3.0
Contributors: Saulo H. P. de Oliveira, Gydo van Zundert, and Henry van den Bedem.
Contact: vdbedem@stanford.edu
Copyright (C) 2009-2019 Stanford University
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation f... | """
Excited States software: qFit 3.0
Contributors: Saulo H. P. de Oliveira, Gydo van Zundert, and Henry van den Bedem.
Contact: vdbedem@stanford.edu
Copyright (C) 2009-2019 Stanford University
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation f... |
jobs = 1
mid_x = -0.5
mid_y = 0.0
render_width = 2.5
render_height = 2.5
iterations = 256
width = 50
height = 25
output = [0] * (width * height)
def mandelbrot_int(cx, cy):
int_precision = 28
zx = 0
zy = 0
cx = int(cx * (1 << int_precision))
cy = int(cy * (1 << int_precision))
depth... | jobs = 1
mid_x = -0.5
mid_y = 0.0
render_width = 2.5
render_height = 2.5
iterations = 256
width = 50
height = 25
output = [0] * (width * height)
def mandelbrot_int(cx, cy):
int_precision = 28
zx = 0
zy = 0
cx = int(cx * (1 << int_precision))
cy = int(cy * (1 << int_precision))
depth = None
... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def get_tensor_shape(t):
return [d for d in t.shape]
def get_tensors_shapes_string(tensors):
res = []
for t in tensors:
res.extend([str(v) for v in get_tensor_shape(t)])
return " ".join(res)
| def get_tensor_shape(t):
return [d for d in t.shape]
def get_tensors_shapes_string(tensors):
res = []
for t in tensors:
res.extend([str(v) for v in get_tensor_shape(t)])
return ' '.join(res) |
__author__ = 'Rahul Gupta'
# Contains relevant constants for running the LDSC pipeline for the Pan Ancestry project.
project_dir = '/Volumes/rahul/Projects/2020_ukb_diverse_pops/Experiments/200501_ldsc_div_pops_pipeline/Data/'
flat_file_location = 'gs://ukb-diverse-pops/sumstats_flat_files/'
bucket = 'rgupta-ldsc'
# ... | __author__ = 'Rahul Gupta'
project_dir = '/Volumes/rahul/Projects/2020_ukb_diverse_pops/Experiments/200501_ldsc_div_pops_pipeline/Data/'
flat_file_location = 'gs://ukb-diverse-pops/sumstats_flat_files/'
bucket = 'rgupta-ldsc'
output_bucket = f'gs://{bucket}/'
anc_to_ldscore = lambda anc: f'gs://rgupta-ldsc/ld/UKBB.{anc... |
print('i am batman', end='\n')
print('hello world', end='\t\t')
print('this is cool\n', end=' ----- ')
print('i am still here')
| print('i am batman', end='\n')
print('hello world', end='\t\t')
print('this is cool\n', end=' ----- ')
print('i am still here') |
# -*- coding: utf-8 -*-
"""Top-level package for DjangoCMS Blog plugin."""
__author__ = """Carlos Martinez"""
__email__ = 'me@carlosmart.co'
__version__ = '0.1.2'
| """Top-level package for DjangoCMS Blog plugin."""
__author__ = 'Carlos Martinez'
__email__ = 'me@carlosmart.co'
__version__ = '0.1.2' |
# Code generated by font_to_py.py.
# Font: Arial.ttf Char set: 0123456789:
# Cmd: ./font_to_py.py Arial.ttf 50 arial_50.py -x -c 0123456789:
version = '0.33'
def height():
return 50
def baseline():
return 49
def max_width():
return 37
def hmap():
return True
def reverse():
return False
def mon... | version = '0.33'
def height():
return 50
def baseline():
return 49
def max_width():
return 37
def hmap():
return True
def reverse():
return False
def monospaced():
return False
def min_ch():
return 48
def max_ch():
return 63
_font = b'%\x00\x00\x03\xfe\x00\x00\x00\x1f\xff\xc0\x00... |
def get_divisors(number: int) -> list:
# we only accept positive numbers
assert number >= 1, f'{number} Only positive numbers are allowed'
return [i for i in range(0, number + 1) if i % 2 == 0]
def run():
try:
number = int(input('Enter a number to calculate all divisors: '))
print(get... | def get_divisors(number: int) -> list:
assert number >= 1, f'{number} Only positive numbers are allowed'
return [i for i in range(0, number + 1) if i % 2 == 0]
def run():
try:
number = int(input('Enter a number to calculate all divisors: '))
print(get_divisors(number))
print('End of... |
"""Utility functions."""
def node_type(node) -> str:
"""
Get the type of the node.
This is the Python equivalent of the
[`nodeType`](https://github.com/stencila/schema/blob/bd90c808d14136c8489ce8bb945b2bb6085b9356/ts/util/nodeType.ts)
function.
"""
# pylint: disable=R0911
if node is ... | """Utility functions."""
def node_type(node) -> str:
"""
Get the type of the node.
This is the Python equivalent of the
[`nodeType`](https://github.com/stencila/schema/blob/bd90c808d14136c8489ce8bb945b2bb6085b9356/ts/util/nodeType.ts)
function.
"""
if node is None:
return 'Null'
... |
#
# Copyright 2019 The Project Oak Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | load('@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl', 'action_config', 'feature', 'flag_group', 'flag_set', 'tool', 'tool_path')
load('@bazel_tools//tools/build_defs/cc:action_names.bzl', 'ACTION_NAMES')
all_link_actions = [ACTION_NAMES.cpp_link_executable, ACTION_NAMES.cpp_link_dynamic_library, ACTION_NAMES.cpp_... |
#
# Copyright (C) 2018 The Android Open Source Project
#
# 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... | model = model()
i1 = input('op1', 'TENSOR_FLOAT32', '{1, 2, 3, 1}')
i2 = parameter('op2', 'TENSOR_INT32', '{4, 2}', [0, 0, 0, 2, 1, 3, 0, 0])
i3 = output('op3', 'TENSOR_FLOAT32', '{1, 4, 7, 1}')
model = model.Operation('PAD', i1, i2).To(i3)
model = model.RelaxedExecution(True)
input0 = {i1: [1.0, 2.0, 3.0, 4.0, 5.0, 6.... |
class MissingSessionError(Exception):
"""Excetion raised for when the user tries to access a database session before it is created."""
def __init__(self):
msg = """
No session found! Either you are not currently in a request context,
or you need to manually create a session context by u... | class Missingsessionerror(Exception):
"""Excetion raised for when the user tries to access a database session before it is created."""
def __init__(self):
msg = '\n No session found! Either you are not currently in a request context,\n or you need to manually create a session context by u... |
class _MultiHeadFunc:
"""base mixin for multiheaded losses and metrics"""
def __init__(self, **kwargs):
self._fns = {}
for k, v in kwargs.items():
if not callable(v):
raise TypeError(
f'functions passed to {self.__class__.__name__} must be callabl... | class _Multiheadfunc:
"""base mixin for multiheaded losses and metrics"""
def __init__(self, **kwargs):
self._fns = {}
for (k, v) in kwargs.items():
if not callable(v):
raise type_error(f'functions passed to {self.__class__.__name__} must be callable but got type {ty... |
__title__ = 'frashfeed-python'
__description__ = 'News feed for Alexa.'
__url__ = 'https://github.com/alexiob/flashfeed-python'
__version__ = '1.0.2'
__author__ = 'Alessandro Iob'
__author_email__ = 'alessandro.iob@gmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2019 Alessandro Iob'
| __title__ = 'frashfeed-python'
__description__ = 'News feed for Alexa.'
__url__ = 'https://github.com/alexiob/flashfeed-python'
__version__ = '1.0.2'
__author__ = 'Alessandro Iob'
__author_email__ = 'alessandro.iob@gmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2019 Alessandro Iob' |
class NotAnEffect():
"""
Not an effect (doesn't inherit from AbstractEffect).
"""
def __init__(self) -> None:
pass
def compose(self) -> None:
pass # pragma: no cover
def __repr__(self) -> str:
return "NotAnEffect()" # pragma: no cover
| class Notaneffect:
"""
Not an effect (doesn't inherit from AbstractEffect).
"""
def __init__(self) -> None:
pass
def compose(self) -> None:
pass
def __repr__(self) -> str:
return 'NotAnEffect()' |
"""
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.
"""
| """
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.
""" |
with open("input.txt", "r") as f:
inp = [int(i) for i in f.readlines()]
# Part 1
n = sum([inp[i] > inp[i-1] for i in range(1, len(inp))])
print("Part 1:", n)
# Part 2
n2 = sum([inp[i] + inp[i+1] + inp[i+2] < inp[i+1] + inp[i+2] + inp[i+3] for i in range(len(inp) - 3)])
print("Part 2:",... | with open('input.txt', 'r') as f:
inp = [int(i) for i in f.readlines()]
n = sum([inp[i] > inp[i - 1] for i in range(1, len(inp))])
print('Part 1:', n)
n2 = sum([inp[i] + inp[i + 1] + inp[i + 2] < inp[i + 1] + inp[i + 2] + inp[i + 3] for i in range(len(inp) - 3)])
print('Part 2:', n2) |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''
This module contains the base class for our plots that support the
brushing & linking technique.
'''
class BrushableCanvas:
'''
Class to define the basic interface of a drawable area that supports
brushing & linking of its data instances.
'''
def __... | """
This module contains the base class for our plots that support the
brushing & linking technique.
"""
class Brushablecanvas:
"""
Class to define the basic interface of a drawable area that supports
brushing & linking of its data instances.
"""
def __init__(self, canvas_name, parent=None):
... |
syntax = r'^\+haunted(?: (?P<locations>.+))?$'
def haunted(caller, locations='here'):
locations = search(locations, kind=db.Room)
if search(caller, within=locations, kind=db.Character, not_within=[caller.character], flags=['dark', '!deaf']).count():
pemit(caller, "You feel some sort of presence.")... | syntax = '^\\+haunted(?: (?P<locations>.+))?$'
def haunted(caller, locations='here'):
locations = search(locations, kind=db.Room)
if search(caller, within=locations, kind=db.Character, not_within=[caller.character], flags=['dark', '!deaf']).count():
pemit(caller, 'You feel some sort of presence.')
... |
def rule(event):
# filter events; event type 11 is an actor_user changed user password
return event.get("event_type_id") == 11
def title(event):
return (
f"User [{event.get('actor_user_name', '<UNKNOWN_USER>')}] has exceeded the user"
f" account password change threshold"
)
| def rule(event):
return event.get('event_type_id') == 11
def title(event):
return f"User [{event.get('actor_user_name', '<UNKNOWN_USER>')}] has exceeded the user account password change threshold" |
# Copyright 2021 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | """Simple helpers for converting continuous-time dynamics to discrete-time."""
def euler(dynamics, dt=0.01):
return lambda x, u, t: x + dt * dynamics(x, u, t)
def rk4(dynamics, dt=0.01):
def integrator(x, u, t):
dt2 = dt / 2.0
k1 = dynamics(x, u, t)
k2 = dynamics(x + dt2 * k1, u, t)
... |
#!/usr/bin/env python
DESCRIPTION = "Conti ransomware api hash with seed 0xE9FF0077"
TYPE = 'unsigned_int'
TEST_1 = 3760887415
def hash(data):
API_buffer = []
i = len(data) >> 3
count = 0
while i != 0:
for index in range(0, 8):
API_buffer.append(data[index + count])
coun... | description = 'Conti ransomware api hash with seed 0xE9FF0077'
type = 'unsigned_int'
test_1 = 3760887415
def hash(data):
api_buffer = []
i = len(data) >> 3
count = 0
while i != 0:
for index in range(0, 8):
API_buffer.append(data[index + count])
count += 8
i -= 1
... |
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
h_len = len(haystack)
n_len = len(needle)
if (n_len == 0):
return 0
if n_len > h_len:
return -1
n_jump = [0] * n_len
i = 2
i_p = i - 1
s_p = 0
cnt = 0... | class Solution:
def str_str(self, haystack: str, needle: str) -> int:
h_len = len(haystack)
n_len = len(needle)
if n_len == 0:
return 0
if n_len > h_len:
return -1
n_jump = [0] * n_len
i = 2
i_p = i - 1
s_p = 0
cnt = 0
... |
# Time: O(n)
# Space: O(h)
# 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 getAllElements(self, root1, root2):
"""
:type root1: TreeNode
:type root2... | class Treenode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def get_all_elements(self, root1, root2):
"""
:type root1: TreeNode
:type root2: TreeNode
:rtype: List[int]
"""
def i... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def rightSideView(self, root):
if not root:
return []
nodes = [root.val]
... | class Solution:
def right_side_view(self, root):
if not root:
return []
nodes = [root.val]
stack = [(root, 0)]
while stack:
(node, level) = stack.pop()
if level >= len(nodes):
nodes.append(node.val)
(left, right) = (nod... |
"""
Cursor Access Mode.
"""
class CursorAccessMode:
"""
Define thre methods of access of cursors.
"""
Insert = 0
Edit = 1
Del = 2
Browse = 3
| """
Cursor Access Mode.
"""
class Cursoraccessmode:
"""
Define thre methods of access of cursors.
"""
insert = 0
edit = 1
del = 2
browse = 3 |
def plane():
print('Plane')
def car():
print('Car')
def main():
print('-' * 55)
plane()
car()
main()
| def plane():
print('Plane')
def car():
print('Car')
def main():
print('-' * 55)
plane()
car()
main() |
test = {
'name': 'scale-stream',
'points': 1,
'suites': [
{
'cases': [
{
'code': r"""
scm> (car s2)
2
scm> (car (cdr-stream s2))
4
scm> (car s4)
4
scm> (car (cdr-stream s4))
8
""",
'hidd... | test = {'name': 'scale-stream', 'points': 1, 'suites': [{'cases': [{'code': '\n scm> (car s2)\n 2\n scm> (car (cdr-stream s2))\n 4\n scm> (car s4)\n 4\n scm> (car (cdr-stream s4))\n 8\n ', 'hidden': False, 'locked': False}], 'scored': True... |
__author__ = 'shenoisz'
def get_object_list( args ):
csv = open( str( args ) , 'r')
lines = [ ]
for divier in csv.readlines( ):
fatias = divier.replace('\n', '').split('|')
lines.append( fatias )
csv.close( )
return lines
def get_object_dict( args ):
csv = open( str( args ) ,... | __author__ = 'shenoisz'
def get_object_list(args):
csv = open(str(args), 'r')
lines = []
for divier in csv.readlines():
fatias = divier.replace('\n', '').split('|')
lines.append(fatias)
csv.close()
return lines
def get_object_dict(args):
csv = open(str(args), 'r')
lines = [... |
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2012, Machinalis S.R.L.
# This file is part of quepy and is distributed under the Modified BSD License.
# You should have received a copy of license in the LICENSE file.
#
# Authors: Rafael Carrascosa <rcarrascosa@machinalis.com>
# Gonzalo Garcia Berrotara... | """
Init for testapp quepy.
""" |
'''Some helper functions to support `native-image` invocation within rules.
'''
load("//java:providers/JavaDependencyInfo.bzl", "JavaDependencyInfo")
load("//graalvm:common/extract/toolchain_info.bzl", "extract_graalvm_native_image_toolchain_info")
def _file_to_path(file):
return file.path
# TODO(dwtj): Consider... | """Some helper functions to support `native-image` invocation within rules.
"""
load('//java:providers/JavaDependencyInfo.bzl', 'JavaDependencyInfo')
load('//graalvm:common/extract/toolchain_info.bzl', 'extract_graalvm_native_image_toolchain_info')
def _file_to_path(file):
return file.path
def make_class_path_dep... |
"""ds4drv is a Sony DualShock 4 userspace driver for Linux."""
__title__ = "ds4drv"
__version__ = "0.5.0"
__author__ = "Christopher Rosell"
__credits__ = ["Christopher Rosell", "George Gibbs", "Lauri Niskanen"]
__license__ = "MIT"
| """ds4drv is a Sony DualShock 4 userspace driver for Linux."""
__title__ = 'ds4drv'
__version__ = '0.5.0'
__author__ = 'Christopher Rosell'
__credits__ = ['Christopher Rosell', 'George Gibbs', 'Lauri Niskanen']
__license__ = 'MIT' |
"""Print 'Hello world' to the terminal.
Here's where the |foo| substitution is used - it is defined
below.
.. |foo| replace:: Here's where it's defined.
So far so good, but what if the definition is not in the same
docstring fragment - it could be in an included footer?
Here the |bar| substitution definition is mis... | """Print 'Hello world' to the terminal.
Here's where the |foo| substitution is used - it is defined
below.
.. |foo| replace:: Here's where it's defined.
So far so good, but what if the definition is not in the same
docstring fragment - it could be in an included footer?
Here the |bar| substitution definition is mis... |
class Solution(object):
def __init__(self, *args, **kwargs):
self.num = None
self.target = None
def addOperators(self, num, target):
"""
:type num: str
:type target: int
:rtype: List[str]
"""
if num is None or len(num) == 0:
return []... | class Solution(object):
def __init__(self, *args, **kwargs):
self.num = None
self.target = None
def add_operators(self, num, target):
"""
:type num: str
:type target: int
:rtype: List[str]
"""
if num is None or len(num) == 0:
return [... |
#!/usr/bin/env python
# This tests a particular tricky case: the interplay of "black" wrap mode
# with fill color. Outside the s,t [0,1] range, it should be black, NOT
# fill color.
# Make an RGB grid for our test
command += (oiio_app("oiiotool")
+ OIIO_TESTSUITE_IMAGEDIR + "/grid.tif"
+ " ... | command += oiio_app('oiiotool') + OIIO_TESTSUITE_IMAGEDIR + '/grid.tif' + ' -ch R,G,B -o grid3.tif >> out.txt ;\n'
command += oiio_app('oiiotool') + OIIO_TESTSUITE_IMAGEDIR + '/grid.tif' + ' -ch R -o grid1.tif >> out.txt ;\n'
command += testtex_command('grid3.tif', ' -res 256 256 -automip ' + ' -wrap black -fill 0.5 -d... |
engine_id = ""
grid_node_address = ""
grid_gateway_address = ""
data_dir = ""
dataset_id = ""
| engine_id = ''
grid_node_address = ''
grid_gateway_address = ''
data_dir = ''
dataset_id = '' |
record = "linux"
cats = [
"cats/linux-kernel.cat"
]
cfgs = [
"cfgs/linux-kernel.cfg"
]
illustrative_tests = [
"tests/MP+relacq.litmus"
]
| record = 'linux'
cats = ['cats/linux-kernel.cat']
cfgs = ['cfgs/linux-kernel.cfg']
illustrative_tests = ['tests/MP+relacq.litmus'] |
cities = (
("Andaman and Nicobar Islands", (("Port Blair", "Port Blair"),)),
(
"Andhra Pradesh",
(
("Visakhapatnam", "Visakhapatnam"),
("Vijayawada", "Vijayawada"),
("Guntur", "Guntur"),
("Nellore", "Nellore"),
("Kurnool", "Kurnool"),
... | cities = (('Andaman and Nicobar Islands', (('Port Blair', 'Port Blair'),)), ('Andhra Pradesh', (('Visakhapatnam', 'Visakhapatnam'), ('Vijayawada', 'Vijayawada'), ('Guntur', 'Guntur'), ('Nellore', 'Nellore'), ('Kurnool', 'Kurnool'), ('Rajamahendravaram', 'Rajamahendravaram'), ('Tirupati', 'Tirupati'), ('Kadapa', 'Kadapa... |
#Q: Add all the natural numbers below one thousand that are multiples of 3 or 5.
#A: 233168
sum([i for i in xrange(1,1000) if i%3==0 or i%5==0])
| sum([i for i in xrange(1, 1000) if i % 3 == 0 or i % 5 == 0]) |
# -*- coding: utf-8 -*-
# Define here the models for your spider middleware
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/spider-middleware.html
class DianpingCrawlerSpiderMiddleware(object):
def process_request(self, request, spider):
cookies = spider.settings.get('COOKIES', {})
... | class Dianpingcrawlerspidermiddleware(object):
def process_request(self, request, spider):
cookies = spider.settings.get('COOKIES', {})
request.cookies.update(cookies) |
class PLAN_CMDS(object):
FETCH_PLAN = "fetch_plan"
FETCH_PROTOCOL = "fetch_protocol"
class TENSOR_SERIALIZATION(object):
TORCH = "torch"
NUMPY = "numpy"
TF = "tf"
ALL = "all"
class GATEWAY_ENDPOINTS(object):
SEARCH_TAGS = "/search"
SEARCH_MODEL = "/search-model"
SEARCH_ENCRYPTED_... | class Plan_Cmds(object):
fetch_plan = 'fetch_plan'
fetch_protocol = 'fetch_protocol'
class Tensor_Serialization(object):
torch = 'torch'
numpy = 'numpy'
tf = 'tf'
all = 'all'
class Gateway_Endpoints(object):
search_tags = '/search'
search_model = '/search-model'
search_encrypted_mo... |
FreeMonoBoldOblique12pt7bBitmaps = [
0x1C, 0xF3, 0xCE, 0x38, 0xE7, 0x1C, 0x61, 0x86, 0x00, 0x63, 0x8C, 0x00,
0xE7, 0xE7, 0xE6, 0xC6, 0xC6, 0xC4, 0x84, 0x03, 0x30, 0x19, 0x81, 0xDC,
0x0C, 0xE0, 0x66, 0x1F, 0xFC, 0xFF, 0xE1, 0x98, 0x0C, 0xC0, 0xEE, 0x06,
0x70, 0xFF, 0xCF, 0xFE, 0x1D, 0xC0, 0xCC, 0x06, 0x6... | free_mono_bold_oblique12pt7b_bitmaps = [28, 243, 206, 56, 231, 28, 97, 134, 0, 99, 140, 0, 231, 231, 230, 198, 198, 196, 132, 3, 48, 25, 129, 220, 12, 224, 102, 31, 252, 255, 225, 152, 12, 192, 238, 6, 112, 255, 207, 254, 29, 192, 204, 6, 96, 119, 3, 48, 0, 1, 0, 112, 12, 7, 241, 254, 113, 204, 17, 128, 63, 3, 240, 15,... |
# A list of applications to be added to INSTALLED_APPS.
ADD_INSTALLED_APPS = ['starlingx_dashboard']
FEATURE = ['starlingx_dashboard']
ADD_HEADER_SECTIONS = \
['starlingx_dashboard.dashboards.admin.active_alarms.views.BannerView', ]
ADD_SCSS_FILES = ['dashboard/scss/styles.scss',
'dashboard/scs... | add_installed_apps = ['starlingx_dashboard']
feature = ['starlingx_dashboard']
add_header_sections = ['starlingx_dashboard.dashboards.admin.active_alarms.views.BannerView']
add_scss_files = ['dashboard/scss/styles.scss', 'dashboard/scss/_host_topology.scss']
auto_discover_static_files = True |
#
# Generated by generate.py
#
class VMCompilerInfo:
def getWordList(self):
return ["@","c@","!","c!",">r","r>",";","[literal]","[bzero]","[halt]","[nop]","+","nand","2/","0=","[temp]","[codebase]","[dictionary]","cursor!","screen!","keyboard@","blockread@","[stackreset]","blockwrite!","0","1","2","-1","dup","dr... | class Vmcompilerinfo:
def get_word_list(self):
return ['@', 'c@', '!', 'c!', '>r', 'r>', ';', '[literal]', '[bzero]', '[halt]', '[nop]', '+', 'nand', '2/', '0=', '[temp]', '[codebase]', '[dictionary]', 'cursor!', 'screen!', 'keyboard@', 'blockread@', '[stackreset]', 'blockwrite!', '0', '1', '2', '-1', 'dup... |
# stack class (implemented in doubly-liunked list)
class Node(object):
# initialize node object
def __init__(self, value=0):
self.value = value
self.next = None
self.previous = None
# handle printing
def __str__(self):
return(f"{self.value}")
class Queue(object):
... | class Node(object):
def __init__(self, value=0):
self.value = value
self.next = None
self.previous = None
def __str__(self):
return f'{self.value}'
class Queue(object):
def __init__(self, node=None):
self.head = node
self.tail = node
def enqueue(self,... |
# Given an array of ints, return True if one of the first 4 elements in the
# array is a 9. The array length may be less than 4.
# array_front9([1, 2, 9, 3, 4]) --> True
# array_front9([1, 2, 3, 4, 9]) --> False
# array_front9([1, 2, 3, 4, 5]) --> False
def array_front9(nums):
return 9 in nums[:4]
print(array_fro... | def array_front9(nums):
return 9 in nums[:4]
print(array_front9([1, 2, 9, 3, 4]))
print(array_front9([1, 2, 3, 4, 9]))
print(array_front9([1, 2, 3, 4, 5])) |
# ----------------------------------------------------------------------------
# pyglet
# Copyright (c) 2006-2008 Alex Holkner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistribu... | """Run list encoding utilities.
:since: pyglet 1.1
"""
__docformat__ = 'restructuredtext'
__version__ = '$Id: $'
class _Run(object):
def __init__(self, value, count):
self.value = value
self.count = count
def __repr__(self):
return 'Run(%r, %d)' % (self.value, self.count)
class Runl... |
def stage(ctx):
return {
"parent": "Tarball",
"triggers": {
"parent": True
},
"parameters": [],
"configs": [],
"jobs": [{
"name": "pytest agent",
"steps": [{
"tool": "shell",
"cmd": "sudo apt update &... | def stage(ctx):
return {'parent': 'Tarball', 'triggers': {'parent': True}, 'parameters': [], 'configs': [], 'jobs': [{'name': 'pytest agent', 'steps': [{'tool': 'shell', 'cmd': 'sudo apt update && sudo apt-get install -y python3-pip || ps axf', 'timeout': 300}, {'tool': 'shell', 'cmd': 'sudo pip3 install pytest'}, ... |
# Copyright 2019 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... | """Unit tests for build_test.bzl."""
load('//rules:build_test.bzl', 'build_test')
def build_test_test_suite():
native.genrule(name='build_test__make_src', outs=['build_test__src.cc'], cmd="echo 'int dummy() { return 0; }' > $@")
native.cc_library(name='build_test__build_target', srcs=[':build_test__make_src'])... |
def startUP():
pass
def carmDown():
pass
| def start_up():
pass
def carm_down():
pass |
"""
object_adventure.py
A text adventure with objects you can pick up and put down.
"""
# data setup
rooms = {
'empty': {'name': 'an empty room',
'east': 'bedroom', 'north': 'temple',
'contents': [],
'text': 'The stone floors and walls are cold and damp.'},
'temple': {'name': 'a sma... | """
object_adventure.py
A text adventure with objects you can pick up and put down.
"""
rooms = {'empty': {'name': 'an empty room', 'east': 'bedroom', 'north': 'temple', 'contents': [], 'text': 'The stone floors and walls are cold and damp.'}, 'temple': {'name': 'a small temple', 'east': 'torture', 'south': 'empty', ... |
#global field?
gname='tristan in GGGGGG!!!'
class c(object):
cname='tristan in CCCCCCC!!!!'
def f(self):
fname='tristan in FFFFFF!!!'
print(fname)
print(self.cname)
print(gname)
def f2(self,test):
fname=test
print(fname)
| gname = 'tristan in GGGGGG!!!'
class C(object):
cname = 'tristan in CCCCCCC!!!!'
def f(self):
fname = 'tristan in FFFFFF!!!'
print(fname)
print(self.cname)
print(gname)
def f2(self, test):
fname = test
print(fname) |
# Xs and Os, Nobody Knows
# Create a function that takes a string, checks if it has the same number of "x"s and "o"s and returns either True or False.
# Return a boolean value (True or False).
# The string can contain any character.
# When no x and no o are in the string, return True.
def XO(txt):
return len(list(fi... | def xo(txt):
return len(list(filter(lambda x: x == 'x' or x == 'X', list(txt)))) == len(list(filter(lambda x: x == 'o' or x == 'O', list(txt))))
print(xo('ooxx'))
print(xo('ooxXm'))
print(xo('xooxx')) |
# 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:
slowptr = head
fastptr = head
while(fastptr and fastptr.next):
fastptr = fastptr.next.n... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def middle_node(self, head: ListNode) -> ListNode:
slowptr = head
fastptr = head
while fastptr and fastptr.next:
fastptr = fastptr.next.next
slowptr = slowptr.n... |
# config.py
# AWS IoT endpoint settings
HOST_NAME = "<URL>-ats.iot.us-east-1.amazonaws.com"
HOST_PORT = 8883
# Thing certs & keys
PRIVATE_KEY = "/home/pi/certs9000/private.pem.key"
DEVICE_CERT = "/home/pi/certs9000/certificate.pem.crt"
ROOT_CERT = "/home/pi/certs9000/root-CA.crt"
# Message settings
TOPIC_SENSOR = "$... | host_name = '<URL>-ats.iot.us-east-1.amazonaws.com'
host_port = 8883
private_key = '/home/pi/certs9000/private.pem.key'
device_cert = '/home/pi/certs9000/certificate.pem.crt'
root_cert = '/home/pi/certs9000/root-CA.crt'
topic_sensor = '$aws/things/CarPen9000/sensor'
topic_ask_sensor = '$aws/things/CarPen9000/askSensor'... |
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# 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... | class Embedverbs(object):
"""
Const Class
This constants set contains possible verbs for a contained object.
See Also:
`API EmbedVerbs <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1embed_1_1EmbedVerbs.html>`_
"""
__ooo_ns__: str = 'com.sun.star.embed'
__o... |
def fiboarray(n):
fibo = [0,1]
for i in range (2,n):
fibo.append(fibo[i-1] + fibo[i-2])
return fibo
def fiboarray_extended(a,b):
max_fibo = fiboarray(max(abs(a),abs(b))+1)
output = []
for i in range (a,b):
if (i < 0):
output.append(-int(pow(-1,i)) * max_fibo[-i... | def fiboarray(n):
fibo = [0, 1]
for i in range(2, n):
fibo.append(fibo[i - 1] + fibo[i - 2])
return fibo
def fiboarray_extended(a, b):
max_fibo = fiboarray(max(abs(a), abs(b)) + 1)
output = []
for i in range(a, b):
if i < 0:
output.append(-int(pow(-1, i)) * max_fibo[... |
expected_output = {
"instance_id": {
4097: {"lisp": 0},
4099: {"lisp": 0},
4100: {"lisp": 0},
8188: {
"lisp": 0,
"site_name": {
"site_uci": {
"any-mac": {
"last_register": "never",
... | expected_output = {'instance_id': {4097: {'lisp': 0}, 4099: {'lisp': 0}, 4100: {'lisp': 0}, 8188: {'lisp': 0, 'site_name': {'site_uci': {'any-mac': {'last_register': 'never', 'up': 'no', 'who_last_registered': '--', 'inst_id': 8188}, '1416.9dff.e928/48': {'last_register': '2w1d', 'up': 'yes#', 'who_last_registered': '1... |
'''
Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B.
Example 1:
Input: A = "ab", B = "ba"
Output: true
Example 2:
Input: A = "ab", B = "ab"
Output: false
Example 3:
Input: A = "aa", B = "aa"
Output: true
Example 4:
Input: A = "a... | """
Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B.
Example 1:
Input: A = "ab", B = "ba"
Output: true
Example 2:
Input: A = "ab", B = "ab"
Output: false
Example 3:
Input: A = "aa", B = "aa"
Output: true
Example 4:
Input: A = "a... |
class Solution:
def twoSum(self, nums: list[int], target: int) -> list[int]:
"""Find indices of the terms.
Given an array of integers nums and an integer target, return indices
of the two numbers such that they add up to target.
"""
my_dict = {}
result = []
f... | class Solution:
def two_sum(self, nums: list[int], target: int) -> list[int]:
"""Find indices of the terms.
Given an array of integers nums and an integer target, return indices
of the two numbers such that they add up to target.
"""
my_dict = {}
result = []
... |
class SOFATrace:
data = []
name = []
title = []
color = []
x_field = []
y_field = []
highlight = None
| class Sofatrace:
data = []
name = []
title = []
color = []
x_field = []
y_field = []
highlight = None |
num = int(input())
def input_lines(number):
lines = set()
for _ in range(number):
lines.add(input())
return lines
def print_data(names):
for name in names:
print(name)
names = input_lines(num)
print_data(names) | num = int(input())
def input_lines(number):
lines = set()
for _ in range(number):
lines.add(input())
return lines
def print_data(names):
for name in names:
print(name)
names = input_lines(num)
print_data(names) |
"""
Column aliasing.
"""
class ColumnAlias:
"""
Descriptor to reference a column by a well known alias.
"""
def __init__(self, name):
self.name = name
def __get__(self, cls, owner):
return getattr(cls or owner, self.name)
def __set__(self, cls, value):
return setatt... | """
Column aliasing.
"""
class Columnalias:
"""
Descriptor to reference a column by a well known alias.
"""
def __init__(self, name):
self.name = name
def __get__(self, cls, owner):
return getattr(cls or owner, self.name)
def __set__(self, cls, value):
return setatt... |
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def partition(self, head, x):
"""
:type head: ListNode
:type x: int
:rtype: ListNode
"""
less = ListNode(-1)
... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def partition(self, head, x):
"""
:type head: ListNode
:type x: int
:rtype: ListNode
"""
less = list_node(-1)
more = list_node(-2)
... |
class BaseColumnsProvider(object):
ROW_ID = 'row_id'
def get_columns_list_with_types(self):
dtypes_list = list()
dtypes_list.append((BaseColumnsProvider.ROW_ID, 'int32'))
return dtypes_list
| class Basecolumnsprovider(object):
row_id = 'row_id'
def get_columns_list_with_types(self):
dtypes_list = list()
dtypes_list.append((BaseColumnsProvider.ROW_ID, 'int32'))
return dtypes_list |
# Copyright (c) Open-MMLab. All rights reserved.
__version__ = '0.18.0'
short_version = __version__
| __version__ = '0.18.0'
short_version = __version__ |
def maxProfit(prices):
profit = 0
for i in range(len(prices)-1):
if prices[i] < prices[i+1]:
profit += (prices[i+1] - prices[i])
return profit
| def max_profit(prices):
profit = 0
for i in range(len(prices) - 1):
if prices[i] < prices[i + 1]:
profit += prices[i + 1] - prices[i]
return profit |
# Using the print function
# Simple usage
print("London")
print(100)
print(20.20)
# print with Variables
first_name = "John"
last_name = "Papa"
print(first_name, last_name, 1, 2, "Hello")
# Using +
print(first_name + last_name)
print(first_name + ", " +last_name)
# Inserting new line character & tab
print("Apples")... | print('London')
print(100)
print(20.2)
first_name = 'John'
last_name = 'Papa'
print(first_name, last_name, 1, 2, 'Hello')
print(first_name + last_name)
print(first_name + ', ' + last_name)
print('Apples')
print('Banana')
print('Mangoes')
print('-----')
print('Apples \nBanana \nMangoes')
print('-----')
print('Apples \tB... |
class LRUCache:
"""
Our LRUCache class keeps track of the max number of nodes it
can hold, the current number of nodes it is holding, a doubly-
linked list that holds the key-value entries in the correct
order, as well as a storage dict that provides fast access
to every node stored in the cach... | class Lrucache:
"""
Our LRUCache class keeps track of the max number of nodes it
can hold, the current number of nodes it is holding, a doubly-
linked list that holds the key-value entries in the correct
order, as well as a storage dict that provides fast access
to every node stored in the cach... |
class Solution:
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
sign = -1 if x < 0 else 1
temp_str = str(abs(x))
if len(temp_str) <= 1:
return sign*int(temp_str)
temp_str = temp_str[::-1]
while(temp_str[0] == '0'):
... | class Solution:
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
sign = -1 if x < 0 else 1
temp_str = str(abs(x))
if len(temp_str) <= 1:
return sign * int(temp_str)
temp_str = temp_str[::-1]
while temp_str[0] == '0':
... |
Text1 = "#"
Text2 = '''
\nadd_core = MSW
owner = MSW
controller = MSW
culture = minesweeper_culture
religion = animism
hre = no
base_tax = 0
base_production = 0
base_manpower = 0
trade_goods = copper\n'''
Text3 = "capital = \""
Text4 = '''"
is_city = yes'''
for i in range (5000, 5100):
stri = str(i)
out = Text1 + s... | text1 = '#'
text2 = '\n\nadd_core = MSW\nowner = MSW\ncontroller = MSW\nculture = minesweeper_culture\nreligion = animism\nhre = no\nbase_tax = 0\nbase_production = 0\nbase_manpower = 0\ntrade_goods = copper\n'
text3 = 'capital = "'
text4 = '"\nis_city = yes'
for i in range(5000, 5100):
stri = str(i)
out = Text... |
# file.py
def create_name():
return "new_file.txt"
def create_time():
return "today"
| def create_name():
return 'new_file.txt'
def create_time():
return 'today' |
#%% File
def write(text):
with open("./myFile.txt", "w") as file:
file.write(text)
def append(text):
with open("./myFile.txt", "a") as file:
file.write(text)
def readDirty():
file = open("./myFile.txt", "r")
content = file.readlines()
file.close()
return content
def read():
... | def write(text):
with open('./myFile.txt', 'w') as file:
file.write(text)
def append(text):
with open('./myFile.txt', 'a') as file:
file.write(text)
def read_dirty():
file = open('./myFile.txt', 'r')
content = file.readlines()
file.close()
return content
def read():
with o... |
def main():
while True:
# input
n = int(input())
if n:
xyrs = [[*map(int, input().split())] for _ in range(n)]
else:
return
# compute
# output
if __name__ == '__main__':
main()
| def main():
while True:
n = int(input())
if n:
xyrs = [[*map(int, input().split())] for _ in range(n)]
else:
return
if __name__ == '__main__':
main() |
'Check if string is of format a.(b+c)*'
print("Enter z to terminate.\n")
string = ""
while string != "z":
string = input("Enter the string to be checked: ")
count = 0
if string[0] == "a":
for i in range(1, len(string)):
if string[i] == "b" or string[i] == "c":
count += 1... | """Check if string is of format a.(b+c)*"""
print('Enter z to terminate.\n')
string = ''
while string != 'z':
string = input('Enter the string to be checked: ')
count = 0
if string[0] == 'a':
for i in range(1, len(string)):
if string[i] == 'b' or string[i] == 'c':
count +... |
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.
class mutable_string(object):
def __init__(self, value):
assert value.__class__ is str
self.target = value
def __getattr__(self, attr):
return self.target.__getattribute__(att... | class Mutable_String(object):
def __init__(self, value):
assert value.__class__ is str
self.target = value
def __getattr__(self, attr):
return self.target.__getattribute__(attr)
def __getitem__(self, key):
return self.target[key]
def __setitem__(self, key, value):
... |
def psychologist():
print('Please tell me your problems')
while True:
answer = (yield)
if answer is not None:
if answer.endswith('?'):
print("Don't ask yourself too much questions")
elif 'good' in answer:
print("Ahh that's good, go on")
... | def psychologist():
print('Please tell me your problems')
while True:
answer = (yield)
if answer is not None:
if answer.endswith('?'):
print("Don't ask yourself too much questions")
elif 'good' in answer:
print("Ahh that's good, go on")
... |
include_gcode_from("/home/michael/Documents/Cross1.ngc")
send_gcode_lines()
i = -2
include_gcode_from("/home/michael/Documents/CrossOutline.ngc",False)
comment("BEGINNING CrossOutline")
while i > -11:
move(0,0)
i -= 2
print("i is: {}".format(i))
if i < -11:
i = -11
setv("#1",i)
send_gco... | include_gcode_from('/home/michael/Documents/Cross1.ngc')
send_gcode_lines()
i = -2
include_gcode_from('/home/michael/Documents/CrossOutline.ngc', False)
comment('BEGINNING CrossOutline')
while i > -11:
move(0, 0)
i -= 2
print('i is: {}'.format(i))
if i < -11:
i = -11
setv('#1', i)
send_g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.