A financial insights prototype connected to Shopify Admin receives one week of stock prices for multiple companies. Find the three companies with the highest average stock price over the seven-day period.
Return their zero-based row indices, ordered from highest average to lowest. If two companies have the same average, place the company with the smaller index first.
Implement top_three_companies(prices), where prices is a non-empty 2D array of numbers. Each row represents one company, and each row contains exactly seven daily prices. Return a list containing up to three integer row indices. If fewer than three companies are provided, return all available indices.
You may compare seven-day totals instead of averages because every company has the same number of days.
def top_three_companies(prices):