au
au copied to clipboard
Try reducing new units when incorporating into common units
See this example:
int main(int, char**) {
std::cout << "1) " << (1 * cm + 1 * mi + 1 * m) << std::endl;
std::cout << "2) " << (1 * cm + 1 * m + 1 * mi) << std::endl;
}
Output:
1) 805177 COM[m, cm, mi]
2) 805177 COM[cm, mi]
In (2), the first addition does not create a common unit, because cm divides m. In (1), by contrast, we start with COM[cm, mi], and then incorporate m. It would be nice if we could check m against each of cm and mi in turn, and simply avoid adding it if it's already taken care of.
We could go even further, and produce COM[cm, mi] when adding COM[m, mi] and cm, effectively replacing m with cm.
Ideas for test cases:
- [x] Include
km + mi + mm--- the first addition creates a common unit, but the second one should "wipe it out" (becausemmis the new common unit). - [x] Phrase each test in terms of "order independence of the resulting unit type" --- that's what we're really after.