title: Number Triangles N Moves
signature: function numberTrianglesNMoves(n: number): number {
source_py: def number_triangles_n_moves(n):
      answer = ([None] * (n + 1))
      answer[0] = 1
      i = 1
      while (i <= n):
          answer[i] = ((answer[(i - 1)] * 3) + 2)
          i = (i + 1)
      return answer[n]
source_cpp: int number_triangles_n_moves(int n) {
    int answer [ n + 1 ] = {
      0 };
      answer [ 0 ] = 1;
      for ( int i = 1;
      i <= n;
      i ++ ) answer [ i ] = answer [ i - 1 ] * 3 + 2;
      return answer [ n ];
    }
question_info.test_list: [{"idx": 0, "outputs": 11118121133111045, "inputs": {"n": 33}}, {"idx": 1, "outputs": 13121, "inputs": {"n": 8}}, {"idx": 2, "outputs": 1457, "inputs": {"n": 6}}]
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(33, 11118121133111045);
    console.log(`TEST-0...${result}`);
  
    result = driver(8, 13121);
    console.log(`TEST-1...${result}`);
  
    result = driver(6, 1457);
    console.log(`TEST-2...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: numberTrianglesNMoves
question_info.test_case_ids: 0 1 2
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js