content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Project Euler #21: Amicable numbers
def sum_of_divisors(n):
sd = 1 # 1 is a divisors1
i = 2
i2 = i * i
while i2 <= n:
if n % i == 0:
sd += i + n // i
if i2 == n:
sd -= i
i += 1
i2 = i * i
return sd
print(sum_of_divisors(220))
print(sum_of_divisors(284))
def main():
N = 10000 # project euler
N = 300 # numsed testing
i = 2
s = 0
while i <= N:
j = sum_of_divisors(i)
if j < i:
pass
elif j == i:
pass
else:
k = sum_of_divisors(j)
if i == k:
s += i + j
i += 1
print(s)
main() | def sum_of_divisors(n):
sd = 1
i = 2
i2 = i * i
while i2 <= n:
if n % i == 0:
sd += i + n // i
if i2 == n:
sd -= i
i += 1
i2 = i * i
return sd
print(sum_of_divisors(220))
print(sum_of_divisors(284))
def main():
n = 10000
n = 300
i = 2
s = 0
while i <= N:
j = sum_of_divisors(i)
if j < i:
pass
elif j == i:
pass
else:
k = sum_of_divisors(j)
if i == k:
s += i + j
i += 1
print(s)
main() |
#!/usr/bin/env python3
#This program will write Hello World !
print("Hello World!")
| print('Hello World!') |
archivo = open("DDSIVClases/archivo.txt", "r")
# imprime cada linea del archivo txt
for linea in archivo:
print(linea)
#linea2 = archivo.readline(2)
#print(linea2)
lineas = archivo.readline()
| archivo = open('DDSIVClases/archivo.txt', 'r')
for linea in archivo:
print(linea)
lineas = archivo.readline() |
tree_count = 0
with open("input.txt") as file_handler:
for n, line in enumerate(file_handler):
if n == 0:
continue
if len(line.strip()) == 0:
continue
charPos = n*3
if charPos > len(line.strip()):
multiples = int(charPos / len(line.strip()))
charPos = charPos - (multiples * len(line.strip()))
char = line[charPos]
if char == "#":
tree_count += 1
print(tree_count)
| tree_count = 0
with open('input.txt') as file_handler:
for (n, line) in enumerate(file_handler):
if n == 0:
continue
if len(line.strip()) == 0:
continue
char_pos = n * 3
if charPos > len(line.strip()):
multiples = int(charPos / len(line.strip()))
char_pos = charPos - multiples * len(line.strip())
char = line[charPos]
if char == '#':
tree_count += 1
print(tree_count) |
#file = open('sample.txt','r')
#contents = file.read()
#file.close()
#print(contents)
with open('file_example.txt', 'r') as file:
contents = file.read()
print(contents)
| with open('file_example.txt', 'r') as file:
contents = file.read()
print(contents) |
def buildPalindrome(st):
for i in range(len(st)):
sub = st[i : len(st)]
if sub[::-1] == sub:
missing = st[0:i]
return st + missing[::-1]
return st
| def build_palindrome(st):
for i in range(len(st)):
sub = st[i:len(st)]
if sub[::-1] == sub:
missing = st[0:i]
return st + missing[::-1]
return st |
n, k = map(int, input().split())
count = 0
for _ in range(n):
a = int(input())
if a%k == 0:
count +=1
print(count) | (n, k) = map(int, input().split())
count = 0
for _ in range(n):
a = int(input())
if a % k == 0:
count += 1
print(count) |
# Programa em q o usuario possa adicionar valores numericos em uma lista, Caso o numero ja exista ele nao sera adicionado
# no final serao exibidos todos os valores unicos em ordem crescente
lista = []
resp = ''
old = 0
while True:
old = int(input('Digite um valor: '))
if old in lista:
print('Valor repetido, nao vou adicionar...')
else:
lista.append(old)
print('Valor adicionado com sucesso...')
resp = input('Deseja continuar? [S/N] ').strip().upper()[0]
while resp not in 'SsNn':
print('Digite uma opcao valida!')
resp = input('Deseja continuar? [S/N] ').strip().upper()[0]
if resp in 'Nn':
break
print('-='*20)
print(f'Voce digitou os valores {sorted(lista)}')
| lista = []
resp = ''
old = 0
while True:
old = int(input('Digite um valor: '))
if old in lista:
print('Valor repetido, nao vou adicionar...')
else:
lista.append(old)
print('Valor adicionado com sucesso...')
resp = input('Deseja continuar? [S/N] ').strip().upper()[0]
while resp not in 'SsNn':
print('Digite uma opcao valida!')
resp = input('Deseja continuar? [S/N] ').strip().upper()[0]
if resp in 'Nn':
break
print('-=' * 20)
print(f'Voce digitou os valores {sorted(lista)}') |
male = [
'AKIO',
'AKIRA',
'AOI',
'ARATA',
'ASUKA',
'AYUMU',
'DAICHI',
'DAIKI',
'DAISUKE',
'GORO',
'GOROU',
'HACHIRO',
'HACHIROU',
'HARU',
'HARUKA',
'HARUKI',
'HARUTO',
'HAYATE',
'HAYATO',
'HIBIKI',
'HIDEAKI',
'HIDEKI',
'HIDEYOSHI',
'HIKARI',
'HIKARU',
'HINATA',
'HIRAKU',
'HIROKI',
'HIROSHI',
'HIROTO',
'ICHIRO',
'ICHIROU',
'ISAMU',
'ITSUKI',
'JIRO',
'JIROU',
'JUN',
"JUN'ICHI",
'JURO',
'JUROU',
'JUUROU',
'KAEDE',
'KAITO',
'KAORU',
'KATASHI',
'KATSU',
'KATSUO',
'KATSURO',
'KATSUROU',
'KAZUKI',
'KAZUO',
'KEN',
"KEN'ICHI",
'KENJI',
'KENSHIN',
'KENTA',
'KICHIRO',
'KICHIROU',
'KIYOSHI',
'KOHAKU',
'KOUKI',
'KOUTA',
'KURO',
'KUROU',
'KYO',
'KYOU',
'MAKOTO',
'MASAMI',
'MASARU',
'MICHI',
'MINATO',
'MINORU',
'NAOKI',
'NAOMI',
'NOBORU',
'NOBU',
'NOBURU',
'NOBUYUKI',
'NORI',
'OSAMU',
'REN',
'RIKU',
'RIKUTO',
'RIN',
'ROKURO',
'ROKUROU',
'RYO',
'RYOICHI',
'RYOTA',
'RYOU',
'RYOUICHI',
'RYOUTA',
'RYUU',
'RYUUNOSUKE',
'SABURO',
'SABUROU',
'SHICHIRO',
'SHICHIROU',
'SHIN',
"SHIN'ICHI",
'SHINOBU',
'SHIORI',
'SHIRO',
'SHIROU',
'SHO',
'SHOTA',
'SHOU',
'SHOUHEI',
'SHOUTA',
'SHUN',
'SORA',
'SOTA',
'SOUMA',
'SOUTA',
'SUSUMU',
'TAICHI',
'TAIKI',
'TAKAHIRO',
'TAKARA',
'TAKASHI',
'TAKEHIKO',
'TAKESHI',
'TAKUMA',
'TAKUMI',
'TAKUYA',
'TARO',
'TAROU',
'TOMOMI',
'TSUBASA',
'YAMATO',
'YASU',
'YORI',
'YOSHI',
'YOSHIRO',
'YOSHIROU',
'YOUTA',
'YUKI',
'YUU',
'YUUDAI',
'YUUKI',
'YUUMA',
'YUUTA',
'YUUTO'
]
female = [
'AI',
'AIKO',
'AIMI',
'AINA',
'AIRI',
'AKANE',
'AKARI',
'AKEMI',
'AKI',
'AKIKO',
'AKIRA',
'AMI',
'AOI',
'ASUKA',
'ATSUKO',
'AYA',
'AYAKA',
'AYAKO',
'AYAME',
'AYANE',
'AYANO',
'CHIHIRO',
'CHIKA',
'CHIKAKO',
'CHINATSU',
'CHIYO',
'CHIYOKO',
'CHO',
'CHOU',
'CHOUKO',
'EMI',
'ETSUKO',
'FUYUKO',
'HANA',
'HANAE',
'HANAKO',
'HARU',
'HARUKA',
'HARUKO',
'HARUNA',
'HIBIKI',
'HIKARI',
'HIKARU',
'HINA',
'HINATA',
'HIROKO',
'HITOMI',
'HONOKA',
'HOSHI',
'HOSHIKO',
'HOTARU',
'IZUMI',
'JUN',
'JUNKO',
'KAEDE',
'KANON',
'KAORI',
'KAORU',
'KAREN',
'KASUMI',
'KAZUE',
'KAZUKO',
'KEIKO',
'KIKU',
'KIMIKO',
'KIYOKO',
'KOHAKU',
'KOHARU',
'KOKORO',
'KOTONE',
'KUMIKO',
'KYO',
'KYOU',
'MAI',
'MAKOTO',
'MAMI',
'MANAMI',
'MAO',
'MARI',
'MARIKO',
'MASAMI',
'MASUYO',
'MAYU',
'MEGUMI',
'MEI',
'MICHI',
'MICHIKO',
'MIDORI',
'MIHO',
'MIKA',
'MIKI',
'MIKU',
'MINAKO',
'MINATO',
'MINORU',
'MIO',
'MISAKI',
'MITSUKO',
'MIU',
'MIYAKO',
'MIYU',
'MIZUKI',
'MOE',
'MOMOKA',
'MOMOKO',
'MORIKO',
'NANA',
'NANAKO',
'NANAMI',
'NAOKO',
'NAOMI',
'NATSUKI',
'NATSUKO',
'NATSUMI',
'NOA',
'NORIKO',
'RAN',
'REI',
'REINA',
'REN',
'RIKO',
'RIN',
'RINA',
'RIO',
'SACHIKO',
'SAKI',
'SAKIKO',
'SAKURA',
'SAKURAKO',
'SATOMI',
'SAYAKA',
'SAYURI',
'SETSUKO',
'SHINJU',
'SHINOBU',
'SHIORI',
'SHIZUKA',
'SHUN',
'SORA',
'SUMIKO',
'SUZU',
'SUZUME',
'TAKAKO',
'TAKARA',
'TAMIKO',
'TOMIKO',
'TOMOKO',
'TOMOMI',
'TSUBAKI',
'TSUBAME',
'TSUBASA',
'TSUKIKO',
'UME',
'UMEKO',
'WAKANA',
'YASU',
'YOKO',
'YOSHI',
'YOSHIKO',
'YOUKO',
'YUA',
'YUI',
'YUINA',
'YUKI',
'YUKIKO',
'YUKO',
'YUMI',
'YUMIKO',
'YURI',
'YUU',
'YUUKA',
'YUUKI',
'YUUKO',
'YUUNA',
'YUZUKI'
]
last = [
'Saiu',
'Susuki',
'Tanaka',
'Kakahashi',
'Okamura',
'Ito',
'Inoue',
'Marina',
'Ohayashi',
'Kaiu',
'Ishii',
'Kichida',
'Ooshita',
'Ishida',
'Yaguchi',
'Masamoto',
'Iue',
'Kimura',
'Saitou',
'Atsumi',
'Isao',
'Abu',
'Ouno',
'Nakashima',
'Iyo',
'Aoki',
'Iketa',
'Hashinomoto',
'Okata',
'Yamasa',
'Sanka',
'Okawa',
'Touda',
'Aeda',
'Sasegawa',
'Gatou',
'Etou',
'Kontou',
'Takeuchi',
'Samurakami',
'Arai',
'Saito',
'Karumera',
'Nakano',
'Outa',
'Shiraishi',
'Eriane',
'Fuabio',
'Torori',
'Nakakawa',
'Miura',
'Okahon',
'Kanako',
'Arekusu',
'Uirane',
'Sakai',
'Eririn',
'Uchiyama',
'Ishita',
'Morita',
'Kazuko',
'Kouda',
'Enzan',
'Ageta',
'Kizakipara',
'Kawano',
'Uida',
'Shida',
'Miyamoto',
'Katsutoshi',
'Anzou',
'Mashita',
'Oshima',
'Imai',
'Tanikuchi',
'Miyagiki',
'Kawamura',
'Saita',
'Murata',
'Kouki',
'Kudau',
'Ootsuka',
'Kan',
'Kubota',
'Sukiyama',
'Sakurai',
'Oba',
'Hijimoto',
'Oyama',
'Oohira',
'Matsui',
'Nokuchi',
'Agano',
'Kanbara',
'Taketa',
'Sano',
'Nagai',
'Imura',
'Kitabayashi',
'Matsuo',
'Kishimoto',
'Kioroshi',
'Ichika',
'Abe',
'Sukimoto',
'Kikuji',
'Kokawa',
'Ounishi',
'Kouno',
'Kikawa',
'Shikuda',
'Iiwasaki',
'Misuno',
'Kawakuchi',
'Omatsuzaki',
'Arurete',
'Kitamura',
'Sannai',
'Kikuike',
'Iita',
'Uemori',
'Osawa',
'Hamata',
'Agari',
'Uchida',
'Kanno',
'Ada',
'Hayashi',
'Tsuchiya',
'Kawasaki',
'Ikazaki',
'Akiyama',
'Nameda',
'Iwata',
'Kano',
'Isa',
'Kurarise',
'Shidzu',
'Itou',
'Nakasai',
'Tagichi',
'Asano',
'Hotta',
'Sanchuu',
'Oushima',
'Toiguchi',
'Honta',
'Ashimura',
'Kaore',
'Yano',
'Oohashi',
'Umaba',
'Morihon',
'Matsushita',
'Hoshino',
'Araki',
'Oike',
'Kichioka',
'Kaai',
'Ookuho',
'Osaki',
'Uemura',
'Nota',
'Matsuura',
'Oota',
'Oogai',
'Naitou',
'Kumakai',
'Miyata',
'Hirai',
'Okura',
'Kurida',
'Eita',
'Nishiyama',
'Ota',
'Amano',
'Soukawa',
'Kurinohara',
'Kasai',
'Shouson',
'Ousawa',
'Ori',
'Oishi',
'Tsumozuki',
'Tanahe',
'Ishizaki',
'Kakuyama',
'Oizumi',
'Yokuta',
'Imoto',
'Sakakuchi',
'Ogihara',
'Sekikuchi',
'Serujio',
'Onishi',
'Eshinu',
'Sutou',
'Fukui',
'Koga',
'Honma'
]
| male = ['AKIO', 'AKIRA', 'AOI', 'ARATA', 'ASUKA', 'AYUMU', 'DAICHI', 'DAIKI', 'DAISUKE', 'GORO', 'GOROU', 'HACHIRO', 'HACHIROU', 'HARU', 'HARUKA', 'HARUKI', 'HARUTO', 'HAYATE', 'HAYATO', 'HIBIKI', 'HIDEAKI', 'HIDEKI', 'HIDEYOSHI', 'HIKARI', 'HIKARU', 'HINATA', 'HIRAKU', 'HIROKI', 'HIROSHI', 'HIROTO', 'ICHIRO', 'ICHIROU', 'ISAMU', 'ITSUKI', 'JIRO', 'JIROU', 'JUN', "JUN'ICHI", 'JURO', 'JUROU', 'JUUROU', 'KAEDE', 'KAITO', 'KAORU', 'KATASHI', 'KATSU', 'KATSUO', 'KATSURO', 'KATSUROU', 'KAZUKI', 'KAZUO', 'KEN', "KEN'ICHI", 'KENJI', 'KENSHIN', 'KENTA', 'KICHIRO', 'KICHIROU', 'KIYOSHI', 'KOHAKU', 'KOUKI', 'KOUTA', 'KURO', 'KUROU', 'KYO', 'KYOU', 'MAKOTO', 'MASAMI', 'MASARU', 'MICHI', 'MINATO', 'MINORU', 'NAOKI', 'NAOMI', 'NOBORU', 'NOBU', 'NOBURU', 'NOBUYUKI', 'NORI', 'OSAMU', 'REN', 'RIKU', 'RIKUTO', 'RIN', 'ROKURO', 'ROKUROU', 'RYO', 'RYOICHI', 'RYOTA', 'RYOU', 'RYOUICHI', 'RYOUTA', 'RYUU', 'RYUUNOSUKE', 'SABURO', 'SABUROU', 'SHICHIRO', 'SHICHIROU', 'SHIN', "SHIN'ICHI", 'SHINOBU', 'SHIORI', 'SHIRO', 'SHIROU', 'SHO', 'SHOTA', 'SHOU', 'SHOUHEI', 'SHOUTA', 'SHUN', 'SORA', 'SOTA', 'SOUMA', 'SOUTA', 'SUSUMU', 'TAICHI', 'TAIKI', 'TAKAHIRO', 'TAKARA', 'TAKASHI', 'TAKEHIKO', 'TAKESHI', 'TAKUMA', 'TAKUMI', 'TAKUYA', 'TARO', 'TAROU', 'TOMOMI', 'TSUBASA', 'YAMATO', 'YASU', 'YORI', 'YOSHI', 'YOSHIRO', 'YOSHIROU', 'YOUTA', 'YUKI', 'YUU', 'YUUDAI', 'YUUKI', 'YUUMA', 'YUUTA', 'YUUTO']
female = ['AI', 'AIKO', 'AIMI', 'AINA', 'AIRI', 'AKANE', 'AKARI', 'AKEMI', 'AKI', 'AKIKO', 'AKIRA', 'AMI', 'AOI', 'ASUKA', 'ATSUKO', 'AYA', 'AYAKA', 'AYAKO', 'AYAME', 'AYANE', 'AYANO', 'CHIHIRO', 'CHIKA', 'CHIKAKO', 'CHINATSU', 'CHIYO', 'CHIYOKO', 'CHO', 'CHOU', 'CHOUKO', 'EMI', 'ETSUKO', 'FUYUKO', 'HANA', 'HANAE', 'HANAKO', 'HARU', 'HARUKA', 'HARUKO', 'HARUNA', 'HIBIKI', 'HIKARI', 'HIKARU', 'HINA', 'HINATA', 'HIROKO', 'HITOMI', 'HONOKA', 'HOSHI', 'HOSHIKO', 'HOTARU', 'IZUMI', 'JUN', 'JUNKO', 'KAEDE', 'KANON', 'KAORI', 'KAORU', 'KAREN', 'KASUMI', 'KAZUE', 'KAZUKO', 'KEIKO', 'KIKU', 'KIMIKO', 'KIYOKO', 'KOHAKU', 'KOHARU', 'KOKORO', 'KOTONE', 'KUMIKO', 'KYO', 'KYOU', 'MAI', 'MAKOTO', 'MAMI', 'MANAMI', 'MAO', 'MARI', 'MARIKO', 'MASAMI', 'MASUYO', 'MAYU', 'MEGUMI', 'MEI', 'MICHI', 'MICHIKO', 'MIDORI', 'MIHO', 'MIKA', 'MIKI', 'MIKU', 'MINAKO', 'MINATO', 'MINORU', 'MIO', 'MISAKI', 'MITSUKO', 'MIU', 'MIYAKO', 'MIYU', 'MIZUKI', 'MOE', 'MOMOKA', 'MOMOKO', 'MORIKO', 'NANA', 'NANAKO', 'NANAMI', 'NAOKO', 'NAOMI', 'NATSUKI', 'NATSUKO', 'NATSUMI', 'NOA', 'NORIKO', 'RAN', 'REI', 'REINA', 'REN', 'RIKO', 'RIN', 'RINA', 'RIO', 'SACHIKO', 'SAKI', 'SAKIKO', 'SAKURA', 'SAKURAKO', 'SATOMI', 'SAYAKA', 'SAYURI', 'SETSUKO', 'SHINJU', 'SHINOBU', 'SHIORI', 'SHIZUKA', 'SHUN', 'SORA', 'SUMIKO', 'SUZU', 'SUZUME', 'TAKAKO', 'TAKARA', 'TAMIKO', 'TOMIKO', 'TOMOKO', 'TOMOMI', 'TSUBAKI', 'TSUBAME', 'TSUBASA', 'TSUKIKO', 'UME', 'UMEKO', 'WAKANA', 'YASU', 'YOKO', 'YOSHI', 'YOSHIKO', 'YOUKO', 'YUA', 'YUI', 'YUINA', 'YUKI', 'YUKIKO', 'YUKO', 'YUMI', 'YUMIKO', 'YURI', 'YUU', 'YUUKA', 'YUUKI', 'YUUKO', 'YUUNA', 'YUZUKI']
last = ['Saiu', 'Susuki', 'Tanaka', 'Kakahashi', 'Okamura', 'Ito', 'Inoue', 'Marina', 'Ohayashi', 'Kaiu', 'Ishii', 'Kichida', 'Ooshita', 'Ishida', 'Yaguchi', 'Masamoto', 'Iue', 'Kimura', 'Saitou', 'Atsumi', 'Isao', 'Abu', 'Ouno', 'Nakashima', 'Iyo', 'Aoki', 'Iketa', 'Hashinomoto', 'Okata', 'Yamasa', 'Sanka', 'Okawa', 'Touda', 'Aeda', 'Sasegawa', 'Gatou', 'Etou', 'Kontou', 'Takeuchi', 'Samurakami', 'Arai', 'Saito', 'Karumera', 'Nakano', 'Outa', 'Shiraishi', 'Eriane', 'Fuabio', 'Torori', 'Nakakawa', 'Miura', 'Okahon', 'Kanako', 'Arekusu', 'Uirane', 'Sakai', 'Eririn', 'Uchiyama', 'Ishita', 'Morita', 'Kazuko', 'Kouda', 'Enzan', 'Ageta', 'Kizakipara', 'Kawano', 'Uida', 'Shida', 'Miyamoto', 'Katsutoshi', 'Anzou', 'Mashita', 'Oshima', 'Imai', 'Tanikuchi', 'Miyagiki', 'Kawamura', 'Saita', 'Murata', 'Kouki', 'Kudau', 'Ootsuka', 'Kan', 'Kubota', 'Sukiyama', 'Sakurai', 'Oba', 'Hijimoto', 'Oyama', 'Oohira', 'Matsui', 'Nokuchi', 'Agano', 'Kanbara', 'Taketa', 'Sano', 'Nagai', 'Imura', 'Kitabayashi', 'Matsuo', 'Kishimoto', 'Kioroshi', 'Ichika', 'Abe', 'Sukimoto', 'Kikuji', 'Kokawa', 'Ounishi', 'Kouno', 'Kikawa', 'Shikuda', 'Iiwasaki', 'Misuno', 'Kawakuchi', 'Omatsuzaki', 'Arurete', 'Kitamura', 'Sannai', 'Kikuike', 'Iita', 'Uemori', 'Osawa', 'Hamata', 'Agari', 'Uchida', 'Kanno', 'Ada', 'Hayashi', 'Tsuchiya', 'Kawasaki', 'Ikazaki', 'Akiyama', 'Nameda', 'Iwata', 'Kano', 'Isa', 'Kurarise', 'Shidzu', 'Itou', 'Nakasai', 'Tagichi', 'Asano', 'Hotta', 'Sanchuu', 'Oushima', 'Toiguchi', 'Honta', 'Ashimura', 'Kaore', 'Yano', 'Oohashi', 'Umaba', 'Morihon', 'Matsushita', 'Hoshino', 'Araki', 'Oike', 'Kichioka', 'Kaai', 'Ookuho', 'Osaki', 'Uemura', 'Nota', 'Matsuura', 'Oota', 'Oogai', 'Naitou', 'Kumakai', 'Miyata', 'Hirai', 'Okura', 'Kurida', 'Eita', 'Nishiyama', 'Ota', 'Amano', 'Soukawa', 'Kurinohara', 'Kasai', 'Shouson', 'Ousawa', 'Ori', 'Oishi', 'Tsumozuki', 'Tanahe', 'Ishizaki', 'Kakuyama', 'Oizumi', 'Yokuta', 'Imoto', 'Sakakuchi', 'Ogihara', 'Sekikuchi', 'Serujio', 'Onishi', 'Eshinu', 'Sutou', 'Fukui', 'Koga', 'Honma'] |
class Scale:
def __init__(self, tonic):
if tonic in ["F", "Bb", "Eb", "Ab", "Db", "Gb", "d", "g", "c", "f", "bb", "eb", ]:
notes = ["A", "Bb", "B", "C", "Db", "D",
"Eb", "E", "F", "Gb", "G", "Ab", ]
else:
notes = ["A", "A#", "B", "C", "C#", "D",
"D#", "E", "F", "F#", "G", "G#", ]
i = notes.index(tonic.capitalize())
self.notes = notes[i:] + notes[:i]
def chromatic(self):
return self.notes
def interval(self, intervals):
i = 0
ret = []
for step in intervals:
ret.append(self.notes[i])
if step == 'm':
i += 1
elif step == 'M':
i += 2
elif step == 'A':
i += 3
return ret
| class Scale:
def __init__(self, tonic):
if tonic in ['F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'd', 'g', 'c', 'f', 'bb', 'eb']:
notes = ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab']
else:
notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
i = notes.index(tonic.capitalize())
self.notes = notes[i:] + notes[:i]
def chromatic(self):
return self.notes
def interval(self, intervals):
i = 0
ret = []
for step in intervals:
ret.append(self.notes[i])
if step == 'm':
i += 1
elif step == 'M':
i += 2
elif step == 'A':
i += 3
return ret |
# binStrToBytes : Converts a binary string to an array of bytes.
# @param bin : The binary string to be converted to byte array.
# @return : The byte array representation of the provided binary string.
def binStrToBytes(bin):
if (not isinstance(bin, str)):
raise TypeError("Unexpected type, expected 'str'")
# Remove whitespace from key and get size
bin = bin.replace(" ", "")
size = len(bin)
# Check length of the key
if (size % 8 != 0):
raise Exception("Invalid length, cannot convert to byte array")
# Convert the binary key string to byte array
return bytes([int(bin[i:i+8], 2) for i in range(0, size, 8)])
| def bin_str_to_bytes(bin):
if not isinstance(bin, str):
raise type_error("Unexpected type, expected 'str'")
bin = bin.replace(' ', '')
size = len(bin)
if size % 8 != 0:
raise exception('Invalid length, cannot convert to byte array')
return bytes([int(bin[i:i + 8], 2) for i in range(0, size, 8)]) |
# Hidden Street - Ardentmill :: 910001000
# Gere :: Master of Smithing :: 9031003
MINING_SKILL = 92010000
SMITHING_CRAFT_SKILL = 92020000
ACCESSORY_CRAFT_SKILL = 92030000
ALCHEMY_CRAFT_SKILL = 92040000
FEE = [5000, 15000, 25000, 40000, 60000, 85000, 115000, 150000, 190000, 235000]
if not sm.hasSkill(SMITHING_CRAFT_SKILL):
selection = sm.sendSay("I am #bGere#k, master Blacksmith. What do you want?\r\n#L0#Hear an explanation about #b#eSmithing#n.#l\r\n#L1#Learn #eSmithing#n.#k#l")
if selection == 0:
sm.sendNext("Smithing is the art of forging the minerals and gems you get from Mining into durable armor and punishing weapons. I'll show you how to shape these raw materials into equipment you've never seen before.")
elif selection == 1:
if not sm.hasSkill(MINING_SKILL):
sm.sendSayOkay("How do you plan to learn Smithing if you don't even know the Mining Profession? Seek out #bCole#k, learn what he has to teach. Then maybe you will be ready.")
sm.dispose()
if sm.hasSkill(ACCESSORY_CRAFT_SKILL) or sm.hasSkill(ALCHEMY_CRAFT_SKILL):
sm.sendNext("Well now, it seems you've already learned Accessory Crafting or Alchemy. Your reach is exceeding your grasp, isn't it? If you really want to learn it, forget one of the other Professions.")
sm.dispose()
learn = sm.sendAskYesNo("You want to learn #bSmithing#k? Show me how earnest you are by coughing up some dough!\r\nIt's #b 5,000 Mesos#k... Are you really ready to do this?\r\n")
if learn:
if sm.getMesos() < 5000:
sm.sendNext("If you can't even gather #b5000 Mesos#k, how can you hope to become a Blacksmith?")
sm.dispose()
sm.giveMesos(-5000)
sm.giveSkill(SMITHING_CRAFT_SKILL, 0x1000000, 13)
sm.playSound("profession/levelup")
sm.sendNext("To be honest, I didn't think you could learn Smithing. Well, you've only learned the most basic skill level. If you can manage to increase your Mastery, I can teach you more.")
else:
sm.sendNext("It's good to be cautious. Come back after you've thought it through.")
else:
selection = sm.sendSay("I am #bGere#k, master Blacksmith. What do you want?\r\n#L2##bRaise #eSmithing#n level.#l\r\n#L3#Unlearn Smithing.#k#l")
if selection == 2:
if sm.isAbleToLevelUpMakingSkill(SMITHING_CRAFT_SKILL):
levelup = sm.sendAskYesNo("Looks like you're ready to level up your Smithing. I'll take #b" + str(FEE[sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)]) + " Mesos#k as tuition. Ready to learn?")
if levelup:
if sm.getMesos() < FEE[sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)]:
sm.sendNext("You don't have enough mesos.")
sm.dispose()
sm.giveMesos(-FEE[sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)])
sm.makingSkillLevelUp(SMITHING_CRAFT_SKILL)
sm.sendNext("Your Smithing skill is now Lv. " + str(sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)) +".")
else:
sm.sendNext("Sure, take some time to think it over. I'll be here.")
sm.dispose()
else:
sm.sendNext("You're not ready to level up your Profession. Come back when you've increased your Mastery.")
elif selection == 3:
unlearn = sm.sendAskYesNo("You will forget everything I've taught you about Smithing. Everything you've worked towards, gone. Do you really want to do this?")
if unlearn:
sm.removeSkill(SMITHING_CRAFT_SKILL)
# set quest value 11495, "0"
# start quest 3263
# complete quest 3263
# remove quest 3263
sm.sendNext("Very well. You are no longer a Blacksmith.")
else:
sm.sendSayOkay("For once, you say something sensible.") | mining_skill = 92010000
smithing_craft_skill = 92020000
accessory_craft_skill = 92030000
alchemy_craft_skill = 92040000
fee = [5000, 15000, 25000, 40000, 60000, 85000, 115000, 150000, 190000, 235000]
if not sm.hasSkill(SMITHING_CRAFT_SKILL):
selection = sm.sendSay('I am #bGere#k, master Blacksmith. What do you want?\r\n#L0#Hear an explanation about #b#eSmithing#n.#l\r\n#L1#Learn #eSmithing#n.#k#l')
if selection == 0:
sm.sendNext("Smithing is the art of forging the minerals and gems you get from Mining into durable armor and punishing weapons. I'll show you how to shape these raw materials into equipment you've never seen before.")
elif selection == 1:
if not sm.hasSkill(MINING_SKILL):
sm.sendSayOkay("How do you plan to learn Smithing if you don't even know the Mining Profession? Seek out #bCole#k, learn what he has to teach. Then maybe you will be ready.")
sm.dispose()
if sm.hasSkill(ACCESSORY_CRAFT_SKILL) or sm.hasSkill(ALCHEMY_CRAFT_SKILL):
sm.sendNext("Well now, it seems you've already learned Accessory Crafting or Alchemy. Your reach is exceeding your grasp, isn't it? If you really want to learn it, forget one of the other Professions.")
sm.dispose()
learn = sm.sendAskYesNo("You want to learn #bSmithing#k? Show me how earnest you are by coughing up some dough!\r\nIt's #b 5,000 Mesos#k... Are you really ready to do this?\r\n")
if learn:
if sm.getMesos() < 5000:
sm.sendNext("If you can't even gather #b5000 Mesos#k, how can you hope to become a Blacksmith?")
sm.dispose()
sm.giveMesos(-5000)
sm.giveSkill(SMITHING_CRAFT_SKILL, 16777216, 13)
sm.playSound('profession/levelup')
sm.sendNext("To be honest, I didn't think you could learn Smithing. Well, you've only learned the most basic skill level. If you can manage to increase your Mastery, I can teach you more.")
else:
sm.sendNext("It's good to be cautious. Come back after you've thought it through.")
else:
selection = sm.sendSay('I am #bGere#k, master Blacksmith. What do you want?\r\n#L2##bRaise #eSmithing#n level.#l\r\n#L3#Unlearn Smithing.#k#l')
if selection == 2:
if sm.isAbleToLevelUpMakingSkill(SMITHING_CRAFT_SKILL):
levelup = sm.sendAskYesNo("Looks like you're ready to level up your Smithing. I'll take #b" + str(FEE[sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)]) + ' Mesos#k as tuition. Ready to learn?')
if levelup:
if sm.getMesos() < FEE[sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)]:
sm.sendNext("You don't have enough mesos.")
sm.dispose()
sm.giveMesos(-FEE[sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)])
sm.makingSkillLevelUp(SMITHING_CRAFT_SKILL)
sm.sendNext('Your Smithing skill is now Lv. ' + str(sm.getMakingSkillLevel(SMITHING_CRAFT_SKILL)) + '.')
else:
sm.sendNext("Sure, take some time to think it over. I'll be here.")
sm.dispose()
else:
sm.sendNext("You're not ready to level up your Profession. Come back when you've increased your Mastery.")
elif selection == 3:
unlearn = sm.sendAskYesNo("You will forget everything I've taught you about Smithing. Everything you've worked towards, gone. Do you really want to do this?")
if unlearn:
sm.removeSkill(SMITHING_CRAFT_SKILL)
sm.sendNext('Very well. You are no longer a Blacksmith.')
else:
sm.sendSayOkay('For once, you say something sensible.') |
''' Dataset 1
# This cases have displaced or incorrect annotation files
# Some maybe be corrected using the map below
skipCase = ['LUNG1-034',
'LUNG1-040',
'LUNG1-044',
'LUNG1-068',
'LUNG1-083',
'LUNG1-084',
'LUNG1-094',
'LUNG1-096',
'LUNG1-176' ]
# corrections applied by using np.roll on the 3D mask along the y-axis(0) and x-axis(1)
# format = (dy,dx), None implies correction requires more than simple translation
corrections = {
'LUNG1-034': (165, 0),
'LUNG1-040': (190, 0),
'LUNG1-044': (166, 0),
'LUNG1-068': None,
'LUNG1-083': (293, 0),
'LUNG1-084': (314, 0),
'LUNG1-094': (328, 0),
'LUNG1-096': (318, 0),
'LUNG1-176': None
}
# Manufactuers of CT Scanners used for different cases
SIEMENS = ['LUNG1-013', 'LUNG1-098', 'LUNG1-099', 'LUNG1-094', 'LUNG1-096', 'LUNG1-097', 'LUNG1-090', 'LUNG1-092', 'LUNG1-093', 'LUNG1-065', 'LUNG1-072', 'LUNG1-073', 'LUNG1-071', 'LUNG1-077', 'LUNG1-075', 'LUNG1-079', 'LUNG1-048',
'LUNG1-051', 'LUNG1-056', 'LUNG1-102', 'LUNG1-103', 'LUNG1-100', 'LUNG1-104', 'LUNG1-105', 'LUNG1-029', 'LUNG1-032', 'LUNG1-001', 'LUNG1-004', 'LUNG1-083', 'LUNG1-082', 'LUNG1-080', 'LUNG1-086', 'LUNG1-084']
CMS = ['LUNG1-014', 'LUNG1-015', 'LUNG1-016', 'LUNG1-017', 'LUNG1-010', 'LUNG1-011', 'LUNG1-012', 'LUNG1-018', 'LUNG1-019', 'LUNG1-095', 'LUNG1-091', 'LUNG1-061', 'LUNG1-060', 'LUNG1-063', 'LUNG1-062', 'LUNG1-064', 'LUNG1-066', 'LUNG1-069', 'LUNG1-068', 'LUNG1-070', 'LUNG1-076', 'LUNG1-074', 'LUNG1-078', 'LUNG1-047', 'LUNG1-046', 'LUNG1-045', 'LUNG1-044', 'LUNG1-043', 'LUNG1-042', 'LUNG1-041', 'LUNG1-040', 'LUNG1-049', 'LUNG1-059',
'LUNG1-052', 'LUNG1-053', 'LUNG1-054', 'LUNG1-055', 'LUNG1-057', 'LUNG1-101', 'LUNG1-028', 'LUNG1-025', 'LUNG1-024', 'LUNG1-027', 'LUNG1-026', 'LUNG1-021', 'LUNG1-020', 'LUNG1-023', 'LUNG1-022', 'LUNG1-038', 'LUNG1-039', 'LUNG1-037', 'LUNG1-034', 'LUNG1-035', 'LUNG1-033', 'LUNG1-030', 'LUNG1-031', 'LUNG1-003', 'LUNG1-002', 'LUNG1-006', 'LUNG1-005', 'LUNG1-009', 'LUNG1-008', 'LUNG1-089', 'LUNG1-088', 'LUNG1-081', 'LUNG1-087', 'LUNG1-085']
'''
''' Dataset 3 '''
# This cases have displaced or incorrect annotation files
# Some maybe be corrected using the map below
skipCase = ['LUNG1-212','LUNG1-043','LUNG1-045','LUNG1-139' ]
# corrections applied by using np.roll on the 3D mask along the y-axis(0) and x-axis(1)
# format = (dy,dx), None implies correction requires more than simple translation
corrections = {
'LUNG1-212' : None,
'LUNG1-043' : None,
'LUNG1-045' : None,
'LUNG1-139': None,
}
# Manufacturers of CT Scanners
# Train
SIEMENS = ['LUNG1-278', 'LUNG1-148', 'LUNG1-237', 'LUNG1-134', 'LUNG1-258', 'LUNG1-259', 'LUNG1-256', 'LUNG1-257', 'LUNG1-255', 'LUNG1-252', 'LUNG1-253', 'LUNG1-317', 'LUNG1-147', 'LUNG1-144', 'LUNG1-145', 'LUNG1-098', 'LUNG1-099', 'LUNG1-141', 'LUNG1-095', 'LUNG1-096', 'LUNG1-097', 'LUNG1-090', 'LUNG1-091', 'LUNG1-092', 'LUNG1-318', 'LUNG1-308', 'LUNG1-309', 'LUNG1-261', 'LUNG1-260', 'LUNG1-129', 'LUNG1-263', 'LUNG1-262', 'LUNG1-178', 'LUNG1-267', 'LUNG1-266', 'LUNG1-264', 'LUNG1-173', 'LUNG1-172', 'LUNG1-171', 'LUNG1-268', 'LUNG1-177', 'LUNG1-176', 'LUNG1-307', 'LUNG1-065', 'LUNG1-069', 'LUNG1-269', 'LUNG1-289', 'LUNG1-288', 'LUNG1-170', 'LUNG1-321', 'LUNG1-281', 'LUNG1-280', 'LUNG1-283', 'LUNG1-282', 'LUNG1-285', 'LUNG1-284', 'LUNG1-287', 'LUNG1-286', 'LUNG1-306', 'LUNG1-274', 'LUNG1-275', 'LUNG1-276', 'LUNG1-277', 'LUNG1-168', 'LUNG1-272', 'LUNG1-273', 'LUNG1-164', 'LUNG1-165', 'LUNG1-166', 'LUNG1-167', 'LUNG1-160', 'LUNG1-161', 'LUNG1-162', 'LUNG1-163', 'LUNG1-072', 'LUNG1-071', 'LUNG1-077', 'LUNG1-074', 'LUNG1-075', 'LUNG1-093', 'LUNG1-079', 'LUNG1-298', 'LUNG1-299', 'LUNG1-139', 'LUNG1-183', 'LUNG1-292', 'LUNG1-293', 'LUNG1-290', 'LUNG1-291', 'LUNG1-296', 'LUNG1-297', 'LUNG1-294', 'LUNG1-295', 'LUNG1-191', 'LUNG1-190', 'LUNG1-193', 'LUNG1-192', 'LUNG1-194', 'LUNG1-197', 'LUNG1-196',
'LUNG1-199', 'LUNG1-313', 'LUNG1-205', 'LUNG1-207', 'LUNG1-111', 'LUNG1-110', 'LUNG1-113', 'LUNG1-112', 'LUNG1-115', 'LUNG1-114', 'LUNG1-117', 'LUNG1-053', 'LUNG1-300', 'LUNG1-146', 'LUNG1-180', 'LUNG1-181', 'LUNG1-315', 'LUNG1-057', 'LUNG1-212', 'LUNG1-213', 'LUNG1-108', 'LUNG1-211', 'LUNG1-216', 'LUNG1-217', 'LUNG1-214', 'LUNG1-215', 'LUNG1-102', 'LUNG1-142', 'LUNG1-100', 'LUNG1-107', 'LUNG1-104', 'LUNG1-105', 'LUNG1-311', 'LUNG1-132', 'LUNG1-310', 'LUNG1-151', 'LUNG1-131', 'LUNG1-103', 'LUNG1-218', 'LUNG1-219', 'LUNG1-227', 'LUNG1-226', 'LUNG1-225', 'LUNG1-224', 'LUNG1-223', 'LUNG1-222', 'LUNG1-221', 'LUNG1-220', 'LUNG1-136', 'LUNG1-133', 'LUNG1-229', 'LUNG1-130', 'LUNG1-304', 'LUNG1-244', 'LUNG1-143', 'LUNG1-119', 'LUNG1-118', 'LUNG1-084', 'LUNG1-231', 'LUNG1-232', 'LUNG1-233', 'LUNG1-234', 'LUNG1-235', 'LUNG1-236', 'LUNG1-305', 'LUNG1-120', 'LUNG1-121', 'LUNG1-122', 'LUNG1-123', 'LUNG1-125', 'LUNG1-126', 'LUNG1-127', 'LUNG1-109', 'LUNG1-138', 'LUNG1-239', 'LUNG1-208', 'LUNG1-270', 'LUNG1-303', 'LUNG1-271', 'LUNG1-320', 'LUNG1-080', 'LUNG1-249', 'LUNG1-248', 'LUNG1-245', 'LUNG1-247', 'LUNG1-246', 'LUNG1-241', 'LUNG1-240', 'LUNG1-243', 'LUNG1-242', 'LUNG1-154', 'LUNG1-157', 'LUNG1-156', 'LUNG1-326', 'LUNG1-150', 'LUNG1-152', 'LUNG1-082', 'LUNG1-048', 'LUNG1-085', 'LUNG1-210']
CMS = ['LUNG1-140', 'LUNG1-094', 'LUNG1-179', 'LUNG1-175', 'LUNG1-061', 'LUNG1-060', 'LUNG1-063', 'LUNG1-062', 'LUNG1-064', 'LUNG1-066', 'LUNG1-068', 'LUNG1-174', 'LUNG1-169', 'LUNG1-073', 'LUNG1-070', 'LUNG1-076', 'LUNG1-078', 'LUNG1-087', 'LUNG1-195', 'LUNG1-198', 'LUNG1-086', 'LUNG1-201', 'LUNG1-046', 'LUNG1-203', 'LUNG1-044', 'LUNG1-204', 'LUNG1-206', 'LUNG1-116', 'LUNG1-055', 'LUNG1-182',
'LUNG1-186', 'LUNG1-187', 'LUNG1-184', 'LUNG1-185', 'LUNG1-051', 'LUNG1-052', 'LUNG1-189', 'LUNG1-054', 'LUNG1-056', 'LUNG1-101', 'LUNG1-106', 'LUNG1-049', 'LUNG1-137', 'LUNG1-149', 'LUNG1-059', 'LUNG1-228', 'LUNG1-047', 'LUNG1-089', 'LUNG1-124', 'LUNG1-043', 'LUNG1-088', 'LUNG1-188', 'LUNG1-209', 'LUNG1-045', 'LUNG1-155', 'LUNG1-153', 'LUNG1-083', 'LUNG1-081', 'LUNG1-159', 'LUNG1-158']
# Val
| """ Dataset 1
# This cases have displaced or incorrect annotation files
# Some maybe be corrected using the map below
skipCase = ['LUNG1-034',
'LUNG1-040',
'LUNG1-044',
'LUNG1-068',
'LUNG1-083',
'LUNG1-084',
'LUNG1-094',
'LUNG1-096',
'LUNG1-176' ]
# corrections applied by using np.roll on the 3D mask along the y-axis(0) and x-axis(1)
# format = (dy,dx), None implies correction requires more than simple translation
corrections = {
'LUNG1-034': (165, 0),
'LUNG1-040': (190, 0),
'LUNG1-044': (166, 0),
'LUNG1-068': None,
'LUNG1-083': (293, 0),
'LUNG1-084': (314, 0),
'LUNG1-094': (328, 0),
'LUNG1-096': (318, 0),
'LUNG1-176': None
}
# Manufactuers of CT Scanners used for different cases
SIEMENS = ['LUNG1-013', 'LUNG1-098', 'LUNG1-099', 'LUNG1-094', 'LUNG1-096', 'LUNG1-097', 'LUNG1-090', 'LUNG1-092', 'LUNG1-093', 'LUNG1-065', 'LUNG1-072', 'LUNG1-073', 'LUNG1-071', 'LUNG1-077', 'LUNG1-075', 'LUNG1-079', 'LUNG1-048',
'LUNG1-051', 'LUNG1-056', 'LUNG1-102', 'LUNG1-103', 'LUNG1-100', 'LUNG1-104', 'LUNG1-105', 'LUNG1-029', 'LUNG1-032', 'LUNG1-001', 'LUNG1-004', 'LUNG1-083', 'LUNG1-082', 'LUNG1-080', 'LUNG1-086', 'LUNG1-084']
CMS = ['LUNG1-014', 'LUNG1-015', 'LUNG1-016', 'LUNG1-017', 'LUNG1-010', 'LUNG1-011', 'LUNG1-012', 'LUNG1-018', 'LUNG1-019', 'LUNG1-095', 'LUNG1-091', 'LUNG1-061', 'LUNG1-060', 'LUNG1-063', 'LUNG1-062', 'LUNG1-064', 'LUNG1-066', 'LUNG1-069', 'LUNG1-068', 'LUNG1-070', 'LUNG1-076', 'LUNG1-074', 'LUNG1-078', 'LUNG1-047', 'LUNG1-046', 'LUNG1-045', 'LUNG1-044', 'LUNG1-043', 'LUNG1-042', 'LUNG1-041', 'LUNG1-040', 'LUNG1-049', 'LUNG1-059',
'LUNG1-052', 'LUNG1-053', 'LUNG1-054', 'LUNG1-055', 'LUNG1-057', 'LUNG1-101', 'LUNG1-028', 'LUNG1-025', 'LUNG1-024', 'LUNG1-027', 'LUNG1-026', 'LUNG1-021', 'LUNG1-020', 'LUNG1-023', 'LUNG1-022', 'LUNG1-038', 'LUNG1-039', 'LUNG1-037', 'LUNG1-034', 'LUNG1-035', 'LUNG1-033', 'LUNG1-030', 'LUNG1-031', 'LUNG1-003', 'LUNG1-002', 'LUNG1-006', 'LUNG1-005', 'LUNG1-009', 'LUNG1-008', 'LUNG1-089', 'LUNG1-088', 'LUNG1-081', 'LUNG1-087', 'LUNG1-085']
"""
' Dataset 3 '
skip_case = ['LUNG1-212', 'LUNG1-043', 'LUNG1-045', 'LUNG1-139']
corrections = {'LUNG1-212': None, 'LUNG1-043': None, 'LUNG1-045': None, 'LUNG1-139': None}
siemens = ['LUNG1-278', 'LUNG1-148', 'LUNG1-237', 'LUNG1-134', 'LUNG1-258', 'LUNG1-259', 'LUNG1-256', 'LUNG1-257', 'LUNG1-255', 'LUNG1-252', 'LUNG1-253', 'LUNG1-317', 'LUNG1-147', 'LUNG1-144', 'LUNG1-145', 'LUNG1-098', 'LUNG1-099', 'LUNG1-141', 'LUNG1-095', 'LUNG1-096', 'LUNG1-097', 'LUNG1-090', 'LUNG1-091', 'LUNG1-092', 'LUNG1-318', 'LUNG1-308', 'LUNG1-309', 'LUNG1-261', 'LUNG1-260', 'LUNG1-129', 'LUNG1-263', 'LUNG1-262', 'LUNG1-178', 'LUNG1-267', 'LUNG1-266', 'LUNG1-264', 'LUNG1-173', 'LUNG1-172', 'LUNG1-171', 'LUNG1-268', 'LUNG1-177', 'LUNG1-176', 'LUNG1-307', 'LUNG1-065', 'LUNG1-069', 'LUNG1-269', 'LUNG1-289', 'LUNG1-288', 'LUNG1-170', 'LUNG1-321', 'LUNG1-281', 'LUNG1-280', 'LUNG1-283', 'LUNG1-282', 'LUNG1-285', 'LUNG1-284', 'LUNG1-287', 'LUNG1-286', 'LUNG1-306', 'LUNG1-274', 'LUNG1-275', 'LUNG1-276', 'LUNG1-277', 'LUNG1-168', 'LUNG1-272', 'LUNG1-273', 'LUNG1-164', 'LUNG1-165', 'LUNG1-166', 'LUNG1-167', 'LUNG1-160', 'LUNG1-161', 'LUNG1-162', 'LUNG1-163', 'LUNG1-072', 'LUNG1-071', 'LUNG1-077', 'LUNG1-074', 'LUNG1-075', 'LUNG1-093', 'LUNG1-079', 'LUNG1-298', 'LUNG1-299', 'LUNG1-139', 'LUNG1-183', 'LUNG1-292', 'LUNG1-293', 'LUNG1-290', 'LUNG1-291', 'LUNG1-296', 'LUNG1-297', 'LUNG1-294', 'LUNG1-295', 'LUNG1-191', 'LUNG1-190', 'LUNG1-193', 'LUNG1-192', 'LUNG1-194', 'LUNG1-197', 'LUNG1-196', 'LUNG1-199', 'LUNG1-313', 'LUNG1-205', 'LUNG1-207', 'LUNG1-111', 'LUNG1-110', 'LUNG1-113', 'LUNG1-112', 'LUNG1-115', 'LUNG1-114', 'LUNG1-117', 'LUNG1-053', 'LUNG1-300', 'LUNG1-146', 'LUNG1-180', 'LUNG1-181', 'LUNG1-315', 'LUNG1-057', 'LUNG1-212', 'LUNG1-213', 'LUNG1-108', 'LUNG1-211', 'LUNG1-216', 'LUNG1-217', 'LUNG1-214', 'LUNG1-215', 'LUNG1-102', 'LUNG1-142', 'LUNG1-100', 'LUNG1-107', 'LUNG1-104', 'LUNG1-105', 'LUNG1-311', 'LUNG1-132', 'LUNG1-310', 'LUNG1-151', 'LUNG1-131', 'LUNG1-103', 'LUNG1-218', 'LUNG1-219', 'LUNG1-227', 'LUNG1-226', 'LUNG1-225', 'LUNG1-224', 'LUNG1-223', 'LUNG1-222', 'LUNG1-221', 'LUNG1-220', 'LUNG1-136', 'LUNG1-133', 'LUNG1-229', 'LUNG1-130', 'LUNG1-304', 'LUNG1-244', 'LUNG1-143', 'LUNG1-119', 'LUNG1-118', 'LUNG1-084', 'LUNG1-231', 'LUNG1-232', 'LUNG1-233', 'LUNG1-234', 'LUNG1-235', 'LUNG1-236', 'LUNG1-305', 'LUNG1-120', 'LUNG1-121', 'LUNG1-122', 'LUNG1-123', 'LUNG1-125', 'LUNG1-126', 'LUNG1-127', 'LUNG1-109', 'LUNG1-138', 'LUNG1-239', 'LUNG1-208', 'LUNG1-270', 'LUNG1-303', 'LUNG1-271', 'LUNG1-320', 'LUNG1-080', 'LUNG1-249', 'LUNG1-248', 'LUNG1-245', 'LUNG1-247', 'LUNG1-246', 'LUNG1-241', 'LUNG1-240', 'LUNG1-243', 'LUNG1-242', 'LUNG1-154', 'LUNG1-157', 'LUNG1-156', 'LUNG1-326', 'LUNG1-150', 'LUNG1-152', 'LUNG1-082', 'LUNG1-048', 'LUNG1-085', 'LUNG1-210']
cms = ['LUNG1-140', 'LUNG1-094', 'LUNG1-179', 'LUNG1-175', 'LUNG1-061', 'LUNG1-060', 'LUNG1-063', 'LUNG1-062', 'LUNG1-064', 'LUNG1-066', 'LUNG1-068', 'LUNG1-174', 'LUNG1-169', 'LUNG1-073', 'LUNG1-070', 'LUNG1-076', 'LUNG1-078', 'LUNG1-087', 'LUNG1-195', 'LUNG1-198', 'LUNG1-086', 'LUNG1-201', 'LUNG1-046', 'LUNG1-203', 'LUNG1-044', 'LUNG1-204', 'LUNG1-206', 'LUNG1-116', 'LUNG1-055', 'LUNG1-182', 'LUNG1-186', 'LUNG1-187', 'LUNG1-184', 'LUNG1-185', 'LUNG1-051', 'LUNG1-052', 'LUNG1-189', 'LUNG1-054', 'LUNG1-056', 'LUNG1-101', 'LUNG1-106', 'LUNG1-049', 'LUNG1-137', 'LUNG1-149', 'LUNG1-059', 'LUNG1-228', 'LUNG1-047', 'LUNG1-089', 'LUNG1-124', 'LUNG1-043', 'LUNG1-088', 'LUNG1-188', 'LUNG1-209', 'LUNG1-045', 'LUNG1-155', 'LUNG1-153', 'LUNG1-083', 'LUNG1-081', 'LUNG1-159', 'LUNG1-158'] |
(5)(3)
l = [a, 21, l]
l(3)
a(20, 21, *n, b=m)
| 5(3)
l = [a, 21, l]
l(3)
a(20, 21, *n, b=m) |
ages = [5, 12, 17, 18, 24, 32]
def myFunc(x):
if x < 18:
return False
else:
return True
adults = filter(myFunc, ages)
for x in adults:
print(x) | ages = [5, 12, 17, 18, 24, 32]
def my_func(x):
if x < 18:
return False
else:
return True
adults = filter(myFunc, ages)
for x in adults:
print(x) |
def fraction(a, b):
try:
return "%.1f" % (float(a) / float(b))
except (ValueError, ZeroDivisionError):
return "ERR"
| def fraction(a, b):
try:
return '%.1f' % (float(a) / float(b))
except (ValueError, ZeroDivisionError):
return 'ERR' |
# M-1
x1 = 12
y1 = 5
z1 = x1*y1
print(z1)
# M-2
eggs = 12
unit_price = 5
total_price = eggs*unit_price
print(total_price)
# M-3
a12345 = 12
b12345 = 5
c12345 = a12345*b12345
print(c12345)
| x1 = 12
y1 = 5
z1 = x1 * y1
print(z1)
eggs = 12
unit_price = 5
total_price = eggs * unit_price
print(total_price)
a12345 = 12
b12345 = 5
c12345 = a12345 * b12345
print(c12345) |
# SAVE PATIENTS
n = int(input())
strength = list(map(int, input().split()))
patient = list(map(int, input().split()))
strength.sort()
patient.sort()
for i in range(n):
if strength[i]<patient[i]:
print("No")
break
else:
print("Yes")
| n = int(input())
strength = list(map(int, input().split()))
patient = list(map(int, input().split()))
strength.sort()
patient.sort()
for i in range(n):
if strength[i] < patient[i]:
print('No')
break
else:
print('Yes') |
# 06 Magic Methods
# https://rszalski.github.io/magicmethods/
# Magiv Methods are called automaticly by Python interpreter, depending on how we use our object and class
class Point:
point_color = "Red"
@classmethod
def zero(cls):
return cls(0, 0, 0)
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __str__(self): # This method is returning our point as a string
return f"{self.x}, {self.y}, {self.z}"
def draw(self):
print(f"Point coordinates ({self.x}, {self.y}, {self.z})")
point_1 = Point(100, 200, 10)
print(point_1) | class Point:
point_color = 'Red'
@classmethod
def zero(cls):
return cls(0, 0, 0)
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __str__(self):
return f'{self.x}, {self.y}, {self.z}'
def draw(self):
print(f'Point coordinates ({self.x}, {self.y}, {self.z})')
point_1 = point(100, 200, 10)
print(point_1) |
# Python vs. C++ Example 4
# Rachel J. Morris, 2013 - RachelJMorris@gmail.com, Moosader.com, github.com/Moosader
# MIT License
# Generally, these shouldn't be stored in separate lists; we would create
# a class to store name & age, but we will do this in a later example.
lstStudentNames = []
lstStudentAges = []
doneWithProgram = False
while ( not doneWithProgram ):
print( "\n" )
print( "What would you like to do?" )
print( "1. Add another student" )
print( "2. End" )
choice = input( "? " )
while ( int(choice) != 1 and int(choice) != 2 ):
choice = input( "Invalid choice, try again: " )
if ( int(choice) == 2 ):
doneWithProgram = True
else:
print( "Add new student:" )
name = input( "Name? " )
age = input( "Age? " )
while ( int(age) < 0 or int(age) > 120 ):
print( "Invalid age, must be between 0 and 120 years old" )
age = input( "Age?" )
# Add new student to list
lstStudentNames.append( name )
lstStudentAges.append( age )
# while ( not doneWithProgram ):
# Program over - Display students
print( "\n\nYour students:" )
for i in range( 0, len( lstStudentNames ) ):
print( lstStudentNames[i] + "\t\tAge: " + lstStudentAges[i] )
| lst_student_names = []
lst_student_ages = []
done_with_program = False
while not doneWithProgram:
print('\n')
print('What would you like to do?')
print('1. Add another student')
print('2. End')
choice = input('? ')
while int(choice) != 1 and int(choice) != 2:
choice = input('Invalid choice, try again: ')
if int(choice) == 2:
done_with_program = True
else:
print('Add new student:')
name = input('Name? ')
age = input('Age? ')
while int(age) < 0 or int(age) > 120:
print('Invalid age, must be between 0 and 120 years old')
age = input('Age?')
lstStudentNames.append(name)
lstStudentAges.append(age)
print('\n\nYour students:')
for i in range(0, len(lstStudentNames)):
print(lstStudentNames[i] + '\t\tAge: ' + lstStudentAges[i]) |
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param root, a tree node
# @return an integer
def sumNumbers(self, root):
if not root:
return 0
queue = []
values = []
self.dfs(root, queue, values)
return sum(values)
def dfs(self, root, queue, values):
queue.append(root)
if not root.left and not root.right:
val = 0
n = len(queue)
for i in range(n):
node = queue[n-i-1]
val += node.val*10**i
values.append(val)
else:
if root.left:
self.dfs(root.left, queue, values)
if root.right:
self.dfs(root.right, queue, values)
queue.pop()
| class Solution:
def sum_numbers(self, root):
if not root:
return 0
queue = []
values = []
self.dfs(root, queue, values)
return sum(values)
def dfs(self, root, queue, values):
queue.append(root)
if not root.left and (not root.right):
val = 0
n = len(queue)
for i in range(n):
node = queue[n - i - 1]
val += node.val * 10 ** i
values.append(val)
else:
if root.left:
self.dfs(root.left, queue, values)
if root.right:
self.dfs(root.right, queue, values)
queue.pop() |
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Simple test on a grid texture
command = testshade("-t 1 -groupname Beatles -layer Cake test")
command += testshade("-t 1 -g 2 2 -groupname Beatles -layer Cake test_v_name")
| command = testshade('-t 1 -groupname Beatles -layer Cake test')
command += testshade('-t 1 -g 2 2 -groupname Beatles -layer Cake test_v_name') |
table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
flag = [ord("X") for i in range(0x64)]
flag[0] = ord(table[0x1c])
flag[1] = ord(table[0x36])
flag[2] = ord(table[(0x1c + 0x36) >> 2])
flag[10] = flag[2]
flag[3] = 0x6a
flag[4] = flag[0] + 1
for p in [0xc, 0x16, 0x18]:
flag[p] = flag[4] - 1
flag[6] = flag[3] - 0x20
flag[11] = 0x2f + 1
flag[1 + 0x22] = flag[11] + 9
flag[0x17] = 1 + 0x2f
flag[8] = flag[0] - 1
flag[0x1b] = flag[4] + 2
flag[0x1f] = flag[4] + 2
flag[9] = flag[0x1b] + 7
flag[0x19] = flag[0x1b] + 7
for p in [0xd, 0x11, 0x15]:
flag[p] = flag[1] + 1
flag[7] = 0x70
flag[0xf] = flag[7] + 3
flag[0xe] = flag[0xf] + 1
flag[0x13] = 0x7a
flag[0x22] = flag[0] - 0x21
flag[0x1a] = 1 + 0x30
flag[0x10] = flag[9] - 0x20
flag[0x1c] = flag[0x10]
flag[0x12] = flag[7] - 0x1e
flag[0x1e] = flag[0x12]
flag[0x20] = flag[4]
#for p in [5, 0x14, 0x1d, 0xc4]:
# print(flag[p])
print(''.join(list(map(chr, flag))))
| table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
flag = [ord('X') for i in range(100)]
flag[0] = ord(table[28])
flag[1] = ord(table[54])
flag[2] = ord(table[28 + 54 >> 2])
flag[10] = flag[2]
flag[3] = 106
flag[4] = flag[0] + 1
for p in [12, 22, 24]:
flag[p] = flag[4] - 1
flag[6] = flag[3] - 32
flag[11] = 47 + 1
flag[1 + 34] = flag[11] + 9
flag[23] = 1 + 47
flag[8] = flag[0] - 1
flag[27] = flag[4] + 2
flag[31] = flag[4] + 2
flag[9] = flag[27] + 7
flag[25] = flag[27] + 7
for p in [13, 17, 21]:
flag[p] = flag[1] + 1
flag[7] = 112
flag[15] = flag[7] + 3
flag[14] = flag[15] + 1
flag[19] = 122
flag[34] = flag[0] - 33
flag[26] = 1 + 48
flag[16] = flag[9] - 32
flag[28] = flag[16]
flag[18] = flag[7] - 30
flag[30] = flag[18]
flag[32] = flag[4]
print(''.join(list(map(chr, flag)))) |
class Configuration:
DB = 'aiohttpdemo_polls'
USER = 'aiohttpdemo_user'
PASS = 'aiohttpdemo_pass'
HOST = 'localhost'
PORT = '5432'
| class Configuration:
db = 'aiohttpdemo_polls'
user = 'aiohttpdemo_user'
pass = 'aiohttpdemo_pass'
host = 'localhost'
port = '5432' |
class Provider(object):
base_url = None
def __init__(self, url: str) -> None:
self.base_url = url
def watch(self):
pass | class Provider(object):
base_url = None
def __init__(self, url: str) -> None:
self.base_url = url
def watch(self):
pass |
#
# PySNMP MIB module XYLAN-BASE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYLAN-BASE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:44:24 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:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, TimeTicks, Integer32, enterprises, Counter32, Counter64, NotificationType, iso, ObjectIdentity, MibIdentifier, ModuleIdentity, Unsigned32, Bits, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "TimeTicks", "Integer32", "enterprises", "Counter32", "Counter64", "NotificationType", "iso", "ObjectIdentity", "MibIdentifier", "ModuleIdentity", "Unsigned32", "Bits", "Gauge32")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
xylan = MibIdentifier((1, 3, 6, 1, 4, 1, 800))
xylanMgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 1))
xylanArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2))
xylanProduct = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3))
xylanMib = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 1, 1))
xylanChassis = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 1))
xylanVlanArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 2))
xylanVportArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 3))
xylanAtmArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 4))
xylanTrapArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 5))
xylanIpxArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 6))
xylanWsmArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 7))
xylanFrArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 8))
xylanCsmArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 9))
xylanVapArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 10))
xylanPportArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 11))
xylanFwArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 12))
xylanIpArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 13))
xylanIpmsArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 14))
xylanAVLArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 15))
xylanBackupArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 16))
xylanPppArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 17))
xylanHealthArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 18))
xylanTsmArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 19))
xylanXIPArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 20))
xylanAscCArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 21))
xylanFltArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 22))
xylanSonetArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 23))
xylanSrtbArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 24))
xylanM013Arch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 25))
xylanVsmArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 26))
xylanNtpArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 27))
xylanOamArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 28))
xylanHrexArch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 2, 31))
xylanHardware = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1))
xylanSwitchDevice = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1))
omniswitch5 = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 1))
omniswitch9 = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 2))
pizzaSwitch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 3))
microSwitch = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 4))
omnicell5 = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 5))
omnicell9 = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 6))
pizzaPort = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 7))
omniStack1024 = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 8))
omniStack6024 = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 9))
xylanSoftware = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 2))
xylanPnni = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 1))
xylanGated = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 2))
xylanMrouted = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 3))
xylanNHRP = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 4))
xylanPolicy = MibIdentifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 5))
atmForum = MibIdentifier((1, 3, 6, 1, 4, 1, 353))
atmForumNetworkManagement = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5))
atmfLanEmulation = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 3))
atmfPnni = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 4))
atmfMpoa = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 8))
mpoaMIB = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 8, 1))
mpoaMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 8, 1, 1))
mibBuilder.exportSymbols("XYLAN-BASE-MIB", xylanFltArch=xylanFltArch, xylanM013Arch=xylanM013Arch, xylanPppArch=xylanPppArch, xylanWsmArch=xylanWsmArch, xylanCsmArch=xylanCsmArch, mpoaMIB=mpoaMIB, xylanFrArch=xylanFrArch, omniStack1024=omniStack1024, pizzaPort=pizzaPort, xylanNtpArch=xylanNtpArch, xylanVapArch=xylanVapArch, xylanAscCArch=xylanAscCArch, xylanSonetArch=xylanSonetArch, xylanIpxArch=xylanIpxArch, microSwitch=microSwitch, xylanVportArch=xylanVportArch, atmfLanEmulation=atmfLanEmulation, xylanIpmsArch=xylanIpmsArch, xylanSwitchDevice=xylanSwitchDevice, atmfPnni=atmfPnni, xylanXIPArch=xylanXIPArch, xylanTsmArch=xylanTsmArch, atmForumNetworkManagement=atmForumNetworkManagement, xylanChassis=xylanChassis, xylanMrouted=xylanMrouted, omnicell5=omnicell5, mpoaMIBObjects=mpoaMIBObjects, xylanNHRP=xylanNHRP, xylan=xylan, xylanSrtbArch=xylanSrtbArch, xylanPportArch=xylanPportArch, xylanArch=xylanArch, xylanVlanArch=xylanVlanArch, xylanPolicy=xylanPolicy, omniStack6024=omniStack6024, xylanAtmArch=xylanAtmArch, xylanIpArch=xylanIpArch, atmfMpoa=atmfMpoa, xylanPnni=xylanPnni, xylanAVLArch=xylanAVLArch, xylanSoftware=xylanSoftware, xylanProduct=xylanProduct, xylanOamArch=xylanOamArch, xylanGated=xylanGated, omniswitch5=omniswitch5, atmForum=atmForum, xylanTrapArch=xylanTrapArch, xylanFwArch=xylanFwArch, xylanMib=xylanMib, omniswitch9=omniswitch9, xylanHardware=xylanHardware, pizzaSwitch=pizzaSwitch, xylanHrexArch=xylanHrexArch, xylanHealthArch=xylanHealthArch, xylanVsmArch=xylanVsmArch, omnicell9=omnicell9, xylanBackupArch=xylanBackupArch, xylanMgmt=xylanMgmt)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ConstraintsUnion', 'ValueSizeConstraint', 'SingleValueConstraint')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, time_ticks, integer32, enterprises, counter32, counter64, notification_type, iso, object_identity, mib_identifier, module_identity, unsigned32, bits, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'TimeTicks', 'Integer32', 'enterprises', 'Counter32', 'Counter64', 'NotificationType', 'iso', 'ObjectIdentity', 'MibIdentifier', 'ModuleIdentity', 'Unsigned32', 'Bits', 'Gauge32')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
xylan = mib_identifier((1, 3, 6, 1, 4, 1, 800))
xylan_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 800, 1))
xylan_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2))
xylan_product = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3))
xylan_mib = mib_identifier((1, 3, 6, 1, 4, 1, 800, 1, 1))
xylan_chassis = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 1))
xylan_vlan_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 2))
xylan_vport_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 3))
xylan_atm_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 4))
xylan_trap_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 5))
xylan_ipx_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 6))
xylan_wsm_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 7))
xylan_fr_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 8))
xylan_csm_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 9))
xylan_vap_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 10))
xylan_pport_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 11))
xylan_fw_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 12))
xylan_ip_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 13))
xylan_ipms_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 14))
xylan_avl_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 15))
xylan_backup_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 16))
xylan_ppp_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 17))
xylan_health_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 18))
xylan_tsm_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 19))
xylan_xip_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 20))
xylan_asc_c_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 21))
xylan_flt_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 22))
xylan_sonet_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 23))
xylan_srtb_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 24))
xylan_m013_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 25))
xylan_vsm_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 26))
xylan_ntp_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 27))
xylan_oam_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 28))
xylan_hrex_arch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 2, 31))
xylan_hardware = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1))
xylan_switch_device = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1))
omniswitch5 = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 1))
omniswitch9 = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 2))
pizza_switch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 3))
micro_switch = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 4))
omnicell5 = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 5))
omnicell9 = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 6))
pizza_port = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 7))
omni_stack1024 = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 8))
omni_stack6024 = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 1, 1, 9))
xylan_software = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 2))
xylan_pnni = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 1))
xylan_gated = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 2))
xylan_mrouted = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 3))
xylan_nhrp = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 4))
xylan_policy = mib_identifier((1, 3, 6, 1, 4, 1, 800, 3, 2, 5))
atm_forum = mib_identifier((1, 3, 6, 1, 4, 1, 353))
atm_forum_network_management = mib_identifier((1, 3, 6, 1, 4, 1, 353, 5))
atmf_lan_emulation = mib_identifier((1, 3, 6, 1, 4, 1, 353, 5, 3))
atmf_pnni = mib_identifier((1, 3, 6, 1, 4, 1, 353, 5, 4))
atmf_mpoa = mib_identifier((1, 3, 6, 1, 4, 1, 353, 5, 8))
mpoa_mib = mib_identifier((1, 3, 6, 1, 4, 1, 353, 5, 8, 1))
mpoa_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 353, 5, 8, 1, 1))
mibBuilder.exportSymbols('XYLAN-BASE-MIB', xylanFltArch=xylanFltArch, xylanM013Arch=xylanM013Arch, xylanPppArch=xylanPppArch, xylanWsmArch=xylanWsmArch, xylanCsmArch=xylanCsmArch, mpoaMIB=mpoaMIB, xylanFrArch=xylanFrArch, omniStack1024=omniStack1024, pizzaPort=pizzaPort, xylanNtpArch=xylanNtpArch, xylanVapArch=xylanVapArch, xylanAscCArch=xylanAscCArch, xylanSonetArch=xylanSonetArch, xylanIpxArch=xylanIpxArch, microSwitch=microSwitch, xylanVportArch=xylanVportArch, atmfLanEmulation=atmfLanEmulation, xylanIpmsArch=xylanIpmsArch, xylanSwitchDevice=xylanSwitchDevice, atmfPnni=atmfPnni, xylanXIPArch=xylanXIPArch, xylanTsmArch=xylanTsmArch, atmForumNetworkManagement=atmForumNetworkManagement, xylanChassis=xylanChassis, xylanMrouted=xylanMrouted, omnicell5=omnicell5, mpoaMIBObjects=mpoaMIBObjects, xylanNHRP=xylanNHRP, xylan=xylan, xylanSrtbArch=xylanSrtbArch, xylanPportArch=xylanPportArch, xylanArch=xylanArch, xylanVlanArch=xylanVlanArch, xylanPolicy=xylanPolicy, omniStack6024=omniStack6024, xylanAtmArch=xylanAtmArch, xylanIpArch=xylanIpArch, atmfMpoa=atmfMpoa, xylanPnni=xylanPnni, xylanAVLArch=xylanAVLArch, xylanSoftware=xylanSoftware, xylanProduct=xylanProduct, xylanOamArch=xylanOamArch, xylanGated=xylanGated, omniswitch5=omniswitch5, atmForum=atmForum, xylanTrapArch=xylanTrapArch, xylanFwArch=xylanFwArch, xylanMib=xylanMib, omniswitch9=omniswitch9, xylanHardware=xylanHardware, pizzaSwitch=pizzaSwitch, xylanHrexArch=xylanHrexArch, xylanHealthArch=xylanHealthArch, xylanVsmArch=xylanVsmArch, omnicell9=omnicell9, xylanBackupArch=xylanBackupArch, xylanMgmt=xylanMgmt) |
pares, impares, positivos, negativos = 0, 0, 0, 0
for i in range(5):
num = int(input())
if num % 2 == 0:
pares += 1
else:
impares += 1
if num > 0:
positivos += 1
elif num < 0:
negativos += 1
print('{} valor(es) par(es)'.format(pares))
print('{} valor(es) impar(es)'.format(impares))
print('{} valor(es) positivo(s)'.format(positivos))
print('{} valor(es) negativo(s)'.format(negativos))
| (pares, impares, positivos, negativos) = (0, 0, 0, 0)
for i in range(5):
num = int(input())
if num % 2 == 0:
pares += 1
else:
impares += 1
if num > 0:
positivos += 1
elif num < 0:
negativos += 1
print('{} valor(es) par(es)'.format(pares))
print('{} valor(es) impar(es)'.format(impares))
print('{} valor(es) positivo(s)'.format(positivos))
print('{} valor(es) negativo(s)'.format(negativos)) |
arquivo = open('argv.py', 'r')
for line in arquivo:
print(line.rstrip())
| arquivo = open('argv.py', 'r')
for line in arquivo:
print(line.rstrip()) |
class D(object):
pass
class E(object):
pass
class F(object):
pass
class B(E, D):
pass
class C(D, F):
pass
class A(B, C):
pass
| class D(object):
pass
class E(object):
pass
class F(object):
pass
class B(E, D):
pass
class C(D, F):
pass
class A(B, C):
pass |
def null(X):
null_list = X.isnull().sum()
return null_list
| def null(X):
null_list = X.isnull().sum()
return null_list |
def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse, obj[16]: Carryaway, obj[17]: Restaurantlessthan20, obj[18]: Restaurant20to50, obj[19]: Direction_same, obj[20]: Distance
# {"feature": "Income", "instances": 113, "metric_value": 0.9904, "depth": 1}
if obj[13]<=6:
# {"feature": "Coupon", "instances": 97, "metric_value": 0.9999, "depth": 2}
if obj[5]>0:
# {"feature": "Distance", "instances": 81, "metric_value": 0.9911, "depth": 3}
if obj[20]<=2:
# {"feature": "Coffeehouse", "instances": 74, "metric_value": 0.974, "depth": 4}
if obj[15]<=2.0:
# {"feature": "Maritalstatus", "instances": 58, "metric_value": 0.9966, "depth": 5}
if obj[9]<=2:
# {"feature": "Passanger", "instances": 54, "metric_value": 1.0, "depth": 6}
if obj[1]>0:
# {"feature": "Bar", "instances": 51, "metric_value": 0.9975, "depth": 7}
if obj[14]>-1.0:
# {"feature": "Children", "instances": 49, "metric_value": 0.9925, "depth": 8}
if obj[10]<=0:
# {"feature": "Restaurant20to50", "instances": 32, "metric_value": 0.9972, "depth": 9}
if obj[18]>0.0:
# {"feature": "Age", "instances": 24, "metric_value": 0.9544, "depth": 10}
if obj[8]<=4:
# {"feature": "Gender", "instances": 20, "metric_value": 0.9928, "depth": 11}
if obj[7]<=0:
# {"feature": "Occupation", "instances": 11, "metric_value": 0.9457, "depth": 12}
if obj[12]>5:
# {"feature": "Driving_to", "instances": 6, "metric_value": 0.9183, "depth": 13}
if obj[0]<=1:
# {"feature": "Coupon_validity", "instances": 5, "metric_value": 0.7219, "depth": 14}
if obj[6]<=0:
return 'True'
elif obj[6]>0:
# {"feature": "Temperature", "instances": 2, "metric_value": 1.0, "depth": 15}
if obj[3]<=55:
return 'False'
elif obj[3]>55:
return 'True'
else: return 'True'
else: return 'False'
elif obj[0]>1:
return 'False'
else: return 'False'
elif obj[12]<=5:
return 'False'
else: return 'False'
elif obj[7]>0:
# {"feature": "Direction_same", "instances": 9, "metric_value": 0.7642, "depth": 12}
if obj[19]<=0:
return 'True'
elif obj[19]>0:
return 'False'
else: return 'False'
else: return 'True'
elif obj[8]>4:
return 'True'
else: return 'True'
elif obj[18]<=0.0:
# {"feature": "Occupation", "instances": 8, "metric_value": 0.8113, "depth": 10}
if obj[12]<=2:
# {"feature": "Temperature", "instances": 4, "metric_value": 1.0, "depth": 11}
if obj[3]>55:
# {"feature": "Time", "instances": 3, "metric_value": 0.9183, "depth": 12}
if obj[4]<=0:
# {"feature": "Coupon_validity", "instances": 2, "metric_value": 1.0, "depth": 13}
if obj[6]<=0:
return 'False'
elif obj[6]>0:
return 'True'
else: return 'True'
elif obj[4]>0:
return 'False'
else: return 'False'
elif obj[3]<=55:
return 'True'
else: return 'True'
elif obj[12]>2:
return 'False'
else: return 'False'
else: return 'False'
elif obj[10]>0:
# {"feature": "Driving_to", "instances": 17, "metric_value": 0.874, "depth": 9}
if obj[0]<=0:
# {"feature": "Coupon_validity", "instances": 12, "metric_value": 0.9799, "depth": 10}
if obj[6]>0:
# {"feature": "Occupation", "instances": 10, "metric_value": 0.8813, "depth": 11}
if obj[12]<=9:
return 'False'
elif obj[12]>9:
# {"feature": "Age", "instances": 5, "metric_value": 0.971, "depth": 12}
if obj[8]<=2:
# {"feature": "Temperature", "instances": 3, "metric_value": 0.9183, "depth": 13}
if obj[3]>55:
# {"feature": "Gender", "instances": 2, "metric_value": 1.0, "depth": 14}
if obj[7]>0:
return 'True'
elif obj[7]<=0:
return 'False'
else: return 'False'
elif obj[3]<=55:
return 'False'
else: return 'False'
elif obj[8]>2:
return 'True'
else: return 'True'
else: return 'True'
elif obj[6]<=0:
return 'True'
else: return 'True'
elif obj[0]>0:
return 'False'
else: return 'False'
else: return 'False'
elif obj[14]<=-1.0:
return 'True'
else: return 'True'
elif obj[1]<=0:
return 'True'
else: return 'True'
elif obj[9]>2:
return 'True'
else: return 'True'
elif obj[15]>2.0:
# {"feature": "Gender", "instances": 16, "metric_value": 0.6962, "depth": 5}
if obj[7]<=0:
return 'True'
elif obj[7]>0:
# {"feature": "Time", "instances": 6, "metric_value": 1.0, "depth": 6}
if obj[4]<=2:
return 'True'
elif obj[4]>2:
return 'False'
else: return 'False'
else: return 'True'
else: return 'True'
elif obj[20]>2:
# {"feature": "Age", "instances": 7, "metric_value": 0.5917, "depth": 4}
if obj[8]>0:
return 'False'
elif obj[8]<=0:
return 'True'
else: return 'True'
else: return 'False'
elif obj[5]<=0:
# {"feature": "Bar", "instances": 16, "metric_value": 0.8113, "depth": 3}
if obj[14]<=0.0:
return 'False'
elif obj[14]>0.0:
# {"feature": "Weather", "instances": 8, "metric_value": 1.0, "depth": 4}
if obj[2]<=0:
# {"feature": "Age", "instances": 5, "metric_value": 0.7219, "depth": 5}
if obj[8]<=4:
return 'False'
elif obj[8]>4:
return 'True'
else: return 'True'
elif obj[2]>0:
return 'True'
else: return 'True'
else: return 'True'
else: return 'False'
elif obj[13]>6:
# {"feature": "Children", "instances": 16, "metric_value": 0.5436, "depth": 2}
if obj[10]<=0:
return 'True'
elif obj[10]>0:
# {"feature": "Weather", "instances": 4, "metric_value": 1.0, "depth": 3}
if obj[2]>0:
return 'False'
elif obj[2]<=0:
return 'True'
else: return 'True'
else: return 'False'
else: return 'True'
| def find_decision(obj):
if obj[13] <= 6:
if obj[5] > 0:
if obj[20] <= 2:
if obj[15] <= 2.0:
if obj[9] <= 2:
if obj[1] > 0:
if obj[14] > -1.0:
if obj[10] <= 0:
if obj[18] > 0.0:
if obj[8] <= 4:
if obj[7] <= 0:
if obj[12] > 5:
if obj[0] <= 1:
if obj[6] <= 0:
return 'True'
elif obj[6] > 0:
if obj[3] <= 55:
return 'False'
elif obj[3] > 55:
return 'True'
else:
return 'True'
else:
return 'False'
elif obj[0] > 1:
return 'False'
else:
return 'False'
elif obj[12] <= 5:
return 'False'
else:
return 'False'
elif obj[7] > 0:
if obj[19] <= 0:
return 'True'
elif obj[19] > 0:
return 'False'
else:
return 'False'
else:
return 'True'
elif obj[8] > 4:
return 'True'
else:
return 'True'
elif obj[18] <= 0.0:
if obj[12] <= 2:
if obj[3] > 55:
if obj[4] <= 0:
if obj[6] <= 0:
return 'False'
elif obj[6] > 0:
return 'True'
else:
return 'True'
elif obj[4] > 0:
return 'False'
else:
return 'False'
elif obj[3] <= 55:
return 'True'
else:
return 'True'
elif obj[12] > 2:
return 'False'
else:
return 'False'
else:
return 'False'
elif obj[10] > 0:
if obj[0] <= 0:
if obj[6] > 0:
if obj[12] <= 9:
return 'False'
elif obj[12] > 9:
if obj[8] <= 2:
if obj[3] > 55:
if obj[7] > 0:
return 'True'
elif obj[7] <= 0:
return 'False'
else:
return 'False'
elif obj[3] <= 55:
return 'False'
else:
return 'False'
elif obj[8] > 2:
return 'True'
else:
return 'True'
else:
return 'True'
elif obj[6] <= 0:
return 'True'
else:
return 'True'
elif obj[0] > 0:
return 'False'
else:
return 'False'
else:
return 'False'
elif obj[14] <= -1.0:
return 'True'
else:
return 'True'
elif obj[1] <= 0:
return 'True'
else:
return 'True'
elif obj[9] > 2:
return 'True'
else:
return 'True'
elif obj[15] > 2.0:
if obj[7] <= 0:
return 'True'
elif obj[7] > 0:
if obj[4] <= 2:
return 'True'
elif obj[4] > 2:
return 'False'
else:
return 'False'
else:
return 'True'
else:
return 'True'
elif obj[20] > 2:
if obj[8] > 0:
return 'False'
elif obj[8] <= 0:
return 'True'
else:
return 'True'
else:
return 'False'
elif obj[5] <= 0:
if obj[14] <= 0.0:
return 'False'
elif obj[14] > 0.0:
if obj[2] <= 0:
if obj[8] <= 4:
return 'False'
elif obj[8] > 4:
return 'True'
else:
return 'True'
elif obj[2] > 0:
return 'True'
else:
return 'True'
else:
return 'True'
else:
return 'False'
elif obj[13] > 6:
if obj[10] <= 0:
return 'True'
elif obj[10] > 0:
if obj[2] > 0:
return 'False'
elif obj[2] <= 0:
return 'True'
else:
return 'True'
else:
return 'False'
else:
return 'True' |
class Question(object):
def __init__(self, id, title, text):
self._id = id
self._title = title
self._text = text
self._answers = []
self._chosen_answer = None
@property
def id(self):
return self._id
@id.setter
def id(self, id):
self._id = id
@property
def title(self):
return self._title
@title.setter
def title(self, title):
self._title = title
@property
def text(self):
return self._text
@text.setter
def text(self, text):
self._text = text
@property
def answers(self):
return self._answers
@answers.setter
def answers(self, answers):
self._answers = answers
@property
def chosen_answer(self):
return self._chosen_answer
@chosen_answer.setter
def chosen_answer(self, chosen_answer):
self._chosen_answer = chosen_answer
| class Question(object):
def __init__(self, id, title, text):
self._id = id
self._title = title
self._text = text
self._answers = []
self._chosen_answer = None
@property
def id(self):
return self._id
@id.setter
def id(self, id):
self._id = id
@property
def title(self):
return self._title
@title.setter
def title(self, title):
self._title = title
@property
def text(self):
return self._text
@text.setter
def text(self, text):
self._text = text
@property
def answers(self):
return self._answers
@answers.setter
def answers(self, answers):
self._answers = answers
@property
def chosen_answer(self):
return self._chosen_answer
@chosen_answer.setter
def chosen_answer(self, chosen_answer):
self._chosen_answer = chosen_answer |
# -*- coding: utf-8 -*-
name = 'usdview'
version = '18.11'
requires = [
'pyside-1.2',
'usd-18.11'
]
def commands():
env.DEFAULT_USD.set('{root}/bin/DefaultUSD.usda')
| name = 'usdview'
version = '18.11'
requires = ['pyside-1.2', 'usd-18.11']
def commands():
env.DEFAULT_USD.set('{root}/bin/DefaultUSD.usda') |
# 7. Write a program that asks the user to enter a word and determines whether the word is a
# palindrome or not. A palindrome is a word that reads the same backwards as forwards.
s = input('Enter a string: ')
new_string = s[::-1] # a negative step reverses the string
if s == new_string:
print('It is a palindrome.')
else:
print('It is not a palindrome.')
| s = input('Enter a string: ')
new_string = s[::-1]
if s == new_string:
print('It is a palindrome.')
else:
print('It is not a palindrome.') |
moveSet1 = 'R1009,D117,L888,D799,L611,U766,L832,U859,L892,D79,R645,U191,L681,D787,R447,D429,L988,U536,L486,D832,R221,D619,R268,D545,L706,U234,L528,D453,R493,D24,L688,U658,L74,D281,R910,D849,L5,U16,R935,D399,L417,U609,R22,D782,L432,D83,L357,D982,L902,U294,L338,U102,R342,D621,R106,U979,L238,U158,R930,D948,L700,D808,R445,U897,R980,U227,L466,D416,R244,U396,R576,U157,R548,U795,R709,U550,R137,U212,L977,U786,L423,D792,R391,D974,R390,U771,R270,D409,L917,D9,R412,D699,L170,D276,L912,U710,R814,U656,R4,D800,R596,U970,L194,U315,L845,D490,L303,U514,L675,D737,L880,D86,L253,D525,R861,D5,R424,D113,L764,D900,R485,D421,R125,U684,R53,U96,L871,U260,R456,U378,L448,D450,L903,D482,R750,U961,R264,D501,R605,D367,R550,U642,R228,U164,L343,U868,R595,D318,R452,U845,L571,D281,R49,D889,L481,U963,R182,U358,R454,U267,L790,D252,R455,D188,L73,U256,L835,D816,R503,U895,L259,U418,R642,U818,L187,U355,R772,U466,R21,U91,R707,D349,L200,U305,R931,D982,L334,D416,L247,D935,L326,U449,L398,D914,R602,U10,R762,D944,L639,D141,L457,U579,L198,U527,R750,U167,R816,D753,R850,D281,L712,D583,L172,D254,L544,D456,R966,U839,R673,D479,R730,D912,R992,D969,R766,U205,R477,D719,R172,D735,R998,D687,R698,D407,R172,U945,R199,U348,L256,D876,R580,U770,L483,D437,R353,D214,R619,U541,R234,D962,R842,U639,R520,D354,L279,D15,R42,U138,L321,D376,L628,D893,L670,D574,L339,U298,L321,D120,L370,U408,L333,D353,L263,D79,R535,D487,R113,D638,R623,D59,L508,D866,R315,U166,L534,U927,L401,D626,L19,D994,L778,D317,L936,U207,L768,U948,R452,U165,R864,D283,L874'
moveSet2 = 'L995,D93,L293,U447,L793,D605,R497,D155,L542,D570,R113,D779,L510,U367,L71,D980,R237,U290,L983,U49,R745,U182,L922,D174,L189,D629,R315,D203,R533,U72,L981,D848,L616,U654,R445,D864,R526,D668,L678,U378,L740,D840,L202,D429,R136,D998,L116,D554,L893,U759,R617,U942,R999,U582,L220,U447,R895,D13,R217,U743,L865,U950,R91,D381,R662,D518,L798,D637,L213,D93,L231,D185,R704,U581,L268,U773,R405,U862,R796,U73,L891,U553,L952,U450,R778,D868,R329,D669,L182,U378,L933,D83,R574,U807,R785,D278,R139,D362,R8,U546,R651,U241,L462,D309,L261,D307,L85,U701,L913,U271,R814,U723,L777,D256,R417,U814,L461,U652,R198,D747,R914,U520,R806,U956,L771,D229,R984,U685,R663,D812,R650,U214,R839,U574,L10,U66,R644,D371,L917,D819,L73,D236,R277,U611,R390,U723,L129,D496,L552,D451,R584,U105,L805,U165,R179,D372,L405,D702,R14,U332,L893,D419,R342,D146,R907,D672,L316,U257,L903,U919,L942,U771,R879,U624,L280,U150,L320,U220,R590,D242,R744,U291,R562,U418,L898,U66,L564,U495,R837,D555,L739,D780,R409,D122,L426,D857,R937,D600,R428,D592,R727,U917,R256,D680,L422,U630,L14,U240,R617,D664,L961,D554,L302,U925,L376,D187,L700,D31,L762,U397,L554,D217,R679,D683,R680,D572,R54,D164,L940,D523,R140,U52,L506,D638,R331,D415,R389,D884,R410,D62,R691,U665,R889,U864,L663,D690,R487,U811,L190,U780,L758,U267,R155,D344,L133,D137,R93,D229,L729,U878,L889,D603,R288,U890,R251,U531,L249,D995,R863,D257,R655,D311,R874,U356,L833,U151,L741,U246,R694,D899,L48,U915,L900,U757,L861,U402,R971,U537,R460,D844,R54,U956,L151,U74,R892,U248,R677,D881,R99,D931,R427'
def move_calculator(move_string: str):
move_set = move_string.split(",")
x_pos = 0
y_pos = 0
move_list = []
for move in move_set:
for step in range(0, int(move[1:])):
if move[0] == 'U':
y_pos += 1
elif move[0] == 'D':
y_pos -= 1
elif move[0] == 'L':
x_pos -= 1
elif move[0] == 'R':
x_pos += 1
move_list.append([x_pos, y_pos])
return move_list
def x_reference(move_list1: list, move_list2: list):
intersections = []
for move in move_list2:
if move in move_list1:
intersections.append(move)
return intersections
move_output1 = move_calculator(moveSet1)
move_output2 = move_calculator(moveSet1)
intersections = x_reference(move_output1, move_output2)
lowest_distance = 10000000000000000000000000000000000000000000000000000
for intersect in intersections:
final_x = 0
final_y = 0
if intersect[0] < 0:
final_x = intersect[0] * -1
else:
final_x = intersect[0]
if intersect[1] < 0:
final_y = intersect[1] * -1
else:
final_y = intersect[1]
if (final_x + final_y) < lowest_distance:
lowest_distance = final_x + final_y
print(lowest_distance)
| move_set1 = 'R1009,D117,L888,D799,L611,U766,L832,U859,L892,D79,R645,U191,L681,D787,R447,D429,L988,U536,L486,D832,R221,D619,R268,D545,L706,U234,L528,D453,R493,D24,L688,U658,L74,D281,R910,D849,L5,U16,R935,D399,L417,U609,R22,D782,L432,D83,L357,D982,L902,U294,L338,U102,R342,D621,R106,U979,L238,U158,R930,D948,L700,D808,R445,U897,R980,U227,L466,D416,R244,U396,R576,U157,R548,U795,R709,U550,R137,U212,L977,U786,L423,D792,R391,D974,R390,U771,R270,D409,L917,D9,R412,D699,L170,D276,L912,U710,R814,U656,R4,D800,R596,U970,L194,U315,L845,D490,L303,U514,L675,D737,L880,D86,L253,D525,R861,D5,R424,D113,L764,D900,R485,D421,R125,U684,R53,U96,L871,U260,R456,U378,L448,D450,L903,D482,R750,U961,R264,D501,R605,D367,R550,U642,R228,U164,L343,U868,R595,D318,R452,U845,L571,D281,R49,D889,L481,U963,R182,U358,R454,U267,L790,D252,R455,D188,L73,U256,L835,D816,R503,U895,L259,U418,R642,U818,L187,U355,R772,U466,R21,U91,R707,D349,L200,U305,R931,D982,L334,D416,L247,D935,L326,U449,L398,D914,R602,U10,R762,D944,L639,D141,L457,U579,L198,U527,R750,U167,R816,D753,R850,D281,L712,D583,L172,D254,L544,D456,R966,U839,R673,D479,R730,D912,R992,D969,R766,U205,R477,D719,R172,D735,R998,D687,R698,D407,R172,U945,R199,U348,L256,D876,R580,U770,L483,D437,R353,D214,R619,U541,R234,D962,R842,U639,R520,D354,L279,D15,R42,U138,L321,D376,L628,D893,L670,D574,L339,U298,L321,D120,L370,U408,L333,D353,L263,D79,R535,D487,R113,D638,R623,D59,L508,D866,R315,U166,L534,U927,L401,D626,L19,D994,L778,D317,L936,U207,L768,U948,R452,U165,R864,D283,L874'
move_set2 = 'L995,D93,L293,U447,L793,D605,R497,D155,L542,D570,R113,D779,L510,U367,L71,D980,R237,U290,L983,U49,R745,U182,L922,D174,L189,D629,R315,D203,R533,U72,L981,D848,L616,U654,R445,D864,R526,D668,L678,U378,L740,D840,L202,D429,R136,D998,L116,D554,L893,U759,R617,U942,R999,U582,L220,U447,R895,D13,R217,U743,L865,U950,R91,D381,R662,D518,L798,D637,L213,D93,L231,D185,R704,U581,L268,U773,R405,U862,R796,U73,L891,U553,L952,U450,R778,D868,R329,D669,L182,U378,L933,D83,R574,U807,R785,D278,R139,D362,R8,U546,R651,U241,L462,D309,L261,D307,L85,U701,L913,U271,R814,U723,L777,D256,R417,U814,L461,U652,R198,D747,R914,U520,R806,U956,L771,D229,R984,U685,R663,D812,R650,U214,R839,U574,L10,U66,R644,D371,L917,D819,L73,D236,R277,U611,R390,U723,L129,D496,L552,D451,R584,U105,L805,U165,R179,D372,L405,D702,R14,U332,L893,D419,R342,D146,R907,D672,L316,U257,L903,U919,L942,U771,R879,U624,L280,U150,L320,U220,R590,D242,R744,U291,R562,U418,L898,U66,L564,U495,R837,D555,L739,D780,R409,D122,L426,D857,R937,D600,R428,D592,R727,U917,R256,D680,L422,U630,L14,U240,R617,D664,L961,D554,L302,U925,L376,D187,L700,D31,L762,U397,L554,D217,R679,D683,R680,D572,R54,D164,L940,D523,R140,U52,L506,D638,R331,D415,R389,D884,R410,D62,R691,U665,R889,U864,L663,D690,R487,U811,L190,U780,L758,U267,R155,D344,L133,D137,R93,D229,L729,U878,L889,D603,R288,U890,R251,U531,L249,D995,R863,D257,R655,D311,R874,U356,L833,U151,L741,U246,R694,D899,L48,U915,L900,U757,L861,U402,R971,U537,R460,D844,R54,U956,L151,U74,R892,U248,R677,D881,R99,D931,R427'
def move_calculator(move_string: str):
move_set = move_string.split(',')
x_pos = 0
y_pos = 0
move_list = []
for move in move_set:
for step in range(0, int(move[1:])):
if move[0] == 'U':
y_pos += 1
elif move[0] == 'D':
y_pos -= 1
elif move[0] == 'L':
x_pos -= 1
elif move[0] == 'R':
x_pos += 1
move_list.append([x_pos, y_pos])
return move_list
def x_reference(move_list1: list, move_list2: list):
intersections = []
for move in move_list2:
if move in move_list1:
intersections.append(move)
return intersections
move_output1 = move_calculator(moveSet1)
move_output2 = move_calculator(moveSet1)
intersections = x_reference(move_output1, move_output2)
lowest_distance = 10000000000000000000000000000000000000000000000000000
for intersect in intersections:
final_x = 0
final_y = 0
if intersect[0] < 0:
final_x = intersect[0] * -1
else:
final_x = intersect[0]
if intersect[1] < 0:
final_y = intersect[1] * -1
else:
final_y = intersect[1]
if final_x + final_y < lowest_distance:
lowest_distance = final_x + final_y
print(lowest_distance) |
##
##
##
def exec(conexao):
cursor = conexao.cursor()
print("RULE 16 - Inicializando",end=' ')
update = " UPDATE principal SET "
update = update + " r25 = \"50\", "
update = update + " r31 = \"50\" "
update = update + " WHERE 1=1 "
update = update + " AND r1 = \"C170\" "
update = update + " AND r3 = \"99999999\" "
cursor.execute(update)
conexao.commit()
print('-',end=' ')
print("Finalizado") | def exec(conexao):
cursor = conexao.cursor()
print('RULE 16 - Inicializando', end=' ')
update = ' UPDATE principal SET '
update = update + ' r25 = "50", '
update = update + ' r31 = "50" '
update = update + ' WHERE 1=1 '
update = update + ' AND r1 = "C170" '
update = update + ' AND r3 = "99999999" '
cursor.execute(update)
conexao.commit()
print('-', end=' ')
print('Finalizado') |
#!/usr/bin/env python
# Import modules
# Read settings file
settings_file = open('./odin_fix_settings.txt')
input_file = settings_file.readline().rstrip()
output_file = settings_file.readline().rstrip()
parsed_file = open(output_file,'w')
parsed_file.write('Date\tTime\tDust\tRH\tTemp\tBatt\n')
with open(input_file,'r') as datafile:
for line in datafile:
has_headers = (line[0]=="D")
if has_headers: continue
c_vec = line.split('\t')
if len(c_vec)!=6: continue
parsed_file.write(line.rstrip() + '\n')
parsed_file.close()
datafile.close() | settings_file = open('./odin_fix_settings.txt')
input_file = settings_file.readline().rstrip()
output_file = settings_file.readline().rstrip()
parsed_file = open(output_file, 'w')
parsed_file.write('Date\tTime\tDust\tRH\tTemp\tBatt\n')
with open(input_file, 'r') as datafile:
for line in datafile:
has_headers = line[0] == 'D'
if has_headers:
continue
c_vec = line.split('\t')
if len(c_vec) != 6:
continue
parsed_file.write(line.rstrip() + '\n')
parsed_file.close()
datafile.close() |
t = int(input())
for ___ in range(t):
length = int(input())
a = [int(k) for k in input().split(' ')]
max_boost = 0
summm = 0
for k in range(length):
if k%2 == 0:
summm += a[k]
for l in range(length-1):
if l%2 == 0:
vygoda = 0
sum_nech, sum_ch = 0, 0+a[l]
for r in range(l+1, length):
if r%2 == 1:
sum_nech += a[r]
vygoda = sum_nech - sum_ch
if vygoda > max_boost:
max_boost = vygoda
else:
sum_ch += a[r]
else:
vygoda = 0
sum_nech, sum_ch = 0+a[l], 0
for r in range(l+1, length):
if r%2 == 0:
sum_ch += a[r]
vygoda = sum_nech - sum_ch
if vygoda > max_boost:
max_boost = vygoda
else:
sum_nech += a[r]
print(summm + max_boost) | t = int(input())
for ___ in range(t):
length = int(input())
a = [int(k) for k in input().split(' ')]
max_boost = 0
summm = 0
for k in range(length):
if k % 2 == 0:
summm += a[k]
for l in range(length - 1):
if l % 2 == 0:
vygoda = 0
(sum_nech, sum_ch) = (0, 0 + a[l])
for r in range(l + 1, length):
if r % 2 == 1:
sum_nech += a[r]
vygoda = sum_nech - sum_ch
if vygoda > max_boost:
max_boost = vygoda
else:
sum_ch += a[r]
else:
vygoda = 0
(sum_nech, sum_ch) = (0 + a[l], 0)
for r in range(l + 1, length):
if r % 2 == 0:
sum_ch += a[r]
vygoda = sum_nech - sum_ch
if vygoda > max_boost:
max_boost = vygoda
else:
sum_nech += a[r]
print(summm + max_boost) |
class Solution:
def __init__(self) :
self.store = {
0 : [],
1 : ["()"]
}
def AllParenthesis(self,n):
if n in self.store :
return self.store[n]
ans = set()
for i in range(n) :
if i == 0 :
for comb in self.AllParenthesis(n-1) :
ans.add('(' + comb + ')')
else :
for comb1 in self.AllParenthesis(i) :
for comb2 in self.AllParenthesis(n-i) :
ans.add(comb1 + comb2)
ans.add(comb2 + comb1)
ans = list(ans)
ans.sort()
self.store[n] = ans
return ans
if __name__=="__main__":
t=int(input())
for i in range(0,t):
n=int(input())
ob=Solution()
result=ob.AllParenthesis(n)
result.sort()
for i in range(0,len(result)):
print(result[i])
| class Solution:
def __init__(self):
self.store = {0: [], 1: ['()']}
def all_parenthesis(self, n):
if n in self.store:
return self.store[n]
ans = set()
for i in range(n):
if i == 0:
for comb in self.AllParenthesis(n - 1):
ans.add('(' + comb + ')')
else:
for comb1 in self.AllParenthesis(i):
for comb2 in self.AllParenthesis(n - i):
ans.add(comb1 + comb2)
ans.add(comb2 + comb1)
ans = list(ans)
ans.sort()
self.store[n] = ans
return ans
if __name__ == '__main__':
t = int(input())
for i in range(0, t):
n = int(input())
ob = solution()
result = ob.AllParenthesis(n)
result.sort()
for i in range(0, len(result)):
print(result[i]) |
def translate(value, leftMin, leftMax, rightMin, rightMax):
leftSpan = leftMax - leftMin
rightSpan = rightMax - rightMin
valueScaled = float(value - leftMin) / float(leftSpan)
result = rightMin + (valueScaled * rightSpan)
return result
def reversed_iterator(iter):
return reversed(list(iter))
| def translate(value, leftMin, leftMax, rightMin, rightMax):
left_span = leftMax - leftMin
right_span = rightMax - rightMin
value_scaled = float(value - leftMin) / float(leftSpan)
result = rightMin + valueScaled * rightSpan
return result
def reversed_iterator(iter):
return reversed(list(iter)) |
t = int(input())
def find_max_level(n: int):
sums = [1]
i = 1
while max(sums) < n:
sums.append(2 * sums[i - 1] + 1)
i += 1
return i
def create_binomial_matrix(level: int):
mat = [[1 if j == i or j == 0 else 0 for j in range(0,level)] for i in range(0,level)]
for i in range(0,len(mat)):
for j in range(0, len(mat[i])):
if j < i and j != 0:
mat[i][j] = mat[i-1][j-1] + mat[i-1][j]
return mat
for _ in range(1, t + 1):
n = int(input())
level = find_max_level(n)
triangle = create_binomial_matrix(level)
positions = [(1,1)]
| t = int(input())
def find_max_level(n: int):
sums = [1]
i = 1
while max(sums) < n:
sums.append(2 * sums[i - 1] + 1)
i += 1
return i
def create_binomial_matrix(level: int):
mat = [[1 if j == i or j == 0 else 0 for j in range(0, level)] for i in range(0, level)]
for i in range(0, len(mat)):
for j in range(0, len(mat[i])):
if j < i and j != 0:
mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j]
return mat
for _ in range(1, t + 1):
n = int(input())
level = find_max_level(n)
triangle = create_binomial_matrix(level)
positions = [(1, 1)] |
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Check with 'pylint' command to code rating.
'''
A very simple script.
'''
def func():
'''
A simple function
'''
first = 1
second = 2
print(first)
print(second)
func()
| """
A very simple script.
"""
def func():
"""
A simple function
"""
first = 1
second = 2
print(first)
print(second)
func() |
_CLASH_ERR = "Cannot have more than one '{}' stanza (Clashing files: {})"
_VALID_ERR = "The data in the '{}' stanza from '{}' failed validation rules."
class MetaloaderError(RuntimeError):
pass
class ExclusiveStanzaClashError(MetaloaderError):
def __init__(self, key, clashing_files):
error_message = _CLASH_ERR.format(key, clashing_files)
super().__init__(error_message)
class StanzaValidationError(MetaloaderError):
def __init__(self, key, filename):
error_message = _VALID_ERR.format(key, filename)
super().__init__(error_message)
| _clash_err = "Cannot have more than one '{}' stanza (Clashing files: {})"
_valid_err = "The data in the '{}' stanza from '{}' failed validation rules."
class Metaloadererror(RuntimeError):
pass
class Exclusivestanzaclasherror(MetaloaderError):
def __init__(self, key, clashing_files):
error_message = _CLASH_ERR.format(key, clashing_files)
super().__init__(error_message)
class Stanzavalidationerror(MetaloaderError):
def __init__(self, key, filename):
error_message = _VALID_ERR.format(key, filename)
super().__init__(error_message) |
class Solution:
def defangIPaddr(self, address: str) -> str:
# replace
return address.replace('.', '[.]')
# def defangIPaddr(self, address: str) -> str:
# # split and join
# return '[.]'.join(address.split('.'))
# def defangIPaddr(self, address: str) -> str:
# # replace
# return re.sub('\.', '[.]', address)
# def defangIPaddr(self, address: str) -> str:
# return ''.join('[.]' if c == '.' else c for c in address)
| class Solution:
def defang_i_paddr(self, address: str) -> str:
return address.replace('.', '[.]') |
def somadig(n):
if n == 0:
return 0
else:
return (n % 10) + somadig(n // 10)
print(somadig(120))
#https://pt.stackoverflow.com/q/349093/101
| def somadig(n):
if n == 0:
return 0
else:
return n % 10 + somadig(n // 10)
print(somadig(120)) |
class Node:
def __init__(self, data):
self.data = data
self.next_node = None
class LinkedList:
def __init__(self):
self.head = None
self.size = 0
def insert_at_start(self, data):
new_node = Node(data)
self.size += 1
if not self.head:
self.head = new_node
else:
new_node.next_node = self.head
self.head = new_node
def insert_at_end(self, data):
new_node = Node(data)
self.size += 1
actual_node = self.head
while actual_node.next_node is not None:
actual_node = actual_node.next_node
actual_node.next_node = new_node
def traverse(self):
actual_node = self.head
while actual_node is not None:
print(actual_node.data, end=' ')
actual_node = actual_node.next_node
def remove(self, data):
if self.head is None:
return
actual_node = self.head
previous_node = None
while actual_node.data != data:
if not actual_node.next_node:
print(f'Value {data} not found.')
return
previous_node = actual_node
actual_node = actual_node.next_node
self.size -= 1
if previous_node:
previous_node.next_node = actual_node.next_node
else:
self.head = actual_node.next_node
def size_of(self):
return self.size
linked_list = LinkedList()
print(linked_list.size_of() == 0)
linked_list.insert_at_start(10)
linked_list.insert_at_start(13)
linked_list.insert_at_end(15)
linked_list.insert_at_end(27)
print(linked_list.head.data == 13)
print(linked_list.size_of() == 4)
linked_list.remove(100)
print(linked_list.size_of() == 4)
linked_list.remove(10)
print(linked_list.head.data == 13)
print(linked_list.size_of() == 3)
linked_list.remove(13)
print(linked_list.head.data == 15)
print(linked_list.size_of() == 2)
linked_list.remove(27)
print(linked_list.head.data == 15)
print(linked_list.size_of() == 1)
linked_list.remove(15)
print(linked_list.head is None)
print(linked_list.size_of() == 0)
| class Node:
def __init__(self, data):
self.data = data
self.next_node = None
class Linkedlist:
def __init__(self):
self.head = None
self.size = 0
def insert_at_start(self, data):
new_node = node(data)
self.size += 1
if not self.head:
self.head = new_node
else:
new_node.next_node = self.head
self.head = new_node
def insert_at_end(self, data):
new_node = node(data)
self.size += 1
actual_node = self.head
while actual_node.next_node is not None:
actual_node = actual_node.next_node
actual_node.next_node = new_node
def traverse(self):
actual_node = self.head
while actual_node is not None:
print(actual_node.data, end=' ')
actual_node = actual_node.next_node
def remove(self, data):
if self.head is None:
return
actual_node = self.head
previous_node = None
while actual_node.data != data:
if not actual_node.next_node:
print(f'Value {data} not found.')
return
previous_node = actual_node
actual_node = actual_node.next_node
self.size -= 1
if previous_node:
previous_node.next_node = actual_node.next_node
else:
self.head = actual_node.next_node
def size_of(self):
return self.size
linked_list = linked_list()
print(linked_list.size_of() == 0)
linked_list.insert_at_start(10)
linked_list.insert_at_start(13)
linked_list.insert_at_end(15)
linked_list.insert_at_end(27)
print(linked_list.head.data == 13)
print(linked_list.size_of() == 4)
linked_list.remove(100)
print(linked_list.size_of() == 4)
linked_list.remove(10)
print(linked_list.head.data == 13)
print(linked_list.size_of() == 3)
linked_list.remove(13)
print(linked_list.head.data == 15)
print(linked_list.size_of() == 2)
linked_list.remove(27)
print(linked_list.head.data == 15)
print(linked_list.size_of() == 1)
linked_list.remove(15)
print(linked_list.head is None)
print(linked_list.size_of() == 0) |
# jmespath/_lrtable.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\xb4\x1bXD\x01\x03z\xbb\x19\xfc\rk\xd7x\x00\xa3'
_lr_action_items = {'STAR':([0,2,11,23,26,28,29,32,36,39,44,45,46,47,48,49,50,55,63,],[1,14,1,1,51,1,57,1,1,1,-16,-17,1,-18,-19,-14,-15,1,1,]),'LPAREN':([10,],[23,]),'NUMBER':([2,26,],[15,15,]),'LBRACKET':([0,1,2,3,4,5,7,8,9,10,11,12,13,14,17,18,23,25,27,28,29,30,31,32,33,35,36,37,39,42,43,44,45,46,47,48,49,50,52,53,54,55,56,57,58,59,61,62,63,64,65,],[2,-3,2,-34,-23,-33,-8,-22,-24,-21,2,-20,26,-3,-11,26,2,26,-7,2,55,-9,-10,2,-26,-25,2,-36,2,26,-12,-16,-17,2,-18,-19,-14,-15,26,-1,-2,2,-6,-5,-4,26,26,-35,2,26,26,]),'DOT':([1,3,4,5,7,8,9,10,12,13,14,17,18,25,27,30,31,33,35,37,42,43,52,53,54,56,57,58,59,61,62,64,65,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,29,-3,-11,29,29,-7,-9,-10,-26,-25,-36,29,-12,29,-1,-2,-6,-5,-4,29,29,-35,29,29,]),'RBRACE':([1,3,4,5,7,8,9,10,12,17,20,22,27,30,31,33,35,37,43,52,53,54,56,57,58,60,61,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,35,-28,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-27,-29,-35,]),'RPAREN':([1,3,4,5,7,8,9,10,12,17,23,27,30,31,33,35,37,38,40,41,42,43,52,53,54,56,57,58,62,64,66,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,37,-7,-9,-10,-26,-25,-36,62,-40,-38,-39,-12,-32,-1,-2,-6,-5,-4,-35,-41,-37,]),'NE':([1,3,4,5,7,8,9,10,12,17,25,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,48,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'LT':([1,3,4,5,7,8,9,10,12,17,25,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,49,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'COLON':([8,19,21,],[-22,-21,36,]),'COMMA':([1,3,4,5,7,8,9,10,12,14,16,17,18,20,22,27,30,31,33,35,37,38,40,41,42,43,52,53,54,56,57,58,59,60,61,62,64,66,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-3,32,-11,-31,34,-28,-7,-9,-10,-26,-25,-36,63,-40,-38,-39,-12,-32,-1,-2,-6,-5,-4,-30,-27,-29,-35,-41,-37,]),'$end':([1,3,4,5,7,8,9,10,12,13,17,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,0,-11,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'GT':([1,3,4,5,7,8,9,10,12,17,25,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,44,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'GTE':([1,3,4,5,7,8,9,10,12,17,25,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,45,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'EXPREF':([23,63,],[39,39,]),'CURRENT':([23,63,],[40,40,]),'LITERAL':([0,2,11,23,28,32,36,39,44,45,46,47,48,49,50,55,63,],[5,5,5,5,5,5,5,5,-16,-17,5,-18,-19,-14,-15,5,5,]),'LBRACE':([0,2,11,23,28,29,32,36,39,44,45,46,47,48,49,50,55,63,],[6,6,6,6,6,6,6,6,6,-16,-17,6,-18,-19,-14,-15,6,6,]),'LTE':([1,3,4,5,7,8,9,10,12,17,25,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,50,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'EQ':([1,3,4,5,7,8,9,10,12,17,25,27,30,31,33,35,37,43,52,53,54,56,57,58,62,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,-11,47,-7,-9,-10,-26,-25,-36,-12,-32,-1,-2,-6,-5,-4,-35,]),'QUOTED_IDENTIFIER':([0,2,6,11,23,28,29,32,34,36,39,44,45,46,47,48,49,50,55,63,],[8,8,8,8,8,8,8,8,8,8,8,-16,-17,8,-18,-19,-14,-15,8,8,]),'UNQUOTED_IDENTIFIER':([0,2,6,11,23,28,29,32,34,36,39,44,45,46,47,48,49,50,55,63,],[10,10,19,10,10,10,10,10,19,10,10,-16,-17,10,-18,-19,-14,-15,10,10,]),'FILTER':([0,1,2,3,4,5,7,8,9,10,11,12,13,14,17,18,23,25,27,28,30,31,32,33,35,36,37,39,42,43,44,45,46,47,48,49,50,52,53,54,55,56,57,58,59,61,62,63,64,65,],[11,-3,11,-34,-23,-33,-8,-22,-24,-21,11,-20,11,-3,-11,11,11,11,-7,11,-9,-10,11,-26,-25,11,-36,11,11,-12,-16,-17,11,-18,-19,-14,-15,-32,-1,-2,11,-6,-5,-4,11,11,-35,11,11,11,]),'RBRACKET':([1,2,3,4,5,7,8,9,10,12,14,15,16,17,18,24,26,27,30,31,33,35,37,43,51,52,53,54,56,57,58,59,62,65,],[-3,17,-34,-23,-33,-8,-22,-24,-21,-20,30,31,33,-11,-31,43,17,-7,-9,-10,-26,-25,-36,-12,30,-32,-1,-2,-6,-5,-4,-30,-35,-13,]),'OR':([1,3,4,5,7,8,9,10,12,13,14,17,18,25,27,30,31,33,35,37,42,43,52,53,54,56,57,58,59,61,62,64,65,],[-3,-34,-23,-33,-8,-22,-24,-21,-20,28,-3,-11,28,28,-7,-9,-10,-26,-25,-36,28,-12,-32,-1,-2,-6,-5,-4,28,28,-35,28,28,]),}
_lr_action = { }
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = { }
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'filter-expression':([11,],[24,]),'function-args':([23,],[38,]),'multi-select-list':([0,2,11,23,28,29,32,36,39,46,55,63,],[9,9,9,9,9,53,9,9,9,9,9,9,]),'comparator':([25,],[46,]),'multi-select-hash':([0,2,11,23,28,29,32,36,39,46,55,63,],[4,4,4,4,4,54,4,4,4,4,4,4,]),'keyval-expr':([6,34,],[22,60,]),'bracket-spec':([0,2,11,13,18,23,25,28,32,36,39,42,46,52,55,59,61,63,64,65,],[7,7,7,27,27,7,27,7,7,7,7,27,7,27,7,27,27,7,27,27,]),'function-arg':([23,63,],[41,66,]),'function-expression':([0,2,11,23,28,29,32,36,39,46,55,63,],[3,3,3,3,3,56,3,3,3,3,3,3,]),'expressions':([2,55,],[16,16,]),'identifier':([0,2,6,11,23,28,29,32,34,36,39,46,55,63,],[12,12,21,12,12,12,58,12,21,12,12,12,12,12,]),'expression':([0,2,11,23,28,32,36,39,46,55,63,],[13,18,25,42,52,59,61,64,65,18,42,]),'keyval-exprs':([6,],[20,]),}
_lr_goto = { }
for _k, _v in _lr_goto_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_goto: _lr_goto[_x] = { }
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> expression","S'",1,None,None,None),
('expression -> expression DOT multi-select-list','expression',3,'p_jmespath_subexpression','jmespath/parser.py',84),
('expression -> expression DOT multi-select-hash','expression',3,'p_jmespath_subexpression','jmespath/parser.py',85),
('expression -> STAR','expression',1,'p_jmespath_subexpression','jmespath/parser.py',86),
('expression -> expression DOT identifier','expression',3,'p_jmespath_subexpression_identifier','jmespath/parser.py',96),
('expression -> expression DOT STAR','expression',3,'p_jmespath_subexpression_wildcard','jmespath/parser.py',101),
('expression -> expression DOT function-expression','expression',3,'p_jmespath_subexpression_function','jmespath/parser.py',106),
('expression -> expression bracket-spec','expression',2,'p_jmespath_index','jmespath/parser.py',111),
('expression -> bracket-spec','expression',1,'p_jmespath_index','jmespath/parser.py',112),
('bracket-spec -> LBRACKET STAR RBRACKET','bracket-spec',3,'p_jmespath_bracket_specifier','jmespath/parser.py',123),
('bracket-spec -> LBRACKET NUMBER RBRACKET','bracket-spec',3,'p_jmespath_bracket_specifier','jmespath/parser.py',124),
('bracket-spec -> LBRACKET RBRACKET','bracket-spec',2,'p_jmespath_bracket_specifier','jmespath/parser.py',125),
('bracket-spec -> FILTER filter-expression RBRACKET','bracket-spec',3,'p_jmespath_bracket_specifier_filter','jmespath/parser.py',135),
('filter-expression -> expression comparator expression','filter-expression',3,'p_jmespath_filter_expression','jmespath/parser.py',140),
('comparator -> LT','comparator',1,'p_jmespath_comparator','jmespath/parser.py',148),
('comparator -> LTE','comparator',1,'p_jmespath_comparator','jmespath/parser.py',149),
('comparator -> GT','comparator',1,'p_jmespath_comparator','jmespath/parser.py',150),
('comparator -> GTE','comparator',1,'p_jmespath_comparator','jmespath/parser.py',151),
('comparator -> EQ','comparator',1,'p_jmespath_comparator','jmespath/parser.py',152),
('comparator -> NE','comparator',1,'p_jmespath_comparator','jmespath/parser.py',153),
('expression -> identifier','expression',1,'p_jmespath_identifier_expr','jmespath/parser.py',166),
('identifier -> UNQUOTED_IDENTIFIER','identifier',1,'p_jmespath_identifier','jmespath/parser.py',170),
('identifier -> QUOTED_IDENTIFIER','identifier',1,'p_jmespath_identifier','jmespath/parser.py',171),
('expression -> multi-select-hash','expression',1,'p_jmespath_multiselect_expressions','jmespath/parser.py',176),
('expression -> multi-select-list','expression',1,'p_jmespath_multiselect_expressions','jmespath/parser.py',177),
('multi-select-hash -> LBRACE keyval-exprs RBRACE','multi-select-hash',3,'p_jmespath_multiselect','jmespath/parser.py',182),
('multi-select-list -> LBRACKET expressions RBRACKET','multi-select-list',3,'p_jmespath_multiselect_list','jmespath/parser.py',187),
('keyval-exprs -> keyval-exprs COMMA keyval-expr','keyval-exprs',3,'p_jmespath_keyval_exprs','jmespath/parser.py',192),
('keyval-exprs -> keyval-expr','keyval-exprs',1,'p_jmespath_keyval_exprs','jmespath/parser.py',193),
('keyval-expr -> identifier COLON expression','keyval-expr',3,'p_jmespath_keyval_expr','jmespath/parser.py',202),
('expressions -> expressions COMMA expression','expressions',3,'p_jmespath_multiple_expressions','jmespath/parser.py',207),
('expressions -> expression','expressions',1,'p_jmespath_multiple_expressions','jmespath/parser.py',208),
('expression -> expression OR expression','expression',3,'p_jmespath_or_expression','jmespath/parser.py',217),
('expression -> LITERAL','expression',1,'p_jmespath_literal_expression','jmespath/parser.py',221),
('expression -> function-expression','expression',1,'p_jmespath_function','jmespath/parser.py',225),
('function-expression -> UNQUOTED_IDENTIFIER LPAREN function-args RPAREN','function-expression',4,'p_jmespath_function_expression','jmespath/parser.py',229),
('function-expression -> UNQUOTED_IDENTIFIER LPAREN RPAREN','function-expression',3,'p_jmespath_function_expression','jmespath/parser.py',230),
('function-args -> function-args COMMA function-arg','function-args',3,'p_jmespath_function_args','jmespath/parser.py',245),
('function-args -> function-arg','function-args',1,'p_jmespath_function_args','jmespath/parser.py',246),
('function-arg -> expression','function-arg',1,'p_jmespath_function_arg','jmespath/parser.py',255),
('function-arg -> CURRENT','function-arg',1,'p_jmespath_function_arg','jmespath/parser.py',256),
('function-arg -> EXPREF expression','function-arg',2,'p_jmespath_function_arg','jmespath/parser.py',257),
]
| _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '´\x1bXD\x01\x03z»\x19ü\rk×x\x00£'
_lr_action_items = {'STAR': ([0, 2, 11, 23, 26, 28, 29, 32, 36, 39, 44, 45, 46, 47, 48, 49, 50, 55, 63], [1, 14, 1, 1, 51, 1, 57, 1, 1, 1, -16, -17, 1, -18, -19, -14, -15, 1, 1]), 'LPAREN': ([10], [23]), 'NUMBER': ([2, 26], [15, 15]), 'LBRACKET': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 23, 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65], [2, -3, 2, -34, -23, -33, -8, -22, -24, -21, 2, -20, 26, -3, -11, 26, 2, 26, -7, 2, 55, -9, -10, 2, -26, -25, 2, -36, 2, 26, -12, -16, -17, 2, -18, -19, -14, -15, 26, -1, -2, 2, -6, -5, -4, 26, 26, -35, 2, 26, 26]), 'DOT': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 17, 18, 25, 27, 30, 31, 33, 35, 37, 42, 43, 52, 53, 54, 56, 57, 58, 59, 61, 62, 64, 65], [-3, -34, -23, -33, -8, -22, -24, -21, -20, 29, -3, -11, 29, 29, -7, -9, -10, -26, -25, -36, 29, -12, 29, -1, -2, -6, -5, -4, 29, 29, -35, 29, 29]), 'RBRACE': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 20, 22, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 60, 61, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 35, -28, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -27, -29, -35]), 'RPAREN': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 23, 27, 30, 31, 33, 35, 37, 38, 40, 41, 42, 43, 52, 53, 54, 56, 57, 58, 62, 64, 66], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 37, -7, -9, -10, -26, -25, -36, 62, -40, -38, -39, -12, -32, -1, -2, -6, -5, -4, -35, -41, -37]), 'NE': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 25, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 48, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'LT': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 25, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 49, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'COLON': ([8, 19, 21], [-22, -21, 36]), 'COMMA': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 14, 16, 17, 18, 20, 22, 27, 30, 31, 33, 35, 37, 38, 40, 41, 42, 43, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 64, 66], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -3, 32, -11, -31, 34, -28, -7, -9, -10, -26, -25, -36, 63, -40, -38, -39, -12, -32, -1, -2, -6, -5, -4, -30, -27, -29, -35, -41, -37]), '$end': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 17, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, 0, -11, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'GT': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 25, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 44, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'GTE': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 25, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 45, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'EXPREF': ([23, 63], [39, 39]), 'CURRENT': ([23, 63], [40, 40]), 'LITERAL': ([0, 2, 11, 23, 28, 32, 36, 39, 44, 45, 46, 47, 48, 49, 50, 55, 63], [5, 5, 5, 5, 5, 5, 5, 5, -16, -17, 5, -18, -19, -14, -15, 5, 5]), 'LBRACE': ([0, 2, 11, 23, 28, 29, 32, 36, 39, 44, 45, 46, 47, 48, 49, 50, 55, 63], [6, 6, 6, 6, 6, 6, 6, 6, 6, -16, -17, 6, -18, -19, -14, -15, 6, 6]), 'LTE': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 25, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 50, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'EQ': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 17, 25, 27, 30, 31, 33, 35, 37, 43, 52, 53, 54, 56, 57, 58, 62], [-3, -34, -23, -33, -8, -22, -24, -21, -20, -11, 47, -7, -9, -10, -26, -25, -36, -12, -32, -1, -2, -6, -5, -4, -35]), 'QUOTED_IDENTIFIER': ([0, 2, 6, 11, 23, 28, 29, 32, 34, 36, 39, 44, 45, 46, 47, 48, 49, 50, 55, 63], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, -16, -17, 8, -18, -19, -14, -15, 8, 8]), 'UNQUOTED_IDENTIFIER': ([0, 2, 6, 11, 23, 28, 29, 32, 34, 36, 39, 44, 45, 46, 47, 48, 49, 50, 55, 63], [10, 10, 19, 10, 10, 10, 10, 10, 19, 10, 10, -16, -17, 10, -18, -19, -14, -15, 10, 10]), 'FILTER': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 23, 25, 27, 28, 30, 31, 32, 33, 35, 36, 37, 39, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65], [11, -3, 11, -34, -23, -33, -8, -22, -24, -21, 11, -20, 11, -3, -11, 11, 11, 11, -7, 11, -9, -10, 11, -26, -25, 11, -36, 11, 11, -12, -16, -17, 11, -18, -19, -14, -15, -32, -1, -2, 11, -6, -5, -4, 11, 11, -35, 11, 11, 11]), 'RBRACKET': ([1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 14, 15, 16, 17, 18, 24, 26, 27, 30, 31, 33, 35, 37, 43, 51, 52, 53, 54, 56, 57, 58, 59, 62, 65], [-3, 17, -34, -23, -33, -8, -22, -24, -21, -20, 30, 31, 33, -11, -31, 43, 17, -7, -9, -10, -26, -25, -36, -12, 30, -32, -1, -2, -6, -5, -4, -30, -35, -13]), 'OR': ([1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 17, 18, 25, 27, 30, 31, 33, 35, 37, 42, 43, 52, 53, 54, 56, 57, 58, 59, 61, 62, 64, 65], [-3, -34, -23, -33, -8, -22, -24, -21, -20, 28, -3, -11, 28, 28, -7, -9, -10, -26, -25, -36, 28, -12, -32, -1, -2, -6, -5, -4, 28, 28, -35, 28, 28])}
_lr_action = {}
for (_k, _v) in _lr_action_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_action:
_lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'filter-expression': ([11], [24]), 'function-args': ([23], [38]), 'multi-select-list': ([0, 2, 11, 23, 28, 29, 32, 36, 39, 46, 55, 63], [9, 9, 9, 9, 9, 53, 9, 9, 9, 9, 9, 9]), 'comparator': ([25], [46]), 'multi-select-hash': ([0, 2, 11, 23, 28, 29, 32, 36, 39, 46, 55, 63], [4, 4, 4, 4, 4, 54, 4, 4, 4, 4, 4, 4]), 'keyval-expr': ([6, 34], [22, 60]), 'bracket-spec': ([0, 2, 11, 13, 18, 23, 25, 28, 32, 36, 39, 42, 46, 52, 55, 59, 61, 63, 64, 65], [7, 7, 7, 27, 27, 7, 27, 7, 7, 7, 7, 27, 7, 27, 7, 27, 27, 7, 27, 27]), 'function-arg': ([23, 63], [41, 66]), 'function-expression': ([0, 2, 11, 23, 28, 29, 32, 36, 39, 46, 55, 63], [3, 3, 3, 3, 3, 56, 3, 3, 3, 3, 3, 3]), 'expressions': ([2, 55], [16, 16]), 'identifier': ([0, 2, 6, 11, 23, 28, 29, 32, 34, 36, 39, 46, 55, 63], [12, 12, 21, 12, 12, 12, 58, 12, 21, 12, 12, 12, 12, 12]), 'expression': ([0, 2, 11, 23, 28, 32, 36, 39, 46, 55, 63], [13, 18, 25, 42, 52, 59, 61, 64, 65, 18, 42]), 'keyval-exprs': ([6], [20])}
_lr_goto = {}
for (_k, _v) in _lr_goto_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_goto:
_lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [("S' -> expression", "S'", 1, None, None, None), ('expression -> expression DOT multi-select-list', 'expression', 3, 'p_jmespath_subexpression', 'jmespath/parser.py', 84), ('expression -> expression DOT multi-select-hash', 'expression', 3, 'p_jmespath_subexpression', 'jmespath/parser.py', 85), ('expression -> STAR', 'expression', 1, 'p_jmespath_subexpression', 'jmespath/parser.py', 86), ('expression -> expression DOT identifier', 'expression', 3, 'p_jmespath_subexpression_identifier', 'jmespath/parser.py', 96), ('expression -> expression DOT STAR', 'expression', 3, 'p_jmespath_subexpression_wildcard', 'jmespath/parser.py', 101), ('expression -> expression DOT function-expression', 'expression', 3, 'p_jmespath_subexpression_function', 'jmespath/parser.py', 106), ('expression -> expression bracket-spec', 'expression', 2, 'p_jmespath_index', 'jmespath/parser.py', 111), ('expression -> bracket-spec', 'expression', 1, 'p_jmespath_index', 'jmespath/parser.py', 112), ('bracket-spec -> LBRACKET STAR RBRACKET', 'bracket-spec', 3, 'p_jmespath_bracket_specifier', 'jmespath/parser.py', 123), ('bracket-spec -> LBRACKET NUMBER RBRACKET', 'bracket-spec', 3, 'p_jmespath_bracket_specifier', 'jmespath/parser.py', 124), ('bracket-spec -> LBRACKET RBRACKET', 'bracket-spec', 2, 'p_jmespath_bracket_specifier', 'jmespath/parser.py', 125), ('bracket-spec -> FILTER filter-expression RBRACKET', 'bracket-spec', 3, 'p_jmespath_bracket_specifier_filter', 'jmespath/parser.py', 135), ('filter-expression -> expression comparator expression', 'filter-expression', 3, 'p_jmespath_filter_expression', 'jmespath/parser.py', 140), ('comparator -> LT', 'comparator', 1, 'p_jmespath_comparator', 'jmespath/parser.py', 148), ('comparator -> LTE', 'comparator', 1, 'p_jmespath_comparator', 'jmespath/parser.py', 149), ('comparator -> GT', 'comparator', 1, 'p_jmespath_comparator', 'jmespath/parser.py', 150), ('comparator -> GTE', 'comparator', 1, 'p_jmespath_comparator', 'jmespath/parser.py', 151), ('comparator -> EQ', 'comparator', 1, 'p_jmespath_comparator', 'jmespath/parser.py', 152), ('comparator -> NE', 'comparator', 1, 'p_jmespath_comparator', 'jmespath/parser.py', 153), ('expression -> identifier', 'expression', 1, 'p_jmespath_identifier_expr', 'jmespath/parser.py', 166), ('identifier -> UNQUOTED_IDENTIFIER', 'identifier', 1, 'p_jmespath_identifier', 'jmespath/parser.py', 170), ('identifier -> QUOTED_IDENTIFIER', 'identifier', 1, 'p_jmespath_identifier', 'jmespath/parser.py', 171), ('expression -> multi-select-hash', 'expression', 1, 'p_jmespath_multiselect_expressions', 'jmespath/parser.py', 176), ('expression -> multi-select-list', 'expression', 1, 'p_jmespath_multiselect_expressions', 'jmespath/parser.py', 177), ('multi-select-hash -> LBRACE keyval-exprs RBRACE', 'multi-select-hash', 3, 'p_jmespath_multiselect', 'jmespath/parser.py', 182), ('multi-select-list -> LBRACKET expressions RBRACKET', 'multi-select-list', 3, 'p_jmespath_multiselect_list', 'jmespath/parser.py', 187), ('keyval-exprs -> keyval-exprs COMMA keyval-expr', 'keyval-exprs', 3, 'p_jmespath_keyval_exprs', 'jmespath/parser.py', 192), ('keyval-exprs -> keyval-expr', 'keyval-exprs', 1, 'p_jmespath_keyval_exprs', 'jmespath/parser.py', 193), ('keyval-expr -> identifier COLON expression', 'keyval-expr', 3, 'p_jmespath_keyval_expr', 'jmespath/parser.py', 202), ('expressions -> expressions COMMA expression', 'expressions', 3, 'p_jmespath_multiple_expressions', 'jmespath/parser.py', 207), ('expressions -> expression', 'expressions', 1, 'p_jmespath_multiple_expressions', 'jmespath/parser.py', 208), ('expression -> expression OR expression', 'expression', 3, 'p_jmespath_or_expression', 'jmespath/parser.py', 217), ('expression -> LITERAL', 'expression', 1, 'p_jmespath_literal_expression', 'jmespath/parser.py', 221), ('expression -> function-expression', 'expression', 1, 'p_jmespath_function', 'jmespath/parser.py', 225), ('function-expression -> UNQUOTED_IDENTIFIER LPAREN function-args RPAREN', 'function-expression', 4, 'p_jmespath_function_expression', 'jmespath/parser.py', 229), ('function-expression -> UNQUOTED_IDENTIFIER LPAREN RPAREN', 'function-expression', 3, 'p_jmespath_function_expression', 'jmespath/parser.py', 230), ('function-args -> function-args COMMA function-arg', 'function-args', 3, 'p_jmespath_function_args', 'jmespath/parser.py', 245), ('function-args -> function-arg', 'function-args', 1, 'p_jmespath_function_args', 'jmespath/parser.py', 246), ('function-arg -> expression', 'function-arg', 1, 'p_jmespath_function_arg', 'jmespath/parser.py', 255), ('function-arg -> CURRENT', 'function-arg', 1, 'p_jmespath_function_arg', 'jmespath/parser.py', 256), ('function-arg -> EXPREF expression', 'function-arg', 2, 'p_jmespath_function_arg', 'jmespath/parser.py', 257)] |
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
load("@python3//:defs.bzl", "interpreter")
def _bitstreams_repo_impl(rctx):
rctx.execute(
[
rctx.path(rctx.attr.python_interpreter),
rctx.attr._cache_manager,
"--build-file=BUILD.bazel",
"--bucket-url={}".format(rctx.attr.bucket_url),
"--cache={}".format(rctx.attr.cache),
"--refresh-time={}".format(rctx.attr.refresh_time),
],
quiet = False,
)
# The bitstream repo is evaluated on every invocation of bazel.
# Once the cache is initialized, a typical invocation will find the latest
# cached bitstream and configure it for use as a test artifact.
#
# The `refresh_time` sets the interval at which the cache manager will
# check for new bitstreams.
#
# By default, the cache manager will configure the latest available bitstream
# as the default bitstream. It will refresh every 18 hours.
#
# The behavior of the cache manager can be constrolled via the BITSTREAM
# environment variable. The environment variable can be any command line
# arguments accepted by the cache manager script.
#
# For example, to force a refresh of the cache:
# BITSTREAM=--refresh bazel build @bitstreams//...
#
# To use an exact bitstream in a test:
# BITSTREAM=3732655dbd225b5c1ae94a79b54cc9dc8cd8e391 bazel test <label>
#
# You can use any valid git commit identifier to select a bitstream:
# BITSTREAM=HEAD~1 bazel test <label>
#
# If you ask for a bitstream that does not exist in the GCP bucket, the
# next oldest bitstream will be chosen.
bitstreams_repo = repository_rule(
implementation = _bitstreams_repo_impl,
attrs = {
"bucket_url": attr.string(
doc = "Location of the GCP bitstream bucket.",
default = "https://storage.googleapis.com/opentitan-bitstreams/",
),
"cache": attr.string(
doc = "Location of bitstreams cache.",
default = "~/.cache/opentitan-bitstreams",
),
"refresh_time": attr.int(
doc = "How often to check for new bitstreams (seconds).",
default = 18 * 3600, # Refresh every 18h
),
"python_interpreter": attr.label(
default = interpreter,
allow_single_file = True,
doc = "Python interpreter to use.",
),
"_cache_manager": attr.label(
default = Label("//rules/scripts:bitstreams_workspace.py"),
allow_files = True,
),
},
environ = ["BITSTREAM"],
local = True,
)
| load('@python3//:defs.bzl', 'interpreter')
def _bitstreams_repo_impl(rctx):
rctx.execute([rctx.path(rctx.attr.python_interpreter), rctx.attr._cache_manager, '--build-file=BUILD.bazel', '--bucket-url={}'.format(rctx.attr.bucket_url), '--cache={}'.format(rctx.attr.cache), '--refresh-time={}'.format(rctx.attr.refresh_time)], quiet=False)
bitstreams_repo = repository_rule(implementation=_bitstreams_repo_impl, attrs={'bucket_url': attr.string(doc='Location of the GCP bitstream bucket.', default='https://storage.googleapis.com/opentitan-bitstreams/'), 'cache': attr.string(doc='Location of bitstreams cache.', default='~/.cache/opentitan-bitstreams'), 'refresh_time': attr.int(doc='How often to check for new bitstreams (seconds).', default=18 * 3600), 'python_interpreter': attr.label(default=interpreter, allow_single_file=True, doc='Python interpreter to use.'), '_cache_manager': attr.label(default=label('//rules/scripts:bitstreams_workspace.py'), allow_files=True)}, environ=['BITSTREAM'], local=True) |
# Reading data from file
f = open("student.txt", mode="r")
data1 = f.read(2)
data2 = f.read(2)
print(data1)
print(data2)
f.close()
print("complete!!!") | f = open('student.txt', mode='r')
data1 = f.read(2)
data2 = f.read(2)
print(data1)
print(data2)
f.close()
print('complete!!!') |
class Solution(object):
def removeDuplicates(self, nums):
ht = {}
insert = 0
for num in nums:
if num in ht:
ht[num] += 1
else:
ht[num] = 1
if ht[num] > 2:
continue
else:
nums[insert] = num
insert += 1
return insert
| class Solution(object):
def remove_duplicates(self, nums):
ht = {}
insert = 0
for num in nums:
if num in ht:
ht[num] += 1
else:
ht[num] = 1
if ht[num] > 2:
continue
else:
nums[insert] = num
insert += 1
return insert |
def module2_1():
a = 2**0.5
print('%.6f' % (a))
def module2_2():
top = 10
bottom = 20
height = 8
area = (top+bottom)*height/2
print('Area of a Trapezoid:%.1f' % area)
def module2_3():
prime_number = [1]
for i in range(2,1001):
prime_flag = True
for prime in prime_number:
if prime != 1:
if i%prime == 0:
prime_flag = False
if prime_flag == True:
prime_number.append(i)
print(prime_number) | def module2_1():
a = 2 ** 0.5
print('%.6f' % a)
def module2_2():
top = 10
bottom = 20
height = 8
area = (top + bottom) * height / 2
print('Area of a Trapezoid:%.1f' % area)
def module2_3():
prime_number = [1]
for i in range(2, 1001):
prime_flag = True
for prime in prime_number:
if prime != 1:
if i % prime == 0:
prime_flag = False
if prime_flag == True:
prime_number.append(i)
print(prime_number) |
# list of file paths to ignore when decrypting
# any files that start with these names will not be dumped
nodecrypt = [
"data\\BehaviourCreator",
"data\\DirectXRedist",
"data\\RecommendedBuilds",
"data\\ReplayEncoder",
"data\\Replays",
"data\\Rofl",
"data\\Shaders",
"data\\Sound\\Music",
"data\\VCRedist",
"data\\Video",
"data\\AwesomenautsIcon.bmp",
] | nodecrypt = ['data\\BehaviourCreator', 'data\\DirectXRedist', 'data\\RecommendedBuilds', 'data\\ReplayEncoder', 'data\\Replays', 'data\\Rofl', 'data\\Shaders', 'data\\Sound\\Music', 'data\\VCRedist', 'data\\Video', 'data\\AwesomenautsIcon.bmp'] |
def feet2inches(feet):
return feet * 12
def inches2feet(inches):
feet = inches / 12.0
remainder_inches = feet % 12.0
return feet, remainder_inches
def inches2meters(inches):
return inches * 39.37007874
def meters2inches(meters):
return meters / 0.0254
def meters2feet(meters):
inches = meters2inches(meters)
feet, remainder_inches = inches2feet(inches)
return feet, remainder_inches
| def feet2inches(feet):
return feet * 12
def inches2feet(inches):
feet = inches / 12.0
remainder_inches = feet % 12.0
return (feet, remainder_inches)
def inches2meters(inches):
return inches * 39.37007874
def meters2inches(meters):
return meters / 0.0254
def meters2feet(meters):
inches = meters2inches(meters)
(feet, remainder_inches) = inches2feet(inches)
return (feet, remainder_inches) |
#file --pair--
# Jakub Grobelny
# 2018
class pair:
def __init__(self, first, second):
self.first = first
self.second = second
def get(self, which):
if which == 0:
return self.first
elif which == 1:
return self.second
else:
raise Exception("Pair access violation!") | class Pair:
def __init__(self, first, second):
self.first = first
self.second = second
def get(self, which):
if which == 0:
return self.first
elif which == 1:
return self.second
else:
raise exception('Pair access violation!') |
# WAP to show the use of for loop
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities: #city is the iteration variable, cities is the iterable being looped over
print(city)
print("Done!")
| cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities:
print(city)
print('Done!') |
nombre = None
edad = None
apellido = None
def nombre_completo():
return nombre + ' ' + apellido
def cumplir_anios():
global edad
edad += 1
| nombre = None
edad = None
apellido = None
def nombre_completo():
return nombre + ' ' + apellido
def cumplir_anios():
global edad
edad += 1 |
class Solution:
def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:
n = len(grid)
row_high = [0]*n
col_high = [0]*n
for i in range(n):
row_high[i] = max(grid[i])
col_high[i] = 0
for j in range(n):
col_high[i] = max(col_high[i], grid[j][i])
increase = 0
for i in range(n):
for j in range(n):
increase += min(row_high[i], col_high[j]) - grid[i][j]
return increase
| class Solution:
def max_increase_keeping_skyline(self, grid: List[List[int]]) -> int:
n = len(grid)
row_high = [0] * n
col_high = [0] * n
for i in range(n):
row_high[i] = max(grid[i])
col_high[i] = 0
for j in range(n):
col_high[i] = max(col_high[i], grid[j][i])
increase = 0
for i in range(n):
for j in range(n):
increase += min(row_high[i], col_high[j]) - grid[i][j]
return increase |
def obfuscated_id(x):
y = x
z = y
return z
a = 42
b = obfuscated_id(a)
| def obfuscated_id(x):
y = x
z = y
return z
a = 42
b = obfuscated_id(a) |
# noinspection PyUnusedLocal
# friend_name = unicode string
def hello(friend_name):
'''
:param Int1: Integer between 0 and 100 inclusive
:param Int2: Integer between 0 and 100 inclusive
:return: Sum of Int1 and Int2
>>> hello ('Bob') --> 'Hello Bob'
>>> sumR1 ('Alice') --> 'Hello Alice'
'''
msg ='Hello, '
screamer ='!'
return msg+friend_name+screamer
'''raise NotImplementedError()'''
| def hello(friend_name):
"""
:param Int1: Integer between 0 and 100 inclusive
:param Int2: Integer between 0 and 100 inclusive
:return: Sum of Int1 and Int2
>>> hello ('Bob') --> 'Hello Bob'
>>> sumR1 ('Alice') --> 'Hello Alice'
"""
msg = 'Hello, '
screamer = '!'
return msg + friend_name + screamer
'raise NotImplementedError()' |
# const
N_INPUTS = 2
N_OUTPUTS = 1
# supported values: 1000, 2000, 4000, 8000, 16000
BATCH_SIZE = 1000
# variables
N_LAYERS = 3
MAX_ITER = 1000
SEED = 41
N_UNITS = []
for i in range(N_LAYERS):
N_UNITS.append(16)
| n_inputs = 2
n_outputs = 1
batch_size = 1000
n_layers = 3
max_iter = 1000
seed = 41
n_units = []
for i in range(N_LAYERS):
N_UNITS.append(16) |
# Irupe Canet
# Check if one number divides another
p = 8
m = 2
if (p % m) == 0:
print(p, "divided by", m, "leaves a reminder of zero.")
print("I'll run too if the condition is True.")
else:
print(p, "divided by", m, "does not leaves a reminder of zero.")
print("I'll run no matter what.")
| p = 8
m = 2
if p % m == 0:
print(p, 'divided by', m, 'leaves a reminder of zero.')
print("I'll run too if the condition is True.")
else:
print(p, 'divided by', m, 'does not leaves a reminder of zero.')
print("I'll run no matter what.") |
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
secrets = {
'ssid' : 'home_network',
'password' : 'ssid_password',
'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
'github_token' : 'fawfj23rakjnfawiefa',
'hackaday_token' : 'h4xx0rs3kret',
}
| secrets = {'ssid': 'home_network', 'password': 'ssid_password', 'timezone': 'America/New_York', 'github_token': 'fawfj23rakjnfawiefa', 'hackaday_token': 'h4xx0rs3kret'} |
width = int(input())
lenght = int(input())
count = width * lenght
while count > 0:
line = input()
if line == "STOP":
break
else:
new_pieces = int(line)
count = count - new_pieces
if count > 0:
print(f"{count} pieces are left.")
else:
print(f"No more cake left! You need {abs(count)} pieces more.")
| width = int(input())
lenght = int(input())
count = width * lenght
while count > 0:
line = input()
if line == 'STOP':
break
else:
new_pieces = int(line)
count = count - new_pieces
if count > 0:
print(f'{count} pieces are left.')
else:
print(f'No more cake left! You need {abs(count)} pieces more.') |
# Program to find GCD of the digits of a number
# Recursive function to return gcd of a and b
def gcd(a, b):
return a if (b == 0) else gcd(b, a % b)
def digitGCD(n):
ans = 0
while n > 0:
ans = gcd(n % 10, ans)
# If at any point GCD is 1, return
if gcd == 1:
return 1
n = n // 10
return ans
n = int(input("Enter a number: "))
print("GCD of the digits of n is", digitGCD(n))
| def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def digit_gcd(n):
ans = 0
while n > 0:
ans = gcd(n % 10, ans)
if gcd == 1:
return 1
n = n // 10
return ans
n = int(input('Enter a number: '))
print('GCD of the digits of n is', digit_gcd(n)) |
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
dic = collections.defaultdict(list)
for s in strs : dic["".join(sorted(s))].append(s)
return list(dic.values())
| class Solution:
def group_anagrams(self, strs: List[str]) -> List[List[str]]:
dic = collections.defaultdict(list)
for s in strs:
dic[''.join(sorted(s))].append(s)
return list(dic.values()) |
#!/usr/bin/env python
wc_arr = [0 for x in range(0, 14000/8)]
def _iswordchar(ch):
return (not (
ch <= 33
or ch == ord(';') or ch == ord('-') or ch == ord('"') or ch == ord('\'')
or (ch >= 35 and ch <= 38)
or (ch >= 40 and ch <= 44)
or (ch >= 46 and ch <= 47)
or ch == 58
or (ch >= 60 and ch <= 63)
or (ch >= 91 and ch <= 94)
or ch == 96
or ch == 124
or (ch >= 126 and ch <= 169 and ch not in [131,138,140,142,154,156,158,159])
or (ch >= 171 and ch <= 177)
or ch == 180
or (ch >= 182 and ch <= 184)
or ch == 187
or ch == 191
or ch == 215
or ch == 247
or (ch >= 697 and ch <= 698)
or (ch >= 706 and ch <= 719)
or (ch >= 722 and ch <= 735)
or (ch >= 741 and ch <= 749)
or (ch >= 884 and ch <= 885)
or ch == 894
or (ch >= 900 and ch <= 901)
or ch == 903
or ch == 1154
or (ch >= 1160 and ch <= 1161)
or (ch >= 1370 and ch <= 1375)
or (ch >= 1417 and ch <= 1418)
or ch == 1470
or ch == 1472
or ch == 1475
or (ch >= 1523 and ch <= 1524)
or ch == 1548
or ch == 1563
or ch == 1567
or (ch >= 1642 and ch <= 1645)
or ch == 1748
or (ch >= 1757 and ch <= 1758)
or ch == 1769
or (ch >= 1789 and ch <= 1790)
or (ch >= 1792 and ch <= 1805)
or ch == 1807
or (ch >= 2404 and ch <= 2405)
or ch == 2416
or (ch >= 2546 and ch <= 2547)
or ch == 2554
or ch == 2928
or ch == 3572
or ch == 3647
or ch == 3663
or (ch >= 3674 and ch <= 3675)
or (ch >= 3841 and ch <= 3863)
or (ch >= 3866 and ch <= 3871)
or ch == 3892
or ch == 3894
or ch == 3896
or (ch >= 3898 and ch <= 3901)
or ch == 3973
or (ch >= 4030 and ch <= 4037)
or (ch >= 4039 and ch <= 4044)
or ch == 4047
or (ch >= 4170 and ch <= 4175)
or ch == 4347
or (ch >= 4961 and ch <= 4968)
or (ch >= 5741 and ch <= 5742)
or ch == 5760
or (ch >= 5787 and ch <= 5788)
or (ch >= 5867 and ch <= 5869)
or (ch >= 6100 and ch <= 6108)
or (ch >= 6144 and ch <= 6158)
or ch == 8125
or (ch >= 8127 and ch <= 8129)
or (ch >= 8141 and ch <= 8143)
or (ch >= 8157 and ch <= 8159)
or (ch >= 8173 and ch <= 8175)
or (ch >= 8189 and ch <= 8190)
or (ch >= 8192 and ch <= 8262)
or (ch >= 8264 and ch <= 8269)
or (ch >= 8298 and ch <= 8303)
or (ch >= 8314 and ch <= 8318)
or (ch >= 8330 and ch <= 8334)
or (ch >= 8352 and ch <= 8367)
or (ch >= 8413 and ch <= 8416)
or (ch >= 8418 and ch <= 8419)
or (ch >= 8448 and ch <= 8449)
or (ch >= 8451 and ch <= 8454)
or (ch >= 8456 and ch <= 8457)
or ch == 8468
or (ch >= 8470 and ch <= 8472)
or (ch >= 8478 and ch <= 8483)
or ch == 8485
or ch == 8487
or ch == 8489
or ch == 8494
or ch == 8498
or ch == 8506
or (ch >= 8592 and ch <= 8691)
or (ch >= 8704 and ch <= 8945)
or (ch >= 8960 and ch <= 9083)
or (ch >= 9085 and ch <= 9114)
or (ch >= 9216 and ch <= 9254)
or (ch >= 9280 and ch <= 9290)
or (ch >= 9372 and ch <= 9449)
or (ch >= 9472 and ch <= 9621)
or (ch >= 9632 and ch <= 9719)
or (ch >= 9728 and ch <= 9747)
or (ch >= 9753 and ch <= 9841)
or (ch >= 9985 and ch <= 9988)
or (ch >= 9990 and ch <= 9993)
or (ch >= 9996 and ch <= 10023)
or (ch >= 10025 and ch <= 10059)
or ch == 10061
or (ch >= 10063 and ch <= 10066)
or ch == 10070
or (ch >= 10072 and ch <= 10078)
or (ch >= 10081 and ch <= 10087)
or ch == 10132
or (ch >= 10136 and ch <= 10159)
or (ch >= 10161 and ch <= 10174)
or (ch >= 10240 and ch <= 10495)
or (ch >= 11904 and ch <= 11929)
or (ch >= 11931 and ch <= 12019)
or (ch >= 12032 and ch <= 12245)
or (ch >= 12272 and ch <= 12283)
or (ch >= 12288 and ch <= 12292)
or (ch >= 12296 and ch <= 12320)
or ch == 12336
or (ch >= 12342 and ch <= 12343)
or (ch >= 12350 and ch <= 12351)
or (ch >= 12443 and ch <= 12444)
or ch == 12539
or (ch >= 12688 and ch <= 12689)
or (ch >= 12694 and ch <= 12703)
or (ch >= 12800 and ch <= 12828)
or (ch >= 12842 and ch <= 12867)
or (ch >= 12896 and ch <= 12923)
or ch == 12927
or (ch >= 12938 and ch <= 12976)
or (ch >= 12992 and ch <= 13003)
or (ch >= 13008 and ch <= 13054)
or (ch >= 13056 and ch <= 13174)
or (ch >= 13179 and ch <= 13277)
or (ch >= 13280 and ch <= 13310)
))
for b in range(0,len(wc_arr)):
for bit in range(0,8):
if _iswordchar(b*8 + bit):
wc_arr[b] |= 1 << bit
f = open("iswordchar.inc", "wt")
print >>f, "static const unsigned char _iswordchar_table[%s] = {" % len(wc_arr)
for i in range(0, len(wc_arr)):
if i>0 and i % 16 == 0:
print >>f
f.write("0x%x" % wc_arr[i])
if i+1 < len(wc_arr):
f.write(",")
print >>f, "};"
print >>f, "static inline bool iswordchar(int ch)"
print >>f, "{"
print >>f, " if (ch == SednaConvertJob::closetag_code || ch == SednaConvertJob::opentag_code)"
print >>f, " return false;"
print >>f, " if (ch >= %s)" % (len(wc_arr)*8)
print >>f, " return true;"
print >>f, " return ((_iswordchar_table[ch >> 3] & (1 << (ch & 7))) != 0);"
print >>f, "}"
f.close()
| wc_arr = [0 for x in range(0, 14000 / 8)]
def _iswordchar(ch):
return not (ch <= 33 or ch == ord(';') or ch == ord('-') or (ch == ord('"')) or (ch == ord("'")) or (ch >= 35 and ch <= 38) or (ch >= 40 and ch <= 44) or (ch >= 46 and ch <= 47) or (ch == 58) or (ch >= 60 and ch <= 63) or (ch >= 91 and ch <= 94) or (ch == 96) or (ch == 124) or (ch >= 126 and ch <= 169 and (ch not in [131, 138, 140, 142, 154, 156, 158, 159])) or (ch >= 171 and ch <= 177) or (ch == 180) or (ch >= 182 and ch <= 184) or (ch == 187) or (ch == 191) or (ch == 215) or (ch == 247) or (ch >= 697 and ch <= 698) or (ch >= 706 and ch <= 719) or (ch >= 722 and ch <= 735) or (ch >= 741 and ch <= 749) or (ch >= 884 and ch <= 885) or (ch == 894) or (ch >= 900 and ch <= 901) or (ch == 903) or (ch == 1154) or (ch >= 1160 and ch <= 1161) or (ch >= 1370 and ch <= 1375) or (ch >= 1417 and ch <= 1418) or (ch == 1470) or (ch == 1472) or (ch == 1475) or (ch >= 1523 and ch <= 1524) or (ch == 1548) or (ch == 1563) or (ch == 1567) or (ch >= 1642 and ch <= 1645) or (ch == 1748) or (ch >= 1757 and ch <= 1758) or (ch == 1769) or (ch >= 1789 and ch <= 1790) or (ch >= 1792 and ch <= 1805) or (ch == 1807) or (ch >= 2404 and ch <= 2405) or (ch == 2416) or (ch >= 2546 and ch <= 2547) or (ch == 2554) or (ch == 2928) or (ch == 3572) or (ch == 3647) or (ch == 3663) or (ch >= 3674 and ch <= 3675) or (ch >= 3841 and ch <= 3863) or (ch >= 3866 and ch <= 3871) or (ch == 3892) or (ch == 3894) or (ch == 3896) or (ch >= 3898 and ch <= 3901) or (ch == 3973) or (ch >= 4030 and ch <= 4037) or (ch >= 4039 and ch <= 4044) or (ch == 4047) or (ch >= 4170 and ch <= 4175) or (ch == 4347) or (ch >= 4961 and ch <= 4968) or (ch >= 5741 and ch <= 5742) or (ch == 5760) or (ch >= 5787 and ch <= 5788) or (ch >= 5867 and ch <= 5869) or (ch >= 6100 and ch <= 6108) or (ch >= 6144 and ch <= 6158) or (ch == 8125) or (ch >= 8127 and ch <= 8129) or (ch >= 8141 and ch <= 8143) or (ch >= 8157 and ch <= 8159) or (ch >= 8173 and ch <= 8175) or (ch >= 8189 and ch <= 8190) or (ch >= 8192 and ch <= 8262) or (ch >= 8264 and ch <= 8269) or (ch >= 8298 and ch <= 8303) or (ch >= 8314 and ch <= 8318) or (ch >= 8330 and ch <= 8334) or (ch >= 8352 and ch <= 8367) or (ch >= 8413 and ch <= 8416) or (ch >= 8418 and ch <= 8419) or (ch >= 8448 and ch <= 8449) or (ch >= 8451 and ch <= 8454) or (ch >= 8456 and ch <= 8457) or (ch == 8468) or (ch >= 8470 and ch <= 8472) or (ch >= 8478 and ch <= 8483) or (ch == 8485) or (ch == 8487) or (ch == 8489) or (ch == 8494) or (ch == 8498) or (ch == 8506) or (ch >= 8592 and ch <= 8691) or (ch >= 8704 and ch <= 8945) or (ch >= 8960 and ch <= 9083) or (ch >= 9085 and ch <= 9114) or (ch >= 9216 and ch <= 9254) or (ch >= 9280 and ch <= 9290) or (ch >= 9372 and ch <= 9449) or (ch >= 9472 and ch <= 9621) or (ch >= 9632 and ch <= 9719) or (ch >= 9728 and ch <= 9747) or (ch >= 9753 and ch <= 9841) or (ch >= 9985 and ch <= 9988) or (ch >= 9990 and ch <= 9993) or (ch >= 9996 and ch <= 10023) or (ch >= 10025 and ch <= 10059) or (ch == 10061) or (ch >= 10063 and ch <= 10066) or (ch == 10070) or (ch >= 10072 and ch <= 10078) or (ch >= 10081 and ch <= 10087) or (ch == 10132) or (ch >= 10136 and ch <= 10159) or (ch >= 10161 and ch <= 10174) or (ch >= 10240 and ch <= 10495) or (ch >= 11904 and ch <= 11929) or (ch >= 11931 and ch <= 12019) or (ch >= 12032 and ch <= 12245) or (ch >= 12272 and ch <= 12283) or (ch >= 12288 and ch <= 12292) or (ch >= 12296 and ch <= 12320) or (ch == 12336) or (ch >= 12342 and ch <= 12343) or (ch >= 12350 and ch <= 12351) or (ch >= 12443 and ch <= 12444) or (ch == 12539) or (ch >= 12688 and ch <= 12689) or (ch >= 12694 and ch <= 12703) or (ch >= 12800 and ch <= 12828) or (ch >= 12842 and ch <= 12867) or (ch >= 12896 and ch <= 12923) or (ch == 12927) or (ch >= 12938 and ch <= 12976) or (ch >= 12992 and ch <= 13003) or (ch >= 13008 and ch <= 13054) or (ch >= 13056 and ch <= 13174) or (ch >= 13179 and ch <= 13277) or (ch >= 13280 and ch <= 13310))
for b in range(0, len(wc_arr)):
for bit in range(0, 8):
if _iswordchar(b * 8 + bit):
wc_arr[b] |= 1 << bit
f = open('iswordchar.inc', 'wt')
(print >> f, 'static const unsigned char _iswordchar_table[%s] = {' % len(wc_arr))
for i in range(0, len(wc_arr)):
if i > 0 and i % 16 == 0:
print >> f
f.write('0x%x' % wc_arr[i])
if i + 1 < len(wc_arr):
f.write(',')
(print >> f, '};')
(print >> f, 'static inline bool iswordchar(int ch)')
(print >> f, '{')
(print >> f, ' if (ch == SednaConvertJob::closetag_code || ch == SednaConvertJob::opentag_code)')
(print >> f, ' return false;')
(print >> f, ' if (ch >= %s)' % (len(wc_arr) * 8))
(print >> f, ' return true;')
(print >> f, ' return ((_iswordchar_table[ch >> 3] & (1 << (ch & 7))) != 0);')
(print >> f, '}')
f.close() |
# The main module for the plugin.
# Note: In ALL plugins there must be a python file called [name-of-plugin].py in a folder called [name-of-plugin]!
def init(page, config):
# This code runs when the generate command is called.
print("Example plugin initialized!")
def site(page):
# This code run whenever a new DarsSite is created.
print("Site created.")
# Doing something with the given site (printing the title)
print("Site title: " + page.title)
def closesite(page):
# This code runs just before the user stops editing the site.
print("Site closed: " + page.title)
| def init(page, config):
print('Example plugin initialized!')
def site(page):
print('Site created.')
print('Site title: ' + page.title)
def closesite(page):
print('Site closed: ' + page.title) |
def belongs_to_file(word, filename):
with open(filename) as f:
l = f.readlines()
for w in l:
if w.strip() == word:
return True
return False
print(belongs_to_file("renard", "words.txt"))
print(belongs_to_file("abbots", "words.txt"))
| def belongs_to_file(word, filename):
with open(filename) as f:
l = f.readlines()
for w in l:
if w.strip() == word:
return True
return False
print(belongs_to_file('renard', 'words.txt'))
print(belongs_to_file('abbots', 'words.txt')) |
class LampTextureSlot:
color_factor = None
object = None
shadow_factor = None
texture_coords = None
use_map_color = None
use_map_shadow = None
| class Lamptextureslot:
color_factor = None
object = None
shadow_factor = None
texture_coords = None
use_map_color = None
use_map_shadow = None |
'''
Created on Feb 24, 2018
@author: danie
'''
| """
Created on Feb 24, 2018
@author: danie
""" |
# Task 05. Faro Shuffle
def faro_shuffle(arr_input):
left_half = deck[:len(arr_input) // 2]
right_half = deck[len(arr_input) // 2:]
new_list = []
for ind in range(len(left_half)):
new_list.append(right_half[ind])
new_list.append(left_half[ind])
return new_list
deck = input().split()
count = int(input())
first = [deck.pop(0)]
last = [deck.pop(len(deck)-1)]
for i in range(1, count+1):
tmp = faro_shuffle(deck)
deck = tmp
print(first+deck+last)
| def faro_shuffle(arr_input):
left_half = deck[:len(arr_input) // 2]
right_half = deck[len(arr_input) // 2:]
new_list = []
for ind in range(len(left_half)):
new_list.append(right_half[ind])
new_list.append(left_half[ind])
return new_list
deck = input().split()
count = int(input())
first = [deck.pop(0)]
last = [deck.pop(len(deck) - 1)]
for i in range(1, count + 1):
tmp = faro_shuffle(deck)
deck = tmp
print(first + deck + last) |
class AccountInfo(object):
_LABELS = ('section',
'organization',
'account-group-code',
'account-code',
'account-group-name',
'account-name',
'amount')
def __init__(self):
self.section = None
self.organization = None
self.account_group_code = None
self.account_code = None
self.account_group_name = None
self.account_name = None
self.amount = None
def equal(self, other):
return self.equal_except_for_amount(other) \
and self.account_amount == other.account_amount
def equal_except_for_amount(self, other):
return self.section == other.section \
and self.organization == other.organization \
and self.account_group_code == other.account_group_code \
and self.account_code == other.account_code \
and self.account_group_name == other.account_group_name \
and self.account_name == other.account_name
def get_category_code(self):
# '95011212999' -> '95'
if self.account_code is None:
return None
return self.account_code[0:2]
def overwrite_by_valid_slots(self, child):
if self._valid_slot(child.section):
self.section = child.section
if self._valid_slot(child.organization):
self.organization = child.organization
if self._valid_slot(child.account_group_code):
self.account_group_code = child.account_group_code
if self._valid_slot(child.account_code):
self.account_code = child.account_code
if self._valid_slot(child.account_group_name):
self.account_group_name = child.account_group_name
if self._valid_slot(child.account_name):
self.account_name = child.account_name
if self._valid_slot(child.amount):
self.amount = child.amount
def print(self):
print('section: %s' % self.section)
print('organization: %s' % self.organization)
print('account-group-code: %s' % self.account_group_code)
print('account-code: %s' % self.account_code)
print('account-group-name: %s' % self.account_group_name)
print('account-name: %s' % self.account_name)
print('amount: %s' % self.amount)
print('valid: %s' % self.valid_info())
def refill_to_empty_slots(self, label):
if self._empty_slot(self.section) and self._valid_slot(label.section):
self.section = label.section
if self._empty_slot(self.organization) and self._valid_slot(label.organization):
self.organization = label.organization
if self._empty_slot(self.account_group_code) and self._valid_slot(label.account_group_code):
self.account_group_code = label.account_group_code
if self._empty_slot(self.account_code) and self._valid_slot(label.account_code):
self.account_code = label.account_code
if self._empty_slot(self.account_group_name) and self._valid_slot(label.account_group_name):
self.account_group_name = label.account_group_name
if self._empty_slot(self.account_name) and self._valid_slot(label.account_name):
self.account_name = label.account_name
if self._empty_slot(self.amount) and self._valid_slot(label.amount):
self.amount = label.amount
def valid_info(self):
return self.account_code != None and len(self.account_code) > 0 \
and self.amount != None and type(self.amount) is int \
and self.account_name != None and len(self.account_name) > 0
def _empty_slot(self, slot):
return slot == None or slot == ''
def _valid_slot(self, slot):
return slot != None and slot != ''
| class Accountinfo(object):
_labels = ('section', 'organization', 'account-group-code', 'account-code', 'account-group-name', 'account-name', 'amount')
def __init__(self):
self.section = None
self.organization = None
self.account_group_code = None
self.account_code = None
self.account_group_name = None
self.account_name = None
self.amount = None
def equal(self, other):
return self.equal_except_for_amount(other) and self.account_amount == other.account_amount
def equal_except_for_amount(self, other):
return self.section == other.section and self.organization == other.organization and (self.account_group_code == other.account_group_code) and (self.account_code == other.account_code) and (self.account_group_name == other.account_group_name) and (self.account_name == other.account_name)
def get_category_code(self):
if self.account_code is None:
return None
return self.account_code[0:2]
def overwrite_by_valid_slots(self, child):
if self._valid_slot(child.section):
self.section = child.section
if self._valid_slot(child.organization):
self.organization = child.organization
if self._valid_slot(child.account_group_code):
self.account_group_code = child.account_group_code
if self._valid_slot(child.account_code):
self.account_code = child.account_code
if self._valid_slot(child.account_group_name):
self.account_group_name = child.account_group_name
if self._valid_slot(child.account_name):
self.account_name = child.account_name
if self._valid_slot(child.amount):
self.amount = child.amount
def print(self):
print('section: %s' % self.section)
print('organization: %s' % self.organization)
print('account-group-code: %s' % self.account_group_code)
print('account-code: %s' % self.account_code)
print('account-group-name: %s' % self.account_group_name)
print('account-name: %s' % self.account_name)
print('amount: %s' % self.amount)
print('valid: %s' % self.valid_info())
def refill_to_empty_slots(self, label):
if self._empty_slot(self.section) and self._valid_slot(label.section):
self.section = label.section
if self._empty_slot(self.organization) and self._valid_slot(label.organization):
self.organization = label.organization
if self._empty_slot(self.account_group_code) and self._valid_slot(label.account_group_code):
self.account_group_code = label.account_group_code
if self._empty_slot(self.account_code) and self._valid_slot(label.account_code):
self.account_code = label.account_code
if self._empty_slot(self.account_group_name) and self._valid_slot(label.account_group_name):
self.account_group_name = label.account_group_name
if self._empty_slot(self.account_name) and self._valid_slot(label.account_name):
self.account_name = label.account_name
if self._empty_slot(self.amount) and self._valid_slot(label.amount):
self.amount = label.amount
def valid_info(self):
return self.account_code != None and len(self.account_code) > 0 and (self.amount != None) and (type(self.amount) is int) and (self.account_name != None) and (len(self.account_name) > 0)
def _empty_slot(self, slot):
return slot == None or slot == ''
def _valid_slot(self, slot):
return slot != None and slot != '' |
class WitEmulator(object):
def __init__(self):
self.name='wit'
def normalise_request_json(self,data):
_data = {}
_data["text"]=data['q'][0]
return _data
def normalise_response_json(self,data):
print('plain response {0}'.format(data))
return [
{
"_text": data["text"],
"confidence": None,
"intent": data["intent"],
"entities" : {key:{"confidence":None,"type":"value","value":val} for key,val in data["entities"].items()}
}
]
| class Witemulator(object):
def __init__(self):
self.name = 'wit'
def normalise_request_json(self, data):
_data = {}
_data['text'] = data['q'][0]
return _data
def normalise_response_json(self, data):
print('plain response {0}'.format(data))
return [{'_text': data['text'], 'confidence': None, 'intent': data['intent'], 'entities': {key: {'confidence': None, 'type': 'value', 'value': val} for (key, val) in data['entities'].items()}}] |
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def bgcd(a, b):
if b == 0:
return a
if a == 0:
return b
if a & 1:
if b & 1:
return bgcd((a - b) >> 1, b)
else:
return bgcd(a, b >> 1)
else:
if b & 1:
return bgcd(a >> 1, b)
else:
return bgcd(a >> 1, b >> 1) << 1
n, m = [int(x) for x in raw_input().split(" ")]
result = 0
for i in range(1, n + 1):
for j in range(1, m + 1):
result += bgcd(i, j)
| def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def bgcd(a, b):
if b == 0:
return a
if a == 0:
return b
if a & 1:
if b & 1:
return bgcd(a - b >> 1, b)
else:
return bgcd(a, b >> 1)
elif b & 1:
return bgcd(a >> 1, b)
else:
return bgcd(a >> 1, b >> 1) << 1
(n, m) = [int(x) for x in raw_input().split(' ')]
result = 0
for i in range(1, n + 1):
for j in range(1, m + 1):
result += bgcd(i, j) |
# Copyright 2013-2021 Aerospike, Inc.
#
# 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 in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class LookupDict:
LOOKUP_MODE = 0
PREFIX_MODE = 1
SUFFIX_MODE = 2
def __init__(self, mode=None):
self._kv = {}
if mode == None:
mode = self.LOOKUP_MODE
self.mode = mode
def __setitem__(self, key, value):
return self.add(key, value)
def __getitem__(self, key):
return self.get(key)
def __delitem__(self, key):
self.remove(key)
def __str__(self):
return str(self._kv)
def __len__(self):
return len(self._kv)
def __contains__(self, k):
try:
self.get_key(k)
return True
except Exception:
return False
def _filter(self, k, keys):
return [key for key in keys if k in key]
def _get_prefix(self, key, min_prefix_len=1):
# There should only be one key found
keys = self._get_key_by_filter(key, self._prefix_filter)
if len(keys) > 1:
raise KeyError("Unable to get prefix for an ambiguous key: '%s'" % (key))
if min_prefix_len == 0:
return ""
# Filter these keys
keys = self._kv.keys()
key = list(key)
prefix = ""
while len(keys) > 1:
prefix += key.pop(0)
keys = self._prefix_filter(prefix, keys)
if len(prefix) >= min_prefix_len:
return prefix
try:
k = keys[0]
if len(k) <= min_prefix_len:
return k
return k[:min_prefix_len]
except Exception:
return prefix
def _prefix_filter(self, prefix, keys):
return [key for key in keys if key.startswith(prefix)]
def _get_suffix(self, key, min_suffix_len=1):
# There should only be one key found
keys = self._get_key_by_filter(key, self._suffix_filter)
if len(keys) > 1:
raise KeyError("Unable to get suffix for an ambiguous key: '%s'" % (key))
if min_suffix_len == 0:
return ""
# Filter these keys
keys = self._kv.keys()
key = list(key)
suffix = ""
while len(keys) > 1:
suffix = key.pop() + suffix
keys = self._suffix_filter(suffix, keys)
if len(suffix) >= min_suffix_len:
return suffix
try:
k = keys[0]
if len(k) <= min_suffix_len:
return k
return k[len(k) - min_suffix_len :]
except Exception:
return suffix
def _suffix_filter(self, suffix, keys):
return [key for key in keys if key.endswith(suffix)]
def _get_key_by_filter(self, k, f):
keys = f(k, self.keys())
if len(keys) == 0:
raise KeyError("Unable to find keys with '%s'" % (k))
return keys
def add(self, key, data):
self._kv[key] = data
def get_key(self, k):
if self.mode == self.PREFIX_MODE:
return self._get_key_by_filter(k, self._prefix_filter)
if self.mode == self.SUFFIX_MODE:
return self._get_key_by_filter(k, self._suffix_filter)
return self._get_key_by_filter(k, self._filter)
def keys(self):
return list(self._kv.keys())
def get(self, k):
keys = self.get_key(k)
return [self._kv[key] for key in keys]
def remove(self, k):
keys = self.get_key(k)
if len(keys) > 1:
raise KeyError("Prefix may not be ambiguous for removal: %s" % (k))
value = self._kv[keys[0]]
del self._kv[keys[0]]
return value
def get_shortname(self, key, min_prefix_len=1, min_suffix_len=1):
if self.mode == self.PREFIX_MODE:
return self._get_prefix(key, min_prefix_len=min_prefix_len)
if self.mode == self.SUFFIX_MODE:
return self._get_suffix(key, min_suffix_len=min_suffix_len)
# There should only be one key found
keys = self.get_key(key)
if len(keys) > 1:
raise KeyError("Unable to get shortname for an ambiguous key: '%s'" % (key))
if min_prefix_len + min_suffix_len >= len(key):
return key
short_format = "%s...%s"
p = self._get_prefix(key, min_prefix_len=min_prefix_len)
s = self._get_suffix(key, min_suffix_len=min_suffix_len)
shortname = short_format % (p, s)
if len(shortname) >= len(key):
return key
return shortname
class PrefixDict(LookupDict):
def __init__(self):
super(PrefixDict, self).__init__(self.PREFIX_MODE)
def get_prefix(self, key):
return self.get_shortname(key)
| class Lookupdict:
lookup_mode = 0
prefix_mode = 1
suffix_mode = 2
def __init__(self, mode=None):
self._kv = {}
if mode == None:
mode = self.LOOKUP_MODE
self.mode = mode
def __setitem__(self, key, value):
return self.add(key, value)
def __getitem__(self, key):
return self.get(key)
def __delitem__(self, key):
self.remove(key)
def __str__(self):
return str(self._kv)
def __len__(self):
return len(self._kv)
def __contains__(self, k):
try:
self.get_key(k)
return True
except Exception:
return False
def _filter(self, k, keys):
return [key for key in keys if k in key]
def _get_prefix(self, key, min_prefix_len=1):
keys = self._get_key_by_filter(key, self._prefix_filter)
if len(keys) > 1:
raise key_error("Unable to get prefix for an ambiguous key: '%s'" % key)
if min_prefix_len == 0:
return ''
keys = self._kv.keys()
key = list(key)
prefix = ''
while len(keys) > 1:
prefix += key.pop(0)
keys = self._prefix_filter(prefix, keys)
if len(prefix) >= min_prefix_len:
return prefix
try:
k = keys[0]
if len(k) <= min_prefix_len:
return k
return k[:min_prefix_len]
except Exception:
return prefix
def _prefix_filter(self, prefix, keys):
return [key for key in keys if key.startswith(prefix)]
def _get_suffix(self, key, min_suffix_len=1):
keys = self._get_key_by_filter(key, self._suffix_filter)
if len(keys) > 1:
raise key_error("Unable to get suffix for an ambiguous key: '%s'" % key)
if min_suffix_len == 0:
return ''
keys = self._kv.keys()
key = list(key)
suffix = ''
while len(keys) > 1:
suffix = key.pop() + suffix
keys = self._suffix_filter(suffix, keys)
if len(suffix) >= min_suffix_len:
return suffix
try:
k = keys[0]
if len(k) <= min_suffix_len:
return k
return k[len(k) - min_suffix_len:]
except Exception:
return suffix
def _suffix_filter(self, suffix, keys):
return [key for key in keys if key.endswith(suffix)]
def _get_key_by_filter(self, k, f):
keys = f(k, self.keys())
if len(keys) == 0:
raise key_error("Unable to find keys with '%s'" % k)
return keys
def add(self, key, data):
self._kv[key] = data
def get_key(self, k):
if self.mode == self.PREFIX_MODE:
return self._get_key_by_filter(k, self._prefix_filter)
if self.mode == self.SUFFIX_MODE:
return self._get_key_by_filter(k, self._suffix_filter)
return self._get_key_by_filter(k, self._filter)
def keys(self):
return list(self._kv.keys())
def get(self, k):
keys = self.get_key(k)
return [self._kv[key] for key in keys]
def remove(self, k):
keys = self.get_key(k)
if len(keys) > 1:
raise key_error('Prefix may not be ambiguous for removal: %s' % k)
value = self._kv[keys[0]]
del self._kv[keys[0]]
return value
def get_shortname(self, key, min_prefix_len=1, min_suffix_len=1):
if self.mode == self.PREFIX_MODE:
return self._get_prefix(key, min_prefix_len=min_prefix_len)
if self.mode == self.SUFFIX_MODE:
return self._get_suffix(key, min_suffix_len=min_suffix_len)
keys = self.get_key(key)
if len(keys) > 1:
raise key_error("Unable to get shortname for an ambiguous key: '%s'" % key)
if min_prefix_len + min_suffix_len >= len(key):
return key
short_format = '%s...%s'
p = self._get_prefix(key, min_prefix_len=min_prefix_len)
s = self._get_suffix(key, min_suffix_len=min_suffix_len)
shortname = short_format % (p, s)
if len(shortname) >= len(key):
return key
return shortname
class Prefixdict(LookupDict):
def __init__(self):
super(PrefixDict, self).__init__(self.PREFIX_MODE)
def get_prefix(self, key):
return self.get_shortname(key) |
'''
Doc Header
'''
def test_this1():
assert 1 == 1, "This should never fail"
| """
Doc Header
"""
def test_this1():
assert 1 == 1, 'This should never fail' |
name = 'stackdandelion'
aliases = ['stackdandelions', 'fixdandelionstacking']
fix_dandelion_stacking_fixed = False
async def run(message):
'Fixes dandelion stacking.'
global fix_dandelion_stacking_fixed
if not fix_dandelion_stacking_fixed:
await message.send('Dandelion stacking has been fixed.')
else:
await message.send('Dandelion stacking is now broken again.')
fix_dandelion_stacking_fixed = not fix_dandelion_stacking_fixed
| name = 'stackdandelion'
aliases = ['stackdandelions', 'fixdandelionstacking']
fix_dandelion_stacking_fixed = False
async def run(message):
"""Fixes dandelion stacking."""
global fix_dandelion_stacking_fixed
if not fix_dandelion_stacking_fixed:
await message.send('Dandelion stacking has been fixed.')
else:
await message.send('Dandelion stacking is now broken again.')
fix_dandelion_stacking_fixed = not fix_dandelion_stacking_fixed |
# Solution for the problem "Constructing a Number"
# https://www.hackerrank.com/contests/hourrank-25/challenges/constructing-a-number/problem
# Number of test cases
t = int(input())
for x in range(t):
# Number of items. We are not actually using this in our approach
n = int(input())
# We are replacing all spaces to get one big number
num = int(input().replace(' ', ''))
# Check whether number is divisible by 3
print("Yes" if num % 3 == 0 else "No") | t = int(input())
for x in range(t):
n = int(input())
num = int(input().replace(' ', ''))
print('Yes' if num % 3 == 0 else 'No') |
name_score = 0
def cal_name_score(n, list_a):
global name_score
name_s = 0
for i in list_a[n]:
name_s += ord(i.lower()) - 96
name_score += name_s * (n+1)
return name_score
if __name__ == '__main__':
with open('p022_names.txt') as f:
name_list = f.readlines()
clear_list = name_list[0].replace('"', '').split(',')
sorted_list = sorted(clear_list)
for i in range(0, len(sorted_list)):
cal_name_score(i, sorted_list)
print(name_score)
| name_score = 0
def cal_name_score(n, list_a):
global name_score
name_s = 0
for i in list_a[n]:
name_s += ord(i.lower()) - 96
name_score += name_s * (n + 1)
return name_score
if __name__ == '__main__':
with open('p022_names.txt') as f:
name_list = f.readlines()
clear_list = name_list[0].replace('"', '').split(',')
sorted_list = sorted(clear_list)
for i in range(0, len(sorted_list)):
cal_name_score(i, sorted_list)
print(name_score) |
# Nested For Loop
# User input for number of rows
rows = int(input("Enter the rows:"))
# Outer loop will print number of rows
for i in range(0, rows+1):
# Inner loop will print number of Astrisk
for j in range(i):
print("*",end = '')
print()
# Program to print number pyramid
rows = int(input("Enter the rows"))
for i in range(0,rows+1):
for j in range(i):
print(i,end = '')
print()
# Nested While Loop
# program uses a nested while loop to find the prime numbers from 2 to 20
i = 2
while(i < 20):
j = 2
while(j <= (i/j)):
if not(i%j): break
j = j + 1
if (j > i/j) : print (i, " is prime")
i = i + 1
print ("Good bye!")
| rows = int(input('Enter the rows:'))
for i in range(0, rows + 1):
for j in range(i):
print('*', end='')
print()
rows = int(input('Enter the rows'))
for i in range(0, rows + 1):
for j in range(i):
print(i, end='')
print()
i = 2
while i < 20:
j = 2
while j <= i / j:
if not i % j:
break
j = j + 1
if j > i / j:
print(i, ' is prime')
i = i + 1
print('Good bye!') |
class Automovel:
cor = ""
marca = ""
qtdegasolina = 45
def __init__(self, c, m):
self.cor = c
self.marca = m
def abastecerCarro(qtdeLitros):
qtdegasolina = qtdegasolina + qtdeLitros
uno = Automovel("Verde","Fiat")
print(uno)
hondafit = Automovel("Preta", "Honda")
print(hondafit)
| class Automovel:
cor = ''
marca = ''
qtdegasolina = 45
def __init__(self, c, m):
self.cor = c
self.marca = m
def abastecer_carro(qtdeLitros):
qtdegasolina = qtdegasolina + qtdeLitros
uno = automovel('Verde', 'Fiat')
print(uno)
hondafit = automovel('Preta', 'Honda')
print(hondafit) |
class Solution:
def decodeString(self, s: str) -> str:
def dfs(s, i):
res, multi = "", 0
while i < len(s):
if '0' <= s[i] <= '9':
multi = multi * 10 + int(s[i])
elif s[i] == '[':
i, tmp = dfs(s, i + 1)
res += multi * tmp
multi = 0
elif s[i] == ']':
return i, res
else:
res += s[i]
i += 1
return res
return dfs(s,0)
class Solution:
def decodeString(self, s: str) -> str:
stack, res, multi = [], "", 0
for c in s:
if c == '[':
stack.append([multi, res])
res, multi = "", 0
elif c == ']':
cur_multi, last_res = stack.pop()
res = last_res + cur_multi * res
elif '0' <= c <= '9':
multi = multi * 10 + int(c)
else:
res += c
return res
| class Solution:
def decode_string(self, s: str) -> str:
def dfs(s, i):
(res, multi) = ('', 0)
while i < len(s):
if '0' <= s[i] <= '9':
multi = multi * 10 + int(s[i])
elif s[i] == '[':
(i, tmp) = dfs(s, i + 1)
res += multi * tmp
multi = 0
elif s[i] == ']':
return (i, res)
else:
res += s[i]
i += 1
return res
return dfs(s, 0)
class Solution:
def decode_string(self, s: str) -> str:
(stack, res, multi) = ([], '', 0)
for c in s:
if c == '[':
stack.append([multi, res])
(res, multi) = ('', 0)
elif c == ']':
(cur_multi, last_res) = stack.pop()
res = last_res + cur_multi * res
elif '0' <= c <= '9':
multi = multi * 10 + int(c)
else:
res += c
return res |
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/test_nbdev_define_in_subfolder/01 define in multiple_nbs 1.ipynb (unless otherwise specified).
__all__ = ['defined_in_multiple_nbs', 'defined_in_multiple_nbs']
# Cell
def defined_in_multiple_nbs():
print("This function was defined on notebook 01")
# Cell
def defined_in_multiple_nbs():
print("This function was defined on notebook 02") | __all__ = ['defined_in_multiple_nbs', 'defined_in_multiple_nbs']
def defined_in_multiple_nbs():
print('This function was defined on notebook 01')
def defined_in_multiple_nbs():
print('This function was defined on notebook 02') |
#!/usr/bin/env python
def part_one() -> None:
buffer = [0]
idx = 0
for i in range(1, 2018):
idx = step(buffer, idx)
buffer.insert(idx + 1, i)
idx += 1
print('Part 1: ', buffer[buffer.index(2017) + 1])
def step(buffer: list, start: int) -> int:
steps = 359
return (steps + start) % len(buffer)
def part_two() -> None:
steps = 359
idx = 0
result = 0
for i in range(1, 50 * (10 ** 6) + 1):
idx = (steps + idx) % i
if idx == 0:
result = i
idx += 1
print('Part 2: ', result)
def main():
part_one()
part_two()
if __name__ == '__main__':
main()
| def part_one() -> None:
buffer = [0]
idx = 0
for i in range(1, 2018):
idx = step(buffer, idx)
buffer.insert(idx + 1, i)
idx += 1
print('Part 1: ', buffer[buffer.index(2017) + 1])
def step(buffer: list, start: int) -> int:
steps = 359
return (steps + start) % len(buffer)
def part_two() -> None:
steps = 359
idx = 0
result = 0
for i in range(1, 50 * 10 ** 6 + 1):
idx = (steps + idx) % i
if idx == 0:
result = i
idx += 1
print('Part 2: ', result)
def main():
part_one()
part_two()
if __name__ == '__main__':
main() |
#page contains functions that locates data about things on the webpage
#add locators
def body_element_locator(browser):
return browser.find_element_by_tag_name('body')
def get_tweets(browser):
return browser.find_elements_by_class_name('tweet-text') | def body_element_locator(browser):
return browser.find_element_by_tag_name('body')
def get_tweets(browser):
return browser.find_elements_by_class_name('tweet-text') |
class WorkflowException(Exception):
pass
class UnsupportedRequirement(WorkflowException):
pass
| class Workflowexception(Exception):
pass
class Unsupportedrequirement(WorkflowException):
pass |
# zop = Zen of python
zop = '''Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!'''
print('"The Zen of Python"\n')
print(zop)
print('')
print('Task 1.\n')
print('The word "better" is here', zop.count('better'), 'times')
print('The word "never" is here', zop.count('never'), 'times')
print('The word "is" is here', zop.count('is'), 'times\n')
print('Task 2.\n')
print(zop.upper())
print('')
print('Task 3.\n')
print(zop.replace('i', '&')) | zop = "Beautiful is better than ugly.\nExplicit is better than implicit.\nSimple is better than complex.\nComplex is better than complicated.\nFlat is better than nested.\nSparse is better than dense.\nReadability counts.\nSpecial cases aren't special enough to break the rules.\nAlthough practicality beats purity.\nErrors should never pass silently.\nUnless explicitly silenced.\nIn the face of ambiguity, refuse the temptation to guess.\nThere should be one-- and preferably only one --obvious way to do it.\nAlthough that way may not be obvious at first unless you're Dutch.\nNow is better than never.\nAlthough never is often better than *right* now.\nIf the implementation is hard to explain, it's a bad idea.\nIf the implementation is easy to explain, it may be a good idea.\nNamespaces are one honking great idea -- let's do more of those!"
print('"The Zen of Python"\n')
print(zop)
print('')
print('Task 1.\n')
print('The word "better" is here', zop.count('better'), 'times')
print('The word "never" is here', zop.count('never'), 'times')
print('The word "is" is here', zop.count('is'), 'times\n')
print('Task 2.\n')
print(zop.upper())
print('')
print('Task 3.\n')
print(zop.replace('i', '&')) |
img_width = 48
img_height = 48
img_depth = 1
batch_size = 32
epochs = 500
| img_width = 48
img_height = 48
img_depth = 1
batch_size = 32
epochs = 500 |
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
occur = {}
count = 0
for i in a:
if i in occur:
count += occur[i] * 2
occur[i] += 1
else:
occur[i] = 1
print(count) | t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
occur = {}
count = 0
for i in a:
if i in occur:
count += occur[i] * 2
occur[i] += 1
else:
occur[i] = 1
print(count) |
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
_ERROR_PAGE_BLOB_SIZE_ALIGNMENT = \
'Invalid page blob size: {0}. ' + \
'The size must be aligned to a 512-byte boundary.'
_ERROR_PAGE_BLOB_START_ALIGNMENT = \
'start_range must align with 512 page size'
_ERROR_PAGE_BLOB_END_ALIGNMENT = \
'end_range must align with 512 page size'
_ERROR_INVALID_BLOCK_ID = \
'All blocks in block list need to have valid block ids.'
_ERROR_INVALID_LEASE_DURATION = \
"lease_duration param needs to be between 15 and 60 or -1."
_ERROR_INVALID_LEASE_BREAK_PERIOD = \
"lease_break_period param needs to be between 0 and 60."
_ERROR_NO_SINGLE_THREAD_CHUNKING = \
'To use blob chunk downloader more than 1 thread must be ' + \
'used since get_blob_to_bytes should be called for single threaded ' + \
'blob downloads.'
| _error_page_blob_size_alignment = 'Invalid page blob size: {0}. ' + 'The size must be aligned to a 512-byte boundary.'
_error_page_blob_start_alignment = 'start_range must align with 512 page size'
_error_page_blob_end_alignment = 'end_range must align with 512 page size'
_error_invalid_block_id = 'All blocks in block list need to have valid block ids.'
_error_invalid_lease_duration = 'lease_duration param needs to be between 15 and 60 or -1.'
_error_invalid_lease_break_period = 'lease_break_period param needs to be between 0 and 60.'
_error_no_single_thread_chunking = 'To use blob chunk downloader more than 1 thread must be ' + 'used since get_blob_to_bytes should be called for single threaded ' + 'blob downloads.' |
img_norm_cfg = dict(
mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5], to_rgb=False)
crop_size = (288, 960)
# KITTI config
kitti_train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', sparse=True),
dict(
type='ColorJitter',
asymmetric_prob=0.0,
brightness=0.4,
contrast=0.4,
saturation=0.4,
hue=0.5 / 3.14),
dict(type='Erase', prob=0.5, bounds=[50, 100], max_num=3),
dict(
type='SpacialTransform',
spacial_prob=0.8,
stretch_prob=0.8,
crop_size=crop_size,
min_scale=-0.2,
max_scale=0.4,
max_stretch=0.2),
dict(type='RandomCrop', crop_size=crop_size),
dict(type='Normalize', **img_norm_cfg),
dict(type='DefaultFormatBundle'),
dict(
type='Collect',
keys=['imgs', 'flow_gt', 'valid'],
meta_keys=[
'filename1', 'filename2', 'ori_filename1', 'ori_filename2',
'filename_flow', 'ori_filename_flow', 'ori_shape', 'img_shape',
'erase_bounds', 'erase_num', 'scale_factor'
])
]
kitti_train = dict(
type='KITTI2015',
data_root='data/kitti2015',
pipeline=kitti_train_pipeline,
test_mode=False)
kitti_test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', sparse=True),
dict(type='InputPad', exponent=3),
dict(type='Normalize', **img_norm_cfg),
dict(type='TestFormatBundle'),
dict(
type='Collect',
keys=['imgs'],
meta_keys=[
'flow_gt', 'valid', 'filename1', 'filename2', 'ori_filename1',
'ori_filename2', 'ori_shape', 'img_shape', 'img_norm_cfg',
'scale_factor', 'pad_shape', 'pad'
])
]
kitti2015_val_test = dict(
type='KITTI2015',
data_root='data/kitti2015',
pipeline=kitti_test_pipeline,
test_mode=True)
data = dict(
train_dataloader=dict(
samples_per_gpu=2,
workers_per_gpu=5,
drop_last=True,
shuffle=True,
persistent_workers=True),
val_dataloader=dict(
samples_per_gpu=1,
workers_per_gpu=5,
shuffle=False,
persistent_workers=True),
test_dataloader=dict(samples_per_gpu=1, workers_per_gpu=2, shuffle=False),
train=kitti_train,
val=kitti2015_val_test,
test=kitti2015_val_test)
| img_norm_cfg = dict(mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5], to_rgb=False)
crop_size = (288, 960)
kitti_train_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', sparse=True), dict(type='ColorJitter', asymmetric_prob=0.0, brightness=0.4, contrast=0.4, saturation=0.4, hue=0.5 / 3.14), dict(type='Erase', prob=0.5, bounds=[50, 100], max_num=3), dict(type='SpacialTransform', spacial_prob=0.8, stretch_prob=0.8, crop_size=crop_size, min_scale=-0.2, max_scale=0.4, max_stretch=0.2), dict(type='RandomCrop', crop_size=crop_size), dict(type='Normalize', **img_norm_cfg), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['imgs', 'flow_gt', 'valid'], meta_keys=['filename1', 'filename2', 'ori_filename1', 'ori_filename2', 'filename_flow', 'ori_filename_flow', 'ori_shape', 'img_shape', 'erase_bounds', 'erase_num', 'scale_factor'])]
kitti_train = dict(type='KITTI2015', data_root='data/kitti2015', pipeline=kitti_train_pipeline, test_mode=False)
kitti_test_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', sparse=True), dict(type='InputPad', exponent=3), dict(type='Normalize', **img_norm_cfg), dict(type='TestFormatBundle'), dict(type='Collect', keys=['imgs'], meta_keys=['flow_gt', 'valid', 'filename1', 'filename2', 'ori_filename1', 'ori_filename2', 'ori_shape', 'img_shape', 'img_norm_cfg', 'scale_factor', 'pad_shape', 'pad'])]
kitti2015_val_test = dict(type='KITTI2015', data_root='data/kitti2015', pipeline=kitti_test_pipeline, test_mode=True)
data = dict(train_dataloader=dict(samples_per_gpu=2, workers_per_gpu=5, drop_last=True, shuffle=True, persistent_workers=True), val_dataloader=dict(samples_per_gpu=1, workers_per_gpu=5, shuffle=False, persistent_workers=True), test_dataloader=dict(samples_per_gpu=1, workers_per_gpu=2, shuffle=False), train=kitti_train, val=kitti2015_val_test, test=kitti2015_val_test) |
maxdepth = 0
def depth(elem, level):
global maxdepth
# your code goes her
# print(elem," :::")
# print(level," [[[]]]")
if (level == maxdepth):
maxdepth += 1
# print(elem)
for child in elem:
# print(child)
depth(child, level + 1)
| maxdepth = 0
def depth(elem, level):
global maxdepth
if level == maxdepth:
maxdepth += 1
for child in elem:
depth(child, level + 1) |
class InvalidKeyType(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
class KeyValueStoreDumpException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs) | class Invalidkeytype(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
class Keyvaluestoredumpexception(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs) |
# This file is automatically generated during the generation of setup.py
# Copyright 2020, Caer
author = 'Jason Dsouza <jasmcaus@gmail.com>'
version = '1.7.8'
full_version = '1.7.8'
release = True
contributors = ['Jason Dsouza <jasmcaus@gmail.com>']
| author = 'Jason Dsouza <jasmcaus@gmail.com>'
version = '1.7.8'
full_version = '1.7.8'
release = True
contributors = ['Jason Dsouza <jasmcaus@gmail.com>'] |
# My solution
def merge_lists(a, b):
res = []
a_cur = 0
b_cur = 0
a_min = a[a_cur]
b_min = b[b_cur]
a_done = False
b_done = False
for i in range(len(a) + len(b)):
if (a_min <= b_min or b_done) and (a_cur < len(a)):
res.append(a_min)
a_cur += 1
if (a_cur < len(a)):
a_min = a[a_cur]
else:
a_done = True
if (a_min >= b_min or a_done) and (b_cur < len(b)):
res.append(b_min)
b_cur += 1
if (a_cur < len(a)):
b_min = b[b_cur]
else:
a_done = True
return res
# Interview Solution
def merge_lists_sol(my_list, alices_list):
# Set up our merged_list
merged_list_size = len(my_list) + len(alices_list)
merged_list = [None] * merged_list_size
current_index_alices = 0
current_index_mine = 0
current_index_merged = 0
while current_index_merged < merged_list_size:
is_my_list_exhausted = current_index_mine >= len(my_list)
is_alices_list_exhausted = current_index_alices >= len(alices_list)
if (not is_my_list_exhausted and
(is_alices_list_exhausted or
my_list[current_index_mine] < alices_list[current_index_alices])):
# Case: next comes from my list
# My list must not be exhausted, and EITHER:
# 1) Alice's list IS exhausted, or
# 2) the current element in my list is less
# than the current element in Alice's list
merged_list[current_index_merged] = my_list[current_index_mine]
current_index_mine += 1
else:
# Case: next comes from Alice's list
merged_list[current_index_merged] = alices_list[current_index_alices]
current_index_alices += 1
current_index_merged += 1
return merged_list
my_list = [3, 4, 6, 10, 11, 15]
alices_list = [1, 5, 8, 12, 14, 19]
print(merge_lists(my_list, alices_list)) | def merge_lists(a, b):
res = []
a_cur = 0
b_cur = 0
a_min = a[a_cur]
b_min = b[b_cur]
a_done = False
b_done = False
for i in range(len(a) + len(b)):
if (a_min <= b_min or b_done) and a_cur < len(a):
res.append(a_min)
a_cur += 1
if a_cur < len(a):
a_min = a[a_cur]
else:
a_done = True
if (a_min >= b_min or a_done) and b_cur < len(b):
res.append(b_min)
b_cur += 1
if a_cur < len(a):
b_min = b[b_cur]
else:
a_done = True
return res
def merge_lists_sol(my_list, alices_list):
merged_list_size = len(my_list) + len(alices_list)
merged_list = [None] * merged_list_size
current_index_alices = 0
current_index_mine = 0
current_index_merged = 0
while current_index_merged < merged_list_size:
is_my_list_exhausted = current_index_mine >= len(my_list)
is_alices_list_exhausted = current_index_alices >= len(alices_list)
if not is_my_list_exhausted and (is_alices_list_exhausted or my_list[current_index_mine] < alices_list[current_index_alices]):
merged_list[current_index_merged] = my_list[current_index_mine]
current_index_mine += 1
else:
merged_list[current_index_merged] = alices_list[current_index_alices]
current_index_alices += 1
current_index_merged += 1
return merged_list
my_list = [3, 4, 6, 10, 11, 15]
alices_list = [1, 5, 8, 12, 14, 19]
print(merge_lists(my_list, alices_list)) |
YOLO = dict()
# Datasets Parameter
YOLO['classes'] = ["aeroplane", "bicycle", "bird", "boat", "bottle"]
YOLO['datasets_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/'
YOLO['anno_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/jinnan_round1_train.json'
YOLO['val_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/jinnan_round1_val.json'
YOLO['pretrain_model'] = './darknet53.conv.74'
YOLO['class_num'] = len(YOLO['classes'])
# Training Parameter
YOLO['save_dir'] = './608/'
YOLO['pretrain_model'] = './darknet53.conv.74'
YOLO['epochs'] = 80
YOLO['epochs_start'] = 0
YOLO['steps'] = [50,60]
YOLO['batch_size'] = 10
YOLO['start_lr'] = 1e-3
YOLO['image_size'] = [608, 608]
YOLO['featmap_size'] = [[19, 19]]
YOLO['anchor'] = [[[2.8523827,2.4452496 ],
[1.3892268,1.8958333 ],
[1.6490009,0.95596665],
[0.7680278,1.3883946 ],
[0.5605738,0.69167805]]]
| yolo = dict()
YOLO['classes'] = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle']
YOLO['datasets_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/'
YOLO['anno_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/jinnan_round1_train.json'
YOLO['val_path'] = '/home/tshzzz/disk_m2/jinnan_round2/datasets/round1_train/jinnan_round1_val.json'
YOLO['pretrain_model'] = './darknet53.conv.74'
YOLO['class_num'] = len(YOLO['classes'])
YOLO['save_dir'] = './608/'
YOLO['pretrain_model'] = './darknet53.conv.74'
YOLO['epochs'] = 80
YOLO['epochs_start'] = 0
YOLO['steps'] = [50, 60]
YOLO['batch_size'] = 10
YOLO['start_lr'] = 0.001
YOLO['image_size'] = [608, 608]
YOLO['featmap_size'] = [[19, 19]]
YOLO['anchor'] = [[[2.8523827, 2.4452496], [1.3892268, 1.8958333], [1.6490009, 0.95596665], [0.7680278, 1.3883946], [0.5605738, 0.69167805]]] |
'''
Manages the ingestion rollback
File: rollback.py
Contains:
Singleton - metaclass for the Singleton pattern implementation
Rollback - a class storing and executing rollback commands
@author: livia
'''
class Singleton(type):
'''Metaclass to create Singleton classes
_instances - saves the instances of classes
'''
# saves the instances of the classes
_instances = {}
def __call__(self, *args, **kwargs):
'''Returns the instance if it already exists, creates a new instance if it doesn't exist
Returns:
an instance of a the class
'''
if self not in self._instances:
self._instances[self] = super(Singleton, self).__call__(*args, **kwargs)
return self._instances[self]
class Rollback(metaclass=Singleton):
'''
Class acting like a stack
can be used to store rollback commands and execute them in reversed order
'''
def __init__(self):
'''Constructor of Rollback
Input Parameter:
logger - a python logging object
'''
self._commands = []
def addCommand(self, command, params={}):
'''Adds a command to the rollback
Input parameters:
command - a command function
params - (default: {}) a keyword dictionary with the command function parameters
'''
newCommand = [command, params]
self._commands.append(newCommand)
def rollback(self):
'''Executes all the saved commands, starting with the last added command (lick a stack)
'''
for cmd in reversed(self._commands):
cmd[0](**cmd[1])
def getCommands(self):
'''Getter for commands
Returns:
commands (list) - a list of the saved commands
'''
return self._commands
| """
Manages the ingestion rollback
File: rollback.py
Contains:
Singleton - metaclass for the Singleton pattern implementation
Rollback - a class storing and executing rollback commands
@author: livia
"""
class Singleton(type):
"""Metaclass to create Singleton classes
_instances - saves the instances of classes
"""
_instances = {}
def __call__(self, *args, **kwargs):
"""Returns the instance if it already exists, creates a new instance if it doesn't exist
Returns:
an instance of a the class
"""
if self not in self._instances:
self._instances[self] = super(Singleton, self).__call__(*args, **kwargs)
return self._instances[self]
class Rollback(metaclass=Singleton):
"""
Class acting like a stack
can be used to store rollback commands and execute them in reversed order
"""
def __init__(self):
"""Constructor of Rollback
Input Parameter:
logger - a python logging object
"""
self._commands = []
def add_command(self, command, params={}):
"""Adds a command to the rollback
Input parameters:
command - a command function
params - (default: {}) a keyword dictionary with the command function parameters
"""
new_command = [command, params]
self._commands.append(newCommand)
def rollback(self):
"""Executes all the saved commands, starting with the last added command (lick a stack)
"""
for cmd in reversed(self._commands):
cmd[0](**cmd[1])
def get_commands(self):
"""Getter for commands
Returns:
commands (list) - a list of the saved commands
"""
return self._commands |
#!/usr/bin/env python3
file_contents = open('in.idf').read().upper()
if 'HVACTEMPLATE' in file_contents:
open('expanded.idf', 'w').write('HI')
open('BasementGHTIn.idf', 'w').write('HI')
open('GHTIn.idf', 'w').write('HI')
open('EPObjects.TXT', 'w').write('HI')
open('RunINPUT.TXT', 'w').write('HI')
open('RunDEBUGOUT.TXT', 'w').write('HI')
open('EPObjects.TXT', 'w').write('HI')
open('BasementGHTIn.idf', 'w').write('HI')
open('MonthlyResults.csv', 'w').write('HI')
open('BasementGHT.idd', 'w').write('HI')
open('SLABINP.TXT', 'w').write('HI')
open('GHTIn.idf', 'w').write('HI')
open('SLABSurfaceTemps.TXT', 'w').write('HI')
open('SLABSplit Surface Temps.TXT', 'w').write('HI')
open('SlabGHT.idd', 'w').write('HI')
| file_contents = open('in.idf').read().upper()
if 'HVACTEMPLATE' in file_contents:
open('expanded.idf', 'w').write('HI')
open('BasementGHTIn.idf', 'w').write('HI')
open('GHTIn.idf', 'w').write('HI')
open('EPObjects.TXT', 'w').write('HI')
open('RunINPUT.TXT', 'w').write('HI')
open('RunDEBUGOUT.TXT', 'w').write('HI')
open('EPObjects.TXT', 'w').write('HI')
open('BasementGHTIn.idf', 'w').write('HI')
open('MonthlyResults.csv', 'w').write('HI')
open('BasementGHT.idd', 'w').write('HI')
open('SLABINP.TXT', 'w').write('HI')
open('GHTIn.idf', 'w').write('HI')
open('SLABSurfaceTemps.TXT', 'w').write('HI')
open('SLABSplit Surface Temps.TXT', 'w').write('HI')
open('SlabGHT.idd', 'w').write('HI') |
BID_VALUE = 'BID_VALUE'
PASS = "PASS"
MIN_BID_VALUE = "MIN_BID_VALUE"
FIRST_ROUND_HONORS_MIN= "FIRST_ROUND_HONORS_MIN"
SECOND_ROUND_HONORS_MIN="SECOND_ROUND_HONORS_MIN"
TRUMP_CARD_ABBREVIATION= "CARD_ABBREVIATION"
| bid_value = 'BID_VALUE'
pass = 'PASS'
min_bid_value = 'MIN_BID_VALUE'
first_round_honors_min = 'FIRST_ROUND_HONORS_MIN'
second_round_honors_min = 'SECOND_ROUND_HONORS_MIN'
trump_card_abbreviation = 'CARD_ABBREVIATION' |
def quick_sort(ARRAY):
ARRAY_LENGTH = len(ARRAY)
if( ARRAY_LENGTH <= 1):
return ARRAY
else:
PIVOT = ARRAY[0]
GREATER = [ element for element in ARRAY[1:] if element > PIVOT ]
LESSER = [ element for element in ARRAY[1:] if element <= PIVOT ]
return quick_sort(LESSER) + [PIVOT] + quick_sort(GREATER) | def quick_sort(ARRAY):
array_length = len(ARRAY)
if ARRAY_LENGTH <= 1:
return ARRAY
else:
pivot = ARRAY[0]
greater = [element for element in ARRAY[1:] if element > PIVOT]
lesser = [element for element in ARRAY[1:] if element <= PIVOT]
return quick_sort(LESSER) + [PIVOT] + quick_sort(GREATER) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.