St. Andrews is pretty small so you can walk from the furthest away halls to the main campus within 20 minutes, or something like that. Don't know from experience, just open days/info in prospectuses.
St Andrews you can definitely walk anywhere you want. Most of the accomodation is around town, so you're right next to the university. The David Russell Apartments are about a mile and a half/two miles from the town centre, but it is in walking distance. There are plenty of buses too. It's really just the self-catering that's a bit further away, but not by much.