title: Count Substrings With Same First And Last Characters
signature: countSubstringsWithSameFirstAndLastCharacters :: String -> Integer
  countSubstringsWithSameFirstAndLastCharacters s = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Integer -> Integer -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: String -> Integer -> String
  driver s expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME s) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver ("LZIKA") (5) )
  
      printf "TEST-1...%s\n" (driver ("0556979952") (16) )
  
      printf "TEST-2...%s\n" (driver ("110010") (12) )
  
      printf "TEST-3...%s\n" (driver ("kGaYfd") (6) )
  
      printf "TEST-4...%s\n" (driver ("413567670657") (19) )
  
      printf "TEST-5...%s\n" (driver ("01001") (9) )
  
      printf "TEST-6...%s\n" (driver ("EQPuFa") (6) )
  
      printf "TEST-7...%s\n" (driver ("48848378") (15) )
  
      printf "TEST-8...%s\n" (driver ("110") (4) )
  
      printf "TEST-9...%s\n" (driver ("PLehNeP") (9) )
  
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;
  }