Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions python-open-source-challenge/issue-70.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
# ISSUE 70
#
# Problem:
# Write a program that accepts daily task records containing completed and incomplete tasks and calculates the completion percentage for every day.
#
# This file contains an incomplete implementation.
# Do not rewrite the program from scratch.
#
# Find and repair the mistakes marked with TODO comments.
#
# After repairing the code, run this file and make sure all
# checks pass before submitting your Pull Request.

def completion_by_day(days):
percentages = {}
for day, tasks in days.items():
# TODO: Check how completed tasks are counted.
completed = sum(tasks.values()) - 1
# Count only completed tasks
completed = sum(tasks.values())
total = len(tasks)
# TODO: Check the denominator for a day's completion percentage.
percentages[day] = completed / (total + 1) * 100 if total else 0
# TODO: Check that days with no tasks are retained.

# Calculate percentage using the actual total number of tasks
percentages[day] = completed / total * 100 if total else 0

# Days with no tasks are retained as 0%
return percentages

def check_solution():
Expand All @@ -30,4 +19,4 @@ def check_solution():
print("All checks passed!")

if __name__ == "__main__":
check_solution()
check_solution()
Loading