Telephone-booth problem solution in c