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