pairs[i] = [a, b] together with ratios[i] means that a / b = ratios[i].
Return True if the facts contradict each other, that is, no choice of numbers for the names satisfies all facts at once, and False otherwise.
Two numbers count as equal when they differ by less than 10⁻⁵. The tests do not hinge on precision: an ordinary float is enough.pairs=[['tea', 'cup'], ['cup', 'jug'], ['tea', 'jug']], ratios=[0.5, 4, 2] → False
The first two facts give tea / jug = 0.5 · 4 = 2, which matches the third. For example tea = 2, cup = 4, jug = 1, so there is no conflict.
pairs=[['x', 'y'], ['y', 'z'], ['x', 'z']], ratios=[3, 2, 5] → True
The first two facts give x / z = 6, but the third says x / z = 5. That is a conflict.
pairs=[['ab', 'ab']], ratios=[1.5] → True
pairs=[['tea', 'cup'], ['cup', 'jug'], ['tea', 'jug']], ratios=[0.5, 4, 2]
False
Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.