title: Count Substrings With Same First And Last Characters
signature: fun countSubstringsWithSameFirstAndLastCharacters(s: String): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(s: String, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(s), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver("LZIKA", 5)
      println("TEST-0...${result}")
      
      result = driver("0556979952", 16)
      println("TEST-1...${result}")
      
      result = driver("110010", 12)
      println("TEST-2...${result}")
      
      result = driver("kGaYfd", 6)
      println("TEST-3...${result}")
      
      result = driver("413567670657", 19)
      println("TEST-4...${result}")
      
      result = driver("01001", 9)
      println("TEST-5...${result}")
      
      result = driver("EQPuFa", 6)
      println("TEST-6...${result}")
      
      result = driver("48848378", 15)
      println("TEST-7...${result}")
      
      result = driver("110", 4)
      println("TEST-8...${result}")
      
      result = driver("PLehNeP", 9)
      println("TEST-9...${result}")
      
          
  }
  
  main()
source_py: def count_substrings_with_same_first_and_last_characters(s):
      result = 0
      n = len(s)
      for i in range(n):
          for j in range(i, n):
              if (s[i] == s[j]):
                  result = (result + 1)
      return result
source_cpp: int count_substrings_with_same_first_and_last_characters(string s) {
    int result = 0;
    int n = s . length ( );
    for ( int i = 0;
    i < n;
    i ++ ) for ( int j = i;
    j < n;
    j ++ ) if ( s [ i ] == s [ j ] ) result ++;
    return result;
  }