content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
DEV = {
"SERVER_NAME": "dev-api.materialsdatafacility.org",
"API_LOG_FILE": "deva.log",
"PROCESS_LOG_FILE": "devp.log",
"LOG_LEVEL": "DEBUG",
"FORM_URL": "https://connect.materialsdatafacility.org/",
"TRANSFER_DEADLINE": 3 * 60 * 60, # 3 hours, in seconds
"INGEST_URL": "https://dev-api.... | dev = {'SERVER_NAME': 'dev-api.materialsdatafacility.org', 'API_LOG_FILE': 'deva.log', 'PROCESS_LOG_FILE': 'devp.log', 'LOG_LEVEL': 'DEBUG', 'FORM_URL': 'https://connect.materialsdatafacility.org/', 'TRANSFER_DEADLINE': 3 * 60 * 60, 'INGEST_URL': 'https://dev-api.materialsdatafacility.org/ingest', 'INGEST_INDEX': 'mdf-... |
inputDoc = open("input.txt")
docLines = inputDoc.readlines()
inputDoc.close()
# PART 1
# Find two numbers that add up to 2020 and multiply them
correct1 = []
for line in docLines:
line = int(line.replace("\n", ""))
for lineTwo in docLines:
lineTwo = int(lineTwo.replace("\n", ""))
if line + line... | input_doc = open('input.txt')
doc_lines = inputDoc.readlines()
inputDoc.close()
correct1 = []
for line in docLines:
line = int(line.replace('\n', ''))
for line_two in docLines:
line_two = int(lineTwo.replace('\n', ''))
if line + lineTwo == 2020:
correct1 = [line, lineTwo]
... |
class InvalidApiKeyError(Exception):
def __init__(self):
self.message = "The API key you inserted isn't valid"
class InvalidCityNameError(Exception):
def __init__(self):
self.message = "Couldn't find any city with this name or code. Please check again."
| class Invalidapikeyerror(Exception):
def __init__(self):
self.message = "The API key you inserted isn't valid"
class Invalidcitynameerror(Exception):
def __init__(self):
self.message = "Couldn't find any city with this name or code. Please check again." |
#
# PySNMP MIB module GWPAGERMIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GWPAGERMIB
# Produced by pysmi-0.3.4 at Wed May 1 13:20:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ... |
a = input()
b = input()
c = input()
print(a[0] + b[1] + c[2])
| a = input()
b = input()
c = input()
print(a[0] + b[1] + c[2]) |
def evalRPN(tokens: List[str]) -> int:
stack = [] #make a stack to hold the numberes and result calculation
for char in tokens: #iterate through the tokens
if char not in "+*-/": #if token is not an operator then it is a number so we add to stack
stack.append(int(cha... | def eval_rpn(tokens: List[str]) -> int:
stack = []
for char in tokens:
if char not in '+*-/':
stack.append(int(char))
else:
(r, l) = (stack.pop(), stack.pop())
if char == '*':
stack.append(l * r)
elif char == '/':
st... |
# Lv-677.PythonCore
name_que = input("Hello. \nWhat is your name? \n")
print ("Hello, ", name_que)
age_que = input("How old are you? \n")
print ("Your age is: ", age_que)
live_que = input(f"Where do u live {name_que}? \n")
print("You live in ", live_que) | name_que = input('Hello. \nWhat is your name? \n')
print('Hello, ', name_que)
age_que = input('How old are you? \n')
print('Your age is: ', age_que)
live_que = input(f'Where do u live {name_que}? \n')
print('You live in ', live_que) |
# Royals and suits
jack = 11
queen = 12
king = 13
ace = 14
spades = 's'
clubs = 'c'
hearts = 'h'
diamonds = 'd'
ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace]
suits = [spades, clubs, hearts, diamonds]
# Hands
straight_flush = 'Straight flush'
quads = 'Four of a kind'
full_house = 'Full house'
flush = '... | jack = 11
queen = 12
king = 13
ace = 14
spades = 's'
clubs = 'c'
hearts = 'h'
diamonds = 'd'
ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace]
suits = [spades, clubs, hearts, diamonds]
straight_flush = 'Straight flush'
quads = 'Four of a kind'
full_house = 'Full house'
flush = 'Flush'
straight = 'Straight'
t... |
s = ''
while True:
try:
s+= input()
except:
break
r = ['a', s.count('a')]
for i in range(98, 123):
n = s.count(chr(i))
if n > r[1]:
r[0] = chr(i)
r[1] = n
elif n == r[1]:
r[0] += chr(i)
print(r[0])
| s = ''
while True:
try:
s += input()
except:
break
r = ['a', s.count('a')]
for i in range(98, 123):
n = s.count(chr(i))
if n > r[1]:
r[0] = chr(i)
r[1] = n
elif n == r[1]:
r[0] += chr(i)
print(r[0]) |
def Run(filepath):
with open(filepath) as input:
measurements = list(map(int, input.read().split('\n')))
print('Day 1')
Part1(measurements)
Part2(measurements)
def Part1(measurements):
increases = 0
previousDepth = None
for depth in measurements:
#Increment if this isn't t... | def run(filepath):
with open(filepath) as input:
measurements = list(map(int, input.read().split('\n')))
print('Day 1')
part1(measurements)
part2(measurements)
def part1(measurements):
increases = 0
previous_depth = None
for depth in measurements:
if previousDepth != None an... |
my_email = 'twitterlehigh2@gmail.com'
my_password = 'kB5-LXX-T7w-TLG'
# my_email = 'twitterlehigh@gmail.com'
# my_password = 'Lehigh131016'
| my_email = 'twitterlehigh2@gmail.com'
my_password = 'kB5-LXX-T7w-TLG' |
'''
Given an integer, write a function that reverses
the bits (in binary) and returns the integer result.
Understand:
417 --> 267
167 --> 417
0 --> 0
Plan:
Use bin() to convert the binary into a string.
Use bracket indexing to reverse the order.
Use int() to convert it into a decimal number.
'''
def csReverseInte... | """
Given an integer, write a function that reverses
the bits (in binary) and returns the integer result.
Understand:
417 --> 267
167 --> 417
0 --> 0
Plan:
Use bin() to convert the binary into a string.
Use bracket indexing to reverse the order.
Use int() to convert it into a decimal number.
"""
def cs_reverse_in... |
class Solution:
def solve(self, board: List[List[str]]) -> None:
m, n = len(board), len(board and board[0])
def explore(i, j):
board[i][j] = "S"
for x, y in ((i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)):
if 0 <= x < m and 0 <= y < n and board[x][y] == "O":... | class Solution:
def solve(self, board: List[List[str]]) -> None:
(m, n) = (len(board), len(board and board[0]))
def explore(i, j):
board[i][j] = 'S'
for (x, y) in ((i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)):
if 0 <= x < m and 0 <= y < n and (board[x][y]... |
class SerVivo:
def __init__(self):
self._vivo = True
def is_vivo(self):
return self._vivo
def morir(self):
self._vivo= False
#Se pone _ porque es una clase abstracta y solo se puede usar en esta clase
#Se pone __ porque es una clase privada solo la usa cada clase
| class Servivo:
def __init__(self):
self._vivo = True
def is_vivo(self):
return self._vivo
def morir(self):
self._vivo = False |
#!/usr/bin/env python3
with open("main.go", encoding="utf-8") as file:
# FIXME
usage = "\n".join(file.read().split("\n")[13:-1])
with open("tools/_README.md", mode="r", encoding="utf-8") as file:
readme = file.read()
readme = readme.replace("<<<<USAGE>>>>", usage)
with open("README.md", mode="w", enco... | with open('main.go', encoding='utf-8') as file:
usage = '\n'.join(file.read().split('\n')[13:-1])
with open('tools/_README.md', mode='r', encoding='utf-8') as file:
readme = file.read()
readme = readme.replace('<<<<USAGE>>>>', usage)
with open('README.md', mode='w', encoding='utf-8') as file:
file.write... |
def binary_search(the_list, target):
lower_bound = 0
upper_bound = len(the_list) - 1
while lower_bound <= upper_bound:
pivot = (lower_bound + upper_bound) // 2
pivot_value = the_list[pivot]
if pivot_value == target:
return pivot
if pivot_value > target... | def binary_search(the_list, target):
lower_bound = 0
upper_bound = len(the_list) - 1
while lower_bound <= upper_bound:
pivot = (lower_bound + upper_bound) // 2
pivot_value = the_list[pivot]
if pivot_value == target:
return pivot
if pivot_value > target:
... |
def solution(n):
sum = 0
print(list(str(n)))
for i, j in enumerate(list(str(n))):
sum+=int(j)
return sum
print(solution(11)) | def solution(n):
sum = 0
print(list(str(n)))
for (i, j) in enumerate(list(str(n))):
sum += int(j)
return sum
print(solution(11)) |
#
# PySNMP MIB module HP-ICF-LINKTEST (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-LINKTEST
# Produced by pysmi-0.3.4 at Wed May 1 13:34:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_intersection, constraints_union, value_range_constraint) ... |
travel_route = input().split('||')
amount_of_fuel = int(input())
amount_of_ammunition = int(input())
travelled_distance = 0
for x in travel_route:
current_command = x.split(' ')
command = current_command[0]
if command == 'Travel':
value = int(current_command[1])
if amount_of_fuel >= value:
... | travel_route = input().split('||')
amount_of_fuel = int(input())
amount_of_ammunition = int(input())
travelled_distance = 0
for x in travel_route:
current_command = x.split(' ')
command = current_command[0]
if command == 'Travel':
value = int(current_command[1])
if amount_of_fuel >= value:
... |
'''
Author : MiKueen
Level : Medium
Problem Statement : Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Example 1:
Input:nums = [1,1,1], k = 2
Output: 2
Constraints:
The length of the array is in range [1, 20,000].
T... | """
Author : MiKueen
Level : Medium
Problem Statement : Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Example 1:
Input:nums = [1,1,1], k = 2
Output: 2
Constraints:
The length of the array is in range [1, 20,000].
T... |
class Node:
@property
def label(self):
return self.__label
@property
def left_child(self):
return self.__left_child
@left_child.setter
def left_child(self, n):
self.__left_child = n
self.__left_child.parent = self
@property
def right_sibling(self):
... | class Node:
@property
def label(self):
return self.__label
@property
def left_child(self):
return self.__left_child
@left_child.setter
def left_child(self, n):
self.__left_child = n
self.__left_child.parent = self
@property
def right_sibling(self):
... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
function
'''
def area(width, height=10):
'''
area
'''
print('width=%s, height=%s' % (width, height))
return width*height
print(area(10, 20))
print(area(height=10, width=20))
print(area(10))
def sum(a, b, *c):
'''
sum
'''
d = a+b
... | """
function
"""
def area(width, height=10):
"""
area
"""
print('width=%s, height=%s' % (width, height))
return width * height
print(area(10, 20))
print(area(height=10, width=20))
print(area(10))
def sum(a, b, *c):
"""
sum
"""
d = a + b
for i in c:
d = d + i
return ... |
# DEFEAT
# https://www.codechef.com/UNCO2021/problems/DEFEAT
NMK = [int(i) for i in input().split()]
matrix = []
for column in range(NMK[1]):
matrix.append([0]* NMK[0])
enemyLoc = []
for enemy in range(NMK[2]):
enemyLoc.append([i for i in input().split()])
for enemy in range(NMK[2]):
for enemyRow in enemyLoc[en... | nmk = [int(i) for i in input().split()]
matrix = []
for column in range(NMK[1]):
matrix.append([0] * NMK[0])
enemy_loc = []
for enemy in range(NMK[2]):
enemyLoc.append([i for i in input().split()])
for enemy in range(NMK[2]):
for enemy_row in enemyLoc[enemy][0]:
for enemy_col in enemyLoc[enemy][1]:
... |
class UvMap(object):
def __init__(self, coords=[], texture_file_name='', name=''):
self.coords = tuple(coords)
self.texture_file_name = texture_file_name
self.name = name
| class Uvmap(object):
def __init__(self, coords=[], texture_file_name='', name=''):
self.coords = tuple(coords)
self.texture_file_name = texture_file_name
self.name = name |
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'cc_source_files': [
'animation.cc',
'animation.h',
'animation_curve.cc',
'animation_curve.h',
'anim... | {'variables': {'cc_source_files': ['animation.cc', 'animation.h', 'animation_curve.cc', 'animation_curve.h', 'animation_events.h', 'animation_id_provider.cc', 'animation_id_provider.h', 'animation_registrar.cc', 'animation_registrar.h', 'append_quads_data.h', 'bitmap_content_layer_updater.cc', 'bitmap_content_layer_upd... |
class FileLock:
def __init__(self, filename):
self.filename = filename
with open(self.filename, 'w') as f:
f.write('done')
def lock(self):
with open(self.filename, 'w') as f:
f.write('working')
def unlock(self):
with open(self.filename, 'w') as f:
... | class Filelock:
def __init__(self, filename):
self.filename = filename
with open(self.filename, 'w') as f:
f.write('done')
def lock(self):
with open(self.filename, 'w') as f:
f.write('working')
def unlock(self):
with open(self.filename, 'w') as f:
... |
# Approach 1
def reverseList(A, start, end):
while start < end:
A[start], A[end] = A[end], A[start]
start += 1
end -= 1
# reverseList([1, 2, 3, 4, 5, 6], 0, 5) = [6 5 4 3 2 1]
# Approach 2
def reverseList(A, start, end):
if start >= end:
return
A[start], A[end] = A[end],... | def reverse_list(A, start, end):
while start < end:
(A[start], A[end]) = (A[end], A[start])
start += 1
end -= 1
def reverse_list(A, start, end):
if start >= end:
return
(A[start], A[end]) = (A[end], A[start])
reverse_list(A, start + 1, end - 1) |
#!/usr/bin/python3
# --- 001 > U5W2P1_Task1_w1
def solution(s):
return int(s)
if __name__ == "__main__":
print('----------start------------')
s = "12"
print(solution( s ))
print('------------end------------') | def solution(s):
return int(s)
if __name__ == '__main__':
print('----------start------------')
s = '12'
print(solution(s))
print('------------end------------') |
def sort(num) :
for i in range(len(num) - 1) :
for j in range(i, len(num)) :
if num[i] > num[j] :
temp = num[i]
num[i] = num[j]
num[j] = temp
num = [2, 6, 4, 8, 7]
sort(num)
print(num)
'''
Output :
[2, 4, 6, 7, 8]
''' | def sort(num):
for i in range(len(num) - 1):
for j in range(i, len(num)):
if num[i] > num[j]:
temp = num[i]
num[i] = num[j]
num[j] = temp
num = [2, 6, 4, 8, 7]
sort(num)
print(num)
'\nOutput :\n[2, 4, 6, 7, 8]\n' |
#! /usr/bin/env python3
def f(x):
def g(y):
# NEED THIS
nonlocal x
x = x - y
return x
return g
g0 = f(100)
ans0 = g0(42)
print(ans0)
g1 = f(200)
ans1 = g1(42)
print(ans1)
| def f(x):
def g(y):
nonlocal x
x = x - y
return x
return g
g0 = f(100)
ans0 = g0(42)
print(ans0)
g1 = f(200)
ans1 = g1(42)
print(ans1) |
# input
N = int(input())
S = []
for i in range(N):
S.append(input())
# process & output
length_T = 0
left = 0
right = N-1
while length_T < N:
if S[left] < S[right]:
print(S[left], end='')
left += 1
elif S[left] > S[right]:
print(S[right], end='')
right -= 1
else:
temp_l = left
temp_r = right
while ... | n = int(input())
s = []
for i in range(N):
S.append(input())
length_t = 0
left = 0
right = N - 1
while length_T < N:
if S[left] < S[right]:
print(S[left], end='')
left += 1
elif S[left] > S[right]:
print(S[right], end='')
right -= 1
else:
temp_l = left
tem... |
spin = input()
electric_charge = input()
if spin == '1' and electric_charge == '0':
print('Photon Boson')
else:
if electric_charge == '-1/3':
print('Strange Quark')
elif electric_charge == '2/3':
print('Charm Quark')
elif electric_charge == '-1':
print('Electron Lepton')
els... | spin = input()
electric_charge = input()
if spin == '1' and electric_charge == '0':
print('Photon Boson')
elif electric_charge == '-1/3':
print('Strange Quark')
elif electric_charge == '2/3':
print('Charm Quark')
elif electric_charge == '-1':
print('Electron Lepton')
else:
print('Muon Lepton') |
#! /usr/bin/python
@onRun
def run(args):
print("run")
return {"msg":"fsd"}
@onPause
def pause(args):
print("pause")
@onStart
def start(args):
print("start")
@onFinish
def finish(args):
print("finish") | @onRun
def run(args):
print('run')
return {'msg': 'fsd'}
@onPause
def pause(args):
print('pause')
@onStart
def start(args):
print('start')
@onFinish
def finish(args):
print('finish') |
#encoding:utf-8
subreddit = 'tf2+tf2memes+tf2shitposterclub'
t_channel = '@r_TF2'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| subreddit = 'tf2+tf2memes+tf2shitposterclub'
t_channel = '@r_TF2'
def send_post(submission, r2t):
return r2t.send_simple(submission) |
def gcd(x, y):
if y == 0:
return x
else:
return gcd(y, x % y)
print(gcd(24, 32))
| def gcd(x, y):
if y == 0:
return x
else:
return gcd(y, x % y)
print(gcd(24, 32)) |
def remove_lead_and_trail_slash(val):
if val.startswith('/'):
val = val[1:]
if val.endswith('/'):
val = val[:-1]
return val
| def remove_lead_and_trail_slash(val):
if val.startswith('/'):
val = val[1:]
if val.endswith('/'):
val = val[:-1]
return val |
def countItems(a: list) -> int:
if len(a) == 0:
return 0
else:
return 1 + countItems(a[1:])
| def count_items(a: list) -> int:
if len(a) == 0:
return 0
else:
return 1 + count_items(a[1:]) |
'''
# > File Name : P1655.py
# > Author : Tony_Wong
# > Created Time : 2019/12/07 12:05:15
# > Algorithm : Stirling II
'''
S = [[0] * 110 for i in range(110)]
for i in range(1, 110):
S[i][i] = S[i][1] = 1
for j in range(2, i):
S[i][j] = S[i - 1][j - 1] + S[i - 1][j] ... | """
# > File Name : P1655.py
# > Author : Tony_Wong
# > Created Time : 2019/12/07 12:05:15
# > Algorithm : Stirling II
"""
s = [[0] * 110 for i in range(110)]
for i in range(1, 110):
S[i][i] = S[i][1] = 1
for j in range(2, i):
S[i][j] = S[i - 1][j - 1] + S[i - 1][j] *... |
target_steps = 10000
steps_done = 0
while True:
line = input()
if line == "Going home":
home_steps = int(input())
steps_done = steps_done + home_steps
if steps_done >= target_steps:
print("Goal reached! Good job!")
print(f"{steps_done - target_steps} steps over ... | target_steps = 10000
steps_done = 0
while True:
line = input()
if line == 'Going home':
home_steps = int(input())
steps_done = steps_done + home_steps
if steps_done >= target_steps:
print('Goal reached! Good job!')
print(f'{steps_done - target_steps} steps over th... |
def axisAlignedBoundingBox(x, y):
minX = x[0]
maxX = x[0]
minY = y[0]
maxY = y[0]
for i in range(1, len(x)):
minX = min(x[i], minX)
maxX = max(x[i], maxX)
minY = min(y[i], minY)
maxY = max(y[i], maxY)
return (maxX - minX) * (maxY - minY) | def axis_aligned_bounding_box(x, y):
min_x = x[0]
max_x = x[0]
min_y = y[0]
max_y = y[0]
for i in range(1, len(x)):
min_x = min(x[i], minX)
max_x = max(x[i], maxX)
min_y = min(y[i], minY)
max_y = max(y[i], maxY)
return (maxX - minX) * (maxY - minY) |
def integrate(a, b, f, N=2000):
dx = (b-a)/N
s=0.0
for i in range(N):
s += f(a+i*dx)
return s * dx
| def integrate(a, b, f, N=2000):
dx = (b - a) / N
s = 0.0
for i in range(N):
s += f(a + i * dx)
return s * dx |
#!/usr/bin/env python3
#coding: utf-8
### 1st line allows to execute this script by typing only its name in terminal, with no need to precede it with the python command
### 2nd line declaring source code charset should be not necessary but for exemple pydoc request it
__doc__ = "INI File Reading and Writing."#inform... | __doc__ = 'INI File Reading and Writing.'
__status__ = 'Development'
__version__ = '1.0.0'
__license__ = 'public domain'
__date__ = '2021'
__author__ = 'N-zo syslog@laposte.net'
__maintainer__ = 'Nzo'
__credits__ = []
__contact__ = 'syslog@laposte.net'
class Parser:
def __init__(self, pathname):
self.pars... |
while True:
try:
code = input("Enter customer code: ")
if code == 'r' or code=='R' or code =='c' or code=='C' or code =='i' or code == 'I':
tcode = 'ok'
else:
break
iread = float(input("Enter init read: "))
fread = float(input('Enter final reading: '))... | while True:
try:
code = input('Enter customer code: ')
if code == 'r' or code == 'R' or code == 'c' or (code == 'C') or (code == 'i') or (code == 'I'):
tcode = 'ok'
else:
break
iread = float(input('Enter init read: '))
fread = float(input('Enter final ... |
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# TODO: Do with good solutions
class Solution:
def convertToDoubly(self, root):
head = TreeNode(0)
pre = [head]
def doublyUtil(root, pre)... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def convert_to_doubly(self, root):
head = tree_node(0)
pre = [head]
def doubly_util(root, pre):
if not root:
return
d... |
def find_count(numbers, target, expression=''):
if not numbers:
print(expression)
if target == 0:
return 1
else:
return 0
result = 0
result += find_count(numbers[1:], target - numbers[0], expression + f'+{numbers[0]}')
result += find_count(numbers[1:], ta... | def find_count(numbers, target, expression=''):
if not numbers:
print(expression)
if target == 0:
return 1
else:
return 0
result = 0
result += find_count(numbers[1:], target - numbers[0], expression + f'+{numbers[0]}')
result += find_count(numbers[1:], tar... |
#1 Interation through lists
L1 = [3,4,5]
L2 = [1,2,3]
L3 = []
for i in range(len(L1)):
L3.append(L1[i] + L2[i])
print(L3)
#2
L1 = [3,4,5]
L2 = [1,2,3]
L4 = list(zip(L1,L2)) #The zip fuction takes two or more sequences and it makes a list of tuples
print(L4)
#3
L1 = [3,4,5]
L2 = [1,2,3]
L3 = []
L4 = list(zip(L1... | l1 = [3, 4, 5]
l2 = [1, 2, 3]
l3 = []
for i in range(len(L1)):
L3.append(L1[i] + L2[i])
print(L3)
l1 = [3, 4, 5]
l2 = [1, 2, 3]
l4 = list(zip(L1, L2))
print(L4)
l1 = [3, 4, 5]
l2 = [1, 2, 3]
l3 = []
l4 = list(zip(L1, L2))
for (x1, x2) in L4:
L3.append(x1 + x2)
print(L3)
l1 = [3, 4, 5]
l2 = [1, 2, 3]
l3 = [x1 + ... |
def solution(st: str, limit: int) -> str:
if len(st) <= limit:
return st
for i in range(len(st)):
return st[i:limit]+'...' | def solution(st: str, limit: int) -> str:
if len(st) <= limit:
return st
for i in range(len(st)):
return st[i:limit] + '...' |
class DetectLangsRequest:
def __init__(self, text, multi, count):
self.text = text
self.multi = multi
self.count = count | class Detectlangsrequest:
def __init__(self, text, multi, count):
self.text = text
self.multi = multi
self.count = count |
print('hi\nmy name is : abdullah')
print("in this code we will do ")
#if elif else
print("if elif else")
print("\n\n")
#________________________#
age = int(input("enter your age "))
print(age)
if (age > 30 and age<60) :
print("wow")
elif (age > 60 ):
print("old")
else :
print("almost") | print('hi\nmy name is : abdullah')
print('in this code we will do ')
print('if elif else')
print('\n\n')
age = int(input('enter your age '))
print(age)
if age > 30 and age < 60:
print('wow')
elif age > 60:
print('old')
else:
print('almost') |
# Exercise 5
#
# We will define a new object, SoccerPlayer
# 1) Think about what data attributes define a soccer player in real life
# Examples include: name, age, position, goals scored
# Feel free to be creative!
# 2) Write the __init__ method for SoccerPlayer
# 3) Write the getters and setters fo... | class Soccerplayer:
pass |
g = 9.81
l1 = 1
l2 = 1
m1 = 1
m2 = 1
| g = 9.81
l1 = 1
l2 = 1
m1 = 1
m2 = 1 |
rand_map = [47, 20, 77, 91, 7, 18, 55, 46, 17, 60, 27, 40, 85, 15, 11, 12, 92, 9, 76, 62, 16, 80, 44, 13, 10, 67, 86, 65, 89, 81, 68, 26, 6, 64, 54, 57, 25, 45, 1, 83, 38, 71, 36, 75, 33, 79, 29, 63, 50, 70, 90, 56, 51, 37, 61, 42, 39, 93, 66, 43, 0, 2, 53, 74, 5, 22, 69, 82, 3, 28, 30, 34, 23, 19, 31, 84, 24, 41, 59, ... | rand_map = [47, 20, 77, 91, 7, 18, 55, 46, 17, 60, 27, 40, 85, 15, 11, 12, 92, 9, 76, 62, 16, 80, 44, 13, 10, 67, 86, 65, 89, 81, 68, 26, 6, 64, 54, 57, 25, 45, 1, 83, 38, 71, 36, 75, 33, 79, 29, 63, 50, 70, 90, 56, 51, 37, 61, 42, 39, 93, 66, 43, 0, 2, 53, 74, 5, 22, 69, 82, 3, 28, 30, 34, 23, 19, 31, 84, 24, 41, 59, ... |
course = "Python 101"
name = ("Carl Richard Matson")
print(course) # Python 101
print(name) | course = 'Python 101'
name = 'Carl Richard Matson'
print(course)
print(name) |
def binary(a, tv):
minimum = 0
maximum = len(a) - 1
while minimum < maximum:
guess = round((minimum + maximum)/2)
if a[guess] == tv:
return guess
elif a[guess] < tv:
minimum = guess + 1
else:
maximum = guess - 1
return -1
arr = []
in... | def binary(a, tv):
minimum = 0
maximum = len(a) - 1
while minimum < maximum:
guess = round((minimum + maximum) / 2)
if a[guess] == tv:
return guess
elif a[guess] < tv:
minimum = guess + 1
else:
maximum = guess - 1
return -1
arr = []
ind... |
#
# PySNMP MIB module MERU-CONFIG-ICR-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MERU-CONFIG-ICR-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:01:04 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ... |
N = int(input())
_hour = str(N // 3600)
N = N % 3600
_min = str(N // 60)
_sec = str(N % 60)
print(_hour + ':', _min + ':', _sec, sep='')
| n = int(input())
_hour = str(N // 3600)
n = N % 3600
_min = str(N // 60)
_sec = str(N % 60)
print(_hour + ':', _min + ':', _sec, sep='') |
__all__ = ['Subcommand']
# placeholder class for subcommand classes to derive from
class Subcommand(object):
pass
# placeholder class for internal subcommand classes
class InternalSubcommand(object):
pass
| __all__ = ['Subcommand']
class Subcommand(object):
pass
class Internalsubcommand(object):
pass |
def Alchemy(C, N):
return 'N' if abs(C.count('A') - C.count('B')) > 1 else 'Y'
if __name__ == "__main__":
T = int(input())
for i in range(T):
N = int(input())
C = input()
print("Case #{}:".format(i+1), end=" ")
print(Alchemy(list(C), N))
# s = "ABBBBABAAABAABBBAABAAAAAABBB... | def alchemy(C, N):
return 'N' if abs(C.count('A') - C.count('B')) > 1 else 'Y'
if __name__ == '__main__':
t = int(input())
for i in range(T):
n = int(input())
c = input()
print('Case #{}:'.format(i + 1), end=' ')
print(alchemy(list(C), N)) |
'''
Lab2
'''
#3.1
my_name = 'Tom'
print(my_name.upper())
#3.2
my_id = 123
print(my_id)
#3.3
# 123=my_id
my_id=your_id=123
print(my_id)
print(your_id)
#3.4
my_id_str = '123'
print(my_id_str)
#3.5
#print(my_name+my_id)
#3.6
print(my_name+my_id_str)
#3.7
print(my_name*3)
#3.8
print('hello, world. This is my fi... | """
Lab2
"""
my_name = 'Tom'
print(my_name.upper())
my_id = 123
print(my_id)
my_id = your_id = 123
print(my_id)
print(your_id)
my_id_str = '123'
print(my_id_str)
print(my_name + my_id_str)
print(my_name * 3)
print('hello, world. This is my first python string.'.split('.')) |
syscalls = [
"fork",
"exit",
"wait",
"pipe",
"read",
"write",
"close",
"kill",
"exec",
"open",
"mknod",
"unlink",
"fstat",
"link",
"mkdir",
"chdir",
"dup",
"getpid",
"sbrk",
"sleep",
"uptime"
]
| syscalls = ['fork', 'exit', 'wait', 'pipe', 'read', 'write', 'close', 'kill', 'exec', 'open', 'mknod', 'unlink', 'fstat', 'link', 'mkdir', 'chdir', 'dup', 'getpid', 'sbrk', 'sleep', 'uptime'] |
class Config():
# simulation
T = 2200
sim_t = 2000 + 1
current_time = 0
# Job
process_t_lower = 1
process_t_upper = 5
job_resource_lower = 5
job_resource_upper = 15
# Server
server_r = 40
server_count = 6
server_heat_constant = 200
server_pos_x = [0, 1, -2, -2,... | class Config:
t = 2200
sim_t = 2000 + 1
current_time = 0
process_t_lower = 1
process_t_upper = 5
job_resource_lower = 5
job_resource_upper = 15
server_r = 40
server_count = 6
server_heat_constant = 200
server_pos_x = [0, 1, -2, -2, 3, 3]
server_pos_y = [0, 0, 0, 2, 1, 3]
... |
class maze_control():
def __init__(self, map, solution):
self.solution = solution
self.dmap = []
for x in map:
temp = []
for y in x:
temp.append(y)
self.dmap.append(temp)
def get_car(self):
if self.solution[0] !=... | class Maze_Control:
def __init__(self, map, solution):
self.solution = solution
self.dmap = []
for x in map:
temp = []
for y in x:
temp.append(y)
self.dmap.append(temp)
def get_car(self):
if self.solution[0] != '':
... |
def print_hello(name=''):
print('Hello,'+name)
name = 'Ann'
name2 = 'Bob'
print_hello(name2) | def print_hello(name=''):
print('Hello,' + name)
name = 'Ann'
name2 = 'Bob'
print_hello(name2) |
if __name__ == '__main__':
input = open('input', 'r').readlines()
inverse = {
'(': ')',
'[': ']',
'{': '}',
'<': '>'
}
points = {
')': 1,
']': 2,
'}': 3,
'>': 4
}
score = lambda x: points[x[0]] if len(x) == 1 else 5*score(x[1:]) ... | if __name__ == '__main__':
input = open('input', 'r').readlines()
inverse = {'(': ')', '[': ']', '{': '}', '<': '>'}
points = {')': 1, ']': 2, '}': 3, '>': 4}
score = lambda x: points[x[0]] if len(x) == 1 else 5 * score(x[1:]) + points[x[0]]
scores = list()
for line in input:
stack = lis... |
class Queue:
def __init__(self):
self.items = []
def push(self, e):
self.items.append(e)
def pop(self):
head = self.items[0]
self.items = self.items[1:]
return head
q = Queue()
q.push(5) # [5]
q.push(7) # [5, 7]
q.push(11) # [5, 7, 11]
print(q.pop()) # ... | class Queue:
def __init__(self):
self.items = []
def push(self, e):
self.items.append(e)
def pop(self):
head = self.items[0]
self.items = self.items[1:]
return head
q = queue()
q.push(5)
q.push(7)
q.push(11)
print(q.pop())
print(q.pop()) |
def check(attempt, context):
if attempt.answer == flags[attempt.participant.id % len(flags)]:
return Checked(True)
if attempt.answer in flags:
return CheckedPlagiarist(False, flags.index(attempt.answer))
return Checked(False)
flags = ['LKL{s0_uSB_PXwlrPxA}', 'LKL{s0_uSB_z7dg8Y9I}... | def check(attempt, context):
if attempt.answer == flags[attempt.participant.id % len(flags)]:
return checked(True)
if attempt.answer in flags:
return checked_plagiarist(False, flags.index(attempt.answer))
return checked(False)
flags = ['LKL{s0_uSB_PXwlrPxA}', 'LKL{s0_uSB_z7dg8Y9I}', 'LKL{s0_... |
# Settings example file
# Edit as needed and save to local_settings.py
HOST = "imap.gmail.com"
USERNAME = "you@gmail.com"
PASSWORD = "IMAPappPassWord"
SEARCH_EMAIL = "tom@myspace.com"
DOWNLOAD_FOLDER = "."
POLLING_INTERVAL = 10000
DATABASE="/home/user/myfinances.gnucash"
| host = 'imap.gmail.com'
username = 'you@gmail.com'
password = 'IMAPappPassWord'
search_email = 'tom@myspace.com'
download_folder = '.'
polling_interval = 10000
database = '/home/user/myfinances.gnucash' |
# Whether to run the call graph tracer with debugging enabled. Turning off
# `if DEBUG: LOGGER.debug()` code completely yielded massive performance improvements.
DEBUG = False
FAIL_ON_UNKNOWN_BYTECODE = False
| debug = False
fail_on_unknown_bytecode = False |
# --------------
# Code starts here
class_1=['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio']
class_2=['Hilary Mason','Carla Gentry','Corinna Cortes']
new_class = class_1+class_2
print(new_class)
new_class.append("Peter Warden")
print(new_class)
new_class.remove("Carla Gentry")
print(new_class)
# Code... | class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1 + class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_class)
courses = {'Math': 65, 'English... |
x = int(input())
if(x % 2 == 0 or x % 5 == 0):
print(x)
else:
print("Not a multiple of 2 or 5")
| x = int(input())
if x % 2 == 0 or x % 5 == 0:
print(x)
else:
print('Not a multiple of 2 or 5') |
age = int(input("How old are you? "))
# if age >= 16 and age <=65:
# if 16 <= age <=65:
if age in range(16, 66):
print("Have a good day at work")
else:
print("Enjoy your free time!")
print("-" * 80)
if age <16 or age > 65:
print("Enjoy your free time!")
else:
print("Have a good day at work!") | age = int(input('How old are you? '))
if age in range(16, 66):
print('Have a good day at work')
else:
print('Enjoy your free time!')
print('-' * 80)
if age < 16 or age > 65:
print('Enjoy your free time!')
else:
print('Have a good day at work!') |
class Solution:
def addBinary(self, a: str, b: str) -> str:
ai,bi,carry = len(a)-1,len(b)-1,0
res = ''
while ai >= 0 or bi >= 0 or carry:
av = int(a[ai]) if ai >= 0 else 0
bv = int(b[bi]) if bi >= 0 else 0
sum3 = av+bv+carry
res = str(sum3%2)+r... | class Solution:
def add_binary(self, a: str, b: str) -> str:
(ai, bi, carry) = (len(a) - 1, len(b) - 1, 0)
res = ''
while ai >= 0 or bi >= 0 or carry:
av = int(a[ai]) if ai >= 0 else 0
bv = int(b[bi]) if bi >= 0 else 0
sum3 = av + bv + carry
r... |
sprinklers = [[False for j in range(1000)] for i in range(1000)]
def checkAndSwap(x1, x2):
if (x1 > x2):
return (x2, x1)
else:
return (x1, x2)
with open("D:\\Work\\Repositories\\programmingContest\\contest1\\programmingContest1Input2.txt") as file:
for line in file:
lin... | sprinklers = [[False for j in range(1000)] for i in range(1000)]
def check_and_swap(x1, x2):
if x1 > x2:
return (x2, x1)
else:
return (x1, x2)
with open('D:\\Work\\Repositories\\programmingContest\\contest1\\programmingContest1Input2.txt') as file:
for line in file:
line = line.lowe... |
politician_mapping = {
"properties": {
"name": {"type": "text", "analyzer": "indexing_analyzer", "search_analyzer":"search_analyzer"},
"occupation": {"type": "text", "analyzer": "indexing_analyzer", "search_analyzer":"search_analyzer"},
"party": {"type": "text", "analyzer": "indexing_analyze... | politician_mapping = {'properties': {'name': {'type': 'text', 'analyzer': 'indexing_analyzer', 'search_analyzer': 'search_analyzer'}, 'occupation': {'type': 'text', 'analyzer': 'indexing_analyzer', 'search_analyzer': 'search_analyzer'}, 'party': {'type': 'text', 'analyzer': 'indexing_analyzer', 'search_analyzer': 'sear... |
class Project:
def __init__(self, id, name, country, altitude, currency):
self.id = id
self.name = name
self.country = country
self.altitude = altitude
self.currency = currency
def __str__(self):
return "ID: {} \nName: {} \nCountry: {} \nAltitude: {} \nCurrency: ... | class Project:
def __init__(self, id, name, country, altitude, currency):
self.id = id
self.name = name
self.country = country
self.altitude = altitude
self.currency = currency
def __str__(self):
return 'ID: {} \nName: {} \nCountry: {} \nAltitude: {} \nCurrency:... |
#!/usr/bin/env python3
# Thinking process:
# This doesn't work
# We need 3 DP tables:
# TD: at day i, if we have a 1-day pass, the [min cost, days left]
# TW: at day i, if we have a 1-week pass, the [min cost, days left]
# TM: at day i, if we have a 1-month pass, the [min cost, days left]
# Recurrence relation
# TD[... | class Solution:
def mincost_tickets(self, days, costs):
(cd, cw, cm) = costs
(ld, lw, lm) = (1, 7, 30)
for d in range(days[0] + 1, days[-1] + 1):
(ld, lw, lm) = (ld - 1, lw - 1, lm - 1)
if d in days:
m = min(cd, cw, cm)
(cd, ld) = (m +... |
def to_list(string):
list_str = []
for tok in string:
list_str.append(tok)
return list_str
def to_string(list):
string_list = ""
for item in list:
string_list += item
return string_list
def fst_op(program):
raw = ""
for item in program:
if item == "(":
... | def to_list(string):
list_str = []
for tok in string:
list_str.append(tok)
return list_str
def to_string(list):
string_list = ''
for item in list:
string_list += item
return string_list
def fst_op(program):
raw = ''
for item in program:
if item == '(':
... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: aghast_generated
class InterpretedBuffer(object):
NONE = 0
InterpretedInlineBuffer = 1
InterpretedInlineInt64Buffer = 2
InterpretedInlineFloat64Buffer = 3
InterpretedExternalBuffer = 4
| class Interpretedbuffer(object):
none = 0
interpreted_inline_buffer = 1
interpreted_inline_int64_buffer = 2
interpreted_inline_float64_buffer = 3
interpreted_external_buffer = 4 |
# https://docs.python.org/3/faq/programming.html#how-do-i-share-global-variables-across-modules
crLog = None
environment_config = None
magic_value_config = None
message_config = None
| cr_log = None
environment_config = None
magic_value_config = None
message_config = None |
def check(i):
for j in range(m):
if need[i][j] > available[j]:
return False
return True
n = int(input("Enter the number of Processes: "))
m = int(input("Enter the number of Resources: "))
allocation = []
for i in range(n):
allocation.append(list(map(int, input('\nEnter the number of in... | def check(i):
for j in range(m):
if need[i][j] > available[j]:
return False
return True
n = int(input('Enter the number of Processes: '))
m = int(input('Enter the number of Resources: '))
allocation = []
for i in range(n):
allocation.append(list(map(int, input('\nEnter the number of inst... |
RESOLVER_STORE = {"pulumi.json": {"Any": {"type": "any"}, "Asset": {"type": "string"}}}
PULUMI_ID = "id"
PULUMI_NS = "pulumi"
PULUMI_HOME_ENV = "PULUMI_HOME"
| resolver_store = {'pulumi.json': {'Any': {'type': 'any'}, 'Asset': {'type': 'string'}}}
pulumi_id = 'id'
pulumi_ns = 'pulumi'
pulumi_home_env = 'PULUMI_HOME' |
def is_in_range(digits, r_max):
number = 0
for i, d in enumerate(digits):
number += d * 10**i
if number > r_max:
return False
# print(number)
return True
def is_valid(digits):
distinct_digits = list(set(digits))
for dd in distinct_digits:
if digits.count(dd) == 2:
return True
return False
def solve(... | def is_in_range(digits, r_max):
number = 0
for (i, d) in enumerate(digits):
number += d * 10 ** i
if number > r_max:
return False
return True
def is_valid(digits):
distinct_digits = list(set(digits))
for dd in distinct_digits:
if digits.count(dd) == 2:
return... |
def analysis(filename):
file = open(filename)
total = []
for entry in file:
info = entry.split(' ')
total.append(info)
total.sort(key = lambda x: int(x[1][:-1]),reverse=True)
# print(total[:1000])
final_analysis = open('final_analysis.txt','w')
for entry in total:
fin... | def analysis(filename):
file = open(filename)
total = []
for entry in file:
info = entry.split(' ')
total.append(info)
total.sort(key=lambda x: int(x[1][:-1]), reverse=True)
final_analysis = open('final_analysis.txt', 'w')
for entry in total:
final_analysis.write(' '.join... |
def sudoku(grid):
match = [i for i in range(1, 10)]
for row in grid:
if sorted(row) != match:
return False
for column_index in range(9):
column = [grid[row_index][column_index] for row_index in range(9)]
if sorted(column) != match:
return False
for row in ... | def sudoku(grid):
match = [i for i in range(1, 10)]
for row in grid:
if sorted(row) != match:
return False
for column_index in range(9):
column = [grid[row_index][column_index] for row_index in range(9)]
if sorted(column) != match:
return False
for row in ... |
## Verifica Palavra no Nome
nome = str(input('Qual seu nome completo? ')).strip()
print('Seu nome tem Silva? {}'.format('SILVA' in nome.upper()))
## Concatenando Strings
print('-='*30)
print('CONCATENANDO STRINGS')
print('-='*30)
a = 'Wollacy'
b = 'Lilian'
c = 'Augusto'
print(a)
print(b)
print(c)
d = a + ' + ' + ... | nome = str(input('Qual seu nome completo? ')).strip()
print('Seu nome tem Silva? {}'.format('SILVA' in nome.upper()))
print('-=' * 30)
print('CONCATENANDO STRINGS')
print('-=' * 30)
a = 'Wollacy'
b = 'Lilian'
c = 'Augusto'
print(a)
print(b)
print(c)
d = a + ' + ' + b + ' = ' + c
print(d) |
syntax = r'^\+(?:tel|port|teleport)(?P<quiet>/quiet)? (?P<target>.+)$'
def teleport(caller, target, quiet=False, force=False):
target = search(caller, target).all()
if not target:
commands.pemit(caller, caller, "\c(red)!!! Unable to find target.")
return
target = target[0]
... | syntax = '^\\+(?:tel|port|teleport)(?P<quiet>/quiet)? (?P<target>.+)$'
def teleport(caller, target, quiet=False, force=False):
target = search(caller, target).all()
if not target:
commands.pemit(caller, caller, '\\c(red)!!! Unable to find target.')
return
target = target[0]
if target is... |
load("@rules_maven_third_party//:import_external.bzl", import_external = "import_external")
def dependencies():
import_external(
name = "org_codehaus_plexus_plexus_archiver",
artifact = "org.codehaus.plexus:plexus-archiver:3.4",
artifact_sha256 = "3c6611c98547dbf3f5125848c273ba719bc10df44e3... | load('@rules_maven_third_party//:import_external.bzl', import_external='import_external')
def dependencies():
import_external(name='org_codehaus_plexus_plexus_archiver', artifact='org.codehaus.plexus:plexus-archiver:3.4', artifact_sha256='3c6611c98547dbf3f5125848c273ba719bc10df44e3f492fa2e302d6135a6ea5', srcjar_sh... |
# 1. Decoration
def deco(param):
def wrapper(func):
def inner_wrapper(*arg, **kwargs):
print(param, arg, kwargs)
inner_res = func(*arg, **kwargs)
return inner_res
return inner_wrapper
return wrapper
@deco(param="do what you want to do")
def origin(times, add... | def deco(param):
def wrapper(func):
def inner_wrapper(*arg, **kwargs):
print(param, arg, kwargs)
inner_res = func(*arg, **kwargs)
return inner_res
return inner_wrapper
return wrapper
@deco(param='do what you want to do')
def origin(times, add, sub, num=1):
... |
# __INIT__.PY
__version__='v1.0.0'
| __version__ = 'v1.0.0' |
class Solution:
def oneEditAway(self, first: str, second: str) -> bool:
dp = [[0] * (len(first) + 1) for _ in range(len(second) + 1)]
n1 = len(first) + 1
n2 = len(second) + 1
for i in range(1, n1):
dp[0][i] = dp[0][i - 1] + 1
for i in range(1, n2):
dp[... | class Solution:
def one_edit_away(self, first: str, second: str) -> bool:
dp = [[0] * (len(first) + 1) for _ in range(len(second) + 1)]
n1 = len(first) + 1
n2 = len(second) + 1
for i in range(1, n1):
dp[0][i] = dp[0][i - 1] + 1
for i in range(1, n2):
... |
class Fraction:
def __repr__(self):
return '%s/%s' % (self.num, self.den)
def __add__(self, other):
num = self.num * other.den + self.den * other.num
den = self.den * other.den
return Fraction(num, den)
def __sub__(self, other):
num = self.num * other.den - self.den... | class Fraction:
def __repr__(self):
return '%s/%s' % (self.num, self.den)
def __add__(self, other):
num = self.num * other.den + self.den * other.num
den = self.den * other.den
return fraction(num, den)
def __sub__(self, other):
num = self.num * other.den - self.de... |
# To import:
# from twoscomplement import *
def lars_reverse_twos_complement(j, bits=1):
return (1<<j.bit_length()+bits) - j
def lars_twos_complement(j):
return (1<<(j.bit_length()))-j
def build_twos_complement_down(j):
origj=j
prevj=0
while prevj != j:
print(f'{j:10d}, {prevj^j:10d}')
prevj... | def lars_reverse_twos_complement(j, bits=1):
return (1 << j.bit_length() + bits) - j
def lars_twos_complement(j):
return (1 << j.bit_length()) - j
def build_twos_complement_down(j):
origj = j
prevj = 0
while prevj != j:
print(f'{j:10d}, {prevj ^ j:10d}')
prevj = j
j = lars_... |
class State:
def __init__(self):
pass
def update(self):
pass | class State:
def __init__(self):
pass
def update(self):
pass |
class EventPropertyError(Exception):
pass
class ValidationError(Exception):
def __init__(self, message: str):
self.message = message
class RetrievalError(Exception):
def __init__(self, message: str):
self.message = message
| class Eventpropertyerror(Exception):
pass
class Validationerror(Exception):
def __init__(self, message: str):
self.message = message
class Retrievalerror(Exception):
def __init__(self, message: str):
self.message = message |
# www.census.gov/geo/www/us_regdiv.pdf
CensusDivisions = (
('PACIFIC', 'AK HI WA OR CA'.split()),
('MOUNTAIN', 'MT ID WY NV UT CO AZ NM'.split()),
('WN_CENTRAL', 'ND SD MN NE IA KS MO'.split()),
('EN_CENTRAL', 'WI MI IL IN OH'.split()),
('WS_CENTRAL', 'OK AR TX LA'.split()),
('ES_CENTRAL', 'KY TN MS AL'.split()),
('S_... | census_divisions = (('PACIFIC', 'AK HI WA OR CA'.split()), ('MOUNTAIN', 'MT ID WY NV UT CO AZ NM'.split()), ('WN_CENTRAL', 'ND SD MN NE IA KS MO'.split()), ('EN_CENTRAL', 'WI MI IL IN OH'.split()), ('WS_CENTRAL', 'OK AR TX LA'.split()), ('ES_CENTRAL', 'KY TN MS AL'.split()), ('S_ATLANTIC', 'FL GA SC NC VA WV DC MD DE'... |
class Enemy:
#state
player_seen_at_tower = None # tower coordinates (x, y, z)
player_seen = None # world coordinates vec3
# constants
speed = 1
jump_speed = 5
jump_angle = 30
maxhp = 100
disappear_on_sight = False
use_ranged_weapons = True
use_grenades = False
... | class Enemy:
player_seen_at_tower = None
player_seen = None
speed = 1
jump_speed = 5
jump_angle = 30
maxhp = 100
disappear_on_sight = False
use_ranged_weapons = True
use_grenades = False
melee_weapon = None
inventory_choices = [] |
def flatten_chebi_api_attr(ch: dict, attr, _mapping: dict):
val = ch.pop(attr)
if isinstance(val, list):
if isinstance(val[0], dict):
if 'data' in val[0]:
# list of dicts
val = [el['data'] for el in val]
else:
# todo: ... | def flatten_chebi_api_attr(ch: dict, attr, _mapping: dict):
val = ch.pop(attr)
if isinstance(val, list):
if isinstance(val[0], dict):
if 'data' in val[0]:
val = [el['data'] for el in val]
else:
pass
else:
pass
elif isinstanc... |
# Path to images we are extracting content and style from
CONTENT_IMAGE_PATH = './coastal_scene.jpg'
STYLE_IMAGE_PATH = './starry_night.jpg'
# Seed for initializing numpy and tf
NP_SEED = 0
TF_SEED = 0
# Path to vgg19 checkpoint, must be downloaded separately
CHECKPOINT_PATH = './vgg_19.ckpt'
# Location of tensorboa... | content_image_path = './coastal_scene.jpg'
style_image_path = './starry_night.jpg'
np_seed = 0
tf_seed = 0
checkpoint_path = './vgg_19.ckpt'
tensorboard_dir = './train/'
debug_dir = './debug/'
height = 224
width = 224
channels = 3
content_layer = 'vgg_19/conv2/conv2_2'
style_list = ['vgg_19/conv1/conv1_1', 'vgg_19/conv... |
path = "input.txt"
file = open(path)
input = file.readlines()
file.close()
horizontal = 0
depth = 0
for item in input:
dir, speed = item.split(" ")
if dir == "forward":
horizontal += int(speed)
elif dir == "down":
depth += int(speed)
elif dir == "up":
depth -= int(speed)
... | path = 'input.txt'
file = open(path)
input = file.readlines()
file.close()
horizontal = 0
depth = 0
for item in input:
(dir, speed) = item.split(' ')
if dir == 'forward':
horizontal += int(speed)
elif dir == 'down':
depth += int(speed)
elif dir == 'up':
depth -= int(speed)
el... |
def str_bin(s_str):
st = s_str
print(' '.join(format(ord(x), "b") for x in st))
def main():
str_bin("lol")
if __name__ == "__main__":
main()
print("done") | def str_bin(s_str):
st = s_str
print(' '.join((format(ord(x), 'b') for x in st)))
def main():
str_bin('lol')
if __name__ == '__main__':
main()
print('done') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.