This file contains hidden or 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 get_intersections(p0, p1): | |
| """ | |
| :type p0: complex | |
| :type p1: complex | |
| :return: | |
| """ |
This file contains hidden or 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 | |
| re.split(r"[ ,.]", s): |
This file contains hidden or 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
| # add | |
| A = 2 + 3j | |
| B = 4 + 5j | |
| print(A + B) | |
| # sub | |
| A = 2 + 3j | |
| B = 4 + 5j | |
| print(A - B) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |