Let the time taken by B to complete the work be denoted by x days.
Since A takes 6 days less than B to complete the work, the time taken by A to complete the work will be (x - 6) days.
Now, the work done by A in 1 day is 1/(x - 6) and the work done by B in 1 day is 1/x.
When both A and B work together, their combined work rate is the sum of their individual work rates. According to the problem, together they can complete the work in 4 days. Therefore, the combined rate is 1/4.
So, the equation becomes: (1/(x - 6)) + (1/x) = 1/4.
To solve this equation, let's first find a common denominator: (x(x - 6)) on the left-hand side: [(x) + (x - 6)] / (x(x - 6)) = 1/4.
Simplifying the numerator: (2x - 6) / (x(x - 6)) = 1/4.
Now, cross-multiply to eliminate the fraction: 4(2x - 6) = x(x - 6).
Distribute both sides: 8x - 24 = x^2 - 6x.
Move all terms to one side to form a quadratic equation: x^2 - 6x - 8x + 24 = 0.
Simplify: x^2 - 14x + 24 = 0.
Now, solve this quadratic equation using the quadratic formula: x = [-(-14) ± √((-14)^2 - 4(1)(24))] / 2(1).
x = [14 ± √(196 - 96)] / 2.
x = [14 ± √100] / 2.
x = [14 ± 10] / 2.
So, x = (14 + 10) / 2 = 24 / 2 = 12 or x = (14 - 10) / 2 = 4 / 2 = 2.
Since the time taken by B must be positive and reasonable, we discard x = 2 because A would take a negative time to complete the work, which is not possible.
Thus, the time taken by B to finish the work is 12 days.