content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def data(Type, value):
'''
Type (NAME | FLOAT | NUMBER | STRING)
'''
return (Type, {'value': value})
def expression(op, lhs, rhs):
'''
lhs (left-hand-side)
rhs (right-hand-side)
op (operator)
'''
return ('Expression', {'op': op, 'lhs': lhs, 'rhs': rhs})
def var_assign(name, ... | def data(Type, value):
"""
Type (NAME | FLOAT | NUMBER | STRING)
"""
return (Type, {'value': value})
def expression(op, lhs, rhs):
"""
lhs (left-hand-side)
rhs (right-hand-side)
op (operator)
"""
return ('Expression', {'op': op, 'lhs': lhs, 'rhs': rhs})
def var_assign(name, val... |
class Watchdog:
def waitForData(self):
data = self.Socket.recv(1024)
print(data)
return data
def sendData(self,data):
print(data)
return self.Socket.send(data.encode("UTF-8"))
def __init__(self, clientSocket):
self.Socket = clientSocket | class Watchdog:
def wait_for_data(self):
data = self.Socket.recv(1024)
print(data)
return data
def send_data(self, data):
print(data)
return self.Socket.send(data.encode('UTF-8'))
def __init__(self, clientSocket):
self.Socket = clientSocket |
# 1.4) check if palindrome permutation
def palindrome_permutation(str=''):
if len(str) < 2:
return False
frequencies = {}
not_even_count = 0
for char in str.lower():
if char == ' ':
continue
frequencies[char] = 1 + frequencies.get(char, 0)
for number in frequ... | def palindrome_permutation(str=''):
if len(str) < 2:
return False
frequencies = {}
not_even_count = 0
for char in str.lower():
if char == ' ':
continue
frequencies[char] = 1 + frequencies.get(char, 0)
for number in frequencies.values():
if number % 2 != 0:... |
#
# PySNMP MIB module HOST-RESOURCES-V2-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HOST-RESOURCES-V2-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:20:16 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class AdversarialMachine():
'''
An abstract adversarial learning-to-rank framework
'''
def __init__(self, eval_dict=None, data_dict=None, gpu=False, device=None):
#todo double-check the necessity of these two arguments
self.eval_dict = eva... | class Adversarialmachine:
"""
An abstract adversarial learning-to-rank framework
"""
def __init__(self, eval_dict=None, data_dict=None, gpu=False, device=None):
self.eval_dict = eval_dict
self.data_dict = data_dict
(self.gpu, self.device) = (gpu, device)
def pre_check(self)... |
# -*- coding: utf-8 -*-
"""Packages to be installed by the system package manager."""
ZYPPER = (
"gawk",
"coreutils",
"-t pattern devel_basis",
"gcc",
"gcc-fortran",
"util-linux",
"R-base",
"bc",
"lshw",
"numactl",
"java",
"libaio",
"python",
)
YUM = (
"epel-rel... | """Packages to be installed by the system package manager."""
zypper = ('gawk', 'coreutils', '-t pattern devel_basis', 'gcc', 'gcc-fortran', 'util-linux', 'R-base', 'bc', 'lshw', 'numactl', 'java', 'libaio', 'python')
yum = ('epel-release', 'gawk', 'coreutils', 'gcc', 'gcc-gfortran', 'util-linux', 'R', 'R-littler', 'bc... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: mcxiaoke
# @Date: 2015-08-18 20:14:05
INVALID_CHARS='/\\<>:?*"|'
def get_safe_filename(text):
text=text.replace(':', 'x')
for c in INVALID_CHARS:
if c in text:
text = text.replace(c, "_")
| invalid_chars = '/\\<>:?*"|'
def get_safe_filename(text):
text = text.replace(':', 'x')
for c in INVALID_CHARS:
if c in text:
text = text.replace(c, '_') |
server_records_from_cap = {
"@id": "doc:server",
"@type": "terminus:Server",
"rdfs:comment": {"@language": "en", "@value": "The current Database Server itself"},
"rdfs:label": {"@language": "en", "@value": "The DB server"},
"terminus:allow_origin": {"@type": "xsd:string", "@value": "*"},
"termin... | server_records_from_cap = {'@id': 'doc:server', '@type': 'terminus:Server', 'rdfs:comment': {'@language': 'en', '@value': 'The current Database Server itself'}, 'rdfs:label': {'@language': 'en', '@value': 'The DB server'}, 'terminus:allow_origin': {'@type': 'xsd:string', '@value': '*'}, 'terminus:resource_includes': [{... |
command = '/opt/django/mikaponics-back/env/bin/gunicorn'
pythonpath = '/opt/django/mikaponics-back/mikaponics'
bind = '127.0.0.1:8001'
workers = 3
| command = '/opt/django/mikaponics-back/env/bin/gunicorn'
pythonpath = '/opt/django/mikaponics-back/mikaponics'
bind = '127.0.0.1:8001'
workers = 3 |
treatment = [
{
"id": "1",
"name": "Dactolisib",
"data_source": "TRACE"
},
{
"id": "2",
"name": "capecitabine",
"data_source": "TRACE"
},
{
"id": "3",
"name": "PREDNISONE",
"data_source": "TRACE"
},
{
"id": "4",
... | treatment = [{'id': '1', 'name': 'Dactolisib', 'data_source': 'TRACE'}, {'id': '2', 'name': 'capecitabine', 'data_source': 'TRACE'}, {'id': '3', 'name': 'PREDNISONE', 'data_source': 'TRACE'}, {'id': '4', 'name': 'FU-LV regimen', 'data_source': 'TRACE'}]
treatment_and_component_helper = [{'treatment_protocol_id': '1', '... |
CLUSTER_COL = "cluster"
COUNT_COL = "count"
RECOMMENDED_COL = "recommended"
CLUSTER_COUNT_COL = "cluster_count"
CLUSTER_SUM_COL = "cluster_sum"
NGRAM_COL = "ngram"
FINGERPRINT_COL = "fingerprint"
NGRAM_FINGERPRINT_COL = "ngram_fingerprint"
LEVENSHTEIN_DISTANCE = "LEVENSHTEIN_DISTANCE"
STRING_TO_INDEX = "string_to_ind... | cluster_col = 'cluster'
count_col = 'count'
recommended_col = 'recommended'
cluster_count_col = 'cluster_count'
cluster_sum_col = 'cluster_sum'
ngram_col = 'ngram'
fingerprint_col = 'fingerprint'
ngram_fingerprint_col = 'ngram_fingerprint'
levenshtein_distance = 'LEVENSHTEIN_DISTANCE'
string_to_index = 'string_to_index... |
#
# PySNMP MIB module TIMETRA-QOS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-QOS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:17:06 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint, constraints_union) ... |
#
# PySNMP MIB module CISCO-FC-SPAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FC-SPAN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:58:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ... |
# Source : https://github.com/mission-peace/interview/blob/master/python/dynamic/longest_increasing_subsequence.py
# Find a subsequence in given array in which the subsequence's elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible.
# Time Complexity: O(N^2), Space Compl... | def longest_increasing_subsequence(arr):
length_arr = len(arr)
longest = float('-inf')
for idx in range(length_arr - 1):
longest_so_far = longest_increasing_subsequence_recursive(arr, idx + 1, arr[idx])
longest = max(longest, longest_so_far)
return longest + 1
def longest_increasing_sub... |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may... | table_name = 'birth_names'
num_girls = 'num_girls'
num_boys = 'num_boys'
state = 'state'
num = 'num'
name = 'name'
gender = 'gender'
ds = 'ds'
girl = 'girl'
boy = 'boy' |
#Copyright (c) 2016 Vidhya, Nandini
#Following code is available for use under MIT license. Please see the LICENSE file for details.
#This project uses as constant the genres we need to train with and classify into. This constant list of genres is stored in this file and is included in others for prediction.
# This i... | genres = ['folk', 'reggae', 'punk', 'classical', 'electronica', 'hip hop', 'rock', 'metal', 'pop', 'jazz'] |
fah = float(input("Qual a temperatura em farenheit ==> "))
celsius = 0.56 * (fah-32)
print("A temperatura de", fah, "farenheit equivale a", celsius, "celsius")
| fah = float(input('Qual a temperatura em farenheit ==> '))
celsius = 0.56 * (fah - 32)
print('A temperatura de', fah, 'farenheit equivale a', celsius, 'celsius') |
# coding: utf-8
BASE_DOCS_URL = 'https://developer.zendesk.com/rest_api/docs/support'
RESOURCE_MAPPING = {
'organizations': {
'resource': 'organizations.json',
'docs': '{0}/organizations'.format(BASE_DOCS_URL)
},
'tickets': {
'resource': 'tickets.json',
'docs': '{0}/tickets... | base_docs_url = 'https://developer.zendesk.com/rest_api/docs/support'
resource_mapping = {'organizations': {'resource': 'organizations.json', 'docs': '{0}/organizations'.format(BASE_DOCS_URL)}, 'tickets': {'resource': 'tickets.json', 'docs': '{0}/tickets'.format(BASE_DOCS_URL)}, 'create_many_tickets': {'resource': 'tic... |
# Copyright 2016 VMware, 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 appl... | i_pv4_any = '0.0.0.0/0'
proto_name_ah = 'ah'
proto_name_dccp = 'dccp'
proto_name_egp = 'egp'
proto_name_esp = 'esp'
proto_name_gre = 'gre'
proto_name_icmp = 'icmp'
proto_name_igmp = 'igmp'
proto_name_ipip = 'ipip'
proto_name_ipv6_encap = 'ipv6-encap'
proto_name_ipv6_frag = 'ipv6-frag'
proto_name_ipv6_icmp = 'ipv6-icmp'... |
###########################################
# Functional Tests to test all home pages #
###########################################
def test_home_page(test_client):
"""
GIVEN a Flask application
WHEN the '/' page is requested (GET)
THEN check if is redirected to the right route:
1. if the response is valid
2. ... | def test_home_page(test_client):
"""
GIVEN a Flask application
WHEN the '/' page is requested (GET)
THEN check if is redirected to the right route:
1. if the response is valid
2. if it renders the right template
(template **templates/start.html** has page title 'Homepage')
"""
response = test_clie... |
"""
Created on March 30, 2018
@author: Alejandro Molina
"""
| """
Created on March 30, 2018
@author: Alejandro Molina
""" |
## Insertion Sort
def insertion_sort(arr, n):
"""
Given an array/list of integers,
return sorted array
"""
for i in range(1, n):
key = arr[i]
j = i-1
while j >= 0 and key < arr[j]:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key | def insertion_sort(arr, n):
"""
Given an array/list of integers,
return sorted array
"""
for i in range(1, n):
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j]:
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key |
n= int(input())
for i in range(1,n+1):
u= (i**3 + 2*i)
print(u,end=',')
| n = int(input())
for i in range(1, n + 1):
u = i ** 3 + 2 * i
print(u, end=',') |
# File: ipcontrol_consts.py
# Copyright (c) 2021 Splunk Inc.
#
# Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
IPCONTROL_ENDPOINT_LOGIN = '/login'
IPCONTROL_ENDPOINT = '/inc-rest/api/v1'
IPCONTROL_ENDPOINT_GET_CHILD_BLOCK = '/Exports/initExportChildBlock'
IPCONTROL_ENDPOINT_GET_HOSTNAME =... | ipcontrol_endpoint_login = '/login'
ipcontrol_endpoint = '/inc-rest/api/v1'
ipcontrol_endpoint_get_child_block = '/Exports/initExportChildBlock'
ipcontrol_endpoint_get_hostname = '/Gets/getDeviceByIPAddr?ipAddress='
ipcontrol_endpoint_get_block_type = '/Exports/initExportChildBlock'
ipcontrol_endpoint_get_ip_address = ... |
# using if statement in complex situation
# elif
country= input("Where are you form?\n").upper()
if country=="ENGLAND":
print("Hello!")
elif country=="GERMANY":# elif allows us to check for different values. It means else-if.
print("Gutan Tag!")
elif country=="FRANCE":
print("Bonjour!")
elif country=="MEXI... | country = input('Where are you form?\n').upper()
if country == 'ENGLAND':
print('Hello!')
elif country == 'GERMANY':
print('Gutan Tag!')
elif country == 'FRANCE':
print('Bonjour!')
elif country == 'MEXICO':
print('Ola Amigo!')
elif country == 'INDIA':
print('Namaste!')
else:
print('Hey!')
deposi... |
def input():
with open("input-20.txt") as lines:
for line in lines:
yield line.strip()
input = input()
enhancer = next(input)
assert len(enhancer) == 512
assert next(input) == ""
pixels = {(x, y): c for y, row in enumerate(input) for x, c in enumerate(row)}
class Image:
def __init__(self... | def input():
with open('input-20.txt') as lines:
for line in lines:
yield line.strip()
input = input()
enhancer = next(input)
assert len(enhancer) == 512
assert next(input) == ''
pixels = {(x, y): c for (y, row) in enumerate(input) for (x, c) in enumerate(row)}
class Image:
def __init__(se... |
# -*- coding: utf-8 -*-
author = 'thecokerdavid'
| author = 'thecokerdavid' |
"""Top-level package for Starter."""
__author__ = ""
__email__ = ""
__version__ = "0.1.0"
| """Top-level package for Starter."""
__author__ = ''
__email__ = ''
__version__ = '0.1.0' |
class LogMessages:
GW_SERVER_LISTENING = 'RD Gateway server listening on {}:{}'
GW_FAILED_PROCESS_HTTP_REQUEST = 'Failed to process HTTP request'
GW_ATTEMPT_NON_WEBSOCKET = 'Unsupported attempt to connect without WebSocket'
WEBSOCKET_RECEIVED_CONNECTION_REQUEST = 'Received WebSocket connec... | class Logmessages:
gw_server_listening = 'RD Gateway server listening on {}:{}'
gw_failed_process_http_request = 'Failed to process HTTP request'
gw_attempt_non_websocket = 'Unsupported attempt to connect without WebSocket'
websocket_received_connection_request = 'Received WebSocket connection request'
... |
# settings that are specific to Flask-User
class AuthConfig(object):
USER_ENABLE_USERNAMES = False
USER_ENABLE_CHANGE_USERNAME = False
USER_ENABLE_REGISTER = True
USER_ENABLE_INVITATION = True
USER_REQUIRE_INVITATION = True
USER_APP_NAME = "Clear My Record"
# def set_default_settings(user_mana... | class Authconfig(object):
user_enable_usernames = False
user_enable_change_username = False
user_enable_register = True
user_enable_invitation = True
user_require_invitation = True
user_app_name = 'Clear My Record' |
class Solution:
def corpFlightBookings(self, bookings: List[List[int]], n: int) -> List[int]:
dp = [0] * n
for i, j, k in bookings:
dp[i - 1] += k
if j < n:
dp[j] -= k
result = [0] * n
result[0] = dp[0]
for i in range(1, n):
... | class Solution:
def corp_flight_bookings(self, bookings: List[List[int]], n: int) -> List[int]:
dp = [0] * n
for (i, j, k) in bookings:
dp[i - 1] += k
if j < n:
dp[j] -= k
result = [0] * n
result[0] = dp[0]
for i in range(1, n):
... |
#!/bin/bash
x = 99
def f1():
x = 88
def f2():
print(x)
f2()
f1()
| x = 99
def f1():
x = 88
def f2():
print(x)
f2()
f1() |
# -*- coding: utf-8 -*-
"""@package Methods.Machine.MagnetType10.comp_surface
Compute the Magnet surface method
@date Created on Wed Dec 17 14:56:19 2014
@copyright (C) 2014-2015 EOMYS ENGINEERING.
@author pierre_b
"""
def comp_surface(self):
"""Compute the Magnet surface (by analytical computation)
Paramete... | """@package Methods.Machine.MagnetType10.comp_surface
Compute the Magnet surface method
@date Created on Wed Dec 17 14:56:19 2014
@copyright (C) 2014-2015 EOMYS ENGINEERING.
@author pierre_b
"""
def comp_surface(self):
"""Compute the Magnet surface (by analytical computation)
Parameters
----------
sel... |
class Solution:
def maxProfit(self, prices: List[int]) -> int:
low = prices[0]
ans = 0
for i in range(1, len(prices)):
low = min(low, prices[i])
ans = max(prices[i] - low, ans)
return ans | class Solution:
def max_profit(self, prices: List[int]) -> int:
low = prices[0]
ans = 0
for i in range(1, len(prices)):
low = min(low, prices[i])
ans = max(prices[i] - low, ans)
return ans |
# Copyright 2021 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
"""This module contains the return codes used in the returncode structure"""
# General success code
SUCCESS = 0
# General error codes
GENERALERROR = 1000
MISSINGFIELDS = 1100
NORESULT = 1200
# Element managemen... | """This module contains the return codes used in the returncode structure"""
success = 0
generalerror = 1000
missingfields = 1100
noresult = 1200
additemfail = 1200
itemdoesnotexist = 1201
deleteitemfail = 1202
updateitemfail = 1203
evalreadyexists = 1250
claimsuccessful = SUCCESS
addclaimfail = 1300
unknowntaprotocol ... |
class Solution:
def wordsAbbreviation(self, words: List[str]) -> List[str]:
def compute_LCP(w1, w2):
cnt = 0
for i, (c1, c2) in enumerate(zip(w1, w2)):
if c1 == c2:
cnt += 1
else:
break
return cnt
... | class Solution:
def words_abbreviation(self, words: List[str]) -> List[str]:
def compute_lcp(w1, w2):
cnt = 0
for (i, (c1, c2)) in enumerate(zip(w1, w2)):
if c1 == c2:
cnt += 1
else:
break
return cn... |
def load_rom_raw(filename):
"""
Loads the data from a .nes file as the nesheader and the rom data without further processing
:param filename:
:return:
"""
with open(filename, "rb") as f:
nesheader = f.read(16)
bytecode = f.read()
return bytecode, nesheader
def load_palette(... | def load_rom_raw(filename):
"""
Loads the data from a .nes file as the nesheader and the rom data without further processing
:param filename:
:return:
"""
with open(filename, 'rb') as f:
nesheader = f.read(16)
bytecode = f.read()
return (bytecode, nesheader)
def load_palette... |
def palindrome(s):
s=s.replace(" ",'')
reverse=s[::-1]
if s==reverse:
return True
else:
return False
| def palindrome(s):
s = s.replace(' ', '')
reverse = s[::-1]
if s == reverse:
return True
else:
return False |
for _ in range(int(input())):
inp = input().lower()
cha = list('abcdefghijklmnopqrstuvwxyz')
for i in inp:
if i in cha: cha.remove(i)
if len(cha)==0: print('pangram')
else: print('missing', ''.join(cha)) | for _ in range(int(input())):
inp = input().lower()
cha = list('abcdefghijklmnopqrstuvwxyz')
for i in inp:
if i in cha:
cha.remove(i)
if len(cha) == 0:
print('pangram')
else:
print('missing', ''.join(cha)) |
#!/usr/bin/env python3
"""
The icarus NMR logging handler process. The process subscribes to a set of PVs and logs them into a file for further inspection.
"""
if __name__ == '__main__':
pass
| """
The icarus NMR logging handler process. The process subscribes to a set of PVs and logs them into a file for further inspection.
"""
if __name__ == '__main__':
pass |
msg = 'Hello World'
print(msg[8])
print(msg[-3])
tinker = 'Tinker'
print(tinker[1:4])
numbers = '123456789'
even = numbers[1:9:2]
odd = numbers[0:10:2]
print(even, odd)
| msg = 'Hello World'
print(msg[8])
print(msg[-3])
tinker = 'Tinker'
print(tinker[1:4])
numbers = '123456789'
even = numbers[1:9:2]
odd = numbers[0:10:2]
print(even, odd) |
string1 = "Linux"
string2 = "Hint"
joined_string = string1 + string2
print(joined_string)
| string1 = 'Linux'
string2 = 'Hint'
joined_string = string1 + string2
print(joined_string) |
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def deleteNode(self, root, key):
"""
:type root: TreeNode
:type key: int
:rtype: TreeNode
"... | class Treenode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def delete_node(self, root, key):
"""
:type root: TreeNode
:type key: int
:rtype: TreeNode
"""
fake_root = tree_node(0... |
N, M, X, Y = map(int, input().rstrip().split())
a = list(map(int, input().rstrip().split()))
a = [n for n in a if n > Y]
if len(a) <= M:
print(sum(a))
else:
a.sort()
while True:
n = a.pop(0)
if n >= X:
print('Handicapped')
exit()
if len(a) <= M:
print(sum(a))
exit() | (n, m, x, y) = map(int, input().rstrip().split())
a = list(map(int, input().rstrip().split()))
a = [n for n in a if n > Y]
if len(a) <= M:
print(sum(a))
else:
a.sort()
while True:
n = a.pop(0)
if n >= X:
print('Handicapped')
exit()
if len(a) <= M:
... |
class Solution:
def maxDepth(self, root: 'Node') -> int:
if not root:
return 0
if not root.children:
return 1
return 1 + max(self.maxDepth(child) for child in root.children)
| class Solution:
def max_depth(self, root: 'Node') -> int:
if not root:
return 0
if not root.children:
return 1
return 1 + max((self.maxDepth(child) for child in root.children)) |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-11-26 01:20:25
# @Author : Racter Liu (racterub) (racterub@gmail.com)
# @Link : https://racterub.io
# @License : MIT
def has_dups(data):
for i in data:
if data.count(i) > 1:
return True
else:
return False
... | def has_dups(data):
for i in data:
if data.count(i) > 1:
return True
else:
return False
print(has_dups([1, 2, 3, 4, 5]))
print(has_dups([1, 2, 1, 3, 4, 5])) |
"""A Text Block Generator"""
def lines(file):
"""Lines generator"""
for line in file:
yield line
yield '\n'
def blocks(file):
"""Blocks generator"""
block = []
for line in lines(file):
if line.strip():
block.append(line)
elif block:
yield ''.join... | """A Text Block Generator"""
def lines(file):
"""Lines generator"""
for line in file:
yield line
yield '\n'
def blocks(file):
"""Blocks generator"""
block = []
for line in lines(file):
if line.strip():
block.append(line)
elif block:
yield ''.join... |
class Prays:
TheBenedictus = 'Blessed be the Lord, the God of Israel he has come to his people and set them free.\
He has raised up for us a mighty savior,\
born of the house of his servant David.\
Through his holy prophets he promised of old\
that he would save us from our enemies,\... | class Prays:
the_benedictus = 'Blessed be the Lord, the God of Israel he has come to his people and set them free. He has raised up for us a mighty savior, born of the house of his servant David. Through his holy prophets he promised of old that he would save us from our enemies, ... |
# https://leetcode.com/problems/count-the-number-of-consistent-strings/
class Solution:
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
dictx = {}
for each in allowed:
dictx[each] = 1
count = 0
for each in ... | class Solution:
def count_consistent_strings(self, allowed: str, words: List[str]) -> int:
dictx = {}
for each in allowed:
dictx[each] = 1
count = 0
for each in words:
flag = True
for i in range(0, len(each)):
if each[i] not in dic... |
test_str = "111"
def show():
print(__name__, "show")
| test_str = '111'
def show():
print(__name__, 'show') |
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
s_nums = sorted(nums)
l = len(nums)
for i, num in enumerate(nums):
t = target - num
o = bisect.bisect_left(s_nums, t)
if o <l:
if t == s_nums[o]:
... | class Solution:
def two_sum(self, nums: List[int], target: int) -> List[int]:
s_nums = sorted(nums)
l = len(nums)
for (i, num) in enumerate(nums):
t = target - num
o = bisect.bisect_left(s_nums, t)
if o < l:
if t == s_nums[o]:
... |
class RangeSlicer:
@staticmethod
def get_sliced_range(start_block: int, end_block: int, step: int):
for index, block_index_breakpoint in enumerate(range(start_block, end_block+step, step)):
if not index:
continue
if block_index_breakpoint > end_block:
... | class Rangeslicer:
@staticmethod
def get_sliced_range(start_block: int, end_block: int, step: int):
for (index, block_index_breakpoint) in enumerate(range(start_block, end_block + step, step)):
if not index:
continue
if block_index_breakpoint > end_block:
... |
#!/usr/bin/python
europe = []
germany = {"name": "Germany", "population": 81000000, "price": 1000}
europe.append(germany)
luxembourg = {"name": "Luxembourg", "population": 512000, "price": 2000}
europe.append(luxembourg)
andorra = {"name": "Andorra", "population": 900000, "price": 3000}
europe.append(andorra)
print(le... | europe = []
germany = {'name': 'Germany', 'population': 81000000, 'price': 1000}
europe.append(germany)
luxembourg = {'name': 'Luxembourg', 'population': 512000, 'price': 2000}
europe.append(luxembourg)
andorra = {'name': 'Andorra', 'population': 900000, 'price': 3000}
europe.append(andorra)
print(len(europe))
europe2 ... |
go = goat = """\
___.
// \\\\
(( ''
\\\\__,
/6 (%)\\,
(__/:";,;\\--____----_
;; :';,:';`;,';,;';`,`_
;:,;;';';,;':,';';,-Y\\
;,;,;';';,;':;';'; Z/
/ ;,';';,;';,;';;'
/ / |';/~~~~~\\';;'
( K | | || |
\\_\\ | | || |
\\Z | | || |
L_| LL_|
LW/ LLW... | go = goat = ' ___.\n // \\\\\n (( \'\'\n \\\\__,\n /6 (%)\\,\n(__/:";,;\\--____----_\n ;; :\';,:\';`;,\';,;\';`,`_\n ;:,;;\';\';,;\':,\';\';,-Y\\\n ;,;,;\';\';,;\':;\';\'; Z/\n / ;,\';\';,;\';,;\';;\'\n / / |\';/~~~~~\\\';;\'\n ( K | | || |\n \\_\\ | | || |\n \\Z | | || |\n ... |
LONG_TIMEOUT = 30.0 # For wifi scan
SHORT_TIMEOUT = 10.0 # For any other command
DEFAULT_MEROSS_HTTP_API = "https://iot.meross.com"
DEFAULT_MQTT_HOST = "mqtt.meross.com"
DEFAULT_MQTT_PORT = 443
DEFAULT_COMMAND_TIMEOUT = 10.0
| long_timeout = 30.0
short_timeout = 10.0
default_meross_http_api = 'https://iot.meross.com'
default_mqtt_host = 'mqtt.meross.com'
default_mqtt_port = 443
default_command_timeout = 10.0 |
class Solution:
def __init__(self):
self.memo = {}
def _can_cross(self, stones, cur_idx, step, last_idx) -> bool:
if (cur_idx, step) in self.memo:
return self.memo[(cur_idx, step)]
if cur_idx == last_idx:
return True
elif cur_idx > last_... | class Solution:
def __init__(self):
self.memo = {}
def _can_cross(self, stones, cur_idx, step, last_idx) -> bool:
if (cur_idx, step) in self.memo:
return self.memo[cur_idx, step]
if cur_idx == last_idx:
return True
elif cur_idx > last_idx:
re... |
# Programa 05
b = 5/2 + 6/4
a = 3 + b
if (a > 7):
c = a + c
print(b - a)
elif (a == 7):
c = a - b
print(2*c + 1)
else:
a = a + b | b = 5 / 2 + 6 / 4
a = 3 + b
if a > 7:
c = a + c
print(b - a)
elif a == 7:
c = a - b
print(2 * c + 1)
else:
a = a + b |
message = input('Enter a message. Go ahead, I\'ll wait!\n')
count = 0
for i in message:
if i != 'a':
print(i, end = "")
elif i == 'a':
count += 1
if count > 3:
i = 'A'
print(i, end = '')
else:
i = '@'
print(i, end = '') | message = input("Enter a message. Go ahead, I'll wait!\n")
count = 0
for i in message:
if i != 'a':
print(i, end='')
elif i == 'a':
count += 1
if count > 3:
i = 'A'
print(i, end='')
else:
i = '@'
print(i, end='') |
# PR#208, calling apply with bogus 3rd argument
def test(x):
return x
assert 7 == test(*(7,))
assert 7 == test(*(), **{'x': 7})
try:
test(*(1,), **7)
print('TypeError expected')
except TypeError:
pass
try:
test(*(1,), **{7:3})
print('TypeError expected')
except TypeError:
pass
try:
... | def test(x):
return x
assert 7 == test(*(7,))
assert 7 == test(*(), **{'x': 7})
try:
test(*(1,), **7)
print('TypeError expected')
except TypeError:
pass
try:
test(*(1,), **{7: 3})
print('TypeError expected')
except TypeError:
pass
try:
test(*(1,), **None)
print('TypeError expected')
... |
class ResponseCookie:
def __init__(self, name, value, expires, max_age, domain, path, secure, http_only):
self._name = name
self._value = value
self._expires = expires
self._max_age = max_age
self._domain = domain
self._path = path
self._secure = secure
... | class Responsecookie:
def __init__(self, name, value, expires, max_age, domain, path, secure, http_only):
self._name = name
self._value = value
self._expires = expires
self._max_age = max_age
self._domain = domain
self._path = path
self._secure = secure
... |
def isValid(self, s: str) -> bool:
stack = []
closeToOpen = {')':'(',']':'[','}':'{'} # dictionarry mappin to avoid alot of if staements
for symbol in s :
if symbol in closeToOpen:#because the key is always the closing parenthesis
if stack and stack... | def is_valid(self, s: str) -> bool:
stack = []
close_to_open = {')': '(', ']': '[', '}': '{'}
for symbol in s:
if symbol in closeToOpen:
if stack and stack[-1] == closeToOpen[symbol]:
stack.pop()
else:
return False
else:
sta... |
# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""A trade represents a fill of an offer.
This happens when an incoming order matches an offer on the opposite side of the order book in price.
Trades can be seen on the Trade History column on Switcheo Exchange.
"""
# Retrieves trades that have already occurred on Switch... | """A trade represents a fill of an offer.
This happens when an incoming order matches an offer on the opposite side of the order book in price.
Trades can be seen on the Trade History column on Switcheo Exchange.
"""
list_trades = '/trades' |
class Temperature(object):
'''
Used to model the temperature
value = 0 - Not known
value = 1 - < 25 degrees
value = 2 - => 25
'''
def __init__(self, value = 0, created = False):
self.value = value
self.created = created
@property
def value(self):
return sel... | class Temperature(object):
"""
Used to model the temperature
value = 0 - Not known
value = 1 - < 25 degrees
value = 2 - => 25
"""
def __init__(self, value=0, created=False):
self.value = value
self.created = created
@property
def value(self):
return self._v... |
#!/usr/bin/python3
number = 2
number = number * number * number
print (number * number * number)
print ("!@#$%^&*()-=") # testing character matching
| number = 2
number = number * number * number
print(number * number * number)
print('!@#$%^&*()-=') |
'''
Created on Oct 31, 2017
@author: jschm
'''
def mapSqr(L):
"""returns the map of sqr and L"""
power = 2
lst = []
# have to make a new list so old is not mutated
# cannot do better
for x in L:
#lst += [x ** power]
# faster
lst.append(x ** power)
return lst
prin... | """
Created on Oct 31, 2017
@author: jschm
"""
def map_sqr(L):
"""returns the map of sqr and L"""
power = 2
lst = []
for x in L:
lst.append(x ** power)
return lst
print(map_sqr([1, 2, 3, 4, 5]))
def find_max(lst):
if lst == []:
return None
max = lst[0]
for x in lst:
... |
new_fruit=input('what fruit am I sorting?')
if new_fruit == Apple:
print ('Bin 1')
elif new_fruit == Orange:
print ('Bin 2')
elif new_fruit == Olive:
print ('Bin 3')
else:
print('Error! I do not recognize this fruit')
| new_fruit = input('what fruit am I sorting?')
if new_fruit == Apple:
print('Bin 1')
elif new_fruit == Orange:
print('Bin 2')
elif new_fruit == Olive:
print('Bin 3')
else:
print('Error! I do not recognize this fruit') |
#Empty print for not disturbing the unit tests output
def myPrint( str ):
pass
def add( i, j):
return i + j
def subtract( i, j):
return i - j
def innerFunction():
pass
def outerFunction():
innerFunction()
def noParamsFunction():
return MyClass()
def mySubstring( st... | def my_print(str):
pass
def add(i, j):
return i + j
def subtract(i, j):
return i - j
def inner_function():
pass
def outer_function():
inner_function()
def no_params_function():
return my_class()
def my_substring(str, length):
return str[:length]
def process_list(aList):
my_print('... |
# https://www.codewars.com/kata/522551eee9abb932420004a0/train/python
'''
Instructions :
I love Fibonacci numbers in general, but I must admit I love some more than others.
I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence.
For example:
nt... | """
Instructions :
I love Fibonacci numbers in general, but I must admit I love some more than others.
I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence.
For example:
nth_fib(4) == 2
Because 2 is the 4th number in the Fibonacci Sequence.
F... |
# -*- coding: utf-8 -*-
"""
s
@author: MAQ
"""
class Node():
def __init__(self, value):
self.value = value
self.next = None
a = Node(1)
b = Node(2)
c = Node(3)
a.next = b
b.next = c
a.next.next.value | """
s
@author: MAQ
"""
class Node:
def __init__(self, value):
self.value = value
self.next = None
a = node(1)
b = node(2)
c = node(3)
a.next = b
b.next = c
a.next.next.value |
class c():
def __init__(self) :
self.h = {0:0,1:1}
self.max = 1
def fib(self,n):
if n in self.h: return self.h[n]
for i in range(self.max+1,n+1):
self.h[i] = self.h[i-1]+self.h[i-2]
return self.h[n]
Fib = c()
for i in range(3):
... | class C:
def __init__(self):
self.h = {0: 0, 1: 1}
self.max = 1
def fib(self, n):
if n in self.h:
return self.h[n]
for i in range(self.max + 1, n + 1):
self.h[i] = self.h[i - 1] + self.h[i - 2]
return self.h[n]
fib = c()
for i in range(3):
r ... |
def main():
in_string = input()
counts = [0] * 26
for c in in_string:
counts[ord(c) - 65] += 1
palindrome = ""
middle = ""
for i in range(26):
if counts[i] % 2 == 1:
if middle:
print("NO SOLUTION")
return
middle = chr(65 + ... | def main():
in_string = input()
counts = [0] * 26
for c in in_string:
counts[ord(c) - 65] += 1
palindrome = ''
middle = ''
for i in range(26):
if counts[i] % 2 == 1:
if middle:
print('NO SOLUTION')
return
middle = chr(65 + i... |
# 3. Write a recursive Python function that returns the sum of the first
# n integers. (Hint: The function will be similar to the factorial function!)
# ie sum_nint(3) = 1 + 2 + 3 = 6 , sum_nint(4) = 1 + 2 + 3 + 4 = 10.
def sum_nint(num):
''' recursive sum of integers
num = last integer in range
'''
... | def sum_nint(num):
""" recursive sum of integers
num = last integer in range
"""
if num == 1:
return 1
else:
return num + sum_nint(num - 1)
def main():
print('Test cases')
n = 3
print('Sum of first', n, 'integers is', sum_nint(n))
n = 4
print('Sum of first', ... |
'''
07 - Removing missing values:
Now that you know there are some missing values in your DataFrame, you
have a few options to deal with them. One way is to remove them from the
dataset completely. In this exercise, you'll remove missing values by
removing all rows that contain missing values.
pandas has be... | """
07 - Removing missing values:
Now that you know there are some missing values in your DataFrame, you
have a few options to deal with them. One way is to remove them from the
dataset completely. In this exercise, you'll remove missing values by
removing all rows that contain missing values.
pandas has be... |
#### Regulation B
IGNORE_DEFINITIONS_IN_PART_1002 = [
'International Banking Act of 1978',
'Packers and Stockyards Act',
'Federal Reserve Act',
'Federal Credit Unions',
'National Credit Union Administration',
'Federal Intermediate Credit Banks',
'Production Credit Associations',
'Farm C... | ignore_definitions_in_part_1002 = ['International Banking Act of 1978', 'Packers and Stockyards Act', 'Federal Reserve Act', 'Federal Credit Unions', 'National Credit Union Administration', 'Federal Intermediate Credit Banks', 'Production Credit Associations', 'Farm Credit Administration', 'Equal Credit Opportunity', '... |
# ------------------------------
# 844. Backspace String Compare
#
# Description:
# Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.
# Example 1:
# Input: S = "ab#c", T = "ad#c"
# Output: true
# Explanation: Both S and T become "ac".
# Ex... | class Solution:
def backspace_compare(self, S, T):
"""
:type S: str
:type T: str
:rtype: bool
"""
s = ''
t = ''
for x in S:
if x != '#':
s += x
else:
s = s[:-1]
for y in T:
if... |
# Author: btjanaka (Bryon Tjanaka)
# Problem: (HackerRank) and-product
# Title: AND Product
# Link: https://www.hackerrank.com/challenges/and-product/problem
# Idea: The problem boils down to finding the leftmost non-aligned bit between
# two numbers, i.e. the leftmost bit that is not identical in a and b. We know
# th... | n = int(input())
for _ in range(n):
(a, b) = map(int, input().split())
nonaligned_pos = -1
for pos in range(32, -1, -1):
a_bit = a & 1 << pos
b_bit = b & 1 << pos
if a_bit != b_bit:
nonaligned_pos = pos
break
if nonaligned_pos == -1:
print(a)
... |
with open("/Users/mccoybecker/Documents/GitHub/scratch-code/numbers.txt", "r") as myfile:
data=myfile.read().replace('\n', '')
print(data)
max = 0
for i in range(len(data)-12):
product = 1
for j in range(i,13+i):
product = product * int(data[j])
if product > max:
max = product
print(ma... | with open('/Users/mccoybecker/Documents/GitHub/scratch-code/numbers.txt', 'r') as myfile:
data = myfile.read().replace('\n', '')
print(data)
max = 0
for i in range(len(data) - 12):
product = 1
for j in range(i, 13 + i):
product = product * int(data[j])
if product > max:
max = product
pri... |
# An n-bit gray code sequence is a sequence of 2n integers where:
# Every integer is in the inclusive range [0, 2n - 1],
# The first integer is 0,
# An integer appears no more than once in the sequence,
# The binary representation of every pair of adjacent integers differs by exactly one bit, and
# The binary re... | class Solution:
def gray_code(self, n: int) -> List[int]:
res = []
for i in range(1 << n):
res.append(i ^ i >> 1)
return res |
#! /usr/bin/env python3.7
def find_active_cat(game_categories, title):
in_title = []
position = {}
title = title.lower()
for k in list(game_categories.keys()):
if k.lower() in title:
in_title.append(k)
position[k] = title.find(k.lower())
in_title = list(set(in_title... | def find_active_cat(game_categories, title):
in_title = []
position = {}
title = title.lower()
for k in list(game_categories.keys()):
if k.lower() in title:
in_title.append(k)
position[k] = title.find(k.lower())
in_title = list(set(in_title))
in_title_len = len(in... |
class Solution:
def firstPalindrome(self, words: List[str]) -> str:
def checkPalindrome(word):
l = len(word)
for i in range(l // 2):
last = l - 1 - i
if word[i] != word[last]:
return False
... | class Solution:
def first_palindrome(self, words: List[str]) -> str:
def check_palindrome(word):
l = len(word)
for i in range(l // 2):
last = l - 1 - i
if word[i] != word[last]:
return False
return True
for wor... |
class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
N = len(nums)
i = 0
zeros = 0
while i + zeros < N:
if nums[i] != 0:
... | class Solution(object):
def move_zeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
n = len(nums)
i = 0
zeros = 0
while i + zeros < N:
if nums[i] != 0:
i ... |
"""Package helper functions, classes, and utilities.
Copyright (c) 2019 Cisco and/or its affiliates.
This software is licensed to you under the terms of the Cisco Sample
Code License, Version 1.0 (the "License"). You may obtain a copy of the
License at
https://developer.cisco.com/docs/licenses
All us... | """Package helper functions, classes, and utilities.
Copyright (c) 2019 Cisco and/or its affiliates.
This software is licensed to you under the terms of the Cisco Sample
Code License, Version 1.0 (the "License"). You may obtain a copy of the
License at
https://developer.cisco.com/docs/licenses
All us... |
"""
* ____ _
* | _ \ ___ __| |_ __ _ _ _ __ ___
* | |_) / _ \ / _` | '__| | | | '_ ` _ \
* | __/ (_) | (_| | | | |_| | | | | | |
* |_| \___/ \__,_|_| \__,_|_| |_| |_|
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the Licens... | """
* ____ _
* | _ \\ ___ __| |_ __ _ _ _ __ ___
* | |_) / _ \\ / _` | '__| | | | '_ ` _ * | __/ (_) | (_| | | | |_| | | | | | |
* |_| \\___/ \\__,_|_| \\__,_|_| |_| |_|
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the Lic... |
# import DevsExpo
zee5 = "https://userapi.zee5.com/v1/user/loginemail?email={email}&password={password}"
nord = "https://zwyr157wwiu6eior.com/v1/users/tokens"
vortex = "https://vortex-api.gg/login"
vypr = "https://api.goldenfrog.com/settings"
| zee5 = 'https://userapi.zee5.com/v1/user/loginemail?email={email}&password={password}'
nord = 'https://zwyr157wwiu6eior.com/v1/users/tokens'
vortex = 'https://vortex-api.gg/login'
vypr = 'https://api.goldenfrog.com/settings' |
class Vehicle:
def __init__(self, cost):
self.cost = cost
def description(self):
return "Vehicle cost is {}".format(self.cost)
car1 = Vehicle(12000)
car2 = Vehicle(5999.99)
print(car1.description())
print(car2.description())
| class Vehicle:
def __init__(self, cost):
self.cost = cost
def description(self):
return 'Vehicle cost is {}'.format(self.cost)
car1 = vehicle(12000)
car2 = vehicle(5999.99)
print(car1.description())
print(car2.description()) |
class Solution:
def shortestPath(self, grid: List[List[int]], k: int) -> int:
m = len(grid)
n = len(grid[0])
if m == 1 and n == 1:
return 0
dirs = [0, 1, 0, -1, 0]
steps = 0
q = deque([(0, 0, k)])
seen = {(0, 0, k)}
while q:
steps += 1
for _ in range(len(q)):
... | class Solution:
def shortest_path(self, grid: List[List[int]], k: int) -> int:
m = len(grid)
n = len(grid[0])
if m == 1 and n == 1:
return 0
dirs = [0, 1, 0, -1, 0]
steps = 0
q = deque([(0, 0, k)])
seen = {(0, 0, k)}
while q:
s... |
for i in range(1, 21):
for j in range(2, i):
if(i % 2 == 0):
break
else:
print(i)
| for i in range(1, 21):
for j in range(2, i):
if i % 2 == 0:
break
else:
print(i) |
Totalplyers = int(input("Number of players: "))
Starplayers = 0
for i in range(Totalplyers):
Numberofpoints = int(input("Number of goals: "))
Numberoffouls = int(input("Number of fouls: "))
Numberofstars = Numberofpoints * 5 - Numberoffouls * 3
if Numberofstars > 40:
Starplayers = Starplayers +... | totalplyers = int(input('Number of players: '))
starplayers = 0
for i in range(Totalplyers):
numberofpoints = int(input('Number of goals: '))
numberoffouls = int(input('Number of fouls: '))
numberofstars = Numberofpoints * 5 - Numberoffouls * 3
if Numberofstars > 40:
starplayers = Starplayers + ... |
"""Generated an open-api spec for a grpc api spec.
Reads the the api spec in protobuf format and generate an open-api spec.
Optionally applies settings from the grpc-service configuration.
"""
def _collect_includes(gen_dir, srcs):
"""Build an include path mapping.
It is important to not just collect unique d... | """Generated an open-api spec for a grpc api spec.
Reads the the api spec in protobuf format and generate an open-api spec.
Optionally applies settings from the grpc-service configuration.
"""
def _collect_includes(gen_dir, srcs):
"""Build an include path mapping.
It is important to not just collect unique d... |
__all__ = ()
class InfoException(Exception):
def __init__(self, info=None):
self.info = info or {}
super().__init__(self.info)
class DeepQMCError(Exception):
pass
class NanError(DeepQMCError):
def __init__(self, rs):
super().__init__()
self.rs = rs
class TrainingBlowu... | __all__ = ()
class Infoexception(Exception):
def __init__(self, info=None):
self.info = info or {}
super().__init__(self.info)
class Deepqmcerror(Exception):
pass
class Nanerror(DeepQMCError):
def __init__(self, rs):
super().__init__()
self.rs = rs
class Trainingblowup(... |
#
# PySNMP MIB module NETSCREEN-VR-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NETSCREEN-VR-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:20:42 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint) ... |
pasword = '123456'
username = 'kamilklkn'
a,b,c,d = 5,5,10,4
result = (a==b) #True
result = (a == c) #False
result = ('sdktrn' == username)
result = (a != b)
result = (a != c)
result = (a >= b)
result = (True == 1)
result = (False == 1)
print(result) | pasword = '123456'
username = 'kamilklkn'
(a, b, c, d) = (5, 5, 10, 4)
result = a == b
result = a == c
result = 'sdktrn' == username
result = a != b
result = a != c
result = a >= b
result = True == 1
result = False == 1
print(result) |
__title__ = 'sellsy_api'
__description__ = 'sellsy_api is a tiny client for Sellsy API'
__url__ = 'https://github.com/Annouar/sellsy-api'
__version__ = '0.0.2'
__author__ = 'Annouar'
__license__ = 'MIT'
| __title__ = 'sellsy_api'
__description__ = 'sellsy_api is a tiny client for Sellsy API'
__url__ = 'https://github.com/Annouar/sellsy-api'
__version__ = '0.0.2'
__author__ = 'Annouar'
__license__ = 'MIT' |
buses = []
n, m, h = map(int, input().split())
for i in range(n):
buses.append(int(input()))
count = 0
for i in range(n - 1):
while buses[n - i - 1] - buses[n - i - 2] > h:
buses[n - i - 2] += m
count += 1
print(count) | buses = []
(n, m, h) = map(int, input().split())
for i in range(n):
buses.append(int(input()))
count = 0
for i in range(n - 1):
while buses[n - i - 1] - buses[n - i - 2] > h:
buses[n - i - 2] += m
count += 1
print(count) |
"""
"Descriptors" section example of descriptor that allows for lazy
initialization of class instance attributes
"""
class InitOnAccess:
def __init__(self, klass, *args, **kwargs):
self.klass = klass
self.args = args
self.kwargs = kwargs
self._initialized = None
def __get__(s... | """
"Descriptors" section example of descriptor that allows for lazy
initialization of class instance attributes
"""
class Initonaccess:
def __init__(self, klass, *args, **kwargs):
self.klass = klass
self.args = args
self.kwargs = kwargs
self._initialized = None
def __get__(s... |
# Time: O(h)
# Space: O(1)
# Definition for a Node.
class Node:
def __init__(self, val):
pass
class Solution(object):
def flipBinaryTree(self, root, leaf):
"""
:type node: Node
:rtype: Node
"""
curr, parent = leaf, None
while True:
child = ... | class Node:
def __init__(self, val):
pass
class Solution(object):
def flip_binary_tree(self, root, leaf):
"""
:type node: Node
:rtype: Node
"""
(curr, parent) = (leaf, None)
while True:
child = curr.parent
curr.parent = parent
... |
class Solution(object):
def divisorGame(self, N):
"""
:type N: int
:rtype: bool
"""
return N % 2 == 0
def test_divisor_game():
assert Solution().divisorGame(2)
assert Solution().divisorGame(3) is False
| class Solution(object):
def divisor_game(self, N):
"""
:type N: int
:rtype: bool
"""
return N % 2 == 0
def test_divisor_game():
assert solution().divisorGame(2)
assert solution().divisorGame(3) is False |
#pembuatan fungsi
def hitung_gaji():
nama =(input("masukan Nama anda :"))
gol=(input("masukan golongan:"))
if gol =="1":
gaji=1000000
tunjangan= 250000
total=gaji+tunjangan
print(f"total gaji yang anda terima {total}")
elif gol == "2":
gaji = 2000000... | def hitung_gaji():
nama = input('masukan Nama anda :')
gol = input('masukan golongan:')
if gol == '1':
gaji = 1000000
tunjangan = 250000
total = gaji + tunjangan
print(f'total gaji yang anda terima {total}')
elif gol == '2':
gaji = 2000000
tunjangan = 5000... |
def add(x, y):
return x + y
def times(func, x, y):
return func(x, y)
a = 2
b = 4
r = times(add, a, b)
print(' - Resultado = ', r)
| def add(x, y):
return x + y
def times(func, x, y):
return func(x, y)
a = 2
b = 4
r = times(add, a, b)
print(' - Resultado = ', r) |
# ##Create 5 dictionaries which have list values
dict1 = {'State': 'Maharashtra', 'City': 'Pune', 'Best Places to Visit': ['Shanivarwada', "Pataleshwar", "Dagdusheth", "Tulshibag"]}
dict2 = {'State': 'Goa', 'Cty': 'North Goa', 'Best Places to Visit': ["panji", "Baga", "Calngut", "Meeramaar"]}
dict3 = {'State': 'Mahara... | dict1 = {'State': 'Maharashtra', 'City': 'Pune', 'Best Places to Visit': ['Shanivarwada', 'Pataleshwar', 'Dagdusheth', 'Tulshibag']}
dict2 = {'State': 'Goa', 'Cty': 'North Goa', 'Best Places to Visit': ['panji', 'Baga', 'Calngut', 'Meeramaar']}
dict3 = {'State': 'Maharashtra', 'City': 'Pune', 'Best Hotel to Visit': ['P... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.