Skip to content

[BUG] - Problem 585 - No test case to check sum was rounded to 2 decimal places #29725

@sk1401ipm

Description

@sk1401ipm

LeetCode Username

sk1401ipm

Problem Number, Title, and Link

  1. https://leetcode.com/problems/investments-in-2016/description/

Bug Category

Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)

Bug Description

The problem asks for the sum to be rounded to 2 decimal places.
However, at least for submissions using pandas, there were no test cases to check that.

Language Used for Code

Pandas

Code used for Submit/Run operation

def find_investments(insurance: pd.DataFrame) -> pd.DataFrame:
    dup_tiv_2015 = insurance.duplicated(subset='tiv_2015', keep=False)
    dup_loc = insurance.duplicated(subset=['lat', 'lon'], keep=False)
    mask = dup_tiv_2015 & ~dup_loc
    result = insurance[mask]
    sum = result.tiv_2016.sum()  # to meet requirements, this needs to be  sum = round(result.tiv_2016.sum(), 2)
    return pd.DataFrame({ 'tiv_2016': [sum] })

Expected behavior

There should be a test case to check that the sum was rounded to 2 decimal places.

For example (slight modification to example 1)

| pid | tiv_2015 | tiv_2016 | lat | lon |
| --- | -------- | -------- | --- | --- |
| 1   | 10       | 5.12345  | 10  | 10  |
| 2   | 20       | 20       | 20  | 20  |
| 3   | 10       | 30       | 20  | 20  |
| 4   | 10       | 40       | 40  | 40  |

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions