In reply to dave_59:
Hi Dave,
Thanks for your response, almost the logic is matching with the needs.
I tried with your logic , seems like casting is not working in constraint.
Below is playground link i tried::
Could you please have a look.
Thanks