title: How To Print Maximum Number Of A Using Given Four Keys
signature: function how_to_print_maximum_number_of_a_using_given_four_keys(n)
source_py: def how_to_print_maximum_number_of_a_using_given_four_keys(N):
      if (N <= 6):
          return N
      screen = ([0] * N)
      for n in range(1, 7):
          screen[(n - 1)] = n
      for n in range(7, (N + 1)):
          screen[(n - 1)] = max((2 * screen[(n - 4)]), max((3 * screen[(n - 5)]), (4 * screen[(n - 6)])))
      return screen[(N - 1)]
source_cpp: int how_to_print_maximum_number_of_a_using_given_four_keys(int N) {
    if ( N <= 6 ) return N;
    int screen [ N ];
    int b;
    int n;
    for ( n = 1;
    n <= 6;
    n ++ ) screen [ n - 1 ] = n;
    for ( n = 7;
    n <= N;
    n ++ ) {
      screen [ n - 1 ] = max ( 2 * screen [ n - 4 ], max ( 3 * screen [ n - 5 ], 4 * screen [ n - 6 ] ) );
    }
    return screen [ N - 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(41, 110592)
      print(string.format("TEST-0...%s",result))
  
      result = driver(94, 274877906944)
      print(string.format("TEST-1...%s",result))
  
      result = driver(80, 5435817984)
      print(string.format("TEST-2...%s",result))
  
      result = driver(40, 82944)
      print(string.format("TEST-3...%s",result))
  
      result = driver(76, 1811939328)
      print(string.format("TEST-4...%s",result))
  
      result = driver(5, 5)
      print(string.format("TEST-5...%s",result))
  
      result = driver(43, 196608)
      print(string.format("TEST-6...%s",result))
  
      result = driver(67, 150994944)
      print(string.format("TEST-7...%s",result))
  
      result = driver(24, 1024)
      print(string.format("TEST-8...%s",result))
  
      result = driver(90, 86973087744)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 110592, "inputs": {"n": 41}}, {"idx": 1, "outputs": 274877906944, "inputs": {"n": 94}}, {"idx": 2, "outputs": 5435817984, "inputs": {"n": 80}}, {"idx": 3, "outputs": 82944, "inputs": {"n": 40}}, {"idx": 4, "outputs": 1811939328, "inputs": {"n": 76}}, {"idx": 5, "outputs": 5, "inputs": {"n": 5}}, {"idx": 6, "outputs": 196608, "inputs": {"n": 43}}, {"idx": 7, "outputs": 150994944, "inputs": {"n": 67}}, {"idx": 8, "outputs": 1024, "inputs": {"n": 24}}, {"idx": 9, "outputs": 86973087744, "inputs": {"n": 90}}]
question_info.extension: lua
question_info.entry_fn_name: how_to_print_maximum_number_of_a_using_given_four_keys
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__