Last active
November 17, 2015 06:45
-
-
Save Lurunchik/3380d08e06ebd1afdf04 to your computer and use it in GitHub Desktop.
pressindex_task2_junior
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
ДОСТАТОЧНО выполнить любое из заданий. | |
Выполнение 1(рефакторинг 1.py) и 2(хотя бы частично) будет большим плюсом. | |
Разместить результаты в своем git репозитории. | |
1. Выбрать для рефакторинга один из файлов ниже 1.py(полегче) или 2.py(для упоротых) отрефакторить и указать ошибки, предложить варианты улучшения. | |
http://acm.timus.ru/problem.aspx?space=1&num=1846 | |
2. Допустим, есть кравлер https://instagram.com, который должен грузить вообще все сообщения этой соц сети (Включая комментарии). | |
Опишите возможные стратегии загрузки и рассчитайте в соответствии с ними и ограничениями апи необходимое количество(можно приблизительное) | |
ресурсов(приложений, выделенных ip, места для записи данных за 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
def f(a, b): | |
if a == 0: | |
return 1 | |
else: | |
if b == 0: | |
return 1 | |
else: | |
if a > b: | |
return f(a - b, b) | |
if b > a: | |
return f(a, b - a) | |
return b | |
n = raw_input() | |
a = [] | |
for i in range(int(n)): | |
str = raw_input() | |
k = str[2:] | |
if str[0] == '-': | |
i = a.index(k) | |
a = a[:i] + a[i+1:] | |
else: | |
a += [k] | |
r = None | |
for i in range(len(a)): | |
if r == None: | |
r = int(a[i]) | |
else: | |
r = f(r, int(a[i])) | |
print(r) |
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
# необязательная часть | |
class Foo(object): | |
def __new__(c, a1, a2): | |
if a1 == None: | |
return a2 | |
if a1 == 0: | |
return 1 | |
else: | |
if a2 == 0: | |
return 1 | |
else: | |
if a1 > a2: | |
return c(a1 - a2, a2) | |
if a2 > a1: | |
return c(a1, a2 - a1) | |
return a2 | |
class Bar(Foo): | |
def __new__(c, a1, a2): | |
print(a1, a2) | |
if len(a2) > 0: | |
print(a2[1:]) | |
return c(Foo(a1, a2[0]), a2[1:]) | |
return a1 | |
n = raw_input() | |
a = [] | |
for i in range(int(n)): | |
str = raw_input() | |
k = str[2:] | |
if str[0] == '-': | |
i = a.index(int(k)) | |
a = a[:i] + a[i+1:] | |
else: | |
a += [int(k)] | |
print(Bar(None, a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment