title: N Th Number Whose Sum Of Digits Is Ten
signature: function n_th_number_whose_sum_of_digits_is_ten(n)
source_py: def n_th_number_whose_sum_of_digits_is_ten(n):
      count = 0
      for curr in itertools.count():
          sum = 0
          x = curr
          while x:
              sum = (sum + (x % 10))
              x = (x // 10)
          if (sum == 10):
              count = (count + 1)
          if (count == n):
              return curr
      return (- 1)
source_cpp: int n_th_number_whose_sum_of_digits_is_ten(int n) {
    int count = 0;
    for ( int curr = 1;
    ;
    curr ++ ) {
      int sum = 0;
      for ( int x = curr;
      x > 0;
      x = x / 10 ) sum = sum + x % 10;
      if ( sum == 10 ) count ++;
      if ( count == n ) return curr;
    }
    return - 1;
  }
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(37, 406)
      print(string.format("TEST-0...%s",result))
  
      result = driver(13, 136)
      print(string.format("TEST-1...%s",result))
  
      result = driver(51, 613)
      print(string.format("TEST-2...%s",result))
  
      result = driver(69, 1054)
      print(string.format("TEST-3...%s",result))
  
      result = driver(76, 1126)
      print(string.format("TEST-4...%s",result))
  
      result = driver(10, 109)
      print(string.format("TEST-5...%s",result))
  
      result = driver(97, 1360)
      print(string.format("TEST-6...%s",result))
  
      result = driver(40, 433)
      print(string.format("TEST-7...%s",result))
  
      result = driver(69, 1054)
      print(string.format("TEST-8...%s",result))
  
      result = driver(4, 46)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 406, "inputs": {"n": 37}}, {"idx": 1, "outputs": 136, "inputs": {"n": 13}}, {"idx": 2, "outputs": 613, "inputs": {"n": 51}}, {"idx": 3, "outputs": 1054, "inputs": {"n": 69}}, {"idx": 4, "outputs": 1126, "inputs": {"n": 76}}, {"idx": 5, "outputs": 109, "inputs": {"n": 10}}, {"idx": 6, "outputs": 1360, "inputs": {"n": 97}}, {"idx": 7, "outputs": 433, "inputs": {"n": 40}}, {"idx": 8, "outputs": 1054, "inputs": {"n": 69}}, {"idx": 9, "outputs": 46, "inputs": {"n": 4}}]
question_info.extension: lua
question_info.entry_fn_name: n_th_number_whose_sum_of_digits_is_ten
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__