title: Dynamic Programming Set 36 Cut A Rope To Maximize Product 1
signature: fun dynamicProgrammingSet36CutARopeToMaximizeProduct1(n: Int): Long {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Long, expected:Long):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Long):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(62, 6973568802)
      println("TEST-0...${result}")
      
      result = driver(53, 258280326)
      println("TEST-1...${result}")
      
      result = driver(8, 18)
      println("TEST-2...${result}")
      
      result = driver(6, 9)
      println("TEST-3...${result}")
      
      result = driver(35, 354294)
      println("TEST-4...${result}")
      
      result = driver(35, 354294)
      println("TEST-5...${result}")
      
      result = driver(46, 19131876)
      println("TEST-6...${result}")
      
      result = driver(74, 564859072962)
      println("TEST-7...${result}")
      
      result = driver(69, 94143178827)
      println("TEST-8...${result}")
      
      result = driver(3, 2)
      println("TEST-9...${result}")
      
          
  }
  
  main()
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 );
  }