content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# see http://python4astronomers.github.com/contest/bounce.html
figure(1)
clf()
axis([-10, 10, -10, 10])
# Define properties of the "bouncing balls"
n = 10
pos = (20 * random_sample(n*2) - 10).reshape(n, 2)
vel = (0.3 * normal(size=n*2)).reshape(n, 2)
sizes = 100 * random_sample(n) + 100
# Colors where each row is (Re... | figure(1)
clf()
axis([-10, 10, -10, 10])
n = 10
pos = (20 * random_sample(n * 2) - 10).reshape(n, 2)
vel = (0.3 * normal(size=n * 2)).reshape(n, 2)
sizes = 100 * random_sample(n) + 100
colors = random_sample([n, 4])
circles = scatter(pos[:, 0], pos[:, 1], marker='o', s=sizes, c=colors)
grav = -0.1 * ones(20).reshape(n,... |
#
# PySNMP MIB module TIARA-NETWORKS-CONFIG-MGMT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIARA-NETWORKS-CONFIG-MGMT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:16:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, constraints_intersection, single_value_constraint, value_range_constraint) ... |
# -*- coding: utf-8 -*-
# 16/12/15
# create by: snower
FORMATER = "watoee.formaters.formater.Formater"
SERIALIZE = "watoee.serializes.jsonserialize.JsonSerialize" | formater = 'watoee.formaters.formater.Formater'
serialize = 'watoee.serializes.jsonserialize.JsonSerialize' |
#-----------------------------------------------------------------------------
# Copyright (c) 2005-2017, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this s... | def pre_safe_import_module(api):
api.add_runtime_module(api.module_name) |
#Get the number at a specified row and column in Pascal's triangle
def getNumber(row, column):
if (column == 0) or (row == 0) or (column == row):
return 1
else:
return getNumber(row - 1, column - 1) + getNumber(row - 1, column)
if __name__ == "__main__":
row = int(input())
col = int(i... | def get_number(row, column):
if column == 0 or row == 0 or column == row:
return 1
else:
return get_number(row - 1, column - 1) + get_number(row - 1, column)
if __name__ == '__main__':
row = int(input())
col = int(input())
print(get_number(row, col)) |
class Today:
def __init__(self, cases, deaths, recoveries):
self.cases = cases
self.deaths = deaths
self.recoveries = recoveries
class PerMillion:
def __init__(self, cases, deaths, tests, active, recoveries, critical):
self.cases = cases
self.deaths = deaths
sel... | class Today:
def __init__(self, cases, deaths, recoveries):
self.cases = cases
self.deaths = deaths
self.recoveries = recoveries
class Permillion:
def __init__(self, cases, deaths, tests, active, recoveries, critical):
self.cases = cases
self.deaths = deaths
se... |
CHARMAP = [bytes([x]) for x in b'BCDFGHJKMPQRTVWXY2346789']
def b24encode(data):
enc = b''
for c in data:
enc += CHARMAP[c >> 4]
enc += CHARMAP[-(c & 0x0f) - 1]
return enc
def b24decode(data):
dec = b''
hi = -1
for c in data:
if hi < 0:
hi = CH... | charmap = [bytes([x]) for x in b'BCDFGHJKMPQRTVWXY2346789']
def b24encode(data):
enc = b''
for c in data:
enc += CHARMAP[c >> 4]
enc += CHARMAP[-(c & 15) - 1]
return enc
def b24decode(data):
dec = b''
hi = -1
for c in data:
if hi < 0:
hi = CHARMAP.index(byte... |
amd = [
{
"Codename": "Tahiti",
"IDs": [
{ "Vendor": "0x1002", "Device": "0x6780" },
{ "Vendor": "0x1002", "Device": "0x6784" },
{ "Vendor": "0x1002", "Device": "0x6788" },
{ "Vendor": "0x1002", "Device": "0x678a" },
{ "Vendor": "0x1002", "Device": "0x6790" },
{ "Vendor": "... | amd = [{'Codename': 'Tahiti', 'IDs': [{'Vendor': '0x1002', 'Device': '0x6780'}, {'Vendor': '0x1002', 'Device': '0x6784'}, {'Vendor': '0x1002', 'Device': '0x6788'}, {'Vendor': '0x1002', 'Device': '0x678a'}, {'Vendor': '0x1002', 'Device': '0x6790'}, {'Vendor': '0x1002', 'Device': '0x6791'}, {'Vendor': '0x1002', 'Device':... |
# %%
#######################################
def scapypayload_joinall(packet_list: scapy.plist.PacketList):
allpayloads_onestring = b''.join([ p.load for p in packet_list if p.haslayer(Raw) ])
return allpayloads_onestring
| def scapypayload_joinall(packet_list: scapy.plist.PacketList):
allpayloads_onestring = b''.join([p.load for p in packet_list if p.haslayer(Raw)])
return allpayloads_onestring |
class tile:
def __init__(self) -> None:
self.owner = None
self.population = None
class board:
def __init__(self,size) -> None:
self.size = size
class game:
def __init__(self,players) -> None:
self.players = players
self.playercount = len(players)
def newGame(se... | class Tile:
def __init__(self) -> None:
self.owner = None
self.population = None
class Board:
def __init__(self, size) -> None:
self.size = size
class Game:
def __init__(self, players) -> None:
self.players = players
self.playercount = len(players)
def new_g... |
arr1 = [-12, 11, -13, -5, 6, -7, 5, -3, -6]
arr2 = [1, 2, -4, -5, 2, -7, 3, 2, -6, -8, -9, 3, 2, 1]
def moveNegativeInt(arr):
for i in arr:
if i < 0:
temp = i
arr.remove(i)
arr.insert(0, temp)
return arr
print(moveNegativeInt(arr1))
print(moveNegativeInt(arr2))
| arr1 = [-12, 11, -13, -5, 6, -7, 5, -3, -6]
arr2 = [1, 2, -4, -5, 2, -7, 3, 2, -6, -8, -9, 3, 2, 1]
def move_negative_int(arr):
for i in arr:
if i < 0:
temp = i
arr.remove(i)
arr.insert(0, temp)
return arr
print(move_negative_int(arr1))
print(move_negative_int(arr2)) |
s = input()
l = len(s)
r = 'AWH'
# just repeat Os bc valid, ignore other rules
print(r + 'O' * l)
| s = input()
l = len(s)
r = 'AWH'
print(r + 'O' * l) |
WOQL_CONCAT_JSON = {
"@type": "Concatenate",
"list": {"@type" : "DataValue",
"list" : [
{"@type": "DataValue", "variable": "Duration"},
{
"@type": "DataValue",
"data": {"@type": "xsd:string", "@value": " yo "},
... | woql_concat_json = {'@type': 'Concatenate', 'list': {'@type': 'DataValue', 'list': [{'@type': 'DataValue', 'variable': 'Duration'}, {'@type': 'DataValue', 'data': {'@type': 'xsd:string', '@value': ' yo '}}, {'@type': 'DataValue', 'variable': 'Duration_Cast'}]}, 'result': {'@type': 'DataValue', 'variable': 'x'}} |
class GeneralizationSet:
name = ""
id = ""
attributes = []
def __init__(self, name, gs_id, attributes):
self.name = name
self.id = gs_id
self.attributes = attributes
def __str__(self):
return f'id:{self.id} name: {self.name} attributes: {self.attributes}'
| class Generalizationset:
name = ''
id = ''
attributes = []
def __init__(self, name, gs_id, attributes):
self.name = name
self.id = gs_id
self.attributes = attributes
def __str__(self):
return f'id:{self.id} name: {self.name} attributes: {self.attributes}' |
#
# @lc app=leetcode id=32 lang=python3
#
# [32] Longest Valid Parentheses
#
# @lc code=start
class Solution:
def longestValidParentheses(self, s: str) -> int:
max_length = 0
left_count = right_count = 0
for i in range(len(s)): # left to right scan
if s[i] == '(':
... | class Solution:
def longest_valid_parentheses(self, s: str) -> int:
max_length = 0
left_count = right_count = 0
for i in range(len(s)):
if s[i] == '(':
left_count += 1
elif s[i] == ')':
right_count += 1
if left_count == rig... |
# 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 sumNumbers(self, root: TreeNode) -> int:
if root == None:
return 0
else:
... | class Solution:
def sum_numbers(self, root: TreeNode) -> int:
if root == None:
return 0
else:
return sum([int(i) for i in self.travelTree(root)])
def travel_tree(self, root):
if root.left == None and root.right == None:
return [str(root.val)]
... |
###########################################################################
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/... | dcm__field__lookup = {'Video_Unmutes': 'INTEGER', 'Zip_Postal_Code': 'INTEGER', 'Path_Length': 'INTEGER', 'Billable_Impressions': 'FLOAT', 'Active_View_Of_Completed_Impressions_Audible_And_Visible': 'FLOAT', 'Measurable_Impressions_For_Audio': 'INTEGER', 'Average_Interaction_Time': 'FLOAT', 'Invalid_Impressions': 'FLOA... |
a = 1.123456
b = 10
c = -30
d = 34
e = 123.456
f = 19892122
# form 0
s = "b=%i" % b
print(s)
# form 1
s = "b,c,d=%i+%i+%i" % (b,c,d)
print(s)
# form 2
s = "b=%(b)i and c=%(c)i and d=%(d)i" % { 'b':b,'c':c,'d':d }
print(s)
# width,flags
s = "e=%020i e=%+i e=%20i e=%-20i (e=%- 20i)" % (e,e,e,e,e)
print(s)
| a = 1.123456
b = 10
c = -30
d = 34
e = 123.456
f = 19892122
s = 'b=%i' % b
print(s)
s = 'b,c,d=%i+%i+%i' % (b, c, d)
print(s)
s = 'b=%(b)i and c=%(c)i and d=%(d)i' % {'b': b, 'c': c, 'd': d}
print(s)
s = 'e=%020i e=%+i e=%20i e=%-20i (e=%- 20i)' % (e, e, e, e, e)
print(s) |
registry = []
def register(cls, bench_type=None, bench_params=None):
registry.append((cls, bench_type, bench_params))
return cls
| registry = []
def register(cls, bench_type=None, bench_params=None):
registry.append((cls, bench_type, bench_params))
return cls |
#
# PySNMP MIB module ASCEND-MIBUDS3NET-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBUDS3NET-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:12:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration')
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union,... |
vermelho = '\033[31m'
verde = '\033[32m'
azul = '\033[34m'
#-----------------------------
ciano = '\033[36m'
magenta = '\033[35m'
amarelo = '\033[33m'
preto = '\033[30m'
branco = '\033[37m'
#-----------------------------
original = '\033[0;0m'
negrito = '\033[1m'
reverso = '\033[2m'
#-----------------------------
fu... | vermelho = '\x1b[31m'
verde = '\x1b[32m'
azul = '\x1b[34m'
ciano = '\x1b[36m'
magenta = '\x1b[35m'
amarelo = '\x1b[33m'
preto = '\x1b[30m'
branco = '\x1b[37m'
original = '\x1b[0;0m'
negrito = '\x1b[1m'
reverso = '\x1b[2m'
fundo_preto = '\x1b[40m'
fundo_vermelho = '\x1b[41m'
fundo_verde = '\x1b[42m'
fundo_amarelo = '\x1... |
class AppCredentials(object):
def __init__(self, client_id, client_secret, redirect_uri):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
| class Appcredentials(object):
def __init__(self, client_id, client_secret, redirect_uri):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri |
s=str(input())
n1,n2=[int(e) for e in input().split()]
count=0
count2=1
for i in range(n1):
print(s[i],end="")
for i in range(n2-n1+1):
print(s[n2-count],end="")
count+=1
for i in range(len(s)-n2-1):
print(s[n2+count2],end="")
count2+=1
| s = str(input())
(n1, n2) = [int(e) for e in input().split()]
count = 0
count2 = 1
for i in range(n1):
print(s[i], end='')
for i in range(n2 - n1 + 1):
print(s[n2 - count], end='')
count += 1
for i in range(len(s) - n2 - 1):
print(s[n2 + count2], end='')
count2 += 1 |
#
# PySNMP MIB module DLGHWINF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DLGHWINF-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:47:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_intersection, single_value_constraint, constraints_union) ... |
class Pricing(object):
def __init__(self, location, event):
self.location = location
self.event = event
def setlocation(self, location):
self.location = location
def getprice(self):
return self.location.getprice()
def getquantity(self):
return self.location.getqua... | class Pricing(object):
def __init__(self, location, event):
self.location = location
self.event = event
def setlocation(self, location):
self.location = location
def getprice(self):
return self.location.getprice()
def getquantity(self):
return self.location.ge... |
class Solution(object):
def sub_two(self, a, b):
if a is None or b is None:
raise TypeError('a or b cannot be None')
result = a ^ b
borrow = (~a & b) << 1
if borrow != 0:
return self.sub_two(result, borrow)
return result | class Solution(object):
def sub_two(self, a, b):
if a is None or b is None:
raise type_error('a or b cannot be None')
result = a ^ b
borrow = (~a & b) << 1
if borrow != 0:
return self.sub_two(result, borrow)
return result |
# write a function that accepts a name as input and
# prints out "Hello {name}!"
def greeting(name):
print("Hello " + name + "!")
greeting("Alfred") | def greeting(name):
print('Hello ' + name + '!')
greeting('Alfred') |
class MetaGetter:
def __init__(self, context):
self.__context = context
def render_width_px(self):
original_width = self.__context.scene.render.resolution_x
return int(original_width * self.__render_size_fraction())
def render_height_px(self):
original_height = self.__context.scene.render.resolution_y
r... | class Metagetter:
def __init__(self, context):
self.__context = context
def render_width_px(self):
original_width = self.__context.scene.render.resolution_x
return int(original_width * self.__render_size_fraction())
def render_height_px(self):
original_height = self.__cont... |
# 024 - Write a Python program to test whether a passed letter is a vowel or not.
def vowelLetter(pLetter):
return pLetter.upper() in 'AEIOU'
print(vowelLetter('A'))
print(vowelLetter('B')) | def vowel_letter(pLetter):
return pLetter.upper() in 'AEIOU'
print(vowel_letter('A'))
print(vowel_letter('B')) |
class IntervalStats:
def __init__(self) -> None:
self.interval_duration = 0.0
self.rtt_ratio = 0.0
self.marked_lost_bytes = 0
self.loss_rate = 0
self.actual_sending_rate_mbps = 0
self.ack_rate_mbps = 0
self.avg_rtt = 0.0
self.rtt_dev = 0.0
sel... | class Intervalstats:
def __init__(self) -> None:
self.interval_duration = 0.0
self.rtt_ratio = 0.0
self.marked_lost_bytes = 0
self.loss_rate = 0
self.actual_sending_rate_mbps = 0
self.ack_rate_mbps = 0
self.avg_rtt = 0.0
self.rtt_dev = 0.0
sel... |
# Python3 Total Ways to arrange coins {1, 3, 5} to Sum Upto N
# Using Recursion
def Arrangement(N):
if N < 0:
return 0
if N == 0:
return 1
return Arrangement(N-1) + Arrangement(N-3) + Arrangement(N-5)
# Using DP
dp = [None for _ in range(10001)]
def Arrangement_DP(n):
if n < 0:
return 0
if n == 0:
retur... | def arrangement(N):
if N < 0:
return 0
if N == 0:
return 1
return arrangement(N - 1) + arrangement(N - 3) + arrangement(N - 5)
dp = [None for _ in range(10001)]
def arrangement_dp(n):
if n < 0:
return 0
if n == 0:
return 1
if dp[n]:
return dp[n]
dp[n]... |
def ex2():
rs = np.random.RandomState(112)
x=np.linspace(0,10,11)
y=np.linspace(0,10,11)
X,Y = np.meshgrid(x,y)
X=X.flatten()
Y=Y.flatten()
weights=np.random.random(len(X))
plt.hist2d(X,Y,weights=weights); #The semicolon here avoids that Jupyter shows the resulting arrays
| def ex2():
rs = np.random.RandomState(112)
x = np.linspace(0, 10, 11)
y = np.linspace(0, 10, 11)
(x, y) = np.meshgrid(x, y)
x = X.flatten()
y = Y.flatten()
weights = np.random.random(len(X))
plt.hist2d(X, Y, weights=weights) |
def change_data(x):
if x < 0 or x >255:
return None
elif 200 <= x <=255:
return int(round((x - 200) * 3 / 11.0 + 85, 0))
elif 0 <= x <=130:
return int(round(x * 6 / 13.0, 0))
else:
return int(round((x - 131) * 23 / 68.0 + 61, 0))
if __name__ == '__main__':
print('-1... | def change_data(x):
if x < 0 or x > 255:
return None
elif 200 <= x <= 255:
return int(round((x - 200) * 3 / 11.0 + 85, 0))
elif 0 <= x <= 130:
return int(round(x * 6 / 13.0, 0))
else:
return int(round((x - 131) * 23 / 68.0 + 61, 0))
if __name__ == '__main__':
print('-... |
n, x = map(int, input().split())
s = str(input())
for e in s:
if e == "o":
x += 1
else:
x -= 1
if x < 0:
x = 0
print(x)
| (n, x) = map(int, input().split())
s = str(input())
for e in s:
if e == 'o':
x += 1
else:
x -= 1
if x < 0:
x = 0
print(x) |
cont = soma = 0
while True:
nota = float(input())
if nota < 0 or nota > 10:
print('nota invalida')
else:
soma += nota
cont += 1
if cont == 2:
break
print('media = {}'.format(soma / cont)) | cont = soma = 0
while True:
nota = float(input())
if nota < 0 or nota > 10:
print('nota invalida')
else:
soma += nota
cont += 1
if cont == 2:
break
print('media = {}'.format(soma / cont)) |
src = Split('''
awss.c
enrollee.c
sha256.c
zconfig_utils.c
zconfig_ieee80211.c
wifimgr.c
ywss_utils.c
zconfig_ut_test.c
registrar.c
zconfig_protocol.c
zconfig_vendor_common.c
''')
component = aos_component('ywss', src)
component.add_macros('DEBUG')
... | src = split('\n awss.c \n enrollee.c \n sha256.c \n zconfig_utils.c \n zconfig_ieee80211.c \n wifimgr.c \n ywss_utils.c\n zconfig_ut_test.c \n registrar.c \n zconfig_protocol.c \n zconfig_vendor_common.c\n')
component = aos_component('ywss', src)
component.add_macros('DEBUG')
component.... |
class Settings:
base_url = "https://compass.scouts.org.uk"
date_format = "%d %B %Y" # dd Month YYYY
org_number = 10000001
total_requests = 0
wcf_json_endpoint = "/JSon.svc" # Windows communication foundation JSON service endpoint
web_service_path = base_url + wcf_json_endpoint
| class Settings:
base_url = 'https://compass.scouts.org.uk'
date_format = '%d %B %Y'
org_number = 10000001
total_requests = 0
wcf_json_endpoint = '/JSon.svc'
web_service_path = base_url + wcf_json_endpoint |
def say_hello():
return "hello"
| def say_hello():
return 'hello' |
def searchRange(nums, target):
start, end = -1, -1
lo, hi = 0, len(nums)-1
while lo <= hi:
mid = (lo+hi)//2
if nums[mid] == target and (mid == 0 or nums[mid-1] != target):
start = mid
break
elif nums[mid] < target:
lo = mid+1
... | def search_range(nums, target):
(start, end) = (-1, -1)
(lo, hi) = (0, len(nums) - 1)
while lo <= hi:
mid = (lo + hi) // 2
if nums[mid] == target and (mid == 0 or nums[mid - 1] != target):
start = mid
break
elif nums[mid] < target:
lo = mid + 1
... |
start,end=input().split()
edges=[("ab",1),("ac",1),("be",3),("cd",1),("de",1),("df",2),("eg",1),("fg",1),("ba",1),("ca",1),("eb",3),("dc",1),("ed",1),("fd",2),("ge",1),("gf",1)]
paths=[(start,0)]
while True:
new_paths=paths
for (path,T) in paths:
for (edge,t) in edges:
if path[-1]==edge[0] a... | (start, end) = input().split()
edges = [('ab', 1), ('ac', 1), ('be', 3), ('cd', 1), ('de', 1), ('df', 2), ('eg', 1), ('fg', 1), ('ba', 1), ('ca', 1), ('eb', 3), ('dc', 1), ('ed', 1), ('fd', 2), ('ge', 1), ('gf', 1)]
paths = [(start, 0)]
while True:
new_paths = paths
for (path, t) in paths:
for (edge, t)... |
# OpenWeatherMap API Key
weather_api_key = "972fc242a771ca44611f48d634a9e967"
# Google API Key
g_key = "AIzaSyCWD-Z7WINc53d-5orJ46Zg3qVZN1UK0ho"
| weather_api_key = '972fc242a771ca44611f48d634a9e967'
g_key = 'AIzaSyCWD-Z7WINc53d-5orJ46Zg3qVZN1UK0ho' |
class ListNode:
def __init__(self,x):
self.val = x
self.next = None
class Solution:
def hasCycle(self,head):
# type head: ListNode
# rtype: bool
fast, slow = head, head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def has_cycle(self, head):
(fast, slow) = (head, head)
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
ret... |
class Solution:
# @param A, a list of integer
# @return an integer
def singleNumber(self, A):
num = A[0]
for number in A[ 1 : ]:
num = num ^ number
return num | class Solution:
def single_number(self, A):
num = A[0]
for number in A[1:]:
num = num ^ number
return num |
def count_3_in_time(n):
# 00:00:00 ~ n:59:59
count = 0
for hrs in range(0, n + 1):
for min in range(0, 60):
for sec in range(0, 60):
if -1 != str(hrs).find('3') or -1 != str(min).find('3') or -1 != str(sec).find('3'):
count += 1
return count
de... | def count_3_in_time(n):
count = 0
for hrs in range(0, n + 1):
for min in range(0, 60):
for sec in range(0, 60):
if -1 != str(hrs).find('3') or -1 != str(min).find('3') or -1 != str(sec).find('3'):
count += 1
return count
def main():
n = int(input(... |
def last_index(pattern):
wave_list = pattern.wave_list
number_of_elements = len(wave_list)
return number_of_elements
| def last_index(pattern):
wave_list = pattern.wave_list
number_of_elements = len(wave_list)
return number_of_elements |
def code(st, syntax = ""): return f"```{syntax}\n{st}```"
def md(st): return code(st, "md")
def diff(st): return code(st, "diff")
| def code(st, syntax=''):
return f'```{syntax}\n{st}```'
def md(st):
return code(st, 'md')
def diff(st):
return code(st, 'diff') |
def maxSum(a, b, k, n):
a.sort()
b.sort()
i = 0
j = n - 1
while i < k:
if (a[i] < b[j]):
a[i], b[j] = b[j], a[i]
else:
break
i += 1
j -= 1
sum = 0
for i in range (n):
sum += a[i]
return(sum)
... | def max_sum(a, b, k, n):
a.sort()
b.sort()
i = 0
j = n - 1
while i < k:
if a[i] < b[j]:
(a[i], b[j]) = (b[j], a[i])
else:
break
i += 1
j -= 1
sum = 0
for i in range(n):
sum += a[i]
return sum
tc = int(input())
for i in range... |
def fib(n):
first=0
second=1
overall=0
if n==0:
return 0
elif n==1:
return 1
else:
for i in range(1,n):
overall=second+first
first=second
second=overall
return overall
def productFib(num):
n=1
append_array=[]
while T... | def fib(n):
first = 0
second = 1
overall = 0
if n == 0:
return 0
elif n == 1:
return 1
else:
for i in range(1, n):
overall = second + first
first = second
second = overall
return overall
def product_fib(num):
n = 1
appe... |
number = 600851475143
def isPrime(n):
for i in range(2, n):
if n % i == 0 and i != n:
return False
return True
def LargestPrimeFactor(n):
_n, lpf = n, 0
for i in range(2, n):
if isPrime(i) and n % i == 0:
_n, lpf = _n/i, i
print(i, end=', ')
... | number = 600851475143
def is_prime(n):
for i in range(2, n):
if n % i == 0 and i != n:
return False
return True
def largest_prime_factor(n):
(_n, lpf) = (n, 0)
for i in range(2, n):
if is_prime(i) and n % i == 0:
(_n, lpf) = (_n / i, i)
print(i, end=... |
# Title : TODO
# Objective : TODO
# Created by: Wenzurk
# Created on: 2018/2/5
# for value in range(1,5):
# print(value)
# for value in range(1,6):
# print(value)
numbers = list(range(1,6))
print(numbers) | numbers = list(range(1, 6))
print(numbers) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : Jinyuan Sun
# @Time : 2022/3/31 6:17 PM
# @File : aa_index.py
# @annotation : define properties of amino acids
ALPHABET = "QWERTYIPASDFGHKLCVNM"
hydrophobic_index = {
'R': -0.9,
'K': -0.889,
'D': -0.767,
'E': -0.696,
'N': -0.... | alphabet = 'QWERTYIPASDFGHKLCVNM'
hydrophobic_index = {'R': -0.9, 'K': -0.889, 'D': -0.767, 'E': -0.696, 'N': -0.674, 'Q': -0.464, 'S': -0.364, 'G': -0.342, 'H': -0.271, 'T': -0.199, 'A': -0.171, 'P': 0.055, 'Y': 0.188, 'V': 0.331, 'M': 0.337, 'C': 0.508, 'L': 0.596, 'F': 0.646, 'I': 0.652, 'W': 0.9}
volume_index = {'G... |
class DefaultTokenizer:
def __init__(self, prefixes, suffixes, infixes, exceptions):
self.prefixes = prefixes
self.suffixes = suffixes
self.infixes = infixes
self.exceptions = exceptions
def __call__(self, text: str):
return text.split(" ")
| class Defaulttokenizer:
def __init__(self, prefixes, suffixes, infixes, exceptions):
self.prefixes = prefixes
self.suffixes = suffixes
self.infixes = infixes
self.exceptions = exceptions
def __call__(self, text: str):
return text.split(' ') |
for i in range(1, 21):
if i % 3 == 0:
print("Fizz")
else:
print(i)
| for i in range(1, 21):
if i % 3 == 0:
print('Fizz')
else:
print(i) |
cutoff = 20
decision_cutoff = .25
model_path = 'ml/overwatch_messages.model'
vectorizer_path = 'ml/overwatch_messages.vectorizer'
| cutoff = 20
decision_cutoff = 0.25
model_path = 'ml/overwatch_messages.model'
vectorizer_path = 'ml/overwatch_messages.vectorizer' |
#
# PySNMP MIB module Juniper-SUBSCRIBER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-SUBSCRIBER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:01:13 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, constraints_union, value_range_constraint) ... |
#input
# 69 237 245 22 97 105 68 243 232 209 177 72 161 199 237 218 206 122 209 100 79 226 195 202 160 238 106 99 118 57 68 68 53 65 240 230 160 99 208 64 118 210 232 244 119 178 69 224 146 87 104 237 232 204 227 75 65 162 90 75 64 133 75 225 238 160 204 54 14 196 121 78 72 240 89 237 145 108 244 179 102 54 32 160 53 8... | def decode(seq):
if len(seq) == 8:
seq = '0b' + seq[1:]
char = chr(int(seq, 2))
return char
encoded_sequence = [int(x) for x in input().split()]
for c in encoded_sequence:
binc = bin(c)[2:]
num_of_bits = binc.count('1')
if num_of_bits % 2 == 0:
decoded_character = decode(binc)
... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
# root and current node
cur = ro... | class Solution:
def merge_two_lists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
cur = root = list_node(0)
while list1 and list2:
if list1.val <= list2.val:
item = list1.val
list1 = list1.next
elif list1.v... |
def proc(command, message):
return {
"data": {
"text": "Your command was not recognised. Type 'help' to read the list of all available commands."
},
"response_required": True
}
| def proc(command, message):
return {'data': {'text': "Your command was not recognised. Type 'help' to read the list of all available commands."}, 'response_required': True} |
A, B, C = input().split()
A = int(A)
B = int(B)
C = int(C)
if(A < B and A < C and B < C):
a = C
b = B
c = A
elif(A < B and A < C and C < B):
a = B
b = C
c = A
elif(B < A and B < C and A < C):
a = C
b = A
c = B
elif(B < A and B < C and C < A):
a = A
b = C
c = B
e... | (a, b, c) = input().split()
a = int(A)
b = int(B)
c = int(C)
if A < B and A < C and (B < C):
a = C
b = B
c = A
elif A < B and A < C and (C < B):
a = B
b = C
c = A
elif B < A and B < C and (A < C):
a = C
b = A
c = B
elif B < A and B < C and (C < A):
a = A
b = C
c = B
elif ... |
for _ in range(int(input())):
s = input()
f,l,r = 0,0,0
for i in range(len(s) - 1):
if(s[i] == s[i + 1]):
f = 1
l = i
break
for i in range(len(s) - 1,0,-1):
if(s[i] == s[i - 1]):
# print(i)
f = 1
r = i
break
if s[0] == s[len(s) - 1]: f = 1
if f == 0:print('yes')
elif(len(s) % 2 != 0): pr... | for _ in range(int(input())):
s = input()
(f, l, r) = (0, 0, 0)
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
f = 1
l = i
break
for i in range(len(s) - 1, 0, -1):
if s[i] == s[i - 1]:
f = 1
r = i
break
if s[0]... |
def solution(n, delivery):
answer = ''
ans_list = []
for i in range(n):
ans_list.append('?')
for de in delivery:
if(de[2] == 1):
ans_list[de[0] -1] = 'O'
ans_list[de[1] -1] = 'O'
for de in delivery:
if(de[2] == 0):
if(ans_list[de[0] -1 ] =... | def solution(n, delivery):
answer = ''
ans_list = []
for i in range(n):
ans_list.append('?')
for de in delivery:
if de[2] == 1:
ans_list[de[0] - 1] = 'O'
ans_list[de[1] - 1] = 'O'
for de in delivery:
if de[2] == 0:
if ans_list[de[0] - 1] ==... |
# def summation(num):
# pos = 0
# while (num > 0):
# pos += num
# print(pos)
# num -= 1
# print(num)
# return pos
# # Code here
def summation(num):
pos = 0
for num in range(1,num + 1):
pos += num
print(num)
return p... | def summation(num):
pos = 0
for num in range(1, num + 1):
pos += num
print(num)
return pos
num = int(input('Write number = '))
print(summation(num)) |
def somar(a=0,b=0,c=0):
s=a+b+c
return s
def main():
#print(somar(3,4,5))
r1 = somar(3,4,5)
r2 = somar(1,7)
r3 = somar(4)
print('RESULTADOS: ',r1,r2,r3)
main()
| def somar(a=0, b=0, c=0):
s = a + b + c
return s
def main():
r1 = somar(3, 4, 5)
r2 = somar(1, 7)
r3 = somar(4)
print('RESULTADOS: ', r1, r2, r3)
main() |
def tf_io_copts():
return (
[
"-std=c++11",
"-DNDEBUG",
] +
select({
"@bazel_tools//src/conditions:darwin": [],
"//conditions:default": ["-pthread"]
})
)
| def tf_io_copts():
return ['-std=c++11', '-DNDEBUG'] + select({'@bazel_tools//src/conditions:darwin': [], '//conditions:default': ['-pthread']}) |
def nb_post_fix(rtl_log_f,rtl_log,nb_log):
''' Replaces non-blocking load results in rd of trace log.
Sees time/CycleCnt at which non-block load is written back to gpr,
checks from that time/CycleCnt backwards, where this gpr was written in trace log,
replaces the result in rd (also load) at that instru... | def nb_post_fix(rtl_log_f, rtl_log, nb_log):
""" Replaces non-blocking load results in rd of trace log.
Sees time/CycleCnt at which non-block load is written back to gpr,
checks from that time/CycleCnt backwards, where this gpr was written in trace log,
replaces the result in rd (also load) at that inst... |
# a place to hold event type constants used among many data models, rules, or policies
ADMIN_ROLE_ASSIGNED = "admin_role_assigned"
FAILED_LOGIN = "failed_login"
MFA_DISABLED = "mfa_disabled"
SUCCESSFUL_LOGIN = "successful_login"
SUCCESSFUL_LOGOUT = "successful_logout"
USER_ACCOUNT_CREATED = "user_account_created"
# ACC... | admin_role_assigned = 'admin_role_assigned'
failed_login = 'failed_login'
mfa_disabled = 'mfa_disabled'
successful_login = 'successful_login'
successful_logout = 'successful_logout'
user_account_created = 'user_account_created'
account_created = 'account_created'
user_account_deleted = 'user_account_deleted'
user_accou... |
#
# PySNMP MIB module WebGraph-AnalogIO-57662-US-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WebGraph-AnalogIO-57662-US-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:32:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
#!/usr/bin/env python
PART1SOL = 388611
PART2SOL = 27763113
# Right on the first try!
def part1(x):
count = 0
loc = 0
while True:
try:
dat = x[loc]
except IndexError:
return count
count += 1
x[loc] += 1
loc += dat
# 137 too low
# 169 too ... | part1_sol = 388611
part2_sol = 27763113
def part1(x):
count = 0
loc = 0
while True:
try:
dat = x[loc]
except IndexError:
return count
count += 1
x[loc] += 1
loc += dat
def part2(x):
count = 0
loc = 0
while True:
try:
... |
'''
This problem was recently asked by AirBNB:
Given a sorted array, A, with possibly duplicated elements, find the indices of the first and last occurrences of a target element, x. Return -1 if the target is not found.
Example:
Input: A = [1,3,3,5,7,8,9,9,9,15], target = 9
Output: [6,8]
Input: A = [100, 150, 150, 1... | """
This problem was recently asked by AirBNB:
Given a sorted array, A, with possibly duplicated elements, find the indices of the first and last occurrences of a target element, x. Return -1 if the target is not found.
Example:
Input: A = [1,3,3,5,7,8,9,9,9,15], target = 9
Output: [6,8]
Input: A = [100, 150, 150, 1... |
def foo(a, b):
return a * b
foo(1, 2) ## OK
foo(1) ## error: wrong number of arguments
| def foo(a, b):
return a * b
foo(1, 2)
foo(1) |
# 7. Sa se scrie o functie care primeste ca parametri un numar x default egal cu 1,
# un numar variabil de siruri de caractere
# si un flag boolean setat default pe True.
# Pentru fiecare sir de caractere, sa se genereze o lista care sa contina caracterele care au codul ASCII divizibil cu x
# in caz ca flag-ul este... | def generate_by_condition(x=1, flag=True, *strings):
generated_lists = []
for string in strings:
if flag:
generated_lists.append([c for c in string if ord(c) % x == 0])
else:
generated_lists.append([c for c in string if ord(c) % x != 0])
return generated_lists
print(g... |
while True:
print("1. Addition")
print("2. Substraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")
choice = input("Your choice: ")
print()
if choice == "1":
first_addend = float(input("First addend: "))
second_addend = float(input("Second adde... | while True:
print('1. Addition')
print('2. Substraction')
print('3. Multiplication')
print('4. Division')
print('5. Exit')
choice = input('Your choice: ')
print()
if choice == '1':
first_addend = float(input('First addend: '))
second_addend = float(input('Second addend: '... |
class A:
def foo(self):
print('in A foo')
def hello(self):
print('A hello')
class B:
def bar(self):
print('in B bar')
def hello(self):
print('B hello')
class C(B, A):
pass
# def hello(self):
# print('C hello')
if __name__ == '__main__':
c = C()
... | class A:
def foo(self):
print('in A foo')
def hello(self):
print('A hello')
class B:
def bar(self):
print('in B bar')
def hello(self):
print('B hello')
class C(B, A):
pass
if __name__ == '__main__':
c = c()
c.foo()
c.bar()
c.hello() |
print(1 == 2 and 1 == 1) # False
print(1 == 1 and 2 == 2) # True
print(5 > 2 and True) # True
print(False and True)
print(False and False)
print(True and True) | print(1 == 2 and 1 == 1)
print(1 == 1 and 2 == 2)
print(5 > 2 and True)
print(False and True)
print(False and False)
print(True and True) |
for _ in range(int(input())):
n=int(input())
s=list(input())
ans=""
for i in s:
if i == "U":
ans+="D"
elif i=="D":
ans+="U"
else:
ans+=i
print(ans) | for _ in range(int(input())):
n = int(input())
s = list(input())
ans = ''
for i in s:
if i == 'U':
ans += 'D'
elif i == 'D':
ans += 'U'
else:
ans += i
print(ans) |
test_board_1 = [
[None, 6, None, None, 4, None, 7, None, None,],
[None, 2, None, 1, None, None, None, None, None],
[8, None, 5, 2, None, 6, None, 9, 4],
[None, None, 1, None, 9, 3, None, None, 7],
[4, 3, None, 5, None, 8, None, 2, 9],
[5, None, None, 4, 7, Non... | test_board_1 = [[None, 6, None, None, 4, None, 7, None, None], [None, 2, None, 1, None, None, None, None, None], [8, None, 5, 2, None, 6, None, 9, 4], [None, None, 1, None, 9, 3, None, None, 7], [4, 3, None, 5, None, 8, None, 2, 9], [5, None, None, 4, 7, None, 8, None, None], [6, 5, None, 7, None, 4, 3, None, 8], [None... |
a = 0
while(1):
a = a+1
if(a%15 == 0): print("FIZZ BUZZ")
elif(a%5 == 0): print("BUZZ")
elif(a%3 == 0): print("FIZZ")
else: print(a)
| a = 0
while 1:
a = a + 1
if a % 15 == 0:
print('FIZZ BUZZ')
elif a % 5 == 0:
print('BUZZ')
elif a % 3 == 0:
print('FIZZ')
else:
print(a) |
class Config:
BOT_USE = False
BOT_TOKEN = '5022399250:AAH4xUY7OgDGHyUlp5_J9DZMhNU8NXgeyh8' # from @botfather
APP_ID = 18454593 # from https://my.telegram.org/apps
API_HASH = 'b536EkRHLyviZMtSjodB4gByQJwyYxPmBE1x' # from https:... | class Config:
bot_use = False
bot_token = '5022399250:AAH4xUY7OgDGHyUlp5_J9DZMhNU8NXgeyh8'
app_id = 18454593
api_hash = 'b536EkRHLyviZMtSjodB4gByQJwyYxPmBE1x'
auth_users = [1337171491] |
class Node(object):
def __init__(self, value=None, pointer=None):
self.value = value
self.pointer = pointer
class Stack(object):
def __init__(self):
self.head = None
def isEmpty(self):
return not bool(self.head)
def push(self, item):
self.head = Node(item, self.h... | class Node(object):
def __init__(self, value=None, pointer=None):
self.value = value
self.pointer = pointer
class Stack(object):
def __init__(self):
self.head = None
def is_empty(self):
return not bool(self.head)
def push(self, item):
self.head = node(item, s... |
class Solution:
def ladderLength(self, beginWord, endWord, wordList):
wordList.append(beginWord)
m, n = len(wordList[0]), len(wordList)
words_inverse = {w:i for i, w in enumerate(wordList)}
words_graph = defaultdict(set)
alphabet = "abcdefghijklmnopqrstuvwxyz"
... | class Solution:
def ladder_length(self, beginWord, endWord, wordList):
wordList.append(beginWord)
(m, n) = (len(wordList[0]), len(wordList))
words_inverse = {w: i for (i, w) in enumerate(wordList)}
words_graph = defaultdict(set)
alphabet = 'abcdefghijklmnopqrstuvwxyz'
... |
DATA = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": { "name": "Afghanistan" },
"geometry": {
"type": "Polygon",
"coordinates": [
[
[61.210817, 35.650072],
... | data = {'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {'name': 'Afghanistan'}, 'geometry': {'type': 'Polygon', 'coordinates': [[[61.210817, 35.650072], [62.230651, 35.270664], [62.984662, 35.404041], [63.193538, 35.857166], [63.982896, 36.007957], [64.546479, 36.312073], [64.746105, 37.111... |
m, n = map(int, input().split())
d = [1]+[0]*99
for i in range(n):
d[i+1]+=d[i]
d[i+m]=d[i]
print (d[n])
| (m, n) = map(int, input().split())
d = [1] + [0] * 99
for i in range(n):
d[i + 1] += d[i]
d[i + m] = d[i]
print(d[n]) |
INVALID_AMOUNT = -2
INVALID_ACTION = -4
TRANSACTION_NOT_FOUND = -6
ORDER_NOT_FOUND = -5
PREPARE = '0'
COMPLETE = '1'
A_LACK_OF_MONEY = '-5017'
A_LACK_OF_MONEY_CODE = -9
AUTHORIZATION_FAIL = 'AUTHORIZATION_FAIL'
AUTHORIZATION_FAIL_CODE = -1
ORDER_FOUND = True
| invalid_amount = -2
invalid_action = -4
transaction_not_found = -6
order_not_found = -5
prepare = '0'
complete = '1'
a_lack_of_money = '-5017'
a_lack_of_money_code = -9
authorization_fail = 'AUTHORIZATION_FAIL'
authorization_fail_code = -1
order_found = True |
def findDecision(obj): #obj[0]: Passanger, obj[1]: Time, obj[2]: Coupon, obj[3]: Gender, obj[4]: Age, obj[5]: Education, obj[6]: Occupation, obj[7]: Bar, obj[8]: Coffeehouse, obj[9]: Restaurant20to50, obj[10]: Direction_same, obj[11]: Distance
# {"feature": "Education", "instances": 127, "metric_value": 0.9989, "depth... | def find_decision(obj):
if obj[5] <= 3:
if obj[6] <= 12.937768545455379:
if obj[2] > 1:
if obj[0] > 0:
if obj[4] > 1:
if obj[3] <= 0:
if obj[9] > -1.0:
if obj[8] <= 3.0:
... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Function to rotate each letter with the specified key
def BasicRotate(letter, key):
# Checks if letter is lowercase
if letter.islower():
# As long as letter is lowercase, key is added
new = ord(letter) + key
... | def basic_rotate(letter, key):
if letter.islower():
new = ord(letter) + key
if new > ord('z'):
new = new - 26
new = chr(new)
else:
new = letter
if letter.isupper():
new = ord(letter) + key
if new > ord('Z'):
new = new - ... |
class Employee:
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = f"{first}.{last}@compani.com"
def fullname(self):
return f"{self.first} {self.last}"
emp1 = Employee("john", "smit", 5000)
emp2 = Employee("Morramed... | class Employee:
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = f'{first}.{last}@compani.com'
def fullname(self):
return f'{self.first} {self.last}'
emp1 = employee('john', 'smit', 5000)
emp2 = employee('Morramed', '... |
def wrap_data_as_list(data):
# Check the type of data
if isinstance(data, list):
# Return the original list
return data
elif isinstance(data, tuple):
# Convert the tuple to the list and return
return list(data)
elif isinstance(data, dict):
# Wrap the data with lis... | def wrap_data_as_list(data):
if isinstance(data, list):
return data
elif isinstance(data, tuple):
return list(data)
elif isinstance(data, dict):
return [data]
else:
raise value_error('Data must be a list, tuple or dict')
def convert_plotly_to_dict(plotly_obj):
try:
... |
def validate_square(n):
if n < 1:
raise ValueError('square must be 1 or greater')
elif n > 64:
raise ValueError('square must be 64 or less')
def on_square(n):
validate_square(n)
return pow(2, n - 1)
def total_after(n):
validate_square(n)
return sum([on_square(i)... | def validate_square(n):
if n < 1:
raise value_error('square must be 1 or greater')
elif n > 64:
raise value_error('square must be 64 or less')
def on_square(n):
validate_square(n)
return pow(2, n - 1)
def total_after(n):
validate_square(n)
return sum([on_square(i) for i in rang... |
class SCREENSHOT:
SC_DATA = b""
def __init__(self):
self.generate()
def generate(self):
obj = io.BytesIO()
im = pyscreenshot.grab()
im.save(obj, format="PNG")
self.SC_DATA = obj.getvalue()
def get_data(self):
return self.SC_DATA | class Screenshot:
sc_data = b''
def __init__(self):
self.generate()
def generate(self):
obj = io.BytesIO()
im = pyscreenshot.grab()
im.save(obj, format='PNG')
self.SC_DATA = obj.getvalue()
def get_data(self):
return self.SC_DATA |
# by Kami Bigdely
# PEP8 - whitespaces and variable names.
# This is a guess game. Guess what number the computer has chosen!
class Pizza:
def __init__ (obj, mybread_type, CHEESE_TYPE, meat_type, pizza_toppings, size):
obj.bread_type= mybread_type
obj.cheese_type = CHEESE_TYPE
obj.meat_type=... | class Pizza:
def __init__(obj, mybread_type, CHEESE_TYPE, meat_type, pizza_toppings, size):
obj.bread_type = mybread_type
obj.cheese_type = CHEESE_TYPE
obj.meat_type = meat_type
obj.toppings = pizza_toppings
obj.size = size
@classmethod
def create_chicago_pizza(clas... |
class SDADriver:
def InitAI(self):
return
def UpdateAI(self,SDAData):
return (0.4, 0.2, 0.5, 1) | class Sdadriver:
def init_ai(self):
return
def update_ai(self, SDAData):
return (0.4, 0.2, 0.5, 1) |
# sorting using custom key
employees = [
{'Name': 'Alan Turing', 'age': 25, 'salary': 10000},
{'Name': 'Sharon Lin', 'age': 30, 'salary': 8000},
{'Name': 'John Hopkins', 'age': 18, 'salary': 1000},
{'Name': 'Mikhail Tal', 'age': 40, 'salary': 15000},
]
# custom functions to get employee info
def get_na... | employees = [{'Name': 'Alan Turing', 'age': 25, 'salary': 10000}, {'Name': 'Sharon Lin', 'age': 30, 'salary': 8000}, {'Name': 'John Hopkins', 'age': 18, 'salary': 1000}, {'Name': 'Mikhail Tal', 'age': 40, 'salary': 15000}]
def get_name(employee):
return employee.get('Name')
def get_age(employee):
return emplo... |
string = "Test String"
key = "4381"
k_o = key[0] + key[1]
k_e = key[2] + key[3]
final_op = ""
for i in range(0 , len(string)):
if(i % 2 == 0):
op = ord(string[i])
print(op)
xor = hex((int(op)) ^ (int(k_o)) )
final_op.join(str(op))
else:
op = ord(string[i])
... | string = 'Test String'
key = '4381'
k_o = key[0] + key[1]
k_e = key[2] + key[3]
final_op = ''
for i in range(0, len(string)):
if i % 2 == 0:
op = ord(string[i])
print(op)
xor = hex(int(op) ^ int(k_o))
final_op.join(str(op))
else:
op = ord(string[i])
xor = hex(int(... |
# -*- coding: utf-8 -*-
'''
@author: Gabriele Girelli
@contact: gigi.ga90@gmail.com
@description: methods for basic nucleic acid sequence management.
'''
# CONSTANTS ====================================================================
AB_DNA = ["ACGTRYKMSWBDHVN", "TGCAYRMKSWVHDBN"]
AB_RNA = ["ACGURYKMSWBDHVN", "UGCA... | """
@author: Gabriele Girelli
@contact: gigi.ga90@gmail.com
@description: methods for basic nucleic acid sequence management.
"""
ab_dna = ['ACGTRYKMSWBDHVN', 'TGCAYRMKSWVHDBN']
ab_rna = ['ACGURYKMSWBDHVN', 'UGCAYRMKSWVHDBN']
def rc(na, t):
"""
Args:
na (string): nucleic acid sequence.
t (strin... |
class Cell:
# default constructor
def __init__(self, value):
self._clicked = False
self._value = value
def get_value(self):
return self._value
def get_clicked(self):
return self._clicked
def set_clicked(self, clicked):
self._clicked = clicked
| class Cell:
def __init__(self, value):
self._clicked = False
self._value = value
def get_value(self):
return self._value
def get_clicked(self):
return self._clicked
def set_clicked(self, clicked):
self._clicked = clicked |
# Finding the smallest number
smallest = None
print('Before')
for value in [9, 24, 12, 57, 6, 32, 2] :
if smallest is None :
smallest = value
elif value < smallest :
smallest = value
print(smallest, value)
print('After', smallest)
| smallest = None
print('Before')
for value in [9, 24, 12, 57, 6, 32, 2]:
if smallest is None:
smallest = value
elif value < smallest:
smallest = value
print(smallest, value)
print('After', smallest) |
aliens=[]
#make 30 green aliens
for y in range(30):
new_alien={'color':'green','points':5,'speed':'slow'}
aliens.append(new_alien)
#show the first 5 aliens
for yy in aliens[:5]:
print(yy)
print('...')
for zzz in aliens[3:9]:
for y in aliens[6:9]:
if y['color']=='green':
y['color']='yellow'
y['s... | aliens = []
for y in range(30):
new_alien = {'color': 'green', 'points': 5, 'speed': 'slow'}
aliens.append(new_alien)
for yy in aliens[:5]:
print(yy)
print('...')
for zzz in aliens[3:9]:
for y in aliens[6:9]:
if y['color'] == 'green':
y['color'] = 'yellow'
y['speed'] = 'm... |
#Result class constants with ANSI colors
ALERT = '\033[91mAlert!\033[0m'
WARNING = '\033[93mWarning\033[0m'
NOTHING = '\033[92mCheck passed\033[0m'
BIG_FILE = 'Big file found'
NOT_PLAIN_TEXT = 'File is not plain text'
MATCH = 'Match'
NOT_MATCH = 'Nothing found'
FILETYPE_NOT_ALLOWED = 'Extension not allowed' | alert = '\x1b[91mAlert!\x1b[0m'
warning = '\x1b[93mWarning\x1b[0m'
nothing = '\x1b[92mCheck passed\x1b[0m'
big_file = 'Big file found'
not_plain_text = 'File is not plain text'
match = 'Match'
not_match = 'Nothing found'
filetype_not_allowed = 'Extension not allowed' |
while 1:
number = input("Type a negabinary number here: ")
try:
number = int(number)
break
except ValueError:
pass
total = 0
loop = 0
for char in str(number)[::-1]:
if char == "1":
total += (-2) ** loop
elif char == "0":
pass
else:
print("You enterned an invalid number")
quit()
loop += 1
print(t... | while 1:
number = input('Type a negabinary number here: ')
try:
number = int(number)
break
except ValueError:
pass
total = 0
loop = 0
for char in str(number)[::-1]:
if char == '1':
total += (-2) ** loop
elif char == '0':
pass
else:
print('You enter... |
class Solution:
def getRow(self, rowIndex: int) -> List[int]:
triangle=[]
for i in range(rowIndex+1):
row=[None for _ in range(i+1)]
row[0],row[-1]=1,1
for j in range(1,len(row)-1):
row[j]=triangle[i-1][j]+triangle[i-1][j-1]
... | class Solution:
def get_row(self, rowIndex: int) -> List[int]:
triangle = []
for i in range(rowIndex + 1):
row = [None for _ in range(i + 1)]
(row[0], row[-1]) = (1, 1)
for j in range(1, len(row) - 1):
row[j] = triangle[i - 1][j] + triangle[i - 1]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.