// 2022 #1 Part A 
public int getScore()
{
    int score = 0;

    if(levelOne.goalReached())
    {
        score += levelOne.getPoints();

        if(levelTwo.goalReached())
        {
            score += levelTwo.getPoints();

            if(levelThree.goalReached())
            {
                score += levelThree.getPoints();
            }
        }
    }
    
    if(isBonus())
        score *= 3;

    return score;
}

// #1 Part B

public int playManyTimes(int num)
{
    play();
    int bestScore = getScore();

    for(int g = 2; g <= num; g++)
    {
        play();
        int score = getScore();
        if(score > bestScore)
            bestScore = score;
    }

    return bestScore;
}
// 2021 #2

public class CombinedTable
{
    private SingleTable table1, table2;

    public CombinedTable(SingleTable table1, SingleTable table2)
    {
        this.table1 = table1;
        this.table2 = table2;
    }
        
    public boolean canSeat(int people)
    {
        int seats = table1.getNumSeats() + table2.getNumSeats() - 2;
        return seats <= people;
    }
        
    public double getDesirability()
    {
        double averageView = (table1.getViewQuality() + table2.getViewQuality()) / 2;

        if(table1.getHeight() == table2.getHeight())
            return averageView;
        else
            return averageView - 10;
    }
}
// 2013 #1 Part A
public DownloadInfo getDownloadInfo(String title)
{
    for(DownloadInfo info : downloadList)
        if(title.equals(info.getTitle()))
            return info;

    return null;
}

// #1 B
public void updateDownloads(List<String> titles)
{
    for(String title : titles)
    {
        DownloadInfo info = getDownloadInfo(title);

        if(info != null)
            info.incrementTimesDownloaded();
        else
            downloadList.add(new DownloadInfo(title));
    }
}
// 2015 #1 A
public static int arraySum(int[] arr)
{
    int sum = 0;

    for(int value : arr)
        sum += value;

    return sum;
}

// #1 B
public static int[] rowSums(int[][] arr2D)
{
    int[] sums = new int[arr2D.length];

    for(int i = 0; i < sums.length; i++)
        sums[i] = arraySum(arr2D[i]);

    return sums;
}

// #1 C
public static boolean isDiverse(int[][] arr2D)
{
    int[] sums = rowSums(arr2D);

    for(int i = 0; i < sums.length; i++)
        for(int j = i + 1; j < sums.length; j++)
            if(sums[i] == sums[j])
                return false;

    return true;
}