title: Number Ways Node Make Loop Size K Undirected Complete Connected Graph N Nodes
signature: function number_ways_node_make_loop_size_k_undirected_complete_connected_graph_n_nodes(n, k)
source_py: def number_ways_node_make_loop_size_k_undirected_complete_connected_graph_n_nodes(n, k):
      p = 1
      if (k % 2):
          p = (- 1)
      return ((pow((n - 1), k) + (p * (n - 1))) / n)
source_cpp: int number_ways_node_make_loop_size_k_undirected_complete_connected_graph_n_nodes(int n, int k) {
    int p = 1;
    if ( k % 2 ) p = - 1;
    return ( pow ( n - 1, k ) + p * ( n - 1 ) ) / n;
  }
question_info.entry_fn_name: number_ways_node_make_loop_size_k_undirected_complete_connected_graph_n_nodes
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0']
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 math.abs(actual - expected) < 1e-06
  end
  
  function driver(n, k, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, k) 
      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(16, 2, 15.0)
      print(string.format("TEST-0...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 15.0, "inputs": {"n": 16, "k": 2}}]