This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sorted([(2, 3), (2, 2), (1, 1)]) | |
# => [(1, 1), (2, 2), (2, 3)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
input_text_path = __file__.replace('.py', '.txt') | |
fd = os.open(input_text_path, os.O_RDONLY) | |
os.dup2(fd, sys.stdin.fileno()) | |
f = open('submit.txt', 'w') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import mxnet as mx | |
import numpy as np | |
import mxlib | |
if __name__ == '__main__': | |
# get model | |
mxlib.get_model('http://data.mxnet.io/models/imagenet/resnext/101-layers/resnext-101', 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(n): | |
if n == 2: return True | |
if n < 2 or n % 2 == 0: return False | |
return pow(2, n - 1, n) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
s = 'yahyahooiurhgsbnfkcfhbi' | |
pattern = r'[bcdefgijklmnpqrstuvwxz]' | |
t = re.sub(pattern, '', s) | |
print(t) | |
# => yahhh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> s = 'abacde' | |
>>> s.count('a') | |
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for s in iter(input, "0"): | |
print(s) | |
# Input | |
# 123 | |
# 55 | |
# 1000 | |
# 0 | |
# Output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# buildings[4][3][10] | |
buildings = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 123.456789 | |
b = round(a, 3) | |
print(b) | |
# => 123.457 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = divmod(10, 3) | |
print(a) | |
# => (3, 1) |