we know that,
Number of days A required to do piece of work = 9 days
Let us consider number of days B required to do piece of work = X days
Number of hours required by A and B together to do piece of work = 6 days
∴ We can calculate, work done by A in 1 day = 1/9
Work done by B in 1 day = 1/x
Work done by both A and B in a day = 1/6
Work done by both A and B in 1 day= 1/9 + 1/x = x+9/9x
x+9/9x = 1/6
6x + 54 = 9x
3x = 54
x = 54/3
x = 18
∴ B can do the work in 18 days