Your question is Top 3 Companies by Stock Averages. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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):