content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
a = 5
b = 15.00
c = 20.00 + 0j
print("\na = 5:")
print(a)
print(type(a))
print("\nb = 15.00:")
print(b)
print(type(b))
print("\nc = 20.00 + 0j:")
print(c)
print(type(c))
print("\n\nRule: Widen the narrower number, so that both are of same type:")
print("\nAddition:\n")
r = a + b
print("\nr = a + b (int + float):")... | a = 5
b = 15.0
c = 20.0 + 0j
print('\na = 5:')
print(a)
print(type(a))
print('\nb = 15.00:')
print(b)
print(type(b))
print('\nc = 20.00 + 0j:')
print(c)
print(type(c))
print('\n\nRule: Widen the narrower number, so that both are of same type:')
print('\nAddition:\n')
r = a + b
print('\nr = a + b (int + float):')
print(... |
# This program also demonstrates a simple for
# loop that uses a list of strings.
for name in['Winken', 'Blinken', 'Nod']:
print(name); | for name in ['Winken', 'Blinken', 'Nod']:
print(name) |
class Update():
def __init__(self, vid, value):
self.vid = vid
self.value = value
def get_vid(self):
return self.vid
def get_value(self):
return self.value
def __str__(self):
return f"Update[vid={self.vid}, value={self.value}]"
def __repr__(self):
... | class Update:
def __init__(self, vid, value):
self.vid = vid
self.value = value
def get_vid(self):
return self.vid
def get_value(self):
return self.value
def __str__(self):
return f'Update[vid={self.vid}, value={self.value}]'
def __repr__(self):
r... |
# Add a list of servers, each represented by (MAC, IP, weight).
# The weights should sum up to 1.0.
servers = [
("00:00:00:00:00:01", "10.0.0.1", 0.33),
("00:00:00:00:00:02", "10.0.0.2", 0.33),
("00:00:00:00:00:03", "10.0.0.3", 0.34)
]
#For testing, we can use the utility functions in confighelper
#i... | servers = [('00:00:00:00:00:01', '10.0.0.1', 0.33), ('00:00:00:00:00:02', '10.0.0.2', 0.33), ('00:00:00:00:00:03', '10.0.0.3', 0.34)]
virtual_server = ('00:00:00:00:00:4', '10.0.0.4') |
# (C) Copyright 2020 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmenta... | class Boundingbox:
def __init__(self, *, north, west, south, east):
self.north = min(float(north), 90.0)
self.west = float(west)
self.south = max(float(south), -90.0)
self.east = float(east)
if self.north <= self.south:
raise value_error('North (%s) must be great... |
def append(xs, ys):
for y in ys:
xs.insert(len(xs), y)
return xs
def concat(lists):
concat_list = []
for l in lists:
concat_list += l
return concat_list
def filter_clone(function, xs):
filtered_list = []
for x in xs:
if function(x):
filtered_list.inser... | def append(xs, ys):
for y in ys:
xs.insert(len(xs), y)
return xs
def concat(lists):
concat_list = []
for l in lists:
concat_list += l
return concat_list
def filter_clone(function, xs):
filtered_list = []
for x in xs:
if function(x):
filtered_list.insert(... |
class Solution:
def freqAlphabets(self, s: str) -> str:
d = {'1': 'a', '2': 'b', '3': 'c', '4': 'd', '5': 'e', '6': 'f', '7': 'g', '8': 'h', '9': 'i', '10#': 'j',
'11#': 'k', '12#': 'l', '13#': 'm', '14#': 'n', '15#': 'o', '16#': 'p', '17#': 'q', '18#': 'r', '19#': 's',
'20#': 't',... | class Solution:
def freq_alphabets(self, s: str) -> str:
d = {'1': 'a', '2': 'b', '3': 'c', '4': 'd', '5': 'e', '6': 'f', '7': 'g', '8': 'h', '9': 'i', '10#': 'j', '11#': 'k', '12#': 'l', '13#': 'm', '14#': 'n', '15#': 'o', '16#': 'p', '17#': 'q', '18#': 'r', '19#': 's', '20#': 't', '21#': 'u', '22#': 'v',... |
#Variables
bookName = "A hundred years"
pages = 300
pages = 301
#Case sensitive
BookName, Pages = "A hundred years 2", 450
#Constants (UPPERCASE)
PI_CONSTANT = 3.1415
PI_CONSTANT = 3.1416
print(bookName)
print(pages)
print(BookName, Pages)
print(PI_CONSTANT) | book_name = 'A hundred years'
pages = 300
pages = 301
(book_name, pages) = ('A hundred years 2', 450)
pi_constant = 3.1415
pi_constant = 3.1416
print(bookName)
print(pages)
print(BookName, Pages)
print(PI_CONSTANT) |
def calculate_fees_1(n):
'''
This function returns the least amount of money that you will
expect to pay for the n Grab rides that you have taken that month.
Parameters:
- n, a non-negative integer which represents the number of Grab rides that you plan to take in a month.
... | def calculate_fees_1(n):
"""
This function returns the least amount of money that you will
expect to pay for the n Grab rides that you have taken that month.
Parameters:
- n, a non-negative integer which represents the number of Grab rides that you plan to take in a month.
"""
... |
number = int(input("Which number do you want to check? "))
if number%2==0:
print(f"{number} is an Even number")
else:
print(f"{number} is an Odd number") | number = int(input('Which number do you want to check? '))
if number % 2 == 0:
print(f'{number} is an Even number')
else:
print(f'{number} is an Odd number') |
def answer(question, information):
print(information)
print(question)
question = question.lower().split()
maiorCount = 0
retorno = ''
count = None
for i in question:
for j in information:
if i + ' ' in j.lower() :
if count == None : count = 0
... | def answer(question, information):
print(information)
print(question)
question = question.lower().split()
maior_count = 0
retorno = ''
count = None
for i in question:
for j in information:
if i + ' ' in j.lower():
if count == None:
coun... |
l = 10
r = 15
ans = 0
while l <= r:
result = 0
temp = l
while (temp):
result += temp & 1
temp >>= 1
flag = True
i = 2
while i < result:
if (result%i==0):
flag = False
i +=1
if (flag and result > 1):
ans += 1
l +=1
print(ans) | l = 10
r = 15
ans = 0
while l <= r:
result = 0
temp = l
while temp:
result += temp & 1
temp >>= 1
flag = True
i = 2
while i < result:
if result % i == 0:
flag = False
i += 1
if flag and result > 1:
ans += 1
l += 1
print(ans) |
words = ["Mon", "tue", "Web", "Thu", "fri", "sat", "sun"]
def change_words(words, func):
for word in words:
print(func(word))
def sample_func(word):
return word.capitalize()
def sample_func2(word):
return word.lower()
# sample_func = lambda word: word.capitalize()
# change_words(l, sample_f... | words = ['Mon', 'tue', 'Web', 'Thu', 'fri', 'sat', 'sun']
def change_words(words, func):
for word in words:
print(func(word))
def sample_func(word):
return word.capitalize()
def sample_func2(word):
return word.lower()
change_words(words, lambda word: word.capitalize())
change_words(words, lambda ... |
def solution(ar):
if len(ar) == 0:
return 0
d = 1
ar.sort()
for i in range(1, len(ar)):
if ar[i] == ar[i-1]:
continue
else:
d += 1
return d
ar1 = []
ar2 = [1]
ar3 = [1, 5, 8, 9]
ar4 = [2, 2, 2, 2, 3, 1] # Return 3
for i in [ar1, ar2, ar3, ar4]:
... | def solution(ar):
if len(ar) == 0:
return 0
d = 1
ar.sort()
for i in range(1, len(ar)):
if ar[i] == ar[i - 1]:
continue
else:
d += 1
return d
ar1 = []
ar2 = [1]
ar3 = [1, 5, 8, 9]
ar4 = [2, 2, 2, 2, 3, 1]
for i in [ar1, ar2, ar3, ar4]:
print(soluti... |
lis = [34,1,53,754,2355,85,32,65,2,167,8,3114,6421]
print("Demo of Insertion Sort\n")
n = len(lis)
for i in range(1, n):
temp = lis[i]
for j in range(i-1,-1,-1):
if lis[j] > temp:
lis[j+1] = lis[j]
else:
lis[j+1] = temp
break
print(lis)
| lis = [34, 1, 53, 754, 2355, 85, 32, 65, 2, 167, 8, 3114, 6421]
print('Demo of Insertion Sort\n')
n = len(lis)
for i in range(1, n):
temp = lis[i]
for j in range(i - 1, -1, -1):
if lis[j] > temp:
lis[j + 1] = lis[j]
else:
lis[j + 1] = temp
break
print(lis) |
class Point3D:
counter=0
def __init__(self, x, y,z):
self.x = x
self.y = y
self.z = z
Point3D.counter+=1
def displayPoint3D(self):
print("x= ",self.x, "y= ", self.y, "z=", self.z)
def countPoints(self):
print(Point3D.counter)
p1=Point3D(12,10,10... | class Point3D:
counter = 0
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
Point3D.counter += 1
def display_point3_d(self):
print('x= ', self.x, 'y= ', self.y, 'z=', self.z)
def count_points(self):
print(Point3D.counter)
p1 = point3_d(12, ... |
#
# PySNMP MIB module CODIMA-GLOBAL-REG (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CODIMA-GLOBAL-REG
# Produced by pysmi-0.3.4 at Wed May 1 12:25:35 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint) ... |
# dictionary mapping AutoCAD color indexes with Blender colors
# --------------------------------------------------------------------------
# color_map.py Final by Ed Blake (AKA Kitsu)
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is... | color_map = {0: [0.0, 0.0, 0.0], 1: [0.99609375, 0.0, 0.0], 2: [0.99609375, 0.99609375, 0.0], 3: [0.0, 0.99609375, 0.0], 4: [0.0, 0.99609375, 0.99609375], 5: [0.0, 0.0, 0.99609375], 6: [0.99609375, 0.0, 0.99609375], 7: [0.99609375, 0.99609375, 0.99609375], 8: [0.25390625, 0.25390625, 0.25390625], 9: [0.5, 0.5, 0.5], 10... |
GOAL = "GOAL"
SHOT = "SHOT"
MISS = "MISSED_SHOT"
BLOCK = "BLOCKED_SHOT"
SHOT_EVENTS = (GOAL, SHOT)
FENWICK_EVENTS = (GOAL, SHOT, MISS)
CORSI_EVENTS = (GOAL, SHOT, MISS, BLOCK)
| goal = 'GOAL'
shot = 'SHOT'
miss = 'MISSED_SHOT'
block = 'BLOCKED_SHOT'
shot_events = (GOAL, SHOT)
fenwick_events = (GOAL, SHOT, MISS)
corsi_events = (GOAL, SHOT, MISS, BLOCK) |
# see __mro__ output in Bite description
class Person:
def __init__(self):
pass
def __repr__(self, string=""):
return "I am a person" + string
class Mother(Person):
def __str__(self):
return self.__repr__(" and awesome mom")
class Father(Person):
... | class Person:
def __init__(self):
pass
def __repr__(self, string=''):
return 'I am a person' + string
class Mother(Person):
def __str__(self):
return self.__repr__(' and awesome mom')
class Father(Person):
def __str__(self):
return self.__repr__(' and cool daddy')
... |
class Solution:
def subsetsWithDup(self, nums: [int]) -> [[int]]:
nums.sort()
result = [[]]
for num in nums:
for i in result[:]:
item = i[:]
item.append(num)
if item not in result:
result.append(item[:])
... | class Solution:
def subsets_with_dup(self, nums: [int]) -> [[int]]:
nums.sort()
result = [[]]
for num in nums:
for i in result[:]:
item = i[:]
item.append(num)
if item not in result:
result.append(item[:])
... |
last = 100000
result = 0
try:
while True:
cur = int(input())
if last < cur:
result += 1
last = cur
except EOFError:
pass
print(result)
| last = 100000
result = 0
try:
while True:
cur = int(input())
if last < cur:
result += 1
last = cur
except EOFError:
pass
print(result) |
n, m = map(int, input().strip().split(' '))
graph = {}
for _ in range(m):
i, j = map(int, input().strip().split(' '))
if j in graph.keys():
graph[j].append(i)
else:
graph[j] =[i]
def countChildrenEdges(graph, node):
count = 0
childNodes = graph[node]
for i in child... | (n, m) = map(int, input().strip().split(' '))
graph = {}
for _ in range(m):
(i, j) = map(int, input().strip().split(' '))
if j in graph.keys():
graph[j].append(i)
else:
graph[j] = [i]
def count_children_edges(graph, node):
count = 0
child_nodes = graph[node]
for i in childNodes:... |
###################### PIC32MZ-W1 Wireless System Services ######################
def loadModule():
print('Load Module: PIC32MZ-W1 Wireless System Services')
appdebugComponent = Module.CreateComponent('sysAppDebugPic32mzw1', "App Debug Service", '/Wireless/System Services/', 'system/appdebug/config/sys_appde... | def load_module():
print('Load Module: PIC32MZ-W1 Wireless System Services')
appdebug_component = Module.CreateComponent('sysAppDebugPic32mzw1', 'App Debug Service', '/Wireless/System Services/', 'system/appdebug/config/sys_appdebug.py')
sys_wifi_pic32mzw1_component = Module.CreateComponent('sysWifiPic32mzw... |
bases = {
"x": 16,
"b": 2,
"o": 8
}
ESCAPES = {
"n": "\n",
"t": "\t",
"r": "\r"
}
def shift_line(data, num):
for i in range(0, num):
data.opcode = data.args[0]
data.args.pop(0)
return data
def req_int(string, splices, tosplice, binary, ws):
return req_int_big(strin... | bases = {'x': 16, 'b': 2, 'o': 8}
escapes = {'n': '\n', 't': '\t', 'r': '\r'}
def shift_line(data, num):
for i in range(0, num):
data.opcode = data.args[0]
data.args.pop(0)
return data
def req_int(string, splices, tosplice, binary, ws):
return req_int_big(string, splices, tosplice, binary,... |
class Card:
def __init__(self, name):
self.name = name
self.actions = []
self.assign_actions(name)
# start of method assign()
def assign_actions(self, name):
if name == 'Ambassador':
self.actions.append('exchange')
self.actions.append('block_steal')
... | class Card:
def __init__(self, name):
self.name = name
self.actions = []
self.assign_actions(name)
def assign_actions(self, name):
if name == 'Ambassador':
self.actions.append('exchange')
self.actions.append('block_steal')
return
if n... |
def suma (x,y):
return x + y
| def suma(x, y):
return x + y |
for _ in range(int(input())):
px, py = map(int, input().split())
s = input()
x, y = 0, 0
res = ''
di = {"U": 0, "D": 0, "L": 0, "R": 0}
u, d, l, r = 0, 0, 0, 0
for i in s:
di[i]+=1
f, f1 = False, False
if px>=x:
if di["R"]>=px:
f = True
elif px<x:
... | for _ in range(int(input())):
(px, py) = map(int, input().split())
s = input()
(x, y) = (0, 0)
res = ''
di = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
(u, d, l, r) = (0, 0, 0, 0)
for i in s:
di[i] += 1
(f, f1) = (False, False)
if px >= x:
if di['R'] >= px:
f = True... |
# Databricks notebook source
# MAGIC %md
# MAGIC # Reading Data - Tables and Views
# MAGIC
# MAGIC **Technical Accomplishments:**
# MAGIC * Demonstrate how to pre-register data sources in Azure Databricks.
# MAGIC * Introduce temporary views over files.
# MAGIC * Read data from tables/views.
# MAGIC * Regarding `print... | pageviews_by_seconds_example_df = spark.read.table('pageviews_by_second_example_tsv')
pageviewsBySecondsExampleDF.printSchema()
display(pageviewsBySecondsExampleDF)
print('Partitions: ' + str(pageviewsBySecondsExampleDF.rdd.getNumPartitions()))
print_records_per_partition(pageviewsBySecondsExampleDF)
print('-' * 80)
pa... |
# "Exercices chapter 3"
try:
grade = float(input("give in ascore between 0.0 and 1.0: \n"))
if grade > 1.0:
print("Bad score")
elif grade >= 0.9:
print("A")
elif grade >= 0.8:
print("B")
elif(grade >= 0.7):
print("C")
elif(grade >= 0.6):
print("D")
eli... | try:
grade = float(input('give in ascore between 0.0 and 1.0: \n'))
if grade > 1.0:
print('Bad score')
elif grade >= 0.9:
print('A')
elif grade >= 0.8:
print('B')
elif grade >= 0.7:
print('C')
elif grade >= 0.6:
print('D')
elif grade < 0.6 and grade >=... |
print('hello world!', end=' ** ')
print('this is new', end='\n\n')
print('this is my', end='-----*****------')
print('oh my!!\n\n\n')
print('I', end='\t')
print('am', end=' 000 ')
print('batman')
| print('hello world!', end=' ** ')
print('this is new', end='\n\n')
print('this is my', end='-----*****------')
print('oh my!!\n\n\n')
print('I', end='\t')
print('am', end=' 000 ')
print('batman') |
__all__ = [
"mathematics",
"text",
"logic",
"controls",
"variables",
"machines",
"dependents",
"images",
"colour",
]
| __all__ = ['mathematics', 'text', 'logic', 'controls', 'variables', 'machines', 'dependents', 'images', 'colour'] |
#file=open("search.txt","w")
#print("enter 10 name")
#x=1
#while(x<=10):
# string=input()
# file.write(string)
# file.write("\n")
#x=x+1
#file.close()
files=open("search.txt","r")
name=input("enter name which you want to search")
data=files.read().split()
iterator=iter(data)
name_iter=iter(name)
for x in... | files = open('search.txt', 'r')
name = input('enter name which you want to search')
data = files.read().split()
iterator = iter(data)
name_iter = iter(name)
for x in range(0, len(data)):
iter_next = next(iterator)
iter2 = iter(iter_next)
for z in iter(iter2):
iter3 = next(iter2)
print(z)
fil... |
class CSVFile(object):
def __init__(self, file_name, headers):
try:
with open(file_name) as f:
pass
except IOError:
self.create_file(file_name, headers)
self.file_name = file_name
def create_file(self, file_name, headers):
with open(file_n... | class Csvfile(object):
def __init__(self, file_name, headers):
try:
with open(file_name) as f:
pass
except IOError:
self.create_file(file_name, headers)
self.file_name = file_name
def create_file(self, file_name, headers):
with open(file_... |
#!/usr/bin/env python
# coding: utf-8
# This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges).
# # Solution Notebook
# ## Problem: Given a positive integer, get the next largest number and the... | class Bits(object):
def get_next_largest(self, num):
if num is None:
raise type_error('num cannot be None')
if num <= 0:
raise value_error('num cannot be 0 or negative')
num_ones = 0
num_zeroes = 0
num_copy = num
while num_copy != 0 and num_co... |
#!/opt/local/bin/python
batch_file='4_batch.txt'
field_file='4_fields.txt'
optional="cid"
def loadfields(filename):
# Read field definition file
# Field definitions are as follows:
#tla (Description Field)
# All we want is the first three chars.
myfile = open(filename, 'r')
fields = []
for line in myfi... | batch_file = '4_batch.txt'
field_file = '4_fields.txt'
optional = 'cid'
def loadfields(filename):
myfile = open(filename, 'r')
fields = []
for line in myfile:
fields.append(line[0:3])
return fields
def loadbatch(filename):
myfile = open(filename, 'r')
records = [{}]
fields = {}
... |
#
# PySNMP MIB module CAREL-ug40cdz-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CAREL-ug40cdz-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:29:25 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (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_union, single_value_constraint, constraints_intersection) ... |
#sortingErrorException.py
list1 = [5, 4, 9, 10, 3, 5]
list2 = ["red", "blue", "orange", "black", "white", "golden"]
list3 = list1 + list2
print("list1:", list1)
print("list2:", list2)
print("list3:", list3)
sortedList1 = sorted(list1)
sortedList2 = sorted(list2)
try:
sortedList3 = sorted(list3)
except:
sorted... | list1 = [5, 4, 9, 10, 3, 5]
list2 = ['red', 'blue', 'orange', 'black', 'white', 'golden']
list3 = list1 + list2
print('list1:', list1)
print('list2:', list2)
print('list3:', list3)
sorted_list1 = sorted(list1)
sorted_list2 = sorted(list2)
try:
sorted_list3 = sorted(list3)
except:
sorted_list3 = "Lists with 'str... |
class Memoize:
def __init__(self, f):
self.f = f
self.memo = {}
def __call__(self, *args):
if not args in self.memo:
self.memo[args] = self.f(*args)
return self.memo[args]
def tiles(rowsize, next):
if rowsize < next:
return 0
if rowsize == next:
... | class Memoize:
def __init__(self, f):
self.f = f
self.memo = {}
def __call__(self, *args):
if not args in self.memo:
self.memo[args] = self.f(*args)
return self.memo[args]
def tiles(rowsize, next):
if rowsize < next:
return 0
if rowsize == next:
... |
# Exercise 1:
# Write a function that returns True if the first and last elements of two lists
# are the same, and return False otherwise.
def is_first_and_last_equal(list1, list2):
return len(list1) > 0 and len(list2) > 0 and \
list1[0] == list2[0] and list1[-1] == list2[-1]
print(is_first_and_last_... | def is_first_and_last_equal(list1, list2):
return len(list1) > 0 and len(list2) > 0 and (list1[0] == list2[0]) and (list1[-1] == list2[-1])
print(is_first_and_last_equal([0, 1, 2, 3, 4, 5], [0, 5]))
print(is_first_and_last_equal([0, 1, 2, 3, 4, 5], [5, 0]))
print(is_first_and_last_equal([0, 1, 2, 3, 4, 5], [1, 5]))... |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( arr , n ) :
d1 = 0
d2 = 0
for i in range ( 0 , n ) :
for j in range ( 0 , n ) :
if ... | def f_gold(arr, n):
d1 = 0
d2 = 0
for i in range(0, n):
for j in range(0, n):
if i == j:
d1 += arr[i][j]
if i == n - j - 1:
d2 += arr[i][j]
return abs(d1 - d2)
if __name__ == '__main__':
param = [([[1, 7, 17, 19, 22, 25, 27, 29, 41, 60,... |
def loadlogo(logo=1):
if logo == 1:
matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0... | def loadlogo(logo=1):
if logo == 1:
matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, ... |
class Functor:
def __init__(self, func, args=None, kwargs=None):
self.func = func
self.args = args or ()
self.kwargs = kwargs or {}
def __call__(self, *args, **kwargs):
return self.func(*self.args, **self.kwargs)
| class Functor:
def __init__(self, func, args=None, kwargs=None):
self.func = func
self.args = args or ()
self.kwargs = kwargs or {}
def __call__(self, *args, **kwargs):
return self.func(*self.args, **self.kwargs) |
# Fibonacci using Tabulation
def fibonacci(n):
# array declaration
f = [0] * (n + 1)
# base case assignment
if n > 0:
f[1] = 1
for i in range(2, n + 1):
f[i] = f[i - 1] + f[i - 2]
return f[n]
# Driver program to test the above function
def main():
n = 3
print("Fibonac... | def fibonacci(n):
f = [0] * (n + 1)
if n > 0:
f[1] = 1
for i in range(2, n + 1):
f[i] = f[i - 1] + f[i - 2]
return f[n]
def main():
n = 3
print('Fibonacci number is ', fibonacci(n))
if __name__ == '__main__':
main() |
class Solution:
def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:
if obstacleGrid[0][0] == 1:
return 0
m, n = len(obstacleGrid), len(obstacleGrid[0])
obstacleGrid[0][0] = 1
for i in range(1,m):
ob... | class Solution:
def unique_paths_with_obstacles(self, obstacleGrid: List[List[int]]) -> int:
if obstacleGrid[0][0] == 1:
return 0
(m, n) = (len(obstacleGrid), len(obstacleGrid[0]))
obstacleGrid[0][0] = 1
for i in range(1, m):
obstacleGrid[i][0] = 1 if obstacl... |
'''
done
'''
if True:
print ("Satu")
print ("Dua")
else:
print ("Tiga")
print ("Empat")
'''
if True:
print ("Satu")
print ("Dua")
else:
print ("Tiga")
print ("Empat")
''' | """
done
"""
if True:
print('Satu')
print('Dua')
else:
print('Tiga')
print('Empat')
'\nif True:\n print ("Satu")\n print ("Dua")\n\nelse:\n print ("Tiga")\nprint ("Empat")\n' |
class ActionDependentSerializerMixin(object):
'''
Supports differentiating serializers across actions
'''
def get_serializer_class(self):
return self.serializers.get(self.action, self.serializers['default'])
class FieldLimitableSerializerMixin(object):
'''
Supports limiting the return... | class Actiondependentserializermixin(object):
"""
Supports differentiating serializers across actions
"""
def get_serializer_class(self):
return self.serializers.get(self.action, self.serializers['default'])
class Fieldlimitableserializermixin(object):
"""
Supports limiting the return ... |
class AccountException(Exception):
pass
class EmailInUseException(AccountException):
pass
class IncorrectPasswordException(AccountException):
pass
class NonUniqueAccountException(AccountException):
pass
class AccountNotFoundException(AccountException):
pass
class EmailFailedException(Accou... | class Accountexception(Exception):
pass
class Emailinuseexception(AccountException):
pass
class Incorrectpasswordexception(AccountException):
pass
class Nonuniqueaccountexception(AccountException):
pass
class Accountnotfoundexception(AccountException):
pass
class Emailfailedexception(AccountExc... |
# Time: O(n^2), can be done in O(nlogn time)
# Space: O(n)
class Solution:
def countSmaller(self, nums: List[int]) -> List[int]:
op = []
sorted_nums = []
for num in nums[::-1]:
index = bisect.bisect_left(sorted_nums, num)
op.append(index)
sorted_nums.ins... | class Solution:
def count_smaller(self, nums: List[int]) -> List[int]:
op = []
sorted_nums = []
for num in nums[::-1]:
index = bisect.bisect_left(sorted_nums, num)
op.append(index)
sorted_nums.insert(index, num)
return op[::-1] |
x = int(input())
if x < 40:
print(40 - x)
elif x < 70:
print(70 - x)
elif x < 90:
print(90 - x)
else:
print('expert')
| x = int(input())
if x < 40:
print(40 - x)
elif x < 70:
print(70 - x)
elif x < 90:
print(90 - x)
else:
print('expert') |
#coding=utf-8
'''
Created on 2014-12-18
@author: Devuser
'''
class SCMInfo(object):
'''
classdocs
'''
def __init__(self,scm_user,scm_password,local_dir):
'''
info for access scm server
'''
self.scmuser=scm_user
self.scmpassword=scm_password
se... | """
Created on 2014-12-18
@author: Devuser
"""
class Scminfo(object):
"""
classdocs
"""
def __init__(self, scm_user, scm_password, local_dir):
"""
info for access scm server
"""
self.scmuser = scm_user
self.scmpassword = scm_password
self.local... |
# can't remember the objective, here
# something to do with putting the data from data.txt into a custom hash table
# then testing it by accessing two given keys?
class CustomHashTable:
def __init__(self, size):
self.size = size
self.hash_table = [[] for i in range(self.size)]
def set_val(self... | class Customhashtable:
def __init__(self, size):
self.size = size
self.hash_table = [[] for i in range(self.size)]
def set_val(self, key, value):
hashed_key = hash(key) % self.size
bucket = self.hash_table[hashed_key]
already_in_bucket = False
for (index, item) ... |
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print('Hi, {}'.format(name)) # ... | def print_hi(name):
print('Hi, {}'.format(name))
def list_mean(p):
total = 0.0
for t in p:
total += t
mean = total / len(p)
return mean
if __name__ == '__main__':
print_hi('PyCharm')
a = [1, 2, 3, 4]
print(list_mean(a)) |
def input():
return list(map(lambda row: [c for c in row], filter(None, open('day_11/input.txt').read().split('\n'))))
def count_neighbours(x, y, seats, max_dist):
count = 0
mx, my = len(seats[0]), len(seats)
for dx, dy in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
... | def input():
return list(map(lambda row: [c for c in row], filter(None, open('day_11/input.txt').read().split('\n'))))
def count_neighbours(x, y, seats, max_dist):
count = 0
(mx, my) = (len(seats[0]), len(seats))
for (dx, dy) in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
... |
def get_input(file):
input = open(file)
test = [x.strip() for x in input]
input.close()
return test
items = get_input('test.txt')
print(items)
| def get_input(file):
input = open(file)
test = [x.strip() for x in input]
input.close()
return test
items = get_input('test.txt')
print(items) |
# This problem was recently asked by Facebook:
# Given an array nums, write a function to move all 0's to the end of it while maintaining
# the relative order of the non-zero elements.
class Solution:
def moveZeros(self, nums):
# Fill this in.
count = 0
n = len(nums)
for i in range... | class Solution:
def move_zeros(self, nums):
count = 0
n = len(nums)
for i in range(n):
if nums[i] != 0:
nums[count] = nums[i]
count += 1
while count < n:
nums[count] = 0
count += 1
nums = [0, 0, 0, 2, 0, 1, 3, 4, 0,... |
def assertEqual(a, b):
assert a == b
def assertGreater(a, b):
assert a > b
def assertGreaterEqual(a, b):
assert a >= b
def assertLessEqual(a, b):
assert a <= b
def assertNotIn(a, b):
assert a not in b
def assertIn(a, b):
assert a in b
def assertCounterEqual(counters, name, value):
assertIn(nam... | def assert_equal(a, b):
assert a == b
def assert_greater(a, b):
assert a > b
def assert_greater_equal(a, b):
assert a >= b
def assert_less_equal(a, b):
assert a <= b
def assert_not_in(a, b):
assert a not in b
def assert_in(a, b):
assert a in b
def assert_counter_equal(counters, name, value... |
def packsonnet_k8s_repositories():
http_archive(
name = "com_github_0xIDANT_packsonnet",
#sha256 = "7f51f859035cd98bcf4f70dedaeaca47fe9fbae6b199882c516d67df416505da",
strip_prefix = "packsonnet-main",
urls = [
"https://github.com/0xIDANT/packsonnet/archive/refs/heads/main... | def packsonnet_k8s_repositories():
http_archive(name='com_github_0xIDANT_packsonnet', strip_prefix='packsonnet-main', urls=['https://github.com/0xIDANT/packsonnet/archive/refs/heads/main.zip']) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class TextConditionFactory():
@staticmethod
def create_text_condition(text):
return lambda amber_input: amber_input == text | class Textconditionfactory:
@staticmethod
def create_text_condition(text):
return lambda amber_input: amber_input == text |
class Solution:
def generate(self, numRows: int):
triangle = [[1]*x for x in range(1, numRows+1)]
for row in range(2, numRows):
for i in range(1, row):
triangle[row][i] = triangle[row-1][i-1] + triangle[row-1][i]
return triangle
if __nam... | class Solution:
def generate(self, numRows: int):
triangle = [[1] * x for x in range(1, numRows + 1)]
for row in range(2, numRows):
for i in range(1, row):
triangle[row][i] = triangle[row - 1][i - 1] + triangle[row - 1][i]
return triangle
if __name__ == '__main__... |
def diagonal_differences(matrix):
sum_left_diagonal = 0
for row in range(len(matrix)):
col = len(matrix) - row - 1
sum_left_diagonal += matrix[row][col]
sum_right_diagonal = 0
for row in range(len(matrix)-1, -1, -1):
col = row
sum_right_diagonal += matrix[row][c... | def diagonal_differences(matrix):
sum_left_diagonal = 0
for row in range(len(matrix)):
col = len(matrix) - row - 1
sum_left_diagonal += matrix[row][col]
sum_right_diagonal = 0
for row in range(len(matrix) - 1, -1, -1):
col = row
sum_right_diagonal += matrix[row][col]
... |
class Solution:
def majorityElement(self, nums: List[int]) -> List[int]:
count1, count2 = 0, 0
can1, can2 = None, None
for n in nums:
if can1 == n:
count1 += 1
elif can2 == n:
count2 += 1
elif count1 == 0:
... | class Solution:
def majority_element(self, nums: List[int]) -> List[int]:
(count1, count2) = (0, 0)
(can1, can2) = (None, None)
for n in nums:
if can1 == n:
count1 += 1
elif can2 == n:
count2 += 1
elif count1 == 0:
... |
class dp:
def knapsack(self, capacity, weight, value, i):
if capacity == 0 or i == -1: return 0
current_weight = weight[i]
if capacity >= weight[i]:
return max(value[i] + self.knapsack(capacity - current_weight, weight, value, i - 1),
self.knapsack(capacity... | class Dp:
def knapsack(self, capacity, weight, value, i):
if capacity == 0 or i == -1:
return 0
current_weight = weight[i]
if capacity >= weight[i]:
return max(value[i] + self.knapsack(capacity - current_weight, weight, value, i - 1), self.knapsack(capacity, weight, ... |
class Graph:
def __init__(self,edges) -> None:
self.edges = edges
self.graph_dict = {}
for start,end in self.edges:
if start in self.graph_dict:
self.graph_dict[start].append(end)
else:
self.graph_dict[start] = [end]
print("Gr... | class Graph:
def __init__(self, edges) -> None:
self.edges = edges
self.graph_dict = {}
for (start, end) in self.edges:
if start in self.graph_dict:
self.graph_dict[start].append(end)
else:
self.graph_dict[start] = [end]
print(... |
class Solution:
def minPathSum(self, grid: List[List[int]]) -> int:
if not grid or not grid[0]:
return 0
row = len(grid)
col = len(grid[0])
dp = [[0] * col for _ in range(row)]
dp[0][0] = grid[0][0]
for i in range(1, row):
dp[i][0] = dp[i - 1]... | class Solution:
def min_path_sum(self, grid: List[List[int]]) -> int:
if not grid or not grid[0]:
return 0
row = len(grid)
col = len(grid[0])
dp = [[0] * col for _ in range(row)]
dp[0][0] = grid[0][0]
for i in range(1, row):
dp[i][0] = dp[i - ... |
# Copyright 2018 Amazon.com, Inc. or its affiliates. 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. A copy of the License
# is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acco... | size_8 = 24
size_16 = 25
size_32 = 26
size_64 = 27
size_illegal_1 = 28
size_illegal_2 = 29
size_illegal_3 = 30
size_stream = 31
major_type_mask = 224
minor_type_mask = 31
type_posint = 0
type_posint_8 = TYPE_POSINT + SIZE_8
type_posint_16 = TYPE_POSINT + SIZE_16
type_posint_32 = TYPE_POSINT + SIZE_32
type_posint_64 = T... |
DISQUS_API_SECRET = "YOUR_SECRET"
DISQUS_API_KEY = "YOUR_KEY"
DISQUS_WEBSITE_SHORTNAME = "YOUR_SHORTNAME"
RECAPTCHA_PUBLIC = "YOUR_PUBLIC"
RECAPTCHA_SECRET = "YOUR_SECRET"
| disqus_api_secret = 'YOUR_SECRET'
disqus_api_key = 'YOUR_KEY'
disqus_website_shortname = 'YOUR_SHORTNAME'
recaptcha_public = 'YOUR_PUBLIC'
recaptcha_secret = 'YOUR_SECRET' |
#!/usr/bin/env python3
# O(N) time and constant space
def max_consecutive_ones_k(arr, k):
longest = left = right = count_zeros = 0
while right < len(arr):
if arr[right] == 0:
count_zeros += 1
while count_zeros > k:
if arr[left] == 0:
count_zeros -= 1
... | def max_consecutive_ones_k(arr, k):
longest = left = right = count_zeros = 0
while right < len(arr):
if arr[right] == 0:
count_zeros += 1
while count_zeros > k:
if arr[left] == 0:
count_zeros -= 1
left += 1
longest = max(longest, right ... |
class TennisGame():
def __init__(self, first_player_name="player1", second_player_name="player2"):
self.first_player_name = first_player_name
self.second_player_name = second_player_name
self.first_player_score = 0
self.second_player_score = 0
@property
def first_player_sco... | class Tennisgame:
def __init__(self, first_player_name='player1', second_player_name='player2'):
self.first_player_name = first_player_name
self.second_player_name = second_player_name
self.first_player_score = 0
self.second_player_score = 0
@property
def first_player_score... |
string = "Donald"
print(f"Changing Case - String '{string}'")
print("string.capitalize(): " + string.capitalize())
print("string.upper(): " + string.upper())
print("string.lower(): " + string.lower())
string = "Amanda"
print(f"\nLocation and Counting - String '{string}'")
print("string.count('a'): " + str(string.count... | string = 'Donald'
print(f"Changing Case - String '{string}'")
print('string.capitalize(): ' + string.capitalize())
print('string.upper(): ' + string.upper())
print('string.lower(): ' + string.lower())
string = 'Amanda'
print(f"\nLocation and Counting - String '{string}'")
print("string.count('a'): " + str(string.count(... |
_base_ = [
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py',
'../_base_/swa.py'
]
# model settings
model = dict(
type='DETR',
pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_base_patch4_window7_224_22k.pth',
backbo... | _base_ = ['../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py', '../_base_/swa.py']
model = dict(type='DETR', pretrained='https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_base_patch4_window7_224_22k.pth', backbone=dict(type='SwinTransformer... |
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0:
return False
y, val = x, 0
while y > 0:
n = y % 10
y //= 10
val *= 10
val += n
return x == val
| class Solution:
def is_palindrome(self, x: int) -> bool:
if x < 0:
return False
(y, val) = (x, 0)
while y > 0:
n = y % 10
y //= 10
val *= 10
val += n
return x == val |
# StateMachine/State.py
# A State has an operation, and can be moved
# into the next State given an Input:
class State:
def run(self):
assert 0, "run not implemented"
def next(self, input):
return None | class State:
def run(self):
assert 0, 'run not implemented'
def next(self, input):
return None |
def NaN_to_list(data, column_name):
'''
When dealing with a column which consist of lists, we need to change
the type of NaNs from 'float' to 'list' in order to perform iterative
operations. This function detects NaNs and creates an empty list for
missing rows.
'''
# Create a boolean vector... | def na_n_to_list(data, column_name):
"""
When dealing with a column which consist of lists, we need to change
the type of NaNs from 'float' to 'list' in order to perform iterative
operations. This function detects NaNs and creates an empty list for
missing rows.
"""
na_n_rows = data[column_... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head or not head.next:
return head
... | class Solution:
def delete_duplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head or not head.next:
return head
if head.next.val != head.val:
head.next = self.deleteDuplicates(head.next)
return head
cur = head
while cur.next... |
#!/usr/bin/env python
class Solution:
def threeSum(self, nums):
nums = sorted(nums)
i = j = k = 0
ret, l = [], len(nums)
for i in range(l):
if i > 0 and nums[i] == nums[i-1]:
continue
j, k = i+1, l-1
while j < k < l:
... | class Solution:
def three_sum(self, nums):
nums = sorted(nums)
i = j = k = 0
(ret, l) = ([], len(nums))
for i in range(l):
if i > 0 and nums[i] == nums[i - 1]:
continue
(j, k) = (i + 1, l - 1)
while j < k < l:
s = n... |
class Article:
def __init__(self):
self.title = ""
self.title_cn = ""
self.url = ""
self.date = ""
self.text = ""
self.text_cn = ""
def __str__(self):
return self.title + "===" + self.url + "===" + self.date
def __hash__(self):
return hash(se... | class Article:
def __init__(self):
self.title = ''
self.title_cn = ''
self.url = ''
self.date = ''
self.text = ''
self.text_cn = ''
def __str__(self):
return self.title + '===' + self.url + '===' + self.date
def __hash__(self):
return hash(s... |
def count_arr_binary(var):
count = 0
while var:
count += var % 2
var = var // 2
return count
arr = list(map(int, input("Enter nums with space").split()))
arr_new = [(arr[i], i) for i in range(len(arr))]
sort_arr = sorted(arr_new, key=lambda x: count_arr_binary(x[0]), reverse=True)
sort_ar... | def count_arr_binary(var):
count = 0
while var:
count += var % 2
var = var // 2
return count
arr = list(map(int, input('Enter nums with space').split()))
arr_new = [(arr[i], i) for i in range(len(arr))]
sort_arr = sorted(arr_new, key=lambda x: count_arr_binary(x[0]), reverse=True)
sort_arr =... |
#Day-02 of 100 Days of Coding
#November 19, 2020
#Shazid Hasan Riam
height = input("Enter Your Height in M: ")
weight = input("Enter Your Weight in KG: ")
bmi = int(weight) / float(height) ** 2
bmi_as_int = int(bmi)
print(bmi)
print(bmi_as_int) | height = input('Enter Your Height in M: ')
weight = input('Enter Your Weight in KG: ')
bmi = int(weight) / float(height) ** 2
bmi_as_int = int(bmi)
print(bmi)
print(bmi_as_int) |
#! /usr/bin/env python3
'''
equals
greater
less
'''
class equals (object):
def __new__ (cls, *args, **kwargs):
return cls._equals (args)
@staticmethod
def _equals (args: tuple|list):
args: iter = iter(args)
temp: any = next(args)
rest: bool = True
for x in a... | """
equals
greater
less
"""
class Equals(object):
def __new__(cls, *args, **kwargs):
return cls._equals(args)
@staticmethod
def _equals(args: tuple | list):
args: iter = iter(args)
temp: any = next(args)
rest: bool = True
for x in args:
if temp !=... |
# 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 countNodes(self, root: Optional[TreeNode]) -> int:
cnt = 0
if(not root):
ret... | class Solution:
def count_nodes(self, root: Optional[TreeNode]) -> int:
cnt = 0
if not root:
return 0
cnt = 1 + self.countNodes(root.left) + self.countNodes(root.right)
return cnt |
# Convert Draine & Li model structures to SEDs with flux normalized
# to something. Here I'm trying to normalize to 1 solar mass of dust
# at 10 Mpc. This should work on either a single model dictionary
# or a list of models.
# DL models give: nu P_nu in erg/s/H nucleon
# j_nu in Jy cm^2 /sr/H nucleon
# make th... | def convert_draineli_sed(dlmodel):
dust_to_h_array = [0.01, 0.01, 0.0101, 0.0102, 0.0102, 0.0103, 0.0104, 0.00343, 0.00344, 0.00359, 0.00206]
nmod = len(dlmodel)
sedstruct = []
refdist = 10.0 * 3.086e+24
atoms_per_msun = 1.989e+33 / 1.67e-24
gas_per_h = 1.36
for i in range(nmod):
lab... |
def quicksort(ary):
return quicksort_pythonic(ary)
def quicksort_pythonic(ary):
if ary is not None:
pivot = ary[0]
low = [i for i in ary[1:] if i <= pivot]
high = [i for i in ary[1:] if i > pivot]
return quicksort_pythonic(low) + [pivot] + quicksort_pythonic(high)
else:
... | def quicksort(ary):
return quicksort_pythonic(ary)
def quicksort_pythonic(ary):
if ary is not None:
pivot = ary[0]
low = [i for i in ary[1:] if i <= pivot]
high = [i for i in ary[1:] if i > pivot]
return quicksort_pythonic(low) + [pivot] + quicksort_pythonic(high)
else:
... |
test = { 'name': 'q3_3_2',
'points': 1,
'suites': [ { 'cases': [ {'code': ">>> test_movie_correctness.labels == ('Title', 'Genre', 'Was correct')\nTrue", 'hidden': False, 'locked': False},
{'code': '>>> test_movie_correctness.num_rows == test_movies.num_rows\nTrue', 'h... | test = {'name': 'q3_3_2', 'points': 1, 'suites': [{'cases': [{'code': ">>> test_movie_correctness.labels == ('Title', 'Genre', 'Was correct')\nTrue", 'hidden': False, 'locked': False}, {'code': '>>> test_movie_correctness.num_rows == test_movies.num_rows\nTrue', 'hidden': False, 'locked': False}, {'code': ">>> # Make s... |
coordinates_E0E1E1 = ((123, 111),
(123, 114), (124, 111), (124, 114), (125, 111), (125, 115), (126, 110), (126, 115), (127, 110), (127, 112), (127, 116), (128, 82), (128, 83), (128, 96), (128, 98), (128, 99), (128, 100), (128, 101), (128, 110), (128, 111), (128, 116), (128, 117), (129, 65), (129, 80), (129, 83), (129... | coordinates_e0_e1_e1 = ((123, 111), (123, 114), (124, 111), (124, 114), (125, 111), (125, 115), (126, 110), (126, 115), (127, 110), (127, 112), (127, 116), (128, 82), (128, 83), (128, 96), (128, 98), (128, 99), (128, 100), (128, 101), (128, 110), (128, 111), (128, 116), (128, 117), (129, 65), (129, 80), (129, 83), (129... |
del_items(0x801355B0)
SetType(0x801355B0, "struct THEME_LOC themeLoc[50]")
del_items(0x80135CF8)
SetType(0x80135CF8, "int OldBlock[4]")
del_items(0x80135D08)
SetType(0x80135D08, "unsigned char L5dungeon[80][80]")
del_items(0x80135998)
SetType(0x80135998, "struct ShadowStruct SPATS[37]")
del_items(0x80135A9C)
SetType(0x... | del_items(2148750768)
set_type(2148750768, 'struct THEME_LOC themeLoc[50]')
del_items(2148752632)
set_type(2148752632, 'int OldBlock[4]')
del_items(2148752648)
set_type(2148752648, 'unsigned char L5dungeon[80][80]')
del_items(2148751768)
set_type(2148751768, 'struct ShadowStruct SPATS[37]')
del_items(2148752028)
set_ty... |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def _get_model(cfg):
mod = __import__('{}.{}'.format(__name__, cfg['model']['name']), fromlist=[''])
return getattr(mod, "DepthPredModel")(**cfg["model"]["params"]) # noqa
| def _get_model(cfg):
mod = __import__('{}.{}'.format(__name__, cfg['model']['name']), fromlist=[''])
return getattr(mod, 'DepthPredModel')(**cfg['model']['params']) |
#
# PySNMP MIB module ATT-CNM-SIP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ATT-CNM-SIP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:31:49 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint) ... |
class Statistic:
def __init__(self):
self.num_correct = 0
self.num_attempts = 0
def __str__(self):
return "%" + str(self.percentage())
def percentage(self) -> float:
if self.num_attempts != 0:
return float(self.num_correct/self.num_attempts)
else:
... | class Statistic:
def __init__(self):
self.num_correct = 0
self.num_attempts = 0
def __str__(self):
return '%' + str(self.percentage())
def percentage(self) -> float:
if self.num_attempts != 0:
return float(self.num_correct / self.num_attempts)
else:
... |
#!/usr/bin/python3
def desbloqueo(caja):
open_box = True
count = 0
for i in caja:
if(len(i) > 1):
for j in i:
for k in caja:
if j in k:
count += 1
if count == len(k):
open_box = False
c... | def desbloqueo(caja):
open_box = True
count = 0
for i in caja:
if len(i) > 1:
for j in i:
for k in caja:
if j in k:
count += 1
if count == len(k):
open_box = False
count = 0
return ope... |
class StraalError(Exception):
_REGISTRY = {}
def __init_subclass__(cls, code: int, **kwargs):
super().__init_subclass__(**kwargs)
cls._register_straal_exc(code)
@classmethod
def _register_straal_exc(cls, code: int):
if code in cls._REGISTRY:
raise RuntimeError(f"Dup... | class Straalerror(Exception):
_registry = {}
def __init_subclass__(cls, code: int, **kwargs):
super().__init_subclass__(**kwargs)
cls._register_straal_exc(code)
@classmethod
def _register_straal_exc(cls, code: int):
if code in cls._REGISTRY:
raise runtime_error(f'Du... |
class NoTaxonomyException(Exception): pass
class NoWsReferenceException(Exception): pass
class NonZeroReturnException(Exception): pass
class ValidationException(Exception): pass
msg_dupGenomes = (
'Duplicate referenced Genomes in GenomeSet')
| class Notaxonomyexception(Exception):
pass
class Nowsreferenceexception(Exception):
pass
class Nonzeroreturnexception(Exception):
pass
class Validationexception(Exception):
pass
msg_dup_genomes = 'Duplicate referenced Genomes in GenomeSet' |
#!usr/bin/env python3
def compute_ranks(graph):
d = 0.8 # damping factor
numloops = 10
ranks = {}
npages = len(graph)
for page in graph:
ranks[page] = 1.0 / npages
for i in range(0, numloops):
newranks = {}
for page in graph:
newrank = (1 - d) / npages
... | def compute_ranks(graph):
d = 0.8
numloops = 10
ranks = {}
npages = len(graph)
for page in graph:
ranks[page] = 1.0 / npages
for i in range(0, numloops):
newranks = {}
for page in graph:
newrank = (1 - d) / npages
for links in graph:
... |
n=0
pa=0;
po=0;
ne=0;
for i in range (0,5,1):
x=int(input())
if x%2==0:
pa=pa+1
if x>0:
po=po+1
if x<0:
ne=ne+1
print("%d valor(es) par(es)" % pa)
print("%d valor(es) impar(es)" % (5-pa))
print("%d valor(es) positivo(s)" % po)
print("%d valor(es) negativo(s)" % ne) | n = 0
pa = 0
po = 0
ne = 0
for i in range(0, 5, 1):
x = int(input())
if x % 2 == 0:
pa = pa + 1
if x > 0:
po = po + 1
if x < 0:
ne = ne + 1
print('%d valor(es) par(es)' % pa)
print('%d valor(es) impar(es)' % (5 - pa))
print('%d valor(es) positivo(s)' % po)
print('%d valor(es) neg... |
_SCOPES = ["https://www.googleapis.com/auth/spreadsheets.readonly"]
# sample doc at: https://docs.google.com/spreadsheets/d/1X0wsfpb5-sm2PE4_dJDliBOrXIOzvVrYrA1JYeyS06c/edit?usp=sharing
_SPREADSHEET_ID = "1X0wsfpb5-sm2PE4_dJDliBOrXIOzvVrYrA1JYeyS06c"
_SHEET_NAME = "Sheet1"
_TEMPLATE_NAME = "template.pdf"
| _scopes = ['https://www.googleapis.com/auth/spreadsheets.readonly']
_spreadsheet_id = '1X0wsfpb5-sm2PE4_dJDliBOrXIOzvVrYrA1JYeyS06c'
_sheet_name = 'Sheet1'
_template_name = 'template.pdf' |
class Lesson:
def __init__(self, lesson_id, classroom, is_lecture):
self.is_lecture = is_lecture
self.classroom = classroom
self.lesson_id = lesson_id
| class Lesson:
def __init__(self, lesson_id, classroom, is_lecture):
self.is_lecture = is_lecture
self.classroom = classroom
self.lesson_id = lesson_id |
# -*- coding: utf-8 -*-
model = {
u'ha ': 0,
u' vh': 1,
u'a m': 2,
u'na ': 3,
u' u ': 4,
u'a n': 5,
u'tsh': 6,
u'wa ': 7,
u'a u': 8,
u' na': 9,
u'nga': 10,
u'vha': 11,
u' ts': 12,
u' dz': 13,
u' kh': 14,
u'dza': 15,
u'a v': 16,
u'ya ': 17,
u' ya': 18,
u'a t': 19,
u'ho ': 20,
u'la ': 21,
u' zw': 2... | model = {u'ha ': 0, u' vh': 1, u'a m': 2, u'na ': 3, u' u ': 4, u'a n': 5, u'tsh': 6, u'wa ': 7, u'a u': 8, u' na': 9, u'nga': 10, u'vha': 11, u' ts': 12, u' dz': 13, u' kh': 14, u'dza': 15, u'a v': 16, u'ya ': 17, u' ya': 18, u'a t': 19, u'ho ': 20, u'la ': 21, u' zw': 22, u' mu': 23, u'edz': 24, u'vhu': 25, u'ga ': 2... |
# a test middleware
def MethodParserMiddleware(get_response):
def middleware(request):
request.method = request.app.environ['REQUEST_METHOD']
response = get_response(request)
return response
return middleware | def method_parser_middleware(get_response):
def middleware(request):
request.method = request.app.environ['REQUEST_METHOD']
response = get_response(request)
return response
return middleware |
self.description = "conflict between a directory and a file"
p1 = pmpkg("pkg1")
p1.files = ["foo/"]
self.addpkg2db("sync", p1)
p2 = pmpkg("pkg2")
p2.files = ["foo"]
self.addpkg2db("sync", p2)
self.args = "-S pkg1 pkg2"
self.addrule("PACMAN_RETCODE=1")
self.addrule("!PKG_EXIST=pkg1")
self.addrule("!PKG_EXIST=pkg2")
| self.description = 'conflict between a directory and a file'
p1 = pmpkg('pkg1')
p1.files = ['foo/']
self.addpkg2db('sync', p1)
p2 = pmpkg('pkg2')
p2.files = ['foo']
self.addpkg2db('sync', p2)
self.args = '-S pkg1 pkg2'
self.addrule('PACMAN_RETCODE=1')
self.addrule('!PKG_EXIST=pkg1')
self.addrule('!PKG_EXIST=pkg2') |
#
# PySNMP MIB module VLAN-COUNTER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VLAN-COUNTER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:27:42 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, value_range_constraint, constraints_intersection) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.