Let B be the distance ridden and let W be the distance walked.
$$B+W=186 \quad(1)$$
now speed=distance/time
so time = distance/speed
Time for the bike ride = B/40
Time for walking = W/4
$$\frac{B}{40}+\frac{W}{4}=6$$
multiply both sides by 40 and we have
$$B+10W=240\quad (2)$$
solve equations 1 and 2 simultaneously to get your answers. 