content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
team_names = ['LA Chargers', 'LA Rams', 'NE Patriots', 'NY Giants', 'Chicago Bears', 'Detroit Lions'] # TODO # Add possible locations and weeks in the season
team_names = ['LA Chargers', 'LA Rams', 'NE Patriots', 'NY Giants', 'Chicago Bears', 'Detroit Lions']
spark = SparkSession \ .builder \ .appName("exercise_eleven") \ .getOrCreate() df1 = spark.read.parquet("hdfs://user/your_user_name/data/userdata1.parquet") df2 = spark.read.format("parquet").load("hdfs://user/your_user_name/data/userdata1.parquet") df1.show()
spark = SparkSession.builder.appName('exercise_eleven').getOrCreate() df1 = spark.read.parquet('hdfs://user/your_user_name/data/userdata1.parquet') df2 = spark.read.format('parquet').load('hdfs://user/your_user_name/data/userdata1.parquet') df1.show()
class Solution: def reverseBits(self, n: int) -> int: result = 0 for i in range(32): # first we move result by 1 bit result <<= 1 # then check if n have 1 at first bit if yes than add it to result result =result| (n & 1) #then finally drop...
class Solution: def reverse_bits(self, n: int) -> int: result = 0 for i in range(32): result <<= 1 result = result | n & 1 n >>= 1 return result
def direct_selection(list): ''' returns an ordered list ''' end = len(list) for i in range(end - 1): #stores the position of the element to be compared min_position = i for j in range(i + 1, end): if list[j] < list[min_position]: min_position = j ...
def direct_selection(list): """ returns an ordered list """ end = len(list) for i in range(end - 1): min_position = i for j in range(i + 1, end): if list[j] < list[min_position]: min_position = j (list[i], list[min_position]) = (list[min_position],...
# 22. A simple way of encrypting a message is to rearrange its characters. One way to rearrange the # characters is to pick out the characters at even indices, put them first in the encrypted string, # and follow them by the odd characters. For example, the string 'message' would be encrypted # as 'msaeesg' because the...
s = input('Enter a string: ') (even, odd) = ('', '') for i in range(0, len(s)): if i % 2 == 0: even += s[i] else: odd += s[i] encrypted = even + odd print('The encrypted string is:', encrypted) (decrypted, even_idx, odd_idx) = ('', 0, 0) for i in range(len(encrypted)): if i % 2 == 0: ...
instructions = input() h_count = 0 v_count = 0 for letter in instructions: if letter == "H": h_count += 1 elif letter == "V": v_count += 1 if h_count%2 == 0: if v_count%2 == 0: print("1 2\n3 4") elif v_count%2 == 1: print("2 1\n4 3") elif h_count%2 == 1: if v_count%2 ...
instructions = input() h_count = 0 v_count = 0 for letter in instructions: if letter == 'H': h_count += 1 elif letter == 'V': v_count += 1 if h_count % 2 == 0: if v_count % 2 == 0: print('1 2\n3 4') elif v_count % 2 == 1: print('2 1\n4 3') elif h_count % 2 == 1: if v_...
# This program calculates "area" of square. In this example, we see couple # of important things - assignments and mathematical operators. Guess what # the following code does? side = 4 area = side * side print(area) # Do it yourself # 1. Write a program to calculate area of triangle # 2. Write a program to calculate...
side = 4 area = side * side print(area)
class Node(object): __slots__ = ('name', 'path', 'local', 'is_leaf') def __init__(self, path): self.path = path self.name = path.split('.')[-1] self.local = True self.is_leaf = False def __repr__(self): return '<%s[%x]: %s>' % (self.__class__.__name__, id(self), s...
class Node(object): __slots__ = ('name', 'path', 'local', 'is_leaf') def __init__(self, path): self.path = path self.name = path.split('.')[-1] self.local = True self.is_leaf = False def __repr__(self): return '<%s[%x]: %s>' % (self.__class__.__name__, id(self), sel...
first_parts = ["Ask-i", "Avrupa", "Asmali", "Yaprak", "Tatli", "Arka", "Cocuklar"] second_parts = ["Memnu", "Yakasi", "Konak", "Dokumu", "Hayat", "Sokaklar", "Duymasin"] ind = 0 last_ind = len(first_parts)-1 while ind <= last_ind: full_name = first_parts[ind] + ' ' + second_parts[ind] print(full_name) ind += 1...
first_parts = ['Ask-i', 'Avrupa', 'Asmali', 'Yaprak', 'Tatli', 'Arka', 'Cocuklar'] second_parts = ['Memnu', 'Yakasi', 'Konak', 'Dokumu', 'Hayat', 'Sokaklar', 'Duymasin'] ind = 0 last_ind = len(first_parts) - 1 while ind <= last_ind: full_name = first_parts[ind] + ' ' + second_parts[ind] print(full_name) ind...
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. DEPS = [ 'recipe_engine/context', 'recipe_engine/step', ] def RunSteps(api): with api.context( env={'mood': 'excellent', 'climate': 'sunny'}, ...
deps = ['recipe_engine/context', 'recipe_engine/step'] def run_steps(api): with api.context(env={'mood': 'excellent', 'climate': 'sunny'}, name_prefix='grandparent'): with api.context(env={'climate': 'rainy'}, name_prefix='mom'): api.step('child', ['echo', 'billy']) with api.context(env...
begin_unit comment|'# Licensed under the Apache License, Version 2.0 (the "License"); you may' nl|'\n' comment|'# not use this file except in compliance with the License. You may obtain' nl|'\n' comment|'# a copy of the License at' nl|'\n' comment|'#' nl|'\n' comment|'# http://www.apache.org/licenses/LICENSE...
begin_unit comment | '# Licensed under the Apache License, Version 2.0 (the "License"); you may' nl | '\n' comment | '# not use this file except in compliance with the License. You may obtain' nl | '\n' comment | '# a copy of the License at' nl | '\n' comment | '#' nl | '\n' comment | '# http://www.apache.or...
def my_awesome_decorator(fun): def wrapped(*args): # increase value _list = [number + 1 for number in args] return fun(*_list) return wrapped @my_awesome_decorator def mod_batch(*numbers): # check divide return all([True if number % 3 == 0 else False for number in numbers ]) print(mod_batch(9,...
def my_awesome_decorator(fun): def wrapped(*args): _list = [number + 1 for number in args] return fun(*_list) return wrapped @my_awesome_decorator def mod_batch(*numbers): return all([True if number % 3 == 0 else False for number in numbers]) print(mod_batch(9, 18, 21)) print(mod_batch(9, ...
# ---------------------------------------------------------------------------- # CLASSES: nightly # # Test Case: queryMultiWindow.py # # Tests: queries - Database # # Defect ID: none # # Programmer: Kathleen Bonnell # Date: May 19, 2004 # # Modifications: # Kathleen Bonnell, Mon Dec 20 15:...
def query_multi_window(): open_database(silo_data_path('wave*.silo database')) add_plot('Pseudocolor', 'pressure') set_time_slider_state(31) draw_plots() v = get_view3_d() v.viewNormal = (0, -1, 0) v.viewUp = (0, 0, 1) set_view3_d(v) clone_window() set_time_slider_state(64) d...
# Recursive class Solution: def connect(self, root: 'Node') -> 'Node': if not root: return root if root.left: root.left.next = root.right if root.next and root.right: root.right.next = root.next.left self.connect(root.left) self.connect(roo...
class Solution: def connect(self, root: 'Node') -> 'Node': if not root: return root if root.left: root.left.next = root.right if root.next and root.right: root.right.next = root.next.left self.connect(root.left) self.connect(root.right) ...
# -*- coding: utf-8 -*- # merge two different dict object def merge(new, base): for i in new: base[i] = new[i] return base
def merge(new, base): for i in new: base[i] = new[i] return base
# Title : Print number and square as tuple # Author : Kiran raj R. # Date : 24:10:2020 userInput = input( "Enter the limit till you need to print the sqaure of numbers :") square_tup = () for i in range(1, int(userInput)+1): square_tup += (i, i**2) try: for j in range(0, len(square_tup), 2): p...
user_input = input('Enter the limit till you need to print the sqaure of numbers :') square_tup = () for i in range(1, int(userInput) + 1): square_tup += (i, i ** 2) try: for j in range(0, len(square_tup), 2): print(f'({square_tup[j]}, {square_tup[j + 1]})') except IndexError: print('Finish printing...
class SampleCmd(object): def hello(self, *args): if len(args) == 0: print("hello") else: print("hello, " + args[0]) class SampleCmdWrapper(gdb.Command): def __init__(self): super(SampleCmdWrapper,self).__init__("sample", gdb.COMMAND_USER) def invoke(self, ar...
class Samplecmd(object): def hello(self, *args): if len(args) == 0: print('hello') else: print('hello, ' + args[0]) class Samplecmdwrapper(gdb.Command): def __init__(self): super(SampleCmdWrapper, self).__init__('sample', gdb.COMMAND_USER) def invoke(self,...
n, w = map(int, input().split()) items = [] append = items.append for i in range(n): append(list(map(int, input().split()))) def knapsack(n, w, items): c = [[0] * (w + 1) for _ in range(n + 1)] g = [[0] * (w + 1) for _ in range(n + 1)] for i in range(w + 1): g[0][i] = 1 for i in range(1...
(n, w) = map(int, input().split()) items = [] append = items.append for i in range(n): append(list(map(int, input().split()))) def knapsack(n, w, items): c = [[0] * (w + 1) for _ in range(n + 1)] g = [[0] * (w + 1) for _ in range(n + 1)] for i in range(w + 1): g[0][i] = 1 for i in range(1, ...
class Tree(): vertices = [(0,0,0), (0,1,0), (1,1,0), (1,0,0), (0,0,1.75), (0,1,1.75), (1,1,1.75), (1,0,1.75), #start of tree (-1,-1,1.75),#8 (-1,2,1.75), (2,2,1.75), (2,-1,...
class Tree: vertices = [(0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 1.75), (0, 1, 1.75), (1, 1, 1.75), (1, 0, 1.75), (-1, -1, 1.75), (-1, 2, 1.75), (2, 2, 1.75), (2, -1, 1.75), (0.5, 0.5, 8)] faces = [(0, 1, 2, 3), (0, 4, 5, 1), (1, 5, 6, 2), (2, 6, 7, 3), (3, 7, 4, 0), (8, 9, 10, 11), (8, 9, 12), (8, 11...
def main(): x = int(input("Enter an integer: ")) if x > 0: print("Number is positive!") elif x < 0: print("Number is negative!") else: print("You entered a zero!") if __name__ == '__main__': main()
def main(): x = int(input('Enter an integer: ')) if x > 0: print('Number is positive!') elif x < 0: print('Number is negative!') else: print('You entered a zero!') if __name__ == '__main__': main()
#!/usr/bin/env python3 def test_prime(test_value): if test_value == 2: return 1 for x in range(2, test_value): if test_value % x == 0: return 0 return 1 def main(): test_value = 179424673 if test_prime(test_value): print(test_value, "is prime.") else: ...
def test_prime(test_value): if test_value == 2: return 1 for x in range(2, test_value): if test_value % x == 0: return 0 return 1 def main(): test_value = 179424673 if test_prime(test_value): print(test_value, 'is prime.') else: print(test_value, 'is ...
#!/usr/bin/env python try: number = int(input("Enter a number: ")) except: print("That's silly") exit() potential_divisors = list(range(1, int(number/2 + 1))) potential_divisors.append(number) divisors = [] for div in potential_divisors: if number % div == 0: divisors.append(str(div)) print(...
try: number = int(input('Enter a number: ')) except: print("That's silly") exit() potential_divisors = list(range(1, int(number / 2 + 1))) potential_divisors.append(number) divisors = [] for div in potential_divisors: if number % div == 0: divisors.append(str(div)) print('The factors of ' + str(...
load("@bazel_skylib//lib:shell.bzl", "shell") load("@io_bazel_rules_go//go:def.bzl", "go_context") def _yo_impl(ctx): go = go_context(ctx) godir = go.go.path[:-1 - len(go.go.basename)] env = dict(go.env) env["YO"] = ctx.attr._yo_executable.files.to_list()[0].path env["SCHEMA_FILE"] = ctx.attr.schem...
load('@bazel_skylib//lib:shell.bzl', 'shell') load('@io_bazel_rules_go//go:def.bzl', 'go_context') def _yo_impl(ctx): go = go_context(ctx) godir = go.go.path[:-1 - len(go.go.basename)] env = dict(go.env) env['YO'] = ctx.attr._yo_executable.files.to_list()[0].path env['SCHEMA_FILE'] = ctx.attr.schem...
class Creature(object): def __init__(self): self.id = 0 self.food_gathered = 0 self.position = []
class Creature(object): def __init__(self): self.id = 0 self.food_gathered = 0 self.position = []
database_set = { 'driver': 'influxdb', 'timezone': 'Asia/Shanghai', 'port': 0, 'host': '', 'database': '', 'username': '', 'password': '' } product_list = ['jinshan'] product_accounts = { 'jinshan': [ 'CTP.990175', ] } product_alarm = { 'jinshan':'alarm_setting.csv'...
database_set = {'driver': 'influxdb', 'timezone': 'Asia/Shanghai', 'port': 0, 'host': '', 'database': '', 'username': '', 'password': ''} product_list = ['jinshan'] product_accounts = {'jinshan': ['CTP.990175']} product_alarm = {'jinshan': 'alarm_setting.csv'} acc_folder = {'jinshan': 'outsourceData.csv'} sector_file =...
age = int(input("Please enter your age here:\n")) if ((age >= 1) and (age <= 6)): print("Hi little baby") elif ((age >= 6) and (age <= 12)): print("Hey little kid") elif ((age >= 13) and (age <= 17)): print("Hey there teen") elif ((age >= 18) and (age <= 40)): print("Hey you are an adult") elif age >= ...
age = int(input('Please enter your age here:\n')) if age >= 1 and age <= 6: print('Hi little baby') elif age >= 6 and age <= 12: print('Hey little kid') elif age >= 13 and age <= 17: print('Hey there teen') elif age >= 18 and age <= 40: print('Hey you are an adult') elif age >= 41: print('You are gr...
my_dict = {"force": [0, 10, 15, 30, 45], "distance": [2.5, 3.5, 6.0, -3.0, 8.1]} res = 0.0 # Here the zip operator is used to iterate over both lists. for force, dist in zip(my_dict["force"], my_dict["distance"]): res += force * dist print(res)
my_dict = {'force': [0, 10, 15, 30, 45], 'distance': [2.5, 3.5, 6.0, -3.0, 8.1]} res = 0.0 for (force, dist) in zip(my_dict['force'], my_dict['distance']): res += force * dist print(res)
# Test duration: 1 hour and 50 minutes (9:10am-11:00am) # # Aids allowed: any material on the course website http://www.cs.toronto.edu/~guerzhoy/180/ # You may use Pyzo (or another Python IDE) during the exam. # # You are responsible for submitting the file midterm.py on Gradescope. # # You can resubmit the file multip...
def sum_cubes(k): s = 0 for i in range(1, k + 1): s += i * i * i return s def sum_cubes_num_terms(n): s = 0 k = 0 while s + k * k * k < n: s += k * k * k k += 1 return k measurements = [10.4, 1.6, 2, 0.2, 0, 0, 5.2, 0, 0, 0, 0, 0, 3.8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2...
def branch2lists(tree): res = [] (statement, superior) = tree if superior: for issuer, branch in superior.items(): _lists = branch2lists(branch) for l in _lists: l.append(statement) if not res: res = _lists else: ...
def branch2lists(tree): res = [] (statement, superior) = tree if superior: for (issuer, branch) in superior.items(): _lists = branch2lists(branch) for l in _lists: l.append(statement) if not res: res = _lists else: ...
# # Copyright (c) 2017 Joy Diamond. All rights reserved. # @gem('Sapphire.Parse1ExpressionStatement') def gem(): require_gem('Sapphire.BookcaseManyStatement') show = 0 def parse1_statement_assign__left__equal_sign(indented, left, equal_sign): right = parse1_ternary_expression_list() ...
@gem('Sapphire.Parse1ExpressionStatement') def gem(): require_gem('Sapphire.BookcaseManyStatement') show = 0 def parse1_statement_assign__left__equal_sign(indented, left, equal_sign): right = parse1_ternary_expression_list() operator = qk() if operator is not none: wk(no...
expected_output = { "vrf": { "default": { "source_address": "192.168.16.226", "source_host": "?", "mofrr": "Enabled", "path": { "192.168.145.2 Ethernet1/4": { "interface_name": "Ethernet1/4", "neighbor_ho...
expected_output = {'vrf': {'default': {'source_address': '192.168.16.226', 'source_host': '?', 'mofrr': 'Enabled', 'path': {'192.168.145.2 Ethernet1/4': {'interface_name': 'Ethernet1/4', 'neighbor_host': '?', 'neighbor_address': '192.168.145.2', 'table_type': 'unicast', 'table_feature': 'ospf', 'table_feature_instance'...
{ "downloads" : [ "https://github.com/google/glog/archive/v0.4.0.tar.gz" ], "license" : "COPYING", "commands" : [ "mkdir gafferBuild", "cd gafferBuild &&" " cmake" " -G {cmakeGenerator}" " -D CMAKE_C_COMPILER={cCompiler}" " -D CMAKE_CXX_COMPILER={cxxCompiler}" " -D CMAKE_INSTALL_PREFIX={b...
{'downloads': ['https://github.com/google/glog/archive/v0.4.0.tar.gz'], 'license': 'COPYING', 'commands': ['mkdir gafferBuild', 'cd gafferBuild && cmake -G {cmakeGenerator} -D CMAKE_C_COMPILER={cCompiler} -D CMAKE_CXX_COMPILER={cxxCompiler} -D CMAKE_INSTALL_PREFIX={buildDir} -D CMAKE_PREFIX_PATH={buildDir} -D CMAKE_POS...
def escreva(a): tam = len(a) + 4 print('~'*tam) print(f' {a}') print('~'*tam) escreva('Bruno')
def escreva(a): tam = len(a) + 4 print('~' * tam) print(f' {a}') print('~' * tam) escreva('Bruno')
# this is a simple comment ''' this is a multi-line comment ''' phrase = 'The source code is commented' print(phrase)
""" this is a multi-line comment """ phrase = 'The source code is commented' print(phrase)
def solution(A): A.sort() scenario1 = A[0] * A[1] * A[-1] scenario2 = A[-1] * A[-2] * A[-3] return scenario1 if (scenario1 > scenario2) else scenario2
def solution(A): A.sort() scenario1 = A[0] * A[1] * A[-1] scenario2 = A[-1] * A[-2] * A[-3] return scenario1 if scenario1 > scenario2 else scenario2
CHAR_OFFSET = 32 # skip control chars START_EMOJI = ord('\U0001F601') def encode(msg, binary=False): ''' Encode a message using emojis ''' new_str = '' if binary: msg_bytes = msg else: msg_bytes = bytes(msg, 'utf-8') for b in msg_bytes: #print(b + START_EM...
char_offset = 32 start_emoji = ord('😁') def encode(msg, binary=False): """ Encode a message using emojis """ new_str = '' if binary: msg_bytes = msg else: msg_bytes = bytes(msg, 'utf-8') for b in msg_bytes: new_str = new_str + chr(b + START_EMOJI - CHAR_OFFSET) ...
# 2020.07.29 # Problem Statement # https://leetcode.com/problems/reverse-nodes-in-k-group/ # Looked up the following youtube video: # https://www.youtube.com/watch?v=cFDvbKTNeCA # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.ne...
class Solution: def reverse_k(k, first): new_tail = first prev = None for i in range(0, k): next_node = first.next first.next = prev prev = first first = next_node new_head = prev after = first return (new_head, new_tai...
t = int(input()) for i in range(t): a = input() b = input() minimum = 3000 flag = 0 for a_iter in range(len(a)-1): if a[a_iter]==b[0]: if len(b)==1: minimum = 0 flag = 1 break b_index = 1 for iter in ra...
t = int(input()) for i in range(t): a = input() b = input() minimum = 3000 flag = 0 for a_iter in range(len(a) - 1): if a[a_iter] == b[0]: if len(b) == 1: minimum = 0 flag = 1 break b_index = 1 for iter in ra...
# Create a list of words from the text below that are shorter than or equal to the input # value. Print the new list. text = [["Glitch", "is", "a", "minor", "problem", "that", "causes", "a", "temporary", "setback"], ["Ephemeral", "lasts", "one", "day", "only"], ["Accolade", "is", "an", "expression", "o...
text = [['Glitch', 'is', 'a', 'minor', 'problem', 'that', 'causes', 'a', 'temporary', 'setback'], ['Ephemeral', 'lasts', 'one', 'day', 'only'], ['Accolade', 'is', 'an', 'expression', 'of', 'praise']] print([word for sentence in text for word in sentence if len(word) <= int(input())])
#Smallest multiple def Euler5(n): l=list(range(n+1))[2:] for i in range(len(l)): for j in range(i+1,len(l)): if l[j]%l[i]==0: l[j]//=l[i] p=1 for x in l: p*=x return p print(Euler5(100))
def euler5(n): l = list(range(n + 1))[2:] for i in range(len(l)): for j in range(i + 1, len(l)): if l[j] % l[i] == 0: l[j] //= l[i] p = 1 for x in l: p *= x return p print(euler5(100))
description_short = "Help you deal with multiple git repositories" keywords = [ "git", "python", "repositories", "multiple", ]
description_short = 'Help you deal with multiple git repositories' keywords = ['git', 'python', 'repositories', 'multiple']
# -*- coding: utf-8 *-* # Copyright (C) 2011-2012 Canonical Services Ltd # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to us...
class Belowcondition(object): def __init__(self, value, slope=0): self.value = value self.slope = slope def __call__(self, value, size=1): return value < self.value + self.slope * size class Abovecondition(object): def __init__(self, value, slope=0): self.value = value ...
class UnityYamlStream( object ): def __init__(self, path ): self.__file = open(path) self.__fileIds = list() def read(self, param): line = self.__file.readline() if line == None or line == '': self.__file.close() self.__fileIds.append( 0 ) return '' if line.startswith('---'): tag = l...
class Unityyamlstream(object): def __init__(self, path): self.__file = open(path) self.__fileIds = list() def read(self, param): line = self.__file.readline() if line == None or line == '': self.__file.close() self.__fileIds.append(0) return ...
# # PySNMP MIB module HPN-ICF-MPLSTE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-MPLSTE-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:40:26 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, constraints_union, single_value_constraint, value_range_constraint) ...
# @lc app=leetcode id=2119 lang=python3 # # [2119] A Number After a Double Reversal # # @lc code=start class Solution: def isSameAfterReversals(self, num: int) -> bool: return int(str(int(str(num)[::-1]))[::-1]) == num # @lc code=end
class Solution: def is_same_after_reversals(self, num: int) -> bool: return int(str(int(str(num)[::-1]))[::-1]) == num
# This function is a remnant of a failed attempt (I might use it later) # def smallest_factor(number: int): # for factor in range(2, int((number)**0.5+1)): # if number % factor == 0: # return(factor) # #if there is no factor, it is prime # return number def num_factors(n: int): ...
def num_factors(n: int): """The number of factors of n""" count = 0 factor = 1 max_search = n while factor < max_search: if n % factor == 0: if factor ** 2 == n: count += 1 return count count += 2 max_search = n / factor ...
#!/usr/bin/env python3 def getAdjacentCoords(Coord, maxX=0, maxY=0): def checkBoundary(X, Y): return X >= 0 and X < maxX and Y >= 0 and Y < maxY X, Y = Coord res = set() offsets = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)) for offsetX, offsetY in offsets: ...
def get_adjacent_coords(Coord, maxX=0, maxY=0): def check_boundary(X, Y): return X >= 0 and X < maxX and (Y >= 0) and (Y < maxY) (x, y) = Coord res = set() offsets = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)) for (offset_x, offset_y) in offsets: curr_x = ...
# 0. Hello World print("Hello World!") print("Time for some Python")
print('Hello World!') print('Time for some Python')
# # PySNMP MIB module CISCO-L2NAT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-L2NAT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:04:09 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
def pythonic_quick_sort(a): if len(a) <= 1: return a pivot = a[-1] pivots = [i for i in a if i == pivot] left = pythonic_quick_sort([i for i in a if i < pivot]) right = pythonic_quick_sort([i for i in a if i > pivot]) return left + pivots + right
def pythonic_quick_sort(a): if len(a) <= 1: return a pivot = a[-1] pivots = [i for i in a if i == pivot] left = pythonic_quick_sort([i for i in a if i < pivot]) right = pythonic_quick_sort([i for i in a if i > pivot]) return left + pivots + right
class Story: def __init__(self, raw_story): self.__raw_history = raw_story def get_raw(self, key): return self.__raw_history[key] def get_items(self): return self.__raw_history.items()
class Story: def __init__(self, raw_story): self.__raw_history = raw_story def get_raw(self, key): return self.__raw_history[key] def get_items(self): return self.__raw_history.items()
string=input("enter a string") print(len(string)) print(string*5) print(string[0]) print(string[-1]) print(string[: :-1]) if len(string) >= 7: print(string[6]) else: print("please enter more than 7 charecters next time") print(string[1:-1]) print(string.upper()) print(string.replace('a', 'e')) print('*'*len(str...
string = input('enter a string') print(len(string)) print(string * 5) print(string[0]) print(string[-1]) print(string[::-1]) if len(string) >= 7: print(string[6]) else: print('please enter more than 7 charecters next time') print(string[1:-1]) print(string.upper()) print(string.replace('a', 'e')) print('*' * le...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- s1 = set([1, 1, 2, 2, 3, 3]) print("s1 = ", s1) s2 = set([2, 3, 4]) print("s2 = ", s2) print("s1 & s2 = ", s1 & s2) print("s1 | s2 = ", s1 | s2)
s1 = set([1, 1, 2, 2, 3, 3]) print('s1 = ', s1) s2 = set([2, 3, 4]) print('s2 = ', s2) print('s1 & s2 = ', s1 & s2) print('s1 | s2 = ', s1 | s2)
class Plugin(object): pass class TextCommand(Plugin): pass class WindowCommand(Plugin): pass class EventListener(Plugin): pass
class Plugin(object): pass class Textcommand(Plugin): pass class Windowcommand(Plugin): pass class Eventlistener(Plugin): pass
def f(x): return 2*x def g(x, b): a = 3*b return f(2) + a def h(x, y, s=None): if s is not None: return f(2) + g(f(2)) + x + y else: return f(2) + g(f(2)) + x*y class Teste: def __init__(self): pass def method_a(self): pass def method_b(self): ...
def f(x): return 2 * x def g(x, b): a = 3 * b return f(2) + a def h(x, y, s=None): if s is not None: return f(2) + g(f(2)) + x + y else: return f(2) + g(f(2)) + x * y class Teste: def __init__(self): pass def method_a(self): pass def method_b(self): ...
class Functor: def __init__(self, function, args, kwargs): self.__function = function self.__args = args self.__kwargs = kwargs def __call__(self): return self.__function(*self.__args, **self.__kwargs)
class Functor: def __init__(self, function, args, kwargs): self.__function = function self.__args = args self.__kwargs = kwargs def __call__(self): return self.__function(*self.__args, **self.__kwargs)
pantheon = { 0: 'Holobore, Spirit of Asceticism', 1: 'Vomitrax, Spirit of Decadence', 2: 'Godzamok, Spirit of Ruin', 3: 'Cyclius, Spirit of Ages', 4: 'Selebrak, Spirit of Festivities', 5: 'Dotjeiess, Spirit of Creation', 6: 'Muridal, Spirit of Labor', 7: 'Jeremy, Spirit of Industry', ...
pantheon = {0: 'Holobore, Spirit of Asceticism', 1: 'Vomitrax, Spirit of Decadence', 2: 'Godzamok, Spirit of Ruin', 3: 'Cyclius, Spirit of Ages', 4: 'Selebrak, Spirit of Festivities', 5: 'Dotjeiess, Spirit of Creation', 6: 'Muridal, Spirit of Labor', 7: 'Jeremy, Spirit of Industry', 8: 'Mokalsium, Mother Spirit', 9: 'S...
# Solution from https://stackoverflow.com/questions/13387125/how-to-link-with-intersphinx-to-django-specific-constructs-like-settings # noqa def setup(app): app.add_crossref_type( directivename="setting", rolename="setting", indextemplate="pair: %s; setting", )
def setup(app): app.add_crossref_type(directivename='setting', rolename='setting', indextemplate='pair: %s; setting')
# # PySNMP MIB module ONEACCESS-VLAN-CONFIG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ONEACCESS-VLAN-CONFIG-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:34:44 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) ...
def birthdayCakeCandles(ar): count = 0 max_ar = max(ar) for i in range(len(ar)): if ar[i] == max_ar: count+=1 return count
def birthday_cake_candles(ar): count = 0 max_ar = max(ar) for i in range(len(ar)): if ar[i] == max_ar: count += 1 return count
number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(number) print(number[6]) mixed = ["apple", "orange", "grapes", "watermelon"] print(mixed) mixed[1] = 0x55 print(mixed) mixed[2] = 10 print(mixed) mixed.append(True) print(mixed) mixed.append(0b100010) print(mixed) mixed.append("characters") print(mixed) ok = list("charac...
number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(number) print(number[6]) mixed = ['apple', 'orange', 'grapes', 'watermelon'] print(mixed) mixed[1] = 85 print(mixed) mixed[2] = 10 print(mixed) mixed.append(True) print(mixed) mixed.append(34) print(mixed) mixed.append('characters') print(mixed) ok = list('characters') pri...
def multiCheck(inA, inB, inC=2): outA = inA * inB if outA % inC == 0: return True else: return False def plusArr(inA, inB): outA = inA + inB arr = [] for i in range(outA+1): arr.append(i) return arr
def multi_check(inA, inB, inC=2): out_a = inA * inB if outA % inC == 0: return True else: return False def plus_arr(inA, inB): out_a = inA + inB arr = [] for i in range(outA + 1): arr.append(i) return arr
def get_all_combinations(source, size): if size > len(source): raise ValueError('size is greater than source') if size <= 1 or len(source) <= 2: return source if not isinstance(source, list): source = list(source) def build_combinations(source, size): if size == len(sou...
def get_all_combinations(source, size): if size > len(source): raise value_error('size is greater than source') if size <= 1 or len(source) <= 2: return source if not isinstance(source, list): source = list(source) def build_combinations(source, size): if size == len(sou...
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). # FORMAT_VERSION_NUMBER: Version number for identifying the export file format output. This # number is shared between `export` and `export-dep-as-jar` task, so it should be changed # when...
default_export_version = '1.1.0'
def f(): print("ok") s=yield 6 print(s) print("ok2") yield gen=f() # print(gen) # next(gen) RET=gen.__next__() print(RET) # next(gen) gen.send(5)
def f(): print('ok') s = (yield 6) print(s) print('ok2') yield gen = f() ret = gen.__next__() print(RET) gen.send(5)
def Settings( **kwargs ): return { 'flags': [ '-x', 'c', '-std=c17', '-W', '-Wall', '-DAPPNAME', '-DVERSION', '-I.' ], }
def settings(**kwargs): return {'flags': ['-x', 'c', '-std=c17', '-W', '-Wall', '-DAPPNAME', '-DVERSION', '-I.']}
# # PySNMP MIB module XYPLEX-IPX-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYPLEX-IPX-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:46:26 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ...
def findLongestSubarray(array: [str]) -> [str]: if not array: return [] dp = [0] * len(array) dp[0] = 1 if (array[0] >= "A" and array[0] <= "Z") or (array[0] >= "a" and array[0] <= "z") else -1 for i in range(1, len(array)): dp[i] = dp[i - 1] + 1 if (array[i] >= "A" and array[i] <= "Z") ...
def find_longest_subarray(array: [str]) -> [str]: if not array: return [] dp = [0] * len(array) dp[0] = 1 if array[0] >= 'A' and array[0] <= 'Z' or (array[0] >= 'a' and array[0] <= 'z') else -1 for i in range(1, len(array)): dp[i] = dp[i - 1] + 1 if array[i] >= 'A' and array[i] <= 'Z' or...
class MealConfig(): def __init__(self, duration, target_weight, weight_per_bite): self.duration = duration self.target_weight = target_weight self.weight_per_bite = weight_per_bite
class Mealconfig: def __init__(self, duration, target_weight, weight_per_bite): self.duration = duration self.target_weight = target_weight self.weight_per_bite = weight_per_bite
config={ "--confidence-digits":[2,int], "--decode-mbr":["true",str], "--frame-shift":[0.01,float], "--inv-acoustic-scale":[1.0,float], "--print-silence":["true",str], }
config = {'--confidence-digits': [2, int], '--decode-mbr': ['true', str], '--frame-shift': [0.01, float], '--inv-acoustic-scale': [1.0, float], '--print-silence': ['true', str]}
class Event: def __init__(self, state, action, reward, state_next, done): self.state = state self.action = action self.reward = reward self.state_next = state_next self.done = done
class Event: def __init__(self, state, action, reward, state_next, done): self.state = state self.action = action self.reward = reward self.state_next = state_next self.done = done
#!/usr/bin/python3 def roman_to_int(roman_string): "converts a roman numeral to an integer" if type(roman_string) is not str or roman_string is None: return (0) total = 0 r_dic = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} for idx in range(len(roman_string)): i...
def roman_to_int(roman_string): """converts a roman numeral to an integer""" if type(roman_string) is not str or roman_string is None: return 0 total = 0 r_dic = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} for idx in range(len(roman_string)): i = r_dic.get(roman...
# Loops allow you to execute code over and over again, which # is where much of the power of programmming lies # While loops execute as long as the condition is true. # Be careful with these, because it is easy to create an # infinite loop! i = 0 while i < 10: print(f"{i} is not yet 10.") # increment i. if i ...
i = 0 while i < 10: print(f'{i} is not yet 10.') i = i + 1 i = 0 while i < 10: print(f'{i} is not yet 10.') i += 1
PLACE_CATEGORIES = ( (0, "undefined"), (1000, "accounting"), (1100, "airport"), (1200, "amusement_park"), (1300, "aquarium"), (1400, "art_gallery"), (1500, "atm"), (1600, "bakery"), (1700, "bank"), (1800, "bar"), (1900, "beauty_salon"), (2000, "bicycle_store"), (2100,...
place_categories = ((0, 'undefined'), (1000, 'accounting'), (1100, 'airport'), (1200, 'amusement_park'), (1300, 'aquarium'), (1400, 'art_gallery'), (1500, 'atm'), (1600, 'bakery'), (1700, 'bank'), (1800, 'bar'), (1900, 'beauty_salon'), (2000, 'bicycle_store'), (2100, 'book_store'), (2200, 'bowling_alley'), (2300, 'bus_...
# Problem: # Write a program that enters an integer and calculates the Fibonacci nth number. # The zero figure of Fibonacci is 1, the first one is also 1, and the next is the sum of the previous two. n = int(input()) a = 1 b = 2 for i in range(1, n): new_b = a + b a = b b = new_b print(a)
n = int(input()) a = 1 b = 2 for i in range(1, n): new_b = a + b a = b b = new_b print(a)
class Opcode: CMP_OP = ( "<", "<=", "==", "!=", ">", ">=", "in", "not in", "is", "is not", "exception match", "BAD", ) HAVE_ARGUMENT = 90 # Opcodes from here have an argument: EXTENDED_ARG = 144 CODEUNIT...
class Opcode: cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is', 'is not', 'exception match', 'BAD') have_argument = 90 extended_arg = 144 codeunit_size = 2 def __init__(self) -> None: self.hasconst: set[int] = set() self.hasname: set[int] = set() self.hasjrel...
def weightnode(a): w = 2**(len(a)) - 1 for (scale, i) in enumerate(a): w = w + (i)*(2**(len(a)-scale-1)) return(w)
def weightnode(a): w = 2 ** len(a) - 1 for (scale, i) in enumerate(a): w = w + i * 2 ** (len(a) - scale - 1) return w
def binary_search(item_list, item): first = 0 last = len(item_list) - 1 while first <= last: mid = first + (last - first) // 2 if item_list[mid] == item: return True else: if item < item_list[mid]: last = mid - 1 else: first = mid + 1 return False # arr = [1, 6, 5,...
def binary_search(item_list, item): first = 0 last = len(item_list) - 1 while first <= last: mid = first + (last - first) // 2 if item_list[mid] == item: return True elif item < item_list[mid]: last = mid - 1 else: first = mid + 1 retur...
def bubble_sort(l): tam = len(l) for i in range(tam): trocou = False for j in range(tam-1): if l[j] > l[j+1]: l[j], l[j+1] = l[j+1], l[j] trocou = True if not trocou: return if __name__ == '__main__': l = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48] print('---- * BUBBLE SORT * ----...
def bubble_sort(l): tam = len(l) for i in range(tam): trocou = False for j in range(tam - 1): if l[j] > l[j + 1]: (l[j], l[j + 1]) = (l[j + 1], l[j]) trocou = True if not trocou: return if __name__ == '__main__': l = [3, 44, 38,...
class clr: reset = "\u001b[0m" black = "\u001b[30m" bblack = "\u001b[30;1m" red = "\u001b[31m" bred = "\u001b[31;1m" green = "\u001b32m" bgreen = "\u001b[32;1m" yellow = "\u001b[33m" byellow = "\u001b[33;1m" blue = "\u001b[34m" bblue = "\u001b[34;1m" magenta =...
class Clr: reset = '\x1b[0m' black = '\x1b[30m' bblack = '\x1b[30;1m' red = '\x1b[31m' bred = '\x1b[31;1m' green = '\x1b32m' bgreen = '\x1b[32;1m' yellow = '\x1b[33m' byellow = '\x1b[33;1m' blue = '\x1b[34m' bblue = '\x1b[34;1m' magenta = '\x1b[35m' bmagenta = '\x1b[3...
kSupportedMetadataTypes = ( str, int, float, bool, type(None) ) ## @name Management States ## @see @ref python.Manager.Manager.managemetPolicy ## @{ ## The Manager has no interest in participating in the management of this kind ## of entity, or a supplied specification is not publishable to a specific ## entity refe...
k_supported_metadata_types = (str, int, float, bool, type(None)) k_ignored = 0 k_managed = 1 k_exclusive = 3 k_state_mask = 7 k_will_manage_path = 8 k_supports_batch_operations = 16 k_field__item_type = 'fnItemType' k_field__display_name = 'displayName' k_field__metadata = 'metadata' k_field__small_icon = 'smallIcon' k...
class Reindeer: def __init__(self, name, speed, time_before_rest, rest_time): self.__name = name self.__speed = int(speed) self.__time_before_rest = int(time_before_rest) self.__rest_time = int(rest_time) self.__current_position = 0 self.__time_without_resting = 0 self.__is_resting = False self.__time_...
class Reindeer: def __init__(self, name, speed, time_before_rest, rest_time): self.__name = name self.__speed = int(speed) self.__time_before_rest = int(time_before_rest) self.__rest_time = int(rest_time) self.__current_position = 0 self.__time_without_resting = 0 ...
#model.connection class ConnectionSettings(object): def __init__(self): self.driver = None self.dbcname = None self.database = None self.uid = None self.pwd = None self.quietmode = None def set_connection_data(self, data): self.driver = data['Driver'] ...
class Connectionsettings(object): def __init__(self): self.driver = None self.dbcname = None self.database = None self.uid = None self.pwd = None self.quietmode = None def set_connection_data(self, data): self.driver = data['Driver'] self.dbcname...
def merge_sort(list): ''' Sorts a list in ascending order Returns a new sorted list Runs in O(n log n) time Divide : Find the midpoint of list and divide into sublists Conquer : Recursively sort the sublists created from previous step Combine : Merge the sorted sublists created in previous s...
def merge_sort(list): """ Sorts a list in ascending order Returns a new sorted list Runs in O(n log n) time Divide : Find the midpoint of list and divide into sublists Conquer : Recursively sort the sublists created from previous step Combine : Merge the sorted sublists created in previous s...
class ChudaException(Exception): pass class EmptyCommandNameException(ChudaException): message = "The command_name attribute is required and cannot be empty" class ArgumentNotFoundException(ChudaException): message = "Argument {} not found" def __init__(self, arg_name): super().__init__(self....
class Chudaexception(Exception): pass class Emptycommandnameexception(ChudaException): message = 'The command_name attribute is required and cannot be empty' class Argumentnotfoundexception(ChudaException): message = 'Argument {} not found' def __init__(self, arg_name): super().__init__(self....
def age_assignment(*args, **ages): res_dict = {} names = [name for name in args] while names: for name in names: for key in ages.keys(): if name[0] == key: res_dict[name] = ages[key] names.remove(name) return res_dict print(ag...
def age_assignment(*args, **ages): res_dict = {} names = [name for name in args] while names: for name in names: for key in ages.keys(): if name[0] == key: res_dict[name] = ages[key] names.remove(name) return res_dict print(age_...
class Solution: def threeSumClosest(self, nums, target): l, m = len(nums) - 1, sum(nums[:3]) if l < 3: return 0 nums.sort() for i in range(l - 1): if i and nums[i] == nums[i - 1]: continue j, k = i + 1, l while j < k: ...
class Solution: def three_sum_closest(self, nums, target): (l, m) = (len(nums) - 1, sum(nums[:3])) if l < 3: return 0 nums.sort() for i in range(l - 1): if i and nums[i] == nums[i - 1]: continue (j, k) = (i + 1, l) whil...
file = open("2.txt", "r") ##part 1 finalH = 0 finalD = 0 for line in file: split = line.split() if (split[0] == "forward"): finalH += int(split[1]) elif(split[0] == "down"): finalD += int(split[1]) elif(split[0] == "up"): finalD -= int(split[1]) print(finalH * finalD) #...
file = open('2.txt', 'r') final_h = 0 final_d = 0 for line in file: split = line.split() if split[0] == 'forward': final_h += int(split[1]) elif split[0] == 'down': final_d += int(split[1]) elif split[0] == 'up': final_d -= int(split[1]) print(finalH * finalD) final_h = 0 final_d...
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': '/tmp/daspi.db', } } # the place where this raspberry pi is installed THIS_PLACE_PK = 1
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': '/tmp/daspi.db'}} this_place_pk = 1
def get_vericication_code(phone): ''' Returns vericition code from a phone numbe. ''' return phone[-6:]
def get_vericication_code(phone): """ Returns vericition code from a phone numbe. """ return phone[-6:]
class Comentarios: def __init__(self,id,idU,comentario,fecha): self.id=id self.idU=idU self.comentario=comentario self.fecha=fecha
class Comentarios: def __init__(self, id, idU, comentario, fecha): self.id = id self.idU = idU self.comentario = comentario self.fecha = fecha
# We have a list of points on the plane. Find the K closest points to the origin (0, 0). # (Here, the distance between two points on a plane is the Euclidean distance.) # You may return the answer in any order. # The answer is guaranteed to be unique (except for the order that it is in.) # Example 1: # Input: p...
class Solution1: def k_closest(self, points: List[List[int]], K: int) -> List[List[int]]: closest = [{'item': points[x], 'index': x, 'square': points[x][0] * points[x][0] + points[x][1] * points[x][1]} for x in range(0, len(points))] return [i['item'] for i in sorted(closest, key=lambda k: k['squar...
class TestMetaClass(type): def __init__(cls, clsName, bases, clsBody): super().__init__(clsName, bases, clsBody) print('TestMetaClass.__init__() is called') def new_func(self): print("new_func() is called") cls.func_x = new_func class TestClass(metaclass=TestMetaClass):...
class Testmetaclass(type): def __init__(cls, clsName, bases, clsBody): super().__init__(clsName, bases, clsBody) print('TestMetaClass.__init__() is called') def new_func(self): print('new_func() is called') cls.func_x = new_func class Testclass(metaclass=TestMetaClass)...
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def push(self,x): node = Node(x) node.next=self.head self.head=node def insertAfter(self,y,x): if y is None: ...
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def push(self, x): node = node(x) node.next = self.head self.head = node def insert_after(self, y, x): if y is None:...
class Solution: _len = lambda self, num: len(str(num)) def findNumbers(self, nums) -> int: return len([num for num in nums if not self._len(num) % 2])
class Solution: _len = lambda self, num: len(str(num)) def find_numbers(self, nums) -> int: return len([num for num in nums if not self._len(num) % 2])
class Solution: def XXX(self, height: List[int]) -> int: L=len(height) start=0 end=L-1 s=min(height[0],height[L-1])*(L-1) while(start<end): if height[start]>height[end]: end-=1 t=min(height[start],height[end])*(end-start) ...
class Solution: def xxx(self, height: List[int]) -> int: l = len(height) start = 0 end = L - 1 s = min(height[0], height[L - 1]) * (L - 1) while start < end: if height[start] > height[end]: end -= 1 t = min(height[start], height[en...
class Solution: def findDisappearedNumbers(self, nums: List[int]) -> List[int]: j = 1 n = len(nums) res = [] nums.sort() i = 0 arr = [-1] *(n + 1 ) for n in nums : arr[n] = 1 for i in range(1,len(arr)): if arr[i] == -1 : ...
class Solution: def find_disappeared_numbers(self, nums: List[int]) -> List[int]: j = 1 n = len(nums) res = [] nums.sort() i = 0 arr = [-1] * (n + 1) for n in nums: arr[n] = 1 for i in range(1, len(arr)): if arr[i] == -1: ...
class BaseTrader( object ): def __init__( self, uid ): self.uid = uid def send_order( self, order ): pass def cancel_order( self, order ): pass
class Basetrader(object): def __init__(self, uid): self.uid = uid def send_order(self, order): pass def cancel_order(self, order): pass
class EdgeSetGraph: def __init__(self, V = (), E = ()): self._V = set() self._E = set() for v in V: self.addvertex(v) for u,v in E: self.addedge(u,v) def vertices(self): return iter(self._V) def edges(self): return iter(self._E) def addvertex(self, v): ...
class Edgesetgraph: def __init__(self, V=(), E=()): self._V = set() self._E = set() for v in V: self.addvertex(v) for (u, v) in E: self.addedge(u, v) def vertices(self): return iter(self._V) def edges(self): return iter(self._E) ...
n = input() if n==n[::-1]: print("YES") else: print("NO")
n = input() if n == n[::-1]: print('YES') else: print('NO')