content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Time: O(n^2) # Space: O(1) class Solution(object): def pancakeSort(self, A): """ :type A: List[int] :rtype: List[int] """ def reverse(l, begin, end): for i in xrange((end-begin) // 2): l[begin+i], l[end-1-i] = l[end-1-i], l[begin+i] re...
class Solution(object): def pancake_sort(self, A): """ :type A: List[int] :rtype: List[int] """ def reverse(l, begin, end): for i in xrange((end - begin) // 2): (l[begin + i], l[end - 1 - i]) = (l[end - 1 - i], l[begin + i]) result = [] ...
class Solution(object): def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ if not (nums1 or nums2): return 0 total_len = len(nums1) + len(nums2) if total_len % 2 == 0: return...
class Solution(object): def find_median_sorted_arrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ if not (nums1 or nums2): return 0 total_len = len(nums1) + len(nums2) if total_len % 2 == 0: ...
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def deleteDuplicates(self, head): if head and head.next: head.next = self.deleteDuplicates(head.next) ...
class Solution(object): def delete_duplicates(self, head): if head and head.next: head.next = self.deleteDuplicates(head.next) return head.next if head.next.val == head.val else head return head
a = True #print(type(a)) b = False #print(type(b)) #print(5>10) #List Type testList = [50,"100",True,50,"50"] print("100" in testList) #print(testList[1]) #print(len(testList)) #print(type(testList)) #Tuple Type testTuple = (50,"100",True,50,"50") #print(testTuple) #print(len(testTuple)) #print(type(testTuple)) testSet...
a = True b = False test_list = [50, '100', True, 50, '50'] print('100' in testList) test_tuple = (50, '100', True, 50, '50') test_set = {50, '100', True, 50, '50', 50, 100, 100, 'a'} test_dic = {'first': 50, 'second': '100', 'third': True, 'a': 50, 'a': 'LAST'} print(testDic) print(len(testDic)) print(type(testDic))
# -*- coding: utf-8 -*- """ Created on Sat Jan 28 22:08:12 2017 @author: mtkes """ def f(x): x = x + 1 print(str(x)) def g(x): x = 2 * x print(str(x)) a = 1 print(str(a)) f(a) g(a) print(str(a))
""" Created on Sat Jan 28 22:08:12 2017 @author: mtkes """ def f(x): x = x + 1 print(str(x)) def g(x): x = 2 * x print(str(x)) a = 1 print(str(a)) f(a) g(a) print(str(a))
pkgname = "rubberband" pkgver = "2.0.0" pkgrel = 0 build_style = "meson" configure_args = [ "-Dfft=fftw", "-Dresampler=libsamplerate", ] hostmakedepends = ["meson", "pkgconf"] # TODO: ladspa-sdk, vamp-sdk makedepends = [ "libsamplerate-devel", "libsndfile-devel", "fftw-devel", ] pkgdesc = "Time-stretching and p...
pkgname = 'rubberband' pkgver = '2.0.0' pkgrel = 0 build_style = 'meson' configure_args = ['-Dfft=fftw', '-Dresampler=libsamplerate'] hostmakedepends = ['meson', 'pkgconf'] makedepends = ['libsamplerate-devel', 'libsndfile-devel', 'fftw-devel'] pkgdesc = 'Time-stretching and pitch-shifting audio library' maintainer = '...
logo = """ ,--, ,--.'| ,---, ,--, ...
logo = '\n\n \n ,--, \n ,--.\'| ,---, ,--, ...
class Solution(object): # Time: O(N), Space: O(1) def validWordAbbreviation(self, word, abbr): """ :type word: str :type abbr: str :rtype: bool """ wordPointer = 0 abbrPointer = 0 while wordPointer < len(word) and abbrPointer < len(abbr): ...
class Solution(object): def valid_word_abbreviation(self, word, abbr): """ :type word: str :type abbr: str :rtype: bool """ word_pointer = 0 abbr_pointer = 0 while wordPointer < len(word) and abbrPointer < len(abbr): if abbr[abbrPointer].i...
LLVM_LINKOPTS = [ "-ldl", "-lz", "-lm", "-lrt", "-lpthread", "-L/usr/local/lib", "-lLLVMLTO", "-lLLVMPasses", "-lLLVMObjCARCOpts", "-lLLVMMIRParser", "-lLLVMSymbolize", "-lLLVMDebugInfoPDB", "-lLLVMDebugInfoDWARF", "-lLLVMCoverage", "-lLLVMMCA", "-lLLVMTab...
llvm_linkopts = ['-ldl', '-lz', '-lm', '-lrt', '-lpthread', '-L/usr/local/lib', '-lLLVMLTO', '-lLLVMPasses', '-lLLVMObjCARCOpts', '-lLLVMMIRParser', '-lLLVMSymbolize', '-lLLVMDebugInfoPDB', '-lLLVMDebugInfoDWARF', '-lLLVMCoverage', '-lLLVMMCA', '-lLLVMTableGen', '-lLLVMDlltoolDriver', '-lLLVMXRay', '-lLLVMOrcJIT', '-lL...
#! /bin/env python # -*- coding: utf-8 -*- ''' Something like metagoofil Nothing... I just write it to work just for google... Practice for OOP '''
""" Something like metagoofil Nothing... I just write it to work just for google... Practice for OOP """
#!/bin/python3 ## so whatever matplotlib plot styling you like here, to be performed just after importing mpl def style_init(mpl): plt = mpl.pyplot mpl.rcParams['figure.autolayout'] = True mpl.rcParams['hatch.color'] = 'k' mpl.rcParams['hatch.linewidth'] = '3' mpl.rcParams['font.size'] = 12 mp...
def style_init(mpl): plt = mpl.pyplot mpl.rcParams['figure.autolayout'] = True mpl.rcParams['hatch.color'] = 'k' mpl.rcParams['hatch.linewidth'] = '3' mpl.rcParams['font.size'] = 12 mpl.rcParams['figure.dpi'] = 72 plt.style.use('dark_background') return def style_before_plotting(mpl, pl...
N = int(input()) M = [] for i in range(N): M.append(input()) answer = [] for i in range(N // 2): ok_chars = set(M[i]).intersection(M[N - 1 - i]) if not ok_chars: print(-1) break answer.append(list(ok_chars)[0]) else: if N % 2 == 0: print("".join(answer) + "".join(reversed(an...
n = int(input()) m = [] for i in range(N): M.append(input()) answer = [] for i in range(N // 2): ok_chars = set(M[i]).intersection(M[N - 1 - i]) if not ok_chars: print(-1) break answer.append(list(ok_chars)[0]) else: if N % 2 == 0: print(''.join(answer) + ''.join(reversed(ans...
class Request: def __init__(self, authenticated, authorized, route): self.authenticated = authenticated self.authorized = authorized self.route = route
class Request: def __init__(self, authenticated, authorized, route): self.authenticated = authenticated self.authorized = authorized self.route = route
''' Created on 07.11.2019 @author: JM ''' class TMC2660_fields(object): """ Define all register bitfields of the TMC2660. Each field is defined as a tuple consisting of ( Address, Mask, Shift ). The name of the register is written as a comment behind each tuple. This is intended for IDE users viewing the defin...
""" Created on 07.11.2019 @author: JM """ class Tmc2660_Fields(object): """ Define all register bitfields of the TMC2660. Each field is defined as a tuple consisting of ( Address, Mask, Shift ). The name of the register is written as a comment behind each tuple. This is intended for IDE users viewing the de...
# Copyright 2019-2020 by Wenfeng Gao, MGLAND animation studio. All rights reserved. # This file is part of IUTest, and is released under the "MIT License Agreement". # Please see the LICENSE file that should have been included as part of this package. class TestRunInfo(object): def __init__(self): self.re...
class Testruninfo(object): def __init__(self): self.reset() def reset(self): self.runTestIds = [] self.runCount = 0 self.failedTestId = None self.successCount = 0 self.failedCount = 0 self.errorCount = 0 self.skipCount = 0 self.expectedFa...
# TODO: this class DataPackage: def __init__(self, access_token, primary_id, secondary_id): self._access_token = access_token self._primary_id = primary_id self._secondary_id = secondary_id @property def access_token(self): return self._access_token def to_xml(self): ...
class Datapackage: def __init__(self, access_token, primary_id, secondary_id): self._access_token = access_token self._primary_id = primary_id self._secondary_id = secondary_id @property def access_token(self): return self._access_token def to_xml(self): datapa...
def prime(num): if num == 2: return 2 else: new = 0 for i in range(2, num): if num%i == 0: new +=1 break if new == 0: print (num) return prime(num-1) (prime(20))
def prime(num): if num == 2: return 2 else: new = 0 for i in range(2, num): if num % i == 0: new += 1 break if new == 0: print(num) return prime(num - 1) prime(20)
#!/usr/bin/env python3 with open("bans.txt", "r") as ban: ban = ban.read().splitlines() bans = {} for b in ban: b = b.split(" ") b[1] = " ".join(b[1:]) bans[b[0]] = b[1] def is_banned(ip): ip = str(ip) for b in bans.keys(): if ip.startswith(b): return bans[b] return 0...
with open('bans.txt', 'r') as ban: ban = ban.read().splitlines() bans = {} for b in ban: b = b.split(' ') b[1] = ' '.join(b[1:]) bans[b[0]] = b[1] def is_banned(ip): ip = str(ip) for b in bans.keys(): if ip.startswith(b): return bans[b] return 0
# Time: O(n!) # Space: O(n) class Solution(object): def canIWin(self, maxChoosableInteger, desiredTotal): """ :type maxChoosableInteger: int :type desiredTotal: int :rtype: bool """ def canIWinHelper(maxChoosableInteger, desiredTotal, visited, lookup): i...
class Solution(object): def can_i_win(self, maxChoosableInteger, desiredTotal): """ :type maxChoosableInteger: int :type desiredTotal: int :rtype: bool """ def can_i_win_helper(maxChoosableInteger, desiredTotal, visited, lookup): if visited in lookup: ...
class FrozenException(Exception): pass class FrozenKeyError(FrozenException, KeyError): pass class FrozenValueError(FrozenException, ValueError): pass
class Frozenexception(Exception): pass class Frozenkeyerror(FrozenException, KeyError): pass class Frozenvalueerror(FrozenException, ValueError): pass
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 8 21:46:38 2018 @author: joy """ message = "Hello Python Crash Course reader!" print(mesage) # NameError: name 'mesage' is not defined
""" Created on Mon Jan 8 21:46:38 2018 @author: joy """ message = 'Hello Python Crash Course reader!' print(mesage)
SUCCESS = 0 COST_SHORTAGE = 1 INVALID_POSITION = 2 LV_MAX = 3 UNKNOWN_TARGET = 4 IMPOSSIBLE_CLUSTER = 5
success = 0 cost_shortage = 1 invalid_position = 2 lv_max = 3 unknown_target = 4 impossible_cluster = 5
guests = ['bobi', 'veli', 'rumen'] for guest in guests : print ('Hi, ' + guest.title() + ' I invite u.') guests[0] = 'slavi' for guest in guests : print ('Hi, ' + guest.title() + ' I invite u.') print (len(guests))
guests = ['bobi', 'veli', 'rumen'] for guest in guests: print('Hi, ' + guest.title() + ' I invite u.') guests[0] = 'slavi' for guest in guests: print('Hi, ' + guest.title() + ' I invite u.') print(len(guests))
sides = {} while True: command = input() if command == "Lumpawaroo": break if "|" in command: command = command.split(" | ", maxsplit=2) force_side = command[0] force_user = command[1] if force_side not in sides: sides[force_side] = [force_user] ...
sides = {} while True: command = input() if command == 'Lumpawaroo': break if '|' in command: command = command.split(' | ', maxsplit=2) force_side = command[0] force_user = command[1] if force_side not in sides: sides[force_side] = [force_user] el...
running_score_table = [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 19, 2...
running_score_table = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 42, 43, 44, 46, 48, 49, 50], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18,...
# -*- coding: utf-8 -*- # # Copyright (C) 2021 Graz University of Technology. # # invenio-alma is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Invenio module to connect InvenioRDM to Alma.""" INVENIO_ALMA_DEFAULT_VALUE = "foobar" "...
"""Invenio module to connect InvenioRDM to Alma.""" invenio_alma_default_value = 'foobar' 'Default value for the application.'
def exercise1(trial): hasSix = False isPair = False pairs = 0 for char in trial: # This is the case if a 6 is found and no 6 has been found before it if char == '6' and not isPair: if hasSix: isPair = True else: hasSix = True ...
def exercise1(trial): has_six = False is_pair = False pairs = 0 for char in trial: if char == '6' and (not isPair): if hasSix: is_pair = True else: has_six = True elif char == '6' and isPair: is_pair = False ...
# Created from ttf-fonts/Entypo.otf with freetype-generator. # freetype-generator created by Meurisse D ( MCHobby.be ). Entypo_13 = { 'width' : 0xc, 'height' : 0xd, 33:( 0x2000, 0x2800, 0x3c00, 0x3c00, 0x3800, 0x2c00, 0x2600, 0x23e0, 0x21f0, 0x2060), 34:( 0x3ffc, 0x3804, 0x3804, 0x3804, 0x3804, 0x3804, 0x3ffc), 35:(...
entypo_13 = {'width': 12, 'height': 13, 33: (8192, 10240, 15360, 15360, 14336, 11264, 9728, 9184, 8688, 8288), 34: (16380, 14340, 14340, 14340, 14340, 14340, 16380), 35: (8420, 12280, 16272, 16368, 16352, 12160, 9728), 36: (8256, 8384, 8416, 8416, 16376, 8208, 8304, 8304, 8304, 8304, 8288, 8224), 37: (16000, 16000, 157...
class EggCartons: def minCartons(self, n): d = {} for i in xrange(17): for j in xrange(13): c = 6 * i + 8 * j d[c] = min(i + j, d.get(c, 30)) return d[n] if n in d else -1
class Eggcartons: def min_cartons(self, n): d = {} for i in xrange(17): for j in xrange(13): c = 6 * i + 8 * j d[c] = min(i + j, d.get(c, 30)) return d[n] if n in d else -1
autocomplete_service = { 'type': 'object', 'nullable': True, 'properties': { 'serviceUrl': { 'description': 'URL of the autocomplete service.', 'type': 'string', }, 'match_any': { 'description': 'If true, autocomplete will find leaves with any part...
autocomplete_service = {'type': 'object', 'nullable': True, 'properties': {'serviceUrl': {'description': 'URL of the autocomplete service.', 'type': 'string'}, 'match_any': {'description': 'If true, autocomplete will find leaves with any part of name matching the query. Otherwise only leaf names that start with the que...
manas="manas is going from varanasi to to delhi and then from delhi to chandigarh" l=manas.split() print(l) dic=dict.fromkeys(l,0) print(dic) for i in l: dic[i]+=1 print("NewDic=",dic) max=0 pos=0 for key in dic.keys(): value=dic[key] if (value > max) : max=value ...
manas = 'manas is going from varanasi to to delhi and then from delhi to chandigarh' l = manas.split() print(l) dic = dict.fromkeys(l, 0) print(dic) for i in l: dic[i] += 1 print('NewDic=', dic) max = 0 pos = 0 for key in dic.keys(): value = dic[key] if value > max: max = value pos = key pri...
file_read = open("input.txt", "r") line = file_read.readline() freq = 0 frequencies_achieved = [freq] was_first_double_frequency_found = False first_double_frequency = 0 while not was_first_double_frequency_found: number = int(line[1:]) if line[0] == '-': freq -= int(number) else: freq +=...
file_read = open('input.txt', 'r') line = file_read.readline() freq = 0 frequencies_achieved = [freq] was_first_double_frequency_found = False first_double_frequency = 0 while not was_first_double_frequency_found: number = int(line[1:]) if line[0] == '-': freq -= int(number) else: freq += in...
HOMOGLYPH_MAP = { '0': [ u'\uff10' ], '1': [ u'\uff11' ], '2': [ u'\uff12' ], '3': [ u'\uff13' ], '4': [ u'\uff14' ], '5': [ u'\uff15' ], '6': [ u'\uff16' ], '7': [ u'\uff17' ], '8': [ u'\uff18' ], '9': [ u'\uff19' ], '-': [ u'\u2010' ], 'a': [ u'\uff41', u'\u0430' ], ...
homoglyph_map = {'0': [u'0'], '1': [u'1'], '2': [u'2'], '3': [u'3'], '4': [u'4'], '5': [u'5'], '6': [u'6'], '7': [u'7'], '8': [u'8'], '9': [u'9'], '-': [u'‐'], 'a': [u'a', u'а'], 'b': [u'b'], 'c': [u'c', u'с'], 'd': [u'd', u'ⅾ'], 'e': [u'e', u'е'], 'f': [u'f'], 'g': [u'g'], 'h': [u'h', u'һ'], 'i': [u'i', u'і', u'ⅰ'], '...
num1 = int(input("Enter a starting number: ")) print("If the ending number is smaller that the starting number, the ending number will be used as the starting number") num2 = int(input("Enter an ending number: ")) step = int(input("Enter the increment value: ")) if num1 < num2: for i in range(num1, num2 + 1, s...
num1 = int(input('Enter a starting number: ')) print('If the ending number is smaller that the starting number, the ending number will be used as the starting number') num2 = int(input('Enter an ending number: ')) step = int(input('Enter the increment value: ')) if num1 < num2: for i in range(num1, num2 + 1, step):...
# a. grids x1_vec = np.linspace(-2,2,500) x2_vec = np.linspace(-2,2,500) x1_grid,x2_grid = np.meshgrid(x1_vec,x2_vec,indexing='ij') f_grid = _f(x1_grid,x2_grid) # b. main fig = plt.figure(dpi = 100, figsize=(7,4)) ax = fig.add_subplot(1,1,1,projection='3d') cs = ax.plot_surface(x1_grid,x2_grid,f_grid,cmap=cm.jet) # c...
x1_vec = np.linspace(-2, 2, 500) x2_vec = np.linspace(-2, 2, 500) (x1_grid, x2_grid) = np.meshgrid(x1_vec, x2_vec, indexing='ij') f_grid = _f(x1_grid, x2_grid) fig = plt.figure(dpi=100, figsize=(7, 4)) ax = fig.add_subplot(1, 1, 1, projection='3d') cs = ax.plot_surface(x1_grid, x2_grid, f_grid, cmap=cm.jet) ax.set_xlab...
class Job: id = 0 def __init__(self): self.id = Job.id Job.id += 1
class Job: id = 0 def __init__(self): self.id = Job.id Job.id += 1
# Copyright 2015 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
def _decode(b): for x in b: if x < 128: yield x else: extra = 0 for i in range(6, 0, -1): if x & 1 << i: extra += 1 else: break bits = x % (1 << 6 - extra) for _ in ran...
"""Constants for pyskyqremote- GB.""" SCHEDULE_URL = "http://awk.epgsky.com/hawk/linear/schedule/{1}/{0}" LIVE_IMAGE_URL = "https://images.metadata.sky.com/pd-image/{0}/16-9" PVR_IMAGE_URL = "https://images.metadata.sky.com/pd-image/{0}/16-9" CHANNEL_IMAGE_URL = "https://d2n0069hmnqmmx.cloudfront.net/epgdata/1.0/newch...
"""Constants for pyskyqremote- GB.""" schedule_url = 'http://awk.epgsky.com/hawk/linear/schedule/{1}/{0}' live_image_url = 'https://images.metadata.sky.com/pd-image/{0}/16-9' pvr_image_url = 'https://images.metadata.sky.com/pd-image/{0}/16-9' channel_image_url = 'https://d2n0069hmnqmmx.cloudfront.net/epgdata/1.0/newcha...
def setLanguage(lang): pass def getLanguage(): return 'ja-JP'
def set_language(lang): pass def get_language(): return 'ja-JP'
{ 'name': 'To-Do Website', 'description': 'Manage your personal To-Do tasks.', 'author': 'Daniel Reis', 'depends': ['todo_stage', 'website_form'], 'data': [ 'views/todo_web.xml', 'views/todo_extend.xml', 'data/config_data.xml', ], }
{'name': 'To-Do Website', 'description': 'Manage your personal To-Do tasks.', 'author': 'Daniel Reis', 'depends': ['todo_stage', 'website_form'], 'data': ['views/todo_web.xml', 'views/todo_extend.xml', 'data/config_data.xml']}
""" 119. Pascal's Triangle II Easy Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Input: rowIndex = 3 Output: [1,3,3,1] Example 2: Input: rowIndex = 0 Output: [1] Exa...
""" 119. Pascal's Triangle II Easy Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Input: rowIndex = 3 Output: [1,3,3,1] Example 2: Input: rowIndex = 0 Output: [1] Exa...
_base_ = '../voc_split1/fadi_split1_shot1_discrimination.py' split = 3 shot = 1 model = dict(roi_head=dict( bbox_head=dict(split=split, loss_margin=dict(shot=shot)))) data = dict(train=dict(split=split, shot=shot), val=dict(split=split), test=dict(split=split)) # learning policy lr_confi...
_base_ = '../voc_split1/fadi_split1_shot1_discrimination.py' split = 3 shot = 1 model = dict(roi_head=dict(bbox_head=dict(split=split, loss_margin=dict(shot=shot)))) data = dict(train=dict(split=split, shot=shot), val=dict(split=split), test=dict(split=split)) lr_config = dict(policy='step', warmup='linear', warmup_ite...
#!/usr/bin/env python3 """ Init for test modules. """ __all__ = [ 'test_die', 'test_die_arguments', 'test_hand' ]
""" Init for test modules. """ __all__ = ['test_die', 'test_die_arguments', 'test_hand']
Unit = () def indent(level, size=2): """Return indentation.""" return ' ' * level * size
unit = () def indent(level, size=2): """Return indentation.""" return ' ' * level * size
##Problem Description ##The program takes the upper and lower limit and prints all odd numbers within a given range. while True: lower=int(input("Enter the lower limit of the range: ")) upper =int(input("Enter the upper limit of the range: ")) d=[] for i in range(lower,upper+1): if(i%2!=...
while True: lower = int(input('Enter the lower limit of the range: ')) upper = int(input('Enter the upper limit of the range: ')) d = [] for i in range(lower, upper + 1): if i % 2 != 0: d.append(i) print('odd numbers in the range are: ', d) print('----------------------------...
def resolve_input_path(path): parts = path.split('.') model_name = parts[len(parts)-1] parts.remove(model_name) module = '.'.join(parts) return module, model_name def build_file_path(module): new_path = module.replace('.', '/') final_path = new_path + '.py' return final_path
def resolve_input_path(path): parts = path.split('.') model_name = parts[len(parts) - 1] parts.remove(model_name) module = '.'.join(parts) return (module, model_name) def build_file_path(module): new_path = module.replace('.', '/') final_path = new_path + '.py' return final_path
#sum of no using recursion def Sum(n): if(n>0): x=int(n%10) n=int(n/10) return x+Sum(n) else: return 0 print("Enter the No") n=int(input()) #no of elements input print("Sum is: ",Sum(n))
def sum(n): if n > 0: x = int(n % 10) n = int(n / 10) return x + sum(n) else: return 0 print('Enter the No') n = int(input()) print('Sum is: ', sum(n))
# Day 2 Part 1 f = "AoC2021/part2.txt" pos = 0 depth = 0 with open(f, 'r') as data: for i in data: move = i.strip().split(" ") if 'forward' in move[0]: pos += int(move[1]) if 'down' in move[0]: depth += int(move[1]) if 'up' in move[0]: depth -= int...
f = 'AoC2021/part2.txt' pos = 0 depth = 0 with open(f, 'r') as data: for i in data: move = i.strip().split(' ') if 'forward' in move[0]: pos += int(move[1]) if 'down' in move[0]: depth += int(move[1]) if 'up' in move[0]: depth -= int(move[1]) print...
# Tambahkan nilai default untuk name def print_hand(hand, name='Tamu'): print(name + ' memilih: ' + hand) # Tambahkan argument ke print_hand print_hand('Batu')
def print_hand(hand, name='Tamu'): print(name + ' memilih: ' + hand) print_hand('Batu')
"""Macro to package AWS Lambdas defined in Javascript""" load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path") load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") load("@bazel_skylib//lib:paths.bzl", "paths") load("@rules_pkg//pkg:pkg.bzl", "pkg_zip") # Note: the `bundler` attribute is basica...
"""Macro to package AWS Lambdas defined in Javascript""" load('@aspect_bazel_lib//lib:directory_path.bzl', 'make_directory_path') load('@aspect_bazel_lib//lib:copy_file.bzl', 'copy_file') load('@bazel_skylib//lib:paths.bzl', 'paths') load('@rules_pkg//pkg:pkg.bzl', 'pkg_zip') def node_lambda(name, bundler, srcs=[], de...
class FakeLogger: def __init__(self): self.messages = [] def log(self, level, message): self.messages.append({"level": level, "message": message}) def by_level(self, level): return [log["message"] for log in self.messages if log["level"] == level] def warning(self, message): ...
class Fakelogger: def __init__(self): self.messages = [] def log(self, level, message): self.messages.append({'level': level, 'message': message}) def by_level(self, level): return [log['message'] for log in self.messages if log['level'] == level] def warning(self, message): ...
# https://app.codesignal.com/arcade/intro/level-3/fzsCQGYbxaEcTr2bL def allLongestStrings(in_array): # Given an array of strings, return another containing only # the longest strings (all strings with longest length equal). lengths = [(len(str), str) for str in in_array] max_len = max(lengths) # Fil...
def all_longest_strings(in_array): lengths = [(len(str), str) for str in in_array] max_len = max(lengths) res = filter(lambda x: x[0] == max_len[0], lengths) return list(map(lambda x: x[1], res))
# # @lc app=leetcode id=495 lang=python3 # # [495] Teemo Attacking # # https://leetcode.com/problems/teemo-attacking/description/ # # algorithms # Medium (51.93%) # Total Accepted: 35.5K # Total Submissions: 68.2K # Testcase Example: '[1,4]\n2' # # In LOL world, there is a hero called Teemo and his att...
class Solution: def find_poisoned_duration(self, timeSeries: List[int], duration: int) -> int: if len(timeSeries) == 0: return 0 sol = 0 for i in range(len(timeSeries) - 1, 0, -1): temp = timeSeries[i] - timeSeries[i - 1] sol += duration if temp > duratio...
LOGM = 30 M = 1<<LOGM MASK = M - 1 def ceildiv(a, b): return -(-a // b) class UpperNode: def __init__(self,label,next_node,prev_node): self.label = label self.next_node = next_node self.prev_node = prev_node def insert(self): j = 1 cur = self.next_node ...
logm = 30 m = 1 << LOGM mask = M - 1 def ceildiv(a, b): return -(-a // b) class Uppernode: def __init__(self, label, next_node, prev_node): self.label = label self.next_node = next_node self.prev_node = prev_node def insert(self): j = 1 cur = self.next_node ...
""" This module defines the interface of a random module. """ class Random: _instance = None def __new__(cls): if cls._instance is None: cls._instance = super().__new__(cls) return cls._instance def seed(self, seed): raise NotImplementedError() def random(self, siz...
""" This module defines the interface of a random module. """ class Random: _instance = None def __new__(cls): if cls._instance is None: cls._instance = super().__new__(cls) return cls._instance def seed(self, seed): raise not_implemented_error() def random(self, ...
class Solution(object): # def threeSum(self, nums): # # skip duplicate # # O(n^3) # if len(nums) < 3: # return [] # nums.sort() # ls = len(nums) # result = [] # for i in range(0, ls - 2): # if nums[i] > 0: # break #...
class Solution(object): def three_sum(self, nums): res = [] nums.sort() ls = len(nums) for i in range(ls - 2): if i > 0 and nums[i] == nums[i - 1]: continue j = i + 1 k = ls - 1 while j < k: curr = nums[...
# Copyright 2018 Databricks, Inc. VERSION = '0.8.3.dev0'
version = '0.8.3.dev0'
"""List of Constants""" SSH_ATTEMPTS = 10 SSH_TIMEOUT = 60 INSTANCE_TIMEOUT = 120 UMASK='0022'
"""List of Constants""" ssh_attempts = 10 ssh_timeout = 60 instance_timeout = 120 umask = '0022'
""" :copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved. :license: BSD, see LICENSE_BSD_Simple.txt for details. """ class PublisherMixin: """ Mixin for publishing messages to a topic's listeners. This will be mixed into topicobj.Topic so that a user can use a Topic object to sen...
""" :copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved. :license: BSD, see LICENSE_BSD_Simple.txt for details. """ class Publishermixin: """ Mixin for publishing messages to a topic's listeners. This will be mixed into topicobj.Topic so that a user can use a Topic object to send...
class Solution: def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: def binary_search(array, target): left = 0 right = len(array) - 1 while left <= right: mid = (left + right) // 2 if array[mid] == target: ...
class Solution: def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: def binary_search(array, target): left = 0 right = len(array) - 1 while left <= right: mid = (left + right) // 2 if array[mid] == target: ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Aug 13 21:28:36 2019 @author: tauro """ idx = pd.date_range(df.date.min(), df.date.max()) aa = test[test['sku'] == 'SKU0933'] bb = aa.copy() bb = bb.set_index('date') bb.index = pd.DatetimeIndex(bb.index) #bb = bb.drop(column=['date']) bb = bb.r...
""" Created on Tue Aug 13 21:28:36 2019 @author: tauro """ idx = pd.date_range(df.date.min(), df.date.max()) aa = test[test['sku'] == 'SKU0933'] bb = aa.copy() bb = bb.set_index('date') bb.index = pd.DatetimeIndex(bb.index) bb = bb.reindex(idx) bb = bb.reset_index() bb = bb.rename(columns={'index': 'date', 'qty_x': 'q...
def sistema_menssagem(msg): hast = len(msg)+4 print('#' * hast) print(f' {msg}') print('#' * hast) sistema_menssagem('hello Word') ''' def contador(*num): cont = 0 for c in num: cont = cont + c print(cont) print() def dobra(ist): pos = 0 while pos < len(ist): ...
def sistema_menssagem(msg): hast = len(msg) + 4 print('#' * hast) print(f' {msg}') print('#' * hast) sistema_menssagem('hello Word') '\ndef contador(*num):\n cont = 0\n for c in num:\n cont = cont + c\n\n print(cont)\n print()\n\n\ndef dobra(ist):\n pos = 0\n while pos < len(is...
class Bank: balance = 0 transaction_count = 0 def __init__(self): pass def deposit(self, amount): Bank.balance += amount message = 'Deposited ' + str(amount) + ' successfully, Balance: ' + str(Bank.balance) Bank.trasaction_count += 1 return message def with...
class Bank: balance = 0 transaction_count = 0 def __init__(self): pass def deposit(self, amount): Bank.balance += amount message = 'Deposited ' + str(amount) + ' successfully, Balance: ' + str(Bank.balance) Bank.trasaction_count += 1 return message def with...
# General Problem 12: # Implement the square root function # Solution: # Use an algorithm that starts off at 0 and increments by a value # whenever the total is still less than our target # if we get ahead of the target, instead we lower the increment value # repeat until our increment value reaches a small enough val...
def guess_square_root(inputInteger): current_range = 1 start = 0 if inputInteger >= 1: while currentRange > 0.0001: if (start + currentRange) * (start + currentRange) < inputInteger: start = start + currentRange else: current_range *= 0.1 e...
# -*- coding: utf-8 -*- """ Created on Fri Oct 29 14:19:14 2021 @author: ABIR RAIHAN """
""" Created on Fri Oct 29 14:19:14 2021 @author: ABIR RAIHAN """
"""Color palette taken from Fractint.""" # taken from Fractint # see https://www.fractint.org/ palette = ( (000, 000, 0), (000, 000, 0), (000, 000, 8), (000, 000, 16), (000, 000, 24), (000, 000, 32), (000, 000, 40), (000, 000, 48), (000, 000, 56), (000, 000, 64), (000, 000, 72), (...
"""Color palette taken from Fractint.""" palette = ((0, 0, 0), (0, 0, 0), (0, 0, 8), (0, 0, 16), (0, 0, 24), (0, 0, 32), (0, 0, 40), (0, 0, 48), (0, 0, 56), (0, 0, 64), (0, 0, 72), (0, 0, 80), (0, 0, 88), (0, 0, 96), (0, 0, 104), (0, 0, 112), (0, 0, 120), (0, 0, 128), (0, 0, 136), (0, 0, 144), (0, 0, 152), (0, 0, 160),...
''' URL: https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ Difficulty: Easy Description: Number of Steps to Reduce a Number to Zero Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you have to divide it by 2, otherwise, you have...
""" URL: https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ Difficulty: Easy Description: Number of Steps to Reduce a Number to Zero Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you have to divide it by 2, otherwise, you have...
def f(): if True: for i in xrange(20000): pass else: a = 1 f()
def f(): if True: for i in xrange(20000): pass else: a = 1 f()
# -*- coding: utf-8 -*- # @Author: zero_kelvin # @Date: 2021-06-26 15:12:34 # @Last Modified by: zero_kelvin # @Last Modified time: 2021-06-26 15:14:14 print("Hello " + input("What is your name? \n") + ". It's a pleasure to meet you!") print("Welcome to the Band Name Generator...") home = input("Where did you grow...
print('Hello ' + input('What is your name? \n') + ". It's a pleasure to meet you!") print('Welcome to the Band Name Generator...') home = input('Where did you grow up? \n') pet = input('What was the name of a pet? \n') print('The name of your band could be ' + home + ' ' + pet)
""" Meter Parser """
""" Meter Parser """
languages = [ "french.txt", "italian.txt", "german.txt", "english.txt" ] def most_frequent(text): """ Returns the letter frequencies of the given text""" letters = tuple(text) freqs = {} for let in letters: freqs.setdefault(let, 0) freqs[let] += 1...
languages = ['french.txt', 'italian.txt', 'german.txt', 'english.txt'] def most_frequent(text): """ Returns the letter frequencies of the given text""" letters = tuple(text) freqs = {} for let in letters: freqs.setdefault(let, 0) freqs[let] += 1 rankedpairs = [] for (key, val) i...
class Foo(object): def a(self, arg): badVariableName = 1 return badVariableName + arg def b(self): pass def c(self): pass def d(self): pass def e(self): pass def f(self): pass def g(self): pass def h(self): p...
class Foo(object): def a(self, arg): bad_variable_name = 1 return badVariableName + arg def b(self): pass def c(self): pass def d(self): pass def e(self): pass def f(self): pass def g(self): pass def h(self): ...
# --------------------------------------------------------------------------------------- # -------------------Author : itsjaysuthar ---------------------------------------------- # --------------------------------------------------------------------------------------- def digit(n): c=0 while n>0: n=n/...
def digit(n): c = 0 while n > 0: n = n // 10 c += 1 return c n1 = 1 n2 = 1 sum = 0 for i in range(3, 100000): sum = n1 + n2 j = digit(sum) if j == 1000: print(i) break n1 = n2 n2 = sum
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: mo-mo- # # Created: 23/09/2018 # Copyright: (c) mo-mo- 2018 # Licence: <your licence> #------------------------------------------------------------------------------- ...
(n, m, x, y) = map(int, input().split()) x_l = list(map(int, input().split())) y_l = list(map(int, input().split())) xm = max(x_l) ym = min(y_l) ans = 'No War' if xm >= ym: ans = 'War' elif xm >= Y: ans = 'War' elif X >= ym: ans = 'War' elif X >= Y: ans = 'War' print(ans)
class GetattrError(AttributeError): # Public pass
class Getattrerror(AttributeError): pass
""" You are given an array of non-negative integers, and are initially positioned at the first index of the array. Each element in the array represents your maximum jump length from that position. Return the fewest number of jumps to reach the last index. You can assume that you can always reach the last index. Exampl...
""" You are given an array of non-negative integers, and are initially positioned at the first index of the array. Each element in the array represents your maximum jump length from that position. Return the fewest number of jumps to reach the last index. You can assume that you can always reach the last index. Exampl...
''' Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? ''' # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def isPalindrome(self, head):...
""" Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? """ class Listnode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def is_palindrome(self, head): """ :type head: Li...
print(""" All the info is at https://discordapp.com/developers/applications/ CREATE A BOT ------------- 1. Navigate to the above URL 2. Click on `New Application` or similar in upper right 3. Enter the name 4. Add a PFP 5. Go to `Bot` in the left panel 6. Click on `Create bot` or similar GET THE TOKEN ----...
print("\nAll the info is at https://discordapp.com/developers/applications/\nCREATE A BOT -------------\n 1. Navigate to the above URL\n 2. Click on `New Application` or similar in upper right\n 3. Enter the name\n 4. Add a PFP\n 5. Go to `Bot` in the left panel\n 6. Click on `Create bot` or similar\n\nGET THE TO...
""" Python Assignment Operators Assignment operators are used to assign values to variables: ----------------------------------------------------- | Operator | Example | Similar to | |-------------------|---------------|---------------| | = | x = 5 | x = 5 | Assign valu...
""" Python Assignment Operators Assignment operators are used to assign values to variables: ----------------------------------------------------- | Operator | Example | Similar to | |-------------------|---------------|---------------| | = | x = 5 | x = 5 | Assign valu...
class Scheduler(): def __init__(self, initial_value, end_value, iterations): self.initial_value = initial_value self.end_value = end_value self.max_iterations = iterations self.current_iteration = 0 def __iter__(self): return self def __next__(self): raise Not...
class Scheduler: def __init__(self, initial_value, end_value, iterations): self.initial_value = initial_value self.end_value = end_value self.max_iterations = iterations self.current_iteration = 0 def __iter__(self): return self def __next__(self): raise no...
""" Input Format A single line of input containing the full name, . Constraints The string consists of alphanumeric characters and spaces. Note: in a word only the first character is capitalized. Example 12abc when capitalized remains 12abc. Output Format Print the capitalized string, """ # Complete the solve fun...
""" Input Format A single line of input containing the full name, . Constraints The string consists of alphanumeric characters and spaces. Note: in a word only the first character is capitalized. Example 12abc when capitalized remains 12abc. Output Format Print the capitalized string, """ def solve(s): for i ...
def a_star(graph, heuristic, start, goal): """ Finds the shortest distance between two nodes using the A-star (A*) algorithm :param graph: an adjacency-matrix-representation of the graph where (x,y) is the weight of the edge or 0 if there is no edge. :param heuristic: an estimation of distance from node...
def a_star(graph, heuristic, start, goal): """ Finds the shortest distance between two nodes using the A-star (A*) algorithm :param graph: an adjacency-matrix-representation of the graph where (x,y) is the weight of the edge or 0 if there is no edge. :param heuristic: an estimation of distance from node...
def countPattern(genome, pattern): """ Find the number of specific pattern in a genome sequence """ count = 0 for index in range(0, len(genome)-len(pattern)+1): if genome[index:index+len(pattern)] == pattern: count += 1 return count def findPattern(genome, pattern): "...
def count_pattern(genome, pattern): """ Find the number of specific pattern in a genome sequence """ count = 0 for index in range(0, len(genome) - len(pattern) + 1): if genome[index:index + len(pattern)] == pattern: count += 1 return count def find_pattern(genome, pattern): ...
#divisibility by 7 not by 5 for x in range(2000,2101): if(x%5==0): continue if(x%7==0): print(x,end=',')
for x in range(2000, 2101): if x % 5 == 0: continue if x % 7 == 0: print(x, end=',')
def sort_prices(list_of_tuples): """ :param list_of_tuples: :return: New tuples list sorted by prices high to low """ new_list = sorted(list_of_tuples, key=lambda x: (x[1]), reverse=True) return new_list def main(): print(sort_prices.__doc__) products = [('milk', '5.5'), ('candy', '2.5...
def sort_prices(list_of_tuples): """ :param list_of_tuples: :return: New tuples list sorted by prices high to low """ new_list = sorted(list_of_tuples, key=lambda x: x[1], reverse=True) return new_list def main(): print(sort_prices.__doc__) products = [('milk', '5.5'), ('candy', '2.5'),...
""" Settings file for project. """ # DEFINE COLORS BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (200, 0, 0) BRIGHT_RED = (255, 0, 0) GREEN = (0, 200, 0) BRIGHT_GREEN = (0, 255, 0) BLUE = (0, 0, 255) PINK = (255, 192, 203) PURPLE = (128, 0, 128) ORANGE = (255, 165, 0) GOLD = (255, 215, 0) YELLOW = ...
""" Settings file for project. """ black = (0, 0, 0) white = (255, 255, 255) red = (200, 0, 0) bright_red = (255, 0, 0) green = (0, 200, 0) bright_green = (0, 255, 0) blue = (0, 0, 255) pink = (255, 192, 203) purple = (128, 0, 128) orange = (255, 165, 0) gold = (255, 215, 0) yellow = (255, 255, 0) grey = (128, 128, 1...
def get_surroundings(x, y, game): coords = [(x - 1, y - 1), (x, y - 1), (x + 1, y - 1), (x - 1, y), (x + 1, y), (x - 1, y + 1), (x, y + 1), (x + 1, y + 1)] cells = [get_cell(_x, _y, game) for _x, _y in coords if 0 <= _x < game.width and 0 <= _y < game.height...
def get_surroundings(x, y, game): coords = [(x - 1, y - 1), (x, y - 1), (x + 1, y - 1), (x - 1, y), (x + 1, y), (x - 1, y + 1), (x, y + 1), (x + 1, y + 1)] cells = [get_cell(_x, _y, game) for (_x, _y) in coords if 0 <= _x < game.width and 0 <= _y < game.height] return cells def get_cell(x, y, game): re...
god = 'THoR' print(god.lower()) print(god.upper()) a = " Hello, World! " print(a.strip()) # returns "Hello, World!" b = "Hello, World!" print(b.split(",")) # returns ['Hello', ' World!']
god = 'THoR' print(god.lower()) print(god.upper()) a = ' Hello, World! ' print(a.strip()) b = 'Hello, World!' print(b.split(','))
letra = input() texto = list(input().split()) totalPalavraTexto = len(texto) cout = 0 for i in range(len(texto)): if(letra in texto[i]): cout = cout + 1 print("{0:.1f}".format(cout / totalPalavraTexto * 100.00))
letra = input() texto = list(input().split()) total_palavra_texto = len(texto) cout = 0 for i in range(len(texto)): if letra in texto[i]: cout = cout + 1 print('{0:.1f}'.format(cout / totalPalavraTexto * 100.0))
COFFEE_SNOB_PHRASES = set((\ 'espresso', 'cappucino', 'macchiato', 'latte', 'cortado', 'pour over', 'barista', 'flat white', 'siphon pot', 'woodneck', 'french press', 'arabica', 'chemex', 'frothed', 'la marzocco', 'mazzer', 'la pavoni', 'nespresso', 'rancilio silvia', 'hario', 'intelligentsia', 'count...
coffee_snob_phrases = set(('espresso', 'cappucino', 'macchiato', 'latte', 'cortado', 'pour over', 'barista', 'flat white', 'siphon pot', 'woodneck', 'french press', 'arabica', 'chemex', 'frothed', 'la marzocco', 'mazzer', 'la pavoni', 'nespresso', 'rancilio silvia', 'hario', 'intelligentsia', 'counter culture', 'barism...
def search4vowels(phrase:str)->set: """Return any vowels found in a supplied phrase""" vowels=set('aeiou') return vowels.intersection(set(phrase)) def search4letters(phrase:str,letters:str='aeiou')->set: """Return a set of the 'letters' found in 'phrase'.""" return set(letters).intersection(set(phrase))
def search4vowels(phrase: str) -> set: """Return any vowels found in a supplied phrase""" vowels = set('aeiou') return vowels.intersection(set(phrase)) def search4letters(phrase: str, letters: str='aeiou') -> set: """Return a set of the 'letters' found in 'phrase'.""" return set(letters).intersecti...
class Solution: def climbStairs(self, n: int) -> int: if n < 2: return 1 prev, curr = 1, 1 for _ in range(n-1): prev, curr = curr, prev + curr return curr
class Solution: def climb_stairs(self, n: int) -> int: if n < 2: return 1 (prev, curr) = (1, 1) for _ in range(n - 1): (prev, curr) = (curr, prev + curr) return curr
''' Reverse the words in a string. Notes * What went well * Saw the insight of reversing the string first and then reversing each word on a second pass * What didn't go well * Didn't validate the termination condition of reversing each (reversed) word, so it didn't reverse the last word. ''' def reverse_array(arr...
""" Reverse the words in a string. Notes * What went well * Saw the insight of reversing the string first and then reversing each word on a second pass * What didn't go well * Didn't validate the termination condition of reversing each (reversed) word, so it didn't reverse the last word. """ def reverse_array(ar...
screen_resX=1920 screen_resY=1080 img_id=[1, 2, 7, 12, 13, 15, 19, 25, 27, 29, 41, 42, 43, 44, 48, 49, 51, 54, 55, 59, 61, 64, 67, 74,...
screen_res_x = 1920 screen_res_y = 1080 img_id = [1, 2, 7, 12, 13, 15, 19, 25, 27, 29, 41, 42, 43, 44, 48, 49, 51, 54, 55, 59, 61, 64, 67, 74, 76, 77, 84, 87, 88, 91, 94, 95, 100, 101, 112, 113, 3, 6, 10, 17, 21, 23, 28, 33, 35, 38, 39, 40, 46, 50, 52, 58, 60, 62, 63, 70, 72, 73, 75, 78, 80, 82, 89, 90, 92, 97, 99, 102...
''' Write a function that takes arraylists of integers, A and B, and returns A_prime and B_prime, such that A_prime contains all elements of A that are not present in B AND B_prime contains all elements of B that are not present in A. Example: A: <4, 2, 6, 5, 2, 7, 2> B: <3, 9, 2, 7, 1> A_prime: <4, 6, 5, 2, 2> B...
""" Write a function that takes arraylists of integers, A and B, and returns A_prime and B_prime, such that A_prime contains all elements of A that are not present in B AND B_prime contains all elements of B that are not present in A. Example: A: <4, 2, 6, 5, 2, 7, 2> B: <3, 9, 2, 7, 1> A_prime: <4, 6, 5, 2, 2> B...
def read_input(file_name: str): with open("inputFiles/" + file_name, "r") as file: return file.read().splitlines() def part1(input_value: [[int]]): gamma = 0 epsilon = 0 for i in range(len(input_value[0])): values = [int(report[i]) for report in input_value] gamma = gamma * 10 ...
def read_input(file_name: str): with open('inputFiles/' + file_name, 'r') as file: return file.read().splitlines() def part1(input_value: [[int]]): gamma = 0 epsilon = 0 for i in range(len(input_value[0])): values = [int(report[i]) for report in input_value] gamma = gamma * 10 +...
# Copyright (c) 2018 Gennadii Donchyts. All rights reserved. # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. # Contributors: # * 2018-08-01: Fedor Baart (f.baart@gmail.com) - added cmocean # * 2019-01-18: Justin Braaten (jstnbraaten@gmail.com) - ...
cmocean = {'Thermal': {7: ['042333', '2c3395', '744992', 'b15f82', 'eb7958', 'fbb43d', 'e8fa5b']}, 'Haline': {7: ['2a186c', '14439c', '206e8b', '3c9387', '5ab978', 'aad85c', 'fdef9a']}, 'Solar': {7: ['331418', '682325', '973b1c', 'b66413', 'cb921a', 'dac62f', 'e1fd4b']}, 'Ice': {7: ['040613', '292851', '3f4b96', '427bb...
class Solution: def decodeAtIndex(self, S: str, K: int) -> str: s , count = [], 0 for c in S: s += [c] if c.isdigit(): count *= int(c) else: count += 1 if count > K-1: break for c in rev...
class Solution: def decode_at_index(self, S: str, K: int) -> str: (s, count) = ([], 0) for c in S: s += [c] if c.isdigit(): count *= int(c) else: count += 1 if count > K - 1: break for c in rever...
class ScrollProperties(object): """ Encapsulates properties related to scrolling. """ @staticmethod def __new__(self, *args): # cannot find CLR constructor """ __new__(cls: type,container: ScrollableControl) """ pass Enabled = property(lambda self: object(), lambda self, v: No...
class Scrollproperties(object): """ Encapsulates properties related to scrolling. """ @staticmethod def __new__(self, *args): """ __new__(cls: type,container: ScrollableControl) """ pass enabled = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets...
class ResourcePermission(object): def __init__(self, resource): self.resource=resource class WritePermission(ResourcePermission): def __init__(self, resource): super(WritePermission, self).__init__(resource) class ReadPermission(ResourcePermission): def __init__(self, resource): su...
class Resourcepermission(object): def __init__(self, resource): self.resource = resource class Writepermission(ResourcePermission): def __init__(self, resource): super(WritePermission, self).__init__(resource) class Readpermission(ResourcePermission): def __init__(self, resource): ...