Scott Logic Interview Question

Three bucket problem