Python, beginner(logic building)

There are 100100 questions in a paper.

  • Each question carries +3 marks for correct answer,
  • -1 marks for incorrect answer i.e. one mark is deducted for each incorrect answer,
  • 0 marks for an unattempted question.

It is given that Chef received exactly �X (0≤�≤100)(0≤X≤100) marks.
Determine the minimum number of problems Chef marked incorrect.

Hi I could only understand a bit from you help request I hope the below program of mine would help you with your problem.

def calculate_incorrect_marks(total_marks, received_marks):
    if received_marks > total_marks * 3 or received_marks < 0:
        return -1  # Invalid input, marks received exceed the maximum possible or negative
    
    min_incorrect = total_marks  # Initialize minimum incorrect marks as the maximum possible
    
    for incorrect in range(total_marks + 1):
        correct = total_marks - incorrect
        total_received_marks = correct * 3 - incorrect
        if total_received_marks == received_marks:
            min_incorrect = min(min_incorrect, incorrect)
    
    if min_incorrect == total_marks:
        return -1  # No combination of correct and incorrect marks results in the received marks
    
    return min_incorrect

# Example usage:
total_questions = 100100
received_marks = int(input("Enter the marks received by Chef: "))
min_incorrect = calculate_incorrect_marks(total_questions, received_marks)

if min_incorrect == -1:
    print("Invalid input or no combination of marks is possible.")
else:
    print("Minimum number of problems marked incorrect:", min_incorrect)