Display a linear combination: Difference between revisions
Content added Content deleted
(attempt to clarify the task) |
mNo edit summary |
||
Line 5: | Line 5: | ||
Write a function that, when given a finite list of scalars <math>(\alpha^1,\alpha^2,\ldots)</math>, creates a string representing the linear combination <math>\sum_i\alpha^i e_i</math> |
Write a function that, when given a finite list of scalars <math>(\alpha^1,\alpha^2,\ldots)</math>, creates a string representing the linear combination <math>\sum_i\alpha^i e_i</math> |
||
The string should have an explicit format often used in mathematics, that is <math>\alpha^{i_1}e_{i_1}\pm\alpha^{i_2}e_{i_2}\pm\ldots</math> where |
The string should have an explicit format often used in mathematics, that is <math>\alpha^{i_1}e_{i_1}\pm\alpha^{i_2}e_{i_2}\pm\ldots</math> where <math>\alpha^{i_k}\neq 0</math> |
||
In other words, and with examples and counter- |
In other words, and with examples and counter-examples, your output must comply to the following rules: |
||
* you don't show null terms, unless the whole combination is null. For instance while the output "0" is fine, "e(1) + 0*e(3)" or "0 + e(1)" are wrong. |
* you don't show null terms, unless the whole combination is null. For instance while the output "0" is fine, "e(1) + 0*e(3)" or "0 + e(1)" are wrong. |