on the way back ...

17.5 min = 7/24 hr

Let t = walk time in hrs

(7/24) - t = run time in hrs

walks 1/3 of the distance ...

d/3 = 8t ... double this, you get 2d/3 = 16t

runs 2/3 of the distance ...

2d/3 = 12[(7/24) - t]

equate the run distances ...

12[(7/24) - t] = 16t

(7/2) - 12t = 16t

7/2 = 28t

t = 7/56 = 1/8 hr

d/3 = 8t

d = 24t = 24(1/8) = 3 km