Solving system verilog constraint without using constraint

SO I am trying to solve something without the using the constraint keyword. The question is , how would you generate the following 5 <= a+b <= 10 WITHOUT using constraint but you are allowed to use $urandom etc ? Any ideas?

In reply to zuzamen:

interview question?

In reply to zuzamen:

Two ideas

  1. generate random numbers for A and B repeatedly stoping when you get values that meet your constraint.
  2. Build your own constraint solver, e.g. What’s behind Wolfram Alpha.

In reply to zuzamen:

Hi,

Your requirement can be achieved with following code, but i don’t know it as per the guideline or not.

  
  int a,b;
  int min = 5;
  int max = 10;
  initial begin
    while(!((a+b) inside {[min:max]}))
      begin
        a = $urandom_range(1,(max-1));
        b = $urandom_range(1,(max-1));
      end    
  end

Regards,
Mitesh Patel