content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#coding=utf-8
'''
Created on 2014-1-5
@author: zhangtiande
'''
| """
Created on 2014-1-5
@author: zhangtiande
""" |
for _ in range(int(input())):
n = int(input())
temp = list(map(int, input().split()))
c = 0
for i in range(n-1):
temp2 = list(map(int, input().split()))
if c==0:
for j in range(n-1):
if temp[j]==1 and (temp[j+1]==1 or temp2[j]==1):
c=1
... | for _ in range(int(input())):
n = int(input())
temp = list(map(int, input().split()))
c = 0
for i in range(n - 1):
temp2 = list(map(int, input().split()))
if c == 0:
for j in range(n - 1):
if temp[j] == 1 and (temp[j + 1] == 1 or temp2[j] == 1):
... |
class OperatingSystemNotSupported(Exception):
def __init__(self, operating_system: str) -> None:
self._operating_system = operating_system
message = f"operating system not supported - {operating_system}"
super().__init__(message)
@property
def operating_system(self) -> str:
... | class Operatingsystemnotsupported(Exception):
def __init__(self, operating_system: str) -> None:
self._operating_system = operating_system
message = f'operating system not supported - {operating_system}'
super().__init__(message)
@property
def operating_system(self) -> str:
... |
money = int(input())
cake = money * 0.2
drinks = cake - 0.45 * cake
animator = 1/3 * money
price = money + cake + drinks + animator
print (price) | money = int(input())
cake = money * 0.2
drinks = cake - 0.45 * cake
animator = 1 / 3 * money
price = money + cake + drinks + animator
print(price) |
class Solution:
def closeStrings(self, word1: str, word2: str) -> bool:
if len(word1)!=len(word2):
return False
show1=[0]*26
show2=[0]*26
for i in range(len(word1)):
show1[ord(word1[i])-ord('a')]+=1
show2[ord(word2[i])-ord('a')]+=1
... | class Solution:
def close_strings(self, word1: str, word2: str) -> bool:
if len(word1) != len(word2):
return False
show1 = [0] * 26
show2 = [0] * 26
for i in range(len(word1)):
show1[ord(word1[i]) - ord('a')] += 1
show2[ord(word2[i]) - ord('a')] +... |
# file grafo.py
class Grafo:
def __init__(self, es_dirigido = False, vertices_init = []):
self.vertices = {}
for v in vertices_init:
self.vertices[v] = {}
self.es_dirigido = es_dirigido
def __contains__(self, v):
return v in self.vertices
def __len__(self):
return len(self.vertices)
def __iter__(sel... | class Grafo:
def __init__(self, es_dirigido=False, vertices_init=[]):
self.vertices = {}
for v in vertices_init:
self.vertices[v] = {}
self.es_dirigido = es_dirigido
def __contains__(self, v):
return v in self.vertices
def __len__(self):
return len(self... |
#
# PySNMP MIB module NBS-SIGCOND-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-SIGCOND-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:17:38 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, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, single_value_constraint, value_range_constraint, constraints_intersection) ... |
def dayOfProgrammer(year):
s=0
if 1700 <= year <= 1917:
if year % 4==0:
for i in range(1, 9):
if i % 2 == 0:
s += 30
else:
s += 31
print(256 - s, ".09", ".", year, sep='')
else:
for i in r... | def day_of_programmer(year):
s = 0
if 1700 <= year <= 1917:
if year % 4 == 0:
for i in range(1, 9):
if i % 2 == 0:
s += 30
else:
s += 31
print(256 - s, '.09', '.', year, sep='')
else:
for ... |
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
res = [[0] * n for _ in range(n)]
xi,yi,dx,dy = 0,0,1,0
for i in range(1,n*n+1):
res[yi][xi]=i
if not 0 <= yi+dy < n or not 0 <= xi+dx < n or res[yi+dy][xi+dx]:
dy,dx = dx,-dy
... | class Solution:
def generate_matrix(self, n: int) -> List[List[int]]:
res = [[0] * n for _ in range(n)]
(xi, yi, dx, dy) = (0, 0, 1, 0)
for i in range(1, n * n + 1):
res[yi][xi] = i
if not 0 <= yi + dy < n or not 0 <= xi + dx < n or res[yi + dy][xi + dx]:
... |
# Merge Two Sorted Lists
#
# Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing
# together the nodes of the first two lists.
#
# Example:
#
# Input: 1->2->4, 1->3->4
# Output: 1->1->2->3->4->4
# Definition for singly-linked list.
class ListNode:
def __init__(s... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def merge_two_lists(self, l1, l2):
if None in (l1, l2):
return l1 or l2
elif l1.val < l2.val:
l1.next = self.mergeTwoLists(l1.next, l2)
ret... |
#bitwise or operator
a=24
b=10
print(bin(a))
print(bin(b))
print(a|b)
| a = 24
b = 10
print(bin(a))
print(bin(b))
print(a | b) |
#CNN Config File
batchsize = 3
numberOfGenres = 4
learningRate = 0.001
numberOfSteps = 10000
dropoutProbability = 0.5
| batchsize = 3
number_of_genres = 4
learning_rate = 0.001
number_of_steps = 10000
dropout_probability = 0.5 |
'''
09 - Subsetting lists of lists
You saw before that a Python list can contain practically anything; even other lists! To subset
lists of lists, you can use the same technique as before: square brackets. Try out the commands
in the following code sample in the IPython Shell:
x = [["a", "b", "c"],
["d", "e", "f... | """
09 - Subsetting lists of lists
You saw before that a Python list can contain practically anything; even other lists! To subset
lists of lists, you can use the same technique as before: square brackets. Try out the commands
in the following code sample in the IPython Shell:
x = [["a", "b", "c"],
["d", "e", "f... |
class DjangoeventsError(Exception):
pass
class AlreadyExists(DjangoeventsError):
pass
| class Djangoeventserror(Exception):
pass
class Alreadyexists(DjangoeventsError):
pass |
# Remove a exclamation mark from the end of string. For a beginner kata, you can assume
# that the input data is always a string, no need to verify it.
# Examples
# remove("Hi!") === "Hi"
# remove("Hi!!!") === "Hi!!"
# remove("!Hi") === "!Hi"
# remove("!Hi!") === "!Hi"
# remove("Hi! Hi!") === "Hi! Hi"
# rem... | def remove(s):
return s[:-1] if s.endswith('!') else s
def test_remove():
assert remove('Hi!') == 'Hi'
assert remove('Hi!!!') == 'Hi!!'
assert remove('!Hi') == '!Hi'
assert remove('!Hi!') == '!Hi'
assert remove('Hi! Hi!') == 'Hi! Hi'
assert remove('Hi') == 'Hi' |
class Solution:
def maxPower(self, s: str) -> int:
best_answer = 1
current_answer = 1
last_char = None
for char in s:
if last_char == char:
current_answer += 1
else:
if current_answer > best_answer:
best_answ... | class Solution:
def max_power(self, s: str) -> int:
best_answer = 1
current_answer = 1
last_char = None
for char in s:
if last_char == char:
current_answer += 1
else:
if current_answer > best_answer:
best_an... |
class Reporter():
def __init__(self, checker):
pass
def doReport(self):
pass
def appendMsg(self):
pass
def export(self):
pass
| class Reporter:
def __init__(self, checker):
pass
def do_report(self):
pass
def append_msg(self):
pass
def export(self):
pass |
def evenNumbersGenerator(x):
while True:
x += 1
yield x
# yield 1
# yield 2
# yield 3
# yield 4
# yield 5
# yield 6
# yield 7
gen=evenNumbersGenerator(5)
print( next(gen) )
print( next(gen) )
print( next(gen) )
print( next(gen) )
| def even_numbers_generator(x):
while True:
x += 1
yield x
gen = even_numbers_generator(5)
print(next(gen))
print(next(gen))
print(next(gen))
print(next(gen)) |
class Optimizer:
def __init__(self, parameters):
pass
def step(self, **kwargs):
raise NotImplementedError
| class Optimizer:
def __init__(self, parameters):
pass
def step(self, **kwargs):
raise NotImplementedError |
# Copyright 2018 Kai Groner
#
# 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 law or agreed to i... | class Ns:
"""Nesting namespace.
>>> ns = NS({ 'foo.bar': 1, 'duck.duck.goose': 101 })
>>> ns.foo
<NS: 'foo'>
>>> ns.foo.bar
1
>>> ns.duck.duck
<NS: 'duck.duck'>
>>> ns.duck.duck.goose
101
>>> ns['foo.quux'] = 2
>>> ns.foo.quux
2
"""
def __init__(self, seq=No... |
spike = {
'kind': 'bulldog',
'owner': 'tom',
}
garfield = {
'kind': 'cat',
'owner': 'mark',
}
tom = {
'kind': 'cat',
'owner': 'will',
}
pets = [spike, garfield, tom]
for pet in pets:
print(pet)
| spike = {'kind': 'bulldog', 'owner': 'tom'}
garfield = {'kind': 'cat', 'owner': 'mark'}
tom = {'kind': 'cat', 'owner': 'will'}
pets = [spike, garfield, tom]
for pet in pets:
print(pet) |
#
# PySNMP MIB module CISCO-FABRIC-MCAST-APPL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FABRIC-MCAST-APPL-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:40:35 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint, constraints_union) ... |
class Stack():
def __init__(self):
self.arr = []
self.length = 0
def __str__(self):
return str(self.__dict__)
def push(self, data):
self.arr.append(data)
self.length += 1
def peek(self):
return self.arr[self.length - 1]
def pop(self):
popped_item = self.arr[self.length - 1]
del self.arr[self.le... | class Stack:
def __init__(self):
self.arr = []
self.length = 0
def __str__(self):
return str(self.__dict__)
def push(self, data):
self.arr.append(data)
self.length += 1
def peek(self):
return self.arr[self.length - 1]
def pop(self):
popped... |
class TrafficLightClassifier(object):
def __init__(self):
PATH_TO_MODEL = 'frozen_inference_graph.pb'
self.detection_graph = tf.Graph()
with self.detection_graph.as_default():
od_graph_def = tf.GraphDef()
# Works up to here.
with tf.gfile.GFile(PATH_TO_MOD... | class Trafficlightclassifier(object):
def __init__(self):
path_to_model = 'frozen_inference_graph.pb'
self.detection_graph = tf.Graph()
with self.detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_MODEL, 'rb') as fid:
... |
a = 1
b = 2
d = 4
c = 3
e = 6
e = 5
f = 7
g = 8
| a = 1
b = 2
d = 4
c = 3
e = 6
e = 5
f = 7
g = 8 |
t = int(input().strip())
for a0 in range(t):
b,w = input().strip().split(' ')
b,w = [int(b),int(w)]
x,y,z = input().strip().split(' ')
x,y,z = [int(x),int(y),int(z)]
cost = b*x + w*y
x_cost = b*(y+z) + w*y
y_cost = b*x + w*(x+z)
new_cost = min(cost, x_cost, y_cost)
print (new... | t = int(input().strip())
for a0 in range(t):
(b, w) = input().strip().split(' ')
(b, w) = [int(b), int(w)]
(x, y, z) = input().strip().split(' ')
(x, y, z) = [int(x), int(y), int(z)]
cost = b * x + w * y
x_cost = b * (y + z) + w * y
y_cost = b * x + w * (x + z)
new_cost = min(cost, x_cos... |
sum1 = 0
sum2 = 0
for i in range (1, 101, 1):
sum1 = sum1 + (i**2)
sum2 = sum2 + i
sum2 = sum2**2
answer = sum2-sum1
print(answer)
| sum1 = 0
sum2 = 0
for i in range(1, 101, 1):
sum1 = sum1 + i ** 2
sum2 = sum2 + i
sum2 = sum2 ** 2
answer = sum2 - sum1
print(answer) |
# day 10 challenge 1
# read input
ratings = []
with open('input.txt', 'r') as file:
for line in file:
ratings.append(int(line))
ratings.sort()
ratings.append(ratings[-1] + 3)
ratings.insert(0, 0)
one_ct = 0
thr_ct = 0
for ind, jlt in enumerate(ratings):
if ind < (len(ratings) - 1):
if (rati... | ratings = []
with open('input.txt', 'r') as file:
for line in file:
ratings.append(int(line))
ratings.sort()
ratings.append(ratings[-1] + 3)
ratings.insert(0, 0)
one_ct = 0
thr_ct = 0
for (ind, jlt) in enumerate(ratings):
if ind < len(ratings) - 1:
if ratings[ind + 1] - jlt == 1:
one... |
#!/usr/bin/env python3
n = int(input())
i = 0
while i < n:
if i == 0:
print(n * "*")
elif 0 < i < n - 1:
print("*" + ((n - 2) * " ") + "*")
elif i == n - 1:
print(n * "*")
i = i + 1
| n = int(input())
i = 0
while i < n:
if i == 0:
print(n * '*')
elif 0 < i < n - 1:
print('*' + (n - 2) * ' ' + '*')
elif i == n - 1:
print(n * '*')
i = i + 1 |
#
# PySNMP MIB module WWP-LEOS-FLOW-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-LEOS-FLOW-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:37:57 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')
(single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint, constraints_union) ... |
# generated from catkin/cmake/template/cfg-extras.context.py.in
DEVELSPACE = 'FALSE' == 'TRUE'
INSTALLSPACE = 'TRUE' == 'TRUE'
CATKIN_DEVEL_PREFIX = '/root/ros_catkin_ws/devel_isolated/roslisp'
CATKIN_GLOBAL_BIN_DESTINATION = 'bin'
CATKIN_GLOBAL_ETC_DESTINATION = 'etc'
CATKIN_GLOBAL_INCLUDE_DESTINATION = 'include'
CA... | develspace = 'FALSE' == 'TRUE'
installspace = 'TRUE' == 'TRUE'
catkin_devel_prefix = '/root/ros_catkin_ws/devel_isolated/roslisp'
catkin_global_bin_destination = 'bin'
catkin_global_etc_destination = 'etc'
catkin_global_include_destination = 'include'
catkin_global_lib_destination = 'lib'
catkin_global_libexec_destinat... |
a,b=1,0
for i in range(int(input())):
x,y,z=list(map(int,input().split()))
a=a*y//x
if z:
b=1-b
print(b,a) | (a, b) = (1, 0)
for i in range(int(input())):
(x, y, z) = list(map(int, input().split()))
a = a * y // x
if z:
b = 1 - b
print(b, a) |
# https://www.hackerrank.com/challenges/merge-the-tools/problem
def merge_the_tools(s, n):
# your code goes here
for part in zip(*[iter(s)] * n):
d = dict()
print(''.join([d.setdefault(c, c) for c in part if c not in d]))
if __name__ == '__main__':
string, k = input(), int(input())
m... | def merge_the_tools(s, n):
for part in zip(*[iter(s)] * n):
d = dict()
print(''.join([d.setdefault(c, c) for c in part if c not in d]))
if __name__ == '__main__':
(string, k) = (input(), int(input()))
merge_the_tools(string, k) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class PodiumApplication():
def __init__(self, app_id, app_secret, podium_url=None):
self.app_id = app_id
self.app_secret = app_secret
self.podium_url = 'https://podium.live' if podium_url is None else podium_url
| class Podiumapplication:
def __init__(self, app_id, app_secret, podium_url=None):
self.app_id = app_id
self.app_secret = app_secret
self.podium_url = 'https://podium.live' if podium_url is None else podium_url |
class DigAdd:
def addDigits(self, num: int) -> int:
if not num:
return 0
else:
mod = (num - 1) % 9
x = mod + 1
return x
print(DigAdd().addDigits(12))
print(DigAdd().addDigits(12836374))
print(DigAdd().addDigits(9))
print(DigAdd().addDigits(8))
| class Digadd:
def add_digits(self, num: int) -> int:
if not num:
return 0
else:
mod = (num - 1) % 9
x = mod + 1
return x
print(dig_add().addDigits(12))
print(dig_add().addDigits(12836374))
print(dig_add().addDigits(9))
print(dig_add().addDigits(8)) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
# O(n) time | O(n) space - where n is the number of the nodes in this binary tree
def maxDepth(self, roo... | class Solution:
def max_depth(self, root: Optional[TreeNode]) -> int:
stack = [[root, 1]]
ans = 0
while stack:
(node, depth) = stack.pop()
if node:
ans = max(ans, depth)
stack.append([node.right, depth + 1])
stack.appen... |
def send_email(name: str, address: str, subject: str, body: str):
print(f"Sending email to {name} ({address})")
print("==========")
print(f"Subject: {subject}\n")
print(body)
| def send_email(name: str, address: str, subject: str, body: str):
print(f'Sending email to {name} ({address})')
print('==========')
print(f'Subject: {subject}\n')
print(body) |
with open('input') as f:
in_data = [line.rstrip() for line in f]
j=0
w=len(in_data[0])
tree_count=0
for i in range(1, len(in_data)):
line = in_data[i]
j=(j+3)%w
if line[j] == '#':
tree_count+=1
print(tree_count)
| with open('input') as f:
in_data = [line.rstrip() for line in f]
j = 0
w = len(in_data[0])
tree_count = 0
for i in range(1, len(in_data)):
line = in_data[i]
j = (j + 3) % w
if line[j] == '#':
tree_count += 1
print(tree_count) |
def isPalindrome(word):
word = word.lower()
if word == word[::-1]:
return True
else:
return False
print(isPalindrome("DDnKnDD"))
| def is_palindrome(word):
word = word.lower()
if word == word[::-1]:
return True
else:
return False
print(is_palindrome('DDnKnDD')) |
for i in range(1, 1001):
print(1001 - i, end="\t")
if i % 5 == 0:
print("")
| for i in range(1, 1001):
print(1001 - i, end='\t')
if i % 5 == 0:
print('') |
with open('day002.txt', 'r') as fd:
inp = fd.read()
rows = inp.split('\n')
def move(p, d):
x, y = p
if d == 'U': p = (x, max(y - 1, 0))
if d == 'D': p = (x, min(y + 1, 2))
if d == 'R': p = (min(x + 1, 2), y)
if d == 'L': p = (max(x - 1, 0), y)
return p
def key(p):
return p[0] + p[1] * 3 +... | with open('day002.txt', 'r') as fd:
inp = fd.read()
rows = inp.split('\n')
def move(p, d):
(x, y) = p
if d == 'U':
p = (x, max(y - 1, 0))
if d == 'D':
p = (x, min(y + 1, 2))
if d == 'R':
p = (min(x + 1, 2), y)
if d == 'L':
p = (max(x - 1, 0), y)
return p
def... |
jvar = 0
def return_something():
return "Hi world"
def change_jvar():
jvar = 18
print(jvar)
def print_jvar():
print(jvar)
print("Called on import! Oops!")
| jvar = 0
def return_something():
return 'Hi world'
def change_jvar():
jvar = 18
print(jvar)
def print_jvar():
print(jvar)
print('Called on import! Oops!') |
# empty class for creating constants
class Constant:
pass
# constants for metrical feet
FOOT = Constant()
FOOT.DACTYL = "Dactyl"
FOOT.SPONDEE = "Spondee"
FOOT.FINAL = "Final"
APPROACH = Constant()
APPROACH.STUDENT = "version_student"
APPROACH.NATIVE_SPEAKER = "version_native_speaker"
APPROACH.FALLBACK = "versio... | class Constant:
pass
foot = constant()
FOOT.DACTYL = 'Dactyl'
FOOT.SPONDEE = 'Spondee'
FOOT.FINAL = 'Final'
approach = constant()
APPROACH.STUDENT = 'version_student'
APPROACH.NATIVE_SPEAKER = 'version_native_speaker'
APPROACH.FALLBACK = 'version_fallback'
syl = constant()
SYL.UNKNOWN = 0
SYL.SHORT = 1
SYL.LONG = 2... |
class Agencia:
def __init__(self,nombre,direccion,email):
self.nombre = nombre
self.direccion = direccion
self.email = email
def getNombre(self):
return self.nombre
def getDireccion(self):
return self.direccion
def getEmail(self):
return self.email
d... | class Agencia:
def __init__(self, nombre, direccion, email):
self.nombre = nombre
self.direccion = direccion
self.email = email
def get_nombre(self):
return self.nombre
def get_direccion(self):
return self.direccion
def get_email(self):
return self.ema... |
# Advent of Code 2017
# Day 9, Part 2
# @geekygirlsarah
# Files to run through
# input.txt being the input the puzzle provides
inputFile = "input.txt"
# inputFile = "testinput.txt"
# Process file
with open(inputFile) as f:
while True:
contents = f.readline(-1)
if not contents:
# print... | input_file = 'input.txt'
with open(inputFile) as f:
while True:
contents = f.readline(-1)
if not contents:
break
state = 'start'
group_level = 0
group_sum = 0
char_pos = -1
garbage_count = 0
while True:
char_pos += 1
... |
#
# PySNMP MIB module Juniper-DVMRP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-DVMRP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:02:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, single_value_constraint, constraints_intersection, value_range_constraint) ... |
# Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.
# Example
# For s = "abacabad", the output should be
# first_not_repeating_character(s) = 'c'.
# There are 2 non-repeating characters in the string... | def first_not_repeating_character(s):
chars = {}
non_repeat = []
for char in s:
if char in chars:
chars[char] += 1
else:
chars[char] = 1
non_repeat.append(char)
for char in non_repeat:
if chars[char] == 1:
return char
return '_' |
skill = input()
while True:
command = input()
if command == 'For Azeroth' or command is None:
break
if command == 'GladiatorStance':
skill = skill.upper()
print(skill)
elif command == 'DefensiveStance':
skill = skill.lower()
print(skill)
elif comman... | skill = input()
while True:
command = input()
if command == 'For Azeroth' or command is None:
break
if command == 'GladiatorStance':
skill = skill.upper()
print(skill)
elif command == 'DefensiveStance':
skill = skill.lower()
print(skill)
elif command.split(' '... |
# Copyright (c) 2020 Club Raiders Project
# https://github.com/HausReport/ClubRaiders
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Faction constants
#
GOVERNMENT = 'government'
MINOR_FACTION_ID = 'minor_faction_id'
MINOR_FACTION_PRESENCES = 'minor_faction_presences'
NEIGHBOR_COUNT = 'neighbor_count'
HAS_ANARCHY... | government = 'government'
minor_faction_id = 'minor_faction_id'
minor_faction_presences = 'minor_faction_presences'
neighbor_count = 'neighbor_count'
has_anarchy = 'hasAnarchy'
id = 'id'
neighbors = 'neighbors'
power_state = 'power_state'
has_docking = 'has_docking'
system_id = 'system_id'
pad_size = 'max_landing_pad_s... |
class Employee:
# class variables
num_of_employees = 0
raise_amount = 1.04
def __init__(self, first, last, pay):
# instance variables
self.first = first
self.last = last
self.pay = pay
self.email = f"{first}.{last}@company.com"
Employee.num_of_employees +... | class Employee:
num_of_employees = 0
raise_amount = 1.04
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = f'{first}.{last}@company.com'
Employee.num_of_employees += 1
def fullname(self):
return f'{self... |
# Constants for browser located in this file.
# CONFIG DIRECTORY NAMES
DIRECTORY_CONFIGURATIONS = 'configurations'
DIRECTORY_TOPICS = 'topics'
DIRECTORY_AVRO_SCHEMAS = 'avro_schemas'
DIRECTORY_DEPLOYMENT_SCRIPTS = 'deployment_scripts'
# CONFIG FILENAMES
FILE_MAIN_CONFIG = 'main_config.yml'
FILE_LOGGER_CONFIG = 'logge... | directory_configurations = 'configurations'
directory_topics = 'topics'
directory_avro_schemas = 'avro_schemas'
directory_deployment_scripts = 'deployment_scripts'
file_main_config = 'main_config.yml'
file_logger_config = 'logger_config.yml'
file_avro_topics = 'avro_topics.yml'
file_ui = 'splash.html'
request_search_st... |
#
# PySNMP MIB module SYMMSYNCE (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/neermitt/Dev/kusanagi/mibs.snmplabs.com/asn1/SYMMSYNCE
# Produced by pysmi-0.3.4 at Tue Jul 30 11:35:09 2019
# On host NEERMITT-M-J0NV platform Darwin version 18.6.0 by user neermitt
# Using Python version 3.7.4 (default, Jul 9 20... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) ... |
def get_head(line, releases, **kwargs):
for release in releases:
if "Django {} release notes".format(release) in line:
return release
return False
def get_urls(releases, **kwargs):
urls = []
for release in releases:
urls.append("https://raw.githubusercontent.com/django/djan... | def get_head(line, releases, **kwargs):
for release in releases:
if 'Django {} release notes'.format(release) in line:
return release
return False
def get_urls(releases, **kwargs):
urls = []
for release in releases:
urls.append('https://raw.githubusercontent.com/django/djang... |
# Scrapy settings for news project
#
# For simplicity, this file contains only the most important settings by
# default. All the other settings are documented here:
#
# http://doc.scrapy.org/topics/settings.html
#
BOT_NAME = 'news'
BOT_VERSION = '1.0'
SPIDER_MODULES = ['news.spiders']
NEWSPIDER_MODULE = 'news.spi... | bot_name = 'news'
bot_version = '1.0'
spider_modules = ['news.spiders']
newspider_module = 'news.spiders'
user_agent = '%s/%s' % (BOT_NAME, BOT_VERSION) |
class Mapper(object):
@staticmethod
def map(enum, value):
result = None
for enum_value in enum:
if Mapper._normalize(value) == Mapper._normalize(enum_value.value):
result = enum_value
return result
@staticmethod
def _normalize(value: str):
ret... | class Mapper(object):
@staticmethod
def map(enum, value):
result = None
for enum_value in enum:
if Mapper._normalize(value) == Mapper._normalize(enum_value.value):
result = enum_value
return result
@staticmethod
def _normalize(value: str):
re... |
def city_country(city, country):
return(city.title() + ", " + country.title())
city = city_country('santiago', 'chile')
print(city)
city = city_country('ushuaia', 'argentina')
print(city)
city = city_country('longyearbyen', 'svalbard')
print(city)
| def city_country(city, country):
return city.title() + ', ' + country.title()
city = city_country('santiago', 'chile')
print(city)
city = city_country('ushuaia', 'argentina')
print(city)
city = city_country('longyearbyen', 'svalbard')
print(city) |
# -*- coding: utf-8 -*-
description = 'setup for Beckhoff PLC mtt devices on PANDA'
group = 'lowlevel'
devices = dict(
mtt = device('nicos.devices.generic.Axis',
description = 'Virtual MTT axis that exchanges block automatically '
'(must be used in "automatic" mode).',
motor... | description = 'setup for Beckhoff PLC mtt devices on PANDA'
group = 'lowlevel'
devices = dict(mtt=device('nicos.devices.generic.Axis', description='Virtual MTT axis that exchanges block automatically (must be used in "automatic" mode).', motor=device('nicos.devices.generic.VirtualMotor', abslimits=(-122, -25), unit='de... |
class Name:
def __init__(self, name, age):
self.name = name
self.age = age
def age_next(self):
return self.age + 10
def name_len(self):
return 'Length of name is {}'.format(len(self.name))
class Education(Name):
def __init__(self, name, age, school, btech, ms):
... | class Name:
def __init__(self, name, age):
self.name = name
self.age = age
def age_next(self):
return self.age + 10
def name_len(self):
return 'Length of name is {}'.format(len(self.name))
class Education(Name):
def __init__(self, name, age, school, btech, ms):
... |
class Constants:
default_config_folder = "config"
default_modules_folder = "modules"
default_deployment_template_file = "deployment.template.json"
default_deployment_debug_template_file = "deployment.debug.template.json"
default_platform = "amd64"
deployment_template_suffix = ".template.json"
... | class Constants:
default_config_folder = 'config'
default_modules_folder = 'modules'
default_deployment_template_file = 'deployment.template.json'
default_deployment_debug_template_file = 'deployment.debug.template.json'
default_platform = 'amd64'
deployment_template_suffix = '.template.json'
... |
class PIDController:
def __init__(self, kp, ki, kd, goal):
self.kp = kp
self.ki = ki
self.kd = kd
self.goal = goal
self.error = 0
self.lX = 0
self.dError = 0
self.iError = 0
def correction(self):
return (self.error * self.kp + self.iErr... | class Pidcontroller:
def __init__(self, kp, ki, kd, goal):
self.kp = kp
self.ki = ki
self.kd = kd
self.goal = goal
self.error = 0
self.lX = 0
self.dError = 0
self.iError = 0
def correction(self):
return self.error * self.kp + self.iError ... |
class HWPDecryptor():
def __init__(self, filepath, key):
self.data = ''
self.key = key
with open(filepath, 'rb') as f:
data = f.read()
self.data = bytearray(data)
def decryption(self):
r = list()
for i in range(0, len(self.data)):
... | class Hwpdecryptor:
def __init__(self, filepath, key):
self.data = ''
self.key = key
with open(filepath, 'rb') as f:
data = f.read()
self.data = bytearray(data)
def decryption(self):
r = list()
for i in range(0, len(self.data)):
a = s... |
def fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
n = int(input("Please enter your number"))
values = [str(fibonacci(x)) for x in range(0, n+1)]
print(",".join(values))
| def fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
n = int(input('Please enter your number'))
values = [str(fibonacci(x)) for x in range(0, n + 1)]
print(','.join(values)) |
RANDOM_SEED = 7 # constant for reproducability
# for training
TRAINING_CONFIG = {
'TYPE': 'single_country', # single_country or country_held_out
'COUNTRY': 'malawi_2016', # malawi_2016, ethiopia_2015
'METRIC': 'est_monthly_phone_cost_pc' # house_has_cellphone or est_monthly_phone_cost_pc
}
# for predicti... | random_seed = 7
training_config = {'TYPE': 'single_country', 'COUNTRY': 'malawi_2016', 'METRIC': 'est_monthly_phone_cost_pc'}
vis_config = {'COUNTRY_NAME': 'Ethiopia', 'COUNTRY_ABBRV': 'MWI', 'TYPE': 'single_country', 'COUNTRY': 'ethiopia_2015', 'METRIC': 'est_monthly_phone_cost_pc'} |
class LetterSpacingKeyword:
Normal = "normal"
class LetterSpacing(
LetterSpacingKeyword,
Length,
):
pass
| class Letterspacingkeyword:
normal = 'normal'
class Letterspacing(LetterSpacingKeyword, Length):
pass |
# problem description: https://www.hackerrank.com/challenges/ctci-connected-cell-in-a-grid/problem
def getBiggestRegion(grid):
n_row = len(grid)
n_col = len(grid[0])
region_sizes = []
for row in range(n_row):
for col in range(n_col):
region_size = measure_region(grid, row, col)
... | def get_biggest_region(grid):
n_row = len(grid)
n_col = len(grid[0])
region_sizes = []
for row in range(n_row):
for col in range(n_col):
region_size = measure_region(grid, row, col)
region_sizes.append(region_size)
return max(region_sizes)
def measure_region(grid, ro... |
expected_output = {
"my_state": "13 -ACTIVE",
"peer_state": "1 -DISABLED",
"mode": "Simplex",
"unit": "Primary",
"unit_id": 48,
"redundancy_mode_operational": "Non-redundant",
"redundancy_mode_configured": "Non-redundant",
"redundancy_state": "Non Redundant",
"maintenance_mode": "Di... | expected_output = {'my_state': '13 -ACTIVE', 'peer_state': '1 -DISABLED', 'mode': 'Simplex', 'unit': 'Primary', 'unit_id': 48, 'redundancy_mode_operational': 'Non-redundant', 'redundancy_mode_configured': 'Non-redundant', 'redundancy_state': 'Non Redundant', 'maintenance_mode': 'Disabled', 'manual_swact': 'disabled', ... |
t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
n *= 2
if n == 2:
print(abs(a[-1]-a[0]))
else:
print(a[n//2]-a[n//2-1])
| t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
n *= 2
if n == 2:
print(abs(a[-1] - a[0]))
else:
print(a[n // 2] - a[n // 2 - 1]) |
# https://wiki.python.org/moin/BitManipulation
# testBit() returns a nonzero result, 2**offset, if the bit at 'offset' is one.
def testBit(int_type, offset):
mask = 1 << offset
return(int_type & mask)
# setBit() returns an integer with the bit at 'offset' set to 1.
def setBit(int_type, offset):
mask = 1... | def test_bit(int_type, offset):
mask = 1 << offset
return int_type & mask
def set_bit(int_type, offset):
mask = 1 << offset
return int_type | mask
def clear_bit(int_type, offset):
print('{0:b}'.format(int_type))
mask = ~(1 << offset)
print('{0:b}'.format(mask))
return int_type & mask
... |
# Django settings for unit test project.
DEBUG = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'database.sqlite',
},
}
SITE_ID = 1
ROOT_URLCONF = 'parler_example.urls'
SECRET_KEY = 'secret'
# Absolute path to the directory that holds media.
# Example: "/ho... | debug = True
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'database.sqlite'}}
site_id = 1
root_urlconf = 'parler_example.urls'
secret_key = 'secret'
media_root = ''
media_url = ''
static_root = '/home/static/'
static_url = '/static/'
templates = [{'BACKEND': 'django.template.backends.django.... |
SCHEDULE_MODE = {
'SECONDS': 1,
'MINUTS': 2,
'HOUR': 3,
'DAY': 4
}
SCHEDULE_STATUS = {
'RUNNING': 1,
'STOPPED': 2
}
SCHEDULE_ACTIVE = {
'ACTIVE': 1,
'DEACTIVE': 2
}
def getDictKeyByName(dictObject, value):
for (key, itemValue) in dictObject.items():
if (value == itemValue):
return key
retu... | schedule_mode = {'SECONDS': 1, 'MINUTS': 2, 'HOUR': 3, 'DAY': 4}
schedule_status = {'RUNNING': 1, 'STOPPED': 2}
schedule_active = {'ACTIVE': 1, 'DEACTIVE': 2}
def get_dict_key_by_name(dictObject, value):
for (key, item_value) in dictObject.items():
if value == itemValue:
return key
return N... |
# --------------
class_1 = ['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio']
class_2 = ['Hilary Mason','Carla Gentry','Corinna Cortes']
new_class = class_1 + class_2
new_class.append("Peter Warden")
print(new_class)
new_class.remove("Carla Gentry")
print(new_class)
courses = { "Math":65,"English":70,... | class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1 + class_2
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_class)
courses = {'Math': 65, 'English': 70, 'History':... |
#
# @lc app=leetcode id=20 lang=python3
#
# [20] Valid Parentheses
#
# @lc code=start
class Solution:
def isValid(self, s: str) -> bool:
# if s == ""
if len(s) == 0:
return True
d = {
')': '(',
'}' : '{',
']' : '['
}
temp = []
... | class Solution:
def is_valid(self, s: str) -> bool:
if len(s) == 0:
return True
d = {')': '(', '}': '{', ']': '['}
temp = []
for item in s:
if item not in d:
temp.append(item)
else:
if temp == []:
... |
total_umur_dalam_hari = 75
jumlah_hari_dalam_sebulan = 30
bulan = total_umur_dalam_hari/jumlah_hari_dalam_sebulan
hari = total_umur_dalam_hari % jumlah_hari_dalam_sebulan
print('umur bayi sekarang {} bulan dan {} hari'.format(bulan,hari))
print('umur bayi sekarang {1} bulan dan {0} hari'.format(hari,bulan))
print('um... | total_umur_dalam_hari = 75
jumlah_hari_dalam_sebulan = 30
bulan = total_umur_dalam_hari / jumlah_hari_dalam_sebulan
hari = total_umur_dalam_hari % jumlah_hari_dalam_sebulan
print('umur bayi sekarang {} bulan dan {} hari'.format(bulan, hari))
print('umur bayi sekarang {1} bulan dan {0} hari'.format(hari, bulan))
print('... |
# Copyright 2018 Road-Support - Roel Adriaans
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Github Connector - OCA extension",
"summary": "Add OCA specific information to Odoo modules",
"version": "13.0.1.0.0",
"category": "Connector",
"license": "AGPL-3",
"author": ... | {'name': 'Github Connector - OCA extension', 'summary': 'Add OCA specific information to Odoo modules', 'version': '13.0.1.0.0', 'category': 'Connector', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Road-Support', 'website': 'https://github.com/OCA/interface-github', 'depends': ['github_connector_o... |
def initialize():
return 'initialize'
def computeTile(x, y, array):
spend_some_time()
return 'computeTile-' + str(x) + ',' + str(y)
def dispose():
return 'dispose'
def spend_some_time():
l = list(range(10000))
for i in range(10000):
l.reverse()
| def initialize():
return 'initialize'
def compute_tile(x, y, array):
spend_some_time()
return 'computeTile-' + str(x) + ',' + str(y)
def dispose():
return 'dispose'
def spend_some_time():
l = list(range(10000))
for i in range(10000):
l.reverse() |
# Exibindo valores da lista com for
comidas = ['Cebola', 'Tomate', 'Cenoura', 'Ovo', 'Queijo', 'Cerveja']
print("indice - elemento")
for indice, elemento in enumerate(comidas):
print (f"{indice:<5}{elemento}")
print(1 + 1)
| comidas = ['Cebola', 'Tomate', 'Cenoura', 'Ovo', 'Queijo', 'Cerveja']
print('indice - elemento')
for (indice, elemento) in enumerate(comidas):
print(f'{indice:<5}{elemento}')
print(1 + 1) |
pkgname = "bsded"
pkgver = "0.99.0"
pkgrel = 0
build_style = "makefile"
pkgdesc = "FreeBSD ed(1) utility"
maintainer = "q66 <q66@chimera-linux.org>"
license = "BSD-2-Clause"
url = "https://github.com/chimera-linux/bsded"
source = f"https://github.com/chimera-linux/bsded/archive/refs/tags/v{pkgver}.tar.gz"
sha256 = "ae3... | pkgname = 'bsded'
pkgver = '0.99.0'
pkgrel = 0
build_style = 'makefile'
pkgdesc = 'FreeBSD ed(1) utility'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'BSD-2-Clause'
url = 'https://github.com/chimera-linux/bsded'
source = f'https://github.com/chimera-linux/bsded/archive/refs/tags/v{pkgver}.tar.gz'
sha256 = 'ae3... |
def load():
with open("input") as f:
yield next(f).strip()
next(f)
img = {}
for y, row in enumerate(f):
img.update({(x, y): v for x, v in enumerate(row.strip())})
yield img
def get_square(x, y, image, void_value):
for i in range(y - 1, y + 2):
for j ... | def load():
with open('input') as f:
yield next(f).strip()
next(f)
img = {}
for (y, row) in enumerate(f):
img.update({(x, y): v for (x, v) in enumerate(row.strip())})
yield img
def get_square(x, y, image, void_value):
for i in range(y - 1, y + 2):
for... |
#a function which formats a duration, given as a number of seconds, in a human-friendly way.
def format_duration(seconds):
if seconds is 0:
return 'now'
times = ['years', 'days', 'hours', 'minutes', 'seconds']
times_to_seconds = {'years':31536000, 'days':86400, 'hours':3600, 'minutes':60, 'seconds... | def format_duration(seconds):
if seconds is 0:
return 'now'
times = ['years', 'days', 'hours', 'minutes', 'seconds']
times_to_seconds = {'years': 31536000, 'days': 86400, 'hours': 3600, 'minutes': 60, 'seconds': 1}
times_to_templates = {'years': '{} year{}', 'days': '{} day{}', 'hours': '{} hour... |
#
# Bounce constant investigation
#
Y_BASE = 210
Y_TOP = 88
Y_MAX = 65 # maximum allowed height
TIME = 113 # time to bounce
# simulates given arc with starting VY and gravity AY
# returns (peak,time length)
def arc(vy,ay,trace=False):
p = 0
y = 0
t = 0
if (trace):
print("arc(%5d,%5d)" % (vy,... | y_base = 210
y_top = 88
y_max = 65
time = 113
def arc(vy, ay, trace=False):
p = 0
y = 0
t = 0
if trace:
print('arc(%5d,%5d)' % (vy, ay))
while y >= 0:
if trace:
print('%3d: %6d %3d' % (t, vy, Y_BASE - y // 256))
y += vy
p = max(p, y)
vy -= ay
... |
ca, na = map(int, input().split())
fila = []
caixas = []
lim = 0
tempo = 0
for cliente in range(na):
chegada, tempo_atendimento = map(int, input().split())
fila.append([chegada, tempo_atendimento])
while fila:
try:
while (tempo >= fila[0][0]) and (len(caixas) < ca):
pessoa = fila[0]
caixas.append(pessoa[1]... | (ca, na) = map(int, input().split())
fila = []
caixas = []
lim = 0
tempo = 0
for cliente in range(na):
(chegada, tempo_atendimento) = map(int, input().split())
fila.append([chegada, tempo_atendimento])
while fila:
try:
while tempo >= fila[0][0] and len(caixas) < ca:
pessoa = fila[0]
... |
class Solution:
def isValid(self, s: str) -> bool:
if s[0] == ')': return False
openClose = {'(':')', '{':'}', '[':']'}
stack = []
for i in range(len(s)):
if s[i] in '({[':
stack.append(s[i])
else:
if not stack... | class Solution:
def is_valid(self, s: str) -> bool:
if s[0] == ')':
return False
open_close = {'(': ')', '{': '}', '[': ']'}
stack = []
for i in range(len(s)):
if s[i] in '({[':
stack.append(s[i])
else:
if not stack... |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def __str__(self):
return "Node:%d" % self.val
class Solution:
# @param {ListNode} head
# @param {integer} val
# @return {ListNode}
def removeElements(self, head, val):
dummy = Lis... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
def __str__(self):
return 'Node:%d' % self.val
class Solution:
def remove_elements(self, head, val):
dummy = list_node(0)
dummy.next = head
current = dummy
while current and curre... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"get_spark_session": "00_00_core.ipynb",
"get_directory_size": "00_00_core.ipynb",
"get_size_format": "00_00_core.ipynb"}
modules = ["core.py"]
doc_url = "https://HansjoergW.github.io/bfh_... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'get_spark_session': '00_00_core.ipynb', 'get_directory_size': '00_00_core.ipynb', 'get_size_format': '00_00_core.ipynb'}
modules = ['core.py']
doc_url = 'https://HansjoergW.github.io/bfh_cas_bgd_fs2020_sa/'
git_url = 'https://github.com/HansjoergW/... |
def count(word):
return f'{word} has {len(word)} characters.'
if __name__ == '__main__':
print(count(input('What is the input string?'))) | def count(word):
return f'{word} has {len(word)} characters.'
if __name__ == '__main__':
print(count(input('What is the input string?'))) |
#!/usr/bin/python3
for n1 in range(1,11):
print("Tabla del " + str(n1))
print("-----------")
for n2 in range(1,11):
print(str(n1) + " por " + str(n2) + " es " + str(n1*n2))
| for n1 in range(1, 11):
print('Tabla del ' + str(n1))
print('-----------')
for n2 in range(1, 11):
print(str(n1) + ' por ' + str(n2) + ' es ' + str(n1 * n2)) |
class Solution:
def candy(self, ratings: List[int]) -> int:
ratingsLength = len(ratings)
if ratingsLength == 0:
return 0
candies = [1] * ratingsLength
for i in range(1, ratingsLength):
if ratings[i] > ratings[i - 1]:
candies[i] = candies[i - 1]... | class Solution:
def candy(self, ratings: List[int]) -> int:
ratings_length = len(ratings)
if ratingsLength == 0:
return 0
candies = [1] * ratingsLength
for i in range(1, ratingsLength):
if ratings[i] > ratings[i - 1]:
candies[i] = candies[i - ... |
expected_output = {
'cores': {
1: {
'virtual_service': 'guestshell+',
'process_name': 'sleep',
'pid': 266,
'date': '2019-05-30 19:53:28',
},
}
}
| expected_output = {'cores': {1: {'virtual_service': 'guestshell+', 'process_name': 'sleep', 'pid': 266, 'date': '2019-05-30 19:53:28'}}} |
# Copyright 2009 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'includes': [
'../../../../../build/common.gypi',
],
'targets': [
{
'target_name': 'service_runtime_x86_32',
'type': 'static... | {'includes': ['../../../../../build/common.gypi'], 'targets': [{'target_name': 'service_runtime_x86_32', 'type': 'static_library', 'sources': ['nacl_app_32.c', 'nacl_switch_32.S', 'nacl_switch_all_regs_32.c', 'nacl_switch_all_regs_asm_32.S', 'nacl_switch_to_app_32.c', 'nacl_syscall_32.S', 'nacl_tls_32.c', 'sel_addrspac... |
n=int(input())
x=[0]+[*map(int,input().split())]
dp=[0]*(n+5)
dp[1]=x[1]
ans=dp[1]
for i in range(2,n+1):
dp[i]=x[i]
for j in range(1,i):
if x[j]>x[i]:
dp[i]=max(dp[i],dp[j]+x[i])
ans=max(ans,dp[i])
print(ans) | n = int(input())
x = [0] + [*map(int, input().split())]
dp = [0] * (n + 5)
dp[1] = x[1]
ans = dp[1]
for i in range(2, n + 1):
dp[i] = x[i]
for j in range(1, i):
if x[j] > x[i]:
dp[i] = max(dp[i], dp[j] + x[i])
ans = max(ans, dp[i])
print(ans) |
n = int(input())
slist = []
for i in range(2,n):
iss = False
for ii in range(2,i):
if i%ii == 0:
iss = True
break;
if not iss:
slist.append(i)
print(slist)
| n = int(input())
slist = []
for i in range(2, n):
iss = False
for ii in range(2, i):
if i % ii == 0:
iss = True
break
if not iss:
slist.append(i)
print(slist) |
def binary_classification_metrics(prediction, ground_truth):
'''
Computes metrics for binary classification
Arguments:
prediction, np array of bool (num_samples) - model predictions
ground_truth, np array of bool (num_samples) - true labels
Returns:
precision, recall, f1, accuracy - classi... | def binary_classification_metrics(prediction, ground_truth):
"""
Computes metrics for binary classification
Arguments:
prediction, np array of bool (num_samples) - model predictions
ground_truth, np array of bool (num_samples) - true labels
Returns:
precision, recall, f1, accuracy - classi... |
global driver
def infect(driver_):
global driver
driver = driver_
class Widget:
selector = None
def __init__(self, driver):
self.driver = driver
def setup_class(self):
if self.selector is None:
raise Exception('You need to assign me a selector: %s' % self)
se... | global driver
def infect(driver_):
global driver
driver = driver_
class Widget:
selector = None
def __init__(self, driver):
self.driver = driver
def setup_class(self):
if self.selector is None:
raise exception('You need to assign me a selector: %s' % self)
sel... |
#
# PySNMP MIB module LIEBERT-GP-AGENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/LIEBERT-GP-AGENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:06:38 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (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_union, value_range_constraint, constraints_intersection) ... |
class ParsingError(Exception):
pass
class UnexpectedToken(ParsingError):
def __init__(self, index):
super().__init__()
self.index = index
| class Parsingerror(Exception):
pass
class Unexpectedtoken(ParsingError):
def __init__(self, index):
super().__init__()
self.index = index |
the_list = [1,2,3,4,5,6,7,8,9,10]
def filter_evens(li):
even_numbers = [items for items in the_list if items % 2 ==0]
print(even_numbers)
filter_evens(the_list) | the_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def filter_evens(li):
even_numbers = [items for items in the_list if items % 2 == 0]
print(even_numbers)
filter_evens(the_list) |
# dictionaries
fruit = {
"orange": "a sweet, orange, citrus frtui",
"apple": "good for making cider",
"lemon": "a sour, yellow citrus fruit",
"grape": "a small, sweet fruit growing in bunches",
"lime": " a sour, green citruis fruit"
}
# print(fruit)
# print(fruit["lemon"])
fruit["pear"] = "an odd s... | fruit = {'orange': 'a sweet, orange, citrus frtui', 'apple': 'good for making cider', 'lemon': 'a sour, yellow citrus fruit', 'grape': 'a small, sweet fruit growing in bunches', 'lime': ' a sour, green citruis fruit'}
fruit['pear'] = 'an odd shaped apple'
fruit['lime'] = 'great with tequila'
while True:
dict_key = ... |
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
n = len(nums)
l = []
for i, j in enumerate(nums):
l.append((j, i))
l.sort(key = lambda x: x[0])
#print(l)
i = 0
j = 1
while j < n... | class Solution:
def contains_nearby_almost_duplicate(self, nums: List[int], k: int, t: int) -> bool:
n = len(nums)
l = []
for (i, j) in enumerate(nums):
l.append((j, i))
l.sort(key=lambda x: x[0])
i = 0
j = 1
while j < n:
if abs(l[j][0... |
exp_token = "dns"
exp_dir = "./exp_diversity_noise"
q_ratio = "0.2"
test_ratio = "0.5"
maj_ratio = 0.755558
prepare_data = False
submit = True
split_size = 1000
n_test = 100
n_test_maj = 100 * maj_ratio
n_test_min = 100 - n_test_maj
k_maj = 5 * maj_ratio
k_min = 5. - k_maj
alpha = "0.1"
n_runs = 100
n_runs_test = 1000
... | exp_token = 'dns'
exp_dir = './exp_diversity_noise'
q_ratio = '0.2'
test_ratio = '0.5'
maj_ratio = 0.755558
prepare_data = False
submit = True
split_size = 1000
n_test = 100
n_test_maj = 100 * maj_ratio
n_test_min = 100 - n_test_maj
k_maj = 5 * maj_ratio
k_min = 5.0 - k_maj
alpha = '0.1'
n_runs = 100
n_runs_test = 1000... |
n = int(input())
for i in range(n):
alg = str(input())
e = str(input()).split()
r = int(e[0])
g = int(e[1])
b = int(e[2])
if alg == 'eye' : p = int(0.3 * r + 0.59 * g + 0.11 * b)
elif alg == 'mean': p = int((r + g + b) / 3)
elif alg == 'max' : p = sorted([r, g, b])[2]
elif alg == '... | n = int(input())
for i in range(n):
alg = str(input())
e = str(input()).split()
r = int(e[0])
g = int(e[1])
b = int(e[2])
if alg == 'eye':
p = int(0.3 * r + 0.59 * g + 0.11 * b)
elif alg == 'mean':
p = int((r + g + b) / 3)
elif alg == 'max':
p = sorted([r, g, b])[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.