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
.idea/ | |
# dotenv | |
.env | |
# virtualenv | |
.venv | |
venv/ | |
ENV/ |
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
.idea/ | |
# Created by https://www.gitignore.io/api/macos,linux,django,python,pycharm | |
### Django ### | |
*.log | |
*.pot | |
*.pyc | |
__pycache__/ | |
local_settings.py |
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 bool_str(str_): | |
list_ = list(str_) | |
tmp_list = [] | |
if list_ and list_[0] != ']' and list_[-1] != '[': | |
for item in list_: | |
if item == '[': | |
tmp_list.append(item) | |
elif item == ']' and tmp_list[-1] == '[': | |
tmp_list.pop() |
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
# Дан массив N и число k <= len(N)/2 | |
# Как разбить массив N на k подмассивов так, | |
# чтобы длина самого длинного и самого короткого | |
# подмассивов отличалась не более чем на 1. | |
def main(arr, n): | |
tmp_arr = [] | |
lenght_arr = len(arr) | |
lenght_sub_arr = lenght_arr // n | |
rem_div = lenght_arr % n |
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
The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. | |
For macOS: | |
brew install libtiff libjpeg webp little-cms2 |
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
Задача 1. Даны два списка, нужно вернуть элементы, которые есть в 1-ом списке, но нет во 2-ом. | |
Оценить эффективность своего решения. | |
list(set(a) - set(b)) | |
Задача 2. Дан массив целых чисел. Нужно удалить из него нули. | |
Можно использовать только О(1) дополнительной памяти. | |
set(a).discard(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
import sys | |
def main(): | |
num_lines = int(input()) | |
output_numbers = [] | |
for i in range(num_lines): | |
line = sys.stdin.readline().rstrip() | |
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 eratoshenes_effective(num): | |
numbers = list(range(num + 1)) | |
numbers[0] = numbers[1] = False | |
for i in range(2, num): | |
if numbers[i]: | |
for j in range(i * i, num + 1, i): | |
numbers[j] = False | |
return numbers |