title: Dynamic Programming Set 36 Cut A Rope To Maximize Product 1
signature: def dynamicProgrammingSet36CutARopeToMaximizeProduct1(n: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Long , expected: Long): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(n: Int, expected: Long): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        62, 
        6973568802L    
      )}")   
  
  
      println(s"TEST-1...${driver(
        53, 
        258280326L    
      )}")   
  
  
      println(s"TEST-2...${driver(
        8, 
        18L    
      )}")   
  
  
      println(s"TEST-3...${driver(
        6, 
        9L    
      )}")   
  
  
      println(s"TEST-4...${driver(
        35, 
        354294L    
      )}")   
  
  
      println(s"TEST-5...${driver(
        35, 
        354294L    
      )}")   
  
  
      println(s"TEST-6...${driver(
        46, 
        19131876L    
      )}")   
  
  
      println(s"TEST-7...${driver(
        74, 
        564859072962L    
      )}")   
  
  
      println(s"TEST-8...${driver(
        69, 
        94143178827L    
      )}")   
  
  
      println(s"TEST-9...${driver(
        3, 
        2L    
      )}")   
  
  }
  
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 );
  }