The stock market finished a tumultuous week on a quiet note, as major benchmarks generally closed modestly higher while still finishing with substantial losses for the week as a whole. Investors seemed to become slightly calmer about geopolitical tension between the U.S. and North Korea, although news that the two nations have been quietly having discussions over several months rattled some nerves. Also helping the mood was good news from several well-known companies. Community Health Systems (NYSE:CYH), TripAdvisor (NASDAQ:TRIP), and Hostess Brands (NASDAQ:TWNK) were among the best performers on the day. Below, we'll look more closely at these stocks to tell you why they did so well.

Community Health climbs on hospital optimism

Shares of Community Health Systems finished up 23%, rebounding from substantial losses throughout the past couple of weeks. Investors have been nervous about what might happen to hospital operators under potential new healthcare reform efforts, but the bigger cause of trouble for Community Health over the past several years has been a trend toward fewer hospital admissions and the resulting pressure on earnings. After losing more ground in the wake of reporting a second-quarter loss, investors now seem to see signs that Community Health could turn things around, but it will take considerable effort and some good fortune from Washington to get the stock moving in the right direction.

Sign for emergency room and main hospital entrance.

Image source: Getty Images.

TripAdvisor bounces back

TripAdvisor stock rose 6%, moving to a gain for the week after having initially looked like it might suffer a big decline. The travel portal reported its second-quarter financial results earlier in the week, which included a drop in adjusted net income and signs of intense competition in the industry. Yet after initially falling sharply after the news, TripAdvisor stock moved upward to finish higher on the session. Since then, investors have grown more optimistic about TripAdvisor's prospects, apparently focusing on the potential to build up a network effect that would serve to create a competitive advantage for the company. The stock is still down considerably year to date, but some still hope that better times lie ahead for TripAdvisor.

Hostess gets a little sweeter

Finally, shares of Hostess Brands picked up 6%. The maker of snack cakes and other baked goods got a bit of relief from big losses earlier in the week following the company's second-quarter financial report, in which Hostess reported modest gains in revenue and earnings but cut its earnings guidance for the full 2017 fiscal year. Today, investors seemed to realize that some of the issues that Hostess faced during the quarter involved one-time events, and they got more upbeat about the company's ability to meet those challenges and overcome them. Those following the stock will have to wait to see whether Hostess' fundamental results during the current quarter will match up to shareholder optimism looking ahead.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.