title: Hexagonal Number
signature: function hexagonalNumber(n: number): number {
source_py: def hexagonal_number(n):
      return (n * ((2 * n) - 1))
source_cpp: int hexagonal_number(int n) {
    return n * ( 2 * n - 1 );
  }
question_info.test_list: [{"idx": 0, "outputs": 2850, "inputs": {"n": 38}}, {"idx": 1, "outputs": 3828, "inputs": {"n": 44}}, {"idx": 2, "outputs": 6670, "inputs": {"n": 58}}, {"idx": 3, "outputs": 190, "inputs": {"n": 10}}, {"idx": 4, "outputs": 1891, "inputs": {"n": 31}}, {"idx": 5, "outputs": 5565, "inputs": {"n": 53}}, {"idx": 6, "outputs": 17578, "inputs": {"n": 94}}, {"idx": 7, "outputs": 8128, "inputs": {"n": 64}}, {"idx": 8, "outputs": 10011, "inputs": {"n": 71}}, {"idx": 9, "outputs": 6903, "inputs": {"n": 59}}]
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 convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(38, 2850);
    console.log(`TEST-0...${result}`);
  
    result = driver(44, 3828);
    console.log(`TEST-1...${result}`);
  
    result = driver(58, 6670);
    console.log(`TEST-2...${result}`);
  
    result = driver(10, 190);
    console.log(`TEST-3...${result}`);
  
    result = driver(31, 1891);
    console.log(`TEST-4...${result}`);
  
    result = driver(53, 5565);
    console.log(`TEST-5...${result}`);
  
    result = driver(94, 17578);
    console.log(`TEST-6...${result}`);
  
    result = driver(64, 8128);
    console.log(`TEST-7...${result}`);
  
    result = driver(71, 10011);
    console.log(`TEST-8...${result}`);
  
    result = driver(59, 6903);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: hexagonalNumber
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js