Look at this test:
assert water_sort(["abcc", "abca", "bcab", "", ""]) == 10
Now, look at this sequence:
('', '', 'abca', 'abcc', 'bcab')
('', 'ab', 'abca', 'bcab', 'cc')
('', 'abb', 'abca', 'bca', 'cc')
('', 'abb', 'abc', 'bcaa', 'cc')
('', 'ab', 'abb', 'bcaa', 'ccc')
('', 'a', 'abbb', 'bcaa', 'ccc')
('', 'aaa', 'abbb', 'bc', 'ccc')
('', 'aaa', 'abbb', 'b', 'cccc')
('', 'a', 'aaa', 'bbbb', 'cccc')
('', '', 'aaaa', 'bbbb', 'cccc')
Notice that the first line is the same as in the test, just sorted. That should be irrelevant.
Isn't that a legal sequence? Notice that after each pouring, the sequence has been sorted, which makes it a little difficult to follow, but I hope not too difficult.
BTW, there is another precondition that must be imposed:
No color occurs more times than the capacity of a tube.
Created at: 2024/01/06 14:54; Updated at: 2024/01/06 19:48