content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# https://leetcode.com/problems/linked-list-cycle-ii/
# Given a linked list, return the node where the cycle begins. If there is no
# cycle, return null.
# There is a cycle in a linked list if there is some node in the list that can be
# reached again by continuously following the next pointer. Internally, pos is
# u... | class Solution:
def detect_cycle(self, head: ListNode) -> ListNode:
if not head or not head.next:
return None
is_cycle = False
(slow, fast) = (head, head)
while fast.next and fast.next.next:
slow = slow.next
fast = fast.next.next
if sl... |
# -*- coding: utf-8 -*-
class KriegspielException(Exception):
pass
| class Kriegspielexception(Exception):
pass |
class Edge:
# edge for polygon
def __init__(self):
self.id = -1
# polygon vertex id
self.v0_id = -1
self.v1_id = -1
# connected polygon node id
self.node0_id = -1
self.node1_id = -1
# the lane id this edge cross
self.cross_lane_id = -1
... | class Edge:
def __init__(self):
self.id = -1
self.v0_id = -1
self.v1_id = -1
self.node0_id = -1
self.node1_id = -1
self.cross_lane_id = -1
def init_edge(self, v0_id, v1_id, node0_id, node1_id):
assert v0_id != v1_id
self.v0_id = v0_id
sel... |
# encoding: utf8
class End(object):
def __init__(self, connection=None):
self.connection = connection
self.__point = None
def paint(self, painter, point):
self.connection.paint(painter, self, point)
def set_point(self, point):
self.__point = point
def get_point(self)... | class End(object):
def __init__(self, connection=None):
self.connection = connection
self.__point = None
def paint(self, painter, point):
self.connection.paint(painter, self, point)
def set_point(self, point):
self.__point = point
def get_point(self):
return s... |
# Straight down to your spine(After u crash into a "PROTEIN THINGNY" by E235 at 65km/h, imagine that high-speed and safe brought u by JR East and ATC/ATS)
# Be "straight" here for sure: This is for some external features that I just want to share around the repo and test it out
# Btw, remenber what this repo for?
def... | def unwrap(incoming: str):
dump = incoming
try:
head = dump.index('{')
except Exception:
return IOError
try:
tail = dump.index('};')
except Exception:
return IOError
dump = dump[head - 1:tail - 1]
raw_val = dump.split(';')
counter = 0
backed_val = {}
... |
num = float(input())
if (100 > num or num > 200) and num != 0:
print("invalid")
elif num == 0:
print()
| num = float(input())
if (100 > num or num > 200) and num != 0:
print('invalid')
elif num == 0:
print() |
# 21300 - [Job Adv] (Lv.60) Aran
sm.setSpeakerID(1510009)
sm.sendNext("How is the training going? Hm, Lv. 60? You still ahve a long way to go, but it's definitely praiseworthy compared to the first time I met you. Continue to train diligently, and I'm sure you'll regain your strength soon!")
if sm.sendAskYesNo("But f... | sm.setSpeakerID(1510009)
sm.sendNext("How is the training going? Hm, Lv. 60? You still ahve a long way to go, but it's definitely praiseworthy compared to the first time I met you. Continue to train diligently, and I'm sure you'll regain your strength soon!")
if sm.sendAskYesNo('But first, you must head to #b#m14000000... |
i = 0
while True:
print(i)
i = i + 1
| i = 0
while True:
print(i)
i = i + 1 |
# Please be warned, that when turning on the "saving_enabled" feature, it will consume a lot of ram while it is saving
# The frames. This is because every single frame that is played during the animation is recorded into the memory
# At the moment, I dont see any other way to output a gif straight out of pygame. ... | saving_enabled = False
optimization_level = 1
duration = 8
display_stats = True
display_grid = True
silhouette = True
brush_size = 3
res = (800, 600)
tile_size = 5
lerp_speed = 0.1
output_name = 'out'
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (170, 0, 210), (0, 130, 200), (255, 128, 128), (255, 255, 255)]
defaul... |
# EDITION
# PLAYING WITH NUMBERS
my_var_int = 1234
my_var_int = my_var_int + 20
print(f"my_var_int: {my_var_int}")
my_var_int += 20# my_var_int = my_var_int + 20
print(f"my_var_int: {my_var_int}")
my_var_int = my_var_int - 75 # substraction
print(f"my_var_int: {my_var_int}")
my_var_int = my_var_int / 2 # division
print... | my_var_int = 1234
my_var_int = my_var_int + 20
print(f'my_var_int: {my_var_int}')
my_var_int += 20
print(f'my_var_int: {my_var_int}')
my_var_int = my_var_int - 75
print(f'my_var_int: {my_var_int}')
my_var_int = my_var_int / 2
print(f'my_var_int: {my_var_int}')
my_var_int = my_var_int * 10
print(f'my_var_int: {my_var_in... |
# Copyright 2012 Google Inc. 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 law or ... | {'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'core_lib', 'type': 'static_library', 'sources': ['address.cc', 'address.h', 'address_filter.h', 'address_filter_impl.h', 'address_range.cc', 'address_range.h', 'address_space.cc', 'address_space.h', 'address_space_internal.h', 'disassembler.cc', 'disassem... |
r=int(input("enter radius\n"))
area=3.14*r*r
print(area)
r=int(input("enter radius\n"))
circumference=2*3.14*r
print(circumference)
| r = int(input('enter radius\n'))
area = 3.14 * r * r
print(area)
r = int(input('enter radius\n'))
circumference = 2 * 3.14 * r
print(circumference) |
plugins_modules = [
"authorization",
"anonymous",
]
| plugins_modules = ['authorization', 'anonymous'] |
SEND_TEXT = 'send_text'
SEND_IMAGE = 'send_image'
SEND_TEXT_AND_BUTTON = 'send_text_and_button'
CHECK_STATUS_MESSAGES = 'check_status_messages'
API = [SEND_TEXT, SEND_IMAGE, SEND_TEXT_AND_BUTTON, CHECK_STATUS_MESSAGES]
API_CHOICES = [(api, api) for api in API] | send_text = 'send_text'
send_image = 'send_image'
send_text_and_button = 'send_text_and_button'
check_status_messages = 'check_status_messages'
api = [SEND_TEXT, SEND_IMAGE, SEND_TEXT_AND_BUTTON, CHECK_STATUS_MESSAGES]
api_choices = [(api, api) for api in API] |
def reverse(list):
if len(list) < 2:
return list
return [list[-1]] + reverse(list[:-1])
assert reverse([]) == []
assert reverse([2]) == [2]
assert reverse([2, 6, 5]) == [5, 6, 2] | def reverse(list):
if len(list) < 2:
return list
return [list[-1]] + reverse(list[:-1])
assert reverse([]) == []
assert reverse([2]) == [2]
assert reverse([2, 6, 5]) == [5, 6, 2] |
class Arvore():
def __init__(self, valor, esq=None, dir=None):
self.dir = dir
self.esq = esq
self.valor = valor
def __iter__(self):
yield self.valor
if self.esq:
for valor in self.esq:
yield valor
if self.dir:
for valor in ... | class Arvore:
def __init__(self, valor, esq=None, dir=None):
self.dir = dir
self.esq = esq
self.valor = valor
def __iter__(self):
yield self.valor
if self.esq:
for valor in self.esq:
yield valor
if self.dir:
for valor in s... |
#4
row=0
while row<10:
col=0
while col<9:
if col+row==6 or row==6 or (col==6):
print("*",end=" ")
else:
print(" ",end=" ")
col +=1
row +=1
print()
| row = 0
while row < 10:
col = 0
while col < 9:
if col + row == 6 or row == 6 or col == 6:
print('*', end=' ')
else:
print(' ', end=' ')
col += 1
row += 1
print() |
def hex(number):
if number == 0:
return '0'
res = ''
while number > 0:
digit = number % 16
if digit <= 9:
digit = str(digit)
elif digit <= 13:
if digit <= 11:
if digit == 10:
digit = 'A'
else:
... | def hex(number):
if number == 0:
return '0'
res = ''
while number > 0:
digit = number % 16
if digit <= 9:
digit = str(digit)
elif digit <= 13:
if digit <= 11:
if digit == 10:
digit = 'A'
else:
... |
class Singleton(type):
_instances = {}
def __call__(cls, tree):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(tree)
instance = cls._instances[cls]
instance.tree = tree # update tree
return instance
def clear(cls):
tr... | class Singleton(type):
_instances = {}
def __call__(cls, tree):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(tree)
instance = cls._instances[cls]
instance.tree = tree
return instance
def clear(cls):
try:
... |
#Joe is a prisoner who has been sentenced to hard labor for his crimes. Each day he is given a pile of large rocks to break into tiny rocks. To make matters worse, they do not provide any tools to work with. Instead, he must use the rocks themselves. He always picks up the largest two stones and smashes them together... | a_count = int(input().strip())
a = []
for _ in range(a_count):
a_item = int(input().strip())
a.append(a_item)
def last_stone_weight(a):
print(f'before sort: {a}')
a.sort()
print(f'after sort: {a}')
b = a[0]
for i in range(len(a)):
if len(a) >= 2:
b = abs(a[-1] - a[-2])
... |
# (C) Datadog, Inc. 2020 - Present
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)
GENERIC_METRICS = {
'go_gc_duration_seconds': 'go.gc_duration_seconds',
'go_goroutines': 'go.goroutines',
'go_info': 'go.info',
'go_memstats_alloc_bytes': 'go.memstats.alloc_bytes',
'go_m... | generic_metrics = {'go_gc_duration_seconds': 'go.gc_duration_seconds', 'go_goroutines': 'go.goroutines', 'go_info': 'go.info', 'go_memstats_alloc_bytes': 'go.memstats.alloc_bytes', 'go_memstats_alloc_bytes_total': 'go.memstats.alloc_bytes_total', 'go_memstats_buck_hash_sys_bytes': 'go.memstats.buck_hash_sys_bytes', 'go... |
N, M = list(map(int, input().split()))
a_list = [[0 for _ in range(M)] for _ in range(N)]
for i in range(N):
a_list[i] = list(map(int, input().split()))
ans = 0
for t1 in range(M-1):
for t2 in range(t1+1, M):
score = 0
for i in range(N):
score += max(a_list[i][t1], a_list[i][t2])
... | (n, m) = list(map(int, input().split()))
a_list = [[0 for _ in range(M)] for _ in range(N)]
for i in range(N):
a_list[i] = list(map(int, input().split()))
ans = 0
for t1 in range(M - 1):
for t2 in range(t1 + 1, M):
score = 0
for i in range(N):
score += max(a_list[i][t1], a_list[i][t2... |
a = int(input())
b = int(input())
c = int(input())
max = a
if max < b:
max = b
if max < c:
max = c
elif max < c:
max = c
print(max) | a = int(input())
b = int(input())
c = int(input())
max = a
if max < b:
max = b
if max < c:
max = c
elif max < c:
max = c
print(max) |
students = {
"males" : ["joseph", "stephen", "theophilus"],
"females" : ["kara", "sharon", "lois"]
}
print(students["males"])
print(students["females"]) | students = {'males': ['joseph', 'stephen', 'theophilus'], 'females': ['kara', 'sharon', 'lois']}
print(students['males'])
print(students['females']) |
def hourglassSum(arr):
dic = {}
top = 0
mid = 1
bot = 2
top_one = 0
mid_one = 1
bot_one = 0
num = 0
max = float('-inf')
while bot < len(arr):
while bot_one < len(arr[-1])-2:
dic[num] = sum(arr[top][top_one : top_one + 3]) + arr[mid][mid_one] + sum(arr... | def hourglass_sum(arr):
dic = {}
top = 0
mid = 1
bot = 2
top_one = 0
mid_one = 1
bot_one = 0
num = 0
max = float('-inf')
while bot < len(arr):
while bot_one < len(arr[-1]) - 2:
dic[num] = sum(arr[top][top_one:top_one + 3]) + arr[mid][mid_one] + sum(arr[bot][bo... |
'''
Various utility methods for building html attributes.
'''
def styles(*styles):
'''Join multiple "conditional styles" and return a single style attribute'''
return '; '.join(filter(None, styles))
def classes(*classes):
'''Join multiple "conditional classes" and return a single class attribute'''
return ' '.joi... | """
Various utility methods for building html attributes.
"""
def styles(*styles):
"""Join multiple "conditional styles" and return a single style attribute"""
return '; '.join(filter(None, styles))
def classes(*classes):
"""Join multiple "conditional classes" and return a single class attribute"""
r... |
class Solution:
def smallestSubsequence(self, s: str) -> str:
stack, seen, lastOccurence = deque([]), set(), {char: index for index, char in enumerate(s)}
for index, char in enumerate(s):
if char not in seen:
while stack and char < stack[-1] and index < lastOccurence[stac... | class Solution:
def smallest_subsequence(self, s: str) -> str:
(stack, seen, last_occurence) = (deque([]), set(), {char: index for (index, char) in enumerate(s)})
for (index, char) in enumerate(s):
if char not in seen:
while stack and char < stack[-1] and (index < lastOc... |
power = {'BUSES': {'Area': 1.33155,
'Bus/Area': 1.33155,
'Bus/Gate Leakage': 0.00662954,
'Bus/Peak Dynamic': 0.0,
'Bus/Runtime Dynamic': 0.0,
'Bus/Subthreshold Leakage': 0.0691322,
'Bus/Subthreshold Leakage with power gating': 0.0259246,
'Gate... | power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres... |
def study_template(p):
study_regex = r"Study"
for template in p.filter_templates(matches=study_regex):
if template.name.strip() == study_regex:
return template
return None
| def study_template(p):
study_regex = 'Study'
for template in p.filter_templates(matches=study_regex):
if template.name.strip() == study_regex:
return template
return None |
'''
*Book Record Management in Python*
With this project a used can Add/Delete/Update/View the book records
the project is implement in python
Inbuilt data structures used: LIST
concepts of functions, try-catch statements, if else statements and loops are used in this pr... | """
*Book Record Management in Python*
With this project a used can Add/Delete/Update/View the book records
the project is implement in python
Inbuilt data structures used: LIST
concepts of functions, try-catch statements, if else statements and loops are used in this program.
... |
DEPS = [
'archive',
'depot_tools/bot_update',
'chromium',
'chromium_tests',
'chromium_android',
'commit_position',
'file',
'depot_tools/gclient',
'isolate',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/python',
'recipe_engine/step',
'swarming',... | deps = ['archive', 'depot_tools/bot_update', 'chromium', 'chromium_tests', 'chromium_android', 'commit_position', 'file', 'depot_tools/gclient', 'isolate', 'recipe_engine/path', 'recipe_engine/platform', 'recipe_engine/properties', 'recipe_engine/python', 'recipe_engine/step', 'swarming', 'test_utils', 'trigger', 'depo... |
### All lines that are commented out (and some that aren't) are optional ###
### Telegram Settings
### Get your own api_id and api_hash from https://my.telegram.org, under API Development
### Default vaules are exmaple and will not work
API_ID = 123456 # Int value, example: 123456
API_HASH = 'e59ffe6c16bfaafb682... | api_id = 123456
api_hash = 'e59ffe6c16bfaafb6821a629fd057bc8'
filter_gym_name = 'Rib Cage Sculpture|Potting Garden|Tamarind Road Playground'
forward_id = 50000001 |
class DatasetParameter:
def __init__(self, db_url, **dataset_kwargs):
self.db_url = db_url
self.dataset_kwargs = dataset_kwargs
@property
def DbUrl(self): return self.db_url
@property
def DbKwargs(self): return self.dataset_kwargs
| class Datasetparameter:
def __init__(self, db_url, **dataset_kwargs):
self.db_url = db_url
self.dataset_kwargs = dataset_kwargs
@property
def db_url(self):
return self.db_url
@property
def db_kwargs(self):
return self.dataset_kwargs |
# This program demonstrates variable reassignment.
# Assign a value to the dollars variable.
dollars = 2.75
print('I have', dollars, 'in my account.')
# Reassign dollars so it references
# a different value.
dollars = 99.95
print('But now I have', dollars, 'in my account!')
| dollars = 2.75
print('I have', dollars, 'in my account.')
dollars = 99.95
print('But now I have', dollars, 'in my account!') |
suffix_slang_3 = {
'ine': '9',
'aus': 'oz',
'ate': '8',
'for': '4',
}
suffix_slang_4 = {
'ause': 'oz',
'fore': '4',
}
general_slang = {
'you': 'u',
'for': '4',
'thanks': 'thnx',
'are': 'r',
'they': 'dey',
'... | suffix_slang_3 = {'ine': '9', 'aus': 'oz', 'ate': '8', 'for': '4'}
suffix_slang_4 = {'ause': 'oz', 'fore': '4'}
general_slang = {'you': 'u', 'for': '4', 'thanks': 'thnx', 'are': 'r', 'they': 'dey', 'this': 'dis', 'that': 'dat'}
prefix_slang_3 = {'for': '4'}
prefix_slang_4 = {'fore': '4'}
abbreviations = {'away from the... |
def ClumpFinder(k,L,t,Genome):
#Length of Genome
N = len(Genome)
#Storing Frequent patterns
freq_patterns = []
for i in range(N-L+1):
#choosing region of length L in the Genome
region = Genome[i:i+L]
#Calculating the Frequency array in the first iteration
if... | def clump_finder(k, L, t, Genome):
n = len(Genome)
freq_patterns = []
for i in range(N - L + 1):
region = Genome[i:i + L]
if i == 0:
freq_dict = {}
for j in range(L - k + 1):
kmer = region[j:j + k]
freq_dict[kmer] = freq_dict.get(kmer, ... |
price, size = map(int, input().split())
dislikes = list(map(int, input().split()))
likes = list(set(range(10)) - set(dislikes))
digits = [int(digit) for digit in str(price)]
r_digits = list(reversed(digits))
res = []
for i in range(len(r_digits)):
if r_digits[i] in likes:
res.append(r_digits[i])
... | (price, size) = map(int, input().split())
dislikes = list(map(int, input().split()))
likes = list(set(range(10)) - set(dislikes))
digits = [int(digit) for digit in str(price)]
r_digits = list(reversed(digits))
res = []
for i in range(len(r_digits)):
if r_digits[i] in likes:
res.append(r_digits[i])
elif ... |
# # Literate Programming in Markdown
# ---------------------------------------------------------------------------
# Literate Programming in Markdown takes a markdown file and converts it into a programming language. Traditional programming often begins with writing code, followed by adding comments. The Literate Pr... | input_file_name = str(input('Type the Input File:'))
output_file_name = str(input('Output File Name (.py added automatically):'))
with open(inputFile_name) as input_file:
input_file_data = list(inputFile)
new_file_string = str()
inside_code_block = False
for line in inputFile_data:
if line[:3] == '~~~':
... |
class UserNotValidException(Exception):
pass
class PhoneNotValidException(Exception):
pass
class ConfigFileParseException(Exception):
pass
class DuplicateUserException(Exception):
pass
class IndexOutofRangeException(Exception):
pass
class IndexNotGivenException(Exception):
pass | class Usernotvalidexception(Exception):
pass
class Phonenotvalidexception(Exception):
pass
class Configfileparseexception(Exception):
pass
class Duplicateuserexception(Exception):
pass
class Indexoutofrangeexception(Exception):
pass
class Indexnotgivenexception(Exception):
pass |
class User:
def __init__(self, user_id, username):
self.id = user_id
self.username = username
self.followers = 0
self.following = 0
def follow(self, user):
user.followers += 1
self.following += 1
user_1 = User("001", "nuno")
user_2 = User("003", "paula")
... | class User:
def __init__(self, user_id, username):
self.id = user_id
self.username = username
self.followers = 0
self.following = 0
def follow(self, user):
user.followers += 1
self.following += 1
user_1 = user('001', 'nuno')
user_2 = user('003', 'paula')
user_1.... |
#Eliminar
conjuntos = set()
conjuntos = {1,2,3,"brian", 4.6}
conjuntos.discard(3)
print (conjuntos)
("==================================================================================")
| conjuntos = set()
conjuntos = {1, 2, 3, 'brian', 4.6}
conjuntos.discard(3)
print(conjuntos)
'==================================================================================' |
#The code is implemented to print the range of numbers from 100-15000
for x in range(50,750):
x = x * 2
print(x)
print("Even number") | for x in range(50, 750):
x = x * 2
print(x)
print('Even number') |
# class for tiles
class Tile:
def __init__(self, name, items=None, player_on=False, mob_on=False):
if name == 'w' or name == 'mt' or name == 'sb':
self.obstacle = True
else:
self.obstacle = False
self.name = name
self.items = items
self.player_on = player_on
self.mob_on = mob_on
self.mob = None
s... | class Tile:
def __init__(self, name, items=None, player_on=False, mob_on=False):
if name == 'w' or name == 'mt' or name == 'sb':
self.obstacle = True
else:
self.obstacle = False
self.name = name
self.items = items
self.player_on = player_on
se... |
def draw_event_cb(e):
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
if dsc.part == lv.PART.TICKS and dsc.id == lv.chart.AXIS.PRIMARY_X:
month = ["Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"]
# dsc.text is defined char text[16], I must therefore ... | def draw_event_cb(e):
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
if dsc.part == lv.PART.TICKS and dsc.id == lv.chart.AXIS.PRIMARY_X:
month = ['Jan', 'Febr', 'March', 'Apr', 'May', 'Jun', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']
dsc.text = bytes(month[dsc.value], 'ascii')
chart = lv.... |
## bisenetv2
cfg = dict(
model_type='bisenetv2',
num_aux_heads=4,
lr_start = 5e-2,
weight_decay=5e-4,
warmup_iters = 1000,
max_iter = 150000,
im_root='/remote-home/source/Cityscapes/',
train_im_anns='../datasets/cityscapes/train.txt',
val_im_anns='../datasets/cityscapes/val.txt',
... | cfg = dict(model_type='bisenetv2', num_aux_heads=4, lr_start=0.05, weight_decay=0.0005, warmup_iters=1000, max_iter=150000, im_root='/remote-home/source/Cityscapes/', train_im_anns='../datasets/cityscapes/train.txt', val_im_anns='../datasets/cityscapes/val.txt', scales=[0.25, 2.0], cropsize=[512, 1024], ims_per_gpu=8, ... |
LOOKUPS = {
"AirConditioning": {
"C":"Central",
"F":"Free Standing",
"M":"Multi-Zone",
"N":"None",
"T":"Through the Wall",
"U":"Unknown Type",
"W":"Window Units",
},
"Borough": {
"BK":"Brooklyn",
"BX":"Bronx",
"NY":"Manhattan",
"QN":"Queens",
"SI":"Staten Island",
},
"B... | lookups = {'AirConditioning': {'C': 'Central', 'F': 'Free Standing', 'M': 'Multi-Zone', 'N': 'None', 'T': 'Through the Wall', 'U': 'Unknown Type', 'W': 'Window Units'}, 'Borough': {'BK': 'Brooklyn', 'BX': 'Bronx', 'NY': 'Manhattan', 'QN': 'Queens', 'SI': 'Staten Island'}, 'BuildingAccess': {'A': 'Attended Elevator', 'E... |
token = ''
Whitelist = 'whitelist.txt'
Masterkey = '1bc45'
Students = 'students.txt'
| token = ''
whitelist = 'whitelist.txt'
masterkey = '1bc45'
students = 'students.txt' |
# define constants
DETALHE_FILE_NAME = 'detalhe_votacao_secao'
MUNZONA_FILE_NAME = 'detalhe_votacao_zona'
DC_CODE = '58335'
TURNO = '2'
SECAO_FILE = 'detalhe_votacao_secao_2016_RJ.txt'
BOLETIM_FILE = 'bweb_2t_RJ_31102016134235.txt'
COLUMNS_TO_DETALHE_SECAO = [
'codigo_municipio',
'secao',
'zona',
... | detalhe_file_name = 'detalhe_votacao_secao'
munzona_file_name = 'detalhe_votacao_zona'
dc_code = '58335'
turno = '2'
secao_file = 'detalhe_votacao_secao_2016_RJ.txt'
boletim_file = 'bweb_2t_RJ_31102016134235.txt'
columns_to_detalhe_secao = ['codigo_municipio', 'secao', 'zona', 'aptos', 'abstencoes', 'nao_considerados',... |
class Singleton:
__instance = None
def __new__(cls, val=None):
if Singleton.__instance is None:
Singleton.__instance = object.__new__(cls)
Singleton.__instance.val = val
return Singleton.__instance
| class Singleton:
__instance = None
def __new__(cls, val=None):
if Singleton.__instance is None:
Singleton.__instance = object.__new__(cls)
Singleton.__instance.val = val
return Singleton.__instance |
with open("input.txt") as f:
card_public, door_public = [int(x) for x in f.readlines()]
def transform_once(subject: int, num: int) -> int:
return (subject * num) % 20201227
num = 1
i = 0
while num != door_public:
i += 1
num = transform_once(7, num)
door_loop = i
num = 1
for _ in range(door_loop):
... | with open('input.txt') as f:
(card_public, door_public) = [int(x) for x in f.readlines()]
def transform_once(subject: int, num: int) -> int:
return subject * num % 20201227
num = 1
i = 0
while num != door_public:
i += 1
num = transform_once(7, num)
door_loop = i
num = 1
for _ in range(door_loop):
n... |
# 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 insertIntoBST(self, root: TreeNode, val: int) -> TreeNode:
# Iteration (1): Time O(h) Space O(1)
... | class Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def insert_into_bst(self, root: TreeNode, val: int) -> TreeNode:
if not root:
return tree_node(val)
node = root
whil... |
def setup_application():
# Example to change config stuff, call this method before everything else.
# config.cache_config.cache_dir = "abc"
a = 1
| def setup_application():
a = 1 |
# Databricks notebook source
GFMGVNZKIYBRLMUHVQJSGYOCQYAYFKD
NATXOZQANOZFMUPBDEBUCJBHQ
BJWJMKDTNLLWEEQGCDJHHROEXMTBAULGXCRKMKPAOIFSOXERBMUOUQBBIVEWZHMSYRLVABWGSRFDRZXZCVSGFRALYARODLWSCWHPCCCYDSNEVCUWSKZJHCKBJDB
HRYAMXRDXHYWHJVTVBJEHAQTXYHBGBHHTNXU
OICSMCKGDPDCHROEZXHBROAOVOMOHKSZQSTZHZOBOUBKWKFQJFW
XVYHXHBOYUJCZFNBKYBK... | GFMGVNZKIYBRLMUHVQJSGYOCQYAYFKD
NATXOZQANOZFMUPBDEBUCJBHQ
BJWJMKDTNLLWEEQGCDJHHROEXMTBAULGXCRKMKPAOIFSOXERBMUOUQBBIVEWZHMSYRLVABWGSRFDRZXZCVSGFRALYARODLWSCWHPCCCYDSNEVCUWSKZJHCKBJDB
HRYAMXRDXHYWHJVTVBJEHAQTXYHBGBHHTNXU
OICSMCKGDPDCHROEZXHBROAOVOMOHKSZQSTZHZOBOUBKWKFQJFW
XVYHXHBOYUJCZFNBKYBKR
TEWCCYBEPDI
DEFSCRSOVVPZHNI... |
DEFAULT_DOTENV_KWARGS = dict(
driver='MSDSS_DATABASE_DRIVER',
user='MSDSS_DATABASE_USER',
password='MSDSS_DATABASE_PASSWORD',
host='MSDSS_DATABASE_HOST',
port='MSDSS_DATABASE_PORT',
database='MSDSS_DATABASE_NAME',
env_file='./.env',
key_path=None,
defaults=dict(
driver='postg... | default_dotenv_kwargs = dict(driver='MSDSS_DATABASE_DRIVER', user='MSDSS_DATABASE_USER', password='MSDSS_DATABASE_PASSWORD', host='MSDSS_DATABASE_HOST', port='MSDSS_DATABASE_PORT', database='MSDSS_DATABASE_NAME', env_file='./.env', key_path=None, defaults=dict(driver='postgresql', user='msdss', password='msdss123', hos... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
dateActually, monthActually, yearActually = list(map(int, input().split()))
dateExpected, monthExpected, yearExpected = list(map(int, input().split()))
fine = 0
if (yearActually > yearExpected):
fine = 10000
elif (yearActually == yearExpected):
... | (date_actually, month_actually, year_actually) = list(map(int, input().split()))
(date_expected, month_expected, year_expected) = list(map(int, input().split()))
fine = 0
if yearActually > yearExpected:
fine = 10000
elif yearActually == yearExpected:
if monthActually > monthExpected:
fine = (monthActual... |
x = int(input())
numbers = 0
while numbers < x:
y = int(input())
numbers += y
print(numbers)
| x = int(input())
numbers = 0
while numbers < x:
y = int(input())
numbers += y
print(numbers) |
# def f():
# x=10
if 1:
x=10
print(x) | if 1:
x = 10
print(x) |
def add(matrix_a, matrix_b):
rows = len(matrix_a)
columns = len(matrix_a[0])
matrix_c = []
for i in range(rows):
list_1 = []
for j in range(columns):
val = matrix_a[i][j] + matrix_b[i][j]
list_1.append(val)
matrix_c.append(list_1)
return matrix_c
def... | def add(matrix_a, matrix_b):
rows = len(matrix_a)
columns = len(matrix_a[0])
matrix_c = []
for i in range(rows):
list_1 = []
for j in range(columns):
val = matrix_a[i][j] + matrix_b[i][j]
list_1.append(val)
matrix_c.append(list_1)
return matrix_c
def ... |
# EDIT THESE WITH YOUR OWN DATASET/TABLES
billing_project_id = 'project_id'
billing_dataset_id = 'billing_dataset'
billing_table_name = 'billing_data'
output_dataset_id = 'output_dataset'
output_table_name = 'transformed_table'
# You can leave this unless you renamed the file yourself.
sql_file_path = 'cud_sud_attrib... | billing_project_id = 'project_id'
billing_dataset_id = 'billing_dataset'
billing_table_name = 'billing_data'
output_dataset_id = 'output_dataset'
output_table_name = 'transformed_table'
sql_file_path = 'cud_sud_attribution_query.sql'
allocation_method = 'P_method_2_commitment_cost' |
# testing the bargaining power proxy
def barPower(budget, totalBudget, N):
'''
(float, float, integer) => float
computes bargaining power within a project
'''
bP = ( N * budget - totalBudget) / (N * totalBudget)
return bP
projects = []
project1 = [10, 10, 10, 10, 1000]
project2 = [50, 50, 5... | def bar_power(budget, totalBudget, N):
"""
(float, float, integer) => float
computes bargaining power within a project
"""
b_p = (N * budget - totalBudget) / (N * totalBudget)
return bP
projects = []
project1 = [10, 10, 10, 10, 1000]
project2 = [50, 50, 50]
project3 = [70, 40, 57, 3, 190]
proje... |
class Solution:
def maxDepth(self, s: str) -> int:
z=0
m=0
for i in s:
if i=="(":
z+=1
elif i==")":
z-=1
m=max(m,z)
return m
| class Solution:
def max_depth(self, s: str) -> int:
z = 0
m = 0
for i in s:
if i == '(':
z += 1
elif i == ')':
z -= 1
m = max(m, z)
return m |
## Animal is-a object
class Animal(object):
pass
## Dog is-a Animal
class Dog(Animal):
def __init__(self, name):
## Dog has-a name
self.name = name
## Cat is-a Animal
class Cat(Animal):
def __init__(self, name):
## Cat has-a name
self.name = name
## Person is-a object... | class Animal(object):
pass
class Dog(Animal):
def __init__(self, name):
self.name = name
class Cat(Animal):
def __init__(self, name):
self.name = name
class Person(object):
def __init__(self, name):
self.name = name
self.pet = None
class Employee(Person):
def ... |
class Project:
def __init__(self, name=None, description=None, id=None):
self.name = name
self.description = description
self.id = id | class Project:
def __init__(self, name=None, description=None, id=None):
self.name = name
self.description = description
self.id = id |
__all__ = [
"max",
"min",
"pow",
"sqrt",
"exp",
"log",
"sin",
"cos",
"tan",
"arcsin",
"arccos",
"arctan",
"fabs",
"floor",
"ceil",
"isinf",
"isnan",
]
def max(a: float, b: float) -> float:
raise NotImplementedError
def min(a: float, b: float) -... | __all__ = ['max', 'min', 'pow', 'sqrt', 'exp', 'log', 'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', 'fabs', 'floor', 'ceil', 'isinf', 'isnan']
def max(a: float, b: float) -> float:
raise NotImplementedError
def min(a: float, b: float) -> float:
raise NotImplementedError
def pow(base: float, exp: float) ... |
# These contain production data that impacts logic
# no dependencies (besides DB migration)
ESSENTIAL_DATA_FIXTURES = (
'counties',
'organizations',
'addresses',
'groups',
'template_options',
)
# These contain fake accounts for each org
# depends on ESSENTIAL_DATA_FIXTURES
MOCK_USER_ACCOUNT_FIXTURE... | essential_data_fixtures = ('counties', 'organizations', 'addresses', 'groups', 'template_options')
mock_user_account_fixtures = ('mock_profiles',)
mock_application_fixtures = ('mock_2_submissions_to_a_pubdef', 'mock_2_submissions_to_ebclc', 'mock_2_submissions_to_cc_pubdef', 'mock_2_submissions_to_sf_pubdef', 'mock_2_s... |
class Const:
GITHUB = "https://github.com/ayvytr/PythonBox"
ISSUE = "https://github.com/Ayvytr/PythonBox/issues"
MAIL = "mailto:ayvytr@163.com?subject=Bug-Report&body={}"
| class Const:
github = 'https://github.com/ayvytr/PythonBox'
issue = 'https://github.com/Ayvytr/PythonBox/issues'
mail = 'mailto:ayvytr@163.com?subject=Bug-Report&body={}' |
def prediction(image_path):
img = tf.keras.utils.load_img(
image_path, target_size=(img_height, img_width))
img = tf.keras.utils.img_to_array(img)
plt.title('Image')
plt.axis('off')
plt.imshow((img/255.0).squeeze())
predict = model.predict(img[np.newaxis , ... | def prediction(image_path):
img = tf.keras.utils.load_img(image_path, target_size=(img_height, img_width))
img = tf.keras.utils.img_to_array(img)
plt.title('Image')
plt.axis('off')
plt.imshow((img / 255.0).squeeze())
predict = model.predict(img[np.newaxis, ...])
predicted_class = labels[np.a... |
target_str = "hello python world"
# reverse encrypt
print(target_str[-1::-1])
| target_str = 'hello python world'
print(target_str[-1::-1]) |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) The Lab of Professor Weiwei Lin (linww@scut.edu.cn),
# School of Computer Science and Engineering, South China University of Technology.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan ... | x1 = 3
x2 = 1
x3 = 5
x4 = 3
x5 = 3
x6 = 3
x7 = 3
x8 = 3
x9 = 3
x10 = 2
x11 = 2
x12 = 4
x13 = 4
x14 = 2
x15 = 2
x16 = 1
x17 = 2
x18 = 5
x19 = 1
x20 = 1
x21 = 1
x22 = 1
x23 = 1
x24 = 2
x25 = 4
x26 = 2
x27 = 3
x28 = 1
x29 = 2
x30 = 4
x31 = 4
x32 = 1
x33 = 4
x34 = 1
x35 = 2
x36 = 1
x37 = 3
x38 = 2
x39 = 1
x40 = 2
x41 = 3
x... |
def solve():
n=int(input())
row,col=(n,n)
res=""
for i in range(row):
for j in range(col):
if i==j:
res+='1 '
elif i==j-1:
res+='1 '
elif i==j+1:
res+='1 '
else:
res+='0 '
if i... | def solve():
n = int(input())
(row, col) = (n, n)
res = ''
for i in range(row):
for j in range(col):
if i == j:
res += '1 '
elif i == j - 1:
res += '1 '
elif i == j + 1:
res += '1 '
else:
... |
tuple_a = 1, 2
tuple_b = (1, 2)
print(tuple_a == tuple_b)
print(tuple_a[1])
AngkorWat = (13.4125, 103.866667)
print(type(AngkorWat))
# <class 'tuple'="">
print("AngkorWat is at latitude: {}".format(AngkorWat[0]))
# AngkorWat is at latitude: 13.4125
print("AngkorWat is at longitude: {}".format(AngkorWat[1])... | tuple_a = (1, 2)
tuple_b = (1, 2)
print(tuple_a == tuple_b)
print(tuple_a[1])
angkor_wat = (13.4125, 103.866667)
print(type(AngkorWat))
print('AngkorWat is at latitude: {}'.format(AngkorWat[0]))
print('AngkorWat is at longitude: {}'.format(AngkorWat[1])) |
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
''' Battery runner classes and Report classes '''
class BatteryRunner(object):
def __init__(self, checks):
self._checks = checks
def check_only(self, obj):
reports = []
fo... | """ Battery runner classes and Report classes """
class Batteryrunner(object):
def __init__(self, checks):
self._checks = checks
def check_only(self, obj):
reports = []
for check in self._checks:
reports.append(check(obj, False))
return reports
def check_fix(s... |
class Solution:
def spiralOrder(self, matrix) -> list:
result = []
m = len(matrix)
n = len(matrix[0])
flag = [[False] * n for _ in range(m)]
i = 0
j = 0
orient = (0, 1) # (0, 1)=left, (1, 0)=down, (0, -1)=right, (-1, 0)=up
while len(result) < m * n:
... | class Solution:
def spiral_order(self, matrix) -> list:
result = []
m = len(matrix)
n = len(matrix[0])
flag = [[False] * n for _ in range(m)]
i = 0
j = 0
orient = (0, 1)
while len(result) < m * n:
result.append(matrix[i][j])
fl... |
class RequireTwoFactorException(Exception):
pass
class LoginFailedException(Exception):
pass
| class Requiretwofactorexception(Exception):
pass
class Loginfailedexception(Exception):
pass |
### Default Pins M5Stack bzw. Mapping auf IoTKitV3.1 small
DEFAULT_IOTKIT_LED1 = 27 # ohne Funktion - internes Neopixel verwenden
DEFAULT_IOTKIT_BUZZER = 27 # ohne Funktion - internen Vibrationsmotor verwenden
DEFAULT_IOTKIT_BUTTON1 = 39 # Pushbotton A unter Touchscreen M5Stack
# Port A
DE... | default_iotkit_led1 = 27
default_iotkit_buzzer = 27
default_iotkit_button1 = 39
default_iotkit_i2_c_sda = 32
default_iotkit_i2_c_scl = 33
default_iotkit_port_b_dac = 26
default_iotkit_port_b_adc = 27
default_iotkit_port_c_tx = 14
default_iotkit_port_c_rx = 13
default_iotkit_port_c_tx = 1
default_iotkit_port_c_rx = 3
de... |
categories = [
(82, False, "player", "defense_ast", "Assist to a tackle."),
(91, False, "player", "defense_ffum", "Defensive player forced a fumble."),
(88, False, "player", "defense_fgblk", "Defensive player blocked a field goal."),
(60, False, "player", "defense_frec", "Defensive player recovered a fu... | categories = [(82, False, 'player', 'defense_ast', 'Assist to a tackle.'), (91, False, 'player', 'defense_ffum', 'Defensive player forced a fumble.'), (88, False, 'player', 'defense_fgblk', 'Defensive player blocked a field goal.'), (60, False, 'player', 'defense_frec', 'Defensive player recovered a fumble by the oppos... |
JAVA_EXEC_LABEL="//third_party/openjdk:java"
PHASICJ_AGENT_LABEL="//phasicj/agent:libpjagent"
RENAISSANCE_JAR_LABEL="//third_party/renaissance:jar"
RENAISSANCE_MAIN_CLASS="org.renaissance.core.Launcher"
PHASICJ_EXEC="//phasicj/cli"
EXTRA_PHASICJ_AGENT_OPTIONS="verbose"
def smoke_test_benchmark(name):
native.sh_tes... | java_exec_label = '//third_party/openjdk:java'
phasicj_agent_label = '//phasicj/agent:libpjagent'
renaissance_jar_label = '//third_party/renaissance:jar'
renaissance_main_class = 'org.renaissance.core.Launcher'
phasicj_exec = '//phasicj/cli'
extra_phasicj_agent_options = 'verbose'
def smoke_test_benchmark(name):
n... |
def trace(func):
def wrapper():
func_name = func.__name__
print(f'Entering "{func_name}" function')
func()
print(f'Exiting from "{func_name}" function')
return wrapper
def say_hello():
print('Hello!')
say_hello = trace(say_hello)
say_hello()
| def trace(func):
def wrapper():
func_name = func.__name__
print(f'Entering "{func_name}" function')
func()
print(f'Exiting from "{func_name}" function')
return wrapper
def say_hello():
print('Hello!')
say_hello = trace(say_hello)
say_hello() |
bitcoin = int(input())
yuans = float(input())
commission = float(input()) / 100
bitcoin_lv = bitcoin * 1168
yuans_dollars = yuans * (0.15 * 1.76)
sum_lv = bitcoin_lv + yuans_dollars
sum_eur = sum_lv / 1.95
sum_eur = round(sum_eur - (commission * sum_eur), 2)
print(sum_eur)
| bitcoin = int(input())
yuans = float(input())
commission = float(input()) / 100
bitcoin_lv = bitcoin * 1168
yuans_dollars = yuans * (0.15 * 1.76)
sum_lv = bitcoin_lv + yuans_dollars
sum_eur = sum_lv / 1.95
sum_eur = round(sum_eur - commission * sum_eur, 2)
print(sum_eur) |
description = 'Neutron Grating Interferometer'
group = 'optional'
tango_base = 'tango://antareshw.antares.frm2.tum.de:10000/antares/'
devices = dict(
G0rz = device('nicos.devices.entangle.Motor',
speed = 1,
unit = 'deg',
description = 'Rotation of G0 grating around beam direction',
... | description = 'Neutron Grating Interferometer'
group = 'optional'
tango_base = 'tango://antareshw.antares.frm2.tum.de:10000/antares/'
devices = dict(G0rz=device('nicos.devices.entangle.Motor', speed=1, unit='deg', description='Rotation of G0 grating around beam direction', tangodevice=tango_base + 'fzjs7/G0rz', abslimi... |
num = int(input("Insert some numbers: "))
even = 0
odd = 0
while num > 0:
if num%2 == 0:
even += 1
else:
odd += 1
num = num//10
print("Even numbers = %d, Odd numbers = %d" % (even,odd))
| num = int(input('Insert some numbers: '))
even = 0
odd = 0
while num > 0:
if num % 2 == 0:
even += 1
else:
odd += 1
num = num // 10
print('Even numbers = %d, Odd numbers = %d' % (even, odd)) |
def foo(x = []):
return x.append("x")
def bar(x = []):
return len(x)
foo()
bar()
class Owner(object):
@classmethod
def cm(cls, arg):
return cls
@classmethod
def cm2(cls, arg):
return arg
#Normal method
def m(self):
a = self.cm(0)
return a.cm2(1)
| def foo(x=[]):
return x.append('x')
def bar(x=[]):
return len(x)
foo()
bar()
class Owner(object):
@classmethod
def cm(cls, arg):
return cls
@classmethod
def cm2(cls, arg):
return arg
def m(self):
a = self.cm(0)
return a.cm2(1) |
#sequence cleaner removes sequences that are ambiguous (6-mer appending the poly sequence is indefinite ("N") and shifts all "N" characters
#in poly sequence right so that they can be combined
def sequenceCleaner(string):
if len(string) < 13:
return "", 0
if string[5] == "*":
return "", 0
if string[len(string)-... | def sequence_cleaner(string):
if len(string) < 13:
return ('', 0)
if string[5] == '*':
return ('', 0)
if string[len(string) - 6] == '*':
return ('', 0)
if not '*' in string[6:len(string) - 6]:
return (string[6:len(string) - 6], len(string) - 12)
else:
return r... |
def fibonaci(n):
if n <= 1:
return n
else:
return fibonaci(n-1)+fibonaci(n-2)
fibonaci(0) | def fibonaci(n):
if n <= 1:
return n
else:
return fibonaci(n - 1) + fibonaci(n - 2)
fibonaci(0) |
class Position:
def __init__(self, idx, ln, col, fn, ftxt) -> None:
self.idx = idx
self.ln = ln
self.col = col
self.fn = fn
self.ftxt = ftxt
def advance(self, current_char=None):
self.idx += 1
self.col += 1
if current_char == "\n":
se... | class Position:
def __init__(self, idx, ln, col, fn, ftxt) -> None:
self.idx = idx
self.ln = ln
self.col = col
self.fn = fn
self.ftxt = ftxt
def advance(self, current_char=None):
self.idx += 1
self.col += 1
if current_char == '\n':
se... |
def on_config():
# Here you can do all you want.
print("Called.")
def on_config_with_config(config):
print("Called with config.")
print(config["docs_dir"])
# You can change config, for example:
# config['docs_dir'] = 'other_directory'
# Optionally, you can return altered config to custom... | def on_config():
print('Called.')
def on_config_with_config(config):
print('Called with config.')
print(config['docs_dir'])
def on_config_with_mkapi(config, mkapi):
print('Called with config and mkapi.')
print(config['docs_dir'])
print(mkapi) |
##########################################################################
# Copyright (c) 2018-2019 NVIDIA Corporation. 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
#... | cuda_acceptable_src_extensions = ['.cu', '.c', '.cc', '.cxx', '.cpp']
cuda_acceptable_hdr_extensions = ['.h', '.cuh', '.hpp', '.inl']
cuda_acceptable_bin_extensions = ['.ptx', '.cubin', '.fatbin', '.o', '.obj', '.a', '.lib', '.res', '.so']
cuda_acceptable_extensions = CUDA_ACCEPTABLE_SRC_EXTENSIONS + CUDA_ACCEPTABLE_BI... |
class Car(object):
condition = "new"
def __init__(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg
my_car = Car("Chevv", "GOLDEN", 1933)
print(my_car.model)
print(my_car.color)
print(my_car.mpg)
| class Car(object):
condition = 'new'
def __init__(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg
my_car = car('Chevv', 'GOLDEN', 1933)
print(my_car.model)
print(my_car.color)
print(my_car.mpg) |
def add(a, b) :
s = a + b
return s
#main app begins here
x = 2
y = 3
z = add(x, y)
print('Sum : ', z) | def add(a, b):
s = a + b
return s
x = 2
y = 3
z = add(x, y)
print('Sum : ', z) |
#service.process.factory.proc_provider_factories
class ProcProviderFactories(object):
def __init__(self, log):
self._log = log
self._factory = None
def get_factory(self, process):
#should instantiate the teradata factory
if self._factory is None:
tmp = __import__('s... | class Procproviderfactories(object):
def __init__(self, log):
self._log = log
self._factory = None
def get_factory(self, process):
if self._factory is None:
tmp = __import__('service.process.factory.' + process.name.lower(), fromlist=[process.name + 'Factory'])
... |
def get_input():
file = open('inputs/bubble_sort.txt')
input = file.read()
file.close()
return input
def bubble_sort(a, n):
swap_count = 0
is_sorted = False
while not is_sorted:
is_sorted = True
for i in range(n-1):
if a[i] > a[i + 1]:
temp = a[i... | def get_input():
file = open('inputs/bubble_sort.txt')
input = file.read()
file.close()
return input
def bubble_sort(a, n):
swap_count = 0
is_sorted = False
while not is_sorted:
is_sorted = True
for i in range(n - 1):
if a[i] > a[i + 1]:
temp = a[... |
PROJECT_ID_LIST_URL = "https://cloudresourcemanager.googleapis.com/v1/projects"
HTTP_GET_METHOD = "GET"
class UtilBase(object):
def __init__(self, config):
self.config = config
self.__projectList = None
def getProjectList(self):
if self.__projectList != None:
return self._... | project_id_list_url = 'https://cloudresourcemanager.googleapis.com/v1/projects'
http_get_method = 'GET'
class Utilbase(object):
def __init__(self, config):
self.config = config
self.__projectList = None
def get_project_list(self):
if self.__projectList != None:
return self... |
NAME='logzmq'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lzmq']
GCC_LIST = ['plugin']
| name = 'logzmq'
cflags = []
ldflags = []
libs = ['-lzmq']
gcc_list = ['plugin'] |
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DEPS = [
'chromium',
'chromium_android',
'depot_tools/bot_update',
'depot_tools/gclient',
]
def RunSteps(api):
api.gclient.set_config('chromium')... | deps = ['chromium', 'chromium_android', 'depot_tools/bot_update', 'depot_tools/gclient']
def run_steps(api):
api.gclient.set_config('chromium')
api.chromium.set_config('chromium')
update_step = api.bot_update.ensure_checkout()
api.chromium_android.upload_apks_for_bisect(update_properties=update_step.js... |
# class Tree:
# def __init__(self, val, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def solve(self, root):
if root:
root.left, root.right = self.solve(root.right), self.solve(root.left)
return root
| class Solution:
def solve(self, root):
if root:
(root.left, root.right) = (self.solve(root.right), self.solve(root.left))
return root |
products = ['bread','meat','egg','cheese']
file1 = open('products.txt','w')
for product in products:
file1.write(product+'\n')
file1.close()
file2= open('products.txt')
var = file2.readlines()
print(var)
| products = ['bread', 'meat', 'egg', 'cheese']
file1 = open('products.txt', 'w')
for product in products:
file1.write(product + '\n')
file1.close()
file2 = open('products.txt')
var = file2.readlines()
print(var) |
class Layer(object):
def __init__(self):
self.prevlayer = None
self.nextlayer = None
def forepropagation(self):
pass
def backpropagation(self):
pass
def initialization(self):
pass
| class Layer(object):
def __init__(self):
self.prevlayer = None
self.nextlayer = None
def forepropagation(self):
pass
def backpropagation(self):
pass
def initialization(self):
pass |
def collapse_sequences(message, collapse_char, collapsing = False):
if message == '':
return ''
# Approach 1:
prepend = message[0]
if prepend == collapse_char:
if collapsing:
prepend = ''
collapsing = True
else:
collapsing = False
return prepend ... | def collapse_sequences(message, collapse_char, collapsing=False):
if message == '':
return ''
prepend = message[0]
if prepend == collapse_char:
if collapsing:
prepend = ''
collapsing = True
else:
collapsing = False
return prepend + collapse_sequences(messa... |
# Zombie Damage Skin
success = sm.addDamageSkin(2434661)
if success:
sm.chat("The Zombie Damage Skin has been added to your account's damage skin collection.")
| success = sm.addDamageSkin(2434661)
if success:
sm.chat("The Zombie Damage Skin has been added to your account's damage skin collection.") |
#
# Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and th... | {'includes': ['../build/features.gypi', '../build/scripts/scripts.gypi', '../build/win/precompile.gypi', 'blink_platform.gypi', 'heap/blink_heap.gypi'], 'targets': [{'target_name': 'blink_common', 'type': '<(component)', 'variables': {'enable_wexit_time_destructors': 1}, 'dependencies': ['../config.gyp:config', '../wtf... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.