Problem 60341. Family Savings Analysis

Given the bank accounts of individuals defined by a list of tuples containing the last name, first name, and savings:
accounts = {
'Smith', 'John', 2500;
'Johnson', 'Fred', 5000;
'Williams', 'Nicolas', 10000;
'Brown', 'Phillip', 1250;
'Jones', 'Alice', 4530;
'Garcia', 'Ahmed', 2200;
'Brown', 'Bernard', 0;
'Johnson', 'Steven', 1670;
'Brown', 'Sylvia', 3;
'Williams', 'Bernard', 300000
};
we consider that individuals with the same last name (first entry of each tuple) are from the same family. If an individual has no attributed income, we consider their savings as zero (as for Bernard Brown).
Write a function that returns the name of the family with the highest strictly positive savings along with the amount of their savings.
Special cases to consider:
  1. If multiple families have the same highest positive savings, the function should return all these families (test 6).
  2. If no family has strictly positive savings, the function should return an empty string for the family name(s) and 0 for the savings (test 5).

Solution Stats

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Sep 16, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers6

Suggested Problems

More from this Author53

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!