Number of days A required do a piece of work : 9 days

Let number of days B required do a piece of work : X days

Number of hours required by A and B together to do a piece of work : 6 days

Work done by A in one day: \(\frac{1}{9}\)

Work done by B in one day: \(\frac{1}{x}\)

Work done by A and B together in a day : \(\frac{1}{6}\)

Work done by A and B together in one day : \(\frac{1}{9}+\frac{1}{x}=\frac{x\,+\,9}{9x}=\frac{1}{6}\)

\(\therefore \frac{x\,+\,9}{9x}=\frac{1}{6}\)

⇒ 6X + 54 = 9X

⇒ 3X = 54

⇒ X = 54/3 = 18

∴ B can do the work 18 days