title: Zeckendorfs Theorem Non Neighbouring Fibonacci Representation
signature: function zeckendorfs_theorem_non_neighbouring_fibonacci_representation(n)
source_py: def zeckendorfs_theorem_non_neighbouring_fibonacci_representation(n):
      if ((n == 0) or (n == 1)):
          return n
      (f1, f2, f3) = (0, 1, 1)
      while (f3 <= n):
          f1 = f2
          f2 = f3
          f3 = (f1 + f2)
      return f2
source_cpp: int zeckendorfs_theorem_non_neighbouring_fibonacci_representation(int n) {
    if ( n == 0 || n == 1 ) return n;
    int f1 = 0, f2 = 1, f3 = 1;
    while ( f3 <= n ) {
      f1 = f2;
      f2 = f3;
      f3 = f1 + f2;
    }
    return f2;
  }
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(54, 34)
      print(string.format("TEST-0...%s",result))
  
      result = driver(71, 55)
      print(string.format("TEST-1...%s",result))
  
      result = driver(64, 55)
      print(string.format("TEST-2...%s",result))
  
      result = driver(71, 55)
      print(string.format("TEST-3...%s",result))
  
      result = driver(96, 89)
      print(string.format("TEST-4...%s",result))
  
      result = driver(43, 34)
      print(string.format("TEST-5...%s",result))
  
      result = driver(70, 55)
      print(string.format("TEST-6...%s",result))
  
      result = driver(94, 89)
      print(string.format("TEST-7...%s",result))
  
      result = driver(95, 89)
      print(string.format("TEST-8...%s",result))
  
      result = driver(69, 55)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 34, "inputs": {"n": 54}}, {"idx": 1, "outputs": 55, "inputs": {"n": 71}}, {"idx": 2, "outputs": 55, "inputs": {"n": 64}}, {"idx": 3, "outputs": 55, "inputs": {"n": 71}}, {"idx": 4, "outputs": 89, "inputs": {"n": 96}}, {"idx": 5, "outputs": 34, "inputs": {"n": 43}}, {"idx": 6, "outputs": 55, "inputs": {"n": 70}}, {"idx": 7, "outputs": 89, "inputs": {"n": 94}}, {"idx": 8, "outputs": 89, "inputs": {"n": 95}}, {"idx": 9, "outputs": 55, "inputs": {"n": 69}}]
question_info.extension: lua
question_info.entry_fn_name: zeckendorfs_theorem_non_neighbouring_fibonacci_representation
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__