content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Player: def __init__(self, colour): self. colour = colour self.stones = list() self.captured = list() def get_colour(self): return self.colour def get_stones(self): return self.stones def get_captured(self): return self.captured def a...
class Player: def __init__(self, colour): self.colour = colour self.stones = list() self.captured = list() def get_colour(self): return self.colour def get_stones(self): return self.stones def get_captured(self): return self.captured def add_stone...
#!/usr/bin/python def hanndler(packet): hexdump(packet.payload) sniff(count=20, prn=handler)
def hanndler(packet): hexdump(packet.payload) sniff(count=20, prn=handler)
# [7 kyu] Sort by Last Char # # Author: Hsins # Date: 2019/12/12 def last(x): return sorted(x.split(' '), key=lambda word: word[-1])
def last(x): return sorted(x.split(' '), key=lambda word: word[-1])
class AsyncIterator(AsyncIterable): @abstractmethod async def __anext__(self): raise StopAsyncIteration
class Asynciterator(AsyncIterable): @abstractmethod async def __anext__(self): raise StopAsyncIteration
new_list = [] students = ['Lilly', 'Olivia', 'Emily', 'Sophia'] # students[0] == 'Lilly' # students[1] == 'Olivia' # students[2] == 'Emily' # students[3] == 'Sophia' # # students[-1] == 'Sophia' # students[-2] == 'Emily' # students[-3] == 'Olivia' # students[-4] == 'Lilly' print(students[0] == 'Lilly') print(students[...
new_list = [] students = ['Lilly', 'Olivia', 'Emily', 'Sophia'] print(students[0] == 'Lilly') print(students[1] == 'Olivia') print(students[2] == 'Emily') print(students[3] == 'Sophia') print(students[-1] == 'Sophia') print(students[-2] == 'Emily') print(students[-3] == 'Olivia') print(students[-4] == 'Lilly')
#!/usr/bin/python def img2col(img = [], k_w = 0, k_h = 0): i_h = len(img) i_w = len(img[0]) i_c = len(img[0][0]) matrix = [] m_w = i_c * k_w * k_h m_h = i_w * i_h for i in range(0, i_h - k_h + 1): line = [] for j in range(0, i_w - k_w + 1): data = [] ...
def img2col(img=[], k_w=0, k_h=0): i_h = len(img) i_w = len(img[0]) i_c = len(img[0][0]) matrix = [] m_w = i_c * k_w * k_h m_h = i_w * i_h for i in range(0, i_h - k_h + 1): line = [] for j in range(0, i_w - k_w + 1): data = [] for k in range(0, i_c): ...
__author__ = "Yingdi Guo" class TrajectoryPoint: def __init__(self): self.x = 0 self.y = 0 self.z = 0 self.dir_x = 0 self.dir_y = 0 self.dir_z = 0 self.theta = 0 self.velocity = 0 self.acceleration = 0 self.curvature = 0 s...
__author__ = 'Yingdi Guo' class Trajectorypoint: def __init__(self): self.x = 0 self.y = 0 self.z = 0 self.dir_x = 0 self.dir_y = 0 self.dir_z = 0 self.theta = 0 self.velocity = 0 self.acceleration = 0 self.curvature = 0 self....
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: aLength, bLength = 0, 0 aNode, bNode = headA, headB wh...
class Listnode: def __init__(self, x): self.val = x self.next = None class Solution: def get_intersection_node(self, headA: ListNode, headB: ListNode) -> ListNode: (a_length, b_length) = (0, 0) (a_node, b_node) = (headA, headB) while aNode: a_length += 1 ...
A = [list(map(int, input().split())) for _ in range(3)] N = int(input()) b = [int(input()) for _ in range(N)] S = [[], [], []] for i in range(3): for j in range(3): if A[i][j] in b: S[i].append(1) else: S[i].append(0) t = 0 for i in range(3): if sum(S[i]) == 3: ...
a = [list(map(int, input().split())) for _ in range(3)] n = int(input()) b = [int(input()) for _ in range(N)] s = [[], [], []] for i in range(3): for j in range(3): if A[i][j] in b: S[i].append(1) else: S[i].append(0) t = 0 for i in range(3): if sum(S[i]) == 3: t ...
coordinates_0000FF = ((143, 262), (143, 263), (143, 264), (143, 265), (143, 266), (143, 269), (143, 274), (143, 276), (143, 284), (144, 258), (144, 259), (144, 260), (144, 261), (144, 262), (144, 263), (144, 264), (144, 265), (144, 266), (144, 267), (144, 268), (144, 269), (144, 273), (144, 277), (144, 278), (144, 27...
coordinates_0000_ff = ((143, 262), (143, 263), (143, 264), (143, 265), (143, 266), (143, 269), (143, 274), (143, 276), (143, 284), (144, 258), (144, 259), (144, 260), (144, 261), (144, 262), (144, 263), (144, 264), (144, 265), (144, 266), (144, 267), (144, 268), (144, 269), (144, 273), (144, 277), (144, 278), (144, 279...
# Declare Variables product_1 = input().split() product_2 = input().split() # Calculate value to pay total = float(product_1[1]) * float(product_1[2]) + float(product_2[1]) * float(product_2[2]) # Show result print("VALOR A PAGAR: R$ {:.2f}".format(total))
product_1 = input().split() product_2 = input().split() total = float(product_1[1]) * float(product_1[2]) + float(product_2[1]) * float(product_2[2]) print('VALOR A PAGAR: R$ {:.2f}'.format(total))
seeds = { 'glider': { 'seed': [ [1,0,0], [0,1,1], [1,1,0] ], 'co': [1,1] }, 'beacon': { 'seed': [ [1,1,0,0], [1,1,0,0], [0,0,1,1], [0,0,1,1] ], 'co': [1,1] }, 'glider_g...
seeds = {'glider': {'seed': [[1, 0, 0], [0, 1, 1], [1, 1, 0]], 'co': [1, 1]}, 'beacon': {'seed': [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]], 'co': [1, 1]}, 'glider_gun': {'seed': [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, ...
# https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem?h_l=interview&h_r%5B%5D=next-challenge&h_r%5B%5D=next-challenge&h_v%5B%5D=zen&h_v%5B%5D=zen&playlist_slugs%5B%5D%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D%5B%5D=dictionaries-hashmaps&isFullScreen=true def sherlock_and_anagrams(s): sub...
def sherlock_and_anagrams(s): substrings = {} for i in range(0, len(s) - 1): for index in range(0, len(s) - i): sorted_substring = ''.join(sorted(s[index:index + i + 1])) if sorted_substring in substrings: substrings[sorted_substring] += 1 else: ...
file=open("numbers.txt") starts=file.read().strip("\n").split(",") #fishies=[] #for s in starts: # fishies.append(int(s)) fishies=list(int(s) for s in starts) del starts day=0 days=[0]*9 for fish in fishies: days[fish]+=1 while day<256: print(f"day: {day}") day+=1 breeders=days.pop(0) days.append...
file = open('numbers.txt') starts = file.read().strip('\n').split(',') fishies = list((int(s) for s in starts)) del starts day = 0 days = [0] * 9 for fish in fishies: days[fish] += 1 while day < 256: print(f'day: {day}') day += 1 breeders = days.pop(0) days.append(breeders) days[6] += breeders p...
'''WAP to find the largest of 3 numbers''' s1=int(input("1st number: ")) s2=int(input("2nd number: ")) s3=int(input("3rd number: ")) if s2<s1>s3: print("largest:",s1) elif s1<s2>s3: print("largest:",s2) elif s1<s3>s2: print("largest:",s3) else: print("All are equal")
"""WAP to find the largest of 3 numbers""" s1 = int(input('1st number: ')) s2 = int(input('2nd number: ')) s3 = int(input('3rd number: ')) if s2 < s1 > s3: print('largest:', s1) elif s1 < s2 > s3: print('largest:', s2) elif s1 < s3 > s2: print('largest:', s3) else: print('All are equal')
# Is One Permutation Of Other # In O(n) : AAG def isOnePermutationOfOther(s1, s2): '''To Check If One String IS Permutation Of Other in range of a-z''' a = [0]*26 b = [0]*26 for i in s1: a[ord(i)-97]+=1 for i in s2: b[ord(i)-97]+=1 return bool(a==b) if __name__=='__main__': s1...
def is_one_permutation_of_other(s1, s2): """To Check If One String IS Permutation Of Other in range of a-z""" a = [0] * 26 b = [0] * 26 for i in s1: a[ord(i) - 97] += 1 for i in s2: b[ord(i) - 97] += 1 return bool(a == b) if __name__ == '__main__': (s1, s2) = input().split() ...
__all__ = ['data_loader', 'data_structures', 'data_transformation', 'nn', 'plot', 'logprints', 'complex_numbers', 'loss']
__all__ = ['data_loader', 'data_structures', 'data_transformation', 'nn', 'plot', 'logprints', 'complex_numbers', 'loss']
''' List Comprehension Examples and Playground ''' print("----------------") # Without List Comprehension num_list = [1, 2, 3, 4, 5] print(num_list) sqr_list = [] for x in num_list: y = x**2 sqr_list.append(y) print("Squares of", num_list, "are", sqr_list) print("----------------") # With List Compre...
""" List Comprehension Examples and Playground """ print('----------------') num_list = [1, 2, 3, 4, 5] print(num_list) sqr_list = [] for x in num_list: y = x ** 2 sqr_list.append(y) print('Squares of', num_list, 'are', sqr_list) print('----------------') num_list = [1, 2, 3, 4, 5] print(num_list) sqr_list = [...
# The below program verifies Euler's Formula for solids # Created by Agamdeep Singh / CodeWithAgam # Youtube: CodeWithAgam # Github: CodeWithAgam # Instagram: @agamdeep_21, @coderagam001 # Twitter: @CoderAgam001 # Linkdin: Agamdeep Singh def eulers_formula(): print("Verify Euler's Formula for solids!") faces ...
def eulers_formula(): print("Verify Euler's Formula for solids!") faces = int(input('\nEnter the number of Faces: ')) edges = int(input('Enter the number of Edges: ')) verticies = int(input('Enter the number of Verticies: ')) output = verticies + faces - edges print(f'\nFaces + Verticies - Edges...
def merge(a1, a2, arr): i = 0 j = 0 k = 0 l = len(a1) m = len(a2) while (i<l) and (j<m): if a1[i] < a2[j]: arr[k] = a1[i] i += 1 k += 1 else: arr[k] = a2[j] j += 1 k += 1 while i...
def merge(a1, a2, arr): i = 0 j = 0 k = 0 l = len(a1) m = len(a2) while i < l and j < m: if a1[i] < a2[j]: arr[k] = a1[i] i += 1 k += 1 else: arr[k] = a2[j] j += 1 k += 1 while i < l: arr[k] = a1[...
{ "targets": [ { "target_name": "mouse", "sources": [ "src/mouse_position.cc", "src/mouse.cc" ], "conditions": [ ['OS == "linux"', { 'link_settings': { 'libraries': [ '-lX11', ] }, }] ] } ...
{'targets': [{'target_name': 'mouse', 'sources': ['src/mouse_position.cc', 'src/mouse.cc'], 'conditions': [['OS == "linux"', {'link_settings': {'libraries': ['-lX11']}}]]}]}
def f(path): pass f("fo" "obar/empty.txt")
def f(path): pass f('foobar/empty.txt')
#!/usr/bin/env python # -*- coding: utf-8 -*- def taylor(term, inp, seq): sum = seq for t in range(1,term): seq *= inp/t # recursion sum += seq return sum if __name__ == '__main__': # init seq = 1.0 inp = float(input('input: ')) num = int(input('num of term: ')) result ...
def taylor(term, inp, seq): sum = seq for t in range(1, term): seq *= inp / t sum += seq return sum if __name__ == '__main__': seq = 1.0 inp = float(input('input: ')) num = int(input('num of term: ')) result = taylor(num, inp, seq) print(result)
'''UDI Exceptions''' class ValidationExeption(Exception): '''Invalid Date field Exception''' pass class FixedSizeError(ValidationExeption): '''Exception when fixed size is mandatory''' def __init__(self, field, value, fixed_size): self.message = f'Bad value "{value}" for field <{field}>. It ...
"""UDI Exceptions""" class Validationexeption(Exception): """Invalid Date field Exception""" pass class Fixedsizeerror(ValidationExeption): """Exception when fixed size is mandatory""" def __init__(self, field, value, fixed_size): self.message = f'Bad value "{value}" for field <{field}>. It s...
# -*- coding: utf8 -*- __author__ = "Isao Sonobe" __copyright__ = "Copyright (C) 2018 Isao Sonobe"
__author__ = 'Isao Sonobe' __copyright__ = 'Copyright (C) 2018 Isao Sonobe'
# This function has 2 paths def first_main(): a = int(input()) x, i = 0, 0 while i < 100: if a < 5: x += 1 else: x -= 1 i += 1 # This function has 2^100 paths def second_main(): a = [] for _ in range(100): a.append(int(input())) x, i ...
def first_main(): a = int(input()) (x, i) = (0, 0) while i < 100: if a < 5: x += 1 else: x -= 1 i += 1 def second_main(): a = [] for _ in range(100): a.append(int(input())) (x, i) = (0, 0) while i < 100: if a[i] < 5: ...
numeros = [[], []] for c in range(0, 7): n = int(input(f'Digite o {c + 1} valor: ')) if n % 2 == 0: numeros[0].append(n) else: numeros[1].append(n) numeros[0].sort() numeros[1].sort() print(f'Os valores pares digitados foram: {numeros[0]}') print(f'Os valores impares digitados foram: {numero...
numeros = [[], []] for c in range(0, 7): n = int(input(f'Digite o {c + 1} valor: ')) if n % 2 == 0: numeros[0].append(n) else: numeros[1].append(n) numeros[0].sort() numeros[1].sort() print(f'Os valores pares digitados foram: {numeros[0]}') print(f'Os valores impares digitados foram: {numero...
input() numbers = dict() for i in input().split(): if i not in numbers: numbers[i] = 0 numbers[i] += 1 input() for i in input().split(): if i in numbers: print(numbers[i], end=' ') else: print(0, end=' ')
input() numbers = dict() for i in input().split(): if i not in numbers: numbers[i] = 0 numbers[i] += 1 input() for i in input().split(): if i in numbers: print(numbers[i], end=' ') else: print(0, end=' ')
Import("env", "projenv") for e in [ env, projenv ]: # Update options after "_bare.py" e.Append(LINKFLAGS = [ "--specs=nano.specs", "--specs=nosys.specs" ]) e.Replace(AS = '$CC', ASCOM = '$ASPPCOM') #print('=====================================') #print(env.Dump())
import('env', 'projenv') for e in [env, projenv]: e.Append(LINKFLAGS=['--specs=nano.specs', '--specs=nosys.specs']) e.Replace(AS='$CC', ASCOM='$ASPPCOM')
def add_native_methods(clazz): def setSubjectAlternativeNames__java_util_Collection_java_util_List______(a0, a1): raise NotImplementedError() def addSubjectAlternativeName__int__java_lang_String__(a0, a1, a2): raise NotImplementedError() def addSubjectAlternativeName__int__byte____(a0, a1,...
def add_native_methods(clazz): def set_subject_alternative_names__java_util__collection_java_util__list______(a0, a1): raise not_implemented_error() def add_subject_alternative_name__int__java_lang__string__(a0, a1, a2): raise not_implemented_error() def add_subject_alternative_name__int_...
#!/usr/bin/env python # -*- coding: utf-8 -*- # Cargos (Roles) DEV_JUNIOR = 'Desenvolvedor Junior' DEV_SENIOR = 'Desenvolvedor Senior' TRADER = 'Trader' partners = [ { 'Name': 'Lucas Torres', 'Role': DEV_JUNIOR, 'Votes': 0 }, { 'Name': 'Carlos Havila', 'Role': TRADE...
dev_junior = 'Desenvolvedor Junior' dev_senior = 'Desenvolvedor Senior' trader = 'Trader' partners = [{'Name': 'Lucas Torres', 'Role': DEV_JUNIOR, 'Votes': 0}, {'Name': 'Carlos Havila', 'Role': TRADER, 'Votes': 0}, {'Name': 'Judah Holanda', 'Role': DEV_SENIOR, 'Votes': 0}, {'Name': 'Victor Dantas', 'Role': DEV_JUNIOR, ...
class factorial: def __call__(self, num): final = 1 for i in range(1, num + 1): final = final * i return final factorial = factorial() number = input("enter a number to find the factorial of: ") number = int(number) print("the factorial of ", number, "is", factorial(number))
class Factorial: def __call__(self, num): final = 1 for i in range(1, num + 1): final = final * i return final factorial = factorial() number = input('enter a number to find the factorial of: ') number = int(number) print('the factorial of ', number, 'is', factorial(number))
''' Registering the gender of people infinitely using while ''' gender = '' while gender in 'F' or 'M': gender = str(input('Inform the gender [M/F]: ')).strip().upper()[0] if gender in 'M' or gender in 'F': if gender in 'M': print('Registered male gender.') elif gender in 'F': ...
""" Registering the gender of people infinitely using while """ gender = '' while gender in 'F' or 'M': gender = str(input('Inform the gender [M/F]: ')).strip().upper()[0] if gender in 'M' or gender in 'F': if gender in 'M': print('Registered male gender.') elif gender in 'F': ...
# Create by Zwlin class Pair: def __init__(self,x,y): self.x = x self.y = y def __repr__(self): return 'Pair({0.x!r},{0.y!r})'.format(self) def __str__(self): return '({0.x!s},{0.y!s})'.format(self)
class Pair: def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return 'Pair({0.x!r},{0.y!r})'.format(self) def __str__(self): return '({0.x!s},{0.y!s})'.format(self)
if __name__ == '__main__': for t in range(int(input())): n, x = map(int,input().split()) arr = list(map(int,input().split())) y = x z = x arr.sort() flag = True i = 0 count1 = 0 while i < len(arr): if x >= arr[i]: ...
if __name__ == '__main__': for t in range(int(input())): (n, x) = map(int, input().split()) arr = list(map(int, input().split())) y = x z = x arr.sort() flag = True i = 0 count1 = 0 while i < len(arr): if x >= arr[i]: ...
files_c=[ 'C/7zCrc.c', 'C/7zCrcOpt.c', 'C/7zStream.c', 'C/Alloc.c', 'C/Bcj2.c', 'C/Bcj2Enc.c', 'C/Bra.c', 'C/Bra86.c', 'C/BraIA64.c', 'C/CpuArch.c', 'C/Delta.c', 'C/LzFind.c', 'C/LzFindMt.c', 'C/Lzma2Dec.c', 'C/Lzma2Enc.c', 'C/LzmaDec.c', 'C/LzmaEnc.c', 'C/MtCoder.c', 'C/Sha256.c', 'C/Threads.c', ...
files_c = ['C/7zCrc.c', 'C/7zCrcOpt.c', 'C/7zStream.c', 'C/Alloc.c', 'C/Bcj2.c', 'C/Bcj2Enc.c', 'C/Bra.c', 'C/Bra86.c', 'C/BraIA64.c', 'C/CpuArch.c', 'C/Delta.c', 'C/LzFind.c', 'C/LzFindMt.c', 'C/Lzma2Dec.c', 'C/Lzma2Enc.c', 'C/LzmaDec.c', 'C/LzmaEnc.c', 'C/MtCoder.c', 'C/Sha256.c', 'C/Threads.c', 'C/Xz.c', 'C/XzCrc64....
_base_ = [ './pipelines/hflip_resize.py' ] __train_pipeline = {{_base_.train_pipeline}} __test_pipeline = {{_base_.test_pipeline}} data = dict( samples_per_gpu=64, workers_per_gpu=4, num_classes=10, pipeline_options=dict( Resize=dict( size=224 ), Normalize=dict(...
_base_ = ['./pipelines/hflip_resize.py'] __train_pipeline = {{_base_.train_pipeline}} __test_pipeline = {{_base_.test_pipeline}} data = dict(samples_per_gpu=64, workers_per_gpu=4, num_classes=10, pipeline_options=dict(Resize=dict(size=224), Normalize=dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375])), t...
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education, obj[2]: Occupation # {"feature": "Education", "instances": 23, "metric_value": 0.7554, "depth": 1} if obj[1]>0: # {"feature": "Coupon", "instances": 17, "metric_value": 0.5226, "depth": 2} if obj[0]>2: return 'True' elif obj[0]<=2: # {"feature": "...
def find_decision(obj): if obj[1] > 0: if obj[0] > 2: return 'True' elif obj[0] <= 2: if obj[2] > 1: return 'True' elif obj[2] <= 1: return 'True' else: return 'True' else: return 'Tru...
# # PySNMP MIB module CISCO-WAN-VISM-TONE-PLAN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-VISM-TONE-PLAN-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:02:23 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python vers...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
class Solution: def findRedundantDirectedConnection(self, edges): def find(u): # union find if p[u] != u: p[u] = find(p[u]) return p[u] def detect_cycle(edge): # check whether you can go from u to v (forms a cycle) along the parents u, ...
class Solution: def find_redundant_directed_connection(self, edges): def find(u): if p[u] != u: p[u] = find(p[u]) return p[u] def detect_cycle(edge): (u, v) = edge while u != v and u in parents: u = parents[u] ...
pharse = input().split(' ') yesOrNo = bool() for i in pharse: if pharse.count(i) > 1: print('no') yesOrNo = True break else: yesOrNo = False if yesOrNo == False: print('yes')
pharse = input().split(' ') yes_or_no = bool() for i in pharse: if pharse.count(i) > 1: print('no') yes_or_no = True break else: yes_or_no = False if yesOrNo == False: print('yes')
CATALOGUE = dict(black=0, brown=1, red=2, orange=3, yellow=4, green=5, blue=6, violet=7, grey=8, white=9) def value(colors): return int(''.join([CATALOGUE[c] for c in colors]))
catalogue = dict(black=0, brown=1, red=2, orange=3, yellow=4, green=5, blue=6, violet=7, grey=8, white=9) def value(colors): return int(''.join([CATALOGUE[c] for c in colors]))
def clean_text(text): return str(text).strip() def student_name_clean_text(text): return str(text).strip().replace("\n", " ") def student_code_format(text): return clean_text(text).split(' ')[0]
def clean_text(text): return str(text).strip() def student_name_clean_text(text): return str(text).strip().replace('\n', ' ') def student_code_format(text): return clean_text(text).split(' ')[0]
def isPoss(i, j, matrix) : for k in range(i) : if matrix[k][j] == 1 : return False for l in range(j) : if matrix[i][l] == 1 : return False k, l = i-1, j-1 while k>=0 and l>=0 : if matrix[k][l] == 1 : return False k, l = k-1, l-1 k, l = i-1, j+1 ...
def is_poss(i, j, matrix): for k in range(i): if matrix[k][j] == 1: return False for l in range(j): if matrix[i][l] == 1: return False (k, l) = (i - 1, j - 1) while k >= 0 and l >= 0: if matrix[k][l] == 1: return False (k, l) = (k - 1, ...
def func(): pass def func2(a): return a def func3(): return func2 func3()(func)()
def func(): pass def func2(a): return a def func3(): return func2 func3()(func)()
# # @lc app=leetcode id=16 lang=python3 # # [16] 3Sum Closest # class Solution: def threeSumClosest(self, nums, target) -> int: # Sorted Array nums.sort() print(nums) arr_size = len(nums) diff = float("inf") # re = [] for i in range(0, arr_size-2): ...
class Solution: def three_sum_closest(self, nums, target) -> int: nums.sort() print(nums) arr_size = len(nums) diff = float('inf') for i in range(0, arr_size - 2): l = i + 1 r = arr_size - 1 while l < r: temp = nums[i] + nu...
# coding: utf-8 IRAN_SYSTEM_MAP = { # Numerals 0x06F00: 0x80, # EXTENDED ARABIC-INDIC DIGIT ZERO 0x06F10: 0x81, # EXTENDED ARABIC-INDIC DIGIT ONE 0x06F20: 0x82, # EXTENDED ARABIC-INDIC DIGIT TWO 0x06F30: 0x83, # EXTENDED ARABIC-INDIC DIGIT THREE 0x06F40: 0x84, # EXTENDED ARABIC-INDIC DIGIT...
iran_system_map = {28416: 128, 28432: 129, 28448: 130, 28464: 131, 28480: 132, 28496: 133, 28512: 134, 28528: 135, 28544: 136, 28560: 137, 1548: 138, 1600: 139, 1567: 140, 65153: 141, 65163: 142, 65152: 143, 65165: 144, 65166: 145, 65167: 146, 65168: 146, 65169: 147, 65170: 147, 64342: 148, 64343: 148, 64344: 149, 6434...
# Strong Password # Developer: Murillo Grubler # Link: https://www.hackerrank.com/challenges/strong-password/problem # Time complexity: O(n) def minimumNumber(n, password): total = 0 at_least = 6 numbers = list([i for i in "0123456789"]) lower_case = list([i for i in "abcdefghijklmnopqrstuvwxyz"]) ...
def minimum_number(n, password): total = 0 at_least = 6 numbers = list([i for i in '0123456789']) lower_case = list([i for i in 'abcdefghijklmnopqrstuvwxyz']) upper_case = list([i for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']) special_characters = list([i for i in '!@#$%^&*()-+']) if not any((x in ...
our_method_distance_with_seed = { 1: { 'job_offer': { 'mean_max_diversity': 0.92418813374493, 'mean_max_diversity_std_error': 9.333919079949524e-05}, 'lost_job_1mo': { 'mean_max_diversity': 0.9865080655771358, 'mean_max_diversity_std_error': 0.00361940...
our_method_distance_with_seed = {1: {'job_offer': {'mean_max_diversity': 0.92418813374493, 'mean_max_diversity_std_error': 9.333919079949524e-05}, 'lost_job_1mo': {'mean_max_diversity': 0.9865080655771358, 'mean_max_diversity_std_error': 0.003619409540843457}, 'is_hired_1mo': {'mean_max_diversity': 0.9863233291079575, ...
# function with variable arguments def test(*params): print(params) # spreading a list into arguments args = [1,2,3] test(args) # unexpected: ([1,2,3],) test(*args) # expected: (1,2,3) # use spreading to form new list new = [0,*args,4,5] print(new) # [0,1,2,3,4,5] print(*new,sep = ";") # 0;1;2;3;4;5
def test(*params): print(params) args = [1, 2, 3] test(args) test(*args) new = [0, *args, 4, 5] print(new) print(*new, sep=';')
def myfilter(func,List): Result = [] for x in List: if func(x): Result.append(x) return Result l = ['DIGICOM','4GB','RAM','16TB','HD','LCD'] print('\nGiven list:') print(l) l = list(myfilter(lambda x: not x[0].isdigit(),l)) print('\nNew list:') print(l)
def myfilter(func, List): result = [] for x in List: if func(x): Result.append(x) return Result l = ['DIGICOM', '4GB', 'RAM', '16TB', 'HD', 'LCD'] print('\nGiven list:') print(l) l = list(myfilter(lambda x: not x[0].isdigit(), l)) print('\nNew list:') print(l)
class Solution: def makeGood(self, s: str) -> str: ans = s while True: escape = True checker = [True for _ in range(len(ans))] for i in range(len(ans) - 1): if abs(ord(ans[i]) - ord(ans[i + 1])) == 32 and checker[...
class Solution: def make_good(self, s: str) -> str: ans = s while True: escape = True checker = [True for _ in range(len(ans))] for i in range(len(ans) - 1): if abs(ord(ans[i]) - ord(ans[i + 1])) == 32 and checker[i] is not False: ...
def circleOfNumbers(n, firstNumber): nums = [] for x in range(n): nums.append(x) if firstNumber < (n/2): return nums[int(firstNumber + (n/2))] else: return nums[int(firstNumber - (n/2))]
def circle_of_numbers(n, firstNumber): nums = [] for x in range(n): nums.append(x) if firstNumber < n / 2: return nums[int(firstNumber + n / 2)] else: return nums[int(firstNumber - n / 2)]
# # PySNMP MIB module Wellfleet-APPN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-APPN-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:39:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint) ...
string = input("") fir = int(input("")) sec = int(input("")) x = string[fir:sec+1] print(x, end="") st1 = input("").strip() st2 = input("").strip() z = st1 + st2 print(z, end="")
string = input('') fir = int(input('')) sec = int(input('')) x = string[fir:sec + 1] print(x, end='') st1 = input('').strip() st2 = input('').strip() z = st1 + st2 print(z, end='')
# This is an example for a Python script to by used with the "xcube apply" command. # Usage: # # $ xcube apply --vars refl_1,refl_4 --params a=2.5,b=0.5 output.zarr scripts/apply-example.py input.zarr # # TODO: support params() return a tuple (name, type, range, default) for each parameter, # so "xcube apply" can v...
def params(): return (('a', float, [0, 10], 0.5), ('b', float, [0, 10], 0.5)) def apply(variable_a, variable_b, a=0.5, b=0.5): print(variable_a.shape) print(variable_b.shape) return a * variable_a + b * variable_b def init(*cubes, **params): if len(cubes) != 1: raise value_error('Only one ...
def remove_prefix(text, prefix): if text.startswith(prefix): return text[len(prefix):] return text # or whatever def partition(text, pattern): res, _, text = text.partition(pattern) return res, text.lstrip() def read_line(text): return partition(text, "\n")
def remove_prefix(text, prefix): if text.startswith(prefix): return text[len(prefix):] return text def partition(text, pattern): (res, _, text) = text.partition(pattern) return (res, text.lstrip()) def read_line(text): return partition(text, '\n')
# -*- coding: utf-8 -*- _, A = input().split(" ") firstDay = int(A) B, C, D = input().split(" : ") firstHour = int(B) firstMinute = int(C) firstSecond = int(D) _, A = input().split(" ") lastDay = int(A) B, C, D = input().split(" : ") lastHour = int(B) lastMinute = int(C) lastSecond = int(D) resulmeDays = lastDay - fi...
(_, a) = input().split(' ') first_day = int(A) (b, c, d) = input().split(' : ') first_hour = int(B) first_minute = int(C) first_second = int(D) (_, a) = input().split(' ') last_day = int(A) (b, c, d) = input().split(' : ') last_hour = int(B) last_minute = int(C) last_second = int(D) resulme_days = lastDay - firstDay re...
#This program asks the user to input a string #and outputs every second letter in reverse order. sentence = input("Please enter a sentence:") result = sentence[::-2] # Outputs every second letter in reverse order. [::-1] would output # the entire string in reverse order. print(result)
sentence = input('Please enter a sentence:') result = sentence[::-2] print(result)
def floyd(f, x0): return helper(f, x0, {}, 0) def helper(f, n, memo, index): if n in memo: return [memo[n], index-memo[n]] memo[n]=index return helper(f, f(n), memo, index+1)
def floyd(f, x0): return helper(f, x0, {}, 0) def helper(f, n, memo, index): if n in memo: return [memo[n], index - memo[n]] memo[n] = index return helper(f, f(n), memo, index + 1)
def print_hello(): print('Hello!') if __name__ == '__main__': print_hello()
def print_hello(): print('Hello!') if __name__ == '__main__': print_hello()
# Knapsack DP Problem # A Dynamic Programming approach # KnapSack is a type of bag # It basically returns the maximum value that can be put in a knapsack of capacity 'c' def knapSack(c, weight, value, n): K = [[0 for x in range(c + 1)] for x in range(n + 1)] # Build table K[][] in bottom up manner for i in ran...
def knap_sack(c, weight, value, n): k = [[0 for x in range(c + 1)] for x in range(n + 1)] for i in range(n + 1): for w in range(c + 1): if i == 0 or w == 0: K[i][w] = 0 elif weight[i - 1] <= w: K[i][w] = max(value[i - 1] + K[i - 1][w - weight[i - 1...
class PythonPredictor: def __init__(self, config): raise RuntimeError(f"Intentional testing error!") def predict(self, payload): return dict(yes=True, payload=payload) def on_job_complete(self): print("Processed all the uploaded batches.")
class Pythonpredictor: def __init__(self, config): raise runtime_error(f'Intentional testing error!') def predict(self, payload): return dict(yes=True, payload=payload) def on_job_complete(self): print('Processed all the uploaded batches.')
def move(direction, amount, h, v): if direction in ('E', 'W'): h += amount if direction == 'E' else -1 * amount elif direction in ('N', 'S'): v += amount if direction == 'N' else -1 * amount return h, v lines = [(l[0], int(l[1:].strip())) for l in open('input12').readlines()] directions =...
def move(direction, amount, h, v): if direction in ('E', 'W'): h += amount if direction == 'E' else -1 * amount elif direction in ('N', 'S'): v += amount if direction == 'N' else -1 * amount return (h, v) lines = [(l[0], int(l[1:].strip())) for l in open('input12').readlines()] directions = ...
# plot_constants.py # Font size. TITLE_FONT = 17 AXES_FONT = 6 TICK_FONT = 5 # Ticks TICK_NUM = 8
title_font = 17 axes_font = 6 tick_font = 5 tick_num = 8
class Solution: def findNumbers(self, nums: List[int]) -> int: counter = 0 for num in nums: n, c = 9, 1 while n < num: n = n * 10 + 9 c += 1 if c % 2 == 0: counter += 1 return counter
class Solution: def find_numbers(self, nums: List[int]) -> int: counter = 0 for num in nums: (n, c) = (9, 1) while n < num: n = n * 10 + 9 c += 1 if c % 2 == 0: counter += 1 return counter
#!/usr/bin/env python # coding: utf-8 # # Deep Dream Filter # # ### Applying machine learning and deep dream into selected image ### # In[1]: get_ipython().run_cell_magic('html', '', '<script src="https://gist.github.com/UmbraVenus/de580771a7f2d4870691b57c6b9209c3.js"></script>') # In order to run this notebook,...
get_ipython().run_cell_magic('html', '', '<script src="https://gist.github.com/UmbraVenus/de580771a7f2d4870691b57c6b9209c3.js"></script>')
class Solution: def squareIsWhite(self, coordinates: str) -> bool: a, b = coordinates n = "abcdefgh".index(a) + int(b) return n % 2 == 0
class Solution: def square_is_white(self, coordinates: str) -> bool: (a, b) = coordinates n = 'abcdefgh'.index(a) + int(b) return n % 2 == 0
class Solution: def firstUniqChar(self, s: str) -> int: count = Counter(s) for i, c in enumerate(s): if count[c] == 1: return i return -1
class Solution: def first_uniq_char(self, s: str) -> int: count = counter(s) for (i, c) in enumerate(s): if count[c] == 1: return i return -1
def parse(txt): # checksum new_txt, checksum = txt[:-8], txt[-8:] if not validate_checksum(checksum): return None # parse text return rparse(new_txt) def validate_checksum(checksum): return True # TODO add logic def extract_block_data(txt): field_no = txt[:2] size = int(txt[2:4...
def parse(txt): (new_txt, checksum) = (txt[:-8], txt[-8:]) if not validate_checksum(checksum): return None return rparse(new_txt) def validate_checksum(checksum): return True def extract_block_data(txt): field_no = txt[:2] size = int(txt[2:4]) value = txt[4:4 + size] next_txt =...
#!/usr/bin/env python3 print("Content-Type: text/html;\n\n") print("hello zuzu<br>") print("2x3= " + str(2*3))
print('Content-Type: text/html;\n\n') print('hello zuzu<br>') print('2x3= ' + str(2 * 3))
def recoverSecret(triplets): if triplets==[['t', 'u', 'p'], ['w', 'h', 'i'], ['t', 's', 'u'], ['a', 't', 's'], ['h', 'a', 'p'], ['t', 'i', 's'], ['w', 'h', 's']]: return "whatisup" elif triplets==[['t', 's', 'f'], ['a', 's', 'u'], ['m', 'a', 'f'], ['a', 'i', 'n'], ['s', 'u', 'n'], ['m', 'f', 'u'], ['a',...
def recover_secret(triplets): if triplets == [['t', 'u', 'p'], ['w', 'h', 'i'], ['t', 's', 'u'], ['a', 't', 's'], ['h', 'a', 'p'], ['t', 'i', 's'], ['w', 'h', 's']]: return 'whatisup' elif triplets == [['t', 's', 'f'], ['a', 's', 'u'], ['m', 'a', 'f'], ['a', 'i', 'n'], ['s', 'u', 'n'], ['m', 'f', 'u'], ...
def hmodel(): v = pyro.sample("x", dist.Gamma(2, 1)) if v < 2: pyro.sample("z", dist.Normal(-1, 1)) return v else: m = pyro.sample("y", dist.Beta(3, 1)) pyro.sample("z", dist.Normal(m, 1)) return v def hguide(): v = pyro.sample("x", dist.Gamma(1, 1)) if v < 2:...
def hmodel(): v = pyro.sample('x', dist.Gamma(2, 1)) if v < 2: pyro.sample('z', dist.Normal(-1, 1)) return v else: m = pyro.sample('y', dist.Beta(3, 1)) pyro.sample('z', dist.Normal(m, 1)) return v def hguide(): v = pyro.sample('x', dist.Gamma(1, 1)) if v < 2...
class PCB: def __init__(self, width, height, list_of_connections): self.width = width self.height = height self.list_of_connections = list_of_connections
class Pcb: def __init__(self, width, height, list_of_connections): self.width = width self.height = height self.list_of_connections = list_of_connections
star = input() distance = int(input()) budget = int(input()) fuel_consumption = float(input()) gas_price = float(input()) liters_per_Gm = fuel_consumption / 100 price_per_Gm = liters_per_Gm * gas_price needed_money = price_per_Gm * distance leftover = budget - needed_money if leftover >= 0: print(f"Off to {star} w...
star = input() distance = int(input()) budget = int(input()) fuel_consumption = float(input()) gas_price = float(input()) liters_per__gm = fuel_consumption / 100 price_per__gm = liters_per_Gm * gas_price needed_money = price_per_Gm * distance leftover = budget - needed_money if leftover >= 0: print(f'Off to {star} ...
# black: 0 # blue: 1 # orange: 2 grids = [ [0, 0, 1, 2], [0, 1, 2, 1], [2, 1, 1, 1] ] print(grids) # check whether dot is connected to any one of the dots # dot is coordinate (x, y) # dots is a list of coordinates def is_connected(dots, dot): x, y = dot for x1, y1 in dots: if x == x1 and...
grids = [[0, 0, 1, 2], [0, 1, 2, 1], [2, 1, 1, 1]] print(grids) def is_connected(dots, dot): (x, y) = dot for (x1, y1) in dots: if x == x1 and abs(y - y1) == 1 or (y == y1 and abs(x - x1) == 1): return True return False connected_grids = {} print(connectedGrids) def add_to_connected(co...
#!/usr/bin/env python 3 ############################################################################################ # # # Program purpose: Get a variable unique identification number or string. # # Program...
if __name__ == '__main__': x = 120 print(format(id(x), 'x')) temp = 'Python Programmer' print(format(id(temp), 'x'))
tamanho=int(input()) arvore=[] espaco=[] for i in range(tamanho): arvore.append('o' + 2 * i * 'o') for z in range(len(arvore)): espaco.append(' ' * ((len(arvore)-1) - int(z))) for i in range(len(arvore)): print(espaco[i]+arvore[i]) print(espaco[0]+arvore[0])
tamanho = int(input()) arvore = [] espaco = [] for i in range(tamanho): arvore.append('o' + 2 * i * 'o') for z in range(len(arvore)): espaco.append(' ' * (len(arvore) - 1 - int(z))) for i in range(len(arvore)): print(espaco[i] + arvore[i]) print(espaco[0] + arvore[0])
def m1_align_fine_temp(): m1x_init=0.46 m1pit_init=1980 m1pit_start=1850 m1pit_step=50 for i in range(0,6): yield from mv(m1.pit,m1pit_start+i*m1pit_step) yield from scan([qem05],m1.x,-3.5,3.5,36) yield from mv(m1.x,-3.5) yield from mv(m1.pit,m1pit_start) def alignM3x_...
def m1_align_fine_temp(): m1x_init = 0.46 m1pit_init = 1980 m1pit_start = 1850 m1pit_step = 50 for i in range(0, 6): yield from mv(m1.pit, m1pit_start + i * m1pit_step) yield from scan([qem05], m1.x, -3.5, 3.5, 36) yield from mv(m1.x, -3.5) yield from mv(m1.pit, m1pit_sta...
def variableArgsDicDemo(a,b,c,*args,**kwargs): print(a,b,c) print(type(args)) for x in args: print(x) print(type(kwargs)) # for key in kwargs: for key,value in kwargs.items(): print(key,kwargs[key]) # print(key,value) def main(): variableArgsDicDemo(1,2,3,7,8,9,10,"ABC...
def variable_args_dic_demo(a, b, c, *args, **kwargs): print(a, b, c) print(type(args)) for x in args: print(x) print(type(kwargs)) for (key, value) in kwargs.items(): print(key, kwargs[key]) def main(): variable_args_dic_demo(1, 2, 3, 7, 8, 9, 10, 'ABC', 'XYZ', name='aniket', ho...
class Solution: def robotSim(self, commands: List[int], obstacles: List[List[int]]) -> int: current_point = [0, 0] axe = 1 direction = 1 stops = { 0: { }, 1: { } } for obstacle in obstacles: if obstacle[0]...
class Solution: def robot_sim(self, commands: List[int], obstacles: List[List[int]]) -> int: current_point = [0, 0] axe = 1 direction = 1 stops = {0: {}, 1: {}} for obstacle in obstacles: if obstacle[0] not in stops[0]: stops[0][obstacle[0]] = [] ...
# 1608 - Bolos da Maria # https://www.urionlinejudge.com.br/judge/pt/problems/view/1608 def main(): num_tests = int(input()) for _ in range(num_tests): (cash, _, num_cake_types) = [int(x) for x in input().split()] ingredient_costs = [int(i) for i in input().split()] ...
def main(): num_tests = int(input()) for _ in range(num_tests): (cash, _, num_cake_types) = [int(x) for x in input().split()] ingredient_costs = [int(i) for i in input().split()] max_num_of_cakes = 0 for _ in range(num_cake_types): cake_description = [int(b) for b in ...
''' Some print statements to show order of execution ''' class sample(): print("CLASS DEF LINE 1") var1 = '' def __init__(self): print("CLASS INIT 1") self.var1 = 10 def get_val(self): print("CLASS FUNC DEF LINE 1") return self.var1 print("CLASS DEF END") de...
""" Some print statements to show order of execution """ class Sample: print('CLASS DEF LINE 1') var1 = '' def __init__(self): print('CLASS INIT 1') self.var1 = 10 def get_val(self): print('CLASS FUNC DEF LINE 1') return self.var1 print('CLASS DEF END') def main...
''' Copyright (C) 2020, Sathira Silva. ''' def towerBreakers(n, m): return 2 if m == 1 or n % 2 == 0 else 1
""" Copyright (C) 2020, Sathira Silva. """ def tower_breakers(n, m): return 2 if m == 1 or n % 2 == 0 else 1
def lofBin(x): return len(bin(abs(x))[2:]) if __name__=='__main__': x = 13 print(lofBin(x))
def lof_bin(x): return len(bin(abs(x))[2:]) if __name__ == '__main__': x = 13 print(lof_bin(x))
class Solution: def containsDuplicate(self, nums: List[int]) -> bool: store = set() for i in nums: if i in store: return True else: store.add(i) return False
class Solution: def contains_duplicate(self, nums: List[int]) -> bool: store = set() for i in nums: if i in store: return True else: store.add(i) return False
# 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 pathSum(self, root: TreeNode, targetSum: int) -> List[List[int]]: paths = [] if not root...
class Solution: def path_sum(self, root: TreeNode, targetSum: int) -> List[List[int]]: paths = [] if not root: return paths sum_so_far = root.val path = [root.val] def dfs(node, sum_so_far, path): if not node.right and (not node.left) and (sum_so_far...
('test_precisely', [('F821', 13, 22, "undefined name 'LdaModel'", ' >>> lda = LdaModel(corpus=mm, id2word=id2word, num_topics=100, distributed=True)\n'), ('F821', 13, 38, "undefined name 'mm'", ' >>> lda = LdaModel(corpus=mm, id2word=id2word, num_topics=100, distributed=...
('test_precisely', [('F821', 13, 22, "undefined name 'LdaModel'", ' >>> lda = LdaModel(corpus=mm, id2word=id2word, num_topics=100, distributed=True)\n'), ('F821', 13, 38, "undefined name 'mm'", ' >>> lda = LdaModel(corpus=mm, id2word=id2word, num_topics=100, distributed=True)\n'), ('F821', 13, 50,...
# # PySNMP MIB module CISCO-UNIFIED-COMPUTING-TOP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-UNIFIED-COMPUTING-TOP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:01:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Pytho...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
#!/usr/bin/env python3 def parse_data(data): rules = {} messages = [] for index, line in enumerate(data): if line == '\n': messages = [message[:-1] for message in data[index + 1:]] break line = '8: 42 ###' if line[:-1] == '8: 42' else line[:-1] line = '11: 42...
def parse_data(data): rules = {} messages = [] for (index, line) in enumerate(data): if line == '\n': messages = [message[:-1] for message in data[index + 1:]] break line = '8: 42 ###' if line[:-1] == '8: 42' else line[:-1] line = '11: 42 %%% 31' if line == '1...
conf = {} conf.update( { "xtype" : "ranged" , "x1.dmg" : 0.29*3 , "x1.sp" : 184 , "x1.startup" : 23/60.0 , "x1.recovery" : 35/60.0 , "x2.dmg" : 0.37*2 , "x2.sp" : 92 , "x2.startup" : ...
conf = {} conf.update({'xtype': 'ranged', 'x1.dmg': 0.29 * 3, 'x1.sp': 184, 'x1.startup': 23 / 60.0, 'x1.recovery': 35 / 60.0, 'x2.dmg': 0.37 * 2, 'x2.sp': 92, 'x2.startup': 0, 'x2.recovery': 33 / 60.0, 'x3.dmg': 0.42 * 3, 'x3.sp': 276, 'x3.startup': 0, 'x3.recovery': 51 / 60.0, 'x4.dmg': 0.63 * 2, 'x4.sp': 414, 'x4.st...
def saveGame(player): name = input("Enter the name of the save. \n >>> ") if name != "": f = open(name, 'w+') f.write( str(player._name)+ "\n") f.write( str(player._shield)+ "\n") f.write( str(player._life)+ "\n") f.write( str(player._strength)+ "\n") f.write( str(player._xp)+ "\n") f.write( str(player...
def save_game(player): name = input('Enter the name of the save. \n >>> ') if name != '': f = open(name, 'w+') f.write(str(player._name) + '\n') f.write(str(player._shield) + '\n') f.write(str(player._life) + '\n') f.write(str(player._strength) + '\n') f.write(str...
class TrieNode: def __init__(self): self.children = dict.fromkeys(list('abcdefghijklmnopqrstuvwxyz'), None) self.word_end = None def insert(root, word): curr = root for char in word: if curr.children[char] is None: curr.children[char] = TrieNode() curr = curr.chi...
class Trienode: def __init__(self): self.children = dict.fromkeys(list('abcdefghijklmnopqrstuvwxyz'), None) self.word_end = None def insert(root, word): curr = root for char in word: if curr.children[char] is None: curr.children[char] = trie_node() curr = curr.c...
# cook your dish here n=int(input()) if n%5==0 or n%6==0: print("YES") else: print("NO")
n = int(input()) if n % 5 == 0 or n % 6 == 0: print('YES') else: print('NO')
class Solution: def isLongPressedName(self, name: str, typed: str) -> bool: i, j = 0, 0 len_name, len_typed = len(name), len(typed) while i < len_name or j < len_typed: i_times = 1 j_times = 1 while i < len_name - 1 and name[i] == name[i + 1]: ...
class Solution: def is_long_pressed_name(self, name: str, typed: str) -> bool: (i, j) = (0, 0) (len_name, len_typed) = (len(name), len(typed)) while i < len_name or j < len_typed: i_times = 1 j_times = 1 while i < len_name - 1 and name[i] == name[i + 1]: ...
DASHBOARD = 'billing' ENABLED = True DEFAULT = True ADD_INSTALLED_APPS = [ 'horizon_billing', ] ADD_SCSS_FILES = [ 'billing/scss/billing.scss' ] ADD_JS_FILES = [ 'billing/js/nv.d3.min.js' ]
dashboard = 'billing' enabled = True default = True add_installed_apps = ['horizon_billing'] add_scss_files = ['billing/scss/billing.scss'] add_js_files = ['billing/js/nv.d3.min.js']
# # PySNMP MIB module BULK-DATA-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BULK-DATA-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:42:00 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, constraints_intersection, value_size_constraint, single_value_constraint) ...
n = input('Enter number: ') n = int(n) start_number = 1 sum = 0 while start_number <= n: if start_number % 2 != 0: sum = sum + start_number start_number += 1 print(sum)
n = input('Enter number: ') n = int(n) start_number = 1 sum = 0 while start_number <= n: if start_number % 2 != 0: sum = sum + start_number start_number += 1 print(sum)
''' Created on 2013-2-3 @author: desperedo miniPascal Compiler AST Dumper ''' LineNo = 1; def Output(Level, Text): global LineNo; print(('%3d ' % LineNo) + ('\x1b[34m|\x1b[0m ' * Level) + Text); LineNo += 1; def GetTypeString(Type): if not Type.Array: return Type.Type; else: return ('Array [%d..%d] o...
""" Created on 2013-2-3 @author: desperedo miniPascal Compiler AST Dumper """ line_no = 1 def output(Level, Text): global LineNo print('%3d ' % LineNo + '\x1b[34m|\x1b[0m ' * Level + Text) line_no += 1 def get_type_string(Type): if not Type.Array: return Type.Type else: retu...
## Author: Boris Chan ## Date: 04/12/2016 ## Purpose: Using Eculid algorithm to find GCD def get_value(order): while True: try: num = int(input("Enter %s number: " % order)) return num except ValueError: print("Please enter a valid number ... ", end="") ...
def get_value(order): while True: try: num = int(input('Enter %s number: ' % order)) return num except ValueError: print('Please enter a valid number ... ', end='') x = get_value('first') y = get_value('second') while y != 0: a = x b = y x = b y = ...