title: Dynamic Programming Set 36 Cut A Rope To Maximize Product 1
signature: dynamicProgrammingSet36CutARopeToMaximizeProduct1(n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          62, 
          6973568802)
      }");
  
      print("TEST-1...${driver(
          53, 
          258280326)
      }");
  
      print("TEST-2...${driver(
          8, 
          18)
      }");
  
      print("TEST-3...${driver(
          6, 
          9)
      }");
  
      print("TEST-4...${driver(
          35, 
          354294)
      }");
  
      print("TEST-5...${driver(
          35, 
          354294)
      }");
  
      print("TEST-6...${driver(
          46, 
          19131876)
      }");
  
      print("TEST-7...${driver(
          74, 
          564859072962)
      }");
  
      print("TEST-8...${driver(
          69, 
          94143178827)
      }");
  
      print("TEST-9...${driver(
          3, 
          2)
      }");
  
      return 0;
  }
source_py: def dynamic_programming_set_36_cut_a_rope_to_maximize_product_1(n):
      if ((n == 2) or (n == 3)):
          return (n - 1)
      res = 1
      while (n > 4):
          n -= 3
          res *= 3
      return (n * res)
source_cpp: int dynamic_programming_set_36_cut_a_rope_to_maximize_product_1(int n) {
    if ( n == 2 || n == 3 ) return ( n - 1 );
    int res = 1;
    while ( n > 4 ) {
      n -= 3;
      res *= 3;
    }
    return ( n * res );
  }