title: Count Substrings With Same First And Last Characters
signature: def count_substrings_with_same_first_and_last_characters(s):
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;
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(s, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              s),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver("LZIKA", 5)
      print(f"TEST-0...{result}")
  
      result = driver("0556979952", 16)
      print(f"TEST-1...{result}")
  
      result = driver("110010", 12)
      print(f"TEST-2...{result}")
  
      result = driver("kGaYfd", 6)
      print(f"TEST-3...{result}")
  
      result = driver("413567670657", 19)
      print(f"TEST-4...{result}")
  
      result = driver("01001", 9)
      print(f"TEST-5...{result}")
  
      result = driver("EQPuFa", 6)
      print(f"TEST-6...{result}")
  
      result = driver("48848378", 15)
      print(f"TEST-7...{result}")
  
      result = driver("110", 4)
      print(f"TEST-8...{result}")
  
      result = driver("PLehNeP", 9)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: count_substrings_with_same_first_and_last_characters
question_info.test_list: [{"idx": 0, "outputs": 5, "inputs": {"s": "LZIKA"}}, {"idx": 1, "outputs": 16, "inputs": {"s": "0556979952"}}, {"idx": 2, "outputs": 12, "inputs": {"s": "110010"}}, {"idx": 3, "outputs": 6, "inputs": {"s": "kGaYfd"}}, {"idx": 4, "outputs": 19, "inputs": {"s": "413567670657"}}, {"idx": 5, "outputs": 9, "inputs": {"s": "01001"}}, {"idx": 6, "outputs": 6, "inputs": {"s": "EQPuFa"}}, {"idx": 7, "outputs": 15, "inputs": {"s": "48848378"}}, {"idx": 8, "outputs": 4, "inputs": {"s": "110"}}, {"idx": 9, "outputs": 9, "inputs": {"s": "PLehNeP"}}]
question_info.entry_cls_name: Solution