title: Square Root Of An Integer
signature: func squareRootOfAnInteger(x int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(x int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(x),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(89, 9)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(11, 3)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(14, 3)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(92, 9)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(76, 8)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(63, 7)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(51, 7)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(16, 4)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(83, 9)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(66, 8)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def square_root_of_an_integer(x):
      if ((x == 0) or (x == 1)):
          return x
      i = 1
      result = 1
      while (result <= x):
          i += 1
          result = (i * i)
      return (i - 1)
source_cpp: int square_root_of_an_integer(int x) {
    if ( x == 0 || x == 1 ) return x;
    int i = 1, result = 1;
    while ( result <= x ) {
      i ++;
      result = i * i;
    }
    return i - 1;
  }