content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#! /usr/bin/python3
#! @authot: @ruhend (Mudigonda Himansh)
#! CRC Encoder
def list2int(mylist):
char_divisor = [str(integer) for integer in mylist]
str_divisor = "". join(char_divisor)
int_divisor = int(str_divisor,2 )
return int_divisor
def DecimalToBinary(num):
answer = []
if num >= 1:
... | def list2int(mylist):
char_divisor = [str(integer) for integer in mylist]
str_divisor = ''.join(char_divisor)
int_divisor = int(str_divisor, 2)
return int_divisor
def decimal_to_binary(num):
answer = []
if num >= 1:
decimal_to_binary(num // 2)
bindigit = num % 2
answer.append(bi... |
class PexOSDeprovisionHandler(object):
def __init__(self):
pass
def run(self, force=False, deluser=False):
return
def run_changed_unique_id(self):
return
| class Pexosdeprovisionhandler(object):
def __init__(self):
pass
def run(self, force=False, deluser=False):
return
def run_changed_unique_id(self):
return |
class TPDO:
def __init__(self, index):
pass
class RPDO:
def __init__(self, index):
pass
| class Tpdo:
def __init__(self, index):
pass
class Rpdo:
def __init__(self, index):
pass |
class Field(object):
def __init__(self, name):
self.name = name
self.internal_name = '_' + self.name
def __get__(self, instance, instance_type):
if instance is None:
return self
return getattr(instance, self.internal_name, '')
def __set__(self, instance, value):... | class Field(object):
def __init__(self, name):
self.name = name
self.internal_name = '_' + self.name
def __get__(self, instance, instance_type):
if instance is None:
return self
return getattr(instance, self.internal_name, '')
def __set__(self, instance, value)... |
def merge_notch_list(notch_list_1, notch_list_2):
"""Merge two notches list
Parameters
----------
notch_list_1 : list
First notch list to merge
notch_list_2 : list
Second notch list to merge
Returns
-------
notch_list : list
list of dictionary with key: "begin_... | def merge_notch_list(notch_list_1, notch_list_2):
"""Merge two notches list
Parameters
----------
notch_list_1 : list
First notch list to merge
notch_list_2 : list
Second notch list to merge
Returns
-------
notch_list : list
list of dictionary with key: "begin_... |
"""pywxclient package module."""
__version__ = '0.1.2'
| """pywxclient package module."""
__version__ = '0.1.2' |
# Copyright 2012 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | """Classes for cloud/file references yielded by gsutil iterators."""
class Bucketlistingreftype(object):
"""Enum class for describing BucketListingRefs."""
bucket = 'bucket'
object = 'object'
prefix = 'prefix'
class Bucketlistingref(object):
"""A reference to one fully expanded iterator result.
... |
'''THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OT... | """THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OT... |
fname = input('Enter a filename:')
try:
fhand = open(fname)
except:
print('File cannot be opened:', fname)
exit()
for line in fhand:
words = line.split()
if len(words) >= 3 and words[0] == 'From':
print(words[2])
| fname = input('Enter a filename:')
try:
fhand = open(fname)
except:
print('File cannot be opened:', fname)
exit()
for line in fhand:
words = line.split()
if len(words) >= 3 and words[0] == 'From':
print(words[2]) |
load(
":poms_for_testing.bzl",
"COMPLEX_POM",
"GRANDPARENT_POM",
"MERGED_EXPECTED_POM",
"PARENT_POM",
)
load(":testing.bzl", "asserts", "test_suite")
load("//maven:poms.bzl", "poms")
load("//maven:xml.bzl", "xml")
def merge_properties_test(env):
parent = """<project><properties>
<foo>fo... | load(':poms_for_testing.bzl', 'COMPLEX_POM', 'GRANDPARENT_POM', 'MERGED_EXPECTED_POM', 'PARENT_POM')
load(':testing.bzl', 'asserts', 'test_suite')
load('//maven:poms.bzl', 'poms')
load('//maven:xml.bzl', 'xml')
def merge_properties_test(env):
parent = '<project><properties>\n <foo>foo</foo>\n <bar>ba... |
"""
Classes to represent error states
"""
class Error(Exception):
"""Base exception class for NPC"""
pass
class FormatError(Error):
"""
Raised when trying to use a malformed file
Attributes:
strerror (str): Error message describing what happened
"""
def __init__(self, strerror):
... | """
Classes to represent error states
"""
class Error(Exception):
"""Base exception class for NPC"""
pass
class Formaterror(Error):
"""
Raised when trying to use a malformed file
Attributes:
strerror (str): Error message describing what happened
"""
def __init__(self, strerror):
... |
def main():
lM = lambda arg: arg * 2
print(lM(5)) # 10
print(lM(0)) # 0
print(lM(10)) # 20
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
new_list = list(filter(lambda x: (x%2 == 0), my_list))
print(new_list)
pass
if __name__ == "__main__":
main() | def main():
l_m = lambda arg: arg * 2
print(l_m(5))
print(l_m(0))
print(l_m(10))
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
new_list = list(filter(lambda x: x % 2 == 0, my_list))
print(new_list)
pass
if __name__ == '__main__':
main() |
input = """
n(1).
n(2).
n(3).
n(4).
a(1,2).
a(1,3).
a(4,3).
a(3,1).
a(2,3).
a(1,4).
b(1,2,1).
b(1,1,1).
b(2,1,2).
b(3,1,1).
b(2,2,2).
c(1,2,3,4).
c(1,2,3,5).
c(4,3,2,1).
c(1,2,4,3).
c(2,1,3,4).
d(1,2,3,4,5).
d(5,4,3,2,1).
d(1,2,3,5,1).
%p(X,Y) v q(X,Z) v r(X,Y,Z,U,W) :- n(X), a(X,Y), b(X,Y,Z), c(X,Y,Z,U),
%d(X,Y,... | input = '\n\nn(1).\nn(2).\nn(3).\nn(4).\n\na(1,2).\na(1,3).\na(4,3).\na(3,1).\na(2,3).\na(1,4).\n\nb(1,2,1).\nb(1,1,1).\nb(2,1,2).\nb(3,1,1).\nb(2,2,2).\n\nc(1,2,3,4).\nc(1,2,3,5).\nc(4,3,2,1).\nc(1,2,4,3).\nc(2,1,3,4).\n\nd(1,2,3,4,5).\nd(5,4,3,2,1).\nd(1,2,3,5,1).\n\n%p(X,Y) v q(X,Z) v r(X,Y,Z,U,W) :- n(X), a(X,Y), b... |
N=10
for x in range (N):
for y in range (N):
print (x,y,x*y)
| n = 10
for x in range(N):
for y in range(N):
print(x, y, x * y) |
'''
Exercise 2:
Write in pseudo code a function merge(listA: List, listB: List) that returns a
sorted list containing the elements of both list where listA and listB are two sorted lists
of integers. If an element exists in both lists, it must appear multiple times in the returned list.
For example:
>>> merge([1,3,4,7]... | """
Exercise 2:
Write in pseudo code a function merge(listA: List, listB: List) that returns a
sorted list containing the elements of both list where listA and listB are two sorted lists
of integers. If an element exists in both lists, it must appear multiple times in the returned list.
For example:
>>> merge([1,3,4,7]... |
"""
PSET-4
Word Game Part 6: Playing a Game
A game consists of playing multiple hands. We need to implement one
final function to complete our word-game program. Write the code that
implements the playGame function. You should remove the code that is
currently uncommented in the playGame body. Read through the
spe... | """
PSET-4
Word Game Part 6: Playing a Game
A game consists of playing multiple hands. We need to implement one
final function to complete our word-game program. Write the code that
implements the playGame function. You should remove the code that is
currently uncommented in the playGame body. Read through the
spe... |
"""
Space : O(n)
Time : O(n)
"""
class Solution:
def reverseStr(self, s: str, k: int) -> str:
ans = ''
n = len(s)
rev = True
for i in range(0, n, k):
chunk = s[i:i+k]
if rev:
ans += "".join(chunk[::-1])
rev = False
... | """
Space : O(n)
Time : O(n)
"""
class Solution:
def reverse_str(self, s: str, k: int) -> str:
ans = ''
n = len(s)
rev = True
for i in range(0, n, k):
chunk = s[i:i + k]
if rev:
ans += ''.join(chunk[::-1])
rev = False
... |
# Licensed to Modin Development Team under one or more contributor license agreements.
# See the NOTICE file distributed with this work for additional information regarding
# copyright ownership. The Modin Development Team licenses this file to you under the
# Apache License, Version 2.0 (the "License"); you may not u... | def unwrap_partitions(api_layer_object, axis=None, bind_ip=False):
"""
Unwrap partitions of the `api_layer_object`.
Parameters
----------
api_layer_object : DataFrame or Series
The API layer object.
axis : None, 0 or 1. Default is None
The axis to unwrap partitions for (0 - row ... |
def unique_paths_with_obstacles(obstacle_grid):
if obstacle_grid is None or len(obstacle_grid) == 0 or obstacle_grid[0] is None or len(obstacle_grid[0]) == 0:
return 0
m = len(obstacle_grid)
n = len(obstacle_grid[0])
dp = [0 for i in range(n)]
for i in range(n):
if obstacle_grid[0]... | def unique_paths_with_obstacles(obstacle_grid):
if obstacle_grid is None or len(obstacle_grid) == 0 or obstacle_grid[0] is None or (len(obstacle_grid[0]) == 0):
return 0
m = len(obstacle_grid)
n = len(obstacle_grid[0])
dp = [0 for i in range(n)]
for i in range(n):
if obstacle_grid[0]... |
def undocumented(f):
"""
Apply the undocumented decorator to handler methods if they should not turn up in the API help
"""
f.undocumented = True
return f
| def undocumented(f):
"""
Apply the undocumented decorator to handler methods if they should not turn up in the API help
"""
f.undocumented = True
return f |
########################################################################
#
# License: BSD
# Created: February 25, 2005
# Author: Ivan Vilata - reverse:net.selidor@ivan
#
# $Id$
#
########################################################################
"""
Parameters for PyTables.
Misc variabl... | """
Parameters for PyTables.
Misc variables:
`__docformat__`
The format of documentation strings in this module.
`__version__`
Repository version of this file.
"""
__docformat__ = 'reStructuredText'
'The format of documentation strings in this module.'
__version__ = '$Revision$'
'Repository version of this fi... |
a=float(input())
b=float(input())
c=float(input())
d=float(input())
e=float(input())
f=float(input())
x=0
y=0
if a>=0:
x=x+1
y=y+a
if b>=0:
x=x+1
y=y+b
if c>=0:
x=x+1
y=y+c
if d>=0:
x=x+1
y=y+d
if e>=0:
x=x+1
y=y+e
if f>=0:
x=x+1
y=y+f
media=y/x
print("%d valores positivos"%x)
print("%.... | a = float(input())
b = float(input())
c = float(input())
d = float(input())
e = float(input())
f = float(input())
x = 0
y = 0
if a >= 0:
x = x + 1
y = y + a
if b >= 0:
x = x + 1
y = y + b
if c >= 0:
x = x + 1
y = y + c
if d >= 0:
x = x + 1
y = y + d
if e >= 0:
x = x + 1
y = y + e... |
"""Constants for HACS"""
VERSION = "0.12.1"
NAME_LONG = "HACS (Home Assistant Community Store)"
NAME_SHORT = "HACS"
DOMAIN = "hacs"
PROJECT_URL = "https://github.com/custom-components/hacs/"
CUSTOM_UPDATER_LOCATIONS = [
"{}/custom_components/custom_updater.py",
"{}/custom_components/custom_updater/__init__.py",... | """Constants for HACS"""
version = '0.12.1'
name_long = 'HACS (Home Assistant Community Store)'
name_short = 'HACS'
domain = 'hacs'
project_url = 'https://github.com/custom-components/hacs/'
custom_updater_locations = ['{}/custom_components/custom_updater.py', '{}/custom_components/custom_updater/__init__.py']
issue_ur... |
def main():
SX, SY, GX, GY = map(int, input().split())
print((SY*GX+SX*GY) / (SY+GY))
if __name__ == "__main__":
main()
| def main():
(sx, sy, gx, gy) = map(int, input().split())
print((SY * GX + SX * GY) / (SY + GY))
if __name__ == '__main__':
main() |
'''Implement a program to calculate sum of odd digits present in the given number
Input Format
a number from the user
Constraints
n>0
Output Format
print sum of odd digits
Sample Input 0
123
Sample Output 0
4
Sample Input 1
101
Sample Output 1
2'''
#solution
n = input()
sum = 0
for i in n:
if int(i)%2 ==... | """Implement a program to calculate sum of odd digits present in the given number
Input Format
a number from the user
Constraints
n>0
Output Format
print sum of odd digits
Sample Input 0
123
Sample Output 0
4
Sample Input 1
101
Sample Output 1
2"""
n = input()
sum = 0
for i in n:
if int(i) % 2 == 1:
... |
def GetCardType(models):
return "Japanese (recognition&recall)"
def MakeCard(data):
result = {}
if 'front_word' not in data and 'back_word' not in data or 'read_word' not in data:
return result
result['Expression'] = data['front_word']
result['Meaning'] = data['back_word']
result['Rea... | def get_card_type(models):
return 'Japanese (recognition&recall)'
def make_card(data):
result = {}
if 'front_word' not in data and 'back_word' not in data or 'read_word' not in data:
return result
result['Expression'] = data['front_word']
result['Meaning'] = data['back_word']
result['Re... |
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
if t < 0 or k <= 0:
return False
table = {}
w = 1 + t
for i, num in enumerate(nums):
curr = num // w
if curr in table:
return True
... | class Solution:
def contains_nearby_almost_duplicate(self, nums: List[int], k: int, t: int) -> bool:
if t < 0 or k <= 0:
return False
table = {}
w = 1 + t
for (i, num) in enumerate(nums):
curr = num // w
if curr in table:
return Tr... |
def make_devision(n: float):
"""
This closure returns a function that returns the devision of an x number by n
"""
def division(x: float) -> float:
return x / n
return division
def run():
n = float(input('Insert n: '))
devision_n = make_devision(n)
x = float(input('Insert x:... | def make_devision(n: float):
"""
This closure returns a function that returns the devision of an x number by n
"""
def division(x: float) -> float:
return x / n
return division
def run():
n = float(input('Insert n: '))
devision_n = make_devision(n)
x = float(input('Insert x... |
while True:
try:
a,b=map(int,input().split())
c=a^b
print(c)
except EOFError:break
| while True:
try:
(a, b) = map(int, input().split())
c = a ^ b
print(c)
except EOFError:
break |
def subsets(arr):
return return_subsets(arr, 0)
def return_subsets(arr, index): # [5,7] # [7] # []
"""
:param: arr - input integer array
Return - list of lists (two dimensional array) where each list represents a subset
TODO: complete this method to return subsets of an array
"""
if len(a... | def subsets(arr):
return return_subsets(arr, 0)
def return_subsets(arr, index):
"""
:param: arr - input integer array
Return - list of lists (two dimensional array) where each list represents a subset
TODO: complete this method to return subsets of an array
"""
if len(arr) <= index:
... |
catlog = ['Show Filter On Binary', 'Show Smooth The Rec', 'Show Smooth The Gear', 'Show Dog The Gear',
'Show QRCode Art', '-', 'Show Dilation', 'Show Erosion', 'Show Open And Close', '-', 'Show Fill Holes',
'Show Outline', 'Show ConvexHull', 'Show Skeleton', '-', 'Show Distance', 'Show Max Circle', 'Show Medial Axis'... | catlog = ['Show Filter On Binary', 'Show Smooth The Rec', 'Show Smooth The Gear', 'Show Dog The Gear', 'Show QRCode Art', '-', 'Show Dilation', 'Show Erosion', 'Show Open And Close', '-', 'Show Fill Holes', 'Show Outline', 'Show ConvexHull', 'Show Skeleton', '-', 'Show Distance', 'Show Max Circle', 'Show Medial Axis', ... |
limit = 25
subreddit = 'cscareerquestions'
client_id = '???'
client_secret = '???'
user_agent = 'python:X.Y.Z:v1.0.0 (by /u/???)'
gmail_user = '???@???.???'
gmail_password = '???'
sender = '???@???.???'
recipient = '???@???.???'
subject = 'Top Trending on /r/%s' % (subreddit)
| limit = 25
subreddit = 'cscareerquestions'
client_id = '???'
client_secret = '???'
user_agent = 'python:X.Y.Z:v1.0.0 (by /u/???)'
gmail_user = '???@???.???'
gmail_password = '???'
sender = '???@???.???'
recipient = '???@???.???'
subject = 'Top Trending on /r/%s' % subreddit |
NOT_ALLOWED = ["", None, True, False, [], {}]
def arrayLength(arr, length):
if len(arr) == length:
return True
else:
return False
def checkFields(staticFields, dataFields):
requiredfields = list(set(staticFields) - set(dataFields))
extraFields = list(set(dataFields) - set(staticField... | not_allowed = ['', None, True, False, [], {}]
def array_length(arr, length):
if len(arr) == length:
return True
else:
return False
def check_fields(staticFields, dataFields):
requiredfields = list(set(staticFields) - set(dataFields))
extra_fields = list(set(dataFields) - set(staticFiel... |
# TODO get wall-tower headings for Transdec regions
# PINGER_FREQUENCY = 30000 # Region A
# PINGER_FREQUENCY = 40000 # Region B
# PINGER_FREQUENCY = 25000 # Region C
# PINGER_FREQUENCY = 35000 # Region D
PINGER_FREQUENCY = 30000
TRACK_MAG_THRESH = 10.8
TRACK_COOLDOWN_SAMPLES = 188000
RIGHT_HANDED = False
PATH_1_BEND... | pinger_frequency = 30000
track_mag_thresh = 10.8
track_cooldown_samples = 188000
right_handed = False
path_1_bend_right = RIGHT_HANDED
path_2_bend_right = RIGHT_HANDED |
"""
Circular Queue
Problem Statement:
Circular Queue is a linear data structure which follows FIFO principle
The difference is that the last position is connected back to the first position to make a circle.
Perform insertion, deletion and traversal operations on Circular Queue.
"""
class CircularQueue:
... | """
Circular Queue
Problem Statement:
Circular Queue is a linear data structure which follows FIFO principle
The difference is that the last position is connected back to the first position to make a circle.
Perform insertion, deletion and traversal operations on Circular Queue.
"""
class Circularqueue:
def __ini... |
manager22222
ssssss
| manager22222
ssssss |
dtype = object
transformers = [
lambda _: _.transpose(),
lambda _: _.rename_axis(
mapper='variable',
axis='index'
),
]
| dtype = object
transformers = [lambda _: _.transpose(), lambda _: _.rename_axis(mapper='variable', axis='index')] |
# Created by MechAviv
# Map ID :: 807000000
# Momijigaoka : Momijigaoka
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(False, True, False, False) | sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(False, True, False, False) |
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
#base case
if(len(s) == 1):
if(s in wordDict):
return True;
else:
return False;
pyt
queue = [0];
visited = [0] * len(s)
while(len(queu... | class Solution:
def word_break(self, s: str, wordDict: List[str]) -> bool:
if len(s) == 1:
if s in wordDict:
return True
else:
return False
pyt
queue = [0]
visited = [0] * len(s)
while len(queue) != 0:
s... |
class Canister:
def __init__(self, agent, canister_id, candid):
self.agent = agent
self.canister_id = canister_id
self.candid = candid
| class Canister:
def __init__(self, agent, canister_id, candid):
self.agent = agent
self.canister_id = canister_id
self.candid = candid |
expected_output = {
"configuration": {
"vpg_name": "VirtualPortGroup2",
"vpg_ip_addr": "192.168.2.1",
"vpg_ip_mask": "255.255.255.0",
"sng_name": "SNG-APPQOE",
"sng_ip_addr": "192.168.2.2",
},
"status": {"operational_state": "RUNNING"},
}
| expected_output = {'configuration': {'vpg_name': 'VirtualPortGroup2', 'vpg_ip_addr': '192.168.2.1', 'vpg_ip_mask': '255.255.255.0', 'sng_name': 'SNG-APPQOE', 'sng_ip_addr': '192.168.2.2'}, 'status': {'operational_state': 'RUNNING'}} |
# Python3 Program to decompose
# a matrix into lower and
# upper traingular matrix
MAX = 100;
def luDecomposition(mat, n):
lower = [[0 for x in range(n)]
for y in range(n)]
upper = [[0 for x in range(n)]
for y in range(n)]
# Decomposing matrix into Upper
# and L... | max = 100
def lu_decomposition(mat, n):
lower = [[0 for x in range(n)] for y in range(n)]
upper = [[0 for x in range(n)] for y in range(n)]
for i in range(n):
for k in range(i, n):
sum = 0
for j in range(i):
sum += lower[i][j] * upper[j][k]
upper[... |
# Based on the user's input
print("Give me any 2 numbers! I'll find how many y is in x percent!")
x = input("Enter the first number: ");
y = input("Enter the second nubmer: ")
def percentage(x, y):
return (float(x) * float(y)) / 100.0
print("{0}% of {1} is equal to {2}".format(x, y, percentage(x, y)));
| print("Give me any 2 numbers! I'll find how many y is in x percent!")
x = input('Enter the first number: ')
y = input('Enter the second nubmer: ')
def percentage(x, y):
return float(x) * float(y) / 100.0
print('{0}% of {1} is equal to {2}'.format(x, y, percentage(x, y))) |
def print_msg(number):
def printer():
"Here we are using the nonlocal keyword"
nonlocal number
number=3
print(number)
printer()
print(number)
print_msg(9)
def transmit_to_space(message):
"This is the enclosing function"
def data_transmitter():
"The nested fu... | def print_msg(number):
def printer():
"""Here we are using the nonlocal keyword"""
nonlocal number
number = 3
print(number)
printer()
print(number)
print_msg(9)
def transmit_to_space(message):
"""This is the enclosing function"""
def data_transmitter():
"""... |
a,b = input().split(" ")
x = float(a)
y = float(b)
if x > 0.00 and y > 0.00:
print("Q1")
elif x > 0.00 and y < 0.00:
print("Q4")
elif x < 0.00 and y > 0.00:
print("Q2")
elif x < 0.00 and y < 0.00:
print("Q3")
elif x == 0.00 and y ==0.00:
print("Origem")
elif x == 0.00 and y > 0.0:
print("Eixo ... | (a, b) = input().split(' ')
x = float(a)
y = float(b)
if x > 0.0 and y > 0.0:
print('Q1')
elif x > 0.0 and y < 0.0:
print('Q4')
elif x < 0.0 and y > 0.0:
print('Q2')
elif x < 0.0 and y < 0.0:
print('Q3')
elif x == 0.0 and y == 0.0:
print('Origem')
elif x == 0.0 and y > 0.0:
print('Eixo Y')
elif ... |
class Event:
"""
Superclass representing any sort of event that can be managed by the EventManager
"""
def __init__(self):
self.name = "Generic Event"
class TickEvent(Event):
"""
An event to tick the game state
"""
def __init__(self):
self.name = "Tick Event"
| class Event:
"""
Superclass representing any sort of event that can be managed by the EventManager
"""
def __init__(self):
self.name = 'Generic Event'
class Tickevent(Event):
"""
An event to tick the game state
"""
def __init__(self):
self.name = 'Tick Event' |
#!/usr/bin/env python
"""
The complete code of Ch. 4, Recipe 7 --
Extending built-in types: Enforcing member-type on collections
"""
class TypedList(list):
"""
Provides a list-based sequence that only allows certain
member-types
"""
# - Keep track of allowed member-types as a read-only property
@pro... | """
The complete code of Ch. 4, Recipe 7 --
Extending built-in types: Enforcing member-type on collections
"""
class Typedlist(list):
"""
Provides a list-based sequence that only allows certain
member-types
"""
@property
def member_types(self):
try:
return self._member_types
... |
class Singleton:
__instance = None
@staticmethod
def getinstance():
if Singleton.__instance is None:
raise Exception("Singleton does not exist!")
return Singleton.__instance
def __init__(self, name):
if Singleton.__instance is not None:
raise Exception("... | class Singleton:
__instance = None
@staticmethod
def getinstance():
if Singleton.__instance is None:
raise exception('Singleton does not exist!')
return Singleton.__instance
def __init__(self, name):
if Singleton.__instance is not None:
raise exception('... |
def set(bit):
"""Set the specifeid bit (1-indexed) eg. set(8) == 0x80"""
return 1 << (bit - 1)
def setN(n):
"""Set the first n specified bits eg. setN(7) == 0x7F"""
return set(n + 1) - 1
def reverse(value, length):
"""Reverse an integer value with length bits eg. reverse(0b10,2) == 0b01"""
out... | def set(bit):
"""Set the specifeid bit (1-indexed) eg. set(8) == 0x80"""
return 1 << bit - 1
def set_n(n):
"""Set the first n specified bits eg. setN(7) == 0x7F"""
return set(n + 1) - 1
def reverse(value, length):
"""Reverse an integer value with length bits eg. reverse(0b10,2) == 0b01"""
outp... |
class Solution:
"""
@param num1: An integer
@param num2: An integer
@param num3: An integer
@return: an interger
"""
def maxOfThreeNumbers(self, num1, num2, num3):
# write your code here
return max(max(num1, num2), max(num2, num3))
| class Solution:
"""
@param num1: An integer
@param num2: An integer
@param num3: An integer
@return: an interger
"""
def max_of_three_numbers(self, num1, num2, num3):
return max(max(num1, num2), max(num2, num3)) |
class Row(list):
def __init__(self, values=None):
self.labels = []
self.values = []
if values:
for idx in values:
self.__setitem__(idx, values[idx])
def __setitem__(self, idx, value):
if type(idx) is str:
if idx in self.labels:
... | class Row(list):
def __init__(self, values=None):
self.labels = []
self.values = []
if values:
for idx in values:
self.__setitem__(idx, values[idx])
def __setitem__(self, idx, value):
if type(idx) is str:
if idx in self.labels:
... |
#from subprocess import call
__all__ = [
'check_numbers',
'command_line',
'match_spaces',
'split_conflict',
'wrap_sentences',
]
| __all__ = ['check_numbers', 'command_line', 'match_spaces', 'split_conflict', 'wrap_sentences'] |
numbers = str(input("Input a list of coma-separated numbers: "))
numbers = ''.join(numbers.split())
numList = numbers.split(",")
numListClean = list(dict.fromkeys(numList))
print(f"\n{numListClean}") | numbers = str(input('Input a list of coma-separated numbers: '))
numbers = ''.join(numbers.split())
num_list = numbers.split(',')
num_list_clean = list(dict.fromkeys(numList))
print(f'\n{numListClean}') |
H = [[0, -1, [68.16,1]], [0, -1, [10.2465,1]], [0, -1, [2.34648,1]],
[0, -1, [0.67332,1]], [0, -1, [0.22466,1]], [0, -1, [0.082217,1]],
[1, 0, [1.3,1]], [1, 0, [0.33,1]],
[2, 0, [1.0,1]], ]
C = [[0, -1, [16371.074,1]], [0, -1, [2426.9925,1]], [0, -1, [544.54418,1]],
[0, -1, [150.80487,1]], [0... | h = [[0, -1, [68.16, 1]], [0, -1, [10.2465, 1]], [0, -1, [2.34648, 1]], [0, -1, [0.67332, 1]], [0, -1, [0.22466, 1]], [0, -1, [0.082217, 1]], [1, 0, [1.3, 1]], [1, 0, [0.33, 1]], [2, 0, [1.0, 1]]]
c = [[0, -1, [16371.074, 1]], [0, -1, [2426.9925, 1]], [0, -1, [544.54418, 1]], [0, -1, [150.80487, 1]], [0, -1, [47.708143... |
pessoas = []
dados = []
while True:
dados.append(input('Digite seu nome: '))
dados.append(float(input('Digite seu peso: ')))
pessoas.append(dados[:])
dados.clear()
r = input('Quer continuar? [S/N]: ')
if r in 'Nn':
break
print(f'{len(pessoas)} pessoas foram cadastradas!')
pesado = 0
leve... | pessoas = []
dados = []
while True:
dados.append(input('Digite seu nome: '))
dados.append(float(input('Digite seu peso: ')))
pessoas.append(dados[:])
dados.clear()
r = input('Quer continuar? [S/N]: ')
if r in 'Nn':
break
print(f'{len(pessoas)} pessoas foram cadastradas!')
pesado = 0
leve... |
ITP_TEMPLATE = """\
;----------------------------TITLE -----------------------------------------------------------------------------------------
; None
;
; This file was generated at {time} on {date} using the ATB API, using information generated by
;
; Automatic Topology Builder
;
; ... | itp_template = ';----------------------------TITLE -----------------------------------------------------------------------------------------\n; None\n;\n; This file was generated at {time} on {date} using the ATB API, using information generated by\n;\n; Automatic Topology Builder \n;\n; ... |
a = [1,2,3,4,5]
def getMinList(numbers):
minNumber = numbers[0]
for i in numbers:
if i < minNumber:
minNumber = i
return minNumber
print(getMinList(a))
print(getMinList([9,3,8,9])) | a = [1, 2, 3, 4, 5]
def get_min_list(numbers):
min_number = numbers[0]
for i in numbers:
if i < minNumber:
min_number = i
return minNumber
print(get_min_list(a))
print(get_min_list([9, 3, 8, 9])) |
class DnsEndPoint(EndPoint):
"""
Represents a network endpoint as a host name or a string representation of an IP address and a port number.
DnsEndPoint(host: str,port: int)
DnsEndPoint(host: str,port: int,addressFamily: AddressFamily)
"""
def Equals(self, comparand):
"""
Equals... | class Dnsendpoint(EndPoint):
"""
Represents a network endpoint as a host name or a string representation of an IP address and a port number.
DnsEndPoint(host: str,port: int)
DnsEndPoint(host: str,port: int,addressFamily: AddressFamily)
"""
def equals(self, comparand):
"""
Equals(self: DnsEnd... |
def q3(datas: List[int]) -> int:
'''find the best time point to buy and sell stocks(at most one transaction)'''
max_profit = 0
min_price = None
for item in datas:
if min_price is None:
min_price = item
continue
if item > min_price:
if item - min_pric... | def q3(datas: List[int]) -> int:
"""find the best time point to buy and sell stocks(at most one transaction)"""
max_profit = 0
min_price = None
for item in datas:
if min_price is None:
min_price = item
continue
if item > min_price:
if item - min_price ... |
'''
Created on Jul 10, 2012
@author: Chris
'''
class Node(object):
def __init__(self):
self.next = None
self.previous = None
self.element = None
class LinkedList(object):
def __init__(self):
self.n = 0
self.last = Node()
self.first = self.last
... | """
Created on Jul 10, 2012
@author: Chris
"""
class Node(object):
def __init__(self):
self.next = None
self.previous = None
self.element = None
class Linkedlist(object):
def __init__(self):
self.n = 0
self.last = node()
self.first = self.last
def append... |
class Member:
def __init__(self, name , age):
self.name = name
self.age=age
self.id=0
def __str__(self):
return "name:{} ,age: {},id:{}".format(self.name,self.age,self.id)
class Post:
def __init__(self , title , content):
self.title = title
self.content = content
self.id=0
def __str__(self):
re... | class Member:
def __init__(self, name, age):
self.name = name
self.age = age
self.id = 0
def __str__(self):
return 'name:{} ,age: {},id:{}'.format(self.name, self.age, self.id)
class Post:
def __init__(self, title, content):
self.title = title
self.content... |
class Solution:
def solve(self, heights):
stack = []
for i in range(len(heights)):
while stack and heights[stack[-1]] <= heights[i]:
stack.pop()
stack.append(i)
return stack
| class Solution:
def solve(self, heights):
stack = []
for i in range(len(heights)):
while stack and heights[stack[-1]] <= heights[i]:
stack.pop()
stack.append(i)
return stack |
'''
Given the head of a linked list, remove the nth node from the end of the list and return its head.
Eg.
Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
'''
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class ... | """
Given the head of a linked list, remove the nth node from the end of the list and return its head.
Eg.
Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
"""
class Solution:
def remove_nth_from_end(self, head: ListNode, n: int) -> ListNode:
if not head.next:
return None
length = 0
... |
#!/usr/bin/env python3
'''
Write a function called gcd that takes parameters a and b and returns
their greatest common divisor
'''
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
print(gcd(12, 8))
| """
Write a function called gcd that takes parameters a and b and returns
their greatest common divisor
"""
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
print(gcd(12, 8)) |
t = int(input())
while t > 0:
t -= 1
n, m = input().split()
blocos = [int(x) for x in input().split()]
blocos.sort()
qt = 0
n = int(n)-1
m = int(m)
while m > 0:
while m < blocos[n]:
n -= 1
m -= blocos[n]
qt += 1
print(qt)
| t = int(input())
while t > 0:
t -= 1
(n, m) = input().split()
blocos = [int(x) for x in input().split()]
blocos.sort()
qt = 0
n = int(n) - 1
m = int(m)
while m > 0:
while m < blocos[n]:
n -= 1
m -= blocos[n]
qt += 1
print(qt) |
# -*- coding: utf-8 -*-
"""General methods to show data like structures. Maybe redundant (BERT).
no mpl specific stuff.
"""
| """General methods to show data like structures. Maybe redundant (BERT).
no mpl specific stuff.
""" |
"""
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumeric string is a string consisting of lowercase English letters and digits.
Example 1:
Input: s = "dfa12321afd"
Output: 2
Explanation: The digits that appear in s are [1, 2, 3]. T... | """
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumeric string is a string consisting of lowercase English letters and digits.
Example 1:
Input: s = "dfa12321afd"
Output: 2
Explanation: The digits that appear in s are [1, 2, 3]. T... |
def grade(arg, key):
if "flag{crash}".lower() == key.lower():
return True, "Denial of service attacks are boring."
else:
return False, "Try crashing the program."
| def grade(arg, key):
if 'flag{crash}'.lower() == key.lower():
return (True, 'Denial of service attacks are boring.')
else:
return (False, 'Try crashing the program.') |
# Copyright: Copyright (c) 2020., Adam Jakab
#
# Author: Adam Jakab <adam at jakab dot pro>
# Created: 2/24/20, 12:09 AM
# License: See LICENSE.txt
__version__ = '1.3.4'
| __version__ = '1.3.4' |
# START LAB EXERCISE 06
print('Lab Exercise 06 \n')
#SETUP
chinese_desserts = [
["Wheat Flour Cake", 190],
["Egg Yolk", 260],
["Green Bean Cake", 100],
["Taro Pastry", 227],
["Durian Cake", 360],
["Flower Pastry", 130],
["Sun Cake", 172]
]
# END SETUP
# PROBLEM 1 (3 points)
# TODO Implem... | print('Lab Exercise 06 \n')
chinese_desserts = [['Wheat Flour Cake', 190], ['Egg Yolk', 260], ['Green Bean Cake', 100], ['Taro Pastry', 227], ['Durian Cake', 360], ['Flower Pastry', 130], ['Sun Cake', 172]]
name = None
print(f'\n1. First dessert item: {name}')
calories = None
print(f'\n2A. Calories of the second desser... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//antlir/bzl:query.bzl", "query")
# Find the feature JSON belonging to this layer.
def layer_features_json_query(layer):
return "$(... | load('//antlir/bzl:query.bzl', 'query')
def layer_features_json_query(layer):
return "$(query_targets_and_outputs '{query}')".format(query=query.attrfilter(label='type', value='image_feature', expr=query.deps(expr=query.set(layer), depth=1)))
def layer_included_features_query(layer):
return "$(query_targets_a... |
# ------------------------------
#
# Routines to work with Genesis lattices.
# C
#
#-------------------------------------------------
# Helper functions
def ele_types(eles):
"""
Returns a list of unique types in eles
"""
return list(set([e['type'] for e in eles] ))
def eles_by_type(eles):
"""
... | def ele_types(eles):
"""
Returns a list of unique types in eles
"""
return list(set([e['type'] for e in eles]))
def eles_by_type(eles):
"""
Separated eles by type, returns a dict of:
<type>:[<eles>]
"""
tlist = ele_types(eles)
tlat = {}
for t in tlist:
tlat[t] = []
... |
###############################################################
VERSION = '0.11.11'
###############################################################
default_app_config = 'swingtime.apps.SwingtimeConfig'
###############################################################
| version = '0.11.11'
default_app_config = 'swingtime.apps.SwingtimeConfig' |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def maxPathSum(self, root: TreeNode) -> int:
"""
Either traversal is fine - preorder (left, right, node) or postorder (right, l... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def max_path_sum(self, root: TreeNode) -> int:
"""
Either traversal is fine - preorder (left, right, node) or postorder (right, left, node).
Recursion approac... |
"""Constants for the Eaton xComfort Bridge integration."""
DOMAIN = "xcomfort_bridge"
CONF_AUTH_KEY = "auth_key"
CONF_IDENTIFIER = "identifier"
CONF_DIMMING = "dimming"
CONF_GATEWAYS = "gateways"
PLATFORMS = ["light"]
VERBOSE = True
| """Constants for the Eaton xComfort Bridge integration."""
domain = 'xcomfort_bridge'
conf_auth_key = 'auth_key'
conf_identifier = 'identifier'
conf_dimming = 'dimming'
conf_gateways = 'gateways'
platforms = ['light']
verbose = True |
#!/usr/bin/env python
"""
https://leetcode.com/problems/merge-sorted-array/description/
Created on 2018-11-16
@author: 'Jiezhi.G@gmail.com'
Reference:
"""
class Solution:
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
... | """
https://leetcode.com/problems/merge-sorted-array/description/
Created on 2018-11-16
@author: 'Jiezhi.G@gmail.com'
Reference:
"""
class Solution:
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:... |
class Card:
def __init__(self, name, team, active):
self.name = name
self.team = team # "teamid :: black=0, team1=1, team2=2, grey=3"
self.active = active # "known=False, unknown=True"
self.toggle = True
def __str__(self):
return "[" + '{:^15}'.format(self.name) + '{:... | class Card:
def __init__(self, name, team, active):
self.name = name
self.team = team
self.active = active
self.toggle = True
def __str__(self):
return '[' + '{:^15}'.format(self.name) + '{:3}'.format(str(self.team)) + '{:6}'.format(str(self.active)) + ']' |
# TODO: #54: DOC
# TODO: provide context managers!
class NetworkBackendNotifications:
""" This interface describes the interaction between the :py:class:`.SimulationManager`,
the :py:class:`.NetworkManager` and the :py:class:`.NetworkBackend`.
"""
#########################################
# ... | class Networkbackendnotifications:
""" This interface describes the interaction between the :py:class:`.SimulationManager`,
the :py:class:`.NetworkManager` and the :py:class:`.NetworkBackend`.
"""
def before_simulation_step(self, simulation_manager, step_cnt, network_backend, emulation_nodes, **kwa... |
class UnknownColumn(Exception):
pass
class HasNoColumns(Exception):
pass
class TableDoesNotExist(Exception):
pass
class TableExists(Exception):
pass
class EmptySet(Exception):
pass
class AmbiguousColumn(Exception):
pass
class UnknownOperator(Exception):
pass
class ColumnMetadat... | class Unknowncolumn(Exception):
pass
class Hasnocolumns(Exception):
pass
class Tabledoesnotexist(Exception):
pass
class Tableexists(Exception):
pass
class Emptyset(Exception):
pass
class Ambiguouscolumn(Exception):
pass
class Unknownoperator(Exception):
pass
class Columnmetadataundefi... |
# Ejercicio 1
# https://leetcode.com/problems/unique-paths-ii/
class Solution:
def uniquePathsWithObstacles(self, obstacleGrid):
if obstacleGrid[0][0] != 0:
return 0
rows, colums = len(obstacleGrid), len(obstacleGrid[0])
dp = []
for i in range(rows):
arr = []
for j in ran... | class Solution:
def unique_paths_with_obstacles(self, obstacleGrid):
if obstacleGrid[0][0] != 0:
return 0
(rows, colums) = (len(obstacleGrid), len(obstacleGrid[0]))
dp = []
for i in range(rows):
arr = []
for j in range(colums):
arr... |
num1 =10
num2 = 20
num3 = 30
num4 = 100
num5 = 'orz'
| num1 = 10
num2 = 20
num3 = 30
num4 = 100
num5 = 'orz' |
latest_block_redis_key = "latest_block_from_chain"
latest_block_hash_redis_key = "latest_blockhash_from_chain"
most_recent_indexed_block_redis_key = "most_recently_indexed_block_from_db"
most_recent_indexed_block_hash_redis_key = "most_recently_indexed_block_hash_from_db"
most_recent_indexed_ipld_block_redis_key = "mos... | latest_block_redis_key = 'latest_block_from_chain'
latest_block_hash_redis_key = 'latest_blockhash_from_chain'
most_recent_indexed_block_redis_key = 'most_recently_indexed_block_from_db'
most_recent_indexed_block_hash_redis_key = 'most_recently_indexed_block_hash_from_db'
most_recent_indexed_ipld_block_redis_key = 'mos... |
def check_i_islarger2(i, last_i):
islarger = i > last_i
last_i = i
return islarger, last_i
def omp_parallel_for_ordered():
sum = 0
is_larger = True
last_i = 0
'omp parallel for schedule(static, 1) ordered'
for i in range(1,100):
ii = i
if 'omp ordered':
tmp_... | def check_i_islarger2(i, last_i):
islarger = i > last_i
last_i = i
return (islarger, last_i)
def omp_parallel_for_ordered():
sum = 0
is_larger = True
last_i = 0
'omp parallel for schedule(static, 1) ordered'
for i in range(1, 100):
ii = i
if 'omp ordered':
(t... |
# Definition for an interval.
class Interval(object):
def __init__(self, s=0, e=0):
self.start = s
self.end = e
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
if len(intervals) <= 1:
... | class Interval(object):
def __init__(self, s=0, e=0):
self.start = s
self.end = e
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
if len(intervals) <= 1:
return intervals
... |
sal_info= dict ()
sal_info={'Austin':911985, 'Dallas': 89999, 'San Jose': 100989, 'Atlanta': 89286,'Portland':101367}
#reassigns the salary for Atlanta
sal_info['Atlanta']= 92340
print (sal_info)
#del sal_info['Atlanta']
#print (sal_info)
#print (sal_info['Atlanta'])
#del sal_info
#sal_info.clear()
#p... | sal_info = dict()
sal_info = {'Austin': 911985, 'Dallas': 89999, 'San Jose': 100989, 'Atlanta': 89286, 'Portland': 101367}
sal_info['Atlanta'] = 92340
print(sal_info)
if 'Seattle' not in sal_info:
sal_info['Seattle'] = 110340
else:
print('key exists')
print(sal_info) |
#This is an exercise program which is reference to Functions and User input
#Initial version
""" Multi line comment
age = input("Enter your age:")
new_age = float(age) + 50
print(new_age)
"""
def age_foo(age):
new_age = float(age) + 50
return new_age
age = input("Enter your age: ")
print(age_fo... | """ Multi line comment
age = input("Enter your age:")
new_age = float(age) + 50
print(new_age)
"""
def age_foo(age):
new_age = float(age) + 50
return new_age
age = input('Enter your age: ')
print(age_foo(age)) |
expected_output = {
"instance": {
"default": {
"vrf": {
"blue": {
"address_family": {
"vpnv4": {
"prefixes": {
"10.144.0.0/24": {
"table_ver... | expected_output = {'instance': {'default': {'vrf': {'blue': {'address_family': {'vpnv4': {'prefixes': {'10.144.0.0/24': {'table_version': '88', 'available_path': '4', 'best_path': '1', 'paths': '4 available, best #1, table blue', 'index': {1: {'next_hop': '10.3.3.3', 'gateway': '10.6.6.6', 'imported_path_from': '12:23:... |
def example_1():
l = [1, 2, 3]
print(l * 5)
print(5 * 'abcd')
def example_2():
board = [['_'] * 3 for i in range(3)]
print(board)
board[1][2] = 'X'
print(board)
def example_3():
weird_board = [['_'] * 3] * 3
print(weird_board)
weird_board[1][2] = '0'
print(weird_board)
... | def example_1():
l = [1, 2, 3]
print(l * 5)
print(5 * 'abcd')
def example_2():
board = [['_'] * 3 for i in range(3)]
print(board)
board[1][2] = 'X'
print(board)
def example_3():
weird_board = [['_'] * 3] * 3
print(weird_board)
weird_board[1][2] = '0'
print(weird_board)
def... |
t = int(input())
for _ in range(t):
s = input()
a = list(s).count('A')
b = list(s).count('B'); #print(a, b)
i = 1
while(i < len(s) - 1):
if s[i] == '.':
start = i
j = i + 1
for j in range(len(s) - 1):
if s[j] != '.':
end = j - 1
break
i = j
else:
... | t = int(input())
for _ in range(t):
s = input()
a = list(s).count('A')
b = list(s).count('B')
i = 1
while i < len(s) - 1:
if s[i] == '.':
start = i
j = i + 1
for j in range(len(s) - 1):
if s[j] != '.':
end = j - 1
... |
# page on website that serves as base for archives.
BASE_URL = \
'https://awebsite.org/index'
# only extract the links that have these strings
# as part of the urls.
BASE_MUST_CONTAIN = '/someword/'
PAGE_MUST_CONTAIN = '/someword/'
# urls to use for testing.
TEST_SINGLE_PAGE_URL = \
'https://awebsite.org/2019... | base_url = 'https://awebsite.org/index'
base_must_contain = '/someword/'
page_must_contain = '/someword/'
test_single_page_url = 'https://awebsite.org/2019'
test_single_page_content = 'https://awebsite.org/2019/experience1'
test_single_page_contains = '/someword/'
aws_region = 'your-region'
db_table = 'your-dynamodb-ta... |
def solve(polymer, rules,values,steps = 10):
for step in range(steps):
new_polymer={}
# Efficiently this can be done with the idea that we do not need to keep the order,
# we just need to represent that if NN -> C then #NN == #NC and #NN == #CN
for key in polymer:
value... | def solve(polymer, rules, values, steps=10):
for step in range(steps):
new_polymer = {}
for key in polymer:
value = polymer[key]
try:
values[rules[key]] += value
except:
values[rules[key]] = value
try:
ne... |
sexo = str(input('digite seu sexo [M/F]: ')).strip().upper()
while sexo not in 'MF':
sexo = str(input('\033[31mdados invalidos.\n\033[mpor favor, informe seu sexo [M/F]: ')).strip().upper()
print(f'sexo {sexo[0]} registrado com sucesso')
| sexo = str(input('digite seu sexo [M/F]: ')).strip().upper()
while sexo not in 'MF':
sexo = str(input('\x1b[31mdados invalidos.\n\x1b[mpor favor, informe seu sexo [M/F]: ')).strip().upper()
print(f'sexo {sexo[0]} registrado com sucesso') |
'''Given a collection of distinct integers, return all possible permutations.
Example:
Input: [1, 2, 3]
Output:
[
[1, 2, 3],
[1, 3, 2],
[2, 1, 3],
[2, 3, 1],
[3, 1, 2],
[3, 2, 1]
]
'''
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rt... | """Given a collection of distinct integers, return all possible permutations.
Example:
Input: [1, 2, 3]
Output:
[
[1, 2, 3],
[1, 3, 2],
[2, 1, 3],
[2, 3, 1],
[3, 1, 2],
[3, 2, 1]
]
"""
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rt... |
WOQL_AND_JSON = {
"@type": "woql:And",
"woql:query_list": [
{
"@type": "woql:QueryListElement",
"woql:index": {"@type": "xsd:nonNegativeInteger", "@value": 0},
"woql:query": {
"@type": "woql:Triple",
"woql:subject": {"@type": "woql:Node... | woql_and_json = {'@type': 'woql:And', 'woql:query_list': [{'@type': 'woql:QueryListElement', 'woql:index': {'@type': 'xsd:nonNegativeInteger', '@value': 0}, 'woql:query': {'@type': 'woql:Triple', 'woql:subject': {'@type': 'woql:Node', 'woql:node': 'doc:a'}, 'woql:predicate': {'@type': 'woql:Node', 'woql:node': 'scm:b'}... |
#Switch database
SPINE_SWITCH_TYPE = ["NX3164Q","NX9332PQ", "NX3132Q", "NX9504", "NX9508", "NX9516"]
LEAF_SWITCH_TYPE = ["NX9372PX", "NX9372TX", "NX9396PX", "NX9396TX", "NX93120TX", "NX93128TX", "NX3172Q"]
#Leaf Switch Interfaces
SWITCH_HOST_IF_MAP = {"NX9372PX":["e1/1", "e1/2", "e1/3", "e1/4", "e1/5","e1/6", "e1... | spine_switch_type = ['NX3164Q', 'NX9332PQ', 'NX3132Q', 'NX9504', 'NX9508', 'NX9516']
leaf_switch_type = ['NX9372PX', 'NX9372TX', 'NX9396PX', 'NX9396TX', 'NX93120TX', 'NX93128TX', 'NX3172Q']
switch_host_if_map = {'NX9372PX': ['e1/1', 'e1/2', 'e1/3', 'e1/4', 'e1/5', 'e1/6', 'e1/7', 'e1/8', 'e1/9', 'e1/10', 'e1/11', 'e1/1... |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | class Secret:
"""Defines Kubernetes Secret Volume"""
def __init__(self, deploy_type, deploy_target, secret, key):
"""Initialize a Kubernetes Secret Object. Used to track requested secrets from
the user.
:param deploy_type: The type of secret deploy in Kubernetes, either `env` or
... |
class Solution:
def XXX(self, nums):
ret = []
path = []
def dfs(li):
if len(li) == len(path):
ret.append(path[:])
for i in li:
if i not in path:
path.append(i)
dfs(li)
path.re... | class Solution:
def xxx(self, nums):
ret = []
path = []
def dfs(li):
if len(li) == len(path):
ret.append(path[:])
for i in li:
if i not in path:
path.append(i)
dfs(li)
path.r... |
# Assignment 1
def assignment_1():
for counter in range (1,11):
print (counter)
# Assignment 2
def assignment_2():
goOn = True
number = 0
half = 0
while(goOn):
print ("Please type a whole number and if you want to end please type 0:")
number = input() # input() method ... | def assignment_1():
for counter in range(1, 11):
print(counter)
def assignment_2():
go_on = True
number = 0
half = 0
while goOn:
print('Please type a whole number and if you want to end please type 0:')
number = input()
print(type(number))
if number == '0':
... |
f = open("mbox.txt")
cnt = 0
for line in f.readlines():
if line.startswith('From'):
print(line.split()[1])
cnt += 1
print ("there was {} people.".format(cnt))
| f = open('mbox.txt')
cnt = 0
for line in f.readlines():
if line.startswith('From'):
print(line.split()[1])
cnt += 1
print('there was {} people.'.format(cnt)) |
# generated from genmsg/cmake/pkg-genmsg.context.in
messages_str = "/xavier_ssd/TrekBot/TrekBot2_WS/src/geographic_info/geographic_msgs/msg/BoundingBox.msg;/xavier_ssd/TrekBot/TrekBot2_WS/src/geographic_info/geographic_msgs/msg/GeographicMapChanges.msg;/xavier_ssd/TrekBot/TrekBot2_WS/src/geographic_info/geographic_msg... | messages_str = '/xavier_ssd/TrekBot/TrekBot2_WS/src/geographic_info/geographic_msgs/msg/BoundingBox.msg;/xavier_ssd/TrekBot/TrekBot2_WS/src/geographic_info/geographic_msgs/msg/GeographicMapChanges.msg;/xavier_ssd/TrekBot/TrekBot2_WS/src/geographic_info/geographic_msgs/msg/GeographicMap.msg;/xavier_ssd/TrekBot/TrekBot2_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.