Is it possible to have an integer increase once and only once if an object's position is locked onto another object?

I am working more on my door system for my puzzle game, and I am using an int value to relate to the number of puzzles in the level to determine wether or not the door should open, however, I am having some trouble figuring out how to keep the puzzle visibly solved as well as only allowing the int value to increase by 1 for each solved puzzle, here is the code I have as of right now, all help is apreciated!

using UnityEngine;

public class SwitchActivation : MonoBehaviour
{
    public Rigidbody2D rb;
    Rigidbody2D m_Rigidbody;
    public int puzzlecomplete = 0;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
       m_Rigidbody = GetComponent<Rigidbody2D>(); 
    }

    // Update is called once per frame
    void Update()
    {
        if (rb.position == m_Rigidbody.position)
        {
            puzzlecomplete += 1;
            Debug.Log($"puzzlecomplete = {puzzlecomplete}");
        }
    }
}

While your solution is a quick and dirty way to store puzzle states, the important thing is not being able to validate a puzzle state when you shouldn’t be (this is how you get bugs) I would recommend actually using a state machine for the states.

OR bitwise flags:

Regardless of what you choose you should know both of these patterns, as they are extremely important in your journey.