title: Minimum Perimeter N Blocks
signature: double minimumPerimeterNBlocks(int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(double actual, double expected){
      return abs(actual - expected) < 1e-09;
  }
  
  string driver(int n, double expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(45, 28.832815729997478); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(80, 37.77708763999664); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(54, 29.393876913398138); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(48, 29.712812921102035); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(83, 36.4417343165772); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(68, 32.984845004941285); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(32, 24.62741699796952); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(20, 19.88854381999832); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(68, 32.984845004941285); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(66, 34.49615361854384); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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;
    }
  }