content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def giwaxs_S_edge_wenkai(t=1): dets = [pil300KW] names = [ 'A2', 'A3', 'A4', 'A5', 'A6'] x = [30000, 16000, 0, -15000, -36000] energies = np.arange(2450, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist()+ np.arange(2490, 2501, 5).tolist() waxs_...
def giwaxs_s_edge_wenkai(t=1): dets = [pil300KW] names = ['A2', 'A3', 'A4', 'A5', 'A6'] x = [30000, 16000, 0, -15000, -36000] energies = np.arange(2450, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist() + np.arange(2490, 2501, 5).tolist() waxs_arc = np.lins...
# -*- coding: utf-8 -*- """ This module recieves an ForecastIO object and holds the currently weather conditions. It has one class for this purpose. """ class FIOCurrently(object): """ This class recieves an ForecastIO object and holds the currently weather conditions. """ currently = None d...
""" This module recieves an ForecastIO object and holds the currently weather conditions. It has one class for this purpose. """ class Fiocurrently(object): """ This class recieves an ForecastIO object and holds the currently weather conditions. """ currently = None def __init__(self, forecast...
"""Module providing logic for retrieving bibitems via xml2rfc-style paths, and serializing them to xml2rfc-style RFC 7991 XML. """
"""Module providing logic for retrieving bibitems via xml2rfc-style paths, and serializing them to xml2rfc-style RFC 7991 XML. """
# # PySNMP MIB module AILUXCONNECT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AILUXCONNECT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:00:39 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(aii_conn_type,) = mibBuilder.importSymbols('AISYSTEM-MIB', 'AIIConnType') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constra...
def test_get_custom_properties(exporters, mocker): blender_data = mocker.MagicMock() vector = mocker.MagicMock() vector.to_list.return_value = [0.0, 0.0, 1.0] blender_data.items.return_value = [ ['str', 'spam'], ['float', 1.0], ['int', 42], ['bool', False], ['vect...
def test_get_custom_properties(exporters, mocker): blender_data = mocker.MagicMock() vector = mocker.MagicMock() vector.to_list.return_value = [0.0, 0.0, 1.0] blender_data.items.return_value = [['str', 'spam'], ['float', 1.0], ['int', 42], ['bool', False], ['vector', vector]] assert exporters.BaseEx...
{ 'includes': [ '../common.gypi' ], 'targets': [ { 'target_name': 'shbench', 'product_name': 'shbench', 'type' : 'executable', 'conditions': [ ['OS=="linux"', { 'ldflags': [ '-pthread' ] }], ], 'defines': [ 'SYS_MULTI_TH...
{'includes': ['../common.gypi'], 'targets': [{'target_name': 'shbench', 'product_name': 'shbench', 'type': 'executable', 'conditions': [['OS=="linux"', {'ldflags': ['-pthread']}]], 'defines': ['SYS_MULTI_THREAD'], 'sources': ['src/sh6bench.c'], 'include_dirs': ['src']}]}
# # Copyright (c) 2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
""" Definitions file: It's main functionality are: 1) housing project constants and enums. 2) housing configuration parameters. 3) housing resource paths. """ class Definitions: group_name = 'rl_coach' process_name = 'coach' dashboard_proc = 'firefox' class Flags: css = 'checkpoint_save_secs'...
class AST: """ Base class for abstract syntax trees """ pass class BinOp(AST): """ Binary operation for abstract syntax trees """ def __init__(self, left, op, right): self.left = left self.op = op self.right = right class Num(AST): """ Node for numbers in abstract syntax...
class Ast: """ Base class for abstract syntax trees """ pass class Binop(AST): """ Binary operation for abstract syntax trees """ def __init__(self, left, op, right): self.left = left self.op = op self.right = right class Num(AST): """ Node for numbers in abstract syntax t...
data = [['accesstoken', 'title', 'tab', 'content'], ['6eb92a53-9392-4dc5-a10a-3a853cad6e2c', 'helloworld', 'share', 'hshahdhsahashhdhahda']] def parse_data(): json_data ={} for i in range(len(data)): for j in range(len(data[i])): json_data[data[0][j]] = data[1][j] print(json_dat...
data = [['accesstoken', 'title', 'tab', 'content'], ['6eb92a53-9392-4dc5-a10a-3a853cad6e2c', 'helloworld', 'share', 'hshahdhsahashhdhahda']] def parse_data(): json_data = {} for i in range(len(data)): for j in range(len(data[i])): json_data[data[0][j]] = data[1][j] print(json_data) json...
# Wrapper node Model # Holds the rules and associated key class Node: def __init__(self, rules, key) -> None: self.rules = rules self.key = key
class Node: def __init__(self, rules, key) -> None: self.rules = rules self.key = key
# binary search tree # author: D1N3SHh # https://github.com/D1N3SHh/algorithms class Red_black_tree(): def __init__(self): self.nil = Node(0, 'black', None, None) self.root = self.nil def __repr__(self): return str(self.root) def left_rotate(self, x): y = x.right ...
class Red_Black_Tree: def __init__(self): self.nil = node(0, 'black', None, None) self.root = self.nil def __repr__(self): return str(self.root) def left_rotate(self, x): y = x.right x.right = y.left if y.left != self.nil: y.left.parent = x ...
# -*- coding: utf-8 -*- """Top-level package for pyDarknetServer.""" __author__ = """Lionel Atty""" __email__ = 'yoyonel@hotmail.com' __version__ = '0.2.0'
"""Top-level package for pyDarknetServer.""" __author__ = 'Lionel Atty' __email__ = 'yoyonel@hotmail.com' __version__ = '0.2.0'
# -*- coding: utf-8 -*- '''A completely generic, data-driven, configuration dialog''' class ConfigDialog(QtGui.QDialog): def __init__(self, parent): QtGui.QDialog.__init__(self, parent) # Set up the UI from designer self.ui=UI_ConfigDialog() self.ui.setupUi(self) pages=[] sections=[] sel...
"""A completely generic, data-driven, configuration dialog""" class Configdialog(QtGui.QDialog): def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.ui = ui__config_dialog() self.ui.setupUi(self) pages = [] sections = [] self.values = {} fo...
# The XPATH to determine if the main page has fully loaded HOME_PAGE_XPATH: str = '/html/body/center/table/tbody/tr[2]/td/center/table[1]/tbody/tr/td[3]' + \ '/table/tbody/tr/td/ul[1]/li[1]/a' # The XPATH on the main page to the table listing the kits KITS_XPATH: str = '/html/body/center/table/...
home_page_xpath: str = '/html/body/center/table/tbody/tr[2]/td/center/table[1]/tbody/tr/td[3]' + '/table/tbody/tr/td/ul[1]/li[1]/a' kits_xpath: str = '/html/body/center/table/tbody/tr[2]/td/center/table[1]/tbody/tr/td[1]' + '/table/tbody/tr[4]/td/table/tbody/tr[4]/td/table'
""" 09: See my workflow as a graph ------------------------------- """
""" 09: See my workflow as a graph ------------------------------- """
# -*- coding: utf-8 -*- """ Created on Mon Mar 14 14:43:55 2022 @author: D.Albert-Weiss """ spec_win1D = [ ('win', int32), ]
""" Created on Mon Mar 14 14:43:55 2022 @author: D.Albert-Weiss """ spec_win1_d = [('win', int32)]
def test_parameter_exclusion_empty(api_client, api_prefix): response = api_client.get(f"{api_prefix}/parameters/1/exclusions/") assert response.status_code == 200 json_dict = response.json expected = { "message": "exclusions for parameter 1", "parameter": {"excluded": [], "excluded_by":...
def test_parameter_exclusion_empty(api_client, api_prefix): response = api_client.get(f'{api_prefix}/parameters/1/exclusions/') assert response.status_code == 200 json_dict = response.json expected = {'message': 'exclusions for parameter 1', 'parameter': {'excluded': [], 'excluded_by': [], 'name': 'Colo...
g = int(input()) l = list(map(int,input().split())) mi = min(l) ma = max(l) y=0 for i in l: if i == ma: break y+=1 l.remove(ma) l.insert(0,ma) x = l[-1::-1] for j in x: if j==mi: break y+=1 print(y)
g = int(input()) l = list(map(int, input().split())) mi = min(l) ma = max(l) y = 0 for i in l: if i == ma: break y += 1 l.remove(ma) l.insert(0, ma) x = l[-1::-1] for j in x: if j == mi: break y += 1 print(y)
def vsota_stevk(n): s = str(n) vsota = 0 for x in s: vsota += int(x) return vsota def euler56(): najvecja_vsota = 0 for a in range(1,100): for b in range(1,100): st = a ** b s = vsota_stevk(st) if s > najvecja_vsota: ...
def vsota_stevk(n): s = str(n) vsota = 0 for x in s: vsota += int(x) return vsota def euler56(): najvecja_vsota = 0 for a in range(1, 100): for b in range(1, 100): st = a ** b s = vsota_stevk(st) if s > najvecja_vsota: najvecja...
def newArr(arr): """ MapReduce: O(n^2) 1. Map: construct the Map with Key is each element and Value is the array 2. Reduce: product all element of Value except the key """ result = [] hashmap = {} for i in arr: hashmap[i] = arr for key, value in hashmap.items(): ...
def new_arr(arr): """ MapReduce: O(n^2) 1. Map: construct the Map with Key is each element and Value is the array 2. Reduce: product all element of Value except the key """ result = [] hashmap = {} for i in arr: hashmap[i] = arr for (key, value) in hashmap.items(): pr...
# this one needs to be a multiple of 8 bitsString = "1111111101111111001111110001111100001111000001110000001100000001" # store here the hex values bhex = list() # check the size of bitsString if len(bitsString) % 8 != 0 : print("Invalid string len provided") # split, convert to 8 and append to a string (make this more ...
bits_string = '1111111101111111001111110001111100001111000001110000001100000001' bhex = list() if len(bitsString) % 8 != 0: print('Invalid string len provided') for i in range(0, len(bitsString), 8): bhex.append(hex(int(bitsString[i:i + 8], 2))) print(bhex) for i in range(len(bhex)): c = bytearray(bhex[i], ...
def gcd(a, b): while b: a, b = b, a % b return a def isPrimeMR(n): d = n - 1 d = d // (d & -d) L = [2] for a in L: t = d y = pow(a, t, n) if y == 1: continue while y != n - 1: y = (y * y) % n if y == 1 or t == n - 1: return 0 t ...
def gcd(a, b): while b: (a, b) = (b, a % b) return a def is_prime_mr(n): d = n - 1 d = d // (d & -d) l = [2] for a in L: t = d y = pow(a, t, n) if y == 1: continue while y != n - 1: y = y * y % n if y == 1 or t == n - 1...
x=int(input()) for i in range(0,x): a,b=map(int,input().split()) print(a+b)
x = int(input()) for i in range(0, x): (a, b) = map(int, input().split()) print(a + b)
suppressions = [ # This one cannot be covered by any Python language test because there is # no code pathway to it. But it is part of the C API, so must not be # excised from the code. [ r".*/multiarray/mapping\.", "PyArray_MapIterReset" ], # PyArray_Std trivially forwards to and appears to be sup...
suppressions = [['.*/multiarray/mapping\\.', 'PyArray_MapIterReset'], ['.*/multiarray/calculation\\.', 'PyArray_Std'], ['.*/multiarray/common\\.', 'PyCapsule_Check']]
# _*_coding:utf-8_*_ class Solution: def get_maybe(self, index, pushV): maybe = [None] j = index - 1 while j >= 0: if None is not pushV[j]: maybe[0] = j break j -= 1 j = index + 1 while j < len...
class Solution: def get_maybe(self, index, pushV): maybe = [None] j = index - 1 while j >= 0: if None is not pushV[j]: maybe[0] = j break j -= 1 j = index + 1 while j < len(pushV): if None is not pushV[j]: ...
# 2020.07.09 # Problem Statement: # https://leetcode.com/problems/longest-palindromic-substring/ class Solution: def longestPalindrome(self, s: str) -> str: # discuss corner cases if len(s) == 0: return "" elif len(s) == 1: return s elif len(s) == 2: ...
class Solution: def longest_palindrome(self, s: str) -> str: if len(s) == 0: return '' elif len(s) == 1: return s elif len(s) == 2: if s[0] == s[1]: return s else: return s[0] current_longest = '' ...
""" Data model module. In this module the data types used in CGnal framework are defined. """
""" Data model module. In this module the data types used in CGnal framework are defined. """
# -*- coding: utf-8 -*- """Top-level package for Tractography Meta-Pipeline Command Line Tool (TRAMPOLINO).""" __author__ = """Matteo Mancini""" __email__ = 'ingmatteomancini@gmail.com' __version__ = '0.1.9'
"""Top-level package for Tractography Meta-Pipeline Command Line Tool (TRAMPOLINO).""" __author__ = 'Matteo Mancini' __email__ = 'ingmatteomancini@gmail.com' __version__ = '0.1.9'
class Solution: @staticmethod def naive(nums,target): l,r = 0,len(nums)-1 while l<=r: m = (l+r)//2 if nums[m]==target: return m if nums[l]<=nums[m]: if target>=nums[l] and target<nums[m]: r=m-1 ...
class Solution: @staticmethod def naive(nums, target): (l, r) = (0, len(nums) - 1) while l <= r: m = (l + r) // 2 if nums[m] == target: return m if nums[l] <= nums[m]: if target >= nums[l] and target < nums[m]: ...
step( """ create unique index unq_image_tag_image_id_tag_id on image_tag (image_id, tag_id) """, """ drop index unq_image_tag_image_id_tag_id """ )
step('\n create unique index unq_image_tag_image_id_tag_id\n on image_tag (image_id, tag_id)\n ', '\n drop index unq_image_tag_image_id_tag_id\n ')
consumer_key = 'gdLsE3urZ6HqjE2RjiwaFBwag' consumer_secret = 'rubc1WvJoYOnsBoUMXXV660MUOhw685uTFjqnYmrRWdqoq6Y48' access_token = '846813944186650627-CpBzbP1i8ag3pREHkd6YcGQeMHbaLOx' access_secret = 'rX2ikxxtI4zplBp9kbEEpibWVKyCwKJmvuxTiKxFgeJKA'
consumer_key = 'gdLsE3urZ6HqjE2RjiwaFBwag' consumer_secret = 'rubc1WvJoYOnsBoUMXXV660MUOhw685uTFjqnYmrRWdqoq6Y48' access_token = '846813944186650627-CpBzbP1i8ag3pREHkd6YcGQeMHbaLOx' access_secret = 'rX2ikxxtI4zplBp9kbEEpibWVKyCwKJmvuxTiKxFgeJKA'
""" The Notebook module. """ class Notebook: """ This notebook does... """ def run(self): """ Your notebook code goes here. """ notebook = Notebook() notebook.run()
""" The Notebook module. """ class Notebook: """ This notebook does... """ def run(self): """ Your notebook code goes here. """ notebook = notebook() notebook.run()
save_dir = './logs' # miniImageNet_path = '../../semifew_data/miniImagenetFullSize' miniImageNet_path = '/home/ojas/projects/unsupervised-meta-learning/data/untarred/miniImagenetFullSize' ISIC_path = "../../semifew_data/ISIC" ChestX_path = "../../semifew_data/chestX" CropDisease_path = "...
save_dir = './logs' mini_image_net_path = '/home/ojas/projects/unsupervised-meta-learning/data/untarred/miniImagenetFullSize' isic_path = '../../semifew_data/ISIC' chest_x_path = '../../semifew_data/chestX' crop_disease_path = '../../semifew_data/plant-disease' euro_sat_path = '/home/ojas/projects/unsupervised-meta-lea...
class Result(object): ''' Simple wrapper object to contain result of single iteration MPI computation ''' def __init__(self, rank, idx): self.rank = rank self.idx = idx self.result = None def __repr__(self): return "rank: %d idx: %s result: %s" % (self.rank, self.idx...
class Result(object): """ Simple wrapper object to contain result of single iteration MPI computation """ def __init__(self, rank, idx): self.rank = rank self.idx = idx self.result = None def __repr__(self): return 'rank: %d idx: %s result: %s' % (self.rank, self.id...
# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
ga_account_id = '' ga_property_id = '' ga_dataset_id = '' ga_import_method = 'di' ga_mp_standard_hit_details = {'v': 1, 'tid': GA_PROPERTY_ID, 't': '', 'ni': 1, 'ec': '', 'ea': '', 'el': '', 'ds': '', 'ua': 'modem'} bqml_predict_query = '\n ' enable_bq_logging = False enable_sendgrid_email_reporting...
option='y' while option=='y': print("Enter the number whose factorial to find") num=int(input()) fac=1 while(num!=1): fac=fac*num num=num-1 print("Factorial is "+str(fac)) print("Do you want to continue?(y/n)") option=input() print('Thank you for using this program...
option = 'y' while option == 'y': print('Enter the number whose factorial to find') num = int(input()) fac = 1 while num != 1: fac = fac * num num = num - 1 print('Factorial is ' + str(fac)) print('Do you want to continue?(y/n)') option = input() print('Thank you for using th...
def poly(a, x): val = 0 for ai in reversed(a): val *= x val += ai return val def diff(a): return [a[i + 1] * (i + 1) for i in range(len(a) - 1)] def divroot(a, x0): b, a[-1] = a[-1], 0 for i in reversed(range(len(a) - 1)): a[i], b = a[i + 1] * x0 + b, a[i] a.p...
def poly(a, x): val = 0 for ai in reversed(a): val *= x val += ai return val def diff(a): return [a[i + 1] * (i + 1) for i in range(len(a) - 1)] def divroot(a, x0): (b, a[-1]) = (a[-1], 0) for i in reversed(range(len(a) - 1)): (a[i], b) = (a[i + 1] * x0 + b, a[i]) ...
tickers = [ 'aapl', 'tsla', ]
tickers = ['aapl', 'tsla']
LAMBDA_232 = 4.934E-11#Amelin and Zaitsev, 2002. # LAMBDA_232 = 4.9475E-11 #old value, used in isoplot ERR_LAMBDA_232 = 0.015E-11#Amelin and Zaitsev, 2002. LAMBDA_235 = 9.8485E-10 #ERR_LAMBDA_235 = LAMBDA_238 = 1.55125E-10 #ERR_LAMBDA_238 = U238_U235 = 137.817 #https://doi.org/10.1016/j.gca.2018.06.014 # U238_U235 =...
lambda_232 = 4.934e-11 err_lambda_232 = 1.5e-13 lambda_235 = 9.8485e-10 lambda_238 = 1.55125e-10 u238_u235 = 137.817 err_u238_u235 = 0.031 lambdas = [LAMBDA_238, LAMBDA_235, LAMBDA_232] isotope_ratios = ['U238_Pb206', 'U235_Pb207', 'Th232_Pb208', 'Pb206_Pb207'] minerals = ['zircon', 'baddeleyite', 'perovskite', 'monazi...
# Bar chart # a graph that represents the category of data with rectangular bars with lengths and heights that are proportional # to the values which they represent. # Can be vertical or horizontal. Can also be grouped. # matplotlib fig, ax = plt.subplots(1, figsize=(24,14)) plt.bar(wrestling_count.index, wrestling_...
(fig, ax) = plt.subplots(1, figsize=(24, 14)) plt.bar(wrestling_count.index, wrestling_count.ID, width=0.9, color='xkcd:plum', edgecolor='ivory', linewidth=0, hatch='-') plt.setp(ax.get_xticklabels(), rotation=45, ha='right', rotation_mode='anchor') plt.title('\nHUNGARIAN WRESTLERS\n', fontsize=55, loc='left') ax.tick_...
{ "targets": [ { "target_name": "gles3", "sources": [ "src/node-gles3.cpp" ], 'include_dirs': [ 'src', 'src/include' ], 'cflags':[], 'conditions': [ ['OS=="mac"', { 'libraries': [ '-lGLEW', '-framework OpenGL' ...
{'targets': [{'target_name': 'gles3', 'sources': ['src/node-gles3.cpp'], 'include_dirs': ['src', 'src/include'], 'cflags': [], 'conditions': [['OS=="mac"', {'libraries': ['-lGLEW', '-framework OpenGL'], 'include_dirs': ['./node_modules/native-graphics-deps/include'], 'library_dirs': ['../node_modules/native-graphics-de...
''' Created on 7 jan. 2013 @author: sander ''' # The following Key ID values are defined by this specification as used # in any packet type that references a Key ID field: # # Name Number Defined in #----------------------------------------------- # None 0 n/a # ...
""" Created on 7 jan. 2013 @author: sander """ key_id_none = 0 key_id_hmac_sha_1_96 = 1 key_id_hmac_sha_256_128 = 2
#!/usr/bin/python3 # ref: https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange#Cryptographic_explanation # ref: https://en.wikipedia.org/wiki/RSA_(cryptosystem) shared_modulus = 23 shared_base = 5 print("shared modulus: %s" % shared_modulus) print("shared base: %s" % shared_base) print("-"*40) alice_sec...
shared_modulus = 23 shared_base = 5 print('shared modulus: %s' % shared_modulus) print('shared base: %s' % shared_base) print('-' * 40) alice_secret = 4 bob_secret = 3 print("alice's secret key: %s" % alice_secret) print("bob's secret key: %s" % bob_secret) print('-' * 40) a = shared_base ** alice_secret % shared_modul...
#!/usr/bin/env python # @Time : 2019-06-03 # @Author : hongshu BUFF_SIZE = 32 * 1024
buff_size = 32 * 1024
########################### # 6.0002 Problem Set 1b: Space Change # Name: # Collaborators: # Time: # Author: charz, cdenise #================================ # Part B: Golden Eggs #================================ # Problem 1 def dp_make_weight(egg_weights, target_weight, memo = {}): """ Find number of eggs t...
def dp_make_weight(egg_weights, target_weight, memo={}): """ Find number of eggs to bring back, using the smallest number of eggs. Assumes there is an infinite supply of eggs of each weight, and there is always a egg of value 1. Parameters: egg_weights - tuple of integers, available egg weights...
# from functools import wraps # def debugMethod(func, cls=None): # '''decorator for debugging passed function''' # @wraps(func) # def wrapper(*args, **kwargs): # print({ # 'class': cls, # class object, not string # 'method': func.__qualname__, # method name, string # ...
class Meta(type): def __getattribute__(self, name): print({'action': 'get', 'attr': name}) return object.__getattribute__(self, name) class A(object, metaclass=Meta): def add(self, x, y): return x + y def mul(self, x, y): return x * y a = a() a.x = 200
#!/usr/bin/env python3 """Solves problem xxx from the Project Euler website""" def solve(): """Solve the problem and return the result""" oneToNine = sum( [len('one'), len('two'), len('three'), len('four'), len('five'), len('six'), ...
"""Solves problem xxx from the Project Euler website""" def solve(): """Solve the problem and return the result""" one_to_nine = sum([len('one'), len('two'), len('three'), len('four'), len('five'), len('six'), len('seven'), len('eight'), len('nine')]) one_to_nintynine = 10 * sum([len('twenty'), len('thirty...
class NCBaseError(Exception): def __init__(self, message) -> None: super(NCBaseError, self).__init__(message) class DataTypeMismatchError(Exception): def __init__(self, provided_data, place:str=None, required_data_type:str=None) -> None: message = f"{provided_data} datatype isn't supported for...
class Ncbaseerror(Exception): def __init__(self, message) -> None: super(NCBaseError, self).__init__(message) class Datatypemismatcherror(Exception): def __init__(self, provided_data, place: str=None, required_data_type: str=None) -> None: message = f"{provided_data} datatype isn't supported ...
class Node: def __init__(self, data): self.data= data self.previous= None self.next= None class DoublyLinkedList: def __init__(self): self.head= None def create_list(self, arr): start= self.head n= len(arr) temp= st...
class Node: def __init__(self, data): self.data = data self.previous = None self.next = None class Doublylinkedlist: def __init__(self): self.head = None def create_list(self, arr): start = self.head n = len(arr) temp = start i = 0 ...
# The ranges below are as specified in the Yellow Paper. # Note: range(s, e) excludes e, hence the +1 valid_opcodes = [ *range(0x00, 0x0b + 1), *range(0x10, 0x1d + 1), 0x20, *range(0x30, 0x3f + 1), *range(0x40, 0x48 + 1), *range(0x50, 0x5b + 1), *range(0x60, 0x6f + 1), *range(0x70, 0x7f ...
valid_opcodes = [*range(0, 11 + 1), *range(16, 29 + 1), 32, *range(48, 63 + 1), *range(64, 72 + 1), *range(80, 91 + 1), *range(96, 111 + 1), *range(112, 127 + 1), *range(128, 143 + 1), *range(144, 159 + 1), *range(160, 164 + 1), *range(240, 245 + 1), 250, 253, 254, 255] terminating_opcodes = [0, 243, 253, 254, 255] imm...
QUESTIONS = { 'a1': { 'Q': 'What is the chemical symbol for gold?', 'A': 'au' }, 'a2': { 'Q': '', 'A': '' }, 'a3': { 'Q': '', 'A': '' }, 'a4': { 'Q': '', 'A': '' }, 'b1': { 'Q': '', 'A'...
questions = {'a1': {'Q': 'What is the chemical symbol for gold?', 'A': 'au'}, 'a2': {'Q': '', 'A': ''}, 'a3': {'Q': '', 'A': ''}, 'a4': {'Q': '', 'A': ''}, 'b1': {'Q': '', 'A': ''}, 'b2': {'Q': '', 'A': ''}, 'b3': {'Q': '', 'A': ''}, 'b4': {'Q': '', 'A': ''}, 'c1': {'Q': '', 'A': ''}, 'c2': {'Q': '', 'A': ''}, 'c3': {'...
#Multilevel Inner Classes #In multilevel inner classes, the inner class contains another class which inner classes to the previous one. class Outer: """Outer Class""" def __init__(self): ## instantiating the 'Inner' class self.inner = self.Inner() ## instantiating the multilevel 'Inn...
class Outer: """Outer Class""" def __init__(self): self.inner = self.Inner() self.innerinner = self.inner.InnerInner() def show_classes(self): print("This is Outer class's function") self.inner.inner_display('message 1 ') self.innerinner.inner_display('message 3') ...
#!/usr/bin/python3 ''' Collects Weather Forecast by Indian Meterological Department, by parsing webpages :) ''' __version__ = '0.2.0' __author__ = 'Anjan Roy<anjanroy@yandex.com>'
""" Collects Weather Forecast by Indian Meterological Department, by parsing webpages :) """ __version__ = '0.2.0' __author__ = 'Anjan Roy<anjanroy@yandex.com>'
# Contains all the basic info about awards class Award: count = 0 def __init__(self, url, number, name, type, application, restrictions, renewable, value, due, description, sequence): self.url = url self.number = number self.name = name self.type = type self.application = applica...
class Award: count = 0 def __init__(self, url, number, name, type, application, restrictions, renewable, value, due, description, sequence): self.url = url self.number = number self.name = name self.type = type self.application = application self.restrictions = r...
""" """ load("@bazel_skylib//lib:paths.bzl", "paths") load("@fbcode_macros//build_defs/lib/thrift:thrift_interface.bzl", "thrift_interface") load("@fbcode_macros//build_defs/lib:common_paths.bzl", "common_paths") load("@fbcode_macros//build_defs/lib:src_and_dep_helpers.bzl", "src_and_dep_helpers") load("@fbcode_macros...
""" """ load('@bazel_skylib//lib:paths.bzl', 'paths') load('@fbcode_macros//build_defs/lib/thrift:thrift_interface.bzl', 'thrift_interface') load('@fbcode_macros//build_defs/lib:common_paths.bzl', 'common_paths') load('@fbcode_macros//build_defs/lib:src_and_dep_helpers.bzl', 'src_and_dep_helpers') load('@fbcode_macros/...
# Cracking the Coding Interview 6th Edition # Chapter 1 - Arrays and Strings. Page 88 # Question 1.2 # Solved by Yong Lin Wang """ Given two strings, write a method to decide if one is a permutation of the other. """ def check_permutation(str1, str2): """ If two strings are permutation to one another,...
""" Given two strings, write a method to decide if one is a permutation of the other. """ def check_permutation(str1, str2): """ If two strings are permutation to one another, they should have the same characters. This solution evaluates the sum of the orders of the strings if they are ...
class Solution: def productExceptSelf(self, nums): """ :type nums: List[int] :rtype: List[int] """ if (not nums): return None n = len(nums) result = [1] * n prod = 1 for i in range(n): result[i] = result[i] * pr...
class Solution: def product_except_self(self, nums): """ :type nums: List[int] :rtype: List[int] """ if not nums: return None n = len(nums) result = [1] * n prod = 1 for i in range(n): result[i] = result[i] * prod ...
class Solution: def dailyTemperatures(self, T: List[int]) -> List[int]: warmer_day = [0]*len(T) recent_day = [2**31-1]*101 MAXLEN = 30000 for i in range(len(T)-1, -1, -1): minday = 2**31-1 for warmer_temp in range(T[i]+1, 101): if recent_day[wa...
class Solution: def daily_temperatures(self, T: List[int]) -> List[int]: warmer_day = [0] * len(T) recent_day = [2 ** 31 - 1] * 101 maxlen = 30000 for i in range(len(T) - 1, -1, -1): minday = 2 ** 31 - 1 for warmer_temp in range(T[i] + 1, 101): ...
# encoding: utf-8 class Animals(object): def __init__(self, sound): self.sound = sound def speak(self): return self.sound
class Animals(object): def __init__(self, sound): self.sound = sound def speak(self): return self.sound
"""Top-level package for Calorimeter.""" __author__ = """Jonathon Vandezande""" __email__ = 'jevandezande@gmail.com' __version__ = '0.2.1'
"""Top-level package for Calorimeter.""" __author__ = 'Jonathon Vandezande' __email__ = 'jevandezande@gmail.com' __version__ = '0.2.1'
f = open('graph.dot') def find_between( s, first, last ): try: start = s.index( first ) + len( first ) end = s.index( last, start ) return s[start:end] except ValueError: return "" s1 = "digraph " s2 = """ { graph [ rankdir="RL" ] """ s3 = "}" for line in f: name = find_betw...
f = open('graph.dot') def find_between(s, first, last): try: start = s.index(first) + len(first) end = s.index(last, start) return s[start:end] except ValueError: return '' s1 = 'digraph ' s2 = '\n{\ngraph [ rankdir="RL" ]\n' s3 = '}' for line in f: name = find_between(line,...
# Copyright 2021 Nokia # Licensed under the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause class ApiVersion(object): def __init__(self, group: str, version: str): self.group = group self.version = version class Kind(ApiVersion): def __init__(self, group: str, version: str, kind...
class Apiversion(object): def __init__(self, group: str, version: str): self.group = group self.version = version class Kind(ApiVersion): def __init__(self, group: str, version: str, kind: str): super().__init__(group, version) self.kind = kind class Resource(ApiVersion): ...
class Accessor(object): """""" pass class WriteThru(Accessor): """Implement write-thru access pattern.""" pass class WriteAround(Accessor): """Implement write-around access pattern.""" pass class WriteBack(Accessor): """Implement write-back access pattern.""" pass
class Accessor(object): """""" pass class Writethru(Accessor): """Implement write-thru access pattern.""" pass class Writearound(Accessor): """Implement write-around access pattern.""" pass class Writeback(Accessor): """Implement write-back access pattern.""" pass
_base_ = '../cascade_rcnn/cascade_mask_rcnn_r50_fpn_mstrain_3x_coco.py' model = dict( backbone=dict( type='ResNeXt', depth=101, groups=32, base_width=8, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=Fa...
_base_ = '../cascade_rcnn/cascade_mask_rcnn_r50_fpn_mstrain_3x_coco.py' model = dict(backbone=dict(type='ResNeXt', depth=101, groups=32, base_width=8, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=False), style='pytorch', init_cfg=dict(type='Pretrained', checkpoint='ope...
def find_missing(S): if len(S) > 0: m = max(S) vals = [ 0 for i in range(m)] for x in S: if x < 0: print("Warning {} is <0. Ignoring it.".format(x)) else: vals[x-1] += 1 return [x+1 for x in range(m) if vals[x] == 0] else: ...
def find_missing(S): if len(S) > 0: m = max(S) vals = [0 for i in range(m)] for x in S: if x < 0: print('Warning {} is <0. Ignoring it.'.format(x)) else: vals[x - 1] += 1 return [x + 1 for x in range(m) if vals[x] == 0] else...
def solution(inpnum): upnum = int(str(9)*inpnum) lownum = int(str(1)+(str(0)*(inpnum-1))) ansnum = None for i in range(upnum,lownum,-1): if len(str(i))==len(set(str(i))): if 2**(i-1)%i==1: ansnum = i break return ansnum
def solution(inpnum): upnum = int(str(9) * inpnum) lownum = int(str(1) + str(0) * (inpnum - 1)) ansnum = None for i in range(upnum, lownum, -1): if len(str(i)) == len(set(str(i))): if 2 ** (i - 1) % i == 1: ansnum = i break return ansnum
def visualize(**images): """PLot images in one row.""" n = len(images) plt.figure(figsize=(16, 5)) for i, (name, image) in enumerate(images.items()): plt.subplot(1, n, i + 1) plt.xticks([]) plt.yticks([]) plt.title(' '.join(name.split('_')).title()) plt.imshow(ima...
def visualize(**images): """PLot images in one row.""" n = len(images) plt.figure(figsize=(16, 5)) for (i, (name, image)) in enumerate(images.items()): plt.subplot(1, n, i + 1) plt.xticks([]) plt.yticks([]) plt.title(' '.join(name.split('_')).title()) plt.imshow(i...
class Solution: def toHex(self, num: int) -> str: if num == 0: return '0' chars, result = '0123456789abcdef', [] if num < 0: num += (1 << 32) while num > 0: result.insert(0, chars[num % 16]) num //= 16 return ''.join(result)
class Solution: def to_hex(self, num: int) -> str: if num == 0: return '0' (chars, result) = ('0123456789abcdef', []) if num < 0: num += 1 << 32 while num > 0: result.insert(0, chars[num % 16]) num //= 16 return ''.join(result)
#!/usr/bin/python3 """ Class check module Functions: is_kind_of_class: checks if obj is inherit from determined class """ def is_kind_of_class(obj, a_class): """ checks class inheritance Args: obj: object to evaluate a_class: suspect father """ return i...
""" Class check module Functions: is_kind_of_class: checks if obj is inherit from determined class """ def is_kind_of_class(obj, a_class): """ checks class inheritance Args: obj: object to evaluate a_class: suspect father """ return isinstance(obj, a_clas...
# Space: O(1) # Time: O(n) # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def diameterOfBinaryTree(self, root): self.res = 0 self.dfs(ro...
class Solution: def diameter_of_binary_tree(self, root): self.res = 0 self.dfs(root) return self.res def dfs(self, root): if root is None: return 0 (left, right) = (0, 0) if root.left: left = self.dfs(root.left) + 1 if root.right:...
try: n = int(input("Enter number")) print(n*n) except: print("Non integer entered")
try: n = int(input('Enter number')) print(n * n) except: print('Non integer entered')
height = int(input()) for i in range(0,height+1): for j in range(0,i+1): if(j == i): print(i,end=" ") else: print("*",end=" ") print() # Sample Input :- 5 # Output :- # 0 # * 1 # * * 2 # * * * 3 # * * * * 4 # * * * * * 5
height = int(input()) for i in range(0, height + 1): for j in range(0, i + 1): if j == i: print(i, end=' ') else: print('*', end=' ') print()
statement_one = False statement_two = True credits = 120 gpa = 1.8 if not credits >= 120: print('You do not have enough credits to graduate.') if not gpa >= 2.0: print('Your GPA is not high enough to graduate.') if not (credits >= 120) and not (gpa >= 2.0): print('You do not meet either require...
statement_one = False statement_two = True credits = 120 gpa = 1.8 if not credits >= 120: print('You do not have enough credits to graduate.') if not gpa >= 2.0: print('Your GPA is not high enough to graduate.') if not credits >= 120 and (not gpa >= 2.0): print('You do not meet either requirement to graduat...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Day 8: Dictionaries and Maps Source : https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem """ n = int(input()) book = dict([input().split() for _ in range(n)]) for _ in range(n): name = input() print("%s=%s" % (name, book[name]) if name in b...
"""Day 8: Dictionaries and Maps Source : https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem """ n = int(input()) book = dict([input().split() for _ in range(n)]) for _ in range(n): name = input() print('%s=%s' % (name, book[name]) if name in book else 'Not found')
LOCALHOST_EQUIVALENTS = frozenset(( 'localhost', '127.0.0.1', '0.0.0.0', '0:0:0:0:0:0:0:0', '0:0:0:0:0:0:0:1', '::1', '::', ))
localhost_equivalents = frozenset(('localhost', '127.0.0.1', '0.0.0.0', '0:0:0:0:0:0:0:0', '0:0:0:0:0:0:0:1', '::1', '::'))
count = int(input()) for i in range(count): print("@"*(count*5)) for i in range(count*3): print("@"*(count)," "*(count*3),"@"*(count),sep="") for i in range(count): print("@"*(count*5))
count = int(input()) for i in range(count): print('@' * (count * 5)) for i in range(count * 3): print('@' * count, ' ' * (count * 3), '@' * count, sep='') for i in range(count): print('@' * (count * 5))
a = input("Enter some list of numbers =") for i in a: print(i) print(type(a))
a = input('Enter some list of numbers =') for i in a: print(i) print(type(a))
# Cache bitcode CACHE = False # Save object file for module ASM = False # Write LLVM dump to file DUMP = True # Enable AST debugging dump DEBUG = True # Write dump files to same directory as module? # if False, this will write all dumps to one "debug" file in the main dir DUMP_TO_DIR = False
cache = False asm = False dump = True debug = True dump_to_dir = False
""" Batch processing examples - Griatch 2012 """
""" Batch processing examples - Griatch 2012 """
''' Common settings for using in a project scope ''' MODEL_ZIP_FILE_NAME_ENV_VAR = 'TF_AWS_MODEL_ZIP_FILE_NAME' MODEL_PROTOBUF_FILE_NAME_ENV_VAR = 'TF_AWS_MODEL_PROTOBUF_FILE_NAME' S3_MODEL_BUCKET_NAME_ENV_VAR = 'TF_AWS_S3_MODEL_BUCKET_NAME'
""" Common settings for using in a project scope """ model_zip_file_name_env_var = 'TF_AWS_MODEL_ZIP_FILE_NAME' model_protobuf_file_name_env_var = 'TF_AWS_MODEL_PROTOBUF_FILE_NAME' s3_model_bucket_name_env_var = 'TF_AWS_S3_MODEL_BUCKET_NAME'
expected_output = { 'pid': 'CISCO3945-CHASSIS', 'os': 'ios', 'platform': 'c3900', 'version': '15.0(1)M7', }
expected_output = {'pid': 'CISCO3945-CHASSIS', 'os': 'ios', 'platform': 'c3900', 'version': '15.0(1)M7'}
class RobertException(Exception): def __init__(self, message: str = None): message = 'An fatal error has occurred' if message is None else message super().__init__(message) class LanguageNotSupported(RobertException): def __init__(self): super().__init__('That language is not supported'...
class Robertexception(Exception): def __init__(self, message: str=None): message = 'An fatal error has occurred' if message is None else message super().__init__(message) class Languagenotsupported(RobertException): def __init__(self): super().__init__('That language is not supported'...
# TODO: Use these simplified dataclasses once support for Python 3.6 is # dropped. Meanwhile we'll use the "polyfill" classes defined below. # # from dataclasses import dataclass, field # # @dataclass # class Client: # user_id: str # user_type: str = field(default="client", init=False) # # # @dataclass # class ...
class Client: user_id: str user_type: str def __init__(self, user_id): self.user_id = user_id self.user_type = 'client' class Team: user_id: str user_type: str def __init__(self, user_id): self.user_id = user_id self.user_type = 'team' class User: user_id:...
def update_dict(old_dict, values): """ Update dictionary without change the original object """ new_dict = old_dict.copy() new_dict.update(values) return new_dict
def update_dict(old_dict, values): """ Update dictionary without change the original object """ new_dict = old_dict.copy() new_dict.update(values) return new_dict
add = 3+2 print (add) subtract = 3-2 print (subtract) multiply = 3*2 print (multiply) division = 3/2 print (division) modulus = 3%2 print (modulus) lessThan = 3<2 print (lessThan) greaterThan = 3>2 print(greaterThan) equals = 3==3 print (equals) logicalAnd = (2==2) and (3==3) and (4==4) print (logicalAnd) logi...
add = 3 + 2 print(add) subtract = 3 - 2 print(subtract) multiply = 3 * 2 print(multiply) division = 3 / 2 print(division) modulus = 3 % 2 print(modulus) less_than = 3 < 2 print(lessThan) greater_than = 3 > 2 print(greaterThan) equals = 3 == 3 print(equals) logical_and = 2 == 2 and 3 == 3 and (4 == 4) print(logicalAnd) ...
#!/usr/bin/env python3 #variable delaration names = [] address = [] age = [] institute = [] dept = [] print('------+++++++Welcome to student info software+++++++------\n') names.insert(0, input('Enter your Full name: ')) address.insert(0, input('Enter your Address: ')) age.insert(0, input('Enter your Ag...
names = [] address = [] age = [] institute = [] dept = [] print('------+++++++Welcome to student info software+++++++------\n') names.insert(0, input('Enter your Full name: ')) address.insert(0, input('Enter your Address: ')) age.insert(0, input('Enter your Age: ')) institute.insert(0, input('Enter your School: ')) dep...
def valid_palindrome(str): left, right = 0, len(str) - 1 while left < right: if not str[left].isalnum(): left += 1 elif not str[right].isalnum(): right -= 1 else: if str[left].lower() != str[right].lower(): print('False') ...
def valid_palindrome(str): (left, right) = (0, len(str) - 1) while left < right: if not str[left].isalnum(): left += 1 elif not str[right].isalnum(): right -= 1 elif str[left].lower() != str[right].lower(): print('False') return False ...
{ 4 : { "operator" : "aggregation", "numgroups" : 1000000 } }
{4: {'operator': 'aggregation', 'numgroups': 1000000}}
def get_numbers_between(set_a, set_b): numbers_between = 0 for candidate in range(1, 101): found = True for item in set_a: if candidate % item: found = False break if not found: continue for item in set_b: if...
def get_numbers_between(set_a, set_b): numbers_between = 0 for candidate in range(1, 101): found = True for item in set_a: if candidate % item: found = False break if not found: continue for item in set_b: if ite...
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def python_dependencies_early(): http_archive( name = "rules_python", url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz", sha256 = "aa96a691d3a8177f3215b14b0edc9641787abaaa...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def python_dependencies_early(): http_archive(name='rules_python', url='https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz', sha256='aa96a691d3a8177f3215b14b0edc9641787abaaa30363a080165d06ab65e1161')
# Pow(x, n): https://leetcode.com/problems/powx-n/ # Implement pow(x, n), which calculates x raised to the power n (i.e., xn). # This problem is pretty straight forward we simply iterate over the n times # multiplying the input every time. The only tricky thing is that if we have # a negative number we need to make s...
class Solution: def my_pow(self, x: float, n: int) -> float: if n == 0: return 1.0 if x == 0: return 0 if n < 0: x = 1 / x n *= -1 result = 1 for _ in range(n): result *= x return result def my_pow_opti...
# User input num1=float(input("Enter the 1st number: ")) num2=float(input("Enter your 2nd number: ")) # Operations the program should perform sum = num1 + num2 difference = num1 - num2 product = num1 * num2 divide = num1 / num2 modulus = num1 % num2 # Computer output print(sum) print(difference) print(product) print(...
num1 = float(input('Enter the 1st number: ')) num2 = float(input('Enter your 2nd number: ')) sum = num1 + num2 difference = num1 - num2 product = num1 * num2 divide = num1 / num2 modulus = num1 % num2 print(sum) print(difference) print(product) print(divide) print(modulus)
def main(): print("Iterative:") print("n=0 ->", fibonacci_iterative(0)) print("n=1 ->", fibonacci_iterative(1)) print("n=6 ->", fibonacci_iterative(6)) print() print("Recursive:") print("n=0 ->", fibonacci_recursive(0)) print("n=1 ->", fibonacci_recursive(1)) print("n=6 ->", fibonacc...
def main(): print('Iterative:') print('n=0 ->', fibonacci_iterative(0)) print('n=1 ->', fibonacci_iterative(1)) print('n=6 ->', fibonacci_iterative(6)) print() print('Recursive:') print('n=0 ->', fibonacci_recursive(0)) print('n=1 ->', fibonacci_recursive(1)) print('n=6 ->', fibonacc...
wanted_income = float(input()) total_income = 0 cocktail = input() while cocktail != "Party!": order = int(input()) cocktail_price = len(cocktail) cocktail_price = order * cocktail_price if cocktail_price % 2 != 0: discount = cocktail_price - (cocktail_price * 0.25) total_income +=...
wanted_income = float(input()) total_income = 0 cocktail = input() while cocktail != 'Party!': order = int(input()) cocktail_price = len(cocktail) cocktail_price = order * cocktail_price if cocktail_price % 2 != 0: discount = cocktail_price - cocktail_price * 0.25 total_income += discoun...
#!/usr/bin/env python3 strings = [ "sszojmmrrkwuftyv", "isaljhemltsdzlum", "fujcyucsrxgatisb", "qiqqlmcgnhzparyg", "oijbmduquhfactbc", "jqzuvtggpdqcekgk", "zwqadogmpjmmxijf", "uilzxjythsqhwndh", "gtssqejjknzkkpvw", "wrggegukhhatygfi", "vhtcgqzerxonhsye", "tedlwzdjfppbmtd...
strings = ['sszojmmrrkwuftyv', 'isaljhemltsdzlum', 'fujcyucsrxgatisb', 'qiqqlmcgnhzparyg', 'oijbmduquhfactbc', 'jqzuvtggpdqcekgk', 'zwqadogmpjmmxijf', 'uilzxjythsqhwndh', 'gtssqejjknzkkpvw', 'wrggegukhhatygfi', 'vhtcgqzerxonhsye', 'tedlwzdjfppbmtdx', 'iuvrelxiapllaxbg', 'feybgiimfthtplui', 'qxmmcnirvkzfrjwd', 'vfarmlti...
""" Time Complexity = O(log(N)) Space Complexity = O(1) Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is return...
""" Time Complexity = O(log(N)) Space Complexity = O(1) Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is return...
minha_matriz1 = [[1], [2], [3]] minha_matriz2 = [[1, 2, 3], [4, 5, 6]] def imprime_matriz(matriz): for i in matriz: linha = '' for j in i: linha += str(j) print(" ".join(linha), end="") print() # imprime_matriz(minha_matriz1) # imprime_matriz(minha_matriz2)
minha_matriz1 = [[1], [2], [3]] minha_matriz2 = [[1, 2, 3], [4, 5, 6]] def imprime_matriz(matriz): for i in matriz: linha = '' for j in i: linha += str(j) print(' '.join(linha), end='') print()
def get_column(game, col_num): ''' Get the columns ''' col = col_num result = [] for i in range(0, 3): temp = game[i] result.append(temp[col]) return result def print_odd_cubes_to_number(number): ''' Print odds and their cubes ''' if number < 1: print('ER...
def get_column(game, col_num): """ Get the columns """ col = col_num result = [] for i in range(0, 3): temp = game[i] result.append(temp[col]) return result def print_odd_cubes_to_number(number): """ Print odds and their cubes """ if number < 1: print('ERROR: number ...
class Transformer(object): mappings = {} value_mappings_functions = {} def __init__(self, initial_data): self.initial_data = initial_data def transform_dict(self, obj: dict): result = {} for k, v in obj.items(): if k in self.mappings.keys(): if k in ...
class Transformer(object): mappings = {} value_mappings_functions = {} def __init__(self, initial_data): self.initial_data = initial_data def transform_dict(self, obj: dict): result = {} for (k, v) in obj.items(): if k in self.mappings.keys(): if k i...
# Main driver file for user input and displaying # Also checks legal moves and keep a move log class GameState(): def __init__(self): # Initial board state # Board is 8x8 2d list with each element having 2 characters # First character represents the color: w = white & b = black # Se...
class Gamestate: def __init__(self): self.board = [['bR', 'bN', 'bB', 'bQ', 'bK', 'bB', 'bN', 'bR'], ['bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp'], ['--', '--', '--', '--', '--', '--', '--', '--'], ['--', '--', '--', '--', '--', '--', '--', '--'], ['--', '--', '--', '--', '--', '--', '--', '--'], ['--',...