title: Minimum Perimeter N Blocks
signature: func minimumPerimeterNBlocks(n int) float64 {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual float64, expected float64) bool {
      return math.Abs(actual - expected) < 1e-09
  }
  
  func driver(n int, expected float64) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(45, 28.832815729997478)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(80, 37.77708763999664)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(54, 29.393876913398138)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(48, 29.712812921102035)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(83, 36.4417343165772)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(68, 32.984845004941285)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(32, 24.62741699796952)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(20, 19.88854381999832)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(68, 32.984845004941285)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(66, 34.49615361854384)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def minimum_perimeter_n_blocks(n):
      l = math.sqrt(n)
      sq = (l * l)
      if (sq == n):
          return (l * 4)
      else:
          row = (n / l)
          perimeter = (2 * (l + row))
          if ((n % l) != 0):
              perimeter += 2
          return perimeter
source_cpp: int minimum_perimeter_n_blocks(int n) {
    int l = sqrt ( n );
    int sq = l * l;
    if ( sq == n ) return l * 4;
    else {
      long long int row = n / l;
      long long int perimeter = 2 * ( l + row );
      if ( n % l != 0 ) perimeter += 2;
      return perimeter;
    }
  }