import inspect, sys
print(*inspect.getmembers(sys.modules['__main__'], inspect.isfunction), sep='\n')
$ pip install -e
- и его можно редактировать на лету, без переустановки. let one = ['one', 'two', 'three', 'four', 'five'];
let two = ['a', 'b', 'five', 'c', 'one'];
one.sort();
two.sort();
let i = one.length, j = two.length, three = [];
while (i > 0 && j > 0) {
i--;
j--;
if (one[i] > two[j]) j++;
else if (one[i] < two[j]) i++;
else three.push(one[i]);
}
console.log(three);
Можно воспользоваться библиотекой:const _ = require("lodash");
console.log(_.intersection(one, two));
Можно воспользоваться встроенным классом Set (пусть будет задание на дом).import re
with open(r'C:\json3toster.json', 'r', encoding="utf-8") as fp:
ds = fp.readlines()
d = {"'title'": 0, "'mes'": 1, "'coord'": 2}
print(len(ds))
findall, buf = re.compile(r"'[^']*'").findall, [''] * 3
for i, s in enumerate(ds):
l = findall(s)
while l:
w = l.pop()
buf[d[l.pop()]] = w
ds[i] = '\t'.join(buf)
ds.sort()
a = ''
with open(r'd:/json_fin.json', 'a', encoding='utf-8') as fg:
for s in ds:
title, mes, coord = s.split('\t')
if a != title:
a = title
fg.write(f"{{'title': {title} 'mes': {mes}, 'coord': {coord}}}\n")
def root(x: float, p: int) -> float:
r = x ** (1 / p)
return (r * (p - 1) + x / r ** (p - 1)) / p
print(root(125, 3))
print(root(777 ** 7, 7))