⌘K
Flycodx

Portfolio NAV Growth Analysis Engine

Portfolio NAV Growth Analysis Engine

HardArrays100% accepted

Arjun invested in multiple mutual funds through an Indian brokerage with historical NAV tracking. He has initial NAV, current NAV, and amounts invested in each fund. Calculate portfolio value, overall return percentage, and identify the best performing fund.

Approach

Given funds [[initial_nav, current_nav, invested]]: portfolio_value = sum of round(current/initial*invested); overall_return = (value-total_invested)/total_invested*100; best_fund_return = max (current-initial)/initial*100. Print 'portfolio_value=V,overall_return=R%,best_fund_return=B%' (percent: up to 2 decimals, trailing zeros dropped).

Input

[[100,120,10000],[50,60,20000]]

Output

portfolio_value=36000,overall_return=20%,best_fund_return=20%
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3