content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
#!/usr/bin/env python # Use generators to avoid crashed in memory when needed to interate on large set of data # Generators can be built with the syntax of list comprehensions but inside () names = ['Tim', 'Mark', 'Donna', 'Albert', 'Sara'] gen_a = (len(n) for n in names) print(next(gen_a)) print(next(gen_a)) # You define a generator function, using the yield keyword to return a value def my_generator(): names = ['Gianluca', 'Lisa', 'Sofia', 'Giulia'] for i in names: yield i # You define a generator iterator as an instance of the function gen = my_generator() # You call next to generate the next value print(next(gen)) print(next(gen)) # Being the generator an iterator you can use it in a for loop as well # notes that we keep generating from where we left for val in gen: print(val) # Remember: generators are used to generate the next value, # they allow you to iterate over values without having to load them # in memory. That's a key difference from a function where you # only get a chance to return all results all at the same time. # For example: # 1. when you read a file the built in mechanism is a generator # 2. the xrange uses a generator # yield: what it does is save the "state" of a generator function
names = ['Tim', 'Mark', 'Donna', 'Albert', 'Sara'] gen_a = (len(n) for n in names) print(next(gen_a)) print(next(gen_a)) def my_generator(): names = ['Gianluca', 'Lisa', 'Sofia', 'Giulia'] for i in names: yield i gen = my_generator() print(next(gen)) print(next(gen)) for val in gen: print(val)
def largest_product(a_list): if len(a_list) == 0: return False column = 0 row = 0 big = a_list[0][0] * a_list[0][1] while column < len(a_list) - 1: if a_list[column][row] * a_list[column][row + 1] > big: big = a_list[column][row] * a_list[column][row + 1] if a_list[column][row] * a_list[column + 1][row] > big: big = a_list[column][row] * a_list[column + 1][row] if a_list[column][row] * a_list[column + 1][row + 1] > big: big = a_list[column][row] * a_list[column + 1][row + 1] if a_list[column + 1][row] * a_list[column + 1][row + 1]: big = a_list[column + 1][row] * a_list[column + 1][row + 1] if a_list[column][row + 1] * a_list[column + 1][row + 1]: a_list[column][row + 1] * a_list[column + 1][row + 1] column += 1 return big
def largest_product(a_list): if len(a_list) == 0: return False column = 0 row = 0 big = a_list[0][0] * a_list[0][1] while column < len(a_list) - 1: if a_list[column][row] * a_list[column][row + 1] > big: big = a_list[column][row] * a_list[column][row + 1] if a_list[column][row] * a_list[column + 1][row] > big: big = a_list[column][row] * a_list[column + 1][row] if a_list[column][row] * a_list[column + 1][row + 1] > big: big = a_list[column][row] * a_list[column + 1][row + 1] if a_list[column + 1][row] * a_list[column + 1][row + 1]: big = a_list[column + 1][row] * a_list[column + 1][row + 1] if a_list[column][row + 1] * a_list[column + 1][row + 1]: a_list[column][row + 1] * a_list[column + 1][row + 1] column += 1 return big
### Dielectric class class Dielectric: ## Intialization function with all properties def __init__(self, pos_x, pos_y, width, height, eps_r): self.pos_x = pos_x self.pos_y = pos_y self.width = width self.height = height self.eps_r = eps_r ## String representation functions def __str__(self): return "x: {}, y: {}, w: {}, h: {}, eps_r: {}".format( self.pos_x, self.pos_y, self.width, self.height, self.eps_r ) def __repr__(self): return self.__str__()
class Dielectric: def __init__(self, pos_x, pos_y, width, height, eps_r): self.pos_x = pos_x self.pos_y = pos_y self.width = width self.height = height self.eps_r = eps_r def __str__(self): return 'x: {}, y: {}, w: {}, h: {}, eps_r: {}'.format(self.pos_x, self.pos_y, self.width, self.height, self.eps_r) def __repr__(self): return self.__str__()
def ceaser(message): ciphered = "" for c in message: if c.isalpha(): if c.isupper(): upper = True else: upper = False c = c.upper() place = ord(c) if place+13 > 90: place = (place+13 - 90) + 64 else: place = place + 13 if upper: ciphered += chr(place) else: ciphered += chr(place).lower() else: ciphered += c return ciphered
def ceaser(message): ciphered = '' for c in message: if c.isalpha(): if c.isupper(): upper = True else: upper = False c = c.upper() place = ord(c) if place + 13 > 90: place = place + 13 - 90 + 64 else: place = place + 13 if upper: ciphered += chr(place) else: ciphered += chr(place).lower() else: ciphered += c return ciphered
# # PySNMP MIB module CONV-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CONV-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:11:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection") Alias, cxConv = mibBuilder.importSymbols("CXProduct-SMI", "Alias", "cxConv") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") ObjectIdentity, iso, Bits, TimeTicks, Counter32, Counter64, Gauge32, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, Unsigned32, NotificationType, ModuleIdentity, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "iso", "Bits", "TimeTicks", "Counter32", "Counter64", "Gauge32", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "Unsigned32", "NotificationType", "ModuleIdentity", "Integer32") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") cxConvTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1), ) if mibBuilder.loadTexts: cxConvTable.setStatus('mandatory') cxConvEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1), ).setIndexNames((0, "CONV-MIB", "cxConvPort")) if mibBuilder.loadTexts: cxConvEntry.setStatus('mandatory') cxConvPort = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxConvPort.setStatus('mandatory') cxConvPortAlias = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 2), Alias()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvPortAlias.setStatus('mandatory') cxConvRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("invalid", 1), ("valid", 2))).clone('valid')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvRowStatus.setStatus('mandatory') cxConvIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxConvIfIndex.setStatus('mandatory') cxConvState = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('on')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvState.setStatus('mandatory') cxConvCompression = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 6), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvCompression.setStatus('mandatory') cxConvCompCompatibility = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("compatibleMemotec", 1), ("compatibleACC", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvCompCompatibility.setStatus('mandatory') cxFwkCircuitTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2), ) if mibBuilder.loadTexts: cxFwkCircuitTable.setStatus('mandatory') cxFwkCircuitEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1), ).setIndexNames((0, "CONV-MIB", "cxFwkCircuitPort")) if mibBuilder.loadTexts: cxFwkCircuitEntry.setStatus('mandatory') cxFwkCircuitPort = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkCircuitPort.setStatus('mandatory') cxFwkCircuitState = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(256, 1, 2, 3, 4))).clone(namedValues=NamedValues(("idle", 256), ("opened", 1), ("closed", 2), ("opening", 3), ("openFailed", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkCircuitState.setStatus('mandatory') cxFwkCircuitRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("invalid", 1), ("valid", 2))).clone('valid')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkCircuitRowStatus.setStatus('mandatory') cxFwkServiceType = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 256))).clone(namedValues=NamedValues(("frameRelay", 1), ("notSpecified", 256)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceType.setStatus('mandatory') cxFwkServiceProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("cls", 1), ("pvc", 2), ("svc", 3), ("char", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceProtocol.setStatus('mandatory') cxFwkServiceName = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 6), OctetString().subtype(subtypeSpec=ValueSizeConstraint(16, 16)).setFixedLength(16)).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkServiceName.setStatus('mandatory') cxFwkDestAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 7), OctetString().subtype(subtypeSpec=ValueSizeConstraint(20, 20)).setFixedLength(20)).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkDestAddress.setStatus('mandatory') cxFwkDestAlias = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 8), Alias()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkDestAlias.setStatus('mandatory') cxFwkServiceCircuitMdu = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 8192)).clone(1600)).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceCircuitMdu.setStatus('mandatory') cxFwkServiceCost = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1000000))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceCost.setStatus('mandatory') cxFwkServiceCardId = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkServiceCardId.setStatus('mandatory') cxFwkServiceSapId = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 12), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkServiceSapId.setStatus('mandatory') cxFwkServiceRouteRef = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceRouteRef.setStatus('mandatory') cxFwkStatsInternalErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 15), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsInternalErrors.setStatus('mandatory') cxFwkStatsRegistrationErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 16), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsRegistrationErrors.setStatus('mandatory') cxFwkStatsQueryErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 17), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsQueryErrors.setStatus('mandatory') cxFwkStatsOpenErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 18), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsOpenErrors.setStatus('mandatory') cxFwkStatsResets = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 19), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsResets.setStatus('mandatory') mibBuilder.exportSymbols("CONV-MIB", cxConvState=cxConvState, cxConvRowStatus=cxConvRowStatus, cxConvPortAlias=cxConvPortAlias, cxFwkServiceCardId=cxFwkServiceCardId, cxFwkStatsOpenErrors=cxFwkStatsOpenErrors, cxFwkDestAlias=cxFwkDestAlias, cxConvCompCompatibility=cxConvCompCompatibility, cxFwkStatsQueryErrors=cxFwkStatsQueryErrors, cxFwkServiceName=cxFwkServiceName, cxFwkServiceProtocol=cxFwkServiceProtocol, cxFwkDestAddress=cxFwkDestAddress, cxConvEntry=cxConvEntry, cxConvIfIndex=cxConvIfIndex, cxFwkServiceCircuitMdu=cxFwkServiceCircuitMdu, cxFwkServiceCost=cxFwkServiceCost, cxFwkCircuitPort=cxFwkCircuitPort, cxFwkStatsInternalErrors=cxFwkStatsInternalErrors, cxFwkServiceSapId=cxFwkServiceSapId, cxFwkCircuitTable=cxFwkCircuitTable, cxFwkStatsRegistrationErrors=cxFwkStatsRegistrationErrors, cxConvPort=cxConvPort, cxFwkCircuitEntry=cxFwkCircuitEntry, cxFwkCircuitState=cxFwkCircuitState, cxFwkCircuitRowStatus=cxFwkCircuitRowStatus, cxFwkServiceType=cxFwkServiceType, cxFwkStatsResets=cxFwkStatsResets, cxFwkServiceRouteRef=cxFwkServiceRouteRef, cxConvTable=cxConvTable, cxConvCompression=cxConvCompression)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection') (alias, cx_conv) = mibBuilder.importSymbols('CXProduct-SMI', 'Alias', 'cxConv') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (object_identity, iso, bits, time_ticks, counter32, counter64, gauge32, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, unsigned32, notification_type, module_identity, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'ObjectIdentity', 'iso', 'Bits', 'TimeTicks', 'Counter32', 'Counter64', 'Gauge32', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'Unsigned32', 'NotificationType', 'ModuleIdentity', 'Integer32') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') cx_conv_table = mib_table((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1)) if mibBuilder.loadTexts: cxConvTable.setStatus('mandatory') cx_conv_entry = mib_table_row((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1)).setIndexNames((0, 'CONV-MIB', 'cxConvPort')) if mibBuilder.loadTexts: cxConvEntry.setStatus('mandatory') cx_conv_port = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: cxConvPort.setStatus('mandatory') cx_conv_port_alias = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 2), alias()).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxConvPortAlias.setStatus('mandatory') cx_conv_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('invalid', 1), ('valid', 2))).clone('valid')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxConvRowStatus.setStatus('mandatory') cx_conv_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 4), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxConvIfIndex.setStatus('mandatory') cx_conv_state = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('on', 1), ('off', 2))).clone('on')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxConvState.setStatus('mandatory') cx_conv_compression = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 6), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxConvCompression.setStatus('mandatory') cx_conv_comp_compatibility = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('compatibleMemotec', 1), ('compatibleACC', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxConvCompCompatibility.setStatus('mandatory') cx_fwk_circuit_table = mib_table((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2)) if mibBuilder.loadTexts: cxFwkCircuitTable.setStatus('mandatory') cx_fwk_circuit_entry = mib_table_row((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1)).setIndexNames((0, 'CONV-MIB', 'cxFwkCircuitPort')) if mibBuilder.loadTexts: cxFwkCircuitEntry.setStatus('mandatory') cx_fwk_circuit_port = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkCircuitPort.setStatus('mandatory') cx_fwk_circuit_state = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(256, 1, 2, 3, 4))).clone(namedValues=named_values(('idle', 256), ('opened', 1), ('closed', 2), ('opening', 3), ('openFailed', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkCircuitState.setStatus('mandatory') cx_fwk_circuit_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('invalid', 1), ('valid', 2))).clone('valid')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkCircuitRowStatus.setStatus('mandatory') cx_fwk_service_type = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 256))).clone(namedValues=named_values(('frameRelay', 1), ('notSpecified', 256)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkServiceType.setStatus('mandatory') cx_fwk_service_protocol = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('cls', 1), ('pvc', 2), ('svc', 3), ('char', 4)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkServiceProtocol.setStatus('mandatory') cx_fwk_service_name = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 6), octet_string().subtype(subtypeSpec=value_size_constraint(16, 16)).setFixedLength(16)).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkServiceName.setStatus('mandatory') cx_fwk_dest_address = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 7), octet_string().subtype(subtypeSpec=value_size_constraint(20, 20)).setFixedLength(20)).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkDestAddress.setStatus('mandatory') cx_fwk_dest_alias = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 8), alias()).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkDestAlias.setStatus('mandatory') cx_fwk_service_circuit_mdu = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 8192)).clone(1600)).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkServiceCircuitMdu.setStatus('mandatory') cx_fwk_service_cost = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(0, 1000000))).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkServiceCost.setStatus('mandatory') cx_fwk_service_card_id = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 11), integer32().subtype(subtypeSpec=value_range_constraint(1, 16))).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkServiceCardId.setStatus('mandatory') cx_fwk_service_sap_id = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 12), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkServiceSapId.setStatus('mandatory') cx_fwk_service_route_ref = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 13), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: cxFwkServiceRouteRef.setStatus('mandatory') cx_fwk_stats_internal_errors = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 15), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkStatsInternalErrors.setStatus('mandatory') cx_fwk_stats_registration_errors = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 16), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkStatsRegistrationErrors.setStatus('mandatory') cx_fwk_stats_query_errors = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 17), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkStatsQueryErrors.setStatus('mandatory') cx_fwk_stats_open_errors = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 18), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkStatsOpenErrors.setStatus('mandatory') cx_fwk_stats_resets = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 19), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cxFwkStatsResets.setStatus('mandatory') mibBuilder.exportSymbols('CONV-MIB', cxConvState=cxConvState, cxConvRowStatus=cxConvRowStatus, cxConvPortAlias=cxConvPortAlias, cxFwkServiceCardId=cxFwkServiceCardId, cxFwkStatsOpenErrors=cxFwkStatsOpenErrors, cxFwkDestAlias=cxFwkDestAlias, cxConvCompCompatibility=cxConvCompCompatibility, cxFwkStatsQueryErrors=cxFwkStatsQueryErrors, cxFwkServiceName=cxFwkServiceName, cxFwkServiceProtocol=cxFwkServiceProtocol, cxFwkDestAddress=cxFwkDestAddress, cxConvEntry=cxConvEntry, cxConvIfIndex=cxConvIfIndex, cxFwkServiceCircuitMdu=cxFwkServiceCircuitMdu, cxFwkServiceCost=cxFwkServiceCost, cxFwkCircuitPort=cxFwkCircuitPort, cxFwkStatsInternalErrors=cxFwkStatsInternalErrors, cxFwkServiceSapId=cxFwkServiceSapId, cxFwkCircuitTable=cxFwkCircuitTable, cxFwkStatsRegistrationErrors=cxFwkStatsRegistrationErrors, cxConvPort=cxConvPort, cxFwkCircuitEntry=cxFwkCircuitEntry, cxFwkCircuitState=cxFwkCircuitState, cxFwkCircuitRowStatus=cxFwkCircuitRowStatus, cxFwkServiceType=cxFwkServiceType, cxFwkStatsResets=cxFwkStatsResets, cxFwkServiceRouteRef=cxFwkServiceRouteRef, cxConvTable=cxConvTable, cxConvCompression=cxConvCompression)
# 268. Missing Number # Runtime: 132 ms, faster than 76.58% of Python3 online submissions for Missing Number. # Memory Usage: 15.5 MB, less than 51.40% of Python3 online submissions for Missing Number. class Solution: # Gauss' Formula def missingNumber(self, nums: list[int]) -> int: expected_sum = len(nums) * (len(nums) + 1) // 2 return expected_sum - sum(nums)
class Solution: def missing_number(self, nums: list[int]) -> int: expected_sum = len(nums) * (len(nums) + 1) // 2 return expected_sum - sum(nums)
class Solution: def removeOuterParentheses(self, S: str) -> str: res = "" level = 0 start = 0 for i, c in enumerate(S): if c == "(": level += 1 if c == ")": level -= 1 if level == 0: res += S[start + 1 : i] start = i + 1 return res
class Solution: def remove_outer_parentheses(self, S: str) -> str: res = '' level = 0 start = 0 for (i, c) in enumerate(S): if c == '(': level += 1 if c == ')': level -= 1 if level == 0: res += S[start + 1:i] start = i + 1 return res
class Linked_List: class __Node: def __init__(self, val): # declare and initialize the private attributes # for objects of the Node class. # TODO replace pass with your implementation self.val=val self.prev=None self.next=None def __init__(self): # declare and initialize the private attributes # for objects of the sentineled Linked_List class # TODO replace pass with your implementation self.__header = self.__Node(None) self.__trailer = self.__Node(None) self.__header.next = self.__trailer # trailer is after header self.__trailer.prev = self.__header # header is before trailer self.__size = 0 def __len__(self): # return the number of value-containing nodes in # this list. # TODO replace pass with your implementation ##??????SHOULD THIS WALK THROUGH return self.__size def append_element(self, val): # increase the size of the list by one, and add a # node containing val at the new tail position. this # is the only way to add items at the tail position. # TODO replace pass with your implementation new_node = Linked_List.__Node(val) self.__trailer.prev.next = new_node new_node.next=self.__trailer new_node.prev=self.__trailer.prev self.__trailer.prev = new_node self.__size = self.__size + 1 def insert_element_at(self, val, index): # assuming the head position (not the header node) # is indexed 0, add a node containing val at the # specified index. If the index is not a valid # position within the list, raise an IndexError # exception. This method cannot be used to add an # item at the tail position. # TODO replace pass with your implementation if index >= self.__size: raise IndexError if index < 0: raise IndexError new_node = Linked_List.__Node(val) current = self.__header for i in range(0, index): current = current.next new_node.next = current.next new_node.prev = current current.next = new_node new_node.next.prev = new_node self.__size = self.__size + 1 def remove_element_at(self, index): # assuming the head position (not the header node) # is indexed 0, remove and return the value stored # in the node at the specified index. If the index # is invalid, raise an IndexError exception. # TODO replace pass with your implementation if index >= self.__size: raise IndexError if index < 0: raise IndexError if self.__size == 0: raise IndexError current = self.__header for i in range(0, index): current = current.next valremoved=current.next.val current.next=current.next.next current.next.prev=current self.__size = self.__size - 1 return valremoved def get_element_at(self, index): # assuming the head position (not the header node) # is indexed 0, return the value stored in the node # at the specified index, but do not unlink it from # the list. If the specified index is invalid, raise # an IndexError exception. # TODO replace pass with your implementation if index >= self.__size: raise IndexError if index < 0: raise IndexError if self.__size == 0: raise IndexError current = self.__header for i in range(0, index): current = current.next return current.next.val #####CHECK CORRECT SYNTAX FOR THIS def rotate_left(self): # rotate the list left one position. Conceptual indices # should all decrease by one, except for the head, which # should become the tail. For example, if the list is # [ 5, 7, 9, -4 ], this method should alter it to # [ 7, 9, -4, 5 ]. This method should modify the list in # place and must not return a value. # TODO replace pass with your implementation. if self.__size==0: raise IndexError self.__trailer.prev.next = self.__header.next self.__header.next = self.__header.next.next self.__header.next.prev=self.__header self.__trailer.prev.next.prev=self.__trailer.prev self.__trailer.prev.next.next=self.__trailer self.__trailer.prev=self.__trailer.prev.next def __str__(self): # return a string representation of the list's # contents. An empty list should appear as [ ]. # A list with one element should appear as [ 5 ]. # A list with two elements should appear as [ 5, 7 ]. # You may assume that the values stored inside of the # node objects implement the __str__() method, so you # call str(val_object) on them to get their string # representations. # TODO replace pass with your implementation current = self.__header.next stringlist = list() stringlist.append("[") if self.__size==0: stringlist.append(" ") else: while(current != self.__trailer): element = str(current.val) stringlist.append(" " + element) if current.next != self.__trailer: stringlist.append(",") else: stringlist.append(" ") current = current.next stringlist.append("]") stringlist = "".join(stringlist) return stringlist def __iter__(self): # initialize a new attribute for walking through your list # TODO insert your initialization code before the return # statement. do not modify the return statement. self.__iter_index = 0 self.__current = self.__header return self def __next__(self): # using the attribute that you initialized in __iter__(), # fetch the next value and return it. If there are no more # values to fetch, raise a StopIteration exception. # TODO replace pass with your implementation if self.__iter_index == self.__size: raise StopIteration self.__current = self.__current.next self.__iter_index = self.__iter_index + 1 return self.__current.val if __name__ == '__main__': # Your test code should go here. Be sure to look at cases # when the list is empty, when it has one element, and when # it has several elements. Do the indexed methods raise exceptions # when given invalid indices? Do they position items # correctly when given valid indices? Does the string # representation of your list conform to the specified format? # Does removing an element function correctly regardless of that # element's location? Does a for loop iterate through your list # from head to tail? Your writeup should explain why you chose the # test cases. Leave all test cases in your code when submitting. # TODO replace pass with your tests list1 = Linked_List() list1.append_element(5) list1.append_element(6) list1.append_element(3) list1.append_element(-7) print("Original List:") print(list1.__str__()) print("Original Length:") print(list1.__len__()) ##Testing Insert-SHOULD WORK print("Testing Insert With Valid Index") try: list1.insert_element_at(-2, 0) except IndexError: print("Invalid index!!") print("New List:") print(list1.__str__()) print("New Length:") print(list1.__len__()) ##Testing Insert-SHOULD GIVE ERROR print("Testing Insert With Invalid Index") try: list1.insert_element_at(9,7) except IndexError: print("Invalid index!!") print(list1.__str__()) ##Testing Insert-SHOULD GIVE ERROR print("Testing Insert With Invalid Index") try: list1.insert_element_at(9,-1) except IndexError: print("Invalid index!!") print(list1.__str__()) ##Testing Remove-SHOULD WORK print("Testing Remove With Valid Index") try: list1.remove_element_at(2) except: print("Invalid index!!") print("New List:") print(list1.__str__()) print("New Length:") print(list1.__len__()) ##Testing Remove-SHOULD GIVE ERROR print("Testing Remove With Invalid Index") try: list1.remove_element_at(-1) except: print("Invalid index!!") print(list1.__str__()) ##Testing Remove-SHOULD GIVE ERROR print("Testing Remove With Invalid Index") try: list1.remove_element_at(10) except: print("Invalid index!!") print(list1.__str__()) ##Testing Get element at-SHOULD WORK print("Testing Get Element With Valid Index") try: list1.get_element_at(1) except: print("Invalid index!!") print(list1.get_element_at(1)) ##Testing Get element at-SHOULD GIVE ERROR print("Testing Get Element With Invalid Index") try: list1.get_element_at(-1) except: print("Invalid index!!") ##Testing Get element at-SHOULD GIVE ERROR print("Testing Get Element With Invalid Index") try: list1.get_element_at(19) except: print("Invalid index!!") print("Rotate Left Output") list1.rotate_left() print(list1.__str__()) print("Size:") print(list1.__len__()) print("Iterator:") for val in list1: print(val) ##empty list list2 = Linked_List() print("Original List:") print(list2.__str__()) print("Original Length:") print(list2.__len__()) ##testing insert-should give error print("Testing Insert With Invalid Index") try: list2.insert_element_at(9,0) except IndexError: print("Invalid index!!") print(list2.__str__()) ##testing remove-SHOULD GIVE ERROR print("Testing Remove With Invalid Index") try: list2.remove_element_at(1) except: print("Invalid index!!") print(list2.__str__()) ##Testing Get element at-SHOULD GIVE ERROR print("Testing Get Element With Invalid Index") try: list2.get_element_at(0) except: print("Invalid index!!") print(list2.__str__()) print("Trying an incorrect use of rotate left:") try: list2.rotate_left() except IndexError: print("Rotate left doesn't work on an empty list!") list2.append_element(2) list2.append_element(6) list2.append_element(8) print("New List:") print(list2.__str__()) print("New Length:") print(list2.__len__())
class Linked_List: class __Node: def __init__(self, val): self.val = val self.prev = None self.next = None def __init__(self): self.__header = self.__Node(None) self.__trailer = self.__Node(None) self.__header.next = self.__trailer self.__trailer.prev = self.__header self.__size = 0 def __len__(self): return self.__size def append_element(self, val): new_node = Linked_List.__Node(val) self.__trailer.prev.next = new_node new_node.next = self.__trailer new_node.prev = self.__trailer.prev self.__trailer.prev = new_node self.__size = self.__size + 1 def insert_element_at(self, val, index): if index >= self.__size: raise IndexError if index < 0: raise IndexError new_node = Linked_List.__Node(val) current = self.__header for i in range(0, index): current = current.next new_node.next = current.next new_node.prev = current current.next = new_node new_node.next.prev = new_node self.__size = self.__size + 1 def remove_element_at(self, index): if index >= self.__size: raise IndexError if index < 0: raise IndexError if self.__size == 0: raise IndexError current = self.__header for i in range(0, index): current = current.next valremoved = current.next.val current.next = current.next.next current.next.prev = current self.__size = self.__size - 1 return valremoved def get_element_at(self, index): if index >= self.__size: raise IndexError if index < 0: raise IndexError if self.__size == 0: raise IndexError current = self.__header for i in range(0, index): current = current.next return current.next.val def rotate_left(self): if self.__size == 0: raise IndexError self.__trailer.prev.next = self.__header.next self.__header.next = self.__header.next.next self.__header.next.prev = self.__header self.__trailer.prev.next.prev = self.__trailer.prev self.__trailer.prev.next.next = self.__trailer self.__trailer.prev = self.__trailer.prev.next def __str__(self): current = self.__header.next stringlist = list() stringlist.append('[') if self.__size == 0: stringlist.append(' ') else: while current != self.__trailer: element = str(current.val) stringlist.append(' ' + element) if current.next != self.__trailer: stringlist.append(',') else: stringlist.append(' ') current = current.next stringlist.append(']') stringlist = ''.join(stringlist) return stringlist def __iter__(self): self.__iter_index = 0 self.__current = self.__header return self def __next__(self): if self.__iter_index == self.__size: raise StopIteration self.__current = self.__current.next self.__iter_index = self.__iter_index + 1 return self.__current.val if __name__ == '__main__': list1 = linked__list() list1.append_element(5) list1.append_element(6) list1.append_element(3) list1.append_element(-7) print('Original List:') print(list1.__str__()) print('Original Length:') print(list1.__len__()) print('Testing Insert With Valid Index') try: list1.insert_element_at(-2, 0) except IndexError: print('Invalid index!!') print('New List:') print(list1.__str__()) print('New Length:') print(list1.__len__()) print('Testing Insert With Invalid Index') try: list1.insert_element_at(9, 7) except IndexError: print('Invalid index!!') print(list1.__str__()) print('Testing Insert With Invalid Index') try: list1.insert_element_at(9, -1) except IndexError: print('Invalid index!!') print(list1.__str__()) print('Testing Remove With Valid Index') try: list1.remove_element_at(2) except: print('Invalid index!!') print('New List:') print(list1.__str__()) print('New Length:') print(list1.__len__()) print('Testing Remove With Invalid Index') try: list1.remove_element_at(-1) except: print('Invalid index!!') print(list1.__str__()) print('Testing Remove With Invalid Index') try: list1.remove_element_at(10) except: print('Invalid index!!') print(list1.__str__()) print('Testing Get Element With Valid Index') try: list1.get_element_at(1) except: print('Invalid index!!') print(list1.get_element_at(1)) print('Testing Get Element With Invalid Index') try: list1.get_element_at(-1) except: print('Invalid index!!') print('Testing Get Element With Invalid Index') try: list1.get_element_at(19) except: print('Invalid index!!') print('Rotate Left Output') list1.rotate_left() print(list1.__str__()) print('Size:') print(list1.__len__()) print('Iterator:') for val in list1: print(val) list2 = linked__list() print('Original List:') print(list2.__str__()) print('Original Length:') print(list2.__len__()) print('Testing Insert With Invalid Index') try: list2.insert_element_at(9, 0) except IndexError: print('Invalid index!!') print(list2.__str__()) print('Testing Remove With Invalid Index') try: list2.remove_element_at(1) except: print('Invalid index!!') print(list2.__str__()) print('Testing Get Element With Invalid Index') try: list2.get_element_at(0) except: print('Invalid index!!') print(list2.__str__()) print('Trying an incorrect use of rotate left:') try: list2.rotate_left() except IndexError: print("Rotate left doesn't work on an empty list!") list2.append_element(2) list2.append_element(6) list2.append_element(8) print('New List:') print(list2.__str__()) print('New Length:') print(list2.__len__())
which_one = int(input("What Months (1-12)?")) months = ['January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October', 'November' , 'December'] if 1 <= which_one <= 12: print("Months " , months[which_one - 1])
which_one = int(input('What Months (1-12)?')) months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] if 1 <= which_one <= 12: print('Months ', months[which_one - 1])
# Example 1 def setup(): # Set to the same size as the source image # https://unsplash.com/photos/mGy1Jjr2e6M size(900, 600) # Load and display and position the image image(loadImage("file.jpg"), 0, 0)
def setup(): size(900, 600) image(load_image('file.jpg'), 0, 0)
MOUSE_BTN_LEFT = b"\x90" MOUSE_BTN_RIGHT = b"\x91" MOUSE_BTN_MIDDLE = b"\x92" KEY_LEFT_CTRL = b"\xe0" KEY_LEFT_SHIFT = b"\xe1" KEY_LEFT_ALT = b"\xe2" KEY_LEFT_GUI = b"\xe3" KEY_RIGHT_CTRL = b"\xe4" KEY_RIGHT_SHIFT = b"\xe5" KEY_RIGHT_ALT = b"\xe6" KEY_RIGHT_GUI = b"\xe8" KEY_A = b"\x04" KEY_B = b"\x05" KEY_C = b"\x06" KEY_D = b"\x07" KEY_E = b"\x08" KEY_F = b"\x09" KEY_G = b"\x0A" KEY_H = b"\x0B" KEY_I = b"\x0C" KEY_J = b"\x0D" KEY_K = b"\x0E" KEY_L = b"\x0F" KEY_M = b"\x10" KEY_N = b"\x11" KEY_O = b"\x12" KEY_P = b"\x13" KEY_Q = b"\x14" KEY_R = b"\x15" KEY_S = b"\x16" KEY_T = b"\x17" KEY_U = b"\x18" KEY_V = b"\x19" KEY_W = b"\x1A" KEY_X = b"\x1B" KEY_Y = b"\x1C" KEY_Z = b"\x1D" KEY_1 = b"\x1E" KEY_2 = b"\x1F" KEY_3 = b"\x20" KEY_4 = b"\x21" KEY_5 = b"\x22" KEY_6 = b"\x23" KEY_7 = b"\x24" KEY_8 = b"\x25" KEY_9 = b"\x26" KEY_0 = b"\x27" KEY_RETURN = b"\x28" KEY_ENTER = b"\x28" KEY_ESC = b"\x29" KEY_ESCAPE = b"\x29" KEY_BCKSPC = b"\x2A" KEY_BACKSPACE = b"\x2A" KEY_TAB = b"\x2B" KEY_SPACE = b"\x2C" KEY_MINUS = b"\x2D" KEY_DASH = b"\x2D" KEY_EQUALS = b"\x2E" KEY_EQUAL = b"\x2E" KEY_LBRACKET = b"\x2F" KEY_RBRACKET = b"\x30" KEY_BACKSLASH = b"\x31" KEY_HASH = b"\x32" KEY_NUMBER = b"\x32" KEY_SEMICOLON = b"\x33" KEY_QUOTE = b"\x34" KEY_BACKQUOTE = b"\x35" KEY_TILDE = b"\x35" KEY_COMMA = b"\x36" KEY_PERIOD = b"\x37" KEY_STOP = b"\x37" KEY_SLASH = b"\x38" KEY_CAPS_LOCK = b"\x39" KEY_CAPSLOCK = b"\x39" KEY_F1 = b"\x3A" KEY_F2 = b"\x3B" KEY_F3 = b"\x3C" KEY_F4 = b"\x3D" KEY_F5 = b"\x3E" KEY_F6 = b"\x3F" KEY_F7 = b"\x40" KEY_F8 = b"\x41" KEY_F9 = b"\x42" KEY_F10 = b"\x43" KEY_F11 = b"\x44" KEY_F12 = b"\x45" KEY_PRINT = b"\x46" KEY_SCROLL_LOCK = b"\x47" KEY_SCROLLLOCK = b"\x47" KEY_PAUSE = b"\x48" KEY_INSERT = b"\x49" KEY_HOME = b"\x4A" KEY_PAGEUP = b"\x4B" KEY_PGUP = b"\x4B" KEY_DEL = b"\x4C" KEY_DELETE = b"\x4C" KEY_END = b"\x4D" KEY_PAGEDOWN = b"\x4E" KEY_PGDOWN = b"\x4E" KEY_RIGHT = b"\x4F" KEY_LEFT = b"\x50" KEY_DOWN = b"\x51" KEY_UP = b"\x52" KEY_NUM_LOCK = b"\x53" KEY_NUMLOCK = b"\x53" KEY_KP_DIVIDE = b"\x54" KEY_KP_MULTIPLY = b"\x55" KEY_KP_MINUS = b"\x56" KEY_KP_PLUS = b"\x57" KEY_KP_ENTER = b"\x58" KEY_KP_RETURN = b"\x58" KEY_KP_1 = b"\x59" KEY_KP_2 = b"\x5A" KEY_KP_3 = b"\x5B" KEY_KP_4 = b"\x5C" KEY_KP_5 = b"\x5D" KEY_KP_6 = b"\x5E" KEY_KP_7 = b"\x5F" KEY_KP_8 = b"\x60" KEY_KP_9 = b"\x61" KEY_KP_0 = b"\x62" KEY_KP_PERIOD = b"\x63" KEY_KP_STOP = b"\x63" KEY_APPLICATION = b"\x65" KEY_POWER = b"\x66" KEY_KP_EQUALS = b"\x67" KEY_KP_EQUAL = b"\x67" KEY_F13 = b"\x68" KEY_F14 = b"\x69" KEY_F15 = b"\x6A" KEY_F16 = b"\x6B" KEY_F17 = b"\x6C" KEY_F18 = b"\x6D" KEY_F19 = b"\x6E" KEY_F20 = b"\x6F" KEY_F21 = b"\x70" KEY_F22 = b"\x71" KEY_F23 = b"\x72" KEY_F24 = b"\x73" KEY_EXECUTE = b"\x74" KEY_HELP = b"\x75" KEY_MENU = b"\x76" KEY_SELECT = b"\x77" KEY_CANCEL = b"\x78" KEY_REDO = b"\x79" KEY_UNDO = b"\x7A" KEY_CUT = b"\x7B" KEY_COPY = b"\x7C" KEY_PASTE = b"\x7D" KEY_FIND = b"\x7E" KEY_MUTE = b"\x7F" KEY_VOLUME_UP = b"\x80" KEY_VOLUME_DOWN = b"\x81"
mouse_btn_left = b'\x90' mouse_btn_right = b'\x91' mouse_btn_middle = b'\x92' key_left_ctrl = b'\xe0' key_left_shift = b'\xe1' key_left_alt = b'\xe2' key_left_gui = b'\xe3' key_right_ctrl = b'\xe4' key_right_shift = b'\xe5' key_right_alt = b'\xe6' key_right_gui = b'\xe8' key_a = b'\x04' key_b = b'\x05' key_c = b'\x06' key_d = b'\x07' key_e = b'\x08' key_f = b'\t' key_g = b'\n' key_h = b'\x0b' key_i = b'\x0c' key_j = b'\r' key_k = b'\x0e' key_l = b'\x0f' key_m = b'\x10' key_n = b'\x11' key_o = b'\x12' key_p = b'\x13' key_q = b'\x14' key_r = b'\x15' key_s = b'\x16' key_t = b'\x17' key_u = b'\x18' key_v = b'\x19' key_w = b'\x1a' key_x = b'\x1b' key_y = b'\x1c' key_z = b'\x1d' key_1 = b'\x1e' key_2 = b'\x1f' key_3 = b' ' key_4 = b'!' key_5 = b'"' key_6 = b'#' key_7 = b'$' key_8 = b'%' key_9 = b'&' key_0 = b"'" key_return = b'(' key_enter = b'(' key_esc = b')' key_escape = b')' key_bckspc = b'*' key_backspace = b'*' key_tab = b'+' key_space = b',' key_minus = b'-' key_dash = b'-' key_equals = b'.' key_equal = b'.' key_lbracket = b'/' key_rbracket = b'0' key_backslash = b'1' key_hash = b'2' key_number = b'2' key_semicolon = b'3' key_quote = b'4' key_backquote = b'5' key_tilde = b'5' key_comma = b'6' key_period = b'7' key_stop = b'7' key_slash = b'8' key_caps_lock = b'9' key_capslock = b'9' key_f1 = b':' key_f2 = b';' key_f3 = b'<' key_f4 = b'=' key_f5 = b'>' key_f6 = b'?' key_f7 = b'@' key_f8 = b'A' key_f9 = b'B' key_f10 = b'C' key_f11 = b'D' key_f12 = b'E' key_print = b'F' key_scroll_lock = b'G' key_scrolllock = b'G' key_pause = b'H' key_insert = b'I' key_home = b'J' key_pageup = b'K' key_pgup = b'K' key_del = b'L' key_delete = b'L' key_end = b'M' key_pagedown = b'N' key_pgdown = b'N' key_right = b'O' key_left = b'P' key_down = b'Q' key_up = b'R' key_num_lock = b'S' key_numlock = b'S' key_kp_divide = b'T' key_kp_multiply = b'U' key_kp_minus = b'V' key_kp_plus = b'W' key_kp_enter = b'X' key_kp_return = b'X' key_kp_1 = b'Y' key_kp_2 = b'Z' key_kp_3 = b'[' key_kp_4 = b'\\' key_kp_5 = b']' key_kp_6 = b'^' key_kp_7 = b'_' key_kp_8 = b'`' key_kp_9 = b'a' key_kp_0 = b'b' key_kp_period = b'c' key_kp_stop = b'c' key_application = b'e' key_power = b'f' key_kp_equals = b'g' key_kp_equal = b'g' key_f13 = b'h' key_f14 = b'i' key_f15 = b'j' key_f16 = b'k' key_f17 = b'l' key_f18 = b'm' key_f19 = b'n' key_f20 = b'o' key_f21 = b'p' key_f22 = b'q' key_f23 = b'r' key_f24 = b's' key_execute = b't' key_help = b'u' key_menu = b'v' key_select = b'w' key_cancel = b'x' key_redo = b'y' key_undo = b'z' key_cut = b'{' key_copy = b'|' key_paste = b'}' key_find = b'~' key_mute = b'\x7f' key_volume_up = b'\x80' key_volume_down = b'\x81'
x = 6 y = 7 # # Simple if # if x == y: # print(f'{x} is equal to {y}') # else: # print(f'{x} is not equal to {y}') # # Elif # if x > y: # print(f'{x} is bigger to {y}') # elif x == y: # print(f'{x} is equal to {y}') # else: # print(f'{x} is not equal to {y}') # Nested if # if x > 2: # if x <= 10: # print(f'{x} is less than 2 and greater than 10') # and logical operators # if x > 2 and x <= 10: # print(f'{x} is less than 2 and greater than 10') # or logical operators # if x > 2 or x <= 10: # print(f'{x} is less than 2 or greater than 10') # not logical operators # if not(x == y): # print(f'{x} is not equal to {y}') # Creating Simple List numbers = [1, 2, 3, 4, 5] # in # if x in numbers: # print(x in numbers) # not in # if x not in numbers: # print(x in numbers) # Identity Operators if x is y: print(x is y) if x is not y: print(x is y) if x is not y: print(x is not y)
x = 6 y = 7 numbers = [1, 2, 3, 4, 5] if x is y: print(x is y) if x is not y: print(x is y) if x is not y: print(x is not y)
# https://leetcode.com/problems/max-consecutive-ones class Solution: def findMaxConsecutiveOnes(self, nums): is_consec = False cnt, ans = 0, 0 for i in range(len(nums)): if (nums[i] == 1) and is_consec: cnt += 1 ans = max(ans, cnt) elif (nums[i] == 1) and (not is_consec): is_consec = True cnt = 1 ans = max(ans, cnt) else: is_consec = False return ans
class Solution: def find_max_consecutive_ones(self, nums): is_consec = False (cnt, ans) = (0, 0) for i in range(len(nums)): if nums[i] == 1 and is_consec: cnt += 1 ans = max(ans, cnt) elif nums[i] == 1 and (not is_consec): is_consec = True cnt = 1 ans = max(ans, cnt) else: is_consec = False return ans
a = 1 b = 2 print('a = ' + str(a) + ',' + 'b = ' + str(b)) temp = a a = b b = temp print('a = ' + str(a) + ',' + 'b = ' + str(b))
a = 1 b = 2 print('a = ' + str(a) + ',' + 'b = ' + str(b)) temp = a a = b b = temp print('a = ' + str(a) + ',' + 'b = ' + str(b))
THRESHOLD = 4 HEADER = '<?xml version="1.0" encoding="utf-8"?>\n\t<output>\n' FOOTER = '\t</output>\n' valMap = { '<': '', '>': '', '&': '', '\"': '' } keyMap = { '~': '', '`': '', '!': '', '@': '', '$': '', '%': '', '^': '', '&': '', '*': '', '(': '', ')': '', '+': '', '=': '', '{': '', '}': '', '[': '', ']': '', '\'': '', '|': '', '\"': '', ';': '', '?': '', '<': '', '>': '', '/': '', ',': '', ' ': '', '#': '_', u'\u2103': u'\u5ea6' }
threshold = 4 header = '<?xml version="1.0" encoding="utf-8"?>\n\t<output>\n' footer = '\t</output>\n' val_map = {'<': '', '>': '', '&': '', '"': ''} key_map = {'~': '', '`': '', '!': '', '@': '', '$': '', '%': '', '^': '', '&': '', '*': '', '(': '', ')': '', '+': '', '=': '', '{': '', '}': '', '[': '', ']': '', "'": '', '|': '', '"': '', ';': '', '?': '', '<': '', '>': '', '/': '', ',': '', ' ': '', '#': '_', u'℃': u'度'}
# Whitelist of generated features in dev STATUS for quicker execution TSFRESH_FEATURE_WHITELIST = [ 'agg_autocorrelation', 'autocorrelation', 'mean', 'mean_change', 'median', 'standard_deviation', 'variance', 'minimum', ] # Size of the time-windows used for generating single time-series TSFRESH_TIME_WINDOWS = 14
tsfresh_feature_whitelist = ['agg_autocorrelation', 'autocorrelation', 'mean', 'mean_change', 'median', 'standard_deviation', 'variance', 'minimum'] tsfresh_time_windows = 14
# # solver_porting.py # # Description: # Hard code the solution values from the paper # Sin-Chung Chang, # "The Method of Space-Time Conservation Element # and Solution Element - A New Approach for Solving the Navier-Stokes # and Euler Equations", # Journal of Computational Physics, Volume 119, # Issue 2, July 1995, Pages 295-324. # # These values are caculated my python program ported from the # demo example written in fortran in the paper above. # # These two functions generated from the same python program # but one with high precision. # def get_specific_solution_for_unit_test(): solution_porting = [ (-0.505000, 1.000000, 0.000000, 1.000000), (-0.495000, 1.000000, 0.000000, 1.000000), (-0.485000, 1.000000, 0.000000, 1.000000), (-0.475000, 1.000000, 0.000000, 1.000000), (-0.465000, 1.000000, 0.000000, 1.000000), (-0.455000, 1.000000, 0.000000, 1.000000), (-0.445000, 1.000000, 0.000000, 1.000000), (-0.435000, 1.000000, 0.000000, 1.000000), (-0.425000, 1.000000, 0.000000, 1.000000), (-0.415000, 1.000000, 0.000000, 1.000000), (-0.405000, 1.000000, 0.000000, 1.000000), (-0.395000, 1.000000, 0.000000, 1.000000), (-0.385000, 1.000000, 0.000000, 1.000000), (-0.375000, 1.000000, 0.000000, 1.000000), (-0.365000, 1.000000, 0.000000, 1.000000), (-0.355000, 1.000000, 0.000000, 1.000000), (-0.345000, 1.000000, 0.000000, 1.000000), (-0.335000, 1.000000, 0.000000, 1.000000), (-0.325000, 1.000000, 0.000000, 1.000000), (-0.315000, 1.000000, 0.000001, 0.999990), (-0.305000, 0.999996, 0.000004, 0.999990), (-0.295000, 0.999976, 0.000028, 0.999960), (-0.285000, 0.999871, 0.000153, 0.999810), (-0.275000, 0.999414, 0.000694, 0.999170), (-0.265000, 0.997818, 0.002584, 0.996940), (-0.255000, 0.993421, 0.007803, 0.990800), (-0.245000, 0.983967, 0.019086, 0.977630), (-0.235000, 0.967934, 0.038418, 0.955410), (-0.225000, 0.945706, 0.065654, 0.924830), (-0.215000, 0.919136, 0.098909, 0.888630), (-0.205000, 0.890232, 0.135996, 0.849670), (-0.195000, 0.860418, 0.175310, 0.809950), (-0.185000, 0.830502, 0.215915, 0.770550), (-0.175000, 0.800906, 0.257311, 0.732020), (-0.165000, 0.771847, 0.299228, 0.694620), (-0.155000, 0.743447, 0.341510, 0.658480), (-0.145000, 0.715776, 0.384050, 0.623660), (-0.135000, 0.688881, 0.426769, 0.590190), (-0.125000, 0.662794, 0.469599, 0.558070), (-0.115000, 0.637537, 0.512474, 0.527300), (-0.105000, 0.613125, 0.555333, 0.497870), (-0.095000, 0.589570, 0.598112, 0.469770), (-0.085000, 0.566880, 0.640745, 0.442980), (-0.075000, 0.545061, 0.683162, 0.417490), (-0.065000, 0.524125, 0.725267, 0.393290), (-0.055000, 0.504121, 0.766883, 0.370400), (-0.045000, 0.485219, 0.807533, 0.349020), (-0.035000, 0.467990, 0.845786, 0.329740), (-0.025000, 0.453912, 0.877936, 0.314190), (-0.015000, 0.445312, 0.897992, 0.304800), (-0.005000, 0.442658, 0.904249, 0.301940), ( 0.005000, 0.442772, 0.904002, 0.302070), ( 0.015000, 0.444581, 0.899744, 0.304060), ( 0.025000, 0.446652, 0.894841, 0.306330), ( 0.035000, 0.447224, 0.893443, 0.306970), ( 0.045000, 0.447163, 0.893599, 0.306900), ( 0.055000, 0.446890, 0.894281, 0.306590), ( 0.065000, 0.446835, 0.894505, 0.306480), ( 0.075000, 0.446873, 0.894351, 0.306550), ( 0.085000, 0.446797, 0.894104, 0.306670), ( 0.095000, 0.446632, 0.893997, 0.306740), ( 0.105000, 0.446665, 0.893903, 0.306780), ( 0.115000, 0.447449, 0.893828, 0.306790), ( 0.125000, 0.448803, 0.893843, 0.306710), ( 0.135000, 0.449307, 0.893970, 0.306610), ( 0.145000, 0.446953, 0.894360, 0.306550), ( 0.155000, 0.424999, 0.896761, 0.306480), ( 0.165000, 0.376460, 0.902293, 0.306370), ( 0.175000, 0.323083, 0.908606, 0.306320), ( 0.185000, 0.283863, 0.913549, 0.306240), ( 0.195000, 0.263120, 0.916182, 0.306270), ( 0.205000, 0.255465, 0.916996, 0.306250), ( 0.215000, 0.253829, 0.917267, 0.306240), ( 0.225000, 0.253852, 0.917300, 0.306280), ( 0.235000, 0.254354, 0.917099, 0.306320), ( 0.245000, 0.254848, 0.917298, 0.306330), ( 0.255000, 0.255146, 0.917121, 0.306240), ( 0.265000, 0.255278, 0.916872, 0.306210), ( 0.275000, 0.255309, 0.917358, 0.306380), ( 0.285000, 0.255084, 0.917145, 0.306250), ( 0.295000, 0.255001, 0.916996, 0.306300), ( 0.305000, 0.255013, 0.917194, 0.306380), ( 0.315000, 0.254891, 0.917686, 0.306140), ( 0.325000, 0.254764, 0.917755, 0.306050), ( 0.335000, 0.254647, 0.917552, 0.306570), ( 0.345000, 0.257049, 0.921870, 0.308520), ( 0.355000, 0.246171, 0.878439, 0.292370), ( 0.365000, 0.133610, 0.075640, 0.110350), ( 0.375000, 0.125018, 0.000152, 0.100020), ( 0.385000, 0.125000, 0.000000, 0.100000), ( 0.395000, 0.125000, 0.000000, 0.100000), ( 0.405000, 0.125000, 0.000000, 0.100000), ( 0.415000, 0.125000, 0.000000, 0.100000), ( 0.425000, 0.125000, 0.000000, 0.100000), ( 0.435000, 0.125000, 0.000000, 0.100000), ( 0.445000, 0.125000, 0.000000, 0.100000), ( 0.455000, 0.125000, 0.000000, 0.100000), ( 0.465000, 0.125000, 0.000000, 0.100000), ( 0.475000, 0.125000, 0.000000, 0.100000), ( 0.485000, 0.125000, 0.000000, 0.100000), ( 0.495000, 0.125000, 0.000000, 0.100000), ( 0.505000, 0.125000, 0.000000, 0.100000) ] return solution_porting def get_specific_solution_for_unit_test_high_precision(): solution_porting = [ (-0.505, 1.0, 0.0, 1.0), (-0.495, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.48499999999999999, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.47499999999999998, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.46499999999999997, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.45499999999999996, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.44499999999999995, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.43499999999999994, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.42499999999999993, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.41499999999999992, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.40499999999999992, 1.0, 1.1102230246251565e-16, 0.99999999999999978), (-0.39499999999999991, 0.99999999999999978, 2.7755575615628918e-16, 0.99999999999999944), (-0.3849999999999999, 0.99999999999999467, 6.4670491184415716e-15, 0.99999999999999234), (-0.37499999999999989, 0.99999999999988776, 1.3308798507695558e-13, 0.99999999999984257), (-0.36499999999999988, 0.99999999999795142, 2.4237278850641443e-12, 0.99999999999713185), (-0.35499999999999987, 0.99999999996762634, 3.8304831530130371e-11, 0.99999999995467714), (-0.34499999999999986, 0.9999999995562131, 5.2509580040759933e-10, 0.99999999937869855), (-0.33499999999999985, 0.99999999472607115, 6.2401971419523565e-09, 0.99999999261649919), (-0.32499999999999984, 0.99999994577382079, 6.4161282047119177e-08, 0.99999992408334937), (-0.31499999999999984, 0.99999951928196795, 5.6879332200680462e-07, 0.99999932699485283), (-0.30499999999999983, 0.99999634481101307, 4.3248824814959905e-06, 0.99999488274087778), (-0.29499999999999982, 0.99997633737099978, 2.79981985962474e-05, 0.99996687254024597), (-0.28499999999999981, 0.99987088139365798, 0.00015278136209548727, 0.99981924026677849), (-0.2749999999999998, 0.99941378043705476, 0.00069375744886315566, 0.99917941692171297), (-0.26499999999999979, 0.99781788235911262, 0.0025838519965398011, 0.99694667070431586), (-0.25499999999999978, 0.99342121495457225, 0.0078025845316690946, 0.99080377644372952), (-0.24499999999999977, 0.98396664008085244, 0.019085577438586857, 0.97763274444798665), (-0.23499999999999976, 0.96793363368888941, 0.038418196061865424, 0.95541204434804472), (-0.22499999999999976, 0.94570644798043035, 0.065654265643744547, 0.92483779493022644), (-0.21499999999999975, 0.91913571997302768, 0.098909427615020667, 0.88863525073537986), (-0.20499999999999974, 0.89023221601523495, 0.13599566576005953, 0.84967793214624232), (-0.19499999999999973, 0.86041780219813813, 0.17531012301721785, 0.80995068909265133), (-0.18499999999999972, 0.8305020195811702, 0.21591521730211277, 0.77055070706890127), (-0.17499999999999971, 0.8009056282617506, 0.25731095878337934, 0.7320223185641187), (-0.1649999999999997, 0.77184714843620994, 0.29922837596343643, 0.69462654528961598), (-0.15499999999999969, 0.74344677036077855, 0.34150984863445688, 0.6584888001930933), (-0.14499999999999968, 0.71577615716384058, 0.3840502790961422, 0.62366900266734182), (-0.13499999999999968, 0.68888144418494501, 0.42676943038587994, 0.59019377200083745), (-0.12499999999999968, 0.6627941455413211, 0.46959860870295073, 0.55807162556304857), (-0.11499999999999969, 0.63753660526589484, 0.51247390933368231, 0.52730052843980701), (-0.10499999999999969, 0.61312484769809938, 0.55533265985338043, 0.49787180099864842), (-0.094999999999999696, 0.58957011850181684, 0.59811153812036699, 0.4697721936664796), (-0.084999999999999701, 0.56688001778671482, 0.64074509894323095, 0.44298533199781343), (-0.074999999999999706, 0.54506080995274542, 0.68316169419725314, 0.41749444939192293), (-0.064999999999999711, 0.52412533713855136, 0.72526708274475149, 0.39329151342581087), (-0.054999999999999709, 0.50412059320145031, 0.7668829674339982, 0.3704086642557895), (-0.044999999999999707, 0.48521942621212033, 0.8075325790323119, 0.34902157047542365), (-0.034999999999999705, 0.46798952801415838, 0.84578618076008127, 0.32974685351833127), (-0.024999999999999703, 0.4539124843363786, 0.87793571859933139, 0.3141914269987745), (-0.014999999999999703, 0.4453117097494409, 0.8979921479041113, 0.3048070144768753), (-0.0049999999999997026, 0.44265849796839962, 0.90424912589460049, 0.30194110396148455), (0.0050000000000002976, 0.44277152604102954, 0.90400167161754941, 0.30207396109955731), (0.015000000000000298, 0.44458074109625789, 0.89974424674017883, 0.30406154478259872), (0.0250000000000003, 0.44665186574379889, 0.89484127842442829, 0.30633620659817651), (0.035000000000000302, 0.44722415984760716, 0.89344336715923944, 0.3069767246505235), (0.045000000000000304, 0.44716266478033079, 0.89359856206472299, 0.30690395534340742), (0.055000000000000306, 0.44689000763788234, 0.89428145391403135, 0.30659011440665951), (0.065000000000000308, 0.44683455389593113, 0.89450478975743941, 0.30648208370927321), (0.075000000000000303, 0.44687343951557484, 0.89435080463668515, 0.30655575368395022), (0.085000000000000298, 0.44679662179222007, 0.89410446777149932, 0.30667701988019136), (0.095000000000000293, 0.44663194699514586, 0.89399670954746402, 0.3067426275793218), (0.10500000000000029, 0.44666498067017296, 0.8939032368159131, 0.30678067827130739), (0.11500000000000028, 0.44744939615633389, 0.8938283386254392, 0.30679034686021484), (0.12500000000000028, 0.44880262918560282, 0.89384265926379181, 0.30671165608649037), (0.13500000000000029, 0.44930671664614646, 0.8939701751341157, 0.30661316478296419), (0.1450000000000003, 0.44695294693653559, 0.89436014525089413, 0.30655123374810866), (0.1550000000000003, 0.42499884313690589, 0.8967607749926938, 0.30648056991207406), (0.16500000000000031, 0.37646019200020114, 0.90229316109419666, 0.3063749421769546), (0.17500000000000032, 0.32308346953859418, 0.9086059712367901, 0.30632068302060489), (0.18500000000000033, 0.28386306263008648, 0.91354863178497869, 0.30624468303654856), (0.19500000000000034, 0.26312012485796243, 0.91618236506234674, 0.30627926864421728), (0.20500000000000035, 0.25546475796037754, 0.91699628286383128, 0.30625564741653527), (0.21500000000000036, 0.25382887050832692, 0.91726748768940347, 0.30624466686916185), (0.22500000000000037, 0.25385244118957323, 0.91730025383922331, 0.30628818557740017), (0.23500000000000038, 0.25435421897952837, 0.91709938305572969, 0.30632175500661168), (0.24500000000000038, 0.25484785803655347, 0.91729763126993402, 0.30633152306973305), (0.25500000000000039, 0.25514629256535842, 0.91712073191552634, 0.30624259391310038), (0.2650000000000004, 0.25527804138560317, 0.91687215887997642, 0.30621371074195036), (0.27500000000000041, 0.2553086860042269, 0.9173579272884218, 0.306381349096989), (0.28500000000000042, 0.25508421322101449, 0.91714513017949251, 0.30625145391872971), (0.29500000000000043, 0.25500112971314676, 0.91699589381745272, 0.30630793033357473), (0.30500000000000044, 0.25501325412451314, 0.91719423148529511, 0.30637974594764761), (0.31500000000000045, 0.2548911547607271, 0.91768611502897424, 0.30614465035840854), (0.32500000000000046, 0.2547644714837658, 0.91775514645688094, 0.30605138955358835), (0.33500000000000046, 0.2546465556459554, 0.91755181317584589, 0.30657038190930797), (0.34500000000000047, 0.25704850786977601, 0.92186989259160956, 0.3085287750393364), (0.35500000000000048, 0.24617054290848731, 0.8784393859773485, 0.29236958085661585), (0.36500000000000049, 0.13360953118193081, 0.07564047374232051, 0.11035282175804639), (0.3750000000000005, 0.12501790423176928, 0.00015158938150652916, 0.10002005518613435), (0.38500000000000051, 0.12500002915548108, 2.4684206810964962e-07, 0.1000000326541411), (0.39500000000000052, 0.12500000004718731, 3.9950684412222107e-10, 0.10000000005284979), (0.40500000000000053, 0.12500000000007638, 6.4678817857060536e-13, 0.10000000000008555), (0.41500000000000054, 0.12500000000000014, 1.0269562977782686e-15, 0.10000000000000016), (0.42500000000000054, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.43500000000000055, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.44500000000000056, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.45500000000000057, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.46500000000000058, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.47500000000000059, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.4850000000000006, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.49500000000000061, 0.125, 8.3266726846886741e-17, 0.10000000000000002), (0.50500000000000056, 0.125, 0.0, 0.10000000000000001)] return solution_porting
def get_specific_solution_for_unit_test(): solution_porting = [(-0.505, 1.0, 0.0, 1.0), (-0.495, 1.0, 0.0, 1.0), (-0.485, 1.0, 0.0, 1.0), (-0.475, 1.0, 0.0, 1.0), (-0.465, 1.0, 0.0, 1.0), (-0.455, 1.0, 0.0, 1.0), (-0.445, 1.0, 0.0, 1.0), (-0.435, 1.0, 0.0, 1.0), (-0.425, 1.0, 0.0, 1.0), (-0.415, 1.0, 0.0, 1.0), (-0.405, 1.0, 0.0, 1.0), (-0.395, 1.0, 0.0, 1.0), (-0.385, 1.0, 0.0, 1.0), (-0.375, 1.0, 0.0, 1.0), (-0.365, 1.0, 0.0, 1.0), (-0.355, 1.0, 0.0, 1.0), (-0.345, 1.0, 0.0, 1.0), (-0.335, 1.0, 0.0, 1.0), (-0.325, 1.0, 0.0, 1.0), (-0.315, 1.0, 1e-06, 0.99999), (-0.305, 0.999996, 4e-06, 0.99999), (-0.295, 0.999976, 2.8e-05, 0.99996), (-0.285, 0.999871, 0.000153, 0.99981), (-0.275, 0.999414, 0.000694, 0.99917), (-0.265, 0.997818, 0.002584, 0.99694), (-0.255, 0.993421, 0.007803, 0.9908), (-0.245, 0.983967, 0.019086, 0.97763), (-0.235, 0.967934, 0.038418, 0.95541), (-0.225, 0.945706, 0.065654, 0.92483), (-0.215, 0.919136, 0.098909, 0.88863), (-0.205, 0.890232, 0.135996, 0.84967), (-0.195, 0.860418, 0.17531, 0.80995), (-0.185, 0.830502, 0.215915, 0.77055), (-0.175, 0.800906, 0.257311, 0.73202), (-0.165, 0.771847, 0.299228, 0.69462), (-0.155, 0.743447, 0.34151, 0.65848), (-0.145, 0.715776, 0.38405, 0.62366), (-0.135, 0.688881, 0.426769, 0.59019), (-0.125, 0.662794, 0.469599, 0.55807), (-0.115, 0.637537, 0.512474, 0.5273), (-0.105, 0.613125, 0.555333, 0.49787), (-0.095, 0.58957, 0.598112, 0.46977), (-0.085, 0.56688, 0.640745, 0.44298), (-0.075, 0.545061, 0.683162, 0.41749), (-0.065, 0.524125, 0.725267, 0.39329), (-0.055, 0.504121, 0.766883, 0.3704), (-0.045, 0.485219, 0.807533, 0.34902), (-0.035, 0.46799, 0.845786, 0.32974), (-0.025, 0.453912, 0.877936, 0.31419), (-0.015, 0.445312, 0.897992, 0.3048), (-0.005, 0.442658, 0.904249, 0.30194), (0.005, 0.442772, 0.904002, 0.30207), (0.015, 0.444581, 0.899744, 0.30406), (0.025, 0.446652, 0.894841, 0.30633), (0.035, 0.447224, 0.893443, 0.30697), (0.045, 0.447163, 0.893599, 0.3069), (0.055, 0.44689, 0.894281, 0.30659), (0.065, 0.446835, 0.894505, 0.30648), (0.075, 0.446873, 0.894351, 0.30655), (0.085, 0.446797, 0.894104, 0.30667), (0.095, 0.446632, 0.893997, 0.30674), (0.105, 0.446665, 0.893903, 0.30678), (0.115, 0.447449, 0.893828, 0.30679), (0.125, 0.448803, 0.893843, 0.30671), (0.135, 0.449307, 0.89397, 0.30661), (0.145, 0.446953, 0.89436, 0.30655), (0.155, 0.424999, 0.896761, 0.30648), (0.165, 0.37646, 0.902293, 0.30637), (0.175, 0.323083, 0.908606, 0.30632), (0.185, 0.283863, 0.913549, 0.30624), (0.195, 0.26312, 0.916182, 0.30627), (0.205, 0.255465, 0.916996, 0.30625), (0.215, 0.253829, 0.917267, 0.30624), (0.225, 0.253852, 0.9173, 0.30628), (0.235, 0.254354, 0.917099, 0.30632), (0.245, 0.254848, 0.917298, 0.30633), (0.255, 0.255146, 0.917121, 0.30624), (0.265, 0.255278, 0.916872, 0.30621), (0.275, 0.255309, 0.917358, 0.30638), (0.285, 0.255084, 0.917145, 0.30625), (0.295, 0.255001, 0.916996, 0.3063), (0.305, 0.255013, 0.917194, 0.30638), (0.315, 0.254891, 0.917686, 0.30614), (0.325, 0.254764, 0.917755, 0.30605), (0.335, 0.254647, 0.917552, 0.30657), (0.345, 0.257049, 0.92187, 0.30852), (0.355, 0.246171, 0.878439, 0.29237), (0.365, 0.13361, 0.07564, 0.11035), (0.375, 0.125018, 0.000152, 0.10002), (0.385, 0.125, 0.0, 0.1), (0.395, 0.125, 0.0, 0.1), (0.405, 0.125, 0.0, 0.1), (0.415, 0.125, 0.0, 0.1), (0.425, 0.125, 0.0, 0.1), (0.435, 0.125, 0.0, 0.1), (0.445, 0.125, 0.0, 0.1), (0.455, 0.125, 0.0, 0.1), (0.465, 0.125, 0.0, 0.1), (0.475, 0.125, 0.0, 0.1), (0.485, 0.125, 0.0, 0.1), (0.495, 0.125, 0.0, 0.1), (0.505, 0.125, 0.0, 0.1)] return solution_porting def get_specific_solution_for_unit_test_high_precision(): solution_porting = [(-0.505, 1.0, 0.0, 1.0), (-0.495, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.485, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.475, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.46499999999999997, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.45499999999999996, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.44499999999999995, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.43499999999999994, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.42499999999999993, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.4149999999999999, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.4049999999999999, 1.0, 1.1102230246251565e-16, 0.9999999999999998), (-0.3949999999999999, 0.9999999999999998, 2.775557561562892e-16, 0.9999999999999994), (-0.3849999999999999, 0.9999999999999947, 6.4670491184415716e-15, 0.9999999999999923), (-0.3749999999999999, 0.9999999999998878, 1.3308798507695558e-13, 0.9999999999998426), (-0.3649999999999999, 0.9999999999979514, 2.4237278850641443e-12, 0.9999999999971318), (-0.35499999999999987, 0.9999999999676263, 3.830483153013037e-11, 0.9999999999546771), (-0.34499999999999986, 0.9999999995562131, 5.250958004075993e-10, 0.9999999993786985), (-0.33499999999999985, 0.9999999947260712, 6.2401971419523565e-09, 0.9999999926164992), (-0.32499999999999984, 0.9999999457738208, 6.416128204711918e-08, 0.9999999240833494), (-0.31499999999999984, 0.999999519281968, 5.687933220068046e-07, 0.9999993269948528), (-0.3049999999999998, 0.9999963448110131, 4.3248824814959905e-06, 0.9999948827408778), (-0.2949999999999998, 0.9999763373709998, 2.79981985962474e-05, 0.999966872540246), (-0.2849999999999998, 0.999870881393658, 0.00015278136209548727, 0.9998192402667785), (-0.2749999999999998, 0.9994137804370548, 0.0006937574488631557, 0.999179416921713), (-0.2649999999999998, 0.9978178823591126, 0.002583851996539801, 0.9969466707043159), (-0.2549999999999998, 0.9934212149545723, 0.007802584531669095, 0.9908037764437295), (-0.24499999999999977, 0.9839666400808524, 0.019085577438586857, 0.9776327444479866), (-0.23499999999999976, 0.9679336336888894, 0.038418196061865424, 0.9554120443480447), (-0.22499999999999976, 0.9457064479804304, 0.06565426564374455, 0.9248377949302264), (-0.21499999999999975, 0.9191357199730277, 0.09890942761502067, 0.8886352507353799), (-0.20499999999999974, 0.890232216015235, 0.13599566576005953, 0.8496779321462423), (-0.19499999999999973, 0.8604178021981381, 0.17531012301721785, 0.8099506890926513), (-0.18499999999999972, 0.8305020195811702, 0.21591521730211277, 0.7705507070689013), (-0.1749999999999997, 0.8009056282617506, 0.25731095878337934, 0.7320223185641187), (-0.1649999999999997, 0.7718471484362099, 0.29922837596343643, 0.694626545289616), (-0.1549999999999997, 0.7434467703607786, 0.3415098486344569, 0.6584888001930933), (-0.14499999999999968, 0.7157761571638406, 0.3840502790961422, 0.6236690026673418), (-0.13499999999999968, 0.688881444184945, 0.42676943038587994, 0.5901937720008374), (-0.12499999999999968, 0.6627941455413211, 0.4695986087029507, 0.5580716255630486), (-0.11499999999999969, 0.6375366052658948, 0.5124739093336823, 0.527300528439807), (-0.10499999999999969, 0.6131248476980994, 0.5553326598533804, 0.4978718009986484), (-0.0949999999999997, 0.5895701185018168, 0.598111538120367, 0.4697721936664796), (-0.0849999999999997, 0.5668800177867148, 0.640745098943231, 0.4429853319978134), (-0.0749999999999997, 0.5450608099527454, 0.6831616941972531, 0.41749444939192293), (-0.06499999999999971, 0.5241253371385514, 0.7252670827447515, 0.39329151342581087), (-0.05499999999999971, 0.5041205932014503, 0.7668829674339982, 0.3704086642557895), (-0.04499999999999971, 0.48521942621212033, 0.8075325790323119, 0.34902157047542365), (-0.034999999999999705, 0.4679895280141584, 0.8457861807600813, 0.3297468535183313), (-0.024999999999999703, 0.4539124843363786, 0.8779357185993314, 0.3141914269987745), (-0.014999999999999703, 0.4453117097494409, 0.8979921479041113, 0.3048070144768753), (-0.004999999999999703, 0.4426584979683996, 0.9042491258946005, 0.30194110396148455), (0.005000000000000298, 0.44277152604102954, 0.9040016716175494, 0.3020739610995573), (0.015000000000000298, 0.4445807410962579, 0.8997442467401788, 0.3040615447825987), (0.0250000000000003, 0.4466518657437989, 0.8948412784244283, 0.3063362065981765), (0.0350000000000003, 0.44722415984760716, 0.8934433671592394, 0.3069767246505235), (0.045000000000000304, 0.4471626647803308, 0.893598562064723, 0.3069039553434074), (0.055000000000000306, 0.44689000763788234, 0.8942814539140314, 0.3065901144066595), (0.06500000000000031, 0.44683455389593113, 0.8945047897574394, 0.3064820837092732), (0.0750000000000003, 0.44687343951557484, 0.8943508046366851, 0.3065557536839502), (0.0850000000000003, 0.44679662179222007, 0.8941044677714993, 0.30667701988019136), (0.09500000000000029, 0.44663194699514586, 0.893996709547464, 0.3067426275793218), (0.10500000000000029, 0.44666498067017296, 0.8939032368159131, 0.3067806782713074), (0.11500000000000028, 0.4474493961563339, 0.8938283386254392, 0.30679034686021484), (0.12500000000000028, 0.4488026291856028, 0.8938426592637918, 0.30671165608649037), (0.1350000000000003, 0.44930671664614646, 0.8939701751341157, 0.3066131647829642), (0.1450000000000003, 0.4469529469365356, 0.8943601452508941, 0.30655123374810866), (0.1550000000000003, 0.4249988431369059, 0.8967607749926938, 0.30648056991207406), (0.1650000000000003, 0.37646019200020114, 0.9022931610941967, 0.3063749421769546), (0.17500000000000032, 0.3230834695385942, 0.9086059712367901, 0.3063206830206049), (0.18500000000000033, 0.2838630626300865, 0.9135486317849787, 0.30624468303654856), (0.19500000000000034, 0.26312012485796243, 0.9161823650623467, 0.3062792686442173), (0.20500000000000035, 0.25546475796037754, 0.9169962828638313, 0.30625564741653527), (0.21500000000000036, 0.2538288705083269, 0.9172674876894035, 0.30624466686916185), (0.22500000000000037, 0.25385244118957323, 0.9173002538392233, 0.3062881855774002), (0.23500000000000038, 0.25435421897952837, 0.9170993830557297, 0.3063217550066117), (0.24500000000000038, 0.25484785803655347, 0.917297631269934, 0.30633152306973305), (0.2550000000000004, 0.2551462925653584, 0.9171207319155263, 0.3062425939131004), (0.2650000000000004, 0.25527804138560317, 0.9168721588799764, 0.30621371074195036), (0.2750000000000004, 0.2553086860042269, 0.9173579272884218, 0.306381349096989), (0.2850000000000004, 0.2550842132210145, 0.9171451301794925, 0.3062514539187297), (0.29500000000000043, 0.25500112971314676, 0.9169958938174527, 0.30630793033357473), (0.30500000000000044, 0.25501325412451314, 0.9171942314852951, 0.3063797459476476), (0.31500000000000045, 0.2548911547607271, 0.9176861150289742, 0.30614465035840854), (0.32500000000000046, 0.2547644714837658, 0.9177551464568809, 0.30605138955358835), (0.33500000000000046, 0.2546465556459554, 0.9175518131758459, 0.30657038190930797), (0.3450000000000005, 0.257048507869776, 0.9218698925916096, 0.3085287750393364), (0.3550000000000005, 0.2461705429084873, 0.8784393859773485, 0.29236958085661585), (0.3650000000000005, 0.1336095311819308, 0.07564047374232051, 0.1103528217580464), (0.3750000000000005, 0.12501790423176928, 0.00015158938150652916, 0.10002005518613435), (0.3850000000000005, 0.12500002915548108, 2.468420681096496e-07, 0.1000000326541411), (0.3950000000000005, 0.1250000000471873, 3.9950684412222107e-10, 0.10000000005284979), (0.4050000000000005, 0.12500000000007638, 6.467881785706054e-13, 0.10000000000008555), (0.41500000000000054, 0.12500000000000014, 1.0269562977782686e-15, 0.10000000000000016), (0.42500000000000054, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.43500000000000055, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.44500000000000056, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.45500000000000057, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.4650000000000006, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.4750000000000006, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.4850000000000006, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.4950000000000006, 0.125, 8.326672684688674e-17, 0.10000000000000002), (0.5050000000000006, 0.125, 0.0, 0.1)] return solution_porting
# __version__.py # autogenerated by poetry-hooks 0.1.0 __version__ = "0.1.0a0" __title__ = "pytorch-caldera" __authors__ = ["Justin Vrana <[email protected]>"] __repository__ = "" __homepage__ = "http://www.github.com/jvrana/caldera" __description__ = "" __maintainers__ = "" __readme__ = "" __license__ = ""
__version__ = '0.1.0a0' __title__ = 'pytorch-caldera' __authors__ = ['Justin Vrana <[email protected]>'] __repository__ = '' __homepage__ = 'http://www.github.com/jvrana/caldera' __description__ = '' __maintainers__ = '' __readme__ = '' __license__ = ''
n = int(input()) data = [] c1, c2 = 0, 0 flag = 0 for i in range(n): val = list(map(int, input().split())) data.append(tuple(val)) c1 += val[0] c2 += val[1] if (c1 % 2) != (c2 % 2): flag = 1 if c1 % 2 == 1 and c2 % 2 == 1 and (c1+c2) % 2 == 0 and n > 1 and flag == 1: print(1) elif c1 % 2 == 0 and c2 % 2 == 0: print(0) else: print(-1)
n = int(input()) data = [] (c1, c2) = (0, 0) flag = 0 for i in range(n): val = list(map(int, input().split())) data.append(tuple(val)) c1 += val[0] c2 += val[1] if c1 % 2 != c2 % 2: flag = 1 if c1 % 2 == 1 and c2 % 2 == 1 and ((c1 + c2) % 2 == 0) and (n > 1) and (flag == 1): print(1) elif c1 % 2 == 0 and c2 % 2 == 0: print(0) else: print(-1)
FULL_SCREEN = "FULL_SCREEN" MOVE_UP = "MOVE_UP" MOVE_LEFT = "MOVE_LEFT" MOVE_RIGHT = "MOVE_RIGHT" MOVE_DOWN = "MOVE_DOWN" ATTACK = "ATTACK" INVENTORY = "INVENTORY" MOVEMENT_ACTION = [ MOVE_DOWN, MOVE_UP, MOVE_RIGHT, MOVE_LEFT, ]
full_screen = 'FULL_SCREEN' move_up = 'MOVE_UP' move_left = 'MOVE_LEFT' move_right = 'MOVE_RIGHT' move_down = 'MOVE_DOWN' attack = 'ATTACK' inventory = 'INVENTORY' movement_action = [MOVE_DOWN, MOVE_UP, MOVE_RIGHT, MOVE_LEFT]
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: current_carry = 0 current = ListNode(0) head = current while l1 or l2 or current_carry: current_val = current_carry current_val += 0 if l1 is None else l1.val current_val += 0 if l2 is None else l2.val if current_val >= 10: current_val -= 10 current_carry = 1 else: current_carry = 0 current.next = ListNode(current_val) current = current.next if l1 is None and l2 is None: break elif l1 is None: l2 = l2.next elif l2 is None: l1 = l1.next else: l1 = l1.next l2 = l2.next return head.next
class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: current_carry = 0 current = list_node(0) head = current while l1 or l2 or current_carry: current_val = current_carry current_val += 0 if l1 is None else l1.val current_val += 0 if l2 is None else l2.val if current_val >= 10: current_val -= 10 current_carry = 1 else: current_carry = 0 current.next = list_node(current_val) current = current.next if l1 is None and l2 is None: break elif l1 is None: l2 = l2.next elif l2 is None: l1 = l1.next else: l1 = l1.next l2 = l2.next return head.next
#!/usr/bin/python3 class Node: def __init__(self, data, lchild=None, rchild=None): self.data = data self.lchild = lchild self.rchild = rchild def pre_order(root): if root != None: print(root.data, end=' ') pre_order(root.lchild) pre_order(root.rchild) def in_order(root): if root != None: in_order(root.lchild) print(root.data, end=' ') in_order(root.rchild) def post_order(root): if root != None: post_order(root.lchild) post_order(root.rchild) print(root.data, end=' ') def layor_order(root): if root == None: return q = [] p = None q.append(root) while len(q) > 0: p = q.pop(0) print(p.data, end=' ') if p.lchild != None: q.append(p.lchild) if p.rchild != None: q.append(p.rchild) print() def height(root): if root == None: return 0 left_height = height(root.lchild) right_height = height(root.rchild) if left_height > right_height: return left_height + 1 else: return right_height + 1 if __name__ == "__main__": a = Node('A', Node('B', Node('D', None, Node('F')), None), Node('C', None, Node('E'))) print("PreOrder:") pre_order(a) print() print("InOder:") in_order(a) print() print("PostOrder:") post_order(a) print() print('LayorOrder:') layor_order(a) print("Tree height:", height(a))
class Node: def __init__(self, data, lchild=None, rchild=None): self.data = data self.lchild = lchild self.rchild = rchild def pre_order(root): if root != None: print(root.data, end=' ') pre_order(root.lchild) pre_order(root.rchild) def in_order(root): if root != None: in_order(root.lchild) print(root.data, end=' ') in_order(root.rchild) def post_order(root): if root != None: post_order(root.lchild) post_order(root.rchild) print(root.data, end=' ') def layor_order(root): if root == None: return q = [] p = None q.append(root) while len(q) > 0: p = q.pop(0) print(p.data, end=' ') if p.lchild != None: q.append(p.lchild) if p.rchild != None: q.append(p.rchild) print() def height(root): if root == None: return 0 left_height = height(root.lchild) right_height = height(root.rchild) if left_height > right_height: return left_height + 1 else: return right_height + 1 if __name__ == '__main__': a = node('A', node('B', node('D', None, node('F')), None), node('C', None, node('E'))) print('PreOrder:') pre_order(a) print() print('InOder:') in_order(a) print() print('PostOrder:') post_order(a) print() print('LayorOrder:') layor_order(a) print('Tree height:', height(a))
DEBUG = False SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/' SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://hlapse:[email protected]/rss' + '?charset=utf8mb4' SQLALCHEMY_TRACK_MODIFICATIONS = False # JWT JWT_ERROR_MESSAGE_KEY = "messsage" JWT_ACCESS_TOKEN_EXPIRES = False # APScheduler SCHEDULER_API_ENABLED = True SCHEDULER_EXECUTORS = {'default': {'type': 'threadpool', 'max_workers': 20}}
debug = False secret_key = b'_5#y2L"F4Q8z\n\xec]/' sqlalchemy_database_uri = 'mysql+pymysql://hlapse:[email protected]/rss' + '?charset=utf8mb4' sqlalchemy_track_modifications = False jwt_error_message_key = 'messsage' jwt_access_token_expires = False scheduler_api_enabled = True scheduler_executors = {'default': {'type': 'threadpool', 'max_workers': 20}}
ROTATED_PROXY_ENABLED = True PROXY_STORAGE = 'scrapy_rotated_proxy.extensions.file_storage.FileProxyStorage' PROXY_FILE_PATH = '' # PROXY_STORAGE = 'scrapy_rotated_proxy.extensions.mongodb_storage.MongoDBProxyStorage' PROXY_MONGODB_HOST = '127.0.0.1' PROXY_MONGODB_PORT = 27017 PROXY_MONGODB_USERNAME = None PROXY_MONGODB_PASSWORD = None PROXY_MONGODB_AUTH_DB = 'admin' PROXY_MONGODB_DB = 'proxy_management' PROXY_MONGODB_COLL = 'proxy' PROXY_MONGODB_COLL_INDEX = [] PROXY_SLEEP_INTERVAL = 60*60*24 PROXY_SPIDER_CLOSE_WHEN_NO_PROXY = True PROXY_RELOAD_ENABLED = False
rotated_proxy_enabled = True proxy_storage = 'scrapy_rotated_proxy.extensions.file_storage.FileProxyStorage' proxy_file_path = '' proxy_mongodb_host = '127.0.0.1' proxy_mongodb_port = 27017 proxy_mongodb_username = None proxy_mongodb_password = None proxy_mongodb_auth_db = 'admin' proxy_mongodb_db = 'proxy_management' proxy_mongodb_coll = 'proxy' proxy_mongodb_coll_index = [] proxy_sleep_interval = 60 * 60 * 24 proxy_spider_close_when_no_proxy = True proxy_reload_enabled = False
# Copyright 2016 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ # { # 'target_name': 'cast_extension_discoverer', # 'includes': ['../../../compile_js2.gypi'], # }, # { # 'target_name': 'cast_video_element', # 'includes': ['../../../compile_js2.gypi'], # }, # { # 'target_name': 'caster', # 'includes': ['../../../compile_js2.gypi'], # }, # { # 'target_name': 'media_manager', # 'includes': ['../../../compile_js2.gypi'], # }, ], }
{'targets': []}
def iscomplex(a): # TODO(beam2d): Implement it raise NotImplementedError def iscomplexobj(x): # TODO(beam2d): Implement it raise NotImplementedError def isfortran(a): # TODO(beam2d): Implement it raise NotImplementedError def isreal(x): # TODO(beam2d): Implement it raise NotImplementedError def isrealobj(x): # TODO(beam2d): Implement it raise NotImplementedError
def iscomplex(a): raise NotImplementedError def iscomplexobj(x): raise NotImplementedError def isfortran(a): raise NotImplementedError def isreal(x): raise NotImplementedError def isrealobj(x): raise NotImplementedError
N, K = map(int, input().split()) S = list(input()) S[K-1] = S[K-1].swapcase() print("".join(S))
(n, k) = map(int, input().split()) s = list(input()) S[K - 1] = S[K - 1].swapcase() print(''.join(S))
full_submit = { 'processes' : [ { 'name': 'mkdir', 'cmd': 'mkdir -p /mnt/mesos/sandbox/sandbox/__jobio/input /mnt/mesos/sandbox/sandbox/__jobio/output' }, { 'name': 'symlink_in', 'cmd': 'ln -s /mnt/mesos/sandbox/sandbox/__jobio/input /job/input' }, { 'name': 'symlink_out', 'cmd': 'ln -s /mnt/mesos/sandbox/sandbox/__jobio/output /job/output' }, { 'name' : "locdown_0", 'cmd' : 'localizer "gs://foo" "/foo"' }, { 'name' : "locdown_1", 'cmd' : 'localizer "http://bar" "/bar"' }, { 'name' : "TESTJOB_ps", 'cmd' : 'echo Hello herc! > /baz' }, { 'name' : "locup_0", 'cmd' : 'localizer "/baz" "gs://baz"' } ], 'finalizers' : [ { 'name' : "__locup_stdout", 'cmd' : 'localizer ".logs/TESTJOB_ps/0/stdout" "gs://stdout"' }, { 'name' : "__locup_stderr", 'cmd' : 'localizer ".logs/TESTJOB_ps/0/stderr" "gs://stderr"' } ], 'tasks' : [{ 'name' : 'TESTJOB_task', 'processes' : [ 'mkdir', 'symlink_in', 'symlink_out', "locdown_0", "locdown_1", "TESTJOB_ps", "locup_0", "__locup_stdout", "__locup_stderr" ], 'ordering' : [ 'mkdir', 'symlink_in', 'symlink_out', "locdown_0", "locdown_1", "TESTJOB_ps", "locup_0" ], 'cpus' : 1, 'mem' : 16, 'memunit' : "MB", 'disk' : 1, 'diskunit' : "MB" }], 'jobs' : [{ 'name' : 'TESTJOB', 'task' : 'TESTJOB_task', 'env' : 'devel', 'cluster' : 'herc', 'hostlimit' : 99999999, 'container' : "python:2.7" }] }
full_submit = {'processes': [{'name': 'mkdir', 'cmd': 'mkdir -p /mnt/mesos/sandbox/sandbox/__jobio/input /mnt/mesos/sandbox/sandbox/__jobio/output'}, {'name': 'symlink_in', 'cmd': 'ln -s /mnt/mesos/sandbox/sandbox/__jobio/input /job/input'}, {'name': 'symlink_out', 'cmd': 'ln -s /mnt/mesos/sandbox/sandbox/__jobio/output /job/output'}, {'name': 'locdown_0', 'cmd': 'localizer "gs://foo" "/foo"'}, {'name': 'locdown_1', 'cmd': 'localizer "http://bar" "/bar"'}, {'name': 'TESTJOB_ps', 'cmd': 'echo Hello herc! > /baz'}, {'name': 'locup_0', 'cmd': 'localizer "/baz" "gs://baz"'}], 'finalizers': [{'name': '__locup_stdout', 'cmd': 'localizer ".logs/TESTJOB_ps/0/stdout" "gs://stdout"'}, {'name': '__locup_stderr', 'cmd': 'localizer ".logs/TESTJOB_ps/0/stderr" "gs://stderr"'}], 'tasks': [{'name': 'TESTJOB_task', 'processes': ['mkdir', 'symlink_in', 'symlink_out', 'locdown_0', 'locdown_1', 'TESTJOB_ps', 'locup_0', '__locup_stdout', '__locup_stderr'], 'ordering': ['mkdir', 'symlink_in', 'symlink_out', 'locdown_0', 'locdown_1', 'TESTJOB_ps', 'locup_0'], 'cpus': 1, 'mem': 16, 'memunit': 'MB', 'disk': 1, 'diskunit': 'MB'}], 'jobs': [{'name': 'TESTJOB', 'task': 'TESTJOB_task', 'env': 'devel', 'cluster': 'herc', 'hostlimit': 99999999, 'container': 'python:2.7'}]}
class TreasureMap: def __init__(self): self.map = {} def populate_map(self): self.map['beach'] = 'sandy shore' self.map['coast'] = 'ocean reef' self.map['volcano'] = 'hot lava' self.map['x'] = 'marks the spot' return
class Treasuremap: def __init__(self): self.map = {} def populate_map(self): self.map['beach'] = 'sandy shore' self.map['coast'] = 'ocean reef' self.map['volcano'] = 'hot lava' self.map['x'] = 'marks the spot' return
def sum(n): a = 0 for b in range(1,n+1,4): a+=b*b # b ** 2 return a n = int(input('n=')) print(sum(n))
def sum(n): a = 0 for b in range(1, n + 1, 4): a += b * b return a n = int(input('n=')) print(sum(n))
#------------------------------------------------------------------------------ # interpreter/interpreter.py # Copyright 2011 Joseph Schilz # Licensed under Apache v2 #------------------------------------------------------------------------------ articles = [" a ", " the "] def verb(command): # A function to isolate the verb in a command. this_verb = "" the_rest = "" first_space = command.find(" ") # If this_input contains a space, the verb is everything before the # first space. if first_space > 0: this_verb = command[0:first_space] the_rest = command[first_space + 1:len(command)] # If it doesn't contain a space, the whole thing is the verb. else: this_verb = command # We handle simple verb aliases at this level... if command[0] == "'": this_verb = "say" the_rest = command[1:len(command)] if command == "north" or command == "n": this_verb = "go" the_rest = "north" elif command == "south" or command == "s": this_verb = "go" the_rest = "south" elif command == "east" or command == "e": this_verb = "go" the_rest = "east" elif command == "west" or command == "w": this_verb = "go" the_rest = "west" elif command == "up" or command == "u": this_verb = "go" the_rest = "up" elif command == "down" or command == "d": this_verb = "go" the_rest = "down" if this_verb == "l": this_verb = "look" elif this_verb == "i": this_verb = "inv" elif this_verb == "h": this_verb = "health" return this_verb, the_rest def interpret(the_verb, the_rest, transitivity=1): the_rest = " " + the_rest.lower() + " " for article in articles: the_rest = the_rest.replace(article, '') if transitivity == 1: the_rest = the_rest.strip().split() if len(the_rest) > 0: # This might not be stable. return [the_rest.pop(), the_rest] else: return False
articles = [' a ', ' the '] def verb(command): this_verb = '' the_rest = '' first_space = command.find(' ') if first_space > 0: this_verb = command[0:first_space] the_rest = command[first_space + 1:len(command)] else: this_verb = command if command[0] == "'": this_verb = 'say' the_rest = command[1:len(command)] if command == 'north' or command == 'n': this_verb = 'go' the_rest = 'north' elif command == 'south' or command == 's': this_verb = 'go' the_rest = 'south' elif command == 'east' or command == 'e': this_verb = 'go' the_rest = 'east' elif command == 'west' or command == 'w': this_verb = 'go' the_rest = 'west' elif command == 'up' or command == 'u': this_verb = 'go' the_rest = 'up' elif command == 'down' or command == 'd': this_verb = 'go' the_rest = 'down' if this_verb == 'l': this_verb = 'look' elif this_verb == 'i': this_verb = 'inv' elif this_verb == 'h': this_verb = 'health' return (this_verb, the_rest) def interpret(the_verb, the_rest, transitivity=1): the_rest = ' ' + the_rest.lower() + ' ' for article in articles: the_rest = the_rest.replace(article, '') if transitivity == 1: the_rest = the_rest.strip().split() if len(the_rest) > 0: return [the_rest.pop(), the_rest] else: return False
URLs = [ ["https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Current version ["https://web.archive.org/web/20220413213804/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 13 - 21:38:04 UTC ["https://web.archive.org/web/20220412213745/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 12 - 21:37:45 UTC ["https://web.archive.org/web/20220411210123/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 11 - 21:01:23 UTC ["https://web.archive.org/web/20220410235550/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 10 - 23:55:50 UTC ["https://web.archive.org/web/20220409233956/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 9 - 23:39:56 UTC ["https://web.archive.org/web/20220408202350/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 8 - 20:23:50 UTC ["https://web.archive.org/web/20220407235250/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 7 - 23:52:50 UTC ["https://web.archive.org/web/20220406205229/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 6 - 20:52:29 UTC ["https://web.archive.org/web/20220405233659/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 5 - 23:36:59 UTC ["https://web.archive.org/web/20220404220900/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 4 - 22:09:00 UTC ["https://web.archive.org/web/20220403225440/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 3 - 22:54:40 UTC ["https://web.archive.org/web/20220402220455/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 2 - 22:04:55 UTC ["https://web.archive.org/web/20220401220928/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Apr 1 - 22:09:28 UTC ["https://web.archive.org/web/20220401002724/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", False], # Mar 31 - (April 01 - 00:27:24 UTC) ["https://web.archive.org/web/20220330234337/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 30 - 23:43:37 UTC ["https://web.archive.org/web/20220329202039/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 29 - 20:20:39 UTC ["https://web.archive.org/web/20220328205313/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 28 - 20:53:13 UTC ["https://web.archive.org/web/20220327235658/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 27 - 23:56:58 UTC ["https://web.archive.org/web/20220326220720/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 26 - 22:07:20 UTC ["https://web.archive.org/web/20220325232201/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 25 - 23:22:01 UTC ["https://web.archive.org/web/20220324235259/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 24 - 23:52:59 UTC ["https://web.archive.org/web/20220323230032/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 23 - 23:00:32 UTC ["https://web.archive.org/web/20220322205154/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 22 - 20:51:54 UTC ["https://web.archive.org/web/20220321235106/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 21 - 23:51:06 UTC ["https://web.archive.org/web/20220320235959/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 20 - 23:59:59 UTC ["https://web.archive.org/web/20220319224651/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 19 - 22:46:51 UTC ["https://web.archive.org/web/20220318215226/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 18 - 21:52:26 UTC ["https://web.archive.org/web/20220317233941/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 17 - 23:39:41 UTC ["https://web.archive.org/web/20220316230757/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 16 - 23:07:57 UTC ["https://web.archive.org/web/20220315235520/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 15 - 23:55:20 UTC ["https://web.archive.org/web/20220315000709/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", False], # Mar 14 - (Mar 15 - 00:07:09 UTC) ["https://web.archive.org/web/20220313230901/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 13 - 23:09:01 UTC ["https://web.archive.org/web/20220312213558/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 12 - 21:35:58 UTC ["https://web.archive.org/web/20220311205005/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 11 - 20:50:05 UTC ["https://web.archive.org/web/20220310235649/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 10 - 23:56:49 UTC ["https://web.archive.org/web/20220309213817/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 9 - 21:38:17 UTC ["https://web.archive.org/web/20220308204303/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 8 - 20:43:03 UTC ["https://web.archive.org/web/20220307220942/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 7 - 22:09:42 UTC ["https://web.archive.org/web/20220306225654/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 6 - 22:56:54 UTC ["https://web.archive.org/web/20220305211400/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 5 - 21:14:00 UTC ["https://web.archive.org/web/20220304235636/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 4 - 23:56:36 UTC ["https://web.archive.org/web/20220303195838/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 3 - 19:58:38 UTC ["https://web.archive.org/web/20220302205559/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 2 - 20:55:59 UTC ["https://web.archive.org/web/20220301185329/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Mar 1 - 18:53:29 UTC ["https://web.archive.org/web/20220228231935/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Feb 28 - 23:19:35 UTC ["https://web.archive.org/web/20220227214345/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Feb 27 - 21:43:45 UTC ["https://web.archive.org/web/20220226185336/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Feb 26 - 18:53:36 UTC ["https://web.archive.org/web/20220225233528/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Feb 25 - 23:35:28 UTC ["https://web.archive.org/web/20220224231142/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html", True], # Feb 24 - 23:11:42 UTC ]
ur_ls = [['https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220413213804/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220412213745/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220411210123/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220410235550/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220409233956/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220408202350/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220407235250/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220406205229/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220405233659/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220404220900/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220403225440/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220402220455/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220401220928/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220401002724/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', False], ['https://web.archive.org/web/20220330234337/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220329202039/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220328205313/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220327235658/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220326220720/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220325232201/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220324235259/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220323230032/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220322205154/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220321235106/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220320235959/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220319224651/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220318215226/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220317233941/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220316230757/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220315235520/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220315000709/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', False], ['https://web.archive.org/web/20220313230901/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220312213558/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220311205005/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220310235649/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220309213817/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220308204303/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220307220942/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220306225654/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220305211400/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220304235636/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220303195838/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220302205559/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220301185329/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220228231935/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220227214345/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220226185336/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220225233528/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True], ['https://web.archive.org/web/20220224231142/https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html', True]]
#Enquiry Form name=input('Enter your First Name ') Class=int(input('Enter your class ')) school=input('Enter your school name ') address=input('Enter your Address ') number=int(input('Enter your phone number ')) #print("Name- ",name,"Class- ",Class,"School- ",school,"Address- ",address,"Phone Number- ",number,sep='\n') print("Name- ",name) print("Class- ",Class) print("School- ",school) print("Address- ",address) print("Phone number- ",number)
name = input('Enter your First Name ') class = int(input('Enter your class ')) school = input('Enter your school name ') address = input('Enter your Address ') number = int(input('Enter your phone number ')) print('Name- ', name) print('Class- ', Class) print('School- ', school) print('Address- ', address) print('Phone number- ', number)
'''ftoc.py - Fahrenheit to Celsius temperature converter''' def f_to_c(f): c = (f - 32) * (5/9) return c def input_float(prompt): ans = input(prompt) return float(ans) f = input_float("What is the temperature (in degrees Fahrenheit)? ") c = f_to_c(f) print("That is", round(c, 1), "degrees Celsius")
"""ftoc.py - Fahrenheit to Celsius temperature converter""" def f_to_c(f): c = (f - 32) * (5 / 9) return c def input_float(prompt): ans = input(prompt) return float(ans) f = input_float('What is the temperature (in degrees Fahrenheit)? ') c = f_to_c(f) print('That is', round(c, 1), 'degrees Celsius')
class Solution: # Sort (Accepted), O(n log n) time, O(n) space def maxProductDifference(self, nums: List[int]) -> int: nums.sort() return (nums[-1] * nums[-2]) - (nums[0] * nums[1]) # One Pass (Top Voted), O(n) time, O(1) space def maxProductDifference(self, nums: List[int]) -> int: min1 = min2 = float('inf') max1 = max2 = float('-inf') for n in nums: if n <= min1: min1, min2, = n, min1 elif n < min2: min2 = n if n >= max1: max1, max2 = n, max1 elif n > max2: max2 = n return max1*max2-min1*min2
class Solution: def max_product_difference(self, nums: List[int]) -> int: nums.sort() return nums[-1] * nums[-2] - nums[0] * nums[1] def max_product_difference(self, nums: List[int]) -> int: min1 = min2 = float('inf') max1 = max2 = float('-inf') for n in nums: if n <= min1: (min1, min2) = (n, min1) elif n < min2: min2 = n if n >= max1: (max1, max2) = (n, max1) elif n > max2: max2 = n return max1 * max2 - min1 * min2
nota = float(input('Digite sua nota, Valor entre "0 e 10": ')) while True: if nota >= 8.5 and nota <= 10: print('Nota igual a A') elif nota >= 7.0 and nota <= 8.4: print('Nota igual a B') elif nota >= 5.0 and nota <= 6.9: print('Nota igual a C') elif nota >= 4.0 and nota <= 4.9: print('Nota igual a D') elif nota >= 0 and nota <= 3.9: print('Nota igual a E') else: print('Nota invalida') nota = float(input('Digite sua nota, Valor entre "0 e 10": '))
nota = float(input('Digite sua nota, Valor entre "0 e 10": ')) while True: if nota >= 8.5 and nota <= 10: print('Nota igual a A') elif nota >= 7.0 and nota <= 8.4: print('Nota igual a B') elif nota >= 5.0 and nota <= 6.9: print('Nota igual a C') elif nota >= 4.0 and nota <= 4.9: print('Nota igual a D') elif nota >= 0 and nota <= 3.9: print('Nota igual a E') else: print('Nota invalida') nota = float(input('Digite sua nota, Valor entre "0 e 10": '))
INVALID_VALUE = -9999 def search_in_dictionary_list(dictionary_list, key_name, key_value): for dictionary in dictionary_list: if dictionary[key_name] == key_value: return dictionary return None def search_value_in_dictionary_list(dictionary_list, key_name, key_value, value_key): dictionary = search_in_dictionary_list(dictionary_list, key_name, key_value) if dictionary is not None: return dictionary[value_key] else: return INVALID_VALUE
invalid_value = -9999 def search_in_dictionary_list(dictionary_list, key_name, key_value): for dictionary in dictionary_list: if dictionary[key_name] == key_value: return dictionary return None def search_value_in_dictionary_list(dictionary_list, key_name, key_value, value_key): dictionary = search_in_dictionary_list(dictionary_list, key_name, key_value) if dictionary is not None: return dictionary[value_key] else: return INVALID_VALUE
expected_output = { "global_drop_stats": { "Ipv4NoAdj": {"octets": 296, "packets": 7}, "Ipv4NoRoute": {"octets": 7964, "packets": 181}, "PuntPerCausePolicerDrops": {"octets": 184230, "packets": 2003}, "UidbNotCfgd": {"octets": 29312827, "packets": 466391}, "UnconfiguredIpv4Fia": {"octets": 360, "packets": 6}, } }
expected_output = {'global_drop_stats': {'Ipv4NoAdj': {'octets': 296, 'packets': 7}, 'Ipv4NoRoute': {'octets': 7964, 'packets': 181}, 'PuntPerCausePolicerDrops': {'octets': 184230, 'packets': 2003}, 'UidbNotCfgd': {'octets': 29312827, 'packets': 466391}, 'UnconfiguredIpv4Fia': {'octets': 360, 'packets': 6}}}
def func(ord_list, num): result = True if num in ord_list else False return result if __name__ == "__main__": l = [-1,3,5,6,8,9] # using binary search def find(ordered_list, element): start_index = 0 end_index = len(ordered_list) - 1 while True: middle_index = int((end_index + start_index) / 2) if middle_index == start_index or middle_index == end_index: if ordered_list[middle_index] == element or ordered_list[end_index] == element: return True else: return False middle_element = ordered_list[middle_index] if middle_element == element: return True elif middle_element > element: end_index = middle_index else: start_index = middle_index if __name__=="__main__": l = [2, 4, 6, 8, 10] print(find(l, 8))
def func(ord_list, num): result = True if num in ord_list else False return result if __name__ == '__main__': l = [-1, 3, 5, 6, 8, 9] def find(ordered_list, element): start_index = 0 end_index = len(ordered_list) - 1 while True: middle_index = int((end_index + start_index) / 2) if middle_index == start_index or middle_index == end_index: if ordered_list[middle_index] == element or ordered_list[end_index] == element: return True else: return False middle_element = ordered_list[middle_index] if middle_element == element: return True elif middle_element > element: end_index = middle_index else: start_index = middle_index if __name__ == '__main__': l = [2, 4, 6, 8, 10] print(find(l, 8))
# 54. Spiral Matrix class Solution: def spiralOrder(self, matrix): if not matrix: return matrix m, n = len(matrix), len(matrix[0]) visited = [[False] * n for _ in range(m)] ans = [] dirs = ((0,1), (1,0), (0,-1), (-1,0)) cur = 0 i = j = 0 while len(ans) < m * n: if not visited[i][j]: ans.append(matrix[i][j]) visited[i][j] = True di, dj = dirs[cur] ii, jj = i+di, j+dj if ii<0 or ii>=m or jj<0 or jj>=n or visited[ii][jj]: cur = (cur+1) % 4 di, dj = dirs[cur] i, j = i+di, j+dj return ans
class Solution: def spiral_order(self, matrix): if not matrix: return matrix (m, n) = (len(matrix), len(matrix[0])) visited = [[False] * n for _ in range(m)] ans = [] dirs = ((0, 1), (1, 0), (0, -1), (-1, 0)) cur = 0 i = j = 0 while len(ans) < m * n: if not visited[i][j]: ans.append(matrix[i][j]) visited[i][j] = True (di, dj) = dirs[cur] (ii, jj) = (i + di, j + dj) if ii < 0 or ii >= m or jj < 0 or (jj >= n) or visited[ii][jj]: cur = (cur + 1) % 4 (di, dj) = dirs[cur] (i, j) = (i + di, j + dj) return ans
class Solution: # @param s, a string # @param wordDict, a set<string> # @return a boolean def wordBreak(self, s, wordDict): n = len(s) if n == 0: return True res = [] chars = ''.join(wordDict) for i in xrange(n): if s[i] not in chars: return False lw = s[-1] lw_end = False for word in wordDict: if word[-1] == lw: lw_end = True if not lw_end: return False return self.dfs(s,[],wordDict, res) def dfs(self, s, path, wordDict,res): if not s : res.append(path[:]) return True for i in xrange(1,len(s)+1): c = s[:i] if c in wordDict: path.append(c) v = self.dfs(s[i:],path,wordDict,res) if v: return True path.pop() return False
class Solution: def word_break(self, s, wordDict): n = len(s) if n == 0: return True res = [] chars = ''.join(wordDict) for i in xrange(n): if s[i] not in chars: return False lw = s[-1] lw_end = False for word in wordDict: if word[-1] == lw: lw_end = True if not lw_end: return False return self.dfs(s, [], wordDict, res) def dfs(self, s, path, wordDict, res): if not s: res.append(path[:]) return True for i in xrange(1, len(s) + 1): c = s[:i] if c in wordDict: path.append(c) v = self.dfs(s[i:], path, wordDict, res) if v: return True path.pop() return False
clan = { } def add_member(tag, name, age, level): clan[tag] = { "Name": name, "age": age, "level": level } return clan def display_clan(): print(clan) add_member("Voodoo", "Andre Williams", 26, "Beginner") display_clan()
clan = {} def add_member(tag, name, age, level): clan[tag] = {'Name': name, 'age': age, 'level': level} return clan def display_clan(): print(clan) add_member('Voodoo', 'Andre Williams', 26, 'Beginner') display_clan()
class CRSError(Exception): pass class DriverError(Exception): pass class TransactionError(RuntimeError): pass class UnsupportedGeometryTypeError(Exception): pass class DriverIOError(IOError): pass
class Crserror(Exception): pass class Drivererror(Exception): pass class Transactionerror(RuntimeError): pass class Unsupportedgeometrytypeerror(Exception): pass class Driverioerror(IOError): pass
# Search Part Problem n = int(input()) part_list = list(map(int, input().split())) m = int(input()) require_list = list(map(int, input().split())) def binary_search(array, target, start, end): mid = (start + end) // 2 if start >= end: return "no" if array[mid] == target: return "yes" if array[mid] > target: return binary_search(array, target, start, mid - 1) else: return binary_search(array, target, mid + 1, end) return "no" part_list = sorted(part_list) result = [binary_search(part_list, i, 0, n) for i in require_list] for answer in result: print(answer, end=" ")
n = int(input()) part_list = list(map(int, input().split())) m = int(input()) require_list = list(map(int, input().split())) def binary_search(array, target, start, end): mid = (start + end) // 2 if start >= end: return 'no' if array[mid] == target: return 'yes' if array[mid] > target: return binary_search(array, target, start, mid - 1) else: return binary_search(array, target, mid + 1, end) return 'no' part_list = sorted(part_list) result = [binary_search(part_list, i, 0, n) for i in require_list] for answer in result: print(answer, end=' ')
time_convert = {"s": 1, "m": 60, "h": 3600, "d": 86400} def convert_time_to_seconds(time): try: return int(time[:-1]) * time_convert[time[-1]] except: raise ValueError
time_convert = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400} def convert_time_to_seconds(time): try: return int(time[:-1]) * time_convert[time[-1]] except: raise ValueError
def loadfile(name): lines = [] f = open(name, "r") for x in f: if x.endswith('\n'): x = x[:-1] lines.append(x.split("-")) return lines def pathFromPosition (position, graph, path, s, e, goingTwice, bt): beenThere = bt.copy() path = path + "-" + position print(path) paths = [] if position == e: return [path] else: edges = findEdgesFromPosition(position, graph) if len(edges) == 0: print("Doodlopend ", path) return [] for edge in edges: if not position[0].isupper(): if goingTwice == False: graph = removeNodeFromGraph(graph, position) else: if position == s: graph = removeNodeFromGraph(graph, position) elif position in beenThere: print(beenThere) print("hiephoooi", path) goingTwice = False for p in beenThere: graph = removeNodeFromGraph(graph, p) else: beenThere.append(position) print("Beenthere", position, path) cedge = edge.copy() cedge.remove(position) nextNode = cedge[0] print(goingTwice) paths.extend(pathFromPosition(nextNode, graph, path, s, e, goingTwice, beenThere)) return paths def removeNodeFromGraph (graph, position): g = [] for edge in graph: if position not in edge: g.append(edge) return g def findEdgesFromPosition (position, graph): edges = [] for edge in graph: if position in edge: edges.append(edge) return edges originalGraph = loadfile("test.txt") print(originalGraph) endPaths = pathFromPosition("start", originalGraph, "", "start", "end", False, []) endPaths2 = pathFromPosition("start", originalGraph, "", "start", "end", True, []) print(endPaths) print(endPaths2) endPaths2 = list(dict.fromkeys(endPaths2)) print("Opdracht 12a: ", len(endPaths)) print("Opdracht 12b: ", len(endPaths2))
def loadfile(name): lines = [] f = open(name, 'r') for x in f: if x.endswith('\n'): x = x[:-1] lines.append(x.split('-')) return lines def path_from_position(position, graph, path, s, e, goingTwice, bt): been_there = bt.copy() path = path + '-' + position print(path) paths = [] if position == e: return [path] else: edges = find_edges_from_position(position, graph) if len(edges) == 0: print('Doodlopend ', path) return [] for edge in edges: if not position[0].isupper(): if goingTwice == False: graph = remove_node_from_graph(graph, position) elif position == s: graph = remove_node_from_graph(graph, position) elif position in beenThere: print(beenThere) print('hiephoooi', path) going_twice = False for p in beenThere: graph = remove_node_from_graph(graph, p) else: beenThere.append(position) print('Beenthere', position, path) cedge = edge.copy() cedge.remove(position) next_node = cedge[0] print(goingTwice) paths.extend(path_from_position(nextNode, graph, path, s, e, goingTwice, beenThere)) return paths def remove_node_from_graph(graph, position): g = [] for edge in graph: if position not in edge: g.append(edge) return g def find_edges_from_position(position, graph): edges = [] for edge in graph: if position in edge: edges.append(edge) return edges original_graph = loadfile('test.txt') print(originalGraph) end_paths = path_from_position('start', originalGraph, '', 'start', 'end', False, []) end_paths2 = path_from_position('start', originalGraph, '', 'start', 'end', True, []) print(endPaths) print(endPaths2) end_paths2 = list(dict.fromkeys(endPaths2)) print('Opdracht 12a: ', len(endPaths)) print('Opdracht 12b: ', len(endPaths2))
def launch(self, Dialog, **kwargs): # This is where the magic happens! # The lx module is persistent so you can store stuff there # and access it in commands. lx._widget = Dialog lx._widgetOptions = kwargs # widgetWrapper creates whatever widget is set via lx._widget above # note we're using launchScript which allows for runtime blessing lx.eval('launchWidget') try: return lx._widgetInstance except: return None
def launch(self, Dialog, **kwargs): lx._widget = Dialog lx._widgetOptions = kwargs lx.eval('launchWidget') try: return lx._widgetInstance except: return None
test = { 'name': 'q1_2', 'points': 1, 'suites': [ { 'cases': [ {'code': '>>> sum(standard_units(make_array(1,2,3,4,5))) == 0\nTrue', 'hidden': False, 'locked': False}, {'code': '>>> np.isclose(standard_units(make_array(1,2,3,4,5))[0], -1.41421356)\nTrue', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
test = {'name': 'q1_2', 'points': 1, 'suites': [{'cases': [{'code': '>>> sum(standard_units(make_array(1,2,3,4,5))) == 0\nTrue', 'hidden': False, 'locked': False}, {'code': '>>> np.isclose(standard_units(make_array(1,2,3,4,5))[0], -1.41421356)\nTrue', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
x = input() total = 0 while x != "NoMoreMoney": money = float(x) if money > 0: total += money print(f"Increase: {money:.2f}") x = input() elif money < 0: print("Invalid operation!") break print(f"Total: {total:.2f}")
x = input() total = 0 while x != 'NoMoreMoney': money = float(x) if money > 0: total += money print(f'Increase: {money:.2f}') x = input() elif money < 0: print('Invalid operation!') break print(f'Total: {total:.2f}')
#File Locations EXTRACT_LIST_FILE = "ExtractList.xlsx" RAW_DATA_FILE = "../../output/WorldBank/WDIData.csv" OUTPUT_PATH = "../../output/WorldBank/split_output/"
extract_list_file = 'ExtractList.xlsx' raw_data_file = '../../output/WorldBank/WDIData.csv' output_path = '../../output/WorldBank/split_output/'
# https://leetcode.com/problems/lucky-numbers-in-a-matrix def lucky_numbers(matrix): all_lucky_numbers, all_mins = [], [] for row in matrix: found_min, col_index = float('Inf'), -1 for index, column in enumerate(row): if column < found_min: found_min = column col_index = index all_mins.append([found_min, col_index]) for a_min in all_mins: [min_value, min_column] = a_min maximum = float('-Inf') for index in range(len(matrix)): num = matrix[index][min_column] maximum = max(num, maximum) if maximum == min_value: all_lucky_numbers.append(min_value) return all_lucky_numbers
def lucky_numbers(matrix): (all_lucky_numbers, all_mins) = ([], []) for row in matrix: (found_min, col_index) = (float('Inf'), -1) for (index, column) in enumerate(row): if column < found_min: found_min = column col_index = index all_mins.append([found_min, col_index]) for a_min in all_mins: [min_value, min_column] = a_min maximum = float('-Inf') for index in range(len(matrix)): num = matrix[index][min_column] maximum = max(num, maximum) if maximum == min_value: all_lucky_numbers.append(min_value) return all_lucky_numbers
[ [float("NaN"), float("NaN"), 66.66666667, 33.33333333, 0.0], [float("NaN"), float("NaN"), 33.33333333, 66.66666667, 66.66666667], [float("NaN"), float("NaN"), 0.0, 0.0, 33.33333333], ]
[[float('NaN'), float('NaN'), 66.66666667, 33.33333333, 0.0], [float('NaN'), float('NaN'), 33.33333333, 66.66666667, 66.66666667], [float('NaN'), float('NaN'), 0.0, 0.0, 33.33333333]]
encrypted_string = 'OMQEMDUEQMEK' for i in range(1,27): temp_str = "" for x in encrypted_string: int_val = ord(x) + i if int_val > 90: # 90 is the numerical value for 'Z' # 65 is the numerical value for 'A' # If int_val is greater than Z then # the number is greater then 90 then # we must again count the difference # from A. int_val = 64 + (int_val - 90) temp_str += chr(int_val) print(f"{i} {temp_str}")
encrypted_string = 'OMQEMDUEQMEK' for i in range(1, 27): temp_str = '' for x in encrypted_string: int_val = ord(x) + i if int_val > 90: int_val = 64 + (int_val - 90) temp_str += chr(int_val) print(f'{i} {temp_str}')
# -*- coding: utf-8 -*- ## \package dbr.moduleaccess # MIT licensing # See: docs/LICENSE.txt ## This class allows access to a 'name' attribute # # \param module_name # \b \e unicode|str : Ideally set to the module's __name__ attribute class ModuleAccessCtrl: def __init__(self, moduleName): self.ModuleName = moduleName ## Retrieves the module_name attribute # # \return # \b \e unicode|str : Module's name def GetModuleName(self): return self.ModuleName
class Moduleaccessctrl: def __init__(self, moduleName): self.ModuleName = moduleName def get_module_name(self): return self.ModuleName
# ternary method num1 = int(input('Enter the number 1::')) num2 = int(input('\nEnter the number 2::')) num3 = int(input('\nEnter the number 3::')) max = (num1 if (num1 > num2 and num1 > num3) else (num2 if(num2 > num3 and num2 > num1) else num3)) print('\n\nThe maximum number is ::', max) #with pre-define functions # a = int(input('Enter the number A::')) # b = int(input('\nEnter the number B::')) # c = int(input('\nEnter the number C::')) # print("\nThe greatest number is :: ", max(a, b, c)) # print("\nThe minimum number is:: ", min(a, b, c)) # simple method # a = int(input('Enter the number A::')) # b = int(input('\nEnter the number B::')) # c = int(input('\nEnter the number C::')) # if a > b and a > c: # print('\n\nThe greatest is A',a) # elif b > c and b > a: # print('\n\nThe greatest is B::',b) # else: # print('\n\nThe greatest is C::', c)
num1 = int(input('Enter the number 1::')) num2 = int(input('\nEnter the number 2::')) num3 = int(input('\nEnter the number 3::')) max = num1 if num1 > num2 and num1 > num3 else num2 if num2 > num3 and num2 > num1 else num3 print('\n\nThe maximum number is ::', max)
num1 = int(input()) num2 = int(input()) if(num1>=num2): print(num1) else:print(num2)
num1 = int(input()) num2 = int(input()) if num1 >= num2: print(num1) else: print(num2)
class Solution: def leastInterval(self, tasks: List[str], n: int) -> int: tasksDict = collections.Counter(tasks) heap = [] c = 0 for k, v in tasksDict.items(): heappush(heap, (-v, k)) while heap: i = 0 stack = [] while i <= n: if len(heap) > 0: index, task = heappop(heap) if index != -1: stack.append((index + 1, task)) c += 1 if len(heap) == 0 and len(stack) == 0: break i += 1 for i in stack: heappush(heap, i) return c
class Solution: def least_interval(self, tasks: List[str], n: int) -> int: tasks_dict = collections.Counter(tasks) heap = [] c = 0 for (k, v) in tasksDict.items(): heappush(heap, (-v, k)) while heap: i = 0 stack = [] while i <= n: if len(heap) > 0: (index, task) = heappop(heap) if index != -1: stack.append((index + 1, task)) c += 1 if len(heap) == 0 and len(stack) == 0: break i += 1 for i in stack: heappush(heap, i) return c
# Written 9/10/14 by dh4gan # Some useful functions for classifying eigenvalues and defining structure def classify_eigenvalue(eigenvalues, threshold): '''Given 3 eigenvalues, and some threshold, returns an integer 'iclass' corresponding to the number of eigenvalues below the threshold iclass = 0 --> clusters (3 +ve eigenvalues, 0 -ve) iclass = 1 --> filaments (2 +ve eigenvalues, 1 -ve) iclass = 2 --> sheet (1 +ve eigenvalues, 2 -ve) iclass = 3 --> voids (0 +ve eigenvalues, 3 -ve) ''' iclass = 0 for i in range(3): if(eigenvalues[i]<threshold): iclass +=1 return int(iclass)
def classify_eigenvalue(eigenvalues, threshold): """Given 3 eigenvalues, and some threshold, returns an integer 'iclass' corresponding to the number of eigenvalues below the threshold iclass = 0 --> clusters (3 +ve eigenvalues, 0 -ve) iclass = 1 --> filaments (2 +ve eigenvalues, 1 -ve) iclass = 2 --> sheet (1 +ve eigenvalues, 2 -ve) iclass = 3 --> voids (0 +ve eigenvalues, 3 -ve) """ iclass = 0 for i in range(3): if eigenvalues[i] < threshold: iclass += 1 return int(iclass)
# ------------------------------------------------------------------------- # # THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, # EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. # ---------------------------------------------------------------------------------- # The example companies, organizations, products, domain names, # e-mail addresses, logos, people, places, and events depicted # herein are fictitious. No association with any real company, # organization, product, domain name, email address, logo, person, # places, or events is intended or should be inferred. # -------------------------------------------------------------------------- # Global constant variables (Azure Storage account/Batch details) # import "config.py" in "batch_python_tutorial_ffmpeg.py" # Update the Batch and Storage account credential strings below with the values # unique to your accounts. These are used when constructing connection strings # for the Batch and Storage client objects. _BATCH_ACCOUNT_NAME = '' _BATCH_ACCOUNT_KEY = '' _BATCH_ACCOUNT_URL = '' _STORAGE_ACCOUNT_NAME = '' _STORAGE_ACCOUNT_KEY = '' _INPUT_BLOB_PREFIX = '' # E.g. if files in container/READS/ then put 'READS'. Keep blank if files are directly in container and not in a sub-directory _INPUT_CONTAINER = '' _OUTPUT_CONTAINER = '' _POOL_ID = '' _DEDICATED_POOL_NODE_COUNT = 0 _LOW_PRIORITY_POOL_NODE_COUNT = 1 _POOL_VM_SIZE = 'STANDARD_D64_v3' _JOB_ID = ''
_batch_account_name = '' _batch_account_key = '' _batch_account_url = '' _storage_account_name = '' _storage_account_key = '' _input_blob_prefix = '' _input_container = '' _output_container = '' _pool_id = '' _dedicated_pool_node_count = 0 _low_priority_pool_node_count = 1 _pool_vm_size = 'STANDARD_D64_v3' _job_id = ''
minombre = "NaCho" minombre = minombre.lower() print (minombre) for i in range(100): print(i) break
minombre = 'NaCho' minombre = minombre.lower() print(minombre) for i in range(100): print(i) break
class SceneManager: def __init__(self): self.scene_list = {} self.current_scene = None def append_scene(self, scene_name, scene): self.scene_list[scene_name] = scene def set_current_scene(self, scene_name): self.current_scene = self.scene_list[scene_name] class Scene: def __init__(self, scene_manager): self.sm = scene_manager def handle_event(self, event): pass def update(self): pass def render(self): pass
class Scenemanager: def __init__(self): self.scene_list = {} self.current_scene = None def append_scene(self, scene_name, scene): self.scene_list[scene_name] = scene def set_current_scene(self, scene_name): self.current_scene = self.scene_list[scene_name] class Scene: def __init__(self, scene_manager): self.sm = scene_manager def handle_event(self, event): pass def update(self): pass def render(self): pass
class Solution: def binary_search(self, array, val): index = bisect_left(array, val) if index != len(array) and array[index] == val: return index else: return -1 def smallestCommonElement(self, mat: List[List[int]]) -> int: values = mat[0] mat.pop(0) for i, val in enumerate(values): flag = True for arr in mat: idx = self.binary_search(arr, val) if idx == -1: flag = False break if flag: return val return -1
class Solution: def binary_search(self, array, val): index = bisect_left(array, val) if index != len(array) and array[index] == val: return index else: return -1 def smallest_common_element(self, mat: List[List[int]]) -> int: values = mat[0] mat.pop(0) for (i, val) in enumerate(values): flag = True for arr in mat: idx = self.binary_search(arr, val) if idx == -1: flag = False break if flag: return val return -1
# This problem was asked by Facebook. # Given a binary tree, return all paths from the root to leaves. # For example, given the tree # 1 # / \ # 2 3 # / \ # 4 5 # it should return [[1, 2], [1, 3, 4], [1, 3, 5]]. #### class Node: def __init__(self, val = None, left = None, right = None): self.val = val self.left = left self.right = right l1 = Node(5) l2 = Node(3) l3 = Node(7) l4 = Node(4) m1 = Node(2, l1, l2) m2 = Node(1, l3, l4) root = Node(6, m1, m2) #### def paths(root): # if no node, it does not contribute to the path if not root: return [] # if leaf node, return node as is if not root.left and not root.right: return [[root.val]] # generate paths to the left and right of current node p = paths(root.left) + paths(root.right) # prepend current value to generated paths p = [[root.val] + p[i] for i in range(len(p))] return p #### print(paths(root))
class Node: def __init__(self, val=None, left=None, right=None): self.val = val self.left = left self.right = right l1 = node(5) l2 = node(3) l3 = node(7) l4 = node(4) m1 = node(2, l1, l2) m2 = node(1, l3, l4) root = node(6, m1, m2) def paths(root): if not root: return [] if not root.left and (not root.right): return [[root.val]] p = paths(root.left) + paths(root.right) p = [[root.val] + p[i] for i in range(len(p))] return p print(paths(root))
class ApiConfig: api_key = None api_base = 'https://www.quandl.com/api/v3' api_version = None page_limit = 100
class Apiconfig: api_key = None api_base = 'https://www.quandl.com/api/v3' api_version = None page_limit = 100
_BEGIN = 0 ZERO=0 RAND=1 _END = 10
_begin = 0 zero = 0 rand = 1 _end = 10
# -*- coding: utf-8 -*- def main(): n, d = map(int, input().split()) s = [input() for _ in range(d)] ans = 0 for i in range(d): for j in range(i, d): if i != j: count = 0 for si, sj in zip(s[i], s[j]): if si == 'o' or sj == 'o': count += 1 ans = max(ans, count) print(ans) if __name__ == '__main__': main()
def main(): (n, d) = map(int, input().split()) s = [input() for _ in range(d)] ans = 0 for i in range(d): for j in range(i, d): if i != j: count = 0 for (si, sj) in zip(s[i], s[j]): if si == 'o' or sj == 'o': count += 1 ans = max(ans, count) print(ans) if __name__ == '__main__': main()
TOPIC = "test.mosquitto.org" # Temperature and umidity publish interval (seconds) DATA_PUBLISH_INTERVAL = 5 # Data amount needed to start processing (reset after) DATA_PROCESS_AMOUNT = 5 # Percentage of mean temperature which will be sent to the air conditioner AIR_CONDITIONER_PERCENTAGE = 0.8 # Humidity below this level will turn the humidifier on HUMIDIFIER_LOWER_THRESHOLD = 50 # Humidity above this level will turn the humidifier off HUMIDIFIER_UPPER_THRESHOLD = 80
topic = 'test.mosquitto.org' data_publish_interval = 5 data_process_amount = 5 air_conditioner_percentage = 0.8 humidifier_lower_threshold = 50 humidifier_upper_threshold = 80
PAGINATE_MODULES = { "Leads": { "stream_name": "leads", "module_name": "Leads", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Deals": { "stream_name": "deals", "module_name": "Deals", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Contacts": { "stream_name": "contacts", "module_name": "Contacts", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Accounts": { "stream_name": "accounts", "module_name": "Accounts", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Tasks": { "stream_name": "tasks", "module_name": "Tasks", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Events": { "stream_name": "events", "module_name": "Events", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Calls": { "stream_name": "calls", "module_name": "Calls", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Activities": { "stream_name": "activities", "module_name": "Activities", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Visits": { "stream_name": "visits", "module_name": "Visits", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Invoices": { "stream_name": "invoices", "module_name": "Invoices", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Notes": { "stream_name": "notes", "module_name": "Notes", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Attachments": { "stream_name": "attachments", "module_name": "Attachments", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, "Lead_Status_History": { "stream_name": "lead_status_history", "module_name": "Lead_Status_History", "params": {"per_page": 200, "sort_by": "Modified_Time", "sort_order": "asc"}, "bookmark_key": "Modified_Time", }, } NON_PAGINATE_MODULES = { "org": { "module_name": "org", "stream_name": "org_settings", }, "settings/stages": { "module_name": "settings/stages", "stream_name": "settings_stages", "params": {"module": "Deals"}, }, } KNOWN_SUBMODULES = { "Deals": [ { "module_name": "Stage_History", "stream_name": "deals_stage_history", "bookmark_key": "Last_Modified_Time", } ] }
paginate_modules = {'Leads': {'stream_name': 'leads', 'module_name': 'Leads', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Deals': {'stream_name': 'deals', 'module_name': 'Deals', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Contacts': {'stream_name': 'contacts', 'module_name': 'Contacts', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Accounts': {'stream_name': 'accounts', 'module_name': 'Accounts', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Tasks': {'stream_name': 'tasks', 'module_name': 'Tasks', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Events': {'stream_name': 'events', 'module_name': 'Events', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Calls': {'stream_name': 'calls', 'module_name': 'Calls', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Activities': {'stream_name': 'activities', 'module_name': 'Activities', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Visits': {'stream_name': 'visits', 'module_name': 'Visits', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Invoices': {'stream_name': 'invoices', 'module_name': 'Invoices', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Notes': {'stream_name': 'notes', 'module_name': 'Notes', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Attachments': {'stream_name': 'attachments', 'module_name': 'Attachments', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}, 'Lead_Status_History': {'stream_name': 'lead_status_history', 'module_name': 'Lead_Status_History', 'params': {'per_page': 200, 'sort_by': 'Modified_Time', 'sort_order': 'asc'}, 'bookmark_key': 'Modified_Time'}} non_paginate_modules = {'org': {'module_name': 'org', 'stream_name': 'org_settings'}, 'settings/stages': {'module_name': 'settings/stages', 'stream_name': 'settings_stages', 'params': {'module': 'Deals'}}} known_submodules = {'Deals': [{'module_name': 'Stage_History', 'stream_name': 'deals_stage_history', 'bookmark_key': 'Last_Modified_Time'}]}
for arquivo in os.listdir(caminho): caminho_completo = os.path.join(caminho, arquivo) #zip.write(caminho_completo, arquivo) print(caminho_completo)
for arquivo in os.listdir(caminho): caminho_completo = os.path.join(caminho, arquivo) print(caminho_completo)
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: (x[0], -x[1])) count = 0 end = -1 for a, b in intervals: if b > end: count += 1 end = b return count
class Solution: def remove_covered_intervals(self, intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: (x[0], -x[1])) count = 0 end = -1 for (a, b) in intervals: if b > end: count += 1 end = b return count
def comb(n, k): nCk = 1 MOD = 10**9+7 for i in range(n-k+1, n+1): nCk *= i nCk %= MOD for i in range(1, k+1): nCk *= pow(i, MOD-2, MOD) nCk %= MOD return nCk n, a, b = map(int, input().split()) mod = 10**9+7 ans = pow(2, n, mod)-1-comb(n, a)-comb(n, b) print(ans % mod)
def comb(n, k): n_ck = 1 mod = 10 ** 9 + 7 for i in range(n - k + 1, n + 1): n_ck *= i n_ck %= MOD for i in range(1, k + 1): n_ck *= pow(i, MOD - 2, MOD) n_ck %= MOD return nCk (n, a, b) = map(int, input().split()) mod = 10 ** 9 + 7 ans = pow(2, n, mod) - 1 - comb(n, a) - comb(n, b) print(ans % mod)
dict1={1:"John",2:"Bob",3:"Bill"} print(dict1) print(dict1.items()) k=dict1.keys() for key in k: print(key) v=dict1.values() for value in v: print(value) print(dict1[3]) del dict1[2] print(dict1)
dict1 = {1: 'John', 2: 'Bob', 3: 'Bill'} print(dict1) print(dict1.items()) k = dict1.keys() for key in k: print(key) v = dict1.values() for value in v: print(value) print(dict1[3]) del dict1[2] print(dict1)
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # lzma_sdk for standalone build. { 'targets': [ { 'target_name': 'ots_lzma_sdk', 'type': 'static_library', 'defines': [ '_7ZIP_ST', # Disable multi-thread support. '_LZMA_PROB32', # This could increase the speed on 32bit platform. ], 'sources': [ 'Alloc.c', 'Alloc.h', 'LzFind.c', 'LzFind.h', 'LzHash.h', 'LzmaEnc.c', 'LzmaEnc.h', 'LzmaDec.c', 'LzmaDec.h', 'LzmaLib.c', 'LzmaLib.h', 'Types.h', ], 'include_dirs': [ '.', ], 'direct_dependent_settings': { 'include_dirs': [ '../..', ], }, }, ], }
{'targets': [{'target_name': 'ots_lzma_sdk', 'type': 'static_library', 'defines': ['_7ZIP_ST', '_LZMA_PROB32'], 'sources': ['Alloc.c', 'Alloc.h', 'LzFind.c', 'LzFind.h', 'LzHash.h', 'LzmaEnc.c', 'LzmaEnc.h', 'LzmaDec.c', 'LzmaDec.h', 'LzmaLib.c', 'LzmaLib.h', 'Types.h'], 'include_dirs': ['.'], 'direct_dependent_settings': {'include_dirs': ['../..']}}]}
# Create a sequence where each element is an individual base of DNA. # Make the array 15 bases long. bases = 'ATTCGGTCATGCTAA' # Print the length of the sequence print("DNA sequence length:", len(bases)) # Create a for loop to output every base of the sequence on a new line. print("All bases:") for base in bases: print(base)
bases = 'ATTCGGTCATGCTAA' print('DNA sequence length:', len(bases)) print('All bases:') for base in bases: print(base)
# Team 5 def save_to_json(datatables: list, directory=None): pass def open_json(): pass
def save_to_json(datatables: list, directory=None): pass def open_json(): pass
_base_ = "./FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_Pbr_01_ape.py" OUTPUT_DIR = "output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_lmPbr_SO/duck" DATASETS = dict(TRAIN=("lm_pbr_duck_train",), TEST=("lm_real_duck_test",)) # bbnc6 # objects duck Avg(1) # ad_2 4.23 4.23 # ad_5 26.01 26.01 # ad_10 61.88 61.88 # rete_2 54.37 54.37 # rete_5 97.28 97.28 # rete_10 100.00 100.00 # re_2 59.15 59.15 # re_5 97.28 97.28 # re_10 100.00 100.00 # te_2 89.67 89.67 # te_5 100.00 100.00 # te_10 100.00 100.00 # proj_2 85.63 85.63 # proj_5 98.22 98.22 # proj_10 99.91 99.91 # re 2.02 2.02 # te 0.01 0.01
_base_ = './FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_Pbr_01_ape.py' output_dir = 'output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_lmPbr_SO/duck' datasets = dict(TRAIN=('lm_pbr_duck_train',), TEST=('lm_real_duck_test',))
class Solution: def sortArray(self, nums: List[int]) -> List[int]: temp = [0] * len(nums) def mergeSort(start, end): if start < end: mid = (start + end) // 2 mergeSort(start, mid) mergeSort(mid + 1, end) i = k = start j = mid + 1 while i <= mid: while j <= end and nums[j] < nums[i]: temp[k] = nums[j] j += 1 k += 1 temp[k] = nums[i] i += 1 k += 1 while j <= end: temp[k] = nums[j] j += 1 k += 1 nums[start: end + 1] = temp[start: end + 1] mergeSort(0, len(nums) - 1) return nums
class Solution: def sort_array(self, nums: List[int]) -> List[int]: temp = [0] * len(nums) def merge_sort(start, end): if start < end: mid = (start + end) // 2 merge_sort(start, mid) merge_sort(mid + 1, end) i = k = start j = mid + 1 while i <= mid: while j <= end and nums[j] < nums[i]: temp[k] = nums[j] j += 1 k += 1 temp[k] = nums[i] i += 1 k += 1 while j <= end: temp[k] = nums[j] j += 1 k += 1 nums[start:end + 1] = temp[start:end + 1] merge_sort(0, len(nums) - 1) return nums
class Foo0(): def __init__(self): pass foo1 = Foo0() class Foo0(): ## error: redefined class def __init__(self, a): pass foo2 = Foo0()
class Foo0: def __init__(self): pass foo1 = foo0() class Foo0: def __init__(self, a): pass foo2 = foo0()
# List of possible Pokemon types types = [ "Normal", "Fire", "Water", "Electric", "Grass", "Ice", "Fighting", "Poison", "Ground", "Flying", "Psychic", "Bug", "Rock", "Ghost", "Dragon", "Dark", "Steel", "Fairy" ] # Chart of type weaknesses. type_dict["Water"]["Fire"] assumes water is attacking fire. type_dict = {"Normal": {"Normal":1, "Fire":1, "Water":1, "Electric":1, "Grass":1, "Ice":1, "Fighting":1, "Poison":1, "Ground":1, "Flying":1, "Psychic":1, "Bug":1, "Rock":0.5, "Ghost":0, "Dragon":1, "Dark":1, "Steel":0.5, "Fairy":1}, "Fire": {"Normal":1, "Fire":0.5, "Water":0.5, "Electric":1, "Grass":2, "Ice":2, "Fighting":1, "Poison":1, "Ground":1, "Flying":1, "Psychic":1, "Bug":2, "Rock":0.5, "Ghost":1, "Dragon":0.5, "Dark":1, "Steel":2, "Fairy":1}, "Water": {"Normal":1, "Fire":2, "Water":0.5, "Electric":1, "Grass":0.5, "Ice":1, "Fighting":1, "Poison":1, "Ground":2, "Flying":1, "Psychic":1, "Bug":1, "Rock":2, "Ghost":1, "Dragon":0.5, "Dark":1, "Steel":1, "Fairy":1}, "Electric": {"Normal":1, "Fire":1, "Water":2, "Electric":0.5, "Grass":0.5, "Ice":1, "Fighting":1, "Poison":1, "Ground":0, "Flying":2, "Psychic":1, "Bug":1, "Rock":1, "Ghost":1, "Dragon":0.5, "Dark":1, "Steel":1, "Fairy":1}, "Grass": {"Normal":1, "Fire":0.5, "Water":2, "Electric":1, "Grass":0.5, "Ice":1, "Fighting":1, "Poison":0.5, "Ground":2, "Flying":0.5, "Psychic":1, "Bug":0.5, "Rock":2, "Ghost":1, "Dragon":0.5, "Dark":1, "Steel":0.5, "Fairy":1}, "Ice": {"Normal":1, "Fire":0.5, "Water":0.5, "Electric":1, "Grass":2, "Ice":0.5, "Fighting":1, "Poison":1, "Ground":2, "Flying":2, "Psychic":1, "Bug":1, "Rock":1, "Ghost":1, "Dragon":2, "Dark":1, "Steel":0.5, "Fairy":1}, "Fighting": {"Normal":2, "Fire":1, "Water":1, "Electric":1, "Grass":1, "Ice":2, "Fighting":1, "Poison":0.5, "Ground":2, "Flying":0.5, "Psychic":0.5, "Bug":0.5, "Rock":2, "Ghost":0, "Dragon":1, "Dark":2, "Steel":2, "Fairy":0.5}, "Poison": {"Normal":1, "Fire":1, "Water":1, "Electric":1, "Grass":2, "Ice":1, "Fighting":1, "Poison":0.5, "Ground":0.5, "Flying":1, "Psychic":1, "Bug":1, "Rock":0.5, "Ghost":0.5, "Dragon":1, "Dark":1, "Steel":0, "Fairy":2}, "Ground": {"Normal":1, "Fire":2, "Water":1, "Electric":2, "Grass":0.5, "Ice":1, "Fighting":1, "Poison":2, "Ground":1, "Flying":0, "Psychic":1, "Bug":0.5, "Rock":2, "Ghost":1, "Dragon":1, "Dark":1, "Steel":2, "Fairy":1}, "Flying": {"Normal":1, "Fire":1, "Water":1, "Electric":0.5, "Grass":2, "Ice":1, "Fighting":2, "Poison":1, "Ground":1, "Flying":1, "Psychic":1, "Bug":2, "Rock":0.5, "Ghost":1, "Dragon":1, "Dark":1, "Steel":0.5, "Fairy":1}, "Psychic": {"Normal":1, "Fire":1, "Water":1, "Electric":1, "Grass":1, "Ice":1, "Fighting":2, "Poison":2, "Ground":1, "Flying":1, "Psychic":0.5, "Bug":1, "Rock":1, "Ghost":1, "Dragon":1, "Dark":0, "Steel":0.5, "Fairy":1}, "Bug": {"Normal":1, "Fire":0.5, "Water":1, "Electric":1, "Grass":2, "Ice":1, "Fighting":0.5, "Poison":0.5, "Ground":1, "Flying":0.5, "Psychic":2, "Bug":1, "Rock":1, "Ghost":0.5, "Dragon":1, "Dark":2, "Steel":0.5, "Fairy":0.5}, "Rock": {"Normal":1, "Fire":2, "Water":1, "Electric":1, "Grass":1, "Ice":2, "Fighting":0.5, "Poison":1, "Ground":0.5, "Flying":2, "Psychic":1, "Bug":2, "Rock":1, "Ghost":1, "Dragon":1, "Dark":1, "Steel":0.5, "Fairy":1}, "Ghost": {"Normal":0, "Fire":1, "Water":1, "Electric":1, "Grass":1, "Ice":1, "Fighting":1, "Poison":1, "Ground":1, "Flying":1, "Psychic":2, "Bug":1, "Rock":1, "Ghost":2, "Dragon":1, "Dark":0.5, "Steel":1, "Fairy":1}, "Dragon": {"Normal":1, "Fire":1, "Water":1, "Electric":1, "Grass":1, "Ice":1, "Fighting":1, "Poison":1, "Ground":1, "Flying":1, "Psychic":1, "Bug":1, "Rock":1, "Ghost":1, "Dragon":2, "Dark":1, "Steel":0.5, "Fairy":0}, "Dark": {"Normal":1, "Fire":1, "Water":1, "Electric":1, "Grass":1, "Ice":1, "Fighting":0.5, "Poison":1, "Ground":1, "Flying":1, "Psychic":2, "Bug":1, "Rock":1, "Ghost":2, "Dragon":1, "Dark":0.5, "Steel":1, "Fairy":0.5}, "Steel": {"Normal":1, "Fire":0.5, "Water":0.5, "Electric":0.5, "Grass":1, "Ice":2, "Fighting":1, "Poison":1, "Ground":1, "Flying":1, "Psychic":1, "Bug":1, "Rock":2, "Ghost":1, "Dragon":1, "Dark":1, "Steel":0.5, "Fairy":1}, "Fairy": {"Normal":1, "Fire":0.5, "Water":1, "Electric":1, "Grass":1, "Ice":1, "Fighting":2, "Poison":0.5, "Ground":1, "Flying":1, "Psychic":1, "Bug":1, "Rock":1, "Ghost":1, "Dragon":2, "Dark":2, "Steel":0.5, "Fairy":1} }
types = ['Normal', 'Fire', 'Water', 'Electric', 'Grass', 'Ice', 'Fighting', 'Poison', 'Ground', 'Flying', 'Psychic', 'Bug', 'Rock', 'Ghost', 'Dragon', 'Dark', 'Steel', 'Fairy'] type_dict = {'Normal': {'Normal': 1, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 1, 'Fighting': 1, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 1, 'Bug': 1, 'Rock': 0.5, 'Ghost': 0, 'Dragon': 1, 'Dark': 1, 'Steel': 0.5, 'Fairy': 1}, 'Fire': {'Normal': 1, 'Fire': 0.5, 'Water': 0.5, 'Electric': 1, 'Grass': 2, 'Ice': 2, 'Fighting': 1, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 1, 'Bug': 2, 'Rock': 0.5, 'Ghost': 1, 'Dragon': 0.5, 'Dark': 1, 'Steel': 2, 'Fairy': 1}, 'Water': {'Normal': 1, 'Fire': 2, 'Water': 0.5, 'Electric': 1, 'Grass': 0.5, 'Ice': 1, 'Fighting': 1, 'Poison': 1, 'Ground': 2, 'Flying': 1, 'Psychic': 1, 'Bug': 1, 'Rock': 2, 'Ghost': 1, 'Dragon': 0.5, 'Dark': 1, 'Steel': 1, 'Fairy': 1}, 'Electric': {'Normal': 1, 'Fire': 1, 'Water': 2, 'Electric': 0.5, 'Grass': 0.5, 'Ice': 1, 'Fighting': 1, 'Poison': 1, 'Ground': 0, 'Flying': 2, 'Psychic': 1, 'Bug': 1, 'Rock': 1, 'Ghost': 1, 'Dragon': 0.5, 'Dark': 1, 'Steel': 1, 'Fairy': 1}, 'Grass': {'Normal': 1, 'Fire': 0.5, 'Water': 2, 'Electric': 1, 'Grass': 0.5, 'Ice': 1, 'Fighting': 1, 'Poison': 0.5, 'Ground': 2, 'Flying': 0.5, 'Psychic': 1, 'Bug': 0.5, 'Rock': 2, 'Ghost': 1, 'Dragon': 0.5, 'Dark': 1, 'Steel': 0.5, 'Fairy': 1}, 'Ice': {'Normal': 1, 'Fire': 0.5, 'Water': 0.5, 'Electric': 1, 'Grass': 2, 'Ice': 0.5, 'Fighting': 1, 'Poison': 1, 'Ground': 2, 'Flying': 2, 'Psychic': 1, 'Bug': 1, 'Rock': 1, 'Ghost': 1, 'Dragon': 2, 'Dark': 1, 'Steel': 0.5, 'Fairy': 1}, 'Fighting': {'Normal': 2, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 2, 'Fighting': 1, 'Poison': 0.5, 'Ground': 2, 'Flying': 0.5, 'Psychic': 0.5, 'Bug': 0.5, 'Rock': 2, 'Ghost': 0, 'Dragon': 1, 'Dark': 2, 'Steel': 2, 'Fairy': 0.5}, 'Poison': {'Normal': 1, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 2, 'Ice': 1, 'Fighting': 1, 'Poison': 0.5, 'Ground': 0.5, 'Flying': 1, 'Psychic': 1, 'Bug': 1, 'Rock': 0.5, 'Ghost': 0.5, 'Dragon': 1, 'Dark': 1, 'Steel': 0, 'Fairy': 2}, 'Ground': {'Normal': 1, 'Fire': 2, 'Water': 1, 'Electric': 2, 'Grass': 0.5, 'Ice': 1, 'Fighting': 1, 'Poison': 2, 'Ground': 1, 'Flying': 0, 'Psychic': 1, 'Bug': 0.5, 'Rock': 2, 'Ghost': 1, 'Dragon': 1, 'Dark': 1, 'Steel': 2, 'Fairy': 1}, 'Flying': {'Normal': 1, 'Fire': 1, 'Water': 1, 'Electric': 0.5, 'Grass': 2, 'Ice': 1, 'Fighting': 2, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 1, 'Bug': 2, 'Rock': 0.5, 'Ghost': 1, 'Dragon': 1, 'Dark': 1, 'Steel': 0.5, 'Fairy': 1}, 'Psychic': {'Normal': 1, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 1, 'Fighting': 2, 'Poison': 2, 'Ground': 1, 'Flying': 1, 'Psychic': 0.5, 'Bug': 1, 'Rock': 1, 'Ghost': 1, 'Dragon': 1, 'Dark': 0, 'Steel': 0.5, 'Fairy': 1}, 'Bug': {'Normal': 1, 'Fire': 0.5, 'Water': 1, 'Electric': 1, 'Grass': 2, 'Ice': 1, 'Fighting': 0.5, 'Poison': 0.5, 'Ground': 1, 'Flying': 0.5, 'Psychic': 2, 'Bug': 1, 'Rock': 1, 'Ghost': 0.5, 'Dragon': 1, 'Dark': 2, 'Steel': 0.5, 'Fairy': 0.5}, 'Rock': {'Normal': 1, 'Fire': 2, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 2, 'Fighting': 0.5, 'Poison': 1, 'Ground': 0.5, 'Flying': 2, 'Psychic': 1, 'Bug': 2, 'Rock': 1, 'Ghost': 1, 'Dragon': 1, 'Dark': 1, 'Steel': 0.5, 'Fairy': 1}, 'Ghost': {'Normal': 0, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 1, 'Fighting': 1, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 2, 'Bug': 1, 'Rock': 1, 'Ghost': 2, 'Dragon': 1, 'Dark': 0.5, 'Steel': 1, 'Fairy': 1}, 'Dragon': {'Normal': 1, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 1, 'Fighting': 1, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 1, 'Bug': 1, 'Rock': 1, 'Ghost': 1, 'Dragon': 2, 'Dark': 1, 'Steel': 0.5, 'Fairy': 0}, 'Dark': {'Normal': 1, 'Fire': 1, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 1, 'Fighting': 0.5, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 2, 'Bug': 1, 'Rock': 1, 'Ghost': 2, 'Dragon': 1, 'Dark': 0.5, 'Steel': 1, 'Fairy': 0.5}, 'Steel': {'Normal': 1, 'Fire': 0.5, 'Water': 0.5, 'Electric': 0.5, 'Grass': 1, 'Ice': 2, 'Fighting': 1, 'Poison': 1, 'Ground': 1, 'Flying': 1, 'Psychic': 1, 'Bug': 1, 'Rock': 2, 'Ghost': 1, 'Dragon': 1, 'Dark': 1, 'Steel': 0.5, 'Fairy': 1}, 'Fairy': {'Normal': 1, 'Fire': 0.5, 'Water': 1, 'Electric': 1, 'Grass': 1, 'Ice': 1, 'Fighting': 2, 'Poison': 0.5, 'Ground': 1, 'Flying': 1, 'Psychic': 1, 'Bug': 1, 'Rock': 1, 'Ghost': 1, 'Dragon': 2, 'Dark': 2, 'Steel': 0.5, 'Fairy': 1}}
class Solution: def checkValidString(self, s: str) -> bool: left_count = 0 star_count = 0 for char in s: if char == '(': left_count += 1 elif char == '*': star_count += 1 else: if left_count > 0: left_count -= 1 elif star_count > 0: star_count -= 1 else: return False if left_count == 0: return True right_count = 0 star_count = 0 for char in s[::-1]: if char == ')': right_count += 1 elif char == '*': star_count += 1 else: if right_count > 0: right_count -= 1 elif star_count >0: star_count -= 1 else: return False return True
class Solution: def check_valid_string(self, s: str) -> bool: left_count = 0 star_count = 0 for char in s: if char == '(': left_count += 1 elif char == '*': star_count += 1 elif left_count > 0: left_count -= 1 elif star_count > 0: star_count -= 1 else: return False if left_count == 0: return True right_count = 0 star_count = 0 for char in s[::-1]: if char == ')': right_count += 1 elif char == '*': star_count += 1 elif right_count > 0: right_count -= 1 elif star_count > 0: star_count -= 1 else: return False return True
# Given an array of ints length 3, return an array with the elements "rotated # left" so {1, 2, 3} yields {2, 3, 1}. # rotate_left3([1, 2, 3]) --> [2, 3, 1] # rotate_left3([5, 11, 9]) --> [11, 9, 5] # rotate_left3([7, 0, 0]) --> [0, 0, 7] def rotate_left3(nums): nums.append(nums.pop(0)) return nums print(rotate_left3([1, 2, 3])) print(rotate_left3([5, 11, 9])) print(rotate_left3([7, 0, 0]))
def rotate_left3(nums): nums.append(nums.pop(0)) return nums print(rotate_left3([1, 2, 3])) print(rotate_left3([5, 11, 9])) print(rotate_left3([7, 0, 0]))
#!/usr/bin/env python3 # Parse input lines = [] with open("10/input.txt", "r") as fd: for line in fd: lines.append(line.rstrip()) illegal = [] for line in lines: stack = list() for c in line: if c == "(": stack.append(")") elif c == "[": stack.append("]") elif c == "{": stack.append("}") elif c == "<": stack.append(">") else: # Closing if len(stack) == 0: illegal.append(c) break expected = stack.pop() if c != expected: illegal.append(c) break mapping = { ")": 3, "]": 57, "}": 1197, ">": 25137 } print(sum([mapping[x] for x in illegal]))
lines = [] with open('10/input.txt', 'r') as fd: for line in fd: lines.append(line.rstrip()) illegal = [] for line in lines: stack = list() for c in line: if c == '(': stack.append(')') elif c == '[': stack.append(']') elif c == '{': stack.append('}') elif c == '<': stack.append('>') else: if len(stack) == 0: illegal.append(c) break expected = stack.pop() if c != expected: illegal.append(c) break mapping = {')': 3, ']': 57, '}': 1197, '>': 25137} print(sum([mapping[x] for x in illegal]))
class Node: def __init__(self, data): self.data = data self.next = None class Queue: def __init__(self): self.front = self.back = None def isEmpty(self): return self.front == None def EnQueue(self, item): temp = Node(item) if(self.back == None): self.front = self.back = temp return self.back.next = temp self.back = temp def DeQueue(self): if(self.isEmpty()): return temp = self.front self.front = temp.next if(self.front == None): self.back = None if __name__ == "__main__": queue = Queue() queue.EnQueue(20) queue.EnQueue(30) queue.DeQueue() queue.DeQueue() queue.EnQueue(40) queue.EnQueue(50) queue.EnQueue(60) queue.DeQueue() print("Queue Front " + str(queue.front.data)) print("Queue Back " + str(queue.back.data))
class Node: def __init__(self, data): self.data = data self.next = None class Queue: def __init__(self): self.front = self.back = None def is_empty(self): return self.front == None def en_queue(self, item): temp = node(item) if self.back == None: self.front = self.back = temp return self.back.next = temp self.back = temp def de_queue(self): if self.isEmpty(): return temp = self.front self.front = temp.next if self.front == None: self.back = None if __name__ == '__main__': queue = queue() queue.EnQueue(20) queue.EnQueue(30) queue.DeQueue() queue.DeQueue() queue.EnQueue(40) queue.EnQueue(50) queue.EnQueue(60) queue.DeQueue() print('Queue Front ' + str(queue.front.data)) print('Queue Back ' + str(queue.back.data))
#/* *** ODSATag: RFact *** */ # Recursively compute and return n! def rfact(n): if n < 0: raise ValueError if n <= 1: return 1 # Base case: return base solution return n * rfact(n-1) # Recursive call for n > 1 #/* *** ODSAendTag: RFact *** */ #/* *** ODSATag: Sfact *** */ # Return n! def sfact(n): if n < 0: raise ValueError # Make a stack just big enough S = AStack(n) while n > 1: S.push(n) n -= 1 result = 1 while S.length() > 0: result = result * S.pop() return result #/* *** ODSAendTag: Sfact *** */
def rfact(n): if n < 0: raise ValueError if n <= 1: return 1 return n * rfact(n - 1) def sfact(n): if n < 0: raise ValueError s = a_stack(n) while n > 1: S.push(n) n -= 1 result = 1 while S.length() > 0: result = result * S.pop() return result
r1, c1 = map(int, input().split()) r2, c2 = map(int, input().split()) if abs(r1 - r2) + abs(c1 - c2) == 0: print(0) exit() # Move if abs(r1 - r2) + abs(c1 - c2) <= 3: print(1) exit() r3 = r2 t = abs(r1 - r2) if abs(c1 + t - c2) < abs(c1 - t - c2): c3 = c1 + t else: c3 = c1 - t # Bishop warp if c3 == c2: print(1) exit() # Move + Move if abs(r1 - r2) + abs(c1 - c2) <= 6: print(2) exit() # Bishop warp + Move if abs(r3 - r2) + abs(c3 - c2) <= 3: print(2) exit() # Bishop warp + Bishop warp if (r1 + c1) % 2 == (r2 + c2) % 2: print(2) exit() # Bishop warp + Bishop warp + Move print(3)
(r1, c1) = map(int, input().split()) (r2, c2) = map(int, input().split()) if abs(r1 - r2) + abs(c1 - c2) == 0: print(0) exit() if abs(r1 - r2) + abs(c1 - c2) <= 3: print(1) exit() r3 = r2 t = abs(r1 - r2) if abs(c1 + t - c2) < abs(c1 - t - c2): c3 = c1 + t else: c3 = c1 - t if c3 == c2: print(1) exit() if abs(r1 - r2) + abs(c1 - c2) <= 6: print(2) exit() if abs(r3 - r2) + abs(c3 - c2) <= 3: print(2) exit() if (r1 + c1) % 2 == (r2 + c2) % 2: print(2) exit() print(3)
age = 10 num = 0 while num < age: if num == 0: num += 1 continue if num % 2 == 0: print(num) if num > 4: break num += 1
age = 10 num = 0 while num < age: if num == 0: num += 1 continue if num % 2 == 0: print(num) if num > 4: break num += 1
# This is Stack build using Singly Linked List class StackNode: def __init__(self, value): self.value = value self._next = None class Stack: def __init__(self): self.head = None # bottom self.tail = None # top self.size = 0 def __len__(self): return self.size def _size(self): return self.size def is_empty(self): return self.size == 0 def __str__(self): linked_list = "" current_node = self.head while current_node is not None: linked_list += f"{current_node.value} -> " current_node = current_node._next linked_list += "None" return linked_list def __repr__(self): return str(self) def push(self, value): node = StackNode(value) if self.is_empty(): self.head = self.tail = node else: self.tail._next = node self.tail = node self.size += 1 def pop(self): assert self.size != 0, 'Stack is empty' tmp = self.head self.size -= 1 if self.is_empty(): self.head = self.tail = None else: self.head = self.head._next return tmp s = Stack() print(s.is_empty()) # print(s) s.push(1) print(s, s.head.value, s.tail.value) s.push(2) print(s, s.head.value, s.tail.value) s.push(3) print(s, s.head.value, s.tail.value) s.push(4) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s)
class Stacknode: def __init__(self, value): self.value = value self._next = None class Stack: def __init__(self): self.head = None self.tail = None self.size = 0 def __len__(self): return self.size def _size(self): return self.size def is_empty(self): return self.size == 0 def __str__(self): linked_list = '' current_node = self.head while current_node is not None: linked_list += f'{current_node.value} -> ' current_node = current_node._next linked_list += 'None' return linked_list def __repr__(self): return str(self) def push(self, value): node = stack_node(value) if self.is_empty(): self.head = self.tail = node else: self.tail._next = node self.tail = node self.size += 1 def pop(self): assert self.size != 0, 'Stack is empty' tmp = self.head self.size -= 1 if self.is_empty(): self.head = self.tail = None else: self.head = self.head._next return tmp s = stack() print(s.is_empty()) s.push(1) print(s, s.head.value, s.tail.value) s.push(2) print(s, s.head.value, s.tail.value) s.push(3) print(s, s.head.value, s.tail.value) s.push(4) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s, s.head.value, s.tail.value) print(s.pop().value) print(s)
def create_data(n): temp = [i for i in range(n)] return temp n = 100 target = n + 11 ma_list = create_data(n) def binary_search(input_list,target): found = False low = 0 high = len(input_list) - 1 mid = int((high + low) / 2) while (low <=high) and (not found): curr = input_list[mid] if curr == target: found = True return True elif curr < target: low = mid +1 elif curr > target: high = mid - 1 mid = int((high + low) / 2) print(mid) return False print(binary_search(ma_list,target))
def create_data(n): temp = [i for i in range(n)] return temp n = 100 target = n + 11 ma_list = create_data(n) def binary_search(input_list, target): found = False low = 0 high = len(input_list) - 1 mid = int((high + low) / 2) while low <= high and (not found): curr = input_list[mid] if curr == target: found = True return True elif curr < target: low = mid + 1 elif curr > target: high = mid - 1 mid = int((high + low) / 2) print(mid) return False print(binary_search(ma_list, target))
# @Author: Ozan YILDIZ@2022 # Simple printing operation val = 12 if __name__ == '__main__': #print operation print("Boolean True (True)", val)
val = 12 if __name__ == '__main__': print('Boolean True (True)', val)
#Finding least trial def least_trial_num(n): #making 1000001 size buffer buffer = [] for i in range(1000001): buffer += [0] #Minimum calculation of 1 is 0 times. buffer[1] = 0 #Minimum calculations of other values for i in range(2, n + 1): #Since calculations of (n - 1), (n / 2), (n / 3) is all minimum-guaranteed, n is also minimum. #First, we set to calculations of n to 1 + calculations of (n - 1) buffer[i] = buffer[i - 1] + 1 #Comparing two if n can be divided by 2 if i % 2 == 0: buffer[i] = min2(buffer[i], buffer[i // 2] + 1) #Comparing two if n can be divided by 3 if i % 3 == 0: buffer[i] = min2(buffer[i], buffer[i // 3] + 1) #Returning a value return buffer[n] #This is fumction which finds least value of two def min2(a, b): if a < b: return a else: return b #Input part N = int(input()) #Output part print(least_trial_num(N))
def least_trial_num(n): buffer = [] for i in range(1000001): buffer += [0] buffer[1] = 0 for i in range(2, n + 1): buffer[i] = buffer[i - 1] + 1 if i % 2 == 0: buffer[i] = min2(buffer[i], buffer[i // 2] + 1) if i % 3 == 0: buffer[i] = min2(buffer[i], buffer[i // 3] + 1) return buffer[n] def min2(a, b): if a < b: return a else: return b n = int(input()) print(least_trial_num(N))
# environment variables ATOM_PROGRAM = '/home/physics/bin/atm' ATOM_UTILS_DIR ='/home/physics/bin/pseudo' element = "Al" equil_volume = 16.4796 # general calculation parameters calc = {"element": element, "lattice": "FCC", "xc": "pb", "n_core": 3, "n_val": 2, "is_spin_pol": False, "core": True, } # pseudopotential parameters electrons = [2, 1] radii = [2.4, 2.8, 2.3, 2.3, 0.7] # SIESTA calculation parameters siesta_calc = {"element": element, "title": element + " SIESTA calc", "xc_f": "GGA", "xc": "PBE" } # electronic configurations configs = [[1.5, 1.5], [1, 2], [0.5, 2.5], [0, 3]] # number of atoms in cubic cell _nat_cell = {"SC": 1, "BCC": 2, "FCC": 4} nat = _nat_cell[calc["lattice"]]
atom_program = '/home/physics/bin/atm' atom_utils_dir = '/home/physics/bin/pseudo' element = 'Al' equil_volume = 16.4796 calc = {'element': element, 'lattice': 'FCC', 'xc': 'pb', 'n_core': 3, 'n_val': 2, 'is_spin_pol': False, 'core': True} electrons = [2, 1] radii = [2.4, 2.8, 2.3, 2.3, 0.7] siesta_calc = {'element': element, 'title': element + ' SIESTA calc', 'xc_f': 'GGA', 'xc': 'PBE'} configs = [[1.5, 1.5], [1, 2], [0.5, 2.5], [0, 3]] _nat_cell = {'SC': 1, 'BCC': 2, 'FCC': 4} nat = _nat_cell[calc['lattice']]
idir="<path to public/template database>/"; odir=idir+"output/"; public_dir='DPA_contest2_public_base_diff_vcc_a128_2009_12_23/' template_dir='DPA_contest2_template_base_diff_vcc_a128_2009_12_23/' template_index_file=idir+'DPA_contest2_template_base_index_file' public_index_file=idir+'DPA_contest2_public_base_index_file' template_keymsg_file=idir+'keymsg_template_base_dpacontest2' public_keymsg_file=idir+'keymsg_public_base_dpacontest2' template_idir=idir+template_dir public_idir=idir+public_dir
idir = '<path to public/template database>/' odir = idir + 'output/' public_dir = 'DPA_contest2_public_base_diff_vcc_a128_2009_12_23/' template_dir = 'DPA_contest2_template_base_diff_vcc_a128_2009_12_23/' template_index_file = idir + 'DPA_contest2_template_base_index_file' public_index_file = idir + 'DPA_contest2_public_base_index_file' template_keymsg_file = idir + 'keymsg_template_base_dpacontest2' public_keymsg_file = idir + 'keymsg_public_base_dpacontest2' template_idir = idir + template_dir public_idir = idir + public_dir
def getNoZeroIntegers(self, n: int) -> List[int]: for i in range(1, n): a = i b = n - i if "0" in str(a) or "0" in str(b): continue return [a, b]
def get_no_zero_integers(self, n: int) -> List[int]: for i in range(1, n): a = i b = n - i if '0' in str(a) or '0' in str(b): continue return [a, b]
province = input('Enter you province: ') if province.lower() == 'surigao': print('Hi, I am from Surigao too.') else: print(f'Hi, so your from { province.capitalize() }')
province = input('Enter you province: ') if province.lower() == 'surigao': print('Hi, I am from Surigao too.') else: print(f'Hi, so your from {province.capitalize()}')
PrimeNums = [] Target = 10001 Number = 0 while len(PrimeNums) < Target: isPrime = True Number += 1 for x in range(2,9): if Number % x == 0 and Number != x: isPrime = False if isPrime: if Number == 1: False else: PrimeNums.append(Number) print(PrimeNums[-1])
prime_nums = [] target = 10001 number = 0 while len(PrimeNums) < Target: is_prime = True number += 1 for x in range(2, 9): if Number % x == 0 and Number != x: is_prime = False if isPrime: if Number == 1: False else: PrimeNums.append(Number) print(PrimeNums[-1])
# SET MISMATCH LEETCODE SOLUTION: # creating a class. class Solution(object): # creating a function to solve the problem. def findErrorNums(self, nums): # creating multiple variables to store various sums. actual_sum = sum(nums) set_sum = sum(set(nums)) a_sum = len(nums) * (len(nums) + 1) / 2 # returning the difference between appropriate sums. return [actual_sum - set_sum, a_sum - set_sum]
class Solution(object): def find_error_nums(self, nums): actual_sum = sum(nums) set_sum = sum(set(nums)) a_sum = len(nums) * (len(nums) + 1) / 2 return [actual_sum - set_sum, a_sum - set_sum]
s = input() t = input() print()
s = input() t = input() print()
def front_back(str): if len(str) < 2: return str n = len(str) first_char = str[0] last_char = str[n-1] middle_chars = str[1:(n-1)] return last_char + middle_chars + first_char
def front_back(str): if len(str) < 2: return str n = len(str) first_char = str[0] last_char = str[n - 1] middle_chars = str[1:n - 1] return last_char + middle_chars + first_char
''' Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after party. He went to a shop to buy a packet of chocolates. At chocolate shop, each packet is having different number of chocolates. He wants to buy such a packet which contains number of chocolates, which can be distributed equally among all of his friends. Help Mr. X to buy such a packet. Input: First line contains T, number of test cases. Each test case contains two integers, N and M. where is N is number of friends and M is number number of chocolates in a packet. Output: In each test case output "Yes" if he can buy that packet and "No" if he can't buy that packet. Constraints: 1<=T<=20 1<=N<=100 1<=M<=10^5 SAMPLE INPUT 2 5 14 3 21 SAMPLE OUTPUT No Yes Explanation Test Case 1: There is no way such that he can distribute 14 chocolates among 5 friends equally. Test Case 2: There are 21 chocolates and 3 friends, so he can distribute chocolates eqally. Each friend will get 7 chocolates. ''' t= int(input()) for i in range(t): p,t = map(int,input().split()) print("Yes" if t % p == 0 else "No")
""" Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after party. He went to a shop to buy a packet of chocolates. At chocolate shop, each packet is having different number of chocolates. He wants to buy such a packet which contains number of chocolates, which can be distributed equally among all of his friends. Help Mr. X to buy such a packet. Input: First line contains T, number of test cases. Each test case contains two integers, N and M. where is N is number of friends and M is number number of chocolates in a packet. Output: In each test case output "Yes" if he can buy that packet and "No" if he can't buy that packet. Constraints: 1<=T<=20 1<=N<=100 1<=M<=10^5 SAMPLE INPUT 2 5 14 3 21 SAMPLE OUTPUT No Yes Explanation Test Case 1: There is no way such that he can distribute 14 chocolates among 5 friends equally. Test Case 2: There are 21 chocolates and 3 friends, so he can distribute chocolates eqally. Each friend will get 7 chocolates. """ t = int(input()) for i in range(t): (p, t) = map(int, input().split()) print('Yes' if t % p == 0 else 'No')
# print ("hello world") # import sys # print(sys.version) # columns = [0,2,4,6,8,10,12,14,16,18,20,22,24,25,27,29,31,33,35,37,39,41,43,45,47,49,50,52,54,56,58,60,62,64,66,68,70,72,74,75,77,79,81,83,85,87,89,91,93,95,97,] for x in range(0, 125): print('P[c:{0}] (0,255,0), '.format(x%125), end='') # Green print('P[c:{0}] (255,255,0), '.format((x+25)%125), end='') # Yellow print('P[c:{0}] (255,255,255), '.format((x+50)%125), end='') # White print('P[c:{0}] (127,0,255), '.format((x+75)%125), end='') # Purple print('P[c:{0}] (0,0,255)'.format((x+100)%125), end='') # Blue print(';')
for x in range(0, 125): print('P[c:{0}] (0,255,0), '.format(x % 125), end='') print('P[c:{0}] (255,255,0), '.format((x + 25) % 125), end='') print('P[c:{0}] (255,255,255), '.format((x + 50) % 125), end='') print('P[c:{0}] (127,0,255), '.format((x + 75) % 125), end='') print('P[c:{0}] (0,0,255)'.format((x + 100) % 125), end='') print(';')