Any ideas on how to constrain a variable so that there are no repeated adjacent digits in its decimal representation?

For example, 22, 333, 4444444, 1111111111 are not allowed. I created a random helper array with size = number of digits in the variable. Applied the constraint that A[i-1]!= A[i] so that adjacent elements don’t repeat. In post randomize, use this array to form the variable needed. However with this way, I am not able to constraint the variable to a maximum value (limit). Is there any other approach to solving this problem?

In reply to svq:
You can use the sum() reduction method for the Binary Coded Decimal conversion in a constraint instead of using post_randomize().

random_variable == BCD.sum() with (item*10**item.index)

In reply to dave_59:

Thanks Dave. That should work although some simulators dont allow power (**) in constraints.

In reply to svq:

All but one support it on EDAPlayground, and I would consider that a tool bug.