title: Program To Check If A Given Number Is Lucky All Digits Are Different
signature: function program_to_check_if_a_given_number_is_lucky_all_digits_are_different(n)
source_py: def program_to_check_if_a_given_number_is_lucky_all_digits_are_different(n):
      ar = ([0] * 10)
      while (n > 0):
          digit = math.floor((n % 10))
          if ar[digit]:
              return 0
          ar[digit] = 1
          n = (n / 10)
      return 1
source_cpp: bool program_to_check_if_a_given_number_is_lucky_all_digits_are_different(int n) {
    bool arr [ 10 ];
    for ( int i = 0;
    i < 10;
    i ++ ) arr [ i ] = false;
    while ( n > 0 ) {
      int digit = n % 10;
      if ( arr [ digit ] ) return false;
      arr [ digit ] = true;
      n = n / 10;
    }
    return true;
  }
question_info.entry_fn_name: program_to_check_if_a_given_number_is_lucky_all_digits_are_different
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(474, 0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(9445, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(90, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(30, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(37453, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(27, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(2400, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(98, 0)
      print(string.format("TEST-7...%s",result))
  
      result = driver(46, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver(722, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"n": 474}}, {"idx": 1, "outputs": 0, "inputs": {"n": 9445}}, {"idx": 2, "outputs": 0, "inputs": {"n": 90}}, {"idx": 3, "outputs": 0, "inputs": {"n": 30}}, {"idx": 4, "outputs": 0, "inputs": {"n": 37453}}, {"idx": 5, "outputs": 0, "inputs": {"n": 27}}, {"idx": 6, "outputs": 0, "inputs": {"n": 2400}}, {"idx": 7, "outputs": 0, "inputs": {"n": 98}}, {"idx": 8, "outputs": 0, "inputs": {"n": 46}}, {"idx": 9, "outputs": 0, "inputs": {"n": 722}}]