Орлов Сергей Леонидович, 321 группа EvalFormulae 7611 | Антон Щербаков, 523 EvalFormulae 7225 | ||||
---|---|---|---|---|---|
f | 1 | def evalform(formula, *args): | f | 1 | def evalform(formula, *args): |
t | 2 | word = '' | t | 2 | id = '' |
3 | a = set() | 3 | variables = set() | ||
4 | for i in formula: | 4 | for ch in formula: | ||
5 | if i.isalpha(): | 5 | if ch.isalpha(): | ||
6 | word += i | 6 | id += ch | ||
7 | elif word: | 7 | else: | ||
8 | a.add(word) | 8 | if id: | ||
9 | variables.add(id) | ||||
9 | word = '' | 10 | id = '' | ||
10 | if word: | 11 | if id: | ||
11 | a.add(word) | 12 | variables.add(id) | ||
12 | d = dict(zip(sorted(a), args)) | 13 | values = dict(zip(sorted(variables), args)) | ||
13 | return eval(formula, d) | 14 | return eval(formula, values) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|