title: Number Ways Node Make Loop Size K Undirected Complete Connected Graph N Nodes
signature: function numberWaysNodeMakeLoopSizeKUndirectedCompleteConnectedGraphNNodes(n: number, k: number): number {
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.test_list: [{"idx": 0, "outputs": 15.0, "inputs": {"n": 16, "k": 2}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return Math.abs(actual - expected) < 1e-06;
  }
  
  function driver(n: number, k: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(16, 2, 15.0);
    console.log(`TEST-0...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: numberWaysNodeMakeLoopSizeKUndirectedCompleteConnectedGraphNNodes
question_info.test_case_ids: 0
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js