content stringlengths 7 1.05M |
|---|
class Karta:
def __init__(self, hodnota, barva, licem_nahoru):
self.hodnota = hodnota
self.barva = barva
self.licem_nahoru = licem_nahoru
def __str__(self):
if not self.licem_nahoru:
return '[???]'
barvy = {'Pi': '♠ ', 'Sr': ' ♥', 'Ka': ' ♦', 'Kr':'♣ '}
... |
languages = {
54: "af",
28: "sq",
522: "am",
1: "ar",
5121: "ar-AL",
15361: "ar-BA",
3073: "ar-EG",
2049: "ar-IQ",
11265: "ar-JO",
13313: "ar-KU",
12289: "ar-LE",
4097: "ar-LI",
6145: "ar-MO",
8193: "ar-OM",
16385: "ar-QA",
1025: "ar-SA",
10241: "ar-SY... |
OBSTACLE_SIZE = 45
ROBOT_SIZE = 45
GOAL_SIZE = 45
GOAL_POS_X = 50
GOAL_POS_Y = 50
START_POS_X = 100
START_POS_Y = 700
BOARD_SIZE = 800
STEP = 10
INFINITY = 100000 |
print("To find the number of vowles in a given string")
count = 0
string=input("enter the string:")
for i in string:
if i in "aeiouAEIOU":
count=count+1
print("the vowels in the given string are:",i)
print("the total numbr of vowles are:",count)
|
##Removal of collisions of knolls with large boulders=name
##layerofcliffspolygons=vector
##radiusofknoll=number3.0
##layerofsmallknollspoints=vector
##radiusoflargeboulders=number4.5
##knolls=output vector
outputs_QGISFIXEDDISTANCEBUFFER_2=processing.runalg('qgis:fixeddistancebuffer', layerofcliffspolygons,radiusoflar... |
# Copyright (c) Sandeep Mistry. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
{
'targets': [
{
'target_name': 'class',
'conditions': [
['OS=="mac"', {
'sources': [
'src/class.mm'
],
... |
class Solution:
def hammingWeight(self, n: int) -> int:
wt = 0
is_non_neg = n >= 0
offset = int(not is_non_neg)
n = abs(n)
for _ in range(32):
if is_non_neg and n == 0:
break
wt += (n + offset) & 1
n >>= 1
return wt
... |
# Time: O(l * n^2)
# Space: O(1)
class Solution(object):
def findLUSlength(self, strs):
"""
:type strs: List[str]
:rtype: int
"""
def isSubsequence(a, b):
i = 0
for j in range(len(b)):
if i >= len(a):
break
... |
"""This problem was asked by Google.
Given a set of distinct positive integers, find the largest subset such that every
pair of elements in the subset (i, j) satisfies either i % j = 0 or j % i = 0.
For example, given the set [3, 5, 10, 20, 21], you should return [5, 10, 20].
Given [1, 3, 6, 24], return [1, 3, 6, 2... |
f = open("/share/Ecoli/GCA_000005845.2_ASM584v2_genomic.fna")
lines = f.readlines()
genome = ""
for i in range(1, len(lines)):
for j in range(len(lines[i]) - 1):
genome = genome + lines[i][j]
for i in range(0 , 3):
extra = len(genome) - i % 11
fragments = ""
fragcount = 0
fraglength = 0
for j in range(i, len(ge... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def f(x):
return x * x
# map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回
r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
print(list(r))
print()
# 把这个list所有数字转为字符串
s = map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9])
print(list(s))
|
#!/usr/local/bin/python3
"""Task
The height of a binary search tree is the number of edges between the tree's root and its furthest leaf.
You are given a pointer, root, pointing to the root of a binary search tree.
Complete the getHeight function provided in your editor so that it returns the height of the binary ... |
# Copyright (c) 2016-2020 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.
class ZellerSplit(object):
"""
Splits up the input config... |
# -*- coding: utf-8 -*-
"""
Created on Thu May 24 21:26:17 2018
@author: Isik
"""
class Position:
"""
Represents position in N dimensions
Is designed to be able to have a direction added to it.
--------------------------------------------------------------------------
properties
... |
"""Take 2 strings s1 and s2 including only letters from ato z.
Return a new sorted string, the longest possible, containing distinct letters,
each taken only once - coming from s1 or s2.
=== Examples: ===
a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"
longest(a, b) -> "abcdefklmopqwxy"
a = "abcdefghijklmnopqrstuvwxyz"... |
def hrs2min(x): return x * 60
def min2sec(x): return x * 60
def SEC_TO_HR(x): return x / 3600.0
# Kelvin to Celcius
def check_range(value, min_val, max_val, descrip):
"""
Check the range of the value
Args:
value: value to check
min_val: minimum value
max_val: maximum value
... |
def test():
a = {'foo': 'bar'}
print(a)
print(a['foo'])
b = {'x':'y'}
a.update(b)
print(a)
keys = a.keys()
print(keys)
vals = a.values()
print(vals)
test()
|
def process(s):
n = s.find(";")
if n > 0:
left = s[:n]+(" " * 64)
s = left[:34]+s[n:]
return s
f = open("revenge.asm")
code = f.readlines()
f.close()
code = [process(c.rstrip()) for c in code]
print("\n".join(code)) |
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:java.bzl", "da_java_library")
load("//bazel_tools:javadoc_library.bzl", "javadoc_library")
load("//bazel_tools:pkg.bzl", "pkg_empty_zip")
load("//bazel_tools:pom_f... |
def reindent(s, numSpaces):
leading_space = numSpaces * ' '
lines = [ leading_space + line.strip()
for line in s.splitlines() ]
return '\n'.join(lines)
|
__author__ = "ricksy"
__email__ = "ricksy@mailbox.org"
__copyright__ = "(c) 2020 ricksy"
__version__ = "1.0.0"
__title__ = "py1"
__description__ = "have not idea"
__license__ = "MIT"
|
initials = [
"b",
"c",
"ch",
"d",
"f",
"g",
"h",
"j",
"k",
"l",
"m",
"n",
"p",
"q",
"r",
"s",
"sh",
"t",
"w",
"x",
"y",
"z",
"zh",
]
finals = ['S', 'Sj', 'StS', 'StSj', 'Z', 'Zj', 'a', 'b', 'bj', 'd', 'dj', 'e', 'f', 'g', 'hrd',... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Student(object):
def __init__(self):
self.name = "Michael"
def __getattr__(self, attr):
if attr == "score":
return 99
if attr == "age":
return lambda: 25
raise AttributeError("'Student' object has no ... |
r1 = float(input('Primeiro segmento: '))
r2 = float(input('Segundo segmento: '))
r3 = float(input('Terceiro segmento: '))
if (r1 < r2 + r3) and (r2 < r1 + r3) and (r3 < r1 + r2):
print('\033[32mOs segmentos acima podem formar um triângulo.\033[m')
if r1 == r2 and r1 == r3:
print('O triângulo forma... |
# Conversao de temperatura
cel = float(input('Informe a temperatura em °C: '))
far = cel * 1.8 + 32
print(f'{cel}°C equivale a {far}°F')
|
while True:
try:
n = int(input())
app_list = input().strip().split()
tick_num = int(input())
tick_list = input().strip().split()
invalid = 0
tick_dict = {}
for app in app_list:
tick_dict[app] = 0
for tick in tick_list:
if tick i... |
"""
This file contains the implementation of a 'left-leaning'
Red Black Binary Search Tree (LLRBT). The implementation is based
on the one described in the book 'Algorithms Fourth Edition'
by Robert Sedgewick and Kevin Wayne.
A LLRBT is a Tree in which every Node have one of
two colors: red or black. The color of a No... |
# -*- coding: utf-8 -*-
GOLDEN_EN_RULES = [
# 1) Simple period to end sentence
("Hello World. My name is Jonas.", ["Hello World.", "My name is Jonas."]),
# 2) Question mark to end sentence
("What is your name? My name is Jonas.", ["What is your name?", "My name is Jonas."]),
# 3) Exclamation point ... |
"""
Faster R-CNN with GIOU Assigner
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.110
Average Precision (AP) @[ IoU=0.25 | area= all | maxDets=1500 ] = -1.000
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.265
Average Precision (AP) @[ IoU=0.75 |... |
SESSION_NAME = "researcher_username"
EXPIRY_NAME = "expiry"
SESSION_UUID = "session_uuid"
STUDY_ADMIN_RESTRICTION = "study_admin_restriction"
|
class Solution:
def addDigits(self, num: int) -> int:
while num > 9:
num = sum([int(x) for x in str(num)])
return num
|
class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
class Solution:
def tiltOfBinaryTreeUtil(self, root):
if root is None:
return 0
left_tilt = self.tiltOfBinaryTreeUtil(root.left)
right_tilt = self.tiltO... |
def getLongestPalindrome(start: int, end: int, s: str) -> str:
while start > -1 and end < len(s) and s[start] == s[end]:
start -= 1
end += 1
return s[start + 1:end]
def longestPalindrome(s: str) -> str:
if not s or len(s) == 0:
return ""
... |
class WeatherItem:
def __init__(self, name, prefix="", suffix="", condition_type_list=[]):
self.__name = name
self.__prefix = prefix
self.__suffix = suffix
self.__condition_list = condition_type_list
def __eq__(self, other):
if isinstance(other, self.__class__):
... |
secondary_todo_list
|
window = None
scene = 'title'
state = ''
class Cursor():
class Title():
menu = 0
class Save_Select():
save = 0
class Roguelike_Menu():
level = 0
character = 0
class Roguelike_Start():
select = 0
class Save():
data = {
0 : '',
1 : '',
... |
class Car:
"""
Add class description here
"""
def __init__(self, name, length, location, orientation):
"""
A constructor for a Car object
:param name: A string representing the car's name
:param length: A positive int representing the car's length.
:param locatio... |
in_file = open('occurrences.txt', 'r')
out_file = open('present.txt', 'w')
counter = 7740
for line in in_file:
row = line.split('\t')
country = row[5]
id = row[0]
ref = row[8]
if country == '':
country = row[6]
if country == '':
pass
else:
out_file.write('M' + str(counter) + '\t' + id + '\t\ttrue\t' + 'h... |
#023 - Separando dígitos de um número
num = int(input('informe um numero: '))
u = num // 1 % 10
d = num // 10 % 10
c = num // 100 % 10
m = num // 1000 % 10
print(f'analisando o numero {num}')
print(f'unidade {u}')
print(f'dezena: {d}')
print(f'centena: {c}')
print(f'milhar: {m}')
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# This line will be programatically read/write by setup.py.
# Leave them at the bottom of this file and don't touch them.
__version__ = "0.1.1"
|
"""
@author: David Lei
@since: 19/09/2017
Bottom up solution to find the nth fibonacci number.
"""
def fib(n):
TABLE = [0, 1]
calculated = 1
while calculated < n:
next_number = TABLE[calculated] + TABLE[calculated - 1]
print("Adding computed value to table {0} + {1} = {2}".format(
... |
# Create a dictionary of lists with new data
avocados_dict = {
"date": ["2019-11-17", "2019-12-01"],
"small_sold": [10859987, 9291631],
"large_sold": [7674135, 6238096]
}
# Convert dictionary into DataFrame
avocados_2019 = pd.DataFrame(avocados_dict)
# Print the new DataFrame
print(avocados_2019) |
Li = [ 22, 35 , 26 , 98 , 55 , 10 , 67 ]
Li.sort()
Li.reverse()
print(Li)
|
class HsrpOutput(object):
# 'show hsrp detail' output
showHsrpDetailOutput = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
... |
SPECS = {
"org.freedesktop.DBus.ObjectManager": """
<interface name="org.freedesktop.DBus.ObjectManager">
<method name="GetManagedObjects">
<arg name="objpath_interfaces_and_properties" type="a{oa{sa{sv}}}" direction="out" />
</method>
</interface>
""",
"org.storage.stratis2.FetchProperties.r4":... |
"""
Code generated from go.sum by //:gazelle-update-repos
"""
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_dependencies():
"""
Managed by gazelle. Add "# keep" comment to modified lines.
"""
go_repository(
name = "co_honnef_go_tools",
importpath = "honnef.co/go/tools",
... |
k=[]
for i in range(3):
#while True:
try:
a=input()
except:
break
k.append(a)
check = [True for i in range(len(k))]
check_three = False
three_s=(-1,-1)
three_e=(-1,-1)
remove_list = []
for num,i in enumerate(k):
for j in range(len(i)):
if j+2 <len(i):
if not check_... |
# 多处理异常
print('start')
# 存在异常的代码
try:
# 捕获异常
a=int(input('请输入一个数值:'))
print('你输入的数值:', a)
print(100 / a)
except ValueError:
# 处理异常
print('ValueError')
except ZeroDivisionError:
print('ZeroDivisionError')
except:
print('final exept')
print('end...') |
#
# Device Database and registry
#
# Need to be adapted to your local devices.
# And these are just default values, not my ones... :)
mqtt_ip = "192.168.178.10"
mqtt_port = 1883
influxdb_ip = "192.168.178.12"
influxdb_user = "myuser"
influxdb_pw = "mypw"
influxdb_db = "mydb"
fritz_ip = "192.168.17.1"
fritz_user =... |
def react_chat_red(eventType, GPIO):
RED_LED = 'P8_8'
if len(eventType) != 0:
if eventType[0] == "on":
GPIO.output(RED_LED, GPIO.HIGH)
elif eventType[0] == "off":
GPIO.output(RED_LED, GPIO.LOW)
elif eventType[0] == "toggle":
state = GPIO.input(RED_L... |
#%%
def numDistinctIslands(grid):
cnt_row, cnt_col = len(grid), len(grid[0])
def dfs(index_row, index_col, dir):
if (
index_row < 0
or index_row >= cnt_row
or index_col < 0
or index_col >= cnt_col
or not grid[index_row][index_col]
):
... |
"""
Experiment on the work of Faten.
Manully define preference relationship between several alternatives and run the .
"""
# Author: Yiru Zhang <yiru.zhang@irisa.fr>
# License: Unlicense
|
with open('input') as f:
data = f.read().strip().split('\n')
initial = {(j, i, 0, 0) for i, s in enumerate(data) for j, c in enumerate(s) if c=='#'}
def fence(s):
min_x = min(s, key=lambda x: x[0])[0]
min_y = min(s, key=lambda x: x[1])[1]
min_z = min(s, key=lambda x: x[2])[2]
min_w = min(s, key=l... |
# import time
# #Indroduction to the game
# print("Hello there \nWelcome to TIC-TAC-TOE")
# time.sleep(1)
# #list of numbers
# num_list = [1,2,3,4,5,6,7,8,9]
# print(num_list)
# #Request for tutorial
# def tutorial():
# tutorial_list = ["=>This game is restricted to 2 players only",
# "=>There are two characte... |
#
# PySNMP MIB module HH3C-MIRRORGROUP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-MIRRORGROUP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:15:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... |
'''THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OT... |
# 2020.07.26
# May not have time to do it on 27th, so...
# Problem Statement
# https://leetcode.com/problems/merge-k-sorted-lists/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# one by one compare
class Solution:... |
def test_valid(cldf_dataset, cldf_logger):
assert cldf_dataset.validate(log=cldf_logger)
def test_languages(cldf_dataset, cldf_logger):
assert len(list(cldf_dataset['LanguageTable'])) == 14
def test_sources(cldf_dataset, cldf_logger):
assert len(cldf_dataset.sources) == 1
def test_parameters(cldf_dat... |
print('-=' * 20, 'CADASTRO DE USUÁRIOS', '-=' * 20)
r = ''
mais18 = homens = mulheresMenos20 = 0
while True:
idade = int(input('Idade: '))
sexo = str(input('Sexo [M/F]:')).strip().upper()[0]
while sexo not in 'M/F':
sexo = str(input('Sexo [M/F]:')).strip().upper()[0]
if idade > 18:
mais1... |
meny = """
Hvilken størrelse skal du finne?
1) Strekning s
2) Fart v
3) Tid t
"""
enhetsmeny = """
Hvilken enhet skal du bruke?
1) lengde: kilometer, tid: timer, fart: km/t
2) lengde: meter, tid: sekunder, fart: m/s
3) lengde: meter, tid: minutter, fart: m/min
"""
# les inn hvi... |
# Python Week 3 Day-16
# الصفوف )الأزواج المرتبة( في لغة البايثون
# Python Tuples
mytuple = ("Python", "Java", "C++", "C#")
print(mytuple)
print("--------------------------------\n")
# في المثال التالي قمنا بتعريف tuple فارغ ، لا يحتوي على أي عنصر.
# An empty tuple in Python.
EmptyTuple = ()
print(EmptyTuple)
print(... |
class BalanceResponse(object):
def __init__(self, data):
self.exchangeId = data['exchangeId']
self.currencyId = data['currencyId']
self.availableBalance = data['availableBalance']
self.realizedBalance = data['realizedBalance']
self.currencySymbol = data['currencySymbol']
... |
#!/usr/bin/python3
"""
Copyright 2018 Nicolas Simonin
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, including without limitation the rights
to use, copy, modify, merge, publ... |
'''
Given a sorted, increasing-order array with unique integer elements,
write an algorithm to create a binary search tree with minimal height.
'''
class myBST():
def __init__(self,key = None, parent = None):
# quick BST structure
self.key = key
self.parent = parent
self.right = ... |
while True:
print('Para interromper o programa digite [-1]')
print('\033[34m=-\033[m'*19)
n = int(input('Digite um número para ver sua taboada: '))
for t in range(1, 11):
print(f'{n} + {t:2} = {n+t}')
print('\033[35m=-\033[m'*6)
for t in range(1, 11):
print(f'{n} X {t:2} = {n*t}'... |
"""
Prefer Interpolated F-Strings Over C-style Format Strings and str.format
"""
# Defining binary and hexadecimal variables
binary = 0b10111011
hexadecimal = 0xc5f
key = "my_var"
value = 1.234
pantry = [
("avocados", 125),
("bananas", 2.5),
("cherries", 15)
]
template = "%s loves food, See %s cook.... |
#! /usr/bin/env python3
# Load maze file into nested array:
with open('../inputs/input25.txt') as fp:
grid = [list(line.strip()) for line in fp.readlines()]
ydim = len(grid)
xdim = len(grid[0])
SYMBOLS = { 'east': '>', 'south': 'v', 'empty': '.'}
# Look up which coords a mover wants to move to
def target_cell(co... |
def solve(arr):
n = len(arr)
lis = [1 for _ in range(n)]
for i in range(1, n):
for j in range(0, i):
if arr[j] < arr[i] and lis[i] < 1 + lis[j]:
lis[i] = 1 + lis[j]
return max(lis)
arr = [3, 10, 2, 1, 20]
assert 3 == solve(arr)
arr = [3, 2]
assert 1 == solve(arr)
arr = [50, 3, 10, 7, 40, ... |
#pragma error
#pragma repy restrictions.badcallname
pass
|
class TestAnomalyDetector(object):
# Lets make some dummy tests to test our Travis-CI configuration
def test_pass(self):
assert 1 == 1
def nothing(self):
print('This does nothing'); |
# Copyright 2022 The Bazel Authors. 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 la... |
"""
Define contstants
"""
LOOP_DEV = "/dev/loop0"
IMG_FILE = "/tmp/hl_lvm.img"
IMG_SIZE = 128 * 1024 ** 2
TEST_VG = "holland"
TEST_LV = "test_lv"
|
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//ocaml:providers.bzl",
"CompilationModeSettingProvider",
"OcamlProvider",
"OcamlNsResolverProvider",
"OcamlLibraryMarker",
"OcamlModuleMarker",
"OcamlNsMarker")
loa... |
def celsius_to_fahrenheit(Celsius):
F = (Celsius/5)*9 + 32
print(F)
def celsius_to_kelvin(Celsius):
K = Celsius + 273
print(K)
def kelvin_to_celsius(Kelvin):
C = Kelvin - 273
print(C)
def kelvin_to_fahrenheit(Kelvin):
F = (((Kelvin - 273) / 5) * 9) + 32
print(F)
def fahrenheit_to_kel... |
"""Module for compilation configuration."""
class CompilationConfiguration:
"""Class that allows the compilation process to be customized."""
dump_artifacts_on_unexpected_failures: bool
enable_topological_optimizations: bool
check_every_input_in_inputset: bool
treat_warnings_as_errors: bool
e... |
def add(x, y):
return x + y
a = 1
b = 2
result = add(a, b)
print("This is the sum: {}, {}, {}".format(a,b,result))
|
def regex(ref, char):
passed = True
for i in ref:
if char == i:
passed = False
return passed |
'''
Created on Aug 30, 2018
@author: Manikandan.R
'''
print ('Running Fibonacci')
a, b = 0, 1
while a < 10:
print(a, end=',')
a, b = b, a + b
print ('Handling Strings')
alphas = "abcdefghijklmnopqrstuvwxyz"
index = len(alphas) // 2
alpha1 = alphas[: index]
alpha2 = alphas[index :]
print ('alphas: ' + alphas)
pri... |
"""
is_anti_list(["1", "0", "0", "1"],
["0", "1", "1", "0"]) ➞ True
is_anti_list(["apples", "bananas", "bananas"],
["bananas", "apples", "apples"]) ➞ True
is_anti_list([3.14, True, 3.14],
[3.14, False, 3.14]) ➞ False
"""
def is_anti_list(list1, list2) -> bool:
if len(list1) ... |
class DebuggableAttribute(Attribute,_Attribute):
"""
Modifies code generation for runtime just-in-time (JIT) debugging. This class cannot be inherited.
DebuggableAttribute(isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool)
DebuggableAttribute(modes: DebuggingModes)
"""
def __init__(self,*args):
... |
class Appointment():
def __init__(self):
self.patient_ID = 0
self.doctor_ID = 0
self.profession = ""
self.day = ""
self.confirm = 0
self.success = 0
|
class Solution:
def singleNumber(self, nums: List[int]) -> int:
result = 0
for n in nums:
result ^= n
return result |
x_range_callback = """
var start = cb_obj.start;
var end = cb_obj.end;
var width = end - start;
var threshold = %f * width; // threshold factor is set from python-side configuration
var intron_alpha = %f; // alpha value is set from python-side configuration
// iterate over each intron
var data = source.da... |
X_full = brca.data
X_train, X_test, y_train, y_test = train_test_split(X_full, y, test_size=0.2, random_state=0)
scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
clf = neighbors.KNeighborsClassifier(n_neighbors=5)
clf.fit(X_train, y_train)
test_score = clf.score(X_test, y_t... |
# -*- coding: utf-8 -*-
def main():
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
print('Bad')
else:
print('Good')
if __name__ == '__main__':
main()
|
#UNION
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 | my_set2
print(my_set3)
# {3, 4, 5, 6, 7}
#INTERSECCION
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 & my_set2
print(my_set3)
# {5}
#DIFERENCIA
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 - my_set2
print(my_set3)
my_set... |
#!/usr/bin/env python
#
# description: Edit Distance
# difficulty: Hard
# leetcode_num: 72
# leetcode_url: https://leetcode.com/problems/edit-distance/
#
# Given two words word1 and word2, find the minimum number of operations
# required to convert word1 to word2.
#
# You have the following 3 operations permitted on a ... |
'''
Contains all the modules that should be available when this folder is imported.
'''
__all__ = [
'google_search',
'bumble_help',
'clock_in',
'clock_out',
'chatbot',
'grepapp_search',
'send_email',
'open_notepad',
'wiki_search',
'wolfram_search',
'start_research_server',
... |
class Test():
def __init__(self, test_attr):
self.test_attr = test_attr
self.test_fn()
print(self.test_attr)
def test_fn(self):
self.test_attr = "goodbye world" |
class Library:
def __init__(self,libraryname,booklist):
self.lend_book={}
self.library_name=libraryname
self.booklist=booklist
for book in self.booklist:
self.lend_book[book] = None
def add_books(self,book_name):
self.booklist.append(book_name)
self.... |
class Solution:
# O(n) time | O(1) space where n is the length of the input array
def missingNumber(self, nums: List[int]) -> int:
missingNumber = 0
for i in range(len(nums)):
missingNumber ^= nums[i]
for i in range(len(nums) + 1):
missingNumber ^= i
... |
"""Consts for Cast integration."""
DOMAIN = "cast"
DEFAULT_PORT = 8009
# Stores a threading.Lock that is held by the internal pychromecast discovery.
INTERNAL_DISCOVERY_RUNNING_KEY = "cast_discovery_running"
# Stores UUIDs of cast devices that were added as entities. Doesn't store
# None UUIDs.
ADDED_CAST_DEVICES_KEY... |
# Write a program that prints the next 20 leap years (enter year or if not, get current year as default)
print('Type your year that you want to check:')
value = int(input())
count = 1
i = 0
def leap_years(year):
if year % 100 == 0:
if year % 400 == 0:
return True
else:
... |
# Top fields
BANDIT_TYPE = 'bandit_type'
BANDIT_ID = 'bandit_id'
PRIORS = 'priors'
ARM_IDS = 'arm_ids'
PARAMETERS = 'parameters'
# Values
N = 'n'
REWARD_SUM = 'reward_sum'
SQUARED_REWARD_SUM = 'squared_reward_sum'
N_REWARDS = 'n_rewards'
# Parametres
EPSILON = 'epsilon'
|
class PyCrudException(Exception):
pass
class DBException(PyCrudException):
pass
class PermissionException(PyCrudException):
pass
class UnknownDatabaseException(PyCrudException):
pass
class InvalidQueryConditionColumn(PyCrudException):
pass
class InvalidQueryConditionOperator(PyCrudExcepti... |
# -*- coding: UTF-8 -*-
def formatMultiline(text, line_length):
return "\n".join(text[i - line_length: i] for i
in range(line_length,
len(text) + line_length,
line_length)
)
def breakByWords(text, max_le... |
if __name__ == '__main__':
string = "2018-11-13"
print(string.replace("-", ""))
string = "201812"
print(string.count("2"))
string = "12345678901234567890"
for i in range(len(string)):
print(string[i], end="")
if (i + 1) % 4 == 0:
print("\n")
string = "123456789012... |
UNK = 0
BOS = 1
EOS = 2
WORD = {
UNK: '<unk>',
BOS: '<s>',
EOS: '</s>'
}
|
'''
Created on Feb 14, 2019
@author: jcorley
'''
PROTOCOL = "tcp"
IP_ADDRESS = "127.0.0.1"
PORT="5555"
KEY_REQUEST_TYPE = "request_type"
KEY_FAILURE_MESSAGE = "failure_message"
KEY_RECIPES = "recipes"
KEY_STATUS = "status"
SUCCESS_STATUS = 1
BAD_MESSAGE_STATUS = -1
UNSUPPORTED_OPERATION_STATUS = -1
... |
CLI_OPTS = {
'data_path': {
'env': 'ELLIOTT_DATA_PATH',
'help': 'Git URL or File Path to build data'
},
'group': {
'env': 'ELLIOTT_GROUP',
'help': 'Sub-group directory or branch to pull build data'
},
'working_dir': {
'env': 'ELLIOTT_WORKING_DIR',
'hel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.