content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def even_list(list):
ans = []
for i in list:
if i % 2 == 0: ans.append(i)
return ans
list = [int(i) for i in input().split()]
print(even_list(list)) | def even_list(list):
ans = []
for i in list:
if i % 2 == 0:
ans.append(i)
return ans
list = [int(i) for i in input().split()]
print(even_list(list)) |
# Copyright 2019 Jeremy Schulman, nwkautomaniac@gmail.com
#
# 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 l... | database_model = dict(nodes=['Cable', 'Device', 'DeviceGroup', 'Interface', 'IPAddress', 'IPNetwork', 'IPInterface', 'LAG', 'LACP', 'RoutingTable', 'VLAN', 'VLANGroup'], edges=[('Device', 'device_member', 'DeviceGroup'), ('Device', 'equip_interface', 'Interface'), ('Interface', 'lag_member', 'LAG'), ('Interface', 'cabl... |
n=int(input());cnt=0
for i in range(1,501):
for j in range(1,i+1):
if i**2==j**2+n: cnt+=1
print(cnt)
| n = int(input())
cnt = 0
for i in range(1, 501):
for j in range(1, i + 1):
if i ** 2 == j ** 2 + n:
cnt += 1
print(cnt) |
'''
Statement
Given the integer N - the number of seconds that is passed since midnight - how many full hours and full minutes are passed since midnight?
The program should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 1339).
For example, if N = 3900, then 3900 sec... | """
Statement
Given the integer N - the number of seconds that is passed since midnight - how many full hours and full minutes are passed since midnight?
The program should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 1339).
For example, if N = 3900, then 3900 sec... |
__all__ = ['hot_url', 'bill200_url', 'hdr']
hot_url = "https://www.billboard.com/charts/hot-100"
bill200_url = "https://www.billboard.com/charts/billboard-200"
hdr = {'User-Agent': 'Mozilla/5.0'}
| __all__ = ['hot_url', 'bill200_url', 'hdr']
hot_url = 'https://www.billboard.com/charts/hot-100'
bill200_url = 'https://www.billboard.com/charts/billboard-200'
hdr = {'User-Agent': 'Mozilla/5.0'} |
def match(command, settings):
return command.script.strip().startswith('man ')
def get_new_command(command, settings):
if '3' in command.script:
return command.script.replace("3", "2")
if '2' in command.script:
return command.script.replace("2", "3")
split_cmd2 = command.script.split(... | def match(command, settings):
return command.script.strip().startswith('man ')
def get_new_command(command, settings):
if '3' in command.script:
return command.script.replace('3', '2')
if '2' in command.script:
return command.script.replace('2', '3')
split_cmd2 = command.script.split()
... |
# -*-coding:utf-8 -*-
'''
@File : __init__.py.py
@Author : HW Shen
@Date : 2020/8/19
@Desc :
''' | """
@File : __init__.py.py
@Author : HW Shen
@Date : 2020/8/19
@Desc :
""" |
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# List of self-checking test applications, which return PASS or FAIL after
# completion.
#
# Each list entry is a dict with the following keys:
#
# name:
# Name of the te... | test_apps_selfchecking = [{'name': 'aes_smoketest', 'targets': ['sim_verilator']}] |
df=pd.read_csv("data/Human_nuisance.csv", index_col=0)
df = df.rename( columns = {"Breeding density(individuals per ha)" : "Breeding" ,
"Number of pedestrians per ha per min" : "Number" } )
## let's build a reference model with only the number
model = smf.ols( 'Breeding ~ Number' , data=df)
results = m... | df = pd.read_csv('data/Human_nuisance.csv', index_col=0)
df = df.rename(columns={'Breeding density(individuals per ha)': 'Breeding', 'Number of pedestrians per ha per min': 'Number'})
model = smf.ols('Breeding ~ Number', data=df)
results = model.fit()
ref_model = 'Breeding ~ Number'
ref_results = results
max_pow = 10
t... |
class Path():
def __init__(self, commands):
self.commands = ["f"]
for command in commands:
self.commands.append(command)
def __getitem__(self, i):
return self.commands[i]
def __len__(self):
return len(self.commands)
def __str__(self):
result = ""... | class Path:
def __init__(self, commands):
self.commands = ['f']
for command in commands:
self.commands.append(command)
def __getitem__(self, i):
return self.commands[i]
def __len__(self):
return len(self.commands)
def __str__(self):
result = ''
... |
def setup():
size(400, 400)
noLoop()
def draw():
for x in range(width):
for y in range(height):
colorMode(HSB)
h = map(x, 0, width-1, 0, 255)
s = map(y, 0, height-1, 255, 0)
stroke(h, s, 255)
point(x, y)
| def setup():
size(400, 400)
no_loop()
def draw():
for x in range(width):
for y in range(height):
color_mode(HSB)
h = map(x, 0, width - 1, 0, 255)
s = map(y, 0, height - 1, 255, 0)
stroke(h, s, 255)
point(x, y) |
# @staticmethod
def nth_root(a, b):
# try:
# if a >= 0 and b is int:
return a ** (1/b)
# except ValueError:
# print('No Negative Numbers For Base')
| def nth_root(a, b):
return a ** (1 / b) |
(
"circuit",
("register", "q", 1),
("macro", "F0", "qubit", ("sequential_block",)),
("macro", "F1", "qubit", ("sequential_block", ("gate", "Sx", "qubit"))),
("macro", "F2", "qubit", ("sequential_block", ("gate", "Sy", "qubit"))),
(
"macro",
"F3",
"qubit",
("sequen... | ('circuit', ('register', 'q', 1), ('macro', 'F0', 'qubit', ('sequential_block',)), ('macro', 'F1', 'qubit', ('sequential_block', ('gate', 'Sx', 'qubit'))), ('macro', 'F2', 'qubit', ('sequential_block', ('gate', 'Sy', 'qubit'))), ('macro', 'F3', 'qubit', ('sequential_block', ('gate', 'Sx', 'qubit'), ('gate', 'Sx', 'qubi... |
held=int(input())
present=int(input())
percentage= ((present/held)*100)
if percentage>=75:
print("u are allowed to exam")
else:
print("not allowed") | held = int(input())
present = int(input())
percentage = present / held * 100
if percentage >= 75:
print('u are allowed to exam')
else:
print('not allowed') |
#!/home/firlism/tools/css_platform/sleepyenv/bin/python
# EASY-INSTALL-SCRIPT: 'Pillow==2.8.2','pilfile.py'
__requires__ = 'Pillow==2.8.2'
__import__('pkg_resources').run_script('Pillow==2.8.2', 'pilfile.py')
| __requires__ = 'Pillow==2.8.2'
__import__('pkg_resources').run_script('Pillow==2.8.2', 'pilfile.py') |
def insertion_sort( list_to_sort ):
n = len(list_to_sort)
i = 1
while i < n:
number = list_to_sort[i]
j = i
while j >= 0:
if list_to_sort[j] > number:
list_to_sort[j+1] = list_to_sort[j]
j -=1
else:
list_to_sort[... | def insertion_sort(list_to_sort):
n = len(list_to_sort)
i = 1
while i < n:
number = list_to_sort[i]
j = i
while j >= 0:
if list_to_sort[j] > number:
list_to_sort[j + 1] = list_to_sort[j]
j -= 1
else:
list_to_sort... |
'''
import dflux_fort
print(dflux_fort.__doc__)
# function signature
dflux_fort.dflux(ny,il,jl,ie,je,w,p,pori,porj,fw,radi,radj,rfil,vis2,vis4)
''' | """
import dflux_fort
print(dflux_fort.__doc__)
# function signature
dflux_fort.dflux(ny,il,jl,ie,je,w,p,pori,porj,fw,radi,radj,rfil,vis2,vis4)
""" |
# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [riscv_const.py]
# Operand type for instruction's operands
RISCV_OP_INVALID = 0
RISCV_OP_REG = 1
RISCV_OP_IMM = 2
RISCV_OP_MEM = 3
# RISCV registers
RISCV_REG_INVALID = 0
# General purpose registers
RISCV_REG_X0 = 1
RISCV_REG_ZERO = RISCV_REG_X0
RISCV_REG_X1 ... | riscv_op_invalid = 0
riscv_op_reg = 1
riscv_op_imm = 2
riscv_op_mem = 3
riscv_reg_invalid = 0
riscv_reg_x0 = 1
riscv_reg_zero = RISCV_REG_X0
riscv_reg_x1 = 2
riscv_reg_ra = RISCV_REG_X1
riscv_reg_x2 = 3
riscv_reg_sp = RISCV_REG_X2
riscv_reg_x3 = 4
riscv_reg_gp = RISCV_REG_X3
riscv_reg_x4 = 5
riscv_reg_tp = RISCV_REG_X4... |
class Televisao:
def __init__(self, min, max):
self.ligada = False
self.canal = 2
self.cmin = min
self.cmax = max
def muda_canal_para_baixo(self):
if self.canal-1 >= self.cmin:
self.canal -= 1
else:
self.canal = self.cmax
def muda_can... | class Televisao:
def __init__(self, min, max):
self.ligada = False
self.canal = 2
self.cmin = min
self.cmax = max
def muda_canal_para_baixo(self):
if self.canal - 1 >= self.cmin:
self.canal -= 1
else:
self.canal = self.cmax
def muda_... |
class Tile:
map_word = "Beach"
def describe(self):
print("You walk in the beach. There is a light house on the west.\n")
def action(self, player, do):
print("I don't understand.")
def leave(self, player, direction):
if direction == "n":
print("It's the open... | class Tile:
map_word = 'Beach'
def describe(self):
print('You walk in the beach. There is a light house on the west.\n')
def action(self, player, do):
print("I don't understand.")
def leave(self, player, direction):
if direction == 'n':
print("It's the open sea. Yo... |
_base_ = ['../cityscapes_grid/cascade_mask_rcnn_r50_fpn_1x_cityscapes.py',]
relations = ["above", "left of", "right of", "below",]
classes = [f"7 {r} 6" for r in relations] + ["all 6s"]
n_freq = 3
bbox_head_kwargs = dict(
type='SpatialRelationBBoxHead',
in_channels=256,
fc_out_channels=1024,
roi_feat_s... | _base_ = ['../cityscapes_grid/cascade_mask_rcnn_r50_fpn_1x_cityscapes.py']
relations = ['above', 'left of', 'right of', 'below']
classes = [f'7 {r} 6' for r in relations] + ['all 6s']
n_freq = 3
bbox_head_kwargs = dict(type='SpatialRelationBBoxHead', in_channels=256, fc_out_channels=1024, roi_feat_size=7, reg_class_agn... |
class CLSInternalError(Exception):
pass
class CLSActionIsRunning(Exception):
pass
class CLSUnknownAnswer(Exception):
pass
| class Clsinternalerror(Exception):
pass
class Clsactionisrunning(Exception):
pass
class Clsunknownanswer(Exception):
pass |
INT_MAX = 4294967296
INT_MIN = -4294967296
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def checkBST(node, mini = INT_MIN, maxi = INT_MAX):
if node == None:
return True
if node.data < mini or node.data > maxi:
return Fals... | int_max = 4294967296
int_min = -4294967296
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def check_bst(node, mini=INT_MIN, maxi=INT_MAX):
if node == None:
return True
if node.data < mini or node.data > maxi:
return False
... |
# -*- coding: utf-8 -*-
# @Time : 2020/12/23 08:59
# @Author : ooooo
class Solution:
def firstUniqChar(self, s: str) -> int:
map = {}
for c in s:
if c in map:
map[c] += 1
else:
map[c] = 1
for i in range(len(s)):
if map[... | class Solution:
def first_uniq_char(self, s: str) -> int:
map = {}
for c in s:
if c in map:
map[c] += 1
else:
map[c] = 1
for i in range(len(s)):
if map[s[i]] == 1:
return i
return -1 |
# -*- coding: utf-8 -*-
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.todo',
'sphinx.ext.imgmath',
... | extensions = ['sphinx.ext.todo', 'sphinx.ext.imgmath', 'sphinx.ext.graphviz', 'rst2pdf.pdfbuilder']
master_doc = 'foobar'
project = u'Foobar'
copyright = u'2009, Jason S'
version = '1.0.1'
release = '1.0.1'
pdf_documents = [('foobar', u'foobar', u'foobar Documentation', u'jsachs')]
pdf_language = 'en_US'
pdf_verbosity ... |
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Silvio Peroni <essepuntato@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any purpose
# with or without fee is hereby granted, provided that the above copyright notice
# and this permission notice appear in all copies.
#
# THE SOFTWARE I... | def r(f_name, m_list):
f = list()
for item in m_list:
l_name = len(f_name)
if item and l_name:
idx = item % l_name
f.extend(r(f_name[0:idx], m_list))
f.insert(0, f_name[idx])
return f
return f
my_mat_list = [int(c) for c in input('Please provid... |
# Sum of digits until get a single digit
n = int(input())
def calsum(n):
s = 0
while(n > 0):
s = s+(n % 10)
n = n//10
return(s)
while(n > 9):
n = calsum(n)
print(n)
| n = int(input())
def calsum(n):
s = 0
while n > 0:
s = s + n % 10
n = n // 10
return s
while n > 9:
n = calsum(n)
print(n) |
# https://leetcode.com/problems/richest-customer-wealth/
class Solution:
def maximumWealth(self, accounts: List[List[int]]) -> int:
prev = -1
for wealth in accounts:
if sum(wealth) > prev:
prev = sum(wealth)
return prev
| class Solution:
def maximum_wealth(self, accounts: List[List[int]]) -> int:
prev = -1
for wealth in accounts:
if sum(wealth) > prev:
prev = sum(wealth)
return prev |
# we check if current step leads to height 0 and previous height was -ve.
height = 0
prev_height = 0
cnt = 0
n = input()
s = input().strip()
for i in range(len(s)):
if (s[i] == 'U'):
height += 1
elif s[i] == 'D':
height -= 1
if height == 0 and prev_height < 0:
cnt += 1
prev_hei... | height = 0
prev_height = 0
cnt = 0
n = input()
s = input().strip()
for i in range(len(s)):
if s[i] == 'U':
height += 1
elif s[i] == 'D':
height -= 1
if height == 0 and prev_height < 0:
cnt += 1
prev_height = height
print(cnt) |
# Problem: https://www.hackerrank.com/challenges/designer-door-mat/problem
# Score: 10
height, length = map(int, input().split())
for i in range(0, height // 2):
s = '.|.' * (i * 2 + 1)
print(s.center(length,'-'))
print('WELCOME'.center(length, '-'))
for i in range(height // 2 - 1, -1, -1):
s = '.|.' * (i... | (height, length) = map(int, input().split())
for i in range(0, height // 2):
s = '.|.' * (i * 2 + 1)
print(s.center(length, '-'))
print('WELCOME'.center(length, '-'))
for i in range(height // 2 - 1, -1, -1):
s = '.|.' * (i * 2 + 1)
print(s.center(length, '-')) |
class Solution:
def reorderedPowerOf2(self, N: int) -> bool:
def isAnagram(s, t):
def frequencies(s):
f = dict()
for c in s:
if c not in f:
f[c] = 0
f[c] += 1
return f
ret... | class Solution:
def reordered_power_of2(self, N: int) -> bool:
def is_anagram(s, t):
def frequencies(s):
f = dict()
for c in s:
if c not in f:
f[c] = 0
f[c] += 1
return f
... |
def get_factors(array):
factor = [0] * len(array)
factor[0] = 1
for i in range(1,len(array)):
factor[i] = array[i-1] * factor[i-1]
base = 1
for j in range(len(array)-1,-1,-1):
factor[j] *= base
base *= array[j]
return factor
assert get_factors([1... | def get_factors(array):
factor = [0] * len(array)
factor[0] = 1
for i in range(1, len(array)):
factor[i] = array[i - 1] * factor[i - 1]
base = 1
for j in range(len(array) - 1, -1, -1):
factor[j] *= base
base *= array[j]
return factor
assert get_factors([1, 2, 3, 4, 5]) ==... |
#
# PySNMP MIB module NETSERVER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NETSERVER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:11:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, constraints_intersection, value_range_constraint, value_size_constraint) ... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
assert format('asdf', '8') == 'asdf '
assert not format('asdf', '8') is 'asdf '
| assert format('asdf', '8') == 'asdf '
assert not format('asdf', '8') is 'asdf ' |
class Money:
moneyId : int
money : int
today: str
days: int
def setMoneyId(self, moneyId):
self.moneyId = moneyId
def setMoney(self, money):
self.money = money
def setToday(self, today):
self.today = today
def setDays(self, days):
self.days = days... | class Money:
money_id: int
money: int
today: str
days: int
def set_money_id(self, moneyId):
self.moneyId = moneyId
def set_money(self, money):
self.money = money
def set_today(self, today):
self.today = today
def set_days(self, days):
self.days = days
... |
userEntry = int(input("Enter a number: "))
if userEntry > 1:
for i in range(2, userEntry):
if userEntry % i == 0:
print(userEntry, "is a Composite Number.")
break
else:
print(userEntry, "is a Prime Number.")
elif userEntry == 0 or userEntry == 1:
print(userEntry, "is... | user_entry = int(input('Enter a number: '))
if userEntry > 1:
for i in range(2, userEntry):
if userEntry % i == 0:
print(userEntry, 'is a Composite Number.')
break
else:
print(userEntry, 'is a Prime Number.')
elif userEntry == 0 or userEntry == 1:
print(userEntry, 'is... |
FULFILLMENT_SUBMITTED = 0
FULFILLMENT_SUBMITTED_ISSUER = 1
BOUNTY_ACTIVATED = 2
FULFILLMENT_ACCEPTED = 3
FULFILLMENT_ACCEPTED_FULFILLER = 4
BOUNTY_EXPIRED = 5
BOUNTY_ISSUED = 6
BOUNTY_KILLED = 7
CONTRIBUTION_ADDED = 8
DEADLINE_EXTENDED = 9
BOUNTY_CHANGED = 10
ISSUER_TRANSFERRED = 11
TRANSFER_RECIPIENT = 12
PAYOUT_INCRE... | fulfillment_submitted = 0
fulfillment_submitted_issuer = 1
bounty_activated = 2
fulfillment_accepted = 3
fulfillment_accepted_fulfiller = 4
bounty_expired = 5
bounty_issued = 6
bounty_killed = 7
contribution_added = 8
deadline_extended = 9
bounty_changed = 10
issuer_transferred = 11
transfer_recipient = 12
payout_incre... |
# Python - 3.6.0
Test.assert_equals(feast('great blue heron', 'garlic naan'), True)
Test.assert_equals(feast('chickadee', 'chocolate cake'), True)
Test.assert_equals(feast('brown bear', 'bear claw'), False)
| Test.assert_equals(feast('great blue heron', 'garlic naan'), True)
Test.assert_equals(feast('chickadee', 'chocolate cake'), True)
Test.assert_equals(feast('brown bear', 'bear claw'), False) |
# def smash(words):
# return ' '.join(words)
# smash = lambda words: ' '.join(words)
smash = ' '.join
| smash = ' '.join |
def split(word):
return [char for char in word]
def argsort(sequence):
return sorted(range(len(sequence)), key=sequence.__getitem__)
def build_key_matrix(key):
key = ''.join(dict.fromkeys(key))
m = [
split(key)
]
char = ord('A')
end = ord('Z')
cols = len(key)
rows = int... | def split(word):
return [char for char in word]
def argsort(sequence):
return sorted(range(len(sequence)), key=sequence.__getitem__)
def build_key_matrix(key):
key = ''.join(dict.fromkeys(key))
m = [split(key)]
char = ord('A')
end = ord('Z')
cols = len(key)
rows = int((26 - cols) / col... |
class PN(object):
def __init__(self, transitions):
self.__transitions = transitions
self.__enabled_transitions = list(filter(lambda transition: transition.is_enabled(), self.__transitions))
def get_enabled_transitions(self):
return self.__enabled_transitions
def get_state_dict(self... | class Pn(object):
def __init__(self, transitions):
self.__transitions = transitions
self.__enabled_transitions = list(filter(lambda transition: transition.is_enabled(), self.__transitions))
def get_enabled_transitions(self):
return self.__enabled_transitions
def get_state_dict(sel... |
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
c = min([a[0][0], a[0][n-1], a[n - 1][0], a[n - 1][n - 1]])
if a[0][0] == c:
for i in a:
print(*i)
pass
elif a[0][n - 1] == c:
for i in range(n - 1, -1, -1):
for j in range(n):
print(a[j][i], end=' ')
... | n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
c = min([a[0][0], a[0][n - 1], a[n - 1][0], a[n - 1][n - 1]])
if a[0][0] == c:
for i in a:
print(*i)
pass
elif a[0][n - 1] == c:
for i in range(n - 1, -1, -1):
for j in range(n):
print(a[j][i], end=' ')
... |
# Implementation of Singly Linked list in Python
# Node of a Singly Linked List
class Node:
# constructor
def __init__(self, data):
self.data = data
self.next = None
def set_data(self, data):
# method for setting the data field of the node
self.data = data
def get_dat... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def set_data(self, data):
self.data = data
def get_data(self):
return self.data
def set_next(self, next):
self.next = next
def get_next(self):
return self.next
def has_ne... |
class MessageType:
BEGIN_SESSION = 0
YES = 1
NO = 2
CONTINUE_SESSION = 3
ATTACK_SUBMARINE = 4
ERROR = 5
DISCONNECT = 6
READY = 7
SUBMARINE_SANK = 8
KEEP_ALIVE = 9
MESSAGE_FIELDS_COUNTS = {
MessageType.BEGIN_SESSION: 2,
MessageType.YES: 0,
MessageType.NO: 0,
Mess... | class Messagetype:
begin_session = 0
yes = 1
no = 2
continue_session = 3
attack_submarine = 4
error = 5
disconnect = 6
ready = 7
submarine_sank = 8
keep_alive = 9
message_fields_counts = {MessageType.BEGIN_SESSION: 2, MessageType.YES: 0, MessageType.NO: 0, MessageType.CONTINUE_SE... |
def increase_version_minor(version, by=1):
return __modify_minor_version__(version, True, by)
def decrease_version_minor(version, by=1):
return __modify_minor_version__(version, False, by)
def __modify_minor_version__(version, addition, by=1):
minor = __get_minor_version__(version)
minor = minor + by ... | def increase_version_minor(version, by=1):
return __modify_minor_version__(version, True, by)
def decrease_version_minor(version, by=1):
return __modify_minor_version__(version, False, by)
def __modify_minor_version__(version, addition, by=1):
minor = __get_minor_version__(version)
minor = minor + by ... |
#======================================
# Solution#1 Sorting
#======================================
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
return sorted(s) == sorted(t)
#======================================
# Solution#2 Hash Table
#======================================
cla... | class Solution:
def is_anagram(self, s: str, t: str) -> bool:
return sorted(s) == sorted(t)
class Solution:
def is_anagram(self, s: str, t: str) -> bool:
(d_s, d_t) = ({}, {})
for c in s:
d_s[c] = d_s.get[c, 0] + 1
for c in t:
d_t[c] = d_t.get[c, 0] + 1... |
crayons = ["Macaroni and Cheese", "Maximum Yellow Red", "Jazzberry Jam"]
print(crayons)
crayons[1] = "Cotton Candy"
print(crayons) | crayons = ['Macaroni and Cheese', 'Maximum Yellow Red', 'Jazzberry Jam']
print(crayons)
crayons[1] = 'Cotton Candy'
print(crayons) |
class User:
id = 0
first_name = ''
last_name = ''
email = ''
projects = []
def __init__(self, id, first_name, last_name, email, projects):
self.id = id
self.first_name = first_name
self.last_name = last_name
self.email = email
self.projects = projects
... | class User:
id = 0
first_name = ''
last_name = ''
email = ''
projects = []
def __init__(self, id, first_name, last_name, email, projects):
self.id = id
self.first_name = first_name
self.last_name = last_name
self.email = email
self.projects = projects
... |
__title__ = 'django-ipware'
__author__ = 'Val Neekman'
__author_email__ = 'info@neekware.com'
__description__ = "A Django application to retrieve user's IP address"
__url__ = 'https://github.com/un33k/django-ipware'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 Val Neekman @ Neekware Inc.'
__version__ = '4.0.0'
| __title__ = 'django-ipware'
__author__ = 'Val Neekman'
__author_email__ = 'info@neekware.com'
__description__ = "A Django application to retrieve user's IP address"
__url__ = 'https://github.com/un33k/django-ipware'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 Val Neekman @ Neekware Inc.'
__version__ = '4.0.0' |
class FeatureGenerator:
def __init__(self, limit, accumulators, save_only_features=False, input_df=None, save_as=None):
self.limit = limit
self.accumulators = accumulators
self.accs_by_action_type = group_accumulators(accumulators)
self.save_only_features = save_only_features
... | class Featuregenerator:
def __init__(self, limit, accumulators, save_only_features=False, input_df=None, save_as=None):
self.limit = limit
self.accumulators = accumulators
self.accs_by_action_type = group_accumulators(accumulators)
self.save_only_features = save_only_features
... |
with open("validate.txt","w") as f:
for i in range(25):
f.writelines("{0} {1} {2}\n".format(0,0,0^0))
for i in range(25):
f.writelines("{0} {1} {2}\n".format(0, 1, 0 ^ 1))
for i in range(25):
f.writelines("{0} {1} {2}\n".format(1, 0, 1 ^ 0))
for i in range(25):
f.write... | with open('validate.txt', 'w') as f:
for i in range(25):
f.writelines('{0} {1} {2}\n'.format(0, 0, 0 ^ 0))
for i in range(25):
f.writelines('{0} {1} {2}\n'.format(0, 1, 0 ^ 1))
for i in range(25):
f.writelines('{0} {1} {2}\n'.format(1, 0, 1 ^ 0))
for i in range(25):
f.wri... |
#
# PySNMP MIB module PAIRGAIN-DS1-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PAIRGAIN-DS1-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:36:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, value_size_constraint, constraints_union, single_value_constraint) ... |
{
'targets': [
{
# unit testing library
'target_name': 'CppUnitLite',
'type': 'static_library',
'sources': [
'src/Failure.cpp',
'src/SimpleString.cpp',
'src/Test.cpp',
'src/TestResult.cpp',
'src/TestRegistry.cpp'
],
'include_dirs': [... | {'targets': [{'target_name': 'CppUnitLite', 'type': 'static_library', 'sources': ['src/Failure.cpp', 'src/SimpleString.cpp', 'src/Test.cpp', 'src/TestResult.cpp', 'src/TestRegistry.cpp'], 'include_dirs': ['./CppUnitLite']}, {'target_name': 'test', 'type': 'executable', 'dependencies': ['CppUnitLite'], 'sources': ['test... |
terms_by_type = {
'Corporation': ['company', 'incorporation', 'incorporated', 'corporation', 'corp.', 'corp', 'inc',
'& co.', '& co', 'inc.', 's.p.a.', 'n.v.', 'a.g.', 'ag', 'a. g.', 'ag.', 'aktiengesellschaft', 'nuf', 's.f.',
'oao', 'co.', 'co'
],
'General Partnership': ['soc.col.', 'stg', 'd.n.o.... | terms_by_type = {'Corporation': ['company', 'incorporation', 'incorporated', 'corporation', 'corp.', 'corp', 'inc', '& co.', '& co', 'inc.', 's.p.a.', 'n.v.', 'a.g.', 'ag', 'a. g.', 'ag.', 'aktiengesellschaft', 'nuf', 's.f.', 'oao', 'co.', 'co'], 'General Partnership': ['soc.col.', 'stg', 'd.n.o.', 'ltda.', 'v.o.s.', '... |
Boundary_conditions = (-6, 6, -20, 2, -5, 5)
Volume_cell = 1.4397
File_out = "SWeqDH_Results"
Number_of_walkers = 100
Number_of_points = 1500
burn_in = 1000
Conc_injection = [500, 500, 500, 500]
Conc_protein_data = "Data/Protein.dat"
Conc_ligand_data = "Data/Ligand.dat"
DH_data = "Data/DH.dat"
Volume_injection_data = "... | boundary_conditions = (-6, 6, -20, 2, -5, 5)
volume_cell = 1.4397
file_out = 'SWeqDH_Results'
number_of_walkers = 100
number_of_points = 1500
burn_in = 1000
conc_injection = [500, 500, 500, 500]
conc_protein_data = 'Data/Protein.dat'
conc_ligand_data = 'Data/Ligand.dat'
dh_data = 'Data/DH.dat'
volume_injection_data = '... |
# Double Gold Star
# Khayyam Triangle
# The French mathematician, Blaise Pascal, who built a mechanical computer in
# the 17th century, studied a pattern of numbers now commonly known in parts of
# the world as Pascal's Triangle (it was also previously studied by many Indian,
# Chinese, and Persian mathematicians, an... | def triangle(n):
trianglelist = []
currentrow = [1]
for count in range(0, n):
trianglelist.append(currentrow)
nextrow = []
previouselement = 0
for element in currentrow:
nextrow.append(element + previouselement)
previouselement = element
nextro... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Check that flows that can never match any rule are properly discarded.
def a_source():
...
def a_sink(x):
...
def b_sink(x):
... | def a_source():
...
def a_sink(x):
...
def b_sink(x):
...
def sanitize_a_source_tito(x):
return x
def sanitize_a_sink_tito(x):
return x
def sanitize_b_sink_tito(x):
return x
def test_source_a_sanitize_a_kept():
return sanitize_a_sink_tito(a_source())
def test_source_a_sanitize_a_b_dis... |
# Balanced Brackets
# Given a string containing three types of brackets, determine if it is balanced.
#
# https://www.hackerrank.com/challenges/balanced-brackets/problem
#
def isBalanced(s):
stack = []
for c in s:
if c in "({[":
stack.append(c)
elif c in ")}]":
if len(st... | def is_balanced(s):
stack = []
for c in s:
if c in '({[':
stack.append(c)
elif c in ')}]':
if len(stack) == 0:
return False
d = stack.pop()
if d + c not in '(){}[]':
return False
return len(stack) == 0
for a0 in ... |
class BinaryTreeNode:
def __init__(self, data, left_node=None, right_node=None):
self.__data = data
self.__left_node = left_node
self.__right_node = right_node
@property
def data(self):
return self.__data
@data.setter
def data(self, data):
self.__data = dat... | class Binarytreenode:
def __init__(self, data, left_node=None, right_node=None):
self.__data = data
self.__left_node = left_node
self.__right_node = right_node
@property
def data(self):
return self.__data
@data.setter
def data(self, data):
self.__data = dat... |
l,k=[int(x) for x in input().split(" ")]
b=list(map(int,input().rstrip().split()))
z=[]
m=[]
o=[]
for i in b:
z.append(i)
if len(z)==k:
m.append(z)
z=[]
if len(z)>0:
m.append(z)
for i in range(len(m)):
if i%2!=0:
m[i]=reversed(m[i])
for i in m:
for j in i:
... | (l, k) = [int(x) for x in input().split(' ')]
b = list(map(int, input().rstrip().split()))
z = []
m = []
o = []
for i in b:
z.append(i)
if len(z) == k:
m.append(z)
z = []
if len(z) > 0:
m.append(z)
for i in range(len(m)):
if i % 2 != 0:
m[i] = reversed(m[i])
for i in m:
for j... |
def QuestionsMarks(strParam):
numbers = '0123456789'
my_list = []
for i in strParam:
if i == '?' or i in numbers:
my_list.append(i)
true_check = False
question_count = 0
value = 0
for i in my_list:
try:
value += int(i)
except ValueError:
... | def questions_marks(strParam):
numbers = '0123456789'
my_list = []
for i in strParam:
if i == '?' or i in numbers:
my_list.append(i)
true_check = False
question_count = 0
value = 0
for i in my_list:
try:
value += int(i)
except ValueError:
... |
class CommentFile:
def __init__(self, f, commentstring="#"):
self.f = f
self.commentstring = commentstring
def next(self):
line = self.f.next()
while line.startswith(self.commentstring):
line = self.f.next()
return line
def __iter__(self):
retur... | class Commentfile:
def __init__(self, f, commentstring='#'):
self.f = f
self.commentstring = commentstring
def next(self):
line = self.f.next()
while line.startswith(self.commentstring):
line = self.f.next()
return line
def __iter__(self):
retur... |
# -*- coding: utf-8 -*-
class PropertyFileLine:
def __init__(self, key, value=None, comment=None):
self.__line = None
self.__key = None
self.__value = None
self.__comment = None
if value is None and comment is None:
self.__parse_line(key)
else:
... | class Propertyfileline:
def __init__(self, key, value=None, comment=None):
self.__line = None
self.__key = None
self.__value = None
self.__comment = None
if value is None and comment is None:
self.__parse_line(key)
else:
self.__key = key
... |
class MmitssPhase():
def __init__(self, phaseNo:int):
self.phaseNo = phaseNo
self.currentCycle = 0
self.previousPhaseNo = False
self.previousPhaseClearanceTime = False
self.initialGMinTimeToEnd = [False, False]
self.initialGMaxTimeToEnd = [False, False]
self.i... | class Mmitssphase:
def __init__(self, phaseNo: int):
self.phaseNo = phaseNo
self.currentCycle = 0
self.previousPhaseNo = False
self.previousPhaseClearanceTime = False
self.initialGMinTimeToEnd = [False, False]
self.initialGMaxTimeToEnd = [False, False]
self.i... |
vowels = ['a', 'e', 'i', 'o', 'u']
word = "Milliways"
for letter in word:
if letter in vowels:
print(letter)
| vowels = ['a', 'e', 'i', 'o', 'u']
word = 'Milliways'
for letter in word:
if letter in vowels:
print(letter) |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"plot_3d_2": "00_core.ipynb",
"normalizePatches": "00_core.ipynb",
"len_multiple_32": "00_core.ipynb",
"mse_masked": "00_core.ipynb",
"mse_masked_loss": "00_core.ipynb",
... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'plot_3d_2': '00_core.ipynb', 'normalizePatches': '00_core.ipynb', 'len_multiple_32': '00_core.ipynb', 'mse_masked': '00_core.ipynb', 'mse_masked_loss': '00_core.ipynb', 'read_covid_CT_and_mask': '00_core.ipynb', 'normalize_rotate': '00_core.ipynb',... |
class SummitRestException(Exception):
def __init__(self, status, uri, msg='', code=None, method='GET'):
self.status = status
self.uri = uri
self.msg = msg
self.code = code
self.method = method
def __str__(self):
return 'HTTP {0} error: {1}'.format(self.status, s... | class Summitrestexception(Exception):
def __init__(self, status, uri, msg='', code=None, method='GET'):
self.status = status
self.uri = uri
self.msg = msg
self.code = code
self.method = method
def __str__(self):
return 'HTTP {0} error: {1}'.format(self.status, s... |
a=0
b=1
print(a)
print(b)
while(b>0):
c=a+b
print(c)
a=b
b=c
| a = 0
b = 1
print(a)
print(b)
while b > 0:
c = a + b
print(c)
a = b
b = c |
def memoized(f):
cache = {}
def wrapper(*args):
if args in cache:
return cache[args]
cache[args] = f(*args)
return cache[args]
return wrapper
@memoized
def fib(n):
return 1 if n <= 1 else fib(n-1) + fib(n-2)
print(fib(100))
| def memoized(f):
cache = {}
def wrapper(*args):
if args in cache:
return cache[args]
cache[args] = f(*args)
return cache[args]
return wrapper
@memoized
def fib(n):
return 1 if n <= 1 else fib(n - 1) + fib(n - 2)
print(fib(100)) |
def recursive(a, l, r):
if r - l > 1:
pivot = r - 1
wall = l
for i in range(l, r - 1):
if a[i] < a[pivot]:
a[wall], a[i] = a[i], a[wall]
wall += 1
a[wall], a[pivot] = a[pivot], a[wall]
recursive(a, l, wall)
recursive(a, wall... | def recursive(a, l, r):
if r - l > 1:
pivot = r - 1
wall = l
for i in range(l, r - 1):
if a[i] < a[pivot]:
(a[wall], a[i]) = (a[i], a[wall])
wall += 1
(a[wall], a[pivot]) = (a[pivot], a[wall])
recursive(a, l, wall)
recursive... |
walkscore_api_key = "ffd1c56f9abcf84872116b4cc2dfcf31"
gkey = "AIzaSyD147ThKlyPZsE9IGB5pptQi24HGdxAWjg"
fb_key = "174281959889926|ITtRr_yiNZ-d0PW_4x8F2i_K2hI" | walkscore_api_key = 'ffd1c56f9abcf84872116b4cc2dfcf31'
gkey = 'AIzaSyD147ThKlyPZsE9IGB5pptQi24HGdxAWjg'
fb_key = '174281959889926|ITtRr_yiNZ-d0PW_4x8F2i_K2hI' |
class Point(object):
'exercise 13-5'
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y
def __repr__(self):
return '(%.1f,%.1f)' % (self.x,self.y) | class Point(object):
"""exercise 13-5"""
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y
def __repr__(self):
return '(%.1f,%.1f)' % (self.x, self.y) |
ZBRUSH_KEYWORDS = {
(
'BackColorSet',
'ButtonFind',
'ButtonPress',
'ButtonSet',
'ButtonUnPress',
'CanvasClick',
'CanvasGyroHide',
'CanvasGyroShow',
'CanvasPanGetH',
'CanvasPanGetV',
'CanvasPanSet',
'CanvasStroke',
... | zbrush_keywords = {('BackColorSet', 'ButtonFind', 'ButtonPress', 'ButtonSet', 'ButtonUnPress', 'CanvasClick', 'CanvasGyroHide', 'CanvasGyroShow', 'CanvasPanGetH', 'CanvasPanGetV', 'CanvasPanSet', 'CanvasStroke', 'CanvasStrokes', 'CanvasZoomGet', 'CanvasZoomSet', 'Caption', 'CurveAddPoint', 'CurvesCreateMesh', 'CurvesDe... |
load(":tests/auto_module.bzl", module1 = "setup")
load(":tests/manual_module.bzl", module2 = "setup")
load(":tests/manual_module_bad_input.bzl", module3 = "setup")
load(":tests/src_dir_not_in_path.bzl", srcdir1 = "setup")
def sqldelight_test_suite(name):
setup_functions = [srcdir1, module1, module2, module3]
t... | load(':tests/auto_module.bzl', module1='setup')
load(':tests/manual_module.bzl', module2='setup')
load(':tests/manual_module_bad_input.bzl', module3='setup')
load(':tests/src_dir_not_in_path.bzl', srcdir1='setup')
def sqldelight_test_suite(name):
setup_functions = [srcdir1, module1, module2, module3]
test_targ... |
class Files:
def __init__(self, path=""):
self.path = path
self.files = {}
def add(self, id, filename):
id = id.lower()
if self.files.get(id) is not None:
raise DuplicatedFileException("File id {} already exists".format(id))
file = File(id, filename)
... | class Files:
def __init__(self, path=''):
self.path = path
self.files = {}
def add(self, id, filename):
id = id.lower()
if self.files.get(id) is not None:
raise duplicated_file_exception('File id {} already exists'.format(id))
file = file(id, filename)
... |
#!/usr/bin/python
# Copyright (c) 1999-2018, Juniper Networks Inc.
#
# All rights reserved.
#
__version__ = "1.3.2"
DATE = "2018-May-31"
| __version__ = '1.3.2'
date = '2018-May-31' |
for i in range(1,4,1):
print()
for j in range(1,3):
print("*",end=" ")
for k in range(1,3):
print(" ",end=" ")
for j in range(1,3):
print("*",end=" ")
for i in range(1,3):
print()
for j in range(1,7):
print("*",end=" ")
for i in range(1,8,1):
print()
for j... | for i in range(1, 4, 1):
print()
for j in range(1, 3):
print('*', end=' ')
for k in range(1, 3):
print(' ', end=' ')
for j in range(1, 3):
print('*', end=' ')
for i in range(1, 3):
print()
for j in range(1, 7):
print('*', end=' ')
for i in range(1, 8, 1):
prin... |
class Solution:
def singleNumbers(self, nums: List[int]) -> List[int]:
ret = 0
a = 0
b = 0
for n in nums:
ret ^= n
h = 1
while(ret & h == 0):
h <<= 1
for n in nums:
if (h & n == 0):
a ^= n
else:
b ^= n
return [a,... | class Solution:
def single_numbers(self, nums: List[int]) -> List[int]:
ret = 0
a = 0
b = 0
for n in nums:
ret ^= n
h = 1
while ret & h == 0:
h <<= 1
for n in nums:
if h & n == 0:
a ^= n
else:
... |
class Solution:
def longestWPI(self, hours: List[int]) -> int:
res = score = 0
seen = {}
for i, h in enumerate(hours):
score += h > 8
score -= h < 9
if score > 0:
res = i + 1
seen.setdefault(score, i)
if score - 1 in... | class Solution:
def longest_wpi(self, hours: List[int]) -> int:
res = score = 0
seen = {}
for (i, h) in enumerate(hours):
score += h > 8
score -= h < 9
if score > 0:
res = i + 1
seen.setdefault(score, i)
if score - ... |
class CloudinaryOptionsMixin:
def __init__(self, *args, cloudinary=None, **kwargs):
super().__init__(*args, **kwargs)
self.cloudinary = cloudinary
def deconstruct(self):
name, path, args, kwargs = super().deconstruct()
if "cloudinary" in kwargs:
del kwargs["cloudinar... | class Cloudinaryoptionsmixin:
def __init__(self, *args, cloudinary=None, **kwargs):
super().__init__(*args, **kwargs)
self.cloudinary = cloudinary
def deconstruct(self):
(name, path, args, kwargs) = super().deconstruct()
if 'cloudinary' in kwargs:
del kwargs['cloudi... |
_base_ = ['./mask2former_swin-b-p4-w12-384_lsj_8x2_50e_coco.py']
pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_large_patch4_window12_384_22k.pth' # noqa
model = dict(
backbone=dict(
embed_dims=192,
num_heads=[6, 12, 24, 48],
init_cfg=dict(type='Pret... | _base_ = ['./mask2former_swin-b-p4-w12-384_lsj_8x2_50e_coco.py']
pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_large_patch4_window12_384_22k.pth'
model = dict(backbone=dict(embed_dims=192, num_heads=[6, 12, 24, 48], init_cfg=dict(type='Pretrained', checkpoint=pretrained)), panop... |
# Adapted from : https://docs.python.org/3/tutorial/controlflow.html
# by Colm Doherty in Feb 2018 and updated on Apr 1st 2018
# Purpose is to understand if, elif and else statements
x = int(input("Please enter an integer: "))
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
elif x =... | x = int(input('Please enter an integer: '))
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
elif x == 1:
print('Single')
else:
print('More') |
elements = [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43]
l=len(elements)
i=0
even=[]
odd=[]
x=elements[i]
while i<l:
if elements[i]%2==0:
even.append(elements[i])
else:
odd.append(elements[i])
i+=1
print(even)
print(odd)
| elements = [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43]
l = len(elements)
i = 0
even = []
odd = []
x = elements[i]
while i < l:
if elements[i] % 2 == 0:
even.append(elements[i])
else:
odd.append(elements[i])
i += 1
print(even)
print(odd) |
num = float(input("Enter a number: "))
if num > 0:
print("pos number")
elif num == 0:
print("zero")
else:
print('Neg number') | num = float(input('Enter a number: '))
if num > 0:
print('pos number')
elif num == 0:
print('zero')
else:
print('Neg number') |
# user input
# https://www.hackerrank.com/challenges/staircase/problem?h_r=internal-search
n = int(input())
# build a staircase of base and height are equal to n
spaces = ' '
hashes = '#'
# print(spaces * (n-1))
# for loop integration
count = 1
for i in range(n):
s = spaces * (n-count) # spaces will decrease by n... | n = int(input())
spaces = ' '
hashes = '#'
count = 1
for i in range(n):
s = spaces * (n - count)
h = hashes * count
print(s + h)
count += 1
pass |
load("//infra/bazel:build.bzl", "foreign_go_binary")
load("//infra/bazel:gpg.bzl", "gpg_sign")
def gen_targets(matrix):
pkg = "github.com/SwordJason/v2ray-core/main"
output = "v2ray"
for (os, arch) in matrix:
bin_name = "v2ray_" + os + "_" + arch
foreign_go_binary(
name = bin_name,
pkg = pkg... | load('//infra/bazel:build.bzl', 'foreign_go_binary')
load('//infra/bazel:gpg.bzl', 'gpg_sign')
def gen_targets(matrix):
pkg = 'github.com/SwordJason/v2ray-core/main'
output = 'v2ray'
for (os, arch) in matrix:
bin_name = 'v2ray_' + os + '_' + arch
foreign_go_binary(name=bin_name, pkg=pkg, ou... |
class Solution:
def allCellsDistOrder(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]:
maxDist = max(r0, R-1-r0) + max(c0, C-1-c0)
bucket = collections.defaultdict(list)
dist = lambda r1, c1, r2, c2: abs(r1 - r2) + abs(c1 - c2)
for i in range(R):
for j in range(C):
bucket[dist... | class Solution:
def all_cells_dist_order(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]:
max_dist = max(r0, R - 1 - r0) + max(c0, C - 1 - c0)
bucket = collections.defaultdict(list)
dist = lambda r1, c1, r2, c2: abs(r1 - r2) + abs(c1 - c2)
for i in range(R):
f... |
def doaddition():
a=10
b=10
c=a+b
print(c)
doaddition() | def doaddition():
a = 10
b = 10
c = a + b
print(c)
doaddition() |
def order(timings, N):
c = 0
j = 0
for i in range(N):
if c <= timings[i][0]:
timings[i].append("C")
c = timings[i][1]
elif j <= timings[i][0]:
timings[i].append("J")
j = timings[i][1]
else:
return False
return timing... | def order(timings, N):
c = 0
j = 0
for i in range(N):
if c <= timings[i][0]:
timings[i].append('C')
c = timings[i][1]
elif j <= timings[i][0]:
timings[i].append('J')
j = timings[i][1]
else:
return False
return timings
fo... |
x = int(input("Enter a number for checking whether it's Prime or not"))
primeFlag = True
for i in range(2,x):
if x%i == 0:
primeFlag = False
if (primeFlag):
print("It is a Prime Number")
else:
print("It is not a Prime Number") | x = int(input("Enter a number for checking whether it's Prime or not"))
prime_flag = True
for i in range(2, x):
if x % i == 0:
prime_flag = False
if primeFlag:
print('It is a Prime Number')
else:
print('It is not a Prime Number') |
path = 'data/day11.txt'
board_size = 10
steps = 100
class OctopusConfig:
board: list[list[int]]
steps: int = 0
flashes: int = 0
first_full_flash = None
def __init__(self):
self.board = []
def add_input_line(self, _line: str) -> None:
row = []
for c in _line.strip():
... | path = 'data/day11.txt'
board_size = 10
steps = 100
class Octopusconfig:
board: list[list[int]]
steps: int = 0
flashes: int = 0
first_full_flash = None
def __init__(self):
self.board = []
def add_input_line(self, _line: str) -> None:
row = []
for c in _line.strip():
... |
def bubble_sort(arr):
n = len(arr)
for i in range(n-1):
for j in range(0, n-i-1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
arr = [6,4,1]
def count_swaps(arr):
swaps = 0 #number of swaps that took place
n = len(arr)
for i in ... | def bubble_sort(arr):
n = len(arr)
for i in range(n - 1):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
return arr
arr = [6, 4, 1]
def count_swaps(arr):
swaps = 0
n = len(arr)
for i in range(n - 1):
... |
__version__ = (0, 3)
__author__ = 'Justyna Zarna'
__contact__ = "justyna.zarna@solution4future.com"
__docformat__ = "restructuredtext"
__license__ = "BSD (3 clause)" | __version__ = (0, 3)
__author__ = 'Justyna Zarna'
__contact__ = 'justyna.zarna@solution4future.com'
__docformat__ = 'restructuredtext'
__license__ = 'BSD (3 clause)' |
def fizzBuzz(n):
for i in range(1,n+1):
if i % 3 ==0 and i % 5 == 0:
print("fizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
if __name__ == '__main__':
n = int(input().strip())
... | def fizz_buzz(n):
for i in range(1, n + 1):
if i % 3 == 0 and i % 5 == 0:
print('fizzBuzz')
elif i % 3 == 0:
print('Fizz')
elif i % 5 == 0:
print('Buzz')
else:
print(i)
if __name__ == '__main__':
n = int(input().strip())
fizz_bu... |
class Solution:
# @param n, an integer
# @return an integer
def climbStairs(self, n):
fibA = fibB = 1
for i in range(n - 1):
fibC = fibA + fibB
fibA = fibB
fibB = fibC
return fibB | class Solution:
def climb_stairs(self, n):
fib_a = fib_b = 1
for i in range(n - 1):
fib_c = fibA + fibB
fib_a = fibB
fib_b = fibC
return fibB |
# python3
def area(x1, y1, x2, y2, x3, y3):
return abs((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))
def solve(Ax, Ay, Bx, By, Cx, Cy, P):
n = len(P)
for i in range(n):
px, py = P[i]
a1 = area(Ax, Ay, Bx, By, px, py)
a2 = area(Bx, By, Cx, Cy, px, py)
a3 = area(Cx, Cy, Ax, Ay, px, py)
... | def area(x1, y1, x2, y2, x3, y3):
return abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1))
def solve(Ax, Ay, Bx, By, Cx, Cy, P):
n = len(P)
for i in range(n):
(px, py) = P[i]
a1 = area(Ax, Ay, Bx, By, px, py)
a2 = area(Bx, By, Cx, Cy, px, py)
a3 = area(Cx, Cy, Ax, Ay, px, p... |
files = {
"binutils-mingw-w64-x86-64_2.25-5+5.2+deb8u1_amd64.deb": "628e9274a1555baa8f9063648f0ce5e5de0c8055d44a3737c8deb1d4c65f6982",
"binutils_2.25-5+deb8u1_amd64.deb": "d9e6ac61d1d5bf63b632923c9f678d8fb64d3f9f82a0e31a8229e6e5b0bbb89d",
"g++-mingw-w64-x86-64_4.9.1-19+14.3_amd64.deb": "fc2682049ca0b8dade0d... | files = {'binutils-mingw-w64-x86-64_2.25-5+5.2+deb8u1_amd64.deb': '628e9274a1555baa8f9063648f0ce5e5de0c8055d44a3737c8deb1d4c65f6982', 'binutils_2.25-5+deb8u1_amd64.deb': 'd9e6ac61d1d5bf63b632923c9f678d8fb64d3f9f82a0e31a8229e6e5b0bbb89d', 'g++-mingw-w64-x86-64_4.9.1-19+14.3_amd64.deb': 'fc2682049ca0b8dade0db46cbbdab0ecd... |
# -*- coding: utf-8 -*-
error_codes = {
4000: 'ValueError:',
4001: 'HeaderError:',
4002: 'GeometryError:',
4003: 'LimitError:',
} | error_codes = {4000: 'ValueError:', 4001: 'HeaderError:', 4002: 'GeometryError:', 4003: 'LimitError:'} |
#code
T = int(input())
for i in range(T):
N = int(input())
array = list(map(int, input().split()))
k = int(input())
array.sort()
print(array[k-1])
| t = int(input())
for i in range(T):
n = int(input())
array = list(map(int, input().split()))
k = int(input())
array.sort()
print(array[k - 1]) |
# problem: https://leetcode.com/problems/brick-wall/
# time complexity: O(NM)
class Solution:
def leastBricks(self, wall: List[List[int]]) -> int:
lenDict = dict()
for w in wall:
wLen = 0
for wallLen in w[:-1]:
wLen += wallLen
lenDict[wLen] = ... | class Solution:
def least_bricks(self, wall: List[List[int]]) -> int:
len_dict = dict()
for w in wall:
w_len = 0
for wall_len in w[:-1]:
w_len += wallLen
lenDict[wLen] = lenDict.get(wLen, 0) + 1
max_cnt = 0
for (key, value) in ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.