content stringlengths 7 1.05M |
|---|
BANNERS = '''
___
____ __ _______/ (_)___ __ __
/ __ \/ / / / ___/ / / __ \/ / / /
/ / / / /_/ / /__/ / / /_/ / /_/ /
/_/ /_/\__,_/\___/_/_/ .___/\__, /
/_/ /____/
---split---
__ _
... |
"""
Largest palindrome product
Problem 4
A palindromic number reads the same both ways.
The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 ร 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
# I had a feeling that palindromic numbers needed at least one pa... |
class C:
def m1(self):
pass
# <editor-fold desc="Description">
def m2(self):
pass
def m3(self):
pass
# </editor-fold> |
'''
Created on Aug 14, 2016
@author: rafacarv
'''
|
class CBWGroup(object):
def __init__(self,
id="",
name="",
created_at="",
updated_at=""):
self.group_id = id
self.name = name
self.created_at = created_at
self.updated_at = updated_at
|
def print_board(data, board):
snake_index = 0
for snake in board['snakes']:
if (snake['id'] == data['you']['id']):
break
snake_index += 1
print("My snake: " + str(snake_index))
for i in range(board['height'] - 1, -1, -1):
for j in range(0, board['wid... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
class Value(object):
NONE = 0
boolean = 1
i8 = 2
u8 = 3
i16 = 4
u16 = 5
i32 = 6
u32 = 7
i64 = 8
u64 = 9
f32 = 10
f64 = 11
str = 12
str_list = 13
int32_list = 14
float_list... |
l = [1,2,3]
assert 1 in l
assert 5 not in l
d = {1:2}
assert 1 in d
assert 2 not in d
d[2] = d
assert 2 in d
print("ok")
|
# -*- coding: utf-8 -*-
"""DOCSTRING."""
class Settings(object):
WIDTH = 800
HEIGHT = 600
SCROLL_SPEED = 30
SAVE_FOLDER = 'saves'
|
def encode(message, rails):
period = 2 * rails - 2
rows = [[] for _ in range(rails)]
for i, c in enumerate(message):
rows[min(i % period, period - i % period)].append(c)
return ''.join(''.join(row) for row in rows)
def decode(encoded_message, rails):
period = 2 * rails - 2
rows_size ... |
__author__ = 'Kalyan'
notes = '''
1. Read instructions for each function carefully.
2. Feel free to create new functions if needed. Give good names!
3. Use builtins and datatypes that we have seen so far.
4. If something about the function spec is not clear, use the corresponding test
for clarification.
5. ... |
a1 = b'\x02'
b1 = 'AB'
c1 = 'EF'
c2 = None
d1 = b'\x03'
bb = a1 + bytes(b1.encode()) + bytes(c1.encode()) + d1
bb2 = a1 + bytes(b1.encode()) + bytes(c2.encode()) + d1
print(type(bb), bb) |
class Solution:
def reverseBits(self, n: int) -> int:
# we can take the last bit of "n" by doing "n % 2"
# and shift the "n" to the right
# then we paste the last bit to the first bit of "res"
# by using `|` operation
# Take 0101 as an example:
# 00... |
"Create maps with OpenStreetMap layers in a minute and embed them in your site."
VERSION = (1, 0, 0)
__author__ = 'Yohan Boniface'
__contact__ = "ybon@openstreetmap.fr"
__homepage__ = "https://github.com/umap-project/umap"
__version__ = ".".join(map(str, VERSION))
|
#!/user/bin/env python
'''structureToPolymerSequences.py:
This mapper maps a structure to it's polypeptides, polynucleotide chain sequences.
For a multi-model structure, only the first model is considered.
'''
__author__ = "Mars (Shih-Cheng) Huang"
__maintainer__ = "Mars (Shih-Cheng) Huang"
__email__ = "marshuang80@g... |
class ChooserStatistician:
def __init__(self, m_iterations):
self.m_iterations = m_iterations
@property
def m_iterations(self):
return self._m_iterations
@m_iterations.setter
def m_iterations(self, m_iterations):
if not m_iterations > 1:
raise ValueError("Number... |
# a = '42'
# print(type(a))
# a = int(a)
# print(type(a))
# b = 'a2'
# print(type(b))
# b = int(b) ERROR ->>>> this cause error!!! because of 'a' in 'a2'
# c = 3.141592
# print(type(c))
# c = int(c)
# print(c, type(c))
d = '3.141592'
print(type(d))
d = int(float(d))
print(d, type(d))
|
"""
Visualization module.
This module contains visualization functions for functional data.
"""
|
class Config(object):
"""Common configurations"""
MINIFY_PAGE = True
SSL_DISABLE = False
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_RECORD_QUERIES = True
# MAIL_SERVER = 'smtp.googlemail.com'
# MAIL_PORT = 587
# MAIL_USE_TLS = True
# ... |
class MultiStack:
def __init__(self, stacksize):
self.numstacks = 3
self.array = [0] * (stacksize * self.numstacks)
self.sizes = [0] * self.numstacks
self.stacksize = stacksize
def Push(self, item, stacknum):
if self.IsFull(stacknum):
raise Exception("Stack i... |
# Confidence Interval using Stats Model Summary
thresh = 0.05
intervals = results.conf_int(alpha=thresh)
# Renaming column names
first_col = str(thresh/2*100)+"%"
second_col = str((1-thresh/2)*100)+"%"
intervals = intervals.rename(columns={0:first_col,1:second_col})
display(intervals) |
def loadfile(name):
lines = []
f = open(name, "r")
for x in f:
if x.endswith('\n'):
x = x[:-1]
line = []
for character in x:
line.append(int(character))
lines.append(line)
return lines
def add1ToAll(lines):
for i in range (0, len(lines)):
... |
class BuildingSpecification(object):
def __init__(self,building_type, display_string, other_buildings_available, codes_available):
self.building_type = building_type
self.display_string = display_string
self.other_buildings_available = other_buildings_available # list of building names
... |
################################################################################
level_number = 6
dungeon_name = 'Catacombs'
wall_style = 'Catacombs'
monster_difficulty = 3
goes_down = True
entry_position = (0, 0)
phase_door = False
level_teleport = [
(4, True),
(5, True),
(6, False),
]
stairs_previou... |
class Solution:
def deleteAndEarn(self, nums: List[int]) -> int:
d = [0] *(max(nums)+1)
for i in nums:
d[i] += i
prev,prever = 0,0
for i in d:
cur = max(prev,prever+i)
prever = prev
prev = cur
return max(cur,prever)
|
"""Helpers for PyTorch-ES examples"""
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Linear') != -1:
m.weight.data.normal_(0.0, 0.02)
|
keywords = ['program', 'label', 'type', 'array', 'of', 'var', 'procedure'
,'function', 'begin', 'end', 'if', 'then', 'else', 'while', 'do'
, 'or', 'and', 'div', 'not']
symbols = ['.', ';', ',', '(', ')', ':', '=',
'<', '>', '+', '-', '*', '[', ':=', '..']
def ... |
"""
PASSENGERS
"""
numPassengers = 19048
passenger_arriving = (
(2, 7, 5, 2, 8, 1, 2, 1, 2, 1, 0, 1, 0, 11, 2, 3, 4, 3, 0, 0, 0, 1, 0, 0, 0, 0), # 0
(10, 5, 4, 4, 7, 4, 2, 0, 1, 3, 0, 0, 0, 6, 8, 4, 3, 2, 3, 5, 3, 1, 1, 0, 0, 0), # 1
(8, 6, 11, 4, 2, 2, 4, 3, 3, 0, 1, 1, 0, 4, 4, 5, 3, 6, 1, 1, 0, 4, 0, 2, 0, 0... |
# Problem Link : https://codeforces.com/problemset/problem/339/A#
s = input()
nums = list(s[0:len(s):2])
nums.sort()
j = 0
for i in range(len(s)):
if i%2 == 0:
print(nums[j], end="")
j += 1
else:
print("+", end="")
|
#
# PySNMP MIB module CISCO-SNMPv2-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SNMPv2-CAPABILITY
# Produced by pysmi-0.3.4 at Wed May 1 12:12:36 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 ... |
description = 'Asyn serial controllers in the SINQ AMOR.'
group='lowlevel'
pvprefix = 'SQ:AMOR:serial'
devices = dict(
serial1=device(
'nicos_ess.devices.epics.extensions.EpicsCommandReply',
epicstimeout=3.0,
description='Controller of the devices connected to serial 1',
commandpv... |
# SPDX-FileCopyrightText: 2021 Pierre Constantineau
# SPDX-License-Identifier: MIT
"""
These keycodes are based on Universal Serial Bus HID Usage Tables Document
Version 1.12
Chapter 10: Keyboard/Keypad Page(0x07) - Page 53
https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
"""
class Keycode:
NO ... |
#!/usr/bin/python3
def NativeZeros(nRows, nCols):
return [range(nRows) for col in range(nCols)]
matrix = NativeZeros(4, 4)
print(matrix)
print(sum([sum(row) for row in matrix]))
|
def prepare_config_line(name, value):
"""
Create the entry for one specific configuration with it's name and value
:param name:
:param value:
:return: string
"""
conf_item = '{}'.format(name)
if value and value.lower() != 'true':
conf_item += ': {}'.format(value.capitalize())
... |
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'includes': [
'../build/win_precompile.gypi',
'../chrome/version.gypi',
'blacklist.gypi',
],
... |
elem = lambda value, next: {'value': value, 'next': next}
to_str = lambda head: '' if head is None \
else str(head['value']) + ' ' + to_str(head['next'])
values = elem(1, elem(2, elem(3, None)))
# print(to_str(values))
def make_powers(count):
powers = []
for i in range(count):
... |
class Allergies(object):
def __init__(self, score):
self.score = [allergen for num, allergen in list(enumerate([
'eggs',
'peanuts',
'shellfish',
'strawberries',
'tomatoes',
'chocolate',
'pollen',
'cats'
... |
# 1. Sort the 'people' list of dictionaries alphabetically based on the
# 'name' key from each dictionary using the 'sorted' function and store
# the new list as 'sorted_by_name'
people = [
{'name': 'Kevin Bacon', 'age': 61},
{'name': 'Fred Ward', 'age': 77},
{'name': 'finn Carter', 'age': 59},
{'name... |
# Copyright 2017 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Weights in the invoices analysis view",
"version": "13.0.1.0.0",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"category": "Inventory, Logistics, Warehousi... |
"""
Projet d'analyse: Sujet 31
Le projet: Il nous est demandรฉ d'approcher la valeur de sin(8/5) tout en certifiant nos resultats.
Cependant, avec la formule de Taylor
sur R combinรฉe a la preuve de Cauchy et a l'etablissement du certificat de convergence,
on s'est vite rendu compte qu... |
# Theory: List
# In your programs, you often need to group several elements in
# order to process them as a single object. For this, you will need
# to use different collections. One of the most useful collections
# in Python is a list. It is one of the most important things in
# Python.
# 1. Creating and printing li... |
class State(object):
def __init__(self):
pass
def enter(self):
"""Initialize data that might not be initialized in init"""
pass
def exit(self):
"""State is finished, perform cleanup if necessary"""
pass
def reason(self):
"""Conditional or l... |
# -*- python -*-
# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we as... |
class Solution:
def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]:
m = len(image)
n = len(image[0])
oldColor = image[sr][sc]
if oldColor == newColor:
return image
def dfs(r, c):
nonlocal image, new... |
#### digonal sum
digonal=[[1,2,3,5],
[4,5,6,4],
[7,8,9,3]
]
def digonaldiffernce(arr):
SUM1=0
SUM2=0
j=0
for i in arr:
SUM1+=i[j]
SUM2+=i[(len(i)-1)-j]
j+=1
return abs(SUM1-SUM2)
print(digonaldiffernce(digonal))
|
"""
Module: 'neopixel' on esp32 1.10.0
"""
# MCU: (sysname='esp32', nodename='esp32', release='1.10.0', version='v1.10 on 2019-01-25', machine='ESP32 module with ESP32')
# Stubber: 1.3.2
class NeoPixel:
''
ORDER = None
def fill():
pass
def write():
pass
def neopixel_write():
pass
... |
"""
Movie object
- title
- storyline
- poster url
- trailer url
"""
class Movie:
def __init__(self, title):
self.title = title
self.storyline = ""
self.poster_url = ""
self.trailer_url = ""
|
class Main:
class featured:
it = {'css': '#content > div.row'}
products = {'css': it['css'] + ' .product-layout'}
names = {'css': products['css'] + ' .caption h4 a'}
|
def foo(x):
print(x)
foo([x for x in range(10)])
|
def dogleg(value, units):
return_dict = {}
if units == 'deg/100ft':
return_dict['deg/100ft'] = value
return_dict['deg/30m'] = value * 0.9843004
elif units == 'deg/30m':
return_dict['deg/100ft'] = value * 1.01595
return_dict['deg/30m'] = value
return return_dict
def axia... |
# V0
# V1
# http://bookshadow.com/weblog/2016/10/13/leetcode-battleships-in-a-board/
# IDEA : GREEDY
class Solution(object):
def countBattleships(self, board):
"""
:type board: List[List[str]]
:rtype: int
"""
h = len(board)
w = len(board[0]) if h else 0
an... |
DYNAMIC_API_URL = 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history'
GET_DYNAMIC_DETAIL_API_URL = 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail'
USER_INFO_API_URL = 'https://api.bilibili.com/x/space/acc/info'
DYNAMIC_URL = 'https://t.bilibili.com/'
|
def readDiary():
day = input("What day do you want to read? ")
file = open(day, "r")
line = file.read()
print(line)
file.close()
def writeDiary():
day = input("What day is your diary for? ")
file = open(day, "w")
line = input("Enter entry: ")
file.write(line)
file.close()
... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def numComponents(self, head, G):
"""
:type head: ListNode
:type G: List[int]
:rtype: int
"""
bits = []
... |
T = int(input())
for c in range(T):
N = int(input())
sum = N * (N + 1) // 2
sqs = N * (N + 1) * (2 * N + 1) // 6
d = sum * sum - sqs
print(abs(d))
|
# This file is part of Pynguin.
#
# Pynguin is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pynguin is distributed in the ho... |
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
class Opencv(CMakePackage, CudaPackage):
"""OpenCV (Open Source Computer Vision Library) is an open source computer
... |
# @Vipin Chaudhari
host='192.168.1.15'
meetup_rsvp_stream_api_url = "http://stream.meetup.com/2/rsvps"
# Kafka info
kafka_topic = "meetup-rsvp-topic"
kafka_server = host+':9092'
# MySQL info
mysql_user = "python"
mysql_pwd = "python"
mysql_db = "meetup"
mysql_driver = "com.mysql.cj.jdbc.Driver"
mys... |
class Layer:
def __init__(self):
self.input = None
self.output = None
def forward_propagation(self,input):
raise NotImplementedError
def backward_propagation(self, output_error,learning_rate):
raise NotImplementedError |
def to_fp_name(path, prefix='fp'):
if path == 'stdout':
return 'stdout'
if path == 'stderr':
return 'stderr'
if path == 'stdin':
return 'stdin'
# For now, just construct a fd variable name by taking objectionable chars out of the path
cleaned = path.replace('.', '_').replac... |
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def lowestCommonAncestor(self, root: TreeNode, p: TreeNode, q: TreeNode) -> TreeNode:
if root is None:
return None
left = self.lo... |
# instance/config.cfg
SQLALCHEMY_DATABASE_URI= \
"mysql://microaccounts_dev:r783qjkldDsiu@localhost:3306/elixir_beacon_testing"
SECRET_KEY= \
"nsady679d8+eiqรฅowmยดยด`msdjjwi"
|
#!/usr/bin/env python
#pylint: skip-file
# This source code is licensed under the Apache license found in the
# LICENSE file in the root directory of this project.
class AclAce(object):
def __init__(self):
"""
Attributes:
swaggerTypes (dict): The key is attribute name and the value is ... |
class MarginGetError(Exception):
pass
class PositionGetError(Exception):
pass
class TickGetError(Exception):
pass
class TradeGetError(Exception):
pass
class BarGetError(Exception):
pass
class FillGetError(Exception):
pass
class OrderPostError(Exception):
pass
class OrderGetErro... |
class MyStuff(object):
def __init__(self):
self.stark = "I am classy Iron Man."
def groot(self):
print("I am classy groot!")
thing = MyStuff()
thing.groot()
print(thing.stark)
|
expected_output = {
"GigabitEthernet0/1/1": {
"service_policy": {
"output": {
"policy_name": {
"shape-out": {
"class_map": {
"class-default": {
"bytes": 0,
... |
class MXVLANPorts(object):
def __init__(self, session):
super(MXVLANPorts, self).__init__()
self._session = session
def getNetworkAppliancePorts(self, networkId: str):
"""
**List per-port VLAN settings for all ports of a MX.**
https://developer.cisco.com/meraki/api/#... |
TOKEN = '668308467:AAETX4hdMRnVvYVBP4bK5WDgvL8zIXoHq5g'
main_url = 'https://schedule.vekclub.com/api/v1/'
list_group = 'handbook/groups-by-institution?institutionId=4'
shedule_group ='schedule/group?groupId=' |
# -*- coding: utf-8 -*-
"""This module contains exceptions
"""
class PublishError(RuntimeError):
"""Raised when the published version is not matching the quality
"""
pass
|
# SOME BASIC CONSTANT AND MASS FUNCTION OF POISSION DISTRIBUTION
# e is Euler's number (e = 2.71828...)
# f(k, lambda) = lambda^k * e^-lambda / k!
# Task:
# A random variable, X , follows Poisson distribution with mean of 2.5. Find the probability with which the random variable X is equal to 5.
# Define functions
d... |
s1 = {'ab', 3,4, (5,6)}
s2 = {'ab', 7, (7,6)}
print(s1-s2)
# Returns all the items in both s1 and s2
print(s1.intersection(s2))
# Returns all the items in a set
print(s1.union(s2))
print('ab' in s1) # Testing for a member's presence in the set
# Lopping through elements in a set
for element in s1:
print(elemen... |
# Programa que converte metros em medidas
print('Conversor de metros\n')
medida = float(input('Insira uma medida em metros: '))
print('Essa medida correponde a\nQuilรดmetros: {:.2f}\nHectรดmetros: {:.2f}\nDecรขmetros: {:.2f}\nDecรญmetros: {:.2f}\nCentรญmetros: {:.2f}\nMilรญmetros: {:.2f}'.format(medida/1000, medida/1... |
AI_FEEDBACK_SCALAS = {
1: "Strongly disagree",
2: "",
3: "",
4: "",
5: "",
6: "",
7: "Strongly agree"
}
AI_FEEDBACK_ACCURACY_SCALAS = {
"no_clue": "I don't know",
"0_percent": "0%",
"20_percent": "20%",
"40_percent": "40%",
"60_percent": "60%",
"80_percent": "80%",
... |
# -*- coding: utf-8 -*-
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def tree2str(self, t):
if t is None:
return ''
result = [str(t.val)]
if t.left is not None or t.right is not None:
... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Simulation : https://framagit.org/kepon/PvMonit/issues/8
# ~ print("PID:0x203");
# ~ print("FW:146");
# ~ print("SER#:HQ18523ZGZI");
# ~ print("V:25260");
# ~ print("I:100");
# ~ print("VPV:28600");
# ~ print("PPV:6");
# ~ print("CS:3");
# ~ print("MPPT:2");
# ~ print("OR:0... |
# Uso de variรกveis em Strings
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
print(full_name)
# Podemos usar f-strings para escrever mensagens completas usando as informaรงรตes associadas a uma variรกvel
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"... |
def check_prime(n):
f = 0
for i in range (2, n//2 +1):
if n%i==0 :
f= 1
break
return f
def min_range(d):
a = (10**(d-1))
return a
def max_range(d):
b = (10**d)
return b
d=int(input("Enter d"))
twin_prime_list = []
for i in range ( min_range(... |
print (" ****** Bienvenido a Calculadora Basica 2020 ****** ")
print (" -------------------------------------------------------- ")
num = input("Ingresar el nรบmero entero a calcular: \n")
calculo = input("Ingresar el simbolo de la operaciรณn que desea realizar: (+,-,*,/) \n")
num_dos = input("Ingresar el siguiente nรบ... |
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 29 10:24:19 2021
@author: USUARIO
"""
|
def valid_parentheses(string):
count = 0
for bracket in string:
if count < 0:
return False
if bracket == "(":
count += 1
if bracket == ")":
count -= 1
else:
continue
return count == 0
def testing():
a = "()"
b = True
... |
# 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
# DFS
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
self.ans = []
self.dfs(root, 0)
... |
"""
Calculates compound interest over a specified time period.
Since:
1.0.0
Catergory:
Maths
Args:
param1 (int) investment: The amount of original investment.
param2 (int) rate: Interest rate in whole number. i.e. 2% = 2.
param3 (int) time: Length of investment. Used to exponentially raise total.... |
# Copyright (c) 2016 Alexander Sosedkin <monk@unboiled.info>
# Distributed under the terms of the MIT License, see below:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction... |
"""
"""
class ConfigurationManager(object):
def __init__(self, full_config):
self._full_config = full_config
def get(self, task_key):
self.result_config = {}
self.current_config = self._full_config.copy()
[self._add_task_options(task_option) for task_option in task_key.spli... |
numbers = (input("enter the value of a number"))
def divisors(numbers):
array = []
for item in range(1, numbers):
if(numbers % item == 0):
print("divisors items", item)
array.append(item)
print(array)
# print("all items",item)
divisors(numbers)
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
mw_util.py
Set of helper functions while dealing with MediaWiki.
str2cat
Adds prefix Category if string doesn't have it.
"""
def str2cat(category):
"""Return a category name starting with Category."""
prefix = "Category:"
if not category.star... |
#!/usr/bin/python3
target = 10
def showVar(a, b):
global target
target = target + b
print('่ฎฟ้ฎtaget:{}'.format(target))
return target
def insert(sql, values):
print("exec sql : {}".format(sql))
print("insert into values:{}".format(values))
return True
showVar(12, 12)
print('ๅ
จๅฑ่ๅดๅ
็targe... |
# Space : O(n)
# Time : O(n**2)
class Solution:
def jump(self, nums: List[int]) -> int:
n = len(nums)
dp = [10**5] * n
dp[0] = 0
if n == 1:
return 0
for i in range(n):
for j in range(nums[i]):
dp[j+i+1] = min(dp[j+i+... |
# -*- coding: utf-8 -*-
"""
Created on 2018-03-
@author: Frank Dip
"""
s = "hello boy"
for i,j in enumerate(s):
print(i, j)
|
while True:
a = input()
if int(a) == 42:
break;
print(int(a))
|
# -*- coding: utf-8 -*-
# Contributors : [srinivas.v@toyotaconnected.co.in,srivathsan.govindarajan@toyotaconnected.co.in,
# harshavardhan.thirupathi@toyotaconnected.co.in,
# ashok.ramadass@toyotaconnected.com ]
class CoefficientNotinRangeError(Exception):
"""
Class to throw exception when a coefficient is ... |
class Solution:
"""
@param matrix: A 2D-array of integers
@return: an integer
"""
def longestContinuousIncreasingSubsequence2(self, matrix):
# write your code here
if not matrix or not matrix[0]:
return 0
m, n = len(matrix), len(matrix[0])
visited = [[0] *... |
__version__ = '0.0.7'
def get_version():
return __version__
|
# -*- coding: utf-8 -*-
"""
solace.views
~~~~~~~~~~~~
All the view functions are implemented in this package.
:copyright: (c) 2009 by Plurk Inc., see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
|
class BaseASHException(Exception):
"""A base exception handler for the ASH ecosystem."""
def __init__(self, *args):
if args:
self.message = args[0]
else:
self.message = self.__doc__
def __str__(self):
return self.message
class DuplicateObject(BaseASHExcept... |
#Question:1
# Initializing matrix
matrix = []
# Taking input from user of rows and column
row = int(input("Enter the number of rows:"))
column = int(input("Enter the number of columns:"))
print("Enter the elements row wise:")
# Getting elements of matrix from user
for i in range(row):
a =[]
... |
devices = \
{
# -------------------------------------------------------------------------
# NXP ARM7TDMI devices Series LPC21xx, LPC22xx, LPC23xx, LPC24xx
"lpc2129":
{
"defines": ["__ARM_LPC2000__"],
"linkerscript": "arm7/lpc/linker/lpc2129.ld",
"size": { "flash": 262144, "ram": 16384 },
},
"lpc2368":
{... |
WALK_UP = 4
WALK_DOWN = 3
WALK_RIGHT = 2
WALK_LEFT = 1
NO_OP = 0
SHOOT = 5
WALK_ACTIONS = [WALK_UP, WALK_DOWN, WALK_RIGHT, WALK_LEFT]
ACTIONS = [NO_OP, WALK_LEFT, WALK_RIGHT, WALK_DOWN, WALK_UP, SHOOT]
|
# Day Six: Lanternfish
file = open("input/06.txt").readlines()
ages = []
for num in file[0].split(","):
ages.append(int(num))
for day in range(80):
for i, fish in enumerate(ages):
if fish == 0:
ages[i] = 6
ages.append(9)
else:
ages[i] = fish-1
print(len(age... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# https://leetcode.com/problems/subarray-sum-equals-k/description/
# I think it is a sub-problem of: https://leetcode.com/problems/path-sum-iii/description/
class Solution(object):
def subarraySum(self, nums, k):
"""
:type nums: List[int]
:ty... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.